@vscada/cdn 0.0.1
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/dist/vscada.js +8730 -0
- package/dist/vscada.umd.cjs +45 -0
- package/package.json +34 -0
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
(function(e){typeof define==`function`&&define.amd?define([],e):e()})(function(){var e=[`1.0`],t=globalThis,n=t.ShadowRoot&&(t.ShadyCSS===void 0||t.ShadyCSS.nativeShadow)&&`adoptedStyleSheets`in Document.prototype&&`replace`in CSSStyleSheet.prototype,r=Symbol(),i=new WeakMap,a=class{constructor(e,t,n){if(this._$cssResult$=!0,n!==r)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=e,this.t=t}get styleSheet(){let e=this.o,t=this.t;if(n&&e===void 0){let n=t!==void 0&&t.length===1;n&&(e=i.get(t)),e===void 0&&((this.o=e=new CSSStyleSheet).replaceSync(this.cssText),n&&i.set(t,e))}return e}toString(){return this.cssText}},o=e=>new a(typeof e==`string`?e:e+``,void 0,r),s=(e,...t)=>new a(e.length===1?e[0]:t.reduce((t,n,r)=>t+(e=>{if(!0===e._$cssResult$)return e.cssText;if(typeof e==`number`)return e;throw Error(`Value passed to 'css' function must be a 'css' function result: `+e+`. Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.`)})(n)+e[r+1],e[0]),e,r),c=(e,r)=>{if(n)e.adoptedStyleSheets=r.map(e=>e instanceof CSSStyleSheet?e:e.styleSheet);else for(let n of r){let r=document.createElement(`style`),i=t.litNonce;i!==void 0&&r.setAttribute(`nonce`,i),r.textContent=n.cssText,e.appendChild(r)}},l=n?e=>e:e=>e instanceof CSSStyleSheet?(e=>{let t=``;for(let n of e.cssRules)t+=n.cssText;return o(t)})(e):e,u,{is:d,defineProperty:f,getOwnPropertyDescriptor:p,getOwnPropertyNames:m,getOwnPropertySymbols:h,getPrototypeOf:g}=Object,_=globalThis,v=_.trustedTypes,y=v?v.emptyScript:``,b=_.reactiveElementPolyfillSupport,x=(e,t)=>e,S={toAttribute(e,t){switch(t){case Boolean:e=e?y:null;break;case Object:case Array:e=e==null?e:JSON.stringify(e)}return e},fromAttribute(e,t){let n=e;switch(t){case Boolean:n=e!==null;break;case Number:n=e===null?null:Number(e);break;case Object:case Array:try{n=JSON.parse(e)}catch{n=null}}return n}},C=(e,t)=>!d(e,t),w={attribute:!0,type:String,converter:S,reflect:!1,useDefault:!1,hasChanged:C};(u=Symbol).metadata??(u.metadata=Symbol(`metadata`)),_.litPropertyMetadata??(_.litPropertyMetadata=new WeakMap);var T=class extends HTMLElement{static addInitializer(e){this._$Ei(),(this.l??(this.l=[])).push(e)}static get observedAttributes(){return this.finalize(),this._$Eh&&[...this._$Eh.keys()]}static createProperty(e,t=w){if(t.state&&(t.attribute=!1),this._$Ei(),this.prototype.hasOwnProperty(e)&&((t=Object.create(t)).wrapped=!0),this.elementProperties.set(e,t),!t.noAccessor){let n=Symbol(),r=this.getPropertyDescriptor(e,n,t);r!==void 0&&f(this.prototype,e,r)}}static getPropertyDescriptor(e,t,n){let{get:r,set:i}=p(this.prototype,e)??{get(){return this[t]},set(e){this[t]=e}};return{get:r,set(t){let a=r?.call(this);i?.call(this,t),this.requestUpdate(e,a,n)},configurable:!0,enumerable:!0}}static getPropertyOptions(e){return this.elementProperties.get(e)??w}static _$Ei(){if(this.hasOwnProperty(x(`elementProperties`)))return;let e=g(this);e.finalize(),e.l!==void 0&&(this.l=[...e.l]),this.elementProperties=new Map(e.elementProperties)}static finalize(){if(this.hasOwnProperty(x(`finalized`)))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(x(`properties`))){let e=this.properties,t=[...m(e),...h(e)];for(let n of t)this.createProperty(n,e[n])}let e=this[Symbol.metadata];if(e!==null){let t=litPropertyMetadata.get(e);if(t!==void 0)for(let[e,n]of t)this.elementProperties.set(e,n)}this._$Eh=new Map;for(let[e,t]of this.elementProperties){let n=this._$Eu(e,t);n!==void 0&&this._$Eh.set(n,e)}this.elementStyles=this.finalizeStyles(this.styles)}static finalizeStyles(e){let t=[];if(Array.isArray(e)){let n=new Set(e.flat(1/0).reverse());for(let e of n)t.unshift(l(e))}else e!==void 0&&t.push(l(e));return t}static _$Eu(e,t){let n=t.attribute;return!1===n?void 0:typeof n==`string`?n:typeof e==`string`?e.toLowerCase():void 0}constructor(){super(),this._$Ep=void 0,this.isUpdatePending=!1,this.hasUpdated=!1,this._$Em=null,this._$Ev()}_$Ev(){this._$ES=new Promise(e=>this.enableUpdating=e),this._$AL=new Map,this._$E_(),this.requestUpdate(),this.constructor.l?.forEach(e=>e(this))}addController(e){(this._$EO??(this._$EO=new Set)).add(e),this.renderRoot!==void 0&&this.isConnected&&e.hostConnected?.()}removeController(e){this._$EO?.delete(e)}_$E_(){let e=new Map,t=this.constructor.elementProperties;for(let n of t.keys())this.hasOwnProperty(n)&&(e.set(n,this[n]),delete this[n]);e.size>0&&(this._$Ep=e)}createRenderRoot(){let e=this.shadowRoot??this.attachShadow(this.constructor.shadowRootOptions);return c(e,this.constructor.elementStyles),e}connectedCallback(){this.renderRoot??(this.renderRoot=this.createRenderRoot()),this.enableUpdating(!0),this._$EO?.forEach(e=>e.hostConnected?.())}enableUpdating(e){}disconnectedCallback(){this._$EO?.forEach(e=>e.hostDisconnected?.())}attributeChangedCallback(e,t,n){this._$AK(e,n)}_$ET(e,t){let n=this.constructor.elementProperties.get(e),r=this.constructor._$Eu(e,n);if(r!==void 0&&!0===n.reflect){let i=(n.converter?.toAttribute===void 0?S:n.converter).toAttribute(t,n.type);this._$Em=e,i==null?this.removeAttribute(r):this.setAttribute(r,i),this._$Em=null}}_$AK(e,t){let n=this.constructor,r=n._$Eh.get(e);if(r!==void 0&&this._$Em!==r){let e=n.getPropertyOptions(r),i=typeof e.converter==`function`?{fromAttribute:e.converter}:e.converter?.fromAttribute===void 0?S:e.converter;this._$Em=r;let a=i.fromAttribute(t,e.type);this[r]=a??this._$Ej?.get(r)??a,this._$Em=null}}requestUpdate(e,t,n,r=!1,i){if(e!==void 0){let a=this.constructor;if(!1===r&&(i=this[e]),n??(n=a.getPropertyOptions(e)),!((n.hasChanged??C)(i,t)||n.useDefault&&n.reflect&&i===this._$Ej?.get(e)&&!this.hasAttribute(a._$Eu(e,n))))return;this.C(e,t,n)}!1===this.isUpdatePending&&(this._$ES=this._$EP())}C(e,t,{useDefault:n,reflect:r,wrapped:i},a){n&&!(this._$Ej??(this._$Ej=new Map)).has(e)&&(this._$Ej.set(e,a??t??this[e]),!0!==i||a!==void 0)||(this._$AL.has(e)||(this.hasUpdated||n||(t=void 0),this._$AL.set(e,t)),!0===r&&this._$Em!==e&&(this._$Eq??(this._$Eq=new Set)).add(e))}async _$EP(){this.isUpdatePending=!0;try{await this._$ES}catch(e){Promise.reject(e)}let e=this.scheduleUpdate();return e!=null&&await e,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){if(!this.isUpdatePending)return;if(!this.hasUpdated){if(this.renderRoot??(this.renderRoot=this.createRenderRoot()),this._$Ep){for(let[e,t]of this._$Ep)this[e]=t;this._$Ep=void 0}let e=this.constructor.elementProperties;if(e.size>0)for(let[t,n]of e){let{wrapped:e}=n,r=this[t];!0!==e||this._$AL.has(t)||r===void 0||this.C(t,void 0,n,r)}}let e=!1,t=this._$AL;try{e=this.shouldUpdate(t),e?(this.willUpdate(t),this._$EO?.forEach(e=>e.hostUpdate?.()),this.update(t)):this._$EM()}catch(t){throw e=!1,this._$EM(),t}e&&this._$AE(t)}willUpdate(e){}_$AE(e){this._$EO?.forEach(e=>e.hostUpdated?.()),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(e)),this.updated(e)}_$EM(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$ES}shouldUpdate(e){return!0}update(e){this._$Eq&&(this._$Eq=this._$Eq.forEach(e=>this._$ET(e,this[e]))),this._$EM()}updated(e){}firstUpdated(e){}};T.elementStyles=[],T.shadowRootOptions={mode:`open`},T[x(`elementProperties`)]=new Map,T[x(`finalized`)]=new Map,b?.({ReactiveElement:T}),(_.reactiveElementVersions??(_.reactiveElementVersions=[])).push(`2.1.2`);var E=globalThis,D=e=>e,ee=E.trustedTypes,te=ee?ee.createPolicy(`lit-html`,{createHTML:e=>e}):void 0,ne=`$lit$`,re=`lit$${Math.random().toFixed(9).slice(2)}$`,ie=`?`+re,ae=`<${ie}>`,oe=document,se=()=>oe.createComment(``),ce=e=>e===null||typeof e!=`object`&&typeof e!=`function`,le=Array.isArray,ue=e=>le(e)||typeof e?.[Symbol.iterator]==`function`,de=`[
|
|
2
|
+
\f\r]`,fe=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,pe=/-->/g,me=/>/g,he=RegExp(`>|${de}(?:([^\\s"'>=/]+)(${de}*=${de}*(?:[^ \t\n\f\r"'\`<>=]|("|')|))|$)`,`g`),ge=/'/g,_e=/"/g,ve=/^(?:script|style|textarea|title)$/i,ye=(e=>(t,...n)=>({_$litType$:e,strings:t,values:n}))(1),be=Symbol.for(`lit-noChange`),O=Symbol.for(`lit-nothing`),xe=new WeakMap,Se=oe.createTreeWalker(oe,129);function Ce(e,t){if(!le(e)||!e.hasOwnProperty(`raw`))throw Error(`invalid template strings array`);return te===void 0?t:te.createHTML(t)}var we=(e,t)=>{let n=e.length-1,r=[],i,a=t===2?`<svg>`:t===3?`<math>`:``,o=fe;for(let t=0;t<n;t++){let n=e[t],s,c,l=-1,u=0;for(;u<n.length&&(o.lastIndex=u,c=o.exec(n),c!==null);)u=o.lastIndex,o===fe?c[1]===`!--`?o=pe:c[1]===void 0?c[2]===void 0?c[3]!==void 0&&(o=he):(ve.test(c[2])&&(i=RegExp(`</`+c[2],`g`)),o=he):o=me:o===he?c[0]===`>`?(o=i??fe,l=-1):c[1]===void 0?l=-2:(l=o.lastIndex-c[2].length,s=c[1],o=c[3]===void 0?he:c[3]===`"`?_e:ge):o===_e||o===ge?o=he:o===pe||o===me?o=fe:(o=he,i=void 0);let d=o===he&&e[t+1].startsWith(`/>`)?` `:``;a+=o===fe?n+ae:l>=0?(r.push(s),n.slice(0,l)+ne+n.slice(l)+re+d):n+re+(l===-2?t:d)}return[Ce(e,a+(e[n]||`<?>`)+(t===2?`</svg>`:t===3?`</math>`:``)),r]},Te=class e{constructor({strings:t,_$litType$:n},r){let i;this.parts=[];let a=0,o=0,s=t.length-1,c=this.parts,[l,u]=we(t,n);if(this.el=e.createElement(l,r),Se.currentNode=this.el.content,n===2||n===3){let e=this.el.content.firstChild;e.replaceWith(...e.childNodes)}for(;(i=Se.nextNode())!==null&&c.length<s;){if(i.nodeType===1){if(i.hasAttributes())for(let e of i.getAttributeNames())if(e.endsWith(ne)){let t=u[o++],n=i.getAttribute(e).split(re),r=/([.?@])?(.*)/.exec(t);c.push({type:1,index:a,name:r[2],strings:n,ctor:r[1]===`.`?Ae:r[1]===`?`?je:r[1]===`@`?Me:ke}),i.removeAttribute(e)}else e.startsWith(re)&&(c.push({type:6,index:a}),i.removeAttribute(e));if(ve.test(i.tagName)){let e=i.textContent.split(re),t=e.length-1;if(t>0){i.textContent=ee?ee.emptyScript:``;for(let n=0;n<t;n++)i.append(e[n],se()),Se.nextNode(),c.push({type:2,index:++a});i.append(e[t],se())}}}else if(i.nodeType===8)if(i.data===ie)c.push({type:2,index:a});else{let e=-1;for(;(e=i.data.indexOf(re,e+1))!==-1;)c.push({type:7,index:a}),e+=re.length-1}a++}}static createElement(e,t){let n=oe.createElement(`template`);return n.innerHTML=e,n}};function Ee(e,t,n=e,r){if(t===be)return t;let i=r===void 0?n._$Cl:n._$Co?.[r],a=ce(t)?void 0:t._$litDirective$;return i?.constructor!==a&&(i?._$AO?.(!1),a===void 0?i=void 0:(i=new a(e),i._$AT(e,n,r)),r===void 0?n._$Cl=i:(n._$Co??(n._$Co=[]))[r]=i),i!==void 0&&(t=Ee(e,i._$AS(e,t.values),i,r)),t}var De=class{constructor(e,t){this._$AV=[],this._$AN=void 0,this._$AD=e,this._$AM=t}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}u(e){let{el:{content:t},parts:n}=this._$AD,r=(e?.creationScope??oe).importNode(t,!0);Se.currentNode=r;let i=Se.nextNode(),a=0,o=0,s=n[0];for(;s!==void 0;){if(a===s.index){let t;s.type===2?t=new Oe(i,i.nextSibling,this,e):s.type===1?t=new s.ctor(i,s.name,s.strings,this,e):s.type===6&&(t=new Ne(i,this,e)),this._$AV.push(t),s=n[++o]}a!==s?.index&&(i=Se.nextNode(),a++)}return Se.currentNode=oe,r}p(e){let t=0;for(let n of this._$AV)n!==void 0&&(n.strings===void 0?n._$AI(e[t]):(n._$AI(e,n,t),t+=n.strings.length-2)),t++}},Oe=class e{get _$AU(){return this._$AM?._$AU??this._$Cv}constructor(e,t,n,r){this.type=2,this._$AH=O,this._$AN=void 0,this._$AA=e,this._$AB=t,this._$AM=n,this.options=r,this._$Cv=r?.isConnected??!0}get parentNode(){let e=this._$AA.parentNode,t=this._$AM;return t!==void 0&&e?.nodeType===11&&(e=t.parentNode),e}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(e,t=this){e=Ee(this,e,t),ce(e)?e===O||e==null||e===``?(this._$AH!==O&&this._$AR(),this._$AH=O):e!==this._$AH&&e!==be&&this._(e):e._$litType$===void 0?e.nodeType===void 0?ue(e)?this.k(e):this._(e):this.T(e):this.$(e)}O(e){return this._$AA.parentNode.insertBefore(e,this._$AB)}T(e){this._$AH!==e&&(this._$AR(),this._$AH=this.O(e))}_(e){this._$AH!==O&&ce(this._$AH)?this._$AA.nextSibling.data=e:this.T(oe.createTextNode(e)),this._$AH=e}$(e){let{values:t,_$litType$:n}=e,r=typeof n==`number`?this._$AC(e):(n.el===void 0&&(n.el=Te.createElement(Ce(n.h,n.h[0]),this.options)),n);if(this._$AH?._$AD===r)this._$AH.p(t);else{let e=new De(r,this),n=e.u(this.options);e.p(t),this.T(n),this._$AH=e}}_$AC(e){let t=xe.get(e.strings);return t===void 0&&xe.set(e.strings,t=new Te(e)),t}k(t){le(this._$AH)||(this._$AH=[],this._$AR());let n=this._$AH,r,i=0;for(let a of t)i===n.length?n.push(r=new e(this.O(se()),this.O(se()),this,this.options)):r=n[i],r._$AI(a),i++;i<n.length&&(this._$AR(r&&r._$AB.nextSibling,i),n.length=i)}_$AR(e=this._$AA.nextSibling,t){for(this._$AP?.(!1,!0,t);e!==this._$AB;){let t=D(e).nextSibling;D(e).remove(),e=t}}setConnected(e){this._$AM===void 0&&(this._$Cv=e,this._$AP?.(e))}},ke=class{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(e,t,n,r,i){this.type=1,this._$AH=O,this._$AN=void 0,this.element=e,this.name=t,this._$AM=r,this.options=i,n.length>2||n[0]!==``||n[1]!==``?(this._$AH=Array(n.length-1).fill(new String),this.strings=n):this._$AH=O}_$AI(e,t=this,n,r){let i=this.strings,a=!1;if(i===void 0)e=Ee(this,e,t,0),a=!ce(e)||e!==this._$AH&&e!==be,a&&(this._$AH=e);else{let r=e,o,s;for(e=i[0],o=0;o<i.length-1;o++)s=Ee(this,r[n+o],t,o),s===be&&(s=this._$AH[o]),a||(a=!ce(s)||s!==this._$AH[o]),s===O?e=O:e!==O&&(e+=(s??``)+i[o+1]),this._$AH[o]=s}a&&!r&&this.j(e)}j(e){e===O?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,e??``)}},Ae=class extends ke{constructor(){super(...arguments),this.type=3}j(e){this.element[this.name]=e===O?void 0:e}},je=class extends ke{constructor(){super(...arguments),this.type=4}j(e){this.element.toggleAttribute(this.name,!!e&&e!==O)}},Me=class extends ke{constructor(e,t,n,r,i){super(e,t,n,r,i),this.type=5}_$AI(e,t=this){if((e=Ee(this,e,t,0)??O)===be)return;let n=this._$AH,r=e===O&&n!==O||e.capture!==n.capture||e.once!==n.once||e.passive!==n.passive,i=e!==O&&(n===O||r);r&&this.element.removeEventListener(this.name,this,n),i&&this.element.addEventListener(this.name,this,e),this._$AH=e}handleEvent(e){typeof this._$AH==`function`?this._$AH.call(this.options?.host??this.element,e):this._$AH.handleEvent(e)}},Ne=class{constructor(e,t,n){this.element=e,this.type=6,this._$AN=void 0,this._$AM=t,this.options=n}get _$AU(){return this._$AM._$AU}_$AI(e){Ee(this,e)}},Pe=E.litHtmlPolyfillSupport;Pe?.(Te,Oe),(E.litHtmlVersions??(E.litHtmlVersions=[])).push(`3.3.3`);var Fe=(e,t,n)=>{let r=n?.renderBefore??t,i=r._$litPart$;if(i===void 0){let e=n?.renderBefore??null;r._$litPart$=i=new Oe(t.insertBefore(se(),e),e,void 0,n??{})}return i._$AI(e),i},Ie=globalThis,Le=class extends T{constructor(){super(...arguments),this.renderOptions={host:this},this._$Do=void 0}createRenderRoot(){var e;let t=super.createRenderRoot();return(e=this.renderOptions).renderBefore??(e.renderBefore=t.firstChild),t}update(e){let t=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(e),this._$Do=Fe(t,this.renderRoot,this.renderOptions)}connectedCallback(){super.connectedCallback(),this._$Do?.setConnected(!0)}disconnectedCallback(){super.disconnectedCallback(),this._$Do?.setConnected(!1)}render(){return be}};Le._$litElement$=!0,Le.finalized=!0,Ie.litElementHydrateSupport?.({LitElement:Le});var Re=Ie.litElementPolyfillSupport;Re?.({LitElement:Le}),(Ie.litElementVersions??(Ie.litElementVersions=[])).push(`4.2.2`);function k(e,t,n){return{code:e,message:t,path:n}}var ze=new Set(e),Be=new Set([`off-page`,`svg-import`]);function A(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Ve(e){return A(e)&&typeof e.x==`number`&&Number.isFinite(e.x)&&typeof e.y==`number`&&Number.isFinite(e.y)&&typeof e.dir==`string`&&[`up`,`down`,`left`,`right`].includes(e.dir)}function He(e,t){if(e===void 0)return null;if(!A(e))return k(`BAD_SHAPE`,`${t}.ports must be an object of named ports`,`${t}.ports`);for(let[n,r]of Object.entries(e))if(!Ve(r))return k(`BAD_SHAPE`,`${t}.ports.${n} must be { x: number, y: number, dir: 'up'|'down'|'left'|'right' }`,`${t}.ports.${n}`);return null}function Ue(e,t){if(!A(e))return{ok:!1,error:k(`BAD_SHAPE`,`Scene must be an object`,``)};if(e.version===void 0||e.version===null||e.version===``)return{ok:!1,error:k(`MISSING_VERSION`,`Scene is missing required "version" field`,`version`)};if(typeof e.version!=`string`||!ze.has(e.version))return{ok:!1,error:k(`UNSUPPORTED_VERSION`,`Scene version "${String(e.version)}" is not supported`,`version`)};if(e.id===void 0||typeof e.id!=`string`||e.id.length===0)return{ok:!1,error:k(`BAD_SHAPE`,`Scene is missing required string "id"`,`id`)};if(!A(e.canvas)||typeof e.canvas.width!=`number`||!Number.isFinite(e.canvas.width)||typeof e.canvas.height!=`number`||!Number.isFinite(e.canvas.height))return{ok:!1,error:k(`BAD_SHAPE`,`Scene "canvas" must be { width: number, height: number }`,`canvas`)};let n=e.elements??[];if(!Array.isArray(n))return{ok:!1,error:k(`BAD_SHAPE`,`Scene "elements" must be an array`,`elements`)};let r=e.groups??[];if(!Array.isArray(r))return{ok:!1,error:k(`BAD_SHAPE`,`Scene "groups" must be an array`,`groups`)};let i=e.connections??[];if(!Array.isArray(i))return{ok:!1,error:k(`BAD_SHAPE`,`Scene "connections" must be an array`,`connections`)};let a=[];for(let e=0;e<n.length;e++){let t=n[e],r=`elements[${e}]`;if(!A(t)||typeof t.id!=`string`||t.id.length===0)return{ok:!1,error:k(`BAD_SHAPE`,`${r} must be an object with a non-empty string "id"`,`${r}.id`)};if(typeof t.type!=`string`||t.type.length===0)return{ok:!1,error:k(`BAD_SHAPE`,`${r} must declare a non-empty string "type"`,`${r}.type`)};let i=He(t.ports,r);if(i)return{ok:!1,error:i};a.push({id:t.id,type:t.type,ports:A(t.ports)?t.ports:{}})}for(let e=0;e<r.length;e++){let t=r[e],n=`groups[${e}]`;if(!A(t)||typeof t.id!=`string`||t.id.length===0)return{ok:!1,error:k(`BAD_SHAPE`,`${n} must be an object with a non-empty string "id"`,`${n}.id`)};if(t.children!==void 0&&!Array.isArray(t.children))return{ok:!1,error:k(`BAD_SHAPE`,`${n}.children must be an array of element ids`,`${n}.children`)};let i=He(t.ports,n);if(i)return{ok:!1,error:i};a.push({id:t.id,type:`group`,ports:A(t.ports)?t.ports:{}})}let o=new Map;for(let e of a){if(o.get(e.id)!==void 0)return{ok:!1,error:k(`DUPLICATE_ID`,`Duplicate element/group id "${e.id}"`,`id:${e.id}`)};o.set(e.id,e.id)}let s=new Map(a.map(e=>[e.id,e])),c=new Map;for(let e=0;e<r.length;e++){let t=r[e],n=`groups[${e}]`,i=t.id,a=Array.isArray(t.children)?t.children.filter(e=>typeof e==`string`):[],o=A(t.ports)?t.ports:{},l=A(t.portMap)?t.portMap:{};for(let e of a){let t=c.get(e);if(t!==void 0)return{ok:!1,error:k(`AMBIGUOUS_GROUP_CHILD`,`Child id "${e}" is declared under more than one group ("${t}" and "${i}")`,`${n}.children`)};c.set(e,i)}let u=new Map;for(let[e,t]of Object.entries(l)){let r=`${n}.portMap.${e}`;if(typeof t!=`string`)continue;if(!(e in o))return{ok:!1,error:k(`UNRESOLVED_GROUP_PORT_MAP`,`Group "${i}" portMap key "${e}" does not match any port declared on the group itself`,r)};let c=t.indexOf(`.`),l=c<0?t:t.slice(0,c),d=c<0?``:t.slice(c+1),f=l.length>0?s.get(l):void 0;if(c<0||l.length===0||d.length===0||!a.includes(l)||!f||!(d in f.ports))return{ok:!1,error:k(`UNRESOLVED_GROUP_PORT_MAP`,`Group "${i}" portMap["${e}"]="${t}" does not resolve to a real port on a child declared in this group's "children"`,r)};let p=`${l}.${d}`,m=u.get(p);if(m!==void 0)return{ok:!1,error:k(`AMBIGUOUS_GROUP_PORT_MAP`,`Group "${i}" maps both "${m}" and "${e}" to the same interior port "${p}"`,r)};u.set(p,e)}}for(let e=0;e<n.length;e++){let r=n[e],i=r.type;if(!Be.has(i)&&!t.has(i))return{ok:!1,error:k(`UNKNOWN_TYPE`,`Element "${r.id}" has unknown type "${i}" — is its primitive group registered via registerPrimitives()?`,`elements[${e}].type`)};if(i===`off-page`){let t=`elements[${e}]`,n=r.target;if(!A(n)||typeof n.scene!=`string`||typeof n.port!=`string`)return{ok:!1,error:k(`BAD_SHAPE`,`${t} (off-page) must declare "target": { scene: string, port: string }`,`${t}.target`)}}}for(let e=0;e<i.length;e++){let t=i[e],n=`connections[${e}]`;if(!A(t)||typeof t.id!=`string`||t.id.length===0)return{ok:!1,error:k(`BAD_SHAPE`,`${n} must be an object with a non-empty string "id"`,`${n}.id`)};for(let e of[`from`,`to`]){let r=t[e],i=`${n}.${e}`;if(typeof r!=`string`||!r.includes(`.`))return{ok:!1,error:k(`BAD_SHAPE`,`${i} must be an "ELEM.port" reference`,i)};let a=r.indexOf(`.`),o=r.slice(0,a),c=r.slice(a+1);if(o.length===0||c.length===0)return{ok:!1,error:k(`BAD_SHAPE`,`${i} must be an "ELEM.port" reference`,i)};let l=s.get(o);if(!l)return{ok:!1,error:k(`UNRESOLVED_PORT`,`Connection "${t.id}" ${e}="${r}" references element "${o}" but no such element or group exists`,i)};if(!(c in l.ports))return{ok:!1,error:k(`UNRESOLVED_PORT`,`Connection "${t.id}" ${e}="${r}" references port "${c}" but "${o}" declares no such port`,i)}}}let l=A(e.topology)?e.topology:{nodes:[],edges:[]},u=Array.isArray(l.nodes)?l.nodes:[],d=Array.isArray(l.edges)?l.edges:[],f=new Set;for(let e of i)A(e)&&typeof e.id==`string`&&f.add(e.id);for(let e=0;e<u.length;e++){let t=u[e],n=`topology.nodes[${e}]`;if(typeof t!=`string`||!s.has(t))return{ok:!1,error:k(`UNRESOLVED_TOPOLOGY_REF`,`topology.nodes[${e}] references "${String(t)}" but no such element or group exists`,n)}}for(let e=0;e<d.length;e++){let t=d[e],n=`topology.edges[${e}]`;if(!A(t)||typeof t.id!=`string`||t.id.length===0)return{ok:!1,error:k(`BAD_SHAPE`,`${n} must be an object with a non-empty string "id"`,`${n}.id`)};if(!f.has(t.id))return{ok:!1,error:k(`UNRESOLVED_TOPOLOGY_REF`,`topology edge "${t.id}" does not reference any connection with that id`,`${n}.id`)};for(let e of[`from`,`to`]){let r=t[e],i=`${n}.${e}`;if(typeof r!=`string`||!s.has(r))return{ok:!1,error:k(`UNRESOLVED_TOPOLOGY_REF`,`topology edge "${t.id}" ${e}="${String(r)}" references an element/group that does not exist`,i)}}}if(l.sources!==void 0){if(!Array.isArray(l.sources))return{ok:!1,error:k(`BAD_SHAPE`,`topology.sources must be an array of node ids`,`topology.sources`)};let e=new Set(u.filter(e=>typeof e==`string`));for(let t=0;t<l.sources.length;t++){let n=l.sources[t],r=`topology.sources[${t}]`;if(typeof n!=`string`||!e.has(n))return{ok:!1,error:k(`UNRESOLVED_TOPOLOGY_REF`,`topology.sources[${t}] references "${String(n)}" but it is not declared in topology.nodes`,r)}}}let p=n.map(e=>{let t=e;return{...t,bindings:Array.isArray(t.bindings)?t.bindings:[],thresholds:Array.isArray(t.thresholds)?t.thresholds:[]}}),m=i.map(e=>{let t=e;return{...t,bindings:Array.isArray(t.bindings)?t.bindings:[]}});return{ok:!0,scene:{...e,elements:p,groups:r,connections:m,topology:e.topology??{nodes:[],edges:[]},media:e.media??{},inferFlow:e.inferFlow===!0}}}async function We(e){return null}var Ge=new Map;function Ke(...e){for(let t of e)for(let[e,n]of Object.entries(t.primitives))Ge.has(e)&&Ge.get(e)!==n&&console.warn(`registerPrimitives: element type "${e}" is already registered — the new registration will overwrite it.`),Ge.set(e,n)}function qe(e){return Ge.get(e)}function Je(){return new Set(Ge.keys())}function Ye(){return Je()}var Xe;function Ze(e){Xe=e}function Qe(){return Xe}var $e=new Map;function et(...e){for(let t of e)$e.set(t.name,t)}function tt(e){return $e.get(e)??{name:e,palette:{}}}var nt={now:()=>performance.now(),onTick(e){let t=requestAnimationFrame(function n(r){e(r),t=requestAnimationFrame(n)});return()=>cancelAnimationFrame(t)}},rt={setTransform(e,t){e.style.transform=t},setAttr(e,t,n){e.setAttribute(t,n)},setCssVar(e,t,n){e.style.setProperty(t,n)},setText(e,t){e.textContent=t},animateTransform(e,t,n){let r=e.animate(t.map(e=>({transform:e})),{duration:n,iterations:1/0,easing:`linear`});return{setPlaybackRate(e){r.playbackRate=e},pause(){r.pause()},resume(){r.play()},seek(e){r.currentTime=e}}}},it={up:{x:0,y:-1},down:{x:0,y:1},left:{x:-1,y:0},right:{x:1,y:0}};function at(e){return it[e]}function ot(e){return e===`left`||e===`right`?`h`:`v`}function st(e,t,n,r){let i={x:e.x+at(t).x*24,y:e.y+at(t).y*24},a={x:n.x+at(r).x*24,y:n.y+at(r).y*24},o=ct(t,r,i,a);for(let t of o){let r=ut([e,i,...t,a,n]);if(!lt(r))return r}return ut([e,i,...o[o.length-1]??[],a,n])}function ct(e,t,n,r){if(ot(e)!==ot(t))return ot(e)===`v`?[[{x:n.x,y:r.y}],[{x:r.x,y:n.y}]]:[[{x:r.x,y:n.y}],[{x:n.x,y:r.y}]];let i=ot(e)===`v`,a=e=>i?e.y:e.x,o=e=>i?e.x:e.y,s=(e,t)=>i?{x:t,y:e}:{x:e,y:t},c=a(n)===a(r)?[]:[s(a(n),o(n)+24),s(a(r),o(n)+24)];return[[{x:r.x,y:n.y}],c]}function lt(e){for(let t=0;t<e.length-1;t++)for(let n=t+1;n<e.length-1;n++){let r=e[t],i=e[t+1],a=e[n],o=e[n+1],s=r.x===i.x;if(s===(a.x===o.x))if(s){if(r.x!==a.x)continue;let e=Math.min(r.y,i.y),t=Math.max(r.y,i.y),n=Math.min(a.y,o.y);if(e<Math.max(a.y,o.y)&&n<t)return!0}else{if(r.y!==a.y)continue;let e=Math.min(r.x,i.x),t=Math.max(r.x,i.x),n=Math.min(a.x,o.x);if(e<Math.max(a.x,o.x)&&n<t)return!0}}return!1}function ut(e){let t=e.slice(),n=!0;for(;n;){n=!1;for(let e=1;e<t.length-1;e++){let r=t[e-1],i=t[e+1],a=t[e];if(a.x===r.x&&a.y===r.y||a.x===i.x&&a.y===i.y){t.splice(e,1),n=!0;break}}if(!n)for(let e=1;e<t.length-1;e++){let r=t[e-1],i=t[e],a=t[e+1],o=i.x-r.x,s=i.y-r.y,c=a.x-i.x,l=a.y-i.y,u=o*l-s*c,d=o*c+s*l,f=o*o+s*s+c*c+l*l||1;if(Math.abs(u)<1e-9*f&&d>0){t.splice(e,1),n=!0;break}}}return t}function dt(e,t,n=36){if(!t||e.length<2)return e;let r=e[0],i=e[e.length-1],a=pt(t*n,e);if(a===0)return e;let o=e.length===2?ft(r,i,a):e;if(o.length===2)return e;let s=gt(mt(o,a));return s[0]=r,s[s.length-1]=i,s}function ft(e,t,n){let r=t.x-e.x,i=t.y-e.y,a=Math.hypot(r,i);if(a<1e-9)return[e,t];let o=r/a,s=i/a,c=Math.min(Math.max(24,Math.abs(n)),a/3);return[e,{x:e.x+o*c,y:e.y+s*c},{x:t.x-o*c,y:t.y-s*c},t]}function pt(e,t){if(t.length<3)return e;let n=1/0;for(let e=0;e<t.length-1;e++){let r=Math.hypot(t[e+1].x-t[e].x,t[e+1].y-t[e].y);r>1e-9&&(n=Math.min(n,r))}if(!Number.isFinite(n))return e;let r=n/2;return Math.sign(e)*Math.min(Math.abs(e),r)}function mt(e,t){let n=[];for(let t=0;t<e.length-1;t++){let r=e[t],i=e[t+1],a=Math.hypot(i.x-r.x,i.y-r.y);n.push(a>1e-9?{x:(i.x-r.x)/a,y:(i.y-r.y)/a}:null)}let r=ht(n),i=[];for(let n=0;n<e.length-1;n++){let a=e[n],o=e[n+1],s=r[n],c={x:-s.y*t,y:s.x*t};i.push({from:{x:a.x+c.x,y:a.y+c.y},to:{x:o.x+c.x,y:o.y+c.y},dir:s})}return i}function ht(e){let t=e.slice();for(let e=0;e<t.length;e++){if(t[e])continue;let n=null;for(let r=e+1;r<t.length&&!n;r++)n=t[r];if(!n)for(let r=e-1;r>=0&&!n;r--)n=t[r];t[e]=n??{x:0,y:0}}return t}function gt(e){let t=[e[0].from];for(let n=0;n<e.length-1;n++){let r=e[n],i=e[n+1];t.push(_t(r.from,r.dir,i.from,i.dir)??r.to)}return t.push(e[e.length-1].to),t}function _t(e,t,n,r){let i=t.x*r.y-t.y*r.x;if(Math.abs(i)<1e-9)return null;let a=n.x-e.x,o=n.y-e.y,s=(a*r.y-o*r.x)/i;return{x:e.x+t.x*s,y:e.y+t.y*s}}function j(e,t){if(e){if(t&&e.styles[t])return e.styles[t];if(e.defaultMedium)return e.styles[e.defaultMedium]}}function vt(e,t){return e.medium===void 0?t.edgeById.get(e.id)?.medium:e.medium}function yt(e,t,n){let r=St(e.from,t),i=St(e.to,t);if(!r||!i)return null;let a={x:r.x,y:r.y},o={x:i.x,y:i.y},s=xt(e.bindings??[]),c=e.laneOffset,l=n?vt(e,n):e.medium,u=e.routing??`orthogonal`,d=!!e.waypoints&&e.waypoints.length>0;if((u===`manual`||u===`orthogonal`)&&d){let t=e.cornerRadius??0;return bt(dt([a,...e.waypoints??[],o],c),t,l,s)}if(u===`orthogonal`){let t=e.cornerRadius??12;return bt(dt(st(a,r.dir,o,i.dir),c),t,l,s)}return{segments:Ct(dt([a,o],c)),corners:[],medium:l,flowBinding:s}}function bt(e,t,n,r){return e.length<=2||t<=0?{segments:Ct(e),corners:[],medium:n,flowBinding:r}:Tt(e,t,n,r)}function xt(e){let t=e.find(e=>e.type===`flow`);return t?{tag:t.tag,min:t.min,max:t.max}:void 0}function St(e,t){let n=e.indexOf(`.`);if(n<0)return null;let r=e.slice(0,n),i=e.slice(n+1),a=t.elements.find(e=>e.id===r);if(!a)return null;let o=a.ports[i];return o?{x:a.x+o.x,y:a.y+o.y,dir:o.dir}:null}function Ct(e){let t=[];for(let n=0;n<e.length-1;n++)t.push({from:e[n],to:e[n+1]});return t}function wt(e,t){let n=[],r=[],i=e[0];for(let a=1;a<e.length-1;a++){let o=e[a-1],s=e[a],c=e[a+1],l=Et(s,o),u=Et(c,s),d=kt(l),f=kt(u),p=Math.min(t,d/2,f/2),m=Ot(l,1/d),h=Ot(u,1/f),g=Et(s,Ot(m,p)),_=Dt(s,Ot(h,p));n.push({from:i,to:g});let v=m.x*h.y-m.y*h.x;r.push({from:g,to:_,radius:p,sweepFlag:v>0?0:1}),i=_}return n.push({from:i,to:e[e.length-1]}),{segments:n,corners:r}}function Tt(e,t,n,r){let{segments:i,corners:a}=wt(e,t);return{segments:i,corners:a,medium:n,flowBinding:r}}function Et(e,t){return{x:e.x-t.x,y:e.y-t.y}}function Dt(e,t){return{x:e.x+t.x,y:e.y+t.y}}function Ot(e,t){return{x:e.x*t,y:e.y*t}}function kt(e){return Math.sqrt(e.x*e.x+e.y*e.y)}function At(e,t){let n=new Map;for(let r of e.groups)if(t.has(r.id))for(let e of r.children)n.set(e,r.id);return n}function jt(e,t,n){return At(e,t).get(n)??n}var Mt={good:0,uncertain:1,stale:2,bad:3};function Nt(e,t){return Mt[e]>=Mt[t]?e:t}function Pt(e,t,n){return e.quality===`bad`?`bad`:t-(e.timestamp??e.arrivalTime)>n?`stale`:e.quality===`uncertain`?`uncertain`:`good`}function Ft(e){return e.reduce((e,t)=>Nt(e,t),`good`)}function It(e){let t=Math.floor(e/1e3);return t<60?`${t}s`:`${Math.floor(t/60)}m`}var M=`http://www.w3.org/2000/svg`;function Lt(e,t){let n=document.createElementNS(M,`g`);n.setAttribute(`class`,`vscada-group-summary`),n.setAttribute(`data-group-id`,e.id);let r=t.tokens.panel;if(!r)return{svg:n,setAlarmCondition:()=>{},setSummaryValue:()=>{}};let i=document.createElementNS(M,`rect`);i.setAttribute(`class`,`vscada-group-face`),i.setAttribute(`width`,String(e.w)),i.setAttribute(`height`,String(e.h)),i.setAttribute(`fill`,r.raised.faceColor),n.appendChild(i);let a=document.createElementNS(M,`path`);a.setAttribute(`class`,`vscada-group-bevel-highlight`),a.setAttribute(`d`,`M 0 ${e.h} L 0 0 L ${e.w} 0`),a.setAttribute(`fill`,`none`),a.setAttribute(`stroke`,r.raised.highlightColor),a.setAttribute(`stroke-width`,`2`),n.appendChild(a);let o=document.createElementNS(M,`path`);o.setAttribute(`class`,`vscada-group-bevel-shadow`),o.setAttribute(`d`,`M ${e.w} 0 L ${e.w} ${e.h} L 0 ${e.h}`),o.setAttribute(`fill`,`none`),o.setAttribute(`stroke`,r.raised.shadowColor),o.setAttribute(`stroke-width`,`2`),n.appendChild(o);let s=document.createElementNS(M,`text`);s.setAttribute(`class`,`vscada-group-label`),s.setAttribute(`x`,`6`),s.setAttribute(`y`,`14`),s.setAttribute(`fill`,r.labelColor),s.textContent=e.label??e.id,n.appendChild(s);let c=new Map;e.summaryTags.forEach((e,t)=>{let i=document.createElementNS(M,`text`);i.setAttribute(`class`,`vscada-group-readout`),i.setAttribute(`data-tag`,e),i.setAttribute(`x`,`6`),i.setAttribute(`y`,String(28+t*14)),i.setAttribute(`fill`,r.readoutColor),n.appendChild(i),c.set(e,i)});let l=document.createElementNS(M,`circle`);l.setAttribute(`class`,`vscada-group-alarm`),l.setAttribute(`cx`,String(e.w-8)),l.setAttribute(`cy`,`8`),l.setAttribute(`r`,`5`),l.setAttribute(`fill`,r.alarmIndicator.goodColor),n.appendChild(l);let u=document.createElementNS(M,`text`);u.setAttribute(`class`,`vscada-group-alarm-label`),u.setAttribute(`x`,String(e.w-8)),u.setAttribute(`y`,`20`),u.setAttribute(`text-anchor`,`middle`),u.setAttribute(`font-size`,`7`),u.setAttribute(`fill`,r.labelColor),u.textContent=`GOOD`,n.appendChild(u);let d={good:r.alarmIndicator.goodColor,uncertain:r.alarmIndicator.uncertainColor,stale:r.alarmIndicator.staleColor,bad:r.alarmIndicator.badColor};function f(e,t){e.setAttr(l,`fill`,d[t]),e.setText(u,t.toUpperCase())}function p(e,t,n){let r=c.get(t);r&&e.setText(r,n)}return{svg:n,setAlarmCondition:f,setSummaryValue:p}}function Rt(e,t){let n=document.createElementNS(M,`g`);n.setAttribute(`class`,`vscada-group-frame`),n.setAttribute(`data-group-id`,e.id);let r=t.tokens.panel;if(!r)return n;let i=document.createElementNS(M,`rect`);i.setAttribute(`class`,`vscada-group-frame-outline`),i.setAttribute(`width`,String(e.w)),i.setAttribute(`height`,String(e.h)),i.setAttribute(`fill`,`none`),i.setAttribute(`stroke`,r.raised.highlightColor),i.setAttribute(`stroke-dasharray`,`4 3`),n.appendChild(i);let a=document.createElementNS(M,`text`);return a.setAttribute(`class`,`vscada-group-frame-label`),a.setAttribute(`x`,`4`),a.setAttribute(`y`,`-4`),a.setAttribute(`fill`,r.labelColor),a.textContent=e.label??e.id,n.appendChild(a),n}function zt(e){return Object.entries(e.portMap).flatMap(([e,t])=>{let n=t.indexOf(`.`);return n<0?[]:[{groupPortName:e,childElementId:t.slice(0,n),childPortName:t.slice(n+1)}]})}function Bt(e,t){let n=new Map;for(let r of e.groups)if(t.has(r.id))for(let e of zt(r))n.set(`${e.childElementId}.${e.childPortName}`,`${r.id}.${e.groupPortName}`);return n}function Vt(e){let t=e.indexOf(`.`);return t<0?e:e.slice(0,t)}function Ht(e,t,n){let r=jt(t,n,Vt(e.from));return r===jt(t,n,Vt(e.to))&&n.has(r)}function Ut(e,t){if(t.size===0)return e;let n=Bt(e,t),r=e.groups.filter(e=>t.has(e.id)).map(e=>({id:e.id,type:`group`,x:e.x,y:e.y,w:e.w,h:e.h,label:e.label,ports:e.ports,bindings:[],thresholds:[],transitions:{}})),i=e=>n.get(e)??e,a=e.connections.filter(n=>!Ht(n,e,t)).map(e=>({...e,from:i(e.from),to:i(e.to)}));return{...e,elements:[...e.elements,...r],connections:a}}function Wt(e,t,n,r){if(Ht(e,t,n))return null;let i=Ut(t,n),a=Bt(t,n);return yt({...e,from:a.get(e.from)??e.from,to:a.get(e.to)??e.to},i,r)}var Gt=class{constructor(e,t,n=``){this.timeSource=e,this.onWarning=t,this.buffer=new Map,this._tagPrefixVersion=0,this._tagPrefix=n}get tagPrefix(){return this._tagPrefix}set tagPrefix(e){e!==this._tagPrefix&&(this._tagPrefix=e,this._tagPrefixVersion++)}get tagPrefixVersion(){return this._tagPrefixVersion}setValues(e){for(let t of e)this.ingestOne(t)}clearValues(){this.buffer.clear()}get(e){return this.buffer.get(e)}resolve(e){return this.buffer.get(this._tagPrefix+e)}get size(){return this.buffer.size}tags(){return this.buffer.keys()}ingestOne(e){let t=e.quality??`good`,n=this.buffer.get(e.tag);if(n&&n.currentValue===e.value&&n.quality===t&&n.timestamp===e.timestamp)return;this.checkTimestamp(e);let r=this.timeSource.now();this.buffer.set(e.tag,{previousValue:n?n.currentValue:e.value,currentValue:e.value,arrivalTime:r,quality:t,timestamp:e.timestamp})}checkTimestamp(e){}},Kt={"state-lamp":0,flow:1,rotation:2,wave:3},qt=class{constructor(){this.entries=[]}register(e,t,n=`rotation`){this.entries.push({elementId:e,handle:t,paused:!1,priority:n})}registeredEntries(){return this.entries.map(e=>({elementId:e.elementId,priority:e.priority}))}unregisterElement(e){this.entries=this.entries.filter(t=>t.elementId!==e)}pauseAll(e){for(let t of this.entries)t.elementId===e&&!t.paused&&(t.handle.pause(),t.paused=!0)}resumeAll(e){for(let t of this.entries)t.elementId===e&&t.paused&&(t.handle.resume(),t.paused=!1)}pauseScene(){for(let e of this.entries)e.paused||(e.handle.pause(),e.paused=!0)}resumeScene(){for(let e of this.entries)e.paused&&(e.handle.resume(),e.paused=!1)}isPaused(e){return this.entries.filter(t=>t.elementId===e).map(e=>e.paused)}seekAll(e){for(let t of this.entries)t.handle.seek(e)}};function Jt(e){return e.quality===`good`?e.explicit===void 0?e.inferred===void 0?{tier:`default`,value:e.defaultValue}:{tier:`inferred`,value:e.inferred}:{tier:`explicit`,value:e.explicit}:{tier:`quality`,value:e.quality}}var Yt=.5,Xt=.1;function Zt(e,t,n=Yt,r=Xt){let i=n*r;return t?e<n+i:e<n-i}var Qt=1e4,$t=1e3,en=100,tn=2e3,nn=1e3,rn=1e3,an=1e3/60,on=1.5;function sn(e){return e===`stale`||e===`bad`}var cn=class{constructor(e,t,n,r,i={}){this.timeSource=e,this.store=t,this.renderer=n,this.animationRegistry=r,this.registrations=[],this.tickables=[],this.overlays=new Map,this.elementQuality=new Map,this.stopTick=null,this.wasSceneFrozen=!1,this.flowFrozen=new Map,this.flowIsolatedOverlay=new Map,this.lodFrozen=new Map,this.lodActiveValue=!1,this.lodMaxActiveAnimations=50,this.visibilityPaused=!1,this.offscreenTimerId=null,this.debugEnabled=!1,this.statsFrameCount=0,this.statsDroppedFrames=0,this.statsWindowStart=0,this.lastTickTime=null,this.statsCallback=null,this.conditionCallback=null,this.stalenessTimeout=Qt,this.connectionState=`connected`,this._mode=`live`,this._animateEnabled=!0,this.snapThreshold=i.snapThreshold??50,this.lastSeenTagPrefixVersion=t.tagPrefixVersion}registerHandle(e,t,n){if(n.kind!==`animation`){if(n.kind===`tween`){this.tickables.push({elementId:e,handle:n});return}this.registrations.push({elementId:e,tag:t,handle:n,lastWritten:void 0,lastArrivalTimeSeen:void 0,tweenDurationMs:en})}}registerQualityOverlay(e,t){this.overlays.set(e,t)}registerFlowInference(e,t){this.flowInference={cache:e,ids:[...t]}}unregisterElement(e){this.registrations=this.registrations.filter(t=>t.elementId!==e),this.tickables=this.tickables.filter(t=>t.elementId!==e),this.overlays.delete(e),this.elementQuality.delete(e),this.flowFrozen.delete(e),this.flowIsolatedOverlay.delete(e),this.lodFrozen.delete(e)}get registrationCount(){return this.registrations.length}get mode(){return this._mode}set mode(e){if(e===this._mode)return;let t=this._mode===`live`;this._mode=e,e===`static`?(t&&this.snapToTargets(),this.stop()):this.start()}get animate(){return this._animateEnabled}set animate(e){if(e===this._animateEnabled)return;if(this._animateEnabled=e,!e){this.animationRegistry.pauseScene();return}let t=new Set(this.animationRegistry.registeredEntries().map(e=>e.elementId));for(let e of t)this.visibilityPaused||this.isElementFrozen(e)||this.flowFrozen.get(e)||this.lodFrozen.get(e)||this.animationRegistry.resumeAll(e)}start(){this.stopTick||this._mode!==`static`&&(this.stopTick=this.timeSource.onTick(e=>this.tick(e)))}stop(){this.stopTick?.(),this.stopTick=null,this.offscreenTimerId!==null&&(clearInterval(this.offscreenTimerId),this.offscreenTimerId=null)}get isRunning(){return this.stopTick!==null}get lodActive(){return this.lodActiveValue}set lodActive(e){this.lodActiveValue=e}get debug(){return this.debugEnabled}set debug(e){let t=e&&!this.debugEnabled;this.debugEnabled=e,t&&(this.statsFrameCount=0,this.statsDroppedFrames=0,this.lastTickTime=null,this.statsWindowStart=this.timeSource.now())}onRenderStats(e){return this.statsCallback=e,()=>{this.statsCallback===e&&(this.statsCallback=null)}}onConditionTransition(e){return this.conditionCallback=e,()=>{this.conditionCallback===e&&(this.conditionCallback=null)}}get isPausedForOffscreen(){return this.visibilityPaused}pauseForOffscreen(){this.visibilityPaused||(this.visibilityPaused=!0,this.stop(),this.animationRegistry.pauseScene(),this.offscreenTimerId=setInterval(()=>this.offscreenTick(),nn))}resumeFromOffscreen(){if(!this.visibilityPaused)return;this.visibilityPaused=!1,this.offscreenTimerId!==null&&(clearInterval(this.offscreenTimerId),this.offscreenTimerId=null);let e=new Set(this.animationRegistry.registeredEntries().map(e=>e.elementId));for(let t of e)this.isElementFrozen(t)||this.flowFrozen.get(t)||this.lodFrozen.get(t)||this.animationRegistry.resumeAll(t);this.start()}offscreenTick(){let e=this.timeSource.now(),t=this.connectionState===`disconnected`;this.evaluateQuality(e,t),this.applyFlowInference()}snapToTargets(){this.syncTagPrefixIfChanged();let e=this.timeSource.now();for(let t of this.tickables)t.handle.snap(this.renderer,e);for(let t of this.registrations){let n=this.store.resolve(t.tag);n&&(t.tweenDurationMs=Math.max(e-n.arrivalTime,1),t.lastArrivalTimeSeen=n.arrivalTime,!Object.is(n.currentValue,t.lastWritten)&&(t.lastWritten=n.currentValue,un(t.handle,this.renderer,n.currentValue,e)))}}tick(e){this.debugEnabled&&this.accountFrame(e),this.syncTagPrefixIfChanged();let t=this.connectionState===`disconnected`;t&&!this.wasSceneFrozen&&this.animationRegistry.pauseScene(),this.wasSceneFrozen=t,this.evaluateQuality(e,t),this.applyFlowInference();for(let n of this.tickables)t||this.isElementFrozen(n.elementId)||n.handle.tick(this.renderer,e);for(let n of this.registrations){if(t||this.isElementFrozen(n.elementId))continue;let r=this.store.resolve(n.tag);if(!r)continue;if(r.arrivalTime!==n.lastArrivalTimeSeen){let e=n.lastArrivalTimeSeen===void 0?en:r.arrivalTime-n.lastArrivalTimeSeen;n.tweenDurationMs=Math.min(Math.max(e,en),tn),n.lastArrivalTimeSeen=r.arrivalTime}let i=n.handle.kind===`state`?r.currentValue:ln(r,e,n.tweenDurationMs,this.snapThreshold);Object.is(i,n.lastWritten)||(n.lastWritten=i,un(n.handle,this.renderer,i,e))}this.applyLod()}applyLod(){if(!this.lodActiveValue&&this.lodFrozen.size===0)return;if(!this.lodActiveValue){for(let[e,t]of[...this.lodFrozen]){if(!t){this.lodFrozen.delete(e);continue}this.isElementFrozen(e)||this.flowFrozen.get(e)||(this.animationRegistry.resumeAll(e),this.lodFrozen.delete(e))}return}let e=this.animationRegistry.registeredEntries(),t=[...e].sort((e,t)=>Kt[e.priority]-Kt[t.priority]),n=new Set(t.slice(0,this.lodMaxActiveAnimations).map(e=>e.elementId));for(let{elementId:t}of e){let e=!n.has(t),r=this.lodFrozen.get(t)??!1;if(e&&!r)this.animationRegistry.pauseAll(t),this.lodFrozen.set(t,!0);else if(!e&&r){if(this.isElementFrozen(t)||this.flowFrozen.get(t))continue;this.animationRegistry.resumeAll(t),this.lodFrozen.set(t,!1)}}}accountFrame(e){this.lastTickTime!==null&&e-this.lastTickTime>an*on&&this.statsDroppedFrames++,this.lastTickTime=e,this.statsFrameCount++;let t=e-this.statsWindowStart;if(t<rn)return;let n=t/1e3,r=n>0?this.statsFrameCount/n:0;this.statsCallback?.({fps:Math.round(r),elementCount:this.countDistinctElements(),droppedFrames:this.statsDroppedFrames}),this.statsFrameCount=0,this.statsDroppedFrames=0,this.statsWindowStart=e}countDistinctElements(){let e=new Set;for(let t of this.registrations)e.add(t.elementId);for(let t of this.tickables)e.add(t.elementId);for(let t of this.overlays.keys())e.add(t);for(let t of this.animationRegistry.registeredEntries())e.add(t.elementId);return e.size}syncTagPrefixIfChanged(){let e=this.store.tagPrefixVersion;if(e!==this.lastSeenTagPrefixVersion){this.lastSeenTagPrefixVersion=e;for(let e of this.registrations)e.lastWritten=void 0,e.lastArrivalTimeSeen=void 0,e.tweenDurationMs=en}}isElementFrozen(e){let t=this.elementQuality.get(e);return t!==void 0&&sn(t.condition)}evaluateQuality(e,t){let n=new Map;for(let e of this.registrations){let t=n.get(e.elementId)??[];t.push(e.tag),n.set(e.elementId,t)}let r=new Set([...n.keys(),...this.overlays.keys()]);for(let i of r){let r=n.get(i)??[],a=`good`,o=0;for(let t of r){let n=this.store.resolve(t);n&&(a=Ft([a,Pt(n,e,this.stalenessTimeout)]),o=Math.max(o,e-(n.timestamp??n.arrivalTime)))}t&&(a=Ft([a,`stale`]));let s=this.elementQuality.get(i),c=s?.condition??`good`,l=this.overlays.get(i);a!==c&&(l?.setCondition(this.renderer,a),this.handleConditionTransition(i,c,a,e),this.conditionCallback?.(i,c,a));let u=s?.lastBadgeUpdate??-1/0;l&&(a===`stale`&&e-u>=$t?(l.setAgeBadge(this.renderer,It(o)),u=e):a!==`stale`&&l.setAgeBadge(this.renderer,null)),this.elementQuality.set(i,{condition:a,lastBadgeUpdate:u})}}applyFlowInference(){if(!this.flowInference)return;let{cache:e,ids:t}=this.flowInference;for(let n of t){let t=e.getState(n),r=this.elementQuality.get(n)?.condition??`good`,i=Jt({quality:r,inferred:t,defaultValue:`flowing`}),a=i.tier===`quality`,o=!a&&(i.value===`no-flow`||i.value===`isolated`);o?this.animationRegistry.pauseAll(n):a||this.flowFrozen.get(n)&&this.animationRegistry.resumeAll(n),this.flowFrozen.set(n,o);let s=this.overlays.get(n),c=i.tier===`inferred`&&i.value===`isolated`,l=this.flowIsolatedOverlay.get(n)??!1;s&&r===`good`&&c!==l&&s.setCondition(this.renderer,c?`stale`:`good`),this.flowIsolatedOverlay.set(n,c)}}handleConditionTransition(e,t,n,r){let i=sn(n)&&!sn(t),a=sn(t)&&!sn(n);if(i){if(this.animationRegistry.pauseAll(e),n===`bad`)for(let t of this.registrations)t.elementId===e&&t.handle.kind===`text`&&(t.handle.write(this.renderer,`----`,r),t.lastWritten=`----`)}else a&&this.animationRegistry.resumeAll(e)}};function ln(e,t,n,r){let{previousValue:i,currentValue:a,arrivalTime:o}=e;if(typeof i!=`number`||typeof a!=`number`||i===a||Math.abs(a-i)>r)return a;let s=Math.min(Math.max((t-o)/n,0),1);return i+(a-i)*s}function un(e,t,n,r){if(e.kind===`numeric`){typeof n==`number`&&e.write(t,n,r);return}(e.kind===`text`||e.kind===`state`)&&e.write(t,n,r)}var N=`http://www.w3.org/2000/svg`,dn=`vscada-quality-hatch`;function fn(e,t,n){let r=n.tokens.quality,i=document.createElementNS(N,`g`);if(i.setAttribute(`class`,`vscada-quality-overlay`),i.setAttribute(`display`,`none`),!r)return{group:i,setCondition:()=>{},setAgeBadge:()=>{}};let a=document.createElementNS(N,`rect`);if(a.setAttribute(`class`,`vscada-quality-dash`),a.setAttribute(`width`,String(e)),a.setAttribute(`height`,String(t)),a.setAttribute(`fill`,`none`),a.setAttribute(`stroke`,r.uncertainDashColor),a.setAttribute(`stroke-dasharray`,`4 3`),a.setAttribute(`display`,`none`),i.appendChild(a),!n.defs.querySelector(`#${dn}`)){let e=document.createElementNS(N,`pattern`);e.setAttribute(`id`,dn),e.setAttribute(`width`,`8`),e.setAttribute(`height`,`8`),e.setAttribute(`patternUnits`,`userSpaceOnUse`),e.setAttribute(`patternTransform`,`rotate(45)`);let t=document.createElementNS(N,`line`);t.setAttribute(`x1`,`0`),t.setAttribute(`y1`,`0`),t.setAttribute(`x2`,`0`),t.setAttribute(`y2`,`8`),t.setAttribute(`stroke`,r.badHatchColor),t.setAttribute(`stroke-width`,`4`),e.appendChild(t),n.defs.appendChild(e)}let o=document.createElementNS(N,`rect`);o.setAttribute(`class`,`vscada-quality-hatch`),o.setAttribute(`width`,String(e)),o.setAttribute(`height`,String(t)),o.setAttribute(`fill`,`url(#${dn})`),o.setAttribute(`opacity`,String(r.badHatchOpacity)),o.setAttribute(`display`,`none`),i.appendChild(o);let s=document.createElementNS(N,`rect`);s.setAttribute(`class`,`vscada-quality-stale`),s.setAttribute(`width`,String(e)),s.setAttribute(`height`,String(t)),s.setAttribute(`fill`,r.staleOverlayColor),s.setAttribute(`opacity`,String(r.staleOverlayOpacity)),s.setAttribute(`display`,`none`),i.appendChild(s);let c=document.createElementNS(N,`g`);c.setAttribute(`class`,`vscada-quality-badge`),c.setAttribute(`display`,`none`);let l=document.createElementNS(N,`rect`);l.setAttribute(`x`,String(e-24)),l.setAttribute(`y`,`-14`),l.setAttribute(`width`,`24`),l.setAttribute(`height`,`12`),l.setAttribute(`fill`,r.badgeBackgroundColor),c.appendChild(l);let u=document.createElementNS(N,`text`);u.setAttribute(`class`,`vscada-quality-badge-text`),u.setAttribute(`x`,String(e-12)),u.setAttribute(`y`,`-5`),u.setAttribute(`font-size`,`8`),u.setAttribute(`text-anchor`,`middle`),u.setAttribute(`fill`,r.badgeTextColor),c.appendChild(u),i.appendChild(c);function d(e,t){e.setAttr(i,`display`,t===`good`?`none`:`inline`),e.setAttr(a,`display`,t===`uncertain`?`inline`:`none`),e.setAttr(o,`display`,t===`bad`?`inline`:`none`),e.setAttr(s,`display`,t===`stale`?`inline`:`none`),e.setAttr(c,`display`,t===`stale`?`inline`:`none`)}function f(e,t){e.setText(u,t??``)}return{group:i,setCondition:d,setAgeBadge:f}}function pn(e){return Number.isNaN(e)?0:Math.min(Math.max(e,0),1)}function mn(e,t,n){return Math.min(Math.max(e,t),n)}function hn(e,t,n){let r=t-e;return r===0?0:pn((n-e)/r)}function gn(e,t){return hn(e.min,e.max,t)}function _n(e,t){return hn(e.min,e.max,t)}function vn(e,t){return mn(t,0,e.max??4)}var yn={minAngleDeg:-135,maxAngleDeg:135};function bn(e,t,n=yn){let r=hn(e.min,e.max,t);return n.minAngleDeg+r*(n.maxAngleDeg-n.minAngleDeg)}function xn(e,t){if(typeof t!=`number`)return String(t);let n=t.toFixed(e.decimals);return e.unit.length>0?`${n} ${e.unit}`:n}function Sn(e,t){if(e.map){let n=e.map[String(t)];if(n!==void 0)return n}return!!t}function Cn(e,t){let n=String(t),r=e.map[n];return r===void 0?{ok:!1,fault:{code:`UNMAPPED_STATE_VALUE`,message:`Tag "${e.tag}": value "${n}" has no entry in this binding's state map`,tag:e.tag}}:{ok:!0,state:r}}function wn(e){return Math.min(Math.max(e,0),1)}function Tn(e){let t=/^#([0-9a-fA-F]{3})$/.exec(e);if(t){let[e,n,r]=t[1].split(``).map(e=>parseInt(e+e,16));return[e,n,r]}let n=/^#([0-9a-fA-F]{6})$/.exec(e);if(n){let e=n[1];return[parseInt(e.slice(0,2),16),parseInt(e.slice(2,4),16),parseInt(e.slice(4,6),16)]}}function En(e){return Math.round(wn(e/255)*255).toString(16).padStart(2,`0`).toUpperCase()}function Dn(e,t,n){let r=Tn(e),i=Tn(t);if(!r||!i)return e;let a=wn(n),o=r[0]+(i[0]-r[0])*a,s=r[1]+(i[1]-r[1])*a,c=r[2]+(i[2]-r[2])*a;return`#${En(o)}${En(s)}${En(c)}`}function On(e,t){let n=[...e].sort((e,t)=>e.offset-t.offset);if(n.length===0)return`#000000`;if(n.length===1)return n[0].color;let r=wn(t);if(r<=n[0].offset)return n[0].color;if(r>=n[n.length-1].offset)return n[n.length-1].color;for(let e=0;e<n.length-1;e++){let t=n[e],i=n[e+1];if(r>=t.offset&&r<=i.offset){let e=i.offset-t.offset,n=e===0?0:(r-t.offset)/e;return Dn(t.color,i.color,n)}}return n[n.length-1].color}function kn(e,t){let n=e.colors;if(!n||n.length===0)return t.default;let r=[];for(let e=0;e<n.length;e++){let i=t.stops[n[e]];if(!i)continue;let a=n.length===1?0:e/(n.length-1);r.push({offset:a,color:i})}return r.length>=2?r:t.default}function An(e,t,n){if(n)return On(kn(e,n),hn(e.min,e.max,t))}var jn=new Map;function Mn(e){return jn.get(e)}var Nn=`http://www.w3.org/2000/svg`,Pn=new Set([`readout`,`state`,`visibility`,`blink`,`color-ramp`]),Fn=[`scale(1)`,`scale(0.3)`,`scale(1)`],In=800;function Ln(e,t,n,r){let i=document.createElementNS(Nn,`g`);i.setAttribute(`class`,`vscada-svg-import`),i.setAttribute(`data-element-id`,e.id);let a=fn(e.w,e.h,t);i.appendChild(a.group);let o={},s=new Set;function c(e,t){s.add(e),a.setCondition(n,`bad`)}function l(e){s.has(e)&&(s.delete(e),s.size===0&&a.setCondition(n,`good`))}let u=Mn(e.svgRef);if(u===void 0)return c(`svgRef:${e.svgRef}`,{code:`MISSING_SVG_SOURCE`,message:`svg-import "${e.id}" references svgRef "${e.svgRef}" but no source is registered — call registerSvgSources() before assigning the scene`,tag:e.svgRef}),{svg:i,handles:o};let d=new DOMParser().parseFromString(u,`image/svg+xml`),f=d.documentElement;if(d.querySelector(`parsererror`)||f.nodeName.toLowerCase()!==`svg`)return c(`svgRef:${e.svgRef}`,{code:`INVALID_SVG_SOURCE`,message:`svg-import "${e.id}"'s svgRef "${e.svgRef}" did not parse as SVG`,tag:e.svgRef}),{svg:i,handles:o};let p=document.createElementNS(Nn,`svg`),m=f.getAttribute(`viewBox`);for(m&&p.setAttribute(`viewBox`,m),p.setAttribute(`width`,String(e.w)),p.setAttribute(`height`,String(e.h)),p.setAttribute(`preserveAspectRatio`,`xMidYMid meet`);f.firstChild;)p.appendChild(document.adoptNode(f.firstChild));i.appendChild(p);for(let r of e.bindings){if(!Pn.has(r.type)){c(`type:${r.tag}`,{code:`UNSUPPORTED_IMPORT_BINDING_TYPE`,message:`svg-import "${e.id}" binding for tag "${r.tag}" has unsupported type "${r.type}" — imported art supports readout/state/visibility/blink/color-ramp only`,tag:r.tag});continue}let i=p.querySelector(`#${CSS.escape(r.svgId)}`);if(!i){c(`id:${r.svgId}`,{code:`MISSING_SVG_ID`,message:`svg-import "${e.id}" binding for tag "${r.tag}" references svgId "${r.svgId}" but no matching element exists in the imported SVG`,tag:r.tag});continue}switch(r.type){case`readout`:o[r.tag]={kind:`text`,write(e,t){e.setText(i,xn(r,t))}};break;case`state`:{let e=`state:${r.tag}`;o[r.tag]={kind:`state`,write(t,n){let a=Cn(r,n);if(a.ok){l(e),t.setAttr(i,`class`,a.state);return}c(e,a.fault)}};break}case`visibility`:o[r.tag]={kind:`state`,write(e,t){e.setAttr(i,`display`,Sn(r,t)?`inline`:`none`)}};break;case`color-ramp`:o[r.tag]={kind:`numeric`,write(e,n){if(typeof n!=`number`)return;let a=An(r,n,t.tokens.colorRamp);a!==void 0&&e.setAttr(i,`fill`,a)}};break;case`blink`:{let t=n.animateTransform(i,Fn,In),a={kind:`animation`,pause:()=>t.pause(),resume:()=>t.resume(),seek:e=>t.seek(e)};o[`__svg-import-blink-animation-${e.id}-${r.tag}`]=a,o[r.tag]={kind:`numeric`,write(e,n){typeof n==`number`&&t.setPlaybackRate(vn(r,n))}};break}}}return{svg:i,handles:o}}function Rn(e){let t=new Set(e.topology.nodes),n=e.topology.edges.map(e=>({id:e.id,from:e.from,to:e.to,medium:e.medium})),r=new Map,i=new Map,a=new Map;for(let e of n){a.set(e.id,e);let t=r.get(e.from);t?t.push(e):r.set(e.from,[e]);let n=i.get(e.to);n?n.push(e):i.set(e.to,[e])}return{nodes:t,edges:n,outgoing:r,incoming:i,edgeById:a}}function zn(e,t,n){let r=n===`downstream`?e.outgoing:e.incoming,i=e=>n===`downstream`?e.to:e.from,a=new Set([t]),o=[t],s=e.nodes.size+1,c=0;for(;o.length>0;){if(c+=1,c>s)throw Error(`reachableSet exceeded its node-count iteration bound — cycle guard invariant violated`);let e=o.shift(),t=r.get(e)??[];for(let e of t){let t=i(e);a.has(t)||(a.add(t),o.push(t))}}return a}function Bn(e,t){return zn(e,t,`downstream`)}function Vn(e,t){let n=new Map;for(let r of e.nodes)n.set(r,t.has(r)?[]:e.outgoing.get(r)??[]);return{...e,outgoing:n}}function Hn(e,t){let n=new Set;for(let r of t)for(let t of Bn(e,r))n.add(t);return n}function Un(e){let{graph:t,sourceNodeIds:n,stoppedSourceNodeIds:r,closedNodeIds:i}=e,a=Vn(t,i),o=[...n].filter(e=>!r.has(e)),s=Hn(t,n),c=Hn(a,n),l=Hn(a,o),u=new Map;for(let e of t.nodes)if(s.has(e)){if(!c.has(e)){u.set(e,`isolated`);continue}u.set(e,l.has(e)?`flowing`:`no-flow`)}let d=new Map;for(let e of t.edges)if(s.has(e.from)){if(!c.has(e.from)){d.set(e.id,`isolated`);continue}if(i.has(e.from)){d.set(e.id,c.has(e.to)?`no-flow`:`isolated`);continue}d.set(e.id,l.has(e.from)?`flowing`:`no-flow`)}return{edgeStates:d,nodeStates:u}}function Wn(e,t){return JSON.stringify([[...e].sort(),[...t].sort()])}var Gn=class{constructor(e,t){this.graph=e,this.sourceNodeIds=t,this.result={edgeStates:new Map,nodeStates:new Map}}update(e,t){let n=Wn(e,t);return n!==this.lastSignature&&(this.result=Un({graph:this.graph,sourceNodeIds:this.sourceNodeIds,stoppedSourceNodeIds:e,closedNodeIds:t}),this.lastSignature=n),this.result}getEdgeState(e){return this.result.edgeStates.get(e)}getNodeState(e){return this.result.nodeStates.get(e)}getState(e){return this.result.edgeStates.get(e)??this.result.nodeStates.get(e)}reset(){this.result={edgeStates:new Map,nodeStates:new Map},this.lastSignature=void 0}};function Kn(e,t){let n=e.edgeById.get(t);if(!n)return;let r=new Set([n.to]),i=new Set([n.id]),a=[n];for(;a.length>0;){let t=a.shift();r.add(t.from);let o=e.incoming.get(t.from)??[];for(let e of o)e.medium===n.medium&&(i.has(e.id)||(i.add(e.id),a.push(e)))}return{nodes:r,edges:i}}function qn(e){return e===`mouse`}var Jn=`data-vscada-highlight`;function Yn(e,t,n){let r=n.highlightAttr??Jn,i;function a(e,n){e&&t.setAttr(e,r,n?`true`:`false`)}function o(){if(i){for(let e of i.nodes)a(n.getNodeElement(e),!1);for(let e of i.edges)a(n.getEdgeElement(e),!1);i=void 0}}return{onPointerEnter(t,r){if(!qn(r.pointerType))return;let s=Kn(e,t);if(s){o(),i=s;for(let e of s.nodes)a(n.getNodeElement(e),!0);for(let e of s.edges)a(n.getEdgeElement(e),!0)}},onPointerLeave(){o()}}}var Xn=class{constructor(e,t){this.animationRegistry=t,this.collapsed=new Map,this.scene=e,this.seedFromScene(e)}seedFromScene(e){this.collapsed=new Map(e.groups.map(e=>[e.id,e.collapsed]))}reset(e){this.scene=e,this.seedFromScene(e)}isCollapsed(e){return this.collapsed.get(e)??!1}collapsedGroupIds(){let e=new Set;for(let[t,n]of this.collapsed)n&&e.add(t);return e}toggleGroup(e){return this.setCollapsed(e,!this.isCollapsed(e))}setCollapsed(e,t){let n=this.scene.groups.find(t=>t.id===e);if(!n)return this.isCollapsed(e);let r=this.isCollapsed(e);return this.collapsed.set(e,t),t&&!r&&this.deregisterChildren(n),t}deregisterChildren(e){if(this.animationRegistry)for(let t of e.children)this.animationRegistry.pauseAll(t),this.animationRegistry.unregisterElement(t)}},P=class{constructor(e,t,n,r){this.map=e,this.transitions=t,this.defaultTransition=n,this.onWarning=r}resolve(e,t){let n=String(e),r=this.map[n],i=this.currentState;if(r===void 0){this.onWarning?.({code:`UNMAPPED_STATE_VALUE`,message:`Tag "${t}": value "${n}" has no entry in this binding's state map`,tag:t});let e=i??`unknown`;return{state:e,previousState:i,transition:this.resolveDefault(i,e),changed:!1}}if(this.currentState=r,i===void 0||i===r)return{state:r,previousState:i,transition:this.resolveDefault(i,r),changed:!1};let a=`${i}→${r}`;return{state:r,previousState:i,transition:this.transitions[a]??this.resolveDefault(i,r),changed:!0}}resolveDefault(e,t){return typeof this.defaultTransition==`function`?this.defaultTransition(e,t):this.defaultTransition}};function Zn(e,t,n,r=44){let i=r/n,a=Math.max(e,i),o=Math.max(t,i);return{x:(e-a)/2,y:(t-o)/2,w:a,h:o}}var Qn=`http://www.w3.org/2000/svg`;function $n(e,t,n,r={x:0,y:0}){let i=Zn(e,t,n),a=document.createElementNS(Qn,`rect`);return a.setAttribute(`x`,String(i.x+r.x)),a.setAttribute(`y`,String(i.y+r.y)),a.setAttribute(`width`,String(i.w)),a.setAttribute(`height`,String(i.h)),a.setAttribute(`fill`,`transparent`),a.setAttribute(`class`,`vscada-hit-area`),a.style.pointerEvents=`all`,a.style.cursor=`pointer`,a.setAttribute(`tabindex`,`0`),a.setAttribute(`role`,`button`),a}function er(e,t,n,r,i={x:0,y:0}){let a=Zn(t,n,r);e.setAttribute(`x`,String(a.x+i.x)),e.setAttribute(`y`,String(a.y+i.y)),e.setAttribute(`width`,String(a.w)),e.setAttribute(`height`,String(a.h))}function tr(e=10){let t=new Map;return{onPointerDown(e,n,r){t.set(e,{x:n,y:r})},onPointerUp(n,r,i){let a=t.get(n);return t.delete(n),a&&Math.hypot(r-a.x,i-a.y)<=e?`tap`:`drag`},onPointerCancel(e){t.delete(e)}}}function nr(e,t){let{elementId:n,elementType:r,tags:i,arbiter:a,isInteractive:o,onClick:s,onHoverChange:c}=t;e.addEventListener(`pointerdown`,e=>{let t=e;a.onPointerDown(t.pointerId,t.clientX,t.clientY)}),e.addEventListener(`pointerup`,e=>{let t=e;a.onPointerUp(t.pointerId,t.clientX,t.clientY)!==`tap`||!o()||s({elementId:n,tags:i,elementType:r})}),e.addEventListener(`pointercancel`,e=>{a.onPointerCancel(e.pointerId)}),e.addEventListener(`keydown`,e=>{let t=e;t.key!==`Enter`&&t.key!==` `||o()&&(t.preventDefault(),s({elementId:n,tags:i,elementType:r}))}),c&&(e.addEventListener(`pointerenter`,e=>{e.pointerType===`mouse`&&c(!0)}),e.addEventListener(`pointerleave`,e=>{e.pointerType===`mouse`&&c(!1)}))}var rr=.0015;function ir(e,t){return Math.hypot(e.x-t.x,e.y-t.y)}function ar(e,t){return{x:(e.x+t.x)/2,y:(e.y+t.y)/2}}function or(e,t=10){let n=new Map,r=null,i=null;function a(){if(n.size<2)return null;let e=[...n.values()];return[e[0],e[1]]}return{onPointerDown(e,t,o){if(n.set(e,{originX:t,originY:o,x:t,y:o}),n.size>=2){r=null;let e=a();i=e?ir(e[0],e[1]):null}},onPointerMove(o,s,c){let l=n.get(o);if(!l)return;if(l.x=s,l.y=c,n.size>=2){let t=a();if(!t||i===null||i<1)return;let n=ir(t[0],t[1]),r=n/i;i=n;let o=ar(t[0],t[1]);e.onZoomAboutPoint(e.getZoom()*r,o.x,o.y);return}if(r===null){if(Math.hypot(s-l.originX,c-l.originY)<=t)return;r=o,l.originX=s,l.originY=c;return}if(o!==r)return;let u=s-l.originX,d=c-l.originY;l.originX=s,l.originY=c,e.onPan(u,d)},onPointerUp(e){n.delete(e),r===e&&(r=null),n.size<2&&(i=null)},onPointerCancel(e){n.delete(e),r===e&&(r=null),n.size<2&&(i=null)},onWheel(t,n,r){let i=Math.exp(-t*rr);e.onZoomAboutPoint(e.getZoom()*i,n,r)}}}var sr=.6;function cr(e){if(e>=1)return 1;let t=10*Math.sqrt(1-sr*sr),n=Math.exp(-.6*10*e),r=sr*10/t;return 1-n*(Math.cos(t*e)+r*Math.sin(t*e))}var lr={linear:e=>e,"ease-in":e=>e*e,"ease-out":e=>1-(1-e)*(1-e),"critically-damped-overshoot":cr};function ur(e){return lr[e]??lr.linear}var dr=class{constructor(e){this.startTime=0,this.durationMs=1,this.easing=lr.linear,this.startValue=e,this.targetValue=e}retarget(e,t,n,r){this.startValue=this.valueAt(e),this.targetValue=t,this.startTime=e,this.durationMs=Math.max(n,1),this.easing=ur(r)}valueAt(e){let t=Math.min(Math.max((e-this.startTime)/this.durationMs,0),1);return this.startValue+(this.targetValue-this.startValue)*this.easing(t)}isSettled(e){return e-this.startTime>=this.durationMs}snap(e){this.startValue=this.targetValue,this.startTime=e,this.durationMs=1}};function fr(e,t,n){return Math.min(Math.max(e,t),n)}function pr(e,t,n,r){let i=t-r-t*n,a=r;return i>a?(i+a)/2:fr(e,i,a)}var mr=class{constructor(e,t,n={}){this.timeSource=e,this.onFrame=t,this.canvasWidth=0,this.canvasHeight=0,this.zoomValue=1,this.panXValue=0,this.panYValue=0,this.tween=null,this.stopTick=null,this.minZoom=n.minZoom??.25,this.maxZoom=n.maxZoom??4,this.panMarginPx=n.panMarginPx??100,this.zoomTweenDurationMs=n.zoomTweenDurationMs??300}get zoom(){return this.zoomValue}get pan(){return{x:this.panXValue,y:this.panYValue}}reset(e,t){this.canvasWidth=e,this.canvasHeight=t,this.tween=null,this.stopTick?.(),this.stopTick=null,this.zoomValue=1,this.panXValue=0,this.panYValue=0,this.onFrame(this.currentTransform())}currentTransform(){return{zoom:this.zoomValue,panX:this.panXValue,panY:this.panYValue}}clampZoom(e){return fr(e,this.minZoom,this.maxZoom)}applyPanClamp(){this.panXValue=pr(this.panXValue,this.canvasWidth,this.zoomValue,this.panMarginPx),this.panYValue=pr(this.panYValue,this.canvasHeight,this.zoomValue,this.panMarginPx)}setZoomImmediate(e){this.tween=null,this.stopTick?.(),this.stopTick=null,this.zoomValue=this.clampZoom(e),this.applyPanClamp(),this.onFrame(this.currentTransform())}setZoomAnimated(e,t=this.zoomTweenDurationMs){let n=this.clampZoom(e),r=this.timeSource.now(),i=new dr(this.zoomValue);i.retarget(r,n,t,`ease-out`),this.tween=i,this.ensureAnimating()}panBy(e,t){this.panXValue+=e,this.panYValue+=t,this.applyPanClamp(),this.onFrame(this.currentTransform())}zoomAboutPoint(e,t,n){this.tween=null,this.stopTick?.(),this.stopTick=null;let r=this.zoomValue,i=this.clampZoom(e),a=i/r;this.panXValue=t-(t-this.panXValue)*a,this.panYValue=n-(n-this.panYValue)*a,this.zoomValue=i,this.applyPanClamp(),this.onFrame(this.currentTransform())}ensureAnimating(){this.stopTick||(this.stopTick=this.timeSource.onTick(e=>this.tickTween(e)))}tickTween(e){let t=this.tween;if(!t){this.stopTick?.(),this.stopTick=null;return}this.zoomValue=t.valueAt(e),this.applyPanClamp(),this.onFrame(this.currentTransform()),t.isSettled(e)&&(this.tween=null,this.stopTick?.(),this.stopTick=null)}snap(){if(!this.tween)return;let e=this.timeSource.now();this.tween.snap(e),this.zoomValue=this.tween.valueAt(e),this.tween=null,this.stopTick?.(),this.stopTick=null,this.applyPanClamp(),this.onFrame(this.currentTransform())}destroy(){this.stopTick?.(),this.stopTick=null,this.tween=null}};function hr(e,t,n){return new mr(e,t,n)}var gr=`VSCADA`;function _r(e){try{let t=e.replace(/-/g,`+`).replace(/_/g,`/`),n=t+`=`.repeat((4-t.length%4)%4),r=atob(n),i=new Uint8Array(r.length);for(let e=0;e<r.length;e++)i[e]=r.charCodeAt(e);return i}catch{return null}}function vr(e){return typeof e==`object`&&!!e&&typeof e.company==`string`&&typeof e.expiry==`string`&&typeof e.tier==`string`&&typeof e.keyId==`string`}function yr(e){let t=e.split(`.`);if(t.length!==4||t[0]!==gr)return null;let[,n,r,i]=t,a=_r(r);if(!a)return null;let o;try{o=JSON.parse(new TextDecoder().decode(a))}catch{return null}if(!vr(o))return null;let s=_r(i);return s?{version:n,encodedPayload:r,payload:o,signature:s}:null}function br(e,t){return new TextEncoder().encode(`${e}.${t}`)}var xr={};function Sr(){return globalThis.crypto?.subtle!==void 0}async function Cr(e,t,n){let r=globalThis.crypto?.subtle;if(!r)return!1;try{let i=await r.importKey(`jwk`,n,{name:`ECDSA`,namedCurve:`P-256`},!1,[`verify`]);return await r.verify({name:`ECDSA`,hash:`SHA-256`},i,t,e)}catch{return!1}}function wr(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name===`Uint8Array`&&`BYTES_PER_ELEMENT`in e&&e.BYTES_PER_ELEMENT===1}function Tr(e,t=``){if(typeof e!=`number`){let n=t&&`"${t}" `;throw TypeError(`${n}expected number, got ${typeof e}`)}if(!Number.isSafeInteger(e)||e<0){let n=t&&`"${t}" `;throw RangeError(`${n}expected integer >= 0, got ${e}`)}}function Er(e,t,n=``){let r=wr(e),i=e?.length,a=t!==void 0;if(!r||a&&i!==t){let o=n&&`"${n}" `,s=a?` of length ${t}`:``,c=r?`length=${i}`:`type=${typeof e}`,l=o+`expected Uint8Array`+s+`, got `+c;throw r?RangeError(l):TypeError(l)}return e}function Dr(e){if(typeof e!=`function`||typeof e.create!=`function`)throw TypeError(`Hash must wrapped by utils.createHasher`);if(Tr(e.outputLen),Tr(e.blockLen),e.outputLen<1)throw Error(`"outputLen" must be >= 1`);if(e.blockLen<1)throw Error(`"blockLen" must be >= 1`)}function Or(e,t=!0){if(e.destroyed)throw Error(`Hash instance has been destroyed`);if(t&&e.finished)throw Error(`Hash#digest() has already been called`)}function kr(e,t){Er(e,void 0,`digestInto() output`);let n=t.outputLen;if(e.length<n)throw RangeError(`"digestInto() output" expected to be of length >=`+n)}function Ar(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function jr(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function F(e,t){return e<<32-t|e>>>t}var Mr=typeof Uint8Array.from([]).toHex==`function`&&typeof Uint8Array.fromHex==`function`,Nr=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,`0`));function Pr(e){if(Er(e),Mr)return e.toHex();let t=``;for(let n=0;n<e.length;n++)t+=Nr[e[n]];return t}var Fr={_0:48,_9:57,A:65,F:70,a:97,f:102};function Ir(e){if(e>=Fr._0&&e<=Fr._9)return e-Fr._0;if(e>=Fr.A&&e<=Fr.F)return e-(Fr.A-10);if(e>=Fr.a&&e<=Fr.f)return e-(Fr.a-10)}function Lr(e){if(typeof e!=`string`)throw TypeError(`hex string expected, got `+typeof e);if(Mr)try{return Uint8Array.fromHex(e)}catch(e){throw e instanceof SyntaxError?RangeError(e.message):e}let t=e.length,n=t/2;if(t%2)throw RangeError(`hex string expected, got unpadded hex of length `+t);let r=new Uint8Array(n);for(let t=0,i=0;t<n;t++,i+=2){let n=Ir(e.charCodeAt(i)),a=Ir(e.charCodeAt(i+1));if(n===void 0||a===void 0){let t=e[i]+e[i+1];throw RangeError(`hex string expected, got non-hex character "`+t+`" at index `+i)}r[t]=n*16+a}return r}function Rr(...e){let t=0;for(let n=0;n<e.length;n++){let r=e[n];Er(r),t+=r.length}let n=new Uint8Array(t);for(let t=0,r=0;t<e.length;t++){let i=e[t];n.set(i,r),r+=i.length}return n}function zr(e,t={}){let n=(t,n)=>e(n).update(t).digest(),r=e(void 0);return n.outputLen=r.outputLen,n.blockLen=r.blockLen,n.canXOF=r.canXOF,n.create=t=>e(t),Object.assign(n,t),Object.freeze(n)}function Br(e=32){Tr(e,`bytesLength`);let t=typeof globalThis==`object`?globalThis.crypto:null;if(typeof t?.getRandomValues!=`function`)throw Error(`crypto.getRandomValues must be defined`);if(e>65536)throw RangeError(`"bytesLength" expected <= 65536, got ${e}`);return t.getRandomValues(new Uint8Array(e))}var Vr=e=>({oid:Uint8Array.from([6,9,96,134,72,1,101,3,4,2,e])});function Hr(e){"@babel/helpers - typeof";return Hr=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},Hr(e)}function Ur(e,t){if(Hr(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(Hr(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function Wr(e){var t=Ur(e,`string`);return Hr(t)==`symbol`?t:t+``}function I(e,t,n){return(t=Wr(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Gr(e,t,n){return e&t^~e&n}function Kr(e,t,n){return e&t^e&n^t&n}var qr=class{constructor(e,t,n,r){I(this,`blockLen`,void 0),I(this,`outputLen`,void 0),I(this,`canXOF`,!1),I(this,`padOffset`,void 0),I(this,`isLE`,void 0),I(this,`buffer`,void 0),I(this,`view`,void 0),I(this,`finished`,!1),I(this,`length`,0),I(this,`pos`,0),I(this,`destroyed`,!1),this.blockLen=e,this.outputLen=t,this.padOffset=n,this.isLE=r,this.buffer=new Uint8Array(e),this.view=jr(this.buffer)}update(e){Or(this),Er(e);let{view:t,buffer:n,blockLen:r}=this,i=e.length;for(let a=0;a<i;){let o=Math.min(r-this.pos,i-a);if(o===r){let t=jr(e);for(;r<=i-a;a+=r)this.process(t,a);continue}n.set(e.subarray(a,a+o),this.pos),this.pos+=o,a+=o,this.pos===r&&(this.process(t,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){Or(this),kr(e,this),this.finished=!0;let{buffer:t,view:n,blockLen:r,isLE:i}=this,{pos:a}=this;t[a++]=128,Ar(this.buffer.subarray(a)),this.padOffset>r-a&&(this.process(n,0),a=0);for(let e=a;e<r;e++)t[e]=0;n.setBigUint64(r-8,BigInt(this.length*8),i),this.process(n,0);let o=jr(e),s=this.outputLen;if(s%4)throw Error(`_sha2: outputLen must be aligned to 32bit`);let c=s/4,l=this.get();if(c>l.length)throw Error(`_sha2: outputLen bigger than state`);for(let e=0;e<c;e++)o.setUint32(4*e,l[e],i)}digest(){let{buffer:e,outputLen:t}=this;this.digestInto(e);let n=e.slice(0,t);return this.destroy(),n}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());let{blockLen:t,buffer:n,length:r,finished:i,destroyed:a,pos:o}=this;return e.destroyed=a,e.finished=i,e.length=r,e.pos=o,r%t&&e.buffer.set(n),e}clone(){return this._cloneInto()}},Jr=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),Yr=Uint32Array.from([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),Xr=new Uint32Array(64),Zr=class extends qr{constructor(e){super(64,e,8,!1)}get(){let{A:e,B:t,C:n,D:r,E:i,F:a,G:o,H:s}=this;return[e,t,n,r,i,a,o,s]}set(e,t,n,r,i,a,o,s){this.A=e|0,this.B=t|0,this.C=n|0,this.D=r|0,this.E=i|0,this.F=a|0,this.G=o|0,this.H=s|0}process(e,t){for(let n=0;n<16;n++,t+=4)Xr[n]=e.getUint32(t,!1);for(let e=16;e<64;e++){let t=Xr[e-15],n=Xr[e-2],r=F(t,7)^F(t,18)^t>>>3;Xr[e]=(F(n,17)^F(n,19)^n>>>10)+Xr[e-7]+r+Xr[e-16]|0}let{A:n,B:r,C:i,D:a,E:o,F:s,G:c,H:l}=this;for(let e=0;e<64;e++){let t=F(o,6)^F(o,11)^F(o,25),u=l+t+Gr(o,s,c)+Yr[e]+Xr[e]|0,d=(F(n,2)^F(n,13)^F(n,22))+Kr(n,r,i)|0;l=c,c=s,s=o,o=a+u|0,a=i,i=r,r=n,n=u+d|0}n=n+this.A|0,r=r+this.B|0,i=i+this.C|0,a=a+this.D|0,o=o+this.E|0,s=s+this.F|0,c=c+this.G|0,l=l+this.H|0,this.set(n,r,i,a,o,s,c,l)}roundClean(){Ar(Xr)}destroy(){this.destroyed=!0,this.set(0,0,0,0,0,0,0,0),Ar(this.buffer)}},Qr=class extends Zr{constructor(){super(32),I(this,`A`,Jr[0]|0),I(this,`B`,Jr[1]|0),I(this,`C`,Jr[2]|0),I(this,`D`,Jr[3]|0),I(this,`E`,Jr[4]|0),I(this,`F`,Jr[5]|0),I(this,`G`,Jr[6]|0),I(this,`H`,Jr[7]|0)}},$r=zr(()=>new Qr,Vr(1)),L=(e,t,n)=>Er(e,t,n),ei=Tr,ti=Pr,ni=(...e)=>Rr(...e),ri=e=>Lr(e),ii=wr,ai=e=>Br(e),oi=BigInt(0),si=BigInt(1);function ci(e,t=``){if(typeof e!=`boolean`){let n=t&&`"${t}" `;throw TypeError(n+`expected boolean, got type=`+typeof e)}return e}function li(e){if(typeof e==`bigint`){if(!vi(e))throw RangeError(`positive bigint expected, got `+e)}else ei(e);return e}function ui(e,t=``){if(typeof e!=`number`){let n=t&&`"${t}" `;throw TypeError(n+`expected number, got type=`+typeof e)}if(!Number.isSafeInteger(e)){let n=t&&`"${t}" `;throw RangeError(n+`expected safe integer, got `+e)}}function di(e){let t=li(e).toString(16);return t.length&1?`0`+t:t}function fi(e){if(typeof e!=`string`)throw TypeError(`hex string expected, got `+typeof e);return e===``?oi:BigInt(`0x`+e)}function pi(e){return fi(Pr(e))}function mi(e){return fi(Pr(_i(Er(e)).reverse()))}function hi(e,t){if(Tr(t),t===0)throw RangeError(`zero length`);e=li(e);let n=e.toString(16);if(n.length>t*2)throw RangeError(`number too large`);return Lr(n.padStart(t*2,`0`))}function gi(e,t){return hi(e,t).reverse()}function _i(e){return Uint8Array.from(L(e))}var vi=e=>typeof e==`bigint`&&oi<=e;function yi(e,t,n){return vi(e)&&vi(t)&&vi(n)&&t<=e&&e<n}function bi(e,t,n,r){if(!yi(t,n,r))throw RangeError(`expected valid `+e+`: `+n+` <= n < `+r+`, got `+t)}function xi(e){if(e<oi)throw Error(`expected non-negative bigint, got `+e);let t;for(t=0;e>oi;e>>=si,t+=1);return t}var Si=e=>(si<<BigInt(e))-si;function Ci(e,t,n){if(Tr(e,`hashLen`),Tr(t,`qByteLen`),typeof n!=`function`)throw TypeError(`hmacFn must be a function`);let r=e=>new Uint8Array(e),i=Uint8Array.of(),a=Uint8Array.of(0),o=Uint8Array.of(1),s=r(e),c=r(e),l=0,u=()=>{s.fill(1),c.fill(0),l=0},d=(...e)=>n(c,ni(s,...e)),f=(e=i)=>{c=d(a,e),s=d(),e.length!==0&&(c=d(o,e),s=d())},p=()=>{if(l++>=1e3)throw Error(`drbg: tried max amount of iterations`);let e=0,n=[];for(;e<t;){s=d();let t=s.slice();n.push(t),e+=s.length}return ni(...n)};return(e,t)=>{u(),f(e);let n;for(;(n=t(p()))===void 0;)f();return u(),n}}function wi(e,t={},n={}){if(Object.prototype.toString.call(e)!==`[object Object]`)throw TypeError(`expected valid options object`);function r(t,n,r){if(!r&&n!==`function`&&!Object.hasOwn(e,t))throw TypeError(`param "${t}" is invalid: expected own property`);let i=e[t];if(r&&i===void 0)return;let a=typeof i;if(a!==n||i===null)throw TypeError(`param "${t}" is invalid: expected ${n}, got ${a}`)}let i=(e,t)=>Object.entries(e).forEach(([e,n])=>r(e,n,t));i(t,!1),i(n,!0)}var R=BigInt(0),z=BigInt(1),Ti=BigInt(2),Ei=BigInt(3),Di=BigInt(4),Oi=BigInt(5),ki=BigInt(7),Ai=BigInt(8),ji=BigInt(9),Mi=BigInt(16);function B(e,t){if(t<=R)throw Error(`mod: expected positive modulus, got `+t);let n=e%t;return n>=R?n:t+n}function Ni(e,t){if(e===R)throw Error(`invert: expected non-zero number`);if(t<=R)throw Error(`invert: expected positive modulus, got `+t);let n=B(e,t),r=t,i=R,a=z,o=z,s=R;for(;n!==R;){let e=r/n,t=r-n*e,c=i-o*e,l=a-s*e;r=n,n=t,i=o,a=s,o=c,s=l}if(r!==z)throw Error(`invert: does not exist`);return B(i,t)}function Pi(e,t,n){let r=e;if(!r.eql(r.sqr(t),n))throw Error(`Cannot find square root`)}function Fi(e,t){let n=e,r=(n.ORDER+z)/Di,i=n.pow(t,r);return Pi(n,i,t),i}function Ii(e,t){let n=e,r=(n.ORDER-Oi)/Ai,i=n.mul(t,Ti),a=n.pow(i,r),o=n.mul(t,a),s=n.mul(n.mul(o,Ti),a),c=n.mul(o,n.sub(s,n.ONE));return Pi(n,c,t),c}function Li(e){let t=Ji(e),n=Ri(e),r=n(t,t.neg(t.ONE)),i=n(t,r),a=n(t,t.neg(r)),o=(e+ki)/Mi;return((e,t)=>{let n=e,s=n.pow(t,o),c=n.mul(s,r),l=n.mul(s,i),u=n.mul(s,a),d=n.eql(n.sqr(c),t),f=n.eql(n.sqr(l),t);s=n.cmov(s,c,d),c=n.cmov(u,l,f);let p=n.eql(n.sqr(c),t),m=n.cmov(s,c,p);return Pi(n,m,t),m})}function Ri(e){if(e<Ei)throw Error(`sqrt is not defined for small field`);let t=e-z,n=0;for(;t%Ti===R;)t/=Ti,n++;let r=Ti,i=Ji(e);for(;Wi(i,r)===1;)if(r++>1e3)throw Error(`Cannot find square root: probably non-prime P`);if(n===1)return Fi;let a=i.pow(r,t),o=(t+z)/Ti;return function(e,r){let i=e;if(i.is0(r))return r;if(Wi(i,r)!==1)throw Error(`Cannot find square root`);let s=n,c=i.mul(i.ONE,a),l=i.pow(r,t),u=i.pow(r,o);for(;!i.eql(l,i.ONE);){if(i.is0(l))return i.ZERO;let e=1,t=i.sqr(l);for(;!i.eql(t,i.ONE);)if(e++,t=i.sqr(t),e===s)throw Error(`Cannot find square root`);let n=z<<BigInt(s-e-1),r=i.pow(c,n);s=e,c=i.sqr(r),l=i.mul(l,c),u=i.mul(u,r)}return u}}function zi(e){return e%Di===Ei?Fi:e%Ai===Oi?Ii:e%Mi===ji?Li(e):Ri(e)}var Bi=[`create`,`isValid`,`is0`,`neg`,`inv`,`sqrt`,`sqr`,`eql`,`add`,`sub`,`mul`,`pow`,`div`,`addN`,`subN`,`mulN`,`sqrN`];function Vi(e){if(wi(e,Bi.reduce((e,t)=>(e[t]=`function`,e),{ORDER:`bigint`,BYTES:`number`,BITS:`number`})),ui(e.BYTES,`BYTES`),ui(e.BITS,`BITS`),e.BYTES<1||e.BITS<1)throw Error(`invalid field: expected BYTES/BITS > 0`);if(e.ORDER<=z)throw Error(`invalid field: expected ORDER > 1, got `+e.ORDER);return e}function Hi(e,t,n){let r=e;if(n<R)throw Error(`invalid exponent, negatives unsupported`);if(n===R)return r.ONE;if(n===z)return t;let i=r.ONE,a=t;for(;n>R;)n&z&&(i=r.mul(i,a)),a=r.sqr(a),n>>=z;return i}function Ui(e,t,n=!1){let r=e,i=Array(t.length).fill(n?r.ZERO:void 0),a=t.reduce((e,t,n)=>r.is0(t)?e:(i[n]=e,r.mul(e,t)),r.ONE),o=r.inv(a);return t.reduceRight((e,t,n)=>r.is0(t)?e:(i[n]=r.mul(e,i[n]),r.mul(e,t)),o),i}function Wi(e,t){let n=e,r=(n.ORDER-z)/Ti,i=n.pow(t,r),a=n.eql(i,n.ONE),o=n.eql(i,n.ZERO),s=n.eql(i,n.neg(n.ONE));if(!a&&!o&&!s)throw Error(`invalid Legendre symbol result`);return a?1:o?0:-1}function Gi(e,t){if(t!==void 0&&ei(t),e<=R)throw Error(`invalid n length: expected positive n, got `+e);if(t!==void 0&&t<1)throw Error(`invalid n length: expected positive bit length, got `+t);let n=xi(e);if(t!==void 0&&t<n)throw Error(`invalid n length: expected bit length (${n}) >= n.length (${t})`);let r=t===void 0?n:t;return{nBitLength:r,nByteLength:Math.ceil(r/8)}}var Ki=new WeakMap,qi=class{constructor(e,t={}){if(I(this,`ORDER`,void 0),I(this,`BITS`,void 0),I(this,`BYTES`,void 0),I(this,`isLE`,void 0),I(this,`ZERO`,R),I(this,`ONE`,z),I(this,`_lengths`,void 0),I(this,`_mod`,void 0),e<=z)throw Error(`invalid field: expected ORDER > 1, got `+e);let n;this.isLE=!1,typeof t==`object`&&t&&(typeof t.BITS==`number`&&(n=t.BITS),typeof t.sqrt==`function`&&Object.defineProperty(this,"sqrt",{value:t.sqrt,enumerable:!0}),typeof t.isLE==`boolean`&&(this.isLE=t.isLE),t.allowedLengths&&(this._lengths=Object.freeze(t.allowedLengths.slice())),typeof t.modFromBytes==`boolean`&&(this._mod=t.modFromBytes));let{nBitLength:r,nByteLength:i}=Gi(e,n);if(i>2048)throw Error(`invalid field: expected ORDER of <= 2048 bytes`);this.ORDER=e,this.BITS=r,this.BYTES=i,Object.freeze(this)}create(e){return B(e,this.ORDER)}isValid(e){if(typeof e!=`bigint`)throw TypeError(`invalid field element: expected bigint, got `+typeof e);return R<=e&&e<this.ORDER}is0(e){return e===R}isValidNot0(e){return!this.is0(e)&&this.isValid(e)}isOdd(e){return(e&z)===z}neg(e){return B(-e,this.ORDER)}eql(e,t){return e===t}sqr(e){return B(e*e,this.ORDER)}add(e,t){return B(e+t,this.ORDER)}sub(e,t){return B(e-t,this.ORDER)}mul(e,t){return B(e*t,this.ORDER)}pow(e,t){return Hi(this,e,t)}div(e,t){return B(e*Ni(t,this.ORDER),this.ORDER)}sqrN(e){return e*e}addN(e,t){return e+t}subN(e,t){return e-t}mulN(e,t){return e*t}inv(e){return Ni(e,this.ORDER)}sqrt(e){let t=Ki.get(this);return t||Ki.set(this,t=zi(this.ORDER)),t(this,e)}toBytes(e){return this.isLE?gi(e,this.BYTES):hi(e,this.BYTES)}fromBytes(e,t=!1){L(e);let{_lengths:n,BYTES:r,isLE:i,ORDER:a,_mod:o}=this;if(n){if(e.length<1||!n.includes(e.length)||e.length>r)throw Error(`Field.fromBytes: expected `+n+` bytes, got `+e.length);let t=new Uint8Array(r);t.set(e,i?0:t.length-e.length),e=t}if(e.length!==r)throw Error(`Field.fromBytes: expected `+r+` bytes, got `+e.length);let s=i?mi(e):pi(e);if(o&&(s=B(s,a)),!t&&!this.isValid(s))throw Error(`invalid field element: outside of range 0..ORDER`);return s}invertBatch(e){return Ui(this,e)}cmov(e,t,n){return ci(n,`condition`),n?t:e}};Object.freeze(qi.prototype);function Ji(e,t={}){return new qi(e,t)}function Yi(e){if(typeof e!=`bigint`)throw Error(`field order must be bigint`);if(e<=z)throw Error(`field order must be greater than 1`);let t=xi(e-z);return Math.ceil(t/8)}function Xi(e){let t=Yi(e);return t+Math.ceil(t/2)}function Zi(e,t,n=!1){L(e);let r=e.length,i=Yi(t),a=Math.max(Xi(t),16);if(r<a||r>1024)throw Error(`expected `+a+`-1024 bytes of input, got `+r);let o=B(n?mi(e):pi(e),t-z)+z;return n?gi(o,i):hi(o,i)}var Qi=BigInt(0),$i=BigInt(1);function ea(e,t){let n=t.negate();return e?n:t}function ta(e,t){let n=Ui(e.Fp,t.map(e=>e.Z));return t.map((t,r)=>e.fromAffine(t.toAffine(n[r])))}function na(e,t){if(!Number.isSafeInteger(e)||e<=0||e>t)throw Error(`invalid window size, expected [1..`+t+`], got W=`+e)}function ra(e,t){na(e,t);let n=Math.ceil(t/e)+1,r=2**(e-1),i=2**e;return{windows:n,windowSize:r,mask:Si(e),maxNumber:i,shiftBy:BigInt(e)}}function ia(e,t,n){let{windowSize:r,mask:i,maxNumber:a,shiftBy:o}=n,s=Number(e&i),c=e>>o;s>r&&(s-=a,c+=$i);let l=t*r,u=l+Math.abs(s)-1,d=s===0,f=s<0,p=t%2!=0;return{nextN:c,offset:u,isZero:d,isNeg:f,isNegF:p,offsetF:l}}var aa=new WeakMap,oa=new WeakMap;function sa(e){return oa.get(e)||1}function ca(e){if(e!==Qi)throw Error(`invalid wNAF`)}var la=class{constructor(e,t){I(this,`BASE`,void 0),I(this,`ZERO`,void 0),I(this,`Fn`,void 0),I(this,`bits`,void 0),this.BASE=e.BASE,this.ZERO=e.ZERO,this.Fn=e.Fn,this.bits=t}_unsafeLadder(e,t,n=this.ZERO){let r=e;for(;t>Qi;)t&$i&&(n=n.add(r)),r=r.double(),t>>=$i;return n}precomputeWindow(e,t){let{windows:n,windowSize:r}=ra(t,this.bits),i=[],a=e,o=a;for(let e=0;e<n;e++){o=a,i.push(o);for(let e=1;e<r;e++)o=o.add(a),i.push(o);a=o.double()}return i}wNAF(e,t,n){if(!this.Fn.isValid(n))throw Error(`invalid scalar`);let r=this.ZERO,i=this.BASE,a=ra(e,this.bits);for(let e=0;e<a.windows;e++){let{nextN:o,offset:s,isZero:c,isNeg:l,isNegF:u,offsetF:d}=ia(n,e,a);n=o,c?i=i.add(ea(u,t[d])):r=r.add(ea(l,t[s]))}return ca(n),{p:r,f:i}}wNAFUnsafe(e,t,n,r=this.ZERO){let i=ra(e,this.bits);for(let e=0;e<i.windows&&n!==Qi;e++){let{nextN:a,offset:o,isZero:s,isNeg:c}=ia(n,e,i);if(n=a,!s){let e=t[o];r=r.add(c?e.negate():e)}}return ca(n),r}getPrecomputes(e,t,n){let r=aa.get(t);return r||(r=this.precomputeWindow(t,e),e!==1&&(typeof n==`function`&&(r=n(r)),aa.set(t,r))),r}cached(e,t,n){let r=sa(e);return this.wNAF(r,this.getPrecomputes(r,e,n),t)}unsafe(e,t,n,r){let i=sa(e);return i===1?this._unsafeLadder(e,t,r):this.wNAFUnsafe(i,this.getPrecomputes(i,e,n),t,r)}createCache(e,t){na(t,this.bits),oa.set(e,t),aa.delete(e)}hasCache(e){return sa(e)!==1}};function ua(e,t,n,r){let i=t,a=e.ZERO,o=e.ZERO;for(;n>Qi||r>Qi;)n&$i&&(a=a.add(i)),r&$i&&(o=o.add(i)),i=i.double(),n>>=$i,r>>=$i;return{p1:a,p2:o}}function da(e,t,n){if(t){if(t.ORDER!==e)throw Error(`Field.ORDER must match order: Fp == p, Fn == n`);return Vi(t),t}else return Ji(e,{isLE:n})}function fa(e,t,n={},r){if(r===void 0&&(r=e===`edwards`),!t||typeof t!=`object`)throw Error(`expected valid ${e} CURVE object`);for(let e of[`p`,`n`,`h`]){let n=t[e];if(!(typeof n==`bigint`&&n>Qi))throw Error(`CURVE.${e} must be positive bigint`)}let i=da(t.p,n.Fp,r),a=da(t.n,n.Fn,r),o=[`Gx`,`Gy`,`a`,e===`weierstrass`?`b`:`d`];for(let e of o)if(!i.isValid(t[e]))throw Error(`CURVE.${e} must be valid field element of CURVE.Fp`);return t=Object.freeze(Object.assign({},t)),{CURVE:t,Fp:i,Fn:a}}function pa(e,t){return function(n){let r=e(n);return{secretKey:r,publicKey:t(r)}}}var ma=class{constructor(e,t){if(I(this,`oHash`,void 0),I(this,`iHash`,void 0),I(this,`blockLen`,void 0),I(this,`outputLen`,void 0),I(this,`canXOF`,!1),I(this,`finished`,!1),I(this,`destroyed`,!1),Dr(e),Er(t,void 0,`key`),this.iHash=e.create(),typeof this.iHash.update!=`function`)throw Error(`Expected instance of class which extends utils.Hash`);this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;let n=this.blockLen,r=new Uint8Array(n);r.set(t.length>n?e.create().update(t).digest():t);for(let e=0;e<r.length;e++)r[e]^=54;this.iHash.update(r),this.oHash=e.create();for(let e=0;e<r.length;e++)r[e]^=106;this.oHash.update(r),Ar(r)}update(e){return Or(this),this.iHash.update(e),this}digestInto(e){Or(this),kr(e,this),this.finished=!0;let t=e.subarray(0,this.outputLen);this.iHash.digestInto(t),this.oHash.update(t),this.oHash.digestInto(t),this.destroy()}digest(){let e=new Uint8Array(this.oHash.outputLen);return this.digestInto(e),e}_cloneInto(e){e||(e=Object.create(Object.getPrototypeOf(this),{}));let{oHash:t,iHash:n,finished:r,destroyed:i,blockLen:a,outputLen:o}=this;return e=e,e.finished=r,e.destroyed=i,e.blockLen=a,e.outputLen=o,e.oHash=t._cloneInto(e.oHash),e.iHash=n._cloneInto(e.iHash),e}clone(){return this._cloneInto()}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}},ha=(()=>{let e=((e,t,n)=>new ma(e,t).update(n).digest());return e.create=(e,t)=>new ma(e,t),e})(),ga=(e,t)=>(e+(e>=0?t:-t)/xa)/t;function _a(e,t,n){bi(`scalar`,e,H,n);let[[r,i],[a,o]]=t,s=ga(o*e,n),c=ga(-i*e,n),l=e-s*r-c*a,u=-s*i-c*o,d=l<H,f=u<H;d&&(l=-l),f&&(u=-u);let p=Si(Math.ceil(xi(n)/2))+ba;if(l<H||l>=p||u<H||u>=p)throw Error(`splitScalar (endomorphism): failed for k`);return{k1neg:d,k1:l,k2neg:f,k2:u}}function va(e){if(![`compact`,`recovered`,`der`].includes(e))throw Error(`Signature format must be "compact", "recovered", or "der"`);return e}function ya(e,t){wi(e);let n={};for(let r of Object.keys(t))n[r]=e[r]===void 0?t[r]:e[r];return ci(n.lowS,`lowS`),ci(n.prehash,`prehash`),n.format!==void 0&&va(n.format),n}var V={Err:class extends Error{constructor(e=``){super(e)}},_tlv:{encode:(e,t)=>{let{Err:n}=V;if(ui(e,`tag`),e<0||e>255)throw new n(`tlv.encode: wrong tag`);if(typeof t!=`string`)throw TypeError(`"data" expected string, got type=`+typeof t);if(t.length&1)throw new n(`tlv.encode: unpadded data`);let r=t.length/2,i=di(r);if(i.length/2&128)throw new n(`tlv.encode: long form length too big`);let a=r>127?di(i.length/2|128):``;return di(e)+a+i+t},decode(e,t){let{Err:n}=V;t=L(t,void 0,`DER data`);let r=0;if(e<0||e>255)throw new n(`tlv.encode: wrong tag`);if(t.length<2||t[r++]!==e)throw new n(`tlv.decode: wrong tlv`);let i=t[r++],a=!!(i&128),o=0;if(!a)o=i;else{let e=i&127;if(!e)throw new n(`tlv.decode(long): indefinite length not supported`);if(e>4)throw new n(`tlv.decode(long): byte length is too big`);let a=t.subarray(r,r+e);if(a.length!==e)throw new n(`tlv.decode: length bytes not complete`);if(a[0]===0)throw new n(`tlv.decode(long): zero leftmost byte`);for(let e of a)o=o<<8|e;if(r+=e,o<128)throw new n(`tlv.decode(long): not minimal encoding`)}let s=t.subarray(r,r+o);if(s.length!==o)throw new n(`tlv.decode: wrong value length`);return{v:s,l:t.subarray(r+o)}}},_int:{encode(e){let{Err:t}=V;if(li(e),e<H)throw new t(`integer: negative integers are not allowed`);let n=di(e);if(Number.parseInt(n[0],16)&8&&(n=`00`+n),n.length&1)throw new t(`unexpected DER parsing assertion: unpadded hex`);return n},decode(e){let{Err:t}=V;if(e.length<1)throw new t(`invalid signature integer: empty`);if(e[0]&128)throw new t(`invalid signature integer: negative`);if(e.length>1&&e[0]===0&&!(e[1]&128))throw new t(`invalid signature integer: unnecessary leading zero`);return pi(e)}},toSig(e){let{Err:t,_int:n,_tlv:r}=V,i=L(e,void 0,`signature`),{v:a,l:o}=r.decode(48,i);if(o.length)throw new t(`invalid signature: left bytes after parsing`);let{v:s,l:c}=r.decode(2,a),{v:l,l:u}=r.decode(2,c);if(u.length)throw new t(`invalid signature: left bytes after parsing`);return{r:n.decode(s),s:n.decode(l)}},hexFromSig(e){let{_tlv:t,_int:n}=V,r=t.encode(2,n.encode(e.r))+t.encode(2,n.encode(e.s));return t.encode(48,r)}};Object.freeze(V._tlv),Object.freeze(V._int),Object.freeze(V);var H=BigInt(0),ba=BigInt(1),xa=BigInt(2),Sa=BigInt(3),Ca=BigInt(4);function wa(e,t={}){var n;let r=fa(`weierstrass`,e,t),i=r.Fp,a=r.Fn,o=r.CURVE,{h:s,n:c}=o;wi(t,{},{allowInfinityPoint:`boolean`,clearCofactor:`function`,isTorsionFree:`function`,fromBytes:`function`,toBytes:`function`,endo:`object`});let{endo:l,allowInfinityPoint:u}=t;if(l&&(!i.is0(o.a)||typeof l.beta!=`bigint`||!Array.isArray(l.basises)))throw Error(`invalid endo: expected "beta": bigint and "basises": array`);let d=Ea(i,a);function f(){if(!i.isOdd)throw Error(`compression is not supported: Field does not have .isOdd()`)}function p(e,t,n){if(u&&t.is0())return Uint8Array.of(0);let{x:r,y:a}=t.toAffine(),o=i.toBytes(r);return ci(n,`isCompressed`),n?(f(),ni(Ta(!i.isOdd(a)),o)):ni(Uint8Array.of(4),o,i.toBytes(a))}function m(e){L(e,void 0,`Point`);let{publicKey:t,publicKeyUncompressed:n}=d,r=e.length,a=e[0],o=e.subarray(1);if(u&&r===1&&a===0)return{x:i.ZERO,y:i.ZERO};if(r===t&&(a===2||a===3)){let e=i.fromBytes(o);if(!i.isValid(e))throw Error(`bad point: is not on curve, wrong x`);let t=_(e),n;try{n=i.sqrt(t)}catch(e){let t=e instanceof Error?`: `+e.message:``;throw Error(`bad point: is not on curve, sqrt error`+t)}f();let r=i.isOdd(n);return(a&1)==1!==r&&(n=i.neg(n)),{x:e,y:n}}else if(r===n&&a===4){let e=i.BYTES,t=i.fromBytes(o.subarray(0,e)),n=i.fromBytes(o.subarray(e,e*2));if(!v(t,n))throw Error(`bad point: is not on curve`);return{x:t,y:n}}else throw Error(`bad point: got length ${r}, expected compressed=${t} or uncompressed=${n}`)}let h=t.toBytes===void 0?p:t.toBytes,g=t.fromBytes===void 0?m:t.fromBytes;function _(e){let t=i.sqr(e),n=i.mul(t,e);return i.add(i.add(n,i.mul(e,o.a)),o.b)}function v(e,t){let n=i.sqr(t),r=_(e);return i.eql(n,r)}if(!v(o.Gx,o.Gy))throw Error(`bad curve params: generator point`);let y=i.mul(i.pow(o.a,Sa),Ca),b=i.mul(i.sqr(o.b),BigInt(27));if(i.is0(i.add(y,b)))throw Error(`bad curve params: a or b`);function x(e,t,n=!1){if(!i.isValid(t)||n&&i.is0(t))throw Error(`bad point coordinate ${e}`);return t}function S(e){if(!(e instanceof T))throw Error(`Weierstrass Point expected`)}function C(e){if(!l||!l.basises)throw Error(`no endo`);return _a(e,l.basises,a.ORDER)}function w(e,t,n,r,a){return n=new T(i.mul(n.X,e),n.Y,n.Z),t=ea(r,t),n=ea(a,n),t.add(n)}class T{constructor(e,t,n){I(this,`X`,void 0),I(this,`Y`,void 0),I(this,`Z`,void 0),this.X=x(`x`,e),this.Y=x(`y`,t,!0),this.Z=x(`z`,n),Object.freeze(this)}static CURVE(){return o}static fromAffine(e){let{x:t,y:n}=e||{};if(!e||!i.isValid(t)||!i.isValid(n))throw Error(`invalid affine point`);if(e instanceof T)throw Error(`projective point not allowed`);return i.is0(t)&&i.is0(n)?T.ZERO:new T(t,n,i.ONE)}static fromBytes(e){let t=T.fromAffine(g(L(e,void 0,`point`)));return t.assertValidity(),t}static fromHex(e){return T.fromBytes(ri(e))}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(e=8,t=!0){return D.createCache(this,e),t||this.multiply(Sa),this}assertValidity(){let e=this;if(e.is0()){if(t.allowInfinityPoint&&i.is0(e.X)&&i.eql(e.Y,i.ONE)&&i.is0(e.Z))return;throw Error(`bad point: ZERO`)}let{x:n,y:r}=e.toAffine();if(!i.isValid(n)||!i.isValid(r))throw Error(`bad point: x or y not field elements`);if(!v(n,r))throw Error(`bad point: equation left != right`);if(!e.isTorsionFree())throw Error(`bad point: not in prime-order subgroup`)}hasEvenY(){let{y:e}=this.toAffine();if(!i.isOdd)throw Error(`Field doesn't support isOdd`);return!i.isOdd(e)}equals(e){S(e);let{X:t,Y:n,Z:r}=this,{X:a,Y:o,Z:s}=e,c=i.eql(i.mul(t,s),i.mul(a,r)),l=i.eql(i.mul(n,s),i.mul(o,r));return c&&l}negate(){return new T(this.X,i.neg(this.Y),this.Z)}double(){let{a:e,b:t}=o,n=i.mul(t,Sa),{X:r,Y:a,Z:s}=this,c=i.ZERO,l=i.ZERO,u=i.ZERO,d=i.mul(r,r),f=i.mul(a,a),p=i.mul(s,s),m=i.mul(r,a);return m=i.add(m,m),u=i.mul(r,s),u=i.add(u,u),c=i.mul(e,u),l=i.mul(n,p),l=i.add(c,l),c=i.sub(f,l),l=i.add(f,l),l=i.mul(c,l),c=i.mul(m,c),u=i.mul(n,u),p=i.mul(e,p),m=i.sub(d,p),m=i.mul(e,m),m=i.add(m,u),u=i.add(d,d),d=i.add(u,d),d=i.add(d,p),d=i.mul(d,m),l=i.add(l,d),p=i.mul(a,s),p=i.add(p,p),d=i.mul(p,m),c=i.sub(c,d),u=i.mul(p,f),u=i.add(u,u),u=i.add(u,u),new T(c,l,u)}add(e){S(e);let{X:t,Y:n,Z:r}=this,{X:a,Y:s,Z:c}=e,l=i.ZERO,u=i.ZERO,d=i.ZERO,f=o.a,p=i.mul(o.b,Sa),m=i.mul(t,a),h=i.mul(n,s),g=i.mul(r,c),_=i.add(t,n),v=i.add(a,s);_=i.mul(_,v),v=i.add(m,h),_=i.sub(_,v),v=i.add(t,r);let y=i.add(a,c);return v=i.mul(v,y),y=i.add(m,g),v=i.sub(v,y),y=i.add(n,r),l=i.add(s,c),y=i.mul(y,l),l=i.add(h,g),y=i.sub(y,l),d=i.mul(f,v),l=i.mul(p,g),d=i.add(l,d),l=i.sub(h,d),d=i.add(h,d),u=i.mul(l,d),h=i.add(m,m),h=i.add(h,m),g=i.mul(f,g),v=i.mul(p,v),h=i.add(h,g),g=i.sub(m,g),g=i.mul(f,g),v=i.add(v,g),m=i.mul(h,v),u=i.add(u,m),m=i.mul(y,v),l=i.mul(_,l),l=i.sub(l,m),m=i.mul(_,h),d=i.mul(y,d),d=i.add(d,m),new T(l,u,d)}subtract(e){return S(e),this.add(e.negate())}is0(){return this.equals(T.ZERO)}multiply(e){let{endo:n}=t;if(!a.isValidNot0(e))throw RangeError(`invalid scalar: out of range`);let r,i,o=e=>D.cached(this,e,e=>ta(T,e));if(n){let{k1neg:t,k1:a,k2neg:s,k2:c}=C(e),{p:l,f:u}=o(a),{p:d,f}=o(c);i=u.add(f),r=w(n.beta,l,d,t,s)}else{let{p:t,f:n}=o(e);r=t,i=n}return ta(T,[r,i])[0]}multiplyUnsafe(e){let{endo:n}=t,r=this,i=e;if(!a.isValid(i))throw RangeError(`invalid scalar: out of range`);if(i===H||r.is0())return T.ZERO;if(i===ba)return r;if(D.hasCache(this))return this.multiply(i);if(n){let{k1neg:e,k1:t,k2neg:a,k2:o}=C(i),{p1:s,p2:c}=ua(T,r,t,o);return w(n.beta,s,c,e,a)}else return D.unsafe(r,i)}toAffine(e){let t=this,n=e,{X:r,Y:a,Z:o}=t;if(i.eql(o,i.ONE))return{x:r,y:a};let s=t.is0();n??(n=s?i.ONE:i.inv(o));let c=i.mul(r,n),l=i.mul(a,n),u=i.mul(o,n);if(s)return{x:i.ZERO,y:i.ZERO};if(!i.eql(u,i.ONE))throw Error(`invZ was invalid`);return{x:c,y:l}}isTorsionFree(){let{isTorsionFree:e}=t;return s===ba?!0:e?e(T,this):D.unsafe(this,c).is0()}clearCofactor(){let{clearCofactor:e}=t;return s===ba?this:e?e(T,this):this.multiplyUnsafe(s)}isSmallOrder(){return s===ba?this.is0():this.clearCofactor().is0()}toBytes(e=!0){return ci(e,`isCompressed`),this.assertValidity(),h(T,this,e)}toHex(e=!0){return ti(this.toBytes(e))}toString(){return`<Point ${this.is0()?`ZERO`:this.toHex()}>`}}n=T,I(T,`BASE`,new n(o.Gx,o.Gy,i.ONE)),I(T,`ZERO`,new n(i.ZERO,i.ONE,i.ZERO)),I(T,`Fp`,i),I(T,`Fn`,a);let E=a.BITS,D=new la(T,t.endo?Math.ceil(E/2):E);return E>=8&&T.BASE.precompute(8),Object.freeze(T.prototype),Object.freeze(T),T}function Ta(e){return Uint8Array.of(e?2:3)}function Ea(e,t){return{secretKey:t.BYTES,publicKey:1+e.BYTES,publicKeyUncompressed:1+2*e.BYTES,publicKeyHasPrefix:!0,signature:2*t.BYTES}}function Da(e,t={}){let{Fn:n}=e,r=t.randomBytes===void 0?ai:t.randomBytes,i=Object.assign(Ea(e.Fp,n),{seed:Math.max(Xi(n.ORDER),16)});function a(e){try{let t=n.fromBytes(e);return n.isValidNot0(t)}catch{return!1}}function o(t,n){let{publicKey:r,publicKeyUncompressed:a}=i;try{let i=t.length;return n===!0&&i!==r||n===!1&&i!==a?!1:!!e.fromBytes(t)}catch{return!1}}function s(e){return e=e===void 0?r(i.seed):e,Zi(L(e,i.seed,`seed`),n.ORDER)}function c(t,r=!0){return e.BASE.multiply(n.fromBytes(t)).toBytes(r)}function l(e){let{secretKey:t,publicKey:r,publicKeyUncompressed:a}=i,o=n._lengths;if(!ii(e))return;let s=L(e,void 0,`key`).length,c=s===r||s===a,l=s===t||!!o?.includes(s);if(!(c&&l))return c}function u(t,r,i=!0){if(l(t)===!0)throw Error(`first arg must be private key`);if(l(r)===!1)throw Error(`second arg must be public key`);let a=n.fromBytes(t);return e.fromBytes(r).multiply(a).toBytes(i)}let d={isValidSecretKey:a,isValidPublicKey:o,randomSecretKey:s},f=pa(s,c);return Object.freeze(d),Object.freeze(i),Object.freeze({getPublicKey:c,getSharedSecret:u,keygen:f,Point:e,utils:d,lengths:i})}function Oa(e,t,n={}){let r=t;Dr(r),wi(n,{},{hmac:`function`,lowS:`boolean`,randomBytes:`function`,bits2int:`function`,bits2int_modN:`function`}),n=Object.assign({},n);let i=n.randomBytes===void 0?ai:n.randomBytes,a=n.hmac===void 0?(e,t)=>ha(r,e,t):n.hmac,{Fp:o,Fn:s}=e,{ORDER:c,BITS:l}=s,{keygen:u,getPublicKey:d,getSharedSecret:f,utils:p,lengths:m}=Da(e,n),h={prehash:!0,lowS:typeof n.lowS!=`boolean`||n.lowS,format:`compact`,extraEntropy:!1},g=c*xa+ba<o.ORDER;function _(e){return e>c>>ba}function v(e,t){if(!s.isValidNot0(t))throw Error(`invalid signature ${e}: out of range 1..Point.Fn.ORDER`);return t}function y(){if(g)throw Error(`"recovered" sig type is not supported for cofactor >2 curves`)}function b(e,t){va(t);let n=m.signature;return L(e,t===`compact`?n:t===`recovered`?n+1:void 0)}class x{constructor(e,t,n){if(I(this,`r`,void 0),I(this,`s`,void 0),I(this,`recovery`,void 0),this.r=v(`r`,e),this.s=v(`s`,t),n!=null){if(y(),![0,1,2,3].includes(n))throw Error(`invalid recovery id`);this.recovery=n}Object.freeze(this)}static fromBytes(e,t=h.format){b(e,t);let n;if(t===`der`){let{r:t,s:n}=V.toSig(L(e));return new x(t,n)}t===`recovered`&&(n=e[0],t=`compact`,e=e.subarray(1));let r=m.signature/2,i=e.subarray(0,r),a=e.subarray(r,r*2);return new x(s.fromBytes(i),s.fromBytes(a),n)}static fromHex(e,t){return this.fromBytes(ri(e),t)}assertRecovery(){let{recovery:e}=this;if(e==null)throw Error(`invalid recovery id: must be present`);return e}addRecoveryBit(e){return new x(this.r,this.s,e)}recoverPublicKey(t){let{r:n,s:r}=this,i=this.assertRecovery(),a=i===2||i===3?n+c:n;if(!o.isValid(a))throw Error(`invalid recovery id: sig.r+curve.n != R.x`);let l=o.toBytes(a),u=e.fromBytes(ni(Ta((i&1)==0),l)),d=s.inv(a),f=C(L(t,void 0,`msgHash`)),p=s.create(-f*d),m=s.create(r*d),h=e.BASE.multiplyUnsafe(p).add(u.multiplyUnsafe(m));if(h.is0())throw Error(`invalid recovery: point at infinify`);return h.assertValidity(),h}hasHighS(){return _(this.s)}toBytes(e=h.format){if(va(e),e===`der`)return ri(V.hexFromSig(this));let{r:t,s:n}=this,r=s.toBytes(t),i=s.toBytes(n);return e===`recovered`?(y(),ni(Uint8Array.of(this.assertRecovery()),r,i)):ni(r,i)}toHex(e){return ti(this.toBytes(e))}}Object.freeze(x.prototype),Object.freeze(x);let S=n.bits2int===void 0?function(e){if(e.length>8192)throw Error(`input is too large`);let t=pi(e),n=e.length*8-l;return n>0?t>>BigInt(n):t}:n.bits2int,C=n.bits2int_modN===void 0?function(e){return s.create(S(e))}:n.bits2int_modN,w=Si(l);function T(e){return bi(`num < 2^`+l,e,H,w),s.toBytes(e)}function E(e,t){return L(e,void 0,`message`),t?L(r(e),void 0,`prehashed message`):e}function D(t,n,r){let{lowS:a,prehash:o,extraEntropy:c}=ya(r,h);t=E(t,o);let l=C(t),u=s.fromBytes(n);if(!s.isValidNot0(u))throw Error(`invalid private key`);let d=[T(u),T(l)];if(c!=null&&c!==!1){let e=c===!0?i(m.secretKey):c;d.push(L(e,void 0,`extraEntropy`))}let f=ni(...d),p=l;function v(t){let n=S(t);if(!s.isValidNot0(n))return;let r=s.inv(n),i=e.BASE.multiply(n).toAffine(),o=s.create(i.x);if(o===H)return;let c=s.create(r*s.create(p+o*u));if(c===H)return;let l=(i.x===o?0:2)|Number(i.y&ba),d=c;return a&&_(c)&&(d=s.neg(c),l^=1),new x(o,d,g?void 0:l)}return{seed:f,k2sig:v}}function ee(e,t,n={}){let{seed:i,k2sig:o}=D(e,t,n);return Ci(r.outputLen,s.BYTES,a)(i,o).toBytes(n.format)}function te(t,n,r,i={}){let{lowS:a,prehash:o,format:c}=ya(i,h);if(r=L(r,void 0,`publicKey`),n=E(n,o),!ii(t)){let e=t instanceof x?`, use sig.toBytes()`:``;throw Error(`verify expects Uint8Array signature`+e)}b(t,c);try{let i=x.fromBytes(t,c),o=e.fromBytes(r);if(a&&i.hasHighS())return!1;let{r:l,s:u}=i,d=C(n),f=s.inv(u),p=s.create(d*f),m=s.create(l*f),h=e.BASE.multiplyUnsafe(p).add(o.multiplyUnsafe(m));return!h.is0()&&s.create(h.x)===l}catch{return!1}}function ne(e,t,n={}){let{prehash:r}=ya(n,h);return t=E(t,r),x.fromBytes(e,`recovered`).recoverPublicKey(t).toBytes()}return Object.freeze({keygen:u,getPublicKey:d,getSharedSecret:f,utils:p,lengths:m,Point:e,sign:ee,verify:te,recoverPublicKey:ne,Signature:x,hash:r})}var ka=Oa(wa({p:BigInt(`0xffffffff00000001000000000000000000000000ffffffffffffffffffffffff`),n:BigInt(`0xffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551`),h:BigInt(1),a:BigInt(`0xffffffff00000001000000000000000000000000fffffffffffffffffffffffc`),b:BigInt(`0x5ac635d8aa3a93e7b3ebbd55769886bc651d06b0cc53b0f63bce3c3e27d2604b`),Gx:BigInt(`0x6b17d1f2e12c4247f8bce6e563a440f277037d812deb33a0f4a13945d898c296`),Gy:BigInt(`0x4fe342e2fe1a7f9b8ee7eb4a7c0f9e162bce33576b315ececbb6406837bf51f5`)}),$r);function Aa(e,t,n){let r=ja(n);if(!r)return!1;try{return ka.verify(t,e,r,{lowS:!1})}catch{return!1}}function ja(e){if(e.kty!==`EC`||e.crv!==`P-256`||!e.x||!e.y)return null;let t=_r(e.x),n=_r(e.y);if(!t||!n||t.length!==32||n.length!==32)return null;let r=new Uint8Array(65);return r[0]=4,r.set(t,1),r.set(n,33),r}var Ma={status:`unlicensed`},Na={status:`pending`};function Pa(e,t,n){let r=Date.parse(e);return Number.isNaN(r)?!1:r>=t||!Number.isNaN(n)&&r>=n}async function Fa(e,t,n,r){let i=yr(e);if(!i)return Ma;let a=t[i.payload.keyId];if(!a)return{status:`unlicensed`,payload:i.payload};let o=br(i.version,i.encodedPayload);if(!(Sr()?await Cr(o,i.signature,a):Aa(o,i.signature,a)))return{status:`unlicensed`,payload:i.payload};let s=Date.parse(r);return Pa(i.payload.expiry,n,s)?{status:`licensed`,payload:i.payload}:{status:`unlicensed`,payload:i.payload}}var Ia=null,La=Ma,Ra=new Map,za=new Set,Ba=0;function Va(){Ba++}function Ha(){Ba--}function Ua(){return Ba}function Wa(e){La=e;for(let t of za)t(e)}function Ga(e){if(e===Ia)return;Ia=e;let t=Ra.get(e);if(t){Wa(t);return}Wa(Na),Fa(e,xr,Date.now(),`2026-09-09`).then(t=>{Ra.set(e,t),Ia===e&&Wa(t)})}function Ka(){return La}function qa(e){return za.add(e),e(La),()=>za.delete(e)}var Ja=`docs/LICENSING.md`,Ya=!1;function Xa(e){if(Ya)return;Ya=!0;let t=e>1?` (${e} instances on this page)`:``;console.info(`[VScada] Running in unlicensed/evaluation mode${t} — full functionality, watermarked. See ${Ja} to apply a license key.`)}var Za=`http://www.w3.org/2000/svg`,Qa=`vscada-watermark-pattern`,$a=`#808080`;function eo(e,t,n){if(!n.querySelector(`#${Qa}`)){let e=document.createElementNS(Za,`pattern`);e.setAttribute(`id`,Qa),e.setAttribute(`width`,`320`),e.setAttribute(`height`,`200`),e.setAttribute(`patternUnits`,`userSpaceOnUse`),e.setAttribute(`patternTransform`,`rotate(-30)`);let t=document.createElementNS(Za,`text`);t.setAttribute(`x`,`10`),t.setAttribute(`y`,`100`),t.setAttribute(`font-size`,`20`),t.setAttribute(`fill`,$a),t.textContent=`VScada — unlicensed`,e.appendChild(t),n.appendChild(e)}let r=document.createElementNS(Za,`g`);r.setAttribute(`class`,`vscada-watermark-repeat`),r.setAttribute(`pointer-events`,`none`),r.setAttribute(`display`,`none`);let i=document.createElementNS(Za,`rect`);i.setAttribute(`width`,String(e)),i.setAttribute(`height`,String(t)),i.setAttribute(`fill`,`url(#${Qa})`),i.setAttribute(`opacity`,`0.12`),r.appendChild(i);let a=document.createElementNS(Za,`g`);a.setAttribute(`class`,`vscada-watermark-badge`),a.setAttribute(`pointer-events`,`none`),a.setAttribute(`display`,`none`);let o=document.createElementNS(Za,`text`);o.setAttribute(`x`,String(e-8)),o.setAttribute(`y`,String(t-8)),o.setAttribute(`text-anchor`,`end`),o.setAttribute(`font-size`,`12`),o.setAttribute(`fill`,$a),o.setAttribute(`opacity`,`0.7`),o.textContent=`VScada — unlicensed`,a.appendChild(o);function s(e){let t=e?`inline`:`none`;r.setAttribute(`display`,t),a.setAttribute(`display`,t)}return{repeat:r,badge:a,setVisible:s}}var to=`http://www.w3.org/2000/svg`;function no(e){let t=e.cloneNode(!0);return ro(e,t),t.getAttribute(`xmlns`)||t.setAttribute(`xmlns`,to),new XMLSerializer().serializeToString(t)}function ro(e,t){io(e,t);let n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT),r=document.createTreeWalker(t,NodeFilter.SHOW_ELEMENT),i=n.nextNode(),a=r.nextNode();for(;i&&a;)io(i,a),i=n.nextNode(),a=r.nextNode()}function io(e,t){let n=getComputedStyle(e),r=n.transform;r&&r!==`none`&&(t.style.transform=r),ao(n,t),oo(n,t)}function ao(e,t){let n=t.getAttribute(`style`);if(!n||!n.includes(`var(`))return;let r=n.split(`;`).map(e=>e.trim()).filter(Boolean).map(t=>{let n=t.indexOf(`:`);if(n===-1)return t;let r=t.slice(0,n).trim(),i=t.slice(n+1).trim();return i.includes(`var(`)?`${r}: ${e.getPropertyValue(r).trim()||i}`:`${r}: ${i}`}).join(`; `);t.setAttribute(`style`,r)}function oo(e,t){for(let n of[...t.attributes]){if(n.name===`style`||!n.value.includes(`var(`))continue;let r=e.getPropertyValue(n.name).trim();r&&t.setAttribute(n.name,r)}}var so=`(prefers-reduced-motion: reduce)`,co=class{constructor(e,t,n){this.target=e,this.staticRepresentations=t,this.matchMedia=n,this.mql=null,this.onChange=e=>this.apply(e.matches),this.priorAnimated=null}connect(){!this.matchMedia||this.mql||(this.mql=this.matchMedia(so),this.mql.addEventListener(`change`,this.onChange),this.apply(this.mql.matches))}disconnect(){this.mql?.removeEventListener(`change`,this.onChange),this.mql=null}get active(){return this.mql?.matches??!1}apply(e){e?(this.priorAnimated===null&&(this.priorAnimated=this.target.animated),this.staticRepresentations.activateAll(),this.target.animated=!1):(this.priorAnimated!==null&&(this.target.animated=this.priorAnimated,this.priorAnimated=null),this.staticRepresentations.deactivateAll())}},lo=class{constructor(){this.entries=[],this.active=!1}register(e,t){this.entries.push({elementId:e,handle:t}),this.active&&t.activate()}unregisterElement(e){this.entries=this.entries.filter(t=>t.elementId!==e)}activateAll(){this.active=!0;for(let e of this.entries)e.handle.activate()}deactivateAll(){this.active=!1;for(let e of this.entries)e.handle.deactivate()}get isActive(){return this.active}},uo=class{constructor(){this.target=null,this.pending=[],this.flushScheduled=!1,this.sawDisconnect=!1}attach(e){this.target=e}announceConditionTransition(e,t,n){if(!(t!==`bad`&&t!==`stale`)){if(t===`stale`&&n){if(this.sawDisconnect)return;this.sawDisconnect=!0,this.enqueue(`Scene disconnected`);return}this.enqueue(t===`bad`?`${e} quality bad`:`${e} stale`)}}announceThresholdCrossing(e,t,n){n!==`normal`&&this.enqueue(`${e} ${t} ${n} alarm`)}enqueue(e){this.pending.push(e),!this.flushScheduled&&(this.flushScheduled=!0,queueMicrotask(()=>this.flush()))}flush(){this.flushScheduled=!1,this.sawDisconnect=!1;let e=this.pending.join(`; `);this.pending=[],this.target&&(this.target.textContent=e)}};function fo(e,t){let n=new Set;for(let r of t)(r.direction===`below`?e<=r.value:e>=r.value)&&n.add(r.level);return n.has(`low-low`)?`low-low`:n.has(`high-high`)?`high-high`:n.has(`low`)?`low`:n.has(`high`)?`high`:`normal`}function po(e,t,n){if(!e)return n;switch(t){case`low-low`:return e.lowLowColor;case`low`:return e.lowColor;case`high`:return e.highColor;case`high-high`:return e.highHighColor;default:return e.normalColor}}var mo,ho=`http://www.w3.org/2000/svg`;function go(e){return e.type===`off-page`}function _o(e){return e.type===`svg-import`}function vo(e){return e.startsWith(`__vessel-wave-animation-`)||e.startsWith(`__vapor-drift-animation-`)?`wave`:e.startsWith(`pipe-flow-animation`)?`flow`:e.startsWith(`__rotating-animations-`)?`rotation`:e.startsWith(`__indicator-lamp-animation-`)?`state-lamp`:`rotation`}var yo=class extends Le{constructor(e=nt,t=rt,n=typeof window<`u`&&typeof window.matchMedia==`function`?window.matchMedia.bind(window):void 0){super(),this._scene=null,this._lastError=null,this._pendingDevValidation=null,this._sceneGeneration=0,this._staticRepresentations=new lo,this._liveRegion=new uo,this._unsubscribeConditionTransition=null,this._builtElements=[],this._builtDefs=null,this._watermark=null,this._licenseVerdict={status:`unlicensed`},this._needsStructureInsert=!1,this._schedulerStarted=!1,this._unsubscribeLicense=null,this._interactive=!0,this._gestureArbiter=tr(),this._hitLayerGroup=null,this._hitAreaEntries=[],this._viewportGroup=null,this._lodActive=!1,this._listenersAttached=!1,this._isIntersecting=!0,this._intersectionObserver=null,this._boundVisibilityChange=null,this._unsubscribeRenderStats=null,this._groupViewState=null,this._flowInferenceCache=null,this._flowStoppedSourceIds=new Set,this._flowClosedNodeIds=new Set,this._flowTrackedElementIds=[],this._renderer=t,this._store=new Gt(e,e=>this._dispatchValueWarning(e)),this._animations=new qt,this._scheduler=new cn(e,this._store,t,this._animations),this._reducedMotion=new co(this,this._staticRepresentations,n),this._unsubscribeConditionTransition=this._scheduler.onConditionTransition((e,t,n)=>this._handleConditionTransition(e,n)),this._viewportState=hr(e,e=>this._onViewportFrame(e)),this._panZoomGestures=or({onPan:(e,t)=>{let n=this._viewBoxScale();this._viewportState.panBy(e*n,t*n)},onZoomAboutPoint:(e,t,n)=>{let r=this._toCanvasPoint(t,n);this._viewportState.zoomAboutPoint(e,r.x,r.y)},getZoom:()=>this._viewportState.zoom})}get stalenessTimeout(){return this._scheduler.stalenessTimeout}set stalenessTimeout(e){this._scheduler.stalenessTimeout=e}get snapThreshold(){return this._scheduler.snapThreshold}set snapThreshold(e){this._scheduler.snapThreshold=e}get connectionState(){return this._scheduler.connectionState}set connectionState(e){this._scheduler.connectionState=e}get mode(){return this._scheduler.mode}set mode(e){this._scheduler.mode=e}get animated(){return this._scheduler.animate}set animated(e){this._scheduler.animate=e}get reducedMotionActive(){return this._reducedMotion.active}snapToTargets(){this._scheduler.snapToTargets(),this._viewportState.snap()}get interactive(){return this._interactive}set interactive(e){this._interactive=e}get zoom(){return this._viewportState.zoom}set zoom(e){this._viewportState.setZoomAnimated(e)}get debug(){return this._scheduler.debug}set debug(e){this._scheduler.debug=e,e&&!this._unsubscribeRenderStats?this._unsubscribeRenderStats=this._scheduler.onRenderStats(e=>this._dispatchRenderStats(e)):!e&&this._unsubscribeRenderStats&&(this._unsubscribeRenderStats(),this._unsubscribeRenderStats=null)}seekAll(e){this._animations.seekAll(e)}exportSVG(){let e=this.renderRoot?.querySelector(`svg`);return e?no(e):``}static get observedAttributes(){return[...super.observedAttributes,`license-key`,`tag-prefix`,`interactive`,`mode`,`animated`]}attributeChangedCallback(e,t,n){super.attributeChangedCallback(e,t,n),e===`license-key`&&n!==null&&n!==t&&Ga(n),e===`tag-prefix`&&n!==t&&(this.tagPrefix=n??``),e===`interactive`&&n!==t&&(this.interactive=n!==`false`),e===`mode`&&n!==t&&(this.mode=n===`static`?`static`:`live`),e===`animated`&&n!==t&&(this.animated=n!==`false`)}get tagPrefix(){return this._store.tagPrefix}set tagPrefix(e){this._store.tagPrefix=e}get scene(){return this._scene}set scene(e){if(e===this._scene)return;let t=++this._sceneGeneration;this._teardownBuiltElements();let n=Ue(e,Ye());if(!n.ok){this._scene=null,this._lastError=n.error,this._pendingDevValidation=null,this.dispatchEvent(new CustomEvent(`scene-error`,{detail:n.error,bubbles:!0,composed:!0})),this.requestUpdate();return}this._scene=n.scene,this._lastError=null,this._groupViewState?this._groupViewState.reset(this._scene):this._groupViewState=new Xn(this._scene,this._animations),this._viewportState.reset(this._scene.canvas.width,this._scene.canvas.height),this._buildElements(this._scene),this.requestUpdate(),this._pendingDevValidation=We(e).then(e=>{if(t===this._sceneGeneration&&!(!e||e.length===0)){for(let t of e)console.warn(`[vscada] scene diagnostic at "${t.path}": ${t.message}`);this.dispatchEvent(new CustomEvent(`scene-error`,{detail:{code:`BAD_SHAPE`,message:`${e.length} dev-only Zod diagnostic(s); see console`,path:e[0].path},bubbles:!0,composed:!0}))}}).catch(e=>{console.error(`[vscada] dev-only scene validation failed`,e)})}get pendingDevValidation(){return this._pendingDevValidation}get values(){return Array.from(this._store.tags()).map(e=>{let t=this._store.get(e),n={tag:e,value:t.currentValue,quality:t.quality};return t.timestamp!==void 0&&(n.timestamp=t.timestamp),n})}set values(e){this.setValues(e)}setValues(e){this._store.setValues(e),this._scheduler.mode===`static`?this._scheduler.snapToTargets():this._maybeStartScheduler()}clearValues(){this._store.clearValues()}connectedCallback(){super.connectedCallback(),Va();let e=!0;this._unsubscribeLicense=qa(t=>{if(e){e=!1,queueMicrotask(()=>this._onLicenseVerdict(Ka()));return}this._onLicenseVerdict(t)}),this._maybeStartScheduler(),this._reducedMotion.connect(),typeof IntersectionObserver<`u`&&(this._intersectionObserver=new IntersectionObserver(e=>{let t=e[e.length-1];t&&(this._isIntersecting=t.isIntersecting,this._syncVisibilityPause())}),this._intersectionObserver.observe(this)),typeof document<`u`&&(this._boundVisibilityChange=()=>this._syncVisibilityPause(),document.addEventListener(`visibilitychange`,this._boundVisibilityChange))}disconnectedCallback(){super.disconnectedCallback(),Ha(),this._reducedMotion.disconnect(),this._unsubscribeConditionTransition?.(),this._unsubscribeLicense?.(),this._unsubscribeLicense=null,this._intersectionObserver?.disconnect(),this._intersectionObserver=null,this._boundVisibilityChange&&(document.removeEventListener(`visibilitychange`,this._boundVisibilityChange),this._boundVisibilityChange=null),this._viewportState.destroy(),this._scheduler.stop(),this._schedulerStarted=!1}_onLicenseVerdict(e){this._licenseVerdict=e,this._watermark?.setVisible(e.status===`unlicensed`),e.status===`unlicensed`&&Xa(Ua())}firstUpdated(){let e=this.renderRoot.querySelector(`.vscada-live-region`);e&&this._liveRegion.attach(e);let t=this.renderRoot.querySelector(`svg`);!t||this._listenersAttached||(this._listenersAttached=!0,this._attachPanZoomListeners(t))}updated(e){if(super.updated(e),!this._needsStructureInsert)return;this._needsStructureInsert=!1;let t=this.renderRoot.querySelector(`svg`);if(t){for(;t.firstChild;)t.removeChild(t.firstChild);this._builtDefs&&t.appendChild(this._builtDefs),this._watermark&&t.appendChild(this._watermark.repeat),this._viewportGroup=document.createElementNS(ho,`g`),this._viewportGroup.setAttribute(`class`,`vscada-viewport`);for(let e of this._builtElements)this._viewportGroup.appendChild(e.svg);this._hitLayerGroup&&this._viewportGroup.appendChild(this._hitLayerGroup),t.appendChild(this._viewportGroup),this._applyViewportTransform({zoom:this._viewportState.zoom,panX:this._viewportState.pan.x,panY:this._viewportState.pan.y}),this._watermark&&t.appendChild(this._watermark.badge)}}render(){let e=ye`<div class="vscada-live-region" aria-live="assertive" aria-atomic="true"></div>`;if(this._lastError)return ye`${e}`;let t=this._scene?.canvas.width??100,n=this._scene?.canvas.height??100;return ye`<svg part="canvas" role="graphics-document" aria-label=${this._scene?`SCADA diagram: ${this._scene.id}`:`SCADA diagram`} viewBox="0 0 ${t} ${n}"></svg>${e}`}_buildElements(e){this._builtDefs=document.createElementNS(`http://www.w3.org/2000/svg`,`defs`);let t={tokens:tt(e.theme??`classic-hmi`),defs:this._builtDefs};t.tokens.focusRing&&(this.style.setProperty(`--vscada-focus-ring-color`,t.tokens.focusRing.color),this.style.setProperty(`--vscada-focus-ring-width`,`${t.tokens.focusRing.widthPx}px`),this.style.setProperty(`--vscada-focus-ring-offset`,`${t.tokens.focusRing.offsetPx}px`)),this._watermark=eo(e.canvas.width,e.canvas.height,this._builtDefs),this._watermark.setVisible(this._licenseVerdict.status===`unlicensed`);let n=Rn(e),r=this._groupViewState?.collapsedGroupIds()??new Set,i=new Set;for(let t of e.groups)if(r.has(t.id))for(let e of t.children)i.add(e);let a=e.topology.sources,o=new Gn(n,e.inferFlow?new Set(a===void 0?[...n.nodes].filter(e=>(n.incoming.get(e)?.length??0)===0&&(n.outgoing.get(e)?.length??0)>0):a.filter(e=>n.nodes.has(e))):new Set);this._flowInferenceCache=o,this._flowStoppedSourceIds=new Set,this._flowClosedNodeIds=new Set;let s=e.inferFlow?[...n.nodes,...n.edges.map(e=>e.id)]:[];this._scheduler.registerFlowInference(o,s);let c=new Map,l=[],u=1;for(let r of e.elements){if(e.inferFlow&&!go(r)&&!_o(r)&&n.nodes.has(r.id)&&this._registerFlowStateTracking(r),i.has(r.id))continue;let a,o;if(_o(r)){let e=Ln(r,t,this._renderer,e=>this._dispatchValueWarning(e));a=e.svg,o=e.handles}else{let e=qe(r.type);if(!e)continue;let n=(go(r),r),i=e.build(n,t,this._renderer);a=i.svg,o=i.handles}let s=go(r)||_o(r)?o:this._wrapHandlesForLiveRegion(r,o);this._registerHandles(r.id,s);let d=document.createElementNS(ho,`g`);if(d.setAttribute(`transform`,`translate(${r.x} ${r.y})`),d.appendChild(a),!go(r)){let e=fn(r.w,r.h,t);d.appendChild(e.group),this._scheduler.registerQualityOverlay(r.id,e);let n=[...new Set(r.bindings.map(e=>e.tag))],i={x:r.x,y:r.y},a=$n(r.w,r.h,this._viewportState.zoom,i);a.setAttribute(`tabindex`,String(u++)),a.setAttribute(`aria-label`,r.label??r.id),this._hitAreaEntries.push({rect:a,w:r.w,h:r.h,origin:i}),nr(a,{elementId:r.id,elementType:r.type,tags:n,arbiter:this._gestureArbiter,isInteractive:()=>this._interactive,onClick:e=>this._dispatchElementClick(e),onHoverChange:e=>{e&&this._dispatchElementHover(r.id,n)}}),l.push({area:r.w*r.h,rect:a})}c.set(r.id,d),this._builtElements.push({elementId:r.id,svg:d})}if(l.length>0){this._hitLayerGroup=document.createElementNS(ho,`g`),this._hitLayerGroup.setAttribute(`class`,`vscada-hit-layer`);for(let e of[...l].sort((e,t)=>t.area-e.area))this._hitLayerGroup.appendChild(e.rect)}for(let n of e.groups){let e=document.createElementNS(ho,`g`);if(e.setAttribute(`transform`,`translate(${n.x} ${n.y})`),e.setAttribute(`class`,`vscada-group`),r.has(n.id)){let r=Lt(n,t);r.svg.style.cursor=`pointer`,r.svg.addEventListener(`click`,()=>this._toggleGroup(n.id)),e.appendChild(r.svg)}else e.appendChild(Rt(n,t));c.set(n.id,e),this._builtElements.push({elementId:n.id,svg:e})}let d=Yn(n,this._renderer,{getNodeElement:e=>c.get(e),getEdgeElement:e=>c.get(e)}),f=Qe();if(f)for(let i of e.connections){let a=Wt(i,e,r,n);if(!a)continue;let{svg:o,handles:s}=f.build(a,t,this._renderer);this._registerHandles(i.id,s),o.addEventListener(`pointerenter`,e=>{d.onPointerEnter(i.id,{pointerType:e.pointerType})}),o.addEventListener(`pointerleave`,()=>d.onPointerLeave()),c.set(i.id,o),this._builtElements.push({elementId:i.id,svg:o})}this._needsStructureInsert=!0}_registerFlowStateTracking(e){let t=e.bindings.find(e=>e.type===`state`);if(!t)return;let n=e.id,r=new P(t.map,e.transitions??{},{duration:0,easing:`linear`},e=>{});this._scheduler.registerHandle(n,t.tag,{kind:`state`,write:(e,i)=>{let a=r.resolve(i,t.tag);a.state===`stopped`?this._flowStoppedSourceIds.add(n):this._flowStoppedSourceIds.delete(n),a.state===`closed`?this._flowClosedNodeIds.add(n):this._flowClosedNodeIds.delete(n),this._flowInferenceCache?.update(this._flowStoppedSourceIds,this._flowClosedNodeIds)}}),this._flowTrackedElementIds.push(n)}_toggleGroup(e){!this._scene||!this._groupViewState||this._interactive&&(this._groupViewState.toggleGroup(e),this.dispatchEvent(new CustomEvent(`element-click`,{detail:{elementId:e,elementType:`group`},bubbles:!0,composed:!0})),this._teardownBuiltElements(),this._buildElements(this._scene),this.requestUpdate())}_handleConditionTransition(e,t){let n=this._scene?.elements.find(t=>t.id===e)?.label??e;this._liveRegion.announceConditionTransition(n,t,this._scheduler.connectionState===`disconnected`)}_wrapHandlesForLiveRegion(e,t){let n=e.thresholds??[];if(n.length===0)return t;let r=e.label??e.id,i={};for(let[a,o]of Object.entries(t)){let t=o.kind===`numeric`?n.filter(e=>e.tag===a):[];if(o.kind!==`numeric`||t.length===0){i[a]=o;continue}let s=e.bindings.find(e=>e.tag===a)?.type??`value`,c=`normal`;i[a]={kind:`numeric`,write:(e,n,i)=>{let a=fo(n,t);a!==c&&(this._liveRegion.announceThresholdCrossing(r,s,a),c=a),o.write(e,n,i)}}}return i}_registerHandles(e,t){for(let[n,r]of Object.entries(t))r.kind===`animation`?this._animations.register(e,r,vo(n)):r.kind===`static-representation`?this._staticRepresentations.register(e,r):this._scheduler.registerHandle(e,n,r)}_teardownBuiltElements(){for(let e of this._builtElements)this._scheduler.unregisterElement(e.elementId),this._animations.unregisterElement(e.elementId),this._staticRepresentations.unregisterElement(e.elementId);for(let e of this._flowTrackedElementIds)this._scheduler.unregisterElement(e);this._builtElements=[],this._flowTrackedElementIds=[],this._builtDefs=null,this._watermark=null,this._hitLayerGroup=null,this._hitAreaEntries=[],this._viewportGroup=null}_maybeStartScheduler(){this._schedulerStarted||!this.isConnected||this._store.size===0||(this._scheduler.start(),this._schedulerStarted=!0)}_dispatchValueWarning(e){this.dispatchEvent(new CustomEvent(`value-warning`,{detail:e,bubbles:!0,composed:!0}))}_dispatchElementClick(e){this.dispatchEvent(new CustomEvent(`element-click`,{detail:e,bubbles:!0,composed:!0}))}_dispatchElementHover(e,t){let n={elementId:e,tags:t};this.dispatchEvent(new CustomEvent(`element-hover`,{detail:n,bubbles:!0,composed:!0}))}_dispatchRenderStats(e){this.dispatchEvent(new CustomEvent(`render-stats`,{detail:e,bubbles:!0,composed:!0}))}_onViewportFrame(e){this._applyViewportTransform(e);for(let t of this._hitAreaEntries)er(t.rect,t.w,t.h,e.zoom,t.origin);let t=Zt(e.zoom,this._lodActive);this._lodActive=t,this._scheduler.lodActive=t,this._viewportGroup?.classList.toggle(`vscada-lod-active`,t)}_applyViewportTransform(e){this._viewportGroup&&this._renderer.setAttr(this._viewportGroup,`transform`,`translate(${e.panX} ${e.panY}) scale(${e.zoom})`)}_viewBoxScale(){if(!this._scene)return 1;let e=this.renderRoot.querySelector(`svg`);if(!e)return 1;let t=e.getBoundingClientRect();return t.width===0?1:this._scene.canvas.width/t.width}_toCanvasPoint(e,t){let n=this.renderRoot.querySelector(`svg`);if(!n||!this._scene)return{x:e,y:t};let r=n.getBoundingClientRect(),i=this._viewBoxScale();return{x:(e-r.left)*i,y:(t-r.top)*i}}_attachPanZoomListeners(e){e.addEventListener(`pointerdown`,e=>{let t=e;this._panZoomGestures.onPointerDown(t.pointerId,t.clientX,t.clientY)}),e.addEventListener(`pointermove`,e=>{let t=e;this._panZoomGestures.onPointerMove(t.pointerId,t.clientX,t.clientY)}),e.addEventListener(`pointerup`,e=>{this._panZoomGestures.onPointerUp(e.pointerId)}),e.addEventListener(`pointercancel`,e=>{this._panZoomGestures.onPointerCancel(e.pointerId)}),e.addEventListener(`wheel`,e=>{e.preventDefault();let t=e;this._panZoomGestures.onWheel(t.deltaY,t.clientX,t.clientY)},{passive:!1})}_syncVisibilityPause(){!this._isIntersecting||document.hidden?this._scheduler.pauseForOffscreen():this._scheduler.resumeFromOffscreen()}};mo=yo,mo.styles=s`
|
|
3
|
+
:host {
|
|
4
|
+
display: block;
|
|
5
|
+
}
|
|
6
|
+
svg {
|
|
7
|
+
display: block;
|
|
8
|
+
width: 100%;
|
|
9
|
+
height: 100%;
|
|
10
|
+
touch-action: none;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Story 4.3 Task 2 — LOD's "text labels below legibility → hidden".
|
|
14
|
+
* One core-owned CSS toggle on the viewport group covers every
|
|
15
|
+
* primitive's text uniformly (labels, readouts, the quality overlay's
|
|
16
|
+
* age badge) — no per-primitive change needed.
|
|
17
|
+
*/
|
|
18
|
+
.vscada-viewport.vscada-lod-active text {
|
|
19
|
+
display: none;
|
|
20
|
+
}
|
|
21
|
+
/* Story 4.4 Task 3 — §11 ARIA live region: present in the accessibility
|
|
22
|
+
tree (never display:none/visibility:hidden, which would strip it
|
|
23
|
+
from screen readers too) but invisible on screen. Standard
|
|
24
|
+
visually-hidden recipe. */
|
|
25
|
+
.vscada-live-region {
|
|
26
|
+
position: absolute;
|
|
27
|
+
width: 1px;
|
|
28
|
+
height: 1px;
|
|
29
|
+
overflow: hidden;
|
|
30
|
+
clip-path: inset(50%);
|
|
31
|
+
white-space: nowrap;
|
|
32
|
+
}
|
|
33
|
+
/* Story 4.4 Task 4 — §11 keyboard focus ring. Custom properties are
|
|
34
|
+
resolved from the theme's focusRing token at scene-build time
|
|
35
|
+
(_buildElements, on the host element) and inherit through the
|
|
36
|
+
shadow boundary by construction; the fallback values here are the
|
|
37
|
+
ONLY thing that ever renders if a theme declares no focusRing token
|
|
38
|
+
at all — a missing focus ring is an accessibility regression, unlike
|
|
39
|
+
a primitive's own graceful color degrade (AD-7), so this default is
|
|
40
|
+
deliberate, not a banned literal-color fallback. */
|
|
41
|
+
.vscada-hit-area:focus-visible {
|
|
42
|
+
outline: var(--vscada-focus-ring-width, 2px) solid var(--vscada-focus-ring-color, #2c7be5);
|
|
43
|
+
outline-offset: var(--vscada-focus-ring-offset, 2px);
|
|
44
|
+
}
|
|
45
|
+
`;function bo(e=`scada-view`){let t=customElements.get(e);t?t!==yo&&console.warn(`defineScadaView: "${e}" is already registered to a different class — ScadaView will not be used for this tag.`):customElements.define(e,yo)}function U(e){return{toCanonical:t=>t*e,fromCanonical:t=>t/e}}var xo={Pa:{family:`pressure`,...U(1)},kPa:{family:`pressure`,...U(1e3)},bar:{family:`pressure`,...U(1e5)},psi:{family:`pressure`,...U(6894.757293168361)},K:{family:`temperature`,toCanonical:e=>e,fromCanonical:e=>e},degC:{family:`temperature`,toCanonical:e=>e+273.15,fromCanonical:e=>e-273.15},degF:{family:`temperature`,toCanonical:e=>(e-32)*5/9+273.15,fromCanonical:e=>(e-273.15)*9/5+32},m3s:{family:`flow`,...U(1)},m3h:{family:`flow`,...U(1/3600)},lpm:{family:`flow`,...U(1/6e4)},gpm:{family:`flow`,...U(.003785411784/60)},m:{family:`level`,...U(1)},mm:{family:`level`,...U(.001)},W:{family:`power`,...U(1)},kW:{family:`power`,...U(1e3)},MW:{family:`power`,...U(1e6)},kg:{family:`mass`,...U(1)},t:{family:`mass`,...U(1e3)},lb:{family:`mass`,...U(.45359237)}};function So(e,t,n){if(t===n)return e;let r=xo[t],i=xo[n];if(!(!r||!i||r.family!==i.family))return i.fromCanonical(r.toCanonical(e))}function Co(e,t){if(typeof e!=`number`||!Number.isFinite(e))return String(e);let n=t.displayUnit??t.unit,r=So(e,t.unit,n),i=r??e,a=r===void 0?t.unit:n,o=i.toFixed(t.decimals);return a.length>0?`${o} ${a}`:o}var wo=Object.freeze({name:`classic-hmi`,palette:{},background:`#3A3A3A`,focusRing:Object.freeze({color:`#E8EAEC`,widthPx:2,offsetPx:2}),pipe:Object.freeze({gradient:Object.freeze([{offset:0,color:`#6E7276`},{offset:.18,color:`#C8CCD0`},{offset:.34,color:`#FFFFFF`},{offset:.5,color:`#D4D8DC`},{offset:.78,color:`#8B9095`},{offset:1,color:`#5A5E62`}]),strokeWidth:24,flange:Object.freeze({widthFactor:1.4,length:9,outlineColor:`#3F4245`,highlightColor:`#E8EAEC`,ringColor:`#55585B`}),dash:Object.freeze({color:`#2C7BE5`,length:10,gap:6,opacity:.85})}),liquid:Object.freeze({surfaceColor:`#D6FBFF`,media:Object.freeze({water:Object.freeze({top:`#2C7BE5`,bottom:`#1A5FC4`})}),defaultMedium:`water`,waveCount:1}),vessel:Object.freeze({bodyStrokeColor:`#8B9095`,bodyFillColor:`#4A4E52`,bodyGradientTopColor:`#5A5E62`,bodyGradientBottomColor:`#3A3D40`,shadingDarkColor:`#2A2C2E`,shadingLightColor:`#C8CCD0`,shadingMidColor:`#6E7276`,specularColor:`#FFFFFF`,rimStrokeColor:`#3F4245`,rimHighlightColor:`#E8EAEC`,hardwareFillColor:`#5A5E62`,hardwareStrokeColor:`#3F4245`,weldLineColor:`#2A2C2E`,contactShadowColor:`#1E1F20`,strokeWidth:2,alarm:Object.freeze({normalColor:`#D6FBFF`,lowColor:`#F5A623`,lowLowColor:`#E74C3C`,highColor:`#F5A623`,highHighColor:`#E74C3C`})}),pump:Object.freeze({states:Object.freeze({stopped:Object.freeze({lampColor:`#8B9095`,blink:!1,label:`STOPPED`}),starting:Object.freeze({lampColor:`#F5A623`,blink:!0,label:`STARTING`}),running:Object.freeze({lampColor:`#2ECC71`,blink:!1,label:`RUNNING`}),tripped:Object.freeze({lampColor:`#E74C3C`,blink:!0,label:`TRIPPED`}),unavailable:Object.freeze({lampColor:`#5A5E62`,blink:!1,label:`UNAVAILABLE`})}),bodyEnergizedColor:`#4A4E52`,bodyDeenergizedColor:`#3A3D40`,impellerColor:`#8B9095`}),drivenEquipment:Object.freeze({states:Object.freeze({stopped:Object.freeze({lampColor:`#8B9095`,blink:!1,label:`STOPPED`}),starting:Object.freeze({lampColor:`#F5A623`,blink:!0,label:`STARTING`}),running:Object.freeze({lampColor:`#2ECC71`,blink:!1,label:`RUNNING`}),tripped:Object.freeze({lampColor:`#E74C3C`,blink:!0,label:`TRIPPED`}),unavailable:Object.freeze({lampColor:`#5A5E62`,blink:!1,label:`UNAVAILABLE`})}),bodyEnergizedColor:`#4A4E52`,bodyDeenergizedColor:`#3A3D40`,rotorColor:`#8B9095`}),fan:Object.freeze({states:Object.freeze({off:Object.freeze({lampColor:`#8B9095`,blink:!1,label:`OFF`}),running:Object.freeze({lampColor:`#2ECC71`,blink:!1,label:`RUNNING`}),fault:Object.freeze({lampColor:`#E74C3C`,blink:!0,label:`FAULT`})}),bodyEnergizedColor:`#4A4E52`,bodyDeenergizedColor:`#3A3D40`,bladeColor:`#8B9095`,blurredDiscColor:`#C8CCD0`,blurredDiscOpacity:.4,blurThresholdRpm:900}),valve:Object.freeze({states:Object.freeze({closed:Object.freeze({indicatorColor:`#8B9095`,blink:!1,label:`CLOSED`}),opening:Object.freeze({indicatorColor:`#F5A623`,blink:!0,label:`OPENING`}),open:Object.freeze({indicatorColor:`#2ECC71`,blink:!1,label:`OPEN`}),closing:Object.freeze({indicatorColor:`#F5A623`,blink:!0,label:`CLOSING`}),fault:Object.freeze({indicatorColor:`#E74C3C`,blink:!0,label:`FAULT`})}),closedColor:`#6E7276`,openColor:`#2C7BE5`,discColor:`#C8CCD0`,arrowColor:`#E8EAEC`,bodyOutlineColor:`#3F4245`,defaultStrokeMs:5e3}),medium:Object.freeze({defaultMedium:`water`,styles:Object.freeze({water:Object.freeze({color:`#2C7BE5`,dashSignature:Object.freeze({length:10,gap:6,opacity:.85}),animationSpeedFactor:1,opacity:.55,waveAmplitude:3,wavePeriod:90,waveSpeed:1,specular:`sharp`,meniscus:!1}),oil:Object.freeze({color:`#A9672B`,dashSignature:Object.freeze({length:14,gap:5,opacity:.9}),animationSpeedFactor:.5,opacity:.95,waveAmplitude:6,wavePeriod:150,waveSpeed:.5,specular:`diffuse`,meniscus:!0}),"fuel-diesel":Object.freeze({color:`#C8D24B`,dashSignature:Object.freeze({length:10,gap:6,opacity:.75}),animationSpeedFactor:.75,opacity:.8,waveAmplitude:4,wavePeriod:110,waveSpeed:.75,specular:`diffuse`,meniscus:!1}),"slurry-sludge":Object.freeze({color:`#4A3F38`,dashSignature:Object.freeze({length:16,gap:3,opacity:.95}),animationSpeedFactor:.2,opacity:.98,waveAmplitude:5,wavePeriod:220,waveSpeed:.15,specular:`none`,meniscus:!1}),"acid-chemical":Object.freeze({color:`#8FD14F`,dashSignature:Object.freeze({length:6,gap:8,opacity:.6}),animationSpeedFactor:.9,opacity:.4,waveAmplitude:3,wavePeriod:100,waveSpeed:.9,specular:`sharp`,meniscus:!1}),"molten-hot":Object.freeze({color:`#FF5A1F`,dashSignature:Object.freeze({length:12,gap:4,opacity:1}),animationSpeedFactor:.35,opacity:1,waveAmplitude:5,wavePeriod:170,waveSpeed:.3,specular:`diffuse`,meniscus:!1}),steam:Object.freeze({color:`#D9DCDE`,dashSignature:Object.freeze({length:4,gap:10,opacity:.55}),animationSpeedFactor:1.6,opacity:.25,plume:Object.freeze({opacity:.25,driftSpeed:.6})}),"flue-gas":Object.freeze({color:`#8A7460`,dashSignature:Object.freeze({length:4,gap:14,opacity:.45}),animationSpeedFactor:1.3,opacity:.35,plume:Object.freeze({opacity:.35,driftSpeed:.5})}),ash:Object.freeze({color:`#5A5550`,dashSignature:Object.freeze({length:14,gap:4,opacity:.9}),animationSpeedFactor:.4}),condensate:Object.freeze({color:`#5FB6C9`,dashSignature:Object.freeze({length:8,gap:8,opacity:.75}),animationSpeedFactor:.8,opacity:.5,waveAmplitude:2,wavePeriod:80,waveSpeed:1.1,specular:`sharp`,meniscus:!1}),feedwater:Object.freeze({color:`#7FD1E0`,dashSignature:Object.freeze({length:9,gap:6,opacity:.8}),animationSpeedFactor:.95,opacity:.5,waveAmplitude:3,wavePeriod:85,waveSpeed:1.05,specular:`sharp`,meniscus:!1}),"hydraulic-oil":Object.freeze({color:`#8B5A1F`,dashSignature:Object.freeze({length:14,gap:5,opacity:.9}),animationSpeedFactor:.45,opacity:.94,waveAmplitude:5,wavePeriod:140,waveSpeed:.45,specular:`diffuse`,meniscus:!0}),electrical:Object.freeze({color:`#F2C230`,dashSignature:Object.freeze({length:2,gap:3,opacity:1}),animationSpeedFactor:2.5})})}),panel:Object.freeze({raised:Object.freeze({faceColor:`#4A4E52`,highlightColor:`#8B9095`,shadowColor:`#1E1F20`}),labelColor:`#E8EAEC`,readoutColor:`#D4D8DC`,alarmIndicator:Object.freeze({goodColor:`#2ECC71`,uncertainColor:`#F5A623`,staleColor:`#979BA0`,badColor:`#ED7A6E`})}),quality:Object.freeze({uncertainDashColor:`#E8B84B`,badHatchColor:`#E74C3C`,badHatchOpacity:.35,staleOverlayColor:`#8B9095`,staleOverlayOpacity:.55,badgeTextColor:`#E8EAEC`,badgeBackgroundColor:`#2A2C2E`}),gauge:Object.freeze({face:Object.freeze({faceColor:`#D98A2B`,bevelHighlightColor:`#F5A623`,bevelShadowColor:`#8A5A1B`,tickColor:`#2A2C2E`,divisionLabelColor:`#2A2C2E`,needleColor:`#E74C3C`,pivotColor:`#2A2C2E`,captionColor:`#2A2C2E`}),zones:Object.freeze({normalColor:`#2C7BE5`,lowColor:`#F5A623`,lowLowColor:`#E74C3C`,highColor:`#F5A623`,highHighColor:`#E74C3C`})}),indicatorLamp:Object.freeze({states:Object.freeze({off:Object.freeze({color:`#5A5E62`,label:`OFF`}),on:Object.freeze({color:`#2ECC71`,label:`ON`}),"blink-slow":Object.freeze({color:`#F5A623`,label:`ACK`}),"blink-fast":Object.freeze({color:`#E74C3C`,label:`ALARM`})}),fastBlinkHz:2.5,slowBlinkHz:.75}),gaugeDigital:Object.freeze({face:Object.freeze({faceColor:`#2A2C2E`,bevelHighlightColor:`#1E1F20`,bevelShadowColor:`#4A4E52`}),digitColor:`#2ECC71`,labelColor:`#E8EAEC`}),readoutPanel:Object.freeze({face:Object.freeze({faceColor:`#2A2C2E`,bevelHighlightColor:`#1E1F20`,bevelShadowColor:`#4A4E52`}),labelColor:`#E8EAEC`,valueColor:`#D4D8DC`}),bargraph:Object.freeze({face:Object.freeze({faceColor:`#2A2C2E`,bevelHighlightColor:`#1E1F20`,bevelShadowColor:`#4A4E52`}),trackColor:`#4A4E52`,fillColor:`#2C7BE5`,thresholdTickColor:`#F5A623`}),trendMini:Object.freeze({face:Object.freeze({faceColor:`#2A2C2E`,bevelHighlightColor:`#1E1F20`,bevelShadowColor:`#4A4E52`}),lineColor:`#2ECC71`,axisColor:`#5A5E62`,pointCount:60}),heat:Object.freeze({states:Object.freeze({off:Object.freeze({glowColor:`#8B9095`,glowOpacity:.15,label:`OFF`}),firing:Object.freeze({glowColor:`#FF5A1F`,glowOpacity:.85,label:`FIRING`})}),bodyColor:`#4A4E52`,outlineColor:`#3F4245`,tubeBundleColor:`#5A5E62`,condensateColor:`#5FB6C9`,coilWidthFactor:.5}),filtration:Object.freeze({bodyColor:`#4A4E52`,outlineColor:`#3F4245`,hopperColor:`#5A5E62`,distributorColor:`#8B9095`,readoutColor:`#D4D8DC`}),conveyor:Object.freeze({states:Object.freeze({stopped:Object.freeze({lampColor:`#8B9095`,blink:!1,label:`STOPPED`}),running:Object.freeze({lampColor:`#2ECC71`,blink:!1,label:`RUNNING`}),fault:Object.freeze({lampColor:`#E74C3C`,blink:!0,label:`FAULT`})}),bodyColor:`#4A4E52`,rollerColor:`#5A5E62`,beltColor:`#2A2C2E`,beltDashColor:`#8B9095`,beltDashLength:14,beltDashGap:6,loadColor:`#4A3F38`}),screwFeeder:Object.freeze({bodyColor:`#4A4E52`,outlineColor:`#3F4245`,helixColor:`#8B9095`}),duct:Object.freeze({seamColor:`#3F4245`,seamSpacing:40}),controls:Object.freeze({pushbutton:Object.freeze({raised:Object.freeze({faceColor:`#4A4E52`,highlightColor:`#8B9095`,shadowColor:`#1E1F20`}),window:Object.freeze({faceColor:`#2A2C2E`,highlightColor:`#4A4E52`,shadowColor:`#1E1F20`}),states:Object.freeze({off:Object.freeze({indicatorColor:`#5A5E62`,label:`OFF`}),on:Object.freeze({indicatorColor:`#2ECC71`,label:`ON`})})}),selectorSwitch:Object.freeze({raised:Object.freeze({faceColor:`#4A4E52`,highlightColor:`#8B9095`,shadowColor:`#1E1F20`}),knobColor:`#8B9095`,pointerColor:`#E8EAEC`,states:Object.freeze({hand:Object.freeze({angleDeg:-45,label:`HAND`}),off:Object.freeze({angleDeg:0,label:`OFF`}),auto:Object.freeze({angleDeg:45,label:`AUTO`})})}),motorStarterPanel:Object.freeze({raised:Object.freeze({faceColor:`#4A4E52`,highlightColor:`#8B9095`,shadowColor:`#1E1F20`}),arrowColor:`#E8EAEC`,states:Object.freeze({stopped:Object.freeze({lampColor:`#8B9095`,blink:!1,label:`STOPPED`}),starting:Object.freeze({lampColor:`#F5A623`,blink:!0,label:`STARTING`}),running:Object.freeze({lampColor:`#2ECC71`,blink:!1,label:`RUNNING`}),tripped:Object.freeze({lampColor:`#E74C3C`,blink:!0,label:`TRIPPED`}),unavailable:Object.freeze({lampColor:`#5A5E62`,blink:!1,label:`UNAVAILABLE`})})})}),electrical:Object.freeze({breaker:Object.freeze({states:Object.freeze({closed:Object.freeze({indicatorColor:`#8B9095`,label:`OPEN`}),energized:Object.freeze({indicatorColor:`#2ECC71`,label:`CLOSED`}),tripped:Object.freeze({indicatorColor:`#E74C3C`,label:`TRIPPED`})}),bodyColor:`#4A4E52`,bodyOutlineColor:`#3F4245`}),transformer:Object.freeze({coilColor:`#4A4E52`,outlineColor:`#3F4245`,states:Object.freeze({"de-energized":Object.freeze({glowColor:`#8B9095`,glowOpacity:.15,label:`DE-ENERGIZED`}),energized:Object.freeze({glowColor:`#F5A623`,glowOpacity:.75,label:`ENERGIZED`})})}),busbar:Object.freeze({deenergizedColor:`#4A4E52`,outlineColor:`#3F4245`,states:Object.freeze({"de-energized":Object.freeze({glowColor:`#4A4E52`,glowOpacity:1,label:`DE-ENERGIZED`}),energized:Object.freeze({glowColor:`#F5A623`,glowOpacity:1,label:`ENERGIZED`})})}),generator:Object.freeze({states:Object.freeze({stopped:Object.freeze({lampColor:`#8B9095`,blink:!1,label:`STOPPED`}),starting:Object.freeze({lampColor:`#F5A623`,blink:!0,label:`STARTING`}),running:Object.freeze({lampColor:`#2ECC71`,blink:!1,label:`RUNNING`}),tripped:Object.freeze({lampColor:`#E74C3C`,blink:!0,label:`TRIPPED`}),unavailable:Object.freeze({lampColor:`#5A5E62`,blink:!1,label:`UNAVAILABLE`})}),bodyEnergizedColor:`#4A4E52`,bodyDeenergizedColor:`#3A3D40`,rotorColor:`#8B9095`}),readoutColor:`#D4D8DC`})}),To=`http://www.w3.org/2000/svg`;function Eo(e,t,n){let r=e,{w:i,h:a}=r,o=t.tokens.offPage,s=document.createElementNS(To,`g`);s.setAttribute(`data-element-id`,r.id),s.setAttribute(`class`,`vscada-off-page`);let c=i*.7,l=[[0,0],[c,0],[i,a/2],[c,a],[0,a]].map(([e,t])=>`${e},${t}`).join(` `),u=document.createElementNS(To,`polygon`);u.setAttribute(`points`,l),u.setAttribute(`fill`,o?.fillColor??`none`),u.setAttribute(`stroke`,o?.strokeColor??`none`),s.appendChild(u);let d=document.createElementNS(To,`text`);d.setAttribute(`class`,`vscada-off-page-label`),d.setAttribute(`x`,String(i/2)),d.setAttribute(`y`,String(a+12)),d.setAttribute(`text-anchor`,`middle`),d.setAttribute(`font-size`,`9`),d.setAttribute(`fill`,o?.labelColor??`none`),d.textContent=r.label??r.target.port,s.appendChild(d);let f=Math.max(i,44),p=Math.max(a,44),m=document.createElementNS(To,`rect`);m.setAttribute(`class`,`vscada-off-page-hit`),m.setAttribute(`x`,String((i-f)/2)),m.setAttribute(`y`,String((a-p)/2)),m.setAttribute(`width`,String(f)),m.setAttribute(`height`,String(p)),m.setAttribute(`fill`,`transparent`),m.setAttribute(`role`,`button`),m.setAttribute(`tabindex`,`0`),m.setAttribute(`aria-label`,`Go to ${r.label??r.target.scene}`),m.style.cursor=`pointer`,s.appendChild(m);let h=()=>{m.dispatchEvent(new CustomEvent(`scene-navigate`,{detail:{scene:r.target.scene,port:r.target.port},bubbles:!0,composed:!0}))};return m.addEventListener(`click`,h),m.addEventListener(`keydown`,e=>{let t=e.key;t!==`Enter`&&t!==` `||(e.preventDefault(),h())}),{svg:s,handles:{}}}var Do=Object.freeze({group:`annotation`,primitives:Object.freeze({"off-page":{build:Eo}})}),Oo=Object.freeze({group:`annotation`,primitives:Object.freeze({...Do.primitives})}),ko=`http://www.w3.org/2000/svg`;function Ao(e,t,n,r){let i=document.createElementNS(ko,`g`);i.setAttribute(`class`,`vscada-chrome-bevel`);let a=document.createElementNS(ko,`rect`);a.setAttribute(`width`,String(e)),a.setAttribute(`height`,String(t)),a.setAttribute(`fill`,n.faceColor),i.appendChild(a);let o=`M 0 ${t} L 0 0 L ${e} 0`,s=`M ${e} 0 L ${e} ${t} L 0 ${t}`,[c,l]=r===`raised`?[o,s]:[s,o],u=document.createElementNS(ko,`path`);u.setAttribute(`class`,`vscada-chrome-bevel-highlight`),u.setAttribute(`d`,c),u.setAttribute(`fill`,`none`),u.setAttribute(`stroke`,n.highlightColor),u.setAttribute(`stroke-width`,String(n.strokeWidth??2)),i.appendChild(u);let d=document.createElementNS(ko,`path`);return d.setAttribute(`class`,`vscada-chrome-bevel-shadow`),d.setAttribute(`d`,l),d.setAttribute(`fill`,`none`),d.setAttribute(`stroke`,n.shadowColor),d.setAttribute(`stroke-width`,String(n.strokeWidth??2)),i.appendChild(d),i}var jo=`http://www.w3.org/2000/svg`,Mo={duration:1,easing:`linear`};function No(e,t,n){let r=document.createElementNS(jo,`g`);r.setAttribute(`data-element-id`,e.id),r.setAttribute(`class`,`vscada-pushbutton`);let i=t.tokens.controls?.pushbutton;if(!i)return{svg:r,handles:{}};let{w:a,h:o}=e,s=Ao(a,o,i.raised,`raised`);s.setAttribute(`class`,`vscada-pushbutton-body`),r.appendChild(s);let c=Math.min(a,o)*.2,l=a-c*2,u=o-c*2,d=Ao(l,u,i.window,`recessed`);d.setAttribute(`class`,`vscada-pushbutton-window`),d.setAttribute(`transform`,`translate(${c}, ${c})`),r.appendChild(d);let f=document.createElementNS(jo,`circle`);f.setAttribute(`class`,`vscada-pushbutton-indicator`),f.setAttribute(`cx`,String(l/2)),f.setAttribute(`cy`,String(u/2)),f.setAttribute(`r`,String(Math.min(l,u)*.3)),d.appendChild(f);let p=document.createElementNS(jo,`text`);p.setAttribute(`class`,`vscada-pushbutton-label`),p.setAttribute(`x`,`0`),p.setAttribute(`y`,String(o+12)),p.setAttribute(`font-size`,`8`),r.appendChild(p);let m={},h=e.bindings.find(e=>e.type===`state`);if(h){let t=new P(h.map,e.transitions,Mo),n={kind:`state`,write(e,n){let r=t.resolve(n,h.tag),a=i.states[r.state];a&&(e.setAttr(f,`fill`,a.indicatorColor),e.setText(p,a.label))}};m[h.tag]=n}return{svg:r,handles:m}}var Po={build:No},Fo=`http://www.w3.org/2000/svg`,Io={duration:1,easing:`linear`};function Lo(e,t,n){let r=document.createElementNS(Fo,`g`);r.setAttribute(`data-element-id`,e.id),r.setAttribute(`class`,`vscada-selector-switch`);let i=t.tokens.controls?.selectorSwitch;if(!i)return{svg:r,handles:{}};let{w:a,h:o}=e,s=Ao(a,o,i.raised,`raised`);s.setAttribute(`class`,`vscada-selector-switch-body`),r.appendChild(s);let c=a/2,l=o/2,u=Math.min(a,o)*.3,d=document.createElementNS(Fo,`circle`);d.setAttribute(`class`,`vscada-selector-switch-knob`),d.setAttribute(`cx`,String(c)),d.setAttribute(`cy`,String(l)),d.setAttribute(`r`,String(u)),d.setAttribute(`fill`,i.knobColor),r.appendChild(d);let f=document.createElementNS(Fo,`line`);f.setAttribute(`class`,`vscada-selector-switch-pointer`),f.setAttribute(`x1`,String(c)),f.setAttribute(`y1`,String(l)),f.setAttribute(`x2`,String(c)),f.setAttribute(`y2`,String(l-u)),f.setAttribute(`stroke`,i.pointerColor),f.setAttribute(`stroke-width`,String(i.strokeWidth??2)),f.style.transformOrigin=`${c}px ${l}px`,r.appendChild(f);let p=document.createElementNS(Fo,`text`);p.setAttribute(`class`,`vscada-selector-switch-label`),p.setAttribute(`x`,`0`),p.setAttribute(`y`,String(o+12)),p.setAttribute(`font-size`,`8`),r.appendChild(p);let m={},h=e.bindings.find(e=>e.type===`state`);if(h){let t=new P(h.map,e.transitions,Io),n={kind:`state`,write(e,n){let r=t.resolve(n,h.tag),a=i.states[r.state];a&&(e.setTransform(f,`rotate(${a.angleDeg}deg)`),e.setText(p,a.label))}};m[h.tag]=n}return{svg:r,handles:m}}var Ro={build:Lo},zo=`http://www.w3.org/2000/svg`,Bo={duration:1,easing:`linear`},Vo=800,Ho=`running`;function Uo(e,t,n){let r=document.createElementNS(zo,`g`);r.setAttribute(`data-element-id`,e.id),r.setAttribute(`class`,`vscada-motor-starter-panel`);let i=t.tokens.controls?.motorStarterPanel;if(!i)return{svg:r,handles:{}};let{w:a,h:o}=e,s=Ao(a,o,i.raised,`raised`);s.setAttribute(`class`,`vscada-motor-starter-panel-body`),r.appendChild(s);let c=a/2,l=o*.25,u=document.createElementNS(zo,`circle`);u.setAttribute(`class`,`vscada-motor-starter-panel-lamp`),u.setAttribute(`cx`,String(c)),u.setAttribute(`cy`,String(l)),u.setAttribute(`r`,String(Math.min(a,o)*.12)),u.style.transformOrigin=`${c}px ${l}px`,r.appendChild(u);let d=n.animateTransform(u,[`scale(1)`,`scale(0.35)`,`scale(1)`],Vo);d.pause();let f=document.createElementNS(zo,`g`);f.setAttribute(`class`,`vscada-motor-starter-panel-arrows`),f.setAttribute(`opacity`,`0`);let p=o*.6,m=document.createElementNS(zo,`path`);m.setAttribute(`d`,`M ${a*.3} ${p} l -8 -5 l 0 10 z`),m.setAttribute(`fill`,i.arrowColor);let h=document.createElementNS(zo,`path`);h.setAttribute(`d`,`M ${a*.7} ${p} l 8 -5 l 0 10 z`),h.setAttribute(`fill`,i.arrowColor),f.appendChild(m),f.appendChild(h),r.appendChild(f);let g=document.createElementNS(zo,`text`);g.setAttribute(`class`,`vscada-motor-starter-panel-label`),g.setAttribute(`x`,`0`),g.setAttribute(`y`,String(o+12)),g.setAttribute(`font-size`,`8`),r.appendChild(g);let _=!1,v={},y=e.bindings.find(e=>e.type===`state`);if(y){let t=new P(y.map,e.transitions,Bo),n={kind:`state`,write(e,n){let r=t.resolve(n,y.tag),a=i.states[r.state];if(!a){_=!1;return}e.setAttr(u,`fill`,a.lampColor),e.setText(g,a.label),_=a.blink,a.blink?d.resume():d.pause(),e.setAttr(f,`opacity`,r.state===Ho?`1`:`0`)}};v[y.tag]=n}let b={kind:`animation`,pause(){d.pause()},resume(){_&&d.resume()},seek(e){d.seek(e)}};return v[`__motor-starter-panel-animation-${e.id}`]=b,{svg:r,handles:v}}var Wo=Object.freeze({group:`controls`,primitives:Object.freeze({pushbutton:Po,"selector-switch":Ro,"motor-starter-panel":{build:Uo}})}),Go=`http://www.w3.org/2000/svg`,Ko=`vscada-pipe-gradient-base`;function qo(e,t){if(e.querySelector(`#${Ko}`))return Ko;let n=document.createElementNS(Go,`linearGradient`);n.setAttribute(`id`,Ko),n.setAttribute(`x1`,`0`),n.setAttribute(`y1`,`0`),n.setAttribute(`x2`,`0`),n.setAttribute(`y2`,`1`);for(let e of t){let t=document.createElementNS(Go,`stop`);t.setAttribute(`offset`,String(e.offset)),t.setAttribute(`stop-color`,e.color),n.appendChild(t)}return e.appendChild(n),Ko}function Jo(e,t,n,r,i,a){let o=document.createElementNS(Go,`linearGradient`);return o.setAttribute(`id`,t),o.setAttributeNS(`http://www.w3.org/1999/xlink`,`href`,`#${Ko}`),o.setAttribute(`href`,`#${Ko}`),o.setAttribute(`gradientUnits`,`userSpaceOnUse`),o.setAttribute(`x1`,String(n)),o.setAttribute(`y1`,String(r)),o.setAttribute(`x2`,String(i)),o.setAttribute(`y2`,String(a)),e.appendChild(o),t}var Yo=`http://www.w3.org/2000/svg`,Xo=0;function Zo(e){return Xo+=1,`${e}-${Xo}`}function Qo(e,t,n){let r=document.createElementNS(Yo,`g`);r.setAttribute(`data-element-id`,e.id),r.setAttribute(`class`,`vscada-duct`);let i=t.tokens.pipe,a=t.tokens.duct;if(!i||!a)return{svg:r,handles:{}};let{w:o,h:s}=e;qo(t.defs,i.gradient);let c=Zo(`vscada-duct-grad`);Jo(t.defs,c,0,0,0,s);let l=document.createElementNS(Yo,`rect`);l.setAttribute(`class`,`vscada-duct-body`),l.setAttribute(`width`,String(o)),l.setAttribute(`height`,String(s)),l.setAttribute(`fill`,`url(#${c})`),r.appendChild(l);let u=j(t.tokens.medium,e.medium)?.color??a.seamColor,d=document.createElementNS(Yo,`g`);d.setAttribute(`class`,`vscada-duct-seams`);for(let e=a.seamSpacing;e<o;e+=a.seamSpacing){let t=document.createElementNS(Yo,`line`);t.setAttribute(`class`,`vscada-duct-seam`),t.setAttribute(`x1`,String(e)),t.setAttribute(`y1`,`0`),t.setAttribute(`x2`,String(e)),t.setAttribute(`y2`,String(s)),t.setAttribute(`stroke`,u),t.setAttribute(`stroke-width`,String(a.strokeWidth??1)),d.appendChild(t)}return r.appendChild(d),{svg:r,handles:{}}}var $o={build:Qo},es=`http://www.w3.org/2000/svg`;function ts(e){return Math.atan2(e.to.y-e.from.y,e.to.x-e.from.x)}var ns=1e3;function rs(e,t){if(!Number.isFinite(t)||t===0)return 0;let n=e/t;return Math.max(-4,Math.min(4,n))}function is(e,t,n){let r=ts(e),i=t.dash.length+t.dash.gap,a=Math.cos(r)*i,o=Math.sin(r)*i,s=document.createElementNS(es,`g`);s.setAttribute(`class`,`vscada-pipe-dash`);let c=document.createElementNS(es,`line`);return c.setAttribute(`x1`,String(e.from.x)),c.setAttribute(`y1`,String(e.from.y)),c.setAttribute(`x2`,String(e.to.x)),c.setAttribute(`y2`,String(e.to.y)),c.setAttribute(`stroke`,t.dash.color),c.setAttribute(`stroke-width`,String(t.dash.lineStrokeWidth??3)),c.setAttribute(`stroke-dasharray`,`${t.dash.length} ${t.dash.gap}`),c.setAttribute(`stroke-opacity`,String(t.dash.opacity)),s.appendChild(c),{group:s,control:n.animateTransform(s,[`translate(0px, 0px)`,`translate(${a}px, ${o}px)`],ns)}}var as=`http://www.w3.org/2000/svg`,os={duration:1,easing:`linear`};function ss(e,t,n){let r=document.createElementNS(as,`g`);r.setAttribute(`data-element-id`,e.id),r.setAttribute(`class`,`vscada-conveyor`);let i=t.tokens.conveyor;if(!i)return{svg:r,handles:{}};let{w:a,h:o}=e,s={},c=document.createElementNS(as,`rect`);c.setAttribute(`class`,`vscada-conveyor-body`),c.setAttribute(`width`,String(a)),c.setAttribute(`height`,String(o)),c.setAttribute(`fill`,i.bodyColor),r.appendChild(c);let l=o*.18,u=o/2;for(let e of[l*1.2,a-l*1.2]){let t=document.createElementNS(as,`circle`);t.setAttribute(`class`,`vscada-conveyor-roller`),t.setAttribute(`cx`,String(e)),t.setAttribute(`cy`,String(u)),t.setAttribute(`r`,String(l)),t.setAttribute(`fill`,i.rollerColor),r.appendChild(t)}let d=document.createElementNS(as,`rect`);d.setAttribute(`class`,`vscada-conveyor-belt`),d.setAttribute(`x`,`0`),d.setAttribute(`y`,String(u-o*.12)),d.setAttribute(`width`,String(a)),d.setAttribute(`height`,String(o*.24)),d.setAttribute(`fill`,i.beltColor),r.appendChild(d);let f=is({from:{x:0,y:u},to:{x:a,y:u}},{dash:{color:i.beltDashColor,length:i.beltDashLength,gap:i.beltDashGap,opacity:1}},n);r.appendChild(f.group);let p=document.createElementNS(as,`rect`);p.setAttribute(`class`,`vscada-conveyor-load`),p.setAttribute(`x`,`0`),p.setAttribute(`y`,String(u-o*.12)),p.setAttribute(`width`,String(a)),p.setAttribute(`height`,String(o*.24)),p.setAttribute(`fill`,i.loadColor),p.setAttribute(`opacity`,`0`),r.appendChild(p);let m=document.createElementNS(as,`circle`);m.setAttribute(`class`,`vscada-conveyor-lamp`),m.setAttribute(`cx`,String(a*.9)),m.setAttribute(`cy`,`-8`),m.setAttribute(`r`,`5`),r.appendChild(m);let h=document.createElementNS(as,`text`);h.setAttribute(`class`,`vscada-conveyor-label`),h.setAttribute(`x`,`0`),h.setAttribute(`y`,String(o+14)),h.setAttribute(`font-size`,`9`),r.appendChild(h);let g=e.bindings.find(e=>e.type===`state`);if(g){let t=new P(g.map,e.transitions,os),n={kind:`state`,write(e,n){let r=t.resolve(n,g.tag),a=i.states[r.state];a&&(e.setAttr(m,`fill`,a.lampColor),e.setText(h,a.label))}};s[g.tag]=n}let _=e.bindings.find(e=>e.type===`rotate`);if(_){let e={kind:`numeric`,write(e,t){typeof t==`number`&&f.control.setPlaybackRate(hn(_.min,_.max,t))}};s[_.tag]=e}let v=e.bindings.find(e=>e.type===`level`);if(v){let e={kind:`numeric`,write(e,t){if(typeof t!=`number`)return;let n=gn(v,t);e.setAttr(p,`opacity`,String(n))}};s[v.tag]=e}return s[`__conveyor-animation-${e.id}`]={kind:`animation`,pause:f.control.pause,resume:f.control.resume,seek:f.control.seek},{svg:r,handles:s}}var cs={build:ss},ls=`http://www.w3.org/2000/svg`,us=900;function ds(e,t,n){let r=document.createElementNS(ls,`g`);r.setAttribute(`data-element-id`,e.id),r.setAttribute(`class`,`vscada-screw-feeder`);let i=t.tokens.screwFeeder;if(!i)return{svg:r,handles:{}};let{w:a,h:o}=e,s=a/2,c=o/2,l=document.createElementNS(ls,`rect`);l.setAttribute(`class`,`vscada-screw-feeder-body`),l.setAttribute(`width`,String(a)),l.setAttribute(`height`,String(o)),l.setAttribute(`fill`,i.bodyColor),l.setAttribute(`stroke`,i.outlineColor),r.appendChild(l);let u=document.createElementNS(ls,`g`);u.setAttribute(`class`,`vscada-screw-feeder-helix`),u.style.transformOrigin=`${s}px ${c}px`;for(let e=0;e<4;e++){let t=document.createElementNS(ls,`line`),n=a/4*e+a/8;t.setAttribute(`x1`,String(n)),t.setAttribute(`y1`,`0`),t.setAttribute(`x2`,String(n)),t.setAttribute(`y2`,String(o)),t.setAttribute(`stroke`,i.helixColor),t.setAttribute(`stroke-width`,String(i.strokeWidth??3)),u.appendChild(t)}r.appendChild(u);let d=n.animateTransform(u,[`rotate(0deg)`,`rotate(360deg)`],us),f={},p=e.bindings.find(e=>e.type===`rotate`);if(p){let e={kind:`numeric`,write(e,t){typeof t==`number`&&d.setPlaybackRate(hn(p.min,p.max,t))}};f[p.tag]=e}return f[`__screw-feeder-animation-${e.id}`]={kind:`animation`,pause:d.pause,resume:d.resume,seek:d.seek},{svg:r,handles:f}}var fs={build:ds},ps=`http://www.w3.org/2000/svg`;function ms(e,t,n){let r=n.flange.widthFactor*n.strokeWidth,i=n.flange.length,a=i/2,o=r/2,s=document.createElementNS(ps,`g`);s.setAttribute(`class`,`vscada-pipe-flange`),s.setAttribute(`transform`,`translate(${e.x} ${e.y}) rotate(${t})`);let c=document.createElementNS(ps,`rect`);c.setAttribute(`x`,String(-a)),c.setAttribute(`y`,String(-o)),c.setAttribute(`width`,String(i)),c.setAttribute(`height`,String(r)),c.setAttribute(`fill`,n.flange.outlineColor),s.appendChild(c);let l=document.createElementNS(ps,`rect`),u=i*.6,d=r*.5;l.setAttribute(`x`,String(-u/2)),l.setAttribute(`y`,String(-d/2)),l.setAttribute(`width`,String(u)),l.setAttribute(`height`,String(d)),l.setAttribute(`fill`,n.flange.highlightColor),s.appendChild(l);for(let e of[-a,a]){let t=document.createElementNS(ps,`line`);t.setAttribute(`class`,`vscada-pipe-flange-ring`),t.setAttribute(`x1`,String(e)),t.setAttribute(`y1`,String(-o)),t.setAttribute(`x2`,String(e)),t.setAttribute(`y2`,String(o)),t.setAttribute(`stroke`,n.flange.ringColor),t.setAttribute(`stroke-width`,String(n.flange.ringStrokeWidth??1)),s.appendChild(t)}return s}var hs=`http://www.w3.org/2000/svg`,gs=2,_s=1400,vs=0;function ys(e){return vs+=1,`${e}-${vs}`}function bs(e,t,n,r){let{color:i,amplitude:a,period:o,strokeWidth:s,opacity:c}=t.wave,l=e.to.x-e.from.x,u=e.to.y-e.from.y,d=Math.hypot(l,u)||1,f=l/d,p=u/d,m=-p,h=f,g=d*2+o,_=[];for(let t=0;t<=g;t+=gs){let n=a*Math.sin(2*Math.PI*t/o),r=e.from.x+f*t+m*n,i=e.from.y+p*t+h*n;_.push(`${t===0?`M`:`L`}${r},${i}`)}let v=document.createElementNS(hs,`g`);v.setAttribute(`class`,`vscada-pipe-wave`);let y=a+s/2,b=ys(`vscada-pipe-wave-clip`),x=document.createElementNS(hs,`clipPath`);x.setAttribute(`id`,b),x.setAttribute(`clipPathUnits`,`userSpaceOnUse`);let S=document.createElementNS(hs,`polygon`),C=[{x:e.from.x+m*y,y:e.from.y+h*y},{x:e.from.x-m*y,y:e.from.y-h*y},{x:e.to.x-m*y,y:e.to.y-h*y},{x:e.to.x+m*y,y:e.to.y+h*y}];S.setAttribute(`points`,C.map(e=>`${e.x},${e.y}`).join(` `)),x.appendChild(S),n.appendChild(x),v.setAttribute(`clip-path`,`url(#${b})`);let w=document.createElementNS(hs,`path`);return w.setAttribute(`class`,`vscada-pipe-wave-ripple`),w.setAttribute(`d`,_.join(` `)),w.setAttribute(`fill`,`none`),w.setAttribute(`stroke`,i),w.setAttribute(`stroke-width`,String(s)),w.setAttribute(`stroke-linecap`,`round`),w.setAttribute(`stroke-linejoin`,`round`),w.setAttribute(`stroke-opacity`,String(c)),v.appendChild(w),{group:v,control:r.animateTransform(v,[`translate(0px, 0px)`,`translate(${-f*o}px, ${-p*o}px)`],_s)}}var xs=`http://www.w3.org/2000/svg`,Ss=180/Math.PI;function Cs(e,t){return Math.atan2(t.y-e.y,t.x-e.x)*Ss}function ws(e,t){return{x:(e.x+t.x)/2,y:(e.y+t.y)/2}}function Ts(e,t,n){let r=t.x-e.x,i=t.y-e.y,a=Math.hypot(r,i)||1,o=-i/a,s=r/a,c=(e.x+t.x)/2,l=(e.y+t.y)/2,u=n/2;return{x1:c-o*u,y1:l-s*u,x2:c+o*u,y2:l+s*u}}var Es=0;function Ds(e){return Es+=1,`${e}-${Es}`}function Os(e,t,n){let r=document.createElementNS(xs,`g`);r.setAttribute(`class`,`vscada-pipe`);let i=t.tokens.pipe;if(!i||e.segments.length===0)return{svg:r,handles:{}};qo(t.defs,i.gradient);let a=j(t.tokens.medium,e.medium),o=a?{...i,dash:{color:a.color,length:a.dashSignature.length,gap:a.dashSignature.gap,opacity:a.dashSignature.opacity}}:i,s=i.flowStyle===`wave`&&i.wave?{wave:a?{...i.wave,color:a.color}:i.wave}:void 0,c=a?.animationSpeedFactor??1,l=document.createElementNS(xs,`g`);l.setAttribute(`class`,`vscada-pipe-body`);let u=[];for(let r=0;r<e.segments.length;r++){let a=e.segments[r];ks(l,t.defs,`M ${a.from.x} ${a.from.y} L ${a.to.x} ${a.to.y}`,a.from,a.to,i.strokeWidth);let d=s?bs(a,s,t.defs,n):is(a,o,n);d.control.setPlaybackRate(c),u.push(d);let f=e.corners[r];f&&ks(l,t.defs,`M ${f.from.x} ${f.from.y} A ${f.radius} ${f.radius} 0 0 ${f.sweepFlag} ${f.to.x} ${f.to.y}`,f.from,f.to,i.strokeWidth)}r.appendChild(l);let d=document.createElementNS(xs,`g`);d.setAttribute(`class`,`vscada-pipe-flanges`);let f=e.segments[0];d.appendChild(ms(f.from,Cs(f.from,f.to),i));for(let t of e.corners)d.appendChild(ms(ws(t.from,t.to),Cs(t.from,t.to),i));let p=e.segments[e.segments.length-1];d.appendChild(ms(p.to,Cs(p.from,p.to),i)),r.appendChild(d);let m=document.createElementNS(xs,`g`);m.setAttribute(`class`,`vscada-pipe-flow-container`);for(let e of u)m.appendChild(e.group);r.appendChild(m);let h={};if(e.flowBinding){let{tag:t,max:n}=e.flowBinding;h[t]={kind:`numeric`,write(e,t){if(typeof t!=`number`)return;let r=rs(t,n)*c;for(let e of u)e.control.setPlaybackRate(r)}}}let g={kind:`animation`,pause(){for(let e of u)e.control.pause()},resume(){for(let e of u)e.control.resume()},seek(e){for(let t of u)t.control.seek(e)}};return h[Ds(`pipe-flow-animation`)]=g,{svg:r,handles:h}}function ks(e,t,n,r,i,a){let o=Ds(`vscada-pipe-grad`),s=Ts(r,i,a);Jo(t,o,s.x1,s.y1,s.x2,s.y2);let c=document.createElementNS(xs,`path`);c.setAttribute(`d`,n),c.setAttribute(`stroke`,`url(#${o})`),c.setAttribute(`stroke-width`,String(a)),c.setAttribute(`fill`,`none`),e.appendChild(c)}var As={build:Os},js=Object.freeze({group:`conveyance`,primitives:Object.freeze({duct:$o,conveyor:cs,"screw-feeder":fs})});function Ms(e,t,n){return Math.min(Math.max(e,t),n)}function Ns(e,t,n,r,i){let a=t.states[n];if(a)return e.setAttr(i.lamp,`fill`,a.lampColor),e.setText(i.label,a.label),i.body&&e.setAttr(i.body,`fill`,n===r?t.bodyEnergizedColor:t.bodyDeenergizedColor),a}function Ps(e,t,n){return(r,i)=>i===e?t:n}var Fs=class{constructor(e,t=.05){this.threshold=e,this.band=t,this.on=!1}update(e){return!this.on&&e>this.threshold*(1+this.band)?this.on=!0:this.on&&e<this.threshold*(1-this.band)&&(this.on=!1),this.on}get isOn(){return this.on}};function Is(e){}function Ls(e){let{element:t,renderer:n,tokens:r,runningState:i,defaultTransition:a,visuals:o,rotationControls:s,blinkControl:c,maxRate:l=4,liveSmoothingMs:u=300,onSpeedRawValue:d,onWarning:f=Is}=e,p={},m=t.bindings.find(e=>e.type===`state`),h=t.bindings.find(e=>e.type===`rotate`),g,_=0,v=new dr(0),y;if(m){let e=new P(m.map,t.transitions,a,f),s={kind:`state`,write(t,a,s){let l=e.resolve(a,m.tag);if(g=l.state,Ns(n,r,l.state,i,o)?.blink?c.resume():c.pause(),l.changed){let e=l.state===i?_:0;v.retarget(s,e,l.transition.duration,l.transition.easing)}}};p[m.tag]=s}if(h){let e=h.max-h.min;p[h.tag]={kind:`numeric`,write(t,n,r){typeof n==`number`&&(d?.(n,r),_=e===0?0:Ms((n-h.min)/e,0,l),g===i&&v.retarget(r,_,u,`linear`))}}}let b={kind:`tween`,tick(e,t){let n=v.valueAt(t);if(n!==y){y=n;for(let e of s)e.setPlaybackRate(n)}},snap(e,t){v.snap(t);let n=v.valueAt(t);y=n;for(let e of s)e.setPlaybackRate(n)}};p[`__rotating-tween-${t.id}`]=b;let x={kind:`animation`,pause(){for(let e of s)e.pause();c.pause()},resume(){for(let e of s)e.resume();g&&r.states[g]?.blink&&c.resume()},seek(e){for(let t of s)t.seek(e);c.seek(e)}};return p[`__rotating-animations-${t.id}`]=x,{handles:p,getCurrentState:()=>g}}var Rs={duration:1,easing:`linear`};function zs(e){}function Bs(e,t,n,r){let i=t.states[n];if(i)return e.setAttr(r.glow,`fill`,i.glowColor),e.setAttr(r.glow,`fill-opacity`,String(i.glowOpacity)),e.setText(r.label,i.label),i}function Vs(e){let{element:t,tokens:n,visuals:r,onWarning:i=zs}=e,a={},o,s=t.bindings.find(e=>e.type===`state`);if(s){let e=new P(s.map,t.transitions,Rs,i),c={kind:`state`,write(t,i){let a=e.resolve(i,s.tag);o=a.state,Bs(t,n,a.state,r)}};a[s.tag]=c}return{handles:a,getCurrentState:()=>o}}function Hs(e,t,n,r=zs){let i={},a,o=e.bindings.find(e=>e.type===`state`);if(o){let s=new P(o.map,e.transitions,Rs,r),c={kind:`state`,write(e,r){let i=s.resolve(r,o.tag);a=i.state;let c=t.states[i.state];c&&(e.setAttr(n.indicator,`fill`,c.indicatorColor),e.setText(n.label,c.label),e.setAttr(n.bridge,`opacity`,i.state===`energized`?`1`:`0`))}};i[o.tag]=c}return{handles:i,getCurrentState:()=>a}}var Us=`http://www.w3.org/2000/svg`,Ws=.4,Gs=.6,Ks=1.5;function qs(e,t,n){let r=document.createElementNS(Us,`g`);r.setAttribute(`data-element-id`,e.id),r.setAttribute(`class`,`vscada-electrical-breaker`);let i=t.tokens.electrical?.breaker;if(!i)return{svg:r,handles:{}};let{w:a,h:o}=e,s=j(t.tokens.medium,e.medium??`electrical`)?.color??i.bodyOutlineColor,c=o/2,l=a*Ws,u=a*Gs,d=document.createElementNS(Us,`line`);d.setAttribute(`class`,`vscada-breaker-lead`),d.setAttribute(`x1`,`0`),d.setAttribute(`y1`,String(c)),d.setAttribute(`x2`,String(l)),d.setAttribute(`y2`,String(c)),d.setAttribute(`stroke`,s),d.setAttribute(`stroke-width`,String((i.strokeWidth??2)*Ks)),r.appendChild(d);let f=document.createElementNS(Us,`line`);f.setAttribute(`class`,`vscada-breaker-lead`),f.setAttribute(`x1`,String(u)),f.setAttribute(`y1`,String(c)),f.setAttribute(`x2`,String(a)),f.setAttribute(`y2`,String(c)),f.setAttribute(`stroke`,s),f.setAttribute(`stroke-width`,String((i.strokeWidth??2)*Ks)),r.appendChild(f);let p=document.createElementNS(Us,`line`);p.setAttribute(`class`,`vscada-breaker-bridge`),p.setAttribute(`x1`,String(l)),p.setAttribute(`y1`,String(c)),p.setAttribute(`x2`,String(u)),p.setAttribute(`y2`,String(c)),p.setAttribute(`stroke`,s),p.setAttribute(`stroke-width`,String((i.strokeWidth??2)*Ks)),p.setAttribute(`opacity`,`0`),r.appendChild(p);let m=document.createElementNS(Us,`rect`);m.setAttribute(`class`,`vscada-breaker-body`),m.setAttribute(`x`,String(a/2-a*.12)),m.setAttribute(`y`,String(c-o*.3)),m.setAttribute(`width`,String(a*.24)),m.setAttribute(`height`,String(o*.6)),m.setAttribute(`fill`,i.bodyColor),m.setAttribute(`stroke`,i.bodyOutlineColor),m.setAttribute(`stroke-width`,String(i.strokeWidth??2)),r.appendChild(m);let h=document.createElementNS(Us,`circle`);h.setAttribute(`class`,`vscada-breaker-indicator`),h.setAttribute(`cx`,String(a/2)),h.setAttribute(`cy`,`-10`),h.setAttribute(`r`,`5`),r.appendChild(h);let g=document.createElementNS(Us,`text`);return g.setAttribute(`class`,`vscada-breaker-label`),g.setAttribute(`x`,String(a/2)),g.setAttribute(`y`,String(o+14)),g.setAttribute(`font-size`,`9`),g.setAttribute(`text-anchor`,`middle`),r.appendChild(g),{svg:r,handles:Hs(e,i,{indicator:h,label:g,bridge:p}).handles}}var Js={build:qs},Ys=`http://www.w3.org/2000/svg`,Xs=1.5;function Zs(e,t,n){let r=document.createElementNS(Ys,`g`);r.setAttribute(`data-element-id`,e.id),r.setAttribute(`class`,`vscada-electrical-transformer`);let i=t.tokens.electrical?.transformer;if(!i)return{svg:r,handles:{}};let{w:a,h:o}=e,s=o/2,c=o*.28,l=a*.4,u=a*.6,d=document.createElementNS(Ys,`ellipse`);d.setAttribute(`class`,`vscada-transformer-glow`),d.setAttribute(`cx`,String(a/2)),d.setAttribute(`cy`,String(s)),d.setAttribute(`rx`,String(a*.42)),d.setAttribute(`ry`,String(o*.48)),d.setAttribute(`fill`,`none`),d.setAttribute(`fill-opacity`,`0`),r.appendChild(d);let f=j(t.tokens.medium,e.medium??`electrical`)?.color??i.outlineColor,p=document.createElementNS(Ys,`line`);p.setAttribute(`x1`,`0`),p.setAttribute(`y1`,String(s)),p.setAttribute(`x2`,String(l-c)),p.setAttribute(`y2`,String(s)),p.setAttribute(`stroke`,f),p.setAttribute(`stroke-width`,String((i.strokeWidth??2)*Xs)),r.appendChild(p);let m=document.createElementNS(Ys,`line`);m.setAttribute(`x1`,String(u+c)),m.setAttribute(`y1`,String(s)),m.setAttribute(`x2`,String(a)),m.setAttribute(`y2`,String(s)),m.setAttribute(`stroke`,f),m.setAttribute(`stroke-width`,String((i.strokeWidth??2)*Xs)),r.appendChild(m);let h=document.createElementNS(Ys,`circle`);h.setAttribute(`class`,`vscada-transformer-coil`),h.setAttribute(`cx`,String(l)),h.setAttribute(`cy`,String(s)),h.setAttribute(`r`,String(c)),h.setAttribute(`fill`,i.coilColor),h.setAttribute(`stroke`,i.outlineColor),h.setAttribute(`stroke-width`,String(i.strokeWidth??2)),r.appendChild(h);let g=document.createElementNS(Ys,`circle`);g.setAttribute(`class`,`vscada-transformer-coil`),g.setAttribute(`cx`,String(u)),g.setAttribute(`cy`,String(s)),g.setAttribute(`r`,String(c)),g.setAttribute(`fill`,i.coilColor),g.setAttribute(`stroke`,i.outlineColor),g.setAttribute(`stroke-width`,String(i.strokeWidth??2)),r.appendChild(g);let _=document.createElementNS(Ys,`text`);return _.setAttribute(`class`,`vscada-transformer-label`),_.setAttribute(`x`,String(a/2)),_.setAttribute(`y`,String(o+14)),_.setAttribute(`font-size`,`9`),_.setAttribute(`text-anchor`,`middle`),r.appendChild(_),{svg:r,handles:Vs({element:e,tokens:i,visuals:{glow:d,label:_}}).handles}}var Qs={build:Zs},$s=`http://www.w3.org/2000/svg`;function ec(e,t,n){let r=document.createElementNS($s,`g`);r.setAttribute(`data-element-id`,e.id),r.setAttribute(`class`,`vscada-electrical-busbar`);let i=t.tokens.electrical?.busbar;if(!i)return{svg:r,handles:{}};let{w:a,h:o}=e,s=document.createElementNS($s,`rect`);s.setAttribute(`class`,`vscada-busbar-bar`),s.setAttribute(`width`,String(a)),s.setAttribute(`height`,String(o)),s.setAttribute(`fill`,i.deenergizedColor),s.setAttribute(`fill-opacity`,`1`),s.setAttribute(`stroke`,i.outlineColor),s.setAttribute(`stroke-width`,String(i.strokeWidth??1)),r.appendChild(s);let c=document.createElementNS($s,`text`);return c.setAttribute(`class`,`vscada-busbar-label`),c.setAttribute(`x`,String(a/2)),c.setAttribute(`y`,String(o+14)),c.setAttribute(`font-size`,`9`),c.setAttribute(`text-anchor`,`middle`),r.appendChild(c),{svg:r,handles:Vs({element:e,tokens:i,visuals:{glow:s,label:c}}).handles}}var tc={build:ec},nc=`http://www.w3.org/2000/svg`,rc=1e3,ic=800,ac=4,oc=`running`,sc=Ps(oc,{duration:1800,easing:`ease-out`},{duration:3500,easing:`ease-in`});function cc(e,t,n){let r=document.createElementNS(nc,`g`);r.setAttribute(`data-element-id`,e.id),r.setAttribute(`class`,`vscada-electrical-generator`);let i=t.tokens.electrical?.generator;if(!i)return{svg:r,handles:{}};let{w:a,h:o}=e,s=a/2,c=o/2,l=Math.min(a,o)*.4,u=document.createElementNS(nc,`circle`);u.setAttribute(`class`,`vscada-generator-body`),u.setAttribute(`cx`,String(s)),u.setAttribute(`cy`,String(c)),u.setAttribute(`r`,String(l)),u.setAttribute(`fill`,i.bodyDeenergizedColor),u.setAttribute(`stroke`,i.rotorColor),u.setAttribute(`stroke-width`,String(i.strokeWidth??2)),r.appendChild(u);let d=document.createElementNS(nc,`text`);d.setAttribute(`class`,`vscada-generator-g`),d.setAttribute(`x`,String(s)),d.setAttribute(`y`,String(c+4)),d.setAttribute(`font-size`,String(l)),d.setAttribute(`text-anchor`,`middle`),d.setAttribute(`fill`,i.rotorColor),d.textContent=`G`,r.appendChild(d);let f=document.createElementNS(nc,`g`);f.setAttribute(`class`,`vscada-generator-rotor`),f.style.transformOrigin=`${s}px ${c}px`;let p=document.createElementNS(nc,`rect`);p.setAttribute(`x`,String(s-1.5)),p.setAttribute(`y`,String(c-l)),p.setAttribute(`width`,`3`),p.setAttribute(`height`,String(l*.35)),p.setAttribute(`fill`,i.rotorColor),f.appendChild(p),r.appendChild(f);let m=n.animateTransform(f,[`rotate(0deg)`,`rotate(360deg)`],rc),h=s+l*.8,g=c-l*.8,_=document.createElementNS(nc,`circle`);_.setAttribute(`class`,`vscada-generator-lamp`),_.setAttribute(`cx`,String(h)),_.setAttribute(`cy`,String(g)),_.setAttribute(`r`,`5`),_.style.transformOrigin=`${h}px ${g}px`,r.appendChild(_);let v=n.animateTransform(_,[`scale(1)`,`scale(0.35)`,`scale(1)`],ic);v.pause();let y=document.createElementNS(nc,`text`);y.setAttribute(`class`,`vscada-generator-label`),y.setAttribute(`x`,String(s)),y.setAttribute(`y`,String(o+14)),y.setAttribute(`font-size`,`9`),y.setAttribute(`text-anchor`,`middle`),r.appendChild(y);let b={...Ls({element:e,renderer:n,tokens:i,runningState:oc,defaultTransition:sc,visuals:{body:u,lamp:_,label:y},rotationControls:[m],blinkControl:v,maxRate:ac}).handles},x=e.bindings.find(e=>e.type===`readout`);if(x){let e=document.createElementNS(nc,`text`);e.setAttribute(`class`,`vscada-generator-readout`),e.setAttribute(`x`,String(s)),e.setAttribute(`y`,`-8`),e.setAttribute(`font-size`,`9`),e.setAttribute(`text-anchor`,`middle`),e.setAttribute(`fill`,t.tokens.electrical?.readoutColor??i.rotorColor),r.appendChild(e),b[x.tag]={kind:`text`,write(t,n){t.setText(e,Co(n,{unit:x.unit,displayUnit:x.displayUnit,decimals:x.decimals}))}}}return{svg:r,handles:b}}var lc=Object.freeze({group:`electrical`,primitives:Object.freeze({breaker:Js,transformer:Qs,busbar:tc,generator:{build:cc}})}),uc=`http://www.w3.org/2000/svg`;function dc(e){let{element:t,theme:n,x:r,y:i}=e,a=n.tokens.filtration,o=t.bindings.find(e=>e.type===`readout`);if(!a||!o)return{text:void 0,handles:{}};let s=document.createElementNS(uc,`text`);s.setAttribute(`class`,`vscada-filtration-readout`),s.setAttribute(`x`,String(r)),s.setAttribute(`y`,String(i)),s.setAttribute(`text-anchor`,`middle`),s.setAttribute(`font-size`,`9`),s.setAttribute(`fill`,a.readoutColor);let c={kind:`text`,write(e,t){e.setText(s,Co(t,{unit:o.unit,displayUnit:o.displayUnit,decimals:o.decimals}))}};return{text:s,handles:{[o.tag]:c}}}var fc=`http://www.w3.org/2000/svg`,pc=.7,mc=.22,hc=4,gc=1.5;function _c(e,t){let n=t*pc,r=e*mc,i=(e-r)/2;return`M0,0 H${e} V${n} L${i+r},${t} L${i},${t} Z`}function vc(e,t,n){let r=document.createElementNS(fc,`g`);r.setAttribute(`data-element-id`,e.id),r.setAttribute(`class`,`vscada-filtration-bag-filter`);let i=t.tokens.filtration;if(!i)return{svg:r,handles:{}};let{w:a,h:o}=e,s=document.createElementNS(fc,`path`);s.setAttribute(`class`,`vscada-filtration-housing`),s.setAttribute(`d`,_c(a,o)),s.setAttribute(`fill`,i.hopperColor),s.setAttribute(`stroke`,i.outlineColor),s.setAttribute(`stroke-width`,String(i.strokeWidth??2)),r.appendChild(s);let c=a/5;for(let e=1;e<=hc;e++){let t=document.createElementNS(fc,`line`);t.setAttribute(`class`,`vscada-filtration-bag`),t.setAttribute(`x1`,String(c*e)),t.setAttribute(`x2`,String(c*e)),t.setAttribute(`y1`,String(o*.08)),t.setAttribute(`y2`,String(o*pc*.85)),t.setAttribute(`stroke`,i.bodyColor),t.setAttribute(`stroke-width`,String((i.strokeWidth??2)*gc)),r.appendChild(t)}let l=dc({element:e,theme:t,x:a/2,y:-6});return l.text&&r.appendChild(l.text),{svg:r,handles:l.handles}}var yc=Object.freeze({group:`filtration`,primitives:Object.freeze({"bag-filter":{build:vc}})}),bc=`http://www.w3.org/2000/svg`,xc=.55,Sc=.1;function Cc(e,t){let n=t*xc,r=e*Sc;return`M0,0 H${e} V${n} L${e/2+r/2},${t} H${e/2-r/2} Z`}function wc(e,t,n){let r=document.createElementNS(bc,`g`);r.setAttribute(`data-element-id`,e.id),r.setAttribute(`class`,`vscada-filtration-cyclone`);let i=t.tokens.filtration;if(!i)return{svg:r,handles:{}};let{w:a,h:o}=e,s=document.createElementNS(bc,`path`);s.setAttribute(`class`,`vscada-filtration-body`),s.setAttribute(`d`,Cc(a,o)),s.setAttribute(`fill`,i.bodyColor),s.setAttribute(`stroke`,i.outlineColor),s.setAttribute(`stroke-width`,String(i.strokeWidth??2)),r.appendChild(s);let c=document.createElementNS(bc,`rect`);c.setAttribute(`class`,`vscada-filtration-inlet`),c.setAttribute(`x`,String(-a*.18)),c.setAttribute(`y`,String(o*.04)),c.setAttribute(`width`,String(a*.18)),c.setAttribute(`height`,String(o*.12)),c.setAttribute(`fill`,i.bodyColor),c.setAttribute(`stroke`,i.outlineColor),c.setAttribute(`stroke-width`,String(i.strokeWidth??2)),r.appendChild(c);let l=dc({element:e,theme:t,x:a/2,y:-6});return l.text&&r.appendChild(l.text),{svg:r,handles:l.handles}}var Tc=Object.freeze({group:`filtration`,primitives:Object.freeze({cyclone:{build:wc}})}),Ec=`http://www.w3.org/2000/svg`,Dc=.2,Oc=5;function kc(e,t,n){let r=document.createElementNS(Ec,`g`);r.setAttribute(`data-element-id`,e.id),r.setAttribute(`class`,`vscada-filtration-scrubber`);let i=t.tokens.filtration;if(!i)return{svg:r,handles:{}};let{w:a,h:o}=e,s=document.createElementNS(Ec,`rect`);s.setAttribute(`class`,`vscada-filtration-body`),s.setAttribute(`width`,String(a)),s.setAttribute(`height`,String(o)),s.setAttribute(`fill`,i.bodyColor),s.setAttribute(`stroke`,i.outlineColor),s.setAttribute(`stroke-width`,String(i.strokeWidth??2)),r.appendChild(s);let c=o*Dc,l=document.createElementNS(Ec,`line`);l.setAttribute(`class`,`vscada-filtration-distributor-bar`),l.setAttribute(`x1`,String(a*.1)),l.setAttribute(`x2`,String(a*.9)),l.setAttribute(`y1`,String(c)),l.setAttribute(`y2`,String(c)),l.setAttribute(`stroke`,i.distributorColor),l.setAttribute(`stroke-width`,String(i.strokeWidth??2)),r.appendChild(l);let u=a*.8/6;for(let e=1;e<=Oc;e++){let t=document.createElementNS(Ec,`line`);t.setAttribute(`class`,`vscada-filtration-distributor-nozzle`);let n=a*.1+u*e;t.setAttribute(`x1`,String(n)),t.setAttribute(`x2`,String(n)),t.setAttribute(`y1`,String(c)),t.setAttribute(`y2`,String(c+o*.05)),t.setAttribute(`stroke`,i.distributorColor),t.setAttribute(`stroke-width`,String(i.strokeWidth??2)),r.appendChild(t)}let d=dc({element:e,theme:t,x:a/2,y:-6});return d.text&&r.appendChild(d.text),{svg:r,handles:d.handles}}var Ac=Object.freeze({group:`filtration`,primitives:Object.freeze({scrubber:{build:kc}})}),jc=`http://www.w3.org/2000/svg`;function Mc(e,t,n){let r=document.createElementNS(jc,`g`);r.setAttribute(`data-element-id`,e.id),r.setAttribute(`class`,`vscada-filtration-stack`);let i=t.tokens.filtration;if(!i)return{svg:r,handles:{}};let{w:a,h:o}=e,s=document.createElementNS(jc,`rect`);s.setAttribute(`class`,`vscada-filtration-body`),s.setAttribute(`width`,String(a)),s.setAttribute(`height`,String(o)),s.setAttribute(`fill`,i.bodyColor),s.setAttribute(`stroke`,i.outlineColor),s.setAttribute(`stroke-width`,String(i.strokeWidth??2)),r.appendChild(s);let c=dc({element:e,theme:t,x:a/2,y:-6});return c.text&&r.appendChild(c.text),{svg:r,handles:c.handles}}var Nc=Object.freeze({group:`filtration`,primitives:Object.freeze({stack:{build:Mc}})}),Pc=Object.freeze({group:`filtration`,primitives:Object.freeze({...yc.primitives,...Tc.primitives,...Ac.primitives,...Nc.primitives})}),Fc=`http://www.w3.org/2000/svg`;function Ic(e,t,n,r,i){let a=document.createElementNS(Fc,`rect`);return a.setAttribute(`x`,String(e)),a.setAttribute(`y`,String(t)),a.setAttribute(`width`,String(n)),a.setAttribute(`height`,String(r)),a.setAttribute(`fill`,i?.hardwareFillColor??`none`),a.setAttribute(`stroke`,i?.hardwareStrokeColor??`none`),i?.strokeWidth!==void 0&&a.setAttribute(`stroke-width`,String(i.strokeWidth)),a}function Lc(e,t,n,r){let i=document.createElementNS(Fc,`circle`);return i.setAttribute(`cx`,String(e)),i.setAttribute(`cy`,String(t)),i.setAttribute(`r`,String(n)),i.setAttribute(`fill`,r?.hardwareFillColor??`none`),i.setAttribute(`stroke`,r?.hardwareStrokeColor??`none`),r?.strokeWidth!==void 0&&i.setAttribute(`stroke-width`,String(r.strokeWidth)),i}function Rc(e,t,n,r,i){let a=document.createElementNS(Fc,`line`);return a.setAttribute(`x1`,String(e)),a.setAttribute(`y1`,String(t)),a.setAttribute(`x2`,String(n)),a.setAttribute(`y2`,String(r)),a.setAttribute(`stroke`,i?.weldLineColor??`none`),a.setAttribute(`stroke-width`,String((i?.strokeWidth??2)*.5)),a.setAttribute(`stroke-dasharray`,`4 3`),a.setAttribute(`class`,`vscada-vessel-weld`),a}function zc(e,t,n,r){let i=Lc(e,t,n,r);return i.setAttribute(`class`,`vscada-vessel-manway`),i}function Bc(e,t,n,r){let i=Lc(e,t,n,r);return i.setAttribute(`class`,`vscada-vessel-bung`),i}function Vc(e,t,n,r,i){let a=Ic(e,t,n,r,i);return a.setAttribute(`class`,`vscada-vessel-nozzle`),a}function Hc(e,t,n,r,i){let a=Ic(e,t,n,r,i);return a.setAttribute(`class`,`vscada-vessel-lug`),a}function Uc(e,t,n,r,i){let a=Ic(e,t,n,r,i);return a.setAttribute(`class`,`vscada-vessel-skirt`),a}function Wc(e,t,n,r,i){let a=document.createElementNS(Fc,`line`);return a.setAttribute(`x1`,String(e)),a.setAttribute(`y1`,String(t)),a.setAttribute(`x2`,String(n)),a.setAttribute(`y2`,String(r)),a.setAttribute(`stroke`,i?.hardwareStrokeColor??`none`),i?.strokeWidth!==void 0&&a.setAttribute(`stroke-width`,String(i.strokeWidth)),a.setAttribute(`class`,`vscada-vessel-leg`),a}function Gc(e,t,n,r){let i=document.createElementNS(Fc,`g`);switch(i.setAttribute(`class`,`vscada-vessel-hardware`),n){case`tank-vertical`:i.appendChild(Vc(e*.45,-t*.03,e*.1,t*.05,r)),i.appendChild(zc(e*.22,t*.1,e*.05,r)),i.appendChild(Hc(e*.06,t*.06,e*.06,t*.03,r)),i.appendChild(Hc(e*.88,t*.06,e*.06,t*.03,r)),i.appendChild(Uc(e*.1,t*.96,e*.8,t*.04,r)),i.appendChild(Rc(0,t*.35,e,t*.35,r)),i.appendChild(Rc(0,t*.68,e,t*.68,r));break;case`tank-horizontal`:i.appendChild(Vc(e*.46,-t*.05,e*.08,t*.06,r)),i.appendChild(zc(e*.75,t*.2,t*.06,r)),i.appendChild(Uc(e*.18,t*.9,e*.1,t*.14,r)),i.appendChild(Uc(e*.72,t*.9,e*.1,t*.14,r)),i.appendChild(Rc(e*.22,0,e*.22,t,r)),i.appendChild(Rc(e*.78,0,e*.78,t,r));break;case`drum`:i.appendChild(Bc(e*.5,-t*.02,t*.05,r)),i.appendChild(Hc(e*.15,t*.85,e*.08,t*.1,r)),i.appendChild(Hc(e*.77,t*.85,e*.08,t*.1,r)),i.appendChild(Rc(e*.5,0,e*.5,t,r));break;case`sphere`:{let n=e/2,a=t/2,o=Math.min(e,t)/2;i.appendChild(Vc(n-e*.04,a-o-t*.04,e*.08,t*.05,r)),i.appendChild(Wc(n-o*.5,a+o*.6,n-o*.9,t,r)),i.appendChild(Wc(n,a+o*.8,n,t,r)),i.appendChild(Wc(n+o*.5,a+o*.6,n+o*.9,t,r));break}case`hopper`:i.appendChild(Vc(e*.45,-t*.03,e*.1,t*.04,r)),i.appendChild(zc(e*.2,t*.12,e*.05,r)),i.appendChild(Vc(e*.42,t*.98,e*.16,t*.05,r)),i.appendChild(Rc(0,t*.5,e,t*.5,r));break;case`silo`:i.appendChild(Vc(e*.46,-t*.03,e*.08,t*.04,r)),i.appendChild(zc(e*.15,t*.3,e*.04,r)),i.appendChild(Uc(e*.1,t*.94,e*.8,t*.06,r)),i.appendChild(Rc(0,t*.45,e,t*.45,r)),i.appendChild(Rc(0,t*.7,e,t*.7,r));break}return i}function Kc(e,t,n,r=6){let i=[],a=r>0?r:6,o=e=>-t*Math.sin(2*Math.PI*e/n);for(let t=0;t<e;t+=a)i.push({x:t,y:o(t)});return i.push({x:e,y:o(e)}),i}function qc(e,t,n,r=6){return Kc(e,t,n,r).map((e,t)=>`${t===0?`M`:`L`}${e.x},${e.y}`).join(` `)}function Jc(e,t,n,r,i=6){return`${qc(e,t,n,i)} L${e},${r} L0,${r} Z`}var Yc=`http://www.w3.org/2000/svg`,Xc=4e3;function Zc(e){return Math.max(e*2.5,6)}function Qc(e,t){let{containerWidth:n,amplitude:r,period:i,speedFactor:a,color:o,opacity:s,specular:c}=e,l=Math.max(n*2,n+i),u=Jc(l,r,i,Zc(r)),d=document.createElementNS(Yc,`g`);d.setAttribute(`class`,`vscada-liquid-wave-carrier`);let f=document.createElementNS(Yc,`g`);f.setAttribute(`class`,`vscada-liquid-wave-loop`),d.appendChild(f);let p=document.createElementNS(Yc,`path`);if(p.setAttribute(`class`,`vscada-liquid-wave-fill`),p.setAttribute(`d`,u),p.setAttribute(`fill`,o),p.setAttribute(`fill-opacity`,String(s)),p.setAttribute(`stroke`,`none`),f.appendChild(p),c!==`none`){let e=document.createElementNS(Yc,`path`);e.setAttribute(`class`,`vscada-liquid-wave-specular vscada-liquid-wave-specular--${c}`),e.setAttribute(`d`,qc(l,r,i)),e.setAttribute(`fill`,`none`),e.setAttribute(`stroke`,o),e.setAttribute(`stroke-width`,c===`sharp`?`2`:String(Math.max(r*2,8)));let t=Math.min(1,Math.max(0,(c===`sharp`?.9:.35)*s));e.setAttribute(`stroke-opacity`,String(t)),f.appendChild(e)}let m=t.animateTransform(f,[`translateX(0px)`,`translateX(-${i}px)`],Xc);return m.setPlaybackRate(a),{carrier:d,control:m}}var $c=.18;function el(e,t,n=$c){return Math.min(e*n,t*.4)}function tl(e,t,n=$c){let r=el(e,t,n),i=t-r;return`M0,0 H${e} V${i} A${e/2},${r} 0 0 1 0,${i} Z`}var nl=.5,rl=.18,il=.18;function al(e,t,n=$c){let r=Math.min(t*n*2,e*.4),i=t/2,a=e-r;return`M${r},0 H${a} A${r},${i} 0 0 1 ${a},${t} H${r} A${r},${i} 0 0 1 ${r},0 Z`}function ol(e,t,n=$c){return Math.min(t*n*2,e*.4)}function sl(e,t){return{cx:e/2,cy:t/2,r:Math.min(e,t)/2}}function cl(e,t){let{cx:n,cy:r,r:i}=sl(e,t);return`M${n-i},${r} A${i},${i} 0 1 0 ${n+i},${r} A${i},${i} 0 1 0 ${n-i},${r} Z`}function ll(e,t,n=nl,r=rl){let i=t*n,a=e*r,o=(e-a)/2;return`M0,0 H${e} V${i} L${o+a},${t} L${o},${t} Z`}function ul(e,t,n=il){let r=t*n;return`M0,${r} L${e/2},0 L${e},${r} V${t} H0 Z`}function dl(e,t=il){return e*t}function fl(e,t,n=il){return`M0,${dl(t,n)} H${e} V${t} H0 Z`}var W=`http://www.w3.org/2000/svg`,pl=.12,ml=.3,hl=.12,gl=.4,_l=.36,vl=.24,yl=.35,bl=.6,xl=.05,Sl=.3,Cl=4;function wl(e){return Number.isNaN(e)?0:Math.min(Math.max(e,0),1)}function Tl(e,t,n){e.querySelector(`#${t}`)||e.appendChild(n())}function El(e,t,n){let r=document.createElementNS(W,`linearGradient`);r.setAttribute(`id`,e),r.setAttribute(`x1`,`0`),r.setAttribute(`y1`,`0`),r.setAttribute(`x2`,t===`x`?`1`:`0`),r.setAttribute(`y2`,t===`x`?`0`:`1`);for(let e of n){let t=document.createElementNS(W,`stop`);t.setAttribute(`offset`,String(e.offset)),t.setAttribute(`stop-color`,e.color),r.appendChild(t)}return r}function Dl(e,t){let n=document.createElementNS(W,`radialGradient`);n.setAttribute(`id`,e),n.setAttribute(`cx`,`0.35`),n.setAttribute(`cy`,`0.3`),n.setAttribute(`r`,`0.75`);for(let e of t){let t=document.createElementNS(W,`stop`);t.setAttribute(`offset`,String(e.offset)),t.setAttribute(`stop-color`,e.color),n.appendChild(t)}return n}function Ol(e,t,n){Tl(e,t,()=>{let e=document.createElementNS(W,`clipPath`);e.setAttribute(`id`,t);let r=document.createElementNS(W,`path`);return r.setAttribute(`d`,n),e.appendChild(r),e})}function kl(e,t,n,r){let i=document.createElementNS(W,`path`);if(i.setAttribute(`class`,`vscada-vessel-body-base`),i.setAttribute(`d`,e),i.setAttribute(`stroke`,t?.bodyStrokeColor??`none`),t?.strokeWidth!==void 0&&i.setAttribute(`stroke-width`,String(t.strokeWidth)),t?.bodyGradientTopColor&&t.bodyGradientBottomColor){let e=`vscada-vessel-body-gradient-${r}`;Tl(n,e,()=>El(e,`y`,[{offset:0,color:t.bodyGradientTopColor},{offset:1,color:t.bodyGradientBottomColor}])),i.setAttribute(`fill`,`url(#${e})`)}else i.setAttribute(`fill`,t?.bodyFillColor??`none`);return i}function Al(e,t,n,r,i,a){let o=document.createElementNS(W,`path`);o.setAttribute(`class`,`vscada-vessel-shading`),o.setAttribute(`d`,e),o.setAttribute(`clip-path`,`url(#${a})`);let s=n?.shadingDarkColor,c=n?.shadingLightColor,l=n?.shadingMidColor;if(s&&c&&l){let e=`vscada-vessel-shading-gradient-${i}`;Tl(r,e,()=>t===`spherical`?Dl(e,[{offset:0,color:c},{offset:bl,color:l},{offset:1,color:s}]):El(e,t===`vertical`?`x`:`y`,[{offset:0,color:s},{offset:yl,color:c},{offset:bl,color:l},{offset:1,color:s}])),o.setAttribute(`fill`,`url(#${e})`)}else o.setAttribute(`fill`,`none`);return o}function jl(e,t,n,r,i){let a=r?.specularColor??`none`;if(n===`spherical`){let{cx:n,cy:r,r:o}=sl(e,t),s=document.createElementNS(W,`ellipse`);return s.setAttribute(`class`,`vscada-vessel-specular`),s.setAttribute(`cx`,String(n-o*gl)),s.setAttribute(`cy`,String(r-o*gl)),s.setAttribute(`rx`,String(o*_l)),s.setAttribute(`ry`,String(o*vl)),s.setAttribute(`fill`,a),s.setAttribute(`fill-opacity`,String(hl)),s.setAttribute(`clip-path`,`url(#${i})`),s}let o=document.createElementNS(W,`rect`);if(o.setAttribute(`class`,`vscada-vessel-specular`),o.setAttribute(`fill`,a),o.setAttribute(`fill-opacity`,String(hl)),o.setAttribute(`clip-path`,`url(#${i})`),n===`vertical`){let n=e*pl;o.setAttribute(`x`,String(e*ml-n/2)),o.setAttribute(`y`,`0`),o.setAttribute(`width`,String(n)),o.setAttribute(`height`,String(t))}else{let n=t*pl;o.setAttribute(`x`,`0`),o.setAttribute(`y`,String(t*ml-n/2)),o.setAttribute(`width`,String(e)),o.setAttribute(`height`,String(n))}return o}function Ml(e,t){let n=document.createElementNS(W,`g`);n.setAttribute(`class`,`vscada-vessel-rim`);for(let r of e){let e=document.createElementNS(W,`ellipse`);e.setAttribute(`cx`,String(r.cx)),e.setAttribute(`cy`,String(r.cy)),e.setAttribute(`rx`,String(r.rx)),e.setAttribute(`ry`,String(r.ry)),e.setAttribute(`fill`,`none`),e.setAttribute(`stroke`,t?.rimStrokeColor??`none`),t?.strokeWidth!==void 0&&e.setAttribute(`stroke-width`,String(t.strokeWidth)),n.appendChild(e);let i=document.createElementNS(W,`path`);if(i.setAttribute(`d`,`M${r.cx-r.rx},${r.cy} A${r.rx},${r.ry} 0 0 1 ${r.cx+r.rx},${r.cy}`),i.setAttribute(`fill`,`none`),i.setAttribute(`stroke`,t?.rimHighlightColor??`none`),t?.strokeWidth!==void 0&&i.setAttribute(`stroke-width`,String(t.strokeWidth)),n.appendChild(i),r.crownRibbing)for(let e=0;e<Cl;e++){let i=e/(Cl-1)*2-1,a=r.cx+i*r.rx*.6,o=r.cy-r.ry*.6,s=document.createElementNS(W,`line`);s.setAttribute(`x1`,String(a)),s.setAttribute(`y1`,String(r.cy)),s.setAttribute(`x2`,String(a)),s.setAttribute(`y2`,String(o)),s.setAttribute(`stroke`,t?.rimHighlightColor??`none`),t?.strokeWidth!==void 0&&s.setAttribute(`stroke-width`,String(t.strokeWidth)),n.appendChild(s)}}return n}function Nl(e,t,n){let r=document.createElementNS(W,`ellipse`);return r.setAttribute(`class`,`vscada-vessel-shadow`),r.setAttribute(`cx`,String(e/2)),r.setAttribute(`cy`,String(t)),r.setAttribute(`rx`,String(e*.55)),r.setAttribute(`ry`,String(e*xl)),r.setAttribute(`fill`,n?.contactShadowColor??`none`),r.setAttribute(`fill-opacity`,String(Sl)),r}function Pl(e){return e.bindings.find(e=>e.type===`level`)}function G({element:e,theme:t,renderer:n,geometry:r}){let{w:i,h:a,id:o}=e,s=t.tokens.vessel,c=t.tokens.liquid,l=r.liquidClipPathD??r.bodyPathD,u=document.createElementNS(W,`g`);u.setAttribute(`data-element-id`,o),u.setAttribute(`class`,`vscada-vessel`),u.setAttribute(`data-vessel-type`,r.hardware),u.setAttribute(`data-alarm-band`,`normal`);let d=`vscada-vessel-body-clip-${o}`;Ol(t.defs,d,r.bodyPathD);let f=`vscada-vessel-liquid-clip-${o}`;Ol(t.defs,f,l),u.appendChild(kl(r.bodyPathD,s,t.defs,o)),u.appendChild(Al(r.bodyPathD,r.orientation,s,t.defs,o,d));let p=document.createElementNS(W,`g`);p.setAttribute(`class`,`vscada-vessel-liquid`),p.setAttribute(`clip-path`,`url(#${f})`);let m=document.createElementNS(W,`g`);m.setAttribute(`class`,`vscada-vessel-liquid-fill`),m.style.transformOrigin=`0px ${a}px`,p.appendChild(m);let h=document.createElementNS(W,`rect`);h.setAttribute(`width`,String(i)),h.setAttribute(`height`,String(a));let g=e.medium??c?.defaultMedium??``,_=c?.media[g]??(c?c.media[c.defaultMedium]:void 0);if(_){let e=`vscada-vessel-fill-${o}`;Tl(t.defs,e,()=>El(e,`y`,[{offset:0,color:_.top},{offset:1,color:_.bottom}])),h.setAttribute(`fill`,`url(#${e})`)}else h.setAttribute(`fill`,`none`);m.appendChild(h);let v=j(t.tokens.medium,e.medium),y=v?.color??_?.top??c?.surfaceColor,b=v?.specular!==void 0,x=[],S=[];if(c&&y&&i>0){let e=Math.max(1,Math.floor(c.waveCount??1));for(let t=0;t<e;t++){let e=Qc({containerWidth:i,amplitude:v?.waveAmplitude??3,period:v?.wavePeriod??80,speedFactor:v?.waveSpeed??1,color:y,opacity:v?.opacity??.4,specular:v?.specular??`sharp`},n);e.carrier.classList.add(`vscada-vessel-wave`),p.appendChild(e.carrier),x.push(e);let t=e.carrier.querySelector(`.vscada-liquid-wave-specular`);t&&S.push(t)}}let C=b?void 0:document.createElementNS(W,`line`);if(C){C.setAttribute(`class`,`vscada-vessel-surface`),C.setAttribute(`x1`,`0`),C.setAttribute(`x2`,String(i)),C.setAttribute(`y1`,`0`),C.setAttribute(`y2`,`0`);let e=po(s?.alarm,`normal`,c?.surfaceColor)??`none`;C.setAttribute(`stroke`,e),s?.strokeWidth!==void 0&&C.setAttribute(`stroke-width`,String(s.strokeWidth)),p.appendChild(C)}u.appendChild(p),u.appendChild(jl(i,a,r.orientation,s,d)),u.appendChild(Ml(r.rims,s)),u.appendChild(Gc(i,a,r.hardware,s));let w=Pl(e),T=document.createElementNS(W,`g`);T.setAttribute(`class`,`vscada-vessel-thresholds`);let E=r.markerMinY??0;if(w){let t=w.max-w.min,n=e.thresholds.filter(e=>e.tag===w.tag);for(let e of n){let n=t===0?0:wl((e.value-w.min)/t),r=Math.max(a*(1-n),E),o=document.createElementNS(W,`line`);o.setAttribute(`class`,`vscada-vessel-threshold-marker vscada-vessel-threshold-marker--${e.level}`),o.setAttribute(`data-level`,e.level),o.setAttribute(`x1`,String(-i*.06)),o.setAttribute(`x2`,String(i*1.06)),o.setAttribute(`y1`,String(r)),o.setAttribute(`y2`,String(r)),o.setAttribute(`stroke`,po(s?.alarm,e.level,void 0)??`none`),s?.strokeWidth!==void 0&&o.setAttribute(`stroke-width`,String(s.strokeWidth)),T.appendChild(o)}}u.appendChild(T),u.appendChild(Nl(i,a,s));let D={};if(w){let t=w.max-w.min,n=e.thresholds.filter(e=>e.tag===w.tag);D[w.tag]={kind:`numeric`,write(e,r){if(typeof r!=`number`)return;let i=t===0?0:wl((r-w.min)/t),o=a*(1-i);for(let t of x)e.setTransform(t.carrier,`translateY(${o}px)`);C&&(e.setAttr(C,`y1`,String(o)),e.setAttr(C,`y2`,String(o)));let l=fo(r,n);if(C){let t=po(s?.alarm,l,c?.surfaceColor)??`none`;e.setAttr(C,`stroke`,t)}if(!C&&S.length>0){let t=(l===`normal`?void 0:po(s?.alarm,l,void 0))??y??`none`;for(let n of S)e.setAttr(n,`stroke`,t)}e.setAttr(u,`data-alarm-band`,l),e.setTransform(m,`scaleY(${i})`)}}}if(x.length>0){let e={kind:`animation`,pause(){for(let e of x)e.control.pause()},resume(){for(let e of x)e.control.resume()},seek(e){for(let t of x)t.control.seek(e)}};D[`__vessel-wave-animation-${o}`]=e}return{svg:u,handles:D}}var Fl=`http://www.w3.org/2000/svg`,Il=3,Ll=2;function Rl(e,t){let n=al(e,t),r=ol(e,t);return{orientation:`horizontal`,bodyPathD:n,rims:[{cx:r,cy:t/2,rx:r,ry:t/2},{cx:e-r,cy:t/2,rx:r,ry:t/2}],hardware:`tank-horizontal`}}function zl(e,t,n){let r=document.createElementNS(Fl,`g`);r.setAttribute(`class`,`vscada-heat-tube-bundle`);let i=t/4,a=i*.7;for(let t=1;t<=Il;t++)for(let o=0;o<Ll;o++){let s=document.createElementNS(Fl,`circle`);s.setAttribute(`class`,`vscada-heat-tube-end`),s.setAttribute(`cx`,String(e+(o-(Ll-1)/2)*a)),s.setAttribute(`cy`,String(i*t)),s.setAttribute(`r`,String(i*.16)),s.setAttribute(`fill`,n),r.appendChild(s)}return r}function Bl(e,t,n){let{svg:r,handles:i}=G({element:e,theme:t,renderer:n,geometry:Rl(e.w,e.h)}),a=t.tokens.heat;if(a){let t=ol(e.w,e.h);r.appendChild(zl(t,e.h,a.tubeBundleColor)),r.appendChild(zl(e.w-t,e.h,a.tubeBundleColor))}return{svg:r,handles:i}}var Vl=Object.freeze({group:`heat`,primitives:Object.freeze({"heat-exchanger-shell-tube":{build:Bl}})}),Hl=`http://www.w3.org/2000/svg`,Ul=4;function Wl(e,t,n){let r=t/n,i=Math.min(r/2,e/4),a=`M0,${i}`,o=!0;for(let t=0;t<n;t++){if(a+=o?` H${e-i}`:` H${i}`,t<n-1){let n=r*(t+1)+i,s=+!!o,c=o?e-i:i;a+=` A${i},${i} 0 0 ${s} ${c},${n}`}o=!o}return a}function Gl(e,t,n){let r=document.createElementNS(Hl,`g`);r.setAttribute(`data-element-id`,e.id),r.setAttribute(`class`,`vscada-heat-coil`);let i=t.tokens.pipe,a=t.tokens.heat;if(!i||!a)return{svg:r,handles:{}};let o=qo(t.defs,i.gradient),{w:s,h:c}=e,l=document.createElementNS(Hl,`path`);return l.setAttribute(`class`,`vscada-heat-coil-path`),l.setAttribute(`d`,Wl(s,c,Ul)),l.setAttribute(`fill`,`none`),l.setAttribute(`stroke`,`url(#${o})`),l.setAttribute(`stroke-width`,String(i.strokeWidth*a.coilWidthFactor)),l.setAttribute(`stroke-linecap`,`round`),r.appendChild(l),{svg:r,handles:{}}}var Kl=Object.freeze({group:`heat`,primitives:Object.freeze({"heat-exchanger-coil":{build:Gl}})}),ql={duration:1,easing:`linear`};function Jl(e){}function Yl(e,t,n,r){let i=t.states[n];if(i)return e.setAttr(r.glow,`fill`,i.glowColor),e.setAttr(r.glow,`fill-opacity`,String(i.glowOpacity)),e.setText(r.label,i.label),i}function Xl(e){let{element:t,tokens:n,visuals:r,onWarning:i=Jl}=e,a={},o,s=t.bindings.find(e=>e.type===`state`);if(s){let e=new P(s.map,t.transitions,ql,i),c={kind:`state`,write(t,i){let a=e.resolve(i,s.tag);o=a.state,Yl(t,n,a.state,r)}};a[s.tag]=c}return{handles:a,getCurrentState:()=>o}}var Zl=`http://www.w3.org/2000/svg`;function Ql(e,t){let n=al(e,t),r=ol(e,t);return{orientation:`horizontal`,bodyPathD:n,rims:[{cx:r,cy:t/2,rx:r,ry:t/2},{cx:e-r,cy:t/2,rx:r,ry:t/2}],hardware:`drum`}}function $l(e,t,n){let{svg:r,handles:i}=G({element:e,theme:t,renderer:n,geometry:Ql(e.w,e.h)}),a=t.tokens.heat;if(!a)return{svg:r,handles:i};let{w:o,h:s}=e,c=document.createElementNS(Zl,`ellipse`);c.setAttribute(`class`,`vscada-heat-firing-glow`),c.setAttribute(`cx`,String(o/2)),c.setAttribute(`cy`,String(s/2)),c.setAttribute(`rx`,String(o*.32)),c.setAttribute(`ry`,String(s*.32)),c.setAttribute(`fill`,`none`),c.setAttribute(`fill-opacity`,`0`),r.appendChild(c);let l=document.createElementNS(Zl,`text`);l.setAttribute(`class`,`vscada-heat-firing-label`),l.setAttribute(`x`,String(o/2)),l.setAttribute(`y`,String(s+14)),l.setAttribute(`font-size`,`9`),l.setAttribute(`text-anchor`,`middle`),r.appendChild(l);let u=Xl({element:e,tokens:a,visuals:{glow:c,label:l}});return{svg:r,handles:{...i,...u.handles}}}var eu=Object.freeze({group:`heat`,primitives:Object.freeze({boiler:{build:$l}})}),tu=`http://www.w3.org/2000/svg`;function nu(e,t){let n=e*.28;return`M${n},0 H${e-n} L${e},${t} H0 Z`}function ru(e,t,n){let r=document.createElementNS(tu,`g`);r.setAttribute(`data-element-id`,e.id),r.setAttribute(`class`,`vscada-heat-furnace`);let i=t.tokens.heat;if(!i)return{svg:r,handles:{}};let{w:a,h:o}=e,s=document.createElementNS(tu,`path`);s.setAttribute(`class`,`vscada-heat-furnace-body`),s.setAttribute(`d`,nu(a,o)),s.setAttribute(`fill`,i.bodyColor),s.setAttribute(`stroke`,i.outlineColor),s.setAttribute(`stroke-width`,String(i.strokeWidth??2)),r.appendChild(s);let c=document.createElementNS(tu,`ellipse`);c.setAttribute(`class`,`vscada-heat-firing-glow`),c.setAttribute(`cx`,String(a/2)),c.setAttribute(`cy`,String(o*.62)),c.setAttribute(`rx`,String(a*.24)),c.setAttribute(`ry`,String(o*.28)),c.setAttribute(`fill`,`none`),c.setAttribute(`fill-opacity`,`0`),r.appendChild(c);let l=document.createElementNS(tu,`text`);l.setAttribute(`class`,`vscada-heat-firing-label`),l.setAttribute(`x`,String(a/2)),l.setAttribute(`y`,String(o+14)),l.setAttribute(`font-size`,`9`),l.setAttribute(`text-anchor`,`middle`),r.appendChild(l);let u={...Xl({element:e,tokens:i,visuals:{glow:c,label:l}}).handles},d=e.bindings.find(e=>e.type===`color-ramp`);if(d){let e={kind:`numeric`,write(e,n){if(typeof n!=`number`)return;let r=An(d,n,t.tokens.colorRamp)??i.states.firing?.glowColor;r&&e.setAttr(c,`fill`,r)}};u[d.tag]=e}return{svg:r,handles:u}}var iu=Object.freeze({group:`heat`,primitives:Object.freeze({furnace:{build:ru}})}),au=`http://www.w3.org/2000/svg`,ou=3;function su(e,t){let n=al(e,t),r=ol(e,t);return{orientation:`horizontal`,bodyPathD:n,rims:[{cx:r,cy:t/2,rx:r,ry:t/2},{cx:e-r,cy:t/2,rx:r,ry:t/2}],hardware:`tank-horizontal`}}function cu(e,t,n){let r=document.createElementNS(au,`g`);r.setAttribute(`class`,`vscada-heat-condensate-wells`);let i=e/4;for(let e=1;e<=ou;e++){let a=document.createElementNS(au,`ellipse`);a.setAttribute(`class`,`vscada-heat-condensate-well`),a.setAttribute(`cx`,String(i*e)),a.setAttribute(`cy`,String(t*.92)),a.setAttribute(`rx`,String(i*.22)),a.setAttribute(`ry`,String(t*.05)),a.setAttribute(`fill`,n),r.appendChild(a)}return r}function lu(e,t,n){let{svg:r,handles:i}=G({element:e,theme:t,renderer:n,geometry:su(e.w,e.h)}),a=t.tokens.heat;return a&&r.appendChild(cu(e.w,e.h,a.condensateColor)),{svg:r,handles:i}}var uu=Object.freeze({group:`heat`,primitives:Object.freeze({condenser:{build:lu}})}),du=`http://www.w3.org/2000/svg`;function fu(e,t){let n=e*.48,r=e*.26,i=e*.34,a=t*.55;return`M${e/2-n},${t} L${e/2-r},${a} L${e/2-i},0 H${e/2+i} L${e/2+r},${a} L${e/2+n},${t} Z`}function pu(e,t,n){let r=document.createElementNS(du,`g`);r.setAttribute(`data-element-id`,e.id),r.setAttribute(`class`,`vscada-heat-cooling-tower`);let i=t.tokens.heat;if(!i)return{svg:r,handles:{}};let{w:a,h:o}=e,s=document.createElementNS(du,`path`);return s.setAttribute(`class`,`vscada-heat-cooling-tower-body`),s.setAttribute(`d`,fu(a,o)),s.setAttribute(`fill`,i.bodyColor),s.setAttribute(`stroke`,i.outlineColor),s.setAttribute(`stroke-width`,String(i.strokeWidth??2)),r.appendChild(s),{svg:r,handles:{}}}var mu=Object.freeze({group:`heat`,primitives:Object.freeze({"cooling-tower":{build:pu}})}),hu=Object.freeze({group:`heat`,primitives:Object.freeze({...Vl.primitives,...Kl.primitives,...eu.primitives,...iu.primitives,...uu.primitives,...mu.primitives})}),K=`http://www.w3.org/2000/svg`,gu=700,_u=`critically-damped-overshoot`,vu=11,yu=.75;function bu(e,t,n){return Math.min(Math.max(e,t),n)}function xu(e,t,n,r){let i=(r-90)*Math.PI/180;return{x:e+n*Math.cos(i),y:t+n*Math.sin(i)}}function Su(e,t,n,r,i){let a=xu(e,t,n,r),o=xu(e,t,n,i),s=+(i-r>180);return`M ${a.x} ${a.y} A ${n} ${n} 0 ${s} 1 ${o.x} ${o.y}`}function Cu(e,t,n){let r=new Set([0,1]);for(let i of n)r.add(hn(e,t,i.value));let i=[...r].sort((e,t)=>e-t),a=[];for(let r=0;r<i.length-1;r++){let o=i[r],s=i[r+1];if(s===o)continue;let c=e+(o+s)/2*(t-e);a.push({fromFrac:o,toFrac:s,band:fo(c,n)})}return a}function wu(e,t,n){let r=t.tokens.gauge,i=document.createElementNS(K,`g`);if(i.setAttribute(`data-element-id`,e.id),i.setAttribute(`class`,`vscada-gauge-analog`),!r)return{svg:i,handles:{}};let a=e.bindings.find(e=>e.type===`needle`);if(!a)return{svg:i,handles:{}};let{w:o,h:s}=e,c=o/2,l=s/2,u=Math.min(o,s)*.45,d=yn,f=e.thresholds.filter(e=>e.tag===a.tag),p=document.createElementNS(K,`circle`);p.setAttribute(`class`,`vscada-gauge-face`),p.setAttribute(`cx`,String(c)),p.setAttribute(`cy`,String(l)),p.setAttribute(`r`,String(u)),p.setAttribute(`fill`,r.face.faceColor),p.setAttribute(`stroke`,r.face.bevelShadowColor),p.setAttribute(`stroke-width`,String(r.face.strokeWidth??2)),i.appendChild(p);let m=document.createElementNS(K,`circle`);m.setAttribute(`class`,`vscada-gauge-bevel`),m.setAttribute(`cx`,String(c)),m.setAttribute(`cy`,String(l)),m.setAttribute(`r`,String(u*.92)),m.setAttribute(`fill`,`none`),m.setAttribute(`stroke`,r.face.bevelHighlightColor),m.setAttribute(`stroke-width`,String((r.face.strokeWidth??2)*yu)),i.appendChild(m);let h=u*.82,g=Cu(a.min,a.max,f);for(let e of g){let t=d.minAngleDeg+e.fromFrac*(d.maxAngleDeg-d.minAngleDeg),n=d.minAngleDeg+e.toFrac*(d.maxAngleDeg-d.minAngleDeg),a=document.createElementNS(K,`path`);a.setAttribute(`class`,`vscada-gauge-zone vscada-gauge-zone-${e.band}`),a.setAttribute(`d`,Su(c,l,h,t,n)),a.setAttribute(`fill`,`none`),a.setAttribute(`stroke`,po(r.zones,e.band,r.zones.normalColor)??r.zones.normalColor),a.setAttribute(`stroke-width`,String(u*.1)),i.appendChild(a)}for(let e=0;e<vu;e++){let t=e/(vu-1),n=d.minAngleDeg+t*(d.maxAngleDeg-d.minAngleDeg),o=xu(c,l,u*.7,n),s=xu(c,l,u*.58,n),f=document.createElementNS(K,`line`);f.setAttribute(`class`,`vscada-gauge-tick`),f.setAttribute(`x1`,String(s.x)),f.setAttribute(`y1`,String(s.y)),f.setAttribute(`x2`,String(o.x)),f.setAttribute(`y2`,String(o.y)),f.setAttribute(`stroke`,r.face.tickColor),f.setAttribute(`stroke-width`,String((r.face.strokeWidth??2)*yu)),i.appendChild(f);let p=a.min+t*(a.max-a.min),m=xu(c,l,u*.45,n),h=document.createElementNS(K,`text`);h.setAttribute(`class`,`vscada-gauge-division-label`),h.setAttribute(`x`,String(m.x)),h.setAttribute(`y`,String(m.y)),h.setAttribute(`font-size`,`7`),h.setAttribute(`text-anchor`,`middle`),h.setAttribute(`fill`,r.face.divisionLabelColor),h.textContent=String(Math.round(p)),i.appendChild(h)}let _=document.createElementNS(K,`line`);_.setAttribute(`class`,`vscada-gauge-needle`),_.setAttribute(`x1`,String(c)),_.setAttribute(`y1`,String(l)),_.setAttribute(`x2`,String(c)),_.setAttribute(`y2`,String(l-u*.75)),_.setAttribute(`stroke`,r.face.needleColor),_.setAttribute(`stroke-width`,String(r.face.strokeWidth??2)),_.style.transformOrigin=`${c}px ${l}px`,i.appendChild(_);let v=document.createElementNS(K,`circle`);v.setAttribute(`class`,`vscada-gauge-pivot`),v.setAttribute(`cx`,String(c)),v.setAttribute(`cy`,String(l)),v.setAttribute(`r`,String(u*.06)),v.setAttribute(`fill`,r.face.pivotColor),i.appendChild(v);let y=document.createElementNS(K,`text`);y.setAttribute(`class`,`vscada-gauge-caption`),y.setAttribute(`x`,String(c)),y.setAttribute(`y`,String(s+14)),y.setAttribute(`font-size`,`10`),y.setAttribute(`font-weight`,`bold`),y.setAttribute(`text-anchor`,`middle`),y.setAttribute(`fill`,r.face.captionColor),y.textContent=e.label??``,i.appendChild(y);let b={},x=new dr(d.minAngleDeg),S=!1,C;function w(e,t){let n=bu(t,d.minAngleDeg,d.maxAngleDeg);n!==C&&(C=n,e.setTransform(_,`rotate(${n}deg)`))}b[a.tag]={kind:`numeric`,write(e,t,n){if(typeof t!=`number`)return;let i=bn(a,t,d),o=fo(t,f);if(e.setAttr(_,`stroke`,po(r.zones,o,r.face.needleColor)??r.face.needleColor),!S){S=!0,x.retarget(n,i,1,`linear`),x.snap(n),w(e,i);return}x.retarget(n,i,gu,_u)}};let T={kind:`tween`,tick(e,t){w(e,x.valueAt(t))},snap(e,t){x.snap(t),w(e,x.valueAt(t))}};return b[`__gauge-analog-tween-${e.id}`]=T,{svg:i,handles:b}}var Tu=Object.freeze({group:`instruments`,primitives:Object.freeze({"gauge-analog":{build:wu}})}),Eu=`http://www.w3.org/2000/svg`,Du={duration:1,easing:`linear`};function Ou(e){}function ku(e,t,n){let r=t.tokens.indicatorLamp,i=document.createElementNS(Eu,`g`);if(i.setAttribute(`data-element-id`,e.id),i.setAttribute(`class`,`vscada-indicator-lamp`),!r)return{svg:i,handles:{}};let a=r,{w:o,h:s}=e,c=o/2,l=s/2,u=Math.min(o,s)*.4,d=document.createElementNS(Eu,`circle`);d.setAttribute(`class`,`vscada-indicator-lamp-shape`),d.setAttribute(`cx`,String(c)),d.setAttribute(`cy`,String(l)),d.setAttribute(`r`,String(u)),d.style.transformOrigin=`${c}px ${l}px`,i.appendChild(d);let f=1e3/r.fastBlinkHz,p=n.animateTransform(d,[`scale(1)`,`scale(0.3)`,`scale(1)`],f);p.pause();let m=document.createElementNS(Eu,`text`);m.setAttribute(`class`,`vscada-indicator-lamp-label`),m.setAttribute(`x`,String(c)),m.setAttribute(`y`,String(s+12)),m.setAttribute(`font-size`,`9`),m.setAttribute(`text-anchor`,`middle`),i.appendChild(m);function h(e,t){let n=a.states[t];n&&(e.setAttr(d,`fill`,n.color),e.setText(m,n.label))}let g={},_=e.bindings.find(e=>e.type===`state`),v=e.bindings.find(e=>e.type===`blink`),y=!1;if(_){let t=new P(_.map,e.transitions,Du,Ou),n={kind:`state`,write(e,n){let i=t.resolve(n,_.tag);h(e,i.state),i.state===`blink-fast`?(p.setPlaybackRate(1),p.resume(),y=!0):i.state===`blink-slow`?(p.setPlaybackRate(r.slowBlinkHz/r.fastBlinkHz),p.resume(),y=!0):(p.pause(),y=!1)}};g[_.tag]=n}if(v){let e=(r.fastBlinkHz+r.slowBlinkHz)/2,t={kind:`numeric`,write(t,n){if(typeof n!=`number`)return;let i=vn(v,n);h(t,i<=0?`off`:i<e?`blink-slow`:`blink-fast`),i<=0?(p.pause(),y=!1):(p.setPlaybackRate(i/r.fastBlinkHz),p.resume(),y=!0)}};g[v.tag]=t}let b={kind:`animation`,pause(){p.pause()},resume(){y&&p.resume()},seek(e){p.seek(e)}};return g[`__indicator-lamp-animation-${e.id}`]=b,{svg:i,handles:g}}var Au=Object.freeze({group:`instruments`,primitives:Object.freeze({"indicator-lamp":{build:ku}})});function ju(e,t,n){let r=Ao(e,t,{faceColor:n.faceColor,highlightColor:n.bevelHighlightColor,shadowColor:n.bevelShadowColor},`recessed`);return r.setAttribute(`class`,`vscada-instrument-face`),r}var Mu=`http://www.w3.org/2000/svg`;function Nu(e,t,n){let r=t.tokens.gaugeDigital,i=document.createElementNS(Mu,`g`);if(i.setAttribute(`data-element-id`,e.id),i.setAttribute(`class`,`vscada-gauge-digital`),!r)return{svg:i,handles:{}};let a=e.bindings.find(e=>e.type===`readout`);if(!a)return{svg:i,handles:{}};let{w:o,h:s}=e;i.appendChild(ju(o,s,r.face));let c=document.createElementNS(Mu,`text`);if(c.setAttribute(`class`,`vscada-gauge-digital-value`),c.setAttribute(`x`,String(o/2)),c.setAttribute(`y`,String(s/2)),c.setAttribute(`text-anchor`,`middle`),c.setAttribute(`dominant-baseline`,`central`),c.setAttribute(`font-family`,`monospace`),c.setAttribute(`font-size`,String(Math.min(o,s)*.32)),c.setAttribute(`fill`,r.digitColor),i.appendChild(c),e.label){let t=document.createElementNS(Mu,`text`);t.setAttribute(`class`,`vscada-gauge-digital-label`),t.setAttribute(`x`,String(o/2)),t.setAttribute(`y`,String(s+12)),t.setAttribute(`text-anchor`,`middle`),t.setAttribute(`font-size`,`9`),t.setAttribute(`fill`,r.labelColor),t.textContent=e.label,i.appendChild(t)}return{svg:i,handles:{[a.tag]:{kind:`text`,write(e,t){e.setText(c,Co(t,{unit:a.unit,displayUnit:a.displayUnit,decimals:a.decimals}))}}}}}var Pu=Object.freeze({group:`instruments`,primitives:Object.freeze({"gauge-digital":{build:Nu}})}),Fu=`http://www.w3.org/2000/svg`;function Iu(e,t,n){let r=t.tokens.readoutPanel,i=document.createElementNS(Fu,`g`);if(i.setAttribute(`data-element-id`,e.id),i.setAttribute(`class`,`vscada-readout-panel`),!r)return{svg:i,handles:{}};let a=e.bindings.filter(e=>e.type===`readout`);if(a.length===0)return{svg:i,handles:{}};let{w:o,h:s}=e;i.appendChild(ju(o,s,r.face));let c=s/a.length,l={};return a.forEach((e,t)=>{let n=c*(t+.5),a=document.createElementNS(Fu,`text`);a.setAttribute(`class`,`vscada-readout-panel-label`),a.setAttribute(`x`,`6`),a.setAttribute(`y`,String(n)),a.setAttribute(`dominant-baseline`,`central`),a.setAttribute(`font-size`,`8`),a.setAttribute(`fill`,r.labelColor),a.textContent=e.tag,i.appendChild(a);let s=document.createElementNS(Fu,`text`);s.setAttribute(`class`,`vscada-readout-panel-value`),s.setAttribute(`x`,String(o-6)),s.setAttribute(`y`,String(n)),s.setAttribute(`text-anchor`,`end`),s.setAttribute(`dominant-baseline`,`central`),s.setAttribute(`font-size`,`9`),s.setAttribute(`fill`,r.valueColor),i.appendChild(s);let u;l[e.tag]={kind:`text`,write(t,n){let r=Co(n,{unit:e.unit,displayUnit:e.displayUnit,decimals:e.decimals});r!==u&&(u=r,t.setText(s,r))}}}),{svg:i,handles:l}}var Lu=Object.freeze({group:`instruments`,primitives:Object.freeze({"readout-panel":{build:Iu}})}),Ru=`http://www.w3.org/2000/svg`;function zu(e,t,n){let r=t.tokens.bargraph,i=document.createElementNS(Ru,`g`);if(i.setAttribute(`data-element-id`,e.id),i.setAttribute(`class`,`vscada-bargraph`),!r)return{svg:i,handles:{}};let a=e.bindings.find(e=>e.type===`level`);if(!a)return{svg:i,handles:{}};let{w:o,h:s}=e;i.appendChild(ju(o,s,r.face));let c=document.createElementNS(Ru,`rect`);c.setAttribute(`class`,`vscada-bargraph-track`),c.setAttribute(`x`,`0`),c.setAttribute(`y`,`0`),c.setAttribute(`width`,String(o)),c.setAttribute(`height`,String(s)),c.setAttribute(`fill`,r.trackColor),i.appendChild(c);let l=document.createElementNS(Ru,`rect`);l.setAttribute(`class`,`vscada-bargraph-fill`),l.setAttribute(`x`,`0`),l.setAttribute(`width`,String(o)),l.setAttribute(`y`,String(s)),l.setAttribute(`height`,`0`),l.setAttribute(`fill`,r.fillColor),i.appendChild(l);let u=e.thresholds.filter(e=>e.tag===a.tag);for(let e of u){let t=s-hn(a.min,a.max,e.value)*s,n=document.createElementNS(Ru,`line`);n.setAttribute(`class`,`vscada-bargraph-threshold vscada-bargraph-threshold-${e.level}`),n.setAttribute(`x1`,`0`),n.setAttribute(`x2`,String(o)),n.setAttribute(`y1`,String(t)),n.setAttribute(`y2`,String(t)),n.setAttribute(`stroke`,r.thresholdTickColor),n.setAttribute(`stroke-width`,String(r.strokeWidth??1.5)),i.appendChild(n)}return{svg:i,handles:{[a.tag]:{kind:`numeric`,write(e,t){if(typeof t!=`number`)return;let n=gn(a,t)*s;e.setAttr(l,`height`,String(n)),e.setAttr(l,`y`,String(s-n))}}}}}var Bu=Object.freeze({group:`instruments`,primitives:Object.freeze({bargraph:{build:zu}})}),Vu=`http://www.w3.org/2000/svg`,Hu=2/3;function Uu(e,t,n){let r=t.tokens.trendMini,i=document.createElementNS(Vu,`g`);if(i.setAttribute(`data-element-id`,e.id),i.setAttribute(`class`,`vscada-trend-mini`),!r)return{svg:i,handles:{}};let a=e.bindings.find(e=>e.type===`readout`);if(!a)return{svg:i,handles:{}};let{w:o,h:s}=e;i.appendChild(ju(o,s,r.face));let c=document.createElementNS(Vu,`line`);c.setAttribute(`class`,`vscada-trend-mini-axis`),c.setAttribute(`x1`,`0`),c.setAttribute(`x2`,String(o)),c.setAttribute(`y1`,String(s/2)),c.setAttribute(`y2`,String(s/2)),c.setAttribute(`stroke`,r.axisColor),c.setAttribute(`stroke-width`,String((r.strokeWidth??1.5)*Hu)),i.appendChild(c);let l=document.createElementNS(Vu,`path`);l.setAttribute(`class`,`vscada-trend-mini-line`),l.setAttribute(`fill`,`none`),l.setAttribute(`stroke`,r.lineColor),l.setAttribute(`stroke-width`,String(r.strokeWidth??1.5)),i.appendChild(l);let u=r.pointCount,d=[];function f(e){if(d.length<2){e.setAttr(l,`d`,``);return}let t=Math.min(...d),n=Math.max(...d)-t||1,r=o/(u-1),i=d.map((e,i)=>`${i*r},${s-(e-t)/n*s}`);e.setAttr(l,`d`,`M ${i.join(` L `)}`)}return{svg:i,handles:{[a.tag]:{kind:`numeric`,write(e,t){typeof t==`number`&&(d.push(t),d.length>u&&d.shift(),f(e))}}}}}var Wu=Object.freeze({group:`instruments`,primitives:Object.freeze({"trend-mini":{build:Uu}})}),Gu=Object.freeze({group:`instruments`,primitives:Object.freeze({...Tu.primitives,...Au.primitives,...Pu.primitives,...Lu.primitives,...Bu.primitives,...Wu.primitives})}),Ku=`http://www.w3.org/2000/svg`;function qu(e,t,n){let r=document.createElementNS(Ku,`g`);r.setAttribute(`data-element-id`,e.id);let i=document.createElementNS(Ku,`text`);i.setAttribute(`x`,`0`),i.setAttribute(`y`,`0`),r.appendChild(i);let a={};for(let t of e.bindings){if(t.type!==`readout`)continue;let e;a[t.tag]={kind:`text`,write(n,r){let a=Ju(r,t.decimals,t.unit);a!==e&&(e=a,n.setText(i,a))}}}return{svg:r,handles:a}}function Ju(e,t,n){return typeof e==`number`?`${e.toFixed(t)} ${n}`:String(e)}var Yu=Object.freeze({group:`readout`,primitives:Object.freeze({readout:{build:qu}})}),Xu=`http://www.w3.org/2000/svg`,Zu=1e3,Qu=800,$u=4,ed=`running`,td=Ps(ed,{duration:1800,easing:`ease-out`},{duration:3500,easing:`ease-in`});function nd(e,t,n){let r=t.tokens.pump,i=document.createElementNS(Xu,`g`);if(i.setAttribute(`data-element-id`,e.id),i.setAttribute(`class`,`vscada-pump`),!r)return{svg:i,handles:{}};let{w:a,h:o}=e,s=document.createElementNS(Xu,`rect`);s.setAttribute(`width`,String(a)),s.setAttribute(`height`,String(o)),s.setAttribute(`fill`,r.bodyDeenergizedColor),i.appendChild(s);let c=document.createElementNS(Xu,`g`);c.setAttribute(`class`,`vscada-pump-impeller`),c.style.transformOrigin=`${a/2}px ${o/2}px`;for(let e=0;e<3;e++){let t=document.createElementNS(Xu,`rect`);t.setAttribute(`x`,String(a/2-2)),t.setAttribute(`y`,String(o*.1)),t.setAttribute(`width`,`4`),t.setAttribute(`height`,String(o*.4)),t.setAttribute(`fill`,r.impellerColor),t.setAttribute(`transform`,`rotate(${e*120} ${a/2} ${o/2})`),c.appendChild(t)}i.appendChild(c);let l=n.animateTransform(c,[`rotate(0deg)`,`rotate(360deg)`],Zu),u=a*.85,d=o*.12,f=document.createElementNS(Xu,`circle`);f.setAttribute(`class`,`vscada-pump-lamp`),f.setAttribute(`cx`,String(u)),f.setAttribute(`cy`,String(d)),f.setAttribute(`r`,`6`),f.style.transformOrigin=`${u}px ${d}px`,i.appendChild(f);let p=n.animateTransform(f,[`scale(1)`,`scale(0.35)`,`scale(1)`],Qu);p.pause();let m=document.createElementNS(Xu,`text`);return m.setAttribute(`class`,`vscada-pump-label`),m.setAttribute(`x`,`0`),m.setAttribute(`y`,String(o+14)),m.setAttribute(`font-size`,`10`),i.appendChild(m),{svg:i,handles:Ls({element:e,renderer:n,tokens:r,runningState:ed,defaultTransition:td,visuals:{body:s,lamp:f,label:m},rotationControls:[l],blinkControl:p,maxRate:$u}).handles}}var rd=Object.freeze({group:`rotating`,primitives:Object.freeze({"pump-centrifugal":{build:nd}})}),id=`http://www.w3.org/2000/svg`,ad=1600,od=800,sd=4,cd=`running`,ld=Ps(cd,{duration:1800,easing:`ease-out`},{duration:3500,easing:`ease-in`});function ud(e,t,n,r){let i=document.createElementNS(id,`g`);i.style.transformOrigin=`${e}px ${t}px`;for(let a=0;a<2;a++){let o=document.createElementNS(id,`rect`);o.setAttribute(`x`,String(e-n)),o.setAttribute(`y`,String(t-n*.35)),o.setAttribute(`width`,String(n*2)),o.setAttribute(`height`,String(n*.7)),o.setAttribute(`rx`,String(n*.35)),o.setAttribute(`fill`,r),o.setAttribute(`transform`,`rotate(${a*90} ${e} ${t})`),i.appendChild(o)}return i}function dd(e,t,n){let r=t.tokens.drivenEquipment,i=document.createElementNS(id,`g`);if(i.setAttribute(`data-element-id`,e.id),i.setAttribute(`class`,`vscada-pump-pd`),!r)return{svg:i,handles:{}};let{w:a,h:o}=e,s=document.createElementNS(id,`rect`);s.setAttribute(`width`,String(a)),s.setAttribute(`height`,String(o)),s.setAttribute(`fill`,r.bodyDeenergizedColor),i.appendChild(s);let c=Math.min(a,o)*.16,l=ud(a*.35,o*.55,c,r.rotorColor),u=ud(a*.65,o*.55,c,r.rotorColor);i.appendChild(l),i.appendChild(u);let d=n.animateTransform(l,[`rotate(0deg)`,`rotate(360deg)`],ad),f=n.animateTransform(u,[`rotate(90deg)`,`rotate(450deg)`],ad),p=a*.85,m=o*.12,h=document.createElementNS(id,`circle`);h.setAttribute(`class`,`vscada-pump-pd-lamp`),h.setAttribute(`cx`,String(p)),h.setAttribute(`cy`,String(m)),h.setAttribute(`r`,`6`),h.style.transformOrigin=`${p}px ${m}px`,i.appendChild(h);let g=n.animateTransform(h,[`scale(1)`,`scale(0.35)`,`scale(1)`],od);g.pause();let _=document.createElementNS(id,`text`);return _.setAttribute(`class`,`vscada-pump-pd-label`),_.setAttribute(`x`,`0`),_.setAttribute(`y`,String(o+14)),_.setAttribute(`font-size`,`10`),i.appendChild(_),{svg:i,handles:Ls({element:e,renderer:n,tokens:r,runningState:cd,defaultTransition:ld,visuals:{body:s,lamp:h,label:_},rotationControls:[d,f],blinkControl:g,maxRate:sd}).handles}}var fd=Object.freeze({group:`rotating`,primitives:Object.freeze({"pump-positive-displacement":{build:dd}})}),q=`http://www.w3.org/2000/svg`,pd=700,md=800,hd=4,gd=`running`,_d=.05,vd=Ps(gd,{duration:1800,easing:`ease-out`},{duration:3500,easing:`ease-in`});function yd(e,t,n,r,i){let a=document.createElementNS(q,`g`);a.style.transformOrigin=`${e}px ${t}px`;let o=document.createElementNS(q,`circle`);o.setAttribute(`cx`,String(e)),o.setAttribute(`cy`,String(t)),o.setAttribute(`r`,String(n)),o.setAttribute(`fill`,i),a.appendChild(o);let s=n*1.1,c=n*.5;for(let o=0;o<4;o++){let l=document.createElementNS(q,`polygon`),u=[[e-s/2,t-n],[e+s/2,t-n],[e+c/2,t-n-r],[e-c/2,t-n-r]].map(e=>e.join(`,`)).join(` `);l.setAttribute(`points`,u),l.setAttribute(`fill`,i),l.setAttribute(`transform`,`rotate(${o*90} ${e} ${t})`),a.appendChild(l)}return a}function bd(e,t,n,r,i,a){let o=document.createElementNS(q,`g`);o.style.transformOrigin=`${e}px ${t}px`;let s=document.createElementNS(q,`circle`);s.setAttribute(`cx`,String(e)),s.setAttribute(`cy`,String(t)),s.setAttribute(`r`,String(n)),s.setAttribute(`fill`,r),s.setAttribute(`opacity`,String(i)),o.appendChild(s);let c=document.createElementNS(q,`g`);c.style.transformOrigin=`${e}px ${t}px`;let l=document.createElementNS(q,`line`);return l.setAttribute(`x1`,String(e)),l.setAttribute(`y1`,String(t-n*.15)),l.setAttribute(`x2`,String(e)),l.setAttribute(`y2`,String(t-n*.95)),l.setAttribute(`stroke`,r),l.setAttribute(`stroke-width`,String(a)),l.setAttribute(`opacity`,String(Math.min(i*1.5,1))),c.appendChild(l),o.appendChild(c),{group:o,streak:c}}function xd(e,t,n){let r=t.tokens.fan,i=document.createElementNS(q,`g`);if(i.setAttribute(`data-element-id`,e.id),i.setAttribute(`class`,`vscada-fan-axial`),!r)return{svg:i,handles:{}};let{w:a,h:o}=e,s=a/2,c=o/2,l=Math.min(a,o)*.4,u=document.createElementNS(q,`rect`);u.setAttribute(`width`,String(a)),u.setAttribute(`height`,String(o)),u.setAttribute(`fill`,r.bodyDeenergizedColor),i.appendChild(u);let d=yd(s,c,l*.22,l*.85,r.bladeColor);d.setAttribute(`class`,`vscada-fan-axial-blades`),i.appendChild(d);let f=n.animateTransform(d,[`rotate(0deg)`,`rotate(360deg)`],pd),{group:p,streak:m}=bd(s,c,l,r.blurredDiscColor,r.blurredDiscOpacity,r.strokeWidth??2);p.setAttribute(`class`,`vscada-fan-axial-blur`),i.appendChild(p);let h=n.animateTransform(m,[`rotate(0deg)`,`rotate(360deg)`],pd);n.setAttr(d,`opacity`,`1`),n.setAttr(p,`opacity`,`0`);let g=a*.85,_=o*.12,v=document.createElementNS(q,`circle`);v.setAttribute(`class`,`vscada-fan-axial-lamp`),v.setAttribute(`cx`,String(g)),v.setAttribute(`cy`,String(_)),v.setAttribute(`r`,`6`),v.style.transformOrigin=`${g}px ${_}px`,i.appendChild(v);let y=n.animateTransform(v,[`scale(1)`,`scale(0.35)`,`scale(1)`],md);y.pause();let b=document.createElementNS(q,`text`);b.setAttribute(`class`,`vscada-fan-axial-label`),b.setAttribute(`x`,`0`),b.setAttribute(`y`,String(o+14)),b.setAttribute(`font-size`,`10`),i.appendChild(b);let x=new Fs(r.blurThresholdRpm,_d),S=!1;return{svg:i,handles:Ls({element:e,renderer:n,tokens:r,runningState:gd,defaultTransition:vd,visuals:{body:u,lamp:v,label:b},rotationControls:[f,h],blinkControl:y,maxRate:hd,onSpeedRawValue(e){let t=x.update(e);t!==S&&(S=t,n.setAttr(d,`opacity`,t?`0`:`1`),n.setAttr(p,`opacity`,t?`1`:`0`))}}).handles}}var Sd=Object.freeze({group:`rotating`,primitives:Object.freeze({"fan-axial":{build:xd}})}),J=`http://www.w3.org/2000/svg`,Cd=900,wd=800,Td=4,Ed=`running`,Dd=.05,Od=Ps(Ed,{duration:1800,easing:`ease-out`},{duration:3500,easing:`ease-in`});function kd(e,t,n,r,i){let a=document.createElementNS(J,`g`);a.style.transformOrigin=`${e}px ${t}px`;let o=document.createElementNS(J,`circle`);o.setAttribute(`cx`,String(e)),o.setAttribute(`cy`,String(t)),o.setAttribute(`r`,String(n*.55)),o.setAttribute(`fill`,`none`),o.setAttribute(`stroke`,i),o.setAttribute(`stroke-width`,String(n*.08)),a.appendChild(o);let s=n*.4,c=n*.12;for(let o=0;o<r;o++){let l=360/r*o,u=document.createElementNS(J,`rect`);u.setAttribute(`x`,String(e-c/2)),u.setAttribute(`y`,String(t-n)),u.setAttribute(`width`,String(c)),u.setAttribute(`height`,String(s)),u.setAttribute(`fill`,i),u.setAttribute(`transform`,`rotate(${l+12} ${e} ${t})`),a.appendChild(u)}return a}function Ad(e,t,n,r,i,a){let o=document.createElementNS(J,`g`);o.style.transformOrigin=`${e}px ${t}px`;let s=document.createElementNS(J,`circle`);s.setAttribute(`cx`,String(e)),s.setAttribute(`cy`,String(t)),s.setAttribute(`r`,String(n)),s.setAttribute(`fill`,r),s.setAttribute(`opacity`,String(i)),o.appendChild(s);let c=document.createElementNS(J,`g`);c.style.transformOrigin=`${e}px ${t}px`;let l=document.createElementNS(J,`line`);return l.setAttribute(`x1`,String(e)),l.setAttribute(`y1`,String(t-n*.15)),l.setAttribute(`x2`,String(e)),l.setAttribute(`y2`,String(t-n*.95)),l.setAttribute(`stroke`,r),l.setAttribute(`stroke-width`,String(a)),l.setAttribute(`opacity`,String(Math.min(i*1.5,1))),c.appendChild(l),o.appendChild(c),{group:o,streak:c}}function jd(e,t,n){let r=t.tokens.fan,i=document.createElementNS(J,`g`);if(i.setAttribute(`data-element-id`,e.id),i.setAttribute(`class`,`vscada-fan-centrifugal`),!r)return{svg:i,handles:{}};let{w:a,h:o}=e,s=a/2,c=o/2,l=Math.min(a,o)*.4,u=document.createElementNS(J,`rect`);u.setAttribute(`width`,String(a)),u.setAttribute(`height`,String(o)),u.setAttribute(`fill`,r.bodyDeenergizedColor),i.appendChild(u);let d=kd(s,c,l,8,r.bladeColor);d.setAttribute(`class`,`vscada-fan-centrifugal-blades`),i.appendChild(d);let f=n.animateTransform(d,[`rotate(0deg)`,`rotate(360deg)`],Cd),{group:p,streak:m}=Ad(s,c,l,r.blurredDiscColor,r.blurredDiscOpacity,r.strokeWidth??2);p.setAttribute(`class`,`vscada-fan-centrifugal-blur`),i.appendChild(p);let h=n.animateTransform(m,[`rotate(0deg)`,`rotate(360deg)`],Cd);n.setAttr(d,`opacity`,`1`),n.setAttr(p,`opacity`,`0`);let g=a*.85,_=o*.12,v=document.createElementNS(J,`circle`);v.setAttribute(`class`,`vscada-fan-centrifugal-lamp`),v.setAttribute(`cx`,String(g)),v.setAttribute(`cy`,String(_)),v.setAttribute(`r`,`6`),v.style.transformOrigin=`${g}px ${_}px`,i.appendChild(v);let y=n.animateTransform(v,[`scale(1)`,`scale(0.35)`,`scale(1)`],wd);y.pause();let b=document.createElementNS(J,`text`);b.setAttribute(`class`,`vscada-fan-centrifugal-label`),b.setAttribute(`x`,`0`),b.setAttribute(`y`,String(o+14)),b.setAttribute(`font-size`,`10`),i.appendChild(b);let x=new Fs(r.blurThresholdRpm,Dd),S=!1;return{svg:i,handles:Ls({element:e,renderer:n,tokens:r,runningState:Ed,defaultTransition:Od,visuals:{body:u,lamp:v,label:b},rotationControls:[f,h],blinkControl:y,maxRate:Td,onSpeedRawValue(e){let t=x.update(e);t!==S&&(S=t,n.setAttr(d,`opacity`,t?`0`:`1`),n.setAttr(p,`opacity`,t?`1`:`0`))}}).handles}}var Md=Object.freeze({group:`rotating`,primitives:Object.freeze({"fan-centrifugal":{build:jd}})}),Nd=`http://www.w3.org/2000/svg`,Pd=600,Fd=800,Id=4,Ld=`running`,Rd=Ps(Ld,{duration:1800,easing:`ease-out`},{duration:3500,easing:`ease-in`});function zd(e,t,n,r){let i=document.createElementNS(Nd,`g`);i.style.transformOrigin=`${e}px ${t}px`;let a=document.createElementNS(Nd,`circle`);a.setAttribute(`cx`,String(e)),a.setAttribute(`cy`,String(t)),a.setAttribute(`r`,String(n*.3)),a.setAttribute(`fill`,r),i.appendChild(a);for(let a=0;a<4;a++){let o=document.createElementNS(Nd,`rect`);o.setAttribute(`x`,String(e-n*.1)),o.setAttribute(`y`,String(t-n)),o.setAttribute(`width`,String(n*.2)),o.setAttribute(`height`,String(n)),o.setAttribute(`fill`,r),o.setAttribute(`transform`,`rotate(${a*90} ${e} ${t})`),i.appendChild(o)}return i}function Bd(e,t,n){let r=t.tokens.drivenEquipment,i=document.createElementNS(Nd,`g`);if(i.setAttribute(`data-element-id`,e.id),i.setAttribute(`class`,`vscada-compressor`),!r)return{svg:i,handles:{}};let{w:a,h:o}=e,s=document.createElementNS(Nd,`rect`);s.setAttribute(`width`,String(a)),s.setAttribute(`height`,String(o)),s.setAttribute(`fill`,r.bodyDeenergizedColor),i.appendChild(s);let c=document.createElementNS(Nd,`rect`),l=Math.min(a,o)*.12;c.setAttribute(`x`,String(l)),c.setAttribute(`y`,String(l)),c.setAttribute(`width`,String(a-l*2)),c.setAttribute(`height`,String(o-l*2)),c.setAttribute(`fill`,`none`),c.setAttribute(`stroke`,r.rotorColor),c.setAttribute(`stroke-width`,String(r.strokeWidth??1)),c.setAttribute(`opacity`,`0.5`),i.appendChild(c);let u=zd(a/2,o/2,Math.min(a,o)*.22,r.rotorColor);i.appendChild(u);let d=n.animateTransform(u,[`rotate(0deg)`,`rotate(360deg)`],Pd),f=a*.85,p=o*.12,m=document.createElementNS(Nd,`circle`);m.setAttribute(`class`,`vscada-compressor-lamp`),m.setAttribute(`cx`,String(f)),m.setAttribute(`cy`,String(p)),m.setAttribute(`r`,`6`),m.style.transformOrigin=`${f}px ${p}px`,i.appendChild(m);let h=n.animateTransform(m,[`scale(1)`,`scale(0.35)`,`scale(1)`],Fd);h.pause();let g=document.createElementNS(Nd,`text`);return g.setAttribute(`class`,`vscada-compressor-label`),g.setAttribute(`x`,`0`),g.setAttribute(`y`,String(o+14)),g.setAttribute(`font-size`,`10`),i.appendChild(g),{svg:i,handles:Ls({element:e,renderer:n,tokens:r,runningState:Ld,defaultTransition:Rd,visuals:{body:s,lamp:m,label:g},rotationControls:[d],blinkControl:h,maxRate:Id}).handles}}var Vd=Object.freeze({group:`rotating`,primitives:Object.freeze({compressor:{build:Bd}})}),Hd=`http://www.w3.org/2000/svg`,Ud=500,Wd=800,Gd=4,Kd=`running`,qd=Ps(Kd,{duration:1800,easing:`ease-out`},{duration:3500,easing:`ease-in`});function Jd(e,t){if(typeof e!=`number`)return String(e);let n=e.toFixed(t.decimals);return t.unit.length>0?`${n} ${t.unit}`:n}function Yd(e,t,n,r){let i=document.createElementNS(Hd,`g`);i.style.transformOrigin=`${e}px ${t}px`;let a=document.createElementNS(Hd,`circle`);a.setAttribute(`cx`,String(e)),a.setAttribute(`cy`,String(t)),a.setAttribute(`r`,String(n*.3)),a.setAttribute(`fill`,r),i.appendChild(a);for(let a=0;a<4;a++){let o=document.createElementNS(Hd,`rect`);o.setAttribute(`x`,String(e-n*.1)),o.setAttribute(`y`,String(t-n)),o.setAttribute(`width`,String(n*.2)),o.setAttribute(`height`,String(n)),o.setAttribute(`fill`,r),o.setAttribute(`transform`,`rotate(${a*90} ${e} ${t})`),i.appendChild(o)}return i}function Xd(e,t,n){let r=t.tokens.drivenEquipment,i=document.createElementNS(Hd,`g`);if(i.setAttribute(`data-element-id`,e.id),i.setAttribute(`class`,`vscada-turbine`),!r)return{svg:i,handles:{}};let{w:a,h:o}=e,s=document.createElementNS(Hd,`rect`);s.setAttribute(`width`,String(a)),s.setAttribute(`height`,String(o)),s.setAttribute(`fill`,r.bodyDeenergizedColor),i.appendChild(s);let c=Math.min(a,o)*.12,l=document.createElementNS(Hd,`rect`);l.setAttribute(`x`,String(c)),l.setAttribute(`y`,String(c)),l.setAttribute(`width`,String(a-c*2)),l.setAttribute(`height`,String(o-c*2)),l.setAttribute(`fill`,`none`),l.setAttribute(`stroke`,r.rotorColor),l.setAttribute(`stroke-width`,String(r.strokeWidth??1)),l.setAttribute(`opacity`,`0.5`),i.appendChild(l);let u=Yd(a/2,o/2,Math.min(a,o)*.22,r.rotorColor);i.appendChild(u);let d=n.animateTransform(u,[`rotate(0deg)`,`rotate(360deg)`],Ud),f=a*.85,p=o*.12,m=document.createElementNS(Hd,`circle`);m.setAttribute(`class`,`vscada-turbine-lamp`),m.setAttribute(`cx`,String(f)),m.setAttribute(`cy`,String(p)),m.setAttribute(`r`,`6`),m.style.transformOrigin=`${f}px ${p}px`,i.appendChild(m);let h=n.animateTransform(m,[`scale(1)`,`scale(0.35)`,`scale(1)`],Wd);h.pause();let g=document.createElementNS(Hd,`text`);g.setAttribute(`class`,`vscada-turbine-label`),g.setAttribute(`x`,`0`),g.setAttribute(`y`,String(o+14)),g.setAttribute(`font-size`,`10`),i.appendChild(g);let _={...Ls({element:e,renderer:n,tokens:r,runningState:Kd,defaultTransition:qd,visuals:{body:s,lamp:m,label:g},rotationControls:[d],blinkControl:h,maxRate:Gd}).handles};return e.bindings.filter(e=>e.type===`readout`).forEach((e,t)=>{let r=document.createElementNS(Hd,`text`);r.setAttribute(`class`,`vscada-turbine-readout`),r.setAttribute(`data-tag`,e.tag),r.setAttribute(`x`,`0`),r.setAttribute(`y`,String(o+28+t*14)),r.setAttribute(`font-size`,`10`),i.appendChild(r);let a=t=>{n.setText(r,Jd(t,e))},s=_[e.tag];if(s&&(s.kind===`numeric`||s.kind===`text`||s.kind===`state`)){let t=s.write.bind(s);_[e.tag]={kind:s.kind,write(e,n,r){t(e,n,r),a(n)}}}else{let t={kind:`text`,write:(e,t)=>a(t)};_[e.tag]=t}}),{svg:i,handles:_}}var Zd=Object.freeze({group:`rotating`,primitives:Object.freeze({turbine:{build:Xd}})}),Qd=`http://www.w3.org/2000/svg`,$d=500,ef=800,tf=4,nf=`running`,rf=Ps(nf,{duration:1800,easing:`ease-out`},{duration:3500,easing:`ease-in`});function af(e,t,n,r){let i=document.createElementNS(Qd,`g`);i.style.transformOrigin=`${e}px ${t}px`;let a=document.createElementNS(Qd,`circle`);a.setAttribute(`cx`,String(e)),a.setAttribute(`cy`,String(t)),a.setAttribute(`r`,String(n*.25)),a.setAttribute(`fill`,r),i.appendChild(a);for(let a=0;a<3;a++){let o=document.createElementNS(Qd,`polygon`),s=[[e-n*.12,t],[e+n*.12,t],[e+n*.05,t-n],[e-n*.05,t-n]].map(e=>e.join(`,`)).join(` `);o.setAttribute(`points`,s),o.setAttribute(`fill`,r),o.setAttribute(`transform`,`rotate(${a*120} ${e} ${t})`),i.appendChild(o)}return i}function of(e,t,n){let r=t.tokens.drivenEquipment,i=document.createElementNS(Qd,`g`);if(i.setAttribute(`data-element-id`,e.id),i.setAttribute(`class`,`vscada-motor`),!r)return{svg:i,handles:{}};let{w:a,h:o}=e,s=a*.65,c=document.createElementNS(Qd,`rect`);c.setAttribute(`width`,String(s)),c.setAttribute(`height`,String(o)),c.setAttribute(`fill`,r.bodyDeenergizedColor),i.appendChild(c);let l=document.createElementNS(Qd,`line`);l.setAttribute(`class`,`vscada-motor-shaft`),l.setAttribute(`x1`,String(s)),l.setAttribute(`y1`,String(o/2)),l.setAttribute(`x2`,String(a*.82)),l.setAttribute(`y2`,String(o/2)),l.setAttribute(`stroke`,r.rotorColor),l.setAttribute(`stroke-width`,String(Math.max(o*.06,r.strokeWidth??1))),i.appendChild(l);let u=af(a*.15,o/2,Math.min(s,o)*.3,r.rotorColor);u.setAttribute(`class`,`vscada-motor-cowl-fan`),i.appendChild(u);let d=n.animateTransform(u,[`rotate(0deg)`,`rotate(360deg)`],$d),f=s*.85,p=o*.14,m=document.createElementNS(Qd,`circle`);m.setAttribute(`class`,`vscada-motor-lamp`),m.setAttribute(`cx`,String(f)),m.setAttribute(`cy`,String(p)),m.setAttribute(`r`,`6`),m.style.transformOrigin=`${f}px ${p}px`,i.appendChild(m);let h=n.animateTransform(m,[`scale(1)`,`scale(0.35)`,`scale(1)`],ef);h.pause();let g=document.createElementNS(Qd,`text`);return g.setAttribute(`class`,`vscada-motor-label`),g.setAttribute(`x`,`0`),g.setAttribute(`y`,String(o+14)),g.setAttribute(`font-size`,`10`),i.appendChild(g),{svg:i,handles:Ls({element:e,renderer:n,tokens:r,runningState:nf,defaultTransition:rf,visuals:{body:c,lamp:m,label:g},rotationControls:[d],blinkControl:h,maxRate:tf}).handles}}var sf=Object.freeze({group:`rotating`,primitives:Object.freeze({motor:{build:of}})}),cf=Object.freeze({group:`rotating`,primitives:Object.freeze({...rd.primitives,...fd.primitives,...Sd.primitives,...Md.primitives,...Vd.primitives,...Zd.primitives,...sf.primitives})}),lf=1,uf=`linear`;function df(e){return Math.min(Math.max(e,0),1)}function ff(e){let{element:t,renderer:n,tokens:r,visuals:i,arrowControl:a,arrowVisual:o,onFraction:s,onWarning:c}=e,l=t.bindings.find(e=>e.type===`position`),u=t.bindings.find(e=>e.type===`state`),d={},f=new dr(0),p,m,h=!1,g;function _(e){let t=r.states[e];t&&(n.setAttr(i.indicator,`fill`,t.indicatorColor),n.setText(i.label,t.label),n.setAttr(o,`opacity`,t.blink?`1`:`0`),t.blink?a.resume():a.pause())}function v(e,t){t!==g&&(g=t,e.setTransform(i.fill,`scaleX(${t})`),s(e,t))}function y(e,t){f.retarget(e,t,lf,uf),f.snap(e)}if(l){let e=l.max-l.min,n={kind:`numeric`,write(n,i,a){if(typeof i!=`number`)return;let o=e===0?0:df((i-l.min)/e);if(!h){h=!0,y(a,o),m=o,v(n,o),u||(p=o<=0?`closed`:o>=1?`open`:`opening`,_(p));return}if(o===m)return;let s=m===void 0||o>m;m=o;let c=t.transitions[`closed→open`],d=t.transitions[`open→closed`],g=(s?c:d)??{duration:r.defaultStrokeMs,easing:uf};f.retarget(a,o,g.duration,g.easing),u||(p=s?`opening`:`closing`,_(p))}};d[l.tag]=n}if(u){let e=new P(u.map,t.transitions,{duration:r.defaultStrokeMs,easing:uf},c),n={kind:`state`,write(t,n,r){let i=e.resolve(n,u.tag),a=i.state,o=p;if(p=a,_(a),l||a===`fault`)return;let s=+(a===`open`||a===`opening`);if(o===void 0){y(r,s),m=s,v(t,s);return}s!==m&&(m=s,f.retarget(r,s,i.transition.duration,i.transition.easing))}};d[u.tag]=n}let b={kind:`tween`,tick(e,t){if(v(e,f.valueAt(t)),!u&&f.isSettled(t)){let e=f.valueAt(t),n=e>=1?`open`:e<=0?`closed`:void 0;n&&n!==p&&(p=n,_(n))}},snap(e,t){f.snap(t),v(e,f.valueAt(t))}};d[`__valve-tween-${t.id}`]=b;let x={kind:`animation`,pause(){a.pause()},resume(){p&&r.states[p]?.blink&&a.resume()},seek(e){a.seek(e)}};return d[`__valve-animations-${t.id}`]=x,{handles:d,getCurrentState:()=>p}}var Y=`http://www.w3.org/2000/svg`,pf=600;function mf(e,t,n){let r=t.tokens.valve,i=document.createElementNS(Y,`g`);if(i.setAttribute(`data-element-id`,e.id),i.setAttribute(`class`,`vscada-valve-gate`),!r)return{svg:i,handles:{}};let{w:a,h:o}=e,s=j(t.tokens.medium,e.medium)?.color??r.openColor,c=document.createElementNS(Y,`rect`);c.setAttribute(`class`,`vscada-valve-body`),c.setAttribute(`width`,String(a)),c.setAttribute(`height`,String(o)),c.setAttribute(`fill`,`none`),c.setAttribute(`stroke`,r.bodyOutlineColor),c.setAttribute(`stroke-width`,String(r.strokeWidth??2)),i.appendChild(c);let l=document.createElementNS(Y,`rect`);l.setAttribute(`class`,`vscada-valve-fill`),l.setAttribute(`width`,String(a)),l.setAttribute(`height`,String(o)),l.setAttribute(`fill`,s),l.style.transformOrigin=`0px 0px`,i.appendChild(l);let u=a*.3,d=o*.6,f=document.createElementNS(Y,`rect`);f.setAttribute(`class`,`vscada-valve-gate-bonnet`),f.setAttribute(`x`,String(a/2-u/2)),f.setAttribute(`y`,String(-d)),f.setAttribute(`width`,String(u)),f.setAttribute(`height`,String(d)),f.setAttribute(`fill`,`none`),f.setAttribute(`stroke`,r.bodyOutlineColor),f.setAttribute(`stroke-width`,String(r.strokeWidth??2)),i.appendChild(f);let p=a*.24,m=document.createElementNS(Y,`rect`);m.setAttribute(`class`,`vscada-valve-gate-wedge`),m.setAttribute(`x`,String(a/2-p/2)),m.setAttribute(`y`,`0`),m.setAttribute(`width`,String(p)),m.setAttribute(`height`,String(o)),m.setAttribute(`fill`,r.discColor),m.style.transformOrigin=`${a/2}px 0px`,i.appendChild(m);let h=document.createElementNS(Y,`g`);h.setAttribute(`class`,`vscada-valve-arrows`),h.setAttribute(`opacity`,`0`);let g=document.createElementNS(Y,`path`);g.setAttribute(`d`,`M ${a*.1} ${o+10} l -6 -4 l 0 8 z`),g.setAttribute(`fill`,r.arrowColor);let _=document.createElementNS(Y,`path`);_.setAttribute(`d`,`M ${a*.9} ${o+10} l 6 -4 l 0 8 z`),_.setAttribute(`fill`,r.arrowColor),h.appendChild(g),h.appendChild(_),h.style.transformOrigin=`${a/2}px ${o+10}px`,i.appendChild(h);let v=n.animateTransform(h,[`scale(1)`,`scale(1.3)`,`scale(1)`],pf),y=document.createElementNS(Y,`circle`);y.setAttribute(`class`,`vscada-valve-indicator`),y.setAttribute(`cx`,String(a*.5)),y.setAttribute(`cy`,String(-d-10)),y.setAttribute(`r`,`5`),i.appendChild(y);let b=document.createElementNS(Y,`text`);return b.setAttribute(`class`,`vscada-valve-label`),b.setAttribute(`x`,`0`),b.setAttribute(`y`,String(o+22)),b.setAttribute(`font-size`,`9`),b.setAttribute(`fill`,r.arrowColor),i.appendChild(b),{svg:i,handles:ff({element:e,renderer:n,tokens:r,visuals:{fill:l,indicator:y,label:b},arrowControl:v,arrowVisual:h,onFraction(e,t){e.setTransform(m,`translateY(${-t*(o+d)}px)`)}}).handles}}var hf=Object.freeze({group:`valves`,primitives:Object.freeze({"valve-gate":{build:mf}})}),gf=`http://www.w3.org/2000/svg`,_f=600,vf=90;function yf(e,t,n){let r=t.tokens.valve,i=document.createElementNS(gf,`g`);if(i.setAttribute(`data-element-id`,e.id),i.setAttribute(`class`,`vscada-valve-ball`),!r)return{svg:i,handles:{}};let{w:a,h:o}=e,s=j(t.tokens.medium,e.medium)?.color??r.openColor,c=a/2,l=o/2,u=Math.min(a,o)*.45,d=document.createElementNS(gf,`circle`);d.setAttribute(`class`,`vscada-valve-body`),d.setAttribute(`cx`,String(c)),d.setAttribute(`cy`,String(l)),d.setAttribute(`r`,String(u)),d.setAttribute(`fill`,`none`),d.setAttribute(`stroke`,r.bodyOutlineColor),d.setAttribute(`stroke-width`,String(r.strokeWidth??2)),i.appendChild(d);let f=document.createElementNS(gf,`rect`);f.setAttribute(`class`,`vscada-valve-fill`),f.setAttribute(`width`,String(a)),f.setAttribute(`height`,String(o)),f.setAttribute(`fill`,s),f.style.transformOrigin=`0px 0px`,i.appendChild(f);let p=document.createElementNS(gf,`ellipse`);p.setAttribute(`class`,`vscada-valve-ball-bore`),p.setAttribute(`cx`,String(c)),p.setAttribute(`cy`,String(l)),p.setAttribute(`rx`,String(u*.7)),p.setAttribute(`ry`,String(u*.22)),p.setAttribute(`fill`,r.discColor),p.style.transformOrigin=`${c}px ${l}px`,i.appendChild(p);let m=document.createElementNS(gf,`g`);m.setAttribute(`class`,`vscada-valve-arrows`),m.setAttribute(`opacity`,`0`);let h=document.createElementNS(gf,`path`);h.setAttribute(`d`,`M ${a*.1} ${o+10} l -6 -4 l 0 8 z`),h.setAttribute(`fill`,r.arrowColor);let g=document.createElementNS(gf,`path`);g.setAttribute(`d`,`M ${a*.9} ${o+10} l 6 -4 l 0 8 z`),g.setAttribute(`fill`,r.arrowColor),m.appendChild(h),m.appendChild(g),m.style.transformOrigin=`${c}px ${o+10}px`,i.appendChild(m);let _=n.animateTransform(m,[`scale(1)`,`scale(1.3)`,`scale(1)`],_f),v=document.createElementNS(gf,`circle`);v.setAttribute(`class`,`vscada-valve-indicator`),v.setAttribute(`cx`,String(c)),v.setAttribute(`cy`,`-10`),v.setAttribute(`r`,`5`),i.appendChild(v);let y=document.createElementNS(gf,`text`);return y.setAttribute(`class`,`vscada-valve-label`),y.setAttribute(`x`,`0`),y.setAttribute(`y`,String(o+22)),y.setAttribute(`font-size`,`9`),y.setAttribute(`fill`,r.arrowColor),i.appendChild(y),{svg:i,handles:ff({element:e,renderer:n,tokens:r,visuals:{fill:f,indicator:v,label:y},arrowControl:_,arrowVisual:m,onFraction(e,t){let n=(1-t)*vf;e.setTransform(p,`rotate(${n}deg)`)}}).handles}}var bf=Object.freeze({group:`valves`,primitives:Object.freeze({"valve-ball":{build:yf}})}),X=`http://www.w3.org/2000/svg`,xf=600,Sf=.12;function Cf(e,t,n){let r=t.tokens.valve,i=document.createElementNS(X,`g`);if(i.setAttribute(`data-element-id`,e.id),i.setAttribute(`class`,`vscada-valve-butterfly`),!r)return{svg:i,handles:{}};let{w:a,h:o}=e,s=j(t.tokens.medium,e.medium)?.color??r.openColor,c=a/2,l=o/2,u=Math.min(a,o)*.45,d=document.createElementNS(X,`circle`);d.setAttribute(`class`,`vscada-valve-body`),d.setAttribute(`cx`,String(c)),d.setAttribute(`cy`,String(l)),d.setAttribute(`r`,String(u)),d.setAttribute(`fill`,`none`),d.setAttribute(`stroke`,r.bodyOutlineColor),d.setAttribute(`stroke-width`,String(r.strokeWidth??2)),i.appendChild(d);let f=document.createElementNS(X,`rect`);f.setAttribute(`class`,`vscada-valve-fill`),f.setAttribute(`width`,String(a)),f.setAttribute(`height`,String(o)),f.setAttribute(`fill`,s),f.style.transformOrigin=`0px 0px`,i.appendChild(f);let p=document.createElementNS(X,`ellipse`);p.setAttribute(`class`,`vscada-valve-butterfly-disc`),p.setAttribute(`cx`,String(c)),p.setAttribute(`cy`,String(l)),p.setAttribute(`rx`,String(u*.85)),p.setAttribute(`ry`,String(u*.85)),p.setAttribute(`fill`,r.discColor),p.style.transformOrigin=`${c}px ${l}px`,i.appendChild(p);let m=document.createElementNS(X,`line`);m.setAttribute(`class`,`vscada-valve-butterfly-shaft`),m.setAttribute(`x1`,String(c)),m.setAttribute(`x2`,String(c)),m.setAttribute(`y1`,String(l-u)),m.setAttribute(`y2`,String(l+u)),m.setAttribute(`stroke`,r.bodyOutlineColor),m.setAttribute(`stroke-width`,String(r.strokeWidth??2)),i.appendChild(m);let h=document.createElementNS(X,`g`);h.setAttribute(`class`,`vscada-valve-arrows`),h.setAttribute(`opacity`,`0`);let g=document.createElementNS(X,`path`);g.setAttribute(`d`,`M ${a*.1} ${o+10} l -6 -4 l 0 8 z`),g.setAttribute(`fill`,r.arrowColor);let _=document.createElementNS(X,`path`);_.setAttribute(`d`,`M ${a*.9} ${o+10} l 6 -4 l 0 8 z`),_.setAttribute(`fill`,r.arrowColor),h.appendChild(g),h.appendChild(_),h.style.transformOrigin=`${c}px ${o+10}px`,i.appendChild(h);let v=n.animateTransform(h,[`scale(1)`,`scale(1.3)`,`scale(1)`],xf),y=document.createElementNS(X,`circle`);y.setAttribute(`class`,`vscada-valve-indicator`),y.setAttribute(`cx`,String(c)),y.setAttribute(`cy`,`-10`),y.setAttribute(`r`,`5`),i.appendChild(y);let b=document.createElementNS(X,`text`);return b.setAttribute(`class`,`vscada-valve-label`),b.setAttribute(`x`,`0`),b.setAttribute(`y`,String(o+22)),b.setAttribute(`font-size`,`9`),b.setAttribute(`fill`,r.arrowColor),i.appendChild(b),{svg:i,handles:ff({element:e,renderer:n,tokens:r,visuals:{fill:f,indicator:y,label:b},arrowControl:v,arrowVisual:h,onFraction(e,t){let n=1-t*(1-Sf);e.setTransform(p,`scaleX(${n})`)}}).handles}}var wf=Object.freeze({group:`valves`,primitives:Object.freeze({"valve-butterfly":{build:Cf}})}),Z=`http://www.w3.org/2000/svg`,Tf=600;function Ef(e,t,n){let r=t.tokens.valve,i=document.createElementNS(Z,`g`);if(i.setAttribute(`data-element-id`,e.id),i.setAttribute(`class`,`vscada-valve-control`),!r)return{svg:i,handles:{}};let{w:a,h:o}=e,s=j(t.tokens.medium,e.medium)?.color??r.openColor,c=document.createElementNS(Z,`rect`);c.setAttribute(`class`,`vscada-valve-body`),c.setAttribute(`width`,String(a)),c.setAttribute(`height`,String(o)),c.setAttribute(`fill`,`none`),c.setAttribute(`stroke`,r.bodyOutlineColor),c.setAttribute(`stroke-width`,String(r.strokeWidth??2)),i.appendChild(c);let l=document.createElementNS(Z,`rect`);l.setAttribute(`class`,`vscada-valve-fill`),l.setAttribute(`width`,String(a)),l.setAttribute(`height`,String(o)),l.setAttribute(`fill`,s),l.style.transformOrigin=`0px 0px`,i.appendChild(l);let u=a*.3,d=o*.6,f=o*.7,p=document.createElementNS(Z,`rect`);p.setAttribute(`class`,`vscada-valve-control-bonnet`),p.setAttribute(`x`,String(a/2-u/2)),p.setAttribute(`y`,String(-d-f)),p.setAttribute(`width`,String(u)),p.setAttribute(`height`,String(d)),p.setAttribute(`fill`,`none`),p.setAttribute(`stroke`,r.bodyOutlineColor),p.setAttribute(`stroke-width`,String(r.strokeWidth??2)),i.appendChild(p);let m=document.createElementNS(Z,`path`);m.setAttribute(`class`,`vscada-valve-control-actuator`);let h=u*.9,g=-d-f;m.setAttribute(`d`,`M ${a/2-h} ${g} A ${h} ${h} 0 0 1 ${a/2+h} ${g} Z`),m.setAttribute(`fill`,`none`),m.setAttribute(`stroke`,r.bodyOutlineColor),m.setAttribute(`stroke-width`,String(r.strokeWidth??2)),i.appendChild(m);let _=a*.24,v=document.createElementNS(Z,`rect`);v.setAttribute(`class`,`vscada-valve-control-wedge`),v.setAttribute(`x`,String(a/2-_/2)),v.setAttribute(`y`,`0`),v.setAttribute(`width`,String(_)),v.setAttribute(`height`,String(o)),v.setAttribute(`fill`,r.discColor),v.style.transformOrigin=`${a/2}px 0px`,i.appendChild(v);let y=document.createElementNS(Z,`g`);y.setAttribute(`class`,`vscada-valve-arrows`),y.setAttribute(`opacity`,`0`);let b=document.createElementNS(Z,`path`);b.setAttribute(`d`,`M ${a*.1} ${o+10} l -6 -4 l 0 8 z`),b.setAttribute(`fill`,r.arrowColor);let x=document.createElementNS(Z,`path`);x.setAttribute(`d`,`M ${a*.9} ${o+10} l 6 -4 l 0 8 z`),x.setAttribute(`fill`,r.arrowColor),y.appendChild(b),y.appendChild(x),y.style.transformOrigin=`${a/2}px ${o+10}px`,i.appendChild(y);let S=n.animateTransform(y,[`scale(1)`,`scale(1.3)`,`scale(1)`],Tf),C=document.createElementNS(Z,`circle`);C.setAttribute(`class`,`vscada-valve-indicator`),C.setAttribute(`cx`,String(a*.5)),C.setAttribute(`cy`,String(g-10)),C.setAttribute(`r`,`5`),i.appendChild(C);let w=document.createElementNS(Z,`text`);w.setAttribute(`class`,`vscada-valve-label`),w.setAttribute(`x`,`0`),w.setAttribute(`y`,String(o+22)),w.setAttribute(`font-size`,`9`),w.setAttribute(`fill`,r.arrowColor),i.appendChild(w);let T=document.createElementNS(Z,`text`);return T.setAttribute(`class`,`vscada-valve-control-readout`),T.setAttribute(`x`,String(a/2)),T.setAttribute(`y`,String(g-h-6)),T.setAttribute(`font-size`,`9`),T.setAttribute(`text-anchor`,`middle`),T.setAttribute(`fill`,r.arrowColor),i.appendChild(T),{svg:i,handles:ff({element:e,renderer:n,tokens:r,visuals:{fill:l,indicator:C,label:w},arrowControl:S,arrowVisual:y,onFraction(e,t){e.setTransform(v,`translateY(${-t*(o+d)}px)`),e.setText(T,`${Math.round(t*100)}%`)}}).handles}}var Df=Object.freeze({group:`valves`,primitives:Object.freeze({"valve-control":{build:Ef}})}),Q=`http://www.w3.org/2000/svg`,Of=600,kf=90;function Af(e,t,n){let r=t.tokens.valve,i=document.createElementNS(Q,`g`);if(i.setAttribute(`data-element-id`,e.id),i.setAttribute(`class`,`vscada-valve-check`),!r)return{svg:i,handles:{}};let{w:a,h:o}=e,s=j(t.tokens.medium,e.medium)?.color??r.openColor,c=document.createElementNS(Q,`rect`);c.setAttribute(`class`,`vscada-valve-body`),c.setAttribute(`width`,String(a)),c.setAttribute(`height`,String(o)),c.setAttribute(`fill`,`none`),c.setAttribute(`stroke`,r.bodyOutlineColor),c.setAttribute(`stroke-width`,String(r.strokeWidth??2)),i.appendChild(c);let l=document.createElementNS(Q,`rect`);l.setAttribute(`class`,`vscada-valve-fill`),l.setAttribute(`width`,String(a)),l.setAttribute(`height`,String(o)),l.setAttribute(`fill`,s),l.style.transformOrigin=`0px 0px`,i.appendChild(l);let u=document.createElementNS(Q,`path`);u.setAttribute(`class`,`vscada-valve-check-flow-glyph`),u.setAttribute(`d`,`M ${a*.15} ${o/2} L ${a*.75} ${o/2} M ${a*.6} ${o/2-5} L ${a*.75} ${o/2} L ${a*.6} ${o/2+5}`),u.setAttribute(`stroke`,r.discColor),u.setAttribute(`stroke-width`,String(r.strokeWidth??2)),u.setAttribute(`fill`,`none`),i.appendChild(u);let d=o*.8,f=document.createElementNS(Q,`rect`);f.setAttribute(`class`,`vscada-valve-check-flap`),f.setAttribute(`x`,String(a/2-2)),f.setAttribute(`y`,String(o-d)),f.setAttribute(`width`,`4`),f.setAttribute(`height`,String(d)),f.setAttribute(`fill`,r.discColor),f.style.transformOrigin=`${a/2}px ${o}px`,i.appendChild(f);let p=document.createElementNS(Q,`g`);p.setAttribute(`class`,`vscada-valve-arrows`),p.setAttribute(`opacity`,`0`);let m=document.createElementNS(Q,`path`);m.setAttribute(`d`,`M ${a*.1} ${o+10} l -6 -4 l 0 8 z`),m.setAttribute(`fill`,r.arrowColor);let h=document.createElementNS(Q,`path`);h.setAttribute(`d`,`M ${a*.9} ${o+10} l 6 -4 l 0 8 z`),h.setAttribute(`fill`,r.arrowColor),p.appendChild(m),p.appendChild(h),p.style.transformOrigin=`${a/2}px ${o+10}px`,i.appendChild(p);let g=n.animateTransform(p,[`scale(1)`,`scale(1.3)`,`scale(1)`],Of),_=document.createElementNS(Q,`circle`);_.setAttribute(`class`,`vscada-valve-indicator`),_.setAttribute(`cx`,String(a*.5)),_.setAttribute(`cy`,`-10`),_.setAttribute(`r`,`5`),i.appendChild(_);let v=document.createElementNS(Q,`text`);return v.setAttribute(`class`,`vscada-valve-label`),v.setAttribute(`x`,`0`),v.setAttribute(`y`,String(o+22)),v.setAttribute(`font-size`,`9`),v.setAttribute(`fill`,r.arrowColor),i.appendChild(v),{svg:i,handles:ff({element:e,renderer:n,tokens:r,visuals:{fill:l,indicator:_,label:v},arrowControl:g,arrowVisual:p,onFraction(e,t){let n=-(1-t)*kf;e.setTransform(f,`rotate(${n}deg)`)}}).handles}}var jf=Object.freeze({group:`valves`,primitives:Object.freeze({"valve-check":{build:Af}})}),$=`http://www.w3.org/2000/svg`,Mf=600,Nf=4,Pf=.75;function Ff(e,t,n){let r=t.tokens.valve,i=document.createElementNS($,`g`);if(i.setAttribute(`data-element-id`,e.id),i.setAttribute(`class`,`vscada-valve-relief`),!r)return{svg:i,handles:{}};let{w:a,h:o}=e,s=j(t.tokens.medium,e.medium)?.color??r.openColor,c=document.createElementNS($,`rect`);c.setAttribute(`class`,`vscada-valve-body`),c.setAttribute(`width`,String(a)),c.setAttribute(`height`,String(o)),c.setAttribute(`fill`,`none`),c.setAttribute(`stroke`,r.bodyOutlineColor),c.setAttribute(`stroke-width`,String(r.strokeWidth??2)),i.appendChild(c);let l=document.createElementNS($,`rect`);l.setAttribute(`class`,`vscada-valve-fill`),l.setAttribute(`width`,String(a)),l.setAttribute(`height`,String(o)),l.setAttribute(`fill`,s),l.style.transformOrigin=`0px 0px`,i.appendChild(l);let u=a*.3,d=o*.7,f=document.createElementNS($,`rect`);f.setAttribute(`class`,`vscada-valve-relief-bonnet`),f.setAttribute(`x`,String(a/2-u/2)),f.setAttribute(`y`,String(-d)),f.setAttribute(`width`,String(u)),f.setAttribute(`height`,String(d)),f.setAttribute(`fill`,`none`),f.setAttribute(`stroke`,r.bodyOutlineColor),f.setAttribute(`stroke-width`,String(r.strokeWidth??2)),i.appendChild(f);let p=-d*.85,m=-d*.15,h=document.createElementNS($,`polyline`);h.setAttribute(`class`,`vscada-valve-relief-spring`),h.setAttribute(`fill`,`none`),h.setAttribute(`stroke`,r.bodyOutlineColor),h.setAttribute(`stroke-width`,String((r.strokeWidth??2)*Pf)),i.appendChild(h);function g(e){let t=[];for(let n=0;n<=Nf*2;n++){let r=p+(e-p)*n/(Nf*2),i=a/2+(n%2==0?-u*.28:u*.28);t.push(`${i},${r}`)}return t.join(` `)}h.setAttribute(`points`,g(m));let _=a*.3,v=document.createElementNS($,`rect`);v.setAttribute(`class`,`vscada-valve-relief-disc`),v.setAttribute(`x`,String(a/2-_/2)),v.setAttribute(`y`,`-4`),v.setAttribute(`width`,String(_)),v.setAttribute(`height`,`4`),v.setAttribute(`fill`,r.discColor),v.style.transformOrigin=`${a/2}px 0px`,i.appendChild(v);let y=document.createElementNS($,`g`);y.setAttribute(`class`,`vscada-valve-arrows`),y.setAttribute(`opacity`,`0`);let b=document.createElementNS($,`path`);b.setAttribute(`d`,`M ${a*.1} ${o+10} l -6 -4 l 0 8 z`),b.setAttribute(`fill`,r.arrowColor);let x=document.createElementNS($,`path`);x.setAttribute(`d`,`M ${a*.9} ${o+10} l 6 -4 l 0 8 z`),x.setAttribute(`fill`,r.arrowColor),y.appendChild(b),y.appendChild(x),y.style.transformOrigin=`${a/2}px ${o+10}px`,i.appendChild(y);let S=n.animateTransform(y,[`scale(1)`,`scale(1.3)`,`scale(1)`],Mf),C=document.createElementNS($,`circle`);C.setAttribute(`class`,`vscada-valve-indicator`),C.setAttribute(`cx`,String(a*.5)),C.setAttribute(`cy`,String(-d-10)),C.setAttribute(`r`,`5`),i.appendChild(C);let w=document.createElementNS($,`text`);w.setAttribute(`class`,`vscada-valve-label`),w.setAttribute(`x`,`0`),w.setAttribute(`y`,String(o+22)),w.setAttribute(`font-size`,`9`),w.setAttribute(`fill`,r.arrowColor),i.appendChild(w);let T=d*.5;return{svg:i,handles:ff({element:e,renderer:n,tokens:r,visuals:{fill:l,indicator:C,label:w},arrowControl:S,arrowVisual:y,onFraction(e,t){e.setTransform(v,`translateY(${-t*T}px)`),e.setAttr(h,`points`,g(m-t*T))}}).handles}}var If=Object.freeze({group:`valves`,primitives:Object.freeze({"valve-relief":{build:Ff}})}),Lf=Object.freeze({group:`valves`,primitives:Object.freeze({...hf.primitives,...bf.primitives,...wf.primitives,...Df.primitives,...jf.primitives,...If.primitives})});function Rf(e,t,n,r){return t+n*Math.sin(2*Math.PI*e/r)}function zf(e,t,n,r,i=6){let a=[],o=i>0?i:6;for(let i=0;i<e;i+=o)a.push({x:Rf(i,t,n,r),y:i});return a.push({x:Rf(e,t,n,r),y:e}),a}function Bf(e,t,n,r,i=6){let a=zf(e,t,n,r,i),o=[...a].reverse();return[...a.map((e,t)=>`${t===0?`M`:`L`}${e.x},${e.y}`),...o.map(e=>`L${-e.x},${e.y}`),`Z`].join(` `)}function Vf(e,t,n,r,i){let a=t===`x`?`translateX(0px)`:`translateY(0px)`,o=t===`x`?`translateX(-${n}px)`:`translateY(-${n}px)`;return i.animateTransform(e,[a,o],r)}var Hf=`http://www.w3.org/2000/svg`,Uf=3e3;function Wf(e,t){let{containerHeight:n,centerX:r,baseHalfWidth:i,wobble:a,period:o,color:s,durationMs:c=Uf}=e,l=Bf(n+o,i,a,o),u=document.createElementNS(Hf,`g`);u.setAttribute(`class`,`vscada-vapor-billow-carrier`),u.setAttribute(`transform`,`translate(${r}, 0)`);let d=document.createElementNS(Hf,`g`);d.setAttribute(`class`,`vscada-vapor-billow-loop`),u.appendChild(d);let f=document.createElementNS(Hf,`path`);return f.setAttribute(`class`,`vscada-vapor-billow-fill`),f.setAttribute(`d`,l),f.setAttribute(`fill`,s),f.setAttribute(`fill-opacity`,`0`),f.setAttribute(`stroke`,`none`),d.appendChild(f),{carrier:u,fill:f,control:Vf(d,`y`,o,c,t)}}function Gf(e){}function Kf(e){let{element:t,group:n,layers:r,staticGlyph:i,plumeStyle:a,brightnessFactor:o=1,onWarning:s=Gf}=e,c=t.bindings.find(e=>e.type===`emission`);if(!c)return{handles:{}};let l={kind:`numeric`,write(e,t){t<0&&s({code:`NEGATIVE_EMISSION_VALUE`,message:`Tag "${c.tag}": emission value ${t} is negative`,tag:c.tag});let l=_n(c,t);e.setAttr(n,`opacity`,l>0?`1`:`0`);let u=Math.min(1,l*a.opacity*o);for(let t of r)e.setAttr(t.fill,`fill-opacity`,String(u)),t.control.setPlaybackRate(l*a.driftSpeed);i&&e.setAttr(i,`fill-opacity`,String(u))}};return{handles:{[c.tag]:l}}}function qf(e,t,n){if(!n)return{};let r=n,i={kind:`static-representation`,activate(){for(let e of t)e.carrier.style.display=`none`;r.style.display=``},deactivate(){for(let e of t)e.carrier.style.display=``;r.style.display=`none`}};return{[`__vapor-static-representation-${e}`]:i}}function Jf(e,t){return t.length===0?{}:{[`__vapor-drift-animation-${e}`]:{kind:`animation`,pause(){for(let e of t)e.control.pause()},resume(){for(let e of t)e.control.resume()},seek(e){for(let n of t)n.control.seek(e)}}}}var Yf=`http://www.w3.org/2000/svg`,Xf=3,Zf=.35,Qf=.9,$f=.6;function ep(e,t,n){let r=document.createElementNS(Yf,`g`);r.setAttribute(`data-element-id`,e.id),r.setAttribute(`class`,`vscada-vapor-plume`),r.setAttribute(`opacity`,`0`);let i=j(t.tokens.medium,e.medium);if(!i?.plume)return{svg:r,handles:{}};let{w:a,h:o}=e,s=a/2,c=Math.max(8,o*Qf),l=[];for(let e=0;e<Xf;e++){let t=Math.max(2,a/2*(1-e*.18)),u=Wf({containerHeight:o,centerX:s,baseHalfWidth:t,wobble:t*Zf,period:c,color:i.color,durationMs:Uf*(1+e*$f)},n);r.appendChild(u.carrier),l.push(u)}let u=document.createElementNS(Yf,`path`);u.setAttribute(`class`,`vscada-vapor-plume-static`),u.setAttribute(`transform`,`translate(${s}, 0)`),u.setAttribute(`d`,Bf(o,a*.32,a*.32*Zf,c)),u.setAttribute(`fill`,i.color),u.setAttribute(`fill-opacity`,`0`),u.setAttribute(`stroke`,`none`),u.style.display=`none`,r.appendChild(u);let d=Kf({element:e,group:r,layers:l,staticGlyph:u,plumeStyle:i.plume}),f=Jf(e.id,l),p=qf(e.id,l,u);return{svg:r,handles:{...d.handles,...f,...p}}}var tp=Object.freeze({group:`vapor`,primitives:Object.freeze({plume:{build:ep}})}),np=`http://www.w3.org/2000/svg`,rp=2,ip=.3,ap=.7,op=.5,sp=.4,cp=1.6,lp=`steam`;function up(e,t,n){let r=document.createElementNS(np,`g`);r.setAttribute(`data-element-id`,e.id),r.setAttribute(`class`,`vscada-vapor-steam-vent`),r.setAttribute(`opacity`,`0`);let i=j(t.tokens.medium,e.medium??lp);if(!i?.plume)return{svg:r,handles:{}};let{w:a,h:o}=e,s=a/2,c=Math.max(6,o*ap),l=[];for(let e=0;e<rp;e++){let t=Math.max(1.5,a/2*(1-e*.2)),u=Wf({containerHeight:o,centerX:s,baseHalfWidth:t,wobble:t*ip,period:c,color:i.color,durationMs:Uf*op*(1+e*sp)},n);r.appendChild(u.carrier),l.push(u)}let u=document.createElementNS(np,`path`);u.setAttribute(`class`,`vscada-vapor-steam-vent-static`),u.setAttribute(`transform`,`translate(${s}, 0)`),u.setAttribute(`d`,Bf(o,a*.28,a*.28*ip,c)),u.setAttribute(`fill`,i.color),u.setAttribute(`fill-opacity`,`0`),u.setAttribute(`stroke`,`none`),u.style.display=`none`,r.appendChild(u);let d=Kf({element:e,group:r,layers:l,staticGlyph:u,plumeStyle:i.plume,brightnessFactor:cp}),f=Jf(e.id,l),p=qf(e.id,l,u);return{svg:r,handles:{...d.handles,...f,...p}}}var dp=Object.freeze({group:`vapor`,primitives:Object.freeze({"steam-vent":{build:up}})}),fp=Object.freeze({group:`vapor`,primitives:Object.freeze({...tp.primitives,...dp.primitives})});function pp(e,t){let n=tl(e,t),r=e*$c;return{orientation:`vertical`,bodyPathD:n,rims:[{cx:e/2,cy:0,rx:e/2,ry:r,crownRibbing:!0},{cx:e/2,cy:t,rx:e/2,ry:r}],hardware:`tank-vertical`}}function mp(e,t,n){return G({element:e,theme:t,renderer:n,geometry:pp(e.w,e.h)})}var hp=Object.freeze({group:`vessels`,primitives:Object.freeze({"tank-vertical":{build:mp}})});function gp(e,t){let n=al(e,t),r=ol(e,t);return{orientation:`horizontal`,bodyPathD:n,rims:[{cx:r,cy:t/2,rx:r,ry:t/2},{cx:e-r,cy:t/2,rx:r,ry:t/2}],hardware:`tank-horizontal`}}function _p(e,t,n){return G({element:e,theme:t,renderer:n,geometry:gp(e.w,e.h)})}var vp=Object.freeze({group:`vessels`,primitives:Object.freeze({"tank-horizontal":{build:_p}})});function yp(e,t){let{cx:n,cy:r,r:i}=sl(e,t);return{orientation:`spherical`,bodyPathD:cl(e,t),rims:[{cx:n,cy:r-i*.7,rx:i*.5,ry:i*.16,crownRibbing:!0}],hardware:`sphere`}}function bp(e,t,n){return G({element:e,theme:t,renderer:n,geometry:yp(e.w,e.h)})}var xp=Object.freeze({group:`vessels`,primitives:Object.freeze({"tank-spherical":{build:bp}})});function Sp(e,t){return{orientation:`vertical`,bodyPathD:ll(e,t),rims:[{cx:e/2,cy:0,rx:e/2,ry:e*$c}],hardware:`hopper`}}function Cp(e,t,n){return G({element:e,theme:t,renderer:n,geometry:Sp(e.w,e.h)})}var wp=Object.freeze({group:`vessels`,primitives:Object.freeze({hopper:{build:Cp}})});function Tp(e,t){let n=ul(e,t),r=fl(e,t),i=dl(t);return{orientation:`vertical`,bodyPathD:n,liquidClipPathD:r,markerMinY:i,rims:[{cx:e/2,cy:i,rx:e/2,ry:e*$c*.5}],hardware:`silo`}}function Ep(e,t,n){return G({element:e,theme:t,renderer:n,geometry:Tp(e.w,e.h)})}var Dp=Object.freeze({group:`vessels`,primitives:Object.freeze({silo:{build:Ep}})});function Op(e,t){let n=al(e,t),r=ol(e,t);return{orientation:`horizontal`,bodyPathD:n,rims:[{cx:r,cy:t/2,rx:r,ry:t/2},{cx:e-r,cy:t/2,rx:r,ry:t/2}],hardware:`drum`}}function kp(e,t,n){return G({element:e,theme:t,renderer:n,geometry:Op(e.w,e.h)})}var Ap=Object.freeze({group:`vessels`,primitives:Object.freeze({drum:{build:kp}})}),jp=Object.freeze({group:`vessels`,primitives:Object.freeze({...hp.primitives,...vp.primitives,...xp.primitives,...wp.primitives,...Dp.primitives,...Ap.primitives})});bo(),et(wo),Ke(Oo,Wo,js,lc,Pc,hu,Gu,Yu,cf,Lf,fp,jp),Ze(As)});
|