iobroker.javascript 9.0.13 → 9.0.18

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +6 -6
  3. package/admin/assets/{OpenAiDialog-BmcYPsVa.js → OpenAiDialog-BVH3CrDi.js} +1 -1
  4. package/admin/assets/{Save-DXaUpIPM.js → Save-C-o2LLTD.js} +1 -1
  5. package/admin/assets/{ScriptEditor-BoSBgnK-.js → ScriptEditor-CAoVSrVf.js} +1 -1
  6. package/admin/assets/{ScriptEditorVanillaMonaco-Xge2wqgO.js → ScriptEditorVanillaMonaco-Cf9lA3Q5.js} +1 -1
  7. package/admin/assets/{createSvgIcon-DlIk-fDn.js → createSvgIcon-XLoRKyxt.js} +5 -5
  8. package/admin/assets/hostInit-OBG53iVO.js +1 -1
  9. package/admin/assets/{index-Br_QjNUk.js → index-BDco9K7T.js} +36 -36
  10. package/admin/assets/{index-OIiv3PJA.js → index-C96hfBFW.js} +1 -1
  11. package/admin/assets/index-CFhFEZTW.js +5 -0
  12. package/admin/assets/{index-BWM5lJbO.js → index-Cm-iTDHo.js} +1 -1
  13. package/admin/assets/{index-CePzv5-W.js → index-DCTpQXgR.js} +69 -69
  14. package/admin/assets/{index-DwcZPzOL.js → index-DKvqhUY5.js} +1 -1
  15. package/admin/assets/{index-BMwfsknM.js → index-DcrzW8Zn.js} +1 -1
  16. package/admin/assets/{inheritsLoose-DNrhibGS.js → inheritsLoose-tR_kcxUR.js} +4 -4
  17. package/admin/assets/iobroker_javascript__loadShare__react__loadShare__-6sH5wUl6.js +1 -0
  18. package/admin/assets/iobroker_javascript__mf_v__runtimeInit__mf_v__-CMP-NJnH.js +8 -0
  19. package/admin/assets/useTheme-C2oUi01-.js +1 -0
  20. package/admin/custom/assets/index-Bym4WjyH.js +908 -0
  21. package/admin/custom/customComponents.js +2 -2
  22. package/admin/mf-manifest.json +1 -1
  23. package/admin/remoteEntry.js +2 -2
  24. package/admin/tab.html +6 -6
  25. package/build/lib/debugger.js +9 -15
  26. package/build/lib/debugger.js.map +1 -1
  27. package/build/lib/mirror.js +21 -18
  28. package/build/lib/mirror.js.map +1 -1
  29. package/build/lib/utils.js.map +1 -1
  30. package/build/main.js +1 -1
  31. package/build/main.js.map +1 -1
  32. package/build/types.d.ts +1 -1
  33. package/io-package.json +66 -66
  34. package/package.json +4 -3
  35. package/admin/assets/index-Cjl4b70e.js +0 -5
  36. package/admin/assets/iobroker_javascript__loadShare__react__loadShare__-i8pXne9X.js +0 -1
  37. package/admin/assets/iobroker_javascript__mf_v__runtimeInit__mf_v__-DZdFIfoQ.js +0 -5
  38. package/admin/assets/useTheme-DakN8Abq.js +0 -1
  39. package/admin/custom/assets/index-BHN4DzE4.js +0 -908
package/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright (c) 2014-2025 bluefox <dogafox@gmail.com>,
3
+ Copyright (c) 2014-2026 bluefox <dogafox@gmail.com>,
4
4
 
5
5
  Copyright (c) 2014 hobbyquaker
6
6
 
package/README.md CHANGED
@@ -26,7 +26,11 @@ Executes Javascript, Typescript Scripts.
26
26
  <!--
27
27
  ### **WORK IN PROGRESS**
28
28
  -->
29
- ### 9.0.13 (2025-12-05)
29
+ ### 9.0.18 (2026-01-11)
30
+ * (@GermanBluefox) Corrected error message with `lastSync`
31
+ * (@klein0r) Corrected JavaScript filter
32
+
33
+ ### 9.0.17 (2025-12-14)
30
34
  * (@GermanBluefox) Added possibility to encrypt scripts with password (only for vendors)
31
35
 
32
36
  ### 9.0.11 (2025-07-29)
@@ -43,14 +47,10 @@ Executes Javascript, Typescript Scripts.
43
47
  ### 9.0.7 (2025-06-29)
44
48
  * (@GermanBluefox) Fixing some blocks in blockly: time, function
45
49
 
46
- ### 9.0.6 (2025-06-18)
47
- * (@GermanBluefox) Speed-up loading of GUI
48
- * (@GermanBluefox) Migrating old blocks to new format
49
-
50
50
  ## License
51
51
  The MIT License (MIT)
52
52
 
53
- Copyright (c) 2014-2025 bluefox <dogafox@gmail.com>,
53
+ Copyright (c) 2014-2026 bluefox <dogafox@gmail.com>,
54
54
 
55
55
  Copyright (c) 2014 hobbyquaker
56
56
 
@@ -1,4 +1,4 @@
1
- import{c as pr,j as P}from"./createSvgIcon-DlIk-fDn.js";import{i as Z}from"./iobroker_javascript__loadShare__react__loadShare__-i8pXne9X.js";import{i as j,c as pn,C as gr}from"./index-Cjl4b70e.js";import{i as U,h as _r}from"./index-CePzv5-W.js";import{_ as yr}from"./preload-helper-BDBacUwf.js";import{C as wr,t as br}from"./index-DZ3lKVw8.js";import xr from"./ScriptEditorVanillaMonaco-Xge2wqgO.js";import"./_commonjsHelpers-Cpj98o6Y.js";import"./iobroker_javascript__mf_v__runtimeInit__mf_v__-DZdFIfoQ.js";import"./inheritsLoose-DNrhibGS.js";const Sr=pr(P.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 R(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 c(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 qn=function(){const{crypto:s}=globalThis;if(s!=null&&s.randomUUID)return qn=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 Et(s){return typeof s=="object"&&s!==null&&("name"in s&&s.name==="AbortError"||"message"in s&&String(s.message).includes("FetchRequestCanceledException"))}const Pt=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 x extends Error{}class H extends x{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 pt({message:n,cause:Pt(t)});const a=t==null?void 0:t.error;return e===400?new Jn(e,a,n,r):e===401?new Hn(e,a,n,r):e===403?new Xn(e,a,n,r):e===404?new Kn(e,a,n,r):e===409?new Vn(e,a,n,r):e===422?new Gn(e,a,n,r):e===429?new Qn(e,a,n,r):e>=500?new zn(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 pt extends H{constructor({message:e,cause:t}){super(void 0,void 0,e||"Connection error.",void 0),t&&(this.cause=t)}}class Jt extends pt{constructor({message:e}={}){super({message:e??"Request timed out."})}}class Jn extends H{}class Hn extends H{}class Xn extends H{}class Kn extends H{}class Vn extends H{}class Gn extends H{}class Qn extends H{}class zn extends H{}class Yn extends x{constructor(){super("Could not parse response content as the length limit was reached")}}class Zn extends x{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 Ar=/^[a-z][a-z0-9+.-]*:/i,vr=s=>Ar.test(s);let K=s=>(K=Array.isArray,K(s)),gn=K;function es(s){return typeof s!="object"?{}:s??{}}function Cr(s){if(!s)return!0;for(const e in s)return!1;return!0}function Ir(s,e){return Object.prototype.hasOwnProperty.call(s,e)}function St(s){return s!=null&&typeof s=="object"&&!Array.isArray(s)}const Rr=(s,e)=>{if(typeof e!="number"||!Number.isInteger(e))throw new x(`${s} must be an integer`);if(e<0)throw new x(`${s} must be a positive integer`);return e},$r=s=>{try{return JSON.parse(s)}catch{return}},Be=s=>new Promise(e=>setTimeout(e,s)),we="5.23.2",kr=()=>typeof window<"u"&&typeof window.document<"u"&&typeof navigator<"u";function Or(){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 Er=()=>{var t;const s=Or();if(s==="deno")return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":we,"X-Stainless-OS":yn(Deno.build.os),"X-Stainless-Arch":_n(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":yn(globalThis.process.platform??"unknown"),"X-Stainless-Arch":_n(globalThis.process.arch??"unknown"),"X-Stainless-Runtime":"node","X-Stainless-Runtime-Version":globalThis.process.version??"unknown"};const e=Pr();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 Pr(){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 _n=s=>s==="x32"?"x32":s==="x86_64"||s==="x64"?"x64":s==="arm"?"arm":s==="aarch64"||s==="arm64"?"arm64":s?`other:${s}`:"unknown",yn=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 wn;const Tr=()=>wn??(wn=Er());function Mr(){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 ts(...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 ns(s){let e=Symbol.asyncIterator in s?s[Symbol.asyncIterator]():s[Symbol.iterator]();return ts({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 ss(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 Nr(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 jr=({headers:s,body:e})=>({bodyHeaders:{"content-type":"application/json"},body:JSON.stringify(e)}),rs="RFC3986",as=s=>String(s),bn={RFC1738:s=>String(s).replace(/%20/g,"+"),RFC3986:as},Fr="RFC1738";let Tt=(s,e)=>(Tt=Object.hasOwn??Function.prototype.call.bind(Object.prototype.hasOwnProperty),Tt(s,e));const ee=(()=>{const s=[];for(let e=0;e<256;++e)s.push("%"+((e<16?"0":"")+e.toString(16)).toUpperCase());return s})(),At=1024,Lr=(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(o){return"%26%23"+parseInt(o.slice(2),16)+"%3B"});let i="";for(let o=0;o<a.length;o+=At){const l=a.length>=At?a.slice(o,o+At):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===Fr&&(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 Dr(s){return!s||typeof s!="object"?!1:!!(s.constructor&&s.constructor.isBuffer&&s.constructor.isBuffer(s))}function xn(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 is={brackets(s){return String(s)+"[]"},comma:"comma",indices(s,e){return String(s)+"["+e+"]"},repeat(s){return String(s)}},os=function(s,e){Array.prototype.push.apply(s,K(e)?e:[e])};let Sn;const B={addQueryPrefix:!1,allowDots:!1,allowEmptyArrays:!1,arrayFormat:"indices",charset:"utf-8",charsetSentinel:!1,delimiter:"&",encode:!0,encodeDotInKeys:!1,encoder:Lr,encodeValuesOnly:!1,format:rs,formatter:as,indices:!1,serializeDate(s){return(Sn??(Sn=Function.prototype.call.bind(Date.prototype.toISOString)))(s)},skipNulls:!1,strictNullHandling:!1};function Br(s){return typeof s=="string"||typeof s=="number"||typeof s=="boolean"||typeof s=="symbol"||typeof s=="bigint"}const vt={};function cs(s,e,t,n,r,a,i,o,l,u,m,h,g,d,b,w,v,E){let p=s,y=E,_=0,C=!1;for(;(y=y.get(vt))!==void 0&&!C;){const T=y.get(s);if(_+=1,typeof T<"u"){if(T===_)throw new RangeError("Cyclic object value");C=!0}typeof y.get(vt)>"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=xn(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,v,"key",d):e;p=""}if(Br(p)||Dr(p)){if(l){const T=w?e:l(e,B.encoder,v,"key",d);return[(b==null?void 0:b(T))+"="+(b==null?void 0:b(l(p,B.encoder,v,"value",d)))]}return[(b==null?void 0:b(e))+"="+(b==null?void 0:b(String(p)))]}const k=[];if(typeof p>"u")return k;let $;if(t==="comma"&&K(p))w&&l&&(p=xn(p,l)),$=[{value:p.length>0?p.join(",")||null:void 0}];else if(K(u))$=u;else{const T=Object.keys(p);$=m?T.sort(m):T}const F=o?String(e).replace(/\./g,"%2E"):String(e),A=n&&K(p)&&p.length===1?F+"[]":F;if(r&&K(p)&&p.length===0)return A+"[]";for(let T=0;T<$.length;++T){const M=$[T],se=typeof M=="object"&&typeof M.value<"u"?M.value:p[M];if(i&&se===null)continue;const me=h&&o?M.replace(/\./g,"%2E"):M,N=K(p)?typeof t=="function"?t(A,me):A:A+(h?"."+me:"["+me+"]");E.set(s,_);const ie=new WeakMap;ie.set(vt,E),os(k,cs(se,N,t,n,r,a,i,o,t==="comma"&&w&&K(p)?null:l,u,m,h,g,d,b,w,v,ie))}return k}function Wr(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=rs;if(typeof s.format<"u"){if(!Tt(bn,s.format))throw new TypeError("Unknown format option provided.");t=s.format}const n=bn[t];let r=B.filter;(typeof s.filter=="function"||K(s.filter))&&(r=s.filter);let a;if(s.arrayFormat&&s.arrayFormat in is?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 Ur(s,e={}){let t=s;const n=Wr(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 o=is[n.arrayFormat],l=o==="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||os(i,cs(t[d],d,o,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 qr(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 An;function Ht(s){let e;return(An??(e=new globalThis.TextEncoder,An=e.encode.bind(e)))(s)}let vn;function Cn(s){let e;return(vn??(e=new globalThis.TextDecoder,vn=e.decode.bind(e)))(s)}var V,G;class gt{constructor(){V.set(this,void 0),G.set(this,void 0),R(this,V,new Uint8Array),R(this,G,null)}decode(e){if(e==null)return[];const t=e instanceof ArrayBuffer?new Uint8Array(e):typeof e=="string"?Ht(e):e;R(this,V,qr([c(this,V,"f"),t]));const n=[];let r;for(;(r=Jr(c(this,V,"f"),c(this,G,"f")))!=null;){if(r.carriage&&c(this,G,"f")==null){R(this,G,r.index);continue}if(c(this,G,"f")!=null&&(r.index!==c(this,G,"f")+1||r.carriage)){n.push(Cn(c(this,V,"f").subarray(0,c(this,G,"f")-1))),R(this,V,c(this,V,"f").subarray(c(this,G,"f"))),R(this,G,null);continue}const a=c(this,G,"f")!==null?r.preceding-1:r.preceding,i=Cn(c(this,V,"f").subarray(0,a));n.push(i),R(this,V,c(this,V,"f").subarray(r.index)),R(this,G,null)}return n}flush(){return c(this,V,"f").length?this.decode(`
1
+ import{c as pr,j as P}from"./createSvgIcon-XLoRKyxt.js";import{i as Z}from"./iobroker_javascript__loadShare__react__loadShare__-6sH5wUl6.js";import{i as j,c as pn,C as gr}from"./index-CFhFEZTW.js";import{i as U,h as _r}from"./index-DCTpQXgR.js";import{_ as yr}from"./preload-helper-BDBacUwf.js";import{C as wr,t as br}from"./index-DZ3lKVw8.js";import xr from"./ScriptEditorVanillaMonaco-Cf9lA3Q5.js";import"./_commonjsHelpers-Cpj98o6Y.js";import"./iobroker_javascript__mf_v__runtimeInit__mf_v__-CMP-NJnH.js";import"./inheritsLoose-tR_kcxUR.js";const Sr=pr(P.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 R(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 c(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 qn=function(){const{crypto:s}=globalThis;if(s!=null&&s.randomUUID)return qn=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 Et(s){return typeof s=="object"&&s!==null&&("name"in s&&s.name==="AbortError"||"message"in s&&String(s.message).includes("FetchRequestCanceledException"))}const Pt=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 x extends Error{}class H extends x{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 pt({message:n,cause:Pt(t)});const a=t==null?void 0:t.error;return e===400?new Jn(e,a,n,r):e===401?new Hn(e,a,n,r):e===403?new Xn(e,a,n,r):e===404?new Kn(e,a,n,r):e===409?new Vn(e,a,n,r):e===422?new Gn(e,a,n,r):e===429?new Qn(e,a,n,r):e>=500?new zn(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 pt extends H{constructor({message:e,cause:t}){super(void 0,void 0,e||"Connection error.",void 0),t&&(this.cause=t)}}class Jt extends pt{constructor({message:e}={}){super({message:e??"Request timed out."})}}class Jn extends H{}class Hn extends H{}class Xn extends H{}class Kn extends H{}class Vn extends H{}class Gn extends H{}class Qn extends H{}class zn extends H{}class Yn extends x{constructor(){super("Could not parse response content as the length limit was reached")}}class Zn extends x{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 Ar=/^[a-z][a-z0-9+.-]*:/i,vr=s=>Ar.test(s);let K=s=>(K=Array.isArray,K(s)),gn=K;function es(s){return typeof s!="object"?{}:s??{}}function Cr(s){if(!s)return!0;for(const e in s)return!1;return!0}function Ir(s,e){return Object.prototype.hasOwnProperty.call(s,e)}function St(s){return s!=null&&typeof s=="object"&&!Array.isArray(s)}const Rr=(s,e)=>{if(typeof e!="number"||!Number.isInteger(e))throw new x(`${s} must be an integer`);if(e<0)throw new x(`${s} must be a positive integer`);return e},$r=s=>{try{return JSON.parse(s)}catch{return}},Be=s=>new Promise(e=>setTimeout(e,s)),we="5.23.2",kr=()=>typeof window<"u"&&typeof window.document<"u"&&typeof navigator<"u";function Or(){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 Er=()=>{var t;const s=Or();if(s==="deno")return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":we,"X-Stainless-OS":yn(Deno.build.os),"X-Stainless-Arch":_n(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":yn(globalThis.process.platform??"unknown"),"X-Stainless-Arch":_n(globalThis.process.arch??"unknown"),"X-Stainless-Runtime":"node","X-Stainless-Runtime-Version":globalThis.process.version??"unknown"};const e=Pr();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 Pr(){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 _n=s=>s==="x32"?"x32":s==="x86_64"||s==="x64"?"x64":s==="arm"?"arm":s==="aarch64"||s==="arm64"?"arm64":s?`other:${s}`:"unknown",yn=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 wn;const Tr=()=>wn??(wn=Er());function Mr(){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 ts(...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 ns(s){let e=Symbol.asyncIterator in s?s[Symbol.asyncIterator]():s[Symbol.iterator]();return ts({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 ss(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 Nr(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 jr=({headers:s,body:e})=>({bodyHeaders:{"content-type":"application/json"},body:JSON.stringify(e)}),rs="RFC3986",as=s=>String(s),bn={RFC1738:s=>String(s).replace(/%20/g,"+"),RFC3986:as},Fr="RFC1738";let Tt=(s,e)=>(Tt=Object.hasOwn??Function.prototype.call.bind(Object.prototype.hasOwnProperty),Tt(s,e));const ee=(()=>{const s=[];for(let e=0;e<256;++e)s.push("%"+((e<16?"0":"")+e.toString(16)).toUpperCase());return s})(),At=1024,Lr=(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(o){return"%26%23"+parseInt(o.slice(2),16)+"%3B"});let i="";for(let o=0;o<a.length;o+=At){const l=a.length>=At?a.slice(o,o+At):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===Fr&&(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 Dr(s){return!s||typeof s!="object"?!1:!!(s.constructor&&s.constructor.isBuffer&&s.constructor.isBuffer(s))}function xn(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 is={brackets(s){return String(s)+"[]"},comma:"comma",indices(s,e){return String(s)+"["+e+"]"},repeat(s){return String(s)}},os=function(s,e){Array.prototype.push.apply(s,K(e)?e:[e])};let Sn;const B={addQueryPrefix:!1,allowDots:!1,allowEmptyArrays:!1,arrayFormat:"indices",charset:"utf-8",charsetSentinel:!1,delimiter:"&",encode:!0,encodeDotInKeys:!1,encoder:Lr,encodeValuesOnly:!1,format:rs,formatter:as,indices:!1,serializeDate(s){return(Sn??(Sn=Function.prototype.call.bind(Date.prototype.toISOString)))(s)},skipNulls:!1,strictNullHandling:!1};function Br(s){return typeof s=="string"||typeof s=="number"||typeof s=="boolean"||typeof s=="symbol"||typeof s=="bigint"}const vt={};function cs(s,e,t,n,r,a,i,o,l,u,m,h,g,d,b,w,v,E){let p=s,y=E,_=0,C=!1;for(;(y=y.get(vt))!==void 0&&!C;){const T=y.get(s);if(_+=1,typeof T<"u"){if(T===_)throw new RangeError("Cyclic object value");C=!0}typeof y.get(vt)>"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=xn(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,v,"key",d):e;p=""}if(Br(p)||Dr(p)){if(l){const T=w?e:l(e,B.encoder,v,"key",d);return[(b==null?void 0:b(T))+"="+(b==null?void 0:b(l(p,B.encoder,v,"value",d)))]}return[(b==null?void 0:b(e))+"="+(b==null?void 0:b(String(p)))]}const k=[];if(typeof p>"u")return k;let $;if(t==="comma"&&K(p))w&&l&&(p=xn(p,l)),$=[{value:p.length>0?p.join(",")||null:void 0}];else if(K(u))$=u;else{const T=Object.keys(p);$=m?T.sort(m):T}const F=o?String(e).replace(/\./g,"%2E"):String(e),A=n&&K(p)&&p.length===1?F+"[]":F;if(r&&K(p)&&p.length===0)return A+"[]";for(let T=0;T<$.length;++T){const M=$[T],se=typeof M=="object"&&typeof M.value<"u"?M.value:p[M];if(i&&se===null)continue;const me=h&&o?M.replace(/\./g,"%2E"):M,N=K(p)?typeof t=="function"?t(A,me):A:A+(h?"."+me:"["+me+"]");E.set(s,_);const ie=new WeakMap;ie.set(vt,E),os(k,cs(se,N,t,n,r,a,i,o,t==="comma"&&w&&K(p)?null:l,u,m,h,g,d,b,w,v,ie))}return k}function Wr(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=rs;if(typeof s.format<"u"){if(!Tt(bn,s.format))throw new TypeError("Unknown format option provided.");t=s.format}const n=bn[t];let r=B.filter;(typeof s.filter=="function"||K(s.filter))&&(r=s.filter);let a;if(s.arrayFormat&&s.arrayFormat in is?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 Ur(s,e={}){let t=s;const n=Wr(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 o=is[n.arrayFormat],l=o==="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||os(i,cs(t[d],d,o,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 qr(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 An;function Ht(s){let e;return(An??(e=new globalThis.TextEncoder,An=e.encode.bind(e)))(s)}let vn;function Cn(s){let e;return(vn??(e=new globalThis.TextDecoder,vn=e.decode.bind(e)))(s)}var V,G;class gt{constructor(){V.set(this,void 0),G.set(this,void 0),R(this,V,new Uint8Array),R(this,G,null)}decode(e){if(e==null)return[];const t=e instanceof ArrayBuffer?new Uint8Array(e):typeof e=="string"?Ht(e):e;R(this,V,qr([c(this,V,"f"),t]));const n=[];let r;for(;(r=Jr(c(this,V,"f"),c(this,G,"f")))!=null;){if(r.carriage&&c(this,G,"f")==null){R(this,G,r.index);continue}if(c(this,G,"f")!=null&&(r.index!==c(this,G,"f")+1||r.carriage)){n.push(Cn(c(this,V,"f").subarray(0,c(this,G,"f")-1))),R(this,V,c(this,V,"f").subarray(c(this,G,"f"))),R(this,G,null);continue}const a=c(this,G,"f")!==null?r.preceding-1:r.preceding,i=Cn(c(this,V,"f").subarray(0,a));n.push(i),R(this,V,c(this,V,"f").subarray(r.index)),R(this,G,null)}return n}flush(){return c(this,V,"f").length?this.decode(`
2
2
  `):[]}}V=new WeakMap,G=new WeakMap;gt.NEWLINE_CHARS=new Set([`
3
3
  `,"\r"]);gt.NEWLINE_REGEXP=/\r\n|[\n\r]/g;function Jr(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 Hr(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},In=(s,e,t)=>{if(s){if(Ir(ot,s))return s;q(t).warn(`${e} was set to ${JSON.stringify(s)}, expected one of ${JSON.stringify(Object.keys(ot))}`)}};function $e(){}function Je(s,e,t){return!e||ot[s]>ot[t]?$e:e[s].bind(e)}const Xr={error:$e,warn:$e,info:$e,debug:$e};let Rn=new WeakMap;function q(s){const e=s.logger,t=s.logLevel??"off";if(!e)return Xr;const n=Rn.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 Rn.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,R(this,Ie,n)}static fromSSEResponse(e,t,n){let r=!1;const a=n?q(n):console;async function*i(){if(r)throw new x("Cannot iterate over a consumed stream, use `.tee()` to split the stream.");r=!0;let o=!1;try{for await(const l of Kr(e,t))if(!o){if(l.data.startsWith("[DONE]")){o=!0;continue}if(l.event===null||!l.event.startsWith("thread.")){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}}}o=!0}catch(l){if(Et(l))return;throw l}finally{o||t.abort()}}return new ne(i,t,n)}static fromReadableStream(e,t,n){let r=!1;async function*a(){const o=new gt,l=ss(e);for await(const u of l)for(const m of o.decode(u))yield m;for(const u of o.flush())yield u}async function*i(){if(r)throw new x("Cannot iterate over a consumed stream, use `.tee()` to split the stream.");r=!0;let o=!1;try{for await(const l of a())o||l&&(yield JSON.parse(l));o=!0}catch(l){if(Et(l))return;throw l}finally{o||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,c(this,Ie,"f")),new ne(()=>r(t),this.controller,c(this,Ie,"f"))]}toReadableStream(){const e=this;let t;return ts({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=Ht(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*Kr(s,e){if(!s.body)throw e.abort(),typeof globalThis.navigator<"u"&&globalThis.navigator.product==="ReactNative"?new x("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 x("Attempted to iterate over a response with no body");const t=new Gr,n=new gt,r=ss(s.body);for await(const a of Vr(r))for(const i of n.decode(a)){const o=t.decode(i);o&&(yield o)}for(const a of n.flush()){const i=t.decode(a);i&&(yield i)}}async function*Vr(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"?Ht(t):t;let r=new Uint8Array(e.length+n.length);r.set(e),r.set(n,e.length),e=r;let a;for(;(a=Hr(e))!==-1;)yield e.slice(0,a),e=e.slice(a)}e.length>0&&(yield e)}class Gr{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-DlIk-fDn.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
+ import{c,j as s}from"./createSvgIcon-XLoRKyxt.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-DlIk-fDn.js";import{R as i}from"./iobroker_javascript__loadShare__react__loadShare__-i8pXne9X.js";import{i as r,I as n}from"./index-Cjl4b70e.js";import{i as a}from"./index-CePzv5-W.js";import l from"./ScriptEditorVanillaMonaco-Xge2wqgO.js";import{I as c}from"./Save-DXaUpIPM.js";import"./_commonjsHelpers-Cpj98o6Y.js";import"./iobroker_javascript__mf_v__runtimeInit__mf_v__-DZdFIfoQ.js";import"./inheritsLoose-DNrhibGS.js";import"./preload-helper-BDBacUwf.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?`
1
+ import{j as e}from"./createSvgIcon-XLoRKyxt.js";import{R as i}from"./iobroker_javascript__loadShare__react__loadShare__-6sH5wUl6.js";import{i as r,I as n}from"./index-CFhFEZTW.js";import{i as a}from"./index-DCTpQXgR.js";import l from"./ScriptEditorVanillaMonaco-Cf9lA3Q5.js";import{I as c}from"./Save-C-o2LLTD.js";import"./_commonjsHelpers-Cpj98o6Y.js";import"./iobroker_javascript__mf_v__runtimeInit__mf_v__-CMP-NJnH.js";import"./inheritsLoose-tR_kcxUR.js";import"./preload-helper-BDBacUwf.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};
@@ -1 +1 @@
1
- import{j as n}from"./createSvgIcon-DlIk-fDn.js";import{R as S}from"./iobroker_javascript__loadShare__react__loadShare__-i8pXne9X.js";import{i as p,o as b,av as C}from"./index-Cjl4b70e.js";import{i as f}from"./index-CePzv5-W.js";import"./_commonjsHelpers-Cpj98o6Y.js";import"./iobroker_javascript__mf_v__runtimeInit__mf_v__-DZdFIfoQ.js";import"./inheritsLoose-DNrhibGS.js";import"./preload-helper-BDBacUwf.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-XLoRKyxt.js";import{R as S}from"./iobroker_javascript__loadShare__react__loadShare__-6sH5wUl6.js";import{i as p,o as b,av as C}from"./index-CFhFEZTW.js";import{i as f}from"./index-DCTpQXgR.js";import"./_commonjsHelpers-Cpj98o6Y.js";import"./iobroker_javascript__mf_v__runtimeInit__mf_v__-CMP-NJnH.js";import"./inheritsLoose-tR_kcxUR.js";import"./preload-helper-BDBacUwf.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};