@tripetto/block-variable
Version:
Variable block for Tripetto.
2 lines • 174 kB
JavaScript
/*! Tripetto Variable Block 3.0.3 - Copyright (C) 2023 Tripetto B.V. - All Rights Reserved */
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("Tripetto")):"function"==typeof define&&define.amd?define("TripettoBlockVariableBuilder",["Tripetto"],t):"object"==typeof exports?exports.TripettoBlockVariableBuilder=t(require("Tripetto")):e.TripettoBlockVariableBuilder=t(e.Tripetto)}(self,(function(e){return function(){var t={174:function(e,t,o){!function(){"use strict";var t={4533:function(e,t,o){var a,n=this&&this.__extends||(a=function(e,t){return a=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var o in t)Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o])},a(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function o(){this.constructor=e}a(e,t),e.prototype=null===t?Object.create(t):(o.prototype=t.prototype,new o)}),l=this&&this.__decorate||function(e,t,o,a){var n,l=arguments.length,i=l<3?t:null===a?a=Object.getOwnPropertyDescriptor(t,o):a;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)i=Reflect.decorate(e,t,o,a);else for(var r=e.length-1;r>=0;r--)(n=e[r])&&(i=(l<3?n(i):l>3?n(t,o,i):n(t,o))||i);return l>3&&i&&Object.defineProperty(t,o,i),i};Object.defineProperty(t,"__esModule",{value:!0}),t.Calculator=void 0;var i=o(9954),r=o(3208),c=o(5331),u=o(4583),s=o(4617),p=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.allowMarkdown=!1,t.startBlank=!0,t.operations=i.Collection.of(r.Operation,t),t}var o;return n(t,e),o=t,Object.defineProperty(t.prototype,"block",{get:function(){return this},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"label",{get:function(){return(0,i.npgettext)("block:calculator","%2 (%1 operation)","%2 (%1 operations)",this.operations.count,this.type.label)},enumerable:!1,configurable:!0}),t.prototype.defineName=function(){var e,t=this;if(!this.node.name&&!this.operations.count){var a=0,n=1;null===(e=this.map)||void 0===e||e.forEach((function(e){if("@tripetto/block-calculator"===e.blockTypeIdentifier&&(a++,e.name&&0===e.name.indexOf(o.label+" "))){var t=(0,i.castToNumber)(e.name.substr(o.label.length+1));t>n&&(n=t+1)}}),"nodes"),this.node.name=o.label+" ".concat(i.Num.max(n,a))}this.outcome.hook("OnSlotProperty","synchronous",(function(e){switch(e.property){case"precision":case"digits":case"decimal":case"separator":case"minimum":case"maximum":case"prefix":case"prefixPlural":case"suffix":case"suffixPlural":t.slots.each((function(o){o instanceof i.Slots.Numeric&&"dynamic"===o.kind&&(0,i.set)(o,e.property,t.outcome[e.property])}))}}),this)},t.prototype.defineSlot=function(){this.outcome=this.slots.static({type:i.Slots.Numeric,reference:"calculator",label:this.node.name||(0,i.pgettext)("block:calculator","Calculation"),exchange:["alias","exportable","precision","digits","decimal","separator","minimum","maximum","prefix","prefixPlural","suffix","suffixPlural"]})},t.prototype.defineEditor=function(){var e=this,t=new i.Forms.Numeric(i.Forms.Numeric.bind(this.outcome,"minimum",void 0)).precision(this.outcome.precision||0).digits(this.outcome.digits||0).decimalSign(this.outcome.decimal||"").thousands(!!this.outcome.separator,this.outcome.separator||"").prefix(this.outcome.prefix||"").prefixPlural(this.outcome.prefixPlural||void 0).suffix(this.outcome.suffix||"").suffixPlural(this.outcome.suffixPlural||void 0).label((0,i.pgettext)("block:calculator","Minimum")),o=new i.Forms.Numeric(i.Forms.Numeric.bind(this.outcome,"maximum",void 0)).precision(this.outcome.precision||0).digits(this.outcome.digits||0).decimalSign(this.outcome.decimal||"").thousands(!!this.outcome.separator,this.outcome.separator||"").prefix(this.outcome.prefix||"").prefixPlural(this.outcome.prefixPlural||void 0).suffix(this.outcome.suffix||"").suffixPlural(this.outcome.suffixPlural||void 0).label((0,i.pgettext)("block:calculator","Maximum")),a=this.editor.form({controls:[new i.Forms.Notification((0,i.pgettext)("block:calculator","Some formatting options were automatically set for you, based on the block you've just selected as initial value."),"success")]}).visible(!1),n=(0,i.getHelpTopic)("block:calculator");this.editor.form({title:(0,i.pgettext)("block:calculator","Explanation"),controls:[new i.Forms.Static((0,i.pgettext)("block:calculator","Perform a calculation and use the result in your form%1.",n?" ([".concat((0,i.pgettext)("block:calculator","learn more"),"](").concat(n,"))"):"")).markdown()]}),this.editor.option({name:(0,i.pgettext)("block:calculator","Operations"),collection:(0,c.calculator)(this),activated:!0,locked:!0}),this.editor.name(!1,!1,(0,i.pgettext)("block:calculator","Description"),!1),this.editor.groups.settings();var l=new i.Forms.Dropdown([{optGroup:(0,i.pgettext)("block:calculator","Decimals")},{label:"#",value:0},{label:"#.#",value:1},{label:"#.##",value:2},{label:"#.###",value:3},{label:"#.####",value:4},{label:"#.#####",value:5},{label:"#.######",value:6},{label:"#.#######",value:7},{label:"#.########",value:8},{optGroup:(0,i.pgettext)("block:calculator","Digits")},{label:"##",value:-2},{label:"###",value:-3},{label:"####",value:-4},{label:"#####",value:-5},{label:"######",value:-6},{label:"#######",value:-7},{label:"########",value:-8},{label:"#########",value:-9},{label:"##########",value:-10},{label:"###########",value:-11},{label:"############",value:-12},{label:"#############",value:-13},{label:"##############",value:-14},{label:"###############",value:-15},{label:"################",value:-16}],(this.outcome.digits?-this.outcome.digits:this.outcome.precision)||0).on((function(){e.outcome.precision=l.isFeatureEnabled&&(0,i.isNumber)(l.value)&&l.value>=0?l.value:void 0,e.outcome.digits=l.isFeatureEnabled&&(0,i.isNumber)(l.value)&&l.value<0?-l.value:void 0,t.precision(e.outcome.precision||0),o.precision(e.outcome.precision||0),t.digits(e.outcome.digits||0),o.digits(e.outcome.digits||0),u.disabled(!e.outcome.precision),M.disabled((e.outcome.digits||0)>0)})),r=this.editor.option({name:(0,i.pgettext)("block:calculator","Format"),form:{title:(0,i.pgettext)("block:calculator","Format"),controls:[l]},activated:(0,i.isNumber)(this.outcome.precision)||(0,i.isNumber)(this.outcome.digits)}),u=new i.Forms.Dropdown([{label:"#.#",value:"."},{label:"#,#",value:","}],i.Forms.Dropdown.bind(this.outcome,"decimal",void 0)).label((0,i.pgettext)("block:calculator","Decimal sign")).disabled(!this.outcome.precision).on((function(e){t.decimalSign(e.isFeatureEnabled&&e.value||""),o.decimalSign(e.isFeatureEnabled&&e.value||"")})),s=new i.Forms.Dropdown([{label:(0,i.pgettext)("block:calculator","None"),value:void 0},{label:"#,###",value:","},{label:"#.###",value:"."}],i.Forms.Dropdown.bind(this.outcome,"separator",void 0)).label((0,i.pgettext)("block:calculator","Thousands separator")).on((function(e){t.thousands(!(!e.isFeatureEnabled||!e.value),e.isFeatureEnabled&&e.value||""),o.thousands(!(!e.isFeatureEnabled||!e.value),e.isFeatureEnabled&&e.value||"")}));this.editor.option({name:(0,i.pgettext)("block:calculator","Limits"),form:{title:(0,i.pgettext)("block:calculator","Limits"),controls:[t,o]},activated:(0,i.isNumber)(this.outcome.minimum)||(0,i.isNumber)(this.outcome.maximum)});var p=new i.Forms.Text("singleline",i.Forms.Text.bind(this.outcome,"prefix",void 0)).sanitize(!1).on((function(e){t.prefix(e.isFeatureEnabled&&e.value||""),o.prefix(e.isFeatureEnabled&&e.value||"")})),d=new i.Forms.Text("singleline",i.Forms.Text.bind(this.outcome,"prefixPlural",void 0)).indent(32).sanitize(!1).on((function(e){t.prefixPlural(e.isFeatureEnabled&&e.isObservable&&e.value||void 0),o.prefixPlural(e.isFeatureEnabled&&e.isObservable&&e.value||void 0)})).placeholder((0,i.pgettext)("block:calculator","Prefix when value is plural")).visible((0,i.isString)(this.outcome.prefixPlural)),b=new i.Forms.Checkbox((0,i.pgettext)("block:calculator","Specify different prefix for plural values"),(0,i.isString)(this.outcome.prefixPlural)).on((function(e){p.placeholder(e.isChecked&&(0,i.pgettext)("block:calculator","Prefix when value is singular")||""),d.visible(e.isChecked)})),f=this.editor.option({name:(0,i.pgettext)("block:calculator","Prefix"),form:{title:(0,i.pgettext)("block:calculator","Prefix"),controls:[p,b,d]},activated:(0,i.isString)(this.outcome.prefix)}),m=new i.Forms.Text("singleline",i.Forms.Text.bind(this.outcome,"suffix",void 0)).sanitize(!1).on((function(e){t.suffix(e.isFeatureEnabled&&e.value||""),o.suffix(e.isFeatureEnabled&&e.value||"")})),v=new i.Forms.Text("singleline",i.Forms.Text.bind(this.outcome,"suffixPlural",void 0)).indent(32).sanitize(!1).on((function(e){t.suffixPlural(e.isFeatureEnabled&&e.isObservable&&e.value||void 0),o.suffixPlural(e.isFeatureEnabled&&e.isObservable&&e.value||void 0)})).placeholder((0,i.pgettext)("block:calculator","Suffix when value is plural")).visible((0,i.isString)(this.outcome.suffixPlural)),g=new i.Forms.Checkbox((0,i.pgettext)("block:calculator","Specify different suffix for plural values"),(0,i.isString)(this.outcome.suffixPlural)).on((function(e){m.placeholder(e.isChecked&&(0,i.pgettext)("block:calculator","Suffix when value is singular")||""),v.visible(e.isChecked)})),x=this.editor.option({name:(0,i.pgettext)("block:calculator","Suffix"),form:{title:(0,i.pgettext)("block:calculator","Suffix"),controls:[m,g,v]},activated:(0,i.isString)(this.outcome.suffix)}),M=this.editor.option({name:(0,i.pgettext)("block:calculator","Signs"),form:{title:(0,i.pgettext)("block:calculator","Signs"),controls:[u,s,new i.Forms.Static((0,i.pgettext)("block:calculator","**Note:** These signs are used to format the number in de dataset. When the number is displayed in a runner, the appropriate user locale might be applied making it seem like changing these settings has no effect.")).markdown()]},activated:(0,i.isString)(this.outcome.separator)||(0,i.isString)(this.outcome.decimal),disabled:(this.outcome.digits||0)>0});this.editor.groups.options(),this.editor.visibility(),this.editor.alias(this.outcome),this.editor.exportable(this.outcome),this.preselect=function(t){var o=!1;!t.precision&&!t.digits||r.isActivated||(l.value=t.digits?-t.digits:t.precision,o=!0,r.activate()),!t.decimal&&!t.separator||M.isActivated||(u.value=t.decimal,s.value=t.decimal,o=!0,M.activate()),!t.prefix&&!t.prefixPlural||f.isActivated||(p.value=t.prefix||"",o=!0,t.prefixPlural&&(d.value=t.prefixPlural,b.check()),f.activate()),!t.suffix&&!t.suffixPlural||x.isActivated||(m.value=t.suffix||"",o=!0,t.suffixPlural&&(v.value=t.suffixPlural,g.check()),x.activate()),o&&(a.visible(!0),(0,i.scheduleTimeout)((function(){a.visible(!1)}),1e4)),e.preselect=void 0}},t.prototype.defineCondition=function(){var e=this,t=function(e,t){return(0,i.each)([{mode:"equal",label:(0,i.pgettext)("block:calculator","Calculation is equal to")},{mode:"not-equal",label:(0,i.pgettext)("block:calculator","Calculation is not equal to")},{mode:"below",label:(0,i.pgettext)("block:calculator","Calculation is lower than")},{mode:"above",label:(0,i.pgettext)("block:calculator","Calculation is higher than")},{mode:"between",label:(0,i.pgettext)("block:calculator","Calculation is between")},{mode:"not-between",label:(0,i.pgettext)("block:calculator","Calculation is not between")},{mode:"defined",label:(0,i.pgettext)("block:calculator","Calculation is valid")},{mode:"undefined",label:(0,i.pgettext)("block:calculator","Calculation is not valid")}],(function(o){e.template({condition:u.CalculatorCondition,label:o.label,autoOpen:"defined"!==o.mode&&"undefined"!==o.mode,props:{slot:t,mode:o.mode,value:0,to:"between"===o.mode||"not-between"===o.mode?0:void 0}})}))};this.slots.count>1?this.slots.each((function(o){o.label&&t(e.conditions.group(o.label),o)})):t(this.conditions,this.outcome)},l([i.definition,(0,i.affects)("#name")],t.prototype,"operations",void 0),l([i.assigned],t.prototype,"defineName",null),l([i.slots,i.renamed],t.prototype,"defineSlot",null),l([i.editor],t.prototype,"defineEditor",null),l([i.conditions],t.prototype,"defineCondition",null),o=l([(0,i.tripetto)({type:"node",legacyBlock:!0,identifier:"@tripetto/block-calculator",version:"4.0.3",icon:s.default,get label(){return(0,i.pgettext)("block:calculator","Calculator")},kind:"headless"})],t)}(i.NodeBlock);t.Calculator=p},5331:function(e,t,o){Object.defineProperty(t,"__esModule",{value:!0}),t.calculator=void 0;var a=o(9954),n=o(3208),l=o(4238);t.calculator=function(e,t,o){return void 0===t&&(t=(0,a.pgettext)("block:calculator","Initial value is the last outcome (ANS).")),{collection:e.operations,banner:o,title:(0,a.pgettext)("block:calculator","Operations"),icon:!0,allowAutoSorting:!1,allowCleanup:(0,a.pgettext)("block:calculator","Remove invalid operations"),placeholder:(0,a.pgettext)("block:calculator","Invalid operation"),allowVariables:!0,allowFormatting:!0,markdown:a.Markdown.MarkdownFeatures.Formatting|a.Markdown.MarkdownFeatures.InlineCode,showAliases:function(t){var o;return null===(o=e.block.slots.select(t.id,"dynamic"))||void 0===o?void 0:o.alias},onReposition:function(e){return e.refresh("name")},onResize:e instanceof n.Operation&&function(){return e.refresh("name")}||void 0,menu:function(){return(0,l.operatorMenu)(e,e instanceof n.Operation)},emptyMessage:{message:e instanceof n.Operation||!e.startBlank?"**"+t+"**\n\n"+(0,a.pgettext)("block:calculator","Click the + button to add an operation.")+"\n\n"+(0,a.pgettext)("block:calculator","Use **=** operation to set another initial value."):"**"+(0,a.pgettext)("block:calculator","Every calculation begins with an initial value.")+"**\n\n"+(0,a.pgettext)("block:calculator","Click the + button to specify that value.")+"\n\n"+(0,a.pgettext)("block:calculator","After that you can add more operations."),height:96}}}},4583:function(e,t,o){var a,n=this&&this.__extends||(a=function(e,t){return a=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var o in t)Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o])},a(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function o(){this.constructor=e}a(e,t),e.prototype=null===t?Object.create(t):(o.prototype=t.prototype,new o)}),l=this&&this.__decorate||function(e,t,o,a){var n,l=arguments.length,i=l<3?t:null===a?a=Object.getOwnPropertyDescriptor(t,o):a;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)i=Reflect.decorate(e,t,o,a);else for(var r=e.length-1;r>=0;r--)(n=e[r])&&(i=(l<3?n(i):l>3?n(t,o,i):n(t,o))||i);return l>3&&i&&Object.defineProperty(t,o,i),i};Object.defineProperty(t,"__esModule",{value:!0}),t.CalculatorCondition=void 0;var i=o(9954),r=o(4617),c=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.allowMarkdown=!0,t.mode="equal",t}return n(t,e),Object.defineProperty(t.prototype,"label",{get:function(){return""},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"name",{get:function(){var e=this.slot;if(e instanceof i.Slots.Numeric){var t=this.parse(e,this.value);switch(this.mode){case"between":return"".concat(t," ≤ @").concat(e.id," ≤ ").concat(this.parse(e,this.to));case"not-between":return"@".concat(e.id," < ").concat(t," ").concat((0,i.pgettext)("block:calculator","or")," @").concat(e.id," > ").concat(this.parse(e,this.to));case"defined":return"@".concat(e.id," ").concat((0,i.pgettext)("block:calculator","calculated"));case"undefined":return"@".concat(e.id," ").concat((0,i.pgettext)("block:calculator","not calculated"));case"not-equal":return"@".concat(e.id," ≠ ").concat(t);case"above":case"below":case"equal":return"@".concat(e.id," ").concat("above"===this.mode?">":"below"===this.mode?"<":"="," ").concat(t)}}return this.type.label},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"title",{get:function(){var e,t;return(null===(e=this.slot)||void 0===e?void 0:e.label)||(null===(t=this.node)||void 0===t?void 0:t.label)},enumerable:!1,configurable:!0}),t.prototype.parse=function(e,t){var o;return(0,i.isNumberFinite)(t)?e.toString(t,(function(e,t){return i.L10n.locale.number(e,t,!1)})):(0,i.isString)(t)&&t&&(null===(o=(0,i.lookupVariable)(this,t))||void 0===o?void 0:o.label)?"@".concat(t):"\\_\\_"},t.prototype.defineEditor=function(){var e=this;this.editor.form({title:(0,i.pgettext)("block:calculator","Compare mode"),controls:[new i.Forms.Radiobutton([{label:(0,i.pgettext)("block:calculator","Calculation is equal to"),value:"equal"},{label:(0,i.pgettext)("block:calculator","Calculation is not equal to"),value:"not-equal"},{label:(0,i.pgettext)("block:calculator","Calculation is lower than"),value:"below"},{label:(0,i.pgettext)("block:calculator","Calculation is higher than"),value:"above"},{label:(0,i.pgettext)("block:calculator","Calculation is between"),value:"between"},{label:(0,i.pgettext)("block:calculator","Calculation is not between"),value:"not-between"},{label:(0,i.pgettext)("block:calculator","Calculation is valid"),value:"defined"},{label:(0,i.pgettext)("block:calculator","Calculation is not valid"),value:"undefined"}],i.Forms.Radiobutton.bind(this,"mode","equal")).on((function(e){switch(o.visible("defined"!==e.value&&"undefined"!==e.value),a.visible("between"===e.value||"not-between"===e.value),e.value){case"equal":o.title=(0,i.pgettext)("block:calculator","If calculation equals");break;case"not-equal":o.title=(0,i.pgettext)("block:calculator","If calculation not equals");break;case"below":o.title=(0,i.pgettext)("block:calculator","If calculation is lower than");break;case"above":o.title=(0,i.pgettext)("block:calculator","If calculation is higher than");break;case"between":o.title=(0,i.pgettext)("block:calculator","If calculation is between");break;case"not-between":o.title=(0,i.pgettext)("block:calculator","If calculation is not between")}}))]});var t=function(t,o,a){var n,l=e[t],r=e.slot,c=new i.Forms.Numeric((0,i.isNumberFinite)(l)?l:0).label((0,i.pgettext)("block:calculator","Use fixed number")).precision((null==r?void 0:r.precision)||0).digits((null==r?void 0:r.digits)||0).decimalSign((null==r?void 0:r.decimal)||"").thousands(!!(null==r?void 0:r.separator),(null==r?void 0:r.separator)||"").prefix((null==r?void 0:r.prefix)||"").prefixPlural((null==r?void 0:r.prefixPlural)||void 0).suffix((null==r?void 0:r.suffix)||"").suffixPlural((null==r?void 0:r.suffixPlural)||void 0).min(null==r?void 0:r.minimum).max(null==r?void 0:r.maximum).autoFocus("value"===t).escape(e.editor.close).enter((function(){return("between"!==e.mode&&"not-between"!==e.mode||"to"===t)&&e.editor.close()})).on((function(o){o.isFormVisible&&o.isObservable&&(e[t]=o.value)})),u=(0,i.populateVariables)(e,(function(e){return e instanceof i.Slots.Number||e instanceof i.Slots.Numeric}),(0,i.isString)(l)?l:void 0,!0,null===(n=e.slot)||void 0===n?void 0:n.id),s=new i.Forms.Dropdown(u,(0,i.isString)(l)?l:"").label((0,i.pgettext)("block:calculator","Use value of")).width("full").on((function(o){o.isFormVisible&&o.isObservable&&(e[t]=o.value||"")}));return e.editor.form({title:o,controls:[new i.Forms.Radiobutton([{label:(0,i.pgettext)("block:calculator","Number"),value:"number"},{label:(0,i.pgettext)("block:calculator","Value"),value:"variable",disabled:0===u.length}],(0,i.isString)(l)?"variable":"number").on((function(e){c.visible("number"===e.value),s.visible("variable"===e.value),c.isObservable&&c.focus()})),c,s]}).visible(a)},o=t("value",(0,i.pgettext)("block:calculator","If calculation equals"),"defined"!==this.mode&&"undefined"!==this.mode),a=t("to",(0,i.pgettext)("block:calculator","And"),"between"===this.mode||"not-between"===this.mode)},l([i.definition,(0,i.affects)("#name")],t.prototype,"mode",void 0),l([i.definition,(0,i.affects)("#name")],t.prototype,"value",void 0),l([i.definition,(0,i.affects)("#name")],t.prototype,"to",void 0),l([i.editor],t.prototype,"defineEditor",null),l([(0,i.tripetto)({type:"condition",legacyBlock:!0,context:"@tripetto/block-calculator",identifier:"@tripetto/block-calculator",version:"4.0.3",icon:r.default,get label(){return(0,i.pgettext)("block:calculator","Verify calculation")}})],t)}(i.ConditionBlock);t.CalculatorCondition=c},427:function(e,t,o){Object.defineProperty(t,"__esModule",{value:!0}),t.angleUnitsControl=void 0;var a=o(9954);t.angleUnitsControl=function(e,t,o,n){void 0===n&&(n="angleUnits");var l=e[n];return t.form({title:(0,a.pgettext)("block:calculator","Units"),controls:[new a.Forms.Radiobutton([{label:(0,a.pgettext)("block:calculator","Degrees")+" (°)",value:"degrees"},{label:(0,a.pgettext)("block:calculator","Radians")+" (rad)",value:"radians"},{label:(0,a.pgettext)("block:calculator","Gradians")+" (ᵍ)",value:"gradians"}],"radians"===l||"gradians"===l?l:"degrees").on((function(t){(0,a.setAny)(e,n,t.value||"degrees"),o&&o(t.value||"degrees")}))]})}},4588:function(e,t,o){Object.defineProperty(t,"__esModule",{value:!0}),t.constantControl=t.getConstantIcon=t.getConstantLabel=void 0;var a=o(9954),n=o(7680);function l(e){switch(e){case"π":return"π ≈ ".concat(a.L10n.locale.number(3.14159,"auto"));case"e":return"e ≈ ".concat(a.L10n.locale.number(2.71828,"auto"));case"γ":return"γ ≈ ".concat(a.L10n.locale.number(.57722,"auto"));case"c":return"c = ".concat(a.L10n.locale.number(299792458)," m/s");case"random":return(0,a.pgettext)("block:calculator","Random value (0 to less than 1)");case"timestamp":return(0,a.pgettext)("block:calculator","UNIX time (seconds since Unix Epoch)");case"year":return(0,a.pgettext)("block:calculator","Year");case"month":return(0,a.pgettext)("block:calculator","Month (January = 1)");case"day":return(0,a.pgettext)("block:calculator","Day of month (1-31)");case"day-of-week":return(0,a.pgettext)("block:calculator","Day of week (Sunday = 0)");case"hour":return(0,a.pgettext)("block:calculator","Hour (0-23)");case"minute":return(0,a.pgettext)("block:calculator","Minute (0-59)");case"second":return(0,a.pgettext)("block:calculator","Second (0-59)");case"millisecond":return(0,a.pgettext)("block:calculator","Millisecond (0-999)");case"timezone":return(0,a.pgettext)("block:calculator","Timezone (in milliseconds)");case"branch":return(0,a.pgettext)("block:calculator","Branch number")}}t.getConstantLabel=l,t.getConstantIcon=function(e){switch(e){case"π":case"e":case"γ":case"c":return 59098;case"random":return 59015;case"timestamp":return 59274;case"year":case"month":case"day-of-week":return 59273;case"day":return 59272;case"hour":case"minute":case"second":case"millisecond":return 59624;case"timezone":return 59526;case"branch":return 59719}},t.constantControl=function(e,t,o,i,r){void 0===o&&(o="value"),void 0===i&&(i="form"),void 0===r&&(r=!0);var c=new a.Forms.Dropdown(n.CONSTANTS.map((function(e){return{label:l(e),value:e}})),(0,a.castToString)(e[o])).autoFocus(r).on((function(t){t.isFormVisible&&t.isObservable&&(0,a.setAny)(e,o,(0,n.castToConstant)(t.value))}));return"inline"===i?c.label((0,a.pgettext)("block:calculator","Use constant")):t.form({title:(0,a.pgettext)("block:calculator","Use constant"),controls:[c]})}},3146:function(e,t,o){Object.defineProperty(t,"__esModule",{value:!0}),t.explanationControl=void 0;var a=o(9954);t.explanationControl=function(e,t){return e.form({title:(0,a.pgettext)("block:calculator","Explanation"),controls:[new a.Forms.Static(t).markdown()]})}},4596:function(e,t,o){Object.defineProperty(t,"__esModule",{value:!0}),t.controls=void 0;var a=o(427),n=o(3146),l=o(5461),i=o(7066),r=o(3788),c=o(4588);t.controls={angles:a.angleUnitsControl,constant:c.constantControl,explanation:n.explanationControl,number:l.numberControl,type:i.typeControl,variable:r.variableControl}},5461:function(e,t,o){Object.defineProperty(t,"__esModule",{value:!0}),t.numberControl=void 0;var a=o(9954);t.numberControl=function(e,t,o,n,l,i){void 0===o&&(o="value"),void 0===n&&(n=!0),void 0===l&&(l=!0),void 0===i&&(i="form");var r=e[o],c=new a.Forms.Numeric((0,a.isNumberFinite)(r)?r:0).precision("auto").thousands(!1).autoFocus(l).on((function(t){t.isFormVisible&&t.isObservable&&(0,a.setAny)(e,o,t.value)}));return n&&(c.enter(t.close),c.escape(t.close)),"percentage"===o&&(c.suffix("%"),c.min(0)),["form"===i?t.form({title:(0,a.pgettext)("block:calculator","Use fixed number"),controls:[c]}):c.label((0,a.pgettext)("block:calculator","Use fixed number")),c]}},7066:function(e,t,o){var a=this&&this.__spreadArray||function(e,t,o){if(o||2===arguments.length)for(var a,n=0,l=t.length;n<l;n++)!a&&n in t||(a||(a=Array.prototype.slice.call(t,0,n)),a[n]=t[n]);return e.concat(a||Array.prototype.slice.call(t))};Object.defineProperty(t,"__esModule",{value:!0}),t.typeControl=void 0;var n=o(9954),l=o(4588),i=o(5461),r=o(3788),c=o(7680);t.typeControl=function(e,t,o,u,s,p,d,b,f,m){void 0===o&&(o=!0),void 0===u&&(u=!1),void 0===s&&(s=!0),void 0===p&&(p="value"),void 0===d&&(d=!0),void 0===b&&(b=!0);var v,g=e[p],x=f?"inline":"form",M=new n.Forms.Radiobutton(a(a(a(a([],o?[{label:e.isSubCalculation&&e.isFirst?(0,n.pgettext)("block:calculator","Last outcome *(%1 parent calculation)*","ANS"):e.isFirst&&!e.calculator.startBlank?(0,n.pgettext)("block:calculator","Initial value"):(0,n.pgettext)("block:calculator","Last outcome *(%1)*","ANS"),value:"ans",disabled:!e.allowANS,markdown:!0}]:[],!0),s?[{label:(0,n.pgettext)("block:calculator","Number"),value:"number"}]:[],!0),[{label:(0,n.pgettext)("block:calculator","Value"),value:"variable"}],!1),u?[{label:(0,n.pgettext)("block:calculator","Constant"),value:"constant"}]:[],!0),(0,n.isString)(g)?(0,c.isConstant)(g)?"constant":"variable":(0,n.isNumberFinite)(g)||!o?"number":"ans").on((function(t){h[0].visible("number"===t.value),w[0].visible("variable"===t.value),k.visible("constant"===t.value),"ans"===t.value&&(0,n.setAny)(e,p,void 0),m&&m(t.value||"number","variable"===t.value&&w[2].value&&(0,n.lookupVariable)(e.calculator.block,w[2].value)||void 0)}));"form"===x&&(v=t.form({title:(0,n.pgettext)("block:calculator","Input"),controls:[M]}));var h=(0,i.numberControl)(e,t,p,d,b,x),w=(0,r.variableControl)(e,t,p,x,b,void 0,m&&function(t){m(M.value||"number","variable"===M.value&&t&&(0,n.lookupVariable)(e.calculator.block,t)||void 0)}),k=(0,l.constantControl)(e,t,p,x,b).visible((0,c.isConstant)((0,n.castToString)(g)));return h[0].visible((0,n.isNumberFinite)(g)||!o&&!(0,n.isString)(g)),w[0].visible((0,n.isString)(g)),M.buttonDisabled("variable",0===w[1]),h[0]instanceof n.Forms.Control&&w[0]instanceof n.Forms.Control&&k instanceof n.Forms.Control&&(v=t.form({title:f,markdown:!0,controls:[M,h[0],w[0],k]})),[v,h[1]]}},3788:function(e,t,o){Object.defineProperty(t,"__esModule",{value:!0}),t.variableControl=void 0;var a=o(9954);t.variableControl=function(e,t,o,n,l,i,r){void 0===o&&(o="value"),void 0===n&&(n="form"),void 0===l&&(l=!0),void 0===i&&(i=function(e){return e instanceof a.Slots.Number||e instanceof a.Slots.Numeric});var c=e[o],u=(0,a.populateVariables)(e.calculator.block,i,(0,a.isString)(c)?c:void 0),s=new a.Forms.Dropdown(u,(0,a.isString)(c)?c:"").placeholder(0===u.length?(0,a.pgettext)("block:calculator","No usable values found..."):"").autoFocus(l).on((function(t){t.isFormVisible&&t.isObservable&&(0,a.setAny)(e,o,t.value||""),r&&r(t.value||"")}));return["form"===n?t.form({title:(0,a.pgettext)("block:calculator","Use value of"),controls:[s]}):s.label((0,a.pgettext)("block:calculator","Use value of")),u.length,s]}},4238:function(e,t,o){var a=this&&this.__assign||function(){return a=Object.assign||function(e){for(var t,o=1,a=arguments.length;o<a;o++)for(var n in t=arguments[o])Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n]);return e},a.apply(this,arguments)},n=this&&this.__spreadArray||function(e,t,o){if(o||2===arguments.length)for(var a,n=0,l=t.length;n<l;n++)!a&&n in t||(a||(a=Array.prototype.slice.call(t,0,n)),a[n]=t[n]);return e.concat(a||Array.prototype.slice.call(t))};Object.defineProperty(t,"__esModule",{value:!0}),t.operatorChangeMenu=t.operatorMenu=void 0;var l=o(9954),i=o(4533),r=o(7680),c=o(4588),u=o(4387),s=o(7200),p=o(4750),d=o(6322),b=o(6456),f=o(4908),m=o(2547),v=o(4948);t.operatorMenu=function(e,t){return void 0===t&&(t=!1),e.startBlank&&0===e.operations.count&&!t?g(e,!1)("+"):[new l.Components.MenuSubmenuWithImage(s.default,(0,l.pgettext)("block:calculator","Add"),(function(){return g(e,t)("+")})),new l.Components.MenuSubmenuWithImage(p.default,(0,l.pgettext)("block:calculator","Subtract"),(function(){return g(e,t)("-")})),new l.Components.MenuSubmenuWithImage(d.default,(0,l.pgettext)("block:calculator","Multiply"),(function(){return g(e,t)("*")})),new l.Components.MenuSubmenuWithImage(b.default,(0,l.pgettext)("block:calculator","Divide"),(function(){return g(e,t)("/")})),new l.Components.MenuSeparator,new l.Components.MenuSubmenuWithImage(u.default,(0,l.pgettext)("block:calculator","Equal"),(function(){return g(e,t)("=")}))]},t.operatorChangeMenu=function(e){return[new l.Components.MenuItemWithImage(s.default,(0,l.pgettext)("block:calculator","Add"),(function(){return e.operator="+"}),"+"===e.operator),new l.Components.MenuItemWithImage(p.default,(0,l.pgettext)("block:calculator","Subtract"),(function(){return e.operator="-"}),"-"===e.operator),new l.Components.MenuItemWithImage(d.default,(0,l.pgettext)("block:calculator","Multiply"),(function(){return e.operator="*"}),"*"===e.operator),new l.Components.MenuItemWithImage(b.default,(0,l.pgettext)("block:calculator","Divide"),(function(){return e.operator="/"}),"/"===e.operator),new l.Components.MenuSeparator,new l.Components.MenuItemWithImage(u.default,(0,l.pgettext)("block:calculator","Equal"),(function(){return e.operator="="}),"="===e.operator)]};var g=function(e,t){return function(o){var a=t||e.startBlank&&0===e.operations.count||"="!==o,i=[];i.push(new l.Components.MenuItemWithIcon(59254,(0,l.pgettext)("block:calculator","Number"),(function(){return e.operations.append().set({operator:o,opcode:"number",value:"/"===o?1:0,open:!0})})));var r=w(e,o);return i.push(new l.Components.MenuSubmenuWithIcon(59105,(0,l.pgettext)("block:calculator","Score"),x(e,o),!1,!1),new l.Components.MenuSubmenuWithIcon(59449,(0,l.pgettext)("block:calculator","Comparison"),(function(){var t=M(e,o);return n([new l.Components.MenuItemWithIcon(e.startBlank||e.operations.count>0?59239:59644,e.startBlank||e.operations.count>0?(0,l.pgettext)("block:calculator","Last outcome (%1)","ANS"):(0,l.pgettext)("block:calculator","Initial value"),(function(){return e.operations.append().set({operator:o,opcode:"equation",value:void 0,cona:0,conb:0,outa:1,outb:0,open:!0})}),0===e.operations.count&&e.startBlank),new l.Components.MenuSubmenuWithIcon(59273,(0,l.pgettext)("block:calculator","Date/time"),[new l.Components.MenuItem((0,l.pgettext)("block:calculator","Current date"),(function(){return e.operations.append().set({operator:o,opcode:"date",value:void 0,cona:l.DateTime.UTCToday,conb:void 0,outa:1,outb:0,open:!0})})),new l.Components.MenuItem((0,l.pgettext)("block:calculator","Current date + time"),(function(){return e.operations.append().set({operator:o,opcode:"datetime",value:void 0,cona:l.DateTime.UTC,conb:void 0,outa:1,outb:0,open:!0})}))])],t,!0)})),new l.Components.MenuSubmenuWithIcon(58927,(0,l.pgettext)("block:calculator","Function"),(function(){return h(o,e.operations,a)})),new l.Components.MenuItemWithIcon(59238,(0,l.pgettext)("block:calculator","Subcalculation"),(function(){return e.operations.append().set({operator:o,opcode:"calc",open:!0})}))),r.length>0&&(r[0]instanceof l.Components.MenuSeparator||i.push(new l.Components.MenuSeparator,new l.Components.MenuLabel((0,l.pgettext)("block:calculator","Blocks"))),i.push.apply(i,r)),i}},x=function(e,t){var o,a=[],n=function(e){if((null==e?void 0:e.id)!==o){var t=null==e?void 0:e.name;a.length>0&&a.push(new l.Components.MenuSeparator),t&&a.push(new l.Components.MenuLabel(t)),o=null==e?void 0:e.id}},i=function(o,i){var r,c,u,s,p=l.Collection.find(i),d=(0,l.getMetadata)(i.block,"calculator");if(p||d&&(null===(c=d[(null===(r=i.slot)||void 0===r?void 0:r.reference)||"*"]||d["*"])||void 0===c?void 0:c.scores)){n(o.block.node.section);var b=null===(s=null===(u=i.slot)||void 0===u?void 0:u.slots)||void 0===s?void 0:s.select("score","feature");if(b){var f=[];k(f,t,e.operations,{type:"slot",block:o.block,label:b.alias||(0,l.pgettext)("block:calculator","Existing score"),icon:o.icon||o.block.type.icon,id:b.id,reference:b.reference,slot:b},!1,!0),f.push(new l.Components.MenuItemWithIcon(59147,(0,l.pgettext)("block:calculator","New score"),(function(){return e.operations.append().set({operator:t,opcode:"score",value:i.id,open:!0})}))),a.push(new l.Components.MenuSubmenuWithImage(o.icon||o.block.type.icon,o.label,f))}else a.push(new l.Components.MenuItemWithImage(o.icon||o.block.type.icon,o.label,(function(){return e.operations.append().set({operator:t,opcode:"score",value:i.id,open:!0})})))}};return(0,l.each)((0,l.populateSlots)(e.block,{mode:"validated",pipes:"include-consumed-slots"}),(function(o){o.slots?(0,l.findFirst)(o.slots,(function(r){var c,u;if("pipe"===r.type){if(l.Collection.find(r)){var s=null===(u=null===(c=r.slot)||void 0===c?void 0:c.slots)||void 0===u?void 0:u.select("score","feature");if(n(o.block.node.section),s){var p=[];k(p,t,e.operations,{type:"slot",block:o.block,label:s.alias||(0,l.pgettext)("block:calculator","Existing score"),icon:o.icon||o.block.type.icon,id:s.id,reference:s.reference,slot:s},!1,!0),p.push(new l.Components.MenuItemWithIcon(59147,(0,l.pgettext)("block:calculator","New score"),(function(){return e.operations.append().set({operator:t,opcode:"score",value:r.id,open:!0})}))),a.push(new l.Components.MenuSubmenuWithImage(o.icon||o.block.type.icon,o.label,p))}else a.push(new l.Components.MenuItemWithImage(o.icon||o.block.type.icon,o.label,(function(){return e.operations.append().set({operator:t,opcode:"score",value:r.id,open:!0})})));return!0}}else if(r.id&&(r.slot instanceof l.Slots.String||r.slot instanceof l.Slots.Text))return i(o,r),!0;return!1})):o.id&&(o.slot instanceof l.Slots.String||o.slot instanceof l.Slots.Text)&&i(o,o)})),a},M=function(e,t){var o,a=[],n=function(e){if((null==e?void 0:e.id)!==o){var t=null==e?void 0:e.name;a.push(new l.Components.MenuSeparator),(t||1===a.length)&&a.push(new l.Components.MenuLabel(t||(0,l.pgettext)("block:calculator","Blocks"))),o=null==e?void 0:e.id}};return(0,l.each)((0,l.populateSlots)(e.block,{mode:"validated",pipes:"exclude"}),(function(o){if(o.slots){var i,r=[];(0,l.each)(o.slots,(function(o){if(o.id&&(o.slot instanceof l.Slots.String||o.slot instanceof l.Slots.Text||o.slot instanceof l.Slots.Boolean||o.slot instanceof l.Slots.Number||o.slot instanceof l.Slots.Numeric||o.slot instanceof l.Slots.Date)){var a=(o.slot instanceof l.Slots.String||o.slot instanceof l.Slots.Text)&&l.Collection.find(o);a&&a.sole||r.push(new l.Components.MenuItemWithIcon((0,l.getSlotIcon)(o.slot),o.label,i=function(){return e.operations.append().set(o.slot instanceof l.Slots.String||o.slot instanceof l.Slots.Text?{operator:t,opcode:"evaluate",value:o.id,cona:0,conb:0,outa:1,outb:0,open:!0}:o.slot instanceof l.Slots.Boolean?{operator:t,opcode:"boolean",value:o.id,outa:1,outb:0,open:!0}:o.slot instanceof l.Slots.Date?{operator:t,opcode:"date",value:o.id,cona:void 0,conb:void 0,outa:1,outb:0,open:!0}:{operator:t,opcode:"equation",value:o.id,cona:0,conb:0,outa:1,outb:0,open:!0})}))}})),r.length>0&&(n(o.block.node.section),a.push(1===r.length&&i?new l.Components.MenuItemWithImage(o.icon||o.block.type.icon,o.label,i):new l.Components.MenuSubmenuWithImage(o.icon||o.block.type.icon,o.label,r)))}else if(o.id&&(o.slot instanceof l.Slots.String||o.slot instanceof l.Slots.Text||o.slot instanceof l.Slots.Boolean||o.slot instanceof l.Slots.Number||o.slot instanceof l.Slots.Numeric||o.slot instanceof l.Slots.Date)){var c=(o.slot instanceof l.Slots.String||o.slot instanceof l.Slots.Text)&&l.Collection.find(o);c&&c.sole||(n(o.block.node.section),a.push(new l.Components.MenuItemWithImage(o.icon||o.block.type.icon,o.label,(function(){return e.operations.append().set(o.slot instanceof l.Slots.String||o.slot instanceof l.Slots.Text?{operator:t,opcode:"evaluate",value:o.id,cona:0,conb:0,outa:1,outb:0,open:!0}:o.slot instanceof l.Slots.Boolean?{operator:t,opcode:"boolean",value:o.id,outa:1,outb:0,open:!0}:o.slot instanceof l.Slots.Date?{operator:t,opcode:"date",value:o.id,cona:void 0,conb:void 0,outa:1,outb:0,open:!0}:{operator:t,opcode:"equation",value:o.id,cona:0,conb:0,outa:1,outb:0,open:!0})}))))}})),a},h=function(e,t,o,a,i){return void 0===i&&(i=!0),n([new l.Components.MenuSubmenuWithIcon(59122,(0,l.pgettext)("block:calculator","Limiting"),[new l.Components.MenuItem("min",(function(){return t.append().set({operator:e,opcode:"min",value:o?0:a,min:0,open:!0})})),new l.Components.MenuItem("max",(function(){return t.append().set({operator:e,opcode:"max",value:o?0:a,max:0,open:!0})})),new l.Components.MenuItem("clamp",(function(){return t.append().set({operator:e,opcode:"clamp",value:o?0:a,min:0,max:0,open:!0})}))]),new l.Components.MenuSubmenuWithImage(m.default,(0,l.pgettext)("block:calculator","Floating point"),[new l.Components.MenuItem("round",(function(){return t.append().set({operator:e,opcode:"round",value:o?0:a,open:o})})),new l.Components.MenuItem("floor",(function(){return t.append().set({operator:e,opcode:"floor",value:o?0:a,open:o})})),new l.Components.MenuItem("ceil",(function(){return t.append().set({operator:e,opcode:"ceil",value:o?0:a,open:o})})),new l.Components.MenuItem("trunc",(function(){return t.append().set({operator:e,opcode:"trunc",value:o?0:a,open:o})}))]),new l.Components.MenuSubmenuWithImage(f.default,(0,l.pgettext)("block:calculator","Exponentiation"),[new l.Components.MenuItem("x²",(function(){return t.append().set({operator:e,opcode:"square",value:o?0:a,open:o})})),new l.Components.MenuItem("√",(function(){return t.append().set({operator:e,opcode:"sqrt",value:o?0:a,open:o})})),new l.Components.MenuItem("pow",(function(){return t.append().set({operator:e,opcode:"pow",exponent:1,open:!0})})),new l.Components.MenuItem("exp",(function(){return t.append().set({operator:e,opcode:"exp",exponent:o?0:void 0,open:o})})),new l.Components.MenuItem("ln",(function(){return t.append().set({operator:e,opcode:"ln",value:o?0:a,open:o})})),new l.Components.MenuItem("log",(function(){return t.append().set({operator:e,opcode:"log",value:o?0:a,open:o})}))]),new l.Components.MenuSubmenuWithIcon(59778,(0,l.pgettext)("block:calculator","Trigonometry"),[new l.Components.MenuItem("sin",(function(){return t.append().set({operator:e,opcode:"sin",value:o?0:a,open:o})})),new l.Components.MenuItem("cos",(function(){return t.append().set({operator:e,opcode:"cos",value:o?0:a,open:o})})),new l.Components.MenuItem("tan",(function(){return t.append().set({operator:e,opcode:"tan",value:o?0:a,open:o})})),new l.Components.MenuSeparator,new l.Components.MenuLabel((0,l.pgettext)("block:calculator","Inverse")),new l.Components.MenuItem("sin⁻¹",(function(){return t.append().set({operator:e,opcode:"asin",value:o?0:a,open:o})})),new l.Components.MenuItem("cos⁻¹",(function(){return t.append().set({operator:e,opcode:"acos",value:o?0:a,open:o})})),new l.Components.MenuItem("tan⁻¹",(function(){return t.append().set({operator:e,opcode:"atan",value:o?0:a,open:o})})),new l.Components.MenuSeparator,new l.Components.MenuLabel((0,l.pgettext)("block:calculator","Hyperbolic")),new l.Components.MenuItem("sinh",(function(){return t.append().set({operator:e,opcode:"sinh",value:o?0:a,open:o})})),new l.Components.MenuItem("cosh",(function(){return t.append().set({operator:e,opcode:"cosh",value:o?0:a,open:o})})),new l.Components.MenuItem("tanh",(function(){return t.append().set({operator:e,opcode:"tanh",value:o?0:a,open:o})})),new l.Components.MenuSeparator,new l.Components.MenuLabel((0,l.pgettext)("block:calculator","Inverse hyperbolic")),new l.Components.MenuItem("sinh⁻¹",(function(){return t.append().set({operator:e,opcode:"asinh",value:o?0:a,open:o})})),new l.Components.MenuItem("cosh⁻¹",(function(){return t.append().set({operator:e,opcode:"acosh",value:o?0:a,open:o})})),new l.Components.MenuItem("tanh⁻¹",(function(){return t.append().set({operator:e,opcode:"atanh",value:o?0:a,open:o})}))]),new l.Components.MenuSubmenuWithIcon(59732,(0,l.pgettext)("block:calculator","Factorial"),[new l.Components.MenuItem("n!",(function(){return t.append().set({operator:e,opcode:"fact",value:o?0:a,open:o})})),new l.Components.MenuItem("gamma",(function(){return t.append().set({operator:e,opcode:"gamma",value:o?0:a,open:o})}))]),new l.Components.MenuSubmenuWithIcon(59704,(0,l.pgettext)("block:calculator","Miscellaneous"),[new l.Components.MenuItem("abs",(function(){return t.append().set({operator:e,opcode:"abs",value:o?0:a,open:o})})),new l.Components.MenuItem("sgn",(function(){return t.append().set({operator:e,opcode:"sgn",value:o?0:a,open:o})})),new l.Components.MenuItem("mod",(function(){return t.append().set({operator:e,opcode:"mod",value:o?0:a,divisor:1,open:!0})})),new l.Components.MenuItem("%",(function(){return t.append().set({operator:e,opcode:"percentage",value:o?0:a,percentage:0,open:!0})}))])],i?[new l.Components.MenuSubmenuWithIcon(59222,(0,l.pgettext)("block:calculator","Constants"),(function(){return r.CONSTANTS.map((function(o){return new l.Components.MenuItemWithIcon((0,c.getConstantIcon)(o),(0,c.getConstantLabel)(o),(function(){return t.append().set({operator:e,opcode:"number",value:o})}))}))}))]:[],!0)},w=function(e,t){var o,a=[],n=function(e){if((null==e?void 0:e.id)!==o){var t=null==e?void 0:e.name;(a.length>0||t)&&a.push(new l.Components.MenuSeparator),t&&a.push(new l.Components.MenuLabel(t)),o=null==e?void 0:e.id}};return(0,l.each)((0,l.populateSlots)(e.block,{mode:"validated",pipes:"include-consumed-slots"}),(function(o){if(o.slots){var i=[],r=!0,c=!1,u=!1;(0,l.findFirst)(o.slots,(function(a){var n,r,s;if("pipe"===a.type){var p=l.Collection.find(a);if(p){var d=null===(r=null===(n=a.slot)||void 0===n?void 0:n.slots)||void 0===r?void 0:r.select("score","feature");if(c=!0,d){var b=[];k(b,t,e.operations,{type:"slot",block:o.block,label:d.alias||(0,l.pgettext)("block:calculator","Existing score"),icon:o.icon||o.block.type.icon,id:d.id,reference:d.reference,slot:d},!1,!0),b.push(new l.Components.MenuItemWithIcon(59147,(0,l.pgettext)("block:calculator","New score"),(function(){return e.operations.append().set({operator:t,opcode:"score",value:a.id,open:!0})}))),i.push(new l.Components.MenuSubmenuWithIcon(59105,(0,l.pgettext)("block:calculator","Score"),b))}else i.push(new l.Components.MenuItemWithIcon(59105,(0,l.pgettext)("block:calculator","Score"),(function(){return e.operations.append().set({operator:t,opcode:"score",value:a.id,open:!0})})));if(p.origin&&p.sole)if(a.slot instanceof l.Slots.Number||a.slot instanceof l.Slots.Numeric)i.push(new l.Components.MenuItemWithIcon(59837,(0,l.pgettext)("block:calculator","Sum"),(function(){return e.operations.append().set({operator:t,opcode:"sum",value:a.id})})));else if(a.slot instanceof l.Slots.Boolean){var f=null===(s=a.slot.slots)||void 0===s?void 0:s.select("counter");f?(u=!0,k(i,t,e.operations,{type:"slot",block:o.block,label:f.label||(0,l.pgettext)("block:calculator","Counter"),icon:v.default,id:f.id,reference:f.reference,slot:f},!1,!0)):i.push(new l.Components.MenuItemWithIcon(59694,(0,l.pgettext)("block:calculator","Count"),(function(){return e.operations.append().set({operator:t,opcode:"count",value:a.id})})))}return!0}}return!1})),(0,l.each)(o.slots,(function(o){"slot"===o.type&&o.id&&o.slot&&("score"!==o.reference&&"counter"!==o.reference||"score"===o.reference&&!c||"counter"===o.reference&&!u)&&(r&&(r=!1,i.length>0&&i.push(new l.Components.MenuSeparator)),k(i,t,e.operations,o,!0))})),i.length>0&&(n(o.block.node.section),a.push(new l.Components.MenuSubmenuWithImage(o.icon||o.block.type.icon,o.label,i)))}else if(o.id&&o.slot){var s=[];k(s,t,e.operations,o,!1),s.length>0&&(n(o.block.node.section),a.push.apply(a,s))}})),a},k=function(e,t,o,a,r,c){var u,s,p,d,b,f,m;if(void 0===c&&(c=!1),a.slot instanceof l.Slots.String||a.slot instanceof l.Slots.Text){var v=l.Collection.find(a),g=(0,l.getMetadata)(a.block,"calculator"),x=function(){return o.append().set({operator:t,opcode:"score",value:a.id,open:!0})},M=(null==v?void 0:v.sole)&&g&&!0===(null===(u=g[a.slot.reference]||g["*"])||void 0===u?void 0:u.allowDefault)||!(null==v?void 0:v.sole)&&(!g||!1!==(null===(s=g[a.slot.reference]||g["*"])||void 0===s?void 0:s.allowDefault)),w=(null==v?void 0:v.sole)&&g&&!0===(null===(p=g[a.slot.reference]||g["*"])||void 0===p?void 0:p.allowCastToNumber)||!(null==v?void 0:v.sole)&&(!g||!1!==(null===(d=g[a.slot.reference]||g["*"])||void 0===d?void 0:d.allowCastToNumber)),I=null===(b=a.slot.slots)||void 0===b?void 0:b.select("score","feature"),S=!!(v||g&&(null===(f=g[a.slot.reference]||g["*"])||void 0===f?void 0:f.scores));if((null==v?void 0:v.sole)&&!w||g&&(null===(m=g[a.slot.reference]||g["*"])||void 0===m?void 0:m.scores)&&!M&&!w)I?(k(A=[],t,o,{type:"slot",block:a.block,label:I.alias||(0,l.pgettext)("block:calculator","Existing score"),icon:a.icon||a.block.type.icon,id:I.id,reference:I.reference,slot:I},!1,!0),A.push(new l.Components.MenuItemWithIcon(59147,(0,l.pgettext)("block:calculator","New score"),(function(){return o.append().set({operator:t,opcode:"score",value:a.id,open:!0})}))),e.push(r?new l.Components.MenuSubmenuWithIcon(59105,(0,l.pgettext)("block:calculator","Score"),A):new l.Components.MenuSubmenuWithImage(a.icon||a.block.type.icon,a.label,A))):e.push(r?new l.Components.MenuItemWithIcon(59105,a.label,x):new l.Components.MenuItemWithImage(a.icon||a.block.type.icon,a.label,x));else{var A,D=[];(S||I)&&(I?(k(A=[],t,o,{type:"slot",block:a.block,label:I.alias||(0,l.pgettext)("block:calculator","Existing score"),icon:a.icon||a.block.type.icon,id:I.id,reference:I.reference,slot:I},!1,!0),A.push(new l.Components.MenuItemWithIcon(59147,(0,l.pgettext)("block:calculator","New score"),x)),D.push(new l.Components.MenuSubmenuWithIcon(59105,(0,l.pgettext)("block:calculator","Score"),A))):D.push(new l.Components.MenuItemWithIcon(59105,(0,l.pgettext)("block:calculator","Score"),x))),M&&D.push(new l.Components.MenuItemWithIcon(59449,(0,l.pgettext)("block:calculator","Compare"),(function(){return o.append().set({operator:t,opcode:"evaluate",value:a.id,cona:0,conb:0,outa:1,outb:0,open:!0})})),new l.Components.MenuItemWithIcon(59771,(0,l.pgettext)("block:calculator","Character count"),(function(){return o.append().set({operator:t,opcode:"chars",value:a.id})})),new l.Components.MenuItemWithIcon(59771,(0,l.pgettext)("block:calculator","Word count"),(function(){return o.append().set({operator:t,opcode:"words",value:a.id})})),new l.Components.MenuItemWithIcon(59771,(0,l.pgettext)("block:calculator","Line count"),(function(){return o.append().set({operator:t,opcode:"lines",value:a.id})})),new l.Components.MenuItemWithIcon(59683,(0,l.pgettext)("block:calculator","Count occurrences"),(function(){return o.append().set({operator:t,opcode:"occurrences",value:a.id,open:!0})}))),w&&D.push(new l.Components.MenuItemWithIcon(59117,(0,l.pgettext)("block:calculator","Convert to number"),(function(){return o.append().set({operator:t,opcode:"cast",value:a.id})}))),D.length>0&&e.push(1===D.length?D[0]:new l.Components.MenuSubmenuWithImage(a.icon||a.block.type.icon,a.label,D))}}else if(!(a.slot instanceof l.Slots.Number||a.slot instanceof l.Slots.Numeric)||!c&&"score"===a.reference&&y(a))if(a.slot instanceof l.Slots.Boolean){var C=function(){return o.append().set({operator:t,opcode:"boolean",value:a.id,outa:1,outb:0,open:!0})};e.push(r?new l.Components.MenuItemWithIcon(59801,a.label,C):new l.Components.MenuItemWithImage(a.icon||a.block.type.icon,a.label,C))}else a.slot instanceof l.Slots.Date&&e.push(new l.Components.MenuSubmenuWithImage(a.icon||a.block.type.icon,a.label,n([new l.Components.MenuItemWithIcon(59449,(0,l.pgettext)("block:calculator","Compare"),(function(){return o.append().set({operator:t,opcode:"date",value:a.id,cona:void 0,conb:void 0,outa:1,outb:0,open:!0})})),new l.Components.MenuItemWithIcon(59390,(0,l.pgettext)("block:calculator","Age"),(function(){return o.append().set({operator:t,opcode:"age",value:a.id,ageAbs:!0})})),new l.Components.MenuSeparator,new l.Components.MenuLabel((0,l.pgettext)("block:calculator","Date related")),new l.Components.MenuItemWithIcon(59269,(0,l.pgettext)("block:calculator","Year"),(function(){return o.append().set({operator:t,opcode:"year",value:a.id})})),new l.Components.MenuItemWithIcon(59273,(0,l.pgettext)("block:calculator","Month (January = 1)"),(function(){return o.append().set({operator:t,opcode:"month",value:a.id})})),new l.Components.MenuItemWithIcon(59272,(0,l.pgettext)("block:calculator","Day of month (1-31)"),(function(){return o.append().set({operator:t,opcode:"day-of-month",value:a.id})})),new l.Components.MenuItemWithIcon(59274,(0,l.pgettext)("block:calculator","Day of week (Sunday = 0)"),(function(){return o.append().set({operator:t,opcode:"day-of-week",value:a.id})}))],a.slot.supportsTime?[new l.Components.MenuSeparator,new l.Components.MenuLabel((0,l.pgettext)("block:calculator","Time related")),new l.Components.MenuItemWithIcon(59624,(0,l.pgettext)("block:calculator","Hour (0-23)"),(function(){return o.append().set({operator:t,opcode:"hour",value:a.id})})),new l.Components.MenuItemWithIcon(59624,(0,l.pgettext)("block:calculator","Minute (0-59)"),(function(){return o.append().set({operator:t,opcode:"minute",value:a.id})})),new l.Components.MenuItemWithIcon(59624,(0,l.pgettext)("block:calculator","Second (0-59)"),(function(){return o.append().set({operator:t,opcode:"second",value:a.id})})),new l.Components.MenuItemWithIcon(59624,(0,l.pgettext)("block:calculator","Millisecond (0-999)"),(function(){return o.append().set({operator:t,opcode:"millisecond",value:a.id})}))]:[],!0)));else{var N=a.block instanceof i.Calculator?"calculator":a.slot.reference;D=function(){return n([new l.Components.MenuItemWithIcon("calcu