x-block-lib 0.10.34 → 0.10.36
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/en.md0q5xx8.js +1 -0
- package/dist/{i18n-en.g7xrumzj.js → i18n-en.fzzizejc.js} +1 -1
- package/dist/{i18n-zhHans.hwzyg72e.js → i18n-zhHans.b0wqxx8d.js} +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +147 -147
- package/dist/rolldown-runtime.81faoggt.js +1 -0
- package/dist/vendor.ltuy0q0e.js +2373 -0
- package/dist/zhHans.ei0ea10m.js +1 -0
- package/package.json +11 -11
- package/dist/rolldown-runtime.mam1o4z7.js +0 -1
package/dist/index.js
CHANGED
|
@@ -1,37 +1,37 @@
|
|
|
1
1
|
import './style.css';
|
|
2
|
-
import*as e from"blockly/core";import{Order as t,javascriptGenerator as n}from"blockly/javascript";import{eventBus as r,globalObjects as i,messageWarning as a,openConfirmDlg as o,openPromptDlg as s,useColor as c,useSystem as l,useViewStack as u}from"x-essential-lib";import{globalState as d}from"x-state-lib";import{addIndent as ee,finalProperties as f,getElement as p,getImplementMethodName as te,getItems as ne,getTag as m,getTypes as re,makeEventId as h,makeEventKeyOfCustomSlot as ie,makeEventKeyOfElementSlot as ae,makeMethodId as g,makeMethodKeyOfCustomSlot as oe,makeMethodKeyOfElementSlot as se,makePropertyId as _,makePropertyKeyOfCustomSlot as ce,makePropertyKeyOfElementSlot as le,makeTriggerId as v,parseNumberUnit as ue,pkgs as de,themeColors as fe,toEventName as pe,toMethodName as me,toPropertyName as he,unwrapEventId as ge,unwrapEventKeyOfCustomSlot as y,unwrapEventKeyOfElementSlot as _e,unwrapMethodId as ve,unwrapMethodKeyOfCustomSlot as ye,unwrapMethodKeyOfElementSlot as be,unwrapPropertyId as xe,unwrapPropertyKeyOfCustomSlot as Se,unwrapPropertyKeyOfElementSlot as Ce,unwrapSlotId as we}from"x-runtime-lib";import{cloneDeep as Te,debounce as Ee,isEqual as b,parseInt as De,snakeCase as Oe,upperCase as ke}from"lodash-es";import{FieldColour as Ae,registerFieldColour as je}from"@blockly/field-colour";import Me from"@sindresorhus/base62";import{CrossTabCopyPaste as Ne}from"@blockly/plugin-cross-tab-copy-paste";import{Fragment as Pe,computed as x,createBlock as S,createCommentVNode as Fe,createElementBlock as C,createElementVNode as w,createVNode as T,defineComponent as E,inject as Ie,isRef as Le,mergeModels as Re,mergeProps as ze,nextTick as Be,normalizeStyle as D,onBeforeUnmount as Ve,onMounted as He,onUnmounted as Ue,openBlock as O,provide as We,ref as Ge,renderList as Ke,renderSlot as qe,resolveComponent as k,resolveDirective as Je,toDisplayString as Ye,unref as A,useId as Xe,useModel as Ze,useTemplateRef as Qe,watch as $e,withCtx as j,withDirectives as et,withKeys as tt,withModifiers as nt}from"vue";import{useResizeObserver as rt}from"@vueuse/core";import{useI18n as it}from"vue-i18n";import{useDisplay as at}from"vuetify";import{VueDraggable as ot}from"vue-draggable-plus";import{shadowBlockConversionChangeListener as st}from"@blockly/shadow-block-converter";import"highlight.js/styles/default.min.css";import ct from"@highlightjs/vue-plugin";import lt from"highlight.js/lib/core";import ut from"highlight.js/lib/languages/javascript";async function dt(t){let n=await import(`./msg/${t}.ts`);e.setLocale(n.default)}function M(t){return e.Msg[t]??t}function ft(t){let n=`<block type="text_v1"><field name="TEXT">${t}</field></block>`;return e.utils.xml.textToDom(n)}function pt(t){let n=`<block type="math_number_v1"><field name="NUM">${t}</field></block>`;return e.utils.xml.textToDom(n)}function mt(t){let n=`<block type="logic_boolean_v1"><field name="BOOL">${t?`TRUE`:`FALSE`}</field></block>`;return e.utils.xml.textToDom(n)}function ht(t,n){let r=null;return n===`string`?r=ft(``):n===`integer`||n===`decimal`?r=pt(0):n===`boolean`?r=mt(!1):n===`enum`||n===`dateTime`?r=ft(``):console.assert(!1,`type not implementd`),r?e.Xml.domToBlock(r,t):null}const gt=`data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZlcnNpb249IjEuMSIgd2lkdGg9IjI0IiBoZWlnaHQ9IjI0Ij48cGF0aCBkPSJNMTggMTBoLTR2LTRjMC0xLjEwNC0uODk2LTItMi0ycy0yIC44OTYtMiAybC4wNzEgNGgtNC4wNzFjLTEuMTA0IDAtMiAuODk2LTIgMnMuODk2IDIgMiAybDQuMDcxLS4wNzEtLjA3MSA0LjA3MWMwIDEuMTA0Ljg5NiAyIDIgMnMyLS44OTYgMi0ydi00LjA3MWw0IC4wNzFjMS4xMDQgMCAyLS44OTYgMi0ycy0uODk2LTItMi0yeiIgZmlsbD0id2hpdGUiIC8+PC9zdmc+Cg==`,_t=`data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZlcnNpb249IjEuMSIgd2lkdGg9IjI0IiBoZWlnaHQ9IjI0Ij48cGF0aCBkPSJNMTggMTFoLTEyYy0xLjEwNCAwLTIgLjg5Ni0yIDJzLjg5NiAyIDIgMmgxMmMxLjEwNCAwIDItLjg5NiAyLTJzLS44OTYtMi0yLTJ6IiBmaWxsPSJ3aGl0ZSIgLz48L3N2Zz4K`;function vt(e){let t=e.lastIndexOf(`V`);if(t<=0||t>=e.length-1)throw Error(`must has V`);return`${Oe(e.substring(0,t))}_${`v`+e.substring(t+1)}`}function yt(e){let t=e.lastIndexOf(`V`);if(t<=0||t>=e.length-1)return console.assert(!1,`invalid key=${e}`),``;let n=e.substring(0,t-1);return`${n[0].toUpperCase()}${n.substring(1)}`}function N(e){return e.length<=0&&e.push([M(`NO_OPTION`),``]),e}function bt(e){let t=0;for(;e;)t++,e=e.getParent();return t}function xt(e){return e.ui===`text`?`string`:e.ui===`number`?`number`:e.ui===`switch`?`boolean`:`string`}function St(e,t){return!!(e.startsWith(`basic.`)||!t.ui||t.readonly)}function P(e){return e.startsWith(`globality_v`)}function F(e){return e.startsWith(`ref_v`)}function I(e){return e.startsWith(`multiple_ref_v`)}function L(e){return e.startsWith(`slot_v`)}function R(e){return e.startsWith(`multiple_slot_v`)}function Ct(e,t,n){let{kind:r,mainKey:i,slotKey:a}=we(e);return!(r!==`elementSlot`&&r!==`multipleElementSlot`||t!==i||n!==a)}function wt(e,t,n){let{kind:r,mainKey:i,slotKey:a}=we(e);return!(r!==`customSlot`&&r!==`multipleCustomSlot`||t!==i||n!==a)}function z(e){return e===`string`?`String`:e===`number`?`Number`:e===`boolean`?`Boolean`:e===`array`?`Array`:e===`object`?`Object`:(e===`any`||console.assert(!1),null)}function Tt(e){return e.array?`Array`:e.ui===`transient`?z(e.type):e.ui===`dummy`?null:e.ui===`text`?`String`:e.ui===`number`?`Number`:e.ui===`switch`?`Boolean`:e.ui===`select`?yt(e.items):e.ui===`multiTypes`?yt(e.types):e.ui===`comp`?`Comp`:e.ui===`slot`?`Slot`:e.ui===`adaptSlot`?`AdaptSlot`:(console.assert(!1),null)}function Et(e){return e===`string`?`String`:e===`integer`||e===`decimal`?`Number`:e===`boolean`?`Boolean`:e===`enum`||e===`dateTime`?`String`:(console.assert(!1),null)}const Dt=`#F44336.#FFEBEE.#FFCDD2.#EF9A9A.#E57373.#EF5350.#E53935.#D32F2F.#C62828.#B71C1C.#FF8A80.#FF5252.#FF1744.#D50000.#e91e63.#fce4ec.#f8bbd0.#f48fb1.#f06292.#ec407a.#d81b60.#c2185b.#ad1457.#880e4f.#ff80ab.#ff4081.#f50057.#c51162.#9c27b0.#f3e5f5.#e1bee7.#ce93d8.#ba68c8.#ab47bc.#8e24aa.#7b1fa2.#6a1b9a.#4a148c.#ea80fc.#e040fb.#d500f9.#aa00ff.#673ab7.#ede7f6.#d1c4e9.#b39ddb.#9575cd.#7e57c2.#5e35b1.#512da8.#4527a0.#311b92.#b388ff.#7c4dff.#651fff.#6200ea.#3f51b5.#e8eaf6.#c5cae9.#9fa8da.#7986cb.#5c6bc0.#3949ab.#303f9f.#283593.#1a237e.#8c9eff.#536dfe.#3d5afe.#304ffe.#2196F3.#E3F2FD.#BBDEFB.#90CAF9.#64B5F6.#42A5F5.#1E88E5.#1976D2.#1565C0.#0D47A1.#82B1FF.#448AFF.#2979FF.#2962FF.#03a9f4.#e1f5fe.#b3e5fc.#81d4fa.#4fc3f7.#29b6f6.#039be5.#0288d1.#0277bd.#01579b.#80d8ff.#40c4ff.#00b0ff.#0091ea.#00bcd4.#e0f7fa.#b2ebf2.#80deea.#4dd0e1.#26c6da.#00acc1.#0097a7.#00838f.#006064.#84ffff.#18ffff.#00e5ff.#00b8d4.#009688.#e0f2f1.#b2dfdb.#80cbc4.#4db6ac.#26a69a.#00897b.#00796b.#00695c.#004d40.#a7ffeb.#64ffda.#1de9b6.#00bfa5.#4CAF50.#E8F5E9.#C8E6C9.#A5D6A7.#81C784.#66BB6A.#43A047.#388E3C.#2E7D32.#1B5E20.#B9F6CA.#69F0AE.#00E676.#00C853.#8bc34a.#f1f8e9.#dcedc8.#c5e1a5.#aed581.#9ccc65.#7cb342.#689f38.#558b2f.#33691e.#ccff90.#b2ff59.#76ff03.#64dd17.#cddc39.#f9fbe7.#f0f4c3.#e6ee9c.#dce775.#d4e157.#c0ca33.#afb42b.#9e9d24.#827717.#f4ff81.#eeff41.#c6ff00.#aeea00.#ffeb3b.#fffde7.#fff9c4.#fff59d.#fff176.#ffee58.#fdd835.#fbc02d.#f9a825.#f57f17.#ffff8d.#ffff00.#ffea00.#ffd600.#ffc107.#fff8e1.#ffecb3.#ffe082.#ffd54f.#ffca28.#ffb300.#ffa000.#ff8f00.#ff6f00.#ffe57f.#ffd740.#ffc400.#ffab00.#ff9800.#fff3e0.#ffe0b2.#ffcc80.#ffb74d.#ffa726.#fb8c00.#f57c00.#ef6c00.#e65100.#ffd180.#ffab40.#ff9100.#ff6d00.#ff5722.#fbe9e7.#ffccbc.#ffab91.#ff8a65.#ff7043.#f4511e.#e64a19.#d84315.#bf360c.#ff9e80.#ff6e40.#ff3d00.#dd2c00.#795548.#efebe9.#d7ccc8.#bcaaa4.#a1887f.#8d6e63.#6d4c41.#5d4037.#4e342e.#3e2723.#.#.#.#.#607d8b.#eceff1.#cfd8dc.#b0bec5.#90a4ae.#78909c.#546e7a.#455a64.#37474f.#263238.#.#.#.#.#9e9e9e.#fafafa.#f5f5f5.#eeeeee.#e0e0e0.#bdbdbd.#757575.#616161.#424242.#212121.#.#.#.#.#000000.#FFFFFF.#FFFFFF00`.split(`.`),Ot=[`add_data_v`,`call_app_method_v`,`call_func_v`,`call_func_internal_v`,`delete_data_v`,`func_entry_v`,`implement_app_method_v`,`open_confirm_dlg_v`,`open_prompt_dlg_v`,`on_app_event_v`,`procedure_def_v`,`transaction_v`,`query_data_v`,`update_data_v`];function kt(e){return!!Ot.find(t=>e.startsWith(t))}const At=e.utils.xml,jt={init:function(){this.key=``,this.name=``,this.locale=!1,this.appendDummyInput().appendField(``,`LABEL`),this.setOutput(!0),this.setColour(220)},mutationToDom:function(){let e=At.createElement(`mutation`);return e.setAttribute(`key`,this.key),e.setAttribute(`name`,this.name),e.setAttribute(`locale`,this.locale?`TRUE`:`FALSE`),e},domToMutation:function(e){this.key=e.getAttribute(`key`)??``,this.name=e.getAttribute(`name`)??``,this.locale=e.getAttribute(`locale`)===`TRUE`,this.updateShape_(),setTimeout(()=>{this.checkWarning_()},0)},saveExtraState:function(){return{key:this.key,name:this.name,locale:this.locale}},loadExtraState:function(e){this.key=e.key??``,this.name=e.name??``,this.locale=e.locale??!1,this.updateShape_(),setTimeout(()=>{this.checkWarning_()},0)},setKeyName:function(e,t,n){this.key=e,this.name=t,this.locale=n,this.updateShape_(),setTimeout(()=>{this.checkWarning_()},0)},onchange:function(t){if(t.type===e.Events.BLOCK_MOVE){let e=t;if(e.blockId!==this.id)return;this.tryDuplicate_(e)}setTimeout(()=>{this.checkWarning_()},0)},tryDuplicate_:function(t){let n=this.workspace.getBlockById(t.oldParentId);if(n&&kt(n.type))try{e.Events.disable();let r=n.getInput(t.oldInputName)?.connection;if(r){let e=Mt(this.workspace,this.key,this.name,this.locale);r.connect(e.outputConnection)}}finally{e.Events.enable()}},updateShape_:function(){if(this.locale){let{i18n:e}=i;this.setFieldValue(e.global.t(this.name),`LABEL`)}else this.setFieldValue(this.name,`LABEL`)},checkWarning_:function(){let e=this.getSurroundParent();for(;e;){if(kt(e.type))for(let t of e.inputList){let e=t.connection?.targetBlock();if(!e||e.type!==`parameter_v1`)continue;let n=e;if(n.key===this.key){n.name!==this.name&&(this.name=n.name),n.locale!==this.locale&&(this.locale=n.locale),this.setWarningText(null);return}}e=e.getSurroundParent()}this.setWarningText(M(`WARN_PARAMETER_NOT_FOUND`))}};e.Blocks.parameter_v1=jt,n.forBlock.parameter_v1=function(e){return[e.key,t.ATOMIC]};function Mt(t,n,r,i){let a=`
|
|
2
|
+
import{A as e,B as t,C as n,D as r,E as i,F as a,G as o,H as s,I as c,K as l,L as u,M as ee,N as te,O as ne,P as d,R as re,S as ie,T as f,U as p,V as m,W as ae,_ as h,a as oe,b as g,c as _,d as v,f as y,g as b,h as se,i as ce,j as le,k as ue,l as de,m as fe,n as pe,o as me,p as x,q as S,r as he,s as ge,u as _e,v as ve,w as ye,x as be,y as C,z as xe}from"./vendor.ltuy0q0e.js";import{eventBus as Se,globalObjects as Ce,messageWarning as we,openConfirmDlg as Te,openPromptDlg as Ee,useColor as De,useSystem as Oe,useViewStack as ke}from"x-essential-lib";import{globalState as w}from"x-state-lib";import{addIndent as Ae,finalProperties as T,getElement as E,getImplementMethodName as je,getItems as Me,getTag as Ne,getTypes as Pe,makeEventId as D,makeEventKeyOfCustomSlot as Fe,makeEventKeyOfElementSlot as Ie,makeMethodId as Le,makeMethodKeyOfCustomSlot as Re,makeMethodKeyOfElementSlot as ze,makePropertyId as Be,makePropertyKeyOfCustomSlot as Ve,makePropertyKeyOfElementSlot as He,makeTriggerId as Ue,parseNumberUnit as We,pkgs as Ge,themeColors as Ke,toEventName as qe,toMethodName as Je,toPropertyName as Ye,unwrapEventId as Xe,unwrapEventKeyOfCustomSlot as Ze,unwrapEventKeyOfElementSlot as Qe,unwrapMethodId as $e,unwrapMethodKeyOfCustomSlot as et,unwrapMethodKeyOfElementSlot as tt,unwrapPropertyId as nt,unwrapPropertyKeyOfCustomSlot as rt,unwrapPropertyKeyOfElementSlot as it,unwrapSlotId as at}from"x-runtime-lib";import ot from"@sindresorhus/base62";import{Fragment as st,computed as O,createBlock as ct,createCommentVNode as lt,createElementBlock as k,createElementVNode as A,createVNode as j,defineComponent as ut,inject as dt,isRef as ft,mergeModels as pt,mergeProps as mt,nextTick as ht,normalizeStyle as M,onBeforeUnmount as gt,onMounted as _t,onUnmounted as vt,openBlock as N,provide as yt,ref as bt,renderList as xt,renderSlot as St,resolveComponent as P,resolveDirective as Ct,toDisplayString as wt,unref as F,useId as Tt,useModel as Et,useTemplateRef as Dt,watch as Ot,withCtx as kt,withDirectives as At,withKeys as jt,withModifiers as Mt}from"vue";import{useResizeObserver as Nt}from"@vueuse/core";import{useI18n as Pt}from"vue-i18n";import{useDisplay as Ft}from"vuetify";import{VueDraggable as It}from"vue-draggable-plus";import"highlight.js/styles/default.min.css";import Lt from"@highlightjs/vue-plugin";import Rt from"highlight.js/lib/core";import zt from"highlight.js/lib/languages/javascript";async function Bt(e){if(e===`en`)ae((await import(`./en.md0q5xx8.js`)).default);else if(e===`zhHans`)ae((await import(`./zhHans.ei0ea10m.js`)).default);else throw Error(`invalid locale=${e}`)}function I(e){return ye[e]??e}function Vt(e){let t=`<block type="text_v1"><field name="TEXT">${e}</field></block>`;return S.xml.textToDom(t)}function Ht(e){let t=`<block type="math_number_v1"><field name="NUM">${e}</field></block>`;return S.xml.textToDom(t)}function Ut(e){let t=`<block type="logic_boolean_v1"><field name="BOOL">${e?`TRUE`:`FALSE`}</field></block>`;return S.xml.textToDom(t)}function Wt(e,t){let n=null;return t===`string`?n=Vt(``):t===`integer`||t===`decimal`?n=Ht(0):t===`boolean`?n=Ut(!1):t===`enum`||t===`dateTime`?n=Vt(``):console.assert(!1,`type not implementd`),n?te.domToBlock(n,e):null}const Gt=`data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZlcnNpb249IjEuMSIgd2lkdGg9IjI0IiBoZWlnaHQ9IjI0Ij48cGF0aCBkPSJNMTggMTBoLTR2LTRjMC0xLjEwNC0uODk2LTItMi0ycy0yIC44OTYtMiAybC4wNzEgNGgtNC4wNzFjLTEuMTA0IDAtMiAuODk2LTIgMnMuODk2IDIgMiAybDQuMDcxLS4wNzEtLjA3MSA0LjA3MWMwIDEuMTA0Ljg5NiAyIDIgMnMyLS44OTYgMi0ydi00LjA3MWw0IC4wNzFjMS4xMDQgMCAyLS44OTYgMi0ycy0uODk2LTItMi0yeiIgZmlsbD0id2hpdGUiIC8+PC9zdmc+Cg==`,Kt=`data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZlcnNpb249IjEuMSIgd2lkdGg9IjI0IiBoZWlnaHQ9IjI0Ij48cGF0aCBkPSJNMTggMTFoLTEyYy0xLjEwNCAwLTIgLjg5Ni0yIDJzLjg5NiAyIDIgMmgxMmMxLjEwNCAwIDItLjg5NiAyLTJzLS44OTYtMi0yLTJ6IiBmaWxsPSJ3aGl0ZSIgLz48L3N2Zz4K`;function qt(e){let t=e.lastIndexOf(`V`);if(t<=0||t>=e.length-1)throw Error(`must has V`);return`${me(e.substring(0,t))}_${`v`+e.substring(t+1)}`}function Jt(e){let t=e.lastIndexOf(`V`);if(t<=0||t>=e.length-1)return console.assert(!1,`invalid key=${e}`),``;let n=e.substring(0,t-1);return`${n[0].toUpperCase()}${n.substring(1)}`}function L(e){return e.length<=0&&e.push([I(`NO_OPTION`),``]),e}function Yt(e){let t=0;for(;e;)t++,e=e.getParent();return t}function Xt(e){return e.ui===`text`?`string`:e.ui===`number`?`number`:e.ui===`switch`?`boolean`:`string`}function Zt(e,t){return!!(e.startsWith(`basic.`)||!t.ui||t.readonly)}function R(e){return e.startsWith(`globality_v`)}function Qt(e){return e.startsWith(`ref_v`)}function $t(e){return e.startsWith(`multiple_ref_v`)}function z(e){return e.startsWith(`slot_v`)}function B(e){return e.startsWith(`multiple_slot_v`)}function en(e,t,n){let{kind:r,mainKey:i,slotKey:a}=at(e);return!(r!==`elementSlot`&&r!==`multipleElementSlot`||t!==i||n!==a)}function tn(e,t,n){let{kind:r,mainKey:i,slotKey:a}=at(e);return!(r!==`customSlot`&&r!==`multipleCustomSlot`||t!==i||n!==a)}function V(e){return e===`string`?`String`:e===`number`?`Number`:e===`boolean`?`Boolean`:e===`array`?`Array`:e===`object`?`Object`:(e===`any`||console.assert(!1),null)}function nn(e){return e.array?`Array`:e.ui===`transient`?V(e.type):e.ui===`dummy`?null:e.ui===`text`?`String`:e.ui===`number`?`Number`:e.ui===`switch`?`Boolean`:e.ui===`select`?Jt(e.items):e.ui===`multiTypes`?Jt(e.types):e.ui===`comp`?`Comp`:e.ui===`slot`?`Slot`:e.ui===`adaptSlot`?`AdaptSlot`:(console.assert(!1),null)}function rn(e){return e===`string`?`String`:e===`integer`||e===`decimal`?`Number`:e===`boolean`?`Boolean`:e===`enum`||e===`dateTime`?`String`:(console.assert(!1),null)}const an=`#F44336.#FFEBEE.#FFCDD2.#EF9A9A.#E57373.#EF5350.#E53935.#D32F2F.#C62828.#B71C1C.#FF8A80.#FF5252.#FF1744.#D50000.#e91e63.#fce4ec.#f8bbd0.#f48fb1.#f06292.#ec407a.#d81b60.#c2185b.#ad1457.#880e4f.#ff80ab.#ff4081.#f50057.#c51162.#9c27b0.#f3e5f5.#e1bee7.#ce93d8.#ba68c8.#ab47bc.#8e24aa.#7b1fa2.#6a1b9a.#4a148c.#ea80fc.#e040fb.#d500f9.#aa00ff.#673ab7.#ede7f6.#d1c4e9.#b39ddb.#9575cd.#7e57c2.#5e35b1.#512da8.#4527a0.#311b92.#b388ff.#7c4dff.#651fff.#6200ea.#3f51b5.#e8eaf6.#c5cae9.#9fa8da.#7986cb.#5c6bc0.#3949ab.#303f9f.#283593.#1a237e.#8c9eff.#536dfe.#3d5afe.#304ffe.#2196F3.#E3F2FD.#BBDEFB.#90CAF9.#64B5F6.#42A5F5.#1E88E5.#1976D2.#1565C0.#0D47A1.#82B1FF.#448AFF.#2979FF.#2962FF.#03a9f4.#e1f5fe.#b3e5fc.#81d4fa.#4fc3f7.#29b6f6.#039be5.#0288d1.#0277bd.#01579b.#80d8ff.#40c4ff.#00b0ff.#0091ea.#00bcd4.#e0f7fa.#b2ebf2.#80deea.#4dd0e1.#26c6da.#00acc1.#0097a7.#00838f.#006064.#84ffff.#18ffff.#00e5ff.#00b8d4.#009688.#e0f2f1.#b2dfdb.#80cbc4.#4db6ac.#26a69a.#00897b.#00796b.#00695c.#004d40.#a7ffeb.#64ffda.#1de9b6.#00bfa5.#4CAF50.#E8F5E9.#C8E6C9.#A5D6A7.#81C784.#66BB6A.#43A047.#388E3C.#2E7D32.#1B5E20.#B9F6CA.#69F0AE.#00E676.#00C853.#8bc34a.#f1f8e9.#dcedc8.#c5e1a5.#aed581.#9ccc65.#7cb342.#689f38.#558b2f.#33691e.#ccff90.#b2ff59.#76ff03.#64dd17.#cddc39.#f9fbe7.#f0f4c3.#e6ee9c.#dce775.#d4e157.#c0ca33.#afb42b.#9e9d24.#827717.#f4ff81.#eeff41.#c6ff00.#aeea00.#ffeb3b.#fffde7.#fff9c4.#fff59d.#fff176.#ffee58.#fdd835.#fbc02d.#f9a825.#f57f17.#ffff8d.#ffff00.#ffea00.#ffd600.#ffc107.#fff8e1.#ffecb3.#ffe082.#ffd54f.#ffca28.#ffb300.#ffa000.#ff8f00.#ff6f00.#ffe57f.#ffd740.#ffc400.#ffab00.#ff9800.#fff3e0.#ffe0b2.#ffcc80.#ffb74d.#ffa726.#fb8c00.#f57c00.#ef6c00.#e65100.#ffd180.#ffab40.#ff9100.#ff6d00.#ff5722.#fbe9e7.#ffccbc.#ffab91.#ff8a65.#ff7043.#f4511e.#e64a19.#d84315.#bf360c.#ff9e80.#ff6e40.#ff3d00.#dd2c00.#795548.#efebe9.#d7ccc8.#bcaaa4.#a1887f.#8d6e63.#6d4c41.#5d4037.#4e342e.#3e2723.#.#.#.#.#607d8b.#eceff1.#cfd8dc.#b0bec5.#90a4ae.#78909c.#546e7a.#455a64.#37474f.#263238.#.#.#.#.#9e9e9e.#fafafa.#f5f5f5.#eeeeee.#e0e0e0.#bdbdbd.#757575.#616161.#424242.#212121.#.#.#.#.#000000.#FFFFFF.#FFFFFF00`.split(`.`),on=[`add_data_v`,`call_app_method_v`,`call_func_v`,`call_func_internal_v`,`delete_data_v`,`func_entry_v`,`implement_app_method_v`,`open_confirm_dlg_v`,`open_prompt_dlg_v`,`on_app_event_v`,`procedure_def_v`,`transaction_v`,`query_data_v`,`update_data_v`];function sn(e){return!!on.find(t=>e.startsWith(t))}const cn=S.xml;x.parameter_v1={init:function(){this.key=``,this.name=``,this.locale=!1,this.appendDummyInput().appendField(``,`LABEL`),this.setOutput(!0),this.setColour(220)},mutationToDom:function(){let e=cn.createElement(`mutation`);return e.setAttribute(`key`,this.key),e.setAttribute(`name`,this.name),e.setAttribute(`locale`,this.locale?`TRUE`:`FALSE`),e},domToMutation:function(e){this.key=e.getAttribute(`key`)??``,this.name=e.getAttribute(`name`)??``,this.locale=e.getAttribute(`locale`)===`TRUE`,this.updateShape_(),setTimeout(()=>{this.checkWarning_()},0)},saveExtraState:function(){return{key:this.key,name:this.name,locale:this.locale}},loadExtraState:function(e){this.key=e.key??``,this.name=e.name??``,this.locale=e.locale??!1,this.updateShape_(),setTimeout(()=>{this.checkWarning_()},0)},setKeyName:function(e,t,n){this.key=e,this.name=t,this.locale=n,this.updateShape_(),setTimeout(()=>{this.checkWarning_()},0)},onchange:function(e){if(e.type===b.BLOCK_MOVE){let t=e;if(t.blockId!==this.id)return;this.tryDuplicate_(t)}setTimeout(()=>{this.checkWarning_()},0)},tryDuplicate_:function(e){let t=this.workspace.getBlockById(e.oldParentId);if(t&&sn(t.type))try{b.disable();let n=t.getInput(e.oldInputName)?.connection;if(n){let e=ln(this.workspace,this.key,this.name,this.locale);n.connect(e.outputConnection)}}finally{b.enable()}},updateShape_:function(){if(this.locale){let{i18n:e}=Ce;this.setFieldValue(e.global.t(this.name),`LABEL`)}else this.setFieldValue(this.name,`LABEL`)},checkWarning_:function(){let e=this.getSurroundParent();for(;e;){if(sn(e.type))for(let t of e.inputList){let e=t.connection?.targetBlock();if(!e||e.type!==`parameter_v1`)continue;let n=e;if(n.key===this.key){n.name!==this.name&&(this.name=n.name),n.locale!==this.locale&&(this.locale=n.locale),this.setWarningText(null);return}}e=e.getSurroundParent()}this.setWarningText(I(`WARN_PARAMETER_NOT_FOUND`))}},y.forBlock.parameter_v1=function(e){return[e.key,v.ATOMIC]};function ln(e,t,n,r){let i=`
|
|
3
3
|
<block type="parameter_v1">
|
|
4
|
-
<mutation key="${
|
|
4
|
+
<mutation key="${t}" name="${n}" locale="${r?`TRUE`:`FALSE`}"/>
|
|
5
5
|
</block>
|
|
6
|
-
`,
|
|
6
|
+
`,a=S.xml.textToDom(i);return te.domToBlock(a,e)}function H(e,t){try{b.disable(),t.forEach(t=>{let[n,r,i,a]=t,o=e.getInput(n)?.connection;if(!o)return;let s=o.targetBlock();if(s){let e=s;if(e&&e.key===r&&e.name===i&&e.locale===a)return;s.dispose()}s=ln(e.workspace,r,i,a),s.outputConnection.connect(o)})}finally{b.enable()}}function un(e){let t=`<shadow type="text_v1"><field name="TEXT">${e}</field></shadow>`;return S.xml.textToDom(t)}function dn(e){let t=`<shadow type="math_number_v1"><field name="NUM">${e}</field></shadow>`;return S.xml.textToDom(t)}function fn(e){let t=`<shadow type="logic_boolean_v1"><field name="BOOL">${e?`TRUE`:`FALSE`}</field></shadow>`;return S.xml.textToDom(t)}function pn(){return S.xml.textToDom(`<shadow type="list_create_v1"></shadow>`)}function mn(){return S.xml.textToDom(`<shadow type="object_create_v1"></shadow>`)}function hn(e){let t=`<shadow type="${qt(e)}"></shadow>`;return S.xml.textToDom(t)}function gn(e){let t=`<shadow type="${qt(e)}"></shadow>`;return S.xml.textToDom(t)}function _n(){return S.xml.textToDom(`<shadow type="select_comp_v1"></shadow>`)}function vn(){return S.xml.textToDom(`<shadow type="select_slot_v1"></shadow>`)}function yn(){return S.xml.textToDom(`
|
|
7
7
|
<shadow type="app_bind_entry_v1">
|
|
8
8
|
<field name="KIND">notSet</field>
|
|
9
|
-
</shadow>`)}function V(e){let t=null;return e===`string`?t=Nt(``):e===`number`?t=Pt(0):e===`boolean`?t=Ft(!1):e===`array`?t=It():e===`object`?t=Lt():e===`any`?t=null:console.assert(!1,`type not implementd`),t}function Ut(e){let t=null;return e.array?t=It():e.ui===`transient`?t=V(e.type):e.ui===`dummy`?t=null:e.ui===`text`?t=Nt(e.default):e.ui===`number`?t=Pt(e.default??0):e.ui===`switch`?t=Ft(e.default):e.ui===`select`?t=Rt(e.items):e.ui===`multiTypes`?t=zt(e.types):e.ui===`comp`?t=Bt():e.ui===`slot`?t=Vt():console.assert(!1,`property ui not implementd`),t}function Wt(){let{activeObject:e,activePage:t}=d.app,n=[];if(e.type===`page`&&t.meta.arguments)for(let{id:e,name:r,type:i}of t.meta.arguments)n.push({key:e,name:r,type:i});return n}function Gt(e){let{activeObject:t,activePage:n}=d.app;if(t.type===`page`){let t=n.meta.arguments?.find(t=>t.id===e);if(t)return{key:t.id,name:t.name,type:t.type}}}function Kt(){let e=[];return Wt().forEach(({key:t,name:n})=>{e.push([n,t])}),N(e)}const qt={init:function(){this.argument={key:``,name:``,type:`string`},this.appendDummyInput().appendField(`%{BKY_APP_V1_GET_PAGE_ARGUMENT_TITLE}`).appendField(new e.FieldDropdown(()=>this.genArgumentOpts_()),`ARGUMENT`),this.setOutput(!0,null),this.setStyle(`variable_blocks`),this.setTooltip(`%{BKY_APP_V1_GET_PAGE_ARGUMENT_TOOLTIP}`),this.setHelpUrl(`%{BKY_APP_V1_GET_PAGE_ARGUMENT_HELPURL}`)},saveExtraState:function(){return{argument:this.argument}},loadExtraState:function(e){this.argument.key=e.argument?.key??``,this.argument.name=e.argument?.name??``,this.argument.type=e.argument?.type??``,this.updateShape_(),setTimeout(()=>{this.checkWarning_()},0)},genArgumentOpts_:function(){return Kt()},onchange:function(t){if(t.type===e.Events.BLOCK_CHANGE){let e=t;e.blockId===this.id&&(e.element===`field`&&e.name===`ARGUMENT`&&this.onArgumentChange_(e.newValue),setTimeout(()=>{this.checkWarning_()},0))}},onArgumentChange_:function(e){let t=Gt(e);if(!t){console.assert(!1);return}this.argument.key=t.key,this.argument.name=t.name,this.argument.type=t.type,this.updateShape_()},updateShape_:function(){this.setOutput(!0,z(this.argument.type))},checkWarning_:function(){let e=Gt(this.argument.key);if(!e){this.setWarningText(M(`WARN_ARGUMENT_NOT_FOUND`));return}if(e.name!==this.argument.name&&(this.argument.name=e.name),e.type!==this.argument.type){this.setWarningText(M(`WARN_ARGUMENT_HAS_CHANGED`));return}this.setWarningText(null)}};e.Blocks.get_page_argument_v1=qt,n.forBlock.get_page_argument_v1=function(e){let r=e;return[`__getPageArgumentV1__(${n.quote_(r.argument.key)})`,t.FUNCTION_CALL]};const Jt=(r,a)=>{let o=vt(r),s=yt(r);e.Blocks[o]={init:function(){this.appendDummyInput().appendField(new e.FieldDropdown(()=>this.genOpts_()),`ITEM`),this.setOutput(!0,s),this.setStyle(`property_blocks`),this.setTooltip(``),this.setHelpUrl(``)},genOpts_:function(){let{i18n:e}=i,t=[];for(let{title:n,value:r}of a)t.push([e.global.t(n),r]);return N(t)}},n.forBlock[o]=function(e){let r=n.quote_;return[r(e.getFieldValue(`ITEM`)),t.ATOMIC]}};for(let e in de){let t=de[e];for(let e of t.items)Jt(e,ne(e))}const Yt=(r,a)=>{let o=vt(r),s=yt(r);e.Blocks[o]={init:function(){this.value=a[0].default,this.appendDummyInput(`DUMMY`).appendField(new e.FieldDropdown(()=>this.genOpts_()),`TYPE`),this.setOutput(!0,s),this.setStyle(`property_blocks`),this.setTooltip(``),this.setHelpUrl(``),this.updateShape_()},saveExtraState:function(){return{value:this.value}},loadExtraState:function(e){this.value=e.value,this.updateShape_(),setTimeout(()=>{this.checkWarning_()},0)},genOpts_:function(){let{i18n:e}=i,t=[];for(let{title:n,value:r}of a)t.push([e.global.t(n),r]);return N(t)},onchange:function(t){if(t.type===e.Events.BLOCK_CHANGE){let e=t;e.blockId===this.id&&(e.element===`field`&&e.name===`TYPE`&&this.onTypeChange_(e.newValue),setTimeout(()=>{this.checkWarning_()},0))}},onTypeChange_:function(e){let t=a.find(t=>t.value===e);if(!t){console.assert(!1);return}this.value=t.default,this.updateShape_()},updateShape_:function(){let t=this.getInput(`DUMMY`);if(!t)return;let n=a.find(e=>e.validator(this.value));if(!n)return;t.removeField(`VALUE`,!0),t.removeField(`SUFFIX`,!0);let r,o;if(n.trait===`number`){let t=this.value??0;r=new e.FieldNumber(t,n.min,n.max,n.precision?1/10**n.precision:null,e=>{this.value=e})}else if(n.trait===`numberUnit`){let t=ue(this.value,n.unit)??0;r=new e.FieldNumber(t,n.min,n.max,n.precision?1/10**n.precision:null,e=>{this.value=e+n.unit}),o=n.unit}else if(n.trait===`hexColor`)r=new Ae(this.value,e=>{this.value=e},{colourOptions:Dt,columns:14});else if(n.trait===`themeColor`){let{i18n:t}=i;r=new e.FieldDropdown(()=>{let e=[];for(let{value:n,title:r}of fe)e.push([t.global.t(r),n]);return e},e=>{this.value=e})}r&&t.appendField(r,`VALUE`),o&&t.appendField(o,`SUFFIX`)},checkWarning_:function(){if(!a.find(e=>e.validator(this.value))){this.setWarningText(M(`WARN_TYPE_NOT_FOUND`));return}this.setWarningText(null)}},n.forBlock[o]=function(e){let r=n.quote_,i=e;return typeof i.value==`string`?[r(i.value),t.ATOMIC]:[i.value,t.ATOMIC]}};for(let e in de){let t=de[e];for(let e of t.types)Yt(e,re(e))}function Xt(){let e=[],{appList:t}=d.app;for(let{id:n,name:r}of t)e.push({id:n,name:r});return e}function Zt(e){let{appList:t}=d.app,n=t.find(t=>t.id===e);if(n)return{id:n.id,name:n.name}}function Qt(){let e=[];return Xt().forEach(({id:t,name:n})=>{e.push([n,t])}),N(e)}function $t(e,t){let{activeObject:n,activeComp:r}=d.app;if(L(e.key)&&t&&n.type===`comp`&&r.meta.slots){let e=r.meta.slots.find(e=>e.id===t);if(e&&e.events&&e.events.length>0)return!1}if(R(e.key)&&t&&n.type===`comp`&&r.meta.slots){let e=r.meta.slots.find(e=>e.id===t);if(e&&e.events&&e.events.length>0)return!1}return!(P(e.key)&&n.type===`comp`&&r.meta.events&&r.meta.events.length>0)}function en(e,t,n){let{activeObject:r,activeComp:i,depends:a}=d.app;if(e.methods&&e.methods.length>0)return!1;if(F(e.key)&&t){let e=a[t];if(e&&e.meta.methods&&e.meta.methods.length>0)return!1}if(I(e.key)&&t){let e=a[t];if(e&&e.meta.methods&&e.meta.methods.length>0)return!1}if(P(e.key)&&r.type===`comp`&&i.meta.methods&&i.meta.methods.length>0)return!1;if(P(e.key)&&n&&r.type===`comp`){let{kind:e,mainKey:t,slotKey:r}=we(n);if(e===`elementSlot`){let e=p(t);if(e&&e.slots){let t=e.slots.find(e=>e.key===r);if(t&&t.methods&&t.methods.length>0)return!1}}else if(e===`customSlot`){let e=a[t];if(e&&e.meta.slots){let t=e.meta.slots.find(e=>e.id===r);if(t&&t.methods&&t.methods.length>0)return!1}}}return!0}function tn(e,t){let{activeObject:n,activeComp:r}=d.app;if(L(e.key)&&t&&n.type===`comp`&&r.meta.slots){let e=r.meta.slots.find(e=>e.id===t);if(e&&e.methods&&e.methods.length>0)return!1}if(R(e.key)&&t&&n.type===`comp`&&r.meta.slots){let e=r.meta.slots.find(e=>e.id===t);if(e&&e.methods&&e.methods.length>0)return!1}return!(P(e.key)&&n.type===`comp`&&r.meta.methods&&r.meta.methods.length>0)}function nn(e,t){let{activeObject:n,activeComp:r}=d.app;if(L(e.key)&&t&&n.type===`comp`&&r.meta.slots){let e=r.meta.slots.find(e=>e.id===t);if(e&&e.methods){for(let{outputs:t}of e.methods)if(t&&t.length>0)return!1}}if(R(e.key)&&t&&n.type===`comp`&&r.meta.slots){let e=r.meta.slots.find(e=>e.id===t);if(e&&e.methods){for(let{outputs:t}of e.methods)if(t&&t.length>0)return!1}}if(P(e.key)&&n.type===`comp`&&r.meta.methods){for(let{outputs:e}of r.meta.methods)if(e&&e.length>0)return!1}return!0}function rn(e,t,n,r,i){return e===`triggerEvent`?$t(t,n):e===`callMethod`?en(t,r,i):e===`implementMethod`?tn(t,n):e===`implementMethodOutput`?nn(t,n):!1}function H(e){let{activeObject:t}=d.app;for(let n of t.nodes){let t=p(n.key);if(!t){console.assert(!1,`invalid element`,n.key);continue}if(!rn(e,t,n.slot,n.comp,n.adaptSlot))return!0}return!1}function U(e){let{activeObject:t}=d.app,n=[];for(let r of t.nodes){let t=p(r.key);if(!t){console.assert(!1,`invalid element`,r.key);continue}rn(e,t,r.slot,r.comp,r.adaptSlot)||n.push({id:r.id,key:r.key,name:t.name,alias:r.alias})}return n}function W(e){let{activeObject:t}=d.app,n=t.nodes.find(t=>t.id===e);if(!n)return;let r=p(n.key);if(!r){console.assert(!1,`invalid element`,n.key);return}return{id:n.id,key:n.key,name:r.name,alias:n.alias}}function an(e){let{i18n:t}=i,n=[],r=U(e);for(let{id:e,name:i,alias:a}of r){let r=t.global.t(i);a&&(r+=` / `+a),n.push([r,e])}return N(n)}function on(){let{activeObject:e,activePage:t,activeComp:n}=d.app;return e.type===`page`?t.meta.states??[]:e.type===`comp`?n.meta.states??[]:[]}function sn(e){let{activeObject:t,activePage:n,activeComp:r}=d.app;if(t.type===`page`)return n.meta.states?.find(t=>t.id===e);if(t.type===`comp`)return r.meta.states?.find(t=>t.id===e)}function cn(){let e=[],t=on();for(let{id:n,name:r}of t)e.push([r,n]);return N(e)}function ln(){let e=[`notSet`];return U(`setProperty`).length>0&&e.push(`property`),on().length>0&&e.push(`state`),e}function un(){let{i18n:e}=i;return N(ln().map(t=>t===`notSet`?[e.global.t(`x-runtime-lib.${t}`),t]:[M(`APP_${ke(t)}`),t]))}function dn(){let{activeApp:e}=d.app,t=[{id:``,name:``}];for(let{id:n,name:r}of e.comps)t.push({id:n,name:r});return t}function fn(e){let{activeApp:t}=d.app;if(!e)return{id:``,name:``};let n=t.comps.find(t=>t.id===e);if(n)return{id:n.id,name:n.name}}function pn(){let{i18n:e}=i,t=[];return dn().forEach(({id:n,name:r})=>{let i=r;n===``&&(i=e.global.t(`x-runtime-lib.notSet`)),t.push([i,n])}),N(t)}function G(e){if(!e)return;let t=[];for(let{id:n,name:r,type:i}of e)t.push({key:n,name:r,type:i});return t}function K(e){return[{key:`newValue`,name:`x-runtime-lib.newValue`,type:e},{key:`oldValue`,name:`x-runtime-lib.oldValue`,type:e}]}function mn(e){let t=!0;switch(e){case``:break;case`elementEvent`:case`elementPropertyChangeEvent`:case`elementSlotEvent`:case`elementSlotPropertyChangeEvent`:case`multipleElementSlotEvent`:case`multipleElementSlotPropertyChangeEvent`:break;case`refEvent`:t=!1;break;case`refPropertyChangeEvent`:break;case`multipleRefEvent`:t=!1;break;case`multipleRefPropertyChangeEvent`:break;case`customSlotEvent`:t=!1;break;case`customSlotPropertyChangeEvent`:break;case`multipleCustomSlotEvent`:t=!1;break;case`multipleCustomSlotPropertyChangeEvent`:break;case`customEvent`:t=!1;break;case`customPropertyChangeEvent`:break;case`elementAdaptSlotEvent`:break;case`elementAdaptSlotPropertyChangeEvent`:break;case`customAdaptSlotEvent`:t=!1;break;case`customAdaptSlotPropertyChangeEvent`:break;case`stateChangeEvent`:break;default:console.assert(!1,`not implemented kind=${e}`)}return t}function hn(e){let{activeObject:t,activePage:n,activeComp:r,depends:i}=d.app,a=[],o=m(t.type,t.subtype),s=t.nodes.find(t=>t.id===e);if(!s)return a;let c=p(s.key);if(!c)return console.assert(!1,`invalid element`,s.key),a;if(c.events)for(let{key:t,name:n,params:r}of c.events)a.push({id:h(`elementEvent`,e,t),kind:`elementEvent`,names:[n],params:r});if(f[c.key]&&f[c.key][o])for(let{keys:t,names:n,raw:r}of f[c.key][o])a.push({id:h(`elementPropertyChangeEvent`,e,t),kind:`elementPropertyChangeEvent`,names:n,params:K(xt(r))});if(F(c.key)&&s.comp){let t=i[s.comp];if(t&&t.meta.events)for(let{id:n,name:r,params:i}of t.meta.events)a.push({id:h(`refEvent`,e,n),kind:`refEvent`,names:[r],params:G(i)})}if(F(c.key)&&s.comp){let t=i[s.comp];if(t&&t.meta.properties)for(let{id:n,name:r,type:i}of t.meta.properties)a.push({id:h(`refPropertyChangeEvent`,e,n),kind:`refPropertyChangeEvent`,names:[r],params:K(i)})}if(I(c.key)&&s.comp){let t=i[s.comp];if(t&&t.meta.events)for(let{id:n,name:r,params:i}of t.meta.events)a.push({id:h(`multipleRefEvent`,e,n),kind:`multipleRefEvent`,names:[r],params:G(i)})}if(I(c.key)&&s.comp){let t=i[s.comp];if(t&&t.meta.properties)for(let{id:n,name:r,type:i}of t.meta.properties)a.push({id:h(`multipleRefPropertyChangeEvent`,e,n),kind:`multipleRefPropertyChangeEvent`,names:[r],params:K(i)})}if(L(c.key)&&s.slot&&t.type===`comp`&&r.meta.slots){let t=r.meta.slots.find(e=>e.id===s.slot);if(t&&t.events)for(let n of t.events)a.push({id:h(`customSlotEvent`,e,ie(r.id,t.id,n.id)),kind:`customSlotEvent`,names:[t.name,n.name],params:G(n.params)})}if(L(c.key)&&s.slot&&t.type===`comp`&&r.meta.slots){let t=r.meta.slots.find(e=>e.id===s.slot);if(t&&t.properties)for(let n of t.properties)a.push({id:h(`customSlotPropertyChangeEvent`,e,ce(r.id,t.id,n.id)),kind:`customSlotPropertyChangeEvent`,names:[t.name,n.name],params:K(n.type)})}if(R(c.key)&&s.slot&&t.type===`comp`&&r.meta.slots){let t=r.meta.slots.find(e=>e.id===s.slot);if(t&&t.events)for(let n of t.events)a.push({id:h(`multipleCustomSlotEvent`,e,ie(r.id,t.id,n.id)),kind:`multipleCustomSlotEvent`,names:[t.name,n.name],params:G(n.params)})}if(R(c.key)&&s.slot&&t.type===`comp`&&r.meta.slots){let t=r.meta.slots.find(e=>e.id===s.slot);if(t&&t.properties)for(let n of t.properties)a.push({id:h(`multipleCustomSlotPropertyChangeEvent`,e,ce(r.id,t.id,n.id)),kind:`multipleCustomSlotPropertyChangeEvent`,names:[t.name,n.name],params:K(n.type)})}if(P(c.key)&&t.type===`comp`&&r.meta.events)for(let{id:t,name:n,params:i}of r.meta.events)a.push({id:h(`customEvent`,e,t),kind:`customEvent`,names:[n],params:G(i)});if(P(c.key)&&t.type===`comp`&&r.meta.properties)for(let{id:t,name:n,type:i}of r.meta.properties)a.push({id:h(`customPropertyChangeEvent`,e,t),kind:`customPropertyChangeEvent`,names:[n],params:K(i)});if(P(c.key)&&t.type===`comp`&&s.adaptSlot){let{kind:t,mainKey:n,slotKey:r}=we(s.adaptSlot);if(t===`elementSlot`){let t=p(n);if(t&&t.slots){let i=t.slots.find(e=>e.key===r);if(i&&i.events)for(let o of i.events)a.push({id:h(`elementAdaptSlotEvent`,e,ae(n,r,o.key)),kind:`elementAdaptSlotEvent`,names:[t.name,i.name,o.name],params:o.params});if(i&&i.properties)for(let n of i.properties)a.push({id:h(`elementAdaptSlotPropertyChangeEvent`,e,le(t.key,i.key,n.key)),kind:`elementAdaptSlotPropertyChangeEvent`,names:[t.name,i.name,n.name],params:K(n.type)})}}else if(t===`customSlot`){let t=i[n];if(t&&t.meta.slots){let i=t.meta.slots.find(e=>e.id===r);if(i&&i.events)for(let r of i.events)a.push({id:h(`customAdaptSlotEvent`,e,ie(n,i.id,r.id)),kind:`customAdaptSlotEvent`,names:[t.name,i.name,r.name],params:G(r.params)});if(i&&i.properties)for(let r of i.properties)a.push({id:h(`customAdaptSlotPropertyChangeEvent`,e,ce(n,i.id,r.id)),kind:`customAdaptSlotPropertyChangeEvent`,names:[t.name,i.name,r.name],params:K(r.type)})}}}if(P(c.key)){if(t.type===`page`){if(n.meta.states)for(let{id:e,name:t,type:r}of n.meta.states)a.push({id:h(`stateChangeEvent`,`globality`,e),kind:`stateChangeEvent`,names:[t],params:K(r)})}else if(t.type===`comp`&&r.meta.states)for(let{id:e,name:t,type:n}of r.meta.states)a.push({id:h(`stateChangeEvent`,`globality`,e),kind:`stateChangeEvent`,names:[t],params:K(n)})}return a}function gn(e){if(!e)return;let{activeObject:t,activePage:n,activeComp:r,depends:i}=d.app,a=m(t.type,t.subtype),{kind:o,nodeId:s,eventKey:c}=ge(e),l=t.nodes.find(e=>e.id===s);if(!l)return;let u=p(l.key);if(!u){console.assert(!1,`invalid element`,l.key);return}if(o===`elementEvent`){let t=u.events?.find(e=>e.key===c);if(t)return{id:e,kind:o,names:[t.name],params:t.params}}else if(o===`elementPropertyChangeEvent`){if(f[u.key]&&f[u.key][a]){let t=f[u.key][a].find(e=>e.keys===c);if(t)return{id:e,kind:o,names:t.names,params:K(xt(t.raw))}}}else if(o===`refEvent`){if(F(u.key)&&l.comp){let t=i[l.comp];if(t){let n=t.meta.events?.find(e=>e.id===c);if(n)return{id:e,kind:o,names:[n.name],params:G(n.params)}}}}else if(o===`refPropertyChangeEvent`){if(F(u.key)&&l.comp){let t=i[l.comp];if(t){let n=t.meta.properties?.find(e=>e.id===c);if(n)return{id:e,kind:o,names:[n.name],params:K(n.type)}}}}else if(o===`multipleRefEvent`){if(I(u.key)&&l.comp){let t=i[l.comp];if(t){let n=t.meta.events?.find(e=>e.id===c);if(n)return{id:e,kind:o,names:[n.name],params:G(n.params)}}}}else if(o===`multipleRefPropertyChangeEvent`){if(I(u.key)&&l.comp){let t=i[l.comp];if(t){let n=t.meta.properties?.find(e=>e.id===c);if(n)return{id:e,kind:o,names:[n.name],params:K(n.type)}}}}else if(o===`customSlotEvent`){if(L(u.key)&&l.slot&&t.type===`comp`&&r.meta.slots){let{compId:t,slotId:n,eventId:i}=y(c);if(r.id===t&&l.slot===n){let t=r.meta.slots.find(e=>e.id===n);if(t&&t.events){let n=t.events.find(e=>e.id===i);if(n)return{id:e,kind:o,names:[t.name,n.name],params:G(n.params)}}}}}else if(o===`customSlotPropertyChangeEvent`){if(L(u.key)&&l.slot&&t.type===`comp`&&r.meta.slots){let{compId:t,slotId:n,eventId:i}=y(c);if(r.id===t&&l.slot===n){let t=r.meta.slots.find(e=>e.id===n);if(t&&t.properties){let n=t.properties.find(e=>e.id===i);if(n)return{id:e,kind:o,names:[t.name,n.name],params:K(n.type)}}}}}else if(o===`multipleCustomSlotEvent`){if(R(u.key)&&l.slot&&t.type===`comp`&&r.meta.slots){let{compId:t,slotId:n,eventId:i}=y(c);if(r.id===t&&l.slot&&n){let t=r.meta.slots.find(e=>e.id===n);if(t&&t.events){let n=t.events.find(e=>e.id===i);if(n)return{id:e,kind:o,names:[t.name,n.name],params:G(n.params)}}}}}else if(o===`multipleCustomSlotPropertyChangeEvent`){if(R(u.key)&&l.slot&&t.type===`comp`&&r.meta.slots){let{compId:t,slotId:n,eventId:i}=y(c);if(r.id===t&&l.slot===n){let t=r.meta.slots.find(e=>e.id===n);if(t&&t.properties){let n=t.properties.find(e=>e.id===i);if(n)return{id:e,kind:o,names:[t.name,n.name],params:K(n.type)}}}}}else if(o===`customEvent`){if(P(u.key)&&t.type===`comp`){let t=r.meta.events?.find(e=>e.id===c);if(t)return{id:e,kind:o,names:[t.name],params:G(t.params)}}}else if(o===`customPropertyChangeEvent`){if(P(u.key)&&t.type===`comp`){let t=r.meta.properties?.find(e=>e.id===c);if(t)return{id:e,kind:o,names:[t.name],params:K(t.type)}}}else if(o===`elementAdaptSlotEvent`){if(P(u.key)&&t.type===`comp`&&l.adaptSlot){let{elementKey:t,slotKey:n,eventKey:r}=_e(c);if(Ct(l.adaptSlot,t,n)){let i=p(t);if(i&&i.slots){let t=i.slots.find(e=>e.key===n);if(t&&t.events){let n=t.events.find(e=>e.key===r);if(n)return{id:e,kind:o,names:[i.name,t.name,n.name],params:n.params}}}}}}else if(o===`elementAdaptSlotPropertyChangeEvent`){if(P(u.key)&&t.type===`comp`&&l.adaptSlot){let{elementKey:t,slotKey:n,propertyKey:r}=Ce(c);if(Ct(l.adaptSlot,t,n)){let i=p(t);if(i&&i.slots){let t=i.slots.find(e=>e.key===n);if(t&&t.properties){let n=t.properties.find(e=>e.key===r);if(n)return{id:e,kind:o,names:[i.name,t.name,n.name],params:K(n.type)}}}}}}else if(o===`customAdaptSlotEvent`){if(P(u.key)&&t.type===`comp`&&l.adaptSlot){let{compId:t,slotId:n,eventId:r}=y(c);if(wt(l.adaptSlot,t,n)){let a=i[t];if(a&&a.meta.slots){let t=a.meta.slots.find(e=>e.id===n);if(t&&t.events){let n=t.events.find(e=>e.id===r);if(n)return{id:e,kind:o,names:[a.name,t.name,n.name],params:G(n.params)}}}}}}else if(o===`customAdaptSlotPropertyChangeEvent`){if(P(u.key)&&t.type===`comp`&&l.adaptSlot){let{compId:t,slotId:n,propertyId:r}=Se(c);if(wt(l.adaptSlot,t,n)){let a=i[t];if(a&&a.meta.slots){let t=a.meta.slots.find(e=>e.id===n);if(t&&t.properties){let n=t.properties.find(e=>e.id===r);if(n)return{id:e,kind:o,names:[a.name,t.name,n.name],params:K(n.type)}}}}}}else if(o===`stateChangeEvent`&&P(u.key)){if(t.type===`page`){let t=n.meta.states?.find(e=>e.id===c);if(t)return{id:e,kind:o,names:[t.name],params:K(t.type)}}else if(t.type===`comp`){let t=r.meta.states?.find(e=>e.id===c);if(t)return{id:e,kind:o,names:[t.name],params:K(t.type)}}}}function _n(e){let t=[],n=hn(e),r;for(let{id:e,kind:i,names:a}of n)i!==r&&(r&&t.push(`separator`),r=i),t.push([pe(i,a),e]);return N(t)}function vn(e){let{activeObject:t,activeComp:n}=d.app,r=[],i=t.nodes.find(t=>t.id===e);if(!i)return r;let a=p(i.key);if(!a)return console.assert(!1,`invalid element`,i.key),r;if(L(a.key)&&i.slot&&t.type===`comp`&&n.meta.slots){let t=n.meta.slots.find(e=>e.id===i.slot);if(t&&t.events)for(let i of t.events)r.push({id:h(`customSlotEvent`,e,ie(n.id,t.id,i.id)),kind:`customSlotEvent`,names:[t.name,i.name],params:G(i.params)})}if(R(a.key)&&i.slot&&t.type===`comp`&&n.meta.slots){let t=n.meta.slots.find(e=>e.id===i.slot);if(t&&t.events)for(let i of t.events)r.push({id:h(`multipleCustomSlotEvent`,e,ie(n.id,t.id,i.id)),kind:`multipleCustomSlotEvent`,names:[t.name,i.name],params:G(i.params)})}if(P(a.key)&&t.type===`comp`&&n.meta.events)for(let e of n.meta.events)r.push({id:h(`customEvent`,`globality`,e.id),kind:`customEvent`,names:[e.name],params:G(e.params)});return r}function yn(e){if(!e)return;let{activeObject:t,activeComp:n}=d.app,{kind:r,nodeId:i,eventKey:a}=ge(e),o=t.nodes.find(e=>e.id===i);if(!o)return;let s=p(o.key);if(!s){console.assert(!1,`invalid element`,o.key);return}if(r===`customSlotEvent`){if(L(s.key)&&o.slot&&t.type===`comp`&&n.meta.slots){let{compId:t,slotId:i,eventId:s}=y(a);if(n.id===t&&o.slot===i){let t=n.meta.slots.find(e=>e.id===i);if(t&&t.events){let n=t.events.find(e=>e.id===s);if(n)return{id:e,kind:r,names:[t.name,n.name],params:G(n.params)}}}}}else if(r===`multipleCustomSlotEvent`){if(R(s.key)&&o.slot&&t.type===`comp`&&n.meta.slots){let{compId:t,slotId:i,eventId:s}=y(a);if(n.id===t&&o.slot&&i){let t=n.meta.slots.find(e=>e.id===i);if(t&&t.events){let n=t.events.find(e=>e.id===s);if(n)return{id:e,kind:r,names:[t.name,n.name],params:G(n.params)}}}}}else if(r===`customEvent`&&P(s.key)&&t.type===`comp`&&n.meta.events){let t=n.meta.events.find(e=>e.id===a);if(t)return{id:e,kind:r,names:[t.name],params:G(t.params)}}}function bn(e){let t=[],n=vn(e),r;for(let{id:e,kind:i,names:a}of n)i!==r&&(r&&t.push(`separator`),r=i),t.push([pe(i,a),e]);return N(t)}function q(e){if(!e)return;let t=[];for(let{id:n,name:r,type:i}of e)t.push({key:n,name:r,type:i});return t}function J(e){if(!e)return;let t=[];for(let{id:n,name:r,type:i}of e)t.push({key:n,name:r,type:i});return t}function xn(e){let t=!0;switch(e){case``:break;case`elementMethod`:case`elementSlotMethod`:case`multipeElementSlotMethod`:break;case`refMethod`:case`multipleRefMethod`:t=!1;break;case`customSlotMethod`:case`multipleCustomSlotMethod`:t=!1;break;case`customMethod`:t=!1;break;case`elementAdaptSlotMethod`:break;case`customAdaptSlotMethod`:t=!1;break;default:console.assert(!1,`not implemented kind=${e}`)}return t}function Sn(e){let{activeObject:t,activeComp:n,depends:r}=d.app,i=[],a=t.nodes.find(t=>t.id===e);if(!a)return i;let o=p(a.key);if(!o)return console.assert(!1,`inavlid element`,a.key),i;if(o.methods)for(let{key:t,name:n,inputs:r,outputs:a}of o.methods)i.push({id:g(`elementMethod`,e,t),kind:`elementMethod`,names:[n],inputs:r,outputs:a});if(F(o.key)&&a.comp){let t=r[a.comp];if(t&&t.meta.methods)for(let{id:n,name:r,inputs:a,outputs:o}of t.meta.methods)i.push({id:g(`refMethod`,e,n),kind:`refMethod`,names:[r],inputs:q(a),outputs:J(o)})}if(I(o.key)&&a.comp){let t=r[a.comp];if(t&&t.meta.methods)for(let{id:n,name:r,inputs:a,outputs:o}of t.meta.methods)i.push({id:g(`multipleRefMethod`,e,n),kind:`multipleRefMethod`,names:[r],inputs:q(a),outputs:J(o)})}if(P(o.key)&&t.type===`comp`&&n.meta.methods)for(let{id:t,name:r,inputs:a,outputs:o}of n.meta.methods)i.push({id:g(`customMethod`,e,t),kind:`customMethod`,names:[r],inputs:q(a),outputs:J(o)});if(P(o.key)&&t.type===`comp`&&a.adaptSlot){let{kind:t,mainKey:n,slotKey:o}=we(a.adaptSlot);if(t===`elementSlot`){let t=p(n);if(t&&t.slots){let n=t.slots.find(e=>e.key===o);if(n&&n.methods)for(let r of n.methods)i.push({id:g(`elementAdaptSlotMethod`,e,se(t.key,n.key,r.key)),kind:`elementAdaptSlotMethod`,names:[t.name,n.name,r.name],inputs:r.inputs,outputs:r.outputs})}}else if(t===`customSlot`){let t=r[n];if(t&&t.meta.slots){let r=t.meta.slots.find(e=>e.id===o);if(r&&r.methods)for(let a of r.methods)i.push({id:g(`customAdaptSlotMethod`,e,oe(n,r.id,a.id)),kind:`customAdaptSlotMethod`,names:[t.name,r.name,a.name],inputs:q(a.inputs),outputs:J(a.outputs)})}}}return i}function Cn(e){if(!e)return;let{activeObject:t,activeComp:n,depends:r}=d.app,{kind:i,nodeId:a,methodKey:o}=ve(e),s=t.nodes.find(e=>e.id===a);if(!s)return;let c=p(s.key);if(!c){console.assert(!1,`invalid element`,s.key);return}if(i===`elementMethod`){let t=c.methods?.find(e=>e.key===o);if(t)return{id:e,kind:i,names:[t.name],inputs:t.inputs,outputs:t.outputs}}else if(i===`refMethod`){if(F(c.key)&&s.comp){let t=r[s.comp];if(t){let n=t.meta.methods?.find(e=>e.id===o);if(n)return{id:e,kind:i,names:[n.name],inputs:q(n.inputs),outputs:J(n.outputs)}}}}else if(i===`multipleRefMethod`){if(I(c.key)&&s.comp){let t=r[s.comp];if(t){let n=t.meta.methods?.find(e=>e.id===o);if(n)return{id:e,kind:i,names:[n.name],inputs:q(n.inputs),outputs:J(n.outputs)}}}}else if(i===`customMethod`){if(P(c.key)&&t.type===`comp`){let t=n.meta.methods?.find(e=>e.id===o);if(t)return{id:e,kind:i,names:[t.name],inputs:q(t.inputs),outputs:q(t.outputs)}}}else if(i===`customSlotMethod`){if(P(c.key)&&t.type===`comp`&&n.meta.slots){let{slotId:t,methodId:r}=ye(o),a=n.meta.slots.find(e=>e.id===t);if(a&&a.methods){let t=a.methods.find(e=>e.id===r);if(t)return{id:e,kind:i,names:[a.name,t.name],inputs:q(t.inputs),outputs:J(t.outputs)}}}}else if(i===`elementAdaptSlotMethod`){if(P(c.key)&&t.type===`comp`&&s.adaptSlot){let{elementKey:t,slotKey:n,methodKey:r}=be(o);if(Ct(s.adaptSlot,t,n)){let a=p(t);if(a&&a.slots){let t=a.slots.find(e=>e.key===n);if(t&&t.methods){let n=t.methods.find(e=>e.key===r);if(n)return{id:e,kind:i,names:[a.name,t.name,n.name],inputs:n.inputs,outputs:n.outputs}}}}}}else if(i===`customAdaptSlotMethod`&&P(c.key)&&t.type===`comp`&&s.adaptSlot){let{compId:t,slotId:n,methodId:a}=ye(o);if(wt(s.adaptSlot,t,n)){let o=r[t];if(o&&o.meta.slots){let t=o.meta.slots.find(e=>e.id===n);if(t&&t.methods){let n=t.methods.find(e=>e.id===a);if(n)return{id:e,kind:i,names:[o.name,t.name,n.name],inputs:q(n.inputs),outputs:J(n.outputs)}}}}}}function wn(e){let t=[],n=Sn(e),r;for(let{id:e,kind:i,names:a}of n)i!==r&&(r&&t.push(`separator`),r=i),t.push([me(i,a),e]);return N(t)}function Tn(e){let t=!0;switch(e){case``:break;case`elementMethod`:case`elementSlotMethod`:case`multipeElementSlotMethod`:break;case`refMethod`:case`multipleRefMethod`:t=!1;break;case`customSlotMethod`:case`multipleCustomSlotMethod`:t=!1;break;case`customMethod`:t=!1;break;case`elementAdaptSlotMethod`:break;case`customAdaptSlotMethod`:t=!1;break;default:console.assert(!1,`not implemented kind=${e}`)}return t}function En(e){let{activeObject:t,activeComp:n}=d.app,r=[],i=t.nodes.find(t=>t.id===e);if(!i)return r;let a=p(i.key);if(!a)return console.assert(!1,`inavlid element`,i.key),r;if(L(a.key)&&i.slot&&t.type===`comp`&&n.meta.slots){let t=n.meta.slots.find(e=>e.id===i.slot);if(t&&t.methods)for(let i of t.methods)r.push({id:g(`customSlotMethod`,e,oe(n.id,t.id,i.id)),kind:`customSlotMethod`,names:[t.name,i.name],inputs:q(i.inputs),outputs:q(i.outputs)})}if(R(a.key)&&i.slot&&t.type===`comp`&&n.meta.slots){let t=n.meta.slots.find(e=>e.id===i.slot);if(t&&t.methods)for(let i of t.methods)r.push({id:g(`multipleCustomSlotMethod`,e,oe(n.id,t.id,i.id)),kind:`multipleCustomSlotMethod`,names:[t.name,i.name],inputs:q(i.inputs),outputs:J(i.outputs)})}if(P(a.key)&&t.type===`comp`&&n.meta.methods)for(let{id:t,name:i,inputs:a,outputs:o}of n.meta.methods)r.push({id:g(`customMethod`,e,t),kind:`customMethod`,names:[i],inputs:q(a),outputs:J(o)});return r}function Dn(e){if(!e)return;let{activeObject:t,activeComp:n}=d.app,{kind:r,nodeId:i,methodKey:a}=ve(e),o=t.nodes.find(e=>e.id===i);if(!o)return;let s=p(o.key);if(!s){console.assert(!1,`invalid element`,o.key);return}if(r===`customSlotMethod`){if(L(s.key)&&o.slot&&t.type===`comp`&&n.meta.slots){let{compId:t,slotId:i,methodId:s}=ye(a);if(n.id===t&&i===o.slot){let t=n.meta.slots.find(e=>e.id===i);if(t&&t.methods){let n=t.methods.find(e=>e.id===s);if(n)return{id:e,kind:r,names:[t.name,n.name],inputs:q(n.inputs),outputs:J(n.outputs)}}}}}else if(r===`multipleCustomSlotMethod`){if(R(s.key)&&o.slot&&t.type===`comp`&&n.meta.slots){let{compId:t,slotId:i,methodId:s}=ye(a);if(n.id===t&&o.slot===i){let t=n.meta.slots.find(e=>e.id===i);if(t&&t.methods){let n=t.methods.find(e=>e.id===s);if(n)return{id:e,kind:r,names:[t.name,n.name],inputs:q(n.inputs),outputs:J(n.outputs)}}}}}else if(r===`customMethod`&&P(s.key)&&t.type===`comp`&&n.meta.methods){let t=n.meta.methods.find(e=>e.id===a);if(t)return{id:e,kind:r,names:[t.name],inputs:q(t.inputs),outputs:J(t.outputs)}}}function On(e){let t=[],n=En(e),r;for(let{id:e,kind:i,names:a}of n)i!==r&&(r&&t.push(`separator`),r=i),t.push([me(i,a),e]);return N(t)}function kn(e){let t=Dn(e);return t?t.outputs:[]}function An(e,t){let n=Dn(e);if(n)return n.outputs?.find(e=>e.key===t)}function jn(e){let t=[],n=kn(e);if(n)for(let{name:e,key:r}of n)t.push([e,r]);return N(t)}function Mn(e){let{appList:t}=d.app,n=[],r=t.find(t=>t.id===e);if(!r)return n;for(let{id:e,name:t}of r.pages)n.push({id:e,name:t});return n}function Nn(e,t){let{appList:n}=d.app,r=n.find(t=>t.id===e);if(!r)return;let i=r.pages.find(e=>e.id===t);if(i)return{id:i.id,name:i.name}}function Pn(e){let t=[];return Mn(e).forEach(({id:e,name:n})=>{t.push([n,e])}),N(t)}function Fn(e,t){let{activeObject:n,activeComp:r,depends:i}=d.app,a=[],o=m(n.type,n.subtype),s=n.nodes.find(t=>t.id===e);if(!s)return a;let c=p(s.key);if(!c)return console.assert(!1,`invalid element`,s.key),a;if(f[c.key]&&f[c.key][o])for(let{keys:n,names:r,raw:i}of f[c.key][o])t===`write`&&St(n,i)||a.push({id:_(`elementProperty`,e,n),kind:`elementProperty`,names:r,meta:{element:!0,raw:i}});if(F(c.key)&&s.comp){let t=i[s.comp];if(t&&t.meta.properties)for(let{id:n,name:r,type:i}of t.meta.properties)a.push({id:_(`refProperty`,e,n),kind:`refProperty`,names:[r],meta:{raw:{type:i}}})}if(I(c.key)&&s.comp){let t=i[s.comp];if(t&&t.meta.properties)for(let{id:n,name:r,type:i}of t.meta.properties)a.push({id:_(`multipleRefProperty`,e,n),kind:`multipleRefProperty`,names:[r],meta:{raw:{type:i}}})}if(L(c.key)&&s.slot&&n.type===`comp`&&r.meta.slots){let t=r.meta.slots.find(e=>e.id===s.slot);if(t&&t.properties)for(let n of t.properties)a.push({id:_(`customSlotProperty`,e,ce(r.id,t.id,n.id)),kind:`customSlotProperty`,names:[t.name,n.name],meta:{raw:{type:n.type}}})}if(R(c.key)&&s.slot&&n.type===`comp`&&r.meta.slots){let t=r.meta.slots.find(e=>e.id===s.slot);if(t&&t.properties)for(let n of t.properties)a.push({id:_(`multipleCustomSlotProperty`,e,ce(r.id,t.id,n.id)),kind:`multipleCustomSlotProperty`,names:[t.name,n.name],meta:{raw:{type:n.type}}})}if(P(c.key)&&n.type===`comp`&&r.meta.properties)for(let{id:t,name:n,type:i}of r.meta.properties)a.push({id:_(`customProperty`,e,t),kind:`customProperty`,names:[n],meta:{raw:{type:i}}});if(P(c.key)&&n.type===`comp`&&s.adaptSlot){let{kind:n,mainKey:r,slotKey:o}=we(s.adaptSlot);if(n===`elementSlot`){let n=p(r);if(n&&n.slots){let r=n.slots.find(e=>e.key===o);if(r&&r.properties)for(let i of r.properties)t===`write`&&i.readonly||a.push({id:_(`elementAdaptSlotProperty`,e,le(n.key,r.key,i.key)),kind:`elementAdaptSlotProperty`,names:[n.name,r.name,i.name],meta:{raw:{type:i.type}}})}}else if(n===`customSlot`){let t=i[r];if(t&&t.meta.slots){let n=t.meta.slots.find(e=>e.id===o);if(n&&n.properties)for(let i of n.properties)a.push({id:_(`customAdaptSlotProperty`,e,ce(r,n.id,i.id)),kind:`customAdaptSlotProperty`,names:[t.name,n.name,i.name],meta:{raw:{type:i.type}}})}}}return a}function In(e){if(!e)return;let{activeObject:t,activeComp:n,depends:r}=d.app,i=m(t.type,t.subtype),{kind:a,nodeId:o,propertyKey:s}=xe(e),c=t.nodes.find(e=>e.id===o);if(!c)return;let l=p(c.key);if(!l){console.assert(!1,`invalid element`,c.key);return}if(a===`elementProperty`){if(f[l.key]&&f[l.key][i]){let t=f[l.key][i].find(e=>e.keys===s);if(t)return{id:e,kind:a,names:t.names,meta:{element:!0,raw:t.raw}}}}else if(a===`refProperty`){if(F(l.key)&&c.comp){let t=r[c.comp];if(t){let n=t.meta.properties?.find(e=>e.id===s);if(n)return{id:e,kind:a,names:[n.name],meta:{raw:{type:n.type}}}}}}else if(a===`multipleRefProperty`){if(I(l.key)&&c.comp){let t=r[c.comp];if(t){let n=t.meta.properties?.find(e=>e.id===s);if(n)return{id:e,kind:a,names:[n.name],meta:{raw:{type:n.type}}}}}}else if(a===`customSlotProperty`){if(L(l.key)&&c.slot&&t.type===`comp`&&n.meta.slots){let{compId:t,slotId:r,propertyId:i}=Se(s);if(n.id===t&&c.slot===r){let t=n.meta.slots.find(e=>e.id===r);if(t&&t.properties){let n=t.properties.find(e=>e.id===i);if(n)return{id:e,kind:a,names:[t.name,n.name],meta:{raw:{type:n.type}}}}}}}else if(a===`multipleCustomSlotProperty`){if(R(l.key)&&c.slot&&t.type===`comp`&&n.meta.slots){let{compId:t,slotId:r,propertyId:i}=Se(s);if(n.id===t&&c.slot===r){let t=n.meta.slots.find(e=>e.id===r);if(t&&t.properties){let n=t.properties.find(e=>e.id===i);if(n)return{id:e,kind:a,names:[t.name,n.name],meta:{raw:{type:n.type}}}}}}}else if(a===`customProperty`){if(P(l.key)&&t.type===`comp`){let t=n.meta.properties?.find(e=>e.id===s);if(t)return{id:e,kind:a,names:[t.name],meta:{raw:{type:t.type}}}}}else if(a===`elementAdaptSlotProperty`){if(P(l.key)&&t.type===`comp`&&c.adaptSlot){let{elementKey:t,slotKey:n,propertyKey:r}=Ce(s);if(Ct(c.adaptSlot,t,n)){let i=p(t);if(i&&i.slots){let t=i.slots.find(e=>e.key===n);if(t&&t.properties){let n=t.properties.find(e=>e.key===r);if(n)return{id:e,kind:a,names:[i.name,t.name,n.name],meta:{raw:{type:n.type}}}}}}}}else if(a===`customAdaptSlotProperty`&&P(l.key)&&t.type===`comp`&&c.adaptSlot){let{compId:t,slotId:n,propertyId:i}=Se(s);if(wt(c.adaptSlot,t,n)){let o=r[t];if(o&&o.meta.slots){let t=o.meta.slots.find(e=>e.id===n);if(t&&t.properties){let n=t.properties.find(e=>e.id===i);if(n)return{id:e,kind:a,names:[o.name,t.name,n.name],meta:{raw:{type:n.type}}}}}}}}function Ln(e,t){let n=[],r=Fn(e,t),i;for(let{id:e,kind:t,names:a}of r)t!==i&&(i&&n.push(`separator`),i=t),n.push([he(t,a),e]);return N(n)}function Rn(){let{activeObject:e,activeComp:t}=d.app,n=[{id:``,name:``}];if(e.type!==`comp`||!t.meta.slots)return n;for(let{id:e,name:r}of t.meta.slots)n.push({id:e,name:r});return n}function zn(e){let{activeObject:t,activeComp:n}=d.app;if(t.type!==`comp`||!n.meta.slots)return;if(!e)return{id:``,name:``};let r=n.meta.slots.find(t=>t.id===e);if(r)return{id:r.id,name:r.name}}function Bn(){let{i18n:e}=i,t=[],n=Rn();for(let{id:r,name:i}of n){let n=i;r===``&&(n=e.global.t(`x-runtime-lib.notSet`)),t.push([n,r])}return N(t)}const Vn={init:function(){this.kind=`notSet`,this.node={id:``,key:``,alias:``},this.property={id:``,kind:``,names:[]},this.state={id:``,name:``,type:`string`},this.appendDummyInput().appendField(new e.FieldDropdown(()=>this.genKindOpts_()),`KIND`).appendField(new e.FieldDropdown(()=>this.genNodeOpts_()),`NODE`).appendField(new e.FieldDropdown(()=>this.genPropertyOpts_()),`PROPERTY`).appendField(new e.FieldDropdown(()=>this.genStateOpts_()),`STATE`),this.setOutput(!0,`BindEntry`),this.updateShape_()},saveExtraState:function(){return{kind:this.kind,node:this.node,property:this.property,state:this.state}},loadExtraState:function(e){this.kind=e.kind??`notSet`,this.node.id=e.node?.id??``,this.node.key=e.node?.key??``,this.node.alias=e.node?.alias??``,this.property.id=e.property?.id??``,this.property.kind=e.property?.kind??``,this.property.names=e.property?.names??[],this.state.id=e.state?.id??``,this.state.name=e.state?.name??``,this.state.type=e.state?.type??`string`,this.updateShape_(),setTimeout(()=>{this.checkWarning_()},0)},genKindOpts_:function(){return un()},genNodeOpts_:function(){return this.kind===`property`?an(`setProperty`):N([])},genPropertyOpts_:function(){return this.kind===`property`?Ln(this.node.id,`write`):N([])},genStateOpts_:function(){return this.kind===`state`?cn():N([])},onchange:function(t){if(t.type===e.Events.BLOCK_CHANGE){let e=t;e.blockId===this.id&&(e.element===`field`&&(e.name===`KIND`?this.onKindChange_(e.newValue):e.name===`NODE`?this.onNodeChange_(e.newValue):e.name===`PROPERTY`?this.onPropertyChange_(e.newValue):e.name===`STATE`&&this.onStateChange_(e.newValue)),setTimeout(()=>{this.checkWarning_()}))}},onKindChange_:function(e){let t=this.kind!==e;if(this.kind=e,this.kind===`notSet`)this.updateShape_();else if(this.kind===`property`){let e=this.getField(`NODE`);if(e.getOptions(!1),t){let t=U(`setProperty`)?.[0];e.setValue(t?.id??``)}this.onNodeChange_(e.getValue())}else if(this.kind===`state`){let e=this.getField(`STATE`);if(e.getOptions(!1),t){let t=on()?.[0];e.setValue(t?.id??``)}this.onStateChange_(e.getValue())}},onNodeChange_:function(e){let t=W(e);if(!t){console.assert(!1);return}let n=this.node?.id!==t.id;this.node.id=t.id,this.node.key=t.key,this.node.alias=t.alias;let r=this.getField(`PROPERTY`);if(r.getOptions(!1),n){let e=Fn(this.node.id,`write`)?.[0];r.setValue(e?.id??``)}this.onPropertyChange_(r.getValue())},onPropertyChange_:function(e){let t=In(e);if(!t){console.assert(!1);return}this.property.id=t.id,this.property.kind=t.kind,this.property.names=t.names,this.updateShape_()},onStateChange_:function(e){let t=sn(e);if(!t){console.assert(!1);return}this.state.id=t.id,this.state.name=t.name,this.state.type=t.type,this.updateShape_()},updateShape_:function(){this.kind===`notSet`?(this.setStyle(`event_blocks`),this.getField(`NODE`).setVisible(!1),this.getField(`PROPERTY`).setVisible(!1),this.getField(`STATE`).setVisible(!1)):this.kind===`property`?(this.setStyle(`property_blocks`),this.getField(`NODE`).setVisible(!0),this.getField(`PROPERTY`).setVisible(!0),this.getField(`STATE`).setVisible(!1)):this.kind===`state`&&(this.setStyle(`state_blocks`),this.getField(`NODE`).setVisible(!1),this.getField(`PROPERTY`).setVisible(!1),this.getField(`STATE`).setVisible(!0)),setTimeout(()=>{this.render()},0)},checkWarning_:function(){if(this.kind===`property`){let e=W(this.node.id);if(!e){this.setWarningText(M(`WARN_NODE_NOT_FOUND`));return}if(e.key!==this.node.key){this.setWarningText(M(`WARN_NODE_HAS_CHANGED`));return}e.alias!==this.node.alias&&(this.node.alias=e.alias);let t=In(this.property.id);if(!t){this.setWarningText(M(`WARN_PROPERTY_NOT_FOUND`));return}if(t.kind!==this.property.kind){this.setWarningText(M(`WARN_PROPERTY_HAS_CHANGED`));return}b(t.names,this.property.names)||(this.property.names=t.names)}else if(this.kind===`state`){let e=sn(this.state.id);if(!e){this.setWarningText(M(`WARN_STATE_NOT_FOUND`));return}if(e.name!==this.state.name&&(this.state.name=e.name),e.type!==this.state.type){this.setWarningText(M(`WARN_STATE_HAS_CHANGED`));return}}this.setWarningText(null)}};e.Blocks.app_bind_entry_v1=Vn,n.forBlock.app_bind_entry_v1=function(){return``};const Hn=e.utils.xml,Un={init:function(){this.appendDummyInput().appendField(`%{BKY_APP_V1_APP_BIND_CONTAINER_TITLE}`),this.appendStatementInput(`STACK`),this.setStyle(`event_blocks`),this.contextMenu=!1}};e.Blocks.app_bind_container_v1=Un;const Wn={init:function(){this.appendDummyInput().appendField(`%{BKY_APP_V1_APP_BIND_ITEM_TITLE}`),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setStyle(`event_blocks`),this.contextMenu=!1}};e.Blocks.app_bind_item_v1=Wn;const Gn={init:function(){this.itemCount_=0,this.setMutator(new e.icons.MutatorIcon([`app_bind_item_v1`],this)),this.debounce_=Ee(()=>{this.checkWarning_()},250),this.setStyle(`event_blocks`),this.setTooltip(`%{BKY_APP_V1_APP_BIND_TOOLTIP}`),this.setHelpUrl(`%{BKY_APP_V1_APP_BIND_HELPURL}`)},mutationToDom:function(){let e=Hn.createElement(`mutation`);return e.setAttribute(`items`,String(this.itemCount_)),e},domToMutation:function(e){let t=e.getAttribute(`items`)??``;this.itemCount_=parseInt(t,0),this.updateShape_(),this.updateShadow_(),setTimeout(()=>{this.checkWarning_()},0)},saveExtraState:function(){return{itemCount:this.itemCount_}},loadExtraState:function(e){this.itemCount_=e.itemCount??0,this.updateShape_(),this.updateShadow_(),setTimeout(()=>{this.checkWarning_()},0)},decompose:function(e){let t=e.newBlock(`app_bind_container_v1`);t.initSvg();let n=t.getInput(`STACK`).connection;for(let t=0;t<this.itemCount_;t++){let t=e.newBlock(`app_bind_item_v1`);t.initSvg(),n.connect(t.previousConnection),n=t.nextConnection}return t},compose:function(e){let t=e.getInputTargetBlock(`STACK`),n=[];for(;t;){if(t.isInsertionMarker()){t=t.getNextBlock();continue}n.push(t.valueConnection_),t=t.getNextBlock()}for(let e=0;e<this.itemCount_;e++){this.getInput(`ADD`+e).setShadowDom(null);let t=this.getInput(`ADD`+e).connection.targetConnection;t&&!n.includes(t)&&t.disconnect()}this.itemCount_=n.length,this.updateShape_();for(let e=0;e<this.itemCount_;e++)n[e]?.reconnect(this,`ADD`+e);this.updateShadow_(),setTimeout(()=>{this.checkWarning_()},0)},saveConnections:function(e){let t=e.getInputTargetBlock(`STACK`),n=0;for(;t;){if(t.isInsertionMarker()){t=t.getNextBlock();continue}let e=this.getInput(`ADD`+n);t.valueConnection_=e?.connection.targetConnection,t=t.getNextBlock(),n++}},onchange:function(){this.debounce_()},updateShape_:function(){this.itemCount_&&this.getInput(`EMPTY`)?this.removeInput(`EMPTY`):!this.itemCount_&&!this.getInput(`EMPTY`)&&this.appendDummyInput(`EMPTY`).appendField(`%{BKY_APP_V1_APP_BIND_TITLE}`);for(let t=0;t<this.itemCount_;t++)this.getInput(`ADD`+t)||(this.appendValueInput(`ADD`+t).setCheck(`BindEntry`),t===0&&this.getInput(`ADD`+t).setAlign(e.inputs.Align.RIGHT).appendField(`%{BKY_APP_V1_APP_BIND_TITLE}`));for(let e=this.itemCount_;this.getInput(`ADD`+e);e++)this.removeInput(`ADD`+e)},updateShadow_:function(){if(!this.isInsertionMarker())for(let e=0;e<this.itemCount_;e++)this.getInput(`ADD`+e).setShadowDom(Ht())},checkWarning_:function(){let e;for(let t=0;t<this.itemCount_;t++){let n=this.getInput(`ADD`+t)?.connection?.targetBlock();if(!n)continue;let r;if(n.kind===`property`){let e=In(n.property.id);e&&(r=e.meta.element?Tt(e.meta.raw):z(e.meta.raw.type))}else if(n.kind===`state`){let e=sn(n.state.id);e&&(r=z(e.type))}if(r&&(e||=r,r!==e)){this.setWarningText(M(`WARN_TYPE_NOT_MATCH`));return}}this.setWarningText(null)}};e.Blocks.app_bind_v1=Gn,n.forBlock.app_bind_v1=function(){return``};const Kn={init:function(){this.node={id:``,key:``,alias:``},this.event={id:``,kind:``,names:[]},this.appendDummyInput().appendField(`%{BKY_APP_V1_ON_APP_EVENT_TITLE}`).appendField(new e.FieldDropdown(()=>this.genNodeOpts_()),`NODE`).appendField(new e.FieldDropdown(()=>this.genEventOpts_()),`EVENT`),this.appendStatementInput(`HANDLE`).appendField(`%{BKY_APP_DO}`),this.setStyle(`event_blocks`),this.setTooltip(`%{BKY_APP_V1_ON_APP_EVENT_TOOLTIP}`),this.setHelpUrl(`%{BKY_APP_V1_ON_APP_EVENT_HELPURL}`),this.initData_()},initData_:function(){if(this.node.id)return;let e=U(`onEvent`)?.[0];if(!e)return;this.node.id=e.id,this.node.key=e.key,this.node.alias=e.alias;let t=this.getField(`NODE`);t.getOptions(!1),t.setValue(this.node.id);let n=hn(this.node.id)?.[0];if(!n)return;this.event.id=n.id,this.event.kind=n.kind,this.event.names=n.names,this.event.params=n.params;let r=this.getField(`EVENT`);r.getOptions(!1),r.setValue(this.event.id)},saveExtraState:function(){return{node:this.node,event:this.event}},loadExtraState:function(e){this.node.id=e.node?.id??``,this.node.key=e.node?.key??``,this.node.alias=e.node?.alias??``,this.event.id=e.event?.id??``,this.event.kind=e.event?.kind??``,this.event.names=e.event?.names??[],this.event.params=e.event?.params,this.updateShape_(),setTimeout(()=>{this.ensureBlocks_(),this.checkWarning_()},0)},genNodeOpts_:function(){return an(`onEvent`)},genEventOpts_:function(){return _n(this.node.id)},onchange:function(t){if(t.type===e.Events.BLOCK_CHANGE){let e=t;e.blockId===this.id&&(e.element===`field`&&(e.name===`NODE`?this.onNodeChange_(e.newValue):e.name===`EVENT`&&this.onEventChange_(e.newValue)),setTimeout(()=>{this.checkWarning_()},0))}},onNodeChange_:function(e){let t=W(e);if(!t){console.assert(!1);return}let n=this.node.id!==t.id;this.node.id=t.id,this.node.key=t.key,this.node.alias=t.alias;let r=this.getField(`EVENT`);if(r.getOptions(!1),n){let e=hn(this.node.id)?.[0];r.setValue(e?.id??``)}this.onEventChange_(r.getValue())},onEventChange_:function(e){let t=gn(e);if(!t){console.assert(!1);return}this.event.id=t.id,this.event.kind=t.kind,this.event.names=t.names,this.event.params=t.params,this.updateShape_(),setTimeout(()=>{this.ensureBlocks_()},0)},updateShape_:function(){for(let e=this.event.params?.length??0;this.getInput(`PARAM`+e);e++){let t=this.getInput(`PARAM`+e).connection.targetBlock();t&&t.dispose(),this.removeInput(`PARAM`+e)}if(this.event.params)for(let e=0;e<this.event.params.length;e++)this.getInput(`PARAM`+e)||(this.appendValueInput(`PARAM`+e),this.moveInputBefore(`PARAM`+e,`HANDLE`));let e=!1;switch(this.event.kind){case`multipleRefEvent`:case`multipleRefPropertyChangeEvent`:case`multipleCustomSlotEvent`:case`multipleCustomSlotPropertyChangeEvent`:e=!0}if(e)this.getInput(`INSTANCE`)||this.appendValueInput(`INSTANCE`).setCheck(`String`),this.event.params&&this.event.params.length>0?this.moveInputBefore(`INSTANCE`,`PARAM0`):this.moveInputBefore(`INSTANCE`,`HANDLE`);else if(this.getInput(`INSTANCE`)){let e=this.getInput(`INSTANCE`).connection.targetBlock();e&&e.dispose(),this.removeInput(`INSTANCE`)}},ensureBlocks_:function(){if(this.isInsertionMarker())return;let e=[];this.getInput(`INSTANCE`)&&e.push([`INSTANCE`,`__instance__`,`x-runtime-lib.instance`,!0]);let t=mn(this.event.kind);if(this.event.params)for(let n=0;n<this.event.params.length;n++){let{key:r,name:i}=this.event.params[n];e.push([`PARAM`+n,`__param$${r}__`,i,t])}e.length>0&&B(this,e)},checkWarning_:function(){let e=W(this.node.id);if(!e){this.setWarningText(M(`WARN_NODE_NOT_FOUND`));return}if(e.key!==this.node.key){this.setWarningText(M(`WARN_NODE_HAS_CHANGED`));return}e.alias!==this.node.alias&&(this.node.alias=e.alias);let t=gn(this.event.id);if(!t){this.setWarningText(M(`WARN_EVENT_NOT_FOUND`));return}if(t.kind!==this.event.kind){this.setWarningText(M(`WARN_EVENT_HAS_CHANGED`));return}if(b(t.names,this.event.names)||(this.event.names=t.names),!b(t.params,this.event.params)){this.setWarningText(M(`WARN_EVENT_HAS_CHANGED`));return}this.setWarningText(null)}};e.Blocks.on_app_event_v1=Kn,n.forBlock.on_app_event_v1=function(e){let t=n.quote_,r=e,i=``;if(r.event.params)for(let e=0;e<r.event.params.length;e++){let t=r.event.params[e];i+=`const __param$${t.key}__ = __params__[${e}];\n`}let a=n.statementToCode(r,`HANDLE`);return`__onEventV1__(${t(r.event.id)}, async (__params__, __instance__) => {
|
|
9
|
+
</shadow>`)}function U(e){let t=null;return e===`string`?t=un(``):e===`number`?t=dn(0):e===`boolean`?t=fn(!1):e===`array`?t=pn():e===`object`?t=mn():e===`any`?t=null:console.assert(!1,`type not implementd`),t}function bn(e){let t=null;return e.array?t=pn():e.ui===`transient`?t=U(e.type):e.ui===`dummy`?t=null:e.ui===`text`?t=un(e.default):e.ui===`number`?t=dn(e.default??0):e.ui===`switch`?t=fn(e.default):e.ui===`select`?t=hn(e.items):e.ui===`multiTypes`?t=gn(e.types):e.ui===`comp`?t=_n():e.ui===`slot`?t=vn():console.assert(!1,`property ui not implementd`),t}function xn(){let{activeObject:e,activePage:t}=w.app,n=[];if(e.type===`page`&&t.meta.arguments)for(let{id:e,name:r,type:i}of t.meta.arguments)n.push({key:e,name:r,type:i});return n}function Sn(e){let{activeObject:t,activePage:n}=w.app;if(t.type===`page`){let t=n.meta.arguments?.find(t=>t.id===e);if(t)return{key:t.id,name:t.name,type:t.type}}}function Cn(){let e=[];return xn().forEach(({key:t,name:n})=>{e.push([n,t])}),L(e)}x.get_page_argument_v1={init:function(){this.argument={key:``,name:``,type:`string`},this.appendDummyInput().appendField(`%{BKY_APP_V1_GET_PAGE_ARGUMENT_TITLE}`).appendField(new C(()=>this.genArgumentOpts_()),`ARGUMENT`),this.setOutput(!0,null),this.setStyle(`variable_blocks`),this.setTooltip(`%{BKY_APP_V1_GET_PAGE_ARGUMENT_TOOLTIP}`),this.setHelpUrl(`%{BKY_APP_V1_GET_PAGE_ARGUMENT_HELPURL}`)},saveExtraState:function(){return{argument:this.argument}},loadExtraState:function(e){this.argument.key=e.argument?.key??``,this.argument.name=e.argument?.name??``,this.argument.type=e.argument?.type??``,this.updateShape_(),setTimeout(()=>{this.checkWarning_()},0)},genArgumentOpts_:function(){return Cn()},onchange:function(e){if(e.type===b.BLOCK_CHANGE){let t=e;t.blockId===this.id&&(t.element===`field`&&t.name===`ARGUMENT`&&this.onArgumentChange_(t.newValue),setTimeout(()=>{this.checkWarning_()},0))}},onArgumentChange_:function(e){let t=Sn(e);if(!t){console.assert(!1);return}this.argument.key=t.key,this.argument.name=t.name,this.argument.type=t.type,this.updateShape_()},updateShape_:function(){this.setOutput(!0,V(this.argument.type))},checkWarning_:function(){let e=Sn(this.argument.key);if(!e){this.setWarningText(I(`WARN_ARGUMENT_NOT_FOUND`));return}if(e.name!==this.argument.name&&(this.argument.name=e.name),e.type!==this.argument.type){this.setWarningText(I(`WARN_ARGUMENT_HAS_CHANGED`));return}this.setWarningText(null)}},y.forBlock.get_page_argument_v1=function(e){let t=e;return[`__getPageArgumentV1__(${y.quote_(t.argument.key)})`,v.FUNCTION_CALL]};const wn=(e,t)=>{let n=qt(e),r=Jt(e);x[n]={init:function(){this.appendDummyInput().appendField(new C(()=>this.genOpts_()),`ITEM`),this.setOutput(!0,r),this.setStyle(`property_blocks`),this.setTooltip(``),this.setHelpUrl(``)},genOpts_:function(){let{i18n:e}=Ce,n=[];for(let{title:r,value:i}of t)n.push([e.global.t(r),i]);return L(n)}},y.forBlock[n]=function(e){let t=y.quote_;return[t(e.getFieldValue(`ITEM`)),v.ATOMIC]}};for(let e in Ge){let t=Ge[e];for(let e of t.items)wn(e,Me(e))}var Tn=ce();const En=(e,t)=>{let n=qt(e),r=Jt(e);x[n]={init:function(){this.value=t[0].default,this.appendDummyInput(`DUMMY`).appendField(new C(()=>this.genOpts_()),`TYPE`),this.setOutput(!0,r),this.setStyle(`property_blocks`),this.setTooltip(``),this.setHelpUrl(``),this.updateShape_()},saveExtraState:function(){return{value:this.value}},loadExtraState:function(e){this.value=e.value,this.updateShape_(),setTimeout(()=>{this.checkWarning_()},0)},genOpts_:function(){let{i18n:e}=Ce,n=[];for(let{title:r,value:i}of t)n.push([e.global.t(r),i]);return L(n)},onchange:function(e){if(e.type===b.BLOCK_CHANGE){let t=e;t.blockId===this.id&&(t.element===`field`&&t.name===`TYPE`&&this.onTypeChange_(t.newValue),setTimeout(()=>{this.checkWarning_()},0))}},onTypeChange_:function(e){let n=t.find(t=>t.value===e);if(!n){console.assert(!1);return}this.value=n.default,this.updateShape_()},updateShape_:function(){let e=this.getInput(`DUMMY`);if(!e)return;let n=t.find(e=>e.validator(this.value));if(!n)return;e.removeField(`VALUE`,!0),e.removeField(`SUFFIX`,!0);let r,i;if(n.trait===`number`)r=new ie(this.value??0,n.min,n.max,n.precision?1/10**n.precision:null,e=>{this.value=e});else if(n.trait===`numberUnit`)r=new ie(We(this.value,n.unit)??0,n.min,n.max,n.precision?1/10**n.precision:null,e=>{this.value=e+n.unit}),i=n.unit;else if(n.trait===`hexColor`)r=new Tn.FieldColour(this.value,e=>{this.value=e},{colourOptions:an,columns:14});else if(n.trait===`themeColor`){let{i18n:e}=Ce;r=new C(()=>{let t=[];for(let{value:n,title:r}of Ke)t.push([e.global.t(r),n]);return t},e=>{this.value=e})}r&&e.appendField(r,`VALUE`),i&&e.appendField(i,`SUFFIX`)},checkWarning_:function(){if(!t.find(e=>e.validator(this.value))){this.setWarningText(I(`WARN_TYPE_NOT_FOUND`));return}this.setWarningText(null)}},y.forBlock[n]=function(e){let t=y.quote_,n=e;return typeof n.value==`string`?[t(n.value),v.ATOMIC]:[n.value,v.ATOMIC]}};for(let e in Ge){let t=Ge[e];for(let e of t.types)En(e,Pe(e))}function Dn(){let e=[],{appList:t}=w.app;for(let{id:n,name:r}of t)e.push({id:n,name:r});return e}function On(e){let{appList:t}=w.app,n=t.find(t=>t.id===e);if(n)return{id:n.id,name:n.name}}function kn(){let e=[];return Dn().forEach(({id:t,name:n})=>{e.push([n,t])}),L(e)}function An(e,t){let{activeObject:n,activeComp:r}=w.app;if(z(e.key)&&t&&n.type===`comp`&&r.meta.slots){let e=r.meta.slots.find(e=>e.id===t);if(e&&e.events&&e.events.length>0)return!1}if(B(e.key)&&t&&n.type===`comp`&&r.meta.slots){let e=r.meta.slots.find(e=>e.id===t);if(e&&e.events&&e.events.length>0)return!1}return!(R(e.key)&&n.type===`comp`&&r.meta.events&&r.meta.events.length>0)}function jn(e,t,n){let{activeObject:r,activeComp:i,depends:a}=w.app;if(e.methods&&e.methods.length>0)return!1;if(Qt(e.key)&&t){let e=a[t];if(e&&e.meta.methods&&e.meta.methods.length>0)return!1}if($t(e.key)&&t){let e=a[t];if(e&&e.meta.methods&&e.meta.methods.length>0)return!1}if(R(e.key)&&r.type===`comp`&&i.meta.methods&&i.meta.methods.length>0)return!1;if(R(e.key)&&n&&r.type===`comp`){let{kind:e,mainKey:t,slotKey:r}=at(n);if(e===`elementSlot`){let e=E(t);if(e&&e.slots){let t=e.slots.find(e=>e.key===r);if(t&&t.methods&&t.methods.length>0)return!1}}else if(e===`customSlot`){let e=a[t];if(e&&e.meta.slots){let t=e.meta.slots.find(e=>e.id===r);if(t&&t.methods&&t.methods.length>0)return!1}}}return!0}function Mn(e,t){let{activeObject:n,activeComp:r}=w.app;if(z(e.key)&&t&&n.type===`comp`&&r.meta.slots){let e=r.meta.slots.find(e=>e.id===t);if(e&&e.methods&&e.methods.length>0)return!1}if(B(e.key)&&t&&n.type===`comp`&&r.meta.slots){let e=r.meta.slots.find(e=>e.id===t);if(e&&e.methods&&e.methods.length>0)return!1}return!(R(e.key)&&n.type===`comp`&&r.meta.methods&&r.meta.methods.length>0)}function Nn(e,t){let{activeObject:n,activeComp:r}=w.app;if(z(e.key)&&t&&n.type===`comp`&&r.meta.slots){let e=r.meta.slots.find(e=>e.id===t);if(e&&e.methods){for(let{outputs:t}of e.methods)if(t&&t.length>0)return!1}}if(B(e.key)&&t&&n.type===`comp`&&r.meta.slots){let e=r.meta.slots.find(e=>e.id===t);if(e&&e.methods){for(let{outputs:t}of e.methods)if(t&&t.length>0)return!1}}if(R(e.key)&&n.type===`comp`&&r.meta.methods){for(let{outputs:e}of r.meta.methods)if(e&&e.length>0)return!1}return!0}function Pn(e,t,n,r,i){return e===`triggerEvent`?An(t,n):e===`callMethod`?jn(t,r,i):e===`implementMethod`?Mn(t,n):e===`implementMethodOutput`?Nn(t,n):!1}function W(e){let{activeObject:t}=w.app;for(let n of t.nodes){let t=E(n.key);if(!t){console.assert(!1,`invalid element`,n.key);continue}if(!Pn(e,t,n.slot,n.comp,n.adaptSlot))return!0}return!1}function Fn(e){let{activeObject:t}=w.app,n=[];for(let r of t.nodes){let t=E(r.key);if(!t){console.assert(!1,`invalid element`,r.key);continue}Pn(e,t,r.slot,r.comp,r.adaptSlot)||n.push({id:r.id,key:r.key,name:t.name,alias:r.alias})}return n}function G(e){let{activeObject:t}=w.app,n=t.nodes.find(t=>t.id===e);if(!n)return;let r=E(n.key);if(!r){console.assert(!1,`invalid element`,n.key);return}return{id:n.id,key:n.key,name:r.name,alias:n.alias}}function In(e){let{i18n:t}=Ce,n=[],r=Fn(e);for(let{id:e,name:i,alias:a}of r){let r=t.global.t(i);a&&(r+=` / `+a),n.push([r,e])}return L(n)}function Ln(){let{activeObject:e,activePage:t,activeComp:n}=w.app;return e.type===`page`?t.meta.states??[]:e.type===`comp`?n.meta.states??[]:[]}function Rn(e){let{activeObject:t,activePage:n,activeComp:r}=w.app;if(t.type===`page`)return n.meta.states?.find(t=>t.id===e);if(t.type===`comp`)return r.meta.states?.find(t=>t.id===e)}function zn(){let e=[],t=Ln();for(let{id:n,name:r}of t)e.push([r,n]);return L(e)}function Bn(){let e=[`notSet`];return Fn(`setProperty`).length>0&&e.push(`property`),Ln().length>0&&e.push(`state`),e}function Vn(){let{i18n:e}=Ce;return L(Bn().map(t=>t===`notSet`?[e.global.t(`x-runtime-lib.${t}`),t]:[I(`APP_${oe(t)}`),t]))}function Hn(){let{activeApp:e}=w.app,t=[{id:``,name:``}];for(let{id:n,name:r}of e.comps)t.push({id:n,name:r});return t}function Un(e){let{activeApp:t}=w.app;if(!e)return{id:``,name:``};let n=t.comps.find(t=>t.id===e);if(n)return{id:n.id,name:n.name}}function Wn(){let{i18n:e}=Ce,t=[];return Hn().forEach(({id:n,name:r})=>{let i=r;n===``&&(i=e.global.t(`x-runtime-lib.notSet`)),t.push([i,n])}),L(t)}function K(e){if(!e)return;let t=[];for(let{id:n,name:r,type:i}of e)t.push({key:n,name:r,type:i});return t}function q(e){return[{key:`newValue`,name:`x-runtime-lib.newValue`,type:e},{key:`oldValue`,name:`x-runtime-lib.oldValue`,type:e}]}function Gn(e){let t=!0;switch(e){case``:break;case`elementEvent`:case`elementPropertyChangeEvent`:case`elementSlotEvent`:case`elementSlotPropertyChangeEvent`:case`multipleElementSlotEvent`:case`multipleElementSlotPropertyChangeEvent`:break;case`refEvent`:t=!1;break;case`refPropertyChangeEvent`:break;case`multipleRefEvent`:t=!1;break;case`multipleRefPropertyChangeEvent`:break;case`customSlotEvent`:t=!1;break;case`customSlotPropertyChangeEvent`:break;case`multipleCustomSlotEvent`:t=!1;break;case`multipleCustomSlotPropertyChangeEvent`:break;case`customEvent`:t=!1;break;case`customPropertyChangeEvent`:break;case`elementAdaptSlotEvent`:break;case`elementAdaptSlotPropertyChangeEvent`:break;case`customAdaptSlotEvent`:t=!1;break;case`customAdaptSlotPropertyChangeEvent`:break;case`stateChangeEvent`:break;default:console.assert(!1,`not implemented kind=${e}`)}return t}function Kn(e){let{activeObject:t,activePage:n,activeComp:r,depends:i}=w.app,a=[],o=Ne(t.type,t.subtype),s=t.nodes.find(t=>t.id===e);if(!s)return a;let c=E(s.key);if(!c)return console.assert(!1,`invalid element`,s.key),a;if(c.events)for(let{key:t,name:n,params:r}of c.events)a.push({id:D(`elementEvent`,e,t),kind:`elementEvent`,names:[n],params:r});if(T[c.key]&&T[c.key][o])for(let{keys:t,names:n,raw:r}of T[c.key][o])a.push({id:D(`elementPropertyChangeEvent`,e,t),kind:`elementPropertyChangeEvent`,names:n,params:q(Xt(r))});if(Qt(c.key)&&s.comp){let t=i[s.comp];if(t&&t.meta.events)for(let{id:n,name:r,params:i}of t.meta.events)a.push({id:D(`refEvent`,e,n),kind:`refEvent`,names:[r],params:K(i)})}if(Qt(c.key)&&s.comp){let t=i[s.comp];if(t&&t.meta.properties)for(let{id:n,name:r,type:i}of t.meta.properties)a.push({id:D(`refPropertyChangeEvent`,e,n),kind:`refPropertyChangeEvent`,names:[r],params:q(i)})}if($t(c.key)&&s.comp){let t=i[s.comp];if(t&&t.meta.events)for(let{id:n,name:r,params:i}of t.meta.events)a.push({id:D(`multipleRefEvent`,e,n),kind:`multipleRefEvent`,names:[r],params:K(i)})}if($t(c.key)&&s.comp){let t=i[s.comp];if(t&&t.meta.properties)for(let{id:n,name:r,type:i}of t.meta.properties)a.push({id:D(`multipleRefPropertyChangeEvent`,e,n),kind:`multipleRefPropertyChangeEvent`,names:[r],params:q(i)})}if(z(c.key)&&s.slot&&t.type===`comp`&&r.meta.slots){let t=r.meta.slots.find(e=>e.id===s.slot);if(t&&t.events)for(let n of t.events)a.push({id:D(`customSlotEvent`,e,Fe(r.id,t.id,n.id)),kind:`customSlotEvent`,names:[t.name,n.name],params:K(n.params)})}if(z(c.key)&&s.slot&&t.type===`comp`&&r.meta.slots){let t=r.meta.slots.find(e=>e.id===s.slot);if(t&&t.properties)for(let n of t.properties)a.push({id:D(`customSlotPropertyChangeEvent`,e,Ve(r.id,t.id,n.id)),kind:`customSlotPropertyChangeEvent`,names:[t.name,n.name],params:q(n.type)})}if(B(c.key)&&s.slot&&t.type===`comp`&&r.meta.slots){let t=r.meta.slots.find(e=>e.id===s.slot);if(t&&t.events)for(let n of t.events)a.push({id:D(`multipleCustomSlotEvent`,e,Fe(r.id,t.id,n.id)),kind:`multipleCustomSlotEvent`,names:[t.name,n.name],params:K(n.params)})}if(B(c.key)&&s.slot&&t.type===`comp`&&r.meta.slots){let t=r.meta.slots.find(e=>e.id===s.slot);if(t&&t.properties)for(let n of t.properties)a.push({id:D(`multipleCustomSlotPropertyChangeEvent`,e,Ve(r.id,t.id,n.id)),kind:`multipleCustomSlotPropertyChangeEvent`,names:[t.name,n.name],params:q(n.type)})}if(R(c.key)&&t.type===`comp`&&r.meta.events)for(let{id:t,name:n,params:i}of r.meta.events)a.push({id:D(`customEvent`,e,t),kind:`customEvent`,names:[n],params:K(i)});if(R(c.key)&&t.type===`comp`&&r.meta.properties)for(let{id:t,name:n,type:i}of r.meta.properties)a.push({id:D(`customPropertyChangeEvent`,e,t),kind:`customPropertyChangeEvent`,names:[n],params:q(i)});if(R(c.key)&&t.type===`comp`&&s.adaptSlot){let{kind:t,mainKey:n,slotKey:r}=at(s.adaptSlot);if(t===`elementSlot`){let t=E(n);if(t&&t.slots){let i=t.slots.find(e=>e.key===r);if(i&&i.events)for(let o of i.events)a.push({id:D(`elementAdaptSlotEvent`,e,Ie(n,r,o.key)),kind:`elementAdaptSlotEvent`,names:[t.name,i.name,o.name],params:o.params});if(i&&i.properties)for(let n of i.properties)a.push({id:D(`elementAdaptSlotPropertyChangeEvent`,e,He(t.key,i.key,n.key)),kind:`elementAdaptSlotPropertyChangeEvent`,names:[t.name,i.name,n.name],params:q(n.type)})}}else if(t===`customSlot`){let t=i[n];if(t&&t.meta.slots){let i=t.meta.slots.find(e=>e.id===r);if(i&&i.events)for(let r of i.events)a.push({id:D(`customAdaptSlotEvent`,e,Fe(n,i.id,r.id)),kind:`customAdaptSlotEvent`,names:[t.name,i.name,r.name],params:K(r.params)});if(i&&i.properties)for(let r of i.properties)a.push({id:D(`customAdaptSlotPropertyChangeEvent`,e,Ve(n,i.id,r.id)),kind:`customAdaptSlotPropertyChangeEvent`,names:[t.name,i.name,r.name],params:q(r.type)})}}}if(R(c.key)){if(t.type===`page`){if(n.meta.states)for(let{id:e,name:t,type:r}of n.meta.states)a.push({id:D(`stateChangeEvent`,`globality`,e),kind:`stateChangeEvent`,names:[t],params:q(r)})}else if(t.type===`comp`&&r.meta.states)for(let{id:e,name:t,type:n}of r.meta.states)a.push({id:D(`stateChangeEvent`,`globality`,e),kind:`stateChangeEvent`,names:[t],params:q(n)})}return a}function qn(e){if(!e)return;let{activeObject:t,activePage:n,activeComp:r,depends:i}=w.app,a=Ne(t.type,t.subtype),{kind:o,nodeId:s,eventKey:c}=Xe(e),l=t.nodes.find(e=>e.id===s);if(!l)return;let u=E(l.key);if(!u){console.assert(!1,`invalid element`,l.key);return}if(o===`elementEvent`){let t=u.events?.find(e=>e.key===c);if(t)return{id:e,kind:o,names:[t.name],params:t.params}}else if(o===`elementPropertyChangeEvent`){if(T[u.key]&&T[u.key][a]){let t=T[u.key][a].find(e=>e.keys===c);if(t)return{id:e,kind:o,names:t.names,params:q(Xt(t.raw))}}}else if(o===`refEvent`){if(Qt(u.key)&&l.comp){let t=i[l.comp];if(t){let n=t.meta.events?.find(e=>e.id===c);if(n)return{id:e,kind:o,names:[n.name],params:K(n.params)}}}}else if(o===`refPropertyChangeEvent`){if(Qt(u.key)&&l.comp){let t=i[l.comp];if(t){let n=t.meta.properties?.find(e=>e.id===c);if(n)return{id:e,kind:o,names:[n.name],params:q(n.type)}}}}else if(o===`multipleRefEvent`){if($t(u.key)&&l.comp){let t=i[l.comp];if(t){let n=t.meta.events?.find(e=>e.id===c);if(n)return{id:e,kind:o,names:[n.name],params:K(n.params)}}}}else if(o===`multipleRefPropertyChangeEvent`){if($t(u.key)&&l.comp){let t=i[l.comp];if(t){let n=t.meta.properties?.find(e=>e.id===c);if(n)return{id:e,kind:o,names:[n.name],params:q(n.type)}}}}else if(o===`customSlotEvent`){if(z(u.key)&&l.slot&&t.type===`comp`&&r.meta.slots){let{compId:t,slotId:n,eventId:i}=Ze(c);if(r.id===t&&l.slot===n){let t=r.meta.slots.find(e=>e.id===n);if(t&&t.events){let n=t.events.find(e=>e.id===i);if(n)return{id:e,kind:o,names:[t.name,n.name],params:K(n.params)}}}}}else if(o===`customSlotPropertyChangeEvent`){if(z(u.key)&&l.slot&&t.type===`comp`&&r.meta.slots){let{compId:t,slotId:n,eventId:i}=Ze(c);if(r.id===t&&l.slot===n){let t=r.meta.slots.find(e=>e.id===n);if(t&&t.properties){let n=t.properties.find(e=>e.id===i);if(n)return{id:e,kind:o,names:[t.name,n.name],params:q(n.type)}}}}}else if(o===`multipleCustomSlotEvent`){if(B(u.key)&&l.slot&&t.type===`comp`&&r.meta.slots){let{compId:t,slotId:n,eventId:i}=Ze(c);if(r.id===t&&l.slot&&n){let t=r.meta.slots.find(e=>e.id===n);if(t&&t.events){let n=t.events.find(e=>e.id===i);if(n)return{id:e,kind:o,names:[t.name,n.name],params:K(n.params)}}}}}else if(o===`multipleCustomSlotPropertyChangeEvent`){if(B(u.key)&&l.slot&&t.type===`comp`&&r.meta.slots){let{compId:t,slotId:n,eventId:i}=Ze(c);if(r.id===t&&l.slot===n){let t=r.meta.slots.find(e=>e.id===n);if(t&&t.properties){let n=t.properties.find(e=>e.id===i);if(n)return{id:e,kind:o,names:[t.name,n.name],params:q(n.type)}}}}}else if(o===`customEvent`){if(R(u.key)&&t.type===`comp`){let t=r.meta.events?.find(e=>e.id===c);if(t)return{id:e,kind:o,names:[t.name],params:K(t.params)}}}else if(o===`customPropertyChangeEvent`){if(R(u.key)&&t.type===`comp`){let t=r.meta.properties?.find(e=>e.id===c);if(t)return{id:e,kind:o,names:[t.name],params:q(t.type)}}}else if(o===`elementAdaptSlotEvent`){if(R(u.key)&&t.type===`comp`&&l.adaptSlot){let{elementKey:t,slotKey:n,eventKey:r}=Qe(c);if(en(l.adaptSlot,t,n)){let i=E(t);if(i&&i.slots){let t=i.slots.find(e=>e.key===n);if(t&&t.events){let n=t.events.find(e=>e.key===r);if(n)return{id:e,kind:o,names:[i.name,t.name,n.name],params:n.params}}}}}}else if(o===`elementAdaptSlotPropertyChangeEvent`){if(R(u.key)&&t.type===`comp`&&l.adaptSlot){let{elementKey:t,slotKey:n,propertyKey:r}=it(c);if(en(l.adaptSlot,t,n)){let i=E(t);if(i&&i.slots){let t=i.slots.find(e=>e.key===n);if(t&&t.properties){let n=t.properties.find(e=>e.key===r);if(n)return{id:e,kind:o,names:[i.name,t.name,n.name],params:q(n.type)}}}}}}else if(o===`customAdaptSlotEvent`){if(R(u.key)&&t.type===`comp`&&l.adaptSlot){let{compId:t,slotId:n,eventId:r}=Ze(c);if(tn(l.adaptSlot,t,n)){let a=i[t];if(a&&a.meta.slots){let t=a.meta.slots.find(e=>e.id===n);if(t&&t.events){let n=t.events.find(e=>e.id===r);if(n)return{id:e,kind:o,names:[a.name,t.name,n.name],params:K(n.params)}}}}}}else if(o===`customAdaptSlotPropertyChangeEvent`){if(R(u.key)&&t.type===`comp`&&l.adaptSlot){let{compId:t,slotId:n,propertyId:r}=rt(c);if(tn(l.adaptSlot,t,n)){let a=i[t];if(a&&a.meta.slots){let t=a.meta.slots.find(e=>e.id===n);if(t&&t.properties){let n=t.properties.find(e=>e.id===r);if(n)return{id:e,kind:o,names:[a.name,t.name,n.name],params:q(n.type)}}}}}}else if(o===`stateChangeEvent`&&R(u.key)){if(t.type===`page`){let t=n.meta.states?.find(e=>e.id===c);if(t)return{id:e,kind:o,names:[t.name],params:q(t.type)}}else if(t.type===`comp`){let t=r.meta.states?.find(e=>e.id===c);if(t)return{id:e,kind:o,names:[t.name],params:q(t.type)}}}}function Jn(e){let t=[],n=Kn(e),r;for(let{id:e,kind:i,names:a}of n)i!==r&&(r&&t.push(`separator`),r=i),t.push([qe(i,a),e]);return L(t)}function Yn(e){let{activeObject:t,activeComp:n}=w.app,r=[],i=t.nodes.find(t=>t.id===e);if(!i)return r;let a=E(i.key);if(!a)return console.assert(!1,`invalid element`,i.key),r;if(z(a.key)&&i.slot&&t.type===`comp`&&n.meta.slots){let t=n.meta.slots.find(e=>e.id===i.slot);if(t&&t.events)for(let i of t.events)r.push({id:D(`customSlotEvent`,e,Fe(n.id,t.id,i.id)),kind:`customSlotEvent`,names:[t.name,i.name],params:K(i.params)})}if(B(a.key)&&i.slot&&t.type===`comp`&&n.meta.slots){let t=n.meta.slots.find(e=>e.id===i.slot);if(t&&t.events)for(let i of t.events)r.push({id:D(`multipleCustomSlotEvent`,e,Fe(n.id,t.id,i.id)),kind:`multipleCustomSlotEvent`,names:[t.name,i.name],params:K(i.params)})}if(R(a.key)&&t.type===`comp`&&n.meta.events)for(let e of n.meta.events)r.push({id:D(`customEvent`,`globality`,e.id),kind:`customEvent`,names:[e.name],params:K(e.params)});return r}function Xn(e){if(!e)return;let{activeObject:t,activeComp:n}=w.app,{kind:r,nodeId:i,eventKey:a}=Xe(e),o=t.nodes.find(e=>e.id===i);if(!o)return;let s=E(o.key);if(!s){console.assert(!1,`invalid element`,o.key);return}if(r===`customSlotEvent`){if(z(s.key)&&o.slot&&t.type===`comp`&&n.meta.slots){let{compId:t,slotId:i,eventId:s}=Ze(a);if(n.id===t&&o.slot===i){let t=n.meta.slots.find(e=>e.id===i);if(t&&t.events){let n=t.events.find(e=>e.id===s);if(n)return{id:e,kind:r,names:[t.name,n.name],params:K(n.params)}}}}}else if(r===`multipleCustomSlotEvent`){if(B(s.key)&&o.slot&&t.type===`comp`&&n.meta.slots){let{compId:t,slotId:i,eventId:s}=Ze(a);if(n.id===t&&o.slot&&i){let t=n.meta.slots.find(e=>e.id===i);if(t&&t.events){let n=t.events.find(e=>e.id===s);if(n)return{id:e,kind:r,names:[t.name,n.name],params:K(n.params)}}}}}else if(r===`customEvent`&&R(s.key)&&t.type===`comp`&&n.meta.events){let t=n.meta.events.find(e=>e.id===a);if(t)return{id:e,kind:r,names:[t.name],params:K(t.params)}}}function Zn(e){let t=[],n=Yn(e),r;for(let{id:e,kind:i,names:a}of n)i!==r&&(r&&t.push(`separator`),r=i),t.push([qe(i,a),e]);return L(t)}function J(e){if(!e)return;let t=[];for(let{id:n,name:r,type:i}of e)t.push({key:n,name:r,type:i});return t}function Y(e){if(!e)return;let t=[];for(let{id:n,name:r,type:i}of e)t.push({key:n,name:r,type:i});return t}function Qn(e){let t=!0;switch(e){case``:break;case`elementMethod`:case`elementSlotMethod`:case`multipeElementSlotMethod`:break;case`refMethod`:case`multipleRefMethod`:t=!1;break;case`customSlotMethod`:case`multipleCustomSlotMethod`:t=!1;break;case`customMethod`:t=!1;break;case`elementAdaptSlotMethod`:break;case`customAdaptSlotMethod`:t=!1;break;default:console.assert(!1,`not implemented kind=${e}`)}return t}function $n(e){let{activeObject:t,activeComp:n,depends:r}=w.app,i=[],a=t.nodes.find(t=>t.id===e);if(!a)return i;let o=E(a.key);if(!o)return console.assert(!1,`inavlid element`,a.key),i;if(o.methods)for(let{key:t,name:n,inputs:r,outputs:a}of o.methods)i.push({id:Le(`elementMethod`,e,t),kind:`elementMethod`,names:[n],inputs:r,outputs:a});if(Qt(o.key)&&a.comp){let t=r[a.comp];if(t&&t.meta.methods)for(let{id:n,name:r,inputs:a,outputs:o}of t.meta.methods)i.push({id:Le(`refMethod`,e,n),kind:`refMethod`,names:[r],inputs:J(a),outputs:Y(o)})}if($t(o.key)&&a.comp){let t=r[a.comp];if(t&&t.meta.methods)for(let{id:n,name:r,inputs:a,outputs:o}of t.meta.methods)i.push({id:Le(`multipleRefMethod`,e,n),kind:`multipleRefMethod`,names:[r],inputs:J(a),outputs:Y(o)})}if(R(o.key)&&t.type===`comp`&&n.meta.methods)for(let{id:t,name:r,inputs:a,outputs:o}of n.meta.methods)i.push({id:Le(`customMethod`,e,t),kind:`customMethod`,names:[r],inputs:J(a),outputs:Y(o)});if(R(o.key)&&t.type===`comp`&&a.adaptSlot){let{kind:t,mainKey:n,slotKey:o}=at(a.adaptSlot);if(t===`elementSlot`){let t=E(n);if(t&&t.slots){let n=t.slots.find(e=>e.key===o);if(n&&n.methods)for(let r of n.methods)i.push({id:Le(`elementAdaptSlotMethod`,e,ze(t.key,n.key,r.key)),kind:`elementAdaptSlotMethod`,names:[t.name,n.name,r.name],inputs:r.inputs,outputs:r.outputs})}}else if(t===`customSlot`){let t=r[n];if(t&&t.meta.slots){let r=t.meta.slots.find(e=>e.id===o);if(r&&r.methods)for(let a of r.methods)i.push({id:Le(`customAdaptSlotMethod`,e,Re(n,r.id,a.id)),kind:`customAdaptSlotMethod`,names:[t.name,r.name,a.name],inputs:J(a.inputs),outputs:Y(a.outputs)})}}}return i}function er(e){if(!e)return;let{activeObject:t,activeComp:n,depends:r}=w.app,{kind:i,nodeId:a,methodKey:o}=$e(e),s=t.nodes.find(e=>e.id===a);if(!s)return;let c=E(s.key);if(!c){console.assert(!1,`invalid element`,s.key);return}if(i===`elementMethod`){let t=c.methods?.find(e=>e.key===o);if(t)return{id:e,kind:i,names:[t.name],inputs:t.inputs,outputs:t.outputs}}else if(i===`refMethod`){if(Qt(c.key)&&s.comp){let t=r[s.comp];if(t){let n=t.meta.methods?.find(e=>e.id===o);if(n)return{id:e,kind:i,names:[n.name],inputs:J(n.inputs),outputs:Y(n.outputs)}}}}else if(i===`multipleRefMethod`){if($t(c.key)&&s.comp){let t=r[s.comp];if(t){let n=t.meta.methods?.find(e=>e.id===o);if(n)return{id:e,kind:i,names:[n.name],inputs:J(n.inputs),outputs:Y(n.outputs)}}}}else if(i===`customMethod`){if(R(c.key)&&t.type===`comp`){let t=n.meta.methods?.find(e=>e.id===o);if(t)return{id:e,kind:i,names:[t.name],inputs:J(t.inputs),outputs:J(t.outputs)}}}else if(i===`customSlotMethod`){if(R(c.key)&&t.type===`comp`&&n.meta.slots){let{slotId:t,methodId:r}=et(o),a=n.meta.slots.find(e=>e.id===t);if(a&&a.methods){let t=a.methods.find(e=>e.id===r);if(t)return{id:e,kind:i,names:[a.name,t.name],inputs:J(t.inputs),outputs:Y(t.outputs)}}}}else if(i===`elementAdaptSlotMethod`){if(R(c.key)&&t.type===`comp`&&s.adaptSlot){let{elementKey:t,slotKey:n,methodKey:r}=tt(o);if(en(s.adaptSlot,t,n)){let a=E(t);if(a&&a.slots){let t=a.slots.find(e=>e.key===n);if(t&&t.methods){let n=t.methods.find(e=>e.key===r);if(n)return{id:e,kind:i,names:[a.name,t.name,n.name],inputs:n.inputs,outputs:n.outputs}}}}}}else if(i===`customAdaptSlotMethod`&&R(c.key)&&t.type===`comp`&&s.adaptSlot){let{compId:t,slotId:n,methodId:a}=et(o);if(tn(s.adaptSlot,t,n)){let o=r[t];if(o&&o.meta.slots){let t=o.meta.slots.find(e=>e.id===n);if(t&&t.methods){let n=t.methods.find(e=>e.id===a);if(n)return{id:e,kind:i,names:[o.name,t.name,n.name],inputs:J(n.inputs),outputs:Y(n.outputs)}}}}}}function tr(e){let t=[],n=$n(e),r;for(let{id:e,kind:i,names:a}of n)i!==r&&(r&&t.push(`separator`),r=i),t.push([Je(i,a),e]);return L(t)}function nr(e){let t=!0;switch(e){case``:break;case`elementMethod`:case`elementSlotMethod`:case`multipeElementSlotMethod`:break;case`refMethod`:case`multipleRefMethod`:t=!1;break;case`customSlotMethod`:case`multipleCustomSlotMethod`:t=!1;break;case`customMethod`:t=!1;break;case`elementAdaptSlotMethod`:break;case`customAdaptSlotMethod`:t=!1;break;default:console.assert(!1,`not implemented kind=${e}`)}return t}function rr(e){let{activeObject:t,activeComp:n}=w.app,r=[],i=t.nodes.find(t=>t.id===e);if(!i)return r;let a=E(i.key);if(!a)return console.assert(!1,`inavlid element`,i.key),r;if(z(a.key)&&i.slot&&t.type===`comp`&&n.meta.slots){let t=n.meta.slots.find(e=>e.id===i.slot);if(t&&t.methods)for(let i of t.methods)r.push({id:Le(`customSlotMethod`,e,Re(n.id,t.id,i.id)),kind:`customSlotMethod`,names:[t.name,i.name],inputs:J(i.inputs),outputs:J(i.outputs)})}if(B(a.key)&&i.slot&&t.type===`comp`&&n.meta.slots){let t=n.meta.slots.find(e=>e.id===i.slot);if(t&&t.methods)for(let i of t.methods)r.push({id:Le(`multipleCustomSlotMethod`,e,Re(n.id,t.id,i.id)),kind:`multipleCustomSlotMethod`,names:[t.name,i.name],inputs:J(i.inputs),outputs:Y(i.outputs)})}if(R(a.key)&&t.type===`comp`&&n.meta.methods)for(let{id:t,name:i,inputs:a,outputs:o}of n.meta.methods)r.push({id:Le(`customMethod`,e,t),kind:`customMethod`,names:[i],inputs:J(a),outputs:Y(o)});return r}function ir(e){if(!e)return;let{activeObject:t,activeComp:n}=w.app,{kind:r,nodeId:i,methodKey:a}=$e(e),o=t.nodes.find(e=>e.id===i);if(!o)return;let s=E(o.key);if(!s){console.assert(!1,`invalid element`,o.key);return}if(r===`customSlotMethod`){if(z(s.key)&&o.slot&&t.type===`comp`&&n.meta.slots){let{compId:t,slotId:i,methodId:s}=et(a);if(n.id===t&&i===o.slot){let t=n.meta.slots.find(e=>e.id===i);if(t&&t.methods){let n=t.methods.find(e=>e.id===s);if(n)return{id:e,kind:r,names:[t.name,n.name],inputs:J(n.inputs),outputs:Y(n.outputs)}}}}}else if(r===`multipleCustomSlotMethod`){if(B(s.key)&&o.slot&&t.type===`comp`&&n.meta.slots){let{compId:t,slotId:i,methodId:s}=et(a);if(n.id===t&&o.slot===i){let t=n.meta.slots.find(e=>e.id===i);if(t&&t.methods){let n=t.methods.find(e=>e.id===s);if(n)return{id:e,kind:r,names:[t.name,n.name],inputs:J(n.inputs),outputs:Y(n.outputs)}}}}}else if(r===`customMethod`&&R(s.key)&&t.type===`comp`&&n.meta.methods){let t=n.meta.methods.find(e=>e.id===a);if(t)return{id:e,kind:r,names:[t.name],inputs:J(t.inputs),outputs:Y(t.outputs)}}}function ar(e){let t=[],n=rr(e),r;for(let{id:e,kind:i,names:a}of n)i!==r&&(r&&t.push(`separator`),r=i),t.push([Je(i,a),e]);return L(t)}function or(e){let t=ir(e);return t?t.outputs:[]}function sr(e,t){let n=ir(e);if(n)return n.outputs?.find(e=>e.key===t)}function cr(e){let t=[],n=or(e);if(n)for(let{name:e,key:r}of n)t.push([e,r]);return L(t)}function lr(e){let{appList:t}=w.app,n=[],r=t.find(t=>t.id===e);if(!r)return n;for(let{id:e,name:t}of r.pages)n.push({id:e,name:t});return n}function ur(e,t){let{appList:n}=w.app,r=n.find(t=>t.id===e);if(!r)return;let i=r.pages.find(e=>e.id===t);if(i)return{id:i.id,name:i.name}}function dr(e){let t=[];return lr(e).forEach(({id:e,name:n})=>{t.push([n,e])}),L(t)}function fr(e,t){let{activeObject:n,activeComp:r,depends:i}=w.app,a=[],o=Ne(n.type,n.subtype),s=n.nodes.find(t=>t.id===e);if(!s)return a;let c=E(s.key);if(!c)return console.assert(!1,`invalid element`,s.key),a;if(T[c.key]&&T[c.key][o])for(let{keys:n,names:r,raw:i}of T[c.key][o])t===`write`&&Zt(n,i)||a.push({id:Be(`elementProperty`,e,n),kind:`elementProperty`,names:r,meta:{element:!0,raw:i}});if(Qt(c.key)&&s.comp){let t=i[s.comp];if(t&&t.meta.properties)for(let{id:n,name:r,type:i}of t.meta.properties)a.push({id:Be(`refProperty`,e,n),kind:`refProperty`,names:[r],meta:{raw:{type:i}}})}if($t(c.key)&&s.comp){let t=i[s.comp];if(t&&t.meta.properties)for(let{id:n,name:r,type:i}of t.meta.properties)a.push({id:Be(`multipleRefProperty`,e,n),kind:`multipleRefProperty`,names:[r],meta:{raw:{type:i}}})}if(z(c.key)&&s.slot&&n.type===`comp`&&r.meta.slots){let t=r.meta.slots.find(e=>e.id===s.slot);if(t&&t.properties)for(let n of t.properties)a.push({id:Be(`customSlotProperty`,e,Ve(r.id,t.id,n.id)),kind:`customSlotProperty`,names:[t.name,n.name],meta:{raw:{type:n.type}}})}if(B(c.key)&&s.slot&&n.type===`comp`&&r.meta.slots){let t=r.meta.slots.find(e=>e.id===s.slot);if(t&&t.properties)for(let n of t.properties)a.push({id:Be(`multipleCustomSlotProperty`,e,Ve(r.id,t.id,n.id)),kind:`multipleCustomSlotProperty`,names:[t.name,n.name],meta:{raw:{type:n.type}}})}if(R(c.key)&&n.type===`comp`&&r.meta.properties)for(let{id:t,name:n,type:i}of r.meta.properties)a.push({id:Be(`customProperty`,e,t),kind:`customProperty`,names:[n],meta:{raw:{type:i}}});if(R(c.key)&&n.type===`comp`&&s.adaptSlot){let{kind:n,mainKey:r,slotKey:o}=at(s.adaptSlot);if(n===`elementSlot`){let n=E(r);if(n&&n.slots){let r=n.slots.find(e=>e.key===o);if(r&&r.properties)for(let i of r.properties)t===`write`&&i.readonly||a.push({id:Be(`elementAdaptSlotProperty`,e,He(n.key,r.key,i.key)),kind:`elementAdaptSlotProperty`,names:[n.name,r.name,i.name],meta:{raw:{type:i.type}}})}}else if(n===`customSlot`){let t=i[r];if(t&&t.meta.slots){let n=t.meta.slots.find(e=>e.id===o);if(n&&n.properties)for(let i of n.properties)a.push({id:Be(`customAdaptSlotProperty`,e,Ve(r,n.id,i.id)),kind:`customAdaptSlotProperty`,names:[t.name,n.name,i.name],meta:{raw:{type:i.type}}})}}}return a}function pr(e){if(!e)return;let{activeObject:t,activeComp:n,depends:r}=w.app,i=Ne(t.type,t.subtype),{kind:a,nodeId:o,propertyKey:s}=nt(e),c=t.nodes.find(e=>e.id===o);if(!c)return;let l=E(c.key);if(!l){console.assert(!1,`invalid element`,c.key);return}if(a===`elementProperty`){if(T[l.key]&&T[l.key][i]){let t=T[l.key][i].find(e=>e.keys===s);if(t)return{id:e,kind:a,names:t.names,meta:{element:!0,raw:t.raw}}}}else if(a===`refProperty`){if(Qt(l.key)&&c.comp){let t=r[c.comp];if(t){let n=t.meta.properties?.find(e=>e.id===s);if(n)return{id:e,kind:a,names:[n.name],meta:{raw:{type:n.type}}}}}}else if(a===`multipleRefProperty`){if($t(l.key)&&c.comp){let t=r[c.comp];if(t){let n=t.meta.properties?.find(e=>e.id===s);if(n)return{id:e,kind:a,names:[n.name],meta:{raw:{type:n.type}}}}}}else if(a===`customSlotProperty`){if(z(l.key)&&c.slot&&t.type===`comp`&&n.meta.slots){let{compId:t,slotId:r,propertyId:i}=rt(s);if(n.id===t&&c.slot===r){let t=n.meta.slots.find(e=>e.id===r);if(t&&t.properties){let n=t.properties.find(e=>e.id===i);if(n)return{id:e,kind:a,names:[t.name,n.name],meta:{raw:{type:n.type}}}}}}}else if(a===`multipleCustomSlotProperty`){if(B(l.key)&&c.slot&&t.type===`comp`&&n.meta.slots){let{compId:t,slotId:r,propertyId:i}=rt(s);if(n.id===t&&c.slot===r){let t=n.meta.slots.find(e=>e.id===r);if(t&&t.properties){let n=t.properties.find(e=>e.id===i);if(n)return{id:e,kind:a,names:[t.name,n.name],meta:{raw:{type:n.type}}}}}}}else if(a===`customProperty`){if(R(l.key)&&t.type===`comp`){let t=n.meta.properties?.find(e=>e.id===s);if(t)return{id:e,kind:a,names:[t.name],meta:{raw:{type:t.type}}}}}else if(a===`elementAdaptSlotProperty`){if(R(l.key)&&t.type===`comp`&&c.adaptSlot){let{elementKey:t,slotKey:n,propertyKey:r}=it(s);if(en(c.adaptSlot,t,n)){let i=E(t);if(i&&i.slots){let t=i.slots.find(e=>e.key===n);if(t&&t.properties){let n=t.properties.find(e=>e.key===r);if(n)return{id:e,kind:a,names:[i.name,t.name,n.name],meta:{raw:{type:n.type}}}}}}}}else if(a===`customAdaptSlotProperty`&&R(l.key)&&t.type===`comp`&&c.adaptSlot){let{compId:t,slotId:n,propertyId:i}=rt(s);if(tn(c.adaptSlot,t,n)){let o=r[t];if(o&&o.meta.slots){let t=o.meta.slots.find(e=>e.id===n);if(t&&t.properties){let n=t.properties.find(e=>e.id===i);if(n)return{id:e,kind:a,names:[o.name,t.name,n.name],meta:{raw:{type:n.type}}}}}}}}function mr(e,t){let n=[],r=fr(e,t),i;for(let{id:e,kind:t,names:a}of r)t!==i&&(i&&n.push(`separator`),i=t),n.push([Ye(t,a),e]);return L(n)}function hr(){let{activeObject:e,activeComp:t}=w.app,n=[{id:``,name:``}];if(e.type!==`comp`||!t.meta.slots)return n;for(let{id:e,name:r}of t.meta.slots)n.push({id:e,name:r});return n}function gr(e){let{activeObject:t,activeComp:n}=w.app;if(t.type!==`comp`||!n.meta.slots)return;if(!e)return{id:``,name:``};let r=n.meta.slots.find(t=>t.id===e);if(r)return{id:r.id,name:r.name}}function _r(){let{i18n:e}=Ce,t=[],n=hr();for(let{id:r,name:i}of n){let n=i;r===``&&(n=e.global.t(`x-runtime-lib.notSet`)),t.push([n,r])}return L(t)}x.app_bind_entry_v1={init:function(){this.kind=`notSet`,this.node={id:``,key:``,alias:``},this.property={id:``,kind:``,names:[]},this.state={id:``,name:``,type:`string`},this.appendDummyInput().appendField(new C(()=>this.genKindOpts_()),`KIND`).appendField(new C(()=>this.genNodeOpts_()),`NODE`).appendField(new C(()=>this.genPropertyOpts_()),`PROPERTY`).appendField(new C(()=>this.genStateOpts_()),`STATE`),this.setOutput(!0,`BindEntry`),this.updateShape_()},saveExtraState:function(){return{kind:this.kind,node:this.node,property:this.property,state:this.state}},loadExtraState:function(e){this.kind=e.kind??`notSet`,this.node.id=e.node?.id??``,this.node.key=e.node?.key??``,this.node.alias=e.node?.alias??``,this.property.id=e.property?.id??``,this.property.kind=e.property?.kind??``,this.property.names=e.property?.names??[],this.state.id=e.state?.id??``,this.state.name=e.state?.name??``,this.state.type=e.state?.type??`string`,this.updateShape_(),setTimeout(()=>{this.checkWarning_()},0)},genKindOpts_:function(){return Vn()},genNodeOpts_:function(){return this.kind===`property`?In(`setProperty`):L([])},genPropertyOpts_:function(){return this.kind===`property`?mr(this.node.id,`write`):L([])},genStateOpts_:function(){return this.kind===`state`?zn():L([])},onchange:function(e){if(e.type===b.BLOCK_CHANGE){let t=e;t.blockId===this.id&&(t.element===`field`&&(t.name===`KIND`?this.onKindChange_(t.newValue):t.name===`NODE`?this.onNodeChange_(t.newValue):t.name===`PROPERTY`?this.onPropertyChange_(t.newValue):t.name===`STATE`&&this.onStateChange_(t.newValue)),setTimeout(()=>{this.checkWarning_()}))}},onKindChange_:function(e){let t=this.kind!==e;if(this.kind=e,this.kind===`notSet`)this.updateShape_();else if(this.kind===`property`){let e=this.getField(`NODE`);if(e.getOptions(!1),t){let t=Fn(`setProperty`)?.[0];e.setValue(t?.id??``)}this.onNodeChange_(e.getValue())}else if(this.kind===`state`){let e=this.getField(`STATE`);if(e.getOptions(!1),t){let t=Ln()?.[0];e.setValue(t?.id??``)}this.onStateChange_(e.getValue())}},onNodeChange_:function(e){let t=G(e);if(!t){console.assert(!1);return}let n=this.node?.id!==t.id;this.node.id=t.id,this.node.key=t.key,this.node.alias=t.alias;let r=this.getField(`PROPERTY`);if(r.getOptions(!1),n){let e=fr(this.node.id,`write`)?.[0];r.setValue(e?.id??``)}this.onPropertyChange_(r.getValue())},onPropertyChange_:function(e){let t=pr(e);if(!t){console.assert(!1);return}this.property.id=t.id,this.property.kind=t.kind,this.property.names=t.names,this.updateShape_()},onStateChange_:function(e){let t=Rn(e);if(!t){console.assert(!1);return}this.state.id=t.id,this.state.name=t.name,this.state.type=t.type,this.updateShape_()},updateShape_:function(){this.kind===`notSet`?(this.setStyle(`event_blocks`),this.getField(`NODE`).setVisible(!1),this.getField(`PROPERTY`).setVisible(!1),this.getField(`STATE`).setVisible(!1)):this.kind===`property`?(this.setStyle(`property_blocks`),this.getField(`NODE`).setVisible(!0),this.getField(`PROPERTY`).setVisible(!0),this.getField(`STATE`).setVisible(!1)):this.kind===`state`&&(this.setStyle(`state_blocks`),this.getField(`NODE`).setVisible(!1),this.getField(`PROPERTY`).setVisible(!1),this.getField(`STATE`).setVisible(!0)),setTimeout(()=>{this.render()},0)},checkWarning_:function(){if(this.kind===`property`){let e=G(this.node.id);if(!e){this.setWarningText(I(`WARN_NODE_NOT_FOUND`));return}if(e.key!==this.node.key){this.setWarningText(I(`WARN_NODE_HAS_CHANGED`));return}e.alias!==this.node.alias&&(this.node.alias=e.alias);let t=pr(this.property.id);if(!t){this.setWarningText(I(`WARN_PROPERTY_NOT_FOUND`));return}if(t.kind!==this.property.kind){this.setWarningText(I(`WARN_PROPERTY_HAS_CHANGED`));return}_(t.names,this.property.names)||(this.property.names=t.names)}else if(this.kind===`state`){let e=Rn(this.state.id);if(!e){this.setWarningText(I(`WARN_STATE_NOT_FOUND`));return}if(e.name!==this.state.name&&(this.state.name=e.name),e.type!==this.state.type){this.setWarningText(I(`WARN_STATE_HAS_CHANGED`));return}}this.setWarningText(null)}},y.forBlock.app_bind_entry_v1=function(){return``};const vr=S.xml;x.app_bind_container_v1={init:function(){this.appendDummyInput().appendField(`%{BKY_APP_V1_APP_BIND_CONTAINER_TITLE}`),this.appendStatementInput(`STACK`),this.setStyle(`event_blocks`),this.contextMenu=!1}},x.app_bind_item_v1={init:function(){this.appendDummyInput().appendField(`%{BKY_APP_V1_APP_BIND_ITEM_TITLE}`),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setStyle(`event_blocks`),this.contextMenu=!1}},x.app_bind_v1={init:function(){this.itemCount_=0,this.setMutator(new xe.MutatorIcon([`app_bind_item_v1`],this)),this.debounce_=de(()=>{this.checkWarning_()},250),this.setStyle(`event_blocks`),this.setTooltip(`%{BKY_APP_V1_APP_BIND_TOOLTIP}`),this.setHelpUrl(`%{BKY_APP_V1_APP_BIND_HELPURL}`)},mutationToDom:function(){let e=vr.createElement(`mutation`);return e.setAttribute(`items`,String(this.itemCount_)),e},domToMutation:function(e){let t=e.getAttribute(`items`)??``;this.itemCount_=parseInt(t,0),this.updateShape_(),this.updateShadow_(),setTimeout(()=>{this.checkWarning_()},0)},saveExtraState:function(){return{itemCount:this.itemCount_}},loadExtraState:function(e){this.itemCount_=e.itemCount??0,this.updateShape_(),this.updateShadow_(),setTimeout(()=>{this.checkWarning_()},0)},decompose:function(e){let t=e.newBlock(`app_bind_container_v1`);t.initSvg();let n=t.getInput(`STACK`).connection;for(let t=0;t<this.itemCount_;t++){let t=e.newBlock(`app_bind_item_v1`);t.initSvg(),n.connect(t.previousConnection),n=t.nextConnection}return t},compose:function(e){let t=e.getInputTargetBlock(`STACK`),n=[];for(;t;){if(t.isInsertionMarker()){t=t.getNextBlock();continue}n.push(t.valueConnection_),t=t.getNextBlock()}for(let e=0;e<this.itemCount_;e++){this.getInput(`ADD`+e).setShadowDom(null);let t=this.getInput(`ADD`+e).connection.targetConnection;t&&!n.includes(t)&&t.disconnect()}this.itemCount_=n.length,this.updateShape_();for(let e=0;e<this.itemCount_;e++)n[e]?.reconnect(this,`ADD`+e);this.updateShadow_(),setTimeout(()=>{this.checkWarning_()},0)},saveConnections:function(e){let t=e.getInputTargetBlock(`STACK`),n=0;for(;t;){if(t.isInsertionMarker()){t=t.getNextBlock();continue}let e=this.getInput(`ADD`+n);t.valueConnection_=e?.connection.targetConnection,t=t.getNextBlock(),n++}},onchange:function(){this.debounce_()},updateShape_:function(){this.itemCount_&&this.getInput(`EMPTY`)?this.removeInput(`EMPTY`):!this.itemCount_&&!this.getInput(`EMPTY`)&&this.appendDummyInput(`EMPTY`).appendField(`%{BKY_APP_V1_APP_BIND_TITLE}`);for(let e=0;e<this.itemCount_;e++)this.getInput(`ADD`+e)||(this.appendValueInput(`ADD`+e).setCheck(`BindEntry`),e===0&&this.getInput(`ADD`+e).setAlign(m.Align.RIGHT).appendField(`%{BKY_APP_V1_APP_BIND_TITLE}`));for(let e=this.itemCount_;this.getInput(`ADD`+e);e++)this.removeInput(`ADD`+e)},updateShadow_:function(){if(!this.isInsertionMarker())for(let e=0;e<this.itemCount_;e++)this.getInput(`ADD`+e).setShadowDom(yn())},checkWarning_:function(){let e;for(let t=0;t<this.itemCount_;t++){let n=this.getInput(`ADD`+t)?.connection?.targetBlock();if(!n)continue;let r;if(n.kind===`property`){let e=pr(n.property.id);e&&(r=e.meta.element?nn(e.meta.raw):V(e.meta.raw.type))}else if(n.kind===`state`){let e=Rn(n.state.id);e&&(r=V(e.type))}if(r&&(e||=r,r!==e)){this.setWarningText(I(`WARN_TYPE_NOT_MATCH`));return}}this.setWarningText(null)}},y.forBlock.app_bind_v1=function(){return``},x.on_app_event_v1={init:function(){this.node={id:``,key:``,alias:``},this.event={id:``,kind:``,names:[]},this.appendDummyInput().appendField(`%{BKY_APP_V1_ON_APP_EVENT_TITLE}`).appendField(new C(()=>this.genNodeOpts_()),`NODE`).appendField(new C(()=>this.genEventOpts_()),`EVENT`),this.appendStatementInput(`HANDLE`).appendField(`%{BKY_APP_DO}`),this.setStyle(`event_blocks`),this.setTooltip(`%{BKY_APP_V1_ON_APP_EVENT_TOOLTIP}`),this.setHelpUrl(`%{BKY_APP_V1_ON_APP_EVENT_HELPURL}`),this.initData_()},initData_:function(){if(this.node.id)return;let e=Fn(`onEvent`)?.[0];if(!e)return;this.node.id=e.id,this.node.key=e.key,this.node.alias=e.alias;let t=this.getField(`NODE`);t.getOptions(!1),t.setValue(this.node.id);let n=Kn(this.node.id)?.[0];if(!n)return;this.event.id=n.id,this.event.kind=n.kind,this.event.names=n.names,this.event.params=n.params;let r=this.getField(`EVENT`);r.getOptions(!1),r.setValue(this.event.id)},saveExtraState:function(){return{node:this.node,event:this.event}},loadExtraState:function(e){this.node.id=e.node?.id??``,this.node.key=e.node?.key??``,this.node.alias=e.node?.alias??``,this.event.id=e.event?.id??``,this.event.kind=e.event?.kind??``,this.event.names=e.event?.names??[],this.event.params=e.event?.params,this.updateShape_(),setTimeout(()=>{this.ensureBlocks_(),this.checkWarning_()},0)},genNodeOpts_:function(){return In(`onEvent`)},genEventOpts_:function(){return Jn(this.node.id)},onchange:function(e){if(e.type===b.BLOCK_CHANGE){let t=e;t.blockId===this.id&&(t.element===`field`&&(t.name===`NODE`?this.onNodeChange_(t.newValue):t.name===`EVENT`&&this.onEventChange_(t.newValue)),setTimeout(()=>{this.checkWarning_()},0))}},onNodeChange_:function(e){let t=G(e);if(!t){console.assert(!1);return}let n=this.node.id!==t.id;this.node.id=t.id,this.node.key=t.key,this.node.alias=t.alias;let r=this.getField(`EVENT`);if(r.getOptions(!1),n){let e=Kn(this.node.id)?.[0];r.setValue(e?.id??``)}this.onEventChange_(r.getValue())},onEventChange_:function(e){let t=qn(e);if(!t){console.assert(!1);return}this.event.id=t.id,this.event.kind=t.kind,this.event.names=t.names,this.event.params=t.params,this.updateShape_(),setTimeout(()=>{this.ensureBlocks_()},0)},updateShape_:function(){for(let e=this.event.params?.length??0;this.getInput(`PARAM`+e);e++){let t=this.getInput(`PARAM`+e).connection.targetBlock();t&&t.dispose(),this.removeInput(`PARAM`+e)}if(this.event.params)for(let e=0;e<this.event.params.length;e++)this.getInput(`PARAM`+e)||(this.appendValueInput(`PARAM`+e),this.moveInputBefore(`PARAM`+e,`HANDLE`));let e=!1;switch(this.event.kind){case`multipleRefEvent`:case`multipleRefPropertyChangeEvent`:case`multipleCustomSlotEvent`:case`multipleCustomSlotPropertyChangeEvent`:e=!0}if(e)this.getInput(`INSTANCE`)||this.appendValueInput(`INSTANCE`).setCheck(`String`),this.event.params&&this.event.params.length>0?this.moveInputBefore(`INSTANCE`,`PARAM0`):this.moveInputBefore(`INSTANCE`,`HANDLE`);else if(this.getInput(`INSTANCE`)){let e=this.getInput(`INSTANCE`).connection.targetBlock();e&&e.dispose(),this.removeInput(`INSTANCE`)}},ensureBlocks_:function(){if(this.isInsertionMarker())return;let e=[];this.getInput(`INSTANCE`)&&e.push([`INSTANCE`,`__instance__`,`x-runtime-lib.instance`,!0]);let t=Gn(this.event.kind);if(this.event.params)for(let n=0;n<this.event.params.length;n++){let{key:r,name:i}=this.event.params[n];e.push([`PARAM`+n,`__param$${r}__`,i,t])}e.length>0&&H(this,e)},checkWarning_:function(){let e=G(this.node.id);if(!e){this.setWarningText(I(`WARN_NODE_NOT_FOUND`));return}if(e.key!==this.node.key){this.setWarningText(I(`WARN_NODE_HAS_CHANGED`));return}e.alias!==this.node.alias&&(this.node.alias=e.alias);let t=qn(this.event.id);if(!t){this.setWarningText(I(`WARN_EVENT_NOT_FOUND`));return}if(t.kind!==this.event.kind){this.setWarningText(I(`WARN_EVENT_HAS_CHANGED`));return}if(_(t.names,this.event.names)||(this.event.names=t.names),!_(t.params,this.event.params)){this.setWarningText(I(`WARN_EVENT_HAS_CHANGED`));return}this.setWarningText(null)}},y.forBlock.on_app_event_v1=function(e){let t=y.quote_,n=e,r=``;if(n.event.params)for(let e=0;e<n.event.params.length;e++){let t=n.event.params[e];r+=`const __param$${t.key}__ = __params__[${e}];\n`}let i=y.statementToCode(n,`HANDLE`);return`__onEventV1__(${t(n.event.id)}, async (__params__, __instance__) => {
|
|
10
10
|
try {
|
|
11
|
-
${
|
|
11
|
+
${Ae(r,4)}${Ae(i,2)} } catch (e) {
|
|
12
12
|
__messageV1__('error', e);
|
|
13
13
|
}
|
|
14
14
|
});
|
|
15
|
-
`}
|
|
16
|
-
${
|
|
17
|
-
`},
|
|
18
|
-
var __result__ = await __openConfirmDlgV1__(${
|
|
19
|
-
${
|
|
20
|
-
`}
|
|
21
|
-
var __result__ = await __openPromptDlgV1__(${
|
|
22
|
-
${
|
|
23
|
-
`},
|
|
24
|
-
const __outputs__ = await ${
|
|
25
|
-
${
|
|
26
|
-
`}else return`await ${
|
|
27
|
-
const __outputs__ = await __callMethodV1__(${
|
|
28
|
-
${
|
|
29
|
-
`}else return`await __callMethodV1__(${
|
|
30
|
-
${
|
|
31
|
-
${
|
|
15
|
+
`},x.trigger_app_event_v1={init:function(){this.node={id:``,key:``,alias:``},this.event={id:``,kind:``,names:[]},this.appendDummyInput().appendField(`%{BKY_APP_V1_TRIGGER_APP_EVENT_TITLE}`).appendField(new C(()=>this.genNodeOpts_()),`NODE`).appendField(new C(()=>this.genEventOpts_()),`EVENT`),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null),this.setStyle(`event_blocks`),this.setTooltip(`%{BKY_APP_V1_TRIGGER_APP_EVENT_TOOLTIP}`),this.setHelpUrl(`%{BKY_APP_V1_TRIGGER_APP_EVENT_HELPURL}`),this.initData_()},initData_:function(){if(this.node.id)return;let e=Fn(`triggerEvent`)?.[0];if(!e)return;this.node.id=e.id,this.node.key=e.key,this.node.alias=e.alias;let t=this.getField(`NODE`);t.getOptions(!1),t.setValue(this.node.id);let n=Yn(this.node.id)?.[0];if(!n)return;this.event.id=n.id,this.event.kind=n.kind,this.event.names=n.names,this.event.params=n.params;let r=this.getField(`EVENT`);r.getOptions(!1),r.setValue(this.event.id)},saveExtraState:function(){return{node:this.node,event:this.event}},loadExtraState:function(e){this.node.id=e.node?.id??``,this.node.key=e.node?.key??``,this.node.alias=e.node?.alias??``,this.event.id=e.event?.id??``,this.event.kind=e.event?.kind??``,this.event.names=e.event?.names??[],this.event.params=e.event?.params,this.updateShape_(),this.updateShadows_(),setTimeout(()=>{this.checkWarning_()},0)},genNodeOpts_:function(){return In(`triggerEvent`)},genEventOpts_:function(){return Zn(this.node.id)},onchange:function(e){if(e.type===b.BLOCK_CHANGE){let t=e;t.blockId===this.id&&(t.element===`field`&&(t.name===`NODE`?this.onNodeChange_(t.newValue):t.name===`EVENT`&&this.onEventChange_(t.newValue)),setTimeout(()=>{this.checkWarning_()},0))}},onNodeChange_:function(e){let t=G(e);if(!t){console.assert(!1);return}let n=this.node.id!==t.id;this.node.id=t.id,this.node.key=t.key,this.node.alias=t.alias;let r=this.getField(`EVENT`);if(r.getOptions(!1),n){let e=Yn(this.node.id)?.[0];r.setValue(e?.id??``)}this.onEventChange_(r.getValue())},onEventChange_:function(e){let t=Xn(e);if(!t){console.assert(!1);return}this.event.id=t.id,this.event.kind=t.kind,this.event.names=t.names,this.event.params=t.params,this.updateShape_(),this.updateShadows_()},updateShape_:function(){for(let e=this.event.params?.length??0;this.getInput(`PARAM`+e);e++){let t=this.getInput(`PARAM`+e)?.connection?.targetBlock();t&&t.dispose(),this.removeInput(`PARAM`+e)}if(this.event.params){for(let e=0;e<this.event.params.length;e++)this.getInput(`PARAM`+e)||this.appendValueInput(`PARAM`+e);for(let e=0;e<this.event.params.length;e++){let{type:t}=this.event.params[e],n=this.getInput(`PARAM`+e);n.connection.setShadowDom(null);let r=n.connection.targetBlock();r&&!r.isShadow()&&r.dispose(),n.setCheck(V(t))}}let e=!1;switch(this.event.kind){case`multipleRefEvent`:case`multipleRefPropertyChangeEvent`:case`multipleCustomSlotEvent`:case`multipleCustomSlotPropertyChangeEvent`:e=!0}if(e)this.getInput(`INSTANCE`)||this.appendValueInput(`INSTANCE`).setAlign(m.Align.RIGHT).appendField(`%{BKY_APP_INSTANCE}`).setCheck(`String`),this.event.params&&this.event.params.length>0&&this.moveInputBefore(`INSTANCE`,`PARAM0`);else if(this.getInput(`INSTANCE`)){let e=this.getInput(`INSTANCE`).connection.targetBlock();e&&e.dispose(),this.removeInput(`INSTANCE`)}},updateShadows_:function(){if(!this.isInsertionMarker()){if(this.getInput(`INSTANCE`)){let e=U(`string`);this.getInput(`INSTANCE`).setShadowDom(e)}if(this.event.params)for(let e=0;e<this.event.params.length;e++){let t=this.event.params[e],n=U(t.type);this.getInput(`PARAM`+e).connection.setShadowDom(n)}}},checkWarning_:function(){let e=G(this.node.id);if(!e){this.setWarningText(I(`WARN_NODE_NOT_FOUND`));return}if(e.key!==this.node.key){this.setWarningText(I(`WARN_NODE_HAS_CHANGED`));return}e.alias!==this.node.alias&&(this.node.alias=e.alias);let t=Xn(this.event.id);if(!t){this.setWarningText(I(`WARN_EVENT_NOT_FOUND`));return}if(t.kind!==this.event.kind){this.setWarningText(I(`WARN_EVENT_HAS_CHANGED`));return}if(_(t.names,this.event.names)||(this.event.names=t.names),!_(t.params,this.event.params)){this.setWarningText(I(`WARN_EVENT_HAS_CHANGED`));return}this.setWarningText(null)}},y.forBlock.trigger_app_event_v1=function(e){let t=y.quote_,n=e,r=`[`;if(n.event.params)for(let e=0;e<n.event.params.length;e++){let t=y.valueToCode(n,`PARAM`+e,v.NONE);e!==0&&(r+=`, `),r+=t}r+=`]`;let i=`''`;return n.getInput(`INSTANCE`)&&(i=y.valueToCode(n,`INSTANCE`,v.NONE)||`''`),`await __triggerEventV1__(${t(n.event.id)}, ${r}, ${i});\n`},a([{type:`watch_effect_v1`,message0:`%{BKY_APP_V1_WATCH_EFFECT_TITLE}`,args0:[{type:`input_dummy`},{type:`input_statement`,name:`HANDLE`}],style:`event_blocks`,tooltip:`%{BKY_APP_V1_WATCH_EFFECT_TOOLTIP}`,helpUrl:`%{BKY_APP_V1_WATCH_EFFECT_HELPURL}`}]),y.forBlock.watch_effect_v1=function(e){return`async function __watchEffect$${ot.encodeString(e.id)}__() {
|
|
16
|
+
${y.statementToCode(e,`HANDLE`)}};
|
|
17
|
+
`},a([{type:`app_debug_trace_v1`,message0:`%{BKY_APP_V1_APP_DEBUG_TRACE_TITLE}`,args0:[{type:`input_value`,name:`OBJECT`}],previousStatement:null,nextStatement:null,style:`procedure_blocks`,tooltip:`%{BKY_APP_V1_APP_DEBUG_TRACE_TOOLTIP}`,helpUrl:`%{BKY_APP_V1_APP_DEBUG_TRACE_HELPURL}`}]),y.forBlock.app_debug_trace_v1=function(e){return`__debugTraceV1__(${y.valueToCode(e,`OBJECT`,v.NONE)});\n`},x.open_confirm_dlg_v1={init:function(){this.appendDummyInput().appendField(`%{BKY_APP_V1_OPEN_CONFIRM_DLG_TITLE}`),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null),this.setStyle(`procedure_blocks`),this.setTooltip(`%{BKY_APP_V1_OPEN_CONFIRM_DLG_TOOLTIP}`),this.setHelpUrl(`%{BKY_APP_V1_OPEN_CONFIRM_DLG_HELPURL}`)},saveExtraState:function(){return{}},loadExtraState:function(){this.updateShape_(),this.updateShadow_(),setTimeout(()=>{this.ensureBlocks_()},0)},updateShape_:function(){this.getInput(`HANDLE`)||this.appendStatementInput(`HANDLE`).appendField(`%{BKY_APP_DO}`),this.getInput(`RESULT`)||(this.appendValueInput(`RESULT`).appendField(`%{BKY_APP_RETURN}`),this.moveInputBefore(`RESULT`,`HANDLE`)),this.getInput(`TEXT`)||(this.appendValueInput(`TEXT`).setCheck(`String`).setAlign(m.Align.RIGHT).appendField(`%{BKY_APP_TEXT}`),this.moveInputBefore(`TEXT`,`RESULT`)),this.getInput(`TITLE`)||(this.appendValueInput(`TITLE`).setCheck(`String`).setAlign(m.Align.RIGHT).appendField(`%{BKY_APP_TITLE}`),this.moveInputBefore(`TITLE`,`TEXT`))},updateShadow_:function(){if(this.isInsertionMarker())return;let e=un(`title`);this.getInput(`TITLE`).connection.setShadowDom(e);let t=un(`text`);this.getInput(`TEXT`).connection.setShadowDom(t)},ensureBlocks_:function(){this.isInsertionMarker()||H(this,[[`RESULT`,`__result__`,`x-runtime-lib.result`,!0]])}},y.forBlock.open_confirm_dlg_v1=function(e){return`{
|
|
18
|
+
var __result__ = await __openConfirmDlgV1__(${y.valueToCode(e,`TITLE`,v.ATOMIC)}, ${y.valueToCode(e,`TEXT`,v.ATOMIC)});
|
|
19
|
+
${y.statementToCode(e,`HANDLE`)}}
|
|
20
|
+
`},x.open_prompt_dlg_v1={init:function(){this.appendDummyInput().appendField(`%{BKY_APP_V1_OPEN_PROMPT_DLG_TITLE}`),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null),this.setStyle(`procedure_blocks`),this.setTooltip(`%{BKY_APP_V1_OPEN_PROMPT_DLG_TOOLTIP}`),this.setHelpUrl(`%{BKY_APP_V1_OPEN_PROMPT_DLG_HELPURL}`)},saveExtraState:function(){return{}},loadExtraState:function(){this.updateShape_(),this.updateShadow_(),setTimeout(()=>{this.ensureBlocks_()},0)},updateShape_:function(){this.getInput(`HANDLE`)||this.appendStatementInput(`HANDLE`).appendField(`%{BKY_APP_DO}`),this.getInput(`RESULT`)||(this.appendValueInput(`RESULT`).appendField(`%{BKY_APP_RETURN}`),this.moveInputBefore(`RESULT`,`HANDLE`)),this.getInput(`VALUE`)||(this.appendValueInput(`VALUE`).setCheck(`String`).setAlign(m.Align.RIGHT).appendField(`%{BKY_APP_VALUE}`),this.moveInputBefore(`VALUE`,`RESULT`)),this.getInput(`LABEL`)||(this.appendValueInput(`LABEL`).setCheck(`String`).setAlign(m.Align.RIGHT).appendField(`%{BKY_APP_LABEL}`),this.moveInputBefore(`LABEL`,`VALUE`)),this.getInput(`TITLE`)||(this.appendValueInput(`TITLE`).setCheck(`String`).setAlign(m.Align.RIGHT).appendField(`%{BKY_APP_TITLE}`),this.moveInputBefore(`TITLE`,`LABEL`))},updateShadow_:function(){if(this.isInsertionMarker())return;let e=un(`title`);this.getInput(`TITLE`).connection.setShadowDom(e);let t=un(`label`);this.getInput(`LABEL`).connection.setShadowDom(t);let n=un(``);this.getInput(`VALUE`).connection.setShadowDom(n)},ensureBlocks_:function(){this.isInsertionMarker()||H(this,[[`RESULT`,`__result__`,`x-runtime-lib.result`,!0]])}},y.forBlock.open_prompt_dlg_v1=function(e){return`{
|
|
21
|
+
var __result__ = await __openPromptDlgV1__(${y.valueToCode(e,`TITLE`,v.ATOMIC)}, ${y.valueToCode(e,`LABEL`,v.ATOMIC)}, ${y.valueToCode(e,`VALUE`,v.ATOMIC)});
|
|
22
|
+
${y.statementToCode(e,`HANDLE`)}}
|
|
23
|
+
`},a([{type:`popup_message_v1`,message0:`%{BKY_APP_V1_POPUP_MESSAGE_TITLE}`,args0:[{type:`field_dropdown`,name:`TYPE`,options:[[`%{BKY_APP_POPUP_MESSAGE_TYPE_INFO}`,`info`],[`%{BKY_APP_POPUP_MESSAGE_TYPE_SUCCESS}`,`success`],[`%{BKY_APP_POPUP_MESSAGE_TYPE_WARNING}`,`warning`],[`%{BKY_APP_POPUP_MESSAGE_TYPE_ERROR}`,`error`]]},{type:`input_value`,name:`TEXT`}],previousStatement:null,nextStatement:null,style:`procedure_blocks`,helpUrl:`%{BKY_APP_V1_POPUP_MESSAGE_HELPURL}`,tooltip:`%{BKY_APP_V1_POPUP_MESSAGE_TOOLTIP}`}]),y.forBlock.popup_message_v1=function(e){return`__messageV1__(${y.quote_(e.getFieldValue(`TYPE`))}, ${y.valueToCode(e,`TEXT`,v.ATOMIC)});\n`},x.call_app_method_v1={init:function(){this.node={id:``,key:``,alias:``},this.method={id:``,kind:``,names:[]},this.appendDummyInput().appendField(`%{BKY_APP_V1_CALL_APP_METHOD_TITLE}`).appendField(new C(()=>this.genNodeOpts_()),`NODE`).appendField(new C(()=>this.genMethodOpts_()),`METHOD`),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null),this.setStyle(`procedure_blocks`),this.setTooltip(`%{BKY_APP_V1_CALL_APP_METHOD_TOOLTIP}`),this.setHelpUrl(`%{BKY_APP_V1_CALL_APP_METHOD_HELPURL}`),this.initData_()},initData_:function(){if(this.node.id)return;let e=Fn(`callMethod`)?.[0];if(!e)return;this.node.id=e.id,this.node.key=e.key,this.node.alias=e.alias;let t=this.getField(`NODE`);t.getOptions(!1),t.setValue(this.node.id);let n=$n(this.node.id)?.[0];if(!n)return;this.method.id=n.id,this.method.kind=n.kind,this.method.names=n.names,this.method.inputs=n.inputs,this.method.outputs=n.outputs;let r=this.getField(`METHOD`);r.getOptions(!1),r.setValue(this.method.id)},saveExtraState:function(){return{node:this.node,method:this.method}},loadExtraState:function(e){this.node.id=e.node?.id??``,this.node.key=e.node?.key??``,this.node.alias=e.node?.alias??``,this.method.id=e.method?.id??``,this.method.kind=e.method?.kind??``,this.method.names=e.method?.names??[],this.method.inputs=e.method?.inputs,this.method.outputs=e.method?.outputs,this.updateShape_(),this.updateShadow_(),setTimeout(()=>{this.ensureBlocks_(),this.checkWarning_()},0)},genNodeOpts_:function(){return In(`callMethod`)},genMethodOpts_:function(){return tr(this.node.id)},onchange:function(e){if(e.type===b.BLOCK_CHANGE){let t=e;t.blockId===this.id&&(t.element===`field`&&(t.name===`NODE`?this.onNodeChange_(t.newValue):t.name===`METHOD`&&this.onMethodChange_(t.newValue)),setTimeout(()=>{this.checkWarning_()},0))}},onNodeChange_:function(e){let t=G(e);if(!t){console.assert(!1);return}let n=this.node.id!==t.id;this.node.id=t.id,this.node.key=t.key,this.node.alias=t.alias;let r=this.getField(`METHOD`);if(r.getOptions(!1),n){let e=$n(this.node.id)?.[0];r.setValue(e?.id??``)}this.onMethodChange_(r.getValue())},onMethodChange_:function(e){let t=er(e);if(!t){console.assert(!1);return}this.method.id=t.id,this.method.kind=t.kind,this.method.names=t.names,this.method.inputs=t.inputs,this.method.outputs=t.outputs,this.updateShape_(),this.updateShadow_(),setTimeout(()=>{this.ensureBlocks_()},0)},updateShape_:function(){this.method.outputs&&this.method.outputs.length>0?this.getInput(`HANDLE`)||this.appendStatementInput(`HANDLE`).appendField(`%{BKY_APP_DO}`):this.getInput(`HANDLE`)&&this.removeInput(`HANDLE`);for(let e=this.method.outputs?.length??0;this.getInput(`OUTPUT`+e);e++){let t=this.getInput(`OUTPUT`+e)?.connection?.targetBlock();t&&t.dispose(),this.removeInput(`OUTPUT`+e)}if(this.method.outputs)for(let e=0;e<this.method.outputs.length;e++){if(this.getInput(`OUTPUT`+e))continue;let t=this.appendValueInput(`OUTPUT`+e);e===0&&t.appendField(`%{BKY_APP_RETURN}`),this.moveInputBefore(`OUTPUT`+e,`HANDLE`)}for(let e=this.method.inputs?.length??0;this.getInput(`INPUT`+e);e++)this.removeInput(`INPUT`+e);if(this.method.inputs)for(let e=0;e<this.method.inputs.length;e++){let t=this.method.inputs[e];this.getInput(`INPUT`+e)||(this.appendValueInput(`INPUT`+e).setAlign(m.Align.RIGHT).appendField(I(t.name)),this.method.outputs&&this.method.outputs.length>0&&this.moveInputBefore(`INPUT`+e,`OUTPUT0`))}let e=!1;switch(this.method.kind){case`multipleRefMethod`:case`multipleCustomSlotMethod`:e=!0}if(e)this.getInput(`INSTANCE`)||this.appendValueInput(`INSTANCE`).setAlign(m.Align.RIGHT).appendField(`%{BKY_APP_INSTANCE}`).setCheck(`String`),this.method.inputs&&this.method.inputs.length>0?this.moveInputBefore(`INSTANCE`,`INPUT0`):this.method.outputs&&this.method.outputs.length>0&&this.moveInputBefore(`INSTANCE`,`OUTPUT0`);else if(this.getInput(`INSTANCE`)){let e=this.getInput(`INSTANCE`).connection.targetBlock();e&&e.dispose(),this.removeInput(`INSTANCE`)}},updateShadow_:function(){if(this.isInsertionMarker())return;let e=!1;switch(this.method.kind){case`multipleRefMethod`:case`multipleCustomSlotMethod`:e=!0}if(e){let e=U(`string`);this.getInput(`INSTANCE`).setShadowDom(e)}if(this.method.inputs)for(let e=0;e<this.method.inputs.length;e++){let t=this.method.inputs[e];if(!t.type)continue;let n=U(t.type);this.getInput(`INPUT`+e).setShadowDom(n)}},ensureBlocks_:function(){if(this.isInsertionMarker())return;let e=[],t=Qn(this.method.kind);if(this.method.outputs)for(let n=0;n<this.method.outputs.length;n++){let{key:r,name:i}=this.method.outputs[n];e.push([`OUTPUT`+n,`__output$${r}__`,i,t])}e.length>0&&H(this,e)},checkWarning_:function(){let e=G(this.node.id);if(!e){this.setWarningText(I(`WARN_NODE_NOT_FOUND`));return}if(e.key!==this.node.key){this.setWarningText(I(`WARN_NODE_HAS_CHANGED`));return}e.alias!==this.node.alias&&(this.node.alias=e.alias);let t=er(this.method.id);if(!t){this.setWarningText(I(`WARN_METHOD_NOT_FOUND`));return}if(t.kind!==this.method.kind){this.setWarningText(I(`WARN_METHOD_HAS_CHANGED`));return}if(_(t.names,this.method.names)||(this.method.names=t.names),!_(t.inputs,this.method.inputs)){this.setWarningText(I(`WARN_METHOD_HAS_CHANGED`));return}if(!_(t.outputs,this.method.outputs)){this.setWarningText(I(`WARN_METHOD_HAS_CHANGED`));return}this.setWarningText(null)}},y.forBlock.call_app_method_v1=function(e){let t=y.INDENT,n=y.quote_,r=e,i=`''`;switch(r.method.kind){case`multipleRefMethod`:case`multipleCustomSlotMethod`:i=y.valueToCode(r,`INSTANCE`,v.NONE)||`''`}let a=`{`;if(r.method.inputs)for(let e=0;e<r.method.inputs.length;e++){let{key:t,type:i}=r.method.inputs[e],o=y.valueToCode(r,`INPUT`+e,v.ATOMIC);if(o===void 0)switch(i){case`string`:o=`''`;break;case`number`:o=`0`;break;case`boolean`:o=`false`;break;case`array`:o=`[]`;break;case`object`:o=`{}`;break;default:o=`null`}a!==`{`&&(a+=`, `),a+=`${n(t)}: ${o}`}a+=`}`;let o=``;if(r.method.outputs)for(let{key:e}of r.method.outputs)o+=`${t}const __output$${e}__ = __outputs__[${n(e)}];\n`;if(r.method.kind===`customMethod`){let{kind:e,nodeId:t,methodKey:n}=$e(r.method.id),s=je(e,t,n);if(r.method.outputs&&r.method.outputs.length>0){let e=y.statementToCode(r,`HANDLE`);return`{
|
|
24
|
+
const __outputs__ = await ${s}(${i}, ${a});
|
|
25
|
+
${o}${e}}
|
|
26
|
+
`}else return`await ${s}(${i}, ${a});\n`}else if(r.method.outputs&&r.method.outputs.length>0){let e=y.statementToCode(r,`HANDLE`);return`{
|
|
27
|
+
const __outputs__ = await __callMethodV1__(${n(r.method.id)}, ${i}, ${a});
|
|
28
|
+
${o}${e}}
|
|
29
|
+
`}else return`await __callMethodV1__(${n(r.method.id)}, ${i}, ${a});\n`},x.implement_app_method_v1={init:function(){this.node={id:``,key:``,alias:``},this.method={id:``,kind:``,names:[]},this.appendDummyInput().appendField(`%{BKY_APP_V1_IMPLEMENT_APP_METHOD_TITLE}`).appendField(new C(()=>this.genNodeOpts_()),`NODE`).appendField(new C(()=>this.genMethodOpts_()),`METHOD`),this.appendStatementInput(`HANDLE`).appendField(`%{BKY_APP_DO}`),this.setStyle(`procedure_blocks`),this.setTooltip(`%{BKY_APP_V1_IMPLEMENT_APP_METHOD_TOOLTIP}`),this.setHelpUrl(`%{BKY_APP_V1_IMPLEMENT_APP_METHOD_HELPURL}`),this.initData_()},initData_:function(){if(this.node.id)return;let e=Fn(`implementMethod`)?.[0];if(!e)return;this.node.id=e.id,this.node.key=e.key,this.node.alias=e.alias;let t=this.getField(`NODE`);t.getOptions(!1),t.setValue(this.node.id);let n=rr(this.node.id)?.[0];if(!n)return;this.method.id=n.id,this.method.kind=n.kind,this.method.names=n.names,this.method.inputs=n.inputs;let r=this.getField(`METHOD`);r.getOptions(!1),r.setValue(this.method.id)},saveExtraState:function(){return{node:this.node,method:this.method}},loadExtraState:function(e){this.node.id=e.node?.id??``,this.node.key=e.node?.key??``,this.node.alias=e.node?.alias??``,this.method.id=e.method?.id??``,this.method.kind=e.method?.kind??``,this.method.names=e.method?.names??[],this.method.inputs=e.method?.inputs,this.updateShape_(),setTimeout(()=>{this.ensureBlocks_(),this.checkWarning_()},0)},genNodeOpts_:function(){return In(`implementMethod`)},genMethodOpts_:function(){return ar(this.node.id)},onchange:function(e){if(e.type===b.BLOCK_CHANGE){let t=e;t.blockId===this.id&&(t.element===`field`&&(t.name===`NODE`?this.onNodeChange_(t.newValue):t.name===`METHOD`&&this.onMethodChange_(t.newValue)),setTimeout(()=>{this.checkWarning_()},0))}},onNodeChange_:function(e){let t=G(e);if(!t){console.assert(!1);return}let n=this.node.id!==t.id;this.node.id=t.id,this.node.key=t.key,this.node.alias=t.alias;let r=this.getField(`METHOD`);if(r.getOptions(!1),n){let e=rr(this.node.id)?.[0];r.setValue(e?.id??``)}r.setValue(r.getValue())},onMethodChange_:function(e){let t=ir(e);if(!t){console.assert(!1);return}this.method.id=t.id,this.method.kind=t.kind,this.method.names=t.names,this.method.inputs=t.inputs,this.updateShape_(),setTimeout(()=>{this.ensureBlocks_()},0)},updateShape_:function(){for(let e=this.method.inputs?.length??0;this.getInput(`INPUT`+e);e++){let t=this.getInput(`INPUT`+e)?.connection?.targetBlock();t&&t.dispose(),this.removeInput(`INPUT`+e)}if(this.method.inputs)for(let e=0;e<this.method.inputs.length;e++)this.getInput(`INPUT`+e)||(this.appendValueInput(`INPUT`+e),this.moveInputBefore(`INPUT`+e,`HANDLE`));let e=!1;switch(this.method.kind){case`multipleCustomSlotMethod`:e=!0}if(e)this.getInput(`INSTANCE`)||this.appendValueInput(`INSTANCE`).setAlign(m.Align.RIGHT).appendField(`%{BKY_APP_INSTANCE}`).setCheck(`String`),this.method.inputs&&this.method.inputs.length>0&&this.moveInputBefore(`INSTANCE`,`INPUT0`);else if(this.getInput(`INSTANCE`)){let e=this.getInput(`INSTANCE`).connection.targetBlock();e&&e.dispose(),this.removeInput(`INSTANCE`)}},ensureBlocks_:function(){if(this.isInsertionMarker())return;let e=[];this.getInput(`INSTANCE`)&&e.push([`INSTANCE`,`__instance__`,`x-runtime-lib.instance`,!0]);let t=nr(this.method.kind);if(this.method.inputs)for(let n=0;n<this.method.inputs.length;n++){let{key:r,name:i}=this.method.inputs[n];e.push([`INPUT`+n,`__input$${r}__`,i,t])}H(this,e)},checkWarning_:function(){let e=G(this.node.id);if(!e){this.setWarningText(I(`WARN_NODE_NOT_FOUND`));return}if(e.key!==this.node.key){this.setWarningText(I(`WARN_NODE_HAS_CHANGED`));return}e.alias!==this.node.alias&&(this.node.alias=e.alias);let t=ir(this.method.id);if(!t){this.setWarningText(I(`WARN_METHOD_NOT_FOUND`));return}if(t.kind!==this.method.kind){this.setWarningText(I(`WARN_METHOD_HAS_CHANGED`));return}if(_(t.names,this.method.names)||(this.method.names=t.names),!_(t.inputs,this.method.inputs)){this.setWarningText(I(`WARN_METHOD_HAS_CHANGED`));return}this.setWarningText(null)}},y.forBlock.implement_app_method_v1=function(e){let t=y.INDENT,n=y.quote_,r=e,{kind:i,nodeId:a,methodKey:o}=$e(r.method.id),s=``;if(r.method.inputs)for(let{key:e}of r.method.inputs)s+=`${t}const __input$${e}__ = __inputs__[${n(e)}];\n`;let c=y.statementToCode(r,`HANDLE`);return`async function ${je(i,a,o)}(__instance__, __inputs__) {
|
|
30
|
+
${s}${t}const __outputs__ = {};
|
|
31
|
+
${c}${t}return __outputs__;
|
|
32
32
|
}
|
|
33
|
-
`};const Qn={init:function(){this.node={id:``,key:``,alias:``},this.method={id:``,kind:``,names:[]},this.output={key:``,name:``,type:`string`},this.appendValueInput(`VALUE`).appendField(`%{BKY_APP_V1_SET_APP_METHOD_OUTPUT_TITLE}`).appendField(new e.FieldDropdown(()=>this.genNodeOpts_()),`NODE`).appendField(new e.FieldDropdown(()=>this.genMethodOpts_()),`METHOD`).appendField(new e.FieldDropdown(()=>this.genOutputOpts_()),`OUTPUT`),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null),this.setStyle(`procedure_blocks`),this.setTooltip(`%{BKY_APP_V1_SET_APP_METHOD_OUTPUT_TOOLTIP}`),this.setHelpUrl(`%{BKY_APP_V1_SET_APP_METHOD_OUTPUT_HELPURL}`),this.initData_(),this.updateShape_(),this.updateShadows_()},initData_:function(){if(this.node.id)return;let e=U(`implementMethod`)?.[0];if(!e)return;this.node.id=e.id,this.node.key=e.key,this.node.alias=e.alias;let t=this.getField(`NODE`);t.getOptions(!1),t.setValue(this.node.id);let n=En(this.node.id)?.[0];if(!n)return;this.method.id=n.id,this.method.kind=n.kind,this.method.names=n.names;let r=this.getField(`METHOD`);r.getOptions(!1),r.setValue(this.method.id);let i=kn(this.method.id)?.[0];if(!i)return;this.output.key=i.key,this.output.name=i.name,this.output.type=i.type;let a=this.getField(`OUTPUT`);a.getOptions(!1),a.setValue(this.output.key)},saveExtraState:function(){return{node:this.node,method:this.method,output:this.output}},loadExtraState:function(e){this.node.id=e.node?.id??``,this.node.key=e.node?.key??``,this.node.alias=e.node?.alias??``,this.method.id=e.method?.id??``,this.method.kind=e.method?.kind??``,this.method.names=e.method?.names??[],this.output.key=e.output?.key??``,this.output.name=e.output?.name??``,this.output.type=e.output?.type??``,this.updateShape_(),this.updateShadows_(),setTimeout(()=>{this.checkWarning_()},0)},genNodeOpts_:function(){return an(`implementMethod`)},genMethodOpts_:function(){return On(this.node.id)},genOutputOpts_:function(){return jn(this.method.id)},onchange:function(t){if(t.type===e.Events.BLOCK_CHANGE){let e=t;e.blockId===this.id&&(e.element===`field`&&(e.name===`NODE`?this.onNodeChange_(e.newValue):e.name===`METHOD`?this.onMethodChange_(e.newValue):e.name===`OUTPUT`&&this.onOutputChange_(e.newValue)),setTimeout(()=>{this.checkWarning_()},0))}},onNodeChange_:function(e){let t=W(e);if(!t){console.assert(!1);return}let n=this.node.id!==t.id;this.node.id=t.id,this.node.key=t.key,this.node.alias=t.alias;let r=this.getField(`METHOD`);if(r.getOptions(!1),n){let e=En(this.node.id)?.[0];r.setValue(e?.id??``)}r.setValue(r.getValue())},onMethodChange_:function(e){let t=Dn(e);if(!t){console.assert(!1);return}let n=this.method.id!==t.id;this.method.id=t.id,this.method.kind=t.kind,this.method.names=t.names;let r=this.getField(`OUTPUT`);if(r.getOptions(!1),n||!An(this.method.id,this.output.key)){let e=kn(this.method.id)?.[0];r.setValue(e?.key??``)}this.onOutputChange_(r.getValue())},onOutputChange_:function(e){let t=An(this.method.id,e);if(!t){console.assert(!1);return}this.output.key=t.key,this.output.name=t.name,this.output.type=t.type},updateShape_:function(){let e=this.getInput(`VALUE`);e.connection.setShadowDom(null);let t=e.connection.targetBlock();t&&!t.isShadow()&&t.dispose();let n=z(this.output.type);e.setCheck(n)},updateShadows_:function(){if(this.isInsertionMarker())return;let e=V(this.output.type);this.getInput(`VALUE`).connection.setShadowDom(e)},checkWarning_:function(){let e=W(this.node.id);if(!e){this.setWarningText(M(`WARN_NODE_NOT_FOUND`));return}if(e.key!==this.node.key){this.setWarningText(M(`WARN_NODE_HAS_CHANGED`));return}e.alias!==this.node.alias&&(this.node.alias=e.alias);let t=Dn(this.method.id);if(!t){this.setWarningText(M(`WARN_METHOD_NOT_FOUND`));return}if(t.kind!==this.method.kind){this.setWarningText(M(`WARN_METHOD_HAS_CHANGED`));return}t.names!==this.method.names&&(this.method.names=t.names);let n=An(this.method.id,this.output.key);if(!n){this.setWarningText(M(`WARN_OUTPUT_NOT_FOUND`));return}if(n.name!==this.output.name&&(this.output.name=n.name),n.type!==this.output.type){this.setWarningText(M(`WARN_OUTPUT_HAS_CHANGED`));return}this.setWarningText(null)}};e.Blocks.set_app_method_output_v1=Qn,n.forBlock.set_app_method_output_v1=function(e){let r=n.quote_,i=e,a=n.valueToCode(i,`VALUE`,t.ATOMIC);if(a===void 0)switch(i.output.type){case`string`:a=`''`;break;case`number`:a=`0`;break;case`boolean`:a=`false`;break;case`array`:a=`[]`;break;case`object`:a=`{}`;break;default:a=`null`}return`__outputs__[${r(i.output.key)}] = ${a};\n`},e.defineBlocksWithJsonArray([{type:`app_env_is_v1`,message0:`%{BKY_APP_V1_APP_ENV_IS_TITLE}`,args0:[{type:`field_dropdown`,name:`ENV`,options:[[`%{BKY_APP_ENV_DEV}`,`dev`],[`%{BKY_APP_ENV_PROD}`,`prod`]]}],output:`Boolean`,style:`logic_blocks`,tooltip:`%{BKY_APP_V1_APP_ENV_IS_TOOLTIP}`,helpUrl:`%{BKY_APP_V1_APP_ENV_IS_HELPURL}`}]),n.forBlock.app_env_is_v1=function(e){return[`__getEnvV1__() === ${n.quote_(e.getFieldValue(`ENV`))}`,t.ATOMIC]};const $n={init:function(){this.app={id:``,name:``},this.page={id:``,name:``},this.appendDummyInput().appendField(`%{BKY_APP_V1_NAVIGATE_TO_TITLE}`).appendField(new e.FieldDropdown(()=>this.genAppOpts_()),`APP`).appendField(new e.FieldDropdown(()=>this.genPageOpts_()),`PAGE`),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null),this.setStyle(`procedure_blocks`),this.setTooltip(`%{BKY_APP_V1_NAVIGATE_TOOLTIP}`),this.setHelpUrl(`%{BKY_APP_V1_NAVIGATE_HELPURL}`),this.initData_()},initData_:function(){if(this.app.id)return;let e=Xt()?.[0];if(!e)return;this.app.id=e.id,this.app.name=e.name;let t=this.getField(`APP`);t.getOptions(!1),t.setValue(this.app.id);let n=Mn(this.app.id)?.[0];if(!n)return;this.page.id=n.id,this.page.name=n.name;let r=this.getField(`PAGE`);r.getOptions(!1),r.setValue(this.page.id)},saveExtraState:function(){return{app:this.app,page:this.page}},loadExtraState:function(e){this.app.id=e.app?.id??``,this.app.name=e.app?.name??``,this.page.id=e.page?.id??``,this.page.name=e.page?.name??``,setTimeout(()=>{this.checkWarning_()},0)},genAppOpts_:function(){return Qt()},genPageOpts_:function(){return Pn(this.app.id)},onchange:function(t){if(t.type===e.Events.BLOCK_CHANGE){let e=t;e.blockId===this.id&&(e.element===`field`&&(e.name===`APP`?this.onAppChange_(e.newValue):e.name===`PAGE`&&this.onPageChange_(e.newValue)),setTimeout(()=>{this.checkWarning_()},0))}},onAppChange_:function(e){let t=Zt(e);if(!t){console.assert(!1);return}let n=this.app.id!==t.id;this.app.id=t.id,this.app.name=t.name;let r=this.getField(`PAGE`);if(r.getOptions(!1),n){let e=Mn(this.app.id)?.[0];r.setValue(e?.id??``)}this.onPageChange_(r.getValue())},onPageChange_:function(e){let t=Nn(this.app.id,e);if(!t){console.assert(!1);return}this.page.id=t.id,this.page.name=t.name},checkWarning_:function(){let e=Zt(this.app.id);if(!e){this.setWarningText(M(`WARN_APP_NOT_FOUND`));return}e.name!==this.app.name&&(this.app.name=e.name);let t=Nn(this.app.id,this.page.id);if(!t){this.setWarningText(M(`WARN_PAGE_NOT_FOUND`));return}t.name!==this.page.name&&(this.page.name=t.name),this.setWarningText(null)}};e.Blocks.navigate_to_v1=$n,n.forBlock.navigate_to_v1=function(e){let t=e;return`__navigateToV1__(${n.quote_(t.app.id)}, ${n.quote_(t.page.id)});\n`};const er={init:function(){this.comp={id:``,name:``},this.appendDummyInput().appendField(`%{BKY_APP_V1_SELECT_COMP_TITLE}`).appendField(new e.FieldDropdown(()=>this.genCompOpts_()),`COMP`),this.setOutput(!0,`Comp`),this.setStyle(`property_blocks`),this.setTooltip(`%{BKY_APP_V1_SELECT_COMP_TOOLTIP}`),this.setHelpUrl(`%{BKY_APP_V1_SELECT_COMP_HELPURL}`),this.initData_()},initData_:function(){if(this.comp.id)return;let e=dn()?.[0];if(!e)return;this.comp.id=e.id,this.comp.name=e.name;let t=this.getField(`COMP`);t.getOptions(!1),t.setValue(this.comp.id)},saveExtraState:function(){return{comp:this.comp}},loadExtraState:function(e){this.comp.id=e.comp?.id??``,this.comp.name=e.comp?.name??``,setTimeout(()=>{this.checkWarning_()},0)},genCompOpts_:function(){return pn()},onchange:function(t){if(t.type===e.Events.BLOCK_CHANGE){let e=t;e.blockId===this.id&&(e.element===`field`&&e.name===`COMP`&&this.onCompChange_(e.newValue),setTimeout(()=>{this.checkWarning_()},0))}},onCompChange_:function(e){let t=fn(e);if(!t){console.assert(!1);return}this.comp.id=t.id,this.comp.name=t.name},checkWarning_:function(){let e=fn(this.comp.id);if(!e){this.setWarningText(M(`WARN_COMP_NOT_FOUND`));return}e.name!==this.comp.name&&(this.comp.name=e.name),this.setWarningText(null)}};e.Blocks.select_comp_v1=er,n.forBlock.select_comp_v1=function(e){let r=n.quote_,i=e,a=i.comp.id,o=i.comp.name;return[`{id:${r(a)},name:${r(o)}}`,t.ATOMIC]};const tr={init:function(){this.slot={id:``,name:``},this.appendDummyInput().appendField(`%{BKY_APP_V1_SELECT_SLOT_TITLE}`).appendField(new e.FieldDropdown(()=>this.genSlotOpts_()),`SLOT`),this.setOutput(!0,`Slot`),this.setStyle(`property_blocks`),this.setTooltip(`%{BKY_APP_V1_SELECT_SLOT_TOOLTIP}`),this.setHelpUrl(`%{BKY_APP_V1_SELECT_SLOT_HELPURL}`),this.initData_()},initData_:function(){if(this.slot.id)return;let e=Rn()?.[0];if(!e)return;this.slot.id=e.id,this.slot.name=e.name;let t=this.getField(`SLOT`);t.getOptions(!1),t.setValue(this.slot.id)},saveExtraState:function(){return{slot:this.slot}},loadExtraState:function(e){this.slot.id=e.slot?.id??``,this.slot.name=e.slot?.name??``,setTimeout(()=>{this.checkWarning_()},0)},genSlotOpts_:function(){return Bn()},onchange:function(t){if(t.type===e.Events.BLOCK_CHANGE){let e=t;e.blockId===this.id&&(e.element===`field`&&e.name===`SLOT`&&this.onSlotChange_(e.newValue),setTimeout(()=>{this.checkWarning_()},0))}},onSlotChange_:function(e){let t=zn(e);if(!t){console.assert(!1);return}this.slot.id=t.id,this.slot.name=t.name},checkWarning_:function(){let e=zn(this.slot.id);if(!e){this.setWarningText(M(`WARN_SLOT_NOT_FOUND`));return}e.name!==this.slot.name&&(this.slot.name=e.name),this.setWarningText(null)}};e.Blocks.select_slot_v1=tr,n.forBlock.select_slot_v1=function(e){let r=n.quote_,i=e,a=i.slot.id,o=i.slot.name;return[`{id:${r(a)},name:${r(o)}}`,t.ATOMIC]};const nr={init:function(){this.node={id:``,key:``,alias:``},this.property={id:``,kind:``,names:[]},this.appendDummyInput().appendField(`%{BKY_APP_V1_GET_APP_PROPERTY_TITLE}`).appendField(new e.FieldDropdown(()=>this.genNodeOpts_()),`NODE`).appendField(new e.FieldDropdown(()=>this.genPropertyOpts_()),`PROPERTY`),this.setOutput(!0,null),this.setInputsInline(!0),this.setStyle(`property_blocks`),this.setTooltip(`%{BKY_APP_V1_GET_APP_PROPERTY_TOOLTIP}`),this.setHelpUrl(`%{BKY_APP_V1_GET_APP_PROPERTY_HELPURL}`),this.initData_(),this.updateShape_()},initData_:function(){if(this.node.id)return;let e=U(`getProperty`)?.[0];if(!e)return;this.node.id=e.id,this.node.key=e.key,this.node.alias=e.alias;let t=this.getField(`NODE`);t.getOptions(!1),t.setValue(this.node.id);let n=Fn(this.node.id,`read`)?.[0];if(!n)return;this.property.id=n.id,this.property.kind=n.kind,this.property.names=n.names;let r=this.getField(`PROPERTY`);r.getOptions(!1),r.setValue(this.property.id)},saveExtraState:function(){return{node:this.node,property:this.property}},loadExtraState:function(e){this.node.id=e.node?.id??``,this.node.key=e.node?.key??``,this.node.alias=e.node?.alias??``,this.property.id=e.property?.id??``,this.property.kind=e.property?.kind??``,this.property.names=e.property?.names??[],this.updateShape_(),setTimeout(()=>{this.checkWarning_()},0)},genNodeOpts_:function(){return an(`getProperty`)},genPropertyOpts_:function(){return Ln(this.node.id,`read`)},onchange:function(t){if(t.type===e.Events.BLOCK_CHANGE){let e=t;e.blockId===this.id&&(e.element===`field`&&(e.name===`NODE`?this.onNodeChange_(e.newValue):e.name===`PROPERTY`&&this.onPropertyChange_(e.newValue)),setTimeout(()=>{this.checkWarning_()},0))}},onNodeChange_:function(e){let t=W(e);if(!t){console.assert(!1);return}let n=this.node.id!==t.id;this.node.id=t.id,this.node.key=t.key,this.node.alias=t.alias;let r=this.getField(`PROPERTY`);if(r.getOptions(!1),n){let e=Fn(this.node.id,`read`)?.[0];r.setValue(e?.id??``)}this.onPropertyChange_(r.getValue())},onPropertyChange_:function(e){let t=In(e);if(!t){console.assert(!1);return}this.property.id=t.id,this.property.kind=t.kind,this.property.names=t.names,this.updateShape_(),this.updateShadow_()},updateShape_:function(){let t=!1;switch(this.property.kind){case`multipleRefProperty`:case`multipleCustomSlotProperty`:t=!0}if(t)this.getInput(`INSTANCE`)||this.appendValueInput(`INSTANCE`).setAlign(e.inputs.Align.RIGHT).appendField(`%{BKY_APP_INSTANCE}`).setCheck(`String`);else if(this.getInput(`INSTANCE`)){let e=this.getInput(`INSTANCE`).connection.targetBlock();e&&e.dispose(),this.removeInput(`INSTANCE`)}},updateShadow_:function(){if(this.isInsertionMarker())return;let e=this.getInput(`INSTANCE`);if(e){e.setShadowDom(null);let t=e.connection?.targetBlock();t&&t.dispose(),e.setShadowDom(V(`string`))}},checkWarning_:function(){let e=W(this.node.id);if(!e){this.setWarningText(M(`WARN_NODE_NOT_FOUND`));return}if(e.key!==this.node.key){this.setWarningText(M(`WARN_NODE_HAS_CHANGED`));return}e.alias!==this.node.alias&&(this.node.alias=e.alias);let t=In(this.property.id);if(!t){this.setWarningText(M(`WARN_PROPERTY_NOT_FOUND`));return}if(t.kind!==this.property.kind){this.setWarningText(M(`WARN_PROPERTY_HAS_CHANGED`));return}b(t.names,this.property.names)||(this.property.names=t.names),this.setWarningText(null)}};e.Blocks.get_app_property_v1=nr,n.forBlock.get_app_property_v1=function(e){let r=n.quote_,i=e,a=`''`;return i.getInput(`INSTANCE`)&&(a=n.valueToCode(i,`INSTANCE`,t.NONE)||`''`),[`__getPropertyV1__(${r(i.property.id)}, ${a})`,t.ATOMIC]};const rr={init:function(){this.node={id:``,key:``,alias:``},this.property={id:``,kind:``,names:[]},this.appendValueInput(`VALUE`).appendField(`%{BKY_APP_V1_SET_APP_PROPERTY_TITLE}`).appendField(new e.FieldDropdown(()=>this.genNodeOpts_()),`NODE`).appendField(new e.FieldDropdown(()=>this.genPropertyOpts_()),`PROPERTY`),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null),this.setInputsInline(!0),this.setStyle(`property_blocks`),this.setTooltip(`%{BKY_APP_V1_SET_APP_PROPERTY_TOOLTIP}`),this.setHelpUrl(`%{BKY_APP_V1_SET_APP_PROPERTY_HELPURL}`),this.initData_(),this.updateShape_(),this.isInFlyout&&this.updateShadow_()},initData_:function(){if(this.node.id)return;let e=U(`setProperty`)?.[0];if(!e)return;this.node.id=e.id,this.node.key=e.key,this.node.alias=e.alias;let t=this.getField(`NODE`);t.getOptions(!1),t.setValue(this.node.id);let n=Fn(this.node.id,`write`)?.[0];if(!n)return;this.property.id=n.id,this.property.kind=n.kind,this.property.names=n.names;let r=this.getField(`PROPERTY`);r.getOptions(!1),r.setValue(this.property.id)},saveExtraState:function(){return{node:this.node,property:this.property}},loadExtraState:function(e){this.node.id=e.node?.id??``,this.node.key=e.node?.key??``,this.node.alias=e.node?.alias??``,this.property.id=e.property?.id??``,this.property.kind=e.property?.kind??``,this.property.names=e.property?.names??[],this.updateShape_(),setTimeout(()=>{this.checkWarning_()},0)},genNodeOpts_:function(){return an(`setProperty`)},genPropertyOpts_:function(){return Ln(this.node.id,`write`)},onchange:function(t){if(t.type===e.Events.BLOCK_CHANGE){let e=t;e.blockId===this.id&&(e.element===`field`&&(e.name===`NODE`?this.onNodeChange_(e.newValue):e.name===`PROPERTY`&&this.onPropertyChange_(e.newValue)),setTimeout(()=>{this.checkWarning_()},0))}},onNodeChange_:function(e){let t=W(e);if(!t){console.assert(!1);return}let n=this.node.id!==t.id;this.node.id=t.id,this.node.key=t.key,this.node.alias=t.alias;let r=this.getField(`PROPERTY`);if(r.getOptions(!1),n){let e=Fn(this.node.id,`write`)?.[0];r.setValue(e?.id??``)}this.onPropertyChange_(r.getValue())},onPropertyChange_:function(e){let t=In(e);if(!t){console.assert(!1);return}this.property.id=t.id,this.property.kind=t.kind,this.property.names=t.names,this.updateShape_(),this.updateShadow_()},updateShape_:function(){let t=!1;switch(this.property.kind){case`multipleRefProperty`:case`multipleCustomSlotProperty`:t=!0}if(t)this.getInput(`INSTANCE`)||this.appendValueInput(`INSTANCE`).setAlign(e.inputs.Align.RIGHT).appendField(`%{BKY_APP_INSTANCE}`).setCheck(`String`);else if(this.getInput(`INSTANCE`)){let e=this.getInput(`INSTANCE`).connection.targetBlock();e&&e.dispose(),this.removeInput(`INSTANCE`)}},updateShadow_:function(){if(this.isInsertionMarker())return;let e=In(this.property.id);if(!e)return;let t=this.getInput(`INSTANCE`);if(t){t.setShadowDom(null);let e=t.connection?.targetBlock();e&&e.dispose(),t.setShadowDom(V(`string`))}let n=this.getInput(`VALUE`);if(n){n.setShadowDom(null);let t=n.connection?.targetBlock();t&&t.dispose(),e.meta.element?n.setCheck(Tt(e.meta.raw)).setShadowDom(Ut(e.meta.raw)):n.setCheck(z(e.meta.raw.type)).setShadowDom(V(e.meta.raw.type))}},checkWarning_:function(){let e=W(this.node.id);if(!e){this.setWarningText(M(`WARN_NODE_NOT_FOUND`));return}if(e.key!==this.node.key){this.setWarningText(M(`WARN_NODE_HAS_CHANGED`));return}e.alias!==this.node.alias&&(this.node.alias=e.alias);let t=In(this.property.id);if(!t){this.setWarningText(M(`WARN_PROPERTY_NOT_FOUND`));return}if(t.kind!==this.property.kind){this.setWarningText(M(`WARN_PROPERTY_HAS_CHANGED`));return}b(t.names,this.property.names)||(this.property.names=t.names),this.setWarningText(null)}};e.Blocks.set_app_property_v1=rr,n.forBlock.set_app_property_v1=function(e){let r=n.quote_,i=e,a=`''`;switch(i.property.kind){case`multipleRefProperty`:case`multipleCustomSlotProperty`:a=n.valueToCode(i,`INSTANCE`,t.NONE)||`''`}let o=n.valueToCode(i,`VALUE`,t.NONE);return`await __setPropertyV1__(${r(i.property.id)}, ${o}, ${a});\n`};const ir={init:function(){this.state={id:``,name:``,type:`string`},this.appendDummyInput().appendField(`%{BKY_APP_V1_GET_APP_STATE_TITLE}`).appendField(new e.FieldDropdown(()=>this.genStateOpts_()),`STATE`),this.setOutput(!0,null),this.setStyle(`state_blocks`),this.setTooltip(`%{BKY_APP_V1_GET_APP_STATE_TOOLTIP}`),this.setHelpUrl(`%{BKY_APP_V1_GET_APP_STATE_HELPURL}`),this.initData_()},initData_:function(){if(this.state.id)return;let e=on()?.[0];if(!e)return;this.state.id=e.id,this.state.name=e.name,this.state.type=e.type;let t=this.getField(`STATE`);t.getOptions(!1),t.setValue(this.state.id)},saveExtraState:function(){return{state:this.state}},loadExtraState:function(e){this.state.id=e.state?.id??``,this.state.name=e.state?.name??``,this.state.type=e.state?.type??`string`,setTimeout(()=>{this.checkWarning_()},0)},genStateOpts_:function(){return cn()},onchange:function(t){if(t.type===e.Events.BLOCK_CHANGE){let e=t;e.blockId===this.id&&e.element===`field`&&e.name===`STATE`&&this.onStateChange_(e.newValue)}},onStateChange_:function(e){let t=sn(e);if(!t){console.assert(!1);return}this.state.id=t.id,this.state.name=t.name,this.state.type=t.type},checkWarning_:function(){let e=sn(this.state.id);if(!e){this.setWarningText(M(`WARN_STATE_NOT_FOUND`));return}if(e.name!==this.state.name&&(this.state.name=e.name),e.type!==this.state.type){this.setWarningText(M(`WARN_STATE_HAS_CHANGED`));return}this.setWarningText(null)}};e.Blocks.get_app_state_v1=ir,n.forBlock.get_app_state_v1=function(e){let r=n.quote_;return[`await __getStateV1__(${r(e.state.id)})`,t.ATOMIC]};const ar={init:function(){this.state={id:``,name:``,type:`string`},this.appendValueInput(`VALUE`).appendField(`%{BKY_APP_V1_SET_APP_STATE_TITLE}`).appendField(new e.FieldDropdown(()=>this.genStateOpts_()),`STATE`),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null),this.setStyle(`state_blocks`),this.setTooltip(`%{BKY_APP_V1_SET_APP_STATE_TOOLTIP}`),this.setHelpUrl(`%{BKY_APP_V1_SET_APP_STATE_HELPURL}`),this.initData_(),this.isInFlyout&&this.updateShadow_()},initData_:function(){if(this.state.id)return;let e=on()?.[0];if(!e)return;this.state.id=e.id,this.state.name=e.name,this.state.type=e.type;let t=this.getField(`STATE`);t.getOptions(!1),t.setValue(this.state.id)},saveExtraState:function(){return{state:this.state}},loadExtraState:function(e){this.state.id=e.state?.id??``,this.state.name=e.state?.name??``,this.state.type=e.state?.type??`string`},genStateOpts_:function(){return cn()},onchange:function(t){if(t.type===e.Events.BLOCK_CHANGE){let e=t;e.blockId===this.id&&e.element===`field`&&e.name===`STATE`&&this.onStateChange_(e.newValue)}},onStateChange_:function(e){let t=sn(e);if(!t){console.assert(!1);return}this.state.id=t.id,this.state.name=t.name,this.state.type=t.type,this.updateShadow_()},updateShadow_:function(){if(this.isInsertionMarker())return;this.getInput(`VALUE`).setShadowDom(null);let e=this.getInput(`VALUE`).connection.targetBlock();e&&e.dispose();let t=z(this.state.type),n=V(this.state.type);this.getInput(`VALUE`).setCheck(t).setShadowDom(n)},checkWarning_:function(){let e=sn(this.state.id);if(!e){this.setWarningText(M(`WARN_STATE_NOT_FOUND`));return}if(e.name!==this.state.name&&(this.state.name=e.name),e.type!==this.state.type){this.setWarningText(M(`WARN_STATE_HAS_CHANGED`));return}this.setWarningText(null)}};e.Blocks.set_app_state_v1=ar,n.forBlock.set_app_state_v1=function(e){let r=n.quote_,i=e,a=n.valueToCode(i,`VALUE`,t.NONE);return`await __setStateV1__(${r(i.state.id)}, ${a});\n`},e.defineBlocksWithJsonArray([{type:`color_blend_v1`,message0:`%{BKY_COLOR_V1_BLEND_TITLE}`,args0:[{type:`input_value`,name:`COLOR1`,check:`Color`,align:`RIGHT`},{type:`input_value`,name:`COLOR2`,check:`Color`,align:`RIGHT`},{type:`input_value`,name:`RATIO`,check:`Number`,align:`RIGHT`}],output:`Color`,style:`color_blocks`,tooltip:`%{BKY_COLOR_V1_BLEND_TOOLTIP}`,helpUrl:`%{BKY_COLOR_V1_BLEND_HELPURL}`}]),n.forBlock.color_blend_v1=function(e){let r=n.valueToCode(e,`COLOR1`,t.NONE)||`'#ffffff'`,i=n.valueToCode(e,`COLOR2`,t.NONE)||`'#000000'`,a=n.valueToCode(e,`RATIO`,t.NONE)||.5;return[`${n.provideFunction_(`colorBlend`,`
|
|
34
|
-
function ${
|
|
33
|
+
`},x.set_app_method_output_v1={init:function(){this.node={id:``,key:``,alias:``},this.method={id:``,kind:``,names:[]},this.output={key:``,name:``,type:`string`},this.appendValueInput(`VALUE`).appendField(`%{BKY_APP_V1_SET_APP_METHOD_OUTPUT_TITLE}`).appendField(new C(()=>this.genNodeOpts_()),`NODE`).appendField(new C(()=>this.genMethodOpts_()),`METHOD`).appendField(new C(()=>this.genOutputOpts_()),`OUTPUT`),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null),this.setStyle(`procedure_blocks`),this.setTooltip(`%{BKY_APP_V1_SET_APP_METHOD_OUTPUT_TOOLTIP}`),this.setHelpUrl(`%{BKY_APP_V1_SET_APP_METHOD_OUTPUT_HELPURL}`),this.initData_(),this.updateShape_(),this.updateShadows_()},initData_:function(){if(this.node.id)return;let e=Fn(`implementMethod`)?.[0];if(!e)return;this.node.id=e.id,this.node.key=e.key,this.node.alias=e.alias;let t=this.getField(`NODE`);t.getOptions(!1),t.setValue(this.node.id);let n=rr(this.node.id)?.[0];if(!n)return;this.method.id=n.id,this.method.kind=n.kind,this.method.names=n.names;let r=this.getField(`METHOD`);r.getOptions(!1),r.setValue(this.method.id);let i=or(this.method.id)?.[0];if(!i)return;this.output.key=i.key,this.output.name=i.name,this.output.type=i.type;let a=this.getField(`OUTPUT`);a.getOptions(!1),a.setValue(this.output.key)},saveExtraState:function(){return{node:this.node,method:this.method,output:this.output}},loadExtraState:function(e){this.node.id=e.node?.id??``,this.node.key=e.node?.key??``,this.node.alias=e.node?.alias??``,this.method.id=e.method?.id??``,this.method.kind=e.method?.kind??``,this.method.names=e.method?.names??[],this.output.key=e.output?.key??``,this.output.name=e.output?.name??``,this.output.type=e.output?.type??``,this.updateShape_(),this.updateShadows_(),setTimeout(()=>{this.checkWarning_()},0)},genNodeOpts_:function(){return In(`implementMethod`)},genMethodOpts_:function(){return ar(this.node.id)},genOutputOpts_:function(){return cr(this.method.id)},onchange:function(e){if(e.type===b.BLOCK_CHANGE){let t=e;t.blockId===this.id&&(t.element===`field`&&(t.name===`NODE`?this.onNodeChange_(t.newValue):t.name===`METHOD`?this.onMethodChange_(t.newValue):t.name===`OUTPUT`&&this.onOutputChange_(t.newValue)),setTimeout(()=>{this.checkWarning_()},0))}},onNodeChange_:function(e){let t=G(e);if(!t){console.assert(!1);return}let n=this.node.id!==t.id;this.node.id=t.id,this.node.key=t.key,this.node.alias=t.alias;let r=this.getField(`METHOD`);if(r.getOptions(!1),n){let e=rr(this.node.id)?.[0];r.setValue(e?.id??``)}r.setValue(r.getValue())},onMethodChange_:function(e){let t=ir(e);if(!t){console.assert(!1);return}let n=this.method.id!==t.id;this.method.id=t.id,this.method.kind=t.kind,this.method.names=t.names;let r=this.getField(`OUTPUT`);if(r.getOptions(!1),n||!sr(this.method.id,this.output.key)){let e=or(this.method.id)?.[0];r.setValue(e?.key??``)}this.onOutputChange_(r.getValue())},onOutputChange_:function(e){let t=sr(this.method.id,e);if(!t){console.assert(!1);return}this.output.key=t.key,this.output.name=t.name,this.output.type=t.type},updateShape_:function(){let e=this.getInput(`VALUE`);e.connection.setShadowDom(null);let t=e.connection.targetBlock();t&&!t.isShadow()&&t.dispose();let n=V(this.output.type);e.setCheck(n)},updateShadows_:function(){if(this.isInsertionMarker())return;let e=U(this.output.type);this.getInput(`VALUE`).connection.setShadowDom(e)},checkWarning_:function(){let e=G(this.node.id);if(!e){this.setWarningText(I(`WARN_NODE_NOT_FOUND`));return}if(e.key!==this.node.key){this.setWarningText(I(`WARN_NODE_HAS_CHANGED`));return}e.alias!==this.node.alias&&(this.node.alias=e.alias);let t=ir(this.method.id);if(!t){this.setWarningText(I(`WARN_METHOD_NOT_FOUND`));return}if(t.kind!==this.method.kind){this.setWarningText(I(`WARN_METHOD_HAS_CHANGED`));return}t.names!==this.method.names&&(this.method.names=t.names);let n=sr(this.method.id,this.output.key);if(!n){this.setWarningText(I(`WARN_OUTPUT_NOT_FOUND`));return}if(n.name!==this.output.name&&(this.output.name=n.name),n.type!==this.output.type){this.setWarningText(I(`WARN_OUTPUT_HAS_CHANGED`));return}this.setWarningText(null)}},y.forBlock.set_app_method_output_v1=function(e){let t=y.quote_,n=e,r=y.valueToCode(n,`VALUE`,v.ATOMIC);if(r===void 0)switch(n.output.type){case`string`:r=`''`;break;case`number`:r=`0`;break;case`boolean`:r=`false`;break;case`array`:r=`[]`;break;case`object`:r=`{}`;break;default:r=`null`}return`__outputs__[${t(n.output.key)}] = ${r};\n`},a([{type:`app_env_is_v1`,message0:`%{BKY_APP_V1_APP_ENV_IS_TITLE}`,args0:[{type:`field_dropdown`,name:`ENV`,options:[[`%{BKY_APP_ENV_DEV}`,`dev`],[`%{BKY_APP_ENV_PROD}`,`prod`]]}],output:`Boolean`,style:`logic_blocks`,tooltip:`%{BKY_APP_V1_APP_ENV_IS_TOOLTIP}`,helpUrl:`%{BKY_APP_V1_APP_ENV_IS_HELPURL}`}]),y.forBlock.app_env_is_v1=function(e){return[`__getEnvV1__() === ${y.quote_(e.getFieldValue(`ENV`))}`,v.ATOMIC]},x.navigate_to_v1={init:function(){this.app={id:``,name:``},this.page={id:``,name:``},this.appendDummyInput().appendField(`%{BKY_APP_V1_NAVIGATE_TO_TITLE}`).appendField(new C(()=>this.genAppOpts_()),`APP`).appendField(new C(()=>this.genPageOpts_()),`PAGE`),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null),this.setStyle(`procedure_blocks`),this.setTooltip(`%{BKY_APP_V1_NAVIGATE_TOOLTIP}`),this.setHelpUrl(`%{BKY_APP_V1_NAVIGATE_HELPURL}`),this.initData_()},initData_:function(){if(this.app.id)return;let e=Dn()?.[0];if(!e)return;this.app.id=e.id,this.app.name=e.name;let t=this.getField(`APP`);t.getOptions(!1),t.setValue(this.app.id);let n=lr(this.app.id)?.[0];if(!n)return;this.page.id=n.id,this.page.name=n.name;let r=this.getField(`PAGE`);r.getOptions(!1),r.setValue(this.page.id)},saveExtraState:function(){return{app:this.app,page:this.page}},loadExtraState:function(e){this.app.id=e.app?.id??``,this.app.name=e.app?.name??``,this.page.id=e.page?.id??``,this.page.name=e.page?.name??``,setTimeout(()=>{this.checkWarning_()},0)},genAppOpts_:function(){return kn()},genPageOpts_:function(){return dr(this.app.id)},onchange:function(e){if(e.type===b.BLOCK_CHANGE){let t=e;t.blockId===this.id&&(t.element===`field`&&(t.name===`APP`?this.onAppChange_(t.newValue):t.name===`PAGE`&&this.onPageChange_(t.newValue)),setTimeout(()=>{this.checkWarning_()},0))}},onAppChange_:function(e){let t=On(e);if(!t){console.assert(!1);return}let n=this.app.id!==t.id;this.app.id=t.id,this.app.name=t.name;let r=this.getField(`PAGE`);if(r.getOptions(!1),n){let e=lr(this.app.id)?.[0];r.setValue(e?.id??``)}this.onPageChange_(r.getValue())},onPageChange_:function(e){let t=ur(this.app.id,e);if(!t){console.assert(!1);return}this.page.id=t.id,this.page.name=t.name},checkWarning_:function(){let e=On(this.app.id);if(!e){this.setWarningText(I(`WARN_APP_NOT_FOUND`));return}e.name!==this.app.name&&(this.app.name=e.name);let t=ur(this.app.id,this.page.id);if(!t){this.setWarningText(I(`WARN_PAGE_NOT_FOUND`));return}t.name!==this.page.name&&(this.page.name=t.name),this.setWarningText(null)}},y.forBlock.navigate_to_v1=function(e){let t=e;return`__navigateToV1__(${y.quote_(t.app.id)}, ${y.quote_(t.page.id)});\n`},x.select_comp_v1={init:function(){this.comp={id:``,name:``},this.appendDummyInput().appendField(`%{BKY_APP_V1_SELECT_COMP_TITLE}`).appendField(new C(()=>this.genCompOpts_()),`COMP`),this.setOutput(!0,`Comp`),this.setStyle(`property_blocks`),this.setTooltip(`%{BKY_APP_V1_SELECT_COMP_TOOLTIP}`),this.setHelpUrl(`%{BKY_APP_V1_SELECT_COMP_HELPURL}`),this.initData_()},initData_:function(){if(this.comp.id)return;let e=Hn()?.[0];if(!e)return;this.comp.id=e.id,this.comp.name=e.name;let t=this.getField(`COMP`);t.getOptions(!1),t.setValue(this.comp.id)},saveExtraState:function(){return{comp:this.comp}},loadExtraState:function(e){this.comp.id=e.comp?.id??``,this.comp.name=e.comp?.name??``,setTimeout(()=>{this.checkWarning_()},0)},genCompOpts_:function(){return Wn()},onchange:function(e){if(e.type===b.BLOCK_CHANGE){let t=e;t.blockId===this.id&&(t.element===`field`&&t.name===`COMP`&&this.onCompChange_(t.newValue),setTimeout(()=>{this.checkWarning_()},0))}},onCompChange_:function(e){let t=Un(e);if(!t){console.assert(!1);return}this.comp.id=t.id,this.comp.name=t.name},checkWarning_:function(){let e=Un(this.comp.id);if(!e){this.setWarningText(I(`WARN_COMP_NOT_FOUND`));return}e.name!==this.comp.name&&(this.comp.name=e.name),this.setWarningText(null)}},y.forBlock.select_comp_v1=function(e){let t=y.quote_,n=e,r=n.comp.id,i=n.comp.name;return[`{id:${t(r)},name:${t(i)}}`,v.ATOMIC]},x.select_slot_v1={init:function(){this.slot={id:``,name:``},this.appendDummyInput().appendField(`%{BKY_APP_V1_SELECT_SLOT_TITLE}`).appendField(new C(()=>this.genSlotOpts_()),`SLOT`),this.setOutput(!0,`Slot`),this.setStyle(`property_blocks`),this.setTooltip(`%{BKY_APP_V1_SELECT_SLOT_TOOLTIP}`),this.setHelpUrl(`%{BKY_APP_V1_SELECT_SLOT_HELPURL}`),this.initData_()},initData_:function(){if(this.slot.id)return;let e=hr()?.[0];if(!e)return;this.slot.id=e.id,this.slot.name=e.name;let t=this.getField(`SLOT`);t.getOptions(!1),t.setValue(this.slot.id)},saveExtraState:function(){return{slot:this.slot}},loadExtraState:function(e){this.slot.id=e.slot?.id??``,this.slot.name=e.slot?.name??``,setTimeout(()=>{this.checkWarning_()},0)},genSlotOpts_:function(){return _r()},onchange:function(e){if(e.type===b.BLOCK_CHANGE){let t=e;t.blockId===this.id&&(t.element===`field`&&t.name===`SLOT`&&this.onSlotChange_(t.newValue),setTimeout(()=>{this.checkWarning_()},0))}},onSlotChange_:function(e){let t=gr(e);if(!t){console.assert(!1);return}this.slot.id=t.id,this.slot.name=t.name},checkWarning_:function(){let e=gr(this.slot.id);if(!e){this.setWarningText(I(`WARN_SLOT_NOT_FOUND`));return}e.name!==this.slot.name&&(this.slot.name=e.name),this.setWarningText(null)}},y.forBlock.select_slot_v1=function(e){let t=y.quote_,n=e,r=n.slot.id,i=n.slot.name;return[`{id:${t(r)},name:${t(i)}}`,v.ATOMIC]},x.get_app_property_v1={init:function(){this.node={id:``,key:``,alias:``},this.property={id:``,kind:``,names:[]},this.appendDummyInput().appendField(`%{BKY_APP_V1_GET_APP_PROPERTY_TITLE}`).appendField(new C(()=>this.genNodeOpts_()),`NODE`).appendField(new C(()=>this.genPropertyOpts_()),`PROPERTY`),this.setOutput(!0,null),this.setInputsInline(!0),this.setStyle(`property_blocks`),this.setTooltip(`%{BKY_APP_V1_GET_APP_PROPERTY_TOOLTIP}`),this.setHelpUrl(`%{BKY_APP_V1_GET_APP_PROPERTY_HELPURL}`),this.initData_(),this.updateShape_()},initData_:function(){if(this.node.id)return;let e=Fn(`getProperty`)?.[0];if(!e)return;this.node.id=e.id,this.node.key=e.key,this.node.alias=e.alias;let t=this.getField(`NODE`);t.getOptions(!1),t.setValue(this.node.id);let n=fr(this.node.id,`read`)?.[0];if(!n)return;this.property.id=n.id,this.property.kind=n.kind,this.property.names=n.names;let r=this.getField(`PROPERTY`);r.getOptions(!1),r.setValue(this.property.id)},saveExtraState:function(){return{node:this.node,property:this.property}},loadExtraState:function(e){this.node.id=e.node?.id??``,this.node.key=e.node?.key??``,this.node.alias=e.node?.alias??``,this.property.id=e.property?.id??``,this.property.kind=e.property?.kind??``,this.property.names=e.property?.names??[],this.updateShape_(),setTimeout(()=>{this.checkWarning_()},0)},genNodeOpts_:function(){return In(`getProperty`)},genPropertyOpts_:function(){return mr(this.node.id,`read`)},onchange:function(e){if(e.type===b.BLOCK_CHANGE){let t=e;t.blockId===this.id&&(t.element===`field`&&(t.name===`NODE`?this.onNodeChange_(t.newValue):t.name===`PROPERTY`&&this.onPropertyChange_(t.newValue)),setTimeout(()=>{this.checkWarning_()},0))}},onNodeChange_:function(e){let t=G(e);if(!t){console.assert(!1);return}let n=this.node.id!==t.id;this.node.id=t.id,this.node.key=t.key,this.node.alias=t.alias;let r=this.getField(`PROPERTY`);if(r.getOptions(!1),n){let e=fr(this.node.id,`read`)?.[0];r.setValue(e?.id??``)}this.onPropertyChange_(r.getValue())},onPropertyChange_:function(e){let t=pr(e);if(!t){console.assert(!1);return}this.property.id=t.id,this.property.kind=t.kind,this.property.names=t.names,this.updateShape_(),this.updateShadow_()},updateShape_:function(){let e=!1;switch(this.property.kind){case`multipleRefProperty`:case`multipleCustomSlotProperty`:e=!0}if(e)this.getInput(`INSTANCE`)||this.appendValueInput(`INSTANCE`).setAlign(m.Align.RIGHT).appendField(`%{BKY_APP_INSTANCE}`).setCheck(`String`);else if(this.getInput(`INSTANCE`)){let e=this.getInput(`INSTANCE`).connection.targetBlock();e&&e.dispose(),this.removeInput(`INSTANCE`)}},updateShadow_:function(){if(this.isInsertionMarker())return;let e=this.getInput(`INSTANCE`);if(e){e.setShadowDom(null);let t=e.connection?.targetBlock();t&&t.dispose(),e.setShadowDom(U(`string`))}},checkWarning_:function(){let e=G(this.node.id);if(!e){this.setWarningText(I(`WARN_NODE_NOT_FOUND`));return}if(e.key!==this.node.key){this.setWarningText(I(`WARN_NODE_HAS_CHANGED`));return}e.alias!==this.node.alias&&(this.node.alias=e.alias);let t=pr(this.property.id);if(!t){this.setWarningText(I(`WARN_PROPERTY_NOT_FOUND`));return}if(t.kind!==this.property.kind){this.setWarningText(I(`WARN_PROPERTY_HAS_CHANGED`));return}_(t.names,this.property.names)||(this.property.names=t.names),this.setWarningText(null)}},y.forBlock.get_app_property_v1=function(e){let t=y.quote_,n=e,r=`''`;return n.getInput(`INSTANCE`)&&(r=y.valueToCode(n,`INSTANCE`,v.NONE)||`''`),[`__getPropertyV1__(${t(n.property.id)}, ${r})`,v.ATOMIC]},x.set_app_property_v1={init:function(){this.node={id:``,key:``,alias:``},this.property={id:``,kind:``,names:[]},this.appendValueInput(`VALUE`).appendField(`%{BKY_APP_V1_SET_APP_PROPERTY_TITLE}`).appendField(new C(()=>this.genNodeOpts_()),`NODE`).appendField(new C(()=>this.genPropertyOpts_()),`PROPERTY`),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null),this.setInputsInline(!0),this.setStyle(`property_blocks`),this.setTooltip(`%{BKY_APP_V1_SET_APP_PROPERTY_TOOLTIP}`),this.setHelpUrl(`%{BKY_APP_V1_SET_APP_PROPERTY_HELPURL}`),this.initData_(),this.updateShape_(),this.isInFlyout&&this.updateShadow_()},initData_:function(){if(this.node.id)return;let e=Fn(`setProperty`)?.[0];if(!e)return;this.node.id=e.id,this.node.key=e.key,this.node.alias=e.alias;let t=this.getField(`NODE`);t.getOptions(!1),t.setValue(this.node.id);let n=fr(this.node.id,`write`)?.[0];if(!n)return;this.property.id=n.id,this.property.kind=n.kind,this.property.names=n.names;let r=this.getField(`PROPERTY`);r.getOptions(!1),r.setValue(this.property.id)},saveExtraState:function(){return{node:this.node,property:this.property}},loadExtraState:function(e){this.node.id=e.node?.id??``,this.node.key=e.node?.key??``,this.node.alias=e.node?.alias??``,this.property.id=e.property?.id??``,this.property.kind=e.property?.kind??``,this.property.names=e.property?.names??[],this.updateShape_(),setTimeout(()=>{this.checkWarning_()},0)},genNodeOpts_:function(){return In(`setProperty`)},genPropertyOpts_:function(){return mr(this.node.id,`write`)},onchange:function(e){if(e.type===b.BLOCK_CHANGE){let t=e;t.blockId===this.id&&(t.element===`field`&&(t.name===`NODE`?this.onNodeChange_(t.newValue):t.name===`PROPERTY`&&this.onPropertyChange_(t.newValue)),setTimeout(()=>{this.checkWarning_()},0))}},onNodeChange_:function(e){let t=G(e);if(!t){console.assert(!1);return}let n=this.node.id!==t.id;this.node.id=t.id,this.node.key=t.key,this.node.alias=t.alias;let r=this.getField(`PROPERTY`);if(r.getOptions(!1),n){let e=fr(this.node.id,`write`)?.[0];r.setValue(e?.id??``)}this.onPropertyChange_(r.getValue())},onPropertyChange_:function(e){let t=pr(e);if(!t){console.assert(!1);return}this.property.id=t.id,this.property.kind=t.kind,this.property.names=t.names,this.updateShape_(),this.updateShadow_()},updateShape_:function(){let e=!1;switch(this.property.kind){case`multipleRefProperty`:case`multipleCustomSlotProperty`:e=!0}if(e)this.getInput(`INSTANCE`)||this.appendValueInput(`INSTANCE`).setAlign(m.Align.RIGHT).appendField(`%{BKY_APP_INSTANCE}`).setCheck(`String`);else if(this.getInput(`INSTANCE`)){let e=this.getInput(`INSTANCE`).connection.targetBlock();e&&e.dispose(),this.removeInput(`INSTANCE`)}},updateShadow_:function(){if(this.isInsertionMarker())return;let e=pr(this.property.id);if(!e)return;let t=this.getInput(`INSTANCE`);if(t){t.setShadowDom(null);let e=t.connection?.targetBlock();e&&e.dispose(),t.setShadowDom(U(`string`))}let n=this.getInput(`VALUE`);if(n){n.setShadowDom(null);let t=n.connection?.targetBlock();t&&t.dispose(),e.meta.element?n.setCheck(nn(e.meta.raw)).setShadowDom(bn(e.meta.raw)):n.setCheck(V(e.meta.raw.type)).setShadowDom(U(e.meta.raw.type))}},checkWarning_:function(){let e=G(this.node.id);if(!e){this.setWarningText(I(`WARN_NODE_NOT_FOUND`));return}if(e.key!==this.node.key){this.setWarningText(I(`WARN_NODE_HAS_CHANGED`));return}e.alias!==this.node.alias&&(this.node.alias=e.alias);let t=pr(this.property.id);if(!t){this.setWarningText(I(`WARN_PROPERTY_NOT_FOUND`));return}if(t.kind!==this.property.kind){this.setWarningText(I(`WARN_PROPERTY_HAS_CHANGED`));return}_(t.names,this.property.names)||(this.property.names=t.names),this.setWarningText(null)}},y.forBlock.set_app_property_v1=function(e){let t=y.quote_,n=e,r=`''`;switch(n.property.kind){case`multipleRefProperty`:case`multipleCustomSlotProperty`:r=y.valueToCode(n,`INSTANCE`,v.NONE)||`''`}let i=y.valueToCode(n,`VALUE`,v.NONE);return`await __setPropertyV1__(${t(n.property.id)}, ${i}, ${r});\n`},x.get_app_state_v1={init:function(){this.state={id:``,name:``,type:`string`},this.appendDummyInput().appendField(`%{BKY_APP_V1_GET_APP_STATE_TITLE}`).appendField(new C(()=>this.genStateOpts_()),`STATE`),this.setOutput(!0,null),this.setStyle(`state_blocks`),this.setTooltip(`%{BKY_APP_V1_GET_APP_STATE_TOOLTIP}`),this.setHelpUrl(`%{BKY_APP_V1_GET_APP_STATE_HELPURL}`),this.initData_()},initData_:function(){if(this.state.id)return;let e=Ln()?.[0];if(!e)return;this.state.id=e.id,this.state.name=e.name,this.state.type=e.type;let t=this.getField(`STATE`);t.getOptions(!1),t.setValue(this.state.id)},saveExtraState:function(){return{state:this.state}},loadExtraState:function(e){this.state.id=e.state?.id??``,this.state.name=e.state?.name??``,this.state.type=e.state?.type??`string`,setTimeout(()=>{this.checkWarning_()},0)},genStateOpts_:function(){return zn()},onchange:function(e){if(e.type===b.BLOCK_CHANGE){let t=e;t.blockId===this.id&&t.element===`field`&&t.name===`STATE`&&this.onStateChange_(t.newValue)}},onStateChange_:function(e){let t=Rn(e);if(!t){console.assert(!1);return}this.state.id=t.id,this.state.name=t.name,this.state.type=t.type},checkWarning_:function(){let e=Rn(this.state.id);if(!e){this.setWarningText(I(`WARN_STATE_NOT_FOUND`));return}if(e.name!==this.state.name&&(this.state.name=e.name),e.type!==this.state.type){this.setWarningText(I(`WARN_STATE_HAS_CHANGED`));return}this.setWarningText(null)}},y.forBlock.get_app_state_v1=function(e){let t=y.quote_;return[`await __getStateV1__(${t(e.state.id)})`,v.ATOMIC]},x.set_app_state_v1={init:function(){this.state={id:``,name:``,type:`string`},this.appendValueInput(`VALUE`).appendField(`%{BKY_APP_V1_SET_APP_STATE_TITLE}`).appendField(new C(()=>this.genStateOpts_()),`STATE`),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null),this.setStyle(`state_blocks`),this.setTooltip(`%{BKY_APP_V1_SET_APP_STATE_TOOLTIP}`),this.setHelpUrl(`%{BKY_APP_V1_SET_APP_STATE_HELPURL}`),this.initData_(),this.isInFlyout&&this.updateShadow_()},initData_:function(){if(this.state.id)return;let e=Ln()?.[0];if(!e)return;this.state.id=e.id,this.state.name=e.name,this.state.type=e.type;let t=this.getField(`STATE`);t.getOptions(!1),t.setValue(this.state.id)},saveExtraState:function(){return{state:this.state}},loadExtraState:function(e){this.state.id=e.state?.id??``,this.state.name=e.state?.name??``,this.state.type=e.state?.type??`string`},genStateOpts_:function(){return zn()},onchange:function(e){if(e.type===b.BLOCK_CHANGE){let t=e;t.blockId===this.id&&t.element===`field`&&t.name===`STATE`&&this.onStateChange_(t.newValue)}},onStateChange_:function(e){let t=Rn(e);if(!t){console.assert(!1);return}this.state.id=t.id,this.state.name=t.name,this.state.type=t.type,this.updateShadow_()},updateShadow_:function(){if(this.isInsertionMarker())return;this.getInput(`VALUE`).setShadowDom(null);let e=this.getInput(`VALUE`).connection.targetBlock();e&&e.dispose();let t=V(this.state.type),n=U(this.state.type);this.getInput(`VALUE`).setCheck(t).setShadowDom(n)},checkWarning_:function(){let e=Rn(this.state.id);if(!e){this.setWarningText(I(`WARN_STATE_NOT_FOUND`));return}if(e.name!==this.state.name&&(this.state.name=e.name),e.type!==this.state.type){this.setWarningText(I(`WARN_STATE_HAS_CHANGED`));return}this.setWarningText(null)}},y.forBlock.set_app_state_v1=function(e){let t=y.quote_,n=e,r=y.valueToCode(n,`VALUE`,v.NONE);return`await __setStateV1__(${t(n.state.id)}, ${r});\n`},a([{type:`color_blend_v1`,message0:`%{BKY_COLOR_V1_BLEND_TITLE}`,args0:[{type:`input_value`,name:`COLOR1`,check:`Color`,align:`RIGHT`},{type:`input_value`,name:`COLOR2`,check:`Color`,align:`RIGHT`},{type:`input_value`,name:`RATIO`,check:`Number`,align:`RIGHT`}],output:`Color`,style:`color_blocks`,tooltip:`%{BKY_COLOR_V1_BLEND_TOOLTIP}`,helpUrl:`%{BKY_COLOR_V1_BLEND_HELPURL}`}]),y.forBlock.color_blend_v1=function(e){let t=y.valueToCode(e,`COLOR1`,v.NONE)||`'#ffffff'`,n=y.valueToCode(e,`COLOR2`,v.NONE)||`'#000000'`,r=y.valueToCode(e,`RATIO`,v.NONE)||.5;return[`${y.provideFunction_(`colorBlend`,`
|
|
34
|
+
function ${y.FUNCTION_NAME_PLACEHOLDER_}(c1, c2, ratio) {
|
|
35
35
|
ratio = Math.max(Math.min(ratio, 1), 0);
|
|
36
36
|
var r1 = parseInt(c1.substring(1, 3), 16);
|
|
37
37
|
var g1 = parseInt(c1.substring(3, 5), 16);
|
|
@@ -47,13 +47,13 @@ function ${n.FUNCTION_NAME_PLACEHOLDER_}(c1, c2, ratio) {
|
|
|
47
47
|
b = ('0' + (b || 0).toString(16)).slice(-2);
|
|
48
48
|
return '#' + r + g + b;
|
|
49
49
|
}
|
|
50
|
-
`)}(${
|
|
51
|
-
function ${
|
|
50
|
+
`)}(${t}, ${n}, ${r})`,v.FUNCTION_CALL]},a([{type:`color_picker_v1`,message0:`%1`,args0:[{type:`field_colour`,name:`COLOR`,colour:`#ff0000`,colourOptions:an,columns:14}],output:`Color`,style:`color_blocks`,tooltip:`%{BKY_COLOR_V1_PICKER_TOOLTIP}`,helpUrl:`%{BKY_COLOR_V1_PICKER_HELPURL}`}]),y.forBlock.color_picker_v1=function(e){return[y.quote_(e.getFieldValue(`COLOR`)),v.ATOMIC]},a([{type:`color_random_v1`,message0:`%{BKY_COLOR_V1_RANDOM_TITLE}`,output:`Color`,style:`color_blocks`,tooltip:`%{BKY_COLOR_V1_RANDOM_TOOLTIP}`,helpUrl:`%{BKY_COLOR_V1_RANDOM_HELPURL}`}]),y.forBlock.color_random_v1=function(){return[`${y.provideFunction_(`colorRandom`,`
|
|
51
|
+
function ${y.FUNCTION_NAME_PLACEHOLDER_}() {
|
|
52
52
|
var num = Math.floor(Math.random() * Math.pow(2, 24));
|
|
53
53
|
return '#' + ('00000' + num.toString(16)).substr(-6);
|
|
54
54
|
}
|
|
55
|
-
`)}()`,
|
|
56
|
-
function ${
|
|
55
|
+
`)}()`,v.FUNCTION_CALL]},a([{type:`color_rgb_v1`,message0:`%{BKY_COLOR_V1_RGB_TITLE}`,args0:[{type:`input_value`,name:`RED`,check:`Number`,align:`RIGHT`},{type:`input_value`,name:`GREEN`,check:`Number`,align:`RIGHT`},{type:`input_value`,name:`BLUE`,check:`Number`,align:`RIGHT`}],output:`Color`,style:`color_blocks`,tooltip:`%{BKY_COLOR_V1_RGB_TOOLTIP}`,helpUrl:`%{BKY_COLOR_V1_RGB_HELPURL}`}]),y.forBlock.color_rgb_v1=function(e){let t=y.valueToCode(e,`RED`,v.NONE)||0,n=y.valueToCode(e,`GREEN`,v.NONE)||0,r=y.valueToCode(e,`BLUE`,v.NONE)||0;return[`${y.provideFunction_(`colorRgb`,`
|
|
56
|
+
function ${y.FUNCTION_NAME_PLACEHOLDER_}(r, g, b) {
|
|
57
57
|
r = Math.max(Math.min(r, 100), 0) * 2.55;
|
|
58
58
|
g = Math.max(Math.min(g, 100), 0) * 2.55;
|
|
59
59
|
b = Math.max(Math.min(b, 100), 0) * 2.55;
|
|
@@ -62,113 +62,113 @@ function ${n.FUNCTION_NAME_PLACEHOLDER_}(r, g, b) {
|
|
|
62
62
|
b = ('0' + (Math.round(b) || 0).toString(16)).slice(-2);
|
|
63
63
|
return '#' + r + g + b;
|
|
64
64
|
}
|
|
65
|
-
`)}(${
|
|
66
|
-
`};function
|
|
67
|
-
${
|
|
68
|
-
${
|
|
69
|
-
${
|
|
70
|
-
`}
|
|
71
|
-
${
|
|
72
|
-
${
|
|
73
|
-
${
|
|
74
|
-
${
|
|
75
|
-
${
|
|
76
|
-
${
|
|
77
|
-
`}
|
|
78
|
-
${
|
|
79
|
-
${
|
|
80
|
-
${
|
|
81
|
-
${
|
|
82
|
-
${
|
|
83
|
-
${
|
|
84
|
-
${
|
|
85
|
-
${
|
|
86
|
-
${
|
|
87
|
-
${
|
|
88
|
-
${
|
|
89
|
-
`}
|
|
90
|
-
${
|
|
91
|
-
${
|
|
92
|
-
${
|
|
93
|
-
${
|
|
94
|
-
${
|
|
95
|
-
${
|
|
96
|
-
${
|
|
97
|
-
${
|
|
98
|
-
${
|
|
99
|
-
${
|
|
100
|
-
`},
|
|
101
|
-
${
|
|
102
|
-
${
|
|
103
|
-
${
|
|
104
|
-
${
|
|
105
|
-
${
|
|
106
|
-
${
|
|
107
|
-
${
|
|
108
|
-
${
|
|
109
|
-
${
|
|
110
|
-
${
|
|
111
|
-
${
|
|
112
|
-
${
|
|
113
|
-
${
|
|
114
|
-
`},e.defineBlocksWithJsonArray([{type:`query_extra_limit_v1`,message0:`%{BKY_DATA_V1_QUERY_EXTRA_LIMIT_TITLE}`,args0:[{type:`input_value`,name:`OFFSET`,check:`Number`},{type:`input_value`,name:`LIMIT`,check:`Number`}],inputsInline:!0,output:`QueryExtra`,style:`object_blocks`,tooltip:`%{BKY_DATA_V1_QUERY_EXTRA_LIMIT_TOOLTIP}`,helpUrl:`%{BKY_DATA_V1_QUERY_EXTRA_LIMIT_HELPURL}`}]),n.forBlock.query_extra_limit_v1=function(e){return[`{type:'limit',value:${n.valueToCode(e,`OFFSET`,t.ATOMIC)||0},value2:${n.valueToCode(e,`LIMIT`,t.ATOMIC)||0}}`,t.ATOMIC]},e.defineBlocksWithJsonArray([{type:`query_extra_sortby_v1`,message0:`%{BKY_DATA_V1_QUERY_EXTRA_SORTBY_TITLE}`,args0:[{type:`input_value`,name:`COLUMN`,check:`String`},{type:`input_value`,name:`DESC`,check:`Boolean`}],inputsInline:!0,output:`QueryExtra`,style:`object_blocks`,tooltip:`%{BKY_DATA_V1_QUERY_EXTRA_SORTBY_TOOLTIP}`,helpUrl:`%{BKY_DATA_V1_QUERY_EXTRA_SORTBY_HELPURL}`}]),n.forBlock.query_extra_sortby_v1=function(e){return[`{type:'sortby',value:${n.valueToCode(e,`COLUMN`,t.ATOMIC)||`''`},value2:${n.valueToCode(e,`DESC`,t.ATOMIC)||!1}}`,t.ATOMIC]};const Ur={init:function(){this.appendDummyInput().appendField(`%{BKY_DATA_LIST}`),this.appendStatementInput(`STACK`),this.setStyle(`object_blocks`),this.contextMenu=!1}};e.Blocks.select_column_container_v1=Ur;const Wr={init:function(){this.appendDummyInput().appendField(`%{BKY_DATA_ITEM}`),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setStyle(`object_blocks`),this.contextMenu=!1}};e.Blocks.select_column_item_v1=Wr;const Gr={init:function(){this.space={id:``,name:``},this.table={id:``,name:``,columns:[]},this.itemCount_=0,this.appendDummyInput().appendField(`%{BKY_DATA_V1_SELECT_COLUMN_TITLE}`).appendField(new e.FieldDropdown(()=>this.genSpaceOpts_()),`SPACE`).appendField(new e.FieldDropdown(()=>this.genTableOpts_()),`TABLE`),this.setMutator(new e.icons.MutatorIcon([`select_column_item_v1`],this)),this.setOutput(!0,`SelectColumn`),this.setStyle(`object_blocks`),this.setTooltip(`%{BKY_DATA_V1_SELECT_COLUMN_TOOLTIP}`),this.setHelpUrl(`%{BKY_DATA_V1_SELECT_COLUMN_HELPURL}`),this.initData_(),this.initShape_()},initData_:function(){if(this.space.id)return;let e=Y()?.[0];if(!e)return;this.space.id=e.id,this.space.name=e.name;let t=this.getField(`SPACE`);t.getOptions(!1),t.setValue(this.space.id,!1);let n=X(this.space.id)?.[0];if(!n)return;this.table.id=n.id,this.table.name=n.name,this.table.columns=n.columns;let r=this.getField(`TABLE`);r.getOptions(!1),r.setValue(this.table.id,!1),this.itemCount_=n.columns.length},saveExtraState:function(){return{space:this.space,table:this.table,itemCount:this.itemCount_}},loadExtraState:function(e){this.space.id=e.space?.id??``,this.space.name=e.space?.name??``,this.table.id=e.table?.id??``,this.table.name=e.table?.name??``,this.table.columns=e.table?.columns??[],this.itemCount_=e.itemCount??0,this.updateShape_(),setTimeout(()=>{this.checkWarning_()},0)},genSpaceOpts_:function(){return xr()},genTableOpts_:function(){return Cr(this.space.id)},genColumnOpts_:function(){let e=[];return this.table.columns.forEach(({id:t,name:n})=>{e.push([n,t])}),N(e)},onchange:function(t){if(t.type===e.Events.BLOCK_CHANGE){let e=t;if(e.blockId===this.id){if(e.element===`field`){if(e.name===`SPACE`)this.onSpaceChange_(e.newValue);else if(e.name===`TABLE`)this.onTableChange_(e.newValue);else if(e.name?.startsWith(`COLUMN`)){let t=parseInt(e.name.substring(6));this.onColumnChange_(t,e.newValue)}}setTimeout(()=>{this.checkWarning_()},0)}}},onSpaceChange_:function(e){let t=br(e);if(!t){console.assert(!1);return}let n=t.id!==this.space.id;this.space.id=t.id,this.space.name=t.name;let r=this.getField(`TABLE`);if(r.getOptions(!1),n){let e=X(this.space.id)?.[0];r.setValue(e?.id??``)}this.onTableChange_(r.getValue())},onTableChange_:function(e){let t=Sr(this.space.id,e);if(!t){console.assert(!1);return}this.table.id=t.id,this.table.name=t.name,this.table.columns=t.columns,this.itemCount_=t.columns.length,this.updateShape_();for(let e=0;e<t.columns.length;e++){let{id:n,name:r}=t.columns[e],i=this.getField(`COLUMN`+e);i.getOptions(!1),i.setValue(n,!1),this.getField(`ALIAS`+e).setValue(r,!1)}},onColumnChange_:function(e,t){let n=this.table.columns.find(e=>e.id===t);if(!n){console.assert(!1);return}this.setFieldValue(n.name,`ALIAS`+e)},decompose:function(e){let t=e.newBlock(`select_column_container_v1`);t.initSvg();let n=t.getInput(`STACK`).connection;for(let t=0;t<this.itemCount_;t++){let t=e.newBlock(`select_column_item_v1`);t.initSvg(),n.connect(t.previousConnection),n=t.nextConnection}return t},compose:function(e){let t=e.getInputTargetBlock(`STACK`),n=[],r=[];for(;t;){if(t.isInsertionMarker()){t=t.getNextBlock();continue}n.push(t.column_),r.push(t.alias_),t=t.getNextBlock()}this.itemCount_=n.length,this.updateShape_();for(let e=0;e<this.itemCount_;e++){let t=n[e]??this.table.columns[0]?.id??``,i=r[e]??this.table.columns[0]?.name??``;this.getField(`COLUMN`+e).setValue(t,!1),this.getField(`ALIAS`+e).setValue(i,!1)}setTimeout(()=>{this.checkWarning_()},0)},saveConnections:function(e){let t=e.getInputTargetBlock(`STACK`),n=0;for(;t;){if(t.isInsertionMarker()){t=t.getNextBlock();continue}t.column_=this.getFieldValue(`COLUMN`+n),t.alias_=this.getFieldValue(`ALIAS`+n),t=t.getNextBlock(),n++}},initShape_:function(){if(!this.isInFlyout&&!this.getInput(`ADD0`))for(let t=0;t<this.table.columns.length;t++){let n=this.table.columns[t],r=new e.FieldDropdown(()=>this.genColumnOpts_()),i=new e.FieldTextInput(``);this.appendDummyInput(`ADD`+t).setAlign(e.inputs.Align.RIGHT).appendField(r,`COLUMN`+t).appendField(`%{BKY_DATA_AS}`).appendField(i,`ALIAS`+t),r.setValue(n.id,!1),i.setValue(n.name,!1)}},updateShape_:function(){for(let e=this.itemCount_;this.getInput(`ADD`+e);e++)this.removeInput(`ADD`+e);for(let t=0;t<this.itemCount_;t++){if(this.getInput(`ADD`+t))continue;let n=new e.FieldDropdown(()=>this.genColumnOpts_()),r=new e.FieldTextInput(``);this.appendDummyInput(`ADD`+t).setAlign(e.inputs.Align.RIGHT).appendField(n,`COLUMN`+t).appendField(`%{BKY_DATA_AS}`).appendField(r,`ALIAS`+t);let i=this.table.columns[0];n.setValue(i.id??``,!1),r.setValue(i.name??``,!1)}},checkWarning_:function(){let e=br(this.space.id);if(!e){this.setWarningText(M(`WARN_SPACE_NOT_FOUND`));return}e.name!==this.space.name&&(this.space.name=e.name);let t=Sr(this.space.id,this.table.id);if(!t){this.setWarningText(M(`WARN_TABLE_NOT_FOUND`));return}if(t.name!==this.table.name&&(this.table.name=t.name),!b(t.columns,this.table.columns)){this.setWarningText(M(`WARN_TABLE_HAS_CHANGED`));return}this.setWarningText(null)}};e.Blocks.select_column_v1=Gr,n.forBlock.select_column_v1=function(e){let r=n.quote_,i=e,a=i.space.id,o=i.table.id,s=[];for(let e=0;e<i.itemCount_;e++){let t=i.getFieldValue(`COLUMN`+e),n=i.table.columns.find(e=>e.id===t).name,r=i.getFieldValue(`ALIAS`+e);s.push({name:n,alias:r})}let c=`[`;return s.forEach(({name:e,alias:t},n)=>{n!==0&&(c+=`,`),c+=`{name:${r(e)},alias:${r(t)}}`}),c+=`]`,[`{spaceId:${r(a)},tableId:${r(o)},columns:${c}}`,t.ATOMIC]};const Kr={init:function(){this.space={id:``,name:``},this.table={id:``,name:``},this.appendDummyInput().appendField(`%{BKY_DATA_V1_SELECT_TABLE_TITLE}`).appendField(new e.FieldDropdown(()=>this.genSpaceOpts_()),`SPACE`).appendField(new e.FieldDropdown(()=>this.genTableOpts_()),`TABLE`),this.setOutput(!0,`SelectTable`),this.setStyle(`object_blocks`),this.setTooltip(`%{BKY_DATA_V1_SELECT_TABLE_TOOLTIP}`),this.setHelpUrl(`%{BKY_DATA_V1_SELECT_TABLE_HELPURL}`),this.initData_()},initData_:function(){if(this.space.id)return;let e=Y()?.[0];if(!e)return;this.space.id=e.id,this.space.name=e.name;let t=this.getField(`SPACE`);t.getOptions(!1),t.setValue(this.space.id);let n=X(this.space.id)?.[0];if(!n)return;this.table.id=n.id,this.table.name=n.name;let r=this.getField(`TABLE`);r.getOptions(!1),r.setValue(this.table.id)},saveExtraState:function(){return{space:this.space,table:this.table}},loadExtraState:function(e){this.space.id=e.space?.id??``,this.space.name=e.space?.name??``,this.table.id=e.table?.id??``,this.table.name=e.table?.name??``,this.checkWarning_()},genSpaceOpts_:function(){return xr()},genTableOpts_:function(){return Cr(this.space.id)},onchange:function(t){if(t.type===e.Events.BLOCK_CHANGE){let e=t;e.blockId===this.id&&(e.element===`field`&&(e.name===`SPACE`?this.onSpaceChange_(e.newValue):e.name===`TABLE`&&this.onTableChange_(e.newValue)),setTimeout(()=>{this.checkWarning_()},0))}},onSpaceChange_:function(e){let t=br(e);if(!t){console.assert(!1);return}let n=t.id!==this.space.id;this.space.id=t.id,this.space.name=t.name;let r=this.getField(`TABLE`);if(r.getOptions(!1),n){let e=X(this.space.id)?.[0];r.setValue(e?.id??``)}this.onTableChange_(r.getValue())},onTableChange_:function(e){let t=Sr(this.space.id,e);if(!t){console.assert(!1);return}this.table.id=t.id,this.table.name=t.name},checkWarning_:function(){let e=br(this.space.id);if(!e){this.setWarningText(M(`WARN_SPACE_NOT_FOUND`));return}e.name!==this.space.name&&(this.space.name=e.name);let t=Sr(this.space.id,this.table.id);if(!t){this.setWarningText(M(`WARN_TABLE_NOT_FOUND`));return}t.name!==this.table.name&&(this.table.name=t.name),this.setWarningText(null)}};e.Blocks.select_table_v1=Kr,n.forBlock.select_table_v1=function(e){let r=n.quote_,i=e,a=i.space.id,o=i.table.id;return[`{spaceId:${r(a)},tableId:${r(o)}}`,t.ATOMIC]};const qr={init:function(){this.appendDummyInput().appendField(`%{BKY_DATA_V1_TRANSACTION_TITLE}`),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null),this.setStyle(`procedure_blocks`),this.setTooltip(`%{BKY_DATA_V1_TRANSACTION_TOOLTIP}`),this.setHelpUrl(`%{BKY_DATA_V1_TRANSACTION_HELPURL}`)},saveExtraState:function(){return{}},loadExtraState:function(){this.updateShape_(),setTimeout(()=>{this.ensureBlocks_()},0)},updateShape_:function(){this.getInput(`FINALLY`)||this.appendStatementInput(`FINALLY`).appendField(`%{BKY_DATA_FINALLY}`),this.getInput(`MESSAGE`)||(this.appendValueInput(`MESSAGE`),this.moveInputBefore(`MESSAGE`,`FINALLY`)),this.getInput(`SUCCESS`)||(this.appendValueInput(`SUCCESS`),this.moveInputBefore(`SUCCESS`,`MESSAGE`)),this.getInput(`HANDLE`)||(this.appendStatementInput(`HANDLE`).appendField(`%{BKY_DATA_DO}`),this.moveInputBefore(`HANDLE`,`SUCCESS`))},ensureBlocks_:function(){this.isInsertionMarker()||B(this,[[`SUCCESS`,`__success__`,`x-runtime-lib.success`,!0],[`MESSAGE`,`__message__`,`x-runtime-lib.message`,!0]])}};e.Blocks.transaction_v1=qr,n.forBlock.transaction_v1=function(e){let t=n.INDENT,r=e,i=bt(r),a=n.statementToCode(r,`HANDLE`),o=n.statementToCode(r,`FINALLY`);return`{
|
|
115
|
-
${t}var __error${
|
|
116
|
-
${t}var __txExist${
|
|
117
|
-
${t}var __tx__ = __txExist${
|
|
118
|
-
${t}var __spName${
|
|
65
|
+
`)}(${t}, ${n}, ${r})`,v.FUNCTION_CALL]},x.on_flow_state_event_v1={init:function(){}},y.forBlock.on_flow_state_event_v1=function(){return`__onFlowStateEventV1__();
|
|
66
|
+
`};function yr(e){let t=w.compute.spaces.find(t=>t.id===e);return t?t.funcs:[]}function br(e,t){let n=w.compute.spaces.find(t=>t.id===e);if(n)return n.funcs.find(e=>e.id===t)}function xr(e){let t=[];return yr(e).forEach(({id:e,name:n})=>{t.push([n,e])}),L(t)}function Sr(){return w.compute.activeFunc}function Cr(e){let{activeFunc:t}=w.compute;return t.outputs?.find(t=>t.id===e)}function wr(){let{activeFunc:e}=w.compute,t=[];return e.outputs?.forEach(({id:e,name:n})=>{t.push([n,e])}),L(t)}function Tr(e){let t=[];return w.compute.spaces.forEach(n=>{e===`func`&&n.funcs.length>0&&t.push(n),e===`flow`&&n.flows.length>0&&t.push(n)}),t}function Er(e){return w.compute.spaces.find(t=>t.id===e)}function Dr(e){let t=[];return Tr(e).forEach(({id:e,name:n})=>{t.push([n,e])}),L(t)}x.call_func_v1={init:function(){this.space={id:``,name:``},this.func={id:``,name:``,inputs:[],outputs:[]},this.appendDummyInput().appendField(`%{BKY_COMPUTE_CALL}`).appendField(new C(()=>this.genSpaceOpts_()),`SPACE`).appendField(new C(()=>this.genFuncOpts_()),`FUNC`),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null),this.setStyle(`procedure_blocks`),this.setTooltip(`%{BKY_COMPUTE_V1_CALL_FUNC_TOOLTIP}`),this.setHelpUrl(`%{BKY_COMPUTE_V1_CALL_FUNC_HELPURL}`),this.initData_()},initData_:function(){if(this.space.id)return;let e=Tr(`func`)?.[0];if(!e)return;this.space.id=e.id,this.space.name=e.name;let t=this.getField(`SPACE`);t.getOptions(!1),t.setValue(this.space.id);let n=yr(this.space.id)?.[0];if(!n)return;this.func.id=n.id,this.func.name=n.name,this.func.inputs=n.inputs,this.func.outputs=n.outputs;let r=this.getField(`FUNC`);r.getOptions(!1),r.setValue(this.func.id)},saveExtraState:function(){return{space:this.space,func:this.func}},loadExtraState:function(e){this.space.id=e.space?.id??``,this.space.name=e.space?.name??``,this.func.id=e.func?.id??``,this.func.name=e.func?.name??``,this.func.inputs=e.func?.inputs??[],this.func.outputs=e.func?.outputs??[],this.updateShape_(),this.updateCheck_(),this.updateShadow_(),setTimeout(()=>{this.ensureBlocks_(),this.checkWarning_()},0)},genSpaceOpts_:function(){return Dr(`func`)},genFuncOpts_:function(){return xr(this.space.id)},onchange:function(e){if(e.type===b.BLOCK_CHANGE){let t=e;t.blockId===this.id&&(t.element===`field`&&(t.name===`SPACE`?this.onSpaceChange_(t.newValue):t.name===`FUNC`&&this.onFuncChange_(t.newValue)),setTimeout(()=>{this.checkWarning_()},0))}},onSpaceChange_:function(e){let t=Er(e);if(!t){console.assert(!1);return}let n=t.id!==this.space.id;this.space.id=t.id,this.space.name=t.name;let r=this.getField(`FUNC`);if(r.getOptions(!1),n){let e=yr(this.space.id)?.[0];r.setValue(e?.id??``)}this.onFuncChange_(r.getValue())},onFuncChange_:function(e){let t=br(this.space.id,e);if(!t){console.assert(!1);return}this.func.id=t.id,this.func.inputs=t.inputs,this.func.outputs=t.outputs,this.updateShape_(),this.updateCheck_(),this.updateShadow_(),setTimeout(()=>{this.ensureBlocks_(),this.checkWarning_()},0)},updateShape_:function(){this.getInput(`CALLBACK`)||this.appendStatementInput(`CALLBACK`).appendField(`%{BKY_COMPUTE_DO}`);for(let e=this.func.outputs.length;this.getInput(`OUTPUT`+e);e++){let t=this.getInput(`OUTPUT`+e)?.connection?.targetBlock();t&&t.dispose(),this.removeInput(`OUTPUT`+e)}for(let e=0;e<this.func.outputs.length;e++){if(this.getInput(`OUTPUT`+e))continue;let t=this.appendValueInput(`OUTPUT`+e);e==0&&t.appendField(`%{BKY_COMPUTE_CALLBACK}`),this.moveInputBefore(`OUTPUT`+e,`CALLBACK`)}for(let e=this.func.inputs.length;this.getInput(`INPUT`+e);e++){let t=this.getInput(`INPUT`+e)?.connection?.targetBlock();t&&t.dispose(),this.removeInput(`INPUT`+e)}for(let e=0;e<this.func.inputs.length;e++){let{name:t}=this.func.inputs[e],n=this.getInput(`INPUT`+e);n?(this.setFieldValue(t,`NAME`+e),n.setCheck(null)):(this.appendValueInput(`INPUT`+e).setAlign(m.Align.RIGHT).appendField(t,`NAME`+e).setCheck(null),this.getInput(`OUTPUT0`)?this.moveInputBefore(`INPUT`+e,`OUTPUT0`):this.moveInputBefore(`INPUT`+e,`CALLBACK`))}},updateCheck_:function(){for(let e=0;e<this.func.inputs.length;e++){let{type:t}=this.func.inputs[e],n=V(t);this.getInput(`INPUT`+e).connection.setCheck(n)}},updateShadow_:function(){if(!this.isInsertionMarker())for(let e=0;e<this.func.inputs.length;e++){let t=this.func.inputs[e],n=U(t.type);this.getInput(`INPUT`+e).setShadowDom(n)}},ensureBlocks_:function(){if(this.isInsertionMarker())return;let e=[];for(let t=0;t<this.func.outputs.length;t++){let{id:n,name:r}=this.func.outputs[t];e.push([`OUTPUT`+t,`__output$${n}__`,r,!1])}H(this,e)},checkWarning_:function(){let e=Er(this.space.id);if(!e){this.setWarningText(I(`WARN_SPACE_NOT_FOUND`));return}e.name!==this.space.name&&(this.space.name=e.name);let t=br(this.space.id,this.func.id);if(!t){this.setWarningText(I(`WARN_FUNC_NOT_FOUND`));return}if(!_(t.inputs,this.func.inputs)){this.setWarningText(I(`WARN_FUNC_HAS_CHANGED`));return}if(!_(t.outputs,this.func.outputs)){this.setWarningText(I(`WARN_FUNC_HAS_CHANGED`));return}this.setWarningText(null)}},y.forBlock.call_func_v1=function(e){let t=y.INDENT,n=y.quote_,r=e,i=n(r.space.id),a=n(r.func.id),o=``;o+=`${t}var __inputs__ = {\n`,r.func.inputs.forEach(({id:e},i)=>{let a=y.valueToCode(r,`INPUT`+i,v.ATOMIC);o+=`${t}${t}${n(e)}: ${a},\n`}),o+=`${t}};`;let s=n(r.space.name+`/`+r.func.name),c=``;r.func.outputs.forEach(({id:e})=>{c+=`${t}var __output${e}__ = __result__[${n(e)}];\n`});let l=y.statementToCode(r,`CALLBACK`);return`{
|
|
67
|
+
${o}
|
|
68
|
+
${t}var __result__ = __callFuncV1__(${i},${a},__inputs__,__getEnvV1__(),${s});
|
|
69
|
+
${c}${l}}
|
|
70
|
+
`},x.call_func_internal_v1={init:function(){this.space={id:``,name:``},this.func={id:``,name:``,inputs:[],outputs:[]},this.appendDummyInput().appendField(`%{BKY_COMPUTE_CALL}`).appendField(new C(()=>this.genSpaceOpts_()),`SPACE`).appendField(new C(()=>this.genFuncOpts_()),`FUNC`),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null),this.setStyle(`procedure_blocks`),this.setTooltip(`%{BKY_COMPUTE_V1_CALL_FUNC_INTERNAL_TOOLTIP}`),this.setHelpUrl(`%{BKY_COMPUTE_V1_CALL_FUNC_INTERNAL_HELPURL}`),this.initData_()},initData_:function(){if(this.space.id)return;let e=Tr(`func`)?.[0];if(!e)return;this.space.id=e.id,this.space.name=e.name;let t=this.getField(`SPACE`);t.getOptions(!1),t.setValue(this.space.id);let n=yr(this.space.id)?.[0];if(!n)return;this.func.id=n.id,this.func.name=n.name,this.func.inputs=n.inputs,this.func.outputs=n.outputs;let r=this.getField(`FUNC`);r.getOptions(!1),r.setValue(this.func.id)},saveExtraState:function(){return{space:this.space,func:this.func}},loadExtraState:function(e){this.space.id=e.space?.id??``,this.space.name=e.space?.name??``,this.func.id=e.func?.id??``,this.func.name=e.func?.name??``,this.func.inputs=e.func?.inputs??[],this.func.outputs=e.func?.outputs??[],this.updateShape_(),this.updateCheck_(),this.updateShadow_(),setTimeout(()=>{this.ensureBlocks_(),this.checkWarning_()},0)},genSpaceOpts_:function(){return Dr(`func`)},genFuncOpts_:function(){return xr(this.space.id)},onchange:function(e){if(e.type===b.BLOCK_CHANGE){let t=e;t.blockId===this.id&&(t.element===`field`&&(t.name===`SPACE`?this.onSpaceChange_(t.newValue):t.name===`FUNC`&&this.onFuncChange_(t.newValue)),setTimeout(()=>{this.checkWarning_()},0))}},onSpaceChange_:function(e){let t=Er(e);if(!t){console.assert(!1);return}let n=t.id!==this.space.id;this.space.id=t.id,this.space.name=t.name;let r=this.getField(`FUNC`);if(r.getOptions(!1),n){let e=yr(this.space.id)?.[0];r.setValue(e?.id??``)}this.onFuncChange_(r.getValue())},onFuncChange_:function(e){let t=br(this.space.id,e);if(!t){console.assert(!1);return}this.func.id=t.id,this.func.inputs=t.inputs,this.func.outputs=t.outputs,this.updateShape_(),this.updateCheck_(),this.updateShadow_(),setTimeout(()=>{this.ensureBlocks_(),this.checkWarning_()},0)},updateShape_:function(){this.getInput(`CALLBACK`)||this.appendStatementInput(`CALLBACK`).appendField(`%{BKY_COMPUTE_DO}`);for(let e=this.func.outputs.length;this.getInput(`OUTPUT`+e);e++){let t=this.getInput(`OUTPUT`+e)?.connection?.targetBlock();t&&t.dispose(),this.removeInput(`OUTPUT`+e)}for(let e=0;e<this.func.outputs.length;e++){if(this.getInput(`OUTPUT`+e))continue;let t=this.appendValueInput(`OUTPUT`+e);e==0&&t.appendField(`%{BKY_COMPUTE_CALLBACK}`),this.moveInputBefore(`OUTPUT`+e,`CALLBACK`)}for(let e=this.func.inputs.length;this.getInput(`INPUT`+e);e++){let t=this.getInput(`INPUT`+e)?.connection?.targetBlock();t&&t.dispose(),this.removeInput(`INPUT`+e)}for(let e=0;e<this.func.inputs.length;e++){let{name:t}=this.func.inputs[e],n=this.getInput(`INPUT`+e);n?(this.setFieldValue(t,`NAME`+e),n.setCheck(null)):(this.appendValueInput(`INPUT`+e).setAlign(m.Align.RIGHT).appendField(t,`NAME`+e).setCheck(null),this.getInput(`OUTPUT0`)?this.moveInputBefore(`INPUT`+e,`OUTPUT0`):this.moveInputBefore(`INPUT`+e,`CALLBACK`))}},updateCheck_:function(){for(let e=0;e<this.func.inputs.length;e++){let{type:t}=this.func.inputs[e],n=V(t);this.getInput(`INPUT`+e).connection.setCheck(n)}},updateShadow_:function(){if(!this.isInsertionMarker())for(let e=0;e<this.func.inputs.length;e++){let t=this.func.inputs[e],n=U(t.type);this.getInput(`INPUT`+e).setShadowDom(n)}},ensureBlocks_:function(){if(this.isInsertionMarker())return;let e=[];for(let t=0;t<this.func.outputs.length;t++){let{id:n,name:r}=this.func.outputs[t];e.push([`OUTPUT`+t,`__output$${n}__`,r,!1])}H(this,e)},checkWarning_:function(){let e=Er(this.space.id);if(!e){this.setWarningText(I(`WARN_SPACE_NOT_FOUND`));return}e.name!==this.space.name&&(this.space.name=e.name);let t=br(this.space.id,this.func.id);if(!t){this.setWarningText(I(`WARN_FUNC_NOT_FOUND`));return}if(!_(t.inputs,this.func.inputs)){this.setWarningText(I(`WARN_FUNC_HAS_CHANGED`));return}if(!_(t.outputs,this.func.outputs)){this.setWarningText(I(`WARN_FUNC_HAS_CHANGED`));return}this.setWarningText(null)}},y.forBlock.call_func_internal_v1=function(e){let t=y.INDENT,n=y.quote_,r=e,i=n(r.space.id),a=n(r.func.id),o=`${t}var __inputs__ = {\n`;r.func.inputs.forEach(({id:e},i)=>{let a=y.valueToCode(r,`INPUT`+i,v.ATOMIC);o+=`${t}${t}${n(e)}: ${a},\n`}),o+=`${t}};`;let s=r.space.name+`/`+r.func.name,c=``;r.func.outputs.forEach(({id:e})=>{c+=`${t}var __output$${e}__ = __result__.outputs[${n(e)}];\n`});let l=y.statementToCode(r,`CALLBACK`);return`{
|
|
71
|
+
${o}
|
|
72
|
+
${t}var __result__ = __callFuncInternalV1__(${i}, ${a}, __inputs__);
|
|
73
|
+
${t}if (!__result__.success) {
|
|
74
|
+
${t}${t}throw 'call func<${s}> failed, reason: ' + __result__.message;
|
|
75
|
+
${t}}
|
|
76
|
+
${c}${l}}
|
|
77
|
+
`},x.func_entry_v1={init:function(){this.func={id:``},this.appendDummyInput().appendField(`%{BKY_COMPUTE_FUNC_ENTRY}`).appendField(``),this.appendStatementInput(`HANDLE`).appendField(`%{BKY_COMPUTE_DO}`),this.setStyle(`procedure_blocks`),this.setTooltip(`%{BKY_COMPUTE_V1_FUNC_ENTRY_TOOLTIP}`),this.setHelpUrl(`%{BKY_COMPUTE_V1_FUNC_ENTRY_HELPURL}`),this.initData_()},initData_:function(){if(this.func.id)return;let{id:e,inputs:t}=Sr();this.func.id=e,this.func.inputs=t},saveExtraState:function(){return{func:this.func}},loadExtraState:function(e){this.func.id=e.func?.id??``,this.func.inputs=e.func?.inputs,this.updateShape_(),setTimeout(()=>{this.ensureBlocks_()},0)},onchange:function(){setTimeout(()=>{this.checkWarning_()},0)},updateShape_:function(){for(let e=this.func.inputs?.length??0;this.getInput(`INPUT`+e);e++){let t=this.getInput(`INPUT`+e)?.connection?.targetBlock();t&&t.dispose(),this.removeInput(`INPUT`+e)}if(this.func.inputs)for(let e=0;e<this.func.inputs.length;e++)this.appendValueInput(`INPUT`+e),this.moveInputBefore(`INPUT`+e,`HANDLE`)},ensureBlocks_:function(){if(this.isInsertionMarker())return;let e=[];if(this.func.inputs)for(let t=0;t<this.func.inputs.length;t++){let{id:n,name:r}=this.func.inputs[t];e.push([`INPUT`+t,`__input$${n}__`,r,!1])}H(this,e)},checkWarning_:function(){let{id:e,inputs:t}=Sr();if(this.func.id!==e&&(this.func.id=e),!_(t,this.func.inputs)){this.setWarningText(I(`WARN_FUNC_HAS_CHANGED`));return}this.setWarningText(null)}},y.forBlock.func_entry_v1=function(e){let t=e,n=y.statementToCode(t,`HANDLE`),r=[];if(t.func.inputs)for(let e=0;e<t.func.inputs.length;e++){let{id:n}=t.func.inputs[e];r.push(`__input$${n}__`)}return`function __funcEntryV1__(${r.join(`, `)}) {
|
|
78
|
+
${n}}`},x.set_func_output_v1={init:function(){this.output={id:``,name:``,type:`string`},this.appendValueInput(`VALUE`).appendField(`%{BKY_COMPUTE_V1_SET_FUNC_OUTPUT_TITLE}`).appendField(new C(()=>this.genOutputOpts_()),`OUTPUT`),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null),this.setStyle(`procedure_blocks`),this.setTooltip(`%{BKY_COMPUTE_V1_SET_FUNC_OUTPUT_TOOLTIP}`),this.setHelpUrl(`%{BKY_COMPUTE_V1_SET_FUNC_OUTPUT_HELPURL}`),this.initData_(),this.updateShape_(),this.updateShadows_()},initData_:function(){if(this.output.id)return;let e=Sr().outputs?.[0];e&&(this.output.id=e.id,this.output.name=e.name,this.output.type=e.type)},saveExtraState:function(){return{output:this.output}},loadExtraState:function(e){this.output.id=e.output?.id??``,this.output.name=e.output?.name??``,this.output.type=e.output?.type??``,this.updateShape_(),this.updateShadows_(),setTimeout(()=>{this.checkWarning_()},0)},genOutputOpts_:function(){return wr()},onchange:function(e){if(e.type===b.BLOCK_CHANGE){let t=e;t.blockId===this.id&&(t.element===`field`&&t.name===`OUTPUT`&&this.onOutputChange_(t.newValue),setTimeout(()=>{this.checkWarning_()},0))}},onOutputChange_:function(e){let t=Cr(e);if(!t){console.assert(!1);return}this.output.id=t.id,this.output.name=t.name,this.output.type=t.type,this.updateShape_(),this.updateShadows_()},updateShape_:function(){let e=this.getInput(`VALUE`);e.connection.setShadowDom(null);let t=e.connection.targetBlock();t&&!t.isShadow()&&t.dispose();let n=V(this.output.type);e.setCheck(n)},updateShadows_:function(){if(this.isInsertionMarker())return;let e=U(this.output.type);this.getInput(`VALUE`).setShadowDom(e)},checkWarning_:function(){let e=Cr(this.output.id);if(!e){this.setWarningText(I(`WARN_FUNC_HAS_CHANGED`));return}if(e.name!==this.output.name&&(this.output.name=e.name),e.type!==this.output.type){this.setWarningText(I(`WARN_FUNC_HAS_CHANGED`));return}this.setWarningText(null)}},y.forBlock.set_func_output_v1=function(e){let t=y.quote_,n=e,{id:r,type:i}=n.output,a=y.valueToCode(n,`VALUE`,v.ATOMIC);if(a===void 0)switch(i){case`string`:a=`''`;break;case`number`:a=`0`;break;case`boolean`:a=`false`;break;case`array`:a=`[]`;break;case`object`:a=`{}`;break;default:a=`null`}return`__setFuncOutputV1__(${t(r)}, ${a});\n`},a([{type:`compute_debug_trace_v1`,message0:`%{BKY_COMPUTE_V1_COMPUTE_DEBUG_TRACE_TITLE}`,args0:[{type:`input_value`,name:`OBJECT`,check:null}],previousStatement:null,nextStatement:null,style:`procedure_blocks`,tooltip:`%{BKY_COMPUTE_V1_COMPUTE_DEBUG_TRACE_TOOLTIP}`,helpUrl:`%{BKY_COMPUTE_V1_COMPUTE_DEBUG_TRACE_HELPURL}`}]),y.forBlock.compute_debug_trace_v1=function(e){return`__debugTraceV1__(${y.valueToCode(e,`OBJECT`,v.ATOMIC)});\n`},a([{type:`compute_env_is_v1`,message0:`%{BKY_COMPUTE_V1_COMPUTE_ENV_IS_TITLE}`,args0:[{type:`field_dropdown`,name:`ENV`,options:[[`%{BKY_COMPUTE_ENV_DEV}`,`dev`],[`%{BKY_COMPUTE_ENV_PROD}`,`prod`]]}],output:`Boolean`,style:`logic_blocks`,tooltip:`%{BKY_COMPUTE_V1_COMPUTE_ENV_IS_TOOLTIP}`,helpUrl:`%{BKY_COMPUTE_V1_COMPUTE_ENV_IS_HELPURL}`}]),y.forBlock.compute_env_is_v1=function(e){return[`__getEnvV1__() === ${y.quote_(e.getFieldValue(`ENV`))}`,v.ATOMIC]};function Or(){let e=[];return w.data.spaces.forEach(t=>{t.tables.length>0&&e.push(t)}),e}function kr(e){let{spaces:t}=w.data;return t.find(t=>t.id===e)}function Ar(){let e=[];return Or().forEach(({id:t,name:n})=>{e.push([n,t])}),L(e)}function X(e){let{spaces:t}=w.data,n=t.find(t=>t.id===e);return n?n.tables:[]}function jr(e,t){let{spaces:n}=w.data,r=n.find(t=>t.id===e);if(r)return r.tables.find(e=>e.id===t)}function Mr(e){let t=[];return X(e).forEach(({id:e,name:n})=>{t.push([n,e])}),L(t)}function Nr(e,t){let{spaces:n}=w.data,r=n.find(t=>t.id===e);if(!r)return[];let i=r.tables.find(e=>e.id===t);return i?i.columns:[]}function Pr(e,t,n){let{spaces:r}=w.data,i=r.find(t=>t.id===e);if(!i)return;let a=i.tables.find(e=>e.id===t);if(a)return a.columns.find(e=>e.id===n)}function Fr(e,t){let n=[];return Nr(e,t).forEach(({id:e,name:t})=>{n.push([t,e])}),L(n)}function Ir(e){let t=e.getInput(`TABLE`).connection;if(t.targetBlock())return;let n,r,i=Or()?.[0];if(i){let e=X(i.id)?.[0];if(e){n={space:{id:i.id,name:i.name},table:{id:e.id,name:e.name,columns:e.columns},itemCount:e.columns.length},r={};for(let t=0;t<e.columns.length;t++){let n=e.columns[t];r[`COLUMN`+t]=n.id}}}let a={type:`update_column_v1`,extraState:n,fields:r},o=p.blocks.append(a,e.workspace);t.connect(o.outputConnection)}function Lr(e){let t=e.getInput(`HANDLE`).connection;if(t.targetBlock())return;let n=p.blocks.append({type:`compute_debug_trace_v1`,inputs:{OBJECT:{shadow:{type:`text_v1`},block:{type:`parameter_v1`,extraState:{key:`__message__`,name:`x-runtime-lib.message`,locale:!0}}}}},e.workspace);t.connect(n.previousConnection)}x.add_data_v1={init:function(){this.appendDummyInput().appendField(`%{BKY_DATA_V1_ADD_DATA_TITLE}`),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null),this.setStyle(`procedure_blocks`),this.setTooltip(`%{BKY_DATA_V1_ADD_DATA_TOOLTIP}`),this.setHelpUrl(`%{BKY_DATA_V1_ADD_DATA_HELPURL}`)},saveExtraState:function(){return{}},loadExtraState:function(){this.updateShape_(),setTimeout(()=>{this.ensureBlocks_()},0)},updateShape_:function(){this.getInput(`HANDLE`)||this.appendStatementInput(`HANDLE`).appendField(`%{BKY_DATA_DO}`),this.getInput(`DATA`)||(this.appendValueInput(`DATA`),this.moveInputBefore(`DATA`,`HANDLE`)),this.getInput(`MESSAGE`)||(this.appendValueInput(`MESSAGE`),this.moveInputBefore(`MESSAGE`,`DATA`)),this.getInput(`SUCCESS`)||(this.appendValueInput(`SUCCESS`).appendField(`%{BKY_DATA_RETURN}`),this.moveInputBefore(`SUCCESS`,`MESSAGE`)),this.getInput(`TABLE`)||(this.appendValueInput(`TABLE`).setCheck(`UpdateColumn`).setAlign(m.Align.RIGHT).appendField(`%{BKY_DATA_TABLE}`),this.moveInputBefore(`TABLE`,`SUCCESS`))},ensureBlocks_:function(){this.isInsertionMarker()||(Ir(this),H(this,[[`SUCCESS`,`__success__`,`x-runtime-lib.success`,!0],[`MESSAGE`,`__message__`,`x-runtime-lib.message`,!0],[`DATA`,`__data__`,`x-runtime-lib.data`,!0]]),Lr(this))}},y.forBlock.add_data_v1=function(e){let t=y.INDENT;return`{
|
|
79
|
+
${t}var __tx__ = typeof(__tx__) !== 'undefined' ? __tx__ : null;
|
|
80
|
+
${t}var __table__ = ${y.valueToCode(e,`TABLE`,v.ATOMIC)||`null`};
|
|
81
|
+
${t}var __result__ = __addDataV1__(__tx__, __table__);
|
|
82
|
+
${t}var __success__ = __result__.success;
|
|
83
|
+
${t}var __message__ = __result__.message;
|
|
84
|
+
${t}var __data__ = __result__.data;
|
|
85
|
+
${t}if (__tx__ && !__success__) {
|
|
86
|
+
${t}${t}throw __message__;
|
|
87
|
+
${t}}
|
|
88
|
+
${y.statementToCode(e,`HANDLE`)}}
|
|
89
|
+
`},x.cond_atomic_v1={init:function(){this.space={id:``,name:``},this.table={id:``,name:``},this.column={id:``,name:``,type:``,extend:``},this.appendValueInput(`VALUE`).appendField(new C(()=>this.genSpaceOpts_()),`SPACE`).appendField(new C(()=>this.genTableOpts_()),`TABLE`).appendField(new C(()=>this.genColumnOpts_()),`COLUMN`).appendField(new C([[`=`,`EQ`],[`≠`,`NEQ`],[`<`,`LT`],[`≤`,`LTE`],[`>`,`GT`],[`≥`,`GTE`]]),`OP`),this.setOutput(!0,`Condition`),this.setStyle(`object_blocks`),this.setTooltip(`%{BKY_DATA_V1_COND_ATOMIC_TOOLTIP}`),this.setHelpUrl(`%{BKY_DATA_V1_COND_ATOMIC_HELPURL}`),this.initData_(),this.updateShape_(),setTimeout(()=>{this.updateBlocks_()},0)},initData_:function(){if(this.space.id)return;let e=Or()?.[0];if(!e)return;this.space.id=e.id,this.space.name=e.name;let t=X(this.space.id)?.[0];if(!t)return;this.table.id=t.id,this.table.name=t.name;let n=Nr(this.space.id,this.table.id)?.[0];n&&(this.column.id=n.id,this.column.name=n.name,this.column.type=n.type,this.column.extend=n.extend)},saveExtraState:function(){return{space:this.space,table:this.table,column:this.column}},loadExtraState:function(e){this.space.id=e.space?.id??``,this.space.name=e.space?.name??``,this.table.id=e.table?.id??``,this.table.name=e.table?.name??``,this.column.id=e.column?.id??``,this.column.name=e.column?.name??``,this.column.type=e.column?.type??``,this.column.extend=e.column?.extend??``,this.updateShape_(),setTimeout(()=>{this.updateBlocks_(),this.updateCheck_(),this.checkWarning_()},0)},genSpaceOpts_:function(){return Ar()},genTableOpts_:function(){return Mr(this.space.id)},genColumnOpts_:function(){return Fr(this.space.id,this.table.id)},onchange:function(e){if(e.type===b.BLOCK_CHANGE){let t=e;t.blockId===this.id&&t.element===`field`&&(t.name===`SPACE`?this.onSpaceChange_(t.newValue):t.name===`TABLE`?this.onTableChange_(t.newValue):t.name===`COLUMN`&&this.onColumnChange_(t.newValue)),setTimeout(()=>{this.checkWarning_()},0)}},onSpaceChange_:function(e){let t=kr(e);if(!t){console.assert(!1);return}let n=t.id!==this.space.id;this.space.id=t.id,this.space.name=t.name;let r=this.getField(`TABLE`);if(r.getOptions(!1),n){let e=X(this.space.id)?.[0];r.setValue(e?.id??``)}this.onTableChange_(r.getValue())},onTableChange_:function(e){let t=jr(this.space.id,e);if(!t){console.assert(!1);return}let n=t.id!==this.table.id;this.table.id=t.id,this.table.name=t.name;let r=this.getField(`COLUMN`);if(r.getOptions(!1),n){let e=Nr(this.space.id,this.table.id)?.[0];r.setValue(e?.id??``)}this.onColumnChange_(r.getValue())},onColumnChange_:function(e){let t=Pr(this.space.id,this.table.id,e);if(!t){console.assert(!1);return}this.column.id=t.id,this.column.name=t.name,this.column.type=t.type,this.column.extend=t.extend,this.updateShape_(),this.updateBlocks_(!0),this.updateCheck_()},updateShape_:function(){let e=this.getField(`SPACE`);e.getOptions(!1),e.setValue(this.space.id);let t=this.getField(`TABLE`);t.getOptions(!1),t.setValue(this.table.id);let n=this.getField(`COLUMN`);n.getOptions(!1),n.setValue(this.column.id)},updateBlocks_:function(e){if(this.isInsertionMarker())return;let t=this.getInput(`VALUE`).connection,n=t.targetBlock();if(e)n&&n.dispose();else if(n)return;let r=Wt(this.workspace,this.column.type);r&&(t.setCheck(null),t.connect(r.outputConnection))},updateCheck_:function(){let e=rn(this.column.type);this.getInput(`VALUE`).connection.setCheck(e)},checkWarning_:function(){let e=kr(this.space.id);if(!e){this.setWarningText(I(`WARN_SPACE_NOT_FOUND`));return}e.name!==this.space.name&&(this.space.name=e.name);let t=jr(this.space.id,this.table.id);if(!t){this.setWarningText(I(`WARN_TABLE_NOT_FOUND`));return}t.name!==this.table.name&&(this.table.name=t.name);let n=Pr(this.space.id,this.table.id,this.column.id);if(!n){this.setWarningText(I(`WARN_COLUMN_NOT_FOUND`));return}if(n.name!==this.column.name&&(this.column.name=n.name),n.type!==this.column.type||n.extend!==this.column.extend){this.setWarningText(I(`WARN_COLUMN_HAS_CHANGED`));return}this.setWarningText(null)}},y.forBlock.cond_atomic_v1=function(e){let t=y.quote_,n=e,r=n.column.name,i=y.valueToCode(n,`VALUE`,v.ATOMIC)||null,a={EQ:`=`,NEQ:`!=`,LT:`<`,LTE:`<=`,GT:`>`,GTE:`>=`}[n.getFieldValue(`OP`)];return[`{type:'ATOMIC',key:${t(r)},value:${i},operator:${t(a)}}`,v.ATOMIC]},x.cond_logic_container_v1={init:function(){this.appendDummyInput().appendField(`%{BKY_DATA_LIST}`),this.appendStatementInput(`STACK`),this.setStyle(`logic_blocks`),this.contextMenu=!1}},x.cond_logic_item_v1={init:function(){this.appendDummyInput().appendField(`%{BKY_DATA_ITEM}`),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setStyle(`logic_blocks`),this.contextMenu=!1}},x.cond_logic_v1={init:function(){this.itemCount_=1,this.appendValueInput(`VALUE`).setCheck(`Condition`).appendField(new C([[`%{BKY_DATA_COND_LOGIC_TYPE_AND}`,`AND`],[`%{BKY_DATA_COND_LOGIC_TYPE_OR}`,`OR`]]),`TYPE`),this.setMutator(new xe.MutatorIcon([`cond_logic_item_v1`],this)),this.setOutput(!0,`Condition`),this.setStyle(`logic_blocks`),this.setTooltip(`%{BKY_DATA_V1_COND_LOGIC_TOOLTIP}`),this.setHelpUrl(`%{BKY_DATA_V1_COND_LOGIC_HELPURL}`),this.updateShape_()},saveExtraState:function(){return{itemCount:this.itemCount_}},loadExtraState:function(e){this.itemCount_=e.itemCount??1,this.updateShape_()},decompose:function(e){let t=e.newBlock(`cond_logic_container_v1`);t.initSvg();let n=t.getInput(`STACK`).connection;for(let t=0;t<this.itemCount_;t++){let t=e.newBlock(`cond_logic_item_v1`);t.initSvg(),n.connect(t.previousConnection),n=t.nextConnection}return t},compose:function(e){let t=e.getInputTargetBlock(`STACK`),n=[];for(;t;){if(t.isInsertionMarker()){t=t.getNextBlock();continue}n.push(t.valueConnection_),t=t.getNextBlock()}for(let e=0;e<this.itemCount_;e++){let t=this.getInput(`ADD`+e).connection?.targetConnection;t&&n.indexOf(t)===-1&&t.disconnect()}this.itemCount_=n.length,this.updateShape_();for(let e=0;e<this.itemCount_;e++)n[e]?.reconnect(this,`ADD`+e)},saveConnections:function(e){let t=e.getInputTargetBlock(`STACK`),n=0;for(;t;){if(t.isInsertionMarker()){t=t.getNextBlock();continue}t.valueConnection_=this.getInput(`ADD`+n)?.connection?.targetConnection,t=t.getNextBlock(),n++}},updateShape_:function(){for(let e=this.itemCount_;this.getInput(`ADD`+e);e++)this.removeInput(`ADD`+e);for(let e=0;e<this.itemCount_;e++)this.getInput(`ADD`+e)||this.appendValueInput(`ADD`+e).setCheck(`Condition`)}},y.forBlock.cond_logic_v1=function(e){let t=y.quote_,n=e,r=n.getFieldValue(`TYPE`),i=[],a=y.valueToCode(n,`VALUE`,v.ATOMIC)||null;i.push(a);for(let e=0;e<n.itemCount_;e++){let t=y.valueToCode(n,`ADD`+e,v.ATOMIC)||null;i.push(t)}return[`{type:${t(r)},entries:[${i}]}`,v.ATOMIC]};function Rr(e){let t=e.getInput(`TABLE`).connection;if(t.targetBlock())return;let n=Or()?.[0],r=X(n?.id??``)?.[0],i={type:`select_table_v1`,extraState:{space:{id:n?.id??``,name:n?.name??``},table:{id:r?.id??``,name:r?.name??``}}},a=p.blocks.append(i,e.workspace);t.connect(a.outputConnection)}function zr(e){let t=e.getInput(`CONDITION`).connection;if(t.targetBlock())return;let n=Or()?.[0],r=X(n?.id??``)?.[0],i=Nr(n?.id,r?.id)?.[0],a={type:`cond_atomic_v1`,extraState:{space:{id:n?.id??``,name:n?.name??``},table:{id:r?.id??``,name:r?.name??``},column:{id:i?.id??``,name:i?.name??``,type:i?.type??``,extend:i?.extend??``}}},o=p.blocks.append(a,e.workspace);t.connect(o.outputConnection)}function Br(e){let t=e.getInput(`HANDLE`).connection;if(t.targetBlock())return;let n=p.blocks.append({type:`compute_debug_trace_v1`,inputs:{OBJECT:{shadow:{type:`text_v1`},block:{type:`parameter_v1`,extraState:{key:`__message__`,name:`x-runtime-lib.message`,locale:!0}}}}},e.workspace);t.connect(n.previousConnection)}x.delete_data_v1={init:function(){this.appendDummyInput().appendField(`%{BKY_DATA_V1_DELETE_DATA_TITLE}`),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null),this.setStyle(`procedure_blocks`),this.setTooltip(`%{BKY_DATA_V1_DELETE_DATA_TOOLTIP}`),this.setHelpUrl(`%{BKY_DATA_V1_DELETE_DATA_HELPURL}`)},saveExtraState:function(){return{}},loadExtraState:function(){this.updateShape_(),setTimeout(()=>{this.ensureBlocks_()},0)},updateShape_:function(){this.getInput(`HANDLE`)||this.appendStatementInput(`HANDLE`).appendField(`%{BKY_DATA_DO}`),this.getInput(`MESSAGE`)||(this.appendValueInput(`MESSAGE`),this.moveInputBefore(`MESSAGE`,`HANDLE`)),this.getInput(`SUCCESS`)||(this.appendValueInput(`SUCCESS`),this.moveInputBefore(`SUCCESS`,`MESSAGE`)),this.getInput(`CONDITION`)||(this.appendValueInput(`CONDITION`).setCheck(`Condition`).setAlign(m.Align.RIGHT).appendField(`%{BKY_DATA_CONDITION}`),this.moveInputBefore(`CONDITION`,`SUCCESS`)),this.getInput(`TABLE`)||(this.appendValueInput(`TABLE`).setCheck(`SelectTable`).setAlign(m.Align.RIGHT).appendField(`%{BKY_DATA_TABLE}`),this.moveInputBefore(`TABLE`,`CONDITION`))},ensureBlocks_:function(){this.isInsertionMarker()||(Rr(this),zr(this),H(this,[[`SUCCESS`,`__success__`,`x-runtime-lib.success`,!0],[`MESSAGE`,`__message__`,`x-runtime-lib.message`,!0]]),Br(this))}},y.forBlock.delete_data_v1=function(e){let t=y.INDENT;return`{
|
|
90
|
+
${t}var __tx__ = typeof(__tx__) !== 'undefined' ? __tx__ : null;
|
|
91
|
+
${t}var __table__ = ${y.valueToCode(e,`TABLE`,v.ATOMIC)||`null`};
|
|
92
|
+
${t}var __condition__ = ${y.valueToCode(e,`CONDITION`,v.ATOMIC)||`null`};
|
|
93
|
+
${t}var __result__ = __deleteDataV1__(__tx__, __table__, __condition__);
|
|
94
|
+
${t}var __success__ = __result__.success;
|
|
95
|
+
${t}var __message__ = __result__.message;
|
|
96
|
+
${t}if (__tx__ && !__success__) {
|
|
97
|
+
${t}${t}throw __message__;
|
|
98
|
+
${t}}
|
|
99
|
+
${y.statementToCode(e,`HANDLE`)}}
|
|
100
|
+
`},a([{type:`interrupt_transaction_v1`,message0:`%{BKY_DATA_V1_INTERRUPT_TRANSACTION_TITLE}`,args0:[{type:`input_value`,name:`VALUE`,check:`String`}],previousStatement:null,nextStatement:null,style:`procedure_blocks`,tooltip:`%{BKY_DATA_V1_INTERRUPT_TRANSACTION_TOOLTIP}`,helpUrl:`%{BKY_DATA_V1_INTERRUPT_TRANSACTION_HELPURL}`}]),y.forBlock.interrupt_transaction_v1=function(e){return`throw ${y.valueToCode(e,`VALUE`,v.NONE)||`''`};\n`};function Vr(e){let t=e.getInput(`TABLE`).connection;if(t.targetBlock())return;let n,r,i=Or()?.[0];if(i){let e=X(i.id)?.[0];if(e){n={space:{id:i.id,name:i.name},table:{id:e.id,name:e.name,columns:e.columns},itemCount:e.columns.length},r={};for(let t=0;t<e.columns.length;t++){let n=e.columns[t];r[`COLUMN`+t]=n.id,r[`ALIAS`+t]=n.name}}}let a={type:`select_column_v1`,extraState:n,fields:r},o=p.blocks.append(a,e.workspace);t.connect(o.outputConnection)}function Hr(e){let t=e.getInput(`CONDITION`).connection;if(t.targetBlock())return;let n=p.blocks.append({type:`cond_atomic_v1`},e.workspace);t.connect(n.outputConnection)}function Ur(e){let t=e.getInput(`EXTRA`).connection;if(t.targetBlock())return;let n=p.blocks.append({type:`list_create_v1`,extraState:{itemCount:1},inputs:{ADD0:{block:{type:`query_extra_limit_v1`,inputs:{OFFSET:{shadow:{type:`math_number_v1`,fields:{NUM:0}}},LIMIT:{shadow:{type:`math_number_v1`,fields:{NUM:100}}}}}}}},e.workspace);t.connect(n.outputConnection)}function Wr(e){let t=e.getInput(`HANDLE`).connection;if(t.targetBlock())return;let n=p.blocks.append({type:`compute_debug_trace_v1`,inputs:{OBJECT:{shadow:{type:`text_v1`},block:{type:`parameter_v1`,extraState:{key:`__message__`,name:`x-runtime-lib.message`,locale:!0}}}}},e.workspace);t.connect(n.previousConnection)}a([{type:`query_data_container_v1`,message0:`%{BKY_DATA_EXTRA} %1`,args0:[{type:`field_checkbox`,name:`EXTRA`,checked:!0}],style:`procedure_blocks`}]),x.query_data_v1={init:function(){this.appendDummyInput().appendField(`%{BKY_DATA_V1_QUERY_DATA_TITLE}`),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null),this.setStyle(`procedure_blocks`),this.setTooltip(`%{BKY_DATA_V1_QUERY_DATA_TOOLTIP}`),this.setHelpUrl(`%{BKY_DATA_V1_QUERY_DATA_HELPURL}`)},saveExtraState:function(){return{}},loadExtraState:function(){this.updateShape_(),setTimeout(()=>{this.ensureBlocks_()},0)},updateShape_:function(){this.getInput(`HANDLE`)||this.appendStatementInput(`HANDLE`).appendField(`%{BKY_DATA_DO}`),this.getInput(`EXTRA_DATA`)||(this.appendValueInput(`EXTRA_DATA`),this.moveInputBefore(`EXTRA_DATA`,`HANDLE`)),this.getInput(`MAIN_DATA`)||(this.appendValueInput(`MAIN_DATA`),this.moveInputBefore(`MAIN_DATA`,`EXTRA_DATA`)),this.getInput(`MESSAGE`)||(this.appendValueInput(`MESSAGE`),this.moveInputBefore(`MESSAGE`,`MAIN_DATA`)),this.getInput(`SUCCESS`)||(this.appendValueInput(`SUCCESS`).appendField(`%{BKY_DATA_RETURN}`),this.moveInputBefore(`SUCCESS`,`MESSAGE`)),this.getInput(`EXTRA`)||(this.appendValueInput(`EXTRA`).setCheck([`QueryExtra`,`Array`]).setAlign(m.Align.RIGHT).appendField(`%{BKY_DATA_EXTRA}`),this.moveInputBefore(`EXTRA`,`SUCCESS`)),this.getInput(`CONDITION`)||(this.appendValueInput(`CONDITION`).setCheck(`Condition`).setAlign(m.Align.RIGHT).appendField(`%{BKY_DATA_CONDITION}`),this.moveInputBefore(`CONDITION`,`EXTRA`)),this.getInput(`TABLE`)||(this.appendValueInput(`TABLE`).setCheck([`SelectColumn`,`Array`]).setAlign(m.Align.RIGHT).appendField(`%{BKY_DATA_TABLE}`),this.moveInputBefore(`TABLE`,`CONDITION`))},ensureBlocks_:function(){this.isInsertionMarker()||(Vr(this),Hr(this),Ur(this),H(this,[[`SUCCESS`,`__success__`,`x-runtime-lib.success`,!0],[`MESSAGE`,`__message__`,`x-runtime-lib.message`,!0],[`MAIN_DATA`,`__mainData__`,`x-runtime-lib.mainData`,!0],[`EXTRA_DATA`,`__extraData__`,`x-runtime-lib.extraData`,!0]]),Wr(this))}},y.forBlock.query_data_v1=function(e){let t=y.INDENT;return`{
|
|
101
|
+
${t}var __tx__ = typeof(__tx__) !== 'undefined' ? __tx__ : null;
|
|
102
|
+
${t}var __table__ = ${y.valueToCode(e,`TABLE`,v.ATOMIC)||`null`};
|
|
103
|
+
${t}var __condition__ = ${y.valueToCode(e,`CONDITION`,v.ATOMIC)||`null`};
|
|
104
|
+
${t}var __extra__ = ${y.valueToCode(e,`EXTRA`,v.ATOMIC)||`null`};
|
|
105
|
+
${t}var __result__ = __queryDataV1__(__tx__, __table__, __condition__, __extra__);
|
|
106
|
+
${t}var __success__ = __result__.success;
|
|
107
|
+
${t}var __message__ = __result__.message;
|
|
108
|
+
${t}var __mainData__ = __result__.mainData;
|
|
109
|
+
${t}var __extraData__ = __result__.extraData;
|
|
110
|
+
${t}if (__tx__ && !__success__) {
|
|
111
|
+
${t}${t}throw __message__;
|
|
112
|
+
${t}}
|
|
113
|
+
${y.statementToCode(e,`HANDLE`)}}
|
|
114
|
+
`},a([{type:`query_extra_limit_v1`,message0:`%{BKY_DATA_V1_QUERY_EXTRA_LIMIT_TITLE}`,args0:[{type:`input_value`,name:`OFFSET`,check:`Number`},{type:`input_value`,name:`LIMIT`,check:`Number`}],inputsInline:!0,output:`QueryExtra`,style:`object_blocks`,tooltip:`%{BKY_DATA_V1_QUERY_EXTRA_LIMIT_TOOLTIP}`,helpUrl:`%{BKY_DATA_V1_QUERY_EXTRA_LIMIT_HELPURL}`}]),y.forBlock.query_extra_limit_v1=function(e){return[`{type:'limit',value:${y.valueToCode(e,`OFFSET`,v.ATOMIC)||0},value2:${y.valueToCode(e,`LIMIT`,v.ATOMIC)||0}}`,v.ATOMIC]},a([{type:`query_extra_sortby_v1`,message0:`%{BKY_DATA_V1_QUERY_EXTRA_SORTBY_TITLE}`,args0:[{type:`input_value`,name:`COLUMN`,check:`String`},{type:`input_value`,name:`DESC`,check:`Boolean`}],inputsInline:!0,output:`QueryExtra`,style:`object_blocks`,tooltip:`%{BKY_DATA_V1_QUERY_EXTRA_SORTBY_TOOLTIP}`,helpUrl:`%{BKY_DATA_V1_QUERY_EXTRA_SORTBY_HELPURL}`}]),y.forBlock.query_extra_sortby_v1=function(e){return[`{type:'sortby',value:${y.valueToCode(e,`COLUMN`,v.ATOMIC)||`''`},value2:${y.valueToCode(e,`DESC`,v.ATOMIC)||!1}}`,v.ATOMIC]},x.select_column_container_v1={init:function(){this.appendDummyInput().appendField(`%{BKY_DATA_LIST}`),this.appendStatementInput(`STACK`),this.setStyle(`object_blocks`),this.contextMenu=!1}},x.select_column_item_v1={init:function(){this.appendDummyInput().appendField(`%{BKY_DATA_ITEM}`),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setStyle(`object_blocks`),this.contextMenu=!1}},x.select_column_v1={init:function(){this.space={id:``,name:``},this.table={id:``,name:``,columns:[]},this.itemCount_=0,this.appendDummyInput().appendField(`%{BKY_DATA_V1_SELECT_COLUMN_TITLE}`).appendField(new C(()=>this.genSpaceOpts_()),`SPACE`).appendField(new C(()=>this.genTableOpts_()),`TABLE`),this.setMutator(new xe.MutatorIcon([`select_column_item_v1`],this)),this.setOutput(!0,`SelectColumn`),this.setStyle(`object_blocks`),this.setTooltip(`%{BKY_DATA_V1_SELECT_COLUMN_TOOLTIP}`),this.setHelpUrl(`%{BKY_DATA_V1_SELECT_COLUMN_HELPURL}`),this.initData_(),this.initShape_()},initData_:function(){if(this.space.id)return;let e=Or()?.[0];if(!e)return;this.space.id=e.id,this.space.name=e.name;let t=this.getField(`SPACE`);t.getOptions(!1),t.setValue(this.space.id,!1);let n=X(this.space.id)?.[0];if(!n)return;this.table.id=n.id,this.table.name=n.name,this.table.columns=n.columns;let r=this.getField(`TABLE`);r.getOptions(!1),r.setValue(this.table.id,!1),this.itemCount_=n.columns.length},saveExtraState:function(){return{space:this.space,table:this.table,itemCount:this.itemCount_}},loadExtraState:function(e){this.space.id=e.space?.id??``,this.space.name=e.space?.name??``,this.table.id=e.table?.id??``,this.table.name=e.table?.name??``,this.table.columns=e.table?.columns??[],this.itemCount_=e.itemCount??0,this.updateShape_(),setTimeout(()=>{this.checkWarning_()},0)},genSpaceOpts_:function(){return Ar()},genTableOpts_:function(){return Mr(this.space.id)},genColumnOpts_:function(){let e=[];return this.table.columns.forEach(({id:t,name:n})=>{e.push([n,t])}),L(e)},onchange:function(e){if(e.type===b.BLOCK_CHANGE){let t=e;if(t.blockId===this.id){if(t.element===`field`){if(t.name===`SPACE`)this.onSpaceChange_(t.newValue);else if(t.name===`TABLE`)this.onTableChange_(t.newValue);else if(t.name?.startsWith(`COLUMN`)){let e=parseInt(t.name.substring(6));this.onColumnChange_(e,t.newValue)}}setTimeout(()=>{this.checkWarning_()},0)}}},onSpaceChange_:function(e){let t=kr(e);if(!t){console.assert(!1);return}let n=t.id!==this.space.id;this.space.id=t.id,this.space.name=t.name;let r=this.getField(`TABLE`);if(r.getOptions(!1),n){let e=X(this.space.id)?.[0];r.setValue(e?.id??``)}this.onTableChange_(r.getValue())},onTableChange_:function(e){let t=jr(this.space.id,e);if(!t){console.assert(!1);return}this.table.id=t.id,this.table.name=t.name,this.table.columns=t.columns,this.itemCount_=t.columns.length,this.updateShape_();for(let e=0;e<t.columns.length;e++){let{id:n,name:r}=t.columns[e],i=this.getField(`COLUMN`+e);i.getOptions(!1),i.setValue(n,!1),this.getField(`ALIAS`+e).setValue(r,!1)}},onColumnChange_:function(e,t){let n=this.table.columns.find(e=>e.id===t);if(!n){console.assert(!1);return}this.setFieldValue(n.name,`ALIAS`+e)},decompose:function(e){let t=e.newBlock(`select_column_container_v1`);t.initSvg();let n=t.getInput(`STACK`).connection;for(let t=0;t<this.itemCount_;t++){let t=e.newBlock(`select_column_item_v1`);t.initSvg(),n.connect(t.previousConnection),n=t.nextConnection}return t},compose:function(e){let t=e.getInputTargetBlock(`STACK`),n=[],r=[];for(;t;){if(t.isInsertionMarker()){t=t.getNextBlock();continue}n.push(t.column_),r.push(t.alias_),t=t.getNextBlock()}this.itemCount_=n.length,this.updateShape_();for(let e=0;e<this.itemCount_;e++){let t=n[e]??this.table.columns[0]?.id??``,i=r[e]??this.table.columns[0]?.name??``;this.getField(`COLUMN`+e).setValue(t,!1),this.getField(`ALIAS`+e).setValue(i,!1)}setTimeout(()=>{this.checkWarning_()},0)},saveConnections:function(e){let t=e.getInputTargetBlock(`STACK`),n=0;for(;t;){if(t.isInsertionMarker()){t=t.getNextBlock();continue}t.column_=this.getFieldValue(`COLUMN`+n),t.alias_=this.getFieldValue(`ALIAS`+n),t=t.getNextBlock(),n++}},initShape_:function(){if(!this.isInFlyout&&!this.getInput(`ADD0`))for(let e=0;e<this.table.columns.length;e++){let t=this.table.columns[e],r=new C(()=>this.genColumnOpts_()),i=new n(``);this.appendDummyInput(`ADD`+e).setAlign(m.Align.RIGHT).appendField(r,`COLUMN`+e).appendField(`%{BKY_DATA_AS}`).appendField(i,`ALIAS`+e),r.setValue(t.id,!1),i.setValue(t.name,!1)}},updateShape_:function(){for(let e=this.itemCount_;this.getInput(`ADD`+e);e++)this.removeInput(`ADD`+e);for(let e=0;e<this.itemCount_;e++){if(this.getInput(`ADD`+e))continue;let t=new C(()=>this.genColumnOpts_()),r=new n(``);this.appendDummyInput(`ADD`+e).setAlign(m.Align.RIGHT).appendField(t,`COLUMN`+e).appendField(`%{BKY_DATA_AS}`).appendField(r,`ALIAS`+e);let i=this.table.columns[0];t.setValue(i.id??``,!1),r.setValue(i.name??``,!1)}},checkWarning_:function(){let e=kr(this.space.id);if(!e){this.setWarningText(I(`WARN_SPACE_NOT_FOUND`));return}e.name!==this.space.name&&(this.space.name=e.name);let t=jr(this.space.id,this.table.id);if(!t){this.setWarningText(I(`WARN_TABLE_NOT_FOUND`));return}if(t.name!==this.table.name&&(this.table.name=t.name),!_(t.columns,this.table.columns)){this.setWarningText(I(`WARN_TABLE_HAS_CHANGED`));return}this.setWarningText(null)}},y.forBlock.select_column_v1=function(e){let t=y.quote_,n=e,r=n.space.id,i=n.table.id,a=[];for(let e=0;e<n.itemCount_;e++){let t=n.getFieldValue(`COLUMN`+e),r=n.table.columns.find(e=>e.id===t).name,i=n.getFieldValue(`ALIAS`+e);a.push({name:r,alias:i})}let o=`[`;return a.forEach(({name:e,alias:n},r)=>{r!==0&&(o+=`,`),o+=`{name:${t(e)},alias:${t(n)}}`}),o+=`]`,[`{spaceId:${t(r)},tableId:${t(i)},columns:${o}}`,v.ATOMIC]},x.select_table_v1={init:function(){this.space={id:``,name:``},this.table={id:``,name:``},this.appendDummyInput().appendField(`%{BKY_DATA_V1_SELECT_TABLE_TITLE}`).appendField(new C(()=>this.genSpaceOpts_()),`SPACE`).appendField(new C(()=>this.genTableOpts_()),`TABLE`),this.setOutput(!0,`SelectTable`),this.setStyle(`object_blocks`),this.setTooltip(`%{BKY_DATA_V1_SELECT_TABLE_TOOLTIP}`),this.setHelpUrl(`%{BKY_DATA_V1_SELECT_TABLE_HELPURL}`),this.initData_()},initData_:function(){if(this.space.id)return;let e=Or()?.[0];if(!e)return;this.space.id=e.id,this.space.name=e.name;let t=this.getField(`SPACE`);t.getOptions(!1),t.setValue(this.space.id);let n=X(this.space.id)?.[0];if(!n)return;this.table.id=n.id,this.table.name=n.name;let r=this.getField(`TABLE`);r.getOptions(!1),r.setValue(this.table.id)},saveExtraState:function(){return{space:this.space,table:this.table}},loadExtraState:function(e){this.space.id=e.space?.id??``,this.space.name=e.space?.name??``,this.table.id=e.table?.id??``,this.table.name=e.table?.name??``,this.checkWarning_()},genSpaceOpts_:function(){return Ar()},genTableOpts_:function(){return Mr(this.space.id)},onchange:function(e){if(e.type===b.BLOCK_CHANGE){let t=e;t.blockId===this.id&&(t.element===`field`&&(t.name===`SPACE`?this.onSpaceChange_(t.newValue):t.name===`TABLE`&&this.onTableChange_(t.newValue)),setTimeout(()=>{this.checkWarning_()},0))}},onSpaceChange_:function(e){let t=kr(e);if(!t){console.assert(!1);return}let n=t.id!==this.space.id;this.space.id=t.id,this.space.name=t.name;let r=this.getField(`TABLE`);if(r.getOptions(!1),n){let e=X(this.space.id)?.[0];r.setValue(e?.id??``)}this.onTableChange_(r.getValue())},onTableChange_:function(e){let t=jr(this.space.id,e);if(!t){console.assert(!1);return}this.table.id=t.id,this.table.name=t.name},checkWarning_:function(){let e=kr(this.space.id);if(!e){this.setWarningText(I(`WARN_SPACE_NOT_FOUND`));return}e.name!==this.space.name&&(this.space.name=e.name);let t=jr(this.space.id,this.table.id);if(!t){this.setWarningText(I(`WARN_TABLE_NOT_FOUND`));return}t.name!==this.table.name&&(this.table.name=t.name),this.setWarningText(null)}},y.forBlock.select_table_v1=function(e){let t=y.quote_,n=e,r=n.space.id,i=n.table.id;return[`{spaceId:${t(r)},tableId:${t(i)}}`,v.ATOMIC]},x.transaction_v1={init:function(){this.appendDummyInput().appendField(`%{BKY_DATA_V1_TRANSACTION_TITLE}`),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null),this.setStyle(`procedure_blocks`),this.setTooltip(`%{BKY_DATA_V1_TRANSACTION_TOOLTIP}`),this.setHelpUrl(`%{BKY_DATA_V1_TRANSACTION_HELPURL}`)},saveExtraState:function(){return{}},loadExtraState:function(){this.updateShape_(),setTimeout(()=>{this.ensureBlocks_()},0)},updateShape_:function(){this.getInput(`FINALLY`)||this.appendStatementInput(`FINALLY`).appendField(`%{BKY_DATA_FINALLY}`),this.getInput(`MESSAGE`)||(this.appendValueInput(`MESSAGE`),this.moveInputBefore(`MESSAGE`,`FINALLY`)),this.getInput(`SUCCESS`)||(this.appendValueInput(`SUCCESS`),this.moveInputBefore(`SUCCESS`,`MESSAGE`)),this.getInput(`HANDLE`)||(this.appendStatementInput(`HANDLE`).appendField(`%{BKY_DATA_DO}`),this.moveInputBefore(`HANDLE`,`SUCCESS`))},ensureBlocks_:function(){this.isInsertionMarker()||H(this,[[`SUCCESS`,`__success__`,`x-runtime-lib.success`,!0],[`MESSAGE`,`__message__`,`x-runtime-lib.message`,!0]])}},y.forBlock.transaction_v1=function(e){let t=y.INDENT,n=e,r=Yt(n),i=y.statementToCode(n,`HANDLE`),a=y.statementToCode(n,`FINALLY`);return`{
|
|
115
|
+
${t}var __error${r}__ = '';
|
|
116
|
+
${t}var __txExist${r}__ = typeof(__tx__) !== 'undefined';
|
|
117
|
+
${t}var __tx__ = __txExist${r}__ ? __tx__ : __txBeginV1__();
|
|
118
|
+
${t}var __spName${r}__ = 'savePoint${r}';
|
|
119
119
|
${t}try {
|
|
120
120
|
${t}${t}if (!__tx__) {
|
|
121
121
|
${t}${t}${t}throw 'begin transaction failed';
|
|
122
122
|
${t}${t}}
|
|
123
|
-
${t}${t}if (__txExist${
|
|
124
|
-
${t}${t}${t}if (__txSavePointV1__(__tx__, __spName${
|
|
123
|
+
${t}${t}if (__txExist${r}__) {
|
|
124
|
+
${t}${t}${t}if (__txSavePointV1__(__tx__, __spName${r}__)) {
|
|
125
125
|
${t}${t}${t}${t}throw 'save point of transaction failed';
|
|
126
126
|
${t}${t}${t}}
|
|
127
127
|
${t}${t}}
|
|
128
|
-
${
|
|
129
|
-
${t}${t}__error${
|
|
128
|
+
${y.prefixLines(i,t)}${t}} catch (__e__) {
|
|
129
|
+
${t}${t}__error${r}__ = __e__ ? __e__ : 'transaction interrupted';
|
|
130
130
|
${t}} finally {
|
|
131
|
-
${t}${t}if (__txExist${
|
|
132
|
-
${t}${t}${t}if (__error${
|
|
133
|
-
${t}${t}${t}${t}__txRollbackToV1__(__tx__, __spName${
|
|
131
|
+
${t}${t}if (__txExist${r}__) {
|
|
132
|
+
${t}${t}${t}if (__error${r}__) {
|
|
133
|
+
${t}${t}${t}${t}__txRollbackToV1__(__tx__, __spName${r}__);
|
|
134
134
|
${t}${t}${t}}
|
|
135
135
|
${t}${t}} else {
|
|
136
136
|
${t}${t}${t}if(__tx__) {
|
|
137
|
-
${t}${t}${t}${t}if (__error${
|
|
137
|
+
${t}${t}${t}${t}if (__error${r}__) {
|
|
138
138
|
${t}${t}${t}${t}${t}__txRollbackV1__(__tx__);
|
|
139
139
|
${t}${t}${t}${t}} else {
|
|
140
140
|
${t}${t}${t}${t}${t}if (__txCommitV1__(__tx__)) {
|
|
141
|
-
${t}${t}${t}${t}${t}${t}__error${
|
|
141
|
+
${t}${t}${t}${t}${t}${t}__error${r}__ = 'commit transaction failed';
|
|
142
142
|
${t}${t}${t}${t}${t}}
|
|
143
143
|
${t}${t}${t}${t}}
|
|
144
144
|
${t}${t}${t}}
|
|
145
145
|
${t}${t}}
|
|
146
|
-
${t}${t}var __success__ = !__error${
|
|
147
|
-
${t}${t}var __message__ = __error${
|
|
148
|
-
${
|
|
149
|
-
${t}${t}${t}throw __error${
|
|
146
|
+
${t}${t}var __success__ = !__error${r}__;
|
|
147
|
+
${t}${t}var __message__ = __error${r}__ ? __error${r}__ : 'success';
|
|
148
|
+
${y.prefixLines(a,t)}${t}${t}if (__txExist${r}__ && __error${r}__) {
|
|
149
|
+
${t}${t}${t}throw __error${r}__;
|
|
150
150
|
${t}${t}}
|
|
151
151
|
${t}}
|
|
152
152
|
}
|
|
153
|
-
`}
|
|
154
|
-
${
|
|
155
|
-
${
|
|
156
|
-
${
|
|
157
|
-
${
|
|
158
|
-
${
|
|
159
|
-
${
|
|
160
|
-
${
|
|
161
|
-
${
|
|
162
|
-
${
|
|
163
|
-
${
|
|
164
|
-
${
|
|
165
|
-
`};const ti=e.utils.xml,ni={init:function(){this.length=0,this.appendDummyInput(`OPEN_BRACKET`).appendField(` [ `),this.appendDummyInput(`ADD`).setAlign(e.inputs.Align.CENTRE).appendField(new e.FieldImage(gt,20,20,void 0,()=>{this.isInFlyout||this.addEntry_()})),this.appendDummyInput(`CLOSE_BRACKET`).appendField(` ] `),this.setInputsInline(!1),this.setOutput(!0,`JsonArray`),this.setColour(350),this.setTooltip(``),this.setHelpUrl(``)},mutationToDom:function(){let e=ti.createElement(`mutation`);return e.setAttribute(`items`,String(this.length)),e},domToMutation:function(e){this.length=De(e.getAttribute(`items`)??``,0),this.initShape_()},initData:function(e){this.length=e,this.initShape_()},initShape_:function(){for(let t=0;t<this.length;t++){let n=`ENTRY`+t,r=this.appendValueInput(n);r.appendField(new e.FieldImage(gt,20,20,void 0,()=>{this.isInFlyout||this.addEntry_(r)})),r.appendField(new e.FieldLabel(String(t))),r.appendField(new e.FieldImage(_t,20,20,void 0,()=>{this.isInFlyout||this.removeEntry_(r)})),this.moveInputBefore(n,`ADD`)}},addEntry_:function(t){let n=this.length;t&&(n=De(t.name.substring(5)));for(let e=this.length-1;e>=n;e--){let t=this.getInput(`ENTRY`+e);t.name=`ENTRY`+(e+1),t.fieldRow[1].setValue(e+1)}let r=this.appendValueInput(`ENTRY`+n);r.appendField(new e.FieldImage(gt,20,20,void 0,()=>{this.isInFlyout||this.addEntry_(r)})),r.appendField(new e.FieldLabel(String(n))),r.appendField(new e.FieldImage(_t,20,20,void 0,()=>{this.isInFlyout||this.removeEntry_(r)})),n===this.length?this.moveInputBefore(`ENTRY`+n,`ADD`):this.moveInputBefore(`ENTRY`+n,`ENTRY`+(n+1)),this.length++},removeEntry_:function(e){let t=e.name,n=this.getInputTargetBlock(t);n&&n.dispose(),this.removeInput(t);let r=De(t.substring(5));for(let e=r+1;e<this.length;e++){let t=this.getInput(`ENTRY`+e);t.name=`ENTRY`+(e-1),t.fieldRow[1].setValue(e-1)}this.length--}};e.Blocks.json_array_v1=ni;const ri={init:function(){this.appendDummyInput().appendField(new e.FieldDropdown([[`false`,`false`],[`true`,`true`]]),`VALUE`),this.setOutput(!0,`JsonBoolean`),this.setColour(210)}};e.Blocks.json_boolean_v1=ri;const ii=e.utils.xml,ai={init:function(){this.length=0,this.appendDummyInput(`OPEN_BRACKET`).appendField(` { `),this.appendDummyInput(`ADD`).setAlign(e.inputs.Align.CENTRE).appendField(new e.FieldImage(gt,20,20,void 0,()=>{this.isInFlyout||this.addEntry_()})),this.appendDummyInput(`CLOSE_BRACHET`).appendField(` } `),this.setInputsInline(!1),this.setOutput(!0,`JsonMap`),this.setColour(120),this.setTooltip(``),this.setHelpUrl(``)},mutationToDom:function(){let e=ii.createElement(`mutation`);for(let t=0;t<this.length;t++){let n=ii.createElement(`item`);n.setAttribute(`key`,this.getFieldValue(`KEY`+t)),e.appendChild(n)}return e},domToMutation:function(e){let t=[];for(let n=0;n<e.childNodes.length;n++){let r=e.childNodes[n].getAttribute(`key`);r&&t.push(r)}this.length=t.length,this.initShape_(t)},initData:function(e){this.length=e.length,this.initShape_(e)},initShape_:function(t){for(let n=0;n<t.length;n++){let r=t[n],i=`ENTRY`+n,a=this.appendValueInput(i);a.appendField(new e.FieldImage(gt,20,20,void 0,()=>{this.isInFlyout||this.addEntry_(a)})),a.appendField(new e.FieldTextInput(r),`KEY`+n),a.appendField(new e.FieldImage(_t,20,20,void 0,()=>{this.isInFlyout||this.removeEntry_(a)})),this.moveInputBefore(i,`ADD`)}},addEntry_:function(t){let n=this.length;t&&(n=De(t.name.substring(5)));for(let e=this.length-1;e>=n;e--)this.getField(`KEY`+e).name=`KEY`+(e+1),this.getInput(`ENTRY`+e).name=`ENTRY`+(e+1);let r=this.appendValueInput(`ENTRY`+n);r.appendField(new e.FieldImage(gt,20,20,void 0,()=>{this.isInFlyout||this.addEntry_(r)})),r.appendField(new e.FieldTextInput(`key`),`KEY`+n),r.appendField(new e.FieldImage(_t,20,20,void 0,()=>{this.isInFlyout||this.removeEntry_(r)})),n===this.length?this.moveInputBefore(`ENTRY`+n,`ADD`):this.moveInputBefore(`ENTRY`+n,`ENTRY`+(n+1)),this.length++},removeEntry_:function(e){let t=e.name,n=this.getInputTargetBlock(t);n&&n.dispose(),this.removeInput(t);let r=De(t.substring(5));for(let e=r+1;e<this.length;e++)this.getField(`KEY`+e).name=`KEY`+(e-1),this.getInput(`ENTRY`+e).name=`ENTRY`+(e-1);this.length--}};e.Blocks.json_map_v1=ai;const oi={init:function(){this.appendDummyInput().appendField(new e.FieldNumber(0),`VALUE`),this.setOutput(!0,`JsonNumber`),this.setColour(230)}};e.Blocks.json_number_v1=oi;const si={init:function(){this.appendDummyInput().setAlign(e.inputs.Align.CENTRE).appendField(`JSON`),this.appendValueInput(`JSON`).setCheck([`JsonMap`,`JsonArray`]),this.setDeletable(!1),this.setColour(250),this.setTooltip(``),this.setHelpUrl(``)}};e.Blocks.json_root_v1=si;const ci={init:function(){this.appendDummyInput().appendField(`"`).appendField(new e.FieldTextInput(``),`VALUE`).appendField(`"`),this.setOutput(!0,`JsonString`),this.setColour(160)}};e.Blocks.json_string_v1=ci;const li=e.utils.xml,ui={init:function(){this.appendDummyInput().appendField(`%{BKY_LIST_V1_CREATE_CONTAINER_TITLE}`),this.appendStatementInput(`STACK`),this.setStyle(`list_blocks`),this.contextMenu=!1}};e.Blocks.list_create_container_v1=ui;const di={init:function(){this.appendDummyInput().appendField(`%{BKY_LIST_V1_CREATE_ITEM_TITLE}`),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setStyle(`list_blocks`),this.contextMenu=!1}};e.Blocks.list_create_item_v1=di;const fi={init:function(){this.itemCount_=0,this.setMutator(new e.icons.MutatorIcon([`list_create_item_v1`],this)),this.setOutput(!0,`Array`),this.setStyle(`list_blocks`),this.setTooltip(`%{BKY_LIST_V1_CREATE_TOOLTIP}`),this.setHelpUrl(`%{BKY_LIST_V1_CREATE_HELPURL}`),this.updateShape_()},mutationToDom:function(){let e=li.createElement(`mutation`);return e.setAttribute(`items`,String(this.itemCount_)),e},domToMutation:function(e){let t=e.getAttribute(`items`)??``;this.itemCount_=parseInt(t,0),this.updateShape_()},saveExtraState:function(){return{itemCount:this.itemCount_}},loadExtraState:function(e){this.itemCount_=e.itemCount??0,this.updateShape_()},decompose:function(e){let t=e.newBlock(`list_create_container_v1`);t.initSvg();let n=t.getInput(`STACK`).connection;for(let t=0;t<this.itemCount_;t++){let t=e.newBlock(`list_create_item_v1`);t.initSvg(),n.connect(t.previousConnection),n=t.nextConnection}return t},compose:function(e){let t=e.getInputTargetBlock(`STACK`),n=[];for(;t;){if(t.isInsertionMarker()){t=t.getNextBlock();continue}n.push(t.valueConnection_),t=t.getNextBlock()}for(let e=0;e<this.itemCount_;e++){let t=this.getInput(`ADD`+e).connection.targetConnection;t&&!n.includes(t)&&t.disconnect()}this.itemCount_=n.length,this.updateShape_();for(let e=0;e<this.itemCount_;e++)n[e]?.reconnect(this,`ADD`+e)},saveConnections:function(e){let t=e.getInputTargetBlock(`STACK`),n=0;for(;t;){if(t.isInsertionMarker()){t=t.getNextBlock();continue}let e=this.getInput(`ADD`+n);t.valueConnection_=e?.connection.targetConnection,t=t.getNextBlock(),n++}},updateShape_:function(){this.itemCount_&&this.getInput(`EMPTY`)?this.removeInput(`EMPTY`):!this.itemCount_&&!this.getInput(`EMPTY`)&&this.appendDummyInput(`EMPTY`).appendField(`%{BKY_LIST_V1_CREATE_TITLE}`);for(let t=0;t<this.itemCount_;t++)this.getInput(`ADD`+t)||(this.appendValueInput(`ADD`+t).setCheck([`String`,`Number`,`Boolean`,`Array`,`Object`]),t===0&&this.getInput(`ADD`+t).setAlign(e.inputs.Align.RIGHT).appendField(`%{BKY_LIST_V1_CREATE_TITLE}`));for(let e=this.itemCount_;this.getInput(`ADD`+e);e++)this.removeInput(`ADD`+e)}};e.Blocks.list_create_v1=fi,n.forBlock.list_create_v1=function(e){let r=e,i=Array(r.itemCount_);for(let e=0;e<r.itemCount_;e++)i[e]=n.valueToCode(r,`ADD`+e,t.NONE)||`null`;return[`[`+i.join(`, `)+`]`,t.ATOMIC]},e.defineBlocksWithJsonArray([{type:`list_delete_v1`,message0:`%{BKY_LIST_V1_DELETE_TITLE}`,args0:[{type:`input_value`,name:`VALUE`,check:`Array`},{type:`input_value`,name:`AT`,check:`Number`}],inputsInline:!0,previousStatement:null,nextStatement:null,style:`list_blocks`,tooltip:`%{BKY_LIST_V1_DELETE_TOOLTIP}`,helpUrl:`%{BKY_LIST_V1_DELETE_HELPURL}`}]),n.forBlock.list_delete_v1=function(e){return`${n.valueToCode(e,`VALUE`,t.MEMBER)||`[]`}.splice(${n.getAdjusted(e,`AT`)}, 1)`},e.defineBlocksWithJsonArray([{type:`list_get_v1`,message0:`%{BKY_LIST_V1_GET_TITLE}`,args0:[{type:`input_value`,name:`VALUE`,check:`Array`},{type:`input_value`,name:`AT`,check:`Number`}],inputsInline:!0,output:null,style:`list_blocks`,tooltip:`%{BKY_LIST_V1_GET_TOOLTIP}`,helpUrl:`%{BKY_LIST_V1_GET_HELPURL}`}]),n.forBlock.list_get_v1=function(e){return[`${n.valueToCode(e,`VALUE`,t.MEMBER)||`[]`}[${n.getAdjusted(e,`AT`)}]`,t.MEMBER]},e.defineBlocksWithJsonArray([{type:`list_get_sublist_v1`,message0:`%{BKY_LIST_V1_GET_SUBLIST_TITLE}`,args0:[{type:`input_value`,name:`LIST`,check:`Array`},{type:`input_value`,name:`START`,check:`Number`},{type:`input_value`,name:`END`,check:`Number`}],inputsInline:!0,output:`Array`,style:`list_blocks`,tooltip:`%{BKY_LIST_V1_GET_SUBLIST_TOOLTIP}`,helpUrl:`%{BKY_LIST_V1_GET_SUBLIST_HELPURL}`}]),n.forBlock.list_get_sublist_v1=function(e){return[`${n.valueToCode(e,`LIST`,t.MEMBER)||`[]`}.slice(${n.getAdjusted(e,`START`)}, ${n.getAdjusted(e,`END`,1)})`,t.FUNCTION_CALL]},e.defineBlocksWithJsonArray([{type:`list_is_empty_v1`,message0:`%{BKY_LIST_V1_IS_EMPTY_TITLE}`,args0:[{type:`input_value`,name:`VALUE`,check:`Array`}],output:`Boolean`,style:`list_blocks`,tooltip:`%{BKY_LIST_V1_IS_EMPTY_TOOLTIP}`,helpUrl:`%{BKY_LIST_V1_IS_EMPTY_HELPURL}`}]),n.forBlock.list_is_empty_v1=function(e){return[`!${n.valueToCode(e,`VALUE`,t.MEMBER)||`[]`}.length`,t.LOGICAL_NOT]},e.defineBlocksWithJsonArray([{type:`list_join_v1`,message0:`%{BKY_LIST_V1_JOIN_TITLE}`,args0:[{type:`input_value`,name:`LIST`,check:`Array`},{type:`input_value`,name:`DELIM`,check:`String`}],inputsInline:!0,output:`String`,style:`list_blocks`,tooltip:`%{BKY_LIST_V1_JOIN_TOOLTIP}`,helpUrl:`%{BKY_LIST_V1_JOIN_HELPURL}`}]),n.forBlock.list_join_v1=function(e){return[`${n.valueToCode(e,`LIST`,t.MEMBER)||`[]`}.join(${n.valueToCode(e,`DELIM`,t.NONE)||`''`})`,t.FUNCTION_CALL]},e.defineBlocksWithJsonArray([{type:`list_length_v1`,message0:`%{BKY_LIST_V1_LENGTH_TITLE}`,args0:[{type:`input_value`,name:`VALUE`,check:`Array`}],output:`Number`,style:`list_blocks`,tooltip:`%{BKY_LIST_V1_LENGTH_TOOLTIP}`,helpUrl:`%{BKY_LIST_V1_LENGTH_HELPURL}`}]),n.forBlock.list_length_v1=function(e){return[`${n.valueToCode(e,`VALUE`,t.MEMBER)||`[]`}.length`,t.MEMBER]},e.defineBlocksWithJsonArray([{type:`list_reverse_v1`,message0:`%{BKY_LIST_V1_REVERSE_TITLE}`,args0:[{type:`input_value`,name:`LIST`,check:`Array`}],inputsInline:!0,output:`Array`,style:`list_blocks`,tooltip:`%{BKY_LIST_V1_REVERSE_TOOLTIP}`,helpUrl:`%{BKY_LIST_V1_REVERSE_HELPURL}`}]),n.forBlock.list_reverse_v1=function(e){return[`${n.valueToCode(e,`LIST`,t.NONE)||`[]`}.slice().reverse()`,t.FUNCTION_CALL]},e.defineBlocksWithJsonArray([{type:`list_set_v1`,message0:`%{BKY_LIST_V1_SET_TITLE}`,args0:[{type:`input_value`,name:`LIST`,check:`Array`},{type:`input_value`,name:`AT`,check:`Number`},{type:`input_value`,name:`VALUE`,check:null}],inputsInline:!0,previousStatement:null,nextStatement:null,style:`list_blocks`,tooltip:`%{BKY_LIST_V1_SET_TOOLTIP}`,helpUrl:`%{BKY_LIST_V1_SET_HELPURL}`}]),n.forBlock.list_set_v1=function(e){return`${n.valueToCode(e,`LIST`,t.MEMBER)||`[]`}[${n.getAdjusted(e,`AT`)}] = ${n.valueToCode(e,`VALUE`,t.ASSIGNMENT)||`null`};\n`},e.Extensions.register(`logic_op_tooltip_v1`,e.Extensions.buildTooltipForDropdown(`OP`,{EQ:`%{BKY_LOGIC_V1_COMPARE_TOOLTIP_EQ}`,NEQ:`%{BKY_LOGIC_V1_COMPARE_TOOLTIP_NEQ}`,LT:`%{BKY_LOGIC_V1_COMPARE_TOOLTIP_LT}`,LTE:`%{BKY_LOGIC_V1_COMPARE_TOOLTIP_LTE}`,GT:`%{BKY_LOGIC_V1_COMPARE_TOOLTIP_GT}`,GTE:`%{BKY_LOGIC_V1_COMPARE_TOOLTIP_GTE}`,AND:`%{BKY_LOGIC_V1_OPERATION_TOOLTIP_AND}`,OR:`%{BKY_LOGIC_V1_OPERATION_TOOLTIP_OR}`})),e.defineBlocksWithJsonArray([{type:`logic_boolean_v1`,message0:`%1`,args0:[{type:`field_dropdown`,name:`BOOL`,options:[[`%{BKY_LOGIC_BOOLEAN_FALSE}`,`FALSE`],[`%{BKY_LOGIC_BOOLEAN_TRUE}`,`TRUE`]]}],output:`Boolean`,style:`logic_blocks`,tooltip:`%{BKY_LOGIC_V1_BOOLEAN_TOOLTIP}`,helpUrl:`%{BKY_LOGIC_V1_BOOLEAN_HELPURL}`}]),n.forBlock.logic_boolean_v1=function(e){return[e.getFieldValue(`BOOL`)===`TRUE`?`true`:`false`,t.ATOMIC]};const pi={onchange:function(t){this.prevBlocks_||=[null,null];let n=this.getInputTargetBlock(`A`),r=this.getInputTargetBlock(`B`);if(n&&r&&!this.workspace.connectionChecker.doTypeChecks(n.outputConnection,r.outputConnection)){e.Events.setGroup(t.group);let i=this.prevBlocks_[0];i!==n&&(n.unplug(),i&&!i.isDisposed()&&!i.isShadow()&&this.getInput(`A`).connection.connect(i.outputConnection));let a=this.prevBlocks_[1];a!==r&&(r.unplug(),a&&!a.isDisposed()&&!a.isShadow()&&this.getInput(`B`).connection.connect(a.outputConnection)),this.bumpNeighbours(),e.Events.setGroup(!1)}this.prevBlocks_[0]=this.getInputTargetBlock(`A`),this.prevBlocks_[1]=this.getInputTargetBlock(`B`)}};e.Extensions.register(`logic_compare_v1`,function(){this.mixin(pi)}),e.defineBlocksWithJsonArray([{type:`logic_compare_v1`,message0:`%1 %2 %3`,args0:[{type:`input_value`,name:`A`},{type:`field_dropdown`,name:`OP`,options:[[`=`,`EQ`],[`≠`,`NEQ`],[`<`,`LT`],[`≤`,`LTE`],[`>`,`GT`],[`≥`,`GTE`]]},{type:`input_value`,name:`B`}],inputsInline:!0,output:`Boolean`,style:`logic_blocks`,helpUrl:`%{BKY_LOGIC_V1_COMPARE_HELPURL}`,extensions:[`logic_compare_v1`,`logic_op_tooltip_v1`]}]),n.forBlock.logic_compare_v1=function(e){let r={EQ:`==`,NEQ:`!=`,LT:`<`,LTE:`<=`,GT:`>`,GTE:`>=`}[e.getFieldValue(`OP`)],i=t.RELATIONAL;return(r===`==`||r===`!=`)&&(i=t.EQUALITY),[`${n.valueToCode(e,`A`,i)||`0`} ${r} ${n.valueToCode(e,`B`,i)||`0`}`,i]},e.Extensions.registerMutator(`logic_if_v1_mutator`,{elseIfCount_:0,hasElse_:!1,mutationToDom:function(){if(this.elseIfCount_<=0&&!this.hasElse_)return null;let t=e.utils.xml.createElement(`mutation`);return this.elseIfCount_>0&&t.setAttribute(`elseIf`,String(this.elseIfCount_)),this.hasElse_&&t.setAttribute(`else`,`TRUE`),t},domToMutation:function(e){this.elseIfCount_=parseInt(e.getAttribute(`elseif`),10)||0,this.hasElse_=e.getAttribute(`else`)===`TRUE`,this.rebuildShape_()},saveExtraState:function(){if(this.elseIfCount_<=0&&!this.hasElse_)return null;let e=Object.create(null);return this.elseIfCount_>0&&(e.elseIfCount=this.elseIfCount_),this.hasElse_&&(e.hasElse=!0),e},loadExtraState:function(e){this.elseIfCount_=e.elseIfCount||0,this.hasElse_=!!e.hasElse,this.updateShape_()},decompose:function(e){let t=e.newBlock(`logic_if_if_v1`);t.initSvg();let n=t.nextConnection;for(let t=0;t<this.elseIfCount_;t++){let t=e.newBlock(`logic_if_else_if_v1`);t.initSvg(),n.connect(t.previousConnection),n=t.nextConnection}if(this.hasElse_){let t=e.newBlock(`logic_if_else_v1`);t.initSvg(),n.connect(t.previousConnection)}return t},compose:function(e){let t=e.nextConnection.targetBlock();this.elseIfCount_=0,this.hasElse_=!1;let n=[null],r=[null],i=null;for(;t;){if(t.isInsertionMarker()){t=t.getNextBlock();continue}switch(t.type){case`logic_if_else_if_v1`:this.elseIfCount_++,n.push(t.valueConnection_),r.push(t.statementConnection_);break;case`logic_if_else_v1`:this.hasElse_=!0,i=t.statementConnection_;break;default:throw TypeError(`Unknown block type: `+t.type)}t=t.getNextBlock()}this.updateShape_(),this.reconnectChildBlocks_(n,r,i)},saveConnections:function(e){let t=e.nextConnection.targetBlock(),n=1;for(;t;){if(t.isInsertionMarker()){t=t.getNextBlock();continue}switch(t.type){case`Logic_if_else_if_v1`:{let e=this.getInput(`IF`+n),r=this.getInput(`DO`+n);t.valueConnection_=e&&e.connection.targetConnection,t.statementConnection_=r&&r.connection.targetConnection,n++;break}case`logic_if_else_v1`:{let e=this.getInput(`ELSE`);t.statementConnection_=e&&e.connection.targetConnection;break}default:throw TypeError(`Unknown block type: `+t.type)}t=t.getNextBlock()}},rebuildShape_:function(){let e=[null],t=[null],n=null;this.getInput(`ELSE`)&&(n=this.getInput(`ELSE`).connection.targetConnection);for(let n=1;this.getInput(`IF`+n);n++){let r=this.getInput(`IF`+n),i=this.getInput(`DO`+n);e.push(r.connection.targetConnection),t.push(i.connection.targetConnection)}this.updateShape_(),this.reconnectChildBlocks_(e,t,n)},updateShape_:function(){this.getInput(`ELSE`)&&this.removeInput(`ELSE`);for(let e=1;this.getInput(`IF`+e);e++)this.removeInput(`IF`+e),this.removeInput(`DO`+e);for(let e=1;e<=this.elseIfCount_;e++)this.appendValueInput(`IF`+e).setCheck(`Boolean`).appendField(M(`LOGIC_ELSE_IF`)),this.appendStatementInput(`DO`+e).appendField(M(`LOGIC_DO`));this.hasElse_&&this.appendStatementInput(`ELSE`).appendField(M(`LOGIC_ELSE`))},reconnectChildBlocks_:function(e,t,n){for(let n=1;n<=this.elseIfCount_;n++)e[n]?.reconnect(this,`IF`+n),t[n]?.reconnect(this,`DO`+n);n?.reconnect(this,`ELSE`)}},void 0,[`logic_if_else_if_v1`,`logic_if_else_v1`]),e.defineBlocksWithJsonArray([{type:`logic_if_v1`,message0:`%{BKY_LOGIC_IF} %1`,args0:[{type:`input_value`,name:`IF0`,check:`Boolean`}],message1:`%{BKY_LOGIC_DO} %1`,args1:[{type:`input_statement`,name:`DO0`}],previousStatement:null,nextStatement:null,style:`logic_blocks`,helpUrl:`%{BKY_LOGIC_V1_IF_HELPURL`,suppressPrefixSuffix:!0,mutator:`logic_if_v1_mutator`},{type:`logic_if_if_v1`,message0:`%{BKY_LOGIC_IF}`,nextStatement:null,enableContextMenu:!1,style:`logic_blocks`},{type:`logic_if_else_if_v1`,message0:`%{BKY_LOGIC_ELSE_IF}`,previousStatement:null,nextStatement:null,enableContextMenu:!1,style:`logic_blocks`},{type:`logic_if_else_v1`,message0:`%{BKY_LOGIC_ELSE}`,previousStatement:null,enableContextMenu:!1,style:`logic_blocks`}]),n.forBlock.logic_if_v1=function(e){let r=0,i=``;n.STATEMENT_PREFIX&&(i+=n.injectId(n.STATEMENT_PREFIX,e));do{let a=n.valueToCode(e,`IF`+r,t.NONE)||`false`,o=n.statementToCode(e,`DO`+r);n.STATEMENT_SUFFIX&&(o=n.prefixLines(n.injectId(n.STATEMENT_SUFFIX,e),n.INDENT)+o),i+=(r>0?` else `:``)+`if (`+a+`) {
|
|
166
|
-
`+
|
|
167
|
-
`+t+`}`}return
|
|
168
|
-
`},
|
|
169
|
-
${
|
|
170
|
-
${
|
|
171
|
-
function ${
|
|
153
|
+
`},x.update_column_container_v1={init:function(){this.appendDummyInput().appendField(`%{BKY_DATA_LIST}`),this.appendStatementInput(`STACK`),this.setStyle(`object_blocks`),this.contextMenu=!1}},x.update_column_item_v1={init:function(){this.appendDummyInput().appendField(`%{BKY_DATA_ITEM}`),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setStyle(`object_blocks`),this.contextMenu=!1}},x.update_column_v1={init:function(){this.space={id:``,name:``},this.table={id:``,name:``,columns:[]},this.itemCount_=0,this.appendDummyInput().appendField(`%{BKY_DATA_V1_UPDATE_COLUMN_TITLE}`).appendField(new C(()=>this.genSpaceOpts_()),`SPACE`).appendField(new C(()=>this.genTableOpts_()),`TABLE`),this.setMutator(new xe.MutatorIcon([`update_column_item_v1`],this)),this.setOutput(!0,`UpdateColumn`),this.setStyle(`object_blocks`),this.setTooltip(`%{BKY_DATA_V1_UPDATE_COLUMN_TOOLTIP}`),this.setHelpUrl(`%{BKY_DATA_V1_UPDATE_COLUMN_HELPURL}`),this.initData_(),this.initShape_()},initData_:function(){if(this.space.id)return;let e=Or()?.[0];if(!e)return;this.space.id=e.id,this.space.name=e.name;let t=this.getField(`SPACE`);t.getOptions(!1),t.setValue(this.space.id,!1);let n=X(this.space.id)?.[0];if(!n)return;this.table.id=n.id,this.table.name=n.name,this.table.columns=n.columns;let r=this.getField(`TABLE`);r.getOptions(!1),r.setValue(this.table.id,!1),this.itemCount_=n.columns.length},saveExtraState:function(){return{space:this.space,table:this.table,itemCount:this.itemCount_}},loadExtraState:function(e){this.space.id=e.space?.id??``,this.space.name=e.space?.name??``,this.table.id=e.table?.id??``,this.table.name=e.table?.name??``,this.table.columns=e.table?.columns??[],this.itemCount_=e.itemCount??0,this.updateShape_(),setTimeout(()=>{this.updateBlocks_(),this.updateCheck_(),this.checkWarning_()},0)},genSpaceOpts_:function(){return Ar()},genTableOpts_:function(){return Mr(this.space.id)},genColumnOpts_:function(){let e=[];return this.table.columns.forEach(({id:t,name:n})=>{e.push([n,t])}),L(e)},onchange:function(e){if(e.type===b.BLOCK_CHANGE){let t=e;if(t.blockId===this.id){if(t.element===`field`){if(t.name===`SPACE`)this.onSpaceChange_(t.newValue);else if(t.name===`TABLE`)this.onTableChange_(t.newValue);else if(t.name.startsWith(`COLUMN`)){let e=parseInt(t.name.substring(6));this.onColumnChange_(e,t.newValue)}}setTimeout(()=>{this.checkWarning_()},0)}}},onSpaceChange_:function(e){let t=kr(e);if(!t){console.assert(!1);return}let n=t.id!==this.space.id;this.space.id=t.id,this.space.name=t.name;let r=this.getField(`TABLE`);if(r.getOptions(!1),n){let e=X(this.space.id)?.[0];r.setValue(e?.id??``)}this.onTableChange_(r.getValue())},onTableChange_:function(e){let t=jr(this.space.id,e);if(!t){console.assert(!1);return}this.table.id=t.id,this.table.name=t.name,this.table.columns=t.columns,this.itemCount_=t.columns.length,this.updateShape_();for(let e=0;e<this.itemCount_;e++){let t=this.table.columns[e].id,n=this.getField(`COLUMN`+e);n.getOptions(!1),n.setValue(t,!1)}setTimeout(()=>{this.updateBlocks_(!0),this.updateCheck_()},0)},onColumnChange_:function(e,t){let n=this.table.columns.find(e=>e.id===t);if(!n){console.assert(!1);return}let r=this.getInput(`ADD`+e).connection,i=r.targetBlock();i&&i.dispose();let a=Wt(this.workspace,n.type);a&&(r.setCheck(null),r.connect(a.outputConnection)),this.updateCheck_()},decompose:function(e){let t=e.newBlock(`update_column_container_v1`);t.initSvg();let n=t.getInput(`STACK`).connection;for(let t=0;t<this.itemCount_;t++){let t=e.newBlock(`update_column_item_v1`);t.initSvg(),n.connect(t.previousConnection),n=t.nextConnection}return t},compose:function(e){let t=e.getInputTargetBlock(`STACK`),n=[],r=[];for(;t;){if(t.isInsertionMarker()){t=t.getNextBlock();continue}n.push(t.column_),r.push(t.valueConnection_),t=t.getNextBlock()}for(let e=0;e<this.itemCount_;e++){let t=this.getInput(`ADD`+e).connection.targetConnection;t&&r.indexOf(t)===-1&&t.disconnect()}this.itemCount_=n.length,this.updateShape_();for(let e=0;e<this.itemCount_;e++){let t=n[e]??this.table.columns?.[0]?.id??``;this.getField(`COLUMN`+e).setValue(t,!1)}setTimeout(()=>{for(let e=0;e<this.itemCount_;e++)this.getInput(`ADD`+e).setCheck(null),r[e]?.reconnect(this,`ADD`+e);this.updateBlocks_(),this.updateCheck_()},0)},saveConnections:function(e){let t=e.getInputTargetBlock(`STACK`),n=0;for(;t;){if(t.isInsertionMarker()){t=t.getNextBlock();continue}t.column_=this.getFieldValue(`COLUMN`+n),t.valueConnection_=this.getInput(`ADD`+n).connection.targetConnection,t=t.getNextBlock(),n++}},initShape_:function(){if(!this.isInFlyout&&!this.getInput(`ADD0`))for(let e=0;e<this.table.columns.length;e++){let t=this.table.columns[e],n=new C(()=>this.genColumnOpts_());this.appendValueInput(`ADD`+e).setAlign(m.Align.RIGHT).appendField(n,`COLUMN`+e),n.setValue(t.id,!1)}},updateShape_:function(){for(let e=this.itemCount_;this.getInput(`ADD`+e);e++){let t=this.getInput(`ADD`+e).connection.targetBlock();t&&t.dispose(),this.removeInput(`ADD`+e)}for(let e=0;e<this.itemCount_;e++){if(this.getInput(`ADD`+e))continue;let t=new C(()=>this.genColumnOpts_());this.appendValueInput(`ADD`+e).setAlign(m.Align.RIGHT).appendField(t,`COLUMN`+e)}},updateBlocks_:function(e){if(!this.isInsertionMarker())for(let t=0;t<this.itemCount_;t++){let n=this.getInput(`ADD`+t),r=n.connection,i=r.targetBlock();if(e)i&&i.dispose();else if(i)continue;let a=this.getFieldValue(`COLUMN`+t),o=this.table.columns.find(e=>e.id===a);if(!o)continue;n.setCheck(null);let s=Wt(this.workspace,o.type);s&&r.connect(s.outputConnection)}},updateCheck_:function(){for(let e=0;e<this.itemCount_;e++){let t=this.getFieldValue(`COLUMN`+e),n=this.table.columns.find(e=>e.id===t);if(!n)continue;let r=rn(n.type);this.getInput(`ADD`+e).setCheck(r)}},checkWarning_:function(){let e=kr(this.space.id);if(!e){this.setWarningText(I(`WARN_SPACE_NOT_FOUND`));return}e.name!==this.space.name&&(this.space.name=e.name);let t=jr(this.space.id,this.table.id);if(!t){this.setWarningText(I(`WARN_TABLE_NOT_FOUND`));return}if(t.name!==this.table.name&&(this.table.name=t.name),!_(t.columns,this.table.columns)){this.setWarningText(I(`WARN_TABLE_HAS_CHANGED`));return}this.setWarningText(null)}},y.forBlock.update_column_v1=function(e){let t=y.quote_,n=e,r=n.space.id,i=n.table.id,a=[];for(let e=0;e<n.itemCount_;e++){let t=n.getFieldValue(`COLUMN`+e),r=n.table.columns.find(e=>e.id===t).name,i=y.valueToCode(n,`ADD`+e,v.ATOMIC)||`null`;a.push({name:r,value:i})}let o=`[`;return a.forEach(({name:e,value:n},r)=>{r!==0&&(o+=`,`),o+=`{name:${t(e)},value:${n}}`}),o+=`]`,[`{spaceId:${t(r)},tableId:${t(i)},columns:${o}}`,v.ATOMIC]};function Gr(e){let t=e.getInput(`TABLE`).connection;if(t.targetBlock())return;let n,r,i=Or()?.[0];if(i){let e=X(i.id)?.[0];if(e){n={space:{id:i.id,name:i.name},table:{id:e.id,name:e.name,columns:e.columns},itemCount:e.columns.length},r={};for(let t=0;t<e.columns.length;t++){let n=e.columns[t];r[`COLUMN`+t]=n.id}}}let a={type:`update_column_v1`,extraState:n,fields:r},o=p.blocks.append(a,e.workspace);t.connect(o.outputConnection)}function Kr(e){let t=e.getInput(`CONDITION`).connection;if(t.targetBlock())return;let n=p.blocks.append({type:`cond_atomic_v1`},e.workspace);t.connect(n.outputConnection)}function qr(e){let t=e.getInput(`HANDLE`).connection;if(t.targetBlock())return;let n=p.blocks.append({type:`compute_debug_trace_v1`,inputs:{OBJECT:{shadow:{type:`text_v1`},block:{type:`parameter_v1`,extraState:{key:`__message__`,name:`x-runtime-lib.message`,locale:!0}}}}},e.workspace);t.connect(n.previousConnection)}x.update_data_v1={init:function(){this.appendDummyInput().appendField(`%{BKY_DATA_V1_UPDATE_DATA_TITLE}`),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null),this.setStyle(`procedure_blocks`),this.setTooltip(`%{BKY_DATA_V1_UPDATE_DATA_TOOLTIP}`),this.setHelpUrl(`%{BKY_DATA_V1_UPDATE_DATA_HELPURL}`)},saveExtraState:function(){return{}},loadExtraState:function(){this.updateShape_(),setTimeout(()=>{this.ensureBlocks()},0)},updateShape_:function(){this.getInput(`HANDLE`)||this.appendStatementInput(`HANDLE`).appendField(`%{BKY_DATA_DO}`),this.getInput(`DATA`)||(this.appendValueInput(`DATA`),this.moveInputBefore(`DATA`,`HANDLE`)),this.getInput(`MESSAGE`)||(this.appendValueInput(`MESSAGE`),this.moveInputBefore(`MESSAGE`,`DATA`)),this.getInput(`SUCCESS`)||(this.appendValueInput(`SUCCESS`).appendField(`%{BKY_DATA_RETURN}`),this.moveInputBefore(`SUCCESS`,`MESSAGE`)),this.getInput(`CONDITION`)||(this.appendValueInput(`CONDITION`).setCheck(`Condition`).setAlign(m.Align.RIGHT).appendField(`%{BKY_DATA_CONDITION}`),this.moveInputBefore(`CONDITION`,`SUCCESS`)),this.getInput(`TABLE`)||(this.appendValueInput(`TABLE`).setCheck(`UpdateColumn`).setAlign(m.Align.RIGHT).appendField(`%{BKY_DATA_TABLE}`),this.moveInputBefore(`TABLE`,`CONDITION`))},ensureBlocks:function(){this.isInsertionMarker()||(Gr(this),Kr(this),H(this,[[`SUCCESS`,`__success__`,`x-runtime-lib.success`,!0],[`MESSAGE`,`__message__`,`x-runtime-lib.message`,!0],[`DATA`,`__data__`,`x-runtime-lib.data`,!0]]),qr(this))}},y.forBlock.update_data_v1=function(e){let t=y.INDENT;return`{
|
|
154
|
+
${t}var __tx__ = typeof(__tx__) !== 'undefined' ? __tx__ : null;
|
|
155
|
+
${t}var __table__ = ${y.valueToCode(e,`TABLE`,v.ATOMIC)||`null`};
|
|
156
|
+
${t}var __condition__ = ${y.valueToCode(e,`CONDITION`,v.ATOMIC)||`null`};
|
|
157
|
+
${t}var __result__ = __updateDataV1__(__tx__, __table__, __condition__);
|
|
158
|
+
${t}var __success__ = __result__.success;
|
|
159
|
+
${t}var __message__ = __result__.message;
|
|
160
|
+
${t}var __data__ = __result__.data;
|
|
161
|
+
${t}if (__tx__ && !__success__) {
|
|
162
|
+
${t}${t}throw __message__;
|
|
163
|
+
${t}}
|
|
164
|
+
${y.statementToCode(e,`HANDLE`)}}
|
|
165
|
+
`};const Jr=S.xml;x.json_array_v1={init:function(){this.length=0,this.appendDummyInput(`OPEN_BRACKET`).appendField(` [ `),this.appendDummyInput(`ADD`).setAlign(m.Align.CENTRE).appendField(new g(Gt,20,20,void 0,()=>{this.isInFlyout||this.addEntry_()})),this.appendDummyInput(`CLOSE_BRACKET`).appendField(` ] `),this.setInputsInline(!1),this.setOutput(!0,`JsonArray`),this.setColour(350),this.setTooltip(``),this.setHelpUrl(``)},mutationToDom:function(){let e=Jr.createElement(`mutation`);return e.setAttribute(`items`,String(this.length)),e},domToMutation:function(e){this.length=ge(e.getAttribute(`items`)??``,0),this.initShape_()},initData:function(e){this.length=e,this.initShape_()},initShape_:function(){for(let e=0;e<this.length;e++){let t=`ENTRY`+e,n=this.appendValueInput(t);n.appendField(new g(Gt,20,20,void 0,()=>{this.isInFlyout||this.addEntry_(n)})),n.appendField(new be(String(e))),n.appendField(new g(Kt,20,20,void 0,()=>{this.isInFlyout||this.removeEntry_(n)})),this.moveInputBefore(t,`ADD`)}},addEntry_:function(e){let t=this.length;e&&(t=ge(e.name.substring(5)));for(let e=this.length-1;e>=t;e--){let t=this.getInput(`ENTRY`+e);t.name=`ENTRY`+(e+1),t.fieldRow[1].setValue(e+1)}let n=this.appendValueInput(`ENTRY`+t);n.appendField(new g(Gt,20,20,void 0,()=>{this.isInFlyout||this.addEntry_(n)})),n.appendField(new be(String(t))),n.appendField(new g(Kt,20,20,void 0,()=>{this.isInFlyout||this.removeEntry_(n)})),t===this.length?this.moveInputBefore(`ENTRY`+t,`ADD`):this.moveInputBefore(`ENTRY`+t,`ENTRY`+(t+1)),this.length++},removeEntry_:function(e){let t=e.name,n=this.getInputTargetBlock(t);n&&n.dispose(),this.removeInput(t);let r=ge(t.substring(5));for(let e=r+1;e<this.length;e++){let t=this.getInput(`ENTRY`+e);t.name=`ENTRY`+(e-1),t.fieldRow[1].setValue(e-1)}this.length--}},x.json_boolean_v1={init:function(){this.appendDummyInput().appendField(new C([[`false`,`false`],[`true`,`true`]]),`VALUE`),this.setOutput(!0,`JsonBoolean`),this.setColour(210)}};const Yr=S.xml;x.json_map_v1={init:function(){this.length=0,this.appendDummyInput(`OPEN_BRACKET`).appendField(` { `),this.appendDummyInput(`ADD`).setAlign(m.Align.CENTRE).appendField(new g(Gt,20,20,void 0,()=>{this.isInFlyout||this.addEntry_()})),this.appendDummyInput(`CLOSE_BRACHET`).appendField(` } `),this.setInputsInline(!1),this.setOutput(!0,`JsonMap`),this.setColour(120),this.setTooltip(``),this.setHelpUrl(``)},mutationToDom:function(){let e=Yr.createElement(`mutation`);for(let t=0;t<this.length;t++){let n=Yr.createElement(`item`);n.setAttribute(`key`,this.getFieldValue(`KEY`+t)),e.appendChild(n)}return e},domToMutation:function(e){let t=[];for(let n=0;n<e.childNodes.length;n++){let r=e.childNodes[n].getAttribute(`key`);r&&t.push(r)}this.length=t.length,this.initShape_(t)},initData:function(e){this.length=e.length,this.initShape_(e)},initShape_:function(e){for(let t=0;t<e.length;t++){let r=e[t],i=`ENTRY`+t,a=this.appendValueInput(i);a.appendField(new g(Gt,20,20,void 0,()=>{this.isInFlyout||this.addEntry_(a)})),a.appendField(new n(r),`KEY`+t),a.appendField(new g(Kt,20,20,void 0,()=>{this.isInFlyout||this.removeEntry_(a)})),this.moveInputBefore(i,`ADD`)}},addEntry_:function(e){let t=this.length;e&&(t=ge(e.name.substring(5)));for(let e=this.length-1;e>=t;e--)this.getField(`KEY`+e).name=`KEY`+(e+1),this.getInput(`ENTRY`+e).name=`ENTRY`+(e+1);let r=this.appendValueInput(`ENTRY`+t);r.appendField(new g(Gt,20,20,void 0,()=>{this.isInFlyout||this.addEntry_(r)})),r.appendField(new n(`key`),`KEY`+t),r.appendField(new g(Kt,20,20,void 0,()=>{this.isInFlyout||this.removeEntry_(r)})),t===this.length?this.moveInputBefore(`ENTRY`+t,`ADD`):this.moveInputBefore(`ENTRY`+t,`ENTRY`+(t+1)),this.length++},removeEntry_:function(e){let t=e.name,n=this.getInputTargetBlock(t);n&&n.dispose(),this.removeInput(t);let r=ge(t.substring(5));for(let e=r+1;e<this.length;e++)this.getField(`KEY`+e).name=`KEY`+(e-1),this.getInput(`ENTRY`+e).name=`ENTRY`+(e-1);this.length--}},x.json_number_v1={init:function(){this.appendDummyInput().appendField(new ie(0),`VALUE`),this.setOutput(!0,`JsonNumber`),this.setColour(230)}},x.json_root_v1={init:function(){this.appendDummyInput().setAlign(m.Align.CENTRE).appendField(`JSON`),this.appendValueInput(`JSON`).setCheck([`JsonMap`,`JsonArray`]),this.setDeletable(!1),this.setColour(250),this.setTooltip(``),this.setHelpUrl(``)}},x.json_string_v1={init:function(){this.appendDummyInput().appendField(`"`).appendField(new n(``),`VALUE`).appendField(`"`),this.setOutput(!0,`JsonString`),this.setColour(160)}};const Xr=S.xml;x.list_create_container_v1={init:function(){this.appendDummyInput().appendField(`%{BKY_LIST_V1_CREATE_CONTAINER_TITLE}`),this.appendStatementInput(`STACK`),this.setStyle(`list_blocks`),this.contextMenu=!1}},x.list_create_item_v1={init:function(){this.appendDummyInput().appendField(`%{BKY_LIST_V1_CREATE_ITEM_TITLE}`),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setStyle(`list_blocks`),this.contextMenu=!1}},x.list_create_v1={init:function(){this.itemCount_=0,this.setMutator(new xe.MutatorIcon([`list_create_item_v1`],this)),this.setOutput(!0,`Array`),this.setStyle(`list_blocks`),this.setTooltip(`%{BKY_LIST_V1_CREATE_TOOLTIP}`),this.setHelpUrl(`%{BKY_LIST_V1_CREATE_HELPURL}`),this.updateShape_()},mutationToDom:function(){let e=Xr.createElement(`mutation`);return e.setAttribute(`items`,String(this.itemCount_)),e},domToMutation:function(e){let t=e.getAttribute(`items`)??``;this.itemCount_=parseInt(t,0),this.updateShape_()},saveExtraState:function(){return{itemCount:this.itemCount_}},loadExtraState:function(e){this.itemCount_=e.itemCount??0,this.updateShape_()},decompose:function(e){let t=e.newBlock(`list_create_container_v1`);t.initSvg();let n=t.getInput(`STACK`).connection;for(let t=0;t<this.itemCount_;t++){let t=e.newBlock(`list_create_item_v1`);t.initSvg(),n.connect(t.previousConnection),n=t.nextConnection}return t},compose:function(e){let t=e.getInputTargetBlock(`STACK`),n=[];for(;t;){if(t.isInsertionMarker()){t=t.getNextBlock();continue}n.push(t.valueConnection_),t=t.getNextBlock()}for(let e=0;e<this.itemCount_;e++){let t=this.getInput(`ADD`+e).connection.targetConnection;t&&!n.includes(t)&&t.disconnect()}this.itemCount_=n.length,this.updateShape_();for(let e=0;e<this.itemCount_;e++)n[e]?.reconnect(this,`ADD`+e)},saveConnections:function(e){let t=e.getInputTargetBlock(`STACK`),n=0;for(;t;){if(t.isInsertionMarker()){t=t.getNextBlock();continue}let e=this.getInput(`ADD`+n);t.valueConnection_=e?.connection.targetConnection,t=t.getNextBlock(),n++}},updateShape_:function(){this.itemCount_&&this.getInput(`EMPTY`)?this.removeInput(`EMPTY`):!this.itemCount_&&!this.getInput(`EMPTY`)&&this.appendDummyInput(`EMPTY`).appendField(`%{BKY_LIST_V1_CREATE_TITLE}`);for(let e=0;e<this.itemCount_;e++)this.getInput(`ADD`+e)||(this.appendValueInput(`ADD`+e).setCheck([`String`,`Number`,`Boolean`,`Array`,`Object`]),e===0&&this.getInput(`ADD`+e).setAlign(m.Align.RIGHT).appendField(`%{BKY_LIST_V1_CREATE_TITLE}`));for(let e=this.itemCount_;this.getInput(`ADD`+e);e++)this.removeInput(`ADD`+e)}},y.forBlock.list_create_v1=function(e){let t=e,n=Array(t.itemCount_);for(let e=0;e<t.itemCount_;e++)n[e]=y.valueToCode(t,`ADD`+e,v.NONE)||`null`;return[`[`+n.join(`, `)+`]`,v.ATOMIC]},a([{type:`list_delete_v1`,message0:`%{BKY_LIST_V1_DELETE_TITLE}`,args0:[{type:`input_value`,name:`VALUE`,check:`Array`},{type:`input_value`,name:`AT`,check:`Number`}],inputsInline:!0,previousStatement:null,nextStatement:null,style:`list_blocks`,tooltip:`%{BKY_LIST_V1_DELETE_TOOLTIP}`,helpUrl:`%{BKY_LIST_V1_DELETE_HELPURL}`}]),y.forBlock.list_delete_v1=function(e){return`${y.valueToCode(e,`VALUE`,v.MEMBER)||`[]`}.splice(${y.getAdjusted(e,`AT`)}, 1)`},a([{type:`list_get_v1`,message0:`%{BKY_LIST_V1_GET_TITLE}`,args0:[{type:`input_value`,name:`VALUE`,check:`Array`},{type:`input_value`,name:`AT`,check:`Number`}],inputsInline:!0,output:null,style:`list_blocks`,tooltip:`%{BKY_LIST_V1_GET_TOOLTIP}`,helpUrl:`%{BKY_LIST_V1_GET_HELPURL}`}]),y.forBlock.list_get_v1=function(e){return[`${y.valueToCode(e,`VALUE`,v.MEMBER)||`[]`}[${y.getAdjusted(e,`AT`)}]`,v.MEMBER]},a([{type:`list_get_sublist_v1`,message0:`%{BKY_LIST_V1_GET_SUBLIST_TITLE}`,args0:[{type:`input_value`,name:`LIST`,check:`Array`},{type:`input_value`,name:`START`,check:`Number`},{type:`input_value`,name:`END`,check:`Number`}],inputsInline:!0,output:`Array`,style:`list_blocks`,tooltip:`%{BKY_LIST_V1_GET_SUBLIST_TOOLTIP}`,helpUrl:`%{BKY_LIST_V1_GET_SUBLIST_HELPURL}`}]),y.forBlock.list_get_sublist_v1=function(e){return[`${y.valueToCode(e,`LIST`,v.MEMBER)||`[]`}.slice(${y.getAdjusted(e,`START`)}, ${y.getAdjusted(e,`END`,1)})`,v.FUNCTION_CALL]},a([{type:`list_is_empty_v1`,message0:`%{BKY_LIST_V1_IS_EMPTY_TITLE}`,args0:[{type:`input_value`,name:`VALUE`,check:`Array`}],output:`Boolean`,style:`list_blocks`,tooltip:`%{BKY_LIST_V1_IS_EMPTY_TOOLTIP}`,helpUrl:`%{BKY_LIST_V1_IS_EMPTY_HELPURL}`}]),y.forBlock.list_is_empty_v1=function(e){return[`!${y.valueToCode(e,`VALUE`,v.MEMBER)||`[]`}.length`,v.LOGICAL_NOT]},a([{type:`list_join_v1`,message0:`%{BKY_LIST_V1_JOIN_TITLE}`,args0:[{type:`input_value`,name:`LIST`,check:`Array`},{type:`input_value`,name:`DELIM`,check:`String`}],inputsInline:!0,output:`String`,style:`list_blocks`,tooltip:`%{BKY_LIST_V1_JOIN_TOOLTIP}`,helpUrl:`%{BKY_LIST_V1_JOIN_HELPURL}`}]),y.forBlock.list_join_v1=function(e){return[`${y.valueToCode(e,`LIST`,v.MEMBER)||`[]`}.join(${y.valueToCode(e,`DELIM`,v.NONE)||`''`})`,v.FUNCTION_CALL]},a([{type:`list_length_v1`,message0:`%{BKY_LIST_V1_LENGTH_TITLE}`,args0:[{type:`input_value`,name:`VALUE`,check:`Array`}],output:`Number`,style:`list_blocks`,tooltip:`%{BKY_LIST_V1_LENGTH_TOOLTIP}`,helpUrl:`%{BKY_LIST_V1_LENGTH_HELPURL}`}]),y.forBlock.list_length_v1=function(e){return[`${y.valueToCode(e,`VALUE`,v.MEMBER)||`[]`}.length`,v.MEMBER]},a([{type:`list_reverse_v1`,message0:`%{BKY_LIST_V1_REVERSE_TITLE}`,args0:[{type:`input_value`,name:`LIST`,check:`Array`}],inputsInline:!0,output:`Array`,style:`list_blocks`,tooltip:`%{BKY_LIST_V1_REVERSE_TOOLTIP}`,helpUrl:`%{BKY_LIST_V1_REVERSE_HELPURL}`}]),y.forBlock.list_reverse_v1=function(e){return[`${y.valueToCode(e,`LIST`,v.NONE)||`[]`}.slice().reverse()`,v.FUNCTION_CALL]},a([{type:`list_set_v1`,message0:`%{BKY_LIST_V1_SET_TITLE}`,args0:[{type:`input_value`,name:`LIST`,check:`Array`},{type:`input_value`,name:`AT`,check:`Number`},{type:`input_value`,name:`VALUE`,check:null}],inputsInline:!0,previousStatement:null,nextStatement:null,style:`list_blocks`,tooltip:`%{BKY_LIST_V1_SET_TOOLTIP}`,helpUrl:`%{BKY_LIST_V1_SET_HELPURL}`}]),y.forBlock.list_set_v1=function(e){return`${y.valueToCode(e,`LIST`,v.MEMBER)||`[]`}[${y.getAdjusted(e,`AT`)}] = ${y.valueToCode(e,`VALUE`,v.ASSIGNMENT)||`null`};\n`},h.register(`logic_op_tooltip_v1`,h.buildTooltipForDropdown(`OP`,{EQ:`%{BKY_LOGIC_V1_COMPARE_TOOLTIP_EQ}`,NEQ:`%{BKY_LOGIC_V1_COMPARE_TOOLTIP_NEQ}`,LT:`%{BKY_LOGIC_V1_COMPARE_TOOLTIP_LT}`,LTE:`%{BKY_LOGIC_V1_COMPARE_TOOLTIP_LTE}`,GT:`%{BKY_LOGIC_V1_COMPARE_TOOLTIP_GT}`,GTE:`%{BKY_LOGIC_V1_COMPARE_TOOLTIP_GTE}`,AND:`%{BKY_LOGIC_V1_OPERATION_TOOLTIP_AND}`,OR:`%{BKY_LOGIC_V1_OPERATION_TOOLTIP_OR}`})),a([{type:`logic_boolean_v1`,message0:`%1`,args0:[{type:`field_dropdown`,name:`BOOL`,options:[[`%{BKY_LOGIC_BOOLEAN_FALSE}`,`FALSE`],[`%{BKY_LOGIC_BOOLEAN_TRUE}`,`TRUE`]]}],output:`Boolean`,style:`logic_blocks`,tooltip:`%{BKY_LOGIC_V1_BOOLEAN_TOOLTIP}`,helpUrl:`%{BKY_LOGIC_V1_BOOLEAN_HELPURL}`}]),y.forBlock.logic_boolean_v1=function(e){return[e.getFieldValue(`BOOL`)===`TRUE`?`true`:`false`,v.ATOMIC]};const Zr={onchange:function(e){this.prevBlocks_||=[null,null];let t=this.getInputTargetBlock(`A`),n=this.getInputTargetBlock(`B`);if(t&&n&&!this.workspace.connectionChecker.doTypeChecks(t.outputConnection,n.outputConnection)){b.setGroup(e.group);let r=this.prevBlocks_[0];r!==t&&(t.unplug(),r&&!r.isDisposed()&&!r.isShadow()&&this.getInput(`A`).connection.connect(r.outputConnection));let i=this.prevBlocks_[1];i!==n&&(n.unplug(),i&&!i.isDisposed()&&!i.isShadow()&&this.getInput(`B`).connection.connect(i.outputConnection)),this.bumpNeighbours(),b.setGroup(!1)}this.prevBlocks_[0]=this.getInputTargetBlock(`A`),this.prevBlocks_[1]=this.getInputTargetBlock(`B`)}};h.register(`logic_compare_v1`,function(){this.mixin(Zr)}),a([{type:`logic_compare_v1`,message0:`%1 %2 %3`,args0:[{type:`input_value`,name:`A`},{type:`field_dropdown`,name:`OP`,options:[[`=`,`EQ`],[`≠`,`NEQ`],[`<`,`LT`],[`≤`,`LTE`],[`>`,`GT`],[`≥`,`GTE`]]},{type:`input_value`,name:`B`}],inputsInline:!0,output:`Boolean`,style:`logic_blocks`,helpUrl:`%{BKY_LOGIC_V1_COMPARE_HELPURL}`,extensions:[`logic_compare_v1`,`logic_op_tooltip_v1`]}]),y.forBlock.logic_compare_v1=function(e){let t={EQ:`==`,NEQ:`!=`,LT:`<`,LTE:`<=`,GT:`>`,GTE:`>=`}[e.getFieldValue(`OP`)],n=v.RELATIONAL;return(t===`==`||t===`!=`)&&(n=v.EQUALITY),[`${y.valueToCode(e,`A`,n)||`0`} ${t} ${y.valueToCode(e,`B`,n)||`0`}`,n]},h.registerMutator(`logic_if_v1_mutator`,{elseIfCount_:0,hasElse_:!1,mutationToDom:function(){if(this.elseIfCount_<=0&&!this.hasElse_)return null;let e=S.xml.createElement(`mutation`);return this.elseIfCount_>0&&e.setAttribute(`elseIf`,String(this.elseIfCount_)),this.hasElse_&&e.setAttribute(`else`,`TRUE`),e},domToMutation:function(e){this.elseIfCount_=parseInt(e.getAttribute(`elseif`),10)||0,this.hasElse_=e.getAttribute(`else`)===`TRUE`,this.rebuildShape_()},saveExtraState:function(){if(this.elseIfCount_<=0&&!this.hasElse_)return null;let e=Object.create(null);return this.elseIfCount_>0&&(e.elseIfCount=this.elseIfCount_),this.hasElse_&&(e.hasElse=!0),e},loadExtraState:function(e){this.elseIfCount_=e.elseIfCount||0,this.hasElse_=!!e.hasElse,this.updateShape_()},decompose:function(e){let t=e.newBlock(`logic_if_if_v1`);t.initSvg();let n=t.nextConnection;for(let t=0;t<this.elseIfCount_;t++){let t=e.newBlock(`logic_if_else_if_v1`);t.initSvg(),n.connect(t.previousConnection),n=t.nextConnection}if(this.hasElse_){let t=e.newBlock(`logic_if_else_v1`);t.initSvg(),n.connect(t.previousConnection)}return t},compose:function(e){let t=e.nextConnection.targetBlock();this.elseIfCount_=0,this.hasElse_=!1;let n=[null],r=[null],i=null;for(;t;){if(t.isInsertionMarker()){t=t.getNextBlock();continue}switch(t.type){case`logic_if_else_if_v1`:this.elseIfCount_++,n.push(t.valueConnection_),r.push(t.statementConnection_);break;case`logic_if_else_v1`:this.hasElse_=!0,i=t.statementConnection_;break;default:throw TypeError(`Unknown block type: `+t.type)}t=t.getNextBlock()}this.updateShape_(),this.reconnectChildBlocks_(n,r,i)},saveConnections:function(e){let t=e.nextConnection.targetBlock(),n=1;for(;t;){if(t.isInsertionMarker()){t=t.getNextBlock();continue}switch(t.type){case`Logic_if_else_if_v1`:{let e=this.getInput(`IF`+n),r=this.getInput(`DO`+n);t.valueConnection_=e&&e.connection.targetConnection,t.statementConnection_=r&&r.connection.targetConnection,n++;break}case`logic_if_else_v1`:{let e=this.getInput(`ELSE`);t.statementConnection_=e&&e.connection.targetConnection;break}default:throw TypeError(`Unknown block type: `+t.type)}t=t.getNextBlock()}},rebuildShape_:function(){let e=[null],t=[null],n=null;this.getInput(`ELSE`)&&(n=this.getInput(`ELSE`).connection.targetConnection);for(let n=1;this.getInput(`IF`+n);n++){let r=this.getInput(`IF`+n),i=this.getInput(`DO`+n);e.push(r.connection.targetConnection),t.push(i.connection.targetConnection)}this.updateShape_(),this.reconnectChildBlocks_(e,t,n)},updateShape_:function(){this.getInput(`ELSE`)&&this.removeInput(`ELSE`);for(let e=1;this.getInput(`IF`+e);e++)this.removeInput(`IF`+e),this.removeInput(`DO`+e);for(let e=1;e<=this.elseIfCount_;e++)this.appendValueInput(`IF`+e).setCheck(`Boolean`).appendField(I(`LOGIC_ELSE_IF`)),this.appendStatementInput(`DO`+e).appendField(I(`LOGIC_DO`));this.hasElse_&&this.appendStatementInput(`ELSE`).appendField(I(`LOGIC_ELSE`))},reconnectChildBlocks_:function(e,t,n){for(let n=1;n<=this.elseIfCount_;n++)e[n]?.reconnect(this,`IF`+n),t[n]?.reconnect(this,`DO`+n);n?.reconnect(this,`ELSE`)}},void 0,[`logic_if_else_if_v1`,`logic_if_else_v1`]),a([{type:`logic_if_v1`,message0:`%{BKY_LOGIC_IF} %1`,args0:[{type:`input_value`,name:`IF0`,check:`Boolean`}],message1:`%{BKY_LOGIC_DO} %1`,args1:[{type:`input_statement`,name:`DO0`}],previousStatement:null,nextStatement:null,style:`logic_blocks`,helpUrl:`%{BKY_LOGIC_V1_IF_HELPURL`,suppressPrefixSuffix:!0,mutator:`logic_if_v1_mutator`},{type:`logic_if_if_v1`,message0:`%{BKY_LOGIC_IF}`,nextStatement:null,enableContextMenu:!1,style:`logic_blocks`},{type:`logic_if_else_if_v1`,message0:`%{BKY_LOGIC_ELSE_IF}`,previousStatement:null,nextStatement:null,enableContextMenu:!1,style:`logic_blocks`},{type:`logic_if_else_v1`,message0:`%{BKY_LOGIC_ELSE}`,previousStatement:null,enableContextMenu:!1,style:`logic_blocks`}]),y.forBlock.logic_if_v1=function(e){let t=0,n=``;y.STATEMENT_PREFIX&&(n+=y.injectId(y.STATEMENT_PREFIX,e));do{let r=y.valueToCode(e,`IF`+t,v.NONE)||`false`,i=y.statementToCode(e,`DO`+t);y.STATEMENT_SUFFIX&&(i=y.prefixLines(y.injectId(y.STATEMENT_SUFFIX,e),y.INDENT)+i),n+=(t>0?` else `:``)+`if (`+r+`) {
|
|
166
|
+
`+i+`}`,t++}while(e.getInput(`IF`+t));if(e.getInput(`ELSE`)||y.STATEMENT_SUFFIX){let t=y.statementToCode(e,`ELSE`);y.STATEMENT_SUFFIX&&(t=y.prefixLines(y.injectId(y.STATEMENT_SUFFIX,e),y.INDENT)+t),n+=` else {
|
|
167
|
+
`+t+`}`}return n+`
|
|
168
|
+
`},a([{type:`logic_negate_v1`,message0:`%{BKY_LOGIC_V1_NEGATE_TITLE}`,args0:[{type:`input_value`,name:`BOOL`,check:`Boolean`}],output:`Boolean`,style:`logic_blocks`,tooltip:`%{BKY_LOGIC_V1_NEGATE_TOOLTIP}`,helpUrl:`%{BKY_LOGIC_V1_NEGATE_HELPURL}`}]),y.forBlock.logic_negate_v1=function(e){return[`!${y.valueToCode(e,`BOOL`,v.LOGICAL_NOT)||`true`}`,v.LOGICAL_NOT]},a([{type:`logic_operation_v1`,message0:`%1 %2 %3`,args0:[{type:`input_value`,name:`A`,check:`Boolean`},{type:`field_dropdown`,name:`OP`,options:[[`%{BKY_LOGIC_OPERATION_AND}`,`AND`],[`%{BKY_LOGIC_OPERATION_OR}`,`OR`]]},{type:`input_value`,name:`B`,check:`Boolean`}],inputsInline:!0,output:`Boolean`,style:`logic_blocks`,helpUrl:`%{BKY_LOGIC_V1_OPERATION_HELPURL}`,extensions:[`logic_op_tooltip_v1`]}]),y.forBlock.logic_operation_v1=function(e){let t=e.getFieldValue(`OP`)===`AND`?`&&`:`||`,n=t===`&&`?v.LOGICAL_AND:v.LOGICAL_OR,r=y.valueToCode(e,`A`,n),i=y.valueToCode(e,`B`,n);if(!r&&!i)r=`false`,i=`false`;else{let e=t===`&&`?`true`:`false`;r||=e,i||=e}return[`${r} ${t} ${i}`,n]},h.registerMixin(`logic_ternary_v1`,{prevParentConnection_:null,onchange:function(e){let t=this.getInputTargetBlock(`THEN`),n=this.getInputTargetBlock(`ELSE`),r=this.outputConnection.targetConnection;if((t||n)&&r)for(let i=0;i<2;i++){let a=i===1?t:n;a&&!a.workspace.connectionChecker.doTypeChecks(a.outputConnection,r)&&(b.setGroup(e.group),r===this.prevParentConnection_?(this.unplug(),r.getSourceBlock().bumpNeighbours()):(a.unplug(),a.bumpNeighbours()),b.setGroup(!1))}this.prevParentConnection_=r}}),a([{type:`logic_ternary_v1`,message0:`%{BKY_LOGIC_TERNARY_CONDITION} %1`,args0:[{type:`input_value`,name:`IF`,check:`Boolean`}],message1:`%{BKY_LOGIC_TERNARY_IF_TRUE} %1`,args1:[{type:`input_value`,name:`THEN`}],message2:`%{BKY_LOGIC_TERNARY_IF_FALSE} %1`,args2:[{type:`input_value`,name:`ELSE`}],output:null,style:`logic_blocks`,tooltip:`%{BKY_LOGIC_V1_TERNARY_TOOLTIP}`,helpUrl:`%{BKY_LOGIC_V1_TERNARY_HELPURL}`,extensions:[`logic_ternary_v1`]}]),y.forBlock.logic_ternary_v1=function(e){let t=y.valueToCode(e,`IF`,v.CONDITIONAL)||`false`,n=y.valueToCode(e,`THEN`,v.CONDITIONAL)||`null`,r=y.valueToCode(e,`ELSE`,v.CONDITIONAL)||`null`;return[t+` ? `+n+` : `+r,v.CONDITIONAL]},h.registerMixin(`contextMenu_newGetVariableBlock_v1`,{customContextMenu:function(e){if(this.isInFlyout)return;let t=this.getField(`VAR`),n=t.getVariable()?.getName();if(!this.isCollapsed()&&n){let r={type:`variable_get_v1`,fields:{VAR:t.saveState(!0)}};e.push({enabled:!0,text:I(`VARIABLE_SET_CREATE_GET`).replace(`%1`,n),callback:fe.callbackFactory(this,r)})}}}),h.register(`flow_control_tooltip_v1`,h.buildTooltipForDropdown(`MODE`,{BREAK:`%{BKY_LOOP_V1_FLOW_CONTROL_TOOLTIP_BREAK}`,CONTINUE:`%{BKY_LOOP_V1_FLOW_CONTROL_TOOLTIP_CONTINUE}`}));const Qr=new Set([`repeat_v1`,`for_each_v1`,`for_v1`,`while_until_v1`]);h.registerMixin(`flow_control_in_loop_check_v1`,{getSurroundLoop:function(){let e=this;do{if(Qr.has(e.type))return e;e=e?.getSurroundParent()}while(e);return null},onchange:function(e){let t=this.workspace;if(!t.isDragging||t.isDragging()||e.type!==b.BLOCK_MOVE&&e.type!==b.BLOCK_CREATE)return;let n=this.getSurroundLoop();if(this.setWarningText(n?null:I(`LOOP_FLOW_CONTROL_WARNING`)),!this.isInFlyout)try{b.setRecordUndo(!1),this.setDisabledReason(!n,`FLOW_CONTROL_NOT_IN_LOOP`)}finally{b.setRecordUndo(!0)}}}),a([{type:`flow_control_v1`,message0:`%1`,args0:[{type:`field_dropdown`,name:`MODE`,options:[[`%{BKY_LOOP_V1_FLOW_CONTROL_OPERATOR_BREAK}`,`BREAK`],[`%{BKY_LOOP_V1_FLOW_CONTROL_OPERATOR_CONTINUE}`,`CONTINUE`]]}],previousStatement:null,style:`loop_blocks`,helpurl:`%{BKY_LOOP_V1_FLOW_CONTROL_HELPURL}`,suppressPrefixSuffix:!0,extensions:[`flow_control_tooltip_v1`,`flow_control_in_loop_check_v1`]}]),y.forBlock.flow_control_v1=function(e){let t=``;if(y.STATEMENT_PREFIX&&(t+=y.injectId(y.STATEMENT_PREFIX,e)),y.STATEMENT_SUFFIX&&(t+=y.injectId(y.STATEMENT_SUFFIX,e)),y.STATEMENT_PREFIX){let n=e.getSurroundLoop();n&&!n.suppressPrefixSuffix&&(t+=y.injectId(y.STATEMENT_PREFIX,n))}switch(e.getFieldValue(`MODE`)){case`BREAK`:return`${t}break;\n`;case`CONTINUE`:return`${t}continue;\n`;default:throw`unknown mode`}},h.register(`for_tooltip_v1`,h.buildTooltipWithFieldText(`%{BKY_LOOP_V1_FOR_TOOLTIP}`,`VAR`)),a([{type:`for_v1`,message0:`%{BKY_LOOP_V1_FOR_TITLE}`,args0:[{type:`field_variable`,name:`VAR`,variable:null},{type:`input_value`,name:`FROM`,check:`Number`,align:`RIGHT`},{type:`input_value`,name:`TO`,check:`Number`,align:`RIGHT`},{type:`input_value`,name:`BY`,check:`Number`,align:`RIGHT`}],message1:`%{BKY_LOOP_DO} %1`,args1:[{type:`input_statement`,name:`DO`}],inputsInline:!0,previousStatement:null,nextStatement:null,style:`loop_blocks`,helpUrl:`%{BKY_LOOP_V1_FOR_HELPURL}`,extensions:[`contextMenu_newGetVariableBlock_v1`,`for_tooltip_v1`]}]),y.forBlock.for_v1=function(e){let t=y.INDENT,n=y.getVariableName(e.getFieldValue(`VAR`)),r=y.valueToCode(e,`FROM`,v.ASSIGNMENT)||`0`,i=y.valueToCode(e,`TO`,v.ASSIGNMENT)||`0`,a=y.valueToCode(e,`BY`,v.ASSIGNMENT)||`1`,o=y.addLoopTrap(y.statementToCode(e,`DO`),e);if(S.string.isNumber(r)&&S.string.isNumber(i)&&S.string.isNumber(a)){let e=Math.abs(Number(a));return Number(r)<=Number(i)?`for (${n} = ${r}; ${n} <= ${i}; ${n} += ${e}) {\n${o}}\n`:`for (${n} = ${r}; ${n} >= ${i}; ${n} -= ${e}) {\n${o}}\n`}else{let e=``,s=r;!r.match(/^\w+$/)&&!S.string.isNumber(r)&&(s=y.nameDB_.getDistinctName(`${n}_from`,f.NameType.VARIABLE),e+=`var ${s} = ${r};\n`);let c=i;!i.match(/^\w+$/)&&!S.string.isNumber(i)&&(c=y.nameDB_.getDistinctName(`${n}_to`,f.NameType.VARIABLE),e+=`var ${c} = ${i};\n`);let l=y.nameDB_.getDistinctName(`${n}_by`,f.NameType.VARIABLE);return e+=`var ${l} = `,S.string.isNumber(a)?e+=`${Math.abs(Number(a))};\n`:e+=`Math.abs(${a});\n`,e+=`if (${s} > ${c}) {\n${t}${l} = -${l};\n}\n`,e+=`for (${n} = ${s}; ${l} >= 0 ? ${n} <= ${c} : ${n} >= ${c}; ${n} += ${l}) {\n${o}}\n`,e}},h.register(`for_each_tooltip_v1`,h.buildTooltipWithFieldText(`%{BKY_LOOP_V1_FOR_EACH_TOOLTIP}`,`VAR`)),a([{type:`for_each_v1`,message0:`%{BKY_LOOP_V1_FOR_EACH_TITLE}`,args0:[{type:`field_variable`,name:`VAR`,variable:null},{type:`input_value`,name:`LIST`,check:`Array`}],message1:`%{BKY_LOOP_DO} %1`,args1:[{type:`input_statement`,name:`DO`}],previousStatement:null,nextStatement:null,style:`loop_blocks`,helpUrl:`%{BKY_LOOP_V1_FOR_EACH_HELPURL}`,extensions:[`contextMenu_newGetVariableBlock_v1`,`for_each_tooltip_v1`]}]),y.forBlock.for_each_v1=function(e){let t=y.INDENT,n=y.getVariableName(e.getFieldValue(`VAR`)),r=y.valueToCode(e,`LIST`,v.ASSIGNMENT)||`[]`,i=y.addLoopTrap(y.statementToCode(e,`DO`),e),a=``,o=r;r.match(/^\w+$/)||(o=y.nameDB_.getDistinctName(`${n}_list`,f.NameType.VARIABLE),a+=`var ${o} = ${r};\n`);let s=y.nameDB_.getDistinctName(`${n}_index`,f.NameType.VARIABLE);return a+=`for (var ${s} in ${o}) {
|
|
169
|
+
${t}${n} = ${o}[${s}];
|
|
170
|
+
${i}}\n`,a},a([{type:`repeat_v1`,message0:`%{BKY_LOOP_V1_REPEAT_TITLE}`,args0:[{type:`input_value`,name:`TIMES`,check:`Number`}],message1:`%{BKY_LOOP_DO} %1`,args1:[{type:`input_statement`,name:`DO`}],previousStatement:null,nextStatement:null,style:`loop_blocks`,tooltip:`%{BKY_LOOP_REPEAT_TOOLTIP}`,helpUrl:`%{BKY_LOOP_REPEAT_HELPURL}`}]),y.forBlock.repeat_v1=function(e){let t;t=e.getField(`TIMES`)?String(Number(e.getFieldValue(`TIMES`))):y.valueToCode(e,`TIMES`,v.ASSIGNMENT)||`0`;let n=y.addLoopTrap(y.statementToCode(e,`DO`),e),r=``,i=y.nameDB_.getDistinctName(`count`,f.NameType.VARIABLE),a=t;return!t.match(/^\w+$/)&&!S.string.isNumber(t)&&(a=y.nameDB_.getDistinctName(`repeat_end`,f.NameType.VARIABLE),r+=`var ${a} = ${t};\n`),r+=`for (var ${i} = 0; ${i} < ${a}; ${i}++) {\n${n}}\n`,r},h.register(`while_until_tooltip_v1`,h.buildTooltipForDropdown(`MODE`,{WHILE:`%{BKY_LOOP_V1_WHILE_UNTIL_TOOLTIP_WHILE}`,UNTIL:`%{BKY_LOOP_V1_WHILE_UNTIL_TOOLTIP_UNTIL}`})),a([{type:`while_until_v1`,message0:`%1 %2`,args0:[{type:`field_dropdown`,name:`MODE`,options:[[`%{BKY_LOOP_V1_WHILE_UNTIL_OPERATOR_WHILE}`,`WHILE`],[`%{BKY_LOOP_V1_WHILE_UNTIL_OPERATOR_UNTIL}`,`UNTIL`]]},{type:`input_value`,name:`CONDITION`,check:`Boolean`}],message1:`%{BKY_LOOP_DO} %1`,args1:[{type:`input_statement`,name:`HANDLE`}],previousStatement:null,nextStatement:null,style:`loop_blocks`,helpUrl:`%{BKY_LOOP_V1_WHILE_UNTIL_HELPURL}`,extensions:[`while_until_tooltip_v1`]}]),y.forBlock.while_until_v1=function(e){let t=e.getFieldValue(`MODE`),n=y.valueToCode(e,`CONDITION`,t===`UNTIL`?v.LOGICAL_NOT:v.NONE)||`false`;t===`UNTIL`&&(n=`!`+n);let r=y.addLoopTrap(y.statementToCode(e,`HANDLE`),e);return`while (${n}) {\n${r}}\n`},h.register(`math_op_tooltip_v1`,h.buildTooltipForDropdown(`OP`,{ADD:`%{BKY_MATH_V1_ARITHMETIC_TOOLTIP_ADD}`,SUBTRACT:`%{BKY_MATH_V1_ARITHMETIC_TOOLTIP_SUBTRACT}`,MULTIPLY:`%{BKY_MATH_V1_ARITHMETIC_TOOLTIP_MULTIPLY}`,DIVIDE:`%{BKY_MATH_V1_ARITHMETIC_TOOLTIP_DIVIDE}`,POWER:`%{BKY_MATH_V1_ARITHMETIC_TOOLTIP_POWER}`,ROOT:`%{BKY_MATH_V1_SINGLE_TOOLTIP_ROOT}`,ABS:`%{BKY_MATH_V1_SINGLE_TOOLTIP_ABS}`,NEG:`%{BKY_MATH_V1_SINGLE_TOOLTIP_NEG}`,LN:`%{BKY_MATH_V1_SINGLE_TOOLTIP_LN}`,LOG10:`%{BKY_MATH_V1_SINGLE_TOOLTIP_LOG10}`,EXP:`%{BKY_MATH_V1_SINGLE_TOOLTIP_EXP}`,POW10:`%{BKY_MATH_V1_SINGLE_TOOLTIP_POW10}`,SIN:`%{BKY_MATH_V1_TRIG_TOOLTIP_SIN}`,COS:`%{BKY_MATH_V1_TRIG_TOOLTIP_COS}`,TAN:`%{BKY_MATH_V1_TRIG_TOOLTIP_TAN}`,ASIN:`%{BKY_MATH_V1_TRIG_TOOLTIP_ASIN}`,ACOS:`%{BKY_MATH_V1_TRIG_TOOLTIP_ACOS}`,ATAN:`%{BKY_MATH_V1_TRIG_TOOLTIP_ATAN}`,SUM:`%{BKY_MATH_V1_ON_LIST_TOOLTIP_SUM}`,MIN:`%{BKY_MATH_V1_ON_LIST_TOOLTIP_MIN}`,MAX:`%{BKY_MATH_V1_ON_LIST_TOOLTIP_MAX}`,AVERAGE:`%{BKY_MATH_V1_ON_LIST_TOOLTIP_AVERAGE}`,MEDIAN:`%{BKY_MATH_V1_ON_LIST_TOOLTIP_MEDIAN}`,MODE:`%{BKY_MATH_V1_ON_LIST_TOOLTIP_MODE}`,STD_DEV:`%{BKY_MATH_V1_ON_LIST_TOOLTIP_STD_DEV}`,RANDOM:`%{BKY_MATH_V1_ON_LIST_TOOLTIP_RANDOM}`})),a([{type:`math_arithmetic_v1`,message0:`%1 %2 %3`,args0:[{type:`input_value`,name:`A`,check:`Number`},{type:`field_dropdown`,name:`OP`,options:[[`%{BKY_MATH_SYMBOL_ADD}`,`ADD`],[`%{BKY_MATH_SYMBOL_SUBTRACT}`,`SUBTRACT`],[`%{BKY_MATH_SYMBOL_MULTIPLY}`,`MULTIPLY`],[`%{BKY_MATH_SYMBOL_DIVIDE}`,`DIVIDE`],[`%{BKY_MATH_SYMBOL_POWER}`,`POWER`]]},{type:`input_value`,name:`B`,check:`Number`}],inputsInline:!0,output:`Number`,style:`math_blocks`,helpUrl:`%{BKY_MATH_V1_ARITHMETIC_HELPURL}`,extensions:[`math_op_tooltip_v1`]}]),y.forBlock.math_arithmetic_v1=function(e){let[t,n]={ADD:[` + `,v.ADDITION],SUBTRACT:[` - `,v.SUBTRACTION],MULTIPLY:[` * `,v.MULTIPLICATION],DIVIDE:[` / `,v.DIVISION],POWER:[null,v.NONE]}[e.getFieldValue(`OP`)],r=y.valueToCode(e,`A`,n)||`0`,i=y.valueToCode(e,`B`,n)||`0`;return t?[r+t+i,n]:[`Math.pow(${r}, ${i})`,v.FUNCTION_CALL]},a([{type:`math_constant_v1`,message0:`%1`,args0:[{type:`field_dropdown`,name:`CONSTANT`,options:[[`π`,`PI`],[`e`,`E`],[`φ`,`GOLDEN_RATIO`],[`sqrt(2)`,`SQRT2`],[`sqrt(½)`,`SQRT1_2`],[`∞`,`INFINITY`]]}],output:`Number`,style:`math_blocks`,tooltip:`%{BKY_MATH_V1_CONSTANT_TOOLTIP}`,helpUrl:`%{BKY_MATH_V1_CONSTANT_HELPURL}`}]),y.forBlock.math_constant_v1=function(e){return{PI:[`Math.PI`,v.MEMBER],E:[`Math.E`,v.MEMBER],GOLDEN_RATIO:[`(1 + Math.sqrt(5)) / 2`,v.DIVISION],SQRT2:[`Math.SQRT2`,v.MEMBER],SQRT1_2:[`Math.SQRT1_2`,v.MEMBER],INFINITY:[`Infinity`,v.ATOMIC]}[e.getFieldValue(`CONSTANT`)]},a([{type:`math_constrain_v1`,message0:`%{BKY_MATH_V1_CONSTRAIN_TITLE}`,args0:[{type:`input_value`,name:`VALUE`,check:`Number`},{type:`input_value`,name:`LOW`,check:`Number`},{type:`input_value`,name:`HIGH`,check:`Number`}],inputsInline:!0,output:`Number`,style:`math_blocks`,tooltip:`%{BKY_MATH_V1_CONSTRAIN_TOOLTIP}`,helpUrl:`%{BKY_MATH_V1_CONSTRAIN_HELPURL}`}]),y.forBlock.math_constrain_v1=function(e){return[`Math.min(Math.max(${y.valueToCode(e,`VALUE`,v.NONE)||`0`}, ${y.valueToCode(e,`LOW`,v.NONE)||`0`}), ${y.valueToCode(e,`HIGH`,v.NONE)||`Infinity`})`,v.FUNCTION_CALL]},a([{type:`math_modulo_v1`,message0:`%{BKY_MATH_V1_MODULO_TITLE}`,args0:[{type:`input_value`,name:`DIVIDEND`,check:`Number`},{type:`input_value`,name:`DIVISOR`,check:`Number`}],inputsInline:!0,output:`Number`,style:`math_blocks`,tooltip:`%{BKY_MATH_V1_MODULO_TOOLTIP}`,helpUrl:`%{BKY_MATH_V1_MODULO_HELPURL}`}]),y.forBlock.math_modulo_v1=function(e){let t=y.valueToCode(e,`DIVIDEND`,v.MODULUS)||`0`,n=y.valueToCode(e,`DIVISOR`,v.MODULUS)||`0`;return[t+` % `+n,v.MODULUS]},a([{type:`math_number_v1`,message0:`%1`,args0:[{type:`field_number`,name:`NUM`,value:0}],output:`Number`,style:`math_blocks`,helpUrl:`%{BKY_MATH_V1_NUMBER_HELPURL}`,tooltip:`%{BKY_MATH_V1_NUMBER_TOOLTIP}`,extensions:[`parent_tooltip_when_inline`]}]),y.forBlock.math_number_v1=function(e){let t=Number(e.getFieldValue(`NUM`)),n=t>=0?v.ATOMIC:v.UNARY_NEGATION;return[String(t),n]},a([{type:`math_number_property_v1`,message0:`%{BKY_MATH_V1_NUMBER_PROPERTY_TITLE}`,args0:[{type:`input_value`,name:`NUM`,check:`Number`},{type:`field_dropdown`,name:`PROP`,options:[[`%{BKY_MATH_NUMBER_PROP_EVEN}`,`EVEN`],[`%{BKY_MATH_NUMBER_PROP_ODD}`,`ODD`],[`%{BKY_MATH_NUMBER_PROP_PRIME}`,`PRIME`],[`%{BKY_MATH_NUMBER_PROP_WHOLE}`,`WHOLE`],[`%{BKY_MATH_NUMBER_PROP_POSITIVE}`,`POSITIVE`],[`%{BKY_MATH_NUMBER_PROP_NEGATIVE}`,`NEGATIVE`]]}],inputsInline:!0,output:`Boolean`,style:`math_blocks`,tooltip:`%{BKY_MATH_V1_NUMBER_PROPERTY_TOOLTIP}`,helpUrl:`%{BKY_MATH_V1_NUMBER_PROPERTY_HELPURL}`}]),y.forBlock.math_number_property_v1=function(e){let t={EVEN:[` % 2 === 0`,v.MODULUS,v.EQUALITY],ODD:[` % 2 === 1`,v.MODULUS,v.EQUALITY],WHOLE:[` % 1 === 0`,v.MODULUS,v.EQUALITY],POSITIVE:[` > 0`,v.RELATIONAL,v.RELATIONAL],NEGATIVE:[` < 0`,v.RELATIONAL,v.RELATIONAL],DIVISIBLE_BY:[null,v.MODULUS,v.EQUALITY],PRIME:[null,v.NONE,v.FUNCTION_CALL]},n=e.getFieldValue(`PROPERTY`),[r,i,a]=t[e.getFieldValue(`PROPERTY`)],o=y.valueToCode(e,`NUMBER_TO_CHECK`,i)||`0`,s;if(n===`PRIME`)s=y.provideFunction_(`mathIsPrime`,`
|
|
171
|
+
function ${y.FUNCTION_NAME_PLACEHOLDER_}(n) {
|
|
172
172
|
// https://en.wikipedia.org/wiki/Primality_test#Naive_methods
|
|
173
173
|
if (n == 2 || n == 3) {
|
|
174
174
|
return true;
|
|
@@ -186,12 +186,12 @@ function ${n.FUNCTION_NAME_PLACEHOLDER_}(n) {
|
|
|
186
186
|
}
|
|
187
187
|
return true;
|
|
188
188
|
}
|
|
189
|
-
`)+`(`+
|
|
190
|
-
function ${
|
|
189
|
+
`)+`(`+o+`)`;else if(n===`DIVISIBLE_BY`){let t=y.valueToCode(e,`DIVISOR`,v.MODULUS)||`0`;s=o+` % `+t+` === 0`}else s=o+r;return[s,a]},a([{type:`math_on_list_v1`,message0:`%{BKY_MATH_V1_ON_LIST_TITLE}`,args0:[{type:`field_dropdown`,name:`OP`,options:[[`%{BKY_MATH_ON_LIST_OPERATOR_SUM}`,`SUM`],[`%{BKY_MATH_ON_LIST_OPERATOR_MIN}`,`MIN`],[`%{BKY_MATH_ON_LIST_OPERATOR_MAX}`,`MAX`],[`%{BKY_MATH_ON_LIST_OPERATOR_AVERAGE}`,`AVERAGE`],[`%{BKY_MATH_ON_LIST_OPERATOR_MEDIAN}`,`MEDIAN`],[`%{BKY_MATH_ON_LIST_OPERATOR_MODE}`,`MODE`],[`%{BKY_MATH_ON_LIST_OPERATOR_STD_DEV}`,`STD_DEV`],[`%{BKY_MATH_ON_LIST_OPERATOR_RANDOM}`,`RANDOM`]]},{type:`input_value`,name:`LIST`,check:`Array`}],output:`Number`,style:`math_blocks`,helpUrl:`%{BKY_MATH_V1_ON_LIST_HELPURL}`,extensions:[`math_op_tooltip_v1`]}]),y.forBlock.math_on_list_v1=function(e){let t=e.getFieldValue(`OP`),n,r;switch(t){case`SUM`:n=y.valueToCode(e,`LIST`,v.MEMBER)||`[]`,r=n+`.reduce(function(x, y) {return x + y;}, 0)`;break;case`MIN`:n=y.valueToCode(e,`LIST`,v.NONE)||`[]`,r=`Math.min.apply(null, `+n+`)`;break;case`MAX`:n=y.valueToCode(e,`LIST`,v.NONE)||`[]`,r=`Math.max.apply(null, `+n+`)`;break;case`AVERAGE`:{let t=y.provideFunction_(`mathMean`,`
|
|
190
|
+
function ${y.FUNCTION_NAME_PLACEHOLDER_}(myList) {
|
|
191
191
|
return myList.reduce(function(x, y) {return x + y;}, 0) / myList.length;
|
|
192
192
|
}
|
|
193
|
-
`);
|
|
194
|
-
function ${
|
|
193
|
+
`);n=y.valueToCode(e,`LIST`,v.NONE)||`[]`,r=t+`(`+n+`)`;break}case`MEDIAN`:{let t=y.provideFunction_(`mathMedian`,`
|
|
194
|
+
function ${y.FUNCTION_NAME_PLACEHOLDER_}(myList) {
|
|
195
195
|
var localList = myList.filter(function (x) {return typeof x === 'number';});
|
|
196
196
|
if (!localList.length) return null;
|
|
197
197
|
localList.sort(function(a, b) {return b - a;});
|
|
@@ -201,8 +201,8 @@ function ${n.FUNCTION_NAME_PLACEHOLDER_}(myList) {
|
|
|
201
201
|
return localList[(localList.length - 1) / 2];
|
|
202
202
|
}
|
|
203
203
|
}
|
|
204
|
-
`);
|
|
205
|
-
function ${
|
|
204
|
+
`);n=y.valueToCode(e,`LIST`,v.NONE)||`[]`,r=t+`(`+n+`)`;break}case`MODE`:{let t=y.provideFunction_(`mathModes`,`
|
|
205
|
+
function ${y.FUNCTION_NAME_PLACEHOLDER_}(values) {
|
|
206
206
|
var modes = [];
|
|
207
207
|
var counts = [];
|
|
208
208
|
var maxCount = 0;
|
|
@@ -230,8 +230,8 @@ function ${n.FUNCTION_NAME_PLACEHOLDER_}(values) {
|
|
|
230
230
|
}
|
|
231
231
|
return modes;
|
|
232
232
|
}
|
|
233
|
-
`);
|
|
234
|
-
function ${
|
|
233
|
+
`);n=y.valueToCode(e,`LIST`,v.NONE)||`[]`,r=t+`(`+n+`)`;break}case`STD_DEV`:{let t=y.provideFunction_(`mathStandardDeviation`,`
|
|
234
|
+
function ${y.FUNCTION_NAME_PLACEHOLDER_}(numbers) {
|
|
235
235
|
var n = numbers.length;
|
|
236
236
|
if (!n) return null;
|
|
237
237
|
var mean = numbers.reduce(function(x, y) {return x + y;}) / n;
|
|
@@ -242,13 +242,13 @@ function ${n.FUNCTION_NAME_PLACEHOLDER_}(numbers) {
|
|
|
242
242
|
variance /= n;
|
|
243
243
|
return Math.sqrt(variance);
|
|
244
244
|
}
|
|
245
|
-
`);
|
|
246
|
-
function ${
|
|
245
|
+
`);n=y.valueToCode(e,`LIST`,v.NONE)||`[]`,r=t+`(`+n+`)`;break}case`RANDOM`:{let t=y.provideFunction_(`mathRandomList`,`
|
|
246
|
+
function ${y.FUNCTION_NAME_PLACEHOLDER_}(list) {
|
|
247
247
|
var x = Math.floor(Math.random() * list.length);
|
|
248
248
|
return list[x];
|
|
249
249
|
}
|
|
250
|
-
`);
|
|
251
|
-
function ${
|
|
250
|
+
`);n=y.valueToCode(e,`LIST`,v.NONE)||`[]`,r=t+`(`+n+`)`;break}default:throw Error(`Unknown operator: `+t)}return[r,v.FUNCTION_CALL]},a([{type:`math_random_float_v1`,message0:`%{BKY_MATH_V1_RANDOM_FLOAT_TITLE}`,output:`Number`,style:`math_blocks`,tooltip:`%{BKY_MATH_V1_RANDOM_FLOAT_TOOLTIP}`,helpUrl:`%{BKY_MATH_V1_RANDOM_FLOAT_HELPURL}`}]),y.forBlock.math_random_float_v1=function(){return[`Math.random()`,v.FUNCTION_CALL]},a([{type:`math_random_int_v1`,message0:`%{BKY_MATH_V1_RANDOM_INT_TITLE}`,args0:[{type:`input_value`,name:`FROM`,check:`Number`},{type:`input_value`,name:`TO`,check:`Number`}],inputsInline:!0,output:`Number`,style:`math_blocks`,tooltip:`%{BKY_MATH_V1_RANDOM_INT_TOOLTIP}`,helpUrl:`%{BKY_MATH_V1_RANDOM_INT_HELPURL}`}]),y.forBlock.math_random_int_v1=function(e){let t=y.valueToCode(e,`FROM`,v.NONE)||`0`,n=y.valueToCode(e,`TO`,v.NONE)||`0`;return[y.provideFunction_(`mathRandomInt`,`
|
|
251
|
+
function ${y.FUNCTION_NAME_PLACEHOLDER_}(a, b) {
|
|
252
252
|
if (a > b) {
|
|
253
253
|
// Swap a and b to ensure a is smaller.
|
|
254
254
|
var c = a;
|
|
@@ -257,8 +257,8 @@ function ${n.FUNCTION_NAME_PLACEHOLDER_}(a, b) {
|
|
|
257
257
|
}
|
|
258
258
|
return Math.floor(Math.random() * (b - a + 1) + a);
|
|
259
259
|
}
|
|
260
|
-
`)+`(`+
|
|
261
|
-
function ${
|
|
260
|
+
`)+`(`+t+`, `+n+`)`,v.FUNCTION_CALL]},a([{type:`math_round_v1`,message0:`%1 %2`,args0:[{type:`field_dropdown`,name:`OP`,options:[[`%{BKY_MATH_ROUND_OPERATOR_ROUND}`,`ROUND`],[`%{BKY_MATH_ROUND_OPERATOR_ROUNDUP}`,`ROUNDUP`],[`%{BKY_MATH_ROUND_OPERATOR_ROUNDDOWN}`,`ROUNDDOWN`]]},{type:`input_value`,name:`NUM`,check:`Number`}],output:`Number`,style:`math_blocks`,helpUrl:`%{BKY_MATH_V1_ROUND_HELPURL}`,tooltip:`%{BKY_MATH_V1_ROUND_TOOLTIP}`}]),y.forBlock.math_round_v1=function(e){let t=e.getFieldValue(`OP`),n=y.valueToCode(e,`NUM`,v.NONE)||`0`,r=``;switch(t){case`ROUND`:r=`Math.round(${n})`;break;case`ROUNDUP`:r=`Math.ceil(${n})`;break;case`ROUNDDOWN`:r=`Math.floor(${n})`;break}return[r,v.FUNCTION_CALL]},a([{type:`math_single_v1`,message0:`%1 %2`,args0:[{type:`field_dropdown`,name:`OP`,options:[[`%{BKY_MATH_SINGLE_OP_ROOT}`,`ROOT`],[`%{BKY_MATH_SINGLE_OP_ABSOLUTE}`,`ABS`],[`-`,`NEG`],[`ln`,`LN`],[`log10`,`LOG10`],[`e^`,`EXP`],[`10^`,`POW10`]]},{type:`input_value`,name:`NUM`,check:`Number`}],output:`Number`,style:`math_blocks`,helpUrl:`%{BKY_MATH_V1_SINGLE_HELPURL}`,extensions:[`math_op_tooltip_v1`]}]),y.forBlock.math_single_v1=function(e){let t=e.getFieldValue(`OP`),n,r;if(t===`NEG`)return r=y.valueToCode(e,`NUM`,v.UNARY_NEGATION)||`0`,r[0]===`-`&&(r=` `+r),n=`-`+r,[n,v.UNARY_NEGATION];switch(r=y.valueToCode(e,`NUM`,v.NONE)||`0`,t){case`ROOT`:n=`Math.sqrt(${r})`;break;case`ABS`:n=`Math.abs(${r})`;break;case`LN`:n=`Math.log(${r})`;break;case`EXP`:n=`Math.exp(${r})`;break;case`POW10`:n=`Math.pow(10, ${r})`;break}if(n)return[n,v.FUNCTION_CALL];switch(t){case`LOG10`:n=`Math.log(${r}) / Math.log(10)`;break;default:throw Error(`Unknown math operator: `+t)}return[n,v.DIVISION]},a([{type:`math_trig_v1`,message0:`%1 %2`,args0:[{type:`field_dropdown`,name:`OP`,options:[[`%{BKY_MATH_TRIG_SIN}`,`SIN`],[`%{BKY_MATH_TRIG_COS}`,`COS`],[`%{BKY_MATH_TRIG_TAN}`,`TAN`],[`%{BKY_MATH_TRIG_ASIN}`,`ASIN`],[`%{BKY_MATH_TRIG_ACOS}`,`ACOS`],[`%{BKY_MATH_TRIG_ATAN}`,`ATAN`]]},{type:`input_value`,name:`NUM`,check:`Number`}],output:`Number`,style:`math_blocks`,helpUrl:`%{BKY_MATH_V1_TRIG_HELPURL}`,extensions:[`math_op_tooltip_v1`]}]),y.forBlock.math_trig_v1=function(e){let t,n=e.getFieldValue(`OP`);t=n===`SIN`||n===`COS`||n===`TAN`?y.valueToCode(e,`NUM`,v.DIVISION)||`0`:y.valueToCode(e,`NUM`,v.NONE)||`0`;let r;switch(n){case`SIN`:r=`Math.sin(${t} / 180 * Math.PI)`;break;case`COS`:r=`Math.cos(${t} / 180 * Math.PI)`;break;case`TAN`:r=`Math.tan(${t} / 180 * Math.PI)`;break}if(r)return[r,v.FUNCTION_CALL];switch(n){case`ASIN`:r=`Math.asin(${t}) / Math.PI * 180`;break;case`ACOS`:r=`Math.acos(${t}) / Math.PI * 180`;break;case`ATAN`:r=`Math.atan(${t}) / Math.PI * 180`;break;default:throw Error(`Unknown math operator: `+n)}return[r,v.DIVISION]};const $r=S.xml;x.object_create_container_v1={init:function(){this.appendDummyInput().appendField(`%{BKY_OBJECT_V1_CREATE_CONTAINER_TITLE}`),this.appendStatementInput(`STACK`),this.setStyle(`object_blocks`),this.contextMenu=!1}},x.object_create_item_v1={init:function(){this.appendDummyInput().appendField(`%{BKY_OBJECT_V1_CREATE_ITEM_TITLE}`),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setStyle(`object_blocks`),this.contextMenu=!1}},x.object_create_v1={init:function(){this.itemCount_=0,this.appendDummyInput().appendField(`%{BKY_OBJECT_V1_CREATE_TITLE}`),this.setMutator(new xe.MutatorIcon([`object_create_item_v1`],this)),this.setOutput(!0,`Object`),this.setStyle(`object_blocks`),this.setTooltip(`%{BKY_OBJECT_V1_CREATE_TOOLTIP}`),this.setHelpUrl(`%{BKY_OBJECT_V1_CREATE_HELPURL}`)},mutationToDom:function(){let e=$r.createElement(`mutation`);return e.setAttribute(`items`,String(this.itemCount_)),e},domToMutation:function(e){let t=e.getAttribute(`items`)??``;this.itemCount_=parseInt(t,0),this.updateShape_()},saveExtraState:function(){return{itemCount:this.itemCount_}},loadExtraState:function(e){this.itemCount_=e.itemCount??0,this.updateShape_()},decompose:function(e){let t=e.newBlock(`object_create_container_v1`);t.initSvg();let n=t.getInput(`STACK`).connection;for(let t=0;t<this.itemCount_;t++){let t=e.newBlock(`object_create_item_v1`);t.initSvg(),n.connect(t.previousConnection),n=t.nextConnection}return t},compose:function(e){let t=e.getInputTargetBlock(`STACK`),n=[],r=[];for(;t;){if(t.isInsertionMarker()){t=t.getNextBlock();continue}n.push(t.key_),r.push(t.valueConnection_),t=t.getNextBlock()}for(let e=0;e<this.itemCount_;e++){let t=this.getInput(`ADD`+e).connection.targetConnection;t&&!r.includes(t)&&t.disconnect()}this.itemCount_=r.length,this.updateShape_();for(let e=0;e<this.itemCount_;e++)this.setFieldValue(n[e],`KEY`+e),r[e]?.reconnect(this,`ADD`+e)},saveConnections:function(e){let t=e.getInputTargetBlock(`STACK`),n=0;for(;t;){if(t.isInsertionMarker()){t=t.getNextBlock();continue}t.key_=this.getFieldValue(`KEY`+n),t.valueConnection_=this.getInput(`ADD`+n)?.connection.targetConnection,t=t.getNextBlock(),n++}},updateShape_:function(){for(let e=0;e<this.itemCount_;e++)this.getInput(`ADD`+e)||this.appendValueInput(`ADD`+e).setAlign(m.Align.RIGHT).appendField(new n(`key`),`KEY`+e);for(let e=this.itemCount_;this.getInput(`ADD`+e);e++)this.removeInput(`ADD`+e)}},y.forBlock.object_create_v1=function(e){let t=e,n=`{`;for(let e=0;e<t.itemCount_;e++){let r=t.getFieldValue(`KEY`+e),i=y.valueToCode(t,`ADD`+e,v.ATOMIC)||null;n+=y.quote_(r)+`: `+i,e<t.itemCount_-1&&(n+=`, `)}return n+=`}`,[n,v.ATOMIC]},a([{type:`object_delete_v1`,message0:`%{BKY_OBJECT_V1_DELETE_TITLE}`,args0:[{type:`input_value`,name:`OBJECT`,check:`Object`,align:`RIGHT`},{type:`input_value`,name:`KEY`,check:`String`,align:`RIGHT`}],inputsInline:!0,previousStatement:null,nextStatement:null,style:`object_blocks`,tooltip:`%{BKY_OBJECT_V1_DELETE_TOOLTIP}`,helpUrl:`%{BKY_OBJECT_V1_DELETE_HELPURL}`}]),y.forBlock.object_delete_v1=function(e){return`${y.provideFunction_(`objectDelete`,`
|
|
261
|
+
function ${y.FUNCTION_NAME_PLACEHOLDER_}(obj, key) {
|
|
262
262
|
if (typeof(obj) !== 'object' || obj === null) {
|
|
263
263
|
return
|
|
264
264
|
}
|
|
@@ -290,8 +290,8 @@ function ${n.FUNCTION_NAME_PLACEHOLDER_}(obj, key) {
|
|
|
290
290
|
}
|
|
291
291
|
}
|
|
292
292
|
}
|
|
293
|
-
`)}(${
|
|
294
|
-
function ${
|
|
293
|
+
`)}(${y.valueToCode(e,`OBJECT`,v.ATOMIC)||`null`}, ${y.valueToCode(e,`KEY`,v.ATOMIC)||`''`});\n`},a([{type:`object_from_json_v1`,message0:`%{BKY_OBJECT_V1_FROM_JSON_TITLE}`,args0:[{type:`input_value`,name:`JSON`,check:`String`}],inputsInline:!0,output:`Object`,style:`object_blocks`,tooltip:`%{BKY_OBJECT_V1_FROM_JSON_TOOLTIP}`,helpUrl:`%{BKY_OBJECT_V1_FROM_JSON_HELPURL}`}]),y.forBlock.object_from_json_v1=function(e){return[`__parseJsonV1__(${y.valueToCode(e,`JSON`,v.NONE)||`''`})`,v.FUNCTION_CALL]},a([{type:`object_get_v1`,message0:`%{BKY_OBJECT_V1_GET_TITLE}`,args0:[{type:`input_value`,name:`OBJECT`,check:`Object`,align:`RIGHT`},{type:`input_value`,name:`KEY`,check:`String`,align:`RIGHT`}],inputsInline:!0,output:null,style:`object_blocks`,tooltip:`%{BKY_OBJECT_V1_GET_TOOLTIP}`,helpUrl:`%{BKY_OBJECT_V1_GET_HELPURL}`}]),y.forBlock.object_get_v1=function(e){return[`${y.provideFunction_(`objectGet`,`
|
|
294
|
+
function ${y.FUNCTION_NAME_PLACEHOLDER_}(obj, key) {
|
|
295
295
|
if (typeof(obj) !== 'object' || obj === null) {
|
|
296
296
|
return
|
|
297
297
|
}
|
|
@@ -315,8 +315,8 @@ function ${n.FUNCTION_NAME_PLACEHOLDER_}(obj, key) {
|
|
|
315
315
|
}
|
|
316
316
|
}
|
|
317
317
|
}
|
|
318
|
-
`)}(${
|
|
319
|
-
function ${
|
|
318
|
+
`)}(${y.valueToCode(e,`OBJECT`,v.ATOMIC)||`null`}, ${y.valueToCode(e,`KEY`,v.ATOMIC)||`''`})`,v.FUNCTION_CALL]},a([{type:`object_set_v1`,message0:`%{BKY_OBJECT_V1_SET_TITLE}`,args0:[{type:`input_value`,name:`OBJECT`,check:`Object`,align:`RIGHT`},{type:`input_value`,name:`KEY`,check:`String`,align:`RIGHT`},{type:`input_value`,name:`TO`,check:[`String`,`Number`,`Boolean`,`Array`,`Object`],align:`RIGHT`}],inputsInline:!0,previousStatement:null,nextStatement:null,style:`object_blocks`,tooltip:`%{BKY_OBJECT_V1_SET_TOOLTIP}`,helpUrl:`%{BKY_OBJECT_V1_SET_HELPURL}`}]),y.forBlock.object_set_v1=function(e){return`${y.provideFunction_(`objectSet`,`
|
|
319
|
+
function ${y.FUNCTION_NAME_PLACEHOLDER_}(obj, key, val) {
|
|
320
320
|
if (typeof(obj) !== 'object' || obj === null) {
|
|
321
321
|
return
|
|
322
322
|
}
|
|
@@ -341,38 +341,38 @@ function ${n.FUNCTION_NAME_PLACEHOLDER_}(obj, key, val) {
|
|
|
341
341
|
}
|
|
342
342
|
}
|
|
343
343
|
}
|
|
344
|
-
`)}(${
|
|
345
|
-
`}
|
|
346
|
-
var res = __downloadResourceV1__(${
|
|
344
|
+
`)}(${y.valueToCode(e,`OBJECT`,v.ATOMIC)||`null`}, ${y.valueToCode(e,`KEY`,v.ATOMIC)||`''`}, ${y.valueToCode(e,`TO`,v.ATOMIC)||`null`});\n`},a([{type:`object_to_json_v1`,message0:`%{BKY_OBJECT_V1_TO_JSON_TITLE}`,args0:[{type:`input_value`,name:`OBJECT`,check:`Object`}],inputsInline:!0,output:`String`,style:`object_blocks`,tooltip:`%{BKY_OBJECT_V1_TO_JSON_TOOLTIP}`,helpUrl:`%{BKY_OBJECT_V1_TO_JSON_HELPURL}`}]),y.forBlock.object_to_json_v1=function(e){return[`__jsonStringifyV1__(${y.valueToCode(e,`OBJECT`,v.NONE)||`null`})`,v.FUNCTION_CALL]};const ei=S.xml;x.procedure_def_container_v1={init:function(){this.appendDummyInput().appendField(`%{BKY_PROCEDURE_V1_DEF_CONTAINER_TITLE}`).appendField(new ve(!1),`WITHRETURN`),this.appendStatementInput(`STACK`),this.setStyle(`procedure_blocks`),this.contextMenu=!1}},x.procedure_def_item_v1={init:function(){let e=new n(i.DEFAULT_ARG);e.setValidator(this.validator_),this.appendDummyInput().appendField(`%{BKY_PROCEDURE_V1_DEF_ITEM_TITLE}`).appendField(e,`NAME`),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setStyle(`procedure_blocks`),this.contextMenu=!1},validator_:function(e){if(e=e.replace(/[\s\xa0]+/g,` `).replace(/^ | $/g,``),!e)return null;let t=this.getSourceBlock();if(!t)return null;let n=t.workspace;n.targetWorkspace&&(n=n.targetWorkspace);let r=n.getAllBlocks(!1);for(let n=0;n<r.length;n++){let i=r[n];if(i.type===`procedure_def_item_v1`&&i.id!==t.id&&i.getFieldValue(`NAME`).toLowerCase()===e.toLowerCase())return null}return e}},x.procedure_def_v1={init:function(){this.withReturn=!1,this.args=[];let e=new n(i.findLegalName(``,this));e.setValidator(i.rename),e.setSpellcheck(!1),this.appendDummyInput(`DUMMY`).appendField(e,`NAME`),this.appendStatementInput(`HANDLE`),this.setMutator(new xe.MutatorIcon([`procedure_def_item_v1`],this)),this.setStyle(`procedure_blocks`),this.setTooltip(`%{BKY_PROCEDURE_V1_DEF_TOOLTIP}`),this.setHelpUrl(`%{BKY_PROCEDURE_V1_DEF_HELPURL}`)},mutationToDom:function(){let e=ei.createElement(`mutation`);return e.setAttribute(`withreturn`,this.withReturn?`TRUE`:`FALSE`),this.args.forEach(t=>{let n=ei.createElement(`arg`);n.setAttribute(`name`,t.name),n.setAttribute(`id`,t.id),e.appendChild(n)}),e},domToMutation:function(e){this.withReturn=e.getAttribute(`withreturn`)===`TRUE`;let t=[];for(let n=0;n<e.childNodes.length;n++){let r=e.childNodes[n];if(r&&r.nodeName.toLowerCase()===`arg`){let e=r.getAttribute(`name`),n=r.getAttribute(`id`);t.push({name:e,id:n})}}this.args=t,this.updateShape_()},saveExtraState:function(){return{withReturn:this.withReturn,args:this.args}},loadExtraState:function(e){this.withReturn=e.withReturn,this.args=e.args,this.updateShape_()},getProcedureDef:function(){let e=this.getFieldValue(`NAME`),t=[];return this.args.forEach(e=>{t.push(e.name)}),[e,t,this.withReturn]},decompose:function(e){let t=e.newBlock(`procedure_def_container_v1`);t.initSvg(),t.setFieldValue(this.withReturn,`WITHRETURN`);let n=t.getInput(`STACK`).connection;for(let t=0;t<this.args.length;t++){let r=this.args[t],i=e.newBlock(`procedure_def_item_v1`);i.setFieldValue(r.name,`NAME`),i.initSvg(),n.connect(i.previousConnection),n=i.nextConnection}return t},compose:function(e){this.withReturn=e.getFieldValue(`WITHRETURN`)===`TRUE`;let t=[],n=e.getInputTargetBlock(`STACK`);for(;n;){if(n.isInsertionMarker()){n=n.getNextBlock();continue}t.push({name:n.getFieldValue(`NAME`),id:n.id}),n=n.getNextBlock()}this.args=t,this.updateShape_(),this.ensureBlocks_()},updateShape_:function(){let e=this.getInput(`DUMMY`);this.withReturn?e.fieldRow.find(e=>e.name===`WITHRETURN`)||e.appendField(`%{BKY_PROCEDURE_WITH_RETURN}`,`WITHRETURN`):e.removeField(`WITHRETURN`,!0);for(let e=0;e<this.args.length;e++)this.getInput(`ARG`+e)||(this.appendValueInput(`ARG`+e),this.moveInputBefore(`ARG`+e,`HANDLE`));for(let e=this.args.length;this.getInput(`ARG`+e);e++){let t=this.getInput(`ARG`+e)?.connection?.targetBlock();t&&t.dispose(),this.removeInput(`ARG`+e)}},ensureBlocks_:function(){if(!this.isInsertionMarker())for(let e=0;e<this.args.length;e++){let t=this.args[e],n=this.getInput(`ARG`+e).connection,r=n.targetBlock();if(r)r.setKeyName(`__param@${t.id}__`,t.name,!1);else try{b.disable(),r=ln(this.workspace,`__param@${t.id}__`,t.name,!1),r.outputConnection.connect(n)}finally{b.enable()}}}};const ti=S.xml;x.procedure_return_v1={init:function(){this.withReturn=!1,this.appendDummyInput(`DUMMY`).appendField(`%{BKY_PROCEDURE_RETURN}`),this.appendValueInput(`VALUE`).appendField(`%{BKY_PROCEDURE_RETURN}`).setVisible(!1),this.setPreviousStatement(!0),this.setStyle(`procedure_blocks`),this.setTooltip(`%{BKY_PROCEDURE_V1_RETURN_TOOLTIP}`),this.setHelpUrl(`%{BKY_PROCEDURE_V1_RETURN_HELPURL}`)},mutationToDom:function(){let e=ti.createElement(`mutation`);return e.setAttribute(`withreturn`,this.withReturn?`TRUE`:`FALSE`),e},domToMutation:function(e){this.withReturn=e.getAttribute(`withreturn`)===`TRUE`,this.updateShape_(),setTimeout(()=>{this.checkWarning_()},0)},saveExtraState:function(){return{withReturn:this.withReturn}},loadExtraState:function(e){this.withReturn=e.withReturn,this.updateShape_(),setTimeout(()=>{this.checkWarning_()},0)},onchange:function(e){if(e.type===b.BLOCK_DRAG){let t=e;if(t.isStart||!t.blocks?.find(e=>e.id===this.id))return;this.updateShape_(),setTimeout(()=>{this.checkWarning_()},0)}},updateShape_:function(){let e=!1,t=this.getRootBlock();if(t.type.startsWith(`procedure_def_v`)){let n=t;this.withReturn!==n.withReturn&&(e=!0)}else t.type.startsWith(`func_entry_v`)&&this.withReturn&&(e=!0);if(e){if(this.withReturn){let e=this.getInput(`INPUT`)?.connection?.targetConnection;e&&e.disconnect()}this.withReturn=!this.withReturn}this.getInput(`DUMMY`).setVisible(!this.withReturn),this.getInput(`VALUE`).setVisible(this.withReturn),this.render()},checkWarning_:function(){let e=this.getRootBlock();e.type===`procedure_def_v1`||e.type===`func_entry_v1`?this.setWarningText(null):this.setWarningText(`the block can only be used in procedure block`)}},y.forBlock.procedure_return_v1=function(e){let t=e;return t.withReturn?`return ${y.valueToCode(t,`VALUE`,v.NONE)||`null`};\n`:`return;
|
|
345
|
+
`},x.download_resource_v1={init:function(){this.appendDummyInput().appendField(`%{BKY_ASSET_V1_DOWNLOAD_ASSET_TITLE}`),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null),this.setStyle(`procedure_blocks`),this.setTooltip(`%{BKY_ASSET_V1_DOWNLOAD_ASSET_TOOLTIP}`),this.setHelpUrl(`%{BKY_ASSET_V1_DOWNLOAD_ASSET_HELPURL}`)},saveExtraState:function(){return{}},loadExtraState:function(){this.updateShape_(),setTimeout(()=>{this.ensureBlocks_()},0)},updateShape_:function(){this.getInput(`HANDLE`)||this.appendStatementInput(`HANDLE`).appendField(`%{BKY_ASSET_DO}`),this.getInput(`DATA`)||(this.appendValueInput(`DATA`),this.moveInputBefore(`DATA`,`HANDLE`)),this.getInput(`MESSAGE`)||(this.appendValueInput(`MESSAGE`),this.moveInputBefore(`MESSAGE`,`DATA`)),this.getInput(`SUCCESS`)||(this.appendValueInput(`SUCCESS`).appendField(`%{BKY_ASSET_RETURN}`),this.moveInputBefore(`SUCCESS`,`MESSAGE`)),this.getInput(`ASSET`)||(this.appendValueInput(`ASSET`).setCheck(`Resource`).setAlign(m.Align.RIGHT).appendField(`%{BKY_ASSET_ASSET}`),this.moveInputBefore(`ASSET`,`SUCCESS`))},ensureBlocks_:function(){this.isInsertionMarker()||H(this,[[`SUCCESS`,`__success__`,`x-runtime-lib.success`,!0],[`MESSAGE`,`__message__`,`x-runtime-lib.message`,!0],[`DATA`,`__data__`,`x-runtime-lib.data`,!0]])}},y.forBlock.download_resource_v1=function(e){return`{
|
|
346
|
+
var res = __downloadResourceV1__(${y.valueToCode(e,`ASSET`,v.ATOMIC)||null});
|
|
347
347
|
var __success__ = res.success;
|
|
348
348
|
var __message__ = res.message;
|
|
349
349
|
var __data__ = res.data;
|
|
350
|
-
${
|
|
350
|
+
${y.statementToCode(e,`HANDLE`)}
|
|
351
351
|
}
|
|
352
|
-
`};function
|
|
353
|
-
var res = __uploadResourceV1__(${
|
|
352
|
+
`};function ni(e){let t=w.resource.spaces.find(t=>t.id===e);if(!t)return[];let n=[];function r(e,t){let i=t+e.name+`/`;n.push({id:e.id,name:i}),e.children.forEach(e=>{r(e,i)})}return r(t.dirTree,``),n}function ri(e){let t=[];return ni(e).forEach(({id:e,name:n})=>{t.push([n,e])}),L(t)}function ii(e,t){let n=w.resource.spaces.find(t=>t.id===e);if(!n)return[];let r=[];return n.resources.forEach(e=>{e.dirid===t&&r.push(e)}),r}function ai(e,t){let n=[];return ii(e,t).forEach(({id:e,name:t})=>{n.push([t,e])}),L(n)}function oi(){let e=[];return w.resource.spaces.forEach(t=>{t.resources.length>0&&e.push(t)}),e}function si(){let e=[];return oi().forEach(({id:t,name:n})=>{e.push([n,t])}),L(e)}x.select_resource_v1={init:function(){this.space={id:``,name:``},this.dir={id:``,name:``},this.resource={id:``,name:``},this.appendDummyInput().appendField(`%{BKY_RESOURCE_V1_SELECT_RESOURCE_TITLE`).appendField(new C(()=>this.genSpaceOpts_()),`SPACE`).appendField(new C(()=>this.genDirOpts_()),`DIR`).appendField(new C(()=>this.genResourceOpts_()),`RESOURCE`),this.setOutput(!0,`Resource`),this.setStyle(`resource_blocks`),this.setTooltip(`%{BKY_RESOURCE_V1_SELECT_RESOURCE_TOOLTIP}`),this.setHelpUrl(`%{BKY_RESOURCE_V1_SELECT_RESOURCE_HELPURL}`),this.initData_()},initData_:function(){if(this.space.id)return;let e=oi()?.[0];if(!e)return;this.space.id=e.id,this.space.name=e.name;let t=this.getField(`SPACE`);t.getOptions(!1),t.setValue(this.space.id);let n=ni(this.space.id)?.[0];if(!n)return;this.dir.id=n.id,this.dir.name=n.name;let r=this.getField(`DIR`);r.getOptions(!1),r.setValue(this.dir.id);let i=ii(this.space.id,this.dir.id)?.[0];if(!i)return;this.resource.id=i.id,this.resource.name=i.name;let a=this.getField(`RESOURCE`);a.getOptions(!1),a.setValue(this.resource.id)},saveExtraState:function(){return{space:this.space,dir:this.dir,resource:this.resource}},loadExtraState:function(e){this.space=_e(e.space),this.dir=_e(e.dir),this.resource=_e(e.resource)},genSpaceOpts_:function(){return si()},genDirOpts_:function(){return ri(this.space.id)},genResourceOpts_:function(){return ai(this.space.id,this.dir.id)}},y.forBlock.select_resource_v1=function(){return``},x.upload_resource_v1={init:function(){this.appendDummyInput().appendField(`%{BKY_RESOURCE_V1_UPLOAD_RESOURCE_TITLE}`),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null),this.setStyle(`resource_blocks`),this.setTooltip(`%{BKY_RESOURCE_V1_UPLOAD_RESOURCE_TOOLTIP}`),this.setHelpUrl(`%{BKY_RESOURCE_V1_UPLOAD_RESOURCE_HELPURL}`)},saveExtraState:function(){return{}},loadExtraState:function(){this.updateShape_(),this.updateShadow_(),setTimeout(()=>{this.ensureBlocks_()},0)},updateShape_:function(){this.getInput(`HANDLE`)||this.appendStatementInput(`HANDLE`).appendField(`%{BKY_RESOURCE_DO}`),this.getInput(`RESULT`)||(this.appendValueInput(`RESULT`),this.moveInputBefore(`RESULT`,`HANDLE`)),this.getInput(`MESSAGE`)||(this.appendValueInput(`MESSAGE`),this.moveInputBefore(`MESSAGE`,`RESULT`)),this.getInput(`SUCCESS`)||(this.appendValueInput(`SUCCESS`).appendField(`%{BKY_RESOURCE_RESULT}`),this.moveInputBefore(`SUCCESS`,`MESSAGE`)),this.getInput(`DATA`)||(this.appendValueInput(`DATA`).setAlign(m.Align.RIGHT).appendField(`%{BKY_RESOURCE_DATA}`),this.moveInputBefore(`DATA`,`SUCCESS`)),this.getInput(`DIR`)||(this.appendValueInput(`DIR`).setCheck(`SelectDir`).setAlign(m.Align.RIGHT).appendField(`%{BKY_RESOURCE_DIR}`),this.moveInputBefore(`DIR`,`DATA`)),this.getInput(`NAME`)||(this.appendValueInput(`NAME`).setCheck(`String`).setAlign(m.Align.RIGHT).appendField(`%{BKY_RESOURCE_NAME}`),this.moveInputBefore(`NAME`,`DIR`))},updateShadow_:function(){if(this.isInsertionMarker())return;let e=un(``);this.getInput(`NAME`)?.setShadowDom(e)},ensureBlocks_:function(){this.isInsertionMarker()||H(this,[[`SUCCESS`,`__success__`,`x-runtime-lib.success`,!0],[`MESSAGE`,`__message__`,`x-runtime-lib.message`,!0],[`RESULT`,`__result__`,`x-runtime-lib.result`,!0]])}},y.forBlock.upload_resource_v1=function(e){return`{
|
|
353
|
+
var res = __uploadResourceV1__(${y.valueToCode(e,`NAME`,v.ATOMIC)||`''`}, ${y.valueToCode(e,`DIR`,v.ATOMIC)||`null`}, ${y.valueToCode(e,`DATA`,v.ATOMIC)||`null`});
|
|
354
354
|
var __success__ = res.success;
|
|
355
355
|
var __message__ = res.message;
|
|
356
356
|
var __result__ = res.result;
|
|
357
|
-
${
|
|
357
|
+
${y.statementToCode(e,`HANDLE`)}
|
|
358
358
|
}
|
|
359
|
-
`},
|
|
360
|
-
function ${
|
|
359
|
+
`},a([{type:`text_v1`,message0:`%{BKY_TEXT_V1_TEXT_TITLE}`,args0:[{type:`field_input`,name:`TEXT`,text:``}],output:`String`,style:`text_blocks`,tooltip:`%{BKY_TEXT_V1_TEXT_TOOLTIP}`,helpUrl:`%{BKY_TEXT_V1_TEXT_HELPURL}`,extensions:[`parent_tooltip_when_inline`]}]),y.forBlock.text_v1=function(e){return[y.quote_(e.getFieldValue(`TEXT`)),v.ATOMIC]};const ci=/^\s*'([^']|\\')*'\s*$/;function li(e){return ci.test(e)?[e,v.ATOMIC]:[`String(${e})`,v.FUNCTION_CALL]}h.register(`text_append_tooltip_v1`,h.buildTooltipWithFieldText(`%{BKY_TEXT_V1_APPEND_TOOLTIP}`,`VAR`)),a([{type:`text_append_v1`,message0:`%{BKY_TEXT_V1_APPEND_TITLE}`,args0:[{type:`field_variable`,name:`VAR`},{type:`input_value`,name:`TEXT`}],previousStatement:null,nextStatement:null,style:`text_blocks`,helpUrl:`%{BKY_TEXT_V1_APPEND_HELPURL}`,extensions:[`text_append_tooltip_v1`]}]),y.forBlock.text_append_v1=function(e){return`${y.nameDB_?.getName(e.getFieldValue(`VAR`),f.NameType.VARIABLE)} += ${li(y.valueToCode(e,`TEXT`,v.NONE)||`''`)};\n`},a([{type:`text_change_case_v1`,message0:`%{BKY_TEXT_V1_CHANGE_CASE_TITLE}`,args0:[{type:`input_value`,name:`TEXT`,check:`String`},{type:`field_dropdown`,name:`CASE`,options:[[`%{BKY_TEXT_CHANGE_CASE_OPERATOR_UPPER_CASE}`,`UPPERCASE`],[`%{BKY_TEXT_CHANGE_CASE_OPERATOR_LOWER_CASE}`,`LOWERCASE`],[`%{BKY_TEXT_CHANGE_CASE_OPERATOR_TITLE_CASE}`,`TITLECASE`]]}],output:`String`,style:`text_blocks`,tooltip:`%{BKY_TEXT_V1_CHANGE_CASE_TOOLTIP}`,helpUrl:`%{BKY_TEXT_V1_CHANGE_CASE_HELPURL}`}]),y.forBlock.text_change_case_v1=function(e){let t={UPPERCASE:`.toUpperCase()`,LOWERCASE:`.toLowerCase()`,TITLECASE:null}[e.getFieldValue(`CASE`)],n=y.valueToCode(e,`TEXT`,t?v.MEMBER:v.NONE)||`''`,r;return r=t?n+t:y.provideFunction_(`textToTitleCase`,`
|
|
360
|
+
function ${y.FUNCTION_NAME_PLACEHOLDER_}(str) {
|
|
361
361
|
return str.slice(0, 1).toUpperCase() + str.slice(1).toLowerCase();
|
|
362
362
|
}
|
|
363
|
-
`)+`(`+
|
|
364
|
-
function ${
|
|
363
|
+
`)+`(`+n+`)`,[r,v.FUNCTION_CALL]},a([{type:`text_char_at_v1`,message0:`%{BKY_TEXT_V1_CHAR_AT_TITLE}`,args0:[{type:`input_value`,name:`VALUE`,check:`String`},{type:`input_value`,name:`AT`,check:`Number`}],inputsInline:!0,output:`String`,style:`text_blocks`,tooltip:`%{BKY_TEXT_V1_CHAR_AT_TOOLTIP}`,helpUrl:`%{BKY_TEXT_V1_CHAR_AT_HELPURL}`}]),y.forBlock.text_char_at_v1=function(e){return[`${y.valueToCode(e,`VALUE`,v.MEMBER)||`[]`}.charAt(${y.getAdjusted(e,`AT`)})`,v.FUNCTION_CALL]},a([{type:`text_count_v1`,message0:`%{BKY_TEXT_V1_COUNT_TITLE}`,args0:[{type:`input_value`,name:`TEXT`,check:`String`},{type:`input_value`,name:`SUBSTR`,check:`String`}],output:`Number`,inputsInline:!0,style:`text_blocks`,tooltip:`%{BKY_TEXT_V1_COUNT_TOOLTIP}`,helpUrl:`%{BKY_TEXT_V1_COUNT_HELPURL}`}]),y.forBlock.text_count_v1=function(e){let t=y.valueToCode(e,`TEXT`,v.NONE)||`''`,n=y.valueToCode(e,`SUBSTR`,v.NONE)||`''`;return[`${y.provideFunction_(`textCount`,`
|
|
364
|
+
function ${y.FUNCTION_NAME_PLACEHOLDER_}(haystack, needle) {
|
|
365
365
|
if (needle.length > 0) {
|
|
366
366
|
return haystack.split(needle).length - 1;
|
|
367
367
|
} else {
|
|
368
368
|
return 0;
|
|
369
369
|
}
|
|
370
370
|
}
|
|
371
|
-
`)}(${
|
|
372
|
-
function ${
|
|
371
|
+
`)}(${t}, ${n})`,v.FUNCTION_CALL]},a([{type:`text_index_of_v1`,message0:`%{BKY_TEXT_V1_INDEX_OF_TITLE}`,args0:[{type:`input_value`,name:`TEXT`,check:`String`},{type:`field_dropdown`,name:`OP`,options:[[`%{BKY_TEXT_INDEX_OF_OPERATOR_FIRST}`,`FIRST`],[`%{BKY_TEXT_INDEX_OF_OPERATOR_LAST}`,`LAST`]]},{type:`input_value`,name:`SUBSTR`,check:`String`}],inputsInline:!0,output:`Number`,style:`text_blocks`,tooltip:`%{BKY_TEXT_V1_INDEX_OF_TOOLTIP}`,helpUrl:`%{BKY_TEXT_V1_INDEX_OF_HELPURL}`}]),y.forBlock.text_index_of_v1=function(e){let t=e.getFieldValue(`OP`)===`FIRST`?`indexOf`:`lastIndexOf`;return[`${y.valueToCode(e,`TEXT`,v.MEMBER)||`''`}.${t}(${y.valueToCode(e,`SUBSTR`,v.NONE)||`''`})`,v.FUNCTION_CALL]},a([{type:`text_is_empty_v1`,message0:`%{BKY_TEXT_V1_IS_EMPTY_TITLE}`,args0:[{type:`input_value`,name:`VALUE`,check:`String`}],output:`Boolean`,style:`text_blocks`,tooltip:`%{BKY_TEXT_V1_IS_EMPTY_TOOLTIP}`,helpUrl:`%{BKY_TEXT_V1_IS_EMPTY_HELPURL}`}]),y.forBlock.text_is_empty_v1=function(e){return[`!${y.valueToCode(e,`VALUE`,v.MEMBER)||`''`}.length`,v.LOGICAL_NOT]};const ui=S.xml;h.registerMutator(`text_join_mutator_v1`,{itemCount_:0,mutationToDom:function(){let e=ui.createElement(`mutation`);return e.setAttribute(`items`,`${this.itemCount_}`),e},domToMutation:function(e){this.itemCount_=parseInt(e.getAttribute(`items`),0),this.updateShape_()},saveExtraState:function(){return{itemCount:this.itemCount_}},loadExtraState:function(e){this.itemCount_=e.itemCount,this.updateShape_()},decompose:function(e){let t=e.newBlock(`text_join_container_v1`);t.initSvg();let n=t.getInput(`STACK`).connection;for(let t=0;t<this.itemCount_;t++){let t=e.newBlock(`text_join_item_v1`);t.initSvg(),n.connect(t.previousConnection),n=t.nextConnection}return t},compose:function(e){let t=e.getInputTargetBlock(`STACK`),n=[];for(;t;){if(t.isInsertionMarker()){t=t.getNextBlock();continue}n.push(t.valueConnection_),t=t.getNextBlock()}for(let e=0;e<this.itemCount_;e++){let t=this.getInput(`ADD`+e).connection.targetConnection;t&&n.indexOf(t)===-1&&t.disconnect()}this.itemCount_=n.length,this.updateShape_();for(let e=0;e<this.itemCount_;e++)n[e]?.reconnect(this,`ADD`+e)},saveConnections:function(e){let t=e.getInputTargetBlock(`STACK`),n=0;for(;t;){if(t.isInsertionMarker()){t=t.getNextBlock();continue}let e=this.getInput(`ADD`+n);t.valueConnection_=e&&e.connection.targetConnection,t=t.getNextBlock(),n++}},updateShape_:function(){this.itemCount_&&this.getInput(`EMPTY`)?this.removeInput(`EMPTY`):!this.itemCount_&&!this.getInput(`EMPTY`)&&this.appendDummyInput(`EMPTY`).appendField(`"`).appendField(`"`);for(let e=0;e<this.itemCount_;e++)if(!this.getInput(`ADD`+e)){let t=this.appendValueInput(`ADD`+e).setAlign(m.Align.RIGHT);e===0&&t.appendField(`%{BKY_TEXT_V1_JOIN_TITLE}`)}for(let e=this.itemCount_;this.getInput(`ADD`+e);e++)this.removeInput(`ADD`+e)}},function(){this.itemCount_=2,this.updateShape_(),this.setMutator(new xe.MutatorIcon([`text_join_item_v1`],this))}),a([{type:`text_join_v1`,message0:``,output:`String`,style:`text_blocks`,helpUrl:`%{BKY_TEXT_V1_JOIN_HELPURL}`,tooltip:`%{BKY_TEXT_V1_JOIN_TOOLTIP}`,mutator:`text_join_mutator_v1`},{type:`text_join_container_v1`,message0:`%{BKY_TEXT_V1_JOIN_TITLE} %1 %2`,args0:[{type:`input_dummy`},{type:`input_statement`,name:`STACK`}],style:`text_blocks`,enableContextMenu:!1},{type:`text_join_item_v1`,message0:`%{BKY_TEXT_V1_JOIN_ITEM_TITLE}`,previousStatement:null,nextStatement:null,style:`text_blocks`,enableContextMenu:!1}]),y.forBlock.text_join_v1=function(e){let t=e;switch(t.itemCount_){case 0:return[`''`,v.ATOMIC];case 1:return li(y.valueToCode(t,`ADD0`,v.NONE)||`''`);case 2:{let e=y.valueToCode(t,`ADD0`,v.NONE)||`''`,n=y.valueToCode(t,`ADD1`,v.NONE)||`''`;return[li(e)[0]+` + `+li(n)[0],v.ADDITION]}default:{let e=Array(t.itemCount_);for(let n=0;n<t.itemCount_;n++)e[n]=y.valueToCode(t,`ADD`+n,v.NONE)||`''`;return[`[`+e.join(`,`)+`].join('')`,v.FUNCTION_CALL]}}},a([{type:`text_length_v1`,message0:`%{BKY_TEXT_V1_LENGTH_TITLE}`,args0:[{type:`input_value`,name:`VALUE`,check:`String`}],output:`Number`,style:`text_blocks`,tooltip:`%{BKY_TEXT_V1_LENGTH_TOOLTIP}`,helpUrl:`%{BKY_TEXT_V1_LENGTH_HELPURL}`}]),y.forBlock.text_length_v1=function(e){return[`${y.valueToCode(e,`VALUE`,v.MEMBER)||`''`}.length`,v.MEMBER]},a([{type:`text_replace_v1`,message0:`%{BKY_TEXT_V1_REPLACE_TITLE}`,args0:[{type:`input_value`,name:`TEXT`,check:`String`},{type:`input_value`,name:`FROM`,check:`String`},{type:`input_value`,name:`TO`,check:`String`}],inputsInline:!0,output:`String`,style:`text_blocks`,tooltip:`%{BKY_TEXT_V1_REPLACE_TOOLTIP}`,helpUrl:`%{BKY_TEXT_V1_REPLACE_HELPURL}`}]),y.forBlock.text_replace_v1=function(e){let t=y.valueToCode(e,`TEXT`,v.NONE)||`''`,n=y.valueToCode(e,`FROM`,v.NONE)||`''`,r=y.valueToCode(e,`TO`,v.NONE)||`''`;return[`${y.provideFunction_(`textReplace`,`
|
|
372
|
+
function ${y.FUNCTION_NAME_PLACEHOLDER_}(haystack, needle, replacement) {
|
|
373
373
|
needle = needle.replace(/([-()\\[\\]{}+?*.$\\^|,:#<!\\\\])/g, '\\\\$1')
|
|
374
374
|
.replace(/\\x08/g, '\\\\x08');
|
|
375
375
|
return haystack.replace(new RegExp(needle, 'g'), replacement);
|
|
376
376
|
}
|
|
377
|
-
`)}(${
|
|
378
|
-
${n.statementToCode(e,`CALLBACK`)}});\n`},e.defineBlocksWithJsonArray([{type:`delay_v1`,message0:`%{BKY_TIME_V1_DELAY_TITLE}`,args0:[{type:`input_value`,name:`DURATION`,check:`Number`}],previousStatement:null,nextStatement:null,style:`time_blocks`,tooltip:`%{BKY_TIME_V1_DELAY_TOOLTIP}`,helpUrl:`%{BKY_TIME_V1_DELAY_HELPURL}`}]),n.forBlock.delay_v1=function(e){return`await __delayV1__(${n.valueToCode(e,`DURATION`,t.ATOMIC)||`0`});\n`};const Ri={customContextMenu:function(t){if(!this.isInFlyout){let n,r;this.type===`variable_get_v1`?(n=`variable_set_v1`,r=M(`VARIABLE_GET_CREATE_SET`)):this.type===`variable_set_v1`?(n=`variable_get_v1`,r=M(`VARIABLE_SET_CREATE_GET`)):console.assert(!1);let i=this.getField(`VAR`),a={type:n,fields:{VAR:i.saveState(!0)}};t.push({enabled:this.workspace.remainingCapacity()>0,text:r.replace(`%1`,i.getText()),callback:e.ContextMenu.callbackFactory(this,a)})}else if(this.type===`variable_get_v1`){let e={text:M(`RENAME_VARIABLE`),enabled:!0,callback:zi(this)},n=this.getField(`VAR`).getText(),r={text:M(`DELETE_VARIABLE`).replace(`%1`,n),enabled:!0,callback:Bi(this)};t.unshift(e),t.unshift(r)}}},zi=function(t){return function(){let n=t.workspace,r=t.getField(`VAR`).getVariable();e.Variables.renameVariable(n,r)}},Bi=function(t){return function(){let n=t.getField(`VAR`).getVariable();n&&e.Variables.deleteVariable(n.getWorkspace(),n,t)}};e.Extensions.registerMixin(`context_menu_variable_v1`,Ri),e.defineBlocksWithJsonArray([{type:`variable_get_v1`,message0:`%1`,args0:[{type:`field_variable`,name:`VAR`}],output:null,style:`variable_blocks`,tooltip:`%{BKY_VARIABLE_V1_GET_TOOLTIP}`,helpUrl:`%{BKY_VARIABLE_V1_GET_HELPURL}`,extensions:[`context_menu_variable_v1`]}]),n.forBlock.variable_get_v1=function(r){return[n.nameDB_.getName(r.getFieldValue(`VAR`),e.Names.NameType.VARIABLE),t.ATOMIC]},e.defineBlocksWithJsonArray([{type:`variable_set_v1`,message0:`%{BKY_VARIABLE_V1_SET_TITLE}`,args0:[{type:`field_variable`,name:`VAR`,variable:``},{type:`input_value`,name:`VALUE`}],previousStatement:null,nextStatement:null,style:`variable_blocks`,tooltip:`%{BKY_VARIABLE_V1_SET_TOOLTIP}`,helpUrl:`%{BKY_VARIABLE_V1_SET_HELPURL}`,extensions:[`context_menu_variable_v1`]}]),n.forBlock.variable_set_v1=function(r){return`${n.nameDB_.getName(r.getFieldValue(`VAR`),e.Names.NameType.VARIABLE)} = ${n.valueToCode(r,`VALUE`,t.ASSIGNMENT)||`0`};\n`},e.dialog.setConfirm(async(e,t)=>{t(!!await o({title:``,text:e}))}),e.dialog.setPrompt(async(e,t,n)=>{let r=await s({title:``,value:t});r!==void 0&&n(String(r))});const Vi=e.FieldDropdown.prototype;Vi.doClassValidation_=function(e){return e};const Hi=Vi.doValueUpdate_;Vi.doValueUpdate_=function(e){Hi.call(this,e),this.selectedOption&&this.selectedOption[1]!==e&&(this.selectedOption=null)};const Ui=Vi.getText_;Vi.getText_=function(){if(this.selectedOption)return Ui.call(this);let{i18n:e}=i,t=this.getSourceBlock();if(this.name===`APP`)return t.app.name;if(this.name===`PAGE`)return t.page.name;if(this.name===`ELEMENT`)return t.element.name;if(this.name===`NODE`){let n=p(t.node.key);if(n)return`${e.global.t(n.name)} / ${t.node.alias}`}else if(this.name===`PROPERTY`){let{kind:e,names:n}=t.property;return he(e,n)}else if(this.name===`EVENT`){let{kind:e,names:n}=t.event;return pe(e,n)}else if(this.name===`METHOD`){let{kind:e,names:n}=t.method;return me(e,n)}else if(this.name===`SPACE`)return t.space.name;else if(this.name===`FUNC`)return t.func.name;else if(this.name===`OUTPUT`)return t.output.name;else if(this.name===`TABLE`)return t.table.name;else if(this.name===`COLUMN`)return t.column.name;else if(this.name===`DIR`)return t.dir.name;else if(this.name===`RESOURCE`)return t.resource.name;return`<n/a>`},e.WorkspaceSvg.prototype.cleanUp=function(){this.setResizesEnabled(!1);let t=e.Events.getGroup();t||e.Events.setGroup(!0);let n=this.getTopBlocks(!0),r=n.filter(e=>e.isMovable()),i=n.filter(e=>!e.isMovable()).map(e=>e.getBoundingRectangle()),a=function(e){for(let t of i)if(e.intersects(t))return t;return null},o=0;for(let e of r){let t=e.getBoundingRectangle();e.moveBy(-t.left,o-t.top,[`cleanup`]),e.snapToGrid(),t=e.getBoundingRectangle();let n=a(t);for(;n!=null;)o=n.top+n.getHeight()+60,e.moveBy(0,o-t.top,[`cleanup`]),e.snapToGrid(),t=e.getBoundingRectangle(),n=a(t);o=e.getRelativeToSurfaceXY().y+e.getHeightWidth().height+60}e.Events.setGroup(t),this.setResizesEnabled(!0)};function Wi(e){let t=e.getParent();return t&&Wi(t)?!0:!t&&!!(e.outputConnection||e.previousConnection)}var Gi=class{init(){let t=e.ContextMenuRegistry.registry.getItem(`blockDisable`);t&&(t.preconditionFn=function(e){let t=e.block;return t&&!t.isInFlyout&&t.workspace.options.disable&&t.isEditable()?t.getInheritedDisabled()||Wi(t)?`disabled`:`enabled`:`hidden`})}};je(),e.ShortcutRegistry.registry.unregister(e.ShortcutItems.names.ESCAPE),new Ne().init({contextMenu:!0,shortcut:!0}),new Gi().init();var Ki=class extends e.Events.Abstract{isBlank=!0;recordUndo=!1;type=`state_change`;constructor(e){super(),this.workspaceId=e.id}};e.registry.register(e.registry.Type.EVENT,`state_change`,Ki);function qi(t){let n=e.getMainWorkspace();if(!n)return;let r=n.getBlockById(t);if(!r)return;let i=r.getRootBlock();if(!i)return;let a=i.getRelativeToSurfaceXY(),o=a.x*n.scale,s=a.y*n.scale;n.scroll(-o,-s)}function Ji(){let t=e.getMainWorkspace();if(!t)return;let n=t.getTopBlocks(!0)?.[0];n&&qi(n.id)}e.Themes.Classic.blockStyles={color_blocks:{colourPrimary:`#a5745b`,colourSecondary:`#ede3de`,colourTertiary:`#845d49`,hat:``},event_blocks:{colourPrimary:`#a5a55b`,colourSecondary:`#ededde`,colourTertiary:`#848449`,hat:``},list_blocks:{colourPrimary:`#745ba5`,colourSecondary:`#e3deed`,colourTertiary:`#5d4984`,hat:``},logic_blocks:{colourPrimary:`#5b80a5`,colourSecondary:`#dee6ed`,colourTertiary:`#496684`,hat:``},loop_blocks:{colourPrimary:`#5ba55b`,colourSecondary:`#deedde`,colourTertiary:`#498449`,hat:``},math_blocks:{colourPrimary:`#5b67a5`,colourSecondary:`#dee1ed`,colourTertiary:`#495284`,hat:``},method_blocks:{colourPrimary:`#995ba5`,colourSecondary:`#ebdeed`,colourTertiary:`#7a4984`,hat:``},object_blocks:{colourPrimary:`#80a55b`,colourSecondary:`#e6edde`,colourTertiary:`#668449`,hat:``},procedure_blocks:{colourPrimary:`#995ba5`,colourSecondary:`#ebdeed`,colourTertiary:`#7a4984`,hat:``},property_blocks:{colourPrimary:`#5ba5a5`,colourSecondary:`#deeded`,colourTertiary:`#498484`,hat:``},state_blocks:{colourPrimary:`#a55b67`,colourSecondary:`#eddee1`,colourTertiary:`#844952`,hat:``},text_blocks:{colourPrimary:`#5ba58c`,colourSecondary:`#deede8`,colourTertiary:`#498470`,hat:``},time_blocks:{colourPrimary:`#5b99a5`,colourSecondary:`#deebed`,colourTertiary:`#497a84`,hat:``},variable_blocks:{colourPrimary:`#a55b80`,colourSecondary:`#eddee6`,colourTertiary:`#844966`,hat:``}},e.Themes.Classic.categoryStyles={color_category:{colour:`#a5745b`},common_category:{colour:`#757575`},compute_category:{colour:`#757575`},data_category:{colour:`#757575`},event_category:{colour:`#a5a55b`},flow_category:{colour:`#757575`},func_category:{colour:`#757575`},list_category:{colour:`#745ba5`},logic_category:{colour:`#5b80a5`},loop_category:{colour:`#5ba55b`},math_category:{colour:`#5b67a5`},method_category:{colour:`#995ba5`},misc_category:{colour:`#757575`},object_category:{colour:`#80a55b`},procedure_category:{colour:`#995ba5`},property_category:{colour:`#5ba5a5`},resource_category:{colour:`#757575`},state_category:{colour:`#a55b67`},text_category:{colour:`#5ba58c`},time_category:{colour:`#5b99a5`},variable_category:{colour:`#a55b80`}};const Yi=e.Theme.defineTheme(`light`,{name:`light`,base:e.Themes.Classic,componentStyles:{workspaceBackgroundColour:`#ffffff`,toolboxBackgroundColour:`#eeeeee`,toolboxForegroundColour:``,flyoutBackgroundColour:`#eeeeee`,flyoutForegroundColour:`#000000`,flyoutOpacity:.8,scrollbarColour:``,insertionMarkerColour:``,insertionMarkerOpacity:.3,scrollbarOpacity:.4,cursorColour:``}}),Xi=e.Theme.defineTheme(`dark`,{name:`dark`,base:e.Themes.Classic,componentStyles:{workspaceBackgroundColour:`#1e1e1e`,toolboxBackgroundColour:`#272727`,toolboxForegroundColour:``,flyoutBackgroundColour:`#272727`,flyoutForegroundColour:`#ffffff`,flyoutOpacity:.8,scrollbarColour:``,insertionMarkerColour:``,insertionMarkerOpacity:.3,scrollbarOpacity:.4,cursorColour:``}});function Zi(t){let n=e.getMainWorkspace();switch(t){case`light`:n.setTheme(Yi);break;case`dark`:n.setTheme(Xi);break}}function Qi(e,t){e.find(e=>e===t)||e.push(t)}const $i=[`get_app_property_v1`,`get_app_state_v1`];function ea(e){let t=[];function n(e){for(let r of e.getChildren(!0))$i.includes(r.type)&&t.push(r),n(r)}return n(e),t}function ta(e){let t=[];for(let n of e)n.type===`get_app_property_v1`?Qi(t,v(`propertyTrigger`,n.property.id)):n.type===`get_app_state_v1`?Qi(t,v(`stateTrigger`,n.state.id)):console.assert(!1);return t}function na(e){let t=[];for(let n of e){if(n.type!==`app_bind_entry_v1`)continue;let e=n;e.kind===`property`?Qi(t,v(`propertyTrigger`,e.property.id)):e.kind===`state`&&Qi(t,v(`stateTrigger`,e.state.id))}return t}function ra(e){let t={watchEffect:{ids:[],triggers:{}},bind:{sets:{},triggers:{}}},n=e.getTopBlocks(!0);if(!n)return t;for(let e of n)if(e.type===`watch_effect_v1`){let n=ta(ea(e));for(let r of n)t.watchEffect.triggers[r]||(t.watchEffect.triggers[r]=[]),Qi(t.watchEffect.triggers[r],e.id);t.watchEffect.ids.push(e.id)}else if(e.type===`app_bind_v1`){let n=na(e.getChildren(!0));t.bind.sets[e.id]=n;for(let r of n)t.bind.triggers[r]||(t.bind.triggers[r]=[]),Qi(t.bind.triggers[r],e.id)}return t}const ia=Symbol();function aa(e){We(ia,e)}function oa(){return Ie(ia)}var sa=E({__name:`index`,props:{lock:{type:Boolean,required:!0}},setup(e,{expose:t}){let{t:n}=it(),r=at(),i=oa(),o=x(()=>r.smAndDown.value),s=()=>{if(!i.workspace){console.assert(!1);return}if(e.lock){a(n(`x-block-lib.msg.cannotOperateInLockedState`));return}i.workspace.cleanUp()},c=()=>{s()};return t({cleanWorkspace:s}),(e,t)=>{let r=k(`v-btn`),i=k(`v-tooltip`);return O(),S(i,{disabled:o.value,text:A(n)(`x-block-lib.tip.hotkeyCtrlQ`)},{activator:j(({props:e})=>[T(r,ze(e,{density:`comfortable`,icon:`mdi-broom`,variant:`outlined`,onClick:c}),null,16)]),_:1},8,[`disabled`,`text`])}}});function ca(t,n){let r=n.newBlock(`json_root_v1`);r.initSvg(),r.render();let i=(e,t)=>{if(e===null)return;let r;if(e instanceof Array)r=`json_array_v1`;else{let t=typeof e;if(t===`object`)r=`json_map_v1`;else if(t===`string`)r=`json_string_v1`;else if(t===`number`)r=`json_number_v1`;else if(t===`boolean`)r=`json_boolean_v1`;else return}let a=n.newBlock(r);if(a.initSvg(),a.render(),t.connect(a.outputConnection),r===`json_map_v1`){let t=[];for(let n in e)t.push(n);a.initData(t);for(let n=0;n<t.length;n++){let r=t[n],o=a.getInput(`ENTRY`+n);i(e[r],o.connection)}}else if(r===`json_array_v1`){a.initData(e.length);for(let t=0;t<e.length;t++)i(e[t],a.getInput(`ENTRY`+t).connection)}else r===`json_string_v1`||r===`json_number_v1`?a.setFieldValue(e,`VALUE`):r===`json_boolean_v1`&&a.setFieldValue(e?`true`:`false`,`VALUE`)};i(t,r.getInput(`JSON`).connection),e.Events.fire(new(e.Events.get(e.Events.FINISHED_LOADING))(n))}function la(e){let t=e=>{if(!e)return null;if(e.type===`json_root_v1`)return t(e.getInputTargetBlock(`JSON`));if(e.type===`json_map_v1`){let n={};for(let r=0;r<e.length;r++){let i=e.getFieldValue(`KEY`+r);n[i]=t(e.getInputTargetBlock(`ENTRY`+r))}return n}else if(e.type===`json_array_v1`){let n=[];for(let r=0;r<e.length;r++)n.push(t(e.getInputTargetBlock(`ENTRY`+r)));return n}else if(e.type===`json_string_v1`)return e.getFieldValue(`VALUE`);else if(e.type===`json_number_v1`)return e.getFieldValue(`VALUE`);else if(e.type===`json_boolean_v1`)return e.getFieldValue(`VALUE`)===`true`;else console.assert(!1)},n=e.getTopBlocks();for(let e of n)if(e.type===`json_root_v1`)return t(e)}var ua=E({__name:`index`,props:{modelValue:{type:Boolean,required:!0},modelModifiers:{}},emits:[`update:modelValue`],setup(e){let{t}=it(),n=at(),r=Ze(e,`modelValue`),i=x(()=>n.smAndDown.value);return(e,n)=>{let a=k(`v-btn`),o=k(`v-tooltip`);return O(),S(o,{disabled:i.value,text:A(t)(`x-block-lib.tip.hotkeyCtrlW`)},{activator:j(({props:e})=>[T(a,ze(e,{density:`comfortable`,icon:r.value?`mdi-lock`:`mdi-lock-open`,variant:`outlined`,onClick:n[0]||=e=>r.value=!r.value}),null,16,[`icon`])]),_:1},8,[`disabled`,`text`])}}});const da={class:`d-flex flex-column`},fa={class:`text-body-large ml-6`},pa={key:0,class:`text-body-small text-grey text-truncate ml-6`,style:{maxWidth:`340px`}};var ma=E({__name:`item`,props:{id:{type:String,required:!0},title:{type:String,required:!0},desc:{type:String,required:!0},select:{type:Boolean,required:!0}},emits:[`x-click`],setup(e,{emit:t}){let{primaryColor:n,backgroundColor2:r,highlightColor:i}=c(),a=t,o=Ge(!1),s=x(()=>{let t={position:`relative`,background:o.value?i.value:r.value,boxSizing:`border-box`,width:`100%`,height:`48px`,marginTop:`1px`,userSelect:`none`};return e.select?(t.borderTop=`1px solid `+n.value,t.borderBottom=`1px solid `+n.value):(t.borderTop=void 0,t.borderBottom=void 0),t});return(t,n)=>{let r=k(`v-spacer`),i=k(`v-icon`),c=Je(`ripple`);return et((O(),C(`div`,{class:`d-flex align-center cursor-pointer`,style:D(s.value),onClick:n[1]||=t=>a(`x-click`,e.id),onMouseout:n[2]||=e=>o.value=!1,onMouseover:n[3]||=e=>o.value=!0},[w(`div`,da,[w(`span`,fa,Ye(e.title),1),e.desc?(O(),C(`span`,pa,Ye(e.desc),1)):Fe(`v-if`,!0)]),T(r),T(i,{class:`x-handle cursor-move mr-3`,icon:`mdi-drag-horizontal-variant`,onMousedown:n[0]||=nt(()=>{},[`stop`])})],36)),[[c]])}}});const ha={key:1,class:`text-body-small text-grey`};var ga=((e,t)=>{let n=e.__vccOpts||e;for(let[e,r]of t)n[e]=r;return n})(E({__name:`index`,props:Re({lock:{type:Boolean,required:!0}},{modelValue:{type:Boolean,required:!0},modelModifiers:{}}),emits:[`update:modelValue`],setup(t,{expose:n}){let{t:r}=it(),i=Ze(t,`modelValue`),o=oa(),s=Ge([]);n({update:()=>{if(!o.workspace){console.assert(!1);return}let t=[];o.workspace.getTopBlocks(!0).forEach(n=>{let i=n.id===e.getSelected()?.id,a=``;if(n.type.startsWith(`on_app_event_v`)){let e=n,t=p(e.node.key);t&&(a=r(t.name),e.node.alias&&(a+=` / `+e.node.alias),a+=` - `+pe(e.event.kind,e.event.names))}else if(n.type.startsWith(`watch_effect_v`))a=r(`x-block-lib.watchEffect`);else if(n.type.startsWith(`app_bind_v`))a=r(`x-block-lib.bind`);else if(n.type.startsWith(`implement_app_method_v`)){let e=n;a=r(`x-block-lib.implementMethod`),a+=` - `+me(e.method.kind,e.method.names)}else a=n.type.startsWith(`func_entry_v`)?r(`x-block-lib.funcEntry`):n.type.startsWith(`procedure_def_v`)?r(`x-block-lib.procedure`)+` - `+n.getFieldValue(`NAME`):r(`x-block-lib.temporaryBlock`);let o=n.getCommentText()??``;t.push({id:n.id,name:a,desc:o,select:i})}),s.value=t}});let c=[],l=()=>{if(t.lock){a(r(`x-block-lib.msg.cannotOperateInLockedState`));return}let e=[];s.value.forEach(({id:t})=>{e.push(t)}),c=e},u=()=>!t.lock,d=t=>{if(!o.workspace){console.assert(!1);return}if(t.oldIndex===void 0||t.newIndex===void 0){console.assert(!1);return}if(t.oldIndex===t.newIndex)return;let n=c[t.oldIndex],r=o.workspace.getBlockById(n);if(!r){console.assert(!1);return}let i=``;t.newIndex>t.oldIndex?i=c[t.newIndex]:t.newIndex>0&&(i=c[t.newIndex-1]);let a=-10;i!==``&&(a=o.workspace.getBlockById(i).getRelativeToSurfaceXY().y+10);let s=r.getRelativeToSurfaceXY();r.moveTo(new e.utils.Coordinate(s.x,a)),o.workspace.cleanUp(),Ji()},ee=async t=>{if(!o.workspace){console.assert(!1);return}let n=o.workspace.getBlockById(t);e.common.setSelected(n),qi(t),i.value=!1};return(e,t)=>s.value.length>0?(O(),S(A(ot),{key:0,modelValue:s.value,"onUpdate:modelValue":t[0]||=e=>s.value=e,animation:150,"ghost-class":`ghost`,handle:`.x-handle`,onEnd:d,onMove:u,onStart:l},{default:j(()=>[(O(!0),C(Pe,null,Ke(s.value,e=>(O(),S(ma,{id:e.id,key:e.id,desc:e.desc,select:e.select,title:e.name,onXClick:ee},null,8,[`id`,`desc`,`select`,`title`]))),128))]),_:1},8,[`modelValue`])):(O(),C(`span`,ha,Ye(A(r)(`x-block-lib.noOption`)),1))}}),[[`__scopeId`,`data-v-x-block-lib-ca7316a0`]]),_a=E({__name:`index`,props:{modelValue:{type:Boolean,required:!0},modelModifiers:{}},emits:[`update:modelValue`],setup(t,{expose:n}){let r=Ze(t,`modelValue`),i=oa();n({update:()=>{if(!i.workspace){console.assert(!1);return}}});let a=t=>{let n=e.getMainWorkspace();if(!n){console.assert(!1);return}let i=n.getBlockById(t);e.common.setSelected(i),qi(t),r.value=!1};return(e,t)=>(O(),C(`div`,{onClick:t[0]||=e=>a(``)},`blockTree`))}});const va={class:`text-body-large`};var ya=E({__name:`index`,props:{type:{type:String,required:!0},lock:{type:Boolean,required:!0}},setup(e,{expose:t}){let{t:n}=it(),r=at(),{sysBarAvail:i}=l(),{backgroundColor1:a}=c(),o=x(()=>r.smAndDown.value),s=x(()=>{let e=`100%`;return r.mdAndUp.value&&(e=`400px`),{background:a.value,width:e,height:`100%`}}),d=x(()=>{let e=48;return i.value&&(e+=24),{position:`relative`,height:`calc(100% - ${e}px)`}}),ee=x(()=>({height:`60px`})),{open:f}=u(`blocklyNavigatorDlg${Xe()}`);Ue(()=>{f.value=!1});let p=Qe(`blockList`),te=Qe(`blockTree`);return t({open:f,update:()=>{e.type===`list`?p.value?.update():e.type===`tree`&&te.value?.update()}}),(t,r)=>{let a=k(`v-sheet`),c=k(`v-btn`),l=k(`v-spacer`),u=k(`v-dialog`),ne=k(`v-tooltip`);return O(),C(Pe,null,[T(u,{modelValue:A(f),"onUpdate:modelValue":r[5]||=e=>Le(f)?f.value=e:null,eager:``,fullscreen:``,"no-click-animation":``,persistent:``,transition:`scroll-x-reverse-transition`,onKeydown:r[6]||=tt(nt(e=>f.value=!1,[`stop`,`prevent`]),[`esc`])},{default:j(()=>[w(`div`,{class:`w-100 h-100 d-flex flex-row-reverse`,onClick:r[3]||=nt(e=>f.value=!1,[`self`]),onContextmenu:r[4]||=nt(e=>f.value=!1,[`self`,`prevent`])},[w(`div`,{class:`elevation-2`,style:D(s.value)},[A(i)?(O(),S(a,{key:0,color:`transparent`,height:24})):Fe(`v-if`,!0),T(a,{class:`d-flex align-center px-2`,color:`transparent`,height:48},{default:j(()=>[T(c,{density:`comfortable`,icon:`mdi-close`,variant:`text`,onClick:r[0]||=e=>f.value=!1}),w(`span`,va,Ye(A(n)(`x-block-lib.navigator`)),1),T(l)]),_:1}),w(`div`,{class:`overflow-y-auto`,style:D(d.value)},[e.type===`list`?(O(),S(ga,{key:0,ref_key:`blockList`,ref:p,modelValue:A(f),"onUpdate:modelValue":r[1]||=e=>Le(f)?f.value=e:null,lock:e.lock},null,8,[`modelValue`,`lock`])):e.type===`tree`?(O(),S(_a,{key:1,ref_key:`blockTree`,ref:te,modelValue:A(f),"onUpdate:modelValue":r[2]||=e=>Le(f)?f.value=e:null},null,8,[`modelValue`])):Fe(`v-if`,!0),w(`div`,{style:D(ee.value)},null,4)],4)],4)],32)]),_:1},8,[`modelValue`]),T(ne,{disabled:o.value,text:A(n)(`x-block-lib.tip.hotkeyCtrlE`)},{activator:j(({props:e})=>[T(c,ze(e,{density:`comfortable`,icon:`mdi-navigation-variant`,variant:`outlined`,onClick:r[7]||=e=>f.value=!0}),null,16)]),_:1},8,[`disabled`,`text`])],64)}}});const Z=e.utils.xml;function Q(e){let t=Z.createElement(`label`);return t.setAttribute(`text`,e),t}function $(e,t){let n=Z.createElement(`block`);if(n.setAttribute(`type`,e),t)for(let e of t)n.appendChild(e);return n}function ba(e){let t=Z.createElement(`mutation`);for(let{key:n,value:r}of e)t.setAttribute(n,r);return t}function xa(e,t){t===void 0&&(t=``);let n=Z.createElement(`value`);n.setAttribute(`name`,e);let r=Z.createElement(`shadow`);r.setAttribute(`type`,`text_v1`);let i=Z.createElement(`field`);i.setAttribute(`name`,`TEXT`);let a=Z.createTextNode(t);return i.appendChild(a),r.appendChild(i),n.appendChild(r),n}function Sa(e,t){t===void 0&&(t=0);let n=Z.createElement(`value`);n.setAttribute(`name`,e);let r=Z.createElement(`shadow`);r.setAttribute(`type`,`math_number_v1`);let i=Z.createElement(`field`);i.setAttribute(`name`,`NUM`);let a=Z.createTextNode(String(t));return i.appendChild(a),r.appendChild(i),n.appendChild(r),n}function Ca(e,t){t===void 0&&(t=!1);let n=Z.createElement(`value`);n.setAttribute(`name`,e);let r=Z.createElement(`shadow`);r.setAttribute(`type`,`logic_boolean_v1`);let i=Z.createElement(`field`);i.setAttribute(`name`,`BOOL`);let a=Z.createTextNode(t?`TRUE`:`FALSE`);return i.appendChild(a),r.appendChild(i),n.appendChild(r),n}function wa(){let{activeObject:e,activeComp:t}=d.app;return!(e.type!==`comp`||!t.meta.states||t.meta.states.length<=0)}function Ta(){let e=[];return e.push(Q(M(`LABEL_EVENT`))),H(`onEvent`)&&e.push($(`on_app_event_v1`)),H(`triggerEvent`)&&e.push($(`trigger_app_event_v1`)),e.push($(`app_bind_v1`,[ba([{key:`items`,value:`2`}])])),e.push($(`watch_effect_v1`)),(H(`getProperty`)||H(`setProperty`))&&e.push(Q(M(`LABEL_PROPERTY`))),H(`getProperty`)&&e.push($(`get_app_property_v1`)),H(`setProperty`)&&e.push($(`set_app_property_v1`)),wa()&&(e.push(Q(M(`LABEL_STATE`))),e.push($(`get_app_state_v1`)),e.push($(`set_app_state_v1`))),(H(`callMethod`)||H(`implementMethod`))&&e.push(Q(M(`LABEL_METHOD`))),H(`callMethod`)&&e.push($(`call_app_method_v1`)),H(`implementMethod`)&&(e.push($(`implement_app_method_v1`)),H(`implementMethodOutput`)&&e.push($(`set_app_method_output_v1`)),e.push($(`procedure_return_v1`))),e}const Ea={name:`APP_COMP_CATEGORY`,callback:Ta};function Da(){let e=[];return e.push(Q(M(`LABEL_FUNC`))),e.push(Q(M(`LABEL_FLOW`))),e}const Oa={name:`APP_COMPUTE_CATEGORY`,callback:Da};function ka(){let e=[];return e.push($(`app_debug_trace_v1`,[xa(`OBJECT`)])),e.push($(`popup_message_v1`,[xa(`TEXT`)])),e.push($(`open_confirm_dlg_v1`)),e.push($(`open_prompt_dlg_v1`)),e}const Aa={name:`APP_MESSAGE_CATEGORY`,callback:ka};function ja(){for(let e of d.app.appList)if(e.pages.length>0)return!0;return!1}function Ma(){let e=[];return e.push($(`app_env_is_v1`)),ja()&&e.push($(`navigate_to_v1`)),e}const Na={name:`APP_MISC_CATEGORY`,callback:Ma};function Pa(){let{activeObject:e,activePage:t}=d.app;return!(e.type!==`page`||!t.meta.states||t.meta.states.length<=0)}function Fa(){let{activeObject:e,activePage:t}=d.app;return!(e.type!==`page`||!t.meta.arguments||t.meta.arguments.length<=0)}function Ia(){let e=[];return e.push(Q(M(`LABEL_EVENT`))),H(`onEvent`)&&e.push($(`on_app_event_v1`)),e.push($(`app_bind_v1`,[ba([{key:`items`,value:`2`}])])),e.push($(`watch_effect_v1`)),(H(`getProperty`)||H(`setProperty`))&&e.push(Q(M(`LABEL_PROPERTY`))),H(`getProperty`)&&e.push($(`get_app_property_v1`)),H(`setProperty`)&&e.push($(`set_app_property_v1`)),Pa()&&(e.push(Q(M(`LABEL_STATE`))),e.push($(`get_app_state_v1`)),e.push($(`set_app_state_v1`))),H(`callMethod`)&&(e.push(Q(M(`LABEL_METHOD`))),e.push($(`call_app_method_v1`))),Fa()&&(e.push(Q(M(`LABEL_ARGUMENT`))),e.push($(`get_page_argument_v1`))),e}const La={name:`APP_PAGE_CATEGORY`,callback:Ia};function Ra(){let e=[];return e.push(Q(M(`LABEL_RESOURCE`))),e.push($(`upload_resource_v1`)),e}const za={name:`APP_RESOURCE_CATEGORY`,callback:Ra},Ba=e.utils.xml;function Va(){let e=[];{let t=Ba.createElement(`label`);t.setAttribute(`text`,`%{BKY_LABEL_PROCEDURE}`),e.push(t)}{let t=Ba.createElement(`block`);t.setAttribute(`type`,`procedure_def_v1`);{let e=Ba.createElement(`field`);e.setAttribute(`name`,`NAME`);let n=Ba.createTextNode(M(`PROCEDURE_DEFAULT_NAME`));e.appendChild(n),t.appendChild(e)}e.push(t)}{let t=Ba.createElement(`block`);t.setAttribute(`type`,`procedure_return_v1`),e.push(t)}return e}const Ha={name:`PROCEDURE_CATEGORY`,callback:Va},Ua=e.utils.xml;function Wa(){let t=e.getMainWorkspace(),n=[];{let e=Ua.createElement(`label`);e.setAttribute(`text`,`%{BKY_LABEL_VARIABLE}`),n.push(e)}{let r=document.createElement(`button`);r.setAttribute(`text`,`%{BKY_NEW_VARIABLE}`),r.setAttribute(`callbackKey`,`CREATE_VARIABLE`),t.registerButtonCallback(`CREATE_VARIABLE`,function(t){e.Variables.createVariableButtonHandler(t.getTargetWorkspace())}),n.push(r)}let r=t.getVariablesOfType(``);if(r.length<=0)return n;r.sort(e.Variables.compareByName);{let e=Ua.createElement(`label`);e.setAttribute(`text`,M(`LABEL_CREATED`)),n.push(e)}return r.forEach(t=>{{let r=Ua.createElement(`block`);r.setAttribute(`type`,`variable_get_v1`),r.appendChild(e.Variables.generateVariableFieldDom(t)),n.push(r)}{let r=Ua.createElement(`block`);r.setAttribute(`type`,`variable_set_v1`),r.appendChild(e.Variables.generateVariableFieldDom(t)),n.push(r)}}),n}const Ga={name:`VARIABLE_CATEGORY`,callback:Wa};function Ka(){let e=[];if(Y().length>0)e.push(Q(M(`LABEL_OPERATION`))),e.push($(`add_data_v1`)),e.push($(`delete_data_v1`)),e.push($(`update_data_v1`)),e.push($(`query_data_v1`)),e.push($(`transaction_v1`)),e.push($(`interrupt_transaction_v1`,[xa(`VALUE`)])),e.push(Q(M(`LABEL_CONDITION`))),e.push($(`cond_logic_v1`)),e.push($(`cond_atomic_v1`,[xa(`VALUE`)])),e.push(Q(M(`LABEL_QUERY_EXTRA`))),e.push($(`query_extra_limit_v1`,[Sa(`OFFSET`,0),Sa(`LIMIT`,1)])),e.push($(`query_extra_sortby_v1`,[xa(`COLUMN`),Ca(`DESC`)]));else{let t=document.createElement(`button`);t.setAttribute(`text`,M(`BUTTON_NO_TABLE`)),t.setAttribute(`callbackKey`,`NO_TABLE`),e.push(t)}return e}const qa={name:`COMPUTE_DATA_CATEGORY`,callback:Ka};function Ja(){return pr(`flow`).length>0}function Ya(){let e=[];return d.compute.activeObject.type===`flow`&&e.push($(`on_flow_state_event_v1`)),Ja()&&console.assert(!0),e}const Xa={name:`COMPUTE_FLOW_CATEGORY`,callback:Ya};function Za(){return pr(`func`).length>0}function Qa(){let{activeObject:e,activeFunc:t}=d.compute,n=[];return e.type===`func`&&(n.push($(`func_entry_v1`)),t.outputs&&t.outputs.length>0&&n.push($(`set_func_output_v1`)),n.push($(`procedure_return_v1`))),Za()&&n.push($(`call_func_internal_v1`)),n}const $a={name:`COMPUTE_FUNC_CATEGORY`,callback:Qa};function eo(){let e=[];return e.push($(`compute_debug_trace_v1`,[xa(`OBJECT`)])),e}const to={name:`COMPUTE_MISC_CATEGORY`,callback:eo},no={kind:`category`,name:`%{BKY_CATEGORY_COLOR}`,categorystyle:`color_category`,contents:[{kind:`block`,type:`color_picker_v1`},{kind:`block`,type:`color_random_v1`},{kind:`block`,type:`color_rgb_v1`,inputs:{RED:{shadow:{type:`math_number_v1`,fields:{NUM:0}}},GREEN:{shadow:{type:`math_number_v1`,fields:{NUM:0}}},BLUE:{shadow:{type:`math_number_v1`,fields:{NUM:0}}}}},{kind:`block`,type:`color_blend_v1`,inputs:{COLOR1:{shadow:{type:`color_picker_v1`,fields:{COLOR:`#ff0000`}}},COLOR2:{shadow:{type:`color_picker_v1`,fields:{COLOR:`#00ff00`}}},RATIO:{shadow:{type:`math_number_v1`,fields:{NUM:.5}}}}}]},ro={kind:`category`,name:`%{BKY_CATEGORY_LIST}`,categorystyle:`list_category`,contents:[{kind:`label`,text:`%{BKY_LABEL_LIST}`},{kind:`block`,type:`list_create_v1`,extraState:{itemCount:0}},{kind:`label`,text:`%{BKY_LABEL_GET}`},{kind:`block`,type:`list_is_empty_v1`},{kind:`block`,type:`list_length_v1`},{kind:`block`,type:`list_get_v1`,inputs:{AT:{shadow:{type:`math_number_v1`,fields:{NUM:1}}}}},{kind:`block`,type:`list_get_sublist_v1`,inputs:{START:{shadow:{type:`math_number_v1`,fields:{NUM:1}}},END:{shadow:{type:`math_number_v1`,fields:{NUM:1}}}}},{kind:`label`,text:`%{BKY_LABEL_SET}`},{kind:`block`,type:`list_set_v1`,inputs:{AT:{shadow:{type:`math_number_v1`,fields:{NUM:1}}}}},{kind:`block`,type:`list_delete_v1`,inputs:{AT:{shadow:{type:`math_number_v1`,fields:{NUM:1}}}}},{kind:`block`,type:`list_join_v1`,inputs:{DELIM:{shadow:{type:`text_v1`,fields:{TEXT:``}}}}},{kind:`block`,type:`list_reverse_v1`}]},io={kind:`category`,name:`%{BKY_CATEGORY_LOGIC}`,categorystyle:`logic_category`,contents:[{kind:`label`,text:`%{BKY_LABEL_BOOLEAN}`},{kind:`block`,type:`logic_boolean_v1`},{kind:`label`,text:`%{BKY_LABEL_BRANCH}`},{kind:`block`,type:`logic_if_v1`},{kind:`label`,text:`%{BKY_LABEL_LOGIC_OPERATION}`},{kind:`block`,type:`logic_compare_v1`},{kind:`block`,type:`logic_operation_v1`},{kind:`block`,type:`logic_negate_v1`},{kind:`block`,type:`logic_ternary_v1`}]},ao={kind:`category`,name:`%{BKY_CATEGORY_LOOP}`,categorystyle:`loop_category`,contents:[{kind:`block`,type:`repeat_v1`,inputs:{TIMES:{shadow:{type:`math_number_v1`,fields:{NUM:10}}}}},{kind:`block`,type:`while_until_v1`},{kind:`block`,type:`for_v1`,inputs:{FROM:{shadow:{type:`math_number_v1`,fields:{NUM:1}}},TO:{shadow:{type:`math_number_v1`,fields:{NUM:10}}},BY:{shadow:{type:`math_number_v1`,fields:{NUM:1}}}}},{kind:`block`,type:`for_each_v1`},{kind:`block`,type:`flow_control_v1`}]},oo={kind:`category`,name:`%{BKY_CATEGORY_MATH}`,categorystyle:`math_category`,contents:[{kind:`label`,text:`%{BKY_LABEL_VALUE}`},{kind:`block`,type:`math_number_v1`,fields:{NUM:0}},{kind:`block`,type:`math_constant_v1`},{kind:`block`,type:`math_random_float_v1`},{kind:`block`,type:`math_random_int_v1`,inputs:{FROM:{shadow:{type:`math_number_v1`,fields:{NUM:1}}},TO:{shadow:{type:`math_number_v1`,fields:{NUM:100}}}}},{kind:`label`,text:`%{BKY_LABEL_MATH_OPERATION}`},{kind:`block`,type:`math_arithmetic_v1`,inputs:{A:{shadow:{type:`math_number_v1`,fields:{NUM:1}}},B:{shadow:{type:`math_number_v1`,fields:{NUM:1}}}}},{kind:`block`,type:`math_round_v1`,inputs:{NUM:{shadow:{type:`math_number_v1`,fields:{NUM:3.1}}}}},{kind:`block`,type:`math_single_v1`,inputs:{NUM:{shadow:{type:`math_number_v1`,fields:{NUM:9}}}}},{kind:`block`,type:`math_trig_v1`,inputs:{NUM:{shadow:{type:`math_number_v1`,fields:{NUM:45}}}}},{kind:`block`,type:`math_modulo_v1`,inputs:{DIVIDEND:{shadow:{type:`math_number_v1`,fields:{NUM:64}}},DIVISOR:{shadow:{type:`math_number_v1`,fields:{NUM:10}}}}},{kind:`block`,type:`math_number_property_v1`,inputs:{NUM:{shadow:{type:`math_number_v1`,fields:{NUM:2}}}}},{kind:`block`,type:`math_on_list_v1`}]},so={kind:`category`,name:`%{BKY_CATEGORY_OBJECT}`,categorystyle:`object_category`,contents:[{kind:`label`,text:`%{BKY_LABEL_OBJECT}`},{kind:`block`,type:`object_create_v1`},{kind:`block`,type:`object_from_json_v1`},{kind:`block`,type:`object_to_json_v1`},{kind:`label`,text:`%{BKY_LABEL_PROPERTY}`},{kind:`block`,type:`object_get_v1`,inputs:{KEY:{shadow:{type:`text_v1`,fields:{TEXT:``}}}}},{kind:`block`,type:`object_set_v1`,inputs:{KEY:{shadow:{type:`text_v1`,fields:{TEXT:``}}}}},{kind:`block`,type:`object_delete_v1`,inputs:{KEY:{shadow:{type:`text_v1`,fields:{TEXT:``}}}}}]},co={kind:`category`,name:`%{BKY_CATEGORY_TEXT}`,categorystyle:`text_category`,contents:[{kind:`label`,text:`%{BKY_LABEL_TEXT}`},{kind:`block`,type:`text_v1`},{kind:`block`,type:`text_join_v1`,extraState:{itemCount:2}},{kind:`label`,text:`%{BKY_LABEL_GET}`},{kind:`block`,type:`text_is_empty_v1`},{kind:`block`,type:`text_length_v1`},{kind:`block`,type:`text_char_at_v1`,inputs:{AT:{shadow:{type:`math_number_v1`,fields:{NUM:1}}}}},{kind:`block`,type:`text_substring_v1`,inputs:{START:{shadow:{type:`math_number_v1`,fields:{NUM:1}}},END:{shadow:{type:`math_number_v1`,fields:{NUM:1}}}}},{kind:`block`,type:`text_index_of_v1`,inputs:{SUBSTR:{shadow:{type:`text_v1`,fields:{TEXT:``}}}}},{kind:`block`,type:`text_count_v1`,inputs:{SUBSTR:{shadow:{type:`text_v1`,fields:{TEXT:``}}}}},{kind:`label`,text:`%{BKY_LABEL_SET}`},{kind:`block`,type:`text_append_v1`,inputs:{TEXT:{shadow:{type:`text_v1`,fields:{TEXT:``}}}}},{kind:`block`,type:`text_replace_v1`,inputs:{FROM:{shadow:{type:`text_v1`,fields:{TEXT:``}}},TO:{shadow:{type:`text_v1`,fields:{TEXT:``}}}}},{kind:`block`,type:`text_split_v1`,inputs:{DELIM:{shadow:{type:`text_v1`,fields:{TEXT:``}}}}},{kind:`block`,type:`text_change_case_v1`},{kind:`block`,type:`text_trim_v1`},{kind:`block`,type:`text_reverse_v1`}]},lo={kind:`category`,name:`%{BKY_CATEGORY_TIME}`,categorystyle:`time_category`,contents:[{kind:`block`,type:`create_timer_v1`},{kind:`block`,type:`delay_v1`,inputs:{DURATION:{shadow:{type:`math_number_v1`,fields:{NUM:1e3}}}}}]},uo={kind:`categoryToolbox`,contents:[{kind:`category`,name:`%{BKY_CATEGORY_COMP}`,categorystyle:`misc_category`,custom:Ea.name},{kind:`category`,name:`%{BKY_CATEGORY_MESSAGE}`,categorystyle:`misc_category`,custom:Aa.name},{kind:`category`,name:`%{BKY_CATEGORY_MISC}`,categorystyle:`misc_category`,custom:Na.name},ao,io,oo,co,ro,so,no,lo,{kind:`category`,name:`%{BKY_CATEGORY_VARIABLE}`,categorystyle:`variable_category`,custom:Ga.name},{kind:`category`,name:`%{BKY_CATEGORY_PROCEDURE}`,categorystyle:`procedure_category`,custom:Ha.name},{kind:`category`,name:`%{BKY_CATEGORY_RESOURCE}`,categorystyle:`resource_category`,custom:za.name},{kind:`category`,name:`%{BKY_CATEGORY_COMPUTE}`,categorystyle:`compute_category`,custom:Oa.name}]},fo={kind:`categoryToolbox`,contents:[{kind:`category`,name:`%{BKY_CATEGORY_FUNC}`,categorystyle:`func_category`,custom:$a.name},{kind:`category`,name:`%{BKY_CATEGORY_FLOW}`,categorystyle:`flow_category`,custom:Xa.name},{kind:`category`,name:`%{BKY_CATEGORY_DATA}`,categorystyle:`data_category`,custom:qa.name},{kind:`category`,name:`%{BKY_CATEGORY_MISC}`,categorystyle:`misc_category`,custom:to.name},ao,io,oo,co,ro,so,no,{kind:`category`,name:`%{BKY_CATEGORY_VARIABLE}`,categorystyle:`variable_category`,custom:Ga.name},{kind:`category`,name:`%{BKY_CATEGORY_PROCEDURE}`,categorystyle:`procedure_category`,custom:Ha.name}]},po={kind:`categoryToolbox`,contents:[{kind:`category`,name:`%{BKY_CATEGORY_FUNC}`,categorystyle:`func_category`,custom:$a.name},{kind:`category`,name:`%{BKY_CATEGORY_FLOW}`,categorystyle:`flow_category`,custom:Xa.name},{kind:`category`,name:`%{BKY_CATEGORY_DATA}`,categorystyle:`data_category`,custom:qa.name},{kind:`category`,name:`%{BKY_CATEGORY_MISC}`,categorystyle:`misc_category`,custom:to.name},ao,io,oo,co,ro,so,no,{kind:`category`,name:`%{BKY_CATEGORY_VARIABLE}`,categorystyle:`variable_category`,custom:Ga.name},{kind:`category`,name:`%{BKY_CATEGORY_PROCEDURE}`,categorystyle:`procedure_category`,custom:Ha.name}]},mo={kind:`categoryToolbox`,contents:[{kind:`category`,name:`%{BKY_CATEGORY_JSON}`,colour:`330`,contents:[{kind:`block`,type:`json_map_v1`},{kind:`block`,type:`json_array_v1`},{kind:`block`,type:`json_string_v1`},{kind:`block`,type:`json_number_v1`},{kind:`block`,type:`json_boolean_v1`}]}]},ho={kind:`categoryToolbox`,contents:[{kind:`category`,name:`%{BKY_CATEGORY_PAGE}`,categorystyle:`misc_category`,custom:La.name},{kind:`category`,name:`%{BKY_CATEGORY_MESSAGE}`,categorystyle:`misc_category`,custom:Aa.name},{kind:`category`,name:`%{BKY_CATEGORY_MISC}`,categorystyle:`misc_category`,custom:Na.name},ao,io,oo,co,ro,so,no,lo,{kind:`category`,name:`%{BKY_CATEGORY_VARIABLE}`,categorystyle:`variable_category`,custom:Ga.name},{kind:`category`,name:`%{BKY_CATEGORY_PROCEDURE}`,categorystyle:`procedure_category`,custom:Ha.name},{kind:`category`,name:`%{BKY_CATEGORY_RESOURCE}`,categorystyle:`resource_category`,custom:za.name},{kind:`category`,name:`%{BKY_CATEGORY_COMPUTE}`,categorystyle:`compute_category`,custom:Oa.name}]},go={grid:{length:2,snap:!0,spacing:20},maxInstances:{func_entry_v1:1},media:`/media/`,move:{drag:!0,scrollbars:!0,wheel:!0},readOnly:!1,theme:`light`,trashcan:!1,zoom:{maxScale:1,minScale:.1,scaleSpeed:1.25,startScale:1,wheel:!0}};function _o(t,n,r,i){go.theme=i?`dark`:`light`,go.toolbox=vo(n,r);let a=e.inject(t,go);return a.addChangeListener(e=>{if(e.type===`state_change`){let e=a.getAllBlocks();for(let t of e){let e=t;e.checkWarning_&&e.checkWarning_()}}setTimeout(()=>{st(e)},0)}),yo(a,n,r),bo(a),a}function vo(e,t){let n;return e===`page`?t===`v1`&&(n=ho):e===`comp`?t===`v1`&&(n=uo):e===`func`?t===`v1`&&(n=po):e===`flow`?t===`v1`&&(n=fo):e===`json`&&t===`v1`&&(n=mo),console.assert(!!n,`invalid toolbox type=${e} version=${t}`),n}function yo(e,t,n){function r({name:n,callback:r}){e.registerToolboxCategoryCallback(n,()=>r(t))}t===`page`?n===`v1`&&(r(La),r(Aa),r(Na),r(Ga),r(Ha),r(za),r(Oa)):t===`comp`?n===`v1`&&(r(Ea),r(Aa),r(Na),r(Ga),r(Ha),r(za),r(Oa)):t===`func`?n===`v1`&&(r($a),r(Xa),r(qa),r(to),r(Ga),r(Ha)):t===`flow`&&n===`v1`&&(r($a),r(Xa),r(qa),r(to),r(Ga),r(Ha))}function bo(e){let{router:t}=i;e.registerButtonCallback(`NO_COMPUTE`,()=>{let e=t.resolve({path:`/compute/`+Date.now()});setTimeout(()=>{window.open(e.href,`_blank`)},100)}),e.registerButtonCallback(`NO_TABLE`,()=>{let e=t.resolve({path:`/data/`+Date.now()});setTimeout(()=>{window.open(e.href,`_blank`)},100)})}const xo={class:`position-relative w-100 h-100`};var So=E({__name:`index`,props:Re({type:{type:String,required:!0},version:{type:String,required:!0},locale:{type:String,required:!0},dark:{type:Boolean,required:!0}},{lock:{type:Boolean,required:!0},lockModifiers:{},scale:{type:Number,required:!0},scaleModifiers:{}}),emits:Re([`ready`],[`update:lock`,`update:scale`]),setup(t,{expose:i,emit:a}){let{backgroundColor2:o}=c(),s=Ze(t,`lock`),l=Ze(t,`scale`),d=a,ee=`blocklyEditor${Xe()}`,f=Ge(),p=Qe(`parentContainer`),te=Qe(`clean`),ne=Qe(`navigator`),m={};aa(m);let re=Ge(!0),h=Ge(!1),ie=x(()=>t.type===`json`?`tree`:`list`),ae=x(()=>({width:`100%`,height:`calc(100% - 48px)`})),g=x(()=>({position:`absolute`,background:o.value,bottom:`0px`,width:`100%`,height:`48px`})),oe=x(()=>({position:`absolute`,background:t.dark?`#0000007f`:`#ffffff7f`,top:`1px`,left:`0px`,width:`56px`,height:`calc(100% - 49px)`,zIndex:999})),se=x(()=>({position:`absolute`,top:`0px`,right:`0px`,zIndex:20})),_=x(()=>({position:`absolute`,background:t.dark?`#0000007f`:`#ffffff7f`,top:`0px`,left:`0px`,width:`100%`,height:`calc(100% - 48px)`,pointerEvents:`none`})),ce=x(()=>({position:`absolute`,background:t.dark?`#0000007f`:`#ffffff7f`,top:`1px`,left:`0px`,width:`56px`,height:`calc(100% - 49px)`,zIndex:999})),le=x(()=>({position:`fixed`,top:0,left:0,zIndex:3e3})),{open:v}=u(`blocklyEditorFlyout${Xe()}`);He(async()=>{if(!f.value||!p.value){console.assert(!1);return}e.setParentContainer(p.value),await dt(t.locale),m.workspace=_o(f.value,t.type,t.version,t.dark),m.workspace.addChangeListener(e.Events.disableOrphans),m.workspace.addChangeListener(ue);let n=document.querySelector(`#${ee} .blocklyFlyout`);new MutationObserver(e=>{e.forEach(e=>{e.type===`attributes`&&e.attributeName===`style`&&(v.value=m.workspace.getFlyout().isVisible())})}).observe(n,{attributes:!0}),v.value=m.workspace.getFlyout().isVisible(),ge(),y(),await Be(),d(`ready`)}),Ve(()=>{v.value=!1}),rt(f,()=>{m.workspace&&e.svgResize(m.workspace)});async function ue(t){if(t.type===e.Events.FINISHED_LOADING){Ji(),setTimeout(()=>{ne.value?.update()},0),re.value=!1;return}if(!re.value){if(t.type===e.Events.VIEWPORT_CHANGE){l.value=m.workspace.getScale();return}t.type===e.Events.BLOCK_DRAG&&(t.isStart?h.value=!0:h.value=!1),setTimeout(()=>{ne.value?.update()},0)}}let de=n=>{re.value=!0,t.type===`json`?ca(n,m.workspace):e.serialization.workspaces.load(n,m.workspace)},fe=()=>t.type===`json`?la(m.workspace):e.serialization.workspaces.save(m.workspace),pe=t=>{e.serialization.blocks.append(t,m.workspace)},me=()=>{if(t.type===`json`)console.assert(!1);else return n.workspaceToCode(m.workspace)},he=()=>ra(m.workspace),ge=()=>{m.workspace.setIsReadOnly(s.value),m.workspace.isReadOnly()&&(v.value=!1)},y=()=>{m.workspace.setScale(l.value)},_e=()=>{e.Events.fire(new(e.Events.get(`state_change`))(m.workspace))},ve=()=>{te.value?.cleanWorkspace()},ye=()=>{s.value=!s.value},be=()=>{ne.value&&(ne.value.open=!0)};return He(()=>{r.on(`cleanWorkspace`,ve),r.on(`toggleBlocklyLock`,ye),r.on(`openBlocklyNavigator`,be)}),Ve(()=>{r.off(`cleanWorkspace`,ve),r.off(`toggleBlocklyLock`,ye),r.off(`openBlocklyNavigator`,be)}),$e(()=>t.locale,e=>{dt(e)}),$e(()=>t.dark,e=>{Zi(e?`dark`:`light`)}),$e(v,e=>{e||m.workspace?.hideChaff()}),$e(s,()=>{ge()}),$e(l,()=>{y()}),i({loading:re,load:de,save:fe,appendBlock:pe,generateCode:me,generateReactivity:he,fireStateChange:_e}),(e,t)=>{let n=k(`v-icon`),r=k(`x-loading`);return O(),C(`div`,xo,[w(`div`,{id:ee,ref_key:`blocklyDiv`,ref:f,style:D(ae.value)},null,4),w(`div`,{style:D(g.value)},[qe(e.$slots,`bottom`)],4),h.value?(O(),C(`div`,{key:0,class:`d-flex flex-column justify-center align-center`,style:D(oe.value)},[T(n,{icon:`mdi-delete`,size:`x-large`})],4)):Fe(`v-if`,!0),re.value?Fe(`v-if`,!0):(O(),C(`div`,{key:1,class:`d-flex align-end ga-3 pt-3 pr-3`,style:D(se.value)},[T(sa,{ref_key:`clean`,ref:te,lock:s.value},null,8,[`lock`]),T(ua,{modelValue:s.value,"onUpdate:modelValue":t[0]||=e=>s.value=e},null,8,[`modelValue`]),T(ya,{ref_key:`navigator`,ref:ne,lock:s.value,type:ie.value},null,8,[`lock`,`type`])],4)),s.value?(O(),C(`div`,{key:2,style:D(ce.value)},null,4)):Fe(`v-if`,!0),s.value?(O(),C(`div`,{key:3,style:D(_.value)},null,4)):Fe(`v-if`,!0),w(`div`,{ref_key:`parentContainer`,ref:p,style:D(le.value)},null,4),T(r,{open:re.value,"z-index":99},null,8,[`open`])])}}}),Co=E({__name:`index`,props:{code:{type:String,required:!0}},setup(e){lt.registerLanguage(`javascript`,ut);let t=ct.component,{backgroundColor2:n}=c();return(r,i)=>{let a=k(`v-sheet`);return O(),S(a,{color:A(n),height:`100%`,width:`100%`},{default:j(()=>[T(A(t),{code:e.code,language:`js`},null,8,[`code`])]),_:1},8,[`color`])}}});const wo={class:`text-body-large`},To={class:`w-100 h-100 overflow-auto`};var Eo=E({__name:`index`,setup(e){let{t}=it(),{sysBarAvail:n}=l(),{backgroundColor0:r,backgroundColor2:i}=c(),a=Ge(``),o=x(()=>{let e=48;return n.value&&(e+=24),{position:`relative`,height:`calc(100% - ${e}px)`}}),{open:s}=u(`sourceDlg`,e=>{a.value=e.code});return(e,c)=>{let l=k(`v-sheet`),u=k(`v-btn`),d=k(`v-spacer`),ee=k(`v-dialog`);return O(),S(ee,{modelValue:A(s),"onUpdate:modelValue":c[1]||=e=>Le(s)?s.value=e:null,fullscreen:``,"no-click-animation":``,persistent:``,transition:`dialog-bottom-transition`,onKeydown:c[2]||=tt(nt(e=>s.value=!1,[`stop`,`prevent`]),[`esc`])},{default:j(()=>[T(l,{color:A(r),height:`100%`,width:`100%`},{default:j(()=>[A(n)?(O(),S(l,{key:0,color:A(i),height:24},null,8,[`color`])):Fe(`v-if`,!0),T(l,{class:`d-flex align-center px-2`,color:A(i),height:48},{default:j(()=>[T(u,{density:`comfortable`,icon:`mdi-close`,variant:`text`,onClick:c[0]||=e=>s.value=!1}),w(`span`,wo,Ye(A(t)(`x-block-lib.dlg.source.title`)),1),T(d)]),_:1},8,[`color`]),w(`div`,{style:D(o.value)},[w(`div`,To,[T(Co,{code:a.value},null,8,[`code`])])],4)]),_:1},8,[`color`])]),_:1},8,[`modelValue`])}}});const Do=e=>{e.component(`XBlockly`,So),e.component(`XSourceDlg`,Eo)};async function Oo(e){if(e===`en`)return(await import(`./i18n-en.g7xrumzj.js`).then(e=>e.t)).default;if(e===`zhHans`)return(await import(`./i18n-zhHans.hwzyg72e.js`).then(e=>e.t)).default;throw Error(`invalid locale=${e}`)}var ko={install:Do};export{So as XBlockly,ko as default,Cn as getCallMethodInfo,Dn as getImplementMethodInfo,W as getNodeInfo,gn as getOnEventInfo,In as getPropertyInfo,yn as getTriggerEventInfo,Do as install,Oo as loadLocaleMessageBlock};
|
|
377
|
+
`)}(${t}, ${n}, ${r})`,v.FUNCTION_CALL]},a([{type:`text_reverse_v1`,message0:`%{BKY_TEXT_V1_REVERSE_TITLE}`,args0:[{type:`input_value`,name:`TEXT`,check:`String`}],inputsInline:!0,output:`String`,style:`text_blocks`,tooltip:`%{BKY_TEXT_V1_REVERSE_TOOLTIP}`,helpUrl:`%{BKY_TEXT_V1_REVERSE_HELPURL}`}]),y.forBlock.text_reverse_v1=function(e){return[(y.valueToCode(e,`TEXT`,v.MEMBER)||`''`)+`.split('').reverse().join('')`,v.FUNCTION_CALL]},a([{type:`text_split_v1`,message0:`%{BKY_TEXT_V1_SPLIT_TITLE}`,args0:[{type:`input_value`,name:`TEXT`,check:`String`},{type:`input_value`,name:`DELIM`,check:`String`}],inputsInline:!0,output:`Array`,style:`text_blocks`,tooltip:`%{BKY_TEXT_V1_SPLIT_TOOLTIP}`,helpUrl:`%{BKY_TEXT_V1_SPLIT_HELPURL}`}]),y.forBlock.text_split_v1=function(e){return[`${y.valueToCode(e,`TEXT`,v.MEMBER)||`''`}.split(${y.valueToCode(e,`DELIM`,v.NONE)||`''`})`,v.FUNCTION_CALL]},a([{type:`text_substring_v1`,message0:`%{BKY_TEXT_V1_SUBSTRING_TITLE}`,args0:[{type:`input_value`,name:`TEXT`,check:`String`},{type:`input_value`,name:`START`,check:`Number`},{type:`input_value`,name:`END`,check:`Number`}],inputsInline:!0,output:`String`,style:`text_blocks`,tooltip:`%{BKY_TEXT_V1_SUBSTRING_TOOLTIP}`,helpUrl:`%{BKY_TEXT_V1_SUBSTRING_HELPURL}`}]),y.forBlock.text_substring_v1=function(e){return[`${y.valueToCode(e,`TEXT`,v.MEMBER)||`''`}.slice(${y.getAdjusted(e,`START`)}, ${y.getAdjusted(e,`END`,1)})`,v.FUNCTION_CALL]},a([{type:`text_trim_v1`,message0:`%{BKY_TEXT_V1_TRIM_TITLE}`,args0:[{type:`field_dropdown`,name:`MODE`,options:[[`%{BKY_TEXT_TRIM_OPERATOR_BOTH}`,`BOTH`],[`%{BKY_TEXT_TRIM_OPERATOR_LEFT}`,`LEFT`],[`%{BKY_TEXT_TRIM_OPERATOR_RIGHT}`,`RIGHT`]]},{type:`input_value`,name:`TEXT`,check:`String`}],output:`String`,style:`text_blocks`,tooltip:`%{BKY_TEXT_V1_TRIM_TOOLTIP}`,helpUrl:`%{BKY_TEXT_V1_TRIM_HELPURL}`}]),y.forBlock.text_trim_v1=function(e){return[`__trimV1__(${y.valueToCode(e,`TEXT`,v.NONE)||`''`}, ${{BOTH:0,LEFT:1,RIGHT:2}[e.getFieldValue(`MODE`)]})`,v.ATOMIC]},x.create_timer_v1={init:function(){this.appendDummyInput().appendField(`%{BKY_TIME_V1_CREATE_TIMER_TITLE}`),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null),this.setStyle(`time_blocks`),this.setTooltip(`%{BKY_TIME_V1_CREATE_TIMER_TOOLTIP}`),this.setHelpUrl(`%{BKY_TIME_V1_CREATE_TIMER_HELPURL}`)},saveExtraState:function(){return{}},loadExtraState:function(){this.updateShape_(),this.updateShadow_()},updateShape_:function(){this.getInput(`CALLBACK`)||this.appendStatementInput(`CALLBACK`).appendField(`%{BKY_TIME_DO}`),this.getInput(`IMMEDIATE`)||(this.appendValueInput(`IMMEDIATE`).setCheck(`Boolean`).setAlign(m.Align.RIGHT).appendField(`%{BKY_TIME_IMMEDIATE}`),this.moveInputBefore(`IMMEDIATE`,`CALLBACK`)),this.getInput(`COUNT`)||(this.appendValueInput(`COUNT`).setCheck(`Number`).setAlign(m.Align.RIGHT).appendField(`%{BKY_TIME_COUNT}`),this.moveInputBefore(`COUNT`,`IMMEDIATE`)),this.getInput(`LOOP`)||(this.appendValueInput(`LOOP`).setCheck(`Boolean`).setAlign(m.Align.RIGHT).appendField(`%{BKY_TIME_LOOP}`),this.moveInputBefore(`LOOP`,`COUNT`)),this.getInput(`INTERVAL`)||(this.appendValueInput(`INTERVAL`).setCheck(`Number`).setAlign(m.Align.RIGHT).appendField(`%{BKY_TIME_INTERVAL_MS}`),this.moveInputBefore(`INTERVAL`,`LOOP`))},updateShadow_:function(){if(this.isInsertionMarker())return;let e=dn(1e3);this.getInput(`INTERVAL`)?.setShadowDom(e);let t=fn(!1);this.getInput(`LOOP`)?.setShadowDom(t);let n=dn(1);this.getInput(`COUNT`)?.setShadowDom(n);let r=fn(!1);this.getInput(`IMMEDIATE`)?.setShadowDom(r)}},y.forBlock.create_timer_v1=function(e){return`__createTimerV1__(${y.valueToCode(e,`INTERVAL`,v.ATOMIC)||`1000`}, ${y.valueToCode(e,`LOOP`,v.ATOMIC)||`false`}, ${y.valueToCode(e,`COUNT`,v.ATOMIC)||`1`}, ${y.valueToCode(e,`IMMEDIATE`,v.ATOMIC)||`false`}, async function() {
|
|
378
|
+
${y.statementToCode(e,`CALLBACK`)}});\n`},a([{type:`delay_v1`,message0:`%{BKY_TIME_V1_DELAY_TITLE}`,args0:[{type:`input_value`,name:`DURATION`,check:`Number`}],previousStatement:null,nextStatement:null,style:`time_blocks`,tooltip:`%{BKY_TIME_V1_DELAY_TOOLTIP}`,helpUrl:`%{BKY_TIME_V1_DELAY_HELPURL}`}]),y.forBlock.delay_v1=function(e){return`await __delayV1__(${y.valueToCode(e,`DURATION`,v.ATOMIC)||`0`});\n`};const di={customContextMenu:function(e){if(!this.isInFlyout){let t,n;this.type===`variable_get_v1`?(t=`variable_set_v1`,n=I(`VARIABLE_GET_CREATE_SET`)):this.type===`variable_set_v1`?(t=`variable_get_v1`,n=I(`VARIABLE_SET_CREATE_GET`)):console.assert(!1);let r=this.getField(`VAR`),i={type:t,fields:{VAR:r.saveState(!0)}};e.push({enabled:this.workspace.remainingCapacity()>0,text:n.replace(`%1`,r.getText()),callback:fe.callbackFactory(this,i)})}else if(this.type===`variable_get_v1`){let t={text:I(`RENAME_VARIABLE`),enabled:!0,callback:fi(this)},n=this.getField(`VAR`).getText(),r={text:I(`DELETE_VARIABLE`).replace(`%1`,n),enabled:!0,callback:pi(this)};e.unshift(t),e.unshift(r)}}},fi=function(e){return function(){let t=e.workspace,n=e.getField(`VAR`).getVariable();le.renameVariable(t,n)}},pi=function(e){return function(){let t=e.getField(`VAR`).getVariable();t&&le.deleteVariable(t.getWorkspace(),t,e)}};h.registerMixin(`context_menu_variable_v1`,di),a([{type:`variable_get_v1`,message0:`%1`,args0:[{type:`field_variable`,name:`VAR`}],output:null,style:`variable_blocks`,tooltip:`%{BKY_VARIABLE_V1_GET_TOOLTIP}`,helpUrl:`%{BKY_VARIABLE_V1_GET_HELPURL}`,extensions:[`context_menu_variable_v1`]}]),y.forBlock.variable_get_v1=function(e){return[y.nameDB_.getName(e.getFieldValue(`VAR`),f.NameType.VARIABLE),v.ATOMIC]},a([{type:`variable_set_v1`,message0:`%{BKY_VARIABLE_V1_SET_TITLE}`,args0:[{type:`field_variable`,name:`VAR`,variable:``},{type:`input_value`,name:`VALUE`}],previousStatement:null,nextStatement:null,style:`variable_blocks`,tooltip:`%{BKY_VARIABLE_V1_SET_TOOLTIP}`,helpUrl:`%{BKY_VARIABLE_V1_SET_HELPURL}`,extensions:[`context_menu_variable_v1`]}]),y.forBlock.variable_set_v1=function(e){return`${y.nameDB_.getName(e.getFieldValue(`VAR`),f.NameType.VARIABLE)} = ${y.valueToCode(e,`VALUE`,v.ASSIGNMENT)||`0`};\n`},c.setConfirm(async(e,t)=>{t(!!await Te({title:``,text:e}))}),c.setPrompt(async(e,t,n)=>{let r=await Ee({title:``,value:t});r!==void 0&&n(String(r))});const mi=C.prototype;mi.doClassValidation_=function(e){return e};const hi=mi.doValueUpdate_;mi.doValueUpdate_=function(e){hi.call(this,e),this.selectedOption&&this.selectedOption[1]!==e&&(this.selectedOption=null)};const gi=mi.getText_;mi.getText_=function(){if(this.selectedOption)return gi.call(this);let{i18n:e}=Ce,t=this.getSourceBlock();if(this.name===`APP`)return t.app.name;if(this.name===`PAGE`)return t.page.name;if(this.name===`ELEMENT`)return t.element.name;if(this.name===`NODE`){let n=E(t.node.key);if(n)return`${e.global.t(n.name)} / ${t.node.alias}`}else if(this.name===`PROPERTY`){let{kind:e,names:n}=t.property;return Ye(e,n)}else if(this.name===`EVENT`){let{kind:e,names:n}=t.event;return qe(e,n)}else if(this.name===`METHOD`){let{kind:e,names:n}=t.method;return Je(e,n)}else if(this.name===`SPACE`)return t.space.name;else if(this.name===`FUNC`)return t.func.name;else if(this.name===`OUTPUT`)return t.output.name;else if(this.name===`TABLE`)return t.table.name;else if(this.name===`COLUMN`)return t.column.name;else if(this.name===`DIR`)return t.dir.name;else if(this.name===`RESOURCE`)return t.resource.name;return`<n/a>`},ee.prototype.cleanUp=function(){this.setResizesEnabled(!1);let e=b.getGroup();e||b.setGroup(!0);let t=this.getTopBlocks(!0),n=t.filter(e=>e.isMovable()),r=t.filter(e=>!e.isMovable()).map(e=>e.getBoundingRectangle()),i=function(e){for(let t of r)if(e.intersects(t))return t;return null},a=0;for(let e of n){let t=e.getBoundingRectangle();e.moveBy(-t.left,a-t.top,[`cleanup`]),e.snapToGrid(),t=e.getBoundingRectangle();let n=i(t);for(;n!=null;)a=n.top+n.getHeight()+60,e.moveBy(0,a-t.top,[`cleanup`]),e.snapToGrid(),t=e.getBoundingRectangle(),n=i(t);a=e.getRelativeToSurfaceXY().y+e.getHeightWidth().height+60}b.setGroup(e),this.setResizesEnabled(!0)};var _i=he();function vi(e){let t=e.getParent();return t&&vi(t)?!0:!t&&!!(e.outputConnection||e.previousConnection)}var yi=class{init(){let e=se.registry.getItem(`blockDisable`);e&&(e.preconditionFn=function(e){let t=e.block;return t&&!t.isInFlyout&&t.workspace.options.disable&&t.isEditable()?t.getInheritedDisabled()||vi(t)?`disabled`:`enabled`:`hidden`})}};(0,Tn.registerFieldColour)(),ne.registry.unregister(r.names.ESCAPE),new _i.CrossTabCopyPaste().init({contextMenu:!0,shortcut:!0}),new yi().init();var bi=class extends b.Abstract{isBlank=!0;recordUndo=!1;type=`state_change`;constructor(e){super(),this.workspaceId=e.id}};s.register(s.Type.EVENT,`state_change`,bi);function xi(e){let t=u();if(!t)return;let n=t.getBlockById(e);if(!n)return;let r=n.getRootBlock();if(!r)return;let i=r.getRelativeToSurfaceXY(),a=i.x*t.scale,o=i.y*t.scale;t.scroll(-a,-o)}function Si(){let e=u();if(!e)return;let t=e.getTopBlocks(!0)?.[0];t&&xi(t.id)}e.Classic.blockStyles={color_blocks:{colourPrimary:`#a5745b`,colourSecondary:`#ede3de`,colourTertiary:`#845d49`,hat:``},event_blocks:{colourPrimary:`#a5a55b`,colourSecondary:`#ededde`,colourTertiary:`#848449`,hat:``},list_blocks:{colourPrimary:`#745ba5`,colourSecondary:`#e3deed`,colourTertiary:`#5d4984`,hat:``},logic_blocks:{colourPrimary:`#5b80a5`,colourSecondary:`#dee6ed`,colourTertiary:`#496684`,hat:``},loop_blocks:{colourPrimary:`#5ba55b`,colourSecondary:`#deedde`,colourTertiary:`#498449`,hat:``},math_blocks:{colourPrimary:`#5b67a5`,colourSecondary:`#dee1ed`,colourTertiary:`#495284`,hat:``},method_blocks:{colourPrimary:`#995ba5`,colourSecondary:`#ebdeed`,colourTertiary:`#7a4984`,hat:``},object_blocks:{colourPrimary:`#80a55b`,colourSecondary:`#e6edde`,colourTertiary:`#668449`,hat:``},procedure_blocks:{colourPrimary:`#995ba5`,colourSecondary:`#ebdeed`,colourTertiary:`#7a4984`,hat:``},property_blocks:{colourPrimary:`#5ba5a5`,colourSecondary:`#deeded`,colourTertiary:`#498484`,hat:``},state_blocks:{colourPrimary:`#a55b67`,colourSecondary:`#eddee1`,colourTertiary:`#844952`,hat:``},text_blocks:{colourPrimary:`#5ba58c`,colourSecondary:`#deede8`,colourTertiary:`#498470`,hat:``},time_blocks:{colourPrimary:`#5b99a5`,colourSecondary:`#deebed`,colourTertiary:`#497a84`,hat:``},variable_blocks:{colourPrimary:`#a55b80`,colourSecondary:`#eddee6`,colourTertiary:`#844966`,hat:``}},e.Classic.categoryStyles={color_category:{colour:`#a5745b`},common_category:{colour:`#757575`},compute_category:{colour:`#757575`},data_category:{colour:`#757575`},event_category:{colour:`#a5a55b`},flow_category:{colour:`#757575`},func_category:{colour:`#757575`},list_category:{colour:`#745ba5`},logic_category:{colour:`#5b80a5`},loop_category:{colour:`#5ba55b`},math_category:{colour:`#5b67a5`},method_category:{colour:`#995ba5`},misc_category:{colour:`#757575`},object_category:{colour:`#80a55b`},procedure_category:{colour:`#995ba5`},property_category:{colour:`#5ba5a5`},resource_category:{colour:`#757575`},state_category:{colour:`#a55b67`},text_category:{colour:`#5ba58c`},time_category:{colour:`#5b99a5`},variable_category:{colour:`#a55b80`}};const Ci=ue.defineTheme(`light`,{name:`light`,base:e.Classic,componentStyles:{workspaceBackgroundColour:`#ffffff`,toolboxBackgroundColour:`#eeeeee`,toolboxForegroundColour:``,flyoutBackgroundColour:`#eeeeee`,flyoutForegroundColour:`#000000`,flyoutOpacity:.8,scrollbarColour:``,insertionMarkerColour:``,insertionMarkerOpacity:.3,scrollbarOpacity:.4,cursorColour:``}}),wi=ue.defineTheme(`dark`,{name:`dark`,base:e.Classic,componentStyles:{workspaceBackgroundColour:`#1e1e1e`,toolboxBackgroundColour:`#272727`,toolboxForegroundColour:``,flyoutBackgroundColour:`#272727`,flyoutForegroundColour:`#ffffff`,flyoutOpacity:.8,scrollbarColour:``,insertionMarkerColour:``,insertionMarkerOpacity:.3,scrollbarOpacity:.4,cursorColour:``}});function Ti(e){let t=u();switch(e){case`light`:t.setTheme(Ci);break;case`dark`:t.setTheme(wi);break}}function Ei(e,t){e.find(e=>e===t)||e.push(t)}const Di=[`get_app_property_v1`,`get_app_state_v1`];function Oi(e){let t=[];function n(e){for(let r of e.getChildren(!0))Di.includes(r.type)&&t.push(r),n(r)}return n(e),t}function ki(e){let t=[];for(let n of e)n.type===`get_app_property_v1`?Ei(t,Ue(`propertyTrigger`,n.property.id)):n.type===`get_app_state_v1`?Ei(t,Ue(`stateTrigger`,n.state.id)):console.assert(!1);return t}function Ai(e){let t=[];for(let n of e){if(n.type!==`app_bind_entry_v1`)continue;let e=n;e.kind===`property`?Ei(t,Ue(`propertyTrigger`,e.property.id)):e.kind===`state`&&Ei(t,Ue(`stateTrigger`,e.state.id))}return t}function ji(e){let t={watchEffect:{ids:[],triggers:{}},bind:{sets:{},triggers:{}}},n=e.getTopBlocks(!0);if(!n)return t;for(let e of n)if(e.type===`watch_effect_v1`){let n=ki(Oi(e));for(let r of n)t.watchEffect.triggers[r]||(t.watchEffect.triggers[r]=[]),Ei(t.watchEffect.triggers[r],e.id);t.watchEffect.ids.push(e.id)}else if(e.type===`app_bind_v1`){let n=Ai(e.getChildren(!0));t.bind.sets[e.id]=n;for(let r of n)t.bind.triggers[r]||(t.bind.triggers[r]=[]),Ei(t.bind.triggers[r],e.id)}return t}const Mi=Symbol();function Ni(e){yt(Mi,e)}function Pi(){return dt(Mi)}var Fi=ut({__name:`index`,props:{lock:{type:Boolean,required:!0}},setup(e,{expose:t}){let{t:n}=Pt(),r=Ft(),i=Pi(),a=O(()=>r.smAndDown.value),o=()=>{if(!i.workspace){console.assert(!1);return}if(e.lock){we(n(`x-block-lib.msg.cannotOperateInLockedState`));return}i.workspace.cleanUp()},s=()=>{o()};return t({cleanWorkspace:o}),(e,t)=>{let r=P(`v-btn`),i=P(`v-tooltip`);return N(),ct(i,{disabled:a.value,text:F(n)(`x-block-lib.tip.hotkeyCtrlQ`)},{activator:kt(({props:e})=>[j(r,mt(e,{density:`comfortable`,icon:`mdi-broom`,variant:`outlined`,onClick:s}),null,16)]),_:1},8,[`disabled`,`text`])}}});function Ii(e,t){let n=t.newBlock(`json_root_v1`);n.initSvg(),n.render();let r=(e,n)=>{if(e===null)return;let i;if(e instanceof Array)i=`json_array_v1`;else{let t=typeof e;if(t===`object`)i=`json_map_v1`;else if(t===`string`)i=`json_string_v1`;else if(t===`number`)i=`json_number_v1`;else if(t===`boolean`)i=`json_boolean_v1`;else return}let a=t.newBlock(i);if(a.initSvg(),a.render(),n.connect(a.outputConnection),i===`json_map_v1`){let t=[];for(let n in e)t.push(n);a.initData(t);for(let n=0;n<t.length;n++){let i=t[n],o=a.getInput(`ENTRY`+n);r(e[i],o.connection)}}else if(i===`json_array_v1`){a.initData(e.length);for(let t=0;t<e.length;t++)r(e[t],a.getInput(`ENTRY`+t).connection)}else i===`json_string_v1`||i===`json_number_v1`?a.setFieldValue(e,`VALUE`):i===`json_boolean_v1`&&a.setFieldValue(e?`true`:`false`,`VALUE`)};r(e,n.getInput(`JSON`).connection),b.fire(new(b.get(b.FINISHED_LOADING))(t))}function Li(e){let t=e=>{if(!e)return null;if(e.type===`json_root_v1`)return t(e.getInputTargetBlock(`JSON`));if(e.type===`json_map_v1`){let n={};for(let r=0;r<e.length;r++){let i=e.getFieldValue(`KEY`+r);n[i]=t(e.getInputTargetBlock(`ENTRY`+r))}return n}else if(e.type===`json_array_v1`){let n=[];for(let r=0;r<e.length;r++)n.push(t(e.getInputTargetBlock(`ENTRY`+r)));return n}else if(e.type===`json_string_v1`)return e.getFieldValue(`VALUE`);else if(e.type===`json_number_v1`)return e.getFieldValue(`VALUE`);else if(e.type===`json_boolean_v1`)return e.getFieldValue(`VALUE`)===`true`;else console.assert(!1)},n=e.getTopBlocks();for(let e of n)if(e.type===`json_root_v1`)return t(e)}var Ri=ut({__name:`index`,props:{modelValue:{type:Boolean,required:!0},modelModifiers:{}},emits:[`update:modelValue`],setup(e){let{t}=Pt(),n=Ft(),r=Et(e,`modelValue`),i=O(()=>n.smAndDown.value);return(e,n)=>{let a=P(`v-btn`),o=P(`v-tooltip`);return N(),ct(o,{disabled:i.value,text:F(t)(`x-block-lib.tip.hotkeyCtrlW`)},{activator:kt(({props:e})=>[j(a,mt(e,{density:`comfortable`,icon:r.value?`mdi-lock`:`mdi-lock-open`,variant:`outlined`,onClick:n[0]||=e=>r.value=!r.value}),null,16,[`icon`])]),_:1},8,[`disabled`,`text`])}}});const zi={class:`d-flex flex-column`},Bi={class:`text-body-large ml-6`},Vi={key:0,class:`text-body-small text-grey text-truncate ml-6`,style:{maxWidth:`340px`}};var Hi=ut({__name:`item`,props:{id:{type:String,required:!0},title:{type:String,required:!0},desc:{type:String,required:!0},select:{type:Boolean,required:!0}},emits:[`x-click`],setup(e,{emit:t}){let{primaryColor:n,backgroundColor2:r,highlightColor:i}=De(),a=t,o=bt(!1),s=O(()=>{let t={position:`relative`,background:o.value?i.value:r.value,boxSizing:`border-box`,width:`100%`,height:`48px`,marginTop:`1px`,userSelect:`none`};return e.select?(t.borderTop=`1px solid `+n.value,t.borderBottom=`1px solid `+n.value):(t.borderTop=void 0,t.borderBottom=void 0),t});return(t,n)=>{let r=P(`v-spacer`),i=P(`v-icon`),c=Ct(`ripple`);return At((N(),k(`div`,{class:`d-flex align-center cursor-pointer`,style:M(s.value),onClick:n[1]||=t=>a(`x-click`,e.id),onMouseout:n[2]||=e=>o.value=!1,onMouseover:n[3]||=e=>o.value=!0},[A(`div`,zi,[A(`span`,Bi,wt(e.title),1),e.desc?(N(),k(`span`,Vi,wt(e.desc),1)):lt(`v-if`,!0)]),j(r),j(i,{class:`x-handle cursor-move mr-3`,icon:`mdi-drag-horizontal-variant`,onMousedown:n[0]||=Mt(()=>{},[`stop`])})],36)),[[c]])}}});const Ui={key:1,class:`text-body-small text-grey`};var Wi=((e,t)=>{let n=e.__vccOpts||e;for(let[e,r]of t)n[e]=r;return n})(ut({__name:`index`,props:pt({lock:{type:Boolean,required:!0}},{modelValue:{type:Boolean,required:!0},modelModifiers:{}}),emits:[`update:modelValue`],setup(e,{expose:t}){let{t:n}=Pt(),r=Et(e,`modelValue`),i=Pi(),a=bt([]);t({update:()=>{if(!i.workspace){console.assert(!1);return}let e=[];i.workspace.getTopBlocks(!0).forEach(t=>{let r=t.id===re()?.id,i=``;if(t.type.startsWith(`on_app_event_v`)){let e=t,r=E(e.node.key);r&&(i=n(r.name),e.node.alias&&(i+=` / `+e.node.alias),i+=` - `+qe(e.event.kind,e.event.names))}else if(t.type.startsWith(`watch_effect_v`))i=n(`x-block-lib.watchEffect`);else if(t.type.startsWith(`app_bind_v`))i=n(`x-block-lib.bind`);else if(t.type.startsWith(`implement_app_method_v`)){let e=t;i=n(`x-block-lib.implementMethod`),i+=` - `+Je(e.method.kind,e.method.names)}else i=t.type.startsWith(`func_entry_v`)?n(`x-block-lib.funcEntry`):t.type.startsWith(`procedure_def_v`)?n(`x-block-lib.procedure`)+` - `+t.getFieldValue(`NAME`):n(`x-block-lib.temporaryBlock`);let a=t.getCommentText()??``;e.push({id:t.id,name:i,desc:a,select:r})}),a.value=e}});let o=[],s=()=>{if(e.lock){we(n(`x-block-lib.msg.cannotOperateInLockedState`));return}let t=[];a.value.forEach(({id:e})=>{t.push(e)}),o=t},c=()=>!e.lock,l=e=>{if(!i.workspace){console.assert(!1);return}if(e.oldIndex===void 0||e.newIndex===void 0){console.assert(!1);return}if(e.oldIndex===e.newIndex)return;let t=o[e.oldIndex],n=i.workspace.getBlockById(t);if(!n){console.assert(!1);return}let r=``;e.newIndex>e.oldIndex?r=o[e.newIndex]:e.newIndex>0&&(r=o[e.newIndex-1]);let a=-10;r!==``&&(a=i.workspace.getBlockById(r).getRelativeToSurfaceXY().y+10);let s=n.getRelativeToSurfaceXY();n.moveTo(new S.Coordinate(s.x,a)),i.workspace.cleanUp(),Si()},u=async e=>{if(!i.workspace){console.assert(!1);return}let t=i.workspace.getBlockById(e);d.setSelected(t),xi(e),r.value=!1};return(e,t)=>a.value.length>0?(N(),ct(F(It),{key:0,modelValue:a.value,"onUpdate:modelValue":t[0]||=e=>a.value=e,animation:150,"ghost-class":`ghost`,handle:`.x-handle`,onEnd:l,onMove:c,onStart:s},{default:kt(()=>[(N(!0),k(st,null,xt(a.value,e=>(N(),ct(Hi,{id:e.id,key:e.id,desc:e.desc,select:e.select,title:e.name,onXClick:u},null,8,[`id`,`desc`,`select`,`title`]))),128))]),_:1},8,[`modelValue`])):(N(),k(`span`,Ui,wt(F(n)(`x-block-lib.noOption`)),1))}}),[[`__scopeId`,`data-v-x-block-lib-ca7316a0`]]),Gi=ut({__name:`index`,props:{modelValue:{type:Boolean,required:!0},modelModifiers:{}},emits:[`update:modelValue`],setup(e,{expose:t}){let n=Et(e,`modelValue`),r=Pi();t({update:()=>{if(!r.workspace){console.assert(!1);return}}});let i=e=>{let t=u();if(!t){console.assert(!1);return}let r=t.getBlockById(e);d.setSelected(r),xi(e),n.value=!1};return(e,t)=>(N(),k(`div`,{onClick:t[0]||=e=>i(``)},`blockTree`))}});const Ki={class:`text-body-large`};var qi=ut({__name:`index`,props:{type:{type:String,required:!0},lock:{type:Boolean,required:!0}},setup(e,{expose:t}){let{t:n}=Pt(),r=Ft(),{sysBarAvail:i}=Oe(),{backgroundColor1:a}=De(),o=O(()=>r.smAndDown.value),s=O(()=>{let e=`100%`;return r.mdAndUp.value&&(e=`400px`),{background:a.value,width:e,height:`100%`}}),c=O(()=>{let e=48;return i.value&&(e+=24),{position:`relative`,height:`calc(100% - ${e}px)`}}),l=O(()=>({height:`60px`})),{open:u}=ke(`blocklyNavigatorDlg${Tt()}`);vt(()=>{u.value=!1});let ee=Dt(`blockList`),te=Dt(`blockTree`);return t({open:u,update:()=>{e.type===`list`?ee.value?.update():e.type===`tree`&&te.value?.update()}}),(t,r)=>{let a=P(`v-sheet`),ne=P(`v-btn`),d=P(`v-spacer`),re=P(`v-dialog`),ie=P(`v-tooltip`);return N(),k(st,null,[j(re,{modelValue:F(u),"onUpdate:modelValue":r[5]||=e=>ft(u)?u.value=e:null,eager:``,fullscreen:``,"no-click-animation":``,persistent:``,transition:`scroll-x-reverse-transition`,onKeydown:r[6]||=jt(Mt(e=>u.value=!1,[`stop`,`prevent`]),[`esc`])},{default:kt(()=>[A(`div`,{class:`w-100 h-100 d-flex flex-row-reverse`,onClick:r[3]||=Mt(e=>u.value=!1,[`self`]),onContextmenu:r[4]||=Mt(e=>u.value=!1,[`self`,`prevent`])},[A(`div`,{class:`elevation-2`,style:M(s.value)},[F(i)?(N(),ct(a,{key:0,color:`transparent`,height:24})):lt(`v-if`,!0),j(a,{class:`d-flex align-center px-2`,color:`transparent`,height:48},{default:kt(()=>[j(ne,{density:`comfortable`,icon:`mdi-close`,variant:`text`,onClick:r[0]||=e=>u.value=!1}),A(`span`,Ki,wt(F(n)(`x-block-lib.navigator`)),1),j(d)]),_:1}),A(`div`,{class:`overflow-y-auto`,style:M(c.value)},[e.type===`list`?(N(),ct(Wi,{key:0,ref_key:`blockList`,ref:ee,modelValue:F(u),"onUpdate:modelValue":r[1]||=e=>ft(u)?u.value=e:null,lock:e.lock},null,8,[`modelValue`,`lock`])):e.type===`tree`?(N(),ct(Gi,{key:1,ref_key:`blockTree`,ref:te,modelValue:F(u),"onUpdate:modelValue":r[2]||=e=>ft(u)?u.value=e:null},null,8,[`modelValue`])):lt(`v-if`,!0),A(`div`,{style:M(l.value)},null,4)],4)],4)],32)]),_:1},8,[`modelValue`]),j(ie,{disabled:o.value,text:F(n)(`x-block-lib.tip.hotkeyCtrlE`)},{activator:kt(({props:e})=>[j(ne,mt(e,{density:`comfortable`,icon:`mdi-navigation-variant`,variant:`outlined`,onClick:r[7]||=e=>u.value=!0}),null,16)]),_:1},8,[`disabled`,`text`])],64)}}}),Ji=pe();const Z=S.xml;function Q(e){let t=Z.createElement(`label`);return t.setAttribute(`text`,e),t}function $(e,t){let n=Z.createElement(`block`);if(n.setAttribute(`type`,e),t)for(let e of t)n.appendChild(e);return n}function Yi(e){let t=Z.createElement(`mutation`);for(let{key:n,value:r}of e)t.setAttribute(n,r);return t}function Xi(e,t){t===void 0&&(t=``);let n=Z.createElement(`value`);n.setAttribute(`name`,e);let r=Z.createElement(`shadow`);r.setAttribute(`type`,`text_v1`);let i=Z.createElement(`field`);i.setAttribute(`name`,`TEXT`);let a=Z.createTextNode(t);return i.appendChild(a),r.appendChild(i),n.appendChild(r),n}function Zi(e,t){t===void 0&&(t=0);let n=Z.createElement(`value`);n.setAttribute(`name`,e);let r=Z.createElement(`shadow`);r.setAttribute(`type`,`math_number_v1`);let i=Z.createElement(`field`);i.setAttribute(`name`,`NUM`);let a=Z.createTextNode(String(t));return i.appendChild(a),r.appendChild(i),n.appendChild(r),n}function Qi(e,t){t===void 0&&(t=!1);let n=Z.createElement(`value`);n.setAttribute(`name`,e);let r=Z.createElement(`shadow`);r.setAttribute(`type`,`logic_boolean_v1`);let i=Z.createElement(`field`);i.setAttribute(`name`,`BOOL`);let a=Z.createTextNode(t?`TRUE`:`FALSE`);return i.appendChild(a),r.appendChild(i),n.appendChild(r),n}function $i(){let{activeObject:e,activeComp:t}=w.app;return!(e.type!==`comp`||!t.meta.states||t.meta.states.length<=0)}function ea(){let e=[];return e.push(Q(I(`LABEL_EVENT`))),W(`onEvent`)&&e.push($(`on_app_event_v1`)),W(`triggerEvent`)&&e.push($(`trigger_app_event_v1`)),e.push($(`app_bind_v1`,[Yi([{key:`items`,value:`2`}])])),e.push($(`watch_effect_v1`)),(W(`getProperty`)||W(`setProperty`))&&e.push(Q(I(`LABEL_PROPERTY`))),W(`getProperty`)&&e.push($(`get_app_property_v1`)),W(`setProperty`)&&e.push($(`set_app_property_v1`)),$i()&&(e.push(Q(I(`LABEL_STATE`))),e.push($(`get_app_state_v1`)),e.push($(`set_app_state_v1`))),(W(`callMethod`)||W(`implementMethod`))&&e.push(Q(I(`LABEL_METHOD`))),W(`callMethod`)&&e.push($(`call_app_method_v1`)),W(`implementMethod`)&&(e.push($(`implement_app_method_v1`)),W(`implementMethodOutput`)&&e.push($(`set_app_method_output_v1`)),e.push($(`procedure_return_v1`))),e}const ta={name:`APP_COMP_CATEGORY`,callback:ea};function na(){let e=[];return e.push(Q(I(`LABEL_FUNC`))),e.push(Q(I(`LABEL_FLOW`))),e}const ra={name:`APP_COMPUTE_CATEGORY`,callback:na};function ia(){let e=[];return e.push($(`app_debug_trace_v1`,[Xi(`OBJECT`)])),e.push($(`popup_message_v1`,[Xi(`TEXT`)])),e.push($(`open_confirm_dlg_v1`)),e.push($(`open_prompt_dlg_v1`)),e}const aa={name:`APP_MESSAGE_CATEGORY`,callback:ia};function oa(){for(let e of w.app.appList)if(e.pages.length>0)return!0;return!1}function sa(){let e=[];return e.push($(`app_env_is_v1`)),oa()&&e.push($(`navigate_to_v1`)),e}const ca={name:`APP_MISC_CATEGORY`,callback:sa};function la(){let{activeObject:e,activePage:t}=w.app;return!(e.type!==`page`||!t.meta.states||t.meta.states.length<=0)}function ua(){let{activeObject:e,activePage:t}=w.app;return!(e.type!==`page`||!t.meta.arguments||t.meta.arguments.length<=0)}function da(){let e=[];return e.push(Q(I(`LABEL_EVENT`))),W(`onEvent`)&&e.push($(`on_app_event_v1`)),e.push($(`app_bind_v1`,[Yi([{key:`items`,value:`2`}])])),e.push($(`watch_effect_v1`)),(W(`getProperty`)||W(`setProperty`))&&e.push(Q(I(`LABEL_PROPERTY`))),W(`getProperty`)&&e.push($(`get_app_property_v1`)),W(`setProperty`)&&e.push($(`set_app_property_v1`)),la()&&(e.push(Q(I(`LABEL_STATE`))),e.push($(`get_app_state_v1`)),e.push($(`set_app_state_v1`))),W(`callMethod`)&&(e.push(Q(I(`LABEL_METHOD`))),e.push($(`call_app_method_v1`))),ua()&&(e.push(Q(I(`LABEL_ARGUMENT`))),e.push($(`get_page_argument_v1`))),e}const fa={name:`APP_PAGE_CATEGORY`,callback:da};function pa(){let e=[];return e.push(Q(I(`LABEL_RESOURCE`))),e.push($(`upload_resource_v1`)),e}const ma={name:`APP_RESOURCE_CATEGORY`,callback:pa},ha=S.xml;function ga(){let e=[];{let t=ha.createElement(`label`);t.setAttribute(`text`,`%{BKY_LABEL_PROCEDURE}`),e.push(t)}{let t=ha.createElement(`block`);t.setAttribute(`type`,`procedure_def_v1`);{let e=ha.createElement(`field`);e.setAttribute(`name`,`NAME`);let n=ha.createTextNode(I(`PROCEDURE_DEFAULT_NAME`));e.appendChild(n),t.appendChild(e)}e.push(t)}{let t=ha.createElement(`block`);t.setAttribute(`type`,`procedure_return_v1`),e.push(t)}return e}const _a={name:`PROCEDURE_CATEGORY`,callback:ga},va=S.xml;function ya(){let e=u(),t=[];{let e=va.createElement(`label`);e.setAttribute(`text`,`%{BKY_LABEL_VARIABLE}`),t.push(e)}{let n=document.createElement(`button`);n.setAttribute(`text`,`%{BKY_NEW_VARIABLE}`),n.setAttribute(`callbackKey`,`CREATE_VARIABLE`),e.registerButtonCallback(`CREATE_VARIABLE`,function(e){le.createVariableButtonHandler(e.getTargetWorkspace())}),t.push(n)}let n=e.getVariablesOfType(``);if(n.length<=0)return t;n.sort(le.compareByName);{let e=va.createElement(`label`);e.setAttribute(`text`,I(`LABEL_CREATED`)),t.push(e)}return n.forEach(e=>{{let n=va.createElement(`block`);n.setAttribute(`type`,`variable_get_v1`),n.appendChild(le.generateVariableFieldDom(e)),t.push(n)}{let n=va.createElement(`block`);n.setAttribute(`type`,`variable_set_v1`),n.appendChild(le.generateVariableFieldDom(e)),t.push(n)}}),t}const ba={name:`VARIABLE_CATEGORY`,callback:ya};function xa(){let e=[];if(Or().length>0)e.push(Q(I(`LABEL_OPERATION`))),e.push($(`add_data_v1`)),e.push($(`delete_data_v1`)),e.push($(`update_data_v1`)),e.push($(`query_data_v1`)),e.push($(`transaction_v1`)),e.push($(`interrupt_transaction_v1`,[Xi(`VALUE`)])),e.push(Q(I(`LABEL_CONDITION`))),e.push($(`cond_logic_v1`)),e.push($(`cond_atomic_v1`,[Xi(`VALUE`)])),e.push(Q(I(`LABEL_QUERY_EXTRA`))),e.push($(`query_extra_limit_v1`,[Zi(`OFFSET`,0),Zi(`LIMIT`,1)])),e.push($(`query_extra_sortby_v1`,[Xi(`COLUMN`),Qi(`DESC`)]));else{let t=document.createElement(`button`);t.setAttribute(`text`,I(`BUTTON_NO_TABLE`)),t.setAttribute(`callbackKey`,`NO_TABLE`),e.push(t)}return e}const Sa={name:`COMPUTE_DATA_CATEGORY`,callback:xa};function Ca(){return Tr(`flow`).length>0}function wa(){let e=[];return w.compute.activeObject.type===`flow`&&e.push($(`on_flow_state_event_v1`)),Ca()&&console.assert(!0),e}const Ta={name:`COMPUTE_FLOW_CATEGORY`,callback:wa};function Ea(){return Tr(`func`).length>0}function Da(){let{activeObject:e,activeFunc:t}=w.compute,n=[];return e.type===`func`&&(n.push($(`func_entry_v1`)),t.outputs&&t.outputs.length>0&&n.push($(`set_func_output_v1`)),n.push($(`procedure_return_v1`))),Ea()&&n.push($(`call_func_internal_v1`)),n}const Oa={name:`COMPUTE_FUNC_CATEGORY`,callback:Da};function ka(){let e=[];return e.push($(`compute_debug_trace_v1`,[Xi(`OBJECT`)])),e}const Aa={name:`COMPUTE_MISC_CATEGORY`,callback:ka},ja={kind:`category`,name:`%{BKY_CATEGORY_COLOR}`,categorystyle:`color_category`,contents:[{kind:`block`,type:`color_picker_v1`},{kind:`block`,type:`color_random_v1`},{kind:`block`,type:`color_rgb_v1`,inputs:{RED:{shadow:{type:`math_number_v1`,fields:{NUM:0}}},GREEN:{shadow:{type:`math_number_v1`,fields:{NUM:0}}},BLUE:{shadow:{type:`math_number_v1`,fields:{NUM:0}}}}},{kind:`block`,type:`color_blend_v1`,inputs:{COLOR1:{shadow:{type:`color_picker_v1`,fields:{COLOR:`#ff0000`}}},COLOR2:{shadow:{type:`color_picker_v1`,fields:{COLOR:`#00ff00`}}},RATIO:{shadow:{type:`math_number_v1`,fields:{NUM:.5}}}}}]},Ma={kind:`category`,name:`%{BKY_CATEGORY_LIST}`,categorystyle:`list_category`,contents:[{kind:`label`,text:`%{BKY_LABEL_LIST}`},{kind:`block`,type:`list_create_v1`,extraState:{itemCount:0}},{kind:`label`,text:`%{BKY_LABEL_GET}`},{kind:`block`,type:`list_is_empty_v1`},{kind:`block`,type:`list_length_v1`},{kind:`block`,type:`list_get_v1`,inputs:{AT:{shadow:{type:`math_number_v1`,fields:{NUM:1}}}}},{kind:`block`,type:`list_get_sublist_v1`,inputs:{START:{shadow:{type:`math_number_v1`,fields:{NUM:1}}},END:{shadow:{type:`math_number_v1`,fields:{NUM:1}}}}},{kind:`label`,text:`%{BKY_LABEL_SET}`},{kind:`block`,type:`list_set_v1`,inputs:{AT:{shadow:{type:`math_number_v1`,fields:{NUM:1}}}}},{kind:`block`,type:`list_delete_v1`,inputs:{AT:{shadow:{type:`math_number_v1`,fields:{NUM:1}}}}},{kind:`block`,type:`list_join_v1`,inputs:{DELIM:{shadow:{type:`text_v1`,fields:{TEXT:``}}}}},{kind:`block`,type:`list_reverse_v1`}]},Na={kind:`category`,name:`%{BKY_CATEGORY_LOGIC}`,categorystyle:`logic_category`,contents:[{kind:`label`,text:`%{BKY_LABEL_BOOLEAN}`},{kind:`block`,type:`logic_boolean_v1`},{kind:`label`,text:`%{BKY_LABEL_BRANCH}`},{kind:`block`,type:`logic_if_v1`},{kind:`label`,text:`%{BKY_LABEL_LOGIC_OPERATION}`},{kind:`block`,type:`logic_compare_v1`},{kind:`block`,type:`logic_operation_v1`},{kind:`block`,type:`logic_negate_v1`},{kind:`block`,type:`logic_ternary_v1`}]},Pa={kind:`category`,name:`%{BKY_CATEGORY_LOOP}`,categorystyle:`loop_category`,contents:[{kind:`block`,type:`repeat_v1`,inputs:{TIMES:{shadow:{type:`math_number_v1`,fields:{NUM:10}}}}},{kind:`block`,type:`while_until_v1`},{kind:`block`,type:`for_v1`,inputs:{FROM:{shadow:{type:`math_number_v1`,fields:{NUM:1}}},TO:{shadow:{type:`math_number_v1`,fields:{NUM:10}}},BY:{shadow:{type:`math_number_v1`,fields:{NUM:1}}}}},{kind:`block`,type:`for_each_v1`},{kind:`block`,type:`flow_control_v1`}]},Fa={kind:`category`,name:`%{BKY_CATEGORY_MATH}`,categorystyle:`math_category`,contents:[{kind:`label`,text:`%{BKY_LABEL_VALUE}`},{kind:`block`,type:`math_number_v1`,fields:{NUM:0}},{kind:`block`,type:`math_constant_v1`},{kind:`block`,type:`math_random_float_v1`},{kind:`block`,type:`math_random_int_v1`,inputs:{FROM:{shadow:{type:`math_number_v1`,fields:{NUM:1}}},TO:{shadow:{type:`math_number_v1`,fields:{NUM:100}}}}},{kind:`label`,text:`%{BKY_LABEL_MATH_OPERATION}`},{kind:`block`,type:`math_arithmetic_v1`,inputs:{A:{shadow:{type:`math_number_v1`,fields:{NUM:1}}},B:{shadow:{type:`math_number_v1`,fields:{NUM:1}}}}},{kind:`block`,type:`math_round_v1`,inputs:{NUM:{shadow:{type:`math_number_v1`,fields:{NUM:3.1}}}}},{kind:`block`,type:`math_single_v1`,inputs:{NUM:{shadow:{type:`math_number_v1`,fields:{NUM:9}}}}},{kind:`block`,type:`math_trig_v1`,inputs:{NUM:{shadow:{type:`math_number_v1`,fields:{NUM:45}}}}},{kind:`block`,type:`math_modulo_v1`,inputs:{DIVIDEND:{shadow:{type:`math_number_v1`,fields:{NUM:64}}},DIVISOR:{shadow:{type:`math_number_v1`,fields:{NUM:10}}}}},{kind:`block`,type:`math_number_property_v1`,inputs:{NUM:{shadow:{type:`math_number_v1`,fields:{NUM:2}}}}},{kind:`block`,type:`math_on_list_v1`}]},Ia={kind:`category`,name:`%{BKY_CATEGORY_OBJECT}`,categorystyle:`object_category`,contents:[{kind:`label`,text:`%{BKY_LABEL_OBJECT}`},{kind:`block`,type:`object_create_v1`},{kind:`block`,type:`object_from_json_v1`},{kind:`block`,type:`object_to_json_v1`},{kind:`label`,text:`%{BKY_LABEL_PROPERTY}`},{kind:`block`,type:`object_get_v1`,inputs:{KEY:{shadow:{type:`text_v1`,fields:{TEXT:``}}}}},{kind:`block`,type:`object_set_v1`,inputs:{KEY:{shadow:{type:`text_v1`,fields:{TEXT:``}}}}},{kind:`block`,type:`object_delete_v1`,inputs:{KEY:{shadow:{type:`text_v1`,fields:{TEXT:``}}}}}]},La={kind:`category`,name:`%{BKY_CATEGORY_TEXT}`,categorystyle:`text_category`,contents:[{kind:`label`,text:`%{BKY_LABEL_TEXT}`},{kind:`block`,type:`text_v1`},{kind:`block`,type:`text_join_v1`,extraState:{itemCount:2}},{kind:`label`,text:`%{BKY_LABEL_GET}`},{kind:`block`,type:`text_is_empty_v1`},{kind:`block`,type:`text_length_v1`},{kind:`block`,type:`text_char_at_v1`,inputs:{AT:{shadow:{type:`math_number_v1`,fields:{NUM:1}}}}},{kind:`block`,type:`text_substring_v1`,inputs:{START:{shadow:{type:`math_number_v1`,fields:{NUM:1}}},END:{shadow:{type:`math_number_v1`,fields:{NUM:1}}}}},{kind:`block`,type:`text_index_of_v1`,inputs:{SUBSTR:{shadow:{type:`text_v1`,fields:{TEXT:``}}}}},{kind:`block`,type:`text_count_v1`,inputs:{SUBSTR:{shadow:{type:`text_v1`,fields:{TEXT:``}}}}},{kind:`label`,text:`%{BKY_LABEL_SET}`},{kind:`block`,type:`text_append_v1`,inputs:{TEXT:{shadow:{type:`text_v1`,fields:{TEXT:``}}}}},{kind:`block`,type:`text_replace_v1`,inputs:{FROM:{shadow:{type:`text_v1`,fields:{TEXT:``}}},TO:{shadow:{type:`text_v1`,fields:{TEXT:``}}}}},{kind:`block`,type:`text_split_v1`,inputs:{DELIM:{shadow:{type:`text_v1`,fields:{TEXT:``}}}}},{kind:`block`,type:`text_change_case_v1`},{kind:`block`,type:`text_trim_v1`},{kind:`block`,type:`text_reverse_v1`}]},Ra={kind:`category`,name:`%{BKY_CATEGORY_TIME}`,categorystyle:`time_category`,contents:[{kind:`block`,type:`create_timer_v1`},{kind:`block`,type:`delay_v1`,inputs:{DURATION:{shadow:{type:`math_number_v1`,fields:{NUM:1e3}}}}}]},za={kind:`categoryToolbox`,contents:[{kind:`category`,name:`%{BKY_CATEGORY_COMP}`,categorystyle:`misc_category`,custom:ta.name},{kind:`category`,name:`%{BKY_CATEGORY_MESSAGE}`,categorystyle:`misc_category`,custom:aa.name},{kind:`category`,name:`%{BKY_CATEGORY_MISC}`,categorystyle:`misc_category`,custom:ca.name},Pa,Na,Fa,La,Ma,Ia,ja,Ra,{kind:`category`,name:`%{BKY_CATEGORY_VARIABLE}`,categorystyle:`variable_category`,custom:ba.name},{kind:`category`,name:`%{BKY_CATEGORY_PROCEDURE}`,categorystyle:`procedure_category`,custom:_a.name},{kind:`category`,name:`%{BKY_CATEGORY_RESOURCE}`,categorystyle:`resource_category`,custom:ma.name},{kind:`category`,name:`%{BKY_CATEGORY_COMPUTE}`,categorystyle:`compute_category`,custom:ra.name}]},Ba={kind:`categoryToolbox`,contents:[{kind:`category`,name:`%{BKY_CATEGORY_FUNC}`,categorystyle:`func_category`,custom:Oa.name},{kind:`category`,name:`%{BKY_CATEGORY_FLOW}`,categorystyle:`flow_category`,custom:Ta.name},{kind:`category`,name:`%{BKY_CATEGORY_DATA}`,categorystyle:`data_category`,custom:Sa.name},{kind:`category`,name:`%{BKY_CATEGORY_MISC}`,categorystyle:`misc_category`,custom:Aa.name},Pa,Na,Fa,La,Ma,Ia,ja,{kind:`category`,name:`%{BKY_CATEGORY_VARIABLE}`,categorystyle:`variable_category`,custom:ba.name},{kind:`category`,name:`%{BKY_CATEGORY_PROCEDURE}`,categorystyle:`procedure_category`,custom:_a.name}]},Va={kind:`categoryToolbox`,contents:[{kind:`category`,name:`%{BKY_CATEGORY_FUNC}`,categorystyle:`func_category`,custom:Oa.name},{kind:`category`,name:`%{BKY_CATEGORY_FLOW}`,categorystyle:`flow_category`,custom:Ta.name},{kind:`category`,name:`%{BKY_CATEGORY_DATA}`,categorystyle:`data_category`,custom:Sa.name},{kind:`category`,name:`%{BKY_CATEGORY_MISC}`,categorystyle:`misc_category`,custom:Aa.name},Pa,Na,Fa,La,Ma,Ia,ja,{kind:`category`,name:`%{BKY_CATEGORY_VARIABLE}`,categorystyle:`variable_category`,custom:ba.name},{kind:`category`,name:`%{BKY_CATEGORY_PROCEDURE}`,categorystyle:`procedure_category`,custom:_a.name}]},Ha={kind:`categoryToolbox`,contents:[{kind:`category`,name:`%{BKY_CATEGORY_JSON}`,colour:`330`,contents:[{kind:`block`,type:`json_map_v1`},{kind:`block`,type:`json_array_v1`},{kind:`block`,type:`json_string_v1`},{kind:`block`,type:`json_number_v1`},{kind:`block`,type:`json_boolean_v1`}]}]},Ua={kind:`categoryToolbox`,contents:[{kind:`category`,name:`%{BKY_CATEGORY_PAGE}`,categorystyle:`misc_category`,custom:fa.name},{kind:`category`,name:`%{BKY_CATEGORY_MESSAGE}`,categorystyle:`misc_category`,custom:aa.name},{kind:`category`,name:`%{BKY_CATEGORY_MISC}`,categorystyle:`misc_category`,custom:ca.name},Pa,Na,Fa,La,Ma,Ia,ja,Ra,{kind:`category`,name:`%{BKY_CATEGORY_VARIABLE}`,categorystyle:`variable_category`,custom:ba.name},{kind:`category`,name:`%{BKY_CATEGORY_PROCEDURE}`,categorystyle:`procedure_category`,custom:_a.name},{kind:`category`,name:`%{BKY_CATEGORY_RESOURCE}`,categorystyle:`resource_category`,custom:ma.name},{kind:`category`,name:`%{BKY_CATEGORY_COMPUTE}`,categorystyle:`compute_category`,custom:ra.name}]},Wa={grid:{length:2,snap:!0,spacing:20},maxInstances:{func_entry_v1:1},media:`/media/`,move:{drag:!0,scrollbars:!0,wheel:!0},readOnly:!1,theme:`light`,trashcan:!1,zoom:{maxScale:1,minScale:.1,scaleSpeed:1.25,startScale:1,wheel:!0}};function Ga(e,n,r,i){Wa.theme=i?`dark`:`light`,Wa.toolbox=Ka(n,r);let a=t(e,Wa);return a.addChangeListener(e=>{if(e.type===`state_change`){let e=a.getAllBlocks();for(let t of e){let e=t;e.checkWarning_&&e.checkWarning_()}}setTimeout(()=>{(0,Ji.shadowBlockConversionChangeListener)(e)},0)}),qa(a,n,r),Ja(a),a}function Ka(e,t){let n;return e===`page`?t===`v1`&&(n=Ua):e===`comp`?t===`v1`&&(n=za):e===`func`?t===`v1`&&(n=Va):e===`flow`?t===`v1`&&(n=Ba):e===`json`&&t===`v1`&&(n=Ha),console.assert(!!n,`invalid toolbox type=${e} version=${t}`),n}function qa(e,t,n){function r({name:n,callback:r}){e.registerToolboxCategoryCallback(n,()=>r(t))}t===`page`?n===`v1`&&(r(fa),r(aa),r(ca),r(ba),r(_a),r(ma),r(ra)):t===`comp`?n===`v1`&&(r(ta),r(aa),r(ca),r(ba),r(_a),r(ma),r(ra)):t===`func`?n===`v1`&&(r(Oa),r(Ta),r(Sa),r(Aa),r(ba),r(_a)):t===`flow`&&n===`v1`&&(r(Oa),r(Ta),r(Sa),r(Aa),r(ba),r(_a))}function Ja(e){let{router:t}=Ce;e.registerButtonCallback(`NO_COMPUTE`,()=>{let e=t.resolve({path:`/compute/`+Date.now()});setTimeout(()=>{window.open(e.href,`_blank`)},100)}),e.registerButtonCallback(`NO_TABLE`,()=>{let e=t.resolve({path:`/data/`+Date.now()});setTimeout(()=>{window.open(e.href,`_blank`)},100)})}const Ya={class:`position-relative w-100 h-100`};var Xa=ut({__name:`index`,props:pt({type:{type:String,required:!0},version:{type:String,required:!0},locale:{type:String,required:!0},dark:{type:Boolean,required:!0}},{lock:{type:Boolean,required:!0},lockModifiers:{},scale:{type:Number,required:!0},scaleModifiers:{}}),emits:pt([`ready`],[`update:lock`,`update:scale`]),setup(e,{expose:t,emit:n}){let{backgroundColor2:r}=De(),i=Et(e,`lock`),a=Et(e,`scale`),s=n,c=`blocklyEditor${Tt()}`,u=bt(),ee=Dt(`parentContainer`),te=Dt(`clean`),ne=Dt(`navigator`),d={};Ni(d);let re=bt(!0),ie=bt(!1),f=O(()=>e.type===`json`?`tree`:`list`),m=O(()=>({width:`100%`,height:`calc(100% - 48px)`})),ae=O(()=>({position:`absolute`,background:r.value,bottom:`0px`,width:`100%`,height:`48px`})),h=O(()=>({position:`absolute`,background:e.dark?`#0000007f`:`#ffffff7f`,top:`1px`,left:`0px`,width:`56px`,height:`calc(100% - 49px)`,zIndex:999})),oe=O(()=>({position:`absolute`,top:`0px`,right:`0px`,zIndex:20})),g=O(()=>({position:`absolute`,background:e.dark?`#0000007f`:`#ffffff7f`,top:`0px`,left:`0px`,width:`100%`,height:`calc(100% - 48px)`,pointerEvents:`none`})),_=O(()=>({position:`absolute`,background:e.dark?`#0000007f`:`#ffffff7f`,top:`1px`,left:`0px`,width:`56px`,height:`calc(100% - 49px)`,zIndex:999})),v=O(()=>({position:`fixed`,top:0,left:0,zIndex:3e3})),{open:se}=ke(`blocklyEditorFlyout${Tt()}`);_t(async()=>{if(!u.value||!ee.value){console.assert(!1);return}o(ee.value),await Bt(e.locale),d.workspace=Ga(u.value,e.type,e.version,e.dark),d.workspace.addChangeListener(b.disableOrphans),d.workspace.addChangeListener(ce);let t=document.querySelector(`#${c} .blocklyFlyout`);new MutationObserver(e=>{e.forEach(e=>{e.type===`attributes`&&e.attributeName===`style`&&(se.value=d.workspace.getFlyout().isVisible())})}).observe(t,{attributes:!0}),se.value=d.workspace.getFlyout().isVisible(),me(),x(),await ht(),s(`ready`)}),gt(()=>{se.value=!1}),Nt(u,()=>{d.workspace&&l(d.workspace)});async function ce(e){if(e.type===b.FINISHED_LOADING){Si(),setTimeout(()=>{ne.value?.update()},0),re.value=!1;return}if(!re.value){if(e.type===b.VIEWPORT_CHANGE){a.value=d.workspace.getScale();return}e.type===b.BLOCK_DRAG&&(e.isStart?ie.value=!0:ie.value=!1),setTimeout(()=>{ne.value?.update()},0)}}let le=t=>{re.value=!0,e.type===`json`?Ii(t,d.workspace):p.workspaces.load(t,d.workspace)},ue=()=>e.type===`json`?Li(d.workspace):p.workspaces.save(d.workspace),de=e=>{p.blocks.append(e,d.workspace)},fe=()=>{if(e.type===`json`)console.assert(!1);else return y.workspaceToCode(d.workspace)},pe=()=>ji(d.workspace),me=()=>{d.workspace.setIsReadOnly(i.value),d.workspace.isReadOnly()&&(se.value=!1)},x=()=>{d.workspace.setScale(a.value)},S=()=>{b.fire(new(b.get(`state_change`))(d.workspace))},he=()=>{te.value?.cleanWorkspace()},ge=()=>{i.value=!i.value},_e=()=>{ne.value&&(ne.value.open=!0)};return _t(()=>{Se.on(`cleanWorkspace`,he),Se.on(`toggleBlocklyLock`,ge),Se.on(`openBlocklyNavigator`,_e)}),gt(()=>{Se.off(`cleanWorkspace`,he),Se.off(`toggleBlocklyLock`,ge),Se.off(`openBlocklyNavigator`,_e)}),Ot(()=>e.locale,e=>{Bt(e)}),Ot(()=>e.dark,e=>{Ti(e?`dark`:`light`)}),Ot(se,e=>{e||d.workspace?.hideChaff()}),Ot(i,()=>{me()}),Ot(a,()=>{x()}),t({loading:re,load:le,save:ue,appendBlock:de,generateCode:fe,generateReactivity:pe,fireStateChange:S}),(e,t)=>{let n=P(`v-icon`),r=P(`x-loading`);return N(),k(`div`,Ya,[A(`div`,{id:c,ref_key:`blocklyDiv`,ref:u,style:M(m.value)},null,4),A(`div`,{style:M(ae.value)},[St(e.$slots,`bottom`)],4),ie.value?(N(),k(`div`,{key:0,class:`d-flex flex-column justify-center align-center`,style:M(h.value)},[j(n,{icon:`mdi-delete`,size:`x-large`})],4)):lt(`v-if`,!0),re.value?lt(`v-if`,!0):(N(),k(`div`,{key:1,class:`d-flex align-end ga-3 pt-3 pr-3`,style:M(oe.value)},[j(Fi,{ref_key:`clean`,ref:te,lock:i.value},null,8,[`lock`]),j(Ri,{modelValue:i.value,"onUpdate:modelValue":t[0]||=e=>i.value=e},null,8,[`modelValue`]),j(qi,{ref_key:`navigator`,ref:ne,lock:i.value,type:f.value},null,8,[`lock`,`type`])],4)),i.value?(N(),k(`div`,{key:2,style:M(_.value)},null,4)):lt(`v-if`,!0),i.value?(N(),k(`div`,{key:3,style:M(g.value)},null,4)):lt(`v-if`,!0),A(`div`,{ref_key:`parentContainer`,ref:ee,style:M(v.value)},null,4),j(r,{open:re.value,"z-index":99},null,8,[`open`])])}}}),Za=ut({__name:`index`,props:{code:{type:String,required:!0}},setup(e){Rt.registerLanguage(`javascript`,zt);let t=Lt.component,{backgroundColor2:n}=De();return(r,i)=>{let a=P(`v-sheet`);return N(),ct(a,{color:F(n),height:`100%`,width:`100%`},{default:kt(()=>[j(F(t),{code:e.code,language:`js`},null,8,[`code`])]),_:1},8,[`color`])}}});const Qa={class:`text-body-large`},$a={class:`w-100 h-100 overflow-auto`};var eo=ut({__name:`index`,setup(e){let{t}=Pt(),{sysBarAvail:n}=Oe(),{backgroundColor0:r,backgroundColor2:i}=De(),a=bt(``),o=O(()=>{let e=48;return n.value&&(e+=24),{position:`relative`,height:`calc(100% - ${e}px)`}}),{open:s}=ke(`sourceDlg`,e=>{a.value=e.code});return(e,c)=>{let l=P(`v-sheet`),u=P(`v-btn`),ee=P(`v-spacer`),te=P(`v-dialog`);return N(),ct(te,{modelValue:F(s),"onUpdate:modelValue":c[1]||=e=>ft(s)?s.value=e:null,fullscreen:``,"no-click-animation":``,persistent:``,transition:`dialog-bottom-transition`,onKeydown:c[2]||=jt(Mt(e=>s.value=!1,[`stop`,`prevent`]),[`esc`])},{default:kt(()=>[j(l,{color:F(r),height:`100%`,width:`100%`},{default:kt(()=>[F(n)?(N(),ct(l,{key:0,color:F(i),height:24},null,8,[`color`])):lt(`v-if`,!0),j(l,{class:`d-flex align-center px-2`,color:F(i),height:48},{default:kt(()=>[j(u,{density:`comfortable`,icon:`mdi-close`,variant:`text`,onClick:c[0]||=e=>s.value=!1}),A(`span`,Qa,wt(F(t)(`x-block-lib.dlg.source.title`)),1),j(ee)]),_:1},8,[`color`]),A(`div`,{style:M(o.value)},[A(`div`,$a,[j(Za,{code:a.value},null,8,[`code`])])],4)]),_:1},8,[`color`])]),_:1},8,[`modelValue`])}}});const to=e=>{e.component(`XBlockly`,Xa),e.component(`XSourceDlg`,eo)};async function no(e){if(e===`en`)return(await import(`./i18n-en.fzzizejc.js`).then(e=>e.t)).default;if(e===`zhHans`)return(await import(`./i18n-zhHans.b0wqxx8d.js`).then(e=>e.t)).default;throw Error(`invalid locale=${e}`)}var ro={install:to};export{Xa as XBlockly,ro as default,er as getCallMethodInfo,ir as getImplementMethodInfo,G as getNodeInfo,qn as getOnEventInfo,pr as getPropertyInfo,Xn as getTriggerEventInfo,to as install,no as loadLocaleMessageBlock};
|