sparql-blockly 1.0.2 → 2.0.0

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.
@@ -1 +1 @@
1
- (()=>{var e={613:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Block=void 0;class r{constructor(e,t){this.values=new Map,this.fields=new Map,this.statements=new Map,this.type=e,t&&(t instanceof r?this.addValue("value",t):this.addField("value",t))}get xml(){const e=document.implementation.createDocument(null,"xml");return e.documentElement.appendChild(this.asDom(e)),e.documentElement}addValue(e,t){t&&this.values.set(e,t)}addField(e,t){this.fields.set(e,t)}addItems(e,t,r,s){const a=(e,t)=>{const a=r.call(s,t);return a.next=e,a};t.reduceRight(a,null)&&this.statements.set(e,t.reduceRight(a,null))}asDom(e){const t=e.createElement("block");t.setAttribute("type",`sparql11_${this.type}`);for(const[r,s]of this.values){const a=e.createElement("value");a.setAttribute("name",r);const i=s.asDom(e);a.appendChild(i),t.appendChild(a)}for(const[r,s]of this.fields){const a=e.createElement("field");a.setAttribute("name",r),a.textContent=s,t.appendChild(a)}for(const[r,s]of this.statements){const a=e.createElement("statement");a.setAttribute("name",r);const i=s.asDom(e);a.appendChild(i),t.appendChild(a)}if(this.next){const r=e.createElement("next"),s=this.next.asDom(e);r.appendChild(s),t.appendChild(r)}return t}}t.Block=r},27:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const s=r(456),a=r(619),i=r(613),n=r(554),o=r(635),p=r(386);class l{constructor(){this.prefixes=new Map}visit(e){switch(e.type){case"query":return this.query(e);case"update":return this.update(e)}}query(e){const t=new i.Block("query");return t.addItems("prologue",l.getPrologueItems(e),this.prologueItem,this),t.addValue("value",this[e.queryType.toLowerCase()](e)),e.values&&t.addValue("values",this.values(e.values)),t}select(e){const t=new i.Block("selectquery");return t.addValue("select",this.selectClause(e)),t.addValue("where",this.queryCommon(e)),t}construct(e){const t=l.normalisePatterns([{triples:e.template,type:"bgp"}]);if(l.isSimpleConstruct(e)){const r=new i.Block("simpleconstructquery");return r.addValue("modifiers",this.solutionModifiers(e)),r.addItems("where",[...t],this.triplesSameSubjectItem,this),e.from&&this.dataset(r,e.from),r}{const r=new i.Block("constructquery");return r.addValue("where",this.queryCommon(e)),r.addItems("template",[...t],this.triplesSameSubjectItem,this),r}}describe(e){const t=e.variables,r=new i.Block("describequery");return e.where&&r.addValue("where",this.queryCommon(e)),l.isWildcard(t)?r.addField("star","*"):r.addItems("subject",t,this.varOrIriItem,this),r}ask(e){return new i.Block("askquery",this.queryCommon(e))}update(e){const t=new i.Block("update");return t.addItems("prologue",l.getPrologueItems(e),this.prologueItem,this),t.addItems("items",e.updates,this.updateItem,this),t}updateItem(e){return"type"in e?new i.Block("updateitem",this.managementOperation(e)):new i.Block("updateitem",this.insertDeleteOperation(e))}managementOperation(e){switch(e.type){case"clear":case"drop":return this.clearDrop(e);case"add":case"move":case"copy":return this.addMoveCopy(e);case"load":return this.load(e);case"create":return this.create(e)}}insertDeleteOperation(e){switch(e.updateType){case"insert":case"delete":case"deletewhere":return this.insertDeleteWhere(e);case"insertdelete":return this.modify(e)}}clearDrop(e){const t=new i.Block("cleardrop");return t.addValue("graph",this.graphRefAll(e.graph)),t.addField("operator",e.type.toUpperCase()),e.silent&&t.addField("silent","SILENT"),t}addMoveCopy(e){const t=new i.Block("addmovecopy");return t.addValue("source",this.graphRefAll(e.source)),t.addValue("destination",this.graphRefAll(e.destination)),t.addField("operator",e.type.toUpperCase()),e.silent&&t.addField("silent","SILENT"),t}load(e){const t=new i.Block("load");return t.addValue("source",this.namedNode(e.source)),e.destination&&t.addValue("destination",this.graphRef(e.destination)),e.silent&&t.addField("silent","SILENT"),t}create(e){const t=new i.Block("create");return t.addValue("graph",this.graphRef(e.graph.name)),e.silent&&t.addField("silent","SILENT"),t}insertDeleteWhere(e){var t;const r=new i.Block("insertdeletewhere");return r.addValue("pattern",this.quadPattern(null!==(t=e.insert)&&void 0!==t?t:e.delete)),r.addField("operator",e.updateType.replace("insert","INSERT DATA").replace("deletewhere","DELETE WHERE").replace("delete","DELETE DATA")),r}quadPattern(e){const t=new i.Block("quadpattern");return t.addItems("items",[...l.normaliseQuads(e)],this.quadPatternItem,this),t}quadPatternItem(e){return"triplesSameSubject"===e.type?new i.Block("quadpatternitem",this.triplesSameSubject(e)):new i.Block("quadpatternitem",this.quadsNotTriples(e))}quadsNotTriples(e){const t=[];for(const[r,s]of l.toTriplesSameSubject(e.triples))t.push({type:"triplesSameSubject",subject:r,predicates:s});const r=new i.Block("quadsnottriples");return r.addValue("name",this.term(e.name)),r.addItems("triples",t,this.triplesSameSubjectItem,this),r}modify(e){const t=new i.Block("modify");return e.graph&&t.addValue("iri",this.namedNode(e.graph)),e.delete.length&&t.addValue("delete",this.quadPattern(e.delete)),e.insert.length&&t.addValue("insert",this.quadPattern(e.insert)),t.addValue("where",this.group(e.where)),e.using&&this.usings(t,e.using),t}graphRefAll(e){return e.name?this.graphRef(e.name):e.all?new i.Block("graphrefallall"):e.default?new i.Block("graphordefault"):new i.Block("graphrefallnamed")}graphRef(e){return new i.Block("graphref",this.namedNode(e))}usings(e,t){const r=(e,t)=>[e,t],s=t.named.map(r.bind(null,!0)),a=t.default.map(r.bind(null,!1));e.addItems("using",a.concat(s),this.using,this)}using([e,t]){return e?new i.Block("usingclause",this.named(t)):new i.Block("usingclause",this.namedNode(t))}pattern(e){if("queryType"in e)return this.subSelect(e);switch(e.type){case"group":return this.group(e.patterns);case"values":return this.values(e.values);default:return this[e.type](e)}}group(e){const t=l.normalisePatterns(e);return 0===t.size?new i.Block("groupgraphpattern"):c(t)?new i.Block("groupgraphpattern",this.pattern(h(t))):new i.Block("groupgraphpattern",this.groupGraphPatternSub([...t]))}groupGraphPatternSub(e){const t=new i.Block("groupgraphpatternsub");return t.addItems("items",e,this.groupSubItem,this),t}bind(e){return new i.Block("bind",this.expressionAsVar(e.expression,e.variable))}service(e){const t=new i.Block("servicegraphpattern");return t.addValue("iri",this.term(e.name)),t.addValue("patterns",this.group(e.patterns)),t.addField("silent",e.silent?"SILENT":""),t}optional(e){return new i.Block("optionalgraphpattern",this.group(e.patterns))}graph(e){const t=new i.Block("graphgraphpattern");return t.addValue("iri",this.term(e.name)),t.addValue("patterns",this.group(e.patterns)),t}filter(e){return"termType"in e.expression||"operator"in e.expression&&["||","&&","=","!=","<",">","<=",">=","in","notin","!","+","-","UMINUS","*","/"].includes(e.expression.operator)?new i.Block("filter",this.bracketted(e.expression)):new i.Block("filter",this.expression(e.expression))}minus(e){return new i.Block("minusgraphpattern",this.group(e.patterns))}union(e){const t=new i.Block("grouporuniongraphpattern");return t.addItems("items",e.patterns,this.groupItem,this),t}triplesSameSubject(e){const t=new i.Block("triplessamesubject");return t.addValue("subject",this.term(e.subject)),t.addItems("predicates",[...e.predicates.entries()],this.propertyList,this),t}subSelect(e){const t=new i.Block("subselect");return t.addValue("select",this.selectClause(e)),t.addValue("pattern",this.group(e.where)),e.values&&t.addValue("values",this.values(e.values)),t.addValue("modifiers",this.solutionModifiers(e)),t}solutionModifiers(e){if(e.group||e.having||e.order||"limit"in e||"offset"in e){const t=new i.Block("solutionmodifier");return"limit"in e&&t.addValue("limit",this.numeric(e.limit.toString())),"offset"in e&&t.addValue("offset",this.numeric(e.offset.toString())),e.group&&t.addItems("group",e.group,this.groupingItem,this),e.having&&t.addItems("having",e.having,this.havingItem,this),e.order&&t.addItems("order",e.order,this.orderItem,this),t}}collection(e){const t=new i.Block("collection");return t.addItems("items",e.items,this.graphNodeItem,this),t}verb(e){return"pathType"in e?this.path(e):e.value===s.RDF.type?new i.Block("a"):this.term(e)}path(e){switch(e.pathType){case"|":return this.pathAlternative(e);case"/":return this.pathSequence(e);case"^":return this.pathInverse(e);case"?":case"+":case"*":return this.pathModifier(e);case"!":return this.pathNegated(e)}}pathAlternative(e){const t=new i.Block("pathalternative");return t.addItems("items",e.items,this.pathAlternativeItem,this),t}pathSequence(e){const t=new i.Block("pathsequence");return t.addItems("items",e.items,this.pathSequenceItem,this),t}pathModifier(e){const t=new i.Block("pathwithmodifier"),r=h(e.items);return"pathType"in r&&["/","|","^"].includes(r.pathType)?t.addValue("value",this.brackettedPath(r)):t.addValue("value",this.verb(r)),t.addField("modifier",e.pathType),t}pathInverse(e){const t=new i.Block("inversepath"),r=h(e.items);return"pathType"in r&&["/","|"].includes(r.pathType)?t.addValue("value",this.brackettedPath(r)):t.addValue("value",this.verb(r)),t}pathNegated(e){const t=h(e.items);if(!("pathType"in t))return new i.Block("negatedpath",this.verb(t));switch(t.pathType){case"|":return new i.Block("negatedpath",this.pathOneInPropertySetAlternative(t));case"^":return new i.Block("negatedpath",this.inversePathOneInPropertySet(t))}}inversePathOneInPropertySet(e){return new i.Block("inversepathoneinpropertyset",this.verb(h(e.items)))}pathOneInPropertySetAlternative(e){const t=new i.Block("pathoneinpropertysetalternative");return t.addItems("items",e.items,this.pathOneInPropertySetAlternativeItem,this),t}brackettedPath(e){return new i.Block("bracketedpath",this.verb(e))}prefix([e,t]){return this.prefixes.set(t,e),e?this.prefixDecl(e,t):this.prefixDeclDefault(t)}prefixDecl(e,t){const r=new i.Block("prefixdecl",this.iriref(t));return r.addField("prefix",e),r}prefixDeclDefault(e){return new i.Block("prefixdecldefault",this.iriref(e))}base(e){return this.baseUri=e,new i.Block("base",this.iriref(e))}queryCommon(e){const t=new i.Block("querycommon");return t.addValue("pattern",this.group(e.where)),t.addValue("modifiers",this.solutionModifiers(e)),e.from&&this.dataset(t,e.from),t}dataset(e,t){const r=(e,t)=>[e,t],s=t.named.map(r.bind(null,!0)),a=t.default.map(r.bind(null,!1));e.addItems("datasets",a.concat(s),this.from,this)}from([e,t]){return e?new i.Block("datasetclause",this.named(t)):new i.Block("datasetclause",this.namedNode(t))}named(e){return new i.Block("namedgraphclause",this.namedNode(e))}selectClause(e){const t=new i.Block("selectclause");e.distinct&&t.addField("distinctOrReduced","DISTINCT"),e.reduced&&t.addField("distinctOrReduced","REDUCED");const r=e.variables;return l.isWildcard(r)?t.addField("star","*"):t.addItems("vars",r,this.varOrExpressionAsVarItem,this),t}values(e){const t=e.reduce(((e,t)=>Object.keys(t)),[]).map(u),r=e.map(Object.values);return c(t)?new i.Block("inlinedata",this.inlineDataOneVar(h(t),r.flat())):new i.Block("inlinedata",this.inlineDataFull(t,r))}inlineDataOneVar(e,t){const r=new i.Block("inlinedataonevar");return r.addValue("variable",this.variable(e)),r.addItems("values",t.flat(),this.dataBlockValueItem,this),r}inlineDataFull(e,t){const r=new i.Block("inlinedatafull");return r.addItems("variables",e,this.variableItem,this),r.addItems("values",t,this.dataBlockValuesItem,this),r}expressionAsVar(e,t){const r=new i.Block("expressionasvar",this.expression(e));return r.addValue("name",this.variable(t)),r}descending(e){const t=new i.Block("ordercondition",this.bracketted(e));return t.addField("operator","DESC"),t}expression(e){return"type"in e?this[e.type](e):this.term(e)}operation(e){switch(e.operator){case"||":case"&&":case"=":case"!=":case"<":case">":case"<=":case">=":case"+":case"-":case"*":case"/":case"!":case"UMINUS":return this.unibinary(e);case"notin":case"in":return this.in(e);case"bound":return this.bound(e);case"exists":case"notexists":return this.exists(e);case"concat":case"coalesce":return this.builtInCallN(e);default:return this[`builtInCall${e.args.length}`](e)}}functionCall(e){const t=new i.Block("iriorfunction");return t.addValue("iri",this.namedNode(e.function)),e.distinct&&t.addField("distinct","DISTINCT"),t.addItems("args",e.args,this.expressionListItem,this),t}aggregate(e){switch(e.aggregation){case"sum":case"min":case"max":case"avg":case"sample":return this.aggregateCommon(e);default:return this[e.aggregation](e)}}exists(e){const t=new i.Block("exists"),r=h(e.args);return"group"===r.type?t.addValue("value",this.pattern(r)):t.addValue("value",this.group(e.args)),t.addField("operator",e.operator.toUpperCase().replace("NOTEXISTS","NOT EXISTS")),t}builtInCall0(e){const t=new i.Block("builtincall0");return t.addField("operator",e.operator.toUpperCase()),t}builtInCall1(e){const t=new i.Block("builtincall1");return t.addValue("arg1",this.expression(h(e.args))),t.addField("operator",e.operator.toUpperCase()),t}builtInCall2(e){const t=new i.Block("builtincall2");return t.addValue("arg1",this.expression(e.args[0])),t.addValue("arg2",this.expression(e.args[1])),t.addField("operator",e.operator.toUpperCase()),t}builtInCall3(e){const t=new i.Block("builtincall3");return t.addValue("arg1",this.expression(e.args[0])),t.addValue("arg2",this.expression(e.args[1])),t.addValue("arg3",this.expression(e.args[2])),t.addField("operator",e.operator.toUpperCase()),t}builtInCall4(e){const t=new i.Block("builtincall4");return t.addValue("arg1",this.expression(e.args[0])),t.addValue("arg2",this.expression(e.args[1])),t.addValue("arg3",this.expression(e.args[2])),t.addValue("arg4",this.expression(e.args[3])),t.addField("operator",e.operator.toUpperCase()),t}builtInCallN(e){const t=new i.Block("builtincalln");return t.addField("operator",e.operator.toUpperCase()),t.addItems("args",e.args,this.expressionListItem,this),t}bound(e){return new i.Block("bound",this.expression(h(e.args)))}bracketted(e){return new i.Block("brackettedexpression",this.expression(e))}unibinary(e,t=l.hierarchy){const[r,s]=d(t);if(s.operators.includes(e.operator)){const t=new i.Block(r);return t.addValue("left",this.bracketArgument(e.args[0],s)),e.args.length>1&&t.addValue("right",this.bracketArgument(e.args[1],s)),["&&","||"].includes(e.operator)||t.addField("operator",e.operator),t}return this.unibinary(e,s.higher)}bracketArgument(e,t=l.hierarchy.unaryexpression){if("operator"in e){if(t.operators.includes(e.operator))return this.bracketted(e);if(t.higher){const[,r]=d(t.higher);return this.bracketArgument(e,r)}}return this.expression(e)}in(e){const t=new i.Block("relationalexpressionin");return t.addValue("left",this.expression(e.args[0])),t.addField("operator",e.operator.toUpperCase().replace("NOTIN","NOT IN")),t.addItems("right",e.args[1],this.expressionListItem,this),t}group_concat(e){const t=new i.Block("group_concat");return t.addValue("arg1",this.expression(e.expression)),t.addValue("separator",this.string(e.separator)),e.distinct&&t.addField("distinct","DISTINCT"),t}count(e){const t=new i.Block("count");return e.distinct&&t.addField("distinct","DISTINCT"),e.expression instanceof a.Wildcard?t.addField("star","*"):t.addValue("arg1",this.expression(e.expression)),t}aggregateCommon(e){const t=new i.Block("aggregate");return t.addValue("arg1",this.expression(e.expression)),t.addField("operator",e.aggregation.toUpperCase()),e.distinct&&t.addField("distinct","DISTINCT"),t}term(e){return e.value===s.RDF.nil?new i.Block("nil"):this[(t=e.termType,t.charAt(0).toLowerCase()+t.substr(1))](e);var t}namedNode(e){for(const[t,r]of this.prefixes)if(e.value.startsWith(t)){const s=e.value.replace(t,"");return r?s?this.prefixedNamePrefixLocalName(r,s):this.prefixedNamePrefix(r):s?this.prefixedNameLocalName(s):this.prefixedName()}if(this.baseUri&&e.value.startsWith(this.baseUri)){const t=e.value.replace(this.baseUri,"");return t?this.iriref(t):new i.Block("irirefdefault")}return this.iriref(e.value)}quad(e){const t=new i.Block("embtp");return t.addValue("subject",this.term(e.subject)),t.addValue("predicate",this.verb(e.predicate)),t.addValue("object",this.term(e.object)),t}prefixedName(){return new i.Block("prefixedname")}prefixedNameLocalName(e){const t=new i.Block("prefixednamelocalname");return t.addField("localName",e),t}prefixedNamePrefix(e){const t=new i.Block("prefixednameprefix");return t.addField("prefix",e),t}prefixedNamePrefixLocalName(e,t){const r=new i.Block("prefixednameprefixlocalname");return r.addField("localName",t),r.addField("prefix",e),r}iriref(e){return new i.Block("iriref",e)}blankNode(e){return new i.Block("blanknodelabel",e.value)}literal(e){switch(e.datatype.value){case s.XSD.string:return this.string(e.value);case s.XSD.integer:case s.XSD.decimal:case s.XSD.double:return this.numeric(e.value);case s.XSD.boolean:return this.boolean(e);case s.RDF.langString:return this.langString(e);default:return this.typedLiteral(e)}}string(e){return new i.Block("string",e)}langString(e){const t=new i.Block("langstring",this.string(e.value));return t.addField("language",e.language),t}numeric(e){return new i.Block("numericliteral",e)}boolean(e){return new i.Block("booleanliteral",e.value.toUpperCase())}typedLiteral(e){const t=new i.Block("typedliteral",this.string(e.value));return t.addValue("datatype",this.namedNode(e.datatype)),t}variable(e){return new i.Block("var1",e.value)}dataBlockValueItem(e){return e?new i.Block("datablockvalueitem",this.term(e)):new i.Block("datablockvalueitem",new i.Block("undef"))}dataBlockValuesItem(e){const t=new i.Block("datablockvaluesitem");return t.addItems("items",e,this.dataBlockValueItem,this),t}prologueItem(e){return e instanceof Array?new i.Block("prologueitem",this.prefix(e)):new i.Block("prologueitem",this.base(e))}varOrExpressionAsVarItem(e){return"expression"in e?new i.Block("varorexpressionasvaritem",this.expressionAsVar(e.expression,e.variable)):new i.Block("varorexpressionasvaritem",this.variable(e))}groupItem(e){return"group"===e.type?new i.Block("groupgraphpatternitem",this.pattern(e)):new i.Block("groupgraphpatternitem",this.group([e]))}variableItem(e){return new i.Block("varitem",this.variable(e))}groupSubItem(e){return new i.Block("groupgraphpatternsubitem",this.pattern(e))}propertyList([e,t]){const r=new i.Block("propertylistnotempty");return r.addValue("predicate",this.verb(e)),r.addItems("objects",[...t],this.objectListItem,this),r}objectListItem(e){return new i.Block("objectlistitem",this.term(e))}expressionListItem(e){return new i.Block("expressionlistitem",this.expression(e))}pathAlternativeItem(e){return new i.Block("pathalternativeitem",this.verb(e))}pathSequenceItem(e){return"pathType"in e&&"|"===e.pathType?new i.Block("pathsequencitem",this.brackettedPath(e)):new i.Block("pathsequencitem",this.verb(e))}pathOneInPropertySetAlternativeItem(e){return"pathType"in e&&"^"===e.pathType?new i.Block("pathoneinpropertysetalternativeitem",this.inversePathOneInPropertySet(e)):new i.Block("pathoneinpropertysetalternativeitem",this.verb(e))}varOrIriItem(e){return new i.Block("varoririitem",this.term(e))}triplesSameSubjectItem(e){return new i.Block("triplessamesubjectitem",this.triplesSameSubject(e))}groupingItem(e){return"variable"in e?new i.Block("groupconditionitem",this.expressionAsVar(e.expression,e.variable)):new i.Block("groupconditionitem",this.expression(e.expression))}havingItem(e){return"termType"in e?new i.Block("havingconditionitem",this.bracketted(e)):new i.Block("havingconditionitem",this.bracketArgument(e))}orderItem(e){return e.descending?new i.Block("orderconditionitem",this.descending(e.expression)):"termType"in e.expression?"Variable"===e.expression.termType?new i.Block("orderconditionitem",this.term(e.expression)):new i.Block("orderconditionitem",this.bracketted(e.expression)):new i.Block("orderconditionitem",this.bracketArgument(e.expression))}graphNodeItem(e){return new i.Block("graphnodeitem",this.term(e))}static isSimpleConstruct(e){if(c(e.where)){const t=h(e.where);if("bgp"===t.type)return JSON.stringify(e.template)===JSON.stringify(t.triples)}}static getPrologueItems(e){const t=[];return e.base&&t.push(e.base),Object.entries(e.prefixes).sort(((e,t)=>e[1].length-t[1].length)).forEach((e=>t.push(e))),t}static isWildcard(e){return"termType"in e[0]&&"Wildcard"==e[0].termType}static toTriplesSameSubject(e){return e.reduce(((e,t)=>{e.has(t.subject)||e.set(t.subject,new n.StringifiedMap);const r=e.get(t.subject);return r.has(t.predicate)||r.set(t.predicate,new o),r.get(t.predicate).add(t.object),e}),new p)}static normalisePatterns(e){return Array.from(e).reduce(((e,t)=>{if("bgp"===t.type){const r=this.toTriplesSameSubject(t.triples);for(const[t,s]of r)e.add({type:"triplesSameSubject",subject:t,predicates:s})}else e.add(t);return e}),new Set)}static normaliseQuads(e){return e.reduce(((e,t)=>{if("bgp"===t.type){const r=this.toTriplesSameSubject(t.triples);for(const[t,s]of r)e.add({type:"triplesSameSubject",subject:t,predicates:s})}else e.add(t);return e}),new Set)}}function u(e){return{value:e.replace("?",""),termType:null,equals:null}}function c(e){return e instanceof Array?1===e.length:1===e.size}function h(e){return e instanceof Array?e[0]:e.values().next().value}function d(e){return h(Object.entries(e))}t.default=l,l.hierarchy={unaryexpression:{operators:["UMINUS","!"],higher:{multiplicativeexpression:{operators:["*","/"],higher:{additiveexpression:{operators:["+","-"],higher:{relationalexpression:{operators:["=","!=","<",">","<=",">="],higher:{conditionalandexpression:{operators:["&&"],higher:{conditionalorexpression:{operators:["||"]}}}}}}}}}}}}},427:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const s=r(456),a=r(564);function i(e){return[e,s.Order.None]}function n(e,...t){return t.filter(Boolean).join(e)}function o(e,...t){return t.filter((e=>e instanceof Array?e[0]:e)).map((e=>e instanceof Array?e[1]:e)).join(e)}function p(e,t){return i(`${e}:${t}`)}function l(e=""){return i(`<${e}>`)}class u extends a.Generator{constructor(){super("SPARQL 1.1"),this.INDENT="",this.addCodeGeneratorProperties()}addCodeGeneratorProperties(){const e="sparql",t=e=>t=>this[e](t);Object.getOwnPropertyNames(u.prototype).filter((t=>t.startsWith(e))).map((t=>{return[(r=t,r.replace(e,"sparql11_").toLowerCase()),t];var r})).map((([e,r])=>[e,t(r)])).forEach((([e,t])=>this[e]=t))}scrub_(e,t,r){if(!r){const r=e.getNextBlock();r&&(t+=this.blockToCode(r))}return t}sparqlQuery(e){return n("\n\n",this.statementToCode(e,"prologue"),n("\n",this.valueToCode(e,"value"),this.valueToCode(e,"values")))}sparqlSelectQuery(e){return i(n("\n",this.valueToCode(e,"select"),this.valueToCode(e,"where")))}sparqlDescribeQuery(e){const t=e.getFieldValue("star"),r=this.statementToCode(e,"subject"),s=this.valueToCode(e,"where");return i(n("\n",n(" ","DESCRIBE",t,r),s))}sparqlAskQuery(e){return i(n("\n","ASK",this.valueToCode(e,"value")))}sparqlSimpleConstructquery(e){const t=this.statementToCode(e,"datasets"),r=this.statementToCode(e,"where"),s=this.valueToCode(e,"modifiers");return i(n("\n","CONSTRUCT",t,n("\n","WHERE {",this.indent(r),"}"),s))}sparqlConstructQuery(e){const t=this.statementToCode(e,"template"),r=this.valueToCode(e,"where");return i(n("\n",n("\n","CONSTRUCT {",this.indent(t),"}"),r))}sparqlUpdate(e){return n("\n\n",this.statementToCode(e,"prologue"),this.statementToCode(e,"items"))}sparqlLoad(e){const t=this.valueToCode(e,"source"),r=e.getFieldValue("silent"),s=this.valueToCode(e,"destination");return i(o(" ",[!0,n(" ","LOAD",r,t)],[s,n(" ","INTO",s)]))}sparqlGraphRef(e){return i(n(" ","GRAPH",this.valueToCode(e,"value")))}sparqlCreate(e){return i(n(" ","CREATE",e.getFieldValue("silent"),this.valueToCode(e,"graph")))}sparqlAddMoveCopy(e){return i(n(" ",e.getFieldValue("operator"),e.getFieldValue("silent"),this.valueToCode(e,"source"),"TO",this.valueToCode(e,"destination")))}sparqlClearDrop(e){return i(n(" ",e.getFieldValue("operator"),e.getFieldValue("silent"),this.valueToCode(e,"graph")))}sparqlQuadPattern(e){const t=this.statementToCode(e,"items");return i(n("\n","{",this.indent(t),"}"))}sparqlInsertDeleteWhere(e){return i(n(" ",e.getFieldValue("operator"),this.valueToCode(e,"pattern")))}sparqlModify(e){const t=this.valueToCode(e,"iri"),r=this.valueToCode(e,"delete"),s=this.valueToCode(e,"insert"),a=this.statementToCode(e,"using"),p=this.valueToCode(e,"where");return i(o("\n",[t,n(" ","WITH",t)],[r,n(" ","DELETE",r)],[s,n(" ","INSERT",s)],a,n(" ","WHERE",p)))}sparqlUsingClause(e){const t=n(" ","USING",this.valueToCode(e,"value"));return this.generateNext(e,t,"\n")}sparqlGraphOrDefault(){return i("DEFAULT")}sparqlQuadsNotTriples(e){const t=this.valueToCode(e,"name"),r=this.statementToCode(e,"triples");return i(n(" ","GRAPH",t,n("\n","{",this.indent(r),"}")))}sparqlSelectClause(e){return i(n(" ","SELECT",e.getFieldValue("distinctOrReduced"),e.getFieldValue("star"),this.statementToCode(e,"vars")))}sparqlExpressionAsVar(e){return i(`(${this.valueToCode(e,"value")} AS ${this.valueToCode(e,"name")})`)}sparqlQueryCommon(e){const t=this.statementToCode(e,"datasets"),r=this.valueToCode(e,"pattern"),s=this.valueToCode(e,"modifiers");return i(n("\n",t,n(" ","WHERE",r),s))}sparqlGroupGraphPattern(e){const t=this.valueToCode(e,"value");return i(n("\n","{",this.indent(t),"}"))}sparqlSubSelect(e){const t=this.valueToCode(e,"select"),r=this.valueToCode(e,"pattern"),s=this.valueToCode(e,"values");return i(n("\n",t,`WHERE ${r}`,this.valueToCode(e,"modifiers"),s))}sparqlTriplesSameSubject(e){var t;const r=this.valueToCode(e,"subject"),s=this.statementToCode(e,"predicates");let a;return a=(null===(t=e.getInputTargetBlock("predicates"))||void 0===t?void 0:t.getNextBlock())?n("\n",r,this.indent(s)):n(" ",r,s),i(a)}sparqlPropertyListNotEmpty(e){const t=n(" ",this.valueToCode(e,"predicate"),this.statementToCode(e,"objects"));return this.generateNext(e,t," ;\n")}sparqlGroupGraphPatternSub(e){return i(this.statementToCode(e,"items"))}sparqlBlankNodePropertyList(e){const t=e.getInputTargetBlock("predicates"),r=this.blockToCode(t);let s;return s=t&&t.getNextBlock()?n("\n","[",this.indent(r),"]"):n(" ","[",r,"]"),i(s)}sparqlCollection(e){return i(n("","(",this.statementToCode(e,"items"),")"))}sparqlOptionalGraphPattern(e){return i(n(" ","OPTIONAL",this.valueToCode(e,"value")))}sparqlGraphGraphPattern(e){return i(n(" ","GRAPH",this.valueToCode(e,"iri"),this.valueToCode(e,"patterns")))}sparqlServiceGraphPattern(e){const t=this.valueToCode(e,"iri");return i(n(" ","SERVICE",e.getFieldValue("silent"),t,this.valueToCode(e,"patterns")))}sparqlMinusGraphPattern(e){return i(n(" ","MINUS",this.valueToCode(e,"value")))}sparqlFilter(e){return i(n(" ","FILTER",this.valueToCode(e,"value")))}sparqlBind(e){return i(n(" ","BIND",this.valueToCode(e,"value")))}sparqlGroupOrUnionGraphPattern(e){return i(n("",...this.statementToCode(e,"items")))}sparqlPrefixDecl(e){return i(`PREFIX ${e.getFieldValue("prefix")}: ${this.valueToCode(e,"value")}`)}sparqlPrefixDeclDefault(e){return i(`PREFIX : ${this.valueToCode(e,"value")}`)}sparqlBase(e){return i(`BASE ${this.valueToCode(e,"value")}`)}sparqlNamedGraphClause(e){return i(`NAMED ${this.valueToCode(e,"value")}`)}sparqlSolutionModifier(e){const t=this.statementToCode(e,"group"),r=this.statementToCode(e,"having"),s=this.statementToCode(e,"order"),a=this.valueToCode(e,"limit"),n=this.valueToCode(e,"offset");return i(o("\n",[t,`GROUP BY ${t}`],[r,`HAVING ${r}`],[s,`ORDER BY ${s}`],[a,`LIMIT ${a}`],[n,`OFFSET ${n}`]))}sparqlOrdercondition(e){return i(n("",e.getFieldValue("operator"),this.valueToCode(e,"value")))}sparqlInlineData(e){return i(n(" ","VALUES",this.valueToCode(e,"value")))}sparqlInlineDataOneVar(e){return i(n(" ",this.valueToCode(e,"variable"),n(" ","{",this.statementToCode(e,"values")," }")))}sparqlInlineDataFull(e){const t=this.statementToCode(e,"variables"),r=this.statementToCode(e,"values");return i(n(" ",n("","(",t,")"),n("\n","{",this.indent(r),"}")))}sparqlA(){return i("a")}sparqlNegatedPath(e){return i(n("","!",this.valueToCode(e,"value")))}sparqlBracketedPath(e){return i(n("","(",this.valueToCode(e,"value"),")"))}sparqlPathWithModifier(e){const t=e.getFieldValue("modifier");return i(n("",this.valueToCode(e,"value"),t))}sparqlInversePath(e){return i(n("","^",this.valueToCode(e,"value")))}sparqlPathAlternative(e){return i(this.statementToCode(e,"items"))}sparqlPathSequence(e){return i(this.statementToCode(e,"items"))}sparqlInversePathOneInPropertySet(e){return i(n("","^",this.valueToCode(e,"value")))}sparqlPathOneInPropertySetAlternative(e){return i(n("","(",this.statementToCode(e,"items"),")"))}sparqlIrirefDefault(){return l()}sparqlIriref(e){return l(e.getFieldValue("value"))}sparqlPrefixedName(){return p("","")}sparqlPrefixedNamePrefix(e){return p(e.getFieldValue("prefix"),"")}sparqlPrefixedNameLocalName(e){return p("",e.getFieldValue("localName"))}sparqlPrefixedNamePrefixLocalName(e){return p(e.getFieldValue("prefix"),e.getFieldValue("localName"))}sparqlString(e){let t=e.getFieldValue("value"),r="'";return t.indexOf(r)>-1&&(r='"',t.indexOf('"')>-1&&(t=t.replace(/"/g,'\\"'))),t.indexOf("\n")>-1&&(r=[...Array(3)].map((()=>r)).join("")),i(`${r}${t}${r}`)}sparqlTypedLiteral(e){return i(`${this.valueToCode(e,"value")}^^${this.valueToCode(e,"datatype")}`)}sparqlLangString(e){return i(`${this.valueToCode(e,"value")}@${e.getFieldValue("language")}`)}sparqlNumericLiteral(e){return i(e.getFieldValue("value").toString())}sparqlBooleanLiteral(e){return i(("TRUE"===e.getFieldValue("value")).toString())}sparqlVar1(e){return this.var(e,"?")}sparqlVar2(e){return this.var(e,"$")}sparqlUndef(){return i("UNDEF")}sparqlNil(){return i("()")}sparqlAnon(){return i("[]")}sparqlBlankNodeLabel(e){return i(`_:${e.getFieldValue("value")}`)}sparqlGraphRefAllNamed(){return i("NAMED")}sparqlGraphRefAllAll(){return i("ALL")}sparqlBrackettedExpression(e){return i(`(${this.valueToCode(e,"value")})`)}sparqlBuiltinCall1(e){return i(`${e.getFieldValue("operator")}(${this.valueToCode(e,"arg1")})`)}sparqlBuiltinCall0(e){return i(`${e.getFieldValue("operator")}()`)}sparqlBuiltinCall2(e){return i(`${e.getFieldValue("operator")}(${this.valueToCode(e,"arg1")}, ${this.valueToCode(e,"arg2")})`)}sparqlBuiltinCall4(e){return i(`${e.getFieldValue("operator")}(${this.valueToCode(e,"arg1")}, ${this.valueToCode(e,"arg2")}, ${this.valueToCode(e,"arg3")}, ${this.valueToCode(e,"arg4")})`)}sparqlBuiltinCall3(e){return i(`${e.getFieldValue("operator")}(${this.valueToCode(e,"arg1")}, ${this.valueToCode(e,"arg2")}, ${this.valueToCode(e,"arg3")})`)}sparqlBuiltinCallN(e){return i(`${e.getFieldValue("operator")}(${this.statementToCode(e,"args")})`)}sparqlAdditiveExpression(e){const t=this.valueToCode(e,"left"),r=this.valueToCode(e,"right");return i(n(" ",t,e.getFieldValue("operator"),r))}sparqlMultiplicativeExpression(e){const t=this.valueToCode(e,"left"),r=this.valueToCode(e,"right");return i(n(" ",t,e.getFieldValue("operator"),r))}sparqlRelationalExpression(e){const t=this.valueToCode(e,"left"),r=this.valueToCode(e,"right");return i(n(" ",t,e.getFieldValue("operator"),r))}sparqlConditionalAndExpression(e){return i(n(" ",this.valueToCode(e,"left"),"&&",this.valueToCode(e,"right")))}sparqlConditionalOrExpression(e){return i(n(" ",this.valueToCode(e,"left"),"||",this.valueToCode(e,"right")))}sparqlRelationalExpressionIn(e){const t=this.valueToCode(e,"left"),r=this.statementToCode(e,"right");return i(n(" ",t,n("",e.getFieldValue("operator")," (",r,")")))}sparqlUnaryexpression(e){const t=e.getFieldValue("operator"),r=this.valueToCode(e,"left");return i(n("",t.replace("UMINUS","-"),r))}sparqlIriOrFunction(e){return i(n("",this.valueToCode(e,"iri"),"(",n(" ",e.getFieldValue("distinct"),this.statementToCode(e,"args")),")"))}sparqlBound(e){return i(n("","BOUND(",this.valueToCode(e,"value"),")"))}sparqlExists(e){return i(n(" ",e.getFieldValue("operator"),this.valueToCode(e,"value")))}sparqlAggregate(e){return i(n("",e.getFieldValue("operator"),"(",n(" ",e.getFieldValue("distinct"),this.valueToCode(e,"arg1")),")"))}sparqlCount(e){const t=this.valueToCode(e,"arg1");return i(n("","COUNT(",n(" ",e.getFieldValue("distinct"),e.getFieldValue("star"),t),")"))}sparqlGroup_Concat(e){const t=this.valueToCode(e,"arg1"),r=e.getFieldValue("distinct"),s=this.valueToCode(e,"separator");return i(o("","GROUP_CONCAT(",n(" ",r,t),[s,n(" ","; SEPARATOR =",s)],")"))}sparqlEmbTp(e){return i(o(" ","<<",this.valueToCode(e,"subject"),this.valueToCode(e,"predicate"),this.valueToCode(e,"object"),">>"))}sparqlObjectListItemAnnotationPattern(e){const t=this.valueToCode(e,"value"),r=this.statementToCode(e,"annotations"),s=n(" ",t,n("\n","{|",this.indent(r),"|}"));return this.generateNext(e,s,", ")}sparqlVarOrExpressionAsVarItem(e){return this.item(" ",e)}sparqlObjectListItem(e){return this.item(", ",e)}sparqlGroupGraphPatternSubItem(e){return this.item(" .\n",e)}sparqlPrologueItem(e){return this.item("\n",e)}sparqlVarOrIriItem(e){return this.item(" ",e)}sparqlDatasetClause(e){const t=`FROM ${this.valueToCode(e,"value")}`;return this.generateNext(e,t,"\n")}sparqlExpressionListItem(e){return this.item(", ",e)}sparqlGroupConditionItem(e){return this.item(" ",e)}sparqlHavingConditionItem(e){return this.item(" ",e)}sparqlOrderConditionItem(e){return this.item(" ",e)}sparqlGraphNodeItem(e){return this.item(" ",e)}sparqlGroupGraphPatternItem(e){return this.item("\nUNION\n",e)}sparqlPathSequencItem(e){return this.item("/",e)}sparqlPathAlternativeItem(e){return this.item("|",e)}sparqlPathOneInPropertySetAlternativeItem(e){return this.item("|",e)}sparqlDataBlockValuesItem(e){const t=n("","(",n(" ",this.statementToCode(e,"items")),")");return this.generateNext(e,t,"\n")}sparqlDataBlockValueItem(e){return this.item(" ",e)}sparqlVarItem(e){return this.item(" ",e)}sparqlTriplesSameSubjectItem(e){return this.item(" .\n",e)}sparqlUpdateItem(e){return this.item(" ;\n\n",e)}sparqlQuadPatternItem(e){return this.item(" .\n",e)}valueToCode(e,t){return super.valueToCode(e,t,s.Order.Atomic)}indent(e){if(e)return this.prefixLines(e,"\t")}var(e,t){return i(`${t}${e.getFieldValue("value")}`)}item(e,t){const r=this.valueToCode(t,"value");return this.generateNext(t,r,e)}generateNext(e,t,r){return e.getNextBlock()&&(t+=r),t}}t.default=u},554:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.StringifiedMap=void 0;class r extends Map{constructor(){super(...arguments),this.keyMap=new Map}set(e,t){const r=JSON.stringify(e);return this.keyMap.set(r,e),super.set(r,t),this}get(e){return super.get(JSON.stringify(e))}has(e){return super.has(JSON.stringify(e))}entries(){return this[Symbol.iterator]()}*[Symbol.iterator](){for(const[e,t]of super[Symbol.iterator]())yield[this.keyMap.get(e),t]}}t.StringifiedMap=r},456:(e,t)=>{"use strict";var r,s,a;Object.defineProperty(t,"__esModule",{value:!0}),t.Order=t.XSD=t.RDF=void 0,(a=t.RDF||(t.RDF={})).type="http://www.w3.org/1999/02/22-rdf-syntax-ns#type",a.langString="http://www.w3.org/1999/02/22-rdf-syntax-ns#langString",a.nil="http://www.w3.org/1999/02/22-rdf-syntax-ns#nil",a.first="http://www.w3.org/1999/02/22-rdf-syntax-ns#first",a.rest="http://www.w3.org/1999/02/22-rdf-syntax-ns#rest",(s=t.XSD||(t.XSD={})).string="http://www.w3.org/2001/XMLSchema#string",s.integer="http://www.w3.org/2001/XMLSchema#integer",s.decimal="http://www.w3.org/2001/XMLSchema#decimal",s.double="http://www.w3.org/2001/XMLSchema#double",s.boolean="http://www.w3.org/2001/XMLSchema#boolean",(r=t.Order||(t.Order={}))[r.None=0]="None",r[r.Atomic=1]="Atomic"},30:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.collection=t.property=t.workspace=t.separator=t.primaryPaths=t.eltPaths=t.eltOrInversePaths=t.sequencePaths=t.paths=t.verbs=t.functionExpressions=t.constraints=t.primaryExpressions=t.unaryExpressions=t.multiplicativeExpressions=t.additiveExpressions=t.relationalExpressions=t.andExpressions=t.expressions=t.updateGraph=t.updateGraphOrDefault=t.updateGraphRefAll=t.groupGraphPattern=t.groupGraphPatternSubs=t.iriRefs=t.iris=t.triplesNodes=t.sameSubjectTriples=t.terms=t.graphNodes=t.graphTerms=t.varsOrIris=t.vars=void 0;const s=r(564);let a=0;function i(e,t,r){q(e,"sparql11_var1",t,"?s",r),q(e,"sparql11_var2",t,"$s",r)}function n(e,t,r){o(e,t,r),q(e,"sparql11_anon",t,"[]",r),q(e,"sparql11_blanknodelabel",t,"_:label",r),q(e,"sparql11_nil",t,"()",r)}function o(e,t,r){u(e,t,r),q(e,"sparql11_typedliteral",t,"''^^<>",r),q(e,"sparql11_langstring",t,"''@en",r),q(e,"sparql11_numericliteral",t,"42",r),q(e,"sparql11_booleanliteral",t,"✓",r),q(e,"sparql11_string",t,"''",r)}function p(e,t,r){q(e,"sparql11_triplessamesubject",t,"Triples same subject",r),l(e,t,r)}function l(e,t,r){q(e,"sparql11_blanknodepropertylist",t,"Blank node property list",r),q(e,"sparql11_collection",t,"Collection",r)}function u(e,t,r){c(e,t,r),q(e,"sparql11_prefixedname",t,":",r),q(e,"sparql11_prefixednameprefix",t,"prefix:",r),q(e,"sparql11_prefixednamelocalname",t,":name",r),q(e,"sparql11_prefixednameprefixlocalname",t,"prefix:name",r)}function c(e,t,r){q(e,"sparql11_iriref",t,"<iri>",r),q(e,"sparql11_irirefdefault",t,"<>",r)}function h(e,t,r){q(e,"sparql11_groupgraphpattern",t,"{}",r)}function d(e,t,r){m(e,t,r),q(e,"sparql11_graphordefault",t,"Default",r)}function m(e,t,r){q(e,"sparql11_graphref",t,"Graph",r)}function f(e,t,r){y(e,t,r),q(e,"sparql11_conditionalandexpression",t,"∧",r)}function y(e,t,r){E(e,t,r),q(e,"sparql11_relationalexpression",t,"=≠<>≤≥",r),q(e,"sparql11_relationalexpressionin",t,"in/not in",r)}function E(e,t,r){g(e,t,r),q(e,"sparql11_additiveexpression",t,"+−",r)}function g(e,t,r){I(e,t,r),q(e,"sparql11_multiplicativeexpression",t,"×÷",r)}function I(e,t,r){C(e,t,r),q(e,"sparql11_unaryexpression",t,"¬+−",r)}function C(e,t,r){i(e,t,r),o(e,t,r),v(e,t,r)}function v(e,t,r){_(e,t,r),q(e,"sparql11_brackettedexpression",t,"()",r)}function _(e,t,r){q(e,"sparql11_builtincall0",t,"𝛌0",r),q(e,"sparql11_builtincall1",t,"𝛌1",r),q(e,"sparql11_builtincall2",t,"𝛌2",r),q(e,"sparql11_builtincall3",t,"𝛌3",r),q(e,"sparql11_builtincall4",t,"𝛌4",r),q(e,"sparql11_builtincalln",t,"𝛌𝐧",r),q(e,"sparql11_iriorfunction",t,"<>𝐧",r),q(e,"sparql11_exists",t,"Exists",r),q(e,"sparql11_bound",t,"Bound",r),q(e,"sparql11_aggregate",t,"Aggregate",r),q(e,"sparql11_count",t,"Count",r),q(e,"sparql11_group_concat",t,"Group concatenation",r)}function b(e,t,r){F(e,t,r),q(e,"sparql11_pathalternative",t,"|",r)}function F(e,t,r){T(e,t,r),q(e,"sparql11_pathsequence",t,"/",r)}function T(e,t,r){x(e,t,r),q(e,"sparql11_inversepath",t,"^",r)}function x(e,t,r){k(e,t,r),q(e,"sparql11_pathwithmodifier",t,"?*+",r)}function k(e,t,r){u(e,t,r),q(e,"sparql11_a",t,"a",r),q(e,"sparql11_negatedpath",t,"!",r),q(e,"sparql11_bracketedpath",t,"()",r)}function q(e,t,r,s,a){S(e,t,r,s,(e=>{const s=e.block.workspace.newBlock(t);s.initSvg(),s.render();const a=e.block;s.outputConnection.connect(a.getInput(r).connection)}),a)}function S(e,t,r,a,i,n){n&&(a=`${n}: ${a}`);const o={displayText:()=>a,preconditionFn:t=>t.block.type===e?"enabled":"hidden",callback:i,scopeType:s.ContextMenuRegistry.ScopeType.BLOCK,id:e+t+r,weight:0};s.ContextMenuRegistry.registry.register(o)}t.vars=i,t.varsOrIris=function(e,t,r){i(e,t,r),u(e,t,r)},t.graphTerms=n,t.graphNodes=function(e,t,r){i(e,t,r),n(e,t,r),l(e,t,r),q(e,"sparql11_embtp",t,"<< >>",r)},t.terms=o,t.sameSubjectTriples=p,t.triplesNodes=l,t.iris=u,t.iriRefs=c,t.groupGraphPatternSubs=function(e,t,r){p(e,t,r),q(e,"sparql11_graphgraphpattern",t,"Graph",r),q(e,"sparql11_servicegraphpattern",t,"Service",r),q(e,"sparql11_bind",t,"Bind",r),q(e,"sparql11_minusgraphpattern",t,"Minus",r),q(e,"sparql11_grouporuniongraphpattern",t,"Union",r),q(e,"sparql11_filter",t,"Filter",r),q(e,"sparql11_optionalgraphpattern",t,"Optional",r),h(e,t,r)},t.groupGraphPattern=h,t.updateGraphRefAll=function(e,t,r){d(e,t,r),q(e,"sparql11_graphrefallnamed",t,"Named",r),q(e,"sparql11_graphrefallall",t,"All",r)},t.updateGraphOrDefault=d,t.updateGraph=m,t.expressions=function(e,t,r){f(e,t,r),q(e,"sparql11_conditionalorexpression",t,"∨",r)},t.andExpressions=f,t.relationalExpressions=y,t.additiveExpressions=E,t.multiplicativeExpressions=g,t.unaryExpressions=I,t.primaryExpressions=C,t.constraints=v,t.functionExpressions=_,t.verbs=function(e,t,r){i(e,t,r),b(e,t,r)},t.paths=b,t.sequencePaths=F,t.eltOrInversePaths=T,t.eltPaths=x,t.primaryPaths=k,t.separator=function(e){const t={displayText:()=>"==========",preconditionFn:t=>t.block.type===e?"disabled":"hidden",callback:()=>{},scopeType:s.ContextMenuRegistry.ScopeType.BLOCK,id:"separator"+ ++a,weight:0};s.ContextMenuRegistry.registry.register(t)},t.workspace=function(e,t){s.ContextMenuRegistry.registry.register({displayText:()=>e,preconditionFn:()=>"enabled",callback:e=>{const r=e.workspace.newBlock(t);r.initSvg(),r.render()},scopeType:s.ContextMenuRegistry.ScopeType.WORKSPACE,id:t,weight:0})},t.property=q,t.collection=function(e,t,r,s,a){S(e,t,r,s,(e=>{const s=e.block.workspace.newBlock(t);s.initSvg(),s.render();const a=e.block.getInput(r).connection,i=a.targetBlock();i?s.previousConnection.connect(i.lastConnectionInStack(!0)):s.previousConnection.connect(a)}),a)}},695:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const s=r(564);s.Blocks.sparql11_prologueitem={init:function(){this.appendValueInput("value").setCheck(["BaseDecl","PrefixDecl"]),this.setInputsInline(!1),this.setPreviousStatement(!0,"PrologueItem"),this.setNextStatement(!0,"PrologueItem"),this.setColour(196)}},s.Blocks.sparql11_base={init:function(){this.appendValueInput("value").setCheck("IRIREF").appendField("BASE"),this.setInputsInline(!1),this.setOutput(!0,"BaseDecl"),this.setColour(196)}},s.Blocks.sparql11_prefixdecl={init:function(){this.appendValueInput("value").setCheck("IRIREF").appendField("PREFIX").appendField(new s.FieldTextInput(""),"prefix").appendField(":"),this.setOutput(!0,"PrefixDecl"),this.setColour(196)}},s.Blocks.sparql11_prefixdecldefault={init:function(){this.appendValueInput("value").setCheck("IRIREF").appendField("PREFIX :"),this.setOutput(!0,"PrefixDecl"),this.setColour(196)}},s.Blocks.sparql11_query={init:function(){this.appendStatementInput("prologue").setCheck("PrologueItem"),this.appendValueInput("value").setCheck(["SelectQuery","ConstructQuery","DescribeQuery","AskQuery"]),this.appendValueInput("values").setCheck("ValuesClause"),this.setColour(196)}},s.Blocks.sparql11_selectquery={init:function(){this.appendValueInput("select").setCheck("SelectClause").appendField("SELECT"),this.appendValueInput("where").setCheck("QueryCommon"),this.setInputsInline(!1),this.setOutput(!0,"SelectQuery"),this.setColour(196)}},s.Blocks.sparql11_simpleconstructquery={init:function(){this.appendDummyInput().appendField("CONSTRUCT"),this.appendStatementInput("datasets").setCheck("DatasetClause"),this.appendStatementInput("where").setCheck("TriplesSameSubjectItem").appendField("WHERE {"),this.appendValueInput("modifiers").setCheck("SolutionModifier").appendField("}"),this.setOutput(!0,"ConstructQuery"),this.setColour(196)}},s.Blocks.sparql11_constructquery={init:function(){this.appendStatementInput("template").setCheck("TriplesSameSubjectItem").appendField("CONSTRUCT {"),this.appendValueInput("where").setCheck("QueryCommon").appendField("}"),this.setOutput(!0,"ConstructQuery"),this.setColour(196)}},s.Blocks.sparql11_describequery={init:function(){this.appendStatementInput("subject").setCheck("VarOrIriItem").appendField("DESCRIBE").appendField(new s.FieldDropdown([["",""],["*","*"]]),"star"),this.appendValueInput("where").setCheck("QueryCommon"),this.setOutput(!0,"DescribeQuery"),this.setColour(196)}},s.Blocks.sparql11_askquery={init:function(){this.appendValueInput("value").setCheck("QueryCommon").appendField("ASK"),this.setOutput(!0,"AskQuery"),this.setColour(196)}},s.Blocks.sparql11_varoririitem={init:function(){this.appendValueInput("value").setCheck("VarOrIri"),this.setPreviousStatement(!0,"VarOrIriItem"),this.setNextStatement(!0,"VarOrIriItem"),this.setColour(196)}},s.Blocks.sparql11_triplessamesubjectitem={init:function(){this.appendValueInput("value").setCheck("TriplesSameSubject"),this.setPreviousStatement(!0,"TriplesSameSubjectItem"),this.setNextStatement(!0,"TriplesSameSubjectItem"),this.setColour(196)}},s.Blocks.sparql11_update={init:function(){this.appendStatementInput("prologue").setCheck("PrologueItem"),this.appendStatementInput("items").setCheck("UpdateItem"),this.setColour(196)}},s.Blocks.sparql11_updateitem={init:function(){this.appendValueInput("value").setCheck(["Update1"]),this.setPreviousStatement(!0,"UpdateItem"),this.setNextStatement(!0,"UpdateItem"),this.setColour(196)}},s.Blocks.sparql11_insertdeletewhere={init:function(){this.appendValueInput("pattern").setCheck("QuadPattern").appendField(new s.FieldDropdown([["INSERT DATA","INSERT DATA"],["DELETE DATA","DELETE DATA"],["DELETE WHERE","DELETE WHERE"]]),"operator"),this.setOutput(!0,"Update1"),this.setColour(196)}},s.Blocks.sparql11_quadpattern={init:function(){this.appendDummyInput().appendField("{"),this.appendStatementInput("items").setCheck("QuadPatternItem"),this.appendDummyInput().appendField("}"),this.setInputsInline(!1),this.setOutput(!0,"QuadPattern"),this.setColour(196)}},s.Blocks.sparql11_quadpatternitem={init:function(){this.appendValueInput("value").setCheck(["TriplesSameSubject","QuadsNotTriples"]),this.setInputsInline(!1),this.setPreviousStatement(!0,"QuadPatternItem"),this.setNextStatement(!0,"QuadPatternItem"),this.setColour(196)}},s.Blocks.sparql11_quadsnottriples={init:function(){this.appendValueInput("name").setCheck("VarOrIri").appendField("GRAPH {"),this.appendStatementInput("triples").setCheck("TriplesSameSubjectItem"),this.appendDummyInput().appendField("}"),this.setInputsInline(!1),this.setOutput(!0,"QuadsNotTriples"),this.setColour(196)}},s.Blocks.sparql11_modify={init:function(){this.appendValueInput("iri").setCheck("iri").appendField("WITH"),this.appendValueInput("delete").setCheck("QuadPattern").appendField("DELETE"),this.appendValueInput("insert").setCheck("QuadPattern").appendField("INSERT"),this.appendStatementInput("using").setCheck("UsingClause"),this.appendValueInput("where").setCheck("GroupGraphPattern").appendField("WHERE"),this.setInputsInline(!1),this.setOutput(!0,"Update1"),this.setColour(196)}},s.Blocks.sparql11_usingclause={init:function(){this.appendValueInput("value").setCheck(["iri","NamedGraphClause"]).appendField("USING"),this.setInputsInline(!1),this.setPreviousStatement(!0,"UsingClause"),this.setNextStatement(!0,"UsingClause"),this.setColour(196)}},s.Blocks.sparql11_load={init:function(){this.appendValueInput("source").setCheck("iri").appendField("LOAD").appendField(new s.FieldDropdown([["",""],["SILENT","SILENT"]]),"silent"),this.appendValueInput("destination").setCheck("GraphRef").appendField("INTO"),this.setOutput(!0,"Update1"),this.setColour(196)}},s.Blocks.sparql11_create={init:function(){this.appendValueInput("graph").setCheck("GraphRef").appendField("CREATE").appendField(new s.FieldDropdown([["",""],["SILENT","SILENT"]]),"silent"),this.setOutput(!0,"Update1"),this.setColour(196)}},s.Blocks.sparql11_addmovecopy={init:function(){this.appendValueInput("source").setCheck("GraphOrDefault").appendField(new s.FieldDropdown([["ADD","ADD"],["MOVE","MOVE"],["COPY","COPY"]]),"operator").appendField(new s.FieldDropdown([["",""],["SILENT","SILENT"]]),"silent"),this.appendValueInput("destination").setCheck("GraphOrDefault").appendField("TO"),this.setOutput(!0,"Update1"),this.setColour(196)}},s.Blocks.sparql11_cleardrop={init:function(){this.appendValueInput("graph").setCheck("GraphRefAll").appendField(new s.FieldDropdown([["CLEAR","CLEAR"],["DROP","DROP"]]),"operator").appendField(new s.FieldDropdown([["",""],["SILENT","SILENT"]]),"silent"),this.setOutput(!0,"Update1"),this.setColour(196)}},s.Blocks.sparql11_graphref={init:function(){this.appendValueInput("value").setCheck("iri").appendField("GRAPH"),this.setOutput(!0,["GraphRef","GraphRefAll","GraphOrDefault"]),this.setColour(196)}},s.Blocks.sparql11_graphrefallnamed={init:function(){this.appendDummyInput().appendField("NAMED"),this.setOutput(!0,"GraphRefAll"),this.setColour(196)}},s.Blocks.sparql11_graphrefallall={init:function(){this.appendDummyInput().appendField("ALL"),this.setOutput(!0,"GraphRefAll"),this.setColour(196)}},s.Blocks.sparql11_graphordefault={init:function(){this.appendDummyInput().appendField("DEFAULT"),this.setOutput(!0,["GraphRefAll","GraphOrDefault"]),this.setColour(196)}},s.Blocks.sparql11_triplessamesubject={init:function(){this.appendValueInput("subject").setCheck(["VarOrTermOrEmbTP","TriplesNode"]),this.appendStatementInput("predicates").setCheck("PropertyListNotEmpty"),this.setOutput(!0,"TriplesSameSubject"),this.setColour(0)}},s.Blocks.sparql11_propertylistnotempty={init:function(){this.appendValueInput("predicate").setCheck(["Verb","Path"]),this.appendStatementInput("objects").setCheck("ObjectListItem"),this.setPreviousStatement(!0,"PropertyListNotEmpty"),this.setNextStatement(!0,"PropertyListNotEmpty"),this.setColour(131)}},s.Blocks.sparql11_objectlistitem={init:function(){this.appendValueInput("value").setCheck("GraphNode"),this.setPreviousStatement(!0,"ObjectListItem"),this.setNextStatement(!0,"ObjectListItem"),this.setColour(294)}},s.Blocks.sparql11_objectlistitemannotationpattern={init:function(){this.appendValueInput("value").appendField("{|").setCheck("GraphNode"),this.appendStatementInput("annotations").setCheck("PropertyListNotEmpty"),this.appendDummyInput().appendField("|}"),this.setPreviousStatement(!0,"ObjectListItem"),this.setNextStatement(!0,"ObjectListItem"),this.setColour(294)}},s.Blocks.sparql11_groupgraphpattern={init:function(){this.appendDummyInput().appendField("{"),this.appendValueInput("value").setCheck(["SubSelect","GroupGraphPatternSub","TriplesNode","TriplesSameSubject","GraphPatternNotTriples","GroupGraphPattern"]),this.appendDummyInput().appendField("}"),this.setInputsInline(!1),this.setOutput(!0,"GroupGraphPattern"),this.setColour(65)}},s.Blocks.sparql11_subselect={init:function(){this.appendValueInput("select").setCheck("SelectClause").appendField("SELECT"),this.appendValueInput("pattern").setCheck("GroupGraphPattern").appendField("WHERE"),this.appendValueInput("modifiers").setCheck("SolutionModifier"),this.appendValueInput("values").setCheck("ValuesClause"),this.setOutput(!0,"SubSelect"),this.setColour(65)}},s.Blocks.sparql11_groupgraphpatternsub={init:function(){this.appendStatementInput("items").setCheck("GroupGraphPatternSubItem"),this.setOutput(!0,"GroupGraphPatternSub"),this.setColour(65)}},s.Blocks.sparql11_groupgraphpatternsubitem={init:function(){this.appendValueInput("value").setCheck(["GroupGraphPattern","TriplesNode","TriplesSameSubject","GraphPatternNotTriples"]),this.setPreviousStatement(!0,"GroupGraphPatternSubItem"),this.setNextStatement(!0,"GroupGraphPatternSubItem"),this.setColour(65)}},s.Blocks.sparql11_graphgraphpattern={init:function(){this.appendValueInput("iri").setCheck("VarOrIri").appendField("GRAPH"),this.appendValueInput("patterns").setCheck("GroupGraphPattern"),this.setInputsInline(!1),this.setOutput(!0,["GraphGraphPattern","GraphPatternNotTriples"]),this.setColour(65)}},s.Blocks.sparql11_servicegraphpattern={init:function(){this.appendValueInput("iri").setCheck("VarOrIri").appendField("SERVICE").appendField(new s.FieldDropdown([["",""],["SILENT","SILENT"]]),"silent"),this.appendValueInput("patterns").setCheck("GroupGraphPattern"),this.setOutput(!0,["ServiceGraphPattern","GraphPatternNotTriples"]),this.setColour(65)}},s.Blocks.sparql11_bind={init:function(){this.appendValueInput("value").setCheck("ExpressionAsVar").appendField("BIND"),this.setOutput(!0,["Bind","GraphPatternNotTriples"]),this.setColour(65)}},s.Blocks.sparql11_minusgraphpattern={init:function(){this.appendValueInput("value").setCheck("GroupGraphPattern").appendField("MINUS"),this.setOutput(!0,["MinusGraphPattern","GraphPatternNotTriples"]),this.setColour(65)}},s.Blocks.sparql11_grouporuniongraphpattern={init:function(){this.appendStatementInput("items").setCheck("GroupGraphPatternItem").appendField("UNION"),this.setInputsInline(!1),this.setOutput(!0,["GroupOrUnionGraphPattern","GraphPatternNotTriples"]),this.setColour(65)}},s.Blocks.sparql11_groupgraphpatternitem={init:function(){this.appendValueInput("value").setCheck("GroupGraphPattern"),this.setPreviousStatement(!0,"GroupGraphPatternItem"),this.setNextStatement(!0,"GroupGraphPatternItem"),this.setColour(65)}},s.Blocks.sparql11_filter={init:function(){this.appendValueInput("value").setCheck("Constraint").appendField("FILTER"),this.setOutput(!0,["Filter","GraphPatternNotTriples"]),this.setColour(65)}},s.Blocks.sparql11_optionalgraphpattern={init:function(){this.appendValueInput("value").setCheck("GroupGraphPattern").appendField("OPTIONAL"),this.setOutput(!0,"GraphPatternNotTriples"),this.setColour(65)}},s.Blocks.sparql11_inlinedata={init:function(){this.appendValueInput("value").setCheck("DataBlock").appendField("VALUES"),this.setOutput(!0,["InlineData","GraphPatternNotTriples","ValuesClause"]),this.setColour(65)}},s.Blocks.sparql11_inlinedataonevar={init:function(){this.appendValueInput("variable").setCheck("Var"),this.appendDummyInput().appendField("{"),this.appendStatementInput("values").setCheck("DataBlockValueItem"),this.appendDummyInput().appendField("}"),this.setOutput(!0,"DataBlock"),this.setColour(65)}},s.Blocks.sparql11_inlinedatafull={init:function(){this.appendDummyInput().appendField("("),this.appendStatementInput("variables").setCheck("VarItem"),this.appendDummyInput().appendField(")"),this.appendDummyInput().appendField("{"),this.appendStatementInput("values").setCheck("DataBlockValuesItem"),this.appendDummyInput().appendField("}"),this.setOutput(!0,["InlineDataFull","DataBlock"]),this.setColour(65)}},s.Blocks.sparql11_datablockvaluesitem={init:function(){this.appendDummyInput().appendField("("),this.appendStatementInput("items").setCheck("DataBlockValueItem"),this.appendDummyInput().appendField(")"),this.setPreviousStatement(!0,"DataBlockValuesItem"),this.setNextStatement(!0,"DataBlockValuesItem"),this.setColour(65)}},s.Blocks.sparql11_datablockvalueitem={init:function(){this.appendValueInput("value").setCheck("DataBlockValue"),this.setPreviousStatement(!0,"DataBlockValueItem"),this.setNextStatement(!0,"DataBlockValueItem"),this.setColour(65)}},s.Blocks.sparql11_a={init:function(){this.appendDummyInput().appendField("a"),this.setOutput(!0,["a","PathPrimary","PathElt","PathEltOrInverse","PathSequence","Path","VerbPath","PathOneInPropertySet","PathNegatedPropertySet","Verb"]),this.setColour(228)}},s.Blocks.sparql11_negatedpath={init:function(){this.appendValueInput("value").setCheck("PathNegatedPropertySet").appendField("!"),this.setInputsInline(!0),this.setOutput(!0,["PathPrimary","PathElt","PathEltOrInverse","PathSequence","Path","VerbPath"]),this.setColour(228)}},s.Blocks.sparql11_bracketedpath={init:function(){this.appendValueInput("value").setCheck("Path").appendField("("),this.appendDummyInput().appendField(")"),this.setOutput(!0,["PathPrimary","PathElt","PathEltOrInverse","PathSequence","Path","VerbPath"]),this.setColour(228)}},s.Blocks.sparql11_pathwithmodifier={init:function(){this.appendValueInput("value").setCheck("PathPrimary").appendField(""),this.appendDummyInput().appendField(new s.FieldDropdown([["",""],["?","?"],["*","*"],["+","+"]]),"modifier"),this.setInputsInline(!0),this.setOutput(!0,["PathElt","PathEltOrInverse","PathSequence","Path","VerbPath"]),this.setColour(228)}},s.Blocks.sparql11_inversepath={init:function(){this.appendValueInput("value").setCheck("PathElt").appendField("^"),this.setInputsInline(!1),this.setInputsInline(!0),this.setOutput(!0,["PathEltOrInverse","PathSequence","Path","VerbPath"]),this.setColour(228)}},s.Blocks.sparql11_pathalternative={init:function(){this.appendDummyInput().appendField("|"),this.appendStatementInput("items").setCheck("PathAlternativeItem"),this.setInputsInline(!0),this.setOutput(!0,["Path","VerbPath"]),this.setColour(228)}},s.Blocks.sparql11_pathsequence={init:function(){this.appendDummyInput().appendField("/"),this.appendStatementInput("items").setCheck("PathSequenceItem"),this.setInputsInline(!0),this.setOutput(!0,["PathSequence","Path","VerbPath"]),this.setColour(228)}},s.Blocks.sparql11_inversepathoneinpropertyset={init:function(){this.appendValueInput("value").setCheck(["iri","a"]).appendField("^"),this.setInputsInline(!0),this.setOutput(!0,["PathOneInPropertySet","PathNegatedPropertySet"]),this.setColour(228)}},s.Blocks.sparql11_pathoneinpropertysetalternative={init:function(){this.appendDummyInput().appendField("(|)"),this.appendStatementInput("items").setCheck("PathOneInPropertySetAlternativeItem"),this.setInputsInline(!0),this.setOutput(!0,"PathNegatedPropertySet"),this.setColour(228)}},s.Blocks.sparql11_pathsequencitem={init:function(){this.appendValueInput("value").setCheck("PathEltOrInverse"),this.setInputsInline(!1),this.setPreviousStatement(!0,"PathSequenceItem"),this.setNextStatement(!0,"PathSequenceItem"),this.setColour(228)}},s.Blocks.sparql11_pathalternativeitem={init:function(){this.appendValueInput("value").setCheck("PathSequence"),this.setInputsInline(!1),this.setPreviousStatement(!0,"PathAlternativeItem"),this.setNextStatement(!0,"PathAlternativeItem"),this.setColour(228)}},s.Blocks.sparql11_pathoneinpropertysetalternativeitem={init:function(){this.appendValueInput("value").setCheck("PathOneInPropertySet"),this.setPreviousStatement(!0,"PathOneInPropertySetAlternativeItem"),this.setNextStatement(!0,"PathOneInPropertySetAlternativeItem"),this.setColour(228)}},s.Blocks.sparql11_querycommon={init:function(){this.appendStatementInput("datasets").setCheck("DatasetClause"),this.appendValueInput("pattern").setCheck("GroupGraphPattern").appendField("WHERE"),this.appendValueInput("modifiers").setCheck("SolutionModifier"),this.setOutput(!0,"QueryCommon"),this.setColour(196)}},s.Blocks.sparql11_selectclause={init:function(){this.appendStatementInput("vars").setCheck("VarOrExpressionAsVarItem").appendField(new s.FieldDropdown([["",""],["DISTINCT","DISTINCT"],["REDUCED","REDUCED"]]),"distinctOrReduced").appendField(new s.FieldDropdown([["",""],["*","*"]]),"star"),this.setOutput(!0,"SelectClause"),this.setColour(196)}},s.Blocks.sparql11_expressionasvar={init:function(){this.appendValueInput("value").setCheck(["Expression","EmbTP"]).appendField("("),this.appendDummyInput().appendField("AS"),this.appendValueInput("name").setCheck("Var"),this.appendDummyInput().appendField(")"),this.setInputsInline(!0),this.setOutput(!0,["ExpressionAsVar","GroupCondition"]),this.setColour(98)}},s.Blocks.sparql11_undef={init:function(){this.appendDummyInput().appendField("UNDEF"),this.setOutput(!0,"DataBlockValue"),this.setColour(65)}},s.Blocks.sparql11_datasetclause={init:function(){this.appendValueInput("value").setCheck(["iri","NamedGraphClause"]).appendField("FROM"),this.setInputsInline(!1),this.setPreviousStatement(!0,"DatasetClause"),this.setNextStatement(!0,"DatasetClause"),this.setColour(196)}},s.Blocks.sparql11_namedgraphclause={init:function(){this.appendValueInput("value").setCheck("iri").appendField("NAMED"),this.setOutput(!0,"NamedGraphClause"),this.setColour(196)}},s.Blocks.sparql11_solutionmodifier={init:function(){this.appendStatementInput("group").setCheck("GroupConditionItem").appendField("GROUP BY"),this.appendStatementInput("having").setCheck("HavingConditionItem").appendField("HAVING"),this.appendStatementInput("order").setCheck("OrderConditionItem").appendField("ORDER BY"),this.appendValueInput("limit").setCheck("NumericLiteral").appendField("LIMIT"),this.appendValueInput("offset").setCheck("NumericLiteral").appendField("OFFSET"),this.setOutput(!0,"SolutionModifier"),this.setColour(196)}},s.Blocks.sparql11_ordercondition={init:function(){this.appendValueInput("value").setCheck("BrackettedExpression").appendField(new s.FieldDropdown([["ASC","ASC"],["DESC","DESC"]]),"operator"),this.setOutput(!0,"OrderCondition"),this.setColour(196)}},s.Blocks.sparql11_groupconditionitem={init:function(){this.appendValueInput("value").setCheck("GroupCondition"),this.setPreviousStatement(!0,"GroupConditionItem"),this.setNextStatement(!0,"GroupConditionItem"),this.setColour(196)}},s.Blocks.sparql11_havingconditionitem={init:function(){this.appendValueInput("value").setCheck("Constraint"),this.setPreviousStatement(!0,"HavingConditionItem"),this.setNextStatement(!0,"HavingConditionItem"),this.setColour(196)}},s.Blocks.sparql11_orderconditionitem={init:function(){this.appendValueInput("value").setCheck(["OrderCondition","Constraint","Var"]),this.setPreviousStatement(!0,"OrderConditionItem"),this.setNextStatement(!0,"OrderConditionItem"),this.setColour(196)}},s.Blocks.sparql11_varorexpressionasvaritem={init:function(){this.appendValueInput("value").setCheck(["Var","ExpressionAsVar"]),this.setInputsInline(!1),this.setPreviousStatement(!0,"VarOrExpressionAsVarItem"),this.setNextStatement(!0,"VarOrExpressionAsVarItem"),this.setColour(196)}},s.Blocks.sparql11_brackettedexpression={init:function(){this.appendValueInput("value").setCheck("Expression").appendField("("),this.appendDummyInput().appendField(")"),this.setOutput(!0,["BrackettedExpression","PrimaryExpression","UnaryExpression","MultiplicativeExpression","AdditiveExpression","RelationalExpression","ConditionalAndExpression","ConditionalOrExpression","Expression","Constraint"]),this.setColour(261)}},s.Blocks.sparql11_multiplicativeexpression={init:function(){this.appendValueInput("left").setCheck("UnaryExpression"),this.appendValueInput("right").setCheck("UnaryExpression").appendField(new s.FieldDropdown([["*","*"],["/","/"]]),"operator"),this.setInputsInline(!0),this.setOutput(!0,["MultiplicativeExpression","AdditiveExpression","RelationalExpression","ConditionalAndExpression","ConditionalOrExpression","Expression"]),this.setColour(261)}},s.Blocks.sparql11_additiveexpression={init:function(){this.appendValueInput("left").setCheck("MultiplicativeExpression"),this.appendValueInput("right").setCheck("MultiplicativeExpression").appendField(new s.FieldDropdown([["+","+"],["-","-"]]),"operator"),this.setInputsInline(!0),this.setOutput(!0,["AdditiveExpression","RelationalExpression","ConditionalAndExpression","ConditionalOrExpression","Expression"]),this.setColour(261)}},s.Blocks.sparql11_relationalexpression={init:function(){this.appendValueInput("left").setCheck("AdditiveExpression"),this.appendValueInput("right").setCheck("AdditiveExpression").appendField(new s.FieldDropdown([["=","="],["!=","!="],["<","<"],[">",">"],["<=","<="],[">=",">="]]),"operator"),this.setInputsInline(!0),this.setOutput(!0,["RelationalExpression","ConditionalAndExpression","ConditionalOrExpression","Expression"]),this.setColour(261)}},s.Blocks.sparql11_relationalexpressionin={init:function(){this.appendValueInput("left").setCheck("AdditiveExpression"),this.appendStatementInput("right").setCheck("ExpressionListItem").appendField(new s.FieldDropdown([["IN","IN"],["NOT IN","NOT IN"]]),"operator"),this.setInputsInline(!0),this.setOutput(!0,["RelationalExpression","ConditionalAndExpression","ConditionalOrExpression","Expression"]),this.setColour(261)}},s.Blocks.sparql11_conditionalandexpression={init:function(){this.appendValueInput("left").setCheck("RelationalExpression"),this.appendValueInput("right").setCheck("RelationalExpression").appendField("&&"),this.setInputsInline(!0),this.setOutput(!0,["ConditionalAndExpression","ConditionalOrExpression","Expression"]),this.setColour(261)}},s.Blocks.sparql11_conditionalorexpression={init:function(){this.appendValueInput("left").setCheck("ConditionalAndExpression"),this.appendValueInput("right").setCheck("ConditionalAndExpression").appendField("||"),this.setInputsInline(!0),this.setOutput(!0,["ConditionalOrExpression","Expression"]),this.setColour(261)}},s.Blocks.sparql11_builtincall0={init:function(){this.appendDummyInput().appendField(new s.FieldDropdown([["BNODE","BNODE"],["RAND","RAND"],["NOW","NOW"],["UUID","UUID"],["STRUUID","STRUUID"]]),"operator").appendField("()"),this.setInputsInline(!0),this.setOutput(!0,["BuiltInCall","PrimaryExpression","UnaryExpression","MultiplicativeExpression","AdditiveExpression","RelationalExpression","ConditionalAndExpression","ConditionalOrExpression","Expression","GroupCondition","Constraint"]),this.setColour(261)}},s.Blocks.sparql11_builtincall1={init:function(){this.appendValueInput("arg1").setCheck("Expression").appendField(new s.FieldDropdown([["STR","STR"],["LANG","LANG"],["DATATYPE","DATATYPE"],["IRI","IRI"],["URI","URI"],["BNODE","BNODE"],["ABS","ABS"],["CEIL","CEIL"],["FLOOR","FLOOR"],["ROUND","ROUND"],["STRLEN","STRLEN"],["UCASE","UCASE"],["LCASE","LCASE"],["ENCODE_FOR_URI","ENCODE_FOR_URI"],["YEAR","YEAR"],["MONTH","MONTH"],["DAY","DAY"],["HOURS","HOURS"],["MINUTES","MINUTES"],["SECONDS","SECONDS"],["TIMEZONE","TIMEZONE"],["TZ","TZ"],["MD5","MD5"],["SHA1","SHA1"],["SHA256","SHA256"],["SHA384","SHA384"],["SHA512","SHA512"],["ISIRI","ISIRI"],["ISURI","ISURI"],["ISBLANK","ISBLANK"],["ISLITERAL","ISLITERAL"],["ISNUMERIC","ISNUMERIC"],["SUBJECT","SUBJECT"],["PREDICATE","PREDICATE"],["OBJECT","OBJECT"],["ISTRIPLE","ISTRIPLE"]]),"operator").appendField("("),this.appendDummyInput().appendField(")"),this.setInputsInline(!0),this.setOutput(!0,["BuiltInCall","PrimaryExpression","UnaryExpression","MultiplicativeExpression","AdditiveExpression","RelationalExpression","ConditionalAndExpression","ConditionalOrExpression","Expression","GroupCondition","Constraint"]),this.setColour(261)}},s.Blocks.sparql11_builtincall2={init:function(){this.appendValueInput("arg1").setCheck("Expression").appendField(new s.FieldDropdown([["LANGMATCHES","LANGMATCHES"],["SUBSTR","SUBSTR"],["CONTAINS","CONTAINS"],["STRSTARTS","STRSTARTS"],["STRENDS","STRENDS"],["STRBEFORE","STRBEFORE"],["STRAFTER","STRAFTER"],["STRLANG","STRLANG"],["STRDT","STRDT"],["SAMETERM","SAMETERM"],["REGEX","REGEX"]]),"operator").appendField("("),this.appendValueInput("arg2").setCheck("Expression").appendField(","),this.appendDummyInput().appendField(")"),this.setInputsInline(!0),this.setOutput(!0,["BuiltInCall","PrimaryExpression","UnaryExpression","MultiplicativeExpression","AdditiveExpression","RelationalExpression","ConditionalAndExpression","ConditionalOrExpression","Expression","GroupCondition","Constraint"]),this.setColour(261)}},s.Blocks.sparql11_builtincall3={init:function(){this.appendValueInput("arg1").setCheck("Expression").appendField(new s.FieldDropdown([["REGEX","REGEX"],["SUBSTR","SUBSTR"],["REPLACE","REPLACE"],["IF","IF"],["TRIPLE","TRIPLE"]]),"operator").appendField("("),this.appendValueInput("arg2").setCheck("Expression").appendField(","),this.appendValueInput("arg3").setCheck("Expression").appendField(","),this.appendDummyInput().appendField(")"),this.setInputsInline(!0),this.setOutput(!0,["BuiltInCall","PrimaryExpression","UnaryExpression","MultiplicativeExpression","AdditiveExpression","RelationalExpression","ConditionalAndExpression","ConditionalOrExpression","Expression","GroupCondition","Constraint"]),this.setColour(261)}},s.Blocks.sparql11_builtincall4={init:function(){this.appendValueInput("arg1").setCheck("Expression").appendField(new s.FieldDropdown([["REPLACE","REPLACE"]]),"operator").appendField("("),this.appendValueInput("arg2").setCheck("Expression").appendField(","),this.appendValueInput("arg3").setCheck("Expression").appendField(","),this.appendValueInput("arg4").setCheck("Expression").appendField(","),this.appendDummyInput().appendField(")"),this.setInputsInline(!0),this.setOutput(!0,["BuiltInCall","PrimaryExpression","UnaryExpression","MultiplicativeExpression","AdditiveExpression","RelationalExpression","ConditionalAndExpression","ConditionalOrExpression","Expression","GroupCondition","Constraint"]),this.setColour(261)}},s.Blocks.sparql11_builtincalln={init:function(){this.appendStatementInput("args").setCheck("ExpressionListItem").appendField(new s.FieldDropdown([["CONCAT","CONCAT"],["COALESCE","COALESCE"]]),"operator").appendField("("),this.appendDummyInput().appendField(")"),this.setInputsInline(!0),this.setOutput(!0,["BuiltInCall","PrimaryExpression","UnaryExpression","MultiplicativeExpression","AdditiveExpression","RelationalExpression","ConditionalAndExpression","ConditionalOrExpression","Expression","GroupCondition","Constraint"]),this.setColour(261)}},s.Blocks.sparql11_iriorfunction={init:function(){this.appendValueInput("iri").setCheck("iri"),this.appendDummyInput().appendField("(").appendField(new s.FieldDropdown([["",""],["DISTINCT","DISTINCT"]]),"distinct"),this.appendStatementInput("args").setCheck("ExpressionListItem"),this.appendDummyInput().appendField(")"),this.setInputsInline(!0),this.setOutput(!0,["BuiltInCall","PrimaryExpression","UnaryExpression","MultiplicativeExpression","AdditiveExpression","RelationalExpression","ConditionalAndExpression","ConditionalOrExpression","Expression","Constraint","GroupCondition"]),this.setColour(261)}},s.Blocks.sparql11_exists={init:function(){this.appendValueInput("value").setCheck("GroupGraphPattern").appendField(new s.FieldDropdown([["EXISTS","EXISTS"],["NOT EXISTS","NOT EXISTS"]]),"operator"),this.setOutput(!0,["BuiltInCall","PrimaryExpression","UnaryExpression","MultiplicativeExpression","AdditiveExpression","RelationalExpression","ConditionalAndExpression","ConditionalOrExpression","Expression","GroupCondition","Constraint"]),this.setColour(261)}},s.Blocks.sparql11_bound={init:function(){this.appendValueInput("value").setCheck("Var").appendField("BOUND ("),this.appendDummyInput().appendField(")"),this.setInputsInline(!0),this.setOutput(!0,["BuiltInCall","PrimaryExpression","UnaryExpression","MultiplicativeExpression","AdditiveExpression","RelationalExpression","ConditionalAndExpression","ConditionalOrExpression","Expression","GroupCondition","Constraint"]),this.setColour(261)}},s.Blocks.sparql11_unaryexpression={init:function(){this.appendValueInput("left").setCheck("PrimaryExpression").appendField(new s.FieldDropdown([["!","!"],["+","+"],["-","UMINUS"]]),"operator"),this.setInputsInline(!0),this.setOutput(!0,["UnaryExpression","MultiplicativeExpression","AdditiveExpression","RelationalExpression","ConditionalAndExpression","ConditionalOrExpression","Expression"]),this.setColour(261)}},s.Blocks.sparql11_aggregate={init:function(){this.appendValueInput("arg1").setCheck("Expression").appendField(new s.FieldDropdown([["SUM","SUM"],["MIN","MIN"],["MAX","MAX"],["AVG","AVG"],["SAMPLE","SAMPLE"]]),"operator").appendField("(").appendField(new s.FieldDropdown([["",""],["DISTINCT","DISTINCT"]]),"distinct"),this.appendDummyInput().appendField(")"),this.setInputsInline(!0),this.setOutput(!0,["BuiltInCall","PrimaryExpression","UnaryExpression","MultiplicativeExpression","AdditiveExpression","RelationalExpression","ConditionalAndExpression","ConditionalOrExpression","Expression","GroupCondition","Constraint"]),this.setColour(261)}},s.Blocks.sparql11_count={init:function(){this.appendValueInput("arg1").setCheck("Expression").appendField("COUNT(").appendField(new s.FieldDropdown([["",""],["DISTINCT","DISTINCT"]]),"distinct").appendField(new s.FieldDropdown([["",""],["*","*"]]),"star"),this.appendDummyInput().appendField(")"),this.setInputsInline(!0),this.setOutput(!0,["BuiltInCall","PrimaryExpression","UnaryExpression","MultiplicativeExpression","AdditiveExpression","RelationalExpression","ConditionalAndExpression","ConditionalOrExpression","Expression","GroupCondition","Constraint"]),this.setColour(261)}},s.Blocks.sparql11_group_concat={init:function(){this.appendValueInput("arg1").setCheck("Expression").appendField("GROUP_CONCAT(").appendField(new s.FieldDropdown([["",""],["DISTINCT","DISTINCT"]]),"distinct"),this.appendValueInput("separator").appendField("; SEPARATOR =").setCheck("string"),this.appendDummyInput().appendField(")"),this.setInputsInline(!0),this.setOutput(!0,["BuiltInCall","PrimaryExpression","UnaryExpression","MultiplicativeExpression","AdditiveExpression","RelationalExpression","ConditionalAndExpression","ConditionalOrExpression","Expression","GroupCondition","Constraint"]),this.setColour(261)}},s.Blocks.sparql11_expressionlistitem={init:function(){this.appendValueInput("value").setCheck("Expression"),this.setPreviousStatement(!0,"ExpressionListItem"),this.setNextStatement(!0,"ExpressionListItem"),this.setColour(261)}},s.Blocks.sparql11_blanknodepropertylist={init:function(){this.appendDummyInput().appendField("["),this.appendStatementInput("predicates").setCheck("PropertyListNotEmpty"),this.appendDummyInput().appendField("]"),this.setOutput(!0,["BlankNodePropertyList","TriplesNode","TriplesSameSubject","GraphNode","Object","TriplesBlock"]),this.setColour(0)}},s.Blocks.sparql11_prefixedname={init:function(){this.appendDummyInput().appendField(":"),this.setInputsInline(!0),this.setOutput(!0,["EmbSubjectOrObject","DataValueTerm","VarOrTermOrEmbTP","iri","VarOrIri","GraphNode","VarOrTerm","GraphTerm","Verb","DataBlockValue","PathPrimary","PathElt","PathEltOrInverse","PathSequence","Path","VerbPath","PathOneInPropertySet","PathNegatedPropertySet","Expression","ConditionalOrExpression","ConditionalAndExpression","RelationalExpression","AdditiveExpression","MultiplicativeExpression","UnaryExpression","PrimaryExpression","iriOrFunction","GraphOrDefault"]),this.setColour(326)}},s.Blocks.sparql11_prefixednameprefix={init:function(){this.appendDummyInput().appendField(new s.FieldTextInput(""),"prefix").appendField(":"),this.setInputsInline(!0),this.setOutput(!0,["EmbSubjectOrObject","DataValueTerm","VarOrTermOrEmbTP","iri","VarOrIri","GraphNode","VarOrTerm","GraphTerm","Verb","DataBlockValue","PathPrimary","PathElt","PathEltOrInverse","PathSequence","Path","VerbPath","PathOneInPropertySet","PathNegatedPropertySet","Expression","ConditionalOrExpression","ConditionalAndExpression","RelationalExpression","AdditiveExpression","MultiplicativeExpression","UnaryExpression","PrimaryExpression","iriOrFunction","GraphOrDefault"]),this.setColour(326)}},s.Blocks.sparql11_prefixednamelocalname={init:function(){this.appendDummyInput().appendField(":").appendField(new s.FieldTextInput(""),"localName"),this.setInputsInline(!0),this.setOutput(!0,["EmbSubjectOrObject","DataValueTerm","VarOrTermOrEmbTP","iri","VarOrIri","GraphNode","VarOrTerm","GraphTerm","Verb","DataBlockValue","PathPrimary","PathElt","PathEltOrInverse","PathSequence","Path","VerbPath","PathOneInPropertySet","PathNegatedPropertySet","Expression","ConditionalOrExpression","ConditionalAndExpression","RelationalExpression","AdditiveExpression","MultiplicativeExpression","UnaryExpression","PrimaryExpression","iriOrFunction","GraphOrDefault"]),this.setColour(326)}},s.Blocks.sparql11_prefixednameprefixlocalname={init:function(){this.appendDummyInput().appendField(new s.FieldTextInput(""),"prefix").appendField(":").appendField(new s.FieldTextInput(""),"localName"),this.setInputsInline(!0),this.setOutput(!0,["EmbSubjectOrObject","DataValueTerm","VarOrTermOrEmbTP","iri","VarOrIri","GraphNode","VarOrTerm","GraphTerm","Verb","DataBlockValue","PathPrimary","PathElt","PathEltOrInverse","PathSequence","Path","VerbPath","PathOneInPropertySet","PathNegatedPropertySet","Expression","ConditionalOrExpression","ConditionalAndExpression","RelationalExpression","AdditiveExpression","MultiplicativeExpression","UnaryExpression","PrimaryExpression","iriOrFunction","GraphOrDefault"]),this.setColour(326)}},s.Blocks.sparql11_embtp={init:function(){this.appendValueInput("subject").appendField("<<").setCheck("EmbSubjectOrObject"),this.appendValueInput("predicate").setCheck("Verb"),this.appendValueInput("object").setCheck("EmbSubjectOrObject"),this.appendDummyInput().appendField(">>"),this.setOutput(!0,["GraphNode","GraphNodePath","VarOrTermOrEmbTP","EmbSubjectOrObject","EmbTP","DataBlockValue"]),this.setColour(0)}},s.Blocks.sparql11_iriref={init:function(){this.appendDummyInput().appendField("<").appendField(new s.FieldTextInput(""),"value").appendField(">"),this.setInputsInline(!0),this.setOutput(!0,["EmbSubjectOrObject","DataValueTerm","VarOrTermOrEmbTP","IRIREF","iri","VarOrIri","GraphNode","VarOrTerm","GraphTerm","Verb","DataBlockValue","PathPrimary","PathElt","PathEltOrInverse","PathSequence","Path","VerbPath","PathOneInPropertySet","PathNegatedPropertySet","Expression","ConditionalOrExpression","ConditionalAndExpression","RelationalExpression","AdditiveExpression","MultiplicativeExpression","UnaryExpression","PrimaryExpression","iriOrFunction","GraphOrDefault"]),this.setColour(326)}},s.Blocks.sparql11_irirefdefault={init:function(){this.appendDummyInput().appendField("<>"),this.setInputsInline(!0),this.setOutput(!0,["EmbSubjectOrObject","DataValueTerm","VarOrTermOrEmbTP","IRIREF","iri","VarOrIri","GraphNode","VarOrTerm","GraphTerm","Verb","DataBlockValue","PathPrimary","PathElt","PathEltOrInverse","PathSequence","Path","VerbPath","PathOneInPropertySet","PathNegatedPropertySet","Expression","ConditionalOrExpression","ConditionalAndExpression","RelationalExpression","AdditiveExpression","MultiplicativeExpression","UnaryExpression","PrimaryExpression","iriOrFunction","GraphOrDefault"]),this.setColour(326)}},s.Blocks.sparql11_typedliteral={init:function(){this.appendValueInput("value").setCheck("string"),this.appendValueInput("datatype").appendField("^^").setCheck("iri"),this.setInputsInline(!0),this.setOutput(!0,["EmbSubjectOrObject","DataValueTerm","VarOrTermOrEmbTP","RDFLiteral","GraphNode","VarOrTerm","GraphTerm","DataBlockValue","Expression","ConditionalOrExpression","ConditionalAndExpression","RelationalExpression","AdditiveExpression","MultiplicativeExpression","UnaryExpression","PrimaryExpression"]),this.setColour(163)}},s.Blocks.sparql11_langstring={init:function(){const e=new s.FieldTextInput("");e.setValidator((e=>/^[a-zA-Z]+(-[a-zA-Z0-9]+)*$/.test(e)?e:null)),this.appendValueInput("value").setCheck("string"),this.appendDummyInput().appendField("@").appendField(e,"language"),this.setInputsInline(!0),this.setOutput(!0,["EmbSubjectOrObject","DataValueTerm","VarOrTermOrEmbTP","RDFLiteral","GraphNode","VarOrTerm","GraphTerm","DataBlockValue","Expression","ConditionalOrExpression","ConditionalAndExpression","RelationalExpression","AdditiveExpression","MultiplicativeExpression","UnaryExpression","PrimaryExpression"]),this.setColour(163)}},s.Blocks.sparql11_collection={init:function(){this.appendDummyInput().appendField("("),this.appendStatementInput("items").setCheck("GraphNodeItem"),this.appendDummyInput().appendField(")"),this.setOutput(!0,["Collection","TriplesNode","TriplesSameSubject","GraphNode","Object","TriplesBlock"]),this.setColour(0)}},s.Blocks.sparql11_graphnodeitem={init:function(){this.appendValueInput("value").setCheck("GraphNode"),this.setPreviousStatement(!0,"GraphNodeItem"),this.setNextStatement(!0,"GraphNodeItem"),this.setColour(294)}},s.Blocks.sparql11_anon={init:function(){this.appendDummyInput().appendField("[]"),this.setOutput(!0,["EmbSubjectOrObject","VarOrTermOrEmbTP","BlankNode","GraphTerm","VarOrTerm","GraphNode","Object"]),this.setColour(98)}},s.Blocks.sparql11_blanknodelabel={init:function(){this.appendDummyInput().appendField("_:").appendField(new s.FieldTextInput(""),"value"),this.setInputsInline(!0),this.setOutput(!0,["EmbSubjectOrObject","VarOrTermOrEmbTP","BlankNode","GraphTerm","VarOrTerm","GraphNode"]),this.setColour(98)}},s.Blocks.sparql11_nil={init:function(){this.appendDummyInput().appendField("()"),this.setOutput(!0,["VarOrTermOrEmbTP","NIL","GraphTerm","VarOrTerm","GraphNode","Object"]),this.setColour(98)}},s.Blocks.sparql11_var1={init:function(){this.appendDummyInput().appendField("?").appendField(new s.FieldTextInput("s"),"value"),this.setInputsInline(!1),this.setOutput(!0,["EmbSubjectOrObject","VarOrTermOrEmbTP","Var","VarOrIri","Verb","VarOrTerm","GraphNode","Object","GroupCondition","Expression","ConditionalOrExpression","ConditionalAndExpression","RelationalExpression","AdditiveExpression","MultiplicativeExpression","UnaryExpression","PrimaryExpression"]),this.setColour(33)}},s.Blocks.sparql11_var2={init:function(){this.appendDummyInput().appendField("$").appendField(new s.FieldTextInput("s"),"value"),this.setInputsInline(!1),this.setOutput(!0,["EmbSubjectOrObject","VarOrTermOrEmbTP","Var","VarOrIri","Verb","VarOrTerm","GraphNode","Object","GroupCondition","Expression","ConditionalOrExpression","ConditionalAndExpression","RelationalExpression","AdditiveExpression","MultiplicativeExpression","UnaryExpression","PrimaryExpression"]),this.setColour(33)}},s.Blocks.sparql11_numericliteral={init:function(){const e=new s.FieldTextInput("");e.setValidator((e=>isNaN(parseFloat(e))||!isFinite(e)?null:e)),this.appendDummyInput().appendField(e,"value"),this.setInputsInline(!0),this.setOutput(!0,["EmbSubjectOrObject","DataValueTerm","VarOrTermOrEmbTP","NumericLiteral","RDFLiteral","GraphNode","VarOrTerm","GraphTerm","DataBlockValue","Expression","ConditionalOrExpression","ConditionalAndExpression","RelationalExpression","AdditiveExpression","MultiplicativeExpression","UnaryExpression","PrimaryExpression"]),this.setColour(163)}},s.Blocks.sparql11_booleanliteral={init:function(){this.appendDummyInput().appendField(new s.FieldCheckbox("TRUE"),"value"),this.setInputsInline(!0),this.setOutput(!0,["EmbSubjectOrObject","DataValueTerm","VarOrTermOrEmbTP","RDFLiteral","GraphNode","VarOrTerm","GraphTerm","DataBlockValue","Expression","ConditionalOrExpression","ConditionalAndExpression","RelationalExpression","AdditiveExpression","MultiplicativeExpression","UnaryExpression","PrimaryExpression"]),this.setColour(163)}},s.Blocks.sparql11_string={init:function(){this.appendDummyInput().appendField(new s.FieldMultilineInput(""),"value"),this.setInputsInline(!0),this.setOutput(!0,["EmbSubjectOrObject","DataValueTerm","VarOrTermOrEmbTP","string","RDFLiteral","GraphNode","VarOrTerm","GraphTerm","DataBlockValue","Expression","ConditionalOrExpression","ConditionalAndExpression","RelationalExpression","AdditiveExpression","MultiplicativeExpression","UnaryExpression","PrimaryExpression"]),this.setColour(163)}},s.Blocks.sparql11_varitem={init:function(){this.appendValueInput("value").setCheck("Var"),this.setInputsInline(!1),this.setPreviousStatement(!0,"VarItem"),this.setNextStatement(!0,"VarItem"),this.setColour(65)}}},590:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.blocklyToSparql=t.sparqlToBlockly=void 0,r(930);const s=r(27),a=r(427),i=r(619);t.sparqlToBlockly=function(e){var t;const r=new i.Parser({sparqlStar:!0}).parse(e);return null===(t=(new s.default).visit(r))||void 0===t?void 0:t.xml},t.blocklyToSparql=function(e){return(new a.default).blockToCode(e)}},930:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),r(695),r(368),r(117);const s=r(564),a=r(427);s.Block.prototype.toString=function(){const e=(new a.default).blockToCode(this,!0);return e instanceof Array?e[0]:e},s.COLLAPSE_CHARS=3e3,s.Field.prototype.maxDisplayLength=3e3},117:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const s=r(30);s.property("sparql11_prologueitem","sparql11_base","value","Base"),s.property("sparql11_prologueitem","sparql11_prefixdecl","value","Prefix"),s.property("sparql11_prologueitem","sparql11_prefixdecldefault","value","Default prefix"),s.iriRefs("sparql11_base","value"),s.iriRefs("sparql11_prefixdecl","value"),s.iriRefs("sparql11_prefixdecldefault","value"),s.workspace("Query","sparql11_query"),s.collection("sparql11_query","sparql11_prologueitem","prologue","Prologue"),s.separator("sparql11_query"),s.property("sparql11_query","sparql11_selectquery","value","Select"),s.property("sparql11_query","sparql11_describequery","value","Describe"),s.property("sparql11_query","sparql11_askquery","value","Ask"),s.property("sparql11_query","sparql11_simpleconstructquery","value","Simple construct"),s.property("sparql11_query","sparql11_constructquery","value","Construct"),s.separator("sparql11_query"),s.property("sparql11_query","sparql11_inlinedata","values","Values"),s.property("sparql11_selectquery","sparql11_selectclause","select","Select clause"),s.property("sparql11_selectquery","sparql11_querycommon","where","Where & modifiers"),s.collection("sparql11_simpleconstructquery","sparql11_datasetclause","datasets","From"),s.collection("sparql11_simpleconstructquery","sparql11_triplessamesubjectitem","where","Triples same subject"),s.property("sparql11_simpleconstructquery","sparql11_solutionmodifier","modifiers","Modifiers"),s.collection("sparql11_constructquery","sparql11_triplessamesubjectitem","template","Template item"),s.property("sparql11_constructquery","sparql11_querycommon","where","Where & modifiers"),s.collection("sparql11_describequery","sparql11_varoririitem","subject","Subject"),s.property("sparql11_describequery","sparql11_querycommon","where","Where & modifiers"),s.property("sparql11_askquery","sparql11_querycommon","value","Where & modifiers"),s.varsOrIris("sparql11_varoririitem","value"),s.sameSubjectTriples("sparql11_triplessamesubjectitem","value"),s.workspace("Update","sparql11_update"),s.collection("sparql11_update","sparql11_prologueitem","prologue","Prologue"),s.separator("sparql11_update"),s.collection("sparql11_update","sparql11_updateitem","items","Update"),s.property("sparql11_updateitem","sparql11_insertdeletewhere","value","Insert/delete (data) where"),s.property("sparql11_updateitem","sparql11_modify","value","Modify"),s.property("sparql11_updateitem","sparql11_load","value","Load"),s.property("sparql11_updateitem","sparql11_create","value","Create"),s.property("sparql11_updateitem","sparql11_addmovecopy","value","Add/move/copy"),s.property("sparql11_updateitem","sparql11_cleardrop","value","Clear/drop"),s.property("sparql11_insertdeletewhere","sparql11_quadpattern","pattern","{}"),s.collection("sparql11_quadpattern","sparql11_quadpatternitem","items","Item"),s.sameSubjectTriples("sparql11_quadpatternitem","value"),s.property("sparql11_quadpatternitem","sparql11_quadsnottriples","value","Graph"),s.varsOrIris("sparql11_quadsnottriples","name"),s.separator("sparql11_quadsnottriples"),s.collection("sparql11_quadsnottriples","sparql11_triplessamesubjectitem","triples","Item"),s.iris("sparql11_modify","iri","With"),s.separator("sparql11_modify"),s.property("sparql11_modify","sparql11_quadpattern","delete","{}","Delete"),s.separator("sparql11_modify"),s.property("sparql11_modify","sparql11_quadpattern","insert","{}","Insert"),s.separator("sparql11_modify"),s.collection("sparql11_modify","sparql11_usingclause","using","Using"),s.separator("sparql11_modify"),s.groupGraphPattern("sparql11_modify","where","Where"),s.property("sparql11_usingclause","sparql11_namedgraphclause","value","Named"),s.separator("sparql11_usingclause"),s.iris("sparql11_usingclause","value"),s.iris("sparql11_load","source","Source"),s.separator("sparql11_load"),s.property("sparql11_load","sparql11_graphref","destination","Graph"),s.property("sparql11_create","sparql11_graphref","graph","Graph"),s.updateGraphOrDefault("sparql11_addmovecopy","source","Source"),s.separator("sparql11_addmovecopy"),s.updateGraphOrDefault("sparql11_addmovecopy","destination","Destination"),s.updateGraphRefAll("sparql11_cleardrop","graph"),s.iris("sparql11_graphref","value"),s.graphNodes("sparql11_triplessamesubject","subject","Subject"),s.separator("sparql11_triplessamesubject"),s.collection("sparql11_triplessamesubject","sparql11_propertylistnotempty","predicates","Predicate"),s.verbs("sparql11_propertylistnotempty","predicate","Predicate"),s.separator("sparql11_propertylistnotempty"),s.collection("sparql11_propertylistnotempty","sparql11_objectlistitem","objects","Node","Object"),s.collection("sparql11_propertylistnotempty","sparql11_objectlistitemannotationpattern","objects","Annotation","Object"),s.graphNodes("sparql11_objectlistitem","value"),s.graphNodes("sparql11_objectlistitemannotationpattern","value"),s.separator("sparql11_objectlistitemannotationpattern"),s.collection("sparql11_objectlistitemannotationpattern","sparql11_propertylistnotempty","annotations","Predicate"),s.groupGraphPatternSubs("sparql11_groupgraphpattern","value"),s.property("sparql11_groupgraphpattern","sparql11_groupgraphpatternsub","value","Multiple patterns"),s.property("sparql11_groupgraphpattern","sparql11_subselect","value","Select"),s.property("sparql11_subselect","sparql11_selectclause","select","Select clause"),s.groupGraphPattern("sparql11_subselect","pattern"),s.property("sparql11_subselect","sparql11_solutionmodifier","modifiers","Modifiers"),s.property("sparql11_subselect","sparql11_inlinedata","values","Values"),s.collection("sparql11_groupgraphpatternsub","sparql11_groupgraphpatternsubitem","items","Item"),s.groupGraphPatternSubs("sparql11_groupgraphpatternsubitem","value"),s.varsOrIris("sparql11_graphgraphpattern","iri"),s.separator("sparql11_graphgraphpattern"),s.groupGraphPattern("sparql11_graphgraphpattern","patterns"),s.varsOrIris("sparql11_servicegraphpattern","iri"),s.separator("sparql11_servicegraphpattern"),s.groupGraphPattern("sparql11_servicegraphpattern","patterns"),s.property("sparql11_bind","sparql11_expressionasvar","value","Projection"),s.groupGraphPattern("sparql11_minusgraphpattern","value"),s.collection("sparql11_grouporuniongraphpattern","sparql11_groupgraphpatternitem","items","Item"),s.groupGraphPattern("sparql11_groupgraphpatternitem","value"),s.constraints("sparql11_filter","value"),s.groupGraphPattern("sparql11_optionalgraphpattern","value"),s.property("sparql11_inlinedata","sparql11_inlinedataonevar","value","One var"),s.property("sparql11_inlinedata","sparql11_inlinedatafull","value","Full"),s.vars("sparql11_inlinedataonevar","variable"),s.collection("sparql11_inlinedataonevar","sparql11_datablockvalueitem","values","Value"),s.collection("sparql11_inlinedatafull","sparql11_varitem","variables","Var"),s.collection("sparql11_inlinedatafull","sparql11_datablockvaluesitem","values","Row"),s.vars("sparql11_varitem","value"),s.property("sparql11_datablockvalueitem","sparql11_undef","value","Undefined"),s.terms("sparql11_datablockvalueitem","value"),s.property("sparql11_datablockvalueitem","sparql11_embtp","value","<< >>"),s.collection("sparql11_datablockvaluesitem","sparql11_datablockvalueitem","items","Cell"),s.property("sparql11_negatedpath","sparql11_a","value","a"),s.property("sparql11_negatedpath","sparql11_inversepathoneinpropertyset","value","^"),s.property("sparql11_negatedpath","sparql11_pathoneinpropertysetalternative","value","|"),s.iris("sparql11_negatedpath","value"),s.paths("sparql11_bracketedpath","value"),s.primaryPaths("sparql11_pathwithmodifier","value"),s.eltPaths("sparql11_inversepath","value"),s.collection("sparql11_pathalternative","sparql11_pathalternativeitem","items","Item"),s.collection("sparql11_pathsequence","sparql11_pathsequencitem","items","Item"),s.property("sparql11_inversepathoneinpropertyset","sparql11_a","value","a"),s.iris("sparql11_inversepathoneinpropertyset","value"),s.collection("sparql11_pathoneinpropertysetalternative","sparql11_pathoneinpropertysetalternativeitem","items","Item"),s.eltOrInversePaths("sparql11_pathsequencitem","value"),s.sequencePaths("sparql11_pathalternativeitem","value"),s.property("sparql11_pathoneinpropertysetalternativeitem","sparql11_a","value","a"),s.property("sparql11_pathoneinpropertysetalternativeitem","sparql11_inversepathoneinpropertyset","value","^"),s.iris("sparql11_pathoneinpropertysetalternativeitem","value"),s.collection("sparql11_querycommon","sparql11_datasetclause","datasets","From"),s.groupGraphPattern("sparql11_querycommon","pattern"),s.property("sparql11_querycommon","sparql11_solutionmodifier","modifiers","Modifiers"),s.collection("sparql11_selectclause","sparql11_varorexpressionasvaritem","vars","Var or projection"),s.vars("sparql11_expressionasvar","name","Name"),s.separator("sparql11_expressionasvar"),s.expressions("sparql11_expressionasvar","value"),s.property("sparql11_expressionasvar","sparql11_embtp","value","<< >>"),s.property("sparql11_datasetclause","sparql11_namedgraphclause","value","Named"),s.separator("sparql11_datasetclause"),s.iris("sparql11_datasetclause","value"),s.iris("sparql11_namedgraphclause","value"),s.collection("sparql11_solutionmodifier","sparql11_groupconditionitem","group","Group item"),s.collection("sparql11_solutionmodifier","sparql11_havingconditionitem","having","Having item"),s.collection("sparql11_solutionmodifier","sparql11_orderconditionitem","order","Order item"),s.property("sparql11_solutionmodifier","sparql11_numericliteral","limit","Limit"),s.property("sparql11_solutionmodifier","sparql11_numericliteral","offset","Offset"),s.property("sparql11_ordercondition","sparql11_brackettedexpression","value","()"),s.vars("sparql11_groupconditionitem","value"),s.separator("sparql11_groupconditionitem"),s.property("sparql11_groupconditionitem","sparql11_expressionasvar","value","Projection"),s.separator("sparql11_groupconditionitem"),s.functionExpressions("sparql11_groupconditionitem","value"),s.constraints("sparql11_havingconditionitem","value"),s.property("sparql11_orderconditionitem","sparql11_ordercondition","value","Descending"),s.separator("sparql11_orderconditionitem"),s.vars("sparql11_orderconditionitem","value"),s.separator("sparql11_orderconditionitem"),s.constraints("sparql11_orderconditionitem","value"),s.property("sparql11_varorexpressionasvaritem","sparql11_var1","value","Var"),s.property("sparql11_varorexpressionasvaritem","sparql11_expressionasvar","value","Projection"),s.expressions("sparql11_brackettedexpression","value"),s.unaryExpressions("sparql11_multiplicativeexpression","left","Left"),s.separator("sparql11_multiplicativeexpression"),s.unaryExpressions("sparql11_multiplicativeexpression","right","Right"),s.multiplicativeExpressions("sparql11_additiveexpression","left","Left"),s.separator("sparql11_additiveexpression"),s.multiplicativeExpressions("sparql11_additiveexpression","right","Right"),s.additiveExpressions("sparql11_relationalexpression","left","Left"),s.separator("sparql11_relationalexpression"),s.additiveExpressions("sparql11_relationalexpression","right","Right"),s.collection("sparql11_relationalexpressionin","sparql11_expressionlistitem","right","Item"),s.separator("sparql11_relationalexpressionin"),s.additiveExpressions("sparql11_relationalexpressionin","left"),s.relationalExpressions("sparql11_conditionalandexpression","left","Left"),s.separator("sparql11_conditionalandexpression"),s.relationalExpressions("sparql11_conditionalandexpression","right","Right"),s.andExpressions("sparql11_conditionalorexpression","left","Left"),s.separator("sparql11_conditionalorexpression"),s.andExpressions("sparql11_conditionalorexpression","right","Right"),s.expressions("sparql11_builtincall1","arg1","1"),s.expressions("sparql11_builtincall2","arg1","1"),s.separator("sparql11_builtincall2"),s.expressions("sparql11_builtincall2","arg2","2"),s.expressions("sparql11_builtincall3","arg1","1"),s.separator("sparql11_builtincall3"),s.expressions("sparql11_builtincall3","arg2","2"),s.separator("sparql11_builtincall3"),s.expressions("sparql11_builtincall3","arg3","3"),s.expressions("sparql11_builtincall4","arg1","1"),s.separator("sparql11_builtincall4"),s.expressions("sparql11_builtincall4","arg2","2"),s.separator("sparql11_builtincall4"),s.expressions("sparql11_builtincall4","arg3","3"),s.separator("sparql11_builtincall4"),s.expressions("sparql11_builtincall4","arg4","4"),s.collection("sparql11_builtincalln","sparql11_expressionlistitem","args","Item"),s.collection("sparql11_iriorfunction","sparql11_expressionlistitem","args","Item"),s.separator("sparql11_iriorfunction"),s.iris("sparql11_iriorfunction","iri"),s.groupGraphPattern("sparql11_exists","value"),s.vars("sparql11_bound","value"),s.primaryExpressions("sparql11_unaryexpression","left"),s.expressions("sparql11_aggregate","arg1"),s.expressions("sparql11_count","arg1"),s.property("sparql11_group_concat","sparql11_string","separator","''","Separator"),s.separator("sparql11_group_concat"),s.expressions("sparql11_group_concat","arg1"),s.expressions("sparql11_expressionlistitem","value"),s.collection("sparql11_blanknodepropertylist","sparql11_propertylistnotempty","predicates","Predicate"),s.graphNodes("sparql11_embtp","subject","Subject"),s.separator("sparql11_embtp"),s.verbs("sparql11_embtp","predicate","Predicate"),s.separator("sparql11_embtp"),s.graphNodes("sparql11_embtp","object","Object"),s.property("sparql11_typedliteral","sparql11_string","value","''","Value"),s.separator("sparql11_typedliteral"),s.iris("sparql11_typedliteral","datatype","Datatype"),s.property("sparql11_langstring","sparql11_string","value","''"),s.collection("sparql11_collection","sparql11_graphnodeitem","items","Item"),s.graphNodes("sparql11_graphnodeitem","value")},368:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const s=r(564);s.ContextMenuRegistry.registry.unregister("undoWorkspace"),s.ContextMenuRegistry.registry.unregister("redoWorkspace"),s.ContextMenuRegistry.registry.unregister("cleanWorkspace"),s.ContextMenuRegistry.registry.unregister("expandWorkspace"),s.ContextMenuRegistry.registry.unregister("workspaceDelete"),s.ContextMenuRegistry.registry.unregister("blockDuplicate"),s.ContextMenuRegistry.registry.unregister("blockComment"),s.ContextMenuRegistry.registry.unregister("blockInline"),s.ContextMenuRegistry.registry.unregister("blockDisable"),s.ContextMenuRegistry.registry.unregister("blockDelete"),s.ContextMenuRegistry.registry.unregister("blockHelp")},386:(e,t,r)=>{const s=r(98);class a{constructor(e){if(this.index=new Map,e)for(const[t,r]of e)this.set(t,r)}get size(){return this.index.size}clear(){this.index.clear()}delete(e){return this.index.delete(s(e))}*entries(){for(const[,{term:e,value:t}]of this.index)yield[e,t]}forEach(e,t){for(const r of this.entries())e.call(t,r[1],r[0],this)}get(e){const t=this.index.get(s(e));return t&&t.value}has(e){return this.index.has(s(e))}*keys(){for(const[,{term:e}]of this.index)yield e}set(e,t){const r=s(e);return this.index.set(r,{term:e,value:t}),this}*values(){for(const[,{value:e}]of this.index)yield e}[Symbol.iterator](){return this.entries()[Symbol.iterator]()}}e.exports=a},98:(e,t,r)=>{const s=r(685),a=r(906),i=r(517),n=r(43),o=r(60),p=r(320),l=r(750);e.exports=function e(t){if(!t)return null;if("BlankNode"===t.termType)return s(t);if("DefaultGraph"===t.termType)return i();if("Literal"===t.termType)return n(t);if("NamedNode"===t.termType)return o(t);if("Quad"===t.termType||t.subject&&t.predicate&&t.object&&t.graph)return p(t,e);if("Variable"===t.termType)return l(t);if(t[Symbol.iterator])return a(t,e);throw new Error(`unknown termType ${t.termType}`)}},685:e=>{e.exports=function(e){return"_:"+e.value}},906:e=>{e.exports=function(e,t){return[...e].map((e=>t(e))).join("\n")+"\n"}},517:e=>{e.exports=function(){return""}},43:(e,t,r)=>{const s=r(60),a=/["\\\\\n\r]/,i=/["\\\\\n\r]/g,n={'"':'\\"',"\\":"\\\\","\n":"\\n","\r":"\\r"};function o(e){return n[e]}e.exports=function(e){const t=(r=e.value,a.test(r)?r.replace(i,o):r);var r;return"http://www.w3.org/2001/XMLSchema#string"===e.datatype.value?'"'+t+'"':"http://www.w3.org/1999/02/22-rdf-syntax-ns#langString"===e.datatype.value?'"'+t+'"@'+e.language:'"'+t+'"^^'+s(e.datatype)}},60:e=>{e.exports=function(e){return"<"+e.value+">"}},320:e=>{e.exports=function(e,t){const r=t(e.subject),s=t(e.predicate),a=t(e.object),i=t(e.graph);return`${r} ${s} ${a} ${i?i+" ":""}.`}},750:e=>{e.exports=function(e){return"?"+e.value}},635:(e,t,r)=>{const s=r(480);function a(e){try{return s(e)}catch(e){return null}}class i{constructor(e){if(this.index=new Map,e)for(const t of e)this.add(t)}get size(){return this.index.size}add(e){const t=s(e);return this.index.has(t)||this.index.set(t,e),this}clear(){this.index.clear()}delete(e){return!!e&&this.index.delete(a(e))}entries(){return this.values().entries()}forEach(e,t){return this.values().forEach(e,t)}has(e){return!!e&&this.index.has(a(e))}values(){return new Set(this.index.values())}keys(){return this.values()}[Symbol.iterator](){return this.values()[Symbol.iterator]()}}e.exports=i},480:(e,t,r)=>{const s=r(255),a=r(340),i=r(559),n=r(547),o=r(288),p=r(801),l=r(629);e.exports=function e(t){if(!t)return null;if("BlankNode"===t.termType)return s(t);if("DefaultGraph"===t.termType)return i();if("Literal"===t.termType)return n(t);if("NamedNode"===t.termType)return o(t);if("Quad"===t.termType||t.subject&&t.predicate&&t.object&&t.graph)return p(t,e);if("Variable"===t.termType)return l(t);if(t[Symbol.iterator])return a(t,e);throw new Error(`unknown termType ${t.termType}`)}},255:e=>{e.exports=function(e){return"_:"+e.value}},340:e=>{e.exports=function(e,t){return[...e].map((e=>t(e))).join("\n")+"\n"}},559:e=>{e.exports=function(){return""}},547:(e,t,r)=>{const s=r(288),a=/["\\\\\n\r]/,i=/["\\\\\n\r]/g,n={'"':'\\"',"\\":"\\\\","\n":"\\n","\r":"\\r"};function o(e){return n[e]}e.exports=function(e){const t=(r=e.value,a.test(r)?r.replace(i,o):r);var r;return"http://www.w3.org/2001/XMLSchema#string"===e.datatype.value?'"'+t+'"':"http://www.w3.org/1999/02/22-rdf-syntax-ns#langString"===e.datatype.value?'"'+t+'"@'+e.language:'"'+t+'"^^'+s(e.datatype)}},288:e=>{e.exports=function(e){return"<"+e.value+">"}},801:e=>{e.exports=function(e,t){const r=t(e.subject),s=t(e.predicate),a=t(e.object),i=t(e.graph);return`${r} ${s} ${a} ${i?i+" ":""}.`}},629:e=>{e.exports=function(e){return"?"+e.value}},640:function(e,t,r){"use strict";var s=this&&this.__createBinding||(Object.create?function(e,t,r,s){void 0===s&&(s=r),Object.defineProperty(e,s,{enumerable:!0,get:function(){return t[r]}})}:function(e,t,r,s){void 0===s&&(s=r),e[s]=t[r]}),a=this&&this.__exportStar||function(e,t){for(var r in e)"default"===r||Object.prototype.hasOwnProperty.call(t,r)||s(t,e,r)};Object.defineProperty(t,"__esModule",{value:!0}),a(r(970),t),a(r(498),t),a(r(381),t),a(r(808),t),a(r(16),t),a(r(387),t),a(r(573),t)},970:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.BlankNode=void 0,t.BlankNode=class{constructor(e){this.termType="BlankNode",this.value=e}equals(e){return!!e&&"BlankNode"===e.termType&&e.value===this.value}}},498:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.DataFactory=void 0;const s=r(970),a=r(381),i=r(808),n=r(16),o=r(387),p=r(573);let l=0;t.DataFactory=class{constructor(e){this.blankNodeCounter=0,e=e||{},this.blankNodePrefix=e.blankNodePrefix||`df_${l++}_`}namedNode(e){return new n.NamedNode(e)}blankNode(e){return new s.BlankNode(e||`${this.blankNodePrefix}${this.blankNodeCounter++}`)}literal(e,t){return new i.Literal(e,t)}variable(e){return new p.Variable(e)}defaultGraph(){return a.DefaultGraph.INSTANCE}quad(e,t,r,s){return new o.Quad(e,t,r,s||this.defaultGraph())}fromTerm(e){switch(e.termType){case"NamedNode":return this.namedNode(e.value);case"BlankNode":return this.blankNode(e.value);case"Literal":return e.language?this.literal(e.value,e.language):e.datatype.equals(i.Literal.XSD_STRING)?this.literal(e.value):this.literal(e.value,this.fromTerm(e.datatype));case"Variable":return this.variable(e.value);case"DefaultGraph":return this.defaultGraph();case"Quad":return this.quad(this.fromTerm(e.subject),this.fromTerm(e.predicate),this.fromTerm(e.object),this.fromTerm(e.graph))}}fromQuad(e){return this.fromTerm(e)}resetBlankNodeCounter(){this.blankNodeCounter=0}}},381:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.DefaultGraph=void 0;class r{constructor(){this.termType="DefaultGraph",this.value=""}equals(e){return!!e&&"DefaultGraph"===e.termType}}t.DefaultGraph=r,r.INSTANCE=new r},808:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Literal=void 0;const s=r(16);class a{constructor(e,t){this.termType="Literal",this.value=e,"string"==typeof t?(this.language=t,this.datatype=a.RDF_LANGUAGE_STRING):t?(this.language="",this.datatype=t):(this.language="",this.datatype=a.XSD_STRING)}equals(e){return!!e&&"Literal"===e.termType&&e.value===this.value&&e.language===this.language&&e.datatype.equals(this.datatype)}}t.Literal=a,a.RDF_LANGUAGE_STRING=new s.NamedNode("http://www.w3.org/1999/02/22-rdf-syntax-ns#langString"),a.XSD_STRING=new s.NamedNode("http://www.w3.org/2001/XMLSchema#string")},16:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.NamedNode=void 0,t.NamedNode=class{constructor(e){this.termType="NamedNode",this.value=e}equals(e){return!!e&&"NamedNode"===e.termType&&e.value===this.value}}},387:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Quad=void 0,t.Quad=class{constructor(e,t,r,s){this.termType="Quad",this.value="",this.subject=e,this.predicate=t,this.object=r,this.graph=s}equals(e){return!!e&&("Quad"===e.termType||!e.termType)&&this.subject.equals(e.subject)&&this.predicate.equals(e.predicate)&&this.object.equals(e.object)&&this.graph.equals(e.graph)}}},573:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Variable=void 0,t.Variable=class{constructor(e){this.termType="Variable",this.value=e}equals(e){return!!e&&"Variable"===e.termType&&e.value===this.value}}},404:e=>{function t(e){this._options=e=e||{};var t=e.prefixes||{};this._prefixByIri={};var r=[];for(var s in t){var a=t[s];n(a)&&(this._prefixByIri[a]=s,r.push(a))}var i=r.join("|").replace(/[\]\/\(\)\*\+\?\.\\\$]/g,"\\$&");this._prefixRegex=new RegExp("^("+i+")([a-zA-Z][\\-_a-zA-Z0-9]*)$"),this._usedPrefixes={},this._sparqlStar=e.sparqlStar,this._indent=n(e.indent)?e.indent:" ",this._newline=n(e.newline)?e.newline:"\n",this._explicitDatatype=Boolean(e.explicitDatatype)}t.prototype.toQuery=function(e){var t="";return e.queryType&&(t+=e.queryType.toUpperCase()+" "),e.reduced&&(t+="REDUCED "),e.distinct&&(t+="DISTINCT "),e.variables?t+=l(e.variables,void 0,(function(e){return o(e)?this.toEntity(e):"("+this.toExpression(e.expression)+" AS "+i(e.variable)+")"}),this)+" ":e.template&&(t+=this.group(e.template,!0)+this._newline),e.from&&(t+=this.graphs("FROM ",e.from.default)+this.graphs("FROM NAMED ",e.from.named)),e.where&&(t+="WHERE "+this.group(e.where,!0)+this._newline),e.updates&&(t+=l(e.updates,";"+this._newline,this.toUpdate,this)),e.group&&(t+="GROUP BY "+l(e.group,void 0,(function(e){var t=n(e.expression)?e.expression:"("+this.toExpression(e.expression)+")";return e.variable?"("+t+" AS "+i(e.variable)+")":t}),this)+this._newline),e.having&&(t+="HAVING ("+l(e.having,void 0,this.toExpression,this)+")"+this._newline),e.order&&(t+="ORDER BY "+l(e.order,void 0,(function(e){var t="("+this.toExpression(e.expression)+")";return e.descending?"DESC "+t:t}),this)+this._newline),e.offset&&(t+="OFFSET "+e.offset+this._newline),e.limit&&(t+="LIMIT "+e.limit+this._newline),e.values&&(t+=this.values(e)),(t=this.baseAndPrefixes(e)+t).trim()},t.prototype.baseAndPrefixes=function(e){var t=e.base?"BASE <"+e.base+">"+this._newline:"",r="";for(var s in e.prefixes)(this._options.allPrefixes||this._usedPrefixes[s])&&(r+="PREFIX "+s+": <"+e.prefixes[s]+">"+this._newline);return t+r},t.prototype.toPattern=function(e){var t=e.type||e instanceof Array&&"array"||(e.subject&&e.predicate&&e.object?"triple":"");if(!(t in this))throw new Error("Unknown entry type: "+t);return this[t](e)},t.prototype.triple=function(e){return this.toEntity(e.subject)+" "+this.toEntity(e.predicate)+" "+this.toEntity(e.object)+"."},t.prototype.array=function(e){return l(e,this._newline,this.toPattern,this)},t.prototype.bgp=function(e){return this.encodeTriples(e.triples)},t.prototype.encodeTriples=function(e){if(!e.length)return"";for(var t=[],r=void 0,s=void 0,a=0;a<e.length;a++){var i=e[a];p(i.subject,r)?p(i.predicate,s)?t.push(","):(s=i.predicate,t.push(";"+this._newline,this._indent,this.toEntity(s))):(r&&t.push("."+this._newline),r=i.subject,s=i.predicate,t.push(this.toEntity(r)," ",this.toEntity(s))),t.push(" ",this.toEntity(i.object))}return t.push("."),t.join("")},t.prototype.graph=function(e){return"GRAPH "+this.toEntity(e.name)+" "+this.group(e)},t.prototype.graphs=function(e,t){return t&&0!==t.length?l(t,"",(function(t){return e+this.toEntity(t)+this._newline}),this):""},t.prototype.group=function(e,t){return-1===(e=!0!==t?this.array(e.patterns||e.triples):this.toPattern("group"!==e.type?e:e.patterns)).indexOf(this._newline)?"{ "+e+" }":"{"+this._newline+this.indent(e)+this._newline+"}"},t.prototype.query=function(e){return this.toQuery(e)},t.prototype.filter=function(e){return"FILTER("+this.toExpression(e.expression)+")"},t.prototype.bind=function(e){return"BIND("+this.toExpression(e.expression)+" AS "+i(e.variable)+")"},t.prototype.optional=function(e){return"OPTIONAL "+this.group(e)},t.prototype.union=function(e){return l(e.patterns,this._newline+"UNION"+this._newline,(function(e){return this.group(e,!0)}),this)},t.prototype.minus=function(e){return"MINUS "+this.group(e)},t.prototype.values=function(e){var t,r,s=Object.keys(e.values.reduce((function(e,t){for(var r in t)e[r]=!0;return e}),{}));return 1===s.length?t=r="":(t="(",r=")"),"VALUES "+t+s.join(" ")+r+" {"+this._newline+l(e.values,this._newline,(function(e){return" "+t+l(s,void 0,(function(t){return e[t]?this.toEntity(e[t]):"UNDEF"}),this)+r}),this)+this._newline+"}"},t.prototype.service=function(e){return"SERVICE "+(e.silent?"SILENT ":"")+this.toEntity(e.name)+" "+this.group(e)},t.prototype.toExpression=function(e){if(o(e))return this.toEntity(e);switch(e.type.toLowerCase()){case"aggregate":return e.aggregation.toUpperCase()+"("+(e.distinct?"DISTINCT ":"")+this.toExpression(e.expression)+(e.separator?'; SEPARATOR = "'+e.separator.replace(r,s)+'"':"")+")";case"functioncall":return this.toEntity(e.function)+"("+l(e.args,", ",this.toExpression,this)+")";case"operation":var t=e.operator.toUpperCase(),a=e.args||[];switch(e.operator.toLowerCase()){case"<":case">":case">=":case"<=":case"&&":case"||":case"=":case"!=":case"+":case"-":case"*":case"/":return(o(a[0])?this.toEntity(a[0]):"("+this.toExpression(a[0])+")")+" "+t+" "+(o(a[1])?this.toEntity(a[1]):"("+this.toExpression(a[1])+")");case"!":return"!("+this.toExpression(a[0])+")";case"uminus":return"-("+this.toExpression(a[0])+")";case"notin":t="NOT IN";case"in":return this.toExpression(a[0])+" "+t+"("+(n(a[1])?a[1]:l(a[1],", ",this.toExpression,this))+")";case"notexists":t="NOT EXISTS";case"exists":return t+" "+this.group(a[0],!0);default:return t+"("+l(a,", ",this.toExpression,this)+")"}default:throw new Error("Unknown expression type: "+e.type)}},t.prototype.toEntity=function(e){if(o(e))switch(e.termType){case"Wildcard":return"*";case"Variable":return i(e);case"BlankNode":return"_:"+e.value;case"Literal":var t=e.value||"",a=e.language||"",n=e.datatype;if(e='"'+t.replace(r,s)+'"',a)e+="@"+a;else if(n){if(!this._explicitDatatype)switch(n.value){case"http://www.w3.org/2001/XMLSchema#string":return e;case"http://www.w3.org/2001/XMLSchema#integer":if(/^\d+$/.test(t))return t+" "}e+="^^"+this.encodeIRI(n.value)}return e;case"Quad":if(!this._sparqlStar)throw new Error("SPARQL* support is not enabled");return e.graph&&"DefaultGraph"!==e.graph.termType?"<< GRAPH "+this.toEntity(e.graph)+" { "+this.toEntity(e.subject)+" "+this.toEntity(e.predicate)+" "+this.toEntity(e.object)+" } >>":"<< "+this.toEntity(e.subject)+" "+this.toEntity(e.predicate)+" "+this.toEntity(e.object)+" >>";default:return this.encodeIRI(e.value)}else{var p=e.items.map(this.toEntity,this),l=e.pathType;switch(l){case"^":case"!":return l+p[0];case"*":case"+":case"?":return"("+p[0]+l+")";default:return"("+p.join(l)+")"}}};var r=/["\\\t\n\r\b\f]/g,s=function(e){return a[e]},a={"\\":"\\\\",'"':'\\"',"\t":"\\t","\n":"\\n","\r":"\\r","\b":"\\b","\f":"\\f"};function i(e){return"?"+e.value}function n(e){return"string"==typeof e}function o(e){return"string"==typeof e.termType}function p(e,t){if(!e||!o(e))return!1;if(!t||!o(t))return!1;if(e.termType!==t.termType)return!1;switch(e.termType){case"Literal":return e.value===t.value&&e.language===t.language&&p(e.datatype,t.datatype);case"Quad":return p(e.subject,t.subject)&&p(e.predicate,t.predicate)&&p(e.object,t.object)&&p(e.graph,t.graph);default:return e.value===t.value}}function l(e,t,r,s){return e.map(r,s).join(n(t)?t:" ")}t.prototype.encodeIRI=function(e){var t=this._prefixRegex.exec(e);if(t){var r=this._prefixByIri[t[1]];return this._usedPrefixes[r]=!0,r+":"+t[2]}return"<"+e+">"},t.prototype.toUpdate=function(e){switch(e.type||e.updateType){case"load":return"LOAD"+(e.source?" "+this.toEntity(e.source):"")+(e.destination?" INTO GRAPH "+this.toEntity(e.destination):"");case"insert":return"INSERT DATA "+this.group(e.insert,!0);case"delete":return"DELETE DATA "+this.group(e.delete,!0);case"deletewhere":return"DELETE WHERE "+this.group(e.delete,!0);case"insertdelete":return(e.graph?"WITH "+this.toEntity(e.graph)+this._newline:"")+(e.delete.length?"DELETE "+this.group(e.delete,!0)+this._newline:"")+(e.insert.length?"INSERT "+this.group(e.insert,!0)+this._newline:"")+(e.using?this.graphs("USING ",e.using.default):"")+(e.using?this.graphs("USING NAMED ",e.using.named):"")+"WHERE "+this.group(e.where,!0);case"add":case"copy":case"move":return e.type.toUpperCase()+(e.source.default?" DEFAULT ":" ")+"TO "+this.toEntity(e.destination.name);case"create":case"clear":case"drop":return e.type.toUpperCase()+(e.silent?" SILENT ":" ")+(e.graph.default?"DEFAULT":e.graph.named?"NAMED":e.graph.all?"ALL":"GRAPH "+this.toEntity(e.graph.name));default:throw new Error("Unknown update query type: "+e.type)}},t.prototype.indent=function(e){return e.replace(/^/gm,this._indent)},e.exports=function(e={}){return{stringify:function(r){var s=Object.create(e);return s.prefixes=r.prefixes,new t(s).toQuery(r)},createGenerator:function(){return new t(e)}}}},107:(e,t,r)=>{e=r.nmd(e);var s=function(){var e=function(e,t,r,s){for(r=r||{},s=e.length;s--;r[e[s]]=t);return r},t=[6,12,15,28,41,50,55,107,117,120,122,123,132,133,138,322,323,324,325,326],s=[2,209],a=[107,117,120,122,123,132,133,138,322,323,324,325,326],i=[1,20],n=[1,29],o=[6,90],p=[45,46,58],l=[45,58],u=[1,58],c=[1,60],h=[1,56],d=[1,59],m=[1,65],f=[1,66],y=[26,34,35],E=[13,16,312],g=[119,141,320,327],I=[13,16,119,141,312],C=[1,88],v=[1,92],_=[1,94],b=[119,141,320,321,327],F=[13,16,119,141,312,321],T=[1,100],x=[2,251],k=[1,99],q=[13,16,34,35,87,93,226,231,245,246,299,300,301,302,303,304,305,306,307,308,309,310,311,312],S=[6,45,46,58,68,75,78,86,88,90],D=[6,13,16,34,45,46,58,68,75,78,86,88,90,312],O=[6,13,16,26,34,35,37,38,45,46,48,58,68,75,78,86,87,88,90,93,100,116,119,132,133,135,140,167,168,170,173,174,191,195,219,224,226,227,231,235,245,246,250,254,258,273,278,295,299,300,301,302,303,304,305,306,307,308,309,310,311,312,328,330,331,333,334,335,336,337,338,339,340],N=[34,35,45,46,58],P=[13,16,34,35,87,275,276,277,279,281,282,284,285,288,290,299,300,301,302,303,304,305,306,307,308,309,310,311,312,340,341,342,343,344,345],A=[2,454],w=[1,123],B=[1,117],V=[1,124],R=[1,125],G=[6,13,16,34,35,46,48,87,90,93,119,167,168,170,173,174,226,231,245,246,299,300,301,302,303,304,305,306,307,308,309,310,311,312,328],L=[2,310],U=[1,142],j=[1,140],$=[6,191],M=[2,327],Q=[2,315],H=[45,135],W=[6,48,78,86,88,90],X=[2,255],z=[1,156],Y=[1,158],Z=[6,48,75,78,86,88,90],K=[2,253],J=[1,164],ee=[1,176],te=[1,174],re=[1,184],se=[1,182],ae=[1,175],ie=[1,180],ne=[1,181],oe=[1,185],pe=[1,186],le=[1,189],ue=[1,190],ce=[1,191],he=[1,192],de=[1,193],me=[1,194],fe=[1,195],ye=[1,196],Ee=[1,197],ge=[1,198],Ie=[1,199],Ce=[6,68,75,78,86,88,90],ve=[37,38,191,250,278],_e=[37,38,191,250,254,278],be=[37,38,191,250,254,258,273,278,295,306,307,308,309,310,311,334,335,336,337,338,339,340],Fe=[26,37,38,191,250,254,258,273,278,295,306,307,308,309,310,311,331,334,335,336,337,338,339,340],Te=[1,229],xe=[1,230],ke=[1,232],qe=[1,233],Se=[1,234],De=[1,235],Oe=[1,237],Ne=[1,238],Pe=[2,461],Ae=[1,240],we=[1,241],Be=[1,242],Ve=[1,248],Re=[1,243],Ge=[1,244],Le=[1,245],Ue=[1,246],je=[1,247],$e=[13,16,48,87,100,231,299,300,301,302,303,304,305,306,307,308,309,310,311,312],Me=[48,93],Qe=[34,38],He=[6,116,191],We=[48,119],Xe=[6,48,86,88,90],ze=[2,339],Ye=[2,331],Ze=[1,293],Ke=[1,295],Je=[48,119,328],et=[13,16,34,195,312],tt=[13,16,34,35,38,46,48,87,90,93,119,167,168,170,173,174,191,195,219,224,226,227,231,235,245,246,278,299,300,301,302,303,304,305,306,307,308,309,310,311,312,328],rt=[13,16,26,34,35,37,38,46,48,87,90,93,100,119,167,168,170,173,174,191,195,219,224,226,227,231,235,245,246,250,254,258,273,278,295,299,300,301,302,303,304,305,306,307,308,309,310,311,312,328,331,334,335,336,337,338,339,340],st=[13,16,26,34,35,37,38,46,48,87,90,93,100,119,167,168,170,173,174,191,195,219,224,226,227,231,235,245,246,250,254,258,273,278,295,297,298,299,300,301,302,303,304,305,306,307,308,309,310,311,312,328,331,334,335,336,337,338,339,340],at=[13,16,34,35,87,219,273,275,276,277,279,281,282,284,285,288,290,299,300,301,302,303,304,305,306,307,308,309,310,311,312,334,340,341,342,343,344,345],it=[1,329],nt=[1,330],ot=[1,332],pt=[1,331],lt=[6,13,16,26,34,35,37,38,46,48,75,78,81,83,86,87,88,90,93,119,167,168,170,173,174,191,226,231,245,246,250,254,258,273,275,276,277,278,279,281,282,284,285,288,290,295,299,300,301,302,303,304,305,306,307,308,309,310,311,312,328,331,334,335,336,337,338,339,340,341,342,343,344,345],ut=[1,340],ct=[1,339],ht=[35,93],dt=[1,353],mt=[1,354],ft=[1,367],yt=[6,48,90],Et=[6,13,16,35,48,78,86,88,90,275,276,277,279,281,282,284,285,288,290,312,340,341,342,343,344,345],gt=[6,13,16,34,35,46,48,78,81,83,86,87,88,90,93,119,167,168,170,173,174,226,231,245,246,275,276,277,279,281,282,284,285,288,290,299,300,301,302,303,304,305,306,307,308,309,310,311,312,328,340,341,342,343,344,345],It=[46,48,90,119,167,168,170,173,174],Ct=[1,386],vt=[1,387],_t=[1,393],bt=[1,392],Ft=[48,119,191,227,328],Tt=[13,16,34,35,38,87,93,226,231,245,246,299,300,301,302,303,304,305,306,307,308,309,310,311,312],xt=[13,16,34,35,38,48,87,93,119,191,226,227,231,245,246,278,299,300,301,302,303,304,305,306,307,308,309,310,311,312,328],kt=[13,16,26,34,35,87,219,273,275,276,277,279,281,282,284,285,288,290,299,300,301,302,303,304,305,306,307,308,309,310,311,312,334,340,341,342,343,344,345],qt=[13,16,38,48,87,100,231,299,300,301,302,303,304,305,306,307,308,309,310,311,312],St=[35,48],Dt=[2,330],Ot=[1,451],Nt=[1,448],Pt=[1,449],At=[6,13,16,26,34,35,37,38,46,48,68,75,78,81,83,86,87,88,90,93,119,167,168,170,173,174,191,226,231,245,246,250,254,258,273,275,276,277,278,279,281,282,284,285,288,290,295,299,300,301,302,303,304,305,306,307,308,309,310,311,312,328,329,331,334,335,336,337,338,339,340,341,342,343,344,345],wt=[13,16,35,195,219,224,312],Bt=[2,387],Vt=[1,469],Rt=[46,48,90,119,167,168,170,173,174,328],Gt=[13,16,34,35,195,219,224,312],Lt=[6,13,16,34,35,48,75,78,86,88,90,275,276,277,279,281,282,284,285,288,290,312,340,341,342,343,344,345],Ut=[13,16,34,35,38,48,87,93,119,191,195,226,227,231,245,246,278,299,300,301,302,303,304,305,306,307,308,309,310,311,312,328],jt=[6,13,16,34,35,48,81,83,86,88,90,275,276,277,279,281,282,284,285,288,290,312,340,341,342,343,344,345],$t=[13,16,34,35,46,48,87,90,93,119,167,168,170,173,174,226,231,245,246,299,300,301,302,303,304,305,306,307,308,309,310,311,312],Mt=[13,16,34,312],Qt=[13,16,34,35,46,48,87,90,93,119,167,168,170,173,174,226,231,245,246,299,300,301,302,303,304,305,306,307,308,309,310,311,312,328],Ht=[2,342],Wt=[13,16,34,35,38,46,48,87,90,93,119,167,168,170,173,174,191,226,227,231,245,246,278,299,300,301,302,303,304,305,306,307,308,309,310,311,312,328],Xt=[13,16,34,35,37,38,46,48,87,90,93,119,167,168,170,173,174,191,195,219,224,226,227,231,235,245,246,278,299,300,301,302,303,304,305,306,307,308,309,310,311,312,328],zt=[2,337],Yt=[13,16,35,195,219,312],Zt=[13,16,34,35,38,46,48,87,90,93,119,167,168,170,173,174,191,195,219,224,226,227,231,245,246,278,299,300,301,302,303,304,305,306,307,308,309,310,311,312,328],Kt=[13,16,38,87,100,231,299,300,301,302,303,304,305,306,307,308,309,310,311,312],Jt=[46,48,90,119,167,168,170,173,174,191,227,328],er=[13,16,34,38,48,87,100,195,231,235,299,300,301,302,303,304,305,306,307,308,309,310,311,312],tr=[13,16,34,35,48,87,93,119,226,231,245,246,299,300,301,302,303,304,305,306,307,308,309,310,311,312],rr=[13,16,34,35,38,87,93,226,231,245,246,299,300,301,302,303,304,305,306,307,308,309,310,311,312,330,331],sr=[13,16,26,34,35,38,87,93,226,231,245,246,299,300,301,302,303,304,305,306,307,308,309,310,311,312,330,331,333,334],ar=[1,630],ir=[1,631],nr=[2,325],or=[13,16,38,195,224,312],pr={trace:function(){},yy:{},symbols_:{error:2,QueryOrUpdate:3,Prologue:4,QueryOrUpdate_group0:5,EOF:6,Prologue_repetition0:7,Query:8,Query_group0:9,Query_option0:10,BaseDecl:11,BASE:12,IRIREF:13,PrefixDecl:14,PREFIX:15,PNAME_NS:16,SelectQuery:17,SelectClauseWildcard:18,SelectQuery_repetition0:19,WhereClause:20,SolutionModifierNoGroup:21,SelectClauseVars:22,SelectQuery_repetition1:23,SolutionModifier:24,SelectClauseBase:25,"*":26,SelectClauseVars_repetition_plus0:27,SELECT:28,SelectClauseBase_option0:29,SubSelect:30,SubSelect_option0:31,SubSelect_option1:32,SelectClauseItem:33,VAR:34,"(":35,Expression:36,AS:37,")":38,VarTriple:39,ConstructQuery:40,CONSTRUCT:41,ConstructTemplate:42,ConstructQuery_repetition0:43,ConstructQuery_repetition1:44,WHERE:45,"{":46,ConstructQuery_option0:47,"}":48,DescribeQuery:49,DESCRIBE:50,DescribeQuery_group0:51,DescribeQuery_repetition0:52,DescribeQuery_option0:53,AskQuery:54,ASK:55,AskQuery_repetition0:56,DatasetClause:57,FROM:58,DatasetClause_option0:59,iri:60,WhereClause_option0:61,GroupGraphPattern:62,SolutionModifier_option0:63,SolutionModifierNoGroup_option0:64,SolutionModifierNoGroup_option1:65,SolutionModifierNoGroup_option2:66,GroupClause:67,GROUP:68,BY:69,GroupClause_repetition_plus0:70,GroupCondition:71,BuiltInCall:72,FunctionCall:73,HavingClause:74,HAVING:75,HavingClause_repetition_plus0:76,OrderClause:77,ORDER:78,OrderClause_repetition_plus0:79,OrderCondition:80,ASC:81,BrackettedExpression:82,DESC:83,Constraint:84,LimitOffsetClauses:85,LIMIT:86,INTEGER:87,OFFSET:88,ValuesClause:89,VALUES:90,InlineData:91,InlineData_repetition0:92,NIL:93,InlineData_repetition1:94,InlineData_repetition_plus2:95,InlineData_repetition3:96,DataBlockValue:97,Literal:98,ConstTriple:99,UNDEF:100,DataBlockValueList:101,DataBlockValueList_repetition_plus0:102,Update:103,Update_repetition0:104,Update1:105,Update_option0:106,LOAD:107,Update1_option0:108,Update1_option1:109,Update1_group0:110,Update1_option2:111,GraphRefAll:112,Update1_group1:113,Update1_option3:114,GraphOrDefault:115,TO:116,CREATE:117,Update1_option4:118,GRAPH:119,INSERTDATA:120,QuadPattern:121,DELETEDATA:122,DELETEWHERE:123,Update1_option5:124,InsertClause:125,Update1_option6:126,Update1_repetition0:127,Update1_option7:128,DeleteClause:129,Update1_option8:130,Update1_repetition1:131,DELETE:132,INSERT:133,UsingClause:134,USING:135,UsingClause_option0:136,WithClause:137,WITH:138,IntoGraphClause:139,INTO:140,DEFAULT:141,GraphOrDefault_option0:142,GraphRefAll_group0:143,QuadPattern_option0:144,QuadPattern_repetition0:145,QuadsNotTriples:146,QuadsNotTriples_group0:147,QuadsNotTriples_option0:148,QuadsNotTriples_option1:149,QuadsNotTriples_option2:150,TriplesTemplate:151,TriplesTemplate_repetition0:152,TriplesSameSubject:153,TriplesTemplate_option0:154,GroupGraphPatternSub:155,GroupGraphPatternSub_option0:156,GroupGraphPatternSub_repetition0:157,GroupGraphPatternSubTail:158,GraphPatternNotTriples:159,GroupGraphPatternSubTail_option0:160,GroupGraphPatternSubTail_option1:161,TriplesBlock:162,TriplesBlock_repetition0:163,TriplesSameSubjectPath:164,TriplesBlock_option0:165,GraphPatternNotTriples_repetition0:166,OPTIONAL:167,MINUS:168,GraphPatternNotTriples_group0:169,SERVICE:170,GraphPatternNotTriples_option0:171,GraphPatternNotTriples_group1:172,FILTER:173,BIND:174,FunctionCall_option0:175,FunctionCall_repetition0:176,ExpressionList:177,ExpressionList_repetition0:178,ConstructTemplate_option0:179,ConstructTriples:180,ConstructTriples_repetition0:181,ConstructTriples_option0:182,TriplesSameSubject_group0:183,PropertyListNotEmpty:184,TriplesNode:185,PropertyList:186,PropertyList_option0:187,VerbObjectList:188,PropertyListNotEmpty_repetition0:189,SemiOptionalVerbObjectList:190,";":191,SemiOptionalVerbObjectList_option0:192,Verb:193,ObjectList:194,a:195,ObjectList_repetition0:196,GraphNode:197,ObjectListPath:198,ObjectListPath_repetition0:199,GraphNodePath:200,TriplesSameSubjectPath_group0:201,PropertyListPathNotEmpty:202,TriplesNodePath:203,TriplesSameSubjectPath_option0:204,PropertyListPathNotEmpty_group0:205,PropertyListPathNotEmpty_repetition0:206,PropertyListPathNotEmpty_repetition1:207,PropertyListPathNotEmptyTail:208,PropertyListPathNotEmptyTail_group0:209,Path:210,Path_repetition0:211,PathSequence:212,PathSequence_repetition0:213,PathEltOrInverse:214,PathElt:215,PathPrimary:216,PathElt_option0:217,PathEltOrInverse_option0:218,"!":219,PathNegatedPropertySet:220,PathOneInPropertySet:221,PathNegatedPropertySet_repetition0:222,PathNegatedPropertySet_option0:223,"^":224,TriplesNode_repetition_plus0:225,"[":226,"]":227,TriplesNodePath_repetition_plus0:228,GraphNode_group0:229,GraphNodePath_group0:230,"<<":231,VarTriple_group0:232,VarTriple_group1:233,VarTriple_group2:234,">>":235,VarTriple_group3:236,VarTriple_group4:237,ConstTriple_group0:238,ConstTriple_group1:239,ConstTriple_group2:240,ConstTriple_group3:241,ConstTriple_group4:242,VarOrTerm:243,Term:244,BLANK_NODE_LABEL:245,ANON:246,ConditionalAndExpression:247,Expression_repetition0:248,ExpressionTail:249,"||":250,RelationalExpression:251,ConditionalAndExpression_repetition0:252,ConditionalAndExpressionTail:253,"&&":254,AdditiveExpression:255,RelationalExpression_group0:256,RelationalExpression_option0:257,IN:258,MultiplicativeExpression:259,AdditiveExpression_repetition0:260,AdditiveExpressionTail:261,AdditiveExpressionTail_group0:262,NumericLiteralPositive:263,AdditiveExpressionTail_repetition0:264,NumericLiteralNegative:265,AdditiveExpressionTail_repetition1:266,UnaryExpression:267,MultiplicativeExpression_repetition0:268,MultiplicativeExpressionTail:269,MultiplicativeExpressionTail_group0:270,UnaryExpression_option0:271,PrimaryExpression:272,"-":273,Aggregate:274,FUNC_ARITY0:275,FUNC_ARITY1:276,FUNC_ARITY2:277,",":278,IF:279,BuiltInCall_group0:280,BOUND:281,BNODE:282,BuiltInCall_option0:283,EXISTS:284,COUNT:285,Aggregate_option0:286,Aggregate_group0:287,FUNC_AGGREGATE:288,Aggregate_option1:289,GROUP_CONCAT:290,Aggregate_option2:291,Aggregate_option3:292,GroupConcatSeparator:293,SEPARATOR:294,"=":295,String:296,LANGTAG:297,"^^":298,DECIMAL:299,DOUBLE:300,BOOLEAN:301,STRING_LITERAL1:302,STRING_LITERAL2:303,STRING_LITERAL_LONG1:304,STRING_LITERAL_LONG2:305,INTEGER_POSITIVE:306,DECIMAL_POSITIVE:307,DOUBLE_POSITIVE:308,INTEGER_NEGATIVE:309,DECIMAL_NEGATIVE:310,DOUBLE_NEGATIVE:311,PNAME_LN:312,QueryOrUpdate_group0_option0:313,Prologue_repetition0_group0:314,SelectClauseBase_option0_group0:315,DISTINCT:316,REDUCED:317,DescribeQuery_group0_repetition_plus0_group0:318,DescribeQuery_group0_repetition_plus0:319,NAMED:320,SILENT:321,CLEAR:322,DROP:323,ADD:324,MOVE:325,COPY:326,ALL:327,".":328,UNION:329,"|":330,"/":331,PathElt_option0_group0:332,"?":333,"+":334,"!=":335,"<":336,">":337,"<=":338,">=":339,NOT:340,CONCAT:341,COALESCE:342,SUBSTR:343,REGEX:344,REPLACE:345,$accept:0,$end:1},terminals_:{2:"error",6:"EOF",12:"BASE",13:"IRIREF",15:"PREFIX",16:"PNAME_NS",26:"*",28:"SELECT",34:"VAR",35:"(",37:"AS",38:")",41:"CONSTRUCT",45:"WHERE",46:"{",48:"}",50:"DESCRIBE",55:"ASK",58:"FROM",68:"GROUP",69:"BY",75:"HAVING",78:"ORDER",81:"ASC",83:"DESC",86:"LIMIT",87:"INTEGER",88:"OFFSET",90:"VALUES",93:"NIL",100:"UNDEF",107:"LOAD",116:"TO",117:"CREATE",119:"GRAPH",120:"INSERTDATA",122:"DELETEDATA",123:"DELETEWHERE",132:"DELETE",133:"INSERT",135:"USING",138:"WITH",140:"INTO",141:"DEFAULT",167:"OPTIONAL",168:"MINUS",170:"SERVICE",173:"FILTER",174:"BIND",191:";",195:"a",219:"!",224:"^",226:"[",227:"]",231:"<<",235:">>",245:"BLANK_NODE_LABEL",246:"ANON",250:"||",254:"&&",258:"IN",273:"-",275:"FUNC_ARITY0",276:"FUNC_ARITY1",277:"FUNC_ARITY2",278:",",279:"IF",281:"BOUND",282:"BNODE",284:"EXISTS",285:"COUNT",288:"FUNC_AGGREGATE",290:"GROUP_CONCAT",294:"SEPARATOR",295:"=",297:"LANGTAG",298:"^^",299:"DECIMAL",300:"DOUBLE",301:"BOOLEAN",302:"STRING_LITERAL1",303:"STRING_LITERAL2",304:"STRING_LITERAL_LONG1",305:"STRING_LITERAL_LONG2",306:"INTEGER_POSITIVE",307:"DECIMAL_POSITIVE",308:"DOUBLE_POSITIVE",309:"INTEGER_NEGATIVE",310:"DECIMAL_NEGATIVE",311:"DOUBLE_NEGATIVE",312:"PNAME_LN",316:"DISTINCT",317:"REDUCED",320:"NAMED",321:"SILENT",322:"CLEAR",323:"DROP",324:"ADD",325:"MOVE",326:"COPY",327:"ALL",328:".",329:"UNION",330:"|",331:"/",333:"?",334:"+",335:"!=",336:"<",337:">",338:"<=",339:">=",340:"NOT",341:"CONCAT",342:"COALESCE",343:"SUBSTR",344:"REGEX",345:"REPLACE"},productions_:[0,[3,3],[4,1],[8,2],[11,2],[14,3],[17,4],[17,4],[18,2],[22,2],[25,2],[30,4],[30,4],[33,1],[33,5],[33,5],[40,5],[40,7],[49,5],[54,4],[57,3],[20,2],[24,2],[21,3],[67,3],[71,1],[71,1],[71,3],[71,5],[71,1],[74,2],[77,3],[80,2],[80,2],[80,1],[80,1],[85,2],[85,2],[85,4],[85,4],[89,2],[91,4],[91,4],[91,6],[97,1],[97,1],[97,1],[97,1],[101,3],[103,3],[105,4],[105,3],[105,5],[105,4],[105,2],[105,2],[105,2],[105,6],[105,6],[129,2],[125,2],[134,3],[137,2],[139,3],[115,1],[115,2],[112,2],[112,1],[121,4],[146,7],[151,3],[62,3],[62,3],[155,2],[158,3],[162,3],[159,2],[159,2],[159,2],[159,3],[159,4],[159,2],[159,6],[159,6],[159,1],[84,1],[84,1],[84,1],[73,2],[73,6],[177,1],[177,4],[42,3],[180,3],[153,2],[153,2],[186,1],[184,2],[190,2],[188,2],[193,1],[193,1],[193,1],[194,2],[198,2],[164,2],[164,2],[202,4],[208,1],[208,3],[210,2],[212,2],[215,2],[214,2],[216,1],[216,1],[216,2],[216,3],[220,1],[220,1],[220,4],[221,1],[221,1],[221,2],[221,2],[185,3],[185,3],[203,3],[203,3],[197,1],[197,1],[200,1],[200,1],[39,9],[39,5],[99,9],[99,5],[243,1],[243,1],[244,1],[244,1],[244,1],[244,1],[244,1],[36,2],[249,2],[247,2],[253,2],[251,1],[251,3],[251,4],[255,2],[261,2],[261,2],[261,2],[259,2],[269,2],[267,2],[267,2],[267,2],[272,1],[272,1],[272,1],[272,1],[272,1],[272,1],[82,3],[72,1],[72,2],[72,4],[72,6],[72,8],[72,2],[72,4],[72,2],[72,4],[72,3],[274,5],[274,5],[274,6],[293,4],[98,1],[98,2],[98,3],[98,1],[98,1],[98,1],[98,1],[98,1],[98,1],[296,1],[296,1],[296,1],[296,1],[263,1],[263,1],[263,1],[265,1],[265,1],[265,1],[60,1],[60,1],[60,1],[313,0],[313,1],[5,1],[5,1],[314,1],[314,1],[7,0],[7,2],[9,1],[9,1],[9,1],[9,1],[10,0],[10,1],[19,0],[19,2],[23,0],[23,2],[27,1],[27,2],[315,1],[315,1],[29,0],[29,1],[31,0],[31,1],[32,0],[32,1],[43,0],[43,2],[44,0],[44,2],[47,0],[47,1],[318,1],[318,1],[319,1],[319,2],[51,1],[51,1],[52,0],[52,2],[53,0],[53,1],[56,0],[56,2],[59,0],[59,1],[61,0],[61,1],[63,0],[63,1],[64,0],[64,1],[65,0],[65,1],[66,0],[66,1],[70,1],[70,2],[76,1],[76,2],[79,1],[79,2],[92,0],[92,2],[94,0],[94,2],[95,1],[95,2],[96,0],[96,2],[102,1],[102,2],[104,0],[104,4],[106,0],[106,2],[108,0],[108,1],[109,0],[109,1],[110,1],[110,1],[111,0],[111,1],[113,1],[113,1],[113,1],[114,0],[114,1],[118,0],[118,1],[124,0],[124,1],[126,0],[126,1],[127,0],[127,2],[128,0],[128,1],[130,0],[130,1],[131,0],[131,2],[136,0],[136,1],[142,0],[142,1],[143,1],[143,1],[143,1],[144,0],[144,1],[145,0],[145,2],[147,1],[147,1],[148,0],[148,1],[149,0],[149,1],[150,0],[150,1],[152,0],[152,3],[154,0],[154,1],[156,0],[156,1],[157,0],[157,2],[160,0],[160,1],[161,0],[161,1],[163,0],[163,3],[165,0],[165,1],[166,0],[166,3],[169,1],[169,1],[171,0],[171,1],[172,1],[172,1],[175,0],[175,1],[176,0],[176,3],[178,0],[178,3],[179,0],[179,1],[181,0],[181,3],[182,0],[182,1],[183,1],[183,1],[187,0],[187,1],[189,0],[189,2],[192,0],[192,1],[196,0],[196,3],[199,0],[199,3],[201,1],[201,1],[204,0],[204,1],[205,1],[205,1],[206,0],[206,3],[207,0],[207,2],[209,1],[209,1],[211,0],[211,3],[213,0],[213,3],[332,1],[332,1],[332,1],[217,0],[217,1],[218,0],[218,1],[222,0],[222,3],[223,0],[223,1],[225,1],[225,2],[228,1],[228,2],[229,1],[229,1],[230,1],[230,1],[232,1],[232,1],[233,1],[233,1],[234,1],[234,1],[236,1],[236,1],[237,1],[237,1],[238,1],[238,1],[239,1],[239,1],[240,1],[240,1],[241,1],[241,1],[242,1],[242,1],[248,0],[248,2],[252,0],[252,2],[256,1],[256,1],[256,1],[256,1],[256,1],[256,1],[257,0],[257,1],[260,0],[260,2],[262,1],[262,1],[264,0],[264,2],[266,0],[266,2],[268,0],[268,2],[270,1],[270,1],[271,0],[271,1],[280,1],[280,1],[280,1],[280,1],[280,1],[283,0],[283,1],[286,0],[286,1],[287,1],[287,1],[289,0],[289,1],[291,0],[291,1],[292,0],[292,1]],performAction:function(e,t,r,s,a,i,n){var o,p,l,u,c=i.length-1;switch(a){case 1:if(i[c-1]=i[c-1]||{},ss.base&&(i[c-1].base=ss.base),ss.base="",i[c-1].prefixes=ss.prefixes,ss.prefixes=null,"update"===i[c-1].type){const e={};for(const t of i[c-1].updates)if("insert"===t.updateType){const r={};for(const e of t.insert)if("bgp"===e.type||"graph"===e.type)for(const t of e.triples)"BlankNode"===t.subject.termType&&(r[t.subject.value]=!0),"BlankNode"===t.predicate.termType&&(r[t.predicate.value]=!0),"BlankNode"===t.object.termType&&(r[t.object.value]=!0);for(const t of Object.keys(r)){if(e[t])throw new Error("Detected reuse blank node across different INSERT DATA clauses");e[t]=!0}}}return i[c-1];case 3:this.$=xr(i[c-1],i[c],{type:"query"});break;case 4:ss.base=qr(i[c]);break;case 5:ss.prefixes||(ss.prefixes={}),i[c-1]=i[c-1].substr(0,i[c-1].length-1),i[c]=qr(i[c]),ss.prefixes[i[c-1]]=i[c];break;case 6:this.$=xr(i[c-3],Ar(i[c-2]),i[c-1],i[c]);break;case 7:if(!ss.skipUngroupedVariableCheck&&(Yr(i[c-3].variables.map((e=>Xr(e.expression)))).some((e=>"count"===e.aggregation&&!(e.expression instanceof lr)))||i[c].group))for(const e of i[c-3].variables)if("Variable"===e.termType){if(!i[c].group||!i[c].group.map((e=>Wr(e))).includes(Wr(e)))throw Error("Projection of ungrouped variable (?"+Wr(e)+")")}else if(0===Xr(e.expression).length){const t=zr(e.expression);for(const e of t)if(!i[c].group.map((e=>Wr(e))).includes(Wr(e)))throw Error("Use of ungrouped variable in projection of operation (?"+Wr(e)+")")}const e=i[c-1].where.filter((e=>"query"===e.type));if(e.length>0){const t=i[c-3].variables.filter((e=>e.variable&&e.variable.value)).map((e=>e.variable.value)),r=Yr(e.map((e=>e.variables))).map((e=>e.value||e.variable.value));for(const e of t)if(r.indexOf(e)>=0)throw Error("Target id of 'AS' (?"+e+") already used in subquery")}this.$=xr(i[c-3],Ar(i[c-2]),i[c-1],i[c]);break;case 8:this.$=xr(i[c-1],{variables:[new lr]});break;case 9:const t=function(e){const t=e.slice().sort(),r=[];for(let e=0;e<t.length-1;e++)t[e+1]==t[e]&&r.push(t[e]);return r}(i[c].map((e=>e.value||e.variable.value)));if(t.length>0)throw Error("Two or more of the resulting columns have the same name (?"+t[0]+")");this.$=xr(i[c-1],{variables:i[c]});break;case 10:this.$=xr({queryType:"SELECT"},i[c]&&(i[c-1]=br(i[c]),i[c]={},i[c][i[c-1]]=!0,i[c]));break;case 11:case 12:this.$=xr(i[c-3],i[c-2],i[c-1],i[c],{type:"query"});break;case 13:case 100:case 137:case 165:this.$=Sr(i[c]);break;case 14:case 28:this.$=Or(i[c-3],{variable:Sr(i[c-1])});break;case 15:this.$=Jr(Or(i[c-3],{variable:Sr(i[c-1])}));break;case 16:this.$=xr({queryType:"CONSTRUCT",template:i[c-3]},Ar(i[c-2]),i[c-1],i[c]);break;case 17:this.$=xr({queryType:"CONSTRUCT",template:i[c-2]=i[c-2]?i[c-2].triples:[]},Ar(i[c-5]),{where:[{type:"bgp",triples:Tr([],i[c-2])}]},i[c]);break;case 18:this.$=xr({queryType:"DESCRIBE",variables:"*"===i[c-3]?[new lr]:i[c-3].map(Sr)},Ar(i[c-2]),i[c-1],i[c]);break;case 19:this.$=xr({queryType:"ASK"},Ar(i[c-2]),i[c-1],i[c]);break;case 20:case 61:this.$={iri:i[c],named:!!i[c-1]};break;case 21:this.$={where:i[c].patterns};break;case 22:this.$=xr(i[c-1],i[c]);break;case 23:this.$=xr(i[c-2],i[c-1],i[c]);break;case 24:this.$={group:i[c]};break;case 25:case 26:case 32:case 34:this.$=Or(i[c]);break;case 27:this.$=Or(i[c-1]);break;case 29:case 35:this.$=Or(Sr(i[c]));break;case 30:this.$={having:i[c]};break;case 31:this.$={order:i[c]};break;case 33:this.$=Or(i[c],{descending:!0});break;case 36:this.$={limit:wr(i[c])};break;case 37:this.$={offset:wr(i[c])};break;case 38:this.$={limit:wr(i[c-2]),offset:wr(i[c])};break;case 39:this.$={limit:wr(i[c]),offset:wr(i[c-2])};break;case 40:this.$={type:"values",values:i[c]};break;case 41:this.$=i[c-1].map((function(e){var t={};return t[i[c-3]]=e,t}));break;case 42:this.$=i[c-1].map((function(){return{}}));break;case 43:var h=i[c-4].length;i[c-4]=i[c-4].map(Sr),this.$=i[c-1].map((function(e){if(e.length!==h)throw Error("Inconsistent VALUES length");for(var t={},r=0;r<h;r++)t["?"+i[c-4][r].value]=e[r];return t}));break;case 46:this.$=Jr(i[c]);break;case 47:this.$=void 0;break;case 48:case 92:case 117:case 166:this.$=i[c-1];break;case 49:this.$={type:"update",updates:Fr(i[c-2],i[c-1])};break;case 50:this.$=xr({type:"load",silent:!!i[c-2],source:i[c-1]},i[c]&&{destination:i[c]});break;case 51:this.$={type:br(i[c-2]),silent:!!i[c-1],graph:i[c]};break;case 52:this.$={type:br(i[c-4]),silent:!!i[c-3],source:i[c-2],destination:i[c]};break;case 53:this.$={type:"create",silent:!!i[c-2],graph:{type:"graph",name:i[c]}};break;case 54:this.$={updateType:"insert",insert:es(i[c])};break;case 55:this.$={updateType:"delete",delete:ts(es(i[c]))};break;case 56:this.$={updateType:"deletewhere",delete:ts(i[c])};break;case 57:this.$=xr({updateType:"insertdelete"},i[c-5],{insert:i[c-4]||[]},{delete:i[c-3]||[]},Ar(i[c-2],"using"),{where:i[c].patterns});break;case 58:this.$=xr({updateType:"insertdelete"},i[c-5],{delete:i[c-4]||[]},{insert:i[c-3]||[]},Ar(i[c-2],"using"),{where:i[c].patterns});break;case 59:this.$=ts(i[c]);break;case 60:case 63:case 157:case 180:this.$=i[c];break;case 62:this.$={graph:i[c]};break;case 64:this.$={type:"graph",default:!0};break;case 65:case 66:this.$={type:"graph",name:i[c]};break;case 67:this.$={},this.$[br(i[c])]=!0;break;case 68:this.$=i[c-2]?kr(i[c-1],[i[c-2]]):kr(i[c-1]);break;case 69:var d=xr(i[c-3]||{triples:[]},{type:"graph",name:Sr(i[c-5])});this.$=i[c]?[d,i[c]]:[d];break;case 70:case 75:this.$={type:"bgp",triples:kr(i[c-2],[i[c-1]])};break;case 71:this.$={type:"group",patterns:[i[c-1]]};break;case 72:for(const e of i[c-1].filter((e=>"bind"===e.type))){const t=i[c-1].indexOf(e),r=new Set;for(const e of i[c-1].slice(0,t))"group"!==e.type&&"bgp"!==e.type||Kr(e).forEach((e=>r.add(e)));if(r.has(e.variable.value))throw Error("Variable used to bind is already bound (?"+e.variable.value+")")}this.$={type:"group",patterns:i[c-1]};break;case 73:this.$=i[c-1]?kr([i[c-1]],i[c]):kr(i[c]);break;case 74:this.$=i[c]?[i[c-2],i[c]]:i[c-2];break;case 76:i[c-1].length?this.$={type:"union",patterns:kr(i[c-1].map(Br),[Br(i[c])])}:this.$=i[c];break;case 77:this.$=xr(i[c],{type:"optional"});break;case 78:this.$=xr(i[c],{type:"minus"});break;case 79:this.$=xr(i[c],{type:"graph",name:Sr(i[c-1])});break;case 80:this.$=xr(i[c],{type:"service",name:Sr(i[c-1]),silent:!!i[c-2]});break;case 81:this.$={type:"filter",expression:i[c]};break;case 82:this.$={type:"bind",variable:Sr(i[c-1]),expression:i[c-3]};break;case 83:this.$=Jr({type:"bind",variable:Sr(i[c-1]),expression:i[c-3]});break;case 88:this.$={type:"functionCall",function:i[c-1],args:[]};break;case 89:this.$={type:"functionCall",function:i[c-5],args:Fr(i[c-2],i[c-1]),distinct:!!i[c-3]};break;case 90:case 108:case 119:case 209:case 217:case 219:case 231:case 233:case 243:case 247:case 267:case 269:case 273:case 277:case 300:case 306:case 317:case 327:case 333:case 339:case 343:case 353:case 355:case 359:case 367:case 371:case 373:case 381:case 383:case 387:case 389:case 398:case 430:case 432:case 442:case 446:case 448:case 450:this.$=[];break;case 91:this.$=Fr(i[c-2],i[c-1]);break;case 93:this.$=kr(i[c-2],[i[c-1]]);break;case 94:case 105:this.$=i[c].map((function(e){return xr(Rr(i[c-1]),e)}));break;case 95:this.$=Tr(i[c].map((function(e){return xr(Rr(i[c-1].entity),e)})),i[c-1].triples);break;case 97:this.$=kr([i[c-1]],i[c]);break;case 98:this.$=kr(i[c]);break;case 99:this.$=Hr(i[c-1],i[c]);break;case 102:case 115:case 122:this.$=ss.factory.namedNode(cr);break;case 103:case 104:this.$=Fr(i[c-1],i[c]);break;case 106:this.$=i[c]?Tr(i[c].map((function(e){return xr(Rr(i[c-1].entity),e)})),i[c-1].triples):i[c-1].triples;break;case 107:this.$=Hr(Sr(i[c-3]),Fr(i[c-2],i[c-1]),i[c]);break;case 109:this.$=Hr(Sr(i[c-1]),i[c]);break;case 110:this.$=i[c-1].length?Nr("|",Fr(i[c-1],i[c])):i[c];break;case 111:this.$=i[c-1].length?Nr("/",Fr(i[c-1],i[c])):i[c];break;case 112:this.$=i[c]?Nr(i[c],[i[c-1]]):i[c-1];break;case 113:this.$=i[c-1]?Nr(i[c-1],[i[c]]):i[c];break;case 116:case 123:this.$=Nr(i[c-1],[i[c]]);break;case 120:this.$=Nr("|",Fr(i[c-2],i[c-1]));break;case 124:this.$=Nr(i[c-1],[ss.factory.namedNode(cr)]);break;case 125:case 127:this.$=function(e){var t=Gr(),r=t,s=[],a=[];e.forEach((function(e){s.push(e.entity),Tr(a,e.triples)}));for(var i=0,n=0,o=s.length,p=Array(2*o);i<o;)p[n++]=Rr(r,ss.factory.namedNode(hr),s[i]),p[n++]=Rr(r,ss.factory.namedNode(dr),r=++i<o?Gr():ss.factory.namedNode(mr));return{entity:t,triples:Tr(p,a)}}(i[c-1]);break;case 126:case 128:this.$=(l=i[c-1],{entity:u=Gr(),triples:l.map((function(e){return xr(Rr(u),e)}))});break;case 129:case 131:this.$={entity:i[c],triples:[]};break;case 133:case 135:this.$=Jr(ss.factory.quad(i[c-4],i[c-3],i[c-2],Sr(i[c-6])));break;case 134:case 136:this.$=Jr(ss.factory.quad(i[c-3],i[c-2],i[c-1]));break;case 141:this.$=Gr(i[c].replace(/^(_:)/,""));break;case 142:this.$=Gr();break;case 143:this.$=ss.factory.namedNode(mr);break;case 144:case 146:case 151:case 155:this.$=Pr(i[c-1],i[c]);break;case 145:this.$=["||",i[c]];break;case 147:this.$=["&&",i[c]];break;case 149:this.$=Dr(i[c-1],[i[c-2],i[c]]);break;case 150:this.$=Dr(i[c-2]?"notin":"in",[i[c-3],i[c]]);break;case 152:case 156:this.$=[i[c-1],i[c]];break;case 153:this.$=["+",Pr(i[c-1],i[c])];break;case 154:var m=Vr(i[c-1].value.replace("-",""),i[c-1].datatype);this.$=["-",Pr(m,i[c])];break;case 158:this.$=Dr(i[c-1],[i[c]]);break;case 159:this.$=Dr("UMINUS",[i[c]]);break;case 168:this.$=Dr(br(i[c-1]));break;case 169:this.$=Dr(br(i[c-3]),[i[c-1]]);break;case 170:this.$=Dr(br(i[c-5]),[i[c-3],i[c-1]]);break;case 171:this.$=Dr(br(i[c-7]),[i[c-5],i[c-3],i[c-1]]);break;case 172:this.$=Dr(br(i[c-1]),i[c]);break;case 173:this.$=Dr("bound",[Sr(i[c-1])]);break;case 174:this.$=Dr(i[c-1],[]);break;case 175:this.$=Dr(i[c-3],[i[c-1]]);break;case 176:this.$=Dr(i[c-2]?"notexists":"exists",[Br(i[c])]);break;case 177:case 178:this.$=Or(i[c-1],{type:"aggregate",aggregation:br(i[c-4]),distinct:!!i[c-2]});break;case 179:this.$=Or(i[c-2],{type:"aggregate",aggregation:br(i[c-5]),distinct:!!i[c-3],separator:i[c-1]||" "});break;case 181:this.$=Vr(i[c]);break;case 182:this.$=(o=i[c-1],p=br(i[c].substr(1)),ss.factory.literal(o,p));break;case 183:this.$=Vr(i[c-2],i[c]);break;case 184:case 197:this.$=Vr(i[c],yr);break;case 185:case 198:this.$=Vr(i[c],Er);break;case 186:case 199:this.$=Vr(br(i[c]),gr);break;case 189:this.$=Vr(i[c].toLowerCase(),Ir);break;case 190:case 191:this.$=Qr(i[c],1);break;case 192:case 193:this.$=Qr(i[c],3);break;case 194:this.$=Vr(i[c].substr(1),yr);break;case 195:this.$=Vr(i[c].substr(1),Er);break;case 196:this.$=Vr(i[c].substr(1).toLowerCase(),gr);break;case 200:this.$=ss.factory.namedNode(qr(i[c]));break;case 201:var f=i[c].indexOf(":"),y=i[c].substr(0,f),E=ss.prefixes[y];if(!E)throw new Error("Unknown prefix: "+y);var g=qr(E+i[c].substr(f+1));this.$=ss.factory.namedNode(g);break;case 202:if(i[c]=i[c].substr(0,i[c].length-1),!(i[c]in ss.prefixes))throw new Error("Unknown prefix: "+i[c]);g=qr(ss.prefixes[i[c]]),this.$=ss.factory.namedNode(g);break;case 210:case 218:case 220:case 222:case 232:case 234:case 240:case 244:case 248:case 262:case 264:case 266:case 268:case 270:case 272:case 274:case 276:case 301:case 307:case 318:case 334:case 368:case 384:case 403:case 405:case 431:case 433:case 443:case 447:case 449:case 451:i[c-1].push(i[c]);break;case 221:case 239:case 261:case 263:case 265:case 271:case 275:case 402:case 404:this.$=[i[c]];break;case 278:i[c-3].push(i[c-2]);break;case 328:case 340:case 344:case 354:case 356:case 360:case 372:case 374:case 382:case 388:case 390:case 399:i[c-2].push(i[c-1])}},table:[e(t,s,{3:1,4:2,7:3}),{1:[3]},e(a,[2,277],{5:4,8:5,313:6,9:7,103:8,17:9,40:10,49:11,54:12,104:13,18:14,22:15,25:19,6:[2,203],28:i,41:[1,16],50:[1,17],55:[1,18]}),e([6,28,41,50,55,107,117,120,122,123,132,133,138,322,323,324,325,326],[2,2],{314:21,11:22,14:23,12:[1,24],15:[1,25]}),{6:[1,26]},{6:[2,205]},{6:[2,206]},{6:[2,215],10:27,89:28,90:n},{6:[2,204]},e(o,[2,211]),e(o,[2,212]),e(o,[2,213]),e(o,[2,214]),{105:30,107:[1,31],110:32,113:33,117:[1,34],120:[1,35],122:[1,36],123:[1,37],124:38,128:39,132:[2,302],133:[2,296],137:45,138:[1,46],322:[1,40],323:[1,41],324:[1,42],325:[1,43],326:[1,44]},e(p,[2,217],{19:47}),e(p,[2,219],{23:48}),e(l,[2,233],{42:49,44:50,46:[1,51]}),{13:u,16:c,26:[1,54],34:h,51:52,60:57,312:d,318:55,319:53},e(p,[2,247],{56:61}),{26:[1,62],27:63,33:64,34:m,35:f},e(y,[2,225],{29:67,315:68,316:[1,69],317:[1,70]}),e(t,[2,210]),e(t,[2,207]),e(t,[2,208]),{13:[1,71]},{16:[1,72]},{1:[2,1]},{6:[2,3]},{6:[2,216]},{34:[1,74],35:[1,76],91:73,93:[1,75]},{6:[2,279],106:77,191:[1,78]},e(E,[2,281],{108:79,321:[1,80]}),e(g,[2,287],{111:81,321:[1,82]}),e(I,[2,292],{114:83,321:[1,84]}),{118:85,119:[2,294],321:[1,86]},{46:C,121:87},{46:C,121:89},{46:C,121:90},{125:91,133:v},{129:93,132:_},e(b,[2,285]),e(b,[2,286]),e(F,[2,289]),e(F,[2,290]),e(F,[2,291]),{132:[2,303],133:[2,297]},{13:u,16:c,60:95,312:d},{20:96,45:T,46:x,57:97,58:k,61:98},{20:101,45:T,46:x,57:102,58:k,61:98},e(p,[2,231],{43:103}),{45:[1,104],57:105,58:k},e(q,[2,359],{179:106,180:107,181:108,48:[2,357]}),e(S,[2,243],{52:109}),e(S,[2,241],{60:57,318:110,13:u,16:c,34:h,312:d}),e(S,[2,242]),e(D,[2,239]),e(D,[2,237]),e(D,[2,238]),e(O,[2,200]),e(O,[2,201]),e(O,[2,202]),{20:111,45:T,46:x,57:112,58:k,61:98},e(p,[2,8]),e(p,[2,9],{33:113,34:m,35:f}),e(N,[2,221]),e(N,[2,13]),e(P,A,{36:114,39:115,247:116,251:118,255:119,259:120,267:121,271:122,219:w,231:B,273:V,334:R}),e(y,[2,10]),e(y,[2,226]),e(y,[2,223]),e(y,[2,224]),e(t,[2,4]),{13:[1,126]},e(G,[2,40]),{46:[1,127]},{46:[1,128]},{34:[1,130],95:129},{6:[2,49]},e(t,s,{7:3,4:131}),{13:u,16:c,60:132,312:d},e(E,[2,282]),{112:133,119:[1,134],141:[1,136],143:135,320:[1,137],327:[1,138]},e(g,[2,288]),e(E,L,{115:139,142:141,119:U,141:j}),e(I,[2,293]),{119:[1,143]},{119:[2,295]},e($,[2,54]),e(q,M,{144:144,151:145,152:146,48:Q,119:Q}),e($,[2,55]),e($,[2,56]),e(H,[2,298],{126:147,129:148,132:_}),{46:C,121:149},e(H,[2,304],{130:150,125:151,133:v}),{46:C,121:152},e([132,133],[2,62]),e(W,X,{21:153,64:154,74:155,75:z}),e(p,[2,218]),{46:Y,62:157},e(E,[2,249],{59:159,320:[1,160]}),{46:[2,252]},e(Z,K,{24:161,63:162,67:163,68:J}),e(p,[2,220]),{20:165,45:T,46:x,57:166,58:k,61:98},{46:[1,167]},e(l,[2,234]),{48:[1,168]},{48:[2,358]},{13:u,16:c,34:ee,35:te,39:173,60:178,87:re,93:se,98:179,153:169,183:170,185:171,226:ae,231:B,243:172,244:177,245:ie,246:ne,263:187,265:188,296:183,299:oe,300:pe,301:le,302:ue,303:ce,304:he,305:de,306:me,307:fe,308:ye,309:Ee,310:ge,311:Ie,312:d},e(Ce,[2,245],{61:98,53:200,57:201,20:202,45:T,46:x,58:k}),e(D,[2,240]),e(Z,K,{63:162,67:163,24:203,68:J}),e(p,[2,248]),e(N,[2,222]),{37:[1,204]},{37:[1,205]},e(ve,[2,430],{248:206}),{13:u,16:c,34:ee,39:209,60:178,87:re,93:se,98:179,119:[1,207],231:B,236:208,243:210,244:177,245:ie,246:ne,263:187,265:188,296:183,299:oe,300:pe,301:le,302:ue,303:ce,304:he,305:de,306:me,307:fe,308:ye,309:Ee,310:ge,311:Ie,312:d},e(_e,[2,432],{252:211}),e(_e,[2,148],{256:212,257:213,258:[2,440],295:[1,214],335:[1,215],336:[1,216],337:[1,217],338:[1,218],339:[1,219],340:[1,220]}),e(be,[2,442],{260:221}),e(Fe,[2,450],{268:222}),{13:u,16:c,34:Te,35:xe,60:226,72:225,73:227,82:224,87:re,98:228,263:187,265:188,272:223,274:231,275:ke,276:qe,277:Se,279:De,280:236,281:Oe,282:Ne,283:239,284:Pe,285:Ae,288:we,290:Be,296:183,299:oe,300:pe,301:le,302:ue,303:ce,304:he,305:de,306:me,307:fe,308:ye,309:Ee,310:ge,311:Ie,312:d,340:Ve,341:Re,342:Ge,343:Le,344:Ue,345:je},{13:u,16:c,34:Te,35:xe,60:226,72:225,73:227,82:224,87:re,98:228,263:187,265:188,272:249,274:231,275:ke,276:qe,277:Se,279:De,280:236,281:Oe,282:Ne,283:239,284:Pe,285:Ae,288:we,290:Be,296:183,299:oe,300:pe,301:le,302:ue,303:ce,304:he,305:de,306:me,307:fe,308:ye,309:Ee,310:ge,311:Ie,312:d,340:Ve,341:Re,342:Ge,343:Le,344:Ue,345:je},{13:u,16:c,34:Te,35:xe,60:226,72:225,73:227,82:224,87:re,98:228,263:187,265:188,272:250,274:231,275:ke,276:qe,277:Se,279:De,280:236,281:Oe,282:Ne,283:239,284:Pe,285:Ae,288:we,290:Be,296:183,299:oe,300:pe,301:le,302:ue,303:ce,304:he,305:de,306:me,307:fe,308:ye,309:Ee,310:ge,311:Ie,312:d,340:Ve,341:Re,342:Ge,343:Le,344:Ue,345:je},e(P,[2,455]),e(t,[2,5]),e($e,[2,267],{92:251}),e(Me,[2,269],{94:252}),{34:[1,254],38:[1,253]},e(Qe,[2,271]),e(a,[2,278],{6:[2,280]}),e($,[2,283],{109:255,139:256,140:[1,257]}),e($,[2,51]),{13:u,16:c,60:258,312:d},e($,[2,67]),e($,[2,312]),e($,[2,313]),e($,[2,314]),{116:[1,259]},e(He,[2,64]),{13:u,16:c,60:260,312:d},e(E,[2,311]),{13:u,16:c,60:261,312:d},e(We,[2,317],{145:262}),e(We,[2,316]),{13:u,16:c,34:ee,35:te,39:173,60:178,87:re,93:se,98:179,153:263,183:170,185:171,226:ae,231:B,243:172,244:177,245:ie,246:ne,263:187,265:188,296:183,299:oe,300:pe,301:le,302:ue,303:ce,304:he,305:de,306:me,307:fe,308:ye,309:Ee,310:ge,311:Ie,312:d},e(H,[2,300],{127:264}),e(H,[2,299]),e([45,132,135],[2,60]),e(H,[2,306],{131:265}),e(H,[2,305]),e([45,133,135],[2,59]),e(o,[2,6]),e(Xe,[2,257],{65:266,77:267,78:[1,268]}),e(W,[2,256]),{13:u,16:c,35:xe,60:274,72:272,73:273,76:269,82:271,84:270,274:231,275:ke,276:qe,277:Se,279:De,280:236,281:Oe,282:Ne,283:239,284:Pe,285:Ae,288:we,290:Be,312:d,340:Ve,341:Re,342:Ge,343:Le,344:Ue,345:je},e([6,48,68,75,78,86,88,90],[2,21]),e(q,ze,{25:19,30:275,155:276,18:277,22:278,156:279,162:280,163:281,28:i,46:Ye,48:Ye,90:Ye,119:Ye,167:Ye,168:Ye,170:Ye,173:Ye,174:Ye}),{13:u,16:c,60:282,312:d},e(E,[2,250]),e(o,[2,7]),e(W,X,{64:154,74:155,21:283,75:z}),e(Z,[2,254]),{69:[1,284]},e(Z,K,{63:162,67:163,24:285,68:J}),e(p,[2,232]),e(q,M,{152:146,47:286,151:287,48:[2,235]}),e(p,[2,92]),{48:[2,361],182:288,328:[1,289]},{13:u,16:c,34:Ze,60:294,184:290,188:291,193:292,195:Ke,312:d},e(Je,[2,365],{188:291,193:292,60:294,186:296,187:297,184:298,13:u,16:c,34:Ze,195:Ke,312:d}),e(et,[2,363]),e(et,[2,364]),{13:u,16:c,34:ee,35:te,39:304,60:178,87:re,93:se,98:179,185:302,197:300,225:299,226:ae,229:301,231:B,243:303,244:177,245:ie,246:ne,263:187,265:188,296:183,299:oe,300:pe,301:le,302:ue,303:ce,304:he,305:de,306:me,307:fe,308:ye,309:Ee,310:ge,311:Ie,312:d},{13:u,16:c,34:Ze,60:294,184:305,188:291,193:292,195:Ke,312:d},e(tt,[2,137]),e(tt,[2,138]),e(tt,[2,139]),e(tt,[2,140]),e(tt,[2,141]),e(tt,[2,142]),e(tt,[2,143]),e(rt,[2,181],{297:[1,306],298:[1,307]}),e(rt,[2,184]),e(rt,[2,185]),e(rt,[2,186]),e(rt,[2,187]),e(rt,[2,188]),e(rt,[2,189]),e(st,[2,190]),e(st,[2,191]),e(st,[2,192]),e(st,[2,193]),e(rt,[2,194]),e(rt,[2,195]),e(rt,[2,196]),e(rt,[2,197]),e(rt,[2,198]),e(rt,[2,199]),e(Z,K,{63:162,67:163,24:308,68:J}),e(S,[2,244]),e(Ce,[2,246]),e(o,[2,19]),{34:[1,309]},{34:[1,310]},e([37,38,191,278],[2,144],{249:311,250:[1,312]}),{13:u,16:c,34:[1,314],60:315,232:313,312:d},{13:u,16:c,34:Ze,60:294,193:316,195:Ke,312:d},e(et,[2,416]),e(et,[2,417]),e(ve,[2,146],{253:317,254:[1,318]}),e(P,A,{259:120,267:121,271:122,255:319,219:w,273:V,334:R}),{258:[1,320]},e(at,[2,434]),e(at,[2,435]),e(at,[2,436]),e(at,[2,437]),e(at,[2,438]),e(at,[2,439]),{258:[2,441]},e([37,38,191,250,254,258,278,295,335,336,337,338,339,340],[2,151],{261:321,262:322,263:323,265:324,273:[1,326],306:me,307:fe,308:ye,309:Ee,310:ge,311:Ie,334:[1,325]}),e(be,[2,155],{269:327,270:328,26:it,331:nt}),e(Fe,[2,157]),e(Fe,[2,160]),e(Fe,[2,161]),e(Fe,[2,162],{35:ot,93:pt}),e(Fe,[2,163]),e(Fe,[2,164]),e(Fe,[2,165]),e(P,A,{247:116,251:118,255:119,259:120,267:121,271:122,36:333,219:w,273:V,334:R}),e(lt,[2,167]),{93:[1,334]},{35:[1,335]},{35:[1,336]},{35:[1,337]},{35:ut,93:ct,177:338},{35:[1,341]},{35:[1,343],93:[1,342]},{284:[1,344]},{35:[1,345]},{35:[1,346]},{35:[1,347]},e(ht,[2,456]),e(ht,[2,457]),e(ht,[2,458]),e(ht,[2,459]),e(ht,[2,460]),{284:[2,462]},e(Fe,[2,158]),e(Fe,[2,159]),{13:u,16:c,48:[1,348],60:350,87:re,97:349,98:351,99:352,100:dt,231:mt,263:187,265:188,296:183,299:oe,300:pe,301:le,302:ue,303:ce,304:he,305:de,306:me,307:fe,308:ye,309:Ee,310:ge,311:Ie,312:d},{48:[1,355],93:[1,356]},{46:[1,357]},e(Qe,[2,272]),e($,[2,50]),e($,[2,284]),{119:[1,358]},e($,[2,66]),e(E,L,{142:141,115:359,119:U,141:j}),e(He,[2,65]),e($,[2,53]),{48:[1,360],119:[1,362],146:361},e(We,[2,329],{154:363,328:[1,364]}),{45:[1,365],134:366,135:ft},{45:[1,368],134:369,135:ft},e(yt,[2,259],{66:370,85:371,86:[1,372],88:[1,373]}),e(Xe,[2,258]),{69:[1,374]},e(W,[2,30],{274:231,280:236,283:239,82:271,72:272,73:273,60:274,84:375,13:u,16:c,35:xe,275:ke,276:qe,277:Se,279:De,281:Oe,282:Ne,284:Pe,285:Ae,288:we,290:Be,312:d,340:Ve,341:Re,342:Ge,343:Le,344:Ue,345:je}),e(Et,[2,263]),e(gt,[2,85]),e(gt,[2,86]),e(gt,[2,87]),{35:ot,93:pt},{48:[1,376]},{48:[1,377]},{20:378,45:T,46:x,61:98},{20:379,45:T,46:x,61:98},e(It,[2,333],{157:380}),e(It,[2,332]),{13:u,16:c,34:ee,35:Ct,39:385,60:178,87:re,93:se,98:179,164:381,201:382,203:383,226:vt,231:B,243:384,244:177,245:ie,246:ne,263:187,265:188,296:183,299:oe,300:pe,301:le,302:ue,303:ce,304:he,305:de,306:me,307:fe,308:ye,309:Ee,310:ge,311:Ie,312:d},e(S,[2,20]),e(yt,[2,22]),{13:u,16:c,34:_t,35:bt,60:274,70:388,71:389,72:390,73:391,274:231,275:ke,276:qe,277:Se,279:De,280:236,281:Oe,282:Ne,283:239,284:Pe,285:Ae,288:we,290:Be,312:d,340:Ve,341:Re,342:Ge,343:Le,344:Ue,345:je},e(o,[2,16]),{48:[1,394]},{48:[2,236]},{48:[2,93]},e(q,[2,360],{48:[2,362]}),e(Je,[2,94]),e(Ft,[2,367],{189:395}),e(q,[2,371],{194:396,196:397}),e(q,[2,100]),e(q,[2,101]),e(q,[2,102]),e(Je,[2,95]),e(Je,[2,96]),e(Je,[2,366]),{13:u,16:c,34:ee,35:te,38:[1,398],39:304,60:178,87:re,93:se,98:179,185:302,197:399,226:ae,229:301,231:B,243:303,244:177,245:ie,246:ne,263:187,265:188,296:183,299:oe,300:pe,301:le,302:ue,303:ce,304:he,305:de,306:me,307:fe,308:ye,309:Ee,310:ge,311:Ie,312:d},e(Tt,[2,402]),e(xt,[2,129]),e(xt,[2,130]),e(xt,[2,406]),e(xt,[2,407]),{227:[1,400]},e(rt,[2,182]),{13:u,16:c,60:401,312:d},e(o,[2,18]),{38:[1,402]},{38:[1,403]},e(ve,[2,431]),e(P,A,{251:118,255:119,259:120,267:121,271:122,247:404,219:w,273:V,334:R}),{46:[1,405]},{46:[2,410]},{46:[2,411]},{13:u,16:c,34:ee,39:407,60:178,87:re,93:se,98:179,231:B,237:406,243:408,244:177,245:ie,246:ne,263:187,265:188,296:183,299:oe,300:pe,301:le,302:ue,303:ce,304:he,305:de,306:me,307:fe,308:ye,309:Ee,310:ge,311:Ie,312:d},e(_e,[2,433]),e(P,A,{255:119,259:120,267:121,271:122,251:409,219:w,273:V,334:R}),e(_e,[2,149]),{35:ut,93:ct,177:410},e(be,[2,443]),e(P,A,{267:121,271:122,259:411,219:w,273:V,334:R}),e(Fe,[2,446],{264:412}),e(Fe,[2,448],{266:413}),e(at,[2,444]),e(at,[2,445]),e(Fe,[2,451]),e(P,A,{271:122,267:414,219:w,273:V,334:R}),e(at,[2,452]),e(at,[2,453]),e(lt,[2,88]),e(at,[2,351],{175:415,316:[1,416]}),{38:[1,417]},e(lt,[2,168]),e(P,A,{247:116,251:118,255:119,259:120,267:121,271:122,36:418,219:w,273:V,334:R}),e(P,A,{247:116,251:118,255:119,259:120,267:121,271:122,36:419,219:w,273:V,334:R}),e(P,A,{247:116,251:118,255:119,259:120,267:121,271:122,36:420,219:w,273:V,334:R}),e(lt,[2,172]),e(lt,[2,90]),e(at,[2,355],{178:421}),{34:[1,422]},e(lt,[2,174]),e(P,A,{247:116,251:118,255:119,259:120,267:121,271:122,36:423,219:w,273:V,334:R}),{46:Y,62:424},e(kt,[2,463],{286:425,316:[1,426]}),e(at,[2,467],{289:427,316:[1,428]}),e(at,[2,469],{291:429,316:[1,430]}),e(G,[2,41]),e($e,[2,268]),e(qt,[2,44]),e(qt,[2,45]),e(qt,[2,46]),e(qt,[2,47]),{13:u,16:c,60:178,87:re,93:se,98:179,99:433,119:[1,431],231:mt,241:432,244:434,245:ie,246:ne,263:187,265:188,296:183,299:oe,300:pe,301:le,302:ue,303:ce,304:he,305:de,306:me,307:fe,308:ye,309:Ee,310:ge,311:Ie,312:d},e(G,[2,42]),e(Me,[2,270]),e(St,[2,273],{96:435}),{13:u,16:c,60:436,312:d},e($,[2,52]),e([6,45,132,133,135,191],[2,68]),e(We,[2,318]),{13:u,16:c,34:[1,438],60:439,147:437,312:d},e(We,[2,70]),e(q,[2,328],{48:Dt,119:Dt}),{46:Y,62:440},e(H,[2,301]),e(E,[2,308],{136:441,320:[1,442]}),{46:Y,62:443},e(H,[2,307]),e(yt,[2,23]),e(yt,[2,260]),{87:[1,444]},{87:[1,445]},{13:u,16:c,34:Ot,35:xe,60:274,72:272,73:273,79:446,80:447,81:Nt,82:271,83:Pt,84:450,274:231,275:ke,276:qe,277:Se,279:De,280:236,281:Oe,282:Ne,283:239,284:Pe,285:Ae,288:we,290:Be,312:d,340:Ve,341:Re,342:Ge,343:Le,344:Ue,345:je},e(Et,[2,264]),e(At,[2,71]),e(At,[2,72]),e(W,X,{64:154,74:155,21:452,75:z}),e(Z,K,{63:162,67:163,24:453,68:J}),{46:[2,343],48:[2,73],89:463,90:n,119:[1,459],158:454,159:455,166:456,167:[1,457],168:[1,458],170:[1,460],173:[1,461],174:[1,462]},e(It,[2,341],{165:464,328:[1,465]}),e(wt,Bt,{202:466,205:467,210:468,211:470,34:Vt}),e(Rt,[2,377],{205:467,210:468,211:470,204:471,202:472,13:Bt,16:Bt,35:Bt,195:Bt,219:Bt,224:Bt,312:Bt,34:Vt}),e(Gt,[2,375]),e(Gt,[2,376]),{13:u,16:c,34:ee,35:Ct,39:478,60:178,87:re,93:se,98:179,200:474,203:476,226:vt,228:473,230:475,231:B,243:477,244:177,245:ie,246:ne,263:187,265:188,296:183,299:oe,300:pe,301:le,302:ue,303:ce,304:he,305:de,306:me,307:fe,308:ye,309:Ee,310:ge,311:Ie,312:d},e(wt,Bt,{205:467,210:468,211:470,202:479,34:Vt}),e(Z,[2,24],{274:231,280:236,283:239,60:274,72:390,73:391,71:480,13:u,16:c,34:_t,35:bt,275:ke,276:qe,277:Se,279:De,281:Oe,282:Ne,284:Pe,285:Ae,288:we,290:Be,312:d,340:Ve,341:Re,342:Ge,343:Le,344:Ue,345:je}),e(Lt,[2,261]),e(Lt,[2,25]),e(Lt,[2,26]),e(P,A,{247:116,251:118,255:119,259:120,267:121,271:122,36:481,219:w,273:V,334:R}),e(Lt,[2,29]),e(Z,K,{63:162,67:163,24:482,68:J}),e([48,119,227,328],[2,97],{190:483,191:[1,484]}),e(Ft,[2,99]),{13:u,16:c,34:ee,35:te,39:304,60:178,87:re,93:se,98:179,185:302,197:485,226:ae,229:301,231:B,243:303,244:177,245:ie,246:ne,263:187,265:188,296:183,299:oe,300:pe,301:le,302:ue,303:ce,304:he,305:de,306:me,307:fe,308:ye,309:Ee,310:ge,311:Ie,312:d},e(Ut,[2,125]),e(Tt,[2,403]),e(Ut,[2,126]),e(rt,[2,183]),e(N,[2,14]),e(N,[2,15]),e(ve,[2,145]),{13:u,16:c,34:ee,39:487,60:178,87:re,93:se,98:179,231:B,233:486,243:488,244:177,245:ie,246:ne,263:187,265:188,296:183,299:oe,300:pe,301:le,302:ue,303:ce,304:he,305:de,306:me,307:fe,308:ye,309:Ee,310:ge,311:Ie,312:d},{235:[1,489]},{235:[2,418]},{235:[2,419]},e(_e,[2,147]),e(_e,[2,150]),e(be,[2,152]),e(be,[2,153],{270:328,269:490,26:it,331:nt}),e(be,[2,154],{270:328,269:491,26:it,331:nt}),e(Fe,[2,156]),e(at,[2,353],{176:492}),e(at,[2,352]),e([6,13,16,26,34,35,37,38,46,48,78,81,83,86,87,88,90,93,119,167,168,170,173,174,191,226,231,245,246,250,254,258,273,275,276,277,278,279,281,282,284,285,288,290,295,299,300,301,302,303,304,305,306,307,308,309,310,311,312,328,331,334,335,336,337,338,339,340,341,342,343,344,345],[2,166]),{38:[1,493]},{278:[1,494]},{278:[1,495]},e(P,A,{247:116,251:118,255:119,259:120,267:121,271:122,36:496,219:w,273:V,334:R}),{38:[1,497]},{38:[1,498]},e(lt,[2,176]),e(P,A,{247:116,251:118,255:119,259:120,267:121,271:122,287:499,36:501,26:[1,500],219:w,273:V,334:R}),e(kt,[2,464]),e(P,A,{247:116,251:118,255:119,259:120,267:121,271:122,36:502,219:w,273:V,334:R}),e(at,[2,468]),e(P,A,{247:116,251:118,255:119,259:120,267:121,271:122,36:503,219:w,273:V,334:R}),e(at,[2,470]),{13:u,16:c,34:[1,505],60:506,238:504,312:d},{13:u,16:c,34:Ze,60:294,193:507,195:Ke,312:d},e(et,[2,426]),e(et,[2,427]),{35:[1,510],48:[1,508],101:509},e($,[2,63]),{46:[1,511]},{46:[2,319]},{46:[2,320]},e($,[2,57]),{13:u,16:c,60:512,312:d},e(E,[2,309]),e($,[2,58]),e(yt,[2,36],{88:[1,513]}),e(yt,[2,37],{86:[1,514]}),e(Xe,[2,31],{274:231,280:236,283:239,82:271,72:272,73:273,60:274,84:450,80:515,13:u,16:c,34:Ot,35:xe,81:Nt,83:Pt,275:ke,276:qe,277:Se,279:De,281:Oe,282:Ne,284:Pe,285:Ae,288:we,290:Be,312:d,340:Ve,341:Re,342:Ge,343:Le,344:Ue,345:je}),e(jt,[2,265]),{35:xe,82:516},{35:xe,82:517},e(jt,[2,34]),e(jt,[2,35]),{31:518,48:[2,227],89:519,90:n},{32:520,48:[2,229],89:521,90:n},e(It,[2,334]),e($t,[2,335],{160:522,328:[1,523]}),{46:Y,62:524},{46:Y,62:525},{46:Y,62:526},{13:u,16:c,34:[1,528],60:529,169:527,312:d},e(Mt,[2,347],{171:530,321:[1,531]}),{13:u,16:c,35:xe,60:274,72:272,73:273,82:271,84:532,274:231,275:ke,276:qe,277:Se,279:De,280:236,281:Oe,282:Ne,283:239,284:Pe,285:Ae,288:we,290:Be,312:d,340:Ve,341:Re,342:Ge,343:Le,344:Ue,345:je},{35:[1,533]},e(Qt,[2,84]),e(It,[2,75]),e(q,[2,340],{46:Ht,48:Ht,90:Ht,119:Ht,167:Ht,168:Ht,170:Ht,173:Ht,174:Ht}),e(Rt,[2,105]),e(q,[2,381],{206:534}),e(q,[2,379]),e(q,[2,380]),e(wt,[2,389],{212:535,213:536}),e(Rt,[2,106]),e(Rt,[2,378]),{13:u,16:c,34:ee,35:Ct,38:[1,537],39:478,60:178,87:re,93:se,98:179,200:538,203:476,226:vt,230:475,231:B,243:477,244:177,245:ie,246:ne,263:187,265:188,296:183,299:oe,300:pe,301:le,302:ue,303:ce,304:he,305:de,306:me,307:fe,308:ye,309:Ee,310:ge,311:Ie,312:d},e(Tt,[2,404]),e(Wt,[2,131]),e(Wt,[2,132]),e(Wt,[2,408]),e(Wt,[2,409]),{227:[1,539]},e(Lt,[2,262]),{37:[1,541],38:[1,540]},e(o,[2,17]),e(Ft,[2,368]),e(Ft,[2,369],{193:292,60:294,192:542,188:543,13:u,16:c,34:Ze,195:Ke,312:d}),e(Ft,[2,103],{278:[1,544]}),{13:u,16:c,34:Ze,60:294,193:545,195:Ke,312:d},e(et,[2,412]),e(et,[2,413]),e(Xt,[2,134]),e(Fe,[2,447]),e(Fe,[2,449]),e(P,A,{247:116,251:118,255:119,259:120,267:121,271:122,36:546,219:w,273:V,334:R}),e(lt,[2,169]),e(P,A,{247:116,251:118,255:119,259:120,267:121,271:122,36:547,219:w,273:V,334:R}),e(P,A,{247:116,251:118,255:119,259:120,267:121,271:122,36:548,219:w,273:V,334:R}),{38:[1,549],278:[1,550]},e(lt,[2,173]),e(lt,[2,175]),{38:[1,551]},{38:[2,465]},{38:[2,466]},{38:[1,552]},{38:[2,471],191:[1,555],292:553,293:554},{46:[1,556]},{46:[2,420]},{46:[2,421]},{13:u,16:c,60:178,87:re,93:se,98:179,99:558,231:mt,242:557,244:559,245:ie,246:ne,263:187,265:188,296:183,299:oe,300:pe,301:le,302:ue,303:ce,304:he,305:de,306:me,307:fe,308:ye,309:Ee,310:ge,311:Ie,312:d},e(G,[2,43]),e(St,[2,274]),{13:u,16:c,60:350,87:re,97:561,98:351,99:352,100:dt,102:560,231:mt,263:187,265:188,296:183,299:oe,300:pe,301:le,302:ue,303:ce,304:he,305:de,306:me,307:fe,308:ye,309:Ee,310:ge,311:Ie,312:d},e(q,M,{152:146,148:562,151:563,48:[2,321]}),e(H,[2,61]),{87:[1,564]},{87:[1,565]},e(jt,[2,266]),e(jt,[2,32]),e(jt,[2,33]),{48:[2,11]},{48:[2,228]},{48:[2,12]},{48:[2,230]},e(q,ze,{163:281,161:566,162:567,46:zt,48:zt,90:zt,119:zt,167:zt,168:zt,170:zt,173:zt,174:zt}),e($t,[2,336]),e(Qt,[2,76],{329:[1,568]}),e(Qt,[2,77]),e(Qt,[2,78]),{46:Y,62:569},{46:[2,345]},{46:[2,346]},{13:u,16:c,34:[1,571],60:572,172:570,312:d},e(Mt,[2,348]),e(Qt,[2,81]),e(P,A,{247:116,251:118,255:119,259:120,267:121,271:122,36:573,39:574,219:w,231:B,273:V,334:R}),{13:u,16:c,34:ee,35:Ct,39:478,60:178,87:re,93:se,98:179,200:575,203:476,226:vt,230:475,231:B,243:477,244:177,245:ie,246:ne,263:187,265:188,296:183,299:oe,300:pe,301:le,302:ue,303:ce,304:he,305:de,306:me,307:fe,308:ye,309:Ee,310:ge,311:Ie,312:d},e(Tt,[2,110],{330:[1,576]}),e(Yt,[2,396],{214:577,218:578,224:[1,579]}),e(Zt,[2,127]),e(Tt,[2,405]),e(Zt,[2,128]),e(Lt,[2,27]),{34:[1,580]},e(Ft,[2,98]),e(Ft,[2,370]),e(q,[2,372]),{13:u,16:c,34:ee,39:582,60:178,87:re,93:se,98:179,231:B,234:581,243:583,244:177,245:ie,246:ne,263:187,265:188,296:183,299:oe,300:pe,301:le,302:ue,303:ce,304:he,305:de,306:me,307:fe,308:ye,309:Ee,310:ge,311:Ie,312:d},{38:[1,584],278:[1,585]},{38:[1,586]},{278:[1,587]},e(lt,[2,91]),e(at,[2,356]),e(lt,[2,177]),e(lt,[2,178]),{38:[1,588]},{38:[2,472]},{294:[1,589]},{13:u,16:c,60:178,87:re,93:se,98:179,99:591,231:mt,239:590,244:592,245:ie,246:ne,263:187,265:188,296:183,299:oe,300:pe,301:le,302:ue,303:ce,304:he,305:de,306:me,307:fe,308:ye,309:Ee,310:ge,311:Ie,312:d},{235:[1,593]},{235:[2,428]},{235:[2,429]},{13:u,16:c,38:[1,594],60:350,87:re,97:595,98:351,99:352,100:dt,231:mt,263:187,265:188,296:183,299:oe,300:pe,301:le,302:ue,303:ce,304:he,305:de,306:me,307:fe,308:ye,309:Ee,310:ge,311:Ie,312:d},e(Kt,[2,275]),{48:[1,596]},{48:[2,322]},e(yt,[2,38]),e(yt,[2,39]),e(It,[2,74]),e(It,[2,338]),{46:[2,344]},e(Qt,[2,79]),{46:Y,62:597},{46:[2,349]},{46:[2,350]},{37:[1,598]},{37:[1,599]},e(Jt,[2,383],{207:600,278:[1,601]}),e(wt,[2,388]),e([13,16,34,35,38,87,93,226,231,245,246,299,300,301,302,303,304,305,306,307,308,309,310,311,312,330],[2,111],{331:[1,602]}),{13:u,16:c,35:[1,608],60:605,195:[1,606],215:603,216:604,219:[1,607],312:d},e(Yt,[2,397]),{38:[1,609]},{48:[1,610]},{48:[2,414]},{48:[2,415]},e(lt,[2,89]),e(at,[2,354]),e(lt,[2,170]),e(P,A,{247:116,251:118,255:119,259:120,267:121,271:122,36:611,219:w,273:V,334:R}),e(lt,[2,179]),{295:[1,612]},{13:u,16:c,34:Ze,60:294,193:613,195:Ke,312:d},e(et,[2,422]),e(et,[2,423]),e(er,[2,136]),e(St,[2,48]),e(Kt,[2,276]),e(tr,[2,323],{149:614,328:[1,615]}),e(Qt,[2,80]),{34:[1,616]},{34:[1,617]},e([46,48,90,119,167,168,170,173,174,227,328],[2,107],{208:618,191:[1,619]}),e(q,[2,382]),e(wt,[2,390]),e(rr,[2,113]),e(rr,[2,394],{217:620,332:621,26:[1,623],333:[1,622],334:[1,624]}),e(sr,[2,114]),e(sr,[2,115]),{13:u,16:c,35:[1,628],60:629,93:[1,627],195:ar,220:625,221:626,224:ir,312:d},e(wt,Bt,{211:470,210:632}),e(Lt,[2,28]),{235:[1,633]},{38:[1,634]},{296:635,302:ue,303:ce,304:he,305:de},{13:u,16:c,60:178,87:re,93:se,98:179,99:637,231:mt,240:636,244:638,245:ie,246:ne,263:187,265:188,296:183,299:oe,300:pe,301:le,302:ue,303:ce,304:he,305:de,306:me,307:fe,308:ye,309:Ee,310:ge,311:Ie,312:d},e(q,M,{152:146,150:639,151:640,48:nr,119:nr}),e(tr,[2,324]),{38:[1,641]},{38:[1,642]},e(Jt,[2,384]),e(Jt,[2,108],{211:470,209:643,210:644,13:Bt,16:Bt,35:Bt,195:Bt,219:Bt,224:Bt,312:Bt,34:[1,645]}),e(rr,[2,112]),e(rr,[2,395]),e(rr,[2,391]),e(rr,[2,392]),e(rr,[2,393]),e(sr,[2,116]),e(sr,[2,118]),e(sr,[2,119]),e(or,[2,398],{222:646}),e(sr,[2,121]),e(sr,[2,122]),{13:u,16:c,60:647,195:[1,648],312:d},{38:[1,649]},e(Xt,[2,133]),e(lt,[2,171]),{38:[2,180]},{48:[1,650]},{48:[2,424]},{48:[2,425]},e(We,[2,69]),e(We,[2,326]),e(Qt,[2,82]),e(Qt,[2,83]),e(q,[2,373],{198:651,199:652}),e(q,[2,385]),e(q,[2,386]),{13:u,16:c,38:[2,400],60:629,195:ar,221:654,223:653,224:ir,312:d},e(sr,[2,123]),e(sr,[2,124]),e(sr,[2,117]),{235:[1,655]},e(Jt,[2,109]),{13:u,16:c,34:ee,35:Ct,39:478,60:178,87:re,93:se,98:179,200:656,203:476,226:vt,230:475,231:B,243:477,244:177,245:ie,246:ne,263:187,265:188,296:183,299:oe,300:pe,301:le,302:ue,303:ce,304:he,305:de,306:me,307:fe,308:ye,309:Ee,310:ge,311:Ie,312:d},{38:[1,657]},{38:[2,401],330:[1,658]},e(er,[2,135]),e(Jt,[2,104],{278:[1,659]}),e(sr,[2,120]),e(or,[2,399]),e(q,[2,374])],defaultActions:{5:[2,205],6:[2,206],8:[2,204],26:[2,1],27:[2,3],28:[2,216],77:[2,49],86:[2,295],100:[2,252],107:[2,358],220:[2,441],248:[2,462],287:[2,236],288:[2,93],314:[2,410],315:[2,411],407:[2,418],408:[2,419],438:[2,319],439:[2,320],500:[2,465],501:[2,466],505:[2,420],506:[2,421],518:[2,11],519:[2,228],520:[2,12],521:[2,230],528:[2,345],529:[2,346],554:[2,472],558:[2,428],559:[2,429],563:[2,322],568:[2,344],571:[2,349],572:[2,350],582:[2,414],583:[2,415],635:[2,180],637:[2,424],638:[2,425]},parseError:function(e,t){if(!t.recoverable){var r=new Error(e);throw r.hash=t,r}this.trace(e)},parse:function(e){var t=this,r=[0],s=[null],a=[],i=this.table,n="",o=0,p=0,l=0,u=2,c=1,h=a.slice.call(arguments,1),d=Object.create(this.lexer),m={yy:{}};for(var f in this.yy)Object.prototype.hasOwnProperty.call(this.yy,f)&&(m.yy[f]=this.yy[f]);d.setInput(e,m.yy),m.yy.lexer=d,m.yy.parser=this,void 0===d.yylloc&&(d.yylloc={});var y=d.yylloc;a.push(y);var E=d.options&&d.options.ranges;"function"==typeof m.yy.parseError?this.parseError=m.yy.parseError:this.parseError=Object.getPrototypeOf(this).parseError;for(var g,I,C,v,_,b,F,T,x,k=function(){var e;return"number"!=typeof(e=d.lex()||c)&&(e=t.symbols_[e]||e),e},q={};;){if(C=r[r.length-1],this.defaultActions[C]?v=this.defaultActions[C]:(null==g&&(g=k()),v=i[C]&&i[C][g]),void 0===v||!v.length||!v[0]){var S="";for(b in x=[],i[C])this.terminals_[b]&&b>u&&x.push("'"+this.terminals_[b]+"'");S=d.showPosition?"Parse error on line "+(o+1)+":\n"+d.showPosition()+"\nExpecting "+x.join(", ")+", got '"+(this.terminals_[g]||g)+"'":"Parse error on line "+(o+1)+": Unexpected "+(g==c?"end of input":"'"+(this.terminals_[g]||g)+"'"),this.parseError(S,{text:d.match,token:this.terminals_[g]||g,line:d.yylineno,loc:y,expected:x})}if(v[0]instanceof Array&&v.length>1)throw new Error("Parse Error: multiple actions possible at state: "+C+", token: "+g);switch(v[0]){case 1:r.push(g),s.push(d.yytext),a.push(d.yylloc),r.push(v[1]),g=null,I?(g=I,I=null):(p=d.yyleng,n=d.yytext,o=d.yylineno,y=d.yylloc,l>0&&l--);break;case 2:if(F=this.productions_[v[1]][1],q.$=s[s.length-F],q._$={first_line:a[a.length-(F||1)].first_line,last_line:a[a.length-1].last_line,first_column:a[a.length-(F||1)].first_column,last_column:a[a.length-1].last_column},E&&(q._$.range=[a[a.length-(F||1)].range[0],a[a.length-1].range[1]]),void 0!==(_=this.performAction.apply(q,[n,p,o,m.yy,v[1],s,a].concat(h))))return _;F&&(r=r.slice(0,-1*F*2),s=s.slice(0,-1*F),a=a.slice(0,-1*F)),r.push(this.productions_[v[1]][0]),s.push(q.$),a.push(q._$),T=i[r[r.length-2]][r[r.length-1]],r.push(T);break;case 3:return!0}}return!0}},lr=r(348).R,ur="http://www.w3.org/1999/02/22-rdf-syntax-ns#",cr=ur+"type",hr=ur+"first",dr=ur+"rest",mr=ur+"nil",fr="http://www.w3.org/2001/XMLSchema#",yr=fr+"integer",Er=fr+"decimal",gr=fr+"double",Ir=fr+"boolean",Cr="",vr="",_r="";function br(e){return e.toLowerCase()}function Fr(e,t){return e.push(t),e}function Tr(e,t){return e.push.apply(e,t),e}function xr(e){e||(e={});for(var t,r=1,s=arguments.length;r<s&&(t=arguments[r]||{});r++)for(var a in t)e[a]=t[a];return e}function kr(){for(var e=[],t=0,r=arguments.length;t<r;t++)e=e.concat.apply(e,arguments[t]);return e}function qr(e){if("<"===e[0]&&(e=e.substring(1,e.length-1)),/^[a-z]+:/i.test(e))return e;if(!ss.base)throw new Error("Cannot resolve relative IRI "+e+" because no base IRI was set.");switch(Cr!==ss.base&&(Cr=ss.base,vr=Cr.replace(/[^\/:]*$/,""),_r=Cr.match(/^(?:[a-z]+:\/*)?[^\/]*/)[0]),e[0]){case void 0:return Cr;case"#":return Cr+e;case"?":return Cr.replace(/(?:\?.*)?$/,e);case"/":return _r+e;default:return vr+e}}function Sr(e){if(e){var t=e[0];if("?"===t||"$"===t)return ss.factory.variable(e.substr(1))}return e}function Dr(e,t){return{type:"operation",operator:e,args:t||[]}}function Or(e,t){var r={expression:"*"===e?new lr:e};if(t)for(var s in t)r[s]=t[s];return r}function Nr(e,t){return{type:"path",pathType:e,items:t}}function Pr(e,t){for(var r,s=0,a=t.length;s<a&&(r=t[s]);s++)e=Dr(r[0],[e,r[1]]);return e}function Ar(e,t){var r,s=[],a=[],i=e.length,n={};if(!i)return null;for(var o=0;o<i&&(r=e[o]);o++)(r.named?a:s).push(r.iri);return n[t||"from"]={default:s,named:a},n}function wr(e){return parseInt(e,10)}function Br(e){return"group"===e.type&&1===e.patterns.length?e.patterns[0]:e}function Vr(e,t){return t&&"NamedNode"!==t.termType&&(t=ss.factory.namedNode(t)),ss.factory.literal(e,t)}function Rr(e,t,r){var s={};return null!=e&&(s.subject=e),null!=t&&(s.predicate=t),null!=r&&(s.object=r),s}function Gr(e){return"string"==typeof e?e.startsWith("e_")?ss.factory.blankNode(e):ss.factory.blankNode("e_"+e):ss.factory.blankNode("g_"+Lr++)}var Lr=0;ss._resetBlanks=function(){Lr=0};var Ur=/\\u([a-fA-F0-9]{4})|\\U([a-fA-F0-9]{8})|\\(.)/g,jr={"\\":"\\","'":"'",'"':'"',t:"\t",b:"\b",n:"\n",r:"\r",f:"\f"},$r=/[\uD800-\uDBFF]([^\uDC00-\uDFFF]|$)/,Mr=String.fromCharCode;function Qr(e,t){e=e.substring(t,e.length-t);try{e=e.replace(Ur,(function(e,t,r,s){var a;if(t){if(a=parseInt(t,16),isNaN(a))throw new Error;return Mr(a)}if(r){if(a=parseInt(r,16),isNaN(a))throw new Error;return a<65535?Mr(a):Mr(55296+((a-=65536)>>10),56320+(1023&a))}var i=jr[s];if(!i)throw new Error;return i}))}catch(e){return""}if($r.exec(e))throw new Error("Invalid unicode codepoint of surrogate pair without corresponding codepoint in "+e);return e}function Hr(e,t,r){var s=[],a=[];return t.forEach((function(t){s.push(Rr(null,e,t.entity)),Tr(a,t.triples)})),kr(s,r||[],a)}function Wr(e){return e.variable?e.variable.value:e.value||e.expression.value}function Xr(e){if(!e)return[];if("aggregate"===e.type)return[e];if("operation"===e.type){const t=[];for(const r of e.args)t.push(...Xr(r));return t}return[]}function zr(e){const t=new Set,r=function(e){e&&("Variable"===e.termType?t.add(e):"operation"===e.type&&e.args.forEach(r))};return r(e),t}function Yr(e,t=1,r=[]){for(const s of e)t>0&&s instanceof Array?Yr(s,t-1,r):r.push(s);return r}function Zr(e){return"Variable"===e.termType}function Kr(e){if(e.triples){const t=[];for(const r of e.triples)Zr(r.subject)&&t.push(r.subject.value),Zr(r.predicate)&&t.push(r.predicate.value),Zr(r.object)&&t.push(r.object.value);return t}if(e.patterns){const t=[];for(const r of e.patterns)t.push(...Kr(r));return t}return[]}function Jr(e){if(!ss.sparqlStar)throw new Error("SPARQL* support is not enabled");return e}function es(e){for(const t of e){if("graph"===t.type&&"Variable"===t.name.termType)throw new Error("Detected illegal variable in GRAPH");if("bgp"===t.type||"graph"===t.type)for(const e of t.triples)if("Variable"===e.subject.termType||"Variable"===e.predicate.termType||"Variable"===e.object.termType)throw new Error("Detected illegal variable in BGP")}return e}function ts(e){for(const t of e)if("bgp"===t.type)for(const e of t.triples)if("BlankNode"===e.subject.termType||"BlankNode"===e.predicate.termType||"BlankNode"===e.object.termType)throw new Error("Detected illegal blank node in BGP");return e}var rs={EOF:1,parseError:function(e,t){if(!this.yy.parser)throw new Error(e);this.yy.parser.parseError(e,t)},setInput:function(e,t){return this.yy=t||this.yy||{},this._input=e,this._more=this._backtrack=this.done=!1,this.yylineno=this.yyleng=0,this.yytext=this.matched=this.match="",this.conditionStack=["INITIAL"],this.yylloc={first_line:1,first_column:0,last_line:1,last_column:0},this.options.ranges&&(this.yylloc.range=[0,0]),this.offset=0,this},input:function(){var e=this._input[0];return this.yytext+=e,this.yyleng++,this.offset++,this.match+=e,this.matched+=e,e.match(/(?:\r\n?|\n).*/g)?(this.yylineno++,this.yylloc.last_line++):this.yylloc.last_column++,this.options.ranges&&this.yylloc.range[1]++,this._input=this._input.slice(1),e},unput:function(e){var t=e.length,r=e.split(/(?:\r\n?|\n)/g);this._input=e+this._input,this.yytext=this.yytext.substr(0,this.yytext.length-t),this.offset-=t;var s=this.match.split(/(?:\r\n?|\n)/g);this.match=this.match.substr(0,this.match.length-1),this.matched=this.matched.substr(0,this.matched.length-1),r.length-1&&(this.yylineno-=r.length-1);var a=this.yylloc.range;return this.yylloc={first_line:this.yylloc.first_line,last_line:this.yylineno+1,first_column:this.yylloc.first_column,last_column:r?(r.length===s.length?this.yylloc.first_column:0)+s[s.length-r.length].length-r[0].length:this.yylloc.first_column-t},this.options.ranges&&(this.yylloc.range=[a[0],a[0]+this.yyleng-t]),this.yyleng=this.yytext.length,this},more:function(){return this._more=!0,this},reject:function(){return this.options.backtrack_lexer?(this._backtrack=!0,this):this.parseError("Lexical error on line "+(this.yylineno+1)+". You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).\n"+this.showPosition(),{text:"",token:null,line:this.yylineno})},less:function(e){this.unput(this.match.slice(e))},pastInput:function(){var e=this.matched.substr(0,this.matched.length-this.match.length);return(e.length>20?"...":"")+e.substr(-20).replace(/\n/g,"")},upcomingInput:function(){var e=this.match;return e.length<20&&(e+=this._input.substr(0,20-e.length)),(e.substr(0,20)+(e.length>20?"...":"")).replace(/\n/g,"")},showPosition:function(){var e=this.pastInput(),t=new Array(e.length+1).join("-");return e+this.upcomingInput()+"\n"+t+"^"},test_match:function(e,t){var r,s,a;if(this.options.backtrack_lexer&&(a={yylineno:this.yylineno,yylloc:{first_line:this.yylloc.first_line,last_line:this.last_line,first_column:this.yylloc.first_column,last_column:this.yylloc.last_column},yytext:this.yytext,match:this.match,matches:this.matches,matched:this.matched,yyleng:this.yyleng,offset:this.offset,_more:this._more,_input:this._input,yy:this.yy,conditionStack:this.conditionStack.slice(0),done:this.done},this.options.ranges&&(a.yylloc.range=this.yylloc.range.slice(0))),(s=e[0].match(/(?:\r\n?|\n).*/g))&&(this.yylineno+=s.length),this.yylloc={first_line:this.yylloc.last_line,last_line:this.yylineno+1,first_column:this.yylloc.last_column,last_column:s?s[s.length-1].length-s[s.length-1].match(/\r?\n?/)[0].length:this.yylloc.last_column+e[0].length},this.yytext+=e[0],this.match+=e[0],this.matches=e,this.yyleng=this.yytext.length,this.options.ranges&&(this.yylloc.range=[this.offset,this.offset+=this.yyleng]),this._more=!1,this._backtrack=!1,this._input=this._input.slice(e[0].length),this.matched+=e[0],r=this.performAction.call(this,this.yy,this,t,this.conditionStack[this.conditionStack.length-1]),this.done&&this._input&&(this.done=!1),r)return r;if(this._backtrack){for(var i in a)this[i]=a[i];return!1}return!1},next:function(){if(this.done)return this.EOF;var e,t,r,s;this._input||(this.done=!0),this._more||(this.yytext="",this.match="");for(var a=this._currentRules(),i=0;i<a.length;i++)if((r=this._input.match(this.rules[a[i]]))&&(!t||r[0].length>t[0].length)){if(t=r,s=i,this.options.backtrack_lexer){if(!1!==(e=this.test_match(r,a[i])))return e;if(this._backtrack){t=!1;continue}return!1}if(!this.options.flex)break}return t?!1!==(e=this.test_match(t,a[s]))&&e:""===this._input?this.EOF:this.parseError("Lexical error on line "+(this.yylineno+1)+". Unrecognized text.\n"+this.showPosition(),{text:"",token:null,line:this.yylineno})},lex:function(){return this.next()||this.lex()},begin:function(e){this.conditionStack.push(e)},popState:function(){return this.conditionStack.length-1>0?this.conditionStack.pop():this.conditionStack[0]},_currentRules:function(){return this.conditionStack.length&&this.conditionStack[this.conditionStack.length-1]?this.conditions[this.conditionStack[this.conditionStack.length-1]].rules:this.conditions.INITIAL.rules},topState:function(e){return(e=this.conditionStack.length-1-Math.abs(e||0))>=0?this.conditionStack[e]:"INITIAL"},pushState:function(e){this.begin(e)},stateStackSize:function(){return this.conditionStack.length},options:{flex:!0,"case-insensitive":!0},performAction:function(e,t,r,s){switch(r){case 0:break;case 1:return 12;case 2:return 15;case 3:return 28;case 4:return 316;case 5:return 317;case 6:return 35;case 7:return 37;case 8:return 38;case 9:return 26;case 10:return 41;case 11:return 45;case 12:return 46;case 13:return 48;case 14:return 50;case 15:return 55;case 16:return 58;case 17:return 320;case 18:return 68;case 19:return 69;case 20:return 75;case 21:return 78;case 22:return 81;case 23:return 83;case 24:return 86;case 25:return 88;case 26:return 90;case 27:return 191;case 28:return 107;case 29:return 321;case 30:return 140;case 31:return 322;case 32:return 323;case 33:return 117;case 34:return 324;case 35:return 116;case 36:return 325;case 37:return 326;case 38:return 120;case 39:return 122;case 40:return 123;case 41:return 138;case 42:return 132;case 43:return 133;case 44:return 135;case 45:return 141;case 46:return 119;case 47:return 327;case 48:return 328;case 49:return 167;case 50:return 170;case 51:return 174;case 52:return 100;case 53:return 168;case 54:return 329;case 55:return 173;case 56:return 231;case 57:return 235;case 58:return 278;case 59:return 195;case 60:return 330;case 61:return 331;case 62:return 224;case 63:return 333;case 64:return 334;case 65:return 219;case 66:return 226;case 67:return 227;case 68:return 250;case 69:return 254;case 70:return 295;case 71:return 335;case 72:return 336;case 73:return 337;case 74:return 338;case 75:return 339;case 76:return 258;case 77:return 340;case 78:return 273;case 79:return 281;case 80:return 282;case 81:return 275;case 82:return 276;case 83:return 277;case 84:return 341;case 85:return 342;case 86:return 279;case 87:return 344;case 88:return 343;case 89:return 345;case 90:return 284;case 91:return 285;case 92:return 288;case 93:return 290;case 94:return 294;case 95:return 298;case 96:return 301;case 97:return 13;case 98:return 16;case 99:return 312;case 100:return 245;case 101:return 34;case 102:return 297;case 103:return 87;case 104:return 299;case 105:return 300;case 106:return 306;case 107:return 307;case 108:return 308;case 109:return 309;case 110:return 310;case 111:return 311;case 112:return"EXPONENT";case 113:return 302;case 114:return 303;case 115:return 304;case 116:return 305;case 117:return 93;case 118:return 246;case 119:return 6;case 120:return"INVALID";case 121:console.log(t.yytext)}},rules:[/^(?:\s+|(#[^\n\r]*))/i,/^(?:BASE)/i,/^(?:PREFIX)/i,/^(?:SELECT)/i,/^(?:DISTINCT)/i,/^(?:REDUCED)/i,/^(?:\()/i,/^(?:AS)/i,/^(?:\))/i,/^(?:\*)/i,/^(?:CONSTRUCT)/i,/^(?:WHERE)/i,/^(?:\{)/i,/^(?:\})/i,/^(?:DESCRIBE)/i,/^(?:ASK)/i,/^(?:FROM)/i,/^(?:NAMED)/i,/^(?:GROUP)/i,/^(?:BY)/i,/^(?:HAVING)/i,/^(?:ORDER)/i,/^(?:ASC)/i,/^(?:DESC)/i,/^(?:LIMIT)/i,/^(?:OFFSET)/i,/^(?:VALUES)/i,/^(?:;)/i,/^(?:LOAD)/i,/^(?:SILENT)/i,/^(?:INTO)/i,/^(?:CLEAR)/i,/^(?:DROP)/i,/^(?:CREATE)/i,/^(?:ADD)/i,/^(?:TO)/i,/^(?:MOVE)/i,/^(?:COPY)/i,/^(?:INSERT((\s+|(#[^\n\r]*)\n\r?)+)DATA)/i,/^(?:DELETE((\s+|(#[^\n\r]*)\n\r?)+)DATA)/i,/^(?:DELETE((\s+|(#[^\n\r]*)\n\r?)+)WHERE)/i,/^(?:WITH)/i,/^(?:DELETE)/i,/^(?:INSERT)/i,/^(?:USING)/i,/^(?:DEFAULT)/i,/^(?:GRAPH)/i,/^(?:ALL)/i,/^(?:\.)/i,/^(?:OPTIONAL)/i,/^(?:SERVICE)/i,/^(?:BIND)/i,/^(?:UNDEF)/i,/^(?:MINUS)/i,/^(?:UNION)/i,/^(?:FILTER)/i,/^(?:<<)/i,/^(?:>>)/i,/^(?:,)/i,/^(?:a)/i,/^(?:\|)/i,/^(?:\/)/i,/^(?:\^)/i,/^(?:\?)/i,/^(?:\+)/i,/^(?:!)/i,/^(?:\[)/i,/^(?:\])/i,/^(?:\|\|)/i,/^(?:&&)/i,/^(?:=)/i,/^(?:!=)/i,/^(?:<)/i,/^(?:>)/i,/^(?:<=)/i,/^(?:>=)/i,/^(?:IN)/i,/^(?:NOT)/i,/^(?:-)/i,/^(?:BOUND)/i,/^(?:BNODE)/i,/^(?:(RAND|NOW|UUID|STRUUID))/i,/^(?:(LANG|DATATYPE|IRI|URI|ABS|CEIL|FLOOR|ROUND|STRLEN|STR|UCASE|LCASE|ENCODE_FOR_URI|YEAR|MONTH|DAY|HOURS|MINUTES|SECONDS|TIMEZONE|TZ|MD5|SHA1|SHA256|SHA384|SHA512|isIRI|isURI|isBLANK|isLITERAL|isNUMERIC))/i,/^(?:(LANGMATCHES|CONTAINS|STRSTARTS|STRENDS|STRBEFORE|STRAFTER|STRLANG|STRDT|sameTerm))/i,/^(?:CONCAT)/i,/^(?:COALESCE)/i,/^(?:IF)/i,/^(?:REGEX)/i,/^(?:SUBSTR)/i,/^(?:REPLACE)/i,/^(?:EXISTS)/i,/^(?:COUNT)/i,/^(?:SUM|MIN|MAX|AVG|SAMPLE)/i,/^(?:GROUP_CONCAT)/i,/^(?:SEPARATOR)/i,/^(?:\^\^)/i,/^(?:true|false)/i,/^(?:(<(?:[^<>\"\{\}\|\^`\\\u0000-\u0020])*>))/i,/^(?:((([A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]|[\uD800-\uDB7F][\uDC00-\uDFFF])(?:(?:(((?:([A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]|[\uD800-\uDB7F][\uDC00-\uDFFF])|_))|-|[0-9]|\u00B7|[\u0300-\u036F\u203F-\u2040])|\.)*(((?:([A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]|[\uD800-\uDB7F][\uDC00-\uDFFF])|_))|-|[0-9]|\u00B7|[\u0300-\u036F\u203F-\u2040]))?)?:))/i,/^(?:(((([A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]|[\uD800-\uDB7F][\uDC00-\uDFFF])(?:(?:(((?:([A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]|[\uD800-\uDB7F][\uDC00-\uDFFF])|_))|-|[0-9]|\u00B7|[\u0300-\u036F\u203F-\u2040])|\.)*(((?:([A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]|[\uD800-\uDB7F][\uDC00-\uDFFF])|_))|-|[0-9]|\u00B7|[\u0300-\u036F\u203F-\u2040]))?)?:)((?:((?:([A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]|[\uD800-\uDB7F][\uDC00-\uDFFF])|_))|:|[0-9]|((%([0-9A-Fa-f])([0-9A-Fa-f]))|(\\(_|~|\.|-|!|\$|&|'|\(|\)|\*|\+|,|;|=|\/|\?|#|@|%))))(?:(?:(((?:([A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]|[\uD800-\uDB7F][\uDC00-\uDFFF])|_))|-|[0-9]|\u00B7|[\u0300-\u036F\u203F-\u2040])|\.|:|((%([0-9A-Fa-f])([0-9A-Fa-f]))|(\\(_|~|\.|-|!|\$|&|'|\(|\)|\*|\+|,|;|=|\/|\?|#|@|%))))*(?:(((?:([A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]|[\uD800-\uDB7F][\uDC00-\uDFFF])|_))|-|[0-9]|\u00B7|[\u0300-\u036F\u203F-\u2040])|:|((%([0-9A-Fa-f])([0-9A-Fa-f]))|(\\(_|~|\.|-|!|\$|&|'|\(|\)|\*|\+|,|;|=|\/|\?|#|@|%)))))?)))/i,/^(?:(_:(?:((?:([A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]|[\uD800-\uDB7F][\uDC00-\uDFFF])|_))|[0-9])(?:(?:(((?:([A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]|[\uD800-\uDB7F][\uDC00-\uDFFF])|_))|-|[0-9]|\u00B7|[\u0300-\u036F\u203F-\u2040])|\.)*(((?:([A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]|[\uD800-\uDB7F][\uDC00-\uDFFF])|_))|-|[0-9]|\u00B7|[\u0300-\u036F\u203F-\u2040]))?))/i,/^(?:([\?\$]((?:((?:([A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]|[\uD800-\uDB7F][\uDC00-\uDFFF])|_))|[0-9])(?:((?:([A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]|[\uD800-\uDB7F][\uDC00-\uDFFF])|_))|[0-9]|\u00B7|[\u0300-\u036F\u203F-\u2040])*)))/i,/^(?:(@[a-zA-Z]+(?:-[a-zA-Z0-9]+)*))/i,/^(?:([0-9]+))/i,/^(?:([0-9]*\.[0-9]+))/i,/^(?:([0-9]+\.[0-9]*([eE][+-]?[0-9]+)|\.([0-9])+([eE][+-]?[0-9]+)|([0-9])+([eE][+-]?[0-9]+)))/i,/^(?:(\+([0-9]+)))/i,/^(?:(\+([0-9]*\.[0-9]+)))/i,/^(?:(\+([0-9]+\.[0-9]*([eE][+-]?[0-9]+)|\.([0-9])+([eE][+-]?[0-9]+)|([0-9])+([eE][+-]?[0-9]+))))/i,/^(?:(-([0-9]+)))/i,/^(?:(-([0-9]*\.[0-9]+)))/i,/^(?:(-([0-9]+\.[0-9]*([eE][+-]?[0-9]+)|\.([0-9])+([eE][+-]?[0-9]+)|([0-9])+([eE][+-]?[0-9]+))))/i,/^(?:([eE][+-]?[0-9]+))/i,/^(?:('(?:(?:[^\u0027\u005C\u000A\u000D])|(\\[tbnrf\\\"']|\\u([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])|\\U([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])))*'))/i,/^(?:("(?:(?:[^\u0022\u005C\u000A\u000D])|(\\[tbnrf\\\"']|\\u([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])|\\U([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])))*"))/i,/^(?:('''(?:(?:'|'')?(?:[^'\\]|(\\[tbnrf\\\"']|\\u([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])|\\U([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f]))))*'''))/i,/^(?:("""(?:(?:"|"")?(?:[^\"\\]|(\\[tbnrf\\\"']|\\u([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])|\\U([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f]))))*"""))/i,/^(?:(\((\u0020|\u0009|\u000D|\u000A)*\)))/i,/^(?:(\[(\u0020|\u0009|\u000D|\u000A)*\]))/i,/^(?:$)/i,/^(?:.)/i,/^(?:.)/i],conditions:{INITIAL:{rules:[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,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,115,116,117,118,119,120,121],inclusive:!0}}};function ss(){this.yy={}}return pr.lexer=rs,ss.prototype=pr,pr.Parser=ss,new ss}();t.parser=s,t.Parser=s.Parser,t.parse=function(){return s.parse.apply(s,arguments)},t.main=function(e){e[1]||(console.log("Usage: "+e[0]+" FILE"),process.exit(1));var s=r(270).readFileSync(r(80).normalize(e[1]),"utf8");return t.parser.parse(s)},r.c[r.s]===e&&t.main(process.argv.slice(1))},348:e=>{class t{constructor(){return r||this}equals(e){return e&&this.termType===e.termType}}Object.defineProperty(t.prototype,"value",{enumerable:!0,value:"*"}),Object.defineProperty(t.prototype,"termType",{enumerable:!0,value:"Wildcard"});var r=new t;e.exports.R=t},619:(e,t,r)=>{var s=r(107).Parser,a=r(404),i=r(348).R,{DataFactory:n}=r(640);e.exports={Parser:function({prefixes:e,baseIRI:t,factory:r,sparqlStar:a,skipUngroupedVariableCheck:i}={}){var o={};for(var p in e||{})o[p]=e[p];var l=new s;return l.parse=function(){return s.base=t||"",s.prefixes=Object.create(o),s.factory=r||new n,s.sparqlStar=Boolean(a),s.skipUngroupedVariableCheck=Boolean(i),s.prototype.parse.apply(l,arguments)},l._resetBlanks=s._resetBlanks,l},Generator:a,Wildcard:i}},564:e=>{"use strict";e.exports=window.Blockly},270:()=>{},80:()=>{}},t={};function r(s){var a=t[s];if(void 0!==a)return a.exports;var i=t[s]={id:s,loaded:!1,exports:{}};return e[s].call(i.exports,i,i.exports,r),i.loaded=!0,i.exports}r.c=t,r.nmd=e=>(e.paths=[],e.children||(e.children=[]),e);var s=r(r.s=590);window.SparqlBlockly=s})();
1
+ (()=>{var e={63:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Block=void 0;class i{constructor(e,t){this.values=new Map,this.fields=new Map,this.statements=new Map,this.type=e,t&&(t instanceof i?this.addValue("value",t):this.addField("value",t))}get xml(){const e=document.implementation.createDocument(null,"xml");return e.documentElement.appendChild(this.asDom(e)),e.documentElement}addValue(e,t){t&&this.values.set(e,t)}addField(e,t){this.fields.set(e,t)}addItems(e,t,i,n){const o=(e,t)=>{const o=i.call(n,t);return o.next=e,o};t.reduceRight(o,null)&&this.statements.set(e,t.reduceRight(o,null))}asDom(e){const t=e.createElement("block");t.setAttribute("type",`sparql11_${this.type}`);for(const[i,n]of this.values){const o=e.createElement("value");o.setAttribute("name",i);const s=n.asDom(e);o.appendChild(s),t.appendChild(o)}for(const[i,n]of this.fields){const o=e.createElement("field");o.setAttribute("name",i),o.textContent=n,t.appendChild(o)}for(const[i,n]of this.statements){const o=e.createElement("statement");o.setAttribute("name",i);const s=n.asDom(e);o.appendChild(s),t.appendChild(o)}if(this.next){const i=e.createElement("next"),n=this.next.asDom(e);i.appendChild(n),t.appendChild(i)}return t}}t.Block=i},670:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=i(150),o=i(82),s=i(63),r=i(210),a=i(600),l=i(378);class h{constructor(){this.prefixes=new Map}visit(e){switch(e.type){case"query":return this.query(e);case"update":return this.update(e)}}query(e){const t=new s.Block("query");return t.addItems("prologue",h.getPrologueItems(e),this.prologueItem,this),t.addValue("value",this[e.queryType.toLowerCase()](e)),e.values&&t.addValue("values",this.values(e.values)),t}select(e){const t=new s.Block("selectquery");return t.addValue("select",this.selectClause(e)),t.addValue("where",this.queryCommon(e)),t}construct(e){const t=h.normalisePatterns([{triples:e.template,type:"bgp"}]);if(h.isSimpleConstruct(e)){const i=new s.Block("simpleconstructquery");return i.addValue("modifiers",this.solutionModifiers(e)),i.addItems("where",[...t],this.triplesSameSubjectItem,this),e.from&&this.dataset(i,e.from),i}{const i=new s.Block("constructquery");return i.addValue("where",this.queryCommon(e)),i.addItems("template",[...t],this.triplesSameSubjectItem,this),i}}describe(e){const t=e.variables,i=new s.Block("describequery");return e.where&&i.addValue("where",this.queryCommon(e)),h.isWildcard(t)?i.addField("star","*"):i.addItems("subject",t,this.varOrIriItem,this),i}ask(e){return new s.Block("askquery",this.queryCommon(e))}update(e){const t=new s.Block("update");return t.addItems("prologue",h.getPrologueItems(e),this.prologueItem,this),t.addItems("items",e.updates,this.updateItem,this),t}updateItem(e){return"type"in e?new s.Block("updateitem",this.managementOperation(e)):new s.Block("updateitem",this.insertDeleteOperation(e))}managementOperation(e){switch(e.type){case"clear":case"drop":return this.clearDrop(e);case"add":case"move":case"copy":return this.addMoveCopy(e);case"load":return this.load(e);case"create":return this.create(e)}}insertDeleteOperation(e){switch(e.updateType){case"insert":case"delete":case"deletewhere":return this.insertDeleteWhere(e);case"insertdelete":return this.modify(e)}}clearDrop(e){const t=new s.Block("cleardrop");return t.addValue("graph",this.graphRefAll(e.graph)),t.addField("operator",e.type.toUpperCase()),e.silent&&t.addField("silent","SILENT"),t}addMoveCopy(e){const t=new s.Block("addmovecopy");return t.addValue("source",this.graphRefAll(e.source)),t.addValue("destination",this.graphRefAll(e.destination)),t.addField("operator",e.type.toUpperCase()),e.silent&&t.addField("silent","SILENT"),t}load(e){const t=new s.Block("load");return t.addValue("source",this.namedNode(e.source)),e.destination&&t.addValue("destination",this.graphRef(e.destination)),e.silent&&t.addField("silent","SILENT"),t}create(e){const t=new s.Block("create");return t.addValue("graph",this.graphRef(e.graph.name)),e.silent&&t.addField("silent","SILENT"),t}insertDeleteWhere(e){var t;const i=new s.Block("insertdeletewhere");return i.addValue("pattern",this.quadPattern(null!==(t=e.insert)&&void 0!==t?t:e.delete)),i.addField("operator",e.updateType.replace("insert","INSERT DATA").replace("deletewhere","DELETE WHERE").replace("delete","DELETE DATA")),i}quadPattern(e){const t=new s.Block("quadpattern");return t.addItems("items",[...h.normaliseQuads(e)],this.quadPatternItem,this),t}quadPatternItem(e){return"triplesSameSubject"===e.type?new s.Block("quadpatternitem",this.triplesSameSubject(e)):new s.Block("quadpatternitem",this.quadsNotTriples(e))}quadsNotTriples(e){const t=[];for(const[i,n]of h.toTriplesSameSubject(e.triples))t.push({type:"triplesSameSubject",subject:i,predicates:n});const i=new s.Block("quadsnottriples");return i.addValue("name",this.term(e.name)),i.addItems("triples",t,this.triplesSameSubjectItem,this),i}modify(e){const t=new s.Block("modify");return e.graph&&t.addValue("iri",this.namedNode(e.graph)),e.delete.length&&t.addValue("delete",this.quadPattern(e.delete)),e.insert.length&&t.addValue("insert",this.quadPattern(e.insert)),t.addValue("where",this.group(e.where)),e.using&&this.usings(t,e.using),t}graphRefAll(e){return e.name?this.graphRef(e.name):e.all?new s.Block("graphrefallall"):e.default?new s.Block("graphordefault"):new s.Block("graphrefallnamed")}graphRef(e){return new s.Block("graphref",this.namedNode(e))}usings(e,t){const i=(e,t)=>[e,t],n=t.named.map(i.bind(null,!0)),o=t.default.map(i.bind(null,!1));e.addItems("using",o.concat(n),this.using,this)}using([e,t]){return e?new s.Block("usingclause",this.named(t)):new s.Block("usingclause",this.namedNode(t))}pattern(e){if("queryType"in e)return this.subSelect(e);switch(e.type){case"group":return this.group(e.patterns);case"values":return this.values(e.values);default:return this[e.type](e)}}group(e){const t=h.normalisePatterns(e);return 0===t.size?new s.Block("groupgraphpattern"):c(t)?new s.Block("groupgraphpattern",this.pattern(d(t))):new s.Block("groupgraphpattern",this.groupGraphPatternSub([...t]))}groupGraphPatternSub(e){const t=new s.Block("groupgraphpatternsub");return t.addItems("items",e,this.groupSubItem,this),t}bind(e){return new s.Block("bind",this.expressionAsVar(e.expression,e.variable))}service(e){const t=new s.Block("servicegraphpattern");return t.addValue("iri",this.term(e.name)),t.addValue("patterns",this.group(e.patterns)),t.addField("silent",e.silent?"SILENT":""),t}optional(e){return new s.Block("optionalgraphpattern",this.group(e.patterns))}graph(e){const t=new s.Block("graphgraphpattern");return t.addValue("iri",this.term(e.name)),t.addValue("patterns",this.group(e.patterns)),t}filter(e){return"termType"in e.expression||"operator"in e.expression&&["||","&&","=","!=","<",">","<=",">=","in","notin","!","+","-","UMINUS","*","/"].includes(e.expression.operator)?new s.Block("filter",this.bracketted(e.expression)):new s.Block("filter",this.expression(e.expression))}minus(e){return new s.Block("minusgraphpattern",this.group(e.patterns))}union(e){const t=new s.Block("grouporuniongraphpattern");return t.addItems("items",e.patterns,this.groupItem,this),t}triplesSameSubject(e){const t=new s.Block("triplessamesubject");return t.addValue("subject",this.term(e.subject)),t.addItems("predicates",[...e.predicates.entries()],this.propertyList,this),t}subSelect(e){const t=new s.Block("subselect");return t.addValue("select",this.selectClause(e)),t.addValue("pattern",this.group(e.where)),e.values&&t.addValue("values",this.values(e.values)),t.addValue("modifiers",this.solutionModifiers(e)),t}solutionModifiers(e){if(e.group||e.having||e.order||"limit"in e||"offset"in e){const t=new s.Block("solutionmodifier");return"limit"in e&&t.addValue("limit",this.numeric(e.limit.toString())),"offset"in e&&t.addValue("offset",this.numeric(e.offset.toString())),e.group&&t.addItems("group",e.group,this.groupingItem,this),e.having&&t.addItems("having",e.having,this.havingItem,this),e.order&&t.addItems("order",e.order,this.orderItem,this),t}}collection(e){const t=new s.Block("collection");return t.addItems("items",e.items,this.graphNodeItem,this),t}verb(e){return"pathType"in e?this.path(e):e.value===n.RDF.type?new s.Block("a"):this.term(e)}path(e){switch(e.pathType){case"|":return this.pathAlternative(e);case"/":return this.pathSequence(e);case"^":return this.pathInverse(e);case"?":case"+":case"*":return this.pathModifier(e);case"!":return this.pathNegated(e)}}pathAlternative(e){const t=new s.Block("pathalternative");return t.addItems("items",e.items,this.pathAlternativeItem,this),t}pathSequence(e){const t=new s.Block("pathsequence");return t.addItems("items",e.items,this.pathSequenceItem,this),t}pathModifier(e){const t=new s.Block("pathwithmodifier"),i=d(e.items);return"pathType"in i&&["/","|","^"].includes(i.pathType)?t.addValue("value",this.brackettedPath(i)):t.addValue("value",this.verb(i)),t.addField("modifier",e.pathType),t}pathInverse(e){const t=new s.Block("inversepath"),i=d(e.items);return"pathType"in i&&["/","|"].includes(i.pathType)?t.addValue("value",this.brackettedPath(i)):t.addValue("value",this.verb(i)),t}pathNegated(e){const t=d(e.items);if(!("pathType"in t))return new s.Block("negatedpath",this.verb(t));switch(t.pathType){case"|":return new s.Block("negatedpath",this.pathOneInPropertySetAlternative(t));case"^":return new s.Block("negatedpath",this.inversePathOneInPropertySet(t))}}inversePathOneInPropertySet(e){return new s.Block("inversepathoneinpropertyset",this.verb(d(e.items)))}pathOneInPropertySetAlternative(e){const t=new s.Block("pathoneinpropertysetalternative");return t.addItems("items",e.items,this.pathOneInPropertySetAlternativeItem,this),t}brackettedPath(e){return new s.Block("bracketedpath",this.verb(e))}prefix([e,t]){return this.prefixes.set(t,e),e?this.prefixDecl(e,t):this.prefixDeclDefault(t)}prefixDecl(e,t){const i=new s.Block("prefixdecl",this.iriref(t));return i.addField("prefix",e),i}prefixDeclDefault(e){return new s.Block("prefixdecldefault",this.iriref(e))}base(e){return this.baseUri=e,new s.Block("base",this.iriref(e))}queryCommon(e){const t=new s.Block("querycommon");return t.addValue("pattern",this.group(e.where)),t.addValue("modifiers",this.solutionModifiers(e)),e.from&&this.dataset(t,e.from),t}dataset(e,t){const i=(e,t)=>[e,t],n=t.named.map(i.bind(null,!0)),o=t.default.map(i.bind(null,!1));e.addItems("datasets",o.concat(n),this.from,this)}from([e,t]){return e?new s.Block("datasetclause",this.named(t)):new s.Block("datasetclause",this.namedNode(t))}named(e){return new s.Block("namedgraphclause",this.namedNode(e))}selectClause(e){const t=new s.Block("selectclause");e.distinct&&t.addField("distinctOrReduced","DISTINCT"),e.reduced&&t.addField("distinctOrReduced","REDUCED");const i=e.variables;return h.isWildcard(i)?t.addField("star","*"):t.addItems("vars",i,this.varOrExpressionAsVarItem,this),t}values(e){const t=e.reduce(((e,t)=>Object.keys(t)),[]).map(u),i=e.map(Object.values);return c(t)?new s.Block("inlinedata",this.inlineDataOneVar(d(t),i.flat())):new s.Block("inlinedata",this.inlineDataFull(t,i))}inlineDataOneVar(e,t){const i=new s.Block("inlinedataonevar");return i.addValue("variable",this.variable(e)),i.addItems("values",t.flat(),this.dataBlockValueItem,this),i}inlineDataFull(e,t){const i=new s.Block("inlinedatafull");return i.addItems("variables",e,this.variableItem,this),i.addItems("values",t,this.dataBlockValuesItem,this),i}expressionAsVar(e,t){const i=new s.Block("expressionasvar",this.expression(e));return i.addValue("name",this.variable(t)),i}descending(e){const t=new s.Block("ordercondition",this.bracketted(e));return t.addField("operator","DESC"),t}expression(e){return"type"in e?this[e.type](e):this.term(e)}operation(e){switch(e.operator){case"||":case"&&":case"=":case"!=":case"<":case">":case"<=":case">=":case"+":case"-":case"*":case"/":case"!":case"UMINUS":return this.unibinary(e);case"notin":case"in":return this.in(e);case"bound":return this.bound(e);case"exists":case"notexists":return this.exists(e);case"concat":case"coalesce":return this.builtInCallN(e);default:return this[`builtInCall${e.args.length}`](e)}}functionCall(e){const t=new s.Block("iriorfunction");return t.addValue("iri",this.namedNode(e.function)),e.distinct&&t.addField("distinct","DISTINCT"),t.addItems("args",e.args,this.expressionListItem,this),t}aggregate(e){switch(e.aggregation){case"sum":case"min":case"max":case"avg":case"sample":return this.aggregateCommon(e);default:return this[e.aggregation](e)}}exists(e){const t=new s.Block("exists"),i=d(e.args);return"group"===i.type?t.addValue("value",this.pattern(i)):t.addValue("value",this.group(e.args)),t.addField("operator",e.operator.toUpperCase().replace("NOTEXISTS","NOT EXISTS")),t}builtInCall0(e){const t=new s.Block("builtincall0");return t.addField("operator",e.operator.toUpperCase()),t}builtInCall1(e){const t=new s.Block("builtincall1");return t.addValue("arg1",this.expression(d(e.args))),t.addField("operator",e.operator.toUpperCase()),t}builtInCall2(e){const t=new s.Block("builtincall2");return t.addValue("arg1",this.expression(e.args[0])),t.addValue("arg2",this.expression(e.args[1])),t.addField("operator",e.operator.toUpperCase()),t}builtInCall3(e){const t=new s.Block("builtincall3");return t.addValue("arg1",this.expression(e.args[0])),t.addValue("arg2",this.expression(e.args[1])),t.addValue("arg3",this.expression(e.args[2])),t.addField("operator",e.operator.toUpperCase()),t}builtInCall4(e){const t=new s.Block("builtincall4");return t.addValue("arg1",this.expression(e.args[0])),t.addValue("arg2",this.expression(e.args[1])),t.addValue("arg3",this.expression(e.args[2])),t.addValue("arg4",this.expression(e.args[3])),t.addField("operator",e.operator.toUpperCase()),t}builtInCallN(e){const t=new s.Block("builtincalln");return t.addField("operator",e.operator.toUpperCase()),t.addItems("args",e.args,this.expressionListItem,this),t}bound(e){return new s.Block("bound",this.expression(d(e.args)))}bracketted(e){return new s.Block("brackettedexpression",this.expression(e))}unibinary(e,t=h.hierarchy){const[i,n]=p(t);if(n.operators.includes(e.operator)){const t=new s.Block(i);return t.addValue("left",this.bracketArgument(e.args[0],n)),e.args.length>1&&t.addValue("right",this.bracketArgument(e.args[1],n)),["&&","||"].includes(e.operator)||t.addField("operator",e.operator),t}return this.unibinary(e,n.higher)}bracketArgument(e,t=h.hierarchy.unaryexpression){if("operator"in e){if(t.operators.includes(e.operator))return this.bracketted(e);if(t.higher){const[,i]=p(t.higher);return this.bracketArgument(e,i)}}return this.expression(e)}in(e){const t=new s.Block("relationalexpressionin");return t.addValue("left",this.expression(e.args[0])),t.addField("operator",e.operator.toUpperCase().replace("NOTIN","NOT IN")),t.addItems("right",e.args[1],this.expressionListItem,this),t}group_concat(e){const t=new s.Block("group_concat");return t.addValue("arg1",this.expression(e.expression)),t.addValue("separator",this.string(e.separator)),e.distinct&&t.addField("distinct","DISTINCT"),t}count(e){const t=new s.Block("count");return e.distinct&&t.addField("distinct","DISTINCT"),e.expression instanceof o.Wildcard?t.addField("star","*"):t.addValue("arg1",this.expression(e.expression)),t}aggregateCommon(e){const t=new s.Block("aggregate");return t.addValue("arg1",this.expression(e.expression)),t.addField("operator",e.aggregation.toUpperCase()),e.distinct&&t.addField("distinct","DISTINCT"),t}term(e){return e.value===n.RDF.nil?new s.Block("nil"):this[(t=e.termType,t.charAt(0).toLowerCase()+t.substr(1))](e);var t}namedNode(e){for(const[t,i]of this.prefixes)if(e.value.startsWith(t)){const n=e.value.replace(t,"");return i?n?this.prefixedNamePrefixLocalName(i,n):this.prefixedNamePrefix(i):n?this.prefixedNameLocalName(n):this.prefixedName()}if(this.baseUri&&e.value.startsWith(this.baseUri)){const t=e.value.replace(this.baseUri,"");return t?this.iriref(t):new s.Block("irirefdefault")}return this.iriref(e.value)}quad(e){const t=new s.Block("embtp");return t.addValue("subject",this.term(e.subject)),t.addValue("predicate",this.verb(e.predicate)),t.addValue("object",this.term(e.object)),t}prefixedName(){return new s.Block("prefixedname")}prefixedNameLocalName(e){const t=new s.Block("prefixednamelocalname");return t.addField("localName",e),t}prefixedNamePrefix(e){const t=new s.Block("prefixednameprefix");return t.addField("prefix",e),t}prefixedNamePrefixLocalName(e,t){const i=new s.Block("prefixednameprefixlocalname");return i.addField("localName",t),i.addField("prefix",e),i}iriref(e){return new s.Block("iriref",e)}blankNode(e){return new s.Block("blanknodelabel",e.value)}literal(e){switch(e.datatype.value){case n.XSD.string:return this.string(e.value);case n.XSD.integer:case n.XSD.decimal:case n.XSD.double:return this.numeric(e.value);case n.XSD.boolean:return this.boolean(e);case n.RDF.langString:return this.langString(e);default:return this.typedLiteral(e)}}string(e){return new s.Block("string",e)}langString(e){const t=new s.Block("langstring",this.string(e.value));return t.addField("language",e.language),t}numeric(e){return new s.Block("numericliteral",e)}boolean(e){return new s.Block("booleanliteral",e.value.toUpperCase())}typedLiteral(e){const t=new s.Block("typedliteral",this.string(e.value));return t.addValue("datatype",this.namedNode(e.datatype)),t}variable(e){return new s.Block("var1",e.value)}dataBlockValueItem(e){return e?new s.Block("datablockvalueitem",this.term(e)):new s.Block("datablockvalueitem",new s.Block("undef"))}dataBlockValuesItem(e){const t=new s.Block("datablockvaluesitem");return t.addItems("items",e,this.dataBlockValueItem,this),t}prologueItem(e){return e instanceof Array?new s.Block("prologueitem",this.prefix(e)):new s.Block("prologueitem",this.base(e))}varOrExpressionAsVarItem(e){return"expression"in e?new s.Block("varorexpressionasvaritem",this.expressionAsVar(e.expression,e.variable)):new s.Block("varorexpressionasvaritem",this.variable(e))}groupItem(e){return"group"===e.type?new s.Block("groupgraphpatternitem",this.pattern(e)):new s.Block("groupgraphpatternitem",this.group([e]))}variableItem(e){return new s.Block("varitem",this.variable(e))}groupSubItem(e){return new s.Block("groupgraphpatternsubitem",this.pattern(e))}propertyList([e,t]){const i=new s.Block("propertylistnotempty");return i.addValue("predicate",this.verb(e)),i.addItems("objects",[...t],this.objectListItem,this),i}objectListItem(e){return new s.Block("objectlistitem",this.term(e))}expressionListItem(e){return new s.Block("expressionlistitem",this.expression(e))}pathAlternativeItem(e){return new s.Block("pathalternativeitem",this.verb(e))}pathSequenceItem(e){return"pathType"in e&&"|"===e.pathType?new s.Block("pathsequencitem",this.brackettedPath(e)):new s.Block("pathsequencitem",this.verb(e))}pathOneInPropertySetAlternativeItem(e){return"pathType"in e&&"^"===e.pathType?new s.Block("pathoneinpropertysetalternativeitem",this.inversePathOneInPropertySet(e)):new s.Block("pathoneinpropertysetalternativeitem",this.verb(e))}varOrIriItem(e){return new s.Block("varoririitem",this.term(e))}triplesSameSubjectItem(e){return new s.Block("triplessamesubjectitem",this.triplesSameSubject(e))}groupingItem(e){return"variable"in e?new s.Block("groupconditionitem",this.expressionAsVar(e.expression,e.variable)):new s.Block("groupconditionitem",this.expression(e.expression))}havingItem(e){return"termType"in e?new s.Block("havingconditionitem",this.bracketted(e)):new s.Block("havingconditionitem",this.bracketArgument(e))}orderItem(e){return e.descending?new s.Block("orderconditionitem",this.descending(e.expression)):"termType"in e.expression?"Variable"===e.expression.termType?new s.Block("orderconditionitem",this.term(e.expression)):new s.Block("orderconditionitem",this.bracketted(e.expression)):new s.Block("orderconditionitem",this.bracketArgument(e.expression))}graphNodeItem(e){return new s.Block("graphnodeitem",this.term(e))}static isSimpleConstruct(e){if(c(e.where)){const t=d(e.where);if("bgp"===t.type)return JSON.stringify(e.template)===JSON.stringify(t.triples)}}static getPrologueItems(e){const t=[];return e.base&&t.push(e.base),Object.entries(e.prefixes).sort(((e,t)=>e[1].length-t[1].length)).forEach((e=>t.push(e))),t}static isWildcard(e){return"termType"in e[0]&&"Wildcard"==e[0].termType}static toTriplesSameSubject(e){return e.reduce(((e,t)=>{e.has(t.subject)||e.set(t.subject,new r.StringifiedMap);const i=e.get(t.subject);return i.has(t.predicate)||i.set(t.predicate,new a),i.get(t.predicate).add(t.object),e}),new l)}static normalisePatterns(e){return Array.from(e).reduce(((e,t)=>{if("bgp"===t.type){const i=this.toTriplesSameSubject(t.triples);for(const[t,n]of i)e.add({type:"triplesSameSubject",subject:t,predicates:n})}else e.add(t);return e}),new Set)}static normaliseQuads(e){return e.reduce(((e,t)=>{if("bgp"===t.type){const i=this.toTriplesSameSubject(t.triples);for(const[t,n]of i)e.add({type:"triplesSameSubject",subject:t,predicates:n})}else e.add(t);return e}),new Set)}}function u(e){return{value:e.replace("?",""),termType:null,equals:null}}function c(e){return e instanceof Array?1===e.length:1===e.size}function d(e){return e instanceof Array?e[0]:e.values().next().value}function p(e){return d(Object.entries(e))}h.hierarchy={unaryexpression:{operators:["UMINUS","!"],higher:{multiplicativeexpression:{operators:["*","/"],higher:{additiveexpression:{operators:["+","-"],higher:{relationalexpression:{operators:["=","!=","<",">","<=",">="],higher:{conditionalandexpression:{operators:["&&"],higher:{conditionalorexpression:{operators:["||"]}}}}}}}}}}}},t.default=h},128:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=i(150),o=i(180);function s(e){return[e,n.Order.None]}function r(e,...t){return t.filter(Boolean).join(e)}function a(e,...t){return t.filter((e=>e instanceof Array?e[0]:e)).map((e=>e instanceof Array?e[1]:e)).join(e)}function l(e,t){return s(`${e}:${t}`)}function h(e=""){return s(`<${e}>`)}class u extends o.Generator{constructor(){super("SPARQL 1.1"),this.INDENT="",this.addCodeGeneratorProperties()}addCodeGeneratorProperties(){const e="sparql",t=e=>t=>this[e](t);Object.getOwnPropertyNames(u.prototype).filter((t=>t.startsWith(e))).map((t=>{return[(i=t,i.replace(e,"sparql11_").toLowerCase()),t];var i})).map((([e,i])=>[e,t(i)])).forEach((([e,t])=>this.forBlock[e]=t))}scrub_(e,t,i){if(!i){const i=e.getNextBlock();i&&(t+=this.blockToCode(i))}return t}sparqlQuery(e){return r("\n\n",this.statementToCode(e,"prologue"),r("\n",this.valueToCode(e,"value"),this.valueToCode(e,"values")))}sparqlSelectQuery(e){return s(r("\n",this.valueToCode(e,"select"),this.valueToCode(e,"where")))}sparqlDescribeQuery(e){const t=e.getFieldValue("star"),i=this.statementToCode(e,"subject"),n=this.valueToCode(e,"where");return s(r("\n",r(" ","DESCRIBE",t,i),n))}sparqlAskQuery(e){return s(r("\n","ASK",this.valueToCode(e,"value")))}sparqlSimpleConstructquery(e){const t=this.statementToCode(e,"datasets"),i=this.statementToCode(e,"where"),n=this.valueToCode(e,"modifiers");return s(r("\n","CONSTRUCT",t,r("\n","WHERE {",this.indent(i),"}"),n))}sparqlConstructQuery(e){const t=this.statementToCode(e,"template"),i=this.valueToCode(e,"where");return s(r("\n",r("\n","CONSTRUCT {",this.indent(t),"}"),i))}sparqlUpdate(e){return r("\n\n",this.statementToCode(e,"prologue"),this.statementToCode(e,"items"))}sparqlLoad(e){const t=this.valueToCode(e,"source"),i=e.getFieldValue("silent"),n=this.valueToCode(e,"destination");return s(a(" ",[!0,r(" ","LOAD",i,t)],[n,r(" ","INTO",n)]))}sparqlGraphRef(e){return s(r(" ","GRAPH",this.valueToCode(e,"value")))}sparqlCreate(e){return s(r(" ","CREATE",e.getFieldValue("silent"),this.valueToCode(e,"graph")))}sparqlAddMoveCopy(e){return s(r(" ",e.getFieldValue("operator"),e.getFieldValue("silent"),this.valueToCode(e,"source"),"TO",this.valueToCode(e,"destination")))}sparqlClearDrop(e){return s(r(" ",e.getFieldValue("operator"),e.getFieldValue("silent"),this.valueToCode(e,"graph")))}sparqlQuadPattern(e){const t=this.statementToCode(e,"items");return s(r("\n","{",this.indent(t),"}"))}sparqlInsertDeleteWhere(e){return s(r(" ",e.getFieldValue("operator"),this.valueToCode(e,"pattern")))}sparqlModify(e){const t=this.valueToCode(e,"iri"),i=this.valueToCode(e,"delete"),n=this.valueToCode(e,"insert"),o=this.statementToCode(e,"using"),l=this.valueToCode(e,"where");return s(a("\n",[t,r(" ","WITH",t)],[i,r(" ","DELETE",i)],[n,r(" ","INSERT",n)],o,r(" ","WHERE",l)))}sparqlUsingClause(e){const t=r(" ","USING",this.valueToCode(e,"value"));return this.generateNext(e,t,"\n")}sparqlGraphOrDefault(){return s("DEFAULT")}sparqlQuadsNotTriples(e){const t=this.valueToCode(e,"name"),i=this.statementToCode(e,"triples");return s(r(" ","GRAPH",t,r("\n","{",this.indent(i),"}")))}sparqlSelectClause(e){return s(r(" ","SELECT",e.getFieldValue("distinctOrReduced"),e.getFieldValue("star"),this.statementToCode(e,"vars")))}sparqlExpressionAsVar(e){return s(`(${this.valueToCode(e,"value")} AS ${this.valueToCode(e,"name")})`)}sparqlQueryCommon(e){const t=this.statementToCode(e,"datasets"),i=this.valueToCode(e,"pattern"),n=this.valueToCode(e,"modifiers");return s(r("\n",t,r(" ","WHERE",i),n))}sparqlGroupGraphPattern(e){const t=this.valueToCode(e,"value");return s(r("\n","{",this.indent(t),"}"))}sparqlSubSelect(e){const t=this.valueToCode(e,"select"),i=this.valueToCode(e,"pattern"),n=this.valueToCode(e,"values");return s(r("\n",t,`WHERE ${i}`,this.valueToCode(e,"modifiers"),n))}sparqlTriplesSameSubject(e){var t;const i=this.valueToCode(e,"subject"),n=this.statementToCode(e,"predicates");let o;return o=(null===(t=e.getInputTargetBlock("predicates"))||void 0===t?void 0:t.getNextBlock())?r("\n",i,this.indent(n)):r(" ",i,n),s(o)}sparqlPropertyListNotEmpty(e){const t=r(" ",this.valueToCode(e,"predicate"),this.statementToCode(e,"objects"));return this.generateNext(e,t," ;\n")}sparqlGroupGraphPatternSub(e){return s(this.statementToCode(e,"items"))}sparqlBlankNodePropertyList(e){const t=e.getInputTargetBlock("predicates"),i=this.blockToCode(t);let n;return n=t&&t.getNextBlock()?r("\n","[",this.indent(i),"]"):r(" ","[",i,"]"),s(n)}sparqlCollection(e){return s(r("","(",this.statementToCode(e,"items"),")"))}sparqlOptionalGraphPattern(e){return s(r(" ","OPTIONAL",this.valueToCode(e,"value")))}sparqlGraphGraphPattern(e){return s(r(" ","GRAPH",this.valueToCode(e,"iri"),this.valueToCode(e,"patterns")))}sparqlServiceGraphPattern(e){const t=this.valueToCode(e,"iri");return s(r(" ","SERVICE",e.getFieldValue("silent"),t,this.valueToCode(e,"patterns")))}sparqlMinusGraphPattern(e){return s(r(" ","MINUS",this.valueToCode(e,"value")))}sparqlFilter(e){return s(r(" ","FILTER",this.valueToCode(e,"value")))}sparqlBind(e){return s(r(" ","BIND",this.valueToCode(e,"value")))}sparqlGroupOrUnionGraphPattern(e){return s(r("",...this.statementToCode(e,"items")))}sparqlPrefixDecl(e){return s(`PREFIX ${e.getFieldValue("prefix")}: ${this.valueToCode(e,"value")}`)}sparqlPrefixDeclDefault(e){return s(`PREFIX : ${this.valueToCode(e,"value")}`)}sparqlBase(e){return s(`BASE ${this.valueToCode(e,"value")}`)}sparqlNamedGraphClause(e){return s(`NAMED ${this.valueToCode(e,"value")}`)}sparqlSolutionModifier(e){const t=this.statementToCode(e,"group"),i=this.statementToCode(e,"having"),n=this.statementToCode(e,"order"),o=this.valueToCode(e,"limit"),r=this.valueToCode(e,"offset");return s(a("\n",[t,`GROUP BY ${t}`],[i,`HAVING ${i}`],[n,`ORDER BY ${n}`],[o,`LIMIT ${o}`],[r,`OFFSET ${r}`]))}sparqlOrdercondition(e){return s(r("",e.getFieldValue("operator"),this.valueToCode(e,"value")))}sparqlInlineData(e){return s(r(" ","VALUES",this.valueToCode(e,"value")))}sparqlInlineDataOneVar(e){return s(r(" ",this.valueToCode(e,"variable"),r(" ","{",this.statementToCode(e,"values")," }")))}sparqlInlineDataFull(e){const t=this.statementToCode(e,"variables"),i=this.statementToCode(e,"values");return s(r(" ",r("","(",t,")"),r("\n","{",this.indent(i),"}")))}sparqlA(){return s("a")}sparqlNegatedPath(e){return s(r("","!",this.valueToCode(e,"value")))}sparqlBracketedPath(e){return s(r("","(",this.valueToCode(e,"value"),")"))}sparqlPathWithModifier(e){const t=e.getFieldValue("modifier");return s(r("",this.valueToCode(e,"value"),t))}sparqlInversePath(e){return s(r("","^",this.valueToCode(e,"value")))}sparqlPathAlternative(e){return s(this.statementToCode(e,"items"))}sparqlPathSequence(e){return s(this.statementToCode(e,"items"))}sparqlInversePathOneInPropertySet(e){return s(r("","^",this.valueToCode(e,"value")))}sparqlPathOneInPropertySetAlternative(e){return s(r("","(",this.statementToCode(e,"items"),")"))}sparqlIrirefDefault(){return h()}sparqlIriref(e){return h(e.getFieldValue("value"))}sparqlPrefixedName(){return l("","")}sparqlPrefixedNamePrefix(e){return l(e.getFieldValue("prefix"),"")}sparqlPrefixedNameLocalName(e){return l("",e.getFieldValue("localName"))}sparqlPrefixedNamePrefixLocalName(e){return l(e.getFieldValue("prefix"),e.getFieldValue("localName"))}sparqlString(e){let t=e.getFieldValue("value"),i="'";return t.indexOf(i)>-1&&(i='"',t.indexOf('"')>-1&&(t=t.replace(/"/g,'\\"'))),t.indexOf("\n")>-1&&(i=[...Array(3)].map((()=>i)).join("")),s(`${i}${t}${i}`)}sparqlTypedLiteral(e){return s(`${this.valueToCode(e,"value")}^^${this.valueToCode(e,"datatype")}`)}sparqlLangString(e){return s(`${this.valueToCode(e,"value")}@${e.getFieldValue("language")}`)}sparqlNumericLiteral(e){return s(e.getFieldValue("value").toString())}sparqlBooleanLiteral(e){return s(("TRUE"===e.getFieldValue("value")).toString())}sparqlVar1(e){return this.var(e,"?")}sparqlVar2(e){return this.var(e,"$")}sparqlUndef(){return s("UNDEF")}sparqlNil(){return s("()")}sparqlAnon(){return s("[]")}sparqlBlankNodeLabel(e){return s(`_:${e.getFieldValue("value")}`)}sparqlGraphRefAllNamed(){return s("NAMED")}sparqlGraphRefAllAll(){return s("ALL")}sparqlBrackettedExpression(e){return s(`(${this.valueToCode(e,"value")})`)}sparqlBuiltinCall1(e){return s(`${e.getFieldValue("operator")}(${this.valueToCode(e,"arg1")})`)}sparqlBuiltinCall0(e){return s(`${e.getFieldValue("operator")}()`)}sparqlBuiltinCall2(e){return s(`${e.getFieldValue("operator")}(${this.valueToCode(e,"arg1")}, ${this.valueToCode(e,"arg2")})`)}sparqlBuiltinCall4(e){return s(`${e.getFieldValue("operator")}(${this.valueToCode(e,"arg1")}, ${this.valueToCode(e,"arg2")}, ${this.valueToCode(e,"arg3")}, ${this.valueToCode(e,"arg4")})`)}sparqlBuiltinCall3(e){return s(`${e.getFieldValue("operator")}(${this.valueToCode(e,"arg1")}, ${this.valueToCode(e,"arg2")}, ${this.valueToCode(e,"arg3")})`)}sparqlBuiltinCallN(e){return s(`${e.getFieldValue("operator")}(${this.statementToCode(e,"args")})`)}sparqlAdditiveExpression(e){const t=this.valueToCode(e,"left"),i=this.valueToCode(e,"right");return s(r(" ",t,e.getFieldValue("operator"),i))}sparqlMultiplicativeExpression(e){const t=this.valueToCode(e,"left"),i=this.valueToCode(e,"right");return s(r(" ",t,e.getFieldValue("operator"),i))}sparqlRelationalExpression(e){const t=this.valueToCode(e,"left"),i=this.valueToCode(e,"right");return s(r(" ",t,e.getFieldValue("operator"),i))}sparqlConditionalAndExpression(e){return s(r(" ",this.valueToCode(e,"left"),"&&",this.valueToCode(e,"right")))}sparqlConditionalOrExpression(e){return s(r(" ",this.valueToCode(e,"left"),"||",this.valueToCode(e,"right")))}sparqlRelationalExpressionIn(e){const t=this.valueToCode(e,"left"),i=this.statementToCode(e,"right");return s(r(" ",t,r("",e.getFieldValue("operator")," (",i,")")))}sparqlUnaryexpression(e){const t=e.getFieldValue("operator"),i=this.valueToCode(e,"left");return s(r("",t.replace("UMINUS","-"),i))}sparqlIriOrFunction(e){return s(r("",this.valueToCode(e,"iri"),"(",r(" ",e.getFieldValue("distinct"),this.statementToCode(e,"args")),")"))}sparqlBound(e){return s(r("","BOUND(",this.valueToCode(e,"value"),")"))}sparqlExists(e){return s(r(" ",e.getFieldValue("operator"),this.valueToCode(e,"value")))}sparqlAggregate(e){return s(r("",e.getFieldValue("operator"),"(",r(" ",e.getFieldValue("distinct"),this.valueToCode(e,"arg1")),")"))}sparqlCount(e){const t=this.valueToCode(e,"arg1");return s(r("","COUNT(",r(" ",e.getFieldValue("distinct"),e.getFieldValue("star"),t),")"))}sparqlGroup_Concat(e){const t=this.valueToCode(e,"arg1"),i=e.getFieldValue("distinct"),n=this.valueToCode(e,"separator");return s(a("","GROUP_CONCAT(",r(" ",i,t),[n,r(" ","; SEPARATOR =",n)],")"))}sparqlEmbTp(e){return s(a(" ","<<",this.valueToCode(e,"subject"),this.valueToCode(e,"predicate"),this.valueToCode(e,"object"),">>"))}sparqlObjectListItemAnnotationPattern(e){const t=this.valueToCode(e,"value"),i=this.statementToCode(e,"annotations"),n=r(" ",t,r("\n","{|",this.indent(i),"|}"));return this.generateNext(e,n,", ")}sparqlVarOrExpressionAsVarItem(e){return this.item(" ",e)}sparqlObjectListItem(e){return this.item(", ",e)}sparqlGroupGraphPatternSubItem(e){return this.item(" .\n",e)}sparqlPrologueItem(e){return this.item("\n",e)}sparqlVarOrIriItem(e){return this.item(" ",e)}sparqlDatasetClause(e){const t=`FROM ${this.valueToCode(e,"value")}`;return this.generateNext(e,t,"\n")}sparqlExpressionListItem(e){return this.item(", ",e)}sparqlGroupConditionItem(e){return this.item(" ",e)}sparqlHavingConditionItem(e){return this.item(" ",e)}sparqlOrderConditionItem(e){return this.item(" ",e)}sparqlGraphNodeItem(e){return this.item(" ",e)}sparqlGroupGraphPatternItem(e){return this.item("\nUNION\n",e)}sparqlPathSequencItem(e){return this.item("/",e)}sparqlPathAlternativeItem(e){return this.item("|",e)}sparqlPathOneInPropertySetAlternativeItem(e){return this.item("|",e)}sparqlDataBlockValuesItem(e){const t=r("","(",r(" ",this.statementToCode(e,"items")),")");return this.generateNext(e,t,"\n")}sparqlDataBlockValueItem(e){return this.item(" ",e)}sparqlVarItem(e){return this.item(" ",e)}sparqlTriplesSameSubjectItem(e){return this.item(" .\n",e)}sparqlUpdateItem(e){return this.item(" ;\n\n",e)}sparqlQuadPatternItem(e){return this.item(" .\n",e)}valueToCode(e,t){return super.valueToCode(e,t,n.Order.Atomic)}indent(e){if(e)return this.prefixLines(e,"\t")}var(e,t){return s(`${t}${e.getFieldValue("value")}`)}item(e,t){const i=this.valueToCode(t,"value");return this.generateNext(t,i,e)}generateNext(e,t,i){return e.getNextBlock()&&(t+=i),t}}t.default=u},210:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.StringifiedMap=void 0;class i extends Map{constructor(){super(...arguments),this.keyMap=new Map}set(e,t){const i=JSON.stringify(e);return this.keyMap.set(i,e),super.set(i,t),this}get(e){return super.get(JSON.stringify(e))}has(e){return super.has(JSON.stringify(e))}entries(){return this[Symbol.iterator]()}*[Symbol.iterator](){for(const[e,t]of super[Symbol.iterator]())yield[this.keyMap.get(e),t]}}t.StringifiedMap=i},150:(e,t)=>{"use strict";var i,n,o;Object.defineProperty(t,"__esModule",{value:!0}),t.Order=t.XSD=t.RDF=void 0,function(e){e.type="http://www.w3.org/1999/02/22-rdf-syntax-ns#type",e.langString="http://www.w3.org/1999/02/22-rdf-syntax-ns#langString",e.nil="http://www.w3.org/1999/02/22-rdf-syntax-ns#nil",e.first="http://www.w3.org/1999/02/22-rdf-syntax-ns#first",e.rest="http://www.w3.org/1999/02/22-rdf-syntax-ns#rest"}(i||(t.RDF=i={})),function(e){e.string="http://www.w3.org/2001/XMLSchema#string",e.integer="http://www.w3.org/2001/XMLSchema#integer",e.decimal="http://www.w3.org/2001/XMLSchema#decimal",e.double="http://www.w3.org/2001/XMLSchema#double",e.boolean="http://www.w3.org/2001/XMLSchema#boolean"}(n||(t.XSD=n={})),function(e){e[e.None=0]="None",e[e.Atomic=1]="Atomic"}(o||(t.Order=o={}))},861:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.vars=s,t.varsOrIris=function(e,t,i){s(e,t,i),u(e,t,i)},t.graphTerms=r,t.graphNodes=function(e,t,i){s(e,t,i),r(e,t,i),h(e,t,i),S(e,"sparql11_embtp",t,"<< >>",i)},t.terms=a,t.sameSubjectTriples=l,t.triplesNodes=h,t.iris=u,t.iriRefs=c,t.groupGraphPatternSubs=function(e,t,i){l(e,t,i),S(e,"sparql11_graphgraphpattern",t,"Graph",i),S(e,"sparql11_servicegraphpattern",t,"Service",i),S(e,"sparql11_bind",t,"Bind",i),S(e,"sparql11_minusgraphpattern",t,"Minus",i),S(e,"sparql11_grouporuniongraphpattern",t,"Union",i),S(e,"sparql11_filter",t,"Filter",i),S(e,"sparql11_optionalgraphpattern",t,"Optional",i),d(e,t,i)},t.groupGraphPattern=d,t.updateGraphRefAll=function(e,t,i){p(e,t,i),S(e,"sparql11_graphrefallnamed",t,"Named",i),S(e,"sparql11_graphrefallall",t,"All",i)},t.updateGraphOrDefault=p,t.updateGraph=g,t.expressions=function(e,t,i){E(e,t,i),S(e,"sparql11_conditionalorexpression",t,"∨",i)},t.andExpressions=E,t.relationalExpressions=T,t.additiveExpressions=_,t.multiplicativeExpressions=f,t.unaryExpressions=m,t.primaryExpressions=b,t.constraints=C,t.functionExpressions=v,t.verbs=function(e,t,i){s(e,t,i),I(e,t,i)},t.paths=I,t.sequencePaths=N,t.eltOrInversePaths=y,t.eltPaths=A,t.primaryPaths=k,t.separator=function(e){const t={displayText:()=>"==========",preconditionFn:t=>t.block.type===e?"disabled":"hidden",callback:()=>{},scopeType:n.ContextMenuRegistry.ScopeType.BLOCK,id:"separator"+ ++o,weight:0};n.ContextMenuRegistry.registry.register(t)},t.workspace=function(e,t){n.ContextMenuRegistry.registry.register({displayText:()=>e,preconditionFn:()=>"enabled",callback:e=>{const i=e.workspace.newBlock(t);i.initSvg(),i.render()},scopeType:n.ContextMenuRegistry.ScopeType.WORKSPACE,id:t,weight:0})},t.property=S,t.collection=function(e,t,i,n,o){O(e,t,i,n,(e=>{const n=e.block.workspace.newBlock(t);n.initSvg(),n.render();const o=e.block.getInput(i).connection,s=o.targetBlock();s?n.previousConnection.connect(s.lastConnectionInStack(!0)):n.previousConnection.connect(o)}),o)};const n=i(180);let o=0;function s(e,t,i){S(e,"sparql11_var1",t,"?s",i),S(e,"sparql11_var2",t,"$s",i)}function r(e,t,i){a(e,t,i),S(e,"sparql11_anon",t,"[]",i),S(e,"sparql11_blanknodelabel",t,"_:label",i),S(e,"sparql11_nil",t,"()",i)}function a(e,t,i){u(e,t,i),S(e,"sparql11_typedliteral",t,"''^^<>",i),S(e,"sparql11_langstring",t,"''@en",i),S(e,"sparql11_numericliteral",t,"42",i),S(e,"sparql11_booleanliteral",t,"✓",i),S(e,"sparql11_string",t,"''",i)}function l(e,t,i){S(e,"sparql11_triplessamesubject",t,"Triples same subject",i),h(e,t,i)}function h(e,t,i){S(e,"sparql11_blanknodepropertylist",t,"Blank node property list",i),S(e,"sparql11_collection",t,"Collection",i)}function u(e,t,i){c(e,t,i),S(e,"sparql11_prefixedname",t,":",i),S(e,"sparql11_prefixednameprefix",t,"prefix:",i),S(e,"sparql11_prefixednamelocalname",t,":name",i),S(e,"sparql11_prefixednameprefixlocalname",t,"prefix:name",i)}function c(e,t,i){S(e,"sparql11_iriref",t,"<iri>",i),S(e,"sparql11_irirefdefault",t,"<>",i)}function d(e,t,i){S(e,"sparql11_groupgraphpattern",t,"{}",i)}function p(e,t,i){g(e,t,i),S(e,"sparql11_graphordefault",t,"Default",i)}function g(e,t,i){S(e,"sparql11_graphref",t,"Graph",i)}function E(e,t,i){T(e,t,i),S(e,"sparql11_conditionalandexpression",t,"∧",i)}function T(e,t,i){_(e,t,i),S(e,"sparql11_relationalexpression",t,"=≠<>≤≥",i),S(e,"sparql11_relationalexpressionin",t,"in/not in",i)}function _(e,t,i){f(e,t,i),S(e,"sparql11_additiveexpression",t,"+−",i)}function f(e,t,i){m(e,t,i),S(e,"sparql11_multiplicativeexpression",t,"×÷",i)}function m(e,t,i){b(e,t,i),S(e,"sparql11_unaryexpression",t,"¬+−",i)}function b(e,t,i){s(e,t,i),a(e,t,i),C(e,t,i)}function C(e,t,i){v(e,t,i),S(e,"sparql11_brackettedexpression",t,"()",i)}function v(e,t,i){S(e,"sparql11_builtincall0",t,"𝛌0",i),S(e,"sparql11_builtincall1",t,"𝛌1",i),S(e,"sparql11_builtincall2",t,"𝛌2",i),S(e,"sparql11_builtincall3",t,"𝛌3",i),S(e,"sparql11_builtincall4",t,"𝛌4",i),S(e,"sparql11_builtincalln",t,"𝛌𝐧",i),S(e,"sparql11_iriorfunction",t,"<>𝐧",i),S(e,"sparql11_exists",t,"Exists",i),S(e,"sparql11_bound",t,"Bound",i),S(e,"sparql11_aggregate",t,"Aggregate",i),S(e,"sparql11_count",t,"Count",i),S(e,"sparql11_group_concat",t,"Group concatenation",i)}function I(e,t,i){N(e,t,i),S(e,"sparql11_pathalternative",t,"|",i)}function N(e,t,i){y(e,t,i),S(e,"sparql11_pathsequence",t,"/",i)}function y(e,t,i){A(e,t,i),S(e,"sparql11_inversepath",t,"^",i)}function A(e,t,i){k(e,t,i),S(e,"sparql11_pathwithmodifier",t,"?*+",i)}function k(e,t,i){u(e,t,i),S(e,"sparql11_a",t,"a",i),S(e,"sparql11_negatedpath",t,"!",i),S(e,"sparql11_bracketedpath",t,"()",i)}function S(e,t,i,n,o){O(e,t,i,n,(e=>{const n=e.block.workspace.newBlock(t);n.initSvg(),n.render();const o=e.block;n.outputConnection.connect(o.getInput(i).connection)}),o)}function O(e,t,i,o,s,r){r&&(o=`${r}: ${o}`);const a={displayText:()=>o,preconditionFn:t=>t.block.type===e?"enabled":"hidden",callback:s,scopeType:n.ContextMenuRegistry.ScopeType.BLOCK,id:e+t+i,weight:0};n.ContextMenuRegistry.registry.register(a)}},442:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=i(180),o=i(715);n.Blocks.sparql11_prologueitem={init:function(){this.appendValueInput("value").setCheck(["BaseDecl","PrefixDecl"]),this.setInputsInline(!1),this.setPreviousStatement(!0,"PrologueItem"),this.setNextStatement(!0,"PrologueItem"),this.setColour(196)}},n.Blocks.sparql11_base={init:function(){this.appendValueInput("value").setCheck("IRIREF").appendField("BASE"),this.setInputsInline(!1),this.setOutput(!0,"BaseDecl"),this.setColour(196)}},n.Blocks.sparql11_prefixdecl={init:function(){this.appendValueInput("value").setCheck("IRIREF").appendField("PREFIX").appendField(new n.FieldTextInput(""),"prefix").appendField(":"),this.setOutput(!0,"PrefixDecl"),this.setColour(196)}},n.Blocks.sparql11_prefixdecldefault={init:function(){this.appendValueInput("value").setCheck("IRIREF").appendField("PREFIX :"),this.setOutput(!0,"PrefixDecl"),this.setColour(196)}},n.Blocks.sparql11_query={init:function(){this.appendStatementInput("prologue").setCheck("PrologueItem"),this.appendValueInput("value").setCheck(["SelectQuery","ConstructQuery","DescribeQuery","AskQuery"]),this.appendValueInput("values").setCheck("ValuesClause"),this.setColour(196)}},n.Blocks.sparql11_selectquery={init:function(){this.appendValueInput("select").setCheck("SelectClause").appendField("SELECT"),this.appendValueInput("where").setCheck("QueryCommon"),this.setInputsInline(!1),this.setOutput(!0,"SelectQuery"),this.setColour(196)}},n.Blocks.sparql11_simpleconstructquery={init:function(){this.appendDummyInput().appendField("CONSTRUCT"),this.appendStatementInput("datasets").setCheck("DatasetClause"),this.appendStatementInput("where").setCheck("TriplesSameSubjectItem").appendField("WHERE {"),this.appendValueInput("modifiers").setCheck("SolutionModifier").appendField("}"),this.setOutput(!0,"ConstructQuery"),this.setColour(196)}},n.Blocks.sparql11_constructquery={init:function(){this.appendStatementInput("template").setCheck("TriplesSameSubjectItem").appendField("CONSTRUCT {"),this.appendValueInput("where").setCheck("QueryCommon").appendField("}"),this.setOutput(!0,"ConstructQuery"),this.setColour(196)}},n.Blocks.sparql11_describequery={init:function(){this.appendStatementInput("subject").setCheck("VarOrIriItem").appendField("DESCRIBE").appendField(new n.FieldDropdown([["",""],["*","*"]]),"star"),this.appendValueInput("where").setCheck("QueryCommon"),this.setOutput(!0,"DescribeQuery"),this.setColour(196)}},n.Blocks.sparql11_askquery={init:function(){this.appendValueInput("value").setCheck("QueryCommon").appendField("ASK"),this.setOutput(!0,"AskQuery"),this.setColour(196)}},n.Blocks.sparql11_varoririitem={init:function(){this.appendValueInput("value").setCheck("VarOrIri"),this.setPreviousStatement(!0,"VarOrIriItem"),this.setNextStatement(!0,"VarOrIriItem"),this.setColour(196)}},n.Blocks.sparql11_triplessamesubjectitem={init:function(){this.appendValueInput("value").setCheck("TriplesSameSubject"),this.setPreviousStatement(!0,"TriplesSameSubjectItem"),this.setNextStatement(!0,"TriplesSameSubjectItem"),this.setColour(196)}},n.Blocks.sparql11_update={init:function(){this.appendStatementInput("prologue").setCheck("PrologueItem"),this.appendStatementInput("items").setCheck("UpdateItem"),this.setColour(196)}},n.Blocks.sparql11_updateitem={init:function(){this.appendValueInput("value").setCheck(["Update1"]),this.setPreviousStatement(!0,"UpdateItem"),this.setNextStatement(!0,"UpdateItem"),this.setColour(196)}},n.Blocks.sparql11_insertdeletewhere={init:function(){this.appendValueInput("pattern").setCheck("QuadPattern").appendField(new n.FieldDropdown([["INSERT DATA","INSERT DATA"],["DELETE DATA","DELETE DATA"],["DELETE WHERE","DELETE WHERE"]]),"operator"),this.setOutput(!0,"Update1"),this.setColour(196)}},n.Blocks.sparql11_quadpattern={init:function(){this.appendDummyInput().appendField("{"),this.appendStatementInput("items").setCheck("QuadPatternItem"),this.appendDummyInput().appendField("}"),this.setInputsInline(!1),this.setOutput(!0,"QuadPattern"),this.setColour(196)}},n.Blocks.sparql11_quadpatternitem={init:function(){this.appendValueInput("value").setCheck(["TriplesSameSubject","QuadsNotTriples"]),this.setInputsInline(!1),this.setPreviousStatement(!0,"QuadPatternItem"),this.setNextStatement(!0,"QuadPatternItem"),this.setColour(196)}},n.Blocks.sparql11_quadsnottriples={init:function(){this.appendValueInput("name").setCheck("VarOrIri").appendField("GRAPH {"),this.appendStatementInput("triples").setCheck("TriplesSameSubjectItem"),this.appendDummyInput().appendField("}"),this.setInputsInline(!1),this.setOutput(!0,"QuadsNotTriples"),this.setColour(196)}},n.Blocks.sparql11_modify={init:function(){this.appendValueInput("iri").setCheck("iri").appendField("WITH"),this.appendValueInput("delete").setCheck("QuadPattern").appendField("DELETE"),this.appendValueInput("insert").setCheck("QuadPattern").appendField("INSERT"),this.appendStatementInput("using").setCheck("UsingClause"),this.appendValueInput("where").setCheck("GroupGraphPattern").appendField("WHERE"),this.setInputsInline(!1),this.setOutput(!0,"Update1"),this.setColour(196)}},n.Blocks.sparql11_usingclause={init:function(){this.appendValueInput("value").setCheck(["iri","NamedGraphClause"]).appendField("USING"),this.setInputsInline(!1),this.setPreviousStatement(!0,"UsingClause"),this.setNextStatement(!0,"UsingClause"),this.setColour(196)}},n.Blocks.sparql11_load={init:function(){this.appendValueInput("source").setCheck("iri").appendField("LOAD").appendField(new n.FieldDropdown([["",""],["SILENT","SILENT"]]),"silent"),this.appendValueInput("destination").setCheck("GraphRef").appendField("INTO"),this.setOutput(!0,"Update1"),this.setColour(196)}},n.Blocks.sparql11_create={init:function(){this.appendValueInput("graph").setCheck("GraphRef").appendField("CREATE").appendField(new n.FieldDropdown([["",""],["SILENT","SILENT"]]),"silent"),this.setOutput(!0,"Update1"),this.setColour(196)}},n.Blocks.sparql11_addmovecopy={init:function(){this.appendValueInput("source").setCheck("GraphOrDefault").appendField(new n.FieldDropdown([["ADD","ADD"],["MOVE","MOVE"],["COPY","COPY"]]),"operator").appendField(new n.FieldDropdown([["",""],["SILENT","SILENT"]]),"silent"),this.appendValueInput("destination").setCheck("GraphOrDefault").appendField("TO"),this.setOutput(!0,"Update1"),this.setColour(196)}},n.Blocks.sparql11_cleardrop={init:function(){this.appendValueInput("graph").setCheck("GraphRefAll").appendField(new n.FieldDropdown([["CLEAR","CLEAR"],["DROP","DROP"]]),"operator").appendField(new n.FieldDropdown([["",""],["SILENT","SILENT"]]),"silent"),this.setOutput(!0,"Update1"),this.setColour(196)}},n.Blocks.sparql11_graphref={init:function(){this.appendValueInput("value").setCheck("iri").appendField("GRAPH"),this.setOutput(!0,["GraphRef","GraphRefAll","GraphOrDefault"]),this.setColour(196)}},n.Blocks.sparql11_graphrefallnamed={init:function(){this.appendDummyInput().appendField("NAMED"),this.setOutput(!0,"GraphRefAll"),this.setColour(196)}},n.Blocks.sparql11_graphrefallall={init:function(){this.appendDummyInput().appendField("ALL"),this.setOutput(!0,"GraphRefAll"),this.setColour(196)}},n.Blocks.sparql11_graphordefault={init:function(){this.appendDummyInput().appendField("DEFAULT"),this.setOutput(!0,["GraphRefAll","GraphOrDefault"]),this.setColour(196)}},n.Blocks.sparql11_triplessamesubject={init:function(){this.appendValueInput("subject").setCheck(["VarOrTermOrEmbTP","TriplesNode"]),this.appendStatementInput("predicates").setCheck("PropertyListNotEmpty"),this.setOutput(!0,"TriplesSameSubject"),this.setColour(0)}},n.Blocks.sparql11_propertylistnotempty={init:function(){this.appendValueInput("predicate").setCheck(["Verb","Path"]),this.appendStatementInput("objects").setCheck("ObjectListItem"),this.setPreviousStatement(!0,"PropertyListNotEmpty"),this.setNextStatement(!0,"PropertyListNotEmpty"),this.setColour(131)}},n.Blocks.sparql11_objectlistitem={init:function(){this.appendValueInput("value").setCheck("GraphNode"),this.setPreviousStatement(!0,"ObjectListItem"),this.setNextStatement(!0,"ObjectListItem"),this.setColour(294)}},n.Blocks.sparql11_objectlistitemannotationpattern={init:function(){this.appendValueInput("value").appendField("{|").setCheck("GraphNode"),this.appendStatementInput("annotations").setCheck("PropertyListNotEmpty"),this.appendDummyInput().appendField("|}"),this.setPreviousStatement(!0,"ObjectListItem"),this.setNextStatement(!0,"ObjectListItem"),this.setColour(294)}},n.Blocks.sparql11_groupgraphpattern={init:function(){this.appendDummyInput().appendField("{"),this.appendValueInput("value").setCheck(["SubSelect","GroupGraphPatternSub","TriplesNode","TriplesSameSubject","GraphPatternNotTriples","GroupGraphPattern"]),this.appendDummyInput().appendField("}"),this.setInputsInline(!1),this.setOutput(!0,"GroupGraphPattern"),this.setColour(65)}},n.Blocks.sparql11_subselect={init:function(){this.appendValueInput("select").setCheck("SelectClause").appendField("SELECT"),this.appendValueInput("pattern").setCheck("GroupGraphPattern").appendField("WHERE"),this.appendValueInput("modifiers").setCheck("SolutionModifier"),this.appendValueInput("values").setCheck("ValuesClause"),this.setOutput(!0,"SubSelect"),this.setColour(65)}},n.Blocks.sparql11_groupgraphpatternsub={init:function(){this.appendStatementInput("items").setCheck("GroupGraphPatternSubItem"),this.setOutput(!0,"GroupGraphPatternSub"),this.setColour(65)}},n.Blocks.sparql11_groupgraphpatternsubitem={init:function(){this.appendValueInput("value").setCheck(["GroupGraphPattern","TriplesNode","TriplesSameSubject","GraphPatternNotTriples"]),this.setPreviousStatement(!0,"GroupGraphPatternSubItem"),this.setNextStatement(!0,"GroupGraphPatternSubItem"),this.setColour(65)}},n.Blocks.sparql11_graphgraphpattern={init:function(){this.appendValueInput("iri").setCheck("VarOrIri").appendField("GRAPH"),this.appendValueInput("patterns").setCheck("GroupGraphPattern"),this.setInputsInline(!1),this.setOutput(!0,["GraphGraphPattern","GraphPatternNotTriples"]),this.setColour(65)}},n.Blocks.sparql11_servicegraphpattern={init:function(){this.appendValueInput("iri").setCheck("VarOrIri").appendField("SERVICE").appendField(new n.FieldDropdown([["",""],["SILENT","SILENT"]]),"silent"),this.appendValueInput("patterns").setCheck("GroupGraphPattern"),this.setOutput(!0,["ServiceGraphPattern","GraphPatternNotTriples"]),this.setColour(65)}},n.Blocks.sparql11_bind={init:function(){this.appendValueInput("value").setCheck("ExpressionAsVar").appendField("BIND"),this.setOutput(!0,["Bind","GraphPatternNotTriples"]),this.setColour(65)}},n.Blocks.sparql11_minusgraphpattern={init:function(){this.appendValueInput("value").setCheck("GroupGraphPattern").appendField("MINUS"),this.setOutput(!0,["MinusGraphPattern","GraphPatternNotTriples"]),this.setColour(65)}},n.Blocks.sparql11_grouporuniongraphpattern={init:function(){this.appendStatementInput("items").setCheck("GroupGraphPatternItem").appendField("UNION"),this.setInputsInline(!1),this.setOutput(!0,["GroupOrUnionGraphPattern","GraphPatternNotTriples"]),this.setColour(65)}},n.Blocks.sparql11_groupgraphpatternitem={init:function(){this.appendValueInput("value").setCheck("GroupGraphPattern"),this.setPreviousStatement(!0,"GroupGraphPatternItem"),this.setNextStatement(!0,"GroupGraphPatternItem"),this.setColour(65)}},n.Blocks.sparql11_filter={init:function(){this.appendValueInput("value").setCheck("Constraint").appendField("FILTER"),this.setOutput(!0,["Filter","GraphPatternNotTriples"]),this.setColour(65)}},n.Blocks.sparql11_optionalgraphpattern={init:function(){this.appendValueInput("value").setCheck("GroupGraphPattern").appendField("OPTIONAL"),this.setOutput(!0,"GraphPatternNotTriples"),this.setColour(65)}},n.Blocks.sparql11_inlinedata={init:function(){this.appendValueInput("value").setCheck("DataBlock").appendField("VALUES"),this.setOutput(!0,["InlineData","GraphPatternNotTriples","ValuesClause"]),this.setColour(65)}},n.Blocks.sparql11_inlinedataonevar={init:function(){this.appendValueInput("variable").setCheck("Var"),this.appendDummyInput().appendField("{"),this.appendStatementInput("values").setCheck("DataBlockValueItem"),this.appendDummyInput().appendField("}"),this.setOutput(!0,"DataBlock"),this.setColour(65)}},n.Blocks.sparql11_inlinedatafull={init:function(){this.appendDummyInput().appendField("("),this.appendStatementInput("variables").setCheck("VarItem"),this.appendDummyInput().appendField(")"),this.appendDummyInput().appendField("{"),this.appendStatementInput("values").setCheck("DataBlockValuesItem"),this.appendDummyInput().appendField("}"),this.setOutput(!0,["InlineDataFull","DataBlock"]),this.setColour(65)}},n.Blocks.sparql11_datablockvaluesitem={init:function(){this.appendDummyInput().appendField("("),this.appendStatementInput("items").setCheck("DataBlockValueItem"),this.appendDummyInput().appendField(")"),this.setPreviousStatement(!0,"DataBlockValuesItem"),this.setNextStatement(!0,"DataBlockValuesItem"),this.setColour(65)}},n.Blocks.sparql11_datablockvalueitem={init:function(){this.appendValueInput("value").setCheck("DataBlockValue"),this.setPreviousStatement(!0,"DataBlockValueItem"),this.setNextStatement(!0,"DataBlockValueItem"),this.setColour(65)}},n.Blocks.sparql11_a={init:function(){this.appendDummyInput().appendField("a"),this.setOutput(!0,["a","PathPrimary","PathElt","PathEltOrInverse","PathSequence","Path","VerbPath","PathOneInPropertySet","PathNegatedPropertySet","Verb"]),this.setColour(228)}},n.Blocks.sparql11_negatedpath={init:function(){this.appendValueInput("value").setCheck("PathNegatedPropertySet").appendField("!"),this.setInputsInline(!0),this.setOutput(!0,["PathPrimary","PathElt","PathEltOrInverse","PathSequence","Path","VerbPath"]),this.setColour(228)}},n.Blocks.sparql11_bracketedpath={init:function(){this.appendValueInput("value").setCheck("Path").appendField("("),this.appendDummyInput().appendField(")"),this.setOutput(!0,["PathPrimary","PathElt","PathEltOrInverse","PathSequence","Path","VerbPath"]),this.setColour(228)}},n.Blocks.sparql11_pathwithmodifier={init:function(){this.appendValueInput("value").setCheck("PathPrimary").appendField(""),this.appendDummyInput().appendField(new n.FieldDropdown([["",""],["?","?"],["*","*"],["+","+"]]),"modifier"),this.setInputsInline(!0),this.setOutput(!0,["PathElt","PathEltOrInverse","PathSequence","Path","VerbPath"]),this.setColour(228)}},n.Blocks.sparql11_inversepath={init:function(){this.appendValueInput("value").setCheck("PathElt").appendField("^"),this.setInputsInline(!1),this.setInputsInline(!0),this.setOutput(!0,["PathEltOrInverse","PathSequence","Path","VerbPath"]),this.setColour(228)}},n.Blocks.sparql11_pathalternative={init:function(){this.appendDummyInput().appendField("|"),this.appendStatementInput("items").setCheck("PathAlternativeItem"),this.setInputsInline(!0),this.setOutput(!0,["Path","VerbPath"]),this.setColour(228)}},n.Blocks.sparql11_pathsequence={init:function(){this.appendDummyInput().appendField("/"),this.appendStatementInput("items").setCheck("PathSequenceItem"),this.setInputsInline(!0),this.setOutput(!0,["PathSequence","Path","VerbPath"]),this.setColour(228)}},n.Blocks.sparql11_inversepathoneinpropertyset={init:function(){this.appendValueInput("value").setCheck(["iri","a"]).appendField("^"),this.setInputsInline(!0),this.setOutput(!0,["PathOneInPropertySet","PathNegatedPropertySet"]),this.setColour(228)}},n.Blocks.sparql11_pathoneinpropertysetalternative={init:function(){this.appendDummyInput().appendField("(|)"),this.appendStatementInput("items").setCheck("PathOneInPropertySetAlternativeItem"),this.setInputsInline(!0),this.setOutput(!0,"PathNegatedPropertySet"),this.setColour(228)}},n.Blocks.sparql11_pathsequencitem={init:function(){this.appendValueInput("value").setCheck("PathEltOrInverse"),this.setInputsInline(!1),this.setPreviousStatement(!0,"PathSequenceItem"),this.setNextStatement(!0,"PathSequenceItem"),this.setColour(228)}},n.Blocks.sparql11_pathalternativeitem={init:function(){this.appendValueInput("value").setCheck("PathSequence"),this.setInputsInline(!1),this.setPreviousStatement(!0,"PathAlternativeItem"),this.setNextStatement(!0,"PathAlternativeItem"),this.setColour(228)}},n.Blocks.sparql11_pathoneinpropertysetalternativeitem={init:function(){this.appendValueInput("value").setCheck("PathOneInPropertySet"),this.setPreviousStatement(!0,"PathOneInPropertySetAlternativeItem"),this.setNextStatement(!0,"PathOneInPropertySetAlternativeItem"),this.setColour(228)}},n.Blocks.sparql11_querycommon={init:function(){this.appendStatementInput("datasets").setCheck("DatasetClause"),this.appendValueInput("pattern").setCheck("GroupGraphPattern").appendField("WHERE"),this.appendValueInput("modifiers").setCheck("SolutionModifier"),this.setOutput(!0,"QueryCommon"),this.setColour(196)}},n.Blocks.sparql11_selectclause={init:function(){this.appendStatementInput("vars").setCheck("VarOrExpressionAsVarItem").appendField(new n.FieldDropdown([["",""],["DISTINCT","DISTINCT"],["REDUCED","REDUCED"]]),"distinctOrReduced").appendField(new n.FieldDropdown([["",""],["*","*"]]),"star"),this.setOutput(!0,"SelectClause"),this.setColour(196)}},n.Blocks.sparql11_expressionasvar={init:function(){this.appendValueInput("value").setCheck(["Expression","EmbTP"]).appendField("("),this.appendDummyInput().appendField("AS"),this.appendValueInput("name").setCheck("Var"),this.appendDummyInput().appendField(")"),this.setInputsInline(!0),this.setOutput(!0,["ExpressionAsVar","GroupCondition"]),this.setColour(98)}},n.Blocks.sparql11_undef={init:function(){this.appendDummyInput().appendField("UNDEF"),this.setOutput(!0,"DataBlockValue"),this.setColour(65)}},n.Blocks.sparql11_datasetclause={init:function(){this.appendValueInput("value").setCheck(["iri","NamedGraphClause"]).appendField("FROM"),this.setInputsInline(!1),this.setPreviousStatement(!0,"DatasetClause"),this.setNextStatement(!0,"DatasetClause"),this.setColour(196)}},n.Blocks.sparql11_namedgraphclause={init:function(){this.appendValueInput("value").setCheck("iri").appendField("NAMED"),this.setOutput(!0,"NamedGraphClause"),this.setColour(196)}},n.Blocks.sparql11_solutionmodifier={init:function(){this.appendStatementInput("group").setCheck("GroupConditionItem").appendField("GROUP BY"),this.appendStatementInput("having").setCheck("HavingConditionItem").appendField("HAVING"),this.appendStatementInput("order").setCheck("OrderConditionItem").appendField("ORDER BY"),this.appendValueInput("limit").setCheck("NumericLiteral").appendField("LIMIT"),this.appendValueInput("offset").setCheck("NumericLiteral").appendField("OFFSET"),this.setOutput(!0,"SolutionModifier"),this.setColour(196)}},n.Blocks.sparql11_ordercondition={init:function(){this.appendValueInput("value").setCheck("BrackettedExpression").appendField(new n.FieldDropdown([["ASC","ASC"],["DESC","DESC"]]),"operator"),this.setOutput(!0,"OrderCondition"),this.setColour(196)}},n.Blocks.sparql11_groupconditionitem={init:function(){this.appendValueInput("value").setCheck("GroupCondition"),this.setPreviousStatement(!0,"GroupConditionItem"),this.setNextStatement(!0,"GroupConditionItem"),this.setColour(196)}},n.Blocks.sparql11_havingconditionitem={init:function(){this.appendValueInput("value").setCheck("Constraint"),this.setPreviousStatement(!0,"HavingConditionItem"),this.setNextStatement(!0,"HavingConditionItem"),this.setColour(196)}},n.Blocks.sparql11_orderconditionitem={init:function(){this.appendValueInput("value").setCheck(["OrderCondition","Constraint","Var"]),this.setPreviousStatement(!0,"OrderConditionItem"),this.setNextStatement(!0,"OrderConditionItem"),this.setColour(196)}},n.Blocks.sparql11_varorexpressionasvaritem={init:function(){this.appendValueInput("value").setCheck(["Var","ExpressionAsVar"]),this.setInputsInline(!1),this.setPreviousStatement(!0,"VarOrExpressionAsVarItem"),this.setNextStatement(!0,"VarOrExpressionAsVarItem"),this.setColour(196)}},n.Blocks.sparql11_brackettedexpression={init:function(){this.appendValueInput("value").setCheck("Expression").appendField("("),this.appendDummyInput().appendField(")"),this.setOutput(!0,["BrackettedExpression","PrimaryExpression","UnaryExpression","MultiplicativeExpression","AdditiveExpression","RelationalExpression","ConditionalAndExpression","ConditionalOrExpression","Expression","Constraint"]),this.setColour(261)}},n.Blocks.sparql11_multiplicativeexpression={init:function(){this.appendValueInput("left").setCheck("UnaryExpression"),this.appendValueInput("right").setCheck("UnaryExpression").appendField(new n.FieldDropdown([["*","*"],["/","/"]]),"operator"),this.setInputsInline(!0),this.setOutput(!0,["MultiplicativeExpression","AdditiveExpression","RelationalExpression","ConditionalAndExpression","ConditionalOrExpression","Expression"]),this.setColour(261)}},n.Blocks.sparql11_additiveexpression={init:function(){this.appendValueInput("left").setCheck("MultiplicativeExpression"),this.appendValueInput("right").setCheck("MultiplicativeExpression").appendField(new n.FieldDropdown([["+","+"],["-","-"]]),"operator"),this.setInputsInline(!0),this.setOutput(!0,["AdditiveExpression","RelationalExpression","ConditionalAndExpression","ConditionalOrExpression","Expression"]),this.setColour(261)}},n.Blocks.sparql11_relationalexpression={init:function(){this.appendValueInput("left").setCheck("AdditiveExpression"),this.appendValueInput("right").setCheck("AdditiveExpression").appendField(new n.FieldDropdown([["=","="],["!=","!="],["<","<"],[">",">"],["<=","<="],[">=",">="]]),"operator"),this.setInputsInline(!0),this.setOutput(!0,["RelationalExpression","ConditionalAndExpression","ConditionalOrExpression","Expression"]),this.setColour(261)}},n.Blocks.sparql11_relationalexpressionin={init:function(){this.appendValueInput("left").setCheck("AdditiveExpression"),this.appendStatementInput("right").setCheck("ExpressionListItem").appendField(new n.FieldDropdown([["IN","IN"],["NOT IN","NOT IN"]]),"operator"),this.setInputsInline(!0),this.setOutput(!0,["RelationalExpression","ConditionalAndExpression","ConditionalOrExpression","Expression"]),this.setColour(261)}},n.Blocks.sparql11_conditionalandexpression={init:function(){this.appendValueInput("left").setCheck("RelationalExpression"),this.appendValueInput("right").setCheck("RelationalExpression").appendField("&&"),this.setInputsInline(!0),this.setOutput(!0,["ConditionalAndExpression","ConditionalOrExpression","Expression"]),this.setColour(261)}},n.Blocks.sparql11_conditionalorexpression={init:function(){this.appendValueInput("left").setCheck("ConditionalAndExpression"),this.appendValueInput("right").setCheck("ConditionalAndExpression").appendField("||"),this.setInputsInline(!0),this.setOutput(!0,["ConditionalOrExpression","Expression"]),this.setColour(261)}},n.Blocks.sparql11_builtincall0={init:function(){this.appendDummyInput().appendField(new n.FieldDropdown([["BNODE","BNODE"],["RAND","RAND"],["NOW","NOW"],["UUID","UUID"],["STRUUID","STRUUID"]]),"operator").appendField("()"),this.setInputsInline(!0),this.setOutput(!0,["BuiltInCall","PrimaryExpression","UnaryExpression","MultiplicativeExpression","AdditiveExpression","RelationalExpression","ConditionalAndExpression","ConditionalOrExpression","Expression","GroupCondition","Constraint"]),this.setColour(261)}},n.Blocks.sparql11_builtincall1={init:function(){this.appendValueInput("arg1").setCheck("Expression").appendField(new n.FieldDropdown([["STR","STR"],["LANG","LANG"],["DATATYPE","DATATYPE"],["IRI","IRI"],["URI","URI"],["BNODE","BNODE"],["ABS","ABS"],["CEIL","CEIL"],["FLOOR","FLOOR"],["ROUND","ROUND"],["STRLEN","STRLEN"],["UCASE","UCASE"],["LCASE","LCASE"],["ENCODE_FOR_URI","ENCODE_FOR_URI"],["YEAR","YEAR"],["MONTH","MONTH"],["DAY","DAY"],["HOURS","HOURS"],["MINUTES","MINUTES"],["SECONDS","SECONDS"],["TIMEZONE","TIMEZONE"],["TZ","TZ"],["MD5","MD5"],["SHA1","SHA1"],["SHA256","SHA256"],["SHA384","SHA384"],["SHA512","SHA512"],["ISIRI","ISIRI"],["ISURI","ISURI"],["ISBLANK","ISBLANK"],["ISLITERAL","ISLITERAL"],["ISNUMERIC","ISNUMERIC"],["SUBJECT","SUBJECT"],["PREDICATE","PREDICATE"],["OBJECT","OBJECT"],["ISTRIPLE","ISTRIPLE"]]),"operator").appendField("("),this.appendDummyInput().appendField(")"),this.setInputsInline(!0),this.setOutput(!0,["BuiltInCall","PrimaryExpression","UnaryExpression","MultiplicativeExpression","AdditiveExpression","RelationalExpression","ConditionalAndExpression","ConditionalOrExpression","Expression","GroupCondition","Constraint"]),this.setColour(261)}},n.Blocks.sparql11_builtincall2={init:function(){this.appendValueInput("arg1").setCheck("Expression").appendField(new n.FieldDropdown([["LANGMATCHES","LANGMATCHES"],["SUBSTR","SUBSTR"],["CONTAINS","CONTAINS"],["STRSTARTS","STRSTARTS"],["STRENDS","STRENDS"],["STRBEFORE","STRBEFORE"],["STRAFTER","STRAFTER"],["STRLANG","STRLANG"],["STRDT","STRDT"],["SAMETERM","SAMETERM"],["REGEX","REGEX"]]),"operator").appendField("("),this.appendValueInput("arg2").setCheck("Expression").appendField(","),this.appendDummyInput().appendField(")"),this.setInputsInline(!0),this.setOutput(!0,["BuiltInCall","PrimaryExpression","UnaryExpression","MultiplicativeExpression","AdditiveExpression","RelationalExpression","ConditionalAndExpression","ConditionalOrExpression","Expression","GroupCondition","Constraint"]),this.setColour(261)}},n.Blocks.sparql11_builtincall3={init:function(){this.appendValueInput("arg1").setCheck("Expression").appendField(new n.FieldDropdown([["REGEX","REGEX"],["SUBSTR","SUBSTR"],["REPLACE","REPLACE"],["IF","IF"],["TRIPLE","TRIPLE"]]),"operator").appendField("("),this.appendValueInput("arg2").setCheck("Expression").appendField(","),this.appendValueInput("arg3").setCheck("Expression").appendField(","),this.appendDummyInput().appendField(")"),this.setInputsInline(!0),this.setOutput(!0,["BuiltInCall","PrimaryExpression","UnaryExpression","MultiplicativeExpression","AdditiveExpression","RelationalExpression","ConditionalAndExpression","ConditionalOrExpression","Expression","GroupCondition","Constraint"]),this.setColour(261)}},n.Blocks.sparql11_builtincall4={init:function(){this.appendValueInput("arg1").setCheck("Expression").appendField(new n.FieldDropdown([["REPLACE","REPLACE"]]),"operator").appendField("("),this.appendValueInput("arg2").setCheck("Expression").appendField(","),this.appendValueInput("arg3").setCheck("Expression").appendField(","),this.appendValueInput("arg4").setCheck("Expression").appendField(","),this.appendDummyInput().appendField(")"),this.setInputsInline(!0),this.setOutput(!0,["BuiltInCall","PrimaryExpression","UnaryExpression","MultiplicativeExpression","AdditiveExpression","RelationalExpression","ConditionalAndExpression","ConditionalOrExpression","Expression","GroupCondition","Constraint"]),this.setColour(261)}},n.Blocks.sparql11_builtincalln={init:function(){this.appendStatementInput("args").setCheck("ExpressionListItem").appendField(new n.FieldDropdown([["CONCAT","CONCAT"],["COALESCE","COALESCE"]]),"operator").appendField("("),this.appendDummyInput().appendField(")"),this.setInputsInline(!0),this.setOutput(!0,["BuiltInCall","PrimaryExpression","UnaryExpression","MultiplicativeExpression","AdditiveExpression","RelationalExpression","ConditionalAndExpression","ConditionalOrExpression","Expression","GroupCondition","Constraint"]),this.setColour(261)}},n.Blocks.sparql11_iriorfunction={init:function(){this.appendValueInput("iri").setCheck("iri"),this.appendDummyInput().appendField("(").appendField(new n.FieldDropdown([["",""],["DISTINCT","DISTINCT"]]),"distinct"),this.appendStatementInput("args").setCheck("ExpressionListItem"),this.appendDummyInput().appendField(")"),this.setInputsInline(!0),this.setOutput(!0,["BuiltInCall","PrimaryExpression","UnaryExpression","MultiplicativeExpression","AdditiveExpression","RelationalExpression","ConditionalAndExpression","ConditionalOrExpression","Expression","Constraint","GroupCondition"]),this.setColour(261)}},n.Blocks.sparql11_exists={init:function(){this.appendValueInput("value").setCheck("GroupGraphPattern").appendField(new n.FieldDropdown([["EXISTS","EXISTS"],["NOT EXISTS","NOT EXISTS"]]),"operator"),this.setOutput(!0,["BuiltInCall","PrimaryExpression","UnaryExpression","MultiplicativeExpression","AdditiveExpression","RelationalExpression","ConditionalAndExpression","ConditionalOrExpression","Expression","GroupCondition","Constraint"]),this.setColour(261)}},n.Blocks.sparql11_bound={init:function(){this.appendValueInput("value").setCheck("Var").appendField("BOUND ("),this.appendDummyInput().appendField(")"),this.setInputsInline(!0),this.setOutput(!0,["BuiltInCall","PrimaryExpression","UnaryExpression","MultiplicativeExpression","AdditiveExpression","RelationalExpression","ConditionalAndExpression","ConditionalOrExpression","Expression","GroupCondition","Constraint"]),this.setColour(261)}},n.Blocks.sparql11_unaryexpression={init:function(){this.appendValueInput("left").setCheck("PrimaryExpression").appendField(new n.FieldDropdown([["!","!"],["+","+"],["-","UMINUS"]]),"operator"),this.setInputsInline(!0),this.setOutput(!0,["UnaryExpression","MultiplicativeExpression","AdditiveExpression","RelationalExpression","ConditionalAndExpression","ConditionalOrExpression","Expression"]),this.setColour(261)}},n.Blocks.sparql11_aggregate={init:function(){this.appendValueInput("arg1").setCheck("Expression").appendField(new n.FieldDropdown([["SUM","SUM"],["MIN","MIN"],["MAX","MAX"],["AVG","AVG"],["SAMPLE","SAMPLE"]]),"operator").appendField("(").appendField(new n.FieldDropdown([["",""],["DISTINCT","DISTINCT"]]),"distinct"),this.appendDummyInput().appendField(")"),this.setInputsInline(!0),this.setOutput(!0,["BuiltInCall","PrimaryExpression","UnaryExpression","MultiplicativeExpression","AdditiveExpression","RelationalExpression","ConditionalAndExpression","ConditionalOrExpression","Expression","GroupCondition","Constraint"]),this.setColour(261)}},n.Blocks.sparql11_count={init:function(){this.appendValueInput("arg1").setCheck("Expression").appendField("COUNT(").appendField(new n.FieldDropdown([["",""],["DISTINCT","DISTINCT"]]),"distinct").appendField(new n.FieldDropdown([["",""],["*","*"]]),"star"),this.appendDummyInput().appendField(")"),this.setInputsInline(!0),this.setOutput(!0,["BuiltInCall","PrimaryExpression","UnaryExpression","MultiplicativeExpression","AdditiveExpression","RelationalExpression","ConditionalAndExpression","ConditionalOrExpression","Expression","GroupCondition","Constraint"]),this.setColour(261)}},n.Blocks.sparql11_group_concat={init:function(){this.appendValueInput("arg1").setCheck("Expression").appendField("GROUP_CONCAT(").appendField(new n.FieldDropdown([["",""],["DISTINCT","DISTINCT"]]),"distinct"),this.appendValueInput("separator").appendField("; SEPARATOR =").setCheck("string"),this.appendDummyInput().appendField(")"),this.setInputsInline(!0),this.setOutput(!0,["BuiltInCall","PrimaryExpression","UnaryExpression","MultiplicativeExpression","AdditiveExpression","RelationalExpression","ConditionalAndExpression","ConditionalOrExpression","Expression","GroupCondition","Constraint"]),this.setColour(261)}},n.Blocks.sparql11_expressionlistitem={init:function(){this.appendValueInput("value").setCheck("Expression"),this.setPreviousStatement(!0,"ExpressionListItem"),this.setNextStatement(!0,"ExpressionListItem"),this.setColour(261)}},n.Blocks.sparql11_blanknodepropertylist={init:function(){this.appendDummyInput().appendField("["),this.appendStatementInput("predicates").setCheck("PropertyListNotEmpty"),this.appendDummyInput().appendField("]"),this.setOutput(!0,["BlankNodePropertyList","TriplesNode","TriplesSameSubject","GraphNode","Object","TriplesBlock"]),this.setColour(0)}},n.Blocks.sparql11_prefixedname={init:function(){this.appendDummyInput().appendField(":"),this.setInputsInline(!0),this.setOutput(!0,["EmbSubjectOrObject","DataValueTerm","VarOrTermOrEmbTP","iri","VarOrIri","GraphNode","VarOrTerm","GraphTerm","Verb","DataBlockValue","PathPrimary","PathElt","PathEltOrInverse","PathSequence","Path","VerbPath","PathOneInPropertySet","PathNegatedPropertySet","Expression","ConditionalOrExpression","ConditionalAndExpression","RelationalExpression","AdditiveExpression","MultiplicativeExpression","UnaryExpression","PrimaryExpression","iriOrFunction","GraphOrDefault"]),this.setColour(326)}},n.Blocks.sparql11_prefixednameprefix={init:function(){this.appendDummyInput().appendField(new n.FieldTextInput(""),"prefix").appendField(":"),this.setInputsInline(!0),this.setOutput(!0,["EmbSubjectOrObject","DataValueTerm","VarOrTermOrEmbTP","iri","VarOrIri","GraphNode","VarOrTerm","GraphTerm","Verb","DataBlockValue","PathPrimary","PathElt","PathEltOrInverse","PathSequence","Path","VerbPath","PathOneInPropertySet","PathNegatedPropertySet","Expression","ConditionalOrExpression","ConditionalAndExpression","RelationalExpression","AdditiveExpression","MultiplicativeExpression","UnaryExpression","PrimaryExpression","iriOrFunction","GraphOrDefault"]),this.setColour(326)}},n.Blocks.sparql11_prefixednamelocalname={init:function(){this.appendDummyInput().appendField(":").appendField(new n.FieldTextInput(""),"localName"),this.setInputsInline(!0),this.setOutput(!0,["EmbSubjectOrObject","DataValueTerm","VarOrTermOrEmbTP","iri","VarOrIri","GraphNode","VarOrTerm","GraphTerm","Verb","DataBlockValue","PathPrimary","PathElt","PathEltOrInverse","PathSequence","Path","VerbPath","PathOneInPropertySet","PathNegatedPropertySet","Expression","ConditionalOrExpression","ConditionalAndExpression","RelationalExpression","AdditiveExpression","MultiplicativeExpression","UnaryExpression","PrimaryExpression","iriOrFunction","GraphOrDefault"]),this.setColour(326)}},n.Blocks.sparql11_prefixednameprefixlocalname={init:function(){this.appendDummyInput().appendField(new n.FieldTextInput(""),"prefix").appendField(":").appendField(new n.FieldTextInput(""),"localName"),this.setInputsInline(!0),this.setOutput(!0,["EmbSubjectOrObject","DataValueTerm","VarOrTermOrEmbTP","iri","VarOrIri","GraphNode","VarOrTerm","GraphTerm","Verb","DataBlockValue","PathPrimary","PathElt","PathEltOrInverse","PathSequence","Path","VerbPath","PathOneInPropertySet","PathNegatedPropertySet","Expression","ConditionalOrExpression","ConditionalAndExpression","RelationalExpression","AdditiveExpression","MultiplicativeExpression","UnaryExpression","PrimaryExpression","iriOrFunction","GraphOrDefault"]),this.setColour(326)}},n.Blocks.sparql11_embtp={init:function(){this.appendValueInput("subject").appendField("<<").setCheck("EmbSubjectOrObject"),this.appendValueInput("predicate").setCheck("Verb"),this.appendValueInput("object").setCheck("EmbSubjectOrObject"),this.appendDummyInput().appendField(">>"),this.setOutput(!0,["GraphNode","GraphNodePath","VarOrTermOrEmbTP","EmbSubjectOrObject","EmbTP","DataBlockValue"]),this.setColour(0)}},n.Blocks.sparql11_iriref={init:function(){this.appendDummyInput().appendField("<").appendField(new n.FieldTextInput(""),"value").appendField(">"),this.setInputsInline(!0),this.setOutput(!0,["EmbSubjectOrObject","DataValueTerm","VarOrTermOrEmbTP","IRIREF","iri","VarOrIri","GraphNode","VarOrTerm","GraphTerm","Verb","DataBlockValue","PathPrimary","PathElt","PathEltOrInverse","PathSequence","Path","VerbPath","PathOneInPropertySet","PathNegatedPropertySet","Expression","ConditionalOrExpression","ConditionalAndExpression","RelationalExpression","AdditiveExpression","MultiplicativeExpression","UnaryExpression","PrimaryExpression","iriOrFunction","GraphOrDefault"]),this.setColour(326)}},n.Blocks.sparql11_irirefdefault={init:function(){this.appendDummyInput().appendField("<>"),this.setInputsInline(!0),this.setOutput(!0,["EmbSubjectOrObject","DataValueTerm","VarOrTermOrEmbTP","IRIREF","iri","VarOrIri","GraphNode","VarOrTerm","GraphTerm","Verb","DataBlockValue","PathPrimary","PathElt","PathEltOrInverse","PathSequence","Path","VerbPath","PathOneInPropertySet","PathNegatedPropertySet","Expression","ConditionalOrExpression","ConditionalAndExpression","RelationalExpression","AdditiveExpression","MultiplicativeExpression","UnaryExpression","PrimaryExpression","iriOrFunction","GraphOrDefault"]),this.setColour(326)}},n.Blocks.sparql11_typedliteral={init:function(){this.appendValueInput("value").setCheck("string"),this.appendValueInput("datatype").appendField("^^").setCheck("iri"),this.setInputsInline(!0),this.setOutput(!0,["EmbSubjectOrObject","DataValueTerm","VarOrTermOrEmbTP","RDFLiteral","GraphNode","VarOrTerm","GraphTerm","DataBlockValue","Expression","ConditionalOrExpression","ConditionalAndExpression","RelationalExpression","AdditiveExpression","MultiplicativeExpression","UnaryExpression","PrimaryExpression"]),this.setColour(163)}},n.Blocks.sparql11_langstring={init:function(){const e=new n.FieldTextInput("");e.setValidator((e=>/^[a-zA-Z]+(-[a-zA-Z0-9]+)*$/.test(e)?e:null)),this.appendValueInput("value").setCheck("string"),this.appendDummyInput().appendField("@").appendField(e,"language"),this.setInputsInline(!0),this.setOutput(!0,["EmbSubjectOrObject","DataValueTerm","VarOrTermOrEmbTP","RDFLiteral","GraphNode","VarOrTerm","GraphTerm","DataBlockValue","Expression","ConditionalOrExpression","ConditionalAndExpression","RelationalExpression","AdditiveExpression","MultiplicativeExpression","UnaryExpression","PrimaryExpression"]),this.setColour(163)}},n.Blocks.sparql11_collection={init:function(){this.appendDummyInput().appendField("("),this.appendStatementInput("items").setCheck("GraphNodeItem"),this.appendDummyInput().appendField(")"),this.setOutput(!0,["Collection","TriplesNode","TriplesSameSubject","GraphNode","Object","TriplesBlock"]),this.setColour(0)}},n.Blocks.sparql11_graphnodeitem={init:function(){this.appendValueInput("value").setCheck("GraphNode"),this.setPreviousStatement(!0,"GraphNodeItem"),this.setNextStatement(!0,"GraphNodeItem"),this.setColour(294)}},n.Blocks.sparql11_anon={init:function(){this.appendDummyInput().appendField("[]"),this.setOutput(!0,["EmbSubjectOrObject","VarOrTermOrEmbTP","BlankNode","GraphTerm","VarOrTerm","GraphNode","Object"]),this.setColour(98)}},n.Blocks.sparql11_blanknodelabel={init:function(){this.appendDummyInput().appendField("_:").appendField(new n.FieldTextInput(""),"value"),this.setInputsInline(!0),this.setOutput(!0,["EmbSubjectOrObject","VarOrTermOrEmbTP","BlankNode","GraphTerm","VarOrTerm","GraphNode"]),this.setColour(98)}},n.Blocks.sparql11_nil={init:function(){this.appendDummyInput().appendField("()"),this.setOutput(!0,["VarOrTermOrEmbTP","NIL","GraphTerm","VarOrTerm","GraphNode","Object"]),this.setColour(98)}},n.Blocks.sparql11_var1={init:function(){this.appendDummyInput().appendField("?").appendField(new n.FieldTextInput("s"),"value"),this.setInputsInline(!1),this.setOutput(!0,["EmbSubjectOrObject","VarOrTermOrEmbTP","Var","VarOrIri","Verb","VarOrTerm","GraphNode","Object","GroupCondition","Expression","ConditionalOrExpression","ConditionalAndExpression","RelationalExpression","AdditiveExpression","MultiplicativeExpression","UnaryExpression","PrimaryExpression"]),this.setColour(33)}},n.Blocks.sparql11_var2={init:function(){this.appendDummyInput().appendField("$").appendField(new n.FieldTextInput("s"),"value"),this.setInputsInline(!1),this.setOutput(!0,["EmbSubjectOrObject","VarOrTermOrEmbTP","Var","VarOrIri","Verb","VarOrTerm","GraphNode","Object","GroupCondition","Expression","ConditionalOrExpression","ConditionalAndExpression","RelationalExpression","AdditiveExpression","MultiplicativeExpression","UnaryExpression","PrimaryExpression"]),this.setColour(33)}},n.Blocks.sparql11_numericliteral={init:function(){const e=new n.FieldTextInput("");e.setValidator((e=>isNaN(parseFloat(e))||!isFinite(Number(e))?null:e)),this.appendDummyInput().appendField(e,"value"),this.setInputsInline(!0),this.setOutput(!0,["EmbSubjectOrObject","DataValueTerm","VarOrTermOrEmbTP","NumericLiteral","RDFLiteral","GraphNode","VarOrTerm","GraphTerm","DataBlockValue","Expression","ConditionalOrExpression","ConditionalAndExpression","RelationalExpression","AdditiveExpression","MultiplicativeExpression","UnaryExpression","PrimaryExpression"]),this.setColour(163)}},n.Blocks.sparql11_booleanliteral={init:function(){this.appendDummyInput().appendField(new n.FieldCheckbox("TRUE"),"value"),this.setInputsInline(!0),this.setOutput(!0,["EmbSubjectOrObject","DataValueTerm","VarOrTermOrEmbTP","RDFLiteral","GraphNode","VarOrTerm","GraphTerm","DataBlockValue","Expression","ConditionalOrExpression","ConditionalAndExpression","RelationalExpression","AdditiveExpression","MultiplicativeExpression","UnaryExpression","PrimaryExpression"]),this.setColour(163)}},n.Blocks.sparql11_string={init:function(){this.appendDummyInput().appendField(new o.FieldMultilineInput(""),"value"),this.setInputsInline(!0),this.setOutput(!0,["EmbSubjectOrObject","DataValueTerm","VarOrTermOrEmbTP","string","RDFLiteral","GraphNode","VarOrTerm","GraphTerm","DataBlockValue","Expression","ConditionalOrExpression","ConditionalAndExpression","RelationalExpression","AdditiveExpression","MultiplicativeExpression","UnaryExpression","PrimaryExpression"]),this.setColour(163)}},n.Blocks.sparql11_varitem={init:function(){this.appendValueInput("value").setCheck("Var"),this.setInputsInline(!1),this.setPreviousStatement(!0,"VarItem"),this.setNextStatement(!0,"VarItem"),this.setColour(65)}}},653:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),i(442),i(252),i(341);const n=i(180),o=i(128);n.Block.prototype.toString=function(){const e=(new o.default).blockToCode(this,!0);return e instanceof Array?e[0]:e},n.COLLAPSE_CHARS=3e3,n.Field.prototype.maxDisplayLength=3e3},341:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=i(861);(0,n.property)("sparql11_prologueitem","sparql11_base","value","Base"),(0,n.property)("sparql11_prologueitem","sparql11_prefixdecl","value","Prefix"),(0,n.property)("sparql11_prologueitem","sparql11_prefixdecldefault","value","Default prefix"),(0,n.iriRefs)("sparql11_base","value"),(0,n.iriRefs)("sparql11_prefixdecl","value"),(0,n.iriRefs)("sparql11_prefixdecldefault","value"),(0,n.workspace)("Query","sparql11_query"),(0,n.collection)("sparql11_query","sparql11_prologueitem","prologue","Prologue"),(0,n.separator)("sparql11_query"),(0,n.property)("sparql11_query","sparql11_selectquery","value","Select"),(0,n.property)("sparql11_query","sparql11_describequery","value","Describe"),(0,n.property)("sparql11_query","sparql11_askquery","value","Ask"),(0,n.property)("sparql11_query","sparql11_simpleconstructquery","value","Simple construct"),(0,n.property)("sparql11_query","sparql11_constructquery","value","Construct"),(0,n.separator)("sparql11_query"),(0,n.property)("sparql11_query","sparql11_inlinedata","values","Values"),(0,n.property)("sparql11_selectquery","sparql11_selectclause","select","Select clause"),(0,n.property)("sparql11_selectquery","sparql11_querycommon","where","Where & modifiers"),(0,n.collection)("sparql11_simpleconstructquery","sparql11_datasetclause","datasets","From"),(0,n.collection)("sparql11_simpleconstructquery","sparql11_triplessamesubjectitem","where","Triples same subject"),(0,n.property)("sparql11_simpleconstructquery","sparql11_solutionmodifier","modifiers","Modifiers"),(0,n.collection)("sparql11_constructquery","sparql11_triplessamesubjectitem","template","Template item"),(0,n.property)("sparql11_constructquery","sparql11_querycommon","where","Where & modifiers"),(0,n.collection)("sparql11_describequery","sparql11_varoririitem","subject","Subject"),(0,n.property)("sparql11_describequery","sparql11_querycommon","where","Where & modifiers"),(0,n.property)("sparql11_askquery","sparql11_querycommon","value","Where & modifiers"),(0,n.varsOrIris)("sparql11_varoririitem","value"),(0,n.sameSubjectTriples)("sparql11_triplessamesubjectitem","value"),(0,n.workspace)("Update","sparql11_update"),(0,n.collection)("sparql11_update","sparql11_prologueitem","prologue","Prologue"),(0,n.separator)("sparql11_update"),(0,n.collection)("sparql11_update","sparql11_updateitem","items","Update"),(0,n.property)("sparql11_updateitem","sparql11_insertdeletewhere","value","Insert/delete (data) where"),(0,n.property)("sparql11_updateitem","sparql11_modify","value","Modify"),(0,n.property)("sparql11_updateitem","sparql11_load","value","Load"),(0,n.property)("sparql11_updateitem","sparql11_create","value","Create"),(0,n.property)("sparql11_updateitem","sparql11_addmovecopy","value","Add/move/copy"),(0,n.property)("sparql11_updateitem","sparql11_cleardrop","value","Clear/drop"),(0,n.property)("sparql11_insertdeletewhere","sparql11_quadpattern","pattern","{}"),(0,n.collection)("sparql11_quadpattern","sparql11_quadpatternitem","items","Item"),(0,n.sameSubjectTriples)("sparql11_quadpatternitem","value"),(0,n.property)("sparql11_quadpatternitem","sparql11_quadsnottriples","value","Graph"),(0,n.varsOrIris)("sparql11_quadsnottriples","name"),(0,n.separator)("sparql11_quadsnottriples"),(0,n.collection)("sparql11_quadsnottriples","sparql11_triplessamesubjectitem","triples","Item"),(0,n.iris)("sparql11_modify","iri","With"),(0,n.separator)("sparql11_modify"),(0,n.property)("sparql11_modify","sparql11_quadpattern","delete","{}","Delete"),(0,n.separator)("sparql11_modify"),(0,n.property)("sparql11_modify","sparql11_quadpattern","insert","{}","Insert"),(0,n.separator)("sparql11_modify"),(0,n.collection)("sparql11_modify","sparql11_usingclause","using","Using"),(0,n.separator)("sparql11_modify"),(0,n.groupGraphPattern)("sparql11_modify","where","Where"),(0,n.property)("sparql11_usingclause","sparql11_namedgraphclause","value","Named"),(0,n.separator)("sparql11_usingclause"),(0,n.iris)("sparql11_usingclause","value"),(0,n.iris)("sparql11_load","source","Source"),(0,n.separator)("sparql11_load"),(0,n.property)("sparql11_load","sparql11_graphref","destination","Graph"),(0,n.property)("sparql11_create","sparql11_graphref","graph","Graph"),(0,n.updateGraphOrDefault)("sparql11_addmovecopy","source","Source"),(0,n.separator)("sparql11_addmovecopy"),(0,n.updateGraphOrDefault)("sparql11_addmovecopy","destination","Destination"),(0,n.updateGraphRefAll)("sparql11_cleardrop","graph"),(0,n.iris)("sparql11_graphref","value"),(0,n.graphNodes)("sparql11_triplessamesubject","subject","Subject"),(0,n.separator)("sparql11_triplessamesubject"),(0,n.collection)("sparql11_triplessamesubject","sparql11_propertylistnotempty","predicates","Predicate"),(0,n.verbs)("sparql11_propertylistnotempty","predicate","Predicate"),(0,n.separator)("sparql11_propertylistnotempty"),(0,n.collection)("sparql11_propertylistnotempty","sparql11_objectlistitem","objects","Node","Object"),(0,n.collection)("sparql11_propertylistnotempty","sparql11_objectlistitemannotationpattern","objects","Annotation","Object"),(0,n.graphNodes)("sparql11_objectlistitem","value"),(0,n.graphNodes)("sparql11_objectlistitemannotationpattern","value"),(0,n.separator)("sparql11_objectlistitemannotationpattern"),(0,n.collection)("sparql11_objectlistitemannotationpattern","sparql11_propertylistnotempty","annotations","Predicate"),(0,n.groupGraphPatternSubs)("sparql11_groupgraphpattern","value"),(0,n.property)("sparql11_groupgraphpattern","sparql11_groupgraphpatternsub","value","Multiple patterns"),(0,n.property)("sparql11_groupgraphpattern","sparql11_subselect","value","Select"),(0,n.property)("sparql11_subselect","sparql11_selectclause","select","Select clause"),(0,n.groupGraphPattern)("sparql11_subselect","pattern"),(0,n.property)("sparql11_subselect","sparql11_solutionmodifier","modifiers","Modifiers"),(0,n.property)("sparql11_subselect","sparql11_inlinedata","values","Values"),(0,n.collection)("sparql11_groupgraphpatternsub","sparql11_groupgraphpatternsubitem","items","Item"),(0,n.groupGraphPatternSubs)("sparql11_groupgraphpatternsubitem","value"),(0,n.varsOrIris)("sparql11_graphgraphpattern","iri"),(0,n.separator)("sparql11_graphgraphpattern"),(0,n.groupGraphPattern)("sparql11_graphgraphpattern","patterns"),(0,n.varsOrIris)("sparql11_servicegraphpattern","iri"),(0,n.separator)("sparql11_servicegraphpattern"),(0,n.groupGraphPattern)("sparql11_servicegraphpattern","patterns"),(0,n.property)("sparql11_bind","sparql11_expressionasvar","value","Projection"),(0,n.groupGraphPattern)("sparql11_minusgraphpattern","value"),(0,n.collection)("sparql11_grouporuniongraphpattern","sparql11_groupgraphpatternitem","items","Item"),(0,n.groupGraphPattern)("sparql11_groupgraphpatternitem","value"),(0,n.constraints)("sparql11_filter","value"),(0,n.groupGraphPattern)("sparql11_optionalgraphpattern","value"),(0,n.property)("sparql11_inlinedata","sparql11_inlinedataonevar","value","One var"),(0,n.property)("sparql11_inlinedata","sparql11_inlinedatafull","value","Full"),(0,n.vars)("sparql11_inlinedataonevar","variable"),(0,n.collection)("sparql11_inlinedataonevar","sparql11_datablockvalueitem","values","Value"),(0,n.collection)("sparql11_inlinedatafull","sparql11_varitem","variables","Var"),(0,n.collection)("sparql11_inlinedatafull","sparql11_datablockvaluesitem","values","Row"),(0,n.vars)("sparql11_varitem","value"),(0,n.property)("sparql11_datablockvalueitem","sparql11_undef","value","Undefined"),(0,n.terms)("sparql11_datablockvalueitem","value"),(0,n.property)("sparql11_datablockvalueitem","sparql11_embtp","value","<< >>"),(0,n.collection)("sparql11_datablockvaluesitem","sparql11_datablockvalueitem","items","Cell"),(0,n.property)("sparql11_negatedpath","sparql11_a","value","a"),(0,n.property)("sparql11_negatedpath","sparql11_inversepathoneinpropertyset","value","^"),(0,n.property)("sparql11_negatedpath","sparql11_pathoneinpropertysetalternative","value","|"),(0,n.iris)("sparql11_negatedpath","value"),(0,n.paths)("sparql11_bracketedpath","value"),(0,n.primaryPaths)("sparql11_pathwithmodifier","value"),(0,n.eltPaths)("sparql11_inversepath","value"),(0,n.collection)("sparql11_pathalternative","sparql11_pathalternativeitem","items","Item"),(0,n.collection)("sparql11_pathsequence","sparql11_pathsequencitem","items","Item"),(0,n.property)("sparql11_inversepathoneinpropertyset","sparql11_a","value","a"),(0,n.iris)("sparql11_inversepathoneinpropertyset","value"),(0,n.collection)("sparql11_pathoneinpropertysetalternative","sparql11_pathoneinpropertysetalternativeitem","items","Item"),(0,n.eltOrInversePaths)("sparql11_pathsequencitem","value"),(0,n.sequencePaths)("sparql11_pathalternativeitem","value"),(0,n.property)("sparql11_pathoneinpropertysetalternativeitem","sparql11_a","value","a"),(0,n.property)("sparql11_pathoneinpropertysetalternativeitem","sparql11_inversepathoneinpropertyset","value","^"),(0,n.iris)("sparql11_pathoneinpropertysetalternativeitem","value"),(0,n.collection)("sparql11_querycommon","sparql11_datasetclause","datasets","From"),(0,n.groupGraphPattern)("sparql11_querycommon","pattern"),(0,n.property)("sparql11_querycommon","sparql11_solutionmodifier","modifiers","Modifiers"),(0,n.collection)("sparql11_selectclause","sparql11_varorexpressionasvaritem","vars","Var or projection"),(0,n.vars)("sparql11_expressionasvar","name","Name"),(0,n.separator)("sparql11_expressionasvar"),(0,n.expressions)("sparql11_expressionasvar","value"),(0,n.property)("sparql11_expressionasvar","sparql11_embtp","value","<< >>"),(0,n.property)("sparql11_datasetclause","sparql11_namedgraphclause","value","Named"),(0,n.separator)("sparql11_datasetclause"),(0,n.iris)("sparql11_datasetclause","value"),(0,n.iris)("sparql11_namedgraphclause","value"),(0,n.collection)("sparql11_solutionmodifier","sparql11_groupconditionitem","group","Group item"),(0,n.collection)("sparql11_solutionmodifier","sparql11_havingconditionitem","having","Having item"),(0,n.collection)("sparql11_solutionmodifier","sparql11_orderconditionitem","order","Order item"),(0,n.property)("sparql11_solutionmodifier","sparql11_numericliteral","limit","Limit"),(0,n.property)("sparql11_solutionmodifier","sparql11_numericliteral","offset","Offset"),(0,n.property)("sparql11_ordercondition","sparql11_brackettedexpression","value","()"),(0,n.vars)("sparql11_groupconditionitem","value"),(0,n.separator)("sparql11_groupconditionitem"),(0,n.property)("sparql11_groupconditionitem","sparql11_expressionasvar","value","Projection"),(0,n.separator)("sparql11_groupconditionitem"),(0,n.functionExpressions)("sparql11_groupconditionitem","value"),(0,n.constraints)("sparql11_havingconditionitem","value"),(0,n.property)("sparql11_orderconditionitem","sparql11_ordercondition","value","Descending"),(0,n.separator)("sparql11_orderconditionitem"),(0,n.vars)("sparql11_orderconditionitem","value"),(0,n.separator)("sparql11_orderconditionitem"),(0,n.constraints)("sparql11_orderconditionitem","value"),(0,n.property)("sparql11_varorexpressionasvaritem","sparql11_var1","value","Var"),(0,n.property)("sparql11_varorexpressionasvaritem","sparql11_expressionasvar","value","Projection"),(0,n.expressions)("sparql11_brackettedexpression","value"),(0,n.unaryExpressions)("sparql11_multiplicativeexpression","left","Left"),(0,n.separator)("sparql11_multiplicativeexpression"),(0,n.unaryExpressions)("sparql11_multiplicativeexpression","right","Right"),(0,n.multiplicativeExpressions)("sparql11_additiveexpression","left","Left"),(0,n.separator)("sparql11_additiveexpression"),(0,n.multiplicativeExpressions)("sparql11_additiveexpression","right","Right"),(0,n.additiveExpressions)("sparql11_relationalexpression","left","Left"),(0,n.separator)("sparql11_relationalexpression"),(0,n.additiveExpressions)("sparql11_relationalexpression","right","Right"),(0,n.collection)("sparql11_relationalexpressionin","sparql11_expressionlistitem","right","Item"),(0,n.separator)("sparql11_relationalexpressionin"),(0,n.additiveExpressions)("sparql11_relationalexpressionin","left"),(0,n.relationalExpressions)("sparql11_conditionalandexpression","left","Left"),(0,n.separator)("sparql11_conditionalandexpression"),(0,n.relationalExpressions)("sparql11_conditionalandexpression","right","Right"),(0,n.andExpressions)("sparql11_conditionalorexpression","left","Left"),(0,n.separator)("sparql11_conditionalorexpression"),(0,n.andExpressions)("sparql11_conditionalorexpression","right","Right"),(0,n.expressions)("sparql11_builtincall1","arg1","1"),(0,n.expressions)("sparql11_builtincall2","arg1","1"),(0,n.separator)("sparql11_builtincall2"),(0,n.expressions)("sparql11_builtincall2","arg2","2"),(0,n.expressions)("sparql11_builtincall3","arg1","1"),(0,n.separator)("sparql11_builtincall3"),(0,n.expressions)("sparql11_builtincall3","arg2","2"),(0,n.separator)("sparql11_builtincall3"),(0,n.expressions)("sparql11_builtincall3","arg3","3"),(0,n.expressions)("sparql11_builtincall4","arg1","1"),(0,n.separator)("sparql11_builtincall4"),(0,n.expressions)("sparql11_builtincall4","arg2","2"),(0,n.separator)("sparql11_builtincall4"),(0,n.expressions)("sparql11_builtincall4","arg3","3"),(0,n.separator)("sparql11_builtincall4"),(0,n.expressions)("sparql11_builtincall4","arg4","4"),(0,n.collection)("sparql11_builtincalln","sparql11_expressionlistitem","args","Item"),(0,n.collection)("sparql11_iriorfunction","sparql11_expressionlistitem","args","Item"),(0,n.separator)("sparql11_iriorfunction"),(0,n.iris)("sparql11_iriorfunction","iri"),(0,n.groupGraphPattern)("sparql11_exists","value"),(0,n.vars)("sparql11_bound","value"),(0,n.primaryExpressions)("sparql11_unaryexpression","left"),(0,n.expressions)("sparql11_aggregate","arg1"),(0,n.expressions)("sparql11_count","arg1"),(0,n.property)("sparql11_group_concat","sparql11_string","separator","''","Separator"),(0,n.separator)("sparql11_group_concat"),(0,n.expressions)("sparql11_group_concat","arg1"),(0,n.expressions)("sparql11_expressionlistitem","value"),(0,n.collection)("sparql11_blanknodepropertylist","sparql11_propertylistnotempty","predicates","Predicate"),(0,n.graphNodes)("sparql11_embtp","subject","Subject"),(0,n.separator)("sparql11_embtp"),(0,n.verbs)("sparql11_embtp","predicate","Predicate"),(0,n.separator)("sparql11_embtp"),(0,n.graphNodes)("sparql11_embtp","object","Object"),(0,n.property)("sparql11_typedliteral","sparql11_string","value","''","Value"),(0,n.separator)("sparql11_typedliteral"),(0,n.iris)("sparql11_typedliteral","datatype","Datatype"),(0,n.property)("sparql11_langstring","sparql11_string","value","''"),(0,n.collection)("sparql11_collection","sparql11_graphnodeitem","items","Item"),(0,n.graphNodes)("sparql11_graphnodeitem","value")},252:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=i(180);n.ContextMenuRegistry.registry.unregister("undoWorkspace"),n.ContextMenuRegistry.registry.unregister("redoWorkspace"),n.ContextMenuRegistry.registry.unregister("cleanWorkspace"),n.ContextMenuRegistry.registry.unregister("expandWorkspace"),n.ContextMenuRegistry.registry.unregister("workspaceDelete"),n.ContextMenuRegistry.registry.unregister("blockDuplicate"),n.ContextMenuRegistry.registry.unregister("blockComment"),n.ContextMenuRegistry.registry.unregister("blockInline"),n.ContextMenuRegistry.registry.unregister("blockDisable"),n.ContextMenuRegistry.registry.unregister("blockDelete"),n.ContextMenuRegistry.registry.unregister("blockHelp")},715:function(e,t,i){var n;n=(e,t,i,n,o,s)=>(()=>{"use strict";var r={370(t){t.exports=e},379(e){e.exports=t},127(e){e.exports=i},157(e){e.exports=n},537(e){e.exports=o},557(e){e.exports=s}};const a={};function l(e){const t=a[e];if(void 0!==t)return t.exports;const i=a[e]={exports:{}};return r[e](i,i.exports,l),i.exports}l.d=(e,t)=>{for(var i in t)l.o(t,i)&&!l.o(e,i)&&Object.defineProperty(e,i,{enumerable:!0,get:t[i]})},l.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),l.r=e=>{Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};let h={};l.r(h),l.d(h,{FieldMultilineInput:()=>_,installAllBlocks:()=>O,registerFieldMultilineInput:()=>f,textMultiline:()=>u});var u={};l.r(u),l.d(u,{BLOCK_NAME:()=>m,blockDefinition:()=>k,installBlock:()=>S,toDart:()=>v,toJavascript:()=>C,toLua:()=>I,toPhp:()=>N,toPython:()=>y});var c=l(370),d=l(127),p=l(379),g=l(157),E=l(537),T=l(557);class _ extends c.FieldTextInput{constructor(e,t,i){super(c.Field.SKIP_SETUP),this.textGroup=null,this.maxLines_=1/0,this.isOverflowedY_=!1,this.hintElement=null,this.cachedHintWidth=null,e!==c.Field.SKIP_SETUP&&(i&&this.configure_(i),this.setValue(e),t&&this.setValidator(t))}configure_(e){super.configure_(e),e.maxLines&&this.setMaxLines(e.maxLines)}toXml(e){return e.textContent=this.getValue().replace(/\n/g,"&#10;"),e}fromXml(e){this.setValue(e.textContent.replace(/&#10;/g,"\n"))}saveState(){const e=this.saveLegacyState(_);return null!==e?e:this.getValue()}loadState(e){this.loadLegacyState(c.Field,e)||this.setValue(e)}initView(){this.createBorderRect_(),this.textGroup=c.utils.dom.createSvgElement(c.utils.Svg.G,{class:"blocklyEditableField"},this.fieldGroup_),this.fieldGroup_&&c.utils.dom.addClass(this.fieldGroup_,"blocklyField")}getDisplayText_(){const e=this.getSourceBlock();if(!e)throw new Error("The field has not yet been attached to its input. Call appendField to attach it.");let t=this.getText();if(!t)return c.Field.NBSP;const i=t.split("\n");t="";const n=this.isOverflowedY_?this.maxLines_:i.length;for(let e=0;e<n;e++){let o=i[e];o.length>this.maxDisplayLength?o=o.substring(0,this.maxDisplayLength-4)+"...":this.isOverflowedY_&&e===n-1&&(o=o.substring(0,o.length-3)+"..."),o=o.replace(/\s/g,c.Field.NBSP),t+=o,e!==n-1&&(t+="\n")}return e.RTL&&(t+="‏"),t}doValueUpdate_(e){super.doValueUpdate_(e),null!==this.value_&&(this.isOverflowedY_=this.value_.split("\n").length>this.maxLines_)}render_(){const e=this.getSourceBlock();if(!e)throw new Error("The field has not yet been attached to its input. Call appendField to attach it.");let t;const i=this.textGroup;for(;t=i.firstChild;)i.removeChild(t);const n=this.getConstants();if(!n)throw Error("Constants not found");const o=this.getDisplayText_().split("\n");let s=0;for(let e=0;e<o.length;e++){const t=n.FIELD_TEXT_HEIGHT+n.FIELD_BORDER_RECT_Y_PADDING;c.utils.dom.createSvgElement(c.utils.Svg.TEXT,{class:"blocklyText blocklyMultilineText",x:n.FIELD_BORDER_RECT_X_PADDING,y:s+n.FIELD_BORDER_RECT_Y_PADDING,dy:n.FIELD_TEXT_BASELINE},i).appendChild(document.createTextNode(o[e])),s+=t}if(this.isBeingEdited_){const e=this.htmlInput_;this.isOverflowedY_?c.utils.dom.addClass(e,"blocklyHtmlTextAreaInputOverflowedY"):c.utils.dom.removeClass(e,"blocklyHtmlTextAreaInputOverflowedY")}if(this.updateSize_(),this.isBeingEdited_){e.RTL?setTimeout(this.resizeEditor_.bind(this),0):this.resizeEditor_();const t=this.htmlInput_;this.isTextValid_?(c.utils.dom.removeClass(t,"blocklyInvalidInput"),c.utils.aria.setState(t,c.utils.aria.State.INVALID,!1)):(c.utils.dom.addClass(t,"blocklyInvalidInput"),c.utils.aria.setState(t,c.utils.aria.State.INVALID,!0))}}updateSize_(){var e;const t=this.getConstants();if(!t)throw Error("Constants not found");const i=this.textGroup.childNodes;let n=0,o=0;for(let e=0;e<i.length;e++){const s=i[e],r=c.utils.dom.getTextWidth(s);r>n&&(n=r),o+=t.FIELD_TEXT_HEIGHT+(e>0?t.FIELD_BORDER_RECT_Y_PADDING:0)}if(this.isBeingEdited_){const e=String(this.value_).split("\n"),i=c.utils.dom.createSvgElement(c.utils.Svg.TEXT,{class:"blocklyText blocklyMultilineText"});for(let t=0;t<e.length;t++){e[t].length>this.maxDisplayLength&&(e[t]=e[t].substring(0,this.maxDisplayLength)),i.textContent=e[t];const o=c.utils.dom.getTextWidth(i);o>n&&(n=o)}const s=this.htmlInput_;n+=s.offsetWidth-s.clientWidth,_.showHint&&(o+=t.FIELD_TEXT_HEIGHT+t.FIELD_BORDER_RECT_Y_PADDING)}if(this.borderRect_&&(o+=2*t.FIELD_BORDER_RECT_Y_PADDING,n+=2*t.FIELD_BORDER_RECT_X_PADDING+1),this.isBeingEdited_&&(n=Math.max(n,_.EDITOR_MIN_WIDTH),_.showHint&&(null===(e=this.hintElement)||void 0===e?void 0:e.isConnected))){const e=this.workspace_.getScale();if(!this.cachedHintWidth||this.cachedHintWidth.scale!==e){this.hintElement.style.width="max-content";const t=this.hintElement.offsetWidth;this.hintElement.style.width="",t>0&&(this.cachedHintWidth={scale:e,widthPx:t})}this.cachedHintWidth&&(n=Math.max(n,this.cachedHintWidth.widthPx/e))}this.borderRect_&&(this.borderRect_.setAttribute("width",`${n}`),this.borderRect_.setAttribute("height",`${o}`)),this.size_.width=n,this.size_.height=o,this.positionBorderRect_()}showEditor_(e,t){super.showEditor_(e,t),this.forceRerender()}widgetCreate_(){const e=c.WidgetDiv.getDiv(),t=this.workspace_.getScale(),i=this.getConstants();if(!i)throw Error("Constants not found");const n=document.createElement("textarea");n.className="blocklyHtmlInput blocklyHtmlTextAreaInput",n.setAttribute("spellcheck",String(this.spellcheck_));const o=i.FIELD_TEXT_FONTSIZE*t+"pt";e.style.fontSize=o,n.style.fontSize=o;const s=c.FieldTextInput.BORDERRADIUS*t+"px";n.style.borderRadius=s;const r=i.FIELD_BORDER_RECT_X_PADDING*t,a=i.FIELD_BORDER_RECT_Y_PADDING*t/2,l=i.FIELD_TEXT_HEIGHT+i.FIELD_BORDER_RECT_Y_PADDING,h=Math.ceil(l*t),u=_.showHint?a+h:a;return n.style.padding=`${a}px ${r}px ${u}px ${r}px`,n.style.lineHeight=l*t+"px",e.appendChild(n),n.value=n.defaultValue=this.getEditorText_(this.value_),n.setAttribute("data-untyped-default-value",String(this.value_)),n.setAttribute("data-old-value",""),c.utils.userAgent.GECKO?setTimeout(this.resizeEditor_.bind(this),0):this.resizeEditor_(),this.bindInputEvents_(n),_.showHint&&(this.hintElement=this.createHint(h),this.hintElement.style.fontFamily=i.FIELD_TEXT_FONTFAMILY,e.appendChild(this.hintElement)),n}createHint(e){const t=document.createElement("div");t.className="blocklyMultilineHint",t.setAttribute("aria-hidden","true"),t.style.height=e+"px";const i=document.createElement("div");i.className="blocklyMultilineHintGroup",i.appendChild(this.createHintKeycap("⏎")),i.appendChild(this.createHintColon()),i.appendChild(this.createHintLabel(_.enterCommits?"commit":"newline")),t.appendChild(i);const n=document.createElement("div");return n.className="blocklyMultilineHintGroup",n.appendChild(this.createHintKeycap("⇧")),n.appendChild(this.createHintKeycap("⏎")),n.appendChild(this.createHintColon()),n.appendChild(this.createHintLabel(_.enterCommits?"newline":"commit")),t.appendChild(n),t}createHintColon(){const e=document.createElement("span");return e.className="blocklyMultilineHintColon",e.textContent=":",e}createHintKeycap(e){const t=document.createElement("span");return t.className="blocklyMultilineHintKey",t.textContent=e,t}createHintLabel(e){const t=document.createElement("span");return t.className="blocklyMultilineHintLabel",t.textContent="commit"===e?c.Msg.FIELD_MULTILINEINPUT_FINISH_EDITING||"Finish editing":c.Msg.FIELD_MULTILINEINPUT_NEW_LINE||"New line",t}setMaxLines(e){"number"==typeof e&&e>0&&e!==this.maxLines_&&(this.maxLines_=e,this.forceRerender())}getMaxLines(){return this.maxLines_}onHtmlInputKeyDown_(e){if("Enter"===e.key){if(e.isComposing)return;const t=e.shiftKey;(_.enterCommits?!t:t)?super.onHtmlInputKeyDown_(e):(this.insertNewline(),e.preventDefault(),e.stopPropagation())}else super.onHtmlInputKeyDown_(e)}insertNewline(){var e,t;const i=this.htmlInput_;if(!i)return;const n=null!==(e=i.selectionStart)&&void 0!==e?e:i.value.length,o=null!==(t=i.selectionEnd)&&void 0!==t?t:n;i.value=i.value.substring(0,n)+"\n"+i.value.substring(o),i.selectionStart=i.selectionEnd=n+1,i.dispatchEvent(new Event("input"))}static fromJson(e){return new this(c.utils.parsing.replaceMessageReferences(e.text),void 0,e)}}function f(){c.fieldRegistry.register("field_multilinetext",_)}_.EDITOR_MIN_WIDTH=150,_.enterCommits=!0,_.showHint=!0,c.Css.register("\n.blocklyHtmlTextAreaInput {\n font-family: monospace;\n resize: none;\n overflow: hidden;\n height: 100%;\n text-align: left;\n}\n\n.blocklyHtmlTextAreaInputOverflowedY {\n overflow-y: scroll;\n}\n\n.blocklyMultilineHint {\n position: absolute;\n bottom: 0;\n left: 0;\n width: 100%;\n display: flex;\n justify-content: space-around;\n align-items: center;\n padding: 0 4px;\n box-sizing: border-box;\n font-size: 0.85em;\n color: rgba(0, 0, 0, 0.6);\n background-color: white;\n border-top: 1px solid rgba(0, 0, 0, 0.15);\n border-radius: 0 0 4px 4px;\n user-select: none;\n pointer-events: none;\n}\n\n.blocklyMultilineHintGroup {\n display: inline-flex;\n align-items: center;\n}\n\n.blocklyMultilineHintKey {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n min-width: 1.3em;\n height: 1.3em;\n padding: 0 0.25em;\n margin: 0 0.1em;\n border: 1px solid rgba(0, 0, 0, 0.35);\n border-radius: 3px;\n background-color: #f5f5f5;\n line-height: 1;\n box-sizing: border-box;\n}\n\n.blocklyMultilineHintColon {\n margin: 0 0.15em;\n}\n\n.blocklyMultilineHintLabel {\n white-space: nowrap;\n}\n");const m="text_multiline",b={type:m,message0:"%1 %2",args0:[{type:"field_image",src:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAwAAAARCAYAAADpPU2iAAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAdhgAAHYYBXaITgQAAABh0RVh0U29mdHdhcmUAcGFpbnQubmV0IDQuMS42/U4J6AAAAP1JREFUOE+Vks0KQUEYhjmRIja4ABtZ2dm5A3t3Ia6AUm7CylYuQRaUhZSlLZJiQbFAyRnPN33y01HOW08z8873zpwzM4F3GWOCruvGIE4/rLaV+Nq1hVGMBqzhqlxgCys4wJA65xnogMHsQ5lujnYHTejBBCK2mE4abjCgMGhNxHgDFWjDSG07kdfVa2pZMf4ZyMAdWmpZMfYOsLiDMYMjlMB+K613QISRhTnITnsYg5yUd0DETmEoMlkFOeIT/A58iyK5E18BuTBfgYXfwNJv4P9/oEBerLylOnRhygmGdPpTTBZAPkde61lbQe4moWUvYUZYLfUNftIY4zwA5X2Z9AYnQrEAAAAASUVORK5CYII=",width:12,height:17,alt:"¶"},{type:"field_multilinetext",name:"TEXT",text:""}],output:"String",style:"text_blocks",helpUrl:"%{BKY_TEXT_TEXT_HELPURL}",tooltip:"%{BKY_TEXT_TEXT_TOOLTIP}",extensions:["parent_tooltip_when_inline"]};function C(e,t){const i=t.multiline_quote_(e.getFieldValue("TEXT")),n=-1!==i.indexOf("+")?d.Order.ADDITION:d.Order.ATOMIC;return[i,n]}function v(e,t){const i=t.multiline_quote_(e.getFieldValue("TEXT")),n=-1!==i.indexOf("+")?p.Order.ADDITIVE:p.Order.ATOMIC;return[i,n]}function I(e,t){const i=t.multiline_quote_(e.getFieldValue("TEXT")),n=-1!==i.indexOf("..")?g.Order.CONCATENATION:g.Order.ATOMIC;return[i,n]}function N(e,t){const i=t.multiline_quote_(e.getFieldValue("TEXT")),n=-1!==i.indexOf(".")?E.Order.STRING_CONCAT:E.Order.ATOMIC;return[i,n]}function y(e,t){const i=t.multiline_quote_(e.getFieldValue("TEXT")),n=-1!==i.indexOf("+")?T.Order.ADDITIVE:T.Order.ATOMIC;return[i,n]}const A=c.common.createBlockDefinitionsFromJsonArray([b]),k=A[m];function S(e={}){f(),c.common.defineBlocks(A),e.javascript&&(e.javascript.forBlock[m]=C),e.dart&&(e.dart.forBlock[m]=v),e.lua&&(e.lua.forBlock[m]=I),e.php&&(e.php.forBlock[m]=N),e.python&&(e.python.forBlock[m]=y)}const O=S;return h})(),e.exports=n(i(500),i(87),i(449),i(172),i(850),i(794))},378:(e,t,i)=>{const n=i(573);class o{constructor(e){if(this.index=new Map,e)for(const[t,i]of e)this.set(t,i)}get size(){return this.index.size}clear(){this.index.clear()}delete(e){return this.index.delete(n(e))}*entries(){for(const[,{term:e,value:t}]of this.index)yield[e,t]}forEach(e,t){for(const i of this.entries())e.call(t,i[1],i[0],this)}get(e){const t=this.index.get(n(e));return t&&t.value}has(e){return this.index.has(n(e))}*keys(){for(const[,{term:e}]of this.index)yield e}set(e,t){const i=n(e);return this.index.set(i,{term:e,value:t}),this}*values(){for(const[,{value:e}]of this.index)yield e}[Symbol.iterator](){return this.entries()[Symbol.iterator]()}}e.exports=o},573:(e,t,i)=>{const n=i(55),o=i(465),s=i(413),r=i(870),a=i(680),l=i(230),h=i(325);e.exports=function e(t){if(!t)return null;if("BlankNode"===t.termType)return n(t);if("DefaultGraph"===t.termType)return s();if("Literal"===t.termType)return r(t);if("NamedNode"===t.termType)return a(t);if("Quad"===t.termType||t.subject&&t.predicate&&t.object&&t.graph)return l(t,e);if("Variable"===t.termType)return h(t);if(t[Symbol.iterator])return o(t,e);throw new Error(`unknown termType ${t.termType}`)}},55:e=>{e.exports=function(e){return"_:"+e.value}},465:e=>{e.exports=function(e,t){return[...e].map((e=>t(e))).join("\n")+"\n"}},413:e=>{e.exports=function(){return""}},870:(e,t,i)=>{const n=i(680),o=/["\\\\\n\r]/,s=/["\\\\\n\r]/g,r={'"':'\\"',"\\":"\\\\","\n":"\\n","\r":"\\r"};function a(e){return r[e]}e.exports=function(e){const t=(i=e.value,o.test(i)?i.replace(s,a):i);var i;return"http://www.w3.org/2001/XMLSchema#string"===e.datatype.value?'"'+t+'"':"http://www.w3.org/1999/02/22-rdf-syntax-ns#langString"===e.datatype.value?'"'+t+'"@'+e.language:'"'+t+'"^^'+n(e.datatype)}},680:e=>{e.exports=function(e){return"<"+e.value+">"}},230:e=>{e.exports=function(e,t){const i=t(e.subject),n=t(e.predicate),o=t(e.object),s=t(e.graph);return`${i} ${n} ${o} ${s?s+" ":""}.`}},325:e=>{e.exports=function(e){return"?"+e.value}},600:(e,t,i)=>{const n=i(755);function o(e){try{return n(e)}catch(e){return null}}class s{constructor(e){if(this.index=new Map,e)for(const t of e)this.add(t)}get size(){return this.index.size}add(e){const t=n(e);return this.index.has(t)||this.index.set(t,e),this}clear(){this.index.clear()}delete(e){return!!e&&this.index.delete(o(e))}entries(){return this.values().entries()}forEach(e,t){return this.values().forEach(e,t)}has(e){return!!e&&this.index.has(o(e))}values(){return new Set(this.index.values())}keys(){return this.values()}[Symbol.iterator](){return this.values()[Symbol.iterator]()}}e.exports=s},755:(e,t,i)=>{const n=i(229),o=i(159),s=i(772),r=i(372),a=i(6),l=i(884),h=i(39);e.exports=function e(t){if(!t)return null;if("BlankNode"===t.termType)return n(t);if("DefaultGraph"===t.termType)return s();if("Literal"===t.termType)return r(t);if("NamedNode"===t.termType)return a(t);if("Quad"===t.termType||t.subject&&t.predicate&&t.object&&t.graph)return l(t,e);if("Variable"===t.termType)return h(t);if(t[Symbol.iterator])return o(t,e);throw new Error(`unknown termType ${t.termType}`)}},229:e=>{e.exports=function(e){return"_:"+e.value}},159:e=>{e.exports=function(e,t){return[...e].map((e=>t(e))).join("\n")+"\n"}},772:e=>{e.exports=function(){return""}},372:(e,t,i)=>{const n=i(6),o=/["\\\\\n\r]/,s=/["\\\\\n\r]/g,r={'"':'\\"',"\\":"\\\\","\n":"\\n","\r":"\\r"};function a(e){return r[e]}e.exports=function(e){const t=(i=e.value,o.test(i)?i.replace(s,a):i);var i;return"http://www.w3.org/2001/XMLSchema#string"===e.datatype.value?'"'+t+'"':"http://www.w3.org/1999/02/22-rdf-syntax-ns#langString"===e.datatype.value?'"'+t+'"@'+e.language:'"'+t+'"^^'+n(e.datatype)}},6:e=>{e.exports=function(e){return"<"+e.value+">"}},884:e=>{e.exports=function(e,t){const i=t(e.subject),n=t(e.predicate),o=t(e.object),s=t(e.graph);return`${i} ${n} ${o} ${s?s+" ":""}.`}},39:e=>{e.exports=function(e){return"?"+e.value}},793:function(e,t,i){"use strict";var n=this&&this.__createBinding||(Object.create?function(e,t,i,n){void 0===n&&(n=i),Object.defineProperty(e,n,{enumerable:!0,get:function(){return t[i]}})}:function(e,t,i,n){void 0===n&&(n=i),e[n]=t[i]}),o=this&&this.__exportStar||function(e,t){for(var i in e)"default"===i||Object.prototype.hasOwnProperty.call(t,i)||n(t,e,i)};Object.defineProperty(t,"__esModule",{value:!0}),o(i(931),t),o(i(483),t),o(i(142),t),o(i(426),t),o(i(988),t),o(i(754),t),o(i(401),t)},931:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.BlankNode=void 0,t.BlankNode=class{constructor(e){this.termType="BlankNode",this.value=e}equals(e){return!!e&&"BlankNode"===e.termType&&e.value===this.value}}},483:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.DataFactory=void 0;const n=i(931),o=i(142),s=i(426),r=i(988),a=i(754),l=i(401);let h=0;t.DataFactory=class{constructor(e){this.blankNodeCounter=0,e=e||{},this.blankNodePrefix=e.blankNodePrefix||`df_${h++}_`}namedNode(e){return new r.NamedNode(e)}blankNode(e){return new n.BlankNode(e||`${this.blankNodePrefix}${this.blankNodeCounter++}`)}literal(e,t){return new s.Literal(e,t)}variable(e){return new l.Variable(e)}defaultGraph(){return o.DefaultGraph.INSTANCE}quad(e,t,i,n){return new a.Quad(e,t,i,n||this.defaultGraph())}fromTerm(e){switch(e.termType){case"NamedNode":return this.namedNode(e.value);case"BlankNode":return this.blankNode(e.value);case"Literal":return e.language?this.literal(e.value,e.language):e.datatype.equals(s.Literal.XSD_STRING)?this.literal(e.value):this.literal(e.value,this.fromTerm(e.datatype));case"Variable":return this.variable(e.value);case"DefaultGraph":return this.defaultGraph();case"Quad":return this.quad(this.fromTerm(e.subject),this.fromTerm(e.predicate),this.fromTerm(e.object),this.fromTerm(e.graph))}}fromQuad(e){return this.fromTerm(e)}resetBlankNodeCounter(){this.blankNodeCounter=0}}},142:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.DefaultGraph=void 0;class i{constructor(){this.termType="DefaultGraph",this.value=""}equals(e){return!!e&&"DefaultGraph"===e.termType}}t.DefaultGraph=i,i.INSTANCE=new i},426:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Literal=void 0;const n=i(988);class o{constructor(e,t){this.termType="Literal",this.value=e,"string"==typeof t?(this.language=t,this.datatype=o.RDF_LANGUAGE_STRING):t?(this.language="",this.datatype=t):(this.language="",this.datatype=o.XSD_STRING)}equals(e){return!!e&&"Literal"===e.termType&&e.value===this.value&&e.language===this.language&&this.datatype.equals(e.datatype)}}t.Literal=o,o.RDF_LANGUAGE_STRING=new n.NamedNode("http://www.w3.org/1999/02/22-rdf-syntax-ns#langString"),o.XSD_STRING=new n.NamedNode("http://www.w3.org/2001/XMLSchema#string")},988:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.NamedNode=void 0,t.NamedNode=class{constructor(e){this.termType="NamedNode",this.value=e}equals(e){return!!e&&"NamedNode"===e.termType&&e.value===this.value}}},754:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Quad=void 0,t.Quad=class{constructor(e,t,i,n){this.termType="Quad",this.value="",this.subject=e,this.predicate=t,this.object=i,this.graph=n}equals(e){return!!e&&("Quad"===e.termType||!e.termType)&&this.subject.equals(e.subject)&&this.predicate.equals(e.predicate)&&this.object.equals(e.object)&&this.graph.equals(e.graph)}}},401:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Variable=void 0,t.Variable=class{constructor(e){this.termType="Variable",this.value=e}equals(e){return!!e&&"Variable"===e.termType&&e.value===this.value}}},825:e=>{function t(e){this._options=e=e||{};var t=e.prefixes||{};this._prefixByIri={};var i=[];for(var n in t){var o=t[n];r(o)&&(this._prefixByIri[o]=n,i.push(o))}var s=i.join("|").replace(/[\]\/\(\)\*\+\?\.\\\$]/g,"\\$&");this._prefixRegex=new RegExp("^("+s+")([a-zA-Z][\\-_a-zA-Z0-9]*)$"),this._usedPrefixes={},this._sparqlStar=e.sparqlStar,this._indent=r(e.indent)?e.indent:" ",this._newline=r(e.newline)?e.newline:"\n",this._explicitDatatype=Boolean(e.explicitDatatype)}t.prototype.toQuery=function(e){var t="";return e.queryType&&(t+=e.queryType.toUpperCase()+" "),e.reduced&&(t+="REDUCED "),e.distinct&&(t+="DISTINCT "),e.variables?t+=h(e.variables,void 0,(function(e){return a(e)?this.toEntity(e):"("+this.toExpression(e.expression)+" AS "+s(e.variable)+")"}),this)+" ":e.template&&(t+=this.group(e.template,!0)+this._newline),e.from&&(t+=this.graphs("FROM ",e.from.default)+this.graphs("FROM NAMED ",e.from.named)),e.where&&(t+="WHERE "+this.group(e.where,!0)+this._newline),e.updates&&(t+=h(e.updates,";"+this._newline,this.toUpdate,this)),e.group&&(t+="GROUP BY "+h(e.group,void 0,(function(e){var t=a(e.expression)?this.toEntity(e.expression):"("+this.toExpression(e.expression)+")";return e.variable?"("+t+" AS "+s(e.variable)+")":t}),this)+this._newline),e.having&&(t+="HAVING ("+h(e.having,void 0,this.toExpression,this)+")"+this._newline),e.order&&(t+="ORDER BY "+h(e.order,void 0,(function(e){var t="("+this.toExpression(e.expression)+")";return e.descending?"DESC "+t:t}),this)+this._newline),e.offset&&(t+="OFFSET "+e.offset+this._newline),e.limit&&(t+="LIMIT "+e.limit+this._newline),e.values&&(t+=this.values(e)),(t=this.baseAndPrefixes(e)+t).trim()},t.prototype.baseAndPrefixes=function(e){var t=e.base?"BASE <"+e.base+">"+this._newline:"",i="";for(var n in e.prefixes)(this._options.allPrefixes||this._usedPrefixes[n])&&(i+="PREFIX "+n+": <"+e.prefixes[n]+">"+this._newline);return t+i},t.prototype.toPattern=function(e){var t=e.type||e instanceof Array&&"array"||(e.subject&&e.predicate&&e.object?"triple":"");if(!(t in this))throw new Error("Unknown entry type: "+t);return this[t](e)},t.prototype.triple=function(e){return this.toEntity(e.subject)+" "+this.toEntity(e.predicate)+" "+this.toEntity(e.object)+"."},t.prototype.array=function(e){return h(e,this._newline,this.toPattern,this)},t.prototype.bgp=function(e){return this.encodeTriples(e.triples)},t.prototype.encodeTriples=function(e){if(!e.length)return"";for(var t=[],i=void 0,n=void 0,o=0;o<e.length;o++){var s=e[o];l(s.subject,i)?l(s.predicate,n)?t.push(","):(n=s.predicate,t.push(";"+this._newline,this._indent,this.toEntity(n))):(i&&t.push("."+this._newline),i=s.subject,n=s.predicate,t.push(this.toEntity(i)," ",this.toEntity(n))),t.push(" ",this.toEntity(s.object))}return t.push("."),t.join("")},t.prototype.graph=function(e){return"GRAPH "+this.toEntity(e.name)+" "+this.group(e)},t.prototype.graphs=function(e,t){return t&&0!==t.length?h(t,"",(function(t){return e+this.toEntity(t)+this._newline}),this):""},t.prototype.group=function(e,t){return-1===(e=!0!==t?this.array(e.patterns||e.triples):this.toPattern("group"!==e.type?e:e.patterns)).indexOf(this._newline)?"{ "+e+" }":"{"+this._newline+this.indent(e)+this._newline+"}"},t.prototype.query=function(e){return this.toQuery(e)},t.prototype.filter=function(e){return"FILTER("+this.toExpression(e.expression)+")"},t.prototype.bind=function(e){return"BIND("+this.toExpression(e.expression)+" AS "+s(e.variable)+")"},t.prototype.optional=function(e){return"OPTIONAL "+this.group(e)},t.prototype.union=function(e){return h(e.patterns,this._newline+"UNION"+this._newline,(function(e){return this.group(e,!0)}),this)},t.prototype.minus=function(e){return"MINUS "+this.group(e)},t.prototype.values=function(e){var t,i,n=Object.keys(e.values.reduce((function(e,t){for(var i in t)e[i]=!0;return e}),{}));return 1===n.length?t=i="":(t="(",i=")"),"VALUES "+t+n.join(" ")+i+" {"+this._newline+h(e.values,this._newline,(function(e){return" "+t+h(n,void 0,(function(t){return e[t]?this.toEntity(e[t]):"UNDEF"}),this)+i}),this)+this._newline+"}"},t.prototype.service=function(e){return"SERVICE "+(e.silent?"SILENT ":"")+this.toEntity(e.name)+" "+this.group(e)},t.prototype.toExpression=function(e){if(a(e))return this.toEntity(e);switch(e.type.toLowerCase()){case"aggregate":return e.aggregation.toUpperCase()+"("+(e.distinct?"DISTINCT ":"")+this.toExpression(e.expression)+("string"==typeof e.separator?'; SEPARATOR = "'+e.separator.replace(i,n)+'"':"")+")";case"functioncall":return this.toEntity(e.function)+"("+h(e.args,", ",this.toExpression,this)+")";case"operation":var t=e.operator.toUpperCase(),o=e.args||[];switch(e.operator.toLowerCase()){case"<":case">":case">=":case"<=":case"&&":case"||":case"=":case"!=":case"+":case"-":case"*":case"/":return(a(o[0])?this.toEntity(o[0]):"("+this.toExpression(o[0])+")")+" "+t+" "+(a(o[1])?this.toEntity(o[1]):"("+this.toExpression(o[1])+")");case"!":return"!("+this.toExpression(o[0])+")";case"uplus":return"+("+this.toExpression(o[0])+")";case"uminus":return"-("+this.toExpression(o[0])+")";case"notin":t="NOT IN";case"in":return this.toExpression(o[0])+" "+t+"("+(r(o[1])?o[1]:h(o[1],", ",this.toExpression,this))+")";case"notexists":t="NOT EXISTS";case"exists":return t+" "+this.group(o[0],!0);default:return t+"("+h(o,", ",this.toExpression,this)+")"}default:throw new Error("Unknown expression type: "+e.type)}},t.prototype.toEntity=function(e){if(a(e))switch(e.termType){case"Wildcard":return"*";case"Variable":return s(e);case"BlankNode":return"_:"+e.value;case"Literal":var t=e.value||"",o=e.language||"",r=e.datatype;if(e='"'+t.replace(i,n)+'"',o)e+="@"+o;else if(r){if(!this._explicitDatatype)switch(r.value){case"http://www.w3.org/2001/XMLSchema#string":return e;case"http://www.w3.org/2001/XMLSchema#integer":if(/^\d+$/.test(t))return t+" "}e+="^^"+this.encodeIRI(r.value)}return e;case"Quad":if(!this._sparqlStar)throw new Error("SPARQL* support is not enabled");return e.graph&&"DefaultGraph"!==e.graph.termType?"<< GRAPH "+this.toEntity(e.graph)+" { "+this.toEntity(e.subject)+" "+this.toEntity(e.predicate)+" "+this.toEntity(e.object)+" } >>":"<< "+this.toEntity(e.subject)+" "+this.toEntity(e.predicate)+" "+this.toEntity(e.object)+" >>";default:return this.encodeIRI(e.value)}else{var l=e.items.map(this.toEntity,this),h=e.pathType;switch(h){case"^":case"!":return h+l[0];case"*":case"+":case"?":return"("+l[0]+h+")";default:return"("+l.join(h)+")"}}};var i=/["\\\t\n\r\b\f]/g,n=function(e){return o[e]},o={"\\":"\\\\",'"':'\\"',"\t":"\\t","\n":"\\n","\r":"\\r","\b":"\\b","\f":"\\f"};function s(e){return"?"+e.value}function r(e){return"string"==typeof e}function a(e){return"string"==typeof e.termType}function l(e,t){if(!e||!a(e))return!1;if(!t||!a(t))return!1;if(e.termType!==t.termType)return!1;switch(e.termType){case"Literal":return e.value===t.value&&e.language===t.language&&l(e.datatype,t.datatype);case"Quad":return l(e.subject,t.subject)&&l(e.predicate,t.predicate)&&l(e.object,t.object)&&l(e.graph,t.graph);default:return e.value===t.value}}function h(e,t,i,n){return e.map(i,n).join(r(t)?t:" ")}t.prototype.encodeIRI=function(e){var t=this._prefixRegex.exec(e);if(t){var i=this._prefixByIri[t[1]];return this._usedPrefixes[i]=!0,i+":"+t[2]}return"<"+e+">"},t.prototype.toUpdate=function(e){switch(e.type||e.updateType){case"load":return"LOAD"+(e.source?" "+this.toEntity(e.source):"")+(e.destination?" INTO GRAPH "+this.toEntity(e.destination):"");case"insert":return"INSERT DATA "+this.group(e.insert,!0);case"delete":return"DELETE DATA "+this.group(e.delete,!0);case"deletewhere":return"DELETE WHERE "+this.group(e.delete,!0);case"insertdelete":return(e.graph?"WITH "+this.toEntity(e.graph)+this._newline:"")+(e.delete.length?"DELETE "+this.group(e.delete,!0)+this._newline:"")+(e.insert.length?"INSERT "+this.group(e.insert,!0)+this._newline:"")+(e.using?this.graphs("USING ",e.using.default):"")+(e.using?this.graphs("USING NAMED ",e.using.named):"")+"WHERE "+this.group(e.where,!0);case"add":case"copy":case"move":return e.type.toUpperCase()+" "+(e.silent?"SILENT ":"")+(e.source.default?"DEFAULT":this.toEntity(e.source.name))+" TO "+this.toEntity(e.destination.name);case"create":case"clear":case"drop":return e.type.toUpperCase()+(e.silent?" SILENT ":" ")+(e.graph.default?"DEFAULT":e.graph.named?"NAMED":e.graph.all?"ALL":"GRAPH "+this.toEntity(e.graph.name));default:throw new Error("Unknown update query type: "+e.type)}},t.prototype.indent=function(e){return e.replace(/^/gm,this._indent)},e.exports=function(e={}){return{stringify:function(i){var n=Object.create(e);return n.prefixes=i.prefixes,new t(n).toQuery(i)},createGenerator:function(){return new t(e)}}}},849:(e,t,i)=>{var n=function(){var e=function(e,t,i,n){for(i=i||{},n=e.length;n--;i[e[n]]=t);return i},t=[6,12,13,15,16,24,32,36,41,45,100,110,113,115,116,123,126,131,197,224,229,308,329,330,331,332,333],n=[2,247],o=[100,110,113,115,116,123,126,131,329,330,331,332,333],s=[2,409],r=[1,18],a=[1,27],l=[13,16,45,197,224,229,308],h=[28,29,53],u=[28,53],c=[1,42],d=[1,45],p=[1,41],g=[1,44],E=[123,126],T=[1,67],_=[39,45,87],f=[13,16,45,197,224,308],m=[1,87],b=[2,281],C=[1,86],v=[13,16,45,82,87,89,231,294,295,296,297,298,299,300,301,302,303,304,305,306,308,309,310,312],I=[6,28,29,53,63,70,73,81,83,85],N=[6,13,16,28,29,53,63,70,73,81,83,85,87,308],y=[6,13,16,28,29,45,53,63,70,73,81,82,83,85,87,89,197,231,294,295,296,297,298,299,300,301,302,303,304,305,306,308,309,310,312,314],A=[6,13,16,28,29,31,39,45,47,48,53,63,70,73,81,82,83,85,87,89,109,112,121,123,126,128,159,160,161,163,164,174,193,197,224,229,231,232,242,246,250,263,265,272,290,294,295,296,297,298,299,300,301,302,303,304,305,306,308,309,310,312,314,317,318,335,337,338,340,341,342,343,344,345,346],k=[13,16,308],S=[112,132,327,334],O=[13,16,112,132,308],R=[1,111],w=[1,117],L=[112,132,327,328,334],D=[13,16,112,132,308,328],x=[28,29,45,53,87],F=[1,138],M=[1,151],P=[1,128],B=[1,127],U=[1,129],V=[1,140],H=[1,141],G=[1,142],W=[1,143],q=[1,144],$=[1,145],j=[1,147],z=[1,148],X=[2,457],Y=[1,158],K=[1,159],J=[1,160],Q=[1,152],Z=[1,153],ee=[1,156],te=[1,171],ie=[1,172],ne=[1,173],oe=[1,174],se=[1,175],re=[1,176],ae=[1,167],le=[1,168],he=[1,169],ue=[1,170],ce=[1,157],de=[1,166],pe=[1,161],ge=[1,162],Ee=[1,163],Te=[1,164],_e=[1,165],fe=[6,13,16,29,31,45,82,85,87,89,112,159,160,161,163,164,231,294,295,296,297,298,299,300,301,302,303,304,305,306,308,309,310,312,335],me=[1,195],be=[6,31,73,81,83,85],Ce=[2,285],ve=[1,199],Ie=[1,201],Ne=[6,31,70,73,81,83,85],ye=[2,283],Ae=[1,207],ke=[1,218],Se=[1,223],Oe=[1,219],Re=[1,225],we=[1,226],Le=[1,224],De=[6,63,70,73,81,83,85],xe=[1,236],Fe=[2,334],Me=[1,243],Pe=[1,241],Be=[6,193],Ue=[2,349],Ve=[2,339],He=[28,128],Ge=[47,48,193,272],We=[47,48,193,242,272],qe=[47,48,193,242,246,272],$e=[47,48,193,242,246,250,263,265,272,290,297,298,299,300,301,302,341,342,343,344,345,346],je=[39,47,48,193,242,246,250,263,265,272,290,297,298,299,300,301,302,338,341,342,343,344,345,346],ze=[1,271],Xe=[1,270],Ye=[6,13,16,29,31,39,45,47,48,70,73,76,78,81,82,83,85,87,89,112,159,160,161,163,164,193,231,242,246,250,263,265,268,269,270,271,272,273,274,276,277,279,280,283,285,290,294,295,296,297,298,299,300,301,302,303,304,305,306,308,309,310,312,335,338,341,342,343,344,345,346,347,348,349,350,351],Ke=[1,281],Je=[1,280],Qe=[13,16,29,31,39,45,47,48,82,85,87,89,112,159,160,161,163,164,174,193,197,224,229,231,232,242,246,250,263,265,272,290,294,295,296,297,298,299,300,301,302,303,304,305,306,308,309,310,312,314,317,318,335,338,341,342,343,344,345,346],Ze=[45,89],et=[13,16,29,31,39,45,47,48,82,85,87,89,112,159,160,161,163,164,174,193,197,224,229,231,232,242,246,250,263,265,272,290,292,293,294,295,296,297,298,299,300,301,302,303,304,305,306,308,309,310,312,314,317,318,335,338,341,342,343,344,345,346],tt=[13,16,31,82,174,294,295,296,297,298,299,300,301,302,303,304,305,306,308,312],it=[31,89],nt=[48,87],ot=[6,13,16,45,48,82,87,89,231,294,295,296,297,298,299,300,301,302,303,304,305,306,308,309,310,312,337,338],st=[6,13,16,39,45,48,82,87,89,231,263,294,295,296,297,298,299,300,301,302,303,304,305,306,308,309,310,312,337,338,340],rt=[1,313],at=[6,85],lt=[6,31,81,83,85],ht=[2,361],ut=[2,353],ct=[1,343],dt=[31,112,335],pt=[13,16,29,31,45,48,82,85,87,89,112,159,160,161,163,164,193,197,224,229,231,232,272,294,295,296,297,298,299,300,301,302,303,304,305,306,308,309,310,312,317,318,335],gt=[13,16,29,31,45,48,82,85,87,89,112,159,160,161,163,164,193,197,224,229,231,232,272,294,295,296,297,298,299,300,301,302,303,304,305,306,308,309,310,312,314,317,318,335],Et=[6,109,193],Tt=[31,112],_t=[13,16,45,82,87,224,263,265,268,269,270,271,273,274,276,277,279,280,283,285,294,295,296,297,298,299,300,301,302,303,304,305,306,308,312,346,347,348,349,350,351],ft=[1,390],mt=[1,391],bt=[13,16,87,197,308,314],Ct=[13,16,39,45,82,87,224,263,265,268,269,270,271,273,274,276,277,279,280,283,285,294,295,296,297,298,299,300,301,302,303,304,305,306,308,312,346,347,348,349,350,351],vt=[1,417],It=[1,418],Nt=[13,16,48,197,229,308],yt=[6,31,85],At=[6,13,16,31,45,73,81,83,85,268,269,270,271,273,274,276,277,279,280,283,285,308,346,347,348,349,350,351],kt=[6,13,16,29,31,45,73,76,78,81,82,83,85,87,89,112,159,160,161,163,164,231,268,269,270,271,273,274,276,277,279,280,283,285,294,295,296,297,298,299,300,301,302,303,304,305,306,308,309,310,312,335,346,347,348,349,350,351],St=[29,31,85,112,159,160,161,163,164],Ot=[1,443],Rt=[1,444],wt=[1,449],Lt=[31,112,193,232,318,335],Dt=[13,16,45,48,82,87,89,231,294,295,296,297,298,299,300,301,302,303,304,305,306,308,309,310,312],xt=[13,16,31,45,48,82,87,89,112,193,231,232,272,294,295,296,297,298,299,300,301,302,303,304,305,306,308,309,310,312,317,318,335],Ft=[13,16,29,31,45,48,82,85,87,89,112,159,160,161,163,164,193,231,232,272,294,295,296,297,298,299,300,301,302,303,304,305,306,308,309,310,312,317,318,335],Mt=[13,16,31,48,82,174,294,295,296,297,298,299,300,301,302,303,304,305,306,308,312],Pt=[31,45],Bt=[1,507],Ut=[1,508],Vt=[6,13,16,29,31,39,45,47,48,63,70,73,76,78,81,82,83,85,87,89,112,159,160,161,163,164,193,231,242,246,250,263,265,268,269,270,271,272,273,274,276,277,279,280,283,285,290,294,295,296,297,298,299,300,301,302,303,304,305,306,308,309,310,312,335,336,338,341,342,343,344,345,346,347,348,349,350,351],Ht=[29,31,85,112,159,160,161,163,164,335],Gt=[6,13,16,31,45,70,73,81,83,85,87,268,269,270,271,273,274,276,277,279,280,283,285,308,346,347,348,349,350,351],Wt=[13,16,31,45,48,82,87,89,112,193,197,231,232,272,294,295,296,297,298,299,300,301,302,303,304,305,306,308,309,310,312,317,318,335],qt=[2,352],$t=[13,16,197,308,314],jt=[1,565],zt=[6,13,16,31,45,76,78,81,83,85,87,268,269,270,271,273,274,276,277,279,280,283,285,308,346,347,348,349,350,351],Xt=[13,16,29,31,45,82,85,87,89,112,159,160,161,163,164,231,294,295,296,297,298,299,300,301,302,303,304,305,306,308,309,310,312],Yt=[13,16,29,31,45,82,85,87,89,112,159,160,161,163,164,231,294,295,296,297,298,299,300,301,302,303,304,305,306,308,309,310,312,335],Kt=[13,16,87,308],Jt=[2,364],Qt=[29,31,85,112,159,160,161,163,164,193,232,318,335],Zt=[31,112,193,232,272,318,335],ei=[2,359],ti=[13,16,48,82,174,294,295,296,297,298,299,300,301,302,303,304,305,306,308,312],ii=[29,31,85,112,159,160,161,163,164,193,232,272,318,335],ni=[13,16,31,45,82,87,89,112,231,294,295,296,297,298,299,300,301,302,303,304,305,306,308,309,310,312],oi=[2,347],si={trace:function(){},yy:{},symbols_:{error:2,QueryOrUpdate:3,Prologue:4,QueryOrUpdate_group0:5,EOF:6,Query:7,Qry:8,Query_option0:9,Prologue_repetition0:10,BaseDecl:11,BASE:12,IRIREF:13,PrefixDecl:14,PREFIX:15,PNAME_NS:16,SelectClauseWildcard:17,Qry_repetition0:18,WhereClause:19,SolutionModifierNoGroup:20,SelectClauseVars:21,Qry_repetition1:22,SolutionModifier:23,CONSTRUCT:24,ConstructTemplate:25,Qry_repetition2:26,Qry_repetition3:27,WHERE:28,"{":29,Qry_option0:30,"}":31,DESCRIBE:32,Qry_group0:33,Qry_repetition4:34,Qry_option1:35,ASK:36,Qry_repetition5:37,SelectClauseBase:38,"*":39,SelectClauseVars_repetition_plus0:40,SELECT:41,SelectClauseBase_option0:42,SelectClauseItem:43,Var:44,"(":45,Expression:46,AS:47,")":48,SubSelect:49,SubSelect_option0:50,SubSelect_option1:51,DatasetClause:52,FROM:53,DatasetClause_option0:54,iri:55,WhereClause_option0:56,GroupGraphPattern:57,SolutionModifier_option0:58,SolutionModifierNoGroup_option0:59,SolutionModifierNoGroup_option1:60,SolutionModifierNoGroup_option2:61,GroupClause:62,GROUP:63,BY:64,GroupClause_repetition_plus0:65,GroupCondition:66,BuiltInCall:67,FunctionCall:68,HavingClause:69,HAVING:70,HavingClause_repetition_plus0:71,OrderClause:72,ORDER:73,OrderClause_repetition_plus0:74,OrderCondition:75,ASC:76,BrackettedExpression:77,DESC:78,Constraint:79,LimitOffsetClauses:80,LIMIT:81,INTEGER:82,OFFSET:83,ValuesClause:84,VALUES:85,InlineData:86,VAR:87,InlineData_repetition0:88,NIL:89,InlineData_repetition1:90,InlineData_repetition_plus2:91,InlineData_repetition3:92,DataBlock:93,DataBlockValueList:94,DataBlockValueList_repetition_plus0:95,Update:96,Update_repetition0:97,Update1:98,Update_option0:99,LOAD:100,Update1_option0:101,Update1_option1:102,Update1_group0:103,Update1_option2:104,GraphRefAll:105,Update1_group1:106,Update1_option3:107,GraphOrDefault:108,TO:109,CREATE:110,Update1_option4:111,GRAPH:112,INSERTDATA:113,QuadPattern:114,DELETEDATA:115,DELETEWHERE:116,Update1_option5:117,InsertDeleteClause:118,Update1_repetition0:119,IntoGraphClause:120,INTO:121,GraphRef:122,DELETE:123,InsertDeleteClause_option0:124,InsertClause:125,INSERT:126,UsingClause:127,USING:128,UsingClause_option0:129,WithClause:130,WITH:131,DEFAULT:132,GraphOrDefault_option0:133,GraphRefAll_group0:134,Quads:135,Quads_option0:136,Quads_repetition0:137,QuadsNotTriples:138,VarOrIri:139,QuadsNotTriples_option0:140,QuadsNotTriples_option1:141,QuadsNotTriples_option2:142,TriplesTemplate:143,TriplesTemplate_repetition0:144,TriplesSameSubject:145,TriplesTemplate_option0:146,GroupGraphPatternSub:147,GroupGraphPatternSub_option0:148,GroupGraphPatternSub_repetition0:149,GroupGraphPatternSubTail:150,GraphPatternNotTriples:151,GroupGraphPatternSubTail_option0:152,GroupGraphPatternSubTail_option1:153,TriplesBlock:154,TriplesBlock_repetition0:155,TriplesSameSubjectPath:156,TriplesBlock_option0:157,GroupOrUnionGraphPattern:158,OPTIONAL:159,MINUS:160,SERVICE:161,GraphPatternNotTriples_option0:162,FILTER:163,BIND:164,InlineDataOneVar:165,InlineDataFull:166,InlineDataOneVar_repetition0:167,InlineDataFull_repetition0:168,InlineDataFull_repetition_plus1:169,InlineDataFull_repetition2:170,DataBlockValue:171,Literal:172,QuotedTriple:173,UNDEF:174,GroupOrUnionGraphPattern_repetition0:175,ArgList:176,ArgList_option0:177,ArgList_repetition0:178,ExpressionList:179,ExpressionList_repetition0:180,ConstructTemplate_option0:181,ConstructTriples:182,ConstructTriples_repetition0:183,ConstructTriples_option0:184,VarOrTermOrQuotedTP:185,PropertyListNotEmpty:186,TriplesNode:187,PropertyList:188,PropertyList_option0:189,VerbObjectList:190,PropertyListNotEmpty_repetition0:191,SemiOptionalVerbObjectList:192,";":193,SemiOptionalVerbObjectList_option0:194,Verb:195,ObjectList:196,a:197,ObjectList_repetition0:198,Object:199,GraphNode:200,Object_option0:201,PropertyListPathNotEmpty:202,TriplesNodePath:203,TriplesSameSubjectPath_option0:204,O:205,PropertyListPathNotEmpty_repetition0:206,PropertyListPathNotEmptyTail:207,O_group0:208,ObjectListPath:209,ObjectListPath_repetition0:210,ObjectPath:211,GraphNodePath:212,ObjectPath_option0:213,Path:214,Path_repetition0:215,PathSequence:216,PathSequence_repetition0:217,PathEltOrInverse:218,PathElt:219,PathPrimary:220,PathElt_option0:221,PathEltOrInverse_option0:222,IriOrA:223,"!":224,PathNegatedPropertySet:225,PathOneInPropertySet:226,PathNegatedPropertySet_repetition0:227,PathNegatedPropertySet_option0:228,"^":229,TriplesNode_repetition_plus0:230,"[":231,"]":232,TriplesNodePath_repetition_plus0:233,VarOrTermOrQuotedTPExpr:234,VarOrTerm:235,GraphTerm:236,BlankNode:237,ConditionalOrExpression:238,ConditionalAndExpression:239,ConditionalOrExpression_repetition0:240,ConditionalOrExpressionTail:241,"||":242,RelationalExpression:243,ConditionalAndExpression_repetition0:244,ConditionalAndExpressionTail:245,"&&":246,NumericExpression:247,RelationalExpression_group0:248,RelationalExpression_option0:249,IN:250,MultiplicativeExpression:251,NumericExpression_repetition0:252,AdditiveExpressionTail:253,AdditiveExpressionTail_group0:254,NumericLiteralPositive:255,AdditiveExpressionTail_repetition0:256,NumericLiteralNegative:257,AdditiveExpressionTail_repetition1:258,UnaryExpression:259,MultiplicativeExpression_repetition0:260,MultiplicativeExpressionTail:261,MultiplicativeExpressionTail_group0:262,"+":263,PrimaryExpression:264,"-":265,ExprQuotedTP:266,Aggregate:267,FUNC_ARITY0:268,FUNC_ARITY1:269,FUNC_ARITY1_SPARQL_STAR:270,FUNC_ARITY2:271,",":272,FUNC_ARITY3:273,FUNC_ARITY3_SPARQL_STAR:274,BuiltInCall_group0:275,BOUND:276,BNODE:277,BuiltInCall_option0:278,EXISTS:279,COUNT:280,Aggregate_option0:281,Aggregate_group0:282,FUNC_AGGREGATE:283,Aggregate_option1:284,GROUP_CONCAT:285,Aggregate_option2:286,Aggregate_option3:287,GroupConcatSeparator:288,SEPARATOR:289,"=":290,String:291,LANGTAG:292,"^^":293,DECIMAL:294,DOUBLE:295,BOOLEAN:296,INTEGER_POSITIVE:297,DECIMAL_POSITIVE:298,DOUBLE_POSITIVE:299,INTEGER_NEGATIVE:300,DECIMAL_NEGATIVE:301,DOUBLE_NEGATIVE:302,STRING_LITERAL1:303,STRING_LITERAL2:304,STRING_LITERAL_LONG1:305,STRING_LITERAL_LONG2:306,PrefixedName:307,PNAME_LN:308,BLANK_NODE_LABEL:309,ANON:310,QuotedTP:311,"<<":312,qtSubjectOrObject:313,">>":314,DataValueTerm:315,AnnotationPattern:316,"{|":317,"|}":318,AnnotationPatternPath:319,ExprVarOrTerm:320,QueryOrUpdate_group0_option0:321,Prologue_repetition0_group0:322,Qry_group0_repetition_plus0:323,SelectClauseBase_option0_group0:324,DISTINCT:325,REDUCED:326,NAMED:327,SILENT:328,CLEAR:329,DROP:330,ADD:331,MOVE:332,COPY:333,ALL:334,".":335,UNION:336,"|":337,"/":338,PathElt_option0_group0:339,"?":340,"!=":341,"<":342,">":343,"<=":344,">=":345,NOT:346,CONCAT:347,COALESCE:348,SUBSTR:349,REGEX:350,REPLACE:351,$accept:0,$end:1},terminals_:{2:"error",6:"EOF",12:"BASE",13:"IRIREF",15:"PREFIX",16:"PNAME_NS",24:"CONSTRUCT",28:"WHERE",29:"{",31:"}",32:"DESCRIBE",36:"ASK",39:"*",41:"SELECT",45:"(",47:"AS",48:")",53:"FROM",63:"GROUP",64:"BY",70:"HAVING",73:"ORDER",76:"ASC",78:"DESC",81:"LIMIT",82:"INTEGER",83:"OFFSET",85:"VALUES",87:"VAR",89:"NIL",100:"LOAD",109:"TO",110:"CREATE",112:"GRAPH",113:"INSERTDATA",115:"DELETEDATA",116:"DELETEWHERE",121:"INTO",123:"DELETE",126:"INSERT",128:"USING",131:"WITH",132:"DEFAULT",159:"OPTIONAL",160:"MINUS",161:"SERVICE",163:"FILTER",164:"BIND",174:"UNDEF",193:";",197:"a",224:"!",229:"^",231:"[",232:"]",242:"||",246:"&&",250:"IN",263:"+",265:"-",268:"FUNC_ARITY0",269:"FUNC_ARITY1",270:"FUNC_ARITY1_SPARQL_STAR",271:"FUNC_ARITY2",272:",",273:"FUNC_ARITY3",274:"FUNC_ARITY3_SPARQL_STAR",276:"BOUND",277:"BNODE",279:"EXISTS",280:"COUNT",283:"FUNC_AGGREGATE",285:"GROUP_CONCAT",289:"SEPARATOR",290:"=",292:"LANGTAG",293:"^^",294:"DECIMAL",295:"DOUBLE",296:"BOOLEAN",297:"INTEGER_POSITIVE",298:"DECIMAL_POSITIVE",299:"DOUBLE_POSITIVE",300:"INTEGER_NEGATIVE",301:"DECIMAL_NEGATIVE",302:"DOUBLE_NEGATIVE",303:"STRING_LITERAL1",304:"STRING_LITERAL2",305:"STRING_LITERAL_LONG1",306:"STRING_LITERAL_LONG2",308:"PNAME_LN",309:"BLANK_NODE_LABEL",310:"ANON",312:"<<",314:">>",317:"{|",318:"|}",325:"DISTINCT",326:"REDUCED",327:"NAMED",328:"SILENT",329:"CLEAR",330:"DROP",331:"ADD",332:"MOVE",333:"COPY",334:"ALL",335:".",336:"UNION",337:"|",338:"/",340:"?",341:"!=",342:"<",343:">",344:"<=",345:">=",346:"NOT",347:"CONCAT",348:"COALESCE",349:"SUBSTR",350:"REGEX",351:"REPLACE"},productions_:[0,[3,3],[7,2],[4,1],[11,2],[14,3],[8,4],[8,4],[8,5],[8,7],[8,5],[8,4],[17,2],[21,2],[38,2],[43,1],[43,5],[49,4],[49,4],[52,3],[19,2],[23,2],[20,3],[62,3],[66,1],[66,1],[66,3],[66,5],[66,1],[69,2],[72,3],[75,2],[75,2],[75,1],[75,1],[80,2],[80,2],[80,4],[80,4],[84,2],[86,4],[86,4],[86,6],[86,2],[94,3],[96,3],[98,4],[98,3],[98,5],[98,4],[98,2],[98,2],[98,2],[98,5],[120,2],[118,3],[118,1],[125,2],[127,3],[130,2],[108,1],[108,2],[122,2],[105,1],[105,1],[114,3],[135,2],[138,7],[143,3],[57,3],[57,3],[147,2],[150,3],[154,3],[151,1],[151,2],[151,2],[151,3],[151,4],[151,2],[151,6],[151,1],[93,1],[93,1],[165,4],[166,4],[166,6],[171,1],[171,1],[171,1],[171,1],[158,2],[79,1],[79,1],[79,1],[68,2],[176,1],[176,5],[179,1],[179,4],[25,3],[182,3],[145,2],[145,2],[188,1],[186,2],[192,2],[190,2],[195,1],[195,1],[196,2],[199,2],[156,2],[156,2],[202,2],[207,1],[207,2],[205,2],[209,2],[211,2],[214,2],[216,2],[219,2],[218,2],[220,1],[220,2],[220,3],[225,1],[225,1],[225,4],[226,1],[226,2],[187,3],[187,3],[203,3],[203,3],[200,1],[200,1],[212,1],[212,1],[234,1],[235,1],[235,1],[139,1],[139,1],[44,1],[236,1],[236,1],[236,1],[236,1],[46,1],[238,2],[241,2],[239,2],[245,2],[243,1],[243,3],[243,4],[247,2],[253,2],[253,2],[253,2],[251,2],[261,2],[259,2],[259,2],[259,2],[259,1],[264,1],[264,1],[264,1],[264,1],[264,1],[264,1],[264,1],[77,3],[67,1],[67,2],[67,4],[67,4],[67,6],[67,8],[67,8],[67,2],[67,4],[67,2],[67,4],[67,3],[267,5],[267,5],[267,6],[288,4],[172,1],[172,2],[172,3],[172,1],[172,1],[172,1],[172,1],[172,1],[172,1],[255,1],[255,1],[255,1],[257,1],[257,1],[257,1],[291,1],[291,1],[291,1],[291,1],[55,1],[55,1],[307,1],[307,1],[237,1],[237,1],[311,5],[173,5],[313,1],[313,1],[313,1],[313,1],[313,1],[315,1],[315,1],[315,1],[185,1],[185,1],[185,1],[316,3],[319,3],[266,5],[320,1],[320,1],[320,1],[223,1],[223,1],[321,0],[321,1],[5,1],[5,1],[5,1],[9,0],[9,1],[322,1],[322,1],[10,0],[10,2],[18,0],[18,2],[22,0],[22,2],[26,0],[26,2],[27,0],[27,2],[30,0],[30,1],[323,1],[323,2],[33,1],[33,1],[34,0],[34,2],[35,0],[35,1],[37,0],[37,2],[40,1],[40,2],[324,1],[324,1],[42,0],[42,1],[50,0],[50,1],[51,0],[51,1],[54,0],[54,1],[56,0],[56,1],[58,0],[58,1],[59,0],[59,1],[60,0],[60,1],[61,0],[61,1],[65,1],[65,2],[71,1],[71,2],[74,1],[74,2],[88,0],[88,2],[90,0],[90,2],[91,1],[91,2],[92,0],[92,2],[95,1],[95,2],[97,0],[97,4],[99,0],[99,2],[101,0],[101,1],[102,0],[102,1],[103,1],[103,1],[104,0],[104,1],[106,1],[106,1],[106,1],[107,0],[107,1],[111,0],[111,1],[117,0],[117,1],[119,0],[119,2],[124,0],[124,1],[129,0],[129,1],[133,0],[133,1],[134,1],[134,1],[134,1],[136,0],[136,1],[137,0],[137,2],[140,0],[140,1],[141,0],[141,1],[142,0],[142,1],[144,0],[144,3],[146,0],[146,1],[148,0],[148,1],[149,0],[149,2],[152,0],[152,1],[153,0],[153,1],[155,0],[155,3],[157,0],[157,1],[162,0],[162,1],[167,0],[167,2],[168,0],[168,2],[169,1],[169,2],[170,0],[170,2],[175,0],[175,3],[177,0],[177,1],[178,0],[178,3],[180,0],[180,3],[181,0],[181,1],[183,0],[183,3],[184,0],[184,1],[189,0],[189,1],[191,0],[191,2],[194,0],[194,1],[198,0],[198,3],[201,0],[201,1],[204,0],[204,1],[206,0],[206,2],[208,1],[208,1],[210,0],[210,3],[213,0],[213,1],[215,0],[215,3],[217,0],[217,3],[339,1],[339,1],[339,1],[221,0],[221,1],[222,0],[222,1],[227,0],[227,3],[228,0],[228,1],[230,1],[230,2],[233,1],[233,2],[240,0],[240,2],[244,0],[244,2],[248,1],[248,1],[248,1],[248,1],[248,1],[248,1],[249,0],[249,1],[252,0],[252,2],[254,1],[254,1],[256,0],[256,2],[258,0],[258,2],[260,0],[260,2],[262,1],[262,1],[275,1],[275,1],[275,1],[275,1],[275,1],[278,0],[278,1],[281,0],[281,1],[282,1],[282,1],[284,0],[284,1],[286,0],[286,1],[287,0],[287,1]],performAction:function(e,t,i,n,o,s,r){var a,l,h,u,c=s.length-1;switch(o){case 1:if(s[c-1]=s[c-1]||{},on.base&&(s[c-1].base=on.base),on.base="",s[c-1].prefixes=on.prefixes,on.prefixes=null,on.pathOnly){if("path"===s[c-1].type||"termType"in s[c-1])return s[c-1];throw new Error("Received full SPARQL query in path only mode")}if("path"===s[c-1].type||"termType"in s[c-1])throw new Error("Received only path in full SPARQL mode");if("update"===s[c-1].type){const e={};for(const t of s[c-1].updates)if("insert"===t.updateType){const i={};for(const e of t.insert)if("bgp"===e.type||"graph"===e.type)for(const t of e.triples)"BlankNode"===t.subject.termType&&(i[t.subject.value]=!0),"BlankNode"===t.predicate.termType&&(i[t.predicate.value]=!0),"BlankNode"===t.object.termType&&(i[t.object.value]=!0);for(const t of Object.keys(i)){if(e[t])throw new Error("Detected reuse blank node across different INSERT DATA clauses");e[t]=!0}}}return s[c-1];case 2:this.$={...s[c-1],...s[c],type:"query"};break;case 4:on.base=yi(s[c]);break;case 5:on.prefixes||(on.prefixes={}),s[c-1]=s[c-1].substr(0,s[c-1].length-1),s[c]=yi(s[c]),on.prefixes[s[c-1]]=s[c];break;case 6:this.$={...s[c-3],...wi(s[c-2]),...s[c-1],...s[c]};break;case 7:if(!on.skipValidation&&(Xi(s[c-3].variables.map((e=>ji(e.expression)))).some((e=>"count"===e.aggregation&&!(e.expression instanceof ri)))||s[c].group))for(const e of s[c-3].variables)if("Variable"===e.termType){if(!s[c].group||!s[c].group.map((e=>$i(e))).includes($i(e)))throw Error("Projection of ungrouped variable (?"+$i(e)+")")}else if(0===ji(e.expression).length){const t=zi(e.expression);for(const e of t)if(!s[c].group||!s[c].group.map||!s[c].group.map((e=>$i(e))).includes($i(e)))throw Error("Use of ungrouped variable in projection of operation (?"+$i(e)+")")}const e=s[c-1].where.filter((e=>"query"===e.type));if(e.length>0){const t=s[c-3].variables.filter((e=>e.variable&&e.variable.value)).map((e=>e.variable.value)),i=Xi(e.map((e=>e.variables))).map((e=>e.value||e.variable.value));for(const e of t)if(i.indexOf(e)>=0)throw Error("Target id of 'AS' (?"+e+") already used in subquery")}this.$=Ii(s[c-3],wi(s[c-2]),s[c-1],s[c]);break;case 8:this.$=Ii({queryType:"CONSTRUCT",template:s[c-3]},wi(s[c-2]),s[c-1],s[c]);break;case 9:this.$=Ii({queryType:"CONSTRUCT",template:s[c-2]=s[c-2]?s[c-2].triples:[]},wi(s[c-5]),{where:[{type:"bgp",triples:vi([],s[c-2])}]},s[c]);break;case 10:this.$=Ii({queryType:"DESCRIBE",variables:"*"===s[c-3]?[new ri]:s[c-3]},wi(s[c-2]),s[c-1],s[c]);break;case 11:this.$=Ii({queryType:"ASK"},wi(s[c-2]),s[c-1],s[c]);break;case 12:this.$=Ii(s[c-1],{variables:[new ri]});break;case 13:const t=function(e){const t=e.slice().sort(),i=[];for(let e=0;e<t.length-1;e++)t[e+1]==t[e]&&i.push(t[e]);return i}(s[c].map((e=>e.value||e.variable.value)));if(t.length>0)throw Error("Two or more of the resulting columns have the same name (?"+t[0]+")");this.$=Ii(s[c-1],{variables:s[c]});break;case 14:this.$=Ii({queryType:"SELECT"},s[c]&&(s[c-1]=bi(s[c]),s[c]={},s[c][s[c-1]]=!0,s[c]));break;case 16:case 27:this.$=Si(s[c-3],{variable:s[c-1]});break;case 17:case 18:this.$=Ii(s[c-3],s[c-2],s[c-1],s[c],{type:"query"});break;case 19:case 58:this.$={iri:s[c],named:!!s[c-1]};break;case 20:this.$={where:s[c].patterns};break;case 21:this.$=Ii(s[c-1],s[c]);break;case 22:this.$=Ii(s[c-2],s[c-1],s[c]);break;case 23:this.$={group:s[c]};break;case 24:case 25:case 28:case 31:case 33:case 34:this.$=Si(s[c]);break;case 26:this.$=Si(s[c-1]);break;case 29:this.$={having:s[c]};break;case 30:this.$={order:s[c]};break;case 32:this.$=Si(s[c],{descending:!0});break;case 35:this.$={limit:Li(s[c])};break;case 36:this.$={offset:Li(s[c])};break;case 37:this.$={limit:Li(s[c-2]),offset:Li(s[c])};break;case 38:this.$={limit:Li(s[c]),offset:Li(s[c-2])};break;case 39:case 43:this.$={type:"values",values:s[c]};break;case 40:case 84:this.$=s[c-1].map((e=>({[s[c-3]]:e})));break;case 41:case 85:this.$=s[c-1].map((()=>({})));break;case 42:case 86:var d=s[c-4].length;s[c-4]=s[c-4].map(Ai),this.$=s[c-1].map((function(e){if(e.length!==d)throw Error("Inconsistent VALUES length");for(var t={},i=0;i<d;i++)t["?"+s[c-4][i].value]=e[i];return t}));break;case 44:case 65:case 100:case 126:case 175:this.$=s[c-1];break;case 45:this.$={type:"update",updates:Ci(s[c-2],s[c-1])};break;case 46:this.$=Ii({type:"load",silent:!!s[c-2],source:s[c-1]},s[c]&&{destination:s[c]});break;case 47:this.$={type:bi(s[c-2]),silent:!!s[c-1],graph:s[c]};break;case 48:this.$={type:bi(s[c-4]),silent:!!s[c-3],source:s[c-2],destination:s[c]};break;case 49:this.$={type:"create",silent:!!s[c-2],graph:{type:"graph",name:s[c]}};break;case 50:this.$={updateType:"insert",insert:en(s[c])};break;case 51:this.$={updateType:"delete",delete:tn(en(s[c]))};break;case 52:this.$={updateType:"deletewhere",delete:tn(s[c])};break;case 53:this.$={updateType:"insertdelete",...s[c-4],...s[c-3],...wi(s[c-2],"using"),where:s[c].patterns};break;case 54:case 57:case 62:case 167:case 191:case 236:this.$=s[c];break;case 55:this.$={delete:tn(s[c-1]),insert:s[c]||[]};break;case 56:this.$={delete:[],insert:s[c]};break;case 59:this.$={graph:s[c]};break;case 60:this.$={type:"graph",default:!0};break;case 61:case 63:this.$={type:"graph",name:s[c]};break;case 64:this.$={[bi(s[c])]:!0};break;case 66:this.$=s[c-1]?Ni(s[c],[s[c-1]]):Ni(s[c]);break;case 67:var p=Ii(s[c-3]||{triples:[]},{type:"graph",name:s[c-5]});this.$=s[c]?[p,s[c]]:[p];break;case 68:case 73:this.$={type:"bgp",triples:Ni(s[c-2],[s[c-1]])};break;case 69:this.$={type:"group",patterns:[s[c-1]]};break;case 70:for(const e of s[c-1].filter((e=>"bind"===e.type))){const t=s[c-1].indexOf(e),i=new Set;for(const e of s[c-1].slice(0,t))"group"!==e.type&&"bgp"!==e.type||Ki(e).forEach((e=>i.add(e)));if(i.has(e.variable.value))throw Error("Variable used to bind is already bound (?"+e.variable.value+")")}this.$={type:"group",patterns:s[c-1]};break;case 71:this.$=s[c-1]?Ni([s[c-1]],s[c]):Ni(s[c]);break;case 72:this.$=s[c]?[s[c-2],s[c]]:s[c-2];break;case 75:this.$=Ii(s[c],{type:"optional"});break;case 76:this.$=Ii(s[c],{type:"minus"});break;case 77:this.$=Ii(s[c],{type:"graph",name:s[c-1]});break;case 78:this.$=Ii(s[c],{type:"service",name:s[c-1],silent:!!s[c-2]});break;case 79:this.$={type:"filter",expression:s[c]};break;case 80:this.$={type:"bind",variable:s[c-1],expression:s[c-3]};break;case 89:this.$=Ji(s[c]);break;case 90:this.$=void 0;break;case 91:this.$=s[c-1].length?{type:"union",patterns:Ni(s[c-1].map(Di),[Di(s[c])])}:s[c];break;case 95:this.$={...s[c],function:s[c-1]};break;case 96:this.$={type:"functionCall",args:[]};break;case 97:this.$={type:"functionCall",args:Ci(s[c-2],s[c-1]),distinct:!!s[c-3]};break;case 98:case 115:case 128:case 247:case 249:case 251:case 253:case 255:case 263:case 267:case 297:case 299:case 303:case 307:case 328:case 341:case 349:case 355:case 361:case 367:case 369:case 373:case 375:case 379:case 381:case 385:case 391:case 395:case 401:case 405:case 409:case 411:case 420:case 428:case 430:case 440:case 444:case 446:case 448:this.$=[];break;case 99:this.$=Ci(s[c-2],s[c-1]);break;case 101:this.$=Ni(s[c-2],[s[c-1]]);break;case 102:case 112:this.$=Zi(s[c].map((e=>Ii(Mi(s[c-1]),e))));break;case 103:this.$=Zi(vi(s[c].map((e=>Ii(Mi(s[c-1].entity),e))),s[c-1].triples));break;case 105:this.$=Ni([s[c-1]],s[c]);break;case 106:this.$=Ni(s[c]);break;case 107:this.$=qi(s[c-1],s[c]);break;case 109:case 237:this.$=on.factory.namedNode(li);break;case 110:case 118:this.$=Ci(s[c-1],s[c]);break;case 111:this.$=s[c]?{annotation:s[c],object:s[c-1]}:s[c-1];break;case 113:this.$=s[c]?Zi(vi(s[c].map((e=>Ii(Mi(s[c-1].entity),e))),s[c-1].triples)):s[c-1].triples;break;case 114:this.$=qi(...s[c-1],s[c]);break;case 116:this.$=qi(...s[c]);break;case 117:case 159:case 163:this.$=[s[c-1],s[c]];break;case 119:this.$=s[c]?{object:s[c-1],annotation:s[c]}:s[c-1];break;case 120:this.$=s[c-1].length?Oi("|",Ci(s[c-1],s[c])):s[c];break;case 121:this.$=s[c-1].length?Oi("/",Ci(s[c-1],s[c])):s[c];break;case 122:this.$=s[c]?Oi(s[c],[s[c-1]]):s[c-1];break;case 123:this.$=s[c-1]?Oi(s[c-1],[s[c]]):s[c];break;case 125:case 131:this.$=Oi(s[c-1],[s[c]]);break;case 129:this.$=Oi("|",Ci(s[c-2],s[c-1]));break;case 132:case 134:this.$=function(e){var t=Pi(),i=t,n=[],o=[];e.forEach((function(e){n.push(e.entity),vi(o,e.triples)}));for(var s=0,r=0,a=n.length,l=Array(2*a);s<a;)l[r++]=Mi(i,on.factory.namedNode(hi),n[s]),l[r++]=Mi(i,on.factory.namedNode(ui),i=++s<a?Pi():on.factory.namedNode(ci));return{entity:t,triples:vi(l,o)}}(s[c-1]);break;case 133:case 135:this.$=(h=s[c-1],{entity:u=Pi(),triples:h.map((function(e){return Ii(Mi(u),e)}))});break;case 140:this.$={entity:s[c],triples:[]};break;case 145:this.$=Ai(s[c]);break;case 149:this.$=on.factory.namedNode(ci);break;case 151:case 153:case 158:case 162:this.$=Ri(s[c-1],s[c]);break;case 152:this.$=["||",s[c]];break;case 154:this.$=["&&",s[c]];break;case 156:this.$=ki(s[c-1],[s[c-2],s[c]]);break;case 157:this.$=ki(s[c-2]?"notin":"in",[s[c-3],s[c]]);break;case 160:this.$=["+",Ri(s[c-1],s[c])];break;case 161:var g=xi(s[c-1].value.replace("-",""),s[c-1].datatype);this.$=["-",Ri(g,s[c])];break;case 164:this.$=ki("UPLUS",[s[c]]);break;case 165:this.$=ki(s[c-1],[s[c]]);break;case 166:this.$=ki("UMINUS",[s[c]]);break;case 177:this.$=ki(bi(s[c-1]));break;case 178:this.$=ki(bi(s[c-3]),[s[c-1]]);break;case 179:this.$=Ji(ki(bi(s[c-3]),[s[c-1]]));break;case 180:this.$=ki(bi(s[c-5]),[s[c-3],s[c-1]]);break;case 181:this.$=ki(bi(s[c-7]),[s[c-5],s[c-3],s[c-1]]);break;case 182:this.$=Ji(ki(bi(s[c-7]),[s[c-5],s[c-3],s[c-1]]));break;case 183:this.$=ki(bi(s[c-1]),s[c]);break;case 184:this.$=ki("bound",[Ai(s[c-1])]);break;case 185:this.$=ki(s[c-1],[]);break;case 186:this.$=ki(s[c-3],[s[c-1]]);break;case 187:this.$=ki(s[c-2]?"notexists":"exists",[Di(s[c])]);break;case 188:case 189:this.$=Si(s[c-1],{type:"aggregate",aggregation:bi(s[c-4]),distinct:!!s[c-2]});break;case 190:this.$=Si(s[c-2],{type:"aggregate",aggregation:bi(s[c-5]),distinct:!!s[c-3],separator:"string"==typeof s[c-1]?s[c-1]:" "});break;case 192:this.$=xi(s[c]);break;case 193:this.$=(a=s[c-1],l=bi(s[c].substr(1)),on.factory.literal(a,l));break;case 194:this.$=xi(s[c-2],s[c]);break;case 195:case 204:this.$=xi(s[c],pi);break;case 196:case 205:this.$=xi(s[c],gi);break;case 197:case 206:this.$=xi(bi(s[c]),Ei);break;case 200:this.$=xi(s[c].toLowerCase(),Ti);break;case 201:this.$=xi(s[c].substr(1),pi);break;case 202:this.$=xi(s[c].substr(1),gi);break;case 203:this.$=xi(s[c].substr(1).toLowerCase(),Ei);break;case 207:case 208:this.$=Wi(s[c],1);break;case 209:case 210:this.$=Wi(s[c],3);break;case 211:this.$=on.factory.namedNode(yi(s[c]));break;case 213:var E=s[c].indexOf(":"),T=s[c].substr(0,E),_=on.prefixes[T];if(!_)throw new Error("Unknown prefix: "+T);var f=yi(_+s[c].substr(E+1));this.$=on.factory.namedNode(f);break;case 214:if(s[c]=s[c].substr(0,s[c].length-1),!(s[c]in on.prefixes))throw new Error("Unknown prefix: "+s[c]);f=yi(on.prefixes[s[c]]),this.$=on.factory.namedNode(f);break;case 215:this.$=Pi(s[c].replace(/^(_:)/,""));break;case 216:this.$=Pi();break;case 217:case 218:case 232:this.$=Ji(Fi(s[c-3],s[c-2],s[c-1]));break;case 230:case 231:this.$=Ji(s[c-1]);break;case 248:case 250:case 252:case 254:case 256:case 260:case 264:case 268:case 270:case 292:case 294:case 296:case 298:case 300:case 302:case 304:case 306:case 329:case 342:case 356:case 368:case 370:case 372:case 374:case 392:case 402:case 425:case 427:case 429:case 431:case 441:case 445:case 447:case 449:s[c-1].push(s[c]);break;case 259:case 269:case 291:case 293:case 295:case 301:case 305:case 371:case 424:case 426:this.$=[s[c]];break;case 308:s[c-3].push(s[c-2]);break;case 350:case 362:case 376:case 380:case 382:case 386:case 396:case 406:case 410:case 412:case 421:s[c-2].push(s[c-1])}},table:[e(t,n,{3:1,4:2,10:3}),{1:[3]},e(o,[2,307],{5:4,7:5,321:6,214:7,8:8,96:9,215:10,17:11,21:12,97:16,38:17,6:[2,238],13:s,16:s,45:s,197:s,224:s,229:s,308:s,24:[1,13],32:[1,14],36:[1,15],41:r}),e([6,13,16,24,32,36,41,45,100,110,113,115,116,123,126,131,197,224,229,308,329,330,331,332,333],[2,3],{322:19,11:20,14:21,12:[1,22],15:[1,23]}),{6:[1,24]},{6:[2,240]},{6:[2,241]},{6:[2,242]},{6:[2,243],9:25,84:26,85:a},{6:[2,239]},e(l,[2,411],{216:28,217:29}),e(h,[2,249],{18:30}),e(h,[2,251],{22:31}),e(u,[2,255],{25:32,27:33,29:[1,34]}),{13:c,16:d,33:35,39:[1,37],44:39,55:40,87:p,139:38,307:43,308:g,323:36},e(h,[2,267],{37:46}),e(E,[2,326],{98:47,103:49,106:50,117:55,130:61,100:[1,48],110:[1,51],113:[1,52],115:[1,53],116:[1,54],131:[1,62],329:[1,56],330:[1,57],331:[1,58],332:[1,59],333:[1,60]}),{39:[1,63],40:64,43:65,44:66,45:T,87:p},e(_,[2,273],{42:68,324:69,325:[1,70],326:[1,71]}),e(t,[2,248]),e(t,[2,245]),e(t,[2,246]),{13:[1,72]},{16:[1,73]},{1:[2,1]},{6:[2,2]},{6:[2,244]},{45:[1,77],85:[1,78],86:74,87:[1,75],89:[1,76]},e([6,13,16,45,48,82,87,89,231,294,295,296,297,298,299,300,301,302,303,304,305,306,308,309,310,312],[2,120],{337:[1,79]}),e(f,[2,418],{218:80,222:81,229:[1,82]}),{19:83,28:m,29:b,52:84,53:C,56:85},{19:88,28:m,29:b,52:89,53:C,56:85},e(h,[2,253],{26:90}),{28:[1,91],52:92,53:C},e(v,[2,385],{181:93,182:94,183:95,31:[2,383]}),e(I,[2,263],{34:96}),e(I,[2,261],{44:39,55:40,307:43,139:97,13:c,16:d,87:p,308:g}),e(I,[2,262]),e(N,[2,259]),e(y,[2,143]),e(y,[2,144]),e([6,13,16,28,29,31,39,45,47,48,53,63,70,73,76,78,81,82,83,85,87,89,112,159,160,161,163,164,193,197,224,229,231,232,242,246,250,263,265,268,269,270,271,272,273,274,276,277,279,280,283,285,290,294,295,296,297,298,299,300,301,302,303,304,305,306,308,309,310,312,314,317,318,335,338,341,342,343,344,345,346,347,348,349,350,351],[2,145]),e(A,[2,211]),e(A,[2,212]),e(A,[2,213]),e(A,[2,214]),{19:98,28:m,29:b,52:99,53:C,56:85},{6:[2,309],99:100,193:[1,101]},e(k,[2,311],{101:102,328:[1,103]}),e(S,[2,317],{104:104,328:[1,105]}),e(O,[2,322],{107:106,328:[1,107]}),{111:108,112:[2,324],328:[1,109]},{29:R,114:110},{29:R,114:112},{29:R,114:113},{118:114,123:[1,115],125:116,126:w},e(L,[2,315]),e(L,[2,316]),e(D,[2,319]),e(D,[2,320]),e(D,[2,321]),e(E,[2,327]),{13:c,16:d,55:118,307:43,308:g},e(h,[2,12]),e(h,[2,13],{44:66,43:119,45:T,87:p}),e(x,[2,269]),e(x,[2,15]),{13:c,16:d,44:136,45:F,46:120,55:133,67:132,68:134,77:131,82:M,87:p,172:135,224:P,238:121,239:122,243:123,247:124,251:125,255:154,257:155,259:126,263:B,264:130,265:U,266:137,267:139,268:V,269:H,270:G,271:W,273:q,274:$,275:146,276:j,277:z,278:149,279:X,280:Y,283:K,285:J,291:150,294:Q,295:Z,296:ee,297:te,298:ie,299:ne,300:oe,301:se,302:re,303:ae,304:le,305:he,306:ue,307:43,308:g,312:ce,346:de,347:pe,348:ge,349:Ee,350:Te,351:_e},e(_,[2,14]),e(_,[2,274]),e(_,[2,271]),e(_,[2,272]),e(t,[2,4]),{13:[1,177]},e(fe,[2,39]),{29:[1,178]},{29:[1,179]},{87:[1,181],91:180},{45:[1,187],87:[1,185],89:[1,186],93:182,165:183,166:184},e(l,[2,410]),e([6,13,16,45,48,82,87,89,231,294,295,296,297,298,299,300,301,302,303,304,305,306,308,309,310,312,337],[2,121],{338:[1,188]}),{13:c,16:d,45:[1,193],55:194,197:me,219:189,220:190,223:191,224:[1,192],307:43,308:g},e(f,[2,419]),e(be,Ce,{20:196,59:197,69:198,70:ve}),e(h,[2,250]),{29:Ie,57:200},e(k,[2,279],{54:202,327:[1,203]}),{29:[2,282]},e(Ne,ye,{23:204,58:205,62:206,63:Ae}),e(h,[2,252]),{19:208,28:m,29:b,52:209,53:C,56:85},{29:[1,210]},e(u,[2,256]),{31:[1,211]},{31:[2,384]},{13:c,16:d,44:215,45:ke,55:220,82:M,87:p,89:Se,145:212,172:221,185:213,187:214,231:Oe,236:216,237:222,255:154,257:155,291:150,294:Q,295:Z,296:ee,297:te,298:ie,299:ne,300:oe,301:se,302:re,303:ae,304:le,305:he,306:ue,307:43,308:g,309:Re,310:we,311:217,312:Le},e(De,[2,265],{56:85,35:227,52:228,19:229,28:m,29:b,53:C}),e(N,[2,260]),e(Ne,ye,{58:205,62:206,23:230,63:Ae}),e(h,[2,268]),{6:[2,45]},e(t,n,{10:3,4:231}),{13:c,16:d,55:232,307:43,308:g},e(k,[2,312]),{105:233,112:xe,122:234,132:[1,237],134:235,327:[1,238],334:[1,239]},e(S,[2,318]),e(k,Fe,{108:240,133:242,112:Me,132:Pe}),e(O,[2,323]),{112:[1,244]},{112:[2,325]},e(Be,[2,50]),e(v,Ue,{135:245,136:246,143:247,144:248,31:Ve,112:Ve}),e(Be,[2,51]),e(Be,[2,52]),e(He,[2,328],{119:249}),{29:R,114:250},e(He,[2,56]),{29:R,114:251},e(E,[2,59]),e(x,[2,270]),{47:[1,252]},e(Ge,[2,150]),e(We,[2,428],{240:253}),e(qe,[2,430],{244:254}),e(qe,[2,155],{248:255,249:256,250:[2,438],290:[1,257],341:[1,258],342:[1,259],343:[1,260],344:[1,261],345:[1,262],346:[1,263]}),e($e,[2,440],{252:264}),e(je,[2,448],{260:265}),{13:c,16:d,44:136,45:F,55:133,67:132,68:134,77:131,82:M,87:p,172:135,255:154,257:155,264:266,266:137,267:139,268:V,269:H,270:G,271:W,273:q,274:$,275:146,276:j,277:z,278:149,279:X,280:Y,283:K,285:J,291:150,294:Q,295:Z,296:ee,297:te,298:ie,299:ne,300:oe,301:se,302:re,303:ae,304:le,305:he,306:ue,307:43,308:g,312:ce,346:de,347:pe,348:ge,349:Ee,350:Te,351:_e},{13:c,16:d,44:136,45:F,55:133,67:132,68:134,77:131,82:M,87:p,172:135,255:154,257:155,264:267,266:137,267:139,268:V,269:H,270:G,271:W,273:q,274:$,275:146,276:j,277:z,278:149,279:X,280:Y,283:K,285:J,291:150,294:Q,295:Z,296:ee,297:te,298:ie,299:ne,300:oe,301:se,302:re,303:ae,304:le,305:he,306:ue,307:43,308:g,312:ce,346:de,347:pe,348:ge,349:Ee,350:Te,351:_e},{13:c,16:d,44:136,45:F,55:133,67:132,68:134,77:131,82:M,87:p,172:135,255:154,257:155,264:268,266:137,267:139,268:V,269:H,270:G,271:W,273:q,274:$,275:146,276:j,277:z,278:149,279:X,280:Y,283:K,285:J,291:150,294:Q,295:Z,296:ee,297:te,298:ie,299:ne,300:oe,301:se,302:re,303:ae,304:le,305:he,306:ue,307:43,308:g,312:ce,346:de,347:pe,348:ge,349:Ee,350:Te,351:_e},e(je,[2,167]),e(je,[2,168]),e(je,[2,169]),e(je,[2,170],{176:269,45:ze,89:Xe}),e(je,[2,171]),e(je,[2,172]),e(je,[2,173]),e(je,[2,174]),{13:c,16:d,44:136,45:F,46:272,55:133,67:132,68:134,77:131,82:M,87:p,172:135,224:P,238:121,239:122,243:123,247:124,251:125,255:154,257:155,259:126,263:B,264:130,265:U,266:137,267:139,268:V,269:H,270:G,271:W,273:q,274:$,275:146,276:j,277:z,278:149,279:X,280:Y,283:K,285:J,291:150,294:Q,295:Z,296:ee,297:te,298:ie,299:ne,300:oe,301:se,302:re,303:ae,304:le,305:he,306:ue,307:43,308:g,312:ce,346:de,347:pe,348:ge,349:Ee,350:Te,351:_e},e(Ye,[2,176]),{89:[1,273]},{45:[1,274]},{45:[1,275]},{45:[1,276]},{45:[1,277]},{45:[1,278]},{45:Ke,89:Je,179:279},{45:[1,282]},{45:[1,284],89:[1,283]},{279:[1,285]},e(Qe,[2,192],{292:[1,286],293:[1,287]}),e(Qe,[2,195]),e(Qe,[2,196]),e(Qe,[2,197]),e(Qe,[2,198]),e(Qe,[2,199]),e(Qe,[2,200]),{13:c,16:d,44:39,55:40,82:M,87:p,139:289,172:291,255:154,257:155,266:290,291:150,294:Q,295:Z,296:ee,297:te,298:ie,299:ne,300:oe,301:se,302:re,303:ae,304:le,305:he,306:ue,307:43,308:g,312:ce,320:288},{45:[1,292]},{45:[1,293]},{45:[1,294]},e(Ze,[2,452]),e(Ze,[2,453]),e(Ze,[2,454]),e(Ze,[2,455]),e(Ze,[2,456]),{279:[2,458]},e(et,[2,207]),e(et,[2,208]),e(et,[2,209]),e(et,[2,210]),e(Qe,[2,201]),e(Qe,[2,202]),e(Qe,[2,203]),e(Qe,[2,204]),e(Qe,[2,205]),e(Qe,[2,206]),e(t,[2,5]),e(tt,[2,297],{88:295}),e(it,[2,299],{90:296}),{48:[1,297],87:[1,298]},e(nt,[2,301]),e(fe,[2,43]),e(fe,[2,82]),e(fe,[2,83]),{29:[1,299]},{29:[1,300]},{87:[1,302],169:301},e(l,[2,412]),e(ot,[2,123]),e(ot,[2,416],{221:303,339:304,39:[1,306],263:[1,307],340:[1,305]}),e(st,[2,124]),{13:c,16:d,45:[1,311],55:194,89:[1,310],197:me,223:312,225:308,226:309,229:rt,307:43,308:g},e(l,s,{215:10,214:314}),e(st,[2,236]),e(st,[2,237]),e(at,[2,6]),e(lt,[2,287],{60:315,72:316,73:[1,317]}),e(be,[2,286]),{13:c,16:d,45:F,55:323,67:321,68:322,71:318,77:320,79:319,267:139,268:V,269:H,270:G,271:W,273:q,274:$,275:146,276:j,277:z,278:149,279:X,280:Y,283:K,285:J,307:43,308:g,346:de,347:pe,348:ge,349:Ee,350:Te,351:_e},e([6,31,63,70,73,81,83,85],[2,20]),e(v,ht,{38:17,49:324,147:325,17:326,21:327,148:328,154:329,155:330,29:ut,31:ut,85:ut,112:ut,159:ut,160:ut,161:ut,163:ut,164:ut,41:r}),{13:c,16:d,55:331,307:43,308:g},e(k,[2,280]),e(at,[2,7]),e(be,Ce,{59:197,69:198,20:332,70:ve}),e(Ne,[2,284]),{64:[1,333]},e(Ne,ye,{58:205,62:206,23:334,63:Ae}),e(h,[2,254]),e(v,Ue,{144:248,30:335,143:336,31:[2,257]}),e(h,[2,100]),{31:[2,387],184:337,335:[1,338]},{13:c,16:d,44:39,55:40,87:p,139:342,186:339,190:340,195:341,197:ct,307:43,308:g},e(dt,[2,389],{44:39,55:40,307:43,190:340,195:341,139:342,188:344,189:345,186:346,13:c,16:d,87:p,197:ct,308:g}),e(pt,[2,227]),e(pt,[2,228]),e(pt,[2,229]),{13:c,16:d,44:215,45:ke,55:220,82:M,87:p,89:Se,172:221,185:351,187:350,200:348,230:347,231:Oe,234:349,236:216,237:222,255:154,257:155,291:150,294:Q,295:Z,296:ee,297:te,298:ie,299:ne,300:oe,301:se,302:re,303:ae,304:le,305:he,306:ue,307:43,308:g,309:Re,310:we,311:217,312:Le},{13:c,16:d,44:39,55:40,87:p,139:342,186:352,190:340,195:341,197:ct,307:43,308:g},e(pt,[2,146]),e(pt,[2,147]),e(pt,[2,148]),e(pt,[2,149]),{13:c,16:d,44:354,55:355,82:M,87:p,172:357,237:356,255:154,257:155,291:150,294:Q,295:Z,296:ee,297:te,298:ie,299:ne,300:oe,301:se,302:re,303:ae,304:le,305:he,306:ue,307:43,308:g,309:Re,310:we,311:358,312:Le,313:353},e(gt,[2,215]),e(gt,[2,216]),e(Ne,ye,{58:205,62:206,23:359,63:Ae}),e(I,[2,264]),e(De,[2,266]),e(at,[2,11]),e(o,[2,308],{6:[2,310]}),e(Be,[2,313],{102:360,120:361,121:[1,362]}),e(Be,[2,47]),e(Be,[2,63]),e(Be,[2,64]),{13:c,16:d,55:363,307:43,308:g},e(Be,[2,336]),e(Be,[2,337]),e(Be,[2,338]),{109:[1,364]},e(Et,[2,60]),{13:c,16:d,55:365,307:43,308:g},e(k,[2,335]),{13:c,16:d,55:366,307:43,308:g},{31:[1,367]},e(Tt,[2,341],{137:368}),e(Tt,[2,340]),{13:c,16:d,44:215,45:ke,55:220,82:M,87:p,89:Se,145:369,172:221,185:213,187:214,231:Oe,236:216,237:222,255:154,257:155,291:150,294:Q,295:Z,296:ee,297:te,298:ie,299:ne,300:oe,301:se,302:re,303:ae,304:le,305:he,306:ue,307:43,308:g,309:Re,310:we,311:217,312:Le},{28:[1,370],127:371,128:[1,372]},e(He,[2,330],{124:373,125:374,126:w}),e(He,[2,57]),{44:375,87:p},e(Ge,[2,151],{241:376,242:[1,377]}),e(We,[2,153],{245:378,246:[1,379]}),{13:c,16:d,44:136,45:F,55:133,67:132,68:134,77:131,82:M,87:p,172:135,224:P,247:380,251:125,255:154,257:155,259:126,263:B,264:130,265:U,266:137,267:139,268:V,269:H,270:G,271:W,273:q,274:$,275:146,276:j,277:z,278:149,279:X,280:Y,283:K,285:J,291:150,294:Q,295:Z,296:ee,297:te,298:ie,299:ne,300:oe,301:se,302:re,303:ae,304:le,305:he,306:ue,307:43,308:g,312:ce,346:de,347:pe,348:ge,349:Ee,350:Te,351:_e},{250:[1,381]},e(_t,[2,432]),e(_t,[2,433]),e(_t,[2,434]),e(_t,[2,435]),e(_t,[2,436]),e(_t,[2,437]),{250:[2,439]},e([47,48,193,242,246,250,272,290,341,342,343,344,345,346],[2,158],{253:382,254:383,255:384,257:385,263:[1,386],265:[1,387],297:te,298:ie,299:ne,300:oe,301:se,302:re}),e($e,[2,162],{261:388,262:389,39:ft,338:mt}),e(je,[2,164]),e(je,[2,165]),e(je,[2,166]),e(Ye,[2,95]),e(Ye,[2,96]),e(_t,[2,377],{177:392,325:[1,393]}),{48:[1,394]},e(Ye,[2,177]),{13:c,16:d,44:136,45:F,46:395,55:133,67:132,68:134,77:131,82:M,87:p,172:135,224:P,238:121,239:122,243:123,247:124,251:125,255:154,257:155,259:126,263:B,264:130,265:U,266:137,267:139,268:V,269:H,270:G,271:W,273:q,274:$,275:146,276:j,277:z,278:149,279:X,280:Y,283:K,285:J,291:150,294:Q,295:Z,296:ee,297:te,298:ie,299:ne,300:oe,301:se,302:re,303:ae,304:le,305:he,306:ue,307:43,308:g,312:ce,346:de,347:pe,348:ge,349:Ee,350:Te,351:_e},{13:c,16:d,44:136,45:F,46:396,55:133,67:132,68:134,77:131,82:M,87:p,172:135,224:P,238:121,239:122,243:123,247:124,251:125,255:154,257:155,259:126,263:B,264:130,265:U,266:137,267:139,268:V,269:H,270:G,271:W,273:q,274:$,275:146,276:j,277:z,278:149,279:X,280:Y,283:K,285:J,291:150,294:Q,295:Z,296:ee,297:te,298:ie,299:ne,300:oe,301:se,302:re,303:ae,304:le,305:he,306:ue,307:43,308:g,312:ce,346:de,347:pe,348:ge,349:Ee,350:Te,351:_e},{13:c,16:d,44:136,45:F,46:397,55:133,67:132,68:134,77:131,82:M,87:p,172:135,224:P,238:121,239:122,243:123,247:124,251:125,255:154,257:155,259:126,263:B,264:130,265:U,266:137,267:139,268:V,269:H,270:G,271:W,273:q,274:$,275:146,276:j,277:z,278:149,279:X,280:Y,283:K,285:J,291:150,294:Q,295:Z,296:ee,297:te,298:ie,299:ne,300:oe,301:se,302:re,303:ae,304:le,305:he,306:ue,307:43,308:g,312:ce,346:de,347:pe,348:ge,349:Ee,350:Te,351:_e},{13:c,16:d,44:136,45:F,46:398,55:133,67:132,68:134,77:131,82:M,87:p,172:135,224:P,238:121,239:122,243:123,247:124,251:125,255:154,257:155,259:126,263:B,264:130,265:U,266:137,267:139,268:V,269:H,270:G,271:W,273:q,274:$,275:146,276:j,277:z,278:149,279:X,280:Y,283:K,285:J,291:150,294:Q,295:Z,296:ee,297:te,298:ie,299:ne,300:oe,301:se,302:re,303:ae,304:le,305:he,306:ue,307:43,308:g,312:ce,346:de,347:pe,348:ge,349:Ee,350:Te,351:_e},{13:c,16:d,44:136,45:F,46:399,55:133,67:132,68:134,77:131,82:M,87:p,172:135,224:P,238:121,239:122,243:123,247:124,251:125,255:154,257:155,259:126,263:B,264:130,265:U,266:137,267:139,268:V,269:H,270:G,271:W,273:q,274:$,275:146,276:j,277:z,278:149,279:X,280:Y,283:K,285:J,291:150,294:Q,295:Z,296:ee,297:te,298:ie,299:ne,300:oe,301:se,302:re,303:ae,304:le,305:he,306:ue,307:43,308:g,312:ce,346:de,347:pe,348:ge,349:Ee,350:Te,351:_e},e(Ye,[2,183]),e(Ye,[2,98]),e(_t,[2,381],{180:400}),{87:[1,401]},e(Ye,[2,185]),{13:c,16:d,44:136,45:F,46:402,55:133,67:132,68:134,77:131,82:M,87:p,172:135,224:P,238:121,239:122,243:123,247:124,251:125,255:154,257:155,259:126,263:B,264:130,265:U,266:137,267:139,268:V,269:H,270:G,271:W,273:q,274:$,275:146,276:j,277:z,278:149,279:X,280:Y,283:K,285:J,291:150,294:Q,295:Z,296:ee,297:te,298:ie,299:ne,300:oe,301:se,302:re,303:ae,304:le,305:he,306:ue,307:43,308:g,312:ce,346:de,347:pe,348:ge,349:Ee,350:Te,351:_e},{29:Ie,57:403},e(Qe,[2,193]),{13:c,16:d,55:404,307:43,308:g},{13:c,16:d,44:39,55:40,87:p,139:342,195:405,197:ct,307:43,308:g},e(bt,[2,233]),e(bt,[2,234]),e(bt,[2,235]),e(Ct,[2,459],{281:406,325:[1,407]}),e(_t,[2,463],{284:408,325:[1,409]}),e(_t,[2,465],{286:410,325:[1,411]}),{13:c,16:d,31:[1,412],55:414,82:M,171:413,172:415,173:416,174:vt,255:154,257:155,291:150,294:Q,295:Z,296:ee,297:te,298:ie,299:ne,300:oe,301:se,302:re,303:ae,304:le,305:he,306:ue,307:43,308:g,312:It},{31:[1,419],89:[1,420]},{29:[1,421]},e(nt,[2,302]),e(tt,[2,367],{167:422}),e(it,[2,369],{168:423}),{48:[1,424],87:[1,425]},e(nt,[2,371]),e(ot,[2,122]),e(ot,[2,417]),e(ot,[2,413]),e(ot,[2,414]),e(ot,[2,415]),e(st,[2,125]),e(st,[2,127]),e(st,[2,128]),e(Nt,[2,420],{227:426}),e(st,[2,130]),{13:c,16:d,55:194,197:me,223:427,307:43,308:g},{48:[1,428]},e(yt,[2,289],{61:429,80:430,81:[1,431],83:[1,432]}),e(lt,[2,288]),{64:[1,433]},e(be,[2,29],{307:43,267:139,275:146,278:149,77:320,67:321,68:322,55:323,79:434,13:c,16:d,45:F,268:V,269:H,270:G,271:W,273:q,274:$,276:j,277:z,279:X,280:Y,283:K,285:J,308:g,346:de,347:pe,348:ge,349:Ee,350:Te,351:_e}),e(At,[2,293]),e(kt,[2,92]),e(kt,[2,93]),e(kt,[2,94]),{45:ze,89:Xe,176:269},{31:[1,435]},{31:[1,436]},{19:437,28:m,29:b,56:85},{19:438,28:m,29:b,56:85},e(St,[2,355],{149:439}),e(St,[2,354]),{13:c,16:d,44:215,45:Ot,55:220,82:M,87:p,89:Se,156:440,172:221,185:441,203:442,231:Rt,236:216,237:222,255:154,257:155,291:150,294:Q,295:Z,296:ee,297:te,298:ie,299:ne,300:oe,301:se,302:re,303:ae,304:le,305:he,306:ue,307:43,308:g,309:Re,310:we,311:217,312:Le},e(I,[2,19]),e(yt,[2,21]),{13:c,16:d,44:450,45:wt,55:323,65:445,66:446,67:447,68:448,87:p,267:139,268:V,269:H,270:G,271:W,273:q,274:$,275:146,276:j,277:z,278:149,279:X,280:Y,283:K,285:J,307:43,308:g,346:de,347:pe,348:ge,349:Ee,350:Te,351:_e},e(at,[2,8]),{31:[1,451]},{31:[2,258]},{31:[2,101]},e(v,[2,386],{31:[2,388]}),e(dt,[2,102]),e(Lt,[2,391],{191:452}),e(v,[2,395],{196:453,198:454}),e(v,[2,108]),e(v,[2,109]),e(dt,[2,103]),e(dt,[2,104]),e(dt,[2,390]),{13:c,16:d,44:215,45:ke,48:[1,455],55:220,82:M,87:p,89:Se,172:221,185:351,187:350,200:456,231:Oe,234:349,236:216,237:222,255:154,257:155,291:150,294:Q,295:Z,296:ee,297:te,298:ie,299:ne,300:oe,301:se,302:re,303:ae,304:le,305:he,306:ue,307:43,308:g,309:Re,310:we,311:217,312:Le},e(Dt,[2,424]),e(xt,[2,136]),e(xt,[2,137]),e(Ft,[2,140]),{232:[1,457]},{13:c,16:d,44:39,55:40,87:p,139:342,195:458,197:ct,307:43,308:g},e(bt,[2,219]),e(bt,[2,220]),e(bt,[2,221]),e(bt,[2,222]),e(bt,[2,223]),e(at,[2,10]),e(Be,[2,46]),e(Be,[2,314]),{112:xe,122:459},e(Be,[2,62]),e(k,Fe,{133:242,108:460,112:Me,132:Pe}),e(Et,[2,61]),e(Be,[2,49]),e([6,28,126,128,193],[2,65]),{31:[2,66],112:[1,462],138:461},e(Tt,[2,351],{146:463,335:[1,464]}),{29:Ie,57:465},e(He,[2,329]),e(k,[2,332],{129:466,327:[1,467]}),e(He,[2,55]),e(He,[2,331]),{48:[1,468]},e(We,[2,429]),{13:c,16:d,44:136,45:F,55:133,67:132,68:134,77:131,82:M,87:p,172:135,224:P,239:469,243:123,247:124,251:125,255:154,257:155,259:126,263:B,264:130,265:U,266:137,267:139,268:V,269:H,270:G,271:W,273:q,274:$,275:146,276:j,277:z,278:149,279:X,280:Y,283:K,285:J,291:150,294:Q,295:Z,296:ee,297:te,298:ie,299:ne,300:oe,301:se,302:re,303:ae,304:le,305:he,306:ue,307:43,308:g,312:ce,346:de,347:pe,348:ge,349:Ee,350:Te,351:_e},e(qe,[2,431]),{13:c,16:d,44:136,45:F,55:133,67:132,68:134,77:131,82:M,87:p,172:135,224:P,243:470,247:124,251:125,255:154,257:155,259:126,263:B,264:130,265:U,266:137,267:139,268:V,269:H,270:G,271:W,273:q,274:$,275:146,276:j,277:z,278:149,279:X,280:Y,283:K,285:J,291:150,294:Q,295:Z,296:ee,297:te,298:ie,299:ne,300:oe,301:se,302:re,303:ae,304:le,305:he,306:ue,307:43,308:g,312:ce,346:de,347:pe,348:ge,349:Ee,350:Te,351:_e},e(qe,[2,156]),{45:Ke,89:Je,179:471},e($e,[2,441]),{13:c,16:d,44:136,45:F,55:133,67:132,68:134,77:131,82:M,87:p,172:135,224:P,251:472,255:154,257:155,259:126,263:B,264:130,265:U,266:137,267:139,268:V,269:H,270:G,271:W,273:q,274:$,275:146,276:j,277:z,278:149,279:X,280:Y,283:K,285:J,291:150,294:Q,295:Z,296:ee,297:te,298:ie,299:ne,300:oe,301:se,302:re,303:ae,304:le,305:he,306:ue,307:43,308:g,312:ce,346:de,347:pe,348:ge,349:Ee,350:Te,351:_e},e(je,[2,444],{256:473}),e(je,[2,446],{258:474}),e(_t,[2,442]),e(_t,[2,443]),e(je,[2,449]),{13:c,16:d,44:136,45:F,55:133,67:132,68:134,77:131,82:M,87:p,172:135,224:P,255:154,257:155,259:475,263:B,264:130,265:U,266:137,267:139,268:V,269:H,270:G,271:W,273:q,274:$,275:146,276:j,277:z,278:149,279:X,280:Y,283:K,285:J,291:150,294:Q,295:Z,296:ee,297:te,298:ie,299:ne,300:oe,301:se,302:re,303:ae,304:le,305:he,306:ue,307:43,308:g,312:ce,346:de,347:pe,348:ge,349:Ee,350:Te,351:_e},e(_t,[2,450]),e(_t,[2,451]),e(_t,[2,379],{178:476}),e(_t,[2,378]),e([6,13,16,29,31,39,45,47,48,73,76,78,81,82,83,85,87,89,112,159,160,161,163,164,193,231,242,246,250,263,265,268,269,270,271,272,273,274,276,277,279,280,283,285,290,294,295,296,297,298,299,300,301,302,303,304,305,306,308,309,310,312,335,338,341,342,343,344,345,346,347,348,349,350,351],[2,175]),{48:[1,477]},{48:[1,478]},{272:[1,479]},{272:[1,480]},{272:[1,481]},{13:c,16:d,44:136,45:F,46:482,55:133,67:132,68:134,77:131,82:M,87:p,172:135,224:P,238:121,239:122,243:123,247:124,251:125,255:154,257:155,259:126,263:B,264:130,265:U,266:137,267:139,268:V,269:H,270:G,271:W,273:q,274:$,275:146,276:j,277:z,278:149,279:X,280:Y,283:K,285:J,291:150,294:Q,295:Z,296:ee,297:te,298:ie,299:ne,300:oe,301:se,302:re,303:ae,304:le,305:he,306:ue,307:43,308:g,312:ce,346:de,347:pe,348:ge,349:Ee,350:Te,351:_e},{48:[1,483]},{48:[1,484]},e(Ye,[2,187]),e(Qe,[2,194]),{13:c,16:d,44:39,55:40,82:M,87:p,139:289,172:291,255:154,257:155,266:290,291:150,294:Q,295:Z,296:ee,297:te,298:ie,299:ne,300:oe,301:se,302:re,303:ae,304:le,305:he,306:ue,307:43,308:g,312:ce,320:485},{13:c,16:d,39:[1,487],44:136,45:F,46:488,55:133,67:132,68:134,77:131,82:M,87:p,172:135,224:P,238:121,239:122,243:123,247:124,251:125,255:154,257:155,259:126,263:B,264:130,265:U,266:137,267:139,268:V,269:H,270:G,271:W,273:q,274:$,275:146,276:j,277:z,278:149,279:X,280:Y,282:486,283:K,285:J,291:150,294:Q,295:Z,296:ee,297:te,298:ie,299:ne,300:oe,301:se,302:re,303:ae,304:le,305:he,306:ue,307:43,308:g,312:ce,346:de,347:pe,348:ge,349:Ee,350:Te,351:_e},e(Ct,[2,460]),{13:c,16:d,44:136,45:F,46:489,55:133,67:132,68:134,77:131,82:M,87:p,172:135,224:P,238:121,239:122,243:123,247:124,251:125,255:154,257:155,259:126,263:B,264:130,265:U,266:137,267:139,268:V,269:H,270:G,271:W,273:q,274:$,275:146,276:j,277:z,278:149,279:X,280:Y,283:K,285:J,291:150,294:Q,295:Z,296:ee,297:te,298:ie,299:ne,300:oe,301:se,302:re,303:ae,304:le,305:he,306:ue,307:43,308:g,312:ce,346:de,347:pe,348:ge,349:Ee,350:Te,351:_e},e(_t,[2,464]),{13:c,16:d,44:136,45:F,46:490,55:133,67:132,68:134,77:131,82:M,87:p,172:135,224:P,238:121,239:122,243:123,247:124,251:125,255:154,257:155,259:126,263:B,264:130,265:U,266:137,267:139,268:V,269:H,270:G,271:W,273:q,274:$,275:146,276:j,277:z,278:149,279:X,280:Y,283:K,285:J,291:150,294:Q,295:Z,296:ee,297:te,298:ie,299:ne,300:oe,301:se,302:re,303:ae,304:le,305:he,306:ue,307:43,308:g,312:ce,346:de,347:pe,348:ge,349:Ee,350:Te,351:_e},e(_t,[2,466]),e(fe,[2,40]),e(tt,[2,298]),e(Mt,[2,87]),e(Mt,[2,88]),e(Mt,[2,89]),e(Mt,[2,90]),{13:c,16:d,55:492,82:M,172:493,255:154,257:155,291:150,294:Q,295:Z,296:ee,297:te,298:ie,299:ne,300:oe,301:se,302:re,303:ae,304:le,305:he,306:ue,307:43,308:g,311:494,312:Le,315:491},e(fe,[2,41]),e(it,[2,300]),e(Pt,[2,303],{92:495}),{13:c,16:d,31:[1,496],55:414,82:M,171:497,172:415,173:416,174:vt,255:154,257:155,291:150,294:Q,295:Z,296:ee,297:te,298:ie,299:ne,300:oe,301:se,302:re,303:ae,304:le,305:he,306:ue,307:43,308:g,312:It},{31:[1,498],89:[1,499]},{29:[1,500]},e(nt,[2,372]),{13:c,16:d,48:[2,422],55:194,197:me,223:312,226:502,228:501,229:rt,307:43,308:g},e(st,[2,131]),e(st,[2,126]),e(yt,[2,22]),e(yt,[2,290]),{82:[1,503]},{82:[1,504]},{13:c,16:d,44:510,45:F,55:323,67:321,68:322,74:505,75:506,76:Bt,77:320,78:Ut,79:509,87:p,267:139,268:V,269:H,270:G,271:W,273:q,274:$,275:146,276:j,277:z,278:149,279:X,280:Y,283:K,285:J,307:43,308:g,346:de,347:pe,348:ge,349:Ee,350:Te,351:_e},e(At,[2,294]),e(Vt,[2,69]),e(Vt,[2,70]),e(be,Ce,{59:197,69:198,20:511,70:ve}),e(Ne,ye,{58:205,62:206,23:512,63:Ae}),{29:[2,375],31:[2,71],84:522,85:a,112:[1,518],150:513,151:514,158:515,159:[1,516],160:[1,517],161:[1,519],163:[1,520],164:[1,521],175:523},e(St,[2,363],{157:524,335:[1,525]}),e(l,s,{215:10,202:526,205:527,208:528,214:529,44:530,87:p}),e(Ht,[2,399],{215:10,205:527,208:528,214:529,44:530,204:531,202:532,13:s,16:s,45:s,197:s,224:s,229:s,308:s,87:p}),{13:c,16:d,44:215,45:Ot,55:220,82:M,87:p,89:Se,172:221,185:351,203:536,212:534,231:Rt,233:533,234:535,236:216,237:222,255:154,257:155,291:150,294:Q,295:Z,296:ee,297:te,298:ie,299:ne,300:oe,301:se,302:re,303:ae,304:le,305:he,306:ue,307:43,308:g,309:Re,310:we,311:217,312:Le},e(l,s,{215:10,205:527,208:528,214:529,44:530,202:537,87:p}),e(Ne,[2,23],{307:43,267:139,275:146,278:149,55:323,67:447,68:448,44:450,66:538,13:c,16:d,45:wt,87:p,268:V,269:H,270:G,271:W,273:q,274:$,276:j,277:z,279:X,280:Y,283:K,285:J,308:g,346:de,347:pe,348:ge,349:Ee,350:Te,351:_e}),e(Gt,[2,291]),e(Gt,[2,24]),e(Gt,[2,25]),{13:c,16:d,44:136,45:F,46:539,55:133,67:132,68:134,77:131,82:M,87:p,172:135,224:P,238:121,239:122,243:123,247:124,251:125,255:154,257:155,259:126,263:B,264:130,265:U,266:137,267:139,268:V,269:H,270:G,271:W,273:q,274:$,275:146,276:j,277:z,278:149,279:X,280:Y,283:K,285:J,291:150,294:Q,295:Z,296:ee,297:te,298:ie,299:ne,300:oe,301:se,302:re,303:ae,304:le,305:he,306:ue,307:43,308:g,312:ce,346:de,347:pe,348:ge,349:Ee,350:Te,351:_e},e(Gt,[2,28]),e(Ne,ye,{58:205,62:206,23:540,63:Ae}),e([31,112,232,318,335],[2,105],{192:541,193:[1,542]}),e(Lt,[2,107]),{13:c,16:d,44:215,45:ke,55:220,82:M,87:p,89:Se,172:221,185:351,187:350,199:543,200:544,231:Oe,234:349,236:216,237:222,255:154,257:155,291:150,294:Q,295:Z,296:ee,297:te,298:ie,299:ne,300:oe,301:se,302:re,303:ae,304:le,305:he,306:ue,307:43,308:g,309:Re,310:we,311:217,312:Le},e(Wt,[2,132]),e(Dt,[2,425]),e(Wt,[2,133]),{13:c,16:d,44:354,55:355,82:M,87:p,172:357,237:356,255:154,257:155,291:150,294:Q,295:Z,296:ee,297:te,298:ie,299:ne,300:oe,301:se,302:re,303:ae,304:le,305:he,306:ue,307:43,308:g,309:Re,310:we,311:358,312:Le,313:545},e(Be,[2,54]),e(Be,[2,48]),e(Tt,[2,342]),{13:c,16:d,44:39,55:40,87:p,139:546,307:43,308:g},e(Tt,[2,68]),e(v,[2,350],{31:qt,112:qt}),e(Be,[2,53]),{13:c,16:d,55:547,307:43,308:g},e(k,[2,333]),e(x,[2,16]),e(We,[2,152]),e(qe,[2,154]),e(qe,[2,157]),e($e,[2,159]),e($e,[2,160],{262:389,261:548,39:ft,338:mt}),e($e,[2,161],{262:389,261:549,39:ft,338:mt}),e(je,[2,163]),{13:c,16:d,44:136,45:F,46:550,55:133,67:132,68:134,77:131,82:M,87:p,172:135,224:P,238:121,239:122,243:123,247:124,251:125,255:154,257:155,259:126,263:B,264:130,265:U,266:137,267:139,268:V,269:H,270:G,271:W,273:q,274:$,275:146,276:j,277:z,278:149,279:X,280:Y,283:K,285:J,291:150,294:Q,295:Z,296:ee,297:te,298:ie,299:ne,300:oe,301:se,302:re,303:ae,304:le,305:he,306:ue,307:43,308:g,312:ce,346:de,347:pe,348:ge,349:Ee,350:Te,351:_e},e(Ye,[2,178]),e(Ye,[2,179]),{13:c,16:d,44:136,45:F,46:551,55:133,67:132,68:134,77:131,82:M,87:p,172:135,224:P,238:121,239:122,243:123,247:124,251:125,255:154,257:155,259:126,263:B,264:130,265:U,266:137,267:139,268:V,269:H,270:G,271:W,273:q,274:$,275:146,276:j,277:z,278:149,279:X,280:Y,283:K,285:J,291:150,294:Q,295:Z,296:ee,297:te,298:ie,299:ne,300:oe,301:se,302:re,303:ae,304:le,305:he,306:ue,307:43,308:g,312:ce,346:de,347:pe,348:ge,349:Ee,350:Te,351:_e},{13:c,16:d,44:136,45:F,46:552,55:133,67:132,68:134,77:131,82:M,87:p,172:135,224:P,238:121,239:122,243:123,247:124,251:125,255:154,257:155,259:126,263:B,264:130,265:U,266:137,267:139,268:V,269:H,270:G,271:W,273:q,274:$,275:146,276:j,277:z,278:149,279:X,280:Y,283:K,285:J,291:150,294:Q,295:Z,296:ee,297:te,298:ie,299:ne,300:oe,301:se,302:re,303:ae,304:le,305:he,306:ue,307:43,308:g,312:ce,346:de,347:pe,348:ge,349:Ee,350:Te,351:_e},{13:c,16:d,44:136,45:F,46:553,55:133,67:132,68:134,77:131,82:M,87:p,172:135,224:P,238:121,239:122,243:123,247:124,251:125,255:154,257:155,259:126,263:B,264:130,265:U,266:137,267:139,268:V,269:H,270:G,271:W,273:q,274:$,275:146,276:j,277:z,278:149,279:X,280:Y,283:K,285:J,291:150,294:Q,295:Z,296:ee,297:te,298:ie,299:ne,300:oe,301:se,302:re,303:ae,304:le,305:he,306:ue,307:43,308:g,312:ce,346:de,347:pe,348:ge,349:Ee,350:Te,351:_e},{48:[1,554],272:[1,555]},e(Ye,[2,184]),e(Ye,[2,186]),{314:[1,556]},{48:[1,557]},{48:[2,461]},{48:[2,462]},{48:[1,558]},{48:[2,467],193:[1,561],287:559,288:560},{13:c,16:d,55:194,197:me,223:562,307:43,308:g},e($t,[2,224]),e($t,[2,225]),e($t,[2,226]),{31:[1,563],45:jt,94:564},e(fe,[2,84]),e(tt,[2,368]),e(fe,[2,85]),e(it,[2,370]),e(Pt,[2,373],{170:566}),{48:[1,567]},{48:[2,423],337:[1,568]},e(yt,[2,35],{83:[1,569]}),e(yt,[2,36],{81:[1,570]}),e(lt,[2,30],{307:43,267:139,275:146,278:149,77:320,67:321,68:322,55:323,79:509,44:510,75:571,13:c,16:d,45:F,76:Bt,78:Ut,87:p,268:V,269:H,270:G,271:W,273:q,274:$,276:j,277:z,279:X,280:Y,283:K,285:J,308:g,346:de,347:pe,348:ge,349:Ee,350:Te,351:_e}),e(zt,[2,295]),{45:F,77:572},{45:F,77:573},e(zt,[2,33]),e(zt,[2,34]),{31:[2,275],50:574,84:575,85:a},{31:[2,277],51:576,84:577,85:a},e(St,[2,356]),e(Xt,[2,357],{152:578,335:[1,579]}),e(Yt,[2,74]),{29:Ie,57:580},{29:Ie,57:581},{13:c,16:d,44:39,55:40,87:p,139:582,307:43,308:g},e(Kt,[2,365],{162:583,328:[1,584]}),{13:c,16:d,45:F,55:323,67:321,68:322,77:320,79:585,267:139,268:V,269:H,270:G,271:W,273:q,274:$,275:146,276:j,277:z,278:149,279:X,280:Y,283:K,285:J,307:43,308:g,346:de,347:pe,348:ge,349:Ee,350:Te,351:_e},{45:[1,586]},e(Yt,[2,81]),{29:Ie,57:587},e(St,[2,73]),e(v,[2,362],{29:Jt,31:Jt,85:Jt,112:Jt,159:Jt,160:Jt,161:Jt,163:Jt,164:Jt}),e(Ht,[2,112]),e(Qt,[2,401],{206:588}),e(v,[2,405],{209:589,210:590}),e(v,[2,403]),e(v,[2,404]),e(Ht,[2,113]),e(Ht,[2,400]),{13:c,16:d,44:215,45:Ot,48:[1,591],55:220,82:M,87:p,89:Se,172:221,185:351,203:536,212:592,231:Rt,234:535,236:216,237:222,255:154,257:155,291:150,294:Q,295:Z,296:ee,297:te,298:ie,299:ne,300:oe,301:se,302:re,303:ae,304:le,305:he,306:ue,307:43,308:g,309:Re,310:we,311:217,312:Le},e(Dt,[2,426]),e(Ft,[2,138]),e(Ft,[2,139]),{232:[1,593]},e(Gt,[2,292]),{47:[1,595],48:[1,594]},e(at,[2,9]),e(Lt,[2,392]),e(Lt,[2,393],{44:39,55:40,307:43,195:341,139:342,194:596,190:597,13:c,16:d,87:p,197:ct,308:g}),e(Lt,[2,110],{272:[1,598]}),e(Zt,[2,397],{201:599,316:600,317:[1,601]}),{314:[1,602]},{29:[1,603]},e(He,[2,58]),e(je,[2,445]),e(je,[2,447]),{48:[1,604],272:[1,605]},{48:[1,606]},{272:[1,607]},{272:[1,608]},e(Ye,[2,99]),e(_t,[2,382]),e([13,16,39,47,48,87,193,197,242,246,250,263,265,272,290,297,298,299,300,301,302,308,314,338,341,342,343,344,345,346],[2,232]),e(Ye,[2,188]),e(Ye,[2,189]),{48:[1,609]},{48:[2,468]},{289:[1,610]},{13:c,16:d,55:492,82:M,172:493,255:154,257:155,291:150,294:Q,295:Z,296:ee,297:te,298:ie,299:ne,300:oe,301:se,302:re,303:ae,304:le,305:he,306:ue,307:43,308:g,311:494,312:Le,315:611},e(fe,[2,42]),e(Pt,[2,304]),{13:c,16:d,55:414,82:M,95:612,171:613,172:415,173:416,174:vt,255:154,257:155,291:150,294:Q,295:Z,296:ee,297:te,298:ie,299:ne,300:oe,301:se,302:re,303:ae,304:le,305:he,306:ue,307:43,308:g,312:It},{31:[1,614],45:jt,94:615},e(st,[2,129]),e(Nt,[2,421]),{82:[1,616]},{82:[1,617]},e(zt,[2,296]),e(zt,[2,31]),e(zt,[2,32]),{31:[2,17]},{31:[2,276]},{31:[2,18]},{31:[2,278]},e(v,ht,{155:330,153:618,154:619,29:ei,31:ei,85:ei,112:ei,159:ei,160:ei,161:ei,163:ei,164:ei}),e(Xt,[2,358]),e(Yt,[2,75]),e(Yt,[2,76]),{29:Ie,57:620},{13:c,16:d,44:39,55:40,87:p,139:621,307:43,308:g},e(Kt,[2,366]),e(Yt,[2,79]),{13:c,16:d,44:136,45:F,46:622,55:133,67:132,68:134,77:131,82:M,87:p,172:135,224:P,238:121,239:122,243:123,247:124,251:125,255:154,257:155,259:126,263:B,264:130,265:U,266:137,267:139,268:V,269:H,270:G,271:W,273:q,274:$,275:146,276:j,277:z,278:149,279:X,280:Y,283:K,285:J,291:150,294:Q,295:Z,296:ee,297:te,298:ie,299:ne,300:oe,301:se,302:re,303:ae,304:le,305:he,306:ue,307:43,308:g,312:ce,346:de,347:pe,348:ge,349:Ee,350:Te,351:_e},e(Yt,[2,91],{336:[1,623]}),e([29,31,85,112,159,160,161,163,164,232,318,335],[2,114],{207:624,193:[1,625]}),e(Qt,[2,117]),{13:c,16:d,44:215,45:Ot,55:220,82:M,87:p,89:Se,172:221,185:351,203:536,211:626,212:627,231:Rt,234:535,236:216,237:222,255:154,257:155,291:150,294:Q,295:Z,296:ee,297:te,298:ie,299:ne,300:oe,301:se,302:re,303:ae,304:le,305:he,306:ue,307:43,308:g,309:Re,310:we,311:217,312:Le},e(pt,[2,134]),e(Dt,[2,427]),e(pt,[2,135]),e(Gt,[2,26]),{44:628,87:p},e(Lt,[2,106]),e(Lt,[2,394]),e(v,[2,396]),e(Zt,[2,111]),e(Zt,[2,398]),{13:c,16:d,44:39,55:40,87:p,139:342,186:629,190:340,195:341,197:ct,307:43,308:g},e(gt,[2,217]),e(v,Ue,{144:248,140:630,143:631,31:[2,343]}),e(Ye,[2,97]),e(_t,[2,380]),e(Ye,[2,180]),{13:c,16:d,44:136,45:F,46:632,55:133,67:132,68:134,77:131,82:M,87:p,172:135,224:P,238:121,239:122,243:123,247:124,251:125,255:154,257:155,259:126,263:B,264:130,265:U,266:137,267:139,268:V,269:H,270:G,271:W,273:q,274:$,275:146,276:j,277:z,278:149,279:X,280:Y,283:K,285:J,291:150,294:Q,295:Z,296:ee,297:te,298:ie,299:ne,300:oe,301:se,302:re,303:ae,304:le,305:he,306:ue,307:43,308:g,312:ce,346:de,347:pe,348:ge,349:Ee,350:Te,351:_e},{13:c,16:d,44:136,45:F,46:633,55:133,67:132,68:134,77:131,82:M,87:p,172:135,224:P,238:121,239:122,243:123,247:124,251:125,255:154,257:155,259:126,263:B,264:130,265:U,266:137,267:139,268:V,269:H,270:G,271:W,273:q,274:$,275:146,276:j,277:z,278:149,279:X,280:Y,283:K,285:J,291:150,294:Q,295:Z,296:ee,297:te,298:ie,299:ne,300:oe,301:se,302:re,303:ae,304:le,305:he,306:ue,307:43,308:g,312:ce,346:de,347:pe,348:ge,349:Ee,350:Te,351:_e},e(Ye,[2,190]),{290:[1,634]},{314:[1,635]},{13:c,16:d,48:[1,636],55:414,82:M,171:637,172:415,173:416,174:vt,255:154,257:155,291:150,294:Q,295:Z,296:ee,297:te,298:ie,299:ne,300:oe,301:se,302:re,303:ae,304:le,305:he,306:ue,307:43,308:g,312:It},e(ti,[2,305]),e(fe,[2,86]),e(Pt,[2,374]),e(yt,[2,37]),e(yt,[2,38]),e(St,[2,72]),e(St,[2,360]),e(Yt,[2,77]),{29:Ie,57:638},{47:[1,639]},{29:[2,376]},e(Qt,[2,402]),e(Qt,[2,115],{215:10,208:528,214:529,44:530,205:640,13:s,16:s,45:s,197:s,224:s,229:s,308:s,87:p}),e(Qt,[2,118],{272:[1,641]}),e(ii,[2,407],{213:642,319:643,317:[1,644]}),{48:[1,645]},{318:[1,646]},{31:[1,647]},{31:[2,344]},{48:[1,648]},{48:[1,649]},{291:650,303:ae,304:le,305:he,306:ue},e(Mt,[2,218]),e(Pt,[2,44]),e(ti,[2,306]),e(Yt,[2,78]),{44:651,87:p},e(Qt,[2,116]),e(v,[2,406]),e(ii,[2,119]),e(ii,[2,408]),e(l,s,{215:10,205:527,208:528,214:529,44:530,202:652,87:p}),e(Gt,[2,27]),e(Zt,[2,230]),e(ni,[2,345],{141:653,335:[1,654]}),e(Ye,[2,181]),e(Ye,[2,182]),{48:[2,191]},{48:[1,655]},{318:[1,656]},e(v,Ue,{144:248,142:657,143:658,31:oi,112:oi}),e(ni,[2,346]),e(Yt,[2,80]),e(ii,[2,231]),e(Tt,[2,67]),e(Tt,[2,348])],defaultActions:{5:[2,240],6:[2,241],7:[2,242],9:[2,239],24:[2,1],25:[2,2],26:[2,244],87:[2,282],94:[2,384],100:[2,45],109:[2,325],166:[2,458],263:[2,439],336:[2,258],337:[2,101],487:[2,461],488:[2,462],560:[2,468],574:[2,17],575:[2,276],576:[2,18],577:[2,278],623:[2,376],631:[2,344],650:[2,191]},parseError:function(e,t){if(!t.recoverable){var i=new Error(e);throw i.hash=t,i}this.trace(e)},parse:function(e){var t=this,i=[0],n=[null],o=[],s=this.table,r="",a=0,l=0,h=0,u=o.slice.call(arguments,1),c=Object.create(this.lexer),d={yy:{}};for(var p in this.yy)Object.prototype.hasOwnProperty.call(this.yy,p)&&(d.yy[p]=this.yy[p]);c.setInput(e,d.yy),d.yy.lexer=c,d.yy.parser=this,void 0===c.yylloc&&(c.yylloc={});var g=c.yylloc;o.push(g);var E,T=c.options&&c.options.ranges;"function"==typeof d.yy.parseError?this.parseError=d.yy.parseError:this.parseError=Object.getPrototypeOf(this).parseError;for(var _,f,m,b,C,v,I,N,y,A={};;){if(m=i[i.length-1],this.defaultActions[m]?b=this.defaultActions[m]:(null==_&&(E=void 0,"number"!=typeof(E=c.lex()||1)&&(E=t.symbols_[E]||E),_=E),b=s[m]&&s[m][_]),void 0===b||!b.length||!b[0]){var k;for(v in y=[],s[m])this.terminals_[v]&&v>2&&y.push("'"+this.terminals_[v]+"'");k=c.showPosition?"Parse error on line "+(a+1)+":\n"+c.showPosition()+"\nExpecting "+y.join(", ")+", got '"+(this.terminals_[_]||_)+"'":"Parse error on line "+(a+1)+": Unexpected "+(1==_?"end of input":"'"+(this.terminals_[_]||_)+"'"),this.parseError(k,{text:c.match,token:this.terminals_[_]||_,line:c.yylineno,loc:g,expected:y})}if(b[0]instanceof Array&&b.length>1)throw new Error("Parse Error: multiple actions possible at state: "+m+", token: "+_);switch(b[0]){case 1:i.push(_),n.push(c.yytext),o.push(c.yylloc),i.push(b[1]),_=null,f?(_=f,f=null):(l=c.yyleng,r=c.yytext,a=c.yylineno,g=c.yylloc,h>0&&h--);break;case 2:if(I=this.productions_[b[1]][1],A.$=n[n.length-I],A._$={first_line:o[o.length-(I||1)].first_line,last_line:o[o.length-1].last_line,first_column:o[o.length-(I||1)].first_column,last_column:o[o.length-1].last_column},T&&(A._$.range=[o[o.length-(I||1)].range[0],o[o.length-1].range[1]]),void 0!==(C=this.performAction.apply(A,[r,l,a,d.yy,b[1],n,o].concat(u))))return C;I&&(i=i.slice(0,-1*I*2),n=n.slice(0,-1*I),o=o.slice(0,-1*I)),i.push(this.productions_[b[1]][0]),n.push(A.$),o.push(A._$),N=s[i[i.length-2]][i[i.length-1]],i.push(N);break;case 3:return!0}}return!0}},ri=i(637).t,ai="http://www.w3.org/1999/02/22-rdf-syntax-ns#",li=ai+"type",hi=ai+"first",ui=ai+"rest",ci=ai+"nil",di="http://www.w3.org/2001/XMLSchema#",pi=di+"integer",gi=di+"decimal",Ei=di+"double",Ti=di+"boolean",_i="",fi="",mi="";function bi(e){return e.toLowerCase()}function Ci(e,t){return e.push(t),e}function vi(e,t){return e.push.apply(e,t),e}function Ii(e){e||(e={});for(var t,i=1,n=arguments.length;i<n&&(t=arguments[i]||{});i++)for(var o in t)e[o]=t[o];return e}function Ni(){for(var e=[],t=0,i=arguments.length;t<i;t++)e=e.concat.apply(e,arguments[t]);return e}function yi(e){if("<"===e[0]&&(e=e.substring(1,e.length-1)),/^[a-z]+:/i.test(e))return e;if(!on.base)throw new Error("Cannot resolve relative IRI "+e+" because no base IRI was set.");switch(_i!==on.base&&(_i=on.base,fi=_i.replace(/[^\/:]*$/,""),mi=_i.match(/^(?:[a-z]+:\/*)?[^\/]*/)[0]),e[0]){case void 0:return _i;case"#":return _i+e;case"?":return _i.replace(/(?:\?.*)?$/,e);case"/":return mi+e;default:return fi+e}}function Ai(e){if(e){var t=e[0];if("?"===t||"$"===t)return on.factory.variable(e.substr(1))}return e}function ki(e,t){return{type:"operation",operator:e,args:t||[]}}function Si(e,t){var i={expression:"*"===e?new ri:e};if(t)for(var n in t)i[n]=t[n];return i}function Oi(e,t){return{type:"path",pathType:e,items:t}}function Ri(e,t){for(var i,n=0,o=t.length;n<o&&(i=t[n]);n++)e=ki(i[0],[e,i[1]]);return e}function wi(e,t){var i,n=[],o=[],s=e.length,r={};if(!s)return null;for(var a=0;a<s&&(i=e[a]);a++)(i.named?o:n).push(i.iri);return r[t||"from"]={default:n,named:o},r}function Li(e){return parseInt(e,10)}function Di(e){return"group"===e.type&&1===e.patterns.length?e.patterns[0]:e}function xi(e,t){return t&&"NamedNode"!==t.termType&&(t=on.factory.namedNode(t)),on.factory.literal(e,t)}function Fi(e,t,i){if(!("termType"in t))throw new Error("Nested triples cannot contain paths");return on.factory.quad(e,t,i)}function Mi(e,t,i,n){var o={};return null!=e&&(o.subject=e),null!=t&&(o.predicate=t),null!=i&&(o.object=i),null!=n&&(o.annotations=n),o}function Pi(e){return"string"==typeof e?e.startsWith("e_")?on.factory.blankNode(e):on.factory.blankNode("e_"+e):on.factory.blankNode("g_"+Bi++)}var Bi=0;on._resetBlanks=function(){Bi=0};var Ui=/\\u([a-fA-F0-9]{4})|\\U([a-fA-F0-9]{8})|\\(.)/g,Vi={"\\":"\\","'":"'",'"':'"',t:"\t",b:"\b",n:"\n",r:"\r",f:"\f"},Hi=/[\uD800-\uDBFF]([^\uDC00-\uDFFF]|$)/,Gi=String.fromCharCode;function Wi(e,t){e=e.substring(t,e.length-t);try{e=e.replace(Ui,(function(e,t,i,n){var o;if(t){if(o=parseInt(t,16),isNaN(o))throw new Error;return Gi(o)}if(i){if(o=parseInt(i,16),isNaN(o))throw new Error;return o<65535?Gi(o):Gi(55296+((o-=65536)>>10),56320+(1023&o))}var s=Vi[n];if(!s)throw new Error;return s}))}catch(e){return""}if(Hi.exec(e))throw new Error("Invalid unicode codepoint of surrogate pair without corresponding codepoint in "+e);return e}function qi(e,t,i){var n=[],o=[];return t.forEach((function(t){let i=null;t.annotation&&(i=t.annotation,t=t.object),n.push(Mi(null,e,t.entity,i)),vi(o,t.triples)})),Ni(n,i||[],o)}function $i(e){return e.variable?e.variable.value:e.value||e.expression.value}function ji(e){if(!e)return[];if("aggregate"===e.type)return[e];if("operation"===e.type){const t=[];for(const i of e.args)t.push(...ji(i));return t}return[]}function zi(e){const t=new Set,i=function(e){e&&("Variable"===e.termType?t.add(e):"operation"===e.type&&e.args.forEach(i))};return i(e),t}function Xi(e,t=1,i=[]){for(const n of e)t>0&&n instanceof Array?Xi(n,t-1,i):i.push(n);return i}function Yi(e){return"Variable"===e.termType}function Ki(e){if(e.triples){const t=[];for(const i of e.triples)Yi(i.subject)&&t.push(i.subject.value),Yi(i.predicate)&&t.push(i.predicate.value),Yi(i.object)&&t.push(i.object.value);return t}if(e.patterns){const t=[];for(const i of e.patterns)t.push(...Ki(i));return t}return[]}function Ji(e){if(!on.sparqlStar)throw new Error("SPARQL-star support is not enabled");return e}function Qi(e,t,i){for(const n of t){const t=Mi("subject"in n?n.subject:e,n.predicate,n.object);i.push(t),n.annotations&&Qi(Fi(e,n.predicate,n.object),n.annotations,i)}}function Zi(e){if(on.sparqlStar){const t=[];return e.forEach((e=>{const i=Mi(e.subject,e.predicate,e.object);t.push(i),e.annotations&&Qi(Fi(e.subject,e.predicate,e.object),e.annotations,t)})),t}return e}function en(e){for(const t of e){if("graph"===t.type&&"Variable"===t.name.termType)throw new Error("Detected illegal variable in GRAPH");if("bgp"===t.type||"graph"===t.type)for(const e of t.triples)if("Variable"===e.subject.termType||"Variable"===e.predicate.termType||"Variable"===e.object.termType)throw new Error("Detected illegal variable in BGP")}return e}function tn(e){for(const t of e)if("bgp"===t.type)for(const e of t.triples)if("BlankNode"===e.subject.termType||"BlankNode"===e.predicate.termType||"BlankNode"===e.object.termType)throw new Error("Detected illegal blank node in BGP");return e}var nn={EOF:1,parseError:function(e,t){if(!this.yy.parser)throw new Error(e);this.yy.parser.parseError(e,t)},setInput:function(e,t){return this.yy=t||this.yy||{},this._input=e,this._more=this._backtrack=this.done=!1,this.yylineno=this.yyleng=0,this.yytext=this.matched=this.match="",this.conditionStack=["INITIAL"],this.yylloc={first_line:1,first_column:0,last_line:1,last_column:0},this.options.ranges&&(this.yylloc.range=[0,0]),this.offset=0,this},input:function(){var e=this._input[0];return this.yytext+=e,this.yyleng++,this.offset++,this.match+=e,this.matched+=e,e.match(/(?:\r\n?|\n).*/g)?(this.yylineno++,this.yylloc.last_line++):this.yylloc.last_column++,this.options.ranges&&this.yylloc.range[1]++,this._input=this._input.slice(1),e},unput:function(e){var t=e.length,i=e.split(/(?:\r\n?|\n)/g);this._input=e+this._input,this.yytext=this.yytext.substr(0,this.yytext.length-t),this.offset-=t;var n=this.match.split(/(?:\r\n?|\n)/g);this.match=this.match.substr(0,this.match.length-1),this.matched=this.matched.substr(0,this.matched.length-1),i.length-1&&(this.yylineno-=i.length-1);var o=this.yylloc.range;return this.yylloc={first_line:this.yylloc.first_line,last_line:this.yylineno+1,first_column:this.yylloc.first_column,last_column:i?(i.length===n.length?this.yylloc.first_column:0)+n[n.length-i.length].length-i[0].length:this.yylloc.first_column-t},this.options.ranges&&(this.yylloc.range=[o[0],o[0]+this.yyleng-t]),this.yyleng=this.yytext.length,this},more:function(){return this._more=!0,this},reject:function(){return this.options.backtrack_lexer?(this._backtrack=!0,this):this.parseError("Lexical error on line "+(this.yylineno+1)+". You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).\n"+this.showPosition(),{text:"",token:null,line:this.yylineno})},less:function(e){this.unput(this.match.slice(e))},pastInput:function(){var e=this.matched.substr(0,this.matched.length-this.match.length);return(e.length>20?"...":"")+e.substr(-20).replace(/\n/g,"")},upcomingInput:function(){var e=this.match;return e.length<20&&(e+=this._input.substr(0,20-e.length)),(e.substr(0,20)+(e.length>20?"...":"")).replace(/\n/g,"")},showPosition:function(){var e=this.pastInput(),t=new Array(e.length+1).join("-");return e+this.upcomingInput()+"\n"+t+"^"},test_match:function(e,t){var i,n,o;if(this.options.backtrack_lexer&&(o={yylineno:this.yylineno,yylloc:{first_line:this.yylloc.first_line,last_line:this.last_line,first_column:this.yylloc.first_column,last_column:this.yylloc.last_column},yytext:this.yytext,match:this.match,matches:this.matches,matched:this.matched,yyleng:this.yyleng,offset:this.offset,_more:this._more,_input:this._input,yy:this.yy,conditionStack:this.conditionStack.slice(0),done:this.done},this.options.ranges&&(o.yylloc.range=this.yylloc.range.slice(0))),(n=e[0].match(/(?:\r\n?|\n).*/g))&&(this.yylineno+=n.length),this.yylloc={first_line:this.yylloc.last_line,last_line:this.yylineno+1,first_column:this.yylloc.last_column,last_column:n?n[n.length-1].length-n[n.length-1].match(/\r?\n?/)[0].length:this.yylloc.last_column+e[0].length},this.yytext+=e[0],this.match+=e[0],this.matches=e,this.yyleng=this.yytext.length,this.options.ranges&&(this.yylloc.range=[this.offset,this.offset+=this.yyleng]),this._more=!1,this._backtrack=!1,this._input=this._input.slice(e[0].length),this.matched+=e[0],i=this.performAction.call(this,this.yy,this,t,this.conditionStack[this.conditionStack.length-1]),this.done&&this._input&&(this.done=!1),i)return i;if(this._backtrack){for(var s in o)this[s]=o[s];return!1}return!1},next:function(){if(this.done)return this.EOF;var e,t,i,n;this._input||(this.done=!0),this._more||(this.yytext="",this.match="");for(var o=this._currentRules(),s=0;s<o.length;s++)if((i=this._input.match(this.rules[o[s]]))&&(!t||i[0].length>t[0].length)){if(t=i,n=s,this.options.backtrack_lexer){if(!1!==(e=this.test_match(i,o[s])))return e;if(this._backtrack){t=!1;continue}return!1}if(!this.options.flex)break}return t?!1!==(e=this.test_match(t,o[n]))&&e:""===this._input?this.EOF:this.parseError("Lexical error on line "+(this.yylineno+1)+". Unrecognized text.\n"+this.showPosition(),{text:"",token:null,line:this.yylineno})},lex:function(){return this.next()||this.lex()},begin:function(e){this.conditionStack.push(e)},popState:function(){return this.conditionStack.length-1>0?this.conditionStack.pop():this.conditionStack[0]},_currentRules:function(){return this.conditionStack.length&&this.conditionStack[this.conditionStack.length-1]?this.conditions[this.conditionStack[this.conditionStack.length-1]].rules:this.conditions.INITIAL.rules},topState:function(e){return(e=this.conditionStack.length-1-Math.abs(e||0))>=0?this.conditionStack[e]:"INITIAL"},pushState:function(e){this.begin(e)},stateStackSize:function(){return this.conditionStack.length},options:{flex:!0,"case-insensitive":!0},performAction:function(e,t,i,n){switch(i){case 0:break;case 1:return 12;case 2:return 15;case 3:return 41;case 4:return 325;case 5:return 326;case 6:return 45;case 7:return 47;case 8:return 48;case 9:return 39;case 10:return 24;case 11:return 28;case 12:return 29;case 13:return 31;case 14:return 32;case 15:return 36;case 16:return 53;case 17:return 327;case 18:return 63;case 19:return 64;case 20:return 70;case 21:return 73;case 22:return 76;case 23:return 78;case 24:return 81;case 25:return 83;case 26:return 85;case 27:return 193;case 28:return 100;case 29:return 328;case 30:return 121;case 31:return 329;case 32:return 330;case 33:return 110;case 34:return 331;case 35:return 109;case 36:return 332;case 37:return 333;case 38:return 113;case 39:return 115;case 40:return 116;case 41:return 131;case 42:return 123;case 43:return 126;case 44:return 128;case 45:return 132;case 46:return 112;case 47:return 334;case 48:return 335;case 49:return 159;case 50:return 161;case 51:return 164;case 52:return 174;case 53:return 160;case 54:return 336;case 55:return 163;case 56:return 312;case 57:return 314;case 58:return 317;case 59:return 318;case 60:return 272;case 61:return 197;case 62:return 337;case 63:return 338;case 64:return 229;case 65:return 340;case 66:return 263;case 67:return 224;case 68:return 231;case 69:return 232;case 70:return 242;case 71:return 246;case 72:return 290;case 73:return 341;case 74:return 342;case 75:return 343;case 76:return 344;case 77:return 345;case 78:return 250;case 79:return 346;case 80:return 265;case 81:return 276;case 82:return 277;case 83:return 268;case 84:return 269;case 85:return 270;case 86:return 271;case 87:return 347;case 88:return 348;case 89:return 273;case 90:return 274;case 91:return 350;case 92:return 349;case 93:return 351;case 94:return 279;case 95:return 280;case 96:return 283;case 97:return 285;case 98:return 289;case 99:return 293;case 100:return 296;case 101:return 13;case 102:return 16;case 103:return 308;case 104:return 309;case 105:return 87;case 106:return 292;case 107:return 82;case 108:return 294;case 109:return 295;case 110:return 297;case 111:return 298;case 112:return 299;case 113:return 300;case 114:return 301;case 115:return 302;case 116:return"EXPONENT";case 117:return 303;case 118:return 304;case 119:return 305;case 120:return 306;case 121:return 89;case 122:return 310;case 123:return 6;case 124:return"INVALID";case 125:console.log(t.yytext)}},rules:[/^(?:\s+|(#[^\n\r]*))/i,/^(?:BASE)/i,/^(?:PREFIX)/i,/^(?:SELECT)/i,/^(?:DISTINCT)/i,/^(?:REDUCED)/i,/^(?:\()/i,/^(?:AS)/i,/^(?:\))/i,/^(?:\*)/i,/^(?:CONSTRUCT)/i,/^(?:WHERE)/i,/^(?:\{)/i,/^(?:\})/i,/^(?:DESCRIBE)/i,/^(?:ASK)/i,/^(?:FROM)/i,/^(?:NAMED)/i,/^(?:GROUP)/i,/^(?:BY)/i,/^(?:HAVING)/i,/^(?:ORDER)/i,/^(?:ASC)/i,/^(?:DESC)/i,/^(?:LIMIT)/i,/^(?:OFFSET)/i,/^(?:VALUES)/i,/^(?:;)/i,/^(?:LOAD)/i,/^(?:SILENT)/i,/^(?:INTO)/i,/^(?:CLEAR)/i,/^(?:DROP)/i,/^(?:CREATE)/i,/^(?:ADD)/i,/^(?:TO)/i,/^(?:MOVE)/i,/^(?:COPY)/i,/^(?:INSERT((\s+|(#[^\n\r]*)\n\r?)+)DATA)/i,/^(?:DELETE((\s+|(#[^\n\r]*)\n\r?)+)DATA)/i,/^(?:DELETE((\s+|(#[^\n\r]*)\n\r?)+)WHERE)/i,/^(?:WITH)/i,/^(?:DELETE)/i,/^(?:INSERT)/i,/^(?:USING)/i,/^(?:DEFAULT)/i,/^(?:GRAPH)/i,/^(?:ALL)/i,/^(?:\.)/i,/^(?:OPTIONAL)/i,/^(?:SERVICE)/i,/^(?:BIND)/i,/^(?:UNDEF)/i,/^(?:MINUS)/i,/^(?:UNION)/i,/^(?:FILTER)/i,/^(?:<<)/i,/^(?:>>)/i,/^(?:\{\|)/i,/^(?:\|\})/i,/^(?:,)/i,/^(?:a)/i,/^(?:\|)/i,/^(?:\/)/i,/^(?:\^)/i,/^(?:\?)/i,/^(?:\+)/i,/^(?:!)/i,/^(?:\[)/i,/^(?:\])/i,/^(?:\|\|)/i,/^(?:&&)/i,/^(?:=)/i,/^(?:!=)/i,/^(?:<)/i,/^(?:>)/i,/^(?:<=)/i,/^(?:>=)/i,/^(?:IN)/i,/^(?:NOT)/i,/^(?:-)/i,/^(?:BOUND)/i,/^(?:BNODE)/i,/^(?:(RAND|NOW|UUID|STRUUID))/i,/^(?:(LANG|DATATYPE|IRI|URI|ABS|CEIL|FLOOR|ROUND|STRLEN|STR|UCASE|LCASE|ENCODE_FOR_URI|YEAR|MONTH|DAY|HOURS|MINUTES|SECONDS|TIMEZONE|TZ|MD5|SHA1|SHA256|SHA384|SHA512|isIRI|isURI|isBLANK|isLITERAL|isNUMERIC))/i,/^(?:(SUBJECT|PREDICATE|OBJECT|isTRIPLE))/i,/^(?:(LANGMATCHES|CONTAINS|STRSTARTS|STRENDS|STRBEFORE|STRAFTER|STRLANG|STRDT|sameTerm))/i,/^(?:CONCAT)/i,/^(?:COALESCE)/i,/^(?:IF)/i,/^(?:TRIPLE)/i,/^(?:REGEX)/i,/^(?:SUBSTR)/i,/^(?:REPLACE)/i,/^(?:EXISTS)/i,/^(?:COUNT)/i,/^(?:SUM|MIN|MAX|AVG|SAMPLE)/i,/^(?:GROUP_CONCAT)/i,/^(?:SEPARATOR)/i,/^(?:\^\^)/i,/^(?:true|false)/i,/^(?:(<(?:[^<>\"\{\}\|\^`\\\u0000-\u0020])*>))/i,/^(?:((([A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]|[\uD800-\uDB7F][\uDC00-\uDFFF])(?:(?:(((?:([A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]|[\uD800-\uDB7F][\uDC00-\uDFFF])|_))|-|[0-9]|\u00B7|[\u0300-\u036F\u203F-\u2040])|\.)*(((?:([A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]|[\uD800-\uDB7F][\uDC00-\uDFFF])|_))|-|[0-9]|\u00B7|[\u0300-\u036F\u203F-\u2040]))?)?:))/i,/^(?:(((([A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]|[\uD800-\uDB7F][\uDC00-\uDFFF])(?:(?:(((?:([A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]|[\uD800-\uDB7F][\uDC00-\uDFFF])|_))|-|[0-9]|\u00B7|[\u0300-\u036F\u203F-\u2040])|\.)*(((?:([A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]|[\uD800-\uDB7F][\uDC00-\uDFFF])|_))|-|[0-9]|\u00B7|[\u0300-\u036F\u203F-\u2040]))?)?:)((?:((?:([A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]|[\uD800-\uDB7F][\uDC00-\uDFFF])|_))|:|[0-9]|((%([0-9A-Fa-f])([0-9A-Fa-f]))|(\\(_|~|\.|-|!|\$|&|'|\(|\)|\*|\+|,|;|=|\/|\?|#|@|%))))(?:(?:(((?:([A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]|[\uD800-\uDB7F][\uDC00-\uDFFF])|_))|-|[0-9]|\u00B7|[\u0300-\u036F\u203F-\u2040])|\.|:|((%([0-9A-Fa-f])([0-9A-Fa-f]))|(\\(_|~|\.|-|!|\$|&|'|\(|\)|\*|\+|,|;|=|\/|\?|#|@|%))))*(?:(((?:([A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]|[\uD800-\uDB7F][\uDC00-\uDFFF])|_))|-|[0-9]|\u00B7|[\u0300-\u036F\u203F-\u2040])|:|((%([0-9A-Fa-f])([0-9A-Fa-f]))|(\\(_|~|\.|-|!|\$|&|'|\(|\)|\*|\+|,|;|=|\/|\?|#|@|%)))))?)))/i,/^(?:(_:(?:((?:([A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]|[\uD800-\uDB7F][\uDC00-\uDFFF])|_))|[0-9])(?:(?:(((?:([A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]|[\uD800-\uDB7F][\uDC00-\uDFFF])|_))|-|[0-9]|\u00B7|[\u0300-\u036F\u203F-\u2040])|\.)*(((?:([A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]|[\uD800-\uDB7F][\uDC00-\uDFFF])|_))|-|[0-9]|\u00B7|[\u0300-\u036F\u203F-\u2040]))?))/i,/^(?:([\?\$]((?:((?:([A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]|[\uD800-\uDB7F][\uDC00-\uDFFF])|_))|[0-9])(?:((?:([A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]|[\uD800-\uDB7F][\uDC00-\uDFFF])|_))|[0-9]|\u00B7|[\u0300-\u036F\u203F-\u2040])*)))/i,/^(?:(@[a-zA-Z]+(?:-[a-zA-Z0-9]+)*))/i,/^(?:([0-9]+))/i,/^(?:([0-9]*\.[0-9]+))/i,/^(?:([0-9]+\.[0-9]*([eE][+-]?[0-9]+)|\.([0-9])+([eE][+-]?[0-9]+)|([0-9])+([eE][+-]?[0-9]+)))/i,/^(?:(\+([0-9]+)))/i,/^(?:(\+([0-9]*\.[0-9]+)))/i,/^(?:(\+([0-9]+\.[0-9]*([eE][+-]?[0-9]+)|\.([0-9])+([eE][+-]?[0-9]+)|([0-9])+([eE][+-]?[0-9]+))))/i,/^(?:(-([0-9]+)))/i,/^(?:(-([0-9]*\.[0-9]+)))/i,/^(?:(-([0-9]+\.[0-9]*([eE][+-]?[0-9]+)|\.([0-9])+([eE][+-]?[0-9]+)|([0-9])+([eE][+-]?[0-9]+))))/i,/^(?:([eE][+-]?[0-9]+))/i,/^(?:('(?:(?:[^\u0027\u005C\u000A\u000D])|(\\[tbnrf\\\"']|\\u([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])|\\U([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])))*'))/i,/^(?:("(?:(?:[^\u0022\u005C\u000A\u000D])|(\\[tbnrf\\\"']|\\u([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])|\\U([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])))*"))/i,/^(?:('''(?:(?:'|'')?(?:[^'\\]|(\\[tbnrf\\\"']|\\u([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])|\\U([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f]))))*'''))/i,/^(?:("""(?:(?:"|"")?(?:[^\"\\]|(\\[tbnrf\\\"']|\\u([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])|\\U([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f]))))*"""))/i,/^(?:(\((\u0020|\u0009|\u000D|\u000A)*\)))/i,/^(?:(\[(\u0020|\u0009|\u000D|\u000A)*\]))/i,/^(?:$)/i,/^(?:.)/i,/^(?:.)/i],conditions:{INITIAL:{rules:[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,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,115,116,117,118,119,120,121,122,123,124,125],inclusive:!0}}};function on(){this.yy={}}return si.lexer=nn,on.prototype=si,si.Parser=on,new on}();e.exports=n},637:e=>{class t{constructor(){return i||this}equals(e){return e&&this.termType===e.termType}}Object.defineProperty(t.prototype,"value",{enumerable:!0,value:"*"}),Object.defineProperty(t.prototype,"termType",{enumerable:!0,value:"Wildcard"});var i=new t;e.exports.t=t},82:(e,t,i)=>{var n=i(849).Parser,o=i(825),s=i(637).t,{DataFactory:r}=i(793);e.exports={Parser:function({prefixes:e,baseIRI:t,factory:i,sparqlStar:o,skipValidation:s,skipUngroupedVariableCheck:a,pathOnly:l}={}){var h={};for(var u in e||{})h[u]=e[u];var c=new n;return c.parse=function(){return n.base=t||"",n.prefixes=Object.create(h),n.factory=i||new r,n.sparqlStar=Boolean(o),n.pathOnly=Boolean(l),n.skipValidation=Boolean(s)||Boolean(a),n.prototype.parse.apply(c,arguments)},c._resetBlanks=n._resetBlanks,c},Generator:o,Wildcard:s}},180:e=>{"use strict";e.exports=window.Blockly},500:function(e,t,i){var n,o;void 0===(o="function"==typeof(n=function(){var e,t,n,o,s,r,a,l,h,u,c,d,p,g,E,T,_,f,m,b,C,v,I,N,y,A,k,S,O,R,w,L,D,x,F,M,P,B,U,V,H,G,W,q,$,j,z,X,Y,K,J,Q,Z,ee,te,ie,ne,oe,se,re,ae,le,he,ue,ce,de,pe,ge,Ee,Te,_e,fe,me,be,Ce,ve,Ie,Ne,ye,Ae,ke,Se,Oe,Re,we,Le,De,xe,Fe,Me,Pe,Be,Ue,Ve,He,Ge,We,qe,$e,je,ze,Xe,Ye,Ke,Je,Qe,Ze,et,tt,it,nt,ot,st,rt,at,lt,ht,ut,ct,dt,pt,gt,Et,Tt,_t,ft,mt,bt,Ct,vt,It,Nt,yt,At,kt,St,Ot,Rt,wt,Lt,Dt,xt,Ft,Mt,Pt,Bt,Ut,Vt,Ht,Gt,Wt,qt,$t,jt,zt,Xt,Yt,Kt,Jt,Qt,Zt,ei,ti,ii,ni,oi,si,ri,ai,li,hi,ui,ci,di,pi,gi,Ei,Ti,_i,fi,mi,bi,Ci,vi,Ii,Ni,yi,Ai,ki,Si,Oi,Ri,wi,Li,Di,xi,Fi,Mi,Pi,Bi,Ui,Vi,Hi,Gi,Wi,qi,$i,ji,zi,Xi,Yi,Ki,Ji,Qi,Zi,en,tn,nn,on,sn,rn,an,ln,hn,un,cn,dn,pn,gn,En,Tn,_n,fn,mn,bn,Cn,vn,In,Nn,yn,An,kn,Sn,On,Rn,wn,Ln,Dn,xn,Fn,Mn,Pn,Bn,Un,Vn,Hn,Gn,Wn,qn,$n,jn,zn,Xn,Yn,Kn,Jn,Qn,Zn,eo,to,io,no,oo,so,ro,ao,lo,ho,uo,co,po,go,Eo,To,_o,fo,mo,bo,Co,vo,Io,No,yo,Ao,ko,So,Oo,Ro,wo,Lo,Do,xo,Fo,Mo,Po,Bo,Uo,Vo,Ho,Go,Wo,qo,$o,jo,zo,Xo,Yo,Ko,Jo,Qo,Zo,es,ts,is,ns,os,ss,rs,as,ls,hs,us,cs,ds,ps,gs,Es,Ts,_s,fs,ms,bs,Cs,vs,Is,Ns,ys,As,ks,Ss,Os,Rs,ws,Ls,Ds,xs,Fs,Ms,Ps,Bs,Us,Vs,Hs,Gs,Ws,qs,$s,js,zs,Xs,Ys,Ks,Js,Qs,Zs={};e=function(e,i){t(),gr=setTimeout((function(){i&&i.handleRightClick(e)}),750)},t=function(){gr&&(clearTimeout(gr),gr=0)},n=function(e){return!e.type.startsWith("pointer")||e instanceof PointerEvent&&s(e)},o=function(e){return`${e.pointerId}`},s=function(e){var t=o(e);return dr?dr===t:"pointerdown"===e.type&&(dr=t,!0)},r=function(e,t,i,o,s,r){function a(e){(s||n(e))&&(i?o.call(i,e):o(e))}var l=[];if(t in pr)for(let i=0;i<pr[t].length;i++){let n=pr[t][i];e.addEventListener(n,a,Object.assign({},{capture:!1},r)),l.push([e,n,a])}else e.addEventListener(t,a,Object.assign({},{capture:!1},r)),l.push([e,t,a]);return l},a=function(e,t,i,n,o){function s(e){i?n.call(i,e):n(e)}var r=[];if(t in pr)for(let i=0;i<pr[t].length;i++){let n=pr[t][i];e.addEventListener(n,s,Object.assign({},{capture:!1},o)),r.push([e,n,s])}else e.addEventListener(t,s,Object.assign({},{capture:!1},o)),r.push([e,t,s]);return r},l=function(e){for(var t=e[e.length-1][2];e.length;){let[t,i,n]=e.pop();t.removeEventListener(i,n,!1)}return t},h=function(e){if(e.target instanceof HTMLElement){if(e.target.isContentEditable||"true"===e.target.getAttribute("data-is-text-input"))return!0;if(e.target instanceof HTMLInputElement)return"text"===(e=e.target).type||"number"===e.type||"email"===e.type||"password"===e.type||"search"===e.type||"tel"===e.type||"url"===e.type;if(e.target instanceof HTMLTextAreaElement)return!0}return!1},u=function(e){return!(!e.ctrlKey||!Cr)||2===e.button},c=function(e,t,i){var n=t.createSVGPoint();return n.x=e.clientX,n.y=e.clientY,i||(i=t.getScreenCTM().inverse()),n.matrixTransform(i)},d=function(e){switch(e.deltaMode){default:return{x:e.deltaX,y:e.deltaY};case 1:return{x:40*e.deltaX,y:40*e.deltaY};case 2:return{x:125*e.deltaX,y:125*e.deltaY}}},p=function(e,t){return-1!==(t=e.indexOf(t))&&(e.splice(t,1),!0)},g=function(e){Lr.push(e)},E=function(e,t,i){t&&"undefined"!=typeof window&&(e=e.getRootNode(),wr.has(e)||(wr.add(e),i=i.replace(/[\\/]$/,""),i=[Dr,...Lr].join("\n").replace(/<<<PATH>>>/g,i),(t=document.createElement("style")).id="blockly-common-style",t.textContent=i,(void 0!==globalThis.ShadowRoot&&e instanceof ShadowRoot?e:document.head).prepend(t)))},T=function(e){e.removeAttribute("role")},_=function(e,t){t?e.setAttribute("role",t):T(e)},f=function(e,t,i){Array.isArray(i)&&(i=i.join(" ")),e.setAttribute("aria-"+t,`${i}`)},m=function(e,t){e.removeAttribute("aria-"+t)},b=function(e,t){return(e=e.getAttribute("aria-"+t))?e:null},C=function(e){if(!Jr||!document.contains(Jr)){var t=document.createElement("div");t.textContent="",t.id="blocklyAriaAnnounce",N(t,"hiddenForAria"),f(t,$r.LIVE,Pr.POLITE),_(t,jr),f(t,$r.ATOMIC,!0),e.appendChild(t),Jr=t}},v=function(e,t){if(!Jr)throw Error("ARIA live region not initialized.");var i=Jr,{assertiveness:n=Pr.POLITE,role:o=jr}=t||{};Wr.push(e),Gr=n===Pr.ASSERTIVE||Gr===Pr.ASSERTIVE?Pr.ASSERTIVE:n===Pr.POLITE||Gr===Pr.POLITE?Pr.POLITE:Pr.OFF,clearTimeout(Kr),Kr=setTimeout((()=>{i.replaceChildren(),f(i,$r.LIVE,Gr),_(i,o);var e=document.createElement("span");e.textContent=Wr.join("\n")+(Qr?" ":""),Qr=!Qr,i.appendChild(e),Wr.length=0,Gr=Pr.OFF}),10)},I=function(e,t,i){var n=document.createElementNS("http://www.w3.org/2000/svg",`${e}`);e!==ea.SVG.toString()&&e!==ea.G.toString()&&n.tagName!==ea.SVG.toString()&&n.tagName!==ea.G.toString()||_(n,Hr.NONE);for(let e in t)n.setAttribute(e,`${t[e]}`);return i&&i.appendChild(n),n},N=function(e,t){return!(t=t.split(" ")).every((t=>e.classList.contains(t)))&&(e.classList.add(...t),!0)},y=function(e,t){e.classList.remove(...t.split(" "))},A=function(e,t){return!(t=t.split(" ")).every((t=>!e.classList.contains(t)))&&(e.classList.remove(...t),!0)},k=function(e,t){return e.classList.contains(t)},S=function(e){return e&&e.parentNode?e.parentNode.removeChild(e):null},O=function(e,t){var i=t.nextSibling;if(!(t=t.parentNode))throw Error("Reference node has no parent.");i?t.insertBefore(e,i):t.appendChild(e)},R=function(e,t){e.style.transform=t,e.style["-webkit-transform"]=t},w=function(){oa++,na||(na=Object.create(null))},L=function(){--oa||(na=null)},D=function(e){var t,i=e.textContent+"\n"+e.className.baseVal;return na&&(t=na[i])||(t=window.getComputedStyle(e),t=x(e,t.fontSize,t.fontWeight,t.fontFamily),na&&(na[i]=t)),t},x=function(e,t,i,n){var o,s=e.textContent;return e=s+"\n"+e.className.baseVal,na&&(o=na[e])||(sa||((o=document.createElement("canvas")).className="blocklyComputeCanvas",document.body.appendChild(o),sa=o.getContext("2d")),s&&sa?(sa.font=i+" "+t+" "+n,o=Math.ceil(sa.measureText(s).width)):o=0,na&&(na[e]=o)),o},F=function(e,t,i,n){var o=document.createElement("span");o.style.font=i+" "+t+" "+n,o.textContent=e,(e=document.createElement("div")).style.width="1px",e.style.height="0",(t=document.createElement("div")).style.display="flex",t.style.position="fixed",t.style.top="0",t.style.left="0",t.appendChild(o),t.appendChild(e),document.body.appendChild(t),i={height:0,baseline:0};try{t.style.alignItems="baseline",i.baseline=e.offsetTop-o.offsetTop,t.style.alignItems="flex-end",i.height=e.offsetTop-o.offsetTop}finally{document.body.removeChild(t)}return i},Zs.t=function(){return ha.getFocusManager()},M=function(e){return e&&"function"==typeof e.getFocusableElement&&"function"==typeof e.getFocusableTree&&"function"==typeof e.onNodeFocus&&"function"==typeof e.onNodeBlur&&"function"==typeof e.canBeFocused},P=function(e){return M(e)&&"string"==typeof e.id&&"object"==typeof e.workspace&&"function"==typeof e.select&&"function"==typeof e.unselect},B=function(e,t){for(let i in t)null!==t[i]&&Array.isArray(t[i])?e[i]=B(e[i]||[],t[i]):e[i]=null!==t[i]&&"object"==typeof t[i]?B(e[i]||Object.create(null),t[i]):t[i];return e},U=function(e,t,i,n){e=e+" was deprecated in "+t+" and will be deleted in "+i+".",n&&(e+="\nUse "+n+" instead."),ga.has(e)||(ga.add(e),console.warn(e))},V=function(e){return fa[e]||null},H=function(){var e=[];for(let t in fa)e.push(fa[t]);return e},G=function(e){fa[e.id]=e},W=function(e){delete fa[e.id]},q=function(){return Ta},$=function(e){Ta=e,e.rendered&&Zs.t().setPopoverFocusRoot(e.getInjectionDiv())},j=function(){var e=Zs.t().getFocusedNode();return e&&P(e)?e:null},z=function(e){var t,i,n,o,s=j(),r=new(_e(Fr.SELECTED))(null!=(t=null==s?void 0:s.id)?t:null,null!=(i=null==e?void 0:e.id)?i:null,null!=(o=null!=(n=null==e?void 0:e.workspace.id)?n:null==s?void 0:s.workspace.id)?o:"");ue(r)},X=function(e=Ta){return _a||(e&&e.rendered?e.getInjectionDiv():null)},Y=function(e){_a=e},K=function(e){for(;e.options.parentWorkspace;)e=e.options.parentWorkspace;var t=e.getParentSvg(),i=e.getCachedParentSvgSize(),n=t.parentElement;if(n instanceof HTMLElement){var o=n.offsetWidth;n=n.offsetHeight,i.width!==o&&(t.setAttribute("width",o+"px"),e.setCachedParentSvgSize(o,null)),i.height!==n&&(t.setAttribute("height",n+"px"),e.setCachedParentSvgSize(null,n)),e.resize()}},J=function(e,t){var i=Object.create(null),n=e.getDescendants(!0);t&&(e=e.getNextBlock())&&(e=n.indexOf(e),n.splice(e,n.length-e));for(let e,t=0;e=n[t];t++)i[e.type]?i[e.type]++:i[e.type]=1;return i},Q=function(e){return function(){this.jsonInit(e)}},Z=function(e){ba.defineBlocksWithJsonArrayInternal(e)},Zs.yb=function(e){var t={};for(let i=0;i<e.length;i++){let n=e[i];if(!n){console.warn(`Block definition #${i} in JSON array is ${n}. Skipping`);continue}let o=n.type;o?t[o]={init:Q(n)}:console.warn(`Block definition #${i} in JSON array is missing a type attribute. Skipping.`)}return t},Zs.Ab=function(e){for(let t of Object.keys(e)){let i=e[t];t in Ur&&console.warn(`Block definition "${t}" overwrites previous definition.`),Ur[t]=i}},ee=function(e){var t=Ta,i=Zs.t().getFocusedTree();for(let e of H())if(i===e){t=e;break}h(e)||!t||t.rendered&&!t.isFlyout&&!t.isVisible()||ca.registry.onKeyDown(t,e)},te=function(e,t,i,n){if(!(e instanceof ya)&&"string"!=typeof e||""===`${e}`.trim())throw Error('Invalid type "'+e+'". The type must be a non-empty string or a Blockly.registry.Type.');if(e=`${e}`.toLowerCase(),"string"!=typeof t||""===t.trim())throw Error('Invalid name "'+t+'". The name must be a non-empty string.');var o=t.toLowerCase();if(!i)throw Error("Can not register a null value");var s=va[e],r=Na[e];if(s||(s=va[e]=Object.create(null),r=Na[e]=Object.create(null)),e===String(ya.FIELD)&&"function"!=typeof i.fromJson)throw Error('Type "'+e+'" must have a fromJson function');if(!n&&s[o]&&s[o]!==i)throw Error('Name "'+o+'" with type "'+e+'" already registered.');s[o]=i,r[o]=t},ie=function(e,t){e=`${e}`.toLowerCase(),t=t.toLowerCase();var i=va[e];i&&i[t]?(delete va[e][t],delete Na[e][t]):console.warn("Unable to unregister ["+t+"]["+e+"] from the registry.")},ne=function(e,t,i){e=`${e}`.toLowerCase(),t=t.toLowerCase();var n=va[e];if(!n||!n[t]){if(t="Unable to find ["+t+"]["+e+"] in the registry.",i)throw Error(t+" You must require or register a "+e+" plugin.");return console.warn(t),null}return n[t]},oe=function(e,t){return e=`${e}`.toLowerCase(),t=t.toLowerCase(),!!(e=va[e])&&!!e[t]},se=function(e,t,i){return ne(e,t,i)},re=function(e,t,i){e=`${e}`.toLowerCase();var n=va[e];if(!n){if(n=`Unable to find [${e}] in the registry.`,i)throw Error(`${n} You must require or register a ${e} plugin.`);return console.warn(n),null}if(!t)return n;e=Na[e],i=Object.create(null);for(let t of Object.keys(n))i[e[t]]=n[t];return i},ae=function(e,t,i){return"function"==typeof(t=t.plugins[String(e)]||"default")?t:ne(e,t,i)},le=function(){return"blockly-"+(wa++).toString(36)},he=function(){return Ra.genUid()},ue=function(e){Sa.fireInternal(e)},ce=function(){var e=pe(ka);ka.length=0;for(let t of e){if(!t.workspaceId)continue;let e;null==(e=V(t.workspaceId))||e.fireChangeListener(t)}},de=function(e){if(e.type===Fr.BLOCK_CHANGE&&"mutation"===e.element){let t;for(t=ka.length;t>0;t--){let i=ka[t-1];if(i.group!==e.group||i.workspaceId!==e.workspaceId||i.type!==Fr.BLOCK_MOVE||i.newParentId!==e.blockId)break}ka.splice(t,0,e)}else ka.push(e)},pe=function(e){var t=[];for(let i of e)if(e=t[t.length-1],!i.isNull())if(e&&e.workspaceId===i.workspaceId&&e.group===i.group)if(i.type===Fr.BLOCK_MOVE&&e.type===Fr.BLOCK_MOVE&&i.blockId===e.blockId){if(e.newParentId=i.newParentId,e.newInputName=i.newInputName,e.newCoordinate=i.newCoordinate,e.reason||i.reason){let t,n;e.reason=Array.from(new Set((null!=(t=e.reason)?t:[]).concat(null!=(n=i.reason)?n:[])))}}else i.type===Fr.BLOCK_CHANGE&&e.type===Fr.BLOCK_CHANGE&&i.blockId===e.blockId&&i.element===e.element&&i.name===e.name?e.newValue=i.newValue:i.type===Fr.VIEWPORT_CHANGE&&e.type===Fr.VIEWPORT_CHANGE?(e.viewTop=i.viewTop,e.viewLeft=i.viewLeft,e.scale=i.scale,e.oldScale=i.oldScale):i.type===Fr.CLICK&&e.type===Fr.BUBBLE_OPEN||(i.type===Fr.SELECTED&&e.type===Fr.SELECTED&&void 0===e.newElementId?(e.newElementId=i.newElementId,e.oldElementId===e.newElementId&&t.pop()):t.push(i));else t.push(i);return t.filter((e=>!e.isNull()))},ge=function(){for(let e,t=0;e=ka[t];t++)e.recordUndo=!1},Ee=function(){return 0===Zs.Ub},Zs.B=function(e){Sa.setGroupInternal(e)},Te=function(e){var t=[];e=e.getDescendants(!1);for(let i,n=0;i=e[n];n++)t[n]=i.id;return t},_e=function(e){var t=ne(ya.EVENT,e,void 0);if(!t)throw Error(`Event type ${e} not found in registry.`);return t},fe=function(e){Object.keys(e).forEach((function(t){Zs.C[t]=e[t]}))},me=function(e){return Ma.getSizeInternal(e)},be=function(e,t){return(e=window.getComputedStyle(e))[t]||e.getPropertyValue(t)},Ce=function(e){var t=new Da(0,0);e=e.getBoundingClientRect();var i=document.documentElement;return i=new Da(window.pageXOffset||i.scrollLeft,window.pageYOffset||i.scrollTop),t.x=e.left+i.x,t.y=e.top+i.y,t},ve=function(){var e=document.body,t=document.documentElement;return new Da(e.scrollLeft||t.scrollLeft,e.scrollTop||t.scrollTop)},Ie=function(e){var t=parseFloat(be(e,"borderLeftWidth")),i=parseFloat(be(e,"borderRightWidth")),n=parseFloat(be(e,"borderTopWidth"));return e=parseFloat(be(e,"borderBottomWidth")),new xa(n,e,t,i)},Ne=function(e,t,i){var n=i.getBoundingClientRect();return i=Ie(i),new Da(e-(n.left+window.scrollX+i.left),t-(n.top+window.scrollY+i.top))},ye=function(e,t,i){e=Ae(e,t,i),t.scrollLeft=e.x,t.scrollTop=e.y},Ae=function(e,t,i){var n=Ce(e),o=Ce(t),s=Ie(t),r=n.x-o.x-s.left;return n=n.y-o.y-s.top,o=new Fa(e.offsetWidth,e.offsetHeight),e=t.clientWidth-o.width,o=t.clientHeight-o.height,s=t.scrollLeft,t=t.scrollTop,i?(s+=r-e/2,t+=n-o/2):(s+=Math.min(r,Math.max(r-e,0)),t+=Math.min(n,Math.max(n-o,0))),new Da(s,t)},ke=function(e){var t=new Da(0,0),i=e.x&&e.getAttribute("x"),n=e.y&&e.getAttribute("y");return i&&(t.x=parseInt(i)),n&&(t.y=parseInt(n)),(i=(i=e.getAttribute("transform"))&&i.match(Ba))&&(t.x+=Number(i[1]),i[3]&&(t.y+=Number(i[3]))),(e=e.getAttribute("style"))&&e.includes("translate")&&(e=e.match(Ua))&&(t.x+=Number(e[1]),e[3]&&(t.y+=Number(e[3]))),t},Se=function(e){for(var t=0,i=0;e;){let n=ke(e);if(t+=n.x,i+=n.y,(" "+(e.getAttribute("class")||"")+" ").includes(" injectionDiv "))break;e=e.parentNode}return new Da(t,i)},Oe=function(){var e=ve();return new xa(e.y,document.documentElement.clientHeight+e.y,e.x,document.documentElement.clientWidth+e.x)},Re=function(){var e=document.documentElement,t=window;return new Da(t.pageXOffset||e.scrollLeft,t.pageYOffset||e.scrollTop)},we=function(e,t){var i=t.x;t=t.y;var n=e.getInjectionDiv().getBoundingClientRect();return i=new Da(i-n.left,t-n.top),t=e.getOriginOffsetInPixels(),Da.difference(i,t).scale(1/e.scale)},Le=function(e,t){var i=t.scale(e.scale);t=i.x,i=i.y;var n=e.getInjectionDiv().getBoundingClientRect();return e=e.getOriginOffsetInPixels(),new Da(t+n.left+e.x,i+n.top+e.y)},Zs.sc=function(e){return qa.createElementNS("https://developers.google.com/blockly/xml",e)},Zs.tc=function(e){return qa.createTextNode(e)},Zs.vc=function(e){var t=Ga.parseFromString(e,"text/xml");if(t&&t.documentElement&&!t.getElementsByTagName("parsererror").length)return t.documentElement;if((t=Ga.parseFromString(e,"text/html"))&&t.body.firstChild&&"xml"===t.body.firstChild.nodeName.toLowerCase())return t.body.firstChild;throw Error(`DOMParser was unable to parse: ${e}`)},De=function(e){return xe(Wa.serializeToString(e))},xe=function(e){return e.replace(za,(e=>`&#${e.charCodeAt(0)};`))},Fe=function(e){if(!e)return null;if(e instanceof Element||"string"==typeof e){e=He(e);var t={contents:Ue(e)};e instanceof Node&&Ve(e,t),e=t}t=e.kind;var i=e.contents;if(t&&"flyoutToolbox"!==t&&"categoryToolbox"!==t)throw Error("Invalid toolbox kind "+t+". Please supply either flyoutToolbox or categoryToolbox");if(!i)throw Error("Toolbox must have a contents attribute.");return e},Me=function(e){return e?e.contents?e.contents:Array.isArray(e)&&e.length>0&&!e[0].nodeType?e:Ue(e):[]},Pe=function(e){if(!e)return!1;var t=e.kind;return t?"categoryToolbox"===t:!!e.contents.filter((e=>"CATEGORY"===e.kind.toUpperCase())).length},Be=function(e){return!(!e||!e.contents||!e.contents.filter((function(e){return"CATEGORY"===e.kind.toUpperCase()})).length)},Ue=function(e){var t=[],i=e.childNodes;i||(i=e);for(let n,o=0;n=i[o];o++){if(!n.tagName)continue;e={};let i=n.tagName.toUpperCase();e.kind=i,"BLOCK"===i?e.blockxml=n:n.childNodes&&n.childNodes.length>0&&(e.contents=Ue(n)),Ve(n,e),t.push(e)}return t},Ve=function(e,t){for(let i=0;i<e.attributes.length;i++){let n=e.attributes[i];n.nodeName.includes("css-")?(t.cssconfig=t.cssconfig||{},t.cssconfig[n.nodeName.replace("css-","")]=n.value):t[n.nodeName]=n.value}},He=function(e){var t=null;if(e)if("string"==typeof e){if("xml"!==(t=Zs.vc(e)).nodeName.toLowerCase())throw TypeError("Toolbox should be an <xml> document.")}else e instanceof Element&&(t=e);return t},Ge=function(e,t,i,n,o,s){var r=s.scrollbar&&s.scrollbar.canScrollVertically();return e.horizontal===el.LEFT?(i=o.absoluteMetrics.left+i,r&&s.RTL&&(i+=Ha.scrollbarThickness)):(i=o.absoluteMetrics.left+o.viewMetrics.width-t.width-i,r&&!s.RTL&&(i-=Ha.scrollbarThickness)),e.vertical===Qa.TOP?e=o.absoluteMetrics.top+n:(e=o.absoluteMetrics.top+o.viewMetrics.height-t.height-n,s.scrollbar&&s.scrollbar.canScrollHorizontally()&&(e-=Ha.scrollbarThickness)),new xa(e,e+t.height,i,i+t.width)},We=function(e,t){return{horizontal:t.toolboxMetrics.position===Ya.LEFT||e.horizontalLayout&&!e.RTL?el.RIGHT:el.LEFT,vertical:t.toolboxMetrics.position===Ya.BOTTOM?Qa.TOP:Qa.BOTTOM}},qe=function(e,t,i,n){var o=e.left,s=e.right-e.left,r=e.bottom-e.top;for(let a=0;a<n.length;a++){let l=n[a];e.intersects(l)&&(e=i===il.UP?l.top-r-t:l.bottom+t,e=new xa(e,e+r,o,o+s),a=-1)}return e},$e=function(e,t){te(ya.SERIALIZER,e,t)},je=function(e,{addCoordinates:t=!1,saveIds:i=!0}={}){var n=e.workspace,o=Object.create(null);return o.height=e.getSize().height,o.width=e.getSize().width,i&&(o.id=e.id),t&&(t=e.getRelativeToSurfaceXY(),o.x=n.RTL?n.getWidth()-t.x:t.x,o.y=t.y),e.getText()&&(o.text=e.getText()),e.isCollapsed()&&(o.collapsed=!0),e.isOwnEditable()||(o.editable=!1),e.isOwnMovable()||(o.movable=!1),e.isOwnDeletable()||(o.deletable=!1),o},ze=function(e,t,{recordUndo:i=!1}={}){var n=Zs.Qc;if(Zs.Qc=i,i=t.newComment(e.id),void 0!==e.x||void 0!==e.y){let n,s=i.getRelativeToSurfaceXY(),r=null!=(n=e.x)?n:s.x;var o;r=t.RTL?t.getWidth()-r:r,t=null!=(o=e.y)?o:s.y,i.moveTo(new Da(r,t))}if(void 0!==e.width||e.height){let t,n;o=i.getSize(),i.setSize(new Fa(null!=(t=e.width)?t:o.width,null!=(n=e.height)?n:o.height))}return void 0!==e.text&&i.setText(e.text),void 0!==e.collapsed&&i.setCollapsed(e.collapsed),void 0!==e.editable&&i.setEditable(e.editable),void 0!==e.movable&&i.setMovable(e.movable),void 0!==e.deletable&&i.setDeletable(e.deletable),Zs.Qc=n,i},Xe=function(e,t){te(ya.PASTER,e,t)},Ye=function(e){for(var t=e.workspace,i=e.getRelativeToSurfaceXY(),n=new Da(0,0),o=t.getTopComments(!1).filter((t=>t.id!==e.id)).map((e=>e.getRelativeToSurfaceXY()));Ke(Da.sum(i,n),o);)n.translate(t.RTL?-30:30,30);e.moveTo(Da.sum(i,n))},Ke=function(e,t){return t.some((t=>Math.abs(t.x-e.x)<=1&&Math.abs(t.y-e.y)<=1))},Je=function(e){return e&&"function"==typeof e.saveState&&"function"==typeof e.loadState},Qe=function(e){return tt(e),Tr?(it(),Promise.resolve()):(yl||(yl=new Promise((e=>{Al=e,kl=window.requestAnimationFrame((()=>{it(),e()}))}))),yl)},Ze=function(){return yl||Promise.resolve()},et=function(e){e||window.cancelAnimationFrame(kl),it(e),!e&&Al&&Al()},tt=function(e){Il.add(e),Nl.set(e,{group:Zs.gd,recordUndo:Zs.Qc});var t=e.getParent();t?tt(t):vl.add(e)},it=function(e){var t=e?new Set([e]):new Set([...vl].map((e=>e.workspace))),i=[...vl].filter(ot).filter((e=>t.has(e.workspace)));for(var n of i)st(n);for(let e of t)e.resizeContents(),e.connectionDBList.forEach((e=>null==e?void 0:e.beginBulkUpdates()));for(var o of i)n=o.getRelativeToSurfaceXY(),o.updateComponentLocations(n);for(var s of t)s.connectionDBList.forEach((e=>null==e?void 0:e.endBulkUpdates()));for(let e of i)o=Zs.gd,s=Zs.Qc,(n=Nl.get(e))&&(n.group&&Zs.B(n.group),Zs.Qc=n.recordUndo),e.bumpNeighbours(),Zs.B(o),Zs.Qc=s;for(let e of i)nt(e);e||(yl=null)},nt=function(e){vl.delete(e),Il.delete(e),Nl.delete(e);for(let t of e.getChildren(!1))nt(t)},ot=function(e){return!e.isDisposed()&&!e.getParent()},st=function(e){if(Il.has(e)&&e.initialized){for(let t of e.getChildren(!1))st(t);e.renderEfficiently()}},rt=function(e,t){dt(Rl.ALERT,e,t,void 0)},at=function(e,t){dt(Rl.CONFIRM,e,t,void 0)},lt=function(e,t,i){dt(Rl.PROMPT,e,i,t)},ht=function(e,t){Dl(e,t)},ut=function(e,t){xl(e,t)},ct=function(e,t,i){Fl(e,t,i)},dt=function(...[e,t,i,n]){var o,s=document.createElement("dialog"),r=document.createElement("form"),a=document.createElement("label"),l=document.createElement("input"),h=document.createElement("div"),u=document.createElement("button");s.className="blocklyDialog",r.className="blocklyDialogForm",a.className="blocklyDialogPrompt",h.className="blocklyDialogButtonRow",u.className="blocklyDialogConfirmButton",r.setAttribute("method","dialog"),a.textContent=t,a.setAttribute("for","blockly-form-input"),u.textContent=Zs.C.DIALOG_OK,u.value="ok",s.appendChild(r),r.appendChild(a),e===Rl.PROMPT&&(l.id="blockly-form-input",l.className="blocklyDialogInput",l.type="text",l.name="input",l.autofocus=!0,n&&(l.value=n),r.appendChild(l)),h.appendChild(u),e!==Rl.CONFIRM&&e!==Rl.PROMPT||((t=document.createElement("button")).className="blocklyDialogCancelButton",t.textContent=Zs.C.DIALOG_CANCEL,t.value="cancel",h.appendChild(t)),r.appendChild(h),0===Ll&&(o=Zs.t().ephemeralFocusTaken()?void 0:Zs.t().takeEphemeralFocus(s)),Ll++,s.addEventListener("close",(()=>{if(! --Ll){let e;null==(e=o)||e()}switch(s.remove(),e){case Rl.CONFIRM:i("ok"===s.returnValue);break;case Rl.PROMPT:i("ok"===s.returnValue?l.value:null);break;case Rl.ALERT:null==i||i()}})),document.body.appendChild(s),s.showModal()},pt=function(e){return"function"==typeof e.bubbleIsVisible&&"function"==typeof e.setBubbleVisible&&"function"==typeof e.getBubble},gt=function(e,t){return t.map((t=>e.getBlockById(t))).filter((e=>e&&e.isShadow())).length===t.length},Et=function(e){return e&&"function"==typeof e.getProcedureDef},Tt=function(e){return void 0!==e.getVariableModel},Zs.Bd=function(e){e=e.getAllBlocks(!1);var t=new Set;for(let i=0;i<e.length;i++){let n=e[i].getVarModels();if(n)for(let e=0;e<n.length;e++){let i=n[e];i.getId()&&t.add(i)}}return Array.from(t.values())},Zs.Cd=function(e){e=e.getAllBlocks(!1);var t=new Set;for(let n,o=0;n=e[o];o++){var i=n.getDeveloperVariables;if(i){i=i();for(let e=0;e<i.length;e++)t.add(i[e])}}return Array.from(t.values())},_t=function(e){return Ur.variables_set||Ur.variables_get||console.warn("There are no variable blocks, but there is a variable category."),e.registerButtonCallback("CREATE_VARIABLE",(function(e){vt(e.getTargetWorkspace())})),[{kind:"button",text:"%{BKY_NEW_VARIABLE}",callbackkey:"CREATE_VARIABLE"},...mt(e,e.getVariableMap().getVariablesOfType(""),!0)]},ft=function(e){return{VAR:{name:e.getName(),type:e.getType()}}},mt=function(e,t,i,n="variables_get",o="variables_set"){i&&(i=Ur.math_change),e=[];var s=t.slice(-1)[0];return s&&(Ur[o]&&e.push({kind:"block",type:o,gap:i?8:24,fields:ft(s)}),i&&e.push({kind:"block",type:"math_change",gap:Ur[n]?20:8,fields:ft(s),inputs:{DELTA:{shadow:{type:"math_number",fields:{NUM:1}}}}})),Ur[n]&&e.push(...t.sort(wt).map((e=>({kind:"block",type:n,gap:8,fields:ft(e)})))),e},bt=function(e){return Kh.generateUniqueNameInternal(e)},Ct=function(e,t){if(!t.length)return e;for(var i="",n="ijkmnopqrstuvwxyzabcdefgh".indexOf(e);;){let o=!1;for(let i=0;i<t.length;i++)if(t[i].toLowerCase()===e){o=!0;break}if(!o)break;25==++n&&(n=0,i=`${Number(i)+1}`),e="ijkmnopqrstuvwxyzabcdefgh".charAt(n)+i}return e},vt=function(e,t,i){var n=i||"";!function i(o){It(Zs.C.NEW_VARIABLE_TITLE,o,(function(o){if(o){var s=yt(o,e);if(s){if(s.getType()===n)var r=Zs.C.VARIABLE_ALREADY_EXISTS.replace("%1",s.getName());else r=(r=Zs.C.VARIABLE_ALREADY_EXISTS_FOR_ANOTHER_TYPE).replace("%1",s.getName()).replace("%2",s.getType());ht(r,(function(){i(o)}))}else{let i=e.getVariableMap().createVariable(o,n);t&&t(o);let s=null==(r=e.getFlyout())?void 0:r.getWorkspace();if(s&&Xh.getIsActive()){var a=e=>{e.type===Zs.Od&&(e=e.blockId)&&(e=s.getBlockById(e))&&"variables_set"===e.type&&e.getFieldValue("VAR")===i.getId()&&(Zs.t().focusNode(e),s.removeChangeListener(a))};s.addChangeListener(a)}}}else t&&t(null)}))}("")},Zs.Rd=function(e,t,i){!function n(o){var s=Zs.C.RENAME_VARIABLE_TITLE.replace("%1",t.getName());It(s,o,(function(o){if(o){var s=Nt(o,t.getType(),e),r=At(t.getName(),o,e);if(s||r){var a="";s?a=Zs.C.VARIABLE_ALREADY_EXISTS_FOR_ANOTHER_TYPE.replace("%1",s.getName()).replace("%2",s.getType()):r&&(a=Zs.C.VARIABLE_ALREADY_EXISTS_FOR_A_PARAMETER.replace("%1",o).replace("%2",r)),ht(a,(function(){n(o)}))}else e.getVariableMap().renameVariable(t,o),i&&i(o)}else i&&i(null)}))}("")},It=function(e,t,i){ct(e,t,(function(e){e&&((e=e.replace(/[\s\xa0]+/g," ").trim())===Zs.C.RENAME_VARIABLE||e===Zs.C.NEW_VARIABLE)&&(e=null),i(e)}))},Nt=function(e,t,i){i=i.getVariableMap().getAllVariables(),e=e.toLowerCase();for(let n,o=0;n=i[o];o++)if(n.getName().toLowerCase()===e&&n.getType()!==t)return n;return null},yt=function(e,t){t=t.getVariableMap().getAllVariables(),e=e.toLowerCase();for(let i,n=0;i=t[n];n++)if(i.getName().toLowerCase()===e)return i;return null},At=function(e,t,i){return i.getProcedureMap().getProcedures().length?kt(e,t,i):St(e,t,i)},kt=function(e,t,i){e=e.toLowerCase(),t=t.toLowerCase(),i=i.getProcedureMap().getProcedures();for(let o of i){var n=o.getParameters().filter(Tt).map((e=>e.getVariableModel().getName()));if(n&&(i=n.some((t=>t.toLowerCase()===e)),n=n.some((e=>e.toLowerCase()===t)),i&&n))return o.getName()}return null},St=function(e,t,i){e=e.toLowerCase(),t=t.toLowerCase(),i=i.getAllBlocks(!1);for(let o of i){if(!Et(o))continue;var n=(i=o.getProcedureDef())[1];let s=n.some((t=>t.toLowerCase()===e));if(n=n.some((e=>e.toLowerCase()===t)),s&&n)return i[0]}return null},Ot=function(e){var t=Zs.sc("field");return t.setAttribute("name","VAR"),t.setAttribute("id",e.getId()),t.setAttribute("variabletype",e.getType()),e=Zs.tc(e.getName()),t.appendChild(e),t},Zs.Wd=function(e,t,i,n){var o=Zs.Vd(e,t,i,n);if(!o){o=e.getVariableMap();let s=e.getPotentialVariableMap();i||(i=bt(e.isFlyout?e.targetWorkspace:e)),o=s?s.createVariable(i,n,null!=t?t:void 0):o.createVariable(i,n,t)}return o},Zs.Vd=function(e,t,i,n){var o=e.getPotentialVariableMap(),s=null;if(t&&(!(s=e.getVariableMap().getVariableById(t))&&o&&(s=o.getVariableById(t)),s))return s;if(i){if(void 0===n)throw Error("Tried to look up a variable by name without a type");!(s=e.getVariableMap().getVariable(i,n))&&o&&(s=o.getVariable(i,n))}return s},Rt=function(e,t){e=e.getVariableMap().getAllVariables();var i=[];if(t.length!==e.length)for(let n=0;n<e.length;n++){let o=e[n];t.includes(o)||i.push(o)}return i},wt=function(e,t){return Yh.compare(e.getName(),t.getName())},Lt=function(e,t){var i=[];e=e.getAllBlocks(!1);for(let n=0;n<e.length;n++){let o=e[n].getVarModels();if(o)for(let s=0;s<o.length;s++)o[s].getId()===t&&i.push(e[n])}return i},Zs.$d=function(e,t,i){var n=t.getName(),o=Lt(e,t.getId());for(let e=o.length-1;e>=0;e--){let t=o[e];if("procedures_defnoreturn"===t.type||"procedures_defreturn"===t.type)return i=String(t.getFieldValue("NAME")),n=Zs.C.CANNOT_DELETE_VARIABLE_PROCEDURE.replace("%1",n).replace("%2",i),void Dl(n,void 0);t===i&&o.splice(e,1)}i&&o.length||o.length>1?(n=Zs.C.DELETE_VARIABLE_CONFIRMATION.replace("%1",String(o.length+(i&&!i.workspace.isFlyout?1:0))).replace("%2",n),ut(n,(i=>{i&&t&&e.getVariableMap().deleteVariable(t)}))):e.getVariableMap().deleteVariable(t)},Dt=function(e,{addCoordinates:t=!1,addInputBlocks:i=!0,addNextBlocks:n=!0,doFullSerialization:o=!0,saveIds:s=!0}={}){if(e.isInsertionMarker())return null;var r={type:e.type,id:s?e.id:void 0};if(t){t=e.workspace;var a=e.getRelativeToSurfaceXY();r.x=Math.round(t.RTL?t.getWidth()-a.x:a.x),r.y=Math.round(a.y)}for(var l of(e.isCollapsed()&&(r.collapsed=!0),e.isEnabled()||(r.disabledReasons=Array.from(e.getDisabledReasons())),e.isOwnDeletable()||(r.deletable=!1),e.isOwnMovable()||(r.movable=!1),e.isOwnEditable()||(r.editable=!1),void 0!==e.inputsInline&&e.inputsInline!==e.inputsInlineDefault&&(r.inline=e.inputsInline),e.data&&(r.data=e.data),e.saveExtraState?null!==(t=e.saveExtraState(o))&&(r.extraState=t):e.mutationToDom&&null!==(t=e.mutationToDom())&&(r.extraState=Nn(t).replace(' xmlns="https://developers.google.com/blockly/xml"',"")),t=Object.create(null),e.getIcons()))Je(l)&&(a=l.saveState(o))&&(t[l.getType().toString()]=a);for(var h of(Object.keys(t).length&&(r.icons=t),l=Object.create(null),e.getFields()))h.isSerializable()&&(l[h.name]=h.saveState(o));if(Object.keys(l).length&&(r.fields=l),i){for(i=Object.create(null),h=0;h<e.inputList.length;h++)(l=e.inputList[h]).connection&&(t=xt(l.connection,o,s))&&(i[l.name]=t);Object.keys(i).length&&(r.inputs=i)}return n&&e.nextConnection&&(e=xt(e.nextConnection,o,s))&&(r.next=e),r},xt=function(e,t,i){var n=e.getShadowState(!0);if(e=e.targetBlock(),!n&&!e)return null;var o=Object.create(null);return n&&(o.shadow=n),e&&!e.isShadow()&&(o.block=Dt(e,{doFullSerialization:t,saveIds:i})),o},Ft=function(e,t,{recordUndo:i=!1}={}){return e=Mt(e,t,{recordUndo:i}),t.rendered&&et(),e},Mt=function(e,t,{parentConnection:i,isShadow:n=!1,recordUndo:o=!1}={}){var s=Zs.Qc;Zs.Qc=o,(o=Zs.gd)||Zs.B(!0),Zs.Ub++;var r=t.getVariableMap().getAllVariables();try{var a=Pt(e,t,{parentConnection:i,isShadow:n})}finally{Zs.Ub--}if(Bt(t,r),Ee()&&ue(new(_e(Fr.BLOCK_CREATE))(a)),Zs.B(o),Zs.Qc=s,t.rendered){let e=a;setTimeout((()=>{e.disposed||e.setConnectionTracking(!0)}),1)}return a},Pt=function(e,t,{parentConnection:i,isShadow:n=!1}={}){if(!e.type)throw new Zh(e);var o=t.newBlock(e.type,e.id);o.setShadow(n),n=void 0===e.x?0:e.x;var s=void 0===e.y?0:e.y,r=o.workspace;if(n=r.RTL?r.getWidth()-n:n,o.moveBy(n,s),e.collapsed&&o.setCollapsed(!0),!1===e.deletable&&o.setDeletable(!1),!1===e.movable&&o.setMovable(!1),!1===e.editable&&o.setEditable(!1),!1===e.enabled&&o.setDisabledReason(!0,"MANUALLY_DISABLED"),Array.isArray(e.disabledReasons))for(var a of e.disabledReasons)o.setDisabledReason(!0,a);if(void 0!==e.inline&&o.setInputsInline(e.inline),void 0!==e.data&&(o.data=e.data),e.extraState&&(o.loadExtraState?o.loadExtraState(e.extraState):o.domToMutation&&o.domToMutation(Zs.vc(e.extraState))),i){if(i.getSourceBlock().isShadow()&&!o.isShadow())throw new iu(e);if(i.type===Zs.je.VALUE){if(!(a=o.outputConnection))throw new eu("output",o,e)}else if(!(a=o.previousConnection))throw new eu("previous",o,e);if(!i.connect(a))throw t=o.workspace.connectionChecker,new tu(t.getErrorMessage(t.canConnectWithReason(a,i,!1),a,i),i.type===Zs.je.VALUE?"output connection":"previous connection",o,e)}if(e.icons)for(var l of i=Object.keys(e.icons)){if(i=e.icons[l],!(a=o.getIcon(l))){if(!(a=ne(ya.ICON,l,!1)))throw new nu(l,o,e);a=new a(o),o.addIcon(a)}Je(a)&&a.loadState(i)}if(e.fields)for(l=Object.keys(e.fields),i=0;i<l.length;i++)a=l[i],n=e.fields[a],(s=o.getField(a))?s.loadState(n):console.warn(`Ignoring non-existant field ${a} in block ${o.type}`);if(e.inputs)for(l=Object.keys(e.inputs),i=0;i<l.length;i++){if(a=l[i],!(n=o.getInput(a))||!n.connection)throw new eu(a,o,e);Ut(n.connection,e.inputs[a])}if(e.next){if(!o.nextConnection)throw new eu("next",o,e);Ut(o.nextConnection,e.next)}if(t.rendered){o.setConnectionTracking(!1),o.initSvg(),o.queueRender();for(let e of o.getIcons())e.onLocationChange(o.getRelativeToSurfaceXY())}else o.initModel();return o},Bt=function(e,t){if(Ee())for(e=Rt(e,t),t=0;t<e.length;t++){let i=e[t];ue(new(_e(Fr.VAR_CREATE))(i))}},Ut=function(e,t){t.shadow&&e.setShadowState(t.shadow),t.block&&Pt(t.block,e.getSourceBlock().workspace,{parentConnection:e})},Vt=function(e){return(e=Ht(e,lu)).length?e[0].join(Ir?" ":" + "):""},Ht=function(e,t){if(0===(e=ca.registry.getKeyCodesByShortcutName(e)).length)return[];(e=e.map((e=>e.split("+")))).forEach((e=>e.sort(((e,t)=>(e=Gt(e))-Gt(t))))),e.sort(((e,t)=>(e=e.includes("Meta")?1:0,(t.includes("Meta")?1:0)-e)));var i=e.filter((e=>e.includes("Meta")===Ir));return(i=0===i.length?e:i).sort(((e,t)=>e.length-t.length)),(i.some((e=>e.some((e=>"Meta"===e||"Alt"===e||"Control"===e))))?[i[0]]:i).map((e=>e.map((e=>{if(Number.isFinite(+e))if((e=+e)>=65&&e<=90)e=String.fromCharCode(e);else{var t={8:Zs.C.BACKSPACE_KEY,9:Zs.C.TAB_KEY,13:Zs.C.ENTER_KEY,16:Zs.C.SHIFT_KEY,17:Zs.C.CONTROL_KEY,18:Zs.C.ALT_KEY,19:Zs.C.PAUSE_KEY,20:Zs.C.CAPS_LOCK_KEY,27:Zs.C.ESCAPE,32:Zs.C.SPACE_KEY,33:Zs.C.PAGE_UP_KEY,34:Zs.C.PAGE_DOWN_KEY,35:Zs.C.END_KEY,36:Zs.C.HOME_KEY,37:"←",38:"↑",39:"→",40:"↓",45:Zs.C.INSERT_KEY,46:Zs.C.DELETE_KEY,48:"0",49:"1",50:"2",51:"3",52:"4",53:"5",54:"6",55:"7",56:"8",57:"9",59:";",61:"=",93:Zs.C.CONTEXT_MENU_KEY,96:"0",97:"1",98:"2",99:"3",100:"4",101:"5",102:"6",103:"7",104:"8",105:"9",106:"×",107:"+",109:"−",110:".",111:"÷",112:"F1",113:"F2",114:"F3",115:"F4",116:"F5",117:"F6",118:"F7",119:"F8",120:"F9",121:"F10",122:"F11",123:"F12",186:";",187:"=",189:"-",188:",",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'",224:"⌘"}[e];t?e=t:(console.warn("Unknown key code: "+e),e=String.fromCharCode(e))}return e})).map((e=>{var i,n=null!=(i=t[e])?i:e;return n.charAt(0).toUpperCase()+n.substring(1)}))))},Gt=function(e){return-1===(e=hu.indexOf(e))?Number.MAX_VALUE:e},Wt=function(e){return e&&"function"==typeof e.init&&"function"==typeof e.getDiv&&"function"==typeof e.getId&&"function"==typeof e.getParent&&"function"==typeof e.getLevel&&"function"==typeof e.isSelectable&&"function"==typeof e.isCollapsible&&"function"==typeof e.dispose&&"function"==typeof e.getClickTarget&&"function"==typeof e.setVisible_&&"function"==typeof e.getParentToolbox},qt=function(e){return"function"==typeof e.getName&&"function"==typeof e.getContents&&"function"==typeof e.setSelected&&"function"==typeof e.onClick&&Wt(e)&&e.isSelectable()},$t=function(e,t=Xr.STANDARD,i){return[t>=Xr.STANDARD&&Xt(e),zt(e),...Yt(e,t,i),t===Xr.LOQUACIOUS&&ei(e),t>=Xr.STANDARD&&(e.isEnabled()?void 0:Zs.C.BLOCK_LABEL_DISABLED),t>=Xr.STANDARD&&(e.isCollapsed()?Zs.C.BLOCK_LABEL_COLLAPSED:void 0),t>=Xr.LOQUACIOUS&&(e.isShadow()?Zs.C.BLOCK_LABEL_REPLACEABLE:void 0),t>=Xr.STANDARD&&si(e),t>=Xr.LOQUACIOUS&&e.getAriaRoleDescription()].filter((e=>!!e)).join(", ")},jt=function(e,t,i=Xr.STANDARD){var n,o=i>=Xr.LOQUACIOUS,s=[],r=e.fieldRow.filter((e=>e.isVisible())).flatMap(((e,t,i)=>{if(e.isLabelField()){if(t<i.length-1&&i[t+1].isLabelField())return s.push(e.computeAriaLabel(o)),[];if(s.length>=1)return s.push(e.computeAriaLabel(o)),e=s.join(" "),s=[],e}return e.computeAriaLabel(o)}));if(!r.length&&t){let n=e.getSourceBlock().inputList,o=n.indexOf(e);if(o>0)return jt(n[o-1],t,i)}return e.type===Zs.je.VALUE&&null===(null==(n=e.connection)?void 0:n.targetConnection)&&i>=Xr.STANDARD&&r.push(Zs.C.INPUT_LABEL_EMPTY),r.filter((e=>!!e))},zt=function(e){var t,i,n,o=null==(t=null!=(n=e.outputConnection)?n:e.previousConnection)||null==(i=t.targetConnection)?void 0:i.getParentInput();if(o&&!(e=o.getSourceBlock()).isInsertionMarker()){if(t=o.getAriaLabelText())e=t;else{if(!e.statementInputCount)return;if(o===(t=e.inputList.find((e=>e.type===Zs.je.STATEMENT))))return;if(!(e=Qt(e,o,!1)).length)return;e=e.join(", ")}return o.type===Zs.je.STATEMENT?(o=Array.isArray(e)?e.join(" "):e,Zs.C.BLOCK_LABEL_BEGIN_PREFIX.replace("%1",o)):e}},Xt=function(e){if(!e.isInFlyout&&!e.isDragging())return e.getRootBlock()===e?Zs.C.BLOCK_LABEL_BEGIN_STACK:void 0},Yt=function(e,t=Xr.STANDARD,i){if(i)return[i];if(i=e=e.inputList.filter((e=>e.isVisible())),t<=Xr.STANDARD){let t=e.filter((e=>e.type===Zs.je.STATEMENT));t.length>1&&(i=e.slice(0,e.indexOf(t[0])+1))}var n=[];return i.flatMap(((e,i,o)=>{var s,r=e.getLabel(t);if(s=i<o.length-1&&Jt(e)&&Kt(o[i+1])){let t,n;s=o[i+1],i=(null==(t=e.connection)?void 0:t.type)===Xl.NEXT_STATEMENT||e.type===Zs.je.END_ROW,s=!(!e.getSourceBlock().getInputsInline()||(null==(n=s.connection)?void 0:n.type)===Xl.NEXT_STATEMENT||i)}return s?(n.push(r),[]):Kt(e)&&n.length>0?(n.push(r),e=n.join(" "),n=[],e):r}))},Kt=function(e){return(e=e.fieldRow.filter((e=>e.isVisible()))).length>0&&e[0].isLabelField()},Jt=function(e){return e.type!==Zs.je.VALUE&&e.type!==Zs.je.STATEMENT&&(e=e.fieldRow.filter((e=>e.isVisible()))).length>0&&e[e.length-1].isLabelField()},Qt=function(e,t,i){var n=e.inputList.indexOf(t);if(-1===n)throw Error(`Input with name "${t.name}" not found on block with id "${e.id}".`);var o=t.type===Zs.je.STATEMENT,s=o?Zt(e.inputList,n):n,r=e.inputList.slice(s,n+1).filter((e=>e.isVisible())),a=r.map((e=>e.getLabel(Xr.TERSE,e!==t||i))),l=o&&a.slice(0,-1).some((e=>!!e));return a.map(((e,t)=>e||((e=r[t]).type===Zs.je.DUMMY||e.type===Zs.je.END_ROW||o&&t===a.length-1&&l?void 0:Zs.C.INPUT_LABEL_INDEX.replace("%1",(e.getIndex()+1).toString())))).filter((e=>void 0!==e))},Zt=function(e,t){for(--t;t>=0;t--)if(e[t].type===Zs.je.STATEMENT)return t+1;return 0},ei=function(e){var t=e.workspace.getToolbox();if(t){var i=void 0;for(let n of t.getToolboxItems())if(qt(n)){if(t=n.getContents(),Array.isArray(t)&&t.some((t=>"block"===t.kind.toLowerCase()&&"type"in t&&t.type===e.type))){i=n;break}"getColour"in n&&"function"==typeof n.getColour&&n.getColour()===e.getColour()&&(i=n)}if(i)return Zs.C.BLOCK_LABEL_TOOLBOX_CATEGORY.replace("%1",i.getName())}},ti=function(e){switch(e){case au.BEFORE:return Zs.C.ANNOUNCE_MOVE_BEFORE;case au.AFTER:return Zs.C.ANNOUNCE_MOVE_AFTER;case au.INSIDE:return Zs.C.ANNOUNCE_MOVE_INSIDE;case au.AROUND:return Zs.C.ANNOUNCE_MOVE_AROUND;default:return Zs.C.ANNOUNCE_MOVE_TO}},ii=function(e,t){var i=e.getParentInput();if(!i)return t;var n=i.getAriaLabelText();if(!n){if(!(e=Qt(e.getSourceBlock(),i,!0)).length)return t;n=e.join(", ")}return t?Zs.C.ANNOUNCE_MOVE_OF.replace("%1",n).replace("%2",t):n},ni=function(e,t,i,n=!1){var o=oi(e,t),s=ti(o),r=![au.BEFORE,au.AFTER].includes(o);return o=r&&i(!0),i=r&&i(!1),n=n?e.getSourceBlock().getStackBlocksCountLabel():"",r=t.getSourceBlock().getAriaLabel(Xr.TERSE),o&&(n=ii(e,n)),i&&(r=ii(t,r)),s.replace("%1",n).replace("%2",r)},oi=function(e,t){switch(e.type){case Xl.INPUT_VALUE:case Xl.OUTPUT_VALUE:return au.TO;case Xl.NEXT_STATEMENT:return e===e.getSourceBlock().nextConnection?au.BEFORE:au.AROUND;case Xl.PREVIOUS_STATEMENT:return t===t.getSourceBlock().nextConnection?au.AFTER:au.INSIDE}return au.UNKNOWN},si=function(e){var t=e.inputList.filter((e=>e.type===Zs.je.STATEMENT)).length;if(t>1)return Zs.C.BLOCK_LABEL_HAS_BRANCHES.replace("%1",t.toString());switch(e.inputList.reduce(((e,t)=>{var i;return t.fieldRow.reduce(((e,t)=>t.EDITABLE&&!t.isFullBlockField()?++e:e),e)+((null==(i=t.connection)?void 0:i.type)===Xl.INPUT_VALUE?1:0)}),0)){case 0:break;case 1:return Zs.C.BLOCK_LABEL_HAS_INPUT;default:return Zs.C.BLOCK_LABEL_HAS_INPUTS}},ri=function(e){return e*Math.PI/180},ai=function(e,t,i){if(i<e){let t=i;i=e,e=t}return Math.max(e,Math.min(t,i))},li=function(){document.querySelector(".blocklyDropDownDiv")||((du=document.createElement("div")).className="blocklyDropDownDiv",du.tabIndex=-1,du.id=le(),(X()||document.body).appendChild(du),(pu=document.createElement("div")).className="blocklyDropDownContent",du.appendChild(pu),Iu=r(pu,"keydown",null,(e=>{ee(e),e.stopPropagation()})),(gu=document.createElement("div")).className="blocklyDropDownArrow",du.appendChild(gu),du.style.opacity="0",du.style.transition="transform 0.25s, opacity 0.25s")},hi=function(){vu&&(vu(!1),vu=null),Ci()},ui=function(){Iu&&(l(Iu),Iu=null),du.remove(),li()},ci=function(e,t){du.style.backgroundColor=e,du.style.borderColor=t},di=function(e,t,i,n=!0){return Cu=!0,Ei(gi(e),e,n,t,i)},pi=function(e){var t=e.getSvgRoot(),i=e.workspace.scale,n=e.height*i;return e=e.width*i,t=Ce(t),new xa(t.y,t.y+n,t.x,t.x+e)},gi=function(e){return e=e.getScaledBBox(),new xa(e.top,e.bottom,e.left,e.right)},Ei=function(e,t,i,n,o){var s=e.left+(e.right-e.left)/2,r=e.bottom;e=e.top,o&&(e+=o);for(var a=(o=t.getSourceBlock()).workspace;a.options.parentWorkspace;)a=a.options.parentWorkspace;return mu=a.getParentSvg().parentNode,Ti(t,o.RTL,s,r,s,e,i,n)},Ti=function(e,t,i,n,o,s,r,a){var l;return Zs.t().registerPopoverFocusLossHandler(hi),null==(l=X())||l.appendChild(du),bu=e,Tu=a||null,du.style.direction=t?"rtl":"ltr",_u=(e=Ta).getRenderer().getClassName(),fu=e.getTheme().getClassName(),N(du,_u),N(du,fu),t=b(e.getFocusableElement(),$r.OWNS),f(e.getFocusableElement(),$r.OWNS,t?[t,du.id]:du.id),e.getFocusableElement().classList.add("blocklyShowingDropDownDiv"),i=Ii(i,n,o,s),r&&(vu=Zs.t().takeEphemeralFocus(du)),i},_i=function(e,t,i,n){return{initialX:(e=mi(e,i.left,i.right,n.width)).divX,initialY:t,finalX:e.divX,finalY:t+16,arrowX:e.arrowX,arrowY:-9,arrowAtTop:!0,arrowVisible:!0}},fi=function(e,t,i,n){return{initialX:(e=mi(e,i.left,i.right,n.width)).divX,initialY:t-n.height,finalX:e.divX,finalY:t-n.height-16,arrowX:e.arrowX,arrowY:n.height-2-8,arrowAtTop:!1,arrowVisible:!0}},mi=function(e,t,i,n){return t=ai(t,e-n/2,i-n),{arrowX:e=ai(12,e=e-8-t,n-12-16),divX:t}},bi=function(e,t){return bu===e&&(t?vi():Ci(),!0)},Ci=function(){bu&&(Zs.t().unregisterPopoverFocusLossHandler(hi),du.style.transform="translate(0, 0)",du.style.opacity="0",Eu=setTimeout((function(){vi()}),250),Tu&&(Tu(),Tu=null))},vi=function(){if(bu){Eu&&clearTimeout(Eu),Tu&&(Tu(),Tu=null),bu=null;var e,t=Ta,i=null!=(e=b(t.getFocusableElement(),$r.OWNS))?e:"";f(t.getFocusableElement(),$r.OWNS,i.replace(du.id,"")),t.getFocusableElement().classList.remove("blocklyShowingDropDownDiv"),t.markFocused(),vu&&(vu(),vu=null),ui()}},Ii=function(e,t,i,n){(e=Nu.getPositionMetrics(e,t,i,n)).arrowVisible?(t=e.arrowX,i=e.arrowY,n=e.arrowAtTop?45:225,gu.style.display="",gu.style.transform=`translate(${t}px, ${i}px) rotate(${n}deg)`,gu.setAttribute("class","blocklyDropDownArrow")):gu.style.display="none",t=Math.floor(e.initialX),i=Math.floor(e.initialY),n=Math.floor(e.finalX);var o=Math.floor(e.finalY),s=du.parentElement;return s&&(({x:t,y:i}=Ne(t,i,s)),({x:n,y:o}=Ne(n,o,s))),du.style.left=t+"px",du.style.top=i+"px",du.style.visibility="visible",du.style.opacity="1",du.style.transform="translate("+(n-t)+"px,"+(o-i)+"px)",!!e.arrowAtTop},Ni=function(){if(bu){var e=bu.getSourceBlock();let t=(e=Cu?gi(bu):pi(e)).left+(e.right-e.left)/2;Ii(t,e.bottom,t,e.top)}else Ci()},yi=function(e){return e.length?e.reduce((function(e,t){return e.length<t.length?e:t})).length:0},Ai=function(e,t){if(!e.length)return 0;if(1===e.length)return e[0].length;var i,n=0;for(t=t||yi(e),i=0;i<t;i++){for(var o=e[0][i],s=1;s<e.length;s++)if(o!==e[s][i])return n;" "===o&&(n=i+1)}for(o=1;o<e.length;o++)if((s=e[o][i])&&" "!==s)return n;return t},ki=function(e,t){if(!e.length)return 0;if(1===e.length)return e[0].length;var i,n=0;for(t=t||yi(e),i=0;i<t;i++){for(var o=e[0].substr(-i-1,1),s=1;s<e.length;s++)if(o!==e[s].substr(-i-1,1))return n;" "===o&&(n=i+1)}for(o=1;o<e.length;o++)if((s=e[o].charAt(e[o].length-i-1))&&" "!==s)return n;return t},Zs.yf=function(e,t){e=e.split("\n");for(let h=0;h<e.length;h++){var i=h;e:{var n=void 0;let i;var o=e[h],s=t;if(o.length<=s){s=o;break e}let u=o.trim().split(/\s+/);for(n=0;n<u.length;n++)u[n].length>s&&(s=u[n].length);var r=-1/0;let c=1;do{i=r,n=o;var a=[];r=u.length/c,o=1;for(var l=0;l<u.length-1;l++)o<(l+1.5)/r?(o++,a[l]=!0):a[l]=!1;a=Oi(u,a,s),r=Si(u,a,s),o=u,l=[];for(let e=0;e<o.length;e++)l.push(o[e]),void 0!==a[e]&&l.push(a[e]?"\n":" ");o=l.join(""),c++}while(r>i);s=n}e[i]=s}return e.join("\n")},Si=function(e,t,i){for(var n=[0],o=[],s=0;s<e.length;s++)n[n.length-1]+=e[s].length,!0===t[s]?(n.push(0),o.push(e[s].charAt(e[s].length-1))):!1===t[s]&&n[n.length-1]++;for(e=Math.max(...n),t=0,s=0;s<n.length;s++)t-=2*Math.pow(Math.abs(i-n[s]),1.5),t-=Math.pow(e-n[s],1.5),".?!".includes(o[s])?t+=i/3:",;)]}".includes(o[s])&&(t+=i/4);return n.length>1&&n[n.length-1]<=n[n.length-2]&&(t+=.5),t},Oi=function(e,t,i){var n=Si(e,t,i);for(let s=0;s<t.length-1;s++){if(t[s]===t[s+1])continue;let r=[].concat(t);r[s]=!r[s],r[s+1]=!r[s+1];let a=Si(e,r,i);if(a>n){n=a;var o=r}}return o?Oi(e,o,i):t},Zs.zf=function(e){return/^\s*-?\d+(\.\d+)?\s*$/.test(e)},Ri=function(e){if(e=wi(e)){for(e=e.tooltip;"function"==typeof e;)e=e();if("string"!=typeof e)throw Error("Tooltip function must return a string.");return e}return""},wi=function(e){for(;e&&e.tooltip;){if("string"==typeof e.tooltip||"function"==typeof e.tooltip)return e;e=e.tooltip}return null},Li=function(){document.querySelector(".blocklyTooltipDiv")||((Mu=document.createElement("div")).className="blocklyTooltipDiv",(X()||document.body).appendChild(Mu))},Di=function(e){e.mouseOverWrapper_=a(e,"pointerover",null,Fi),e.mouseOutWrapper_=a(e,"pointerout",null,Mi),e.addEventListener("pointermove",Pi,!1)},xi=function(e){e&&(l(e.mouseOverWrapper_),l(e.mouseOutWrapper_),e.removeEventListener("pointermove",Pi))},Fi=function(e){Ou||(e=wi(e.currentTarget),xu!==e&&(Ui(),Fu=null,xu=e),clearTimeout(Ru))},Mi=function(){Ou||(Ru=setTimeout((function(){Fu=xu=null,Ui()}),1),clearTimeout(wu),wu=0)},Pi=function(e){if(xu&&xu.tooltip&&!Ou)if(Su){let t=Lu-e.pageX;e=Du-e.pageY,Math.sqrt(t*t+e*e)>10&&Ui()}else Fu!==xu&&(clearTimeout(wu),Lu=e.pageX,Du=e.pageY,wu=setTimeout((()=>{if(this instanceof Element)for(let t of H()){if(!t.rendered)continue;let i;if(null!=(i=t.getInjectionDiv())&&i.contains(this)){var e=t;break}}Gi(e)}),750))},Bi=function(){Fu=xu=null,Ui()},Ui=function(){Su&&(Su=!1,Mu&&(Mu.style.display="none")),wu&&(clearTimeout(wu),wu=0)},Vi=function(e,t){xu!==e&&(Ui(),Fu=null,xu=e),xu&&xu.tooltip&&!Ou&&(e=e.getFocusableElement().getBoundingClientRect(),Lu=xu.RTL?e.x+e.width:e.x,Du=e.y+e.height,Gi(t))},Hi=function(){Ui(),Ou=!0},Gi=function(e){if(!Ou&&(Fu=xu,Mu)){var t;if(null==(t=X(e))||t.appendChild(Mu),Mu.textContent="",Mu&&xu)if("function"==typeof ku)ku(Mu,xu);else for(e=Ri(xu),e=(e=Zs.yf(e,50)).split("\n"),t=0;t<e.length;t++){var i=document.createElement("div");i.appendChild(document.createTextNode(e[t])),Mu.appendChild(i)}e=xu.RTL,Mu.style.direction=e?"rtl":"ltr",Mu.style.display="block",Su=!0,t=document.documentElement.clientWidth,i=document.documentElement.clientHeight;var n=Lu;n=e?n-(0+Mu.offsetWidth):n+0;var o,s=Du+10,r=null==(o=Mu)?void 0:o.parentElement;r&&(n-=(o=r.getBoundingClientRect()).left+window.scrollX,s-=o.top+window.scrollY),s+Mu.offsetHeight>i+window.scrollY&&(s-=Mu.offsetHeight+20),e?n=Math.max(5-window.scrollX,n):n+Mu.offsetWidth>t+window.scrollX-10&&(n=t-Mu.offsetWidth-10);var{x:a,y:l}={x:n,y:s};Mu.style.left=a+"px",Mu.style.top=l+"px"}},Wi=function(e){e=`${e}`.toLowerCase().trim();var t=Vu[e];if(t)return t;if(t="#"===(t="0x"===e.substring(0,2)?"#"+e.substring(2):e)[0]?t:"#"+t,/^#[0-9a-f]{6}$/.test(t))return t;if(/^#[0-9a-f]{3}$/.test(t))return["#",t[1],t[1],t[2],t[2],t[3],t[3]].join("");var i=e.match(/^(?:rgb)?\s*\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)$/);return i&&(e=Number(i[1]),t=Number(i[2]),i=Number(i[3]),e>=0&&e<256&&t>=0&&t<256&&i>=0&&i<256)?qi(e,t,i):null},qi=function(e,t,i){return t=e<<16|t<<8|i,e<16?"#"+(16777216|t).toString(16).substr(1):"#"+t.toString(16)},$i=function(e){return(e=Wi(e))?[(e=parseInt(e.substr(1),16))>>16,e>>8&255,255&e]:[0,0,0]},ji=function(e,t,i){var n=0,o=0,s=0;if(0===t)s=o=n=i;else{let r=Math.floor(e/60),a=e/60-r;e=i*(1-t);let l=i*(1-t*a);switch(t=i*(1-t*(1-a)),r){case 1:n=l,o=i,s=e;break;case 2:n=e,o=i,s=t;break;case 3:n=e,o=l,s=i;break;case 4:n=t,o=e,s=i;break;case 5:n=i,o=e,s=l;break;case 6:case 0:n=i,o=t,s=e}}return qi(Math.floor(n),Math.floor(o),Math.floor(s))},zi=function(e,t,i){return(e=Wi(e))&&(t=Wi(t))?(e=$i(e),t=$i(t),qi(Math.round(t[0]+i*(e[0]-t[0])),Math.round(t[1]+i*(e[1]-t[1])),Math.round(t[2]+i*(e[2]-t[2])))):null},Xi=function(e){return ji(e,Bu,255*Uu)},Yi=function(e,t,i){var n=[],o=e.split("");o.push("");var s=0;e=[];var r=null;for(let h=0;h<o.length;h++){var a=o[h];if(0===s)if("%"===a)(s=e.join(""))&&n.push(s),e.length=0,s=1;else if(i&&"\n"===a){let t=e.join("");t&&n.push(t),e.length=0,n.push(a)}else e.push(a);else if(1===s)"%"===a?(e.push(a),s=0):t&&"0"<=a&&a<="9"?(s=2,r=a,(a=e.join(""))&&n.push(a),e.length=0):"{"===a?s=3:(e.push("%",a),s=0);else if(2===s)if("0"<=a&&a<="9")r+=a;else{var l=void 0;n.push(parseInt(null!=(l=r)?l:"",10)),h--,s=0}else 3===s&&(""===a?(e.splice(0,0,"%{"),h--,s=0):"}"!==a?e.push(a):(s=e.join(""),/[A-Z]\w*/i.test(s)&&(a=(a=s.toUpperCase()).startsWith("BKY_")?a.substring(4):null)&&a in Zs.C?"string"==typeof(s=Zs.C[a])?Array.prototype.push.apply(n,Yi(s,t,i)):t?n.push(`${s}`):n.push(s):n.push("%{"+s+"}"),s=e.length=0))}for((t=e.join(""))&&n.push(t),l=[],e.length=0,o=0;o<n.length;o++)"string"!=typeof n[o]||i&&"\n"===n[o]?((t=e.join(""))&&l.push(t),e.length=0,l.push(n[o])):e.push(n[o]);return(t=e.join(""))&&l.push(t),e.length=0,l},Ki=function(e){return Yi(e,!0,!0)},Ji=function(e){return"string"!=typeof e?e:(e=Yi(e,!1,!1)).length?String(e[0]):""},Qi=function(e){var t="string"==typeof e?Ji(e):e,i=Number(t);if(!isNaN(i)&&0<=i&&i<=360)return{hue:i,hex:ji(i,Bu,255*Uu)};if(i=Wi(t))return{hue:null,hex:i};throw i='Invalid colour: "'+t+'"',e!==t&&(i+=' (from "'+e+'")'),Error(i)},Zi=function(){Ju&&(Ju(!1),Ju=null),nn()},en=function(){var e=X()||document.body,t=document.querySelector("div.blocklyWidgetDiv");t?qu=t:((qu=document.createElement("div")).id=le(),qu.className="blocklyWidgetDiv",qu.tabIndex=-1),r(qu,"keydown",null,(e=>{ee(e),e.stopPropagation()})),e.appendChild(qu)},tn=function(e,t,i,n,o=!0){if(nn(),ju=e,Xu=i,i=qu){var s,r=b((zu=null!=n?n:Ta).getFocusableElement(),$r.OWNS);f(zu.getFocusableElement(),$r.OWNS,r?[r,i.id]:i.id),zu.getFocusableElement().classList.add("blocklyShowingWidgetDiv"),null==(s=X())||s.appendChild(i),i.style.direction=t?"rtl":"ltr",i.style.display="block",!n&&e instanceof Wu&&e.getSourceBlock(),Yu=zu.getRenderer().getClassName(),Ku=zu.getTheme().getClassName(),Yu&&N(i,Yu),Ku&&N(i,Ku),o&&(Ju=Zs.t().takeEphemeralFocus(i)),Zs.t().registerPopoverFocusLossHandler(Zi)}},nn=function(){if(ju){ju=null;var e,t,i=qu;i&&(Zs.t().unregisterPopoverFocusLossHandler(Zi),i.style.display="none",i.style.left="",i.style.top="",Xu&&(Xu(),Xu=null),i.textContent="",Yu&&(A(i,Yu),Yu=""),Ku&&(A(i,Ku),Ku=""),null==(e=zu)||e.markFocused(),Ju&&(Ju(),Ju=null),zu&&qu&&(i=null!=(t=b(zu.getFocusableElement(),$r.OWNS))?t:"",f(zu.getFocusableElement(),$r.OWNS,i.replace(qu.id,"")),zu.getFocusableElement().classList.remove("blocklyShowingWidgetDiv")))}},on=function(e){ju===e&&nn()},sn=function(e){for(var t=null===zu,i=e;!t&&i;){if(i===e){t=!0;break}i=e.options.parentWorkspace}t&&nn()},rn=function(e,t,i){if(qu){var n=qu.parentElement;n&&({x:e,y:t}=Ne(e,t,n)),qu.style.left=e+"px",qu.style.top=t+"px",qu.style.height=i+"px"}},an=function(e,t,i,n){var o=t.bottom+i.height>=e.bottom?t.top-i.height:t.bottom;e=n?Math.min(Math.max(t.right-i.width,e.left),e.right-i.width):Math.max(Math.min(t.left,e.right-i.width),e.left),o<0?rn(e,0,i.height+o):rn(e,o,i.height)},ln=function(){var e;null!=(e=ju)&&e.repositionForWindowResize&&ju.repositionForWindowResize()||nn()},hn=function(e,t,i,n,o){if(tn(ec,i,gn,n),t.length){o||(e instanceof PointerEvent?o=new Da(e.clientX,e.clientY):(console.warn("Context menu opened with keyboard but no location given"),o=new Da(0,0)));var s=un(t,i,e,o);tc=s,cn(s,i,o),setTimeout((function(){s.focus()}),1),Zu=null}else pn()},un=function(e,t,i,n){var o=new bl;o.setRole(Hr.MENU);for(let s=0;s<e.length;s++){let r=e[s];if(r.separator){o.addChild(new Cl);continue}let a=new ml(En(r));a.setRightToLeft(t),a.setRole(Hr.MENUITEM),o.addChild(a),a.setEnabled(r.enabled),r.enabled&&a.onAction((function(e,t){pn(),requestAnimationFrame((()=>{setTimeout((()=>{r.callback(r.scope,i,t,n)}),0)}))}),{})}return o},cn=function(e,t,i){var n=Oe();i=new xa(i.y+n.top,i.y+n.top,i.x+n.left,i.x+n.left);var o=qu;if(!o)throw Error("Attempting to create a context menu when widget div is null");o=e.render(o),N(o,"blocklyContextMenu"),r(o,"contextmenu",null,dn),e.focus(),o=e.getSize(),t&&(i.left+=o.width,i.right+=o.width,n.left+=o.width,n.right+=o.width),an(n,i,o,t),e.focus()},dn=function(e){e.preventDefault(),e.stopPropagation()},pn=function(){var e;on(ec),Zu=null,null==(e=tc)||e.dispose(),tc=null},gn=function(){tc&&(tc.dispose(),tc=null)},Zs.Pg=function(e,t){return()=>{Zs.Ub++;try{var i=t instanceof Element?An(t,e.workspace):Mt(t,e.workspace);let n=e.getRelativeToSurfaceXY();n.x=e.RTL?n.x-Zs.Og.snapRadius:n.x+Zs.Og.snapRadius,n.y+=2*Zs.Og.snapRadius,i.moveBy(n.x,n.y)}finally{Zs.Ub--}return Ee()&&!i.isShadow()&&ue(new(_e(Fr.BLOCK_CREATE))(i)),Zs.t().focusNode(i),i}},En=function(e){var t=e.text;if(t&&!(t instanceof HTMLElement)){let i=document.createElement("div");i.className="blocklyShortcutContainer";let n=document.createElement("span");return n.textContent=t,(t=document.createElement("span")).className="blocklyShortcut",e="id"in e&&e.associatedKeyboardShortcut?Vt(e.associatedKeyboardShortcut):"",t.textContent=` ${e}`,i.appendChild(n),i.appendChild(t),i}return e.text},Tn=function(e,t){return(t=c(t,e.getParentSvg(),e.getInverseScreenCTM())).x/=e.scale,t.y/=e.scale,t},_n=function(e,t,i){t=Tn(e,t),lc.set(e,Da.difference(i,t))},fn=function(e,t){if(t=Tn(e,t),!(e=lc.get(e)))throw Error("Drag not initialized");return Da.sum(e,t)},mn=function(e,t=!1){var i=Zs.sc("comment");t||i.setAttribute("id",e.id),t=e.workspace;var n=e.getRelativeToSurfaceXY().clone();return n.x=t.RTL?t.getWidth()-n.x:n.x,i.setAttribute("x",`${n.x}`),i.setAttribute("y",`${n.y}`),i.setAttribute("w",`${e.getSize().width}`),i.setAttribute("h",`${e.getSize().height}`),e.getText()&&(i.textContent=e.getText()),e.isCollapsed()&&i.setAttribute("collapsed","true"),e.isOwnEditable()||i.setAttribute("editable","false"),e.isOwnMovable()||i.setAttribute("movable","false"),e.isOwnDeletable()||i.setAttribute("deletable","false"),i},bn=function(e){var t=Zs.sc("variables");for(let i=0;i<e.length;i++){let n=e[i],o=Zs.sc("variable");o.appendChild(Zs.tc(n.getName())),n.getType()&&o.setAttribute("type",n.getType()),o.id=n.getId(),t.appendChild(o)}return t},Cn=function(e,t){if(e.isInsertionMarker()&&!(e=e.getChildren(!1)[0]))return new DocumentFragment;var i=0;if(e.workspace.RTL&&(i=e.workspace.getWidth()),(t=vn(e,t)).nodeType===ta.ELEMENT_NODE){let n=e.getRelativeToSurfaceXY();t.setAttribute("x",String(Math.round(e.workspace.RTL?i-n.x:n.x))),t.setAttribute("y",String(Math.round(n.y)))}return t},vn=function(e,t){if(e.isInsertionMarker())return(t=e.getChildren(!1)[0])?vn(t):new DocumentFragment;var i=Zs.sc(e.isShadow()?"shadow":"block");if(i.setAttribute("type",e.type),t||(i.id=e.id),e.mutationToDom){var n=e.mutationToDom();n&&(n.hasChildNodes()||n.hasAttributes())&&i.appendChild(n)}for(var o of e.getFields())o.isSerializable()?((n=Zs.sc("field")).setAttribute("name",o.name||""),n=o.toXml(n)):n=null,n&&i.appendChild(n);if(o=e.getCommentText()){var s=e.getIcon(Hl.COMMENT);n=s.getBubbleSize();var r=s.bubbleIsVisible();s=s.getBubbleLocation();var a=Zs.sc("comment");a.appendChild(Zs.tc(o)),a.setAttribute("pinned",`${r}`),a.setAttribute("h",`${n.height}`),a.setAttribute("w",`${n.width}`),s&&(a.setAttribute("x",`${e.workspace.RTL?e.workspace.getWidth()-(s.x+n.width):s.x}`),a.setAttribute("y",`${s.y}`)),i.appendChild(a)}for(e.data&&((o=Zs.sc("data")).appendChild(Zs.tc(e.data)),i.appendChild(o)),o=0;o<e.inputList.length;o++){var l=void 0;r=!0,(n=e.inputList[o]).type!==Zs.je.DUMMY&&n.type!==Zs.je.END_ROW&&(s=n.connection.targetBlock(),n.type===Zs.je.VALUE?l=Zs.sc("value"):n.type===Zs.je.STATEMENT&&(l=Zs.sc("statement")),!(a=n.connection.getShadowDom())||s&&s.isShadow()||l.appendChild(In(a,t)),s&&(s=vn(s,t)).nodeType===ta.ELEMENT_NODE&&(l.appendChild(s),r=!1),l.setAttribute("name",n.name),r||i.appendChild(l))}if(void 0!==e.inputsInline&&e.inputsInline!==e.inputsInlineDefault&&i.setAttribute("inline",String(e.inputsInline)),e.isCollapsed()&&i.setAttribute("collapsed","true"),e.isEnabled()||i.setAttribute("disabled-reasons",Array.from(e.getDisabledReasons()).map(encodeURIComponent).join(",")),e.isOwnDeletable()||i.setAttribute("deletable","false"),e.isOwnMovable()||i.setAttribute("movable","false"),e.isOwnEditable()||i.setAttribute("editable","false"),(l=e.getNextBlock())&&(o=vn(l,t)).nodeType===ta.ELEMENT_NODE){var h=Zs.sc("next");h.appendChild(o),i.appendChild(h)}return!(e=e.nextConnection&&e.nextConnection.getShadowDom())||l&&l.isShadow()||h.appendChild(In(e,t)),i},In=function(e,t){for(var i,n=e=e.cloneNode(!0);n;)if(t&&"shadow"===n.nodeName&&n.removeAttribute("id"),n.firstChild)n=n.firstChild;else{for(;n&&!n.nextSibling;){let e;i=n,n=n.parentNode,i.nodeType===ta.TEXT_NODE&&""===i.data.trim()&&(null==(e=n)?void 0:e.firstChild)!==i&&S(i)}n&&(i=n,n=n.nextSibling,i.nodeType===ta.TEXT_NODE&&""===i.data.trim()&&S(i))}return e},Nn=function(e){return De(e).replace(/<(\w+)([^<]*)\/>/g,"<$1$2></$1>")},Zs.ch=function(e,t){var i=0;t.RTL&&(i=t.getWidth());var n=[];w();var o=Zs.gd;o||Zs.B(!0),t.setResizesEnabled&&t.setResizesEnabled(!1);var s=!0;try{for(let o,r=0;o=e.childNodes[r];r++){let e=o.nodeName.toLowerCase(),r=o;if("block"===e||"shadow"===e&&!Zs.Qc){let e=An(r,t);n.push(e.id);let o,a,l=parseInt(null!=(o=r.getAttribute("x"))?o:"10",10),h=parseInt(null!=(a=r.getAttribute("y"))?a:"10",10);isNaN(l)||isNaN(h)||e.moveBy(t.RTL?i-l:l,h,["create"]),s=!1}else{if("shadow"===e)throw TypeError("Shadow block cannot be a top-level block.");if("comment"===e)yn(r,t);else if("variables"===e){if(!s)throw Error("'variables' tag must exist once before block and shadow tag elements in the workspace XML, but it was found in another location.");kn(r,t),s=!1}}}}finally{Zs.B(o),t.setResizesEnabled&&t.setResizesEnabled(!0),t.rendered&&et(),L()}return ue(new(_e(Fr.FINISHED_LOADING))(t)),n},yn=function(e,t){var i,n,o,s,r,a,l=null!=(i=e.getAttribute("id"))?i:void 0;return(i=t.rendered?new Ec(t,l):new gc(t,l)).setText(null!=(n=e.textContent)?n:""),n=parseInt(null!=(o=e.getAttribute("x"))?o:"",10),o=parseInt(null!=(s=e.getAttribute("y"))?s:"",10),isNaN(n)||isNaN(o)||(n=t.RTL?t.getWidth()-n:n,i.moveTo(new Da(n,o))),t=parseInt(null!=(r=e.getAttribute("w"))?r:"",10),r=parseInt(null!=(a=e.getAttribute("h"))?a:"",10),isNaN(t)||isNaN(r)||i.setSize(new Fa(t,r)),"true"===e.getAttribute("collapsed")&&i.setCollapsed(!0),"false"===e.getAttribute("editable")&&i.setEditable(!1),"false"===e.getAttribute("movable")&&i.setMovable(!1),"false"===e.getAttribute("deletable")&&i.setDeletable(!1),i},Zs.fh=function(e,t){return e=An(e,t),t.rendered&&et(),e},An=function(e,t){Zs.Ub++;var i=t.getVariableMap().getAllVariables();try{var n=Rn(e,t);if(t.rendered){let e=n,i=n.getDescendants(!1);e.setConnectionTracking(!1);for(let e=i.length-1;e>=0;e--)i[e].initSvg();for(let e=i.length-1;e>=0;e--)i[e].queueRender();setTimeout((function(){e.disposed||e.setConnectionTracking(!0)}),1),t.resizeContents()}else{let e=n.getDescendants(!1);for(let t=e.length-1;t>=0;t--)e[t].initModel()}}finally{Zs.Ub--}if(Ee()){for(e=Rt(t,i),t=0;t<e.length;t++)i=e[t],ue(new(_e(Fr.VAR_CREATE))(i));ue(new(_e(Fr.BLOCK_CREATE))(n))}return n},kn=function(e,t){for(let n=0;n<e.children.length;n++){var i=e.children[n];let o=i.getAttribute("type"),s=i.getAttribute("id");if(!(i=i.textContent))break;t.getVariableMap().createVariable(i,null!=o?o:void 0,s)}},Sn=function(e,t){for(let i=0;i<e.length;i++){let n,o,s,r,a=e[i],l=a.textContent,h="true"===a.getAttribute("pinned"),u=parseInt(null!=(n=a.getAttribute("w"))?n:"50",10),c=parseInt(null!=(o=a.getAttribute("h"))?o:"50",10),d=parseInt(null!=(s=a.getAttribute("x"))?s:"",10),p=parseInt(null!=(r=a.getAttribute("y"))?r:"",10);t.setCommentText(l);let g=t.getIcon(Hl.COMMENT);isNaN(u)||isNaN(c)||g.setBubbleSize(new Fa(u,c)),g.setBubbleVisible(h),setTimeout((()=>{isNaN(d)||isNaN(p)||(d=t.workspace.RTL?t.workspace.getWidth()-(d+u):d,g.setBubbleLocation(new Da(d,p))),g.setBubbleVisible(h)}),1)}},On=function(e){var t=null,i=null;for(let n=0;n<e.childNodes.length;n++){let o=e.childNodes[n];o.nodeType===ta.ELEMENT_NODE&&("block"===o.nodeName.toLowerCase()?t=o:"shadow"===o.nodeName.toLowerCase()&&(i=o))}return{childBlockElement:t,childShadowElement:i}},Rn=function(e,t,i,n){var o,s=e.getAttribute("type");if(!s)throw TypeError("Block type unspecified: "+e.outerHTML);var r=null!=(o=e.getAttribute("id"))?o:void 0;o=t.newBlock(s,r);var a=[],l=[],h=[],u=[],c=[];r=[];for(var d=0;d<e.children.length;d++){var p=e.children[d];if(p.nodeType!==ta.TEXT_NODE)switch(p.nodeName.toLowerCase()){case"mutation":a.push(p);break;case"comment":l.push(p);break;case"data":h.push(p);break;case"title":case"field":u.push(p);break;case"value":case"statement":c.push(p);break;case"next":r.push(p);break;default:console.warn("Ignoring unknown tag: "+p.nodeName)}}for(d=!1,p=0;p<a.length;p++){let e=a[p];o.domToMutation&&(o.domToMutation(e),o.initSvg&&(d=!0))}for(a=d,Sn(l,o),l=h,h=0;h<l.length;h++)o.data=l[h].textContent;if(i){if(n){if(!o.previousConnection)throw TypeError("Next block does not have previous statement.");n=o.previousConnection}else if(o.outputConnection)n=o.outputConnection;else{if(!o.previousConnection)throw TypeError("Child block does not have output or previous statement.");n=o.previousConnection}if(!i.connect(n))throw e=o.workspace.connectionChecker,TypeError(e.getErrorMessage(e.canConnectWithReason(n,i,!1),n,i))}for(i=u,u=0;u<i.length;u++)(h=(l=i[u]).getAttribute("name"))?(d=(n=o).getField(h))?d.fromXml(l):console.warn("Ignoring non-existent field "+h+" in block "+n.type):console.warn(`Ignoring unnamed field in block ${o.type}`);for(i=0;i<c.length;i++){if(!(n=(l=(u=c[i]).getAttribute("name"))?o.getInput(l):null)){console.warn("Ignoring non-existent input "+l+" in block "+s);break}if((u=On(u)).childBlockElement){if(!n.connection)throw TypeError("Input connection does not exist.");Rn(u.childBlockElement,t,n.connection,!1)}if(u.childShadowElement){var g=void 0;null==(g=n.connection)||g.setShadowDom(u.childShadowElement)}}for(s=r,g=0;g<s.length;g++){if((r=On(s[g])).childBlockElement){if(!o.nextConnection)throw TypeError("Next statement does not exist.");if(o.nextConnection.isConnected())throw TypeError("Next statement is already connected.");Rn(r.childBlockElement,t,o.nextConnection,!0)}r.childShadowElement&&o.nextConnection&&o.nextConnection.setShadowDom(r.childShadowElement)}if(a&&o.initSvg(),(t=e.getAttribute("inline"))&&o.setInputsInline("true"===t),(t=e.getAttribute("disabled"))&&o.setDisabledReason("true"===t||"disabled"===t,"MANUALLY_DISABLED"),null!==(t=e.getAttribute("disabled-reasons")))for(var E of t.split(","))o.setDisabledReason(!0,decodeURIComponent(E));if((E=e.getAttribute("deletable"))&&o.setDeletable("true"===E),(E=e.getAttribute("movable"))&&o.setMovable("true"===E),(E=e.getAttribute("editable"))&&o.setEditable("true"===E),(E=e.getAttribute("collapsed"))&&o.setCollapsed("true"===E),"shadow"===e.nodeName.toLowerCase()){for(e=o.getChildren(!1),E=0;E<e.length;E++)if(!e[E].isShadow())throw TypeError("Shadow block not allowed non-shadow child.");o.setShadow(!0)}return o},wn=function(e,t){te(ya.FIELD,e,t,!0)},Zs.lh=function(e){return _c.fromJsonInternal(e)},Ln=function(e){return e&&"object"==typeof e&&"src"in e&&"string"==typeof e.src&&"alt"in e&&"string"==typeof e.alt&&"width"in e&&"number"==typeof e.width&&"height"in e&&"number"==typeof e.height},Zs.oh=function(e,t){if("string"!=typeof e||""===e.trim())throw Error('Error: Invalid extension name "'+e+'"');if(xc[e])throw Error('Error: Extension "'+e+'" is already registered.');if("function"!=typeof t)throw Error('Error: Extension "'+e+'" must be a function');xc[e]=t},Zs.ph=function(e,t){if(!t||"object"!=typeof t)throw Error('Error: Mixin "'+e+'" must be a object');Zs.oh(e,(function(){this.mixin(t)}))},Zs.th=function(e,t,i,n){var o='Error when registering mutator "'+e+'": ';Mn(o,t);var s=Fn(t.compose,t.decompose,o+" compose/decompose");if(i&&"function"!=typeof i)throw Error(o+'Extension "'+e+'" is not a function');Zs.oh(e,(function(){s&&this.setMutator(new Zs.sh(n||[],this)),this.mixin(t),i&&i.apply(this)}))},Dn=function(e){return!!xc[e]},xn=function(e,t,i){var n=xc[e];if("function"!=typeof n)throw Error('Error: Extension "'+e+'" not found.');if(i){if(Pn(t).length)throw Error('Error: tried to apply mutation "'+e+'" to a block that already has mutator functions. Block id: '+t.id)}else var o=Pn(t);if(n.apply(t),i)Mn('Error after applying mutator "'+e+'": ',t);else{e:if(i=o,t=Pn(t),t.length!==i.length)t=!1;else{for(n=0;n<t.length;n++)if(i[n]!==t[n]){t=!1;break e}t=!0}if(!t)throw Error('Error when applying extension "'+e+'": mutation properties changed when applying a non-mutator extension.')}},Fn=function(e,t,i){if(e&&t){if("function"!=typeof e||"function"!=typeof t)throw Error(i+" must be a function");return!0}if(!e&&!t)return!1;throw Error(i+"Must have both or neither functions")},Mn=function(e,t){var i=Fn(t.mutationToDom,t.domToMutation,e+" mutationToDom/domToMutation"),n=Fn(t.saveExtraState,t.loadExtraState,e+" saveExtraState/loadExtraState");if(!i&&!n)throw Error(e+"Mutations must contain either XML hooks, or JSON hooks, or both");Fn(t.compose,t.decompose,e+" compose/decompose")},Pn=function(e){var t=[];return void 0!==e.domToMutation&&t.push(e.domToMutation),void 0!==e.mutationToDom&&t.push(e.mutationToDom),void 0!==e.saveExtraState&&t.push(e.saveExtraState),void 0!==e.loadExtraState&&t.push(e.loadExtraState),void 0!==e.compose&&t.push(e.compose),void 0!==e.decompose&&t.push(e.decompose),t},Zs.yh=function(e,t){var i=[];return function(){i.includes(this.type)||(Bn(this,e,t),i.push(this.type)),this.setTooltip(function(){var i=String(this.getFieldValue(e));return Ji(t[i])}.bind(this))}},Bn=function(e,t,i){var n=e.getField(t);if(n instanceof mc&&!n.isOptionListDynamic()){n=n.getOptions();for(let o of n)o!==mc.SEPARATOR&&([,n]=o,void 0===i[n]&&console.warn(`No tooltip mapping for value ${n} of field ${t} of block type ${e.type}.`))}},Zs.Ah=function(e,t){return function(){this.setTooltip(function(){var i=this.getField(t);return Ji(e).replace("%1",i?i.getText():"")}.bind(this))}},Un=function(e,t){return" "+e+","+t+" "},Vn=function(e,t){return" "+e+t.join("")},Hn=function(e,t){return" M "+e+","+t+" "},Gn=function(e,t){return" m "+e+","+t+" "},Wn=function(e,t){return" l "+e+","+t+" "},qn=function(e){return" l"+e.join("")},$n=function(e,t){return" "+e+" "+t+" "},jn=function(e,t,i,n){return e+" "+i+" "+i+" "+t+n},zn=function(e,t){var i=null,n=null==(t=t.outputConnection)?void 0:t.getConnectionChecker();for(let o,s=0;o=e.inputList[s];s++){let e=o.connection;if(e&&null!=n&&n.canConnect(t,e,!1)){if(i)return null;i=e}}return i},Xn=function(e){return M(e)&&"function"==typeof e.getType&&"function"==typeof e.initView&&"function"==typeof e.dispose&&"function"==typeof e.getWeight&&"function"==typeof e.getSize&&"function"==typeof e.applyColour&&"function"==typeof e.hideForInsertionMarker&&"function"==typeof e.updateEditable&&"function"==typeof e.updateCollapsed&&"function"==typeof e.isShownWhenCollapsed&&"function"==typeof e.setOffsetInBlock&&"function"==typeof e.onLocationChange&&"function"==typeof e.onClick},Yn=function(e){if(!(e.getDescendants(!1).length>100)){var t=e.workspace,i=e.getSvgRoot();t.getAudioManager().play("delete");var n,o=e.getRelativeToSurfaceXY(),s=i.cloneNode(!0);s.setAttribute("transform","translate("+o.x+","+o.y+")"),null==(n=t.getLayerManager())||n.appendToAnimationLayer({getSvgRoot:()=>s}),Kn(s,{x:o.x,y:o.y,width:e.width,height:e.height},t.RTL,new Date)}},Kn=function(e,t,i,n){var o=((new Date).getTime()-n.getTime())/150;o>1?S(e):(e.setAttribute("transform","translate("+(t.x+(i?-1:1)*t.width/2*o)+","+(t.y+t.height/2*o)+") scale("+(1-o)+")"),setTimeout(Kn,10,e,t,i,n))},Jn=function(e){var t=e.workspace,i=t.scale;if(t.getAudioManager().play("click"),!(i<1)){var n=t.getSvgXY(e.getSvgRoot());e.outputConnection?(n.x+=(e.RTL?3:-3)*i,n.y+=13*i):e.previousConnection&&(n.x+=(e.RTL?-23:23)*i,n.y+=3*i);var o=I(ea.CIRCLE,{cx:n.x,cy:n.y,r:0,fill:"none",stroke:"#888","stroke-width":10},t.getParentSvg());e=I(ea.ANIMATE,{id:"animationCircle",begin:"indefinite",attributeName:"r",dur:"150ms",from:0,to:25*i},o),t=I(ea.ANIMATE,{id:"animationOpacity",begin:"indefinite",attributeName:"opacity",dur:"150ms",from:1,to:0},o),e.beginElement(),t.beginElement(),setTimeout((()=>{S(o)}),150)}},Qn=function(e){if(eo(),e.workspace.getAudioManager().play("disconnect"),!(e.workspace.scale<1)){var t=e.getHeightWidth().height;t=Math.atan(10/t)/Math.PI*180,e.RTL||(t*=-1),td=e,Zn(e,t,new Date,0)}},Zn=function(e,t,i,n){var o=[.66,1,.66,0,-.66,-1,-.66,0],s="";i.getTime()+200>(new Date).getTime()&&(s=`skewX(${Math.round(o[n%o.length]*t)})`,ed=setTimeout(Zn,15,e,t,i,n+1)),e.getSvgRoot().setAttribute("transform",`${e.getTranslation()} ${s}`)},eo=function(){td&&(ed&&(clearTimeout(ed),ed=null),td.getSvgRoot().setAttribute("transform",td.getTranslation()),td=null)},to=function(e,t){e.workspace.RTL&&(t.x=e.workspace.getWidth()-t.x);for(var i=e.workspace,n=Zs.Og.snapRadius,o=Da.difference(t,e.getRelativeToSurfaceXY()),s=new Da(0,0),r=i.getAllBlocks(!1).filter((t=>t.id!=e.id)).map((e=>e.getRelativeToSurfaceXY()));io(Da.sum(t,s),r)||no(e,Da.sum(o,s),n);)i.RTL?s.translate(-n,2*n):s.translate(n,2*n);e.moveTo(Da.sum(t,s))},io=function(e,t){return t.some((t=>Math.abs(t.x-e.x)<=1&&Math.abs(t.y-e.y)<=1))},no=function(e,t,i){return e.getConnections_(!1).some((e=>!!e.closest(i,t).connection))},oo=function(e,t,i){var n=i.getBoundingRectangle(),o=n.right-n.left,s=ai(t.top,n.top,t.top+t.height-(n.bottom-n.top))-n.top,r=t.left;return t=t.left+t.width-o,e.RTL?r=Math.min(t,r):t=Math.max(r,t),!(!(e=ai(r,n.left,t)-n.left)&&!s||(i.moveBy(e,s,["inbounds"]),0))},so=function(e){return t=>{var i,n=e.getMetricsManager();if(n.hasFixedEdges()&&!e.isDragging())if(Br.includes(null!=(i=t.type)?i:"")){switch(n=n.getScrollMetrics(!0),i=null,t.type){case Fr.BLOCK_CREATE:case Fr.BLOCK_MOVE:(i=e.getBlockById(t.blockId))&&(i=i.getRootBlock());break;case Fr.COMMENT_CREATE:case Fr.COMMENT_MOVE:case Fr.COMMENT_RESIZE:i=e.getCommentById(t.commentId)}if(i){var o=Zs.gd||!1;Zs.B(t.group),oo(e,n,i)&&!t.group&&console.warn("Moved object in bounds but there was no event group. This may break undo."),Zs.B(o)}}else t.type===Fr.VIEWPORT_CHANGE&&t.scale&&t.oldScale&&t.scale>t.oldScale&&ro(e)}},ro=function(e){var t=e.getMetricsManager();if(t.hasFixedEdges()&&!e.isDragging()){t=t.getScrollMetrics(!0);var i=e.getTopBoundedElements();for(let n,o=0;n=i[o];o++)oo(e,t,n)}},ao=function(e,t){var i=e.toCopyData();return sd=i,rd=P(e)&&e.workspace instanceof ig?e.workspace:null,ad=t,i},lo=function(e,t,i){return e&&t?ho(e,t,i):sd&&rd?ho(sd,rd,ad):null},ho=function(e,t,i){var n,o,s;return t=t.isMutator?t:null!=(n=t.options.parentWorkspace)?n:t,null!=(s=null==(o=ne(ya.PASTER,e.paster,!1))?void 0:o.paste(e,t,i))?s:null},uo=function(e){return"function"==typeof e.getBoundingRectangle&&"function"==typeof e.moveBy},co=function(e){return e&&"function"==typeof e.toCopyData},po=function(e){return e&&"function"==typeof e.isDeletable&&"function"==typeof e.dispose&&"function"==typeof e.setDeleteStyle},go=function(e){return e&&"function"==typeof e.getRelativeToSurfaceXY&&"function"==typeof e.isMovable&&"function"==typeof e.startDrag&&"function"==typeof e.drag&&"function"==typeof e.endDrag&&"function"==typeof e.revertDrag},Eo=function(){ca.registry.register({name:pd.ESCAPE,preconditionFn:e=>!e.isReadOnly(),callback:e=>(e.hideChaff(),!0),keyCodes:[bc.ESC],displayText:()=>Zs.C.SHORTCUTS_ESCAPE})},To=function(){ca.registry.register({name:pd.DELETE,preconditionFn:(e,t)=>(t=t.focusedNode,(t=!e.isReadOnly()&&null!=t&&po(t)&&t.isDeletable()&&!e.isDragging()&&!Zs.t().ephemeralFocusTaken())||e.getAudioManager().playErrorBeep(),t),callback:(e,t,i,n)=>(t.preventDefault(),(t=n.focusedNode)instanceof Pd?t.checkAndDelete():po(t)&&t.isDeletable()&&(Zs.B(!0),t.dispose(),Zs.B(!1),e.getAudioManager().play("delete")),!0),keyCodes:[bc.DELETE,bc.BACKSPACE],displayText:()=>Zs.C.SHORTCUTS_DELETE})},_o=function(e){return!!(co(e)&&po(e)&&go(e))&&(e.isCopyable?e.isCopyable():e instanceof Pd||e instanceof Ec?e.isOwnDeletable()&&e.isOwnMovable():e.isDeletable()&&e.isMovable())},fo=function(){var e=ca.registry.createSerializedKey(bc.C,[bc.CTRL_CMD]);ca.registry.register({name:pd.COPY,preconditionFn(e,t){t=t.focusedNode;var i=e.isFlyout?e.targetWorkspace:e;return(t=!!t&&!!i&&!i.isDragging()&&!Zs.t().ephemeralFocusTaken()&&_o(t))||e.getAudioManager().playErrorBeep(),t},callback:(e,t,i,n)=>(t.preventDefault(),!!((i=n.focusedNode)&&co(i)&&_o(i))&&!!(n=e.isFlyout?e.targetWorkspace:e)&&(i.workspace.isFlyout||n.hideChaff(),n=go(i)&&i.workspace==n?i.getRelativeToSurfaceXY():void 0,(i=!!ao(i,n))&&t instanceof KeyboardEvent&&Ol.show(e,{message:Zs.C.KEYBOARD_NAV_COPIED_HINT.replace("%1",Vt(pd.PASTE)),duration:7,id:"copiedHint"}),i)),keyCodes:[e],displayText:()=>Zs.C.COPY_SHORTCUT})},mo=function(){var e=ca.registry.createSerializedKey(bc.X,[bc.CTRL_CMD]);ca.registry.register({name:pd.CUT,preconditionFn:(e,t)=>((t=!!(t=t.focusedNode)&&!e.isReadOnly()&&!e.isDragging()&&!Zs.t().ephemeralFocusTaken()&&_o(t)&&po(t)&&t.isDeletable())||e.getAudioManager().playErrorBeep(),t),callback:(e,t,i,n)=>!!((i=n.focusedNode)&&_o(i)&&po(i)&&i.isDeletable()&&co(i))&&(n=go(i)?i.getRelativeToSurfaceXY():void 0,n=ao(i,n),i instanceof Pd?(i.checkAndDelete(),t.preventDefault()):po(i)&&(Zs.B(!0),i.dispose(),Zs.B(!1),e.getAudioManager().play("delete"),t.preventDefault()),n&&t instanceof KeyboardEvent&&Ol.show(e,{message:Zs.C.KEYBOARD_NAV_CUT_HINT.replace("%1",Vt(pd.PASTE)),duration:7,id:"cutHint"}),!!n),keyCodes:[e],displayText:()=>Zs.C.CUT_SHORTCUT})},bo=function(){var e=ca.registry.createSerializedKey(bc.V,[bc.CTRL_CMD]);ca.registry.register({name:pd.PASTE,preconditionFn(){var e=rd;if(!e||!e.rendered)return!1;var t=e.isFlyout?e.targetWorkspace:e;return(t=!(!sd||!t||t.isReadOnly()||t.isDragging()||Zs.t().ephemeralFocusTaken()))||e.getAudioManager().playErrorBeep(),t},callback(e,t){var i=sd,n=Zs.t().getFocusedNode();if(!i)return!1;var o=rd;if(!o)return!1;if(Ol.hide(e,"cutHint"),Ol.hide(e,"copiedHint"),!(e=o.isFlyout?o.targetWorkspace:o)||e.isReadOnly())return!1;if(t instanceof PointerEvent){var s=we(e,new Da(t.clientX,t.clientY));return!!lo(i,e,s)}if(t=null==(s=e.getNavigator().getSourceBlockFromNode(n))?void 0:s.getRelativeToSurfaceXY())return!!lo(i,e,t);if(!(s=ad))return!!lo(i,e);var{left:r,top:a,width:l,height:h}=e.getMetricsManager().getViewMetrics(!0);return new xa(a,a+h,r,r+l).contains(s.x,s.y)?!!lo(i,e):(s=new Da(r+l/2,a+h/2),!!lo(i,e,s))},keyCodes:[e],displayText:()=>Zs.C.PASTE_SHORTCUT})},Co=function(){var e=ca.registry.createSerializedKey(bc.Z,[bc.CTRL_CMD]);ca.registry.register({name:pd.UNDO,preconditionFn:e=>!e.isReadOnly()&&!e.isDragging()&&!Zs.t().ephemeralFocusTaken(),callback:(e,t)=>(e.hideChaff(),e.undo(),t.preventDefault(),!0),keyCodes:[e],displayText:()=>Zs.C.UNDO})},vo=function(){var e=ca.registry.createSerializedKey(bc.Z,[bc.CTRL_CMD,bc.SHIFT]),t=ca.registry.createSerializedKey(bc.Y,[bc.CTRL]);ca.registry.register({name:pd.REDO,preconditionFn:e=>!e.isDragging()&&!e.isReadOnly()&&!Zs.t().ephemeralFocusTaken(),callback:(e,t)=>(e.hideChaff(),e.redo(),t.preventDefault(),!0),keyCodes:[e,t],displayText:()=>Zs.C.REDO})},Io=function(){var e=e=>{var t,i=Zs.t().getFocusedNode();return go(i)?i:null!=(t=e.getNavigator().getSourceBlockFromNode(Zs.t().getFocusedNode()))?t:void 0},t=ca.registry.createSerializedKey(bc.M,[bc.SHIFT]),i={name:pd.START_MOVE,preconditionFn:t=>!!(t=e(t))&&yc.mover.canMove(t),callback:(t,i)=>(Xh.setIsActive(!0),(t=e(t))&&Zs.t().focusNode(t),!!t&&yc.mover.startMove(t,i)),keyCodes:[bc.M],displayText:()=>Zs.C.SHORTCUTS_START_MOVE};t=[i,Object.assign({},i,{name:pd.START_MOVE_STACK,keyCodes:[t],displayText:()=>Zs.C.SHORTCUTS_START_MOVE_STACK}),{name:pd.FINISH_MOVE,preconditionFn:()=>yc.mover.isMoving(),callback:(e,t)=>yc.mover.finishMove(t),keyCodes:[bc.ENTER,bc.SPACE],allowCollision:!0,displayText:()=>Zs.C.SHORTCUTS_FINISH_MOVE},{name:pd.ABORT_MOVE,preconditionFn:()=>yc.mover.isMoving(),callback:(e,t)=>yc.mover.abortMove(t),keyCodes:[bc.ESC],allowCollision:!0,displayText:()=>Zs.C.SHORTCUTS_ABORT_MOVE},{name:pd.MOVE_LEFT,preconditionFn:()=>yc.mover.isMoving(),callback:(e,t)=>(t.preventDefault(),yc.mover.move(vc.LEFT,t)),keyCodes:[bc.LEFT,Td],allowCollision:!0,displayText:()=>Zs.C.SHORTCUTS_MOVE_LEFT},{name:pd.MOVE_RIGHT,preconditionFn:()=>yc.mover.isMoving(),callback:(e,t)=>(t.preventDefault(),yc.mover.move(vc.RIGHT,t)),keyCodes:[bc.RIGHT,_d],allowCollision:!0,displayText:()=>Zs.C.SHORTCUTS_MOVE_RIGHT},{name:pd.MOVE_UP,preconditionFn:()=>yc.mover.isMoving(),callback:(e,t)=>(t.preventDefault(),yc.mover.move(vc.UP,t)),keyCodes:[bc.UP,fd],allowCollision:!0,displayText:()=>Zs.C.SHORTCUTS_MOVE_UP},{name:pd.MOVE_DOWN,preconditionFn:()=>yc.mover.isMoving(),callback:(e,t)=>(t.preventDefault(),yc.mover.move(vc.DOWN,t)),keyCodes:[bc.DOWN,md],allowCollision:!0,displayText:()=>Zs.C.SHORTCUTS_MOVE_DOWN}];for(let e of t)ca.registry.register(e)},No=function(){var e=ca.registry.createSerializedKey(bc.ENTER,[bc.CTRL_CMD]),t=ca.registry.createSerializedKey(bc.F10,[bc.SHIFT]);ca.registry.register({name:pd.MENU,preconditionFn:e=>!e.isDragging(),callback:(e,t)=>{if(Xh.setIsActive(!0),(e=Zs.t().getFocusedNode())&&"function"==typeof e.showContextMenu){let i;return e.showContextMenu(t),null==(i=tc)||i.highlightNext(),!0}return!1},keyCodes:[e,t,bc.CONTEXT_MENU],displayText:()=>Zs.C.SHORTCUTS_SHOW_CONTEXT_MENU})},yo=function(){var e={right:{name:pd.NAVIGATE_RIGHT,preconditionFn:e=>!e.isDragging()&&!bu&&!ju,callback:(e,t)=>{var i,n;return t.preventDefault(),Xh.setIsActive(!0),(t=e.RTL?null==(i=Zs.t().getFocusedTree())?void 0:i.getNavigator().getOutNode():null==(n=Zs.t().getFocusedTree())?void 0:n.getNavigator().getInNode())?(Zs.t().focusNode(t),!0):(e.getAudioManager().playErrorBeep(),!1)},keyCodes:[bc.RIGHT],allowCollision:!0,displayText:()=>Zs.C.SHORTCUTS_NAVIGATE_RIGHT},left:{name:pd.NAVIGATE_LEFT,preconditionFn:e=>!e.isDragging()&&!bu&&!ju,callback:(e,t)=>{var i,n;return t.preventDefault(),Xh.setIsActive(!0),(t=e.RTL?null==(i=Zs.t().getFocusedTree())?void 0:i.getNavigator().getInNode():null==(n=Zs.t().getFocusedTree())?void 0:n.getNavigator().getOutNode())?(Zs.t().focusNode(t),!0):(e.getAudioManager().playErrorBeep(),!1)},keyCodes:[bc.LEFT],allowCollision:!0,displayText:()=>Zs.C.SHORTCUTS_NAVIGATE_LEFT},down:{name:pd.NAVIGATE_DOWN,preconditionFn:e=>!e.isDragging()&&!bu&&!ju,callback:(e,t)=>{var i;return t.preventDefault(),Xh.setIsActive(!0),(t=null==(i=Zs.t().getFocusedTree())?void 0:i.getNavigator().getNextNode())?(e.getAudioManager().maybePlayScopeChangeAudioCue(t),Zs.t().focusNode(t),!0):(e.getAudioManager().playErrorBeep(),!1)},keyCodes:[bc.DOWN],allowCollision:!0,displayText:()=>Zs.C.SHORTCUTS_NAVIGATE_DOWN},up:{name:pd.NAVIGATE_UP,preconditionFn:e=>!e.isDragging()&&!bu&&!ju,callback:(e,t)=>{var i;return t.preventDefault(),Xh.setIsActive(!0),(t=null==(i=Zs.t().getFocusedTree())?void 0:i.getNavigator().getPreviousNode())?(e.getAudioManager().maybePlayScopeChangeAudioCue(t),Zs.t().focusNode(t),!0):(e.getAudioManager().playErrorBeep(),!1)},keyCodes:[bc.UP],allowCollision:!0,displayText:()=>Zs.C.SHORTCUTS_NAVIGATE_UP}};for(let t of Object.values(e))ca.registry.register(t)},Ao=function(){ca.registry.register({name:pd.FOCUS_WORKSPACE,preconditionFn:e=>!e.isDragging(),callback:e=>{var t;return Xh.setIsActive(!0),e=bd(e),Zs.t().focusNode(null!=(t=e.getWorkspaceFocusTarget())?t:e),!0},keyCodes:[bc.W],displayText:()=>Zs.C.SHORTCUTS_FOCUS_WORKSPACE})},ko=function(){ca.registry.register({name:pd.FOCUS_TOOLBOX,preconditionFn:e=>!e.isDragging(),callback:(e,t)=>{var i=e.getToolbox();if(i)Xh.setIsActive(!0),Zs.t().focusTree(i);else{if(!(e=e.getFlyout()))return!1;Xh.setIsActive(!0),Zs.t().focusTree(e.getWorkspace())}return t.preventDefault(),!0},keyCodes:[bc.T],displayText:()=>Zs.C.SHORTCUTS_FOCUS_TOOLBOX})},So=function(){ca.registry.register({name:pd.INFORMATION,preconditionFn:()=>!0,callback:e=>{var t=Zs.t().getFocusedNode(),i=e.getNavigator().getSourceBlockFromNode(t);if(i)return e=$t(i,Xr.LOQUACIOUS),v(e),!0;if(t===e){i=0===(e=(t=bd(e)).getTopBlocks().length)?"WORKSPACE_CONTENTS_BLOCKS_ZERO":1===e?"WORKSPACE_CONTENTS_BLOCKS_ONE":"WORKSPACE_CONTENTS_BLOCKS_MANY";let n="";return(t=t.getTopComments().length)>0&&(n=Zs.C[1===t?"WORKSPACE_CONTENTS_COMMENTS_ONE":"WORKSPACE_CONTENTS_COMMENTS_MANY"].replace("%1",String(t))),e=Zs.C[i].replace("%1",String(e)).replace("%2",n),v(e),!0}return!1},keyCodes:[bc.I],displayText:()=>Zs.C.SHORTCUTS_INFORMATION})},Oo=function(){var e=ca.registry.createSerializedKey(bc.I,[bc.SHIFT]);ca.registry.register({name:pd.EXTENDED_INFORMATION,preconditionFn:()=>!0,callback:e=>{if(!(e=e.getNavigator().getSourceBlockFromNode(Zs.t().getFocusedNode())))return!1;for(var t,i=[],n=e;null!=(t=n.outputConnection)&&t.isConnected();)n=n.getParent();for(n!==e&&i.push($t(n,Xr.TERSE)),t=n.getParent();t;)i.push($t(t,Xr.TERSE)),t=t.getParent();if(i.length){let t;i.reverse(),null!=(t=e.outputConnection)&&t.isConnected()||i.push(Zs.C.CURRENT_BLOCK_ANNOUNCEMENT.replace("%1",$t(e,Xr.TERSE))),v(Zs.C.PARENT_BLOCKS_ANNOUNCEMENT.replace("%1",i.join(",")))}else v(Zs.C.NO_PARENT_ANNOUNCEMENT);return!0},keyCodes:[e],displayText:()=>Zs.C.SHORTCUTS_EXTENDED_INFORMATION})},Ro=function(){var e=ca.registry.createSerializedKey(bc.X,[bc.SHIFT]);ca.registry.register({name:pd.DISCONNECT,preconditionFn:(e,t)=>(t=t.focusedNode,(t=!e.isDragging()&&!e.isReadOnly()&&t instanceof Pd&&!t.isShadow())||e.getAudioManager().playErrorBeep(),t),callback:(e,t)=>(Xh.setIsActive(!0),(e=Zs.t().getFocusedNode())instanceof Pd&&(t=!(t instanceof KeyboardEvent&&t.shiftKey),Zs.B(!0),e.unplug(t),Zs.B(!1),!0)),keyCodes:[bc.X,e],displayText:()=>Zs.C.SHORTCUTS_DISCONNECT})},wo=function(){var e=(e,t=Zs.t().getFocusedNode())=>{var i=e.getNavigator();for(let n=t;n&&n!==e;n=i.getParent(n))t=n;return P(t)?t:null},t={name:pd.PREVIOUS_STACK,preconditionFn:t=>!(t.isDragging()||!e(t)||bu||ju),callback:t=>{Xh.setIsActive(!0);var i=e(t);return!!i&&!!(t=e(t,t.getNavigator().navigateStacks(i,-1)))&&(Zs.t().focusNode(t),!0)},keyCodes:[bc.B],displayText:()=>Zs.C.SHORTCUTS_PREVIOUS_STACK};ca.registry.register({name:pd.NEXT_STACK,preconditionFn:t=>!(t.isDragging()||!e(t)||bu||ju),callback:t=>{Xh.setIsActive(!0);var i=e(t);return!!i&&!!(t=t.getNavigator().navigateStacks(i,1))&&(Zs.t().focusNode(t),!0)},keyCodes:[bc.N],displayText:()=>Zs.C.SHORTCUTS_NEXT_STACK}),ca.registry.register(t)},Lo=function(){var e=()=>{var e=Zs.t().getFocusedTree();if(e instanceof ig&&e.isFlyout&&e.targetWorkspace){let t;return null!=(t=e.targetWorkspace.getFlyout())?t:null}return null},t=(e,t)=>{var i=e.getContents().map((e=>e.getElement()));e=(e=(e=>{var t=e.getWorkspace().getNavigator();e=e.getContents().map((e=>e.getElement()));for(var i,n=null!=(i=Zs.t().getFocusedNode())?i:null;n&&!e.includes(n);)n=t.getParent(n);return n})(e))?i.indexOf(e):1===t?-1:i.length;for(let o=1;o<=i.length;o++){var n=e+t*o;if(n<0||n>=i.length)break;if((n=i[n])instanceof ud&&n.isLabel())return n}return null},i=ca.registry.createSerializedKey(bc.H,[bc.SHIFT]);i={name:pd.PREVIOUS_HEADING,preconditionFn:t=>!(t.isDragging()||bu||ju||!e()),callback:()=>{var i=e();return!!i&&!!(i=t(i,-1))&&(Xh.setIsActive(!0),Zs.t().focusNode(i),!0)},keyCodes:[i],displayText:()=>Zs.C.SHORTCUTS_PREVIOUS_HEADING},ca.registry.register({name:pd.NEXT_HEADING,preconditionFn:t=>!(t.isDragging()||bu||ju||!e()),callback:()=>{var i=e();return!!i&&!!(i=t(i,1))&&(Xh.setIsActive(!0),Zs.t().focusNode(i),!0)},keyCodes:[bc.H],displayText:()=>Zs.C.SHORTCUTS_NEXT_HEADING}),ca.registry.register(i)},Do=function(){ca.registry.register({name:pd.PERFORM_ACTION,preconditionFn:e=>!(e.isDragging()||bu||ju||Zs.t().ephemeralFocusTaken()),callback:(e,t)=>{if(Xh.setIsActive(!0),(e=Zs.t().getFocusedNode())&&"performAction"in e){let i;return t.preventDefault(),null==(i=e.performAction)||i.call(e,t),!0}return!1},keyCodes:[bc.ENTER,bc.SPACE],allowCollision:!0,displayText:()=>Zs.C.SHORTCUTS_PERFORM_ACTION})},xo=function(){ca.registry.register({name:pd.DUPLICATE,preconditionFn:(e,t)=>(({focusedNode:t}=t),(t=!e.isDragging()&&!e.isReadOnly()&&!e.isFlyout&&(!(t instanceof Pd)||t.isDuplicatable()))||e.getAudioManager().playErrorBeep(),t),callback:(e,t,i,n)=>(Xh.setIsActive(!0),!!(t=co(n.focusedNode)&&n.focusedNode)&&!!(t=t.toCopyData())&&!!lo(t,e)),keyCodes:[bc.D],allowCollision:!0,displayText:()=>Zs.C.SHORTCUTS_DUPLICATE})},Fo=function(){ca.registry.register({name:pd.CLEANUP,preconditionFn:e=>!e.isDragging()&&!e.isReadOnly()&&!e.isFlyout,callback:e=>(Xh.setIsActive(!0),e.cleanUp(),!0),keyCodes:[bc.C],allowCollision:!0,displayText:()=>Zs.C.SHORTCUTS_CLEANUP})},Mo=function(){var e=ca.registry.createSerializedKey(bc.J,[bc.CTRL_CMD]);ca.registry.register({name:pd.SHOW_TOOLTIP,preconditionFn:e=>!e.isDragging(),callback:e=>{var t=Zs.t().getFocusedNode();return null!==t&&(Xh.setIsActive(!0),Vi(t,e)),!0},keyCodes:[e],allowCollision:!0,displayText:()=>Zs.C.SHORTCUTS_SHOW_TOOLTIP})},Po=function(){var e=ca.registry.createSerializedKey(bc.A,[bc.ALT,bc.SHIFT]),t=!1;ca.registry.register({name:pd.TOGGLE_SCREENREADER,preconditionFn:()=>!0,callback:(e,i)=>{var n,o;return t=!t,Xh.setScopeChangeAudioCuesEnabled(t),e.getNavigator().setNavigationLoops(!t),null==(n=e.getToolbox())||n.getNavigator().setNavigationLoops(!t),null==(o=e.getFlyout())||o.getWorkspace().getNavigator().setNavigationLoops(!t),Ol.show(e,{message:(t?Zs.C.SCREENREADER_MODE_ENABLED:Zs.C.SCREENREADER_MODE_DISABLED).replace("%1",Vt(pd.TOGGLE_SCREENREADER)),duration:7,id:"screenreaderHint"}),i.preventDefault(),!0},keyCodes:[e],allowCollision:!0,displayText:()=>Zs.C.SHORTCUTS_TOGGLE_SCREENREADER_MODE})},Bo=function(){ca.registry.register({name:pd.JUMP_BLOCK_START,preconditionFn:Cd,callback(e,t,i,n){return!!n.focusedNode&&(null!=(o=e=e.getNavigator().getSourceBlockFromNode(n.focusedNode))&&o.getFullBlockField()&&e.getParent()&&(e=e.getParent()),!!e&&(Zs.t().focusNode(e),!0));var o},keyCodes:[bc.HOME],displayText:()=>Zs.C.SHORTCUTS_JUMP_BLOCK_START})},Uo=function(){ca.registry.register({name:pd.JUMP_BLOCK_END,preconditionFn:Cd,callback(e,t,i,n){return!(!n.focusedNode||(null!=(o=e=e.getNavigator().getSourceBlockFromNode(n.focusedNode))&&o.getFullBlockField()&&e.getParent()&&(e=e.getParent()),!e||!(o=e.inputList).length||!((o=o[o.length-1].connection)&&o instanceof jc)||(Zs.t().focusNode(o),0)));var o},keyCodes:[bc.END],displayText:()=>Zs.C.SHORTCUTS_JUMP_BLOCK_END})},Vo=function(){ca.registry.register({name:pd.JUMP_TOP_STACK,preconditionFn:Cd,callback:(e,t,i,n)=>!!n.focusedNode&&!!(e=e.getNavigator().getSourceBlockFromNode(n.focusedNode))&&(e=e.getRootBlock(),Zs.t().focusNode(e),!0),keyCodes:[bc.PAGE_UP],displayText:()=>Zs.C.SHORTCUTS_JUMP_TOP_STACK})},Ho=function(){ca.registry.register({name:pd.JUMP_BOTTOM_STACK,preconditionFn:Cd,callback(e,t,i,n){return!(!n.focusedNode||!(e=e.getNavigator().getSourceBlockFromNode(n.focusedNode))||!(e=null==(o=e.getRootBlock().lastConnectionInStack(!1))?void 0:o.getSourceBlock())||(o=(o=e.getDescendants(!0))[o.length-1],Zs.t().focusNode(o),0));var o},keyCodes:[bc.PAGE_DOWN],displayText:()=>Zs.C.SHORTCUTS_JUMP_BOTTOM_STACK})},Go=function(){var e=ca.registry.createSerializedKey(bc.HOME,[bc.CTRL_CMD]);ca.registry.register({name:pd.JUMP_FIRST_BLOCK,preconditionFn:e=>!e.isDragging()&&!Zs.t().ephemeralFocusTaken(),callback(e){var t=Id(e);return t?!!t.length&&(Zs.t().focusNode(t[0]),!0):!!(e=e.getTopBlocks(!0)).length&&(Zs.t().focusNode(e[0]),!0)},keyCodes:[e],displayText:()=>Zs.C.SHORTCUTS_JUMP_FIRST_BLOCK})},Wo=function(){var e=ca.registry.createSerializedKey(bc.END,[bc.CTRL_CMD]);ca.registry.register({name:pd.JUMP_LAST_BLOCK,preconditionFn:e=>!e.isDragging()&&!Zs.t().ephemeralFocusTaken(),callback(e){var t=Id(e);return t?!!t.length&&(Zs.t().focusNode(t[t.length-1]),!0):!!(e=e.getAllBlocks(!0)).length&&(Zs.t().focusNode(e[e.length-1]),!0)},keyCodes:[e],displayText:()=>Zs.C.SHORTCUTS_JUMP_LAST_BLOCK})},qo=function(e,t,i){var n=t[t.length-1].start>=t[0].start;return{items:e,leadingEdge:e=>n?t[e].start:-t[e].end,trailingEdge:e=>n?t[e].end:-t[e].start,viewLeadingEdge:n?i.start:-i.end,viewTrailingEdge:n?i.end:-i.start}},$o=function(e){var t=e.getNavigator().getNavigableItems(e.getRootFocusableNode());if(!t.length)return null;var i=e.isHorizontal(),n=e=>(e=e.getBoundingClientRect(),i?{start:e.left,end:e.right}:{start:e.top,end:e.bottom});e=e.getRootFocusableNode().getFocusableElement();var o=t.map((e=>n(e.getFocusableElement())));return qo(t,o,n(e))},jo=function(e){var t=e.getNavigator().getNavigableItems(e.getRootFocusableNode()).filter((e=>uo(e)));if(!t.length)return null;var i,n,o=!(null==(i=e.targetWorkspace)||null==(n=i.getFlyout())||!n.horizontalLayout);return e=e.getMetricsManager().getViewMetrics(!0),e=o?{start:e.left,end:e.left+e.width}:{start:e.top,end:e.top+e.height},i=t.map((e=>(e=e.getBoundingRectangle(),o?{start:e.left,end:e.right}:{start:e.top,end:e.bottom}))),qo(t,i,e)},zo=function(e,t){var i=vd(e);if(!(e=i?$o(i):jo(e)))return!1;i=e.items;var n=Zs.t().getFocusedNode();n=n?i.indexOf(n):-1;var o=e.viewTrailingEdge-e.viewLeadingEdge,s=-1;if(t)for(var r=n>=0?Math.max(e.viewLeadingEdge,e.leadingEdge(n)):e.viewLeadingEdge,a=0;a<i.length&&!(e.leadingEdge(a)>=r+o);a++)s=a;else for(r=n>=0?Math.min(e.viewTrailingEdge,e.trailingEdge(n)):e.viewTrailingEdge,a=i.length-1;a>=0&&!(e.trailingEdge(a)<=r-o);a--)s=a;return!(s<0||s===n&&((s+=t?1:-1)<0||s>=i.length)||(Zs.t().focusNode(i[s]),0))},Xo=function(){ca.registry.register({name:pd.JUMP_PREVIOUS_PAGE,preconditionFn:Nd,callback:(e,t)=>!!zo(e,!1)&&(t.preventDefault(),!0),keyCodes:[bc.PAGE_UP],allowCollision:!0,displayText:()=>Zs.C.SHORTCUTS_JUMP_PREVIOUS_PAGE})},Yo=function(){ca.registry.register({name:pd.JUMP_NEXT_PAGE,preconditionFn:Nd,callback:(e,t)=>!!zo(e,!0)&&(t.preventDefault(),!0),keyCodes:[bc.PAGE_DOWN],allowCollision:!0,displayText:()=>Zs.C.SHORTCUTS_JUMP_NEXT_PAGE})},Ko=function(){var e=[{name:pd.SCROLL_LEFT,preconditionFn:kd,callback:(e,t)=>Od(e,t,Ed.LEFT),keyCodes:[Td],allowCollision:!0,displayText:()=>Zs.C.SHORTCUTS_SCROLL_LEFT},{name:pd.SCROLL_RIGHT,preconditionFn:kd,callback:(e,t)=>Od(e,t,Ed.RIGHT),keyCodes:[_d],allowCollision:!0,displayText:()=>Zs.C.SHORTCUTS_SCROLL_RIGHT},{name:pd.SCROLL_UP,preconditionFn:kd,callback:(e,t)=>Od(e,t,Ed.UP),keyCodes:[fd],allowCollision:!0,displayText:()=>Zs.C.SHORTCUTS_SCROLL_UP},{name:pd.SCROLL_DOWN,preconditionFn:kd,callback:(e,t)=>Od(e,t,Ed.DOWN),keyCodes:[md],allowCollision:!0,displayText:()=>Zs.C.SHORTCUTS_SCROLL_DOWN}];for(let t of e)ca.registry.register(t)},Jo=function(){Eo(),To(),fo(),mo(),bo(),Co(),vo()},Qo=function(){No(),Io(),Ao(),ko(),yo(),Ro(),wo(),Lo(),Do(),xo(),Fo(),Mo()},Zo=function(){So(),Oo(),Po()},es=function(e,t=!1){var i=Zs.C.KEYBOARD_NAV_UNCONSTRAINED_MOVE_HINT.replace("%1",Cr||mr||br?Zs.C.COMMAND_KEY:Zs.C.CONTROL_KEY).replace("%2",Zs.C.ENTER_KEY);Ol.show(e,{message:i,id:"unconstrainedMoveHint",oncePerSession:!t})},ts=function(e){var t=Zs.C.KEYBOARD_NAV_CONSTRAINED_MOVE_HINT.replace("%1",Zs.C.ENTER_KEY);Ol.show(e,{message:t,id:"constrainedMoveHint",oncePerSession:!0})},is=function(e){var t=[];for(var i of e.getIcons()){if(e.isCollapsed()&&!i.isShownWhenCollapsed())continue;let n;t.push(i),pt(i)&&i.bubbleIsVisible()&&(n=i.getBubble())&&t.push(n)}for(let n of e.inputList)n.isVisible()&&(t.push(...n.fieldRow),(i=n.connection)&&(t.push(i),(i=i.targetBlock())&&(t.push(i),(i=i.lastConnectionInStack(!1))&&t.push(i))));return e.nextConnection&&!e.isCollapsed()&&t.push(e.nextConnection),t},ns=function(e,t,i){return-1===(t=(e=is(e)).indexOf(t))?null:(i=t+i)>=0&&i<e.length?e[i]:null},os=function(e){return e&&"function"==typeof e.getChildToolboxItems&&"function"==typeof e.isExpanded&&"function"==typeof e.toggleExpanded&&qt(e)&&e.isCollapsible()},ss=function(e){var t=e.options.toolboxPosition;return e.options.RTL&&t!==Ya.TOP&&t!==Ya.BOTTOM?t===Ya.LEFT?Ya.RIGHT:Ya.LEFT:t},rs=function(e,t){te(ya.ICON,e.toString(),t)},as=function(e){return"function"==typeof e.getProcedureModel&&"function"==typeof e.doProcedureUpdate&&"function"==typeof e.isProcedureDef},ls=function(e){return e&&"function"==typeof e.startPublishing&&"function"==typeof e.stopPublishing},hs=function(e){var t=e.getProcedureMap().getProcedures().filter((e=>!e.getReturnTypes())).map((e=>[e.getName(),e.getParameters().map((e=>e.getName())),!1]));e.getBlocksByType("procedures_defnoreturn",!1).forEach((e=>{!as(e)&&Et(e)&&t.push(e.getProcedureDef())}));var i=e.getProcedureMap().getProcedures().filter((e=>!!e.getReturnTypes())).map((e=>[e.getName(),e.getParameters().map((e=>e.getName())),!0]));return e.getBlocksByType("procedures_defreturn",!1).forEach((e=>{!as(e)&&Et(e)&&i.push(e.getProcedureDef())})),t.sort(us),i.sort(us),[t,i]},us=function(e,t){return e[0].localeCompare(t[0],void 0,{sensitivity:"base"})},Zs.Bj=function(e,t){if(t.isInFlyout)return e;for(e=e||Zs.C.UNNAMED_KEY||"unnamed";cs(e,t.workspace,t);){let t=e.match(/^(.*?)(\d+)$/);e=t?t[1]+(parseInt(t[2])+1):e+"2"}return e},cs=function(e,t,i){for(let n of t.getAllBlocks(!1))if(n!==i&&Et(n)&&Zs.Cj.equals(n.getProcedureDef()[0],e))return!0;i=i&&as(i)?null==i?void 0:i.getProcedureModel():void 0;for(let n of t.getProcedureMap().getProcedures())if(n!==i&&Zs.Cj.equals(n.getName(),e))return!0;return!1},Zs.Ej=function(e){var t=this.getSourceBlock();if(!t)throw new $u;e=e.trim();var i=Zs.Bj(e,t);as(t)&&!t.isInsertionMarker()&&t.getProcedureModel().setName(i);var n=this.getValue();if(n!==e&&n!==i)for(e=t.workspace.getAllBlocks(!1),t=0;t<e.length;t++){let o=e[t];o.renameProcedure&&o.renameProcedure(n,i)}return i},ds=function(e){function t(e,t){for(let[n,o]of e)i.push({kind:"block",type:t,gap:16,extraState:{name:n,params:o}})}var i=[];return Ur.procedures_defnoreturn&&i.push({kind:"block",type:"procedures_defnoreturn",gap:16,fields:{NAME:Zs.C.PROCEDURES_DEFNORETURN_PROCEDURE}}),Ur.procedures_defreturn&&i.push({kind:"block",type:"procedures_defreturn",gap:16,fields:{NAME:Zs.C.PROCEDURES_DEFRETURN_PROCEDURE}}),Ur.procedures_ifreturn&&i.push({kind:"block",type:"procedures_ifreturn",gap:16}),i.length&&(i[i.length-1].gap=24),t((e=hs(e))[0],"procedures_callnoreturn"),t(e[1],"procedures_callreturn"),i},ps=function(e){var t=[],i=e.getBlocksByType("procedures_mutatorarg",!1);for(let e,n=0;e=i[n];n++)t.push(e.getFieldValue("NAME"));i=Zs.sc("xml");var n=Zs.sc("block");n.setAttribute("type","procedures_mutatorarg");var o=Zs.sc("field");o.setAttribute("name","NAME"),t=Ct("x",t),t=Zs.tc(t),o.appendChild(t),n.appendChild(o),i.appendChild(n),e.updateToolbox(i)},gs=function(e){if(e.type===Fr.BUBBLE_OPEN&&"mutator"===e.bubbleType&&e.isOpen&&e.blockId){var t=(e=V(e.workspaceId).getBlockById(e.blockId)).type;"procedures_defnoreturn"!==t&&"procedures_defreturn"!==t||(e=e.getIcon(Zs.sh.TYPE).getWorkspace(),ps(e),e.addChangeListener(Es))}},Es=function(e){e.type!==Fr.BLOCK_CREATE&&e.type!==Fr.BLOCK_DELETE&&e.type!==Fr.BLOCK_CHANGE&&e.type!==Fr.BLOCK_FIELD_INTERMEDIATE_CHANGE||(e=V(e.workspaceId),ps(e))},Ts=function(e,t){return t.getAllBlocks(!1).filter((t=>as(t)&&!t.isProcedureDef()&&t.getProcedureModel()&&Zs.Cj.equals(t.getProcedureModel().getName(),e)||t&&"function"==typeof t.getProcedureCall&&"function"==typeof t.renameProcedure&&Zs.Cj.equals(t.getProcedureCall(),e)))},Zs.Kj=function(e){var t=Zs.Qc,i=e.getProcedureDef()[0],n=e.mutationToDom(!0);e=Ts(i,e.workspace);for(let s,r=0;s=e[r];r++){i=(i=s.mutationToDom())&&De(i),s.domToMutation&&s.domToMutation(n);var o=s.mutationToDom();i!==(o=o&&De(o))&&(Zs.Qc=!1,ue(new(_e(Fr.BLOCK_CHANGE))(s,"mutation",null,i,o)),Zs.Qc=t)}},Zs.Lj=function(e,t){for(let i of t.getAllBlocks(!1))if(as(i)&&i.isProcedureDef()&&Zs.Cj.equals(i.getProcedureModel().getName(),e)||Et(i)&&Zs.Cj.equals(i.getProcedureDef()[0],e))return i;return null},_s=function(e,t){te(ya.RENDERER,e,t)},fs=function(e,t,i){return(e=new(ne(ya.RENDERER,e,void 0))(e)).init(t,i),e},ms=function(e){vt(e.getTargetWorkspace(),void 0,"String")},bs=function(e){vt(e.getTargetWorkspace(),void 0,"Number")},Cs=function(e){vt(e.getTargetWorkspace(),void 0,"Colour")},vs=function(e){return Ur.variables_set_dynamic||Ur.variables_get_dynamic||console.warn("There are no dynamic variable blocks, but there is a dynamic variable category."),e.registerButtonCallback("CREATE_VARIABLE_STRING",ms),e.registerButtonCallback("CREATE_VARIABLE_NUMBER",bs),e.registerButtonCallback("CREATE_VARIABLE_COLOUR",Cs),[{kind:"button",text:Zs.C.NEW_STRING_VARIABLE,callbackkey:"CREATE_VARIABLE_STRING"},{kind:"button",text:Zs.C.NEW_NUMBER_VARIABLE,callbackkey:"CREATE_VARIABLE_NUMBER"},{kind:"button",text:Zs.C.NEW_COLOUR_VARIABLE,callbackkey:"CREATE_VARIABLE_COLOUR"},...mt(e,e.getVariableMap().getAllVariables(),!1,"variables_get_dynamic","variables_set_dynamic")]},Is=function(e){var t=e.saveState();return e.getParameters().length?(t.parameters=e.getParameters().map((e=>e.saveState())),t):t},Ns=function(e,t,i,n){if(e=e.loadState(i,n),!i.parameters)return e;for(let[o,s]of i.parameters.entries())e.insertParameter(t.loadState(s,n),o);return e},ys=function(e,t){return e<=0?0:(t=Math.min(Math.abs(t),e),e-Math.sqrt(e*e-t*t))},As=function(e,t){e.setAttribute("dir","LTR"),E(e,t.hasCss,t.pathToMedia);var i=I(ea.SVG,{xmlns:"http://www.w3.org/2000/svg","xmlns:html":"http://www.w3.org/1999/xhtml","xmlns:xlink":"http://www.w3.org/1999/xlink",version:"1.1",class:"blocklySvg"},e),n=I(ea.DEFS,{},i),o=String(Math.random()).substring(2);return t.gridPattern=pp.createDom(o,t.gridOptions,n,e),i},ks=function(e,t,i){i.parentWorkspace=null;var n=(i=new ig(i)).options;i.scale=n.zoomOptions.startScale,t.appendChild(i.createDom("blocklyMainBackground",e));var o=i.getRenderer().getClassName();return o&&N(e,o),(o=i.getTheme().getClassName())&&N(e,o),!n.hasCategories&&n.languageTree&&(o=i.addFlyout(ea.SVG),e.insertBefore(o,t)),n.hasTrashcan&&i.addTrashcan(),n.zoomOptions&&n.zoomOptions.controls&&i.addZoomControls(),i.getThemeManager().subscribe(t,"workspaceBackgroundColour","background-color"),i.translate(0,0),i.addChangeListener(so(i)),K(i),en(),li(),Li(),i},Ss=function(e){var t=e.options,i=e.getParentSvg();if(r(i.parentNode,"contextmenu",null,(function(e){h(e)||e.preventDefault()})),i=r(window,"resize",null,(function(){Ui(),e.hideComponents(!0),K(e),Ni(),ln(),ro(e)})),e.setResizeHandlerWrapper(i),Os(),t.languageTree){i=e.getToolbox();let n=e.getFlyout(!0);i?i.init():n&&(n.init(e),n.show(t.languageTree),"function"==typeof n.scrollToStart&&n.scrollToStart())}t.hasTrashcan&&e.trashcan.init(),t.zoomOptions&&t.zoomOptions.controls&&e.zoomControls_.init(),t.moveOptions&&t.moveOptions.scrollbars?(e.scrollbar=new lp(e,!0===t.moveOptions.scrollbars||!!t.moveOptions.scrollbars.horizontal,!0===t.moveOptions.scrollbars||!!t.moveOptions.scrollbars.vertical,"blocklyMainWorkspaceScrollbar"),e.scrollbar.resize()):e.setMetrics({x:.5,y:.5}),t.hasSounds&&Rs(t.pathToMedia,e)},Os=function(){Mg||(r(document,"scroll",null,(function(){var e=H();for(let t,i=0;t=e[i];i++)t instanceof ig&&t.updateInverseScreenCTM()})),a(document,"touchend",null,t),a(document,"touchcancel",null,t),a(document,"keydown",null,(function(e){"Tab"===e.key&&Xh.setIsActive(!0)}))),Mg=!0},Rs=function(e,t){(t=t.getAudioManager()).load([`${e}click.mp3`],"click"),t.load([`${e}disconnect.mp3`],"disconnect"),t.load([`${e}delete.mp3`],"delete"),t.load([`${e}drop.mp3`],"drop")},ws=function(){nc.registry.register({displayText:()=>Zs.C.UNDO,preconditionFn:e=>e.workspace.getUndoStack().length>0?"enabled":"disabled",callback(e){e.workspace.undo()},scopeType:nc.ScopeType.WORKSPACE,id:"undoWorkspace",weight:1,associatedKeyboardShortcut:"undo"})},Ls=function(){nc.registry.register({displayText:()=>Zs.C.REDO,preconditionFn:e=>e.workspace.getRedoStack().length>0?"enabled":"disabled",callback(e){e.workspace.redo()},scopeType:nc.ScopeType.WORKSPACE,id:"redoWorkspace",weight:2,associatedKeyboardShortcut:"redo"})},Ds=function(){nc.registry.register({displayText:()=>Zs.C.CLEAN_UP,preconditionFn:e=>e.workspace.isMovable()?e.workspace.getTopBlocks(!1).length>1?"enabled":"disabled":"hidden",callback(e){e.workspace.cleanUp()},scopeType:nc.ScopeType.WORKSPACE,id:"cleanWorkspace",weight:3,associatedKeyboardShortcut:"cleanup"})},xs=function(e,t){function i(t){o--,t.setCollapsed(e),0===o&&Zs.B(!1)}var n=0,o=0;Zs.B(!0);for(let e=0;e<t.length;e++){let s=t[e];for(;s;)o++,setTimeout(i.bind(null,s),n),s=s.getNextBlock(),n+=10}},Fs=function(){nc.registry.register({displayText:()=>Zs.C.COLLAPSE_ALL,preconditionFn(e){if(e.workspace.options.collapse){e=e.workspace.getTopBlocks(!1);for(let t=0;t<e.length;t++){let i=e[t];for(;i;){if(!i.isCollapsed())return"enabled";i=i.getNextBlock()}}return"disabled"}return"hidden"},callback(e){xs(!0,e.workspace.getTopBlocks(!0))},scopeType:nc.ScopeType.WORKSPACE,id:"collapseWorkspace",weight:4})},Ms=function(){nc.registry.register({displayText:()=>Zs.C.EXPAND_ALL,preconditionFn(e){if(e.workspace.options.collapse){e=e.workspace.getTopBlocks(!1);for(let t=0;t<e.length;t++){let i=e[t];for(;i;){if(i.isCollapsed())return"enabled";i=i.getNextBlock()}}return"disabled"}return"hidden"},callback(e){xs(!1,e.workspace.getTopBlocks(!0))},scopeType:nc.ScopeType.WORKSPACE,id:"expandWorkspace",weight:5})},Ps=function(e,t){if(e.isDeletable())Array.prototype.push.apply(t,e.getDescendants(!1));else{e=e.getChildren(!1);for(let i=0;i<e.length;i++)Ps(e[i],t)}},Bs=function(e){var t=[];e=e.getTopBlocks(!0);for(let i=0;i<e.length;i++)Ps(e[i],t);return t},Us=function(e,t){t?Zs.B(t):(Zs.B(!0),t=Zs.gd);var i=e.shift();i&&(i.isDeadOrDying()?Us(e,t):(i.dispose(!1,!0),setTimeout(Us,10,e,t))),Zs.B(!1)},Vs=function(){nc.registry.register({displayText:e=>e.workspace?1===(e=Bs(e.workspace).length)?Zs.C.DELETE_BLOCK:Zs.C.DELETE_X_BLOCKS.replace("%1",`${e}`):"",preconditionFn:e=>e.workspace&&Bs(e.workspace).length>0?"enabled":"disabled",callback(e){if(e.workspace){e.workspace.cancelCurrentGesture();var t=Bs(e.workspace);t.length<2?Us(t):ut(Zs.C.DELETE_ALL_BLOCKS.replace("%1",String(t.length)),(function(e){e&&Us(t)}))}},scopeType:nc.ScopeType.WORKSPACE,id:"workspaceDelete",weight:6})},Hs=function(){nc.registry.register({displayText:()=>Zs.C.DUPLICATE_BLOCK,preconditionFn:e=>!(e=e.block).isInFlyout&&e.isDeletable()&&e.isMovable()?e.isDuplicatable()?"enabled":"disabled":"hidden",callback(e){if(e.block){var t=e.block.toCopyData();t&&lo(t,e.block.workspace)}},scopeType:nc.ScopeType.BLOCK,id:"blockDuplicate",weight:1,associatedKeyboardShortcut:"duplicate"})},Gs=function(){nc.registry.register({displayText:e=>e.block.hasIcon(Tp.TYPE)?Zs.C.REMOVE_COMMENT:Zs.C.ADD_COMMENT,preconditionFn(e){var t,i;return(t=(e=e.block)&&!e.isInFlyout&&e.workspace.options.comments&&!e.isCollapsed()&&e.isEditable())&&!(t=e.hasIcon(Tp.TYPE))&&(t=!(e=!(!e||!e.isSimpleReporter())&&(null==(i=e.getFields().next().value)?void 0:i.isFullBlockField()))),t?"enabled":"hidden"},callback(e){(e=e.block)&&e.hasIcon(Tp.TYPE)?e.setCommentText(null):e.setCommentText("")},scopeType:nc.ScopeType.BLOCK,id:"blockComment",weight:2})},Ws=function(){nc.registry.register({displayText:e=>e.block.getInputsInline()?Zs.C.EXTERNAL_INPUTS:Zs.C.INLINE_INPUTS,preconditionFn(e){if(!(e=e.block).isInFlyout&&e.isMovable()&&!e.isCollapsed())for(let t=1;t<e.inputList.length;t++)if(!(e.inputList[t-1]instanceof Sg||e.inputList[t]instanceof Sg))return"enabled";return"hidden"},callback(e){e.block.setInputsInline(!e.block.getInputsInline())},scopeType:nc.ScopeType.BLOCK,id:"blockInline",weight:3})},qs=function(){nc.registry.register({displayText:e=>e.block.isCollapsed()?Zs.C.EXPAND_BLOCK:Zs.C.COLLAPSE_BLOCK,preconditionFn:e=>!(e=e.block).isInFlyout&&e.isMovable()&&e.workspace.options.collapse?"enabled":"hidden",callback(e){e.block.setCollapsed(!e.block.isCollapsed())},scopeType:nc.ScopeType.BLOCK,id:"blockCollapseExpand",weight:4})},$s=function(){nc.registry.register({displayText:e=>e.block.hasDisabledReason("MANUALLY_DISABLED")?Zs.C.ENABLE_BLOCK:Zs.C.DISABLE_BLOCK,preconditionFn(e){if(!(e=e.block).isInFlyout&&e.workspace.options.disable&&e.isEditable()){var t=e.getDisabledReasons();return t=t.size>(t.has("MANUALLY_DISABLED")?1:0),e.getInheritedDisabled()||t?"disabled":"enabled"}return"hidden"},callback(e){e=e.block;var t=Zs.gd;t||Zs.B(!0),e.setDisabledReason(!e.hasDisabledReason("MANUALLY_DISABLED"),"MANUALLY_DISABLED"),Zs.B(t)},scopeType:nc.ScopeType.BLOCK,id:"blockDisable",weight:5})},js=function(){nc.registry.register({displayText(e){var t=e.block;return e=t.getDescendants(!1).length,(t=t.getNextBlock())&&(e-=t.getDescendants(!1).length),1===e?Zs.C.DELETE_BLOCK:Zs.C.DELETE_X_BLOCKS.replace("%1",`${e}`)},preconditionFn:e=>!e.block.isInFlyout&&e.block.isDeletable()?"enabled":"hidden",callback(e){e.block&&(Zs.t().focusNode(e.block),e.block.checkAndDelete())},scopeType:nc.ScopeType.BLOCK,id:"blockDelete",weight:6,associatedKeyboardShortcut:"delete"})},zs=function(){nc.registry.register({displayText:()=>Zs.C.HELP,preconditionFn:e=>("function"==typeof(e=e.block).helpUrl?e.helpUrl():e.helpUrl)?"enabled":"hidden",callback(e){e.block.showHelp()},scopeType:nc.ScopeType.BLOCK,id:"blockHelp",weight:7})},Xs=function(){nc.registry.register({displayText:()=>Zs.C.REMOVE_COMMENT,preconditionFn(e){var t;return null!=(t=e.comment)&&t.isDeletable()?"enabled":"hidden"},callback(e){var t,i;Zs.B(!0),null==(t=e.comment)||t.dispose(),Zs.B(!1),null==(i=e.comment)||i.workspace.getAudioManager().play("delete")},scopeType:nc.ScopeType.COMMENT,id:"commentDelete",weight:6,associatedKeyboardShortcut:"delete"})},Ys=function(){nc.registry.register({displayText:()=>Zs.C.DUPLICATE_COMMENT,preconditionFn(e){var t;return null!=(t=e.comment)&&t.isMovable()?"enabled":"hidden"},callback(e){if(e.comment){var t=e.comment.toCopyData();t&&lo(t,e.comment.workspace)}},scopeType:nc.ScopeType.COMMENT,id:"commentDuplicate",weight:1,associatedKeyboardShortcut:"duplicate"})},Ks=function(){nc.registry.register({displayText:()=>Zs.C.ADD_COMMENT,preconditionFn:e=>{var t;return null!=(t=e.workspace)&&t.isMutator?"hidden":"enabled"},callback:(e,t,i,n)=>{(e=e.workspace)&&(Zs.B(!0),(t=new Ec(e)).moveTo(we(e,new Da(n.x,n.y))),Zs.t().focusNode(t),Zs.B(!1))},scopeType:nc.ScopeType.WORKSPACE,id:"commentCreate",weight:8})},Js=function(){ws(),Ls(),Ds(),Fs(),Ms(),Vs(),Hs(),Gs(),Ws(),qs(),$s(),js(),zs()},(Qs=Qs||{}).scope={},Qs.ASSUME_ES2020=!1,Qs.ASSUME_ES6=Qs.ASSUME_ES2020,Qs.ASSUME_ES5=Qs.ASSUME_ES6,Qs.ASSUME_NO_NATIVE_MAP=!1,Qs.ASSUME_NO_NATIVE_SET=!1,Qs.ISOLATE_POLYFILLS=!1,Qs.FORCE_POLYFILL_PROMISE=!1,Qs.FORCE_POLYFILL_PROMISE_WHEN_NO_UNHANDLED_REJECTION=!1,Qs.INSTRUMENT_ASYNC_CONTEXT=!0,Qs.objectCreate=Qs.ASSUME_ES5||"function"==typeof Object.create?Object.create:function(e){function t(){}return t.prototype=e,new t},Qs.defineProperty=Qs.ASSUME_ES5||"function"==typeof Object.defineProperties?Object.defineProperty:function(e,t,i){return e==Array.prototype||e==Object.prototype||(e[t]=i.value),e},Qs.getGlobal=function(e){e=["object"==typeof globalThis&&globalThis,e,"object"==typeof window&&window,"object"==typeof self&&self,"object"==typeof i.g&&i.g];for(var t=0;t<e.length;++t){var n=e[t];if(n&&n.Math==Math)return n}throw Error("Cannot find global object")},Qs.global=Qs.ASSUME_ES2020?globalThis:Qs.getGlobal(this),Qs.IS_SYMBOL_NATIVE="function"==typeof Symbol&&"symbol"==typeof Symbol("x"),Qs.TRUST_ES6_POLYFILLS=!Qs.ISOLATE_POLYFILLS||Qs.IS_SYMBOL_NATIVE,Qs.polyfills={},Qs.propertyToPolyfillSymbol={},Qs.POLYFILL_PREFIX="$jscp$";var er="Int8 Uint8 Uint8Clamped Int16 Uint16 Int32 Uint32 Float32 Float64".split(" ");Qs.global.BigInt64Array&&(er.push("BigInt64"),er.push("BigUint64")),Qs.TYPED_ARRAY_CLASSES=er,Qs.polyfillTypedArrayMethod=function(e,t,i,n){if(t)for(var o=0;o<Qs.TYPED_ARRAY_CLASSES.length;o++){var s=Qs.TYPED_ARRAY_CLASSES[o]+"Array.prototype."+e;Qs.ISOLATE_POLYFILLS?Qs.polyfillIsolated(s,t,i,n):Qs.polyfillUnisolated(s,t,i,n)}},Qs.polyfill=function(e,t,i,n){t&&(Qs.ISOLATE_POLYFILLS?Qs.polyfillIsolated(e,t,i,n):Qs.polyfillUnisolated(e,t,i,n))},Qs.polyfillUnisolated=function(e,t){var i=Qs.global;e=e.split(".");for(var n=0;n<e.length-1;n++){var o=e[n];if(!(o in i))return;i=i[o]}(t=t(n=i[e=e[e.length-1]]))!=n&&null!=t&&Qs.defineProperty(i,e,{configurable:!0,writable:!0,value:t})},Qs.polyfillIsolated=function(e,t,i){var n=e.split(".");e=1===n.length;var o=n[0];o=!e&&o in Qs.polyfills?Qs.polyfills:Qs.global;for(var s=0;s<n.length-1;s++){var r=n[s];if(!(r in o))return;o=o[r]}n=n[n.length-1],null!=(t=t(i=Qs.IS_SYMBOL_NATIVE&&"es6"===i?o[n]:null))&&(e?Qs.defineProperty(Qs.polyfills,n,{configurable:!0,writable:!0,value:t}):t!==i&&(void 0===Qs.propertyToPolyfillSymbol[n]&&(e=1e9*Math.random()>>>0,Qs.propertyToPolyfillSymbol[n]=Qs.IS_SYMBOL_NATIVE?Qs.global.Symbol(n):Qs.POLYFILL_PREFIX+e+"$"+n),Qs.defineProperty(o,Qs.propertyToPolyfillSymbol[n],{configurable:!0,writable:!0,value:t})))},Qs.getConstructImplementation=function(){if(Qs.TRUST_ES6_POLYFILLS&&"undefined"!=typeof Reflect&&Reflect.construct){if(function(){function e(){}return new e,Reflect.construct(e,[],(function(){})),new e instanceof e}())return Reflect.construct;var e=Reflect.construct;return function(t,i,n){return t=e(t,i),n&&Reflect.setPrototypeOf(t,n.prototype),t}}return function(e,t,i){return void 0===i&&(i=e),i=Qs.objectCreate(i.prototype||Object.prototype),Function.prototype.apply.call(e,i,t)||i}},Qs.construct=Qs.getConstructImplementation(),Qs.underscoreProtoCanBeSet=function(){var e={};try{return e.__proto__={a:!0},e.a}catch(e){}return!1},Qs.setPrototypeOf=Qs.ASSUME_ES6||Qs.TRUST_ES6_POLYFILLS&&"function"==typeof Object.setPrototypeOf?Object.setPrototypeOf:Qs.underscoreProtoCanBeSet()?function(e,t){if(e.__proto__=t,e.__proto__!==t)throw new TypeError(e+" is not extensible");return e}:null,Qs.inherits=function(e,t){if(e.prototype=Qs.objectCreate(t.prototype),e.prototype.constructor=e,Qs.ASSUME_ES6||Qs.setPrototypeOf){var i=Qs.setPrototypeOf;i(e,t)}else for(i in t)if("prototype"!=i)if(Object.defineProperties){var n=Object.getOwnPropertyDescriptor(t,i);n&&Object.defineProperty(e,i,n)}else e[i]=t[i];e.superClass_=t.prototype},Qs.arrayIteratorImpl=function(e){var t=0;return function(){return t<e.length?{done:!1,value:e[t++]}:{done:!0}}},Qs.arrayIterator=function(e){return{next:Qs.arrayIteratorImpl(e)}},Qs.makeIterator=function(e){var t="undefined"!=typeof Symbol&&Symbol.iterator&&e[Symbol.iterator];if(t)return t.call(e);if("number"==typeof e.length)return Qs.arrayIterator(e);throw Error(String(e)+" is not an iterable or ArrayLike")},Qs.arrayFromIterator=function(e){for(var t,i=[];!(t=e.next()).done;)i.push(t.value);return i},Qs.arrayFromIterable=function(e){return e instanceof Array?e:Qs.arrayFromIterator(Qs.makeIterator(e))},Qs.generator={},Qs.generator.ensureIteratorResultIsObject_=function(e){if(!(e instanceof Object))throw new TypeError("Iterator result "+e+" is not an object")},Qs.generator.Context=function(){this.isRunning_=!1,this.yieldAllIterator_=null,this.yieldResult=void 0,this.nextAddress=1,this.finallyAddress_=this.catchAddress_=0,this.finallyContexts_=this.abruptCompletion_=null},Qs.generator.Context.prototype.start_=function(){if(this.isRunning_)throw new TypeError("Generator is already running");this.isRunning_=!0},Qs.generator.Context.prototype.stop_=function(){this.isRunning_=!1},Qs.generator.Context.prototype.jumpToErrorHandler_=function(){this.nextAddress=this.catchAddress_||this.finallyAddress_},Qs.generator.Context.prototype.next_=function(e){this.yieldResult=e},Qs.generator.Context.prototype.throw_=function(e){this.abruptCompletion_={exception:e,isException:!0},this.jumpToErrorHandler_()},Qs.generator.Context.prototype.getNextAddressJsc=function(){return this.nextAddress},Qs.generator.Context.prototype.getNextAddressJsc=function(){return this.nextAddress},Qs.generator.Context.prototype.getYieldResultJsc=function(){return this.yieldResult},Qs.generator.Context.prototype.getYieldResultJsc=function(){return this.yieldResult},Qs.generator.Context.prototype.return=function(e){this.abruptCompletion_={return:e},this.nextAddress=this.finallyAddress_},Qs.generator.Context.prototype.return=Qs.generator.Context.prototype.return,Qs.generator.Context.prototype.jumpThroughFinallyBlocks=function(e){this.abruptCompletion_={jumpTo:e},this.finallyAddress_<e?(this.nextAddress=e,this.abruptCompletion_=null):this.nextAddress=this.finallyAddress_},Qs.generator.Context.prototype.jumpThroughFinallyBlocks=Qs.generator.Context.prototype.jumpThroughFinallyBlocks,Qs.generator.Context.prototype.yield=function(e,t){return this.nextAddress=t,{value:e}},Qs.generator.Context.prototype.yield=Qs.generator.Context.prototype.yield,Qs.generator.Context.prototype.yieldAll=function(e,t){var i=(e=Qs.makeIterator(e)).next();if(Qs.generator.ensureIteratorResultIsObject_(i),!i.done)return this.yieldAllIterator_=e,this.yield(i.value,t);this.yieldResult=i.value,this.nextAddress=t},Qs.generator.Context.prototype.yieldAll=Qs.generator.Context.prototype.yieldAll,Qs.generator.Context.prototype.jumpTo=function(e){this.nextAddress=e},Qs.generator.Context.prototype.jumpTo=Qs.generator.Context.prototype.jumpTo,Qs.generator.Context.prototype.jumpToEnd=function(){this.nextAddress=0},Qs.generator.Context.prototype.jumpToEnd=Qs.generator.Context.prototype.jumpToEnd,Qs.generator.Context.prototype.setCatchFinallyBlocks=function(e,t){this.catchAddress_=e,null!=t&&(this.finallyAddress_=t)},Qs.generator.Context.prototype.setCatchFinallyBlocks=Qs.generator.Context.prototype.setCatchFinallyBlocks,Qs.generator.Context.prototype.setFinallyBlock=function(e){this.catchAddress_=0,this.finallyAddress_=e||0},Qs.generator.Context.prototype.setFinallyBlock=Qs.generator.Context.prototype.setFinallyBlock,Qs.generator.Context.prototype.leaveTryBlock=function(e,t){this.nextAddress=e,this.catchAddress_=t||0},Qs.generator.Context.prototype.leaveTryBlock=Qs.generator.Context.prototype.leaveTryBlock,Qs.generator.Context.prototype.enterCatchBlock=function(e){return this.catchAddress_=e||0,e=this.abruptCompletion_.exception,this.abruptCompletion_=null,e},Qs.generator.Context.prototype.enterCatchBlock=Qs.generator.Context.prototype.enterCatchBlock,Qs.generator.Context.prototype.enterFinallyBlock=function(e,t,i){i?this.finallyContexts_[i]=this.abruptCompletion_:this.finallyContexts_=[this.abruptCompletion_],this.catchAddress_=e||0,this.finallyAddress_=t||0,this.abruptCompletion_=null},Qs.generator.Context.prototype.enterFinallyBlock=Qs.generator.Context.prototype.enterFinallyBlock,Qs.generator.Context.prototype.leaveFinallyBlock=function(e,t){if(t=this.finallyContexts_.splice(t||0)[0],t=this.abruptCompletion_=this.abruptCompletion_||t){if(t.isException)return this.jumpToErrorHandler_();null!=t.jumpTo&&this.finallyAddress_<t.jumpTo?(this.nextAddress=t.jumpTo,this.abruptCompletion_=null):this.nextAddress=this.finallyAddress_}else this.nextAddress=e},Qs.generator.Context.prototype.leaveFinallyBlock=Qs.generator.Context.prototype.leaveFinallyBlock,Qs.generator.Context.prototype.forIn=function(e){return new Qs.generator.Context.PropertyIterator(e)},Qs.generator.Context.prototype.forIn=Qs.generator.Context.prototype.forIn,Qs.generator.Context.PropertyIterator=function(e){for(var t in this.object_=e,this.properties_=[],e)this.properties_.push(t);this.properties_.reverse()},Qs.generator.Context.PropertyIterator.prototype.getNext=function(){for(;this.properties_.length>0;){var e=this.properties_.pop();if(e in this.object_)return e}return null},Qs.generator.Context.PropertyIterator.prototype.getNext=Qs.generator.Context.PropertyIterator.prototype.getNext,Qs.generator.Engine_=function(e){this.context_=new Qs.generator.Context,this.program_=e},Qs.generator.Engine_.prototype.next_=function(e){return this.context_.start_(),this.context_.yieldAllIterator_?this.yieldAllStep_(this.context_.yieldAllIterator_.next,e,this.context_.next_):(this.context_.next_(e),this.nextStep_())},Qs.generator.Engine_.prototype.return_=function(e){this.context_.start_();var t=this.context_.yieldAllIterator_;return t?this.yieldAllStep_("return"in t?t.return:function(e){return{value:e,done:!0}},e,this.context_.return):(this.context_.return(e),this.nextStep_())},Qs.generator.Engine_.prototype.throw_=function(e){if(this.context_.start_(),this.context_.yieldAllIterator_){var t=this.context_.yieldAllIterator_.throw;if(t)return this.yieldAllStep_(t,e,this.context_.next_);e=this.context_.yieldAllIterator_,this.context_.yieldAllIterator_=null;try{if(e.return){var i=e.return();Qs.generator.ensureIteratorResultIsObject_(i)}this.context_.throw_(new TypeError("The iterator does not provide a 'throw' method."))}catch(e){this.context_.throw_(e)}return this.nextStep_()}return this.context_.throw_(e),this.nextStep_()},Qs.generator.Engine_.prototype.yieldAllStep_=function(e,t,i){try{var n=e.call(this.context_.yieldAllIterator_,t);if(Qs.generator.ensureIteratorResultIsObject_(n),!n.done)return this.context_.stop_(),n;var o=n.value}catch(e){return this.context_.yieldAllIterator_=null,this.context_.throw_(e),this.nextStep_()}return this.context_.yieldAllIterator_=null,i.call(this.context_,o),this.nextStep_()},Qs.generator.Engine_.prototype.nextStep_=function(){for(;this.context_.nextAddress;)try{var e=this.program_(this.context_);if(e)return this.context_.stop_(),{value:e.value,done:!1}}catch(e){this.context_.yieldResult=void 0,this.context_.throw_(e)}if(this.context_.stop_(),this.context_.abruptCompletion_){if(e=this.context_.abruptCompletion_,this.context_.abruptCompletion_=null,e.isException)throw e.exception;return{value:e.return,done:!0}}return{value:void 0,done:!0}},Qs.generator.Generator_=function(e){this.next=function(t){return e.next_(t)},this.throw=function(t){return e.throw_(t)},this.return=function(t){return e.return_(t)},this[Symbol.iterator]=function(){return this}},Qs.generator.createGenerator=function(e,t){return t=new Qs.generator.Generator_(new Qs.generator.Engine_(t)),Qs.setPrototypeOf&&e.prototype&&Qs.setPrototypeOf(t,e.prototype),t},Qs.asyncExecutePromiseGenerator=function(e){function t(t){return e.next(t)}function i(t){return e.throw(t)}return new Promise((function(n,o){!function e(s){s.done?n(s.value):Promise.resolve(s.value).then(t,i).then(e,o)}(e.next())}))},Qs.asyncExecutePromiseGeneratorFunction=function(e){return Qs.asyncExecutePromiseGenerator(e())},Qs.asyncExecutePromiseGeneratorProgram=function(e){return Qs.asyncExecutePromiseGenerator(new Qs.generator.Generator_(new Qs.generator.Engine_(e)))},Qs.polyfill("globalThis",(function(e){return e||Qs.global}),"es_2020","es3"),Qs.polyfill("Array.prototype.includes",(function(e){return e||function(e,t){var i=this;i instanceof String&&(i=String(i));var n=i.length;for((t=t||0)<0&&(t=Math.max(t+n,0));t<n;t++){var o=i[t];if(o===e||Object.is(o,e))return!0}return!1}}),"es7","es3"),Qs.owns=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},Qs.polyfill("Object.values",(function(e){return e||function(e){var t,i=[];for(t in e)Qs.owns(e,t)&&i.push(e[t]);return i}}),"es8","es3"),Qs.checkEs6ConformanceViaProxy=function(){try{var e={},t=Object.create(new Qs.global.Proxy(e,{get:function(i,n,o){return i==e&&"q"==n&&o==t}}));return!0===t.q}catch(e){return!1}},Qs.USE_PROXY_FOR_ES6_CONFORMANCE_CHECKS=!1,Qs.ES6_CONFORMANCE=Qs.USE_PROXY_FOR_ES6_CONFORMANCE_CHECKS&&Qs.checkEs6ConformanceViaProxy(),Qs.initSymbol=function(){},Qs.iteratorPrototype=function(e){return(e={next:e})[Symbol.iterator]=function(){return this},e},Qs.MapEntry=function(){},Qs.polyfill("Set.prototype.difference",(function(e){return e||function(e){Qs.checkIsSetInstance(this),Qs.checkIsSetLike(e);var t=Qs.getSmallerAndLargerSets(this,e);e=new Set(this);var i=t.smallerSetIterator;t=t.largerSet;for(var n=i.next();!n.done;)t.has(n.value)&&e.delete(n.value),n=i.next();return e}}),"es_next","es6"),Qs.checkIsSetLike=function(e){if("object"!=typeof e||null===e||"number"!=typeof e.size||e.size<0||"function"!=typeof e.keys||"function"!=typeof e.has)throw new TypeError("Argument must be set-like")},Qs.checkIsValidIterator=function(e){if("object"!=typeof e||null===e||"function"!=typeof e.next)throw new TypeError("Invalid iterator.");return e},Qs.getSmallerAndLargerSets=function(e,t){return e.size<=t.size?{smallerSetIterator:e.keys(),largerSet:t}:{smallerSetIterator:Qs.checkIsValidIterator(t.keys()),largerSet:e}},Qs.checkIsSetInstance=function(e){if(!(e instanceof Set))throw new TypeError("Method must be called on an instance of Set.")},Qs.iteratorFromArray=function(e,t){if(Qs.ASSUME_ES6)return e[Symbol.iterator]();e instanceof String&&(e+="");var i=0,n=!1,o={next:function(){if(!n&&i<e.length){var o=i++;return{value:t(o,e[o]),done:!1}}return n=!0,{done:!0,value:void 0}}};return o[Symbol.iterator]=function(){return o},o},Qs.polyfill("Array.prototype.values",(function(e){return e||function(){return Qs.iteratorFromArray(this,(function(e,t){return t}))}}),"es8","es3"),Qs.polyfill("Array.prototype.flatMap",(function(e){return e||function(e,t){var i=[];return Array.prototype.forEach.call(this,(function(n,o,s){n=e.call(t,n,o,s),Array.isArray(n)?i.push.apply(i,n):i.push(n)})),i}}),"es9","es5"),Qs.polyfill("Array.prototype.flat",(function(e){return e||function(e){e=void 0===e?1:e;var t=[];return Array.prototype.forEach.call(this,(function(i){Array.isArray(i)&&e>0?(i=Array.prototype.flat.call(i,e-1),t.push.apply(t,i)):t.push(i)})),t}}),"es9","es5"),Qs.polyfill("Object.entries",(function(e){return e||function(e){var t,i=[];for(t in e)Qs.owns(e,t)&&i.push([t,e[t]]);return i}}),"es8","es3");var tr,ir,nr,or,sr,rr,ar,lr,hr,ur,cr="ontouchstart"in globalThis||!!(globalThis.document&&document.documentElement&&"ontouchstart"in document.documentElement)||!(!globalThis.navigator||!globalThis.navigator.maxTouchPoints&&!globalThis.navigator.msMaxTouchPoints),dr=null,pr={mousedown:["pointerdown"],mouseenter:["pointerenter"],mouseleave:["pointerleave"],mousemove:["pointermove"],mouseout:["pointerout"],mouseover:["pointerover"],mouseup:["pointerup","pointercancel"],touchend:["pointerup"],touchcancel:["pointercancel"]},gr=0,Er={TOUCH_ENABLED:cr,TOUCH_MAP:pr};Er.checkTouchIdentifier=s,Er.clearTouchIdentifier=function(){dr=null},Er.getTouchIdentifierFromEvent=o,Er.longStart=e,Er.longStop=t,Er.shouldHandleEvent=n,function(e){function t(e){return i.includes(e.toUpperCase())}var i=(tr=e).toUpperCase();ir=t("JavaFX"),nr=t("WebKit"),or=t("Gecko")&&!nr,sr=t("Android"),e=globalThis.navigator&&globalThis.navigator.maxTouchPoints,rr=t("iPad")||t("Macintosh")&&e>0,ar=t("iPhone")&&!rr,lr=t("Macintosh"),hr=rr||sr&&!t("Mobile")||t("Silk"),ur=!hr&&(ar||sr)}(globalThis.navigator&&globalThis.navigator.userAgent||"");var Tr=ir,_r=or,fr=sr,mr=rr,br=ar,Cr=lr,vr=ur,Ir=Cr||mr||br,Nr={ANDROID:fr,APPLE:Ir,GECKO:_r,IPAD:mr,IPHONE:br,JavaFx:Tr,MAC:Cr,MOBILE:vr,raw:tr},yr={};yr.bind=a,yr.conditionalBind=r,yr.getScrollDeltaPixels=d,yr.isRightButton=u,yr.isTargetInput=h,yr.mouseToSvg=c,yr.unbind=l;var Ar={};Ar.removeElem=p;var kr=class{constructor(e){this.name=e}toString(){return this.name}};kr.POSITIONABLE=new kr("positionable"),kr.DRAG_TARGET=new kr("drag_target"),kr.DELETE_AREA=new kr("delete_area"),kr.AUTOHIDEABLE=new kr("autohideable"),kr.FOCUSABLE=new kr("focusable");var Sr=class{constructor(){this.componentData=new Map,this.capabilityToComponentIds=new Map}addComponent(e,t){var i,n=e.component.id;if(!t&&this.componentData.has(n))throw Error('Plugin "'+n+'" with capabilities "'+(null==(i=this.componentData.get(n))?void 0:i.capabilities)+'" already added.');for(this.componentData.set(n,e),t=[],i=0;i<e.capabilities.length;i++){let o=String(e.capabilities[i]).toLowerCase();if(t.push(o),this.capabilityToComponentIds.has(o)){let e;null==(e=this.capabilityToComponentIds.get(o))||e.push(n)}else this.capabilityToComponentIds.set(o,[n])}this.componentData.get(n).capabilities=t}removeComponent(e){var t=this.componentData.get(e);if(t){for(let i=0;i<t.capabilities.length;i++){let n=String(t.capabilities[i]).toLowerCase();p(this.capabilityToComponentIds.get(n),e)}this.componentData.delete(e)}}addCapability(e,t){if(!this.getComponent(e))throw Error('Cannot add capability, "'+t+'". Plugin "'+e+'" has not been added to the ComponentManager');var i,n;this.hasCapability(e,t)?console.warn('Plugin "'+e+'already has capability "'+t+'"'):(t=`${t}`.toLowerCase(),null==(i=this.componentData.get(e))||i.capabilities.push(t),null==(n=this.capabilityToComponentIds.get(t))||n.push(e))}removeCapability(e,t){if(!this.getComponent(e))throw Error('Cannot remove capability, "'+t+'". Plugin "'+e+'" has not been added to the ComponentManager');this.hasCapability(e,t)?(t=`${t}`.toLowerCase(),p(this.componentData.get(e).capabilities,t),p(this.capabilityToComponentIds.get(t),e)):console.warn('Plugin "'+e+"doesn't have capability \""+t+'" to remove')}hasCapability(e,t){return t=`${t}`.toLowerCase(),this.componentData.has(e)&&this.componentData.get(e).capabilities.includes(t)}getComponent(e){var t;return null==(t=this.componentData.get(e))?void 0:t.component}getComponents(e,t){if(e=`${e}`.toLowerCase(),!(e=this.capabilityToComponentIds.get(e)))return[];var i=[];if(t){let t=[];e.forEach((e=>{t.push(this.componentData.get(e))})),t.sort((function(e,t){return e.weight-t.weight})),t.forEach((function(e){i.push(e.component)}))}else e.forEach((e=>{i.push(this.componentData.get(e).component)}));return i}};Sr.Capability=kr;var Or=Sr||(Sr={}),Rr=Or.ComponentWeight||(Or.ComponentWeight={});Rr[Rr.TOOLBOX_WEIGHT=0]="TOOLBOX_WEIGHT",Rr[Rr.FLYOUT_WEIGHT=1]="FLYOUT_WEIGHT",Rr[Rr.TRASHCAN_WEIGHT=2]="TRASHCAN_WEIGHT",Rr[Rr.ZOOM_CONTROLS_WEIGHT=3]="ZOOM_CONTROLS_WEIGHT";var wr=new WeakSet,Lr=[],Dr=`\n:is(\n .injectionDiv,\n .blocklyWidgetDiv,\n .blocklyDropdownDiv,\n .blocklyTooltipDiv,\n) * {\n box-sizing: border-box;\n}\n\n.blocklySvg {\n background-color: #fff;\n outline: none;\n overflow: hidden; /* IE overflows by default. */\n position: absolute;\n display: block;\n}\n\n.blocklyWidgetDiv {\n display: none;\n position: absolute;\n z-index: 99999; /* big value for bootstrap3 compatibility */\n}\n\n.injectionDiv {\n height: 100%;\n position: relative;\n overflow: hidden; /* So blocks in drag surface disappear at edges */\n touch-action: none;\n user-select: none;\n -webkit-user-select: none;\n}\n\n.blocklyBlockCanvas.blocklyCanvasTransitioning,\n.blocklyBubbleCanvas.blocklyCanvasTransitioning {\n transition: transform .5s;\n}\n\n.blocklyEmboss {\n filter: var(--blocklyEmbossFilter);\n}\n\n.blocklyTooltipDiv {\n background-color: #ffffc7;\n border: 1px solid #ddc;\n box-shadow: 4px 4px 20px 1px rgba(0,0,0,.15);\n color: #000;\n display: none;\n font: 9pt sans-serif;\n opacity: .9;\n padding: 2px;\n position: absolute;\n z-index: 100000; /* big value for bootstrap3 compatibility */\n}\n\n.blocklyDropDownDiv {\n position: absolute;\n left: 0;\n top: 0;\n z-index: 1000;\n visibility: hidden;\n border: 1px solid;\n border-color: #dadce0;\n background-color: #fff;\n border-radius: 2px;\n padding: 4px;\n box-shadow: 0 0 3px 1px rgba(0,0,0,.3);\n}\n\n.blocklyDropDownDiv:focus {\n box-shadow: 0 0 6px 1px rgba(0,0,0,.3);\n}\n\n.blocklyDropDownContent {\n max-height: 300px; /* @todo: spec for maximum height. */\n}\n\n.blocklyDropDownArrow {\n position: absolute;\n left: 0;\n top: 0;\n width: 16px;\n height: 16px;\n z-index: -1;\n background-color: inherit;\n border-color: inherit;\n border-top: 1px solid;\n border-left: 1px solid;\n border-top-left-radius: 4px;\n border-color: inherit;\n}\n\n.blocklyHighlighted>.blocklyPath {\n filter: var(--blocklyEmbossFilter);\n}\n\n.blocklyHighlightedConnectionPath {\n fill: none;\n}\n\n.blocklyHighlightedConnectionPathVisible {\n stroke: #fc3;\n stroke-width: 4px;\n}\n\n.blocklyPathLight {\n fill: none;\n stroke-linecap: round;\n stroke-width: 1;\n}\n\n.blocklySelected>.blocklyPathLight {\n display: none;\n}\n\n.blocklyDraggable {\n cursor: grab;\n cursor: -webkit-grab;\n}\n\n.blocklyDragging {\n cursor: grabbing;\n cursor: -webkit-grabbing;\n /* Drag surface disables events to not block the toolbox, so we have to\n * reenable them here for the cursor values to work. */\n pointer-events: auto;\n}\n\n /* Changes cursor on mouse down. Not effective in Firefox because of\n https://bugzilla.mozilla.org/show_bug.cgi?id=771241 */\n.blocklyDraggable:active {\n cursor: grabbing;\n cursor: -webkit-grabbing;\n}\n\n.blocklyDragging.blocklyDraggingDelete,\n.blocklyDragging.blocklyDraggingDelete .blocklyField {\n cursor: url("<<<PATH>>>/handdelete.cur"), auto;\n}\n\n.blocklyDragging>.blocklyPath,\n.blocklyDragging>.blocklyPathLight {\n fill-opacity: .8;\n stroke-opacity: .8;\n}\n\n.blocklyDragging>.blocklyPathDark {\n display: none;\n}\n\n.blocklyDisabledPattern>.blocklyPath {\n fill: var(--blocklyDisabledPattern);\n fill-opacity: .5;\n stroke-opacity: .5;\n}\n\n.blocklyDisabled>.blocklyPathLight,\n.blocklyDisabled>.blocklyPathDark {\n display: none;\n}\n\n.blocklyInsertionMarker>.blocklyPath,\n.blocklyInsertionMarker>.blocklyPathLight,\n.blocklyInsertionMarker>.blocklyPathDark {\n fill-opacity: .2;\n stroke: none;\n}\n\n.blocklyNonEditableField>text {\n pointer-events: none;\n}\n\n.blocklyFlyout {\n position: absolute;\n z-index: 20;\n}\n\n.blocklyText text {\n cursor: default;\n}\n\n/*\n Don't allow users to select text. It gets annoying when trying to\n drag a block and selected text moves instead.\n*/\n.blocklySvg text {\n user-select: none;\n -ms-user-select: none;\n -webkit-user-select: none;\n cursor: inherit;\n}\n\n.blocklyIconGroup {\n cursor: default;\n}\n\n.blocklyIconGroup:not(:hover):not(:focus),\n.blocklyIconGroupReadonly {\n opacity: .6;\n}\n\n.blocklyIconShape {\n fill: #00f;\n stroke: #fff;\n stroke-width: 1px;\n}\n\n.blocklyIconSymbol {\n fill: #fff;\n}\n\n.blocklyMinimalBody {\n margin: 0;\n padding: 0;\n height: 100%;\n}\n\n.blocklyHtmlInput {\n border: none;\n border-radius: 4px;\n height: 100%;\n margin: 0;\n outline: none;\n padding: 0;\n width: 100%;\n text-align: center;\n display: block;\n box-sizing: border-box;\n}\n\n/* Remove the increase and decrease arrows on the field number editor */\ninput.blocklyHtmlInput[type=number]::-webkit-inner-spin-button,\ninput.blocklyHtmlInput[type=number]::-webkit-outer-spin-button {\n -webkit-appearance: none;\n margin: 0;\n}\n\ninput[type=number] {\n -moz-appearance: textfield;\n}\n\n.blocklyMainBackground {\n stroke-width: 1;\n stroke: #c6c6c6; /* Equates to #ddd due to border being off-pixel. */\n}\n\n.blocklyMutatorBackground {\n fill: #fff;\n stroke: #ddd;\n stroke-width: 1;\n}\n\n.blocklyFlyoutBackground {\n fill: #ddd;\n fill-opacity: .8;\n}\n\n.blocklyMainWorkspaceScrollbar {\n z-index: 20;\n}\n\n.blocklyFlyoutScrollbar {\n z-index: 30;\n}\n\n.blocklyScrollbarHorizontal,\n.blocklyScrollbarVertical {\n position: absolute;\n outline: none;\n}\n\n.blocklyScrollbarBackground {\n opacity: 0;\n pointer-events: none;\n}\n\n.blocklyScrollbarHandle {\n fill: #ccc;\n}\n\n.blocklyScrollbarBackground:hover+.blocklyScrollbarHandle,\n.blocklyScrollbarHandle:hover {\n fill: #bbb;\n}\n\n/* Darken flyout scrollbars due to being on a grey background. */\n/* By contrast, workspace scrollbars are on a white background. */\n.blocklyFlyout .blocklyScrollbarHandle {\n fill: #bbb;\n}\n\n.blocklyFlyout .blocklyScrollbarBackground:hover+.blocklyScrollbarHandle,\n.blocklyFlyout .blocklyScrollbarHandle:hover {\n fill: #aaa;\n}\n\n.blocklyInvalidInput {\n background: #faa;\n}\n\n.blocklyVerticalMarker {\n stroke-width: 3px;\n fill: rgba(255,255,255,.5);\n pointer-events: none;\n}\n\n.blocklyComputeCanvas {\n position: absolute;\n width: 0;\n height: 0;\n}\n\n.blocklyNoPointerEvents {\n pointer-events: none;\n}\n\n.blocklyContextMenu {\n border-radius: 4px;\n max-height: 100%;\n box-sizing: content-box;\n}\n\n.blocklyDropdownMenu {\n border-radius: 2px;\n padding: 0 !important;\n}\n\n.blocklyDropdownMenu .blocklyMenuItem {\n /* 28px on the left for icon or checkbox. */\n padding-left: 28px;\n}\n\n/* BiDi override for the resting state. */\n.blocklyDropdownMenu .blocklyMenuItemRtl {\n /* Flip left/right padding for BiDi. */\n padding-left: 5px;\n padding-right: 28px;\n}\n\n.blocklyWidgetDiv .blocklyMenu {\n user-select: none;\n -ms-user-select: none;\n -webkit-user-select: none;\n background: #fff;\n border: 1px solid transparent;\n box-shadow: 0 0 3px 1px rgba(0,0,0,.3);\n font: normal 13px Arial, sans-serif;\n margin: 0;\n outline: none;\n padding: 4px 0;\n position: absolute;\n overflow-y: auto;\n overflow-x: hidden;\n max-height: 100%;\n z-index: 20000; /* Arbitrary, but some apps depend on it... */\n}\n\n.blocklyWidgetDiv .blocklyMenu:focus {\n box-shadow: 0 0 6px 1px rgba(0,0,0,.3);\n}\n\n.blocklyDropDownDiv .blocklyMenu {\n user-select: none;\n -ms-user-select: none;\n -webkit-user-select: none;\n background: inherit; /* Compatibility with gapi, reset from goog-menu */\n border: inherit; /* Compatibility with gapi, reset from goog-menu */\n font: normal 13px "Helvetica Neue", Helvetica, sans-serif;\n outline: none;\n overflow-y: auto;\n overflow-x: hidden;\n max-height: 100%;\n z-index: 20000; /* Arbitrary, but some apps depend on it... */\n}\n\n/* State: resting. */\n.blocklyMenuItem {\n border: none;\n color: #000;\n cursor: pointer;\n list-style: none;\n margin: 0;\n /* 7em on the right for shortcut. */\n min-width: 7em;\n padding: 6px 15px;\n white-space: nowrap;\n}\n\n/* State: disabled. */\n.blocklyMenuItemDisabled {\n color: #ccc;\n cursor: inherit;\n}\n\n/* State: hover. */\n.blocklyMenuItemHighlight {\n background-color: rgba(0,0,0,.1);\n}\n\n/* State: selected/checked. */\n.blocklyMenuItemSelected .blocklyMenuItemCheckbox {\n background: url(<<<PATH>>>/sprites.svg) no-repeat -48px -16px;\n float: left;\n margin-left: -24px;\n width: 16px;\n height: 16px;\n position: static; /* Scroll with the menu. */\n display: block;\n}\n\n.blocklyMenuItemRtl .blocklyMenuItemCheckbox {\n float: right;\n margin-right: -24px;\n}\n\n.blocklyMenuSeparator {\n background-color: #ccc;\n height: 1px;\n border: 0;\n margin-left: 4px;\n margin-right: 4px;\n}\n\n.blocklyRTL .blocklyMenuItemContent .blocklyShortcutContainer {\n flex-direction: row-reverse;\n}\n.blocklyMenuItemContent .blocklyShortcutContainer {\n width: 100%;\n display: flex;\n justify-content: space-between;\n gap: 16px;\n}\n.blocklyMenuItemContent .blocklyShortcutContainer .blocklyShortcut {\n color: #ccc;\n}\n\n.blocklyBlockDragSurface, .blocklyAnimationLayer {\n position: absolute;\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n overflow: visible !important;\n z-index: 80;\n pointer-events: none;\n}\n\n.blocklyField {\n cursor: default;\n}\n\n.blocklyInputField {\n cursor: text;\n}\n\n.blocklyDragging .blocklyField,\n.blocklyDragging .blocklyIconGroup {\n cursor: grabbing;\n}\n\n.blocklyActiveFocus:is(\n .blocklyFlyout,\n .blocklyWorkspace,\n .blocklyWorkspaceSelectionRing,\n .blocklyField,\n .blocklyPath,\n .blocklyHighlightedConnectionPath,\n .blocklyComment,\n .blocklyBubble,\n .blocklyIconGroup,\n .blocklyTextarea,\n),\n.blocklyZoom:focus,\n.blocklyTrash:focus {\n outline: none;\n}\n.hiddenForAria {\n position: absolute;\n left: -9999px;\n width: 1px;\n height: 1px;\n overflow: hidden;\n}\n\n.injectionDiv {\n --blockly-active-node-color: #fff200;\n --blockly-active-tree-color: #1379f6;\n --blockly-selection-width: 3px;\n}\n\n/* Active focus cases: */\n/* Blocks with active focus. */\n.blocklyKeyboardNavigation\n .blocklyActiveFocus:is(.blocklyPath, .blocklyHighlightedConnectionPath),\n/* Fields with active focus, */\n.blocklyKeyboardNavigation\n .blocklyActiveFocus.blocklyField\n > .blocklyFieldRect,\n/* Icons with active focus. */\n.blocklyKeyboardNavigation\n .blocklyActiveFocus.blocklyIconGroup\n > .blocklyIconShape:first-child,\n.blocklyKeyboardNavigation\n .blocklyActiveFocus\n > .blocklyFocusRing,\n.blocklyTrash:focus-visible > .blocklyFocusRing,\n.blocklyZoom:focus-visible > .blocklyFocusRing {\n stroke: var(--blockly-active-node-color);\n stroke-width: var(--blockly-selection-width);\n}\n\n/* Passive focus cases: */\n/* Blocks with passive focus except when widget/dropdown div in use. */\n.blocklyKeyboardNavigation:not(\n :has(\n .blocklyDropDownDiv:focus-within,\n .blocklyWidgetDiv:focus-within\n )\n )\n .blocklyPassiveFocus:is(\n .blocklyPath:not(.blocklyFlyout .blocklyPath),\n .blocklyHighlightedConnectionPath\n ),\n/* Fields with passive focus except when widget/dropdown div in use. */\n.blocklyKeyboardNavigation:not(\n :has(\n .blocklyDropDownDiv:focus-within,\n .blocklyWidgetDiv:focus-within\n )\n )\n .blocklyPassiveFocus.blocklyField\n > .blocklyFieldRect,\n/* Icons with passive focus except when widget/dropdown div in use. */\n.blocklyKeyboardNavigation:not(\n :has(\n .blocklyDropDownDiv:focus-within,\n .blocklyWidgetDiv:focus-within\n )\n )\n .blocklyPassiveFocus.blocklyIconGroup\n > .blocklyIconShape:first-child {\n stroke: var(--blockly-active-node-color);\n stroke-dasharray: 5px 3px;\n stroke-width: var(--blockly-selection-width);\n}\n\n/* Different ways for toolbox/flyout to be the active tree: */\n/* Active focus in the flyout. */\n.blocklyKeyboardNavigation .blocklyFlyout:has(.blocklyActiveFocus),\n/* Active focus in the toolbox. */\n.blocklyKeyboardNavigation .blocklyToolbox:has(.blocklyActiveFocus),\n/* Active focus on the toolbox/flyout. */\n.blocklyKeyboardNavigation\n .blocklyActiveFocus:is(.blocklyFlyout, .blocklyToolbox) {\n outline-offset: calc(var(--blockly-selection-width) * -1);\n outline: var(--blockly-selection-width) solid\n var(--blockly-active-tree-color);\n}\n\n/* Suppress default outline. */\n.blocklyKeyboardNavigation\n .blocklyToolboxCategoryContainer:focus-visible {\n outline: none;\n}\n\n /* Different ways for the workspace to be the active tree: */\n/* Active focus within workspace. */\n.blocklyKeyboardNavigation\n .blocklyWorkspace:has(.blocklyActiveFocus)\n .blocklyWorkspaceFocusRing,\n/* Active focus within drag layer. */\n.blocklyKeyboardNavigation\n .blocklySvg:has(~ .blocklyBlockDragSurface .blocklyActiveFocus)\n .blocklyWorkspaceFocusRing,\n/* Active focus on workspace. */\n.blocklyKeyboardNavigation\n .blocklyWorkspace.blocklyActiveFocus\n .blocklyWorkspaceFocusRing,\n/* Focus in widget/dropdown div considered to be in workspace. */\n .blocklyKeyboardNavigation\n .blocklyWorkspace.blocklyShowingDropDownDiv\n .blocklyWorkspaceFocusRing,\n.blocklyKeyboardNavigation\n .blocklyWorkspace.blocklyShowingWidgetDiv\n .blocklyWorkspaceFocusRing {\n stroke: var(--blockly-active-tree-color);\n stroke-width: calc(var(--blockly-selection-width) * 2);\n}\n\n/* The region itself is the active node (e.g. focused by clicking the\n background). */\n.blocklyKeyboardNavigation\n .blocklyWorkspace.blocklyActiveFocus\n .blocklyWorkspaceSelectionRing,\n/* The selection ring itself is the active node (it doubles as the workspace's\n keyboard focus target). */\n.blocklyKeyboardNavigation\n .blocklyWorkspaceSelectionRing.blocklyActiveFocus {\n stroke: var(--blockly-active-node-color);\n stroke-width: var(--blockly-selection-width);\n}\n\n/* The selection ring is a decorative highlight that can also be the workspace's\n focus target; either way it should never intercept pointer events. */\n.blocklyWorkspaceSelectionRing {\n pointer-events: none;\n}\n\n/* The workspace itself is the active node. */\n.blocklyKeyboardNavigation\n .blocklyBubble.blocklyActiveFocus\n .blocklyEmboss .blocklyDraggable {\n stroke: var(--blockly-active-node-color);\n stroke-width: var(--blockly-selection-width);\n}\n/* Flyout buttons and labels */\n.blocklyKeyboardNavigation .blocklyFlyout .blocklyFlyoutLabel.blocklyActiveFocus,\n.blocklyKeyboardNavigation .blocklyFlyout .blocklyFlyoutButton.blocklyActiveFocus {\n outline: none;\n}\n.blocklyKeyboardNavigation .blocklyFlyout .blocklyFlyoutLabel.blocklyActiveFocus > .blocklyFlyoutLabelText,\n.blocklyKeyboardNavigation .blocklyFlyout .blocklyFlyoutButton.blocklyActiveFocus > .blocklyFlyoutButtonBackground {\n outline-offset: 2px;\n outline: var(--blockly-selection-width) solid var(--blockly-active-node-color);\n border-radius: 2px;\n}\n.blocklyDialog {\n min-width: 300px;\n border-radius: 16px;\n box-shadow: 0 8px 8px rgba(0, 0, 0, 0.2);\n border: 1px solid #999;\n}\n.blocklyDialogForm {\n display: flex;\n flex-direction: column;\n row-gap: 8px;\n}\n.blocklyDialogButtonRow {\n display: flex;\n flex-direction: ${vr||Ir?"row-reverse":"row"};\n column-gap: 8px;\n}\n`,xr={};xr.inject=E,xr.register=g;var Fr,Mr=Fr||(Fr={});Mr.BLOCK_CREATE="create",Mr.BLOCK_DELETE="delete",Mr.BLOCK_CHANGE="change",Mr.BLOCK_FIELD_INTERMEDIATE_CHANGE="block_field_intermediate_change",Mr.BLOCK_MOVE="move",Mr.VAR_CREATE="var_create",Mr.VAR_DELETE="var_delete",Mr.VAR_RENAME="var_rename",Mr.VAR_TYPE_CHANGE="var_type_change",Mr.UI="ui",Mr.BLOCK_DRAG="drag",Mr.SELECTED="selected",Mr.CLICK="click",Mr.MARKER_MOVE="marker_move",Mr.BUBBLE_OPEN="bubble_open",Mr.TRASHCAN_OPEN="trashcan_open",Mr.TOOLBOX_ITEM_SELECT="toolbox_item_select",Mr.THEME_CHANGE="theme_change",Mr.VIEWPORT_CHANGE="viewport_change",Mr.COMMENT_CREATE="comment_create",Mr.COMMENT_DELETE="comment_delete",Mr.COMMENT_CHANGE="comment_change",Mr.COMMENT_MOVE="comment_move",Mr.COMMENT_RESIZE="comment_resize",Mr.COMMENT_DRAG="comment_drag",Mr.COMMENT_COLLAPSE="comment_collapse",Mr.FINISHED_LOADING="finished_loading";var Pr,Br=[Fr.BLOCK_CREATE,Fr.BLOCK_MOVE,Fr.COMMENT_CREATE,Fr.COMMENT_MOVE],Ur=Object.create(null),Vr=Pr||(Pr={});Vr.ASSERTIVE="assertive",Vr.OFF="off",Vr.POLITE="polite";var Hr,Gr=Pr.OFF,Wr=[],qr=Hr||(Hr={});qr.APPLICATION="application",qr.BUTTON="button",qr.CHECKBOX="checkbox",qr.DIALOG="dialog",qr.FIGURE="figure",qr.GENERIC="generic",qr.GRID="grid",qr.GRIDCELL="gridcell",qr.GROUP="group",qr.LIST="list",qr.LISTBOX="listbox",qr.LISTITEM="listitem",qr.MENU="menu",qr.MENUITEM="menuitem",qr.NONE="none",qr.OPTION="option",qr.REGION="region",qr.ROW="row",qr.SEARCH="search",qr.SEPARATOR="separator",qr.STATUS="status",qr.TEXTBOX="textbox",qr.TREE="tree",qr.TREEITEM="treeitem";var $r,jr=Hr.STATUS,zr=$r||($r={});zr.ACTIVEDESCENDANT="activedescendant",zr.ATOMIC="atomic",zr.CHECKED="checked",zr.CONTROLS="controls",zr.DISABLED="disabled",zr.EXPANDED="expanded",zr.HASPOPUP="haspopup",zr.HIDDEN="hidden",zr.INVALID="invalid",zr.LABEL="label",zr.LABELLEDBY="labelledby",zr.LEVEL="level",zr.LIVE="live",zr.PRESSED="pressed",zr.ROLEDESCRIPTION="roledescription",zr.SELECTED="selected",zr.VALUEMAX="valuemax",zr.VALUEMIN="valuemin",zr.OWNS="owns";var Xr,Yr=Xr||(Xr={});Yr[Yr.TERSE=0]="TERSE",Yr[Yr.STANDARD=1]="STANDARD",Yr[Yr.LOQUACIOUS=2]="LOQUACIOUS";var Kr,Jr=null,Qr=!1,Zr={};Zr.LiveRegionAssertiveness=Pr,Zr.Role=Hr,Zr.State=$r,Zr.Verbosity=Xr,Zr.announceDynamicAriaState=v,Zr.clearState=m,Zr.getRole=function(e){return(e=e.getAttribute("role"))&&Object.values(Hr).includes(e)?e:null},Zr.getState=b,Zr.initializeGlobalAriaLiveRegion=C,Zr.removeRole=T,Zr.setRole=_,Zr.setState=f;var ea=class{constructor(e){this.tagName=e}toString(){return this.tagName}};ea.ANIMATE=new ea("animate"),ea.CIRCLE=new ea("circle"),ea.CLIPPATH=new ea("clipPath"),ea.DEFS=new ea("defs"),ea.FECOMPOSITE=new ea("feComposite"),ea.FECOMPONENTTRANSFER=new ea("feComponentTransfer"),ea.FEFLOOD=new ea("feFlood"),ea.FEFUNCA=new ea("feFuncA"),ea.FEGAUSSIANBLUR=new ea("feGaussianBlur"),ea.FEPOINTLIGHT=new ea("fePointLight"),ea.FESPECULARLIGHTING=new ea("feSpecularLighting"),ea.FILTER=new ea("filter"),ea.FOREIGNOBJECT=new ea("foreignObject"),ea.G=new ea("g"),ea.IMAGE=new ea("image"),ea.LINE=new ea("line"),ea.PATH=new ea("path"),ea.PATTERN=new ea("pattern"),ea.POLYGON=new ea("polygon"),ea.RECT=new ea("rect"),ea.SVG=new ea("svg"),ea.TEXT=new ea("text"),ea.TSPAN=new ea("tspan");var ta,ia=ta||(ta={});ia[ia.ELEMENT_NODE=1]="ELEMENT_NODE",ia[ia.TEXT_NODE=3]="TEXT_NODE",ia[ia.COMMENT_NODE=8]="COMMENT_NODE";var na=null,oa=0,sa=null,ra={HTML_NS:"http://www.w3.org/1999/xhtml"};ra.NodeType=ta,ra.SVG_NS="http://www.w3.org/2000/svg",ra.XLINK_NS="http://www.w3.org/1999/xlink",ra.addClass=N,ra.createSvgElement=I,ra.getFastTextWidth=function(e,t,i,n){return x(e,t+"pt",i,n)},ra.getFastTextWidthWithSizeString=x,ra.getTextWidth=D,ra.hasClass=k,ra.insertAfter=O,ra.measureFontMetrics=F,ra.removeClass=A,ra.removeClasses=y,ra.removeNode=S,ra.setCssTransform=R,ra.startTextWidthCache=w,ra.stopTextWidthCache=L;var aa=class{static findFocusedNode(e){var t=e.getRootFocusableNode();if(!t.canBeFocused())return null;var i=t.getFocusableElement();return k(i,aa.ACTIVE_CLASS_NAME)||k(i,aa.PASSIVE_CSS_CLASS_NAME)||((t=i.querySelector(this.ACTIVE_FOCUS_NODE_CSS_SELECTOR))instanceof HTMLElement||t instanceof SVGElement)&&(t=aa.findFocusableNodeFor(t,e))?t:((i=i.querySelector(this.PASSIVE_FOCUS_NODE_CSS_SELECTOR))instanceof HTMLElement||i instanceof SVGElement)&&(e=aa.findFocusableNodeFor(i,e))?e:null}static findFocusableNodeFor(e,t){if(!e.id||"null"===e.id||-1!==t.getNestedTrees().map((t=>aa.findFocusableNodeFor(e,t))).findIndex((e=>!!e)))return null;var i,n=t.getRootFocusableNode();return n.canBeFocused()&&e===n.getFocusableElement()||(n=null!=(i=t.lookUpFocusableNode(e.id))?i:null)?n:null!==(i=e.getAttribute("tabindex"))&&Number(i)>=0?null:(i=e.parentElement)?aa.findFocusableNodeFor(i,t):null}};aa.ACTIVE_CLASS_NAME="blocklyActiveFocus",aa.PASSIVE_CSS_CLASS_NAME="blocklyPassiveFocus",aa.ACTIVE_FOCUS_NODE_CSS_SELECTOR=`.${aa.ACTIVE_CLASS_NAME}`,aa.PASSIVE_FOCUS_NODE_CSS_SELECTOR=`.${aa.PASSIVE_CSS_CLASS_NAME}`;var la=class{constructor(e,t){this.tree=e,this.rootShouldBeAutoTabbable=t}},ha=class{constructor(e){this.previouslyFocusedNode=this.focusedNode=null,this.registeredTrees=[],this.isUpdatingFocusedNode=this.recentlyLostAllFocus=this.lockFocusStateChanges=this.currentlyHoldsEphemeralFocus=!1,this.popoverFocusLossHandlers=new Set,this.popoverFocusOutHandler=e=>{var t;if(null===(e=e.relatedTarget)||e instanceof Node&&(null==(t=this.popoverFocusRoot)||!t.contains(e)))for(let e of this.popoverFocusLossHandlers)e()};var t=e=>{if(!this.isUpdatingFocusedNode){this.recentlyLostAllFocus=!e;var t=null;if(e instanceof HTMLElement||e instanceof SVGElement)for(var i of this.registeredTrees)if(t=aa.findFocusableNodeFor(e,i.tree))break;if(t&&t.canBeFocused()){let n;e=t.getFocusableTree(),i=null==(n=this.focusedNode)?void 0:n.getFocusableTree(),t===e.getRootFocusableNode()&&e!==i?this.focusTree(e):this.focusNode(t)}else this.defocusCurrentFocusedNode()}};e("focusin",(e=>{e instanceof FocusEvent&&t(document.activeElement)})),e("focusout",(e=>{e instanceof FocusEvent&&t(e.relatedTarget)}))}registerTree(e,t=!1){if(this.ensureManagerIsUnlocked(),this.isRegistered(e))throw Error(`Attempted to re-register already registered tree: ${e}.`);this.registeredTrees.push(new la(e,t));var i=e.getRootFocusableNode().getFocusableElement();if(!i.id||"null"===i.id)throw Error(`Attempting to register a tree with a root element that has an invalid ID: ${e}.`);t&&(i.tabIndex=0)}isRegistered(e){return!!this.lookUpRegistration(e)}lookUpRegistration(e){var t;return null!=(t=this.registeredTrees.find((t=>t.tree===e)))?t:null}unregisterTree(e){if(this.ensureManagerIsUnlocked(),!this.isRegistered(e))throw Error(`Attempted to unregister not registered tree: ${e}.`);var t=this.registeredTrees.findIndex((t=>t.tree===e)),i=this.registeredTrees[t];this.registeredTrees.splice(t,1),t=aa.findFocusedNode(e);var n=e.getRootFocusableNode();t&&this.removeHighlight(t),this.focusedNode!==t&&this.focusedNode!==n||this.updateFocusedNode(null),this.removeHighlight(n),i.rootShouldBeAutoTabbable&&e.getRootFocusableNode().getFocusableElement().removeAttribute("tabindex")}getFocusedTree(){var e,t;return null!=(t=null==(e=this.focusedNode)?void 0:e.getFocusableTree())?t:null}getFocusedNode(){return this.focusedNode}getPreviouslyFocusedNode(){return this.previouslyFocusedNode}focusTree(e){if(this.ensureManagerIsUnlocked(),!this.isRegistered(e))throw Error(`Attempted to focus unregistered tree: ${e}.`);var t,i=aa.findFocusedNode(e),n=e.getRestoredFocusableNode(i);e=e.getRootFocusableNode(),this.focusNode(null!=(t=null!=n?n:i)?t:e)}focusNode(e){this.ensureManagerIsUnlocked();var t=!this.currentlyHoldsEphemeralFocus;t&&(this.isUpdatingFocusedNode=!0);var i,n=(null==(i=this.focusedNode)?void 0:i.getFocusableElement())!==document.activeElement;if(this.focusedNode!==e||n)if(e.canBeFocused()){if(i=e.getFocusableTree(),!this.isRegistered(i))throw Error(`Attempted to focus unregistered node: ${e}.`);(n=e.getFocusableElement()).id&&"null"!==n.id||console.warn("Trying to focus a node that has an invalid ID.");var o=aa.findFocusableNodeFor(n,i);n=aa.findFocusedNode(i);var s,r=e;o!==e&&(r=i.getRestoredFocusableNode(n),e=i.getRootFocusableNode(),r=null!=(s=null!=r?r:n)?s:e),s=null==(e=this.focusedNode)?void 0:e.getFocusableTree(),e&&this.passivelyFocusNode(e,i),i=i.getRootFocusableNode(),n&&this.removeHighlight(n),i!==r&&this.removeHighlight(i),this.currentlyHoldsEphemeralFocus||this.activelyFocusNode(r,null!=s?s:null),this.updateFocusedNode(r)}else console.warn("Trying to focus a node that can't be focused.");t&&(this.isUpdatingFocusedNode=!1)}takeEphemeralFocus(e){if(this.ensureManagerIsUnlocked(),this.currentlyHoldsEphemeralFocus)throw Error(`Attempted to take ephemeral focus when it's already held, with new element: ${e}.`);this.currentlyHoldsEphemeralFocus=!0,this.focusedNode&&this.passivelyFocusNode(this.focusedNode,null),e.focus({preventScroll:!0});var t=!1;return(i=!0)=>{if(t)throw Error(`Attempted to finish ephemeral focus twice for element: ${e}.`);if(t=!0,this.currentlyHoldsEphemeralFocus=!1,this.focusedNode&&i){this.activelyFocusNode(this.focusedNode,null);let e=this.focusedNode;setTimeout((()=>{!this.focusedNode&&this.previouslyFocusedNode===e&&this.recentlyLostAllFocus&&this.focusNode(e)}),0)}}}ephemeralFocusTaken(){return this.currentlyHoldsEphemeralFocus}ensureManagerIsUnlocked(){if(this.lockFocusStateChanges)throw Error("FocusManager state changes cannot happen in a tree/node focus/blur callback.")}updateFocusedNode(e){this.previouslyFocusedNode=this.focusedNode,this.focusedNode=e}defocusCurrentFocusedNode(){this.focusedNode&&!this.currentlyHoldsEphemeralFocus&&(this.passivelyFocusNode(this.focusedNode,null),this.updateFocusedNode(null))}activelyFocusNode(e,t){this.lockFocusStateChanges=!0;var i,n=e.getFocusableTree(),o=e.getFocusableElement(),s=null==(i=this.lookUpRegistration(n))?void 0:i.rootShouldBeAutoTabbable;n!==t&&(n.onTreeFocus(e,t),s&&(n.getRootFocusableNode().getFocusableElement().tabIndex=-1)),e.onNodeFocus(),this.lockFocusStateChanges=!1,s&&e===n.getRootFocusableNode()||o.hasAttribute("tabindex")||(o.tabIndex=-1),this.setNodeToVisualActiveFocus(e),o.focus({preventScroll:!0})}passivelyFocusNode(e,t){this.lockFocusStateChanges=!0;var i=e.getFocusableTree();if(i!==t){let e;i.onTreeBlur(t),null!=(e=this.lookUpRegistration(i))&&e.rootShouldBeAutoTabbable&&(i.getRootFocusableNode().getFocusableElement().tabIndex=0)}e.onNodeBlur(),this.lockFocusStateChanges=!1,i!==t&&this.setNodeToVisualPassiveFocus(e)}setNodeToVisualActiveFocus(e){e=e.getFocusableElement(),N(e,ha.ACTIVE_FOCUS_NODE_CSS_CLASS_NAME),A(e,ha.PASSIVE_FOCUS_NODE_CSS_CLASS_NAME)}setNodeToVisualPassiveFocus(e){e=e.getFocusableElement(),A(e,ha.ACTIVE_FOCUS_NODE_CSS_CLASS_NAME),N(e,ha.PASSIVE_FOCUS_NODE_CSS_CLASS_NAME)}removeHighlight(e){e=e.getFocusableElement(),A(e,ha.ACTIVE_FOCUS_NODE_CSS_CLASS_NAME),A(e,ha.PASSIVE_FOCUS_NODE_CSS_CLASS_NAME)}static getFocusManager(){return ha.focusManager||(ha.focusManager=new ha(document.addEventListener)),ha.focusManager}setPopoverFocusRoot(e){var t;null==(t=this.popoverFocusRoot)||t.removeEventListener("focusout",this.popoverFocusOutHandler),this.popoverFocusRoot=e,this.popoverFocusRoot.addEventListener("focusout",this.popoverFocusOutHandler)}registerPopoverFocusLossHandler(e){this.popoverFocusLossHandlers.add(e)}unregisterPopoverFocusLossHandler(e){this.popoverFocusLossHandlers.delete(e)}};ha.ACTIVE_FOCUS_NODE_CSS_CLASS_NAME="blocklyActiveFocus",ha.PASSIVE_FOCUS_NODE_CSS_CLASS_NAME="blocklyPassiveFocus",ha.focusManager=null;var ua={};ua.deepMerge=B;var ca=class{constructor(){this.shortcuts=new Map,this.keyMap=new Map,this.reset()}reset(){this.shortcuts.clear(),this.keyMap.clear()}register(e,t){if(this.shortcuts.get(e.name)&&!t)throw Error(`Shortcut named "${e.name}" already exists.`);if(this.shortcuts.set(e.name,e),null!=(t=e.keyCodes)&&t.length)for(let i of t)this.addKeyMapping(i,e.name,!!e.allowCollision)}unregister(e){return this.shortcuts.get(e)?(this.removeAllKeyMappings(e),this.shortcuts.delete(e),!0):(console.warn(`Keyboard shortcut named "${e}" not found.`),!1)}addKeyMapping(e,t,i){e=`${e}`;var n=this.keyMap.get(e);if(n&&!i)throw Error(`Shortcut named "${t}" collides with shortcuts "${[...n]}"`);n&&i?this.keyMap.set(e,new Set([t,...n])):this.keyMap.set(e,new Set([t]))}removeKeyMapping(e,t,i){var n=this.keyMap.get(e);return n&&n.delete(t)?(0===n.size&&this.keyMap.delete(e),!0):(i||console.warn(`No keyboard shortcut named "${t}" registered with key code "${e}"`),!1)}removeAllKeyMappings(e){for(let t of this.keyMap.keys())this.removeKeyMapping(t,e,!0)}setKeyMap(e){this.keyMap.clear();for(let t in e)this.keyMap.set(t,new Set(e[t]))}getKeyMap(){var e=Object.create(null);for(let[t,i]of this.keyMap)e[t]=[...i];return e}getRegistry(){var e=Object.create(null);for(let[t,i]of this.shortcuts)e[t]=i;return B(Object.create(null),e)}onKeyDown(e,t){var i=this.serializeKeyEvent(t);if(!(i=this.getShortcutNamesByKeyCode(i)))return!1;for(let n of i){let o,s,r;if((i=this.shortcuts.get(n))&&(!i.preconditionFn||i.preconditionFn(e,{focusedNode:null!=(o=Zs.t().getFocusedNode())?o:void 0}))&&null!=(s=i.callback)&&s.call(i,e,t,i,{focusedNode:null!=(r=Zs.t().getFocusedNode())?r:void 0}))return!0}return!1}getShortcutNamesByKeyCode(e){return(e=this.keyMap.get(e))?[...e]:[]}getKeyCodesByShortcutName(e){var t=[];for(let[i,n]of this.keyMap)n.has(e)&&t.push(i);return t}serializeKeyEvent(e){var t="";for(let i in ca.modifierKeys)e.getModifierState(i)&&(""!==t&&(t+="+"),t+=i);return""!==t&&e.keyCode?t+="+"+e.keyCode:e.keyCode&&(t=String(e.keyCode)),t}checkModifiers(e){for(let t of e)if(!(t in ca.modifierKeys))throw Error(t+" is not a valid modifier key.")}createSerializedKey(e,t){var i="";if(t){this.checkModifiers(t);for(let e in ca.modifierKeys)t.includes(ca.modifierKeys[e])&&(""!==i&&(i+="+"),i+=e)}return""!==i&&e?i+="+"+e:e&&(i=`${e}`),i}};ca.registry=new ca;var da=ca||(ca={}),pa=da.modifierKeys||(da.modifierKeys={});pa[pa.Shift=16]="Shift",pa[pa.Control=17]="Control",pa[pa.Alt=18]="Alt",pa[pa.Meta=91]="Meta";var ga=new Set,Ea={};Ea.warn=U;var Ta,_a,fa=Object.create(null),ma=[],ba={defineBlocksWithJsonArrayInternal:function(e){Zs.Ab(Zs.yb(e))}},Ca={TEST_ONLY:ba};Ca.createBlockDefinitionsFromJsonArray=Zs.yb,Ca.defineBlocks=Zs.Ab,Ca.defineBlocksWithJsonArray=Z,Ca.draggingConnections=ma,Ca.fireSelectedEvent=z,Ca.getAllWorkspaces=H,Ca.getBlockTypeCounts=J,Ca.getMainWorkspace=q,Ca.getParentContainer=X,Ca.getSelected=j,Ca.getWorkspaceById=V,Ca.globalShortcutHandler=ee,Ca.registerWorkspace=G,Ca.setMainWorkspace=$,Ca.setParentContainer=Y,Ca.setSelected=function(e){Zs.t().focusNode(e)},Ca.svgResize=K,Ca.unregisterWorkpace=function(e){U("Blockly.common.unregisterWorkpace","v13","v14","Blockly.common.unregisterWorkspace"),W(e)},Ca.unregisterWorkspace=W;var va=Object.create(null),Ia={typeMap:va},Na=Object.create(null),ya=class{constructor(e){this.name=e}toString(){return this.name}};ya.CONNECTION_CHECKER=new ya("connectionChecker"),ya.CONNECTION_PREVIEWER=new ya("connectionPreviewer"),ya.EVENT=new ya("event"),ya.FIELD=new ya("field"),ya.INPUT=new ya("input"),ya.RENDERER=new ya("renderer"),ya.TOOLBOX=new ya("toolbox"),ya.THEME=new ya("theme"),ya.TOOLBOX_ITEM=new ya("toolboxItem"),ya.FLYOUTS_VERTICAL_TOOLBOX=new ya("flyoutsVerticalToolbox"),ya.FLYOUTS_HORIZONTAL_TOOLBOX=new ya("flyoutsHorizontalToolbox"),ya.FLYOUT_INFLATER=new ya("flyoutInflater"),ya.METRICS_MANAGER=new ya("metricsManager"),ya.BLOCK_DRAGGER=new ya("blockDragger"),ya.SERIALIZER=new ya("serializer"),ya.ICON=new ya("icon"),ya.PASTER=new ya("paster"),ya.VARIABLE_MODEL=new ya("variableModel"),ya.VARIABLE_MAP=new ya("variableMap");var Aa={DEFAULT:"default",TEST_ONLY:Ia};Aa.Type=ya,Aa.getAllItems=re,Aa.getClass=se,Aa.getClassFromOptions=ae,Aa.getObject=function(e,t,i){return ne(e,t,i)},Aa.hasItem=oe,Aa.register=te,Aa.unregister=ie;var ka,Sa,Oa,Ra={genUid:()=>{var e=[];for(let t=0;t<20;t++)e[t]="!#$%()*+,-./:;=?@[]^_`{|}~ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789".charAt(88*Math.random());return e.join("")}},wa=0,La={TEST_ONLY:Ra};La.genUid=he,La.getNextUniqueId=le,Zs.gd="",Zs.Qc=!0,Zs.Ub=0,Sa={FIRE_QUEUE:ka=[],enqueueEvent:de,fireNow:ce,fireInternal:function(e){if(Ee()){if(!ka.length)try{requestAnimationFrame((()=>{setTimeout(ce,0)}))}catch(e){setTimeout(ce,0)}de(e)}},setGroupInternal:function(e){Zs.gd="boolean"==typeof e?e?he():"":e}},Zs.C=Object.create(null),Oa={Msg:Zs.C,setLocale:fe};var Da=class{constructor(e,t){this.x=e,this.y=t}clone(){return new Da(this.x,this.y)}scale(e){return this.x*=e,this.y*=e,this}translate(e,t){return this.x+=e,this.y+=t,this}static equals(e,t){return e===t||!(!e||!t)&&e.x===t.x&&e.y===t.y}static distance(e,t){var i=e.x-t.x;return e=e.y-t.y,Math.sqrt(i*i+e*e)}static magnitude(e){return Math.sqrt(e.x*e.x+e.y*e.y)}static difference(e,t){return new Da(e.x-t.x,e.y-t.y)}static sum(e,t){return new Da(e.x+t.x,e.y+t.y)}},xa=class{constructor(e,t,i,n){this.top=e,this.bottom=t,this.left=i,this.right=n}static from(e){return new xa(e.y,e.y+e.height,e.x,e.x+e.width)}clone(){return new xa(this.top,this.bottom,this.left,this.right)}getHeight(){return this.bottom-this.top}getWidth(){return this.right-this.left}getOrigin(){return new Da(this.left,this.top)}contains(e,t){return e>=this.left&&e<=this.right&&t>=this.top&&t<=this.bottom}intersects(e){return this.left<=e.right&&this.right>=e.left&&this.bottom>=e.top&&this.top<=e.bottom}static equals(e,t){return e===t||!(!e||!t)&&e.top===t.top&&e.bottom===t.bottom&&e.left===t.left&&e.right===t.right}static createFromPoint(e,t,i){var n=e.x;return e=e.y,new xa(e,e+i,n,n+t)}},Fa=class{constructor(e,t){this.width=e,this.height=t}static equals(e,t){return e===t||!(!e||!t)&&e.width===t.width&&e.height===t.height}static max(e,t){return new Fa(Math.max(e.width,t.width),Math.max(e.height,t.height))}static min(e,t){return new Fa(Math.min(e.width,t.width),Math.min(e.height,t.height))}},Ma={getSizeInternal:function(e){if("none"!==be(e,"display"))return new Fa(e.offsetWidth,e.offsetHeight);var t=e.style,i=t.display,n=t.visibility,o=t.position;t.visibility="hidden",t.position="absolute",t.display="inline";var s=e.offsetWidth;return e=e.offsetHeight,t.display=i,t.position=o,t.visibility=n,new Fa(s,e)}},Pa={TEST_ONLY:Ma};Pa.getBorderBox=Ie,Pa.getComputedStyle=be,Pa.getContainerOffsetToScrollInto=Ae,Pa.getPageOffset=Ce,Pa.getSize=me,Pa.getViewportPageOffset=ve,Pa.pageToContainerOffset=Ne,Pa.scrollIntoContainerView=ye;var Ba=/translate\(\s*([-+\d.e]+)([ ,]\s*([-+\d.e]+)\s*)?/,Ua=/transform:\s*translate(?:3d)?\(\s*([-+\d.e]+)\s*px([ ,]\s*([-+\d.e]+)\s*px)?/,Va={TEST_ONLY:{XY_REGEX:Ba,XY_STYLE_REGEX:Ua}};Va.getDocumentScroll=Re,Va.getInjectionDivXY=Se,Va.getRelativeXY=ke,Va.getViewportBBox=Oe,Va.screenToWsCoordinates=we,Va.wsToScreenCoordinates=Le;var Ha=class{constructor(e,t,i,n,o){this.workspace=e,this.horizontal=t,this.oldHostMetrics=null,this.ratio=1,this.origin=new Da(0,0),this.startDragHandle=this.handlePosition=this.handleLength=this.scrollbarLength=this.startDragMouse=0,this.containerVisible=this.isHandleVisible=!0,this.position=new Da(0,0),this.onMouseMoveWrapper_=this.onMouseUpWrapper_=null,this.pair=i||!1,this.margin=void 0!==o?o:Ha.DEFAULT_SCROLLBAR_MARGIN,e="blocklyScrollbar"+(this.horizontal?"Horizontal":"Vertical"),n&&(e+=" "+n),this.outerSvg=I(ea.SVG,{class:e}),n=I(ea.G,{},this.outerSvg),this.svgBackground=I(ea.RECT,{class:"blocklyScrollbarBackground"},n),e=Math.floor((Ha.scrollbarThickness-5)/2),this.svgHandle=I(ea.RECT,{class:"blocklyScrollbarHandle",rx:e,ry:e},n),this.workspace.getThemeManager().subscribe(this.svgHandle,"scrollbarColour","fill"),this.workspace.getThemeManager().subscribe(this.svgHandle,"scrollbarOpacity","fill-opacity"),O(this.outerSvg,this.workspace.getParentSvg()),this.setInitialThickness(),t?(this.lengthAttribute_="width",this.positionAttribute_="x"):(this.lengthAttribute_="height",this.positionAttribute_="y"),this.onMouseDownBarWrapper_=r(this.svgBackground,"pointerdown",this,this.onMouseDownBar),this.onMouseDownHandleWrapper_=r(this.svgHandle,"pointerdown",this,this.onMouseDownHandle)}setInitialThickness(){var e=Ha.scrollbarThickness;this.horizontal?(this.svgBackground.setAttribute("height",String(e)),this.outerSvg.setAttribute("height",String(e)),this.svgHandle.setAttribute("height",String(e-5)),this.svgHandle.setAttribute("y","2.5")):(this.svgBackground.setAttribute("width",String(e)),this.outerSvg.setAttribute("width",String(e)),this.svgHandle.setAttribute("width",String(e-5)),this.svgHandle.setAttribute("x","2.5"))}dispose(){this.cleanUp(),l(this.onMouseDownBarWrapper_),l(this.onMouseDownHandleWrapper_),S(this.outerSvg),this.workspace.getThemeManager().unsubscribe(this.svgHandle)}constrainHandleLength(e){return e<=0||isNaN(e)?0:Math.min(e,this.scrollbarLength)}setHandleLength(e){this.handleLength=e,this.svgHandle.setAttribute(this.lengthAttribute_,String(this.handleLength))}constrainHandlePosition(e){return e<=0||isNaN(e)?0:Math.min(e,this.scrollbarLength-this.handleLength)}setHandlePosition(e){this.handlePosition=e,this.svgHandle.setAttribute(this.positionAttribute_,String(this.handlePosition))}setScrollbarLength(e){this.scrollbarLength=e,this.outerSvg.setAttribute(this.lengthAttribute_,String(this.scrollbarLength)),this.svgBackground.setAttribute(this.lengthAttribute_,String(this.scrollbarLength))}setPosition(e,t){this.position.x=e,this.position.y=t,R(this.outerSvg,"translate("+(this.position.x+this.origin.x)+"px,"+(this.position.y+this.origin.y)+"px)")}resize(e){(e||(e=this.workspace.getMetrics()))&&(this.oldHostMetrics&&Ha.metricsAreEquivalent(e,this.oldHostMetrics)||(this.horizontal?this.resizeHorizontal(e):this.resizeVertical(e),this.oldHostMetrics=e,this.updateMetrics()))}requiresViewResize(e){return!this.oldHostMetrics||this.oldHostMetrics.viewWidth!==e.viewWidth||this.oldHostMetrics.viewHeight!==e.viewHeight||this.oldHostMetrics.absoluteLeft!==e.absoluteLeft||this.oldHostMetrics.absoluteTop!==e.absoluteTop}resizeHorizontal(e){this.requiresViewResize(e)?this.resizeViewHorizontal(e):this.resizeContentHorizontal(e)}resizeViewHorizontal(e){var t=e.viewWidth-2*this.margin;this.pair&&(t-=Ha.scrollbarThickness),this.setScrollbarLength(Math.max(0,t)),t=e.absoluteLeft+this.margin,this.pair&&this.workspace.RTL&&(t+=Ha.scrollbarThickness),this.setPosition(t,e.absoluteTop+e.viewHeight-Ha.scrollbarThickness-this.margin),this.resizeContentHorizontal(e)}resizeContentHorizontal(e){if(e.viewWidth>=e.scrollWidth)this.setHandleLength(this.scrollbarLength),this.setHandlePosition(0),this.pair||this.setVisible(!1);else{this.pair||this.setVisible(!0);var t=this.scrollbarLength*e.viewWidth/e.scrollWidth;t=this.constrainHandleLength(t),this.setHandleLength(t),t=e.scrollWidth-e.viewWidth;var i=this.scrollbarLength-this.handleLength;e=(e.viewLeft-e.scrollLeft)/t*i,e=this.constrainHandlePosition(e),this.setHandlePosition(e),this.ratio=i/t}}resizeVertical(e){this.requiresViewResize(e)?this.resizeViewVertical(e):this.resizeContentVertical(e)}resizeViewVertical(e){var t=e.viewHeight-2*this.margin;this.pair&&(t-=Ha.scrollbarThickness),this.setScrollbarLength(Math.max(0,t)),this.setPosition(this.workspace.RTL?e.absoluteLeft+this.margin:e.absoluteLeft+e.viewWidth-Ha.scrollbarThickness-this.margin,e.absoluteTop+this.margin),this.resizeContentVertical(e)}resizeContentVertical(e){if(e.viewHeight>=e.scrollHeight)this.setHandleLength(this.scrollbarLength),this.setHandlePosition(0),this.pair||this.setVisible(!1);else{this.pair||this.setVisible(!0);var t=this.scrollbarLength*e.viewHeight/e.scrollHeight;t=this.constrainHandleLength(t),this.setHandleLength(t),t=e.scrollHeight-e.viewHeight;var i=this.scrollbarLength-this.handleLength;e=(e.viewTop-e.scrollTop)/t*i,e=this.constrainHandlePosition(e),this.setHandlePosition(e),this.ratio=i/t}}isVisible(){return this.isHandleVisible}setContainerVisible(e){var t=e!==this.containerVisible;this.containerVisible=e,t&&this.updateDisplay_()}setVisible(e){if(this.pair)throw Error("Unable to toggle visibility of paired scrollbars.");this.setVisibleInternal(e)}setVisibleInternal(e){var t=e!==this.isVisible();this.isHandleVisible=e,t&&this.updateDisplay_()}updateDisplay_(){this.containerVisible&&this.isVisible()?this.outerSvg.setAttribute("display","block"):this.outerSvg.setAttribute("display","none")}onMouseDownBar(e){if(this.workspace.markFocused(),dr=null,this.cleanUp(),u(e))e.stopPropagation();else{var t=c(e,this.workspace.getParentSvg(),this.workspace.getInverseScreenCTM());t=this.horizontal?t.x:t.y;var i=Se(this.svgHandle);i=this.horizontal?i.x:i.y;var n=this.handlePosition,o=.95*this.handleLength;t<=i?n-=o:t>=i+this.handleLength&&(n+=o),this.setHandlePosition(this.constrainHandlePosition(n)),this.updateMetrics(),e.stopPropagation(),e.preventDefault()}}onMouseDownHandle(e){this.workspace.markFocused(),this.cleanUp(),u(e)?e.stopPropagation():(this.startDragHandle=this.handlePosition,this.startDragMouse=this.horizontal?e.clientX:e.clientY,this.onMouseUpWrapper_=r(document,"pointerup",this,this.onMouseUpHandle),this.onMouseMoveWrapper_=r(document,"pointermove",this,this.onMouseMoveHandle),e.stopPropagation(),e.preventDefault())}onMouseMoveHandle(e){this.setHandlePosition(this.constrainHandlePosition(this.startDragHandle+((this.horizontal?e.clientX:e.clientY)-this.startDragMouse))),this.updateMetrics()}onMouseUpHandle(){dr=null,this.cleanUp()}cleanUp(){this.workspace.hideChaff(!0),this.onMouseUpWrapper_&&(l(this.onMouseUpWrapper_),this.onMouseUpWrapper_=null),this.onMouseMoveWrapper_&&(l(this.onMouseMoveWrapper_),this.onMouseMoveWrapper_=null)}getRatio_(){var e=this.handlePosition/(this.scrollbarLength-this.handleLength);return isNaN(e)&&(e=0),e}updateMetrics(){var e=this.getRatio_();this.horizontal?this.workspace.setMetrics({x:e}):this.workspace.setMetrics({y:e})}set(e,t){this.setHandlePosition(this.constrainHandlePosition(e*this.ratio)),(t||void 0===t)&&this.updateMetrics()}setOrigin(e,t){this.origin=new Da(e,t)}static metricsAreEquivalent(e,t){return e.viewWidth===t.viewWidth&&e.viewHeight===t.viewHeight&&e.viewLeft===t.viewLeft&&e.viewTop===t.viewTop&&e.absoluteTop===t.absoluteTop&&e.absoluteLeft===t.absoluteLeft&&e.scrollWidth===t.scrollWidth&&e.scrollHeight===t.scrollHeight&&e.scrollLeft===t.scrollLeft&&e.scrollTop===t.scrollTop}};Ha.scrollbarThickness=cr?25:15,Ha.DEFAULT_SCROLLBAR_MARGIN=.5;var Ga={parseFromString:function(){throw Error("DOMParser was not found in the global scope and was not properly injected using injectDependencies")}},Wa={serializeToString:function(){throw Error("XMLSerializer was not foundin the global scope and was not properly injected using injectDependencies")}},{document:qa,DOMParser:$a,XMLSerializer:ja}=globalThis;$a&&(Ga=new $a),ja&&(Wa=new ja);var za=/[\x00-\x09\x0B\x0C\x0E-\x1F]/g,Xa={NAME_SPACE:"https://developers.google.com/blockly/xml"};Xa.createElement=Zs.sc,Xa.createTextNode=Zs.tc,Xa.domToText=De,Xa.injectDependencies=function(e){({document:qa=qa,DOMParser:$a=$a,XMLSerializer:ja=ja}=e),Ga=new $a,Wa=new ja},Xa.textToDom=Zs.vc;var Ya,Ka=Ya||(Ya={});Ka[Ka.TOP=0]="TOP",Ka[Ka.BOTTOM=1]="BOTTOM",Ka[Ka.LEFT=2]="LEFT",Ka[Ka.RIGHT=3]="RIGHT";var Ja={};Ja.Position=Ya,Ja.convertFlyoutDefToJsonArray=Me,Ja.convertToolboxDefToJson=Fe,Ja.hasCategories=Pe,Ja.isCategoryCollapsible=Be,Ja.parseToolboxTree=He;var Qa,Za=Qa||(Qa={});Za[Za.TOP=0]="TOP",Za[Za.BOTTOM=1]="BOTTOM";var el,tl=el||(el={});tl[tl.LEFT=0]="LEFT",tl[tl.RIGHT=1]="RIGHT";var il,nl=il||(il={});nl[nl.UP=0]="UP",nl[nl.DOWN=1]="DOWN";var ol={};ol.bumpDirection=il,ol.bumpPositionRect=qe,ol.getCornerOppositeToolbox=We,ol.getStartPositionRect=Ge,ol.horizontalPosition=el,ol.verticalPosition=Qa;var sl=96,rl=124,al="sprites.svg",ll=class{constructor(e,t){this.workspace=e,this.group=t,this.pointerDownHandler=r(t,"pointerdown",null,this.performAction.bind(this)),this.keyDownHandler=a(t,"keydown",this,this.onKeyDown),_(t,Hr.BUTTON),this.id=le(),this.group.id=this.id}zoom(e,t){this.workspace.markFocused(),this.workspace.zoomCenter(e),this.fireZoomEvent(),dr=null,t.stopPropagation(),t.preventDefault()}fireZoomEvent(){var e=new(_e(Fr.CLICK))(null,this.workspace.id,"zoom_controls");ue(e)}getGroup(){return this.group}onKeyDown(e){"Enter"!==e.key&&" "!==e.key||(e.preventDefault(),this.performAction(e))}dispose(){l(this.pointerDownHandler),l(this.keyDownHandler)}},hl=class extends ll{constructor(e,t){var i=String(Math.random()).substring(2);t=I(ea.G,{class:"blocklyZoom blocklyZoomIn",tabindex:"0"},t),f(t,$r.LABEL,Zs.C.ZOOM_IN),I(ea.RECT,{width:40,height:40,x:-4,y:-4,rx:2,ry:2,fill:"none",class:"blocklyFocusRing"},t);var n=I(ea.CLIPPATH,{id:"blocklyZoominClipPath"+i},t);I(ea.RECT,{width:32,height:32},n),I(ea.IMAGE,{width:sl,height:rl,x:-32,y:-92,"clip-path":"url(#blocklyZoominClipPath"+i+")"},t).setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",e.options.pathToMedia+al),super(e,t)}performAction(e){this.zoom(1,e)}},ul=class extends ll{constructor(e,t){var i=String(Math.random()).substring(2);t=I(ea.G,{class:"blocklyZoom blocklyZoomOut",tabindex:"0"},t),f(t,$r.LABEL,Zs.C.ZOOM_OUT),I(ea.RECT,{width:40,height:40,x:-4,y:-4,rx:2,ry:2,fill:"none",class:"blocklyFocusRing"},t);var n=I(ea.CLIPPATH,{id:"blocklyZoomoutClipPath"+i},t);I(ea.RECT,{width:32,height:32},n),I(ea.IMAGE,{width:sl,height:rl,x:-64,y:-92,"clip-path":"url(#blocklyZoomoutClipPath"+i+")"},t).setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",e.options.pathToMedia+al),super(e,t)}performAction(e){this.zoom(-1,e)}},cl=class extends ll{constructor(e,t){var i=String(Math.random()).substring(2);t=I(ea.G,{class:"blocklyZoom blocklyZoomReset",tabindex:"0"},t),f(t,$r.LABEL,Zs.C.RESET_ZOOM),I(ea.RECT,{width:40,height:40,x:-4,y:-4,rx:2,ry:2,fill:"none",class:"blocklyFocusRing"},t);var n=I(ea.CLIPPATH,{id:"blocklyZoomresetClipPath"+i},t);I(ea.RECT,{width:32,height:32},n),I(ea.IMAGE,{width:sl,height:rl,y:-92,"clip-path":"url(#blocklyZoomresetClipPath"+i+")"},t).setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",e.options.pathToMedia+al),super(e,t)}performAction(e){this.workspace.markFocused();var t=Math.log(this.workspace.options.zoomOptions.startScale/this.workspace.scale)/Math.log(this.workspace.options.zoomOptions.scaleSpeed);this.workspace.beginCanvasTransition(),this.workspace.zoomCenter(t),this.workspace.scrollCenter(),setTimeout(this.workspace.endCanvasTransition.bind(this.workspace),500),this.fireZoomEvent(),dr=null,e.stopPropagation(),e.preventDefault()}},dl=class{constructor(e){this.workspace=e,this.id="zoomControls",this.zoomResetControl=this.zoomOutControl=this.zoomInControl=null,this.HEIGHT=this.WIDTH=32,this.SMALL_SPACING=2,this.LARGE_SPACING=11,this.MARGIN_HORIZONTAL=this.MARGIN_VERTICAL=20,this.svgGroup=null,this.top=this.left=0,this.initialized=!1}createDom(){return this.svgGroup=I(ea.G,{}),this.zoomOutControl=new ul(this.workspace,this.svgGroup),this.zoomInControl=new hl(this.workspace,this.svgGroup),this.workspace.isMovable()&&(this.zoomResetControl=new cl(this.workspace,this.svgGroup)),this.svgGroup}init(){this.workspace.getComponentManager().addComponent({component:this,weight:Sr.ComponentWeight.ZOOM_CONTROLS_WEIGHT,capabilities:[Sr.Capability.POSITIONABLE]}),this.initialized=!0}dispose(){var e,t,i;this.workspace.getComponentManager().removeComponent("zoomControls"),this.svgGroup&&S(this.svgGroup),null==(e=this.zoomInControl)||e.dispose(),null==(t=this.zoomOutControl)||t.dispose(),null==(i=this.zoomResetControl)||i.dispose()}getBoundingRectangle(){var e=this.SMALL_SPACING+2*this.HEIGHT;return this.zoomResetControl&&(e+=this.LARGE_SPACING+this.HEIGHT),new xa(this.top,this.top+e,this.left,this.left+this.WIDTH)}position(e,t){if(this.initialized){var i,n=We(this.workspace,e),o=this.SMALL_SPACING+2*this.HEIGHT;if(this.zoomResetControl&&(o+=this.LARGE_SPACING+this.HEIGHT),e=Ge(n,new Fa(this.WIDTH,o),this.MARGIN_HORIZONTAL,this.MARGIN_VERTICAL,e,this.workspace),n=n.vertical,t=qe(e,this.MARGIN_VERTICAL,n===Qa.TOP?il.DOWN:il.UP,t),n===Qa.TOP){var s,r=this.SMALL_SPACING+this.HEIGHT;null==(s=this.zoomInControl)||s.getGroup().setAttribute("transform","translate(0, "+r+")"),this.zoomResetControl&&(r=r+this.LARGE_SPACING+this.HEIGHT,this.zoomResetControl.getGroup().setAttribute("transform","translate(0, "+r+")"))}else{let e;s=this.zoomResetControl?this.LARGE_SPACING+this.HEIGHT:0,null==(e=this.zoomInControl)||e.getGroup().setAttribute("transform","translate(0, "+s+")"),s=s+this.SMALL_SPACING+this.HEIGHT,null==(r=this.zoomOutControl)||r.getGroup().setAttribute("transform","translate(0, "+s+")")}this.top=t.top,this.left=t.left,null==(i=this.svgGroup)||i.setAttribute("transform","translate("+this.left+","+this.top+")")}}};g("\n.blocklyZoom>image, .blocklyZoom>svg>image {\n opacity: .4;\n}\n\n.blocklyZoom>image:hover, .blocklyZoom>svg>image:hover, .blocklyZoom:focus>image {\n opacity: .8;\n}\n\n.blocklyZoom>image:active, .blocklyZoom>svg>image:active {\n opacity: 1;\n}\n");var pl={};pl.register=$e,pl.unregister=function(e){ie(ya.SERIALIZER,e)};var gl=class{constructor(){this.priority=25}save(e){var t=[];for(let i of e.getTopComments())(e=je(i,{addCoordinates:!0,saveIds:!0}))&&t.push(e);return t.length?t:null}load(e,t){for(let i of e)ze(i,t,{recordUndo:Zs.Qc})}clear(e){for(let t of e.getTopComments())t.dispose()}};$e("workspaceComments",new gl);var El={};El.WorkspaceCommentSerializer=gl,El.append=ze,El.save=je;var Tl={};Tl.register=Xe,Tl.unregister=function(e){ie(ya.PASTER,e)};var _l=class{paste(e,t,i){e=e.commentState,i&&(e.x=i.x,e.y=i.y),Zs.Ub++;try{var n=ze(e,t);Ye(n)}finally{Zs.Ub--}return n?(Ee()&&ue(new(_e(Fr.COMMENT_CREATE))(n)),Zs.t().focusNode(n),n):null}};_l.TYPE="workspace-comment",Xe(_l.TYPE,new _l),Zs.Og={dragRadius:5,flyoutDragRadius:10,snapRadius:28,connectingSnapRadius:28,currentConnectionPreference:8,bumpDelay:250};var fl,ml=class{constructor(e,t,i){this.content=e,this.opt_value=t,this.ariaLabel=i,this.enabled=!0,this.element=null,this.rightToLeft=!1,this.roleName=null,this.highlight=this.checked=this.checkable=!1,this.actionHandler=null,this.id=le()}createDom(){var e=document.createElement("div");e.id=this.getId(),this.element=e,e.className="blocklyMenuItem "+(this.enabled?"":"blocklyMenuItemDisabled ")+(this.checked?"blocklyMenuItemSelected ":"")+(this.highlight?"blocklyMenuItemHighlight ":"")+(this.rightToLeft?"blocklyMenuItemRtl ":"");var t=document.createElement("div");f(e,$r.LABEL,this.getAriaLabel()),_(t,Hr.NONE),t.className="blocklyMenuItemContent";var i=this.content;return"string"==typeof this.content&&(i=document.createTextNode(this.content)),t.appendChild(i),e.appendChild(t),this.checkable&&this.toggleHasCheckbox(!0),this.roleName&&_(e,this.roleName),f(e,$r.SELECTED,this.checkable&&this.checked||!1),f(e,$r.DISABLED,!this.enabled),e}getAriaLabel(){return this.ariaLabel||("string"==typeof this.content?this.content:this.content.textContent)}dispose(){this.element=null}getElement(){return this.element}getId(){return this.id}getValue(){var e;return null!=(e=this.opt_value)?e:null}setRightToLeft(e){var t;this.rightToLeft=e,null==(t=this.getElement())||t.classList.toggle("blocklyMenuItemRtl",this.rightToLeft)}setRole(e){this.roleName=e}setCheckable(e){(this.checkable=e)||this.setChecked(!1),this.toggleHasCheckbox(e)}setChecked(e){e&&!this.checkable||(this.checked=e,(e=this.getElement())&&(e.classList.toggle("blocklyMenuItemSelected",this.checked),f(e,$r.SELECTED,this.checked)))}setHighlighted(e){if(this.highlight=e,this.isEnabled()){let e;null==(e=this.getElement())||e.classList.toggle("blocklyMenuItemHighlight",this.highlight)}}isEnabled(){return this.enabled}setEnabled(e){this.enabled=e,(e=this.getElement())&&(e.classList.toggle("blocklyMenuItemDisabled",!this.enabled),f(e,$r.DISABLED,!this.enabled))}performAction(e){this.isEnabled()&&this.actionHandler&&this.actionHandler(this,e)}onAction(e,t){this.actionHandler=e.bind(t)}toggleHasCheckbox(e){if(e){let n;var t,i;null!=(n=this.getElement())&&n.querySelector(".blocklyMenuItemContent .blocklyMenuItemCheckbox")||(e=document.createElement("div"),f(e,$r.HIDDEN,!0),e.className="blocklyMenuItemCheckbox ",null==(t=this.getElement())||null==(i=t.querySelector(".blocklyMenuItemContent"))||i.prepend(e))}else{let e,t;null==(e=this.getElement())||null==(t=e.querySelector(".blocklyMenuItemContent .blocklyMenuItemCheckbox"))||t.remove()}}},bl=class{constructor(){this.menuItems=[],this.roleName=this.element=this.onKeyDownHandler=this.pointerLeaveHandler=this.pointerEnterHandler=this.clickHandler=this.pointerMoveHandler=this.highlightedItem=this.openingCoords=null,this.id=le()}addChild(e){this.menuItems.push(e)}render(e){var t=document.createElement("div");t.className="blocklyMenu",t.tabIndex=0,t.id=this.getId(),this.roleName&&_(t,this.roleName),this.element=t;for(let e,i=0;e=this.menuItems[i];i++)t.appendChild(e.createDom());return this.pointerMoveHandler=r(t,"pointermove",this,this.handlePointerMove,!0),this.clickHandler=r(t,"pointerup",this,this.handleClick,!0),this.pointerEnterHandler=r(t,"pointerenter",this,this.handlePointerEnter,!0),this.pointerLeaveHandler=r(t,"pointerleave",this,this.handlePointerLeave,!0),this.onKeyDownHandler=r(t,"keydown",this,this.handleKeyEvent),e.appendChild(t),t}getElement(){return this.element}focus(){var e=this.getElement();e&&e.focus({preventScroll:!0})}blur(){var e=this.getElement();e&&e.blur()}setRole(e){this.roleName=e}dispose(){this.pointerMoveHandler&&(l(this.pointerMoveHandler),this.pointerMoveHandler=null),this.clickHandler&&(l(this.clickHandler),this.clickHandler=null),this.pointerEnterHandler&&(l(this.pointerEnterHandler),this.pointerEnterHandler=null),this.pointerLeaveHandler&&(l(this.pointerLeaveHandler),this.pointerLeaveHandler=null),this.onKeyDownHandler&&(l(this.onKeyDownHandler),this.onKeyDownHandler=null);for(let e,t=0;e=this.menuItems[t];t++)e.dispose();this.element=null}getMenuItem(e){for(var t=this.getElement();e&&e!==t;){if(e.classList.contains("blocklyMenuItem")){let t=this.getMenuItems();for(let i,n=0;i=t[n];n++)if(i.getElement()===e)return i}e=e.parentElement}return null}setHighlighted(e){var t=this.highlightedItem;if(t&&(t.setHighlighted(!1),this.highlightedItem=null),e){e.setHighlighted(!0),this.highlightedItem=e,t=this.getElement();let i=e.getElement();t&&i&&(ye(i,t),f(t,$r.ACTIVEDESCENDANT,e.getId()))}}highlightNext(){var e=this.highlightedItem?this.getMenuItems().indexOf(this.highlightedItem):-1;this.highlightHelper(e,1)}highlightPrevious(){var e=this.highlightedItem?this.getMenuItems().indexOf(this.highlightedItem):-1;this.highlightHelper(e<0?this.menuItems.length:e,-1)}highlightFirst(){this.highlightHelper(-1,1)}highlightLast(){this.highlightHelper(this.menuItems.length,-1)}highlightHelper(e,t){e+=t;for(var i,n=this.getMenuItems();i=n[e];){if(i.isEnabled()){this.setHighlighted(i);break}e+=t}}handlePointerMove(e){0!==Math.max(Math.abs(e.movementX),Math.abs(e.movementY))&&(e=this.getMenuItem(e.target))&&(e.isEnabled()?this.highlightedItem!==e&&this.setHighlighted(e):this.setHighlighted(null))}handleClick(e){var t=this.openingCoords;if(this.openingCoords=null,t&&"number"==typeof e.clientX){let i=new Da(e.clientX,e.clientY);if(Da.distance(t,i)<1)return}(t=this.getMenuItem(e.target))&&t.performAction(e)}handlePointerEnter(){this.focus()}handlePointerLeave(){this.getElement()&&this.setHighlighted(null)}handleKeyEvent(e){if(this.menuItems.length&&!(e.shiftKey||e.ctrlKey||e.metaKey||e.altKey)){var t=this.highlightedItem;switch(e.key){case"Enter":case" ":t&&t.performAction(e);break;case"ArrowUp":this.highlightPrevious();break;case"ArrowDown":this.highlightNext();break;case"PageUp":case"Home":this.highlightFirst();break;case"PageDown":case"End":this.highlightLast();break;default:return}e.preventDefault(),e.stopPropagation()}}getSize(){var e=this.getElement(),t=me(e);return t.height=e.scrollHeight,t}getMenuItems(){return this.menuItems.filter((e=>e instanceof ml))}getId(){return this.id}},Cl=class{constructor(){this.element=null}createDom(){return this.element=document.createElement("hr"),this.element.className="blocklyMenuSeparator",_(this.element,Hr.SEPARATOR),this.element}dispose(){var e;null==(e=this.element)||e.remove(),this.element=null}};(fl=Zs.je||(Zs.je={}))[fl.VALUE=1]="VALUE",fl[fl.STATEMENT=3]="STATEMENT",fl[fl.DUMMY=5]="DUMMY",fl[fl.CUSTOM=6]="CUSTOM",fl[fl.END_ROW=7]="END_ROW";var vl=new Set,Il=new WeakSet,Nl=new WeakMap,yl=null,Al=null,kl=0,Sl={};Sl.finishQueuedRenders=Ze,Sl.queueRender=Qe,Sl.triggerQueuedRenders=et;var Ol=class{static show(e,t){if(t.oncePerSession&&t.id){if(this.shownIds.has(t.id))return;this.shownIds.add(t.id)}this.hide(e);var i=this.createDom(e,t);requestAnimationFrame((()=>{i.style.bottom="2rem"}))}static createDom(e,t){var{message:i,duration:n=5,assertiveness:o=Pr.POLITE}=t,s=document.createElement("div");e.getInjectionDiv().appendChild(s),s.dataset.toastId=t.id,s.className="blocklyToast",(t=s.appendChild(document.createElement("div"))).className="blocklyToastMessage",t.innerText=i,(t=s.appendChild(document.createElement("button"))).className="blocklyToastCloseButton",f(t,$r.LABEL,Zs.C.CLOSE);var r,a=I(ea.SVG,{width:24,height:24,viewBox:"0 0 24 24",fill:"none"},t);return f(a,$r.HIDDEN,!0),I(ea.RECT,{x:19.7782,y:2.80762,width:2,height:24,transform:"rotate(45, 19.7782, 2.80762)",fill:"black"},a),I(ea.RECT,{x:2.80762,y:4.22183,width:2,height:24,transform:"rotate(-45, 2.80762, 4.22183)",fill:"black"},a),t.addEventListener("click",(()=>{var t=Zs.t(),i=t.getPreviouslyFocusedNode();s.remove(),null!=i&&i.canBeFocused()?t.focusNode(i):t.focusTree(e)})),t=()=>{r=setTimeout((()=>s.remove()),1e3*n)},a=()=>clearTimeout(r),s.addEventListener("focusin",a),s.addEventListener("focusout",t),s.addEventListener("mouseenter",a),s.addEventListener("mousemove",a),s.addEventListener("mouseleave",t),t(),v(i,{assertiveness:o,role:Hr.STATUS}),s}static hide(e,t){(e=e.getInjectionDiv().querySelector(".blocklyToast"))instanceof HTMLElement&&(!t||t===e.dataset.toastId)&&e.remove()}};Ol.shownIds=new Set,g("\n.blocklyToast {\n font-size: 1.2rem;\n position: absolute;\n bottom: -10rem;\n right: 2rem;\n padding: 1rem;\n color: black;\n background-color: white;\n border: 2px solid black;\n border-radius: 0.4rem;\n z-index: 999;\n display: flex;\n align-items: center;\n gap: 0.8rem;\n line-height: 1.5;\n transition: bottom 0.3s ease-out;\n}\n\n.blocklyToast .blocklyToastMessage {\n max-width: 18rem;\n}\n\n.blocklyToast .blocklyToastCloseButton {\n margin: 0;\n padding: 0.2rem;\n background-color: transparent;\n color: black;\n border: none;\n cursor: pointer;\n}\n");var Rl,wl=Rl||(Rl={});wl[wl.ALERT=1]="ALERT",wl[wl.CONFIRM=2]="CONFIRM",wl[wl.PROMPT=3]="PROMPT";var Ll=0,Dl=rt,xl=at,Fl=lt,Ml=Ol.show.bind(Ol),Pl=Ml,Bl={};Bl.alert=ht,Bl.confirm=ut,Bl.prompt=ct,Bl.setAlert=function(e=rt){Dl=e},Bl.setConfirm=function(e=at){xl=e},Bl.setPrompt=function(e=lt){Fl=e},Bl.setToast=function(e=Ml){Pl=e},Bl.toast=function(e,t){Pl(e,t)};var Ul=class{constructor(){this.workspaceId=void 0,this.isUiEvent=!1,this.type="",this.group=Zs.gd,this.recordUndo=Zs.Qc}toJson(){return{type:this.type,group:this.group}}static fromJson(e,t,i){return i.isBlank=!1,i.group=e.group||"",i.workspaceId=t.id,i}isNull(){return!1}run(){}getEventWorkspace_(){var e;if(this.workspaceId&&(e=V(this.workspaceId)),!e)throw Error("Workspace is null. Event must have been generated from real Blockly events.");return e}},Vl=class extends Ul{constructor(e){super(),this.isBlank=!0,this.isBlank=!e,e&&(this.blockId=e.id,this.workspaceId=e.workspace.id)}toJson(){var e=super.toJson();if(!this.blockId)throw Error("The block ID is undefined. Either pass a block to the constructor, or call fromJson");return e.blockId=this.blockId,e}static fromJson(e,t,i){return(t=Ul.fromJson(e,t,null!=i?i:new Vl)).blockId=e.blockId,t}},Hl=class{constructor(e){this.name=e}toString(){return this.name}equals(e){return this.name===e.toString()}};Hl.MUTATOR=new Hl("mutator"),Hl.WARNING=new Hl("warning"),Hl.COMMENT=new Hl("comment");var Gl=class extends Vl{constructor(e,t,i,n,o){super(e),this.type=Fr.BLOCK_CHANGE,e&&(this.element=t,this.name=i||void 0,this.oldValue=n,this.newValue=o)}toJson(){var e=super.toJson();if(!this.element)throw Error("The changed element is undefined. Either pass an element to the constructor, or call fromJson");return e.element=this.element,e.name=this.name,e.oldValue=this.oldValue,e.newValue=this.newValue,this.disabledReason&&(e.disabledReason=this.disabledReason),e}static fromJson(e,t,i){return(t=Vl.fromJson(e,t,null!=i?i:new Gl)).element=e.element,t.name=e.name,t.oldValue=e.oldValue,t.newValue=e.newValue,void 0!==e.disabledReason&&(t.disabledReason=e.disabledReason),t}setDisabledReason(e){if("disabled"!==this.element)throw Error('Cannot set the disabled reason for a BlockChange event if the element is not "disabled".');this.disabledReason=e}isNull(){return this.oldValue===this.newValue}run(e){var t=this.getEventWorkspace_();if(!this.blockId)throw Error("The block ID is undefined. Either pass a block to the constructor, or call fromJson");if(!(t=t.getBlockById(this.blockId)))throw Error("The associated block is undefined. Either pass a block to the constructor, or call fromJson");var i=t.getIcon(Hl.MUTATOR);switch(i&&pt(i)&&i.bubbleIsVisible()&&i.setBubbleVisible(!1),e=e?this.newValue:this.oldValue,this.element){case"field":(t=t.getField(this.name))?t.setValue(e):console.warn("Can't set non-existent field: "+this.name);break;case"comment":t.setCommentText(null!=e?e:null);break;case"collapsed":t.setCollapsed(!!e);break;case"disabled":var n;t.setDisabledReason(!!e,null!=(n=this.disabledReason)?n:"MANUALLY_DISABLED");break;case"inline":t.setInputsInline(!!e);break;case"mutation":n=Gl.getExtraBlockState_(t),t.loadExtraState?t.loadExtraState(JSON.parse(e||"{}")):t.domToMutation&&t.domToMutation(Zs.vc(e||"<mutation/>")),ue(new Gl(t,"mutation",null,n,e));break;default:console.warn("Unknown change type: "+this.element)}}static getExtraBlockState_(e){return e.saveExtraState?(e=e.saveExtraState(!0))?JSON.stringify(e):"":e.mutationToDom&&(e=e.mutationToDom())?Nn(e):""}};te(ya.EVENT,Fr.BLOCK_CHANGE,Gl);var Wl=class extends Vl{constructor(e){super(e),this.type=Fr.BLOCK_CREATE,e&&(e.isShadow()&&(this.recordUndo=!1),this.ids=Te(e),this.json=Dt(e,{addCoordinates:!0}))}toJson(){var e=super.toJson();if(!this.ids)throw Error("The block IDs are undefined. Either pass a block to the constructor, or call fromJson");if(!this.json)throw Error("The block JSON is undefined. Either pass a block to the constructor, or call fromJson");return e.ids=this.ids,e.json=this.json,this.recordUndo||(e.recordUndo=this.recordUndo),e}static fromJson(e,t,i){return(t=Vl.fromJson(e,t,null!=i?i:new Wl)).ids=e.ids,t.json=e.json,void 0!==e.recordUndo&&(t.recordUndo=e.recordUndo),t}run(e){var t=this.getEventWorkspace_();if(!this.json)throw Error("The block JSON is undefined. Either pass a block to the constructor, or call fromJson");if(!this.ids)throw Error("The block IDs are undefined. Either pass a block to the constructor, or call fromJson");if(!gt(t,this.ids))if(e)Ft(this.json,t);else for(e=0;e<this.ids.length;e++){let i=this.ids[e],n=t.getBlockById(i);n?n.dispose(!1):i===this.blockId&&console.warn("Can't uncreate non-existent block: "+i)}}};te(ya.EVENT,Fr.BLOCK_CREATE,Wl);var ql=class extends Vl{constructor(e){if(super(e),this.type=Fr.BLOCK_DELETE,e){if(e.getParent())throw Error("Connected blocks cannot be deleted.");e.isShadow()&&(this.recordUndo=!1),this.ids=Te(e),this.wasShadow=e.isShadow(),this.oldJson=Dt(e,{addCoordinates:!0})}}toJson(){var e=super.toJson();if(!this.ids)throw Error("The block IDs are undefined. Either pass a block to the constructor, or call fromJson");if(void 0===this.wasShadow)throw Error("Whether the block was a shadow is undefined. Either pass a block to the constructor, or call fromJson");if(!this.oldJson)throw Error("The old block JSON is undefined. Either pass a block to the constructor, or call fromJson");return e.ids=this.ids,e.wasShadow=this.wasShadow,e.oldJson=this.oldJson,this.recordUndo||(e.recordUndo=this.recordUndo),e}static fromJson(e,t,i){return(t=Vl.fromJson(e,t,null!=i?i:new ql)).ids=e.ids,t.wasShadow=e.wasShadow,t.oldJson=e.oldJson,void 0!==e.recordUndo&&(t.recordUndo=e.recordUndo),t}run(e){var t=this.getEventWorkspace_();if(!this.ids)throw Error("The block IDs are undefined. Either pass a block to the constructor, or call fromJson");if(!this.oldJson)throw Error("The old block JSON is undefined. Either pass a block to the constructor, or call fromJson");if(e)for(e=0;e<this.ids.length;e++){let i=this.ids[e],n=t.getBlockById(i);n?n.dispose(!1):i===this.blockId&&console.warn("Can't delete non-existent block: "+i)}else Ft(this.oldJson,t)}};te(ya.EVENT,Fr.BLOCK_DELETE,ql);var $l=class extends Ul{constructor(e){super(),this.isBlank=!0,this.recordUndo=!1,this.isUiEvent=!0,this.isBlank=void 0===e,this.workspaceId=e||""}},jl=class extends $l{constructor(e,t,i){super(e?e.workspace.id:void 0),this.type=Fr.BLOCK_DRAG,e&&(this.blockId=e.id,this.isStart=t,this.blocks=i)}toJson(){var e=super.toJson();if(void 0===this.isStart)throw Error("Whether this event is the start of a drag is undefined. Either pass the value to the constructor, or call fromJson");if(void 0===this.blockId)throw Error("The block ID is undefined. Either pass a block to the constructor, or call fromJson");return e.isStart=this.isStart,e.blockId=this.blockId,e.blocks=this.blocks,e}static fromJson(e,t,i){return(t=$l.fromJson(e,t,null!=i?i:new jl)).isStart=e.isStart,t.blockId=e.blockId,t.blocks=e.blocks,t}};te(ya.EVENT,Fr.BLOCK_DRAG,jl);var zl=class extends Vl{constructor(e,t,i,n){super(e),this.type=Fr.BLOCK_FIELD_INTERMEDIATE_CHANGE,this.recordUndo=!1,e&&(this.name=t,this.oldValue=i,this.newValue=n)}toJson(){var e=super.toJson();if(!this.name)throw Error("The changed field name is undefined. Either pass a name to the constructor, or call fromJson.");return e.name=this.name,e.oldValue=this.oldValue,e.newValue=this.newValue,e}static fromJson(e,t,i){return(t=Vl.fromJson(e,t,null!=i?i:new zl)).name=e.name,t.oldValue=e.oldValue,t.newValue=e.newValue,t}isNull(){return this.oldValue===this.newValue}run(e){var t=this.getEventWorkspace_();if(!this.blockId)throw Error("The block ID is undefined. Either pass a block to the constructor, or call fromJson");if(!(t=t.getBlockById(this.blockId)))throw Error("The associated block is undefined. Either pass a block to the constructor, or call fromJson");e=e?this.newValue:this.oldValue,(t=t.getField(this.name))?t.setValue(e):console.warn("Can't set non-existent field: "+this.name)}};te(ya.EVENT,Fr.BLOCK_FIELD_INTERMEDIATE_CHANGE,zl);var Xl,Yl=Xl||(Xl={});Yl[Yl.INPUT_VALUE=1]="INPUT_VALUE",Yl[Yl.OUTPUT_VALUE=2]="OUTPUT_VALUE",Yl[Yl.NEXT_STATEMENT=3]="NEXT_STATEMENT",Yl[Yl.PREVIOUS_STATEMENT=4]="PREVIOUS_STATEMENT";var Kl=class extends Vl{constructor(e){super(e),this.type=Fr.BLOCK_MOVE,e&&(e.isShadow()&&(this.recordUndo=!1),e=this.currentLocation(),this.oldParentId=e.parentId,this.oldInputName=e.inputName,this.oldCoordinate=e.coordinate)}toJson(){var e=super.toJson();return e.oldParentId=this.oldParentId,e.oldInputName=this.oldInputName,this.oldCoordinate&&(e.oldCoordinate=`${Math.round(this.oldCoordinate.x)}, ${Math.round(this.oldCoordinate.y)}`),e.newParentId=this.newParentId,e.newInputName=this.newInputName,this.newCoordinate&&(e.newCoordinate=`${Math.round(this.newCoordinate.x)}, ${Math.round(this.newCoordinate.y)}`),this.reason&&(e.reason=this.reason),this.recordUndo||(e.recordUndo=this.recordUndo),e}static fromJson(e,t,i){return(t=Vl.fromJson(e,t,null!=i?i:new Kl)).oldParentId=e.oldParentId,t.oldInputName=e.oldInputName,e.oldCoordinate&&(i=e.oldCoordinate.split(","),t.oldCoordinate=new Da(Number(i[0]),Number(i[1]))),t.newParentId=e.newParentId,t.newInputName=e.newInputName,e.newCoordinate&&(i=e.newCoordinate.split(","),t.newCoordinate=new Da(Number(i[0]),Number(i[1]))),void 0!==e.reason&&(t.reason=e.reason),void 0!==e.recordUndo&&(t.recordUndo=e.recordUndo),t}recordNew(){var e=this.currentLocation();this.newParentId=e.parentId,this.newInputName=e.inputName,this.newCoordinate=e.coordinate}setReason(e){this.reason=e}currentLocation(){var e=this.getEventWorkspace_();if(!this.blockId)throw Error("The block ID is undefined. Either pass a block to the constructor, or call fromJson");var t=e.getBlockById(this.blockId);if(!t)throw Error("The block associated with the block move event could not be found");e={};var i=t.getParent();return i?(e.parentId=i.id,(t=i.getInputWithBlock(t))&&(e.inputName=t.name)):e.coordinate=t.getRelativeToSurfaceXY(),e}isNull(){return this.oldParentId===this.newParentId&&this.oldInputName===this.newInputName&&Da.equals(this.oldCoordinate,this.newCoordinate)}run(e){var t=this.getEventWorkspace_();if(!this.blockId)throw Error("The block ID is undefined. Either pass a block to the constructor, or call fromJson");var i=t.getBlockById(this.blockId);if(i){var n=e?this.newParentId:this.oldParentId,o=e?this.newInputName:this.oldInputName;if(e=e?this.newCoordinate:this.oldCoordinate,n){var s=t.getBlockById(n);if(!s)return void console.warn("Can't connect to non-existent block: "+n)}if(i.getParent()&&i.unplug(),e)o=i.getRelativeToSurfaceXY(),i.moveBy(e.x-o.x,e.y-o.y,this.reason);else{let e,n;(!(t=i.outputConnection)||i.previousConnection&&i.previousConnection.isConnected())&&(t=i.previousConnection),i=null==(n=t)?void 0:n.type,o?(i=s.getInput(o))&&(e=i.connection):i===Xl.PREVIOUS_STATEMENT&&(e=s.nextConnection),e&&t?t.connect(e):console.warn("Can't connect to non-existent input: "+o)}}else console.warn("Can't move non-existent block: "+this.blockId)}};te(ya.EVENT,Fr.BLOCK_MOVE,Kl);var Jl,Ql=class extends $l{constructor(e,t,i){super(e?e.workspace.id:void 0),this.type=Fr.BUBBLE_OPEN,e&&(this.blockId=e.id,this.isOpen=t,this.bubbleType=i)}toJson(){var e=super.toJson();if(void 0===this.isOpen)throw Error("Whether this event is for opening the bubble is undefined. Either pass the value to the constructor, or call fromJson");if(!this.bubbleType)throw Error("The type of bubble is undefined. Either pass the value to the constructor, or call fromJson");return e.isOpen=this.isOpen,e.bubbleType=this.bubbleType,e.blockId=this.blockId||"",e}static fromJson(e,t,i){return(t=$l.fromJson(e,t,null!=i?i:new Ql)).isOpen=e.isOpen,t.bubbleType=e.bubbleType,t.blockId=e.blockId,t}},Zl=Jl||(Jl={});Zl.MUTATOR="mutator",Zl.COMMENT="comment",Zl.WARNING="warning",te(ya.EVENT,Fr.BUBBLE_OPEN,Ql);var eh,th=class extends $l{constructor(e,t,i){null===(t=e?e.workspace.id:t)&&(t=void 0),super(t),this.type=Fr.CLICK,this.blockId=e?e.id:void 0,this.targetType=i}toJson(){var e=super.toJson();if(!this.targetType)throw Error("The click target type is undefined. Either pass a block to the constructor, or call fromJson");return e.targetType=this.targetType,e.blockId=this.blockId,e}static fromJson(e,t,i){return(t=$l.fromJson(e,t,null!=i?i:new th)).targetType=e.targetType,t.blockId=e.blockId,t}},ih=eh||(eh={});ih.BLOCK="block",ih.WORKSPACE="workspace",ih.ZOOM_CONTROLS="zoom_controls",te(ya.EVENT,Fr.CLICK,th);var nh=class extends Ul{constructor(e){super(),this.isBlank=!0,this.isBlank=!e,e&&(this.commentId=e.id,this.workspaceId=e.workspace.id,this.group=Zs.gd,this.recordUndo=Zs.Qc)}toJson(){var e=super.toJson();if(!this.commentId)throw Error("The comment ID is undefined. Either pass a comment to the constructor, or call fromJson");return e.commentId=this.commentId,e}static fromJson(e,t,i){return(t=Ul.fromJson(e,t,null!=i?i:new nh)).commentId=e.commentId,t}static CommentCreateDeleteHelper(e,t){var i=e.getEventWorkspace_();if(t){if(!e.json)throw Error("Encountered a comment event without proper json");ze(e.json,i)}else{if(!e.commentId)throw Error("The comment ID is undefined. Either pass a comment to the constructor, or call fromJson");(t=i.getCommentById(e.commentId))?t.dispose():console.warn("Can't delete non-existent comment: "+e.commentId)}}},oh=class extends nh{constructor(e,t,i){super(e),this.type=Fr.COMMENT_CHANGE,e&&(this.oldContents_=void 0===t?"":t,this.newContents_=void 0===i?"":i)}toJson(){var e=super.toJson();if(!this.oldContents_)throw Error("The old contents is undefined. Either pass a value to the constructor, or call fromJson");if(!this.newContents_)throw Error("The new contents is undefined. Either pass a value to the constructor, or call fromJson");return e.oldContents=this.oldContents_,e.newContents=this.newContents_,e}static fromJson(e,t,i){return(t=nh.fromJson(e,t,null!=i?i:new oh)).oldContents_=e.oldContents,t.newContents_=e.newContents,t}isNull(){return this.oldContents_===this.newContents_}run(e){var t=this.getEventWorkspace_();if(!this.commentId)throw Error("The comment ID is undefined. Either pass a comment to the constructor, or call fromJson");if(t=t.getCommentById(this.commentId)){var i=e?this.newContents_:this.oldContents_;if(void 0===i){if(e)throw Error("The new contents is undefined. Either pass a value to the constructor, or call fromJson");throw Error("The old contents is undefined. Either pass a value to the constructor, or call fromJson")}t.setText(i)}else console.warn("Can't change non-existent comment: "+this.commentId)}};te(ya.EVENT,Fr.COMMENT_CHANGE,oh);var sh=class extends nh{constructor(e,t){super(e),this.newCollapsed=t,this.type=Fr.COMMENT_COLLAPSE}toJson(){var e=super.toJson();if(void 0===this.newCollapsed)throw Error("The new collapse value undefined. Either call recordNew, or call fromJson");return e.newCollapsed=this.newCollapsed,e}static fromJson(e,t,i){return(t=nh.fromJson(e,t,null!=i?i:new sh)).newCollapsed=e.newCollapsed,t}run(e){var t=this.getEventWorkspace_();if(!this.commentId)throw Error("The comment ID is undefined. Either pass a comment to the constructor, or call fromJson");(t=t.getCommentById(this.commentId))?t.setCollapsed(e?!!this.newCollapsed:!this.newCollapsed):console.warn("Can't collapse or uncollapse non-existent comment: "+this.commentId)}};te(ya.EVENT,Fr.COMMENT_COLLAPSE,sh);var rh=class extends nh{constructor(e){super(e),this.type=Fr.COMMENT_CREATE,e&&(this.json=je(e,{addCoordinates:!0}))}toJson(){var e=super.toJson();if(!this.json)throw Error("The comment JSON is undefined. Either pass a block to the constructor, or call fromJson");return e.json=this.json,e}static fromJson(e,t,i){return(t=nh.fromJson(e,t,null!=i?i:new rh)).json=e.json,t}run(e){nh.CommentCreateDeleteHelper(this,e)}};te(ya.EVENT,Fr.COMMENT_CREATE,rh);var ah=class extends nh{constructor(e){super(e),this.type=Fr.COMMENT_DELETE,e&&(this.json=je(e,{addCoordinates:!0}))}run(e){nh.CommentCreateDeleteHelper(this,!e)}toJson(){var e=super.toJson();if(!this.json)throw Error("The comment JSON is undefined. Either pass a block to the constructor, or call fromJson");return e.json=this.json,e}static fromJson(e,t,i){return(t=nh.fromJson(e,t,null!=i?i:new ah)).json=e.json,t}};te(ya.EVENT,Fr.COMMENT_DELETE,ah);var lh=class extends $l{constructor(e,t){super(e?e.workspace.id:void 0),this.type=Fr.COMMENT_DRAG,e&&(this.commentId=e.id,this.isStart=t)}toJson(){var e=super.toJson();if(void 0===this.isStart)throw Error("Whether this event is the start of a drag is undefined. Either pass the value to the constructor, or call fromJson");if(void 0===this.commentId)throw Error("The comment ID is undefined. Either pass a comment to the constructor, or call fromJson");return e.isStart=this.isStart,e.commentId=this.commentId,e}static fromJson(e,t,i){return(t=$l.fromJson(e,t,null!=i?i:new lh)).isStart=e.isStart,t.commentId=e.commentId,t}};te(ya.EVENT,Fr.COMMENT_DRAG,lh);var hh=class extends nh{constructor(e){super(e),this.type=Fr.COMMENT_MOVE,e&&(this.comment_=e,this.oldCoordinate_=e.getRelativeToSurfaceXY())}recordNew(){if(this.newCoordinate_)throw Error("Tried to record the new position of a comment on the same event twice.");if(!this.comment_)throw Error("The comment is undefined. Pass a comment to the constructor if you want to use the record functionality");this.newCoordinate_=this.comment_.getRelativeToSurfaceXY()}setReason(e){this.reason=e}setOldCoordinate(e){this.oldCoordinate_=e}toJson(){var e=super.toJson();if(!this.oldCoordinate_)throw Error("The old comment position is undefined. Either pass a comment to the constructor, or call fromJson");if(!this.newCoordinate_)throw Error("The new comment position is undefined. Either call recordNew, or call fromJson");return e.oldCoordinate=`${Math.round(this.oldCoordinate_.x)}, ${Math.round(this.oldCoordinate_.y)}`,e.newCoordinate=Math.round(this.newCoordinate_.x)+","+Math.round(this.newCoordinate_.y),e}static fromJson(e,t,i){return t=nh.fromJson(e,t,null!=i?i:new hh),i=e.oldCoordinate.split(","),t.oldCoordinate_=new Da(Number(i[0]),Number(i[1])),i=e.newCoordinate.split(","),t.newCoordinate_=new Da(Number(i[0]),Number(i[1])),t}isNull(){return Da.equals(this.oldCoordinate_,this.newCoordinate_)}run(e){var t=this.getEventWorkspace_();if(!this.commentId)throw Error("The comment ID is undefined. Either pass a comment to the constructor, or call fromJson");if(t=t.getCommentById(this.commentId)){if(!(e=e?this.newCoordinate_:this.oldCoordinate_))throw Error("Either oldCoordinate_ or newCoordinate_ is undefined. Either pass a comment to the constructor and call recordNew, or call fromJson");t.moveTo(e)}else console.warn("Can't move non-existent comment: "+this.commentId)}};te(ya.EVENT,Fr.COMMENT_MOVE,hh);var uh=class extends nh{constructor(e){super(e),this.type=Fr.COMMENT_RESIZE,e&&(this.oldSize=e.getSize())}recordCurrentSizeAsNewSize(){if(this.newSize)throw Error("Tried to record the new size of a comment on the same event twice.");var e=this.getEventWorkspace_();if(!this.commentId)throw Error("The comment ID is undefined. Either pass a comment to the constructor, or call fromJson");if(!(e=e.getCommentById(this.commentId)))throw Error("The comment associated with the comment resize event could not be found");this.newSize=e.getSize()}toJson(){var e=super.toJson();if(!this.oldSize)throw Error("The old comment size is undefined. Either pass a comment to the constructor, or call fromJson");if(!this.newSize)throw Error("The new comment size is undefined. Either call recordCurrentSizeAsNewSize, or call fromJson");return e.oldWidth=Math.round(this.oldSize.width),e.oldHeight=Math.round(this.oldSize.height),e.newWidth=Math.round(this.newSize.width),e.newHeight=Math.round(this.newSize.height),e}static fromJson(e,t,i){return(t=nh.fromJson(e,t,null!=i?i:new uh)).oldSize=new Fa(e.oldWidth,e.oldHeight),t.newSize=new Fa(e.newWidth,e.newHeight),t}isNull(){return Fa.equals(this.oldSize,this.newSize)}run(e){var t=this.getEventWorkspace_();if(!this.commentId)throw Error("The comment ID is undefined. Either pass a comment to the constructor, or call fromJson");if(t=t.getCommentById(this.commentId)){if(!(e=e?this.newSize:this.oldSize))throw Error("Either oldSize or newSize is undefined. Either pass a comment to the constructor and call recordCurrentSizeAsNewSize, or call fromJson");t.setSize(e)}else console.warn("Can't resize non-existent comment: "+this.commentId)}};te(ya.EVENT,Fr.COMMENT_RESIZE,uh);var ch=class extends $l{constructor(e,t,i){super(i),this.type=Fr.SELECTED,this.oldElementId=null!=e?e:void 0,this.newElementId=null!=t?t:void 0}toJson(){var e=super.toJson();return e.oldElementId=this.oldElementId,e.newElementId=this.newElementId,e}static fromJson(e,t,i){return(t=$l.fromJson(e,t,null!=i?i:new ch)).oldElementId=e.oldElementId,t.newElementId=e.newElementId,t}};te(ya.EVENT,Fr.SELECTED,ch);var dh=class extends $l{constructor(e,t){super(t),this.type=Fr.THEME_CHANGE,this.themeName=e}toJson(){var e=super.toJson();if(!this.themeName)throw Error("The theme name is undefined. Either pass a theme name to the constructor, or call fromJson");return e.themeName=this.themeName,e}static fromJson(e,t,i){return(t=$l.fromJson(e,t,null!=i?i:new dh)).themeName=e.themeName,t}};te(ya.EVENT,Fr.THEME_CHANGE,dh);var ph=class extends $l{constructor(e,t,i){super(i),this.type=Fr.TOOLBOX_ITEM_SELECT,this.oldItem=null!=e?e:void 0,this.newItem=null!=t?t:void 0}toJson(){var e=super.toJson();return e.oldItem=this.oldItem,e.newItem=this.newItem,e}static fromJson(e,t,i){return(t=$l.fromJson(e,t,null!=i?i:new ph)).oldItem=e.oldItem,t.newItem=e.newItem,t}};te(ya.EVENT,Fr.TOOLBOX_ITEM_SELECT,ph);var gh=class extends $l{constructor(e,t){super(t),this.type=Fr.TRASHCAN_OPEN,this.isOpen=e}toJson(){var e=super.toJson();if(void 0===this.isOpen)throw Error("Whether this is already open or not is undefined. Either pass a value to the constructor, or call fromJson");return e.isOpen=this.isOpen,e}static fromJson(e,t,i){return(t=$l.fromJson(e,t,null!=i?i:new gh)).isOpen=e.isOpen,t}};te(ya.EVENT,Fr.TRASHCAN_OPEN,gh);var Eh=class extends Ul{constructor(e){super(),this.isBlank=!0,this.isBlank=void 0===e,e&&(this.varId=e.getId(),this.workspaceId=e.getWorkspace().id)}toJson(){var e=super.toJson();if(!this.varId)throw Error("The var ID is undefined. Either pass a variable to the constructor, or call fromJson");return e.varId=this.varId,e}static fromJson(e,t,i){return(t=Ul.fromJson(e,t,null!=i?i:new Eh)).varId=e.varId,t}},Th=class extends Eh{constructor(e){super(e),this.type=Fr.VAR_CREATE,e&&(this.varType=e.getType(),this.varName=e.getName())}toJson(){var e=super.toJson();if(void 0===this.varType)throw Error("The var type is undefined. Either pass a variable to the constructor, or call fromJson");if(!this.varName)throw Error("The var name is undefined. Either pass a variable to the constructor, or call fromJson");return e.varType=this.varType,e.varName=this.varName,e}static fromJson(e,t,i){return(t=Eh.fromJson(e,t,null!=i?i:new Th)).varType=e.varType,t.varName=e.varName,t}run(e){var t=this.getEventWorkspace_();if(!this.varId)throw Error("The var ID is undefined. Either pass a variable to the constructor, or call fromJson");if(!this.varName)throw Error("The var name is undefined. Either pass a variable to the constructor, or call fromJson");t=t.getVariableMap(),e?t.createVariable(this.varName,this.varType,this.varId):(e=t.getVariableById(this.varId))&&t.deleteVariable(e)}};te(ya.EVENT,Fr.VAR_CREATE,Th);var _h=class extends Eh{constructor(e){super(e),this.type=Fr.VAR_DELETE,e&&(this.varType=e.getType(),this.varName=e.getName())}toJson(){var e=super.toJson();if(void 0===this.varType)throw Error("The var type is undefined. Either pass a variable to the constructor, or call fromJson");if(!this.varName)throw Error("The var name is undefined. Either pass a variable to the constructor, or call fromJson");return e.varType=this.varType,e.varName=this.varName,e}static fromJson(e,t,i){return(t=Eh.fromJson(e,t,null!=i?i:new _h)).varType=e.varType,t.varName=e.varName,t}run(e){var t=this.getEventWorkspace_();if(!this.varId)throw Error("The var ID is undefined. Either pass a variable to the constructor, or call fromJson");if(!this.varName)throw Error("The var name is undefined. Either pass a variable to the constructor, or call fromJson");t=t.getVariableMap(),e?(e=t.getVariableById(this.varId))&&t.deleteVariable(e):t.createVariable(this.varName,this.varType,this.varId)}};te(ya.EVENT,Fr.VAR_DELETE,_h);var fh=class extends Eh{constructor(e,t){super(e),this.type=Fr.VAR_RENAME,e&&(this.oldName=e.getName(),this.newName=void 0===t?"":t)}toJson(){var e=super.toJson();if(!this.oldName)throw Error("The old var name is undefined. Either pass a variable to the constructor, or call fromJson");if(!this.newName)throw Error("The new var name is undefined. Either pass a value to the constructor, or call fromJson");return e.oldName=this.oldName,e.newName=this.newName,e}static fromJson(e,t,i){return(t=Eh.fromJson(e,t,null!=i?i:new fh)).oldName=e.oldName,t.newName=e.newName,t}run(e){var t=this.getEventWorkspace_();if(!this.varId)throw Error("The var ID is undefined. Either pass a variable to the constructor, or call fromJson");if(!this.oldName)throw Error("The old var name is undefined. Either pass a variable to the constructor, or call fromJson");if(!this.newName)throw Error("The new var name is undefined. Either pass a value to the constructor, or call fromJson");var i=(t=t.getVariableMap()).getVariableById(this.varId);e?i&&t.renameVariable(i,this.newName):i&&t.renameVariable(i,this.oldName)}};te(ya.EVENT,Fr.VAR_RENAME,fh);var mh=class extends Eh{constructor(e,t,i){super(e),this.oldType=t,this.newType=i,this.type=Fr.VAR_TYPE_CHANGE}toJson(){var e=super.toJson();if(!this.oldType||!this.newType)throw Error("The variable's types are undefined. Either pass them to the constructor, or call fromJson");return e.oldType=this.oldType,e.newType=this.newType,e}static fromJson(e,t,i){return(t=Eh.fromJson(e,t,null!=i?i:new mh)).oldType=e.oldType,t.newType=e.newType,t}run(e){var t=this.getEventWorkspace_();if(!this.varId)throw Error("The var ID is undefined. Either pass a variable to the constructor, or call fromJson");if(!this.oldType||!this.newType)throw Error("The variable's types are undefined. Either pass them to the constructor, or call fromJson");var i=t.getVariableMap().getVariableById(this.varId);i&&(e?t.getVariableMap().changeVariableType(i,this.newType):t.getVariableMap().changeVariableType(i,this.oldType))}};te(ya.EVENT,Fr.VAR_TYPE_CHANGE,mh);var bh=class extends $l{constructor(e,t,i,n,o){super(n),this.type=Fr.VIEWPORT_CHANGE,this.viewTop=e,this.viewLeft=t,this.scale=i,this.oldScale=o}toJson(){var e=super.toJson();if(void 0===this.viewTop)throw Error("The view top is undefined. Either pass a value to the constructor, or call fromJson");if(void 0===this.viewLeft)throw Error("The view left is undefined. Either pass a value to the constructor, or call fromJson");if(void 0===this.scale)throw Error("The scale is undefined. Either pass a value to the constructor, or call fromJson");if(void 0===this.oldScale)throw Error("The old scale is undefined. Either pass a value to the constructor, or call fromJson");return e.viewTop=this.viewTop,e.viewLeft=this.viewLeft,e.scale=this.scale,e.oldScale=this.oldScale,e}static fromJson(e,t,i){return(t=$l.fromJson(e,t,null!=i?i:new bh)).viewTop=e.viewTop,t.viewLeft=e.viewLeft,t.scale=e.scale,t.oldScale=e.oldScale,t}};te(ya.EVENT,Fr.VIEWPORT_CHANGE,bh);var Ch,vh,Ih,Nh,yh,Ah,kh,Sh,Oh,Rh,wh,Lh,Dh,xh,Fh,Mh,Ph,Bh,Uh,Vh,Hh,Gh,Wh,qh,$h,jh=class extends Ul{constructor(e){super(),this.isBlank=!0,this.recordUndo=!1,this.type=Fr.FINISHED_LOADING,this.isBlank=!!e,e&&(this.workspaceId=e.id)}};te(ya.EVENT,Fr.FINISHED_LOADING,jh),Zs.Dm=Fr.BLOCK_CHANGE,Zs.Od=Fr.BLOCK_CREATE,Zs.Em=Fr.BLOCK_DELETE,Ch=Fr.BLOCK_DRAG,Zs.Gm=Fr.BLOCK_MOVE,vh=Fr.BLOCK_FIELD_INTERMEDIATE_CHANGE,Ih=Fr.BUBBLE_OPEN,Nh=Fr.BLOCK_CHANGE,yh=Fr.CLICK,Ah=Fr.COMMENT_CHANGE,kh=Fr.COMMENT_CREATE,Sh=Fr.COMMENT_DELETE,Oh=Fr.COMMENT_MOVE,Rh=Fr.COMMENT_RESIZE,wh=Fr.COMMENT_DRAG,Lh=Fr.BLOCK_CREATE,Dh=Fr.BLOCK_DELETE,xh=Fr.FINISHED_LOADING,Fh=Fr.BLOCK_MOVE,Mh=Fr.SELECTED,Ph=Fr.THEME_CHANGE,Bh=Fr.TOOLBOX_ITEM_SELECT,Uh=Fr.TRASHCAN_OPEN,Vh=Fr.UI,Hh=Fr.VAR_CREATE,Gh=Fr.VAR_DELETE,Wh=Fr.VAR_RENAME,qh=Fr.VIEWPORT_CHANGE,($h={}).Abstract=Ul,$h.BLOCK_CHANGE=Zs.Dm,$h.BLOCK_CREATE=Zs.Od,$h.BLOCK_DELETE=Zs.Em,$h.BLOCK_DRAG=Ch,$h.BLOCK_FIELD_INTERMEDIATE_CHANGE=vh,$h.BLOCK_MOVE=Zs.Gm,$h.BUBBLE_OPEN=Ih,$h.BUMP_EVENTS=Br,$h.BlockBase=Vl,$h.BlockChange=Gl,$h.BlockCreate=Wl,$h.BlockDelete=ql,$h.BlockDrag=jl,$h.BlockFieldIntermediateChange=zl,$h.BlockMove=Kl,$h.BubbleOpen=Ql,$h.BubbleType=Jl,$h.CHANGE=Nh,$h.CLICK=yh,$h.COMMENT_CHANGE=Ah,$h.COMMENT_CREATE=kh,$h.COMMENT_DELETE=Sh,$h.COMMENT_DRAG=wh,$h.COMMENT_MOVE=Oh,$h.COMMENT_RESIZE=Rh,$h.CREATE=Lh,$h.Click=th,$h.ClickTarget=eh,$h.CommentBase=nh,$h.CommentChange=oh,$h.CommentCollapse=sh,$h.CommentCreate=rh,$h.CommentDelete=ah,$h.CommentDrag=lh,$h.CommentMove=hh,$h.CommentResize=uh,$h.DELETE=Dh,$h.FINISHED_LOADING=xh,$h.FinishedLoading=jh,$h.MOVE=Fh,$h.SELECTED=Mh,$h.Selected=ch,$h.THEME_CHANGE=Ph,$h.TOOLBOX_ITEM_SELECT=Bh,$h.TRASHCAN_OPEN=Uh,$h.ThemeChange=dh,$h.ToolboxItemSelect=ph,$h.TrashcanOpen=gh,$h.UI=Vh,$h.UiBase=$l,$h.VAR_CREATE=Hh,$h.VAR_DELETE=Gh,$h.VAR_RENAME=Wh,$h.VIEWPORT_CHANGE=qh,$h.VarBase=Eh,$h.VarCreate=Th,$h.VarDelete=_h,$h.VarRename=fh,$h.VarTypeChange=mh,$h.ViewportChange=bh,$h.clearPendingUndo=ge,$h.disable=function(){Zs.Ub++},$h.disableOrphans=function(e){if((e.type===Fr.BLOCK_MOVE||e.type===Fr.BLOCK_CREATE||e.type===Fr.BLOCK_DRAG&&!e.isStart)&&e.workspaceId){var t=V(e.workspaceId);if(!e.blockId)throw Error("Encountered a blockEvent without a proper blockId");if(e=t.getBlockById(e.blockId)){let i=Zs.Qc;try{Zs.Qc=!1;let i=e.getParent();if(i&&!i.hasDisabledReason("ORPHANED_BLOCK")){let t=e.getDescendants(!1);for(let e,i=0;e=t[i];i++)e.setDisabledReason(!1,"ORPHANED_BLOCK")}else if((e.outputConnection||e.previousConnection)&&!t.isDragging())do{e.setDisabledReason(!0,"ORPHANED_BLOCK"),e=e.getNextBlock()}while(e)}finally{Zs.Qc=i}}}},$h.enable=function(){Zs.Ub--},$h.filter=pe,$h.fire=ue,$h.fromJson=function(e,t){var i=_e(e.type);if(!i)throw Error("Unknown event type.");return i.fromJson(e,t)},$h.get=_e,$h.getDescendantIds=Te,$h.getGroup=function(){return Zs.gd},$h.getRecordUndo=function(){return Zs.Qc},$h.isEnabled=Ee,$h.setGroup=Zs.B,$h.setRecordUndo=function(e){Zs.Qc=e};var zh=class{constructor(){this.scopeChangeAudioCuesEnabled=this.isActive=!1,this.activeClassName="blocklyKeyboardNavigation"}setIsActive(e=!0){this.isActive=e,this.updateActiveVisualization()}getIsActive(){return this.isActive}setScopeChangeAudioCuesEnabled(e){this.scopeChangeAudioCuesEnabled=e}getScopeChangeAudioCuesEnabled(){return this.scopeChangeAudioCuesEnabled}updateActiveVisualization(){var e=Ta.getInjectionDiv().parentElement;this.isActive?null==e||e.classList.add(this.activeClassName):null==e||e.classList.remove(this.activeClassName)}},Xh=new zh,Yh=new Intl.Collator(void 0,{sensitivity:"base"}),Kh={generateUniqueNameInternal:function(e){return Ct("i",e.getVariableMap().getAllVariables().map((e=>e.getName())))}},Jh={CATEGORY_NAME:"VARIABLE",TEST_ONLY:Kh,VAR_LETTER_OPTIONS:"ijkmnopqrstuvwxyzabcdefgh"};Jh.allDeveloperVariables=Zs.Cd,Jh.allUsedVarModels=Zs.Bd,Jh.compareByName=wt,Jh.createVariableButtonHandler=vt,Jh.deleteVariable=Zs.$d,Jh.flyoutCategory=_t,Jh.flyoutCategoryBlocks=function(e){var t=[];if((e=e.getVariableMap().getVariablesOfType("")).length>0){var i=e[e.length-1];if(Ur.variables_set){var n=Zs.sc("block");n.setAttribute("type","variables_set"),n.setAttribute("gap",Ur.math_change?"8":"24"),n.appendChild(Ot(i)),t.push(n)}if(Ur.math_change&&((n=Zs.sc("block")).setAttribute("type","math_change"),n.setAttribute("gap",Ur.variables_get?"20":"8"),n.appendChild(Ot(i)),i=Zs.vc('<value name="DELTA"><shadow type="math_number"><field name="NUM">1</field></shadow></value>'),n.appendChild(i),t.push(n)),Ur.variables_get){e.sort(wt);for(let n,o=0;n=e[o];o++)(i=Zs.sc("block")).setAttribute("type","variables_get"),i.setAttribute("gap","8"),i.appendChild(Ot(n)),t.push(i)}}return t},Jh.generateUniqueName=bt,Jh.generateUniqueNameFromOptions=Ct,Jh.generateVariableFieldDom=Ot,Jh.getAddedVariables=Rt,Jh.getOrCreateVariablePackage=Zs.Wd,Jh.getVariable=Zs.Vd,Jh.getVariableUsesById=Lt,Jh.jsonFlyoutCategoryBlocks=mt,Jh.nameUsedWithAnyType=yt,Jh.nameUsedWithConflictingParam=At,Jh.promptName=It,Jh.renameVariable=Zs.Rd;var Qh=class extends Error{},Zh=class extends Qh{constructor(e){super("Expected to find a 'type' property, defining the block type"),this.state=e}},eu=class extends Qh{constructor(e,t,i){super(`The block ${t.toDevString()} is missing a(n) ${e}\nconnection`),this.block=t,this.state=i}},tu=class extends Qh{constructor(e,t,i,n){super(`The block ${i.toDevString()} could not connect its\n${t} to its parent, because: ${e}`),this.childBlock=i,this.childState=n}},iu=class extends Qh{constructor(e){super("Encountered a real block which is defined as a child of a shadow\nblock. It is an invariant of Blockly that shadow blocks only have shadow\nchildren"),this.state=e}},nu=class extends Qh{constructor(e,t,i){super(`Cannot add an icon of type '${e}' to the block ${t.toDevString()}, because there is no icon registered with type '${e}'. Make sure that all of your icons have been registered.`),this.block=t,this.state=i}},ou={};ou.BadConnectionCheck=tu,ou.DeserializationError=Qh,ou.MissingBlockType=Zh,ou.MissingConnection=eu,ou.RealChildOfShadow=iu,ou.UnregisteredIcon=nu;var su=class{constructor(){this.priority=50}save(e){var t=[];for(let i of e.getTopBlocks(!1))(e=Dt(i,{addCoordinates:!0,doFullSerialization:!1}))&&t.push(e);return t.length?{languageVersion:0,blocks:t}:null}load(e,t){e=e.blocks;for(let i of e)Ft(i,t,{recordUndo:Zs.Qc})}clear(e){for(let t of e.getTopBlocks(!1))t.dispose(!1)}};$e("blocks",new su);var ru={};ru.BlockSerializer=su,ru.append=Ft,ru.appendInternal=Mt,ru.save=Dt;var au,lu={Control:Zs.C.CONTROL_KEY,Meta:"⌘",Alt:Ir?"⌥":Zs.C.ALT_KEY},hu=["Meta","Control","Alt","Shift"],uu=au||(au={});uu[uu.UNKNOWN=0]="UNKNOWN",uu[uu.BEFORE=1]="BEFORE",uu[uu.AFTER=2]="AFTER",uu[uu.AROUND=3]="AROUND",uu[uu.INSIDE=4]="INSIDE",uu[uu.TO=5]="TO";var cu={};cu.clamp=ai,cu.toDegrees=function(e){return 180*e/Math.PI},cu.toRadians=ri;var du,pu,gu,Eu=null,Tu=null,_u="",fu="",mu=null,bu=null,Cu=null,vu=null,Iu=null,Nu={getBoundsInfo:function(){var e=Ce(mu),t=me(mu);return{left:e.x,right:e.x+t.width,top:e.y,bottom:e.y+t.height,width:t.width,height:t.height}},getPositionMetrics:function(e,t,i,n){var o=Nu.getBoundsInfo(),s=me(du);return t+s.height<o.bottom?_i(e,t,o,s):n-s.height>o.top?fi(i,n,o,s):t+s.height<document.documentElement.clientHeight?_i(e,t,o,s):n-s.height>document.documentElement.clientTop?fi(i,n,o,s):{initialX:(e=mi(e,o.left,o.right,s.width)).divX,initialY:0,finalX:e.divX,finalY:0,arrowAtTop:null,arrowX:null,arrowY:null,arrowVisible:!1}}},yu={ANIMATION_TIME:.25,ARROW_HORIZONTAL_PADDING:12,ARROW_SIZE:16,BORDER_SIZE:1,PADDING_Y:16,TEST_ONLY:Nu};yu.clearContent=ui,yu.createDom=li,yu.getContentDiv=function(){return pu},yu.getOwner=function(){return bu},yu.getPositionX=mi,yu.hide=Ci,yu.hideIfOwner=bi,yu.hideWithoutAnimation=vi,yu.isVisible=function(){return!!bu},yu.repositionForWindowResize=Ni,yu.setBoundsElement=function(e){mu=e},yu.setColour=ci,yu.show=Ti,yu.showPositionedByBlock=function(e,t,i,n,o=!0){return Ei(pi(t),e,o,i,n)},yu.showPositionedByField=di;var Au={};Au.commonWordPrefix=Ai,Au.commonWordSuffix=ki,Au.isNumber=Zs.zf,Au.shortestStringLength=yi,Au.wrap=Zs.yf;var ku=void 0,Su=!1,Ou=!1,Ru=0,wu=0,Lu=0,Du=0,xu=null,Fu=null,Mu=null,Pu={HOVER_MS:750,LIMIT:50,MARGINS:5,OFFSET_X:0,OFFSET_Y:10,RADIUS_OK:10};Pu.bindMouseEvents=Di,Pu.block=Hi,Pu.createDom=Li,Pu.display=Vi,Pu.dispose=Bi,Pu.getCustomTooltip=function(){return ku},Pu.getDiv=function(){return Mu},Pu.getTooltipOfObject=Ri,Pu.hide=Ui,Pu.isVisible=function(){return Su},Pu.setCustomTooltip=function(e){ku=e},Pu.unbindMouseEvents=xi,Pu.unblock=function(){Ou=!1};var Bu=.45,Uu=.65,Vu={aqua:"#00ffff",black:"#000000",blue:"#0000ff",fuchsia:"#ff00ff",gray:"#808080",green:"#008000",lime:"#00ff00",maroon:"#800000",navy:"#000080",olive:"#808000",purple:"#800080",red:"#ff0000",silver:"#c0c0c0",teal:"#008080",white:"#ffffff",yellow:"#ffff00"},Hu={};Hu.blend=zi,Hu.getHsvSaturation=function(){return Bu},Hu.getHsvValue=function(){return Uu},Hu.hexToRgb=$i,Hu.hsvToHex=ji,Hu.hueToHex=Xi,Hu.names=Vu,Hu.parse=Wi,Hu.rgbToHex=qi,Hu.setHsvSaturation=function(e){Bu=e},Hu.setHsvValue=function(e){Uu=e};var Gu={checkMessageReferences:function(e){var t=!0,i=e.match(/%{BKY_[A-Z]\w*}/gi);if(i)for(let n=0;n<i.length;n++){let o=i[n].toUpperCase();void 0===Zs.C[o.slice(6,-1)]&&(console.warn("No message string for "+i[n]+" in "+e),t=!1)}return t}};Gu.parseBlockColour=Qi,Gu.replaceMessageReferences=Ji,Gu.tokenizeInterpolation=Ki;var Wu=class{get size_(){return this.size}set size_(e){this.size=e}constructor(e,t,i){this.DEFAULT_VALUE=null,this.name=void 0,this.tooltip=this.ariaTypeName=this.validator_=null,this.size=new Fa(0,0),this.constants_=this.mouseDownWrapper=this.textContent_=this.textElement_=this.borderRect_=this.fieldGroup_=null,this.disposed=!1,this.maxDisplayLength=50,this.sourceBlock_=null,this.enabled_=this.visible_=this.isDirty_=!0,this.suffixField=this.prefixField=this.clickTarget_=null,this.EDITABLE=!0,this.SERIALIZABLE=!1,this.id_=null,this.value_="DEFAULT_VALUE"in new.target.prototype?new.target.prototype.DEFAULT_VALUE:this.DEFAULT_VALUE,this.size_=new Fa(0,0),e!==Wu.SKIP_SETUP&&(i&&this.configure_(i),this.setValue(e),t&&this.setValidator(t))}configure_(e){e.tooltip&&this.setTooltip(Ji(e.tooltip)),e.ariaTypeName&&this.setAriaTypeName(e.ariaTypeName)}setSourceBlock(e){if(this.sourceBlock_)throw Error("Field already bound to a block");if(this.sourceBlock_=e,e.id.includes("_field"))throw Error(`Field ID indicator is contained in block ID. This may cause problems with focus: ${e.id}.`)}getConstants(){return!this.constants_&&this.sourceBlock_&&!this.sourceBlock_.isDeadOrDying()&&this.sourceBlock_.workspace.rendered&&(this.constants_=this.sourceBlock_.workspace.getRenderer().getConstants()),this.constants_}getSourceBlock(){return this.sourceBlock_}getAriaTypeName(){return this.ariaTypeName||null}setAriaTypeName(e){this.ariaTypeName=Ji(e)}getAriaValue(){return null==this.getValue()?null:this.getText()}computeAriaLabel(e=!0){e=e?this.getAriaTypeName():null;var t=this.getAriaValue();return null!==t&&""!==t||(t=Zs.C.FIELD_LABEL_EMPTY),e?`${e}: ${t}`:t}init(){if(!this.fieldGroup_){this.fieldGroup_=I(ea.G,{}),this.isVisible()||(this.fieldGroup_.style.display="none");var e=this.sourceBlock_;e.getSvgRoot().appendChild(this.fieldGroup_),this.initView(),this.updateEditable(),this.setTooltip(this.tooltip),this.bindEvents_(),this.initModel(),this.applyColour(),this.isFullBlockField()?this.id_=le():this.id_=`${e.id}_field_${le()}`,this.fieldGroup_.setAttribute("id",this.id_)}}initView(){this.createBorderRect_(),this.createTextElement_(),this.fieldGroup_&&N(this.fieldGroup_,"blocklyField")}initModel(){}isFullBlockField(){return!1}isLabelField(){return!1}createBorderRect_(){this.borderRect_=I(ea.RECT,{rx:this.getConstants().FIELD_BORDER_RECT_RADIUS,ry:this.getConstants().FIELD_BORDER_RECT_RADIUS,x:0,y:0,height:this.size_.height,width:this.size_.width,class:"blocklyFieldRect"},this.fieldGroup_)}createTextElement_(){this.textElement_=I(ea.TEXT,{class:"blocklyText blocklyFieldText","aria-hidden":"true"},this.fieldGroup_),this.getConstants().FIELD_TEXT_BASELINE_CENTER&&this.textElement_.setAttribute("dominant-baseline","central"),this.textContent_=document.createTextNode(""),this.textElement_.appendChild(this.textContent_)}bindEvents_(){var e=this.getClickTarget_();if(!e)throw Error("A click target has not been set.");Di(e),this.mouseDownWrapper=r(e,"pointerdown",this,this.onMouseDown_)}fromXml(e){this.setValue(e.textContent)}toXml(e){return e.textContent=this.getValue(),e}saveState(){var e=this.saveLegacyState(Wu);return null!==e?e:this.getValue()}loadState(e){this.loadLegacyState(Wu,e)||this.setValue(e)}saveLegacyState(e){return e.prototype.saveState===this.saveState&&e.prototype.toXml!==this.toXml?((e=Zs.sc("field")).setAttribute("name",this.name||""),De(this.toXml(e)).replace(' xmlns="https://developers.google.com/blockly/xml"',"")):null}loadLegacyState(e,t){return e.prototype.loadState===this.loadState&&e.prototype.fromXml!==this.fromXml&&(this.fromXml(Zs.vc(t)),!0)}dispose(){var e;bi(this),on(this),null!=(e=this.getSourceBlock())&&e.isDeadOrDying()||S(this.fieldGroup_),(e=this.getClickTarget_())&&(xi(e),delete e.tooltip),this.tooltip=null,this.disposed=!0}updateEditable(){var e=this.fieldGroup_,t=this.getSourceBlock();this.EDITABLE&&e&&t&&(this.enabled_&&t.isEditable()?(N(e,"blocklyEditableField"),A(e,"blocklyNonEditableField")):(N(e,"blocklyNonEditableField"),A(e,"blocklyEditableField")))}setEnabled(e){this.enabled_=e,this.updateEditable()}isEnabled(){return this.enabled_}isClickable(){return this.enabled_&&!!this.sourceBlock_&&this.sourceBlock_.isEditable()&&this.showEditor_!==Wu.prototype.showEditor_}isClickableInFlyout(e){return!e}isCurrentlyEditable(){return this.enabled_&&this.EDITABLE&&!!this.sourceBlock_&&this.sourceBlock_.isEditable()}isSerializable(){var e=!1;return this.name&&(this.SERIALIZABLE?e=!0:this.EDITABLE&&(console.warn("Detected an editable field that was not serializable. Please define SERIALIZABLE property as true on all editable custom fields. Proceeding with serialization."),e=!0)),e}isVisible(){return this.visible_}setVisible(e){if(this.visible_!==e){this.visible_=e;var t=this.fieldGroup_;t&&(t.style.display=e?"block":"none")}}setValidator(e){this.validator_=e}getValidator(){return this.validator_}getSvgRoot(){return this.fieldGroup_}getBorderRect(){if(!this.borderRect_)throw Error(`The border rectangle is ${this.borderRect_}.`);return this.borderRect_}getTextElement(){if(!this.textElement_)throw Error(`The text element is ${this.textElement_}.`);return this.textElement_}getTextContent(){if(!this.textContent_)throw Error(`The text content is ${this.textContent_}.`);return this.textContent_}applyColour(){}render_(){this.textContent_&&(this.textContent_.nodeValue=this.getDisplayText_()),this.updateSize_()}showEditor(e){this.isClickable()&&this.showEditor_(e)}showEditor_(){}repositionForWindowResize(){return!1}updateSize_(e){var t=this.getConstants(),i=2*(e=void 0!==e?e:this.borderRect_?this.getConstants().FIELD_BORDER_RECT_X_PADDING:0),n=t.FIELD_TEXT_HEIGHT,o=0;this.textElement_&&(i+=o=D(this.textElement_)),this.borderRect_&&(n=Math.max(n,t.FIELD_BORDER_RECT_HEIGHT)),this.size_=new Fa(i,n),this.positionTextElement_(e,o),this.positionBorderRect_()}positionTextElement_(e,t){if(this.textElement_){var i,n=this.getConstants(),o=this.size_.height/2;this.textElement_.setAttribute("x",String(null!=(i=this.getSourceBlock())&&i.RTL?this.size_.width-t-e:e)),this.textElement_.setAttribute("y",String(n.FIELD_TEXT_BASELINE_CENTER?o:o-n.FIELD_TEXT_HEIGHT/2+n.FIELD_TEXT_BASELINE))}}positionBorderRect_(){this.borderRect_&&(this.borderRect_.setAttribute("width",String(this.size_.width)),this.borderRect_.setAttribute("height",String(this.size_.height)),this.borderRect_.setAttribute("rx",String(this.getConstants().FIELD_BORDER_RECT_RADIUS)),this.borderRect_.setAttribute("ry",String(this.getConstants().FIELD_BORDER_RECT_RADIUS)))}getSize(){return this.isVisible()?(this.isDirty_&&(this.render_(),this.isDirty_=!1),this.size_):new Fa(0,0)}getScaledBBox(){var e=this.getSourceBlock();if(!e)throw new $u;if(this.borderRect_){var t=this.borderRect_.getBoundingClientRect(),i=Ce(this.borderRect_);e=t.width,t=t.height}else{t=this.sourceBlock_.getHeightWidth();let n=e.workspace.scale;i=this.getAbsoluteXY_(),e=(t.width+1)*n,t=(t.height+1)*n,_r?(i.x+=1.5*n,i.y+=1.5*n):(i.x-=.5*n,i.y-=.5*n)}return new xa(i.y,i.y+t,i.x,i.x+e)}onLocationChange(){}getDisplayText_(){var e=this.getText();return e.length>this.maxDisplayLength&&(e=e.substring(0,this.maxDisplayLength-2)+"…"),e=e.replace(/\s/g,Wu.NBSP),this.sourceBlock_&&this.sourceBlock_.RTL&&(e+="‏"),e}getText(){var e=this.getText_();return String(null!==e?e:this.getValue())}getText_(){return null}markDirty(){this.isDirty_=!0,this.constants_=null}forceRerender(){this.isDirty_=!0,this.sourceBlock_&&this.sourceBlock_.rendered&&this.sourceBlock_.queueRender()}setValue(e,t=!0){if(null!==e){var i=Zs.gd;i||Zs.B(!0);try{let i=this.doClassValidation_(e),l=this.processValidation(e,i,t);if(!(l instanceof Error)){var n,o=null==(n=this.getValidator())?void 0:n.call(this,l),s=this.processValidation(l,o,t);if(!(s instanceof Error)){var r=this.sourceBlock_;if(!r||!r.disposed){var a=this.getValue();a===s?this.doValueUpdate_(s):(this.doValueUpdate_(s),t&&r&&Ee()&&ue(new(_e(Fr.BLOCK_CHANGE))(r,"field",this.name||null,a,s)),this.isDirty_&&this.forceRerender())}}}}finally{Zs.B(i)}}}processValidation(e,t,i){return null===t?(this.doValueInvalid_(e,i),this.isDirty_&&this.forceRerender(),Error()):void 0===t?e:t}getValue(){return this.value_}doClassValidation_(e){return null==e?null:e}doValueUpdate_(e){this.value_=e,this.isDirty_=!0}doValueInvalid_(){}onMouseDown_(e){this.sourceBlock_&&!this.sourceBlock_.isDeadOrDying()&&(e=this.sourceBlock_.workspace.getGesture(e))&&e.setStartField(this)}setTooltip(e){e||""===e||(e=this.sourceBlock_);var t=this.getClickTarget_();t?t.tooltip=e:this.tooltip=e}getTooltip(){var e=this.getClickTarget_();return Ri(e||{tooltip:this.tooltip})}getClickTarget_(){return this.clickTarget_||this.getSvgRoot()}getAbsoluteXY_(){return Ce(this.getClickTarget_())}referencesVariables(){return!1}refreshVariableName(){}getParentInput(){var e=null,t=this.getSourceBlock();if(!t)throw new $u;var i=t.inputList;for(let n=0;n<t.inputList.length;n++){let t=i[n],o=t.fieldRow;for(let i=0;i<o.length;i++)if(o[i]===this){e=t;break}}return e}getFlipRtl(){return!1}onShortcut(){return!1}getFocusableElement(){if(!this.fieldGroup_)throw Error("This field currently has no representative DOM element.");return this.fieldGroup_}getFocusableTree(){var e=this.getSourceBlock();if(!e)throw new $u;return e.workspace}onNodeFocus(){var e=this.getSourceBlock();e.workspace.scrollBoundsIntoView(e.getBoundingRectangleWithoutChildren())}onNodeBlur(){}canBeFocused(){return!0}performAction(){this.showEditor()}recomputeAriaContext(){try{var e=this.getFocusableElement()}catch(e){return!1}if(!e)return!1;var t;if(null!=(t=this.getSourceBlock())&&t.isInFlyout){let n,o;if(null==(n=this.getSourceBlock())||!n.getFullBlockField()||null!=(o=this.getSourceBlock())&&o.getParent())return f(e,$r.HIDDEN,!0),!1;var i;t=(null==(i=this.getSourceBlock())?void 0:i.getAriaRoleDescription())||Zs.C.BLOCK_LABEL_VALUE,f(e,$r.ROLEDESCRIPTION,t)}return m(e,$r.HIDDEN),_(e,Hr.BUTTON),i=this.computeAriaLabel(!0),this.isFullBlockField()&&(i=$t(this.getSourceBlock(),Xr.STANDARD,i)),f(e,$r.LABEL,i),!0}static fromJson(){throw Error("Attempted to instantiate a field from the registry that hasn't defined a 'fromJson' method.")}};Wu.NBSP=" ",Wu.SKIP_SETUP=Symbol("SKIP_SETUP");var qu,$u=class extends Error{constructor(){super("The field has not yet been attached to its input. Call appendField to attach it.")}},ju=null,zu=null,Xu=null,Yu="",Ku="",Ju=null,Qu={};Qu.createDom=en,Qu.getDiv=function(){return qu},Qu.hide=nn,Qu.hideIfOwner=on,Qu.hideIfOwnerIsInWorkspace=sn,Qu.isVisible=function(){return!!ju},Qu.positionWithAnchor=an,Qu.repositionForWindowResize=ln,Qu.show=tn,Qu.testOnly_setDiv=function(e){if(qu=e,null===e){let e;null==(e=document.querySelector(".blocklyWidgetDiv"))||e.remove()}};var Zu=null,ec={},tc=null,ic={};ic.callbackFactory=Zs.Pg,ic.dispose=gn,ic.getCurrentBlock=function(){return Zu},ic.getMenu=function(){return tc},ic.hide=pn,ic.setCurrentBlock=function(e){Zu=e},ic.show=hn;var nc=class{constructor(){this.registeredItems=new Map,this.reset()}reset(){this.registeredItems.clear()}register(e){if(this.registeredItems.has(e.id))throw Error('Menu item with ID "'+e.id+'" is already registered.');this.registeredItems.set(e.id,e)}unregister(e){if(!this.registeredItems.has(e))throw Error('Menu item with ID "'+e+'" not found.');this.registeredItems.delete(e)}getItem(e){var t;return null!=(t=this.registeredItems.get(e))?t:null}getContextMenuOptions(e,t){var i=[];for(let n of this.registeredItems.values()){if(n.scopeType){if(n.scopeType===rc.BLOCK&&!e.block)continue;if(n.scopeType===rc.COMMENT&&!e.comment)continue;if(n.scopeType===rc.WORKSPACE&&!e.workspace)continue}let o;o={id:n.id,scope:e,weight:n.weight};let s,r,a=null==(r=(s=n).preconditionFn)?void 0:r.call(s,e,t);if("hidden"!==a){if(n.separator)o=Object.assign({},o,{separator:!0});else{let t="function"==typeof n.displayText?n.displayText(e):n.displayText;o=Object.assign({},o,{text:t,callback:n.callback,enabled:"enabled"===a,associatedKeyboardShortcut:n.associatedKeyboardShortcut})}i.push(o)}}return i.sort((function(e,t){return e.weight-t.weight})),i}},oc=nc||(nc={}),sc=oc.ScopeType||(oc.ScopeType={});sc.BLOCK="block",sc.WORKSPACE="workspace",sc.COMMENT="comment",oc.registry=new oc;var rc=nc.ScopeType,ac=class{constructor(e){this.comment=e,this.startLoc=null,this.workspace=e.workspace}isMovable(){return this.comment.isOwnMovable()&&!this.comment.isDeadOrDying()&&!this.workspace.isReadOnly()}startDrag(){var e;return this.fireDragStartEvent(),this.startLoc=this.comment.getRelativeToSurfaceXY(),this.workspace.setResizesEnabled(!1),null==(e=this.workspace.getLayerManager())||e.moveToDragLayer(this.comment),this.comment.setDragging(!0),this.comment}drag(e){this.comment.moveDuringDrag(e)}endDrag(){var e;this.fireDragEndEvent(),this.fireMoveEvent(),null==(e=this.workspace.getLayerManager())||e.moveOffDragLayer(this.comment,50),this.workspace.getAudioManager().play("drop"),this.comment.setDragging(!1),this.comment.snapToGrid(),this.workspace.setResizesEnabled(!0)}fireDragStartEvent(){var e=new(_e(Fr.COMMENT_DRAG))(this.comment,!0);ue(e)}fireDragEndEvent(){var e=new(_e(Fr.COMMENT_DRAG))(this.comment,!1);ue(e)}fireMoveEvent(){if(!this.comment.isDeadOrDying()){var e=new(_e(Fr.COMMENT_MOVE))(this.comment);e.setReason(["drag"]),e.oldCoordinate_=this.startLoc,e.recordNew(),ue(e)}}revertDrag(){this.startLoc&&this.comment.moveDuringDrag(this.startLoc)}},lc=new WeakMap,hc=class{constructor(e,t,i,n){this.id=e,this.workspace=t,this.container=i,this.commentView=n}isVisible(){return this.icon.checkVisibility()}getCommentView(){return this.commentView}getSize(e=!1){var t=this.icon.getBBox();return t=xa.from(t),e&&(e=this.getMargin(),t.left-=e,t.top-=e,t.bottom+=e,t.right+=e),t}getMargin(){return(this.container.getBBox().height-this.icon.getBBox().height)/2}getFocusableElement(){return this.icon}getFocusableTree(){return this.workspace}onNodeFocus(){var e=this.getCommentView(),t=e.getRelativeToSurfaceXY(),i=e.getSize();t=new xa(t.y,t.y+i.height,t.x,t.x+i.width),e.workspace.scrollBoundsIntoView(t)}onNodeBlur(){}canBeFocused(){return this.isVisible()}recomputeAriaContext(){if(this.icon){_(this.icon,Hr.BUTTON);var e=this.getAriaLabel();f(this.icon,$r.LABEL,e||Zs.C.ARIA_LABEL_BUTTON)}}getAriaLabel(){return null}},uc=class extends hc{constructor(e,t,i,n){super(`${e}_collapse_bar_button`,t,i,n),this.icon=I(ea.IMAGE,{class:"blocklyFoldoutIcon",href:`${this.workspace.options.pathToMedia}foldout-icon.svg`,id:this.id},this.container),this.recomputeAriaContext(),this.bindId=r(this.icon,"pointerdown",this,this.performAction.bind(this))}dispose(){l(this.bindId)}reposition(){var e=this.getMargin();this.icon.setAttribute("y",`${e}`),this.icon.setAttribute("x",`${e}`)}performAction(e){dr=null,this.getCommentView().bringToFront(),e&&e instanceof PointerEvent&&u(e)?e.stopPropagation():(this.getCommentView().setCollapsed(!this.getCommentView().isCollapsed()),this.recomputeAriaContext(),this.workspace.hideChaff(),null==e||e.stopPropagation())}getAriaLabel(){return this.getCommentView().isCollapsed()?Zs.C.ARIA_LABEL_COMMENT_EXPAND:Zs.C.ARIA_LABEL_COMMENT_COLLAPSE}},cc=class{constructor(e,t,i){this.workspace=e,this.onFinishEditing=i,this.textChangeListeners=[],this.text="",this.foreignObject=I(ea.FOREIGNOBJECT,{class:"blocklyCommentForeignObject"}),(e=document.createElementNS("http://www.w3.org/1999/xhtml","body")).setAttribute("xmlns","http://www.w3.org/1999/xhtml"),e.className="blocklyMinimalBody",this.textArea=document.createElementNS("http://www.w3.org/1999/xhtml","textarea"),this.textArea.setAttribute("tabindex","-1"),this.textArea.setAttribute("dir",this.workspace.RTL?"RTL":"LTR"),_(this.textArea,Hr.TEXTBOX),this.textArea.setAttribute("placeholder",Zs.C.WORKSPACE_COMMENT_DEFAULT_TEXT),N(this.textArea,"blocklyCommentText"),N(this.textArea,"blocklyTextarea"),N(this.textArea,"blocklyText"),e.appendChild(this.textArea),this.foreignObject.appendChild(e),this.id=t+"_comment_textarea_",this.textArea.setAttribute("id",this.id),r(this.textArea,"change",this,this.onTextChange),r(this.textArea,"pointerdown",this,(e=>{e.stopPropagation(),Zs.t().focusNode(this),dr=null})),r(this.textArea,"wheel",this,(e=>{e.stopPropagation()}),!1,{passive:!0}),r(this.textArea,"keydown",this,this.handleKeyDown)}getDom(){return this.foreignObject}getText(){return this.text}setText(e){this.textArea.value=e,this.onTextChange()}setParent(e){this.parent=e}getParent(){return this.parent}onTextChange(){var e=this.text;this.text=this.textArea.value;for(let t=this.textChangeListeners.length-1;t>=0;t--)this.textChangeListeners[t](e,this.text)}handleKeyDown(e){("Escape"===e.key||"Enter"===e.key&&(e.ctrlKey||e.metaKey))&&(this.onFinishEditing&&this.onFinishEditing(),e.stopPropagation())}addTextChangeListener(e){this.textChangeListeners.push(e)}removeTextChangeListener(e){this.textChangeListeners.splice(this.textChangeListeners.indexOf(e),1)}setPlaceholderText(e){this.textArea.placeholder=e}setEditable(e){e?this.textArea.removeAttribute("readonly"):this.textArea.setAttribute("readonly","true")}updateSize(e,t){this.foreignObject.setAttribute("height",""+(e.height-t.height)),this.foreignObject.setAttribute("width",`${e.width}`),this.foreignObject.setAttribute("y",`${t.height}`),this.workspace.RTL&&this.foreignObject.setAttribute("x",""+-e.width)}getFocusableElement(){return this.textArea}getFocusableTree(){return this.workspace}onNodeFocus(){var e=xa.from(this.foreignObject.getBoundingClientRect());this.workspace.scrollBoundsIntoView(xa.createFromPoint(we(this.workspace,e.getOrigin()),e.getWidth(),e.getHeight()))}onNodeBlur(){}canBeFocused(){return!!this.id}},dc=class extends hc{constructor(e,t,i,n){super(`${e}_delete_bar_button`,t,i,n),this.icon=I(ea.IMAGE,{class:"blocklyDeleteIcon",href:`${this.workspace.options.pathToMedia}delete-icon.svg`,id:this.id},i),this.recomputeAriaContext(),this.bindId=r(this.icon,"pointerdown",this,this.performAction.bind(this))}dispose(){l(this.bindId)}reposition(){var e=this.getMargin();this.icon.setAttribute("x","0");var t=this.container.getBBox();this.icon.setAttribute("y",`${e}`),this.icon.setAttribute("x",""+(t.width-this.getSize(!0).getWidth()))}performAction(e){dr=null,e&&e instanceof PointerEvent&&u(e)?e.stopPropagation():(this.getCommentView().dispose(),null==e||e.stopPropagation(),Zs.t().focusNode(this.workspace),this.workspace.getAudioManager().play("delete"))}getAriaLabel(){return Zs.C.REMOVE_COMMENT}},pc=class{constructor(e,t){var i;this.workspace=e,this.commentId=t,this.collapsed=!1,this.editable=!0,this.location=new Da(0,0),this.sizeChangeListeners=[],this.disposeListeners=[],this.collapseChangeListeners=[],this.resizePointerMoveListener=this.resizePointerUpListener=null,this.disposed=this.disposing=!1,this.svgRoot=I(ea.G,{class:"blocklyComment blocklyEditable blocklyDraggable"}),_(this.svgRoot,Hr.BUTTON),f(this.svgRoot,$r.ROLEDESCRIPTION,Zs.C.ARIA_LABEL_COMMENT),this.highlightRect=this.createHighlightRect(this.svgRoot),({topBarGroup:this.topBarGroup,topBarBackground:this.topBarBackground,deleteButton:this.deleteButton,foldoutButton:this.foldoutButton,textPreview:this.textPreview,textPreviewNode:this.textPreviewNode}=this.createTopBar(this.svgRoot)),this.commentEditor=this.createTextArea(),f(this.svgRoot,$r.LABELLEDBY,this.commentEditor.getFocusableElement().id),this.resizeHandle=this.createResizeHandle(this.svgRoot,e),null==(i=e.getLayerManager())||i.append(this,50),this.size=pc.defaultCommentSize,this.setSizeWithoutFiringEvents(this.size),this.moveTo(new Da(0,0))}createHighlightRect(e){return I(ea.RECT,{class:"blocklyCommentHighlight"},e)}createTopBar(e){e=I(ea.G,{class:"blocklyCommentTopbar"},e);var t=I(ea.RECT,{class:"blocklyCommentTopbarBackground"},e),i=new dc(this.commentId,this.workspace,e,this),n=new uc(this.commentId,this.workspace,e,this);this.addDisposeListener((()=>{i.dispose(),n.dispose()}));var o=I(ea.TEXT,{class:"blocklyCommentPreview blocklyCommentText blocklyText"},e),s=document.createTextNode("");return o.appendChild(s),{topBarGroup:e,topBarBackground:t,deleteButton:i,foldoutButton:n,textPreview:o,textPreviewNode:s}}createTextArea(){var e=new cc(this.workspace,this.commentId,(()=>this.svgRoot.focus()));return this.svgRoot.appendChild(e.getDom()),e.addTextChangeListener(((e,t)=>{this.updateTextPreview(t),this.setSize(this.size)})),e}getEditorFocusableNode(){return this.commentEditor}createResizeHandle(e,t){return e=I(ea.IMAGE,{class:"blocklyResizeHandle",href:`${t.options.pathToMedia}resize-handle.svg`},e),r(e,"pointerdown",this,this.onResizePointerDown),e}getSvgRoot(){return this.svgRoot}getSize(){return this.collapsed?this.topBarBackground.getBBox():this.size}setSizeWithoutFiringEvents(e){var t=this.topBarBackground.getBBox(),i=this.textPreview.getBBox(),n=this.resizeHandle.getBBox();this.size=e=Fa.max(e,this.calcMinSize(t)),this.svgRoot.setAttribute("height",`${e.height}`),this.svgRoot.setAttribute("width",`${e.width}`),this.updateHighlightRect(e),this.updateTopBarSize(e),this.commentEditor.updateSize(e,t),this.deleteButton.reposition(),this.foldoutButton.reposition(),this.updateTextPreviewSize(e,t,i),this.updateResizeHandlePosition(e,n)}setSize(e){var t=this.preResizeSize||this.size;this.setSizeWithoutFiringEvents(e),this.onSizeChange(t,this.size)}calcMinSize(e){var t;this.updateTextPreview(null!=(t=this.commentEditor.getText())?t:"");var i=t=D(this.textPreview);return this.foldoutButton.isVisible()?i+=this.foldoutButton.getSize(!0).getWidth():t&&(i+=4),this.deleteButton.isVisible()?i+=this.deleteButton.getSize(!0).getWidth():t&&(i+=4),new Fa(i,e.height+20)}updateHighlightRect(e){this.highlightRect.setAttribute("height",`${e.height}`),this.highlightRect.setAttribute("width",`${e.width}`),this.workspace.RTL&&this.highlightRect.setAttribute("x",""+-e.width)}updateTopBarSize(e){this.topBarBackground.setAttribute("width",`${e.width}`)}updateTextPreviewSize(e,t,i){t=(t.height-i.height)/2;var n=this.foldoutButton.getSize(!0),o=this.deleteButton.getSize(!0);e=e.width-n.getWidth()-o.getWidth(),this.textPreview.setAttribute("x",""+(this.workspace.RTL?-1:1)*n.getWidth()),this.textPreview.setAttribute("y",`${t+i.height/2}`),this.textPreview.setAttribute("width",`${e}`)}updateResizeHandlePosition(e,t){this.resizeHandle.setAttribute("y",""+(e.height-t.height)),this.resizeHandle.setAttribute("x",""+(e.width-t.width))}onSizeChange(e,t){for(let i=this.sizeChangeListeners.length-1;i>=0;i--)this.sizeChangeListeners[i](e,t)}addSizeChangeListener(e){this.sizeChangeListeners.push(e)}removeSizeChangeListener(e){this.sizeChangeListeners.splice(this.sizeChangeListeners.indexOf(e),1)}onResizePointerDown(e){this.isEditable()&&(this.bringToFront(),u(e)||(this.preResizeSize=this.getSize(),_n(this.workspace,e,new Da(this.workspace.RTL?-this.getSize().width:this.getSize().width,this.getSize().height)),this.resizePointerUpListener=r(document,"pointerup",this,this.onResizePointerUp),this.resizePointerMoveListener=r(document,"pointermove",this,this.onResizePointerMove),this.workspace.hideChaff()),e.stopPropagation())}onResizePointerUp(){dr=null,this.resizePointerUpListener&&(l(this.resizePointerUpListener),this.resizePointerUpListener=null),this.resizePointerMoveListener&&(l(this.resizePointerMoveListener),this.resizePointerMoveListener=null),this.setSize(this.size),this.preResizeSize=void 0}onResizePointerMove(e){e=fn(this.workspace,e),this.setSizeWithoutFiringEvents(new Fa(this.workspace.RTL?-e.x:e.x,e.y))}isCollapsed(){return this.collapsed}setCollapsed(e){(this.collapsed=e)?N(this.svgRoot,"blocklyCollapsed"):A(this.svgRoot,"blocklyCollapsed"),this.setSizeWithoutFiringEvents(this.size),this.onCollapse()}onCollapse(){for(let e=this.collapseChangeListeners.length-1;e>=0;e--)this.collapseChangeListeners[e](this.collapsed)}addOnCollapseListener(e){this.collapseChangeListeners.push(e)}removeOnCollapseListener(e){this.collapseChangeListeners.splice(this.collapseChangeListeners.indexOf(e),1)}isEditable(){return this.editable}setEditable(e){(this.editable=e)?(N(this.svgRoot,"blocklyEditable"),A(this.svgRoot,"blocklyReadonly")):(A(this.svgRoot,"blocklyEditable"),N(this.svgRoot,"blocklyReadonly")),this.commentEditor.setEditable(e)}getRelativeToSurfaceXY(){return this.location}moveTo(e){this.location=e,this.svgRoot.setAttribute("transform",`translate(${e.x}, ${e.y})`)}getText(){return this.commentEditor.getText()}setText(e){this.commentEditor.setText(e)}setPlaceholderText(e){this.commentEditor.setPlaceholderText(e)}addTextChangeListener(e){this.commentEditor.addTextChangeListener(e)}removeTextChangeListener(e){this.commentEditor.removeTextChangeListener(e)}updateTextPreview(e){this.textPreviewNode.textContent=this.truncateText(e)}truncateText(e){return e.length>=12?`${e.substring(0,9)}...`:e}bringToFront(){var e=this.svgRoot.parentNode,t=e.childNodes;t[t.length-1]!==this.svgRoot&&e.appendChild(this.svgRoot)}onDeleteDown(e){dr=null,u(e)||this.dispose(),e.stopPropagation()}dispose(){this.disposing=!0,S(this.svgRoot);for(let e=this.disposeListeners.length-1;e>=0;e--)this.disposeListeners[e]();this.disposeListeners.length=0,this.disposed=!0}isDisposed(){return this.disposed}isDeadOrDying(){return this.disposing||this.disposed}addDisposeListener(e){this.disposeListeners.push(e)}removeDisposeListener(e){this.disposeListeners.splice(this.disposeListeners.indexOf(e),1)}getCommentBarButtons(){return[this.foldoutButton,this.deleteButton]}};pc.defaultCommentSize=new Fa(120,100),g("\n.injectionDiv {\n --commentFillColour: #FFFCC7;\n --commentBorderColour: #F2E49B;\n}\n\n.blocklyComment .blocklyTextarea {\n background-color: var(--commentFillColour);\n border: 1px solid var(--commentBorderColour);\n box-sizing: border-box;\n display: block;\n outline: 0;\n padding: 5px;\n resize: none;\n width: 100%;\n height: 100%;\n}\n\n.blocklyReadonly.blocklyComment .blocklyTextarea {\n cursor: inherit;\n}\n\n.blocklyDeleteIcon {\n width: 20px;\n height: 20px;\n display: none;\n cursor: pointer;\n}\n\n.blocklyFoldoutIcon {\n width: 20px;\n height: 20px;\n transform-origin: 12px 12px;\n cursor: pointer;\n}\n.blocklyResizeHandle {\n width: 12px;\n height: 12px;\n cursor: se-resize;\n}\n.blocklyReadonly.blocklyComment .blocklyResizeHandle {\n cursor: inherit;\n}\n\n.blocklyCommentTopbarBackground {\n fill: var(--commentBorderColour);\n height: 24px;\n}\n\n.blocklyComment .blocklyCommentPreview.blocklyText {\n fill: #000;\n dominant-baseline: middle;\n visibility: hidden;\n}\n\n.blocklyCollapsed.blocklyComment .blocklyCommentPreview {\n visibility: visible;\n}\n\n.blocklyCollapsed.blocklyComment .blocklyCommentForeignObject,\n.blocklyCollapsed.blocklyComment .blocklyResizeHandle {\n display: none;\n}\n\n.blocklyCollapsed.blocklyComment .blocklyFoldoutIcon {\n transform: rotate(-90deg);\n}\n\n.blocklyRTL .blocklyCommentTopbar {\n transform: scale(-1, 1);\n}\n\n.blocklyRTL .blocklyCommentForeignObject {\n direction: rtl;\n}\n\n.blocklyRTL .blocklyCommentPreview {\n /* Revert the scale and control RTL using direction instead. */\n transform: scale(-1, 1);\n direction: rtl;\n}\n\n.blocklyRTL .blocklyResizeHandle {\n transform: scale(-1, 1);\n cursor: sw-resize;\n}\n\n.blocklyCommentHighlight {\n fill: none;\n}\n\n.blocklyComment.blocklyActiveFocus .blocklyCommentHighlight {\n stroke: var(--blockly-active-node-color);\n stroke-width: calc(2 * var(--blockly-selection-width));\n}\n\n.blocklyCollapsed.blocklyComment.blocklyActiveFocus .blocklyCommentTopbarBackground {\n stroke: var(--blockly-active-node-color);\n stroke-width: var(--blockly-selection-width);\n}\n\n.blocklyCommentText.blocklyActiveFocus {\n border-color: var(--blockly-active-node-color);\n border-width: var(--blockly-selection-width);\n}\n\n.blocklyCommentTopbar image.blocklyActiveFocus {\n outline: var(--blockly-selection-width) solid var(--blockly-active-node-color);\n}\n\n.blocklyCollapsed.blocklyComment.blocklyActiveFocus .blocklyCommentHighlight {\n stroke: none;\n}\n");var gc=class{constructor(e,t){this.workspace=e,this.text="",this.collapsed=!1,this.deletable=this.movable=this.editable=!0,this.location=new Da(0,0),this.disposing=this.disposed=!1,this.id=t&&!e.getCommentById(t)?t:he(),this.size=pc.defaultCommentSize,e.addTopComment(this),this.fireCreateEvent()}fireCreateEvent(){Ee()&&ue(new(_e(Fr.COMMENT_CREATE))(this))}fireDeleteEvent(){Ee()&&ue(new(_e(Fr.COMMENT_DELETE))(this))}fireChangeEvent(e,t){Ee()&&ue(new(_e(Fr.COMMENT_CHANGE))(this,e,t))}fireCollapseEvent(e){Ee()&&ue(new(_e(Fr.COMMENT_COLLAPSE))(this,e))}setText(e){var t=this.text;this.text=e,this.fireChangeEvent(t,e)}getText(){return this.text}setSize(e){var t=new(_e(Fr.COMMENT_RESIZE))(this);this.size=e,t.recordCurrentSizeAsNewSize(),ue(t)}getSize(){return this.size}setCollapsed(e){this.collapsed=e,this.fireCollapseEvent(e)}isCollapsed(){return this.collapsed}setEditable(e){this.editable=e}isEditable(){return this.isOwnEditable()&&!this.workspace.isReadOnly()}isOwnEditable(){return this.editable}setMovable(e){this.movable=e}isMovable(){return this.isOwnMovable()&&!this.workspace.isReadOnly()&&!this.workspace.isFlyout}isOwnMovable(){return this.movable}setDeletable(e){this.deletable=e}isDeletable(){return this.isOwnDeletable()&&!this.isDeadOrDying()&&!this.workspace.isReadOnly()&&!this.workspace.isFlyout}isOwnDeletable(){return this.deletable}moveTo(e,t){var i=new(_e(Fr.COMMENT_MOVE))(this);t&&i.setReason(t),this.location=e,i.recordNew(),ue(i)}getRelativeToSurfaceXY(){return this.location.clone()}dispose(){this.disposing=!0,this.fireDeleteEvent(),this.workspace.removeTopComment(this),this.disposed=!0}isDisposed(){return this.disposed}isDeadOrDying(){return this.disposing||this.disposed}},Ec=class extends gc{constructor(e,t){super(e,t),this.dragStrategy=new ac(this),this.workspace=e,this.view=new pc(e,this.id),this.view.getEditorFocusableNode().setParent(this),this.view.setSize(this.getSize()),this.view.setEditable(this.isEditable()),this.view.getSvgRoot().setAttribute("data-id",this.id),this.view.getSvgRoot().setAttribute("id",this.id),this.addModelUpdateBindings(),r(this.view.getSvgRoot(),"pointerdown",this,this.startGesture)}addModelUpdateBindings(){this.view.addTextChangeListener(((e,t)=>{super.setText(t)})),this.view.addSizeChangeListener(((e,t)=>{super.setSize(t)})),this.view.addOnCollapseListener((()=>{super.setCollapsed(this.view.isCollapsed())})),this.view.addDisposeListener((()=>{this.isDeadOrDying()||this.dispose()}))}setText(e){this.view.setText(e)}setPlaceholderText(e){this.view.setPlaceholderText(e)}setSize(e){this.view.setSize(e)}setCollapsed(e){this.view.setCollapsed(e)}setEditable(e){super.setEditable(e),this.view.setEditable(this.isEditable())}getSvgRoot(){return this.view.getSvgRoot()}getSize(){return super.getSize()}getBoundingRectangle(){var e,t,i=this.getRelativeToSurfaceXY(),n=null!=(t=null==(e=this.view)?void 0:e.getSize())?t:this.getSize();return this.workspace.RTL?(e=i.x-n.width,t=i.x):(e=i.x,t=i.x+n.width),new xa(i.y,i.y+n.height,e,t)}moveBy(e,t,i){var n=this.getRelativeToSurfaceXY();e=new Da(n.x+e,n.y+t),this.moveTo(e,i)}moveTo(e,t){super.moveTo(e,t),this.view.moveTo(e)}moveDuringDrag(e){this.location=e,this.view.moveTo(e)}setDragging(e){e?N(this.getSvgRoot(),"blocklyDragging"):A(this.getSvgRoot(),"blocklyDragging")}dispose(){this.disposing=!0;var e=Zs.t();e.getFocusedNode()===this&&setTimeout((()=>{e.isRegistered(this.workspace)&&e.focusTree(this.workspace)}),0),this.view.isDeadOrDying()||this.view.dispose(),super.dispose()}startGesture(e){var t=this.workspace.getGesture(e);t&&(t.handleCommentStart(e,this),Zs.t().focusNode(this))}setDeleteStyle(e){e?N(this.getSvgRoot(),"blocklyDraggingDelete"):A(this.getSvgRoot(),"blocklyDraggingDelete")}isCopyable(){return this.isOwnMovable()&&this.isOwnDeletable()}isMovable(){return this.dragStrategy.isMovable()}startDrag(){return this.dragStrategy.startDrag()}drag(e){this.dragStrategy.drag(e)}endDrag(){this.dragStrategy.endDrag()}revertDrag(){this.dragStrategy.revertDrag()}select(){N(this.getSvgRoot(),"blocklySelected"),z(this)}unselect(){A(this.getSvgRoot(),"blocklySelected"),z(null)}toCopyData(){return{paster:_l.TYPE,commentState:je(this,{addCoordinates:!0,saveIds:!1})}}showContextMenu(e){var t=nc.registry.getContextMenuOptions({comment:this,focusedNode:this},e),i=e instanceof PointerEvent?new Da(e.clientX,e.clientY):Le(this.workspace,this.getRelativeToSurfaceXY()).translate(10,10);hn(e,t,this.workspace.RTL,this.workspace,i)}snapToGrid(){if(!this.isDeadOrDying()){var e=this.workspace.getGrid();if(null!=e&&e.shouldSnap()){var t=this.getRelativeToSurfaceXY();(e=e.alignXY(t))!==t&&this.moveTo(e,["snap"])}}}getEditorFocusableNode(){return this.view.getEditorFocusableNode()}getFocusableElement(){return this.getSvgRoot()}getFocusableTree(){return this.workspace}onNodeFocus(){var e;this.select(),null==(e=this.getSvgRoot().parentElement)||e.appendChild(this.getSvgRoot()),this.workspace.scrollBoundsIntoView(this.getBoundingRectangle())}onNodeBlur(){this.unselect()}canBeFocused(){return!0}performAction(){this.setCollapsed(!1),Zs.t().focusNode(this.getEditorFocusableNode())}},Tc={appendDomToWorkspace:function(e,t){if(!t.getBlocksBoundingBox)return Zs.ch(e,t);var i=t.getBlocksBoundingBox();if(e=Zs.ch(e,t),i&&i.top!==i.bottom){var n=i.bottom;i=t.RTL?i.right:i.left;var o=1/0;let s=-1/0,r=1/0;for(let i=0;i<e.length;i++){let n=t.getBlockById(e[i]).getRelativeToSurfaceXY();n.y<r&&(r=n.y),n.x<o&&(o=n.x),n.x>s&&(s=n.x)}for(n=n-r+10,i=t.RTL?i-s:i-o,o=0;o<e.length;o++)t.getBlockById(e[o]).moveBy(i,n,["create"])}return e}};Tc.blockToDom=vn,Tc.blockToDomWithXY=Cn,Tc.clearWorkspaceAndLoadFromXml=function(e,t){return t.setResizesEnabled(!1),t.clear(),e=Zs.ch(e,t),t.setResizesEnabled(!0),e},Tc.deleteNext=function(e){for(let t=0;t<e.childNodes.length;t++){let i=e.childNodes[t];if("next"===i.nodeName.toLowerCase()){e.removeChild(i);break}}},Tc.domToBlock=Zs.fh,Tc.domToBlockInternal=An,Tc.domToPrettyText=function(e){e=Nn(e).split("<");var t="";for(let i=1;i<e.length;i++){let n=e[i];"/"===n[0]&&(t=t.substring(2)),e[i]=t+"<"+n,"/"!==n[0]&&"/>"!==n.slice(-2)&&(t+=" ")}return(e=(e=e.join("\n")).replace(/(<(\w+)\b[^>]*>[^\n]*)\n *<\/\2>/g,"$1</$2>")).replace(/^\n/,"")},Tc.domToText=Nn,Tc.domToVariables=kn,Tc.domToWorkspace=Zs.ch,Tc.loadWorkspaceComment=yn,Tc.saveWorkspaceComment=mn,Tc.variablesToDom=bn,Tc.workspaceToDom=function(e,t=!1){var i=Zs.sc("xml"),n=bn(Zs.Bd(e));n.hasChildNodes()&&i.appendChild(n);for(let n of e.getTopComments())i.appendChild(mn(n,t));for(e=e.getTopBlocks(!0),n=0;n<e.length;n++)i.appendChild(Cn(e[n],t));return i};var _c={fromJsonInternal:function(e){var t=ne(ya.FIELD,e.type,void 0);return t?t.fromJson(e):(console.warn("Blockly could not create a field of type "+e.type+". The field is probably not being registered. This could be because the file is not loaded, the field does not register itself (Issue #1584), or the registration is not being reached."),null)}},fc={TEST_ONLY:_c};fc.fromJson=Zs.lh,fc.register=wn,fc.unregister=function(e){ie(ya.FIELD,e)};var mc=class extends Wu{constructor(e,t,i){super(Wu.SKIP_SETUP),this.svgArrow=this.arrow=this.imageElement=this.menu_=this.selectedMenuItem=null,this.SERIALIZABLE=!0,this.clickTarget_=this.suffixField=this.prefixField=this.generatedOptions=null,this.isInitialized=!1,e!==Wu.SKIP_SETUP&&(this.setOptions(e),i&&this.configure_(i),t&&this.setValidator(t))}fromXml(e){this.isOptionListDynamic()&&this.getOptions(!1),this.setValue(e.textContent)}loadState(e){this.loadLegacyState(mc,e)||(this.isOptionListDynamic()&&this.getOptions(!1),this.setValue(e))}initView(){this.shouldAddBorderRect_()?this.createBorderRect_():this.clickTarget_=this.sourceBlock_.getSvgRoot(),this.createTextElement_(),this.imageElement=I(ea.IMAGE,{},this.fieldGroup_),this.getConstants().FIELD_DROPDOWN_SVG_ARROW?this.createSVGArrow_():this.createTextArrow_(),this.borderRect_&&N(this.borderRect_,"blocklyDropdownRect"),this.fieldGroup_&&(N(this.fieldGroup_,"blocklyField"),N(this.fieldGroup_,"blocklyDropdownField")),this.recomputeAriaContext(),this.isInitialized=!0}isFullBlockField(){var e;return!this.shouldAddBorderRect_()&&!(null==(e=this.getSourceBlock())||!e.isSimpleReporter())}shouldAddBorderRect_(){var e;return!this.getConstants().FIELD_DROPDOWN_NO_BORDER_RECT_SHADOW||this.getConstants().FIELD_DROPDOWN_NO_BORDER_RECT_SHADOW&&!(null!=(e=this.getSourceBlock())&&e.isShadow())}createTextArrow_(){var e,t;this.arrow=I(ea.TSPAN,{},this.textElement_),this.arrow.appendChild(document.createTextNode(null!=(e=this.getSourceBlock())&&e.RTL?mc.ARROW_CHAR+" ":" "+mc.ARROW_CHAR)),this.getConstants().FIELD_TEXT_BASELINE_CENTER&&this.arrow.setAttribute("dominant-baseline","central"),null!=(t=this.getSourceBlock())&&t.RTL?this.getTextElement().insertBefore(this.arrow,this.textContent_):this.getTextElement().appendChild(this.arrow)}createSVGArrow_(){this.svgArrow=I(ea.IMAGE,{height:this.getConstants().FIELD_DROPDOWN_SVG_ARROW_SIZE+"px",width:this.getConstants().FIELD_DROPDOWN_SVG_ARROW_SIZE+"px"},this.fieldGroup_),f(this.svgArrow,$r.HIDDEN,!0),this.svgArrow.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",this.getConstants().FIELD_DROPDOWN_SVG_ARROW_DATAURI)}showEditor_(e){var t=this.getSourceBlock();if(!t)throw new $u;this.dropdownCreate(),this.menu_&&(this.menu_.openingCoords=e&&"number"==typeof e.clientX?new Da(e.clientX,e.clientY):null,ui(),e=this.menu_.render(pu),N(e,"blocklyDropdownMenu"),this.getConstants().FIELD_DROPDOWN_COLOURED_DIV&&(t=t.getColour(),e=this.sourceBlock_.getColourTertiary(),ci(t,e)),di(this,this.dropdownDispose_.bind(this)),pu.style.height=`${this.menu_.getSize().height}px`,this.menu_.focus(),this.selectedMenuItem&&this.menu_.setHighlighted(this.selectedMenuItem),this.applyColour(),f(this.getFocusableElement(),$r.EXPANDED,!0))}dropdownCreate(){var e=this.getSourceBlock();if(!e)throw new $u;var t=new bl;t.setRole(Hr.LISTBOX),this.menu_=t,f(this.getFocusableElement(),$r.CONTROLS,this.menu_.getId());var i=this.getOptions(!1);this.selectedMenuItem=null;for(let s=0;s<i.length;s++){var n=i[s];if(n===mc.SEPARATOR){t.addChild(new Cl);continue}let[r,a]=n;if(n=this.computeOptionAriaLabel(n,s),Ln(r)){var o=new Image(r.width,r.height);o.src=r.src,o.alt=r.alt}else o=r;(n=new ml(o,a,n)).setRole(Hr.OPTION),n.setRightToLeft(e.RTL),n.setCheckable(!0),t.addChild(n),n.setChecked(a===this.value_),a===this.value_&&(this.selectedMenuItem=n),n.onAction(this.handleMenuActionEvent,this)}}dropdownDispose_(){this.menu_&&this.menu_.dispose(),this.selectedMenuItem=this.menu_=null,this.applyColour(),f(this.getFocusableElement(),$r.EXPANDED,!1)}handleMenuActionEvent(e){bi(this,!0),this.onItemSelected_(this.menu_,e)}onItemSelected_(e,t){this.setValue(t.getValue())}isOptionListDynamic(){return"function"==typeof this.menuGenerator_}getOptions(e){if(!this.menuGenerator_)throw TypeError("A menu generator was never defined.");return Array.isArray(this.menuGenerator_)?this.menuGenerator_:(e&&this.generatedOptions||(this.generatedOptions=this.menuGenerator_(),this.validateOptions(this.generatedOptions)),this.generatedOptions)}setOptions(e){Array.isArray(e)?(this.validateOptions(e),e=this.trimOptions(e),this.menuGenerator_=e.options,this.prefixField=e.prefix||null,this.suffixField=e.suffix||null):this.menuGenerator_=e,this.selectedOption=this.getOptions(!1)[0],this.setValue(this.selectedOption[1])}doClassValidation_(e){return this.getOptions(!0).some((t=>t[1]===e))?e:(this.sourceBlock_&&console.warn("Cannot set the dropdown's value to an unavailable option. Block type: "+this.sourceBlock_.type+", Field name: "+this.name+", Value: "+e),null)}doValueUpdate_(e){super.doValueUpdate_(e),e=this.getOptions(!0);for(let t,i=0;t=e[i];i++)t[1]===this.value_&&(this.selectedOption=t);this.isInitialized&&this.recomputeAriaContext()}applyColour(){var e=this.sourceBlock_;this.borderRect_&&(this.borderRect_.setAttribute("stroke",e.getColourTertiary()),this.menu_?this.borderRect_.setAttribute("fill",e.getColourTertiary()):this.borderRect_.setAttribute("fill","transparent")),e&&this.arrow&&(e.isShadow()?this.arrow.style.fill=e.getColourSecondary():this.arrow.style.fill=e.getColour())}render_(){this.getTextContent().nodeValue="",this.imageElement.style.display="none";var e=this.selectedOption&&this.selectedOption[0];Ln(e)?this.renderSelectedImage(e):this.renderSelectedText(),this.positionBorderRect_()}renderSelectedImage(e){var t=this.getSourceBlock();if(!t)throw new $u;this.imageElement.style.display="",this.imageElement.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",e.src),this.imageElement.setAttribute("height",String(e.height)),this.imageElement.setAttribute("width",String(e.width));var i=Number(e.height);e=Number(e.width);var n=!!this.borderRect_,o=Math.max(n?this.getConstants().FIELD_DROPDOWN_BORDER_RECT_HEIGHT:0,i+mc.IMAGE_Y_PADDING);n=n?this.getConstants().FIELD_BORDER_RECT_X_PADDING:0;var s=this.svgArrow?this.positionSVGArrow(e+n,o/2-this.getConstants().FIELD_DROPDOWN_SVG_ARROW_SIZE/2):D(this.arrow);this.size_=new Fa(e+s+2*n,o);var r=0;t.RTL?this.imageElement.setAttribute("x",`${n+s}`):(r=e+s,this.getTextElement().setAttribute("text-anchor","end"),this.imageElement.setAttribute("x",`${n}`)),this.imageElement.setAttribute("y",String(o/2-i/2)),this.positionTextElement_(r+n,e+s)}renderSelectedText(){this.getTextContent().nodeValue=this.getDisplayText_();var e=this.getTextElement();N(e,"blocklyDropdownText"),e.setAttribute("text-anchor","start");var t=!!this.borderRect_;e=Math.max(t?this.getConstants().FIELD_DROPDOWN_BORDER_RECT_HEIGHT:0,this.getConstants().FIELD_TEXT_HEIGHT);var i=D(this.getTextElement());t=t?this.getConstants().FIELD_BORDER_RECT_X_PADDING:0;var n=0;this.svgArrow&&(n=this.positionSVGArrow(i+t,e/2-this.getConstants().FIELD_DROPDOWN_SVG_ARROW_SIZE/2)),this.size_=new Fa(i+n+2*t,e),this.positionTextElement_(t,i)}positionSVGArrow(e,t){if(!this.svgArrow)return 0;var i=this.getSourceBlock();if(!i)throw new $u;var n=this.borderRect_?this.getConstants().FIELD_BORDER_RECT_X_PADDING:0,o=this.getConstants().FIELD_DROPDOWN_SVG_ARROW_PADDING,s=this.getConstants().FIELD_DROPDOWN_SVG_ARROW_SIZE;return this.svgArrow.setAttribute("transform","translate("+(i.RTL?n:e+o)+","+t+")"),s+o}getText_(){if(!this.selectedOption)return null;var e=this.selectedOption[0];if(Ln(e))return e.alt;if("undefined"!=typeof HTMLElement&&e instanceof HTMLElement){let t;return e.title||(null!=(t=e.ariaLabel)?t:e.innerText)}return"string"==typeof e?e:(console.warn("Can't get text for existing dropdown option. If you're using HTMLElement dropdown options in node, ensure you're using jsdom-global or similar."),null)}static fromJson(e){if(!e.options)throw Error("options are required for the dropdown field. The options property must be assigned an array of [humanReadableValue, languageNeutralValue] tuples.");return new this(e.options,void 0,e)}trimOptions(e){var t=!1,i=e.map((e=>{if(e===mc.SEPARATOR)return t=!0,e;var[i,n,o]=e;return"string"==typeof i?(e=[Ji(i),n],o&&e.push(Ji(o)),e):(t=!0,e=[Ln(i)?Object.assign({},i,{alt:Ji(i.alt)}):i,n],o&&e.push(Ji(o)),e)}));if(t||e.length<2)return{options:i};var n=i.map((([e])=>e)),o=yi(n);e=Ai(n,o);var s=ki(n,o);return!e&&!s||o<=e+s?{options:i}:(o=e?n[0].substring(0,e-1):void 0,n=s?n[0].substr(1-s):void 0,{options:this.applyTrim(i,e,s),prefix:o,suffix:n})}applyTrim(e,t,i){return e.map((([e,n,o])=>(e=e.substring(t,e.length-i),void 0!==o?[e,n,o]:[e,n])))}validateOptions(e){if(!Array.isArray(e))throw TypeError("FieldDropdown options must be an array.");if(!e.length)throw TypeError("FieldDropdown options must not be an empty array.");var t=!1;for(let i=0;i<e.length;i++){let n=e[i];Array.isArray(n)||n===mc.SEPARATOR?"string"!=typeof n[1]?(t=!0,console.error(`Invalid option[${i}]: Each FieldDropdown option id must be a string.\n Found ${n[1]} in: ${n}`)):!n[0]||"string"==typeof n[0]||Ln(n[0])||"undefined"!=typeof HTMLElement&&n[0]instanceof HTMLElement?n[2]&&"string"!=typeof n[2]&&(t=!0,console.error(`Invalid option[${i}]: Each FieldDropdown option ARIA label must be a string.\n Found ${n[2]} in: ${n}`)):(t=!0,console.error(`Invalid option[${i}]: Each FieldDropdown option must have a string\n label, image description, or HTML element. Found ${n[0]} in: ${n}`)):(t=!0,console.error(`Invalid option[${i}]: Each FieldDropdown option must be an array or\n the string literal 'separator'. Found: ${n}`))}if(t)throw TypeError("Found invalid FieldDropdown options.")}getAriaTypeName(){return this.ariaTypeName||Zs.C.ARIA_TYPE_FIELD_DROPDOWN}getAriaValue(){return this.getSelectedAriaLabel()||this.getText()||Zs.C.FIELD_LABEL_EMPTY}getSelectedAriaLabel(){if(!this.selectedOption)return null;var e=this.selectedOption;return"string"==typeof(e=this.computeOptionAriaLabel(e,this.getOptions(!1).indexOf(e)))?e:null}recomputeAriaContext(){if(!super.recomputeAriaContext())return!1;var e=this.getFocusableElement();return f(e,$r.HASPOPUP,"listbox"),f(e,$r.EXPANDED,!!this.menu_),!0}computeOptionAriaLabel(e,t){if(e===mc.SEPARATOR)return"";var[i,,n]=e;if("string"==typeof n&&n.trim())return n;if(e=null,Ln(i)){let t;e=null!=(t=i.ariaLabel)?t:i.alt}else if("undefined"!=typeof HTMLElement&&i instanceof HTMLElement){let t;e=null!=(t=i.ariaLabel)?t:i.title||i.innerText}else"string"==typeof i&&(e=i);return e&&e.trim()?e:Zs.C.FIELD_LABEL_OPTION_INDEX.replace("%1",String(t+1))}};mc.SEPARATOR="separator",mc.ARROW_CHAR="▾",mc.IMAGE_Y_OFFSET=5,mc.IMAGE_Y_PADDING=2*mc.IMAGE_Y_OFFSET,wn("field_dropdown",mc);var bc,Cc=bc||(bc={});Cc[Cc.WIN_KEY_FF_LINUX=0]="WIN_KEY_FF_LINUX",Cc[Cc.MAC_ENTER=3]="MAC_ENTER",Cc[Cc.BACKSPACE=8]="BACKSPACE",Cc[Cc.TAB=9]="TAB",Cc[Cc.NUM_CENTER=12]="NUM_CENTER",Cc[Cc.ENTER=13]="ENTER",Cc[Cc.SHIFT=16]="SHIFT",Cc[Cc.CTRL=17]="CTRL",Cc[Cc.ALT=18]="ALT",Cc[Cc.PAUSE=19]="PAUSE",Cc[Cc.CAPS_LOCK=20]="CAPS_LOCK",Cc[Cc.ESC=27]="ESC",Cc[Cc.SPACE=32]="SPACE",Cc[Cc.PAGE_UP=33]="PAGE_UP",Cc[Cc.PAGE_DOWN=34]="PAGE_DOWN",Cc[Cc.END=35]="END",Cc[Cc.HOME=36]="HOME",Cc[Cc.LEFT=37]="LEFT",Cc[Cc.UP=38]="UP",Cc[Cc.RIGHT=39]="RIGHT",Cc[Cc.DOWN=40]="DOWN",Cc[Cc.PLUS_SIGN=43]="PLUS_SIGN",Cc[Cc.PRINT_SCREEN=44]="PRINT_SCREEN",Cc[Cc.INSERT=45]="INSERT",Cc[Cc.DELETE=46]="DELETE",Cc[Cc.ZERO=48]="ZERO",Cc[Cc.ONE=49]="ONE",Cc[Cc.TWO=50]="TWO",Cc[Cc.THREE=51]="THREE",Cc[Cc.FOUR=52]="FOUR",Cc[Cc.FIVE=53]="FIVE",Cc[Cc.SIX=54]="SIX",Cc[Cc.SEVEN=55]="SEVEN",Cc[Cc.EIGHT=56]="EIGHT",Cc[Cc.NINE=57]="NINE",Cc[Cc.FF_SEMICOLON=59]="FF_SEMICOLON",Cc[Cc.FF_EQUALS=61]="FF_EQUALS",Cc[Cc.FF_DASH=173]="FF_DASH",Cc[Cc.FF_HASH=163]="FF_HASH",Cc[Cc.QUESTION_MARK=63]="QUESTION_MARK",Cc[Cc.AT_SIGN=64]="AT_SIGN",Cc[Cc.A=65]="A",Cc[Cc.B=66]="B",Cc[Cc.C=67]="C",Cc[Cc.D=68]="D",Cc[Cc.E=69]="E",Cc[Cc.F=70]="F",Cc[Cc.G=71]="G",Cc[Cc.H=72]="H",Cc[Cc.I=73]="I",Cc[Cc.J=74]="J",Cc[Cc.K=75]="K",Cc[Cc.L=76]="L",Cc[Cc.M=77]="M",Cc[Cc.N=78]="N",Cc[Cc.O=79]="O",Cc[Cc.P=80]="P",Cc[Cc.Q=81]="Q",Cc[Cc.R=82]="R",Cc[Cc.S=83]="S",Cc[Cc.T=84]="T",Cc[Cc.U=85]="U",Cc[Cc.V=86]="V",Cc[Cc.W=87]="W",Cc[Cc.X=88]="X",Cc[Cc.Y=89]="Y",Cc[Cc.Z=90]="Z",Cc[Cc.META=91]="META",Cc[Cc.WIN_KEY_RIGHT=92]="WIN_KEY_RIGHT",Cc[Cc.CONTEXT_MENU=93]="CONTEXT_MENU",Cc[Cc.NUM_ZERO=96]="NUM_ZERO",Cc[Cc.NUM_ONE=97]="NUM_ONE",Cc[Cc.NUM_TWO=98]="NUM_TWO",Cc[Cc.NUM_THREE=99]="NUM_THREE",Cc[Cc.NUM_FOUR=100]="NUM_FOUR",Cc[Cc.NUM_FIVE=101]="NUM_FIVE",Cc[Cc.NUM_SIX=102]="NUM_SIX",Cc[Cc.NUM_SEVEN=103]="NUM_SEVEN",Cc[Cc.NUM_EIGHT=104]="NUM_EIGHT",Cc[Cc.NUM_NINE=105]="NUM_NINE",Cc[Cc.NUM_MULTIPLY=106]="NUM_MULTIPLY",Cc[Cc.NUM_PLUS=107]="NUM_PLUS",Cc[Cc.NUM_MINUS=109]="NUM_MINUS",Cc[Cc.NUM_PERIOD=110]="NUM_PERIOD",Cc[Cc.NUM_DIVISION=111]="NUM_DIVISION",Cc[Cc.F1=112]="F1",Cc[Cc.F2=113]="F2",Cc[Cc.F3=114]="F3",Cc[Cc.F4=115]="F4",Cc[Cc.F5=116]="F5",Cc[Cc.F6=117]="F6",Cc[Cc.F7=118]="F7",Cc[Cc.F8=119]="F8",Cc[Cc.F9=120]="F9",Cc[Cc.F10=121]="F10",Cc[Cc.F11=122]="F11",Cc[Cc.F12=123]="F12",Cc[Cc.NUMLOCK=144]="NUMLOCK",Cc[Cc.SCROLL_LOCK=145]="SCROLL_LOCK",Cc[Cc.FIRST_MEDIA_KEY=166]="FIRST_MEDIA_KEY",Cc[Cc.LAST_MEDIA_KEY=183]="LAST_MEDIA_KEY",Cc[Cc.SEMICOLON=186]="SEMICOLON",Cc[Cc.DASH=189]="DASH",Cc[Cc.EQUALS=187]="EQUALS",Cc[Cc.COMMA=188]="COMMA",Cc[Cc.PERIOD=190]="PERIOD",Cc[Cc.SLASH=191]="SLASH",Cc[Cc.APOSTROPHE=192]="APOSTROPHE",Cc[Cc.TILDE=192]="TILDE",Cc[Cc.SINGLE_QUOTE=222]="SINGLE_QUOTE",Cc[Cc.OPEN_SQUARE_BRACKET=219]="OPEN_SQUARE_BRACKET",Cc[Cc.BACKSLASH=220]="BACKSLASH",Cc[Cc.CLOSE_SQUARE_BRACKET=221]="CLOSE_SQUARE_BRACKET",Cc[Cc.WIN_KEY=224]="WIN_KEY",Cc[Cc.MAC_FF_META=224]="MAC_FF_META",Cc[Cc.MAC_WK_CMD_LEFT=91]="MAC_WK_CMD_LEFT",Cc[Cc.MAC_WK_CMD_RIGHT=93]="MAC_WK_CMD_RIGHT",Cc[Cc.WIN_IME=229]="WIN_IME",Cc[Cc.VK_NONAME=252]="VK_NONAME",Cc[Cc.PHANTOM=255]="PHANTOM",Cc[Cc.CTRL_CMD=Cr||br||mr?Cc.MAC_WK_CMD_LEFT:Cc.CTRL]="CTRL_CMD";var vc,Ic=class{constructor(e){var t,i,n;this.workspace=e,this.svgRoot=I(ea.G,{},null!=(n=null==(t=e.getLayerManager())?void 0:t.getDragLayer())?n:null==(i=e.getLayerManager())?void 0:i.getBlockLayer()),this.svgRoot.classList.add("blocklyMoveIndicator"),e=e.RTL,I(ea.CIRCLE,{fill:"white","fill-opacity":"0.8",stroke:"grey","stroke-width":"1",r:20,cx:20*(e?-1:1),cy:20},this.svgRoot),I(ea.PATH,{fill:"none",stroke:"black","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"m18 9l3 3l-3 3m-3-3h6M6 9l-3 3l3 3m-3-3h6m0 6l3 3l3-3m-3-3v6m3-15l-3-3l-3 3m3-3v6",transform:`translate(${8*(e?-4:1)} 8)`},this.svgRoot)}moveTo(e,t){this.svgRoot.setAttribute("transform",`translate(${e+(this.workspace.RTL?20:-20)}, ${t-20})`)}dispose(){S(this.svgRoot)}},Nc=vc||(vc={});Nc[Nc.NONE=0]="NONE",Nc[Nc.UP=1]="UP",Nc[Nc.DOWN=2]="DOWN",Nc[Nc.LEFT=3]="LEFT",Nc[Nc.RIGHT=4]="RIGHT";var yc=class{constructor(){this.totalDelta=new Da(0,0),this.stepDistance=20,this.allowedShortcuts=[],this.blurListener=()=>{this.abortMove()},this.moving=!1}canMove(e){return!e.workspace.isReadOnly()&&e.isMovable()}isMoving(){return this.moving}startMove(e,t){if(!this.canMove(e)||this.isMoving())return!1;this.moving=!0;var i=ae(ya.BLOCK_DRAGGER,e.workspace.options,!0);if(!i)throw Error("no Dragger registered");return this.dragger=new i(e,e.workspace),this.draggable=this.dragger.onDragStart(t),this.startLocation=this.draggable.getRelativeToSurfaceXY(),this.updateTotalDelta(),this.draggable.getFocusableElement().addEventListener("blur",this.blurListener),e=Object.values(ca.registry.getRegistry()).flatMap((e=>e.keyCodes)).filter((e=>e&&![bc.RIGHT,bc.LEFT,bc.UP,bc.DOWN,bc.ENTER,bc.SPACE,bc.ESC,bc.M].includes("number"==typeof e?e:parseInt(`${e.split("+").pop()}`)))).filter((e=>!!e)),ca.registry.register({name:"commitMove",preconditionFn:()=>this.isMoving(),callback:()=>(this.finishMove(),!1),keyCodes:e,allowCollision:!0},!0),this.scrollCurrentElementIntoView(),this.moveIndicator=new Ic(this.draggable.workspace),this.repositionMoveIndicator(),!0}move(e,t){switch(e){case vc.UP:this.totalDelta.y-=this.stepDistance;break;case vc.DOWN:this.totalDelta.y+=this.stepDistance;break;case vc.LEFT:this.totalDelta.x-=this.stepDistance;break;case vc.RIGHT:this.totalDelta.x+=this.stepDistance}var i;return null==(i=this.dragger)||i.onDrag(t,this.totalPixelDelta()),this.updateTotalDelta(),this.scrollCurrentElementIntoView(),this.repositionMoveIndicator(),!0}finishMove(e){var t;return this.preDragEndCleanup(),null==(t=this.dragger)||t.onDragEnd(e,this.totalPixelDelta()),this.postDragEndCleanup(),!0}abortMove(e){var t;return this.preDragEndCleanup(),null==(t=this.dragger)||t.onDragRevert(e,this.totalPixelDelta()),this.postDragEndCleanup(),!0}setMoveDistance(e){this.stepDistance=e}getAllowedShortcuts(){return this.allowedShortcuts}setAllowedShortcuts(e){this.allowedShortcuts=e}repositionMoveIndicator(){Ze().then((()=>{var e,t,i,n=null==(e=this.draggable)?void 0:e.getBoundingRectangle();this.draggable&&"getBoundingRectangleWithoutChildren"in this.draggable&&(n=this.positionForBlockMoveIndicator(this.draggable)),n&&(null==(i=this.moveIndicator)||i.moveTo(null!=(t=this.draggable)&&t.workspace.RTL?n.left:n.right,n.top))}))}positionForBlockMoveIndicator(e){for(var t,i=e.workspace.getNavigator(),n=e;t=i.getInNode(n);)n=t;i=i.getSourceBlockFromNode(n),n=e.getBoundingRectangleWithoutChildren().getOrigin().y;for(var o;(null==(o=i)?void 0:o.getBoundingRectangleWithoutChildren().getOrigin().y)!==n;){let e,t;i=null!=(t=null==(e=i)?void 0:e.getParent())?t:null}var s,r;return null!=(r=null==(s=i)?void 0:s.getBoundingRectangleWithoutChildren())?r:e.getBoundingRectangleWithoutChildren()}preDragEndCleanup(){var e;ca.registry.unregister("commitMove"),null==(e=this.draggable)||e.getFocusableElement().removeEventListener("blur",this.blurListener)}postDragEndCleanup(){var e;null==(e=this.moveIndicator)||e.dispose(),this.startLocation=this.dragger=this.draggable=this.moveIndicator=void 0,this.totalDelta=new Da(0,0),this.moving=!1}totalPixelDelta(){var e,t,i=null!=(t=null==(e=this.draggable)?void 0:e.workspace.scale)?t:1;return new Da(this.totalDelta.x*i,this.totalDelta.y*i)}scrollCurrentElementIntoView(){if(this.draggable){var e=this.draggable.getBoundingRectangle();this.draggable.workspace.scrollBoundsIntoView(e)}}updateTotalDelta(){this.draggable&&this.startLocation&&(this.totalDelta=new Da(this.draggable.getRelativeToSurfaceXY().x-this.startLocation.x,this.draggable.getRelativeToSurfaceXY().y-this.startLocation.y))}};yc.mover=new yc;var Ac,kc=class{constructor(e,t,i,n){this.name=e,this.startHats=!1,this.blockStyles=t||Object.create(null),this.categoryStyles=i||Object.create(null),this.componentStyles=n||Object.create(null),this.fontStyle=Object.create(null),te(ya.THEME,e,this,!0)}getClassName(){return this.name+"-theme"}setBlockStyle(e,t){this.blockStyles[e]=t}setCategoryStyle(e,t){this.categoryStyles[e]=t}getComponentStyle(e){if(!(e=this.componentStyles[e]))return null;if("string"==typeof e){let t=this.getComponentStyle(e);if(t)return t}return`${e}`}setComponentStyle(e,t){this.componentStyles[e]=t}setFontStyle(e){this.fontStyle=e}setStartHats(e){this.startHats=e}static defineTheme(e,t){e=e.toLowerCase();var i=new kc(e),n=t.base;if(n){if("string"==typeof n){let e;n=null!=(e=ne(ya.THEME,n,void 0))?e:void 0}n instanceof kc&&(B(i,n),i.name=e)}return B(i.blockStyles,t.blockStyles),B(i.categoryStyles,t.categoryStyles),B(i.componentStyles,t.componentStyles),B(i.fontStyle,t.fontStyle),null!==t.startHats&&(i.startHats=t.startHats),i}},Sc=new kc("classic",{colour_blocks:{colourPrimary:"20"},list_blocks:{colourPrimary:"260"},logic_blocks:{colourPrimary:"210"},loop_blocks:{colourPrimary:"120"},math_blocks:{colourPrimary:"230"},procedure_blocks:{colourPrimary:"290"},text_blocks:{colourPrimary:"160"},variable_blocks:{colourPrimary:"330"},variable_dynamic_blocks:{colourPrimary:"310"},hat_blocks:{colourPrimary:"330",hat:"cap"}},{colour_category:{colour:"20"},list_category:{colour:"260"},logic_category:{colour:"210"},loop_category:{colour:"120"},math_category:{colour:"230"},procedure_category:{colour:"290"},text_category:{colour:"160"},variable_category:{colour:"330"},variable_dynamic_category:{colour:"310"}}),Oc=class{constructor(e){this.gridPattern=null,this.getMetrics=this.setMetrics=void 0;var t,i=null,n=!1,o=!1,s=!1,r=!1,a=!1,l=!1,h=!!e.readOnly;h||(i=Fe(null!=(t=e.toolbox)?t:null),n=Pe(i),o=void 0===(o=e.trashcan)?n:o,s=void 0===(s=e.collapse)?n:s,r=void 0===(r=e.comments)?n:r,a=void 0===(a=e.disable)?n:a,l=void 0===(l=e.sounds)||l),t=e.maxTrashcanContents,o?void 0===t&&(t=32):t=0;var u=!!e.rtl,c=e.horizontalLayout;void 0===c&&(c=!1);var d="end"!==e.toolboxPosition;d=c?d?Ya.TOP:Ya.BOTTOM:d===u?Ya.RIGHT:Ya.LEFT;var p=e.css;void 0===p&&(p=!0);var g="https://static.blockly.com/media/";e.media&&(g=e.media.endsWith("/")?e.media:e.media+"/");var E=e.oneBasedIndex;E=void 0===E||E;var T,_,f,m=e.renderer||"thrasos",b=e.plugins||{},C=e.modalInputs;void 0===C&&(C=!0),this.RTL=u,this.oneBasedIndex=E,this.collapse=s,this.comments=r,this.disable=a,this.readOnly=h,this.maxBlocks=e.maxBlocks||1/0,this.maxInstances=null!=(T=e.maxInstances)?T:null,this.modalInputs=C,this.pathToMedia=g,this.hasCategories=n,this.moveOptions=Oc.parseMoveOptions(e,n),this.hasScrollbars=!!this.moveOptions.scrollbars,this.hasTrashcan=o,this.maxTrashcanContents=t,this.hasSounds=l,this.hasCss=p,this.horizontalLayout=c,this.languageTree=i,this.gridOptions=Oc.parseGridOptions(e),this.zoomOptions=Oc.parseZoomOptions(e),this.toolboxPosition=d,this.theme=Oc.parseThemeOptions(e),this.renderer=m,this.rendererOverrides=null!=(_=e.rendererOverrides)?_:null,this.parentWorkspace=null!=(f=e.parentWorkspace)?f:null,this.plugins=b}static parseMoveOptions(e,t){var i=e.move||{},n={};return void 0===i.scrollbars&&void 0===e.scrollbars?n.scrollbars=t:"object"==typeof i.scrollbars?(n.scrollbars={horizontal:!!i.scrollbars.horizontal,vertical:!!i.scrollbars.vertical},n.scrollbars.horizontal&&n.scrollbars.vertical?n.scrollbars=!0:n.scrollbars.horizontal||n.scrollbars.vertical||(n.scrollbars=!1)):n.scrollbars=!!i.scrollbars||!!e.scrollbars,n.wheel=n.scrollbars&&void 0!==i.wheel?!!i.wheel:"object"==typeof n.scrollbars,n.drag=!(!n.scrollbars||void 0!==i.drag&&!i.drag),n}static parseZoomOptions(e){e=e.zoom||{};var t={};return t.controls=void 0!==e.controls&&!!e.controls,t.wheel=void 0!==e.wheel&&!!e.wheel,t.startScale=void 0===e.startScale?1:Number(e.startScale),t.maxScale=void 0===e.maxScale?3:Number(e.maxScale),t.minScale=void 0===e.minScale?.3:Number(e.minScale),t.scaleSpeed=void 0===e.scaleSpeed?1.2:Number(e.scaleSpeed),t.pinch=void 0===e.pinch?t.wheel||t.controls:!!e.pinch,t}static parseGridOptions(e){e=e.grid||{};var t={};return t.spacing=Number(e.spacing)||0,t.colour=e.colour||"#888",t.length=void 0===e.length?1:Number(e.length),t.snap=t.spacing>0&&!!e.snap,t}static parseThemeOptions(e){return"string"==typeof(e=e.theme||Sc)?ne(ya.THEME,e,void 0):e instanceof kc?e:kc.defineTheme(e.name||"builtin"+le(),e)}},Rc=class{constructor(e,t){this.bubble=e,this.workspace=t,this.startLoc=null}isMovable(){return!0}startDrag(){var e;return this.startLoc=this.bubble.getRelativeToSurfaceXY(),this.workspace.setResizesEnabled(!1),null==(e=this.workspace.getLayerManager())||e.moveToDragLayer(this.bubble),this.bubble.setDragging&&this.bubble.setDragging(!0),this.bubble}drag(e){this.bubble.moveDuringDrag(e)}endDrag(){var e;this.workspace.setResizesEnabled(!0),null==(e=this.workspace.getLayerManager())||e.moveOffDragLayer(this.bubble,100),this.bubble.setDragging(!1)}revertDrag(){this.startLoc&&this.bubble.moveDuringDrag(this.startLoc)}},wc=class{constructor(e,t,i,n,o){this.workspace=e,this.anchor=t,this.ownerRect=i,this.owner=o,this.size=new Fa(0,0),this.colour="#ffffff",this.disposed=!1,this.relativeLeft=this.relativeTop=0,this.dragStrategy=new Rc(this,this.workspace),this.ariaLabelProvider=null,this.id=le(),this.svgRoot=I(ea.G,{class:"blocklyBubble"},e.getBubbleCanvas()),e=I(ea.G,{class:"blocklyEmboss"},this.svgRoot),this.tail=I(ea.PATH,{class:"blocklyBubbleTail"},e),this.background=I(ea.RECT,{class:"blocklyDraggable",x:0,y:0,rx:Ac.BORDER_WIDTH,ry:Ac.BORDER_WIDTH},e),this.contentContainer=I(ea.G,{},this.svgRoot),this.focusableElement=null!=n?n:this.svgRoot,this.focusableElement.setAttribute("id",this.id),r(this.background,"pointerdown",this,this.onMouseDown),r(this.focusableElement,"keydown",this,this.onKeyDown),this.recomputeAriaContext()}dispose(){S(this.svgRoot),this.disposed=!0}setAnchorLocation(e,t=!1){this.anchor=e,t?this.positionByRect(this.ownerRect):this.positionRelativeToAnchor(),this.renderTail()}setPositionRelativeToAnchor(e,t){this.relativeLeft=e,this.relativeTop=t,this.positionRelativeToAnchor(),this.renderTail()}getSize(){return this.size}setSize(e,t=!1){e.width=Math.max(e.width,Ac.MIN_SIZE),e.height=Math.max(e.height,Ac.MIN_SIZE),this.size=e,this.background.setAttribute("width",`${e.width}`),this.background.setAttribute("height",`${e.height}`),t?this.positionByRect(this.ownerRect):this.positionRelativeToAnchor(),this.renderTail()}getColour(){return this.colour}setColour(e){this.colour=e,this.tail.setAttribute("fill",e),this.background.setAttribute("fill",e)}onMouseDown(e){var t;null==(t=this.workspace.getGesture(e))||t.handleBubbleStart(e,this),Zs.t().focusNode(this)}onKeyDown(e){"Escape"===e.key&&this.owner&&(this.owner.setBubbleVisible(!1),Zs.t().focusNode(this.owner))}positionRelativeToAnchor(){var e=this.anchor.x;e=this.workspace.RTL?e-(this.relativeLeft+this.size.width):e+this.relativeLeft,this.moveTo(e,this.relativeTop+this.anchor.y)}moveTo(e,t){this.svgRoot.setAttribute("transform",`translate(${e}, ${t})`)}moveBy(e,t){var i=this.getRelativeToSurfaceXY();this.moveTo(i.x+e,i.y+t)}positionByRect(e=new xa(0,0,0,0)){var t=this.workspace.getMetricsManager().getViewMetrics(!0),i=this.getOptimalRelativeLeft(t),n=this.getOptimalRelativeTop(t),o={x:i,y:-this.size.height-this.workspace.getRenderer().getConstants().MIN_BLOCK_HEIGHT},s={x:-this.size.width-30,y:n};n={x:e.getWidth(),y:n};var r={x:i,y:e.getHeight()};i=e.getWidth()<e.getHeight()?n:r,e=e.getWidth()<e.getHeight()?r:n,n=this.getOverlap(o,t),r=this.getOverlap(s,t);var a=this.getOverlap(i,t);t=this.getOverlap(e,t),n===(t=Math.max(n,r,a,t))?(this.relativeLeft=o.x,this.relativeTop=o.y):r===t?(this.relativeLeft=s.x,this.relativeTop=s.y):a===t?(this.relativeLeft=i.x,this.relativeTop=i.y):(this.relativeLeft=e.x,this.relativeTop=e.y),this.positionRelativeToAnchor()}getOverlap(e,t){var i=this.workspace.RTL?this.anchor.x-e.x-this.size.width:e.x+this.anchor.x;return e=e.y+this.anchor.y,Math.max(0,Math.min(1,(Math.min(i+this.size.width,t.left+t.width)-Math.max(i,t.left))*(Math.min(e+this.size.height,t.top+t.height)-Math.max(e,t.top))/(this.size.width*this.size.height)))}getOptimalRelativeLeft(e){var t=-this.size.width/4;if(this.size.width>e.width)return t;if(e=this.getWorkspaceViewRect(e),this.workspace.RTL){var i=this.anchor.x-t;i-this.size.width<e.left?t=-(e.left-this.anchor.x+this.size.width):i>e.right&&(t=-(e.right-this.anchor.x))}else{let n=(i=t+this.anchor.x)+this.size.width;i<e.left?t=e.left-this.anchor.x:n>e.right&&(t=e.right-this.anchor.x-this.size.width)}return t}getOptimalRelativeTop(e){var t=-this.size.height/4;if(this.size.height>e.height)return t;var i=this.anchor.y+t,n=i+this.size.height;return i<(e=this.getWorkspaceViewRect(e)).top?t=e.top-this.anchor.y:n>e.bottom&&(t=e.bottom-this.anchor.y-this.size.height),t}getWorkspaceViewRect(e){var t=e.top,i=e.top+e.height,n=e.left;return e=e.left+e.width,i-=this.getScrollbarThickness(),this.workspace.RTL?n-=this.getScrollbarThickness():e-=this.getScrollbarThickness(),new xa(t,i,n,e)}getScrollbarThickness(){return Ha.scrollbarThickness/this.workspace.scale}renderTail(){var e,t=[],i=this.size.width/2,n=this.size.height/2,o=-this.relativeLeft,s=-this.relativeTop;if(i===o&&n===s)t.push("M "+i+","+n);else{s-=n,o-=i,this.workspace.RTL&&(o*=-1);var r=Math.sqrt(s*s+o*o),a=Math.acos(o/r);s<0&&(a=2*Math.PI-a);var l=a+Math.PI/2;l>2*Math.PI&&(l-=2*Math.PI);var h=Math.sin(l);let e=Math.cos(l),u=(this.size.width+this.size.height)/Ac.TAIL_THICKNESS;u=Math.min(u,this.size.width,this.size.height)/4,o=i+(l=1-Ac.ANCHOR_RADIUS/r)*o,s=n+l*s,l=i+u*e;let c=n+u*h;i-=u*e,n-=u*h,(h=a+(h=ri(this.workspace.RTL?-Ac.TAIL_ANGLE:Ac.TAIL_ANGLE)))>2*Math.PI&&(h-=2*Math.PI),a=Math.sin(h)*r/Ac.TAIL_BEND,r=Math.cos(h)*r/Ac.TAIL_BEND,t.push("M"+l+","+c),t.push("C"+(l+r)+","+(c+a)+" "+o+","+s+" "+o+","+s),t.push("C"+o+","+s+" "+(i+r)+","+(n+a)+" "+i+","+n)}t.push("z"),null==(e=this.tail)||e.setAttribute("d",t.join(" "))}bringToFront(){var e,t=null==(e=this.svgRoot)?void 0:e.parentNode;return!(!this.svgRoot||(null==t?void 0:t.lastChild)===this.svgRoot||(null==t||t.appendChild(this.svgRoot),0))}getRelativeToSurfaceXY(){return new Da(this.workspace.RTL?-this.relativeLeft+this.anchor.x-this.size.width:this.anchor.x+this.relativeLeft,this.anchor.y+this.relativeTop)}getBoundingRectangle(){var e=this.getRelativeToSurfaceXY();return new xa(e.y,e.y+this.size.height,e.x,e.x+this.size.width)}getSvgRoot(){return this.svgRoot}moveDuringDrag(e){this.moveTo(e.x,e.y),this.relativeLeft=this.workspace.RTL?this.anchor.x-e.x-this.size.width:e.x-this.anchor.x,this.relativeTop=e.y-this.anchor.y,this.renderTail()}setDragging(){}setDeleteStyle(){}isDeletable(){return!1}showContextMenu(){}isMovable(){return!0}startDrag(){return this.dragStrategy.startDrag()}drag(e){this.dragStrategy.drag(e)}endDrag(){this.dragStrategy.endDrag()}revertDrag(){this.dragStrategy.revertDrag()}select(){z(this)}unselect(){z(null)}getFocusableElement(){return this.focusableElement}getFocusableTree(){return this.workspace}onNodeFocus(){this.select(),this.bringToFront();var e=this.getRelativeToSurfaceXY(),t=this.getSize();e=new xa(e.y,e.y+t.height,e.x,e.x+t.width),this.workspace.scrollBoundsIntoView(e)}onNodeBlur(){this.unselect()}canBeFocused(){return!0}getOwner(){return this.owner}recomputeAriaContext(){var e=this.getFocusableElement();if(e){_(e,Hr.GROUP);var t,i=null==(t=this.getAriaLabel())?void 0:t.trim();f(e,$r.LABEL,i||Zs.C.BUBBLE_LABEL_DEFAULT)}}setAriaLabelProvider(e){this.ariaLabelProvider=e,this.recomputeAriaContext()}getAriaLabel(){if(this.ariaLabelProvider){if("string"==typeof this.ariaLabelProvider)return this.ariaLabelProvider;if("function"==typeof this.ariaLabelProvider)return this.ariaLabelProvider(this)}return null}};Ac=wc,wc.BORDER_WIDTH=6,wc.DOUBLE_BORDER=2*Ac.BORDER_WIDTH,wc.MIN_SIZE=Ac.DOUBLE_BORDER,wc.TAIL_THICKNESS=1,wc.TAIL_ANGLE=20,wc.TAIL_BEND=4,wc.ANCHOR_RADIUS=8;var Lc=class extends wc{constructor(e,t,i,n,o){var s,r;super(t,i,n,void 0,o),this.workspace=t,this.anchor=i,this.ownerRect=n,this.owner=o,this.autoLayout=!0,t=new Oc(e),this.validateWorkspaceOptions(t),this.svgDialog=I(ea.SVG,{x:wc.BORDER_WIDTH,y:wc.BORDER_WIDTH},this.contentContainer),e.parentWorkspace=this.workspace,this.miniWorkspace=this.newWorkspaceSvg(new Oc(e)),this.miniWorkspace.internalIsMutator=!0,e=this.miniWorkspace.createDom("blocklyMutatorBackground"),this.svgDialog.appendChild(e),t.languageTree&&(e.insertBefore(this.miniWorkspace.addFlyout(ea.G),this.miniWorkspace.getCanvas()),null==(e=this.miniWorkspace.getFlyout())||e.init(this.miniWorkspace),null==e||e.show(t.languageTree)),N(this.svgRoot,"blocklyMiniWorkspaceBubble"),this.miniWorkspace.addChangeListener(this.onWorkspaceChange.bind(this)),null==(s=this.miniWorkspace.getFlyout())||null==(r=s.getWorkspace())||r.addChangeListener(this.onWorkspaceChange.bind(this)),this.updateBubbleSize()}dispose(){this.miniWorkspace.dispose(),super.dispose()}getWorkspace(){return this.miniWorkspace}addWorkspaceChangeListener(e){this.miniWorkspace.addChangeListener(e)}validateWorkspaceOptions(e){if(e.hasCategories)throw Error("The miniworkspace bubble does not support toolboxes with categories");if(e.hasTrashcan)throw Error("The miniworkspace bubble does not support trashcans");if(e.zoomOptions.controls||e.zoomOptions.wheel||e.zoomOptions.pinch)throw Error("The miniworkspace bubble does not support zooming");if(e.moveOptions.scrollbars||e.moveOptions.wheel||e.moveOptions.drag)throw Error("The miniworkspace bubble does not allow scrolling/moving the workspace");if(e.horizontalLayout)throw Error("The miniworkspace bubble does not support horizontal layouts")}onWorkspaceChange(){this.bumpBlocksIntoBounds(),this.updateBubbleSize()}bumpBlocksIntoBounds(){if(!this.miniWorkspace.isDragging()||yc.mover.isMoving())for(let e of this.miniWorkspace.getTopBlocks(!1)){let t=e.getRelativeToSurfaceXY();if(t.y<20&&e.moveBy(0,20-t.y),e.RTL){let i=-20,n=this.miniWorkspace.getFlyout();n&&(i-=n.getWidth()),t.x>i&&e.moveBy(i-t.x,0)}else t.x<20&&e.moveBy(20-t.x,0)}}updateBubbleSize(){if(!this.miniWorkspace.isDragging()||yc.mover.isMoving()){this.autoLayout&&(this.autoLayout=!yc.mover.isMoving());var e=this.getSize(),t=this.calculateWorkspaceSize();Math.abs(e.width-t.width)<Lc.MINIMUM_VIEW_CHANGE&&Math.abs(e.height-t.height)<Lc.MINIMUM_VIEW_CHANGE||(this.svgDialog.setAttribute("width",`${t.width}px`),this.svgDialog.setAttribute("height",`${t.height}px`),this.miniWorkspace.setCachedParentSvgSize(t.width,t.height),this.miniWorkspace.RTL&&this.miniWorkspace.getCanvas().setAttribute("transform",`translate(${t.width}, 0)`),this.setSize(new Fa(t.width+wc.DOUBLE_BORDER,t.height+wc.DOUBLE_BORDER),this.autoLayout),this.miniWorkspace.resize(),this.miniWorkspace.recordDragTargets())}}calculateWorkspaceSize(){var e=this.miniWorkspace.getCanvas().getBBox(),t=e.width+Lc.MARGIN;e=e.height+Lc.MARGIN;var i=this.miniWorkspace.getFlyout();if(i){let n=i.getWorkspace().getMetricsManager().getScrollMetrics();e=Math.max(e,n.height+20),t+=i.getWidth()}return new Fa(t,e)}updateBlockStyles(){for(var e of this.miniWorkspace.getAllBlocks(!1))e.setStyle(e.getStyleName());var t;if(e=null==(t=this.miniWorkspace.getFlyout())?void 0:t.getWorkspace())for(let t of e.getAllBlocks(!1))t.setStyle(t.getStyleName())}moveDuringDrag(e){super.moveDuringDrag(e),this.autoLayout=!1}moveTo(e,t){super.moveTo(e,t),this.miniWorkspace.recordDragTargets()}newWorkspaceSvg(){throw Error("The implementation of newWorkspaceSvg should be monkey-patched in by blockly.ts")}performAction(){Zs.t().focusTree(this.getWorkspace())}};Lc.MINIMUM_VIEW_CHANGE=10,Lc.MARGIN=3*wc.DOUBLE_BORDER;var Dc=class{constructor(e){this.sourceBlock=e,this.offsetInBlock=new Da(0,0),this.workspaceLocation=new Da(0,0),this.svgRoot=null,this.tooltip=e,this.id=le()}getType(){throw Error("Icons must implement getType")}initView(e){if(!this.svgRoot){var t=this.sourceBlock;this.svgRoot=I(ea.G,{class:"blocklyIconGroup",id:this.id}),t.getSvgRoot().appendChild(this.svgRoot),this.updateSvgRootOffset(),r(this.svgRoot,"pointerdown",this,e),this.svgRoot.tooltip=this,Di(this.svgRoot),this.recomputeAriaContext()}}dispose(){this.svgRoot&&(xi(this.svgRoot),delete this.svgRoot.tooltip,S(this.svgRoot)),this.tooltip=""}getWeight(){return-1}getSize(){return new Fa(0,0)}setTooltip(e){this.tooltip=null!=e?e:this.sourceBlock}getTooltip(){return this.tooltip}applyColour(){}updateEditable(){}updateCollapsed(){this.svgRoot&&(this.sourceBlock.isCollapsed()?this.svgRoot.style.display="none":this.svgRoot.style.display="block",pt(this)&&this.setBubbleVisible(!1))}hideForInsertionMarker(){this.svgRoot&&(this.svgRoot.style.display="none")}isShownWhenCollapsed(){return!1}setOffsetInBlock(e){this.offsetInBlock=e,this.updateSvgRootOffset()}updateSvgRootOffset(){var e;null==(e=this.svgRoot)||e.setAttribute("transform",`translate(${this.offsetInBlock.x}, ${this.offsetInBlock.y})`)}onLocationChange(e){this.workspaceLocation=Da.sum(e,this.offsetInBlock)}onClick(){}isClickableInFlyout(){return!0}getFocusableElement(){var e=this.svgRoot;if(!e)throw Error("Attempting to focus uninitialized icon.");return e}getFocusableTree(){return this.sourceBlock.workspace}onNodeFocus(){var e=this.sourceBlock.getBoundingRectangle();e=new xa(e.top+this.offsetInBlock.y,e.top+this.offsetInBlock.y+this.getSize().height,e.left+this.offsetInBlock.x,e.left+this.offsetInBlock.x+this.getSize().width),this.sourceBlock.workspace.scrollBoundsIntoView(e)}onNodeBlur(){}canBeFocused(){return!0}performAction(){this.onClick(),Ze().then((()=>{if(pt(this)&&this.bubbleIsVisible()){let e=this.getBubble();e&&Zs.t().focusNode(e)}}))}getSourceBlock(){return this.sourceBlock}showContextMenu(e){this.getSourceBlock().showContextMenu(e)}recomputeAriaContext(){var e=this.getFocusableElement();if(e){var t,i,n=null==(t=this.sourceBlock.workspace.targetWorkspace)?void 0:t.getFlyout();n&&!this.isClickableInFlyout(n.autoClose)?f(e,$r.HIDDEN,!0):(m(e,$r.HIDDEN),_(e,Hr.BUTTON),t=null!=(i=this.getAriaLabel())?i:Zs.C.ICON_LABEL_DEFAULT,f(e,$r.LABEL,t))}}getAriaLabel(){return null}};Zs.sh=class extends Dc{constructor(e,t){super(t),this.flyoutBlockTypes=e,this.sourceBlock=t,this.saveConnectionsListener=this.updateWorkspacePid=this.rootBlock=this.miniWorkspaceBubble=null}getType(){return Zs.sh.TYPE}initView(e){this.svgRoot||(super.initView(e),I(ea.RECT,{class:"blocklyIconShape",rx:"4",ry:"4",height:"16",width:"16"},this.svgRoot),I(ea.PATH,{class:"blocklyIconSymbol",d:"m4.203,7.296 0,1.368 -0.92,0.677 -0.11,0.41 0.9,1.559 0.41,0.11 1.043,-0.457 1.187,0.683 0.127,1.134 0.3,0.3 1.8,0 0.3,-0.299 0.127,-1.138 1.185,-0.682 1.046,0.458 0.409,-0.11 0.9,-1.559 -0.11,-0.41 -0.92,-0.677 0,-1.366 0.92,-0.677 0.11,-0.41 -0.9,-1.559 -0.409,-0.109 -1.046,0.458 -1.185,-0.682 -0.127,-1.138 -0.3,-0.299 -1.8,0 -0.3,0.3 -0.126,1.135 -1.187,0.682 -1.043,-0.457 -0.41,0.11 -0.899,1.559 0.108,0.409z"},this.svgRoot),I(ea.CIRCLE,{class:"blocklyIconShape",r:"2.7",cx:"8",cy:"8"},this.svgRoot),N(this.svgRoot,"blocklyMutatorIcon"))}dispose(){var e;super.dispose(),null==(e=this.miniWorkspaceBubble)||e.dispose()}getWeight(){return Zs.sh.WEIGHT}getSize(){return new Fa(17,17)}applyColour(){var e,t;super.applyColour(),null==(e=this.miniWorkspaceBubble)||e.setColour(this.sourceBlock.getColour()),null==(t=this.miniWorkspaceBubble)||t.updateBlockStyles()}updateCollapsed(){super.updateCollapsed(),this.sourceBlock.isCollapsed()&&this.setBubbleVisible(!1)}onLocationChange(e){var t;super.onLocationChange(e),null==(t=this.miniWorkspaceBubble)||t.setAnchorLocation(this.getAnchorLocation())}onClick(){super.onClick(),this.sourceBlock.isEditable()&&this.setBubbleVisible(!this.bubbleIsVisible())}isClickableInFlyout(){return!1}bubbleIsVisible(){return!!this.miniWorkspaceBubble}setBubbleVisible(e){var t=this;return(0,Qs.asyncExecutePromiseGeneratorFunction)((function*(){if(t.bubbleIsVisible()!==e){if(yield Ze(),e){let e;t.miniWorkspaceBubble=new Lc(t.getMiniWorkspaceConfig(),t.sourceBlock.workspace,t.getAnchorLocation(),t.getBubbleOwnerRect(),t),t.applyColour(),t.createRootBlock(),t.addSaveConnectionsListener(),null==(e=t.miniWorkspaceBubble)||e.addWorkspaceChangeListener(t.createMiniWorkspaceChangeListener()),t.miniWorkspaceBubble.setAriaLabelProvider(Zs.C.WORKSPACE_LABEL_MUTATOR_WORKSPACE)}else{let e;null==(e=t.miniWorkspaceBubble)||e.dispose(),t.miniWorkspaceBubble=null,t.saveConnectionsListener&&t.sourceBlock.workspace.removeChangeListener(t.saveConnectionsListener),t.saveConnectionsListener=null}ue(new(_e(Fr.BUBBLE_OPEN))(t.sourceBlock,e,"mutator")),t.recomputeAriaContext()}}))}getBubble(){return this.miniWorkspaceBubble}getMiniWorkspaceConfig(){var e,t={disable:!1,media:this.sourceBlock.workspace.options.pathToMedia,rtl:this.sourceBlock.RTL,renderer:this.sourceBlock.workspace.options.renderer,rendererOverrides:null!=(e=this.sourceBlock.workspace.options.rendererOverrides)?e:void 0};return this.flyoutBlockTypes.length&&(t.toolbox={kind:"flyoutToolbox",contents:this.flyoutBlockTypes.map((e=>({kind:"block",type:e})))}),t}getAnchorLocation(){return Da.sum(this.workspaceLocation,new Da(8.5,8.5))}getBubbleOwnerRect(){var e=this.sourceBlock.getSvgRoot().getBBox();return new xa(e.y,e.y+e.height,e.x,e.x+e.width)}createRootBlock(){if(!this.sourceBlock.decompose)throw Error("Blocks with mutator icons must include a decompose method");for(var e of(this.rootBlock=this.sourceBlock.decompose(this.miniWorkspaceBubble.getWorkspace()),this.rootBlock.getDescendants(!1)))e.queueRender();var t,i,n,o;this.rootBlock.setMovable(!1),this.rootBlock.setDeletable(!1),e=null!=(o=null==(t=this.miniWorkspaceBubble)||null==(i=t.getWorkspace())||null==(n=i.getFlyout())?void 0:n.getWidth())?o:0,this.rootBlock.moveBy(this.rootBlock.RTL?-(e+16):16,16)}addSaveConnectionsListener(){this.sourceBlock.saveConnections&&this.rootBlock&&(this.saveConnectionsListener=()=>{this.sourceBlock.saveConnections&&this.rootBlock&&this.sourceBlock.saveConnections(this.rootBlock)},this.saveConnectionsListener(),this.sourceBlock.workspace.addChangeListener(this.saveConnectionsListener))}createMiniWorkspaceChangeListener(){return e=>{Zs.sh.isIgnorableMutatorEvent(e)||this.updateWorkspacePid||(this.updateWorkspacePid=setTimeout((()=>{this.updateWorkspacePid=null,this.recomposeSourceBlock()}),0))}}static isIgnorableMutatorEvent(e){return e.isUiEvent||e.type===Fr.BLOCK_CREATE||e.type===Fr.BLOCK_CHANGE&&"disabled"===e.element}recomposeSourceBlock(){if(this.rootBlock){if(!this.sourceBlock.compose)throw Error("Blocks with mutator icons must include a compose method");var e=Zs.gd;e||Zs.B(!0);var t=Gl.getExtraBlockState_(this.sourceBlock);this.sourceBlock.compose(this.rootBlock);var i=Gl.getExtraBlockState_(this.sourceBlock);t!==i&&ue(new(_e(Fr.BLOCK_CHANGE))(this.sourceBlock,"mutation",null,t,i)),Zs.B(e)}}getWorkspace(){var e;return null==(e=this.miniWorkspaceBubble)?void 0:e.getWorkspace()}getAriaLabel(){return this.bubbleIsVisible()?Zs.C.ICON_LABEL_MUTATOR_OPEN:Zs.C.ICON_LABEL_MUTATOR_CLOSED}},Zs.sh.TYPE=Hl.MUTATOR,Zs.sh.WEIGHT=1;var xc=Object.create(null),Fc={allExtensions:xc};Zs.oh("parent_tooltip_when_inline",(function(){var e=this.tooltip;this.setTooltip(function(){var t=this.getParent();return t&&t.getInputsInline()&&t.tooltip||e}.bind(this))}));var Mc={TEST_ONLY:Fc};Mc.apply=xn,Mc.buildTooltipForDropdown=Zs.yh,Mc.buildTooltipWithFieldText=Zs.Ah,Mc.isRegistered=Dn,Mc.register=Zs.oh,Mc.registerMixin=Zs.ph,Mc.registerMutator=Zs.th,Mc.runAfterPageLoad=function(e){if("object"!=typeof document)throw Error("runAfterPageLoad() requires browser document.");if("complete"===document.readyState)e();else{let t=setInterval((function(){"complete"===document.readyState&&(clearInterval(t),e())}),10)}},Mc.unregister=function(e){Dn(e)?delete xc[e]:console.warn('No extension mapping for name "'+e+'" found to unregister')};var Pc={};Pc.arc=jn,Pc.curve=Vn,Pc.line=qn,Pc.lineOnAxis=$n,Pc.lineTo=Wn,Pc.moveBy=Gn,Pc.moveTo=Hn,Pc.point=Un;var Bc={};Bc.Coordinate=Da,Bc.KeyCodes=bc,Bc.Rect=xa,Bc.Size=Fa,Bc.Svg=ea,Bc.aria=Zr,Bc.array=Ar,Bc.browserEvents=yr,Bc.colour=Hu,Bc.deprecation=Ea,Bc.dom=ra,Bc.extensions=Mc,Bc.idGenerator=La,Bc.math=cu,Bc.object=ua,Bc.parsing=Gu,Bc.string=Au,Bc.style=Pa,Bc.svgMath=Va,Bc.svgPaths=Pc,Bc.toolbox=Ja,Bc.userAgent=Nr,Bc.xml=Xa;var Uc=class extends wc{constructor(e,t,i,n){super(e,t,i,void 0,n),this.workspace=e,this.anchor=t,this.ownerRect=i,this.owner=n,this.resizePointerMoveListener=this.resizePointerUpListener=null,this.sizeChangeListeners=[],this.locationChangeListeners=[],this.DEFAULT_SIZE=new Fa(160+wc.DOUBLE_BORDER,80+wc.DOUBLE_BORDER),this.MIN_SIZE=new Fa(45+wc.DOUBLE_BORDER,20+wc.DOUBLE_BORDER),this.editable=!0,this.textChangeListener=()=>{this.recomputeAriaContext()},N(this.svgRoot,"blocklyTextInputBubble"),this.editor=new cc(e,this.id,(()=>{Zs.t().focusNode(this)})),this.contentContainer.appendChild(this.editor.getDom()),this.resizeGroup=this.createResizeHandle(this.svgRoot,e),this.setSize(this.DEFAULT_SIZE,!0),this.addTextChangeListener(this.textChangeListener)}getText(){return this.editor.getText()}setText(e){this.editor.setText(e)}setEditable(e){this.editable=e,this.editor.setEditable(e)}isEditable(){return this.editable}addTextChangeListener(e){this.editor.addTextChangeListener(e)}addSizeChangeListener(e){this.sizeChangeListeners.push(e)}addLocationChangeListener(e){this.locationChangeListeners.push(e)}createResizeHandle(e,t){return e=I(ea.IMAGE,{class:"blocklyResizeHandle",href:`${t.options.pathToMedia}resize-handle.svg`},e),r(e,"pointerdown",this,this.onResizePointerDown),e}setSize(e,t=!1){e.width=Math.max(e.width,this.MIN_SIZE.width),e.height=Math.max(e.height,this.MIN_SIZE.height);var i=e.width-wc.DOUBLE_BORDER,n=e.height-wc.DOUBLE_BORDER;this.editor.updateSize(new Fa(i,n),new Fa(0,0)),this.editor.getDom().setAttribute("x",""+wc.DOUBLE_BORDER/2),this.editor.getDom().setAttribute("y",""+wc.DOUBLE_BORDER/2),this.resizeGroup.setAttribute("y",`${n}`),this.workspace.RTL?this.resizeGroup.setAttribute("x",""+-wc.DOUBLE_BORDER):this.resizeGroup.setAttribute("x",`${i}`),super.setSize(e,t),this.onSizeChange()}getSize(){return super.getSize()}moveDuringDrag(e){super.moveDuringDrag(e),this.onLocationChange()}setPositionRelativeToAnchor(e,t){super.setPositionRelativeToAnchor(e,t),this.onLocationChange()}positionByRect(e=new xa(0,0,0,0)){super.positionByRect(e),this.onLocationChange()}onResizePointerDown(e){this.bringToFront(),u(e)||(_n(this.workspace,e,new Da(this.workspace.RTL?-this.getSize().width:this.getSize().width,this.getSize().height)),this.resizePointerUpListener=r(document,"pointerup",this,this.onResizePointerUp),this.resizePointerMoveListener=r(document,"pointermove",this,this.onResizePointerMove),this.workspace.hideChaff()),e.stopPropagation()}onResizePointerUp(){dr=null,this.resizePointerUpListener&&(l(this.resizePointerUpListener),this.resizePointerUpListener=null),this.resizePointerMoveListener&&(l(this.resizePointerMoveListener),this.resizePointerMoveListener=null)}onResizePointerMove(e){e=fn(this.workspace,e),this.setSize(new Fa(this.workspace.RTL?-e.x:e.x,e.y),!1),this.onSizeChange()}onSizeChange(){for(let e of this.sizeChangeListeners)e()}onLocationChange(){for(let e of this.locationChangeListeners)e()}getEditor(){return this.editor}performAction(){Zs.t().focusNode(this.getEditor())}dispose(){super.dispose(),this.editor.removeTextChangeListener(this.textChangeListener)}};g("\n.blocklyTextInputBubble .blocklyTextarea {\n background-color: var(--commentFillColour);\n border: 0;\n box-sizing: border-box;\n display: block;\n outline: 0;\n padding: 5px;\n resize: none;\n width: 100%;\n height: 100%;\n}\n");var Vc=class{constructor(e){this.connectionChecker=e,this.connections=[],this.bulkCounter=0}addConnection(e,t){t=this.calculateIndexForYPos(t),this.connections.splice(t,0,e)}findIndexOfConnection(e,t){if(!this.connections.length)return-1;var i=this.calculateIndexForYPos(t);if(i>=this.connections.length)return-1;t=e.y;for(var n=i;n>=0&&this.connections[n].y===t;){if(this.connections[n]===e)return n;n--}for(n=i;n<this.connections.length&&this.connections[n].y===t;){if(this.connections[n]===e)return n;n++}return-1}calculateIndexForYPos(e){if(!this.connections.length)return 0;for(var t=0,i=this.connections.length;t<i;){let n=Math.floor((t+i)/2);if(this.connections[n].y<e)t=n+1;else{if(!(this.connections[n].y>e)){t=n;break}i=n}}return t}removeConnection(e,t){if(-1===(e=this.findIndexOfConnection(e,t)))throw Error("Unable to find connection in connectionDB.");this.connections.splice(e,1)}reorderConnection(e,t){0===this.bulkCounter&&(this.removeConnection(e,e.y),this.addConnection(e,t))}getNeighbours(e,t){function i(e){var i=o-n[e].x,r=s-n[e].y;return Math.sqrt(i*i+r*r)<=t&&l.push(n[e]),r<t}var n=this.connections,o=e.x,s=e.y;e=0;for(var r=n.length-2,a=r;e<a;)n[a].y<s?e=a:r=a,a=Math.floor((e+r)/2);var l=[];if(r=e=a,n.length){for(;e>=0&&i(e);)e--;do{r++}while(r<n.length&&i(r))}return l}isInYRange(e,t,i){return Math.abs(this.connections[e].y-t)<=i}searchForClosest(e,t,i){if(!this.connections.length)return{connection:null,radius:t};var n=e.y,o=e.x;e.x=o+i.x,e.y=n+i.y;var s=this.calculateIndexForYPos(e.y);i=null;for(var r,a=t,l=s-1;l>=0&&this.isInYRange(l,e.y,t);)r=this.connections[l],this.connectionChecker.canConnect(e,r,!0,a)&&(i=r,a=r.distanceFrom(e)),l--;for(;s<this.connections.length&&this.isInYRange(s,e.y,t);)r=this.connections[s],this.connectionChecker.canConnect(e,r,!0,a)&&(i=r,a=r.distanceFrom(e)),s++;return e.x=o,e.y=n,{connection:i,radius:a}}beginBulkUpdates(){this.bulkCounter++}endBulkUpdates(){if(0===this.bulkCounter)throw Error("Bulk updates are already ended.");this.bulkCounter--,0===this.bulkCounter&&this.reorderConnections()}reorderConnections(){this.connections.sort(((e,t)=>e.y-t.y))}static init(e){var t=[];return t[Xl.INPUT_VALUE]=new Vc(e),t[Xl.OUTPUT_VALUE]=new Vc(e),t[Xl.NEXT_STATEMENT]=new Vc(e),t[Xl.PREVIOUS_STATEMENT]=new Vc(e),t}},Hc=class{constructor(e,t){if(this.type=t,this.targetConnection=null,this.disposed=!1,this.shadowDom=this.check=null,this.y=this.x=0,this.shadowState=null,this.sourceBlock_=e,e.id.includes("_connection"))throw Error(`Connection ID indicator is contained in block ID. This will cause problems with focus: ${e.id}.`);this.id=`${e.id}_connection_${le()}`}connect_(e){var t=Xl.INPUT_VALUE,i=this.getSourceBlock(),n=e.getSourceBlock();if(e.isConnected()&&e.disconnectInternal(!1),this.isConnected()){let e=this.stashShadowState(),t=this.targetBlock();if(t.isShadow())t.dispose(!1);else{this.disconnectInternal();var o=t}this.applyShadowState(e)}if(Ee()){var s=new(_e(Fr.BLOCK_MOVE))(n);s.setReason(["connect"])}if(!this||!e)throw Error("Cannot connect null connections.");this.targetConnection=e,e.targetConnection=this,n.setParent(i),s&&(s.recordNew(),ue(s)),o&&(e=this.type===t?o.outputConnection:o.previousConnection)&&((n=Hc.getConnectionForOrphanedConnection(n,e))?e.connect(n):e.onFailedConnect(this))}dispose(){if(this.isConnected()){this.isSuperior()&&this.setShadowStateInternal();let e=this.targetBlock();e&&!e.isDeadOrDying()&&e.unplug()}this.disposed=!0}getSourceBlock(){return this.sourceBlock_}isSuperior(){return this.type===Xl.INPUT_VALUE||this.type===Xl.NEXT_STATEMENT}isConnected(){return!!this.targetConnection}getConnectionChecker(){return this.sourceBlock_.workspace.connectionChecker}onFailedConnect(){}connect(e){if(this.targetConnection===e)return!0;if(this.getConnectionChecker().canConnect(this,e,!1)){let t=Zs.gd;t||Zs.B(!0),this.isSuperior()?this.connect_(e):e.connect_(this),Zs.B(t)}return this.isConnected()}disconnect(){this.disconnectInternal()}disconnectInternal(e=!0){var{parentConnection:t,childConnection:i}=this.getParentAndChildConnections();if(!t||!i)throw Error("Source connection not connected.");var n=Zs.gd;if(n||Zs.B(!0),Ee()){var o=new(_e(Fr.BLOCK_MOVE))(i.getSourceBlock());o.setReason(["disconnect"])}var s=this.targetConnection;s&&(s.targetConnection=null),this.targetConnection=null,e&&i.getSourceBlock().setParent(null),o&&(o.recordNew(),ue(o)),i.getSourceBlock().isShadow()||t.respawnShadow_(),Zs.B(n)}getParentAndChildConnections(){return this.targetConnection?this.isSuperior()?{parentConnection:this,childConnection:this.targetConnection}:{parentConnection:this.targetConnection,childConnection:this}:{}}respawnShadow_(){this.createShadowBlock(!0)}reconnect(e,t){return!(this.getSourceBlock().isDeadOrDying()||(t=null==(i=e.getInput(t))?void 0:i.connection,(i=this.targetBlock())&&i!==e||!t||t.targetConnection===this||(t.isConnected()&&t.disconnect(),t.connect(this),0)));var i}targetBlock(){if(this.isConnected()){let e,t;return null!=(t=null==(e=this.targetConnection)?void 0:e.getSourceBlock())?t:null}return null}onCheckChanged_(){!this.isConnected()||this.targetConnection&&this.getConnectionChecker().canConnect(this,this.targetConnection,!1)||(this.isSuperior()?this.targetBlock():this.sourceBlock_).unplug()}setCheck(e){return e?(Array.isArray(e)||(e=[e]),this.check=e,this.onCheckChanged_()):this.check=null,this}getCheck(){return this.check}setShadowDom(e){this.setShadowStateInternal({shadowDom:e})}getShadowDom(e){return e&&this.targetBlock().isShadow()?vn(this.targetBlock()):this.shadowDom}setShadowState(e){this.setShadowStateInternal({shadowState:e})}getShadowState(e){return e&&this.targetBlock()&&this.targetBlock().isShadow()?Dt(this.targetBlock()):this.shadowState}neighbours(){return[]}getParentInput(){var e=null,t=this.sourceBlock_.inputList;for(let i=0;i<t.length;i++)if(t[i].connection===this){e=t[i];break}return e}toString(){var e=this.sourceBlock_;if(!e)return"Orphan Connection";if(e.outputConnection===this)var t="Output Connection of ";else if(e.previousConnection===this)t="Previous Connection of ";else if(e.nextConnection===this)t="Next Connection of ";else{t=null;for(let i,n=0;i=e.inputList[n];n++)if(i.connection===this){t=i;break}if(!t)return console.warn("Connection not actually connected to sourceBlock_"),"Orphan Connection";t='Input "'+t.name+'" connection on '}return t+e.toDevString()}stashShadowState(){var e=this.getShadowDom(!0),t=this.getShadowState(!0);return this.shadowState=this.shadowDom=null,{shadowDom:e,shadowState:t}}applyShadowState({shadowDom:e,shadowState:t}){this.shadowDom=e,this.shadowState=t}setShadowStateInternal({shadowDom:e=null,shadowState:t=null}={}){this.shadowDom=e,this.shadowState=t,this.getSourceBlock().isDeadOrDying()||((e=this.targetBlock())?e.isShadow()?(e.dispose(!1),this.respawnShadow_(),this.targetBlock()&&this.targetBlock().isShadow()&&this.serializeShadow(this.targetBlock())):(e=this.createShadowBlock(!1),this.serializeShadow(e),e&&e.dispose(!1)):(this.respawnShadow_(),this.targetBlock()&&this.targetBlock().isShadow()&&this.serializeShadow(this.targetBlock())))}createShadowBlock(e){var t=this.getSourceBlock(),i=this.getShadowState(),n=this.getShadowDom();if(t.isDeadOrDying()||!i&&!n)return null;if(i)return Mt(i,t.workspace,{parentConnection:e?this:void 0,isShadow:!0,recordUndo:!1});if(n){if(t=An(n,t.workspace),e)if(this.type===Xl.INPUT_VALUE){if(!t.outputConnection)throw Error("Shadow block is missing an output connection");if(!this.connect(t.outputConnection))throw Error("Could not connect shadow block to connection")}else{if(this.type!==Xl.NEXT_STATEMENT)throw Error("Cannot connect a shadow block to a previous/output connection");if(!t.previousConnection)throw Error("Shadow block is missing previous connection");if(!this.connect(t.previousConnection))throw Error("Could not connect shadow block to connection")}return t}return null}serializeShadow(e){e&&(this.shadowDom=vn(e),this.shadowState=Dt(e))}static getConnectionForOrphanedConnection(e,t){if(t.type===Xl.OUTPUT_VALUE){e:{t=t.getSourceBlock();for(var i;i=zn(e,t);)if(!(e=i.targetBlock())||e.isShadow()){t=i;break e}t=null}return t}return e=e.lastConnectionInStack(!0),i=t.getConnectionChecker(),e&&i.canConnect(t,e,!1)?e:null}};Hc.CAN_CONNECT=0,Hc.REASON_SELF_CONNECTION=1,Hc.REASON_WRONG_TYPE=2,Hc.REASON_TARGET_NULL=3,Hc.REASON_CHECKS_FAILED=4,Hc.REASON_DIFFERENT_WORKSPACES=5,Hc.REASON_SHADOW_PARENT=6,Hc.REASON_DRAG_CHECKS_FAILED=7,Hc.REASON_PREVIOUS_AND_OUTPUT=8;var Gc,Wc=class extends Error{constructor(e){super(`Tried to append an icon of type ${e.getType()} when an icon of that type already exists on the block. Use getIcon to access the existing icon.`),this.icon=e}},qc={};qc.DuplicateIconType=Wc,(Gc=Zs.Xn||(Zs.Xn={}))[Gc.LEFT=-1]="LEFT",Gc[Gc.CENTRE=0]="CENTRE",Gc[Gc.RIGHT=1]="RIGHT";var $c=[];$c[Xl.INPUT_VALUE]=Xl.OUTPUT_VALUE,$c[Xl.OUTPUT_VALUE]=Xl.INPUT_VALUE,$c[Xl.NEXT_STATEMENT]=Xl.PREVIOUS_STATEMENT,$c[Xl.PREVIOUS_STATEMENT]=Xl.NEXT_STATEMENT;var jc=class extends Hc{constructor(e,t){super(e,t),this.highlighted=!1,this.targetConnection=null,this.db=e.workspace.connectionDBList[t],this.dbOpposite=e.workspace.connectionDBList[$c[t]],this.offsetInBlock=new Da(0,0),this.trackedState=jc.TrackedState.WILL_TRACK}dispose(){var e,t;super.dispose(),this.trackedState===jc.TrackedState.TRACKED&&this.db.removeConnection(this,this.y),null==(t=(e=this.sourceBlock_.pathObject).removeConnectionHighlight)||t.call(e,this)}getSourceBlock(){return super.getSourceBlock()}targetBlock(){return super.targetBlock()}distanceFrom(e){var t=this.x-e.x;return e=this.y-e.y,Math.sqrt(t*t+e*e)}bumpAwayFrom(e,t=!1){if(!this.sourceBlock_.workspace.isDragging()){var i=Zs.Og.snapRadius+Math.floor(10*Math.random()),n=Zs.Og.snapRadius+Math.floor(10*Math.random()),o=e.sourceBlock_.getRootBlock(),s=this.sourceBlock_.getRootBlock();if(!o.isInFlyout&&!s.isInFlyout){var r=!0;if(s.isMovable())o.isMovable()&&t&&(n=-n);else{if(!o.isMovable())return;r=!1,i=-i,n=-n}t=r?e:this,e=r?this:e,(o=r?s:o).RTL&&(i=-i),o.moveBy(t.x+i-e.x,t.y+n-e.y,["bump"])}}}moveTo(e,t){var i=this.x!==e||this.y!==t,n=!1;return this.trackedState===jc.TrackedState.WILL_TRACK?(this.db.addConnection(this,t),this.trackedState=jc.TrackedState.TRACKED,n=!0):this.trackedState===jc.TrackedState.TRACKED&&i&&(this.db.reorderConnection(this,t),n=!0),this.x=e,this.y=t,n}moveBy(e,t){return this.moveTo(this.x+e,this.y+t)}moveToOffset(e){return this.moveTo(e.x+this.offsetInBlock.x,e.y+this.offsetInBlock.y)}setOffsetInBlock(e,t){this.offsetInBlock.x=e,this.offsetInBlock.y=t}getOffsetInBlock(){return this.offsetInBlock}tightenEfficiently(){var e=this.targetConnection,t=this.targetBlock();e&&t&&(e=Da.difference(this.offsetInBlock,e.offsetInBlock),this.insertionMarker&&(this.type===Xl.INPUT_VALUE?e.x+=this.insertionMarker.getHeightWidth().width:e.y+=this.insertionMarker.getHeightWidth().height),t.translate(e.x,e.y))}closest(e,t){return this.dbOpposite.searchForClosest(this,e,t)}setAriaRole(e){var t=this.type===Xl.INPUT_VALUE?Zs.C.INPUT_LABEL_VALUE:Zs.C.INPUT_LABEL_STATEMENT;_(e,Hr.FIGURE),f(e,$r.ROLEDESCRIPTION,t)}recomputeAriaContext(e){this.setAriaRole(e);var t,i,n,o,s=null!=(n=this.getParentInput())?n:null==(t=this.getSourceBlock().getTopStackBlock().previousConnection)||null==(i=t.targetConnection)?void 0:i.getParentInput();s?(t=null!=(o=null==s?void 0:s.getAriaLabelText())?o:Qt(s.getSourceBlock(),s,!0).join(", "),this.type===Xl.NEXT_STATEMENT?f(e,$r.LABEL,Zs.C.INPUT_LABEL_END_STATEMENT.replace("%1",t)):f(e,$r.LABEL,t)):f(e,$r.LABEL,Zs.C.INPUT_LABEL_EMPTY)}highlight(){this.highlighted=!0;var e=this.findHighlightSvg();e&&(N(e,"blocklyHighlightedConnectionPathVisible"),requestAnimationFrame((()=>{var t=e.parentElement;if(t)for(;e.nextSibling;)t.insertBefore(e.nextSibling,e)})),this.recomputeAriaContext(e))}unhighlight(){this.highlighted=!1;var e=this.findHighlightSvg();e&&A(e,"blocklyHighlightedConnectionPathVisible")}isHighlighted(){return this.highlighted}setTracking(e){e&&this.trackedState===jc.TrackedState.TRACKED||!e&&this.trackedState===jc.TrackedState.UNTRACKED||this.sourceBlock_.isInFlyout||(e?(this.db.addConnection(this,this.y),this.trackedState=jc.TrackedState.TRACKED):(this.trackedState===jc.TrackedState.TRACKED&&this.db.removeConnection(this,this.y),this.trackedState=jc.TrackedState.UNTRACKED))}stopTrackingAll(){if(this.setTracking(!1),this.targetConnection){let e=this.targetBlock().getDescendants(!1);for(let t=0;t<e.length;t++){let i=e[t],n=i.getConnections_(!0);for(let e=0;e<n.length;e++)n[e].setTracking(!1);for(let e of i.getIcons())pt(e)&&e.setBubbleVisible(!1)}}}startTrackingAll(){this.setTracking(!0);var e=[];if(this.type!==Xl.INPUT_VALUE&&this.type!==Xl.NEXT_STATEMENT)return e;var t=this.targetBlock();if(t){let i;t.isCollapsed()?(i=[],t.outputConnection&&i.push(t.outputConnection),t.nextConnection&&i.push(t.nextConnection),t.previousConnection&&i.push(t.previousConnection)):i=t.getConnections_(!0);for(let t=0;t<i.length;t++)e.push(...i[t].startTrackingAll());e.length||(e=[t])}return e}onFailedConnect(e){var t=this.getSourceBlock();if(Zs.Qc){let i=Zs.gd;setTimeout(function(){t.isDisposed()||t.getParent()||(Zs.B(i),this.bumpAwayFrom(e),Zs.B(!1))}.bind(this),Zs.Og.bumpDelay)}}disconnectInternal(e=!0){var{parentConnection:t,childConnection:i}=this.getParentAndChildConnections();if(t&&i){var n=Zs.gd;n||Zs.B(!0);var o=t.getSourceBlock(),s=i.getSourceBlock();super.disconnectInternal(e),o.queueRender(),s.updateDisabled(),s.queueRender(),s.getSvgRoot().style.display="block",Zs.B(n)}}respawnShadow_(){super.respawnShadow_();var e=this.targetBlock();e&&(e.initSvg(),e.queueRender())}neighbours(e){return this.dbOpposite.getNeighbours(this,e)}connect_(e){super.connect_(e);var t=this.getSourceBlock();e=e.getSourceBlock(),t.updateDisabled(),e.updateDisabled(),e.queueRender(),(t=t.getInputWithBlock(e))&&(t=t.isVisible(),e.getSvgRoot().style.display=t?"block":"none")}onCheckChanged_(){!this.isConnected()||this.targetConnection&&this.getConnectionChecker().canConnect(this,this.targetConnection,!1)||(this.isSuperior()?this.targetBlock():this.sourceBlock_).unplug()}setCheck(e){return super.setCheck(e),this.sourceBlock_.queueRender(),this}showContextMenu(e){var t=nc.registry.getContextMenuOptions({focusedNode:this},e);if(t.length){var i=this.getSourceBlock(),n=i.workspace;if(e instanceof PointerEvent)var o=new Da(e.clientX,e.clientY);else o=new Da(this.x,this.y),o=Le(n,o).translate(i.RTL?-5:5,5);hn(e,t,i.RTL,n,o)}}getFocusableElement(){var e=this.findHighlightSvg();if(e)return e;throw Error("No highlight SVG found corresponding to this connection.")}getFocusableTree(){return this.getSourceBlock().workspace}onNodeFocus(){this.highlight();var e=this.getSourceBlock();e.workspace.isFlyout||e.moveSvgRootToFront(),e.workspace.scrollBoundsIntoView(e.getBoundingRectangleWithoutChildren())}onNodeBlur(){this.unhighlight()}canBeFocused(){return null!==this.findHighlightSvg()}findHighlightSvg(){return this.getSourceBlock().getSvgRoot().querySelector(`#${CSS.escape(this.id)}`)}attachInsertionMarker(e){this.insertionMarker=e}detachInsertionMarker(){this.insertionMarker=void 0}getInsertionMarker(){return this.insertionMarker}},zc=jc||(jc={}),Xc=zc.TrackedState||(zc.TrackedState={});Xc[Xc.WILL_TRACK=-1]="WILL_TRACK",Xc[Xc.UNTRACKED=0]="UNTRACKED",Xc[Xc.TRACKED=1]="TRACKED";var Yc=class{constructor(e,t){this.name=e,this.sourceBlock=t,this.fieldRow=[],this.align=Zs.Xn.LEFT,this.visible=!0,this.ariaLabelProvider=null,this.type=Zs.je.CUSTOM,this.connection=null}getSourceBlock(){return this.sourceBlock}appendField(e,t){return this.insertFieldAt(this.fieldRow.length,e,t),this}insertFieldAt(e,t,i){if(e<0||e>this.fieldRow.length)throw Error("index "+e+" out of bounds.");return t||""===t&&i?("string"==typeof t&&(t=Zs.lh({type:"field_label",text:t})),t.setSourceBlock(this.sourceBlock),this.sourceBlock.initialized&&this.initField(t),t.name=i,t.setVisible(this.isVisible()),t.prefixField&&(e=this.insertFieldAt(e,t.prefixField)),this.fieldRow.splice(e,0,t),e++,t.suffixField&&(e=this.insertFieldAt(e,t.suffixField)),this.sourceBlock.rendered&&this.sourceBlock.queueRender(),e):e}removeField(e,t){for(let t,i=0;t=this.fieldRow[i];i++)if(t.name===e)return t.dispose(),this.fieldRow.splice(i,1),this.sourceBlock.rendered&&this.sourceBlock.queueRender(),!0;if(t)return!1;throw Error('Field "'+e+'" not found.')}isVisible(){return this.visible}setVisible(e){var t=[];if(this.visible===e)return t;this.visible=e;for(let t,i=0;t=this.fieldRow[i];i++)t.setVisible(e);if(this.connection&&this.connection instanceof jc){e?t=this.connection.startTrackingAll():this.connection.stopTrackingAll();let i=this.connection.targetBlock();i&&(i.getSvgRoot().style.display=e?"block":"none")}return t}markDirty(){for(let e,t=0;e=this.fieldRow[t];t++)e.markDirty()}setCheck(e){if(!this.connection)throw Error("This input does not have a connection.");return this.connection.setCheck(e),this}setAlign(e){return this.align=e,this.sourceBlock.rendered&&this.sourceBlock.queueRender(),this}setShadowDom(e){if(!this.connection)throw Error("This input does not have a connection.");return this.connection.setShadowDom(e),this}getShadowDom(){if(!this.connection)throw Error("This input does not have a connection.");return this.connection.getShadowDom()}init(){for(let e of this.fieldRow)e.init()}setAriaLabelProvider(e){return this.ariaLabelProvider=e,this}getAriaLabelText(){return this.ariaLabelProvider?"string"==typeof this.ariaLabelProvider?Ji(this.ariaLabelProvider):this.ariaLabelProvider(this):null}initModel(){for(let e of this.fieldRow)e.initModel()}initField(e){this.sourceBlock.rendered?e.init():e.initModel()}dispose(){for(let e,t=0;e=this.fieldRow[t];t++)e.dispose();this.connection&&this.connection.dispose()}makeConnection(e){return this.sourceBlock.makeConnection_(e)}getRowId(){var e=this.getSourceBlock().inputList;if(this===e.find((e=>e.isVisible()))||this===e[0])return this.getSourceBlock().getRowId();var t,i,n=e.indexOf(this),o=(null==(t=e[n-1].connection)?void 0:t.type)===Xl.NEXT_STATEMENT;return(null==(i=this.connection)?void 0:i.type)===Xl.NEXT_STATEMENT||o?`${this.getSourceBlock().id}-input${n}`:e[n-1].getRowId()}getLabel(e=Xr.STANDARD,t=!0){if(!this.isVisible())return"";var i,n=jt(this,!1,e);return t&&(null==(i=this.connection)?void 0:i.type)===Xl.INPUT_VALUE&&(t=this.connection.targetBlock())&&!t.isInsertionMarker()&&n.push(Yt(t,e).join(", ")),n.join(", ")}getIndex(){var e=[Zs.je.DUMMY,Zs.je.END_ROW];return this.getSourceBlock().inputList.filter((t=>!e.includes(t.type))).indexOf(this)}},Kc=class extends Yc{constructor(e,t){super(e,t),this.name=e,this.type=Zs.je.DUMMY}},Jc=class extends Yc{constructor(e,t){super(e,t),this.name=e,this.type=Zs.je.END_ROW}},Qc=class extends Yc{constructor(e,t){if(!e)throw Error("Statement inputs must have a non-empty name");super(e,t),this.name=e,this.type=Zs.je.STATEMENT,this.connection=this.makeConnection(Xl.NEXT_STATEMENT)}};Zs.go=class extends Yc{constructor(e,t){if(!e)throw Error("Value inputs must have a non-empty name");super(e,t),this.name=e,this.type=Zs.je.VALUE,this.connection=this.makeConnection(Xl.INPUT_VALUE)}};var Zc=class{constructor(e,t,i){if(this.data=null,this.disposed=!1,this.hue=null,this.colour_="#000000",this.styleName_="",this.suppressPrefixSuffix=!1,this.previousConnection=this.nextConnection=this.outputConnection=null,this.inputList=[],this.icons=[],this.disabledReasons=new Set,this.tooltip="",this.contextMenu=!0,this.parentBlock_=null,this.childBlocks_=[],this.editable=this.movable=this.deletable=!0,this.collapsed_=this.shadow=!1,this.outputShape_=null,this.rendered=this.isInsertionMarker_=this.initialized=this.disposing=!1,this.onchangeWrapper=this.helpUrl=null,this.statementInputCount=0,this.workspace=e,this.id=i&&!e.getBlockById(i)?i:he(),e.setBlockById(this.id,this),this.xy=new Da(0,0),this.isInFlyout=e.isFlyout,this.isInMutator=e.isMutator,this.RTL=e.RTL,t){if(this.type=t,!(i=Ur[t])||"object"!=typeof i)throw TypeError("Invalid block definition for type: "+t);Object.assign(this,i)}e.addTopBlock(this),e.addTypedBlock(this),new.target===Zc&&this.doInit_()}doInit_(){var e=Zs.gd;e||Zs.B(!0);var t=Zs.Qc;try{"function"==typeof this.init&&(Zs.Qc=!1,this.init(),Zs.Qc=t),Ee()&&ue(new(_e(Fr.BLOCK_CREATE))(this))}finally{Zs.B(e),Zs.Qc=t}this.inputsInlineDefault=this.inputsInline,"function"==typeof this.onchange&&this.setOnChange(this.onchange)}dispose(e=!1){this.disposing=!0,this.tooltip="",this.onchangeWrapper&&this.workspace.removeChangeListener(this.onchangeWrapper),this.unplug(e),Ee()&&ue(new(_e(Fr.BLOCK_DELETE))(this)),this.workspace.removeTopBlock(this),this.disposeInternal()}disposeInternal(){this.disposing=!0,this.onchangeWrapper&&this.workspace.removeChangeListener(this.onchangeWrapper),this.workspace.removeTypedBlock(this),this.workspace.removeBlockById(this.id),"function"==typeof this.destroy&&this.destroy(),this.childBlocks_.forEach((e=>e.disposeInternal())),this.inputList.forEach((e=>e.dispose())),this.inputList.length=0,this.getConnections_(!0).forEach((e=>e.dispose())),this.disposed=!0}isDeadOrDying(){return this.disposing||this.disposed}initModel(){if(!this.initialized){for(let e of this.inputList)e.initModel();this.initialized=!0}}unplug(e){this.outputConnection&&this.unplugFromRow(e),this.previousConnection&&this.unplugFromStack(e)}unplugFromRow(e){var t,i=null;null!=(t=this.outputConnection)&&t.isConnected()&&(i=this.outputConnection.targetConnection,this.outputConnection.disconnect()),i&&e&&(e=this.getOnlyValueConnection())&&e.isConnected()&&!e.targetBlock().isShadow()&&(null==(e=e.targetConnection)||e.disconnect(),this.workspace.connectionChecker.canConnect(e,i,!1)?i.connect(e):null==e||e.onFailedConnect(i))}getOnlyValueConnection(){var e=null;for(let t=0;t<this.inputList.length;t++){let i=this.inputList[t].connection;if(i&&i.type===Xl.INPUT_VALUE&&i.targetConnection){if(e)return null;e=i}}return e}unplugFromStack(e){var t,i=null;if(null!=(t=this.previousConnection)&&t.isConnected()&&(i=this.previousConnection.targetConnection,this.previousConnection.disconnect()),e){for(e=this.getNextBlock();e&&(e.isShadow()||!e.isMovable());)e=e.getNextBlock();var n,o,s,r;e&&(null==(e=null!=(r=null==(n=e.previousConnection)||null==(o=n.targetBlock())||null==(s=o.nextConnection)?void 0:s.targetConnection)?r:null)||e.disconnect(),i&&this.workspace.connectionChecker.canConnect(i,e,!1)&&i.connect(e))}}getConnections_(){var e=[];this.outputConnection&&e.push(this.outputConnection),this.previousConnection&&e.push(this.previousConnection),this.nextConnection&&e.push(this.nextConnection);for(let t,i=0;t=this.inputList[i];i++)t.connection&&e.push(t.connection);return e}lastConnectionInStack(e){for(var t=this.nextConnection;t;){let i=t.targetBlock();if(!i||e&&i.isShadow())return t;t=i.nextConnection}return null}bumpNeighbours(){}getParent(){return this.parentBlock_}getInputWithBlock(e){for(let t,i=0;t=this.inputList[i];i++)if(t.connection&&t.connection.targetBlock()===e)return t;return null}getSurroundParent(){var e=this;do{var t=e;if(!(e=e.getParent()))return null}while(e.getNextBlock()===t);return e}getNextBlock(){return this.nextConnection&&this.nextConnection.targetBlock()}getPreviousBlock(){return this.previousConnection&&this.previousConnection.targetBlock()}getRootBlock(){var e=this;do{var t=e;e=t.parentBlock_}while(e);return t}getTopStackBlock(){var e=this;do{var t=e.getPreviousBlock()}while(t&&t.getNextBlock()===e&&(e=t));return e}getChildren(e){if(!e)return this.childBlocks_;e=[];for(let i,n=0;i=this.inputList[n];n++)if(i.connection){var t=i.connection.targetBlock();t&&e.push(t)}return(t=this.getNextBlock())&&e.push(t),e}setParent(e){if(e!==this.parentBlock_){var t=this.previousConnection&&this.previousConnection.targetBlock()||this.outputConnection&&this.outputConnection.targetBlock(),i=!!t;if(i&&e&&t!==e)throw Error("Block connected to superior one that is not new parent.");if(!i&&e)throw Error("Block not connected to new parent.");if(i&&!e)throw Error("Cannot set parent to null while block is still connected to superior block.");this.parentBlock_?p(this.parentBlock_.childBlocks_,this):this.workspace.removeTopBlock(this),(this.parentBlock_=e)?e.childBlocks_.push(this):this.workspace.addTopBlock(this)}}getDescendants(e){var t=[this],i=this.getChildren(e);for(let n,o=0;n=i[o];o++)t.push(...n.getDescendants(e));return t}isDeletable(){return this.deletable&&!this.isInFlyout&&!this.shadow&&!this.isDeadOrDying()&&!this.workspace.isReadOnly()}isOwnDeletable(){return this.deletable}setDeletable(e){this.deletable=e}isMovable(){return this.movable&&!this.isInFlyout&&!this.shadow&&!this.isDeadOrDying()&&!this.workspace.isReadOnly()}isOwnMovable(){return this.movable}setMovable(e){this.movable=e}isDuplicatable(){return!this.workspace.hasBlockLimits()||this.workspace.isCapacityAvailable(J(this,!0))}isShadow(){return this.shadow}setShadow(e){this.shadow=e}isInsertionMarker(){return this.isInsertionMarker_}setInsertionMarker(e){this.isInsertionMarker_=e}isEditable(){return this.editable&&!this.isDeadOrDying()&&!this.workspace.isReadOnly()}isOwnEditable(){return this.editable}setEditable(e){this.editable=e;for(let e of this.getFields())e.updateEditable()}isDisposed(){return this.disposed}getFullBlockField(){if(!this.isSimpleReporter())return null;var e,t=null==(e=this.inputList[0])?void 0:e.fieldRow[0];return null!=t&&t.isFullBlockField()?t:null}isSimpleReporter(){if(!this.outputConnection)return!1;for(let e of this.inputList)if(e.connection||e.fieldRow.length>1)return!1;return!0}getMatchingConnection(e,t){var i=this.getConnections_(!0);if(e=e.getConnections_(!0),i.length!==e.length)throw Error("Connection lists did not match in length.");for(let n=0;n<e.length;n++)if(e[n]===t)return i[n];return null}setHelpUrl(e){this.helpUrl=e}setTooltip(e){this.tooltip=e}getTooltip(){return Ri(this)}getColour(){return this.colour_}getStyleName(){return this.styleName_}getHue(){return this.hue}setColour(e){e=Qi(e),this.hue=e.hue,this.colour_=e.hex}setStyle(e){this.styleName_=e}setOnChange(e){if(e&&"function"!=typeof e)throw Error("onchange must be a function.");this.onchangeWrapper&&this.workspace.removeChangeListener(this.onchangeWrapper),this.onchange=e,this.onchangeWrapper=e.bind(this),this.workspace.addChangeListener(this.onchangeWrapper)}getField(e){if("string"!=typeof e)throw TypeError("Block.prototype.getField expects a string with the field name but received "+(void 0===e?"nothing":e+" of type "+typeof e)+" instead");for(let t of this.getFields())if(t.name===e)return t;return null}*getFields(){for(let e of this.inputList)for(let t of e.fieldRow)yield t}getVarModels(){var e=[];for(let t of this.getFields())if(t.referencesVariables()){let i=this.workspace.getVariableMap().getVariableById(t.getValue());i&&e.push(i)}return e}updateVarName(e){for(let t of this.getFields())t.referencesVariables()&&e.getId()===t.getValue()&&t.refreshVariableName()}renameVarById(e,t){for(let i of this.getFields())i.referencesVariables()&&e===i.getValue()&&i.setValue(t)}getFieldValue(e){return(e=this.getField(e))?e.getValue():null}setFieldValue(e,t){var i=this.getField(t);if(!i)throw Error('Field "'+t+'" not found.');i.setValue(e)}setPreviousStatement(e,t){if(e)void 0===t&&(t=null),this.previousConnection||(this.previousConnection=this.makeConnection_(Xl.PREVIOUS_STATEMENT)),this.previousConnection.setCheck(t);else if(this.previousConnection){if(this.previousConnection.isConnected())throw Error("Must disconnect previous statement before removing connection.");this.previousConnection.dispose(),this.previousConnection=null}}setNextStatement(e,t){if(e)void 0===t&&(t=null),this.nextConnection||(this.nextConnection=this.makeConnection_(Xl.NEXT_STATEMENT)),this.nextConnection.setCheck(t);else if(this.nextConnection){if(this.nextConnection.isConnected())throw Error("Must disconnect next statement before removing connection.");this.nextConnection.dispose(),this.nextConnection=null}}setOutput(e,t){if(e)void 0===t&&(t=null),this.outputConnection||(this.outputConnection=this.makeConnection_(Xl.OUTPUT_VALUE)),this.outputConnection.setCheck(t);else if(this.outputConnection){if(this.outputConnection.isConnected())throw Error("Must disconnect output value before removing connection.");this.outputConnection.dispose(),this.outputConnection=null}}setInputsInline(e){this.inputsInline!==e&&(ue(new(_e(Fr.BLOCK_CHANGE))(this,"inline",null,this.inputsInline,e)),this.inputsInline=e)}getInputsInline(){if(void 0!==this.inputsInline)return this.inputsInline;for(var e=1;e<this.inputList.length;e++)if(this.inputList[e-1]instanceof Kc&&this.inputList[e]instanceof Kc)return!1;for(e=1;e<this.inputList.length;e++)if(this.inputList[e-1]instanceof Zs.go&&this.inputList[e]instanceof Kc)return!0;for(e=0;e<this.inputList.length;e++)if(this.inputList[e]instanceof Jc)return!0;return!1}setOutputShape(e){this.outputShape_=e}getOutputShape(){return this.outputShape_}isEnabled(){return 0===this.disabledReasons.size}setDisabledReason(e,t){e||this.workspace.options.disable||!this.hasDisabledReason("MANUALLY_DISABLED")||"MANUALLY_DISABLED"==t||this.setDisabledReason(!1,"MANUALLY_DISABLED"),this.disabledReasons.has(t)!==e&&(e?this.disabledReasons.add(t):this.disabledReasons.delete(t),(e=new(_e(Fr.BLOCK_CHANGE))(this,"disabled",null,!e,e)).setDisabledReason(t),ue(e))}getInheritedDisabled(){for(var e=this.getSurroundParent();e;){if(!e.isEnabled())return!0;e=e.getSurroundParent()}return!1}hasDisabledReason(e){return this.disabledReasons.has(e)}getDisabledReasons(){return this.disabledReasons}isCollapsed(){return this.collapsed_}setCollapsed(e){this.collapsed_!==e&&(ue(new(_e(Fr.BLOCK_CHANGE))(this,"collapsed",null,this.collapsed_,e)),this.collapsed_=e)}setAriaRoleDescriptionProvider(e){this.ariaRoleDescriptionProvider=e}getAriaRoleDescription(){return this.ariaRoleDescriptionProvider?"function"==typeof this.ariaRoleDescriptionProvider?this.ariaRoleDescriptionProvider():Ji(this.ariaRoleDescriptionProvider):this.statementInputCount?Zs.C.BLOCK_LABEL_CONTAINER:this.outputConnection?Zs.C.BLOCK_LABEL_VALUE:Zs.C.BLOCK_LABEL_STATEMENT}toString(e,t){t=this.toTokens(t);for(let e=2;e<t.length;e++)"("===t[e-2]&&")"===t[e]&&(t[e-2]=t[e-1],t.splice(e-1,2));var i="";return t=(t=t.reduce(((e,t)=>(e=e+("("===i||")"===t?"":" ")+t,i=t[t.length-1],e)),"")).trim()||"???",e&&t.length>e&&(t=t.substring(0,e-3)+"..."),t}toTokens(e="?"){var t=[];for(let n of this.inputList)if("_TEMP_COLLAPSED_INPUT"!=n.name){for(let e of n.fieldRow)t.push(e.getText());if(n.connection){let o=n.connection.targetBlock();if(o){var i=n.connection;let s=i.getCheck();!s&&i.targetConnection&&(s=i.targetConnection.getCheck()),(i=!!s&&(s.includes("Boolean")||s.includes("Number")))&&t.push("("),t.push(...o.toTokens(e)),i&&t.push(")")}else t.push(e)}}return t}appendValueInput(e){return this.appendInput(new Zs.go(e,this))}appendStatementInput(e){return this.statementInputCount++,this.appendInput(new Qc(e,this))}appendDummyInput(e=""){return this.appendInput(new Kc(e,this))}appendEndRowInput(e=""){return this.appendInput(new Jc(e,this))}appendInput(e){return this.inputList.push(e),e}appendInputFromRegistry(e,t){return(e=ne(ya.INPUT,e,!1))?this.appendInput(new e(t,this)):null}jsonInit(e){var t=e.type?'Block "'+e.type+'": ':"";if(e.output&&e.previousStatement)throw Error(t+"Must not have both an output and a previousStatement.");for(var i=0;e[`args${i}`];){if(void 0===e[`message${i}`])throw Error(t+`args${i} must have a corresponding message (message${i}).`);i++}if(e.style&&"object"==typeof e.style&&(this.hat=e.style.hat,e.style=null),e.style&&e.colour)throw Error(t+"Must not have both a colour and a style.");for(e.style?this.jsonInitStyle(e,t):this.jsonInitColour(e,t),i=0;void 0!==e[`message${i}`];)this.interpolate(e[`message${i}`]||"",e[`args${i}`]||[],e[`implicitAlign${i}`]||e[`lastDummyAlign${i}`],t),i++;if(void 0!==e.inputsInline&&(Zs.Ub++,this.setInputsInline(e.inputsInline),Zs.Ub--),void 0!==e.output&&this.setOutput(!0,e.output),void 0!==e.outputShape&&this.setOutputShape(e.outputShape),void 0!==e.previousStatement&&this.setPreviousStatement(!0,e.previousStatement),void 0!==e.nextStatement&&this.setNextStatement(!0,e.nextStatement),void 0!==e.tooltip&&(i=Ji(e.tooltip),this.setTooltip(i)),void 0!==e.enableContextMenu&&(this.contextMenu=!!e.enableContextMenu),void 0!==e.suppressPrefixSuffix&&(this.suppressPrefixSuffix=!!e.suppressPrefixSuffix),void 0!==e.helpUrl&&(i=Ji(e.helpUrl),this.setHelpUrl(i)),void 0!==e.ariaRoleDescription&&this.setAriaRoleDescriptionProvider(e.ariaRoleDescription),"string"==typeof e.extensions&&(console.warn(t+"JSON attribute 'extensions' should be an array of strings. Found raw string in JSON for '"+e.type+"' block."),e.extensions=[e.extensions]),void 0!==e.mutator&&xn(e.mutator,this,!0),e=e.extensions,Array.isArray(e))for(t=0;t<e.length;t++)xn(e[t],this,!1)}jsonInitColour(e,t){if("colour"in e)if(void 0===e.colour)console.warn(t+"Undefined colour value.");else{e=e.colour;try{this.setColour(e)}catch(i){console.warn(t+"Illegal colour value: ",e)}}}jsonInitStyle(e,t){e=e.style;try{this.setStyle(e)}catch(i){console.warn(t+"Style does not exist: ",e)}}mixin(e,t){if(void 0!==t&&"boolean"!=typeof t)throw Error("opt_disableCheck must be a boolean if provided");if(!t){t=[];for(let i in e)void 0!==this[i]&&t.push(i);if(t.length)throw Error("Mixin will overwrite block members: "+JSON.stringify(t))}Object.assign(this,e)}interpolate(e,t,i,n){e=Ki(e),this.validateTokens(e,t.length),t=this.interpolateArguments(e,t,i),i=[];for(let o,s=0;o=t[s];s++)if(this.isInputKeyword(o.type)){if(e=this.inputFromJson(o,n)){for(let t,n=0;t=i[n];n++)e.appendField(t[0],t[1]);i.length=0}}else(e=this.fieldFromJson(o))&&i.push([e,o.name])}validateTokens(e,t){var i=[],n=0;for(let o=0;o<e.length;o++){let s=e[o];if("number"==typeof s){if(s<1||s>t)throw Error('Block "'+this.type+'": Message index %'+s+" out of range.");if(i[s])throw Error('Block "'+this.type+'": Message index %'+s+" duplicated.");i[s]=!0,n++}}if(n!==t)throw Error('Block "'+this.type+'": Message does not reference all '+t+" arg(s).")}interpolateArguments(e,t,i){var n=[];for(let s=0;s<e.length;s++){var o=e[s];if("number"==typeof o&&(o=t[o-1]),"string"==typeof o)if("\n"===o)o={type:"input_end_row"},i&&(o.align=i);else if(!(o=this.stringToFieldJson(o)))continue;n.push(o)}return(e=n.length)&&!this.isInputKeyword(n[e-1].type)&&(e={type:"input_dummy"},i&&(e.align=i),n.push(e)),n}fieldFromJson(e){var t=Zs.lh(e);return!t&&e.alt?"string"==typeof e.alt?(e=this.stringToFieldJson(e.alt))?this.fieldFromJson(e):null:this.fieldFromJson(e.alt):t}inputFromJson(e,t){var i={LEFT:Zs.Xn.LEFT,RIGHT:Zs.Xn.RIGHT,CENTRE:Zs.Xn.CENTRE,CENTER:Zs.Xn.CENTRE};switch(e.type){case"input_value":var n=this.appendValueInput(e.name);break;case"input_statement":n=this.appendStatementInput(e.name);break;case"input_dummy":n=this.appendDummyInput(e.name);break;case"input_end_row":n=this.appendEndRowInput(e.name);break;default:n=this.appendInputFromRegistry(e.type,e.name)}return n?(e.check&&n.setCheck(e.check),e.align&&(void 0===(i=i[e.align.toUpperCase()])?console.warn(t+"Illegal align value: ",e.align):n.setAlign(i)),e.ariaLabelText&&n.setAriaLabelProvider(e.ariaLabelText),n):null}isInputKeyword(e){return"input_value"===e||"input_statement"===e||"input_dummy"===e||"input_end_row"===e||oe(ya.INPUT,e)}stringToFieldJson(e){return(e=e.trim())?{type:"field_label",text:e}:null}moveInputBefore(e,t){if(e!==t){var i=-1,n=t?-1:this.inputList.length;for(let o,s=0;o=this.inputList[s];s++)if(o.name===e){if(i=s,-1!==n)break}else if(t&&o.name===t&&(n=s,-1!==i))break;if(-1===i)throw Error('Named input "'+e+'" not found.');if(-1===n)throw Error('Reference input "'+t+'" not found.');this.moveNumberedInputBefore(i,n)}}moveNumberedInputBefore(e,t){if(e===t)throw Error("Can't move input to itself.");if(e>=this.inputList.length)throw RangeError("Input index "+e+" out of bounds.");if(t>this.inputList.length)throw RangeError("Reference input "+t+" out of bounds.");var i=this.inputList[e];this.inputList.splice(e,1),e<t&&t--,this.inputList.splice(t,0,i)}removeInput(e,t){for(let t,i=0;t=this.inputList[i];i++)if(t.name===e)return t instanceof Qc&&this.statementInputCount--,t.dispose(),this.inputList.splice(i,1),!0;if(t)return!1;throw Error("Input not found: "+e)}getInput(e){for(let t,i=0;t=this.inputList[i];i++)if(t.name===e)return t;return null}getInputTargetBlock(e){return(e=this.getInput(e))&&e.connection&&e.connection.targetBlock()}getCommentText(){var e,t;return null!=(t=null==(e=this.getIcon(Hl.COMMENT))?void 0:e.getText())?t:null}setCommentText(e){var t,i,n=null!=(i=null==(t=this.getIcon(Hl.COMMENT))?void 0:t.getText())?i:null;if(n!==e){if(null!==e){if(!(t=this.getIcon(Hl.COMMENT))){if(!(t=ne(ya.ICON,Hl.COMMENT.toString(),!1)))throw Error("No comment icon class is registered, so a comment cannot be set");if(t=new t(this),!(Xn(t)&&pt(t)&&Je(t)&&"function"==typeof t.setText&&"function"==typeof t.getText&&"function"==typeof t.setBubbleSize&&"function"==typeof t.getBubbleSize&&"function"==typeof t.setBubbleLocation&&"function"==typeof t.getBubbleLocation&&t.getType()===Hl.COMMENT))throw Error("The class registered as a comment icon does not conform to the ICommentIcon interface");t=this.addIcon(t)}Zs.Ub++,t.setText(e),Zs.Ub--}else this.removeIcon(Hl.COMMENT);ue(new(_e(Fr.BLOCK_CHANGE))(this,"comment",null,n,e))}}setWarningText(){}setMutator(){}addIcon(e){if(this.hasIcon(e.getType()))throw new Wc(e);return this.icons.push(e),this.icons.sort(((e,t)=>e.getWeight()-t.getWeight())),e}removeIcon(e){return!!this.hasIcon(e)&&(null==(t=this.getIcon(e))||t.dispose(),this.icons=this.icons.filter((t=>!t.getType().equals(e))),!0);var t}hasIcon(e){return this.icons.some((t=>t.getType().equals(e)))}getIcon(e){return e instanceof Hl?this.icons.find((t=>t.getType().equals(e))):this.icons.find((t=>t.getType().toString()===e))}getIcons(){return[...this.icons]}getRelativeToSurfaceXY(){return this.xy.clone()}moveBy(e,t,i){if(this.parentBlock_)throw Error("Block has parent");var n=new(_e(Fr.BLOCK_MOVE))(this);i&&n.setReason(i),this.xy.translate(e,t),n.recordNew(),ue(n)}makeConnection_(e){return new Hc(this,e)}allInputsFilled(e){if(void 0===e&&(e=!0),!e&&this.isShadow())return!1;for(let i,n=0;i=this.inputList[n];n++)if(i.connection){var t=i.connection.targetBlock();if(!t||!t.allInputsFilled(e))return!1}return!(t=this.getNextBlock())||t.allInputsFilled(e)}toDevString(){var e=this.type?'"'+this.type+'" block':"Block";return this.id&&(e+=' (id="'+this.id+'")'),e}};Zc.COLLAPSED_INPUT_NAME="_TEMP_COLLAPSED_INPUT",Zc.COLLAPSED_FIELD_NAME="_TEMP_COLLAPSED_FIELD";var ed=null,td=null,id={};id.connectionUiEffect=Jn,id.disconnectUiEffect=Qn,id.disconnectUiStop=eo,id.disposeUiEffect=Yn;var nd=class{paste(e,t,i){if(!t.isCapacityAvailable(e.typeCounts))return null;i&&(e.blockState.x=i.x,e.blockState.y=i.y),i=null!=i?i:new Da(e.blockState.x||0,e.blockState.y||0),Zs.Ub++;try{var n=Ft(e.blockState,t);to(n,i)}finally{Zs.Ub--}if(!n)return n;Ee()&&!n.isShadow()&&ue(new(_e(Fr.BLOCK_CREATE))(n));var o=n;return Ze().then((()=>{n.isDeadOrDying()||Zs.t().focusNode(o)})),n}};nd.TYPE="block",Xe(nd.TYPE,new nd);var od={};od.bumpIntoBounds=oo,od.bumpIntoBoundsHandler=so,od.bumpTopObjectsIntoBounds=ro;var sd=null,rd=null,ad=void 0,ld={};ld.BlockPaster=nd,ld.copy=ao,ld.getLastCopiedData=function(){return sd},ld.getLastCopiedLocation=function(){return ad},ld.getLastCopiedWorkspace=function(){return rd},ld.paste=lo,ld.registry=Tl,ld.setLastCopiedData=function(e){sd=e},ld.setLastCopiedLocation=function(e){ad=e},ld.setLastCopiedWorkspace=function(e){rd=e};var hd={};hd.CollapseCommentBarButton=uc,hd.CommentBarButton=hc,hd.CommentEditor=cc,hd.CommentView=pc,hd.DeleteCommentBarButton=dc,hd.RenderedWorkspaceComment=Ec,hd.WorkspaceComment=gc;var ud=class{constructor(e,t,i,n){if(this.workspace=e,this.targetWorkspace=t,this.isFlyoutLabel=n,this.height=this.width=0,this.cursorSvg=this.svgText=null,this.text=i.text,this.position=new Da(0,0),this.callbackKey=i.callbackKey||i.callbackkey,this.cssClass=i["web-class"]||null,this.info=i,e=this.isFlyoutLabel?"blocklyFlyoutLabel":"blocklyFlyoutButton",this.cssClass&&(e+=" "+this.cssClass),this.id=le(),this.svgGroup=I(ea.G,{id:this.id,class:e},this.workspace.getCanvas()),!this.isFlyoutLabel){var o=I(ea.RECT,{class:"blocklyFlyoutButtonShadow",rx:ud.BORDER_RADIUS,ry:ud.BORDER_RADIUS,x:1,y:1},this.svgGroup);_(o,Hr.NONE)}e=I(ea.RECT,{class:this.isFlyoutLabel?"blocklyFlyoutLabelBackground":"blocklyFlyoutButtonBackground",rx:ud.BORDER_RADIUS,ry:ud.BORDER_RADIUS},this.svgGroup),_(e,Hr.NONE),t=I(ea.TEXT,{class:this.isFlyoutLabel?"blocklyFlyoutLabelText":"blocklyText",x:0,y:0,"text-anchor":"middle"},this.svgGroup),i=Ji(this.text),this.workspace.RTL&&(i+="‏"),t.textContent=i,this.isFlyoutLabel&&(this.svgText=t,this.workspace.getThemeManager().subscribe(this.svgText,"flyoutForegroundColour","fill")),_(t,Hr.NONE),n=`${i}, ${this.isFlyoutLabel?Zs.C.ARIA_LABEL_HEADING:Zs.C.ARIA_LABEL_BUTTON}`,f(this.getFocusableElement(),$r.LABEL,n),_(this.getFocusableElement(),Hr.OPTION),n=be(t,"fontSize");var s=be(t,"fontWeight"),a=be(t,"fontFamily");if(this.width=x(t,n,s,a),i=F(i,n,s,a),this.height=this.height||i.height,!this.isFlyoutLabel){let e,t;this.width+=2*ud.TEXT_MARGIN_X,this.height+=2*ud.TEXT_MARGIN_Y,null==(e=o)||e.setAttribute("width",String(this.width)),null==(t=o)||t.setAttribute("height",String(this.height))}e.setAttribute("width",String(this.width)),e.setAttribute("height",String(this.height)),t.setAttribute("x",String(this.width/2)),t.setAttribute("y",String(this.height/2-i.height/2+i.baseline)),this.updateTransform(),this.onMouseDownWrapper=r(this.svgGroup,"pointerdown",this,this.onMouseDown),this.onMouseUpWrapper=r(this.svgGroup,"pointerup",this,this.onMouseUp)}createDom(){return this.svgGroup}show(){this.updateTransform(),this.svgGroup.setAttribute("display","block")}updateTransform(){this.svgGroup.setAttribute("transform","translate("+this.position.x+","+this.position.y+")")}moveTo(e,t){this.position.x=e,this.position.y=t,this.updateTransform()}moveBy(e,t){this.moveTo(this.position.x+e,this.position.y+t)}isLabel(){return this.isFlyoutLabel}getPosition(){return this.position}getBoundingRectangle(){return new xa(this.position.y,this.position.y+this.height,this.position.x,this.position.x+this.width)}getButtonText(){return this.text}getTargetWorkspace(){return this.targetWorkspace}getWorkspace(){return this.workspace}dispose(){l(this.onMouseDownWrapper),l(this.onMouseUpWrapper),this.svgGroup&&S(this.svgGroup),this.svgText&&this.workspace.getThemeManager().unsubscribe(this.svgText)}setCursorSvg(e){e?this.svgGroup&&(this.svgGroup.appendChild(e),this.cursorSvg=e):this.cursorSvg=null}onMouseUp(e){(e=this.targetWorkspace.getGesture(e))&&e.cancel(),this.isFlyoutLabel&&this.callbackKey?console.warn("Labels should not have callbacks. Label text: "+this.text):this.isFlyoutLabel||this.callbackKey&&this.targetWorkspace.getButtonCallback(this.callbackKey)?this.isFlyoutLabel||(e=this.targetWorkspace.getButtonCallback(this.callbackKey))&&e(this):console.warn("Buttons should have callbacks. Button text: "+this.text)}onMouseDown(e){var t=this.targetWorkspace.getGesture(e),i=this.targetWorkspace.getFlyout();t&&i&&t.handleFlyoutStart(e,i)}getSvgRoot(){return this.svgGroup}getFocusableElement(){return this.svgGroup}getFocusableTree(){return this.workspace}onNodeFocus(){var e=this.getPosition();e=new xa(e.y,e.y+this.height,e.x,e.x+this.width),this.workspace.scrollBoundsIntoView(e)}onNodeBlur(){}canBeFocused(){return!0}getId(){return this.id}performAction(){if(this.isFlyoutLabel){var e=this.targetWorkspace;let t=Zs.C.KEYBOARD_NAV_FLYOUT_LABEL_HINT.replace("%1",Vt(pd.NEXT_HEADING));Ol.show(e,{message:t,id:"flyoutLabelHint"})}else(e=this.targetWorkspace.getButtonCallback(this.callbackKey))&&e(this)}};ud.TEXT_MARGIN_X=5,ud.TEXT_MARGIN_Y=2,ud.BORDER_RADIUS=4,g("\n.blocklyFlyoutButton {\n fill: #888;\n cursor: default;\n}\n\n.blocklyFlyoutButtonShadow {\n fill: #666;\n}\n\n@media (hover: hover) {\n .blocklyFlyoutButton:hover {\n fill: #aaa;\n }\n}\n\n.blocklyFlyoutButton:active {\n fill: #aaa;\n}\n\n.blocklyFlyoutLabel {\n cursor: default;\n}\n\n.blocklyFlyoutLabelBackground {\n opacity: 0;\n}\n");var cd,dd=cd||(cd={});dd[dd.COMMIT=1]="COMMIT",dd[dd.DELETE=2]="DELETE",dd[dd.REVERT=3]="REVERT";var pd,gd=pd||(pd={});gd.ESCAPE="escape",gd.DELETE="delete",gd.COPY="copy",gd.CUT="cut",gd.PASTE="paste",gd.UNDO="undo",gd.REDO="redo",gd.MENU="menu",gd.FOCUS_WORKSPACE="focus_workspace",gd.FOCUS_TOOLBOX="focus_toolbox",gd.START_MOVE="start_move",gd.START_MOVE_STACK="start_move_stack",gd.FINISH_MOVE="finish_move",gd.ABORT_MOVE="abort_move",gd.MOVE_UP="move_up",gd.MOVE_DOWN="move_down",gd.MOVE_LEFT="move_left",gd.MOVE_RIGHT="move_right",gd.NAVIGATE_RIGHT="right",gd.NAVIGATE_LEFT="left",gd.NAVIGATE_UP="up",gd.NAVIGATE_DOWN="down",gd.DISCONNECT="disconnect",gd.NEXT_STACK="next_stack",gd.PREVIOUS_STACK="previous_stack",gd.INFORMATION="information",gd.EXTENDED_INFORMATION="extended_information",gd.PERFORM_ACTION="perform_action",gd.DUPLICATE="duplicate",gd.CLEANUP="cleanup",gd.SHOW_TOOLTIP="show_tooltip",gd.NEXT_HEADING="next_heading",gd.PREVIOUS_HEADING="previous_heading",gd.TOGGLE_SCREENREADER="toggle_screenreader",gd.JUMP_TOP_STACK="jump_to_top_of_stack",gd.JUMP_BOTTOM_STACK="jump_to_bottom_of_stack",gd.JUMP_BLOCK_START="jump_to_block_start",gd.JUMP_BLOCK_END="jump_to_block_end",gd.JUMP_FIRST_BLOCK="jump_to_first_block",gd.JUMP_LAST_BLOCK="jump_to_last_block",gd.JUMP_PREVIOUS_PAGE="jump_to_previous_page",gd.JUMP_NEXT_PAGE="jump_to_next_page",gd.SCROLL_LEFT="scroll_left",gd.SCROLL_RIGHT="scroll_right",gd.SCROLL_UP="scroll_up",gd.SCROLL_DOWN="scroll_down";var Ed,Td=ca.registry.createSerializedKey(bc.LEFT,[bc.CTRL_CMD]),_d=ca.registry.createSerializedKey(bc.RIGHT,[bc.CTRL_CMD]),fd=ca.registry.createSerializedKey(bc.UP,[bc.CTRL_CMD]),md=ca.registry.createSerializedKey(bc.DOWN,[bc.CTRL_CMD]),bd=e=>{if(e.isFlyout){let t=e.targetWorkspace;if(t)return bd(t)}var t;return null!=(t=e.getRootWorkspace())?t:e},Cd=(e,t)=>!(e.isFlyout||!t.focusedNode||e.isDragging()||Zs.t().ephemeralFocusTaken()||!e.getNavigator().getSourceBlockFromNode(t.focusedNode)),vd=e=>(e=e.getToolbox())&&Zs.t().getFocusedTree()===e?e:null,Id=e=>{var t,i=null!=(t=vd(e))?t:e.isFlyout&&Zs.t().getFocusedTree()===e?e:null;return i?i.getNavigator().getNavigableItems(i.getRootFocusableNode()):null},Nd=e=>{var t;return(t=!e.isDragging()&&!Zs.t().ephemeralFocusTaken())&&((t=!!vd(e))||(t=e.isFlyout&&Zs.t().getFocusedTree()===e)),t},yd=Ed||(Ed={});yd[yd.LEFT=0]="LEFT",yd[yd.RIGHT=1]="RIGHT",yd[yd.UP=2]="UP",yd[yd.DOWN=3]="DOWN";var Ad={[Ed.LEFT]:"ANNOUNCE_SCROLLED_LEFT",[Ed.RIGHT]:"ANNOUNCE_SCROLLED_RIGHT",[Ed.UP]:"ANNOUNCE_SCROLLED_UP",[Ed.DOWN]:"ANNOUNCE_SCROLLED_DOWN"},kd=e=>{var t;return!e.isDragging()&&e.isMovable()&&!(null!=(t=e.targetWorkspace)&&t.isMutator)&&!yc.mover.isMoving()&&!bu&&!ju},Sd=e=>{e.getAudioManager().playErrorBeep(),v(Zs.C.ANNOUNCE_CANT_SCROLL_FURTHER)},Od=(e,t,i)=>{if(t.preventDefault(),i===Ed.LEFT||i===Ed.RIGHT?!e.isMovableHorizontally():!e.isMovableVertically())return Sd(e),!0;var n=t=0;switch(i){case Ed.LEFT:t=50;break;case Ed.RIGHT:t=-50;break;case Ed.UP:n=50;break;case Ed.DOWN:n=-50}var o=e.scrollX,s=e.scrollY;return e.scroll(o+t,s+n),e.scrollX===o&&e.scrollY===s?(Sd(e),!0):(v(Zs.C[Ad[i]]),!0)};Jo(),Qo(),Zo();var Rd={};Rd.names=pd,Rd.registerArrowNavigation=yo,Rd.registerCleanup=Fo,Rd.registerCopy=fo,Rd.registerCut=mo,Rd.registerDefaultShortcuts=Jo,Rd.registerDelete=To,Rd.registerDisconnectBlock=Ro,Rd.registerDuplicate=xo,Rd.registerEscape=Eo,Rd.registerFocusToolbox=ko,Rd.registerFocusWorkspace=Ao,Rd.registerHeadingNavigation=Lo,Rd.registerJumpBlockEnd=Uo,Rd.registerJumpBlockStart=Bo,Rd.registerJumpBottomStack=Ho,Rd.registerJumpFirstBlock=Go,Rd.registerJumpLastBlock=Wo,Rd.registerJumpNextPage=Yo,Rd.registerJumpPreviousPage=Xo,Rd.registerJumpTopStack=Vo,Rd.registerKeyboardNavigationShortcuts=Qo,Rd.registerMovementShortcuts=Io,Rd.registerNavigationShortcuts=function(){Bo(),Uo(),Vo(),Ho(),Go(),Wo(),Xo(),Yo(),Ko()},Rd.registerPaste=bo,Rd.registerPerformAction=Do,Rd.registerReadExtendedInformation=Oo,Rd.registerReadInformation=So,Rd.registerRedo=vo,Rd.registerScreenReaderShortcuts=Zo,Rd.registerShowContextMenu=No,Rd.registerShowTooltip=Mo,Rd.registerStackNavigation=wo,Rd.registerToggleScreenreaderMode=Po,Rd.registerUndo=Co,Rd.registerWorkspaceScrollShortcuts=Ko;var wd,Ld=wd||(wd={});Ld[Ld.CONSTRAINED=1]="CONSTRAINED",Ld[Ld.UNCONSTRAINED=2]="UNCONSTRAINED";var Dd=class{constructor(e){this.block=e,this.connectionPreviewer=this.connectionCandidate=this.startLoc=this.startChildConn=this.startParentConn=null,this.dragging=!1,this.allConnectionPairs=[],this.moveMode=wd.UNCONSTRAINED,this.originalEventGroup="",this.lastAnnouncedNeighbour=this.lastAnnouncedLocal=void 0,this.lastBlockDisabledReasons=new Map,this.WORKSPACE_MARGIN=this.BLOCK_CONNECTION_OFFSET=10,this.workspace=e.workspace}isMovable(){var e;return this.block.isOwnMovable()&&!this.block.isDeadOrDying()&&!this.workspace.isReadOnly()&&(!this.block.isInFlyout||this.block.isEnabled()&&!(null!=(e=this.block.workspace.targetWorkspace)&&e.isReadOnly()))}positionNewBlock(e,t){if(e=Le(e.workspace,e.getRelativeToSurfaceXY()),e=we(t.workspace,e),t.moveDuringDrag(e),this.moveMode===wd.CONSTRAINED){var i=(e=t.workspace).getMetricsManager().getViewMetrics(!0),n=i.top+this.WORKSPACE_MARGIN,o=e.RTL?i.left+i.width-this.WORKSPACE_MARGIN:i.left+this.WORKSPACE_MARGIN,s=Math.max(Zs.Og.connectingSnapRadius,Zs.Og.snapRadius)+2,r=e.getTopBlocks(!0).filter((e=>e.id!==t.id)).map((e=>(e=e.getBoundingRectangle(),new xa(e.top-s,e.bottom+s,e.left-s,e.right+s)))),a=t.getHeightWidth().width,l=function(e){for(let t of r)if(e.intersects(t))return t;return null},h=o,u=e.getRenderer().getConstants().MIN_BLOCK_HEIGHT,c=t.getBoundingRectangle();t.moveBy(e.RTL?h-c.right:h-c.left,n-c.top,["cleanup"]);for(var d=l(c=t.getBoundingRectangle());null!=d;)h=e.RTL?d.left-80:d.right+80,d=d.top+d.getHeight()+u,(e.RTL?h-a>=i.left:h+a<=i.left+i.width)||(n=d,h=o),t.moveBy(e.RTL?h-c.right:h-c.left,n-c.top,["cleanup"]),d=l(c=t.getBoundingRectangle())}}getTargetBlock(){if(this.block.isShadow()){var e=this.block.getParent();if(e)return e}else if(this.block.isInFlyout&&this.block.workspace.targetWorkspace&&(e=this.block.getRootBlock(),e=Dt(e)))return e=Mt(e,this.block.workspace.targetWorkspace,{recordUndo:!0}),Zs.Qc=!1,e.render(),this.positionNewBlock(this.block,e),e.setDragging(!0),Zs.Qc=!0,e;return this.block}announceMove(e=!1){if(this.connectionCandidate)e=ni(this.connectionCandidate.local,this.connectionCandidate.neighbour,this.hasMultipleCompatibleConnections.bind(this),e);else{var t=e?this.block.getStackBlocksCountLabel():"";e=(e=Zs.C.ANNOUNCE_MOVE_WORKSPACE).replace("%1",t)}var i,n,o,s;t=null!=(n=null==(i=this.connectionCandidate)?void 0:i.local)?n:null,i=null!=(s=null==(o=this.connectionCandidate)?void 0:o.neighbour)?s:null,void 0!==this.lastAnnouncedLocal&&t===this.lastAnnouncedLocal&&i===this.lastAnnouncedNeighbour||(this.lastAnnouncedLocal=t,this.lastAnnouncedNeighbour=i,v(e.replace(/\s+/g," ")))}hasMultipleCompatibleConnections(e=!0){var t=this.connectionCandidate;if(!t)return!1;var i=e?"local":"neighbour",n=e?"neighbour":"local";return this.allConnectionPairs.filter((e=>e[n]===t[n]&&e[i]!==t[i].getSourceBlock().nextConnection&&e[i].getSourceBlock().id===t[i].getSourceBlock().id)).length>1}startDrag(e){this.updateMoveMode(e);var t,i=this.getTargetBlock();if(i!==this.block)return i.startDrag(e);if(this.block.workspace.recordDragTargets(),this.dragging=!0,this.lastAnnouncedNeighbour=this.lastAnnouncedLocal=void 0,this.fireDragStartEvent(),this.startLoc=this.block.getRelativeToSurfaceXY(),this.connectionCandidate=null,this.connectionPreviewer=new(ae(ya.CONNECTION_PREVIEWER,this.workspace.options))(this.block),w(),this.workspace.setResizesEnabled(!1),eo(),i=this.shouldHealStack(e),this.storeInitialConnections(i),this.shouldDisconnect(i)&&this.disconnectBlock(i),this.block.setDragging(!0),this.enableAllDraggedBlocks(this.block),this.cacheAllConnectionPairs(),e instanceof KeyboardEvent){let t;e=null!=(t=this.getInitialCandidate())?t:void 0,this.updateConnectionPreview(this.block,new Da(0,0),e)&&this.block.moveDuringDrag(this.determineConnectionOffset()),this.allConnectionPairs.length?ts(this.workspace):es(this.workspace)}else this.block.moveDuringDrag(this.startLoc);return null==(t=this.workspace.getLayerManager())||t.moveToDragLayer(this.block),this.getVisibleBubbles(this.block).forEach((e=>{var t;null==(t=this.workspace.getLayerManager())||t.moveToDragLayer(e,!1)})),this.announceMove(!0),this.block}cacheAllConnectionPairs(){var e=this.block.workspace.connectionChecker,t=[];this.allConnectionPairs=[];var i=this.getLocalConnections(this.block);for(let e of this.block.workspace.getTopBlocks(!0))t.push(...this.getAllConnections(e));for(let n of t)for(let t of i){let i;!e.canConnect(t,n,!0,1/0)||null!=(i=n.targetBlock())&&i.isInsertionMarker()||this.allConnectionPairs.push({local:t,neighbour:n})}}getVisibleBubbles(e){return e.getDescendants(!1).flatMap((e=>e.getIcons())).filter((e=>pt(e)&&e.bubbleIsVisible())).map((e=>e.getBubble())).filter((e=>!!e)).sort(((e,t)=>(e=e.getSvgRoot().compareDocumentPosition(t.getSvgRoot()))&Node.DOCUMENT_POSITION_PRECEDING?1:e&Node.DOCUMENT_POSITION_FOLLOWING?-1:0))}shouldHealStack(e){return e instanceof PointerEvent?e.ctrlKey||e.metaKey:e instanceof KeyboardEvent&&!(e.shiftKey||!this.block.previousConnection)}shouldDisconnect(e){return!!(this.block.getParent()||e&&this.block.nextConnection&&this.block.nextConnection.targetBlock())}disconnectBlock(e){this.block.unplug(e),Qn(this.block)}storeInitialConnections(e){var t,i=this.startChildConn=this.startParentConn=null,n=null;if(null!=(t=this.block.outputConnection)&&t.isConnected())i=this.block.outputConnection,n=this.block.outputConnection.targetConnection;else{let e;null!=(e=this.block.previousConnection)&&e.isConnected()&&(i=this.block.previousConnection,n=this.block.previousConnection.targetConnection)}this.startParentConn=n,i&&n?this.connectionCandidate={local:i,neighbour:n,distance:0}:e&&(i=null==(e=this.block.nextConnection)?void 0:e.targetConnection,e&&i&&(this.connectionCandidate={local:e,neighbour:i,distance:0}),this.startChildConn=null!=i?i:null)}fireDragStartEvent(){var e=new(_e(Fr.BLOCK_DRAG))(this.block,!0,this.block.getDescendants(!1));ue(e)}fireDragEndEvent(){var e=new(_e(Fr.BLOCK_DRAG))(this.block,!1,this.block.getDescendants(!1));ue(e)}fireMoveEvent(){if(!this.block.isDeadOrDying()){var e=new(_e(Fr.BLOCK_MOVE))(this.block);e.setReason(["drag"]),e.oldCoordinate=this.startLoc,e.recordNew(),ue(e)}}drag(e,t){if(this.updateMoveMode(t),this.moveMode===wd.UNCONSTRAINED&&this.block.moveDuringDrag(e),t=!!this.connectionCandidate,this.updateConnectionPreview(this.block,Da.difference(e,this.startLoc)),this.connectionCandidate)this.moveMode===wd.CONSTRAINED&&this.block.moveDuringDrag(this.determineConnectionOffset());else if(this.moveMode===wd.CONSTRAINED&&(this.allConnectionPairs.length||es(this.workspace,!0),!t))return void this.workspace.getAudioManager().playErrorBeep();this.announceMove()}determineConnectionOffset(){var{local:e,neighbour:t}=this.connectionCandidate,i=e.getOffsetInBlock(),n=t.x-i.x;i=t.y-i.y;var o=this.BLOCK_CONNECTION_OFFSET;return e.type===Xl.PREVIOUS_STATEMENT||e.type===Xl.OUTPUT_VALUE?(n+=o,i+=o):(n-=o,i-=o),new Da(n,i)}updateConnectionPreview(e,t,i){var n=this.connectionCandidate;if(i=null!=i?i:this.getConnectionCandidate(t),this.connectionCandidate=null,i){var o=n&&this.currCandidateIsBetter(n,t,i)?n:i;this.connectionCandidate=o;var s,{local:r,neighbour:a}=o;if(o=r.type===Xl.OUTPUT_VALUE||r.type===Xl.PREVIOUS_STATEMENT,t=a.isConnected()&&!(null!=(s=a.targetBlock())&&s.isInsertionMarker()),o&&t&&!this.orphanCanConnectAtEnd(e,a.targetBlock(),r.type)){var l;null==(l=this.connectionPreviewer)||l.previewReplacement(r,a,a.targetBlock())}else{let e;null==(e=this.connectionPreviewer)||e.previewConnection(r,a)}return a}if(this.moveMode===wd.CONSTRAINED){let i,o;if((l=null!=(o=null==(s=null!=(i=null==n?void 0:n.neighbour.getSourceBlock())?i:null)?void 0:s.getRootBlock())?o:s)===e&&(l=s),!l){let e;return void(null==(e=this.connectionPreviewer)||e.hidePreview())}if(!(s=e.workspace.getTopBlocks().filter((t=>t!==e.getRootBlock())).map((e=>e.getBoundingRectangle()))).length){let e;return void(null==(e=this.connectionPreviewer)||e.hidePreview())}var h;switch(n=null!=(h=null==n?void 0:n.neighbour.x)?h:e.getRelativeToSurfaceXY().x,h=2*this.BLOCK_CONNECTION_OFFSET,this.getDirectionToNewLocation(Da.sum(this.startLoc,t))){case vc.LEFT:case vc.UP:t=Math.min(...s.map((e=>e.top)))-h-e.getHeightWidth().height;break;default:t=Math.max(...s.map((e=>e.bottom)))+h}e.moveDuringDrag(new Da(n,t))}null==(o=this.connectionPreviewer)||o.hidePreview()}orphanCanConnectAtEnd(e,t,i){return!!Hc.getConnectionForOrphanedConnection(e,i===Xl.OUTPUT_VALUE?t.outputConnection:t.previousConnection)}currCandidateIsBetter(e,t,i){if(this.moveMode===wd.CONSTRAINED)return!1;var{local:n,neighbour:o}=e;e=new Da(n.x,n.y);var s=new Da(o.x,o.y);return t=Da.distance(Da.sum(e,t),s),i.distance>t-Zs.Og.currentConnectionPreference}getConnectionCandidate(e){return this.moveMode===wd.CONSTRAINED?this.findTraversalCandidate(e):this.getClosestCandidate(this.block,e)}getClosestCandidate(e,t){var i=this.getSearchRadius();e=this.getLocalConnections(e);var n=null;for(let o of e){let{connection:e,radius:s}=o.closest(i,t);e&&(n={local:o,neighbour:e,distance:s},i=s)}return n}getSearchRadius(){return this.moveMode===wd.CONSTRAINED?1/0:this.connectionCandidate?Zs.Og.connectingSnapRadius:Zs.Og.snapRadius}getLocalConnections(e){var t=e.getConnections_(!1),i=e.lastConnectionInStack(!0);i&&i!==e.nextConnection&&t.push(i),e=[e.outputConnection,e.previousConnection,e.nextConnection].filter((e=>!!e)),i=[];for(let n of t)e.includes(n)||i.push(n);return i.reverse(),[...e,...i]}endDrag(e,t){var i;if(t===cd.DELETE&&Yn(this.block),this.originalEventGroup=Zs.gd,this.fireDragEndEvent(),this.fireMoveEvent(),L(),eo(),null==(i=this.connectionPreviewer)||i.hidePreview(),!this.block.isDeadOrDying()&&this.dragging&&t!==cd.DELETE){let e;null==(e=this.workspace.getLayerManager())||e.moveOffDragLayer(this.block,50),this.getVisibleBubbles(this.block).forEach((e=>{var t;return null==(t=this.workspace.getLayerManager())?void 0:t.moveOffDragLayer(e,100,!1)})),this.block.setDragging(!1),this.redisableAllDraggedBlocks(this.block)}this.connectionCandidate&&t!==cd.DELETE?(this.applyConnections(this.connectionCandidate),this.disposeStep()):(t!==cd.DELETE&&this.workspace.getAudioManager().play("drop"),this.block.queueRender().then((()=>this.disposeStep()))),this.allConnectionPairs=[],this.connectionCandidate=this.startChildConn=this.startParentConn=null,this.dragging=!1}disposeStep(){var e,t=Zs.gd;Zs.B(this.originalEventGroup),this.block.snapToGrid(),null==(e=this.connectionPreviewer)||e.dispose(),this.workspace.setResizesEnabled(!0),Zs.B(t)}applyConnections(e){var{local:t,neighbour:i}=e;t.connect(i);var n=t.isSuperior()?i:t,o=this.block.getRootBlock();Ze().then((()=>{Jn(n.getSourceBlock()),setTimeout((()=>{o.bringToFront()}),0)}))}revertDrag(){var e;if(null==(e=this.connectionPreviewer)||e.hidePreview(),this.connectionCandidate=null,this.block.nextConnection){let e;null==(e=this.startChildConn)||e.connect(this.block.nextConnection)}if(this.startParentConn)switch(this.startParentConn.type){case Xl.INPUT_VALUE:this.block.outputConnection&&this.startParentConn.connect(this.block.outputConnection);break;case Xl.NEXT_STATEMENT:this.block.previousConnection&&this.startParentConn.connect(this.block.previousConnection)}else{let e;this.block.moveDuringDrag(this.startLoc),null==(e=this.workspace.getLayerManager())||e.moveOffDragLayer(this.block,50),this.getVisibleBubbles(this.block).forEach((e=>{var t;return null==(t=this.workspace.getLayerManager())?void 0:t.moveOffDragLayer(e,100,!1)})),oo(this.workspace,this.workspace.getMetricsManager().getScrollMetrics(!0),this.block)}this.startParentConn=this.startChildConn=null,this.block.setDragging(!1),this.redisableAllDraggedBlocks(this.block),this.dragging=!1,v(Zs.C.ANNOUNCE_MOVE_CANCELED)}findTraversalCandidate(e){var t=this.getDirectionToNewLocation(Da.sum(this.startLoc,e)),i=this.allConnectionPairs;if(t===vc.NONE||!i.length)return this.connectionCandidate;t=t===vc.RIGHT||t===vc.DOWN;var n=i.findIndex((e=>{var t,i;return(null==(t=this.connectionCandidate)?void 0:t.local)===e.local&&(null==(i=this.connectionCandidate)?void 0:i.neighbour)===e.neighbour})),o=this.block.workspace.getNavigator();return t?-1===n?this.isInTerminalPosition(this.block,vc.DOWN)?o.getNavigationLoops()?this.pairToCandidate(i[0]):null:this.getClosestCandidate(this.block,e):n===i.length-1?null:this.pairToCandidate(i[n+1]):-1===n?this.isInTerminalPosition(this.block,vc.UP)?o.getNavigationLoops()?this.pairToCandidate(i[i.length-1]):null:this.getClosestCandidate(this.block,e):0===n?null:this.pairToCandidate(i[n-1])}isInTerminalPosition(e,t){if(e.getParent())return!1;var i=e.workspace.getTopBlocks(!0),n=e.getBoundingRectangle(),o=(t=t===vc.UP)?"top":"bottom",s=t?(e,t)=>e<=t:(e,t)=>e>=t;t=i.filter((t=>t.id!==e.id&&s(t.getBoundingRectangle()[o],n[o]))),i=e.getConnections_(!1);for(let n of t){t=this.getAllConnections(n);for(let n of i)for(let i of t)if(e.workspace.connectionChecker.canConnect(n,i,!0,1/0))return!1}return!0}pairToCandidate(e){return Object.assign({},e,{distance:0})}getDirectionToNewLocation(e){var t=this.block.getRelativeToSurfaceXY();e=Da.difference(e,t);var{x:i,y:n}=e;return Math.abs(i)>Math.abs(n)?i<0?vc.LEFT:vc.RIGHT:Math.abs(n)>0?n<0?vc.UP:vc.DOWN:vc.NONE}getAllConnections(e){if(e.isShadow())return[];var t=[];if(e.outputConnection&&t.push(e.outputConnection),e.previousConnection&&t.push(e.previousConnection),!e.isCollapsed())for(let i of e.inputList)if(i.connection&&i.isVisible()){t.push(i.connection);let e=i.connection.targetBlock();e&&t.push(...this.getAllConnections(e))}return e.nextConnection&&(t.push(e.nextConnection),(e=e.nextConnection.targetBlock())&&t.push(...this.getAllConnections(e))),t}getInitialCandidate(){var e=this.workspace.getSvgGroup().querySelector(`.${ha.PASSIVE_FOCUS_NODE_CSS_CLASS_NAME}`);if(!e||!e.id||e===this.block.getFocusableElement())return null;if(!(e=this.workspace.lookUpFocusableNode(e.id)))return null;var t=this.workspace.getNavigator().getSourceBlockFromNode(e);if(!t)return null;var i=null;if(t.getConnections_(!1).includes(e)){i=e;let t=this.block.workspace.connectionChecker;if(e=this.block.getConnections_(!1).find((e=>t.canConnect(e,i,!0,1/0))))return{local:e,neighbour:i,distance:0}}if(e=this.allConnectionPairs.find((e=>e.neighbour.getSourceBlock()===t)))return this.pairToCandidate(e);var n,o=null==(n=t.outputConnection)?void 0:n.targetConnection;if(n=this.allConnectionPairs.find((e=>e.neighbour===o)))return this.pairToCandidate(n);for(var s=t.getSurroundParent();s;){if(n=this.allConnectionPairs.find((e=>e.neighbour.getSourceBlock()===s)))return this.pairToCandidate(n);s=s.getSurroundParent()}return null}updateMoveMode(e){this.moveMode=e instanceof KeyboardEvent&&!e.ctrlKey&&!e.metaKey?wd.CONSTRAINED:wd.UNCONSTRAINED}enableAllDraggedBlocks(e){var t=Zs.Qc;Zs.Qc=!1,this.lastBlockDisabledReasons.clear(),e.getDescendants(!1).forEach((e=>{var t=new Set(e.getDisabledReasons());this.lastBlockDisabledReasons.set(e.id,t),t.forEach((t=>e.setDisabledReason(!1,t)))})),Zs.Qc=t}redisableAllDraggedBlocks(e){var t=Zs.Qc;Zs.Qc=!1,e.getDescendants(!1).forEach((e=>{var t;null==(t=this.lastBlockDisabledReasons.get(e.id))||t.forEach((t=>{e.setDisabledReason(!0,t)}))})),Zs.Qc=t}},xd=class extends Wu{isLabelField(){return!0}constructor(e,t,i){super(Wu.SKIP_SETUP),this.class=null,this.EDITABLE=!1,this.maxDisplayLength=1/0,e!==Wu.SKIP_SETUP&&(i?this.configure_(i):this.class=t||null,this.setValue(e))}configure_(e){super.configure_(e),e.class&&(this.class=e.class)}initView(){this.createTextElement_(),this.class&&N(this.getTextElement(),this.class),this.fieldGroup_&&(N(this.fieldGroup_,"blocklyLabelField"),f(this.fieldGroup_,$r.HIDDEN,!0))}computeAriaLabel(e=!0){e=e?this.getAriaTypeName():null;var t,i=null!=(t=this.getAriaValue())?t:"";return e?`${e}: ${i}`:i}doClassValidation_(e){return null==e?null:`${e}`}setClass(e){this.textElement_&&(this.class&&A(this.textElement_,this.class),e&&N(this.textElement_,e)),this.class=e}static fromJson(e){return new this(Ji(e.text),void 0,e)}};wn("field_label",xd),xd.prototype.DEFAULT_VALUE="";var Fd=class extends wc{constructor(e,t,i,n,o){super(t,i,n,void 0,o),this.text=e,this.workspace=t,this.anchor=i,this.ownerRect=n,this.owner=o,this.paragraph=this.stringToSvg(e,this.contentContainer),this.updateBubbleSize(),N(this.svgRoot,"blocklyTextBubble")}getText(){return this.text}setText(e){this.text=e,S(this.paragraph),this.paragraph=this.stringToSvg(e,this.contentContainer),this.updateBubbleSize()}stringToSvg(e,t){return t=this.createParagraph(t),e=this.createTextFragments(t,e),this.workspace.RTL&&this.rightAlignTextFragments(t.getBBox().width,e),t}createParagraph(e){return I(ea.G,{class:"blocklyText blocklyBubbleText blocklyNoPointerEvents",transform:`translate(0,${wc.BORDER_WIDTH})`,style:"direction: "+(this.workspace.RTL?"rtl":"ltr")},e)}createTextFragments(e,t){var i=1;return t.split("\n").map((t=>{var n=I(ea.TEXT,{y:`${i}em`,x:wc.BORDER_WIDTH},e);return t=document.createTextNode(t),n.appendChild(t),i+=1,n}))}rightAlignTextFragments(e,t){for(let i of t)i.setAttribute("text-anchor","start"),i.setAttribute("x",`${e+wc.BORDER_WIDTH}`)}updateBubbleSize(){var e=this.paragraph.getBBox();this.setSize(new Fa(e.width+2*wc.BORDER_WIDTH,e.height+2*wc.BORDER_WIDTH),!0)}},Md=class extends Dc{constructor(e){super(e),this.sourceBlock=e,this.textMap=new Map,this.textBubble=null}getType(){return Md.TYPE}initView(e){this.svgRoot||(super.initView(e),I(ea.PATH,{class:"blocklyIconShape",d:"M2,15Q-1,15 0.5,12L6.5,1.7Q8,-1 9.5,1.7L15.5,12Q17,15 14,15z"},this.svgRoot),I(ea.PATH,{class:"blocklyIconSymbol",d:"m7,4.8v3.16l0.27,2.27h1.46l0.27,-2.27v-3.16z"},this.svgRoot),I(ea.RECT,{class:"blocklyIconSymbol",x:"7",y:"11",height:"2",width:"2"},this.svgRoot),N(this.svgRoot,"blocklyWarningIcon"))}dispose(){var e;super.dispose(),null==(e=this.textBubble)||e.dispose()}getWeight(){return Md.WEIGHT}getSize(){return new Fa(17,17)}applyColour(){var e;super.applyColour(),null==(e=this.textBubble)||e.setColour(this.sourceBlock.getColour())}updateCollapsed(){}isShownWhenCollapsed(){return!0}onLocationChange(e){var t;super.onLocationChange(e),null==(t=this.textBubble)||t.setAnchorLocation(this.getAnchorLocation())}addMessage(e,t){return this.textMap.get(t)===e||(e?this.textMap.set(t,e):this.textMap.delete(t),null==(i=this.textBubble)||i.setText(this.getText())),this;var i}getText(){return[...this.textMap.values()].join("\n")}onClick(){super.onClick(),this.setBubbleVisible(!this.bubbleIsVisible())}isClickableInFlyout(){return!1}bubbleIsVisible(){return!!this.textBubble}setBubbleVisible(e){var t=this;return(0,Qs.asyncExecutePromiseGeneratorFunction)((function*(){if(t.bubbleIsVisible()!==e){if(yield Ze(),e)t.textBubble=new Fd(t.getText(),t.sourceBlock.workspace,t.getAnchorLocation(),t.getBubbleOwnerRect(),t),t.applyColour(),t.textBubble.setAriaLabelProvider((()=>Zs.C.BUBBLE_LABEL_WARNING.replace("%1",t.getText())));else{let e;null==(e=t.textBubble)||e.dispose(),t.textBubble=null}ue(new(_e(Fr.BUBBLE_OPEN))(t.sourceBlock,e,"warning")),t.recomputeAriaContext()}}))}getBubble(){return this.textBubble}getAnchorLocation(){return Da.sum(this.workspaceLocation,new Da(8.5,8.5))}getBubbleOwnerRect(){var e=this.sourceBlock.getSvgRoot().getBBox();return new xa(e.y,e.y+e.height,e.x,e.x+e.width)}getAriaLabel(){return this.bubbleIsVisible()?Zs.C.ICON_LABEL_WARNING_OPEN:Zs.C.ICON_LABEL_WARNING_CLOSED}};Md.TYPE=Hl.WARNING,Md.WEIGHT=2;var Pd=class extends Zc{constructor(e,t,i){if(super(e,t,i),this.childlessWidth=this.width=this.height=0,this.warningTextDb=new Map,this.mutator=null,this.rendered=!0,this.visuallyDisabled=!1,this.previousConnection=this.nextConnection=this.outputConnection=null,this.translation="",this.dragging=!1,this.relativeCoords=new Da(0,0),this.dragStrategy=new Dd(this),!e.rendered)throw TypeError("Cannot create a rendered block in a headless workspace");this.workspace=e,this.svgGroup=I(ea.G,{}),t&&N(this.svgGroup,t),this.style=e.getRenderer().getConstants().getBlockStyle(null),this.pathObject=e.getRenderer().makePathObject(this.svgGroup,this.style),(e=this.pathObject.svgPath).tooltip=this,Di(e),this.svgGroup.setAttribute("data-id",this.id),e.id=le(),this.doInit_()}initSvg(){if(!this.initialized){for(var e of this.inputList)e.init();for(let e of this.getIcons())e.initView(this.createIconPointerDownListener(e)),e.updateEditable();this.applyColour(),this.pathObject.updateMovable(this.isMovable()||this.isInFlyout),(e=this.getSvgRoot())&&r(e,"pointerdown",this,this.onMouseDown),e.parentNode||this.workspace.getCanvas().appendChild(e),this.recomputeAriaContext(),this.initialized=!0}}getColourSecondary(){return this.style.colourSecondary}getColourTertiary(){return this.style.colourTertiary}select(){this.addSelect(),z(this)}unselect(){this.removeSelect(),z(null)}setParent(e){var t=this.parentBlock_;if(e!==t){w(),super.setParent(e),L();var i=this.getSvgRoot();if(!this.workspace.isClearing&&i){var n,o=Zs.t().getFocusedNode(),s=this.getSvgRoot().contains(null!=(n=null==o?void 0:o.getFocusableElement())?n:null);e?(e.getSvgRoot().appendChild(i),s&&o&&Zs.t().focusNode(o)):t&&(e=this.getRelativeToSurfaceXY(),this.workspace.getCanvas().appendChild(i),this.translate(e.x,e.y)),s&&o&&Zs.t().focusNode(o),this.applyColour(),this.recomputeAriaContext()}}}moveBy(e,t,i){if(this.parentBlock_)throw Error("Block has parent");var n=Ee(),o=null;n&&(o=new(_e(Fr.BLOCK_MOVE))(this),i&&o.setReason(i)),e=new Da(e,t),t=this.getRelativeToSurfaceXY(),e=Da.sum(t,e),this.translate(e.x,e.y),this.workspace.connectionDBList.forEach((e=>null==e?void 0:e.beginBulkUpdates())),this.updateComponentLocations(e),this.workspace.connectionDBList.forEach((e=>null==e?void 0:e.endBulkUpdates())),n&&o&&(o.recordNew(),ue(o)),this.workspace.resizeContents()}translate(e,t){this.translation=`translate(${e}, ${t})`,this.relativeCoords=new Da(e,t),this.getSvgRoot().setAttribute("transform",this.getTranslation())}getTranslation(){return this.translation}moveTo(e,t){var i=this.getRelativeToSurfaceXY();this.moveBy(e.x-i.x,e.y-i.y,t)}moveDuringDrag(e){this.translate(e.x,e.y),this.updateComponentLocations(e)}snapToGrid(){if(!this.isDeadOrDying()&&!this.getParent()&&!this.isInFlyout){var e=this.workspace.getGrid();if(null!=e&&e.shouldSnap()){var t=this.getRelativeToSurfaceXY();(e=e.alignXY(t))!==t&&this.moveTo(e,["snap"])}}}getBoundingRectangle(){return this.getBoundingRectangleWithDimensions(this.getHeightWidth())}getBoundingRectangleWithoutChildren(){return this.getBoundingRectangleWithDimensions({height:this.height,width:this.childlessWidth})}getBoundingRectangleWithDimensions(e){var t=this.getRelativeToSurfaceXY();if(this.RTL)var i=t.x-e.width,n=t.x;else i=t.x,n=t.x+e.width;return new xa(t.y,t.y+e.height,i,n)}markDirty(){this.pathObject.constants=this.workspace.getRenderer().getConstants();for(let e,t=0;e=this.inputList[t];t++)e.markDirty()}setCollapsed(e){this.collapsed_!==e&&(super.setCollapsed(e),this.updateCollapsed())}childHasWarning(){var e=this.getNextBlock();e=e?new Set(e.getDescendants(!1)):null;var t=this.getDescendants(!1);for(let i of t)if(i!==this&&(null==e||!e.has(i))&&i.getIcon(Md.TYPE))return!0;return!1}updateCollapsed(){var e=this.isCollapsed();for(let t,i=0;t=this.inputList[i];i++)"_TEMP_COLLAPSED_INPUT"!==t.name&&t.setVisible(!e);for(var t of this.getIcons())t.updateCollapsed();e?(N(this.svgGroup,"blocklyCollapsed"),this.childHasWarning()&&this.setWarningText(Zs.C.COLLAPSED_WARNINGS_WARNING,Pd.COLLAPSED_WARNING_ID),e=this.toString(30),(t=this.getField("_TEMP_COLLAPSED_FIELD"))?t.setValue(e):((this.getInput("_TEMP_COLLAPSED_INPUT")||this.appendDummyInput("_TEMP_COLLAPSED_INPUT")).appendField(new xd(e),"_TEMP_COLLAPSED_FIELD"),this.recomputeAriaContext())):(this.updateDisabled(),this.removeInput("_TEMP_COLLAPSED_INPUT"),A(this.svgGroup,"blocklyCollapsed"),this.setWarningText(null,Pd.COLLAPSED_WARNING_ID))}onMouseDown(e){if(!this.workspace.isReadOnly()){var t=this.workspace.getGesture(e);t&&t.handleBlockStart(e,this)}}showHelp(){var e="function"==typeof this.helpUrl?this.helpUrl():this.helpUrl;e&&window.open(e)}generateContextMenu(e){return this.workspace.isReadOnly()||!this.contextMenu?null:(e=nc.registry.getContextMenuOptions({block:this,focusedNode:this},e),this.customContextMenu&&this.customContextMenu(e),e)}calculateContextMenuLocation(e){if(e instanceof PointerEvent)return new Da(e.clientX,e.clientY);e=Le(this.workspace,this.getRelativeToSurfaceXY());var t,i,n=null==(t=this.inputList.filter((e=>e.isVisible())).flatMap((e=>e.fieldRow)).find((e=>e.isVisible())))||null==(i=t.getSvgRoot())?void 0:i.getBoundingClientRect();return new Da(this.RTL?e.x-5:e.x+5,(n&&n.height?n.y+n.height:e.y+this.height)+5)}showContextMenu(e){if(this.isShadow()){for(var t=this.getParent();t&&t.isShadow();)t=t.getParent();t&&(Zs.t().focusNode(t),t.showContextMenu(e))}else{t=this.generateContextMenu(e);var i=this.calculateContextMenuLocation(e);t&&t.length&&(hn(e,t,this.RTL,this.workspace,i),Zu=this)}}updateComponentLocations(e){this.xy.x=e.x,this.xy.y=e.y,this.dragging||this.updateConnectionLocations(e),this.updateIconLocations(e),this.updateFieldLocations(e);for(let t of this.getChildren(!1))t.updateComponentLocations(Da.sum(e,t.relativeCoords))}updateConnectionLocations(e){for(let t of this.getConnections_(!1))t.moveToOffset(e)}updateIconLocations(e){for(let t of this.getIcons())t.onLocationChange(e)}updateFieldLocations(e){for(let t of this.inputList)for(let i of t.fieldRow)i.onLocationChange(e)}addClass(e){N(this.svgGroup,e)}removeClass(e){A(this.svgGroup,e)}setDragging(e){(this.dragging=e)?(this.translation="",ma.push(...this.getConnections_(!0)),this.addClass("blocklyDragging")):(ma.length=0,this.removeClass("blocklyDragging"),this.getFullBlockField()&&this.recomputeAriaContext());for(let t=0;t<this.childBlocks_.length;t++)this.childBlocks_[t].setDragging(e)}isDragging(){return this.dragging}setMovable(e){super.setMovable(e),this.pathObject.updateMovable(e)}setEditable(e){super.setEditable(e),e?A(this.svgGroup,"blocklyNotEditable"):N(this.svgGroup,"blocklyNotEditable"),e=this.getIcons();for(let t=0;t<e.length;t++)e[t].updateEditable()}setShadow(e){super.setShadow(e),this.applyColour(),this.recomputeAriaContext()}setInsertionMarker(e){this.isInsertionMarker_!==e&&(this.isInsertionMarker_=e)&&(this.setColour(this.workspace.getRenderer().getConstants().INSERTION_MARKER_COLOUR),this.pathObject.updateInsertionMarker(!0))}getSvgRoot(){return this.svgGroup}getNearestNeighbour(){if(!this.workspace.rendered)return null;var e=this.workspace.getAllBlocks(!1).filter((e=>!e.isDeadOrDying())),t=null,i=Number.MAX_SAFE_INTEGER,n=this.getRelativeToSurfaceXY();for(let o of e)e=o.getRelativeToSurfaceXY(),(e=Math.sqrt(Math.pow(e.x-n.x,2)+Math.pow(e.y-n.y,2)))<i&&(t=o,i=e);return t}dispose(e,t){this.disposing=!0,xi(this.pathObject.svgPath),delete this.pathObject.svgPath.tooltip,Bi(),pn(),t&&(this.unplug(e),Yn(this));var i=Zs.t();try{let e,t;var n=null!=(t=null==(e=i.getFocusedNode())?void 0:e.getFocusableElement())?t:null}catch(e){n=null}if(super.dispose(!!e),S(this.svgGroup),this.getSvgRoot().contains(n)){let t=this.getParent();if(!t){let i;if(e=null!=(i=this.outputConnection)?i:this.previousConnection){let i;t=null==(i=e.closest(0,new Da(0,0)).connection)?void 0:i.getSourceBlock()}}setTimeout((()=>{if(this.workspace.rendered)if(t)i.focusNode(t);else{let e=this.getNearestNeighbour();e?i.focusNode(e):i.focusTree(this.workspace)}}),0)}}disposeInternal(){this.disposing=!0,super.disposeInternal(),Zs.t().getFocusedNode()===this&&this.workspace.cancelCurrentGesture(),[...this.warningTextDb.values()].forEach((e=>clearTimeout(e))),this.warningTextDb.clear(),this.getIcons().forEach((e=>e.dispose()))}checkAndDelete(){this.workspace.isFlyout||(Zs.B(!0),this.workspace.hideChaff(),this.outputConnection?this.dispose(!1,!0):this.dispose(!0,!0),Zs.B(!1))}toCopyData(e=!1){return this.isInsertionMarker_?null:{paster:nd.TYPE,blockState:Dt(this,{addCoordinates:!0,addNextBlocks:e,saveIds:!1}),typeCounts:J(this,!0)}}applyColour(){var e,t;for(null==(t=(e=this.pathObject).applyColour)||t.call(e,this),e=this.getIcons(),t=0;t<e.length;t++)e[t].applyColour();for(let e of this.getFields())e.applyColour()}updateDisabled(){var e=!this.isEnabled()||this.getInheritedDisabled();if(this.visuallyDisabled===e){let e;null==(e=this.getNextBlock())||e.updateDisabled()}else{this.applyColour(),this.visuallyDisabled=e;for(let e of this.getChildren(!1))e.updateDisabled();this.recomputeAriaContext()}}setWarningText(e,t=""){if(t)this.warningTextDb.has(t)&&(clearTimeout(this.warningTextDb.get(t)),this.warningTextDb.delete(t));else{for(var i of this.warningTextDb.values())clearTimeout(i);this.warningTextDb.clear()}if(this.workspace.isDragging())this.warningTextDb.set(t,setTimeout((()=>{this.isDeadOrDying()||(this.warningTextDb.delete(t),this.setWarningText(e,t))}),100));else if(this.isInFlyout&&(e=null),i=this.getIcon(Md.TYPE),e){let n=this.getSurroundParent(),o=null;for(;n;)n.isCollapsed()&&(o=n),n=n.getSurroundParent();o&&o.setWarningText(Zs.C.COLLAPSED_WARNINGS_WARNING,Pd.COLLAPSED_WARNING_ID),i?i.addMessage(e,t):this.addIcon(new Md(this).addMessage(e,t))}else i&&(t?(i.addMessage("",t),i.getText()||this.removeIcon(Md.TYPE)):this.removeIcon(Md.TYPE))}setMutator(e){this.removeIcon(Zs.sh.TYPE),e&&this.addIcon(e)}addIcon(e){return super.addIcon(e),e instanceof Zs.sh&&(this.mutator=e),e.initView(this.createIconPointerDownListener(e)),e.applyColour(),e.updateEditable(),this.queueRender(),e}createIconPointerDownListener(e){return t=>{!this.isDeadOrDying()&&(t=this.workspace.getGesture(t))&&(this.bringToFront(),t.setStartIcon(e),Zs.t().focusNode(e))}}removeIcon(e){var t=super.removeIcon(e);return e.equals(Zs.sh.TYPE)&&(this.mutator=null),this.queueRender(),t}setDisabledReason(e,t){var i=this.isEnabled();super.setDisabledReason(e,t),this.isEnabled()===i||this.getInheritedDisabled()||this.updateDisabled()}setDeletable(e){super.setDeletable(e),e?A(this.svgGroup,"blocklyNotDeletable"):N(this.svgGroup,"blocklyNotDeletable")}setHighlighted(e){this.pathObject.updateHighlighted(e)}addSelect(){this.pathObject.updateSelected(!0)}removeSelect(){this.pathObject.updateSelected(!1)}setDeleteStyle(e){this.pathObject.updateDraggingDelete(e)}getColour(){return this.style.colourPrimary}setColour(e){var t,i;super.setColour(e),e=this.workspace.getRenderer().getConstants().getBlockStyleForColour(this.colour_),null==(i=(t=this.pathObject).setStyle)||i.call(t,e.style),this.style=e.style,this.styleName_=e.name,this.applyColour()}setStyle(e){var t=this.workspace.getRenderer().getConstants().getBlockStyle(e);if(this.styleName_&&A(this.svgGroup,this.styleName_),!t)throw Error("Invalid style name: "+e);{let i,n;this.hat=t.hat,null==(n=(i=this.pathObject).setStyle)||n.call(i,t),this.colour_=t.colourPrimary,this.style=t,this.applyColour(),N(this.svgGroup,e),this.styleName_=e}}getStyle(){return this.style}bringToFront(e=!1){var t=Zs.t().getFocusedNode();this.moveSvgRootToFront(e),t&&Zs.t().focusNode(t)}moveSvgRootToFront(e=!1){this.isDeadOrDying()||requestAnimationFrame((()=>{if(!this.dragging){var t=this;do{if(t.isDeadOrDying())break;let i=t.getSvgRoot(),n=i.parentNode;if(!n)break;let o=n.childNodes;if(o[o.length-1]!==i)for(;i.nextSibling;)n.insertBefore(i.nextSibling,i);if(e)break;t=t.getParent()}while(t)}}))}setPreviousStatement(e,t){super.setPreviousStatement(e,t),this.queueRender()}setNextStatement(e,t){super.setNextStatement(e,t),this.queueRender()}setOutput(e,t){super.setOutput(e,t),this.queueRender()}setInputsInline(e){super.setInputsInline(e),this.queueRender()}removeInput(e,t){return e=super.removeInput(e,t),this.queueRender(),e}moveNumberedInputBefore(e,t){super.moveNumberedInputBefore(e,t),this.queueRender()}appendInput(e){return super.appendInput(e),this.queueRender(),e}setConnectionTracking(e){if(this.previousConnection&&this.previousConnection.setTracking(e),this.outputConnection&&this.outputConnection.setTracking(e),this.nextConnection){this.nextConnection.setTracking(e);var t=this.nextConnection.targetBlock();t&&t.setConnectionTracking(e)}if(!this.collapsed_)for(t=0;t<this.inputList.length;t++){var i=this.inputList[t].connection;i&&(i.setTracking(e),(i=i.targetBlock())&&i.setConnectionTracking(e))}}getConnections_(e){var t=[];if(this.outputConnection&&t.push(this.outputConnection),this.previousConnection&&t.push(this.previousConnection),this.nextConnection&&t.push(this.nextConnection),e||!this.collapsed_)for(let e,i=0;e=this.inputList[i];i++)e.connection&&t.push(e.connection);return t}lastConnectionInStack(e){return super.lastConnectionInStack(e)}getMatchingConnection(e,t){return super.getMatchingConnection(e,t)}makeConnection_(e){return new jc(this,e)}getNextBlock(){return super.getNextBlock()}getPreviousBlock(){return super.getPreviousBlock()}bumpNeighbours(){var e=this.getRootBlock();if(!(this.isDeadOrDying()||this.workspace.isDragging()||this.isDragging()||e.isInFlyout))for(let t of this.getConnections_(!1)){if(t.isSuperior()){let e;null==(e=t.targetBlock())||e.bumpNeighbours()}for(let i of t.neighbours(Zs.Og.snapRadius))i.getSourceBlock().getRootBlock()!==e&&(t.isConnected()&&i.isConnected()||(t.isSuperior()?i.bumpAwayFrom(t,!1):i.getSourceBlock().isDragging()||t.bumpAwayFrom(i,!0)))}}scheduleSnapAndBump(){this.snapToGrid(),this.bumpNeighbours()}positionNearConnection(e,t,i){if(e.type===Xl.NEXT_STATEMENT||e.type===Xl.INPUT_VALUE){let n=t.x;t=t.y,n+=i.x-e.getOffsetInBlock().x,t+=i.y-e.getOffsetInBlock().y,this.moveBy(n,t)}}getChildren(e){return super.getChildren(e)}queueRender(){return Qe(this)}render(){this.queueRender(),et()}renderEfficiently(){w(),this.isCollapsed()&&this.updateCollapsed(),this.isEnabled()||this.updateDisabled(),this.workspace.getRenderer().render(this),this.tightenChildrenEfficiently(),L()}tightenChildrenEfficiently(){for(let e of this.inputList){let t=e.connection;t&&t.tightenEfficiently()}this.nextConnection&&this.nextConnection.tightenEfficiently()}getHeightWidth(){var e=this.height,t=this.width,i=this.getNextBlock();if(i){i=i.getHeightWidth();let n=this.workspace.getRenderer().getConstants().NOTCH_HEIGHT;e+=i.height-n,t=Math.max(t,i.width)}return{height:e,width:t}}fadeForReplacement(e){var t,i;null==(i=(t=this.pathObject).updateReplacing)||i.call(t,e)}getDragStrategy(){return this.dragStrategy}setDragStrategy(e){this.dragStrategy=e}isCopyable(){return this.isOwnDeletable()&&this.isOwnMovable()}isMovable(){return this.dragStrategy.isMovable()}startDrag(e){return this.dragStrategy.startDrag(e)}drag(e,t){this.dragStrategy.drag(e,t)}endDrag(e,t){this.dragStrategy.endDrag(e,t)}revertDrag(){this.dragStrategy.revertDrag()}toFlyoutInfo(){var e=Object.assign({},{kind:"BLOCK"},Dt(this)),t=new Set(["id","height","width","pinned","enabled"]);return function e(i){for(let n in i)t.has(n)?delete i[n]:"object"==typeof i[n]&&e(i[n])}(e),[e]}jsonInit(e){super.jsonInit(e),e.classes&&this.addClass(Array.isArray(e.classes)?e.classes.join(" "):e.classes)}getNestingLevel(){var e=this.getSurroundParent();return e?e.getNestingLevel()+1:0}getFocusableElement(){var e=this.getFullBlockField();return e?e.getFocusableElement():this.pathObject.svgPath}getFocusableTree(){return this.workspace}onNodeFocus(){this.recomputeAriaContext(),this.select(),this.workspace.isFlyout||this.moveSvgRootToFront();var e=Zs.t().getFocusedNode();e&&e!==this&&Ze().then((()=>{this.workspace.scrollBoundsIntoView(this.getBoundingRectangleWithoutChildren())}))}onNodeBlur(){this.unselect()}canBeFocused(){return!0}performAction(e){if(this.workspace.isFlyout)yc.mover.startMove(this,e);else{if(this.isSimpleReporter())for(var t of this.inputList)for(let e of t.fieldRow)if(e.isClickable()&&e.isFullBlockField())return void e.showEditor();this.workspace.getNavigator().getInNode(this)?(e=this.workspace,t=Vt(e.RTL?pd.NAVIGATE_LEFT:pd.NAVIGATE_RIGHT),t=Zs.C.KEYBOARD_NAV_BLOCK_NAVIGATION_HINT.replace("%1",t),Ol.show(e,{message:t,id:"blockNavigationHint"})):(e=this.workspace,(t=Vt("list_shortcuts"))&&(t=Zs.C.HELP_PROMPT.replace("%1",t),Ol.show(e,{message:t,id:"helpHint"})))}}getParents(){for(var e=new Set,t=this.getParent();t;)e.add(t),t=t.getParent();return e}getOutputParents(){var e=new Set;e.add(this);for(var t,i=null==(t=this.outputConnection)?void 0:t.targetBlock();i;){let t;e.add(i),i=null==(t=i.outputConnection)?void 0:t.targetBlock()}return e}getRowId(){var e,t,i=null==(e=this.outputConnection)||null==(t=e.targetConnection)?void 0:t.getParentInput();return i?i.getRowId():this.id}recomputeAriaContext(){var e=this.getFullBlockField();e?e.recomputeAriaContext():(!(e=this.getAriaLabel(Xr.STANDARD))||Ir||e.endsWith(",")||(e+=","),f(this.getFocusableElement(),$r.LABEL,e),_(this.getSvgRoot(),Hr.NONE),e=this.getFocusableElement(),this.isInFlyout||_(e,Hr.FIGURE),f(e,$r.ROLEDESCRIPTION,this.getAriaRoleDescription()))}getAriaLabel(e){return $t(this,e)}getStackBlocksCountLabel(){for(var e=1,t=this.getNextBlock();t;)e++,t=t.getNextBlock();return e<=1?$t(this,Xr.TERSE):Zs.C.BLOCK_LABEL_STACK_BLOCKS.replace("%1",e.toString())}};Pd.INLINE=-1,Pd.COLLAPSED_WARNING_ID="TEMP_COLLAPSED_WARNING_";var Bd=class{constructor(){}onDragEnter(){}onDragOver(){}onDragExit(){}onDrop(){}getClientRect(){return null}shouldPreventMove(){return!1}},Ud=class extends Bd{constructor(){super(),this.wouldDelete_=!1}wouldDelete(e){return yc.mover.isMoving()?this.updateWouldDelete_(!1):e instanceof Pd?(e=!e.getParent()&&e.isDeletable(),this.updateWouldDelete_(e)):this.updateWouldDelete_(po(e)&&e.isDeletable()),this.wouldDelete_}updateWouldDelete_(e){this.wouldDelete_=e}},Vd=class{constructor(e,t){this.element=e,this.type=t}getElement(){return this.element}getType(){return this.type}},Hd=class{constructor(e){this.workspace_=e}getDimensionsPx_(e){var t=0,i=0;return e&&(t=e.getWidth(),i=e.getHeight()),new Fa(t,i)}getFlyoutMetrics(e){return{width:(e=this.getDimensionsPx_(this.workspace_.getFlyout(e))).width,height:e.height,position:this.workspace_.toolboxPosition}}getToolboxMetrics(){var e=this.getDimensionsPx_(this.workspace_.getToolbox());return{width:e.width,height:e.height,position:this.workspace_.toolboxPosition}}getSvgMetrics(){return this.workspace_.getCachedParentSvgSize()}getAbsoluteMetrics(){var e,t=0,i=0,n=this.getToolboxMetrics(),o=this.getFlyoutMetrics(),s=!!this.workspace_.getToolbox(),r=!(null!=(e=this.workspace_.getFlyout())&&e.autoClose),a=(e=s?n.position:o.position)===Ya.TOP;return e===Ya.LEFT&&(s&&(t+=n.width),r&&(t+=o.width)),a&&(s&&(i+=n.height),r&&(i+=o.height)),{top:i,left:t}}getViewMetrics(e){e=e?this.workspace_.scale:1;var t,i=this.getSvgMetrics(),n=this.getToolboxMetrics(),o=this.getFlyoutMetrics(),s=!!this.workspace_.getToolbox(),r=!(null!=(t=this.workspace_.getFlyout())&&t.autoClose),a=(t=s?n.position:o.position)===Ya.LEFT||t===Ya.RIGHT;return t!==Ya.TOP&&t!==Ya.BOTTOM||(s&&(i.height-=n.height),r&&(i.height-=o.height)),a&&(s&&(i.width-=n.width),r&&(i.width-=o.width)),{height:i.height/e,width:i.width/e,top:-this.workspace_.scrollY/e,left:-this.workspace_.scrollX/e}}getContentMetrics(e){e=e?1:this.workspace_.scale;var t=this.workspace_.getBlocksBoundingBox();return{height:(t.bottom-t.top)*e,width:(t.right-t.left)*e,top:t.top*e,left:t.left*e}}hasFixedEdges(){return!this.workspace_.isMovableHorizontally()||!this.workspace_.isMovableVertically()}getComputedFixedEdges_(e){if(!this.hasFixedEdges())return{};var t=this.workspace_.isMovableHorizontally(),i=this.workspace_.isMovableVertically();e=e||this.getViewMetrics(!1);var n={};return i||(n.top=e.top,n.bottom=e.top+e.height),t||(n.left=e.left,n.right=e.left+e.width),n}getPaddedContent_(e,t){var i=t.top+t.height,n=t.left+t.width,o=e.width,s=o/2,r=(e=e.height)/2;return{top:Math.min(t.top-r,i-e),bottom:Math.max(i+r,t.top+e),left:Math.min(t.left-s,n-o),right:Math.max(n+s,t.left+o)}}getScrollMetrics(e,t,i){e=e?this.workspace_.scale:1,t=t||this.getViewMetrics(!1);var n=i||this.getContentMetrics();i=this.getComputedFixedEdges_(t),t=this.getPaddedContent_(t,n),n=void 0!==i.top?i.top:t.top;var o=void 0!==i.left?i.left:t.left;return{top:n/e,left:o/e,width:((void 0!==i.right?i.right:t.right)-o)/e,height:((void 0!==i.bottom?i.bottom:t.bottom)-n)/e}}getUiMetrics(){return{viewMetrics:this.getViewMetrics(),absoluteMetrics:this.getAbsoluteMetrics(),toolboxMetrics:this.getToolboxMetrics()}}getMetrics(){var e=this.getToolboxMetrics(),t=this.getFlyoutMetrics(!0),i=this.getSvgMetrics(),n=this.getAbsoluteMetrics(),o=this.getViewMetrics(),s=this.getContentMetrics(),r=this.getScrollMetrics(!1,o,s);return{contentHeight:s.height,contentWidth:s.width,contentTop:s.top,contentLeft:s.left,scrollHeight:r.height,scrollWidth:r.width,scrollTop:r.top,scrollLeft:r.left,viewHeight:o.height,viewWidth:o.width,viewTop:o.top,viewLeft:o.left,absoluteTop:n.top,absoluteLeft:n.left,svgHeight:i.height,svgWidth:i.width,toolboxWidth:e.width,toolboxHeight:e.height,toolboxPosition:e.position,flyoutWidth:t.width,flyoutHeight:t.height}}};te(ya.METRICS_MANAGER,"default",Hd);var Gd,Wd=class extends Hd{constructor(e,t){super(e),this.flyout_=t}getBoundingBox(){try{var e=this.workspace_.getCanvas().getBBox()}catch(t){e={height:0,y:0,width:0,x:0}}return e}getContentMetrics(e){var t=this.getBoundingBox();return e=e?1:this.workspace_.scale,{height:t.height*e,width:t.width*e,top:t.y*e,left:t.x*e}}getScrollMetrics(e,t,i){return t=i||this.getContentMetrics(),i=this.flyout_.MARGIN*this.workspace_.scale,e=e?this.workspace_.scale:1,{height:(t.height+2*i)/e,width:(t.width+t.left+i)/e,top:0,left:0}}},qd=class{constructor(e,t){this.gap=e,this.axis=t,this.y=this.x=0}getBoundingRectangle(){switch(this.axis){case"x":return new xa(this.y,this.y,this.x,this.x+this.gap);case"y":return new xa(this.y,this.y+this.gap,this.x,this.x)}}moveBy(e,t){this.x+=e,this.y+=t}isNavigable(){return!1}getFocusableElement(){throw Error("Cannot be focused")}getFocusableTree(){throw Error("Cannot be focused")}onNodeFocus(){}onNodeBlur(){}canBeFocused(){return!1}},$d=class{getFirstChild(){return null}getParent(e){return e.getWorkspace()}getNextSibling(){return null}getPreviousSibling(){return null}getRowId(e){return e.getId()}isNavigable(e){return e.canBeFocused()}isApplicable(e){return e instanceof ud}},jd=class{getFirstChild(){return null}getParent(){return null}getNextSibling(){return null}getPreviousSibling(){return null}getRowId(){return"error"}isNavigable(){return!1}isApplicable(e){return e instanceof qd}},zd=class{getFirstChild(e){return is(e)[0]}getParent(e){var t;if(null!=(t=e.previousConnection)&&t.targetBlock()){if(t=e.getSurroundParent())return t}else{let t;if(null!=(t=e.outputConnection)&&t.targetBlock())return e.outputConnection.targetBlock()}return e.workspace}getNextSibling(e){if(e.nextConnection){let t;return null!=(t=e.nextConnection.targetBlock())?t:e.nextConnection}var t;return null!=(t=e.outputConnection)&&t.targetConnection?(t=this.getParent(e),ns(t,e,1)):null}getPreviousSibling(e){var t,i;return null!=(t=e.previousConnection)&&t.targetBlock()?e.previousConnection:null!=(i=e.outputConnection)&&i.targetBlock()?ns(e.outputConnection.targetBlock(),e,-1):null}getRowId(e){return e.getRowId()}isNavigable(e){return e.canBeFocused()}isApplicable(e){return e instanceof Pd}},Xd=class{getFirstChild(){return null}getParent(e){var t;return null!=(t=e.getOwner())?t:null}getNextSibling(e){var t;return ns(null==(t=e.getOwner())?void 0:t.getSourceBlock(),e,1)}getPreviousSibling(e){var t;return ns(null==(t=e.getOwner())?void 0:t.getSourceBlock(),e,-1)}getRowId(e){var t,i,n;return null!=(n=null==(t=e.getOwner())||null==(i=t.getSourceBlock())?void 0:i.getRowId())?n:""}isNavigable(e){return e.canBeFocused()}isApplicable(e){return e instanceof wc}},Yd=class{getFirstChild(){return null}getParent(e){return e.getCommentView().workspace.getCommentById(e.getCommentView().commentId)}getNextSibling(e){var t=e.getCommentView().getCommentBarButtons();return(e=t.indexOf(e))>=0&&e+1<t.length?t[e+1]:null}getPreviousSibling(e){var t=e.getCommentView().getCommentBarButtons();return(e=t.indexOf(e))>0?t[e-1]:null}getRowId(e){return e.getCommentView().commentId}isNavigable(e){return e.canBeFocused()}isApplicable(e){return e instanceof hc}},Kd=class{getFirstChild(){return null}getParent(){return null}getNextSibling(){return null}getPreviousSibling(){return null}getRowId(e){return e.id}isNavigable(e){return e.canBeFocused()}isApplicable(e){return e instanceof cc}},Jd=class{getFirstChild(){return null}getParent(e){return e.getSourceBlock()}getNextSibling(e){if(e.getParentInput())return ns(e.getSourceBlock(),e,1);if(e.type===Xl.NEXT_STATEMENT&&e.getSourceBlock().getSurroundParent()&&!e.targetConnection)return ns(e.getSourceBlock().getSurroundParent(),e,1);switch(e.type){case Xl.NEXT_STATEMENT:return e.targetConnection;case Xl.PREVIOUS_STATEMENT:case Xl.OUTPUT_VALUE:return e.getSourceBlock()}return null}getPreviousSibling(e){if(e.getParentInput())return ns(e.getParentInput().getSourceBlock(),e,-1);switch(e.type){case Xl.NEXT_STATEMENT:return e.getSourceBlock();case Xl.PREVIOUS_STATEMENT:case Xl.OUTPUT_VALUE:return e.targetConnection}return null}getRowId(e){switch(e.type){case Xl.NEXT_STATEMENT:case Xl.PREVIOUS_STATEMENT:return e.id;case Xl.INPUT_VALUE:return e.getParentInput().getRowId();default:return e.getSourceBlock().getRowId()}}isNavigable(e){if(!e.canBeFocused())return!1;if(e.type===Xl.NEXT_STATEMENT){if(e.targetBlock())return!1;let t,i=null!=(t=e.getSourceBlock().getRootBlock())?t:e.getSourceBlock();return e!==i.lastConnectionInStack(!1)}return e.type===Xl.INPUT_VALUE&&!e.targetBlock()}isApplicable(e){return e instanceof jc}},Qd=class{getFirstChild(){return null}getParent(e){return e.getSourceBlock()}getNextSibling(e){return ns(e.getSourceBlock(),e,1)}getPreviousSibling(e){return ns(e.getSourceBlock(),e,-1)}getRowId(e){return e.getParentInput().getRowId()}isNavigable(e){var t;return e.canBeFocused()&&e.isVisible()&&(e.isClickable()||e.isCurrentlyEditable())&&!(null!=(t=e.getSourceBlock())&&t.isSimpleReporter()&&e.isFullBlockField())&&e.getParentInput().isVisible()}isApplicable(e){return e instanceof Wu}},Zd=class{getFirstChild(){return null}getParent(e){return e.getSourceBlock()}getNextSibling(e){return ns(e.getSourceBlock(),e,1)}getPreviousSibling(e){return ns(e.getSourceBlock(),e,-1)}getRowId(e){return e.getSourceBlock().getRowId()}isNavigable(e){return e.canBeFocused()}isApplicable(e){return e instanceof Dc}},ep=class{getFirstChild(e){return e.view.getCommentBarButtons()[0]}getParent(e){return e.workspace}getNextSibling(){return null}getPreviousSibling(){return null}getRowId(e){return e.id}isNavigable(e){return e.canBeFocused()}isApplicable(e){return e instanceof Ec}},tp=class{getFirstChild(e){return(e=e.getTopBlocks(!0)).length?e[0]:null}getParent(){return null}getNextSibling(){return null}getPreviousSibling(){return null}getRowId(e){return e.id}isNavigable(e){return e.canBeFocused()&&!e.isMutator}isApplicable(e){return e instanceof ig}},ip=Gd||(Gd={});ip[ip.NEXT=0]="NEXT",ip[ip.PREVIOUS=1]="PREVIOUS",ip[ip.IN=2]="IN",ip[ip.OUT=3]="OUT";var np,op=class{constructor(){this.rules=[new zd,new Qd,new Jd,new tp,new Zd,new ep,new Yd,new Xd,new Kd],this.navigationLoops=!0}addNavigationPolicy(e){this.rules.push(e)}get(e){return this.rules.find((t=>t.isApplicable(e)))}getFirstChild(e){var t,i=null==(t=this.get(e))?void 0:t.getFirstChild(e);return i?this.isNavigable(i)?i:this.getFirstChild(i)||this.getNextSibling(i):null}getParent(e){var t,i=null==(t=this.get(e))?void 0:t.getParent(e);return i?this.isNavigable(i)?i:this.getParent(i):null}getNextSibling(e){var t,i=null==(t=this.get(e))?void 0:t.getNextSibling(e);return i?this.isNavigable(i)?i:this.getNextSibling(i):null}getPreviousSibling(e){var t,i=null==(t=this.get(e))?void 0:t.getPreviousSibling(e);return i?this.isNavigable(i)?i:this.getPreviousSibling(i):null}getPreviousNode(e=Zs.t().getFocusedNode()){if(!e)return null;var t=this.getPreviousNodeImpl(e,e,Gd.PREVIOUS);if(!t||t===e.getFocusableTree()){if(!(t=this.navigateStacks(e,-1)))return null;t=this.getLastNodeInStack(t,e)}return this.getLeftmostSibling(t)}getOutNode(e=Zs.t().getFocusedNode()){return this.getPreviousNodeImpl(e,e,Gd.OUT)}getNextNode(e=Zs.t().getFocusedNode()){var t=this.getNextNodeImpl(e,e,Gd.NEXT);return e&&null===t?this.navigateStacks(e,1):t}getInNode(e=Zs.t().getFocusedNode()){return this.getNextNodeImpl(e,e,Gd.IN)}getPreviousNodeImpl(e,t,i,n=new Set){if(!t||!e||n.has(t))return null;var o=this.getRightMostChild(this.getPreviousSibling(t),t)||this.getParent(t);return o&&this.transitionAllowed(e,o,i)?o:o?(n.add(t),this.getPreviousNodeImpl(e,o,i,n)):null}getNextNodeImpl(e,t,i,n=new Set){if(!t||!e||n.has(t))return null;for(var o=this.getFirstChild(t)||this.getNextSibling(t),s=t;s&&!o&&(s=this.getParent(s));)o=this.getNextSibling(s);return o&&this.transitionAllowed(e,o,i)?o:o?(n.add(t),this.getNextNodeImpl(e,o,i,n)):null}getRightMostChild(e,t){if(!e)return e;var i=this.getFirstChild(e);if(!i||i===t)return e;for(e=i;e&&e!==t;e=this.getNextSibling(i))i=e;return this.getRightMostChild(i,t)}setNavigationLoops(e){this.navigationLoops=e}getNavigationLoops(){return this.navigationLoops}getNavigableItems(e=(null==(np=Zs.t().getFocusedTree())?void 0:np.getRootFocusableNode())){return e?this.getTopLevelItems(e).filter((e=>this.isNavigable(e))):[]}getFirstNode(){var e,t=null==(e=Zs.t().getFocusedTree())?void 0:e.getRootFocusableNode();return t?this.getTopLevelItems(t)[0]:null}getLastNode(){var e,t=null==(e=Zs.t().getFocusedTree())?void 0:e.getRootFocusableNode();return t?this.getTopLevelItems(t).slice(-1)[0]:null}transitionAllowed(e,t,i){switch(i){case Gd.IN:case Gd.OUT:return this.getRowId(e)===this.getRowId(t);case Gd.NEXT:case Gd.PREVIOUS:return this.getRowId(e)!==this.getRowId(t)}}getLeftmostSibling(e){if(!e)return null;for(var t;t=this.getPreviousNodeImpl(e,e,Gd.OUT);)e=t;return e}getLastNodeInStack(e,t){for(var i;(i=this.getNextNodeImpl(e,e,Gd.NEXT))&&i!==t;)e=i;return e}getRowId(e){var t;return null==(t=this.get(e))?void 0:t.getRowId(e)}navigateStacks(e,t){var i,n,o=this.getTopLevelItems(e),s=null!=(n=null==(i=this.getSourceBlockFromNode(e))?void 0:i.getRootBlock())?n:e;return e=o.indexOf(s)+t,t=null,e>=0&&e<o.length?t=o[e]:e<0&&this.getNavigationLoops()?t=o[o.length-1]:e>=o.length&&this.getNavigationLoops()&&(t=o[0]),t}getTopLevelItems(e){return e.getFocusableTree().getTopBoundedElements(!0)}isNavigable(e){var t;return null==(t=this.get(e))?void 0:t.isNavigable(e)}getSourceBlockFromNode(e){return e instanceof Pd?e:e instanceof Wu||e instanceof jc||e instanceof Dc?e.getSourceBlock():e instanceof cc&&(e=e.getParent())instanceof Pd?e:null}},sp=class{getFirstChild(e){return os(e)?e.getChildToolboxItems()[0]:null}getParent(e){return e.getParent()}getNextSibling(e){var t,i=e.getParentToolbox().getToolboxItems();return e=i.indexOf(e),null!=(t=i[e+1])?t:null}getPreviousSibling(e){var t,i=e.getParentToolbox().getToolboxItems();return e=i.indexOf(e),null!=(t=i[e-1])?t:null}getRowId(e){return e.getId()}isNavigable(e){return e.canBeFocused()&&this.allParentsExpanded(e)}allParentsExpanded(e){return!(e=e.getParent())||!os(e)||e.isExpanded()&&this.allParentsExpanded(e)}isApplicable(e){return Wt(e)}},rp=class extends op{constructor(e){super(),this.toolbox=e,this.rules=[new sp]}getInNode(e=Zs.t().getFocusedNode(),t=!1){var i,n=ss(this.toolbox.getWorkspace());if(!t)switch(n){case Ya.TOP:case Ya.BOTTOM:return this.getNextNode(e,!0);case Ya.RIGHT:return this.getOutNode(e,!0)}return!qt(e)||qt(e)&&!e.getContents().length?null:(e=null==(i=this.toolbox.getFlyout())?void 0:i.getWorkspace().getNavigator())?!this.toolbox.getWorkspace().RTL||n!==Ya.TOP&&n!==Ya.BOTTOM?e.getFirstNode():e.getLastNode():null}getOutNode(e,t=!1){if(!t)switch(ss(this.toolbox.getWorkspace())){case Ya.TOP:case Ya.BOTTOM:return this.getPreviousNode(e,!0);case Ya.RIGHT:return this.getInNode(e,!0)}return super.getOutNode(e)}getNextNode(e,t=!1){if(!t)switch(ss(this.toolbox.getWorkspace())){case Ya.TOP:return this.getInNode(e,!0);case Ya.BOTTOM:return this.getOutNode(e,!0)}return super.getNextNode(e)}getPreviousNode(e,t=!1){if(!t)switch(ss(this.toolbox.getWorkspace())){case Ya.TOP:return this.getOutNode(e,!0);case Ya.BOTTOM:return this.getInNode(e,!0)}return super.getPreviousNode(e)}getTopLevelItems(){return this.toolbox.getToolboxItems()}},ap=class extends op{constructor(e){super(),this.flyout=e,this.rules.push(new $d,new jd)}getOutNode(e,t=!1){if(!t&&this.flyout.targetWorkspace)switch(ss(this.flyout.targetWorkspace)){case Ya.TOP:case Ya.BOTTOM:return this.flyout.RTL?this.getNextNode(e,!0):this.getPreviousNode(e,!0);case Ya.RIGHT:return null}var i;return(e=null==(i=this.flyout.targetWorkspace)?void 0:i.getToolbox())?e.getSelectedItem():null}getInNode(e,t=!1){if(!t&&this.flyout.targetWorkspace)switch(ss(this.flyout.targetWorkspace)){case Ya.TOP:case Ya.BOTTOM:return this.flyout.RTL?this.getPreviousNode(e,!0):this.getNextNode(e,!0);case Ya.RIGHT:return this.getOutNode(e,!0)}return super.getInNode(e)}getNextNode(e,t=!1){if(!t&&this.flyout.targetWorkspace)switch(ss(this.flyout.targetWorkspace)){case Ya.TOP:return null;case Ya.BOTTOM:return this.getOutNode(e,!0)}return super.getNextNode(e)}getPreviousNode(e,t=!1){if(!t&&this.flyout.targetWorkspace)switch(ss(this.flyout.targetWorkspace)){case Ya.TOP:return this.getOutNode(e,!0);case Ya.BOTTOM:return null}return super.getPreviousNode(e)}getTopLevelItems(){return this.flyout.getContents().map((e=>e.getElement())).filter((e=>this.isNavigable(e)))}isNavigable(e){return super.isNavigable(e)&&this.flyout.getContents().map((e=>e.getElement())).includes(e)}},lp=class{constructor(e,t,i,n,o){this.workspace=e,this.oldHostMetrics=this.corner_=this.vScroll=this.hScroll=null,i=void 0===i||i;var s=(t=void 0===t||t)&&i;t&&(this.hScroll=new Ha(e,!0,s,n,o)),i&&(this.vScroll=new Ha(e,!1,s,n,o)),s&&(this.corner_=I(ea.RECT,{height:Ha.scrollbarThickness,width:Ha.scrollbarThickness,class:"blocklyScrollbarBackground"}),O(this.corner_,e.getBubbleCanvas()))}dispose(){S(this.corner_),this.oldHostMetrics=this.corner_=null,this.hScroll&&(this.hScroll.dispose(),this.hScroll=null),this.vScroll&&(this.vScroll.dispose(),this.vScroll=null)}resize(){var e=this.workspace.getMetrics();if(e){var t=!1,i=!1;if(this.oldHostMetrics&&this.oldHostMetrics.viewWidth===e.viewWidth&&this.oldHostMetrics.viewHeight===e.viewHeight&&this.oldHostMetrics.absoluteTop===e.absoluteTop&&this.oldHostMetrics.absoluteLeft===e.absoluteLeft?(this.oldHostMetrics&&this.oldHostMetrics.scrollWidth===e.scrollWidth&&this.oldHostMetrics.viewLeft===e.viewLeft&&this.oldHostMetrics.scrollLeft===e.scrollLeft||(t=!0),this.oldHostMetrics&&this.oldHostMetrics.scrollHeight===e.scrollHeight&&this.oldHostMetrics.viewTop===e.viewTop&&this.oldHostMetrics.scrollTop===e.scrollTop||(i=!0)):i=t=!0,t||i){try{Zs.Ub++,this.hScroll&&t&&this.hScroll.resize(e),this.vScroll&&i&&this.vScroll.resize(e)}finally{Zs.Ub--}this.workspace.maybeFireViewportChangeEvent()}if(this.hScroll&&this.vScroll){if(!this.oldHostMetrics||this.oldHostMetrics.viewWidth!==e.viewWidth||this.oldHostMetrics.absoluteLeft!==e.absoluteLeft){let e;null==(e=this.corner_)||e.setAttribute("x",String(this.vScroll.position.x))}if(!this.oldHostMetrics||this.oldHostMetrics.viewHeight!==e.viewHeight||this.oldHostMetrics.absoluteTop!==e.absoluteTop){let e;null==(e=this.corner_)||e.setAttribute("y",String(this.hScroll.position.y))}}this.oldHostMetrics=e}}canScrollHorizontally(){return!!this.hScroll}canScrollVertically(){return!!this.vScroll}setOrigin(e,t){this.hScroll&&this.hScroll.setOrigin(e,t),this.vScroll&&this.vScroll.setOrigin(e,t)}set(e,t,i){this.hScroll&&this.hScroll.set(e,!1),this.vScroll&&this.vScroll.set(t,!1),(i||void 0===i)&&(e={},this.hScroll&&(e.x=this.hScroll.getRatio_()),this.vScroll&&(e.y=this.vScroll.getRatio_()),this.workspace.setMetrics(e))}setX(e){this.hScroll&&this.hScroll.set(e,!0)}setY(e){this.vScroll&&this.vScroll.set(e,!0)}setContainerVisible(e){this.hScroll&&this.hScroll.setContainerVisible(e),this.vScroll&&this.vScroll.setContainerVisible(e)}isVisible(){var e=!1;return this.hScroll&&(e=this.hScroll.isVisible()),this.vScroll&&(e=e||this.vScroll.isVisible()),e}setVisible(e){this.hScroll&&this.hScroll.setVisibleInternal(e),this.vScroll&&this.vScroll.setVisibleInternal(e)}resizeContent(e){this.hScroll&&this.hScroll.resizeContentHorizontal(e),this.vScroll&&this.vScroll.resizeContentVertical(e)}resizeView(e){this.hScroll&&this.hScroll.resizeViewHorizontal(e),this.vScroll&&this.vScroll.resizeViewVertical(e)}},hp=class{load(e,t){return e=new qd(0,t.horizontalLayout?"x":"y"),new Vd(e,"sep")}gapForItem(e,t){var i;return null!=(i=parseInt(String(e.gap)))?i:t}disposeItem(){}getType(){return"sep"}};te(ya.FLYOUT_INFLATER,"sep",hp);var up=class extends Ud{constructor(e){super(),this.horizontalLayout=!1,this.boundEvents=[],this.reflowWrapper=null,this.inhibitReflowWrapper=!1,this.contents=[],this.autoClose=!0,this.visible=!1,this.containerVisible=!0,this.CORNER_RADIUS=8,this.SCROLLBAR_MARGIN=2.5,this.height_=this.width_=0,this.svgGroup_=this.svgBackground_=null,this.inflaters=new Map,e.setMetrics=this.setMetrics_.bind(this),this.workspace_=new ig(e),this.workspace_.setMetricsManager(new Wd(this.workspace_,this)),this.workspace_.internalIsFlyout=!0,this.workspace_.setVisible(this.visible),this.workspace_.setNavigator(new ap(this)),this.id=he(),this.RTL=!!e.RTL,this.toolboxPosition_=e.toolboxPosition,this.tabWidth_=this.workspace_.getRenderer().getConstants().TAB_WIDTH,this.MARGIN=this.CORNER_RADIUS,this.GAP_X=3*this.MARGIN,this.GAP_Y=3*this.MARGIN}createDom(e){return this.svgGroup_=I(e,{class:"blocklyFlyout"}),this.svgGroup_.style.display="none",this.svgBackground_=I(ea.PATH,{class:"blocklyFlyoutBackground"},this.svgGroup_),this.svgGroup_.appendChild(this.workspace_.createDom()),this.workspace_.getThemeManager().subscribe(this.svgBackground_,"flyoutBackgroundColour","fill"),this.workspace_.getThemeManager().subscribe(this.svgBackground_,"flyoutOpacity","fill-opacity"),this.svgGroup_.addEventListener("keydown",(e=>{"Escape"===e.key&&(Zs.t().focusTree(this.targetWorkspace),this.targetWorkspace.isMutator||this.autoHide(!1),e.preventDefault(),e.stopPropagation())})),this.svgGroup_}init(e){this.targetWorkspace=e,this.workspace_.targetWorkspace=e,this.workspace_.setInitialAriaContext(),this.workspace_.scrollbar=new lp(this.workspace_,this.horizontalLayout,!this.horizontalLayout,"blocklyFlyoutScrollbar",this.SCROLLBAR_MARGIN),this.hide(),this.boundEvents.push(r(this.svgGroup_,"wheel",this,this.wheel_,!1,{passive:!1})),this.boundEvents.push(r(this.svgBackground_,"pointerdown",this,this.onMouseDown)),this.workspace_.getGesture=this.targetWorkspace.getGesture.bind(this.targetWorkspace),this.workspace_.setVariableMap(this.targetWorkspace.getVariableMap()),this.workspace_.createPotentialVariableMap(),e.getComponentManager().addComponent({component:this,weight:Sr.ComponentWeight.FLYOUT_WEIGHT,capabilities:[Sr.Capability.AUTOHIDEABLE,Sr.Capability.DELETE_AREA,Sr.Capability.DRAG_TARGET]})}dispose(){this.hide(),this.targetWorkspace.getComponentManager().removeComponent(this.id);for(let e of this.boundEvents)l(e);this.boundEvents.length=0,this.workspace_&&(this.workspace_.getThemeManager().unsubscribe(this.svgBackground_),this.workspace_.dispose()),this.svgGroup_&&S(this.svgGroup_)}getWidth(){return this.width_}getHeight(){return this.height_}getFlyoutScale(){return this.targetWorkspace.scale}getWorkspace(){return this.workspace_}setAutoClose(e){this.autoClose=e,this.targetWorkspace.recordDragTargets(),this.targetWorkspace.resizeContents()}autoHide(e){!e&&this.targetWorkspace.getFlyout(!0)===this&&this.autoClose&&this.hide()}getTargetWorkspace(){return this.targetWorkspace}isVisible(){return this.visible}setVisible(e){var t=e!==this.isVisible();this.visible=e,t&&(this.autoClose||this.targetWorkspace.recordDragTargets(),this.updateDisplay())}setContainerVisible(e){var t=e!==this.containerVisible;this.containerVisible=e,t&&this.updateDisplay()}getContents(){return this.contents}setContents(e){this.contents=e}updateDisplay(){var e,t=!!this.containerVisible&&this.isVisible();this.svgGroup_&&(this.svgGroup_.style.display=t?"block":"none"),null==(e=this.workspace_.scrollbar)||e.setContainerVisible(t)}positionAt_(e,t,i,n){var o,s;null==(o=this.svgGroup_)||o.setAttribute("width",`${e}`),null==(s=this.svgGroup_)||s.setAttribute("height",`${t}`),this.workspace_.setCachedParentSvgSize(e,t),this.svgGroup_&&R(this.svgGroup_,"translate("+i+"px,"+n+"px)"),(e=this.workspace_.scrollbar)&&(e.setOrigin(i,n),e.resize(),e.hScroll&&e.hScroll.setPosition(e.hScroll.position.x,e.hScroll.position.y),e.vScroll&&e.vScroll.setPosition(e.vScroll.position.x,e.vScroll.position.y))}hide(){this.isVisible()&&(this.setVisible(!1),this.reflowWrapper&&(this.workspace_.removeChangeListener(this.reflowWrapper),this.reflowWrapper=null))}show(e){Zs.t().getFocusedTree()===this.workspace_&&Zs.t().getFocusedNode()!==this.workspace_&&Zs.t().focusNode(this.workspace_),this.workspace_.setResizesEnabled(!1),Zs.Qc=!1,this.hide(),this.clearOldBlocks(),"string"==typeof e&&(e=this.getDynamicCategoryContents(e)),this.setVisible(!0),e=Me(e),e=this.createFlyoutInfo(e),et(this.workspace_),this.setContents(e),this.layout_(e),this.horizontalLayout?this.height_=0:this.width_=0,this.reflow(),this.updateAriaContext(),Zs.Qc=!0,this.workspace_.setResizesEnabled(!0),this.reflowWrapper=e=>{this.inhibitReflowWrapper||e.type!==Fr.BLOCK_CHANGE&&e.type!==Fr.BLOCK_FIELD_INTERMEDIATE_CHANGE||this.reflow()},this.workspace_.addChangeListener(this.reflowWrapper)}updateAriaContext(){var e=this.getContents().map((e=>e.getElement())).filter((e=>e.canBeFocused())).map((e=>e.getFocusableElement().id));f(this.getWorkspace().getCanvas(),$r.OWNS,e.join(" ")),this.targetWorkspace.isMutator||this.autoClose?_(this.getWorkspace().svgGroup_,Hr.NONE):_(this.getWorkspace().svgGroup_,Hr.REGION);var t=(e=null==(t=this.targetWorkspace.getToolbox())?void 0:t.getSelectedItem())&&qt(e)?e.getName():"";t=Zs.C.WORKSPACE_LABEL_FLYOUT_WORKSPACE.replace("%1",t).trim(),f(this.getWorkspace().getCanvas(),$r.LABEL,t),_(this.getWorkspace().getCanvas(),Hr.LISTBOX)}createFlyoutInfo(e){var t=[],i=this.horizontalLayout?this.GAP_X:this.GAP_Y;for(let n of e)"custom"in n&&(e=this.getDynamicCategoryContents(n.custom),e=Me(e),t.push(...this.createFlyoutInfo(e))),e=n.kind.toLowerCase(),(e=this.getInflaterForType(e))&&(t.push(e.load(n,this)),(e=e.gapForItem(n,i))&&t.push(new Vd(new qd(e,this.horizontalLayout?"x":"y"),"sep")));return this.normalizeSeparators(t)}normalizeSeparators(e){for(let t=e.length-1;t>0;t--){let i=e[t].getType().toLowerCase(),n=e[t-1].getType().toLowerCase();"sep"===i&&"sep"===n&&e.splice(t-1,1)}return e}getDynamicCategoryContents(e){if("function"!=typeof(e=this.workspace_.targetWorkspace.getToolboxCategoryCallback(e)))throw TypeError("Couldn't find a callback function when opening a toolbox category.");return e(this.workspace_.targetWorkspace)}clearOldBlocks(){var e;this.getContents().forEach((e=>{var t;null==(t=this.getInflaterForType(e.getType()))||t.disposeItem(e)})),null==(e=this.workspace_.getPotentialVariableMap())||e.clear()}onMouseDown(e){var t=this.targetWorkspace.getGesture(e);t&&t.handleFlyoutStart(e,this)}reflow(){this.inhibitReflowWrapper=!0,this.reflowInternal_(),this.inhibitReflowWrapper=!1}isScrollable(){return!!this.workspace_.scrollbar&&this.workspace_.scrollbar.isVisible()}getInflaterForType(e){var t;return this.inflaters.has(e)?null!=(t=this.inflaters.get(e))?t:null:(t=ne(ya.FLYOUT_INFLATER,e,void 0))?(t=new t,this.inflaters.set(e,t),t):null}},cp=class{constructor(e){this.workspace=e,this.horizontalScrollEnabled=this.workspace.isMovableHorizontally(),this.verticalScrollEnabled=this.workspace.isMovableVertically(),this.startScrollXY_=new Da(e.scrollX,e.scrollY)}startDrag(){}endDrag(e){this.drag(e)}drag(e){if(e=Da.sum(this.startScrollXY_,e),this.horizontalScrollEnabled&&this.verticalScrollEnabled)this.workspace.scroll(e.x,e.y);else if(this.horizontalScrollEnabled)this.workspace.scroll(e.x,this.workspace.scrollY);else{if(!this.verticalScrollEnabled)throw new TypeError("Invalid state.");this.workspace.scroll(this.workspace.scrollX,e.y)}}},dp=class{constructor(e,t){this.creatorWorkspace=t,this.mouseDownXY=new Da(0,0),this.startWorkspace_=this.targetBlock=this.startComment=this.startBlock=this.startIcon=this.startField=this.startBubble=null,this.hasExceededDragRadius=!1,this.boundEvents=[],this.workspaceDragger=this.dragger=null,this.dragging=!1,this.flyout=null,this.multiTouch=this.isEnding_=this.gestureHasStarted=this.calledUpdateIsDragging=!1,this.cachedPoints=new Map,this.startDistance=this.previousScale=0,this.currentDropdownOwner=this.isPinchZoomEnabled=null,this.mostRecentEvent=e,this.currentDragDeltaXY=new Da(0,0)}dispose(){dr=null,Ou=!1,this.creatorWorkspace.clearGesture();for(let e of this.boundEvents)l(e);this.boundEvents.length=0}updateFromEvent(e){var i=new Da(e.clientX,e.clientY);this.updateDragDelta(i)&&(this.updateIsDragging(e),t()),this.mostRecentEvent=e}updateDragDelta(e){return this.currentDragDeltaXY=Da.difference(e,this.mouseDownXY),!this.hasExceededDragRadius&&(this.hasExceededDragRadius=Da.magnitude(this.currentDragDeltaXY)>(this.flyout?Zs.Og.flyoutDragRadius:Zs.Og.dragRadius))}updateIsDraggingWorkspace(){if(!this.startWorkspace_)throw Error("Cannot update dragging the workspace because the start workspace is undefined");(this.flyout?this.flyout.isScrollable():this.startWorkspace_&&this.startWorkspace_.isDraggable())&&(this.dragging=!0,this.workspaceDragger=new cp(this.startWorkspace_),this.workspaceDragger.startDrag())}updateIsDragging(e){if(!this.startWorkspace_)throw Error("Cannot update dragging because the start workspace is undefined");if(this.calledUpdateIsDragging)throw Error("updateIsDragging_ should only be called once per gesture.");this.calledUpdateIsDragging=!0;var t=j();t&&go(t)&&t.isMovable()?(this.dragging=!0,this.dragger=this.createDragger(t),this.dragger.onDragStart(e),this.dragger.onDrag(e,this.currentDragDeltaXY)):this.updateIsDraggingWorkspace()}createDragger(e){return new(ae(ya.BLOCK_DRAGGER,this.creatorWorkspace.options,!0))(e)}doStart(t){if(!this.startWorkspace_)throw Error("Cannot start the touch gesture becauase the start workspace is undefined");this.isPinchZoomEnabled=this.startWorkspace_.options.zoomOptions&&this.startWorkspace_.options.zoomOptions.pinch,h(t)?this.cancel():(this.gestureHasStarted=!0,eo(),this.startWorkspace_.updateScreenCalculationsIfScrolled(),this.startWorkspace_.isMutator&&this.startWorkspace_.resize(),this.currentDropdownOwner=bu,this.startWorkspace_.hideChaff(!!this.flyout),this.startWorkspace_.markFocused(),this.mostRecentEvent=t,Hi(),u(t)?this.handleRightClick(t):("pointerdown"===t.type.toLowerCase()&&"mouse"!==t.pointerType&&e(t,this),this.mouseDownXY=new Da(t.clientX,t.clientY),this.bindMouseEvents(t),this.isEnding_||this.handleTouchStart(t)))}bindMouseEvents(e){this.boundEvents.push(r(document,"pointerdown",null,this.handleStart.bind(this),!0)),this.boundEvents.push(r(document,"pointermove",null,this.handleMove.bind(this),!0)),this.boundEvents.push(r(document,"pointerup",null,this.handleUp.bind(this),!0)),this.boundEvents.push(r(document,"pointercancel",null,this.handleUp.bind(this),!0)),e.preventDefault(),e.stopPropagation()}handleStart(e){this.isDragging()||(this.handleTouchStart(e),this.isMultiTouch()&&t())}handleMove(e){this.isDragging()&&n(e)||!this.isMultiTouch()?(this.updateFromEvent(e),this.workspaceDragger?this.workspaceDragger.drag(this.currentDragDeltaXY):this.dragger&&this.dragger.onDrag(this.mostRecentEvent,this.currentDragDeltaXY),e.preventDefault(),e.stopPropagation()):this.isMultiTouch()&&(this.handleTouchMove(e),t())}handleUp(e){if(this.isDragging()||this.handleTouchEnd(e),!this.isMultiTouch()||this.isDragging()){if(!n(e))return;if(this.updateFromEvent(e),t(),this.isEnding_)return void console.log("Trying to end a gesture recursively.");this.isEnding_=!0,this.dragger?(Xh.setIsActive(!1),this.dragger.onDragEnd(e,this.currentDragDeltaXY)):this.workspaceDragger?(Xh.setIsActive(!1),this.workspaceDragger.endDrag(this.currentDragDeltaXY)):this.isBubbleClick()||this.isCommentClick()||(this.isFieldClick()?this.doFieldClick():this.isIconClick()?this.doIconClick():this.isBlockClick()?this.doBlockClick():this.isWorkspaceClick()&&this.doWorkspaceClick(e))}e.preventDefault(),e.stopPropagation(),this.dispose()}handleTouchStart(e){var t=o(e);this.cachedPoints.set(t,this.getTouchPoint(e));var i=Array.from(this.cachedPoints.keys());2===i.length&&(t=this.cachedPoints.get(i[0]),i=this.cachedPoints.get(i[1]),this.startDistance=Da.distance(t,i),this.multiTouch=!0,e.preventDefault())}handleTouchMove(e){var t=o(e);this.cachedPoints.set(t,this.getTouchPoint(e)),this.isPinchZoomEnabled&&2===this.cachedPoints.size?this.handlePinch(e):(this.updateFromEvent(e),this.workspaceDragger?this.workspaceDragger.drag(this.currentDragDeltaXY):this.dragger&&this.dragger.onDrag(this.mostRecentEvent,this.currentDragDeltaXY),e.preventDefault(),e.stopPropagation())}handlePinch(e){var t=Array.from(this.cachedPoints.keys()),i=this.cachedPoints.get(t[0]);if(t=this.cachedPoints.get(t[1]),i=Da.distance(i,t)/this.startDistance,this.previousScale>0&&this.previousScale<1/0){if(t=(t=i-this.previousScale)>0?5*t:6*t,!this.startWorkspace_)throw Error("Cannot handle a pinch because the start workspace is undefined");let n=this.startWorkspace_,o=c(e,n.getParentSvg(),n.getInverseScreenCTM());n.zoom(o.x,o.y,t)}this.previousScale=i,e.preventDefault()}handleTouchEnd(e){e=o(e),this.cachedPoints.has(e)&&this.cachedPoints.delete(e),this.cachedPoints.size<2&&(this.cachedPoints.clear(),this.previousScale=0)}getTouchPoint(e){return this.startWorkspace_?new Da(e.pageX,e.pageY):null}isMultiTouch(){return this.multiTouch}cancel(){this.isEnding_||(t(),this.dragger?this.dragger.onDragEnd(this.mostRecentEvent,this.currentDragDeltaXY):this.workspaceDragger&&this.workspaceDragger.endDrag(this.currentDragDeltaXY),this.dispose())}handleRightClick(e){var t=Zs.t().getFocusedNode();if(t&&"function"==typeof t.showContextMenu){let i;null==(i=this.startWorkspace_)||i.hideChaff(!!this.flyout),t.showContextMenu(e)}e.preventDefault(),e.stopPropagation(),Xh.setIsActive(!1),this.dispose()}handleWsStart(e,t){if(this.gestureHasStarted)throw Error("Tried to call gesture.handleWsStart, but the gesture had already been started.");this.setStartWorkspace(t),this.mostRecentEvent=e,this.targetBlock||this.startBubble||this.startComment||this.startIcon||Zs.t().focusNode(t),this.doStart(e)}fireWorkspaceClick(e){ue(new(_e(Fr.CLICK))(null,e.id,"workspace"))}handleFlyoutStart(e,t){if(this.gestureHasStarted)throw Error("Tried to call gesture.handleFlyoutStart, but the gesture had already been started.");this.setStartFlyout(t),this.handleWsStart(e,t.getWorkspace())}handleBlockStart(e,t){if(this.gestureHasStarted)throw Error("Tried to call gesture.handleBlockStart, but the gesture had already been started.");this.setStartBlock(t),this.mostRecentEvent=e}handleBubbleStart(e,t){if(this.gestureHasStarted)throw Error("Tried to call gesture.handleBubbleStart, but the gesture had already been started.");this.setStartBubble(t),this.mostRecentEvent=e}handleCommentStart(e,t){if(this.gestureHasStarted)throw Error("Tried to call gesture.handleCommentStart, but the gesture had already been started.");this.setStartComment(t),this.mostRecentEvent=e}doFieldClick(){if(!this.startField)throw Error("Cannot do a field click because the start field is undefined");this.currentDropdownOwner!==this.startField&&this.startField.showEditor(this.mostRecentEvent)}doIconClick(){if(!this.startIcon)throw Error("Cannot do an icon click because the start icon is undefined");this.startIcon.onClick()}doBlockClick(){if(this.flyout&&this.flyout.autoClose){if(!this.targetBlock)throw Error("Cannot do a block click because the target block is undefined");var e=Dt(this.targetBlock);let i=this.flyout.targetWorkspace;if(e&&i){var t=Le(this.flyout.getWorkspace(),this.targetBlock.getRelativeToSurfaceXY());t=we(i,t),e.x=t.x,e.y=t.y,Mt(e,i,{recordUndo:!0}),i.hideChaff(!1)}}else{if(!this.startWorkspace_)throw Error("Cannot do a block click because the start workspace is undefined");e=new(_e(Fr.CLICK))(this.startBlock,this.startWorkspace_.id,"block"),ue(e)}Zs.B(!1)}doWorkspaceClick(){this.fireWorkspaceClick(this.startWorkspace_||this.creatorWorkspace)}setStartField(e){if(this.gestureHasStarted)throw Error("Tried to call gesture.setStartField, but the gesture had already been started.");this.startField||(this.startField=e)}setStartIcon(e){if(this.gestureHasStarted)throw Error("Tried to call gesture.setStartIcon, but the gesture had already been started.");this.startIcon||(this.startIcon=e)}setStartBubble(e){this.startBubble||(this.startBubble=e)}setStartComment(e){this.startComment||(this.startComment=e)}setStartBlock(e){var t,i,n;this.startBlock||this.startBubble||this.startIcon&&(!e.isInFlyout||null!=(n=(i=this.startIcon).isClickableInFlyout)&&n.call(i,!(null==(t=e.workspace.getFlyout())||!t.autoClose)))||(this.startBlock=e,e.isInFlyout&&e!==e.getRootBlock()?this.setTargetBlock(e.getRootBlock()):this.setTargetBlock(e))}setTargetBlock(e){e.isShadow()?this.setTargetBlock(e.getParent()):(this.targetBlock=e,this.targetBlock.bringToFront(),Zs.t().focusNode(this.targetBlock))}setStartWorkspace(e){this.startWorkspace_||(this.startWorkspace_=e)}setStartFlyout(e){this.flyout||(this.flyout=e)}isBubbleClick(){return!!this.startBubble&&!this.hasExceededDragRadius}isCommentClick(){return!!this.startComment&&!this.hasExceededDragRadius}isBlockClick(){return!(!this.startBlock||this.hasExceededDragRadius||this.isFieldClick()||this.isIconClick())}isFieldClick(){return!!this.startField&&this.startField.isClickable()&&!this.hasExceededDragRadius&&(!this.flyout||this.startField.isClickableInFlyout(this.flyout.autoClose))}isIconClick(){if(!this.startIcon)return!1;var e=!this.flyout||!this.startIcon.isClickableInFlyout||this.startIcon.isClickableInFlyout(this.flyout.autoClose);return!this.hasExceededDragRadius&&e}isWorkspaceClick(){return!(this.startBlock||this.startBubble||this.startField||this.hasExceededDragRadius)}getCurrentDragger(){var e,t;return null!=(t=null!=(e=this.workspaceDragger)?e:this.dragger)?t:null}isDragging(){return this.dragging}hasStarted(){return this.gestureHasStarted}static inProgress(){var e=H();for(let t,i=0;t=e[i];i++)if(t.currentGesture_)return!0;return!1}},pp=class{constructor(e,t){var i,n,o;this.pattern=e,this.scale=1,this.spacing=null!=(i=t.spacing)?i:0,this.length=null!=(n=t.length)?n:1,this.line2=(this.line1=e.firstChild)&&this.line1.nextSibling,this.snapToGrid=null!=(o=t.snap)&&o}setSpacing(e){this.spacing=e,this.update(this.scale)}getSpacing(){return this.spacing}setLength(e){this.length=e,this.update(this.scale)}getLength(){return this.length}setSnapToGrid(e){this.snapToGrid=e}shouldSnap(){return this.snapToGrid}getPatternId(){return this.pattern.id}update(e){this.scale=e;var t=this.spacing*e;this.pattern.setAttribute("width",`${t}`),this.pattern.setAttribute("height",`${t}`);var i=(t=Math.floor(this.spacing/2)+.5)-this.length/2,n=t+this.length/2;t*=e,i*=e,n*=e,this.setLineAttributes(this.line1,e,i,n,t,t),this.setLineAttributes(this.line2,e,t,t,i,n)}setLineAttributes(e,t,i,n,o,s){e&&(e.setAttribute("stroke-width",`${t}`),e.setAttribute("x1",`${i}`),e.setAttribute("y1",`${o}`),e.setAttribute("x2",`${n}`),e.setAttribute("y2",`${s}`))}moveTo(e,t){this.pattern.setAttribute("x",`${e}`),this.pattern.setAttribute("y",`${t}`)}alignXY(e){var t=this.getSpacing(),i=t/2,n=Math.round(Math.round((e.x-i)/t)*t+i);return t=Math.round(Math.round((e.y-i)/t)*t+i),n===e.x&&t===e.y?e:new Da(n,t)}static createDom(e,t,i,n){var o,s;if(e=I(ea.PATTERN,{id:"blocklyGridPattern"+e,patternUnits:"userSpaceOnUse"},i),(null!=(o=t.length)?o:1)>0&&(null!=(s=t.spacing)?s:0)>0){let i;I(ea.LINE,{stroke:t.colour},e),null!=(i=t.length)&&i&&I(ea.LINE,{stroke:t.colour},e)}else I(ea.LINE,{},e);return n&&n.style.setProperty("--blocklyGridPattern",`url(#${e.id})`),e}},gp=class{constructor(e){this.workspace=e,this.layers=new Map,(e=e.getInjectionDiv())&&(this.dragLayer=this.createDragLayer(e),this.animationLayer=this.createAnimationLayer(e)),e=this.createLayer(50),N(e,"blocklyBlockCanvas"),e=this.createLayer(100),N(e,"blocklyBubbleCanvas")}createDragLayer(e){var t=I(ea.SVG,{class:"blocklyBlockDragSurface",xmlns:"http://www.w3.org/2000/svg","xmlns:html":"http://www.w3.org/1999/xhtml","xmlns:xlink":"http://www.w3.org/1999/xlink",version:"1.1"});return e.append(t),I(ea.G,{},t)}createAnimationLayer(e){var t=I(ea.SVG,{class:"blocklyAnimationLayer",xmlns:"http://www.w3.org/2000/svg","xmlns:html":"http://www.w3.org/1999/xhtml","xmlns:xlink":"http://www.w3.org/1999/xlink",version:"1.1"});return e.append(t),I(ea.G,{},t)}appendToAnimationLayer(e){var t,i,n=null==(t=this.dragLayer)?void 0:t.getAttribute("transform");if(n){let e;null==(e=this.animationLayer)||e.setAttribute("transform",n)}null==(i=this.animationLayer)||i.appendChild(e.getSvgRoot())}translateLayers(e,t){var i;e=`translate(${e.x}, ${e.y}) scale(${t})`,null==(i=this.dragLayer)||i.setAttribute("transform",e);for(let[,t]of this.layers)t.setAttribute("transform",e)}moveToDragLayer(e,t=!0){var i;null==(i=this.dragLayer)||i.appendChild(e.getSvgRoot()),t&&e.canBeFocused()&&Zs.t().focusNode(e)}moveOffDragLayer(e,t,i=!0){this.append(e,t),i&&e.canBeFocused()&&Zs.t().focusNode(e)}append(e,t){var i;if(this.layers.has(t)||this.createLayer(t),e=e.getSvgRoot(),(null==(i=this.layers.get(t))?void 0:i.lastChild)!==e){let i;null==(i=this.layers.get(t))||i.appendChild(e)}}createLayer(e){var t=this.workspace.getSvgGroup(),i=I(ea.G,{}),n=!1,o=[...this.layers].sort(((e,t)=>e[0]-t[0]));for(let[s,r]of o)if(e<s){t.insertBefore(i,r),n=!0;break}return n||t.appendChild(i),this.layers.set(e,i),i}hasLayer(e){return e===this.dragLayer||new Set(this.layers.values()).has(e)}getBlockLayer(){return this.layers.get(50)}getBubbleLayer(){return this.layers.get(100)}getDragLayer(){return this.dragLayer}},Ep={};Ep.register=rs,Ep.unregister=function(e){ie(ya.ICON,e)};var Tp=class extends Dc{constructor(e){super(e),this.sourceBlock=e,this.textInputBubble=null,this.text="",this.bubbleSize=new Fa(160,80),this.bubbleVisiblity=!1}getType(){return Tp.TYPE}initView(e){this.svgRoot||(super.initView(e),I(ea.CIRCLE,{class:"blocklyIconShape",r:"8",cx:"8",cy:"8"},this.svgRoot),I(ea.PATH,{class:"blocklyIconSymbol",d:"m6.8,10h2c0.003,-0.617 0.271,-0.962 0.633,-1.266 2.875,-2.4050.607,-5.534 -3.765,-3.874v1.7c3.12,-1.657 3.698,0.118 2.336,1.25-1.201,0.998 -1.201,1.528 -1.204,2.19z"},this.svgRoot),I(ea.RECT,{class:"blocklyIconSymbol",x:"6.8",y:"10.78",height:"2",width:"2"},this.svgRoot),N(this.svgRoot,"blocklyCommentIcon"))}dispose(){var e;super.dispose(),null==(e=this.textInputBubble)||e.dispose()}getWeight(){return Tp.WEIGHT}getSize(){return new Fa(17,17)}applyColour(){super.applyColour();var e,t=this.sourceBlock.getColour();null==(e=this.textInputBubble)||e.setColour(t)}updateEditable(){var e=this,t=()=>super.updateEditable;return(0,Qs.asyncExecutePromiseGeneratorFunction)((function*(){t().call(e),e.bubbleIsVisible()&&(yield e.setBubbleVisible(!1),yield e.setBubbleVisible(!0))}))}onLocationChange(e){var t,i=this.workspaceLocation;super.onLocationChange(e),this.bubbleLocation&&(e=Da.difference(this.workspaceLocation,i),this.bubbleLocation=Da.sum(this.bubbleLocation,e)),e=this.getAnchorLocation(),null==(t=this.textInputBubble)||t.setAnchorLocation(e)}setText(e){var t,i=this.text;ue(new(_e(Fr.BLOCK_CHANGE))(this.sourceBlock,"comment",null,i,e)),this.text=e,null==(t=this.textInputBubble)||t.setText(this.text)}getText(){return this.text}setBubbleSize(e){var t;this.bubbleSize=e,null==(t=this.textInputBubble)||t.setSize(this.bubbleSize,!0)}getBubbleSize(){return this.bubbleSize}setBubbleLocation(e){var t;this.bubbleLocation=e,null==(t=this.textInputBubble)||t.moveDuringDrag(e)}getBubbleLocation(){return this.bubbleLocation}saveState(){if(this.text){let e={text:this.text,pinned:this.bubbleIsVisible(),height:this.bubbleSize.height,width:this.bubbleSize.width},t=this.getBubbleLocation();return t&&(e.x=this.sourceBlock.workspace.RTL?this.sourceBlock.workspace.getWidth()-(t.x+this.bubbleSize.width):t.x,e.y=t.y),e}return null}loadState(e){var t,i,n,o;this.text=null!=(t=e.text)?t:"",this.bubbleSize=new Fa(null!=(i=e.width)?i:160,null!=(n=e.height)?n:80),this.bubbleVisiblity=null!=(o=e.pinned)&&o,this.setBubbleVisible(this.bubbleVisiblity);var s=e.x,r=e.y;Ze().then((()=>{s&&r&&(s=this.sourceBlock.workspace.RTL?this.sourceBlock.workspace.getWidth()-(s+this.bubbleSize.width):s,this.setBubbleLocation(new Da(s,r)))}))}onClick(){super.onClick(),this.setBubbleVisible(!this.bubbleIsVisible())}isClickableInFlyout(){return!1}onTextChange(){if(this.textInputBubble){var e=this.textInputBubble.getText();this.text!==e&&(ue(new(_e(Fr.BLOCK_CHANGE))(this.sourceBlock,"comment",null,this.text,e)),this.text=e)}}onSizeChange(){this.textInputBubble&&(this.bubbleSize=this.textInputBubble.getSize())}onBubbleLocationChange(){this.textInputBubble&&(this.bubbleLocation=this.textInputBubble.getRelativeToSurfaceXY())}bubbleIsVisible(){return this.bubbleVisiblity}setBubbleVisible(e){var t=this;return(0,Qs.asyncExecutePromiseGeneratorFunction)((function*(){t.bubbleVisiblity!==e&&(t.bubbleVisiblity=e,yield Ze(),!t.sourceBlock.rendered||t.sourceBlock.isInFlyout||t.sourceBlock.isInsertionMarker()||(e?(t.sourceBlock.isEditable()?t.showEditableBubble():t.showNonEditableBubble(),t.applyColour()):t.hideBubble(),ue(new(_e(Fr.BUBBLE_OPEN))(t.sourceBlock,e,"comment")),t.svgRoot&&t.recomputeAriaContext()))}))}getBubble(){return this.textInputBubble}showEditableBubble(){var e,t;this.createBubble(),null==(e=this.textInputBubble)||e.addTextChangeListener((()=>this.onTextChange())),null==(t=this.textInputBubble)||t.addSizeChangeListener((()=>this.onSizeChange()))}showNonEditableBubble(){var e;this.createBubble(),null==(e=this.textInputBubble)||e.setEditable(!1)}createBubble(){this.textInputBubble=new Uc(this.sourceBlock.workspace,this.getAnchorLocation(),this.getBubbleOwnerRect(),this),this.textInputBubble.getEditor().setParent(this.sourceBlock),this.textInputBubble.setText(this.getText()),this.textInputBubble.setSize(this.bubbleSize,!0),this.bubbleLocation&&this.textInputBubble.moveDuringDrag(this.bubbleLocation),this.textInputBubble.addTextChangeListener((()=>this.onTextChange())),this.textInputBubble.addSizeChangeListener((()=>this.onSizeChange())),this.textInputBubble.addLocationChangeListener((()=>this.onBubbleLocationChange())),this.textInputBubble.setAriaLabelProvider((()=>Zs.C.BUBBLE_LABEL_COMMENT.replace("%1",this.getText())))}hideBubble(){var e;null==(e=this.textInputBubble)||e.dispose(),this.textInputBubble=null}getAnchorLocation(){return Da.sum(this.workspaceLocation,new Da(8.5,8.5))}getBubbleOwnerRect(){return this.sourceBlock.getBoundingRectangleWithoutChildren()}getAriaLabel(){return this.bubbleIsVisible()?Zs.C.ICON_LABEL_COMMENT_OPEN:Zs.C.ICON_LABEL_COMMENT_CLOSED}};Tp.TYPE=Hl.COMMENT,Tp.WEIGHT=3,rs(Tp.TYPE,Tp);var _p,fp,mp={};mp.CommentIcon=Tp,mp.Icon=Dc,mp.IconType=Hl,mp.MutatorIcon=Zs.sh,mp.WarningIcon=Md,mp.exceptions=qc,mp.registry=Ep,Zs.Cj=class{constructor(e,t){this.db=new Map,this.dbReverse=new Set,this.variableMap=null,this.variablePrefix=t||"",this.reservedWords=new Set(e?e.split(","):[])}reset(){this.db.clear(),this.dbReverse.clear(),this.variableMap=null}setVariableMap(e){this.variableMap=e}getNameForUserVariable(e){return this.variableMap?(e=this.variableMap.getVariableById(e))?e.getName():null:(console.warn("Deprecated call to Names.prototype.getName without defining a variable map. To fix, add the following code in your generator's init() function:\nBlockly.YourGeneratorName.nameDB_.setVariableMap(workspace.getVariableMap());"),null)}populateVariables(e){e=Zs.Bd(e);for(let t=0;t<e.length;t++)this.getName(e[t].getId(),Zs.P.VARIABLE)}populateProcedures(){throw Error("The implementation of populateProcedures should be monkey-patched in by blockly.ts")}getName(e,t){var i=e;t===Zs.P.VARIABLE&&(e=this.getNameForUserVariable(e))&&(i=e),e=i.toLowerCase();var n=t===Zs.P.VARIABLE||t===Zs.P.DEVELOPER_VARIABLE?this.variablePrefix:"";this.db.has(t)||this.db.set(t,new Map);var o=this.db.get(t);return o.has(e)?n+o.get(e):(t=this.getDistinctName(i,t),o.set(e,t.substr(n.length)),t)}getUserNames(e){var t;return(e=null==(t=this.db.get(e))?void 0:t.keys())?Array.from(e):[]}getDistinctName(e,t){e=this.safeName(e);for(var i,n,o=null;this.dbReverse.has(e+(null!=(i=o)?i:""))||this.reservedWords.has(e+(null!=(n=o)?n:""));)o=o?o+1:2;var s;return e+=null!=(s=o)?s:"",this.dbReverse.add(e),(t===Zs.P.VARIABLE||t===Zs.P.DEVELOPER_VARIABLE?this.variablePrefix:"")+e}safeName(e){return e?(e=encodeURI(e.replace(/ /g,"_")).replace(/[^\w]/g,"_"),"0123456789".includes(e[0])&&(e="my_"+e)):e=Zs.C.UNNAMED_KEY||"unnamed",e}static equals(e,t){return e.toLowerCase()===t.toLowerCase()}},(fp=(_p=Zs.Cj||(Zs.Cj={})).NameType||(_p.NameType={})).DEVELOPER_VARIABLE="DEVELOPER_VARIABLE",fp.VARIABLE="VARIABLE",fp.PROCEDURE="PROCEDURE",Zs.P=Zs.Cj.NameType,Zs.Cj.DEVELOPER_VARIABLE_TYPE=Zs.P.DEVELOPER_VARIABLE;var bp=class extends Map{constructor(){super()}set(e,t){return this.get(e)===t||(super.set(e,t),ls(t)&&t.startPublishing()),this}delete(e){var t=this.get(e);return(e=super.delete(e))?(ls(t)&&t.stopPublishing(),e):e}clear(){if(this.size)for(let e of this.keys())this.delete(e)}add(e){return this.set(e.getId(),e)}getProcedures(){return[...this.values()]}},Cp={CATEGORY_NAME:"PROCEDURE",DEFAULT_ARG:"x"};Cp.ObservableProcedureMap=bp,Cp.allProcedures=hs,Cp.findLegalName=Zs.Bj,Cp.flyoutCategory=ds,Cp.getCallers=Ts,Cp.getDefinition=Zs.Lj,Cp.isNameUsed=cs,Cp.isProcedureBlock=as,Cp.mutateCallers=Zs.Kj,Cp.mutatorOpenListener=gs,Cp.rename=Zs.Ej;var vp=new class{constructor(){this.NONE=0,this.FIELD=1,this.HAT=2,this.ICON=4,this.SPACER=8,this.BETWEEN_ROW_SPACER=16,this.IN_ROW_SPACER=32,this.EXTERNAL_VALUE_INPUT=64,this.INPUT=128,this.INLINE_INPUT=256,this.STATEMENT_INPUT=512,this.CONNECTION=1024,this.PREVIOUS_CONNECTION=2048,this.NEXT_CONNECTION=4096,this.OUTPUT_CONNECTION=8192,this.CORNER=16384,this.LEFT_SQUARE_CORNER=32768,this.LEFT_ROUND_CORNER=65536,this.RIGHT_SQUARE_CORNER=131072,this.RIGHT_ROUND_CORNER=262144,this.JAGGED_EDGE=524288,this.ROW=1048576,this.TOP_ROW=2097152,this.BOTTOM_ROW=4194304,this.INPUT_ROW=8388608,this.LEFT_CORNER=this.LEFT_SQUARE_CORNER|this.LEFT_ROUND_CORNER,this.RIGHT_CORNER=this.RIGHT_SQUARE_CORNER|this.RIGHT_ROUND_CORNER,this.nextTypeValue_=16777216}getType(e){return Object.prototype.hasOwnProperty.call(this,e)||(this[e]=this.nextTypeValue_,this.nextTypeValue_<<=1),this[e]}isField(e){return(e.type&this.FIELD)>=1}isHat(e){return(e.type&this.HAT)>=1}isIcon(e){return(e.type&this.ICON)>=1}isSpacer(e){return(e.type&this.SPACER)>=1}isInRowSpacer(e){return(e.type&this.IN_ROW_SPACER)>=1}isSpacerRow(e){return(e.type&this.BETWEEN_ROW_SPACER)>=1}isInput(e){return(e.type&this.INPUT)>=1}isExternalInput(e){return(e.type&this.EXTERNAL_VALUE_INPUT)>=1}isInlineInput(e){return(e.type&this.INLINE_INPUT)>=1}isStatementInput(e){return(e.type&this.STATEMENT_INPUT)>=1}isPreviousConnection(e){return(e.type&this.PREVIOUS_CONNECTION)>=1}isNextConnection(e){return(e.type&this.NEXT_CONNECTION)>=1}isPreviousOrNextConnection(e){return this.isPreviousConnection(e)||this.isNextConnection(e)}isRoundCorner(e){return(e.type&this.LEFT_ROUND_CORNER)>=1||(e.type&this.RIGHT_ROUND_CORNER)>=1}isLeftRoundedCorner(e){return this.isRoundCorner(e)&&(e.type&this.LEFT_ROUND_CORNER)>=1}isRightRoundedCorner(e){return this.isRoundCorner(e)&&(e.type&this.RIGHT_ROUND_CORNER)>=1}isLeftSquareCorner(e){return(e.type&this.LEFT_SQUARE_CORNER)>=1}isRightSquareCorner(e){return(e.type&this.RIGHT_SQUARE_CORNER)>=1}isCorner(e){return(e.type&this.CORNER)>=1}isJaggedEdge(e){return(e.type&this.JAGGED_EDGE)>=1}isRow(e){return(e.type&this.ROW)>=1}isBetweenRowSpacer(e){return(e.type&this.BETWEEN_ROW_SPACER)>=1}isTopRow(e){return(e.type&this.TOP_ROW)>=1}isBottomRow(e){return(e.type&this.BOTTOM_ROW)>=1}isTopOrBottomRow(e){return this.isTopRow(e)||this.isBottomRow(e)}isInputRow(e){return(e.type&this.INPUT_ROW)>=1}},Ip=class{constructor(e){this.centerline=this.xPos=this.height=this.width=0,this.constants_=e,this.type=vp.NONE,this.notchOffset=this.constants_.NOTCH_OFFSET_LEFT}},Np=class{constructor(e){this.elements=[],this.xPos=this.yPos=this.widthWithConnectedBlocks=this.minWidth=this.minHeight=this.width=this.height=0,this.hasStatement=this.hasExternalInput=!1,this.statementEdge=0,this.hasJaggedEdge=this.hasDummyInput=this.hasInlineInput=!1,this.align=null,this.constants_=e,this.type=vp.ROW,this.notchOffset=this.constants_.NOTCH_OFFSET_LEFT}getLastInput(){for(let e=this.elements.length-1;e>=0;e--){let t=this.elements[e];if(vp.isInput(t))return t}return null}measure(){throw Error("Unexpected attempt to measure a base Row.")}startsWithElemSpacer(){return!0}endsWithElemSpacer(){return!0}getFirstSpacer(){for(let e=0;e<this.elements.length;e++){let t=this.elements[e];if(vp.isInRowSpacer(t))return t}return null}getLastSpacer(){for(let e=this.elements.length-1;e>=0;e--){let t=this.elements[e];if(vp.isInRowSpacer(t))return t}return null}},yp=class extends Np{constructor(e){super(e),this.hasNextConnection=!1,this.connection=null,this.baseline=this.descenderHeight=0,this.type|=vp.BOTTOM_ROW}hasLeftSquareCorner(e){return!!e.outputConnection||!!e.getNextBlock()}hasRightSquareCorner(){return!0}measure(){var e=0,t=0,i=0;for(let n=0;n<this.elements.length;n++){let o=this.elements[n];t+=o.width,vp.isSpacer(o)||(vp.isNextConnection(o)?i=Math.max(i,o.height):e=Math.max(e,o.height))}this.width=Math.max(this.minWidth,t),this.height=Math.max(this.minHeight,e)+i,this.descenderHeight=i,this.widthWithConnectedBlocks=this.width}startsWithElemSpacer(){return!1}endsWithElemSpacer(){return!1}},Ap=class extends Ip{constructor(e,t){super(e),this.connectionModel=t,this.type|=vp.CONNECTION,this.shape=this.constants_.shapeFor(t),this.isDynamicShape="isDynamic"in this.shape&&this.shape.isDynamic,this.highlighted=t.isHighlighted()}},kp=class extends Ap{constructor(e,t){super(e,t.connection),this.input=t,this.connectionOffsetY=this.connectionOffsetX=0,this.type|=vp.INPUT,this.align=t.align,this.connectedBlock=t.connection&&t.connection.targetBlock()?t.connection.targetBlock():null,e=t.connection.getInsertionMarker(),this.connectedBlockHeight=this.connectedBlockWidth=0,this.connectedBlock&&(t=this.connectedBlock.getHeightWidth(),this.connectedBlockWidth=t.width,this.connectedBlockHeight=t.height),e&&(e=e.getHeightWidth(),this.connectedBlockWidth+=e.width,this.connectedBlockHeight+=e.height)}},Sp=class extends kp{constructor(e,t){super(e,t),this.height=0,this.type|=vp.EXTERNAL_VALUE_INPUT,this.connectedBlockHeight?((e=this.connectionModel.getInsertionMarker())&&(this.connectedBlockHeight=e.getHeightWidth().height),this.height=this.connectedBlockHeight-this.constants_.TAB_OFFSET_FROM_TOP-this.constants_.MEDIUM_PADDING):this.height=this.shape.height,this.width=this.shape.width+this.constants_.EXTERNAL_VALUE_INPUT_PADDING,this.connectionOffsetY=this.constants_.TAB_OFFSET_FROM_TOP,this.connectionHeight=this.shape.height,this.connectionWidth=this.shape.width}},Op=class extends Ip{constructor(e,t,i){super(e),this.field=t,this.parentInput=i,this.isEditable=t.EDITABLE,this.flipRtl=t.getFlipRtl(),this.type|=vp.FIELD,e=this.field.getSize(),this.height=e.height,this.width=e.width}},Rp=class extends Ip{constructor(e){super(e),this.type|=vp.HAT,this.height=this.constants_.START_HAT.height,this.width=this.constants_.START_HAT.width,this.ascenderHeight=this.height}},wp=class extends Ip{constructor(e,t){super(e),this.icon=t,this.flipRtl=!1,this.type|=vp.ICON,e=t.getSize(),this.height=e.height,this.width=e.width}},Lp=class extends Ip{constructor(e,t){super(e),this.type|=vp.SPACER|vp.IN_ROW_SPACER,this.width=t,this.height=this.constants_.SPACER_DEFAULT_HEIGHT}},Dp=class extends kp{constructor(e,t){super(e,t),this.type|=vp.INLINE_INPUT,this.connectedBlockWidth||this.connectedBlockHeight?(this.width=this.connectedBlockWidth,this.height=this.connectedBlockHeight):(this.height=this.constants_.EMPTY_INLINE_INPUT_HEIGHT,this.width=this.constants_.EMPTY_INLINE_INPUT_PADDING),this.connectionHeight=this.isDynamicShape?this.shape.height(this.height):this.shape.height,this.connectionWidth=this.isDynamicShape?this.shape.width(this.height):this.shape.width,this.connectedBlockHeight||(this.width+=this.connectionWidth*(this.isDynamicShape?2:1)),this.connectionOffsetY="connectionOffsetY"in this.shape?this.shape.connectionOffsetY(this.connectionHeight):this.constants_.TAB_OFFSET_FROM_TOP,this.connectionOffsetX="connectionOffsetX"in this.shape?this.shape.connectionOffsetX(this.connectionWidth):0}},xp=class extends Np{constructor(e){super(e),this.connectedBlockWidths=0,this.type|=vp.INPUT_ROW}measure(){this.width=this.minWidth,this.height=this.minHeight;var e=0;for(let t=0;t<this.elements.length;t++){let i=this.elements[t];this.width+=i.width,vp.isInput(i)&&(vp.isStatementInput(i)?e+=i.connectedBlockWidth:vp.isExternalInput(i)&&0!==i.connectedBlockWidth&&(e+=i.connectedBlockWidth-i.connectionWidth)),vp.isSpacer(i)||(this.height=Math.max(this.height,i.height))}this.connectedBlockWidths=e,this.widthWithConnectedBlocks=this.width+e}endsWithElemSpacer(){return!this.hasExternalInput&&!this.hasStatement}},Fp=class extends Ip{constructor(e){super(e),this.type|=vp.JAGGED_EDGE,this.height=this.constants_.JAGGED_TEETH.height,this.width=this.constants_.JAGGED_TEETH.width}},Mp=class extends Ap{constructor(e,t){super(e,t),this.type|=vp.NEXT_CONNECTION,this.height=this.shape.height,this.width=this.shape.width,(e=t.getInsertionMarker())&&(this.height+=e.getHeightWidth().height)}},Pp=class extends Ap{constructor(e,t){super(e,t),this.connectionOffsetX=0,this.type|=vp.OUTPUT_CONNECTION,this.height=this.isDynamicShape?0:this.shape.height,this.startX=this.width=this.isDynamicShape?0:this.shape.width,this.connectionOffsetY=this.constants_.TAB_OFFSET_FROM_TOP}},Bp=class extends Ap{constructor(e,t){super(e,t),this.type|=vp.PREVIOUS_CONNECTION,this.height=this.shape.height,this.width=this.shape.width}},Up=class extends Ip{constructor(e,t){super(e),this.type=(t&&"left"!==t?vp.RIGHT_ROUND_CORNER:vp.LEFT_ROUND_CORNER)|vp.CORNER,this.width=this.constants_.CORNER_RADIUS,this.height=this.constants_.CORNER_RADIUS/2}},Vp=class extends Np{constructor(e,t,i){super(e),this.height=t,this.width=i,this.precedesStatement=this.followsStatement=!1,this.widthWithConnectedBlocks=0,this.type|=vp.SPACER|vp.BETWEEN_ROW_SPACER,this.elements=[new Lp(this.constants_,i)]}measure(){}},Hp=class extends Ip{constructor(e,t){super(e),this.type=(t&&"left"!==t?vp.RIGHT_SQUARE_CORNER:vp.LEFT_SQUARE_CORNER)|vp.CORNER,this.width=this.height=this.constants_.NO_PADDING}},Gp=class extends kp{constructor(e,t){super(e,t),this.type|=vp.STATEMENT_INPUT,this.height=this.connectedBlockHeight?this.connectedBlockHeight+this.constants_.STATEMENT_BOTTOM_SPACER:this.constants_.EMPTY_STATEMENT_INPUT_HEIGHT,this.width=this.constants_.STATEMENT_INPUT_NOTCH_OFFSET+this.shape.width}},Wp=class extends Np{constructor(e){super(e),this.ascenderHeight=this.capline=0,this.hasPreviousConnection=!1,this.connection=null,this.type|=vp.TOP_ROW}hasLeftSquareCorner(e){var t=(e.hat?"cap"===e.hat:this.constants_.ADD_START_HATS)&&!e.outputConnection&&!e.previousConnection,i=e.getPreviousBlock();return!!e.outputConnection||t||!!i&&i.getNextBlock()===e}hasRightSquareCorner(){return!0}measure(){var e=0,t=0,i=0;for(let n=0;n<this.elements.length;n++){let o=this.elements[n];t+=o.width,vp.isSpacer(o)||(vp.isHat(o)?i=Math.max(i,o.ascenderHeight):e=Math.max(e,o.height))}this.width=Math.max(this.minWidth,t),this.height=Math.max(this.minHeight,e)+i,this.capline=this.ascenderHeight=i,this.widthWithConnectedBlocks=this.width}startsWithElemSpacer(){return!1}endsWithElemSpacer(){return!1}},qp=new Map,$p=class{constructor(){this.NO_PADDING=0,this.SMALL_PADDING=3,this.MEDIUM_PADDING=5,this.MEDIUM_LARGE_PADDING=8,this.LARGE_PADDING=10,this.TAB_HEIGHT=15,this.TAB_OFFSET_FROM_TOP=5,this.TAB_VERTICAL_OVERLAP=2.5,this.TAB_WIDTH=8,this.NOTCH_WIDTH=15,this.NOTCH_HEIGHT=4,this.MIN_BLOCK_WIDTH=12,this.EMPTY_BLOCK_SPACER_HEIGHT=16,this.CORNER_RADIUS=8,this.NOTCH_OFFSET_LEFT=15,this.STATEMENT_BOTTOM_SPACER=0,this.STATEMENT_INPUT_PADDING_LEFT=20,this.BETWEEN_STATEMENT_PADDING_Y=4,this.ADD_START_HATS=!1,this.START_HAT_HEIGHT=15,this.START_HAT_WIDTH=100,this.SPACER_DEFAULT_HEIGHT=15,this.MIN_BLOCK_HEIGHT=24,this.EMPTY_INLINE_INPUT_PADDING=14.5,this.EXTERNAL_VALUE_INPUT_PADDING=2,this.JAGGED_TEETH_HEIGHT=12,this.JAGGED_TEETH_WIDTH=6,this.FIELD_TEXT_FONTSIZE=11,this.FIELD_TEXT_FONTWEIGHT="normal",this.FIELD_TEXT_FONTFAMILY="sans-serif",this.FIELD_TEXT_BASELINE=this.FIELD_TEXT_HEIGHT=-1,this.FIELD_BORDER_RECT_RADIUS=4,this.FIELD_BORDER_RECT_HEIGHT=16,this.FIELD_BORDER_RECT_X_PADDING=5,this.FIELD_BORDER_RECT_Y_PADDING=3,this.FIELD_BORDER_RECT_COLOUR="#fff",this.FIELD_DROPDOWN_SVG_ARROW=this.FIELD_DROPDOWN_COLOURED_DIV=this.FIELD_DROPDOWN_NO_BORDER_RECT_SHADOW=!1,this.FIELD_DROPDOWN_SVG_ARROW_SIZE=12,this.FIELD_COLOUR_FULL_BLOCK=this.FIELD_TEXTINPUT_BOX_SHADOW=!1,this.FIELD_COLOUR_DEFAULT_WIDTH=26,this.defs=null,this.embossFilterId="",this.embossFilter=null,this.disabledPatternId="",this.disabledPattern=null,this.debugFilterId="",this.debugFilter=null,this.CURSOR_COLOUR="#cc0a0a",this.MARKER_COLOUR="#4286f4",this.CURSOR_WS_WIDTH=100,this.WS_CURSOR_HEIGHT=5,this.CURSOR_STACK_PADDING=10,this.CURSOR_BLOCK_PADDING=2,this.CURSOR_STROKE_WIDTH=4,this.FULL_BLOCK_FIELDS=!1,this.INSERTION_MARKER_COLOUR="#000000",this.INSERTION_MARKER_OPACITY=.2,this.SHAPES={PUZZLE:1,NOTCH:2},this.TALL_INPUT_FIELD_OFFSET_Y=this.MEDIUM_PADDING,this.DUMMY_INPUT_SHADOW_MIN_HEIGHT=this.DUMMY_INPUT_MIN_HEIGHT=this.TAB_HEIGHT,this.STATEMENT_INPUT_NOTCH_OFFSET=this.NOTCH_OFFSET_LEFT,this.TOP_ROW_MIN_HEIGHT=this.MEDIUM_PADDING,this.TOP_ROW_PRECEDES_STATEMENT_MIN_HEIGHT=this.LARGE_PADDING,this.BOTTOM_ROW_MIN_HEIGHT=this.MEDIUM_PADDING,this.BOTTOM_ROW_AFTER_STATEMENT_MIN_HEIGHT=this.LARGE_PADDING,this.EMPTY_INLINE_INPUT_HEIGHT=this.TAB_HEIGHT+11,this.EMPTY_STATEMENT_INPUT_HEIGHT=this.MIN_BLOCK_HEIGHT,this.START_POINT=Gn(0,0),this.FIELD_TEXT_BASELINE_CENTER=!0,this.FIELD_DROPDOWN_BORDER_RECT_HEIGHT=this.FIELD_BORDER_RECT_HEIGHT,this.FIELD_DROPDOWN_SVG_ARROW_PADDING=this.FIELD_BORDER_RECT_X_PADDING,this.FIELD_DROPDOWN_SVG_ARROW_DATAURI="data:image/svg+xml;base64,PHN2ZyBpZD0iTGF5ZXJfMSIgZGF0YS1uYW1lPSJMYXllciAxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIxMi43MSIgaGVpZ2h0PSI4Ljc5IiB2aWV3Qm94PSIwIDAgMTIuNzEgOC43OSI+PHRpdGxlPmRyb3Bkb3duLWFycm93PC90aXRsZT48ZyBvcGFjaXR5PSIwLjEiPjxwYXRoIGQ9Ik0xMi43MSwyLjQ0QTIuNDEsMi40MSwwLDAsMSwxMiw0LjE2TDguMDgsOC4wOGEyLjQ1LDIuNDUsMCwwLDEtMy40NSwwTDAuNzIsNC4xNkEyLjQyLDIuNDIsMCwwLDEsMCwyLjQ0LDIuNDgsMi40OCwwLDAsMSwuNzEuNzFDMSwwLjQ3LDEuNDMsMCw2LjM2LDBTMTEuNzUsMC40NiwxMiwuNzFBMi40NCwyLjQ0LDAsMCwxLDEyLjcxLDIuNDRaIiBmaWxsPSIjMjMxZjIwIi8+PC9nPjxwYXRoIGQ9Ik02LjM2LDcuNzlhMS40MywxLjQzLDAsMCwxLTEtLjQyTDEuNDIsMy40NWExLjQ0LDEuNDQsMCwwLDEsMC0yYzAuNTYtLjU2LDkuMzEtMC41Niw5Ljg3LDBhMS40NCwxLjQ0LDAsMCwxLDAsMkw3LjM3LDcuMzdBMS40MywxLjQzLDAsMCwxLDYuMzYsNy43OVoiIGZpbGw9IiNmZmYiLz48L3N2Zz4=",this.FIELD_COLOUR_DEFAULT_HEIGHT=this.FIELD_BORDER_RECT_HEIGHT,this.FIELD_CHECKBOX_X_OFFSET=this.FIELD_BORDER_RECT_X_PADDING-3,this.randomIdentifier=String(Math.random()).substring(2)}init(){this.JAGGED_TEETH=this.makeJaggedTeeth(),this.NOTCH=this.makeNotch(),this.START_HAT=this.makeStartHat(),this.PUZZLE_TAB=this.makePuzzleTab(),this.INSIDE_CORNERS=this.makeInsideCorners(),this.OUTSIDE_CORNERS=this.makeOutsideCorners()}setTheme(e){this.blockStyles=Object.create(null);var t=e.blockStyles;for(let e in t)this.blockStyles[e]=this.validatedBlockStyle_(t[e]);this.setDynamicProperties_(e)}setDynamicProperties_(e){this.setFontConstants_(e),this.setComponentConstants_(e),this.ADD_START_HATS=void 0!==e.startHats?e.startHats:this.ADD_START_HATS}setFontConstants_(e){e.fontStyle&&e.fontStyle.family&&(this.FIELD_TEXT_FONTFAMILY=e.fontStyle.family),e.fontStyle&&e.fontStyle.weight&&(this.FIELD_TEXT_FONTWEIGHT=e.fontStyle.weight),e.fontStyle&&e.fontStyle.size&&(this.FIELD_TEXT_FONTSIZE=e.fontStyle.size),e=F("Hg",this.FIELD_TEXT_FONTSIZE+"pt",this.FIELD_TEXT_FONTWEIGHT,this.FIELD_TEXT_FONTFAMILY),this.FIELD_TEXT_HEIGHT=e.height,this.FIELD_TEXT_BASELINE=e.baseline}setComponentConstants_(e){this.CURSOR_COLOUR=e.getComponentStyle("cursorColour")||this.CURSOR_COLOUR,this.MARKER_COLOUR=e.getComponentStyle("markerColour")||this.MARKER_COLOUR,this.INSERTION_MARKER_COLOUR=e.getComponentStyle("insertionMarkerColour")||this.INSERTION_MARKER_COLOUR,this.INSERTION_MARKER_OPACITY=Number(e.getComponentStyle("insertionMarkerOpacity"))||this.INSERTION_MARKER_OPACITY}getBlockStyleForColour(e){var t="auto_"+e;return this.blockStyles[t]||(this.blockStyles[t]=this.createBlockStyle_(e)),{style:this.blockStyles[t],name:t}}getBlockStyle(e){return this.blockStyles[e||""]||(e&&e.startsWith("auto_")?this.getBlockStyleForColour(e.substring(5)).style:this.createBlockStyle_("#000000"))}createBlockStyle_(e){return this.validatedBlockStyle_({colourPrimary:e})}validatedBlockStyle_(e){var t={};return e&&Object.assign(t,e),e=Qi(t.colourPrimary||"#000"),t.colourPrimary=e.hex,t.colourSecondary=t.colourSecondary?Qi(t.colourSecondary).hex:this.generateSecondaryColour_(t.colourPrimary),t.colourTertiary=t.colourTertiary?Qi(t.colourTertiary).hex:this.generateTertiaryColour_(t.colourPrimary),t.hat=t.hat||"",t}generateSecondaryColour_(e){return zi("#fff",e,.6)||e}generateTertiaryColour_(e){return zi("#fff",e,.3)||e}dispose(){this.embossFilter&&S(this.embossFilter),this.disabledPattern&&S(this.disabledPattern),this.debugFilter&&S(this.debugFilter)}makeJaggedTeeth(){var e=this.JAGGED_TEETH_HEIGHT,t=this.JAGGED_TEETH_WIDTH;return{height:e,width:t,path:qn([Un(t,e/4),Un(2*-t,e/2),Un(t,e/4)])}}makeStartHat(){var e=this.START_HAT_HEIGHT,t=this.START_HAT_WIDTH;return{height:.75*e,width:t,path:Vn("c",[Un(30,-e),Un(70,-e),Un(t,0)])}}makePuzzleTab(){function e(e){var n=-(e=e?-1:1),o=i/2,s=o+2.5,r=o+.5,a=Un(-t,e*o);return o=Un(t,e*o),Vn("c",[Un(0,e*s),Un(-t,n*r),a])+Vn("s",[Un(t,2.5*n),o])}var t=this.TAB_WIDTH,i=this.TAB_HEIGHT,n=e(!0),o=e(!1);return{type:this.SHAPES.PUZZLE,width:t,height:i,pathDown:o,pathUp:n}}makeNotch(){function e(e){return qn([Un(e*n,i),Un(3*e,0),Un(e*n,-i)])}var t=this.NOTCH_WIDTH,i=this.NOTCH_HEIGHT,n=(t-3)/2,o=e(1),s=e(-1);return{type:this.SHAPES.NOTCH,width:t,height:i,pathLeft:o,pathRight:s}}makeInsideCorners(){var e=this.CORNER_RADIUS;return{width:e,height:e,pathTop:jn("a","0 0,0",e,Un(-e,e)),pathBottom:jn("a","0 0,0",e,Un(e,e))}}makeOutsideCorners(){var e=this.CORNER_RADIUS,t=Gn(0,e)+jn("a","0 0,1",e,Un(e,-e)),i=jn("a","0 0,1",e,Un(e,e)),n=jn("a","0 0,1",e,Un(-e,-e));return{topLeft:t,topRight:i,bottomRight:jn("a","0 0,1",e,Un(-e,e)),bottomLeft:n,rightHeight:e}}shapeFor(e){switch(e.type){case Xl.INPUT_VALUE:case Xl.OUTPUT_VALUE:return this.PUZZLE_TAB;case Xl.PREVIOUS_STATEMENT:case Xl.NEXT_STATEMENT:return this.NOTCH;default:throw Error("Unknown connection type")}}createDom(e,t,i){if(i){let e=i.getRootNode();this.injectCSS_(e,t)}this.defs=I(ea.DEFS,{},e),e=I(ea.FILTER,{id:"blocklyEmbossFilter"+this.randomIdentifier},this.defs),I(ea.FEGAUSSIANBLUR,{in:"SourceAlpha",stdDeviation:1,result:"blur"},e),t=I(ea.FESPECULARLIGHTING,{in:"blur",surfaceScale:1,specularConstant:.5,specularExponent:10,"lighting-color":"white",result:"specOut"},e),I(ea.FEPOINTLIGHT,{x:-5e3,y:-1e4,z:2e4},t),I(ea.FECOMPOSITE,{in:"specOut",in2:"SourceAlpha",operator:"in",result:"specOut"},e),I(ea.FECOMPOSITE,{in:"SourceGraphic",in2:"specOut",operator:"arithmetic",k1:0,k2:1,k3:1,k4:0},e),this.embossFilterId=e.id,this.embossFilter=e,e=I(ea.PATTERN,{id:"blocklyDisabledPattern"+this.randomIdentifier,patternUnits:"userSpaceOnUse",width:10,height:10},this.defs),I(ea.RECT,{width:10,height:10,fill:"#aaa"},e),I(ea.PATH,{d:"M 0 0 L 10 10 M 10 0 L 0 10",stroke:"#cc0"},e),this.disabledPatternId=e.id,this.disabledPattern=e,this.createDebugFilter(),i&&(i.style.setProperty("--blocklyEmbossFilter",`url(#${this.embossFilterId})`),i.style.setProperty("--blocklyDisabledPattern",`url(#${this.disabledPatternId})`),i.style.setProperty("--blocklyDebugFilter",`url(#${this.debugFilterId})`))}createDebugFilter(){if(!this.debugFilter){let e=I(ea.FILTER,{id:"blocklyDebugFilter"+this.randomIdentifier,height:"160%",width:"180%",y:"-30%",x:"-40%"},this.defs),t=I(ea.FECOMPONENTTRANSFER,{result:"outBlur"},e);I(ea.FEFUNCA,{type:"table",tableValues:"0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1"},t),I(ea.FEFLOOD,{"flood-color":"#ff0000","flood-opacity":.5,result:"outColor"},e),I(ea.FECOMPOSITE,{in:"outColor",in2:"outBlur",operator:"in",result:"outGlow"},e),this.debugFilterId=e.id,this.debugFilter=e}}injectCSS_(e,t){var i,n;"undefined"!=typeof window&&(null!=(i=qp.get(t))&&i.has(e)||((i=document.createElement("style")).className="blockly-renderer-style",i.textContent=this.getCSS_(t).join("\n"),(void 0!==globalThis.ShadowRoot&&e instanceof ShadowRoot?e:document.head).prepend(i),(i=null!=(n=qp.get(t))?n:new WeakSet).add(e),qp.set(t,i)))}getCSS_(e){return[`${e}.injectionDiv {`,"--blockly-active-node-color: #fc3;","}",`${e} .blocklyText, `,`${e} .blocklyFlyoutLabelText {`,`font: ${this.FIELD_TEXT_FONTWEIGHT} ${this.FIELD_TEXT_FONTSIZE}pt ${this.FIELD_TEXT_FONTFAMILY};`,"}",`${e} .blocklyText {`,"fill: #fff;","}",`${e} .blocklyNonEditableField>rect,`,`${e} .blocklyEditableField>rect {`,`fill: ${this.FIELD_BORDER_RECT_COLOUR};`,"fill-opacity: .6;","stroke: none;","}",`${e} .blocklyNonEditableField>text,`,`${e} .blocklyEditableField>text {`,"fill: #000;","}",`${e} .blocklyFlyoutLabelText {`,"fill: #000;","}",`${e} .blocklyText.blocklyBubbleText {`,"fill: #000;","}",`${e} .blocklyEditableField:not(.blocklyEditing):hover>rect {`,"stroke: #fff;","stroke-width: 2;","}",`${e} .blocklyHtmlInput {`,`font-family: ${this.FIELD_TEXT_FONTFAMILY};`,`font-weight: ${this.FIELD_TEXT_FONTWEIGHT};`,"}",`${e} .blocklySelected>.blocklyPath {`,"stroke: #fc3;","stroke-width: 3px;","}",`${e} .blocklyHighlightedConnectionPathVisible {`,"stroke: #fc3;","}",`${e} .blocklyReplaceable .blocklyPath {`,"fill-opacity: .5;","}",`${e} .blocklyReplaceable .blocklyPathLight,`,`${e} .blocklyReplaceable .blocklyPathDark {`,"display: none;","}",`${e} .blocklyInsertionMarker>.blocklyPath {`,`fill-opacity: ${this.INSERTION_MARKER_OPACITY};`,"stroke: none;","}"]}},jp=class{constructor(e,t){this.inlinePath_=this.outlinePath_="",this.block_=e,this.info_=t,this.topLeft_=e.getRelativeToSurfaceXY(),this.constants_=t.getRenderer().getConstants()}draw(){this.drawOutline_(),this.drawInternals_(),this.updateConnectionHighlights(),this.block_.pathObject.setPath(this.outlinePath_+"\n"+this.inlinePath_),this.info_.RTL&&this.block_.pathObject.flipRTL(),this.recordSizeOnBlock_()}recordSizeOnBlock_(){this.block_.height=this.info_.height,this.block_.width=this.info_.widthWithChildren,this.block_.childlessWidth=this.info_.width}drawOutline_(){this.drawTop_();for(let e=1;e<this.info_.rows.length-1;e++){let t=this.info_.rows[e];t.hasJaggedEdge?this.drawJaggedEdge_(t):t.hasStatement?this.drawStatementInput_(t):t.hasExternalInput?this.drawValueInput_(t):this.drawRightSideRow_(t)}this.drawBottom_(),this.drawLeft_()}drawTop_(){var e=this.info_.topRow,t=e.elements;this.positionPreviousConnection_(),this.outlinePath_+=Gn(e.xPos,this.info_.startY);for(let e,i=0;e=t[i];i++)vp.isLeftRoundedCorner(e)?this.outlinePath_+=this.constants_.OUTSIDE_CORNERS.topLeft:vp.isRightRoundedCorner(e)?this.outlinePath_+=this.constants_.OUTSIDE_CORNERS.topRight:vp.isPreviousConnection(e)?this.outlinePath_+=e.shape.pathLeft:vp.isHat(e)?this.outlinePath_+=this.constants_.START_HAT.path:vp.isSpacer(e)&&(this.outlinePath_+=$n("h",e.width));this.outlinePath_+=$n("v",e.height-e.ascenderHeight)}drawJaggedEdge_(e){this.outlinePath_+=this.constants_.JAGGED_TEETH.path+$n("v",e.height-this.constants_.JAGGED_TEETH.height)}drawValueInput_(e){var t=e.getLastInput();this.positionExternalValueConnection_(e);var i=t.shape.isDynamic?t.shape.pathDown(t.height):t.shape.pathDown;this.outlinePath_+=$n("H",t.xPos+t.width)+i+$n("v",e.height-t.connectionHeight)}drawStatementInput_(e){var t=e.getLastInput();if(t){var i=t.xPos+t.notchOffset+t.shape.width;t=t.shape.pathRight+$n("h",-(t.notchOffset-this.constants_.INSIDE_CORNERS.width))+this.constants_.INSIDE_CORNERS.pathTop;var n=e.height-2*this.constants_.INSIDE_CORNERS.height;this.outlinePath_+=$n("H",i)+t+$n("v",n)+this.constants_.INSIDE_CORNERS.pathBottom+$n("H",e.xPos+e.width),this.positionStatementInputConnection_(e)}}drawRightSideRow_(e){this.outlinePath_+=$n("V",e.yPos+e.height)}drawBottom_(){var e=this.info_.bottomRow,t=e.elements;this.positionNextConnection_();var i=0,n="";for(let o,s=t.length-1;o=t[s];s--)vp.isNextConnection(o)?n+=o.shape.pathRight:vp.isLeftSquareCorner(o)?n+=$n("H",e.xPos):vp.isLeftRoundedCorner(o)?n+=this.constants_.OUTSIDE_CORNERS.bottomLeft:vp.isRightRoundedCorner(o)?(n+=this.constants_.OUTSIDE_CORNERS.bottomRight,i=this.constants_.OUTSIDE_CORNERS.rightHeight):vp.isSpacer(o)&&(n+=$n("h",-1*o.width));this.outlinePath_+=$n("V",e.baseline-i),this.outlinePath_+=n}drawLeft_(){var e=this.info_.outputConnection;if(this.positionOutputConnection_(),e){let t=e.connectionOffsetY+e.height;e=e.shape.isDynamic?e.shape.pathUp(e.height):e.shape.pathUp,this.outlinePath_+=$n("V",t)+e}this.outlinePath_+="z"}drawInternals_(){for(let e,t=0;e=this.info_.rows[t];t++)for(let t,i=0;t=e.elements[i];i++)vp.isInlineInput(t)?this.drawInlineInput_(t):(vp.isIcon(t)||vp.isField(t))&&this.layoutField_(t)}layoutField_(e){var t=e.centerline-e.height/2,i=e.xPos,n="";this.info_.RTL&&(i=-(i+e.width),e.flipRtl&&(i+=e.width,n="scale(-1 1)")),vp.isIcon(e)?((n=e.icon).setOffsetInBlock(new Da(i,t)),this.info_.isInsertionMarker&&n.hideForInsertionMarker()):((e=e.field.getSvgRoot()).setAttribute("transform","translate("+i+","+t+")"+n),this.info_.isInsertionMarker&&e.setAttribute("display","none"))}drawInlineInput_(e){var t=e.width,i=e.height,n=e.connectionOffsetY,o=e.connectionHeight+n;this.inlinePath_+=Hn(e.xPos+e.connectionWidth,e.centerline-i/2)+$n("v",n)+e.shape.pathDown+$n("v",i-o)+$n("h",t-e.connectionWidth)+$n("v",-i)+"z",this.positionInlineInputConnection_(e)}positionInlineInputConnection_(e){var t=e.centerline-e.height/2;if(e.connectionModel){let i=e.xPos+e.connectionWidth+e.connectionOffsetX;this.info_.RTL&&(i*=-1),e.connectionModel.setOffsetInBlock(i,t+e.connectionOffsetY)}}positionStatementInputConnection_(e){var t=e.getLastInput();if(null!=t&&t.connectionModel){let i=e.xPos+e.statementEdge+t.notchOffset;this.info_.RTL&&(i*=-1),t.connectionModel.setOffsetInBlock(i,e.yPos)}}positionExternalValueConnection_(e){var t=e.getLastInput();if(t&&t.connectionModel){let i=e.xPos+e.width;this.info_.RTL&&(i*=-1),t.connectionModel.setOffsetInBlock(i,e.yPos)}}positionPreviousConnection_(){var e=this.info_.topRow;if(e.connection){let t=e.xPos+e.notchOffset;e.connection.connectionModel.setOffsetInBlock(this.info_.RTL?-t:t,0)}}positionNextConnection_(){var e=this.info_.bottomRow;if(e.connection){let t=e.connection,i=t.xPos;t.connectionModel.setOffsetInBlock(this.info_.RTL?-i:i,e.baseline)}}positionOutputConnection_(){if(this.info_.outputConnection){var e=this.info_.startX+this.info_.outputConnection.connectionOffsetX;let t;e=this.info_.RTL?-e:e,null==(t=this.block_.outputConnection)||t.setOffsetInBlock(e,this.info_.outputConnection.connectionOffsetY)}}updateConnectionHighlights(){for(let e of this.info_.rows)for(let t of e.elements){if(!(t instanceof Ap))continue;let e=this.drawConnectionHighlightPath(t);e&&(t.connectionModel.setAriaRole(e),e.classList.toggle("blocklyHighlightedConnectionPathVisible",t.highlighted))}}drawConnectionHighlightPath(e){var t=e.connectionModel;e=t.type===Xl.INPUT_VALUE||t.type===Xl.OUTPUT_VALUE?this.getExpressionConnectionHighlightPath(e):this.getStatementConnectionHighlightPath(e);var i,n,o=t.getSourceBlock();return null==(n=(i=o.pathObject).addConnectionHighlight)?void 0:n.call(i,t,e,t.getOffsetInBlock(),o.RTL)}getExpressionConnectionHighlightPath(e){var t="";if(e.shape.isDynamic)t=e.shape.pathDown(e.height);else{var i=e.shape;void 0!==i.pathDown&&void 0!==i.pathUp&&(t=e.shape.pathDown)}return e=this.constants_.TAB_OFFSET_FROM_TOP,Gn(0,-e)+$n("v",e)+t+$n("v",e)}getStatementConnectionHighlightPath(e){var t=e.shape;if(void 0===t.pathLeft||void 0===t.pathRight)throw Error("Statement connections should have notch shapes");return t=this.constants_.NOTCH_OFFSET_LEFT-this.constants_.CORNER_RADIUS,Gn(-t,0)+$n("h",t)+e.shape.pathLeft+$n("h",t)}},zp=class{constructor(e,t){this.statementEdge=this.width=this.widthWithChildren=this.height=0,this.rows=[],this.inputRows=[],this.startY=this.startX=0,this.renderer_=e,this.block_=t,this.constants_=this.renderer_.getConstants(),this.outputConnection=t.outputConnection?new Pp(this.constants_,t.outputConnection):null,this.isInline=t.getInputsInline()&&!t.isCollapsed(),this.isCollapsed=t.isCollapsed(),this.isInsertionMarker=t.isInsertionMarker(),this.RTL=t.RTL,this.topRow=new Wp(this.constants_),this.bottomRow=new yp(this.constants_)}getRenderer(){return this.renderer_}measure(){this.createRows_(),this.addElemSpacing_(),this.addRowSpacing_(),this.computeBounds_(),this.alignRowElements_(),this.finalize_()}createRows_(){this.populateTopRow_(),this.rows.push(this.topRow);var e=new xp(this.constants_);this.inputRows.push(e);var t=this.block_.getIcons();for(let i,n=0;i=t[n];n++){let t=new wp(this.constants_,i);this.isCollapsed&&!i.isShownWhenCollapsed()||e.elements.push(t)}t=void 0;for(let i,n=0;i=this.block_.inputList[n];n++)if(i.isVisible()){this.shouldStartNewRow_(i,t)&&(this.rows.push(e),e=new xp(this.constants_),this.inputRows.push(e));for(let t,n=0;t=i.fieldRow[n];n++)e.elements.push(new Op(this.constants_,t,i));this.addInput_(i,e),t=i}this.isCollapsed&&(e.hasJaggedEdge=!0,e.elements.push(new Fp(this.constants_))),(e.elements.length||e.hasDummyInput)&&this.rows.push(e),this.populateBottomRow_(),this.rows.push(this.bottomRow)}populateTopRow_(){var e=!!this.block_.previousConnection,t=(this.block_.hat?"cap"===this.block_.hat:this.constants_.ADD_START_HATS)&&!this.outputConnection&&!e,i=this.topRow.hasLeftSquareCorner(this.block_)?Hp:Up;this.topRow.elements.push(new i(this.constants_)),t?(e=new Rp(this.constants_),this.topRow.elements.push(e)):e&&(this.topRow.hasPreviousConnection=!0,this.topRow.connection=new Bp(this.constants_,this.block_.previousConnection),this.topRow.elements.push(this.topRow.connection)),this.block_.inputList.length&&this.block_.inputList[0]instanceof Qc&&!this.block_.isCollapsed()?this.topRow.minHeight=this.constants_.TOP_ROW_PRECEDES_STATEMENT_MIN_HEIGHT:this.topRow.minHeight=this.constants_.TOP_ROW_MIN_HEIGHT,i=this.topRow.hasRightSquareCorner(this.block_)?Hp:Up,this.topRow.elements.push(new i(this.constants_,"right"))}populateBottomRow_(){this.bottomRow.hasNextConnection=!!this.block_.nextConnection,this.bottomRow.minHeight=this.block_.inputList.length&&this.block_.inputList[this.block_.inputList.length-1]instanceof Qc?this.constants_.BOTTOM_ROW_AFTER_STATEMENT_MIN_HEIGHT:this.constants_.BOTTOM_ROW_MIN_HEIGHT,this.bottomRow.hasLeftSquareCorner(this.block_)?this.bottomRow.elements.push(new Hp(this.constants_)):this.bottomRow.elements.push(new Up(this.constants_)),this.bottomRow.hasNextConnection&&(this.bottomRow.connection=new Mp(this.constants_,this.block_.nextConnection),this.bottomRow.elements.push(this.bottomRow.connection)),this.bottomRow.hasRightSquareCorner(this.block_)?this.bottomRow.elements.push(new Hp(this.constants_,"right")):this.bottomRow.elements.push(new Up(this.constants_,"right"))}addInput_(e,t){this.isInline&&e instanceof Zs.go?(t.elements.push(new Dp(this.constants_,e)),t.hasInlineInput=!0):e instanceof Qc?(t.elements.push(new Gp(this.constants_,e)),t.hasStatement=!0):e instanceof Zs.go?(t.elements.push(new Sp(this.constants_,e)),t.hasExternalInput=!0):(e instanceof Kc||e instanceof Jc)&&(t.minHeight=Math.max(t.minHeight,e.getSourceBlock()&&e.getSourceBlock().isShadow()?this.constants_.DUMMY_INPUT_SHADOW_MIN_HEIGHT:this.constants_.DUMMY_INPUT_MIN_HEIGHT),t.hasDummyInput=!0),null===t.align&&(t.align=e.align)}shouldStartNewRow_(e,t){return!!t&&(t instanceof Jc||e instanceof Qc||t instanceof Qc||(e instanceof Zs.go||e instanceof Kc||t instanceof Zs.go)&&!this.isInline)}addElemSpacing_(){for(let e,t=0;e=this.rows[t];t++){let t=e.elements;if(e.elements=[],e.startsWithElemSpacer()&&e.elements.push(new Lp(this.constants_,this.getInRowSpacing_(null,t[0]))),t.length){for(let i=0;i<t.length-1;i++){e.elements.push(t[i]);let n=this.getInRowSpacing_(t[i],t[i+1]);e.elements.push(new Lp(this.constants_,n))}e.elements.push(t[t.length-1]),e.endsWithElemSpacer()&&e.elements.push(new Lp(this.constants_,this.getInRowSpacing_(t[t.length-1],null)))}}}getInRowSpacing_(e,t){if(!e&&t&&vp.isStatementInput(t))return this.constants_.STATEMENT_INPUT_PADDING_LEFT;if(e&&vp.isInput(e)&&!t){if(vp.isExternalInput(e))return this.constants_.NO_PADDING;if(vp.isInlineInput(e))return this.constants_.LARGE_PADDING;if(vp.isStatementInput(e))return this.constants_.NO_PADDING}return e&&vp.isLeftSquareCorner(e)&&t&&(vp.isPreviousConnection(t)||vp.isNextConnection(t))?t.notchOffset:e&&vp.isLeftRoundedCorner(e)&&t&&(vp.isPreviousConnection(t)||vp.isNextConnection(t))?t.notchOffset-this.constants_.CORNER_RADIUS:e&&vp.isField(e)&&0===e.width?this.constants_.NO_PADDING:this.constants_.MEDIUM_PADDING}computeBounds_(){var e=0,t=0,i=0;for(let o,s=0;o=this.rows[s];s++){if(o.measure(),t=Math.max(t,o.width),o.hasStatement){var n=o.getLastInput();let t;n=o.width-(null!=(t=null==n?void 0:n.width)?t:0),e=Math.max(e,n)}i=Math.max(i,o.widthWithConnectedBlocks)}this.statementEdge=e,this.width=t;for(let e,t=0;e=this.rows[t];t++)e.hasStatement&&(e.statementEdge=this.statementEdge);this.widthWithChildren=Math.max(t,i),this.outputConnection&&(this.startX=this.outputConnection.width,this.width+=this.outputConnection.width,this.widthWithChildren+=this.outputConnection.width)}alignRowElements_(){for(let t,i=0;t=this.rows[i];i++)if(t.hasStatement)this.alignStatementRow_(t);else{var e=t.width;(e=this.getDesiredRowWidth_(t)-e)>0&&this.addAlignmentPadding_(t,e),vp.isTopOrBottomRow(t)&&(t.widthWithConnectedBlocks=t.width)}}getDesiredRowWidth_(){return this.width-this.startX}addAlignmentPadding_(e,t){var i=e.getFirstSpacer(),n=e.getLastSpacer();if((e.hasExternalInput||e.hasStatement)&&(e.widthWithConnectedBlocks+=t),e.align===Zs.Xn.LEFT&&n)n.width+=t;else if(e.align===Zs.Xn.CENTRE&&i&&n)i.width+=t/2,n.width+=t/2;else if(e.align===Zs.Xn.RIGHT&&i)i.width+=t;else{if(!n)return;n.width+=t}e.width+=t}alignStatementRow_(e){var t=e.getLastInput();if(t){var i=e.width-t.width,n=this.statementEdge;(i=n-i)>0&&this.addAlignmentPadding_(e,i),i=e.width,n=this.getDesiredRowWidth_(e),t.width+=n-i,t.height=Math.max(t.height,e.height),e.width+=n-i,e.widthWithConnectedBlocks=Math.max(e.width,this.statementEdge+e.connectedBlockWidths)}}addRowSpacing_(){var e=this.rows;this.rows=[];for(let t=0;t<e.length;t++)this.rows.push(e[t]),t!==e.length-1&&this.rows.push(this.makeSpacerRow_(e[t],e[t+1]))}makeSpacerRow_(e,t){var i=this.getSpacerRowHeight_(e,t),n=this.getSpacerRowWidth_(e,t);return i=new Vp(this.constants_,i,n),e.hasStatement&&(i.followsStatement=!0),t.hasStatement&&(i.precedesStatement=!0),i}getSpacerRowWidth_(){return this.width-this.startX}getSpacerRowHeight_(){return this.constants_.MEDIUM_PADDING}getElemCenterline_(e,t){return vp.isSpacer(t)?e.yPos+t.height/2:vp.isBottomRow(e)?(e=e.yPos+e.height-e.descenderHeight,vp.isNextConnection(t)?e+t.height/2:e-t.height/2):vp.isTopRow(e)?vp.isHat(t)?e.capline-t.height/2:e.capline+t.height/2:e.yPos+e.height/2}recordElemPositions_(e){var t=e.xPos;for(let i,n=0;i=e.elements[n];n++)vp.isSpacer(i)&&(i.height=e.height),i.xPos=t,i.centerline=this.getElemCenterline_(e,i),t+=i.width}finalize_(){var e=0,t=0;for(let i,n=0;i=this.rows[n];n++)i.yPos=t,i.xPos=this.startX,t+=i.height,e=Math.max(e,i.widthWithConnectedBlocks),this.recordElemPositions_(i);if(this.outputConnection&&this.block_.nextConnection){let t=this.block_.nextConnection.targetBlock();t&&(e=Math.max(e,t.getHeightWidth().width))}this.widthWithChildren=e+this.startX,this.height=t,this.startY=this.topRow.capline,this.bottomRow.baseline=t-this.bottomRow.descenderHeight}getMeasureableForConnection(e){var t;if((null==(t=this.outputConnection)?void 0:t.connectionModel)===e)return this.outputConnection;for(let t of this.rows)for(let i of t.elements)if(i instanceof Ap&&i.connectionModel===e)return i;return null}},Xp=class{constructor(e,t,i){this.connectionHighlights=new WeakMap,this.highlightOffsets=new WeakMap,this.constants=i,this.style=t,this.svgRoot=e,this.svgPath=I(ea.PATH,{class:"blocklyPath"},this.svgRoot),this.setClass_("blocklyBlock",!0)}setPath(e){this.svgPath.setAttribute("d",e)}flipRTL(){this.svgPath.setAttribute("transform","scale(-1 1)")}applyColour(e){this.svgPath.setAttribute("stroke",this.style.colourTertiary),this.svgPath.setAttribute("fill",this.style.colourPrimary),this.updateShadow_(e.isShadow()),this.updateDisabled_(!e.isEnabled()||e.getInheritedDisabled())}setStyle(e){this.style=e}setClass_(e,t){e&&(t?N(this.svgRoot,e):A(this.svgRoot,e))}updateHighlighted(e){e?this.setClass_("blocklyHighlighted",!0):this.setClass_("blocklyHighlighted",!1)}updateShadow_(e){e?(this.setClass_("blocklyShadow",!0),this.svgPath.setAttribute("stroke","none"),this.svgPath.setAttribute("fill",this.style.colourSecondary)):this.setClass_("blocklyShadow",!1)}updateDisabled_(e){this.setClass_("blocklyDisabled",e),this.setClass_("blocklyDisabledPattern",e)}updateSelected(e){this.setClass_("blocklySelected",e)}updateDraggingDelete(e){this.setClass_("blocklyDraggingDelete",e)}updateInsertionMarker(e){this.setClass_("blocklyInsertionMarker",e)}updateMovable(e){this.setClass_("blocklyDraggable",e)}updateReplacing(e){this.setClass_("blocklyReplaceable",e)}addConnectionHighlight(e,t,i,n){return i=`translate(${i.x}, ${i.y})`+(n?" scale(-1 1)":""),(n=this.connectionHighlights.get(e))?(n.setAttribute("d",t),n.setAttribute("transform",i),n):(t=I(ea.PATH,{id:e.id,class:"blocklyHighlightedConnectionPath",d:t,transform:i},this.svgRoot),this.connectionHighlights.set(e,t),t)}removeConnectionHighlight(e){var t=this.connectionHighlights.get(e);t&&(S(t),this.connectionHighlights.delete(e))}},Yp=class{constructor(e){this.overrides=null,this.name=e}getClassName(){return this.name+"-renderer"}init(e,t){this.constants_=this.makeConstants_(),t&&(this.overrides=t,Object.assign(this.constants_,t)),this.constants_.setTheme(e),this.constants_.init()}createDom(e,t,i){this.constants_.createDom(e,"."+this.getClassName()+"."+t.getClassName(),i)}refreshDom(e,t,i){var n=this.getConstants();n.dispose(),this.constants_=this.makeConstants_(),this.overrides&&Object.assign(this.constants_,this.overrides),this.constants_.randomIdentifier=n.randomIdentifier,this.constants_.setTheme(t),this.constants_.init(),this.createDom(e,t,i)}dispose(){this.constants_&&this.constants_.dispose()}makeConstants_(){return new $p}makeRenderInfo_(e){return new zp(this,e)}makeDrawer_(e,t){return new jp(e,t)}makePathObject(e,t){return new Xp(e,t,this.constants_)}getConstants(){return this.constants_}shouldHighlightConnection(e){return!e.getSourceBlock().isDragging()}orphanCanConnectAtEnd(e,t,i){return!!Hc.getConnectionForOrphanedConnection(e,i===Xl.OUTPUT_VALUE?t.outputConnection:t.previousConnection)}render(e){var t=this.makeRenderInfo_(e);t.measure(),this.makeDrawer_(e,t).draw()}},Kp={};Kp.BottomRow=yp,Kp.Connection=Ap,Kp.ConstantProvider=$p,Kp.Drawer=jp,Kp.ExternalValueInput=Sp,Kp.Field=Op,Kp.Hat=Rp,Kp.Icon=wp,Kp.InRowSpacer=Lp,Kp.InlineInput=Dp,Kp.InputConnection=kp,Kp.InputRow=xp,Kp.JaggedEdge=Fp,Kp.Measurable=Ip,Kp.NextConnection=Mp,Kp.OutputConnection=Pp,Kp.PathObject=Xp,Kp.PreviousConnection=Bp,Kp.RenderInfo=zp,Kp.Renderer=Yp,Kp.RoundCorner=Up,Kp.Row=Np,Kp.SpacerRow=Vp,Kp.SquareCorner=Hp,Kp.StatementInput=Gp,Kp.TopRow=Wp,Kp.Types=vp,Kp.init=fs,Kp.register=_s,Kp.unregister=function(e){ie(ya.RENDERER,e)};var Jp=class{constructor(e,t){this.workspace=e,this.theme=t,this.subscribedWorkspaces=[],this.componentDB=new Map}getTheme(){return this.theme}setTheme(e){var t=this.theme;this.theme=e,(e=this.workspace.getInjectionDiv())&&(t&&(t=t.getClassName())&&A(e,t),(t=this.theme.getClassName())&&N(e,t));for(let e,t=0;e=this.subscribedWorkspaces[t];t++)e.refreshTheme();for(let[i,n]of this.componentDB)for(let o of n){e=o.element,t=o.propertyName;let n=this.theme&&this.theme.getComponentStyle(i);e.style.setProperty(t,n||"")}for(let e of this.subscribedWorkspaces)e.hideChaff()}subscribeWorkspace(e){this.subscribedWorkspaces.push(e)}unsubscribeWorkspace(e){if(!p(this.subscribedWorkspaces,e))throw Error("Cannot unsubscribe a workspace that hasn't been subscribed.")}subscribe(e,t,i){this.componentDB.has(t)||this.componentDB.set(t,[]),this.componentDB.get(t).push({element:e,propertyName:i}),t=this.theme&&this.theme.getComponentStyle(t),e.style.setProperty(i,t||"")}unsubscribe(e){if(e)for(let[t,i]of this.componentDB){for(let t=i.length-1;t>=0;t--)i[t].element===e&&i.splice(t,1);i.length||this.componentDB.delete(t)}}dispose(){this.subscribedWorkspaces.length=0,this.componentDB.clear()}},Qp={CATEGORY_NAME:"VARIABLE_DYNAMIC"};Qp.flyoutCategory=vs,Qp.flyoutCategoryBlocks=function(e){var t=[];if((e=e.getVariableMap().getAllVariables()).length>0){if(Ur.variables_set_dynamic){var i=e[e.length-1];let n=Zs.sc("block");n.setAttribute("type","variables_set_dynamic"),n.setAttribute("gap","24"),n.appendChild(Ot(i)),t.push(n)}if(Ur.variables_get_dynamic){e.sort(wt);for(let n,o=0;n=e[o];o++)(i=Zs.sc("block")).setAttribute("type","variables_get_dynamic"),i.setAttribute("gap","8"),i.appendChild(Ot(n)),t.push(i)}}return t},Qp.onCreateVariableButtonClick_Colour=Cs,Qp.onCreateVariableButtonClick_Number=bs,Qp.onCreateVariableButtonClick_String=ms;var Zp=class{get isFlyout(){return this.internalIsFlyout}get isMutator(){return this.internalIsMutator}constructor(e){this.isClearing=this.internalIsMutator=this.internalIsFlyout=this.rendered=!1,this.MAX_UNDO=1024,this.connectionDBList=[],this.topBlocks=[],this.topComments=[],this.commentDB=new Map,this.listeners=[],this.undoStack_=[],this.redoStack_=[],this.blockDB=new Map,this.typedBlocksDB=new Map,this.procedureMap=new bp,this.readOnly=!1,this.potentialVariableMap=null,this.id=he(),G(this),this.options=e||new Oc({}),this.RTL=!!this.options.RTL,this.horizontalLayout=!!this.options.horizontalLayout,this.toolboxPosition=this.options.toolboxPosition,this.connectionChecker=new(ae(ya.CONNECTION_CHECKER,this.options,!0))(this),this.variableMap=new(this.getVariableMapClass())(this),this.setIsReadOnly(this.options.readOnly)}dispose(){this.listeners.length=0,this.clear(),W(this)}sortObjects(e,t){var i=e=>({getBoundingRectangle:()=>{var t=e.getRelativeToSurfaceXY();return new xa(t.y,t.y,t.x,t.x)},moveBy:()=>{}});return this.sortByOrigin(i(e),i(t))}sortByOrigin(e,t){var i=Math.sin(ri(Zp.SCAN_ANGLE))*(this.RTL?-1:1);return e=e.getBoundingRectangle().getOrigin(),t=t.getBoundingRectangle().getOrigin(),e.y+i*e.x-(t.y+i*t.x)}addTopBlock(e){this.topBlocks.push(e)}removeTopBlock(e){if(!p(this.topBlocks,e))throw Error("Block not present in workspace's list of top-most blocks.")}getTopBlocks(e=!1){var t=[].concat(this.topBlocks);return e&&t.length>1&&t.sort(this.sortObjects.bind(this)),t}addTypedBlock(e){this.typedBlocksDB.has(e.type)||this.typedBlocksDB.set(e.type,[]),this.typedBlocksDB.get(e.type).push(e)}removeTypedBlock(e){p(this.typedBlocksDB.get(e.type),e),this.typedBlocksDB.get(e.type).length||this.typedBlocksDB.delete(e.type)}getBlocksByType(e,t=!1){return this.typedBlocksDB.has(e)?(e=this.typedBlocksDB.get(e).slice(0),t&&e&&e.length>1&&e.sort(this.sortObjects.bind(this)),e.filter((e=>!e.isInsertionMarker()))):[]}addTopComment(e){this.topComments.push(e),this.commentDB.has(e.id)&&console.warn('Overriding an existing comment on this workspace, with id "'+e.id+'"'),this.commentDB.set(e.id,e)}removeTopComment(e){if(!p(this.topComments,e))throw Error("Comment not present in workspace's list of top-most comments.");this.commentDB.delete(e.id)}getTopComments(e=!1){var t=[].concat(this.topComments);return e&&t.length>1&&t.sort(this.sortObjects.bind(this)),t}getAllBlocks(e=!1){if(e){var t=this.getTopBlocks(!0);e=[];for(let i=0;i<t.length;i++)e.push(...t[i].getDescendants(!0))}else for(e=this.getTopBlocks(!1),t=0;t<e.length;t++)e.push(...e[t].getChildren(!1));return e.filter((e=>!e.isInsertionMarker()))}clear(){this.isClearing=!0;try{let e=Zs.gd;for(e||Zs.B(!0);this.topBlocks.length;)this.topBlocks[0].dispose(!1);for(;this.topComments.length;)this.topComments[this.topComments.length-1].dispose();Zs.B(e),this.isFlyout||this.variableMap.clear(),this.potentialVariableMap&&this.potentialVariableMap.clear()}finally{this.isClearing=!1}}getWidth(){return 0}newBlock(){throw Error("The implementation of newBlock should be monkey-patched in by blockly.ts")}newComment(){throw Error("The implementation of newComment should be monkey-patched in by blockly.ts")}remainingCapacity(){return isNaN(this.options.maxBlocks)?1/0:this.options.maxBlocks-this.getAllBlocks(!1).length}remainingCapacityOfType(e){return this.options.maxInstances?(void 0!==this.options.maxInstances[e]?this.options.maxInstances[e]:1/0)-this.getBlocksByType(e,!1).length:1/0}isCapacityAvailable(e){if(!this.hasBlockLimits())return!0;var t=0;for(let i in e){if(e[i]>this.remainingCapacityOfType(i))return!1;t+=e[i]}return!(t>this.remainingCapacity())}hasBlockLimits(){return this.options.maxBlocks!==1/0||!!this.options.maxInstances}getUndoStack(){return this.undoStack_}getRedoStack(){return this.redoStack_}undo(e=!1){var t=e?this.redoStack_:this.undoStack_,i=e?this.undoStack_:this.redoStack_,n=t.pop();if(n){for(var o=[n];t.length&&n.group&&n.group===t[t.length-1].group;){let e=t.pop();e&&o.push(e)}for(t=0;t<o.length;t++)i.push(o[t]);Zs.Qc=!1;try{for(i=0;i<o.length;i++)o[i].run(e)}finally{Zs.Qc=!0}}}redo(){this.undo(!0)}clearUndo(){this.undoStack_.length=0,this.redoStack_.length=0,ge()}addChangeListener(e){return this.listeners.push(e),e}removeChangeListener(e){p(this.listeners,e)}fireChangeListener(e){if(e.recordUndo)for(this.undoStack_.push(e),this.redoStack_.length=0;this.undoStack_.length>this.MAX_UNDO&&this.MAX_UNDO>=0;)this.undoStack_.shift();for(let t=0;t<this.listeners.length;t++)(0,this.listeners[t])(e)}getBlockById(e){return this.blockDB.get(e)||null}setBlockById(e,t){this.blockDB.set(e,t)}removeBlockById(e){this.blockDB.delete(e)}getCommentById(e){var t;return null!=(t=this.commentDB.get(e))?t:null}allInputsFilled(e){var t=this.getTopBlocks(!1);for(let i=0;i<t.length;i++)if(!t[i].allInputsFilled(e))return!1;return!0}getPotentialVariableMap(){return this.potentialVariableMap}createPotentialVariableMap(){this.potentialVariableMap=new(this.getVariableMapClass())(this,!0)}getVariableMap(){return this.variableMap}setVariableMap(e){this.variableMap=e}getProcedureMap(){return this.procedureMap}getRootWorkspace(){var e=null,t=this.options.parentWorkspace;return this.isFlyout?t&&t.options&&(e=t.options.parentWorkspace):t&&(e=t),e}static getById(e){return V(e)}static getAll(){return H()}getVariableMapClass(){var e=ae(ya.VARIABLE_MAP,this.options,!0);if(!e)throw Error("No variable map is registered.");return e}isReadOnly(){return this.readOnly}setIsReadOnly(e){this.readOnly=e,this.options.readOnly=e}};Zp.SCAN_ANGLE=3;var eg=class{constructor(e){this.parentWorkspace=e,this.sounds=new Map,this.lastSound=null,this.muted=!1,window.AudioContext&&(this.context=new AudioContext)}dispose(){var e;this.sounds.clear(),null==(e=this.context)||e.close()}load(e,t){var i=this;return(0,Qs.asyncExecutePromiseGeneratorFunction)((function*(){if(e.length){var n,o=yield(yield fetch(e[0])).arrayBuffer();null==(n=i.context)||n.decodeAudioData(o,(e=>{i.sounds.set(t,e)}))}}))}play(e,t){var i=this;return(0,Qs.asyncExecutePromiseGeneratorFunction)((function*(){if(i.isPlayingAllowed()&&0!==t){var n=i.sounds.get(e);if(n){if(yield i.prepareToPlay(),"running"===i.context.state){var o=i.context.createBufferSource(),s=i.context.createGain();s.gain.value=null!=t?t:1,s.connect(i.context.destination),o.buffer=n,o.connect(s),o.addEventListener("ended",(()=>{o.disconnect(),s.disconnect()})),o.start()}}else i.parentWorkspace&&(n=i.parentWorkspace.getAudioManager())!==i&&n.play(e,t)}}))}beep(e,t=.2){var i=this;return(0,Qs.asyncExecutePromiseGeneratorFunction)((function*(){if(i.isPlayingAllowed()&&(yield i.prepareToPlay(),"running"===i.context.state)){var n=i.context.createOscillator();n.type="sine",n.frequency.setValueAtTime(e,i.context.currentTime);var o=i.context.createGain();o.gain.setValueAtTime(0,i.context.currentTime),o.gain.linearRampToValueAtTime(.5,i.context.currentTime+.01),o.gain.linearRampToValueAtTime(0,i.context.currentTime+t),n.connect(o),o.connect(i.context.destination),n.start(i.context.currentTime),n.stop(i.context.currentTime+t)}}))}playErrorBeep(){var e=this;return(0,Qs.asyncExecutePromiseGeneratorFunction)((function*(){return e.beep(260)}))}maybePlayScopeChangeAudioCue(e){if(Xh.getScopeChangeAudioCuesEnabled()){var t=this.parentWorkspace.getNavigator(),i=t.getSourceBlockFromNode(Zs.t().getFocusedNode());e=t.getSourceBlockFromNode(e),t=0,i&&e&&i.getNestingLevel()!==(t=e.getNestingLevel())&&this.beep(400+60*t)}}isPlayingAllowed(){var e=new Date;return!(this.getMuted()||!this.context||null!==this.lastSound&&e.getTime()-this.lastSound.getTime()<100)}prepareToPlay(){var e=this;return(0,Qs.asyncExecutePromiseGeneratorFunction)((function*(){e.lastSound=new Date,"suspended"===e.context.state&&navigator.userActivation.hasBeenActive&&(yield e.context.resume())}))}setMuted(e){this.muted=e}getMuted(){return this.muted}},tg=class{constructor(e,t){this.workspace=e,this.element=t}getFocusableElement(){return this.element}getFocusableTree(){return this.workspace}onNodeFocus(){this.workspace.handleWorkspaceFocusTargetFocus()}onNodeBlur(){}canBeFocused(){return!0}getWorkspace(){return this.workspace}showContextMenu(e){this.workspace.showContextMenu(e)}},ig=class extends Zp{constructor(e){var t,i;super(e),this.resizeHandlerWrapper=null,this.resizesEnabled=this.visible=this.rendered=!0,this.startScrollY=this.startScrollX=this.scrollY=this.scrollX=0,this.oldScale=this.scale=1,this.oldLeft=this.oldTop=0,this.inverseScreenCTM=this.targetWorkspace=this.dummyWheelListener=this.configureContextMenu=this.lastRecordedPageScroll=this.injectionDiv=this.currentGesture_=this.toolbox=this.flyout=this.scrollbar=this.trashcan=null,this.inverseScreenCTMDirty=!0,this.highlightedBlocks=[],this.toolboxCategoryCallbacks=new Map,this.flyoutButtonCallbacks=new Map,this.cachedParentSvg=null,this.topBoundedElements=[],this.dragTargetAreas=[],this.workspaceFocusTarget=this.workspaceFocusTargetElement=this.workspaceSelectionRing=this.workspaceFocusRing=this.zoomControls_=this.layerManager=null,this.navigator=new op,this.metricsManager=new(ae(ya.METRICS_MANAGER,e,!0))(this),this.getMetrics=e.getMetrics||this.metricsManager.getMetrics.bind(this.metricsManager),this.setMetrics=e.setMetrics||ig.setTopLevelWorkspaceMetrics,this.componentManager=new Sr,this.connectionDBList=Vc.init(this.connectionChecker),this.audioManager=new eg(null!=(t=e.parentWorkspace)?t:this),this.grid=this.options.gridPattern?new pp(this.options.gridPattern,e.gridOptions):null,Jh&&_t&&this.registerToolboxCategoryCallback("VARIABLE",_t),Qp&&vs&&this.registerToolboxCategoryCallback("VARIABLE_DYNAMIC",vs),Cp&&ds&&(this.registerToolboxCategoryCallback("PROCEDURE",ds),this.addChangeListener(gs)),this.addChangeListener(this.variableChangeCallback.bind(this)),this.themeManager_=this.options.parentWorkspace?this.options.parentWorkspace.getThemeManager():new Jp(this,this.options.theme||Sc),this.themeManager_.subscribeWorkspace(this),this.renderer=fs(this.options.renderer||"geras",this.getTheme(),null!=(i=this.options.rendererOverrides)?i:void 0),this.cachedParentSvgSize=new Fa(0,0)}getMetricsManager(){return this.metricsManager}setMetricsManager(e){this.metricsManager=e,this.getMetrics=this.metricsManager.getMetrics.bind(this.metricsManager)}getComponentManager(){return this.componentManager}getRenderer(){return this.renderer}getThemeManager(){return this.themeManager_}getTheme(){return this.themeManager_.getTheme()}setTheme(e){e||(e=Sc),this.themeManager_.setTheme(e)}refreshTheme(){if(this.svgGroup_){var e=null===this.options.parentWorkspace;this.renderer.refreshDom(this.svgGroup_,this.getTheme(),e?this.getInjectionDiv():void 0)}this.updateBlockStyles(this.getAllBlocks(!1).filter((e=>!!e.getStyleName()))),this.refreshToolboxSelection(),this.toolbox&&this.toolbox.refreshTheme(),this.isVisible()&&this.setVisible(!0),e=new(_e(Fr.THEME_CHANGE))(this.getTheme().name,this.id),ue(e)}updateBlockStyles(e){for(let t,i=0;t=e[i];i++){let e=t.getStyleName();e&&t.setStyle(e)}}getInverseScreenCTM(){if(this.inverseScreenCTMDirty){let e=this.getParentSvg().getScreenCTM();e&&(this.inverseScreenCTM=e.inverse(),this.inverseScreenCTMDirty=!1)}return this.inverseScreenCTM}updateInverseScreenCTM(){this.inverseScreenCTMDirty=!0}isVisible(){return this.visible}getSvgXY(e){var t=0,i=0,n=1;(this.getCanvas().contains(e)||this.getBubbleCanvas().contains(e))&&(n=this.scale);do{let o=ke(e);e!==this.getCanvas()&&e!==this.getBubbleCanvas()||(n=1),t+=o.x*n,i+=o.y*n,e=e.parentNode}while(e&&e!==this.getParentSvg()&&e!==this.getInjectionDiv());return new Da(t,i)}getCachedParentSvgSize(){var e=this.cachedParentSvgSize;return new Fa(e.width,e.height)}getOriginOffsetInPixels(){return Se(this.getCanvas())}getInjectionDiv(){if(!this.injectionDiv){let e=this.svgGroup_;for(;e;){if((" "+(e.getAttribute("class")||"")+" ").includes(" injectionDiv ")){this.injectionDiv=e;break}e=e.parentNode}}return this.injectionDiv}getSvgGroup(){return this.svgGroup_}getBlockCanvas(){return this.getCanvas()}setResizeHandlerWrapper(e){this.resizeHandlerWrapper=e}setInitialAriaContext(){if(!this.svgGroup_)throw Error("Must initialize svgGroup_ by calling `createDom` before calling setAriaContext");this.isFlyout||(_(this.svgGroup_,Hr.REGION),this.isMutator?f(this.svgGroup_,$r.LABEL,Zs.C.WORKSPACE_LABEL_MUTATOR_WORKSPACE):(f(this.svgGroup_,$r.LABEL,Zs.C.WORKSPACE_LABEL_PLAIN),this.workspaceFocusTargetElement&&(_(this.workspaceFocusTargetElement,Hr.FIGURE),f(this.workspaceFocusTargetElement,$r.ROLEDESCRIPTION,Zs.C.WORKSPACE_ROLEDESCRIPTION),this.updateAriaLabel())))}updateAriaLabel(){if(this.workspaceFocusTargetElement){var e=this.getTopBlocks(!1).length;f(this.workspaceFocusTargetElement,$r.LABEL,1==e?Zs.C.WORKSPACE_LABEL_1_STACK:Zs.C.WORKSPACE_LABEL_MANY_STACKS.replace("%1",String(e)))}}createDom(e,t){return this.injectionDiv||(this.injectionDiv=null!=t?t:null),this.svgGroup_=I(ea.G,{class:"blocklyWorkspace",id:this.id}),e&&(this.svgBackground_=I(ea.RECT,{height:"100%",width:"100%",class:e},this.svgGroup_),"blocklyMainBackground"===e&&this.grid?this.svgBackground_.style.fill="var(--blocklyGridPattern)":this.themeManager_.subscribe(this.svgBackground_,"workspaceBackgroundColour","fill")),this.workspaceSelectionRing=e=I(ea.RECT,{fill:"none",class:"blocklyWorkspaceSelectionRing"},this.svgGroup_),this.workspaceFocusRing=I(ea.RECT,{fill:"none",class:"blocklyWorkspaceFocusRing"},this.svgGroup_),this.isFlyout||this.isMutator||(e.id=`${this.id}_focusTarget`,this.workspaceFocusTargetElement=e,this.workspaceFocusTarget=new tg(this,e)),this.layerManager=new gp(this),this.svgBlockCanvas_=this.layerManager.getBlockLayer(),this.svgBubbleCanvas_=this.layerManager.getBubbleLayer(),this.setInitialAriaContext(),this.isFlyout||(r(this.svgGroup_,"pointerdown",this,this.onMouseDown,!1),this.dummyWheelListener=()=>{},document.body.addEventListener("wheel",this.dummyWheelListener,{passive:!0}),r(this.svgGroup_,"wheel",this,this.onMouseWheel,!1,{passive:!1})),this.options.hasCategories&&(this.toolbox=new(ae(ya.TOOLBOX,this.options,!0))(this)),this.grid&&this.grid.update(this.scale),this.recordDragTargets(),e=null===this.options.parentWorkspace,this.renderer.createDom(this.svgGroup_,this.getTheme(),e?this.getInjectionDiv():void 0),Zs.t().registerTree(this,!!this.injectionDiv||this.isFlyout),this.svgGroup_}dispose(){if(this.rendered=!1,this.currentGesture_&&this.currentGesture_.cancel(),this.svgGroup_&&S(this.svgGroup_),this.toolbox&&(this.toolbox.dispose(),this.toolbox=null),this.flyout&&(this.flyout.dispose(),this.flyout=null),this.trashcan&&(this.trashcan.dispose(),this.trashcan=null),this.scrollbar&&(this.scrollbar.dispose(),this.scrollbar=null),this.zoomControls_&&this.zoomControls_.dispose(),this.audioManager&&this.audioManager.dispose(),this.grid&&(this.grid=null),this.renderer.dispose(),super.dispose(),this.themeManager_&&(this.themeManager_.unsubscribeWorkspace(this),this.themeManager_.unsubscribe(this.svgBackground_),this.options.parentWorkspace||this.themeManager_.dispose()),this.connectionDBList.length=0,this.toolboxCategoryCallbacks.clear(),this.flyoutButtonCallbacks.clear(),!this.options.parentWorkspace){let e=this.getParentSvg();e&&e.parentNode&&S(e.parentNode)}var e,t;this.resizeHandlerWrapper&&(l(this.resizeHandlerWrapper),this.resizeHandlerWrapper=null),this.dummyWheelListener&&(document.body.removeEventListener("wheel",this.dummyWheelListener),this.dummyWheelListener=null),null==(e=this.workspaceFocusRing)||e.remove(),null==(t=this.workspaceSelectionRing)||t.remove(),Zs.t().isRegistered(this)&&Zs.t().unregisterTree(this)}addTrashcan(){this.trashcan=ig.newTrashcan(this);var e=this.trashcan.createDom();this.svgGroup_.appendChild(e)}static newTrashcan(){throw Error("The implementation of newTrashcan should be monkey-patched in by blockly.ts")}addZoomControls(){this.zoomControls_=new dl(this);var e=this.zoomControls_.createDom();this.svgGroup_.appendChild(e)}copyOptionsForFlyout(){return new Oc({parentWorkspace:this,rtl:this.RTL,oneBasedIndex:this.options.oneBasedIndex,horizontalLayout:this.horizontalLayout,renderer:this.options.renderer,rendererOverrides:this.options.rendererOverrides,plugins:this.options.plugins,modalInputs:this.options.modalInputs,move:{scrollbars:!0}})}addFlyout(e){var t=this.copyOptionsForFlyout();return t.toolboxPosition=this.options.toolboxPosition,this.flyout=this.horizontalLayout?new(ae(ya.FLYOUTS_HORIZONTAL_TOOLBOX,this.options,!0))(t):new(ae(ya.FLYOUTS_VERTICAL_TOOLBOX,this.options,!0))(t),this.flyout.autoClose=!1,this.flyout.getWorkspace().setVisible(!0),this.flyout.createDom(e)}getFlyout(e){return this.flyout||e?this.flyout:this.toolbox?this.toolbox.getFlyout():null}getToolbox(){return this.toolbox}updateScreenCalculations(){this.updateInverseScreenCTM(),this.recordDragTargets()}resizeContents(){this.resizesEnabled&&this.rendered&&(this.scrollbar&&this.scrollbar.resize(),this.updateInverseScreenCTM())}resize(){this.toolbox?this.toolbox.position():this.flyout&&this.flyout.position();var e=this.componentManager.getComponents(Sr.Capability.POSITIONABLE,!0),t=this.getMetricsManager().getUiMetrics(),i=[];for(let n,o=0;n=e[o];o++){n.position(t,i);let e=n.getBoundingRectangle();e&&i.push(e)}this.scrollbar&&this.scrollbar.resize(),this.updateScreenCalculations(),this.workspaceFocusRing&&this.workspaceSelectionRing&&(this.resizeWorkspaceRing(this.workspaceSelectionRing,5),this.resizeWorkspaceRing(this.workspaceFocusRing,0))}resizeWorkspaceRing(e,t){var i=this.getMetrics();e.setAttribute("x",`${i.absoluteLeft+t}`),e.setAttribute("y",`${i.absoluteTop+t}`),e.setAttribute("width",`${Math.max(0,i.viewWidth-2*t)}`),e.setAttribute("height",`${Math.max(0,i.svgHeight-2*t)}`)}updateScreenCalculationsIfScrolled(){var e=Re();Da.equals(this.lastRecordedPageScroll,e)||(this.lastRecordedPageScroll=e,this.updateScreenCalculations())}getLayerManager(){return this.layerManager}getCanvas(){return this.layerManager.getBlockLayer()}setCachedParentSvgSize(e,t){var i=this.getParentSvg();null!=e&&(this.cachedParentSvgSize.width=e,i.setAttribute("data-cached-width",`${e}`)),null!=t&&(this.cachedParentSvgSize.height=t,i.setAttribute("data-cached-height",`${t}`))}getBubbleCanvas(){return this.layerManager.getBubbleLayer()}getParentSvg(){if(!this.cachedParentSvg){let e=this.svgGroup_;for(;e;){if("svg"===e.tagName){this.cachedParentSvg=e;break}e=e.parentNode}}return this.cachedParentSvg}maybeFireViewportChangeEvent(){if(Ee()){var e=this.scale,t=-this.scrollY,i=-this.scrollX;if(!(e===this.oldScale&&Math.abs(t-this.oldTop)<1&&Math.abs(i-this.oldLeft)<1)){var n=new(_e(Fr.VIEWPORT_CHANGE))(t,i,e,this.id,this.oldScale);this.oldScale=e,this.oldTop=t,this.oldLeft=i,ue(n)}}}translate(e,t){var i,n;null==(i=this.layerManager)||i.translateLayers(new Da(e,t),this.scale),null==(n=this.grid)||n.moveTo(e,t),this.maybeFireViewportChangeEvent()}getWidth(){var e=this.getMetrics();return e?e.viewWidth/this.scale:0}setVisible(e){this.visible=e,this.svgGroup_&&(this.scrollbar&&this.scrollbar.setContainerVisible(e),this.getFlyout()&&this.getFlyout().setContainerVisible(e),this.getParentSvg().style.display=e?"block":"none",this.toolbox&&this.toolbox.setVisible(e),e||this.hideChaff(!0))}render(){var e=this.getAllBlocks(!1);for(let t=e.length-1;t>=0;t--)e[t].queueRender();this.getTopBlocks().flatMap((e=>e.getDescendants(!1))).filter((e=>e.isInsertionMarker())).forEach((e=>e.queueRender()))}highlightBlock(e,t){if(void 0===t){for(let e,t=0;e=this.highlightedBlocks[t];t++)e.setHighlighted(!1);this.highlightedBlocks.length=0}(e=e?this.getBlockById(e):null)&&((t=void 0===t||t)?this.highlightedBlocks.includes(e)||this.highlightedBlocks.push(e):p(this.highlightedBlocks,e),e.setHighlighted(t))}variableChangeCallback(e){switch(e.type){case Fr.VAR_CREATE:case Fr.VAR_DELETE:case Fr.VAR_RENAME:case Fr.VAR_TYPE_CHANGE:this.refreshToolboxSelection()}}refreshToolboxSelection(){var e=this.isFlyout?this.targetWorkspace:this;e&&!e.currentGesture_&&e.toolbox&&e.toolbox.getFlyout()&&e.toolbox.refreshSelection()}recordDragTargets(){var e=this.componentManager.getComponents(Sr.Capability.DRAG_TARGET,!0);this.dragTargetAreas=[];for(let t,i=0;t=e[i];i++){let e=t.getClientRect();e&&this.dragTargetAreas.push({component:t,clientRect:e})}}newBlock(){throw Error("The implementation of newBlock should be monkey-patched in by blockly.ts")}newComment(){throw Error("The implementation of newComment should be monkey-patched in by blockly.ts")}getDragTarget(e){e=e instanceof Da?e:new Da(e.clientX,e.clientY);for(let t,i=0;t=this.dragTargetAreas[i];i++)if(t.clientRect.contains(e.x,e.y))return t.component;return null}onMouseDown(e){var t=this.getGesture(e);t&&t.handleWsStart(e,this)}startDrag(e,t){_n(this,e,t)}moveDrag(e){return fn(this,e)}isDragging(){return yc.mover.isMoving()||null!==this.currentGesture_&&this.currentGesture_.isDragging()}isDraggable(){return this.options.moveOptions&&this.options.moveOptions.drag}isMovable(){return this.options.moveOptions&&!!this.options.moveOptions.scrollbars||this.options.moveOptions&&this.options.moveOptions.wheel||this.options.moveOptions&&this.options.moveOptions.drag||this.options.zoomOptions&&this.options.zoomOptions.wheel||this.options.zoomOptions&&this.options.zoomOptions.pinch}isMovableHorizontally(){var e=!!this.scrollbar;return this.isMovable()&&(!e||e&&this.scrollbar.canScrollHorizontally())}isMovableVertically(){var e=!!this.scrollbar;return this.isMovable()&&(!e||e&&this.scrollbar.canScrollVertically())}onMouseWheel(e){if(dp.inProgress())e.preventDefault(),e.stopPropagation();else{var t=this.options.zoomOptions&&this.options.zoomOptions.wheel,i=this.options.moveOptions&&this.options.moveOptions.wheel;if(t||i){var n=d(e);if(Cr)var o=e.metaKey;t&&(e.ctrlKey||o||!i)?(n=-n.y/50,t=c(e,this.getParentSvg(),this.getInverseScreenCTM()),this.zoom(t.x,t.y,n)):(t=this.scrollX-n.x,i=this.scrollY-n.y,e.shiftKey&&!n.x&&(t=this.scrollX-n.y,i=this.scrollY),this.scroll(t,i)),e.preventDefault()}}}getBlocksBoundingBox(){var e=this.getTopBoundedElements();if(!e.length)return new xa(0,0,0,0);var t=e[0].getBoundingRectangle();for(let n=1;n<e.length;n++){var i=e[n];i.isInsertionMarker&&i.isInsertionMarker()||((i=i.getBoundingRectangle()).top<t.top&&(t.top=i.top),i.bottom>t.bottom&&(t.bottom=i.bottom),i.left<t.left&&(t.left=i.left),i.right>t.right&&(t.right=i.right))}return t}cleanUp(){function e(e){for(let t of o)if(e.intersects(t))return t;return null}this.setResizesEnabled(!1);var t=Zs.gd;t||Zs.B(!0);var i=this.getTopBlocks(!0),n=i.filter((e=>e.isMovable())),o=i.filter((e=>!e.isMovable())).map((e=>e.getBoundingRectangle())),s=0;i=this.renderer.getConstants().MIN_BLOCK_HEIGHT;for(let t of n){for(n=t.getBoundingRectangle(),t.moveBy(-n.left,s-n.top,["cleanup"]),t.snapToGrid(),s=e(n=t.getBoundingRectangle());null!=s;)s=s.top+s.getHeight()+i,t.moveBy(0,s-n.top,["cleanup"]),t.snapToGrid(),s=e(n=t.getBoundingRectangle());s=t.getRelativeToSurfaceXY().y+t.getHeightWidth().height+i}Zs.B(t),this.setResizesEnabled(!0)}showContextMenu(e){if(!this.isReadOnly()&&!this.isFlyout){var t=nc.registry.getContextMenuOptions({workspace:this,focusedNode:this},e);if(this.configureContextMenu&&this.configureContextMenu(t,e),e instanceof PointerEvent)var i=new Da(e.clientX,e.clientY);else i=this.getMetricsManager().getViewMetrics(!0),i=Le(this,new Da(this.RTL?i.left+i.width-5:i.left+5,i.top+5));hn(e,t,this.RTL,this,i)}}updateToolbox(e){if(e=Fe(e)){if(!this.options.languageTree)throw Error("Existing toolbox is null. Can't create new toolbox.");if(Pe(e)){if(!this.toolbox)throw Error("Existing toolbox has no categories. Can't change mode.");this.options.languageTree=e,this.toolbox.render(e)}else{if(!this.flyout)throw Error("Existing toolbox has categories. Can't change mode.");this.options.languageTree=e,this.flyout.show(e)}}else if(this.options.languageTree)throw Error("Can't nullify an existing toolbox.")}markFocused(){this.options.parentWorkspace?this.options.parentWorkspace.markFocused():($(this),this.getParentSvg().focus({preventScroll:!0}))}zoom(e,t,i){i=Math.pow(this.options.zoomOptions.scaleSpeed,i);var n=this.scale*i;if(this.scale!==n){n>this.options.zoomOptions.maxScale?i=this.options.zoomOptions.maxScale/this.scale:n<this.options.zoomOptions.minScale&&(i=this.options.zoomOptions.minScale/this.scale);var o=this.getCanvas().getCTM(),s=this.getParentSvg().createSVGPoint();s.x=e,s.y=t,e=(s=s.matrixTransform(o.inverse())).x,t=s.y,o=o.translate(e*(1-i),t*(1-i)).scale(i),this.scrollX=Math.round(o.e),this.scrollY=Math.round(o.f),this.setScale(n)}}zoomCenter(e){var t=this.getMetrics();if(this.flyout){var i=t.svgWidth?t.svgWidth/2:0;t=t.svgHeight?t.svgHeight/2:0}else i=t.viewWidth/2+t.absoluteLeft,t=t.viewHeight/2+t.absoluteTop;this.zoom(i,t,e)}zoomToFit(){if(this.isMovable()){var e=this.getMetrics(),t=e.viewWidth;e=e.viewHeight;var i=this.getBlocksBoundingBox(),n=i.right-i.left+40;if(i=i.bottom-i.top+40,n){this.flyout&&(this.horizontalLayout?(e+=this.flyout.getHeight(),i+=this.flyout.getHeight()/this.scale):(t+=this.flyout.getWidth(),n+=this.flyout.getWidth()/this.scale)),Zs.Ub++;try{this.setScale(Math.min(t/n,e/i)),this.scrollCenter()}finally{Zs.Ub--}this.maybeFireViewportChangeEvent()}}else console.warn("Tried to move a non-movable workspace. This could result in blocks becoming inaccessible.")}beginCanvasTransition(){N(this.getCanvas(),"blocklyCanvasTransitioning"),N(this.getBubbleCanvas(),"blocklyCanvasTransitioning")}endCanvasTransition(){A(this.getCanvas(),"blocklyCanvasTransitioning"),A(this.getBubbleCanvas(),"blocklyCanvasTransitioning")}scrollCenter(){if(this.isMovable()){var e=this.getMetrics(),t=(e.scrollWidth-e.viewWidth)/2,i=(e.scrollHeight-e.viewHeight)/2;t=-t-e.scrollLeft,i=-i-e.scrollTop,this.scroll(t,i)}else console.warn("Tried to move a non-movable workspace. This could result in blocks becoming inaccessible.")}centerOnBlock(e,t){if(this.isMovable()){var i=e?this.getBlockById(e):null;if(i){e=i.getRelativeToSurfaceXY(),i=t?{height:i.height,width:i.width}:i.getHeightWidth();var n=this.scale;t=(e.x+(this.RTL?-1:1)*i.width/2)*n,e=(e.y+i.height/2)*n,i=this.getMetrics(),this.scroll(-(t-i.viewWidth/2),-(e-i.viewHeight/2))}}else console.warn("Tried to move a non-movable workspace. This could result in blocks becoming inaccessible.")}setScale(e){e=Math.round(1e3*e)/1e3,this.options.zoomOptions.maxScale&&e>this.options.zoomOptions.maxScale?e=this.options.zoomOptions.maxScale:this.options.zoomOptions.minScale&&e<this.options.zoomOptions.minScale&&(e=this.options.zoomOptions.minScale),this.scale=e,this.hideChaff(!1),(e=this.getFlyout(!1))&&e.isVisible()&&(e.reflow(),this.recordDragTargets()),this.grid&&this.grid.update(this.scale),e=this.getMetrics(),this.scrollX-=e.absoluteLeft,this.scrollY-=e.absoluteTop,e.viewLeft+=e.absoluteLeft,e.viewTop+=e.absoluteTop,this.scroll(this.scrollX,this.scrollY),this.scrollbar&&(this.flyout?this.scrollbar.resizeView(e):this.scrollbar.resizeContent(e))}getScale(){return this.scale}getAbsoluteScale(){var e=e=>{if(e.isFlyout){let t,i=null==(t=e.targetWorkspace)?void 0:t.getFlyout();if(i instanceof up)return i.getFlyoutScale()}return e.getScale()},t=(i,n)=>i.options.parentWorkspace&&i.options.parentWorkspace.getSvgGroup().contains(i.getSvgGroup())?t(i.options.parentWorkspace,n*e(i)):n*e(i);return t(this,1)}scroll(e,t,i=!0){i&&this.hideChaff(!0),i=this.getMetrics(),e=Math.min(e,-i.scrollLeft),t=Math.min(t,-i.scrollTop);var n=i.scrollTop+Math.max(0,i.scrollHeight-i.viewHeight);e=Math.round(Math.max(e,-(i.scrollLeft+Math.max(0,i.scrollWidth-i.viewWidth)))),t=Math.round(Math.max(t,-n)),this.scrollX=e,this.scrollY=t,this.scrollbar&&this.scrollbar.set(-(e+i.scrollLeft),-(t+i.scrollTop),!1),e+=i.absoluteLeft,t+=i.absoluteTop,this.translate(e,t)}getBlockById(e){return super.getBlockById(e)}getAllBlocks(e=!1){return super.getAllBlocks(e)}getTopBlocks(e=!1){return super.getTopBlocks(e)}addTopBlock(e){this.addTopBoundedElement(e),super.addTopBlock(e)}removeTopBlock(e){this.removeTopBoundedElement(e),super.removeTopBlock(e)}addTopComment(e){this.addTopBoundedElement(e),super.addTopComment(e)}removeTopComment(e){this.removeTopBoundedElement(e),super.removeTopComment(e)}getTopComments(e=!1){return super.getTopComments(e)}getCommentById(e){return super.getCommentById(e)}getRootWorkspace(){return super.getRootWorkspace()}addTopBoundedElement(e){this.topBoundedElements.push(e)}removeTopBoundedElement(e){p(this.topBoundedElements,e)}getTopBoundedElements(e=!1){var t=[].concat(this.topBoundedElements);return e&&t.sort(this.sortByOrigin.bind(this)),t}setResizesEnabled(e){var t=!this.resizesEnabled&&e;this.resizesEnabled=e,t&&this.resizeContents()}clear(){this.setResizesEnabled(!1),super.clear(),this.topBoundedElements=[],this.setResizesEnabled(!0)}registerButtonCallback(e,t){if("function"!=typeof t)throw TypeError("Button callbacks must be functions.");this.flyoutButtonCallbacks.set(e,t)}getButtonCallback(e){var t;return null!=(t=this.flyoutButtonCallbacks.get(e))?t:null}removeButtonCallback(e){this.flyoutButtonCallbacks.delete(e)}registerToolboxCategoryCallback(e,t){if("function"!=typeof t)throw TypeError("Toolbox category callbacks must be functions.");this.toolboxCategoryCallbacks.set(e,t)}getToolboxCategoryCallback(e){return this.toolboxCategoryCallbacks.get(e)||null}removeToolboxCategoryCallback(e){this.toolboxCategoryCallbacks.delete(e)}getGesture(e){if(yc.mover.isMoving())return null==e||e.preventDefault(),null==e||e.stopPropagation(),null;var t,i="pointerdown"===(null==e?void 0:e.type);return i&&null!=(t=this.currentGesture_)&&t.hasStarted()&&(console.warn("Tried to start the same gesture twice."),this.currentGesture_.cancel()),!this.currentGesture_&&i&&(this.currentGesture_=new dp(e,this)),this.currentGesture_}clearGesture(){this.currentGesture_=null}cancelCurrentGesture(){this.currentGesture_&&this.currentGesture_.cancel()}getAudioManager(){return this.audioManager}getGrid(){return this.grid}hideChaff(e=!1){Ui(),sn(this),vi(),this.hideComponents(e)}hideComponents(e=!1){this.getComponentManager().getComponents(Sr.Capability.AUTOHIDEABLE,!0).forEach((t=>t.autoHide(e)))}static setTopLevelWorkspaceMetrics(e){var t=this.getMetrics();"number"==typeof e.x&&(this.scrollX=-(t.scrollLeft+(t.scrollWidth-t.viewWidth)*e.x)),"number"==typeof e.y&&(this.scrollY=-(t.scrollTop+(t.scrollHeight-t.viewHeight)*e.y)),this.translate(this.scrollX+t.absoluteLeft,this.scrollY+t.absoluteTop)}addClass(e){this.injectionDiv&&N(this.injectionDiv,e)}removeClass(e){this.injectionDiv&&A(this.injectionDiv,e)}setIsReadOnly(e){super.setIsReadOnly(e),e?this.addClass("blocklyReadOnly"):this.removeClass("blocklyReadOnly")}scrollBoundsIntoView(e,t=10){if(!dp.inProgress()){var i=this.getScale(),n=this.getMetricsManager().getViewMetrics(!0);if(n=new xa(n.top,n.top+n.height,n.left,n.left+n.width),!(e.left>=n.left&&e.top>=n.top&&e.right<=n.right&&e.bottom<=n.bottom)){(e=e.clone()).top-=t,e.bottom+=t,e.left-=t,e.right+=t;var o=t=0;e.left<n.left?t=this.RTL?Math.min(n.left-e.left,n.right-e.right):n.left-e.left:e.right>n.right&&(t=this.RTL?n.right-e.right:Math.max(n.right-e.right,n.left-e.left)),e.top<n.top?o=n.top-e.top:e.bottom>n.bottom&&(o=Math.max(n.bottom-e.bottom,n.top-e.top)),this.scroll(this.scrollX+t*i,this.scrollY+o*i,!1)}}}getFocusableElement(){return this.svgGroup_}getFocusableTree(){return this}onNodeFocus(){this.maybeAnnounceScreenreaderHint()}handleWorkspaceFocusTargetFocus(){this.updateAriaLabel(),this.maybeAnnounceScreenreaderHint()}maybeAnnounceScreenreaderHint(){ig.everFocused||this.options.parentWorkspace||(v(Zs.C.SCREENREADER_HINT.replace("%1",Vt(pd.TOGGLE_SCREENREADER))),ig.everFocused=!0)}onNodeBlur(){}canBeFocused(){return!0}getRootFocusableNode(){return this}getRestoredFocusableNode(e){if(e)return e;var t;if(e=null==(t=this.targetWorkspace)?void 0:t.getFlyout(),this.isFlyout&&e){let t,i;return null!=(i=null==(t=e.getContents().find((e=>(e=e.getElement(),M(e)&&e.canBeFocused()))))?void 0:t.getElement())?i:null}if(this.isMutator){let e;return null!=(e=this.getTopBlocks(!0)[0])?e:null}return this.workspaceFocusTarget}getWorkspaceFocusTarget(){return this.workspaceFocusTarget}getNestedTrees(){var e=H().filter((e=>e.isMutator&&e.options.parentWorkspace===this)),t=this.getFlyout(!0);return t&&e.push(t.getWorkspace()),e}searchForWorkspaceComment(e){for(let t of this.getTopComments())if(t instanceof Ec&&t.canBeFocused()&&t.getFocusableElement().id===e)return t}lookUpFocusableNode(e){if(this.workspaceFocusTargetElement&&this.workspaceFocusTargetElement.id===e)return this.workspaceFocusTarget;var t,i,n=null==(t=this.targetWorkspace)?void 0:t.getFlyout();if(this.isFlyout&&n)for(var o of n.getContents())if(t=o.getElement(),M(t)&&t.canBeFocused()&&t.getFocusableElement().id===e)return t;if(o=e.indexOf("_field_"),t=e.indexOf("_connection_"),-1!==o){var s=e.substring(0,o);if(s=this.getBlockById(s))for(var r of s.getFields())if(r.canBeFocused()&&r.getFocusableElement().id===e)return r;return null}if(-1!==t){if(s=e.substring(0,t),s=this.getBlockById(s))for(let t of s.getConnections_(!0))if(t.id===e)return t;return null}if(-1!==(r=Math.max(e.indexOf("_comment_textarea_"),e.indexOf("_collapse_bar_button"),e.indexOf("_delete_bar_button")))&&(r=e.substring(0,r),r=this.searchForWorkspaceComment(r)))return e.indexOf("_comment_textarea_")>-1?r.getEditorFocusableNode():null!=(i=r.view.getCommentBarButtons().find((t=>t.id.includes(e))))?i:null;if((i=this.getAllBlocks(!1).find((t=>t.getFocusableElement().id===e)))||(i=this.searchForWorkspaceComment(e)))return i;for(var a of i=this.getAllBlocks().map((e=>e.getIcons())).flat()){if(a.canBeFocused()&&a.getFocusableElement().id===e)return a;if(pt(a)){if((i=a.getBubble())&&i.canBeFocused()&&i.getFocusableElement().id===e)return i;if(i instanceof Uc&&i.getEditor().getFocusableElement().id===e)return i.getEditor()}}for(s of a=this.getComponentManager().getComponents(Sr.Capability.FOCUSABLE,!1))if(s.getFocusableElement().getAttribute("id")===e)return s;return null}onTreeFocus(){this.updateAriaLabel()}onTreeBlur(e){if(this.isFlyout&&this.targetWorkspace){var t=this.targetWorkspace.getToolbox();t&&e===t||Zs.t().ephemeralFocusTaken()&&e!==this.targetWorkspace||(t&&"function"==typeof t.autoHide?t.autoHide(!1):(e=this.targetWorkspace.getFlyout())&&"function"==typeof e.autoHide&&e.autoHide(!1))}}performAction(){Ol.show(this,{message:Zs.C.KEYBOARD_NAV_WORKSPACE_NAVIGATION_HINT,id:"workspaceNavigationHint"})}getNavigator(){return this.navigator}setNavigator(e){this.navigator=e}};ig.everFocused=!1;var ng=class{constructor(e,t,i,n){this.workspace=e,this.name=t,this.type=i||"",this.id=n||he()}getId(){return this.id}getName(){return this.name}setName(e){return this.name=e,this}getType(){return this.type}setType(e){return this.type=e,this}getWorkspace(){return this.workspace}save(){var e={name:this.getName(),id:this.getId()},t=this.getType();return t&&(e.type=t),e}static load(e,t){e=new this(t,e.name,e.type,e.id),t.getVariableMap().addVariable(e),ue(new(_e(Fr.VAR_CREATE))(e))}};te(ya.VARIABLE_MODEL,"default",ng);var og=class{constructor(e,t=!1){this.workspace=e,this.potentialMap=t,this.variableMap=new Map}clear(){for(let e of this.variableMap.values())for(let t of e.values())this.deleteVariable(t);if(0!==this.variableMap.size)throw Error("Non-empty variable map")}renameVariable(e,t){if(e.getName()===t)return e;var i=e.getType();i=this.getVariable(t,i);var n=this.workspace.getAllBlocks(!1),o="";this.potentialMap||(o=Zs.gd)||Zs.B(!0);try{i&&i.getId()!==e.getId()?this.renameVariableWithConflict(e,t,i,n):this.renameVariableAndUses(e,t,n)}finally{this.potentialMap||Zs.B(o)}return e}changeVariableType(e,t){var i=e.getType();if(i===t)return e;var n,o=this.variableMap.get(i);return null==o||o.delete(e.getId()),0===(null==o?void 0:o.size)&&this.variableMap.delete(i),e.setType(t),(o=null!=(n=this.variableMap.get(t))?n:new Map).set(e.getId(),e),this.variableMap.has(t)||this.variableMap.set(t,o),ue(new(_e(Fr.VAR_TYPE_CHANGE))(e,i,t)),e}renameVariableAndUses(e,t,i){for(this.potentialMap||ue(new(_e(Fr.VAR_RENAME))(e,t)),e.setName(t),t=0;t<i.length;t++)i[t].updateVarName(e)}renameVariableWithConflict(e,t,i,n){var o,s=e.getType();for(t!==i.getName()&&this.renameVariableAndUses(i,t,n),t=0;t<n.length;t++)n[t].renameVarById(e.getId(),i.getId());this.potentialMap||ue(new(_e(Fr.VAR_DELETE))(e)),null==(o=this.variableMap.get(s))||o.delete(e.getId())}createVariable(e,t,i){var n,o=this.getVariable(e,t);if(o){if(i&&o.getId()!==i)throw Error('Variable "'+e+'" is already in use and its id is "'+o.getId()+'" which conflicts with the passed in id, "'+i+'".');return o}if(i&&this.getVariableById(i))throw Error('Variable id, "'+i+'", is already in use.');if(o=i||he(),t=t||"",!(i=ae(ya.VARIABLE_MODEL,this.workspace.options,!0)))throw Error("No variable model is registered.");return o=new i(this.workspace,e,t,o),(e=null!=(n=this.variableMap.get(t))?n:new Map).set(o.getId(),o),this.variableMap.has(t)||this.variableMap.set(t,e),this.potentialMap||ue(new(_e(Fr.VAR_CREATE))(o)),o}addVariable(e){var t,i=e.getType();this.variableMap.has(i)||this.variableMap.set(i,new Map),null==(t=this.variableMap.get(i))||t.set(e.getId(),e)}deleteVariable(e){var t=Lt(this.workspace,e.getId()),i="";this.potentialMap||(i=Zs.gd)||Zs.B(!0);try{for(let e=0;e<t.length;e++)t[e].isDeadOrDying()||t[e].dispose(!0);let i=this.variableMap.get(e.getType());i&&i.has(e.getId())&&(i.delete(e.getId()),this.potentialMap||ue(new(_e(Fr.VAR_DELETE))(e)),0===i.size&&this.variableMap.delete(e.getType()))}finally{this.potentialMap||Zs.B(i)}}getVariable(e,t){return(t=this.variableMap.get(t||""))&&null!=(i=[...t.values()].find((t=>Zs.Cj.equals(t.getName(),e))))?i:null;var i}getVariableById(e){for(let t of this.variableMap.values())if(t.has(e)){let i;return null!=(i=t.get(e))?i:null}return null}getVariablesOfType(e){return(e=this.variableMap.get(e||""))?[...e.values()]:[]}getTypes(){return[...this.variableMap.keys()]}getAllVariables(){var e=[];for(let t of this.variableMap.values())e=e.concat(...t.values());return e}};te(ya.VARIABLE_MAP,"default",og);var sg=class extends Ud{constructor(e){super(),this.workspace=e,this.id="trashcan",this.uniqueId=le(),this.contents=[],this.flyout=null,this.isLidOpen=!1,this.svgGroup=null,this.top=this.left=0,this.initialized=!1,this.workspace.options.maxTrashcanContents<=0||(e=this.workspace.copyOptionsForFlyout(),this.workspace.horizontalLayout?(e.toolboxPosition=this.workspace.toolboxPosition===Ya.TOP?Ya.BOTTOM:Ya.TOP,this.flyout=new(ae(ya.FLYOUTS_HORIZONTAL_TOOLBOX,this.workspace.options,!0))(e)):(e.toolboxPosition=this.workspace.toolboxPosition===Ya.RIGHT?Ya.LEFT:Ya.RIGHT,this.flyout=new(ae(ya.FLYOUTS_VERTICAL_TOOLBOX,this.workspace.options,!0))(e)),this.workspace.addChangeListener(this.onDelete.bind(this)))}createDom(){this.svgGroup=I(ea.G,{class:"blocklyTrash",tabindex:"0",id:this.uniqueId}),I(ea.RECT,{width:55,height:68,x:-4,y:-4,rx:2,ry:2,fill:"none",class:"blocklyFocusRing"},this.svgGroup),_(this.svgGroup,Hr.BUTTON),f(this.svgGroup,$r.LABEL,Zs.C.ARIA_LABEL_TRASH_EMPTY),f(this.svgGroup,$r.DISABLED,!0);var e=String(Math.random()).substring(2),t=I(ea.CLIPPATH,{id:"blocklyTrashBodyClipPath"+e},this.svgGroup);return I(ea.RECT,{width:47,height:44,y:16},t),I(ea.IMAGE,{width:sl,x:-0,height:rl,y:-32,"clip-path":"url(#blocklyTrashBodyClipPath"+e+")"},this.svgGroup).setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",this.workspace.options.pathToMedia+al),t=I(ea.CLIPPATH,{id:"blocklyTrashLidClipPath"+e},this.svgGroup),I(ea.RECT,{width:47,height:16},t),t=I(ea.G,{class:"blocklyTrashLid"},this.svgGroup),t=I(ea.SVG,{viewBox:"0 32 47 16",width:47,height:16},t),I(ea.IMAGE,{width:sl,height:rl,href:this.workspace.options.pathToMedia+al},t),a(this.svgGroup,"pointerdown",this,this.blockMouseDownWhenOpenable),a(this.svgGroup,"pointerup",this,this.click),a(this.svgGroup,"keydown",this,this.onKeyDown),this.svgGroup}init(){if(this.workspace.options.maxTrashcanContents>0){let e=this.flyout.createDom(ea.SVG);N(e,"blocklyTrashcanFlyout"),O(e,this.workspace.getParentSvg()),this.flyout.init(this.workspace)}this.workspace.getComponentManager().addComponent({component:this,weight:Sr.ComponentWeight.TRASHCAN_WEIGHT,capabilities:[Sr.Capability.AUTOHIDEABLE,Sr.Capability.DELETE_AREA,Sr.Capability.DRAG_TARGET,Sr.Capability.POSITIONABLE]}),this.initialized=!0,this.setLidOpen(!1)}dispose(){var e;this.workspace.getComponentManager().removeComponent("trashcan"),null==(e=this.flyout)||e.dispose(),this.flyout=null,this.svgGroup&&S(this.svgGroup)}hasContents(){return!!this.contents.length}contentsIsOpen(){return!!this.flyout&&this.flyout.isVisible()}openFlyout(){if(!this.contentsIsOpen()){var e=this.contents.map((function(e){return JSON.parse(e)})),t=this.workspace.getParentSvg().style;t.cursor="wait",setTimeout((()=>{var i,n;if(null==(i=this.flyout)||i.show(e),t.cursor="",null==(n=this.workspace.scrollbar)||n.setVisible(!1),Xh.getIsActive()){let e,t;(i=null==(t=null==(e=this.flyout)?void 0:e.getWorkspace())?void 0:t.getNavigator().getFirstNode())&&Zs.t().focusNode(i)}}),10),this.fireUiEvent(!0)}}closeFlyout(){var e,t;this.contentsIsOpen()&&(null==(e=this.flyout)||e.hide(),null==(t=this.workspace.scrollbar)||t.setVisible(!0),this.fireUiEvent(!1),this.workspace.recordDragTargets())}autoHide(e){!e&&this.flyout&&this.closeFlyout()}emptyContents(){this.hasContents()&&this.svgGroup&&(this.contents.length=0,this.svgGroup.classList.remove("blocklyTrashFull"),f(this.svgGroup,$r.LABEL,Zs.C.ARIA_LABEL_TRASH_EMPTY),f(this.svgGroup,$r.DISABLED,!0),this.closeFlyout())}position(e,t){if(this.initialized){var i,n,o=We(this.workspace,e);e=Ge(o,new Fa(47,60),20,20,e,this.workspace),t=qe(e,20,o.vertical===Qa.TOP?il.DOWN:il.UP,t),this.top=t.top,this.left=t.left,null==(i=this.svgGroup)||i.setAttribute("transform","translate("+this.left+","+this.top+")"),null==(n=this.flyout)||n.position()}}getBoundingRectangle(){return new xa(this.top,this.top+44+16,this.left,this.left+47)}getClientRect(){if(!this.svgGroup)return null;var e=this.svgGroup.getBoundingClientRect(),t=e.top+32-10;return e=e.left+0-10,new xa(t,t+16+44+20,e,e+47+20)}onDragOver(){yc.mover.isMoving()||this.setLidOpen(this.wouldDelete_)}onDragExit(){yc.mover.isMoving()||this.setLidOpen(!1)}onDrop(){yc.mover.isMoving()||setTimeout(this.setLidOpen.bind(this,!1),100)}setLidOpen(e){var t;this.isLidOpen!==e&&(this.isLidOpen=e,null==(t=this.svgGroup)||t.classList.toggle("blocklyTrashOpen",e))}closeLid(){this.setLidOpen(!1)}click(){this.hasContents()&&!this.workspace.isDragging()&&this.openFlyout()}onKeyDown(e){"Enter"!==e.key&&" "!==e.key||(e.preventDefault(),this.click())}fireUiEvent(e){e=new(_e(Fr.TRASHCAN_OPEN))(e,this.workspace.id),ue(e)}blockMouseDownWhenOpenable(e){!this.contentsIsOpen()&&this.hasContents()&&e.stopPropagation()}onDelete(e){if(!(this.workspace.options.maxTrashcanContents<=0||e.type!==Fr.BLOCK_DELETE||e.wasShadow)&&this.svgGroup){if(!e.oldJson)throw Error("Encountered a delete event without proper oldJson");if(e=JSON.stringify(this.cleanBlockJson(e.oldJson)),!this.contents.includes(e)){for(this.contents.unshift(e);this.contents.length>this.workspace.options.maxTrashcanContents;)this.contents.pop();this.svgGroup.classList.add("blocklyTrashFull"),f(this.svgGroup,$r.LABEL,Zs.C.OPEN_TRASH),m(this.svgGroup,$r.DISABLED)}}}cleanBlockJson(e){return function e(t){if(t){if(delete t.id,delete t.x,delete t.y,delete t.enabled,delete t.disabledReasons,t.icons&&t.icons.comment){var i=t.icons.comment;delete i.height,delete i.width,delete i.pinned}for(var n in i=t.inputs){var o=i[n];let t=o.block;o=o.shadow,t&&e(t),o&&e(o)}t.next&&(t=(n=t.next).block,n=n.shadow,t&&e(t),n&&e(n))}}(e=JSON.parse(JSON.stringify(e))),Object.assign({},{kind:"BLOCK"},e)}};g("\n .blocklyTrash > image {\n opacity: 0.4;\n transition: opacity 0.08s ease-out;\n }\n\n .blocklyTrashLid {\n opacity: 0.4;\n transition: rotate 0.08s ease-out, opacity 0.08s ease-out;\n transform-origin: 46px 12px;\n rotate: 0deg;\n pointer-events: none;\n }\n\n .blocklyRTL .blocklyTrashLid {\n transform-origin: 0px 12px;\n }\n\n .blocklyTrash.blocklyTrashFull .blocklyTrashLid {\n rotate: 5deg;\n }\n\n .blocklyRTL .blocklyTrash.blocklyTrashFull .blocklyTrashLid {\n rotate: -5deg;\n }\n\n .blocklyTrash.blocklyTrashOpen > image,\n .blocklyTrash.blocklyTrashOpen > .blocklyTrashLid,\n .blocklyTrash.blocklyTrashFull:hover > image,\n .blocklyTrash.blocklyTrashFull:hover > .blocklyTrashLid,\n .blocklyTrash.blocklyTrashFull:focus > image,\n .blocklyTrash.blocklyTrashFull:focus > .blocklyTrashLid {\n opacity: 0.8;\n }\n\n .blocklyTrash.blocklyTrashOpen .blocklyTrashLid,\n .blocklyTrash.blocklyTrashFull:hover .blocklyTrashLid,\n .blocklyTrash.blocklyTrashFull:focus .blocklyTrashLid {\n rotate: 45deg;\n }\n\n .blocklyRTL .blocklyTrash.blocklyTrashOpen .blocklyTrashLid,\n .blocklyRTL .blocklyTrash.blocklyTrashFull:hover .blocklyTrashLid,\n .blocklyRTL .blocklyTrash.blocklyTrashFull:focus .blocklyTrashLid {\n rotate: -45deg;\n }\n");var rg={ProcedureSerializer:class{constructor(e,t){this.procedureModelClass=e,this.parameterModelClass=t,this.priority=75}save(e){return(e=e.getProcedureMap().getProcedures().map((e=>Is(e)))).length?e:null}load(e,t){var i=t.getProcedureMap();for(let n of e)i.add(Ns(this.procedureModelClass,this.parameterModelClass,n,t))}clear(e){e.getProcedureMap().clear()}}};rg.loadProcedure=Ns,rg.saveProcedure=Is;var ag=class{constructor(){this.priority=100}save(e){return(e=e.getVariableMap().getAllVariables().map((e=>e.save()))).length?e:null}load(e,t){var i=ne(ya.VARIABLE_MODEL,"default",void 0);e.forEach((e=>{null==i||i.load(e,t)}))}clear(e){e.getVariableMap().clear()}};$e("variables",new ag);var lg={};lg.VariableSerializer=ag;var hg={blocks:ru,exceptions:ou,priorities:{BLOCKS:50,PROCEDURES:75,VARIABLES:100,WORKSPACE_COMMENTS:25},procedures:rg,registry:pl,variables:lg,workspaceComments:El,workspaces:{load:function(e,t,{recordUndo:i=!1}={}){var n=re(ya.SERIALIZER,!0);if(n){n=Object.entries(n).sort(((e,t)=>t[1].priority-e[1].priority));var o=Zs.Qc;Zs.Qc=i,(i=Zs.gd)||Zs.B(!0),w(),t instanceof ig&&t.setResizesEnabled(!1);for(let[,e]of n.reverse()){let i;null==(i=e)||i.clear(t)}for(let[i,o]of n.reverse())if(e[i]){let n;null==(n=o)||n.load(e[i],t)}t instanceof ig&&t.setResizesEnabled(!0),L(),ue(new(_e(Fr.FINISHED_LOADING))(t)),Zs.B(i),Zs.Qc=o}},save:function(e){var t=Object.create(null),i=re(ya.SERIALIZER,!0);for(let n in i){let o,s=null==(o=i[n])?void 0:o.save(e);s&&(t[n]=s)}return t}}};"Blockly"in globalThis||(globalThis.Blockly={Msg:Oa});var ug=class{load(e,t){return(e=new ud(t.getWorkspace(),t.targetWorkspace,e,!0)).show(),new Vd(e,"label")}gapForItem(e,t){return t}disposeItem(e){(e=e.getElement())instanceof ud&&e.dispose()}getType(){return"label"}};te(ya.FLYOUT_INFLATER,"label",ug);var cg=class{constructor(){this.size=new Fa(0,0)}getHeightWidth(){return this.size}show(e,t){this.parentConnection=e,this.parentConnection.attachInsertionMarker(this);var i=t.getSourceBlock(),n=new Map;for(var o of i.getConnections_(!1))n.set(o,o.targetConnection),o.targetConnection=null;t.targetConnection=e,i.workspace.getRenderer().render(i),this.partiallyTighten(i,t),this.marker=this.makeMarker(i),o=i.getBoundingRectangleWithoutChildren(),this.size=new Fa(o.getWidth(),o.getHeight()),o=e.getSourceBlock().getRelativeToSurfaceXY();var s=Da.difference(e.getOffsetInBlock(),t.getOffsetInBlock());for(let[e,t]of n.entries())e.targetConnection=t;i.workspace.getRenderer().render(i),this.partiallyTighten(i,t),this.marker.setAttribute("transform",`translate(${o.x+s.x}, ${o.y+s.y}) ${i.workspace.RTL?"scale(-1, 1)":""}`),e.getSourceBlock().queueRender(),et()}hide(){var e,t;this.parentConnection&&(null==(e=this.marker)||e.remove(),this.marker=void 0,this.parentConnection.detachInsertionMarker(),null==(t=this.parentConnection)||t.getSourceBlock().queueRender(),et(),this.parentConnection=void 0)}makeMarker(e){var t,i=I(ea.G,{transform:`translate(${e.relativeCoords.x}, ${e.relativeCoords.y})`,class:"blocklyInsertionMarker"});return I(ea.PATH,{d:null!=(t=e.pathObject.svgPath.getAttribute("d"))?t:"",class:"blocklyPath"},i),e.workspace.getCanvas().appendChild(i),i}partiallyTighten(e,t){for(let i of e.inputList){if(i===t.getParentInput())continue;let e=i.connection;e&&e.tightenEfficiently()}e.nextConnection&&e.nextConnection!==t&&e.nextConnection.tightenEfficiently()}},dg=class extends $p{constructor(){super(),this.FIELD_TEXT_BASELINE_CENTER=!1,this.DARK_PATH_OFFSET=1,this.MAX_BOTTOM_WIDTH=30,this.STATEMENT_BOTTOM_SPACER=-this.NOTCH_HEIGHT/2}getCSS_(e){return super.getCSS_(e).concat([`${e} .blocklyInsertionMarker>.blocklyPathLight,`,`${e} .blocklyInsertionMarker>.blocklyPathDark {`,`fill-opacity: ${this.INSERTION_MARKER_OPACITY};`,"stroke: none;","}"])}},pg=class{constructor(e){this.inlineSteps_=this.steps_="",this.info_=e,this.RTL_=this.info_.RTL,e=e.getRenderer(),this.constants_=e.getConstants(),this.highlightConstants_=e.getHighlightConstants(),this.highlightOffset=this.highlightConstants_.OFFSET,this.outsideCornerPaths_=this.highlightConstants_.OUTSIDE_CORNER,this.insideCornerPaths_=this.highlightConstants_.INSIDE_CORNER,this.puzzleTabPaths_=this.highlightConstants_.PUZZLE_TAB,this.notchPaths_=this.highlightConstants_.NOTCH,this.startPaths_=this.highlightConstants_.START_HAT,this.jaggedTeethPaths_=this.highlightConstants_.JAGGED_TEETH}getPath(){return this.steps_+"\n"+this.inlineSteps_}drawTopCorner(e){this.steps_+=Gn(e.xPos,this.info_.startY);for(let t,i=0;t=e.elements[i];i++)vp.isLeftSquareCorner(t)?this.steps_+=this.highlightConstants_.START_POINT:vp.isLeftRoundedCorner(t)?this.steps_+=this.outsideCornerPaths_.topLeft(this.RTL_):vp.isPreviousConnection(t)?this.steps_+=this.notchPaths_.pathLeft:vp.isHat(t)?this.steps_+=this.startPaths_.path(this.RTL_):vp.isSpacer(t)&&0!==t.width&&(this.steps_+=$n("H",t.xPos+t.width-this.highlightOffset));this.steps_+=$n("H",e.xPos+e.width-this.highlightOffset)}drawJaggedEdge_(e){this.info_.RTL&&(this.steps_+=this.jaggedTeethPaths_.pathLeft+$n("v",e.height-this.jaggedTeethPaths_.height-this.highlightOffset))}drawValueInput(e){var t=e.getLastInput();if(this.RTL_){let i=e.height-t.connectionHeight;this.steps_+=Hn(t.xPos+t.width-this.highlightOffset,e.yPos)+this.puzzleTabPaths_.pathDown(this.RTL_)+$n("v",i)}else this.steps_+=Hn(t.xPos+t.width,e.yPos)+this.puzzleTabPaths_.pathDown(this.RTL_)}drawStatementInput(e){var t=e.getLastInput();if(t)if(this.RTL_){let i=e.height-2*this.insideCornerPaths_.height;this.steps_+=Hn(t.xPos,e.yPos)+this.insideCornerPaths_.pathTop(this.RTL_)+$n("v",i)+this.insideCornerPaths_.pathBottom(this.RTL_)+Wn(e.width-t.xPos-this.insideCornerPaths_.width,0)}else this.steps_+=Hn(t.xPos,e.yPos+e.height)+this.insideCornerPaths_.pathBottom(this.RTL_)+Wn(e.width-t.xPos-this.insideCornerPaths_.width,0)}drawRightSideRow(e){var t=e.xPos+e.width-this.highlightOffset;e instanceof Vp&&e.followsStatement&&(this.steps_+=$n("H",t)),this.RTL_&&(this.steps_+=$n("H",t),e.height>this.highlightOffset&&(this.steps_+=$n("V",e.yPos+e.height-this.highlightOffset)))}drawBottomRow(e){if(this.RTL_)this.steps_+=$n("V",e.baseline-this.highlightOffset);else{let t=this.info_.bottomRow.elements[0];vp.isLeftSquareCorner(t)?this.steps_+=Hn(e.xPos+this.highlightOffset,e.baseline-this.highlightOffset):vp.isLeftRoundedCorner(t)&&(this.steps_+=Hn(e.xPos,e.baseline),this.steps_+=this.outsideCornerPaths_.bottomLeft())}}drawLeft(){var e=this.info_.outputConnection;e&&(e=e.connectionOffsetY+e.height,this.RTL_?this.steps_+=Hn(this.info_.startX,e):(this.steps_+=Hn(this.info_.startX+this.highlightOffset,this.info_.bottomRow.baseline-this.highlightOffset),this.steps_+=$n("V",e)),this.steps_+=this.puzzleTabPaths_.pathUp(this.RTL_)),this.RTL_||(e=this.info_.topRow,vp.isLeftRoundedCorner(e.elements[0])?this.steps_+=$n("V",this.outsideCornerPaths_.height):this.steps_+=$n("V",e.capline+this.highlightOffset))}drawInlineInput(e){var t=this.highlightOffset,i=e.xPos+e.connectionWidth,n=e.centerline-e.height/2,o=e.width-e.connectionWidth,s=n+t;this.RTL_?(n=e.connectionOffsetY-t,e=e.height-(e.connectionOffsetY+e.connectionHeight)+t,this.inlineSteps_+=Hn(i-t,s)+$n("v",n)+this.puzzleTabPaths_.pathDown(this.RTL_)+$n("v",e)+$n("h",o)):this.inlineSteps_+=Hn(e.xPos+e.width+t,s)+$n("v",e.height)+$n("h",-o)+Hn(i,n+e.connectionOffsetY)+this.puzzleTabPaths_.pathDown(this.RTL_)}},gg=class extends jp{constructor(e,t){super(e,t),this.highlighter_=new pg(t)}draw(){this.drawOutline_(),this.drawInternals_(),this.updateConnectionHighlights();var e=this.block_.pathObject;e.setPath(this.outlinePath_+"\n"+this.inlinePath_),e.setHighlightPath(this.highlighter_.getPath()),this.info_.RTL&&e.flipRTL(),this.recordSizeOnBlock_()}drawTop_(){this.highlighter_.drawTopCorner(this.info_.topRow),this.highlighter_.drawRightSideRow(this.info_.topRow),super.drawTop_()}drawJaggedEdge_(e){this.highlighter_.drawJaggedEdge_(e),super.drawJaggedEdge_(e)}drawValueInput_(e){this.highlighter_.drawValueInput(e),super.drawValueInput_(e)}drawStatementInput_(e){this.highlighter_.drawStatementInput(e),super.drawStatementInput_(e)}drawRightSideRow_(e){this.highlighter_.drawRightSideRow(e),this.outlinePath_+=$n("H",e.xPos+e.width)+$n("V",e.yPos+e.height)}drawBottom_(){this.highlighter_.drawBottomRow(this.info_.bottomRow),super.drawBottom_()}drawLeft_(){this.highlighter_.drawLeft(),super.drawLeft_()}drawInlineInput_(e){this.highlighter_.drawInlineInput(e),super.drawInlineInput_(e)}positionInlineInputConnection_(e){var t=e.centerline-e.height/2;if(e.connectionModel){let i=e.xPos+e.connectionWidth+this.constants_.DARK_PATH_OFFSET;this.info_.RTL&&(i*=-1),e.connectionModel.setOffsetInBlock(i,t+e.connectionOffsetY+this.constants_.DARK_PATH_OFFSET)}}positionStatementInputConnection_(e){var t=e.getLastInput();if(null!=t&&t.connectionModel){let i=e.xPos+e.statementEdge+t.notchOffset;i=this.info_.RTL?-1*i:i+this.constants_.DARK_PATH_OFFSET,t.connectionModel.setOffsetInBlock(i,e.yPos+this.constants_.DARK_PATH_OFFSET)}}positionExternalValueConnection_(e){var t=e.getLastInput();if(t&&t.connectionModel){let i=e.xPos+e.width+this.constants_.DARK_PATH_OFFSET;this.info_.RTL&&(i*=-1),t.connectionModel.setOffsetInBlock(i,e.yPos)}}positionNextConnection_(){var e=this.info_.bottomRow;if(e.connection){let t=e.connection,i=t.xPos;t.connectionModel.setOffsetInBlock((this.info_.RTL?-i:i)+this.constants_.DARK_PATH_OFFSET/2,e.baseline+this.constants_.DARK_PATH_OFFSET)}}},Eg=class{constructor(e){this.OFFSET=.5,this.constantProvider=e,this.START_POINT=Gn(this.OFFSET,this.OFFSET)}init(){this.INSIDE_CORNER=this.makeInsideCorner(),this.OUTSIDE_CORNER=this.makeOutsideCorner(),this.PUZZLE_TAB=this.makePuzzleTab(),this.NOTCH=this.makeNotch(),this.JAGGED_TEETH=this.makeJaggedTeeth(),this.START_HAT=this.makeStartHat()}makeInsideCorner(){var e=this.constantProvider.CORNER_RADIUS,t=this.OFFSET,i=(1-Math.SQRT1_2)*(e+t)-t,n=Gn(i,i)+jn("a","0 0,0",e,Un(-i-t,e-i)),o=jn("a","0 0,0",e+t,Un(e+t,e+t)),s=Gn(i,-i)+jn("a","0 0,0",e+t,Un(e-i,i+t));return{width:e+t,height:e,pathTop:e=>e?n:"",pathBottom:e=>e?o:s}}makeOutsideCorner(){var e=this.constantProvider.CORNER_RADIUS,t=this.OFFSET,i=(1-Math.SQRT1_2)*(e-t)+t,n=Gn(i,i)+jn("a","0 0,1",e-t,Un(e-i,-i+t)),o=Gn(t,e)+jn("a","0 0,1",e-t,Un(e,-e+t)),s=-i,r=Gn(i,s)+jn("a","0 0,1",e-t,Un(-i+t,-s-e));return{height:e,topLeft:e=>e?n:o,bottomLeft:()=>r}}makePuzzleTab(){var e=this.constantProvider.TAB_WIDTH,t=this.constantProvider.TAB_HEIGHT,i=Gn(-2,2.5-t+.9)+Wn(-.45*e,-2.1),n=$n("v",2.5)+Gn(.97*-e,2.5)+Vn("q",[Un(.05*-e,10),Un(.3*e,9.5)])+Gn(.67*e,-1.9)+$n("v",2.5),o=$n("v",-1.5)+Gn(-.92*e,-.5)+Vn("q",[Un(-.19*e,-5.5),Un(0,-11)])+Gn(.92*e,1),s=Gn(-5,t-.7)+Wn(.46*e,-2.1);return{width:e,height:t,pathUp:e=>e?i:o,pathDown:e=>e?n:s}}makeNotch(){return{pathLeft:$n("h",this.OFFSET)+this.constantProvider.NOTCH.pathLeft}}makeJaggedTeeth(){return{pathLeft:Wn(5.1,2.6)+Gn(-10.2,6.8)+Wn(5.1,2.6),height:12,width:10.2}}makeStartHat(){var e=this.constantProvider.START_HAT.height,t=Gn(25,-8.7)+Vn("c",[Un(29.7,-6.2),Un(57.2,-.5),Un(75,8.7)]),i=Vn("c",[Un(17.8,-9.2),Un(45.3,-14.9),Un(75,-8.7)])+Hn(100.5,e+.5);return{path:e=>e?t:i}}},Tg=class extends Dp{constructor(e,t){super(e,t),this.constants_=e,this.connectedBlock&&(this.width+=this.constants_.DARK_PATH_OFFSET,this.height+=this.constants_.DARK_PATH_OFFSET)}},_g=class extends Gp{constructor(e,t){super(e,t),this.constants_=e,this.connectedBlock&&(this.height+=this.constants_.DARK_PATH_OFFSET)}},fg=class extends zp{constructor(e,t){super(e,t),this.renderer_=e}getRenderer(){return this.renderer_}populateBottomRow_(){super.populateBottomRow_(),this.block_.inputList.length&&this.block_.inputList[this.block_.inputList.length-1]instanceof Qc||(this.bottomRow.minHeight=this.constants_.MEDIUM_PADDING-this.constants_.DARK_PATH_OFFSET)}addInput_(e,t){this.isInline&&e instanceof Zs.go?(t.elements.push(new Tg(this.constants_,e)),t.hasInlineInput=!0):e instanceof Qc?(t.elements.push(new _g(this.constants_,e)),t.hasStatement=!0):e instanceof Zs.go?(t.elements.push(new Sp(this.constants_,e)),t.hasExternalInput=!0):(e instanceof Kc||e instanceof Jc)&&(t.minHeight=Math.max(t.minHeight,this.constants_.DUMMY_INPUT_MIN_HEIGHT),t.hasDummyInput=!0),this.isInline||null!==t.align||(t.align=e.align)}addElemSpacing_(){var e=!1;for(let t,i=0;t=this.rows[i];i++)t.hasExternalInput&&(e=!0);for(let i,n=0;i=this.rows[n];n++){var t=i.elements;if(i.elements=[],i.startsWithElemSpacer()&&i.elements.push(new Lp(this.constants_,this.getInRowSpacing_(null,t[0]))),t.length){for(let e=0;e<t.length-1;e++){i.elements.push(t[e]);let n=this.getInRowSpacing_(t[e],t[e+1]);i.elements.push(new Lp(this.constants_,n))}i.elements.push(t[t.length-1]),i.endsWithElemSpacer()&&(t=this.getInRowSpacing_(t[t.length-1],null),e&&i.hasDummyInput&&(t+=this.constants_.TAB_WIDTH),i.elements.push(new Lp(this.constants_,t)))}}}getInRowSpacing_(e,t){if(!e)return t&&vp.isField(t)&&t.isEditable?this.constants_.MEDIUM_PADDING:t&&vp.isInlineInput(t)?this.constants_.MEDIUM_LARGE_PADDING:t&&vp.isStatementInput(t)?this.constants_.STATEMENT_INPUT_PADDING_LEFT:this.constants_.LARGE_PADDING;if(!vp.isInput(e)&&(!t||vp.isStatementInput(t)))return vp.isField(e)&&e.isEditable?0===e.width?this.constants_.NO_PADDING:this.constants_.MEDIUM_PADDING:vp.isIcon(e)?2*this.constants_.LARGE_PADDING+1:vp.isHat(e)?this.constants_.NO_PADDING:vp.isPreviousOrNextConnection(e)?this.constants_.LARGE_PADDING:vp.isLeftRoundedCorner(e)?this.constants_.MIN_BLOCK_WIDTH:vp.isJaggedEdge(e)?this.constants_.NO_PADDING:this.constants_.LARGE_PADDING;if(vp.isInput(e)&&!t){if(vp.isExternalInput(e))return this.constants_.NO_PADDING;if(vp.isInlineInput(e))return this.constants_.LARGE_PADDING;if(vp.isStatementInput(e))return this.constants_.NO_PADDING}if(!vp.isInput(e)&&t&&vp.isInput(t)){if(vp.isField(e)&&e.isEditable){if(vp.isInlineInput(t)||vp.isExternalInput(t))return this.constants_.SMALL_PADDING}else{if(vp.isInlineInput(t)||vp.isExternalInput(t))return this.constants_.MEDIUM_LARGE_PADDING;if(vp.isStatementInput(t))return this.constants_.LARGE_PADDING}return this.constants_.LARGE_PADDING-1}if(vp.isIcon(e)&&t&&!vp.isInput(t))return this.constants_.LARGE_PADDING;if(vp.isInlineInput(e)&&t&&vp.isField(t))return t.isEditable?this.constants_.MEDIUM_PADDING:this.constants_.LARGE_PADDING;if(vp.isLeftSquareCorner(e)&&t){if(vp.isHat(t))return this.constants_.NO_PADDING;if(vp.isPreviousConnection(t))return t.notchOffset;if(vp.isNextConnection(t))return t.notchOffset+(this.RTL?1:-1)*this.constants_.DARK_PATH_OFFSET/2}if(vp.isLeftRoundedCorner(e)&&t){if(vp.isPreviousConnection(t))return t.notchOffset-this.constants_.CORNER_RADIUS;if(vp.isNextConnection(t))return t.notchOffset-this.constants_.CORNER_RADIUS+(this.RTL?1:-1)*this.constants_.DARK_PATH_OFFSET/2}return vp.isField(e)&&t&&vp.isField(t)&&e.isEditable===t.isEditable?0===e.width?this.constants_.NO_PADDING:this.constants_.LARGE_PADDING:t&&vp.isJaggedEdge(t)?this.constants_.LARGE_PADDING:this.constants_.MEDIUM_PADDING}getSpacerRowHeight_(e,t){return vp.isTopRow(e)&&vp.isBottomRow(t)?this.constants_.EMPTY_BLOCK_SPACER_HEIGHT:vp.isTopRow(e)||vp.isBottomRow(t)?this.constants_.NO_PADDING:e.hasExternalInput&&t.hasExternalInput?this.constants_.LARGE_PADDING:!e.hasStatement&&t.hasStatement?this.constants_.BETWEEN_STATEMENT_PADDING_Y:e.hasStatement&&t.hasStatement||!e.hasStatement&&t.hasDummyInput||e.hasDummyInput?this.constants_.LARGE_PADDING:this.constants_.MEDIUM_PADDING}getElemCenterline_(e,t){if(vp.isSpacer(t))return e.yPos+t.height/2;if(vp.isBottomRow(e))return e=e.yPos+e.height-e.descenderHeight,vp.isNextConnection(t)?e+t.height/2:e-t.height/2;if(vp.isTopRow(e))return vp.isHat(t)?e.capline-t.height/2:e.capline+t.height/2;var i=e.yPos;return vp.isField(t)||vp.isIcon(t)?(i+=t.height/2,(e.hasInlineInput||e.hasStatement)&&t.height+this.constants_.TALL_INPUT_FIELD_OFFSET_Y<=e.height&&(i+=this.constants_.TALL_INPUT_FIELD_OFFSET_Y)):i=vp.isInlineInput(t)?i+t.height/2:i+e.height/2,i}alignRowElements_(){if(this.isInline){var e=0,t=new WeakMap,i=null;for(let n,o=this.rows.length-1;n=this.rows[o];o--)t.set(n,e),vp.isInputRow(n)&&(n.hasStatement&&this.alignStatementRow_(n),i&&i.hasStatement&&n.width<i.width?t.set(n,i.width):e=n.hasStatement?n.width:Math.max(e,n.width),i=n);e=0;for(let n,o=0;n=this.rows[o];o++)n.hasStatement?e=this.getDesiredRowWidth_(n):vp.isSpacer(n)?n.width=Math.max(e,t.get(n)):(i=n.width,(e=Math.max(e,t.get(n))-i)>0&&this.addAlignmentPadding_(n,e),e=n.width)}else super.alignRowElements_()}getDesiredRowWidth_(e){return this.isInline&&e.hasStatement?this.statementEdge+this.constants_.MAX_BOTTOM_WIDTH+this.startX:super.getDesiredRowWidth_(e)}finalize_(){var e=0,t=0;for(let n,o=0;n=this.rows[o];o++){n.yPos=t,n.xPos=this.startX,t+=n.height,e=Math.max(e,n.widthWithConnectedBlocks);var i=t-this.topRow.ascenderHeight;n===this.bottomRow&&i<this.constants_.MIN_BLOCK_HEIGHT&&(i=this.constants_.MIN_BLOCK_HEIGHT-i,this.bottomRow.height+=i,t+=i),this.recordElemPositions_(n)}this.outputConnection&&this.block_.nextConnection&&this.block_.nextConnection.isConnected()&&(i=this.block_.nextConnection.targetBlock())&&(e=Math.max(e,i.getHeightWidth().width-this.constants_.DARK_PATH_OFFSET)),this.bottomRow.baseline=t-this.bottomRow.descenderHeight,this.widthWithChildren=e+this.startX+this.constants_.DARK_PATH_OFFSET,this.width+=this.constants_.DARK_PATH_OFFSET,this.height=t+this.constants_.DARK_PATH_OFFSET,this.startY=this.topRow.capline}},mg=class extends Xp{constructor(e,t,i){super(e,t,i),this.constants=i,this.colourDark="#000000",this.svgPathDark=I(ea.PATH,{class:"blocklyPathDark",transform:"translate(1,1)"}),this.svgRoot.insertBefore(this.svgPathDark,this.svgPath),this.svgPathLight=I(ea.PATH,{class:"blocklyPathLight"},this.svgRoot)}setPath(e){this.svgPath.setAttribute("d",e),this.svgPathDark.setAttribute("d",e)}setHighlightPath(e){this.svgPathLight.setAttribute("d",e)}flipRTL(){this.svgPath.setAttribute("transform","scale(-1 1)"),this.svgPathLight.setAttribute("transform","scale(-1 1)"),this.svgPathDark.setAttribute("transform","translate(1,1) scale(-1 1)")}applyColour(e){this.svgPathLight.style.display="",this.svgPathDark.style.display="",this.svgPathLight.setAttribute("stroke",this.style.colourTertiary),this.svgPathDark.setAttribute("fill",this.colourDark),super.applyColour(e),this.svgPath.setAttribute("stroke","none")}setStyle(e){this.style=e,this.colourDark=zi("#000",this.style.colourPrimary,.2)||this.colourDark}updateHighlighted(e){super.updateHighlighted(e),this.svgPathLight.style.display=e?"none":"inline"}updateShadow_(e){super.updateShadow_(e),e&&(this.svgPathLight.style.display="none",this.svgPathDark.setAttribute("fill",this.style.colourSecondary))}updateDisabled_(e){super.updateDisabled_(e),e&&this.svgPath.setAttribute("stroke","none")}},bg=class extends Yp{constructor(e){super(e),this.highlightConstants=null}init(e,t){super.init(e,t),this.highlightConstants=this.makeHighlightConstants_(),this.highlightConstants.init()}refreshDom(e,t,i){super.refreshDom(e,t,i),this.getHighlightConstants().init()}makeConstants_(){return new dg}makeRenderInfo_(e){return new fg(this,e)}makeDrawer_(e,t){return new gg(e,t)}makePathObject(e,t){return new mg(e,t,this.getConstants())}makeHighlightConstants_(){return new Eg(this.getConstants())}getHighlightConstants(){if(!this.highlightConstants)throw Error("Cannot access the highlight constants because init has not been called");return this.highlightConstants}};_s("geras",bg);var Cg=class extends zp{constructor(e,t){super(e,t)}getRenderer(){return this.renderer_}addElemSpacing_(){for(var e=!1,t=0;t<this.rows.length;t++)if(this.rows[t].hasExternalInput){e=!0;break}for(t=0;t<this.rows.length;t++){let n=this.rows[t];var i=n.elements;if(n.elements=[],n.startsWithElemSpacer()&&n.elements.push(new Lp(this.constants_,this.getInRowSpacing_(null,i[0]))),i.length){for(let e=0;e<i.length-1;e++){n.elements.push(i[e]);let t=this.getInRowSpacing_(i[e],i[e+1]);n.elements.push(new Lp(this.constants_,t))}n.elements.push(i[i.length-1]),n.endsWithElemSpacer()&&(i=this.getInRowSpacing_(i[i.length-1],null),e&&n.hasDummyInput&&(i+=this.constants_.TAB_WIDTH),n.elements.push(new Lp(this.constants_,i)))}}}getInRowSpacing_(e,t){if(!e)return t&&vp.isField(t)&&t.isEditable?this.constants_.MEDIUM_PADDING:t&&vp.isInlineInput(t)?this.constants_.MEDIUM_LARGE_PADDING:t&&vp.isStatementInput(t)?this.constants_.STATEMENT_INPUT_PADDING_LEFT:this.constants_.LARGE_PADDING;if(!vp.isInput(e)&&!t)return vp.isField(e)&&e.isEditable?0===e.width?this.constants_.NO_PADDING:this.constants_.MEDIUM_PADDING:vp.isIcon(e)?2*this.constants_.LARGE_PADDING+1:vp.isHat(e)?this.constants_.NO_PADDING:vp.isPreviousOrNextConnection(e)?this.constants_.LARGE_PADDING:vp.isLeftRoundedCorner(e)?this.constants_.MIN_BLOCK_WIDTH:vp.isJaggedEdge(e)?this.constants_.NO_PADDING:this.constants_.LARGE_PADDING;if(vp.isInput(e)&&!t){if(vp.isExternalInput(e))return this.constants_.NO_PADDING;if(vp.isInlineInput(e))return this.constants_.LARGE_PADDING;if(vp.isStatementInput(e))return this.constants_.NO_PADDING}if(!vp.isInput(e)&&t&&vp.isInput(t)){if(vp.isField(e)&&e.isEditable){if(vp.isInlineInput(t)||vp.isExternalInput(t))return this.constants_.SMALL_PADDING}else{if(vp.isInlineInput(t)||vp.isExternalInput(t))return this.constants_.MEDIUM_LARGE_PADDING;if(vp.isStatementInput(t))return this.constants_.LARGE_PADDING}return this.constants_.LARGE_PADDING-1}if(vp.isIcon(e)&&t&&!vp.isInput(t))return this.constants_.LARGE_PADDING;if(vp.isInlineInput(e)&&t&&vp.isField(t))return t.isEditable?this.constants_.MEDIUM_PADDING:this.constants_.LARGE_PADDING;if(vp.isLeftSquareCorner(e)&&t){if(vp.isHat(t))return this.constants_.NO_PADDING;if(vp.isPreviousConnection(t)||vp.isNextConnection(t))return t.notchOffset}return vp.isLeftRoundedCorner(e)&&t?t.notchOffset-this.constants_.CORNER_RADIUS:vp.isField(e)&&t&&vp.isField(t)&&e.isEditable===t.isEditable?0===e.width?this.constants_.NO_PADDING:this.constants_.LARGE_PADDING:t&&vp.isJaggedEdge(t)?this.constants_.LARGE_PADDING:this.constants_.MEDIUM_PADDING}getSpacerRowHeight_(e,t){return vp.isTopRow(e)&&vp.isBottomRow(t)?this.constants_.EMPTY_BLOCK_SPACER_HEIGHT:vp.isTopRow(e)||vp.isBottomRow(t)?this.constants_.NO_PADDING:e.hasExternalInput&&t.hasExternalInput?this.constants_.LARGE_PADDING:!e.hasStatement&&t.hasStatement?this.constants_.BETWEEN_STATEMENT_PADDING_Y:e.hasStatement&&t.hasStatement||e.hasDummyInput||t.hasDummyInput?this.constants_.LARGE_PADDING:this.constants_.MEDIUM_PADDING}getElemCenterline_(e,t){if(vp.isSpacer(t))return e.yPos+t.height/2;if(vp.isBottomRow(e))return e=e.yPos+e.height-e.descenderHeight,vp.isNextConnection(t)?e+t.height/2:e-t.height/2;if(vp.isTopRow(e))return vp.isHat(t)?e.capline-t.height/2:e.capline+t.height/2;var i=e.yPos;return vp.isField(t)&&e.hasStatement?i+(this.constants_.TALL_INPUT_FIELD_OFFSET_Y+t.height/2):i+e.height/2}finalize_(){for(var e=0,t=0,i=0;i<this.rows.length;i++){let o=this.rows[i];o.yPos=t,o.xPos=this.startX,t+=o.height,e=Math.max(e,o.widthWithConnectedBlocks);var n=t-this.topRow.ascenderHeight;o===this.bottomRow&&n<this.constants_.MIN_BLOCK_HEIGHT&&(n=this.constants_.MIN_BLOCK_HEIGHT-n,this.bottomRow.height+=n,t+=n),this.recordElemPositions_(o)}this.outputConnection&&this.block_.nextConnection&&this.block_.nextConnection.isConnected()&&(i=this.block_.nextConnection.targetBlock())&&(e=Math.max(e,i.getHeightWidth().width)),this.bottomRow.baseline=t-this.bottomRow.descenderHeight,this.widthWithChildren=e+this.startX,this.height=t,this.startY=this.topRow.capline}},vg=class extends Yp{constructor(e){super(e)}makeRenderInfo_(e){return new Cg(this,e)}};_s("thrasos",vg);var Ig=class extends $p{constructor(e){super(),this.GRID_UNIT=4,this.CURSOR_COLOUR="#ffa200",this.CURSOR_RADIUS=5,this.JAGGED_TEETH_WIDTH=this.JAGGED_TEETH_HEIGHT=0,this.START_HAT_HEIGHT=22,this.START_HAT_WIDTH=96,this.SHAPES={HEXAGONAL:1,ROUND:2,SQUARE:3,PUZZLE:4,NOTCH:5},this.SHAPE_IN_SHAPE_PADDING={1:{0:5*this.GRID_UNIT,1:2*this.GRID_UNIT,2:5*this.GRID_UNIT,3:5*this.GRID_UNIT},2:{0:3*this.GRID_UNIT,1:3*this.GRID_UNIT,2:1*this.GRID_UNIT,3:2*this.GRID_UNIT},3:{0:2*this.GRID_UNIT,1:2*this.GRID_UNIT,2:2*this.GRID_UNIT,3:2*this.GRID_UNIT}},this.FULL_BLOCK_FIELDS=!0,this.FIELD_TEXT_FONTWEIGHT="bold",this.FIELD_TEXT_FONTFAMILY='"Helvetica Neue", "Segoe UI", Helvetica, sans-serif',this.FIELD_COLOUR_FULL_BLOCK=this.FIELD_TEXTINPUT_BOX_SHADOW=this.FIELD_DROPDOWN_SVG_ARROW=this.FIELD_DROPDOWN_COLOURED_DIV=this.FIELD_DROPDOWN_NO_BORDER_RECT_SHADOW=!0,this.SELECTED_GLOW_COLOUR="#fff200",this.SELECTED_GLOW_SIZE=.5,this.selectedGlowFilterId="",this.SQUARED=this.ROUNDED=this.HEXAGONAL=this.selectedGlowFilter=null,e&&(this.GRID_UNIT=e),this.SMALL_PADDING=this.GRID_UNIT,this.MEDIUM_PADDING=2*this.GRID_UNIT,this.MEDIUM_LARGE_PADDING=3*this.GRID_UNIT,this.LARGE_PADDING=4*this.GRID_UNIT,this.CORNER_RADIUS=1*this.GRID_UNIT,this.NOTCH_WIDTH=9*this.GRID_UNIT,this.NOTCH_HEIGHT=2*this.GRID_UNIT,this.STATEMENT_INPUT_NOTCH_OFFSET=this.NOTCH_OFFSET_LEFT=3*this.GRID_UNIT,this.MIN_BLOCK_WIDTH=2*this.GRID_UNIT,this.MIN_BLOCK_HEIGHT=12*this.GRID_UNIT,this.EMPTY_STATEMENT_INPUT_HEIGHT=6*this.GRID_UNIT,this.TOP_ROW_MIN_HEIGHT=this.CORNER_RADIUS,this.TOP_ROW_PRECEDES_STATEMENT_MIN_HEIGHT=this.LARGE_PADDING,this.BOTTOM_ROW_MIN_HEIGHT=this.CORNER_RADIUS,this.BOTTOM_ROW_AFTER_STATEMENT_MIN_HEIGHT=6*this.GRID_UNIT,this.STATEMENT_BOTTOM_SPACER=-this.NOTCH_HEIGHT,this.STATEMENT_INPUT_SPACER_MIN_WIDTH=40*this.GRID_UNIT,this.STATEMENT_INPUT_PADDING_LEFT=4*this.GRID_UNIT,this.EMPTY_INLINE_INPUT_PADDING=4*this.GRID_UNIT,this.EMPTY_INLINE_INPUT_HEIGHT=8*this.GRID_UNIT,this.DUMMY_INPUT_MIN_HEIGHT=8*this.GRID_UNIT,this.DUMMY_INPUT_SHADOW_MIN_HEIGHT=6*this.GRID_UNIT,this.CURSOR_WS_WIDTH=20*this.GRID_UNIT,this.FIELD_TEXT_FONTSIZE=3*this.GRID_UNIT,this.FIELD_BORDER_RECT_RADIUS=this.CORNER_RADIUS,this.FIELD_BORDER_RECT_X_PADDING=2*this.GRID_UNIT,this.FIELD_BORDER_RECT_Y_PADDING=1.625*this.GRID_UNIT,this.FIELD_BORDER_RECT_HEIGHT=8*this.GRID_UNIT,this.FIELD_DROPDOWN_BORDER_RECT_HEIGHT=8*this.GRID_UNIT,this.FIELD_DROPDOWN_SVG_ARROW_PADDING=this.FIELD_BORDER_RECT_X_PADDING,this.FIELD_COLOUR_DEFAULT_WIDTH=6*this.GRID_UNIT,this.FIELD_COLOUR_DEFAULT_HEIGHT=8*this.GRID_UNIT,this.FIELD_CHECKBOX_X_OFFSET=1*this.GRID_UNIT,this.MAX_DYNAMIC_CONNECTION_SHAPE_WIDTH=12*this.GRID_UNIT}setFontConstants_(e){super.setFontConstants_(e),this.FIELD_DROPDOWN_BORDER_RECT_HEIGHT=this.FIELD_BORDER_RECT_HEIGHT=this.FIELD_TEXT_HEIGHT+2*this.FIELD_BORDER_RECT_Y_PADDING}init(){super.init(),this.HEXAGONAL=this.makeHexagonal(),this.ROUNDED=this.makeRounded(),this.SQUARED=this.makeSquared(),this.STATEMENT_INPUT_NOTCH_OFFSET=this.NOTCH_OFFSET_LEFT+this.INSIDE_CORNERS.rightWidth}setDynamicProperties_(e){super.setDynamicProperties_(e),this.SELECTED_GLOW_COLOUR=e.getComponentStyle("selectedGlowColour")||this.SELECTED_GLOW_COLOUR,this.SELECTED_GLOW_SIZE=(e=Number(e.getComponentStyle("selectedGlowSize")))&&!isNaN(e)?e:this.SELECTED_GLOW_SIZE}dispose(){super.dispose(),this.selectedGlowFilter&&S(this.selectedGlowFilter)}makeStartHat(){var e=this.START_HAT_HEIGHT,t=this.START_HAT_WIDTH;return{height:.75*e,width:t,path:Vn("c",[Un(25,-e),Un(71,-e),Un(t,0)])}}makeHexagonal(){function e(e,i,n){var o=e/2;return Wn(-(n=n?-1:1)*(o=o>t?t:o),e=(i?-1:1)*e/2)+Wn(n*o,e)}var t=this.MAX_DYNAMIC_CONNECTION_SHAPE_WIDTH;return{type:this.SHAPES.HEXAGONAL,isDynamic:!0,width:e=>(e/=2)>t?t:e,height:e=>e,connectionOffsetY:e=>e/2,connectionOffsetX:e=>-e,pathDown:t=>e(t,!1,!1),pathUp:t=>e(t,!0,!1),pathRightDown:t=>e(t,!1,!0),pathRightUp:t=>e(t,!1,!0)}}makeRounded(){function e(e,t,n){var o=e>i?e-i:0,s=n===t?"0":"1";return jn("a","0 0,"+s,e=(e>i?i:e)/2,Un((n?1:-1)*e,(t?-1:1)*e))+$n("v",(t?-1:1)*o)+jn("a","0 0,"+s,e,Un((n?-1:1)*e,(t?-1:1)*e))}var t=this.MAX_DYNAMIC_CONNECTION_SHAPE_WIDTH,i=2*t;return{type:this.SHAPES.ROUND,isDynamic:!0,width:e=>(e/=2)>t?t:e,height:e=>e,connectionOffsetY:e=>e/2,connectionOffsetX:e=>-e,pathDown:t=>e(t,!1,!1),pathUp:t=>e(t,!0,!1),pathRightDown:t=>e(t,!1,!0),pathRightUp:t=>e(t,!1,!0)}}makeSquared(){function e(e,i,n){e-=2*t;var o=n===i?"0":"1";return jn("a","0 0,"+o,t,Un((n?1:-1)*t,(i?-1:1)*t))+$n("v",(i?-1:1)*e)+jn("a","0 0,"+o,t,Un((n?-1:1)*t,(i?-1:1)*t))}var t=this.CORNER_RADIUS;return{type:this.SHAPES.SQUARE,isDynamic:!0,width:()=>t,height:e=>e,connectionOffsetY:e=>e/2,connectionOffsetX:e=>-e,pathDown:t=>e(t,!1,!1),pathUp:t=>e(t,!0,!1),pathRightDown:t=>e(t,!1,!0),pathRightUp:t=>e(t,!1,!0)}}shapeFor(e){var t=e.getCheck();switch(!t&&e.targetConnection&&(t=e.targetConnection.getCheck()),e.type){case Xl.INPUT_VALUE:case Xl.OUTPUT_VALUE:if(null!==(e=e.getSourceBlock().getOutputShape()))switch(e){case this.SHAPES.HEXAGONAL:return this.HEXAGONAL;case this.SHAPES.ROUND:return this.ROUNDED;case this.SHAPES.SQUARE:return this.SQUARED}return t&&t.includes("Boolean")?this.HEXAGONAL:(t&&t.includes("Number")||t&&t.includes("String"),this.ROUNDED);case Xl.PREVIOUS_STATEMENT:case Xl.NEXT_STATEMENT:return this.NOTCH;default:throw Error("Unknown type")}}makeNotch(){function e(e){return Vn("c",[Un(e*o/2,0),Un(e*o*3/4,r/2),Un(e*o,r)])+qn([Un(e*o,s)])+Vn("c",[Un(e*o/4,r/2),Un(e*o/2,r),Un(e*o,r)])+$n("h",e*n)+Vn("c",[Un(e*o/2,0),Un(e*o*3/4,-r/2),Un(e*o,-r)])+qn([Un(e*o,-s)])+Vn("c",[Un(e*o/4,-r/2),Un(e*o/2,-r),Un(e*o,-r)])}var t=this.NOTCH_WIDTH,i=this.NOTCH_HEIGHT,n=t/3,o=n/3,s=i/2,r=s/2,a=e(1),l=e(-1);return{type:this.SHAPES.NOTCH,width:t,height:i,pathLeft:a,pathRight:l}}makeInsideCorners(){var e=this.CORNER_RADIUS,t=jn("a","0 0,0",e,Un(-e,e)),i=jn("a","0 0,1",e,Un(-e,e));return{width:e,height:e,pathTop:t,pathBottom:jn("a","0 0,0",e,Un(e,e)),rightWidth:e,rightHeight:e,pathTopRight:i,pathBottomRight:jn("a","0 0,1",e,Un(e,e))}}generateSecondaryColour_(e){return zi("#000",e,.15)||e}generateTertiaryColour_(e){return zi("#000",e,.25)||e}createDom(e,t,i){super.createDom(e,t,i),e=I(ea.DEFS,{},e),e=I(ea.FILTER,{id:"blocklySelectedGlowFilter"+this.randomIdentifier,height:"160%",width:"180%",y:"-30%",x:"-40%"},e),I(ea.FEGAUSSIANBLUR,{in:"SourceGraphic",stdDeviation:this.SELECTED_GLOW_SIZE},e),t=I(ea.FECOMPONENTTRANSFER,{result:"outBlur"},e),I(ea.FEFUNCA,{type:"table",tableValues:"0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1"},t),I(ea.FEFLOOD,{"flood-color":this.SELECTED_GLOW_COLOUR,"flood-opacity":1,result:"outColor"},e),I(ea.FECOMPOSITE,{in:"outColor",in2:"outBlur",operator:"in",result:"outGlow"},e),this.selectedGlowFilterId=e.id,this.selectedGlowFilter=e,i&&i.style.setProperty("--blocklySelectedGlowFilter",`url(#${this.selectedGlowFilterId})`)}getCSS_(e){return[`${e} .blocklyText,`,`${e} .blocklyFlyoutLabelText {`,`font: ${this.FIELD_TEXT_FONTWEIGHT} ${this.FIELD_TEXT_FONTSIZE}pt ${this.FIELD_TEXT_FONTFAMILY};`,"}",`${e} .blocklyTextInputBubble textarea {`,"font-weight: normal;","}",`${e} .blocklyText {`,"fill: #fff;","}",`${e} .blocklyNonEditableField>rect:not(.blocklyDropdownRect),`,`${e} .blocklyEditableField>rect:not(.blocklyDropdownRect) {`,`fill: ${this.FIELD_BORDER_RECT_COLOUR};`,"}",`${e} .blocklyNonEditableField>text,`,`${e} .blocklyEditableField>text,`,`${e} .blocklyNonEditableField>g>text,`,`${e} .blocklyEditableField>g>text {`,"fill: #575E75;","}",`${e} .blocklyFlyoutLabelText {`,"fill: #575E75;","}",`${e} .blocklyText.blocklyBubbleText {`,"fill: #575E75;","}",`${e} .blocklyDraggable:not(.blocklyDisabled)`," .blocklyEditableField:not(.blocklyEditing):hover>rect,",`${e} .blocklyDraggable:not(.blocklyDisabled)`," .blocklyEditableField:not(.blocklyEditing):hover>.blocklyPath {","stroke: #fff;","stroke-width: 2;","}",`${e} .blocklyHtmlInput {`,`font-family: ${this.FIELD_TEXT_FONTFAMILY};`,`font-weight: ${this.FIELD_TEXT_FONTWEIGHT};`,"color: #575E75;","}",`${e} .blocklyDropdownText {`,"fill: #fff !important;","}",`${e}.blocklyWidgetDiv .blocklyMenuItem,`,`${e}.blocklyDropDownDiv .blocklyMenuItem {`,`font-family: ${this.FIELD_TEXT_FONTFAMILY};`,"}",`${e}.blocklyDropDownDiv .blocklyMenuItemContent {`,"color: #fff;","}",`${e} .blocklyHighlightedConnectionPathVisible {`,`stroke: ${this.SELECTED_GLOW_COLOUR};`,"}",`${e} .blocklyDisabledPattern > .blocklyOutlinePath {`,"fill: var(--blocklyDisabledPattern)","}",`${e} .blocklyInsertionMarker>.blocklyPath {`,`fill-opacity: ${this.INSERTION_MARKER_OPACITY};`,"stroke: none;","}",`${e} .blocklySelected>.blocklyPath.blocklyPathSelected {`,"fill: none;","filter: var(--blocklySelectedGlowFilter);","}"]}},Ng=class extends jp{constructor(e,t){super(e,t)}draw(){var e=this.block_.pathObject;e.beginDrawing(),this.drawOutline_(),this.drawInternals_(),this.updateConnectionHighlights(),e.setPath(this.outlinePath_+"\n"+this.inlinePath_),this.info_.RTL&&e.flipRTL(),this.recordSizeOnBlock_(),this.info_.outputConnection&&(e.outputShapeType=this.info_.outputConnection.shape.type),e.endDrawing()}drawOutline_(){this.info_.outputConnection&&this.info_.outputConnection.isDynamicShape&&!this.info_.hasStatementInput&&!this.info_.bottomRow.hasNextConnection?(this.drawFlatTop_(),this.drawRightDynamicConnection_(),this.drawFlatBottom_(),this.drawLeftDynamicConnection_()):super.drawOutline_()}drawLeft_(){this.info_.outputConnection&&this.info_.outputConnection.isDynamicShape?this.drawLeftDynamicConnection_():super.drawLeft_()}drawRightSideRow_(e){if(!(e.height<=0)){if(vp.isSpacer(e)){let n=e.precedesStatement;var t=e.followsStatement;if(n||t){let o=this.constants_.INSIDE_CORNERS;var i=o.rightHeight;return i=e.height-(n?i:0),t=t?o.pathBottomRight:"",e=i>0?$n("V",e.yPos+i):"",void(this.outlinePath_+=t+e+(n?o.pathTopRight:""))}}this.outlinePath_+=$n("V",e.yPos+e.height)}}drawRightDynamicConnection_(){if(!this.info_.outputConnection)throw Error("Cannot draw the output connection of a block that doesn't have one");this.outlinePath_+=this.info_.outputConnection.shape.pathRightDown(this.info_.outputConnection.height)}drawLeftDynamicConnection_(){if(!this.info_.outputConnection)throw Error("Cannot draw the output connection of a block that doesn't have one");this.positionOutputConnection_(),this.outlinePath_+=this.info_.outputConnection.shape.pathUp(this.info_.outputConnection.height),this.outlinePath_+="z"}drawFlatTop_(){var e=this.info_.topRow;this.positionPreviousConnection_(),this.outlinePath_+=Gn(e.xPos,this.info_.startY),this.outlinePath_+=$n("h",e.width)}drawFlatBottom_(){var e=this.info_.bottomRow;this.positionNextConnection_(),this.outlinePath_+=$n("V",e.baseline),this.outlinePath_+=$n("h",-e.width)}drawInlineInput_(e){this.positionInlineInputConnection_(e);var t=e.input.name;e.connectedBlock||this.info_.isInsertionMarker||(e=Hn(e.xPos+e.connectionWidth,e.centerline-e.height/2)+this.getInlineInputPath(e),this.block_.pathObject.setOutlinePath(t,e))}getInlineInputPath(e){var t=e.width-2*e.connectionWidth,i=e.height;return $n("h",t)+e.shape.pathRightDown(i)+$n("h",-t)+e.shape.pathUp(i)+"z"}drawStatementInput_(e){var t=e.getLastInput(),i=t.xPos+t.notchOffset+t.shape.width,n=this.constants_.INSIDE_CORNERS,o=t.shape.pathRight+$n("h",-(t.notchOffset-n.width))+n.pathTop,s=e.height-2*n.height;t=n.pathBottom+$n("h",t.notchOffset-n.width)+(t.connectedBottomNextConnection?"":t.shape.pathLeft),this.outlinePath_+=$n("H",i)+o+$n("v",s)+t+$n("H",e.xPos+e.width),this.positionStatementInputConnection_(e)}drawConnectionHighlightPath(e){var t=e.connectionModel;if(t.type===Xl.NEXT_STATEMENT||t.type===Xl.PREVIOUS_STATEMENT||t.type===Xl.OUTPUT_VALUE&&!e.isDynamicShape)return super.drawConnectionHighlightPath(e);e=t.type===Xl.INPUT_VALUE?Hn(e.connectionWidth,-e.height/2)+this.getInlineInputPath(e):Hn(e.width,-e.height/2)+e.shape.pathDown(e.height);var i,n,o=t.getSourceBlock();return null==(n=(i=o.pathObject).addConnectionHighlight)?void 0:n.call(i,t,e,t.getOffsetInBlock(),o.RTL)}},yg=class extends Wu{constructor(e,t,i,n,o,s,r){if(super(Wu.SKIP_SETUP),this.imageElement=this.clickHandler=null,this.flipRtl=this.isDirty_=this.EDITABLE=!1,this.altText="",i=Number(Ji(i)),t=Number(Ji(t)),isNaN(i)||isNaN(t))throw Error("Height and width values of an image field must cast to numbers.");if(i<=0||t<=0)throw Error("Height and width values of an image field must be greater than 0.");this.size_=new Fa(t,i+yg.Y_PADDING),this.imageHeight=i,"function"==typeof o&&(this.clickHandler=o),e!==Wu.SKIP_SETUP&&(r?this.configure_(r):"object"!=typeof n||null===n||Array.isArray(n)||!("alt"in n)&&!("flipRtl"in n)?(this.flipRtl=!!s,this.altText="string"==typeof n&&Ji(n)||""):this.configure_(n),this.setValue(Ji(e)))}configure_(e){super.configure_(e),e.flipRtl&&(this.flipRtl=e.flipRtl),e.alt&&(this.altText=Ji(e.alt))}initView(){this.imageElement=I(ea.IMAGE,{height:this.imageHeight+"px",width:this.size_.width+"px",alt:this.altText},this.fieldGroup_),this.imageElement.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",this.value_),this.fieldGroup_&&N(this.fieldGroup_,"blocklyImageField"),this.clickHandler&&(this.imageElement.style.cursor="pointer"),this.recomputeAriaContext()}updateSize_(){}doClassValidation_(e){return"string"!=typeof e?null:e}doValueUpdate_(e){this.value_=e,this.imageElement&&this.imageElement.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",this.value_),this.recomputeAriaContext()}getFlipRtl(){return this.flipRtl}setAlt(e){e!==this.altText&&(this.altText=e||"",this.imageElement&&this.imageElement.setAttribute("alt",this.altText))}isClickable(){return super.isClickable()&&!!this.clickHandler}showEditor_(){this.clickHandler&&this.clickHandler(this)}setOnClickHandler(e){this.clickHandler=e}getText_(){return this.altText}static fromJson(e){if(!e.src||!e.width||!e.height)throw Error("src, width, and height values for an image field arerequired. The width and height must be non-zero.");return new this(e.src,e.width,e.height,void 0,void 0,void 0,e)}getAriaTypeName(){return this.ariaTypeName||Zs.C.ARIA_TYPE_FIELD_IMAGE}getAriaValue(){return this.altText||null}computeAriaLabel(e){var t=this.getAriaValue();return this.isClickable()||!t?"":(e=e?this.getAriaTypeName():null)?`${e}: ${t}`:t}recomputeAriaContext(){if(!super.recomputeAriaContext())return!1;var e=this.getFocusableElement();if(!this.isClickable())return _(e,Hr.NONE),m(e,$r.LABEL),!1;var t=this.getAriaValue()||"";return f(e,$r.LABEL,t),!0}};yg.Y_PADDING=1,wn("field_image",yg),yg.prototype.DEFAULT_VALUE="";var Ag=class extends Wu{set size_(e){super.size_=e}get size_(){var e=super.size_;return e.width<14&&(e.width=14),e}constructor(e,t,i){super(Wu.SKIP_SETUP),this.spellcheck_=!0,this.htmlInput_=null,this.isTextValid_=this.isBeingEdited_=!1,this.onInputWrapper=this.onKeyDownWrapper=this.valueWhenEditorWasOpened_=this.warningIcon=null,this.fullBlockClickTarget_=!1,this.workspace_=null,this.SERIALIZABLE=!0,e!==Wu.SKIP_SETUP&&(i&&this.configure_(i),this.setValue(e),t&&this.setValidator(t))}configure_(e){super.configure_(e),void 0!==e.spellcheck&&(this.spellcheck_=e.spellcheck)}initView(){if(!this.getSourceBlock())throw new $u;this.isFullBlockField()||this.createBorderRect_(),this.createTextElement_(),this.fieldGroup_&&N(this.fieldGroup_,"blocklyField"),this.isFullBlockField()&&(this.clickTarget_=this.sourceBlock_.getSvgRoot()),this.fieldGroup_&&N(this.fieldGroup_,"blocklyInputField"),this.recomputeAriaContext()}isFullBlockField(){var e,t=this.getSourceBlock();if(!t)throw new $u;return this.fullBlockClickTarget_=!(null==(e=this.getConstants())||!e.FULL_BLOCK_FIELDS)&&t.isSimpleReporter()}createWarningIcon(){if(!this.sourceBlock_)return null;var e=this.getScaledBBox();return e=e.bottom-e.top,e=I(ea.SVG,{class:"blocklyInputWarning",viewBox:"-4 0 24 16",x:"0",y:"0",height:`${e}px`,width:`${e}px`}),I(ea.PATH,{class:"blocklyInputWarningIconShape",d:"M2,15Q-1,15 0.5,12L6.5,1.7Q8,-1 9.5,1.7L15.5,12Q17,15 14,15z"},e),I(ea.PATH,{class:"blocklyInputWarningIconSymbol",d:"m7,4.8v3.16l0.27,2.27h1.46l0.27,-2.27v-3.16z"},e),I(ea.RECT,{class:"blocklyInputWarningIconSymbol",x:"7",y:"11",height:"2",width:"2"},e),e}doValueInvalid_(e,t=!0){this.isBeingEdited_&&(this.isDirty_=!0,this.isTextValid_=!1,e=this.value_,this.value_=this.valueWhenEditorWasOpened_,this.sourceBlock_&&Ee()&&this.value_!==e&&t&&ue(new(_e(Fr.BLOCK_CHANGE))(this.sourceBlock_,"field",this.name||null,e,this.value_))),this.recomputeAriaContext()}doValueUpdate_(e){this.isTextValid_=this.isDirty_=!0,this.value_=e,this.recomputeAriaContext()}applyColour(){var e=this.getSourceBlock();if(!e)throw new $u;this.getConstants().FULL_BLOCK_FIELDS&&this.fieldGroup_&&(!this.isFullBlockField()&&this.borderRect_?(this.borderRect_.style.display="block",this.borderRect_.setAttribute("stroke",e.getColourTertiary())):e.pathObject.svgPath.setAttribute("fill",this.getConstants().FIELD_BORDER_RECT_COLOUR))}getSize(){var e;return null!=(e=this.getConstants())&&e.FULL_BLOCK_FIELDS&&(this.render_(),this.isDirty_=!1),super.getSize()}onLocationChange(){this.isBeingEdited_&&this.resizeEditor_()}render_(){super.render_();var e=this.getSourceBlock();if(!e)throw new $u;if(this.isBeingEdited_){let t=this.htmlInput_;this.renderWarningIcon(e.RTL,this.isTextValid_),this.isTextValid_?(A(t,"blocklyInvalidInput"),f(t,$r.INVALID,!1)):(N(t,"blocklyInvalidInput"),f(t,$r.INVALID,!0))}this.getConstants().FULL_BLOCK_FIELDS&&e.applyColour()}renderWarningIcon(e,t){var i=this.htmlInput_;if(this.warningIcon)if(t)i.style.paddingRight="",i.style.paddingLeft="",A(this.warningIcon,"blocklyInputWarningInvalid");else{var n=(t=this.getScaledBBox()).bottom-t.top;n=(t=!!this.borderRect_)?this.getConstants().FIELD_BORDER_RECT_X_PADDING:n/2,N(this.warningIcon,"blocklyInputWarningInvalid");let o=this.warningIcon.getBoundingClientRect().width;i.setAttribute("width",`${i.offsetWidth+o}px`);let s=o/1.5;e?i.style.paddingRight=`${s}px`:i.style.paddingLeft=`${s}px`,this.size_.width=o,e=t?this.getConstants().FIELD_TEXT_HEIGHT-this.getConstants().FIELD_BORDER_RECT_X_PADDING:0,this.updateSize_(n+e)}}setSpellcheck(e){e!==this.spellcheck_&&(this.spellcheck_=e,this.htmlInput_&&this.htmlInput_.setAttribute("spellcheck",this.spellcheck_))}showEditor_(e,t=!1,i=!0){this.workspace_=this.sourceBlock_.workspace,!t&&this.workspace_.options.modalInputs&&(vr||fr||mr)?this.showPromptEditor():this.showInlineEditor(t,i)}showPromptEditor(){ct(Zs.C.CHANGE_VALUE_TITLE,this.getText(),(e=>{null!==e&&this.setValue(this.getValueFromEditorText_(e)),this.onFinishEditing_(this.value_)}))}showInlineEditor(e,t){var i=this.getSourceBlock();if(!i)throw new $u;tn(this,i.RTL,this.widgetDispose_.bind(this),this.workspace_,t),this.htmlInput_=this.widgetCreate_(),this.isBeingEdited_=!0,this.valueWhenEditorWasOpened_=this.value_,e||(this.htmlInput_.focus({preventScroll:!0}),this.htmlInput_.select())}widgetCreate_(){var e=this.getSourceBlock();if(!e)throw new $u;Zs.B(!0);var t=qu,i=this.getClickTarget_();if(!i)throw Error("A click target has not been set.");N(i,"blocklyEditing"),(i=document.createElement("input")).className="blocklyHtmlInput",i.setAttribute("spellcheck",this.spellcheck_),this.warningIcon=this.createWarningIcon();var n=this.workspace_.getAbsoluteScale(),o=this.getConstants().FIELD_TEXT_FONTSIZE*n+"pt";if(t.style.fontSize=o,i.style.fontSize=o,o=Ag.BORDERRADIUS*n+"px",this.isFullBlockField()){let s=this.getScaledBBox();o=(s.bottom-s.top)/2+"px",e=e.getParent()?e.getParent().getColourTertiary():this.sourceBlock_.getColourTertiary(),i.style.border=1*n+"px solid "+e,t.style.borderRadius=o,t.style.transition="box-shadow 0.25s ease 0s",this.getConstants().FIELD_TEXTINPUT_BOX_SHADOW&&(t.style.boxShadow="rgba(255, 255, 255, 0.3) 0 0 0 "+4*n+"px"),e=(s.bottom-s.top)/4,this.warningIcon.style.paddingLeft=`${e}px`,this.warningIcon.style.paddingRight=`${e}px`}return i.style.borderRadius=o,this.warningIcon&&t.appendChild(this.warningIcon),t.appendChild(i),i.value=i.defaultValue=this.getEditorText_(this.value_),i.setAttribute("data-untyped-default-value",String(this.value_)),this.resizeEditor_(),this.bindInputEvents_(i),i}widgetDispose_(){this.isBeingEdited_=!1,this.isTextValid_=!0,this.forceRerender(),this.onFinishEditing_(this.value_),this.sourceBlock_&&Ee()&&null!==this.valueWhenEditorWasOpened_&&this.valueWhenEditorWasOpened_!==this.value_&&(ue(new(_e(Fr.BLOCK_CHANGE))(this.sourceBlock_,"field",this.name||null,this.valueWhenEditorWasOpened_,this.value_)),this.valueWhenEditorWasOpened_=null),Zs.B(!1),this.unbindInputEvents_();var e=qu.style;if(e.width="auto",e.height="auto",e.fontSize="",e.transition="",e.boxShadow="",this.htmlInput_=null,!(e=this.getClickTarget_()))throw Error("A click target has not been set.");A(e,"blocklyEditing"),this.recomputeAriaContext()}onFinishEditing_(){}bindInputEvents_(e){this.onKeyDownWrapper=r(e,"keydown",this,this.onHtmlInputKeyDown_),this.onInputWrapper=r(e,"input",this,this.onHtmlInputChange)}unbindInputEvents_(){this.onKeyDownWrapper&&(l(this.onKeyDownWrapper),this.onKeyDownWrapper=null),this.onInputWrapper&&(l(this.onInputWrapper),this.onInputWrapper=null)}onHtmlInputKeyDown_(e){if("Enter"===e.key)on(this),vi(),e.stopPropagation();else if("Escape"===e.key)this.setValue(this.htmlInput_.getAttribute("data-untyped-default-value"),!1),on(this),vi();else if("Tab"===e.key){var t;e.preventDefault();let i=null==(t=this.workspace_)?void 0:t.getNavigator(),n=e=>(e instanceof Ag||e instanceof Pd&&e.isSimpleReporter())&&e!==this.getSourceBlock();t=this;do{t=e.shiftKey?null==i?void 0:i.getOutNode(t):null==i?void 0:i.getInNode(t)}while(t&&!n(t));(t=t instanceof Pd&&t.isSimpleReporter()?t.getFields().next().value:t)instanceof Ag&&(on(this),vi(),e=t.getSourceBlock(),t.isFullBlockField()&&e&&e instanceof Pd?Zs.t().focusNode(e):Zs.t().focusNode(t),t.showEditor())}}onHtmlInputChange(){var e=this.value_;this.setValue(this.getValueFromEditorText_(this.htmlInput_.value),!1),this.sourceBlock_&&Ee()&&this.value_!==e&&ue(new(_e(Fr.BLOCK_FIELD_INTERMEDIATE_CHANGE))(this.sourceBlock_,this.name||null,e,this.value_))}setEditorValue_(e,t=!0){this.isDirty_=!0,this.isBeingEdited_&&(this.htmlInput_.value=this.getEditorText_(e)),this.setValue(e,t)}resizeEditor_(){Ze().then((()=>{var e=this.getSourceBlock();if(!e)throw new $u;var t=qu;if(t){var i=this.getScaledBBox();t.style.width=i.right-i.left+"px",t.style.height=i.bottom-i.top+"px",e=e.RTL?i.right-t.offsetWidth:i.left,i=i.top;var n=null==t?void 0:t.parentElement;n&&({x:e,y:i}=Ne(e,i,n)),t.style.left=`${e}px`,t.style.top=`${i}px`}}))}repositionForWindowResize(){var e=this.getSourceBlock(),t=this.workspace_;if(!(e instanceof Pd))return!1;if(this.resizeEditor_(),!(e=this.getClickTarget_())||!t)return!0;e=xa.from(e.getBoundingClientRect());var i=we(t,e.getOrigin()),n=t.scale;return t.scrollBoundsIntoView(xa.createFromPoint(i,e.getWidth()/n,e.getHeight()/n)),!0}positionTextElement_(e,t){var i=2*e+t;super.positionTextElement_(e+(i<14?(14-i)/2:0),t)}getText_(){return this.isBeingEdited_&&this.htmlInput_?this.htmlInput_.value:null}getEditorText_(e){return`${e}`}getValueFromEditorText_(e){return e}getAriaTypeName(){return this.ariaTypeName||Zs.C.ARIA_TYPE_FIELD_INPUT}getAriaValue(){return this.getText()||Zs.C.FIELD_LABEL_EMPTY}recomputeAriaContext(){if(!super.recomputeAriaContext())return!1;var e,t=this.getFocusableElement(),i=this.computeAriaLabel(!0),n=this.isCurrentlyEditable()&&!(null!=(e=this.getSourceBlock())&&e.isInFlyout);if(this.isFullBlockField()){if(e=$t(this.getSourceBlock(),Xr.STANDARD,i),n){let t;i=e.split(", "),n=void 0===(n=Xt(this.getSourceBlock()))?-1:i.indexOf(n),i[n=-1===n?0:n+1]=Zs.C.FIELD_LABEL_EDIT_PREFIX.replace("%1",null!=(t=i[n])?t:""),i=i.join(", ")}}else n&&(i=Zs.C.FIELD_LABEL_EDIT_PREFIX.replace("%1",i));return f(t,$r.LABEL,i),!0}};Ag.BORDERRADIUS=4,g("\n .blocklyInputWarningIconShape {\n stroke: #1f1f1f;\n stroke-width: 1px;\n fill: none;\n }\n .blocklyInputWarningIconSymbol {\n fill: #1f1f1f;\n }\n .blocklyInputWarning {\n display: none;\n position: absolute;\n }\n .blocklyInputWarning.blocklyInputWarningInvalid {\n display: inline;\n }\n");var kg=class extends yp{constructor(e){super(e)}endsWithElemSpacer(){return!1}hasLeftSquareCorner(e){return!!e.outputConnection}hasRightSquareCorner(e){return!!e.outputConnection&&!e.statementInputCount&&!e.nextConnection}},Sg=class extends Gp{constructor(e,t){if(super(e,t),this.connectedBottomNextConnection=!1,this.connectedBlock){for(e=this.connectedBlock;t=e.getNextBlock();)e=t;e.nextConnection||(this.height=this.connectedBlockHeight,this.connectedBottomNextConnection=!0)}}},Og=class extends Ip{constructor(e){super(e),this.width=this.height=0,this.type|=vp.getType("RIGHT_CONNECTION")}},Rg=class extends Wp{constructor(e){super(e)}endsWithElemSpacer(){return!1}hasLeftSquareCorner(e){var t=(e.hat?"cap"===e.hat:this.constants_.ADD_START_HATS)&&!e.outputConnection&&!e.previousConnection;return!!e.outputConnection||t}hasRightSquareCorner(e){return!!e.outputConnection&&!e.statementInputCount&&!e.nextConnection}},wg=class extends zp{constructor(e,t){super(e,t),this.isInline=!0,this.renderer_=e,this.constants_=this.renderer_.getConstants(),this.topRow=new Rg(this.constants_),this.bottomRow=new kg(this.constants_),this.isMultiRow=!t.getInputsInline()||t.isCollapsed(),this.hasStatementInput=t.statementInputCount>0,this.rightSide=this.outputConnection?new Og(this.constants_):null,this.rightAlignedDummyInputs=new WeakMap}getRenderer(){return this.renderer_}measure(){this.createRows_(),this.addElemSpacing_(),this.addRowSpacing_(),this.adjustXPosition_(),this.computeBounds_(),this.alignRowElements_(),this.finalize_()}shouldStartNewRow_(e,t){return!!t&&(t instanceof Jc||e instanceof Qc||t instanceof Qc||(e instanceof Zs.go||e instanceof Kc||e instanceof Jc)&&(!this.isInline||this.isMultiRow))}getDesiredRowWidth_(e){return e.hasStatement?this.width-this.startX-(this.constants_.INSIDE_CORNERS.rightWidth||0):super.getDesiredRowWidth_(e)}getInRowSpacing_(e,t){return e&&t||!this.outputConnection||!this.outputConnection.isDynamicShape||this.hasStatementInput||this.bottomRow.hasNextConnection?!e&&t&&vp.isStatementInput(t)?this.constants_.STATEMENT_INPUT_PADDING_LEFT:e&&vp.isLeftRoundedCorner(e)&&t&&(vp.isPreviousConnection(t)||vp.isNextConnection(t))?t.notchOffset-this.constants_.CORNER_RADIUS:e&&vp.isLeftSquareCorner(e)&&t&&vp.isHat(t)||e&&vp.isField(e)&&0===e.width?this.constants_.NO_PADDING:this.constants_.MEDIUM_PADDING:this.constants_.NO_PADDING}getSpacerRowHeight_(e,t){if(vp.isTopRow(e)&&vp.isBottomRow(t))return this.constants_.EMPTY_BLOCK_SPACER_HEIGHT;var i=vp.isInputRow(e)&&e.hasStatement,n=vp.isInputRow(t)&&t.hasStatement;return n||i?(e=Math.max(this.constants_.NOTCH_HEIGHT,this.constants_.INSIDE_CORNERS.rightHeight||0),n&&i?Math.max(e,this.constants_.DUMMY_INPUT_MIN_HEIGHT):e):vp.isTopRow(e)?e.hasPreviousConnection||this.outputConnection&&!this.hasStatementInput?this.constants_.NO_PADDING:Math.abs(this.constants_.NOTCH_HEIGHT-this.constants_.CORNER_RADIUS):vp.isBottomRow(t)?this.outputConnection?!t.hasNextConnection&&this.hasStatementInput?Math.abs(this.constants_.NOTCH_HEIGHT-this.constants_.CORNER_RADIUS):this.constants_.NO_PADDING:Math.max(this.topRow.minHeight,Math.max(this.constants_.NOTCH_HEIGHT,this.constants_.CORNER_RADIUS))-this.constants_.CORNER_RADIUS:this.constants_.MEDIUM_PADDING}getSpacerRowWidth_(e,t){var i=this.width-this.startX;return vp.isInputRow(e)&&e.hasStatement||vp.isInputRow(t)&&t.hasStatement?Math.max(i,this.constants_.STATEMENT_INPUT_SPACER_MIN_WIDTH):i}getElemCenterline_(e,t){if(e.hasStatement&&!vp.isSpacer(t)&&!vp.isStatementInput(t))return e.yPos+this.constants_.EMPTY_STATEMENT_INPUT_HEIGHT/2;if(vp.isInlineInput(t)){let i=t.connectedBlock;if(i&&i.outputConnection&&i.nextConnection)return e.yPos+i.height/2}return super.getElemCenterline_(e,t)}addInput_(e,t){if((e instanceof Kc||e instanceof Jc)&&t.hasDummyInput&&t.align===Zs.Xn.LEFT&&e.align===Zs.Xn.RIGHT)this.rightAlignedDummyInputs.set(t,e);else if(e instanceof Qc)return t.elements.push(new Sg(this.constants_,e)),t.hasStatement=!0,void(null===t.align&&(t.align=e.align));super.addInput_(e,t)}addAlignmentPadding_(e,t){if(this.rightAlignedDummyInputs.get(e)){let i;for(let t=0;t<e.elements.length;t++){let n=e.elements[t];if(vp.isSpacer(n)&&(i=n),vp.isField(n)&&n.parentInput===this.rightAlignedDummyInputs.get(e))break}if(i)return i.width+=t,void(e.width+=t)}super.addAlignmentPadding_(e,t)}adjustXPosition_(){var e=this.constants_.NOTCH_OFFSET_LEFT+this.constants_.NOTCH_WIDTH,t=e;for(let o=2;o<this.rows.length-1;o+=2){var i=this.rows[o-1];let s=this.rows[o];var n=this.rows[o+1];if(i=2===o?!!this.topRow.hasPreviousConnection:!!i.followsStatement,n=o+2>=this.rows.length-1?!!this.bottomRow.hasNextConnection:!!n.precedesStatement,vp.isInputRow(s)&&s.hasStatement){let i,n;s.measure(),t=s.width-(null!=(n=null==(i=s.getLastInput())?void 0:i.width)?n:0)+e}else if(i&&(2===o||n)&&vp.isInputRow(s)&&!s.hasStatement){n=s.xPos,i=null;for(let e=0;e<s.elements.length;e++){let o=s.elements[e];vp.isSpacer(o)&&(i=o),!(i&&(vp.isField(o)||vp.isInput(o))&&n<t)||vp.isField(o)&&(o.field instanceof xd||o.field instanceof yg)||(i.width+=t-n),n+=o.width}}}}finalizeOutputConnection_(){if(this.outputConnection&&this.outputConnection.isDynamicShape){var e=this.outputConnection.shape;if("isDynamic"in e&&e.isDynamic){for(var t=0,i=0;i<this.rows.length;i++){let e=this.rows[i];e.yPos=t,t+=e.height}this.height=t,i=this.bottomRow.hasNextConnection?this.height-this.bottomRow.descenderHeight:this.height,t=e.height(i),i=e.width(i),this.outputConnection.height=t,this.outputConnection.width=i,this.outputConnection.startX=i,this.outputConnection.connectionOffsetY=e.connectionOffsetY(t),this.outputConnection.connectionOffsetX=e.connectionOffsetX(i),e=0,this.hasStatementInput||this.bottomRow.hasNextConnection||(e=i,this.rightSide.height=t,this.rightSide.width=e,this.rightSide.centerline=t/2,this.rightSide.xPos=this.width+e),this.startX=i,this.width+=i+e,this.widthWithChildren+=i+e}}}finalizeHorizontalAlignment_(){if(this.outputConnection&&!this.hasStatementInput&&!this.bottomRow.hasNextConnection){for(var e=0,t=0;t<this.rows.length;t++){var i=this.rows[t];if(!vp.isInputRow(i))continue;e=i.elements[i.elements.length-2];let n=this.getNegativeSpacing_(i.elements[1]),o=this.getNegativeSpacing_(e);e=n+o;let s=this.constants_.MIN_BLOCK_WIDTH+2*this.outputConnection.width;this.width-e<s&&(n=(e=this.width-s)/2,o=e/2),i.elements.unshift(new Lp(this.constants_,-n)),i.elements.push(new Lp(this.constants_,-o))}if(e)for(this.width-=e,this.widthWithChildren-=e,this.rightSide.xPos-=e,t=0;t<this.rows.length;t++)i=this.rows[t],vp.isTopOrBottomRow(i)&&(i.elements[1].width-=e),i.width-=e,i.widthWithConnectedBlocks-=e}}getNegativeSpacing_(e){if(!e||!this.outputConnection)return 0;var t=this.outputConnection.width,i=this.outputConnection.shape.type,n=this.constants_;if(this.inputRows.length>1)return i===n.SHAPES.ROUND?(i=this.constants_.MAX_DYNAMIC_CONNECTION_SHAPE_WIDTH,i=this.height/2>i?i:this.height/2,t-(i=ys(i,i-this.constants_.SMALL_PADDING))):0;if(vp.isInlineInput(e)){var o=e.connectedBlock;return null==(e=o?o.pathObject.outputShapeType:e.shape.type)||o&&o.outputConnection&&(o.statementInputCount||o.nextConnection)||i===n.SHAPES.HEXAGONAL&&i!==e?0:t-this.constants_.SHAPE_IN_SHAPE_PADDING[i][e]}if(vp.isField(e)){if(i===n.SHAPES.ROUND&&e.field instanceof Ag)return t-2.75*n.GRID_UNIT;let s=o=this.constants_.SHAPE_IN_SHAPE_PADDING[i][0];return i===n.SHAPES.ROUND&&(i=ys(t,e.height/2)+n.SMALL_PADDING,s=Math.min(t,Math.max(o,i))),t-s}return vp.isIcon(e)?this.constants_.SMALL_PADDING:0}finalizeVerticalAlignment_(){if(!this.outputConnection)for(let n=2;n<this.rows.length-1;n+=2){let o=this.rows[n-1],s=this.rows[n],r=this.rows[n+1];var e=2===n,t=n+2>=this.rows.length-1?!!this.bottomRow.hasNextConnection:!!r.precedesStatement;if(e?this.topRow.hasPreviousConnection:o.followsStatement){var i=s.elements[1];if(i=3===s.elements.length&&i instanceof Op&&(i.field instanceof xd||i.field instanceof yg),!e&&i)o.height-=this.constants_.SMALL_PADDING,r.height-=this.constants_.SMALL_PADDING,s.height-=this.constants_.MEDIUM_PADDING;else if(e||t){if(t){for(e=!1,t=0;t<s.elements.length;t++)if(i=s.elements[t],vp.isInlineInput(i)&&i.connectedBlock&&!i.connectedBlock.isShadow()&&i.connectedBlock.getHeightWidth().height>=40){e=!0;break}e&&(o.height-=this.constants_.SMALL_PADDING,r.height-=this.constants_.SMALL_PADDING)}}else o.height+=this.constants_.SMALL_PADDING}}}finalize_(){this.finalizeOutputConnection_(),this.finalizeHorizontalAlignment_(),this.finalizeVerticalAlignment_(),super.finalize_(),this.rightSide&&(this.widthWithChildren+=this.rightSide.width)}},Lg=class extends Xp{constructor(e,t,i){super(e,t,i),this.svgPathSelected=null,this.outlines=new Map,this.remainingOutlines=new Set,this.outputShapeType=null,this.constants=i}setPath(e){super.setPath(e),this.svgPathSelected&&this.svgPathSelected.setAttribute("d",e)}applyColour(e){super.applyColour(e);var t=e.getParent();e.isShadow()&&t&&this.svgPath.setAttribute("stroke",t.getColourTertiary());for(let e of this.outlines.values())e.setAttribute("fill",this.style.colourTertiary)}flipRTL(){super.flipRTL();for(let e of this.outlines.values())e.setAttribute("transform","scale(-1 1)");var e;null==(e=this.svgPathSelected)||e.setAttribute("transform","scale(-1 1)")}updateSelected(e){this.setClass_("blocklySelected",e),e?this.svgPathSelected||(this.svgPathSelected=I(ea.PATH,{class:"blocklyPath blocklyPathSelected",stroke:this.svgPath.getAttribute("stroke")||"",fill:this.svgPath.getAttribute("fill")||"",d:this.svgPath.getAttribute("d")||"",transform:this.svgPath.getAttribute("transform")||"",role:Hr.NONE},this.svgRoot),this.svgRoot.appendChild(this.svgPathSelected)):this.svgPathSelected&&(this.svgRoot.removeChild(this.svgPathSelected),this.svgPathSelected=null)}beginDrawing(){this.remainingOutlines.clear();for(let e of this.outlines.keys())this.remainingOutlines.add(e)}endDrawing(){if(this.remainingOutlines.size)for(let e of this.remainingOutlines)this.removeOutlinePath(e);this.remainingOutlines.clear()}setOutlinePath(e,t){(e=this.getOutlinePath(e)).setAttribute("d",t),e.setAttribute("fill",this.style.colourTertiary)}getOutlinePath(e){if(!this.outlines.has(e)){let t=I(ea.PATH,{class:"blocklyOutlinePath",d:""},this.svgRoot);f(t,$r.HIDDEN,!0),this.outlines.set(e,t)}return this.remainingOutlines.delete(e),this.outlines.get(e)}removeOutlinePath(e){var t,i;null==(t=this.outlines.get(e))||null==(i=t.parentNode)||i.removeChild(this.outlines.get(e)),this.outlines.delete(e)}},Dg=class extends Yp{constructor(e){super(e)}makeConstants_(){return new Ig}makeRenderInfo_(e){return new wg(this,e)}makeDrawer_(e,t){return new Ng(e,t)}makePathObject(e,t){return new Lg(e,t,this.getConstants())}getConstants(){return this.constants_}shouldHighlightConnection(e){return super.shouldHighlightConnection(e)||e.type===Xl.INPUT_VALUE}};_s("zelos",Dg);var xg=class{constructor(e){this.staticConn=this.draggedConn=this.markerConn=this.fadedBlock=null,this.workspace=e.workspace,this.insertionMarker=new cg}previewReplacement(e,t,i){Zs.Ub++;try{this.hidePreview(),this.fadedBlock=i,i.fadeForReplacement(!0),this.workspace.getRenderer().shouldHighlightConnection(t)&&(t.highlight(),this.staticConn=t)}finally{Zs.Ub--}}previewConnection(e,t){if(e!==this.draggedConn||t!==this.staticConn){Zs.Ub++;try{this.hidePreview(),this.shouldUseMarkerPreview(e,t)&&(this.shouldUseFastInsertionMarkers()?this.insertionMarker.show(t,e):this.markerConn=this.previewMarker(e,t)),this.workspace.getRenderer().shouldHighlightConnection(t)&&t.highlight(),this.workspace.getRenderer().shouldHighlightConnection(e)&&e.highlight(),this.draggedConn=e,this.staticConn=t}finally{Zs.Ub--}}}shouldUseMarkerPreview(e,t){return t.type===Xl.PREVIOUS_STATEMENT||t.type===Xl.NEXT_STATEMENT||!(this.workspace.getRenderer()instanceof Dg)}previewMarker(e,t){var i=e.getSourceBlock(),n=this.createInsertionMarker(i),o=this.getMatchingConnection(i,n,e);if(!o)return null;n.queueRender(),et(),o.connect(t);var s={x:t.x-o.x,y:t.y-o.y},r=o.getOffsetInBlock().clone();return Ze().then((()=>{if(!n.isDeadOrDying()){Zs.Ub++;try{null==n||n.positionNearConnection(o,s,r),null==n||n.getSvgRoot().setAttribute("visibility","visible")}finally{Zs.Ub--}}})),o}serializeBlockToInsertionMarker(e){var t=Dt(e,{addCoordinates:!1,addInputBlocks:!1,addNextBlocks:!1,doFullSerialization:!1});if(!t)throw Error(`Failed to serialize source block. ${e.toDevString()}`);return t}createInsertionMarker(e){e=this.serializeBlockToInsertionMarker(e),e=Ft(e,this.workspace);for(let t of e.getDescendants(!1))t.setInsertionMarker(!0);return e.initSvg(),e.getSvgRoot().setAttribute("visibility","hidden"),e}getMatchingConnection(e,t,i){if(e=e.getConnections_(!0),t=t.getConnections_(!0),e.length!==t.length)return null;for(let n=0;n<e.length;n++)if(e[n]===i)return t[n];return null}hidePreview(){Zs.Ub++;try{this.staticConn&&(this.staticConn.unhighlight(),this.staticConn=null),this.draggedConn&&(this.draggedConn.unhighlight(),this.draggedConn=null),this.fadedBlock&&(this.fadedBlock.fadeForReplacement(!1),this.fadedBlock=null),this.shouldUseFastInsertionMarkers()?this.insertionMarker.hide():this.markerConn&&(this.hideInsertionMarker(this.markerConn),this.draggedConn=this.markerConn=null)}finally{Zs.Ub--}}hideInsertionMarker(e){var t,i=e.getSourceBlock(),n=i.outputConnection;if(null!=(t=i.previousConnection)&&t.targetConnection||null!=n&&n.targetConnection)i.unplug(!0);else{let t;null==(t=e.targetBlock())||t.unplug(!1)}i.dispose()}dispose(){this.hidePreview()}shouldUseFastInsertionMarkers(){var e=this.workspace.getRenderer();return e.constructor===vg||e.constructor===bg||e.constructor===Dg||xg.useFastInsertionMarkers}};xg.useFastInsertionMarkers=!1,te(ya.CONNECTION_PREVIEWER,"default",xg);var Fg={};Fg.Align=Zs.Xn,Fg.DummyInput=Kc,Fg.EndRowInput=Jc,Fg.Input=Yc,Fg.StatementInput=Qc,Fg.ValueInput=Zs.go,Fg.inputTypes=Zs.je;var Mg=!1;Zs.zq=class{constructor(e){this.forBlock=Object.create(null),this.FUNCTION_NAME_PLACEHOLDER_="{leCUI8hutHZI4480Dc}",this.STATEMENT_SUFFIX=this.STATEMENT_PREFIX=this.INFINITE_LOOP_TRAP=null,this.INDENT=" ",this.COMMENT_WRAP=60,this.ORDER_OVERRIDES=[],this.isInitialized=null,this.RESERVED_WORDS_="",this.definitions_=Object.create(null),this.functionNames_=Object.create(null),this.nameDB_=void 0,this.name_=e,this.FUNCTION_NAME_PLACEHOLDER_REGEXP_=new RegExp(this.FUNCTION_NAME_PLACEHOLDER_,"g")}workspaceToCode(e){e||(console.warn("No workspace specified in workspaceToCode call. Guessing."),e=Ta);var t=[];this.init(e),e=e.getTopBlocks(!0);for(let i,n=0;i=e[n];n++){let e=this.blockToCode(i);Array.isArray(e)&&(e=e[0]),e&&(i.outputConnection&&(e=this.scrubNakedValue(e),this.STATEMENT_PREFIX&&!i.suppressPrefixSuffix&&(e=this.injectId(this.STATEMENT_PREFIX,i)+e),this.STATEMENT_SUFFIX&&!i.suppressPrefixSuffix&&(e+=this.injectId(this.STATEMENT_SUFFIX,i))),t.push(e))}return t=t.join("\n"),(t=(t=(t=this.finish(t)).replace(/^\s+\n/,"")).replace(/\n\s+$/,"\n")).replace(/[ \t]+\n/g,"\n")}prefixLines(e,t){return t+e.replace(/(?!\n$)\n/g,"\n"+t)}allNestedComments(e){var t=[];e=e.getDescendants(!0);for(let i=0;i<e.length;i++){let n=e[i].getCommentText();n&&t.push(n)}return t.length&&t.push(""),t.join("\n")}blockToCode(e,t){if(!1===this.isInitialized&&console.warn("CodeGenerator init was not called before blockToCode was called."),!e)return"";if(!e.isEnabled())return t?"":this.blockToCode(e.getNextBlock());if(e.isInsertionMarker())return t?"":this.blockToCode(e.getChildren(!1)[0]);var i=this.forBlock[e.type];if("function"!=typeof i)throw Error(`${this.name_} generator does not know how to generate code for block type "${e.type}".`);if(i=i.call(e,e,this),Array.isArray(i)){if(!e.outputConnection)throw TypeError("Expecting string from statement block: "+e.type);return[this.scrub_(e,i[0],t),i[1]]}if("string"==typeof i)return this.STATEMENT_PREFIX&&!e.suppressPrefixSuffix&&(i=this.injectId(this.STATEMENT_PREFIX,e)+i),this.STATEMENT_SUFFIX&&!e.suppressPrefixSuffix&&(i+=this.injectId(this.STATEMENT_SUFFIX,e)),this.scrub_(e,i,t);if(null===i)return"";throw SyntaxError("Invalid code generated: "+i)}valueToCode(e,t,i){if(isNaN(i))throw TypeError("Expecting valid order from block: "+e.type);var n=e.getInputTargetBlock(t);if(!n&&!e.getInput(t))throw ReferenceError(`Input "${t}" doesn't exist on "${e.type}"`);if(!n)return"";if(""===(t=this.blockToCode(n)))return"";if(!Array.isArray(t))throw TypeError(`Expecting tuple from value block: ${n.type} See docs.blockly.com/guides/create-custom-blocks/code-generation/overview/ for more information`);if(e=t[0],t=t[1],isNaN(t))throw TypeError("Expecting valid order from value block: "+n.type);if(!e)return"";n=!1;var o=Math.floor(i),s=Math.floor(t);if(o<=s&&(o!==s||0!==o&&99!==o))for(n=!0,o=0;o<this.ORDER_OVERRIDES.length;o++)if(this.ORDER_OVERRIDES[o][0]===i&&this.ORDER_OVERRIDES[o][1]===t){n=!1;break}return n&&(e="("+e+")"),e}statementToCode(e,t){var i=e.getInputTargetBlock(t);if(!i&&!e.getInput(t))throw ReferenceError(`Input "${t}" doesn't exist on "${e.type}"`);if("string"!=typeof(e=this.blockToCode(i)))throw TypeError("Expecting code from statement block: "+(i&&i.type));return e&&(e=this.prefixLines(e,this.INDENT)),e}addLoopTrap(e,t){return this.INFINITE_LOOP_TRAP&&(e=this.prefixLines(this.injectId(this.INFINITE_LOOP_TRAP,t),this.INDENT)+e),this.STATEMENT_SUFFIX&&!t.suppressPrefixSuffix&&(e=this.prefixLines(this.injectId(this.STATEMENT_SUFFIX,t),this.INDENT)+e),this.STATEMENT_PREFIX&&!t.suppressPrefixSuffix&&(e+=this.prefixLines(this.injectId(this.STATEMENT_PREFIX,t),this.INDENT)),e}injectId(e,t){return t=t.id.replace(/\$/g,"$$$$"),e.replace(/%1/g,"'"+t+"'")}addReservedWords(e){this.RESERVED_WORDS_+=e+","}provideFunction_(e,t){if(!this.definitions_[e]){let i,n=this.nameDB_.getDistinctName(e,Zs.P.PROCEDURE);for(this.functionNames_[e]=n,Array.isArray(t)&&(t=t.join("\n")),t=t.trim().replace(this.FUNCTION_NAME_PLACEHOLDER_REGEXP_,n);i!==t;)i=t,t=t.replace(/^(( {2})*) {2}/gm,"$1\0");t=t.replace(/\0/g,this.INDENT),this.definitions_[e]=t}return this.functionNames_[e]}getVariableName(e){return this.getName(e,Zs.P.VARIABLE)}getProcedureName(e){return this.getName(e,Zs.P.PROCEDURE)}getName(e,t){if(!this.nameDB_)throw Error("Name database is not defined. You must initialize `nameDB_` in your generator class and call `init` first.");return this.nameDB_.getName(e,t)}init(){this.definitions_=Object.create(null),this.functionNames_=Object.create(null)}scrub_(e,t){return t}finish(e){return this.definitions_=Object.create(null),this.functionNames_=Object.create(null),e}scrubNakedValue(e){return e}};var Pg=class extends up{constructor(e){super(e)}setMetrics_(e){if(this.isVisible()){var t=this.workspace_.getMetricsManager(),i=t.getScrollMetrics(),n=t.getViewMetrics();t=t.getAbsoluteMetrics(),"number"==typeof e.y&&(this.workspace_.scrollY=-(i.top+(i.height-n.height)*e.y)),this.workspace_.translate(this.workspace_.scrollX+t.left,this.workspace_.scrollY+t.top)}}getX(){if(!this.isVisible())return 0;var e=this.targetWorkspace.getMetricsManager(),t=e.getAbsoluteMetrics(),i=e.getViewMetrics();return e=e.getToolboxMetrics(),this.targetWorkspace.toolboxPosition===this.toolboxPosition_?this.targetWorkspace.getToolbox()?this.toolboxPosition_===Ya.LEFT?e.width:i.width-this.getWidth():this.toolboxPosition_===Ya.LEFT?0:i.width:this.toolboxPosition_===Ya.LEFT?0:i.width+t.left-this.getWidth()}getY(){return 0}position(){if(this.isVisible()&&this.targetWorkspace.isVisible()){var e=this.targetWorkspace.getMetricsManager().getViewMetrics();this.height_=e.height;var t=this.getWidth()-this.CORNER_RADIUS;this.setBackgroundPath(t,e.height-2*this.CORNER_RADIUS),e=this.getX(),t=this.getY(),this.positionAt_(this.getWidth(),this.getHeight(),e,t)}}setBackgroundPath(e,t){var i=this.toolboxPosition_===Ya.RIGHT,n=e+this.CORNER_RADIUS;(n=["M "+(i?n:0)+",0"]).push("h",i?-e:e),n.push("a",this.CORNER_RADIUS,this.CORNER_RADIUS,0,0,i?0:1,i?-this.CORNER_RADIUS:this.CORNER_RADIUS,this.CORNER_RADIUS),n.push("v",Math.max(0,t)),n.push("a",this.CORNER_RADIUS,this.CORNER_RADIUS,0,0,i?0:1,i?this.CORNER_RADIUS:-this.CORNER_RADIUS,this.CORNER_RADIUS),n.push("h",i?e:-e),n.push("z"),this.svgBackground_.setAttribute("d",n.join(" "))}scrollToStart(){var e;null==(e=this.workspace_.scrollbar)||e.setY(0)}wheel_(e){var t=d(e);if(t.y){let e,i=this.workspace_.getMetricsManager(),n=i.getScrollMetrics();t=i.getViewMetrics().top-n.top+t.y,null==(e=this.workspace_.scrollbar)||e.setY(t),sn(this.workspace_),vi()}e.preventDefault(),e.stopPropagation()}layout_(e){this.workspace_.scale=this.targetWorkspace.scale;var t=this.MARGIN,i=this.RTL?t:t+this.tabWidth_;for(let n of e)n.getElement().moveBy(i,t),t+=n.getElement().getBoundingRectangle().getHeight()}getClientRect(){if(!this.svgGroup_||this.autoClose||!this.isVisible())return null;var e=this.svgGroup_.getBoundingClientRect(),t=e.left;return this.toolboxPosition_===Ya.LEFT?new xa(-1e9,1e9,-1e9,t+e.width):new xa(-1e9,1e9,t,1e9)}reflowInternal_(){this.workspace_.scale=this.getFlyoutScale();var e=this.getContents().reduce(((e,t)=>Math.max(e,t.getElement().getBoundingRectangle().getWidth())),0);if(e+=1.5*this.MARGIN+this.tabWidth_,e*=this.workspace_.scale,e+=Ha.scrollbarThickness,this.getWidth()!==e){if(this.RTL)for(let t of this.getContents()){let i=t.getElement().getBoundingRectangle().left,n=e/this.workspace_.scale-t.getElement().getBoundingRectangle().getWidth()-this.MARGIN-this.tabWidth_;t.getElement().moveBy(n-i,0)}this.targetWorkspace.scrollbar||this.autoClose||this.targetWorkspace.getFlyout()!==this||this.toolboxPosition_!==Ya.LEFT||this.targetWorkspace.translate(this.targetWorkspace.scrollX+e,this.targetWorkspace.scrollY),this.width_=e,this.position(),this.targetWorkspace.resizeContents(),this.targetWorkspace.recordDragTargets()}}};Pg.registryName="verticalFlyout",te(ya.FLYOUTS_VERTICAL_TOOLBOX,"default",Pg);var Bg=class extends up{constructor(e){super(e),this.horizontalLayout=!0}setMetrics_(e){if(this.isVisible()){var t=this.workspace_.getMetricsManager(),i=t.getScrollMetrics(),n=t.getViewMetrics();t=t.getAbsoluteMetrics(),"number"==typeof e.x&&(this.workspace_.scrollX=-(i.left+(i.width-n.width)*e.x)),this.workspace_.translate(this.workspace_.scrollX+t.left,this.workspace_.scrollY+t.top)}}getX(){return 0}getY(){if(!this.isVisible())return 0;var e=this.targetWorkspace.getMetricsManager(),t=e.getAbsoluteMetrics(),i=e.getViewMetrics();e=e.getToolboxMetrics();var n=this.toolboxPosition_===Ya.TOP;return this.targetWorkspace.toolboxPosition===this.toolboxPosition_?this.targetWorkspace.getToolbox()?n?e.height:i.height-this.getHeight():n?0:i.height:n?0:i.height+t.top-this.getHeight()}position(){if(this.isVisible()&&this.targetWorkspace.isVisible()){var e=this.targetWorkspace.getMetricsManager().getViewMetrics();this.width_=e.width,e=e.width-2*this.CORNER_RADIUS;var t=this.getHeight()-this.CORNER_RADIUS;this.setBackgroundPath(e,t),e=this.getX(),t=this.getY(),this.positionAt_(this.getWidth(),this.getHeight(),e,t)}}setBackgroundPath(e,t){var i=this.toolboxPosition_===Ya.TOP,n=["M 0,"+(i?0:this.CORNER_RADIUS)];i?(n.push("h",e+2*this.CORNER_RADIUS),n.push("v",t),n.push("a",this.CORNER_RADIUS,this.CORNER_RADIUS,0,0,1,-this.CORNER_RADIUS,this.CORNER_RADIUS),n.push("h",-e),n.push("a",this.CORNER_RADIUS,this.CORNER_RADIUS,0,0,1,-this.CORNER_RADIUS,-this.CORNER_RADIUS)):(n.push("a",this.CORNER_RADIUS,this.CORNER_RADIUS,0,0,1,this.CORNER_RADIUS,-this.CORNER_RADIUS),n.push("h",e),n.push("a",this.CORNER_RADIUS,this.CORNER_RADIUS,0,0,1,this.CORNER_RADIUS,this.CORNER_RADIUS),n.push("v",t),n.push("h",-e-2*this.CORNER_RADIUS)),n.push("z"),this.svgBackground_.setAttribute("d",n.join(" "))}scrollToStart(){var e;null==(e=this.workspace_.scrollbar)||e.setX(this.RTL?1/0:0)}wheel_(e){var t=d(e);if(t=t.x||t.y){let e,i=this.workspace_.getMetricsManager(),n=i.getScrollMetrics();t=i.getViewMetrics().left-n.left+t,null==(e=this.workspace_.scrollbar)||e.setX(t),sn(this.workspace_),vi()}e.preventDefault(),e.stopPropagation()}layout_(e){this.workspace_.scale=this.targetWorkspace.scale;var t=this.MARGIN,i=t+this.tabWidth_;this.RTL&&(e=e.reverse());for(let n of e)e=n.getElement().getBoundingRectangle(),e=this.RTL?i+e.getWidth():i,n.getElement().moveBy(e,t),i+=n.getElement().getBoundingRectangle().getWidth()}getClientRect(){if(!this.svgGroup_||this.autoClose||!this.isVisible())return null;var e=this.svgGroup_.getBoundingClientRect(),t=e.top;return this.toolboxPosition_===Ya.TOP?new xa(-1e9,t+e.height,-1e9,1e9):new xa(t,1e9,-1e9,1e9)}reflowInternal_(){this.workspace_.scale=this.getFlyoutScale();var e=this.getContents().reduce(((e,t)=>Math.max(e,t.getElement().getBoundingRectangle().getHeight())),0);e+=1.5*this.MARGIN,e*=this.workspace_.scale,e+=Ha.scrollbarThickness,this.getHeight()!==e&&(this.targetWorkspace.scrollbar||this.autoClose||this.targetWorkspace.getFlyout()!==this||this.toolboxPosition_!==Ya.TOP||this.targetWorkspace.translate(this.targetWorkspace.scrollX,this.targetWorkspace.scrollY+e),this.height_=e,this.position(),this.targetWorkspace.resizeContents(),this.targetWorkspace.recordDragTargets())}};te(ya.FLYOUTS_HORIZONTAL_TOOLBOX,"default",Bg);var Ug=class extends mc{constructor(e,t,i,n,o){super(Wu.SKIP_SETUP),this.defaultType="",this.variableTypes=[],this.variable=null,this.SERIALIZABLE=!0,this.menuGenerator_=Ug.dropdownCreate,this.defaultVariableName="string"==typeof e?e:"",this.size_=new Fa(0,0),e!==Wu.SKIP_SETUP&&(o?this.configure_(o):this.setTypes(i,n),t&&this.setValidator(t))}configure_(e){super.configure_(e),this.setTypes(e.variableTypes,e.defaultType)}initModel(){var e=this.getSourceBlock();if(!e)throw new $u;this.variable||(e=Zs.Wd(e.workspace,null,this.defaultVariableName,this.defaultType),this.doValueUpdate_(e.getId()))}initView(){super.initView(),N(this.fieldGroup_,"blocklyVariableField")}shouldAddBorderRect_(){var e=this.getSourceBlock();if(!e)throw new $u;return super.shouldAddBorderRect_()&&(!this.getConstants().FIELD_DROPDOWN_NO_BORDER_RECT_SHADOW||"variables_get"!==e.type)}fromXml(e){var t=this.getSourceBlock();if(!t)throw new $u;var i=e.getAttribute("id"),n=e.textContent,o=e.getAttribute("variabletype")||e.getAttribute("variableType")||"";if(t=Zs.Wd(t.workspace,i,n,o),null!==o&&o!==t.getType())throw Error("Serialized variable type with id '"+t.getId()+"' had type "+t.getType()+", and does not match variable field that references it: "+Nn(e)+".");this.setValue(t.getId())}toXml(e){return this.initModel(),e.id=this.variable.getId(),e.textContent=this.variable.getName(),this.variable.getType()&&e.setAttribute("variabletype",this.variable.getType()),e}saveState(e){var t=this.saveLegacyState(Ug);return null!==t||(this.initModel(),t={id:this.variable.getId()},e&&(t.name=this.variable.getName(),t.type=this.variable.getType())),t}loadState(e){var t=this.getSourceBlock();if(!t)throw new $u;this.loadLegacyState(Ug,e)||(e=Zs.Wd(t.workspace,e.id||null,e.name,e.type||""),this.setValue(e.getId()))}setSourceBlock(e){if(e.isShadow())throw Error("Variable fields are not allowed to exist on shadow blocks.");super.setSourceBlock(e)}getValue(){return this.variable?this.variable.getId():null}getText(){return this.variable?this.variable.getName():""}getVariable(){return this.variable}getDefaultType(){return this.defaultType}getValidator(){return this.variable?this.validator_:null}doClassValidation_(e){if(null===e)return null;var t=this.getSourceBlock();if(!t)throw new $u;return(t=Zs.Vd(t.workspace,e))?(t=t.getType(),this.typeIsAllowed(t)?e:(console.warn("Variable type doesn't match this field! Type was "+t),null)):(console.warn("Variable id doesn't point to a real variable! ID was "+e),null)}doValueUpdate_(e){var t=this.getSourceBlock();if(!t)throw new $u;this.variable=Zs.Vd(t.workspace,e),super.doValueUpdate_(e)}typeIsAllowed(e){var t=this.getVariableTypes();if(!t)return!0;for(let i=0;i<t.length;i++)if(e===t[i])return!0;return!1}getVariableTypes(){if(this.variableTypes)return this.variableTypes;if(!this.sourceBlock_||this.sourceBlock_.isDeadOrDying())return[""];var e=this.sourceBlock_.workspace.getVariableMap().getTypes();if(this.sourceBlock_.isInFlyout){let t=this.sourceBlock_.workspace.getPotentialVariableMap();if(!t)return e;e=Array.from(new Set([...e,...t.getTypes()]))}return e}setTypes(e=null,t=""){var i=this.getText();if(Array.isArray(e)){if(0===e.length)throw Error(`'variableTypes' of field variable ${i} was an empty list. If you want to include all variable types, pass 'null' instead.`);i=!1;for(let n=0;n<e.length;n++)e[n]===t&&(i=!0);if(!i)throw Error("Invalid default type '"+t+"' in the definition of a FieldVariable")}else if(null!==e)throw Error(`'variableTypes' was not an array or null in the definition of FieldVariable ${i}`);this.defaultType=t,this.variableTypes=e}refreshVariableName(){this.forceRerender()}onItemSelected_(e,t){if(e=t.getValue(),this.sourceBlock_&&!this.sourceBlock_.isDeadOrDying()){if("RENAME_VARIABLE_ID"===e&&this.variable)return void Zs.Rd(this.sourceBlock_.workspace,this.variable);if("DELETE_VARIABLE_ID"===e&&this.variable)return e=this.variable.getWorkspace(),void Zs.$d(e,this.variable,this.sourceBlock_)}this.setValue(e)}referencesVariables(){return!0}static fromJson(e){return new this(Ji(e.variable),void 0,void 0,void 0,e)}static dropdownCreate(){if(!this.variable)throw Error("Tried to call dropdownCreate on a variable field with no variable selected.");var e=this.getText(),t=[],i=this.getSourceBlock();if(i&&!i.isDeadOrDying()){i=i.workspace;let e=this.getVariableTypes();for(let s=0;s<e.length;s++){let r=e[s],a=i.getVariableMap().getVariablesOfType(r);if(t=t.concat(a),i.isFlyout){var n=void 0,o=void 0;t=t.concat(null!=(o=null==(n=i.getPotentialVariableMap())?void 0:n.getVariablesOfType(r))?o:[])}}}for(t.sort(wt),n=[],o=0;o<t.length;o++)n[o]=[t[o].getName(),t[o].getId()];return n.push([Zs.C.RENAME_VARIABLE.replace("%1",e),"RENAME_VARIABLE_ID"]),Zs.C.DELETE_VARIABLE&&n.push([Zs.C.DELETE_VARIABLE.replace("%1",e),"DELETE_VARIABLE_ID"]),n}getAriaValue(){return Zs.C.FIELD_LABEL_VARIABLE.replace("%1",super.getAriaValue())}};wn("field_variable",Ug),Zs.Dq=class extends Ag{constructor(e,t,i){super(e,t,i)}initView(){super.initView(),this.fieldGroup_&&N(this.fieldGroup_,"blocklyTextInputField")}doClassValidation_(e){return void 0===e?null:`${e}`}static fromJson(e){return new this(Ji(e.text),void 0,e)}getAriaTypeName(){return this.ariaTypeName||Zs.C.ARIA_TYPE_FIELD_TEXT_INPUT}},wn("field_input",Zs.Dq),Zs.Dq.prototype.DEFAULT_VALUE="";var Vg=class extends Ag{constructor(e,t,i,n,o,s){super(Wu.SKIP_SETUP),this.min_=-1/0,this.max_=1/0,this.precision_=0,this.decimalPlaces=null,this.spellcheck_=!1,e!==Wu.SKIP_SETUP&&(s?this.configure_(s):this.setConstraints(t,i,n),this.setValue(e),o&&this.setValidator(o))}configure_(e){super.configure_(e),this.setMinInternal(e.min),this.setMaxInternal(e.max),this.setPrecisionInternal(e.precision)}setConstraints(e,t,i){this.setMinInternal(e),this.setMaxInternal(t),this.setPrecisionInternal(i),this.setValue(this.getValue())}setMin(e){this.setMinInternal(e),this.setValue(this.getValue())}setMinInternal(e){null==e?this.min_=-1/0:(e=Number(e),isNaN(e)||(this.min_=e))}getMin(){return this.min_}setMax(e){this.setMaxInternal(e),this.setValue(this.getValue())}setMaxInternal(e){null==e?this.max_=1/0:(e=Number(e),isNaN(e)||(this.max_=e))}getMax(){return this.max_}setPrecision(e){this.setPrecisionInternal(e),this.setValue(this.getValue())}setPrecisionInternal(e){this.precision_=Number(e)||0;var t=String(this.precision_);t.includes("e")&&(t=this.precision_.toLocaleString("en-US",{maximumFractionDigits:20}));var i=t.indexOf(".");this.decimalPlaces=-1===i?e?0:null:t.length-i-1}getPrecision(){return this.precision_}doClassValidation_(e){return null===e?null:(e=(e=(e=`${e}`.replace(/O/gi,"0")).replace(/,/g,"")).replace(/infinity/i,"Infinity"),e=Number(e||0),isNaN(e)?null:(e=Math.min(Math.max(e,this.min_),this.max_),this.precision_&&isFinite(e)&&(e=Math.round(e/this.precision_)*this.precision_),null!==this.decimalPlaces&&(e=Number(e.toFixed(this.decimalPlaces))),e))}widgetCreate_(){var e=super.widgetCreate_();return this.min_>-1/0&&(e.min=`${this.min_}`),this.max_<1/0&&(e.max=`${this.max_}`),e}initView(){super.initView(),this.fieldGroup_&&N(this.fieldGroup_,"blocklyNumberField")}static fromJson(e){return new this(e.value,void 0,void 0,void 0,void 0,e)}getAriaTypeName(){return this.ariaTypeName||Zs.C.ARIA_TYPE_FIELD_NUMBER}};wn("field_number",Vg),Vg.prototype.DEFAULT_VALUE=0;var Hg=class extends xd{constructor(e,t,i){super(String(null!=e?e:""),t,i),this.EDITABLE=!1,this.SERIALIZABLE=!0}static fromJson(e){return new this(Ji(e.text),void 0,e)}};wn("field_label_serializable",Hg);var Gg=class extends Wu{constructor(e,t,i){super(Wu.SKIP_SETUP),this.SERIALIZABLE=!0,this.value_=this.value_,this.checkChar=Gg.CHECK_CHAR,e!==Wu.SKIP_SETUP&&(i&&this.configure_(i),this.setValue(e),t&&this.setValidator(t))}configure_(e){super.configure_(e),e.checkCharacter&&(this.checkChar=e.checkCharacter)}saveState(){var e=this.saveLegacyState(Gg);return null!==e?e:this.getValueBoolean()}initView(){super.initView();var e=this.getTextElement();N(this.fieldGroup_,"blocklyCheckboxField"),e.style.display=this.value_?"block":"none",this.recomputeAriaContext()}render_(){this.textContent_&&(this.textContent_.nodeValue=this.getDisplayText_()),this.updateSize_(this.getConstants().FIELD_CHECKBOX_X_OFFSET)}getDisplayText_(){return this.checkChar}setCheckCharacter(e){this.checkChar=e||Gg.CHECK_CHAR,this.forceRerender()}showEditor_(){this.setValue(!this.value_)}doClassValidation_(e){return!0===e||"TRUE"===e?"TRUE":!1===e||"FALSE"===e?"FALSE":null}doValueUpdate_(e){this.value_=this.convertValueToBool(e),this.textElement_&&(this.textElement_.style.display=this.value_?"block":"none"),this.recomputeAriaContext()}getValue(){return this.value_?"TRUE":"FALSE"}getValueBoolean(){return this.value_}getText(){return String(this.convertValueToBool(this.value_))}convertValueToBool(e){return"string"==typeof e?"TRUE"===e:!!e}getAriaTypeName(){return this.ariaTypeName||Zs.C.ARIA_TYPE_FIELD_CHECKBOX}getAriaValue(){return this.convertValueToBool(this.value_)?Zs.C.FIELD_LABEL_CHECKBOX_CHECKED:Zs.C.FIELD_LABEL_CHECKBOX_UNCHECKED}static fromJson(e){return new this(e.checked,void 0,e)}recomputeAriaContext(){if(!super.recomputeAriaContext())return!1;var e=this.getFocusableElement();f(e,$r.HIDDEN,!1),_(e,Hr.CHECKBOX);var t=this.convertValueToBool(this.value_);return f(e,$r.CHECKED,t),t=this.getAriaTypeName(),f(e,$r.LABEL,t),!0}};Gg.CHECK_CHAR="✓",wn("field_checkbox",Gg),Gg.prototype.DEFAULT_VALUE=!1;var Wg=class{constructor(e){this.draggable=e,this.dragTarget=null,this.revertShouldDelete=!1,e instanceof Pd&&e.workspace.isFlyout&&(this.revertShouldDelete=!0),this.startLoc=e.getRelativeToSurfaceXY()}onDragStart(e){return Zs.gd||Zs.B(!0),this.draggable=this.draggable.startDrag(e),this.startLoc=this.draggable.getRelativeToSurfaceXY(),this.draggable}onDrag(e,t){this.moveDraggable(e,t),(e=e instanceof PointerEvent?e:null)&&(e=new Da(e.clientX,e.clientY),po(this.draggable)&&this.draggable.setDeleteStyle(this.wouldDeleteDraggable(e,this.draggable)),this.updateDragTarget(e))}updateDragTarget(e){if(e=this.draggable.workspace.getDragTarget(e),this.dragTarget!==e){let t;null==(t=this.dragTarget)||t.onDragExit(this.draggable),null==e||e.onDragEnter(this.draggable)}null==e||e.onDragOver(this.draggable),this.dragTarget=e}moveDraggable(e,t){t=this.pixelsToWorkspaceUnits(t),t=Da.sum(this.startLoc,t),this.draggable.drag(t,e)}wouldDeleteDraggable(e,t){return!(!(e=this.draggable.workspace.getDragTarget(e))||!this.draggable.workspace.getComponentManager().hasCapability(e.id,Sr.Capability.DELETE_AREA))&&e.wouldDelete(t)}onDragEnd(e){var t,i=Zs.gd,n=e instanceof PointerEvent?e:null;n?(n=new Da(n.clientX,n.clientY),this.draggable.workspace.getDragTarget(n)&&(null==(t=this.dragTarget)||t.onDrop(this.draggable)),t=!1,this.shouldReturnToStart(n,this.draggable)&&(t=!0,this.draggable.revertDrag()),(n=po(this.draggable)&&this.wouldDeleteDraggable(n,this.draggable))&&po(this.draggable)?(this.draggable.endDrag(e,cd.DELETE),Zs.B(i),this.draggable.dispose()):this.draggable.endDrag(e,t?cd.REVERT:cd.COMMIT),Zs.B(!1),!n&&M(this.draggable)&&Zs.t().focusNode(this.draggable)):(this.draggable.endDrag(e,cd.COMMIT),M(this.draggable)&&Zs.t().focusNode(this.draggable))}onDragRevert(e){this.revertShouldDelete&&po(this.draggable)?(this.draggable.endDrag(e,cd.DELETE),this.draggable.dispose()):(this.draggable.revertDrag(),M(this.draggable)&&Zs.t().focusNode(this.draggable))}shouldReturnToStart(e,t){return!!(e=this.draggable.workspace.getDragTarget(e))&&e.shouldPreventMove(t)}pixelsToWorkspaceUnits(e){return e=new Da(e.x/this.draggable.workspace.scale,e.y/this.draggable.workspace.scale),this.draggable.workspace.isMutator&&e.scale(1/this.draggable.workspace.options.parentWorkspace.scale),e}};te(ya.BLOCK_DRAGGER,"default",Wg);var qg={};qg.BlockDragStrategy=Dd,qg.BubbleDragStrategy=Rc,qg.CommentDragStrategy=ac,qg.Dragger=Wg;var $g={};$g.BottomRow=kg,$g.ConstantProvider=Ig,$g.Drawer=Ng,$g.PathObject=Lg,$g.RenderInfo=wg,$g.Renderer=Dg,$g.RightConnectionShape=Og,$g.StatementInput=Sg,$g.TopRow=Rg,Js();var jg={};jg.registerCleanup=Ds,jg.registerCollapse=Fs,jg.registerCollapseExpandBlock=qs,jg.registerComment=Gs,jg.registerCommentCreate=Ks,jg.registerCommentDelete=Xs,jg.registerCommentDuplicate=Ys,jg.registerCommentOptions=function(){Ys(),Xs(),Ks()},jg.registerDefaultOptions=Js,jg.registerDelete=js,jg.registerDeleteAll=Vs,jg.registerDisable=$s,jg.registerDuplicate=Hs,jg.registerExpand=Ms,jg.registerHelp=zs,jg.registerInline=Ws,jg.registerRedo=Ls,jg.registerUndo=ws;var zg=class{canConnect(e,t,i,n){return this.canConnectWithReason(e,t,i,n)===Hc.CAN_CONNECT}canConnectWithReason(e,t,i,n){var o=this.doSafetyChecks(e,t);return o!==Hc.CAN_CONNECT?o:this.doTypeChecks(e,t)?i&&!this.doDragChecks(e,t,n||0)?Hc.REASON_DRAG_CHECKS_FAILED:Hc.CAN_CONNECT:Hc.REASON_CHECKS_FAILED}getErrorMessage(e,t,i){switch(e){case Hc.REASON_SELF_CONNECTION:return"Attempted to connect a block to itself.";case Hc.REASON_DIFFERENT_WORKSPACES:return"Blocks not on same workspace.";case Hc.REASON_WRONG_TYPE:return"Attempt to connect incompatible types.";case Hc.REASON_TARGET_NULL:return"Target connection is null.";case Hc.REASON_CHECKS_FAILED:return"Connection checks failed. "+t+" expected "+t.getCheck()+", found "+i.getCheck();case Hc.REASON_SHADOW_PARENT:return"Connecting non-shadow to shadow block.";case Hc.REASON_DRAG_CHECKS_FAILED:return"Drag checks failed.";case Hc.REASON_PREVIOUS_AND_OUTPUT:return"Block would have an output and a previous connection.";default:return"Unknown connection failure: this should never happen!"}}doSafetyChecks(e,t){if(!e||!t)return Hc.REASON_TARGET_NULL;if(e.isSuperior())var i=e.getSourceBlock(),n=t.getSourceBlock(),o=t;else n=e.getSourceBlock(),i=t.getSourceBlock(),o=e,e=t;return i===n?Hc.REASON_SELF_CONNECTION:o.type!==$c[e.type]?Hc.REASON_WRONG_TYPE:i.workspace!==n.workspace?Hc.REASON_DIFFERENT_WORKSPACES:i.isShadow()&&!n.isShadow()?Hc.REASON_SHADOW_PARENT:o.type===Xl.OUTPUT_VALUE&&n.previousConnection&&n.previousConnection.isConnected()||o.type===Xl.PREVIOUS_STATEMENT&&n.outputConnection&&n.outputConnection.isConnected()?Hc.REASON_PREVIOUS_AND_OUTPUT:Hc.CAN_CONNECT}doTypeChecks(e,t){if(e=e.getCheck(),t=t.getCheck(),!e||!t)return!0;for(let i=0;i<e.length;i++)if(t.includes(e[i]))return!0;return!1}doDragChecks(e,t,i){if(e.distanceFrom(t)>i||t.getSourceBlock().isInsertionMarker())return!1;switch(t.type){case Xl.PREVIOUS_STATEMENT:return this.canConnectToPrevious_(e,t);case Xl.OUTPUT_VALUE:if(t.isConnected()&&!t.targetBlock().isInsertionMarker()||e.isConnected())return!1;break;case Xl.INPUT_VALUE:if(t.isConnected()&&!t.targetBlock().isMovable()&&!t.targetBlock().isShadow())return!1;break;case Xl.NEXT_STATEMENT:if(t.isConnected()&&!e.getSourceBlock().nextConnection&&!t.targetBlock().isShadow()&&t.targetBlock().nextConnection||t.targetBlock()&&!t.targetBlock().isMovable()&&!t.targetBlock().isShadow())return!1;break;default:return!1}return!ma.includes(t)}canConnectToPrevious_(e,t){return!(e.targetConnection||ma.includes(t)||t.targetConnection&&(!(e=t.targetBlock()).isInsertionMarker()||e.getPreviousBlock()))}};te(ya.CONNECTION_CHECKER,"default",zg);var Xg=class{load(e,t){return(e=new ud(t.getWorkspace(),t.targetWorkspace,e,!1)).show(),new Vd(e,"button")}gapForItem(e,t){return t}disposeItem(e){(e=e.getElement())instanceof ud&&e.dispose()}getType(){return"button"}};te(ya.FLYOUT_INFLATER,"button",Xg);var Yg={};Yg.Bubble=wc,Yg.MiniWorkspaceBubble=Lc,Yg.TextBubble=Fd,Yg.TextInputBubble=Uc;var Kg=class{constructor(){this.permanentlyDisabledBlocks=new Set,this.listeners=new Map,this.capacityWrapper=this.filterFlyoutBasedOnCapacity.bind(this)}load(e,t){this.setFlyout(t);var i=this.createBlock(e,t.getWorkspace());i.isEnabled()?this.updateStateBasedOnCapacity(i):this.permanentlyDisabledBlocks.add(i),i.getDescendants(!1).forEach((e=>{e.isInFlyout=!0;var t=e.getFocusableElement(),n=e.pathObject.svgPath;n!==t&&(f(n,$r.HIDDEN,!0),_(n,Hr.NONE)),e===i?_(t,Hr.OPTION):(f(t,$r.HIDDEN,!0),_(t,Hr.NONE))})),e=i.getIcons().filter((e=>{var i;return null==(i=e.isClickableInFlyout)?void 0:i.call(e,t.autoClose)})).map((e=>e.getFocusableElement().id)).filter((e=>!!e));var n=i.getConnections_(!0).map((e=>e.id));return(e=[...e,...n]).length&&f(i.getFocusableElement(),$r.OWNS,e),this.addBlockListeners(i),new Vd(i,"block")}createBlock(e,t){return e.blockxml?(e="string"==typeof e.blockxml?Zs.vc(e.blockxml):e.blockxml,t=An(e,t)):(void 0===e.enabled&&(e.enabled="true"!==e.disabled&&!0!==e.disabled),void 0===e.disabledReasons&&!1===e.enabled&&(e.disabledReasons=["MANUALLY_DISABLED"]),"x"in e&&delete e.x,"y"in e&&delete e.y,t=Mt(e,t)),t}gapForItem(e,t){if(e.gap)var i=parseInt(String(e.gap));else e.blockxml&&(e="string"==typeof e.blockxml?Zs.vc(e.blockxml):e.blockxml,i=parseInt(e.getAttribute("gap")));return!i||isNaN(i)?t:i}disposeItem(e){(e=e.getElement())instanceof Pd&&(this.removeListeners(e.id),this.permanentlyDisabledBlocks.delete(e),e.dispose(!1,!1))}removeListeners(e){var t;(null!=(t=this.listeners.get(e))?t:[]).forEach((e=>l(e))),this.listeners.delete(e)}setFlyout(e){if(this.flyout!==e){if(this.flyout){let e;null==(e=this.flyout.targetWorkspace)||e.removeChangeListener(this.capacityWrapper)}var t;this.flyout=e,null==(t=this.flyout.targetWorkspace)||t.addChangeListener(this.capacityWrapper)}}updateStateBasedOnCapacity(e){for(var t,i,n=null==(t=this.flyout)||null==(i=t.targetWorkspace)?void 0:i.isCapacityAvailable(J(e));e;)e.setDisabledReason(!n,"WORKSPACE_AT_BLOCK_CAPACITY"),e=e.getNextBlock()}addBlockListeners(e){var t=[];t.push(r(e.getSvgRoot(),"pointerdown",e,(t=>{var i,n,o=null==(i=this.flyout)||null==(n=i.targetWorkspace)?void 0:n.getGesture(t);o&&this.flyout&&(o.setStartBlock(e),o.handleFlyoutStart(t,this.flyout))}))),t.push(a(e.getSvgRoot(),"pointermove",null,(()=>{var t,i;null!=(t=this.flyout)&&null!=(i=t.targetWorkspace)&&i.isDragging()||e.addSelect()}))),t.push(a(e.getSvgRoot(),"pointerleave",null,(()=>{var t,i;null!=(t=this.flyout)&&null!=(i=t.targetWorkspace)&&i.isDragging()||e.removeSelect()}))),this.listeners.set(e.id,t)}filterFlyoutBasedOnCapacity(e){!this.flyout||e&&e.type!==Fr.BLOCK_CREATE&&e.type!==Fr.BLOCK_DELETE||this.flyout.getWorkspace().getTopBlocks(!1).forEach((e=>{this.permanentlyDisabledBlocks.has(e)||this.updateStateBasedOnCapacity(e)}))}getType(){return"block"}};te(ya.FLYOUT_INFLATER,"block",Kg);var Jg={};Jg.ConstantProvider=dg,Jg.Drawer=gg,Jg.HighlightConstantProvider=Eg,Jg.Highlighter=pg,Jg.InlineInput=Tg,Jg.PathObject=mg,Jg.RenderInfo=fg,Jg.Renderer=bg,Jg.StatementInput=_g;var Qg={};Qg.RenderInfo=Cg,Qg.Renderer=vg;var Zg=new kc("zelos",{colour_blocks:{colourPrimary:"#CF63CF",colourSecondary:"#C94FC9",colourTertiary:"#BD42BD"},list_blocks:{colourPrimary:"#9966FF",colourSecondary:"#855CD6",colourTertiary:"#774DCB"},logic_blocks:{colourPrimary:"#4C97FF",colourSecondary:"#4280D7",colourTertiary:"#3373CC"},loop_blocks:{colourPrimary:"#0fBD8C",colourSecondary:"#0DA57A",colourTertiary:"#0B8E69"},math_blocks:{colourPrimary:"#59C059",colourSecondary:"#46B946",colourTertiary:"#389438"},procedure_blocks:{colourPrimary:"#FF6680",colourSecondary:"#FF4D6A",colourTertiary:"#FF3355"},text_blocks:{colourPrimary:"#FFBF00",colourSecondary:"#E6AC00",colourTertiary:"#CC9900"},variable_blocks:{colourPrimary:"#FF8C1A",colourSecondary:"#FF8000",colourTertiary:"#DB6E00"},variable_dynamic_blocks:{colourPrimary:"#FF8C1A",colourSecondary:"#FF8000",colourTertiary:"#DB6E00"},hat_blocks:{colourPrimary:"#4C97FF",colourSecondary:"#4280D7",colourTertiary:"#3373CC",hat:"cap"}},{colour_category:{colour:"#CF63CF"},list_category:{colour:"#9966FF"},logic_category:{colour:"#4C97FF"},loop_category:{colour:"#0fBD8C"},math_category:{colour:"#59C059"},procedure_category:{colour:"#FF6680"},text_category:{colour:"#FFBF00"},variable_category:{colour:"#FF8C1A"},variable_dynamic_category:{colour:"#FF8C1A"}}),eE={Classic:Sc,Zelos:Zg},tE=class{constructor(e,t,i){this.id_=e.toolboxitemid||le(),this.level_=(this.parent_=i||null)?this.parent_.getLevel()+1:0,this.toolboxItemDef_=e,this.parentToolbox_=t,this.workspace_=this.parentToolbox_.getWorkspace()}init(){}getDiv(){return null}getClickTarget(){return null}getId(){return this.id_}getParent(){return null}getLevel(){return this.level_}isSelectable(){return!1}isCollapsible(){return!1}dispose(){}setVisible_(){}getFocusableElement(){var e=this.getDiv();if(!e)throw Error("Trying to access toolbox item before DOM is initialized.");if(!(e instanceof HTMLElement))throw Error("Toolbox item div is unexpectedly not an HTML element.");return e}getFocusableTree(){return this.parentToolbox_}onNodeFocus(){this.getFocusableElement().scrollIntoView({block:"nearest",inline:"nearest"})}onNodeBlur(){}canBeFocused(){return!0}getParentToolbox(){return this.parentToolbox_}},iE=class extends tE{constructor(e,t,i){super(e,t,i),this.colour_=this.name_="",this.labelDom_=this.iconDom_=this.rowContents_=this.rowDiv_=this.htmlDiv_=null,this.isDisabled_=this.isHidden_=!1,this.flyoutItems_=[],this.cssConfig_=this.makeDefaultCssConfig_()}init(){this.parseCategoryDef_(this.toolboxItemDef_),this.parseContents_(this.toolboxItemDef_),this.createDom_(),"true"===this.toolboxItemDef_.hidden&&this.hide()}makeDefaultCssConfig_(){return{container:"blocklyToolboxCategoryContainer",row:"blocklyToolboxCategory",rowcontentcontainer:"blocklyTreeRowContentContainer",icon:"blocklyToolboxCategoryIcon",label:"blocklyToolboxCategoryLabel",contents:"blocklyToolboxCategoryGroup",selected:"blocklyToolboxSelected",openicon:"blocklyToolboxCategoryIconOpen",closedicon:"blocklyToolboxCategoryIconClosed"}}parseContents_(e){if("custom"in e)this.flyoutItems_=e.custom;else if(e=e.contents)for(let t=0;t<e.length;t++){let i=e[t];Array.isArray(this.flyoutItems_)&&this.flyoutItems_.push(i)}}parseCategoryDef_(e){this.name_="name"in e?Ji(e.name):"",this.colour_=this.getColour_(e),Object.assign(this.cssConfig_,e.cssconfig||e.cssConfig)}createDom_(){this.htmlDiv_=this.createContainer_(),_(this.htmlDiv_,Hr.TREEITEM),f(this.htmlDiv_,$r.SELECTED,!1),f(this.htmlDiv_,$r.LEVEL,this.level_+1),this.rowDiv_=this.createRowContainer_(),this.rowDiv_.style.pointerEvents="auto",this.htmlDiv_.appendChild(this.rowDiv_),this.rowContents_=this.createRowContentsContainer_(),this.rowContents_.style.pointerEvents="none",this.rowDiv_.appendChild(this.rowContents_),this.iconDom_=this.createIconDom_(),_(this.iconDom_,Hr.NONE),this.rowContents_.appendChild(this.iconDom_),this.labelDom_=this.createLabelDom_(this.name_),this.rowContents_.appendChild(this.labelDom_);var e=this.labelDom_.getAttribute("id");return e&&f(this.htmlDiv_,$r.LABELLEDBY,e),this.addColourBorder_(this.colour_),this.htmlDiv_}createContainer_(){var e=document.createElement("div");e.tabIndex=-1,e.id=this.getId();var t=this.cssConfig_.container;return t&&N(e,t),e}createRowContainer_(){var e=document.createElement("div"),t=this.cssConfig_.row;return t&&N(e,t),t=iE.nestedPadding*this.getLevel()+"px",this.workspace_.RTL?e.style.paddingRight=t:e.style.paddingLeft=t,e}createRowContentsContainer_(){var e=document.createElement("div"),t=this.cssConfig_.rowcontentcontainer;return t&&N(e,t),e}createIconDom_(){var e=document.createElement("span");if(!this.parentToolbox_.isHorizontal()){let t=this.cssConfig_.icon;t&&N(e,t)}return e.style.display="inline-block",e}createLabelDom_(e){var t=document.createElement("span");return t.setAttribute("id",this.getId()+".label"),t.textContent=e,(e=this.cssConfig_.label)&&N(t,e),t}refreshTheme(){this.colour_=this.getColour_(this.toolboxItemDef_),this.addColourBorder_(this.colour_)}addColourBorder_(e){e&&(e=iE.borderWidth+"px solid "+(e||"#ddd"),this.workspace_.RTL?this.rowDiv_.style.borderRight=e:this.rowDiv_.style.borderLeft=e)}getColour_(e){var t=e.categorystyle||e.categoryStyle;if((e=e.colour)&&t)console.warn('Toolbox category "'+this.name_+'" must not have both a style and a colour');else{if(t)return this.getColourfromStyle(t);if(e)return this.parseColour(e)}return""}getColour(){return this.colour_}getColourfromStyle(e){var t=this.workspace_.getTheme();if(e&&t){if((t=t.categoryStyles[e])&&t.colour)return this.parseColour(t.colour);console.warn('Style "'+e+'" must exist and contain a colour value')}return""}getClickTarget(){return this.rowDiv_}parseColour(e){if(null==(e=Ji(e))||""===e)return"";var t=Number(e);return isNaN(t)?(t=Wi(e))?t:(console.warn('Toolbox category "'+this.name_+'" has unrecognized colour attribute: '+e),""):Xi(t)}openIcon_(e){if(e){var t=this.cssConfig_.closedicon;t&&y(e,t),(t=this.cssConfig_.openicon)&&N(e,t)}}closeIcon_(e){if(e){var t=this.cssConfig_.openicon;t&&y(e,t),(t=this.cssConfig_.closedicon)&&N(e,t)}}setVisible_(e){this.htmlDiv_.style.display=e?"block":"none",this.isHidden_=!e,this.parentToolbox_.getSelectedItem()===this&&this.parentToolbox_.clearSelection()}hide(){this.setVisible_(!1)}show(){this.setVisible_(!0)}isVisible(){return!this.isHidden_&&this.allAncestorsExpanded_()}allAncestorsExpanded_(){for(var e=this;e.getParent();)if(!(e=e.getParent()).isExpanded())return!1;return!0}isSelectable(){return this.isVisible()&&!this.isDisabled_}onClick(){}setSelected(e){if(this.rowDiv_){var t=this.cssConfig_.selected;if(e){let e=this.parseColour(iE.defaultBackgroundColour);this.rowDiv_.style.backgroundColor=this.colour_||e,t&&N(this.rowDiv_,t)}else this.rowDiv_.style.backgroundColor="",t&&A(this.rowDiv_,t);f(this.htmlDiv_,$r.SELECTED,e)}}setDisabled(e){this.isDisabled_=e,this.getDiv().setAttribute("disabled",`${e}`),e?this.getDiv().setAttribute("disabled","true"):this.getDiv().removeAttribute("disabled")}getName(){return this.name_}getParent(){return this.parent_}getDiv(){return this.htmlDiv_}onNodeFocus(){super.onNodeFocus(),this.getParentToolbox().getSelectedItem()!==this&&this.getParentToolbox().setSelectedItem(this)}getContents(){return this.flyoutItems_}updateFlyoutContents(e){this.flyoutItems_=[],this.toolboxItemDef_="string"==typeof e?{kind:this.toolboxItemDef_.kind,custom:e,id:this.toolboxItemDef_.id,categorystyle:this.toolboxItemDef_.categorystyle,colour:this.toolboxItemDef_.colour,cssconfig:this.toolboxItemDef_.cssconfig,hidden:this.toolboxItemDef_.hidden}:{kind:this.toolboxItemDef_.kind,name:"name"in this.toolboxItemDef_?this.toolboxItemDef_.name:"",contents:Me(e),id:this.toolboxItemDef_.id,categorystyle:this.toolboxItemDef_.categorystyle,colour:this.toolboxItemDef_.colour,cssconfig:this.toolboxItemDef_.cssconfig,hidden:this.toolboxItemDef_.hidden},this.parseContents_(this.toolboxItemDef_)}dispose(){S(this.htmlDiv_)}};iE.registrationName="category",iE.nestedPadding=19,iE.borderWidth=8,iE.defaultBackgroundColour="#57e",g('\n.blocklyToolboxCategory:not(.blocklyToolboxSelected):hover {\n background-color: rgba(255, 255, 255, .2);\n}\n\n.blocklyToolbox[layout="h"] .blocklyToolboxCategoryContainer {\n margin: 1px 5px 1px 0;\n}\n\n.blocklyToolbox[dir="RTL"][layout="h"] .blocklyToolboxCategoryContainer {\n margin: 1px 0 1px 5px;\n}\n\n.blocklyToolboxCategory {\n height: 22px;\n line-height: 22px;\n margin-bottom: 3px;\n padding-right: 8px;\n white-space: nowrap;\n}\n\n.blocklyToolbox[dir="RTL"] .blocklyToolboxCategory {\n margin-left: 8px;\n padding-right: 0;\n}\n\n.blocklyToolboxCategoryIcon {\n background-image: url(<<<PATH>>>/sprites.svg);\n height: 16px;\n vertical-align: middle;\n visibility: hidden;\n width: 16px;\n}\n\n.blocklyToolboxCategoryIconClosed {\n background-position: -32px -1px;\n}\n\n.blocklyToolbox[dir="RTL"] .blocklyToolboxCategoryIconClosed {\n background-position: 0 -1px;\n}\n\n.blocklyToolboxSelected>.blocklyToolboxCategoryIconClosed {\n background-position: -32px -17px;\n}\n\n.blocklyToolbox[dir="RTL"] .blocklyToolboxSelected>.blocklyToolboxCategoryIconClosed {\n background-position: 0 -17px;\n}\n\n.blocklyToolboxCategoryIconOpen {\n background-position: -16px -1px;\n}\n\n.blocklyToolboxSelected>.blocklyToolboxCategoryIconOpen {\n background-position: -16px -17px;\n}\n\n.blocklyToolboxCategoryLabel {\n cursor: default;\n font: 16px sans-serif;\n padding: 0 3px;\n vertical-align: middle;\n}\n\n.blocklyToolboxDelete .blocklyToolboxCategoryLabel {\n cursor: url("<<<PATH>>>/handdelete.cur"), auto;\n}\n\n.blocklyToolboxSelected .blocklyToolboxCategoryLabel {\n color: #fff;\n}\n'),te(ya.TOOLBOX_ITEM,iE.registrationName,iE);var nE=class extends tE{constructor(e,t){super(e,t),this.cssConfig_={container:"blocklyTreeSeparator"},this.htmlDiv=null,Object.assign(this.cssConfig_,e.cssconfig||e.cssConfig)}init(){this.createDom_()}createDom_(){var e=document.createElement("div");e.id=this.getId();var t=this.cssConfig_.container;return t&&N(e,t),_(e,Hr.NONE),this.htmlDiv=e}getDiv(){return this.htmlDiv}dispose(){S(this.htmlDiv)}canBeFocused(){return!1}};nE.registrationName="sep",g('\n.blocklyTreeSeparator {\n border-bottom: solid #e5e5e5 1px;\n height: 0;\n margin: 5px 0;\n}\n\n.blocklyToolbox[layout="h"] .blocklyTreeSeparator {\n border-right: solid #e5e5e5 1px;\n border-bottom: none;\n height: auto;\n margin: 0 5px 0 5px;\n padding: 5px 0;\n width: 0;\n}\n'),te(ya.TOOLBOX_ITEM,nE.registrationName,nE);var oE=class extends iE{constructor(e,t,i){super(e,t,i),this.subcategoriesDiv_=null,this.expanded_=!1,this.toolboxItems_=[]}makeDefaultCssConfig_(){var e=super.makeDefaultCssConfig_();return e.contents="blocklyToolboxCategoryGroup",e}parseContents_(e){if("custom"in e)this.flyoutItems_=e.custom;else{let t=e.contents;if(t){this.flyoutItems_=[],e=!0;for(let i=0;i<t.length;i++){let n=t[i];!oe(ya.TOOLBOX_ITEM,n.kind)||n.kind.toLowerCase()===nE.registrationName&&e?(this.flyoutItems_.push(n),e=!0):(this.createToolboxItem(n),e=!1)}}}}createToolboxItem(e){var t=e.kind;"CATEGORY"===t.toUpperCase()&&Be(e)&&(t=oE.registrationName),e=new(ne(ya.TOOLBOX_ITEM,t,void 0))(e,this.parentToolbox_,this),this.toolboxItems_.push(e)}init(){super.init(),this.setExpanded("true"===this.toolboxItemDef_.expanded||!0===this.toolboxItemDef_.expanded)}createDom_(){super.createDom_();var e=this.getChildToolboxItems();return this.subcategoriesDiv_=this.createSubCategoriesDom_(e),_(this.subcategoriesDiv_,Hr.GROUP),this.htmlDiv_.appendChild(this.subcategoriesDiv_),this.closeIcon_(this.iconDom_),f(this.htmlDiv_,$r.EXPANDED,!1),this.htmlDiv_}createIconDom_(){var e=document.createElement("span");if(!this.parentToolbox_.isHorizontal()){let t=this.cssConfig_.icon;t&&N(e,t),e.style.visibility="visible"}return e.style.display="inline-block",e}createSubCategoriesDom_(e){var t=document.createElement("div");t.style.display="none";var i=this.cssConfig_.contents;for(i&&N(t,i),i=0;i<e.length;i++){let n=e[i];n.init();let o=n.getDiv();if(t.appendChild(o),n.getClickTarget){let e;null==(e=n.getClickTarget())||e.setAttribute("id",n.getId())}}return t}setExpanded(e){this.expanded_!==e&&((this.expanded_=e)?(this.subcategoriesDiv_.style.display="block",this.openIcon_(this.iconDom_)):(this.setFlyoutVisible(!1),this.subcategoriesDiv_.style.display="none",this.closeIcon_(this.iconDom_)),f(this.htmlDiv_,$r.EXPANDED,e),this.parentToolbox_.handleToolboxItemResize())}setVisible_(e){this.htmlDiv_.style.display=e?"block":"none";var t=this.getChildToolboxItems();for(let i=0;i<t.length;i++)t[i].setVisible_(e);this.isHidden_=!e,this.parentToolbox_.getSelectedItem()===this&&this.parentToolbox_.clearSelection()}isExpanded(){return this.expanded_}isCollapsible(){return!0}onClick(){if(this.flyoutItems_.length>0){var e=this.getParentToolbox();let t;if(e=e.getSelectedItem()===this&&(null==(t=e.getFlyout())?void 0:t.isVisible()),this.expanded_&&!e)return void this.setFlyoutVisible(!0)}this.toggleExpanded()}setFlyoutVisible(e){var t;null==(t=this.parentToolbox_.getFlyout())||t.setVisible(e)}toggleExpanded(){this.setExpanded(!this.expanded_)}getDiv(){return this.htmlDiv_}getChildToolboxItems(){return this.toolboxItems_}};oE.registrationName="collapsibleCategory",te(ya.TOOLBOX_ITEM,oE.registrationName,oE);var sE=class extends Ud{constructor(e){super(),this.id="toolbox",this.contentsDiv_=this.HtmlDiv=null,this.isVisible_=!1,this.height_=this.width_=0,this.flyout=null,this.contents=new Map,this.previouslySelectedItem_=this.selectedItem_=null,this.boundEvents_=[],this.mouseDown=!1,this.navigator=new rp(this),this.workspace_=e,this.toolboxDef_=e.options.languageTree||{contents:[]},this.horizontalLayout=e.options.horizontalLayout,this.RTL=e.options.RTL,this.toolboxPosition=e.options.toolboxPosition}onShortcut(){return!1}init(){var e=this.workspace_,t=e.getParentSvg();this.flyout=this.createFlyout_(),this.HtmlDiv=this.createDom_(this.workspace_);var i=this.flyout.createDom("svg");e.getInjectionDiv().insertBefore(i,t),N(i,"blocklyToolboxFlyout"),this.setVisible(!0),this.flyout.init(e),this.render(this.toolboxDef_),(e=e.getThemeManager()).subscribe(this.HtmlDiv,"toolboxBackgroundColour","background-color"),e.subscribe(this.HtmlDiv,"toolboxForegroundColour","color"),this.workspace_.getComponentManager().addComponent({component:this,weight:Sr.ComponentWeight.TOOLBOX_WEIGHT,capabilities:[Sr.Capability.AUTOHIDEABLE,Sr.Capability.DELETE_AREA,Sr.Capability.DRAG_TARGET]}),Zs.t().registerTree(this,!0)}createDom_(e){e=e.getParentSvg();var t,i=this.createContainer_();return i.id=le(),this.contentsDiv_=this.createContentsContainer_(),_(this.contentsDiv_,Hr.TREE),i.appendChild(this.contentsDiv_),null==(t=e.parentNode)||t.insertBefore(i,e),this.attachEvents_(i,this.contentsDiv_),i}createContainer_(){var e=document.createElement("div");return e.setAttribute("layout",this.isHorizontal()?"h":"v"),N(e,"blocklyToolbox"),e.setAttribute("dir",this.RTL?"RTL":"LTR"),e}createContentsContainer_(){var e=document.createElement("div");return N(e,"blocklyToolboxCategoryGroup"),this.isHorizontal()&&(e.style.flexDirection="row"),e}attachEvents_(e,t){var i=r(e,"pointerdown",this,this.onClick_,!1);this.boundEvents_.push(i),e=a(e,"pointerup",this,(()=>{this.mouseDown=!1})),this.boundEvents_.push(e),t=r(t,"keydown",this,this.onKeyDown_,!1),this.boundEvents_.push(t)}onClick_(e){var t=()=>{Zs.t().focusNode(this),this.clearSelection(),Ta.hideChaff(!1),e.preventDefault()};if(this.mouseDown=!0,u(e)||e.target===this.HtmlDiv)t();else{var i=e.target.getAttribute("id");i&&null!=(i=this.getToolboxItemById(i))&&i.isSelectable()&&(i.onClick(e),i===this.getSelectedItem()?t():(this.setSelectedItem(i),Ta.hideChaff(!0)))}dr=null}onKeyDown_(e){var t=!1;switch(e.key){case"ArrowLeft":t=this.toggleSelectedItem(!1);break;case"ArrowRight":t=this.toggleSelectedItem(!0);break;case"Escape":Zs.t().focusTree(this.getWorkspace()),t=!0}t&&(e.preventDefault(),e.stopPropagation())}createFlyout_(){var e=this.workspace_,t=e.copyOptionsForFlyout();return t.toolboxPosition=e.options.toolboxPosition,new(e.horizontalLayout?ae(ya.FLYOUTS_HORIZONTAL_TOOLBOX,e.options,!0):ae(ya.FLYOUTS_VERTICAL_TOOLBOX,e.options,!0))(t)}render(e){this.toolboxDef_=e,this.contents.forEach((e=>e.dispose())),this.contents.clear(),this.renderContents_(e.contents),this.position(),this.handleToolboxItemResize()}renderContents_(e){var t,i=document.createDocumentFragment();for(let t=0;t<e.length;t++)this.createToolboxItem(e[t],i);null==(t=this.contentsDiv_)||t.appendChild(i)}createToolboxItem(e,t){var i=e.kind;if("CATEGORY"===i.toUpperCase()&&Be(e)&&(i=oE.registrationName),i=se(ya.TOOLBOX_ITEM,i.toLowerCase())){let n;(e=new i(e,this)).init(),this.addToolboxItem_(e),(i=e.getDiv())&&t.appendChild(i),null==(n=e.getClickTarget())||n.setAttribute("id",e.getId())}}addToolboxItem_(e){if(this.contents.set(e.getId(),e),e.isCollapsible()){e=e.getChildToolboxItems();for(let t=0;t<e.length;t++)this.addToolboxItem_(e[t])}}getToolboxItems(){return[...this.contents.values()]}addStyle(e){e&&this.HtmlDiv&&N(this.HtmlDiv,e)}removeStyle(e){e&&this.HtmlDiv&&A(this.HtmlDiv,e)}getClientRect(){if(!this.HtmlDiv||!this.isVisible_)return null;var e=this.HtmlDiv.getBoundingClientRect(),t=e.top,i=t+e.height,n=e.left;return e=n+e.width,this.toolboxPosition===Ya.TOP?new xa(-1e7,i,-1e7,1e7):this.toolboxPosition===Ya.BOTTOM?new xa(t,1e7,-1e7,1e7):this.toolboxPosition===Ya.LEFT?new xa(-1e7,1e7,-1e7,e):new xa(-1e7,1e7,n,1e7)}onDragEnter(){yc.mover.isMoving()||this.updateCursorDeleteStyle_(!0)}onDragExit(){yc.mover.isMoving()||this.updateCursorDeleteStyle_(!1)}onDrop(){yc.mover.isMoving()||this.updateCursorDeleteStyle_(!1)}updateWouldDelete_(e){e!==this.wouldDelete_&&(this.updateCursorDeleteStyle_(!1),this.wouldDelete_=e,this.updateCursorDeleteStyle_(!0))}updateCursorDeleteStyle_(e){var t=this.wouldDelete_?"blocklyToolboxDelete":"blocklyToolboxGrab";e?this.addStyle(t):this.removeStyle(t)}getToolboxItemById(e){return this.contents.get(e)||null}getWidth(){return this.width_}getHeight(){return this.height_}getFlyout(){return this.flyout}getWorkspace(){return this.workspace_}getSelectedItem(){return this.selectedItem_}getPreviouslySelectedItem(){return this.previouslySelectedItem_}isHorizontal(){return this.horizontalLayout}position(){var e,t=this.workspace_.getMetrics(),i=this.HtmlDiv;i&&(this.horizontalLayout?(i.style.left="0",i.style.height="auto",i.style.width="100%",this.height_=i.offsetHeight,this.width_=t.viewWidth,this.toolboxPosition===Ya.TOP?i.style.top="0":i.style.bottom="0"):(this.toolboxPosition===Ya.RIGHT?i.style.right="0":i.style.left="0",i.style.height="100%",this.width_=i.offsetWidth,this.height_=t.viewHeight),null==(e=this.flyout)||e.position())}handleToolboxItemResize(){if(this.HtmlDiv){var e=this.workspace_,t=this.HtmlDiv.getBoundingClientRect(),i=this.getFlyout(),n=this.toolboxPosition===Ya.LEFT?e.scrollX+t.width+(i&&!i.autoClose?i.getWidth():0):e.scrollX;t=this.toolboxPosition===Ya.TOP?e.scrollY+t.height+(i&&!i.autoClose?i.getHeight():0):e.scrollY,e.translate(n,t),K(e)}}clearSelection(){this.setSelectedItem(null)}refreshTheme(){this.contents.forEach((e=>{e.refreshTheme&&e.refreshTheme()}))}refreshSelection(){if(this.selectedItem_&&this.selectedItem_.isSelectable()&&this.selectedItem_.getContents().length){let e;null==(e=this.flyout)||e.show(this.selectedItem_.getContents())}}setVisible(e){this.isVisible_!==e&&(this.HtmlDiv&&(this.HtmlDiv.style.display=e?"block":"none"),this.isVisible_=e,this.workspace_.recordDragTargets())}autoHide(e){!e&&this.flyout&&this.flyout.autoClose&&this.clearSelection()}setSelectedItem(e){var t=this.selectedItem_;!e&&!t||e&&!qt(e)||(this.shouldDeselectItem_(t,e)&&null!==t&&this.deselectItem_(t),this.shouldSelectItem_(t,e)&&null!==e&&this.selectItem_(t,e),this.updateFlyout_(t,e),this.fireSelectEvent(t,e))}shouldDeselectItem_(e,t){return null!==e&&(!e.isCollapsible()||e!==t)}shouldSelectItem_(e,t){return null!==t&&t!==e}deselectItem_(e){this.selectedItem_=null,this.previouslySelectedItem_=e,e.setSelected(!1),f(this.contentsDiv_,$r.ACTIVEDESCENDANT,"")}selectItem_(e,t){this.selectedItem_=t,this.previouslySelectedItem_=e,t.setSelected(!0),f(this.contentsDiv_,$r.ACTIVEDESCENDANT,t.getId())}selectItemByPosition(e){(e=this.getToolboxItems()[e])&&this.setSelectedItem(e)}updateFlyout_(e,t){if(t&&(e!==t||t.isCollapsible())&&t.getContents().length){let e,i;null==(e=this.flyout)||e.show(t.getContents()),null==(i=this.flyout)||i.scrollToStart()}else{let e;null==(e=this.flyout)||e.hide()}}fireSelectEvent(e,t){var i=e&&e.getName(),n=t&&t.getName();e===t&&(n=null),e=new(_e(Fr.TOOLBOX_ITEM_SELECT))(i,n,this.workspace_.id),ue(e)}toggleSelectedItem(e){var t,i;return!(!os(this.selectedItem_)||null==(t=this.selectedItem_)||!t.isCollapsible()||(null==(i=this.selectedItem_)?void 0:i.isExpanded())===e||(this.selectedItem_.toggleExpanded(),0))}dispose(){var e;for(this.workspace_.getComponentManager().removeComponent("toolbox"),null==(e=this.flyout)||e.dispose(),this.contents.forEach((e=>e.dispose())),e=0;e<this.boundEvents_.length;e++)l(this.boundEvents_[e]);this.boundEvents_=[],this.contents.clear(),this.HtmlDiv&&(this.workspace_.getThemeManager().unsubscribe(this.HtmlDiv),S(this.HtmlDiv)),Zs.t().unregisterTree(this)}getFocusableElement(){if(!this.HtmlDiv)throw Error("Toolbox DOM has not yet been created.");return this.HtmlDiv}getFocusableTree(){return this}onNodeFocus(){}onNodeBlur(){}canBeFocused(){return!0}getRootFocusableNode(){return this}getRestoredFocusableNode(e){if(!e||e===this){let e;return null!=(e=this.getToolboxItems().find((e=>e.isSelectable())))?e:null}return null}getNestedTrees(){return[]}lookUpFocusableNode(e){return this.getToolboxItemById(e)}onTreeFocus(e){e!==this?this.getSelectedItem()===e||this.mouseDown||this.setSelectedItem(e):this.clearSelection()}onTreeBlur(e){var t;e&&e===(null==(t=this.flyout)?void 0:t.getWorkspace())||this.autoHide(!1)}getNavigator(){return this.navigator}};g('\n.blocklyToolboxDelete {\n cursor: url("<<<PATH>>>/handdelete.cur"), auto;\n}\n\n.blocklyToolboxGrab {\n cursor: url("<<<PATH>>>/handclosed.cur"), auto;\n cursor: grabbing;\n cursor: -webkit-grabbing;\n}\n\n/* Category tree in Toolbox. */\n.blocklyToolbox {\n box-sizing: border-box;\n user-select: none;\n -ms-user-select: none;\n -webkit-user-select: none;\n background-color: #ddd;\n overflow-x: visible;\n overflow-y: auto;\n padding: 4px 0 4px 0;\n position: absolute;\n z-index: 70; /* so blocks go under toolbox when dragging */\n -webkit-tap-highlight-color: transparent; /* issue #1345 */\n}\n\n.blocklyToolboxCategoryGroup {\n display: flex;\n flex-wrap: wrap;\n flex-direction: column;\n}\n\n.blocklyToolboxCategoryGroup:focus {\n outline: none;\n}\n'),te(ya.TOOLBOX,"default",sE);var rE=Xl.INPUT_VALUE,aE=Xl.OUTPUT_VALUE,lE=Xl.NEXT_STATEMENT,hE=Xl.PREVIOUS_STATEMENT,uE=Ya.TOP,cE=Ya.BOTTOM,dE=Ya.LEFT,pE=Ya.RIGHT;Zp.prototype.newBlock=function(e,t){return new Zc(this,e,t)},ig.prototype.newBlock=function(e,t){return new Pd(this,e,t)},Zp.prototype.newComment=function(e){return new gc(this,e)},ig.prototype.newComment=function(e){return new Ec(this,e)},ig.newTrashcan=function(e){return new sg(e)},Lc.prototype.newWorkspaceSvg=function(e){return new ig(e)},Zs.Cj.prototype.populateProcedures=function(e){e=(e=hs(e))[0].concat(e[1]);for(let t=0;t<e.length;t++)this.getName(e[t][0],Zs.Cj.NameType.PROCEDURE)};var gE={};return gE.Block=Zc,gE.BlockFlyoutInflater=Kg,gE.BlockNavigationPolicy=zd,gE.BlockSvg=Pd,gE.Blocks=Ur,gE.BubbleNavigationPolicy=Xd,gE.ButtonFlyoutInflater=Xg,gE.COLLAPSED_FIELD_NAME="_TEMP_COLLAPSED_FIELD",gE.COLLAPSED_INPUT_NAME="_TEMP_COLLAPSED_INPUT",gE.COLLAPSE_CHARS=30,gE.CodeGenerator=Zs.zq,gE.CollapsibleToolboxCategory=oE,gE.CommentBarButtonNavigationPolicy=Yd,gE.CommentEditorNavigationPolicy=Kd,gE.ComponentManager=Sr,gE.Connection=Hc,gE.ConnectionChecker=zg,gE.ConnectionDB=Vc,gE.ConnectionNavigationPolicy=Jd,gE.ConnectionType=Xl,gE.ContextMenu=ic,gE.ContextMenuItems=jg,gE.ContextMenuRegistry=nc,gE.Css=xr,gE.DELETE_VARIABLE_ID="DELETE_VARIABLE_ID",gE.DeleteArea=Ud,gE.Direction=vc,gE.DragDisposition=cd,gE.DragTarget=Bd,gE.DropDownDiv=yu,gE.Events=$h,gE.Extensions=Mc,gE.Field=Wu,gE.FieldCheckbox=Gg,gE.FieldDropdown=mc,gE.FieldImage=yg,gE.FieldLabel=xd,gE.FieldLabelSerializable=Hg,gE.FieldNavigationPolicy=Qd,gE.FieldNumber=Vg,gE.FieldTextInput=Zs.Dq,gE.FieldVariable=Ug,gE.Flyout=up,gE.FlyoutButton=ud,gE.FlyoutButtonNavigationPolicy=$d,gE.FlyoutItem=Vd,gE.FlyoutMetricsManager=Wd,gE.FlyoutNavigator=ap,gE.FlyoutSeparator=qd,gE.FlyoutSeparatorNavigationPolicy=jd,gE.FocusManager=ha,gE.FocusableTreeTraverser=aa,gE.Generator=Zs.zq,gE.Gesture=dp,gE.Grid=pp,gE.HorizontalFlyout=Bg,gE.INPUT_VALUE=rE,gE.IconNavigationPolicy=Zd,gE.Input=Yc,gE.InsertionMarkerPreviewer=xg,gE.KeyboardMover=yc,gE.KeyboardNavigationController=zh,gE.LabelFlyoutInflater=ug,gE.Menu=bl,gE.MenuItem=ml,gE.MetricsManager=Hd,gE.MoveIndicator=Ic,gE.Msg=Zs.C,gE.NEXT_STATEMENT=lE,gE.Names=Zs.Cj,gE.NavigationDirection=Gd,gE.Navigator=op,gE.OPPOSITE_TYPE=$c,gE.OUTPUT_VALUE=aE,gE.Options=Oc,gE.PREVIOUS_STATEMENT=hE,gE.PROCEDURE_CATEGORY_NAME="PROCEDURE",gE.Procedures=Cp,gE.RENAME_VARIABLE_ID="RENAME_VARIABLE_ID",gE.RenderedConnection=jc,gE.Scrollbar=Ha,gE.ScrollbarPair=lp,gE.SeparatorFlyoutInflater=hp,gE.ShortcutItems=Rd,gE.ShortcutRegistry=ca,gE.TOOLBOX_AT_BOTTOM=cE,gE.TOOLBOX_AT_LEFT=dE,gE.TOOLBOX_AT_RIGHT=pE,gE.TOOLBOX_AT_TOP=uE,gE.Theme=kc,gE.ThemeManager=Jp,gE.Themes=eE,gE.Toast=Ol,gE.Toolbox=sE,gE.ToolboxCategory=iE,gE.ToolboxItem=tE,gE.ToolboxItemNavigationPolicy=sp,gE.ToolboxNavigator=rp,gE.ToolboxSeparator=nE,gE.Tooltip=Pu,gE.Touch=Er,gE.Trashcan=sg,gE.UnattachedFieldError=$u,gE.VARIABLE_CATEGORY_NAME="VARIABLE",gE.VARIABLE_DYNAMIC_CATEGORY_NAME="VARIABLE_DYNAMIC",gE.VERSION="13.4.0",gE.VariableMap=og,gE.VariableModel=ng,gE.Variables=Jh,gE.VariablesDynamic=Qp,gE.VerticalFlyout=Pg,gE.WidgetDiv=Qu,gE.Workspace=Zp,gE.WorkspaceAudio=eg,gE.WorkspaceCommentNavigationPolicy=ep,gE.WorkspaceDragger=cp,gE.WorkspaceNavigationPolicy=tp,gE.WorkspaceSvg=ig,gE.Xml=Tc,gE.ZoomControls=dl,gE.blockAnimations=id,gE.blockRendering=Kp,gE.browserEvents=yr,gE.bubbles=Yg,gE.bumpObjects=od,gE.clipboard=ld,gE.comments=hd,gE.common=Ca,gE.config=Zs.Og,gE.constants={COLLAPSED_FIELD_NAME:"_TEMP_COLLAPSED_FIELD",COLLAPSED_INPUT_NAME:"_TEMP_COLLAPSED_INPUT",MANUALLY_DISABLED:"MANUALLY_DISABLED"},gE.defineBlocksWithJsonArray=Z,gE.dialog=Bl,gE.dragging=qg,gE.fieldRegistry=fc,gE.geras=Jg,gE.getFocusManager=Zs.t,gE.getMainWorkspace=q,gE.getSelected=j,gE.hasBubble=pt,gE.hideChaff=function(e){Ta.hideChaff(e)},gE.icons=mp,gE.inject=function(e,t){var i,n=null;if(n="string"==typeof e?document.getElementById(e)||document.querySelector(e):e,!document.contains(n)&&document!==(null==(i=n)?void 0:i.ownerDocument))throw Error("Error: container is not in current document");e=new Oc(t||{}),i=document.createElement("div"),N(i,"injectionDiv"),null!=t&&t.rtl&&N(i,"blocklyRTL"),_(i,Hr.APPLICATION),n.appendChild(i),t=As(i,e);var o=ks(i,t,e);return Ss(o),$(o),K(o),i.addEventListener("focusin",(function(){$(o)})),r(i,"keydown",null,ee),C(i),o},gE.inputs=Fg,gE.isBoundedElement=uo,gE.isCopyable=co,gE.isDeletable=po,gE.isDraggable=go,gE.isIcon=Xn,gE.isObservable=ls,gE.isPaster=function(e){return e&&"function"==typeof e.paste},gE.isRenderedElement=function(e){return e&&"function"==typeof e.getSvgRoot},gE.isSelectable=P,gE.isSerializable=Je,gE.isVariableBackedParameterModel=Tt,gE.keyboardNavigationController=Xh,gE.layers={BLOCK:50,BUBBLE:100},gE.navigateBlock=ns,gE.procedures=Cp,gE.registry=Aa,gE.renderManagement=Sl,gE.serialization=hg,gE.setLocale=fe,gE.setParentContainer=Y,gE.svgResize=K,gE.thrasos=Qg,gE.uiPosition=ol,gE.utils=Bc,gE.zelos=$g,Zs.__chunk_blockly=gE,Zs.__chunk_blockly.__namespace__=Zs,Zs.__chunk_blockly})?n.apply(t,[]):n)||(e.exports=o)},87:function(e,t,i){var n,o,s;o=[i(500)],void 0===(s="function"==typeof(n=function(e){var t,i=e.__namespace__,n=function(e,i){var n=0,o="";i.STATEMENT_PREFIX&&(o+=i.injectId(i.STATEMENT_PREFIX,e));do{var s=i.valueToCode(e,"IF"+n,t.NONE)||"false",r=i.statementToCode(e,"DO"+n);i.STATEMENT_SUFFIX&&(r=i.prefixLines(i.injectId(i.STATEMENT_SUFFIX,e),i.INDENT)+r),o+=(n>0?"else ":"")+"if ("+s+") {\n"+r+"}",n++}while(e.getInput("IF"+n));return(e.getInput("ELSE")||i.STATEMENT_SUFFIX)&&(r=e.getInput("ELSE")?i.statementToCode(e,"ELSE"):"",i.STATEMENT_SUFFIX&&(r=i.prefixLines(i.injectId(i.STATEMENT_SUFFIX,e),i.INDENT)+r),o+=" else {\n"+r+"}"),o+"\n"},o=function(e,n){var o=e.getField("TIMES")?String(Number(e.getFieldValue("TIMES"))):n.valueToCode(e,"TIMES",t.ASSIGNMENT)||"0",s=n.statementToCode(e,"DO");s=n.addLoopTrap(s,e),e="";var r=n.nameDB_.getDistinctName("count",i.P.VARIABLE),a=o;return o.match(/^\w+$/)||i.zf(o)||(e+="var "+(a=n.nameDB_.getDistinctName("repeat_end",i.P.VARIABLE))+" = "+o+";\n"),e+"for (int "+r+" = 0; "+r+" < "+a+"; "+r+"++) {\n"+s+"}\n"},s=function(e,i){var n=e.getFieldValue("OP");if("NEG"===n)return"-"===(e=i.valueToCode(e,"NUM",t.UNARY_PREFIX)||"0")[0]&&(e=" "+e),["-"+e,t.UNARY_PREFIX];switch(i.definitions_.import_dart_math="import 'dart:math' as Math;",e="ABS"===n||"ROUND"===n.substring(0,5)?i.valueToCode(e,"NUM",t.UNARY_POSTFIX)||"0":"SIN"===n||"COS"===n||"TAN"===n?i.valueToCode(e,"NUM",t.MULTIPLICATIVE)||"0":i.valueToCode(e,"NUM",t.NONE)||"0",n){case"ABS":var o=e+".abs()";break;case"ROOT":o="Math.sqrt("+e+")";break;case"LN":o="Math.log("+e+")";break;case"EXP":o="Math.exp("+e+")";break;case"POW10":o="Math.pow(10,"+e+")";break;case"ROUND":o=e+".round()";break;case"ROUNDUP":o=e+".ceil()";break;case"ROUNDDOWN":o=e+".floor()";break;case"SIN":o="Math.sin("+e+" / 180 * Math.pi)";break;case"COS":o="Math.cos("+e+" / 180 * Math.pi)";break;case"TAN":o="Math.tan("+e+" / 180 * Math.pi)"}if(o)return[o,t.UNARY_POSTFIX];switch(n){case"LOG10":o="Math.log("+e+") / Math.log(10)";break;case"ASIN":o="Math.asin("+e+") / Math.pi * 180";break;case"ACOS":o="Math.acos("+e+") / Math.pi * 180";break;case"ATAN":o="Math.atan("+e+") / Math.pi * 180";break;default:throw Error("Unknown math operator: "+n)}return[o,t.MULTIPLICATIVE]},r=function(e,i){var n=i.getProcedureName(e.getFieldValue("NAME")),o="";i.STATEMENT_PREFIX&&(o+=i.injectId(i.STATEMENT_PREFIX,e)),i.STATEMENT_SUFFIX&&(o+=i.injectId(i.STATEMENT_SUFFIX,e)),o&&(o=i.prefixLines(o,i.INDENT));var s="";i.INFINITE_LOOP_TRAP&&(s=i.prefixLines(i.injectId(i.INFINITE_LOOP_TRAP,e),i.INDENT));var r="";e.getInput("STACK")&&(r=i.statementToCode(e,"STACK"));var a="";e.getInput("RETURN")&&(a=i.valueToCode(e,"RETURN",t.NONE)||"");var l="";r&&a&&(l=o),a&&(a=i.INDENT+"return "+a+";\n");var h=a?"dynamic":"void",u=[],c=e.getVarModels();for(let e=0;e<c.length;e++)u[e]=i.getVariableName(c[e].getId());return o=h+" "+n+"("+u.join(", ")+") {\n"+o+s+r+l+a+"}",o=i.scrub_(e,o),i.definitions_["%"+n]=o,null},a=function(e,i){i.definitions_.import_dart_html="import 'dart:html' as Html;";var n="Html.window.prompt("+(e.getField("TEXT")?i.quote_(e.getFieldValue("TEXT")):i.valueToCode(e,"TEXT",t.NONE)||"''")+", '')";return"NUMBER"===e.getFieldValue("TYPE")&&(i.definitions_.import_dart_math="import 'dart:math' as Math;",n="Math.parseDouble("+n+")"),[n,t.UNARY_POSTFIX]},l=function(e,i){return[i.getVariableName(e.getFieldValue("VAR")),t.ATOMIC]},h=function(e,i){var n=i.valueToCode(e,"VALUE",t.ASSIGNMENT)||"0";return i.getVariableName(e.getFieldValue("VAR"))+" = "+n+";\n"},u=t||(t={});u[u.ATOMIC=0]="ATOMIC",u[u.UNARY_POSTFIX=1]="UNARY_POSTFIX",u[u.UNARY_PREFIX=2]="UNARY_PREFIX",u[u.MULTIPLICATIVE=3]="MULTIPLICATIVE",u[u.ADDITIVE=4]="ADDITIVE",u[u.SHIFT=5]="SHIFT",u[u.BITWISE_AND=6]="BITWISE_AND",u[u.BITWISE_XOR=7]="BITWISE_XOR",u[u.BITWISE_OR=8]="BITWISE_OR",u[u.RELATIONAL=9]="RELATIONAL",u[u.EQUALITY=10]="EQUALITY",u[u.LOGICAL_AND=11]="LOGICAL_AND",u[u.LOGICAL_OR=12]="LOGICAL_OR",u[u.IF_NULL=13]="IF_NULL",u[u.CONDITIONAL=14]="CONDITIONAL",u[u.CASCADE=15]="CASCADE",u[u.ASSIGNMENT=16]="ASSIGNMENT",u[u.NONE=99]="NONE";var c=class extends i.zq{constructor(e="Dart"){super(e),this.isInitialized=!1;for(let i in t)"string"!=typeof(e=t[i])&&(this["ORDER_"+i]=e);this.addReservedWords("assert,break,case,catch,class,const,continue,default,do,else,enum,extends,false,final,finally,for,if,in,is,new,null,rethrow,return,super,switch,this,throw,true,try,var,void,while,with,print,identityHashCode,identical,BidirectionalIterator,Comparable,double,Function,int,Invocation,Iterable,Iterator,List,Map,Match,num,Pattern,RegExp,Set,StackTrace,String,StringSink,Type,bool,DateTime,Deprecated,Duration,Expando,Null,Object,RuneIterator,Runes,Stopwatch,StringBuffer,Symbol,Uri,Comparator,AbstractClassInstantiationError,ArgumentError,AssertionError,CastError,ConcurrentModificationError,CyclicInitializationError,Error,Exception,FallThroughError,FormatException,IntegerDivisionByZeroException,NoSuchMethodError,NullThrownError,OutOfMemoryError,RangeError,StackOverflowError,StateError,TypeError,UnimplementedError,UnsupportedError")}init(e){super.init(e),this.nameDB_?this.nameDB_.reset():this.nameDB_=new i.Cj(this.RESERVED_WORDS_),this.nameDB_.setVariableMap(e.getVariableMap()),this.nameDB_.populateVariables(e),this.nameDB_.populateProcedures(e);var t=[],n=i.Cd(e);for(let e=0;e<n.length;e++)t.push(this.nameDB_.getName(n[e],i.P.DEVELOPER_VARIABLE));for(e=i.Bd(e),n=0;n<e.length;n++)t.push(this.nameDB_.getName(e[n].getId(),i.P.VARIABLE));t.length&&(this.definitions_.variables="var "+t.join(", ")+";"),this.isInitialized=!0}finish(e){e&&(e=this.prefixLines(e,this.INDENT)),e="main() {\n"+e+"}";var t=[],i=[];for(let e in this.definitions_){let n=this.definitions_[e];n.match(/^import\s/)?t.push(n):i.push(n)}return e=super.finish(e),this.isInitialized=!1,this.nameDB_.reset(),(t.join("\n")+"\n\n"+i.join("\n\n")).replace(/\n\n+/g,"\n\n").replace(/\n*$/,"\n\n\n")+e}scrubNakedValue(e){return e+";\n"}quote_(e){return"'"+(e=e.replace(/\\/g,"\\\\").replace(/\n/g,"\\\n").replace(/\$/g,"\\$").replace(/'/g,"\\'"))+"'"}multiline_quote_(e){return e.split(/\n/g).map(this.quote_).join(" + '\\n' + \n")}scrub_(e,t,n=!1){var o="";if(!e.outputConnection||!e.outputConnection.targetConnection){var s=e.getCommentText();s&&(s=i.yf(s,this.COMMENT_WRAP-3),o="getProcedureDef"in e?o+this.prefixLines(s+"\n","/// "):o+this.prefixLines(s+"\n","// "));for(let t=0;t<e.inputList.length;t++)e.inputList[t].type===i.je.VALUE&&(s=e.inputList[t].connection.targetBlock())&&(s=this.allNestedComments(s))&&(o+=this.prefixLines(s,"// "))}return e=e.nextConnection&&e.nextConnection.targetBlock(),o+t+(n?"":this.blockToCode(e))}getAdjusted(e,n,o=0,s=!1,r=t.NONE){e.workspace.options.oneBasedIndex&&o--;var a=e.workspace.options.oneBasedIndex?"1":"0",l=r;return o?l=t.ADDITIVE:s&&(l=t.UNARY_PREFIX),e=this.valueToCode(e,n,l)||a,0!==o||s?i.zf(e)?(e=String(Number(e)+o),s&&(e=String(-Number(e))),e):(o>0?e=`${e} + ${o}`:o<0&&(e=`${e} - ${-o}`),s&&(e=o?`-(${e})`:`-${e}`),Math.floor(r)>=Math.floor(l)&&(e=`(${e})`),e):e}},d={};d.controls_if=n,d.controls_ifelse=n,d.logic_boolean=function(e){return["TRUE"===e.getFieldValue("BOOL")?"true":"false",t.ATOMIC]},d.logic_compare=function(e,i){var n={EQ:"==",NEQ:"!=",LT:"<",LTE:"<=",GT:">",GTE:">="}[e.getFieldValue("OP")],o="=="===n||"!="===n?t.EQUALITY:t.RELATIONAL;return[(i.valueToCode(e,"A",o)||"0")+" "+n+" "+(e=i.valueToCode(e,"B",o)||"0"),o]},d.logic_negate=function(e,i){var n=t.UNARY_PREFIX;return["!"+(i.valueToCode(e,"BOOL",n)||"true"),n]},d.logic_null=function(){return["null",t.ATOMIC]},d.logic_operation=function(e,i){var n="AND"===e.getFieldValue("OP")?"&&":"||",o="&&"===n?t.LOGICAL_AND:t.LOGICAL_OR,s=i.valueToCode(e,"A",o);return e=i.valueToCode(e,"B",o),s||e?(i="&&"===n?"true":"false",s||(s=i),e||(e=i)):e=s="false",[s+" "+n+" "+e,o]},d.logic_ternary=function(e,i){return[(i.valueToCode(e,"IF",t.CONDITIONAL)||"false")+" ? "+(i.valueToCode(e,"THEN",t.CONDITIONAL)||"null")+" : "+(e=i.valueToCode(e,"ELSE",t.CONDITIONAL)||"null"),t.CONDITIONAL]};var p={controls_flow_statements:function(e,t){var i="";if(t.STATEMENT_PREFIX&&(i+=t.injectId(t.STATEMENT_PREFIX,e)),t.STATEMENT_SUFFIX&&(i+=t.injectId(t.STATEMENT_SUFFIX,e)),t.STATEMENT_PREFIX){let n=e.getSurroundLoop();n&&!n.suppressPrefixSuffix&&(i+=t.injectId(t.STATEMENT_PREFIX,n))}switch(e.getFieldValue("FLOW")){case"BREAK":return i+"break;\n";case"CONTINUE":return i+"continue;\n"}throw Error("Unknown flow statement.")},controls_for:function(e,n){var o=n.getVariableName(e.getFieldValue("VAR")),s=n.valueToCode(e,"FROM",t.ASSIGNMENT)||"0",r=n.valueToCode(e,"TO",t.ASSIGNMENT)||"0",a=n.valueToCode(e,"BY",t.ASSIGNMENT)||"1",l=n.statementToCode(e,"DO");if(l=n.addLoopTrap(l,e),i.zf(s)&&i.zf(r)&&i.zf(a))e="for ("+o+" = "+s+"; "+o+((n=Number(s)<=Number(r))?" <= ":" >= ")+r+"; "+o,e=1===(o=Math.abs(Number(a)))?e+(n?"++":"--"):e+(n?" += ":" -= ")+o,e+=") {\n"+l+"}\n";else{e="";let t=s;s.match(/^\w+$/)||i.zf(s)||(t=n.nameDB_.getDistinctName(o+"_start",i.P.VARIABLE),e+="var "+t+" = "+s+";\n"),s=r,r.match(/^\w+$/)||i.zf(r)||(e+="var "+(s=n.nameDB_.getDistinctName(o+"_end",i.P.VARIABLE))+" = "+r+";\n"),e+="num "+(r=n.nameDB_.getDistinctName(o+"_inc",i.P.VARIABLE))+" = ",e=i.zf(a)?e+(Math.abs(Number(a))+";\n"):e+"("+a+").abs();\n",e+="if ("+t+" > "+s+") {\n",e=(e+=n.INDENT+r+" = -"+r+";\n")+"}\nfor ("+o+" = "+t+"; "+r+" >= 0 ? "+o+" <= "+s+" : "+o+" >= "+s+"; "+o+" += "+r+") {\n"+l+"}\n"}return e},controls_forEach:function(e,i){var n=i.getVariableName(e.getFieldValue("VAR")),o=i.valueToCode(e,"LIST",t.ASSIGNMENT)||"[]",s=i.statementToCode(e,"DO");return"for (var "+n+" in "+o+") {\n"+(s=i.addLoopTrap(s,e))+"}\n"}};p.controls_repeat=o,p.controls_repeat_ext=o,p.controls_whileUntil=function(e,i){var n="UNTIL"===e.getFieldValue("MODE"),o=i.valueToCode(e,"BOOL",n?t.UNARY_PREFIX:t.NONE)||"false",s=i.statementToCode(e,"DO");return n&&(o="!"+o),"while ("+o+") {\n"+(s=i.addLoopTrap(s,e))+"}\n"};var g={math_arithmetic:function(e,i){var n={ADD:[" + ",t.ADDITIVE],MINUS:[" - ",t.ADDITIVE],MULTIPLY:[" * ",t.MULTIPLICATIVE],DIVIDE:[" / ",t.MULTIPLICATIVE],POWER:[null,t.NONE]}[e.getFieldValue("OP")],o=n[0];n=n[1];var s=i.valueToCode(e,"A",n)||"0";return e=i.valueToCode(e,"B",n)||"0",o?[s+o+e,n]:(i.definitions_.import_dart_math="import 'dart:math' as Math;",["Math.pow("+s+", "+e+")",t.UNARY_POSTFIX])},math_atan2:function(e,i){i.definitions_.import_dart_math="import 'dart:math' as Math;";var n=i.valueToCode(e,"X",t.NONE)||"0";return["Math.atan2("+(i.valueToCode(e,"Y",t.NONE)||"0")+", "+n+") / Math.pi * 180",t.MULTIPLICATIVE]},math_change:function(e,i){var n=i.valueToCode(e,"DELTA",t.ADDITIVE)||"0";return(e=i.getVariableName(e.getFieldValue("VAR")))+" = ("+e+" is num ? "+e+" : 0) + "+n+";\n"},math_constant:function(e,i){var n={PI:["Math.pi",t.UNARY_POSTFIX],E:["Math.e",t.UNARY_POSTFIX],GOLDEN_RATIO:["(1 + Math.sqrt(5)) / 2",t.MULTIPLICATIVE],SQRT2:["Math.sqrt2",t.UNARY_POSTFIX],SQRT1_2:["Math.sqrt1_2",t.UNARY_POSTFIX],INFINITY:["double.infinity",t.ATOMIC]};return"INFINITY"!==(e=e.getFieldValue("CONSTANT"))&&(i.definitions_.import_dart_math="import 'dart:math' as Math;"),n[e]},math_constrain:function(e,i){return i.definitions_.import_dart_math="import 'dart:math' as Math;",["Math.min(Math.max("+(i.valueToCode(e,"VALUE",t.NONE)||"0")+", "+(i.valueToCode(e,"LOW",t.NONE)||"0")+"), "+(e=i.valueToCode(e,"HIGH",t.NONE)||"double.infinity")+")",t.UNARY_POSTFIX]},math_modulo:function(e,i){return[(i.valueToCode(e,"DIVIDEND",t.MULTIPLICATIVE)||"0")+" % "+(e=i.valueToCode(e,"DIVISOR",t.MULTIPLICATIVE)||"0"),t.MULTIPLICATIVE]},math_number:function(e){return(e=Number(e.getFieldValue("NUM")))===1/0?["double.infinity",t.UNARY_POSTFIX]:e===-1/0?["-double.infinity",t.UNARY_PREFIX]:[String(e),e<0?t.UNARY_PREFIX:t.ATOMIC]},math_number_property:function(e,i){var n={EVEN:[" % 2 == 0",t.MULTIPLICATIVE,t.EQUALITY],ODD:[" % 2 == 1",t.MULTIPLICATIVE,t.EQUALITY],WHOLE:[" % 1 == 0",t.MULTIPLICATIVE,t.EQUALITY],POSITIVE:[" > 0",t.RELATIONAL,t.RELATIONAL],NEGATIVE:[" < 0",t.RELATIONAL,t.RELATIONAL],DIVISIBLE_BY:[null,t.MULTIPLICATIVE,t.EQUALITY],PRIME:[null,t.NONE,t.UNARY_POSTFIX]},o=e.getFieldValue("PROPERTY"),[s,r,a]=n[o];if(n=i.valueToCode(e,"NUMBER_TO_CHECK",r)||"0","PRIME"===o)i.definitions_.import_dart_math="import 'dart:math' as Math;",e=i.provideFunction_("math_isPrime",`\nbool ${i.FUNCTION_NAME_PLACEHOLDER_}(n) {\n // https://en.wikipedia.org/wiki/Primality_test#Naive_methods\n if (n == 2 || n == 3) {\n return true;\n }\n // False if n is null, negative, is 1, or not whole.\n // And false if n is divisible by 2 or 3.\n if (n == null || n <= 1 || n % 1 != 0 || n % 2 == 0 || n % 3 == 0) {\n return false;\n }\n // Check all the numbers of form 6k +/- 1, up to sqrt(n).\n for (var x = 6; x <= Math.sqrt(n) + 1; x += 6) {\n if (n % (x - 1) == 0 || n % (x + 1) == 0) {\n return false;\n }\n }\n return true;\n}\n`)+"("+n+")";else if("DIVISIBLE_BY"===o){if("0"===(e=i.valueToCode(e,"DIVISOR",t.MULTIPLICATIVE)||"0"))return["false",t.ATOMIC];e=n+" % "+e+" == 0"}else e=n+s;return[e,a]},math_on_list:function(e,i){var n=e.getFieldValue("OP");switch(e=i.valueToCode(e,"LIST",t.NONE)||"[]",n){case"SUM":i=i.provideFunction_("math_sum",`\nnum ${i.FUNCTION_NAME_PLACEHOLDER_}(List<num> myList) {\n num sumVal = 0;\n myList.forEach((num entry) {sumVal += entry;});\n return sumVal;\n}\n`)+"("+e+")";break;case"MIN":i.definitions_.import_dart_math="import 'dart:math' as Math;",i=i.provideFunction_("math_min",`\nnum ${i.FUNCTION_NAME_PLACEHOLDER_}(List<num> myList) {\n if (myList.isEmpty) return null;\n num minVal = myList[0];\n myList.forEach((num entry) {minVal = Math.min(minVal, entry);});\n return minVal;\n}\n`)+"("+e+")";break;case"MAX":i.definitions_.import_dart_math="import 'dart:math' as Math;",i=i.provideFunction_("math_max",`\nnum ${i.FUNCTION_NAME_PLACEHOLDER_}(List<num> myList) {\n if (myList.isEmpty) return null;\n num maxVal = myList[0];\n myList.forEach((num entry) {maxVal = Math.max(maxVal, entry);});\n return maxVal;\n}\n`)+"("+e+")";break;case"AVERAGE":i=i.provideFunction_("math_mean",`\nnum ${i.FUNCTION_NAME_PLACEHOLDER_}(List myList) {\n // First filter list for numbers only.\n List localList = new List.from(myList);\n localList.removeWhere((a) => a is! num);\n if (localList.isEmpty) return null;\n num sumVal = 0;\n localList.forEach((var entry) {sumVal += entry;});\n return sumVal / localList.length;\n}\n`)+"("+e+")";break;case"MEDIAN":i=i.provideFunction_("math_median",`\nnum ${i.FUNCTION_NAME_PLACEHOLDER_}(List myList) {\n // First filter list for numbers only, then sort, then return middle value\n // or the average of two middle values if list has an even number of elements.\n List localList = new List.from(myList);\n localList.removeWhere((a) => a is! num);\n if (localList.isEmpty) return null;\n localList.sort((a, b) => (a - b));\n int index = localList.length ~/ 2;\n if (localList.length % 2 == 1) {\n return localList[index];\n } else {\n return (localList[index - 1] + localList[index]) / 2;\n }\n}\n`)+"("+e+")";break;case"MODE":i.definitions_.import_dart_math="import 'dart:math' as Math;",i=i.provideFunction_("math_modes",`\nList ${i.FUNCTION_NAME_PLACEHOLDER_}(List values) {\n List modes = [];\n List counts = [];\n int maxCount = 0;\n for (int i = 0; i < values.length; i++) {\n var value = values[i];\n bool found = false;\n int thisCount;\n for (int j = 0; j < counts.length; j++) {\n if (counts[j][0] == value) {\n thisCount = ++counts[j][1];\n found = true;\n break;\n }\n }\n if (!found) {\n counts.add([value, 1]);\n thisCount = 1;\n }\n maxCount = Math.max(thisCount, maxCount);\n }\n for (int j = 0; j < counts.length; j++) {\n if (counts[j][1] == maxCount) {\n modes.add(counts[j][0]);\n }\n }\n return modes;\n}\n`)+"("+e+")";break;case"STD_DEV":i.definitions_.import_dart_math="import 'dart:math' as Math;",i=i.provideFunction_("math_standard_deviation",`\nnum ${i.FUNCTION_NAME_PLACEHOLDER_}(List myList) {\n // First filter list for numbers only.\n List numbers = new List.from(myList);\n numbers.removeWhere((a) => a is! num);\n if (numbers.isEmpty) return null;\n num n = numbers.length;\n num sum = 0;\n numbers.forEach((x) => sum += x);\n num mean = sum / n;\n num sumSquare = 0;\n numbers.forEach((x) => sumSquare += Math.pow(x - mean, 2));\n return Math.sqrt(sumSquare / n);\n}\n`)+"("+e+")";break;case"RANDOM":i.definitions_.import_dart_math="import 'dart:math' as Math;",i=i.provideFunction_("math_random_item",`\ndynamic ${i.FUNCTION_NAME_PLACEHOLDER_}(List myList) {\n int x = new Math.Random().nextInt(myList.length);\n return myList[x];\n}\n`)+"("+e+")";break;default:throw Error("Unknown operator: "+n)}return[i,t.UNARY_POSTFIX]},math_random_float:function(e,i){return i.definitions_.import_dart_math="import 'dart:math' as Math;",["new Math.Random().nextDouble()",t.UNARY_POSTFIX]},math_random_int:function(e,i){i.definitions_.import_dart_math="import 'dart:math' as Math;";var n=i.valueToCode(e,"FROM",t.NONE)||"0";return e=i.valueToCode(e,"TO",t.NONE)||"0",[i.provideFunction_("math_random_int",`\nint ${i.FUNCTION_NAME_PLACEHOLDER_}(num a, num b) {\n if (a > b) {\n // Swap a and b to ensure a is smaller.\n num c = a;\n a = b;\n b = c;\n }\n return new Math.Random().nextInt(b - a + 1) + a;\n}\n`)+"("+n+", "+e+")",t.UNARY_POSTFIX]}};g.math_round=s,g.math_single=s,g.math_trig=s;var E={procedures_callnoreturn:function(e,t){return t.forBlock.procedures_callreturn(e,t)[0]+";\n"},procedures_callreturn:function(e,i){var n=i.getProcedureName(e.getFieldValue("NAME")),o=[],s=e.getVarModels();for(let n=0;n<s.length;n++)o[n]=i.valueToCode(e,"ARG"+n,t.NONE)||"null";return[n+"("+o.join(", ")+")",t.UNARY_POSTFIX]}};E.procedures_defnoreturn=r,E.procedures_defreturn=r,E.procedures_ifreturn=function(e,i){var n="if ("+(i.valueToCode(e,"CONDITION",t.NONE)||"false")+") {\n";return i.STATEMENT_SUFFIX&&(n+=i.prefixLines(i.injectId(i.STATEMENT_SUFFIX,e),i.INDENT)),e.hasReturnValue_?(e=i.valueToCode(e,"VALUE",t.NONE)||"null",n+=i.INDENT+"return "+e+";\n"):n+=i.INDENT+"return;\n",n+"}\n"};var T={text:function(e,i){return[i.quote_(e.getFieldValue("TEXT")),t.ATOMIC]},text_append:function(e,i){var n=i.getVariableName(e.getFieldValue("VAR"));return n+" = ["+n+", "+(e=i.valueToCode(e,"TEXT",t.NONE)||"''")+"].join();\n"},text_changeCase:function(e,i){var n={UPPERCASE:".toUpperCase()",LOWERCASE:".toLowerCase()",TITLECASE:null}[e.getFieldValue("CASE")];return e=i.valueToCode(e,"TEXT",n?t.UNARY_POSTFIX:t.NONE)||"''",[n?e+n:i.provideFunction_("text_toTitleCase",`\nString ${i.FUNCTION_NAME_PLACEHOLDER_}(String str) {\n RegExp exp = new RegExp(r'\\b');\n List<String> list = str.split(exp);\n final title = new StringBuffer();\n for (String part in list) {\n if (part.length > 0) {\n title.write(part[0].toUpperCase());\n if (part.length > 0) {\n title.write(part.substring(1).toLowerCase());\n }\n }\n }\n return title.toString();\n}\n`)+"("+e+")",t.UNARY_POSTFIX]},text_charAt:function(e,i){var n=e.getFieldValue("WHERE")||"FROM_START",o=i.valueToCode(e,"VALUE","FIRST"===n||"FROM_START"===n?t.UNARY_POSTFIX:t.NONE)||"''";switch(n){case"FIRST":return[o+"[0]",t.UNARY_POSTFIX];case"FROM_START":return[o+"["+(e=i.getAdjusted(e,"AT"))+"]",t.UNARY_POSTFIX];case"LAST":case"FROM_END":return e="LAST"===n?1:i.getAdjusted(e,"AT",1),[`${i.provideFunction_("text_get_from_end",`\nString ${i.FUNCTION_NAME_PLACEHOLDER_}(String text, num x) {\n return text[text.length - x];\n}\n`)}(${o}, ${e})`,t.UNARY_POSTFIX];case"RANDOM":return i.definitions_.import_dart_math="import 'dart:math' as Math;",[i.provideFunction_("text_random_letter",`\nString ${i.FUNCTION_NAME_PLACEHOLDER_}(String text) {\n int x = new Math.Random().nextInt(text.length);\n return text[x];\n}\n`)+"("+o+")",t.UNARY_POSTFIX]}throw Error("Unhandled option (text_charAt).")},text_count:function(e,i){var n=i.valueToCode(e,"TEXT",t.NONE)||"''";return e=i.valueToCode(e,"SUB",t.NONE)||"''",[i.provideFunction_("text_count",`\nint ${i.FUNCTION_NAME_PLACEHOLDER_}(String haystack, String needle) {\n if (needle.length == 0) {\n return haystack.length + 1;\n }\n int index = 0;\n int count = 0;\n while (index != -1) {\n index = haystack.indexOf(needle, index);\n if (index != -1) {\n count++;\n index += needle.length;\n }\n }\n return count;\n}\n`)+"("+n+", "+e+")",t.UNARY_POSTFIX]},text_getSubstring:function(e,i){var n=e.getFieldValue("WHERE1"),o=e.getFieldValue("WHERE2"),s="FROM_END"!==n&&"FROM_START"===o,r=i.valueToCode(e,"STRING",s?t.UNARY_POSTFIX:t.NONE)||"''";if("FIRST"===n&&"LAST"===o)return[r,t.NONE];if(r.match(/^'?\w+'?$/)||s){switch(n){case"FROM_START":n=i.getAdjusted(e,"AT1");break;case"FROM_END":n=r+".length - "+(n=i.getAdjusted(e,"AT1",1,!1,t.ADDITIVE));break;case"FIRST":n="0";break;default:throw Error("Unhandled option (text_getSubstring).")}switch(o){case"FROM_START":var a=i.getAdjusted(e,"AT2",1);break;case"FROM_END":a=r+".length - "+(a=i.getAdjusted(e,"AT2",0,!1,t.ADDITIVE));break;case"LAST":break;default:throw Error("Unhandled option (text_getSubstring).")}i="LAST"===o?r+".substring("+n+")":r+".substring("+n+", "+a+")"}else a=i.getAdjusted(e,"AT1"),e=i.getAdjusted(e,"AT2"),i=i.provideFunction_("text_get_substring",`\nString ${i.FUNCTION_NAME_PLACEHOLDER_}(String text, String where1, num at1, String where2, num at2) {\n int getAt(String where, num at) {\n if (where == 'FROM_END') {\n at = text.length - 1 - at;\n } else if (where == 'FIRST') {\n at = 0;\n } else if (where == 'LAST') {\n at = text.length - 1;\n } else if (where != 'FROM_START') {\n throw 'Unhandled option (text_getSubstring).';\n }\n return at;\n }\n at1 = getAt(where1, at1);\n at2 = getAt(where2, at2) + 1;\n return text.substring(at1, at2);\n}\n`)+"("+r+", '"+n+"', "+a+", '"+o+"', "+e+")";return[i,t.UNARY_POSTFIX]},text_indexOf:function(e,i){var n="FIRST"===e.getFieldValue("END")?"indexOf":"lastIndexOf",o=i.valueToCode(e,"FIND",t.NONE)||"''";return i=(i.valueToCode(e,"VALUE",t.UNARY_POSTFIX)||"''")+"."+n+"("+o+")",e.workspace.options.oneBasedIndex?[i+" + 1",t.ADDITIVE]:[i,t.UNARY_POSTFIX]},text_isEmpty:function(e,i){return[(i.valueToCode(e,"VALUE",t.UNARY_POSTFIX)||"''")+".isEmpty",t.UNARY_POSTFIX]},text_join:function(e,i){switch(e.itemCount_){case 0:return["''",t.ATOMIC];case 1:return[(i.valueToCode(e,"ADD0",t.UNARY_POSTFIX)||"''")+".toString()",t.UNARY_POSTFIX];default:let n=Array(e.itemCount_);for(let o=0;o<e.itemCount_;o++)n[o]=i.valueToCode(e,"ADD"+o,t.NONE)||"''";return["["+n.join(",")+"].join()",t.UNARY_POSTFIX]}},text_length:function(e,i){return[(i.valueToCode(e,"VALUE",t.UNARY_POSTFIX)||"''")+".length",t.UNARY_POSTFIX]},text_print:function(e,i){return"print("+(i.valueToCode(e,"TEXT",t.NONE)||"''")+");\n"}};T.text_prompt=a,T.text_prompt_ext=a,T.text_replace=function(e,i){return[(i.valueToCode(e,"TEXT",t.UNARY_POSTFIX)||"''")+".replaceAll("+(i.valueToCode(e,"FROM",t.NONE)||"''")+", "+(e=i.valueToCode(e,"TO",t.NONE)||"''")+")",t.UNARY_POSTFIX]},T.text_reverse=function(e,i){return["new String.fromCharCodes("+(i.valueToCode(e,"TEXT",t.UNARY_POSTFIX)||"''")+".runes.toList().reversed)",t.UNARY_PREFIX]},T.text_trim=function(e,i){var n={LEFT:".replaceFirst(new RegExp(r'^\\s+'), '')",RIGHT:".replaceFirst(new RegExp(r'\\s+$'), '')",BOTH:".trim()"}[e.getFieldValue("MODE")];return[(i.valueToCode(e,"TEXT",t.UNARY_POSTFIX)||"''")+n,t.UNARY_POSTFIX]};var _={};_.variables_get=l,_.variables_set=h;var f={};f.variables_get_dynamic=l,f.variables_set_dynamic=h;var m=new c;m.addReservedWords("Html,Math");var b=Object.assign({},{lists_create_empty:function(){return["[]",t.ATOMIC]},lists_create_with:function(e,i){var n=Array(e.itemCount_);for(let o=0;o<e.itemCount_;o++)n[o]=i.valueToCode(e,"ADD"+o,t.NONE)||"null";return["["+n.join(", ")+"]",t.ATOMIC]},lists_getIndex:function(e,n){function o(){var e=n.nameDB_.getDistinctName("tmp_list",i.P.VARIABLE),t="List "+e+" = "+a+";\n";return a=e,t}var s=e.getFieldValue("MODE")||"GET",r=e.getFieldValue("WHERE")||"FROM_START",a=n.valueToCode(e,"VALUE","RANDOM"===r||"FROM_END"===r?t.NONE:t.UNARY_POSTFIX)||"[]";if(("RANDOM"!==r||"REMOVE"!==s)&&"FROM_END"!==r||a.match(/^\w+$/))switch(r){case"FIRST":if("GET"===s)return[a+".first",t.UNARY_POSTFIX];if("GET_REMOVE"===s)return[a+".removeAt(0)",t.UNARY_POSTFIX];if("REMOVE"===s)return a+".removeAt(0);\n";break;case"LAST":if("GET"===s)return[a+".last",t.UNARY_POSTFIX];if("GET_REMOVE"===s)return[a+".removeLast()",t.UNARY_POSTFIX];if("REMOVE"===s)return a+".removeLast();\n";break;case"FROM_START":if(e=n.getAdjusted(e,"AT"),"GET"===s)return[a+"["+e+"]",t.UNARY_POSTFIX];if("GET_REMOVE"===s)return[a+".removeAt("+e+")",t.UNARY_POSTFIX];if("REMOVE"===s)return a+".removeAt("+e+");\n";break;case"FROM_END":if(e=n.getAdjusted(e,"AT",1,!1,t.ADDITIVE),"GET"===s)return[a+"["+a+".length - "+e+"]",t.UNARY_POSTFIX];if("GET_REMOVE"===s||"REMOVE"===s){if(e=a+".removeAt("+a+".length - "+e+")","GET_REMOVE"===s)return[e,t.UNARY_POSTFIX];if("REMOVE"===s)return e+";\n"}break;case"RANDOM":if(n.definitions_.import_dart_math="import 'dart:math' as Math;","REMOVE"===s)return"int "+(s=n.nameDB_.getDistinctName("tmp_x",i.P.VARIABLE))+" = new Math.Random().nextInt("+a+".length);\n"+a+".removeAt("+s+");\n";if("GET"===s)return[n.provideFunction_("lists_get_random_item",`\ndynamic ${n.FUNCTION_NAME_PLACEHOLDER_}(List my_list) {\n int x = new Math.Random().nextInt(my_list.length);\n return my_list[x];\n}\n`)+"("+a+")",t.UNARY_POSTFIX];if("GET_REMOVE"===s)return[n.provideFunction_("lists_remove_random_item",`\ndynamic ${n.FUNCTION_NAME_PLACEHOLDER_}(List my_list) {\n int x = new Math.Random().nextInt(my_list.length);\n return my_list.removeAt(x);\n}\n`)+"("+a+")",t.UNARY_POSTFIX]}else{if("RANDOM"===r)return n.definitions_.import_dart_math="import 'dart:math' as Math;",(s=o())+"int "+(e=n.nameDB_.getDistinctName("tmp_x",i.P.VARIABLE))+" = new Math.Random().nextInt("+a+".length);\n"+a+".removeAt("+e+");\n";if("REMOVE"===s)return s=n.getAdjusted(e,"AT",1,!1,t.ADDITIVE),o()+(a+".removeAt(")+a+".length - "+s+");\n";if("GET"===s)return s=n.getAdjusted(e,"AT",1),[n.provideFunction_("lists_get_from_end",`\ndynamic ${n.FUNCTION_NAME_PLACEHOLDER_}(List my_list, num x) {\n x = my_list.length - x;\n return my_list[x];\n}\n`)+"("+a+", "+s+")",t.UNARY_POSTFIX];if("GET_REMOVE"===s)return s=n.getAdjusted(e,"AT",1),[n.provideFunction_("lists_remove_from_end",`\ndynamic ${n.FUNCTION_NAME_PLACEHOLDER_}(List my_list, num x) {\n x = my_list.length - x;\n return my_list.removeAt(x);\n}\n`)+"("+a+", "+s+")",t.UNARY_POSTFIX]}throw Error("Unhandled combination (lists_getIndex).")},lists_getSublist:function(e,i){var n=i.valueToCode(e,"LIST",t.UNARY_POSTFIX)||"[]",o=e.getFieldValue("WHERE1"),s=e.getFieldValue("WHERE2");if(n.match(/^\w+$/)||"FROM_END"!==o&&"FROM_START"===s){switch(o){case"FROM_START":o=i.getAdjusted(e,"AT1");break;case"FROM_END":o=n+".length - "+(o=i.getAdjusted(e,"AT1",1,!1,t.ADDITIVE));break;case"FIRST":o="0";break;default:throw Error("Unhandled option (lists_getSublist).")}switch(s){case"FROM_START":var r=i.getAdjusted(e,"AT2",1);break;case"FROM_END":r=n+".length - "+(r=i.getAdjusted(e,"AT2",0,!1,t.ADDITIVE));break;case"LAST":break;default:throw Error("Unhandled option (lists_getSublist).")}i="LAST"===s?n+".sublist("+o+")":n+".sublist("+o+", "+r+")"}else r=i.getAdjusted(e,"AT1"),e=i.getAdjusted(e,"AT2"),i=i.provideFunction_("lists_get_sublist",`\nList ${i.FUNCTION_NAME_PLACEHOLDER_}(List list, String where1, num at1, String where2, num at2) {\n int getAt(String where, num at) {\n if (where == 'FROM_END') {\n at = list.length - 1 - at;\n } else if (where == 'FIRST') {\n at = 0;\n } else if (where == 'LAST') {\n at = list.length - 1;\n } else if (where != 'FROM_START') {\n throw 'Unhandled option (lists_getSublist).';\n }\n return at;\n }\n at1 = getAt(where1, at1);\n at2 = getAt(where2, at2) + 1;\n return list.sublist(at1, at2);\n}\n`)+"("+n+", '"+o+"', "+r+", '"+s+"', "+e+")";return[i,t.UNARY_POSTFIX]},lists_indexOf:function(e,i){var n="FIRST"===e.getFieldValue("END")?"indexOf":"lastIndexOf",o=i.valueToCode(e,"FIND",t.NONE)||"''";return i=(i.valueToCode(e,"VALUE",t.UNARY_POSTFIX)||"[]")+"."+n+"("+o+")",e.workspace.options.oneBasedIndex?[i+" + 1",t.ADDITIVE]:[i,t.UNARY_POSTFIX]},lists_isEmpty:function(e,i){return[(i.valueToCode(e,"VALUE",t.UNARY_POSTFIX)||"[]")+".isEmpty",t.UNARY_POSTFIX]},lists_length:function(e,i){return[(i.valueToCode(e,"VALUE",t.UNARY_POSTFIX)||"[]")+".length",t.UNARY_POSTFIX]},lists_repeat:function(e,i){var n=i.valueToCode(e,"ITEM",t.NONE)||"null";return["new List.filled("+(i.valueToCode(e,"NUM",t.NONE)||"0")+", "+n+")",t.UNARY_POSTFIX]},lists_reverse:function(e,i){return["new List.from("+(i.valueToCode(e,"LIST",t.NONE)||"[]")+".reversed)",t.UNARY_POSTFIX]},lists_setIndex:function(e,n){function o(){if(a.match(/^\w+$/))return"";var e=n.nameDB_.getDistinctName("tmp_list",i.P.VARIABLE),t="List "+e+" = "+a+";\n";return a=e,t}var s=e.getFieldValue("MODE")||"GET",r=e.getFieldValue("WHERE")||"FROM_START",a=n.valueToCode(e,"LIST",t.UNARY_POSTFIX)||"[]",l=n.valueToCode(e,"TO",t.ASSIGNMENT)||"null";switch(r){case"FIRST":if("SET"===s)return a+"[0] = "+l+";\n";if("INSERT"===s)return a+".insert(0, "+l+");\n";break;case"LAST":if("SET"===s)return o()+(a+"[")+a+".length - 1] = "+l+";\n";if("INSERT"===s)return a+".add("+l+");\n";break;case"FROM_START":if(e=n.getAdjusted(e,"AT"),"SET"===s)return a+"["+e+"] = "+l+";\n";if("INSERT"===s)return a+".insert("+e+", "+l+");\n";break;case"FROM_END":if(e=n.getAdjusted(e,"AT",1,!1,t.ADDITIVE),r=o(),"SET"===s)return r+(a+"[")+a+".length - "+e+"] = "+l+";\n";if("INSERT"===s)return r+(a+".insert(")+a+".length - "+e+", "+l+");\n";break;case"RANDOM":if(n.definitions_.import_dart_math="import 'dart:math' as Math;",e=o(),e+="int "+(r=n.nameDB_.getDistinctName("tmp_x",i.P.VARIABLE))+" = new Math.Random().nextInt("+a+".length);\n","SET"===s)return e+(a+"[")+r+"] = "+l+";\n";if("INSERT"===s)return e+(a+".insert(")+r+", "+l+");\n"}throw Error("Unhandled combination (lists_setIndex).")},lists_sort:function(e,i){var n=i.valueToCode(e,"LIST",t.NONE)||"[]",o="1"===e.getFieldValue("DIRECTION")?1:-1;return e=e.getFieldValue("TYPE"),[i.provideFunction_("lists_sort",`\nList ${i.FUNCTION_NAME_PLACEHOLDER_}(List list, String type, int direction) {\n var compareFuncs = {\n 'NUMERIC': (a, b) => (direction * a.compareTo(b)).toInt(),\n 'TEXT': (a, b) => direction * a.toString().compareTo(b.toString()),\n 'IGNORE_CASE':\n (a, b) => direction *\n a.toString().toLowerCase().compareTo(b.toString().toLowerCase())\n };\n list = new List.from(list);\n var compare = compareFuncs[type];\n list.sort(compare);\n return list;\n}\n`)+"("+n+', "'+e+'", '+o+")",t.UNARY_POSTFIX]},lists_split:function(e,i){var n=i.valueToCode(e,"INPUT",t.UNARY_POSTFIX);if(i=i.valueToCode(e,"DELIM",t.NONE)||"''","SPLIT"===(e=e.getFieldValue("MODE")))n||(n="''"),e="split";else{if("JOIN"!==e)throw Error("Unknown mode: "+e);n||(n="[]"),e="join"}return[n+"."+e+"("+i+")",t.UNARY_POSTFIX]}},d,p,g,E,T,_,f);for(let e in b)m.forBlock[e]=b[e];var C={};return C.DartGenerator=c,C.Order=t,C.dartGenerator=m,i.__chunk_dart=C,i.__chunk_dart.__namespace__=i,i.__chunk_dart})?n.apply(t,o):n)||(e.exports=s)},449:function(e,t,i){var n,o,s;o=[i(500)],void 0===(s="function"==typeof(n=function(e){var t,i=e.__namespace__,n=function(e,t,i){return"FIRST"===t?"0":"FROM_END"===t?e+".length - 1 - "+i:"LAST"===t?e+".length - 1":i},o=function(e,i){var n=0,o="";i.STATEMENT_PREFIX&&(o+=i.injectId(i.STATEMENT_PREFIX,e));do{let s=i.valueToCode(e,"IF"+n,t.NONE)||"false",r=i.statementToCode(e,"DO"+n);i.STATEMENT_SUFFIX&&(r=i.prefixLines(i.injectId(i.STATEMENT_SUFFIX,e),i.INDENT)+r),o+=(n>0?" else ":"")+"if ("+s+") {\n"+r+"}",n++}while(e.getInput("IF"+n));return(e.getInput("ELSE")||i.STATEMENT_SUFFIX)&&(n=e.getInput("ELSE")?i.statementToCode(e,"ELSE"):"",i.STATEMENT_SUFFIX&&(n=i.prefixLines(i.injectId(i.STATEMENT_SUFFIX,e),i.INDENT)+n),o+=" else {\n"+n+"}"),o+"\n"},s=function(e,n){var o=e.getField("TIMES")?String(Number(e.getFieldValue("TIMES"))):n.valueToCode(e,"TIMES",t.ASSIGNMENT)||"0",s=n.statementToCode(e,"DO");s=n.addLoopTrap(s,e),e="";var r=n.nameDB_.getDistinctName("count",i.P.VARIABLE),a=o;return o.match(/^\w+$/)||i.zf(o)||(e+="var "+(a=n.nameDB_.getDistinctName("repeat_end",i.P.VARIABLE))+" = "+o+";\n"),e+"for (var "+r+" = 0; "+r+" < "+a+"; "+r+"++) {\n"+s+"}\n"},r=function(e,i){var n=e.getFieldValue("OP");if("NEG"===n)return"-"===(e=i.valueToCode(e,"NUM",t.UNARY_NEGATION)||"0")[0]&&(e=" "+e),["-"+e,t.UNARY_NEGATION];switch(e="SIN"===n||"COS"===n||"TAN"===n?i.valueToCode(e,"NUM",t.DIVISION)||"0":i.valueToCode(e,"NUM",t.NONE)||"0",n){case"ABS":var o="Math.abs("+e+")";break;case"ROOT":o="Math.sqrt("+e+")";break;case"LN":o="Math.log("+e+")";break;case"EXP":o="Math.exp("+e+")";break;case"POW10":o="Math.pow(10,"+e+")";break;case"ROUND":o="Math.round("+e+")";break;case"ROUNDUP":o="Math.ceil("+e+")";break;case"ROUNDDOWN":o="Math.floor("+e+")";break;case"SIN":o="Math.sin("+e+" / 180 * Math.PI)";break;case"COS":o="Math.cos("+e+" / 180 * Math.PI)";break;case"TAN":o="Math.tan("+e+" / 180 * Math.PI)"}if(o)return[o,t.FUNCTION_CALL];switch(n){case"LOG10":o="Math.log("+e+") / Math.log(10)";break;case"ASIN":o="Math.asin("+e+") / Math.PI * 180";break;case"ACOS":o="Math.acos("+e+") / Math.PI * 180";break;case"ATAN":o="Math.atan("+e+") / Math.PI * 180";break;default:throw Error("Unknown math operator: "+n)}return[o,t.DIVISION]},a=function(e,i){var n=i.getProcedureName(e.getFieldValue("NAME")),o="";i.STATEMENT_PREFIX&&(o+=i.injectId(i.STATEMENT_PREFIX,e)),i.STATEMENT_SUFFIX&&(o+=i.injectId(i.STATEMENT_SUFFIX,e)),o&&(o=i.prefixLines(o,i.INDENT));var s="";i.INFINITE_LOOP_TRAP&&(s=i.prefixLines(i.injectId(i.INFINITE_LOOP_TRAP,e),i.INDENT));var r="";e.getInput("STACK")&&(r=i.statementToCode(e,"STACK"));var a="";e.getInput("RETURN")&&(a=i.valueToCode(e,"RETURN",t.NONE)||"");var l="";r&&a&&(l=o),a&&(a=i.INDENT+"return "+a+";\n");var h=[],u=e.getVarModels();for(let e=0;e<u.length;e++)h[e]=i.getVariableName(u[e].getId());return o="function "+n+"("+h.join(", ")+") {\n"+o+s+r+l+a+"}",o=i.scrub_(e,o),i.definitions_["%"+n]=o,null},l=function(e){return m.test(e)?[e,t.ATOMIC]:["String("+e+")",t.FUNCTION_CALL]},h=function(e,t,i){return"FIRST"===t?"0":"FROM_END"===t?e+".length - 1 - "+i:"LAST"===t?e+".length - 1":i},u=function(e,i){return i="window.prompt("+(e.getField("TEXT")?i.quote_(e.getFieldValue("TEXT")):i.valueToCode(e,"TEXT",t.NONE)||"''")+")","NUMBER"===e.getFieldValue("TYPE")&&(i="Number("+i+")"),[i,t.FUNCTION_CALL]},c=function(e,i){return[i.getVariableName(e.getFieldValue("VAR")),t.ATOMIC]},d=function(e,i){var n=i.valueToCode(e,"VALUE",t.ASSIGNMENT)||"0";return i.getVariableName(e.getFieldValue("VAR"))+" = "+n+";\n"},p=t||(t={});p[p.ATOMIC=0]="ATOMIC",p[p.NEW=1.1]="NEW",p[p.MEMBER=1.2]="MEMBER",p[p.FUNCTION_CALL=2]="FUNCTION_CALL",p[p.INCREMENT=3]="INCREMENT",p[p.DECREMENT=3]="DECREMENT",p[p.BITWISE_NOT=4.1]="BITWISE_NOT",p[p.UNARY_PLUS=4.2]="UNARY_PLUS",p[p.UNARY_NEGATION=4.3]="UNARY_NEGATION",p[p.LOGICAL_NOT=4.4]="LOGICAL_NOT",p[p.TYPEOF=4.5]="TYPEOF",p[p.VOID=4.6]="VOID",p[p.DELETE=4.7]="DELETE",p[p.AWAIT=4.8]="AWAIT",p[p.EXPONENTIATION=5]="EXPONENTIATION",p[p.MULTIPLICATION=5.1]="MULTIPLICATION",p[p.DIVISION=5.2]="DIVISION",p[p.MODULUS=5.3]="MODULUS",p[p.SUBTRACTION=6.1]="SUBTRACTION",p[p.ADDITION=6.2]="ADDITION",p[p.BITWISE_SHIFT=7]="BITWISE_SHIFT",p[p.RELATIONAL=8]="RELATIONAL",p[p.IN=8]="IN",p[p.INSTANCEOF=8]="INSTANCEOF",p[p.EQUALITY=9]="EQUALITY",p[p.BITWISE_AND=10]="BITWISE_AND",p[p.BITWISE_XOR=11]="BITWISE_XOR",p[p.BITWISE_OR=12]="BITWISE_OR",p[p.LOGICAL_AND=13]="LOGICAL_AND",p[p.LOGICAL_OR=14]="LOGICAL_OR",p[p.CONDITIONAL=15]="CONDITIONAL",p[p.ASSIGNMENT=16]="ASSIGNMENT",p[p.YIELD=17]="YIELD",p[p.COMMA=18]="COMMA",p[p.NONE=99]="NONE";var g=class extends i.zq{constructor(e="JavaScript"){super(e),this.ORDER_OVERRIDES=[[t.FUNCTION_CALL,t.MEMBER],[t.FUNCTION_CALL,t.FUNCTION_CALL],[t.MEMBER,t.MEMBER],[t.MEMBER,t.FUNCTION_CALL],[t.LOGICAL_NOT,t.LOGICAL_NOT],[t.MULTIPLICATION,t.MULTIPLICATION],[t.ADDITION,t.ADDITION],[t.LOGICAL_AND,t.LOGICAL_AND],[t.LOGICAL_OR,t.LOGICAL_OR]],this.isInitialized=!1;for(let i in t)"string"!=typeof(e=t[i])&&(this["ORDER_"+i]=e);this.addReservedWords("break,case,catch,class,const,continue,debugger,default,delete,do,else,export,extends,finally,for,function,if,import,in,instanceof,new,return,super,switch,this,throw,try,typeof,var,void,while,with,yield,enum,implements,interface,let,package,private,protected,public,static,await,null,true,false,arguments,"+Object.getOwnPropertyNames(globalThis).join(","))}init(e){super.init(e),this.nameDB_?this.nameDB_.reset():this.nameDB_=new i.Cj(this.RESERVED_WORDS_),this.nameDB_.setVariableMap(e.getVariableMap()),this.nameDB_.populateVariables(e),this.nameDB_.populateProcedures(e);var t=[],n=i.Cd(e);for(let e=0;e<n.length;e++)t.push(this.nameDB_.getName(n[e],i.P.DEVELOPER_VARIABLE));for(e=i.Bd(e),n=0;n<e.length;n++)t.push(this.nameDB_.getName(e[n].getId(),i.P.VARIABLE));t.length&&(this.definitions_.variables="var "+t.join(", ")+";"),this.isInitialized=!0}finish(e){var t=Object.values(this.definitions_);return super.finish(e),this.isInitialized=!1,this.nameDB_.reset(),t.join("\n\n")+"\n\n\n"+e}scrubNakedValue(e){return e+";\n"}quote_(e){return"'"+(e=e.replace(/\\/g,"\\\\").replace(/\n/g,"\\\n").replace(/'/g,"\\'"))+"'"}multiline_quote_(e){return e.split(/\n/g).map(this.quote_).join(" + '\\n' +\n")}scrub_(e,t,n=!1){var o="";if(!e.outputConnection||!e.outputConnection.targetConnection){var s=e.getCommentText();s&&(s=i.yf(s,this.COMMENT_WRAP-3),o+=this.prefixLines(s+"\n","// "));for(let t=0;t<e.inputList.length;t++)e.inputList[t].type===i.je.VALUE&&(s=e.inputList[t].connection.targetBlock())&&(s=this.allNestedComments(s))&&(o+=this.prefixLines(s,"// "))}return e=e.nextConnection&&e.nextConnection.targetBlock(),o+t+(n?"":this.blockToCode(e))}getAdjusted(e,n,o=0,s=!1,r=t.NONE){e.workspace.options.oneBasedIndex&&o--;var a=e.workspace.options.oneBasedIndex?"1":"0",l=r;return o>0?l=t.ADDITION:o<0?l=t.SUBTRACTION:s&&(l=t.UNARY_NEGATION),e=this.valueToCode(e,n,l)||a,0!==o||s?i.zf(e)?(e=String(Number(e)+o),s&&(e=String(-Number(e))),e):(o>0?e=`${e} + ${o}`:o<0&&(e=`${e} - ${-o}`),s&&(e=o?`-(${e})`:`-${e}`),Math.floor(r)>=Math.floor(l)&&(e=`(${e})`),e):e}},E={};E.controls_if=o,E.controls_ifelse=o,E.logic_boolean=function(e){return["TRUE"===e.getFieldValue("BOOL")?"true":"false",t.ATOMIC]},E.logic_compare=function(e,i){var n={EQ:"==",NEQ:"!=",LT:"<",LTE:"<=",GT:">",GTE:">="}[e.getFieldValue("OP")],o="=="===n||"!="===n?t.EQUALITY:t.RELATIONAL;return[(i.valueToCode(e,"A",o)||"0")+" "+n+" "+(e=i.valueToCode(e,"B",o)||"0"),o]},E.logic_negate=function(e,i){var n=t.LOGICAL_NOT;return["!"+(i.valueToCode(e,"BOOL",n)||"true"),n]},E.logic_null=function(){return["null",t.ATOMIC]},E.logic_operation=function(e,i){var n="AND"===e.getFieldValue("OP")?"&&":"||",o="&&"===n?t.LOGICAL_AND:t.LOGICAL_OR,s=i.valueToCode(e,"A",o);return e=i.valueToCode(e,"B",o),s||e?(i="&&"===n?"true":"false",s||(s=i),e||(e=i)):e=s="false",[s+" "+n+" "+e,o]},E.logic_ternary=function(e,i){return[(i.valueToCode(e,"IF",t.CONDITIONAL)||"false")+" ? "+(i.valueToCode(e,"THEN",t.CONDITIONAL)||"null")+" : "+(e=i.valueToCode(e,"ELSE",t.CONDITIONAL)||"null"),t.CONDITIONAL]};var T={controls_flow_statements:function(e,t){var i="";if(t.STATEMENT_PREFIX&&(i+=t.injectId(t.STATEMENT_PREFIX,e)),t.STATEMENT_SUFFIX&&(i+=t.injectId(t.STATEMENT_SUFFIX,e)),t.STATEMENT_PREFIX){let n=e.getSurroundLoop();n&&!n.suppressPrefixSuffix&&(i+=t.injectId(t.STATEMENT_PREFIX,n))}switch(e.getFieldValue("FLOW")){case"BREAK":return i+"break;\n";case"CONTINUE":return i+"continue;\n"}throw Error("Unknown flow statement.")},controls_for:function(e,n){var o=n.getVariableName(e.getFieldValue("VAR")),s=n.valueToCode(e,"FROM",t.ASSIGNMENT)||"0",r=n.valueToCode(e,"TO",t.ASSIGNMENT)||"0",a=n.valueToCode(e,"BY",t.ASSIGNMENT)||"1",l=n.statementToCode(e,"DO");if(l=n.addLoopTrap(l,e),i.zf(s)&&i.zf(r)&&i.zf(a))e="for ("+o+" = "+s+"; "+o+((n=Number(s)<=Number(r))?" <= ":" >= ")+r+"; "+o,e=1===(o=Math.abs(Number(a)))?e+(n?"++":"--"):e+(n?" += ":" -= ")+o,e+=") {\n"+l+"}\n";else{e="";let t=s;s.match(/^\w+$/)||i.zf(s)||(t=n.nameDB_.getDistinctName(o+"_start",i.P.VARIABLE),e+="var "+t+" = "+s+";\n"),s=r,r.match(/^\w+$/)||i.zf(r)||(e+="var "+(s=n.nameDB_.getDistinctName(o+"_end",i.P.VARIABLE))+" = "+r+";\n"),e+="var "+(r=n.nameDB_.getDistinctName(o+"_inc",i.P.VARIABLE))+" = ",e=i.zf(a)?e+(Math.abs(Number(a))+";\n"):e+"Math.abs("+a+");\n",e+="if ("+t+" > "+s+") {\n",e=(e+=n.INDENT+r+" = -"+r+";\n")+"}\nfor ("+o+" = "+t+"; "+r+" >= 0 ? "+o+" <= "+s+" : "+o+" >= "+s+"; "+o+" += "+r+") {\n"+l+"}\n"}return e},controls_forEach:function(e,n){var o=n.getVariableName(e.getFieldValue("VAR")),s=n.valueToCode(e,"LIST",t.ASSIGNMENT)||"[]",r=n.statementToCode(e,"DO");r=n.addLoopTrap(r,e),e="";var a=s;return s.match(/^\w+$/)||(e+="var "+(a=n.nameDB_.getDistinctName(o+"_list",i.P.VARIABLE))+" = "+s+";\n"),e+"for (var "+(s=n.nameDB_.getDistinctName(o+"_index",i.P.VARIABLE))+" in "+a+") {\n"+(r=n.INDENT+o+" = "+a+"["+s+"];\n"+r)+"}\n"}};T.controls_repeat=s,T.controls_repeat_ext=s,T.controls_whileUntil=function(e,i){var n="UNTIL"===e.getFieldValue("MODE"),o=i.valueToCode(e,"BOOL",n?t.LOGICAL_NOT:t.NONE)||"false",s=i.statementToCode(e,"DO");return n&&(o="!"+o),"while ("+o+") {\n"+(s=i.addLoopTrap(s,e))+"}\n"};var _={math_arithmetic:function(e,i){var n={ADD:[" + ",t.ADDITION],MINUS:[" - ",t.SUBTRACTION],MULTIPLY:[" * ",t.MULTIPLICATION],DIVIDE:[" / ",t.DIVISION],POWER:[null,t.NONE]}[e.getFieldValue("OP")],o=n[0];n=n[1];var s=i.valueToCode(e,"A",n)||"0";return e=i.valueToCode(e,"B",n)||"0",o?[s+o+e,n]:["Math.pow("+s+", "+e+")",t.FUNCTION_CALL]},math_atan2:function(e,i){var n=i.valueToCode(e,"X",t.NONE)||"0";return["Math.atan2("+(i.valueToCode(e,"Y",t.NONE)||"0")+", "+n+") / Math.PI * 180",t.DIVISION]},math_change:function(e,i){var n=i.valueToCode(e,"DELTA",t.ADDITION)||"0";return(e=i.getVariableName(e.getFieldValue("VAR")))+" = (typeof "+e+" === 'number' ? "+e+" : 0) + "+n+";\n"},math_constant:function(e){return{PI:["Math.PI",t.MEMBER],E:["Math.E",t.MEMBER],GOLDEN_RATIO:["(1 + Math.sqrt(5)) / 2",t.DIVISION],SQRT2:["Math.SQRT2",t.MEMBER],SQRT1_2:["Math.SQRT1_2",t.MEMBER],INFINITY:["Infinity",t.ATOMIC]}[e.getFieldValue("CONSTANT")]},math_constrain:function(e,i){return["Math.min(Math.max("+(i.valueToCode(e,"VALUE",t.NONE)||"0")+", "+(i.valueToCode(e,"LOW",t.NONE)||"0")+"), "+(e=i.valueToCode(e,"HIGH",t.NONE)||"Infinity")+")",t.FUNCTION_CALL]},math_modulo:function(e,i){return[(i.valueToCode(e,"DIVIDEND",t.MODULUS)||"0")+" % "+(e=i.valueToCode(e,"DIVISOR",t.MODULUS)||"0"),t.MODULUS]},math_number:function(e){return e=Number(e.getFieldValue("NUM")),[String(e),e>=0?t.ATOMIC:t.UNARY_NEGATION]},math_number_property:function(e,i){var n={EVEN:[" % 2 === 0",t.MODULUS,t.EQUALITY],ODD:[" % 2 === 1",t.MODULUS,t.EQUALITY],WHOLE:[" % 1 === 0",t.MODULUS,t.EQUALITY],POSITIVE:[" > 0",t.RELATIONAL,t.RELATIONAL],NEGATIVE:[" < 0",t.RELATIONAL,t.RELATIONAL],DIVISIBLE_BY:[null,t.MODULUS,t.EQUALITY],PRIME:[null,t.NONE,t.FUNCTION_CALL]},o=e.getFieldValue("PROPERTY"),[s,r,a]=n[o];return n=i.valueToCode(e,"NUMBER_TO_CHECK",r)||"0",[e="PRIME"===o?i.provideFunction_("mathIsPrime",`\nfunction ${i.FUNCTION_NAME_PLACEHOLDER_}(n) {\n // https://en.wikipedia.org/wiki/Primality_test#Naive_methods\n if (n == 2 || n == 3) {\n return true;\n }\n // False if n is NaN, negative, is 1, or not whole.\n // And false if n is divisible by 2 or 3.\n if (isNaN(n) || n <= 1 || n % 1 !== 0 || n % 2 === 0 || n % 3 === 0) {\n return false;\n }\n // Check all the numbers of form 6k +/- 1, up to sqrt(n).\n for (var x = 6; x <= Math.sqrt(n) + 1; x += 6) {\n if (n % (x - 1) === 0 || n % (x + 1) === 0) {\n return false;\n }\n }\n return true;\n}\n`)+"("+n+")":"DIVISIBLE_BY"===o?n+" % "+(e=i.valueToCode(e,"DIVISOR",t.MODULUS)||"0")+" === 0":n+s,a]},math_on_list:function(e,i){var n=e.getFieldValue("OP");switch(n){case"SUM":e=i.valueToCode(e,"LIST",t.MEMBER)||"[]",e+=".reduce(function(x, y) {return x + y;}, 0)";break;case"MIN":e="Math.min.apply(null, "+(e=i.valueToCode(e,"LIST",t.NONE)||"[]")+")";break;case"MAX":e="Math.max.apply(null, "+(e=i.valueToCode(e,"LIST",t.NONE)||"[]")+")";break;case"AVERAGE":e=(n=i.provideFunction_("mathMean",`\nfunction ${i.FUNCTION_NAME_PLACEHOLDER_}(myList) {\n return myList.reduce(function(x, y) {return x + y;}, 0) / myList.length;\n}\n`))+"("+(e=i.valueToCode(e,"LIST",t.NONE)||"[]")+")";break;case"MEDIAN":e=(n=i.provideFunction_("mathMedian",`\nfunction ${i.FUNCTION_NAME_PLACEHOLDER_}(myList) {\n var localList = myList.filter(function (x) {return typeof x === 'number';});\n if (!localList.length) return null;\n localList.sort(function(a, b) {return b - a;});\n if (localList.length % 2 === 0) {\n return (localList[localList.length / 2 - 1] + localList[localList.length / 2]) / 2;\n } else {\n return localList[(localList.length - 1) / 2];\n }\n}\n`))+"("+(e=i.valueToCode(e,"LIST",t.NONE)||"[]")+")";break;case"MODE":e=(n=i.provideFunction_("mathModes",`\nfunction ${i.FUNCTION_NAME_PLACEHOLDER_}(values) {\n var modes = [];\n var counts = [];\n var maxCount = 0;\n for (var i = 0; i < values.length; i++) {\n var value = values[i];\n var found = false;\n var thisCount;\n for (var j = 0; j < counts.length; j++) {\n if (counts[j][0] === value) {\n thisCount = ++counts[j][1];\n found = true;\n break;\n }\n }\n if (!found) {\n counts.push([value, 1]);\n thisCount = 1;\n }\n maxCount = Math.max(thisCount, maxCount);\n }\n for (var j = 0; j < counts.length; j++) {\n if (counts[j][1] === maxCount) {\n modes.push(counts[j][0]);\n }\n }\n return modes;\n}\n`))+"("+(e=i.valueToCode(e,"LIST",t.NONE)||"[]")+")";break;case"STD_DEV":e=(n=i.provideFunction_("mathStandardDeviation",`\nfunction ${i.FUNCTION_NAME_PLACEHOLDER_}(numbers) {\n var n = numbers.length;\n if (!n) return null;\n var mean = numbers.reduce(function(x, y) {return x + y;}) / n;\n var variance = 0;\n for (var j = 0; j < n; j++) {\n variance += Math.pow(numbers[j] - mean, 2);\n }\n variance /= n;\n return Math.sqrt(variance);\n}\n`))+"("+(e=i.valueToCode(e,"LIST",t.NONE)||"[]")+")";break;case"RANDOM":e=(n=i.provideFunction_("mathRandomList",`\nfunction ${i.FUNCTION_NAME_PLACEHOLDER_}(list) {\n var x = Math.floor(Math.random() * list.length);\n return list[x];\n}\n`))+"("+(e=i.valueToCode(e,"LIST",t.NONE)||"[]")+")";break;default:throw Error("Unknown operator: "+n)}return[e,t.FUNCTION_CALL]},math_random_float:function(){return["Math.random()",t.FUNCTION_CALL]},math_random_int:function(e,i){var n=i.valueToCode(e,"FROM",t.NONE)||"0";return e=i.valueToCode(e,"TO",t.NONE)||"0",[i.provideFunction_("mathRandomInt",`\nfunction ${i.FUNCTION_NAME_PLACEHOLDER_}(a, b) {\n if (a > b) {\n // Swap a and b to ensure a is smaller.\n var c = a;\n a = b;\n b = c;\n }\n return Math.floor(Math.random() * (b - a + 1) + a);\n}\n`)+"("+n+", "+e+")",t.FUNCTION_CALL]}};_.math_round=r,_.math_single=r,_.math_trig=r;var f={procedures_callnoreturn:function(e,t){return t.forBlock.procedures_callreturn(e,t)[0]+";\n"},procedures_callreturn:function(e,i){var n=i.getProcedureName(e.getFieldValue("NAME")),o=[],s=e.getVarModels();for(let n=0;n<s.length;n++)o[n]=i.valueToCode(e,"ARG"+n,t.NONE)||"null";return[n+"("+o.join(", ")+")",t.FUNCTION_CALL]}};f.procedures_defnoreturn=a,f.procedures_defreturn=a,f.procedures_ifreturn=function(e,i){var n="if ("+(i.valueToCode(e,"CONDITION",t.NONE)||"false")+") {\n";return i.STATEMENT_SUFFIX&&(n+=i.prefixLines(i.injectId(i.STATEMENT_SUFFIX,e),i.INDENT)),e.hasReturnValue_?(e=i.valueToCode(e,"VALUE",t.NONE)||"null",n+=i.INDENT+"return "+e+";\n"):n+=i.INDENT+"return;\n",n+"}\n"};var m=/^\s*'([^']|\\')*'\s*$/,b={text:function(e,i){return[i.quote_(e.getFieldValue("TEXT")),t.ATOMIC]},text_append:function(e,i){var n=i.getVariableName(e.getFieldValue("VAR"));return e=i.valueToCode(e,"TEXT",t.NONE)||"''",n+" += "+l(e)[0]+";\n"},text_changeCase:function(e,i){var n={UPPERCASE:".toUpperCase()",LOWERCASE:".toLowerCase()",TITLECASE:null}[e.getFieldValue("CASE")];return e=i.valueToCode(e,"TEXT",n?t.MEMBER:t.NONE)||"''",[n?e+n:i.provideFunction_("textToTitleCase",`\nfunction ${i.FUNCTION_NAME_PLACEHOLDER_}(str) {\n return str.replace(/\\S+/g,\n function(txt) {return txt[0].toUpperCase() + txt.substring(1).toLowerCase();});\n}\n`)+"("+e+")",t.FUNCTION_CALL]},text_charAt:function(e,i){var n=e.getFieldValue("WHERE")||"FROM_START",o=i.valueToCode(e,"VALUE","RANDOM"===n?t.NONE:t.MEMBER)||"''";switch(n){case"FIRST":return[o+".charAt(0)",t.FUNCTION_CALL];case"LAST":return[o+".slice(-1)",t.FUNCTION_CALL];case"FROM_START":return[o+".charAt("+(e=i.getAdjusted(e,"AT"))+")",t.FUNCTION_CALL];case"FROM_END":return[o+".slice("+(e=i.getAdjusted(e,"AT",1,!0))+").charAt(0)",t.FUNCTION_CALL];case"RANDOM":return[i.provideFunction_("textRandomLetter",`\nfunction ${i.FUNCTION_NAME_PLACEHOLDER_}(text) {\n var x = Math.floor(Math.random() * text.length);\n return text[x];\n}\n`)+"("+o+")",t.FUNCTION_CALL]}throw Error("Unhandled option (text_charAt).")},text_count:function(e,i){var n=i.valueToCode(e,"TEXT",t.NONE)||"''";return e=i.valueToCode(e,"SUB",t.NONE)||"''",[i.provideFunction_("textCount",`\nfunction ${i.FUNCTION_NAME_PLACEHOLDER_}(haystack, needle) {\n if (needle.length === 0) {\n return haystack.length + 1;\n } else {\n return haystack.split(needle).length - 1;\n }\n}\n`)+"("+n+", "+e+")",t.FUNCTION_CALL]},text_getSubstring:function(e,i){var n={FIRST:"First",LAST:"Last",FROM_START:"FromStart",FROM_END:"FromEnd"},o=e.getFieldValue("WHERE1"),s=e.getFieldValue("WHERE2"),r="FROM_END"!==o&&"LAST"!==o&&"FROM_END"!==s&&"LAST"!==s,a=i.valueToCode(e,"STRING",r?t.MEMBER:t.NONE)||"''";if("FIRST"===o&&"LAST"===s)return[a,t.NONE];if(a.match(/^'?\w+'?$/)||r){switch(o){case"FROM_START":n=i.getAdjusted(e,"AT1");break;case"FROM_END":n=a+".length - "+(n=i.getAdjusted(e,"AT1",1,!1,t.SUBTRACTION));break;case"FIRST":n="0";break;default:throw Error("Unhandled option (text_getSubstring).")}switch(s){case"FROM_START":i=i.getAdjusted(e,"AT2",1);break;case"FROM_END":i=a+".length - "+(i=i.getAdjusted(e,"AT2",0,!1,t.SUBTRACTION));break;case"LAST":i=a+".length";break;default:throw Error("Unhandled option (text_getSubstring).")}a=a+".slice("+n+", "+i+")"}else r=i.getAdjusted(e,"AT1"),e=i.getAdjusted(e,"AT2"),a=i.provideFunction_("subsequence"+n[o]+n[s],`\nfunction ${i.FUNCTION_NAME_PLACEHOLDER_}(sequence${"FROM_END"===o||"FROM_START"===o?", at1":""}${"FROM_END"===s||"FROM_START"===s?", at2":""}) {\n var start = ${h("sequence",o,"at1")};\n var end = ${h("sequence",s,"at2")} + 1;\n return sequence.slice(start, end);\n}\n`)+"("+a+("FROM_END"===o||"FROM_START"===o?", "+r:"")+("FROM_END"===s||"FROM_START"===s?", "+e:"")+")";return[a,t.FUNCTION_CALL]},text_indexOf:function(e,i){var n="FIRST"===e.getFieldValue("END")?"indexOf":"lastIndexOf",o=i.valueToCode(e,"FIND",t.NONE)||"''";return i=(i.valueToCode(e,"VALUE",t.MEMBER)||"''")+"."+n+"("+o+")",e.workspace.options.oneBasedIndex?[i+" + 1",t.ADDITION]:[i,t.FUNCTION_CALL]},text_isEmpty:function(e,i){return["!"+(i.valueToCode(e,"VALUE",t.MEMBER)||"''")+".length",t.LOGICAL_NOT]},text_join:function(e,i){switch(e.itemCount_){case 0:return["''",t.ATOMIC];case 1:return e=i.valueToCode(e,"ADD0",t.NONE)||"''",l(e);case 2:var n=i.valueToCode(e,"ADD0",t.NONE)||"''";return e=i.valueToCode(e,"ADD1",t.NONE)||"''",[l(n)[0]+" + "+l(e)[0],t.ADDITION];default:n=Array(e.itemCount_);for(let o=0;o<e.itemCount_;o++)n[o]=i.valueToCode(e,"ADD"+o,t.NONE)||"''";return["["+n.join(",")+"].join('')",t.FUNCTION_CALL]}},text_length:function(e,i){return[(i.valueToCode(e,"VALUE",t.MEMBER)||"''")+".length",t.MEMBER]},text_print:function(e,i){return"window.alert("+(i.valueToCode(e,"TEXT",t.NONE)||"''")+");\n"}};b.text_prompt=u,b.text_prompt_ext=u,b.text_replace=function(e,i){var n=i.valueToCode(e,"TEXT",t.NONE)||"''",o=i.valueToCode(e,"FROM",t.NONE)||"''";return e=i.valueToCode(e,"TO",t.NONE)||"''",[i.provideFunction_("textReplace",`\nfunction ${i.FUNCTION_NAME_PLACEHOLDER_}(haystack, needle, replacement) {\n needle = needle.replace(/([-()\\[\\]{}+?*.$\\^|,:#<!\\\\])/g, '\\\\$1')\n .replace(/\\x08/g, '\\\\x08');\n return haystack.replace(new RegExp(needle, 'g'), replacement);\n}\n`)+"("+n+", "+o+", "+e+")",t.FUNCTION_CALL]},b.text_reverse=function(e,i){return[(i.valueToCode(e,"TEXT",t.MEMBER)||"''")+".split('').reverse().join('')",t.FUNCTION_CALL]},b.text_trim=function(e,i){var n={LEFT:".replace(/^[\\s\\xa0]+/, '')",RIGHT:".replace(/[\\s\\xa0]+$/, '')",BOTH:".trim()"}[e.getFieldValue("MODE")];return[(i.valueToCode(e,"TEXT",t.MEMBER)||"''")+n,t.FUNCTION_CALL]};var C={};C.variables_get=c,C.variables_set=d;var v={};v.variables_get_dynamic=c,v.variables_set_dynamic=d;var I=new g,N=Object.assign({},{lists_create_empty:function(){return["[]",t.ATOMIC]},lists_create_with:function(e,i){var n=Array(e.itemCount_);for(let o=0;o<e.itemCount_;o++)n[o]=i.valueToCode(e,"ADD"+o,t.NONE)||"null";return["["+n.join(", ")+"]",t.ATOMIC]},lists_getIndex:function(e,i){var n=e.getFieldValue("MODE")||"GET",o=e.getFieldValue("WHERE")||"FROM_START",s=i.valueToCode(e,"VALUE","RANDOM"===o?t.NONE:t.MEMBER)||"[]";switch(o){case"FIRST":if("GET"===n)return[s+"[0]",t.MEMBER];if("GET_REMOVE"===n)return[s+".shift()",t.MEMBER];if("REMOVE"===n)return s+".shift();\n";break;case"LAST":if("GET"===n)return[s+".slice(-1)[0]",t.MEMBER];if("GET_REMOVE"===n)return[s+".pop()",t.MEMBER];if("REMOVE"===n)return s+".pop();\n";break;case"FROM_START":if(e=i.getAdjusted(e,"AT"),"GET"===n)return[s+"["+e+"]",t.MEMBER];if("GET_REMOVE"===n)return[s+".splice("+e+", 1)[0]",t.FUNCTION_CALL];if("REMOVE"===n)return s+".splice("+e+", 1);\n";break;case"FROM_END":if(e=i.getAdjusted(e,"AT",1,!0),"GET"===n)return[s+".slice("+e+")[0]",t.FUNCTION_CALL];if("GET_REMOVE"===n)return[s+".splice("+e+", 1)[0]",t.FUNCTION_CALL];if("REMOVE"===n)return s+".splice("+e+", 1);";break;case"RANDOM":if(s=i.provideFunction_("listsGetRandomItem",`\nfunction ${i.FUNCTION_NAME_PLACEHOLDER_}(list, remove) {\n var x = Math.floor(Math.random() * list.length);\n if (remove) {\n return list.splice(x, 1)[0];\n } else {\n return list[x];\n }\n}\n`)+"("+s+", "+("GET"!==n)+")","GET"===n||"GET_REMOVE"===n)return[s,t.FUNCTION_CALL];if("REMOVE"===n)return s+";\n"}throw Error("Unhandled combination (lists_getIndex).")},lists_getSublist:function(e,i){var o={FIRST:"First",LAST:"Last",FROM_START:"FromStart",FROM_END:"FromEnd"},s=i.valueToCode(e,"LIST",t.MEMBER)||"[]",r=e.getFieldValue("WHERE1"),a=e.getFieldValue("WHERE2");if("FIRST"===r&&"LAST"===a)s+=".slice(0)";else if(s.match(/^\w+$/)||"FROM_END"!==r&&"FROM_START"===a){switch(r){case"FROM_START":o=i.getAdjusted(e,"AT1");break;case"FROM_END":o=s+".length - "+(o=i.getAdjusted(e,"AT1",1,!1,t.SUBTRACTION));break;case"FIRST":o="0";break;default:throw Error("Unhandled option (lists_getSublist).")}switch(a){case"FROM_START":i=i.getAdjusted(e,"AT2",1);break;case"FROM_END":i=s+".length - "+(i=i.getAdjusted(e,"AT2",0,!1,t.SUBTRACTION));break;case"LAST":i=s+".length";break;default:throw Error("Unhandled option (lists_getSublist).")}s=s+".slice("+o+", "+i+")"}else{let t=i.getAdjusted(e,"AT1");e=i.getAdjusted(e,"AT2"),s=i.provideFunction_("subsequence"+o[r]+o[a],`\nfunction ${i.FUNCTION_NAME_PLACEHOLDER_}(sequence${"FROM_END"===r||"FROM_START"===r?", at1":""}${"FROM_END"===a||"FROM_START"===a?", at2":""}) {\n var start = ${n("sequence",r,"at1")};\n var end = ${n("sequence",a,"at2")} + 1;\n return sequence.slice(start, end);\n}\n`)+"("+s+("FROM_END"===r||"FROM_START"===r?", "+t:"")+("FROM_END"===a||"FROM_START"===a?", "+e:"")+")"}return[s,t.FUNCTION_CALL]},lists_indexOf:function(e,i){var n="FIRST"===e.getFieldValue("END")?"indexOf":"lastIndexOf",o=i.valueToCode(e,"FIND",t.NONE)||"''";return i=(i.valueToCode(e,"VALUE",t.MEMBER)||"[]")+"."+n+"("+o+")",e.workspace.options.oneBasedIndex?[i+" + 1",t.ADDITION]:[i,t.FUNCTION_CALL]},lists_isEmpty:function(e,i){return["!"+(i.valueToCode(e,"VALUE",t.MEMBER)||"[]")+".length",t.LOGICAL_NOT]},lists_length:function(e,i){return[(i.valueToCode(e,"VALUE",t.MEMBER)||"[]")+".length",t.MEMBER]},lists_repeat:function(e,i){return[i.provideFunction_("listsRepeat",`\nfunction ${i.FUNCTION_NAME_PLACEHOLDER_}(value, n) {\n var array = [];\n for (var i = 0; i < n; i++) {\n array[i] = value;\n }\n return array;\n}\n`)+"("+(i.valueToCode(e,"ITEM",t.NONE)||"null")+", "+(e=i.valueToCode(e,"NUM",t.NONE)||"0")+")",t.FUNCTION_CALL]},lists_reverse:function(e,i){return[(i.valueToCode(e,"LIST",t.FUNCTION_CALL)||"[]")+".slice().reverse()",t.FUNCTION_CALL]},lists_setIndex:function(e,n){function o(){if(s.match(/^\w+$/))return"";var e=n.nameDB_.getDistinctName("tmpList",i.P.VARIABLE),t="var "+e+" = "+s+";\n";return s=e,t}var s=n.valueToCode(e,"LIST",t.MEMBER)||"[]",r=e.getFieldValue("MODE")||"GET",a=e.getFieldValue("WHERE")||"FROM_START",l=n.valueToCode(e,"TO",t.ASSIGNMENT)||"null";switch(a){case"FIRST":if("SET"===r)return s+"[0] = "+l+";\n";if("INSERT"===r)return s+".unshift("+l+");\n";break;case"LAST":if("SET"===r)return o()+(s+"[")+s+".length - 1] = "+l+";\n";if("INSERT"===r)return s+".push("+l+");\n";break;case"FROM_START":if(e=n.getAdjusted(e,"AT"),"SET"===r)return s+"["+e+"] = "+l+";\n";if("INSERT"===r)return s+".splice("+e+", 0, "+l+");\n";break;case"FROM_END":if(e=n.getAdjusted(e,"AT",1,!1,t.SUBTRACTION),a=o(),"SET"===r)return a+(s+"[")+s+".length - "+e+"] = "+l+";\n";if("INSERT"===r)return a+(s+".splice(")+s+".length - "+e+", 0, "+l+");\n";break;case"RANDOM":if(e=o(),e+="var "+(a=n.nameDB_.getDistinctName("tmpX",i.P.VARIABLE))+" = Math.floor(Math.random() * "+s+".length);\n","SET"===r)return e+(s+"[")+a+"] = "+l+";\n";if("INSERT"===r)return e+(s+".splice(")+a+", 0, "+l+");\n"}throw Error("Unhandled combination (lists_setIndex).")},lists_sort:function(e,i){var n=i.valueToCode(e,"LIST",t.FUNCTION_CALL)||"[]",o="1"===e.getFieldValue("DIRECTION")?1:-1;return e=e.getFieldValue("TYPE"),[n+".slice().sort("+(i=i.provideFunction_("listsGetSortCompare",`\nfunction ${i.FUNCTION_NAME_PLACEHOLDER_}(type, direction) {\n var compareFuncs = {\n 'NUMERIC': function(a, b) {\n return Number(a) - Number(b); },\n 'TEXT': function(a, b) {\n return String(a) > String(b) ? 1 : -1; },\n 'IGNORE_CASE': function(a, b) {\n return String(a).toLowerCase() > String(b).toLowerCase() ? 1 : -1; },\n };\n var compare = compareFuncs[type];\n return function(a, b) { return compare(a, b) * direction; };\n}\n `))+'("'+e+'", '+o+"))",t.FUNCTION_CALL]},lists_split:function(e,i){var n=i.valueToCode(e,"INPUT",t.MEMBER);if(i=i.valueToCode(e,"DELIM",t.NONE)||"''","SPLIT"===(e=e.getFieldValue("MODE")))n||(n="''"),e="split";else{if("JOIN"!==e)throw Error("Unknown mode: "+e);n||(n="[]"),e="join"}return[n+"."+e+"("+i+")",t.FUNCTION_CALL]}},E,T,_,f,b,C,v);for(let e in N)I.forBlock[e]=N[e];var y={};return y.JavascriptGenerator=g,y.Order=t,y.javascriptGenerator=I,i.__chunk_javascript=y,i.__chunk_javascript.__namespace__=i,i.__chunk_javascript})?n.apply(t,o):n)||(e.exports=s)},172:function(e,t,i){var n,o,s;o=[i(500)],void 0===(s="function"==typeof(n=function(e){var t,i=e.__namespace__,n=function(e,t,i){return"FIRST"===t?"1":"FROM_END"===t?"#"+e+" + 1 - "+i:"LAST"===t?"#"+e:"RANDOM"===t?"math.random(#"+e+")":i},o=function(e,i){var n=0,o="";i.STATEMENT_PREFIX&&(o+=i.injectId(i.STATEMENT_PREFIX,e));do{let s=i.valueToCode(e,"IF"+n,t.NONE)||"false",r=i.statementToCode(e,"DO"+n);i.STATEMENT_SUFFIX&&(r=i.prefixLines(i.injectId(i.STATEMENT_SUFFIX,e),i.INDENT)+r),o+=(n>0?"else":"")+"if "+s+" then\n"+r,n++}while(e.getInput("IF"+n));return(e.getInput("ELSE")||i.STATEMENT_SUFFIX)&&(n=e.getInput("ELSE")?i.statementToCode(e,"ELSE"):"",i.STATEMENT_SUFFIX&&(n=i.prefixLines(i.injectId(i.STATEMENT_SUFFIX,e),i.INDENT)+n),o+="else\n"+n),o+"end\n"},s=function(e,t){return e.includes("goto continue\n")?e+t+"::continue::\n":e},r=function(e,n){var o=e.getField("TIMES")?String(Number(e.getFieldValue("TIMES"))):n.valueToCode(e,"TIMES",t.NONE)||"0";o=i.zf(o)?parseInt(o,10):"math.floor("+o+")";var r=n.statementToCode(e,"DO");return r=n.addLoopTrap(r,e),r=s(r,n.INDENT),"for "+n.nameDB_.getDistinctName("count",i.P.VARIABLE)+" = 1, "+o+" do\n"+r+"end\n"},a=function(e,i){var n=e.getFieldValue("OP");if("NEG"===n)return["-"+(e=i.valueToCode(e,"NUM",t.UNARY)||"0"),t.UNARY];if("POW10"===n)return["10 ^ "+(e=i.valueToCode(e,"NUM",t.EXPONENTIATION)||"0"),t.EXPONENTIATION];switch(e="ROUND"===n?i.valueToCode(e,"NUM",t.ADDITIVE)||"0":i.valueToCode(e,"NUM",t.NONE)||"0",n){case"ABS":n="math.abs("+e+")";break;case"ROOT":n="math.sqrt("+e+")";break;case"LN":n="math.log("+e+")";break;case"LOG10":n="math.log("+e+", 10)";break;case"EXP":n="math.exp("+e+")";break;case"ROUND":n="math.floor("+e+" + .5)";break;case"ROUNDUP":n="math.ceil("+e+")";break;case"ROUNDDOWN":n="math.floor("+e+")";break;case"SIN":n="math.sin(math.rad("+e+"))";break;case"COS":n="math.cos(math.rad("+e+"))";break;case"TAN":n="math.tan(math.rad("+e+"))";break;case"ASIN":n="math.deg(math.asin("+e+"))";break;case"ACOS":n="math.deg(math.acos("+e+"))";break;case"ATAN":n="math.deg(math.atan("+e+"))";break;default:throw Error("Unknown math operator: "+n)}return[n,t.HIGH]},l=function(e,i){var n=i.getProcedureName(e.getFieldValue("NAME")),o="";i.STATEMENT_PREFIX&&(o+=i.injectId(i.STATEMENT_PREFIX,e)),i.STATEMENT_SUFFIX&&(o+=i.injectId(i.STATEMENT_SUFFIX,e)),o&&(o=i.prefixLines(o,i.INDENT));var s="";i.INFINITE_LOOP_TRAP&&(s=i.prefixLines(i.injectId(i.INFINITE_LOOP_TRAP,e),i.INDENT));var r="";e.getInput("STACK")&&(r=i.statementToCode(e,"STACK"));var a="";e.getInput("RETURN")&&(a=i.valueToCode(e,"RETURN",t.NONE)||"");var l="";r&&a&&(l=o),a?a=i.INDENT+"return "+a+"\n":r||(r="");var h=[],u=e.getVarModels();for(let e=0;e<u.length;e++)h[e]=i.getVariableName(u[e].getId());return o="function "+n+"("+h.join(", ")+")\n"+o+s+r+l+a+"end\n",o=i.scrub_(e,o),i.definitions_["%"+n]=o,null},h=function(e,i){var n=e.getField("TEXT")?i.quote_(e.getFieldValue("TEXT")):i.valueToCode(e,"TEXT",t.NONE)||"''";return i=i.provideFunction_("text_prompt",`\nfunction ${i.FUNCTION_NAME_PLACEHOLDER_}(msg)\n io.write(msg)\n io.flush()\n return io.read()\nend\n`)+"("+n+")","NUMBER"===e.getFieldValue("TYPE")&&(i="tonumber("+i+", 10)"),[i,t.HIGH]},u=function(e,i){return[i.getVariableName(e.getFieldValue("VAR")),t.ATOMIC]},c=function(e,i){var n=i.valueToCode(e,"VALUE",t.NONE)||"0";return i.getVariableName(e.getFieldValue("VAR"))+" = "+n+"\n"},d=t||(t={});d[d.ATOMIC=0]="ATOMIC",d[d.HIGH=1]="HIGH",d[d.EXPONENTIATION=2]="EXPONENTIATION",d[d.UNARY=3]="UNARY",d[d.MULTIPLICATIVE=4]="MULTIPLICATIVE",d[d.ADDITIVE=5]="ADDITIVE",d[d.CONCATENATION=6]="CONCATENATION",d[d.RELATIONAL=7]="RELATIONAL",d[d.AND=8]="AND",d[d.OR=9]="OR",d[d.NONE=99]="NONE";var p=class extends i.zq{constructor(e="Lua"){super(e),this.isInitialized=!1;for(let i in t)"string"!=typeof(e=t[i])&&(this["ORDER_"+i]=e);this.addReservedWords("_,__inext,assert,bit,colors,colours,coroutine,disk,dofile,error,fs,fetfenv,getmetatable,gps,help,io,ipairs,keys,loadfile,loadstring,math,native,next,os,paintutils,pairs,parallel,pcall,peripheral,print,printError,rawequal,rawget,rawset,read,rednet,redstone,rs,select,setfenv,setmetatable,sleep,string,table,term,textutils,tonumber,tostring,turtle,type,unpack,vector,write,xpcall,_VERSION,__indext,HTTP,and,break,do,else,elseif,end,false,for,function,if,in,local,nil,not,or,repeat,return,then,true,until,while,add,sub,mul,div,mod,pow,unm,concat,len,eq,lt,le,index,newindex,call,assert,collectgarbage,dofile,error,_G,getmetatable,inpairs,load,loadfile,next,pairs,pcall,print,rawequal,rawget,rawlen,rawset,select,setmetatable,tonumber,tostring,type,_VERSION,xpcall,require,package,string,table,math,bit32,io,file,os,debug")}init(e){super.init(e),this.nameDB_?this.nameDB_.reset():this.nameDB_=new i.Cj(this.RESERVED_WORDS_),this.nameDB_.setVariableMap(e.getVariableMap()),this.nameDB_.populateVariables(e),this.nameDB_.populateProcedures(e),this.isInitialized=!0}finish(e){var t=Object.values(this.definitions_);return e=super.finish(e),this.isInitialized=!1,this.nameDB_.reset(),t.join("\n\n")+"\n\n\n"+e}scrubNakedValue(e){return"local _ = "+e+"\n"}quote_(e){return"'"+(e=e.replace(/\\/g,"\\\\").replace(/\n/g,"\\\n").replace(/'/g,"\\'"))+"'"}multiline_quote_(e){return e.split(/\n/g).map(this.quote_).join(" .. '\\n' ..\n")}scrub_(e,t,n=!1){var o="";if(!e.outputConnection||!e.outputConnection.targetConnection){var s=e.getCommentText();s&&(s=i.yf(s,this.COMMENT_WRAP-3),o+=this.prefixLines(s,"-- ")+"\n");for(let t=0;t<e.inputList.length;t++)e.inputList[t].type===i.je.VALUE&&(s=e.inputList[t].connection.targetBlock())&&(s=this.allNestedComments(s))&&(o+=this.prefixLines(s,"-- "))}return e=e.nextConnection&&e.nextConnection.targetBlock(),o+t+(n?"":this.blockToCode(e))}},g={};g.controls_if=o,g.controls_ifelse=o,g.logic_boolean=function(e){return["TRUE"===e.getFieldValue("BOOL")?"true":"false",t.ATOMIC]},g.logic_compare=function(e,i){var n={EQ:"==",NEQ:"~=",LT:"<",LTE:"<=",GT:">",GTE:">="}[e.getFieldValue("OP")];return[(i.valueToCode(e,"A",t.RELATIONAL)||"0")+" "+n+" "+(e=i.valueToCode(e,"B",t.RELATIONAL)||"0"),t.RELATIONAL]},g.logic_negate=function(e,i){return["not "+(i.valueToCode(e,"BOOL",t.UNARY)||"true"),t.UNARY]},g.logic_null=function(){return["nil",t.ATOMIC]},g.logic_operation=function(e,i){var n="AND"===e.getFieldValue("OP")?"and":"or",o="and"===n?t.AND:t.OR,s=i.valueToCode(e,"A",o);return e=i.valueToCode(e,"B",o),s||e?(i="and"===n?"true":"false",s||(s=i),e||(e=i)):e=s="false",[s+" "+n+" "+e,o]},g.logic_ternary=function(e,i){return[(i.valueToCode(e,"IF",t.AND)||"false")+" and "+(i.valueToCode(e,"THEN",t.AND)||"nil")+" or "+(e=i.valueToCode(e,"ELSE",t.OR)||"nil"),t.OR]};var E={controls_flow_statements:function(e,t){var i="";if(t.STATEMENT_PREFIX&&(i+=t.injectId(t.STATEMENT_PREFIX,e)),t.STATEMENT_SUFFIX&&(i+=t.injectId(t.STATEMENT_SUFFIX,e)),t.STATEMENT_PREFIX){let n=e.getSurroundLoop();n&&!n.suppressPrefixSuffix&&(i+=t.injectId(t.STATEMENT_PREFIX,n))}switch(e.getFieldValue("FLOW")){case"BREAK":return i+"break\n";case"CONTINUE":return i+"goto continue\n"}throw Error("Unknown flow statement.")},controls_for:function(e,n){var o=n.getVariableName(e.getFieldValue("VAR")),r=n.valueToCode(e,"FROM",t.NONE)||"0",a=n.valueToCode(e,"TO",t.NONE)||"0",l=n.valueToCode(e,"BY",t.NONE)||"1",h=n.statementToCode(e,"DO");if(h=n.addLoopTrap(h,e),h=s(h,n.INDENT),e="",i.zf(r)&&i.zf(a)&&i.zf(l))var u=(Number(r)<=Number(a)?"":"-")+Math.abs(Number(l));else e="",e+=(u=n.nameDB_.getDistinctName(o+"_inc",i.P.VARIABLE))+" = ",e=(e=i.zf(l)?e+(Math.abs(l)+"\n"):e+"math.abs("+l+")\n")+"if ("+r+") > ("+a+") then\n"+(n.INDENT+u)+" = -"+u+"\n",e+="end\n";return e+"for "+o+" = "+r+", "+a+", "+u+" do\n"+h+"end\n"},controls_forEach:function(e,i){var n=i.getVariableName(e.getFieldValue("VAR")),o=i.valueToCode(e,"LIST",t.NONE)||"{}",r=i.statementToCode(e,"DO");return r=i.addLoopTrap(r,e),"for _, "+n+" in ipairs("+o+") do \n"+(r=s(r,i.INDENT))+"end\n"}};E.controls_repeat=r,E.controls_repeat_ext=r,E.controls_whileUntil=function(e,i){var n="UNTIL"===e.getFieldValue("MODE"),o=i.valueToCode(e,"BOOL",n?t.UNARY:t.NONE)||"false",r=i.statementToCode(e,"DO");return r=i.addLoopTrap(r,e),n&&(o="not "+o),"while "+o+" do\n"+(r=s(r,i.INDENT))+"end\n"};var T={math_arithmetic:function(e,i){var n={ADD:[" + ",t.ADDITIVE],MINUS:[" - ",t.ADDITIVE],MULTIPLY:[" * ",t.MULTIPLICATIVE],DIVIDE:[" / ",t.MULTIPLICATIVE],POWER:[" ^ ",t.EXPONENTIATION]}[e.getFieldValue("OP")],o=n[0];return n=n[1],[(i.valueToCode(e,"A",n)||"0")+o+(e=i.valueToCode(e,"B",n)||"0"),n]},math_atan2:function(e,i){var n=i.valueToCode(e,"X",t.NONE)||"0";return["math.deg(math.atan2("+(i.valueToCode(e,"Y",t.NONE)||"0")+", "+n+"))",t.HIGH]},math_change:function(e,i){var n=i.valueToCode(e,"DELTA",t.ADDITIVE)||"0";return(e=i.getVariableName(e.getFieldValue("VAR")))+" = "+e+" + "+n+"\n"},math_constant:function(e){return{PI:["math.pi",t.HIGH],E:["math.exp(1)",t.HIGH],GOLDEN_RATIO:["(1 + math.sqrt(5)) / 2",t.MULTIPLICATIVE],SQRT2:["math.sqrt(2)",t.HIGH],SQRT1_2:["math.sqrt(1 / 2)",t.HIGH],INFINITY:["math.huge",t.HIGH]}[e.getFieldValue("CONSTANT")]},math_constrain:function(e,i){return["math.min(math.max("+(i.valueToCode(e,"VALUE",t.NONE)||"0")+", "+(i.valueToCode(e,"LOW",t.NONE)||"-math.huge")+"), "+(e=i.valueToCode(e,"HIGH",t.NONE)||"math.huge")+")",t.HIGH]},math_modulo:function(e,i){return[(i.valueToCode(e,"DIVIDEND",t.MULTIPLICATIVE)||"0")+" % "+(e=i.valueToCode(e,"DIVISOR",t.MULTIPLICATIVE)||"0"),t.MULTIPLICATIVE]},math_number:function(e){return e=Number(e.getFieldValue("NUM")),[String(e),e<0?t.UNARY:t.ATOMIC]},math_number_property:function(e,i){var n={EVEN:[" % 2 == 0",t.MULTIPLICATIVE,t.RELATIONAL],ODD:[" % 2 == 1",t.MULTIPLICATIVE,t.RELATIONAL],WHOLE:[" % 1 == 0",t.MULTIPLICATIVE,t.RELATIONAL],POSITIVE:[" > 0",t.RELATIONAL,t.RELATIONAL],NEGATIVE:[" < 0",t.RELATIONAL,t.RELATIONAL],DIVISIBLE_BY:[null,t.MULTIPLICATIVE,t.RELATIONAL],PRIME:[null,t.NONE,t.HIGH]},o=e.getFieldValue("PROPERTY"),[s,r,a]=n[o];if(n=i.valueToCode(e,"NUMBER_TO_CHECK",r)||"0","PRIME"===o)e=i.provideFunction_("math_isPrime",`\nfunction ${i.FUNCTION_NAME_PLACEHOLDER_}(n)\n -- https://en.wikipedia.org/wiki/Primality_test#Naive_methods\n if n == 2 or n == 3 then\n return true\n end\n -- False if n is NaN, negative, is 1, or not whole.\n -- And false if n is divisible by 2 or 3.\n if not(n > 1) or n % 1 ~= 0 or n % 2 == 0 or n % 3 == 0 then\n return false\n end\n -- Check all the numbers of form 6k +/- 1, up to sqrt(n).\n for x = 6, math.sqrt(n) + 1.5, 6 do\n if n % (x - 1) == 0 or n % (x + 1) == 0 then\n return false\n end\n end\n return true\nend\n`)+"("+n+")";else if("DIVISIBLE_BY"===o){if("0"===(e=i.valueToCode(e,"DIVISOR",t.MULTIPLICATIVE)||"0"))return["nil",t.ATOMIC];e=n+" % "+e+" == 0"}else e=n+s;return[e,a]},math_on_list:function(e,i){function n(){return i.provideFunction_("math_sum",`\nfunction ${i.FUNCTION_NAME_PLACEHOLDER_}(t)\n local result = 0\n for _, v in ipairs(t) do\n result = result + v\n end\n return result\nend\n`)}var o=e.getFieldValue("OP");switch(e=i.valueToCode(e,"LIST",t.NONE)||"{}",o){case"SUM":o=n();break;case"MIN":o=i.provideFunction_("math_min",`\nfunction ${i.FUNCTION_NAME_PLACEHOLDER_}(t)\n if #t == 0 then\n return 0\n end\n local result = math.huge\n for _, v in ipairs(t) do\n if v < result then\n result = v\n end\n end\n return result\nend\n`);break;case"AVERAGE":o=i.provideFunction_("math_average",`\nfunction ${i.FUNCTION_NAME_PLACEHOLDER_}(t)\n if #t == 0 then\n return 0\n end\n return ${n()}(t) / #t\nend\n`);break;case"MAX":o=i.provideFunction_("math_max",`\nfunction ${i.FUNCTION_NAME_PLACEHOLDER_}(t)\n if #t == 0 then\n return 0\n end\n local result = -math.huge\n for _, v in ipairs(t) do\n if v > result then\n result = v\n end\n end\n return result\nend\n`);break;case"MEDIAN":o=i.provideFunction_("math_median",`\nfunction ${i.FUNCTION_NAME_PLACEHOLDER_}(t)\n -- Source: http://lua-users.org/wiki/SimpleStats\n if #t == 0 then\n return 0\n end\n local temp = {}\n for _, v in ipairs(t) do\n if type(v) == 'number' then\n table.insert(temp, v)\n end\n end\n table.sort(temp)\n if #temp % 2 == 0 then\n return (temp[#temp / 2] + temp[(#temp / 2) + 1]) / 2\n else\n return temp[math.ceil(#temp / 2)]\n end\nend\n`);break;case"MODE":o=i.provideFunction_("math_modes",`\nfunction ${i.FUNCTION_NAME_PLACEHOLDER_}(t)\n -- Source: http://lua-users.org/wiki/SimpleStats\n local counts = {}\n for _, v in ipairs(t) do\n if counts[v] == nil then\n counts[v] = 1\n else\n counts[v] = counts[v] + 1\n end\n end\n local biggestCount = 0\n for _, v in pairs(counts) do\n if v > biggestCount then\n biggestCount = v\n end\n end\n local temp = {}\n for k, v in pairs(counts) do\n if v == biggestCount then\n table.insert(temp, k)\n end\n end\n return temp\nend\n`);break;case"STD_DEV":o=i.provideFunction_("math_standard_deviation",`\nfunction ${i.FUNCTION_NAME_PLACEHOLDER_}(t)\n local m\n local vm\n local total = 0\n local count = 0\n local result\n m = #t == 0 and 0 or ${n()}(t) / #t\n for _, v in ipairs(t) do\n if type(v) == 'number' then\n vm = v - m\n total = total + (vm * vm)\n count = count + 1\n end\n end\n result = math.sqrt(total / (count-1))\n return result\nend\n`);break;case"RANDOM":o=i.provideFunction_("math_random_list",`\nfunction ${i.FUNCTION_NAME_PLACEHOLDER_}(t)\n if #t == 0 then\n return nil\n end\n return t[math.random(#t)]\nend\n`);break;default:throw Error("Unknown operator: "+o)}return[o+"("+e+")",t.HIGH]},math_random_float:function(){return["math.random()",t.HIGH]},math_random_int:function(e,i){return["math.random("+(i.valueToCode(e,"FROM",t.NONE)||"0")+", "+(e=i.valueToCode(e,"TO",t.NONE)||"0")+")",t.HIGH]}};T.math_round=a,T.math_single=a,T.math_trig=a;var _={procedures_callnoreturn:function(e,t){return t.forBlock.procedures_callreturn(e,t)[0]+"\n"},procedures_callreturn:function(e,i){var n=i.getProcedureName(e.getFieldValue("NAME")),o=[],s=e.getVarModels();for(let n=0;n<s.length;n++)o[n]=i.valueToCode(e,"ARG"+n,t.NONE)||"nil";return[n+"("+o.join(", ")+")",t.HIGH]}};_.procedures_defnoreturn=l,_.procedures_defreturn=l,_.procedures_ifreturn=function(e,i){var n="if "+(i.valueToCode(e,"CONDITION",t.NONE)||"false")+" then\n";return i.STATEMENT_SUFFIX&&(n+=i.prefixLines(i.injectId(i.STATEMENT_SUFFIX,e),i.INDENT)),e.hasReturnValue_?(e=i.valueToCode(e,"VALUE",t.NONE)||"nil",n+=i.INDENT+"return "+e+"\n"):n+=i.INDENT+"return\n",n+"end\n"};var f={text:function(e,i){return[i.quote_(e.getFieldValue("TEXT")),t.ATOMIC]},text_append:function(e,i){var n=i.getVariableName(e.getFieldValue("VAR"));return n+" = "+n+" .. "+(e=i.valueToCode(e,"TEXT",t.CONCATENATION)||"''")+"\n"},text_changeCase:function(e,i){var n,o=e.getFieldValue("CASE");return e=i.valueToCode(e,"TEXT",t.NONE)||"''","UPPERCASE"===o?n="string.upper":"LOWERCASE"===o?n="string.lower":"TITLECASE"===o&&(n=i.provideFunction_("text_titlecase",`\nfunction ${i.FUNCTION_NAME_PLACEHOLDER_}(str)\n local buf = {}\n local inWord = false\n for i = 1, #str do\n local c = string.sub(str, i, i)\n if inWord then\n table.insert(buf, string.lower(c))\n if string.find(c, "%s") then\n inWord = false\n end\n else\n table.insert(buf, string.upper(c))\n inWord = true\n end\n end\n return table.concat(buf)\nend\n`)),[n+"("+e+")",t.HIGH]},text_charAt:function(e,i){var n=e.getFieldValue("WHERE")||"FROM_START",o=i.valueToCode(e,"VALUE",t.NONE)||"''";if("RANDOM"===n)i=i.provideFunction_("text_random_letter",`\nfunction ${i.FUNCTION_NAME_PLACEHOLDER_}(str)\n local index = math.random(string.len(str))\n return string.sub(str, index, index)\nend\n`)+"("+o+")";else{if("FIRST"===n)n="1";else if("LAST"===n)n="-1";else if(e=i.valueToCode(e,"AT","FROM_END"===n?t.UNARY:t.NONE)||"1","FROM_START"===n)n=e;else{if("FROM_END"!==n)throw Error("Unhandled option (text_charAt).");n="-"+e}i=n.match(/^-?\w*$/)?"string.sub("+o+", "+n+", "+n+")":i.provideFunction_("text_char_at",`\nfunction ${i.FUNCTION_NAME_PLACEHOLDER_}(str, index)\n return string.sub(str, index, index)\nend\n`)+"("+o+", "+n+")"}return[i,t.HIGH]},text_count:function(e,i){var n=i.valueToCode(e,"TEXT",t.NONE)||"''";return e=i.valueToCode(e,"SUB",t.NONE)||"''",[i.provideFunction_("text_count",`\nfunction ${i.FUNCTION_NAME_PLACEHOLDER_}(haystack, needle)\n if #needle == 0 then\n return #haystack + 1\n end\n local i = 1\n local count = 0\n while true do\n i = string.find(haystack, needle, i, true)\n if i == nil then\n break\n end\n count = count + 1\n i = i + #needle\n end\n return count\nend\n`)+"("+n+", "+e+")",t.HIGH]},text_getSubstring:function(e,i){var n=i.valueToCode(e,"STRING",t.NONE)||"''",o=e.getFieldValue("WHERE1"),s=i.valueToCode(e,"AT1","FROM_END"===o?t.UNARY:t.NONE)||"1";if("FIRST"===o)o=1;else if("FROM_START"===o)o=s;else{if("FROM_END"!==o)throw Error("Unhandled option (text_getSubstring)");o="-"+s}if(s=e.getFieldValue("WHERE2"),e=i.valueToCode(e,"AT2","FROM_END"===s?t.UNARY:t.NONE)||"1","LAST"===s)e=-1;else if("FROM_START"!==s){if("FROM_END"!==s)throw Error("Unhandled option (text_getSubstring)");e="-"+e}return["string.sub("+n+", "+o+", "+e+")",t.HIGH]},text_indexOf:function(e,i){var n=i.valueToCode(e,"FIND",t.NONE)||"''",o=i.valueToCode(e,"VALUE",t.NONE)||"''";return[("FIRST"===e.getFieldValue("END")?i.provideFunction_("firstIndexOf",`\nfunction ${i.FUNCTION_NAME_PLACEHOLDER_}(str, substr)\n local i = string.find(str, substr, 1, true)\n if i == nil then\n return 0\n end\n return i\nend\n`):i.provideFunction_("lastIndexOf",`\nfunction ${i.FUNCTION_NAME_PLACEHOLDER_}(str, substr)\n local i = string.find(string.reverse(str), string.reverse(substr), 1, true)\n if i then\n return #str + 2 - i - #substr\n end\n return 0\nend\n`))+"("+o+", "+n+")",t.HIGH]},text_isEmpty:function(e,i){return["#"+(i.valueToCode(e,"VALUE",t.UNARY)||"''")+" == 0",t.RELATIONAL]},text_join:function(e,i){if(0===e.itemCount_)return["''",t.ATOMIC];if(1===e.itemCount_)return["tostring("+(i.valueToCode(e,"ADD0",t.NONE)||"''")+")",t.HIGH];if(2===e.itemCount_){var n=i.valueToCode(e,"ADD0",t.CONCATENATION)||"''";return[n+" .. "+(e=i.valueToCode(e,"ADD1",t.CONCATENATION)||"''"),t.CONCATENATION]}n=[];for(let o=0;o<e.itemCount_;o++)n[o]=i.valueToCode(e,"ADD"+o,t.NONE)||"''";return["table.concat({"+n.join(", ")+"})",t.HIGH]},text_length:function(e,i){return["#"+(i.valueToCode(e,"VALUE",t.UNARY)||"''"),t.UNARY]},text_print:function(e,i){return"print("+(i.valueToCode(e,"TEXT",t.NONE)||"''")+")\n"}};f.text_prompt=h,f.text_prompt_ext=h,f.text_replace=function(e,i){var n=i.valueToCode(e,"TEXT",t.NONE)||"''",o=i.valueToCode(e,"FROM",t.NONE)||"''";return e=i.valueToCode(e,"TO",t.NONE)||"''",[i.provideFunction_("text_replace",`\nfunction ${i.FUNCTION_NAME_PLACEHOLDER_}(haystack, needle, replacement)\n local buf = {}\n local i = 1\n while i <= #haystack do\n if string.sub(haystack, i, i + #needle - 1) == needle then\n for j = 1, #replacement do\n table.insert(buf, string.sub(replacement, j, j))\n end\n i = i + #needle\n else\n table.insert(buf, string.sub(haystack, i, i))\n i = i + 1\n end\n end\n return table.concat(buf)\nend\n`)+"("+n+", "+o+", "+e+")",t.HIGH]},f.text_reverse=function(e,i){return["string.reverse("+(i.valueToCode(e,"TEXT",t.NONE)||"''")+")",t.HIGH]},f.text_trim=function(e,i){var n={LEFT:"^%s*(,-)",RIGHT:"(.-)%s*$",BOTH:"^%s*(.-)%s*$"}[e.getFieldValue("MODE")];return["string.gsub("+(i.valueToCode(e,"TEXT",t.NONE)||"''")+', "'+n+'", "%1")',t.HIGH]};var m={};m.variables_get=u,m.variables_set=c;var b={};b.variables_get_dynamic=u,b.variables_set_dynamic=c;var C=new p,v=Object.assign({},{lists_create_empty:function(){return["{}",t.HIGH]},lists_create_with:function(e,i){var n=Array(e.itemCount_);for(let o=0;o<e.itemCount_;o++)n[o]=i.valueToCode(e,"ADD"+o,t.NONE)||"nil";return["{"+n.join(", ")+"}",t.HIGH]},lists_getIndex:function(e,o){var s=e.getFieldValue("MODE")||"GET",r=e.getFieldValue("WHERE")||"FROM_START",a=o.valueToCode(e,"VALUE",t.HIGH)||"({})";return"LAST"!==r&&"FROM_END"!==r&&"RANDOM"!==r||a.match(/^\w+$/)?(o=o.valueToCode(e,"AT","GET"===s&&"FROM_END"===r?t.ADDITIVE:t.NONE)||"1",o=n(a,r,o),"GET"===s?[a+"["+o+"]",t.HIGH]:(r="table.remove("+a+", "+o+")","GET_REMOVE"===s?[r,t.HIGH]:r+"\n")):"REMOVE"===s?(s=o.valueToCode(e,"AT","FROM_END"===r?t.ADDITIVE:t.NONE)||"1",(o=o.nameDB_.getDistinctName("tmp_list",i.P.VARIABLE))+" = "+a+"\ntable.remove("+o+", "+(s=n(o,r,s))+")\n"):(e=o.valueToCode(e,"AT",t.NONE)||"1",[("GET"===s?o.provideFunction_("list_get_"+r.toLowerCase(),["function "+o.FUNCTION_NAME_PLACEHOLDER_+"(t"+("FROM_END"===r||"FROM_START"===r?", at)":")")," return t["+n("t",r,"at")+"]","end"]):o.provideFunction_("list_remove_"+r.toLowerCase(),["function "+o.FUNCTION_NAME_PLACEHOLDER_+"(t"+("FROM_END"===r||"FROM_START"===r?", at)":")")," return table.remove(t, "+n("t",r,"at")+")","end"]))+"("+a+("FROM_END"===r||"FROM_START"===r?", "+e:"")+")",t.HIGH])},lists_getSublist:function(e,i){var o=i.valueToCode(e,"LIST",t.NONE)||"{}",s=e.getFieldValue("WHERE1"),r=e.getFieldValue("WHERE2"),a=i.valueToCode(e,"AT1",t.NONE)||"1";e=i.valueToCode(e,"AT2",t.NONE)||"1";var l="FROM_END"===s||"FROM_START"===s?", at1":"",h="FROM_END"===r||"FROM_START"===r?", at2":"";return[i.provideFunction_("list_sublist_"+s.toLowerCase()+"_"+r.toLowerCase(),`\nfunction ${i.FUNCTION_NAME_PLACEHOLDER_}(source${l}${h})\n local t = {}\n local start = ${n("source",s,"at1")}\n local finish = ${n("source",r,"at2")}\n for i = start, finish do\n table.insert(t, source[i])\n end\n return t\nend\n`)+"("+o+("FROM_END"===s||"FROM_START"===s?", "+a:"")+("FROM_END"===r||"FROM_START"===r?", "+e:"")+")",t.HIGH]},lists_indexOf:function(e,i){var n=i.valueToCode(e,"FIND",t.NONE)||"''",o=i.valueToCode(e,"VALUE",t.NONE)||"{}";return[("FIRST"===e.getFieldValue("END")?i.provideFunction_("first_index",`\nfunction ${i.FUNCTION_NAME_PLACEHOLDER_}(t, elem)\n for k, v in ipairs(t) do\n if v == elem then\n return k\n end\n end\n return 0\nend\n`):i.provideFunction_("last_index",`\nfunction ${i.FUNCTION_NAME_PLACEHOLDER_}(t, elem)\n for i = #t, 1, -1 do\n if t[i] == elem then\n return i\n end\n end\n return 0\nend\n`))+"("+o+", "+n+")",t.HIGH]},lists_isEmpty:function(e,i){return["#"+(i.valueToCode(e,"VALUE",t.UNARY)||"{}")+" == 0",t.RELATIONAL]},lists_length:function(e,i){return["#"+(i.valueToCode(e,"VALUE",t.UNARY)||"{}"),t.UNARY]},lists_repeat:function(e,i){return[i.provideFunction_("create_list_repeated",`\nfunction ${i.FUNCTION_NAME_PLACEHOLDER_}(item, count)\n local t = {}\n for i = 1, count do\n table.insert(t, item)\n end\n return t\nend\n `)+"("+(i.valueToCode(e,"ITEM",t.NONE)||"nil")+", "+(e=i.valueToCode(e,"NUM",t.NONE)||"0")+")",t.HIGH]},lists_reverse:function(e,i){return e=i.valueToCode(e,"LIST",t.NONE)||"{}",[i.provideFunction_("list_reverse",`\nfunction ${i.FUNCTION_NAME_PLACEHOLDER_}(input)\n local reversed = {}\n for i = #input, 1, -1 do\n table.insert(reversed, input[i])\n end\n return reversed\nend\n`)+"("+e+")",t.HIGH]},lists_setIndex:function(e,o){var s=o.valueToCode(e,"LIST",t.HIGH)||"{}",r=e.getFieldValue("MODE")||"SET",a=e.getFieldValue("WHERE")||"FROM_START",l=o.valueToCode(e,"AT",t.ADDITIVE)||"1";e=o.valueToCode(e,"TO",t.NONE)||"Nil";var h="";return"LAST"!==a&&"FROM_END"!==a&&"RANDOM"!==a||s.match(/^\w+$/)||(h=(o=o.nameDB_.getDistinctName("tmp_list",i.P.VARIABLE))+" = "+s+"\n",s=o),(h="SET"===r?h+(s+"[")+n(s,a,l)+"] = "+e:h+"table.insert("+s+", "+n(s,a,l)+("LAST"===a?" + 1":"")+", "+e+")")+"\n"},lists_sort:function(e,i){var n=i.valueToCode(e,"LIST",t.NONE)||"{}",o="1"===e.getFieldValue("DIRECTION")?1:-1;return e=e.getFieldValue("TYPE"),[i.provideFunction_("list_sort",`\nfunction ${i.FUNCTION_NAME_PLACEHOLDER_}(list, typev, direction)\n local t = {}\n for n,v in pairs(list) do table.insert(t, v) end\n local compareFuncs = {\n NUMERIC = function(a, b)\n return (tonumber(tostring(a)) or 0)\n < (tonumber(tostring(b)) or 0) end,\n TEXT = function(a, b)\n return tostring(a) < tostring(b) end,\n IGNORE_CASE = function(a, b)\n return string.lower(tostring(a)) < string.lower(tostring(b)) end\n }\n local compareTemp = compareFuncs[typev]\n local compare = compareTemp\n if direction == -1\n then compare = function(a, b) return compareTemp(b, a) end\n end\n table.sort(t, compare)\n return t\nend\n`)+"("+n+',"'+e+'", '+o+")",t.HIGH]},lists_split:function(e,i){var n=i.valueToCode(e,"INPUT",t.NONE),o=i.valueToCode(e,"DELIM",t.NONE)||"''";if("SPLIT"===(e=e.getFieldValue("MODE")))n||(n="''"),i=i.provideFunction_("list_string_split",`\nfunction ${i.FUNCTION_NAME_PLACEHOLDER_}(input, delim)\n local t = {}\n local pos = 1\n while true do\n next_delim = string.find(input, delim, pos)\n if next_delim == nil then\n table.insert(t, string.sub(input, pos))\n break\n else\n table.insert(t, string.sub(input, pos, next_delim-1))\n pos = next_delim + #delim\n end\n end\n return t\nend\n`);else{if("JOIN"!==e)throw Error("Unknown mode: "+e);n||(n="{}"),i="table.concat"}return[i+"("+n+", "+o+")",t.HIGH]}},g,E,T,_,f,m,b);for(let e in v)C.forBlock[e]=v[e];var I={};return I.LuaGenerator=p,I.Order=t,I.luaGenerator=C,i.__chunk_lua=I,i.__chunk_lua.__namespace__=i,i.__chunk_lua})?n.apply(t,o):n)||(e.exports=s)},850:function(e,t,i){var n,o,s;o=[i(500)],void 0===(s="function"==typeof(n=function(e){var t,i=e.__namespace__,n=function(e,i){var n=0,o="";i.STATEMENT_PREFIX&&(o+=i.injectId(i.STATEMENT_PREFIX,e));do{var s=i.valueToCode(e,"IF"+n,t.NONE)||"false",r=i.statementToCode(e,"DO"+n);i.STATEMENT_SUFFIX&&(r=i.prefixLines(i.injectId(i.STATEMENT_SUFFIX,e),i.INDENT)+r),o+=(n>0?" else ":"")+"if ("+s+") {\n"+r+"}",n++}while(e.getInput("IF"+n));return(e.getInput("ELSE")||i.STATEMENT_SUFFIX)&&(r=e.getInput("ELSE")?i.statementToCode(e,"ELSE"):"",i.STATEMENT_SUFFIX&&(r=i.prefixLines(i.injectId(i.STATEMENT_SUFFIX,e),i.INDENT)+r),o+=" else {\n"+r+"}"),o+"\n"},o=function(e,n){var o=e.getField("TIMES")?String(Number(e.getFieldValue("TIMES"))):n.valueToCode(e,"TIMES",t.ASSIGNMENT)||"0",s=n.statementToCode(e,"DO");s=n.addLoopTrap(s,e),e="";var r=n.nameDB_.getDistinctName("count",i.P.VARIABLE),a=o;return o.match(/^\w+$/)||i.zf(o)||(e+=(a=n.nameDB_.getDistinctName("repeat_end",i.P.VARIABLE))+" = "+o+";\n"),e+"for ("+r+" = 0; "+r+" < "+a+"; "+r+"++) {\n"+s+"}\n"},s=function(e,i){var n=e.getFieldValue("OP");if("NEG"===n)return"-"===(e=i.valueToCode(e,"NUM",t.UNARY_NEGATION)||"0")[0]&&(e=" "+e),["-"+e,t.UNARY_NEGATION];switch(e="SIN"===n||"COS"===n||"TAN"===n?i.valueToCode(e,"NUM",t.DIVISION)||"0":i.valueToCode(e,"NUM",t.NONE)||"0",n){case"ABS":var o="abs("+e+")";break;case"ROOT":o="sqrt("+e+")";break;case"LN":o="log("+e+")";break;case"EXP":o="exp("+e+")";break;case"POW10":o="pow(10,"+e+")";break;case"ROUND":o="round("+e+")";break;case"ROUNDUP":o="ceil("+e+")";break;case"ROUNDDOWN":o="floor("+e+")";break;case"SIN":o="sin("+e+" / 180 * pi())";break;case"COS":o="cos("+e+" / 180 * pi())";break;case"TAN":o="tan("+e+" / 180 * pi())"}if(o)return[o,t.FUNCTION_CALL];switch(n){case"LOG10":o="log("+e+") / log(10)";break;case"ASIN":o="asin("+e+") / pi() * 180";break;case"ACOS":o="acos("+e+") / pi() * 180";break;case"ATAN":o="atan("+e+") / pi() * 180";break;default:throw Error("Unknown math operator: "+n)}return[o,t.DIVISION]},r=function(e,n){var o=[],s=e.workspace,r=i.Bd(s)||[];for(var a of r)r=a.getName(),e.getVarModels().includes(a)||o.push(n.getVariableName(r));for(s=i.Cd(s),a=0;a<s.length;a++)o.push(n.nameDB_.getName(s[a],i.P.DEVELOPER_VARIABLE));s=o.length?n.INDENT+"global "+o.join(", ")+";\n":"",o=n.getProcedureName(e.getFieldValue("NAME")),a="",n.STATEMENT_PREFIX&&(a+=n.injectId(n.STATEMENT_PREFIX,e)),n.STATEMENT_SUFFIX&&(a+=n.injectId(n.STATEMENT_SUFFIX,e)),a&&(a=n.prefixLines(a,n.INDENT)),r="",n.INFINITE_LOOP_TRAP&&(r=n.prefixLines(n.injectId(n.INFINITE_LOOP_TRAP,e),n.INDENT));var l="";e.getInput("STACK")&&(l=n.statementToCode(e,"STACK"));var h="";e.getInput("RETURN")&&(h=n.valueToCode(e,"RETURN",t.NONE)||"");var u="";l&&h&&(u=a),h&&(h=n.INDENT+"return "+h+";\n");var c=[],d=e.getVarModels();for(let e=0;e<d.length;e++)c[e]=n.getVariableName(d[e].getId());return s="function "+o+"("+c.join(", ")+") {\n"+s+a+r+l+u+h+"}",s=n.scrub_(e,s),n.definitions_["%"+o]=s,null},a=function(e,i){return i="readline("+(e.getField("TEXT")?i.quote_(e.getFieldValue("TEXT")):i.valueToCode(e,"TEXT",t.NONE)||"''")+")","NUMBER"===e.getFieldValue("TYPE")&&(i="floatval("+i+")"),[i,t.FUNCTION_CALL]},l=function(e,i){return[i.getVariableName(e.getFieldValue("VAR")),t.ATOMIC]},h=function(e,i){var n=i.valueToCode(e,"VALUE",t.ASSIGNMENT)||"0";return i.getVariableName(e.getFieldValue("VAR"))+" = "+n+";\n"},u=t||(t={});u[u.ATOMIC=0]="ATOMIC",u[u.CLONE=1]="CLONE",u[u.NEW=1]="NEW",u[u.MEMBER=2.1]="MEMBER",u[u.FUNCTION_CALL=2.2]="FUNCTION_CALL",u[u.POWER=3]="POWER",u[u.INCREMENT=4]="INCREMENT",u[u.DECREMENT=4]="DECREMENT",u[u.BITWISE_NOT=4]="BITWISE_NOT",u[u.CAST=4]="CAST",u[u.SUPPRESS_ERROR=4]="SUPPRESS_ERROR",u[u.INSTANCEOF=5]="INSTANCEOF",u[u.LOGICAL_NOT=6]="LOGICAL_NOT",u[u.UNARY_PLUS=7.1]="UNARY_PLUS",u[u.UNARY_NEGATION=7.2]="UNARY_NEGATION",u[u.MULTIPLICATION=8.1]="MULTIPLICATION",u[u.DIVISION=8.2]="DIVISION",u[u.MODULUS=8.3]="MODULUS",u[u.ADDITION=9.1]="ADDITION",u[u.SUBTRACTION=9.2]="SUBTRACTION",u[u.STRING_CONCAT=9.3]="STRING_CONCAT",u[u.BITWISE_SHIFT=10]="BITWISE_SHIFT",u[u.RELATIONAL=11]="RELATIONAL",u[u.EQUALITY=12]="EQUALITY",u[u.REFERENCE=13]="REFERENCE",u[u.BITWISE_AND=13]="BITWISE_AND",u[u.BITWISE_XOR=14]="BITWISE_XOR",u[u.BITWISE_OR=15]="BITWISE_OR",u[u.LOGICAL_AND=16]="LOGICAL_AND",u[u.LOGICAL_OR=17]="LOGICAL_OR",u[u.IF_NULL=18]="IF_NULL",u[u.CONDITIONAL=19]="CONDITIONAL",u[u.ASSIGNMENT=20]="ASSIGNMENT",u[u.LOGICAL_AND_WEAK=21]="LOGICAL_AND_WEAK",u[u.LOGICAL_XOR=22]="LOGICAL_XOR",u[u.LOGICAL_OR_WEAK=23]="LOGICAL_OR_WEAK",u[u.NONE=99]="NONE";var c=class extends i.zq{constructor(e="PHP"){super(e),this.ORDER_OVERRIDES=[[t.MEMBER,t.FUNCTION_CALL],[t.MEMBER,t.MEMBER],[t.LOGICAL_NOT,t.LOGICAL_NOT],[t.MULTIPLICATION,t.MULTIPLICATION],[t.ADDITION,t.ADDITION],[t.LOGICAL_AND,t.LOGICAL_AND],[t.LOGICAL_OR,t.LOGICAL_OR]],this.isInitialized=!1;for(let i in t)"string"!=typeof(e=t[i])&&(this["ORDER_"+i]=e);this.addReservedWords("__halt_compiler,abstract,and,array,as,break,callable,case,catch,class,clone,const,continue,declare,default,die,do,echo,else,elseif,empty,enddeclare,endfor,endforeach,endif,endswitch,endwhile,eval,exit,extends,final,for,foreach,function,global,goto,if,implements,include,include_once,instanceof,insteadof,interface,isset,list,namespace,new,or,print,private,protected,public,require,require_once,return,static,switch,throw,trait,try,unset,use,var,while,xor,PHP_VERSION,PHP_MAJOR_VERSION,PHP_MINOR_VERSION,PHP_RELEASE_VERSION,PHP_VERSION_ID,PHP_EXTRA_VERSION,PHP_ZTS,PHP_DEBUG,PHP_MAXPATHLEN,PHP_OS,PHP_SAPI,PHP_EOL,PHP_INT_MAX,PHP_INT_SIZE,DEFAULT_INCLUDE_PATH,PEAR_INSTALL_DIR,PEAR_EXTENSION_DIR,PHP_EXTENSION_DIR,PHP_PREFIX,PHP_BINDIR,PHP_BINARY,PHP_MANDIR,PHP_LIBDIR,PHP_DATADIR,PHP_SYSCONFDIR,PHP_LOCALSTATEDIR,PHP_CONFIG_FILE_PATH,PHP_CONFIG_FILE_SCAN_DIR,PHP_SHLIB_SUFFIX,E_ERROR,E_WARNING,E_PARSE,E_NOTICE,E_CORE_ERROR,E_CORE_WARNING,E_COMPILE_ERROR,E_COMPILE_WARNING,E_USER_ERROR,E_USER_WARNING,E_USER_NOTICE,E_DEPRECATED,E_USER_DEPRECATED,E_ALL,E_STRICT,__COMPILER_HALT_OFFSET__,TRUE,FALSE,NULL,__CLASS__,__DIR__,__FILE__,__FUNCTION__,__LINE__,__METHOD__,__NAMESPACE__,__TRAIT__")}init(e){super.init(e),this.nameDB_?this.nameDB_.reset():this.nameDB_=new i.Cj(this.RESERVED_WORDS_,"$"),this.nameDB_.setVariableMap(e.getVariableMap()),this.nameDB_.populateVariables(e),this.nameDB_.populateProcedures(e),this.isInitialized=!0}finish(e){var t=Object.values(this.definitions_);return e=super.finish(e),this.isInitialized=!1,this.nameDB_.reset(),t.join("\n\n")+"\n\n\n"+e}scrubNakedValue(e){return e+";\n"}quote_(e){return"'"+(e=e.replace(/\\/g,"\\\\").replace(/\n/g,"\\\n").replace(/'/g,"\\'"))+"'"}multiline_quote_(e){return e.split(/\n/g).map(this.quote_).join(' . "\\n" .\n')}scrub_(e,t,n=!1){var o="";if(!e.outputConnection||!e.outputConnection.targetConnection){var s=e.getCommentText();s&&(s=i.yf(s,this.COMMENT_WRAP-3),o+=this.prefixLines(s,"// ")+"\n");for(let t=0;t<e.inputList.length;t++)e.inputList[t].type===i.je.VALUE&&(s=e.inputList[t].connection.targetBlock())&&(s=this.allNestedComments(s))&&(o+=this.prefixLines(s,"// "))}return e=e.nextConnection&&e.nextConnection.targetBlock(),o+t+(n?"":this.blockToCode(e))}getAdjusted(e,n,o=0,s=!1,r=t.NONE){e.workspace.options.oneBasedIndex&&o--;var a=e.workspace.options.oneBasedIndex?"1":"0",l=r;return o>0?l=t.ADDITION:o<0?l=t.SUBTRACTION:s&&(l=t.UNARY_NEGATION),e=this.valueToCode(e,n,l)||a,0!==o||s?i.zf(e)?(e=String(Number(e)+o),s&&(e=String(-Number(e))),e):(o>0?e=`${e} + ${o}`:o<0&&(e=`${e} - ${-o}`),s&&(e=o?`-(${e})`:`-${e}`),Math.floor(r)>=Math.floor(l)&&(e=`(${e})`),e):e}},d={};d.controls_if=n,d.controls_ifelse=n,d.logic_boolean=function(e){return["TRUE"===e.getFieldValue("BOOL")?"true":"false",t.ATOMIC]},d.logic_compare=function(e,i){var n={EQ:"==",NEQ:"!=",LT:"<",LTE:"<=",GT:">",GTE:">="}[e.getFieldValue("OP")],o="=="===n||"!="===n?t.EQUALITY:t.RELATIONAL;return[(i.valueToCode(e,"A",o)||"0")+" "+n+" "+(e=i.valueToCode(e,"B",o)||"0"),o]},d.logic_negate=function(e,i){var n=t.LOGICAL_NOT;return["!"+(i.valueToCode(e,"BOOL",n)||"true"),n]},d.logic_null=function(){return["null",t.ATOMIC]},d.logic_operation=function(e,i){var n="AND"===e.getFieldValue("OP")?"&&":"||",o="&&"===n?t.LOGICAL_AND:t.LOGICAL_OR,s=i.valueToCode(e,"A",o);return e=i.valueToCode(e,"B",o),s||e?(i="&&"===n?"true":"false",s||(s=i),e||(e=i)):e=s="false",[s+" "+n+" "+e,o]},d.logic_ternary=function(e,i){return[(i.valueToCode(e,"IF",t.CONDITIONAL)||"false")+" ? "+(i.valueToCode(e,"THEN",t.CONDITIONAL)||"null")+" : "+(e=i.valueToCode(e,"ELSE",t.CONDITIONAL)||"null"),t.CONDITIONAL]};var p={controls_flow_statements:function(e,t){var i="";if(t.STATEMENT_PREFIX&&(i+=t.injectId(t.STATEMENT_PREFIX,e)),t.STATEMENT_SUFFIX&&(i+=t.injectId(t.STATEMENT_SUFFIX,e)),t.STATEMENT_PREFIX){let n=e.getSurroundLoop();n&&!n.suppressPrefixSuffix&&(i+=t.injectId(t.STATEMENT_PREFIX,n))}switch(e.getFieldValue("FLOW")){case"BREAK":return i+"break;\n";case"CONTINUE":return i+"continue;\n"}throw Error("Unknown flow statement.")},controls_for:function(e,n){var o=n.getVariableName(e.getFieldValue("VAR")),s=n.valueToCode(e,"FROM",t.ASSIGNMENT)||"0",r=n.valueToCode(e,"TO",t.ASSIGNMENT)||"0",a=n.valueToCode(e,"BY",t.ASSIGNMENT)||"1",l=n.statementToCode(e,"DO");if(l=n.addLoopTrap(l,e),i.zf(s)&&i.zf(r)&&i.zf(a))e="for ("+o+" = "+s+"; "+o+((n=Number(s)<=Number(r))?" <= ":" >= ")+r+"; "+o,e=1===(o=Math.abs(Number(a)))?e+(n?"++":"--"):e+(n?" += ":" -= ")+o,e+=") {\n"+l+"}\n";else{e="";let t=s;s.match(/^\w+$/)||i.zf(s)||(t=n.nameDB_.getDistinctName(o+"_start",i.P.VARIABLE),e+=t+" = "+s+";\n"),s=r,r.match(/^\w+$/)||i.zf(r)||(e+=(s=n.nameDB_.getDistinctName(o+"_end",i.P.VARIABLE))+" = "+r+";\n"),e+=(r=n.nameDB_.getDistinctName(o+"_inc",i.P.VARIABLE))+" = ",e=i.zf(a)?e+(Math.abs(Number(a))+";\n"):e+"abs("+a+");\n",e+="if ("+t+" > "+s+") {\n",e=(e+=n.INDENT+r+" = -"+r+";\n")+"}\nfor ("+o+" = "+t+"; "+r+" >= 0 ? "+o+" <= "+s+" : "+o+" >= "+s+"; "+o+" += "+r+") {\n"+l+"}\n"}return e},controls_forEach:function(e,i){var n=i.getVariableName(e.getFieldValue("VAR")),o=i.valueToCode(e,"LIST",t.ASSIGNMENT)||"[]",s=i.statementToCode(e,"DO");return"foreach ("+o+" as "+n+") {\n"+(s=i.addLoopTrap(s,e))+"}\n"}};p.controls_repeat=o,p.controls_repeat_ext=o,p.controls_whileUntil=function(e,i){var n="UNTIL"===e.getFieldValue("MODE"),o=i.valueToCode(e,"BOOL",n?t.LOGICAL_NOT:t.NONE)||"false",s=i.statementToCode(e,"DO");return n&&(o="!"+o),"while ("+o+") {\n"+(s=i.addLoopTrap(s,e))+"}\n"};var g={math_arithmetic:function(e,i){var n={ADD:[" + ",t.ADDITION],MINUS:[" - ",t.SUBTRACTION],MULTIPLY:[" * ",t.MULTIPLICATION],DIVIDE:[" / ",t.DIVISION],POWER:[" ** ",t.POWER]}[e.getFieldValue("OP")],o=n[0];return n=n[1],[(i.valueToCode(e,"A",n)||"0")+o+(e=i.valueToCode(e,"B",n)||"0"),n]},math_atan2:function(e,i){var n=i.valueToCode(e,"X",t.NONE)||"0";return["atan2("+(i.valueToCode(e,"Y",t.NONE)||"0")+", "+n+") / pi() * 180",t.DIVISION]},math_change:function(e,i){var n=i.valueToCode(e,"DELTA",t.ADDITION)||"0";return i.getVariableName(e.getFieldValue("VAR"))+" += "+n+";\n"},math_constant:function(e){return{PI:["M_PI",t.ATOMIC],E:["M_E",t.ATOMIC],GOLDEN_RATIO:["(1 + sqrt(5)) / 2",t.DIVISION],SQRT2:["M_SQRT2",t.ATOMIC],SQRT1_2:["M_SQRT1_2",t.ATOMIC],INFINITY:["INF",t.ATOMIC]}[e.getFieldValue("CONSTANT")]},math_constrain:function(e,i){return["min(max("+(i.valueToCode(e,"VALUE",t.NONE)||"0")+", "+(i.valueToCode(e,"LOW",t.NONE)||"0")+"), "+(e=i.valueToCode(e,"HIGH",t.NONE)||"Infinity")+")",t.FUNCTION_CALL]},math_modulo:function(e,i){return[(i.valueToCode(e,"DIVIDEND",t.MODULUS)||"0")+" % "+(e=i.valueToCode(e,"DIVISOR",t.MODULUS)||"0"),t.MODULUS]},math_number:function(e){return(e=Number(e.getFieldValue("NUM")))===1/0?["INF",t.ATOMIC]:e===-1/0?["-INF",t.UNARY_NEGATION]:[String(e),e>=0?t.ATOMIC:t.UNARY_NEGATION]},math_number_property:function(e,i){var n={EVEN:[""," % 2 == 0",t.MODULUS,t.EQUALITY],ODD:[""," % 2 == 1",t.MODULUS,t.EQUALITY],WHOLE:["is_int(",")",t.NONE,t.FUNCTION_CALL],POSITIVE:[""," > 0",t.RELATIONAL,t.RELATIONAL],NEGATIVE:[""," < 0",t.RELATIONAL,t.RELATIONAL],DIVISIBLE_BY:[null,null,t.MODULUS,t.EQUALITY],PRIME:[null,null,t.NONE,t.FUNCTION_CALL]},o=e.getFieldValue("PROPERTY"),[s,r,a,l]=n[o];if(n=i.valueToCode(e,"NUMBER_TO_CHECK",a)||"0","PRIME"===o)e=i.provideFunction_("math_isPrime",`\nfunction ${i.FUNCTION_NAME_PLACEHOLDER_}($n) {\n // https://en.wikipedia.org/wiki/Primality_test#Naive_methods\n if ($n == 2 || $n == 3) {\n return true;\n }\n // False if n is NaN, negative, is 1, or not whole.\n // And false if n is divisible by 2 or 3.\n if (!is_numeric($n) || $n <= 1 || $n % 1 != 0 || $n % 2 == 0 || $n % 3 == 0) {\n return false;\n }\n // Check all the numbers of form 6k +/- 1, up to sqrt(n).\n for ($x = 6; $x <= sqrt($n) + 1; $x += 6) {\n if ($n % ($x - 1) == 0 || $n % ($x + 1) == 0) {\n return false;\n }\n }\n return true;\n}\n`)+"("+n+")";else if("DIVISIBLE_BY"===o){if("0"===(e=i.valueToCode(e,"DIVISOR",t.MODULUS)||"0"))return["false",t.ATOMIC];e=n+" % "+e+" == 0"}else e=s+n+r;return[e,l]},math_on_list:function(e,i){var n=e.getFieldValue("OP");switch(n){case"SUM":e="array_sum("+(e=i.valueToCode(e,"LIST",t.FUNCTION_CALL)||"array()")+")";break;case"MIN":e="min("+(e=i.valueToCode(e,"LIST",t.FUNCTION_CALL)||"array()")+")";break;case"MAX":e="max("+(e=i.valueToCode(e,"LIST",t.FUNCTION_CALL)||"array()")+")";break;case"AVERAGE":e=(n=i.provideFunction_("math_mean",`\nfunction ${i.FUNCTION_NAME_PLACEHOLDER_}($myList) {\n return array_sum($myList) / count($myList);\n}\n`))+"("+(e=i.valueToCode(e,"LIST",t.NONE)||"array()")+")";break;case"MEDIAN":e=(n=i.provideFunction_("math_median",`\nfunction ${i.FUNCTION_NAME_PLACEHOLDER_}($arr) {\n sort($arr,SORT_NUMERIC);\n return (count($arr) % 2) ? $arr[floor(count($arr) / 2)] :\n ($arr[floor(count($arr) / 2)] + $arr[floor(count($arr) / 2) - 1]) / 2;\n}\n`))+"("+(e=i.valueToCode(e,"LIST",t.NONE)||"[]")+")";break;case"MODE":e=(n=i.provideFunction_("math_modes",`\nfunction ${i.FUNCTION_NAME_PLACEHOLDER_}($values) {\n if (empty($values)) return array();\n $counts = array_count_values($values);\n arsort($counts); // Sort counts in descending order\n $modes = array_keys($counts, current($counts), true);\n return $modes;\n}\n`))+"("+(e=i.valueToCode(e,"LIST",t.NONE)||"[]")+")";break;case"STD_DEV":e=(n=i.provideFunction_("math_standard_deviation",`\nfunction ${i.FUNCTION_NAME_PLACEHOLDER_}($numbers) {\n $n = count($numbers);\n if (!$n) return null;\n $mean = array_sum($numbers) / count($numbers);\n foreach($numbers as $key => $num) $devs[$key] = pow($num - $mean, 2);\n return sqrt(array_sum($devs) / (count($devs) - 1));\n}\n`))+"("+(e=i.valueToCode(e,"LIST",t.NONE)||"[]")+")";break;case"RANDOM":e=(n=i.provideFunction_("math_random_list",`\nfunction ${i.FUNCTION_NAME_PLACEHOLDER_}($list) {\n $x = rand(0, count($list)-1);\n return $list[$x];\n}\n`))+"("+(e=i.valueToCode(e,"LIST",t.NONE)||"[]")+")";break;default:throw Error("Unknown operator: "+n)}return[e,t.FUNCTION_CALL]},math_random_float:function(){return["(float)rand()/(float)getrandmax()",t.FUNCTION_CALL]},math_random_int:function(e,i){var n=i.valueToCode(e,"FROM",t.NONE)||"0";return e=i.valueToCode(e,"TO",t.NONE)||"0",[i.provideFunction_("math_random_int",`\nfunction ${i.FUNCTION_NAME_PLACEHOLDER_}($a, $b) {\n if ($a > $b) {\n return rand($b, $a);\n }\n return rand($a, $b);\n}\n`)+"("+n+", "+e+")",t.FUNCTION_CALL]}};g.math_round=s,g.math_single=s,g.math_trig=s;var E={procedures_callnoreturn:function(e,t){return t.forBlock.procedures_callreturn(e,t)[0]+";\n"},procedures_callreturn:function(e,i){var n=i.getProcedureName(e.getFieldValue("NAME")),o=[],s=e.getVarModels();for(let n=0;n<s.length;n++)o[n]=i.valueToCode(e,"ARG"+n,t.NONE)||"null";return[n+"("+o.join(", ")+")",t.FUNCTION_CALL]}};E.procedures_defnoreturn=r,E.procedures_defreturn=r,E.procedures_ifreturn=function(e,i){var n="if ("+(i.valueToCode(e,"CONDITION",t.NONE)||"false")+") {\n";return i.STATEMENT_SUFFIX&&(n+=i.prefixLines(i.injectId(i.STATEMENT_SUFFIX,e),i.INDENT)),e.hasReturnValue_?(e=i.valueToCode(e,"VALUE",t.NONE)||"null",n+=i.INDENT+"return "+e+";\n"):n+=i.INDENT+"return;\n",n+"}\n"};var T={text:function(e,i){return[i.quote_(e.getFieldValue("TEXT")),t.ATOMIC]},text_append:function(e,i){return i.getVariableName(e.getFieldValue("VAR"))+" .= "+(e=i.valueToCode(e,"TEXT",t.ASSIGNMENT)||"''")+";\n"},text_changeCase:function(e,i){var n;return i=i.valueToCode(e,"TEXT",t.NONE)||"''","UPPERCASE"===e.getFieldValue("CASE")?n="strtoupper("+i+")":"LOWERCASE"===e.getFieldValue("CASE")?n="strtolower("+i+")":"TITLECASE"===e.getFieldValue("CASE")&&(n="ucwords(strtolower("+i+"))"),[n,t.FUNCTION_CALL]},text_charAt:function(e,i){var n=e.getFieldValue("WHERE")||"FROM_START",o=i.valueToCode(e,"VALUE",t.NONE)||"''";switch(n){case"FIRST":return["substr("+o+", 0, 1)",t.FUNCTION_CALL];case"LAST":return["substr("+o+", -1)",t.FUNCTION_CALL];case"FROM_START":return["substr("+o+", "+(e=i.getAdjusted(e,"AT"))+", 1)",t.FUNCTION_CALL];case"FROM_END":return["substr("+o+", "+(e=i.getAdjusted(e,"AT",1,!0))+", 1)",t.FUNCTION_CALL];case"RANDOM":return[i.provideFunction_("text_random_letter",`\nfunction ${i.FUNCTION_NAME_PLACEHOLDER_}($text) {\n return $text[rand(0, strlen($text) - 1)];\n}\n`)+"("+o+")",t.FUNCTION_CALL]}throw Error("Unhandled option (text_charAt).")},text_count:function(e,i){var n=i.valueToCode(e,"TEXT",t.NONE)||"''";return["strlen("+(e=i.valueToCode(e,"SUB",t.NONE)||"''")+") === 0 ? strlen("+n+") + 1 : substr_count("+n+", "+e+")",t.CONDITIONAL]},text_getSubstring:function(e,i){var n=e.getFieldValue("WHERE1"),o=e.getFieldValue("WHERE2"),s=i.valueToCode(e,"STRING",t.NONE)||"''";if("FIRST"===n&&"LAST"===o)return[s,t.NONE];var r=i.getAdjusted(e,"AT1");return e=i.getAdjusted(e,"AT2"),[i.provideFunction_("text_get_substring",`\nfunction ${i.FUNCTION_NAME_PLACEHOLDER_}($text, $where1, $at1, $where2, $at2) {\n if ($where1 == 'FROM_END') {\n $at1 = strlen($text) - 1 - $at1;\n } else if ($where1 == 'FIRST') {\n $at1 = 0;\n } else if ($where1 != 'FROM_START') {\n throw new Exception('Unhandled option (text_get_substring).');\n }\n $length = 0;\n if ($where2 == 'FROM_START') {\n $length = $at2 - $at1 + 1;\n } else if ($where2 == 'FROM_END') {\n $length = strlen($text) - $at1 - $at2;\n } else if ($where2 == 'LAST') {\n $length = strlen($text) - $at1;\n } else {\n throw new Exception('Unhandled option (text_get_substring).');\n }\n return substr($text, $at1, $length);\n}\n`)+"("+s+", '"+n+"', "+r+", '"+o+"', "+e+")",t.FUNCTION_CALL]},text_indexOf:function(e,i){var n="FIRST"===e.getFieldValue("END")?"strpos":"strrpos",o=i.valueToCode(e,"FIND",t.NONE)||"''",s=i.valueToCode(e,"VALUE",t.NONE)||"''",r=" -1",a="";return e.workspace.options.oneBasedIndex&&(r=" 0",a=" + 1"),[i.provideFunction_("FIRST"===e.getFieldValue("END")?"text_indexOf":"text_lastIndexOf",`\nfunction ${i.FUNCTION_NAME_PLACEHOLDER_}($text, $search) {\n $pos = ${n}($text, $search);\n return $pos === false ? ${r} : $pos${a};\n}\n`)+"("+s+", "+o+")",t.FUNCTION_CALL]},text_isEmpty:function(e,i){return["empty("+(i.valueToCode(e,"VALUE",t.NONE)||"''")+")",t.FUNCTION_CALL]},text_join:function(e,i){if(0===e.itemCount_)return["''",t.ATOMIC];if(1===e.itemCount_)return[i.valueToCode(e,"ADD0",t.NONE)||"''",t.NONE];if(2===e.itemCount_){var n=i.valueToCode(e,"ADD0",t.STRING_CONCAT)||"''";return[n+" . "+(e=i.valueToCode(e,"ADD1",t.STRING_CONCAT)||"''"),t.STRING_CONCAT]}n=Array(e.itemCount_);for(let o=0;o<e.itemCount_;o++)n[o]=i.valueToCode(e,"ADD"+o,t.NONE)||"''";return["implode('', array("+n.join(",")+"))",t.FUNCTION_CALL]},text_length:function(e,i){return[i.provideFunction_("length",`\nfunction ${i.FUNCTION_NAME_PLACEHOLDER_}($value) {\n if (is_string($value)) {\n return strlen($value);\n }\n return count($value);\n}\n`)+"("+(e=i.valueToCode(e,"VALUE",t.NONE)||"''")+")",t.FUNCTION_CALL]},text_print:function(e,i){return"print("+(i.valueToCode(e,"TEXT",t.NONE)||"''")+");\n"}};T.text_prompt=a,T.text_prompt_ext=a,T.text_replace=function(e,i){var n=i.valueToCode(e,"TEXT",t.NONE)||"''";return["str_replace("+(i.valueToCode(e,"FROM",t.NONE)||"''")+", "+(e=i.valueToCode(e,"TO",t.NONE)||"''")+", "+n+")",t.FUNCTION_CALL]},T.text_reverse=function(e,i){return["strrev("+(i.valueToCode(e,"TEXT",t.NONE)||"''")+")",t.FUNCTION_CALL]},T.text_trim=function(e,i){return[{LEFT:"ltrim",RIGHT:"rtrim",BOTH:"trim"}[e.getFieldValue("MODE")]+"("+(e=i.valueToCode(e,"TEXT",t.NONE)||"''")+")",t.FUNCTION_CALL]};var _={};_.variables_get=l,_.variables_set=h;var f={};f.variables_get_dynamic=l,f.variables_set_dynamic=h;var m=new c,b=Object.assign({},{lists_create_empty:function(){return["array()",t.FUNCTION_CALL]},lists_create_with:function(e,i){var n=Array(e.itemCount_);for(let o=0;o<e.itemCount_;o++)n[o]=i.valueToCode(e,"ADD"+o,t.NONE)||"null";return["array("+n.join(", ")+")",t.FUNCTION_CALL]},lists_getIndex:function(e,i){var n=e.getFieldValue("MODE")||"GET";switch(e.getFieldValue("WHERE")||"FROM_START"){case"FIRST":if("GET"===n)return[(i.valueToCode(e,"VALUE",t.MEMBER)||"array()")+"[0]",t.MEMBER];if("GET_REMOVE"===n)return["array_shift("+(i.valueToCode(e,"VALUE",t.NONE)||"array()")+")",t.FUNCTION_CALL];if("REMOVE"===n)return"array_shift("+(i.valueToCode(e,"VALUE",t.NONE)||"array()")+");\n";break;case"LAST":if("GET"===n)return["end("+(i.valueToCode(e,"VALUE",t.NONE)||"array()")+")",t.FUNCTION_CALL];if("GET_REMOVE"===n)return["array_pop("+(i.valueToCode(e,"VALUE",t.NONE)||"array()")+")",t.FUNCTION_CALL];if("REMOVE"===n)return"array_pop("+(i.valueToCode(e,"VALUE",t.NONE)||"array()")+");\n";break;case"FROM_START":var o=i.getAdjusted(e,"AT");if("GET"===n)return[(i.valueToCode(e,"VALUE",t.MEMBER)||"array()")+"["+o+"]",t.MEMBER];if("GET_REMOVE"===n)return["array_splice("+(i.valueToCode(e,"VALUE",t.NONE)||"array()")+", "+o+", 1)[0]",t.FUNCTION_CALL];if("REMOVE"===n)return"array_splice("+(i.valueToCode(e,"VALUE",t.NONE)||"array()")+", "+o+", 1);\n";break;case"FROM_END":if("GET"===n)return["array_slice("+(n=i.valueToCode(e,"VALUE",t.NONE)||"array()")+", "+(i=i.getAdjusted(e,"AT",1,!0))+", 1)[0]",t.FUNCTION_CALL];if("GET_REMOVE"===n||"REMOVE"===n){if(o=i.valueToCode(e,"VALUE",t.NONE)||"array()",i="array_splice("+o+", count("+o+") - "+(i=i.getAdjusted(e,"AT",1,!1,t.SUBTRACTION))+", 1)[0]","GET_REMOVE"===n)return[i,t.FUNCTION_CALL];if("REMOVE"===n)return i+";\n"}break;case"RANDOM":if(e=i.valueToCode(e,"VALUE",t.NONE)||"array()","GET"===n)return[i.provideFunction_("lists_get_random_item",`\nfunction ${i.FUNCTION_NAME_PLACEHOLDER_}($list) {\n return $list[rand(0,count($list)-1)];\n}\n`)+"("+e+")",t.FUNCTION_CALL];if("GET_REMOVE"===n)return[i.provideFunction_("lists_get_remove_random_item",`\nfunction ${i.FUNCTION_NAME_PLACEHOLDER_}(&$list) {\n $x = rand(0,count($list)-1);\n unset($list[$x]);\n return array_values($list);\n}\n`)+"("+e+")",t.FUNCTION_CALL];if("REMOVE"===n)return i.provideFunction_("lists_remove_random_item",`\nfunction ${i.FUNCTION_NAME_PLACEHOLDER_}(&$list) {\n unset($list[rand(0,count($list)-1)]);\n}\n`)+"("+e+");\n"}throw Error("Unhandled combination (lists_getIndex).")},lists_getSublist:function(e,n){var o=n.valueToCode(e,"LIST",t.NONE)||"array()",s=e.getFieldValue("WHERE1"),r=e.getFieldValue("WHERE2");if("FIRST"!==s||"LAST"!==r)if(o.match(/^\$\w+$/)||"FROM_END"!==s&&"FROM_START"===r){switch(s){case"FROM_START":s=n.getAdjusted(e,"AT1");break;case"FROM_END":s="count("+o+") - "+(s=n.getAdjusted(e,"AT1",1,!1,t.SUBTRACTION));break;case"FIRST":s="0";break;default:throw Error("Unhandled option (lists_getSublist).")}switch(r){case"FROM_START":n=n.getAdjusted(e,"AT2",0,!1,t.SUBTRACTION),n+=" - ",n=i.zf(String(s))||String(s).match(/^\(.+\)$/)?n+s:n+"("+s+")",n+=" + 1";break;case"FROM_END":n="count("+o+") - "+(n=n.getAdjusted(e,"AT2",0,!1,t.SUBTRACTION))+" - ",n=i.zf(String(s))||String(s).match(/^\(.+\)$/)?n+s:n+"("+s+")";break;case"LAST":n="count("+o+") - ",n=i.zf(String(s))||String(s).match(/^\(.+\)$/)?n+s:n+"("+s+")";break;default:throw Error("Unhandled option (lists_getSublist).")}o="array_slice("+o+", "+s+", "+n+")"}else{let t=n.getAdjusted(e,"AT1");e=n.getAdjusted(e,"AT2"),o=n.provideFunction_("lists_get_sublist",`\nfunction ${n.FUNCTION_NAME_PLACEHOLDER_}($list, $where1, $at1, $where2, $at2) {\n if ($where1 == 'FROM_END') {\n $at1 = count($list) - 1 - $at1;\n } else if ($where1 == 'FIRST') {\n $at1 = 0;\n } else if ($where1 != 'FROM_START') {\n throw new Exception('Unhandled option (lists_get_sublist).');\n }\n $length = 0;\n if ($where2 == 'FROM_START') {\n $length = $at2 - $at1 + 1;\n } else if ($where2 == 'FROM_END') {\n $length = count($list) - $at1 - $at2;\n } else if ($where2 == 'LAST') {\n $length = count($list) - $at1;\n } else {\n throw new Exception('Unhandled option (lists_get_sublist).');\n }\n return array_slice($list, $at1, $length);\n}\n`)+"("+o+", '"+s+"', "+t+", '"+r+"', "+e+")"}return[o,t.FUNCTION_CALL]},lists_indexOf:function(e,i){var n=i.valueToCode(e,"FIND",t.NONE)||"''",o=i.valueToCode(e,"VALUE",t.MEMBER)||"[]",s=" -1",r="";return e.workspace.options.oneBasedIndex&&(s=" 0",r=" + 1"),[("FIRST"===e.getFieldValue("END")?i.provideFunction_("indexOf",`\nfunction ${i.FUNCTION_NAME_PLACEHOLDER_}($haystack, $needle) {\n for ($index = 0; $index < count($haystack); $index++) {\n if ($haystack[$index] == $needle) return $index${r};\n }\n return ${s};\n}\n`):i.provideFunction_("lastIndexOf",`\nfunction ${i.FUNCTION_NAME_PLACEHOLDER_}($haystack, $needle) {\n $last = ${s};\n for ($index = 0; $index < count($haystack); $index++) {\n if ($haystack[$index] == $needle) $last = $index${r};\n }\n return $last;\n}\n`))+"("+o+", "+n+")",t.FUNCTION_CALL]},lists_isEmpty:function(e,i){return["empty("+(i.valueToCode(e,"VALUE",t.FUNCTION_CALL)||"array()")+")",t.FUNCTION_CALL]},lists_length:function(e,i){return[i.provideFunction_("length",`\nfunction ${i.FUNCTION_NAME_PLACEHOLDER_}($value) {\n if (is_string($value)) {\n return strlen($value);\n } else {\n return count($value);\n }\n}\n`)+"("+(e=i.valueToCode(e,"VALUE",t.NONE)||"''")+")",t.FUNCTION_CALL]},lists_repeat:function(e,i){return[i.provideFunction_("lists_repeat",`\nfunction ${i.FUNCTION_NAME_PLACEHOLDER_}($value, $count) {\n $array = array();\n for ($index = 0; $index < $count; $index++) {\n $array[] = $value;\n }\n return $array;\n}\n`)+"("+(i.valueToCode(e,"ITEM",t.NONE)||"null")+", "+(e=i.valueToCode(e,"NUM",t.NONE)||"0")+")",t.FUNCTION_CALL]},lists_reverse:function(e,i){return["array_reverse("+(i.valueToCode(e,"LIST",t.NONE)||"[]")+")",t.FUNCTION_CALL]},lists_setIndex:function(e,n){var o=e.getFieldValue("MODE")||"GET",s=e.getFieldValue("WHERE")||"FROM_START",r=n.valueToCode(e,"TO",t.ASSIGNMENT)||"null";switch(s){case"FIRST":if("SET"===o)return(n.valueToCode(e,"LIST",t.MEMBER)||"array()")+"[0] = "+r+";\n";if("INSERT"===o)return"array_unshift("+(n.valueToCode(e,"LIST",t.NONE)||"array()")+", "+r+");\n";break;case"LAST":if(e=n.valueToCode(e,"LIST",t.NONE)||"array()","SET"===o)return n.provideFunction_("lists_set_last_item",`\nfunction ${n.FUNCTION_NAME_PLACEHOLDER_}(&$list, $value) {\n $list[count($list) - 1] = $value;\n}\n`)+"("+e+", "+r+");\n";if("INSERT"===o)return"array_push("+e+", "+r+");\n";break;case"FROM_START":if(s=n.getAdjusted(e,"AT"),"SET"===o)return(n.valueToCode(e,"LIST",t.MEMBER)||"array()")+"["+s+"] = "+r+";\n";if("INSERT"===o)return"array_splice("+(n.valueToCode(e,"LIST",t.NONE)||"array()")+", "+s+", 0, "+r+");\n";break;case"FROM_END":if(s=n.valueToCode(e,"LIST",t.NONE)||"array()",e=n.getAdjusted(e,"AT",1),"SET"===o)return n.provideFunction_("lists_set_from_end",`\nfunction ${n.FUNCTION_NAME_PLACEHOLDER_}(&$list, $at, $value) {\n $list[count($list) - $at] = $value;\n}\n`)+"("+s+", "+e+", "+r+");\n";if("INSERT"===o)return n.provideFunction_("lists_insert_from_end",`\nfunction ${n.FUNCTION_NAME_PLACEHOLDER_}(&$list, $at, $value) {\n return array_splice($list, count($list) - $at, 0, $value);\n}\n`)+"("+s+", "+e+", "+r+");\n";break;case"RANDOM":if((e=n.valueToCode(e,"LIST",t.REFERENCE)||"array()").match(/^\$\w+$/))s="";else{var a=(s=n.nameDB_.getDistinctName("tmp_list",i.P.VARIABLE))+" = &"+e+";\n";e=s,s=a}if(s+=(n=n.nameDB_.getDistinctName("tmp_x",i.P.VARIABLE))+" = rand(0, count("+e+")-1);\n","SET"===o)return s+(e+"[")+n+"] = "+r+";\n";if("INSERT"===o)return s+"array_splice("+e+", "+n+", 0, "+r+");\n"}throw Error("Unhandled combination (lists_setIndex).")},lists_sort:function(e,i){var n=i.valueToCode(e,"LIST",t.NONE)||"array()",o="1"===e.getFieldValue("DIRECTION")?1:-1;return e=e.getFieldValue("TYPE"),[i.provideFunction_("lists_sort",`\nfunction ${i.FUNCTION_NAME_PLACEHOLDER_}($list, $type, $direction) {\n $sortCmpFuncs = array(\n 'NUMERIC' => 'strnatcasecmp',\n 'TEXT' => 'strcmp',\n 'IGNORE_CASE' => 'strcasecmp'\n );\n $sortCmp = $sortCmpFuncs[$type];\n $list2 = $list;\n usort($list2, $sortCmp);\n if ($direction == -1) {\n $list2 = array_reverse($list2);\n }\n return $list2;\n}\n`)+"("+n+', "'+e+'", '+o+")",t.FUNCTION_CALL]},lists_split:function(e,i){var n=i.valueToCode(e,"INPUT",t.NONE);if(i=i.valueToCode(e,"DELIM",t.NONE)||"''","SPLIT"===(e=e.getFieldValue("MODE")))n||(n="''"),e="explode";else{if("JOIN"!==e)throw Error("Unknown mode: "+e);n||(n="array()"),e="implode"}return[e+"("+i+", "+n+")",t.FUNCTION_CALL]}},d,p,g,E,T,_,f);for(let e in b)m.forBlock[e]=b[e];var C={};return C.Order=t,C.PhpGenerator=c,C.phpGenerator=m,i.__chunk_php=C,i.__chunk_php.__namespace__=i,i.__chunk_php})?n.apply(t,o):n)||(e.exports=s)},794:function(e,t,i){var n,o,s;o=[i(500)],void 0===(s="function"==typeof(n=function(e){var t,i=e.__namespace__,n=function(e,i){var n=0,o="";i.STATEMENT_PREFIX&&(o+=i.injectId(i.STATEMENT_PREFIX,e));do{var s=i.valueToCode(e,"IF"+n,t.NONE)||"False",r=i.statementToCode(e,"DO"+n)||i.PASS;i.STATEMENT_SUFFIX&&(r=i.prefixLines(i.injectId(i.STATEMENT_SUFFIX,e),i.INDENT)+r),o+=(0===n?"if ":"elif ")+s+":\n"+r,n++}while(e.getInput("IF"+n));return(e.getInput("ELSE")||i.STATEMENT_SUFFIX)&&(r=e.getInput("ELSE")&&i.statementToCode(e,"ELSE")||i.PASS,i.STATEMENT_SUFFIX&&(r=i.prefixLines(i.injectId(i.STATEMENT_SUFFIX,e),i.INDENT)+r),o+="else:\n"+r),o},o=function(e,n){var o=e.getField("TIMES")?String(parseInt(e.getFieldValue("TIMES"),10)):n.valueToCode(e,"TIMES",t.NONE)||"0";o=i.zf(o)?parseInt(o,10):"int("+o+")";var s=n.statementToCode(e,"DO");return s=n.addLoopTrap(s,e)||n.PASS,"for "+n.nameDB_.getDistinctName("count",i.P.VARIABLE)+" in range("+o+"):\n"+s},s=function(e,i){var n=e.getFieldValue("OP");if("NEG"===n){var o=i.valueToCode(e,"NUM",t.UNARY_SIGN)||"0";return["-"+o,t.UNARY_SIGN]}switch(i.definitions_.import_math="import math",e="SIN"===n||"COS"===n||"TAN"===n?i.valueToCode(e,"NUM",t.MULTIPLICATIVE)||"0":i.valueToCode(e,"NUM",t.NONE)||"0",n){case"ABS":o="math.fabs("+e+")";break;case"ROOT":o="math.sqrt("+e+")";break;case"LN":o="math.log("+e+")";break;case"LOG10":o="math.log10("+e+")";break;case"EXP":o="math.exp("+e+")";break;case"POW10":o="math.pow(10,"+e+")";break;case"ROUND":o="round("+e+")";break;case"ROUNDUP":o="math.ceil("+e+")";break;case"ROUNDDOWN":o="math.floor("+e+")";break;case"SIN":o="math.sin("+e+" / 180.0 * math.pi)";break;case"COS":o="math.cos("+e+" / 180.0 * math.pi)";break;case"TAN":o="math.tan("+e+" / 180.0 * math.pi)"}if(o)return[o,t.FUNCTION_CALL];switch(n){case"ASIN":o="math.asin("+e+") / math.pi * 180";break;case"ACOS":o="math.acos("+e+") / math.pi * 180";break;case"ATAN":o="math.atan("+e+") / math.pi * 180";break;default:throw Error("Unknown math operator: "+n)}return[o,t.MULTIPLICATIVE]},r=function(e,n){var o=[],s=e.workspace,r=i.Bd(s)||[];for(var a of r)r=a.getName(),e.getVarModels().includes(a)||o.push(n.getVariableName(r));for(s=i.Cd(s),a=0;a<s.length;a++)o.push(n.nameDB_.getName(s[a],i.P.DEVELOPER_VARIABLE));s=o.length?n.INDENT+"global "+o.join(", ")+"\n":"",o=n.getProcedureName(e.getFieldValue("NAME")),a="",n.STATEMENT_PREFIX&&(a+=n.injectId(n.STATEMENT_PREFIX,e)),n.STATEMENT_SUFFIX&&(a+=n.injectId(n.STATEMENT_SUFFIX,e)),a&&(a=n.prefixLines(a,n.INDENT)),r="",n.INFINITE_LOOP_TRAP&&(r=n.prefixLines(n.injectId(n.INFINITE_LOOP_TRAP,e),n.INDENT));var l="";e.getInput("STACK")&&(l=n.statementToCode(e,"STACK"));var h="";e.getInput("RETURN")&&(h=n.valueToCode(e,"RETURN",t.NONE)||"");var u="";l&&h&&(u=a),h?h=n.INDENT+"return "+h+"\n":l||(l=n.PASS);var c=[],d=e.getVarModels();for(let e=0;e<d.length;e++)c[e]=n.getVariableName(d[e].getId());return s="def "+o+"("+c.join(", ")+"):\n"+s+a+r+l+u+h,s=n.scrub_(e,s),n.definitions_["%"+o]=s,null},a=function(e){return _.test(e)?[e,t.ATOMIC]:["str("+e+")",t.FUNCTION_CALL]},l=function(e,i){var n=i.provideFunction_("text_prompt",`\ndef ${i.FUNCTION_NAME_PLACEHOLDER_}(msg):\n try:\n return raw_input(msg)\n except NameError:\n return input(msg)\n`);return n=n+"("+(i=e.getField("TEXT")?i.quote_(e.getFieldValue("TEXT")):i.valueToCode(e,"TEXT",t.NONE)||"''")+")","NUMBER"===e.getFieldValue("TYPE")&&(n="float("+n+")"),[n,t.FUNCTION_CALL]},h=function(e,i){return[i.getVariableName(e.getFieldValue("VAR")),t.ATOMIC]},u=function(e,i){var n=i.valueToCode(e,"VALUE",t.NONE)||"0";return i.getVariableName(e.getFieldValue("VAR"))+" = "+n+"\n"},c=t||(t={});c[c.ATOMIC=0]="ATOMIC",c[c.COLLECTION=1]="COLLECTION",c[c.STRING_CONVERSION=1]="STRING_CONVERSION",c[c.MEMBER=2.1]="MEMBER",c[c.FUNCTION_CALL=2.2]="FUNCTION_CALL",c[c.EXPONENTIATION=3]="EXPONENTIATION",c[c.UNARY_SIGN=4]="UNARY_SIGN",c[c.BITWISE_NOT=4]="BITWISE_NOT",c[c.MULTIPLICATIVE=5]="MULTIPLICATIVE",c[c.ADDITIVE=6]="ADDITIVE",c[c.BITWISE_SHIFT=7]="BITWISE_SHIFT",c[c.BITWISE_AND=8]="BITWISE_AND",c[c.BITWISE_XOR=9]="BITWISE_XOR",c[c.BITWISE_OR=10]="BITWISE_OR",c[c.RELATIONAL=11]="RELATIONAL",c[c.LOGICAL_NOT=12]="LOGICAL_NOT",c[c.LOGICAL_AND=13]="LOGICAL_AND",c[c.LOGICAL_OR=14]="LOGICAL_OR",c[c.CONDITIONAL=15]="CONDITIONAL",c[c.LAMBDA=16]="LAMBDA",c[c.NONE=99]="NONE";var d=class extends i.zq{constructor(e="Python"){super(e),this.ORDER_OVERRIDES=[[t.FUNCTION_CALL,t.MEMBER],[t.FUNCTION_CALL,t.FUNCTION_CALL],[t.MEMBER,t.MEMBER],[t.MEMBER,t.FUNCTION_CALL],[t.LOGICAL_NOT,t.LOGICAL_NOT],[t.LOGICAL_AND,t.LOGICAL_AND],[t.LOGICAL_OR,t.LOGICAL_OR]],this.PASS="",this.isInitialized=!1;for(let i in t)"string"!=typeof(e=t[i])&&(this["ORDER_"+i]=e);this.addReservedWords("False,None,True,and,as,assert,break,class,continue,def,del,elif,else,except,exec,finally,for,from,global,if,import,in,is,lambda,nonlocal,not,or,pass,print,raise,return,try,while,with,yield,NotImplemented,Ellipsis,__debug__,quit,exit,copyright,license,credits,ArithmeticError,AssertionError,AttributeError,BaseException,BlockingIOError,BrokenPipeError,BufferError,BytesWarning,ChildProcessError,ConnectionAbortedError,ConnectionError,ConnectionRefusedError,ConnectionResetError,DeprecationWarning,EOFError,Ellipsis,EnvironmentError,Exception,FileExistsError,FileNotFoundError,FloatingPointError,FutureWarning,GeneratorExit,IOError,ImportError,ImportWarning,IndentationError,IndexError,InterruptedError,IsADirectoryError,KeyError,KeyboardInterrupt,LookupError,MemoryError,ModuleNotFoundError,NameError,NotADirectoryError,NotImplemented,NotImplementedError,OSError,OverflowError,PendingDeprecationWarning,PermissionError,ProcessLookupError,RecursionError,ReferenceError,ResourceWarning,RuntimeError,RuntimeWarning,StandardError,StopAsyncIteration,StopIteration,SyntaxError,SyntaxWarning,SystemError,SystemExit,TabError,TimeoutError,TypeError,UnboundLocalError,UnicodeDecodeError,UnicodeEncodeError,UnicodeError,UnicodeTranslateError,UnicodeWarning,UserWarning,ValueError,Warning,ZeroDivisionError,_,__build_class__,__debug__,__doc__,__import__,__loader__,__name__,__package__,__spec__,abs,all,any,apply,ascii,basestring,bin,bool,buffer,bytearray,bytes,callable,chr,classmethod,cmp,coerce,compile,complex,copyright,credits,delattr,dict,dir,divmod,enumerate,eval,exec,execfile,exit,file,filter,float,format,frozenset,getattr,globals,hasattr,hash,help,hex,id,input,int,intern,isinstance,issubclass,iter,len,license,list,locals,long,map,max,memoryview,min,next,object,oct,open,ord,pow,print,property,quit,range,raw_input,reduce,reload,repr,reversed,round,set,setattr,slice,sorted,staticmethod,str,sum,super,tuple,type,unichr,unicode,vars,xrange,zip")}init(e){super.init(e),this.PASS=this.INDENT+"pass\n",this.nameDB_?this.nameDB_.reset():this.nameDB_=new i.Cj(this.RESERVED_WORDS_),this.nameDB_.setVariableMap(e.getVariableMap()),this.nameDB_.populateVariables(e),this.nameDB_.populateProcedures(e);var t=[],n=i.Cd(e);for(let e=0;e<n.length;e++)t.push(this.nameDB_.getName(n[e],i.Cj.DEVELOPER_VARIABLE_TYPE)+" = None");for(e=i.Bd(e),n=0;n<e.length;n++)t.push(this.getVariableName(e[n].getId())+" = None");this.definitions_.variables=t.join("\n"),this.isInitialized=!0}finish(e){var t=[],i=[];for(let e in this.definitions_){let n=this.definitions_[e];n.match(/^(from\s+\S+\s+)?import\s+\S+/)?t.push(n):i.push(n)}return e=super.finish(e),this.isInitialized=!1,this.nameDB_.reset(),(t.join("\n")+"\n\n"+i.join("\n\n")).replace(/\n\n+/g,"\n\n").replace(/\n*$/,"\n\n\n")+e}scrubNakedValue(e){return e+"\n"}quote_(e){var t="'";return(e=e.replace(/\\/g,"\\\\").replace(/\n/g,"\\\n")).includes("'")&&(e.includes('"')?e=e.replace(/'/g,"\\'"):t='"'),t+e+t}multiline_quote_(e){return e.split(/\n/g).map(this.quote_).join(" + '\\n' + \n")}scrub_(e,t,n=!1){var o="";if(!e.outputConnection||!e.outputConnection.targetConnection){var s=e.getCommentText();s&&(s=i.yf(s,this.COMMENT_WRAP-3),o+=this.prefixLines(s+"\n","# "));for(let t=0;t<e.inputList.length;t++)e.inputList[t].type===i.je.VALUE&&(s=e.inputList[t].connection.targetBlock())&&(s=this.allNestedComments(s))&&(o+=this.prefixLines(s,"# "))}return e=e.nextConnection&&e.nextConnection.targetBlock(),o+t+(n?"":this.blockToCode(e))}getAdjustedInt(e,n,o=0,s=!1){e.workspace.options.oneBasedIndex&&o--;var r=e.workspace.options.oneBasedIndex?"1":"0";return e=this.valueToCode(e,n,o?t.ADDITIVE:t.NONE)||r,i.zf(e)?(e=parseInt(e,10)+o,s&&(e=-e)):(e=o>0?"int("+e+" + "+o+")":o<0?"int("+e+" - "+-o+")":"int("+e+")",s&&(e="-"+e)),e}},p={};p.controls_if=n,p.controls_ifelse=n,p.logic_boolean=function(e){return["TRUE"===e.getFieldValue("BOOL")?"True":"False",t.ATOMIC]},p.logic_compare=function(e,i){var n={EQ:"==",NEQ:"!=",LT:"<",LTE:"<=",GT:">",GTE:">="}[e.getFieldValue("OP")],o=t.RELATIONAL;return[(i.valueToCode(e,"A",o)||"0")+" "+n+" "+(e=i.valueToCode(e,"B",o)||"0"),o]},p.logic_negate=function(e,i){return["not "+(i.valueToCode(e,"BOOL",t.LOGICAL_NOT)||"True"),t.LOGICAL_NOT]},p.logic_null=function(){return["None",t.ATOMIC]},p.logic_operation=function(e,i){var n="AND"===e.getFieldValue("OP")?"and":"or",o="and"===n?t.LOGICAL_AND:t.LOGICAL_OR,s=i.valueToCode(e,"A",o);return e=i.valueToCode(e,"B",o),s||e?(i="and"===n?"True":"False",s||(s=i),e||(e=i)):e=s="False",[s+" "+n+" "+e,o]},p.logic_ternary=function(e,i){var n=i.valueToCode(e,"IF",t.CONDITIONAL)||"False";return[(i.valueToCode(e,"THEN",t.CONDITIONAL)||"None")+" if "+n+" else "+(e=i.valueToCode(e,"ELSE",t.CONDITIONAL)||"None"),t.CONDITIONAL]};var g={controls_flow_statements:function(e,t){var i="";if(t.STATEMENT_PREFIX&&(i+=t.injectId(t.STATEMENT_PREFIX,e)),t.STATEMENT_SUFFIX&&(i+=t.injectId(t.STATEMENT_SUFFIX,e)),t.STATEMENT_PREFIX){let n=e.getSurroundLoop();n&&!n.suppressPrefixSuffix&&(i+=t.injectId(t.STATEMENT_PREFIX,n))}switch(e.getFieldValue("FLOW")){case"BREAK":return i+"break\n";case"CONTINUE":return i+"continue\n"}throw Error("Unknown flow statement.")},controls_for:function(e,n){function o(){return n.provideFunction_("downRange",`\ndef ${n.FUNCTION_NAME_PLACEHOLDER_}(start, stop, step):\n while start >= stop:\n yield start\n start -= abs(step)\n`)}function s(){return n.provideFunction_("upRange",`\ndef ${n.FUNCTION_NAME_PLACEHOLDER_}(start, stop, step):\n while start <= stop:\n yield start\n start += abs(step)\n`)}var r=n.getVariableName(e.getFieldValue("VAR")),a=n.valueToCode(e,"FROM",t.NONE)||"0",l=n.valueToCode(e,"TO",t.NONE)||"0",h=n.valueToCode(e,"BY",t.NONE)||"1",u=n.statementToCode(e,"DO");u=n.addLoopTrap(u,e)||n.PASS;var c="";return i.zf(a)&&i.zf(l)&&i.zf(h)?(a=Number(a),l=Number(l),h=Math.abs(Number(h)),a%1==0&&l%1==0&&h%1==0?(a<=l?(l++,e=0===a&&1===h?l:a+", "+l,1!==h&&(e+=", "+h)):e=a+", "+--l+", -"+h,e="range("+e+")"):(e=a<l?s():o(),e+="("+a+", "+l+", "+h+")")):(a=(e=function(e,t){return i.zf(e)?e=String(Number(e)):e.match(/^\w+$/)||(t=n.nameDB_.getDistinctName(r+t,i.P.VARIABLE),c+=t+" = "+e+"\n",e=t),e})(a,"_start"),l=e(l,"_end"),h=e(h,"_inc"),"number"==typeof a&&"number"==typeof l?(e=a<l?s():o(),e+="("+a+", "+l+", "+h+")"):e="("+a+" <= "+l+") and "+s()+"("+a+", "+l+", "+h+") or "+o()+"("+a+", "+l+", "+h+")"),c+="for "+r+" in "+e+":\n"+u},controls_forEach:function(e,i){var n=i.getVariableName(e.getFieldValue("VAR")),o=i.valueToCode(e,"LIST",t.RELATIONAL)||"[]",s=i.statementToCode(e,"DO");return"for "+n+" in "+o+":\n"+(i.addLoopTrap(s,e)||i.PASS)}};g.controls_repeat=o,g.controls_repeat_ext=o,g.controls_whileUntil=function(e,i){var n="UNTIL"===e.getFieldValue("MODE"),o=i.valueToCode(e,"BOOL",n?t.LOGICAL_NOT:t.NONE)||"False",s=i.statementToCode(e,"DO");return n&&(o="not "+o),"while "+o+":\n"+(i.addLoopTrap(s,e)||i.PASS)};var E={math_arithmetic:function(e,i){var n={ADD:[" + ",t.ADDITIVE],MINUS:[" - ",t.ADDITIVE],MULTIPLY:[" * ",t.MULTIPLICATIVE],DIVIDE:[" / ",t.MULTIPLICATIVE],POWER:[" ** ",t.EXPONENTIATION]}[e.getFieldValue("OP")],o=n[0];return n=n[1],[(i.valueToCode(e,"A",n)||"0")+o+(e=i.valueToCode(e,"B",n)||"0"),n]},math_atan2:function(e,i){i.definitions_.import_math="import math";var n=i.valueToCode(e,"X",t.NONE)||"0";return["math.atan2("+(i.valueToCode(e,"Y",t.NONE)||"0")+", "+n+") / math.pi * 180",t.MULTIPLICATIVE]},math_change:function(e,i){i.definitions_.from_numbers_import_Number="from numbers import Number";var n=i.valueToCode(e,"DELTA",t.ADDITIVE)||"0";return(e=i.getVariableName(e.getFieldValue("VAR")))+" = ("+e+" if isinstance("+e+", Number) else 0) + "+n+"\n"},math_constant:function(e,i){var n={PI:["math.pi",t.MEMBER],E:["math.e",t.MEMBER],GOLDEN_RATIO:["(1 + math.sqrt(5)) / 2",t.MULTIPLICATIVE],SQRT2:["math.sqrt(2)",t.MEMBER],SQRT1_2:["math.sqrt(1.0 / 2)",t.MEMBER],INFINITY:["float('inf')",t.ATOMIC]};return"INFINITY"!==(e=e.getFieldValue("CONSTANT"))&&(i.definitions_.import_math="import math"),n[e]},math_constrain:function(e,i){return["min(max("+(i.valueToCode(e,"VALUE",t.NONE)||"0")+", "+(i.valueToCode(e,"LOW",t.NONE)||"0")+"), "+(e=i.valueToCode(e,"HIGH",t.NONE)||"float('inf')")+")",t.FUNCTION_CALL]},math_modulo:function(e,i){return[(i.valueToCode(e,"DIVIDEND",t.MULTIPLICATIVE)||"0")+" % "+(e=i.valueToCode(e,"DIVISOR",t.MULTIPLICATIVE)||"0"),t.MULTIPLICATIVE]},math_number:function(e){return(e=Number(e.getFieldValue("NUM")))===1/0?['float("inf")',t.FUNCTION_CALL]:e===-1/0?['-float("inf")',t.UNARY_SIGN]:[String(e),e<0?t.UNARY_SIGN:t.ATOMIC]},math_number_property:function(e,i){var n={EVEN:[" % 2 == 0",t.MULTIPLICATIVE,t.RELATIONAL],ODD:[" % 2 == 1",t.MULTIPLICATIVE,t.RELATIONAL],WHOLE:[" % 1 == 0",t.MULTIPLICATIVE,t.RELATIONAL],POSITIVE:[" > 0",t.RELATIONAL,t.RELATIONAL],NEGATIVE:[" < 0",t.RELATIONAL,t.RELATIONAL],DIVISIBLE_BY:[null,t.MULTIPLICATIVE,t.RELATIONAL],PRIME:[null,t.NONE,t.FUNCTION_CALL]},o=e.getFieldValue("PROPERTY"),[s,r,a]=n[o];if(n=i.valueToCode(e,"NUMBER_TO_CHECK",r)||"0","PRIME"===o)i.definitions_.import_math="import math",i.definitions_.from_numbers_import_Number="from numbers import Number",e=i.provideFunction_("math_isPrime",`\ndef ${i.FUNCTION_NAME_PLACEHOLDER_}(n):\n # https://en.wikipedia.org/wiki/Primality_test#Naive_methods\n # If n is not a number but a string, try parsing it.\n if not isinstance(n, Number):\n try:\n n = float(n)\n except:\n return False\n if n == 2 or n == 3:\n return True\n # False if n is negative, is 1, or not whole, or if n is divisible by 2 or 3.\n if n <= 1 or n % 1 != 0 or n % 2 == 0 or n % 3 == 0:\n return False\n # Check all the numbers of form 6k +/- 1, up to sqrt(n).\n for x in range(6, int(math.sqrt(n)) + 2, 6):\n if n % (x - 1) == 0 or n % (x + 1) == 0:\n return False\n return True\n`)+"("+n+")";else if("DIVISIBLE_BY"===o){if("0"===(e=i.valueToCode(e,"DIVISOR",t.MULTIPLICATIVE)||"0"))return["False",t.ATOMIC];e=n+" % "+e+" == 0"}else e=n+s;return[e,a]},math_on_list:function(e,i){var n=e.getFieldValue("OP");switch(e=i.valueToCode(e,"LIST",t.NONE)||"[]",n){case"SUM":i="sum("+e+")";break;case"MIN":i="min("+e+")";break;case"MAX":i="max("+e+")";break;case"AVERAGE":i.definitions_.from_numbers_import_Number="from numbers import Number",i=i.provideFunction_("math_mean",`\ndef ${i.FUNCTION_NAME_PLACEHOLDER_}(myList):\n localList = [e for e in myList if isinstance(e, Number)]\n if not localList: return\n return float(sum(localList)) / len(localList)\n`)+"("+e+")";break;case"MEDIAN":i.definitions_.from_numbers_import_Number="from numbers import Number",i=i.provideFunction_("math_median",`\ndef ${i.FUNCTION_NAME_PLACEHOLDER_}(myList):\n localList = sorted([e for e in myList if isinstance(e, Number)])\n if not localList: return\n if len(localList) % 2 == 0:\n return (localList[len(localList) // 2 - 1] + localList[len(localList) // 2]) / 2.0\n else:\n return localList[(len(localList) - 1) // 2]\n`)+"("+e+")";break;case"MODE":i=i.provideFunction_("math_modes",`\ndef ${i.FUNCTION_NAME_PLACEHOLDER_}(some_list):\n modes = []\n # Using a lists of [item, count] to keep count rather than dict\n # to avoid "unhashable" errors when the counted item is itself a list or dict.\n counts = []\n maxCount = 1\n for item in some_list:\n found = False\n for count in counts:\n if count[0] == item:\n count[1] += 1\n maxCount = max(maxCount, count[1])\n found = True\n if not found:\n counts.append([item, 1])\n for counted_item, item_count in counts:\n if item_count == maxCount:\n modes.append(counted_item)\n return modes\n`)+"("+e+")";break;case"STD_DEV":i.definitions_.import_math="import math",i=i.provideFunction_("math_standard_deviation",`\ndef ${i.FUNCTION_NAME_PLACEHOLDER_}(numbers):\n n = len(numbers)\n if n == 0: return\n mean = float(sum(numbers)) / n\n variance = sum((x - mean) ** 2 for x in numbers) / n\n return math.sqrt(variance)\n`)+"("+e+")";break;case"RANDOM":i.definitions_.import_random="import random",i="random.choice("+e+")";break;default:throw Error("Unknown operator: "+n)}return[i,t.FUNCTION_CALL]},math_random_float:function(e,i){return i.definitions_.import_random="import random",["random.random()",t.FUNCTION_CALL]},math_random_int:function(e,i){return i.definitions_.import_random="import random",["random.randint("+(i.valueToCode(e,"FROM",t.NONE)||"0")+", "+(e=i.valueToCode(e,"TO",t.NONE)||"0")+")",t.FUNCTION_CALL]}};E.math_round=s,E.math_single=s,E.math_trig=s;var T={procedures_callnoreturn:function(e,t){return t.forBlock.procedures_callreturn(e,t)[0]+"\n"},procedures_callreturn:function(e,i){var n=i.getProcedureName(e.getFieldValue("NAME")),o=[],s=e.getVarModels();for(let n=0;n<s.length;n++)o[n]=i.valueToCode(e,"ARG"+n,t.NONE)||"None";return[n+"("+o.join(", ")+")",t.FUNCTION_CALL]}};T.procedures_defnoreturn=r,T.procedures_defreturn=r,T.procedures_ifreturn=function(e,i){var n="if "+(i.valueToCode(e,"CONDITION",t.NONE)||"False")+":\n";return i.STATEMENT_SUFFIX&&(n+=i.prefixLines(i.injectId(i.STATEMENT_SUFFIX,e),i.INDENT)),e.hasReturnValue_?(e=i.valueToCode(e,"VALUE",t.NONE)||"None",n+=i.INDENT+"return "+e+"\n"):n+=i.INDENT+"return\n",n};var _=/^\s*'([^']|\\')*'\s*$/,f={text:function(e,i){return[i.quote_(e.getFieldValue("TEXT")),t.ATOMIC]},text_append:function(e,i){var n=i.getVariableName(e.getFieldValue("VAR"));return e=i.valueToCode(e,"TEXT",t.NONE)||"''",n+" = str("+n+") + "+a(e)[0]+"\n"},text_changeCase:function(e,i){var n={UPPERCASE:".upper()",LOWERCASE:".lower()",TITLECASE:".title()"}[e.getFieldValue("CASE")];return[(i.valueToCode(e,"TEXT",t.MEMBER)||"''")+n,t.FUNCTION_CALL]},text_charAt:function(e,i){var n=e.getFieldValue("WHERE")||"FROM_START",o=i.valueToCode(e,"VALUE","RANDOM"===n?t.NONE:t.MEMBER)||"''";switch(n){case"FIRST":return[o+"[0]",t.MEMBER];case"LAST":return[o+"[-1]",t.MEMBER];case"FROM_START":return[o+"["+(e=i.getAdjustedInt(e,"AT"))+"]",t.MEMBER];case"FROM_END":return[o+"["+(e=i.getAdjustedInt(e,"AT",1,!0))+"]",t.MEMBER];case"RANDOM":return i.definitions_.import_random="import random",[i.provideFunction_("text_random_letter",`\ndef ${i.FUNCTION_NAME_PLACEHOLDER_}(text):\n x = int(random.random() * len(text))\n return text[x]\n`)+"("+o+")",t.FUNCTION_CALL]}throw Error("Unhandled option (text_charAt).")},text_count:function(e,i){return[(i.valueToCode(e,"TEXT",t.MEMBER)||"''")+".count("+(e=i.valueToCode(e,"SUB",t.NONE)||"''")+")",t.FUNCTION_CALL]},text_getSubstring:function(e,n){var o=e.getFieldValue("WHERE1"),s=e.getFieldValue("WHERE2"),r=n.valueToCode(e,"STRING",t.MEMBER)||"''";switch(o){case"FROM_START":0===(o=n.getAdjustedInt(e,"AT1"))&&(o="");break;case"FROM_END":o=n.getAdjustedInt(e,"AT1",1,!0);break;case"FIRST":o="";break;default:throw Error("Unhandled option (text_getSubstring)")}switch(s){case"FROM_START":e=n.getAdjustedInt(e,"AT2",1);break;case"FROM_END":e=n.getAdjustedInt(e,"AT2",0,!0),i.zf(String(e))?0===e&&(e=""):(n.definitions_.import_sys="import sys",e+=" or sys.maxsize");break;case"LAST":e="";break;default:throw Error("Unhandled option (text_getSubstring)")}return[r+"["+o+" : "+e+"]",t.MEMBER]},text_indexOf:function(e,i){var n="FIRST"===e.getFieldValue("END")?"find":"rfind",o=i.valueToCode(e,"FIND",t.NONE)||"''";return i=(i.valueToCode(e,"VALUE",t.MEMBER)||"''")+"."+n+"("+o+")",e.workspace.options.oneBasedIndex?[i+" + 1",t.ADDITIVE]:[i,t.FUNCTION_CALL]},text_isEmpty:function(e,i){return["not len("+(i.valueToCode(e,"VALUE",t.NONE)||"''")+")",t.LOGICAL_NOT]},text_join:function(e,n){switch(e.itemCount_){case 0:return["''",t.ATOMIC];case 1:return e=n.valueToCode(e,"ADD0",t.NONE)||"''",a(e);case 2:var o=n.valueToCode(e,"ADD0",t.NONE)||"''";return e=n.valueToCode(e,"ADD1",t.NONE)||"''",[a(o)[0]+" + "+a(e)[0],t.ADDITIVE];default:o=[];for(let i=0;i<e.itemCount_;i++)o[i]=n.valueToCode(e,"ADD"+i,t.NONE)||"''";return["''.join([str("+(e=n.nameDB_.getDistinctName("x",i.P.VARIABLE))+") for "+e+" in ["+o.join(", ")+"]])",t.FUNCTION_CALL]}},text_length:function(e,i){return["len("+(i.valueToCode(e,"VALUE",t.NONE)||"''")+")",t.FUNCTION_CALL]},text_print:function(e,i){return"print("+(i.valueToCode(e,"TEXT",t.NONE)||"''")+")\n"}};f.text_prompt=l,f.text_prompt_ext=l,f.text_replace=function(e,i){return[(i.valueToCode(e,"TEXT",t.MEMBER)||"''")+".replace("+(i.valueToCode(e,"FROM",t.NONE)||"''")+", "+(e=i.valueToCode(e,"TO",t.NONE)||"''")+")",t.MEMBER]},f.text_reverse=function(e,i){return[(i.valueToCode(e,"TEXT",t.MEMBER)||"''")+"[::-1]",t.MEMBER]},f.text_trim=function(e,i){var n={LEFT:".lstrip()",RIGHT:".rstrip()",BOTH:".strip()"}[e.getFieldValue("MODE")];return[(i.valueToCode(e,"TEXT",t.MEMBER)||"''")+n,t.FUNCTION_CALL]};var m={};m.variables_get=h,m.variables_set=u;var b={};b.variables_get_dynamic=h,b.variables_set_dynamic=u;var C=new d;C.addReservedWords("math,random,Number");var v=Object.assign({},{lists_create_empty:function(){return["[]",t.ATOMIC]},lists_create_with:function(e,i){var n=Array(e.itemCount_);for(let o=0;o<e.itemCount_;o++)n[o]=i.valueToCode(e,"ADD"+o,t.NONE)||"None";return["["+n.join(", ")+"]",t.ATOMIC]},lists_getIndex:function(e,i){var n=e.getFieldValue("MODE")||"GET",o=e.getFieldValue("WHERE")||"FROM_START",s=i.valueToCode(e,"VALUE","RANDOM"===o?t.NONE:t.MEMBER)||"[]";switch(o){case"FIRST":if("GET"===n)return[s+"[0]",t.MEMBER];if("GET_REMOVE"===n)return[s+".pop(0)",t.FUNCTION_CALL];if("REMOVE"===n)return s+".pop(0)\n";break;case"LAST":if("GET"===n)return[s+"[-1]",t.MEMBER];if("GET_REMOVE"===n)return[s+".pop()",t.FUNCTION_CALL];if("REMOVE"===n)return s+".pop()\n";break;case"FROM_START":if(e=i.getAdjustedInt(e,"AT"),"GET"===n)return[s+"["+e+"]",t.MEMBER];if("GET_REMOVE"===n)return[s+".pop("+e+")",t.FUNCTION_CALL];if("REMOVE"===n)return s+".pop("+e+")\n";break;case"FROM_END":if(e=i.getAdjustedInt(e,"AT",1,!0),"GET"===n)return[s+"["+e+"]",t.MEMBER];if("GET_REMOVE"===n)return[s+".pop("+e+")",t.FUNCTION_CALL];if("REMOVE"===n)return s+".pop("+e+")\n";break;case"RANDOM":if(i.definitions_.import_random="import random","GET"===n)return["random.choice("+s+")",t.FUNCTION_CALL];if(s=i.provideFunction_("lists_remove_random_item",`\ndef ${i.FUNCTION_NAME_PLACEHOLDER_}(myList):\n x = int(random.random() * len(myList))\n return myList.pop(x)\n`)+"("+s+")","GET_REMOVE"===n)return[s,t.FUNCTION_CALL];if("REMOVE"===n)return s+"\n"}throw Error("Unhandled combination (lists_getIndex).")},lists_getSublist:function(e,n){var o=n.valueToCode(e,"LIST",t.MEMBER)||"[]",s=e.getFieldValue("WHERE1"),r=e.getFieldValue("WHERE2");switch(s){case"FROM_START":0===(s=n.getAdjustedInt(e,"AT1"))&&(s="");break;case"FROM_END":s=n.getAdjustedInt(e,"AT1",1,!0);break;case"FIRST":s="";break;default:throw Error("Unhandled option (lists_getSublist)")}switch(r){case"FROM_START":e=n.getAdjustedInt(e,"AT2",1);break;case"FROM_END":e=n.getAdjustedInt(e,"AT2",0,!0),i.zf(String(e))?0===e&&(e=""):(n.definitions_.import_sys="import sys",e+=" or sys.maxsize");break;case"LAST":e="";break;default:throw Error("Unhandled option (lists_getSublist)")}return[o+"["+s+" : "+e+"]",t.MEMBER]},lists_indexOf:function(e,i){var n=i.valueToCode(e,"FIND",t.NONE)||"[]",o=i.valueToCode(e,"VALUE",t.NONE)||"''",s=" -1",r="",a=" - 1";return e.workspace.options.oneBasedIndex&&(s=" 0",r=" + 1",a=""),[("FIRST"===e.getFieldValue("END")?i.provideFunction_("first_index",`\ndef ${i.FUNCTION_NAME_PLACEHOLDER_}(my_list, elem):\n try: index = my_list.index(elem)${r}\n except: index =${s}\n return index\n`):i.provideFunction_("last_index",`\ndef ${i.FUNCTION_NAME_PLACEHOLDER_}(my_list, elem):\n try: index = len(my_list) - my_list[::-1].index(elem)${a}\n except: index =${s}\n return index\n`))+"("+o+", "+n+")",t.FUNCTION_CALL]},lists_isEmpty:function(e,i){return["not len("+(i.valueToCode(e,"VALUE",t.NONE)||"[]")+")",t.LOGICAL_NOT]},lists_length:function(e,i){return["len("+(i.valueToCode(e,"VALUE",t.NONE)||"[]")+")",t.FUNCTION_CALL]},lists_repeat:function(e,i){return["["+(i.valueToCode(e,"ITEM",t.NONE)||"None")+"] * "+(e=i.valueToCode(e,"NUM",t.MULTIPLICATIVE)||"0"),t.MULTIPLICATIVE]},lists_reverse:function(e,i){return["list(reversed("+(i.valueToCode(e,"LIST",t.NONE)||"[]")+"))",t.FUNCTION_CALL]},lists_setIndex:function(e,n){var o=n.valueToCode(e,"LIST",t.MEMBER)||"[]",s=e.getFieldValue("MODE")||"GET",r=e.getFieldValue("WHERE")||"FROM_START",a=n.valueToCode(e,"TO",t.NONE)||"None";switch(r){case"FIRST":if("SET"===s)return o+"[0] = "+a+"\n";if("INSERT"===s)return o+".insert(0, "+a+")\n";break;case"LAST":if("SET"===s)return o+"[-1] = "+a+"\n";if("INSERT"===s)return o+".append("+a+")\n";break;case"FROM_START":if(n=n.getAdjustedInt(e,"AT"),"SET"===s)return o+"["+n+"] = "+a+"\n";if("INSERT"===s)return o+".insert("+n+", "+a+")\n";break;case"FROM_END":if(n=n.getAdjustedInt(e,"AT",1,!0),"SET"===s)return o+"["+n+"] = "+a+"\n";if("INSERT"===s)return o+".insert("+n+", "+a+")\n";break;case"RANDOM":if(n.definitions_.import_random="import random",o.match(/^\w+$/)?e="":(r=(e=n.nameDB_.getDistinctName("tmp_list",i.P.VARIABLE))+" = "+o+"\n",o=e,e=r),e+=(n=n.nameDB_.getDistinctName("tmp_x",i.P.VARIABLE))+" = int(random.random() * len("+o+"))\n","SET"===s)return e+(o+"[")+n+"] = "+a+"\n";if("INSERT"===s)return e+(o+".insert(")+n+", "+a+")\n"}throw Error("Unhandled combination (lists_setIndex).")},lists_sort:function(e,i){var n=i.valueToCode(e,"LIST",t.NONE)||"[]",o=e.getFieldValue("TYPE");return e="1"===e.getFieldValue("DIRECTION")?"False":"True",[i.provideFunction_("lists_sort",`\ndef ${i.FUNCTION_NAME_PLACEHOLDER_}(my_list, type, reverse):\n def try_float(s):\n try:\n return float(s)\n except:\n return 0\n key_funcs = {\n "NUMERIC": try_float,\n "TEXT": str,\n "IGNORE_CASE": lambda s: str(s).lower()\n }\n key_func = key_funcs[type]\n list_cpy = list(my_list)\n return sorted(list_cpy, key=key_func, reverse=reverse)\n`)+"("+n+', "'+o+'", '+e+")",t.FUNCTION_CALL]},lists_split:function(e,i){var n=e.getFieldValue("MODE");if("SPLIT"===n)e=(n=i.valueToCode(e,"INPUT",t.MEMBER)||"''")+".split("+(e=i.valueToCode(e,"DELIM",t.NONE))+")";else{if("JOIN"!==n)throw Error("Unknown mode: "+n);n=i.valueToCode(e,"INPUT",t.NONE)||"[]",e=(i.valueToCode(e,"DELIM",t.MEMBER)||"''")+".join("+n+")"}return[e,t.FUNCTION_CALL]}},p,g,E,T,f,m,b);for(let e in v)C.forBlock[e]=v[e];var I={};return I.Order=t,I.PythonGenerator=d,I.pythonGenerator=C,i.__chunk_python=I,i.__chunk_python.__namespace__=i,i.__chunk_python})?n.apply(t,o):n)||(e.exports=s)}},t={};function i(n){var o=t[n];if(void 0!==o)return o.exports;var s=t[n]={exports:{}};return e[n].call(s.exports,s,s.exports,i),s.exports}i.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}();var n={};(()=>{"use strict";var e=n;Object.defineProperty(e,"__esModule",{value:!0}),e.sparqlToBlockly=function(e){var i;const n=new s.Parser({sparqlStar:!0}).parse(e);return null===(i=(new t.default).visit(n))||void 0===i?void 0:i.xml},e.blocklyToSparql=function(e){return(new o.default).blockToCode(e)},i(653);const t=i(670),o=i(128),s=i(82)})(),window.SparqlBlockly=n})();