iobroker.javascript 9.0.9 → 9.0.11
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/README.md +8 -6
- package/admin/assets/{OpenAiDialog-CDDsvlCe.js → OpenAiDialog-BYXyaWDU.js} +1 -1
- package/admin/assets/{Save-D3ZQadHC.js → Save--0ldNXLf.js} +1 -1
- package/admin/assets/{ScriptEditor-Ciz-_SvX.js → ScriptEditor-CpRWvDSw.js} +1 -1
- package/admin/assets/{ScriptEditorVanillaMonaco-Cs6PL8eZ.js → ScriptEditorVanillaMonaco-BWe9MiKn.js} +1 -1
- package/admin/assets/{createSvgIcon-BDXN8whp.js → createSvgIcon-C_ElRFrf.js} +1 -1
- package/admin/assets/index-BLZa2V1g.js +1 -0
- package/admin/assets/{index-quKi7QsD.js → index-BUU5hWiL.js} +95 -95
- package/admin/assets/{index-DOeHpve2.js → index-CMttI-gM.js} +4 -4
- package/admin/assets/index-DeFm7TiX.js +5 -0
- package/admin/assets/{index-PhbDiVdG.js → index-T5pCS60x.js} +1 -1
- package/admin/assets/index-fhg5Z_KX.js +930 -0
- package/admin/assets/{inheritsLoose-BLb-YnoJ.js → inheritsLoose-CLw44UEv.js} +1 -1
- package/admin/assets/useTheme-CpAj0H76.js +1 -0
- package/admin/custom/assets/index-DsPFm5o5.js +904 -0
- package/admin/custom/customComponents.js +2 -2
- package/admin/google-blockly/own/blocks_procedures.js +162 -0
- package/admin/google-blockly/own/blocks_system.js +1 -1
- package/admin/mf-manifest.json +1 -1
- package/admin/remoteEntry.js +2 -2
- package/admin/tab.html +4 -4
- package/build-backend/lib/javascript.d.ts +1504 -147
- package/build-backend/lib/protectFs.js +111 -104
- package/build-backend/lib/protectFs.js.map +1 -1
- package/io-package.json +14 -14
- package/package.json +3 -3
- package/admin/assets/index-BZGWELt0.js +0 -930
- package/admin/assets/index-BxkzUxCi.js +0 -27
- package/admin/assets/index-DsS-er0h.js +0 -5
- package/admin/assets/useTheme-BbFVG4-1.js +0 -1
- package/admin/custom/assets/index-FOcWxrRT.js +0 -904
package/README.md
CHANGED
|
@@ -26,9 +26,16 @@ Executes Javascript, Typescript Scripts.
|
|
|
26
26
|
<!--
|
|
27
27
|
### **WORK IN PROGRESS**
|
|
28
28
|
-->
|
|
29
|
-
### 9.0.
|
|
29
|
+
### 9.0.11 (2025-07-29)
|
|
30
|
+
* (@GermanBluefox) Corrected the rule editor if the condition is empty
|
|
31
|
+
* (@GermanBluefox) Corrected types for TypeScript
|
|
32
|
+
|
|
33
|
+
### 9.0.10 (2025-07-27)
|
|
30
34
|
* (@klein0r) Added Blockly block to format a numeric value
|
|
31
35
|
* (@GermanBluefox) Fixing some blocks in blockly: cron, time
|
|
36
|
+
* (@GermanBluefox) Added new block: "unconditional return"
|
|
37
|
+
* (@GermanBluefox) Type definitions for TypeScript were updated
|
|
38
|
+
* (@GermanBluefox) Corrected bug with deleting of sub-folders
|
|
32
39
|
|
|
33
40
|
### 9.0.7 (2025-06-29)
|
|
34
41
|
* (@GermanBluefox) Fixing some blocks in blockly: time, function
|
|
@@ -42,11 +49,6 @@ Executes Javascript, Typescript Scripts.
|
|
|
42
49
|
* (@GermanBluefox) Corrected import of Blockly blocks
|
|
43
50
|
* (@GermanBluefox) Corrected editing of Blockly
|
|
44
51
|
|
|
45
|
-
### 9.0.3 (2025-06-12)
|
|
46
|
-
|
|
47
|
-
* (@GermanBluefox) Corrected the rule editor
|
|
48
|
-
* (@GermanBluefox) Removed the unused JS files
|
|
49
|
-
|
|
50
52
|
## License
|
|
51
53
|
The MIT License (MIT)
|
|
52
54
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{c as cr,j as E}from"./createSvgIcon-BDXN8whp.js";import{i as Z}from"./iobroker_javascript__loadShare__react__loadShare__-B-pIv4x_.js";import{i as j,c as hn,C as lr}from"./index-DsS-er0h.js";import{i as U,h as ur}from"./index-quKi7QsD.js";import{_ as hr}from"./preload-helper-Dp1pzeXC.js";import{C as dr,t as fr}from"./index-BompUVvy.js";import mr from"./ScriptEditorVanillaMonaco-Cs6PL8eZ.js";import"./_commonjsHelpers-Cpj98o6Y.js";import"./iobroker_javascript__mf_v__runtimeInit__mf_v__-CmuPLb0X.js";import"./inheritsLoose-BLb-YnoJ.js";const pr=cr(E.jsx("path",{d:"M11.07 12.85c.77-1.39 2.25-2.21 3.11-3.44.91-1.29.4-3.7-2.18-3.7-1.69 0-2.52 1.28-2.87 2.34L6.54 6.96C7.25 4.83 9.18 3 11.99 3c2.35 0 3.96 1.07 4.78 2.41.7 1.15 1.11 3.3.03 4.9-1.2 1.77-2.35 2.31-2.97 3.45-.25.46-.35.76-.35 2.24h-2.89c-.01-.78-.13-2.05.48-3.15M14 20c0 1.1-.9 2-2 2s-2-.9-2-2 .9-2 2-2 2 .9 2 2"}),"QuestionMark");function C(s,e,t,n,r){if(typeof e=="function"?s!==e||!0:!e.has(s))throw new TypeError("Cannot write private member to an object whose class did not declare it");return e.set(s,t),t}function o(s,e,t,n){if(t==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?s!==e||!n:!e.has(s))throw new TypeError("Cannot read private member from an object whose class did not declare it");return t==="m"?n:t==="a"?n.call(s):n?n.value:e.get(s)}let Dn=function(){const{crypto:s}=globalThis;if(s!=null&&s.randomUUID)return Dn=s.randomUUID.bind(s),s.randomUUID();const e=new Uint8Array(1),t=s?()=>s.getRandomValues(e)[0]:()=>Math.random()*255&255;return"10000000-1000-4000-8000-100000000000".replace(/[018]/g,n=>(+n^t()&15>>+n/4).toString(16))};function Ot(s){return typeof s=="object"&&s!==null&&("name"in s&&s.name==="AbortError"||"message"in s&&String(s.message).includes("FetchRequestCanceledException"))}const Et=s=>{if(s instanceof Error)return s;if(typeof s=="object"&&s!==null){try{if(Object.prototype.toString.call(s)==="[object Error]"){const e=new Error(s.message,s.cause?{cause:s.cause}:{});return s.stack&&(e.stack=s.stack),s.cause&&!e.cause&&(e.cause=s.cause),s.name&&(e.name=s.name),e}}catch{}try{return new Error(JSON.stringify(s))}catch{}}return new Error(s)};class I extends Error{}class H extends I{constructor(e,t,n,r){super(`${H.makeMessage(e,t,n)}`),this.status=e,this.headers=r,this.requestID=r==null?void 0:r.get("x-request-id"),this.error=t;const a=t;this.code=a==null?void 0:a.code,this.param=a==null?void 0:a.param,this.type=a==null?void 0:a.type}static makeMessage(e,t,n){const r=t!=null&&t.message?typeof t.message=="string"?t.message:JSON.stringify(t.message):t?JSON.stringify(t):n;return e&&r?`${e} ${r}`:e?`${e} status code (no body)`:r||"(no status code or body)"}static generate(e,t,n,r){if(!e||!r)return new mt({message:n,cause:Et(t)});const a=t==null?void 0:t.error;return e===400?new Bn(e,a,n,r):e===401?new Wn(e,a,n,r):e===403?new Un(e,a,n,r):e===404?new qn(e,a,n,r):e===409?new Jn(e,a,n,r):e===422?new Hn(e,a,n,r):e===429?new Xn(e,a,n,r):e>=500?new Kn(e,a,n,r):new H(e,a,n,r)}}class z extends H{constructor({message:e}={}){super(void 0,void 0,e||"Request was aborted.",void 0)}}class mt extends H{constructor({message:e,cause:t}){super(void 0,void 0,e||"Connection error.",void 0),t&&(this.cause=t)}}class qt extends mt{constructor({message:e}={}){super({message:e??"Request timed out."})}}class Bn extends H{}class Wn extends H{}class Un extends H{}class qn extends H{}class Jn extends H{}class Hn extends H{}class Xn extends H{}class Kn extends H{}class Vn extends I{constructor(){super("Could not parse response content as the length limit was reached")}}class Gn extends I{constructor(){super("Could not parse response content as the request was rejected by the content filter")}}class Re extends Error{constructor(e){super(e)}}const gr=/^[a-z][a-z0-9+.-]*:/i,_r=s=>gr.test(s);let K=s=>(K=Array.isArray,K(s)),dn=K;function yr(s){return typeof s!="object"?{}:s??{}}function wr(s){if(!s)return!0;for(const e in s)return!1;return!0}function br(s,e){return Object.prototype.hasOwnProperty.call(s,e)}function St(s){return s!=null&&typeof s=="object"&&!Array.isArray(s)}const Sr=(s,e)=>{if(typeof e!="number"||!Number.isInteger(e))throw new I(`${s} must be an integer`);if(e<0)throw new I(`${s} must be a positive integer`);return e},xr=s=>{try{return JSON.parse(s)}catch{return}},Be=s=>new Promise(e=>setTimeout(e,s)),we="5.10.2",Ar=()=>typeof window<"u"&&typeof window.document<"u"&&typeof navigator<"u";function vr(){return typeof Deno<"u"&&Deno.build!=null?"deno":typeof EdgeRuntime<"u"?"edge":Object.prototype.toString.call(typeof globalThis.process<"u"?globalThis.process:0)==="[object process]"?"node":"unknown"}const Cr=()=>{var t;const s=vr();if(s==="deno")return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":we,"X-Stainless-OS":mn(Deno.build.os),"X-Stainless-Arch":fn(Deno.build.arch),"X-Stainless-Runtime":"deno","X-Stainless-Runtime-Version":typeof Deno.version=="string"?Deno.version:((t=Deno.version)==null?void 0:t.deno)??"unknown"};if(typeof EdgeRuntime<"u")return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":we,"X-Stainless-OS":"Unknown","X-Stainless-Arch":`other:${EdgeRuntime}`,"X-Stainless-Runtime":"edge","X-Stainless-Runtime-Version":globalThis.process.version};if(s==="node")return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":we,"X-Stainless-OS":mn(globalThis.process.platform??"unknown"),"X-Stainless-Arch":fn(globalThis.process.arch??"unknown"),"X-Stainless-Runtime":"node","X-Stainless-Runtime-Version":globalThis.process.version??"unknown"};const e=Ir();return e?{"X-Stainless-Lang":"js","X-Stainless-Package-Version":we,"X-Stainless-OS":"Unknown","X-Stainless-Arch":"unknown","X-Stainless-Runtime":`browser:${e.browser}`,"X-Stainless-Runtime-Version":e.version}:{"X-Stainless-Lang":"js","X-Stainless-Package-Version":we,"X-Stainless-OS":"Unknown","X-Stainless-Arch":"unknown","X-Stainless-Runtime":"unknown","X-Stainless-Runtime-Version":"unknown"}};function Ir(){if(typeof navigator>"u"||!navigator)return null;const s=[{key:"edge",pattern:/Edge(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"ie",pattern:/MSIE(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"ie",pattern:/Trident(?:.*rv\:(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"chrome",pattern:/Chrome(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"firefox",pattern:/Firefox(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"safari",pattern:/(?:Version\W+(\d+)\.(\d+)(?:\.(\d+))?)?(?:\W+Mobile\S*)?\W+Safari/}];for(const{key:e,pattern:t}of s){const n=t.exec(navigator.userAgent);if(n){const r=n[1]||0,a=n[2]||0,i=n[3]||0;return{browser:e,version:`${r}.${a}.${i}`}}}return null}const fn=s=>s==="x32"?"x32":s==="x86_64"||s==="x64"?"x64":s==="arm"?"arm":s==="aarch64"||s==="arm64"?"arm64":s?`other:${s}`:"unknown",mn=s=>(s=s.toLowerCase(),s.includes("ios")?"iOS":s==="android"?"Android":s==="darwin"?"MacOS":s==="win32"?"Windows":s==="freebsd"?"FreeBSD":s==="openbsd"?"OpenBSD":s==="linux"?"Linux":s?`Other:${s}`:"Unknown");let pn;const Rr=()=>pn??(pn=Cr());function kr(){if(typeof fetch<"u")return fetch;throw new Error("`fetch` is not defined as a global; Either pass `fetch` to the client, `new OpenAI({ fetch })` or polyfill the global, `globalThis.fetch = fetch`")}function Qn(...s){const e=globalThis.ReadableStream;if(typeof e>"u")throw new Error("`ReadableStream` is not defined as a global; You will need to polyfill it, `globalThis.ReadableStream = ReadableStream`");return new e(...s)}function zn(s){let e=Symbol.asyncIterator in s?s[Symbol.asyncIterator]():s[Symbol.iterator]();return Qn({start(){},async pull(t){const{done:n,value:r}=await e.next();n?t.close():t.enqueue(r)},async cancel(){var t;await((t=e.return)==null?void 0:t.call(e))}})}function Yn(s){if(s[Symbol.asyncIterator])return s;const e=s.getReader();return{async next(){try{const t=await e.read();return t!=null&&t.done&&e.releaseLock(),t}catch(t){throw e.releaseLock(),t}},async return(){const t=e.cancel();return e.releaseLock(),await t,{done:!0,value:void 0}},[Symbol.asyncIterator](){return this}}}async function $r(s){var n,r;if(s===null||typeof s!="object")return;if(s[Symbol.asyncIterator]){await((r=(n=s[Symbol.asyncIterator]()).return)==null?void 0:r.call(n));return}const e=s.getReader(),t=e.cancel();e.releaseLock(),await t}const Or=({headers:s,body:e})=>({bodyHeaders:{"content-type":"application/json"},body:JSON.stringify(e)}),Zn="RFC3986",es=s=>String(s),gn={RFC1738:s=>String(s).replace(/%20/g,"+"),RFC3986:es},Er="RFC1738";let Pt=(s,e)=>(Pt=Object.hasOwn??Function.prototype.call.bind(Object.prototype.hasOwnProperty),Pt(s,e));const ee=(()=>{const s=[];for(let e=0;e<256;++e)s.push("%"+((e<16?"0":"")+e.toString(16)).toUpperCase());return s})(),xt=1024,Pr=(s,e,t,n,r)=>{if(s.length===0)return s;let a=s;if(typeof s=="symbol"?a=Symbol.prototype.toString.call(s):typeof s!="string"&&(a=String(s)),t==="iso-8859-1")return escape(a).replace(/%u[0-9a-f]{4}/gi,function(c){return"%26%23"+parseInt(c.slice(2),16)+"%3B"});let i="";for(let c=0;c<a.length;c+=xt){const l=a.length>=xt?a.slice(c,c+xt):a,u=[];for(let m=0;m<l.length;++m){let h=l.charCodeAt(m);if(h===45||h===46||h===95||h===126||h>=48&&h<=57||h>=65&&h<=90||h>=97&&h<=122||r===Er&&(h===40||h===41)){u[u.length]=l.charAt(m);continue}if(h<128){u[u.length]=ee[h];continue}if(h<2048){u[u.length]=ee[192|h>>6]+ee[128|h&63];continue}if(h<55296||h>=57344){u[u.length]=ee[224|h>>12]+ee[128|h>>6&63]+ee[128|h&63];continue}m+=1,h=65536+((h&1023)<<10|l.charCodeAt(m)&1023),u[u.length]=ee[240|h>>18]+ee[128|h>>12&63]+ee[128|h>>6&63]+ee[128|h&63]}i+=u.join("")}return i};function Tr(s){return!s||typeof s!="object"?!1:!!(s.constructor&&s.constructor.isBuffer&&s.constructor.isBuffer(s))}function _n(s,e){if(K(s)){const t=[];for(let n=0;n<s.length;n+=1)t.push(e(s[n]));return t}return e(s)}const ts={brackets(s){return String(s)+"[]"},comma:"comma",indices(s,e){return String(s)+"["+e+"]"},repeat(s){return String(s)}},ns=function(s,e){Array.prototype.push.apply(s,K(e)?e:[e])};let yn;const B={addQueryPrefix:!1,allowDots:!1,allowEmptyArrays:!1,arrayFormat:"indices",charset:"utf-8",charsetSentinel:!1,delimiter:"&",encode:!0,encodeDotInKeys:!1,encoder:Pr,encodeValuesOnly:!1,format:Zn,formatter:es,indices:!1,serializeDate(s){return(yn??(yn=Function.prototype.call.bind(Date.prototype.toISOString)))(s)},skipNulls:!1,strictNullHandling:!1};function Mr(s){return typeof s=="string"||typeof s=="number"||typeof s=="boolean"||typeof s=="symbol"||typeof s=="bigint"}const At={};function ss(s,e,t,n,r,a,i,c,l,u,m,h,g,d,b,w,A,O){let p=s,y=O,_=0,v=!1;for(;(y=y.get(At))!==void 0&&!v;){const T=y.get(s);if(_+=1,typeof T<"u"){if(T===_)throw new RangeError("Cyclic object value");v=!0}typeof y.get(At)>"u"&&(_=0)}if(typeof u=="function"?p=u(e,p):p instanceof Date?p=g==null?void 0:g(p):t==="comma"&&K(p)&&(p=_n(p,function(T){return T instanceof Date?g==null?void 0:g(T):T})),p===null){if(a)return l&&!w?l(e,B.encoder,A,"key",d):e;p=""}if(Mr(p)||Tr(p)){if(l){const T=w?e:l(e,B.encoder,A,"key",d);return[(b==null?void 0:b(T))+"="+(b==null?void 0:b(l(p,B.encoder,A,"value",d)))]}return[(b==null?void 0:b(e))+"="+(b==null?void 0:b(String(p)))]}const $=[];if(typeof p>"u")return $;let R;if(t==="comma"&&K(p))w&&l&&(p=_n(p,l)),R=[{value:p.length>0?p.join(",")||null:void 0}];else if(K(u))R=u;else{const T=Object.keys(p);R=m?T.sort(m):T}const F=c?String(e).replace(/\./g,"%2E"):String(e),x=n&&K(p)&&p.length===1?F+"[]":F;if(r&&K(p)&&p.length===0)return x+"[]";for(let T=0;T<R.length;++T){const M=R[T],se=typeof M=="object"&&typeof M.value<"u"?M.value:p[M];if(i&&se===null)continue;const me=h&&c?M.replace(/\./g,"%2E"):M,N=K(p)?typeof t=="function"?t(x,me):x:x+(h?"."+me:"["+me+"]");O.set(s,_);const ie=new WeakMap;ie.set(At,O),ns($,ss(se,N,t,n,r,a,i,c,t==="comma"&&w&&K(p)?null:l,u,m,h,g,d,b,w,A,ie))}return $}function Nr(s=B){if(typeof s.allowEmptyArrays<"u"&&typeof s.allowEmptyArrays!="boolean")throw new TypeError("`allowEmptyArrays` option can only be `true` or `false`, when provided");if(typeof s.encodeDotInKeys<"u"&&typeof s.encodeDotInKeys!="boolean")throw new TypeError("`encodeDotInKeys` option can only be `true` or `false`, when provided");if(s.encoder!==null&&typeof s.encoder<"u"&&typeof s.encoder!="function")throw new TypeError("Encoder has to be a function.");const e=s.charset||B.charset;if(typeof s.charset<"u"&&s.charset!=="utf-8"&&s.charset!=="iso-8859-1")throw new TypeError("The charset option must be either utf-8, iso-8859-1, or undefined");let t=Zn;if(typeof s.format<"u"){if(!Pt(gn,s.format))throw new TypeError("Unknown format option provided.");t=s.format}const n=gn[t];let r=B.filter;(typeof s.filter=="function"||K(s.filter))&&(r=s.filter);let a;if(s.arrayFormat&&s.arrayFormat in ts?a=s.arrayFormat:"indices"in s?a=s.indices?"indices":"repeat":a=B.arrayFormat,"commaRoundTrip"in s&&typeof s.commaRoundTrip!="boolean")throw new TypeError("`commaRoundTrip` must be a boolean, or absent");const i=typeof s.allowDots>"u"?s.encodeDotInKeys?!0:B.allowDots:!!s.allowDots;return{addQueryPrefix:typeof s.addQueryPrefix=="boolean"?s.addQueryPrefix:B.addQueryPrefix,allowDots:i,allowEmptyArrays:typeof s.allowEmptyArrays=="boolean"?!!s.allowEmptyArrays:B.allowEmptyArrays,arrayFormat:a,charset:e,charsetSentinel:typeof s.charsetSentinel=="boolean"?s.charsetSentinel:B.charsetSentinel,commaRoundTrip:!!s.commaRoundTrip,delimiter:typeof s.delimiter>"u"?B.delimiter:s.delimiter,encode:typeof s.encode=="boolean"?s.encode:B.encode,encodeDotInKeys:typeof s.encodeDotInKeys=="boolean"?s.encodeDotInKeys:B.encodeDotInKeys,encoder:typeof s.encoder=="function"?s.encoder:B.encoder,encodeValuesOnly:typeof s.encodeValuesOnly=="boolean"?s.encodeValuesOnly:B.encodeValuesOnly,filter:r,format:t,formatter:n,serializeDate:typeof s.serializeDate=="function"?s.serializeDate:B.serializeDate,skipNulls:typeof s.skipNulls=="boolean"?s.skipNulls:B.skipNulls,sort:typeof s.sort=="function"?s.sort:null,strictNullHandling:typeof s.strictNullHandling=="boolean"?s.strictNullHandling:B.strictNullHandling}}function jr(s,e={}){let t=s;const n=Nr(e);let r,a;typeof n.filter=="function"?(a=n.filter,t=a("",t)):K(n.filter)&&(a=n.filter,r=a);const i=[];if(typeof t!="object"||t===null)return"";const c=ts[n.arrayFormat],l=c==="comma"&&n.commaRoundTrip;r||(r=Object.keys(t)),n.sort&&r.sort(n.sort);const u=new WeakMap;for(let g=0;g<r.length;++g){const d=r[g];n.skipNulls&&t[d]===null||ns(i,ss(t[d],d,c,l,n.allowEmptyArrays,n.strictNullHandling,n.skipNulls,n.encodeDotInKeys,n.encode?n.encoder:null,n.filter,n.sort,n.allowDots,n.serializeDate,n.format,n.formatter,n.encodeValuesOnly,n.charset,u))}const m=i.join(n.delimiter);let h=n.addQueryPrefix===!0?"?":"";return n.charsetSentinel&&(n.charset==="iso-8859-1"?h+="utf8=%26%2310003%3B&":h+="utf8=%E2%9C%93&"),m.length>0?h+m:""}function Fr(s){let e=0;for(const r of s)e+=r.length;const t=new Uint8Array(e);let n=0;for(const r of s)t.set(r,n),n+=r.length;return t}let wn;function Jt(s){let e;return(wn??(e=new globalThis.TextEncoder,wn=e.encode.bind(e)))(s)}let bn;function Sn(s){let e;return(bn??(e=new globalThis.TextDecoder,bn=e.decode.bind(e)))(s)}var V,G;class pt{constructor(){V.set(this,void 0),G.set(this,void 0),C(this,V,new Uint8Array),C(this,G,null)}decode(e){if(e==null)return[];const t=e instanceof ArrayBuffer?new Uint8Array(e):typeof e=="string"?Jt(e):e;C(this,V,Fr([o(this,V,"f"),t]));const n=[];let r;for(;(r=Lr(o(this,V,"f"),o(this,G,"f")))!=null;){if(r.carriage&&o(this,G,"f")==null){C(this,G,r.index);continue}if(o(this,G,"f")!=null&&(r.index!==o(this,G,"f")+1||r.carriage)){n.push(Sn(o(this,V,"f").subarray(0,o(this,G,"f")-1))),C(this,V,o(this,V,"f").subarray(o(this,G,"f"))),C(this,G,null);continue}const a=o(this,G,"f")!==null?r.preceding-1:r.preceding,i=Sn(o(this,V,"f").subarray(0,a));n.push(i),C(this,V,o(this,V,"f").subarray(r.index)),C(this,G,null)}return n}flush(){return o(this,V,"f").length?this.decode(`
|
|
1
|
+
import{c as cr,j as E}from"./createSvgIcon-C_ElRFrf.js";import{i as Z}from"./iobroker_javascript__loadShare__react__loadShare__-B-pIv4x_.js";import{i as j,c as hn,C as lr}from"./index-DeFm7TiX.js";import{i as U,h as ur}from"./index-BUU5hWiL.js";import{_ as hr}from"./preload-helper-Dp1pzeXC.js";import{C as dr,t as fr}from"./index-BompUVvy.js";import mr from"./ScriptEditorVanillaMonaco-BWe9MiKn.js";import"./_commonjsHelpers-Cpj98o6Y.js";import"./iobroker_javascript__mf_v__runtimeInit__mf_v__-CmuPLb0X.js";import"./inheritsLoose-CLw44UEv.js";const pr=cr(E.jsx("path",{d:"M11.07 12.85c.77-1.39 2.25-2.21 3.11-3.44.91-1.29.4-3.7-2.18-3.7-1.69 0-2.52 1.28-2.87 2.34L6.54 6.96C7.25 4.83 9.18 3 11.99 3c2.35 0 3.96 1.07 4.78 2.41.7 1.15 1.11 3.3.03 4.9-1.2 1.77-2.35 2.31-2.97 3.45-.25.46-.35.76-.35 2.24h-2.89c-.01-.78-.13-2.05.48-3.15M14 20c0 1.1-.9 2-2 2s-2-.9-2-2 .9-2 2-2 2 .9 2 2"}),"QuestionMark");function C(s,e,t,n,r){if(typeof e=="function"?s!==e||!0:!e.has(s))throw new TypeError("Cannot write private member to an object whose class did not declare it");return e.set(s,t),t}function o(s,e,t,n){if(t==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?s!==e||!n:!e.has(s))throw new TypeError("Cannot read private member from an object whose class did not declare it");return t==="m"?n:t==="a"?n.call(s):n?n.value:e.get(s)}let Dn=function(){const{crypto:s}=globalThis;if(s!=null&&s.randomUUID)return Dn=s.randomUUID.bind(s),s.randomUUID();const e=new Uint8Array(1),t=s?()=>s.getRandomValues(e)[0]:()=>Math.random()*255&255;return"10000000-1000-4000-8000-100000000000".replace(/[018]/g,n=>(+n^t()&15>>+n/4).toString(16))};function Ot(s){return typeof s=="object"&&s!==null&&("name"in s&&s.name==="AbortError"||"message"in s&&String(s.message).includes("FetchRequestCanceledException"))}const Et=s=>{if(s instanceof Error)return s;if(typeof s=="object"&&s!==null){try{if(Object.prototype.toString.call(s)==="[object Error]"){const e=new Error(s.message,s.cause?{cause:s.cause}:{});return s.stack&&(e.stack=s.stack),s.cause&&!e.cause&&(e.cause=s.cause),s.name&&(e.name=s.name),e}}catch{}try{return new Error(JSON.stringify(s))}catch{}}return new Error(s)};class I extends Error{}class H extends I{constructor(e,t,n,r){super(`${H.makeMessage(e,t,n)}`),this.status=e,this.headers=r,this.requestID=r==null?void 0:r.get("x-request-id"),this.error=t;const a=t;this.code=a==null?void 0:a.code,this.param=a==null?void 0:a.param,this.type=a==null?void 0:a.type}static makeMessage(e,t,n){const r=t!=null&&t.message?typeof t.message=="string"?t.message:JSON.stringify(t.message):t?JSON.stringify(t):n;return e&&r?`${e} ${r}`:e?`${e} status code (no body)`:r||"(no status code or body)"}static generate(e,t,n,r){if(!e||!r)return new mt({message:n,cause:Et(t)});const a=t==null?void 0:t.error;return e===400?new Bn(e,a,n,r):e===401?new Wn(e,a,n,r):e===403?new Un(e,a,n,r):e===404?new qn(e,a,n,r):e===409?new Jn(e,a,n,r):e===422?new Hn(e,a,n,r):e===429?new Xn(e,a,n,r):e>=500?new Kn(e,a,n,r):new H(e,a,n,r)}}class z extends H{constructor({message:e}={}){super(void 0,void 0,e||"Request was aborted.",void 0)}}class mt extends H{constructor({message:e,cause:t}){super(void 0,void 0,e||"Connection error.",void 0),t&&(this.cause=t)}}class qt extends mt{constructor({message:e}={}){super({message:e??"Request timed out."})}}class Bn extends H{}class Wn extends H{}class Un extends H{}class qn extends H{}class Jn extends H{}class Hn extends H{}class Xn extends H{}class Kn extends H{}class Vn extends I{constructor(){super("Could not parse response content as the length limit was reached")}}class Gn extends I{constructor(){super("Could not parse response content as the request was rejected by the content filter")}}class Re extends Error{constructor(e){super(e)}}const gr=/^[a-z][a-z0-9+.-]*:/i,_r=s=>gr.test(s);let K=s=>(K=Array.isArray,K(s)),dn=K;function yr(s){return typeof s!="object"?{}:s??{}}function wr(s){if(!s)return!0;for(const e in s)return!1;return!0}function br(s,e){return Object.prototype.hasOwnProperty.call(s,e)}function St(s){return s!=null&&typeof s=="object"&&!Array.isArray(s)}const Sr=(s,e)=>{if(typeof e!="number"||!Number.isInteger(e))throw new I(`${s} must be an integer`);if(e<0)throw new I(`${s} must be a positive integer`);return e},xr=s=>{try{return JSON.parse(s)}catch{return}},Be=s=>new Promise(e=>setTimeout(e,s)),we="5.10.2",Ar=()=>typeof window<"u"&&typeof window.document<"u"&&typeof navigator<"u";function vr(){return typeof Deno<"u"&&Deno.build!=null?"deno":typeof EdgeRuntime<"u"?"edge":Object.prototype.toString.call(typeof globalThis.process<"u"?globalThis.process:0)==="[object process]"?"node":"unknown"}const Cr=()=>{var t;const s=vr();if(s==="deno")return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":we,"X-Stainless-OS":mn(Deno.build.os),"X-Stainless-Arch":fn(Deno.build.arch),"X-Stainless-Runtime":"deno","X-Stainless-Runtime-Version":typeof Deno.version=="string"?Deno.version:((t=Deno.version)==null?void 0:t.deno)??"unknown"};if(typeof EdgeRuntime<"u")return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":we,"X-Stainless-OS":"Unknown","X-Stainless-Arch":`other:${EdgeRuntime}`,"X-Stainless-Runtime":"edge","X-Stainless-Runtime-Version":globalThis.process.version};if(s==="node")return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":we,"X-Stainless-OS":mn(globalThis.process.platform??"unknown"),"X-Stainless-Arch":fn(globalThis.process.arch??"unknown"),"X-Stainless-Runtime":"node","X-Stainless-Runtime-Version":globalThis.process.version??"unknown"};const e=Ir();return e?{"X-Stainless-Lang":"js","X-Stainless-Package-Version":we,"X-Stainless-OS":"Unknown","X-Stainless-Arch":"unknown","X-Stainless-Runtime":`browser:${e.browser}`,"X-Stainless-Runtime-Version":e.version}:{"X-Stainless-Lang":"js","X-Stainless-Package-Version":we,"X-Stainless-OS":"Unknown","X-Stainless-Arch":"unknown","X-Stainless-Runtime":"unknown","X-Stainless-Runtime-Version":"unknown"}};function Ir(){if(typeof navigator>"u"||!navigator)return null;const s=[{key:"edge",pattern:/Edge(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"ie",pattern:/MSIE(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"ie",pattern:/Trident(?:.*rv\:(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"chrome",pattern:/Chrome(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"firefox",pattern:/Firefox(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"safari",pattern:/(?:Version\W+(\d+)\.(\d+)(?:\.(\d+))?)?(?:\W+Mobile\S*)?\W+Safari/}];for(const{key:e,pattern:t}of s){const n=t.exec(navigator.userAgent);if(n){const r=n[1]||0,a=n[2]||0,i=n[3]||0;return{browser:e,version:`${r}.${a}.${i}`}}}return null}const fn=s=>s==="x32"?"x32":s==="x86_64"||s==="x64"?"x64":s==="arm"?"arm":s==="aarch64"||s==="arm64"?"arm64":s?`other:${s}`:"unknown",mn=s=>(s=s.toLowerCase(),s.includes("ios")?"iOS":s==="android"?"Android":s==="darwin"?"MacOS":s==="win32"?"Windows":s==="freebsd"?"FreeBSD":s==="openbsd"?"OpenBSD":s==="linux"?"Linux":s?`Other:${s}`:"Unknown");let pn;const Rr=()=>pn??(pn=Cr());function kr(){if(typeof fetch<"u")return fetch;throw new Error("`fetch` is not defined as a global; Either pass `fetch` to the client, `new OpenAI({ fetch })` or polyfill the global, `globalThis.fetch = fetch`")}function Qn(...s){const e=globalThis.ReadableStream;if(typeof e>"u")throw new Error("`ReadableStream` is not defined as a global; You will need to polyfill it, `globalThis.ReadableStream = ReadableStream`");return new e(...s)}function zn(s){let e=Symbol.asyncIterator in s?s[Symbol.asyncIterator]():s[Symbol.iterator]();return Qn({start(){},async pull(t){const{done:n,value:r}=await e.next();n?t.close():t.enqueue(r)},async cancel(){var t;await((t=e.return)==null?void 0:t.call(e))}})}function Yn(s){if(s[Symbol.asyncIterator])return s;const e=s.getReader();return{async next(){try{const t=await e.read();return t!=null&&t.done&&e.releaseLock(),t}catch(t){throw e.releaseLock(),t}},async return(){const t=e.cancel();return e.releaseLock(),await t,{done:!0,value:void 0}},[Symbol.asyncIterator](){return this}}}async function $r(s){var n,r;if(s===null||typeof s!="object")return;if(s[Symbol.asyncIterator]){await((r=(n=s[Symbol.asyncIterator]()).return)==null?void 0:r.call(n));return}const e=s.getReader(),t=e.cancel();e.releaseLock(),await t}const Or=({headers:s,body:e})=>({bodyHeaders:{"content-type":"application/json"},body:JSON.stringify(e)}),Zn="RFC3986",es=s=>String(s),gn={RFC1738:s=>String(s).replace(/%20/g,"+"),RFC3986:es},Er="RFC1738";let Pt=(s,e)=>(Pt=Object.hasOwn??Function.prototype.call.bind(Object.prototype.hasOwnProperty),Pt(s,e));const ee=(()=>{const s=[];for(let e=0;e<256;++e)s.push("%"+((e<16?"0":"")+e.toString(16)).toUpperCase());return s})(),xt=1024,Pr=(s,e,t,n,r)=>{if(s.length===0)return s;let a=s;if(typeof s=="symbol"?a=Symbol.prototype.toString.call(s):typeof s!="string"&&(a=String(s)),t==="iso-8859-1")return escape(a).replace(/%u[0-9a-f]{4}/gi,function(c){return"%26%23"+parseInt(c.slice(2),16)+"%3B"});let i="";for(let c=0;c<a.length;c+=xt){const l=a.length>=xt?a.slice(c,c+xt):a,u=[];for(let m=0;m<l.length;++m){let h=l.charCodeAt(m);if(h===45||h===46||h===95||h===126||h>=48&&h<=57||h>=65&&h<=90||h>=97&&h<=122||r===Er&&(h===40||h===41)){u[u.length]=l.charAt(m);continue}if(h<128){u[u.length]=ee[h];continue}if(h<2048){u[u.length]=ee[192|h>>6]+ee[128|h&63];continue}if(h<55296||h>=57344){u[u.length]=ee[224|h>>12]+ee[128|h>>6&63]+ee[128|h&63];continue}m+=1,h=65536+((h&1023)<<10|l.charCodeAt(m)&1023),u[u.length]=ee[240|h>>18]+ee[128|h>>12&63]+ee[128|h>>6&63]+ee[128|h&63]}i+=u.join("")}return i};function Tr(s){return!s||typeof s!="object"?!1:!!(s.constructor&&s.constructor.isBuffer&&s.constructor.isBuffer(s))}function _n(s,e){if(K(s)){const t=[];for(let n=0;n<s.length;n+=1)t.push(e(s[n]));return t}return e(s)}const ts={brackets(s){return String(s)+"[]"},comma:"comma",indices(s,e){return String(s)+"["+e+"]"},repeat(s){return String(s)}},ns=function(s,e){Array.prototype.push.apply(s,K(e)?e:[e])};let yn;const B={addQueryPrefix:!1,allowDots:!1,allowEmptyArrays:!1,arrayFormat:"indices",charset:"utf-8",charsetSentinel:!1,delimiter:"&",encode:!0,encodeDotInKeys:!1,encoder:Pr,encodeValuesOnly:!1,format:Zn,formatter:es,indices:!1,serializeDate(s){return(yn??(yn=Function.prototype.call.bind(Date.prototype.toISOString)))(s)},skipNulls:!1,strictNullHandling:!1};function Mr(s){return typeof s=="string"||typeof s=="number"||typeof s=="boolean"||typeof s=="symbol"||typeof s=="bigint"}const At={};function ss(s,e,t,n,r,a,i,c,l,u,m,h,g,d,b,w,A,O){let p=s,y=O,_=0,v=!1;for(;(y=y.get(At))!==void 0&&!v;){const T=y.get(s);if(_+=1,typeof T<"u"){if(T===_)throw new RangeError("Cyclic object value");v=!0}typeof y.get(At)>"u"&&(_=0)}if(typeof u=="function"?p=u(e,p):p instanceof Date?p=g==null?void 0:g(p):t==="comma"&&K(p)&&(p=_n(p,function(T){return T instanceof Date?g==null?void 0:g(T):T})),p===null){if(a)return l&&!w?l(e,B.encoder,A,"key",d):e;p=""}if(Mr(p)||Tr(p)){if(l){const T=w?e:l(e,B.encoder,A,"key",d);return[(b==null?void 0:b(T))+"="+(b==null?void 0:b(l(p,B.encoder,A,"value",d)))]}return[(b==null?void 0:b(e))+"="+(b==null?void 0:b(String(p)))]}const $=[];if(typeof p>"u")return $;let R;if(t==="comma"&&K(p))w&&l&&(p=_n(p,l)),R=[{value:p.length>0?p.join(",")||null:void 0}];else if(K(u))R=u;else{const T=Object.keys(p);R=m?T.sort(m):T}const F=c?String(e).replace(/\./g,"%2E"):String(e),x=n&&K(p)&&p.length===1?F+"[]":F;if(r&&K(p)&&p.length===0)return x+"[]";for(let T=0;T<R.length;++T){const M=R[T],se=typeof M=="object"&&typeof M.value<"u"?M.value:p[M];if(i&&se===null)continue;const me=h&&c?M.replace(/\./g,"%2E"):M,N=K(p)?typeof t=="function"?t(x,me):x:x+(h?"."+me:"["+me+"]");O.set(s,_);const ie=new WeakMap;ie.set(At,O),ns($,ss(se,N,t,n,r,a,i,c,t==="comma"&&w&&K(p)?null:l,u,m,h,g,d,b,w,A,ie))}return $}function Nr(s=B){if(typeof s.allowEmptyArrays<"u"&&typeof s.allowEmptyArrays!="boolean")throw new TypeError("`allowEmptyArrays` option can only be `true` or `false`, when provided");if(typeof s.encodeDotInKeys<"u"&&typeof s.encodeDotInKeys!="boolean")throw new TypeError("`encodeDotInKeys` option can only be `true` or `false`, when provided");if(s.encoder!==null&&typeof s.encoder<"u"&&typeof s.encoder!="function")throw new TypeError("Encoder has to be a function.");const e=s.charset||B.charset;if(typeof s.charset<"u"&&s.charset!=="utf-8"&&s.charset!=="iso-8859-1")throw new TypeError("The charset option must be either utf-8, iso-8859-1, or undefined");let t=Zn;if(typeof s.format<"u"){if(!Pt(gn,s.format))throw new TypeError("Unknown format option provided.");t=s.format}const n=gn[t];let r=B.filter;(typeof s.filter=="function"||K(s.filter))&&(r=s.filter);let a;if(s.arrayFormat&&s.arrayFormat in ts?a=s.arrayFormat:"indices"in s?a=s.indices?"indices":"repeat":a=B.arrayFormat,"commaRoundTrip"in s&&typeof s.commaRoundTrip!="boolean")throw new TypeError("`commaRoundTrip` must be a boolean, or absent");const i=typeof s.allowDots>"u"?s.encodeDotInKeys?!0:B.allowDots:!!s.allowDots;return{addQueryPrefix:typeof s.addQueryPrefix=="boolean"?s.addQueryPrefix:B.addQueryPrefix,allowDots:i,allowEmptyArrays:typeof s.allowEmptyArrays=="boolean"?!!s.allowEmptyArrays:B.allowEmptyArrays,arrayFormat:a,charset:e,charsetSentinel:typeof s.charsetSentinel=="boolean"?s.charsetSentinel:B.charsetSentinel,commaRoundTrip:!!s.commaRoundTrip,delimiter:typeof s.delimiter>"u"?B.delimiter:s.delimiter,encode:typeof s.encode=="boolean"?s.encode:B.encode,encodeDotInKeys:typeof s.encodeDotInKeys=="boolean"?s.encodeDotInKeys:B.encodeDotInKeys,encoder:typeof s.encoder=="function"?s.encoder:B.encoder,encodeValuesOnly:typeof s.encodeValuesOnly=="boolean"?s.encodeValuesOnly:B.encodeValuesOnly,filter:r,format:t,formatter:n,serializeDate:typeof s.serializeDate=="function"?s.serializeDate:B.serializeDate,skipNulls:typeof s.skipNulls=="boolean"?s.skipNulls:B.skipNulls,sort:typeof s.sort=="function"?s.sort:null,strictNullHandling:typeof s.strictNullHandling=="boolean"?s.strictNullHandling:B.strictNullHandling}}function jr(s,e={}){let t=s;const n=Nr(e);let r,a;typeof n.filter=="function"?(a=n.filter,t=a("",t)):K(n.filter)&&(a=n.filter,r=a);const i=[];if(typeof t!="object"||t===null)return"";const c=ts[n.arrayFormat],l=c==="comma"&&n.commaRoundTrip;r||(r=Object.keys(t)),n.sort&&r.sort(n.sort);const u=new WeakMap;for(let g=0;g<r.length;++g){const d=r[g];n.skipNulls&&t[d]===null||ns(i,ss(t[d],d,c,l,n.allowEmptyArrays,n.strictNullHandling,n.skipNulls,n.encodeDotInKeys,n.encode?n.encoder:null,n.filter,n.sort,n.allowDots,n.serializeDate,n.format,n.formatter,n.encodeValuesOnly,n.charset,u))}const m=i.join(n.delimiter);let h=n.addQueryPrefix===!0?"?":"";return n.charsetSentinel&&(n.charset==="iso-8859-1"?h+="utf8=%26%2310003%3B&":h+="utf8=%E2%9C%93&"),m.length>0?h+m:""}function Fr(s){let e=0;for(const r of s)e+=r.length;const t=new Uint8Array(e);let n=0;for(const r of s)t.set(r,n),n+=r.length;return t}let wn;function Jt(s){let e;return(wn??(e=new globalThis.TextEncoder,wn=e.encode.bind(e)))(s)}let bn;function Sn(s){let e;return(bn??(e=new globalThis.TextDecoder,bn=e.decode.bind(e)))(s)}var V,G;class pt{constructor(){V.set(this,void 0),G.set(this,void 0),C(this,V,new Uint8Array),C(this,G,null)}decode(e){if(e==null)return[];const t=e instanceof ArrayBuffer?new Uint8Array(e):typeof e=="string"?Jt(e):e;C(this,V,Fr([o(this,V,"f"),t]));const n=[];let r;for(;(r=Lr(o(this,V,"f"),o(this,G,"f")))!=null;){if(r.carriage&&o(this,G,"f")==null){C(this,G,r.index);continue}if(o(this,G,"f")!=null&&(r.index!==o(this,G,"f")+1||r.carriage)){n.push(Sn(o(this,V,"f").subarray(0,o(this,G,"f")-1))),C(this,V,o(this,V,"f").subarray(o(this,G,"f"))),C(this,G,null);continue}const a=o(this,G,"f")!==null?r.preceding-1:r.preceding,i=Sn(o(this,V,"f").subarray(0,a));n.push(i),C(this,V,o(this,V,"f").subarray(r.index)),C(this,G,null)}return n}flush(){return o(this,V,"f").length?this.decode(`
|
|
2
2
|
`):[]}}V=new WeakMap,G=new WeakMap;pt.NEWLINE_CHARS=new Set([`
|
|
3
3
|
`,"\r"]);pt.NEWLINE_REGEXP=/\r\n|[\n\r]/g;function Lr(s,e){for(let r=e??0;r<s.length;r++){if(s[r]===10)return{preceding:r,index:r+1,carriage:!1};if(s[r]===13)return{preceding:r,index:r+1,carriage:!0}}return null}function Dr(s){for(let n=0;n<s.length-1;n++){if(s[n]===10&&s[n+1]===10||s[n]===13&&s[n+1]===13)return n+2;if(s[n]===13&&s[n+1]===10&&n+3<s.length&&s[n+2]===13&&s[n+3]===10)return n+4}return-1}const ot={off:0,error:200,warn:300,info:400,debug:500},xn=(s,e,t)=>{if(s){if(br(ot,s))return s;q(t).warn(`${e} was set to ${JSON.stringify(s)}, expected one of ${JSON.stringify(Object.keys(ot))}`)}};function ke(){}function Je(s,e,t){return!e||ot[s]>ot[t]?ke:e[s].bind(e)}const Br={error:ke,warn:ke,info:ke,debug:ke};let An=new WeakMap;function q(s){const e=s.logger,t=s.logLevel??"off";if(!e)return Br;const n=An.get(e);if(n&&n[0]===t)return n[1];const r={error:Je("error",e,t),warn:Je("warn",e,t),info:Je("info",e,t),debug:Je("debug",e,t)};return An.set(e,[t,r]),r}const le=s=>(s.options&&(s.options={...s.options},delete s.options.headers),s.headers&&(s.headers=Object.fromEntries((s.headers instanceof Headers?[...s.headers]:Object.entries(s.headers)).map(([e,t])=>[e,e.toLowerCase()==="authorization"||e.toLowerCase()==="cookie"||e.toLowerCase()==="set-cookie"?"***":t]))),"retryOfRequestLogID"in s&&(s.retryOfRequestLogID&&(s.retryOf=s.retryOfRequestLogID),delete s.retryOfRequestLogID),s);var Ie;class ne{constructor(e,t,n){this.iterator=e,Ie.set(this,void 0),this.controller=t,C(this,Ie,n)}static fromSSEResponse(e,t,n){let r=!1;const a=n?q(n):console;async function*i(){if(r)throw new I("Cannot iterate over a consumed stream, use `.tee()` to split the stream.");r=!0;let c=!1;try{for await(const l of Wr(e,t))if(!c){if(l.data.startsWith("[DONE]")){c=!0;continue}if(l.event===null||l.event.startsWith("response.")||l.event.startsWith("image_edit.")||l.event.startsWith("image_generation.")||l.event.startsWith("transcript.")){let u;try{u=JSON.parse(l.data)}catch(m){throw a.error("Could not parse message into JSON:",l.data),a.error("From chunk:",l.raw),m}if(u&&u.error)throw new H(void 0,u.error,void 0,e.headers);yield u}else{let u;try{u=JSON.parse(l.data)}catch(m){throw console.error("Could not parse message into JSON:",l.data),console.error("From chunk:",l.raw),m}if(l.event=="error")throw new H(void 0,u.error,u.message,void 0);yield{event:l.event,data:u}}}c=!0}catch(l){if(Ot(l))return;throw l}finally{c||t.abort()}}return new ne(i,t,n)}static fromReadableStream(e,t,n){let r=!1;async function*a(){const c=new pt,l=Yn(e);for await(const u of l)for(const m of c.decode(u))yield m;for(const u of c.flush())yield u}async function*i(){if(r)throw new I("Cannot iterate over a consumed stream, use `.tee()` to split the stream.");r=!0;let c=!1;try{for await(const l of a())c||l&&(yield JSON.parse(l));c=!0}catch(l){if(Ot(l))return;throw l}finally{c||t.abort()}}return new ne(i,t,n)}[(Ie=new WeakMap,Symbol.asyncIterator)](){return this.iterator()}tee(){const e=[],t=[],n=this.iterator(),r=a=>({next:()=>{if(a.length===0){const i=n.next();e.push(i),t.push(i)}return a.shift()}});return[new ne(()=>r(e),this.controller,o(this,Ie,"f")),new ne(()=>r(t),this.controller,o(this,Ie,"f"))]}toReadableStream(){const e=this;let t;return Qn({async start(){t=e[Symbol.asyncIterator]()},async pull(n){try{const{value:r,done:a}=await t.next();if(a)return n.close();const i=Jt(JSON.stringify(r)+`
|
|
4
4
|
`);n.enqueue(i)}catch(r){n.error(r)}},async cancel(){var n;await((n=t.return)==null?void 0:n.call(t))}})}}async function*Wr(s,e){if(!s.body)throw e.abort(),typeof globalThis.navigator<"u"&&globalThis.navigator.product==="ReactNative"?new I("The default react-native fetch implementation does not support streaming. Please use expo/fetch: https://docs.expo.dev/versions/latest/sdk/expo/#expofetch-api"):new I("Attempted to iterate over a response with no body");const t=new qr,n=new pt,r=Yn(s.body);for await(const a of Ur(r))for(const i of n.decode(a)){const c=t.decode(i);c&&(yield c)}for(const a of n.flush()){const i=t.decode(a);i&&(yield i)}}async function*Ur(s){let e=new Uint8Array;for await(const t of s){if(t==null)continue;const n=t instanceof ArrayBuffer?new Uint8Array(t):typeof t=="string"?Jt(t):t;let r=new Uint8Array(e.length+n.length);r.set(e),r.set(n,e.length),e=r;let a;for(;(a=Dr(e))!==-1;)yield e.slice(0,a),e=e.slice(a)}e.length>0&&(yield e)}class qr{constructor(){this.event=null,this.data=[],this.chunks=[]}decode(e){if(e.endsWith("\r")&&(e=e.substring(0,e.length-1)),!e){if(!this.event&&!this.data.length)return null;const a={event:this.event,data:this.data.join(`
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c,j as s}from"./createSvgIcon-
|
|
1
|
+
import{c,j as s}from"./createSvgIcon-C_ElRFrf.js";const o=c(s.jsx("path",{d:"M17 3H5c-1.11 0-2 .9-2 2v14c0 1.1.89 2 2 2h14c1.1 0 2-.9 2-2V7zm-5 16c-1.66 0-3-1.34-3-3s1.34-3 3-3 3 1.34 3 3-1.34 3-3 3m3-10H5V5h10z"}),"Save");export{o as I};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{j as e}from"./createSvgIcon-
|
|
1
|
+
import{j as e}from"./createSvgIcon-C_ElRFrf.js";import{R as i}from"./iobroker_javascript__loadShare__react__loadShare__-B-pIv4x_.js";import{i as r,I as n}from"./index-DeFm7TiX.js";import{i as a}from"./index-BUU5hWiL.js";import l from"./ScriptEditorVanillaMonaco-BWe9MiKn.js";import{I as c}from"./Save--0ldNXLf.js";import"./_commonjsHelpers-Cpj98o6Y.js";import"./iobroker_javascript__mf_v__runtimeInit__mf_v__-CmuPLb0X.js";import"./inheritsLoose-CLw44UEv.js";import"./preload-helper-Dp1pzeXC.js";const o={textArea:{width:"calc(100% - 10px)",resize:"none"},dialog:{height:"95%"},fullHeight:{height:"100%",overflow:"hidden"},args:s=>({color:s.palette.mode==="dark"?"white":"black",height:30,width:"100%",fontSize:16}),argsTitle:s=>({color:s.palette.mode==="dark"?"white":"black",fontWeight:"bold"})};class k extends i.Component{constructor(t){super(t),this.state={changed:!1,source:!t.source&&t.isReturn?`
|
|
2
2
|
return false`:t.source}}componentDidMount(){setTimeout(()=>{var t;try{(t=window.document.getElementById("source-text-area"))==null||t.focus()}catch{}},100)}handleCancel(){this.props.onClose(!1)}handleOk(){(!this.props.isReturn||this.state.source.includes("return "))&&this.props.onClose(this.state.source)}onChange(t){this.setState({changed:!0,source:t})}render(){return e.jsxs(r.Dialog,{onClose:()=>!1,maxWidth:"lg",sx:{"& .MuiDialog-paper":o.dialog},fullWidth:!0,open:!0,"aria-labelledby":"source-dialog-title",children:[e.jsx(r.DialogTitle,{id:"source-dialog-title",children:a.I18n.t("Function editor")}),e.jsxs(r.DialogContent,{style:o.fullHeight,children:[this.props.args&&e.jsxs(r.Box,{sx:o.args,children:[e.jsx(r.Box,{component:"span",sx:o.argsTitle,children:a.I18n.t("function (")}),this.props.args,e.jsx(r.Box,{component:"span",sx:o.argsTitle,children:")"})]},"arguments"),e.jsx(l,{triggerPrettier:1,adapterName:this.props.adapterName,runningInstances:this.props.runningInstances,style:{...o.textArea,height:this.props.args?"calc(100% - 30px)":"100%"},name:"blockly",socket:this.props.socket,readOnly:!1,checkJs:!1,changed:this.state.changed,code:this.state.source,isDark:this.props.themeType==="dark",onChange:t=>this.onChange(t),language:"javascript"},"scriptEditor")]}),e.jsxs(r.DialogActions,{children:[e.jsx(r.Button,{variant:"contained",onClick:()=>this.handleOk(),color:"primary",startIcon:e.jsx(c,{}),children:a.I18n.t("Save")}),e.jsx(r.Button,{color:"grey",variant:"contained",onClick:()=>this.handleCancel(),startIcon:e.jsx(n,{}),children:a.I18n.t("Cancel")})]})]})}}export{k as default};
|
package/admin/assets/{ScriptEditorVanillaMonaco-Cs6PL8eZ.js → ScriptEditorVanillaMonaco-BWe9MiKn.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as n}from"./createSvgIcon-BDXN8whp.js";import{R as S}from"./iobroker_javascript__loadShare__react__loadShare__-B-pIv4x_.js";import{i as p,o as b,aA as C}from"./index-DsS-er0h.js";import{i as f}from"./index-quKi7QsD.js";import"./_commonjsHelpers-Cpj98o6Y.js";import"./iobroker_javascript__mf_v__runtimeInit__mf_v__-CmuPLb0X.js";import"./inheritsLoose-BLb-YnoJ.js";import"./preload-helper-Dp1pzeXC.js";function v(w){return/^script\.js\.global\./.test(w)}let O=0;function E(w){const t=/\x1b\[[0-9;]*m/g;return w.replace(t,"")}class R extends S.Component{monacoDiv=null;editor=null;monaco=window.monaco;insert="";originalCode;runningInstancesStr;monacoCounter=0;location;breakpoints;lastSearch="";typings={};decorations=[];triggerPrettier;constructor(t){super(t),this.state={name:"current",isDark:t.isDark||!1,language:t.language||"javascript",readOnly:t.readOnly||!1,alive:!0,check:!1,searchText:this.props.searchText||"",typingsLoaded:!1,showError:null},this.triggerPrettier=t.triggerPrettier,this.runningInstancesStr=JSON.stringify(this.props.runningInstances),this.originalCode=t.code||"",this.monacoDiv=S.createRef()}waitForMonaco(t){var e,s,o,r,l,a,h,g;let i=!!((r=(o=(s=(e=this.monaco)==null?void 0:e.languages)==null?void 0:s.typescript)==null?void 0:o.typescriptDefaults)!=null&&r.getCompilerOptions);if(!i||!this.props.runningInstances){if(this.monaco=window.monaco,i=!!((g=(h=(a=(l=this.monaco)==null?void 0:l.languages)==null?void 0:a.typescript)==null?void 0:h.typescriptDefaults)!=null&&g.getCompilerOptions),this.monacoCounter++,!i&&this.monacoCounter<20){console.log("wait for monaco loaded"),setTimeout(()=>this.waitForMonaco(t),200);return}this.monacoCounter>=20&&console.error("Cannot load monaco!")}else t&&t()}loadTypings(t){if(!this.editor)return;t||=this.props.runningInstances;const i=t&&Object.keys(t).find(e=>t==null?void 0:t[e]);i&&this.props.socket.sendTo(i.replace("system.adapter.",""),"loadTypings",null).then(e=>{this.setState({alive:!0,check:!0,typingsLoaded:!0}),this.setTypeCheck(!0),e.typings?(this.typings=e.typings,this.setEditorTypings(this.state.name)):console.error(`failed to load typings: ${e.error}`)})}componentDidMount(){var e,s,o,r,l,a,h,g,y,k,d,u;let t=!!((r=(o=(s=(e=this.monaco)==null?void 0:e.languages)==null?void 0:s.typescript)==null?void 0:o.typescriptDefaults)!=null&&r.getCompilerOptions);if((!t||!this.props.runningInstances)&&(this.monaco=window.monaco,t=!!((g=(h=(a=(l=this.monaco)==null?void 0:l.languages)==null?void 0:a.typescript)==null?void 0:h.typescriptDefaults)!=null&&g.getCompilerOptions),!t)){console.log("wait for monaco loaded..."),this.waitForMonaco(()=>this.componentDidMount());return}if(!this.editor&&t&&this.monaco){console.log("Init editor"),(k=(y=this.props).onRegisterSelect)==null||k.call(y,()=>{var m;if(this.editor){const D=this.editor.getSelection();if(D)return(m=this.editor.getModel())==null?void 0:m.getValueInRange(D)}});const c=this.monaco.languages.typescript.typescriptDefaults.getCompilerOptions();c.allowJs=!0,c.checkJs=this.props.checkJs!==!1,c.noLib=!0,c.lib=[],c.useUnknownInCatchVariables=!1,c.moduleResolution=this.monaco.languages.typescript.ModuleResolutionKind.NodeJs,c.target=this.monaco.languages.typescript.ScriptTarget.ESNext,c.module=this.monaco.languages.typescript.ModuleKind.ESNext,c.allowNonTsExtensions=!0,this.monaco.languages.typescript.typescriptDefaults.setCompilerOptions(c),this.setTypeCheck(!1),(d=this.monacoDiv)!=null&&d.current&&(this.editor=this.monaco.editor.create((u=this.monacoDiv)==null?void 0:u.current,{lineNumbers:"on",scrollBeyondLastLine:!1,automaticLayout:!0,glyphMargin:!!this.props.breakpoints,colorDecorators:!0}),this.editor.onDidChangeModelContent(()=>this.onChange()),this.loadTypings(),this.props.onForceSave&&this.editor.addCommand(this.monaco.KeyMod.CtrlCmd|this.monaco.KeyCode.KeyS,()=>this.props.onForceSave&&this.props.onForceSave()),setTimeout(()=>{this.highlightText(this.state.searchText),this.location=this.props.location||void 0,this.breakpoints=this.props.breakpoints,this.showDecorators()}))}const i={selectOnLineNumbers:!0,scrollBeyondLastLine:!1,automaticLayout:!0,readOnly:this.state.readOnly,language:this.state.language,isDark:this.state.isDark};this.setEditorOptions(i),this.editor&&(this.editor.focus(),this.editor.setValue(this.originalCode),this.props.onToggleBreakpoint?this.editor.onMouseDown(c=>{var D;const m=c.target;this.props.onToggleBreakpoint&&((D=m.detail)==null?void 0:D.glyphMarginLeft)!==void 0&&m.position&&this.props.onToggleBreakpoint(m.position.lineNumber-1)}):this.editor.onMouseDown(()=>{}))}setEditorOptions(t){var i;t&&(t.language&&this.setEditorLanguage(t.language),this.editor&&(t.readOnly!==void 0&&this.editor.updateOptions({readOnly:t.readOnly}),t.lineWrap!==void 0&&this.editor.updateOptions({wordWrap:t.lineWrap?"on":"off"})),t.typeCheck!==void 0&&this.setTypeCheck(t.typeCheck),t.isDark!==void 0&&((i=this.monaco)==null||i.editor.setTheme(t.isDark?"vs-dark":"vs")))}componentWillUnmount(){var t,i;this.editor&&((i=(t=this.props).onRegisterSelect)==null||i.call(t,null),this.editor.dispose(),this.editor=null)}async doPrettier(){var e,s,o,r;const t=this.props.runningInstances&&Object.keys(this.props.runningInstances).find(l=>{var a;return(a=this.props.runningInstances)==null?void 0:a[l]});if(!t){window.alert(f.I18n.t("No script adapter instance found to format the code"));return}const i=await this.props.socket.sendTo(t.replace("system.adapter.",""),"prettier",{code:(e=this.editor)==null?void 0:e.getValue(),type:this.state.language});i.error?this.setState({showError:{title:f.I18n.t("Error formatting code"),message:E(i.error)}}):i.code&&((s=this.editor)==null||s.setValue(i.code),(r=(o=this.props).onChange)==null||r.call(o,i.code),this.showDecorators())}setEditorLanguage(t){var e;if(!this.editor)return;const i=this.editor.getModel();if(i){const s=i.getValue(),o=i.uri.path,r=typeof o=="string"&&o.includes(".")?o.substring(0,o.lastIndexOf(".")):"index",l=t==="javascript"?"js":t==="typescript"?"ts":t;i.dispose();const a=t==="javascript"||t==="typescript"?"typescript":t,h=(e=this.monaco)==null?void 0:e.editor.createModel(s,a,this.monaco.Uri.from({scheme:window.location.protocol.replace(":",""),path:`${r}${O++}.${l}`}));h&&this.editor.setModel(h)}}setTypeCheck(t){var e,s;const i={noSemanticValidation:!this.state.alive||!t,noSyntaxValidation:!this.state.alive};(e=this.monaco)==null||e.languages.typescript.typescriptDefaults.setDiagnosticsOptions(i),(s=this.monaco)==null||s.languages.typescript.javascriptDefaults.setDiagnosticsOptions({noSemanticValidation:!this.state.alive||!t,noSyntaxValidation:!this.state.alive})}setEditorTypings(t=""){var o,r,l,a,h,g,y,k;const i=v(t),e=`${t}.d.ts`,s=[];for(const d of Object.keys(this.typings))i&&(d==="global.d.ts"||d.startsWith("script.js.global")&&d!==e)||s.push({filePath:d,content:this.typings[d]});if((a=(l=(r=(o=this.monaco)==null?void 0:o.languages)==null?void 0:r.typescript)==null?void 0:l.typescriptDefaults)!=null&&a.setExtraLibs)this.monaco.languages.typescript.typescriptDefaults.setExtraLibs(s);else if((k=(y=(g=(h=this.monaco)==null?void 0:h.languages)==null?void 0:g.typescript)==null?void 0:y.typescriptDefaults)!=null&&k.addExtraLib){const d=this.monaco.languages.typescript.typescriptDefaults.getExtraLibs();s.forEach(u=>{!d[u.filePath]&&this.monaco&&this.monaco.languages.typescript.typescriptDefaults.addExtraLib(u.content,u.filePath)})}}insertTextIntoEditor(t){if(!this.editor||!this.monaco)return;const i=this.editor.getSelection();if(i){const e=new this.monaco.Range(i.startLineNumber,i.startColumn,i.endLineNumber,i.endColumn);this.editor.executeEdits("",[{range:e,text:t,forceMoveMarkers:!0}])}this.editor.focus()}highlightText(t){var e;if(!this.editor||!this.monaco)return;const i=t?(e=this.editor.getModel())==null?void 0:e.findMatches(t,!0,!1,!1,null,!0):void 0;if(i!=null&&i.length)i.forEach(s=>{var o;return(o=this.editor)==null?void 0:o.setSelection(s.range)}),this.editor.revealLine(i[0].range.startLineNumber);else{const s=this.editor.getPosition();if(s){const o=s.lineNumber,r=s.column;this.editor.setSelection(new this.monaco.Range(o,r,o,r))}}}showDecorators(){var i;const t=[];if(this.location&&this.monaco&&(t.push({range:new this.monaco.Range(this.location.lineNumber+1,(this.location.columnNumber||0)+1,this.location.lineNumber+1,1e3),options:{isWholeLine:!1,className:this.props.isDark?"monacoCurrentLineDark":"monacoCurrentLine"}}),t.push({range:new this.monaco.Range(this.location.lineNumber+1,0,this.location.lineNumber+1,0),options:{isWholeLine:!0,className:this.props.isDark?"monacoCurrentFullLineDark":"monacoCurrentFullLine"}})),(i=this.breakpoints)==null||i.forEach(e=>{this.monaco&&t.push({range:new this.monaco.Range(e.location.lineNumber+1,0,e.location.lineNumber+1,100),options:{isWholeLine:!0,glyphMarginClassName:this.props.isDark?"monacoBreakPointDark":"monacoBreakPoint"}})}),this.editor){const e=this.editor.getModel();e&&(this.decorations=e.deltaDecorations(this.decorations,t))}}initNewScript(t,i){var e;this.setState({name:t}),this.originalCode=i||"",(e=this.editor)==null||e.setValue(i||""),this.highlightText(this.lastSearch),this.showDecorators(),this.setEditorTypings(t)}scrollToLineIfNeeded(t){if(this.editor){const i=this.editor.getVisibleRanges();(!i||!i[0]||i[0].startLineNumber>t||t>i[0].endLineNumber)&&this.editor.revealLineInCenter(t)}}UNSAFE_componentWillReceiveProps(t){const i={};this.state.name!==t.name&&this.initNewScript(t.name,t.code),JSON.stringify(t.runningInstances)!==this.runningInstancesStr&&(this.runningInstancesStr=JSON.stringify(t.runningInstances),this.state.typingsLoaded||this.loadTypings(t.runningInstances)),this.editor&&!t.changed&&(t.code!==this.originalCode||t.code!==this.editor.getValue())&&(this.originalCode=t.code||"",this.editor.setValue(this.originalCode),this.showDecorators(),this.location&&this.scrollToLineIfNeeded(this.location.lineNumber+1)),t.searchText!==this.lastSearch&&(this.lastSearch=t.searchText||"",this.highlightText(this.lastSearch)),JSON.stringify(t.location)!==JSON.stringify(this.location)&&JSON.stringify(t.breakpoints)!==JSON.stringify(this.breakpoints)?(this.location=t.location||void 0,this.breakpoints=t.breakpoints,this.showDecorators(),this.editor&&this.location&&this.scrollToLineIfNeeded(this.location.lineNumber+1)):JSON.stringify(t.breakpoints)!==JSON.stringify(this.breakpoints)?(this.breakpoints=t.breakpoints,this.showDecorators()):JSON.stringify(t.location)!==JSON.stringify(this.location)&&(this.location=t.location||void 0,this.showDecorators(),this.editor&&this.location&&this.scrollToLineIfNeeded(this.location.lineNumber+1)),this.state.language!==(t.language||"javascript")?(this.setState({language:t.language||"javascript"}),i.language=t.language||"javascript"):this.state.readOnly!==(t.readOnly||!1)?(this.setState({readOnly:t.readOnly||!1}),i.readOnly=t.readOnly):this.state.isDark!==(t.isDark||!1)&&(this.setState({isDark:t.isDark||!1}),i.isDark=t.isDark),this.setEditorOptions(i),this.insert!==t.insert&&(this.insert=t.insert||"",this.insert&&(console.log(`Insert text: ${this.insert}`),setTimeout(e=>{this.insertTextIntoEditor(e),setTimeout(()=>this.props.onInserted&&this.props.onInserted(),100)},100,this.insert)))}onChange(){var t,i;!this.props.readOnly&&this.editor&&((i=(t=this.props).onChange)==null||i.call(t,this.editor.getValue()))}renderErrorDialog(){return this.state.showError?this.state.showError.full?n.jsxs(p.Dialog,{open:!0,maxWidth:"md",onClose:()=>this.setState({showError:null}),children:[n.jsx(p.DialogTitle,{children:this.state.showError.title||f.I18n.t("Error")}),n.jsx(p.DialogContent,{children:n.jsx("pre",{children:n.jsx("code",{children:this.state.showError.message})})}),n.jsx(p.DialogActions,{children:n.jsxs(p.Button,{variant:"contained",startIcon:n.jsx(b,{}),onClick:()=>this.setState({showError:null}),children:[f.I18n.t("Close")," "]})})]}):n.jsx(p.Snackbar,{open:!0,autoHideDuration:5e3,onClose:()=>this.setState({showError:null}),message:this.state.showError.title,action:n.jsxs(S.Fragment,{children:[n.jsx(p.Button,{color:"secondary",size:"small",onClick:()=>this.setState({showError:{...this.state.showError,full:!0}}),children:f.I18n.t("More")}),n.jsx(p.IconButton,{size:"small","aria-label":"close",color:"inherit",onClick:()=>this.setState({showError:null}),children:n.jsx(b,{fontSize:"small"})})]})}):null}render(){var t,i,e;return!((e=(i=(t=this.monaco)==null?void 0:t.languages)==null?void 0:i.typescript)!=null&&e.typescriptDefaults)||!this.props.runningInstances?(setTimeout(()=>{this.monaco=window.monaco,this.forceUpdate()},200),null):(this.props.triggerPrettier!==this.triggerPrettier&&(this.triggerPrettier=this.props.triggerPrettier,setTimeout(()=>this.doPrettier().catch(s=>console.error("Error formatting code:",s)),50)),n.jsxs("div",{ref:this.monacoDiv,style:{...this.props.style,width:"100%",height:"100%",overflow:"hidden",position:"relative"},children:[this.renderErrorDialog(),!this.state.check&&n.jsx(p.Fab,{size:"small",title:f.I18n.t("Check is not active, because javascript adapter is disabled"),style:{bottom:10,right:10,opacity:.5,position:"absolute",zIndex:1,background:"red",color:"white"},color:"secondary",children:n.jsx(C,{})})]}))}}export{R as default};
|
|
1
|
+
import{j as n}from"./createSvgIcon-C_ElRFrf.js";import{R as S}from"./iobroker_javascript__loadShare__react__loadShare__-B-pIv4x_.js";import{i as p,o as b,av as C}from"./index-DeFm7TiX.js";import{i as f}from"./index-BUU5hWiL.js";import"./_commonjsHelpers-Cpj98o6Y.js";import"./iobroker_javascript__mf_v__runtimeInit__mf_v__-CmuPLb0X.js";import"./inheritsLoose-CLw44UEv.js";import"./preload-helper-Dp1pzeXC.js";function v(w){return/^script\.js\.global\./.test(w)}let O=0;function E(w){const t=/\x1b\[[0-9;]*m/g;return w.replace(t,"")}class R extends S.Component{monacoDiv=null;editor=null;monaco=window.monaco;insert="";originalCode;runningInstancesStr;monacoCounter=0;location;breakpoints;lastSearch="";typings={};decorations=[];triggerPrettier;constructor(t){super(t),this.state={name:"current",isDark:t.isDark||!1,language:t.language||"javascript",readOnly:t.readOnly||!1,alive:!0,check:!1,searchText:this.props.searchText||"",typingsLoaded:!1,showError:null},this.triggerPrettier=t.triggerPrettier,this.runningInstancesStr=JSON.stringify(this.props.runningInstances),this.originalCode=t.code||"",this.monacoDiv=S.createRef()}waitForMonaco(t){var e,s,o,r,l,a,h,g;let i=!!((r=(o=(s=(e=this.monaco)==null?void 0:e.languages)==null?void 0:s.typescript)==null?void 0:o.typescriptDefaults)!=null&&r.getCompilerOptions);if(!i||!this.props.runningInstances){if(this.monaco=window.monaco,i=!!((g=(h=(a=(l=this.monaco)==null?void 0:l.languages)==null?void 0:a.typescript)==null?void 0:h.typescriptDefaults)!=null&&g.getCompilerOptions),this.monacoCounter++,!i&&this.monacoCounter<20){console.log("wait for monaco loaded"),setTimeout(()=>this.waitForMonaco(t),200);return}this.monacoCounter>=20&&console.error("Cannot load monaco!")}else t&&t()}loadTypings(t){if(!this.editor)return;t||=this.props.runningInstances;const i=t&&Object.keys(t).find(e=>t==null?void 0:t[e]);i&&this.props.socket.sendTo(i.replace("system.adapter.",""),"loadTypings",null).then(e=>{this.setState({alive:!0,check:!0,typingsLoaded:!0}),this.setTypeCheck(!0),e.typings?(this.typings=e.typings,this.setEditorTypings(this.state.name)):console.error(`failed to load typings: ${e.error}`)})}componentDidMount(){var e,s,o,r,l,a,h,g,y,k,d,u;let t=!!((r=(o=(s=(e=this.monaco)==null?void 0:e.languages)==null?void 0:s.typescript)==null?void 0:o.typescriptDefaults)!=null&&r.getCompilerOptions);if((!t||!this.props.runningInstances)&&(this.monaco=window.monaco,t=!!((g=(h=(a=(l=this.monaco)==null?void 0:l.languages)==null?void 0:a.typescript)==null?void 0:h.typescriptDefaults)!=null&&g.getCompilerOptions),!t)){console.log("wait for monaco loaded..."),this.waitForMonaco(()=>this.componentDidMount());return}if(!this.editor&&t&&this.monaco){console.log("Init editor"),(k=(y=this.props).onRegisterSelect)==null||k.call(y,()=>{var m;if(this.editor){const D=this.editor.getSelection();if(D)return(m=this.editor.getModel())==null?void 0:m.getValueInRange(D)}});const c=this.monaco.languages.typescript.typescriptDefaults.getCompilerOptions();c.allowJs=!0,c.checkJs=this.props.checkJs!==!1,c.noLib=!0,c.lib=[],c.useUnknownInCatchVariables=!1,c.moduleResolution=this.monaco.languages.typescript.ModuleResolutionKind.NodeJs,c.target=this.monaco.languages.typescript.ScriptTarget.ESNext,c.module=this.monaco.languages.typescript.ModuleKind.ESNext,c.allowNonTsExtensions=!0,this.monaco.languages.typescript.typescriptDefaults.setCompilerOptions(c),this.setTypeCheck(!1),(d=this.monacoDiv)!=null&&d.current&&(this.editor=this.monaco.editor.create((u=this.monacoDiv)==null?void 0:u.current,{lineNumbers:"on",scrollBeyondLastLine:!1,automaticLayout:!0,glyphMargin:!!this.props.breakpoints,colorDecorators:!0}),this.editor.onDidChangeModelContent(()=>this.onChange()),this.loadTypings(),this.props.onForceSave&&this.editor.addCommand(this.monaco.KeyMod.CtrlCmd|this.monaco.KeyCode.KeyS,()=>this.props.onForceSave&&this.props.onForceSave()),setTimeout(()=>{this.highlightText(this.state.searchText),this.location=this.props.location||void 0,this.breakpoints=this.props.breakpoints,this.showDecorators()}))}const i={selectOnLineNumbers:!0,scrollBeyondLastLine:!1,automaticLayout:!0,readOnly:this.state.readOnly,language:this.state.language,isDark:this.state.isDark};this.setEditorOptions(i),this.editor&&(this.editor.focus(),this.editor.setValue(this.originalCode),this.props.onToggleBreakpoint?this.editor.onMouseDown(c=>{var D;const m=c.target;this.props.onToggleBreakpoint&&((D=m.detail)==null?void 0:D.glyphMarginLeft)!==void 0&&m.position&&this.props.onToggleBreakpoint(m.position.lineNumber-1)}):this.editor.onMouseDown(()=>{}))}setEditorOptions(t){var i;t&&(t.language&&this.setEditorLanguage(t.language),this.editor&&(t.readOnly!==void 0&&this.editor.updateOptions({readOnly:t.readOnly}),t.lineWrap!==void 0&&this.editor.updateOptions({wordWrap:t.lineWrap?"on":"off"})),t.typeCheck!==void 0&&this.setTypeCheck(t.typeCheck),t.isDark!==void 0&&((i=this.monaco)==null||i.editor.setTheme(t.isDark?"vs-dark":"vs")))}componentWillUnmount(){var t,i;this.editor&&((i=(t=this.props).onRegisterSelect)==null||i.call(t,null),this.editor.dispose(),this.editor=null)}async doPrettier(){var e,s,o,r;const t=this.props.runningInstances&&Object.keys(this.props.runningInstances).find(l=>{var a;return(a=this.props.runningInstances)==null?void 0:a[l]});if(!t){window.alert(f.I18n.t("No script adapter instance found to format the code"));return}const i=await this.props.socket.sendTo(t.replace("system.adapter.",""),"prettier",{code:(e=this.editor)==null?void 0:e.getValue(),type:this.state.language});i.error?this.setState({showError:{title:f.I18n.t("Error formatting code"),message:E(i.error)}}):i.code&&((s=this.editor)==null||s.setValue(i.code),(r=(o=this.props).onChange)==null||r.call(o,i.code),this.showDecorators())}setEditorLanguage(t){var e;if(!this.editor)return;const i=this.editor.getModel();if(i){const s=i.getValue(),o=i.uri.path,r=typeof o=="string"&&o.includes(".")?o.substring(0,o.lastIndexOf(".")):"index",l=t==="javascript"?"js":t==="typescript"?"ts":t;i.dispose();const a=t==="javascript"||t==="typescript"?"typescript":t,h=(e=this.monaco)==null?void 0:e.editor.createModel(s,a,this.monaco.Uri.from({scheme:window.location.protocol.replace(":",""),path:`${r}${O++}.${l}`}));h&&this.editor.setModel(h)}}setTypeCheck(t){var e,s;const i={noSemanticValidation:!this.state.alive||!t,noSyntaxValidation:!this.state.alive};(e=this.monaco)==null||e.languages.typescript.typescriptDefaults.setDiagnosticsOptions(i),(s=this.monaco)==null||s.languages.typescript.javascriptDefaults.setDiagnosticsOptions({noSemanticValidation:!this.state.alive||!t,noSyntaxValidation:!this.state.alive})}setEditorTypings(t=""){var o,r,l,a,h,g,y,k;const i=v(t),e=`${t}.d.ts`,s=[];for(const d of Object.keys(this.typings))i&&(d==="global.d.ts"||d.startsWith("script.js.global")&&d!==e)||s.push({filePath:d,content:this.typings[d]});if((a=(l=(r=(o=this.monaco)==null?void 0:o.languages)==null?void 0:r.typescript)==null?void 0:l.typescriptDefaults)!=null&&a.setExtraLibs)this.monaco.languages.typescript.typescriptDefaults.setExtraLibs(s);else if((k=(y=(g=(h=this.monaco)==null?void 0:h.languages)==null?void 0:g.typescript)==null?void 0:y.typescriptDefaults)!=null&&k.addExtraLib){const d=this.monaco.languages.typescript.typescriptDefaults.getExtraLibs();s.forEach(u=>{!d[u.filePath]&&this.monaco&&this.monaco.languages.typescript.typescriptDefaults.addExtraLib(u.content,u.filePath)})}}insertTextIntoEditor(t){if(!this.editor||!this.monaco)return;const i=this.editor.getSelection();if(i){const e=new this.monaco.Range(i.startLineNumber,i.startColumn,i.endLineNumber,i.endColumn);this.editor.executeEdits("",[{range:e,text:t,forceMoveMarkers:!0}])}this.editor.focus()}highlightText(t){var e;if(!this.editor||!this.monaco)return;const i=t?(e=this.editor.getModel())==null?void 0:e.findMatches(t,!0,!1,!1,null,!0):void 0;if(i!=null&&i.length)i.forEach(s=>{var o;return(o=this.editor)==null?void 0:o.setSelection(s.range)}),this.editor.revealLine(i[0].range.startLineNumber);else{const s=this.editor.getPosition();if(s){const o=s.lineNumber,r=s.column;this.editor.setSelection(new this.monaco.Range(o,r,o,r))}}}showDecorators(){var i;const t=[];if(this.location&&this.monaco&&(t.push({range:new this.monaco.Range(this.location.lineNumber+1,(this.location.columnNumber||0)+1,this.location.lineNumber+1,1e3),options:{isWholeLine:!1,className:this.props.isDark?"monacoCurrentLineDark":"monacoCurrentLine"}}),t.push({range:new this.monaco.Range(this.location.lineNumber+1,0,this.location.lineNumber+1,0),options:{isWholeLine:!0,className:this.props.isDark?"monacoCurrentFullLineDark":"monacoCurrentFullLine"}})),(i=this.breakpoints)==null||i.forEach(e=>{this.monaco&&t.push({range:new this.monaco.Range(e.location.lineNumber+1,0,e.location.lineNumber+1,100),options:{isWholeLine:!0,glyphMarginClassName:this.props.isDark?"monacoBreakPointDark":"monacoBreakPoint"}})}),this.editor){const e=this.editor.getModel();e&&(this.decorations=e.deltaDecorations(this.decorations,t))}}initNewScript(t,i){var e;this.setState({name:t}),this.originalCode=i||"",(e=this.editor)==null||e.setValue(i||""),this.highlightText(this.lastSearch),this.showDecorators(),this.setEditorTypings(t)}scrollToLineIfNeeded(t){if(this.editor){const i=this.editor.getVisibleRanges();(!i||!i[0]||i[0].startLineNumber>t||t>i[0].endLineNumber)&&this.editor.revealLineInCenter(t)}}UNSAFE_componentWillReceiveProps(t){const i={};this.state.name!==t.name&&this.initNewScript(t.name,t.code),JSON.stringify(t.runningInstances)!==this.runningInstancesStr&&(this.runningInstancesStr=JSON.stringify(t.runningInstances),this.state.typingsLoaded||this.loadTypings(t.runningInstances)),this.editor&&!t.changed&&(t.code!==this.originalCode||t.code!==this.editor.getValue())&&(this.originalCode=t.code||"",this.editor.setValue(this.originalCode),this.showDecorators(),this.location&&this.scrollToLineIfNeeded(this.location.lineNumber+1)),t.searchText!==this.lastSearch&&(this.lastSearch=t.searchText||"",this.highlightText(this.lastSearch)),JSON.stringify(t.location)!==JSON.stringify(this.location)&&JSON.stringify(t.breakpoints)!==JSON.stringify(this.breakpoints)?(this.location=t.location||void 0,this.breakpoints=t.breakpoints,this.showDecorators(),this.editor&&this.location&&this.scrollToLineIfNeeded(this.location.lineNumber+1)):JSON.stringify(t.breakpoints)!==JSON.stringify(this.breakpoints)?(this.breakpoints=t.breakpoints,this.showDecorators()):JSON.stringify(t.location)!==JSON.stringify(this.location)&&(this.location=t.location||void 0,this.showDecorators(),this.editor&&this.location&&this.scrollToLineIfNeeded(this.location.lineNumber+1)),this.state.language!==(t.language||"javascript")?(this.setState({language:t.language||"javascript"}),i.language=t.language||"javascript"):this.state.readOnly!==(t.readOnly||!1)?(this.setState({readOnly:t.readOnly||!1}),i.readOnly=t.readOnly):this.state.isDark!==(t.isDark||!1)&&(this.setState({isDark:t.isDark||!1}),i.isDark=t.isDark),this.setEditorOptions(i),this.insert!==t.insert&&(this.insert=t.insert||"",this.insert&&(console.log(`Insert text: ${this.insert}`),setTimeout(e=>{this.insertTextIntoEditor(e),setTimeout(()=>this.props.onInserted&&this.props.onInserted(),100)},100,this.insert)))}onChange(){var t,i;!this.props.readOnly&&this.editor&&((i=(t=this.props).onChange)==null||i.call(t,this.editor.getValue()))}renderErrorDialog(){return this.state.showError?this.state.showError.full?n.jsxs(p.Dialog,{open:!0,maxWidth:"md",onClose:()=>this.setState({showError:null}),children:[n.jsx(p.DialogTitle,{children:this.state.showError.title||f.I18n.t("Error")}),n.jsx(p.DialogContent,{children:n.jsx("pre",{children:n.jsx("code",{children:this.state.showError.message})})}),n.jsx(p.DialogActions,{children:n.jsxs(p.Button,{variant:"contained",startIcon:n.jsx(b,{}),onClick:()=>this.setState({showError:null}),children:[f.I18n.t("Close")," "]})})]}):n.jsx(p.Snackbar,{open:!0,autoHideDuration:5e3,onClose:()=>this.setState({showError:null}),message:this.state.showError.title,action:n.jsxs(S.Fragment,{children:[n.jsx(p.Button,{color:"secondary",size:"small",onClick:()=>this.setState({showError:{...this.state.showError,full:!0}}),children:f.I18n.t("More")}),n.jsx(p.IconButton,{size:"small","aria-label":"close",color:"inherit",onClick:()=>this.setState({showError:null}),children:n.jsx(b,{fontSize:"small"})})]})}):null}render(){var t,i,e;return!((e=(i=(t=this.monaco)==null?void 0:t.languages)==null?void 0:i.typescript)!=null&&e.typescriptDefaults)||!this.props.runningInstances?(setTimeout(()=>{this.monaco=window.monaco,this.forceUpdate()},200),null):(this.props.triggerPrettier!==this.triggerPrettier&&(this.triggerPrettier=this.props.triggerPrettier,setTimeout(()=>this.doPrettier().catch(s=>console.error("Error formatting code:",s)),50)),n.jsxs("div",{ref:this.monacoDiv,style:{...this.props.style,width:"100%",height:"100%",overflow:"hidden",position:"relative"},children:[this.renderErrorDialog(),!this.state.check&&n.jsx(p.Fab,{size:"small",title:f.I18n.t("Check is not active, because javascript adapter is disabled"),style:{bottom:10,right:10,opacity:.5,position:"absolute",zIndex:1,background:"red",color:"white"},color:"secondary",children:n.jsx(C,{})})]}))}}export{R as default};
|
|
@@ -27,4 +27,4 @@ const theme = ${JSON.stringify(t,null,2)};
|
|
|
27
27
|
theme.breakpoints = createBreakpoints(theme.breakpoints || {});
|
|
28
28
|
theme.transitions = createTransitions(theme.transitions || {});
|
|
29
29
|
|
|
30
|
-
export default theme;`}function Ke(e={},...t){const{breakpoints:r,mixins:n={},spacing:a,palette:o={},transitions:s={},typography:c={},shape:u,...f}=e;if(e.vars&&e.generateThemeVars===void 0)throw new Error(le(20));const p=Ht(o),d=zt(e);let m=K(d,{mixins:Go(d.breakpoints,n),palette:p,shadows:qo.slice(),typography:Ko(p,c),transitions:Jo(s),zIndex:{...ei}});return m=K(m,f),m=t.reduce((S,g)=>K(S,g),m),m.unstable_sxConfig={...mt,...f==null?void 0:f.unstable_sxConfig},m.unstable_sx=function(g){return Se({sx:g,theme:this})},m.toRuntimeSource=Ur,m}function Fi(...e){return Ke(...e)}function ri(e){let t;return e<1?t=5.11916*e**2:t=4.5*Math.log(e+1)+2,Math.round(t*10)/1e3}const ni=[...Array(25)].map((e,t)=>{if(t===0)return"none";const r=ri(t);return`linear-gradient(rgba(255 255 255 / ${r}), rgba(255 255 255 / ${r}))`});function Yr(e){return{inputPlaceholder:e==="dark"?.5:.42,inputUnderline:e==="dark"?.7:.42,switchTrackDisabled:e==="dark"?.2:.12,switchTrack:e==="dark"?.3:.38}}function qr(e){return e==="dark"?ni:[]}function ai(e){const{palette:t={mode:"light"},opacity:r,overlays:n,...a}=e,o=Ht(t);return{palette:o,opacity:{...Yr(o.mode),...r},overlays:n||qr(o.mode),...a}}function oi(e){var t;return!!e[0].match(/(cssVarPrefix|colorSchemeSelector|modularCssLayers|rootSelector|typography|mixins|breakpoints|direction|transitions)/)||!!e[0].match(/sxConfig$/)||e[0]==="palette"&&!!((t=e[1])!=null&&t.match(/(mode|contrastThreshold|tonalOffset)/))}const ii=e=>[...[...Array(25)].map((t,r)=>`--${e?`${e}-`:""}overlays-${r}`),`--${e?`${e}-`:""}palette-AppBar-darkBg`,`--${e?`${e}-`:""}palette-AppBar-darkColor`],si=e=>(t,r)=>{const n=e.rootSelector||":root",a=e.colorSchemeSelector;let o=a;if(a==="class"&&(o=".%s"),a==="data"&&(o="[data-%s]"),a!=null&&a.startsWith("data-")&&!a.includes("%s")&&(o=`[${a}="%s"]`),e.defaultColorScheme===t){if(t==="dark"){const s={};return ii(e.cssVarPrefix).forEach(c=>{s[c]=r[c],delete r[c]}),o==="media"?{[n]:r,"@media (prefers-color-scheme: dark)":{[n]:s}}:o?{[o.replace("%s",t)]:s,[`${n}, ${o.replace("%s",t)}`]:r}:{[n]:{...r,...s}}}if(o&&o!=="media")return`${n}, ${o.replace("%s",String(t))}`}else if(t){if(o==="media")return{[`@media (prefers-color-scheme: ${String(t)})`]:{[n]:r}};if(o)return o.replace("%s",String(t))}return n};function ci(e,t){t.forEach(r=>{e[r]||(e[r]={})})}function l(e,t,r){!e[t]&&r&&(e[t]=r)}function Te(e){return typeof e!="string"||!e.startsWith("hsl")?e:Gr(e)}function ne(e,t){`${t}Channel`in e||(e[`${t}Channel`]=Ae(Te(e[t])))}function li(e){return typeof e=="number"?`${e}px`:typeof e=="string"||typeof e=="function"||Array.isArray(e)?e:"8px"}const J=e=>{try{return e()}catch{}},ui=(e="mui")=>_o(e);function bt(e,t,r,n){if(!t)return;t=t===!0?{}:t;const a=n==="dark"?"dark":"light";if(!r){e[n]=ai({...t,palette:{mode:a,...t==null?void 0:t.palette}});return}const{palette:o,...s}=Ke({...r,palette:{mode:a,...t==null?void 0:t.palette}});return e[n]={...t,palette:o,opacity:{...Yr(a),...t==null?void 0:t.opacity},overlays:(t==null?void 0:t.overlays)||qr(a)},s}function fi(e={},...t){const{colorSchemes:r={light:!0},defaultColorScheme:n,disableCssColorScheme:a=!1,cssVarPrefix:o="mui",shouldSkipGeneratingVar:s=oi,colorSchemeSelector:c=r.light&&r.dark?"media":void 0,rootSelector:u=":root",...f}=e,p=Object.keys(r)[0],d=n||(r.light&&p!=="light"?"light":p),m=ui(o),{[d]:S,light:g,dark:h,...b}=r,v={...b};let A=S;if((d==="dark"&&!("dark"in r)||d==="light"&&!("light"in r))&&(A=!0),!A)throw new Error(le(21,d));const w=bt(v,A,f,d);g&&!v.light&&bt(v,g,void 0,"light"),h&&!v.dark&&bt(v,h,void 0,"dark");let x={defaultColorScheme:d,...w,cssVarPrefix:o,colorSchemeSelector:c,rootSelector:u,getCssVar:m,colorSchemes:v,font:{...Wo(w.typography),...w.font},spacing:li(f.spacing)};Object.keys(x.colorSchemes).forEach(L=>{const i=x.colorSchemes[L].palette,y=T=>{const E=T.split("-"),q=E[1],H=E[2];return m(T,i[q][H])};if(i.mode==="light"&&(l(i.common,"background","#fff"),l(i.common,"onBackground","#000")),i.mode==="dark"&&(l(i.common,"background","#000"),l(i.common,"onBackground","#fff")),ci(i,["Alert","AppBar","Avatar","Button","Chip","FilledInput","LinearProgress","Skeleton","Slider","SnackbarContent","SpeedDialAction","StepConnector","StepContent","Switch","TableCell","Tooltip"]),i.mode==="light"){l(i.Alert,"errorColor",O(i.error.light,.6)),l(i.Alert,"infoColor",O(i.info.light,.6)),l(i.Alert,"successColor",O(i.success.light,.6)),l(i.Alert,"warningColor",O(i.warning.light,.6)),l(i.Alert,"errorFilledBg",y("palette-error-main")),l(i.Alert,"infoFilledBg",y("palette-info-main")),l(i.Alert,"successFilledBg",y("palette-success-main")),l(i.Alert,"warningFilledBg",y("palette-warning-main")),l(i.Alert,"errorFilledColor",J(()=>i.getContrastText(i.error.main))),l(i.Alert,"infoFilledColor",J(()=>i.getContrastText(i.info.main))),l(i.Alert,"successFilledColor",J(()=>i.getContrastText(i.success.main))),l(i.Alert,"warningFilledColor",J(()=>i.getContrastText(i.warning.main))),l(i.Alert,"errorStandardBg",R(i.error.light,.9)),l(i.Alert,"infoStandardBg",R(i.info.light,.9)),l(i.Alert,"successStandardBg",R(i.success.light,.9)),l(i.Alert,"warningStandardBg",R(i.warning.light,.9)),l(i.Alert,"errorIconColor",y("palette-error-main")),l(i.Alert,"infoIconColor",y("palette-info-main")),l(i.Alert,"successIconColor",y("palette-success-main")),l(i.Alert,"warningIconColor",y("palette-warning-main")),l(i.AppBar,"defaultBg",y("palette-grey-100")),l(i.Avatar,"defaultBg",y("palette-grey-400")),l(i.Button,"inheritContainedBg",y("palette-grey-300")),l(i.Button,"inheritContainedHoverBg",y("palette-grey-A100")),l(i.Chip,"defaultBorder",y("palette-grey-400")),l(i.Chip,"defaultAvatarColor",y("palette-grey-700")),l(i.Chip,"defaultIconColor",y("palette-grey-700")),l(i.FilledInput,"bg","rgba(0, 0, 0, 0.06)"),l(i.FilledInput,"hoverBg","rgba(0, 0, 0, 0.09)"),l(i.FilledInput,"disabledBg","rgba(0, 0, 0, 0.12)"),l(i.LinearProgress,"primaryBg",R(i.primary.main,.62)),l(i.LinearProgress,"secondaryBg",R(i.secondary.main,.62)),l(i.LinearProgress,"errorBg",R(i.error.main,.62)),l(i.LinearProgress,"infoBg",R(i.info.main,.62)),l(i.LinearProgress,"successBg",R(i.success.main,.62)),l(i.LinearProgress,"warningBg",R(i.warning.main,.62)),l(i.Skeleton,"bg",`rgba(${y("palette-text-primaryChannel")} / 0.11)`),l(i.Slider,"primaryTrack",R(i.primary.main,.62)),l(i.Slider,"secondaryTrack",R(i.secondary.main,.62)),l(i.Slider,"errorTrack",R(i.error.main,.62)),l(i.Slider,"infoTrack",R(i.info.main,.62)),l(i.Slider,"successTrack",R(i.success.main,.62)),l(i.Slider,"warningTrack",R(i.warning.main,.62));const T=Me(i.background.default,.8);l(i.SnackbarContent,"bg",T),l(i.SnackbarContent,"color",J(()=>i.getContrastText(T))),l(i.SpeedDialAction,"fabHoverBg",Me(i.background.paper,.15)),l(i.StepConnector,"border",y("palette-grey-400")),l(i.StepContent,"border",y("palette-grey-400")),l(i.Switch,"defaultColor",y("palette-common-white")),l(i.Switch,"defaultDisabledColor",y("palette-grey-100")),l(i.Switch,"primaryDisabledColor",R(i.primary.main,.62)),l(i.Switch,"secondaryDisabledColor",R(i.secondary.main,.62)),l(i.Switch,"errorDisabledColor",R(i.error.main,.62)),l(i.Switch,"infoDisabledColor",R(i.info.main,.62)),l(i.Switch,"successDisabledColor",R(i.success.main,.62)),l(i.Switch,"warningDisabledColor",R(i.warning.main,.62)),l(i.TableCell,"border",R(Le(i.divider,1),.88)),l(i.Tooltip,"bg",Le(i.grey[700],.92))}if(i.mode==="dark"){l(i.Alert,"errorColor",R(i.error.light,.6)),l(i.Alert,"infoColor",R(i.info.light,.6)),l(i.Alert,"successColor",R(i.success.light,.6)),l(i.Alert,"warningColor",R(i.warning.light,.6)),l(i.Alert,"errorFilledBg",y("palette-error-dark")),l(i.Alert,"infoFilledBg",y("palette-info-dark")),l(i.Alert,"successFilledBg",y("palette-success-dark")),l(i.Alert,"warningFilledBg",y("palette-warning-dark")),l(i.Alert,"errorFilledColor",J(()=>i.getContrastText(i.error.dark))),l(i.Alert,"infoFilledColor",J(()=>i.getContrastText(i.info.dark))),l(i.Alert,"successFilledColor",J(()=>i.getContrastText(i.success.dark))),l(i.Alert,"warningFilledColor",J(()=>i.getContrastText(i.warning.dark))),l(i.Alert,"errorStandardBg",O(i.error.light,.9)),l(i.Alert,"infoStandardBg",O(i.info.light,.9)),l(i.Alert,"successStandardBg",O(i.success.light,.9)),l(i.Alert,"warningStandardBg",O(i.warning.light,.9)),l(i.Alert,"errorIconColor",y("palette-error-main")),l(i.Alert,"infoIconColor",y("palette-info-main")),l(i.Alert,"successIconColor",y("palette-success-main")),l(i.Alert,"warningIconColor",y("palette-warning-main")),l(i.AppBar,"defaultBg",y("palette-grey-900")),l(i.AppBar,"darkBg",y("palette-background-paper")),l(i.AppBar,"darkColor",y("palette-text-primary")),l(i.Avatar,"defaultBg",y("palette-grey-600")),l(i.Button,"inheritContainedBg",y("palette-grey-800")),l(i.Button,"inheritContainedHoverBg",y("palette-grey-700")),l(i.Chip,"defaultBorder",y("palette-grey-700")),l(i.Chip,"defaultAvatarColor",y("palette-grey-300")),l(i.Chip,"defaultIconColor",y("palette-grey-300")),l(i.FilledInput,"bg","rgba(255, 255, 255, 0.09)"),l(i.FilledInput,"hoverBg","rgba(255, 255, 255, 0.13)"),l(i.FilledInput,"disabledBg","rgba(255, 255, 255, 0.12)"),l(i.LinearProgress,"primaryBg",O(i.primary.main,.5)),l(i.LinearProgress,"secondaryBg",O(i.secondary.main,.5)),l(i.LinearProgress,"errorBg",O(i.error.main,.5)),l(i.LinearProgress,"infoBg",O(i.info.main,.5)),l(i.LinearProgress,"successBg",O(i.success.main,.5)),l(i.LinearProgress,"warningBg",O(i.warning.main,.5)),l(i.Skeleton,"bg",`rgba(${y("palette-text-primaryChannel")} / 0.13)`),l(i.Slider,"primaryTrack",O(i.primary.main,.5)),l(i.Slider,"secondaryTrack",O(i.secondary.main,.5)),l(i.Slider,"errorTrack",O(i.error.main,.5)),l(i.Slider,"infoTrack",O(i.info.main,.5)),l(i.Slider,"successTrack",O(i.success.main,.5)),l(i.Slider,"warningTrack",O(i.warning.main,.5));const T=Me(i.background.default,.98);l(i.SnackbarContent,"bg",T),l(i.SnackbarContent,"color",J(()=>i.getContrastText(T))),l(i.SpeedDialAction,"fabHoverBg",Me(i.background.paper,.15)),l(i.StepConnector,"border",y("palette-grey-600")),l(i.StepContent,"border",y("palette-grey-600")),l(i.Switch,"defaultColor",y("palette-grey-300")),l(i.Switch,"defaultDisabledColor",y("palette-grey-600")),l(i.Switch,"primaryDisabledColor",O(i.primary.main,.55)),l(i.Switch,"secondaryDisabledColor",O(i.secondary.main,.55)),l(i.Switch,"errorDisabledColor",O(i.error.main,.55)),l(i.Switch,"infoDisabledColor",O(i.info.main,.55)),l(i.Switch,"successDisabledColor",O(i.success.main,.55)),l(i.Switch,"warningDisabledColor",O(i.warning.main,.55)),l(i.TableCell,"border",O(Le(i.divider,1),.68)),l(i.Tooltip,"bg",Le(i.grey[700],.92))}ne(i.background,"default"),ne(i.background,"paper"),ne(i.common,"background"),ne(i.common,"onBackground"),ne(i,"divider"),Object.keys(i).forEach(T=>{const E=i[T];T!=="tonalOffset"&&E&&typeof E=="object"&&(E.main&&l(i[T],"mainChannel",Ae(Te(E.main))),E.light&&l(i[T],"lightChannel",Ae(Te(E.light))),E.dark&&l(i[T],"darkChannel",Ae(Te(E.dark))),E.contrastText&&l(i[T],"contrastTextChannel",Ae(Te(E.contrastText))),T==="text"&&(ne(i[T],"primary"),ne(i[T],"secondary")),T==="action"&&(E.active&&ne(i[T],"active"),E.selected&&ne(i[T],"selected")))})}),x=t.reduce((L,i)=>K(L,i),x);const $={prefix:o,disableCssColorScheme:a,shouldSkipGeneratingVar:s,getSelector:si(x)},{vars:k,generateThemeVars:C,generateStyleSheets:W}=Ro(x,$);return x.vars=k,Object.entries(x.colorSchemes[x.defaultColorScheme]).forEach(([L,i])=>{x[L]=i}),x.generateThemeVars=C,x.generateStyleSheets=W,x.generateSpacing=function(){return jr(f.spacing,jt(this))},x.getColorSchemeSelector=Bo(c),x.spacing=x.generateSpacing(),x.shouldSkipGeneratingVar=s,x.unstable_sxConfig={...mt,...f==null?void 0:f.unstable_sxConfig},x.unstable_sx=function(i){return Se({sx:i,theme:this})},x.toRuntimeSource=Ur,x}function pr(e,t,r){e.colorSchemes&&r&&(e.colorSchemes[t]={...r!==!0&&r,palette:Ht({...r===!0?{}:r.palette,mode:t})})}function di(e={},...t){const{palette:r,cssVariables:n=!1,colorSchemes:a=r?void 0:{light:!0},defaultColorScheme:o=r==null?void 0:r.mode,...s}=e,c=o||"light",u=a==null?void 0:a[c],f={...a,...r?{[c]:{...typeof u!="boolean"&&u,palette:r}}:void 0};if(n===!1){if(!("colorSchemes"in e))return Ke(e,...t);let p=r;"palette"in e||f[c]&&(f[c]!==!0?p=f[c].palette:c==="dark"&&(p={mode:"dark"}));const d=Ke({...e,palette:p},...t);return d.defaultColorScheme=c,d.colorSchemes=f,d.palette.mode==="light"&&(d.colorSchemes.light={...f.light!==!0&&f.light,palette:d.palette},pr(d,"dark",f.dark)),d.palette.mode==="dark"&&(d.colorSchemes.dark={...f.dark!==!0&&f.dark,palette:d.palette},pr(d,"light",f.light)),d}return!r&&!("light"in f)&&c==="light"&&(f.light=!0),fi({...s,colorSchemes:f,defaultColorScheme:c,...typeof n!="boolean"&&n},...t)}const mi=di();function pi(e){return e!=="ownerState"&&e!=="theme"&&e!=="sx"&&e!=="as"}const hi=e=>pi(e)&&e!=="classes",gi=mo({themeId:on,defaultTheme:mi,rootShouldForwardProp:hi}),yi=Po;function bi(e){return $o(e)}function Si(e){return zr("MuiSvgIcon",e)}const Li=co("MuiSvgIcon",["root","colorPrimary","colorSecondary","colorAction","colorError","colorDisabled","fontSizeInherit","fontSizeSmall","fontSizeMedium","fontSizeLarge"]),vi=e=>{const{color:t,fontSize:r,classes:n}=e,a={root:["root",t!=="inherit"&&`color${be(t)}`,`fontSize${be(r)}`]};return Ao(a,Si,n)},Ci=gi("svg",{name:"MuiSvgIcon",slot:"Root",overridesResolver:(e,t)=>{const{ownerState:r}=e;return[t.root,r.color!=="inherit"&&t[`color${be(r.color)}`],t[`fontSize${be(r.fontSize)}`]]}})(yi(({theme:e})=>{var t,r,n,a,o,s,c,u,f,p,d,m,S,g;return{userSelect:"none",width:"1em",height:"1em",display:"inline-block",flexShrink:0,transition:(a=(t=e.transitions)==null?void 0:t.create)==null?void 0:a.call(t,"fill",{duration:(n=(r=(e.vars??e).transitions)==null?void 0:r.duration)==null?void 0:n.shorter}),variants:[{props:h=>!h.hasSvgAsChild,style:{fill:"currentColor"}},{props:{fontSize:"inherit"},style:{fontSize:"inherit"}},{props:{fontSize:"small"},style:{fontSize:((s=(o=e.typography)==null?void 0:o.pxToRem)==null?void 0:s.call(o,20))||"1.25rem"}},{props:{fontSize:"medium"},style:{fontSize:((u=(c=e.typography)==null?void 0:c.pxToRem)==null?void 0:u.call(c,24))||"1.5rem"}},{props:{fontSize:"large"},style:{fontSize:((p=(f=e.typography)==null?void 0:f.pxToRem)==null?void 0:p.call(f,35))||"2.1875rem"}},...Object.entries((e.vars??e).palette).filter(([,h])=>h&&h.main).map(([h])=>{var b,v;return{props:{color:h},style:{color:(v=(b=(e.vars??e).palette)==null?void 0:b[h])==null?void 0:v.main}}}),{props:{color:"action"},style:{color:(m=(d=(e.vars??e).palette)==null?void 0:d.action)==null?void 0:m.active}},{props:{color:"disabled"},style:{color:(g=(S=(e.vars??e).palette)==null?void 0:S.action)==null?void 0:g.disabled}},{props:{color:"inherit"},style:{color:void 0}}]}})),$t=I.forwardRef(function(t,r){const n=bi({props:t,name:"MuiSvgIcon"}),{children:a,className:o,color:s="inherit",component:c="svg",fontSize:u="medium",htmlColor:f,inheritViewBox:p=!1,titleAccess:d,viewBox:m="0 0 24 24",...S}=n,g=I.isValidElement(a)&&a.type==="svg",h={...n,color:s,component:c,fontSize:u,instanceFontSize:t.fontSize,inheritViewBox:p,viewBox:m,hasSvgAsChild:g},b={};p||(b.viewBox=m);const v=vi(h);return We.jsxs(Ci,{as:c,className:io(v.root,o),focusable:"false",color:f,"aria-hidden":d?void 0:!0,role:d?"img":void 0,ref:r,...b,...S,...g&&a.props,ownerState:h,children:[g?a.props.children:a,d?We.jsx("title",{children:d}):null]})});$t.muiName="SvgIcon";function Mi(e,t){function r(n,a){return We.jsx($t,{"data-testid":`${t}Icon`,ref:a,...n,children:e})}return r.muiName=$t.muiName,I.memo(I.forwardRef(r))}export{bo as $,Ei as A,Ie as B,jr as C,ca as D,le as E,mi as F,fi as G,de as H,Oe as I,me as J,ue as K,oo as L,co as M,bi as N,Qo as O,_i as P,gi as Q,yi as R,ri as S,on as T,Wt as U,Gt as V,ko as W,hi as X,st as Y,pi as Z,St as _,Io as a,$t as a0,So as a1,Bi as a2,Gr as a3,ie as a4,pt as a5,xo as a6,Tt as a7,Fi as a8,Jo as a9,Xo as aa,ai as ab,oi as ac,Ko as ad,Go as ae,ii as af,Li as ag,Si as ah,Rt as ai,Or as aj,Bt as ak,Ai as al,Tr as am,Rr as an,Pi as ao,$i as ap,Ti as aq,Fn as ar,ln as as,ce as at,Ii as au,di as b,Mi as c,wo as d,ae as e,mt as f,pe as g,Se as h,Vn as i,We as j,io as k,mo as l,At as m,ro as n,ke as o,be as p,Ao as q,fe as r,na as s,zt as t,Ri as u,zr as v,oe as w,Oi as x,jt as y,K as z};
|
|
30
|
+
export default theme;`}function Ke(e={},...t){const{breakpoints:r,mixins:n={},spacing:a,palette:o={},transitions:s={},typography:c={},shape:u,...f}=e;if(e.vars&&e.generateThemeVars===void 0)throw new Error(le(20));const p=Ht(o),d=zt(e);let m=K(d,{mixins:Go(d.breakpoints,n),palette:p,shadows:qo.slice(),typography:Ko(p,c),transitions:Jo(s),zIndex:{...ei}});return m=K(m,f),m=t.reduce((S,g)=>K(S,g),m),m.unstable_sxConfig={...mt,...f==null?void 0:f.unstable_sxConfig},m.unstable_sx=function(g){return Se({sx:g,theme:this})},m.toRuntimeSource=Ur,m}function Fi(...e){return Ke(...e)}function ri(e){let t;return e<1?t=5.11916*e**2:t=4.5*Math.log(e+1)+2,Math.round(t*10)/1e3}const ni=[...Array(25)].map((e,t)=>{if(t===0)return"none";const r=ri(t);return`linear-gradient(rgba(255 255 255 / ${r}), rgba(255 255 255 / ${r}))`});function Yr(e){return{inputPlaceholder:e==="dark"?.5:.42,inputUnderline:e==="dark"?.7:.42,switchTrackDisabled:e==="dark"?.2:.12,switchTrack:e==="dark"?.3:.38}}function qr(e){return e==="dark"?ni:[]}function ai(e){const{palette:t={mode:"light"},opacity:r,overlays:n,...a}=e,o=Ht(t);return{palette:o,opacity:{...Yr(o.mode),...r},overlays:n||qr(o.mode),...a}}function oi(e){var t;return!!e[0].match(/(cssVarPrefix|colorSchemeSelector|modularCssLayers|rootSelector|typography|mixins|breakpoints|direction|transitions)/)||!!e[0].match(/sxConfig$/)||e[0]==="palette"&&!!((t=e[1])!=null&&t.match(/(mode|contrastThreshold|tonalOffset)/))}const ii=e=>[...[...Array(25)].map((t,r)=>`--${e?`${e}-`:""}overlays-${r}`),`--${e?`${e}-`:""}palette-AppBar-darkBg`,`--${e?`${e}-`:""}palette-AppBar-darkColor`],si=e=>(t,r)=>{const n=e.rootSelector||":root",a=e.colorSchemeSelector;let o=a;if(a==="class"&&(o=".%s"),a==="data"&&(o="[data-%s]"),a!=null&&a.startsWith("data-")&&!a.includes("%s")&&(o=`[${a}="%s"]`),e.defaultColorScheme===t){if(t==="dark"){const s={};return ii(e.cssVarPrefix).forEach(c=>{s[c]=r[c],delete r[c]}),o==="media"?{[n]:r,"@media (prefers-color-scheme: dark)":{[n]:s}}:o?{[o.replace("%s",t)]:s,[`${n}, ${o.replace("%s",t)}`]:r}:{[n]:{...r,...s}}}if(o&&o!=="media")return`${n}, ${o.replace("%s",String(t))}`}else if(t){if(o==="media")return{[`@media (prefers-color-scheme: ${String(t)})`]:{[n]:r}};if(o)return o.replace("%s",String(t))}return n};function ci(e,t){t.forEach(r=>{e[r]||(e[r]={})})}function l(e,t,r){!e[t]&&r&&(e[t]=r)}function Te(e){return typeof e!="string"||!e.startsWith("hsl")?e:Gr(e)}function ne(e,t){`${t}Channel`in e||(e[`${t}Channel`]=Ae(Te(e[t])))}function li(e){return typeof e=="number"?`${e}px`:typeof e=="string"||typeof e=="function"||Array.isArray(e)?e:"8px"}const J=e=>{try{return e()}catch{}},ui=(e="mui")=>_o(e);function bt(e,t,r,n){if(!t)return;t=t===!0?{}:t;const a=n==="dark"?"dark":"light";if(!r){e[n]=ai({...t,palette:{mode:a,...t==null?void 0:t.palette}});return}const{palette:o,...s}=Ke({...r,palette:{mode:a,...t==null?void 0:t.palette}});return e[n]={...t,palette:o,opacity:{...Yr(a),...t==null?void 0:t.opacity},overlays:(t==null?void 0:t.overlays)||qr(a)},s}function fi(e={},...t){const{colorSchemes:r={light:!0},defaultColorScheme:n,disableCssColorScheme:a=!1,cssVarPrefix:o="mui",shouldSkipGeneratingVar:s=oi,colorSchemeSelector:c=r.light&&r.dark?"media":void 0,rootSelector:u=":root",...f}=e,p=Object.keys(r)[0],d=n||(r.light&&p!=="light"?"light":p),m=ui(o),{[d]:S,light:g,dark:h,...b}=r,v={...b};let A=S;if((d==="dark"&&!("dark"in r)||d==="light"&&!("light"in r))&&(A=!0),!A)throw new Error(le(21,d));const w=bt(v,A,f,d);g&&!v.light&&bt(v,g,void 0,"light"),h&&!v.dark&&bt(v,h,void 0,"dark");let x={defaultColorScheme:d,...w,cssVarPrefix:o,colorSchemeSelector:c,rootSelector:u,getCssVar:m,colorSchemes:v,font:{...Wo(w.typography),...w.font},spacing:li(f.spacing)};Object.keys(x.colorSchemes).forEach(L=>{const i=x.colorSchemes[L].palette,y=T=>{const E=T.split("-"),q=E[1],H=E[2];return m(T,i[q][H])};if(i.mode==="light"&&(l(i.common,"background","#fff"),l(i.common,"onBackground","#000")),i.mode==="dark"&&(l(i.common,"background","#000"),l(i.common,"onBackground","#fff")),ci(i,["Alert","AppBar","Avatar","Button","Chip","FilledInput","LinearProgress","Skeleton","Slider","SnackbarContent","SpeedDialAction","StepConnector","StepContent","Switch","TableCell","Tooltip"]),i.mode==="light"){l(i.Alert,"errorColor",O(i.error.light,.6)),l(i.Alert,"infoColor",O(i.info.light,.6)),l(i.Alert,"successColor",O(i.success.light,.6)),l(i.Alert,"warningColor",O(i.warning.light,.6)),l(i.Alert,"errorFilledBg",y("palette-error-main")),l(i.Alert,"infoFilledBg",y("palette-info-main")),l(i.Alert,"successFilledBg",y("palette-success-main")),l(i.Alert,"warningFilledBg",y("palette-warning-main")),l(i.Alert,"errorFilledColor",J(()=>i.getContrastText(i.error.main))),l(i.Alert,"infoFilledColor",J(()=>i.getContrastText(i.info.main))),l(i.Alert,"successFilledColor",J(()=>i.getContrastText(i.success.main))),l(i.Alert,"warningFilledColor",J(()=>i.getContrastText(i.warning.main))),l(i.Alert,"errorStandardBg",R(i.error.light,.9)),l(i.Alert,"infoStandardBg",R(i.info.light,.9)),l(i.Alert,"successStandardBg",R(i.success.light,.9)),l(i.Alert,"warningStandardBg",R(i.warning.light,.9)),l(i.Alert,"errorIconColor",y("palette-error-main")),l(i.Alert,"infoIconColor",y("palette-info-main")),l(i.Alert,"successIconColor",y("palette-success-main")),l(i.Alert,"warningIconColor",y("palette-warning-main")),l(i.AppBar,"defaultBg",y("palette-grey-100")),l(i.Avatar,"defaultBg",y("palette-grey-400")),l(i.Button,"inheritContainedBg",y("palette-grey-300")),l(i.Button,"inheritContainedHoverBg",y("palette-grey-A100")),l(i.Chip,"defaultBorder",y("palette-grey-400")),l(i.Chip,"defaultAvatarColor",y("palette-grey-700")),l(i.Chip,"defaultIconColor",y("palette-grey-700")),l(i.FilledInput,"bg","rgba(0, 0, 0, 0.06)"),l(i.FilledInput,"hoverBg","rgba(0, 0, 0, 0.09)"),l(i.FilledInput,"disabledBg","rgba(0, 0, 0, 0.12)"),l(i.LinearProgress,"primaryBg",R(i.primary.main,.62)),l(i.LinearProgress,"secondaryBg",R(i.secondary.main,.62)),l(i.LinearProgress,"errorBg",R(i.error.main,.62)),l(i.LinearProgress,"infoBg",R(i.info.main,.62)),l(i.LinearProgress,"successBg",R(i.success.main,.62)),l(i.LinearProgress,"warningBg",R(i.warning.main,.62)),l(i.Skeleton,"bg",`rgba(${y("palette-text-primaryChannel")} / 0.11)`),l(i.Slider,"primaryTrack",R(i.primary.main,.62)),l(i.Slider,"secondaryTrack",R(i.secondary.main,.62)),l(i.Slider,"errorTrack",R(i.error.main,.62)),l(i.Slider,"infoTrack",R(i.info.main,.62)),l(i.Slider,"successTrack",R(i.success.main,.62)),l(i.Slider,"warningTrack",R(i.warning.main,.62));const T=Me(i.background.default,.8);l(i.SnackbarContent,"bg",T),l(i.SnackbarContent,"color",J(()=>i.getContrastText(T))),l(i.SpeedDialAction,"fabHoverBg",Me(i.background.paper,.15)),l(i.StepConnector,"border",y("palette-grey-400")),l(i.StepContent,"border",y("palette-grey-400")),l(i.Switch,"defaultColor",y("palette-common-white")),l(i.Switch,"defaultDisabledColor",y("palette-grey-100")),l(i.Switch,"primaryDisabledColor",R(i.primary.main,.62)),l(i.Switch,"secondaryDisabledColor",R(i.secondary.main,.62)),l(i.Switch,"errorDisabledColor",R(i.error.main,.62)),l(i.Switch,"infoDisabledColor",R(i.info.main,.62)),l(i.Switch,"successDisabledColor",R(i.success.main,.62)),l(i.Switch,"warningDisabledColor",R(i.warning.main,.62)),l(i.TableCell,"border",R(Le(i.divider,1),.88)),l(i.Tooltip,"bg",Le(i.grey[700],.92))}if(i.mode==="dark"){l(i.Alert,"errorColor",R(i.error.light,.6)),l(i.Alert,"infoColor",R(i.info.light,.6)),l(i.Alert,"successColor",R(i.success.light,.6)),l(i.Alert,"warningColor",R(i.warning.light,.6)),l(i.Alert,"errorFilledBg",y("palette-error-dark")),l(i.Alert,"infoFilledBg",y("palette-info-dark")),l(i.Alert,"successFilledBg",y("palette-success-dark")),l(i.Alert,"warningFilledBg",y("palette-warning-dark")),l(i.Alert,"errorFilledColor",J(()=>i.getContrastText(i.error.dark))),l(i.Alert,"infoFilledColor",J(()=>i.getContrastText(i.info.dark))),l(i.Alert,"successFilledColor",J(()=>i.getContrastText(i.success.dark))),l(i.Alert,"warningFilledColor",J(()=>i.getContrastText(i.warning.dark))),l(i.Alert,"errorStandardBg",O(i.error.light,.9)),l(i.Alert,"infoStandardBg",O(i.info.light,.9)),l(i.Alert,"successStandardBg",O(i.success.light,.9)),l(i.Alert,"warningStandardBg",O(i.warning.light,.9)),l(i.Alert,"errorIconColor",y("palette-error-main")),l(i.Alert,"infoIconColor",y("palette-info-main")),l(i.Alert,"successIconColor",y("palette-success-main")),l(i.Alert,"warningIconColor",y("palette-warning-main")),l(i.AppBar,"defaultBg",y("palette-grey-900")),l(i.AppBar,"darkBg",y("palette-background-paper")),l(i.AppBar,"darkColor",y("palette-text-primary")),l(i.Avatar,"defaultBg",y("palette-grey-600")),l(i.Button,"inheritContainedBg",y("palette-grey-800")),l(i.Button,"inheritContainedHoverBg",y("palette-grey-700")),l(i.Chip,"defaultBorder",y("palette-grey-700")),l(i.Chip,"defaultAvatarColor",y("palette-grey-300")),l(i.Chip,"defaultIconColor",y("palette-grey-300")),l(i.FilledInput,"bg","rgba(255, 255, 255, 0.09)"),l(i.FilledInput,"hoverBg","rgba(255, 255, 255, 0.13)"),l(i.FilledInput,"disabledBg","rgba(255, 255, 255, 0.12)"),l(i.LinearProgress,"primaryBg",O(i.primary.main,.5)),l(i.LinearProgress,"secondaryBg",O(i.secondary.main,.5)),l(i.LinearProgress,"errorBg",O(i.error.main,.5)),l(i.LinearProgress,"infoBg",O(i.info.main,.5)),l(i.LinearProgress,"successBg",O(i.success.main,.5)),l(i.LinearProgress,"warningBg",O(i.warning.main,.5)),l(i.Skeleton,"bg",`rgba(${y("palette-text-primaryChannel")} / 0.13)`),l(i.Slider,"primaryTrack",O(i.primary.main,.5)),l(i.Slider,"secondaryTrack",O(i.secondary.main,.5)),l(i.Slider,"errorTrack",O(i.error.main,.5)),l(i.Slider,"infoTrack",O(i.info.main,.5)),l(i.Slider,"successTrack",O(i.success.main,.5)),l(i.Slider,"warningTrack",O(i.warning.main,.5));const T=Me(i.background.default,.98);l(i.SnackbarContent,"bg",T),l(i.SnackbarContent,"color",J(()=>i.getContrastText(T))),l(i.SpeedDialAction,"fabHoverBg",Me(i.background.paper,.15)),l(i.StepConnector,"border",y("palette-grey-600")),l(i.StepContent,"border",y("palette-grey-600")),l(i.Switch,"defaultColor",y("palette-grey-300")),l(i.Switch,"defaultDisabledColor",y("palette-grey-600")),l(i.Switch,"primaryDisabledColor",O(i.primary.main,.55)),l(i.Switch,"secondaryDisabledColor",O(i.secondary.main,.55)),l(i.Switch,"errorDisabledColor",O(i.error.main,.55)),l(i.Switch,"infoDisabledColor",O(i.info.main,.55)),l(i.Switch,"successDisabledColor",O(i.success.main,.55)),l(i.Switch,"warningDisabledColor",O(i.warning.main,.55)),l(i.TableCell,"border",O(Le(i.divider,1),.68)),l(i.Tooltip,"bg",Le(i.grey[700],.92))}ne(i.background,"default"),ne(i.background,"paper"),ne(i.common,"background"),ne(i.common,"onBackground"),ne(i,"divider"),Object.keys(i).forEach(T=>{const E=i[T];T!=="tonalOffset"&&E&&typeof E=="object"&&(E.main&&l(i[T],"mainChannel",Ae(Te(E.main))),E.light&&l(i[T],"lightChannel",Ae(Te(E.light))),E.dark&&l(i[T],"darkChannel",Ae(Te(E.dark))),E.contrastText&&l(i[T],"contrastTextChannel",Ae(Te(E.contrastText))),T==="text"&&(ne(i[T],"primary"),ne(i[T],"secondary")),T==="action"&&(E.active&&ne(i[T],"active"),E.selected&&ne(i[T],"selected")))})}),x=t.reduce((L,i)=>K(L,i),x);const $={prefix:o,disableCssColorScheme:a,shouldSkipGeneratingVar:s,getSelector:si(x)},{vars:k,generateThemeVars:C,generateStyleSheets:W}=Ro(x,$);return x.vars=k,Object.entries(x.colorSchemes[x.defaultColorScheme]).forEach(([L,i])=>{x[L]=i}),x.generateThemeVars=C,x.generateStyleSheets=W,x.generateSpacing=function(){return jr(f.spacing,jt(this))},x.getColorSchemeSelector=Bo(c),x.spacing=x.generateSpacing(),x.shouldSkipGeneratingVar=s,x.unstable_sxConfig={...mt,...f==null?void 0:f.unstable_sxConfig},x.unstable_sx=function(i){return Se({sx:i,theme:this})},x.toRuntimeSource=Ur,x}function pr(e,t,r){e.colorSchemes&&r&&(e.colorSchemes[t]={...r!==!0&&r,palette:Ht({...r===!0?{}:r.palette,mode:t})})}function di(e={},...t){const{palette:r,cssVariables:n=!1,colorSchemes:a=r?void 0:{light:!0},defaultColorScheme:o=r==null?void 0:r.mode,...s}=e,c=o||"light",u=a==null?void 0:a[c],f={...a,...r?{[c]:{...typeof u!="boolean"&&u,palette:r}}:void 0};if(n===!1){if(!("colorSchemes"in e))return Ke(e,...t);let p=r;"palette"in e||f[c]&&(f[c]!==!0?p=f[c].palette:c==="dark"&&(p={mode:"dark"}));const d=Ke({...e,palette:p},...t);return d.defaultColorScheme=c,d.colorSchemes=f,d.palette.mode==="light"&&(d.colorSchemes.light={...f.light!==!0&&f.light,palette:d.palette},pr(d,"dark",f.dark)),d.palette.mode==="dark"&&(d.colorSchemes.dark={...f.dark!==!0&&f.dark,palette:d.palette},pr(d,"light",f.light)),d}return!r&&!("light"in f)&&c==="light"&&(f.light=!0),fi({...s,colorSchemes:f,defaultColorScheme:c,...typeof n!="boolean"&&n},...t)}const mi=di();function pi(e){return e!=="ownerState"&&e!=="theme"&&e!=="sx"&&e!=="as"}const hi=e=>pi(e)&&e!=="classes",gi=mo({themeId:on,defaultTheme:mi,rootShouldForwardProp:hi}),yi=Po;function bi(e){return $o(e)}function Si(e){return zr("MuiSvgIcon",e)}const Li=co("MuiSvgIcon",["root","colorPrimary","colorSecondary","colorAction","colorError","colorDisabled","fontSizeInherit","fontSizeSmall","fontSizeMedium","fontSizeLarge"]),vi=e=>{const{color:t,fontSize:r,classes:n}=e,a={root:["root",t!=="inherit"&&`color${be(t)}`,`fontSize${be(r)}`]};return Ao(a,Si,n)},Ci=gi("svg",{name:"MuiSvgIcon",slot:"Root",overridesResolver:(e,t)=>{const{ownerState:r}=e;return[t.root,r.color!=="inherit"&&t[`color${be(r.color)}`],t[`fontSize${be(r.fontSize)}`]]}})(yi(({theme:e})=>{var t,r,n,a,o,s,c,u,f,p,d,m,S,g;return{userSelect:"none",width:"1em",height:"1em",display:"inline-block",flexShrink:0,transition:(a=(t=e.transitions)==null?void 0:t.create)==null?void 0:a.call(t,"fill",{duration:(n=(r=(e.vars??e).transitions)==null?void 0:r.duration)==null?void 0:n.shorter}),variants:[{props:h=>!h.hasSvgAsChild,style:{fill:"currentColor"}},{props:{fontSize:"inherit"},style:{fontSize:"inherit"}},{props:{fontSize:"small"},style:{fontSize:((s=(o=e.typography)==null?void 0:o.pxToRem)==null?void 0:s.call(o,20))||"1.25rem"}},{props:{fontSize:"medium"},style:{fontSize:((u=(c=e.typography)==null?void 0:c.pxToRem)==null?void 0:u.call(c,24))||"1.5rem"}},{props:{fontSize:"large"},style:{fontSize:((p=(f=e.typography)==null?void 0:f.pxToRem)==null?void 0:p.call(f,35))||"2.1875rem"}},...Object.entries((e.vars??e).palette).filter(([,h])=>h&&h.main).map(([h])=>{var b,v;return{props:{color:h},style:{color:(v=(b=(e.vars??e).palette)==null?void 0:b[h])==null?void 0:v.main}}}),{props:{color:"action"},style:{color:(m=(d=(e.vars??e).palette)==null?void 0:d.action)==null?void 0:m.active}},{props:{color:"disabled"},style:{color:(g=(S=(e.vars??e).palette)==null?void 0:S.action)==null?void 0:g.disabled}},{props:{color:"inherit"},style:{color:void 0}}]}})),$t=I.forwardRef(function(t,r){const n=bi({props:t,name:"MuiSvgIcon"}),{children:a,className:o,color:s="inherit",component:c="svg",fontSize:u="medium",htmlColor:f,inheritViewBox:p=!1,titleAccess:d,viewBox:m="0 0 24 24",...S}=n,g=I.isValidElement(a)&&a.type==="svg",h={...n,color:s,component:c,fontSize:u,instanceFontSize:t.fontSize,inheritViewBox:p,viewBox:m,hasSvgAsChild:g},b={};p||(b.viewBox=m);const v=vi(h);return We.jsxs(Ci,{as:c,className:io(v.root,o),focusable:"false",color:f,"aria-hidden":d?void 0:!0,role:d?"img":void 0,ref:r,...b,...S,...g&&a.props,ownerState:h,children:[g?a.props.children:a,d?We.jsx("title",{children:d}):null]})});$t.muiName="SvgIcon";function Mi(e,t){function r(n,a){return We.jsx($t,{"data-testid":`${t}Icon`,ref:a,...n,children:e})}return r.muiName=$t.muiName,I.memo(I.forwardRef(r))}export{bo as $,Ei as A,Ie as B,jr as C,ca as D,le as E,mi as F,fi as G,oo as H,de as I,Oe as J,me as K,ue as L,co as M,bi as N,Qo as O,_i as P,gi as Q,yi as R,ri as S,on as T,Wt as U,Gt as V,ko as W,hi as X,st as Y,pi as Z,St as _,Io as a,$t as a0,So as a1,Bi as a2,Gr as a3,ie as a4,pt as a5,xo as a6,Tt as a7,Fi as a8,Jo as a9,Xo as aa,ai as ab,oi as ac,Ko as ad,Go as ae,ii as af,Li as ag,Si as ah,Rt as ai,Or as aj,Bt as ak,Ai as al,Tr as am,Rr as an,Pi as ao,$i as ap,Ti as aq,Fn as ar,ln as as,ce as at,Ii as au,di as b,Mi as c,wo as d,ae as e,mt as f,pe as g,Se as h,Vn as i,We as j,io as k,mo as l,At as m,ro as n,ke as o,be as p,Ao as q,fe as r,na as s,zt as t,Ri as u,zr as v,oe as w,Oi as x,jt as y,K as z};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{j as t}from"./createSvgIcon-C_ElRFrf.js";import{i as u}from"./iobroker_javascript__loadShare__react__loadShare__-B-pIv4x_.js";import{u as pe,a as xe,i as x,M as X,C as te,G as be,b as Ce,c as he,I as we,S as J,d as ve,e as le,j as je,D as Ie,f as Oe}from"./index-BUU5hWiL.js";import{i as N,C as Se}from"./index-DeFm7TiX.js";import"./_commonjsHelpers-Cpj98o6Y.js";import"./iobroker_javascript__mf_v__runtimeInit__mf_v__-CmuPLb0X.js";import"./inheritsLoose-CLw44UEv.js";import"./preload-helper-Dp1pzeXC.js";function Ae(n){const s=pe().getMonitor(),[i,r]=xe(s,n);return u.useEffect(()=>s.subscribeToOffsetChange(r)),u.useEffect(()=>s.subscribeToStateChange(r)),i}let V;function ye(){return V||(V=new Image,V.src="data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw=="),V}const De="_wrapperRules_nnott_1",ke="_rootWrapper_nnott_9",Ne="_addClass_nnott_14",ne={wrapperRules:De,rootWrapper:ke,addClass:Ne},$e="_switchesItem_10ls3_1",Be="_switchesItemActive_10ls3_28",Ee="_iconTheme_10ls3_36",se={switchesItem:$e,switchesItemActive:Be,iconTheme:Ee},ue=({name:n,id:e,active:s,icon:i,adapter:r,socket:o,onDoubleClick:c,title:l,onTouchMove:d,style:I})=>t.jsxs("div",{onDoubleClick:c,onTouchMove:d,title:l?x.I18n.t(l):void 0,className:x.Utils.clsx(se.switchesItem,s&&se.switchesItemActive,`block-${e}`),children:[t.jsx(X,{iconName:i,className:se.iconTheme,adapter:r,socket:o,style:I}),t.jsx("span",{children:n?x.I18n.t(n):""})]},e),Me="_cardStyle_8rq8v_1",qe="_cardStyleActive_8rq8v_17",He="_controlMenu_8rq8v_22",Te="_closeBtn_8rq8v_31",We="_isDelete_8rq8v_73",Pe="_drag_mobile_8rq8v_90",G={cardStyle:Me,cardStyleActive:qe,controlMenu:He,closeBtn:Te,isDelete:We,drag_mobile:Pe};function K(n,e,s){let i;switch(n){case"actions":if(s==="else")return i={...e,actions:{...e[n],else:[...e[n].else]}},i;if(s==="then")return i={...e,actions:{...e[n],then:[...e[n].then]}},i;throw console.error(`Unknown additionalParameter: ${s}`),new Error(`Unknown additionalParameter: ${s}`);case"triggers":return i={...e,triggers:[...e.triggers]},i;case"conditions":return i={...e,conditions:[...e.conditions]},i;default:throw new Error(`Unknown name: ${n}`)}}function z(n,e,s,i){var r;switch(n){case"actions":return e.actions[s]=e.actions[s].filter(o=>o._id!==i),e;case"conditions":return e.conditions[s]=(r=e.conditions[s])==null?void 0:r.filter(o=>o._id!==i),e;case"triggers":default:return e.triggers=e.triggers.filter(o=>o._id!==i),e}}function Fe(n,e,s){const{_id:i,acceptedBy:r}=n;let o;if(!r||!e[r])return console.warn(`Cannot find ${r}`),e;switch(r){case"actions":if(o=e.actions[s].find(c=>c._id===i),!o)console.warn(`Cannot find ${i}`);else{const c=e.actions[s].indexOf(o);e.actions[s][c]=n}return e;case"conditions":if(o=e.conditions[s].find(c=>c._id===i),!o)console.warn(`Cannot find ${i}`);else{const c=e.conditions[s].indexOf(o);e.conditions[s][c]=n}return e;default:if(o=e.triggers.find(c=>c._id===i),!o)console.warn(`Cannot find ${i}`);else{const c=e.triggers.indexOf(o);e.triggers[c]=n}return e}}const me=u.memo(n=>{var B;const{setUserRules:e,userRules:s,_id:i,id:r,blockValue:o,active:c,acceptedBy:l,isTourOpen:d,setTourStep:I,tourStep:S}=n,[O,_]=u.useState(null),{blocks:a,socket:k,onUpdate:H,setOnUpdate:w,onDebugMessage:f,enableSimulation:b}=u.useContext(te),p=u.useCallback(m=>a==null?void 0:a.find(C=>C.getStaticData().id===m),[a]),h=u.useCallback(m=>{const C=Fe(m,s,o);C&&e(C)},[s]),v=m=>{m.currentTarget!==O&&_(m.currentTarget)},M=()=>_(null),W=u.useMemo(()=>{const m=p(r)||be;return t.jsx(m,{...n,notFound:!p(r),isTourOpen:d,setTourStep:I,tourStep:S,onUpdate:H,setOnUpdate:w,enableSimulation:b,onDebugMessage:f,onChange:h,className:void 0,socket:k})},[s,H,f,b]),[$,q]=u.useState(!1);return t.jsxs("div",{onMouseMove:v,onMouseEnter:v,onMouseLeave:M,onMouseDown:m=>{if(m.ctrlKey){let C;const j=K(l,s,o);l==="conditions"?(C=j.conditions[o].find(g=>g._id===i),C&&j.conditions[o].splice(j.conditions[o].indexOf(C),0,{...C,_id:Date.now()})):l==="actions"?(C=j.actions[o].find(g=>g._id===i),C&&j.actions[o].splice(j.actions[o].indexOf(C),0,{...C,_id:Date.now()})):(C=j.triggers.find(g=>g._id===i),C&&j.triggers.splice(j[l].indexOf(C),0,{...C,_id:Date.now()})),e(j)}},id:"height",style:c?{width:(((B=document.getElementById("width"))==null?void 0:B.clientWidth)||0)-70}:void 0,className:`${G.cardStyle} ${c?G.cardStyleActive:null} ${$?G.isDelete:null}`,children:[t.jsx("div",{className:G.drag_mobile}),W,e&&t.jsx("div",{className:G.controlMenu,style:O?{opacity:1}:{opacity:0},children:t.jsx("div",{onClick:()=>{let m=K(l,s,o);m=z(l,m,o,i),q(!0),setTimeout(()=>{l==="triggers"&&w(!0),e(m)},300)},className:G.closeBtn})})]})}),Ue={position:"fixed",pointerEvents:"none",zIndex:100,left:0,top:0,width:"100%",height:"100%"},Je=(n,e,s)=>{if(!n||!e)return{display:"none"};let{x:i,y:r}=e;const o=`translate(${i}px, ${r}px)`;return{transform:o,WebkitTransform:o}},Le=n=>{const{itemType:e,isDragging:s,item:i,initialOffset:r,currentOffset:o,targetIds:c}=Ae(d=>({item:d.getItem(),itemType:d.getItemType(),initialOffset:d.getInitialSourceClientOffset(),currentOffset:d.getSourceClientOffset(),isDragging:d.isDragging(),targetIds:d.getTargetIds()})),l=()=>{switch(e){case"box":return c.length?t.jsx(me,{active:!0,...i,allBlocks:n.allBlocks}):t.jsx(ue,{active:!0,...i,socket:n.socket});default:return null}};return s?t.jsx("div",{style:Ue,children:t.jsx("div",{style:Je(r,o),children:l()})}):null},ze="_border_wrpm3_1",Ge="_emptyBlockStyle_wrpm3_6",Ke="_emptyBlock_wrpm3_6",Qe="_selectOnChange_wrpm3_22",Xe="_selectOnChangeHelp_wrpm3_28",Ye="_selectOnChangeHelpIcon_wrpm3_34",Ze="_emptyBlockNone_wrpm3_49",Ve="_mainBlockItemRules_wrpm3_55",Re="_nameBlockItems_wrpm3_63",et="_contentBlockItem_wrpm3_73",tt="_wrapperMargin_wrpm3_81",nt="_contentHeightOn_wrpm3_87",st="_contentHeightOff_wrpm3_99",ot="_cardAdd_wrpm3_105",it="_blockCardAdd_wrpm3_125",ct="_addClassOverflow_wrpm3_136",at="_addClassHeight_wrpm3_140",D={border:ze,emptyBlockStyle:Ge,emptyBlock:Ke,selectOnChange:Qe,selectOnChangeHelp:Xe,selectOnChangeHelpIcon:Ye,emptyBlockNone:Ze,mainBlockItemRules:Ve,nameBlockItems:Re,contentBlockItem:et,wrapperMargin:tt,contentHeightOn:nt,contentHeightOff:st,cardAdd:ot,blockCardAdd:it,addClassOverflow:ct,addClassHeight:at};function re(n,e){const[s,i]=u.useState(window.localStorage.getItem(e)?JSON.parse(window.localStorage.getItem(e)||""):n);return[s,o=>{window.localStorage.setItem(e,JSON.stringify(o)),i(o)},!!window.localStorage.getItem(e)]}function rt(n,e){let s=0,i=null,r;return function(...o){const c=Date.now();r=o,c-s>=e?(s=c,n.apply(this,o)):i||(i=setTimeout(()=>{s=Date.now(),i=null,n.apply(this,r)},e-(c-s)))}}function ee(n){if(Array.isArray(n))return n.map(e=>ee(e));if(typeof n=="function")return n.bind(null);if(n&&typeof n=="object"){const e={};return Object.keys(n).forEach(s=>{e[s]=ee(n[s])}),e}return n}const oe=rt((n,e)=>n(e),0);function R(n,e){const s=e.find(i=>i._id===n);return{card:s,index:s?e.indexOf(s):-1}}function ie(n,e,s,i,r,o,c,l,d){const{card:I,index:S}=R(n,s);if(!(S<e&&l<d)&&!(S>e&&l>d)&&I&&S!==e){const O=ee(s);O.splice(S,1),O.splice(e,0,I);const _=ee(r);switch(o){case"actions":_.actions[c]=O,oe(i,_);return;case"conditions":_.conditions[c]=O,oe(i,_);return;default:_.triggers=O,oe(i,_);return}}}const lt="_drag_7xfhc_1",dt="_root_7xfhc_11",de={drag:lt,root:dt},_e=({typeBlock:n,allProperties:e,id:s,isActive:i,setUserRules:r,userRules:o,children:c,_id:l,blockValue:d})=>{const{setOnUpdate:I}=u.useContext(te),[{opacity:S},O,_]=Ce({type:"box",item:()=>({...e,id:s,isActive:i,_id:l}),end:(w,f)=>{const{acceptedBy:b}=w,p=f.getDropResult();let h;if(!p)return typeof l=="number"&&!f.getTargetIds().length&&(h=K(b,o,d),h=z(b,h,d,l),r(h)),null;if(p.blockValue!==d){const v=typeof l=="number"?l:Date.now();h=K(b,o,p.blockValue);const M={id:w.id,acceptedBy:w.acceptedBy};switch(b){case"actions":return d&&(h=z("actions",h,d,v)),h=z("actions",h,p.blockValue,v),h.actions[p.blockValue].push({...M,_id:v}),r(h);case"conditions":return typeof d=="number"&&(h=z("conditions",h,d,v)),h=z("conditions",h,p.blockValue,v),h.conditions[p.blockValue].push({...M,_id:v}),r(h);default:return I(!0),h=z("triggers",h,p.blockValue,v),h.triggers.push({...M,_id:v}),r(h)}}},collect:w=>({opacity:w.isDragging()?.4:1,isDragging:w.isDragging()})}),a=u.useRef(null),[,k]=he({accept:"box",canDrop:()=>!1,hover({_id:w,acceptedBy:f},b){var W;if(!a.current||n!==f)return;const p=(W=a.current)==null?void 0:W.getBoundingClientRect(),h=(p.bottom-p.top)/2,v=b.getClientOffset(),M=((v==null?void 0:v.y)||0)-p.top;if(l&&w!==l)switch(f){case"actions":if(d==="then"||d==="else"){const{index:$}=R(l,o.actions[d]);$!==w&&ie(w,$,o[f][d],r,o,f,d,M,h)}return;case"conditions":if(typeof d=="number"){const{index:$}=R(l,o[f][d]);$!==w&&ie(w,$,o[f][d],r,o,f,d,M,h)}return;default:{const{index:$}=R(l,o[f]);$!==w&&ie(w,$,o[f],r,o,f,void 0,M,h);return}}}});u.useEffect(()=>{_(ye(),{captureDraggingState:!0})},[]),O(k(a));const H=window.innerWidth<600;return t.jsxs("div",{ref:H&&l?null:a,className:de.root,style:{opacity:S},children:[t.jsx("div",{className:l?de.drag:null,ref:l&&H?a:null}),c]})},ft=({onClose:n,open:e})=>t.jsxs(N.Dialog,{open:e,onClose:n,"aria-labelledby":"alert-dialog-title","aria-describedby":"alert-dialog-description",children:[t.jsx(N.DialogContent,{children:t.jsxs("div",{style:{fontSize:"1rem",fontFamily:'"Roboto", "Helvetica", "Arial", sans-serif',fontWeight:400,lineHeight:1.5,letterSpacing:"0.00938em"},children:[t.jsx("h3",{children:x.I18n.t("On condition change")}),t.jsx("div",{children:x.I18n.t("help_on_change")}),t.jsx("h3",{children:x.I18n.t("Just check")}),t.jsx("div",{children:x.I18n.t("help_just_check")})]})}),t.jsx(N.DialogActions,{children:t.jsx(N.Button,{onClick:n,color:"primary",autoFocus:!0,startIcon:t.jsx(Se,{}),children:x.I18n.t("OK")})})]}),gt=({onClose:n,open:e})=>t.jsxs(N.Dialog,{open:e,onClose:n,"aria-labelledby":"alert-dialog-title","aria-describedby":"alert-dialog-description",children:[t.jsx(N.DialogContent,{children:t.jsxs(N.DialogContentText,{id:"alert-dialog-description",children:[t.jsx("h3",{children:x.I18n.t("On condition change")}),t.jsx("div",{children:x.I18n.t("help_on_change")}),t.jsx("h3",{children:x.I18n.t("Just check")}),t.jsx("div",{children:x.I18n.t("help_just_check")})]})}),t.jsx(N.DialogActions,{children:t.jsx(N.Button,{onClick:n,color:"primary",autoFocus:!0,children:x.I18n.t("OK")})})]}),fe=({size:n,blockValue:e,boolean:s,typeBlock:i,userRules:r,setUserRules:o,animation:c,setTourStep:l,tourStep:d,isTourOpen:I,theme:S,themeType:O,themeName:_})=>{var T;const[a,k]=u.useState(!1),[H,w]=u.useState(!1),[f,b]=u.useState(!1),[p,h]=u.useState("");s===void 0&&(s=!0);const v=he({accept:"box",drop:()=>({blockValue:e}),hover:({acceptedBy:A,_id:L},Y)=>{k(A===i),b(!!L),h(Y.getHandlerId()||"")},canDrop:({acceptedBy:A})=>(w(A===i),A===i),collect:A=>{var L;return{isOver:A.isOver(),canDrop:((L=A.getItem())==null?void 0:L.acceptedBy)===i,offset:A.getClientOffset(),targetId:A.getHandlerId()}}}),M=v[0],{canDrop:W,isOver:$,offset:q,targetId:B}=M,m=v[1];u.useEffect(()=>{h("")},[q]);const C=W&&$;let j="";C?j=a?"#00fb003d":"#fb00002e":W?j=H?"#00fb003d":"#fb00002e":q&&(j=B===p?"#fb00002e":"");let g;return i==="actions"?g=r.actions[e]:i==="conditions"?g=r.conditions[e]:g=r.triggers,t.jsx("div",{ref:m,style:{backgroundColor:j},className:`${x.Utils.clsx(D.contentBlockItem,n&&D.addClassHeight)} ${s?c?D.contentHeightOn:null:D.contentHeightOff}`,children:t.jsxs("div",{className:D.wrapperMargin,children:[g.map(A=>t.jsx(_e,{typeBlock:i,...A,blockValue:e,allProperties:A,userRules:r,setUserRules:o,children:t.jsx(me,{...A,isTourOpen:I,setTourStep:l,tourStep:d,settings:A,blockValue:e,userRules:r,setUserRules:o,theme:S,themeType:O,themeName:_})},A._id)),t.jsx("div",{style:C&&a&&!f?{height:((T=document.getElementById("height"))==null?void 0:T.clientHeight)||200}:void 0,className:`${D.emptyBlockStyle} ${C&&a&&!f?D.emptyBlock:D.emptyBlockNone}`})]})})},ce=({size:n,typeBlock:e,name:s,nameAdditionally:i,additionally:r,border:o,userRules:c,setUserRules:l,iconName:d,adapter:I,socket:S,setTourStep:O,tourStep:_,isTourOpen:a,theme:k,themeType:H,themeName:w})=>{const[f,b,p]=re(e==="actions"?!1:[],`additionallyClickItems_${e}`),[h,v]=u.useState(!1),[M,W]=u.useState(!1);u.useEffect(()=>{if(e==="conditions"&&(f==null?void 0:f.length)!==c.conditions.length-1){const B=[];c.conditions.forEach((m,C)=>{C>0&&B.push({_id:Date.now(),open:!0})}),b([...f,...B])}e==="actions"&&!p&&c.actions.else.length&&b(!0)},[]);const[$,q]=u.useState(!1);return t.jsxs("div",{className:`${x.Utils.clsx(D.mainBlockItemRules,n&&D.addClassOverflow)} ${o&&!n?D.border:null}`,children:[t.jsxs("span",{id:"width",className:D.nameBlockItems,children:[t.jsx(X,{iconName:d,className:D.iconThemCard,adapter:I,socket:S}),s]}),e==="conditions"?t.jsxs("div",{style:{width:"100%"},children:[t.jsxs(N.Select,{variant:"standard",className:D.selectOnChange,value:c.justCheck||!1,onChange:B=>{const m=K("conditions",c);m.justCheck=B.target.value==="true",l(m)},children:[t.jsx(N.MenuItem,{value:"false",children:x.I18n.t("on condition change")}),t.jsx(N.MenuItem,{value:"true",children:x.I18n.t("just check")})]}),t.jsx(N.IconButton,{size:"small",title:x.I18n.t("Explanation"),className:D.selectOnChangeHelp,onClick:()=>v(!0),children:t.jsx(we,{className:D.selectOnChangeHelpIcon})})]}):null,t.jsx(fe,{setTourStep:O,tourStep:_,isTourOpen:a,blockValue:e==="actions"?"then":e==="conditions"?0:e,typeBlock:e,setUserRules:l,userRules:c,theme:k,themeName:w,themeType:H,size:n}),r&&[...Array(e==="actions"?1:c.conditions.length-1)].map((B,m)=>{const C=(j=m)=>e==="actions"?!!f:!!f.find((g,T)=>T===j&&g.open);return t.jsxs(u.Fragment,{children:[t.jsxs("div",{onClick:()=>{if(e==="actions")return b(!f),null;let j=JSON.parse(JSON.stringify(f));if(c.conditions[m+1].length)return j[m].open=!j[m].open,b(j),null;j=j.filter((g,T)=>T!==m),b(j),q(m),setTimeout(()=>{q(!1),l({...c,conditions:[...c.conditions.filter((g,T)=>T!==m+1)]})},250)},className:D.blockCardAdd,children:[C()?"-":"+",t.jsx("div",{className:D.cardAdd,children:i})]},m),t.jsx(fe,{blockValue:e==="actions"?"else":e==="conditions"?m+1:e,typeBlock:e,setUserRules:l,userRules:c,boolean:C(),animation:$===m,size:n,theme:k,themeName:w,themeType:H})]},`${m}_block_${e}`)}),r&&e==="conditions"&&t.jsxs("div",{onClick:()=>{b([...f,{_id:Date.now(),open:!0}]),l({...c,conditions:[...c.conditions,[]]}),q(c.conditions.length-1),setTimeout(()=>q(!1),1e3)},className:D.blockCardAdd,children:["+",t.jsx("div",{className:D.cardAdd,children:i})]}),t.jsx(ft,{open:h,onClose:()=>v(!1)}),t.jsx(gt,{open:M,onClose:()=>W(!1)})]})},ht="_menuRules_1qqcb_1",ut="_switchesRenderWrapper_1qqcb_13",mt="_menuOff_1qqcb_22",_t="_menuTitle_1qqcb_28",pt="_marginAuto_1qqcb_42",xt="_inputWidth_1qqcb_47",bt="_menuWrapper_1qqcb_52",Ct="_hamburgerWrapper_1qqcb_57",wt="_hamburgerOff_1qqcb_74",vt="_nothingFound_1qqcb_82",jt="_resetSearch_1qqcb_89",It="_controlPanel_1qqcb_101",Ot="_controlPanelAppBar_1qqcb_112",St="_addClassMenu_1qqcb_126",At="_addClassBackground_1qqcb_132",yt="_addClassPosition_1qqcb_136",E={menuRules:ht,switchesRenderWrapper:ut,menuOff:mt,menuTitle:_t,marginAuto:pt,inputWidth:xt,menuWrapper:bt,hamburgerWrapper:Ct,hamburgerOff:wt,nothingFound:vt,resetSearch:jt,controlPanel:It,controlPanelAppBar:Ot,addClassMenu:St,addClassBackground:At,addClassPosition:yt},Dt=n=>{const{allProperties:e,allProperties:{acceptedBy:s,id:i},setUserRules:r,userRules:o,setTourStep:c,tourStep:l,isTourOpen:d,onTouchMove:I,isActive:S}=n;return t.jsx(_e,{allProperties:e,id:e.id,isActive:S,setUserRules:r,userRules:o,children:t.jsx(ue,{onDoubleClick:()=>{d&&l===J.addScheduleByDoubleClick&&i==="TriggerScheduleBlock"&&c(J.openTagsMenu),d&&l===J.addActionPrintText&&i==="ActionPrintText"&&c(J.showJavascript);const O=Date.now();let _;switch(s){case"actions":_="then";break;case"conditions":_=o[s].length-1;break}const a=K(s,o,_),k={id:i,_id:O,acceptedBy:s};_!==void 0?s==="actions"?a.actions[_].push({...k}):s==="conditions"&&a.conditions[_].push({...k}):a.triggers.push({...k}),r(a)},...n,...e,onTouchMove:I})})},kt="_hamburgerMenu_hqnsm_8",Nt="_animate_hqnsm_21",ge={hamburgerMenu:kt,animate:Nt};function $t({bool:n}){return t.jsx("div",{className:`${ge.hamburgerMenu} ${n?ge.animate:""}`})}const Bt=({addClass:n,setAllBlocks:e,allBlocks:s,userRules:i,onChangeBlocks:r,setTourStep:o,tourStep:c,isTourOpen:l})=>{const{blocks:d,socket:I}=u.useContext(te),[S,O]=re(!1,"hamburgerOnOff"),[_,a]=re({text:"",type:"triggers",index:0},"filterControlPanel"),k=(f=_.text,b=_.type)=>{if(!d)return;let p=[...d];p=p.filter(h=>{if(!f)return!0;const{name:v}=h.getStaticData();return v&&x.I18n.t(v).toLowerCase().includes(f.toLowerCase())}),p=p.filter(h=>b===h.getStaticData().acceptedBy),e(p)},H=(f,b)=>{l&&b===0&&c===J.selectTriggers&&o(J.addScheduleByDoubleClick),l&&b===2&&c===J.selectActions&&o(J.addActionPrintText),a({..._,index:b,type:["triggers","conditions","actions"][b]}),k(_.text,["triggers","conditions","actions"][b])},w=f=>({id:`scrollable-force-tab-${f}`,"aria-controls":`scrollable-force-tabpanel-${f}`});return u.useEffect(()=>{k()},[d]),t.jsx(N.ClickAwayListener,{mouseEvent:!1,touchEvent:"onTouchStart",onClickAway:()=>O(!0),children:t.jsxs("div",{className:x.Utils.clsx(E.menuWrapper,n[1035]&&E.addClassMenu),children:[t.jsx("div",{className:`${E.hamburgerWrapper} ${S?E.hamburgerOff:null}`,onClick:()=>O(!S),children:t.jsx($t,{bool:!S})}),t.jsxs("div",{className:`${x.Utils.clsx(E.menuRules,n[1035]&&E.addClassBackground,n[835]&&E.addClassPosition)} ${S?E.menuOff:null}`,children:[t.jsx("div",{className:E.controlPanel,children:t.jsx(N.AppBar,{className:E.controlPanelAppBar,position:"static",children:t.jsxs(N.Tabs,{value:_.index,onChange:H,children:[t.jsx(N.Tab,{className:"blocks-triggers",title:x.I18n.t("Triggers"),icon:t.jsx(X,{iconName:"FlashOn"}),...w(0)}),t.jsx(N.Tab,{title:x.I18n.t("Conditions"),className:"blocks-conditions",icon:t.jsx(X,{iconName:"Help"}),...w(1)}),t.jsx(N.Tab,{title:x.I18n.t("Actions"),className:"blocks-actions",icon:t.jsx(X,{iconName:"PlayForWork"}),...w(2)})]})})}),t.jsx("div",{className:E.switchesRenderWrapper,children:t.jsxs("span",{children:[s.map(f=>{const{name:b,id:p,icon:h,adapter:v}=f.getStaticData();return t.jsx(u.Fragment,{children:t.jsx(Dt,{adapter:v,allProperties:f.getStaticData(),icon:h,id:p,isActive:!1,isTourOpen:l,name:b,onTouchMove:()=>O(!0),setTourStep:o,setUserRules:r,socket:I,tourStep:c,userRules:i})},p)}),!s.length&&t.jsxs("div",{className:E.nothingFound,children:[x.I18n.t("Nothing found"),"...",t.jsx("div",{className:E.resetSearch,onClick:()=>{a({..._,text:""}),k("")},children:x.I18n.t("reset search")})]})]})}),t.jsx("div",{className:x.Utils.clsx(E.menuTitle,E.marginAuto)}),t.jsx(ve,{className:E.inputWidth,fullWidth:!0,customValue:!0,value:_.text,size:"small",autoComplete:"off",label:x.I18n.t("search"),variant:"outlined",onChange:f=>{a({..._,text:f}),k(f)}})]})]})})};let ae=[];const Ut=({code:n,onChange:e,themeName:s,themeType:i,theme:r,setTourStep:o,tourStep:c,isTourOpen:l,command:d,scriptId:I,changed:S,running:O})=>{var j;const{blocks:_,socket:a,setOnUpdate:k,setOnDebugMessage:H,setEnableSimulation:w}=u.useContext(te),[f,b]=u.useState([]),[p,h]=u.useState(le(n)),[v,M]=u.useState(""),[W,$]=u.useState(!1);u.useEffect(()=>{let g,T;const A=(F,y)=>{F===`${g}.alive`&&T!==(y==null?void 0:y.val)&&(T=!!(y!=null&&y.val),T&&g&&(a==null||a.sendTo(g.replace(/^system\.adapter\./,""),"rulesOn",I)))},L=(F,y)=>{var U,Q;a&&g!==((U=y==null?void 0:y.common)==null?void 0:U.engine)&&(g&&(a.unsubscribeState(`${g}.alive`,A),T&&a.sendTo(g.replace(/^system\.adapter\./,""),"rulesOn",I)),g=(Q=y==null?void 0:y.common)==null?void 0:Q.engine,g&&g&&a.subscribeState(`${g}.alive`,A))},Y=(F,y)=>{if(y)try{const U=JSON.parse(y.val),Q=Date.now();if(U.ruleId===I&&Q-U.ts<1e3){const P=[...ae,{blockId:U.blockId,data:U.data,ts:U.ts}];P.length>200&&P.splice(0,200-P.length);for(let Z=P.length-1;Z>=0;Z--)if(P[Z].ts<Q-5e3){P.splice(0,Z);break}console.log(`Debug1: ${JSON.stringify(ae)}`),console.log(`Debug2: ${JSON.stringify(P)}`),ae=P,H(P)}}catch{console.error(`Cannot parse: ${y.val}`)}};return a==null||a.getObject(I).then(F=>{var y;g=(y=F==null?void 0:F.common)==null?void 0:y.engine,a.subscribeObject(I,L),g&&(a.subscribeState(`${g}.alive`,A),a.subscribeState(`${g.replace(/^system\.adapter\./,"")}.debug.rules`,Y))}),function(){a==null||a.unsubscribeState(I,A),g&&(a==null||a.unsubscribeObject(`${g}.alive`,L),T&&(a==null||a.sendTo(g.replace(/^system\.adapter\./,""),"rulesOff",I)),a==null||a.unsubscribeState(`${g.replace(/^system\.adapter\./,"")}.debug.rules`,Y))}},[]),u.useEffect(()=>{w(!S&&O)},[S,O,w]),u.useEffect(()=>{d&&(M(d),W||$(!0))},[d]),u.useEffect(()=>{const g=le(n);JSON.stringify(g)!==JSON.stringify(p)&&(h(g),k(!0))},[n]),u.useEffect(()=>{document.getElementsByTagName("HTML")[0].className=s||"blue"},[s]);const q=u.useCallback(g=>{h(g),_&&e(je(g,_))},[_,e]),B=u.useRef(null),[m,C]=u.useState({835:!1,1035:!1});return u.useEffect(()=>{B.current&&(B.current.clientWidth<=1035&&C({835:!1,1035:!0}),B.current.clientWidth<=835&&C({1035:!0,835:!0}),B.current.clientWidth>1035&&C({835:!1,1035:!1}))},[((j=B.current)==null?void 0:j.clientWidth)||0]),!_||!a?null:t.jsxs("div",{className:ne.wrapperRules,ref:B,children:[t.jsx(Le,{allBlocks:f,socket:a}),W?v==="export"?t.jsx(Ie,{scriptId:I,themeType:i,onClose:()=>$(!1),text:JSON.stringify(p,null,2)}):t.jsx(Oe,{themeType:i,onClose:g=>{$(!1),g&&q(JSON.parse(g))}}):null,t.jsxs("div",{className:x.Utils.clsx(ne.rootWrapper,m[835]&&ne.addClass),children:[t.jsx(Bt,{setAllBlocks:b,allBlocks:f,userRules:p,onChangeBlocks:q,setTourStep:o,tourStep:c,addClass:m,isTourOpen:l}),t.jsx(ce,{socket:a,setUserRules:q,userRules:p,isTourOpen:l,setTourStep:o,tourStep:c,name:`${x.I18n.t("when")}...`,typeBlock:"triggers",iconName:"FlashOn",size:m[835],themeType:i,themeName:s,theme:r}),t.jsx(ce,{socket:a,setUserRules:q,isTourOpen:l,setTourStep:o,tourStep:c,userRules:p,name:`...${x.I18n.t("and")}...`,typeBlock:"conditions",iconName:"Help",nameAdditionally:x.I18n.t("or"),additionally:!0,border:!0,size:m[835],themeType:i,themeName:s,theme:r}),t.jsx(ce,{socket:a,setUserRules:q,isTourOpen:l,setTourStep:o,tourStep:c,userRules:p,name:`...${x.I18n.t("then")}`,typeBlock:"actions",iconName:"PlayForWork",nameAdditionally:x.I18n.t("else"),additionally:!0,size:m[835],themeType:i,themeName:s,theme:r})]})]},"rulesEditor")};export{Ut as default};
|