mirror of https://github.com/facebook/jest.git
53 lines
186 KiB
JavaScript
53 lines
186 KiB
JavaScript
/* eslint-disable */
|
|
//prettier-ignore
|
|
module.exports = {
|
|
name: "@yarnpkg/plugin-constraints",
|
|
factory: function (require) {
|
|
var plugin=(()=>{var zi=Object.create;var Je=Object.defineProperty;var Wi=Object.getOwnPropertyDescriptor;var Li=Object.getOwnPropertyNames;var Hi=Object.getPrototypeOf,Yi=Object.prototype.hasOwnProperty;var G=(r=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(r,{get:(l,f)=>(typeof require<"u"?require:l)[f]}):r)(function(r){if(typeof require<"u")return require.apply(this,arguments);throw new Error('Dynamic require of "'+r+'" is not supported')});var C=(r,l)=>()=>(l||r((l={exports:{}}).exports,l),l.exports),Gi=(r,l)=>{for(var f in l)Je(r,f,{get:l[f],enumerable:!0})},Br=(r,l,f,c)=>{if(l&&typeof l=="object"||typeof l=="function")for(let w of Li(l))!Yi.call(r,w)&&w!==f&&Je(r,w,{get:()=>l[w],enumerable:!(c=Wi(l,w))||c.enumerable});return r};var _e=(r,l,f)=>(f=r!=null?zi(Hi(r)):{},Br(l||!r||!r.__esModule?Je(f,"default",{value:r,enumerable:!0}):f,r)),Ui=r=>Br(Je({},"__esModule",{value:!0}),r);var Fr=C((Cu,_r)=>{var Zi;(function(r){var l=function(){return{"append/2":[new r.type.Rule(new r.type.Term("append",[new r.type.Var("X"),new r.type.Var("L")]),new r.type.Term("foldl",[new r.type.Term("append",[]),new r.type.Var("X"),new r.type.Term("[]",[]),new r.type.Var("L")]))],"append/3":[new r.type.Rule(new r.type.Term("append",[new r.type.Term("[]",[]),new r.type.Var("X"),new r.type.Var("X")]),null),new r.type.Rule(new r.type.Term("append",[new r.type.Term(".",[new r.type.Var("H"),new r.type.Var("T")]),new r.type.Var("X"),new r.type.Term(".",[new r.type.Var("H"),new r.type.Var("S")])]),new r.type.Term("append",[new r.type.Var("T"),new r.type.Var("X"),new r.type.Var("S")]))],"member/2":[new r.type.Rule(new r.type.Term("member",[new r.type.Var("X"),new r.type.Term(".",[new r.type.Var("X"),new r.type.Var("_")])]),null),new r.type.Rule(new r.type.Term("member",[new r.type.Var("X"),new r.type.Term(".",[new r.type.Var("_"),new r.type.Var("Xs")])]),new r.type.Term("member",[new r.type.Var("X"),new r.type.Var("Xs")]))],"permutation/2":[new r.type.Rule(new r.type.Term("permutation",[new r.type.Term("[]",[]),new r.type.Term("[]",[])]),null),new r.type.Rule(new r.type.Term("permutation",[new r.type.Term(".",[new r.type.Var("H"),new r.type.Var("T")]),new r.type.Var("S")]),new r.type.Term(",",[new r.type.Term("permutation",[new r.type.Var("T"),new r.type.Var("P")]),new r.type.Term(",",[new r.type.Term("append",[new r.type.Var("X"),new r.type.Var("Y"),new r.type.Var("P")]),new r.type.Term("append",[new r.type.Var("X"),new r.type.Term(".",[new r.type.Var("H"),new r.type.Var("Y")]),new r.type.Var("S")])])]))],"maplist/2":[new r.type.Rule(new r.type.Term("maplist",[new r.type.Var("_"),new r.type.Term("[]",[])]),null),new r.type.Rule(new r.type.Term("maplist",[new r.type.Var("P"),new r.type.Term(".",[new r.type.Var("X"),new r.type.Var("Xs")])]),new r.type.Term(",",[new r.type.Term("call",[new r.type.Var("P"),new r.type.Var("X")]),new r.type.Term("maplist",[new r.type.Var("P"),new r.type.Var("Xs")])]))],"maplist/3":[new r.type.Rule(new r.type.Term("maplist",[new r.type.Var("_"),new r.type.Term("[]",[]),new r.type.Term("[]",[])]),null),new r.type.Rule(new r.type.Term("maplist",[new r.type.Var("P"),new r.type.Term(".",[new r.type.Var("A"),new r.type.Var("As")]),new r.type.Term(".",[new r.type.Var("B"),new r.type.Var("Bs")])]),new r.type.Term(",",[new r.type.Term("call",[new r.type.Var("P"),new r.type.Var("A"),new r.type.Var("B")]),new r.type.Term("maplist",[new r.type.Var("P"),new r.type.Var("As"),new r.type.Var("Bs")])]))],"maplist/4":[new r.type.Rule(new r.type.Term("maplist",[new r.type.Var("_"),new r.type.Term("[]",[]),new r.type.Term("[]",[]),new r.type.Term("[]",[])]),null),new r.type.Rule(new r.type.Term("maplist",[new r.type.Var("P"),new r.type.Term(".",[new r.type.Var("A"),new r.type.Var("As")]),new r.type.Term(".",[new r.type.Var("B"),new r.type.Var("Bs")]),new r.type.Term(".",[new r.type.Var("C"),new r.type.Var("Cs")])]),new r.type.Term(",",[new r.type.Term("call",[new r.type.Var("P"),new r.type.Var("A"),new r.type.Var("B"),new r.type.Var("C")]),new r.type.Term("maplist",[new r.type.Var("P"),new r.type.Var("As"),new r.type.Var("Bs"),new r.type.Var("Cs")])]))],"maplist/5":[new r.type.Rule(new r.type.Term("maplist",[new r.type.Var("_"),new r.type.Term("[]",[]),new r.type.Term("[]",[]),new r.type.Term("[]",[]),new r.type.Term("[]",[])]),null),new r.type.Rule(new r.type.Term("maplist",[new r.type.Var("P"),new r.type.Term(".",[new r.type.Var("A"),new r.type.Var("As")]),new r.type.Term(".",[new r.type.Var("B"),new r.type.Var("Bs")]),new r.type.Term(".",[new r.type.Var("C"),new r.type.Var("Cs")]),new r.type.Term(".",[new r.type.Var("D"),new r.type.Var("Ds")])]),new r.type.Term(",",[new r.type.Term("call",[new r.type.Var("P"),new r.type.Var("A"),new r.type.Var("B"),new r.type.Var("C"),new r.type.Var("D")]),new r.type.Term("maplist",[new r.type.Var("P"),new r.type.Var("As"),new r.type.Var("Bs"),new r.type.Var("Cs"),new r.type.Var("Ds")])]))],"maplist/6":[new r.type.Rule(new r.type.Term("maplist",[new r.type.Var("_"),new r.type.Term("[]",[]),new r.type.Term("[]",[]),new r.type.Term("[]",[]),new r.type.Term("[]",[]),new r.type.Term("[]",[])]),null),new r.type.Rule(new r.type.Term("maplist",[new r.type.Var("P"),new r.type.Term(".",[new r.type.Var("A"),new r.type.Var("As")]),new r.type.Term(".",[new r.type.Var("B"),new r.type.Var("Bs")]),new r.type.Term(".",[new r.type.Var("C"),new r.type.Var("Cs")]),new r.type.Term(".",[new r.type.Var("D"),new r.type.Var("Ds")]),new r.type.Term(".",[new r.type.Var("E"),new r.type.Var("Es")])]),new r.type.Term(",",[new r.type.Term("call",[new r.type.Var("P"),new r.type.Var("A"),new r.type.Var("B"),new r.type.Var("C"),new r.type.Var("D"),new r.type.Var("E")]),new r.type.Term("maplist",[new r.type.Var("P"),new r.type.Var("As"),new r.type.Var("Bs"),new r.type.Var("Cs"),new r.type.Var("Ds"),new r.type.Var("Es")])]))],"maplist/7":[new r.type.Rule(new r.type.Term("maplist",[new r.type.Var("_"),new r.type.Term("[]",[]),new r.type.Term("[]",[]),new r.type.Term("[]",[]),new r.type.Term("[]",[]),new r.type.Term("[]",[]),new r.type.Term("[]",[])]),null),new r.type.Rule(new r.type.Term("maplist",[new r.type.Var("P"),new r.type.Term(".",[new r.type.Var("A"),new r.type.Var("As")]),new r.type.Term(".",[new r.type.Var("B"),new r.type.Var("Bs")]),new r.type.Term(".",[new r.type.Var("C"),new r.type.Var("Cs")]),new r.type.Term(".",[new r.type.Var("D"),new r.type.Var("Ds")]),new r.type.Term(".",[new r.type.Var("E"),new r.type.Var("Es")]),new r.type.Term(".",[new r.type.Var("F"),new r.type.Var("Fs")])]),new r.type.Term(",",[new r.type.Term("call",[new r.type.Var("P"),new r.type.Var("A"),new r.type.Var("B"),new r.type.Var("C"),new r.type.Var("D"),new r.type.Var("E"),new r.type.Var("F")]),new r.type.Term("maplist",[new r.type.Var("P"),new r.type.Var("As"),new r.type.Var("Bs"),new r.type.Var("Cs"),new r.type.Var("Ds"),new r.type.Var("Es"),new r.type.Var("Fs")])]))],"maplist/8":[new r.type.Rule(new r.type.Term("maplist",[new r.type.Var("_"),new r.type.Term("[]",[]),new r.type.Term("[]",[]),new r.type.Term("[]",[]),new r.type.Term("[]",[]),new r.type.Term("[]",[]),new r.type.Term("[]",[]),new r.type.Term("[]",[])]),null),new r.type.Rule(new r.type.Term("maplist",[new r.type.Var("P"),new r.type.Term(".",[new r.type.Var("A"),new r.type.Var("As")]),new r.type.Term(".",[new r.type.Var("B"),new r.type.Var("Bs")]),new r.type.Term(".",[new r.type.Var("C"),new r.type.Var("Cs")]),new r.type.Term(".",[new r.type.Var("D"),new r.type.Var("Ds")]),new r.type.Term(".",[new r.type.Var("E"),new r.type.Var("Es")]),new r.type.Term(".",[new r.type.Var("F"),new r.type.Var("Fs")]),new r.type.Term(".",[new r.type.Var("G"),new r.type.Var("Gs")])]),new r.type.Term(",",[new r.type.Term("call",[new r.type.Var("P"),new r.type.Var("A"),new r.type.Var("B"),new r.type.Var("C"),new r.type.Var("D"),new r.type.Var("E"),new r.type.Var("F"),new r.type.Var("G")]),new r.type.Term("maplist",[new r.type.Var("P"),new r.type.Var("As"),new r.type.Var("Bs"),new r.type.Var("Cs"),new r.type.Var("Ds"),new r.type.Var("Es"),new r.type.Var("Fs"),new r.type.Var("Gs")])]))],"include/3":[new r.type.Rule(new r.type.Term("include",[new r.type.Var("_"),new r.type.Term("[]",[]),new r.type.Term("[]",[])]),null),new r.type.Rule(new r.type.Term("include",[new r.type.Var("P"),new r.type.Term(".",[new r.type.Var("H"),new r.type.Var("T")]),new r.type.Var("L")]),new r.type.Term(",",[new r.type.Term("=..",[new r.type.Var("P"),new r.type.Var("A")]),new r.type.Term(",",[new r.type.Term("append",[new r.type.Var("A"),new r.type.Term(".",[new r.type.Var("H"),new r.type.Term("[]",[])]),new r.type.Var("B")]),new r.type.Term(",",[new r.type.Term("=..",[new r.type.Var("F"),new r.type.Var("B")]),new r.type.Term(",",[new r.type.Term(";",[new r.type.Term(",",[new r.type.Term("call",[new r.type.Var("F")]),new r.type.Term(",",[new r.type.Term("=",[new r.type.Var("L"),new r.type.Term(".",[new r.type.Var("H"),new r.type.Var("S")])]),new r.type.Term("!",[])])]),new r.type.Term("=",[new r.type.Var("L"),new r.type.Var("S")])]),new r.type.Term("include",[new r.type.Var("P"),new r.type.Var("T"),new r.type.Var("S")])])])])]))],"exclude/3":[new r.type.Rule(new r.type.Term("exclude",[new r.type.Var("_"),new r.type.Term("[]",[]),new r.type.Term("[]",[])]),null),new r.type.Rule(new r.type.Term("exclude",[new r.type.Var("P"),new r.type.Term(".",[new r.type.Var("H"),new r.type.Var("T")]),new r.type.Var("S")]),new r.type.Term(",",[new r.type.Term("exclude",[new r.type.Var("P"),new r.type.Var("T"),new r.type.Var("E")]),new r.type.Term(",",[new r.type.Term("=..",[new r.type.Var("P"),new r.type.Var("L")]),new r.type.Term(",",[new r.type.Term("append",[new r.type.Var("L"),new r.type.Term(".",[new r.type.Var("H"),new r.type.Term("[]",[])]),new r.type.Var("Q")]),new r.type.Term(",",[new r.type.Term("=..",[new r.type.Var("R"),new r.type.Var("Q")]),new r.type.Term(";",[new r.type.Term(",",[new r.type.Term("call",[new r.type.Var("R")]),new r.type.Term(",",[new r.type.Term("!",[]),new r.type.Term("=",[new r.type.Var("S"),new r.type.Var("E")])])]),new r.type.Term("=",[new r.type.Var("S"),new r.type.Term(".",[new r.type.Var("H"),new r.type.Var("E")])])])])])])]))],"foldl/4":[new r.type.Rule(new r.type.Term("foldl",[new r.type.Var("_"),new r.type.Term("[]",[]),new r.type.Var("I"),new r.type.Var("I")]),null),new r.type.Rule(new r.type.Term("foldl",[new r.type.Var("P"),new r.type.Term(".",[new r.type.Var("H"),new r.type.Var("T")]),new r.type.Var("I"),new r.type.Var("R")]),new r.type.Term(",",[new r.type.Term("=..",[new r.type.Var("P"),new r.type.Var("L")]),new r.type.Term(",",[new r.type.Term("append",[new r.type.Var("L"),new r.type.Term(".",[new r.type.Var("I"),new r.type.Term(".",[new r.type.Var("H"),new r.type.Term(".",[new r.type.Var("X"),new r.type.Term("[]",[])])])]),new r.type.Var("L2")]),new r.type.Term(",",[new r.type.Term("=..",[new r.type.Var("P2"),new r.type.Var("L2")]),new r.type.Term(",",[new r.type.Term("call",[new r.type.Var("P2")]),new r.type.Term("foldl",[new r.type.Var("P"),new r.type.Var("T"),new r.type.Var("X"),new r.type.Var("R")])])])])]))],"select/3":[new r.type.Rule(new r.type.Term("select",[new r.type.Var("E"),new r.type.Term(".",[new r.type.Var("E"),new r.type.Var("Xs")]),new r.type.Var("Xs")]),null),new r.type.Rule(new r.type.Term("select",[new r.type.Var("E"),new r.type.Term(".",[new r.type.Var("X"),new r.type.Var("Xs")]),new r.type.Term(".",[new r.type.Var("X"),new r.type.Var("Ys")])]),new r.type.Term("select",[new r.type.Var("E"),new r.type.Var("Xs"),new r.type.Var("Ys")]))],"sum_list/2":[new r.type.Rule(new r.type.Term("sum_list",[new r.type.Term("[]",[]),new r.type.Num(0,!1)]),null),new r.type.Rule(new r.type.Term("sum_list",[new r.type.Term(".",[new r.type.Var("X"),new r.type.Var("Xs")]),new r.type.Var("S")]),new r.type.Term(",",[new r.type.Term("sum_list",[new r.type.Var("Xs"),new r.type.Var("Y")]),new r.type.Term("is",[new r.type.Var("S"),new r.type.Term("+",[new r.type.Var("X"),new r.type.Var("Y")])])]))],"max_list/2":[new r.type.Rule(new r.type.Term("max_list",[new r.type.Term(".",[new r.type.Var("X"),new r.type.Term("[]",[])]),new r.type.Var("X")]),null),new r.type.Rule(new r.type.Term("max_list",[new r.type.Term(".",[new r.type.Var("X"),new r.type.Var("Xs")]),new r.type.Var("S")]),new r.type.Term(",",[new r.type.Term("max_list",[new r.type.Var("Xs"),new r.type.Var("Y")]),new r.type.Term(";",[new r.type.Term(",",[new r.type.Term(">=",[new r.type.Var("X"),new r.type.Var("Y")]),new r.type.Term(",",[new r.type.Term("=",[new r.type.Var("S"),new r.type.Var("X")]),new r.type.Term("!",[])])]),new r.type.Term("=",[new r.type.Var("S"),new r.type.Var("Y")])])]))],"min_list/2":[new r.type.Rule(new r.type.Term("min_list",[new r.type.Term(".",[new r.type.Var("X"),new r.type.Term("[]",[])]),new r.type.Var("X")]),null),new r.type.Rule(new r.type.Term("min_list",[new r.type.Term(".",[new r.type.Var("X"),new r.type.Var("Xs")]),new r.type.Var("S")]),new r.type.Term(",",[new r.type.Term("min_list",[new r.type.Var("Xs"),new r.type.Var("Y")]),new r.type.Term(";",[new r.type.Term(",",[new r.type.Term("=<",[new r.type.Var("X"),new r.type.Var("Y")]),new r.type.Term(",",[new r.type.Term("=",[new r.type.Var("S"),new r.type.Var("X")]),new r.type.Term("!",[])])]),new r.type.Term("=",[new r.type.Var("S"),new r.type.Var("Y")])])]))],"prod_list/2":[new r.type.Rule(new r.type.Term("prod_list",[new r.type.Term("[]",[]),new r.type.Num(1,!1)]),null),new r.type.Rule(new r.type.Term("prod_list",[new r.type.Term(".",[new r.type.Var("X"),new r.type.Var("Xs")]),new r.type.Var("S")]),new r.type.Term(",",[new r.type.Term("prod_list",[new r.type.Var("Xs"),new r.type.Var("Y")]),new r.type.Term("is",[new r.type.Var("S"),new r.type.Term("*",[new r.type.Var("X"),new r.type.Var("Y")])])]))],"last/2":[new r.type.Rule(new r.type.Term("last",[new r.type.Term(".",[new r.type.Var("X"),new r.type.Term("[]",[])]),new r.type.Var("X")]),null),new r.type.Rule(new r.type.Term("last",[new r.type.Term(".",[new r.type.Var("_"),new r.type.Var("Xs")]),new r.type.Var("X")]),new r.type.Term("last",[new r.type.Var("Xs"),new r.type.Var("X")]))],"prefix/2":[new r.type.Rule(new r.type.Term("prefix",[new r.type.Var("Part"),new r.type.Var("Whole")]),new r.type.Term("append",[new r.type.Var("Part"),new r.type.Var("_"),new r.type.Var("Whole")]))],"nth0/3":[new r.type.Rule(new r.type.Term("nth0",[new r.type.Var("X"),new r.type.Var("Y"),new r.type.Var("Z")]),new r.type.Term(";",[new r.type.Term("->",[new r.type.Term("var",[new r.type.Var("X")]),new r.type.Term("nth",[new r.type.Num(0,!1),new r.type.Var("X"),new r.type.Var("Y"),new r.type.Var("Z"),new r.type.Var("_")])]),new r.type.Term(",",[new r.type.Term(">=",[new r.type.Var("X"),new r.type.Num(0,!1)]),new r.type.Term(",",[new r.type.Term("nth",[new r.type.Num(0,!1),new r.type.Var("X"),new r.type.Var("Y"),new r.type.Var("Z"),new r.type.Var("_")]),new r.type.Term("!",[])])])]))],"nth1/3":[new r.type.Rule(new r.type.Term("nth1",[new r.type.Var("X"),new r.type.Var("Y"),new r.type.Var("Z")]),new r.type.Term(";",[new r.type.Term("->",[new r.type.Term("var",[new r.type.Var("X")]),new r.type.Term("nth",[new r.type.Num(1,!1),new r.type.Var("X"),new r.type.Var("Y"),new r.type.Var("Z"),new r.type.Var("_")])]),new r.type.Term(",",[new r.type.Term(">",[new r.type.Var("X"),new r.type.Num(0,!1)]),new r.type.Term(",",[new r.type.Term("nth",[new r.type.Num(1,!1),new r.type.Var("X"),new r.type.Var("Y"),new r.type.Var("Z"),new r.type.Var("_")]),new r.type.Term("!",[])])])]))],"nth0/4":[new r.type.Rule(new r.type.Term("nth0",[new r.type.Var("X"),new r.type.Var("Y"),new r.type.Var("Z"),new r.type.Var("W")]),new r.type.Term(";",[new r.type.Term("->",[new r.type.Term("var",[new r.type.Var("X")]),new r.type.Term("nth",[new r.type.Num(0,!1),new r.type.Var("X"),new r.type.Var("Y"),new r.type.Var("Z"),new r.type.Var("W")])]),new r.type.Term(",",[new r.type.Term(">=",[new r.type.Var("X"),new r.type.Num(0,!1)]),new r.type.Term(",",[new r.type.Term("nth",[new r.type.Num(0,!1),new r.type.Var("X"),new r.type.Var("Y"),new r.type.Var("Z"),new r.type.Var("W")]),new r.type.Term("!",[])])])]))],"nth1/4":[new r.type.Rule(new r.type.Term("nth1",[new r.type.Var("X"),new r.type.Var("Y"),new r.type.Var("Z"),new r.type.Var("W")]),new r.type.Term(";",[new r.type.Term("->",[new r.type.Term("var",[new r.type.Var("X")]),new r.type.Term("nth",[new r.type.Num(1,!1),new r.type.Var("X"),new r.type.Var("Y"),new r.type.Var("Z"),new r.type.Var("W")])]),new r.type.Term(",",[new r.type.Term(">",[new r.type.Var("X"),new r.type.Num(0,!1)]),new r.type.Term(",",[new r.type.Term("nth",[new r.type.Num(1,!1),new r.type.Var("X"),new r.type.Var("Y"),new r.type.Var("Z"),new r.type.Var("W")]),new r.type.Term("!",[])])])]))],"nth/5":[new r.type.Rule(new r.type.Term("nth",[new r.type.Var("N"),new r.type.Var("N"),new r.type.Term(".",[new r.type.Var("X"),new r.type.Var("Xs")]),new r.type.Var("X"),new r.type.Var("Xs")]),null),new r.type.Rule(new r.type.Term("nth",[new r.type.Var("N"),new r.type.Var("O"),new r.type.Term(".",[new r.type.Var("X"),new r.type.Var("Xs")]),new r.type.Var("Y"),new r.type.Term(".",[new r.type.Var("X"),new r.type.Var("Ys")])]),new r.type.Term(",",[new r.type.Term("is",[new r.type.Var("M"),new r.type.Term("+",[new r.type.Var("N"),new r.type.Num(1,!1)])]),new r.type.Term("nth",[new r.type.Var("M"),new r.type.Var("O"),new r.type.Var("Xs"),new r.type.Var("Y"),new r.type.Var("Ys")])]))],"length/2":function(c,w,_){var v=_.args[0],g=_.args[1];if(!r.type.is_variable(g)&&!r.type.is_integer(g))c.throw_error(r.error.type("integer",g,_.indicator));else if(r.type.is_integer(g)&&g.value<0)c.throw_error(r.error.domain("not_less_than_zero",g,_.indicator));else{var h=new r.type.Term("length",[v,new r.type.Num(0,!1),g]);r.type.is_integer(g)&&(h=new r.type.Term(",",[h,new r.type.Term("!",[])])),c.prepend([new r.type.State(w.goal.replace(h),w.substitution,w)])}},"length/3":[new r.type.Rule(new r.type.Term("length",[new r.type.Term("[]",[]),new r.type.Var("N"),new r.type.Var("N")]),null),new r.type.Rule(new r.type.Term("length",[new r.type.Term(".",[new r.type.Var("_"),new r.type.Var("X")]),new r.type.Var("A"),new r.type.Var("N")]),new r.type.Term(",",[new r.type.Term("succ",[new r.type.Var("A"),new r.type.Var("B")]),new r.type.Term("length",[new r.type.Var("X"),new r.type.Var("B"),new r.type.Var("N")])]))],"replicate/3":function(c,w,_){var v=_.args[0],g=_.args[1],h=_.args[2];if(r.type.is_variable(g))c.throw_error(r.error.instantiation(_.indicator));else if(!r.type.is_integer(g))c.throw_error(r.error.type("integer",g,_.indicator));else if(g.value<0)c.throw_error(r.error.domain("not_less_than_zero",g,_.indicator));else if(!r.type.is_variable(h)&&!r.type.is_list(h))c.throw_error(r.error.type("list",h,_.indicator));else{for(var T=new r.type.Term("[]"),x=0;x<g.value;x++)T=new r.type.Term(".",[v,T]);c.prepend([new r.type.State(w.goal.replace(new r.type.Term("=",[T,h])),w.substitution,w)])}},"sort/2":function(c,w,_){var v=_.args[0],g=_.args[1];if(r.type.is_variable(v))c.throw_error(r.error.instantiation(_.indicator));else if(!r.type.is_variable(g)&&!r.type.is_fully_list(g))c.throw_error(r.error.type("list",g,_.indicator));else{for(var h=[],T=v;T.indicator==="./2";)h.push(T.args[0]),T=T.args[1];if(r.type.is_variable(T))c.throw_error(r.error.instantiation(_.indicator));else if(!r.type.is_empty_list(T))c.throw_error(r.error.type("list",v,_.indicator));else{for(var x=h.sort(r.compare),b=x.length-1;b>0;b--)x[b].equals(x[b-1])&&x.splice(b,1);for(var P=new r.type.Term("[]"),b=x.length-1;b>=0;b--)P=new r.type.Term(".",[x[b],P]);c.prepend([new r.type.State(w.goal.replace(new r.type.Term("=",[P,g])),w.substitution,w)])}}},"msort/2":function(c,w,_){var v=_.args[0],g=_.args[1];if(r.type.is_variable(v))c.throw_error(r.error.instantiation(_.indicator));else if(!r.type.is_variable(g)&&!r.type.is_fully_list(g))c.throw_error(r.error.type("list",g,_.indicator));else{for(var h=[],T=v;T.indicator==="./2";)h.push(T.args[0]),T=T.args[1];if(r.type.is_variable(T))c.throw_error(r.error.instantiation(_.indicator));else if(!r.type.is_empty_list(T))c.throw_error(r.error.type("list",v,_.indicator));else{for(var x=h.sort(r.compare),b=new r.type.Term("[]"),P=x.length-1;P>=0;P--)b=new r.type.Term(".",[x[P],b]);c.prepend([new r.type.State(w.goal.replace(new r.type.Term("=",[b,g])),w.substitution,w)])}}},"keysort/2":function(c,w,_){var v=_.args[0],g=_.args[1];if(r.type.is_variable(v))c.throw_error(r.error.instantiation(_.indicator));else if(!r.type.is_variable(g)&&!r.type.is_fully_list(g))c.throw_error(r.error.type("list",g,_.indicator));else{for(var h=[],T,x=v;x.indicator==="./2";){if(T=x.args[0],r.type.is_variable(T)){c.throw_error(r.error.instantiation(_.indicator));return}else if(!r.type.is_term(T)||T.indicator!=="-/2"){c.throw_error(r.error.type("pair",T,_.indicator));return}T.args[0].pair=T.args[1],h.push(T.args[0]),x=x.args[1]}if(r.type.is_variable(x))c.throw_error(r.error.instantiation(_.indicator));else if(!r.type.is_empty_list(x))c.throw_error(r.error.type("list",v,_.indicator));else{for(var b=h.sort(r.compare),P=new r.type.Term("[]"),N=b.length-1;N>=0;N--)P=new r.type.Term(".",[new r.type.Term("-",[b[N],b[N].pair]),P]),delete b[N].pair;c.prepend([new r.type.State(w.goal.replace(new r.type.Term("=",[P,g])),w.substitution,w)])}}},"take/3":function(c,w,_){var v=_.args[0],g=_.args[1],h=_.args[2];if(r.type.is_variable(g)||r.type.is_variable(v))c.throw_error(r.error.instantiation(_.indicator));else if(!r.type.is_list(g))c.throw_error(r.error.type("list",g,_.indicator));else if(!r.type.is_integer(v))c.throw_error(r.error.type("integer",v,_.indicator));else if(!r.type.is_variable(h)&&!r.type.is_list(h))c.throw_error(r.error.type("list",h,_.indicator));else{for(var T=v.value,x=[],b=g;T>0&&b.indicator==="./2";)x.push(b.args[0]),b=b.args[1],T--;if(T===0){for(var P=new r.type.Term("[]"),T=x.length-1;T>=0;T--)P=new r.type.Term(".",[x[T],P]);c.prepend([new r.type.State(w.goal.replace(new r.type.Term("=",[P,h])),w.substitution,w)])}}},"drop/3":function(c,w,_){var v=_.args[0],g=_.args[1],h=_.args[2];if(r.type.is_variable(g)||r.type.is_variable(v))c.throw_error(r.error.instantiation(_.indicator));else if(!r.type.is_list(g))c.throw_error(r.error.type("list",g,_.indicator));else if(!r.type.is_integer(v))c.throw_error(r.error.type("integer",v,_.indicator));else if(!r.type.is_variable(h)&&!r.type.is_list(h))c.throw_error(r.error.type("list",h,_.indicator));else{for(var T=v.value,x=[],b=g;T>0&&b.indicator==="./2";)x.push(b.args[0]),b=b.args[1],T--;T===0&&c.prepend([new r.type.State(w.goal.replace(new r.type.Term("=",[b,h])),w.substitution,w)])}},"reverse/2":function(c,w,_){var v=_.args[0],g=_.args[1],h=r.type.is_instantiated_list(v),T=r.type.is_instantiated_list(g);if(r.type.is_variable(v)&&r.type.is_variable(g))c.throw_error(r.error.instantiation(_.indicator));else if(!r.type.is_variable(v)&&!r.type.is_fully_list(v))c.throw_error(r.error.type("list",v,_.indicator));else if(!r.type.is_variable(g)&&!r.type.is_fully_list(g))c.throw_error(r.error.type("list",g,_.indicator));else if(!h&&!T)c.throw_error(r.error.instantiation(_.indicator));else{for(var x=h?v:g,b=new r.type.Term("[]",[]);x.indicator==="./2";)b=new r.type.Term(".",[x.args[0],b]),x=x.args[1];c.prepend([new r.type.State(w.goal.replace(new r.type.Term("=",[b,h?g:v])),w.substitution,w)])}},"list_to_set/2":function(c,w,_){var v=_.args[0],g=_.args[1];if(r.type.is_variable(v))c.throw_error(r.error.instantiation(_.indicator));else{for(var h=v,T=[];h.indicator==="./2";)T.push(h.args[0]),h=h.args[1];if(r.type.is_variable(h))c.throw_error(r.error.instantiation(_.indicator));else if(!r.type.is_term(h)||h.indicator!=="[]/0")c.throw_error(r.error.type("list",v,_.indicator));else{for(var x=[],b=new r.type.Term("[]",[]),P,N=0;N<T.length;N++){P=!1;for(var z=0;z<x.length&&!P;z++)P=r.compare(T[N],x[z])===0;P||x.push(T[N])}for(N=x.length-1;N>=0;N--)b=new r.type.Term(".",[x[N],b]);c.prepend([new r.type.State(w.goal.replace(new r.type.Term("=",[g,b])),w.substitution,w)])}}}}},f=["append/2","append/3","member/2","permutation/2","maplist/2","maplist/3","maplist/4","maplist/5","maplist/6","maplist/7","maplist/8","include/3","exclude/3","foldl/4","sum_list/2","max_list/2","min_list/2","prod_list/2","last/2","prefix/2","nth0/3","nth1/3","nth0/4","nth1/4","length/2","replicate/3","select/3","sort/2","msort/2","keysort/2","take/3","drop/3","reverse/2","list_to_set/2"];typeof _r<"u"?_r.exports=function(c){r=c,new r.type.Module("lists",l(),f)}:new r.type.Module("lists",l(),f)})(Zi)});var tt=C(M=>{"use strict";var ke=process.platform==="win32",wr="aes-256-cbc",Qi="sha256",Lr="The current environment doesn't support interactive reading from TTY.",W=G("fs"),zr=process.binding("tty_wrap").TTY,dr=G("child_process"),ge=G("path"),vr={prompt:"> ",hideEchoBack:!1,mask:"*",limit:[],limitMessage:"Input another, please.$<( [)limit(])>",defaultInput:"",trueValue:[],falseValue:[],caseSensitive:!1,keepWhitespace:!1,encoding:"utf8",bufferSize:1024,print:void 0,history:!0,cd:!1,phContent:void 0,preCheck:void 0},pe="none",ue,Ae,Wr=!1,we,Ke,gr,Ji=0,xr="",Se=[],je,Hr=!1,hr=!1,Fe=!1;function Yr(r){function l(f){return f.replace(/[^\w\u0080-\uFFFF]/g,function(c){return"#"+c.charCodeAt(0)+";"})}return Ke.concat(function(f){var c=[];return Object.keys(f).forEach(function(w){f[w]==="boolean"?r[w]&&c.push("--"+w):f[w]==="string"&&r[w]&&c.push("--"+w,l(r[w]))}),c}({display:"string",displayOnly:"boolean",keyIn:"boolean",hideEchoBack:"boolean",mask:"string",limit:"string",caseSensitive:"boolean"}))}function Ki(r,l){function f(ee){var U,Ue="",Ze;for(gr=gr||G("os").tmpdir();;){U=ge.join(gr,ee+Ue);try{Ze=W.openSync(U,"wx")}catch(Qe){if(Qe.code==="EEXIST"){Ue++;continue}else throw Qe}W.closeSync(Ze);break}return U}var c,w,_,v={},g,h,T=f("readline-sync.stdout"),x=f("readline-sync.stderr"),b=f("readline-sync.exit"),P=f("readline-sync.done"),N=G("crypto"),z,Q,te;z=N.createHash(Qi),z.update(""+process.pid+Ji+++Math.random()),te=z.digest("hex"),Q=N.createDecipher(wr,te),c=Yr(r),ke?(w=process.env.ComSpec||"cmd.exe",process.env.Q='"',_=["/V:ON","/S","/C","(%Q%"+w+"%Q% /V:ON /S /C %Q%%Q%"+we+"%Q%"+c.map(function(ee){return" %Q%"+ee+"%Q%"}).join("")+" & (echo !ERRORLEVEL!)>%Q%"+b+"%Q%%Q%) 2>%Q%"+x+"%Q% |%Q%"+process.execPath+"%Q% %Q%"+__dirname+"\\encrypt.js%Q% %Q%"+wr+"%Q% %Q%"+te+"%Q% >%Q%"+T+"%Q% & (echo 1)>%Q%"+P+"%Q%"]):(w="/bin/sh",_=["-c",'("'+we+'"'+c.map(function(ee){return" '"+ee.replace(/'/g,"'\\''")+"'"}).join("")+'; echo $?>"'+b+'") 2>"'+x+'" |"'+process.execPath+'" "'+__dirname+'/encrypt.js" "'+wr+'" "'+te+'" >"'+T+'"; echo 1 >"'+P+'"']),Fe&&Fe("_execFileSync",c);try{dr.spawn(w,_,l)}catch(ee){v.error=new Error(ee.message),v.error.method="_execFileSync - spawn",v.error.program=w,v.error.args=_}for(;W.readFileSync(P,{encoding:r.encoding}).trim()!=="1";);return(g=W.readFileSync(b,{encoding:r.encoding}).trim())==="0"?v.input=Q.update(W.readFileSync(T,{encoding:"binary"}),"hex",r.encoding)+Q.final(r.encoding):(h=W.readFileSync(x,{encoding:r.encoding}).trim(),v.error=new Error(Lr+(h?`
|
|
`+h:"")),v.error.method="_execFileSync",v.error.program=w,v.error.args=_,v.error.extMessage=h,v.error.exitCode=+g),W.unlinkSync(T),W.unlinkSync(x),W.unlinkSync(b),W.unlinkSync(P),v}function ji(r){var l,f={},c,w={env:process.env,encoding:r.encoding};if(we||(ke?process.env.PSModulePath?(we="powershell.exe",Ke=["-ExecutionPolicy","Bypass","-File",__dirname+"\\read.ps1"]):(we="cscript.exe",Ke=["//nologo",__dirname+"\\read.cs.js"]):(we="/bin/sh",Ke=[__dirname+"/read.sh"])),ke&&!process.env.PSModulePath&&(w.stdio=[process.stdin]),dr.execFileSync){l=Yr(r),Fe&&Fe("execFileSync",l);try{f.input=dr.execFileSync(we,l,w)}catch(_){c=_.stderr?(_.stderr+"").trim():"",f.error=new Error(Lr+(c?`
|
|
`+c:"")),f.error.method="execFileSync",f.error.program=we,f.error.args=l,f.error.extMessage=c,f.error.exitCode=_.status,f.error.code=_.code,f.error.signal=_.signal}}else f=Ki(r,w);return f.error||(f.input=f.input.replace(/^\s*'|'\s*$/g,""),r.display=""),f}function mr(r){var l="",f=r.display,c=!r.display&&r.keyIn&&r.hideEchoBack&&!r.mask;function w(){var _=ji(r);if(_.error)throw _.error;return _.input}return hr&&hr(r),function(){var _,v,g;function h(){return _||(_=process.binding("fs"),v=process.binding("constants")),_}if(typeof pe=="string")if(pe=null,ke){if(g=function(T){var x=T.replace(/^\D+/,"").split("."),b=0;return(x[0]=+x[0])&&(b+=x[0]*1e4),(x[1]=+x[1])&&(b+=x[1]*100),(x[2]=+x[2])&&(b+=x[2]),b}(process.version),!(g>=20302&&g<40204||g>=5e4&&g<50100||g>=50600&&g<60200)&&process.stdin.isTTY)process.stdin.pause(),pe=process.stdin.fd,Ae=process.stdin._handle;else try{pe=h().open("CONIN$",v.O_RDWR,parseInt("0666",8)),Ae=new zr(pe,!0)}catch{}if(process.stdout.isTTY)ue=process.stdout.fd;else{try{ue=W.openSync("\\\\.\\CON","w")}catch{}if(typeof ue!="number")try{ue=h().open("CONOUT$",v.O_RDWR,parseInt("0666",8))}catch{}}}else{if(process.stdin.isTTY){process.stdin.pause();try{pe=W.openSync("/dev/tty","r"),Ae=process.stdin._handle}catch{}}else try{pe=W.openSync("/dev/tty","r"),Ae=new zr(pe,!1)}catch{}if(process.stdout.isTTY)ue=process.stdout.fd;else try{ue=W.openSync("/dev/tty","w")}catch{}}}(),function(){var _,v,g=!r.hideEchoBack&&!r.keyIn,h,T,x,b,P;je="";function N(z){return z===Wr?!0:Ae.setRawMode(z)!==0?!1:(Wr=z,!0)}if(Hr||!Ae||typeof ue!="number"&&(r.display||!g)){l=w();return}if(r.display&&(W.writeSync(ue,r.display),r.display=""),!r.displayOnly){if(!N(!g)){l=w();return}for(T=r.keyIn?1:r.bufferSize,h=Buffer.allocUnsafe&&Buffer.alloc?Buffer.alloc(T):new Buffer(T),r.keyIn&&r.limit&&(v=new RegExp("[^"+r.limit+"]","g"+(r.caseSensitive?"":"i")));;){x=0;try{x=W.readSync(pe,h,0,T)}catch(z){if(z.code!=="EOF"){N(!1),l+=w();return}}if(x>0?(b=h.toString(r.encoding,0,x),je+=b):(b=`
|
|
`,je+=String.fromCharCode(0)),b&&typeof(P=(b.match(/^(.*?)[\r\n]/)||[])[1])=="string"&&(b=P,_=!0),b&&(b=b.replace(/[\x00-\x08\x0b\x0c\x0e-\x1f\x7f]/g,"")),b&&v&&(b=b.replace(v,"")),b&&(g||(r.hideEchoBack?r.mask&&W.writeSync(ue,new Array(b.length+1).join(r.mask)):W.writeSync(ue,b)),l+=b),!r.keyIn&&_||r.keyIn&&l.length>=T)break}!g&&!c&&W.writeSync(ue,`
|
|
`),N(!1)}}(),r.print&&!c&&r.print(f+(r.displayOnly?"":(r.hideEchoBack?new Array(l.length+1).join(r.mask):l)+`
|
|
`),r.encoding),r.displayOnly?"":xr=r.keepWhitespace||r.keyIn?l:l.trim()}function es(r,l){var f=[];function c(w){w!=null&&(Array.isArray(w)?w.forEach(c):(!l||l(w))&&f.push(w))}return c(r),f}function Vr(r){return r.replace(/[\x00-\x7f]/g,function(l){return"\\x"+("00"+l.charCodeAt().toString(16)).substr(-2)})}function Z(){var r=Array.prototype.slice.call(arguments),l,f;return r.length&&typeof r[0]=="boolean"&&(f=r.shift(),f&&(l=Object.keys(vr),r.unshift(vr))),r.reduce(function(c,w){return w==null||(w.hasOwnProperty("noEchoBack")&&!w.hasOwnProperty("hideEchoBack")&&(w.hideEchoBack=w.noEchoBack,delete w.noEchoBack),w.hasOwnProperty("noTrim")&&!w.hasOwnProperty("keepWhitespace")&&(w.keepWhitespace=w.noTrim,delete w.noTrim),f||(l=Object.keys(w)),l.forEach(function(_){var v;if(!!w.hasOwnProperty(_))switch(v=w[_],_){case"mask":case"limitMessage":case"defaultInput":case"encoding":v=v!=null?v+"":"",v&&_!=="limitMessage"&&(v=v.replace(/[\r\n]/g,"")),c[_]=v;break;case"bufferSize":!isNaN(v=parseInt(v,10))&&typeof v=="number"&&(c[_]=v);break;case"displayOnly":case"keyIn":case"hideEchoBack":case"caseSensitive":case"keepWhitespace":case"history":case"cd":c[_]=!!v;break;case"limit":case"trueValue":case"falseValue":c[_]=es(v,function(g){var h=typeof g;return h==="string"||h==="number"||h==="function"||g instanceof RegExp}).map(function(g){return typeof g=="string"?g.replace(/[\r\n]/g,""):g});break;case"print":case"phContent":case"preCheck":c[_]=typeof v=="function"?v:void 0;break;case"prompt":case"display":c[_]=v!=null?v:"";break}})),c},{})}function br(r,l,f){return l.some(function(c){var w=typeof c;return w==="string"?f?r===c:r.toLowerCase()===c.toLowerCase():w==="number"?parseFloat(r)===c:w==="function"?c(r):c instanceof RegExp?c.test(r):!1})}function Sr(r,l){var f=ge.normalize(ke?(process.env.HOMEDRIVE||"")+(process.env.HOMEPATH||""):process.env.HOME||"").replace(/[\/\\]+$/,"");return r=ge.normalize(r),l?r.replace(/^~(?=\/|\\|$)/,f):r.replace(new RegExp("^"+Vr(f)+"(?=\\/|\\\\|$)",ke?"i":""),"~")}function Ne(r,l){var f="(?:\\(([\\s\\S]*?)\\))?(\\w+|.-.)(?:\\(([\\s\\S]*?)\\))?",c=new RegExp("(\\$)?(\\$<"+f+">)","g"),w=new RegExp("(\\$)?(\\$\\{"+f+"\\})","g");function _(v,g,h,T,x,b){var P;return g||typeof(P=l(x))!="string"?h:P?(T||"")+P+(b||""):""}return r.replace(c,_).replace(w,_)}function Gr(r,l,f){var c,w=[],_=-1,v=0,g="",h;function T(x,b){return b.length>3?(x.push(b[0]+"..."+b[b.length-1]),h=!0):b.length&&(x=x.concat(b)),x}return c=r.reduce(function(x,b){return x.concat((b+"").split(""))},[]).reduce(function(x,b){var P,N;return l||(b=b.toLowerCase()),P=/^\d$/.test(b)?1:/^[A-Z]$/.test(b)?2:/^[a-z]$/.test(b)?3:0,f&&P===0?g+=b:(N=b.charCodeAt(0),P&&P===_&&N===v+1?w.push(b):(x=T(x,w),w=[b],_=P),v=N),x},[]),c=T(c,w),g&&(c.push(g),h=!0),{values:c,suppressed:h}}function Ur(r,l){return r.join(r.length>2?", ":l?" / ":"/")}function Zr(r,l){var f,c,w={},_;if(l.phContent&&(f=l.phContent(r,l)),typeof f!="string")switch(r){case"hideEchoBack":case"mask":case"defaultInput":case"caseSensitive":case"keepWhitespace":case"encoding":case"bufferSize":case"history":case"cd":f=l.hasOwnProperty(r)?typeof l[r]=="boolean"?l[r]?"on":"off":l[r]+"":"";break;case"limit":case"trueValue":case"falseValue":c=l[l.hasOwnProperty(r+"Src")?r+"Src":r],l.keyIn?(w=Gr(c,l.caseSensitive),c=w.values):c=c.filter(function(v){var g=typeof v;return g==="string"||g==="number"}),f=Ur(c,w.suppressed);break;case"limitCount":case"limitCountNotZero":f=l[l.hasOwnProperty("limitSrc")?"limitSrc":"limit"].length,f=f||r!=="limitCountNotZero"?f+"":"";break;case"lastInput":f=xr;break;case"cwd":case"CWD":case"cwdHome":f=process.cwd(),r==="CWD"?f=ge.basename(f):r==="cwdHome"&&(f=Sr(f));break;case"date":case"time":case"localeDate":case"localeTime":f=new Date()["to"+r.replace(/^./,function(v){return v.toUpperCase()})+"String"]();break;default:typeof(_=(r.match(/^history_m(\d+)$/)||[])[1])=="string"&&(f=Se[Se.length-_]||"")}return f}function Qr(r){var l=/^(.)-(.)$/.exec(r),f="",c,w,_,v;if(!l)return null;for(c=l[1].charCodeAt(0),w=l[2].charCodeAt(0),v=c<w?1:-1,_=c;_!==w+v;_+=v)f+=String.fromCharCode(_);return f}function Tr(r){var l=new RegExp(/(\s*)(?:("|')(.*?)(?:\2|$)|(\S+))/g),f,c="",w=[],_;for(r=r.trim();f=l.exec(r);)_=f[3]||f[4]||"",f[1]&&(w.push(c),c=""),c+=_;return c&&w.push(c),w}function Jr(r,l){return l.trueValue.length&&br(r,l.trueValue,l.caseSensitive)?!0:l.falseValue.length&&br(r,l.falseValue,l.caseSensitive)?!1:r}function Kr(r){var l,f,c,w,_,v,g;function h(x){return Zr(x,r)}function T(x){r.display+=(/[^\r\n]$/.test(r.display)?`
|
|
`:"")+x}for(r.limitSrc=r.limit,r.displaySrc=r.display,r.limit="",r.display=Ne(r.display+"",h);;){if(l=mr(r),f=!1,c="",r.defaultInput&&!l&&(l=r.defaultInput),r.history&&((w=/^\s*\!(?:\!|-1)(:p)?\s*$/.exec(l))?(_=Se[0]||"",w[1]?f=!0:l=_,T(_+`
|
|
`),f||(r.displayOnly=!0,mr(r),r.displayOnly=!1)):l&&l!==Se[Se.length-1]&&(Se=[l])),!f&&r.cd&&l)switch(v=Tr(l),v[0].toLowerCase()){case"cd":if(v[1])try{process.chdir(Sr(v[1],!0))}catch(x){T(x+"")}f=!0;break;case"pwd":T(process.cwd()),f=!0;break}if(!f&&r.preCheck&&(g=r.preCheck(l,r),l=g.res,g.forceNext&&(f=!0)),!f){if(!r.limitSrc.length||br(l,r.limitSrc,r.caseSensitive))break;r.limitMessage&&(c=Ne(r.limitMessage,h))}T((c?c+`
|
|
`:"")+Ne(r.displaySrc+"",h))}return Jr(l,r)}M._DBG_set_useExt=function(r){Hr=r};M._DBG_set_checkOptions=function(r){hr=r};M._DBG_set_checkMethod=function(r){Fe=r};M._DBG_clearHistory=function(){xr="",Se=[]};M.setDefaultOptions=function(r){return vr=Z(!0,r),Z(!0)};M.question=function(r,l){return Kr(Z(Z(!0,l),{display:r}))};M.prompt=function(r){var l=Z(!0,r);return l.display=l.prompt,Kr(l)};M.keyIn=function(r,l){var f=Z(Z(!0,l),{display:r,keyIn:!0,keepWhitespace:!0});return f.limitSrc=f.limit.filter(function(c){var w=typeof c;return w==="string"||w==="number"}).map(function(c){return Ne(c+"",Qr)}),f.limit=Vr(f.limitSrc.join("")),["trueValue","falseValue"].forEach(function(c){f[c]=f[c].reduce(function(w,_){var v=typeof _;return v==="string"||v==="number"?w=w.concat((_+"").split("")):w.push(_),w},[])}),f.display=Ne(f.display+"",function(c){return Zr(c,f)}),Jr(mr(f),f)};M.questionEMail=function(r,l){return r==null&&(r="Input e-mail address: "),M.question(r,Z({hideEchoBack:!1,limit:/^[a-zA-Z0-9.!#$%&'*+\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/,limitMessage:"Input valid e-mail address, please.",trueValue:null,falseValue:null},l,{keepWhitespace:!1,cd:!1}))};M.questionNewPassword=function(r,l){var f,c,w,_=Z({hideEchoBack:!0,mask:"*",limitMessage:`It can include: $<charlist>
|
|
And the length must be: $<length>`,trueValue:null,falseValue:null,caseSensitive:!0},l,{history:!1,cd:!1,phContent:function(N){return N==="charlist"?f.text:N==="length"?c+"..."+w:null}}),v,g,h,T,x,b,P;for(l=l||{},v=Ne(l.charlist?l.charlist+"":"$<!-~>",Qr),(isNaN(c=parseInt(l.min,10))||typeof c!="number")&&(c=12),(isNaN(w=parseInt(l.max,10))||typeof w!="number")&&(w=24),T=new RegExp("^["+Vr(v)+"]{"+c+","+w+"}$"),f=Gr([v],_.caseSensitive,!0),f.text=Ur(f.values,f.suppressed),g=l.confirmMessage!=null?l.confirmMessage:"Reinput a same one to confirm it: ",h=l.unmatchMessage!=null?l.unmatchMessage:"It differs from first one. Hit only the Enter key if you want to retry from first one.",r==null&&(r="Input new password: "),x=_.limitMessage;!P;)_.limit=T,_.limitMessage=x,b=M.question(r,_),_.limit=[b,""],_.limitMessage=h,P=M.question(g,_);return b};function jr(r,l,f){var c;function w(_){return c=f(_),!isNaN(c)&&typeof c=="number"}return M.question(r,Z({limitMessage:"Input valid number, please."},l,{limit:w,cd:!1})),c}M.questionInt=function(r,l){return jr(r,l,function(f){return parseInt(f,10)})};M.questionFloat=function(r,l){return jr(r,l,parseFloat)};M.questionPath=function(r,l){var f,c="",w=Z({hideEchoBack:!1,limitMessage:`$<error(
|
|
)>Input valid path, please.$<( Min:)min>$<( Max:)max>`,history:!0,cd:!0},l,{keepWhitespace:!1,limit:function(_){var v,g,h;_=Sr(_,!0),c="";function T(x){x.split(/\/|\\/).reduce(function(b,P){var N=ge.resolve(b+=P+ge.sep);if(!W.existsSync(N))W.mkdirSync(N);else if(!W.statSync(N).isDirectory())throw new Error("Non directory already exists: "+N);return b},"")}try{if(v=W.existsSync(_),f=v?W.realpathSync(_):ge.resolve(_),!l.hasOwnProperty("exists")&&!v||typeof l.exists=="boolean"&&l.exists!==v)return c=(v?"Already exists":"No such file or directory")+": "+f,!1;if(!v&&l.create&&(l.isDirectory?T(f):(T(ge.dirname(f)),W.closeSync(W.openSync(f,"w"))),f=W.realpathSync(f)),v&&(l.min||l.max||l.isFile||l.isDirectory)){if(g=W.statSync(f),l.isFile&&!g.isFile())return c="Not file: "+f,!1;if(l.isDirectory&&!g.isDirectory())return c="Not directory: "+f,!1;if(l.min&&g.size<+l.min||l.max&&g.size>+l.max)return c="Size "+g.size+" is out of range: "+f,!1}if(typeof l.validate=="function"&&(h=l.validate(f))!==!0)return typeof h=="string"&&(c=h),!1}catch(x){return c=x+"",!1}return!0},phContent:function(_){return _==="error"?c:_!=="min"&&_!=="max"?null:l.hasOwnProperty(_)?l[_]+"":""}});return l=l||{},r==null&&(r='Input path (you can "cd" and "pwd"): '),M.question(r,w),f};function et(r,l){var f={},c={};return typeof r=="object"?(Object.keys(r).forEach(function(w){typeof r[w]=="function"&&(c[l.caseSensitive?w:w.toLowerCase()]=r[w])}),f.preCheck=function(w){var _;return f.args=Tr(w),_=f.args[0]||"",l.caseSensitive||(_=_.toLowerCase()),f.hRes=_!=="_"&&c.hasOwnProperty(_)?c[_].apply(w,f.args.slice(1)):c.hasOwnProperty("_")?c._.apply(w,f.args):null,{res:w,forceNext:!1}},c.hasOwnProperty("_")||(f.limit=function(){var w=f.args[0]||"";return l.caseSensitive||(w=w.toLowerCase()),c.hasOwnProperty(w)})):f.preCheck=function(w){return f.args=Tr(w),f.hRes=typeof r=="function"?r.apply(w,f.args):!0,{res:w,forceNext:!1}},f}M.promptCL=function(r,l){var f=Z({hideEchoBack:!1,limitMessage:"Requested command is not available.",caseSensitive:!1,history:!0},l),c=et(r,f);return f.limit=c.limit,f.preCheck=c.preCheck,M.prompt(f),c.args};M.promptLoop=function(r,l){for(var f=Z({hideEchoBack:!1,trueValue:null,falseValue:null,caseSensitive:!1,history:!0},l);!r(M.prompt(f)););};M.promptCLLoop=function(r,l){var f=Z({hideEchoBack:!1,limitMessage:"Requested command is not available.",caseSensitive:!1,history:!0},l),c=et(r,f);for(f.limit=c.limit,f.preCheck=c.preCheck;M.prompt(f),!c.hRes;);};M.promptSimShell=function(r){return M.prompt(Z({hideEchoBack:!1,history:!0},r,{prompt:function(){return ke?"$<cwd>>":(process.env.USER||"")+(process.env.HOSTNAME?"@"+process.env.HOSTNAME.replace(/\..*$/,""):"")+":$<cwdHome>$ "}()}))};function rt(r,l,f){var c;return r==null&&(r="Are you sure? "),(!l||l.guide!==!1)&&(r+="")&&(r=r.replace(/\s*:?\s*$/,"")+" [y/n]: "),c=M.keyIn(r,Z(l,{hideEchoBack:!1,limit:f,trueValue:"y",falseValue:"n",caseSensitive:!1})),typeof c=="boolean"?c:""}M.keyInYN=function(r,l){return rt(r,l)};M.keyInYNStrict=function(r,l){return rt(r,l,"yn")};M.keyInPause=function(r,l){r==null&&(r="Continue..."),(!l||l.guide!==!1)&&(r+="")&&(r=r.replace(/\s+$/,"")+" (Hit any key)"),M.keyIn(r,Z({limit:null},l,{hideEchoBack:!0,mask:""}))};M.keyInSelect=function(r,l,f){var c=Z({hideEchoBack:!1},f,{trueValue:null,falseValue:null,caseSensitive:!1,phContent:function(h){return h==="itemsCount"?r.length+"":h==="firstItem"?(r[0]+"").trim():h==="lastItem"?(r[r.length-1]+"").trim():null}}),w="",_={},v=49,g=`
|
|
`;if(!Array.isArray(r)||!r.length||r.length>35)throw"`items` must be Array (max length: 35).";return r.forEach(function(h,T){var x=String.fromCharCode(v);w+=x,_[x]=T,g+="["+x+"] "+(h+"").trim()+`
|
|
`,v=v===57?97:v+1}),(!f||f.cancel!==!1)&&(w+="0",_[0]=-1,g+="[0] "+(f&&f.cancel!=null&&typeof f.cancel!="boolean"?(f.cancel+"").trim():"CANCEL")+`
|
|
`),c.limit=w,g+=`
|
|
`,l==null&&(l="Choose one from list: "),(l+="")&&((!f||f.guide!==!1)&&(l=l.replace(/\s*:?\s*$/,"")+" [$<limit>]: "),g+=l),_[M.keyIn(g,c).toLowerCase()]};M.getRawInput=function(){return je};function ze(r,l){var f;return l.length&&(f={},f[r]=l[0]),M.setDefaultOptions(f)[r]}M.setPrint=function(){return ze("print",arguments)};M.setPrompt=function(){return ze("prompt",arguments)};M.setEncoding=function(){return ze("encoding",arguments)};M.setMask=function(){return ze("mask",arguments)};M.setBufferSize=function(){return ze("bufferSize",arguments)}});var kr=C((Au,ie)=>{(function(){var r={major:0,minor:2,patch:66,status:"beta"};tau_file_system={files:{},open:function(e,n,t){var s=tau_file_system.files[e];if(!s){if(t==="read")return null;s={path:e,text:"",type:n,get:function(a,u){return u===this.text.length||u>this.text.length?"end_of_file":this.text.substring(u,u+a)},put:function(a,u){return u==="end_of_file"?(this.text+=a,!0):u==="past_end_of_file"?null:(this.text=this.text.substring(0,u)+a+this.text.substring(u+a.length),!0)},get_byte:function(a){if(a==="end_of_stream")return-1;var u=Math.floor(a/2);if(this.text.length<=u)return-1;var p=_(this.text[Math.floor(a/2)],0);return a%2===0?p&255:p/256>>>0},put_byte:function(a,u){var p=u==="end_of_stream"?this.text.length:Math.floor(u/2);if(this.text.length<p)return null;var y=this.text.length===p?-1:_(this.text[Math.floor(u/2)],0);return u%2===0?(y=y/256>>>0,y=(y&255)<<8|a&255):(y=y&255,y=(a&255)<<8|y&255),this.text.length===p?this.text+=v(y):this.text=this.text.substring(0,p)+v(y)+this.text.substring(p+1),!0},flush:function(){return!0},close:function(){var a=tau_file_system.files[this.path];return a?!0:null}},tau_file_system.files[e]=s}return t==="write"&&(s.text=""),s}},tau_user_input={buffer:"",get:function(e,n){for(var t;tau_user_input.buffer.length<e;)t=window.prompt(),t&&(tau_user_input.buffer+=t);return t=tau_user_input.buffer.substr(0,e),tau_user_input.buffer=tau_user_input.buffer.substr(e),t}},tau_user_output={put:function(e,n){return console.log(e),!0},flush:function(){return!0}},nodejs_file_system={open:function(e,n,t){var s=G("fs"),a=s.openSync(e,t[0]);return t==="read"&&!s.existsSync(e)?null:{get:function(u,p){var y=new Buffer(u);return s.readSync(a,y,0,u,p),y.toString()},put:function(u,p){var y=Buffer.from(u);if(p==="end_of_file")s.writeSync(a,y);else{if(p==="past_end_of_file")return null;s.writeSync(a,y,0,y.length,p)}return!0},get_byte:function(u){return null},put_byte:function(u,p){return null},flush:function(){return!0},close:function(){return s.closeSync(a),!0}}}},nodejs_user_input={buffer:"",get:function(e,n){for(var t,s=tt();nodejs_user_input.buffer.length<e;)nodejs_user_input.buffer+=s.question();return t=nodejs_user_input.buffer.substr(0,e),nodejs_user_input.buffer=nodejs_user_input.buffer.substr(e),t}},nodejs_user_output={put:function(e,n){return process.stdout.write(e),!0},flush:function(){return!0}};var l;Array.prototype.indexOf?l=function(e,n){return e.indexOf(n)}:l=function(e,n){for(var t=e.length,s=0;s<t;s++)if(n===e[s])return s;return-1};var f=function(e,n){if(e.length!==0){for(var t=e[0],s=e.length,a=1;a<s;a++)t=n(t,e[a]);return t}},c;Array.prototype.map?c=function(e,n){return e.map(n)}:c=function(e,n){for(var t=[],s=e.length,a=0;a<s;a++)t.push(n(e[a]));return t};var w;Array.prototype.filter?w=function(e,n){return e.filter(n)}:w=function(e,n){for(var t=[],s=e.length,a=0;a<s;a++)n(e[a])&&t.push(e[a]);return t};var _;String.prototype.codePointAt?_=function(e,n){return e.codePointAt(n)}:_=function(e,n){return e.charCodeAt(n)};var v;String.fromCodePoint?v=function(){return String.fromCodePoint.apply(null,arguments)}:v=function(){return String.fromCharCode.apply(null,arguments)};var g=0,h=1,T=/(\\a)|(\\b)|(\\f)|(\\n)|(\\r)|(\\t)|(\\v)|\\x([0-9a-fA-F]+)\\|\\([0-7]+)\\|(\\\\)|(\\')|('')|(\\")|(\\`)|(\\.)|(.)/g,x={"\\a":7,"\\b":8,"\\f":12,"\\n":10,"\\r":13,"\\t":9,"\\v":11};function b(e){var n=[],t=!1;return e.replace(T,function(s,a,u,p,y,d,m,S,O,A,R,k,L,B,q,F,H){switch(!0){case O!==void 0:return n.push(parseInt(O,16)),"";case A!==void 0:return n.push(parseInt(A,8)),"";case R!==void 0:case k!==void 0:case L!==void 0:case B!==void 0:case q!==void 0:return n.push(_(s.substr(1),0)),"";case H!==void 0:return n.push(_(H,0)),"";case F!==void 0:t=!0;default:return n.push(x[s]),""}}),t?null:n}function P(e,n){var t="";if(e.length<2)return e;try{e=e.replace(/\\([0-7]+)\\/g,function(p,y){return v(parseInt(y,8))}),e=e.replace(/\\x([0-9a-fA-F]+)\\/g,function(p,y){return v(parseInt(y,16))})}catch{return null}for(var s=0;s<e.length;s++){var a=e.charAt(s),u=e.charAt(s+1);if(a===n&&u===n)s++,t+=n;else if(a==="\\")if(["a","b","f","n","r","t","v","'",'"',"\\","a","\b","\f",`
|
|
`,"\r"," ","\v"].indexOf(u)!==-1)switch(s+=1,u){case"a":t+="a";break;case"b":t+="\b";break;case"f":t+="\f";break;case"n":t+=`
|
|
`;break;case"r":t+="\r";break;case"t":t+=" ";break;case"v":t+="\v";break;case"'":t+="'";break;case'"':t+='"';break;case"\\":t+="\\";break}else return null;else t+=a}return t}function N(e){for(var n="",t=0;t<e.length;t++)switch(e.charAt(t)){case"'":n+="\\'";break;case"\\":n+="\\\\";break;case"\b":n+="\\b";break;case"\f":n+="\\f";break;case`
|
|
`:n+="\\n";break;case"\r":n+="\\r";break;case" ":n+="\\t";break;case"\v":n+="\\v";break;default:n+=e.charAt(t);break}return n}function z(e){var n=e.substr(2);switch(e.substr(0,2).toLowerCase()){case"0x":return parseInt(n,16);case"0b":return parseInt(n,2);case"0o":return parseInt(n,8);case"0'":return b(n)[0];default:return parseFloat(e)}}var Q={whitespace:/^\s*(?:(?:%.*)|(?:\/\*(?:\n|\r|.)*?\*\/)|(?:\s+))\s*/,variable:/^(?:[A-Z_][a-zA-Z0-9_]*)/,atom:/^(\!|,|;|[a-z][0-9a-zA-Z_]*|[#\$\&\*\+\-\.\/\:\<\=\>\?\@\^\~\\]+|'(?:[^']*?(?:\\(?:x?\d+)?\\)*(?:'')*(?:\\')*)*')/,number:/^(?:0o[0-7]+|0x[0-9a-fA-F]+|0b[01]+|0'(?:''|\\[abfnrtv\\'"`]|\\x?\d+\\|[^\\])|\d+(?:\.\d+(?:[eE][+-]?\d+)?)?)/,string:/^(?:"([^"]|""|\\")*"|`([^`]|``|\\`)*`)/,l_brace:/^(?:\[)/,r_brace:/^(?:\])/,l_bracket:/^(?:\{)/,r_bracket:/^(?:\})/,bar:/^(?:\|)/,l_paren:/^(?:\()/,r_paren:/^(?:\))/};function te(e,n){return e.get_flag("char_conversion").id==="on"?n.replace(/./g,function(t){return e.get_char_conversion(t)}):n}function ee(e){this.thread=e,this.text="",this.tokens=[]}ee.prototype.set_last_tokens=function(e){return this.tokens=e},ee.prototype.new_text=function(e){this.text=e,this.tokens=[]},ee.prototype.get_tokens=function(e){var n,t=0,s=0,a=0,u=[],p=!1;if(e){var y=this.tokens[e-1];t=y.len,n=te(this.thread,this.text.substr(y.len)),s=y.line,a=y.start}else n=this.text;if(/^\s*$/.test(n))return null;for(;n!=="";){var d=[],m=!1;if(/^\n/.exec(n)!==null){s++,a=0,t++,n=n.replace(/\n/,""),p=!0;continue}for(var S in Q)if(Q.hasOwnProperty(S)){var O=Q[S].exec(n);O&&d.push({value:O[0],name:S,matches:O})}if(!d.length)return this.set_last_tokens([{value:n,matches:[],name:"lexical",line:s,start:a}]);var y=f(d,function(B,q){return B.value.length>=q.value.length?B:q});switch(y.start=a,y.line=s,n=n.replace(y.value,""),a+=y.value.length,t+=y.value.length,y.name){case"atom":y.raw=y.value,y.value.charAt(0)==="'"&&(y.value=P(y.value.substr(1,y.value.length-2),"'"),y.value===null&&(y.name="lexical",y.value="unknown escape sequence"));break;case"number":y.float=y.value.substring(0,2)!=="0x"&&y.value.match(/[.eE]/)!==null&&y.value!=="0'.",y.value=z(y.value),y.blank=m;break;case"string":var A=y.value.charAt(0);y.value=P(y.value.substr(1,y.value.length-2),A),y.value===null&&(y.name="lexical",y.value="unknown escape sequence");break;case"whitespace":var R=u[u.length-1];R&&(R.space=!0),m=!0;continue;case"r_bracket":u.length>0&&u[u.length-1].name==="l_bracket"&&(y=u.pop(),y.name="atom",y.value="{}",y.raw="{}",y.space=!1);break;case"r_brace":u.length>0&&u[u.length-1].name==="l_brace"&&(y=u.pop(),y.name="atom",y.value="[]",y.raw="[]",y.space=!1);break}y.len=t,u.push(y),m=!1}var k=this.set_last_tokens(u);return k.length===0?null:k};function U(e,n,t,s,a){if(!n[t])return{type:g,value:i.error.syntax(n[t-1],"expression expected",!0)};var u;if(s==="0"){var p=n[t];switch(p.name){case"number":return{type:h,len:t+1,value:new i.type.Num(p.value,p.float)};case"variable":return{type:h,len:t+1,value:new i.type.Var(p.value)};case"string":var y;switch(e.get_flag("double_quotes").id){case"atom":y=new o(p.value,[]);break;case"codes":y=new o("[]",[]);for(var d=p.value.length-1;d>=0;d--)y=new o(".",[new i.type.Num(_(p.value,d),!1),y]);break;case"chars":y=new o("[]",[]);for(var d=p.value.length-1;d>=0;d--)y=new o(".",[new i.type.Term(p.value.charAt(d),[]),y]);break}return{type:h,len:t+1,value:y};case"l_paren":var k=U(e,n,t+1,e.__get_max_priority(),!0);return k.type!==h?k:n[k.len]&&n[k.len].name==="r_paren"?(k.len++,k):{type:g,derived:!0,value:i.error.syntax(n[k.len]?n[k.len]:n[k.len-1],") or operator expected",!n[k.len])};case"l_bracket":var k=U(e,n,t+1,e.__get_max_priority(),!0);return k.type!==h?k:n[k.len]&&n[k.len].name==="r_bracket"?(k.len++,k.value=new o("{}",[k.value]),k):{type:g,derived:!0,value:i.error.syntax(n[k.len]?n[k.len]:n[k.len-1],"} or operator expected",!n[k.len])}}var m=Ue(e,n,t,a);return m.type===h||m.derived||(m=Ze(e,n,t),m.type===h||m.derived)?m:{type:g,derived:!1,value:i.error.syntax(n[t],"unexpected token")}}var S=e.__get_max_priority(),O=e.__get_next_priority(s),A=t;if(n[t].name==="atom"&&n[t+1]&&(n[t].space||n[t+1].name!=="l_paren")){var p=n[t++],R=e.__lookup_operator_classes(s,p.value);if(R&&R.indexOf("fy")>-1){var k=U(e,n,t,s,a);if(k.type!==g)return p.value==="-"&&!p.space&&i.type.is_number(k.value)?{value:new i.type.Num(-k.value.value,k.value.is_float),len:k.len,type:h}:{value:new i.type.Term(p.value,[k.value]),len:k.len,type:h};u=k}else if(R&&R.indexOf("fx")>-1){var k=U(e,n,t,O,a);if(k.type!==g)return{value:new i.type.Term(p.value,[k.value]),len:k.len,type:h};u=k}}t=A;var k=U(e,n,t,O,a);if(k.type===h){t=k.len;var p=n[t];if(n[t]&&(n[t].name==="atom"&&e.__lookup_operator_classes(s,p.value)||n[t].name==="bar"&&e.__lookup_operator_classes(s,"|"))){var L=O,B=s,R=e.__lookup_operator_classes(s,p.value);if(R.indexOf("xf")>-1)return{value:new i.type.Term(p.value,[k.value]),len:++k.len,type:h};if(R.indexOf("xfx")>-1){var q=U(e,n,t+1,L,a);return q.type===h?{value:new i.type.Term(p.value,[k.value,q.value]),len:q.len,type:h}:(q.derived=!0,q)}else if(R.indexOf("xfy")>-1){var q=U(e,n,t+1,B,a);return q.type===h?{value:new i.type.Term(p.value,[k.value,q.value]),len:q.len,type:h}:(q.derived=!0,q)}else if(k.type!==g)for(;;){t=k.len;var p=n[t];if(p&&p.name==="atom"&&e.__lookup_operator_classes(s,p.value)){var R=e.__lookup_operator_classes(s,p.value);if(R.indexOf("yf")>-1)k={value:new i.type.Term(p.value,[k.value]),len:++t,type:h};else if(R.indexOf("yfx")>-1){var q=U(e,n,++t,L,a);if(q.type===g)return q.derived=!0,q;t=q.len,k={value:new i.type.Term(p.value,[k.value,q.value]),len:t,type:h}}else break}else break}}else u={type:g,value:i.error.syntax(n[k.len-1],"operator expected")};return k}return k}function Ue(e,n,t,s){if(!n[t]||n[t].name==="atom"&&n[t].raw==="."&&!s&&(n[t].space||!n[t+1]||n[t+1].name!=="l_paren"))return{type:g,derived:!1,value:i.error.syntax(n[t-1],"unfounded token")};var a=n[t],u=[];if(n[t].name==="atom"&&n[t].raw!==","){if(t++,n[t-1].space)return{type:h,len:t,value:new i.type.Term(a.value,u)};if(n[t]&&n[t].name==="l_paren"){if(n[t+1]&&n[t+1].name==="r_paren")return{type:g,derived:!0,value:i.error.syntax(n[t+1],"argument expected")};var p=U(e,n,++t,"999",!0);if(p.type===g)return p.derived?p:{type:g,derived:!0,value:i.error.syntax(n[t]?n[t]:n[t-1],"argument expected",!n[t])};for(u.push(p.value),t=p.len;n[t]&&n[t].name==="atom"&&n[t].value===",";){if(p=U(e,n,t+1,"999",!0),p.type===g)return p.derived?p:{type:g,derived:!0,value:i.error.syntax(n[t+1]?n[t+1]:n[t],"argument expected",!n[t+1])};u.push(p.value),t=p.len}if(n[t]&&n[t].name==="r_paren")t++;else return{type:g,derived:!0,value:i.error.syntax(n[t]?n[t]:n[t-1],", or ) expected",!n[t])}}return{type:h,len:t,value:new i.type.Term(a.value,u)}}return{type:g,derived:!1,value:i.error.syntax(n[t],"term expected")}}function Ze(e,n,t){if(!n[t])return{type:g,derived:!1,value:i.error.syntax(n[t-1],"[ expected")};if(n[t]&&n[t].name==="l_brace"){var s=U(e,n,++t,"999",!0),a=[s.value],u=void 0;if(s.type===g)return n[t]&&n[t].name==="r_brace"?{type:h,len:t+1,value:new i.type.Term("[]",[])}:{type:g,derived:!0,value:i.error.syntax(n[t],"] expected")};for(t=s.len;n[t]&&n[t].name==="atom"&&n[t].value===",";){if(s=U(e,n,t+1,"999",!0),s.type===g)return s.derived?s:{type:g,derived:!0,value:i.error.syntax(n[t+1]?n[t+1]:n[t],"argument expected",!n[t+1])};a.push(s.value),t=s.len}var p=!1;if(n[t]&&n[t].name==="bar"){if(p=!0,s=U(e,n,t+1,"999",!0),s.type===g)return s.derived?s:{type:g,derived:!0,value:i.error.syntax(n[t+1]?n[t+1]:n[t],"argument expected",!n[t+1])};u=s.value,t=s.len}return n[t]&&n[t].name==="r_brace"?{type:h,len:t+1,value:me(a,u)}:{type:g,derived:!0,value:i.error.syntax(n[t]?n[t]:n[t-1],p?"] expected":", or | or ] expected",!n[t])}}return{type:g,derived:!1,value:i.error.syntax(n[t],"list expected")}}function Qe(e,n,t){var s=n[t].line,a=U(e,n,t,e.__get_max_priority(),!1),u=null,p;if(a.type!==g)if(t=a.len,n[t]&&n[t].name==="atom"&&n[t].raw===".")if(t++,i.type.is_term(a.value)){if(a.value.indicator===":-/2"?(u=new i.type.Rule(a.value.args[0],he(a.value.args[1])),p={value:u,len:t,type:h}):a.value.indicator==="-->/2"?(u=Di(new i.type.Rule(a.value.args[0],a.value.args[1]),e),u.body=he(u.body),p={value:u,len:t,type:i.type.is_rule(u)?h:g}):(u=new i.type.Rule(a.value,null),p={value:u,len:t,type:h}),u){var y=u.singleton_variables();y.length>0&&e.throw_warning(i.warning.singleton(y,u.head.indicator,s))}return p}else return{type:g,value:i.error.syntax(n[t],"callable expected")};else return{type:g,value:i.error.syntax(n[t]?n[t]:n[t-1],". or operator expected")};return a}function qi(e,n,t){t=t||{},t.from=t.from?t.from:"$tau-js",t.reconsult=t.reconsult!==void 0?t.reconsult:!0;var s=new ee(e),a={},u;s.new_text(n);var p=0,y=s.get_tokens(p);do{if(y===null||!y[p])break;var d=Qe(e,y,p);if(d.type===g)return new o("throw",[d.value]);if(d.value.body===null&&d.value.head.indicator==="?-/1"){var m=new X(e.session);m.add_goal(d.value.head.args[0]),m.answer(function(O){i.type.is_error(O)?e.throw_warning(O.args[0]):(O===!1||O===null)&&e.throw_warning(i.warning.failed_goal(d.value.head.args[0],d.len))}),p=d.len;var S=!0}else if(d.value.body===null&&d.value.head.indicator===":-/1"){var S=e.run_directive(d.value.head.args[0]);p=d.len,d.value.head.args[0].indicator==="char_conversion/2"&&(y=s.get_tokens(p),p=0)}else{u=d.value.head.indicator,t.reconsult!==!1&&a[u]!==!0&&!e.is_multifile_predicate(u)&&(e.session.rules[u]=w(e.session.rules[u]||[],function(A){return A.dynamic}),a[u]=!0);var S=e.add_rule(d.value,t);p=d.len}if(!S)return S}while(!0);return!0}function $i(e,n){var t=new ee(e);t.new_text(n);var s=0;do{var a=t.get_tokens(s);if(a===null)break;var u=U(e,a,0,e.__get_max_priority(),!1);if(u.type!==g){var p=u.len,y=p;if(a[p]&&a[p].name==="atom"&&a[p].raw===".")e.add_goal(he(u.value));else{var d=a[p];return new o("throw",[i.error.syntax(d||a[p-1],". or operator expected",!d)])}s=u.len+1}else return new o("throw",[u.value])}while(!0);return!0}function Di(e,n){e=e.rename(n);var t=n.next_free_variable(),s=pr(e.body,t,n);return s.error?s.value:(e.body=s.value,e.head.args=e.head.args.concat([t,s.variable]),e.head=new o(e.head.id,e.head.args),e)}function pr(e,n,t){var s;if(i.type.is_term(e)&&e.indicator==="!/0")return{value:e,variable:n,error:!1};if(i.type.is_term(e)&&e.indicator===",/2"){var a=pr(e.args[0],n,t);if(a.error)return a;var u=pr(e.args[1],a.variable,t);return u.error?u:{value:new o(",",[a.value,u.value]),variable:u.variable,error:!1}}else{if(i.type.is_term(e)&&e.indicator==="{}/1")return{value:e.args[0],variable:n,error:!1};if(i.type.is_empty_list(e))return{value:new o("true",[]),variable:n,error:!1};if(i.type.is_list(e)){s=t.next_free_variable();for(var p=e,y;p.indicator==="./2";)y=p,p=p.args[1];return i.type.is_variable(p)?{value:i.error.instantiation("DCG"),variable:n,error:!0}:i.type.is_empty_list(p)?(y.args[1]=s,{value:new o("=",[n,e]),variable:s,error:!1}):{value:i.error.type("list",e,"DCG"),variable:n,error:!0}}else return i.type.is_callable(e)?(s=t.next_free_variable(),e.args=e.args.concat([n,s]),e=new o(e.id,e.args),{value:e,variable:s,error:!1}):{value:i.error.type("callable",e,"DCG"),variable:n,error:!0}}}function he(e){return i.type.is_variable(e)?new o("call",[e]):i.type.is_term(e)&&[",/2",";/2","->/2"].indexOf(e.indicator)!==-1?new o(e.id,[he(e.args[0]),he(e.args[1])]):e}function me(e,n){for(var t=n||new i.type.Term("[]",[]),s=e.length-1;s>=0;s--)t=new i.type.Term(".",[e[s],t]);return t}function Xi(e,n){for(var t=e.length-1;t>=0;t--)e[t]===n&&e.splice(t,1)}function yr(e){for(var n={},t=[],s=0;s<e.length;s++)e[s]in n||(t.push(e[s]),n[e[s]]=!0);return t}function Bi(e,n,t,s){if(e.session.rules[t]!==null){for(var a=0;a<e.session.rules[t].length;a++)if(e.session.rules[t][a]===s){e.session.rules[t].splice(a,1),e.success(n);break}}}function ye(e){return function(n,t,s){var a=s.args[0],u=s.args.slice(1,e);if(i.type.is_variable(a))n.throw_error(i.error.instantiation(n.level));else if(!i.type.is_callable(a))n.throw_error(i.error.type("callable",a,n.level));else{var p=new o(a.id,a.args.concat(u));n.prepend([new V(t.goal.replace(p),t.substitution,t)])}}}function oe(e){for(var n=e.length-1;n>=0;n--)if(e.charAt(n)==="/")return new o("/",[new o(e.substring(0,n)),new E(parseInt(e.substring(n+1)),!1)])}function I(e){this.id=e}function E(e,n){this.is_float=n!==void 0?n:parseInt(e)!==e,this.value=this.is_float?e:parseInt(e)}var Dr=0;function o(e,n,t){this.ref=t||++Dr,this.id=e,this.args=n||[],this.indicator=e+"/"+this.args.length}var Fi=0;function ne(e,n,t,s,a,u){this.id=Fi++,this.stream=e,this.mode=n,this.alias=t,this.type=s!==void 0?s:"text",this.reposition=a!==void 0?a:!0,this.eof_action=u!==void 0?u:"eof_code",this.position=this.mode==="append"?"end_of_stream":0,this.output=this.mode==="write"||this.mode==="append",this.input=this.mode==="read"}function Y(e){e=e||{},this.links=e}function V(e,n,t){n=n||new Y,t=t||null,this.goal=e,this.substitution=n,this.parent=t}function J(e,n,t){this.head=e,this.body=n,this.dynamic=t||!1}function D(e){e=e===void 0||e<=0?1e3:e,this.rules={},this.src_predicates={},this.rename=0,this.modules=[],this.thread=new X(this),this.total_threads=1,this.renamed_variables={},this.public_predicates={},this.multifile_predicates={},this.limit=e,this.streams={user_input:new ne(typeof ie<"u"&&ie.exports?nodejs_user_input:tau_user_input,"read","user_input","text",!1,"reset"),user_output:new ne(typeof ie<"u"&&ie.exports?nodejs_user_output:tau_user_output,"write","user_output","text",!1,"eof_code")},this.file_system=typeof ie<"u"&&ie.exports?nodejs_file_system:tau_file_system,this.standard_input=this.streams.user_input,this.standard_output=this.streams.user_output,this.current_input=this.streams.user_input,this.current_output=this.streams.user_output,this.format_success=function(n){return n.substitution},this.format_error=function(n){return n.goal},this.flag={bounded:i.flag.bounded.value,max_integer:i.flag.max_integer.value,min_integer:i.flag.min_integer.value,integer_rounding_function:i.flag.integer_rounding_function.value,char_conversion:i.flag.char_conversion.value,debug:i.flag.debug.value,max_arity:i.flag.max_arity.value,unknown:i.flag.unknown.value,double_quotes:i.flag.double_quotes.value,occurs_check:i.flag.occurs_check.value,dialect:i.flag.dialect.value,version_data:i.flag.version_data.value,nodejs:i.flag.nodejs.value},this.__loaded_modules=[],this.__char_conversion={},this.__operators={1200:{":-":["fx","xfx"],"-->":["xfx"],"?-":["fx"]},1100:{";":["xfy"]},1050:{"->":["xfy"]},1e3:{",":["xfy"]},900:{"\\+":["fy"]},700:{"=":["xfx"],"\\=":["xfx"],"==":["xfx"],"\\==":["xfx"],"@<":["xfx"],"@=<":["xfx"],"@>":["xfx"],"@>=":["xfx"],"=..":["xfx"],is:["xfx"],"=:=":["xfx"],"=\\=":["xfx"],"<":["xfx"],"=<":["xfx"],">":["xfx"],">=":["xfx"]},600:{":":["xfy"]},500:{"+":["yfx"],"-":["yfx"],"/\\":["yfx"],"\\/":["yfx"]},400:{"*":["yfx"],"/":["yfx"],"//":["yfx"],rem:["yfx"],mod:["yfx"],"<<":["yfx"],">>":["yfx"]},200:{"**":["xfx"],"^":["xfy"],"-":["fy"],"+":["fy"],"\\":["fy"]}}}function X(e){this.epoch=Date.now(),this.session=e,this.session.total_threads++,this.total_steps=0,this.cpu_time=0,this.cpu_time_last=0,this.points=[],this.debugger=!1,this.debugger_states=[],this.level="top_level/0",this.__calls=[],this.current_limit=this.session.limit,this.warnings=[]}function Xr(e,n,t){this.id=e,this.rules=n,this.exports=t,i.module[e]=this}Xr.prototype.exports_predicate=function(e){return this.exports.indexOf(e)!==-1},I.prototype.unify=function(e,n){if(n&&l(e.variables(),this.id)!==-1&&!i.type.is_variable(e))return null;var t={};return t[this.id]=e,new Y(t)},E.prototype.unify=function(e,n){return i.type.is_number(e)&&this.value===e.value&&this.is_float===e.is_float?new Y:null},o.prototype.unify=function(e,n){if(i.type.is_term(e)&&this.indicator===e.indicator){for(var t=new Y,s=0;s<this.args.length;s++){var a=i.unify(this.args[s].apply(t),e.args[s].apply(t),n);if(a===null)return null;for(var u in a.links)t.links[u]=a.links[u];t=t.apply(a)}return t}return null},ne.prototype.unify=function(e,n){return i.type.is_stream(e)&&this.id===e.id?new Y:null},I.prototype.toString=function(e){return this.id},E.prototype.toString=function(e){return this.is_float&&l(this.value.toString(),".")===-1?this.value+".0":this.value.toString()},o.prototype.toString=function(e,n,t){if(e=e||{},e.quoted=e.quoted===void 0?!0:e.quoted,e.ignore_ops=e.ignore_ops===void 0?!1:e.ignore_ops,e.numbervars=e.numbervars===void 0?!1:e.numbervars,n=n===void 0?1200:n,t=t===void 0?"":t,e.numbervars&&this.indicator==="$VAR/1"&&i.type.is_integer(this.args[0])&&this.args[0].value>=0){var s=this.args[0].value,a=Math.floor(s/26),u=s%26;return"ABCDEFGHIJKLMNOPQRSTUVWXYZ"[u]+(a!==0?a:"")}switch(this.indicator){case"[]/0":case"{}/0":case"!/0":return this.id;case"{}/1":return"{"+this.args[0].toString(e)+"}";case"./2":for(var p="["+this.args[0].toString(e),y=this.args[1];y.indicator==="./2";)p+=", "+y.args[0].toString(e),y=y.args[1];return y.indicator!=="[]/0"&&(p+="|"+y.toString(e)),p+="]",p;case",/2":return"("+this.args[0].toString(e)+", "+this.args[1].toString(e)+")";default:var d=this.id,m=e.session?e.session.lookup_operator(this.id,this.args.length):null;if(e.session===void 0||e.ignore_ops||m===null)return e.quoted&&!/^(!|,|;|[a-z][0-9a-zA-Z_]*)$/.test(d)&&d!=="{}"&&d!=="[]"&&(d="'"+N(d)+"'"),d+(this.args.length?"("+c(this.args,function(R){return R.toString(e)}).join(", ")+")":"");var S=m.priority>n.priority||m.priority===n.priority&&(m.class==="xfy"&&this.indicator!==n.indicator||m.class==="yfx"&&this.indicator!==n.indicator||this.indicator===n.indicator&&m.class==="yfx"&&t==="right"||this.indicator===n.indicator&&m.class==="xfy"&&t==="left");m.indicator=this.indicator;var O=S?"(":"",A=S?")":"";return this.args.length===0?"("+this.id+")":["fy","fx"].indexOf(m.class)!==-1?O+d+" "+this.args[0].toString(e,m)+A:["yf","xf"].indexOf(m.class)!==-1?O+this.args[0].toString(e,m)+" "+d+A:O+this.args[0].toString(e,m,"left")+" "+this.id+" "+this.args[1].toString(e,m,"right")+A}},ne.prototype.toString=function(e){return"<stream>("+this.id+")"},Y.prototype.toString=function(e){var n="{";for(var t in this.links)!this.links.hasOwnProperty(t)||(n!=="{"&&(n+=", "),n+=t+"/"+this.links[t].toString(e));return n+="}",n},V.prototype.toString=function(e){return this.goal===null?"<"+this.substitution.toString(e)+">":"<"+this.goal.toString(e)+", "+this.substitution.toString(e)+">"},J.prototype.toString=function(e){return this.body?this.head.toString(e)+" :- "+this.body.toString(e)+".":this.head.toString(e)+"."},D.prototype.toString=function(e){for(var n="",t=0;t<this.modules.length;t++)n+=":- use_module(library("+this.modules[t]+`)).
|
|
`;n+=`
|
|
`;for(key in this.rules)for(t=0;t<this.rules[key].length;t++)n+=this.rules[key][t].toString(e),n+=`
|
|
`;return n},I.prototype.clone=function(){return new I(this.id)},E.prototype.clone=function(){return new E(this.value,this.is_float)},o.prototype.clone=function(){return new o(this.id,c(this.args,function(e){return e.clone()}))},ne.prototype.clone=function(){return new Stram(this.stream,this.mode,this.alias,this.type,this.reposition,this.eof_action)},Y.prototype.clone=function(){var e={};for(var n in this.links)!this.links.hasOwnProperty(n)||(e[n]=this.links[n].clone());return new Y(e)},V.prototype.clone=function(){return new V(this.goal.clone(),this.substitution.clone(),this.parent)},J.prototype.clone=function(){return new J(this.head.clone(),this.body!==null?this.body.clone():null)},I.prototype.equals=function(e){return i.type.is_variable(e)&&this.id===e.id},E.prototype.equals=function(e){return i.type.is_number(e)&&this.value===e.value&&this.is_float===e.is_float},o.prototype.equals=function(e){if(!i.type.is_term(e)||this.indicator!==e.indicator)return!1;for(var n=0;n<this.args.length;n++)if(!this.args[n].equals(e.args[n]))return!1;return!0},ne.prototype.equals=function(e){return i.type.is_stream(e)&&this.id===e.id},Y.prototype.equals=function(e){var n;if(!i.type.is_substitution(e))return!1;for(n in this.links)if(!!this.links.hasOwnProperty(n)&&(!e.links[n]||!this.links[n].equals(e.links[n])))return!1;for(n in e.links)if(!!e.links.hasOwnProperty(n)&&!this.links[n])return!1;return!0},V.prototype.equals=function(e){return i.type.is_state(e)&&this.goal.equals(e.goal)&&this.substitution.equals(e.substitution)&&this.parent===e.parent},J.prototype.equals=function(e){return i.type.is_rule(e)&&this.head.equals(e.head)&&(this.body===null&&e.body===null||this.body!==null&&this.body.equals(e.body))},I.prototype.rename=function(e){return e.get_free_variable(this)},E.prototype.rename=function(e){return this},o.prototype.rename=function(e){return new o(this.id,c(this.args,function(n){return n.rename(e)}))},ne.prototype.rename=function(e){return this},J.prototype.rename=function(e){return new J(this.head.rename(e),this.body!==null?this.body.rename(e):null)},I.prototype.variables=function(){return[this.id]},E.prototype.variables=function(){return[]},o.prototype.variables=function(){return[].concat.apply([],c(this.args,function(e){return e.variables()}))},ne.prototype.variables=function(){return[]},J.prototype.variables=function(){return this.body===null?this.head.variables():this.head.variables().concat(this.body.variables())},I.prototype.apply=function(e){return e.lookup(this.id)?e.lookup(this.id):this},E.prototype.apply=function(e){return this},o.prototype.apply=function(e){if(this.indicator==="./2"){for(var n=[],t=this;t.indicator==="./2";)n.push(t.args[0].apply(e)),t=t.args[1];for(var s=t.apply(e),a=n.length-1;a>=0;a--)s=new o(".",[n[a],s]);return s}return new o(this.id,c(this.args,function(u){return u.apply(e)}),this.ref)},ne.prototype.apply=function(e){return this},J.prototype.apply=function(e){return new J(this.head.apply(e),this.body!==null?this.body.apply(e):null)},Y.prototype.apply=function(e){var n,t={};for(n in this.links)!this.links.hasOwnProperty(n)||(t[n]=this.links[n].apply(e));return new Y(t)},o.prototype.select=function(){for(var e=this;e.indicator===",/2";)e=e.args[0];return e},o.prototype.replace=function(e){return this.indicator===",/2"?this.args[0].indicator===",/2"?new o(",",[this.args[0].replace(e),this.args[1]]):e===null?this.args[1]:new o(",",[e,this.args[1]]):e},o.prototype.search=function(e){if(i.type.is_term(e)&&e.ref!==void 0&&this.ref===e.ref)return!0;for(var n=0;n<this.args.length;n++)if(i.type.is_term(this.args[n])&&this.args[n].search(e))return!0;return!1},D.prototype.get_current_input=function(){return this.current_input},X.prototype.get_current_input=function(){return this.session.get_current_input()},D.prototype.get_current_output=function(){return this.current_output},X.prototype.get_current_output=function(){return this.session.get_current_output()},D.prototype.set_current_input=function(e){this.current_input=e},X.prototype.set_current_input=function(e){return this.session.set_current_input(e)},D.prototype.set_current_output=function(e){this.current_input=e},X.prototype.set_current_output=function(e){return this.session.set_current_output(e)},D.prototype.get_stream_by_alias=function(e){return this.streams[e]},X.prototype.get_stream_by_alias=function(e){return this.session.get_stream_by_alias(e)},D.prototype.file_system_open=function(e,n,t){return this.file_system.open(e,n,t)},X.prototype.file_system_open=function(e,n,t){return this.session.file_system_open(e,n,t)},D.prototype.get_char_conversion=function(e){return this.__char_conversion[e]||e},X.prototype.get_char_conversion=function(e){return this.session.get_char_conversion(e)},D.prototype.parse=function(e){return this.thread.parse(e)},X.prototype.parse=function(e){var n=new ee(this);n.new_text(e);var t=n.get_tokens();if(t===null)return!1;var s=U(this,t,0,this.__get_max_priority(),!1);return s.len!==t.length?!1:{value:s.value,expr:s,tokens:t}},D.prototype.get_flag=function(e){return this.flag[e]},X.prototype.get_flag=function(e){return this.session.get_flag(e)},D.prototype.add_rule=function(e,n){return n=n||{},n.from=n.from?n.from:"$tau-js",this.src_predicates[e.head.indicator]=n.from,this.rules[e.head.indicator]||(this.rules[e.head.indicator]=[]),this.rules[e.head.indicator].push(e),this.public_predicates.hasOwnProperty(e.head.indicator)||(this.public_predicates[e.head.indicator]=!1),!0},X.prototype.add_rule=function(e,n){return this.session.add_rule(e,n)},D.prototype.run_directive=function(e){this.thread.run_directive(e)},X.prototype.run_directive=function(e){return i.type.is_directive(e)?(i.directive[e.indicator](this,e),!0):!1},D.prototype.__get_max_priority=function(){return"1200"},X.prototype.__get_max_priority=function(){return this.session.__get_max_priority()},D.prototype.__get_next_priority=function(e){var n=0;e=parseInt(e);for(var t in this.__operators)if(!!this.__operators.hasOwnProperty(t)){var s=parseInt(t);s>n&&s<e&&(n=s)}return n.toString()},X.prototype.__get_next_priority=function(e){return this.session.__get_next_priority(e)},D.prototype.__lookup_operator_classes=function(e,n){return this.__operators.hasOwnProperty(e)&&this.__operators[e][n]instanceof Array&&this.__operators[e][n]||!1},X.prototype.__lookup_operator_classes=function(e,n){return this.session.__lookup_operator_classes(e,n)},D.prototype.lookup_operator=function(e,n){for(var t in this.__operators)if(this.__operators[t][e]){for(var s=0;s<this.__operators[t][e].length;s++)if(n===0||this.__operators[t][e][s].length===n+1)return{priority:t,class:this.__operators[t][e][s]}}return null},X.prototype.lookup_operator=function(e,n){return this.session.lookup_operator(e,n)},D.prototype.throw_warning=function(e){this.thread.throw_warning(e)},X.prototype.throw_warning=function(e){this.warnings.push(e)},D.prototype.get_warnings=function(){return this.thread.get_warnings()},X.prototype.get_warnings=function(){return this.warnings},D.prototype.add_goal=function(e,n){this.thread.add_goal(e,n)},X.prototype.add_goal=function(e,n,t){t=t||null,n===!0&&(this.points=[]);for(var s=e.variables(),a={},u=0;u<s.length;u++)a[s[u]]=new I(s[u]);this.points.push(new V(e,new Y(a),t))},D.prototype.consult=function(e,n){return this.thread.consult(e,n)},X.prototype.consult=function(e,n){var t="";if(typeof e=="string"){t=e;var s=t.length;if(t.substring(s-3,s)===".pl"&&document.getElementById(t)){var a=document.getElementById(t),u=a.getAttribute("type");u!==null&&u.replace(/ /g,"").toLowerCase()==="text/prolog"&&(t=a.text)}}else if(e.nodeName)switch(e.nodeName.toLowerCase()){case"input":case"textarea":t=e.value;break;default:t=e.innerHTML;break}else return!1;return this.warnings=[],qi(this,t,n)},D.prototype.query=function(e){return this.thread.query(e)},X.prototype.query=function(e){return this.points=[],this.debugger_points=[],$i(this,e)},D.prototype.head_point=function(){return this.thread.head_point()},X.prototype.head_point=function(){return this.points[this.points.length-1]},D.prototype.get_free_variable=function(e){return this.thread.get_free_variable(e)},X.prototype.get_free_variable=function(e){var n=[];if(e.id==="_"||this.session.renamed_variables[e.id]===void 0){for(this.session.rename++,this.points.length>0&&(n=this.head_point().substitution.domain());l(n,i.format_variable(this.session.rename))!==-1;)this.session.rename++;if(e.id==="_")return new I(i.format_variable(this.session.rename));this.session.renamed_variables[e.id]=i.format_variable(this.session.rename)}return new I(this.session.renamed_variables[e.id])},D.prototype.next_free_variable=function(){return this.thread.next_free_variable()},X.prototype.next_free_variable=function(){this.session.rename++;var e=[];for(this.points.length>0&&(e=this.head_point().substitution.domain());l(e,i.format_variable(this.session.rename))!==-1;)this.session.rename++;return new I(i.format_variable(this.session.rename))},D.prototype.is_public_predicate=function(e){return!this.public_predicates.hasOwnProperty(e)||this.public_predicates[e]===!0},X.prototype.is_public_predicate=function(e){return this.session.is_public_predicate(e)},D.prototype.is_multifile_predicate=function(e){return this.multifile_predicates.hasOwnProperty(e)&&this.multifile_predicates[e]===!0},X.prototype.is_multifile_predicate=function(e){return this.session.is_multifile_predicate(e)},D.prototype.prepend=function(e){return this.thread.prepend(e)},X.prototype.prepend=function(e){for(var n=e.length-1;n>=0;n--)this.points.push(e[n])},D.prototype.success=function(e,n){return this.thread.success(e,n)},X.prototype.success=function(e,t){var t=typeof t>"u"?e:t;this.prepend([new V(e.goal.replace(null),e.substitution,t)])},D.prototype.throw_error=function(e){return this.thread.throw_error(e)},X.prototype.throw_error=function(e){this.prepend([new V(new o("throw",[e]),new Y,null,null)])},D.prototype.step_rule=function(e,n){return this.thread.step_rule(e,n)},X.prototype.step_rule=function(e,n){var t=n.indicator;if(e==="user"&&(e=null),e===null&&this.session.rules.hasOwnProperty(t))return this.session.rules[t];for(var s=e===null?this.session.modules:l(this.session.modules,e)===-1?[]:[e],a=0;a<s.length;a++){var u=i.module[s[a]];if(u.rules.hasOwnProperty(t)&&(u.rules.hasOwnProperty(this.level)||u.exports_predicate(t)))return i.module[s[a]].rules[t]}return null},D.prototype.step=function(){return this.thread.step()},X.prototype.step=function(){if(this.points.length!==0){var e=!1,n=this.points.pop();if(this.debugger&&this.debugger_states.push(n),i.type.is_term(n.goal)){var t=n.goal.select(),s=null,a=[];if(t!==null){this.total_steps++;for(var u=n;u.parent!==null&&u.parent.goal.search(t);)u=u.parent;if(this.level=u.parent===null?"top_level/0":u.parent.goal.select().indicator,i.type.is_term(t)&&t.indicator===":/2"&&(s=t.args[0].id,t=t.args[1]),s===null&&i.type.is_builtin(t))this.__call_indicator=t.indicator,e=i.predicate[t.indicator](this,n,t);else{var p=this.step_rule(s,t);if(p===null)this.session.rules.hasOwnProperty(t.indicator)||(this.get_flag("unknown").id==="error"?this.throw_error(i.error.existence("procedure",t.indicator,this.level)):this.get_flag("unknown").id==="warning"&&this.throw_warning("unknown procedure "+t.indicator+" (from "+this.level+")"));else if(p instanceof Function)e=p(this,n,t);else{for(var y in p)if(!!p.hasOwnProperty(y)){var d=p[y];this.session.renamed_variables={},d=d.rename(this);var m=this.get_flag("occurs_check").indicator==="true/0",S=new V,O=i.unify(t,d.head,m);O!==null&&(S.goal=n.goal.replace(d.body),S.goal!==null&&(S.goal=S.goal.apply(O)),S.substitution=n.substitution.apply(O),S.parent=n,a.push(S))}this.prepend(a)}}}}else i.type.is_variable(n.goal)?this.throw_error(i.error.instantiation(this.level)):this.throw_error(i.error.type("callable",n.goal,this.level));return e}},D.prototype.answer=function(e){return this.thread.answer(e)},X.prototype.answer=function(e){e=e||function(n){},this.__calls.push(e),!(this.__calls.length>1)&&this.again()},D.prototype.answers=function(e,n,t){return this.thread.answers(e,n,t)},X.prototype.answers=function(e,n,t){var s=n||1e3,a=this;if(n<=0){t&&t();return}this.answer(function(u){e(u),u!==!1?setTimeout(function(){a.answers(e,n-1,t)},1):t&&t()})},D.prototype.again=function(e){return this.thread.again(e)},X.prototype.again=function(e){for(var n,t=Date.now();this.__calls.length>0;){for(this.warnings=[],e!==!1&&(this.current_limit=this.session.limit);this.current_limit>0&&this.points.length>0&&this.head_point().goal!==null&&!i.type.is_error(this.head_point().goal);)if(this.current_limit--,this.step()===!0)return;var s=Date.now();this.cpu_time_last=s-t,this.cpu_time+=this.cpu_time_last;var a=this.__calls.shift();this.current_limit<=0?a(null):this.points.length===0?a(!1):i.type.is_error(this.head_point().goal)?(n=this.session.format_error(this.points.pop()),this.points=[],a(n)):(this.debugger&&this.debugger_states.push(this.head_point()),n=this.session.format_success(this.points.pop()),a(n))}},D.prototype.unfold=function(e){if(e.body===null)return!1;var n=e.head,t=e.body,s=t.select(),a=new X(this),u=[];a.add_goal(s),a.step();for(var p=a.points.length-1;p>=0;p--){var y=a.points[p],d=n.apply(y.substitution),m=t.replace(y.goal);m!==null&&(m=m.apply(y.substitution)),u.push(new J(d,m))}var S=this.rules[n.indicator],O=l(S,e);return u.length>0&&O!==-1?(S.splice.apply(S,[O,1].concat(u)),!0):!1},X.prototype.unfold=function(e){return this.session.unfold(e)},I.prototype.interpret=function(e){return i.error.instantiation(e.level)},E.prototype.interpret=function(e){return this},o.prototype.interpret=function(e){return i.type.is_unitary_list(this)?this.args[0].interpret(e):i.operate(e,this)},I.prototype.compare=function(e){return this.id<e.id?-1:this.id>e.id?1:0},E.prototype.compare=function(e){if(this.value===e.value&&this.is_float===e.is_float)return 0;if(this.value<e.value||this.value===e.value&&this.is_float&&!e.is_float)return-1;if(this.value>e.value)return 1},o.prototype.compare=function(e){if(this.args.length<e.args.length||this.args.length===e.args.length&&this.id<e.id)return-1;if(this.args.length>e.args.length||this.args.length===e.args.length&&this.id>e.id)return 1;for(var n=0;n<this.args.length;n++){var t=i.compare(this.args[n],e.args[n]);if(t!==0)return t}return 0},Y.prototype.lookup=function(e){return this.links[e]?this.links[e]:null},Y.prototype.filter=function(e){var n={};for(var t in this.links)if(!!this.links.hasOwnProperty(t)){var s=this.links[t];e(t,s)&&(n[t]=s)}return new Y(n)},Y.prototype.exclude=function(e){var n={};for(var t in this.links)!this.links.hasOwnProperty(t)||l(e,t)===-1&&(n[t]=this.links[t]);return new Y(n)},Y.prototype.add=function(e,n){this.links[e]=n},Y.prototype.domain=function(e){var n=e===!0?function(a){return a}:function(a){return new I(a)},t=[];for(var s in this.links)t.push(n(s));return t},I.prototype.compile=function(){return'new pl.type.Var("'+this.id.toString()+'")'},E.prototype.compile=function(){return"new pl.type.Num("+this.value.toString()+", "+this.is_float.toString()+")"},o.prototype.compile=function(){return'new pl.type.Term("'+this.id.replace(/"/g,'\\"')+'", ['+c(this.args,function(e){return e.compile()})+"])"},J.prototype.compile=function(){return"new pl.type.Rule("+this.head.compile()+", "+(this.body===null?"null":this.body.compile())+")"},D.prototype.compile=function(){var e,n=[],t;for(var s in this.rules)if(!!this.rules.hasOwnProperty(s)){var a=this.rules[s];t=[],e='"'+s+'": [';for(var u=0;u<a.length;u++)t.push(a[u].compile());e+=t.join(),e+="]",n.push(e)}return"{"+n.join()+"};"},I.prototype.toJavaScript=function(){},E.prototype.toJavaScript=function(){return this.value},o.prototype.toJavaScript=function(){if(this.args.length===0&&this.indicator!=="[]/0")return this.id;if(i.type.is_list(this)){for(var e=[],n=this,t;n.indicator==="./2";){if(t=n.args[0].toJavaScript(),t===void 0)return;e.push(t),n=n.args[1]}if(n.indicator==="[]/0")return e}},J.prototype.singleton_variables=function(){var e=this.head.variables(),n={},t=[];this.body!==null&&(e=e.concat(this.body.variables()));for(var s=0;s<e.length;s++)n[e[s]]===void 0&&(n[e[s]]=0),n[e[s]]++;for(var a in n)a!=="_"&&n[a]===1&&t.push(a);return t};var i={__env:typeof ie<"u"&&ie.exports?global:window,module:{},version:r,parser:{tokenizer:ee,expression:U},utils:{str_indicator:oe,codePointAt:_,fromCodePoint:v},statistics:{getCountTerms:function(){return Dr}},fromJavaScript:{test:{boolean:function(e){return e===!0||e===!1},number:function(e){return typeof e=="number"},string:function(e){return typeof e=="string"},list:function(e){return e instanceof Array},variable:function(e){return e===void 0},any:function(e){return!0}},conversion:{boolean:function(e){return new o(e?"true":"false",[])},number:function(e){return new E(e,e%1!==0)},string:function(e){return new o(e,[])},list:function(e){for(var n=[],t,s=0;s<e.length;s++){if(t=i.fromJavaScript.apply(e[s]),t===void 0)return;n.push(t)}return me(n)},variable:function(e){return new I("_")},any:function(e){}},apply:function(e){for(var n in i.fromJavaScript.test)if(n!=="any"&&i.fromJavaScript.test[n](e))return i.fromJavaScript.conversion[n](e);return i.fromJavaScript.conversion.any(e)}},type:{Var:I,Num:E,Term:o,Rule:J,State:V,Stream:ne,Module:Xr,Thread:X,Session:D,Substitution:Y,order:[I,E,o,ne],compare:function(e,n){var t=l(i.type.order,e.constructor),s=l(i.type.order,n.constructor);if(t<s)return-1;if(t>s)return 1;if(e.constructor===E){if(e.is_float&&n.is_float)return 0;if(e.is_float)return-1;if(n.is_float)return 1}return 0},is_substitution:function(e){return e instanceof Y},is_state:function(e){return e instanceof V},is_rule:function(e){return e instanceof J},is_variable:function(e){return e instanceof I},is_stream:function(e){return e instanceof ne},is_anonymous_var:function(e){return e instanceof I&&e.id==="_"},is_callable:function(e){return e instanceof o},is_number:function(e){return e instanceof E},is_integer:function(e){return e instanceof E&&!e.is_float},is_float:function(e){return e instanceof E&&e.is_float},is_term:function(e){return e instanceof o},is_atom:function(e){return e instanceof o&&e.args.length===0},is_ground:function(e){if(e instanceof I)return!1;if(e instanceof o){for(var n=0;n<e.args.length;n++)if(!i.type.is_ground(e.args[n]))return!1}return!0},is_atomic:function(e){return e instanceof o&&e.args.length===0||e instanceof E},is_compound:function(e){return e instanceof o&&e.args.length>0},is_list:function(e){return e instanceof o&&(e.indicator==="[]/0"||e.indicator==="./2")},is_empty_list:function(e){return e instanceof o&&e.indicator==="[]/0"},is_non_empty_list:function(e){return e instanceof o&&e.indicator==="./2"},is_fully_list:function(e){for(;e instanceof o&&e.indicator==="./2";)e=e.args[1];return e instanceof I||e instanceof o&&e.indicator==="[]/0"},is_instantiated_list:function(e){for(;e instanceof o&&e.indicator==="./2";)e=e.args[1];return e instanceof o&&e.indicator==="[]/0"},is_unitary_list:function(e){return e instanceof o&&e.indicator==="./2"&&e.args[1]instanceof o&&e.args[1].indicator==="[]/0"},is_character:function(e){return e instanceof o&&(e.id.length===1||e.id.length>0&&e.id.length<=2&&_(e.id,0)>=65536)},is_character_code:function(e){return e instanceof E&&!e.is_float&&e.value>=0&&e.value<=1114111},is_byte:function(e){return e instanceof E&&!e.is_float&&e.value>=0&&e.value<=255},is_operator:function(e){return e instanceof o&&i.arithmetic.evaluation[e.indicator]},is_directive:function(e){return e instanceof o&&i.directive[e.indicator]!==void 0},is_builtin:function(e){return e instanceof o&&i.predicate[e.indicator]!==void 0},is_error:function(e){return e instanceof o&&e.indicator==="throw/1"},is_predicate_indicator:function(e){return e instanceof o&&e.indicator==="//2"&&e.args[0]instanceof o&&e.args[0].args.length===0&&e.args[1]instanceof E&&e.args[1].is_float===!1},is_flag:function(e){return e instanceof o&&e.args.length===0&&i.flag[e.id]!==void 0},is_value_flag:function(e,n){if(!i.type.is_flag(e))return!1;for(var t in i.flag[e.id].allowed)if(!!i.flag[e.id].allowed.hasOwnProperty(t)&&i.flag[e.id].allowed[t].equals(n))return!0;return!1},is_io_mode:function(e){return i.type.is_atom(e)&&["read","write","append"].indexOf(e.id)!==-1},is_stream_option:function(e){return i.type.is_term(e)&&(e.indicator==="alias/1"&&i.type.is_atom(e.args[0])||e.indicator==="reposition/1"&&i.type.is_atom(e.args[0])&&(e.args[0].id==="true"||e.args[0].id==="false")||e.indicator==="type/1"&&i.type.is_atom(e.args[0])&&(e.args[0].id==="text"||e.args[0].id==="binary")||e.indicator==="eof_action/1"&&i.type.is_atom(e.args[0])&&(e.args[0].id==="error"||e.args[0].id==="eof_code"||e.args[0].id==="reset"))},is_stream_position:function(e){return i.type.is_integer(e)&&e.value>=0||i.type.is_atom(e)&&(e.id==="end_of_stream"||e.id==="past_end_of_stream")},is_stream_property:function(e){return i.type.is_term(e)&&(e.indicator==="input/0"||e.indicator==="output/0"||e.indicator==="alias/1"&&(i.type.is_variable(e.args[0])||i.type.is_atom(e.args[0]))||e.indicator==="file_name/1"&&(i.type.is_variable(e.args[0])||i.type.is_atom(e.args[0]))||e.indicator==="position/1"&&(i.type.is_variable(e.args[0])||i.type.is_stream_position(e.args[0]))||e.indicator==="reposition/1"&&(i.type.is_variable(e.args[0])||i.type.is_atom(e.args[0])&&(e.args[0].id==="true"||e.args[0].id==="false"))||e.indicator==="type/1"&&(i.type.is_variable(e.args[0])||i.type.is_atom(e.args[0])&&(e.args[0].id==="text"||e.args[0].id==="binary"))||e.indicator==="mode/1"&&(i.type.is_variable(e.args[0])||i.type.is_atom(e.args[0])&&(e.args[0].id==="read"||e.args[0].id==="write"||e.args[0].id==="append"))||e.indicator==="eof_action/1"&&(i.type.is_variable(e.args[0])||i.type.is_atom(e.args[0])&&(e.args[0].id==="error"||e.args[0].id==="eof_code"||e.args[0].id==="reset"))||e.indicator==="end_of_stream/1"&&(i.type.is_variable(e.args[0])||i.type.is_atom(e.args[0])&&(e.args[0].id==="at"||e.args[0].id==="past"||e.args[0].id==="not")))},is_streamable:function(e){return e.__proto__.stream!==void 0},is_read_option:function(e){return i.type.is_term(e)&&["variables/1","variable_names/1","singletons/1"].indexOf(e.indicator)!==-1},is_write_option:function(e){return i.type.is_term(e)&&(e.indicator==="quoted/1"&&i.type.is_atom(e.args[0])&&(e.args[0].id==="true"||e.args[0].id==="false")||e.indicator==="ignore_ops/1"&&i.type.is_atom(e.args[0])&&(e.args[0].id==="true"||e.args[0].id==="false")||e.indicator==="numbervars/1"&&i.type.is_atom(e.args[0])&&(e.args[0].id==="true"||e.args[0].id==="false"))},is_close_option:function(e){return i.type.is_term(e)&&e.indicator==="force/1"&&i.type.is_atom(e.args[0])&&(e.args[0].id==="true"||e.args[0].id==="false")},is_modifiable_flag:function(e){return i.type.is_flag(e)&&i.flag[e.id].changeable},is_module:function(e){return e instanceof o&&e.indicator==="library/1"&&e.args[0]instanceof o&&e.args[0].args.length===0&&i.module[e.args[0].id]!==void 0}},arithmetic:{evaluation:{"e/0":{type_args:null,type_result:!0,fn:function(e){return Math.E}},"pi/0":{type_args:null,type_result:!0,fn:function(e){return Math.PI}},"tau/0":{type_args:null,type_result:!0,fn:function(e){return 2*Math.PI}},"epsilon/0":{type_args:null,type_result:!0,fn:function(e){return Number.EPSILON}},"+/1":{type_args:null,type_result:null,fn:function(e,n){return e}},"-/1":{type_args:null,type_result:null,fn:function(e,n){return-e}},"\\/1":{type_args:!1,type_result:!1,fn:function(e,n){return~e}},"abs/1":{type_args:null,type_result:null,fn:function(e,n){return Math.abs(e)}},"sign/1":{type_args:null,type_result:null,fn:function(e,n){return Math.sign(e)}},"float_integer_part/1":{type_args:!0,type_result:!1,fn:function(e,n){return parseInt(e)}},"float_fractional_part/1":{type_args:!0,type_result:!0,fn:function(e,n){return e-parseInt(e)}},"float/1":{type_args:null,type_result:!0,fn:function(e,n){return parseFloat(e)}},"floor/1":{type_args:!0,type_result:!1,fn:function(e,n){return Math.floor(e)}},"truncate/1":{type_args:!0,type_result:!1,fn:function(e,n){return parseInt(e)}},"round/1":{type_args:!0,type_result:!1,fn:function(e,n){return Math.round(e)}},"ceiling/1":{type_args:!0,type_result:!1,fn:function(e,n){return Math.ceil(e)}},"sin/1":{type_args:null,type_result:!0,fn:function(e,n){return Math.sin(e)}},"cos/1":{type_args:null,type_result:!0,fn:function(e,n){return Math.cos(e)}},"tan/1":{type_args:null,type_result:!0,fn:function(e,n){return Math.tan(e)}},"asin/1":{type_args:null,type_result:!0,fn:function(e,n){return Math.asin(e)}},"acos/1":{type_args:null,type_result:!0,fn:function(e,n){return Math.acos(e)}},"atan/1":{type_args:null,type_result:!0,fn:function(e,n){return Math.atan(e)}},"atan2/2":{type_args:null,type_result:!0,fn:function(e,n,t){return Math.atan2(e,n)}},"exp/1":{type_args:null,type_result:!0,fn:function(e,n){return Math.exp(e)}},"sqrt/1":{type_args:null,type_result:!0,fn:function(e,n){return Math.sqrt(e)}},"log/1":{type_args:null,type_result:!0,fn:function(e,n){return e>0?Math.log(e):i.error.evaluation("undefined",n.__call_indicator)}},"+/2":{type_args:null,type_result:null,fn:function(e,n,t){return e+n}},"-/2":{type_args:null,type_result:null,fn:function(e,n,t){return e-n}},"*/2":{type_args:null,type_result:null,fn:function(e,n,t){return e*n}},"//2":{type_args:null,type_result:!0,fn:function(e,n,t){return n?e/n:i.error.evaluation("zero_division",t.__call_indicator)}},"///2":{type_args:!1,type_result:!1,fn:function(e,n,t){return n?parseInt(e/n):i.error.evaluation("zero_division",t.__call_indicator)}},"**/2":{type_args:null,type_result:!0,fn:function(e,n,t){return Math.pow(e,n)}},"^/2":{type_args:null,type_result:null,fn:function(e,n,t){return Math.pow(e,n)}},"<</2":{type_args:!1,type_result:!1,fn:function(e,n,t){return e<<n}},">>/2":{type_args:!1,type_result:!1,fn:function(e,n,t){return e>>n}},"/\\/2":{type_args:!1,type_result:!1,fn:function(e,n,t){return e&n}},"\\//2":{type_args:!1,type_result:!1,fn:function(e,n,t){return e|n}},"xor/2":{type_args:!1,type_result:!1,fn:function(e,n,t){return e^n}},"rem/2":{type_args:!1,type_result:!1,fn:function(e,n,t){return n?e%n:i.error.evaluation("zero_division",t.__call_indicator)}},"mod/2":{type_args:!1,type_result:!1,fn:function(e,n,t){return n?e-parseInt(e/n)*n:i.error.evaluation("zero_division",t.__call_indicator)}},"max/2":{type_args:null,type_result:null,fn:function(e,n,t){return Math.max(e,n)}},"min/2":{type_args:null,type_result:null,fn:function(e,n,t){return Math.min(e,n)}}}},directive:{"dynamic/1":function(e,n){var t=n.args[0];if(i.type.is_variable(t))e.throw_error(i.error.instantiation(n.indicator));else if(!i.type.is_compound(t)||t.indicator!=="//2")e.throw_error(i.error.type("predicate_indicator",t,n.indicator));else if(i.type.is_variable(t.args[0])||i.type.is_variable(t.args[1]))e.throw_error(i.error.instantiation(n.indicator));else if(!i.type.is_atom(t.args[0]))e.throw_error(i.error.type("atom",t.args[0],n.indicator));else if(!i.type.is_integer(t.args[1]))e.throw_error(i.error.type("integer",t.args[1],n.indicator));else{var s=n.args[0].args[0].id+"/"+n.args[0].args[1].value;e.session.public_predicates[s]=!0,e.session.rules[s]||(e.session.rules[s]=[])}},"multifile/1":function(e,n){var t=n.args[0];i.type.is_variable(t)?e.throw_error(i.error.instantiation(n.indicator)):!i.type.is_compound(t)||t.indicator!=="//2"?e.throw_error(i.error.type("predicate_indicator",t,n.indicator)):i.type.is_variable(t.args[0])||i.type.is_variable(t.args[1])?e.throw_error(i.error.instantiation(n.indicator)):i.type.is_atom(t.args[0])?i.type.is_integer(t.args[1])?e.session.multifile_predicates[n.args[0].args[0].id+"/"+n.args[0].args[1].value]=!0:e.throw_error(i.error.type("integer",t.args[1],n.indicator)):e.throw_error(i.error.type("atom",t.args[0],n.indicator))},"set_prolog_flag/2":function(e,n){var t=n.args[0],s=n.args[1];i.type.is_variable(t)||i.type.is_variable(s)?e.throw_error(i.error.instantiation(n.indicator)):i.type.is_atom(t)?i.type.is_flag(t)?i.type.is_value_flag(t,s)?i.type.is_modifiable_flag(t)?e.session.flag[t.id]=s:e.throw_error(i.error.permission("modify","flag",t)):e.throw_error(i.error.domain("flag_value",new o("+",[t,s]),n.indicator)):e.throw_error(i.error.domain("prolog_flag",t,n.indicator)):e.throw_error(i.error.type("atom",t,n.indicator))},"use_module/1":function(e,n){var t=n.args[0];if(i.type.is_variable(t))e.throw_error(i.error.instantiation(n.indicator));else if(!i.type.is_term(t))e.throw_error(i.error.type("term",t,n.indicator));else if(i.type.is_module(t)){var s=t.args[0].id;l(e.session.modules,s)===-1&&e.session.modules.push(s)}},"char_conversion/2":function(e,n){var t=n.args[0],s=n.args[1];i.type.is_variable(t)||i.type.is_variable(s)?e.throw_error(i.error.instantiation(n.indicator)):i.type.is_character(t)?i.type.is_character(s)?t.id===s.id?delete e.session.__char_conversion[t.id]:e.session.__char_conversion[t.id]=s.id:e.throw_error(i.error.type("character",s,n.indicator)):e.throw_error(i.error.type("character",t,n.indicator))},"op/3":function(e,n){var t=n.args[0],s=n.args[1],a=n.args[2];if(i.type.is_variable(t)||i.type.is_variable(s)||i.type.is_variable(a))e.throw_error(i.error.instantiation(n.indicator));else if(!i.type.is_integer(t))e.throw_error(i.error.type("integer",t,n.indicator));else if(!i.type.is_atom(s))e.throw_error(i.error.type("atom",s,n.indicator));else if(!i.type.is_atom(a))e.throw_error(i.error.type("atom",a,n.indicator));else if(t.value<0||t.value>1200)e.throw_error(i.error.domain("operator_priority",t,n.indicator));else if(a.id===",")e.throw_error(i.error.permission("modify","operator",a,n.indicator));else if(a.id==="|"&&(t.value<1001||s.id.length!==3))e.throw_error(i.error.permission("modify","operator",a,n.indicator));else if(["fy","fx","yf","xf","xfx","yfx","xfy"].indexOf(s.id)===-1)e.throw_error(i.error.domain("operator_specifier",s,n.indicator));else{var u={prefix:null,infix:null,postfix:null};for(var p in e.session.__operators)if(!!e.session.__operators.hasOwnProperty(p)){var y=e.session.__operators[p][a.id];y&&(l(y,"fx")!==-1&&(u.prefix={priority:p,type:"fx"}),l(y,"fy")!==-1&&(u.prefix={priority:p,type:"fy"}),l(y,"xf")!==-1&&(u.postfix={priority:p,type:"xf"}),l(y,"yf")!==-1&&(u.postfix={priority:p,type:"yf"}),l(y,"xfx")!==-1&&(u.infix={priority:p,type:"xfx"}),l(y,"xfy")!==-1&&(u.infix={priority:p,type:"xfy"}),l(y,"yfx")!==-1&&(u.infix={priority:p,type:"yfx"}))}var d;switch(s.id){case"fy":case"fx":d="prefix";break;case"yf":case"xf":d="postfix";break;default:d="infix";break}if(((u.prefix&&d==="prefix"||u.postfix&&d==="postfix"||u.infix&&d==="infix")&&u[d].type!==s.id||u.infix&&d==="postfix"||u.postfix&&d==="infix")&&t.value!==0)e.throw_error(i.error.permission("create","operator",a,n.indicator));else return u[d]&&(Xi(e.session.__operators[u[d].priority][a.id],s.id),e.session.__operators[u[d].priority][a.id].length===0&&delete e.session.__operators[u[d].priority][a.id]),t.value>0&&(e.session.__operators[t.value]||(e.session.__operators[t.value.toString()]={}),e.session.__operators[t.value][a.id]||(e.session.__operators[t.value][a.id]=[]),e.session.__operators[t.value][a.id].push(s.id)),!0}}},predicate:{"op/3":function(e,n,t){i.directive["op/3"](e,t)&&e.success(n)},"current_op/3":function(e,n,t){var s=t.args[0],a=t.args[1],u=t.args[2],p=[];for(var y in e.session.__operators)for(var d in e.session.__operators[y])for(var m=0;m<e.session.__operators[y][d].length;m++)p.push(new V(n.goal.replace(new o(",",[new o("=",[new E(y,!1),s]),new o(",",[new o("=",[new o(e.session.__operators[y][d][m],[]),a]),new o("=",[new o(d,[]),u])])])),n.substitution,n));e.prepend(p)},";/2":function(e,n,t){if(i.type.is_term(t.args[0])&&t.args[0].indicator==="->/2"){var s=e.points,a=e.session.format_success,u=e.session.format_error;e.session.format_success=function(m){return m.substitution},e.session.format_error=function(m){return m.goal},e.points=[new V(t.args[0].args[0],n.substitution,n)];var p=function(m){e.points=s,e.session.format_success=a,e.session.format_error=u,m===!1?e.prepend([new V(n.goal.replace(t.args[1]),n.substitution,n)]):i.type.is_error(m)?e.throw_error(m.args[0]):m===null?(e.prepend([n]),e.__calls.shift()(null)):e.prepend([new V(n.goal.replace(t.args[0].args[1]).apply(m),n.substitution.apply(m),n)])};e.__calls.unshift(p)}else{var y=new V(n.goal.replace(t.args[0]),n.substitution,n),d=new V(n.goal.replace(t.args[1]),n.substitution,n);e.prepend([y,d])}},"!/0":function(e,n,t){var s,a,u=[];for(s=n,a=null;s.parent!==null&&s.parent.goal.search(t);)if(a=s,s=s.parent,s.goal!==null){var p=s.goal.select();if(p&&p.id==="call"&&p.search(t)){s=a;break}}for(var y=e.points.length-1;y>=0;y--){for(var d=e.points[y],m=d.parent;m!==null&&m!==s.parent;)m=m.parent;m===null&&m!==s.parent&&u.push(d)}e.points=u.reverse(),e.success(n)},"\\+/1":function(e,n,t){var s=t.args[0];i.type.is_variable(s)?e.throw_error(i.error.instantiation(e.level)):i.type.is_callable(s)?e.prepend([new V(n.goal.replace(new o(",",[new o(",",[new o("call",[s]),new o("!",[])]),new o("fail",[])])),n.substitution,n),new V(n.goal.replace(null),n.substitution,n)]):e.throw_error(i.error.type("callable",s,e.level))},"->/2":function(e,n,t){var s=n.goal.replace(new o(",",[t.args[0],new o(",",[new o("!"),t.args[1]])]));e.prepend([new V(s,n.substitution,n)])},"fail/0":function(e,n,t){},"false/0":function(e,n,t){},"true/0":function(e,n,t){e.success(n)},"call/1":ye(1),"call/2":ye(2),"call/3":ye(3),"call/4":ye(4),"call/5":ye(5),"call/6":ye(6),"call/7":ye(7),"call/8":ye(8),"once/1":function(e,n,t){var s=t.args[0];e.prepend([new V(n.goal.replace(new o(",",[new o("call",[s]),new o("!",[])])),n.substitution,n)])},"forall/2":function(e,n,t){var s=t.args[0],a=t.args[1];e.prepend([new V(n.goal.replace(new o("\\+",[new o(",",[new o("call",[s]),new o("\\+",[new o("call",[a])])])])),n.substitution,n)])},"repeat/0":function(e,n,t){e.prepend([new V(n.goal.replace(null),n.substitution,n),n])},"throw/1":function(e,n,t){i.type.is_variable(t.args[0])?e.throw_error(i.error.instantiation(e.level)):e.throw_error(t.args[0])},"catch/3":function(e,n,t){var s=e.points;e.points=[],e.prepend([new V(t.args[0],n.substitution,n)]);var a=e.session.format_success,u=e.session.format_error;e.session.format_success=function(y){return y.substitution},e.session.format_error=function(y){return y.goal};var p=function(y){var d=e.points;if(e.points=s,e.session.format_success=a,e.session.format_error=u,i.type.is_error(y)){for(var m=[],S=e.points.length-1;S>=0;S--){for(var R=e.points[S],O=R.parent;O!==null&&O!==n.parent;)O=O.parent;O===null&&O!==n.parent&&m.push(R)}e.points=m;var A=e.get_flag("occurs_check").indicator==="true/0",R=new V,k=i.unify(y.args[0],t.args[1],A);k!==null?(R.substitution=n.substitution.apply(k),R.goal=n.goal.replace(t.args[2]).apply(k),R.parent=n,e.prepend([R])):e.throw_error(y.args[0])}else if(y!==!1){for(var L=y===null?[]:[new V(n.goal.apply(y).replace(null),n.substitution.apply(y),n)],B=[],S=d.length-1;S>=0;S--){B.push(d[S]);var q=d[S].goal!==null?d[S].goal.select():null;if(i.type.is_term(q)&&q.indicator==="!/0")break}var F=c(B,function(H){return H.goal===null&&(H.goal=new o("true",[])),H=new V(n.goal.replace(new o("catch",[H.goal,t.args[1],t.args[2]])),n.substitution.apply(H.substitution),H.parent),H.exclude=t.args[0].variables(),H}).reverse();e.prepend(F),e.prepend(L),y===null&&(this.current_limit=0,e.__calls.shift()(null))}};e.__calls.unshift(p)},"=/2":function(e,n,t){var s=e.get_flag("occurs_check").indicator==="true/0",a=new V,u=i.unify(t.args[0],t.args[1],s);u!==null&&(a.goal=n.goal.apply(u).replace(null),a.substitution=n.substitution.apply(u),a.parent=n,e.prepend([a]))},"unify_with_occurs_check/2":function(e,n,t){var s=new V,a=i.unify(t.args[0],t.args[1],!0);a!==null&&(s.goal=n.goal.apply(a).replace(null),s.substitution=n.substitution.apply(a),s.parent=n,e.prepend([s]))},"\\=/2":function(e,n,t){var s=e.get_flag("occurs_check").indicator==="true/0",a=i.unify(t.args[0],t.args[1],s);a===null&&e.success(n)},"subsumes_term/2":function(e,n,t){var s=e.get_flag("occurs_check").indicator==="true/0",a=i.unify(t.args[1],t.args[0],s);a!==null&&t.args[1].apply(a).equals(t.args[1])&&e.success(n)},"findall/3":function(e,n,t){var s=t.args[0],a=t.args[1],u=t.args[2];if(i.type.is_variable(a))e.throw_error(i.error.instantiation(t.indicator));else if(!i.type.is_callable(a))e.throw_error(i.error.type("callable",a,t.indicator));else if(!i.type.is_variable(u)&&!i.type.is_list(u))e.throw_error(i.error.type("list",u,t.indicator));else{var p=e.next_free_variable(),y=new o(",",[a,new o("=",[p,s])]),d=e.points,m=e.session.limit,S=e.session.format_success;e.session.format_success=function(R){return R.substitution},e.add_goal(y,!0,n);var O=[],A=function(R){if(R!==!1&&R!==null&&!i.type.is_error(R))e.__calls.unshift(A),O.push(R.links[p.id]),e.session.limit=e.current_limit;else if(e.points=d,e.session.limit=m,e.session.format_success=S,i.type.is_error(R))e.throw_error(R.args[0]);else if(e.current_limit>0){for(var k=new o("[]"),L=O.length-1;L>=0;L--)k=new o(".",[O[L],k]);e.prepend([new V(n.goal.replace(new o("=",[u,k])),n.substitution,n)])}};e.__calls.unshift(A)}},"bagof/3":function(e,n,t){var s,a=t.args[0],u=t.args[1],p=t.args[2];if(i.type.is_variable(u))e.throw_error(i.error.instantiation(t.indicator));else if(!i.type.is_callable(u))e.throw_error(i.error.type("callable",u,t.indicator));else if(!i.type.is_variable(p)&&!i.type.is_list(p))e.throw_error(i.error.type("list",p,t.indicator));else{var y=e.next_free_variable(),d;u.indicator==="^/2"?(d=u.args[0].variables(),u=u.args[1]):d=[],d=d.concat(a.variables());for(var m=u.variables().filter(function(F){return l(d,F)===-1}),S=new o("[]"),O=m.length-1;O>=0;O--)S=new o(".",[new I(m[O]),S]);var A=new o(",",[u,new o("=",[y,new o(",",[S,a])])]),R=e.points,k=e.session.limit,L=e.session.format_success;e.session.format_success=function(F){return F.substitution},e.add_goal(A,!0,n);var B=[],q=function(F){if(F!==!1&&F!==null&&!i.type.is_error(F)){e.__calls.unshift(q);var H=!1,K=F.links[y.id].args[0],be=F.links[y.id].args[1];for(var Te in B)if(!!B.hasOwnProperty(Te)){var Xe=B[Te];if(Xe.variables.equals(K)){Xe.answers.push(be),H=!0;break}}H||B.push({variables:K,answers:[be]}),e.session.limit=e.current_limit}else if(e.points=R,e.session.limit=k,e.session.format_success=L,i.type.is_error(F))e.throw_error(F.args[0]);else if(e.current_limit>0){for(var Be=[],fe=0;fe<B.length;fe++){F=B[fe].answers;for(var xe=new o("[]"),Ve=F.length-1;Ve>=0;Ve--)xe=new o(".",[F[Ve],xe]);Be.push(new V(n.goal.replace(new o(",",[new o("=",[S,B[fe].variables]),new o("=",[p,xe])])),n.substitution,n))}e.prepend(Be)}};e.__calls.unshift(q)}},"setof/3":function(e,n,t){var s,a=t.args[0],u=t.args[1],p=t.args[2];if(i.type.is_variable(u))e.throw_error(i.error.instantiation(t.indicator));else if(!i.type.is_callable(u))e.throw_error(i.error.type("callable",u,t.indicator));else if(!i.type.is_variable(p)&&!i.type.is_list(p))e.throw_error(i.error.type("list",p,t.indicator));else{var y=e.next_free_variable(),d;u.indicator==="^/2"?(d=u.args[0].variables(),u=u.args[1]):d=[],d=d.concat(a.variables());for(var m=u.variables().filter(function(F){return l(d,F)===-1}),S=new o("[]"),O=m.length-1;O>=0;O--)S=new o(".",[new I(m[O]),S]);var A=new o(",",[u,new o("=",[y,new o(",",[S,a])])]),R=e.points,k=e.session.limit,L=e.session.format_success;e.session.format_success=function(F){return F.substitution},e.add_goal(A,!0,n);var B=[],q=function(F){if(F!==!1&&F!==null&&!i.type.is_error(F)){e.__calls.unshift(q);var H=!1,K=F.links[y.id].args[0],be=F.links[y.id].args[1];for(var Te in B)if(!!B.hasOwnProperty(Te)){var Xe=B[Te];if(Xe.variables.equals(K)){Xe.answers.push(be),H=!0;break}}H||B.push({variables:K,answers:[be]}),e.session.limit=e.current_limit}else if(e.points=R,e.session.limit=k,e.session.format_success=L,i.type.is_error(F))e.throw_error(F.args[0]);else if(e.current_limit>0){for(var Be=[],fe=0;fe<B.length;fe++){F=B[fe].answers.sort(i.compare);for(var xe=new o("[]"),Ve=F.length-1;Ve>=0;Ve--)xe=new o(".",[F[Ve],xe]);Be.push(new V(n.goal.replace(new o(",",[new o("=",[S,B[fe].variables]),new o("=",[p,xe])])),n.substitution,n))}e.prepend(Be)}};e.__calls.unshift(q)}},"functor/3":function(e,n,t){var s,a=t.args[0],u=t.args[1],p=t.args[2];if(i.type.is_variable(a)&&(i.type.is_variable(u)||i.type.is_variable(p)))e.throw_error(i.error.instantiation("functor/3"));else if(!i.type.is_variable(p)&&!i.type.is_integer(p))e.throw_error(i.error.type("integer",t.args[2],"functor/3"));else if(!i.type.is_variable(u)&&!i.type.is_atomic(u))e.throw_error(i.error.type("atomic",t.args[1],"functor/3"));else if(i.type.is_integer(u)&&i.type.is_integer(p)&&p.value!==0)e.throw_error(i.error.type("atom",t.args[1],"functor/3"));else if(i.type.is_variable(a)){if(t.args[2].value>=0){for(var y=[],d=0;d<p.value;d++)y.push(e.next_free_variable());var m=i.type.is_integer(u)?u:new o(u.id,y);e.prepend([new V(n.goal.replace(new o("=",[a,m])),n.substitution,n)])}}else{var S=i.type.is_integer(a)?a:new o(a.id,[]),O=i.type.is_integer(a)?new E(0,!1):new E(a.args.length,!1),A=new o(",",[new o("=",[S,u]),new o("=",[O,p])]);e.prepend([new V(n.goal.replace(A),n.substitution,n)])}},"arg/3":function(e,n,t){if(i.type.is_variable(t.args[0])||i.type.is_variable(t.args[1]))e.throw_error(i.error.instantiation(t.indicator));else if(t.args[0].value<0)e.throw_error(i.error.domain("not_less_than_zero",t.args[0],t.indicator));else if(!i.type.is_compound(t.args[1]))e.throw_error(i.error.type("compound",t.args[1],t.indicator));else{var s=t.args[0].value;if(s>0&&s<=t.args[1].args.length){var a=new o("=",[t.args[1].args[s-1],t.args[2]]);e.prepend([new V(n.goal.replace(a),n.substitution,n)])}}},"=../2":function(e,n,t){var s;if(i.type.is_variable(t.args[0])&&(i.type.is_variable(t.args[1])||i.type.is_non_empty_list(t.args[1])&&i.type.is_variable(t.args[1].args[0])))e.throw_error(i.error.instantiation(t.indicator));else if(!i.type.is_fully_list(t.args[1]))e.throw_error(i.error.type("list",t.args[1],t.indicator));else if(i.type.is_variable(t.args[0])){if(!i.type.is_variable(t.args[1])){var u=[];for(s=t.args[1].args[1];s.indicator==="./2";)u.push(s.args[0]),s=s.args[1];i.type.is_variable(t.args[0])&&i.type.is_variable(s)?e.throw_error(i.error.instantiation(t.indicator)):u.length===0&&i.type.is_compound(t.args[1].args[0])?e.throw_error(i.error.type("atomic",t.args[1].args[0],t.indicator)):u.length>0&&(i.type.is_compound(t.args[1].args[0])||i.type.is_number(t.args[1].args[0]))?e.throw_error(i.error.type("atom",t.args[1].args[0],t.indicator)):u.length===0?e.prepend([new V(n.goal.replace(new o("=",[t.args[1].args[0],t.args[0]],n)),n.substitution,n)]):e.prepend([new V(n.goal.replace(new o("=",[new o(t.args[1].args[0].id,u),t.args[0]])),n.substitution,n)])}}else{if(i.type.is_atomic(t.args[0]))s=new o(".",[t.args[0],new o("[]")]);else{s=new o("[]");for(var a=t.args[0].args.length-1;a>=0;a--)s=new o(".",[t.args[0].args[a],s]);s=new o(".",[new o(t.args[0].id),s])}e.prepend([new V(n.goal.replace(new o("=",[s,t.args[1]])),n.substitution,n)])}},"copy_term/2":function(e,n,t){var s=t.args[0].rename(e);e.prepend([new V(n.goal.replace(new o("=",[s,t.args[1]])),n.substitution,n.parent)])},"term_variables/2":function(e,n,t){var s=t.args[0],a=t.args[1];if(!i.type.is_fully_list(a))e.throw_error(i.error.type("list",a,t.indicator));else{var u=me(c(yr(s.variables()),function(p){return new I(p)}));e.prepend([new V(n.goal.replace(new o("=",[a,u])),n.substitution,n)])}},"clause/2":function(e,n,t){if(i.type.is_variable(t.args[0]))e.throw_error(i.error.instantiation(t.indicator));else if(!i.type.is_callable(t.args[0]))e.throw_error(i.error.type("callable",t.args[0],t.indicator));else if(!i.type.is_variable(t.args[1])&&!i.type.is_callable(t.args[1]))e.throw_error(i.error.type("callable",t.args[1],t.indicator));else if(e.session.rules[t.args[0].indicator]!==void 0)if(e.is_public_predicate(t.args[0].indicator)){var s=[];for(var a in e.session.rules[t.args[0].indicator])if(!!e.session.rules[t.args[0].indicator].hasOwnProperty(a)){var u=e.session.rules[t.args[0].indicator][a];e.session.renamed_variables={},u=u.rename(e),u.body===null&&(u.body=new o("true"));var p=new o(",",[new o("=",[u.head,t.args[0]]),new o("=",[u.body,t.args[1]])]);s.push(new V(n.goal.replace(p),n.substitution,n))}e.prepend(s)}else e.throw_error(i.error.permission("access","private_procedure",t.args[0].indicator,t.indicator))},"current_predicate/1":function(e,n,t){var s=t.args[0];if(!i.type.is_variable(s)&&(!i.type.is_compound(s)||s.indicator!=="//2"))e.throw_error(i.error.type("predicate_indicator",s,t.indicator));else if(!i.type.is_variable(s)&&!i.type.is_variable(s.args[0])&&!i.type.is_atom(s.args[0]))e.throw_error(i.error.type("atom",s.args[0],t.indicator));else if(!i.type.is_variable(s)&&!i.type.is_variable(s.args[1])&&!i.type.is_integer(s.args[1]))e.throw_error(i.error.type("integer",s.args[1],t.indicator));else{var a=[];for(var u in e.session.rules)if(!!e.session.rules.hasOwnProperty(u)){var p=u.lastIndexOf("/"),y=u.substr(0,p),d=parseInt(u.substr(p+1,u.length-(p+1))),m=new o("/",[new o(y),new E(d,!1)]),S=new o("=",[m,s]);a.push(new V(n.goal.replace(S),n.substitution,n))}e.prepend(a)}},"asserta/1":function(e,n,t){if(i.type.is_variable(t.args[0]))e.throw_error(i.error.instantiation(t.indicator));else if(!i.type.is_callable(t.args[0]))e.throw_error(i.error.type("callable",t.args[0],t.indicator));else{var s,a;t.args[0].indicator===":-/2"?(s=t.args[0].args[0],a=he(t.args[0].args[1])):(s=t.args[0],a=null),i.type.is_callable(s)?a!==null&&!i.type.is_callable(a)?e.throw_error(i.error.type("callable",a,t.indicator)):e.is_public_predicate(s.indicator)?(e.session.rules[s.indicator]===void 0&&(e.session.rules[s.indicator]=[]),e.session.public_predicates[s.indicator]=!0,e.session.rules[s.indicator]=[new J(s,a,!0)].concat(e.session.rules[s.indicator]),e.success(n)):e.throw_error(i.error.permission("modify","static_procedure",s.indicator,t.indicator)):e.throw_error(i.error.type("callable",s,t.indicator))}},"assertz/1":function(e,n,t){if(i.type.is_variable(t.args[0]))e.throw_error(i.error.instantiation(t.indicator));else if(!i.type.is_callable(t.args[0]))e.throw_error(i.error.type("callable",t.args[0],t.indicator));else{var s,a;t.args[0].indicator===":-/2"?(s=t.args[0].args[0],a=he(t.args[0].args[1])):(s=t.args[0],a=null),i.type.is_callable(s)?a!==null&&!i.type.is_callable(a)?e.throw_error(i.error.type("callable",a,t.indicator)):e.is_public_predicate(s.indicator)?(e.session.rules[s.indicator]===void 0&&(e.session.rules[s.indicator]=[]),e.session.public_predicates[s.indicator]=!0,e.session.rules[s.indicator].push(new J(s,a,!0)),e.success(n)):e.throw_error(i.error.permission("modify","static_procedure",s.indicator,t.indicator)):e.throw_error(i.error.type("callable",s,t.indicator))}},"retract/1":function(e,n,t){if(i.type.is_variable(t.args[0]))e.throw_error(i.error.instantiation(t.indicator));else if(!i.type.is_callable(t.args[0]))e.throw_error(i.error.type("callable",t.args[0],t.indicator));else{var s,a;if(t.args[0].indicator===":-/2"?(s=t.args[0].args[0],a=t.args[0].args[1]):(s=t.args[0],a=new o("true")),typeof n.retract>"u")if(e.is_public_predicate(s.indicator)){if(e.session.rules[s.indicator]!==void 0){for(var u=[],p=0;p<e.session.rules[s.indicator].length;p++){e.session.renamed_variables={};var y=e.session.rules[s.indicator][p],d=y.rename(e);d.body===null&&(d.body=new o("true",[]));var m=e.get_flag("occurs_check").indicator==="true/0",S=i.unify(new o(",",[s,a]),new o(",",[d.head,d.body]),m);if(S!==null){var O=new V(n.goal.replace(new o(",",[new o("retract",[new o(":-",[s,a])]),new o(",",[new o("=",[s,d.head]),new o("=",[a,d.body])])])),n.substitution,n);O.retract=y,u.push(O)}}e.prepend(u)}}else e.throw_error(i.error.permission("modify","static_procedure",s.indicator,t.indicator));else Bi(e,n,s.indicator,n.retract)}},"retractall/1":function(e,n,t){var s=t.args[0];i.type.is_variable(s)?e.throw_error(i.error.instantiation(t.indicator)):i.type.is_callable(s)?e.prepend([new V(n.goal.replace(new o(",",[new o("retract",[new i.type.Term(":-",[s,new I("_")])]),new o("fail",[])])),n.substitution,n),new V(n.goal.replace(null),n.substitution,n)]):e.throw_error(i.error.type("callable",s,t.indicator))},"abolish/1":function(e,n,t){if(i.type.is_variable(t.args[0])||i.type.is_term(t.args[0])&&t.args[0].indicator==="//2"&&(i.type.is_variable(t.args[0].args[0])||i.type.is_variable(t.args[0].args[1])))e.throw_error(i.error.instantiation(t.indicator));else if(!i.type.is_term(t.args[0])||t.args[0].indicator!=="//2")e.throw_error(i.error.type("predicate_indicator",t.args[0],t.indicator));else if(!i.type.is_atom(t.args[0].args[0]))e.throw_error(i.error.type("atom",t.args[0].args[0],t.indicator));else if(!i.type.is_integer(t.args[0].args[1]))e.throw_error(i.error.type("integer",t.args[0].args[1],t.indicator));else if(t.args[0].args[1].value<0)e.throw_error(i.error.domain("not_less_than_zero",t.args[0].args[1],t.indicator));else if(i.type.is_number(e.get_flag("max_arity"))&&t.args[0].args[1].value>e.get_flag("max_arity").value)e.throw_error(i.error.representation("max_arity",t.indicator));else{var s=t.args[0].args[0].id+"/"+t.args[0].args[1].value;e.is_public_predicate(s)?(delete e.session.rules[s],e.success(n)):e.throw_error(i.error.permission("modify","static_procedure",s,t.indicator))}},"atom_length/2":function(e,n,t){if(i.type.is_variable(t.args[0]))e.throw_error(i.error.instantiation(t.indicator));else if(!i.type.is_atom(t.args[0]))e.throw_error(i.error.type("atom",t.args[0],t.indicator));else if(!i.type.is_variable(t.args[1])&&!i.type.is_integer(t.args[1]))e.throw_error(i.error.type("integer",t.args[1],t.indicator));else if(i.type.is_integer(t.args[1])&&t.args[1].value<0)e.throw_error(i.error.domain("not_less_than_zero",t.args[1],t.indicator));else{var s=new E(t.args[0].id.length,!1);e.prepend([new V(n.goal.replace(new o("=",[s,t.args[1]])),n.substitution,n)])}},"atom_concat/3":function(e,n,t){var s,a,u=t.args[0],p=t.args[1],y=t.args[2];if(i.type.is_variable(y)&&(i.type.is_variable(u)||i.type.is_variable(p)))e.throw_error(i.error.instantiation(t.indicator));else if(!i.type.is_variable(u)&&!i.type.is_atom(u))e.throw_error(i.error.type("atom",u,t.indicator));else if(!i.type.is_variable(p)&&!i.type.is_atom(p))e.throw_error(i.error.type("atom",p,t.indicator));else if(!i.type.is_variable(y)&&!i.type.is_atom(y))e.throw_error(i.error.type("atom",y,t.indicator));else{var d=i.type.is_variable(u),m=i.type.is_variable(p);if(!d&&!m)a=new o("=",[y,new o(u.id+p.id)]),e.prepend([new V(n.goal.replace(a),n.substitution,n)]);else if(d&&!m)s=y.id.substr(0,y.id.length-p.id.length),s+p.id===y.id&&(a=new o("=",[u,new o(s)]),e.prepend([new V(n.goal.replace(a),n.substitution,n)]));else if(m&&!d)s=y.id.substr(u.id.length),u.id+s===y.id&&(a=new o("=",[p,new o(s)]),e.prepend([new V(n.goal.replace(a),n.substitution,n)]));else{for(var S=[],O=0;O<=y.id.length;O++){var A=new o(y.id.substr(0,O)),R=new o(y.id.substr(O));a=new o(",",[new o("=",[A,u]),new o("=",[R,p])]),S.push(new V(n.goal.replace(a),n.substitution,n))}e.prepend(S)}}},"sub_atom/5":function(e,n,t){var s,a=t.args[0],u=t.args[1],p=t.args[2],y=t.args[3],d=t.args[4];if(i.type.is_variable(a))e.throw_error(i.error.instantiation(t.indicator));else if(!i.type.is_variable(u)&&!i.type.is_integer(u))e.throw_error(i.error.type("integer",u,t.indicator));else if(!i.type.is_variable(p)&&!i.type.is_integer(p))e.throw_error(i.error.type("integer",p,t.indicator));else if(!i.type.is_variable(y)&&!i.type.is_integer(y))e.throw_error(i.error.type("integer",y,t.indicator));else if(i.type.is_integer(u)&&u.value<0)e.throw_error(i.error.domain("not_less_than_zero",u,t.indicator));else if(i.type.is_integer(p)&&p.value<0)e.throw_error(i.error.domain("not_less_than_zero",p,t.indicator));else if(i.type.is_integer(y)&&y.value<0)e.throw_error(i.error.domain("not_less_than_zero",y,t.indicator));else{var m=[],S=[],O=[];if(i.type.is_variable(u))for(s=0;s<=a.id.length;s++)m.push(s);else m.push(u.value);if(i.type.is_variable(p))for(s=0;s<=a.id.length;s++)S.push(s);else S.push(p.value);if(i.type.is_variable(y))for(s=0;s<=a.id.length;s++)O.push(s);else O.push(y.value);var A=[];for(var R in m)if(!!m.hasOwnProperty(R)){s=m[R];for(var k in S)if(!!S.hasOwnProperty(k)){var L=S[k],B=a.id.length-s-L;if(l(O,B)!==-1&&s+L+B===a.id.length){var q=a.id.substr(s,L);if(a.id===a.id.substr(0,s)+q+a.id.substr(s+L,B)){var F=new o("=",[new o(q),d]),H=new o("=",[u,new E(s)]),K=new o("=",[p,new E(L)]),be=new o("=",[y,new E(B)]),Te=new o(",",[new o(",",[new o(",",[H,K]),be]),F]);A.push(new V(n.goal.replace(Te),n.substitution,n))}}}}e.prepend(A)}},"atom_chars/2":function(e,n,t){var s=t.args[0],a=t.args[1];if(i.type.is_variable(s)&&i.type.is_variable(a))e.throw_error(i.error.instantiation(t.indicator));else if(!i.type.is_variable(s)&&!i.type.is_atom(s))e.throw_error(i.error.type("atom",s,t.indicator));else if(i.type.is_variable(s)){for(var y=a,d=i.type.is_variable(s),m="";y.indicator==="./2";){if(i.type.is_character(y.args[0]))m+=y.args[0].id;else if(i.type.is_variable(y.args[0])&&d){e.throw_error(i.error.instantiation(t.indicator));return}else if(!i.type.is_variable(y.args[0])){e.throw_error(i.error.type("character",y.args[0],t.indicator));return}y=y.args[1]}i.type.is_variable(y)&&d?e.throw_error(i.error.instantiation(t.indicator)):!i.type.is_empty_list(y)&&!i.type.is_variable(y)?e.throw_error(i.error.type("list",a,t.indicator)):e.prepend([new V(n.goal.replace(new o("=",[new o(m),s])),n.substitution,n)])}else{for(var u=new o("[]"),p=s.id.length-1;p>=0;p--)u=new o(".",[new o(s.id.charAt(p)),u]);e.prepend([new V(n.goal.replace(new o("=",[a,u])),n.substitution,n)])}},"atom_codes/2":function(e,n,t){var s=t.args[0],a=t.args[1];if(i.type.is_variable(s)&&i.type.is_variable(a))e.throw_error(i.error.instantiation(t.indicator));else if(!i.type.is_variable(s)&&!i.type.is_atom(s))e.throw_error(i.error.type("atom",s,t.indicator));else if(i.type.is_variable(s)){for(var y=a,d=i.type.is_variable(s),m="";y.indicator==="./2";){if(i.type.is_character_code(y.args[0]))m+=v(y.args[0].value);else if(i.type.is_variable(y.args[0])&&d){e.throw_error(i.error.instantiation(t.indicator));return}else if(!i.type.is_variable(y.args[0])){e.throw_error(i.error.representation("character_code",t.indicator));return}y=y.args[1]}i.type.is_variable(y)&&d?e.throw_error(i.error.instantiation(t.indicator)):!i.type.is_empty_list(y)&&!i.type.is_variable(y)?e.throw_error(i.error.type("list",a,t.indicator)):e.prepend([new V(n.goal.replace(new o("=",[new o(m),s])),n.substitution,n)])}else{for(var u=new o("[]"),p=s.id.length-1;p>=0;p--)u=new o(".",[new E(_(s.id,p),!1),u]);e.prepend([new V(n.goal.replace(new o("=",[a,u])),n.substitution,n)])}},"char_code/2":function(e,n,t){var s=t.args[0],a=t.args[1];if(i.type.is_variable(s)&&i.type.is_variable(a))e.throw_error(i.error.instantiation(t.indicator));else if(!i.type.is_variable(s)&&!i.type.is_character(s))e.throw_error(i.error.type("character",s,t.indicator));else if(!i.type.is_variable(a)&&!i.type.is_integer(a))e.throw_error(i.error.type("integer",a,t.indicator));else if(!i.type.is_variable(a)&&!i.type.is_character_code(a))e.throw_error(i.error.representation("character_code",t.indicator));else if(i.type.is_variable(a)){var u=new E(_(s.id,0),!1);e.prepend([new V(n.goal.replace(new o("=",[u,a])),n.substitution,n)])}else{var p=new o(v(a.value));e.prepend([new V(n.goal.replace(new o("=",[p,s])),n.substitution,n)])}},"number_chars/2":function(e,n,t){var s,a=t.args[0],u=t.args[1];if(i.type.is_variable(a)&&i.type.is_variable(u))e.throw_error(i.error.instantiation(t.indicator));else if(!i.type.is_variable(a)&&!i.type.is_number(a))e.throw_error(i.error.type("number",a,t.indicator));else if(!i.type.is_variable(u)&&!i.type.is_list(u))e.throw_error(i.error.type("list",u,t.indicator));else{var p=i.type.is_variable(a);if(!i.type.is_variable(u)){var y=u,d=!0;for(s="";y.indicator==="./2";){if(i.type.is_character(y.args[0]))s+=y.args[0].id;else if(i.type.is_variable(y.args[0]))d=!1;else if(!i.type.is_variable(y.args[0])){e.throw_error(i.error.type("character",y.args[0],t.indicator));return}y=y.args[1]}if(d=d&&i.type.is_empty_list(y),!i.type.is_empty_list(y)&&!i.type.is_variable(y)){e.throw_error(i.error.type("list",u,t.indicator));return}if(!d&&p){e.throw_error(i.error.instantiation(t.indicator));return}else if(d)if(i.type.is_variable(y)&&p){e.throw_error(i.error.instantiation(t.indicator));return}else{var m=e.parse(s),S=m.value;!i.type.is_number(S)||m.tokens[m.tokens.length-1].space?e.throw_error(i.error.syntax_by_predicate("parseable_number",t.indicator)):e.prepend([new V(n.goal.replace(new o("=",[a,S])),n.substitution,n)]);return}}if(!p){s=a.toString();for(var O=new o("[]"),A=s.length-1;A>=0;A--)O=new o(".",[new o(s.charAt(A)),O]);e.prepend([new V(n.goal.replace(new o("=",[u,O])),n.substitution,n)])}}},"number_codes/2":function(e,n,t){var s,a=t.args[0],u=t.args[1];if(i.type.is_variable(a)&&i.type.is_variable(u))e.throw_error(i.error.instantiation(t.indicator));else if(!i.type.is_variable(a)&&!i.type.is_number(a))e.throw_error(i.error.type("number",a,t.indicator));else if(!i.type.is_variable(u)&&!i.type.is_list(u))e.throw_error(i.error.type("list",u,t.indicator));else{var p=i.type.is_variable(a);if(!i.type.is_variable(u)){var y=u,d=!0;for(s="";y.indicator==="./2";){if(i.type.is_character_code(y.args[0]))s+=v(y.args[0].value);else if(i.type.is_variable(y.args[0]))d=!1;else if(!i.type.is_variable(y.args[0])){e.throw_error(i.error.type("character_code",y.args[0],t.indicator));return}y=y.args[1]}if(d=d&&i.type.is_empty_list(y),!i.type.is_empty_list(y)&&!i.type.is_variable(y)){e.throw_error(i.error.type("list",u,t.indicator));return}if(!d&&p){e.throw_error(i.error.instantiation(t.indicator));return}else if(d)if(i.type.is_variable(y)&&p){e.throw_error(i.error.instantiation(t.indicator));return}else{var m=e.parse(s),S=m.value;!i.type.is_number(S)||m.tokens[m.tokens.length-1].space?e.throw_error(i.error.syntax_by_predicate("parseable_number",t.indicator)):e.prepend([new V(n.goal.replace(new o("=",[a,S])),n.substitution,n)]);return}}if(!p){s=a.toString();for(var O=new o("[]"),A=s.length-1;A>=0;A--)O=new o(".",[new E(_(s,A),!1),O]);e.prepend([new V(n.goal.replace(new o("=",[u,O])),n.substitution,n)])}}},"upcase_atom/2":function(e,n,t){var s=t.args[0],a=t.args[1];i.type.is_variable(s)?e.throw_error(i.error.instantiation(t.indicator)):i.type.is_atom(s)?!i.type.is_variable(a)&&!i.type.is_atom(a)?e.throw_error(i.error.type("atom",a,t.indicator)):e.prepend([new V(n.goal.replace(new o("=",[a,new o(s.id.toUpperCase(),[])])),n.substitution,n)]):e.throw_error(i.error.type("atom",s,t.indicator))},"downcase_atom/2":function(e,n,t){var s=t.args[0],a=t.args[1];i.type.is_variable(s)?e.throw_error(i.error.instantiation(t.indicator)):i.type.is_atom(s)?!i.type.is_variable(a)&&!i.type.is_atom(a)?e.throw_error(i.error.type("atom",a,t.indicator)):e.prepend([new V(n.goal.replace(new o("=",[a,new o(s.id.toLowerCase(),[])])),n.substitution,n)]):e.throw_error(i.error.type("atom",s,t.indicator))},"atomic_list_concat/2":function(e,n,t){var s=t.args[0],a=t.args[1];e.prepend([new V(n.goal.replace(new o("atomic_list_concat",[s,new o("",[]),a])),n.substitution,n)])},"atomic_list_concat/3":function(e,n,t){var s=t.args[0],a=t.args[1],u=t.args[2];if(i.type.is_variable(a)||i.type.is_variable(s)&&i.type.is_variable(u))e.throw_error(i.error.instantiation(t.indicator));else if(!i.type.is_variable(s)&&!i.type.is_list(s))e.throw_error(i.error.type("list",s,t.indicator));else if(!i.type.is_variable(u)&&!i.type.is_atom(u))e.throw_error(i.error.type("atom",u,t.indicator));else if(i.type.is_variable(u)){for(var y="",d=s;i.type.is_term(d)&&d.indicator==="./2";){if(!i.type.is_atom(d.args[0])&&!i.type.is_number(d.args[0])){e.throw_error(i.error.type("atomic",d.args[0],t.indicator));return}y!==""&&(y+=a.id),i.type.is_atom(d.args[0])?y+=d.args[0].id:y+=""+d.args[0].value,d=d.args[1]}y=new o(y,[]),i.type.is_variable(d)?e.throw_error(i.error.instantiation(t.indicator)):!i.type.is_term(d)||d.indicator!=="[]/0"?e.throw_error(i.error.type("list",s,t.indicator)):e.prepend([new V(n.goal.replace(new o("=",[y,u])),n.substitution,n)])}else{var p=me(c(u.id.split(a.id),function(m){return new o(m,[])}));e.prepend([new V(n.goal.replace(new o("=",[p,s])),n.substitution,n)])}},"@=</2":function(e,n,t){i.compare(t.args[0],t.args[1])<=0&&e.success(n)},"==/2":function(e,n,t){i.compare(t.args[0],t.args[1])===0&&e.success(n)},"\\==/2":function(e,n,t){i.compare(t.args[0],t.args[1])!==0&&e.success(n)},"@</2":function(e,n,t){i.compare(t.args[0],t.args[1])<0&&e.success(n)},"@>/2":function(e,n,t){i.compare(t.args[0],t.args[1])>0&&e.success(n)},"@>=/2":function(e,n,t){i.compare(t.args[0],t.args[1])>=0&&e.success(n)},"compare/3":function(e,n,t){var s=t.args[0],a=t.args[1],u=t.args[2];if(!i.type.is_variable(s)&&!i.type.is_atom(s))e.throw_error(i.error.type("atom",s,t.indicator));else if(i.type.is_atom(s)&&["<",">","="].indexOf(s.id)===-1)e.throw_error(i.type.domain("order",s,t.indicator));else{var p=i.compare(a,u);p=p===0?"=":p===-1?"<":">",e.prepend([new V(n.goal.replace(new o("=",[s,new o(p,[])])),n.substitution,n)])}},"is/2":function(e,n,t){var s=t.args[1].interpret(e);i.type.is_number(s)?e.prepend([new V(n.goal.replace(new o("=",[t.args[0],s],e.level)),n.substitution,n)]):e.throw_error(s)},"between/3":function(e,n,t){var s=t.args[0],a=t.args[1],u=t.args[2];if(i.type.is_variable(s)||i.type.is_variable(a))e.throw_error(i.error.instantiation(t.indicator));else if(!i.type.is_integer(s))e.throw_error(i.error.type("integer",s,t.indicator));else if(!i.type.is_integer(a))e.throw_error(i.error.type("integer",a,t.indicator));else if(!i.type.is_variable(u)&&!i.type.is_integer(u))e.throw_error(i.error.type("integer",u,t.indicator));else if(i.type.is_variable(u)){var p=[new V(n.goal.replace(new o("=",[u,s])),n.substitution,n)];s.value<a.value&&p.push(new V(n.goal.replace(new o("between",[new E(s.value+1,!1),a,u])),n.substitution,n)),e.prepend(p)}else s.value<=u.value&&a.value>=u.value&&e.success(n)},"succ/2":function(e,n,t){var s=t.args[0],a=t.args[1];i.type.is_variable(s)&&i.type.is_variable(a)?e.throw_error(i.error.instantiation(t.indicator)):!i.type.is_variable(s)&&!i.type.is_integer(s)?e.throw_error(i.error.type("integer",s,t.indicator)):!i.type.is_variable(a)&&!i.type.is_integer(a)?e.throw_error(i.error.type("integer",a,t.indicator)):!i.type.is_variable(s)&&s.value<0?e.throw_error(i.error.domain("not_less_than_zero",s,t.indicator)):!i.type.is_variable(a)&&a.value<0?e.throw_error(i.error.domain("not_less_than_zero",a,t.indicator)):(i.type.is_variable(a)||a.value>0)&&(i.type.is_variable(s)?e.prepend([new V(n.goal.replace(new o("=",[s,new E(a.value-1,!1)])),n.substitution,n)]):e.prepend([new V(n.goal.replace(new o("=",[a,new E(s.value+1,!1)])),n.substitution,n)]))},"=:=/2":function(e,n,t){var s=i.arithmetic_compare(e,t.args[0],t.args[1]);i.type.is_term(s)?e.throw_error(s):s===0&&e.success(n)},"=\\=/2":function(e,n,t){var s=i.arithmetic_compare(e,t.args[0],t.args[1]);i.type.is_term(s)?e.throw_error(s):s!==0&&e.success(n)},"</2":function(e,n,t){var s=i.arithmetic_compare(e,t.args[0],t.args[1]);i.type.is_term(s)?e.throw_error(s):s<0&&e.success(n)},"=</2":function(e,n,t){var s=i.arithmetic_compare(e,t.args[0],t.args[1]);i.type.is_term(s)?e.throw_error(s):s<=0&&e.success(n)},">/2":function(e,n,t){var s=i.arithmetic_compare(e,t.args[0],t.args[1]);i.type.is_term(s)?e.throw_error(s):s>0&&e.success(n)},">=/2":function(e,n,t){var s=i.arithmetic_compare(e,t.args[0],t.args[1]);i.type.is_term(s)?e.throw_error(s):s>=0&&e.success(n)},"var/1":function(e,n,t){i.type.is_variable(t.args[0])&&e.success(n)},"atom/1":function(e,n,t){i.type.is_atom(t.args[0])&&e.success(n)},"atomic/1":function(e,n,t){i.type.is_atomic(t.args[0])&&e.success(n)},"compound/1":function(e,n,t){i.type.is_compound(t.args[0])&&e.success(n)},"integer/1":function(e,n,t){i.type.is_integer(t.args[0])&&e.success(n)},"float/1":function(e,n,t){i.type.is_float(t.args[0])&&e.success(n)},"number/1":function(e,n,t){i.type.is_number(t.args[0])&&e.success(n)},"nonvar/1":function(e,n,t){i.type.is_variable(t.args[0])||e.success(n)},"ground/1":function(e,n,t){t.variables().length===0&&e.success(n)},"acyclic_term/1":function(e,n,t){for(var s=n.substitution.apply(n.substitution),a=t.args[0].variables(),u=0;u<a.length;u++)if(n.substitution.links[a[u]]!==void 0&&!n.substitution.links[a[u]].equals(s.links[a[u]]))return;e.success(n)},"callable/1":function(e,n,t){i.type.is_callable(t.args[0])&&e.success(n)},"is_list/1":function(e,n,t){for(var s=t.args[0];i.type.is_term(s)&&s.indicator==="./2";)s=s.args[1];i.type.is_term(s)&&s.indicator==="[]/0"&&e.success(n)},"current_input/1":function(e,n,t){var s=t.args[0];!i.type.is_variable(s)&&!i.type.is_stream(s)&&!i.type.is_atom(s)?e.throw_error(i.error.domain("stream",s,t.indicator)):(i.type.is_atom(s)&&e.get_stream_by_alias(s.id)&&(s=e.get_stream_by_alias(s.id)),e.prepend([new V(n.goal.replace(new o("=",[s,e.get_current_input()])),n.substitution,n)]))},"current_output/1":function(e,n,t){var s=t.args[0];!i.type.is_variable(s)&&!i.type.is_stream(s)&&!i.type.is_atom(s)?e.throw_error(i.error.domain("stream_or_alias",s,t.indicator)):(i.type.is_atom(s)&&e.get_stream_by_alias(s.id)&&(s=e.get_stream_by_alias(s.id)),e.prepend([new V(n.goal.replace(new o("=",[s,e.get_current_output()])),n.substitution,n)]))},"set_input/1":function(e,n,t){var s=t.args[0],a=i.type.is_stream(s)?s:e.get_stream_by_alias(s.id);i.type.is_variable(s)?e.throw_error(i.error.instantiation(t.indicator)):!i.type.is_variable(s)&&!i.type.is_stream(s)&&!i.type.is_atom(s)?e.throw_error(i.error.domain("stream_or_alias",s,t.indicator)):i.type.is_stream(a)?a.output===!0?e.throw_error(i.error.permission("input","stream",s,t.indicator)):(e.set_current_input(a),e.success(n)):e.throw_error(i.error.existence("stream",s,t.indicator))},"set_output/1":function(e,n,t){var s=t.args[0],a=i.type.is_stream(s)?s:e.get_stream_by_alias(s.id);i.type.is_variable(s)?e.throw_error(i.error.instantiation(t.indicator)):!i.type.is_variable(s)&&!i.type.is_stream(s)&&!i.type.is_atom(s)?e.throw_error(i.error.domain("stream_or_alias",s,t.indicator)):i.type.is_stream(a)?a.input===!0?e.throw_error(i.error.permission("output","stream",s,t.indicator)):(e.set_current_output(a),e.success(n)):e.throw_error(i.error.existence("stream",s,t.indicator))},"open/3":function(e,n,t){var s=t.args[0],a=t.args[1],u=t.args[2];e.prepend([new V(n.goal.replace(new o("open",[s,a,u,new o("[]",[])])),n.substitution,n)])},"open/4":function(e,n,t){var s=t.args[0],a=t.args[1],u=t.args[2],p=t.args[3];if(i.type.is_variable(s)||i.type.is_variable(a))e.throw_error(i.error.instantiation(t.indicator));else if(!i.type.is_variable(a)&&!i.type.is_atom(a))e.throw_error(i.error.type("atom",a,t.indicator));else if(!i.type.is_list(p))e.throw_error(i.error.type("list",p,t.indicator));else if(!i.type.is_variable(u))e.throw_error(i.error.type("variable",u,t.indicator));else if(!i.type.is_atom(s)&&!i.type.is_streamable(s))e.throw_error(i.error.domain("source_sink",s,t.indicator));else if(!i.type.is_io_mode(a))e.throw_error(i.error.domain("io_mode",a,t.indicator));else{for(var y={},d=p,m;i.type.is_term(d)&&d.indicator==="./2";){if(m=d.args[0],i.type.is_variable(m)){e.throw_error(i.error.instantiation(t.indicator));return}else if(!i.type.is_stream_option(m)){e.throw_error(i.error.domain("stream_option",m,t.indicator));return}y[m.id]=m.args[0].id,d=d.args[1]}if(d.indicator!=="[]/0"){i.type.is_variable(d)?e.throw_error(i.error.instantiation(t.indicator)):e.throw_error(i.error.type("list",p,t.indicator));return}else{var S=y.alias;if(S&&e.get_stream_by_alias(S)){e.throw_error(i.error.permission("open","source_sink",new o("alias",[new o(S,[])]),t.indicator));return}y.type||(y.type="text");var O;if(i.type.is_atom(s)?O=e.file_system_open(s.id,y.type,a.id):O=s.stream(y.type,a.id),O===!1){e.throw_error(i.error.permission("open","source_sink",s,t.indicator));return}else if(O===null){e.throw_error(i.error.existence("source_sink",s,t.indicator));return}var A=new ne(O,a.id,y.alias,y.type,y.reposition==="true",y.eof_action);S?e.session.streams[S]=A:e.session.streams[A.id]=A,e.prepend([new V(n.goal.replace(new o("=",[u,A])),n.substitution,n)])}}},"close/1":function(e,n,t){var s=t.args[0];e.prepend([new V(n.goal.replace(new o("close",[s,new o("[]",[])])),n.substitution,n)])},"close/2":function(e,n,t){var s=t.args[0],a=t.args[1],u=i.type.is_stream(s)?s:e.get_stream_by_alias(s.id);if(i.type.is_variable(s)||i.type.is_variable(a))e.throw_error(i.error.instantiation(t.indicator));else if(!i.type.is_list(a))e.throw_error(i.error.type("list",a,t.indicator));else if(!i.type.is_stream(s)&&!i.type.is_atom(s))e.throw_error(i.error.domain("stream_or_alias",s,t.indicator));else if(!i.type.is_stream(u)||u.stream===null)e.throw_error(i.error.existence("stream",s,t.indicator));else{for(var p={},y=a,d;i.type.is_term(y)&&y.indicator==="./2";){if(d=y.args[0],i.type.is_variable(d)){e.throw_error(i.error.instantiation(t.indicator));return}else if(!i.type.is_close_option(d)){e.throw_error(i.error.domain("close_option",d,t.indicator));return}p[d.id]=d.args[0].id==="true",y=y.args[1]}if(y.indicator!=="[]/0"){i.type.is_variable(y)?e.throw_error(i.error.instantiation(t.indicator)):e.throw_error(i.error.type("list",a,t.indicator));return}else{if(u===e.session.standard_input||u===e.session.standard_output){e.success(n);return}else u===e.session.current_input?e.session.current_input=e.session.standard_input:u===e.session.current_output&&(e.session.current_output=e.session.current_output);u.alias!==null?delete e.session.streams[u.alias]:delete e.session.streams[u.id],u.output&&u.stream.flush();var m=u.stream.close();u.stream=null,(p.force===!0||m===!0)&&e.success(n)}}},"flush_output/0":function(e,n,t){e.prepend([new V(n.goal.replace(new o(",",[new o("current_output",[new I("S")]),new o("flush_output",[new I("S")])])),n.substitution,n)])},"flush_output/1":function(e,n,t){var s=t.args[0],a=i.type.is_stream(s)?s:e.get_stream_by_alias(s.id);i.type.is_variable(s)?e.throw_error(i.error.instantiation(t.indicator)):!i.type.is_stream(s)&&!i.type.is_atom(s)?e.throw_error(i.error.domain("stream_or_alias",s,t.indicator)):!i.type.is_stream(a)||a.stream===null?e.throw_error(i.error.existence("stream",s,t.indicator)):s.input===!0?e.throw_error(i.error.permission("output","stream",output,t.indicator)):(a.stream.flush(),e.success(n))},"stream_property/2":function(e,n,t){var s=t.args[0],a=t.args[1],u=i.type.is_stream(s)?s:e.get_stream_by_alias(s.id);if(!i.type.is_variable(s)&&!i.type.is_stream(s)&&!i.type.is_atom(s))e.throw_error(i.error.domain("stream_or_alias",s,t.indicator));else if(!i.type.is_variable(s)&&(!i.type.is_stream(u)||u.stream===null))e.throw_error(i.error.existence("stream",s,t.indicator));else if(!i.type.is_variable(a)&&!i.type.is_stream_property(a))e.throw_error(i.error.domain("stream_property",a,t.indicator));else{var p=[],y=[];if(!i.type.is_variable(s))p.push(u);else for(var d in e.session.streams)p.push(e.session.streams[d]);for(var m=0;m<p.length;m++){var S=[];p[m].filename&&S.push(new o("file_name",[new o(p[m].file_name,[])])),S.push(new o("mode",[new o(p[m].mode,[])])),S.push(new o(p[m].input?"input":"output",[])),p[m].alias&&S.push(new o("alias",[new o(p[m].alias,[])])),S.push(new o("position",[typeof p[m].position=="number"?new E(p[m].position,!1):new o(p[m].position,[])])),S.push(new o("end_of_stream",[new o(p[m].position==="end_of_stream"?"at":p[m].position==="past_end_of_stream"?"past":"not",[])])),S.push(new o("eof_action",[new o(p[m].eof_action,[])])),S.push(new o("reposition",[new o(p[m].reposition?"true":"false",[])])),S.push(new o("type",[new o(p[m].type,[])]));for(var O=0;O<S.length;O++)y.push(new V(n.goal.replace(new o(",",[new o("=",[i.type.is_variable(s)?s:u,p[m]]),new o("=",[a,S[O]])])),n.substitution,n))}e.prepend(y)}},"at_end_of_stream/0":function(e,n,t){e.prepend([new V(n.goal.replace(new o(",",[new o("current_input",[new I("S")]),new o(",",[new o("stream_property",[new I("S"),new o("end_of_stream",[new I("E")])]),new o(",",[new o("!",[]),new o(";",[new o("=",[new I("E"),new o("at",[])]),new o("=",[new I("E"),new o("past",[])])])])])])),n.substitution,n)])},"at_end_of_stream/1":function(e,n,t){var s=t.args[0];e.prepend([new V(n.goal.replace(new o(",",[new o("stream_property",[s,new o("end_of_stream",[new I("E")])]),new o(",",[new o("!",[]),new o(";",[new o("=",[new I("E"),new o("at",[])]),new o("=",[new I("E"),new o("past",[])])])])])),n.substitution,n)])},"set_stream_position/2":function(e,n,t){var s=t.args[0],a=t.args[1],u=i.type.is_stream(s)?s:e.get_stream_by_alias(s.id);i.type.is_variable(s)||i.type.is_variable(a)?e.throw_error(i.error.instantiation(t.indicator)):!i.type.is_stream(s)&&!i.type.is_atom(s)?e.throw_error(i.error.domain("stream_or_alias",s,t.indicator)):!i.type.is_stream(u)||u.stream===null?e.throw_error(i.error.existence("stream",s,t.indicator)):i.type.is_stream_position(a)?u.reposition===!1?e.throw_error(i.error.permission("reposition","stream",s,t.indicator)):(i.type.is_integer(a)?u.position=a.value:u.position=a.id,e.success(n)):e.throw_error(i.error.domain("stream_position",a,t.indicator))},"get_char/1":function(e,n,t){var s=t.args[0];e.prepend([new V(n.goal.replace(new o(",",[new o("current_input",[new I("S")]),new o("get_char",[new I("S"),s])])),n.substitution,n)])},"get_char/2":function(e,n,t){var s=t.args[0],a=t.args[1],u=i.type.is_stream(s)?s:e.get_stream_by_alias(s.id);if(i.type.is_variable(s))e.throw_error(i.error.instantiation(t.indicator));else if(!i.type.is_variable(a)&&!i.type.is_character(a))e.throw_error(i.error.type("in_character",a,t.indicator));else if(!i.type.is_stream(s)&&!i.type.is_atom(s))e.throw_error(i.error.domain("stream_or_alias",s,t.indicator));else if(!i.type.is_stream(u)||u.stream===null)e.throw_error(i.error.existence("stream",s,t.indicator));else if(u.output)e.throw_error(i.error.permission("input","stream",s,t.indicator));else if(u.type==="binary")e.throw_error(i.error.permission("input","binary_stream",s,t.indicator));else if(u.position==="past_end_of_stream"&&u.eof_action==="error")e.throw_error(i.error.permission("input","past_end_of_stream",s,t.indicator));else{var p;if(u.position==="end_of_stream")p="end_of_file",u.position="past_end_of_stream";else{if(p=u.stream.get(1,u.position),p===null){e.throw_error(i.error.representation("character",t.indicator));return}u.position++}e.prepend([new V(n.goal.replace(new o("=",[new o(p,[]),a])),n.substitution,n)])}},"get_code/1":function(e,n,t){var s=t.args[0];e.prepend([new V(n.goal.replace(new o(",",[new o("current_input",[new I("S")]),new o("get_code",[new I("S"),s])])),n.substitution,n)])},"get_code/2":function(e,n,t){var s=t.args[0],a=t.args[1],u=i.type.is_stream(s)?s:e.get_stream_by_alias(s.id);if(i.type.is_variable(s))e.throw_error(i.error.instantiation(t.indicator));else if(!i.type.is_variable(a)&&!i.type.is_integer(a))e.throw_error(i.error.type("integer",char,t.indicator));else if(!i.type.is_variable(s)&&!i.type.is_stream(s)&&!i.type.is_atom(s))e.throw_error(i.error.domain("stream_or_alias",s,t.indicator));else if(!i.type.is_stream(u)||u.stream===null)e.throw_error(i.error.existence("stream",s,t.indicator));else if(u.output)e.throw_error(i.error.permission("input","stream",s,t.indicator));else if(u.type==="binary")e.throw_error(i.error.permission("input","binary_stream",s,t.indicator));else if(u.position==="past_end_of_stream"&&u.eof_action==="error")e.throw_error(i.error.permission("input","past_end_of_stream",s,t.indicator));else{var p;if(u.position==="end_of_stream")p=-1,u.position="past_end_of_stream";else{if(p=u.stream.get(1,u.position),p===null){e.throw_error(i.error.representation("character",t.indicator));return}p=_(p,0),u.position++}e.prepend([new V(n.goal.replace(new o("=",[new E(p,!1),a])),n.substitution,n)])}},"peek_char/1":function(e,n,t){var s=t.args[0];e.prepend([new V(n.goal.replace(new o(",",[new o("current_input",[new I("S")]),new o("peek_char",[new I("S"),s])])),n.substitution,n)])},"peek_char/2":function(e,n,t){var s=t.args[0],a=t.args[1],u=i.type.is_stream(s)?s:e.get_stream_by_alias(s.id);if(i.type.is_variable(s))e.throw_error(i.error.instantiation(t.indicator));else if(!i.type.is_variable(a)&&!i.type.is_character(a))e.throw_error(i.error.type("in_character",a,t.indicator));else if(!i.type.is_stream(s)&&!i.type.is_atom(s))e.throw_error(i.error.domain("stream_or_alias",s,t.indicator));else if(!i.type.is_stream(u)||u.stream===null)e.throw_error(i.error.existence("stream",s,t.indicator));else if(u.output)e.throw_error(i.error.permission("input","stream",s,t.indicator));else if(u.type==="binary")e.throw_error(i.error.permission("input","binary_stream",s,t.indicator));else if(u.position==="past_end_of_stream"&&u.eof_action==="error")e.throw_error(i.error.permission("input","past_end_of_stream",s,t.indicator));else{var p;if(u.position==="end_of_stream")p="end_of_file",u.position="past_end_of_stream";else if(p=u.stream.get(1,u.position),p===null){e.throw_error(i.error.representation("character",t.indicator));return}e.prepend([new V(n.goal.replace(new o("=",[new o(p,[]),a])),n.substitution,n)])}},"peek_code/1":function(e,n,t){var s=t.args[0];e.prepend([new V(n.goal.replace(new o(",",[new o("current_input",[new I("S")]),new o("peek_code",[new I("S"),s])])),n.substitution,n)])},"peek_code/2":function(e,n,t){var s=t.args[0],a=t.args[1],u=i.type.is_stream(s)?s:e.get_stream_by_alias(s.id);if(i.type.is_variable(s))e.throw_error(i.error.instantiation(t.indicator));else if(!i.type.is_variable(a)&&!i.type.is_integer(a))e.throw_error(i.error.type("integer",char,t.indicator));else if(!i.type.is_variable(s)&&!i.type.is_stream(s)&&!i.type.is_atom(s))e.throw_error(i.error.domain("stream_or_alias",s,t.indicator));else if(!i.type.is_stream(u)||u.stream===null)e.throw_error(i.error.existence("stream",s,t.indicator));else if(u.output)e.throw_error(i.error.permission("input","stream",s,t.indicator));else if(u.type==="binary")e.throw_error(i.error.permission("input","binary_stream",s,t.indicator));else if(u.position==="past_end_of_stream"&&u.eof_action==="error")e.throw_error(i.error.permission("input","past_end_of_stream",s,t.indicator));else{var p;if(u.position==="end_of_stream")p=-1,u.position="past_end_of_stream";else{if(p=u.stream.get(1,u.position),p===null){e.throw_error(i.error.representation("character",t.indicator));return}p=_(p,0)}e.prepend([new V(n.goal.replace(new o("=",[new E(p,!1),a])),n.substitution,n)])}},"put_char/1":function(e,n,t){var s=t.args[0];e.prepend([new V(n.goal.replace(new o(",",[new o("current_output",[new I("S")]),new o("put_char",[new I("S"),s])])),n.substitution,n)])},"put_char/2":function(e,n,t){var s=t.args[0],a=t.args[1],u=i.type.is_stream(s)?s:e.get_stream_by_alias(s.id);i.type.is_variable(s)||i.type.is_variable(a)?e.throw_error(i.error.instantiation(t.indicator)):i.type.is_character(a)?!i.type.is_variable(s)&&!i.type.is_stream(s)&&!i.type.is_atom(s)?e.throw_error(i.error.domain("stream_or_alias",s,t.indicator)):!i.type.is_stream(u)||u.stream===null?e.throw_error(i.error.existence("stream",s,t.indicator)):u.input?e.throw_error(i.error.permission("output","stream",s,t.indicator)):u.type==="binary"?e.throw_error(i.error.permission("output","binary_stream",s,t.indicator)):u.stream.put(a.id,u.position)&&(typeof u.position=="number"&&u.position++,e.success(n)):e.throw_error(i.error.type("character",a,t.indicator))},"put_code/1":function(e,n,t){var s=t.args[0];e.prepend([new V(n.goal.replace(new o(",",[new o("current_output",[new I("S")]),new o("put_code",[new I("S"),s])])),n.substitution,n)])},"put_code/2":function(e,n,t){var s=t.args[0],a=t.args[1],u=i.type.is_stream(s)?s:e.get_stream_by_alias(s.id);i.type.is_variable(s)||i.type.is_variable(a)?e.throw_error(i.error.instantiation(t.indicator)):i.type.is_integer(a)?i.type.is_character_code(a)?!i.type.is_variable(s)&&!i.type.is_stream(s)&&!i.type.is_atom(s)?e.throw_error(i.error.domain("stream_or_alias",s,t.indicator)):!i.type.is_stream(u)||u.stream===null?e.throw_error(i.error.existence("stream",s,t.indicator)):u.input?e.throw_error(i.error.permission("output","stream",s,t.indicator)):u.type==="binary"?e.throw_error(i.error.permission("output","binary_stream",s,t.indicator)):u.stream.put_char(v(a.value),u.position)&&(typeof u.position=="number"&&u.position++,e.success(n)):e.throw_error(i.error.representation("character_code",t.indicator)):e.throw_error(i.error.type("integer",a,t.indicator))},"nl/0":function(e,n,t){e.prepend([new V(n.goal.replace(new o(",",[new o("current_output",[new I("S")]),new o("put_char",[new I("S"),new o(`
|
|
`,[])])])),n.substitution,n)])},"nl/1":function(e,n,t){var s=t.args[0];e.prepend([new V(n.goal.replace(new o("put_char",[s,new o(`
|
|
`,[])])),n.substitution,n)])},"get_byte/1":function(e,n,t){var s=t.args[0];e.prepend([new V(n.goal.replace(new o(",",[new o("current_input",[new I("S")]),new o("get_byte",[new I("S"),s])])),n.substitution,n)])},"get_byte/2":function(e,n,t){var s=t.args[0],a=t.args[1],u=i.type.is_stream(s)?s:e.get_stream_by_alias(s.id);if(i.type.is_variable(s))e.throw_error(i.error.instantiation(t.indicator));else if(!i.type.is_variable(a)&&!i.type.is_byte(a))e.throw_error(i.error.type("in_byte",char,t.indicator));else if(!i.type.is_stream(s)&&!i.type.is_atom(s))e.throw_error(i.error.domain("stream_or_alias",s,t.indicator));else if(!i.type.is_stream(u)||u.stream===null)e.throw_error(i.error.existence("stream",s,t.indicator));else if(u.output)e.throw_error(i.error.permission("input","stream",s,t.indicator));else if(u.type==="text")e.throw_error(i.error.permission("input","text_stream",s,t.indicator));else if(u.position==="past_end_of_stream"&&u.eof_action==="error")e.throw_error(i.error.permission("input","past_end_of_stream",s,t.indicator));else{var p;if(u.position==="end_of_stream")p="end_of_file",u.position="past_end_of_stream";else{if(p=u.stream.get_byte(u.position),p===null){e.throw_error(i.error.representation("byte",t.indicator));return}u.position++}e.prepend([new V(n.goal.replace(new o("=",[new E(p,!1),a])),n.substitution,n)])}},"peek_byte/1":function(e,n,t){var s=t.args[0];e.prepend([new V(n.goal.replace(new o(",",[new o("current_input",[new I("S")]),new o("peek_byte",[new I("S"),s])])),n.substitution,n)])},"peek_byte/2":function(e,n,t){var s=t.args[0],a=t.args[1],u=i.type.is_stream(s)?s:e.get_stream_by_alias(s.id);if(i.type.is_variable(s))e.throw_error(i.error.instantiation(t.indicator));else if(!i.type.is_variable(a)&&!i.type.is_byte(a))e.throw_error(i.error.type("in_byte",char,t.indicator));else if(!i.type.is_stream(s)&&!i.type.is_atom(s))e.throw_error(i.error.domain("stream_or_alias",s,t.indicator));else if(!i.type.is_stream(u)||u.stream===null)e.throw_error(i.error.existence("stream",s,t.indicator));else if(u.output)e.throw_error(i.error.permission("input","stream",s,t.indicator));else if(u.type==="text")e.throw_error(i.error.permission("input","text_stream",s,t.indicator));else if(u.position==="past_end_of_stream"&&u.eof_action==="error")e.throw_error(i.error.permission("input","past_end_of_stream",s,t.indicator));else{var p;if(u.position==="end_of_stream")p="end_of_file",u.position="past_end_of_stream";else if(p=u.stream.get_byte(u.position),p===null){e.throw_error(i.error.representation("byte",t.indicator));return}e.prepend([new V(n.goal.replace(new o("=",[new E(p,!1),a])),n.substitution,n)])}},"put_byte/1":function(e,n,t){var s=t.args[0];e.prepend([new V(n.goal.replace(new o(",",[new o("current_output",[new I("S")]),new o("put_byte",[new I("S"),s])])),n.substitution,n)])},"put_byte/2":function(e,n,t){var s=t.args[0],a=t.args[1],u=i.type.is_stream(s)?s:e.get_stream_by_alias(s.id);i.type.is_variable(s)||i.type.is_variable(a)?e.throw_error(i.error.instantiation(t.indicator)):i.type.is_byte(a)?!i.type.is_variable(s)&&!i.type.is_stream(s)&&!i.type.is_atom(s)?e.throw_error(i.error.domain("stream_or_alias",s,t.indicator)):!i.type.is_stream(u)||u.stream===null?e.throw_error(i.error.existence("stream",s,t.indicator)):u.input?e.throw_error(i.error.permission("output","stream",s,t.indicator)):u.type==="text"?e.throw_error(i.error.permission("output","text_stream",s,t.indicator)):u.stream.put_byte(a.value,u.position)&&(typeof u.position=="number"&&u.position++,e.success(n)):e.throw_error(i.error.type("byte",a,t.indicator))},"read/1":function(e,n,t){var s=t.args[0];e.prepend([new V(n.goal.replace(new o(",",[new o("current_input",[new I("S")]),new o("read_term",[new I("S"),s,new o("[]",[])])])),n.substitution,n)])},"read/2":function(e,n,t){var s=t.args[0],a=t.args[1];e.prepend([new V(n.goal.replace(new o("read_term",[s,a,new o("[]",[])])),n.substitution,n)])},"read_term/2":function(e,n,t){var s=t.args[0],a=t.args[1];e.prepend([new V(n.goal.replace(new o(",",[new o("current_input",[new I("S")]),new o("read_term",[new I("S"),s,a])])),n.substitution,n)])},"read_term/3":function(e,n,t){var s=t.args[0],a=t.args[1],u=t.args[2],p=i.type.is_stream(s)?s:e.get_stream_by_alias(s.id);if(i.type.is_variable(s)||i.type.is_variable(u))e.throw_error(i.error.instantiation(t.indicator));else if(!i.type.is_list(u))e.throw_error(i.error.type("list",u,t.indicator));else if(!i.type.is_stream(s)&&!i.type.is_atom(s))e.throw_error(i.error.domain("stream_or_alias",s,t.indicator));else if(!i.type.is_stream(p)||p.stream===null)e.throw_error(i.error.existence("stream",s,t.indicator));else if(p.output)e.throw_error(i.error.permission("input","stream",s,t.indicator));else if(p.type==="binary")e.throw_error(i.error.permission("input","binary_stream",s,t.indicator));else if(p.position==="past_end_of_stream"&&p.eof_action==="error")e.throw_error(i.error.permission("input","past_end_of_stream",s,t.indicator));else{for(var y={},d=u,m;i.type.is_term(d)&&d.indicator==="./2";){if(m=d.args[0],i.type.is_variable(m)){e.throw_error(i.error.instantiation(t.indicator));return}else if(!i.type.is_read_option(m)){e.throw_error(i.error.domain("read_option",m,t.indicator));return}y[m.id]=m.args[0],d=d.args[1]}if(d.indicator!=="[]/0"){i.type.is_variable(d)?e.throw_error(i.error.instantiation(t.indicator)):e.throw_error(i.error.type("list",u,t.indicator));return}else{for(var S,O,A,R="",k=[],L=null;L===null||L.name!=="atom"||L.value!=="."||A.type===g&&i.flatten_error(new o("throw",[A.value])).found==="token_not_found";){if(S=p.stream.get(1,p.position),S===null){e.throw_error(i.error.representation("character",t.indicator));return}if(S==="end_of_file"||S==="past_end_of_file"){A?e.throw_error(i.error.syntax(k[A.len-1],". or expression expected",!1)):e.throw_error(i.error.syntax(null,"token not found",!0));return}p.position++,R+=S,O=new ee(e),O.new_text(R),k=O.get_tokens(),L=k!==null&&k.length>0?k[k.length-1]:null,k!==null&&(A=U(e,k,0,e.__get_max_priority(),!1))}if(A.type===h&&A.len===k.length-1&&L.value==="."){A=A.value.rename(e);var B=new o("=",[a,A]);if(y.variables){var q=me(c(yr(A.variables()),function(F){return new I(F)}));B=new o(",",[B,new o("=",[y.variables,q])])}if(y.variable_names){var q=me(c(yr(A.variables()),function(H){var K;for(K in e.session.renamed_variables)if(e.session.renamed_variables.hasOwnProperty(K)&&e.session.renamed_variables[K]===H)break;return new o("=",[new o(K,[]),new I(H)])}));B=new o(",",[B,new o("=",[y.variable_names,q])])}if(y.singletons){var q=me(c(new J(A,null).singleton_variables(),function(H){var K;for(K in e.session.renamed_variables)if(e.session.renamed_variables.hasOwnProperty(K)&&e.session.renamed_variables[K]===H)break;return new o("=",[new o(K,[]),new I(H)])}));B=new o(",",[B,new o("=",[y.singletons,q])])}e.prepend([new V(n.goal.replace(B),n.substitution,n)])}else A.type===h?e.throw_error(i.error.syntax(k[A.len],"unexpected token",!1)):e.throw_error(A.value)}}},"write/1":function(e,n,t){var s=t.args[0];e.prepend([new V(n.goal.replace(new o(",",[new o("current_output",[new I("S")]),new o("write",[new I("S"),s])])),n.substitution,n)])},"write/2":function(e,n,t){var s=t.args[0],a=t.args[1];e.prepend([new V(n.goal.replace(new o("write_term",[s,a,new o(".",[new o("quoted",[new o("false",[])]),new o(".",[new o("ignore_ops",[new o("false")]),new o(".",[new o("numbervars",[new o("true")]),new o("[]",[])])])])])),n.substitution,n)])},"writeq/1":function(e,n,t){var s=t.args[0];e.prepend([new V(n.goal.replace(new o(",",[new o("current_output",[new I("S")]),new o("writeq",[new I("S"),s])])),n.substitution,n)])},"writeq/2":function(e,n,t){var s=t.args[0],a=t.args[1];e.prepend([new V(n.goal.replace(new o("write_term",[s,a,new o(".",[new o("quoted",[new o("true",[])]),new o(".",[new o("ignore_ops",[new o("false")]),new o(".",[new o("numbervars",[new o("true")]),new o("[]",[])])])])])),n.substitution,n)])},"write_canonical/1":function(e,n,t){var s=t.args[0];e.prepend([new V(n.goal.replace(new o(",",[new o("current_output",[new I("S")]),new o("write_canonical",[new I("S"),s])])),n.substitution,n)])},"write_canonical/2":function(e,n,t){var s=t.args[0],a=t.args[1];e.prepend([new V(n.goal.replace(new o("write_term",[s,a,new o(".",[new o("quoted",[new o("true",[])]),new o(".",[new o("ignore_ops",[new o("true")]),new o(".",[new o("numbervars",[new o("false")]),new o("[]",[])])])])])),n.substitution,n)])},"write_term/2":function(e,n,t){var s=t.args[0],a=t.args[1];e.prepend([new V(n.goal.replace(new o(",",[new o("current_output",[new I("S")]),new o("write_term",[new I("S"),s,a])])),n.substitution,n)])},"write_term/3":function(e,n,t){var s=t.args[0],a=t.args[1],u=t.args[2],p=i.type.is_stream(s)?s:e.get_stream_by_alias(s.id);if(i.type.is_variable(s)||i.type.is_variable(u))e.throw_error(i.error.instantiation(t.indicator));else if(!i.type.is_list(u))e.throw_error(i.error.type("list",u,t.indicator));else if(!i.type.is_stream(s)&&!i.type.is_atom(s))e.throw_error(i.error.domain("stream_or_alias",s,t.indicator));else if(!i.type.is_stream(p)||p.stream===null)e.throw_error(i.error.existence("stream",s,t.indicator));else if(p.input)e.throw_error(i.error.permission("output","stream",s,t.indicator));else if(p.type==="binary")e.throw_error(i.error.permission("output","binary_stream",s,t.indicator));else if(p.position==="past_end_of_stream"&&p.eof_action==="error")e.throw_error(i.error.permission("output","past_end_of_stream",s,t.indicator));else{for(var y={},d=u,m;i.type.is_term(d)&&d.indicator==="./2";){if(m=d.args[0],i.type.is_variable(m)){e.throw_error(i.error.instantiation(t.indicator));return}else if(!i.type.is_write_option(m)){e.throw_error(i.error.domain("write_option",m,t.indicator));return}y[m.id]=m.args[0].id==="true",d=d.args[1]}if(d.indicator!=="[]/0"){i.type.is_variable(d)?e.throw_error(i.error.instantiation(t.indicator)):e.throw_error(i.error.type("list",u,t.indicator));return}else{y.session=e.session;var S=a.toString(y);p.stream.put(S,p.position),typeof p.position=="number"&&(p.position+=S.length),e.success(n)}}},"halt/0":function(e,n,t){e.points=[]},"halt/1":function(e,n,t){var s=t.args[0];i.type.is_variable(s)?e.throw_error(i.error.instantiation(t.indicator)):i.type.is_integer(s)?e.points=[]:e.throw_error(i.error.type("integer",s,t.indicator))},"current_prolog_flag/2":function(e,n,t){var s=t.args[0],a=t.args[1];if(!i.type.is_variable(s)&&!i.type.is_atom(s))e.throw_error(i.error.type("atom",s,t.indicator));else if(!i.type.is_variable(s)&&!i.type.is_flag(s))e.throw_error(i.error.domain("prolog_flag",s,t.indicator));else{var u=[];for(var p in i.flag)if(!!i.flag.hasOwnProperty(p)){var y=new o(",",[new o("=",[new o(p),s]),new o("=",[e.get_flag(p),a])]);u.push(new V(n.goal.replace(y),n.substitution,n))}e.prepend(u)}},"set_prolog_flag/2":function(e,n,t){var s=t.args[0],a=t.args[1];i.type.is_variable(s)||i.type.is_variable(a)?e.throw_error(i.error.instantiation(t.indicator)):i.type.is_atom(s)?i.type.is_flag(s)?i.type.is_value_flag(s,a)?i.type.is_modifiable_flag(s)?(e.session.flag[s.id]=a,e.success(n)):e.throw_error(i.error.permission("modify","flag",s)):e.throw_error(i.error.domain("flag_value",new o("+",[s,a]),t.indicator)):e.throw_error(i.error.domain("prolog_flag",s,t.indicator)):e.throw_error(i.error.type("atom",s,t.indicator))}},flag:{bounded:{allowed:[new o("true"),new o("false")],value:new o("true"),changeable:!1},max_integer:{allowed:[new E(Number.MAX_SAFE_INTEGER)],value:new E(Number.MAX_SAFE_INTEGER),changeable:!1},min_integer:{allowed:[new E(Number.MIN_SAFE_INTEGER)],value:new E(Number.MIN_SAFE_INTEGER),changeable:!1},integer_rounding_function:{allowed:[new o("down"),new o("toward_zero")],value:new o("toward_zero"),changeable:!1},char_conversion:{allowed:[new o("on"),new o("off")],value:new o("on"),changeable:!0},debug:{allowed:[new o("on"),new o("off")],value:new o("off"),changeable:!0},max_arity:{allowed:[new o("unbounded")],value:new o("unbounded"),changeable:!1},unknown:{allowed:[new o("error"),new o("fail"),new o("warning")],value:new o("error"),changeable:!0},double_quotes:{allowed:[new o("chars"),new o("codes"),new o("atom")],value:new o("codes"),changeable:!0},occurs_check:{allowed:[new o("false"),new o("true")],value:new o("false"),changeable:!0},dialect:{allowed:[new o("tau")],value:new o("tau"),changeable:!1},version_data:{allowed:[new o("tau",[new E(r.major,!1),new E(r.minor,!1),new E(r.patch,!1),new o(r.status)])],value:new o("tau",[new E(r.major,!1),new E(r.minor,!1),new E(r.patch,!1),new o(r.status)]),changeable:!1},nodejs:{allowed:[new o("yes"),new o("no")],value:new o(typeof ie<"u"&&ie.exports?"yes":"no"),changeable:!1}},unify:function(e,n,t){t=t===void 0?!1:t;for(var s=[{left:e,right:n}],a={};s.length!==0;){var u=s.pop();if(e=u.left,n=u.right,i.type.is_term(e)&&i.type.is_term(n)){if(e.indicator!==n.indicator)return null;for(var p=0;p<e.args.length;p++)s.push({left:e.args[p],right:n.args[p]})}else if(i.type.is_number(e)&&i.type.is_number(n)){if(e.value!==n.value||e.is_float!==n.is_float)return null}else if(i.type.is_variable(e)){if(i.type.is_variable(n)&&e.id===n.id)continue;if(t===!0&&n.variables().indexOf(e.id)!==-1)return null;if(e.id!=="_"){var y=new Y;y.add(e.id,n);for(var p=0;p<s.length;p++)s[p].left=s[p].left.apply(y),s[p].right=s[p].right.apply(y);for(var p in a)a[p]=a[p].apply(y);a[e.id]=n}}else if(i.type.is_variable(n))s.push({left:n,right:e});else if(e.unify!==void 0){if(!e.unify(n))return null}else return null}return new Y(a)},compare:function(e,n){var t=i.type.compare(e,n);return t!==0?t:e.compare(n)},arithmetic_compare:function(e,n,t){var s=n.interpret(e);if(i.type.is_number(s)){var a=t.interpret(e);return i.type.is_number(a)?s.value<a.value?-1:s.value>a.value?1:0:a}else return s},operate:function(e,n){if(i.type.is_operator(n)){for(var t=i.type.is_operator(n),s=[],a,u=!1,p=0;p<n.args.length;p++){if(a=n.args[p].interpret(e),i.type.is_number(a)){if(t.type_args!==null&&a.is_float!==t.type_args)return i.error.type(t.type_args?"float":"integer",a,e.__call_indicator);s.push(a.value)}else return a;u=u||a.is_float}return s.push(e),a=i.arithmetic.evaluation[n.indicator].fn.apply(this,s),u=t.type_result===null?u:t.type_result,i.type.is_term(a)?a:a===Number.POSITIVE_INFINITY||a===Number.NEGATIVE_INFINITY?i.error.evaluation("overflow",e.__call_indicator):u===!1&&e.get_flag("bounded").id==="true"&&(a>e.get_flag("max_integer").value||a<e.get_flag("min_integer").value)?i.error.evaluation("int_overflow",e.__call_indicator):new E(a,u)}else return i.error.type("evaluable",n.indicator,e.__call_indicator)},error:{existence:function(e,n,t){return typeof n=="string"&&(n=oe(n)),new o("error",[new o("existence_error",[new o(e),n]),oe(t)])},type:function(e,n,t){return new o("error",[new o("type_error",[new o(e),n]),oe(t)])},instantiation:function(e){return new o("error",[new o("instantiation_error"),oe(e)])},domain:function(e,n,t){return new o("error",[new o("domain_error",[new o(e),n]),oe(t)])},representation:function(e,n){return new o("error",[new o("representation_error",[new o(e)]),oe(n)])},permission:function(e,n,t,s){return new o("error",[new o("permission_error",[new o(e),new o(n),t]),oe(s)])},evaluation:function(e,n){return new o("error",[new o("evaluation_error",[new o(e)]),oe(n)])},syntax:function(e,n,t){e=e||{value:"",line:0,column:0,matches:[""],start:0};var s=t&&e.matches.length>0?e.start+e.matches[0].length:e.start,a=t?new o("token_not_found"):new o("found",[new o(e.value.toString())]),u=new o(".",[new o("line",[new E(e.line+1)]),new o(".",[new o("column",[new E(s+1)]),new o(".",[a,new o("[]",[])])])]);return new o("error",[new o("syntax_error",[new o(n)]),u])},syntax_by_predicate:function(e,n){return new o("error",[new o("syntax_error",[new o(e)]),oe(n)])}},warning:{singleton:function(e,n,t){for(var s=new o("[]"),a=e.length-1;a>=0;a--)s=new o(".",[new I(e[a]),s]);return new o("warning",[new o("singleton_variables",[s,oe(n)]),new o(".",[new o("line",[new E(t,!1)]),new o("[]")])])},failed_goal:function(e,n){return new o("warning",[new o("failed_goal",[e]),new o(".",[new o("line",[new E(n,!1)]),new o("[]")])])}},format_variable:function(e){return"_"+e},format_answer:function(e,n,s){n instanceof D&&(n=n.thread);var s=s||{};if(s.session=n?n.session:void 0,i.type.is_error(e))return"uncaught exception: "+e.args[0].toString();if(e===!1)return"false.";if(e===null)return"limit exceeded ;";var a=0,u="";if(i.type.is_substitution(e)){var p=e.domain(!0);e=e.filter(function(m,S){return!i.type.is_variable(S)||p.indexOf(S.id)!==-1&&m!==S.id})}for(var y in e.links)!e.links.hasOwnProperty(y)||(a++,u!==""&&(u+=", "),u+=y.toString(s)+" = "+e.links[y].toString(s));var d=typeof n>"u"||n.points.length>0?" ;":".";return a===0?"true"+d:u+d},flatten_error:function(e){if(!i.type.is_error(e))return null;e=e.args[0];var n={};return n.type=e.args[0].id,n.thrown=n.type==="syntax_error"?null:e.args[1].id,n.expected=null,n.found=null,n.representation=null,n.existence=null,n.existence_type=null,n.line=null,n.column=null,n.permission_operation=null,n.permission_type=null,n.evaluation_type=null,n.type==="type_error"||n.type==="domain_error"?(n.expected=e.args[0].args[0].id,n.found=e.args[0].args[1].toString()):n.type==="syntax_error"?e.args[1].indicator==="./2"?(n.expected=e.args[0].args[0].id,n.found=e.args[1].args[1].args[1].args[0],n.found=n.found.id==="token_not_found"?n.found.id:n.found.args[0].id,n.line=e.args[1].args[0].args[0].value,n.column=e.args[1].args[1].args[0].args[0].value):n.thrown=e.args[1].id:n.type==="permission_error"?(n.found=e.args[0].args[2].toString(),n.permission_operation=e.args[0].args[0].id,n.permission_type=e.args[0].args[1].id):n.type==="evaluation_error"?n.evaluation_type=e.args[0].args[0].id:n.type==="representation_error"?n.representation=e.args[0].args[0].id:n.type==="existence_error"&&(n.existence=e.args[0].args[1].toString(),n.existence_type=e.args[0].args[0].id),n},create:function(e){return new i.type.Session(e)}};typeof ie<"u"?ie.exports=i:window.pl=i})()});var er=C((Nu,nt)=>{var rs=Array.isArray;nt.exports=rs});var st=C((Ru,it)=>{var ts=typeof global=="object"&&global&&global.Object===Object&&global;it.exports=ts});var rr=C((Mu,at)=>{var ns=st(),is=typeof self=="object"&&self&&self.Object===Object&&self,ss=ns||is||Function("return this")();at.exports=ss});var tr=C((qu,ot)=>{var as=rr(),os=as.Symbol;ot.exports=os});var ft=C(($u,ct)=>{var ut=tr(),lt=Object.prototype,us=lt.hasOwnProperty,ls=lt.toString,We=ut?ut.toStringTag:void 0;function cs(r){var l=us.call(r,We),f=r[We];try{r[We]=void 0;var c=!0}catch{}var w=ls.call(r);return c&&(l?r[We]=f:delete r[We]),w}ct.exports=cs});var yt=C((Du,pt)=>{var fs=Object.prototype,ps=fs.toString;function ys(r){return ps.call(r)}pt.exports=ys});var Pr=C((Xu,gt)=>{var _t=tr(),_s=ft(),ws=yt(),gs="[object Null]",ds="[object Undefined]",wt=_t?_t.toStringTag:void 0;function vs(r){return r==null?r===void 0?ds:gs:wt&&wt in Object(r)?_s(r):ws(r)}gt.exports=vs});var vt=C((Bu,dt)=>{function hs(r){return r!=null&&typeof r=="object"}dt.exports=hs});var nr=C((Fu,ht)=>{var ms=Pr(),bs=vt(),Ts="[object Symbol]";function xs(r){return typeof r=="symbol"||bs(r)&&ms(r)==Ts}ht.exports=xs});var bt=C((zu,mt)=>{var Vs=er(),Ss=nr(),ks=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,Ps=/^\w*$/;function Os(r,l){if(Vs(r))return!1;var f=typeof r;return f=="number"||f=="symbol"||f=="boolean"||r==null||Ss(r)?!0:Ps.test(r)||!ks.test(r)||l!=null&&r in Object(l)}mt.exports=Os});var ir=C((Wu,Tt)=>{function Is(r){var l=typeof r;return r!=null&&(l=="object"||l=="function")}Tt.exports=Is});var Vt=C((Lu,xt)=>{var Cs=Pr(),Es=ir(),As="[object AsyncFunction]",Ns="[object Function]",Rs="[object GeneratorFunction]",Ms="[object Proxy]";function qs(r){if(!Es(r))return!1;var l=Cs(r);return l==Ns||l==Rs||l==As||l==Ms}xt.exports=qs});var kt=C((Hu,St)=>{var $s=rr(),Ds=$s["__core-js_shared__"];St.exports=Ds});var It=C((Yu,Ot)=>{var Or=kt(),Pt=function(){var r=/[^.]+$/.exec(Or&&Or.keys&&Or.keys.IE_PROTO||"");return r?"Symbol(src)_1."+r:""}();function Xs(r){return!!Pt&&Pt in r}Ot.exports=Xs});var Et=C((Gu,Ct)=>{var Bs=Function.prototype,Fs=Bs.toString;function zs(r){if(r!=null){try{return Fs.call(r)}catch{}try{return r+""}catch{}}return""}Ct.exports=zs});var Nt=C((Uu,At)=>{var Ws=Vt(),Ls=It(),Hs=ir(),Ys=Et(),Gs=/[\\^$.*+?()[\]{}|]/g,Us=/^\[object .+?Constructor\]$/,Zs=Function.prototype,Qs=Object.prototype,Js=Zs.toString,Ks=Qs.hasOwnProperty,js=RegExp("^"+Js.call(Ks).replace(Gs,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function ea(r){if(!Hs(r)||Ls(r))return!1;var l=Ws(r)?js:Us;return l.test(Ys(r))}At.exports=ea});var Mt=C((Zu,Rt)=>{function ra(r,l){return r==null?void 0:r[l]}Rt.exports=ra});var sr=C((Qu,qt)=>{var ta=Nt(),na=Mt();function ia(r,l){var f=na(r,l);return ta(f)?f:void 0}qt.exports=ia});var Le=C((Ju,$t)=>{var sa=sr(),aa=sa(Object,"create");$t.exports=aa});var Bt=C((Ku,Xt)=>{var Dt=Le();function oa(){this.__data__=Dt?Dt(null):{},this.size=0}Xt.exports=oa});var zt=C((ju,Ft)=>{function ua(r){var l=this.has(r)&&delete this.__data__[r];return this.size-=l?1:0,l}Ft.exports=ua});var Lt=C((el,Wt)=>{var la=Le(),ca="__lodash_hash_undefined__",fa=Object.prototype,pa=fa.hasOwnProperty;function ya(r){var l=this.__data__;if(la){var f=l[r];return f===ca?void 0:f}return pa.call(l,r)?l[r]:void 0}Wt.exports=ya});var Yt=C((rl,Ht)=>{var _a=Le(),wa=Object.prototype,ga=wa.hasOwnProperty;function da(r){var l=this.__data__;return _a?l[r]!==void 0:ga.call(l,r)}Ht.exports=da});var Ut=C((tl,Gt)=>{var va=Le(),ha="__lodash_hash_undefined__";function ma(r,l){var f=this.__data__;return this.size+=this.has(r)?0:1,f[r]=va&&l===void 0?ha:l,this}Gt.exports=ma});var Qt=C((nl,Zt)=>{var ba=Bt(),Ta=zt(),xa=Lt(),Va=Yt(),Sa=Ut();function Re(r){var l=-1,f=r==null?0:r.length;for(this.clear();++l<f;){var c=r[l];this.set(c[0],c[1])}}Re.prototype.clear=ba;Re.prototype.delete=Ta;Re.prototype.get=xa;Re.prototype.has=Va;Re.prototype.set=Sa;Zt.exports=Re});var Kt=C((il,Jt)=>{function ka(){this.__data__=[],this.size=0}Jt.exports=ka});var Ir=C((sl,jt)=>{function Pa(r,l){return r===l||r!==r&&l!==l}jt.exports=Pa});var He=C((al,en)=>{var Oa=Ir();function Ia(r,l){for(var f=r.length;f--;)if(Oa(r[f][0],l))return f;return-1}en.exports=Ia});var tn=C((ol,rn)=>{var Ca=He(),Ea=Array.prototype,Aa=Ea.splice;function Na(r){var l=this.__data__,f=Ca(l,r);if(f<0)return!1;var c=l.length-1;return f==c?l.pop():Aa.call(l,f,1),--this.size,!0}rn.exports=Na});var sn=C((ul,nn)=>{var Ra=He();function Ma(r){var l=this.__data__,f=Ra(l,r);return f<0?void 0:l[f][1]}nn.exports=Ma});var on=C((ll,an)=>{var qa=He();function $a(r){return qa(this.__data__,r)>-1}an.exports=$a});var ln=C((cl,un)=>{var Da=He();function Xa(r,l){var f=this.__data__,c=Da(f,r);return c<0?(++this.size,f.push([r,l])):f[c][1]=l,this}un.exports=Xa});var fn=C((fl,cn)=>{var Ba=Kt(),Fa=tn(),za=sn(),Wa=on(),La=ln();function Me(r){var l=-1,f=r==null?0:r.length;for(this.clear();++l<f;){var c=r[l];this.set(c[0],c[1])}}Me.prototype.clear=Ba;Me.prototype.delete=Fa;Me.prototype.get=za;Me.prototype.has=Wa;Me.prototype.set=La;cn.exports=Me});var yn=C((pl,pn)=>{var Ha=sr(),Ya=rr(),Ga=Ha(Ya,"Map");pn.exports=Ga});var gn=C((yl,wn)=>{var _n=Qt(),Ua=fn(),Za=yn();function Qa(){this.size=0,this.__data__={hash:new _n,map:new(Za||Ua),string:new _n}}wn.exports=Qa});var vn=C((_l,dn)=>{function Ja(r){var l=typeof r;return l=="string"||l=="number"||l=="symbol"||l=="boolean"?r!=="__proto__":r===null}dn.exports=Ja});var Ye=C((wl,hn)=>{var Ka=vn();function ja(r,l){var f=r.__data__;return Ka(l)?f[typeof l=="string"?"string":"hash"]:f.map}hn.exports=ja});var bn=C((gl,mn)=>{var eo=Ye();function ro(r){var l=eo(this,r).delete(r);return this.size-=l?1:0,l}mn.exports=ro});var xn=C((dl,Tn)=>{var to=Ye();function no(r){return to(this,r).get(r)}Tn.exports=no});var Sn=C((vl,Vn)=>{var io=Ye();function so(r){return io(this,r).has(r)}Vn.exports=so});var Pn=C((hl,kn)=>{var ao=Ye();function oo(r,l){var f=ao(this,r),c=f.size;return f.set(r,l),this.size+=f.size==c?0:1,this}kn.exports=oo});var In=C((ml,On)=>{var uo=gn(),lo=bn(),co=xn(),fo=Sn(),po=Pn();function qe(r){var l=-1,f=r==null?0:r.length;for(this.clear();++l<f;){var c=r[l];this.set(c[0],c[1])}}qe.prototype.clear=uo;qe.prototype.delete=lo;qe.prototype.get=co;qe.prototype.has=fo;qe.prototype.set=po;On.exports=qe});var An=C((bl,En)=>{var Cn=In(),yo="Expected a function";function Cr(r,l){if(typeof r!="function"||l!=null&&typeof l!="function")throw new TypeError(yo);var f=function(){var c=arguments,w=l?l.apply(this,c):c[0],_=f.cache;if(_.has(w))return _.get(w);var v=r.apply(this,c);return f.cache=_.set(w,v)||_,v};return f.cache=new(Cr.Cache||Cn),f}Cr.Cache=Cn;En.exports=Cr});var Rn=C((Tl,Nn)=>{var _o=An(),wo=500;function go(r){var l=_o(r,function(c){return f.size===wo&&f.clear(),c}),f=l.cache;return l}Nn.exports=go});var qn=C((xl,Mn)=>{var vo=Rn(),ho=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,mo=/\\(\\)?/g,bo=vo(function(r){var l=[];return r.charCodeAt(0)===46&&l.push(""),r.replace(ho,function(f,c,w,_){l.push(w?_.replace(mo,"$1"):c||f)}),l});Mn.exports=bo});var Dn=C((Vl,$n)=>{function To(r,l){for(var f=-1,c=r==null?0:r.length,w=Array(c);++f<c;)w[f]=l(r[f],f,r);return w}$n.exports=To});var Ln=C((Sl,Wn)=>{var Xn=tr(),xo=Dn(),Vo=er(),So=nr(),ko=1/0,Bn=Xn?Xn.prototype:void 0,Fn=Bn?Bn.toString:void 0;function zn(r){if(typeof r=="string")return r;if(Vo(r))return xo(r,zn)+"";if(So(r))return Fn?Fn.call(r):"";var l=r+"";return l=="0"&&1/r==-ko?"-0":l}Wn.exports=zn});var Yn=C((kl,Hn)=>{var Po=Ln();function Oo(r){return r==null?"":Po(r)}Hn.exports=Oo});var ar=C((Pl,Gn)=>{var Io=er(),Co=bt(),Eo=qn(),Ao=Yn();function No(r,l){return Io(r)?r:Co(r,l)?[r]:Eo(Ao(r))}Gn.exports=No});var or=C((Ol,Un)=>{var Ro=nr(),Mo=1/0;function qo(r){if(typeof r=="string"||Ro(r))return r;var l=r+"";return l=="0"&&1/r==-Mo?"-0":l}Un.exports=qo});var Er=C((Il,Zn)=>{var $o=ar(),Do=or();function Xo(r,l){l=$o(l,r);for(var f=0,c=l.length;r!=null&&f<c;)r=r[Do(l[f++])];return f&&f==c?r:void 0}Zn.exports=Xo});var Ar=C((Cl,Qn)=>{var Bo=Er();function Fo(r,l,f){var c=r==null?void 0:Bo(r,l);return c===void 0?f:c}Qn.exports=Fo});var ui=C((Hl,oi)=>{var Uo=sr(),Zo=function(){try{var r=Uo(Object,"defineProperty");return r({},"",{}),r}catch{}}();oi.exports=Zo});var fi=C((Yl,ci)=>{var li=ui();function Qo(r,l,f){l=="__proto__"&&li?li(r,l,{configurable:!0,enumerable:!0,value:f,writable:!0}):r[l]=f}ci.exports=Qo});var yi=C((Gl,pi)=>{var Jo=fi(),Ko=Ir(),jo=Object.prototype,eu=jo.hasOwnProperty;function ru(r,l,f){var c=r[l];(!(eu.call(r,l)&&Ko(c,f))||f===void 0&&!(l in r))&&Jo(r,l,f)}pi.exports=ru});var wi=C((Ul,_i)=>{var tu=9007199254740991,nu=/^(?:0|[1-9]\d*)$/;function iu(r,l){var f=typeof r;return l=l==null?tu:l,!!l&&(f=="number"||f!="symbol"&&nu.test(r))&&r>-1&&r%1==0&&r<l}_i.exports=iu});var vi=C((Zl,di)=>{var su=yi(),au=ar(),ou=wi(),gi=ir(),uu=or();function lu(r,l,f,c){if(!gi(r))return r;l=au(l,r);for(var w=-1,_=l.length,v=_-1,g=r;g!=null&&++w<_;){var h=uu(l[w]),T=f;if(h==="__proto__"||h==="constructor"||h==="prototype")return r;if(w!=v){var x=g[h];T=c?c(x,h,g):void 0,T===void 0&&(T=gi(x)?x:ou(l[w+1])?[]:{})}su(g,h,T),g=g[h]}return r}di.exports=lu});var mi=C((Ql,hi)=>{var cu=vi();function fu(r,l,f){return r==null?r:cu(r,l,f)}hi.exports=fu});var Ti=C((Jl,bi)=>{function pu(r){var l=r==null?0:r.length;return l?r[l-1]:void 0}bi.exports=pu});var Vi=C((Kl,xi)=>{function yu(r,l,f){var c=-1,w=r.length;l<0&&(l=-l>w?0:w+l),f=f>w?w:f,f<0&&(f+=w),w=l>f?0:f-l>>>0,l>>>=0;for(var _=Array(w);++c<w;)_[c]=r[c+l];return _}xi.exports=yu});var ki=C((jl,Si)=>{var _u=Er(),wu=Vi();function gu(r,l){return l.length<2?r:_u(r,wu(l,0,-1))}Si.exports=gu});var Oi=C((ec,Pi)=>{var du=ar(),vu=Ti(),hu=ki(),mu=or();function bu(r,l){return l=du(l,r),r=hu(r,l),r==null||delete r[mu(vu(l))]}Pi.exports=bu});var Ci=C((rc,Ii)=>{var Tu=Oi();function xu(r,l){return r==null?!0:Tu(r,l)}Ii.exports=xu});var Ou={};Gi(Ou,{default:()=>Pu});var Mi=G("@yarnpkg/core");var ii=G("@yarnpkg/cli"),ur=G("@yarnpkg/core"),si=G("@yarnpkg/core"),Ge=G("clipanion");var ae=G("@yarnpkg/core"),le=G("@yarnpkg/core"),De=G("@yarnpkg/fslib"),ni=_e(Fr()),$e=_e(kr());var Rr=G("@yarnpkg/core"),Mr=_e(Ar()),re=_e(kr()),Kn=_e(G("vm")),{is_atom:de,is_variable:zo,is_instantiated_list:Wo}=re.default.type;function Jn(r,l,f){r.prepend(f.map(c=>new re.default.type.State(l.goal.replace(c),l.substitution,l)))}var jn=new WeakMap;function Nr(r){let l=jn.get(r.session);if(l==null)throw new Error("Assertion failed: A project should have been registered for the active session");return l}var Lo=new re.default.type.Module("constraints",{["project_workspaces_by_descriptor/3"]:(r,l,f)=>{let[c,w,_]=f.args;if(!de(c)||!de(w)){r.throw_error(re.default.error.instantiation(f.indicator));return}let v=Rr.structUtils.parseIdent(c.id),g=Rr.structUtils.makeDescriptor(v,w.id),T=Nr(r).tryWorkspaceByDescriptor(g);zo(_)&&T!==null&&Jn(r,l,[new re.default.type.Term("=",[_,new re.default.type.Term(String(T.relativeCwd))])]),de(_)&&T!==null&&T.relativeCwd===_.id&&r.success(l)},["workspace_field/3"]:(r,l,f)=>{let[c,w,_]=f.args;if(!de(c)||!de(w)){r.throw_error(re.default.error.instantiation(f.indicator));return}let g=Nr(r).tryWorkspaceByCwd(c.id);if(g==null)return;let h=(0,Mr.default)(g.manifest.raw,w.id);typeof h>"u"||Jn(r,l,[new re.default.type.Term("=",[_,new re.default.type.Term(typeof h=="object"?JSON.stringify(h):h)])])},["workspace_field_test/3"]:(r,l,f)=>{let[c,w,_]=f.args;r.prepend([new re.default.type.State(l.goal.replace(new re.default.type.Term("workspace_field_test",[c,w,_,new re.default.type.Term("[]",[])])),l.substitution,l)])},["workspace_field_test/4"]:(r,l,f)=>{let[c,w,_,v]=f.args;if(!de(c)||!de(w)||!de(_)||!Wo(v)){r.throw_error(re.default.error.instantiation(f.indicator));return}let h=Nr(r).tryWorkspaceByCwd(c.id);if(h==null)return;let T=(0,Mr.default)(h.manifest.raw,w.id);if(typeof T>"u")return;let x={$$:T};for(let[P,N]of v.toJavaScript().entries())x[`$${P}`]=N;Kn.default.runInNewContext(_.id,x)&&r.success(l)}},["project_workspaces_by_descriptor/3","workspace_field/3","workspace_field_test/3","workspace_field_test/4"]);function ei(r,l){jn.set(r,l),r.consult(`:- use_module(library(${Lo.id})).`)}(0,ni.default)($e.default);var ri=["dependencies","devDependencies","peerDependencies"];function j(r){if(r instanceof $e.default.type.Num)return r.value;if(r instanceof $e.default.type.Term)switch(r.indicator){case"throw/1":return j(r.args[0]);case"error/1":return j(r.args[0]);case"error/2":if(r.args[0]instanceof $e.default.type.Term&&r.args[0].indicator==="syntax_error/1")return Object.assign(j(r.args[0]),...j(r.args[1]));{let l=j(r.args[0]);return l.message+=` (in ${j(r.args[1])})`,l}case"syntax_error/1":return new ae.ReportError(ae.MessageName.PROLOG_SYNTAX_ERROR,`Syntax error: ${j(r.args[0])}`);case"existence_error/2":return new ae.ReportError(ae.MessageName.PROLOG_EXISTENCE_ERROR,`Existence error: ${j(r.args[0])} ${j(r.args[1])} not found`);case"instantiation_error/0":return new ae.ReportError(ae.MessageName.PROLOG_INSTANTIATION_ERROR,"Instantiation error: an argument is variable when an instantiated argument was expected");case"line/1":return{line:j(r.args[0])};case"column/1":return{column:j(r.args[0])};case"found/1":return{found:j(r.args[0])};case"./2":return[j(r.args[0])].concat(j(r.args[1]));case"//2":return`${j(r.args[0])}/${j(r.args[1])}`;default:return r.id}throw`couldn't pretty print because of unsupported node ${r}`}function ti(r){let l;try{l=j(r)}catch(f){throw typeof f=="string"?new ae.ReportError(ae.MessageName.PROLOG_UNKNOWN_ERROR,`Unknown error: ${r} (note: ${f})`):f}return typeof l.line<"u"&&typeof l.column<"u"&&(l.message+=` at line ${l.line}, column ${l.column}`),l}var qr=class{constructor(l,f){let c=1e3*l.workspaces.length;this.session=$e.default.create(c),ei(this.session,l),this.session.consult(":- use_module(library(lists))."),this.session.consult(f)}fetchNextAnswer(){return new Promise(l=>{this.session.answer(f=>{l(f)})})}async*makeQuery(l){let f=this.session.query(l);if(f!==!0)throw ti(f);for(;;){let c=await this.fetchNextAnswer();if(c===null)throw new ae.ReportError(ae.MessageName.PROLOG_LIMIT_EXCEEDED,"Resolution limit exceeded");if(!c)break;if(c.id==="throw")throw ti(c);yield c}}};function Pe(r){return r.id==="null"?null:`${r.toJavaScript()}`}function Ho(r){if(r.id==="null")return null;{let l=r.toJavaScript();if(typeof l!="string")return JSON.stringify(l);try{return JSON.stringify(JSON.parse(l))}catch{return JSON.stringify(l)}}}var ce=class{constructor(l){this.source="";this.project=l;let f=l.configuration.get("constraintsPath");De.xfs.existsSync(f)&&(this.source=De.xfs.readFileSync(f,"utf8"))}static async find(l){return new ce(l)}getProjectDatabase(){let l="";for(let f of ri)l+=`dependency_type(${f}).
|
|
`;for(let f of this.project.workspacesByCwd.values()){let c=f.relativeCwd;l+=`workspace(${ve(c)}).
|
|
`,l+=`workspace_ident(${ve(c)}, ${ve(le.structUtils.stringifyIdent(f.locator))}).
|
|
`,l+=`workspace_version(${ve(c)}, ${ve(f.manifest.version)}).
|
|
`;for(let w of ri)for(let _ of f.manifest[w].values())l+=`workspace_has_dependency(${ve(c)}, ${ve(le.structUtils.stringifyIdent(_))}, ${ve(_.range)}, ${w}).
|
|
`}return l+=`workspace(_) :- false.
|
|
`,l+=`workspace_ident(_, _) :- false.
|
|
`,l+=`workspace_version(_, _) :- false.
|
|
`,l+=`workspace_has_dependency(_, _, _, _) :- false.
|
|
`,l}getDeclarations(){let l="";return l+=`gen_enforced_dependency(_, _, _, _) :- false.
|
|
`,l+=`gen_enforced_field(_, _, _) :- false.
|
|
`,l}get fullSource(){return`${this.getProjectDatabase()}
|
|
${this.source}
|
|
${this.getDeclarations()}`}createSession(){return new qr(this.project,this.fullSource)}async process(){let l=this.createSession();return{enforcedDependencies:await this.genEnforcedDependencies(l),enforcedFields:await this.genEnforcedFields(l)}}async genEnforcedDependencies(l){let f=[];for await(let c of l.makeQuery("workspace(WorkspaceCwd), dependency_type(DependencyType), gen_enforced_dependency(WorkspaceCwd, DependencyIdent, DependencyRange, DependencyType).")){let w=De.ppath.resolve(this.project.cwd,Pe(c.links.WorkspaceCwd)),_=Pe(c.links.DependencyIdent),v=Pe(c.links.DependencyRange),g=Pe(c.links.DependencyType);if(w===null||_===null)throw new Error("Invalid rule");let h=this.project.getWorkspaceByCwd(w),T=le.structUtils.parseIdent(_);f.push({workspace:h,dependencyIdent:T,dependencyRange:v,dependencyType:g})}return le.miscUtils.sortMap(f,[({dependencyRange:c})=>c!==null?"0":"1",({workspace:c})=>le.structUtils.stringifyIdent(c.locator),({dependencyIdent:c})=>le.structUtils.stringifyIdent(c)])}async genEnforcedFields(l){let f=[];for await(let c of l.makeQuery("workspace(WorkspaceCwd), gen_enforced_field(WorkspaceCwd, FieldPath, FieldValue).")){let w=De.ppath.resolve(this.project.cwd,Pe(c.links.WorkspaceCwd)),_=Pe(c.links.FieldPath),v=Ho(c.links.FieldValue);if(w===null||_===null)throw new Error("Invalid rule");let g=this.project.getWorkspaceByCwd(w);f.push({workspace:g,fieldPath:_,fieldValue:v})}return le.miscUtils.sortMap(f,[({workspace:c})=>le.structUtils.stringifyIdent(c.locator),({fieldPath:c})=>c])}async*query(l){let f=this.createSession();for await(let c of f.makeQuery(l)){let w={};for(let[_,v]of Object.entries(c.links))_!=="_"&&(w[_]=Pe(v));yield w}}};function ve(r){return typeof r=="string"?`'${r}'`:"[]"}var Oe=class extends ii.BaseCommand{constructor(){super(...arguments);this.json=Ge.Option.Boolean("--json",!1,{description:"Format the output as an NDJSON stream"});this.query=Ge.Option.String()}async execute(){let f=await ur.Configuration.find(this.context.cwd,this.context.plugins),{project:c}=await ur.Project.find(f,this.context.cwd),w=await ce.find(c),_=this.query;return _.endsWith(".")||(_=`${_}.`),(await si.StreamReport.start({configuration:f,json:this.json,stdout:this.context.stdout},async g=>{for await(let h of w.query(_)){let T=Array.from(Object.entries(h)),x=T.length,b=T.reduce((P,[N])=>Math.max(P,N.length),0);for(let P=0;P<x;P++){let[N,z]=T[P];g.reportInfo(null,`${Go(P,x)}${N.padEnd(b," ")} = ${Yo(z)}`)}g.reportJson(h)}})).exitCode()}};Oe.paths=[["constraints","query"]],Oe.usage=Ge.Command.Usage({category:"Constraints-related commands",description:"query the constraints fact database",details:`
|
|
This command will output all matches to the given prolog query.
|
|
`,examples:[["List all dependencies throughout the workspace","yarn constraints query 'workspace_has_dependency(_, DependencyName, _, _).'"]]});function Yo(r){return typeof r!="string"?`${r}`:r.match(/^[a-zA-Z][a-zA-Z0-9_]+$/)?r:`'${r}'`}function Go(r,l){let f=r===0,c=r===l-1;return f&&c?"":f?"\u250C ":c?"\u2514 ":"\u2502 "}var ai=G("@yarnpkg/cli"),lr=G("@yarnpkg/core"),cr=G("clipanion");var Ie=class extends ai.BaseCommand{constructor(){super(...arguments);this.verbose=cr.Option.Boolean("-v,--verbose",!1,{description:"Also print the fact database automatically compiled from the workspace manifests"})}async execute(){let f=await lr.Configuration.find(this.context.cwd,this.context.plugins),{project:c}=await lr.Project.find(f,this.context.cwd),w=await ce.find(c);this.context.stdout.write(this.verbose?w.fullSource:w.source)}};Ie.paths=[["constraints","source"]],Ie.usage=cr.Command.Usage({category:"Constraints-related commands",description:"print the source code for the constraints",details:"\n This command will print the Prolog source code used by the constraints engine. Adding the `-v,--verbose` flag will print the *full* source code, including the fact database automatically compiled from the workspace manifests.\n ",examples:[["Prints the source code","yarn constraints source"],["Print the source code and the fact database","yarn constraints source -v"]]});var Ei=G("@yarnpkg/cli"),Ee=G("@yarnpkg/core"),se=G("@yarnpkg/core"),$=G("@yarnpkg/core"),fr=G("clipanion"),Ai=_e(Ar()),Ni=_e(mi()),Ri=_e(Ci());var Ce=class extends Ei.BaseCommand{constructor(){super(...arguments);this.fix=fr.Option.Boolean("--fix",!1,{description:"Attempt to automatically fix unambiguous issues, following a multi-pass process"})}async execute(){let f=await Ee.Configuration.find(this.context.cwd,this.context.plugins),{project:c}=await Ee.Project.find(f,this.context.cwd),w=await ce.find(c),_=await se.StreamReport.start({configuration:f,stdout:this.context.stdout},async v=>{let g=new Set,h=[];for(let T=0,x=this.fix?10:1;T<x;++T){h=[];let b=await w.process(),P=new Set;await Vu(P,h,b.enforcedDependencies,{fix:this.fix,configuration:f});for(let{manifest:z}of P){let Q={};z.exportTo(Q),z.raw=Q}let N=new Set;await Su(N,h,b.enforcedFields,{fix:this.fix,configuration:f});for(let{manifest:z}of N)z.load(z.raw);if(g=new Set([...g,...P,...N]),P.size===0&&N.size===0)break}await Promise.all([...g].map(async T=>{await T.persistManifest()}));for(let[T,x]of h)v.reportError(T,x)});return _.hasErrors()?_.exitCode():0}};Ce.paths=[["constraints"]],Ce.usage=fr.Command.Usage({category:"Constraints-related commands",description:"check that the project constraints are met",details:`
|
|
This command will run constraints on your project and emit errors for each one that is found but isn't met. If any error is emitted the process will exit with a non-zero exit code.
|
|
|
|
If the \`--fix\` flag is used, Yarn will attempt to automatically fix the issues the best it can, following a multi-pass process (with a maximum of 10 iterations). Some ambiguous patterns cannot be autofixed, in which case you'll have to manually specify the right resolution.
|
|
|
|
For more information as to how to write constraints, please consult our dedicated page on our website: https://yarnpkg.com/features/constraints.
|
|
`,examples:[["Check that all constraints are satisfied","yarn constraints"],["Autofix all unmet constraints","yarn constraints --fix"]]});async function Vu(r,l,f,{configuration:c,fix:w}){let _=new Map,v=new Map;for(let{workspace:g,dependencyIdent:h,dependencyRange:T,dependencyType:x}of f){let b=v.get(g);typeof b>"u"&&v.set(g,b=new Map);let P=b.get(h.identHash);typeof P>"u"&&b.set(h.identHash,P=new Map);let N=P.get(x);typeof N>"u"&&P.set(x,N=new Set),_.set(h.identHash,h),N.add(T)}for(let[g,h]of v)for(let[T,x]of h){let b=_.get(T);if(typeof b>"u")throw new Error("Assertion failed: The ident should have been registered");for(let[P,N]of x){let z=N.has(null)?[null]:[...N];if(z.length>2)l.push([se.MessageName.CONSTRAINTS_AMBIGUITY,`${$.structUtils.prettyWorkspace(c,g)} must depend on ${$.structUtils.prettyIdent(c,b)} via conflicting ranges ${z.slice(0,-1).map(Q=>$.structUtils.prettyRange(c,String(Q))).join(", ")}, and ${$.structUtils.prettyRange(c,String(z[z.length-1]))} (in ${P})`]);else if(z.length>1)l.push([se.MessageName.CONSTRAINTS_AMBIGUITY,`${$.structUtils.prettyWorkspace(c,g)} must depend on ${$.structUtils.prettyIdent(c,b)} via conflicting ranges ${$.structUtils.prettyRange(c,String(z[0]))} and ${$.structUtils.prettyRange(c,String(z[1]))} (in ${P})`]);else{let Q=g.manifest[P].get(b.identHash),[te]=z;te!==null?Q?Q.range!==te&&(w?(g.manifest[P].set(b.identHash,$.structUtils.makeDescriptor(b,te)),r.add(g)):l.push([se.MessageName.CONSTRAINTS_INCOMPATIBLE_DEPENDENCY,`${$.structUtils.prettyWorkspace(c,g)} must depend on ${$.structUtils.prettyIdent(c,b)} via ${$.structUtils.prettyRange(c,te)}, but uses ${$.structUtils.prettyRange(c,Q.range)} instead (in ${P})`])):w?(g.manifest[P].set(b.identHash,$.structUtils.makeDescriptor(b,te)),r.add(g)):l.push([se.MessageName.CONSTRAINTS_MISSING_DEPENDENCY,`${$.structUtils.prettyWorkspace(c,g)} must depend on ${$.structUtils.prettyIdent(c,b)} (via ${$.structUtils.prettyRange(c,te)}), but doesn't (in ${P})`]):Q&&(w?(g.manifest[P].delete(b.identHash),r.add(g)):l.push([se.MessageName.CONSTRAINTS_EXTRANEOUS_DEPENDENCY,`${$.structUtils.prettyWorkspace(c,g)} has an extraneous dependency on ${$.structUtils.prettyIdent(c,b)} (in ${P})`]))}}}}async function Su(r,l,f,{configuration:c,fix:w}){let _=new Map;for(let{workspace:v,fieldPath:g,fieldValue:h}of f){let T=Ee.miscUtils.getMapWithDefault(_,v);Ee.miscUtils.getSetWithDefault(T,g).add(h)}for(let[v,g]of _)for(let[h,T]of g){let x=[...T];if(x.length>2)l.push([se.MessageName.CONSTRAINTS_AMBIGUITY,`${$.structUtils.prettyWorkspace(c,v)} must have a field ${$.formatUtils.pretty(c,h,"cyan")} set to conflicting values ${x.slice(0,-1).map(b=>$.formatUtils.pretty(c,String(b),"magenta")).join(", ")}, or ${$.formatUtils.pretty(c,String(x[x.length-1]),"magenta")}`]);else if(x.length>1)l.push([se.MessageName.CONSTRAINTS_AMBIGUITY,`${$.structUtils.prettyWorkspace(c,v)} must have a field ${$.formatUtils.pretty(c,h,"cyan")} set to conflicting values ${$.formatUtils.pretty(c,String(x[0]),"magenta")} or ${$.formatUtils.pretty(c,String(x[1]),"magenta")}`]);else{let b=(0,Ai.default)(v.manifest.raw,h),[P]=x;P!==null?b===void 0?w?(await $r(v,h,P),r.add(v)):l.push([se.MessageName.CONSTRAINTS_MISSING_FIELD,`${$.structUtils.prettyWorkspace(c,v)} must have a field ${$.formatUtils.pretty(c,h,"cyan")} set to ${$.formatUtils.pretty(c,String(P),"magenta")}, but doesn't`]):JSON.stringify(b)!==P&&(w?(await $r(v,h,P),r.add(v)):l.push([se.MessageName.CONSTRAINTS_INCOMPATIBLE_FIELD,`${$.structUtils.prettyWorkspace(c,v)} must have a field ${$.formatUtils.pretty(c,h,"cyan")} set to ${$.formatUtils.pretty(c,String(P),"magenta")}, but is set to ${$.formatUtils.pretty(c,JSON.stringify(b),"magenta")} instead`])):b!=null&&(w?(await $r(v,h,null),r.add(v)):l.push([se.MessageName.CONSTRAINTS_EXTRANEOUS_FIELD,`${$.structUtils.prettyWorkspace(c,v)} has an extraneous field ${$.formatUtils.pretty(c,h,"cyan")} set to ${$.formatUtils.pretty(c,JSON.stringify(b),"magenta")}`]))}}}async function $r(r,l,f){f===null?(0,Ri.default)(r.manifest.raw,l):(0,Ni.default)(r.manifest.raw,l,JSON.parse(f))}var ku={configuration:{constraintsPath:{description:"The path of the constraints file.",type:Mi.SettingsType.ABSOLUTE_PATH,default:"./constraints.pro"}},commands:[Oe,Ie,Ce]},Pu=ku;return Ui(Ou);})();
|
|
return plugin;
|
|
}
|
|
};
|