//***********************************************************************************
// TMS WEB CORE framework code is copyright (c) 2018 - 2021 by tmssoftware.com bvba
// The code or parts of the code cannot be used in any way outside 
// a TMS WEB Core application generated by a licensed user or company.
//***********************************************************************************
var pas = { $libimports: {}};

var rtl = {

  version: 30101,

  quiet: false,
  debug_load_units: false,
  debug_rtti: false,

  $res : {},

  debug: function(){
    if (rtl.quiet || !console || !console.log) return;
    console.log(arguments);
  },

  error: function(s){
    rtl.debug('Error: ',s);
    throw s;
  },

  warn: function(s){
    rtl.debug('Warn: ',s);
  },

  checkVersion: function(v){
    if (rtl.version != v) throw "expected rtl version "+v+", but found "+rtl.version;
  },

  hiInt: Math.pow(2,53),

  hasString: function(s){
    return rtl.isString(s) && (s.length>0);
  },

  isArray: function(a) {
    return Array.isArray(a);
  },

  isFunction: function(f){
    return typeof(f)==="function";
  },

  isModule: function(m){
    return rtl.isObject(m) && rtl.hasString(m.$name) && (pas[m.$name]===m);
  },

  isImplementation: function(m){
    return rtl.isObject(m) && rtl.isModule(m.$module) && (m.$module.$impl===m);
  },

  isNumber: function(n){
    return typeof(n)==="number";
  },

  isObject: function(o){
    var s=typeof(o);
    return (typeof(o)==="object") && (o!=null);
  },

  isString: function(s){
    return typeof(s)==="string";
  },

  getNumber: function(n){
    return typeof(n)==="number"?n:NaN;
  },

  getChar: function(c){
    return ((typeof(c)==="string") && (c.length===1)) ? c : "";
  },

  getObject: function(o){
    return ((typeof(o)==="object") || (typeof(o)==='function')) ? o : null;
  },

  isTRecord: function(type){
    return (rtl.isObject(type) && type.hasOwnProperty('$new') && (typeof(type.$new)==='function'));
  },

  isPasClass: function(type){
    return (rtl.isObject(type) && type.hasOwnProperty('$classname') && rtl.isObject(type.$module));
  },

  isPasClassInstance: function(type){
    return (rtl.isObject(type) && rtl.isPasClass(type.$class));
  },

  hexStr: function(n,digits){
    return ("000000000000000"+n.toString(16).toUpperCase()).slice(-digits);
  },

  m_loading: 0,
  m_loading_intf: 1,
  m_intf_loaded: 2,
  m_loading_impl: 3, // loading all used unit
  m_initializing: 4, // running initialization
  m_initialized: 5,

  module: function(module_name, intfuseslist, intfcode, impluseslist){
    var lModule = pas[module_name];
    if (lModule) {
      lModule.$intfcode = intfcode;
    } 
    else {
      rtl.modulenew(module_name, intfuseslist, intfcode, impluseslist);
    }
  },

  modulenew: function(module_name, intfuseslist, intfcode, impluseslist){
    if (rtl.debug_load_units) rtl.debug('rtl.module name="'+module_name+'" intfuses='+intfuseslist+' impluses='+impluseslist);
    if (!rtl.hasString(module_name)) rtl.error('invalid module name "'+module_name+'"');
    if (!rtl.isArray(intfuseslist)) rtl.error('invalid interface useslist of "'+module_name+'"');
    if (!rtl.isFunction(intfcode)) rtl.error('invalid interface code of "'+module_name+'"');
    if (!(impluseslist==undefined) && !rtl.isArray(impluseslist)) rtl.error('invalid implementation useslist of "'+module_name+'"');

    if (pas[module_name])
      rtl.error('module "'+module_name+'" is already registered');

    var r = Object.create(rtl.tSectionRTTI);
    var module = r.$module = pas[module_name] = {
      $name: module_name,
      $intfuseslist: intfuseslist,
      $impluseslist: impluseslist,
      $state: rtl.m_loading,
      $intfcode: intfcode,
      $implcode: null,
      $impl: null,
      $rtti: r
    };
    if (impluseslist) module.$impl = {
          $module: module,
          $rtti: r
        };
  },

  exitcode: 0,

  run: function(module_name){
    try {
      if (!rtl.hasString(module_name)) module_name='program';
      if (rtl.debug_load_units) rtl.debug('rtl.run module="'+module_name+'"');
      rtl.initRTTI();
      var module = pas[module_name];
      if (!module) rtl.error('rtl.run module "'+module_name+'" missing');
      rtl.loadintf(module);
      rtl.loadimpl(module);
      if ((module_name=='program') || (module_name=='library')){
        if (rtl.debug_load_units) rtl.debug('running $main');
        var r = pas[module_name].$main();
        if (rtl.isNumber(r)) rtl.exitcode = r;
      }
    } catch(re) {
      if (!rtl.showUncaughtExceptions) {
        throw re
      } else {  
        if (!rtl.handleUncaughtException(re)) {
          rtl.showException(re);
          rtl.exitcode = 216;
        }  
      }
    } 
    return rtl.exitcode;
  },
  
  showException : function (re) {
    var errStack = (re.hasOwnProperty('stack')) ? re.stack : re;
    var errMsg = rtl.hasString(re.$classname) ? re.$classname : '';
    errMsg += ((errMsg) ? ': ' : '') + (re.hasOwnProperty('fMessage') ? re.fMessage : '');
    errMsg += ((errMsg) ? "\n" : '') + errStack;
    errMsg = "Uncaught Exception:\n" + errMsg;
    console.log(errMsg);
    alert(errMsg);
  },

  handleUncaughtException: function (e) {
    if (rtl.onUncaughtException) {
      try {
        rtl.onUncaughtException(e);
        return true;
      } catch (ee) {
        return false; 
      }
    } else {
      return false;
    }
  },

  loadintf: function(module){
    if (module.$state>rtl.m_loading_intf) return; // already finished
    if (rtl.debug_load_units) rtl.debug('loadintf: "'+module.$name+'"');
    if (module.$state===rtl.m_loading_intf)
      rtl.error('unit cycle detected "'+module.$name+'"');
    module.$state=rtl.m_loading_intf;
    // load interfaces of interface useslist
    rtl.loaduseslist(module,module.$intfuseslist,rtl.loadintf);
    // run interface
    if (rtl.debug_load_units) rtl.debug('loadintf: run intf of "'+module.$name+'"');
    module.$intfcode(module.$intfuseslist);
    // success
    module.$state=rtl.m_intf_loaded;
    // Note: units only used in implementations are not yet loaded (not even their interfaces)
  },

  loaduseslist: function(module,useslist,f){
    if (useslist==undefined) return;
    var len = useslist.length;
    for (var i = 0; i<len; i++) {
      var unitname=useslist[i];
      if (rtl.debug_load_units) rtl.debug('loaduseslist of "'+module.$name+'" uses="'+unitname+'"');
      if (pas[unitname]==undefined)
        rtl.error('module "'+module.$name+'" misses "'+unitname+'"');
      f(pas[unitname]);
    }
  },

  loadimpl: function(module){
    if (module.$state>=rtl.m_loading_impl) return; // already processing
    if (module.$state<rtl.m_intf_loaded) rtl.error('loadimpl: interface not loaded of "'+module.$name+'"');
    if (rtl.debug_load_units) rtl.debug('loadimpl: load uses of "'+module.$name+'"');
    module.$state=rtl.m_loading_impl;
    // load interfaces of implementation useslist
    rtl.loaduseslist(module,module.$impluseslist,rtl.loadintf);
    // load implementation of interfaces useslist
    rtl.loaduseslist(module,module.$intfuseslist,rtl.loadimpl);
    // load implementation of implementation useslist
    rtl.loaduseslist(module,module.$impluseslist,rtl.loadimpl);
    // Note: At this point all interfaces used by this unit are loaded. If
    //   there are implementation uses cycles some used units might not yet be
    //   initialized. This is by design.
    // run implementation
    if (rtl.debug_load_units) rtl.debug('loadimpl: run impl of "'+module.$name+'"');
    if (rtl.isFunction(module.$implcode)) module.$implcode(module.$impluseslist);
    // run initialization
    if (rtl.debug_load_units) rtl.debug('loadimpl: run init of "'+module.$name+'"');
    module.$state=rtl.m_initializing;
    if (rtl.isFunction(module.$init)) module.$init();
    // unit initialized
    module.$state=rtl.m_initialized;
  },

  createCallback: function(scope, fn){
    var cb;
    if (typeof(fn)==='string'){
      if (!scope.hasOwnProperty('$events')) scope.$events = {};
      cb = scope.$events[fn];
      if (cb) return cb;
      scope.$events[fn] = cb = function(){
        return scope[fn].apply(scope,arguments);
      };
    } else {
      cb = function(){
        return fn.apply(scope,arguments);
      };
    };
    cb.scope = scope;
    cb.fn = fn;
    return cb;
  },

  createSafeCallback: function(scope, fn){
    var cb;
    if (typeof(fn)==='string'){
      if (!scope[fn]) return null;
      if (!scope.hasOwnProperty('$events')) scope.$events = {};
      cb = scope.$events[fn];
      if (cb) return cb;
      scope.$events[fn] = cb = function(){
        try{
          return scope[fn].apply(scope,arguments);
        } catch (err) {
          if (!rtl.handleUncaughtException(err)) throw err;
        }
      };
    } else if(!fn) {
      return null;
    } else {
      cb = function(){
        try{
          return fn.apply(scope,arguments);
        } catch (err) {
          if (!rtl.handleUncaughtException(err)) throw err;
        }
      };
    };
    cb.scope = scope;
    cb.fn = fn;
    return cb;
  },

  eqCallback: function(a,b){
    // can be a function or a function wrapper
    if (a===b){
      return true;
    } else {
      return (a!=null) && (b!=null) && (a.fn) && (a.scope===b.scope) && (a.fn===b.fn);
    }
  },

  initStruct: function(c,parent,name){
    if ((parent.$module) && (parent.$module.$impl===parent)) parent=parent.$module;
    c.$parent = parent;
    if (rtl.isModule(parent)){
      c.$module = parent;
      c.$name = name;
    } else {
      c.$module = parent.$module;
      c.$name = parent.$name+'.'+name;
    };
    return parent;
  },

  initClass: function(c,parent,name,initfn,rttiname){
    parent[name] = c;
    c.$class = c; // Note: o.$class === Object.getPrototypeOf(o)
    c.$classname = rttiname?rttiname:name;
    parent = rtl.initStruct(c,parent,name);
    c.$fullname = parent.$name+'.'+name;
    // rtti
    if (rtl.debug_rtti) rtl.debug('initClass '+c.$fullname);
    var t = c.$module.$rtti.$Class(c.$classname,{ "class": c });
    c.$rtti = t;
    if (rtl.isObject(c.$ancestor)) t.ancestor = c.$ancestor.$rtti;
    if (!t.ancestor) t.ancestor = null;
    // init members
    initfn.call(c);
  },

  createClass: function(parent,name,ancestor,initfn,rttiname){
    // create a normal class,
    // ancestor must be null or a normal class,
    // the root ancestor can be an external class
    var lClass = parent[name];
    if (lClass) {
      return lClass; 
    }

    var c = null;
    if (ancestor != null){
      c = Object.create(ancestor);
      c.$ancestor = ancestor;
      // Note:
      // if root is an "object" then c.$ancestor === Object.getPrototypeOf(c)
      // if root is a "function" then c.$ancestor === c.__proto__, Object.getPrototypeOf(c) returns the root
    } else {
      c = { $ancestor: null };
      c.$create = function(fn,args){
        if (args == undefined) args = [];
        var o = Object.create(this);
        o.$init();
        try{
          if (typeof(fn)==="string"){
            o[fn].apply(o,args);
          } else {
            fn.apply(o,args);
          };
          o.AfterConstruction();
        } catch($e){
          // do not call BeforeDestruction
          if (o.Destroy) o.Destroy();
          o.$final();
          throw $e;
        }
        return o;
      };
      c.$destroy = function(fnname){
        this.BeforeDestruction();
        if (this[fnname]) this[fnname]();
        this.$final();
      };
    };
    rtl.initClass(c,parent,name,initfn,rttiname);
  },

  createClassExt: function(parent,name,ancestor,newinstancefnname,initfn,rttiname){
    // Create a class using an external ancestor.
    // If newinstancefnname is given, use that function to create the new object.
    // If exist call BeforeDestruction and AfterConstruction.
    var isFunc = rtl.isFunction(ancestor);
    var c = null;
    if (isFunc){
      // create pascal class descendent from JS function
      c = Object.create(ancestor.prototype);
      c.$ancestorfunc = ancestor;
      c.$ancestor = null; // no pascal ancestor
    } else if (ancestor.$func){
      // create pascal class descendent from a pascal class descendent of a JS function
      isFunc = true;
      c = Object.create(ancestor);
      c.$ancestor = ancestor;
    } else {
      c = Object.create(ancestor);
      c.$ancestor = null; // no pascal ancestor
    }
    c.$create = function(fn,args){
      if (args == undefined) args = [];
      var o = null;
      if (newinstancefnname.length>0){
        o = this[newinstancefnname](fn,args);
      } else if(isFunc) {
        o = new this.$func(args);
      } else {
        o = Object.create(c);
      }
      if (o.$init) o.$init();
      try{
        if (typeof(fn)==="string"){
          this[fn].apply(o,args);
        } else {
          fn.apply(o,args);
        };
        if (o.AfterConstruction) o.AfterConstruction();
      } catch($e){
        // do not call BeforeDestruction
        if (o.Destroy) o.Destroy();
        if (o.$final) o.$final();
        throw $e;
      }
      return o;
    };
    c.$destroy = function(fnname){
      if (this.BeforeDestruction) this.BeforeDestruction();
      if (this[fnname]) this[fnname]();
      if (this.$final) this.$final();
    };
    rtl.initClass(c,parent,name,initfn,rttiname);
    if (isFunc){
      function f(){}
      f.prototype = c;
      c.$func = f;
    }
  },

  createHelper: function(parent,name,ancestor,initfn,rttiname){
    // create a helper,
    // ancestor must be null or a helper,
    var c = null;
    if (ancestor != null){
      c = Object.create(ancestor);
      c.$ancestor = ancestor;
      // c.$ancestor === Object.getPrototypeOf(c)
    } else {
      c = { $ancestor: null };
    };
    parent[name] = c;
    c.$class = c; // Note: o.$class === Object.getPrototypeOf(o)
    c.$classname = rttiname?rttiname:name;
    parent = rtl.initStruct(c,parent,name);
    c.$fullname = parent.$name+'.'+name;
    // rtti
    var t = c.$module.$rtti.$Helper(c.$classname,{ "helper": c });
    c.$rtti = t;
    if (rtl.isObject(ancestor)) t.ancestor = ancestor.$rtti;
    if (!t.ancestor) t.ancestor = null;
    // init members
    initfn.call(c);
  },

  tObjectDestroy: "Destroy",

  free: function(obj,name){
    if (obj[name]==null) return null;
    obj[name].$destroy(rtl.tObjectDestroy);
    obj[name]=null;
  },

  freeLoc: function(obj){
    if (obj==null) return null;
    obj.$destroy(rtl.tObjectDestroy);
    return null;
  },

  hideProp: function(o,p,v){
    Object.defineProperty(o,p, {
      enumerable: false,
      configurable: true,
      writable: true
    });
    if(arguments.length>2){ o[p]=v; }
  },

  recNewT: function(parent,name,initfn,full){
    if (parent) {
      var lRec = parent[name];
      if (lRec) {
        return lRec;
      }
    } 

    // create new record type
    var t = {};
    if (parent) parent[name] = t;
    var h = rtl.hideProp;
    if (full){
      rtl.initStruct(t,parent,name);
      t.$record = t;
      h(t,'$record');
      h(t,'$name');
      h(t,'$parent');
      h(t,'$module');
      h(t,'$initSpec');
    }
    initfn.call(t);
    if (!t.$new){
      t.$new = function(){ return Object.create(t); };
    }
    t.$clone = function(r){ return t.$new().$assign(r); };
    h(t,'$new');
    h(t,'$clone');
    h(t,'$eq');
    h(t,'$assign');
    return t;
  },

  is: function(instance,type){
    return type.isPrototypeOf(instance) || (instance===type);
  },

  isExt: function(instance,type,mode){
    // mode===1 means instance must be a Pascal class instance
    // mode===2 means instance must be a Pascal class
    // Notes:
    // isPrototypeOf and instanceof return false on equal
    // isPrototypeOf does not work for Date.isPrototypeOf(new Date())
    //   so if isPrototypeOf is false test with instanceof
    // instanceof needs a function on right side
    if (instance == null) return false; // Note: ==null checks for undefined too
    if ((typeof(type) !== 'object') && (typeof(type) !== 'function')) return false;
    if (instance === type){
      if (mode===1) return false;
      if (mode===2) return rtl.isPasClass(instance);
      return true;
    }
    if (type.isPrototypeOf && type.isPrototypeOf(instance)){
      if (mode===1) return rtl.isPasClassInstance(instance);
      if (mode===2) return rtl.isPasClass(instance);
      return true;
    }
    if ((typeof type == 'function') && (instance instanceof type)) return true;
    return false;
  },

  Exception: null,
  EInvalidCast: null,
  EAbstractError: null,
  ERangeError: null,
  EIntOverflow: null,
  EPropWriteOnly: null,

  raiseE: function(typename){
    var t = rtl[typename];
    if (t==null){
      var mod = pas.SysUtils;
      if (!mod) mod = pas.sysutils;
      if (!mod) mod = pas["System.SysUtils"];
      if (mod){
        t = mod[typename];
        if (!t) t = mod[typename.toLowerCase()];
        if (!t) t = mod['Exception'];
        if (!t) t = mod['exception'];
      }
    }
    if (t){
      if (t.Create){
        throw t.$create("Create");
      } else if (t.create){
        throw t.$create("create");
      }
    }
    if (typename === "EInvalidCast") throw "invalid type cast";
    if (typename === "EAbstractError") throw "Abstract method called";
    if (typename === "ERangeError") throw "range error";
    throw typename;
  },

  as: function(instance,type){
    if((instance === null) || rtl.is(instance,type)) return instance;
    rtl.raiseE("EInvalidCast");
  },

  asExt: function(instance,type,mode){
    if((instance === null) || rtl.isExt(instance,type,mode)) return instance;
    rtl.raiseE("EInvalidCast");
  },

  createInterface: function(module, name, guid, fnnames, ancestor, initfn, rttiname){
    //console.log('createInterface name="'+name+'" guid="'+guid+'" names='+fnnames);
    var lInterface = module[name];
    if (lInterface) {
      return lInterface; 
    }

    var i = ancestor?Object.create(ancestor):{};
    module[name] = i;
    i.$module = module;
    i.$name = rttiname?rttiname:name;
    i.$fullname = module.$name+'.'+i.$name;
    i.$guid = guid;
    i.$guidr = null;
    i.$names = fnnames?fnnames:[];
    if (rtl.isFunction(initfn)){
      // rtti
      if (rtl.debug_rtti) rtl.debug('createInterface '+i.$fullname);
      var t = i.$module.$rtti.$Interface(i.$name,{ "interface": i, module: module });
      i.$rtti = t;
      if (ancestor) t.ancestor = ancestor.$rtti;
      if (!t.ancestor) t.ancestor = null;
      initfn.call(i);
    }
    return i;
  },

  strToGUIDR: function(s,g){
    var p = 0;
    function n(l){
      var h = s.substr(p,l);
      p+=l;
      return parseInt(h,16);
    }
    p+=1; // skip {
    g.D1 = n(8);
    p+=1; // skip -
    g.D2 = n(4);
    p+=1; // skip -
    g.D3 = n(4);
    p+=1; // skip -
    if (!g.D4) g.D4=[];
    g.D4[0] = n(2);
    g.D4[1] = n(2);
    p+=1; // skip -
    for(var i=2; i<8; i++) g.D4[i] = n(2);
    return g;
  },

  guidrToStr: function(g){
    if (g.$intf) return g.$intf.$guid;
    var h = rtl.hexStr;
    var s='{'+h(g.D1,8)+'-'+h(g.D2,4)+'-'+h(g.D3,4)+'-'+h(g.D4[0],2)+h(g.D4[1],2)+'-';
    for (var i=2; i<8; i++) s+=h(g.D4[i],2);
    s+='}';
    return s;
  },

  createTGUID: function(guid){
    var TGuid = (pas.System)?pas.System.TGuid:pas.system.tguid;
    var g = rtl.strToGUIDR(guid,TGuid.$new());
    return g;
  },

  getIntfGUIDR: function(intfTypeOrVar){
    if (!intfTypeOrVar) return null;
    if (!intfTypeOrVar.$guidr){
      var g = rtl.createTGUID(intfTypeOrVar.$guid);
      if (!intfTypeOrVar.hasOwnProperty('$guid')) intfTypeOrVar = Object.getPrototypeOf(intfTypeOrVar);
      g.$intf = intfTypeOrVar;
      intfTypeOrVar.$guidr = g;
    }
    return intfTypeOrVar.$guidr;
  },

  addIntf: function (aclass, intf, map){
    function jmp(fn){
      if (typeof(fn)==="function"){
        return function(){ return fn.apply(this.$o,arguments); };
      } else {
        return function(){ rtl.raiseE('EAbstractError'); };
      }
    }
    if(!map) map = {};
    var t = intf;
    var item = Object.create(t);
    if (!aclass.hasOwnProperty('$intfmaps')) aclass.$intfmaps = {};
    aclass.$intfmaps[intf.$guid] = item;
    do{
      var names = t.$names;
      if (!names) break;
      for (var i=0; i<names.length; i++){
        var intfname = names[i];
        var fnname = map[intfname];
        if (!fnname) fnname = intfname;
        //console.log('addIntf: intftype='+t.$name+' index='+i+' intfname="'+intfname+'" fnname="'+fnname+'" old='+typeof(item[intfname]));
        item[intfname] = jmp(aclass[fnname]);
      }
      t = Object.getPrototypeOf(t);
    }while(t!=null);
  },

  getIntfG: function (obj, guid, query){
    if (!obj) return null;
    //console.log('getIntfG: obj='+obj.$classname+' guid='+guid+' query='+query);
    // search
    var maps = obj.$intfmaps;
    if (!maps) return null;
    var item = maps[guid];
    if (!item) return null;
    // check delegation
    //console.log('getIntfG: obj='+obj.$classname+' guid='+guid+' query='+query+' item='+typeof(item));
    if (typeof item === 'function') return item.call(obj); // delegate. Note: COM contains _AddRef
    // check cache
    var intf = null;
    if (obj.$interfaces){
      intf = obj.$interfaces[guid];
      //console.log('getIntfG: obj='+obj.$classname+' guid='+guid+' cache='+typeof(intf));
    }
    if (!intf){ // intf can be undefined!
      intf = Object.create(item);
      intf.$o = obj;
      if (!obj.$interfaces) obj.$interfaces = {};
      obj.$interfaces[guid] = intf;
    }
    if (typeof(query)==='object'){
      // called by queryIntfT
      var o = null;
      if (intf.QueryInterface(rtl.getIntfGUIDR(query),
          {get:function(){ return o; }, set:function(v){ o=v; }}) === 0){
        return o;
      } else {
        return null;
      }
    } else if(query===2){
      // called by TObject.GetInterfaceByStr
      if (intf.$kind === 'com') intf._AddRef();
    }
    return intf;
  },

  getIntfT: function(obj,intftype){
    return rtl.getIntfG(obj,intftype.$guid);
  },

  queryIntfT: function(obj,intftype){
    return rtl.getIntfG(obj,intftype.$guid,intftype);
  },

  queryIntfIsT: function(obj,intftype){
    var i = rtl.getIntfG(obj,intftype.$guid);
    if (!i) return false;
    if (i.$kind === 'com') i._Release();
    return true;
  },

  asIntfT: function (obj,intftype){
    var i = rtl.getIntfG(obj,intftype.$guid);
    if (i!==null) return i;
    rtl.raiseEInvalidCast();
  },

  intfIsIntfT: function(intf,intftype){
    return (intf!==null) && rtl.queryIntfIsT(intf.$o,intftype);
  },

  intfAsIntfT: function (intf,intftype){
    if (!intf) return null;
    var i = rtl.getIntfG(intf.$o,intftype.$guid);
    if (i) return i;
    rtl.raiseEInvalidCast();
  },

  intfIsClass: function(intf,classtype){
    return (intf!=null) && (rtl.is(intf.$o,classtype));
  },

  intfAsClass: function(intf,classtype){
    if (intf==null) return null;
    return rtl.as(intf.$o,classtype);
  },

  intfToClass: function(intf,classtype){
    if ((intf!==null) && rtl.is(intf.$o,classtype)) return intf.$o;
    return null;
  },

  // interface reference counting
  intfRefs: { // base object for temporary interface variables
    ref: function(id,intf){
      // called for temporary interface references needing delayed release
      var old = this[id];
      //console.log('rtl.intfRefs.ref: id='+id+' old="'+(old?old.$name:'null')+'" intf="'+(intf?intf.$name:'null')+' $o='+(intf?intf.$o:'null'));
      if (old){
        // called again, e.g. in a loop
        delete this[id];
        old._Release(); // may fail
      }
      if(intf) {
        this[id]=intf;
      }
      return intf;
    },
    free: function(){
      //console.log('rtl.intfRefs.free...');
      for (var id in this){
        if (this.hasOwnProperty(id)){
          var intf = this[id];
          if (intf){
            //console.log('rtl.intfRefs.free: id='+id+' '+intf.$name+' $o='+intf.$o.$classname);
            intf._Release();
          }
        }
      }
    }
  },

  createIntfRefs: function(){
    //console.log('rtl.createIntfRefs');
    return Object.create(rtl.intfRefs);
  },

  setIntfP: function(path,name,value,skipAddRef){
    var old = path[name];
    //console.log('rtl.setIntfP path='+path+' name='+name+' old="'+(old?old.$name:'null')+'" value="'+(value?value.$name:'null')+'"');
    if (old === value) return;
    if (old !== null){
      path[name]=null;
      old._Release();
    }
    if (value !== null){
      if (!skipAddRef) value._AddRef();
      path[name]=value;
    }
  },

  setIntfL: function(old,value,skipAddRef){
    //console.log('rtl.setIntfL old="'+(old?old.$name:'null')+'" value="'+(value?value.$name:'null')+'"');
    if (old !== value){
      if (value!==null){
        if (!skipAddRef) value._AddRef();
      }
      if (old!==null){
        old._Release();  // Release after AddRef, to avoid double Release if Release creates an exception
      }
    } else if (skipAddRef){
      if (old!==null){
        old._Release();  // value has an AddRef
      }
    }
    return value;
  },

  _AddRef: function(intf){
    //if (intf) console.log('rtl._AddRef intf="'+(intf?intf.$name:'null')+'"');
    if (intf) intf._AddRef();
    return intf;
  },

  _Release: function(intf){
    //if (intf) console.log('rtl._Release intf="'+(intf?intf.$name:'null')+'"');
    if (intf) intf._Release();
    return intf;
  },

  _ReleaseArray: function(a,dim){
    if (!a) return null;
    for (var i=0; i<a.length; i++){
      if (dim<=1){
        if (a[i]) a[i]._Release();
      } else {
        rtl._ReleaseArray(a[i],dim-1);
      }
    }
    return null;
  },

  trunc: function(a){
    return a<0 ? Math.ceil(a) : Math.floor(a);
  },

  checkMethodCall: function(obj,type){
    if (rtl.isObject(obj) && rtl.is(obj,type)) return;
    rtl.raiseE("EInvalidCast");
  },

  oc: function(i){
    // overflow check integer
    if ((Math.floor(i)===i) && (i>=-0x1fffffffffffff) && (i<=0x1fffffffffffff)) return i;
    rtl.raiseE('EIntOverflow');
  },

  rc: function(i,minval,maxval){
    // range check integer
    if ((Math.floor(i)===i) && (i>=minval) && (i<=maxval)) return i;
    rtl.raiseE('ERangeError');
  },

  rcc: function(c,minval,maxval){
    // range check char
    if ((typeof(c)==='string') && (c.length===1)){
      var i = c.charCodeAt(0);
      if ((i>=minval) && (i<=maxval)) return c;
    }
    rtl.raiseE('ERangeError');
  },

  rcSetCharAt: function(s,index,c){
    // range check setCharAt
    if ((typeof(s)!=='string') || (index<0) || (index>=s.length)) rtl.raiseE('ERangeError');
    return rtl.setCharAt(s,index,c);
  },

  rcCharAt: function(s,index){
    // range check charAt
    if ((typeof(s)!=='string') || (index<0) || (index>=s.length)) rtl.raiseE('ERangeError');
    return s.charAt(index);
  },

  rcArrR: function(arr,index){
    // range check read array
    if (Array.isArray(arr) && (typeof(index)==='number') && (index>=0) && (index<arr.length)){
      if (arguments.length>2){
        // arr,index1,index2,...
        arr=arr[index];
        for (var i=2; i<arguments.length; i++) arr=rtl.rcArrR(arr,arguments[i]);
        return arr;
      }
      return arr[index];
    }
    rtl.raiseE('ERangeError');
  },

  rcArrW: function(arr,index,value){
    // range check write array
    // arr,index1,index2,...,value
    for (var i=3; i<arguments.length; i++){
      arr=rtl.rcArrR(arr,index);
      index=arguments[i-1];
      value=arguments[i];
    }
    if (Array.isArray(arr) && (typeof(index)==='number') && (index>=0) && (index<arr.length)){
      return arr[index]=value;
    }
    rtl.raiseE('ERangeError');
  },

  length: function(arr){
    return (arr == null) ? 0 : arr.length;
  },

  arrayRef: function(a){
    if (a!=null) rtl.hideProp(a,'$pas2jsrefcnt',1);
    return a;
  },

  arraySetLength: function(arr,defaultvalue,newlength){
    var stack = [];
    var s = 9999;
    for (var i=2; i<arguments.length; i++){
      var j = arguments[i];
      if (j==='s'){ s = i-2; }
      else {
        stack.push({ dim:j+0, a:null, i:0, src:null });
      }
    }
    var dimmax = stack.length-1;
    var depth = 0;
    var lastlen = 0;
    var item = null;
    var a = null;
    var src = arr;
    var srclen = 0, oldlen = 0;
    do{
      if (depth>0){
        item=stack[depth-1];
        src = (item.src && item.src.length>item.i)?item.src[item.i]:null;
      }
      if (!src){
        a = [];
        srclen = 0;
        oldlen = 0;
      } else if (src.$pas2jsrefcnt>0 || depth>=s){
        a = [];
        srclen = src.length;
        oldlen = srclen;
      } else {
        a = src;
        srclen = 0;
        oldlen = a.length;
      }
      lastlen = stack[depth].dim;
      a.length = lastlen;
      if (depth>0){
        item.a[item.i]=a;
        item.i++;
        if ((lastlen===0) && (item.i<item.a.length)) continue;
      }
      if (lastlen>0){
        if (depth<dimmax){
          item = stack[depth];
          item.a = a;
          item.i = 0;
          item.src = src;
          depth++;
          continue;
        } else {
          if (srclen>lastlen) srclen=lastlen;
          if (rtl.isArray(defaultvalue)){
            // array of dyn array
            for (var i=0; i<srclen; i++) a[i]=src[i];
            for (var i=oldlen; i<lastlen; i++) a[i]=[];
          } else if (rtl.isObject(defaultvalue)) {
            if (rtl.isTRecord(defaultvalue)){
              // array of record
              for (var i=0; i<srclen; i++) a[i]=defaultvalue.$clone(src[i]);
              for (var i=oldlen; i<lastlen; i++) a[i]=defaultvalue.$new();
            } else {
              // array of set
              for (var i=0; i<srclen; i++) a[i]=rtl.refSet(src[i]);
              for (var i=oldlen; i<lastlen; i++) a[i]={};
            }
          } else {
            for (var i=0; i<srclen; i++) a[i]=src[i];
            for (var i=oldlen; i<lastlen; i++) a[i]=defaultvalue;
          }
        }
      }
      // backtrack
      while ((depth>0) && (stack[depth-1].i>=stack[depth-1].dim)){
        depth--;
      };
      if (depth===0){
        if (dimmax===0) return a;
        return stack[0].a;
      }
    }while (true);
  },

  arrayEq: function(a,b){
    if (a===null) return b===null;
    if (b===null) return false;
    if (a.length!==b.length) return false;
    for (var i=0; i<a.length; i++) if (a[i]!==b[i]) return false;
    return true;
  },

  arrayClone: function(type,src,srcpos,endpos,dst,dstpos){
    // type: 0 for references, "refset" for calling refSet(), a function for new type()
    // src must not be null
    // This function does not range check.
    if(type === 'refSet') {
      for (; srcpos<endpos; srcpos++) dst[dstpos++] = rtl.refSet(src[srcpos]); // ref set
    } else if (type === 'slice'){
      for (; srcpos<endpos; srcpos++) dst[dstpos++] = src[srcpos].slice(0); // clone static array of simple types
    } else if (typeof(type)==='function'){
      for (; srcpos<endpos; srcpos++) dst[dstpos++] = type(src[srcpos]); // clone function
    } else if (rtl.isTRecord(type)){
      for (; srcpos<endpos; srcpos++) dst[dstpos++] = type.$clone(src[srcpos]); // clone record
    }  else {
      for (; srcpos<endpos; srcpos++) dst[dstpos++] = src[srcpos]; // reference
    };
  },

  arrayConcat: function(type){
    // type: see rtl.arrayClone
    var a = [];
    var l = 0;
    for (var i=1; i<arguments.length; i++){
      var src = arguments[i];
      if (src !== null) l+=src.length;
    };
    a.length = l;
    l=0;
    for (var i=1; i<arguments.length; i++){
      var src = arguments[i];
      if (src === null) continue;
      rtl.arrayClone(type,src,0,src.length,a,l);
      l+=src.length;
    };
    return a;
  },

  arrayConcatN: function(){
    var a = null;
    for (var i=0; i<arguments.length; i++){
      var src = arguments[i];
      if (src === null) continue;
      if (a===null){
        a=rtl.arrayRef(src); // Note: concat(a) does not clone
      } else if (a['$pas2jsrefcnt']){
        a=a.concat(src); // clone a and append src
      } else {
        for (var i=0; i<src.length; i++){
          a.push(src[i]);
        }
      }
    };
    return a;
  },

  arrayPush: function(type,a){
    if(a===null){
      a=[];
    } else if (a['$pas2jsrefcnt']){
      a=rtl.arrayCopy(type,a,0,a.length);
    }
    rtl.arrayClone(type,arguments,2,arguments.length,a,a.length);
    return a;
  },

  arrayPushN: function(a){
    if(a===null){
      a=[];
    } else if (a['$pas2jsrefcnt']){
      a=a.concat();
    }
    for (var i=1; i<arguments.length; i++){
      a.push(arguments[i]);
    }
    return a;
  },

  arrayCopy: function(type, srcarray, index, count){
    // type: see rtl.arrayClone
    // if count is missing, use srcarray.length
    if (srcarray === null) return [];
    if (index < 0) index = 0;
    if (count === undefined) count=srcarray.length;
    var end = index+count;
    if (end>srcarray.length) end = srcarray.length;
    if (index>=end) return [];
    if (type===0){
      return srcarray.slice(index,end);
    } else {
      var a = [];
      a.length = end-index;
      rtl.arrayClone(type,srcarray,index,end,a,0);
      return a;
    }
  },

  arrayInsert: function(item, arr, index){
    if (arr){
      arr.splice(index,0,item);
      return arr;
    } else {
      return [item];
    }
  },

  setCharAt: function(s,index,c){
    return s.substr(0,index)+c+s.substr(index+1);
  },

  getResStr: function(mod,name){
    var rs = mod.$resourcestrings[name];
    return rs.current?rs.current:rs.org;
  },

  createSet: function(){
    var s = {};
    for (var i=0; i<arguments.length; i++){
      if (arguments[i]!=null){
        s[arguments[i]]=true;
      } else {
        var first=arguments[i+=1];
        var last=arguments[i+=1];
        for(var j=first; j<=last; j++) s[j]=true;
      }
    }
    return s;
  },

  cloneSet: function(s){
    var r = {};
    for (var key in s) r[key]=true;
    return r;
  },

  refSet: function(s){
    rtl.hideProp(s,'$shared',true);
    return s;
  },

  includeSet: function(s,enumvalue){
    if (s.$shared) s = rtl.cloneSet(s);
    s[enumvalue] = true;
    return s;
  },

  excludeSet: function(s,enumvalue){
    if (s.$shared) s = rtl.cloneSet(s);
    delete s[enumvalue];
    return s;
  },

  diffSet: function(s,t){
    var r = {};
    for (var key in s) if (!t[key]) r[key]=true;
    return r;
  },

  unionSet: function(s,t){
    var r = {};
    for (var key in s) r[key]=true;
    for (var key in t) r[key]=true;
    return r;
  },

  intersectSet: function(s,t){
    var r = {};
    for (var key in s) if (t[key]) r[key]=true;
    return r;
  },

  symDiffSet: function(s,t){
    var r = {};
    for (var key in s) if (!t[key]) r[key]=true;
    for (var key in t) if (!s[key]) r[key]=true;
    return r;
  },

  eqSet: function(s,t){
    for (var key in s) if (!t[key]) return false;
    for (var key in t) if (!s[key]) return false;
    return true;
  },

  neSet: function(s,t){
    return !rtl.eqSet(s,t);
  },

  leSet: function(s,t){
    for (var key in s) if (!t[key]) return false;
    return true;
  },

  geSet: function(s,t){
    for (var key in t) if (!s[key]) return false;
    return true;
  },

  strSetLength: function(s,newlen){
    var oldlen = s.length;
    if (oldlen > newlen){
      return s.substring(0,newlen);
    } else if (s.repeat){
      // Note: repeat needs ECMAScript6!
      return s+' '.repeat(newlen-oldlen);
    } else {
       while (oldlen<newlen){
         s+=' ';
         oldlen++;
       };
       return s;
    }
  },

  spaceLeft: function(s,width){
    var l=s.length;
    if (l>=width) return s;
    if (s.repeat){
      // Note: repeat needs ECMAScript6!
      return ' '.repeat(width-l) + s;
    } else {
      while (l<width){
        s=' '+s;
        l++;
      };
      return s;
    };
  },

  floatToStr: function(d,w,p){
    // input 1-3 arguments: double, width, precision
    if (arguments.length>2){
      return rtl.spaceLeft(d.toFixed(p),w);
    } else {
	  // exponent width
	  var pad = "";
	  var ad = Math.abs(d);
	  if (((ad>1) && (ad<1.0e+10)) ||  ((ad>1.e-10) && (ad<1))) {
		pad='00';
	  } else if ((ad>1) && (ad<1.0e+100) || (ad<1.e-10)) {
		pad='0';
      }  	
	  if (arguments.length<2) {
	    w=24;		
      } else if (w<9) {
		w=9;
      }		  
      var p = w-8;
      var s=(d>0 ? " " : "" ) + d.toExponential(p);
      s=s.replace(/e(.)/,'E$1'+pad);
      return rtl.spaceLeft(s,w);
    }
  },

  valEnum: function(s, enumType, setCodeFn){
    s = s.toLowerCase();
    for (var key in enumType){
      if((typeof(key)==='string') && (key.toLowerCase()===s)){
        setCodeFn(0);
        return enumType[key];
      }
    }
    setCodeFn(1);
    return 0;
  },

  lw: function(l){
    // fix longword bitwise operation
    return l<0?l+0x100000000:l;
  },

  and: function(a,b){
    var hi = 0x80000000;
    var low = 0x7fffffff;
    var h = (a / hi) & (b / hi);
    var l = (a & low) & (b & low);
    return h*hi + l;
  },

  or: function(a,b){
    var hi = 0x80000000;
    var low = 0x7fffffff;
    var h = (a / hi) | (b / hi);
    var l = (a & low) | (b & low);
    return h*hi + l;
  },

  xor: function(a,b){
    var hi = 0x80000000;
    var low = 0x7fffffff;
    var h = (a / hi) ^ (b / hi);
    var l = (a & low) ^ (b & low);
    return h*hi + l;
  },

  shr: function(a,b){
    if (a<0) a += rtl.hiInt;
    if (a<0x80000000) return a >> b;
    if (b<=0) return a;
    if (b>54) return 0;
    return Math.floor(a / Math.pow(2,b));
  },

  shl: function(a,b){
    if (a<0) a += rtl.hiInt;
    if (b<=0) return a;
    if (b>54) return 0;
    var r = a * Math.pow(2,b);
    if (r <= rtl.hiInt) return r;
    return r % rtl.hiInt;
  },

  initRTTI: function(){
    if (rtl.debug_rtti) rtl.debug('initRTTI');

    // base types
    rtl.tTypeInfo = { name: "tTypeInfo", kind: 0, $module: null, attr: null };
    function newBaseTI(name,kind,ancestor){
      if (!ancestor) ancestor = rtl.tTypeInfo;
      if (rtl.debug_rtti) rtl.debug('initRTTI.newBaseTI "'+name+'" '+kind+' ("'+ancestor.name+'")');
      var t = Object.create(ancestor);
      t.name = name;
      t.kind = kind;
      rtl[name] = t;
      return t;
    };
    function newBaseInt(name,minvalue,maxvalue,ordtype){
      var t = newBaseTI(name,1 /* tkInteger */,rtl.tTypeInfoInteger);
      t.minvalue = minvalue;
      t.maxvalue = maxvalue;
      t.ordtype = ordtype;
      return t;
    };
    newBaseTI("tTypeInfoInteger",1 /* tkInteger */);
    newBaseInt("shortint",-0x80,0x7f,0);
    newBaseInt("byte",0,0xff,1);
    newBaseInt("smallint",-0x8000,0x7fff,2);
    newBaseInt("word",0,0xffff,3);
    newBaseInt("longint",-0x80000000,0x7fffffff,4);
    newBaseInt("longword",0,0xffffffff,5);
    newBaseInt("nativeint",-0x10000000000000,0xfffffffffffff,6);
    newBaseInt("nativeuint",0,0xfffffffffffff,7);
    newBaseTI("char",2 /* tkChar */);
    newBaseTI("string",3 /* tkString */);
    newBaseTI("tTypeInfoEnum",4 /* tkEnumeration */,rtl.tTypeInfoInteger);
    newBaseTI("tTypeInfoSet",5 /* tkSet */);
    newBaseTI("double",6 /* tkDouble */);
    newBaseTI("boolean",7 /* tkBool */);
    newBaseTI("tTypeInfoProcVar",8 /* tkProcVar */);
    newBaseTI("tTypeInfoMethodVar",9 /* tkMethod */,rtl.tTypeInfoProcVar);
    newBaseTI("tTypeInfoArray",10 /* tkArray */);
    newBaseTI("tTypeInfoDynArray",11 /* tkDynArray */);
    newBaseTI("tTypeInfoPointer",15 /* tkPointer */);
    var t = newBaseTI("pointer",15 /* tkPointer */,rtl.tTypeInfoPointer);
    t.reftype = null;
    newBaseTI("jsvalue",16 /* tkJSValue */);
    newBaseTI("tTypeInfoRefToProcVar",17 /* tkRefToProcVar */,rtl.tTypeInfoProcVar);

    // member kinds
    rtl.tTypeMember = { attr: null };
    function newMember(name,kind){
      var m = Object.create(rtl.tTypeMember);
      m.name = name;
      m.kind = kind;
      rtl[name] = m;
    };
    newMember("tTypeMemberField",1); // tmkField
    newMember("tTypeMemberMethod",2); // tmkMethod
    newMember("tTypeMemberProperty",3); // tmkProperty

    // base object for storing members: a simple object
    rtl.tTypeMembers = {};

    // tTypeInfoStruct - base object for tTypeInfoClass, tTypeInfoRecord, tTypeInfoInterface
    var tis = newBaseTI("tTypeInfoStruct",0);
    tis.$addMember = function(name,ancestor,options){
      if (rtl.debug_rtti){
        if (!rtl.hasString(name) || (name.charAt()==='$')) throw 'invalid member "'+name+'", this="'+this.name+'"';
        if (!rtl.is(ancestor,rtl.tTypeMember)) throw 'invalid ancestor "'+ancestor+':'+ancestor.name+'", "'+this.name+'.'+name+'"';
        if ((options!=undefined) && (typeof(options)!='object')) throw 'invalid options "'+options+'", "'+this.name+'.'+name+'"';
      };
      var t = Object.create(ancestor);
      t.name = name;
      this.members[name] = t;
      this.names.push(name);
      if (rtl.isObject(options)){
        for (var key in options) if (options.hasOwnProperty(key)) t[key] = options[key];
      };
      return t;
    };
    tis.addField = function(name,type,options){
      var t = this.$addMember(name,rtl.tTypeMemberField,options);
      if (rtl.debug_rtti){
        if (!rtl.is(type,rtl.tTypeInfo)) throw 'invalid type "'+type+'", "'+this.name+'.'+name+'"';
      };
      t.typeinfo = type;
      this.fields.push(name);
      return t;
    };
    tis.addFields = function(){
      var i=0;
      while(i<arguments.length){
        var name = arguments[i++];
        var type = arguments[i++];
        if ((i<arguments.length) && (typeof(arguments[i])==='object')){
          this.addField(name,type,arguments[i++]);
        } else {
          this.addField(name,type);
        };
      };
    };
    tis.addMethod = function(name,methodkind,params,result,flags,options){
      var t = this.$addMember(name,rtl.tTypeMemberMethod,options);
      t.methodkind = methodkind;
      t.procsig = rtl.newTIProcSig(params,result,flags);
      this.methods.push(name);
      return t;
    };
    tis.addProperty = function(name,flags,result,getter,setter,options){
      var t = this.$addMember(name,rtl.tTypeMemberProperty,options);
      t.flags = flags;
      t.typeinfo = result;
      t.getter = getter;
      t.setter = setter;
      // Note: in options: params, stored, defaultvalue
      t.params = rtl.isArray(t.params) ? rtl.newTIParams(t.params) : null;
      this.properties.push(name);
      if (!rtl.isString(t.stored)) t.stored = "";
      return t;
    };
    tis.getField = function(index){
      return this.members[this.fields[index]];
    };
    tis.getMethod = function(index){
      return this.members[this.methods[index]];
    };
    tis.getProperty = function(index){
      return this.members[this.properties[index]];
    };

    newBaseTI("tTypeInfoRecord",12 /* tkRecord */,rtl.tTypeInfoStruct);
    newBaseTI("tTypeInfoClass",13 /* tkClass */,rtl.tTypeInfoStruct);
    newBaseTI("tTypeInfoClassRef",14 /* tkClassRef */);
    newBaseTI("tTypeInfoInterface",18 /* tkInterface */,rtl.tTypeInfoStruct);
    newBaseTI("tTypeInfoHelper",19 /* tkHelper */,rtl.tTypeInfoStruct);
    newBaseTI("tTypeInfoExtClass",20 /* tkExtClass */,rtl.tTypeInfoClass);
  },

  tSectionRTTI: {
    $module: null,
    $inherited: function(name,ancestor,o){
      if (rtl.debug_rtti){
        rtl.debug('tSectionRTTI.newTI "'+(this.$module?this.$module.$name:"(no module)")
          +'"."'+name+'" ('+ancestor.name+') '+(o?'init':'forward'));
      };
      var t = this[name];
      if (t){
        if (!t.$forward) {
          return t;
        }
        if (!ancestor.isPrototypeOf(t)) throw 'typeinfo ancestor mismatch "'+name+'" ancestor="'+ancestor.name+'" t.name="'+t.name+'"';
      } else {
        t = Object.create(ancestor);
        t.name = name;
        t.$module = this.$module;
        this[name] = t;
      }
      if (o){
        delete t.$forward;
        for (var key in o) if (o.hasOwnProperty(key)) t[key]=o[key];
      } else {
        t.$forward = true;
      }
      return t;
    },
    $Scope: function(name,ancestor,o){
      var t=this.$inherited(name,ancestor,o);
      if (!t.members) {
        t.members = {};
      }
      if (!t.names) {
        t.names = [];
      }
      if (!t.fields) {
        t.fields = [];
      }  
      if (!t.methods) {
        t.methods = [];
      }  
      if (!t.properties) {
        t.properties = [];
      }  
      return t;
    },
    $TI: function(name,kind,o){ var t=this.$inherited(name,rtl.tTypeInfo,o); t.kind = kind; return t; },
    $Int: function(name,o){ return this.$inherited(name,rtl.tTypeInfoInteger,o); },
    $Enum: function(name,o){ return this.$inherited(name,rtl.tTypeInfoEnum,o); },
    $Set: function(name,o){ return this.$inherited(name,rtl.tTypeInfoSet,o); },
    $StaticArray: function(name,o){ return this.$inherited(name,rtl.tTypeInfoArray,o); },
    $DynArray: function(name,o){ return this.$inherited(name,rtl.tTypeInfoDynArray,o); },
    $ProcVar: function(name,o){ return this.$inherited(name,rtl.tTypeInfoProcVar,o); },
    $RefToProcVar: function(name,o){ return this.$inherited(name,rtl.tTypeInfoRefToProcVar,o); },
    $MethodVar: function(name,o){ return this.$inherited(name,rtl.tTypeInfoMethodVar,o); },
    $Record: function(name,o){ return this.$Scope(name,rtl.tTypeInfoRecord,o); },
    $Class: function(name,o){ return this.$Scope(name,rtl.tTypeInfoClass,o); },
    $ClassRef: function(name,o){ return this.$inherited(name,rtl.tTypeInfoClassRef,o); },
    $Pointer: function(name,o){ return this.$inherited(name,rtl.tTypeInfoPointer,o); },
    $Interface: function(name,o){ return this.$Scope(name,rtl.tTypeInfoInterface,o); },
    $Helper: function(name,o){ return this.$Scope(name,rtl.tTypeInfoHelper,o); },
    $ExtClass: function(name,o){ return this.$Scope(name,rtl.tTypeInfoExtClass,o); }
  },

  newTIParam: function(param){
    // param is an array, 0=name, 1=type, 2=optional flags
    var t = {
      name: param[0],
      typeinfo: param[1],
      flags: (rtl.isNumber(param[2]) ? param[2] : 0)
    };
    return t;
  },

  newTIParams: function(list){
    // list: optional array of [paramname,typeinfo,optional flags]
    var params = [];
    if (rtl.isArray(list)){
      for (var i=0; i<list.length; i++) params.push(rtl.newTIParam(list[i]));
    };
    return params;
  },

  newTIProcSig: function(params,result,flags){
    var s = {
      params: rtl.newTIParams(params),
      resulttype: result?result:null,
      flags: flags?flags:0
    };
    return s;
  },

  addResource: function(aRes){
    rtl.$res[aRes.name]=aRes;
  },

  getResource: function(aName){
    var res = rtl.$res[aName];
    if (res !== undefined) {
      return res;
    } else {
      return null;
    }
  },

  getResourceList: function(){
    return Object.keys(rtl.$res);
  }
}

rtl.module("System",[],function () {
  "use strict";
  var $mod = this;
  var $impl = $mod.$impl;
  this.LineEnding = "\n";
  this.sLineBreak = this.LineEnding;
  this.PathDelim = "/";
  this.$rtti.$Set("AllowDirectorySeparators$a",{comptype: rtl.char});
  this.AllowDirectorySeparators = rtl.createSet(47,92);
  this.$rtti.$Set("AllowDriveSeparators$a",{comptype: rtl.char});
  this.AllowDriveSeparators = rtl.createSet(58);
  this.ExtensionSeparator = ".";
  this.MaxSmallint = 32767;
  this.MinSmallint = -32768;
  this.MaxShortInt = 127;
  this.MinShortInt = -128;
  this.MaxByte = 0xFF;
  this.MaxWord = 0xFFFF;
  this.MaxLongint = 0x7fffffff;
  this.MaxCardinal = 0xffffffff;
  this.Maxint = 2147483647;
  this.IsMultiThread = false;
  this.$rtti.$inherited("Real",rtl.double,{});
  this.$rtti.$inherited("Extended",rtl.double,{});
  this.$rtti.$inherited("TDateTime",rtl.double,{});
  this.$rtti.$inherited("TTime",this.$rtti["TDateTime"],{});
  this.$rtti.$inherited("TDate",this.$rtti["TDateTime"],{});
  this.$rtti.$inherited("UInt64",rtl.nativeuint,{});
  this.$rtti.$inherited("QWord",rtl.nativeuint,{});
  this.$rtti.$inherited("Comp",rtl.nativeint,{});
  this.$rtti.$inherited("WideString",rtl.string,{});
  this.TTextLineBreakStyle = {"0": "tlbsLF", tlbsLF: 0, "1": "tlbsCRLF", tlbsCRLF: 1, "2": "tlbsCR", tlbsCR: 2};
  this.$rtti.$Enum("TTextLineBreakStyle",{minvalue: 0, maxvalue: 2, ordtype: 1, enumtype: this.TTextLineBreakStyle});
  this.TCompareOption = {"0": "coIgnoreCase", coIgnoreCase: 0, "1": "coDigitAsNumbers", coDigitAsNumbers: 1};
  this.$rtti.$Enum("TCompareOption",{minvalue: 0, maxvalue: 1, ordtype: 1, enumtype: this.TCompareOption});
  this.$rtti.$Set("TCompareOptions",{comptype: this.$rtti["TCompareOption"]});
  rtl.recNewT(this,"TGuid",function () {
    this.D1 = 0;
    this.D2 = 0;
    this.D3 = 0;
    this.$new = function () {
      var r = Object.create(this);
      r.D4 = rtl.arraySetLength(null,0,8);
      return r;
    };
    this.$eq = function (b) {
      return (this.D1 === b.D1) && (this.D2 === b.D2) && (this.D3 === b.D3) && rtl.arrayEq(this.D4,b.D4);
    };
    this.$assign = function (s) {
      this.D1 = s.D1;
      this.D2 = s.D2;
      this.D3 = s.D3;
      this.D4 = s.D4.slice(0);
      return this;
    };
    var $r = $mod.$rtti.$Record("TGuid",{});
    $r.addField("D1",rtl.longword);
    $r.addField("D2",rtl.word);
    $r.addField("D3",rtl.word);
    $mod.$rtti.$StaticArray("TGuid.D4$a",{dims: [8], eltype: rtl.byte});
    $r.addField("D4",$mod.$rtti["TGuid.D4$a"]);
  });
  this.$rtti.$inherited("TGUIDString",rtl.string,{});
  this.$rtti.$Pointer("PMethod",{reftype: this.$rtti["TMethod"]});
  rtl.recNewT(this,"TMethod",function () {
    this.Code = null;
    this.Data = null;
    this.$eq = function (b) {
      return (this.Code === b.Code) && (this.Data === b.Data);
    };
    this.$assign = function (s) {
      this.Code = s.Code;
      this.Data = s.Data;
      return this;
    };
    var $r = $mod.$rtti.$Record("TMethod",{});
    $r.addField("Code",rtl.pointer);
    $r.addField("Data",rtl.pointer);
  });
  this.$rtti.$Class("TObject");
  this.$rtti.$ClassRef("TClass",{instancetype: this.$rtti["TObject"]});
  rtl.createClass(this,"TObject",null,function () {
    this.$init = function () {
    };
    this.$final = function () {
    };
    this.Create = function () {
      return this;
    };
    this.Destroy = function () {
    };
    this.Free = function () {
      this.$destroy("Destroy");
    };
    this.ClassType = function () {
      return this;
    };
    this.ClassNameIs = function (Name) {
      var Result = false;
      Result = $impl.SameText(Name,this.$classname);
      return Result;
    };
    this.InheritsFrom = function (aClass) {
      return (aClass!=null) && ((this==aClass) || aClass.isPrototypeOf(this));
    };
    this.MethodName = function (aCode) {
      var Result = "";
      Result = "";
      if (aCode === null) return Result;
      if (typeof(aCode)!=='function') return "";
      var i = 0;
      var TI = this.$rtti;
      if (rtl.isObject(aCode.scope)){
        // callback
        if (typeof aCode.fn === "string") return aCode.fn;
        aCode = aCode.fn;
      }
      // Not a callback, check rtti
      while ((Result === "") && (TI != null)) {
        i = 0;
        while ((Result === "") && (i < TI.methods.length)) {
          if (this[TI.getMethod(i).name] === aCode)
            Result=TI.getMethod(i).name;
          i += 1;
        };
        if (Result === "") TI = TI.ancestor;
      };
      // return Result;
      return Result;
    };
    this.MethodAddress = function (aName) {
      var Result = null;
      Result = null;
      if (aName === "") return Result;
      var i = 0;
        var TI = this.$rtti;
        var N = "";
        var MN = "";
        N = aName.toLowerCase();
        while ((MN === "") && (TI != null)) {
          i = 0;
          while ((MN === "") && (i < TI.methods.length)) {
            if (TI.getMethod(i).name.toLowerCase() === N) MN = TI.getMethod(i).name;
            i += 1;
          };
          if (MN === "") TI = TI.ancestor;
        };
        if (MN !== "") Result = this[MN];
      //  return Result;
      return Result;
    };
    this.FieldAddress = function (aName) {
      var Result = null;
      Result = null;
      if (aName === "") return Result;
      var aClass = this.$class;
      var ClassTI = null;
      var myName = aName.toLowerCase();
      var MemberTI = null;
      while (aClass !== null) {
        ClassTI = aClass.$rtti;
        for (var i = 0, $end2 = ClassTI.fields.length - 1; i <= $end2; i++) {
          MemberTI = ClassTI.getField(i);
          if (MemberTI.name.toLowerCase() === myName) {
             return MemberTI;
          };
        };
        aClass = aClass.$ancestor ? aClass.$ancestor : null;
      };
      return Result;
    };
    this.ClassInfo = function () {
      var Result = null;
      Result = this.$rtti;
      return Result;
    };
    this.QualifiedClassName = function () {
      var Result = "";
      Result = this.$module.$name + "." + this.$classname;
      return Result;
    };
    this.AfterConstruction = function () {
    };
    this.BeforeDestruction = function () {
    };
    this.Dispatch = function (aMessage) {
      var aClass = null;
      var Id = undefined;
      if (!rtl.isObject(aMessage)) return;
      Id = aMessage["Msg"];
      if (!rtl.isNumber(Id)) return;
      aClass = this.$class.ClassType();
      while (aClass !== null) {
        var Handlers = aClass.$msgint;
        if (rtl.isObject(Handlers) && Handlers.hasOwnProperty(Id)){
          this[Handlers[Id]](aMessage);
          return;
        };
        aClass = aClass.$ancestor;
      };
      this.DefaultHandler(aMessage);
    };
    this.DispatchStr = function (aMessage) {
      var aClass = null;
      var Id = undefined;
      if (!rtl.isObject(aMessage)) return;
      Id = aMessage["MsgStr"];
      if (!rtl.isString(Id)) return;
      aClass = this.$class.ClassType();
      while (aClass !== null) {
        var Handlers = aClass.$msgstr;
        if (rtl.isObject(Handlers) && Handlers.hasOwnProperty(Id)){
          this[Handlers[Id]](aMessage);
          return;
        };
        aClass = aClass.$ancestor;
      };
      this.DefaultHandlerStr(aMessage);
    };
    this.DefaultHandler = function (aMessage) {
      if (aMessage) ;
    };
    this.DefaultHandlerStr = function (aMessage) {
      if (aMessage) ;
    };
    this.GetInterface = function (iid, obj) {
      var Result = false;
      var i = iid.$intf;
      if (i){
        // iid is the private TGuid of an interface
        i = rtl.getIntfG(this,i.$guid,2);
        if (i){
          obj.set(i);
          return true;
        }
      };
      Result = this.GetInterfaceByStr(rtl.guidrToStr(iid),obj);
      return Result;
    };
    this.GetInterface$1 = function (iidstr, obj) {
      var Result = false;
      Result = this.GetInterfaceByStr(iidstr,obj);
      return Result;
    };
    this.GetInterfaceByStr = function (iidstr, obj) {
      var Result = false;
      Result = false;
      if (!$mod.IObjectInstance["$str"]) $mod.IObjectInstance["$str"] = rtl.guidrToStr($mod.IObjectInstance);
      if (iidstr == $mod.IObjectInstance["$str"]) {
        obj.set(this);
        return true;
      };
      var i = rtl.getIntfG(this,iidstr,2);
      obj.set(i);
      Result=(i!==null);
      return Result;
    };
    this.GetInterfaceWeak = function (iid, obj) {
      var Result = false;
      Result = this.GetInterface(iid,obj);
      if (Result){
        var o = obj.get();
        if (o.$kind==='com'){
          o._Release();
        }
      };
      return Result;
    };
    this.Equals = function (Obj) {
      var Result = false;
      Result = Obj === this;
      return Result;
    };
    this.ToString = function () {
      var Result = "";
      Result = this.$classname;
      return Result;
    };
  });
  rtl.createClass(this,"TCustomAttribute",this.TObject,function () {
  });
  this.$rtti.$DynArray("TCustomAttributeArray",{eltype: this.$rtti["TCustomAttribute"]});
  this.$rtti.$ClassRef("TCustomAttributeClass",{instancetype: this.$rtti["TCustomAttribute"]});
  this.S_OK = 0;
  this.S_FALSE = 1;
  this.E_NOINTERFACE = -2147467262;
  this.E_UNEXPECTED = -2147418113;
  this.E_NOTIMPL = -2147467263;
  rtl.createInterface(this,"IUnknown","{00000000-0000-0000-C000-000000000046}",["QueryInterface","_AddRef","_Release"],null,function () {
    this.$kind = "com";
    var $r = this.$rtti;
    $r.addMethod("QueryInterface",1,[["iid",$mod.$rtti["TGuid"],2],["obj",null,4]],rtl.longint);
    $r.addMethod("_AddRef",1,[],rtl.longint);
    $r.addMethod("_Release",1,[],rtl.longint);
  });
  rtl.createInterface(this,"IInvokable","{88387EF6-BCEE-3E17-9E85-5D491ED4FC10}",[],this.IUnknown,function () {
  });
  rtl.createInterface(this,"IEnumerator","{ECEC7568-4E50-30C9-A2F0-439342DE2ADB}",["GetCurrent","MoveNext","Reset"],this.IUnknown,function () {
    var $r = this.$rtti;
    $r.addMethod("GetCurrent",1,[],$mod.$rtti["TObject"]);
    $r.addMethod("MoveNext",1,[],rtl.boolean);
    $r.addMethod("Reset",0,[]);
    $r.addProperty("Current",1,$mod.$rtti["TObject"],"GetCurrent","");
  });
  rtl.createInterface(this,"IEnumerable","{9791C368-4E51-3424-A3CE-D4911D54F385}",["GetEnumerator"],this.IUnknown,function () {
    var $r = this.$rtti;
    $r.addMethod("GetEnumerator",1,[],$mod.$rtti["IEnumerator"]);
  });
  rtl.createClass(this,"TInterfacedObject",this.TObject,function () {
    this.$init = function () {
      $mod.TObject.$init.call(this);
      this.fRefCount = 0;
    };
    this.QueryInterface = function (iid, obj) {
      var Result = 0;
      if (this.GetInterface(iid,obj)) {
        Result = 0}
       else Result = -2147467262;
      return Result;
    };
    this._AddRef = function () {
      var Result = 0;
      this.fRefCount += 1;
      Result = this.fRefCount;
      return Result;
    };
    this._Release = function () {
      var Result = 0;
      this.fRefCount -= 1;
      Result = this.fRefCount;
      if (this.fRefCount === 0) this.$destroy("Destroy");
      return Result;
    };
    this.BeforeDestruction = function () {
      if (this.fRefCount !== 0) rtl.raiseE('EHeapMemoryError');
    };
    rtl.addIntf(this,$mod.IUnknown);
  });
  this.$rtti.$ClassRef("TInterfacedClass",{instancetype: this.$rtti["TInterfacedObject"]});
  rtl.createClass(this,"TAggregatedObject",this.TObject,function () {
    this.$init = function () {
      $mod.TObject.$init.call(this);
      this.fController = null;
    };
    this.GetController = function () {
      var Result = null;
      var $ok = false;
      try {
        Result = rtl.setIntfL(Result,this.fController);
        $ok = true;
      } finally {
        if (!$ok) rtl._Release(Result);
      };
      return Result;
    };
    this.QueryInterface = function (iid, obj) {
      var Result = 0;
      Result = this.fController.QueryInterface(iid,obj);
      return Result;
    };
    this._AddRef = function () {
      var Result = 0;
      Result = this.fController._AddRef();
      return Result;
    };
    this._Release = function () {
      var Result = 0;
      Result = this.fController._Release();
      return Result;
    };
    this.Create$1 = function (aController) {
      $mod.TObject.Create.call(this);
      this.fController = aController;
      return this;
    };
  });
  rtl.createClass(this,"TContainedObject",this.TAggregatedObject,function () {
    this.QueryInterface = function (iid, obj) {
      var Result = 0;
      if (this.GetInterface(iid,obj)) {
        Result = 0}
       else Result = -2147467262;
      return Result;
    };
    rtl.addIntf(this,$mod.IUnknown);
  });
  this.IObjectInstance = this.TGuid.$clone({D1: 0xD91C9AF4, D2: 0x3C93, D3: 0x420F, D4: [0xA3,0x03,0xBF,0x5B,0xA8,0x2B,0xFD,0x23]});
  this.TTypeKind = {"0": "tkUnknown", tkUnknown: 0, "1": "tkInteger", tkInteger: 1, "2": "tkChar", tkChar: 2, "3": "tkString", tkString: 3, "4": "tkEnumeration", tkEnumeration: 4, "5": "tkSet", tkSet: 5, "6": "tkDouble", tkDouble: 6, "7": "tkBool", tkBool: 7, "8": "tkProcVar", tkProcVar: 8, "9": "tkMethod", tkMethod: 9, "10": "tkArray", tkArray: 10, "11": "tkDynArray", tkDynArray: 11, "12": "tkRecord", tkRecord: 12, "13": "tkClass", tkClass: 13, "14": "tkClassRef", tkClassRef: 14, "15": "tkPointer", tkPointer: 15, "16": "tkJSValue", tkJSValue: 16, "17": "tkRefToProcVar", tkRefToProcVar: 17, "18": "tkInterface", tkInterface: 18, "19": "tkHelper", tkHelper: 19, "20": "tkExtClass", tkExtClass: 20};
  this.$rtti.$Enum("TTypeKind",{minvalue: 0, maxvalue: 20, ordtype: 1, enumtype: this.TTypeKind});
  this.$rtti.$Set("TTypeKinds",{comptype: this.$rtti["TTypeKind"]});
  this.tkFloat = this.TTypeKind.tkDouble;
  this.tkProcedure = this.TTypeKind.tkProcVar;
  this.tkAny = rtl.createSet(null,this.TTypeKind.tkUnknown,this.TTypeKind.tkExtClass);
  this.tkMethods = rtl.createSet(this.TTypeKind.tkMethod);
  this.tkProperties = rtl.diffSet(rtl.diffSet(this.tkAny,this.tkMethods),rtl.createSet(this.TTypeKind.tkUnknown));
  this.vtInteger = 0;
  this.vtBoolean = 1;
  this.vtExtended = 3;
  this.vtPointer = 5;
  this.vtObject = 7;
  this.vtClass = 8;
  this.vtWideChar = 9;
  this.vtCurrency = 12;
  this.vtInterface = 14;
  this.vtUnicodeString = 18;
  this.vtNativeInt = 19;
  this.vtJSValue = 20;
  this.$rtti.$Pointer("PVarRec",{reftype: this.$rtti["TVarRec"]});
  rtl.recNewT(this,"TVarRec",function () {
    this.VType = 0;
    this.VJSValue = undefined;
    this.$eq = function (b) {
      return (this.VType === b.VType) && (this.VJSValue === b.VJSValue) && (this.VJSValue === b.VJSValue) && (this.VJSValue === b.VJSValue) && (this.VJSValue === b.VJSValue) && (this.VJSValue === b.VJSValue) && (this.VJSValue === b.VJSValue) && (this.VJSValue === b.VJSValue) && (this.VJSValue === b.VJSValue) && (this.VJSValue === b.VJSValue) && (this.VJSValue === b.VJSValue) && (this.VJSValue === b.VJSValue) && (this.VJSValue === b.VJSValue);
    };
    this.$assign = function (s) {
      this.VType = s.VType;
      this.VJSValue = s.VJSValue;
      this.VJSValue = s.VJSValue;
      this.VJSValue = s.VJSValue;
      this.VJSValue = s.VJSValue;
      this.VJSValue = s.VJSValue;
      this.VJSValue = s.VJSValue;
      this.VJSValue = s.VJSValue;
      this.VJSValue = s.VJSValue;
      this.VJSValue = s.VJSValue;
      this.VJSValue = s.VJSValue;
      this.VJSValue = s.VJSValue;
      this.VJSValue = s.VJSValue;
      return this;
    };
    var $r = $mod.$rtti.$Record("TVarRec",{});
    $r.addField("VType",rtl.byte);
    $r.addField("VJSValue",rtl.jsvalue);
    $r.addField("VJSValue",rtl.longint);
    $r.addField("VJSValue",rtl.boolean);
    $r.addField("VJSValue",rtl.double);
    $r.addField("VJSValue",rtl.pointer);
    $r.addField("VJSValue",$mod.$rtti["TObject"]);
    $r.addField("VJSValue",$mod.$rtti["TClass"]);
    $r.addField("VJSValue",rtl.char);
    $r.addField("VJSValue",rtl.nativeint);
    $r.addField("VJSValue",rtl.pointer);
    $r.addField("VJSValue",rtl.string);
    $r.addField("VJSValue",rtl.nativeint);
  });
  this.$rtti.$DynArray("TVarRecArray",{eltype: this.$rtti["TVarRec"]});
  this.VarRecs = function () {
    var Result = [];
    var i = 0;
    var v = null;
    Result = [];
    while (i < arguments.length) {
      v = $mod.TVarRec.$new();
      v.VType = rtl.trunc(arguments[i]);
      i += 1;
      v.VJSValue = arguments[i];
      i += 1;
      Result.push($mod.TVarRec.$clone(v));
    };
    return Result;
  };
  this.IsConsole = false;
  this.FirstDotAtFileNameStartIsExtension = false;
  this.$rtti.$ProcVar("TOnParamCount",{procsig: rtl.newTIProcSig([],rtl.longint)});
  this.$rtti.$ProcVar("TOnParamStr",{procsig: rtl.newTIProcSig([["Index",rtl.longint]],rtl.string)});
  this.OnParamCount = null;
  this.OnParamStr = null;
  this.ParamCount = function () {
    var Result = 0;
    if ($mod.OnParamCount != null) {
      Result = $mod.OnParamCount()}
     else Result = 0;
    return Result;
  };
  this.ParamStr = function (Index) {
    var Result = "";
    if ($mod.OnParamStr != null) {
      Result = $mod.OnParamStr(Index)}
     else if (Index === 0) {
      Result = "js"}
     else Result = "";
    return Result;
  };
  this.Frac = function (A) {
    return A % 1;
  };
  this.Odd = function (A) {
    return A&1 != 0;
  };
  this.Random = function (Range) {
    return Math.floor(Math.random()*Range);
  };
  this.Sqr = function (A) {
    return A*A;
  };
  this.Sqr$1 = function (A) {
    return A*A;
  };
  this.Trunc = function (A) {
    if (!Math.trunc) {
      Math.trunc = function(v) {
        v = +v;
        if (!isFinite(v)) return v;
        return (v - v % 1) || (v < 0 ? -0 : v === 0 ? v : 0);
      };
    }
    $mod.Trunc = Math.trunc;
    return Math.trunc(A);
  };
  this.DefaultTextLineBreakStyle = this.TTextLineBreakStyle.tlbsLF;
  this.Int = function (A) {
    var Result = 0.0;
    Result = $mod.Trunc(A);
    return Result;
  };
  this.Copy = function (S, Index, Size) {
    if (Index<1) Index = 1;
    return (Size>0) ? S.substring(Index-1,Index+Size-1) : "";
  };
  this.Copy$1 = function (S, Index) {
    if (Index<1) Index = 1;
    return S.substr(Index-1);
  };
  this.Delete = function (S, Index, Size) {
    var h = "";
    if ((Index < 1) || (Index > S.get().length) || (Size <= 0)) return;
    h = S.get();
    S.set($mod.Copy(h,1,Index - 1) + $mod.Copy$1(h,Index + Size));
  };
  this.Pos = function (Search, InString) {
    return InString.indexOf(Search)+1;
  };
  this.Pos$1 = function (Search, InString, StartAt) {
    return InString.indexOf(Search,StartAt-1)+1;
  };
  this.Insert = function (Insertion, Target, Index) {
    var t = "";
    if (Insertion === "") return;
    t = Target.get();
    if (Index < 1) {
      Target.set(Insertion + t)}
     else if (Index > t.length) {
      Target.set(t + Insertion)}
     else Target.set($mod.Copy(t,1,Index - 1) + Insertion + $mod.Copy(t,Index,t.length));
  };
  this.upcase = function (c) {
    return c.toUpperCase();
  };
  this.binstr = function (val, cnt) {
    var Result = "";
    var i = 0;
    Result = rtl.strSetLength(Result,cnt);
    for (var $l = cnt; $l >= 1; $l--) {
      i = $l;
      Result = rtl.setCharAt(Result,i - 1,String.fromCharCode(48 + (val & 1)));
      val = Math.floor(val / 2);
    };
    return Result;
  };
  this.val = function (S, NI, Code) {
    NI.set($impl.valint(S,-9007199254740991,9007199254740991,Code));
  };
  this.val$1 = function (S, NI, Code) {
    var x = 0.0;
    if (S === "") {
      Code.set(1);
      return;
    };
    x = Number(S);
    if (isNaN(x) || (x !== $mod.Int(x)) || (x < 0)) {
      Code.set(1)}
     else {
      Code.set(0);
      NI.set($mod.Trunc(x));
    };
  };
  this.val$2 = function (S, SI, Code) {
    SI.set($impl.valint(S,-128,127,Code));
  };
  this.val$3 = function (S, B, Code) {
    B.set($impl.valint(S,0,255,Code));
  };
  this.val$4 = function (S, SI, Code) {
    SI.set($impl.valint(S,-32768,32767,Code));
  };
  this.val$5 = function (S, W, Code) {
    W.set($impl.valint(S,0,65535,Code));
  };
  this.val$6 = function (S, I, Code) {
    I.set($impl.valint(S,-2147483648,2147483647,Code));
  };
  this.val$7 = function (S, C, Code) {
    C.set($impl.valint(S,0,4294967295,Code));
  };
  this.val$8 = function (S, d, Code) {
    var x = 0.0;
    if (S === "") {
      Code.set(1);
      return;
    };
    x = Number(S);
    if (isNaN(x)) {
      Code.set(1)}
     else {
      Code.set(0);
      d.set(x);
    };
  };
  this.val$9 = function (S, b, Code) {
    if ($impl.SameText(S,"true")) {
      Code.set(0);
      b.set(true);
    } else if ($impl.SameText(S,"false")) {
      Code.set(0);
      b.set(false);
    } else Code.set(1);
  };
  this.StringOfChar = function (c, l) {
    var Result = "";
    var i = 0;
    if ((l>0) && c.repeat) return c.repeat(l);
    Result = "";
    for (var $l = 1, $end = l; $l <= $end; $l++) {
      i = $l;
      Result = Result + c;
    };
    return Result;
  };
  this.Write = function () {
    var i = 0;
    for (var $l = 0, $end = arguments.length - 1; $l <= $end; $l++) {
      i = $l;
      if ($impl.WriteCallBack != null) {
        $impl.WriteCallBack(arguments[i],false)}
       else $impl.WriteBuf = $impl.WriteBuf + ("" + arguments[i]);
    };
  };
  this.Writeln = function () {
    var i = 0;
    var l = 0;
    var s = "";
    l = arguments.length - 1;
    if ($impl.WriteCallBack != null) {
      for (var $l = 0, $end = l; $l <= $end; $l++) {
        i = $l;
        $impl.WriteCallBack(arguments[i],i === l);
      };
    } else {
      s = $impl.WriteBuf;
      for (var $l1 = 0, $end1 = l; $l1 <= $end1; $l1++) {
        i = $l1;
        s = s + ("" + arguments[i]);
      };
      console.log(s);
      $impl.WriteBuf = "";
    };
  };
  this.$rtti.$ProcVar("TConsoleHandler",{procsig: rtl.newTIProcSig([["S",rtl.jsvalue],["NewLine",rtl.boolean]])});
  this.SetWriteCallBack = function (H) {
    var Result = null;
    Result = $impl.WriteCallBack;
    $impl.WriteCallBack = H;
    return Result;
  };
  this.Assigned = function (V) {
    return (V!=undefined) && (V!=null) && (!rtl.isArray(V) || (V.length > 0));
  };
  this.StrictEqual = function (A, B) {
    return A === B;
  };
  this.StrictInequal = function (A, B) {
    return A !== B;
  };
  this.$rtti.$DynArray("TArray<RTTI.TValue>",{});
  this.$rtti.$DynArray("TArray<RTTI.TRttiType>",{});
  this.$rtti.$DynArray("TArray<RTTI.TRttiField>",{});
  this.$rtti.$DynArray("TArray<RTTI.TRttiParameter>",{});
  this.$rtti.$DynArray("TArray<RTTI.TRttiMethod>",{});
  this.$rtti.$DynArray("TArray<RTTI.TRttiProperty>",{});
  this.$rtti.$DynArray("TArray<Classes.TPersistentClass>",{});
  $mod.$implcode = function () {
    $mod.$rtti.$ExtClass("TJSObj",{jsclass: "Object"});
    $mod.$rtti.$ExtClass("TJSArray",{jsclass: "Array"});
    $mod.$rtti.$ExtClass("TJSArguments",{jsclass: "arguments"});
    $impl.SameText = function (s1, s2) {
      return s1.toLowerCase() == s2.toLowerCase();
    };
    $impl.WriteBuf = "";
    $impl.WriteCallBack = null;
    $impl.valint = function (S, MinVal, MaxVal, Code) {
      var Result = 0;
      var x = 0.0;
      if (S === "") {
        Code.set(1);
        return Result;
      };
      x = Number(S);
      if (isNaN(x)) {
        var $tmp = $mod.Copy(S,1,1);
        if ($tmp === "$") {
          x = Number("0x" + $mod.Copy$1(S,2))}
         else if ($tmp === "&") {
          x = Number("0o" + $mod.Copy$1(S,2))}
         else if ($tmp === "%") {
          x = Number("0b" + $mod.Copy$1(S,2))}
         else {
          Code.set(1);
          return Result;
        };
      };
      if (isNaN(x) || (x !== $mod.Int(x))) {
        Code.set(1)}
       else if ((x < MinVal) || (x > MaxVal)) {
        Code.set(2)}
       else {
        Result = $mod.Trunc(x);
        Code.set(0);
      };
      return Result;
    };
  };
  $mod.$init = function () {
    rtl.exitcode = 0;
  };
},[]);
rtl.module("RTLConsts",["System"],function () {
  "use strict";
  var $mod = this;
  $mod.$resourcestrings = {SArgumentMissing: {org: 'Missing argument in format "%s"'}, SInvalidFormat: {org: 'Invalid format specifier : "%s"'}, SInvalidArgIndex: {org: 'Invalid argument index in format: "%s"'}, SListCapacityError: {org: "List capacity (%s) exceeded."}, SListCountError: {org: "List count (%s) out of bounds."}, SMapKeyError: {org: "Key not found : %s"}, SListIndexError: {org: "List index (%s) out of bounds"}, SSortedListError: {org: "Operation not allowed on sorted list"}, SDuplicateString: {org: "String list does not allow duplicates"}, SDuplicateItem: {org: "ThreadList does not allow duplicates"}, SErrFindNeedsSortedList: {org: "Cannot use find on unsorted list"}, SInvalidName: {org: 'Invalid component name: "%s"'}, SInvalidBoolean: {org: '"%s" is not a valid boolean.'}, SDuplicateName: {org: 'Duplicate component name: "%s"'}, SErrInvalidDate: {org: 'Invalid date: "%s"'}, SErrInvalidTimeFormat: {org: 'Invalid time format: "%s"'}, SInvalidDateFormat: {org: 'Invalid date format: "%s"'}, SCantReadPropertyS: {org: 'Cannot read property "%s"'}, SCantWritePropertyS: {org: 'Cannot write property "%s"'}, SErrPropertyNotFound: {org: 'Unknown property: "%s"'}, SIndexedPropertyNeedsParams: {org: 'Indexed property "%s" needs parameters'}, SErrInvalidTypecast: {org: "Invalid class typecast"}, SErrInvalidInteger: {org: 'Invalid integer value: "%s"'}, SErrInvalidFloat: {org: 'Invalid floating-point value: "%s"'}, SInvalidDateTime: {org: "Invalid date-time value: %s"}, SInvalidCurrency: {org: "Invalid currency value: %s"}, SErrInvalidDayOfWeek: {org: "%d is not a valid day of the week"}, SErrInvalidTimeStamp: {org: 'Invalid date/timestamp : "%s"'}, SErrInvalidDateWeek: {org: "%d %d %d is not a valid dateweek"}, SErrInvalidDayOfYear: {org: "Year %d does not have a day number %d"}, SErrInvalidDateMonthWeek: {org: "Year %d, month %d, Week %d and day %d is not a valid date."}, SErrInvalidDayOfWeekInMonth: {org: "Year %d Month %d NDow %d DOW %d is not a valid date"}, SInvalidJulianDate: {org: "%f Julian cannot be represented as a DateTime"}, SErrInvalidHourMinuteSecMsec: {org: "%d:%d:%d.%d is not a valid time specification"}, SInvalidGUID: {org: '"%s" is not a valid GUID value'}, SEmptyStreamIllegalReader: {org: "Illegal Nil stream for TReader constructor"}, SInvalidPropertyValue: {org: "Invalid value for property"}, SInvalidImage: {org: "Invalid stream format"}, SUnknownProperty: {org: 'Unknown property: "%s"'}, SUnknownPropertyType: {org: "Unknown property type %s"}, SAncestorNotFound: {org: 'Ancestor class for "%s" not found.'}, SUnsupportedPropertyVariantType: {org: "Unsupported property variant type %d"}, SPropertyException: {org: "Error reading %s%s%s: %s"}, SInvalidPropertyPath: {org: "Invalid property path"}, SReadOnlyProperty: {org: "Property is read-only"}, SClassNotFound: {org: 'Class "%s" not found'}, SEmptyStreamIllegalWriter: {org: "Illegal Nil stream for TWriter constructor"}, SErrInvalidPropertyType: {org: "Invalid property type from streamed property: %d"}, SParserExpected: {org: "Wrong token type: %s expected"}, SParserInvalidFloat: {org: "Invalid floating point number: %s"}, SParserInvalidInteger: {org: "Invalid integer number: %s"}, SParserUnterminatedString: {org: "Unterminated string"}, SParserWrongTokenType: {org: "Wrong token type: %s expected but %s found"}, SParserWrongTokenSymbol: {org: "Wrong token symbol: %s expected but %s found"}, SParserLocInfo: {org: " (at %d,%d, stream offset %.8x)"}, SParserUnterminatedBinValue: {org: "Unterminated byte value"}, SParserInvalidProperty: {org: "Invalid property"}, SRangeError: {org: "Range error"}, SParamIsNegative: {org: 'Parameter "%s" cannot be negative.'}, SErrNoStreaming: {org: 'Failed to initialize component class "%s": No streaming method available.'}, SResNotFound: {org: "Resource %s not found"}, SErrResourceStreamNoWrite: {org: "Cannot write to resource stream"}, SErrResourceNotBase64: {org: "Resource %s is not base64 encoded"}, SErrUnknownResourceEncoding: {org: 'Unknown encoding for resource: "%s"'}};
});
rtl.module("Types",["System"],function () {
  "use strict";
  var $mod = this;
  this.TDirection = {"0": "FromBeginning", FromBeginning: 0, "1": "FromEnd", FromEnd: 1};
  this.$rtti.$Enum("TDirection",{minvalue: 0, maxvalue: 1, ordtype: 1, enumtype: this.TDirection});
  this.$rtti.$DynArray("TBooleanDynArray",{eltype: rtl.boolean});
  this.$rtti.$DynArray("TWordDynArray",{eltype: rtl.word});
  this.$rtti.$DynArray("TIntegerDynArray",{eltype: rtl.longint});
  this.$rtti.$DynArray("TNativeIntDynArray",{eltype: rtl.nativeint});
  this.$rtti.$DynArray("TStringDynArray",{eltype: rtl.string});
  this.$rtti.$DynArray("TDoubleDynArray",{eltype: rtl.double});
  this.$rtti.$DynArray("TJSValueDynArray",{eltype: rtl.jsvalue});
  this.$rtti.$DynArray("TObjectDynArray",{eltype: pas.System.$rtti["TObject"]});
  this.$rtti.$DynArray("TByteDynArray",{eltype: rtl.byte});
  this.TDuplicates = {"0": "dupIgnore", dupIgnore: 0, "1": "dupAccept", dupAccept: 1, "2": "dupError", dupError: 2};
  this.$rtti.$Enum("TDuplicates",{minvalue: 0, maxvalue: 2, ordtype: 1, enumtype: this.TDuplicates});
  this.$rtti.$RefToProcVar("TProc",{procsig: rtl.newTIProcSig([])});
  this.$rtti.$RefToProcVar("TProcString",{procsig: rtl.newTIProcSig([["aString",rtl.string,2]])});
  this.$rtti.$MethodVar("TListCallback",{procsig: rtl.newTIProcSig([["data",rtl.jsvalue],["arg",rtl.jsvalue]]), methodkind: 0});
  this.$rtti.$ProcVar("TListStaticCallback",{procsig: rtl.newTIProcSig([["data",rtl.jsvalue],["arg",rtl.jsvalue]])});
  rtl.recNewT(this,"TSize",function () {
    this.cx = 0;
    this.cy = 0;
    this.$eq = function (b) {
      return (this.cx === b.cx) && (this.cy === b.cy);
    };
    this.$assign = function (s) {
      this.cx = s.cx;
      this.cy = s.cy;
      return this;
    };
    var $r = $mod.$rtti.$Record("TSize",{});
    $r.addField("cx",rtl.longint);
    $r.addField("cy",rtl.longint);
  });
  rtl.recNewT(this,"TPoint",function () {
    this.x = 0;
    this.y = 0;
    this.$eq = function (b) {
      return (this.x === b.x) && (this.y === b.y);
    };
    this.$assign = function (s) {
      this.x = s.x;
      this.y = s.y;
      return this;
    };
    var $r = $mod.$rtti.$Record("TPoint",{});
    $r.addField("x",rtl.longint);
    $r.addField("y",rtl.longint);
  });
  rtl.recNewT(this,"TRect",function () {
    this.Left = 0;
    this.Top = 0;
    this.Right = 0;
    this.Bottom = 0;
    this.$eq = function (b) {
      return (this.Left === b.Left) && (this.Top === b.Top) && (this.Right === b.Right) && (this.Bottom === b.Bottom);
    };
    this.$assign = function (s) {
      this.Left = s.Left;
      this.Top = s.Top;
      this.Right = s.Right;
      this.Bottom = s.Bottom;
      return this;
    };
    var $r = $mod.$rtti.$Record("TRect",{});
    $r.addField("Left",rtl.longint);
    $r.addField("Top",rtl.longint);
    $r.addField("Right",rtl.longint);
    $r.addField("Bottom",rtl.longint);
  });
  this.EqualRect = function (r1, r2) {
    var Result = false;
    Result = (r1.Left === r2.Left) && (r1.Right === r2.Right) && (r1.Top === r2.Top) && (r1.Bottom === r2.Bottom);
    return Result;
  };
  this.Rect = function (Left, Top, Right, Bottom) {
    var Result = $mod.TRect.$new();
    Result.Left = Left;
    Result.Top = Top;
    Result.Right = Right;
    Result.Bottom = Bottom;
    return Result;
  };
  this.Bounds = function (ALeft, ATop, AWidth, AHeight) {
    var Result = $mod.TRect.$new();
    Result.Left = ALeft;
    Result.Top = ATop;
    Result.Right = ALeft + AWidth;
    Result.Bottom = ATop + AHeight;
    return Result;
  };
  this.Point = function (x, y) {
    var Result = $mod.TPoint.$new();
    Result.x = x;
    Result.y = y;
    return Result;
  };
  this.PtInRect = function (aRect, p) {
    var Result = false;
    Result = (p.y >= aRect.Top) && (p.y < aRect.Bottom) && (p.x >= aRect.Left) && (p.x < aRect.Right);
    return Result;
  };
  this.IntersectRect = function (aRect, R1, R2) {
    var Result = false;
    var lRect = $mod.TRect.$new();
    lRect.$assign(R1);
    if (R2.Left > R1.Left) lRect.Left = R2.Left;
    if (R2.Top > R1.Top) lRect.Top = R2.Top;
    if (R2.Right < R1.Right) lRect.Right = R2.Right;
    if (R2.Bottom < R1.Bottom) lRect.Bottom = R2.Bottom;
    if ($mod.IsRectEmpty(lRect)) {
      aRect.$assign($mod.Rect(0,0,0,0));
      Result = false;
    } else {
      Result = true;
      aRect.$assign(lRect);
    };
    return Result;
  };
  this.UnionRect = function (aRect, R1, R2) {
    var Result = false;
    var lRect = $mod.TRect.$new();
    lRect.$assign(R1);
    if (R2.Left < R1.Left) lRect.Left = R2.Left;
    if (R2.Top < R1.Top) lRect.Top = R2.Top;
    if (R2.Right > R1.Right) lRect.Right = R2.Right;
    if (R2.Bottom > R1.Bottom) lRect.Bottom = R2.Bottom;
    if ($mod.IsRectEmpty(lRect)) {
      aRect.$assign($mod.Rect(0,0,0,0));
      Result = false;
    } else {
      aRect.$assign(lRect);
      Result = true;
    };
    return Result;
  };
  this.IsRectEmpty = function (aRect) {
    var Result = false;
    Result = (aRect.Right <= aRect.Left) || (aRect.Bottom <= aRect.Top);
    return Result;
  };
  this.OffsetRect = function (aRect, DX, DY) {
    var Result = false;
    aRect.Left += DX;
    aRect.Top += DY;
    aRect.Right += DX;
    aRect.Bottom += DY;
    Result = true;
    return Result;
  };
  this.CenterPoint = function (aRect) {
    var Result = $mod.TPoint.$new();
    function Avg(a, b) {
      var Result = 0;
      if (a < b) {
        Result = a + ((b - a) >>> 1)}
       else Result = b + ((a - b) >>> 1);
      return Result;
    };
    Result.x = Avg(aRect.Left,aRect.Right);
    Result.y = Avg(aRect.Top,aRect.Bottom);
    return Result;
  };
  this.InflateRect = function (aRect, dx, dy) {
    var Result = false;
    aRect.Left -= dx;
    aRect.Top -= dy;
    aRect.Right += dx;
    aRect.Bottom += dy;
    Result = true;
    return Result;
  };
  this.Size = function (AWidth, AHeight) {
    var Result = $mod.TSize.$new();
    Result.cx = AWidth;
    Result.cy = AHeight;
    return Result;
  };
  this.Size$1 = function (aRect) {
    var Result = $mod.TSize.$new();
    Result.cx = aRect.Right - aRect.Left;
    Result.cy = aRect.Bottom - aRect.Top;
    return Result;
  };
});
rtl.module("JS",["System","Types"],function () {
  "use strict";
  var $mod = this;
  rtl.createClass(this,"AsyncAttribute",pas.System.TCustomAttribute,function () {
  });
  rtl.createClass(this,"ExternalJSAttribute",pas.System.TCustomAttribute,function () {
    this.$init = function () {
      pas.System.TCustomAttribute.$init.call(this);
      this.FName = "";
    };
    this.Create$1 = function (AName) {
      pas.System.TObject.Create.call(this);
      this.FName = AName;
      return this;
    };
  });
  rtl.createClass(this,"EJS",pas.System.TObject,function () {
    this.$init = function () {
      pas.System.TObject.$init.call(this);
      this.FMessage = "";
    };
    this.Create$1 = function (Msg) {
      this.FMessage = Msg;
      return this;
    };
  });
  this.$rtti.$ExtClass("TJSObject",{jsclass: "Object"});
  this.$rtti.$DynArray("TJSObjectDynArray",{eltype: this.$rtti["TJSObject"]});
  this.$rtti.$DynArray("TJSObjectDynArrayArray",{eltype: this.$rtti["TJSObjectDynArray"]});
  this.$rtti.$DynArray("TJSStringDynArray",{eltype: rtl.string});
  this.$rtti.$ExtClass("TJSIteratorValue",{jsclass: "IteratorValue"});
  this.$rtti.$ExtClass("TJSIterator",{jsclass: "Iterator"});
  this.$rtti.$ExtClass("TJSSet");
  this.$rtti.$RefToProcVar("TJSSetEventProc",{procsig: rtl.newTIProcSig([["value",rtl.jsvalue],["key",rtl.nativeint],["set_",this.$rtti["TJSSet"]]])});
  this.$rtti.$RefToProcVar("TJSSetProcCallBack",{procsig: rtl.newTIProcSig([["value",rtl.jsvalue],["key",rtl.jsvalue]])});
  this.$rtti.$ExtClass("TJSSet",{jsclass: "Set"});
  this.$rtti.$RefToProcVar("TJSMapFunctionCallBack",{procsig: rtl.newTIProcSig([["arg",rtl.jsvalue]],rtl.jsvalue)});
  this.$rtti.$RefToProcVar("TJSMapProcCallBack",{procsig: rtl.newTIProcSig([["value",rtl.jsvalue],["key",rtl.jsvalue]])});
  this.$rtti.$ExtClass("TJSMap",{jsclass: "Map"});
  this.$rtti.$ExtClass("TJSFunction",{ancestor: this.$rtti["TJSObject"], jsclass: "Function"});
  this.$rtti.$ExtClass("TJSDate",{ancestor: this.$rtti["TJSFunction"], jsclass: "Date"});
  rtl.recNewT(this,"TLocaleCompareOptions",function () {
    this.$eq = function (b) {
      return (this.localeMatcher === b.localeMatcher) && (this.usage === b.usage) && (this.sensitivity === b.sensitivity) && (this.ignorePunctuation === b.ignorePunctuation) && (this.numeric === b.numeric) && (this.caseFirst === b.caseFirst);
    };
    this.$assign = function (s) {
      this.localeMatcher = s.localeMatcher;
      this.usage = s.usage;
      this.sensitivity = s.sensitivity;
      this.ignorePunctuation = s.ignorePunctuation;
      this.numeric = s.numeric;
      this.caseFirst = s.caseFirst;
      return this;
    };
    var $r = $mod.$rtti.$Record("TLocaleCompareOptions",{});
    $r.addField("localeMatcher",rtl.string);
    $r.addField("usage",rtl.string);
    $r.addField("sensitivity",rtl.string);
    $r.addField("ignorePunctuation",rtl.boolean);
    $r.addField("numeric",rtl.boolean);
    $r.addField("caseFirst",rtl.string);
  });
  this.$rtti.$ExtClass("TJSRegexp",{jsclass: "RegExp"});
  this.$rtti.$RefToProcVar("TReplaceCallBack",{procsig: rtl.newTIProcSig([["match",rtl.string,2]],rtl.string,2)});
  this.$rtti.$RefToProcVar("TReplaceCallBack0",{procsig: rtl.newTIProcSig([["match",rtl.string,2],["offset",rtl.longint],["AString",rtl.string]],rtl.string)});
  this.$rtti.$RefToProcVar("TReplaceCallBack1",{procsig: rtl.newTIProcSig([["match",rtl.string,2],["p1",rtl.string,2],["offset",rtl.longint],["AString",rtl.string]],rtl.string)});
  this.$rtti.$RefToProcVar("TReplaceCallBack2",{procsig: rtl.newTIProcSig([["match",rtl.string,2],["p1",rtl.string,2],["p2",rtl.string,2],["offset",rtl.longint],["AString",rtl.string]],rtl.string)});
  this.$rtti.$ExtClass("TJSString",{jsclass: "String"});
  this.$rtti.$ExtClass("TJSArray");
  this.$rtti.$RefToProcVar("TJSArrayEventProc",{procsig: rtl.newTIProcSig([["element",rtl.jsvalue],["index",rtl.nativeint],["anArray",this.$rtti["TJSArray"]]])});
  this.$rtti.$RefToProcVar("TJSArrayEvent",{procsig: rtl.newTIProcSig([["element",rtl.jsvalue],["index",rtl.nativeint],["anArray",this.$rtti["TJSArray"]]],rtl.boolean)});
  this.$rtti.$RefToProcVar("TJSArrayMapEvent",{procsig: rtl.newTIProcSig([["element",rtl.jsvalue],["index",rtl.nativeint],["anArray",this.$rtti["TJSArray"]]],rtl.jsvalue)});
  this.$rtti.$RefToProcVar("TJSArrayReduceEvent",{procsig: rtl.newTIProcSig([["accumulator",rtl.jsvalue],["currentValue",rtl.jsvalue],["currentIndex",rtl.nativeint],["anArray",this.$rtti["TJSArray"]]],rtl.jsvalue)});
  this.$rtti.$RefToProcVar("TJSArrayCompareEvent",{procsig: rtl.newTIProcSig([["a",rtl.jsvalue],["b",rtl.jsvalue]],rtl.nativeint)});
  this.$rtti.$ExtClass("TJSArray",{jsclass: "Array"});
  this.$rtti.$ExtClass("TJSArrayBuffer",{ancestor: this.$rtti["TJSObject"], jsclass: "ArrayBuffer"});
  this.$rtti.$ExtClass("TJSBufferSource",{jsclass: "BufferSource"});
  this.$rtti.$ExtClass("TJSTypedArray");
  this.$rtti.$ProcVar("TJSTypedArrayCallBack",{procsig: rtl.newTIProcSig([["element",rtl.jsvalue],["index",rtl.nativeint],["anArray",this.$rtti["TJSTypedArray"]]],rtl.boolean)});
  this.$rtti.$MethodVar("TJSTypedArrayEvent",{procsig: rtl.newTIProcSig([["element",rtl.jsvalue],["index",rtl.nativeint],["anArray",this.$rtti["TJSTypedArray"]]],rtl.boolean), methodkind: 1});
  this.$rtti.$ProcVar("TJSTypedArrayMapCallBack",{procsig: rtl.newTIProcSig([["element",rtl.jsvalue],["index",rtl.nativeint],["anArray",this.$rtti["TJSTypedArray"]]],rtl.jsvalue)});
  this.$rtti.$MethodVar("TJSTypedArrayMapEvent",{procsig: rtl.newTIProcSig([["element",rtl.jsvalue],["index",rtl.nativeint],["anArray",this.$rtti["TJSTypedArray"]]],rtl.jsvalue), methodkind: 1});
  this.$rtti.$ProcVar("TJSTypedArrayReduceCallBack",{procsig: rtl.newTIProcSig([["accumulator",rtl.jsvalue],["currentValue",rtl.jsvalue],["currentIndex",rtl.nativeint],["anArray",this.$rtti["TJSTypedArray"]]],rtl.jsvalue)});
  this.$rtti.$ProcVar("TJSTypedArrayCompareCallBack",{procsig: rtl.newTIProcSig([["a",rtl.jsvalue],["b",rtl.jsvalue]],rtl.nativeint)});
  this.$rtti.$ExtClass("TJSTypedArray",{ancestor: this.$rtti["TJSBufferSource"], jsclass: "TypedArray"});
  this.$rtti.$ExtClass("TJSInt8Array",{ancestor: this.$rtti["TJSTypedArray"], jsclass: "Int8Array"});
  this.$rtti.$ExtClass("TJSUint8Array",{ancestor: this.$rtti["TJSTypedArray"], jsclass: "Uint8Array"});
  this.$rtti.$ExtClass("TJSUint8ClampedArray",{ancestor: this.$rtti["TJSTypedArray"], jsclass: "Uint8ClampedArray"});
  this.$rtti.$ExtClass("TJSInt16Array",{ancestor: this.$rtti["TJSTypedArray"], jsclass: "Int16Array"});
  this.$rtti.$ExtClass("TJSUint16Array",{ancestor: this.$rtti["TJSTypedArray"], jsclass: "Uint16Array"});
  this.$rtti.$ExtClass("TJSInt32Array",{ancestor: this.$rtti["TJSTypedArray"], jsclass: "Int32Array"});
  this.$rtti.$ExtClass("TJSUint32Array",{ancestor: this.$rtti["TJSTypedArray"], jsclass: "Uint32Array"});
  this.$rtti.$ExtClass("TJSFloat32Array",{ancestor: this.$rtti["TJSTypedArray"], jsclass: "Float32Array"});
  this.$rtti.$ExtClass("TJSFloat64Array",{ancestor: this.$rtti["TJSTypedArray"], jsclass: "Float64Array"});
  this.$rtti.$ExtClass("TJSDataView",{ancestor: this.$rtti["TJSBufferSource"], jsclass: "DataView"});
  this.$rtti.$ExtClass("TJSJSON",{ancestor: this.$rtti["TJSObject"], jsclass: "JSON"});
  this.$rtti.$ExtClass("TJSError",{ancestor: this.$rtti["TJSObject"], jsclass: "Error"});
  this.$rtti.$RefToProcVar("TJSPromiseResolver",{procsig: rtl.newTIProcSig([["aValue",rtl.jsvalue]],rtl.jsvalue)});
  this.$rtti.$RefToProcVar("TJSPromiseExecutor",{procsig: rtl.newTIProcSig([["resolve",this.$rtti["TJSPromiseResolver"]],["reject",this.$rtti["TJSPromiseResolver"]]])});
  this.$rtti.$RefToProcVar("TJSPromiseFinallyHandler",{procsig: rtl.newTIProcSig([])});
  this.$rtti.$ExtClass("TJSPromise");
  this.$rtti.$DynArray("TJSPromiseArray",{eltype: this.$rtti["TJSPromise"]});
  this.$rtti.$ExtClass("TJSPromise",{jsclass: "Promise"});
  rtl.createHelper(this,"TJSPromiseHelper",null,function () {
    this.From = function (AValue) {
      var Result = null;
      Result = AValue;
      return Result;
    };
  });
  this.$rtti.$ExtClass("TJSFunctionArguments",{jsclass: "arguments"});
  this.$rtti.$ExtClass("TJSIteratorResult",{ancestor: this.$rtti["TJSObject"], jsclass: "IteratorResult"});
  this.$rtti.$ExtClass("TJSAsyncIterator",{ancestor: this.$rtti["TJSObject"], jsclass: "AsyncIterator"});
  this.$rtti.$ExtClass("TJSSyntaxError",{ancestor: this.$rtti["TJSError"], jsclass: "SyntaxError"});
  this.$rtti.$ExtClass("TJSTextDecoderOptions",{ancestor: this.$rtti["TJSObject"], jsclass: "Object"});
  this.$rtti.$ExtClass("TJSTextDecodeOptions",{ancestor: this.$rtti["TJSObject"], jsclass: "Object"});
  this.$rtti.$ExtClass("TJSTextDecoder",{ancestor: this.$rtti["TJSObject"], jsclass: "TextDecoder"});
  this.$rtti.$ExtClass("TJSTextEncoderEncodeIntoResult",{ancestor: this.$rtti["TJSObject"], jsclass: "Object"});
  this.$rtti.$ExtClass("TJSTextEncoder",{ancestor: this.$rtti["TJSObject"], jsclass: "TextEncoder"});
  this.New = function (aElements) {
    var Result = null;
    var L = 0;
    var I = 0;
    var S = "";
    L = rtl.length(aElements);
    if ((L % 2) === 1) throw $mod.EJS.$create("Create$1",["Number of arguments must be even"]);
    I = 0;
    while (I < L) {
      if (!rtl.isString(aElements[I])) {
        S = String(I);
        throw $mod.EJS.$create("Create$1",["Argument " + S + " must be a string."]);
      };
      I += 2;
    };
    I = 0;
    Result = new Object();
    while (I < L) {
      S = "" + aElements[I];
      Result[S] = aElements[I + 1];
      I += 2;
    };
    return Result;
  };
  this.JSDelete = function (Obj, PropName) {
    return delete Obj[PropName];
  };
  this.hasValue = function (v) {
    if(v){ return true; } else { return false; };
  };
  this.isBoolean = function (v) {
    return typeof(v) == 'boolean';
  };
  this.isDate = function (v) {
    return (v instanceof Date);
  };
  this.isCallback = function (v) {
    return rtl.isObject(v) && rtl.isObject(v.scope) && (rtl.isString(v.fn) || rtl.isFunction(v.fn));
  };
  this.isChar = function (v) {
    return (typeof(v)!="string") && (v.length==1);
  };
  this.isClass = function (v) {
    return (typeof(v)=="object") && (v!=null) && (v.$class == v);
  };
  this.isClassInstance = function (v) {
    return (typeof(v)=="object") && (v!=null) && (v.$class == Object.getPrototypeOf(v));
  };
  this.isInteger = function (v) {
    return Math.floor(v)===v;
  };
  this.isNull = function (v) {
    return v === null;
  };
  this.isRecord = function (v) {
    return (typeof(v)==="object")
    && (typeof(v.$new)==="function")
    && (typeof(v.$clone)==="function")
    && (typeof(v.$eq)==="function")
    && (typeof(v.$assign)==="function");
  };
  this.isUndefined = function (v) {
    return v == undefined;
  };
  this.isDefined = function (v) {
    return !(v == undefined);
  };
  this.isUTF16Char = function (v) {
    if (typeof(v)!="string") return false;
    if ((v.length==0) || (v.length>2)) return false;
    var code = v.charCodeAt(0);
    if (code < 0xD800){
      if (v.length == 1) return true;
    } else if (code <= 0xDBFF){
      if (v.length==2){
        code = v.charCodeAt(1);
        if (code >= 0xDC00 && code <= 0xDFFF) return true;
      };
    };
    return false;
  };
  this.jsInstanceOf = function (aFunction, aFunctionWithPrototype) {
    return aFunction instanceof aFunctionWithPrototype;
  };
  this.toNumber = function (v) {
    return v-0;
  };
  this.toInteger = function (v) {
    var Result = 0;
    if ($mod.isInteger(v)) {
      Result = rtl.trunc(v)}
     else Result = 0;
    return Result;
  };
  this.toObject = function (Value) {
    var Result = null;
    if (rtl.isObject(Value)) {
      Result = Value}
     else Result = null;
    return Result;
  };
  this.toArray = function (Value) {
    var Result = null;
    if (rtl.isArray(Value)) {
      Result = Value}
     else Result = null;
    return Result;
  };
  this.toBoolean = function (Value) {
    var Result = false;
    if ($mod.isBoolean(Value)) {
      Result = !(Value == false)}
     else Result = false;
    return Result;
  };
  this.ToString = function (Value) {
    var Result = "";
    if (rtl.isString(Value)) {
      Result = "" + Value}
     else Result = "";
    return Result;
  };
  this.TJSValueType = {"0": "jvtNull", jvtNull: 0, "1": "jvtBoolean", jvtBoolean: 1, "2": "jvtInteger", jvtInteger: 2, "3": "jvtFloat", jvtFloat: 3, "4": "jvtString", jvtString: 4, "5": "jvtObject", jvtObject: 5, "6": "jvtArray", jvtArray: 6};
  this.$rtti.$Enum("TJSValueType",{minvalue: 0, maxvalue: 6, ordtype: 1, enumtype: this.TJSValueType});
  this.GetValueType = function (JS) {
    var Result = 0;
    var t = "";
    if ($mod.isNull(JS)) {
      Result = $mod.TJSValueType.jvtNull}
     else {
      t = typeof(JS);
      if (t === "string") {
        Result = $mod.TJSValueType.jvtString}
       else if (t === "boolean") {
        Result = $mod.TJSValueType.jvtBoolean}
       else if (t === "object") {
        if (rtl.isArray(JS)) {
          Result = $mod.TJSValueType.jvtArray}
         else Result = $mod.TJSValueType.jvtObject;
      } else if (t === "number") if ($mod.isInteger(JS)) {
        Result = $mod.TJSValueType.jvtInteger}
       else Result = $mod.TJSValueType.jvtFloat;
    };
    return Result;
  };
});
rtl.module("SysUtils",["System","RTLConsts","JS"],function () {
  "use strict";
  var $mod = this;
  var $impl = $mod.$impl;
  this.FreeAndNil = function (Obj) {
    var o = null;
    o = Obj.get();
    if (o === null) return;
    Obj.set(null);
    o.$destroy("Destroy");
  };
  this.$rtti.$ProcVar("TProcedure",{procsig: rtl.newTIProcSig([])});
  this.FloatRecDigits = 19;
  this.$rtti.$Set("TSysCharSet",{comptype: rtl.char});
  rtl.recNewT(this,"TFloatRec",function () {
    this.Exponent = 0;
    this.Negative = false;
    this.$new = function () {
      var r = Object.create(this);
      r.Digits = rtl.arraySetLength(null,"\x00",19);
      return r;
    };
    this.$eq = function (b) {
      return (this.Exponent === b.Exponent) && (this.Negative === b.Negative) && rtl.arrayEq(this.Digits,b.Digits);
    };
    this.$assign = function (s) {
      this.Exponent = s.Exponent;
      this.Negative = s.Negative;
      this.Digits = s.Digits.slice(0);
      return this;
    };
    var $r = $mod.$rtti.$Record("TFloatRec",{});
    $r.addField("Exponent",rtl.longint);
    $r.addField("Negative",rtl.boolean);
    $mod.$rtti.$StaticArray("TFloatRec.Digits$a",{dims: [19], eltype: rtl.char});
    $r.addField("Digits",$mod.$rtti["TFloatRec.Digits$a"]);
  });
  this.TEndian = {"0": "Little", Little: 0, "1": "Big", Big: 1};
  this.$rtti.$Enum("TEndian",{minvalue: 0, maxvalue: 1, ordtype: 1, enumtype: this.TEndian});
  this.$rtti.$StaticArray("TByteArray",{dims: [32768], eltype: rtl.byte});
  this.$rtti.$StaticArray("TWordArray",{dims: [16384], eltype: rtl.word});
  this.$rtti.$DynArray("TBytes",{eltype: rtl.byte});
  this.$rtti.$DynArray("TStringArray",{eltype: rtl.string});
  this.$rtti.$StaticArray("TMonthNameArray",{dims: [12], eltype: rtl.string});
  this.$rtti.$StaticArray("TDayTable",{dims: [12], eltype: rtl.word});
  this.$rtti.$StaticArray("TWeekNameArray",{dims: [7], eltype: rtl.string});
  this.$rtti.$StaticArray("TDayNames",{dims: [7], eltype: rtl.string});
  rtl.recNewT(this,"TFormatSettings",function () {
    this.CurrencyDecimals = 0;
    this.CurrencyFormat = 0;
    this.CurrencyString = "";
    this.DateSeparator = "\x00";
    this.DecimalSeparator = "";
    this.LongDateFormat = "";
    this.LongTimeFormat = "";
    this.NegCurrFormat = 0;
    this.ShortDateFormat = "";
    this.ShortTimeFormat = "";
    this.ThousandSeparator = "";
    this.TimeAMString = "";
    this.TimePMString = "";
    this.TimeSeparator = "\x00";
    this.TwoDigitYearCenturyWindow = 0;
    $mod.$rtti.$ProcVar("TFormatSettings.TLocaleInitCallback",{procsig: rtl.newTIProcSig([["aLocale",rtl.string,2],["aInstance",$r]])});
    this.InitLocaleHandler = null;
    this.$new = function () {
      var r = Object.create(this);
      r.DateTimeToStrFormat = rtl.arraySetLength(null,"",2);
      r.LongDayNames = rtl.arraySetLength(null,"",7);
      r.LongMonthNames = rtl.arraySetLength(null,"",12);
      r.ShortDayNames = rtl.arraySetLength(null,"",7);
      r.ShortMonthNames = rtl.arraySetLength(null,"",12);
      return r;
    };
    this.$eq = function (b) {
      return (this.CurrencyDecimals === b.CurrencyDecimals) && (this.CurrencyFormat === b.CurrencyFormat) && (this.CurrencyString === b.CurrencyString) && (this.DateSeparator === b.DateSeparator) && rtl.arrayEq(this.DateTimeToStrFormat,b.DateTimeToStrFormat) && (this.DecimalSeparator === b.DecimalSeparator) && (this.LongDateFormat === b.LongDateFormat) && rtl.arrayEq(this.LongDayNames,b.LongDayNames) && rtl.arrayEq(this.LongMonthNames,b.LongMonthNames) && (this.LongTimeFormat === b.LongTimeFormat) && (this.NegCurrFormat === b.NegCurrFormat) && (this.ShortDateFormat === b.ShortDateFormat) && rtl.arrayEq(this.ShortDayNames,b.ShortDayNames) && rtl.arrayEq(this.ShortMonthNames,b.ShortMonthNames) && (this.ShortTimeFormat === b.ShortTimeFormat) && (this.ThousandSeparator === b.ThousandSeparator) && (this.TimeAMString === b.TimeAMString) && (this.TimePMString === b.TimePMString) && (this.TimeSeparator === b.TimeSeparator) && (this.TwoDigitYearCenturyWindow === b.TwoDigitYearCenturyWindow);
    };
    this.$assign = function (s) {
      this.CurrencyDecimals = s.CurrencyDecimals;
      this.CurrencyFormat = s.CurrencyFormat;
      this.CurrencyString = s.CurrencyString;
      this.DateSeparator = s.DateSeparator;
      this.DateTimeToStrFormat = s.DateTimeToStrFormat.slice(0);
      this.DecimalSeparator = s.DecimalSeparator;
      this.LongDateFormat = s.LongDateFormat;
      this.LongDayNames = s.LongDayNames.slice(0);
      this.LongMonthNames = s.LongMonthNames.slice(0);
      this.LongTimeFormat = s.LongTimeFormat;
      this.NegCurrFormat = s.NegCurrFormat;
      this.ShortDateFormat = s.ShortDateFormat;
      this.ShortDayNames = s.ShortDayNames.slice(0);
      this.ShortMonthNames = s.ShortMonthNames.slice(0);
      this.ShortTimeFormat = s.ShortTimeFormat;
      this.ThousandSeparator = s.ThousandSeparator;
      this.TimeAMString = s.TimeAMString;
      this.TimePMString = s.TimePMString;
      this.TimeSeparator = s.TimeSeparator;
      this.TwoDigitYearCenturyWindow = s.TwoDigitYearCenturyWindow;
      return this;
    };
    this.GetBrowserLocale = function () {
      return navigator.language;
    };
    this.GetJSLocale = function () {
      return Intl.DateTimeFormat().resolvedOptions().locale;
    };
    this.GetLocaleDecimalSeparator = function (ALocale) {
      var lNumber = 1.1;
      lNumber = lNumber.toLocaleString(ALocale).substring(1, 2);
      return lNumber;
    };
    this.GetLocaleLongDayName = function (ADayOfWeek, ALocale) {
      var lBaseDate = new Date(2017, 0, 1); // Sunday
      lBaseDate.setDate(lBaseDate.getDate() + ADayOfWeek - 1);
      return lBaseDate.toLocaleDateString(ALocale, { weekday: 'long' });
    };
    this.GetLocaleLongMonthName = function (AMonth, ALocale) {
      var lBaseDate = new Date(2017, AMonth - 1, 1);
      return lBaseDate.toLocaleDateString(ALocale, { month: 'long' });
    };
    this.GetLocaleLongTimeFormat = function (ALocale) {
      var Result = "";
      Result = "hh:nn:ss";
      if ($mod.UpperCase(ALocale) === "EN-US") Result = "hh:nn:ss AMPM";
      return Result;
    };
    var cDeli = "-";
    var cShortLength = 2;
    this.GetLocaleShortDateFormat = function (ALocale) {
      var Result = "";
      var lIndex = 0;
      var res = "";
      res = $mod.TStringHelper.Empty;
      ALocale = $mod.TStringHelper.ToLower.call({get: function () {
          return ALocale;
        }, set: function (v) {
          ALocale = v;
        }});
      lIndex = $mod.TStringHelper.IndexOf.call({get: function () {
          return ALocale;
        }, set: function (v) {
          ALocale = v;
        }},cDeli);
      if (lIndex >= 0) {
        ALocale = $mod.TStringHelper.Substring$1.call({get: function () {
            return ALocale;
          }, set: function (v) {
            ALocale = v;
          }},0,lIndex) + $mod.TStringHelper.ToUpper.call({a: $mod.TStringHelper.Substring.call({get: function () {
              return ALocale;
            }, set: function (v) {
              ALocale = v;
            }},lIndex), get: function () {
            return this.a;
          }, set: function (v) {
            this.a = v;
          }})}
       else {
        if ($mod.TStringHelper.GetLength.call({get: function () {
            return ALocale;
          }, set: function (v) {
            ALocale = v;
          }}) === 2) ALocale = ALocale + cDeli + $mod.TStringHelper.ToUpper.call({get: function () {
            return ALocale;
          }, set: function (v) {
            ALocale = v;
          }});
      };
      var lFormats = {
        "ar-SA" : "dd/MM/yy",
        "bg-BG" : "dd.M.yyyy",
        "ca-ES" : "dd/MM/yyyy",
        "zh-TW" : "yyyy/M/d",
        "cs-CZ" : "d.M.yyyy",
        "da-DK" : "dd-MM-yyyy",
        "de-DE" : "dd.MM.yyyy",
        "el-GR" : "d/M/yyyy",
        "en-US" : "M/d/yyyy",
        "fi-FI" : "d.M.yyyy",
        "fr-FR" : "dd/MM/yyyy",
        "he-IL" : "dd/MM/yyyy",
        "hu-HU" : "yyyy. MM. dd.",
        "is-IS" : "d.M.yyyy",
        "it-IT" : "dd/MM/yyyy",
        "ja-JP" : "yyyy/MM/dd",
        "ko-KR" : "yyyy-MM-dd",
        "nl-NL" : "d-M-yyyy",
        "nb-NO" : "dd.MM.yyyy",
        "pl-PL" : "yyyy-MM-dd",
        "pt-BR" : "d/M/yyyy",
        "ro-RO" : "dd.MM.yyyy",
        "ru-RU" : "dd.MM.yyyy",
        "hr-HR" : "d.M.yyyy",
        "sk-SK" : "d. M. yyyy",
        "sq-AL" : "yyyy-MM-dd",
        "sv-SE" : "yyyy-MM-dd",
        "th-TH" : "d/M/yyyy",
        "tr-TR" : "dd.MM.yyyy",
        "ur-PK" : "dd/MM/yyyy",
        "id-ID" : "dd/MM/yyyy",
        "uk-UA" : "dd.MM.yyyy",
        "be-BY" : "dd.MM.yyyy",
        "sl-SI" : "d.M.yyyy",
        "et-EE" : "d.MM.yyyy",
        "lv-LV" : "yyyy.MM.dd.",
        "lt-LT" : "yyyy.MM.dd",
        "fa-IR" : "MM/dd/yyyy",
        "vi-VN" : "dd/MM/yyyy",
        "hy-AM" : "dd.MM.yyyy",
        "az-Latn-AZ" : "dd.MM.yyyy",
        "eu-ES" : "yyyy/MM/dd",
        "mk-MK" : "dd.MM.yyyy",
        "af-ZA" : "yyyy/MM/dd",
        "ka-GE" : "dd.MM.yyyy",
        "fo-FO" : "dd-MM-yyyy",
        "hi-IN" : "dd-MM-yyyy",
        "ms-MY" : "dd/MM/yyyy",
        "kk-KZ" : "dd.MM.yyyy",
        "ky-KG" : "dd.MM.yy",
        "sw-KE" : "M/d/yyyy",
        "uz-Latn-UZ" : "dd/MM yyyy",
        "tt-RU" : "dd.MM.yyyy",
        "pa-IN" : "dd-MM-yy",
        "gu-IN" : "dd-MM-yy",
        "ta-IN" : "dd-MM-yyyy",
        "te-IN" : "dd-MM-yy",
        "kn-IN" : "dd-MM-yy",
        "mr-IN" : "dd-MM-yyyy",
        "sa-IN" : "dd-MM-yyyy",
        "mn-MN" : "yy.MM.dd",
        "gl-ES" : "dd/MM/yy",
        "kok-IN" : "dd-MM-yyyy",
        "syr-SY" : "dd/MM/yyyy",
        "dv-MV" : "dd/MM/yy",
        "ar-IQ" : "dd/MM/yyyy",
        "zh-CN" : "yyyy/M/d",
        "de-CH" : "dd.MM.yyyy",
        "en-GB" : "dd/MM/yyyy",
        "es-MX" : "dd/MM/yyyy",
        "fr-BE" : "d/MM/yyyy",
        "it-CH" : "dd.MM.yyyy",
        "nl-BE" : "d/MM/yyyy",
        "nn-NO" : "dd.MM.yyyy",
        "pt-PT" : "dd-MM-yyyy",
        "sr-Latn-CS" : "d.M.yyyy",
        "sv-FI" : "d.M.yyyy",
        "az-Cyrl-AZ" : "dd.MM.yyyy",
        "ms-BN" : "dd/MM/yyyy",
        "uz-Cyrl-UZ" : "dd.MM.yyyy",
        "ar-EG" : "dd/MM/yyyy",
        "zh-HK" : "d/M/yyyy",
        "de-AT" : "dd.MM.yyyy",
        "en-AU" : "d/MM/yyyy",
        "es-ES" : "dd/MM/yyyy",
        "fr-CA" : "yyyy-MM-dd",
        "sr-Cyrl-CS" : "d.M.yyyy",
        "ar-LY" : "dd/MM/yyyy",
        "zh-SG" : "d/M/yyyy",
        "de-LU" : "dd.MM.yyyy",
        "en-CA" : "dd/MM/yyyy",
        "es-GT" : "dd/MM/yyyy",
        "fr-CH" : "dd.MM.yyyy",
        "ar-DZ" : "dd-MM-yyyy",
        "zh-MO" : "d/M/yyyy",
        "de-LI" : "dd.MM.yyyy",
        "en-NZ" : "d/MM/yyyy",
        "es-CR" : "dd/MM/yyyy",
        "fr-LU" : "dd/MM/yyyy",
        "ar-MA" : "dd-MM-yyyy",
        "en-IE" : "dd/MM/yyyy",
        "es-PA" : "MM/dd/yyyy",
        "fr-MC" : "dd/MM/yyyy",
        "ar-TN" : "dd-MM-yyyy",
        "en-ZA" : "yyyy/MM/dd",
        "es-DO" : "dd/MM/yyyy",
        "ar-OM" : "dd/MM/yyyy",
        "en-JM" : "dd/MM/yyyy",
        "es-VE" : "dd/MM/yyyy",
        "ar-YE" : "dd/MM/yyyy",
        "en-029" : "MM/dd/yyyy",
        "es-CO" : "dd/MM/yyyy",
        "ar-SY" : "dd/MM/yyyy",
        "en-BZ" : "dd/MM/yyyy",
        "es-PE" : "dd/MM/yyyy",
        "ar-JO" : "dd/MM/yyyy",
        "en-TT" : "dd/MM/yyyy",
        "es-AR" : "dd/MM/yyyy",
        "ar-LB" : "dd/MM/yyyy",
        "en-ZW" : "M/d/yyyy",
        "es-EC" : "dd/MM/yyyy",
        "ar-KW" : "dd/MM/yyyy",
        "en-PH" : "M/d/yyyy",
        "es-CL" : "dd-MM-yyyy",
        "ar-AE" : "dd/MM/yyyy",
        "es-UY" : "dd/MM/yyyy",
        "ar-BH" : "dd/MM/yyyy",
        "es-PY" : "dd/MM/yyyy",
        "ar-QA" : "dd/MM/yyyy",
        "es-BO" : "dd/MM/yyyy",
        "es-SV" : "dd/MM/yyyy",
        "es-HN" : "dd/MM/yyyy",
        "es-NI" : "dd/MM/yyyy",
        "es-PR" : "dd/MM/yyyy",
        "am-ET" : "d/M/yyyy",
        "tzm-Latn-DZ" : "dd-MM-yyyy",
        "iu-Latn-CA" : "d/MM/yyyy",
        "sma-NO" : "dd.MM.yyyy",
        "mn-Mong-CN" : "yyyy/M/d",
        "gd-GB" : "dd/MM/yyyy",
        "en-MY" : "d/M/yyyy",
        "prs-AF" : "dd/MM/yy",
        "bn-BD" : "dd-MM-yy",
        "wo-SN" : "dd/MM/yyyy",
        "rw-RW" : "M/d/yyyy",
        "qut-GT" : "dd/MM/yyyy",
        "sah-RU" : "MM.dd.yyyy",
        "gsw-FR" : "dd/MM/yyyy",
        "co-FR" : "dd/MM/yyyy",
        "oc-FR" : "dd/MM/yyyy",
        "mi-NZ" : "dd/MM/yyyy",
        "ga-IE" : "dd/MM/yyyy",
        "se-SE" : "yyyy-MM-dd",
        "br-FR" : "dd/MM/yyyy",
        "smn-FI" : "d.M.yyyy",
        "moh-CA" : "M/d/yyyy",
        "arn-CL" : "dd-MM-yyyy",
        "ii-CN" : "yyyy/M/d",
        "dsb-DE" : "d. M. yyyy",
        "ig-NG" : "d/M/yyyy",
        "kl-GL" : "dd-MM-yyyy",
        "lb-LU" : "dd/MM/yyyy",
        "ba-RU" : "dd.MM.yy",
        "nso-ZA" : "yyyy/MM/dd",
        "quz-BO" : "dd/MM/yyyy",
        "yo-NG" : "d/M/yyyy",
        "ha-Latn-NG" : "d/M/yyyy",
        "fil-PH" : "M/d/yyyy",
        "ps-AF" : "dd/MM/yy",
        "fy-NL" : "d-M-yyyy",
        "ne-NP" : "M/d/yyyy",
        "se-NO" : "dd.MM.yyyy",
        "iu-Cans-CA" : "d/M/yyyy",
        "sr-Latn-RS" : "d.M.yyyy",
        "si-LK" : "yyyy-MM-dd",
        "sr-Cyrl-RS" : "d.M.yyyy",
        "lo-LA" : "dd/MM/yyyy",
        "km-KH" : "yyyy-MM-dd",
        "cy-GB" : "dd/MM/yyyy",
        "bo-CN" : "yyyy/M/d",
        "sms-FI" : "d.M.yyyy",
        "as-IN" : "dd-MM-yyyy",
        "ml-IN" : "dd-MM-yy",
        "en-IN" : "dd-MM-yyyy",
        "or-IN" : "dd-MM-yy",
        "bn-IN" : "dd-MM-yy",
        "tk-TM" : "dd.MM.yy",
        "bs-Latn-BA" : "d.M.yyyy",
        "mt-MT" : "dd/MM/yyyy",
        "sr-Cyrl-ME" : "d.M.yyyy",
        "se-FI" : "d.M.yyyy",
        "zu-ZA" : "yyyy/MM/dd",
        "xh-ZA" : "yyyy/MM/dd",
        "tn-ZA" : "yyyy/MM/dd",
        "hsb-DE" : "d. M. yyyy",
        "bs-Cyrl-BA" : "d.M.yyyy",
        "tg-Cyrl-TJ" : "dd.MM.yy",
        "sr-Latn-BA" : "d.M.yyyy",
        "smj-NO" : "dd.MM.yyyy",
        "rm-CH" : "dd/MM/yyyy",
        "smj-SE" : "yyyy-MM-dd",
        "quz-EC" : "dd/MM/yyyy",
        "quz-PE" : "dd/MM/yyyy",
        "hr-BA" : "d.M.yyyy.",
        "sr-Latn-ME" : "d.M.yyyy",
        "sma-SE" : "yyyy-MM-dd",
        "en-SG" : "d/M/yyyy",
        "ug-CN" : "yyyy-M-d",
        "sr-Cyrl-BA" : "d.M.yyyy",
        "es-US" : "M/d/yyyy"};
      res = lFormats[ALocale] || 'dd/MM/yyyy';
      Result = res;
      return Result;
    };
    this.GetLocaleShortDayName = function (ADayOfWeek, ALocale) {
      var lBaseDate = new Date(2017, 0, 1); // Sunday
        lBaseDate.setDate(lBaseDate.getDate() + ADayOfWeek - 1);
      
        var lLoc = "";
        if (ALocale == '')
          lLoc = navigator.language
        else
          lLoc = ALocale;
      
        return lBaseDate.toLocaleDateString(lLoc, { weekday: 'short' });
    };
    this.GetLocaleShortMonthName = function (AMonth, ALocale) {
      var lBaseDate = new Date(2017, AMonth - 1, 1);
      var lLoc = "";
      if (ALocale == '')
        lLoc = navigator.language
      else
        lLoc = ALocale;
      return lBaseDate.toLocaleDateString(lLoc, { month: 'short' });
    };
    this.GetLocaleShortTimeFormat = function (ALocale) {
      var Result = "";
      Result = "hh:nn";
      if ($mod.UpperCase(ALocale) === "EN-US") Result = "h:nn AMPM";
      return Result;
    };
    this.Create = function () {
      var Result = $mod.TFormatSettings.$new();
      Result.$assign($mod.TFormatSettings.Create$1($mod.TFormatSettings.GetJSLocale()));
      return Result;
    };
    var cDateSeps = ["/",".","-"];
    var cTimeSeps = [":",".","-"];
    var cDecSeps = [",","."];
    var cThousandSeps = [".",","];
    this.Create$1 = function (ALocale) {
      var Result = $mod.TFormatSettings.$new();
      var lTimeStr = "";
      var lCount = 0;
      var lLoc = "";
      lLoc = $mod.UpperCase(ALocale);
      if (pas.System.Pos("DE",lLoc) === 1) {
        Result.LongDayNames[0] = "Sonntag";
        Result.LongDayNames[1] = "Montag";
        Result.LongDayNames[2] = "Dienstag";
        Result.LongDayNames[3] = "Mittwoch";
        Result.LongDayNames[4] = "Donnerstag";
        Result.LongDayNames[5] = "Freitag";
        Result.LongDayNames[6] = "Samstag";
        Result.ShortDayNames[0] = "Son";
        Result.ShortDayNames[1] = "Mon";
        Result.ShortDayNames[2] = "Die";
        Result.ShortDayNames[3] = "Mit";
        Result.ShortDayNames[4] = "Don";
        Result.ShortDayNames[5] = "Fre";
        Result.ShortDayNames[6] = "Sam";
        Result.ShortMonthNames[0] = "Jan";
        Result.ShortMonthNames[1] = "Feb";
        Result.ShortMonthNames[2] = "Mär";
        Result.ShortMonthNames[3] = "Apr";
        Result.ShortMonthNames[4] = "Mai";
        Result.ShortMonthNames[5] = "Jun";
        Result.ShortMonthNames[6] = "Jul";
        Result.ShortMonthNames[7] = "Aug";
        Result.ShortMonthNames[8] = "Sep";
        Result.ShortMonthNames[9] = "Okt";
        Result.ShortMonthNames[10] = "Nov";
        Result.ShortMonthNames[11] = "Dez";
        Result.LongMonthNames[0] = "Januar";
        Result.LongMonthNames[1] = "Februar";
        Result.LongMonthNames[2] = "März";
        Result.LongMonthNames[3] = "April";
        Result.LongMonthNames[4] = "Mai";
        Result.LongMonthNames[5] = "Juni";
        Result.LongMonthNames[6] = "Juli";
        Result.LongMonthNames[7] = "August";
        Result.LongMonthNames[8] = "September";
        Result.LongMonthNames[9] = "Oktober";
        Result.LongMonthNames[10] = "November";
        Result.LongMonthNames[11] = "Dezember";
      } else if (pas.System.Pos("FR",$mod.UpperCase(ALocale)) === 1) {
        Result.LongDayNames[0] = "Dimanche";
        Result.LongDayNames[1] = "Lundi";
        Result.LongDayNames[2] = "Mardi";
        Result.LongDayNames[3] = "Mecredi";
        Result.LongDayNames[4] = "Jeudi";
        Result.LongDayNames[5] = "Vendredi";
        Result.LongDayNames[6] = "Samedi";
        Result.ShortDayNames[0] = "Dim";
        Result.ShortDayNames[1] = "Lun";
        Result.ShortDayNames[2] = "Mar";
        Result.ShortDayNames[3] = "Mer";
        Result.ShortDayNames[4] = "Jeu";
        Result.ShortDayNames[5] = "Ven";
        Result.ShortDayNames[6] = "Sam";
        Result.ShortMonthNames[0] = "Jan";
        Result.ShortMonthNames[1] = "Fév";
        Result.ShortMonthNames[2] = "Mar";
        Result.ShortMonthNames[3] = "Avr";
        Result.ShortMonthNames[4] = "Mai";
        Result.ShortMonthNames[5] = "Jun";
        Result.ShortMonthNames[6] = "Jul";
        Result.ShortMonthNames[7] = "Aoû";
        Result.ShortMonthNames[8] = "Sep";
        Result.ShortMonthNames[9] = "Oct";
        Result.ShortMonthNames[10] = "Nov";
        Result.ShortMonthNames[11] = "Déc";
        Result.LongMonthNames[0] = "Janvier";
        Result.LongMonthNames[1] = "Février";
        Result.LongMonthNames[2] = "Mars";
        Result.LongMonthNames[3] = "Avril";
        Result.LongMonthNames[4] = "Mai";
        Result.LongMonthNames[5] = "Juin";
        Result.LongMonthNames[6] = "Juillet";
        Result.LongMonthNames[7] = "Août";
        Result.LongMonthNames[8] = "Septembre";
        Result.LongMonthNames[9] = "Octobre";
        Result.LongMonthNames[10] = "Novembre";
        Result.LongMonthNames[11] = "Décembre";
      } else if (pas.System.Pos("ES",$mod.UpperCase(ALocale)) === 1) {
        Result.LongDayNames[0] = "Domingo";
        Result.LongDayNames[1] = "Lunes";
        Result.LongDayNames[2] = "Martes";
        Result.LongDayNames[3] = "Miércoles";
        Result.LongDayNames[4] = "Jueves";
        Result.LongDayNames[5] = "Viernes";
        Result.LongDayNames[6] = "Sábado";
        Result.ShortDayNames[0] = "Dom";
        Result.ShortDayNames[1] = "Lun";
        Result.ShortDayNames[2] = "Mar";
        Result.ShortDayNames[3] = "Mié";
        Result.ShortDayNames[4] = "Jue";
        Result.ShortDayNames[5] = "Vie";
        Result.ShortDayNames[6] = "Sáb";
        Result.ShortMonthNames[0] = "Ene";
        Result.ShortMonthNames[1] = "Feb";
        Result.ShortMonthNames[2] = "Mar";
        Result.ShortMonthNames[3] = "Abr";
        Result.ShortMonthNames[4] = "May";
        Result.ShortMonthNames[5] = "Jun";
        Result.ShortMonthNames[6] = "Jul";
        Result.ShortMonthNames[7] = "Ago";
        Result.ShortMonthNames[8] = "Sep";
        Result.ShortMonthNames[9] = "Oct";
        Result.ShortMonthNames[10] = "Nov";
        Result.ShortMonthNames[11] = "Dic";
        Result.LongMonthNames[0] = "January";
        Result.LongMonthNames[1] = "Febrero";
        Result.LongMonthNames[2] = "Marzi";
        Result.LongMonthNames[3] = "Abril";
        Result.LongMonthNames[4] = "Mayo";
        Result.LongMonthNames[5] = "Junio";
        Result.LongMonthNames[6] = "Julio";
        Result.LongMonthNames[7] = "Agusto";
        Result.LongMonthNames[8] = "Septiembre";
        Result.LongMonthNames[9] = "Octubre";
        Result.LongMonthNames[10] = "Noviembre";
        Result.LongMonthNames[11] = "Diciembre";
      } else {
        Result.LongDayNames[0] = "Sunday";
        Result.LongDayNames[1] = "Monday";
        Result.LongDayNames[2] = "Tuesday";
        Result.LongDayNames[3] = "Wednesday";
        Result.LongDayNames[4] = "Thursday";
        Result.LongDayNames[5] = "Friday";
        Result.LongDayNames[6] = "Saturday";
        Result.ShortDayNames[0] = "Sun";
        Result.ShortDayNames[1] = "Mon";
        Result.ShortDayNames[2] = "Tue";
        Result.ShortDayNames[3] = "Wed";
        Result.ShortDayNames[4] = "Thu";
        Result.ShortDayNames[5] = "Fri";
        Result.ShortDayNames[6] = "Sat";
        Result.ShortMonthNames[0] = "Jan";
        Result.ShortMonthNames[1] = "Feb";
        Result.ShortMonthNames[2] = "Mar";
        Result.ShortMonthNames[3] = "Apr";
        Result.ShortMonthNames[4] = "May";
        Result.ShortMonthNames[5] = "Jun";
        Result.ShortMonthNames[6] = "Jul";
        Result.ShortMonthNames[7] = "Aug";
        Result.ShortMonthNames[8] = "Sep";
        Result.ShortMonthNames[9] = "Oct";
        Result.ShortMonthNames[10] = "Nov";
        Result.ShortMonthNames[11] = "Dec";
        Result.LongMonthNames[0] = "January";
        Result.LongMonthNames[1] = "February";
        Result.LongMonthNames[2] = "March";
        Result.LongMonthNames[3] = "April";
        Result.LongMonthNames[4] = "May";
        Result.LongMonthNames[5] = "June";
        Result.LongMonthNames[6] = "July";
        Result.LongMonthNames[7] = "August";
        Result.LongMonthNames[8] = "September";
        Result.LongMonthNames[9] = "October";
        Result.LongMonthNames[10] = "November";
        Result.LongMonthNames[11] = "December";
      };
      Result.DateTimeToStrFormat[0] = "c";
      Result.DateTimeToStrFormat[1] = "f";
      Result.DateSeparator = "-";
      Result.TimeSeparator = ":";
      Result.ShortDateFormat = "yyyy-mm-dd";
      Result.LongDateFormat = "ddd, yyyy-mm-dd";
      Result.DecimalSeparator = ".";
      Result.ThousandSeparator = ",";
      Result.TimeAMString = "AM";
      Result.TimePMString = "PM";
      Result.TwoDigitYearCenturyWindow = 50;
      Result.ShortTimeFormat = $mod.TFormatSettings.GetLocaleShortTimeFormat(ALocale);
      Result.LongTimeFormat = $mod.TFormatSettings.GetLocaleLongTimeFormat(ALocale);
      Result.ShortDateFormat = $mod.TFormatSettings.GetLocaleShortDateFormat(ALocale);
      for (var $l = 0, $end = rtl.length(cDateSeps) - 1; $l <= $end; $l++) {
        lCount = $l;
        if ($mod.TStringHelper.IndexOf.call({p: Result, get: function () {
            return this.p.ShortDateFormat;
          }, set: function (v) {
            this.p.ShortDateFormat = v;
          }},cDateSeps[lCount]) >= 0) Result.DateSeparator = cDateSeps[lCount];
      };
      var lEvent = new Date('Jan 1, 1980 06:07:08 GMT+00:00');
      var lLoc1 = "";
      if (ALocale == "")
        lLoc1 = navigator.language;
      else
        lLoc1 = ALocale;
      lTimeStr = lEvent.toLocaleTimeString(lLoc1);
      for (var $l1 = 0, $end1 = rtl.length(cTimeSeps) - 1; $l1 <= $end1; $l1++) {
        lCount = $l1;
        if ($mod.TStringHelper.IndexOf.call({get: function () {
            return lTimeStr;
          }, set: function (v) {
            lTimeStr = v;
          }},cTimeSeps[lCount]) >= 0) Result.TimeSeparator = cTimeSeps[lCount];
      };
      for (lCount = 1; lCount <= 7; lCount++) Result.ShortDayNames[lCount - 1] = $mod.TFormatSettings.GetLocaleShortDayName(lCount,ALocale);
      for (lCount = 1; lCount <= 7; lCount++) Result.LongDayNames[lCount - 1] = $mod.TFormatSettings.GetLocaleLongDayName(lCount,ALocale);
      for (lCount = 1; lCount <= 12; lCount++) Result.ShortMonthNames[lCount - 1] = $mod.TFormatSettings.GetLocaleShortMonthName(lCount,ALocale);
      for (lCount = 1; lCount <= 12; lCount++) Result.LongMonthNames[lCount - 1] = $mod.TFormatSettings.GetLocaleLongMonthName(lCount,ALocale);
      Result.DecimalSeparator = $mod.TFormatSettings.GetLocaleDecimalSeparator(ALocale);
      for (var $l2 = 0, $end2 = rtl.length(cDecSeps) - 1; $l2 <= $end2; $l2++) {
        lCount = $l2;
        if (Result.DecimalSeparator === cDecSeps[lCount]) {
          Result.ThousandSeparator = cThousandSeps[lCount];
          break;
        };
      };
      if ($mod.TFormatSettings.InitLocaleHandler != null) $mod.TFormatSettings.InitLocaleHandler($mod.UpperCase(ALocale),$mod.TFormatSettings.$clone(Result));
      return Result;
    };
    this.Invariant = function () {
      var Result = $mod.TFormatSettings.$new();
      if (!$impl.FInvariantCreated) {
        $impl.FInvariant.$assign($mod.TFormatSettings.Create$1("EN-US"));
        $impl.FInvariant.CurrencyString = "¤";
        $impl.FInvariant.CurrencyFormat = 0;
        $impl.FInvariant.CurrencyDecimals = 2;
        $impl.FInvariant.DateSeparator = "/";
        $impl.FInvariant.TimeSeparator = ":";
        $impl.FInvariant.ShortDateFormat = "MM/dd/yyyy";
        $impl.FInvariant.LongDateFormat = "dddd, dd MMMMM yyyy HH:mm:ss";
        $impl.FInvariant.TimeAMString = "AM";
        $impl.FInvariant.TimePMString = "PM";
        $impl.FInvariant.ShortTimeFormat = "HH:mm";
        $impl.FInvariant.LongTimeFormat = "HH:mm:ss";
        $impl.FInvariant.ShortMonthNames = $impl.DefaultShortMonthNames.slice(0);
        $impl.FInvariant.LongMonthNames = $impl.DefaultLongMonthNames.slice(0);
        $impl.FInvariant.ShortDayNames = $impl.DefaultShortDayNames.slice(0);
        $impl.FInvariant.LongDayNames = $impl.DefaultLongDayNames.slice(0);
        $impl.FInvariant.ThousandSeparator = ",";
        $impl.FInvariant.DecimalSeparator = ".";
        $impl.FInvariant.TwoDigitYearCenturyWindow = 50;
        $impl.FInvariant.NegCurrFormat = 0;
        $impl.FInvariantCreated = true;
      };
      Result.$assign($impl.FInvariant);
      return Result;
    };
    var $r = $mod.$rtti.$Record("TFormatSettings",{});
    $r.addField("CurrencyDecimals",rtl.byte);
    $r.addField("CurrencyFormat",rtl.byte);
    $r.addField("CurrencyString",rtl.string);
    $r.addField("DateSeparator",rtl.char);
    $mod.$rtti.$StaticArray("TFormatSettings.DateTimeToStrFormat$a",{dims: [2], eltype: rtl.string});
    $r.addField("DateTimeToStrFormat",$mod.$rtti["TFormatSettings.DateTimeToStrFormat$a"]);
    $r.addField("DecimalSeparator",rtl.string);
    $r.addField("LongDateFormat",rtl.string);
    $r.addField("LongDayNames",$mod.$rtti["TDayNames"]);
    $r.addField("LongMonthNames",$mod.$rtti["TMonthNameArray"]);
    $r.addField("LongTimeFormat",rtl.string);
    $r.addField("NegCurrFormat",rtl.byte);
    $r.addField("ShortDateFormat",rtl.string);
    $r.addField("ShortDayNames",$mod.$rtti["TDayNames"]);
    $r.addField("ShortMonthNames",$mod.$rtti["TMonthNameArray"]);
    $r.addField("ShortTimeFormat",rtl.string);
    $r.addField("ThousandSeparator",rtl.string);
    $r.addField("TimeAMString",rtl.string);
    $r.addField("TimePMString",rtl.string);
    $r.addField("TimeSeparator",rtl.char);
    $r.addField("TwoDigitYearCenturyWindow",rtl.word);
    $r.addField("InitLocaleHandler",$mod.$rtti["TFormatSettings.TLocaleInitCallback"]);
    $r.addMethod("Create",5,[],$r,1);
    $r.addMethod("Create$1",5,[["ALocale",rtl.string,2]],$r,1);
    $r.addMethod("Invariant",5,[],$r,1);
  },true);
  rtl.createClass(this,"Exception",pas.System.TObject,function () {
    this.LogMessageOnCreate = false;
    this.$init = function () {
      pas.System.TObject.$init.call(this);
      this.FMessage = "";
      this.FHelpContext = 0;
      this.FJSError = null;
      this.FStack = undefined;
    };
    this.$final = function () {
      this.FJSError = undefined;
      pas.System.TObject.$final.call(this);
    };
    this.Create$1 = function (Msg) {
      this.FMessage = Msg;
      this.FJSError = new Error(Msg);
      this.FStack = this.FJSError.stack;
      this.FHelpContext = 0;
      if (this.LogMessageOnCreate) pas.System.Writeln("Created exception ",this.$classname," with message: ",Msg);
      return this;
    };
    this.CreateFmt = function (Msg, Args) {
      this.Create$1($mod.Format(Msg,Args));
      return this;
    };
    this.CreateHelp = function (Msg, AHelpContext) {
      this.Create$1(Msg);
      this.FHelpContext = AHelpContext;
      return this;
    };
    this.CreateFmtHelp = function (Msg, Args, AHelpContext) {
      this.Create$1($mod.Format(Msg,Args));
      this.FHelpContext = AHelpContext;
      return this;
    };
    this.ToString = function () {
      var Result = "";
      Result = this.$classname + ": " + this.FMessage;
      return Result;
    };
  });
  this.$rtti.$ClassRef("ExceptClass",{instancetype: this.$rtti["Exception"]});
  rtl.createClass(this,"EExternal",this.Exception,function () {
  });
  rtl.createClass(this,"EMathError",this.EExternal,function () {
  });
  rtl.createClass(this,"EInvalidOp",this.EMathError,function () {
  });
  rtl.createClass(this,"EZeroDivide",this.EMathError,function () {
  });
  rtl.createClass(this,"EOverflow",this.EMathError,function () {
  });
  rtl.createClass(this,"EUnderflow",this.EMathError,function () {
  });
  rtl.createClass(this,"EAbort",this.Exception,function () {
  });
  rtl.createClass(this,"EInvalidCast",this.Exception,function () {
  });
  rtl.createClass(this,"EAssertionFailed",this.Exception,function () {
  });
  rtl.createClass(this,"EObjectCheck",this.Exception,function () {
  });
  rtl.createClass(this,"EConvertError",this.Exception,function () {
  });
  rtl.createClass(this,"EFormatError",this.Exception,function () {
  });
  rtl.createClass(this,"EIntError",this.EExternal,function () {
  });
  rtl.createClass(this,"EDivByZero",this.EIntError,function () {
  });
  rtl.createClass(this,"ERangeError",this.EIntError,function () {
  });
  rtl.createClass(this,"EIntOverflow",this.EIntError,function () {
  });
  rtl.createClass(this,"EInOutError",this.Exception,function () {
    this.$init = function () {
      $mod.Exception.$init.call(this);
      this.ErrorCode = 0;
    };
  });
  rtl.createClass(this,"EHeapMemoryError",this.Exception,function () {
  });
  rtl.createClass(this,"EExternalException",this.EExternal,function () {
  });
  rtl.createClass(this,"EInvalidPointer",this.EHeapMemoryError,function () {
  });
  rtl.createClass(this,"EOutOfMemory",this.EHeapMemoryError,function () {
  });
  rtl.createClass(this,"EVariantError",this.Exception,function () {
    this.$init = function () {
      $mod.Exception.$init.call(this);
      this.ErrCode = 0;
    };
    this.CreateCode = function (Code) {
      this.ErrCode = Code;
      return this;
    };
  });
  rtl.createClass(this,"EAccessViolation",this.EExternal,function () {
  });
  rtl.createClass(this,"EBusError",this.EAccessViolation,function () {
  });
  rtl.createClass(this,"EPrivilege",this.EExternal,function () {
  });
  rtl.createClass(this,"EStackOverflow",this.EExternal,function () {
  });
  rtl.createClass(this,"EControlC",this.EExternal,function () {
  });
  rtl.createClass(this,"EAbstractError",this.Exception,function () {
  });
  rtl.createClass(this,"EPropReadOnly",this.Exception,function () {
  });
  rtl.createClass(this,"EPropWriteOnly",this.Exception,function () {
  });
  rtl.createClass(this,"EIntfCastError",this.Exception,function () {
  });
  rtl.createClass(this,"EInvalidContainer",this.Exception,function () {
  });
  rtl.createClass(this,"EInvalidInsert",this.Exception,function () {
  });
  rtl.createClass(this,"EPackageError",this.Exception,function () {
  });
  rtl.createClass(this,"EOSError",this.Exception,function () {
    this.$init = function () {
      $mod.Exception.$init.call(this);
      this.ErrorCode = 0;
    };
  });
  rtl.createClass(this,"ESafecallException",this.Exception,function () {
  });
  rtl.createClass(this,"ENoThreadSupport",this.Exception,function () {
  });
  rtl.createClass(this,"ENoWideStringSupport",this.Exception,function () {
  });
  rtl.createClass(this,"ENotImplemented",this.Exception,function () {
  });
  rtl.createClass(this,"EArgumentException",this.Exception,function () {
  });
  rtl.createClass(this,"EArgumentOutOfRangeException",this.EArgumentException,function () {
  });
  rtl.createClass(this,"EArgumentNilException",this.EArgumentException,function () {
  });
  rtl.createClass(this,"EPathTooLongException",this.Exception,function () {
  });
  rtl.createClass(this,"ENotSupportedException",this.Exception,function () {
  });
  rtl.createClass(this,"EDirectoryNotFoundException",this.Exception,function () {
  });
  rtl.createClass(this,"EFileNotFoundException",this.Exception,function () {
  });
  rtl.createClass(this,"EPathNotFoundException",this.Exception,function () {
  });
  rtl.createClass(this,"ENoConstructException",this.Exception,function () {
  });
  this.EmptyStr = "";
  this.EmptyWideStr = "";
  this.HexDisplayPrefix = "$";
  this.LeadBytes = {};
  this.CharInSet = function (Ch, CSet) {
    var Result = false;
    var I = 0;
    Result = false;
    I = rtl.length(CSet) - 1;
    while (!Result && (I >= 0)) {
      Result = Ch === CSet[I];
      I -= 1;
    };
    return Result;
  };
  this.CharInSet$1 = function (Ch, CSet) {
    var Result = false;
    Result = Ch.charCodeAt() in CSet;
    return Result;
  };
  this.LeftStr = function (S, Count) {
    return (Count>0) ? S.substr(0,Count) : "";
  };
  this.RightStr = function (S, Count) {
    var l = S.length;
    return (Count<1) ? "" : ( Count>=l ? S : S.substr(l-Count));
  };
  this.Trim = function (S) {
    return S.replace(/^[\s\uFEFF\xA0\x00-\x1f]+/,'').replace(/[\s\uFEFF\xA0\x00-\x1f]+$/,'');
  };
  this.TrimLeft = function (S) {
    return S.replace(/^[\s\uFEFF\xA0\x00-\x1f]+/,'');
  };
  this.TrimRight = function (S) {
    return S.replace(/[\s\uFEFF\xA0\x00-\x1f]+$/,'');
  };
  this.UpperCase = function (s) {
    return s.toUpperCase();
  };
  this.LowerCase = function (s) {
    return s.toLowerCase();
  };
  this.CompareStr = function (s1, s2) {
    var l1 = s1.length;
    var l2 = s2.length;
    if (l1<=l2){
      var s = s2.substr(0,l1);
      if (s1<s){ return -1;
      } else if (s1>s){ return 1;
      } else { return l1<l2 ? -1 : 0; };
    } else {
      var s = s1.substr(0,l2);
      if (s<s2){ return -1;
      } else { return 1; };
    };
  };
  this.SameStr = function (s1, s2) {
    return s1 == s2;
  };
  this.CompareText = function (s1, s2) {
    var l1 = s1.toLowerCase();
    var l2 = s2.toLowerCase();
    if (l1>l2){ return 1;
    } else if (l1<l2){ return -1;
    } else { return 0; };
  };
  this.SameText = function (s1, s2) {
    return s1.toLowerCase() == s2.toLowerCase();
  };
  this.AnsiCompareText = function (s1, s2) {
    return s1.localeCompare(s2);
  };
  this.AnsiSameText = function (s1, s2) {
    return s1.toLowerCase() == s2.toLowerCase();
  };
  this.AnsiCompareStr = function (s1, s2) {
    var Result = 0;
    Result = $mod.CompareText(s1,s2);
    return Result;
  };
  this.AppendStr = function (Dest, S) {
    Dest.set(Dest.get() + S);
  };
  this.Format = function (Fmt, Args) {
    var Result = "";
    Result = $mod.Format$1(Fmt,Args,$mod.FormatSettings);
    return Result;
  };
  this.Format$1 = function (Fmt, Args, aSettings) {
    var Result = "";
    var ChPos = 0;
    var OldPos = 0;
    var ArgPos = 0;
    var DoArg = 0;
    var Len = 0;
    var Hs = "";
    var ToAdd = "";
    var Index = 0;
    var Width = 0;
    var Prec = 0;
    var Left = false;
    var Fchar = "\x00";
    var vq = 0;
    function ReadFormat() {
      var Result = "\x00";
      var Value = 0;
      function ReadInteger() {
        var Code = 0;
        var ArgN = 0;
        if (Value !== -1) return;
        OldPos = ChPos;
        while ((ChPos <= Len) && (Fmt.charAt(ChPos - 1) <= "9") && (Fmt.charAt(ChPos - 1) >= "0")) ChPos += 1;
        if (ChPos > Len) $impl.DoFormatError(1,Fmt);
        if (Fmt.charAt(ChPos - 1) === "*") {
          if (Index === 255) {
            ArgN = ArgPos}
           else {
            ArgN = Index;
            Index += 1;
          };
          if ((ChPos > OldPos) || (ArgN > (rtl.length(Args) - 1))) $impl.DoFormatError(1,Fmt);
          ArgPos = ArgN + 1;
          var $tmp = Args[ArgN].VType;
          if ($tmp === 0) {
            Value = Args[ArgN].VJSValue}
           else if ($tmp === 19) {
            Value = Args[ArgN].VJSValue}
           else {
            $impl.DoFormatError(1,Fmt);
          };
          ChPos += 1;
        } else {
          if (OldPos < ChPos) {
            pas.System.val(pas.System.Copy(Fmt,OldPos,ChPos - OldPos),{get: function () {
                return Value;
              }, set: function (v) {
                Value = v;
              }},{get: function () {
                return Code;
              }, set: function (v) {
                Code = v;
              }});
            if (Code > 0) $impl.DoFormatError(1,Fmt);
          } else Value = -1;
        };
      };
      function ReadIndex() {
        if (Fmt.charAt(ChPos - 1) !== ":") {
          ReadInteger()}
         else Value = 0;
        if (Fmt.charAt(ChPos - 1) === ":") {
          if (Value === -1) $impl.DoFormatError(2,Fmt);
          Index = Value;
          Value = -1;
          ChPos += 1;
        };
      };
      function ReadLeft() {
        if (Fmt.charAt(ChPos - 1) === "-") {
          Left = true;
          ChPos += 1;
        } else Left = false;
      };
      function ReadWidth() {
        ReadInteger();
        if (Value !== -1) {
          Width = Value;
          Value = -1;
        };
      };
      function ReadPrec() {
        if (Fmt.charAt(ChPos - 1) === ".") {
          ChPos += 1;
          ReadInteger();
          if (Value === -1) Value = 0;
          Prec = Value;
        };
      };
      Index = 255;
      Width = -1;
      Prec = -1;
      Value = -1;
      ChPos += 1;
      if (Fmt.charAt(ChPos - 1) === "%") {
        Result = "%";
        return Result;
      };
      ReadIndex();
      ReadLeft();
      ReadWidth();
      ReadPrec();
      Result = pas.System.upcase(Fmt.charAt(ChPos - 1));
      return Result;
    };
    function Checkarg(AT, err) {
      var Result = false;
      Result = false;
      if (Index === 255) {
        DoArg = ArgPos}
       else DoArg = Index;
      ArgPos = DoArg + 1;
      if ((DoArg > (rtl.length(Args) - 1)) || (Args[DoArg].VType !== AT)) {
        if (err) $impl.DoFormatError(3,Fmt);
        ArgPos -= 1;
        return Result;
      };
      Result = true;
      return Result;
    };
    Result = "";
    Len = Fmt.length;
    ChPos = 1;
    OldPos = 1;
    ArgPos = 0;
    while (ChPos <= Len) {
      while ((ChPos <= Len) && (Fmt.charAt(ChPos - 1) !== "%")) ChPos += 1;
      if (ChPos > OldPos) Result = Result + pas.System.Copy(Fmt,OldPos,ChPos - OldPos);
      if (ChPos < Len) {
        Fchar = ReadFormat();
        var $tmp = Fchar;
        if ($tmp === "D") {
          if (Checkarg(0,false)) {
            ToAdd = $mod.IntToStr(Args[DoArg].VJSValue)}
           else if (Checkarg(19,true)) ToAdd = $mod.IntToStr(Args[DoArg].VJSValue);
          Width = Math.abs(Width);
          Index = Prec - ToAdd.length;
          if (ToAdd.charAt(0) !== "-") {
            ToAdd = pas.System.StringOfChar("0",Index) + ToAdd}
           else pas.System.Insert(pas.System.StringOfChar("0",Index + 1),{get: function () {
              return ToAdd;
            }, set: function (v) {
              ToAdd = v;
            }},2);
        } else if ($tmp === "U") {
          if (Checkarg(0,false)) {
            ToAdd = $mod.IntToStr(Args[DoArg].VJSValue >>> 0)}
           else if (Checkarg(19,true)) ToAdd = $mod.IntToStr(Args[DoArg].VJSValue);
          Width = Math.abs(Width);
          Index = Prec - ToAdd.length;
          ToAdd = pas.System.StringOfChar("0",Index) + ToAdd;
        } else if ($tmp === "E") {
          if (Checkarg(12,false)) {
            ToAdd = $mod.FloatToStrF$1(Args[DoArg].VJSValue / 10000,$mod.TFloatFormat.ffExponent,3,Prec,aSettings)}
           else if (Checkarg(3,true)) ToAdd = $mod.FloatToStrF$1(Args[DoArg].VJSValue,$mod.TFloatFormat.ffExponent,3,Prec,aSettings);
        } else if ($tmp === "F") {
          if (Checkarg(12,false)) {
            ToAdd = $mod.FloatToStrF$1(Args[DoArg].VJSValue / 10000,$mod.TFloatFormat.ffFixed,9999,Prec,aSettings)}
           else if (Checkarg(0,false)) {
            ToAdd = $mod.FloatToStrF$1(Args[DoArg].VJSValue,$mod.TFloatFormat.ffFixed,9999,Prec,aSettings)}
           else if (Checkarg(3,true)) ToAdd = $mod.FloatToStrF$1(Args[DoArg].VJSValue,$mod.TFloatFormat.ffFixed,9999,Prec,aSettings);
        } else if ($tmp === "G") {
          if (Checkarg(12,false)) {
            ToAdd = $mod.FloatToStrF$1(Args[DoArg].VJSValue / 10000,$mod.TFloatFormat.ffGeneral,Prec,3,aSettings)}
           else if (Checkarg(3,true)) ToAdd = $mod.FloatToStrF$1(Args[DoArg].VJSValue,$mod.TFloatFormat.ffGeneral,Prec,3,aSettings);
        } else if ($tmp === "N") {
          if (Checkarg(12,false)) {
            ToAdd = $mod.FloatToStrF$1(Args[DoArg].VJSValue / 10000,$mod.TFloatFormat.ffNumber,9999,Prec,aSettings)}
           else if (Checkarg(3,true)) ToAdd = $mod.FloatToStrF$1(Args[DoArg].VJSValue,$mod.TFloatFormat.ffNumber,9999,Prec,aSettings);
        } else if ($tmp === "M") {
          if (Checkarg(12,false)) {
            ToAdd = $mod.FloatToStrF$1(Args[DoArg].VJSValue / 10000,$mod.TFloatFormat.ffCurrency,9999,Prec,aSettings)}
           else if (Checkarg(3,true)) ToAdd = $mod.FloatToStrF$1(Args[DoArg].VJSValue,$mod.TFloatFormat.ffCurrency,9999,Prec,aSettings);
        } else if ($tmp === "S") {
          if (Checkarg(18,false)) {
            Hs = Args[DoArg].VJSValue}
           else if (Checkarg(9,true)) Hs = Args[DoArg].VJSValue;
          Index = Hs.length;
          if ((Prec !== -1) && (Index > Prec)) Index = Prec;
          ToAdd = pas.System.Copy(Hs,1,Index);
        } else if ($tmp === "P") {
          if (Checkarg(0,false)) {
            ToAdd = $mod.IntToHex(Args[DoArg].VJSValue,8)}
           else if (Checkarg(0,true)) ToAdd = $mod.IntToHex(Args[DoArg].VJSValue,16);
        } else if ($tmp === "X") {
          if (Checkarg(0,false)) {
            vq = Args[DoArg].VJSValue;
            Index = 16;
          } else if (Checkarg(19,true)) {
            vq = Args[DoArg].VJSValue;
            Index = 31;
          };
          if (Prec > Index) {
            ToAdd = $mod.IntToHex(vq,Index)}
           else {
            Index = 1;
            while ((rtl.shl(1,Index * 4) <= vq) && (Index < 16)) Index += 1;
            if (Index > Prec) Prec = Index;
            ToAdd = $mod.IntToHex(vq,Prec);
          };
        } else if ($tmp === "%") ToAdd = "%";
        if (Width !== -1) if (ToAdd.length < Width) if (!Left) {
          ToAdd = pas.System.StringOfChar(" ",Width - ToAdd.length) + ToAdd}
         else ToAdd = ToAdd + pas.System.StringOfChar(" ",Width - ToAdd.length);
        Result = Result + ToAdd;
      };
      ChPos += 1;
      OldPos = ChPos;
    };
    return Result;
  };
  this.BytesOf = function (AVal) {
    var Result = [];
    var I = 0;
    Result = rtl.arraySetLength(Result,0,AVal.length);
    for (var $l = 0, $end = AVal.length - 1; $l <= $end; $l++) {
      I = $l;
      Result[I] = AVal.charCodeAt((I + 1) - 1);
    };
    return Result;
  };
  this.StringOf = function (ABytes) {
    var Result = "";
    var I = 0;
    Result = "";
    for (var $l = 0, $end = rtl.length(ABytes) - 1; $l <= $end; $l++) {
      I = $l;
      Result = Result + String.fromCharCode(ABytes[I]);
    };
    return Result;
  };
  this.LocaleCompare = function (s1, s2, locales) {
    return s1.localeCompare(s2,locales) == 0;
  };
  this.NormalizeStr = function (S, Norm) {
    return S.normalize(Norm);
  };
  var Alpha = rtl.createSet(null,65,90,null,97,122,95);
  var AlphaNum = rtl.unionSet(Alpha,rtl.createSet(null,48,57));
  var Dot = ".";
  this.IsValidIdent = function (Ident, AllowDots, StrictDots) {
    var Result = false;
    var First = false;
    var I = 0;
    var Len = 0;
    Len = Ident.length;
    if (Len < 1) return false;
    First = true;
    Result = false;
    I = 1;
    while (I <= Len) {
      if (First) {
        if (!(Ident.charCodeAt(I - 1) in Alpha)) return Result;
        First = false;
      } else if (AllowDots && (Ident.charAt(I - 1) === Dot)) {
        if (StrictDots) {
          if (I >= Len) return Result;
          First = true;
        };
      } else if (!(Ident.charCodeAt(I - 1) in AlphaNum)) return Result;
      I = I + 1;
    };
    Result = true;
    return Result;
  };
  this.TStringReplaceFlag = {"0": "rfReplaceAll", rfReplaceAll: 0, "1": "rfIgnoreCase", rfIgnoreCase: 1};
  this.$rtti.$Enum("TStringReplaceFlag",{minvalue: 0, maxvalue: 1, ordtype: 1, enumtype: this.TStringReplaceFlag});
  this.$rtti.$Set("TStringReplaceFlags",{comptype: this.$rtti["TStringReplaceFlag"]});
  this.Randomize = function () {
  };
  this.StringReplace = function (aOriginal, aSearch, aReplace, Flags) {
    var Result = "";
    var REFlags = "";
    var REString = "";
    REFlags = "";
    if ($mod.TStringReplaceFlag.rfReplaceAll in Flags) REFlags = "g";
    if ($mod.TStringReplaceFlag.rfIgnoreCase in Flags) REFlags = REFlags + "i";
    REString = aSearch.replace(new RegExp($impl.RESpecials,"g"),"\\$1");
    Result = aOriginal.replace(new RegExp(REString,REFlags),aReplace);
    return Result;
  };
  this.QuoteString = function (aOriginal, AQuote) {
    var Result = "";
    Result = AQuote + $mod.StringReplace(aOriginal,AQuote,AQuote + AQuote,rtl.createSet($mod.TStringReplaceFlag.rfReplaceAll)) + AQuote;
    return Result;
  };
  this.QuotedStr = function (s, QuoteChar) {
    var Result = "";
    Result = $mod.QuoteString(s,QuoteChar);
    return Result;
  };
  this.DeQuoteString = function (aQuoted, AQuote) {
    var Result = "";
    var i = 0;
    Result = aQuoted;
    if (Result.substr(0,1) !== AQuote) return Result;
    Result = Result.slice(1);
    i = 1;
    while (i <= Result.length) {
      if (Result.charAt(i - 1) === AQuote) {
        if ((i === Result.length) || (Result.charAt((i + 1) - 1) !== AQuote)) {
          Result = Result.slice(0,i - 1);
          return Result;
        } else Result = Result.slice(0,i - 1) + Result.slice(i);
      } else i += 1;
    };
    return Result;
  };
  this.LastDelimiter = function (Delimiters, S) {
    var Result = 0;
    Result = S.length;
    while ((Result > 0) && (pas.System.Pos(S.charAt(Result - 1),Delimiters) === 0)) Result -= 1;
    return Result;
  };
  this.IsDelimiter = function (Delimiters, S, Index) {
    var Result = false;
    Result = false;
    if ((Index > 0) && (Index <= S.length)) Result = pas.System.Pos(S.charAt(Index - 1),Delimiters) !== 0;
    return Result;
  };
  this.AdjustLineBreaks = function (S) {
    var Result = "";
    Result = $mod.AdjustLineBreaks$1(S,pas.System.DefaultTextLineBreakStyle);
    return Result;
  };
  this.AdjustLineBreaks$1 = function (S, Style) {
    var Result = "";
    var I = 0;
    var L = 0;
    var Res = "";
    function Add(C) {
      Res = Res + C;
    };
    I = 0;
    L = S.length;
    Result = "";
    while (I <= L) {
      var $tmp = S.charAt(I - 1);
      if ($tmp === "\n") {
        if (Style in rtl.createSet(pas.System.TTextLineBreakStyle.tlbsCRLF,pas.System.TTextLineBreakStyle.tlbsCR)) Add("\r");
        if (Style === pas.System.TTextLineBreakStyle.tlbsCRLF) Add("\n");
        I += 1;
      } else if ($tmp === "\r") {
        if (Style === pas.System.TTextLineBreakStyle.tlbsCRLF) Add("\r");
        Add("\n");
        I += 1;
        if (S.charAt(I - 1) === "\n") I += 1;
      } else {
        Add(S.charAt(I - 1));
        I += 1;
      };
    };
    Result = Res;
    return Result;
  };
  var Quotes = rtl.createSet(39,34);
  this.WrapText = function (Line, BreakStr, BreakChars, MaxCol) {
    var Result = "";
    var L = "";
    var C = "\x00";
    var LQ = "\x00";
    var BC = "\x00";
    var P = 0;
    var BLen = 0;
    var Len = 0;
    var HB = false;
    var IBC = false;
    Result = "";
    L = Line;
    BLen = BreakStr.length;
    if (BLen > 0) {
      BC = BreakStr.charAt(0)}
     else BC = "\x00";
    Len = L.length;
    while (Len > 0) {
      P = 1;
      LQ = "\x00";
      HB = false;
      IBC = false;
      while ((P <= Len) && ((P <= MaxCol) || !IBC) && ((LQ !== "\x00") || !HB)) {
        C = L.charAt(P - 1);
        if (C === LQ) {
          LQ = "\x00"}
         else if (C.charCodeAt() in Quotes) LQ = C;
        if (LQ !== "\x00") {
          P += 1}
         else {
          HB = (C === BC) && (BreakStr === pas.System.Copy(L,P,BLen));
          if (HB) {
            P += BLen}
           else {
            if (P >= MaxCol) IBC = $mod.CharInSet(C,BreakChars);
            P += 1;
          };
        };
      };
      Result = Result + pas.System.Copy(L,1,P - 1);
      pas.System.Delete({get: function () {
          return L;
        }, set: function (v) {
          L = v;
        }},1,P - 1);
      Len = L.length;
      if ((Len > 0) && !HB) Result = Result + BreakStr;
    };
    return Result;
  };
  this.WrapText$1 = function (Line, MaxCol) {
    var Result = "";
    Result = $mod.WrapText(Line,pas.System.sLineBreak,[" ","-","\t"],MaxCol);
    return Result;
  };
  this.SwapEndian = function (W) {
    var Result = 0;
    Result = ((W & 0xFF) << 8) | ((W >>> 8) & 0xFF);
    return Result;
  };
  this.SwapEndian$1 = function (C) {
    var Result = 0;
    Result = rtl.lw(rtl.lw(rtl.lw(rtl.lw((C & 0xFF) << 24) | rtl.lw((C & 0xFF00) << 8)) | (rtl.lw(C >>> 8) & 0xFF00)) | (rtl.lw(C >>> 24) & 0xFF));
    return Result;
  };
  this.IntToStr = function (Value) {
    var Result = "";
    Result = "" + Value;
    return Result;
  };
  this.TryStrToInt = function (S, res) {
    var Result = false;
    Result = $mod.TryStrToInt$1(S,res,$mod.FormatSettings);
    return Result;
  };
  this.TryStrToInt$1 = function (S, res, aSettings) {
    var Result = false;
    var NI = 0;
    Result = $mod.TryStrToInt$3(S,{get: function () {
        return NI;
      }, set: function (v) {
        NI = v;
      }},aSettings);
    Result = Result && (-2147483648 <= NI) && (NI <= 2147483647);
    if (Result) res.set(NI);
    return Result;
  };
  this.TryStrToInt$2 = function (S, res) {
    var Result = false;
    Result = $impl.IntTryStrToInt(S,res,$mod.FormatSettings.DecimalSeparator);
    return Result;
  };
  this.TryStrToInt$3 = function (S, res, aSettings) {
    var Result = false;
    Result = $impl.IntTryStrToInt(S,res,aSettings.DecimalSeparator);
    return Result;
  };
  this.StrToIntDef = function (S, aDef) {
    var Result = 0;
    var R = 0;
    if ($mod.TryStrToInt$2(S,{get: function () {
        return R;
      }, set: function (v) {
        R = v;
      }})) {
      Result = R}
     else Result = aDef;
    return Result;
  };
  this.StrToIntDef$1 = function (S, aDef) {
    var Result = 0;
    var R = 0;
    if ($mod.TryStrToInt$2(S,{get: function () {
        return R;
      }, set: function (v) {
        R = v;
      }})) {
      Result = R}
     else Result = aDef;
    return Result;
  };
  this.StrToInt = function (S) {
    var Result = 0;
    var R = 0;
    if (!$mod.TryStrToInt$2(S,{get: function () {
        return R;
      }, set: function (v) {
        R = v;
      }})) throw $mod.EConvertError.$create("CreateFmt",[rtl.getResStr(pas.RTLConsts,"SErrInvalidInteger"),pas.System.VarRecs(18,S)]);
    Result = R;
    return Result;
  };
  this.StrToNativeInt = function (S) {
    var Result = 0;
    if (!$mod.TryStrToInt$2(S,{get: function () {
        return Result;
      }, set: function (v) {
        Result = v;
      }})) throw $mod.EConvertError.$create("CreateFmt",[rtl.getResStr(pas.RTLConsts,"SErrInvalidInteger"),pas.System.VarRecs(18,S)]);
    return Result;
  };
  this.StrToUInt = function (s) {
    var Result = 0;
    if (!$mod.TryStrToUInt(s,{get: function () {
        return Result;
      }, set: function (v) {
        Result = v;
      }})) throw $mod.EConvertError.$create("CreateFmt",[rtl.getResStr(pas.RTLConsts,"SErrInvalidInteger"),pas.System.VarRecs(18,s)]);
    return Result;
  };
  this.StrToUIntDef = function (s, aDef) {
    var Result = 0;
    if (!$mod.TryStrToUInt(s,{get: function () {
        return Result;
      }, set: function (v) {
        Result = v;
      }})) Result = aDef;
    return Result;
  };
  this.UIntToStr = function (Value) {
    var Result = "";
    Result = $mod.IntToStr(Value);
    return Result;
  };
  this.TryStrToUInt = function (s, C) {
    var Result = false;
    var N = 0;
    Result = $mod.TryStrToInt$2(s,{get: function () {
        return N;
      }, set: function (v) {
        N = v;
      }});
    Result = (N >= 0) && (N <= 4294967295);
    if (Result) C.set(N);
    return Result;
  };
  this.StrToInt64 = function (S) {
    var Result = 0;
    var N = 0;
    if (!$mod.TryStrToInt$2(S,{get: function () {
        return N;
      }, set: function (v) {
        N = v;
      }})) throw $mod.EConvertError.$create("CreateFmt",[rtl.getResStr(pas.RTLConsts,"SErrInvalidInteger"),pas.System.VarRecs(18,S)]);
    Result = N;
    return Result;
  };
  this.StrToInt64Def = function (S, ADefault) {
    var Result = 0;
    if (!$mod.TryStrToInt64(S,{get: function () {
        return Result;
      }, set: function (v) {
        Result = v;
      }})) Result = ADefault;
    return Result;
  };
  this.TryStrToInt64 = function (S, res) {
    var Result = false;
    Result = $mod.TryStrToInt64$1(S,res,$mod.FormatSettings);
    return Result;
  };
  this.TryStrToInt64$1 = function (S, res, ASettings) {
    var Result = false;
    var R = 0;
    Result = $mod.TryStrToInt$3(S,{get: function () {
        return R;
      }, set: function (v) {
        R = v;
      }},ASettings);
    if (Result) res.set(R);
    return Result;
  };
  this.StrToQWord = function (S) {
    var Result = 0;
    var N = 0;
    if (!$mod.TryStrToInt$2(S,{get: function () {
        return N;
      }, set: function (v) {
        N = v;
      }}) || (N < 0)) throw $mod.EConvertError.$create("CreateFmt",[rtl.getResStr(pas.RTLConsts,"SErrInvalidInteger"),pas.System.VarRecs(18,S)]);
    Result = N;
    return Result;
  };
  this.StrToQWordDef = function (S, ADefault) {
    var Result = 0;
    if (!$mod.TryStrToQWord(S,{get: function () {
        return Result;
      }, set: function (v) {
        Result = v;
      }})) Result = ADefault;
    return Result;
  };
  this.TryStrToQWord = function (S, res) {
    var Result = false;
    var R = 0;
    Result = $mod.TryStrToInt$2(S,{get: function () {
        return R;
      }, set: function (v) {
        R = v;
      }}) && (R >= 0);
    if (Result) res.set(R);
    return Result;
  };
  this.TryStrToQWord$1 = function (S, res) {
    var Result = false;
    Result = $mod.TryStrToQWord(S,res);
    return Result;
  };
  this.StrToUInt64 = function (S) {
    var Result = 0;
    var N = 0;
    if (!$mod.TryStrToInt$2(S,{get: function () {
        return N;
      }, set: function (v) {
        N = v;
      }}) || (N < 0)) throw $mod.EConvertError.$create("CreateFmt",[rtl.getResStr(pas.RTLConsts,"SErrInvalidInteger"),pas.System.VarRecs(18,S)]);
    Result = N;
    return Result;
  };
  this.StrToUInt64Def = function (S, ADefault) {
    var Result = 0;
    if (!$mod.TryStrToUInt64(S,{get: function () {
        return Result;
      }, set: function (v) {
        Result = v;
      }})) Result = ADefault;
    return Result;
  };
  this.TryStrToUInt64 = function (S, res) {
    var Result = false;
    var R = 0;
    Result = $mod.TryStrToInt$2(S,{get: function () {
        return R;
      }, set: function (v) {
        R = v;
      }}) && (R >= 0);
    if (Result) res.set(R);
    return Result;
  };
  this.TryStrToUInt64$1 = function (S, res) {
    var Result = false;
    Result = $mod.TryStrToUInt64(S,res);
    return Result;
  };
  this.StrToDWord = function (S) {
    var Result = 0;
    if (!$mod.TryStrToDWord(S,{get: function () {
        return Result;
      }, set: function (v) {
        Result = v;
      }})) throw $mod.EConvertError.$create("CreateFmt",[rtl.getResStr(pas.RTLConsts,"SErrInvalidInteger"),pas.System.VarRecs(18,S)]);
    return Result;
  };
  this.StrToDWordDef = function (S, ADefault) {
    var Result = 0;
    if (!$mod.TryStrToDWord(S,{get: function () {
        return Result;
      }, set: function (v) {
        Result = v;
      }})) Result = ADefault;
    return Result;
  };
  this.TryStrToDWord = function (S, res) {
    var Result = false;
    var R = 0;
    Result = $mod.TryStrToInt$2(S,{get: function () {
        return R;
      }, set: function (v) {
        R = v;
      }}) && (R >= 0) && (R <= 0xFFFFFFFF);
    if (Result) res.set(R);
    return Result;
  };
  this.IntToHex = function (Value, Digits) {
    var Result = "";
    Result = "";
    if (Value < 0) if (Value<0) Value = 0xFFFFFFFF + Value + 1;
    Result=Value.toString(16);
    Result = $mod.UpperCase(Result);
    while (Result.length < Digits) Result = "0" + Result;
    return Result;
  };
  this.MaxCurrency = 900719925474.0991;
  this.MinCurrency = -900719925474.0991;
  this.TFloatFormat = {"0": "ffFixed", ffFixed: 0, "1": "ffGeneral", ffGeneral: 1, "2": "ffExponent", ffExponent: 2, "3": "ffNumber", ffNumber: 3, "4": "ffCurrency", ffCurrency: 4};
  this.$rtti.$Enum("TFloatFormat",{minvalue: 0, maxvalue: 4, ordtype: 1, enumtype: this.TFloatFormat});
  var Rounds = "123456789:";
  this.FloatToDecimal = function (Value, Precision, Decimals) {
    var Result = $mod.TFloatRec.$new();
    var Buffer = "";
    var InfNan = "";
    var OutPos = 0;
    var error = 0;
    var N = 0;
    var L = 0;
    var C = 0;
    var GotNonZeroBeforeDot = false;
    var BeforeDot = false;
    Result.Negative = false;
    Result.Exponent = 0;
    for (C = 0; C <= 19; C++) Result.Digits[C] = "0";
    if (Value === 0) return Result;
    Buffer = rtl.floatToStr(Value,24);
    N = 1;
    L = Buffer.length;
    while (Buffer.charAt(N - 1) === " ") N += 1;
    Result.Negative = Buffer.charAt(N - 1) === "-";
    if (Result.Negative) {
      N += 1}
     else if (Buffer.charAt(N - 1) === "+") N += 1;
    if (L >= (N + 2)) {
      InfNan = pas.System.Copy(Buffer,N,3);
      if (InfNan === "Inf") {
        Result.Digits[0] = "\x00";
        Result.Exponent = 32767;
        return Result;
      };
      if (InfNan === "Nan") {
        Result.Digits[0] = "\x00";
        Result.Exponent = -32768;
        return Result;
      };
    };
    OutPos = 0;
    Result.Exponent = 0;
    BeforeDot = true;
    GotNonZeroBeforeDot = false;
    while ((L >= N) && (Buffer.charAt(N - 1) !== "E")) {
      if (Buffer.charAt(N - 1) === ".") {
        BeforeDot = false}
       else {
        if (BeforeDot) {
          Result.Exponent += 1;
          Result.Digits[OutPos] = Buffer.charAt(N - 1);
          if (Buffer.charAt(N - 1) !== "0") GotNonZeroBeforeDot = true;
        } else Result.Digits[OutPos] = Buffer.charAt(N - 1);
        OutPos += 1;
      };
      N += 1;
    };
    N += 1;
    if (N <= L) {
      pas.System.val$6(pas.System.Copy(Buffer,N,(L - N) + 1),{get: function () {
          return C;
        }, set: function (v) {
          C = v;
        }},{get: function () {
          return error;
        }, set: function (v) {
          error = v;
        }});
      Result.Exponent += C;
    };
    N = OutPos;
    L = 19;
    while (N < L) {
      Result.Digits[N] = "0";
      N += 1;
    };
    if ((Decimals + Result.Exponent) < Precision) {
      N = Decimals + Result.Exponent}
     else N = Precision;
    if (N >= L) N = L - 1;
    if (N === 0) {
      if (Result.Digits[0] >= "5") {
        Result.Digits[0] = "1";
        Result.Digits[1] = "\x00";
        Result.Exponent += 1;
      } else Result.Digits[0] = "\x00";
    } else if (N > 0) {
      if (Result.Digits[N] >= "5") {
        do {
          Result.Digits[N] = "\x00";
          N -= 1;
          Result.Digits[N] = Rounds.charAt(($mod.StrToInt(Result.Digits[N]) + 1) - 1);
        } while (!((N === 0) || (Result.Digits[N] < ":")));
        if (Result.Digits[0] === ":") {
          Result.Digits[0] = "1";
          Result.Exponent += 1;
        };
      } else {
        Result.Digits[N] = "0";
        while ((N > -1) && (Result.Digits[N] === "0")) {
          Result.Digits[N] = "\x00";
          N -= 1;
        };
      };
    } else Result.Digits[0] = "\x00";
    if ((Result.Digits[0] === "\x00") && !GotNonZeroBeforeDot) {
      Result.Exponent = 0;
      Result.Negative = false;
    };
    return Result;
  };
  this.FloatToStr = function (Value) {
    var Result = "";
    Result = $mod.FloatToStr$1(Value,$mod.FormatSettings);
    return Result;
  };
  this.FloatToStr$1 = function (Value, aSettings) {
    var Result = "";
    Result = $mod.FloatToStrF$1(Value,$mod.TFloatFormat.ffGeneral,15,0,aSettings);
    return Result;
  };
  this.FloatToStrF = function (Value, format, Precision, Digits) {
    var Result = "";
    Result = $mod.FloatToStrF$1(Value,format,Precision,Digits,$mod.FormatSettings);
    return Result;
  };
  this.FloatToStrF$1 = function (Value, format, Precision, Digits, aSettings) {
    var Result = "";
    var TS = "";
    var DS = "";
    DS = aSettings.DecimalSeparator;
    TS = aSettings.ThousandSeparator;
    var $tmp = format;
    if ($tmp === $mod.TFloatFormat.ffGeneral) {
      Result = $impl.FormatGeneralFloat(Value,Precision,DS)}
     else if ($tmp === $mod.TFloatFormat.ffExponent) {
      Result = $impl.FormatExponentFloat(Value,Precision,Digits,DS)}
     else if ($tmp === $mod.TFloatFormat.ffFixed) {
      Result = $impl.FormatFixedFloat(Value,Digits,DS)}
     else if ($tmp === $mod.TFloatFormat.ffNumber) {
      Result = $impl.FormatNumberFloat(Value,Digits,DS,TS)}
     else if ($tmp === $mod.TFloatFormat.ffCurrency) Result = $impl.FormatNumberCurrency(Value * 10000,Digits,aSettings);
    if ((format !== $mod.TFloatFormat.ffCurrency) && (Result.length > 1) && (Result.charAt(0) === "-")) $impl.RemoveLeadingNegativeSign({get: function () {
        return Result;
      }, set: function (v) {
        Result = v;
      }},DS,TS);
    return Result;
  };
  this.TryStrToFloat = function (S, res) {
    var Result = false;
    Result = $mod.TryStrToFloat$2(S,res);
    return Result;
  };
  this.TryStrToFloat$1 = function (S, res, aSettings) {
    var Result = false;
    Result = $mod.TryStrToFloat$3(S,res,aSettings);
    return Result;
  };
  this.TryStrToFloat$2 = function (S, res) {
    var Result = false;
    Result = $mod.TryStrToFloat$3(S,res,$mod.FormatSettings);
    return Result;
  };
  var TDecimalPart = {"0": "dpDigit", dpDigit: 0, "1": "dpSignificand", dpSignificand: 1, "2": "dpExp", dpExp: 2};
  this.TryStrToFloat$3 = function (S, res, aSettings) {
    var Result = false;
    var J = undefined;
    var I = 0;
    var aStart = 0;
    var Len = 0;
    var N = "";
    var p = 0;
    Result = false;
    N = S;
    if (aSettings.ThousandSeparator !== "") N = $mod.StringReplace(N,aSettings.ThousandSeparator,"",rtl.createSet($mod.TStringReplaceFlag.rfReplaceAll));
    if (aSettings.DecimalSeparator !== ".") N = $mod.StringReplace(N,aSettings.DecimalSeparator,".",{});
    p = TDecimalPart.dpDigit;
    I = 1;
    aStart = 1;
    Len = N.length;
    while (I <= Len) {
      var $tmp = N.charAt(I - 1);
      if (($tmp === "+") || ($tmp === "-")) {
        var $tmp1 = p;
        if ($tmp1 === TDecimalPart.dpSignificand) {
          return Result}
         else if ($tmp1 === TDecimalPart.dpDigit) {
          if (I > aStart) return Result}
         else if ($tmp1 === TDecimalPart.dpExp) if (I > (aStart + 1)) return Result;
      } else if (($tmp >= "0") && ($tmp <= "9")) {}
      else if ($tmp === ".") {
        if (p !== TDecimalPart.dpDigit) return Result;
        p = TDecimalPart.dpSignificand;
        aStart = I;
      } else if (($tmp === "E") || ($tmp === "e")) {
        if (p === TDecimalPart.dpExp) {
          return Result}
         else {
          p = TDecimalPart.dpExp;
          aStart = I;
        };
      } else {
        return Result;
      };
      I += 1;
    };
    J = parseFloat(N);
    Result = !isNaN(J);
    if (Result) res.set(rtl.getNumber(J));
    return Result;
  };
  this.StrToFloatDef = function (S, aDef) {
    var Result = 0.0;
    if (!$mod.TryStrToFloat$3(S,{get: function () {
        return Result;
      }, set: function (v) {
        Result = v;
      }},$mod.FormatSettings)) Result = aDef;
    return Result;
  };
  this.StrToFloatDef$1 = function (S, aDef, aSettings) {
    var Result = 0.0;
    if (!$mod.TryStrToFloat$3(S,{get: function () {
        return Result;
      }, set: function (v) {
        Result = v;
      }},aSettings)) Result = aDef;
    return Result;
  };
  this.StrToFloat = function (S) {
    var Result = 0.0;
    Result = $mod.StrToFloat$1(S,$mod.FormatSettings);
    return Result;
  };
  this.StrToFloat$1 = function (S, aSettings) {
    var Result = 0.0;
    if (!$mod.TryStrToFloat$3(S,{get: function () {
        return Result;
      }, set: function (v) {
        Result = v;
      }},aSettings)) throw $mod.EConvertError.$create("CreateFmt",[rtl.getResStr(pas.RTLConsts,"SErrInvalidFloat"),pas.System.VarRecs(18,S)]);
    return Result;
  };
  this.FormatFloat = function (Fmt, aValue) {
    var Result = "";
    Result = $mod.FormatFloat$1(Fmt,aValue,$mod.TFormatSettings.$clone($mod.FormatSettings));
    return Result;
  };
  var MaxPrecision = 18;
  this.FormatFloat$1 = function (Fmt, aValue, aSettings) {
    var Result = "";
    var E = 0.0;
    var FV = $mod.TFloatRec.$new();
    var Section = "";
    var SectionLength = 0;
    var ThousandSep = false;
    var IsScientific = false;
    var DecimalPos = 0;
    var FirstDigit = 0;
    var LastDigit = 0;
    var RequestedDigits = 0;
    var ExpSize = 0;
    var Available = 0;
    var Current = 0;
    var PadZeroes = 0;
    var DistToDecimal = 0;
    function InitVars() {
      E = aValue;
      Section = "";
      SectionLength = 0;
      ThousandSep = false;
      IsScientific = false;
      DecimalPos = 0;
      FirstDigit = 2147483647;
      LastDigit = 0;
      RequestedDigits = 0;
      ExpSize = 0;
      Available = -1;
    };
    function ToResult(AChar) {
      Result = Result + AChar;
    };
    function AddToResult(AStr) {
      Result = Result + AStr;
    };
    function WriteDigit(ADigit) {
      if (ADigit === "\x00") return;
      DistToDecimal -= 1;
      if (DistToDecimal === -1) {
        AddToResult(aSettings.DecimalSeparator);
        ToResult(ADigit);
      } else {
        ToResult(ADigit);
        if (ThousandSep && ((DistToDecimal % 3) === 0) && (DistToDecimal > 1)) AddToResult(aSettings.ThousandSeparator);
      };
    };
    function GetDigit() {
      var Result = "\x00";
      Result = "\x00";
      if (Current <= Available) {
        Result = FV.Digits[Current];
        Current += 1;
      } else if (DistToDecimal <= LastDigit) {
        DistToDecimal -= 1}
       else Result = "0";
      return Result;
    };
    function CopyDigit() {
      if (PadZeroes === 0) {
        WriteDigit(GetDigit())}
       else if (PadZeroes < 0) {
        PadZeroes += 1;
        if (DistToDecimal <= FirstDigit) {
          WriteDigit("0")}
         else DistToDecimal -= 1;
      } else {
        while (PadZeroes > 0) {
          WriteDigit(GetDigit());
          PadZeroes -= 1;
        };
        WriteDigit(GetDigit());
      };
    };
    function GetSections(SP) {
      var Result = 0;
      var FL = 0;
      var i = 0;
      var C = "\x00";
      var Q = "\x00";
      var inQuote = false;
      Result = 1;
      SP.get()[1] = -1;
      SP.get()[2] = -1;
      SP.get()[3] = -1;
      inQuote = false;
      Q = "\x00";
      i = 1;
      FL = Fmt.length;
      while (i <= FL) {
        C = Fmt.charAt(i - 1);
        var $tmp = C;
        if ($tmp === ";") {
          if (!inQuote) {
            if (Result > 3) throw $mod.Exception.$create("Create$1",["Invalid float format"]);
            SP.get()[Result] = i;
            Result += 1;
          };
        } else if (($tmp === '"') || ($tmp === "'")) {
          if (inQuote) {
            inQuote = C !== Q}
           else {
            inQuote = true;
            Q = C;
          };
        };
        i += 1;
      };
      if (SP.get()[Result] === -1) SP.get()[Result] = FL + 1;
      return Result;
    };
    function AnalyzeFormat() {
      var I = 0;
      var Len = 0;
      var Q = "\x00";
      var C = "\x00";
      var InQuote = false;
      Len = Section.length;
      I = 1;
      InQuote = false;
      Q = "\x00";
      while (I <= Len) {
        C = Section.charAt(I - 1);
        if (C.charCodeAt() in rtl.createSet(34,39)) {
          if (InQuote) {
            InQuote = C !== Q}
           else {
            InQuote = true;
            Q = C;
          };
        } else if (!InQuote) {
          var $tmp = C;
          if ($tmp === ".") {
            if (DecimalPos === 0) DecimalPos = RequestedDigits + 1}
           else if ($tmp === ",") {
            ThousandSep = aSettings.ThousandSeparator !== "\x00"}
           else if (($tmp === "e") || ($tmp === "E")) {
            I += 1;
            if (I < Len) {
              C = Section.charAt(I - 1);
              IsScientific = C.charCodeAt() in rtl.createSet(45,43);
              if (IsScientific) while ((I < Len) && (Section.charAt((I + 1) - 1) === "0")) {
                ExpSize += 1;
                I += 1;
              };
              if (ExpSize > 4) ExpSize = 4;
            };
          } else if ($tmp === "#") {
            RequestedDigits += 1}
           else if ($tmp === "0") {
            if (RequestedDigits < FirstDigit) FirstDigit = RequestedDigits + 1;
            RequestedDigits += 1;
            LastDigit = RequestedDigits + 1;
          };
        };
        I += 1;
      };
      if (DecimalPos === 0) DecimalPos = RequestedDigits + 1;
      LastDigit = DecimalPos - LastDigit;
      if (LastDigit > 0) LastDigit = 0;
      FirstDigit = DecimalPos - FirstDigit;
      if (FirstDigit < 0) FirstDigit = 0;
    };
    function ValueOutSideScope() {
      var Result = false;
      Result = ((FV.Exponent >= 18) && !IsScientific) || (FV.Exponent === 0x7FF) || (FV.Exponent === 0x800);
      return Result;
    };
    function CalcRunVars() {
      var D = 0;
      var P = 0;
      if (IsScientific) {
        P = RequestedDigits;
        D = 9999;
      } else {
        P = 18;
        D = (RequestedDigits - DecimalPos) + 1;
      };
      FV.$assign($mod.FloatToDecimal(aValue,P,D));
      DistToDecimal = DecimalPos - 1;
      if (IsScientific) {
        PadZeroes = 0}
       else {
        PadZeroes = FV.Exponent - (DecimalPos - 1);
        if (PadZeroes >= 0) DistToDecimal = FV.Exponent;
      };
      Available = -1;
      while ((Available < 18) && (FV.Digits[Available + 1] !== "\x00")) Available += 1;
    };
    function FormatExponent(ASign, aExponent) {
      var Result = "";
      Result = $mod.IntToStr(aExponent);
      Result = pas.System.StringOfChar("0",ExpSize - Result.length) + Result;
      if (aExponent < 0) {
        Result = "-" + Result}
       else if ((aExponent > 0) && (ASign === "+")) Result = ASign + Result;
      return Result;
    };
    var I = 0;
    var S = 0;
    var C = "\x00";
    var Q = "\x00";
    var PA = [];
    var InLiteral = false;
    PA = rtl.arraySetLength(PA,0,4);
    Result = "";
    InitVars();
    if (E > 0) {
      S = 1}
     else if (E < 0) {
      S = 2}
     else S = 3;
    PA[0] = 0;
    I = GetSections({get: function () {
        return PA;
      }, set: function (v) {
        PA = v;
      }});
    if ((I < S) || ((PA[S] - PA[S - 1]) === 0)) S = 1;
    SectionLength = PA[S] - PA[S - 1] - 1;
    Section = pas.System.Copy(Fmt,PA[S - 1] + 1,SectionLength);
    Section = rtl.strSetLength(Section,SectionLength);
    AnalyzeFormat();
    CalcRunVars();
    if ((SectionLength === 0) || ValueOutSideScope()) {
      Section=E.toPrecision(15);
      Result = Section;
    };
    I = 1;
    Current = 0;
    Q = " ";
    InLiteral = false;
    if (FV.Negative && (S === 1)) ToResult("-");
    while (I <= SectionLength) {
      C = Section.charAt(I - 1);
      if (C.charCodeAt() in rtl.createSet(34,39)) {
        if (InLiteral) {
          InLiteral = C !== Q}
         else {
          InLiteral = true;
          Q = C;
        };
      } else if (InLiteral) {
        ToResult(C)}
       else {
        var $tmp = C;
        if (($tmp === "0") || ($tmp === "#")) {
          CopyDigit()}
         else if (($tmp === ".") || ($tmp === ",")) {}
        else if (($tmp === "e") || ($tmp === "E")) {
          ToResult(C);
          I += 1;
          if (I <= Section.length) {
            C = Section.charAt(I - 1);
            if (C.charCodeAt() in rtl.createSet(43,45)) {
              AddToResult(FormatExponent(C,(FV.Exponent - DecimalPos) + 1));
              while ((I < SectionLength) && (Section.charAt((I + 1) - 1) === "0")) I += 1;
            };
          };
        } else {
          ToResult(C);
        };
      };
      I += 1;
    };
    return Result;
  };
  this.$rtti.$DynArray("FalseBoolStrs$a",{eltype: rtl.string});
  this.TrueBoolStrs = [];
  this.FalseBoolStrs = [];
  this.StrToBool = function (S) {
    var Result = false;
    if (!$mod.TryStrToBool(S,{get: function () {
        return Result;
      }, set: function (v) {
        Result = v;
      }})) throw $mod.EConvertError.$create("CreateFmt",[rtl.getResStr(pas.RTLConsts,"SInvalidBoolean"),pas.System.VarRecs(18,S)]);
    return Result;
  };
  this.BoolToStr = function (B, UseBoolStrs) {
    var Result = "";
    if (UseBoolStrs) {
      $impl.CheckBoolStrs();
      if (B) {
        Result = $mod.TrueBoolStrs[0]}
       else Result = $mod.FalseBoolStrs[0];
    } else if (B) {
      Result = "-1"}
     else Result = "0";
    return Result;
  };
  this.BoolToStr$1 = function (B, TrueS, FalseS) {
    var Result = "";
    if (B) {
      Result = TrueS}
     else Result = FalseS;
    return Result;
  };
  this.StrToBoolDef = function (S, Default) {
    var Result = false;
    if (!$mod.TryStrToBool(S,{get: function () {
        return Result;
      }, set: function (v) {
        Result = v;
      }})) Result = Default;
    return Result;
  };
  this.TryStrToBool = function (S, Value) {
    var Result = false;
    var Temp = "";
    var I = 0;
    var D = 0.0;
    var Code = 0;
    Temp = $mod.UpperCase(S);
    pas.System.val$8(Temp,{get: function () {
        return D;
      }, set: function (v) {
        D = v;
      }},{get: function () {
        return Code;
      }, set: function (v) {
        Code = v;
      }});
    Result = true;
    if (Code === 0) {
      Value.set(D !== 0.0)}
     else {
      $impl.CheckBoolStrs();
      for (var $l = 0, $end = rtl.length($mod.TrueBoolStrs) - 1; $l <= $end; $l++) {
        I = $l;
        if (Temp === $mod.UpperCase($mod.TrueBoolStrs[I])) {
          Value.set(true);
          return Result;
        };
      };
      for (var $l1 = 0, $end1 = rtl.length($mod.FalseBoolStrs) - 1; $l1 <= $end1; $l1++) {
        I = $l1;
        if (Temp === $mod.UpperCase($mod.FalseBoolStrs[I])) {
          Value.set(false);
          return Result;
        };
      };
      Result = false;
    };
    return Result;
  };
  this.ConfigExtension = ".cfg";
  this.SysConfigDir = "";
  this.$rtti.$ProcVar("TOnGetEnvironmentVariable",{procsig: rtl.newTIProcSig([["EnvVar",rtl.string,2]],rtl.string)});
  this.$rtti.$ProcVar("TOnGetEnvironmentString",{procsig: rtl.newTIProcSig([["Index",rtl.longint]],rtl.string)});
  this.$rtti.$ProcVar("TOnGetEnvironmentVariableCount",{procsig: rtl.newTIProcSig([],rtl.longint)});
  this.$rtti.$ProcVar("TShowExceptionHandler",{procsig: rtl.newTIProcSig([["Msg",rtl.string,2]])});
  this.$rtti.$RefToProcVar("TUncaughtPascalExceptionHandler",{procsig: rtl.newTIProcSig([["aObject",pas.System.$rtti["TObject"]]])});
  this.$rtti.$RefToProcVar("TUncaughtJSExceptionHandler",{procsig: rtl.newTIProcSig([["aObject",pas.JS.$rtti["TJSObject"]]])});
  this.OnGetEnvironmentVariable = null;
  this.OnGetEnvironmentString = null;
  this.OnGetEnvironmentVariableCount = null;
  this.OnShowException = null;
  this.SetOnUnCaughtExceptionHandler = function (aValue) {
    var Result = null;
    Result = $impl.OnPascalException;
    $impl.OnPascalException = aValue;
    $mod.HookUncaughtExceptions();
    return Result;
  };
  this.SetOnUnCaughtExceptionHandler$1 = function (aValue) {
    var Result = null;
    Result = $impl.OnJSException;
    $impl.OnJSException = aValue;
    $mod.HookUncaughtExceptions();
    return Result;
  };
  this.HookUncaughtExceptions = function () {
    rtl.onUncaughtException = $impl.RTLExceptionHook;
    rtl.showUncaughtExceptions = true;
  };
  this.GetEnvironmentVariable = function (EnvVar) {
    var Result = "";
    if ($mod.OnGetEnvironmentVariable != null) {
      Result = $mod.OnGetEnvironmentVariable(EnvVar)}
     else Result = "";
    return Result;
  };
  this.GetEnvironmentVariableCount = function () {
    var Result = 0;
    if ($mod.OnGetEnvironmentVariableCount != null) {
      Result = $mod.OnGetEnvironmentVariableCount()}
     else Result = 0;
    return Result;
  };
  this.GetEnvironmentString = function (Index) {
    var Result = "";
    if ($mod.OnGetEnvironmentString != null) {
      Result = $mod.OnGetEnvironmentString(Index)}
     else Result = "";
    return Result;
  };
  this.ShowException = function (ExceptObject, ExceptAddr) {
    var S = "";
    S = rtl.getResStr($mod,"SApplicationException") + ExceptObject.$classname;
    if ($mod.Exception.isPrototypeOf(ExceptObject)) S = S + " : " + ExceptObject.FMessage;
    $impl.DoShowException(S);
    if (ExceptAddr === null) ;
  };
  this.Abort = function () {
    throw $mod.EAbort.$create("Create$1",[rtl.getResStr($mod,"SAbortError")]);
  };
  this.TEventType = {"0": "etCustom", etCustom: 0, "1": "etInfo", etInfo: 1, "2": "etWarning", etWarning: 2, "3": "etError", etError: 3, "4": "etDebug", etDebug: 4};
  this.$rtti.$Enum("TEventType",{minvalue: 0, maxvalue: 4, ordtype: 1, enumtype: this.TEventType});
  this.$rtti.$Set("TEventTypes",{comptype: this.$rtti["TEventType"]});
  rtl.recNewT(this,"TSystemTime",function () {
    this.Year = 0;
    this.Month = 0;
    this.Day = 0;
    this.DayOfWeek = 0;
    this.Hour = 0;
    this.Minute = 0;
    this.Second = 0;
    this.MilliSecond = 0;
    this.$eq = function (b) {
      return (this.Year === b.Year) && (this.Month === b.Month) && (this.Day === b.Day) && (this.DayOfWeek === b.DayOfWeek) && (this.Hour === b.Hour) && (this.Minute === b.Minute) && (this.Second === b.Second) && (this.MilliSecond === b.MilliSecond);
    };
    this.$assign = function (s) {
      this.Year = s.Year;
      this.Month = s.Month;
      this.Day = s.Day;
      this.DayOfWeek = s.DayOfWeek;
      this.Hour = s.Hour;
      this.Minute = s.Minute;
      this.Second = s.Second;
      this.MilliSecond = s.MilliSecond;
      return this;
    };
    var $r = $mod.$rtti.$Record("TSystemTime",{});
    $r.addField("Year",rtl.word);
    $r.addField("Month",rtl.word);
    $r.addField("Day",rtl.word);
    $r.addField("DayOfWeek",rtl.word);
    $r.addField("Hour",rtl.word);
    $r.addField("Minute",rtl.word);
    $r.addField("Second",rtl.word);
    $r.addField("MilliSecond",rtl.word);
  });
  rtl.recNewT(this,"TTimeStamp",function () {
    this.Time = 0;
    this.Date = 0;
    this.$eq = function (b) {
      return (this.Time === b.Time) && (this.Date === b.Date);
    };
    this.$assign = function (s) {
      this.Time = s.Time;
      this.Date = s.Date;
      return this;
    };
    var $r = $mod.$rtti.$Record("TTimeStamp",{});
    $r.addField("Time",rtl.longint);
    $r.addField("Date",rtl.longint);
  });
  this.TimeSeparator = "\x00";
  this.DateSeparator = "\x00";
  this.ShortDateFormat = "";
  this.LongDateFormat = "";
  this.ShortTimeFormat = "";
  this.LongTimeFormat = "";
  this.DecimalSeparator = "";
  this.ThousandSeparator = "";
  this.TimeAMString = "";
  this.TimePMString = "";
  this.HoursPerDay = 24;
  this.MinsPerHour = 60;
  this.SecsPerMin = 60;
  this.MSecsPerSec = 1000;
  this.MinsPerDay = 24 * 60;
  this.SecsPerHour = 60 * 60;
  this.SecsPerDay = 1440 * 60;
  this.MSecsPerDay = 86400 * 1000;
  this.MaxDateTime = 2958465.99999999;
  this.MinDateTime = -693593.99999999;
  this.JulianEpoch = -2415018.5;
  this.UnixEpoch = -2415018.5 + 2440587.5;
  this.DateDelta = 693594;
  this.UnixDateDelta = 25569;
  this.MonthDays$a$clone = function (a) {
    var b = [];
    b.length = 2;
    for (var c = 0; c < 2; c++) b[c] = a[c].slice(0);
    return b;
  };
  this.$rtti.$StaticArray("MonthDays$a",{dims: [2,12], eltype: rtl.word});
  this.MonthDays = [[31,28,31,30,31,30,31,31,30,31,30,31],[31,29,31,30,31,30,31,31,30,31,30,31]];
  this.ShortMonthNames = rtl.arraySetLength(null,"",12);
  this.LongMonthNames = rtl.arraySetLength(null,"",12);
  this.ShortDayNames = rtl.arraySetLength(null,"",7);
  this.LongDayNames = rtl.arraySetLength(null,"",7);
  this.FormatSettings = this.TFormatSettings.$new();
  this.TwoDigitYearCenturyWindow = 50;
  this.DateTimeToJSDate = function (aDateTime, asUTC) {
    var Result = null;
    var Y = 0;
    var M = 0;
    var D = 0;
    var h = 0;
    var n = 0;
    var s = 0;
    var z = 0;
    $mod.DecodeDate(pas.System.Trunc(aDateTime),{get: function () {
        return Y;
      }, set: function (v) {
        Y = v;
      }},{get: function () {
        return M;
      }, set: function (v) {
        M = v;
      }},{get: function () {
        return D;
      }, set: function (v) {
        D = v;
      }});
    $mod.DecodeTime(pas.System.Frac(aDateTime),{get: function () {
        return h;
      }, set: function (v) {
        h = v;
      }},{get: function () {
        return n;
      }, set: function (v) {
        n = v;
      }},{get: function () {
        return s;
      }, set: function (v) {
        s = v;
      }},{get: function () {
        return z;
      }, set: function (v) {
        z = v;
      }});
    if (asUTC) {
      Result = new Date(Date.UTC(Y,M - 1,D,h,n,s,z))}
     else Result = new Date(Y,M - 1,D,h,n,s,z);
    return Result;
  };
  this.JSDateToDateTime = function (aDate) {
    var Result = 0.0;
    Result = $mod.EncodeDate(aDate.getFullYear(),aDate.getMonth() + 1,aDate.getDate()) + $mod.EncodeTime(aDate.getHours(),aDate.getMinutes(),aDate.getSeconds(),aDate.getMilliseconds());
    return Result;
  };
  this.DateTimeToTimeStamp = function (DateTime) {
    var Result = $mod.TTimeStamp.$new();
    var D = 0.0;
    D = DateTime * 86400000;
    if (D < 0) {
      D = D - 0.5}
     else D = D + 0.5;
    Result.Time = pas.System.Trunc(Math.abs(pas.System.Trunc(D)) % 86400000);
    Result.Date = 693594 + rtl.trunc(pas.System.Trunc(D) / 86400000);
    return Result;
  };
  this.TimeStampToDateTime = function (TimeStamp) {
    var Result = 0.0;
    Result = $mod.ComposeDateTime(TimeStamp.Date - 693594,TimeStamp.Time / 86400000);
    return Result;
  };
  this.MSecsToTimeStamp = function (MSecs) {
    var Result = $mod.TTimeStamp.$new();
    Result.Date = pas.System.Trunc(MSecs / 86400000);
    MSecs = MSecs - (Result.Date * 86400000);
    Result.Time = Math.round(MSecs);
    return Result;
  };
  this.TimeStampToMSecs = function (TimeStamp) {
    var Result = 0;
    Result = TimeStamp.Time + (TimeStamp.Date * 86400000);
    return Result;
  };
  this.DateTimeToSystemTime = function (DateTime, SystemTime) {
    $mod.DecodeDateFully(DateTime,{p: SystemTime, get: function () {
        return this.p.Year;
      }, set: function (v) {
        this.p.Year = v;
      }},{p: SystemTime, get: function () {
        return this.p.Month;
      }, set: function (v) {
        this.p.Month = v;
      }},{p: SystemTime, get: function () {
        return this.p.Day;
      }, set: function (v) {
        this.p.Day = v;
      }},{p: SystemTime, get: function () {
        return this.p.DayOfWeek;
      }, set: function (v) {
        this.p.DayOfWeek = v;
      }});
    $mod.DecodeTime(DateTime,{p: SystemTime, get: function () {
        return this.p.Hour;
      }, set: function (v) {
        this.p.Hour = v;
      }},{p: SystemTime, get: function () {
        return this.p.Minute;
      }, set: function (v) {
        this.p.Minute = v;
      }},{p: SystemTime, get: function () {
        return this.p.Second;
      }, set: function (v) {
        this.p.Second = v;
      }},{p: SystemTime, get: function () {
        return this.p.MilliSecond;
      }, set: function (v) {
        this.p.MilliSecond = v;
      }});
    SystemTime.DayOfWeek -= 1;
  };
  this.SystemTimeToDateTime = function (SystemTime) {
    var Result = 0.0;
    Result = $mod.ComposeDateTime($impl.DoEncodeDate(SystemTime.Year,SystemTime.Month,SystemTime.Day),$impl.DoEncodeTime(SystemTime.Hour,SystemTime.Minute,SystemTime.Second,SystemTime.MilliSecond));
    return Result;
  };
  this.FloatToDateTime = function (Value) {
    var Result = 0.0;
    if ((Value < $mod.MinDateTime) || (Value > $mod.MaxDateTime)) throw $mod.EConvertError.$create("CreateFmt",[rtl.getResStr(pas.RTLConsts,"SInvalidDateTime"),pas.System.VarRecs(18,$mod.FloatToStr(Value))]);
    Result = Value;
    return Result;
  };
  this.TryEncodeDate = function (Year, Month, Day, date) {
    var Result = false;
    var c = 0;
    var ya = 0;
    Result = (Year > 0) && (Year < 10000) && (Month >= 1) && (Month <= 12) && (Day > 0) && (Day <= $mod.MonthDays[+$mod.IsLeapYear(Year)][Month - 1]);
    if (Result) {
      if (Month > 2) {
        Month -= 3}
       else {
        Month += 9;
        Year -= 1;
      };
      c = rtl.trunc(Year / 100);
      ya = Year - (100 * c);
      date.set(((146097 * c) >>> 2) + ((1461 * ya) >>> 2) + rtl.trunc(((153 * Month) + 2) / 5) + Day);
      date.set(date.get() - 693900);
    };
    return Result;
  };
  this.TryEncodeTime = function (Hour, Min, Sec, MSec, Time) {
    var Result = false;
    Result = (Hour < 24) && (Min < 60) && (Sec < 60) && (MSec < 1000);
    if (Result) Time.set(((Hour * 3600000) + (Min * 60000) + (Sec * 1000) + MSec) / 86400000);
    return Result;
  };
  this.EncodeDate = function (Year, Month, Day) {
    var Result = 0.0;
    if (!$mod.TryEncodeDate(Year,Month,Day,{get: function () {
        return Result;
      }, set: function (v) {
        Result = v;
      }})) throw $mod.EConvertError.$create("CreateFmt",["%s-%s-%s is not a valid date specification",pas.System.VarRecs(18,$mod.IntToStr(Year),18,$mod.IntToStr(Month),18,$mod.IntToStr(Day))]);
    return Result;
  };
  this.EncodeTime = function (Hour, Minute, Second, MilliSecond) {
    var Result = 0.0;
    if (!$mod.TryEncodeTime(Hour,Minute,Second,MilliSecond,{get: function () {
        return Result;
      }, set: function (v) {
        Result = v;
      }})) throw $mod.EConvertError.$create("CreateFmt",["%s:%s:%s.%s is not a valid time specification",pas.System.VarRecs(18,$mod.IntToStr(Hour),18,$mod.IntToStr(Minute),18,$mod.IntToStr(Second),18,$mod.IntToStr(MilliSecond))]);
    return Result;
  };
  this.DecodeDate = function (date, Year, Month, Day) {
    var ly = 0;
    var ld = 0;
    var lm = 0;
    var j = 0;
    if (date <= -693594) {
      Year.set(0);
      Month.set(0);
      Day.set(0);
    } else {
      if (date > 0) {
        date = date + (1 / (86400000 * 2))}
       else date = date - (1 / (86400000 * 2));
      if (date > $mod.MaxDateTime) date = $mod.MaxDateTime;
      j = rtl.shl(pas.System.Trunc(date) + 693900,2) - 1;
      ly = rtl.trunc(j / 146097);
      j = j - (146097 * ly);
      ld = rtl.lw(j >>> 2);
      j = rtl.trunc((rtl.lw(ld << 2) + 3) / 1461);
      ld = rtl.lw(((rtl.lw(ld << 2) + 7) - (1461 * j)) >>> 2);
      lm = rtl.trunc(((5 * ld) - 3) / 153);
      ld = rtl.trunc((((5 * ld) + 2) - (153 * lm)) / 5);
      ly = (100 * ly) + j;
      if (lm < 10) {
        lm += 3}
       else {
        lm -= 9;
        ly += 1;
      };
      Year.set(ly);
      Month.set(lm);
      Day.set(ld);
    };
  };
  this.DecodeTime = function (Time, Hour, Minute, Second, MilliSecond) {
    var l = 0;
    l = $mod.DateTimeToTimeStamp(Time).Time;
    Hour.set(rtl.trunc(l / 3600000));
    l = l % 3600000;
    Minute.set(rtl.trunc(l / 60000));
    l = l % 60000;
    Second.set(rtl.trunc(l / 1000));
    l = l % 1000;
    MilliSecond.set(l);
  };
  this.DecodeDateFully = function (DateTime, Year, Month, Day, DOW) {
    var Result = false;
    $mod.DecodeDate(DateTime,Year,Month,Day);
    DOW.set($mod.DayOfWeek(DateTime));
    Result = $mod.IsLeapYear(Year.get());
    return Result;
  };
  this.ComposeDateTime = function (date, Time) {
    var Result = 0.0;
    if (date < 0) {
      Result = pas.System.Trunc(date) - Math.abs(pas.System.Frac(Time))}
     else Result = pas.System.Trunc(date) + Math.abs(pas.System.Frac(Time));
    return Result;
  };
  this.ReplaceTime = function (dati, NewTime) {
    dati.set($mod.ComposeDateTime(dati.get(),NewTime));
  };
  this.ReplaceDate = function (DateTime, NewDate) {
    var tmp = 0.0;
    tmp = NewDate;
    $mod.ReplaceTime({get: function () {
        return tmp;
      }, set: function (v) {
        tmp = v;
      }},DateTime.get());
    DateTime.set(tmp);
  };
  this.Date = function () {
    var Result = 0.0;
    Result = pas.System.Trunc($mod.Now());
    return Result;
  };
  this.Time = function () {
    var Result = 0.0;
    Result = $mod.Now() - $mod.Date();
    return Result;
  };
  this.Now = function () {
    var Result = 0.0;
    Result = $mod.JSDateToDateTime(new Date());
    return Result;
  };
  this.DayOfWeek = function (DateTime) {
    var Result = 0;
    Result = 1 + ((pas.System.Trunc(DateTime) - 1) % 7);
    if (Result <= 0) Result += 7;
    return Result;
  };
  this.IncMonth = function (DateTime, NumberOfMonths) {
    var Result = 0.0;
    var Year = 0;
    var Month = 0;
    var Day = 0;
    $mod.DecodeDate(DateTime,{get: function () {
        return Year;
      }, set: function (v) {
        Year = v;
      }},{get: function () {
        return Month;
      }, set: function (v) {
        Month = v;
      }},{get: function () {
        return Day;
      }, set: function (v) {
        Day = v;
      }});
    $mod.IncAMonth({get: function () {
        return Year;
      }, set: function (v) {
        Year = v;
      }},{get: function () {
        return Month;
      }, set: function (v) {
        Month = v;
      }},{get: function () {
        return Day;
      }, set: function (v) {
        Day = v;
      }},NumberOfMonths);
    Result = $mod.ComposeDateTime($impl.DoEncodeDate(Year,Month,Day),DateTime);
    return Result;
  };
  this.IncAMonth = function (Year, Month, Day, NumberOfMonths) {
    var TempMonth = 0;
    var S = 0;
    if (NumberOfMonths >= 0) {
      S = 1}
     else S = -1;
    Year.set(Year.get() + rtl.trunc(NumberOfMonths / 12));
    TempMonth = (Month.get() + (NumberOfMonths % 12)) - 1;
    if ((TempMonth > 11) || (TempMonth < 0)) {
      TempMonth -= S * 12;
      Year.set(Year.get() + S);
    };
    Month.set(TempMonth + 1);
    if (Day.get() > $mod.MonthDays[+$mod.IsLeapYear(Year.get())][Month.get() - 1]) Day.set($mod.MonthDays[+$mod.IsLeapYear(Year.get())][Month.get() - 1]);
  };
  this.IsLeapYear = function (Year) {
    var Result = false;
    Result = ((Year % 4) === 0) && (((Year % 100) !== 0) || ((Year % 400) === 0));
    return Result;
  };
  this.CurrentYear = function () {
    var Result = 0;
    Result = (new Date()).getFullYear();
    return Result;
  };
  this.DateTimeToString = function (Result, Format, DateTime) {
    $mod.DateTimeToString$1(Result,Format,DateTime,$mod.FormatSettings);
  };
  this.DateTimeToString$1 = function (Result, Format, DateTime, AFormatSettings) {
    Result.set($mod.FormatDateTime$1(Format,DateTime,AFormatSettings));
  };
  this.DateToStr = function (date) {
    var Result = "";
    Result = $mod.DateToStr$1(date,$mod.FormatSettings);
    return Result;
  };
  this.DateToStr$1 = function (date, aSettings) {
    var Result = "";
    Result = $mod.FormatDateTime$1("ddddd",date,aSettings);
    return Result;
  };
  this.StrToDate = function (S) {
    var Result = 0.0;
    Result = $mod.StrToDate$3(S,$mod.FormatSettings);
    return Result;
  };
  this.StrToDate$1 = function (S, separator) {
    var Result = 0.0;
    Result = $mod.StrToDate$2(S,$mod.FormatSettings.ShortDateFormat,separator);
    return Result;
  };
  this.StrToDate$2 = function (S, useformat, separator) {
    var Result = 0.0;
    var MSg = "";
    Result = $impl.IntStrToDate({get: function () {
        return MSg;
      }, set: function (v) {
        MSg = v;
      }},S,useformat,separator);
    if (MSg !== "") throw $mod.EConvertError.$create("Create$1",[MSg]);
    return Result;
  };
  this.StrToDate$3 = function (S, aSettings) {
    var Result = 0.0;
    Result = $mod.StrToDate$2(S,aSettings.ShortDateFormat,aSettings.DateSeparator);
    return Result;
  };
  this.TryStrToDate = function (S, Value) {
    var Result = false;
    Result = $mod.TryStrToDate$1(S,Value,$mod.FormatSettings);
    return Result;
  };
  this.TryStrToDate$1 = function (S, Value, aSettings) {
    var Result = false;
    Result = $mod.TryStrToDate$3(S,Value,aSettings.ShortDateFormat,aSettings.DateSeparator);
    return Result;
  };
  this.TryStrToDate$2 = function (S, Value, separator) {
    var Result = false;
    Result = $mod.TryStrToDate$3(S,Value,$mod.FormatSettings.ShortDateFormat,separator);
    return Result;
  };
  this.TryStrToDate$3 = function (S, Value, useformat, separator) {
    var Result = false;
    var Msg = "";
    Result = S.length !== 0;
    if (Result) {
      Value.set($impl.IntStrToDate({get: function () {
          return Msg;
        }, set: function (v) {
          Msg = v;
        }},S,useformat,separator));
      Result = Msg === "";
    };
    return Result;
  };
  this.StrToDateDef = function (S, Defvalue) {
    var Result = 0.0;
    Result = $mod.StrToDateDef$1(S,Defvalue,"\x00");
    return Result;
  };
  this.StrToDateDef$1 = function (S, Defvalue, separator) {
    var Result = 0.0;
    if (!$mod.TryStrToDate$2(S,{get: function () {
        return Result;
      }, set: function (v) {
        Result = v;
      }},separator)) Result = Defvalue;
    return Result;
  };
  this.StrToDateDef$2 = function (S, Defvalue, aSettings) {
    var Result = 0.0;
    if (!$mod.TryStrToDate$1(S,{get: function () {
        return Result;
      }, set: function (v) {
        Result = v;
      }},aSettings)) Result = Defvalue;
    return Result;
  };
  this.TimeToStr = function (Time) {
    var Result = "";
    Result = $mod.TimeToStr$1(Time,$mod.FormatSettings);
    return Result;
  };
  this.TimeToStr$1 = function (Time, aSettings) {
    var Result = "";
    Result = $mod.FormatDateTime$1("tt",Time,aSettings);
    return Result;
  };
  this.StrToTime = function (S) {
    var Result = 0.0;
    Result = $mod.StrToTime$2(S,$mod.FormatSettings);
    return Result;
  };
  this.StrToTime$1 = function (S, separator) {
    var Result = 0.0;
    var aSettings = $mod.TFormatSettings.$new();
    aSettings.$assign($mod.TFormatSettings.Create());
    aSettings.TimeSeparator = separator;
    Result = $mod.StrToTime$2(S,aSettings);
    return Result;
  };
  this.StrToTime$2 = function (S, aSettings) {
    var Result = 0.0;
    var Msg = "";
    Result = $impl.IntStrToTime({get: function () {
        return Msg;
      }, set: function (v) {
        Msg = v;
      }},S,S.length,aSettings);
    if (Msg !== "") throw $mod.EConvertError.$create("Create$1",[Msg]);
    return Result;
  };
  this.TryStrToTime = function (S, Value) {
    var Result = false;
    Result = $mod.TryStrToTime$1(S,Value,$mod.TFormatSettings.$clone($mod.FormatSettings));
    return Result;
  };
  this.TryStrToTime$1 = function (S, Value, aSettings) {
    var Result = false;
    var Msg = "";
    Result = S.length !== 0;
    if (Result) {
      Value.set($impl.IntStrToTime({get: function () {
          return Msg;
        }, set: function (v) {
          Msg = v;
        }},S,S.length,aSettings));
      Result = Msg === "";
    };
    return Result;
  };
  this.TryStrToTime$2 = function (S, Value, separator) {
    var Result = false;
    var Fmt = $mod.TFormatSettings.$new();
    Fmt.$assign($mod.TFormatSettings.Create());
    Fmt.TimeSeparator = separator;
    Result = $mod.TryStrToTime$1(S,Value,$mod.TFormatSettings.$clone(Fmt));
    return Result;
  };
  this.StrToTimeDef = function (S, Defvalue) {
    var Result = 0.0;
    Result = $mod.StrToTimeDef$1(S,Defvalue,"\x00");
    return Result;
  };
  this.StrToTimeDef$1 = function (S, Defvalue, separator) {
    var Result = 0.0;
    if (!$mod.TryStrToTime$2(S,{get: function () {
        return Result;
      }, set: function (v) {
        Result = v;
      }},separator)) Result = Defvalue;
    return Result;
  };
  this.StrToTimeDef$2 = function (AString, ADefault, aSettings) {
    var Result = 0.0;
    if (!$mod.TryStrToTime$1(AString,{get: function () {
        return Result;
      }, set: function (v) {
        Result = v;
      }},$mod.TFormatSettings.$clone(aSettings))) Result = ADefault;
    return Result;
  };
  this.DateTimeToStr = function (DateTime, ForceTimeIfZero) {
    var Result = "";
    Result = $mod.DateTimeToStr$1(DateTime,$mod.FormatSettings,ForceTimeIfZero);
    return Result;
  };
  this.DateTimeToStr$1 = function (DateTime, aSettings, ForceTimeIfZero) {
    var Result = "";
    Result = $mod.FormatDateTime$1($impl.DateTimeToStrFormat[+ForceTimeIfZero],DateTime,aSettings);
    return Result;
  };
  this.StrToDateTime = function (S) {
    var Result = 0.0;
    Result = $mod.StrToDateTime$1(S,$mod.FormatSettings);
    return Result;
  };
  this.StrToDateTime$1 = function (s, aSettings) {
    var Result = 0.0;
    var TimeStr = "";
    var DateStr = "";
    var PartsFound = 0;
    PartsFound = $impl.SplitDateTimeStr(s,{get: function () {
        return DateStr;
      }, set: function (v) {
        DateStr = v;
      }},{get: function () {
        return TimeStr;
      }, set: function (v) {
        TimeStr = v;
      }},aSettings);
    var $tmp = PartsFound;
    if ($tmp === 0) {
      Result = $mod.StrToDate("")}
     else if ($tmp === 1) {
      if (DateStr.length > 0) {
        Result = $mod.StrToDate$2(DateStr,aSettings.ShortDateFormat,aSettings.DateSeparator)}
       else Result = $mod.StrToTime(TimeStr)}
     else if ($tmp === 2) Result = $mod.ComposeDateTime($mod.StrToDate$2(DateStr,aSettings.ShortDateFormat,aSettings.DateSeparator),$mod.StrToTime(TimeStr));
    return Result;
  };
  this.TryStrToDateTime = function (S, Value) {
    var Result = false;
    Result = $mod.TryStrToDateTime$1(S,Value,$mod.FormatSettings);
    return Result;
  };
  this.TryStrToDateTime$1 = function (S, Value, aSettings) {
    var Result = false;
    var I = 0;
    var dtdate = 0.0;
    var dttime = 0.0;
    Result = false;
    I = pas.System.Pos(aSettings.TimeSeparator,S);
    if (I > 0) {
      while ((I > 0) && (S.charAt(I - 1) !== " ")) I -= 1;
      if (I > 0) {
        if (!$mod.TryStrToDate$1(pas.System.Copy(S,1,I - 1),{get: function () {
            return dtdate;
          }, set: function (v) {
            dtdate = v;
          }},aSettings)) return Result;
        if (!$mod.TryStrToTime$1(pas.System.Copy(S,I + 1,S.length - I),{get: function () {
            return dttime;
          }, set: function (v) {
            dttime = v;
          }},$mod.TFormatSettings.$clone(aSettings))) return Result;
        Value.set($mod.ComposeDateTime(dtdate,dttime));
        Result = true;
      } else Result = $mod.TryStrToTime$1(S,Value,$mod.TFormatSettings.$clone(aSettings));
    } else Result = $mod.TryStrToDate$1(S,Value,aSettings);
    return Result;
  };
  this.StrToDateTimeDef = function (S, Defvalue) {
    var Result = 0.0;
    Result = $mod.StrToDateTimeDef$1(S,Defvalue,$mod.TFormatSettings.$clone($mod.FormatSettings));
    return Result;
  };
  this.StrToDateTimeDef$1 = function (S, Defvalue, aSettings) {
    var Result = 0.0;
    if (!$mod.TryStrToDateTime$1(S,{get: function () {
        return Result;
      }, set: function (v) {
        Result = v;
      }},aSettings)) Result = Defvalue;
    return Result;
  };
  this.FormatDateTime = function (FormatStr, DateTime) {
    var Result = "";
    Result = $mod.FormatDateTime$1(FormatStr,DateTime,$mod.FormatSettings);
    return Result;
  };
  this.FormatDateTime$1 = function (FormatStr, DateTime, aSettings) {
    var Result = "";
    function StoreStr(FormatStr, APos, Len) {
      Result = Result + pas.System.Copy(FormatStr,APos,Len);
    };
    function StoreString(AStr) {
      Result = Result + AStr;
    };
    function StoreInt(Value, Digits) {
      var S = "";
      S = $mod.IntToStr(Value);
      while (S.length < Digits) S = "0" + S;
      StoreString(S);
    };
    var Year = 0;
    var Month = 0;
    var Day = 0;
    var DayOfWeek = 0;
    var Hour = 0;
    var Minute = 0;
    var Second = 0;
    var MilliSecond = 0;
    function StoreFormat(FormatStr, Nesting, TimeFlag) {
      var Token = "\x00";
      var lastformattoken = "\x00";
      var prevlasttoken = "\x00";
      var Count = 0;
      var Clock12 = false;
      var tmp = 0;
      var isInterval = false;
      var P = 0;
      var FormatCurrent = 0;
      var FormatEnd = 0;
      if (Nesting > 1) return;
      FormatCurrent = 1;
      FormatEnd = FormatStr.length;
      Clock12 = false;
      isInterval = false;
      P = 1;
      while (P <= FormatEnd) {
        Token = FormatStr.charAt(P - 1);
        var $tmp = Token;
        if (($tmp === "'") || ($tmp === '"')) {
          P += 1;
          while ((P < FormatEnd) && (FormatStr.charAt(P - 1) !== Token)) P += 1;
        } else if (($tmp === "A") || ($tmp === "a")) {
          if (($mod.CompareText(pas.System.Copy(FormatStr,P,3),"A/P") === 0) || ($mod.CompareText(pas.System.Copy(FormatStr,P,4),"AMPM") === 0) || ($mod.CompareText(pas.System.Copy(FormatStr,P,5),"AM/PM") === 0)) {
            Clock12 = true;
            break;
          };
        };
        P += 1;
      };
      Token = "ÿ";
      lastformattoken = " ";
      prevlasttoken = "H";
      while (FormatCurrent <= FormatEnd) {
        Token = $mod.UpperCase(FormatStr.charAt(FormatCurrent - 1)).charAt(0);
        Count = 1;
        P = FormatCurrent + 1;
        var $tmp1 = Token;
        if (($tmp1 === "'") || ($tmp1 === '"')) {
          while ((P < FormatEnd) && (FormatStr.charAt(P - 1) !== Token)) P += 1;
          P += 1;
          Count = P - FormatCurrent;
          StoreStr(FormatStr,FormatCurrent + 1,Count - 2);
        } else if ($tmp1 === "A") {
          if ($mod.CompareText(pas.System.Copy(FormatStr,FormatCurrent,4),"AMPM") === 0) {
            Count = 4;
            if (Hour < 12) {
              StoreString(aSettings.TimeAMString)}
             else StoreString(aSettings.TimePMString);
          } else if ($mod.CompareText(pas.System.Copy(FormatStr,FormatCurrent,5),"AM/PM") === 0) {
            Count = 5;
            if (Hour < 12) {
              StoreStr(FormatStr,FormatCurrent,2)}
             else StoreStr(FormatStr,FormatCurrent + 3,2);
          } else if ($mod.CompareText(pas.System.Copy(FormatStr,FormatCurrent,3),"A/P") === 0) {
            Count = 3;
            if (Hour < 12) {
              StoreStr(FormatStr,FormatCurrent,1)}
             else StoreStr(FormatStr,FormatCurrent + 2,1);
          } else throw $mod.EConvertError.$create("Create$1",["Illegal character in format string"]);
        } else if ($tmp1 === "/") {
          StoreString(aSettings.DateSeparator);
        } else if ($tmp1 === ":") {
          StoreString(aSettings.TimeSeparator)}
         else if (($tmp1 === " ") || ($tmp1 === "C") || ($tmp1 === "D") || ($tmp1 === "H") || ($tmp1 === "M") || ($tmp1 === "N") || ($tmp1 === "S") || ($tmp1 === "T") || ($tmp1 === "Y") || ($tmp1 === "Z") || ($tmp1 === "F")) {
          while ((P <= FormatEnd) && ($mod.UpperCase(FormatStr.charAt(P - 1)) === Token)) P += 1;
          Count = P - FormatCurrent;
          var $tmp2 = Token;
          if ($tmp2 === " ") {
            StoreStr(FormatStr,FormatCurrent,Count)}
           else if ($tmp2 === "Y") {
            if (Count > 2) {
              StoreInt(Year,4)}
             else StoreInt(Year % 100,2);
          } else if ($tmp2 === "M") {
            if (isInterval && ((prevlasttoken === "H") || TimeFlag)) {
              StoreInt(Minute + ((Hour + (pas.System.Trunc(Math.abs(DateTime)) * 24)) * 60),0)}
             else if ((lastformattoken === "H") || TimeFlag) {
              if (Count === 1) {
                StoreInt(Minute,0)}
               else StoreInt(Minute,2);
            } else {
              var $tmp3 = Count;
              if ($tmp3 === 1) {
                StoreInt(Month,0)}
               else if ($tmp3 === 2) {
                StoreInt(Month,2)}
               else if ($tmp3 === 3) {
                StoreString(aSettings.ShortMonthNames[Month - 1])}
               else {
                StoreString(aSettings.LongMonthNames[Month - 1]);
              };
            };
          } else if ($tmp2 === "D") {
            var $tmp4 = Count;
            if ($tmp4 === 1) {
              StoreInt(Day,0)}
             else if ($tmp4 === 2) {
              StoreInt(Day,2)}
             else if ($tmp4 === 3) {
              StoreString(aSettings.ShortDayNames[DayOfWeek - 1])}
             else if ($tmp4 === 4) {
              StoreString(aSettings.LongDayNames[DayOfWeek - 1])}
             else if ($tmp4 === 5) {
              StoreFormat(aSettings.ShortDateFormat,Nesting + 1,false)}
             else {
              StoreFormat(aSettings.LongDateFormat,Nesting + 1,false);
            };
          } else if ($tmp2 === "H") {
            if (isInterval) {
              StoreInt(Hour + (pas.System.Trunc(Math.abs(DateTime)) * 24),0)}
             else if (Clock12) {
              tmp = Hour % 12;
              if (tmp === 0) tmp = 12;
              if (Count === 1) {
                StoreInt(tmp,0)}
               else StoreInt(tmp,2);
            } else {
              if (Count === 1) {
                StoreInt(Hour,0)}
               else StoreInt(Hour,2);
            }}
           else if ($tmp2 === "N") {
            if (isInterval) {
              StoreInt(Minute + ((Hour + (pas.System.Trunc(Math.abs(DateTime)) * 24)) * 60),0)}
             else if (Count === 1) {
              StoreInt(Minute,0)}
             else StoreInt(Minute,2)}
           else if ($tmp2 === "S") {
            if (isInterval) {
              StoreInt(Second + ((Minute + ((Hour + (pas.System.Trunc(Math.abs(DateTime)) * 24)) * 60)) * 60),0)}
             else if (Count === 1) {
              StoreInt(Second,0)}
             else StoreInt(Second,2)}
           else if ($tmp2 === "Z") {
            if (Count === 1) {
              StoreInt(MilliSecond,0)}
             else StoreInt(MilliSecond,3)}
           else if ($tmp2 === "T") {
            if (Count === 1) {
              StoreFormat(aSettings.ShortTimeFormat,Nesting + 1,true)}
             else StoreFormat(aSettings.LongTimeFormat,Nesting + 1,true)}
           else if ($tmp2 === "C") {
            StoreFormat(aSettings.ShortDateFormat,Nesting + 1,false);
            if ((Hour !== 0) || (Minute !== 0) || (Second !== 0)) {
              StoreString(" ");
              StoreFormat(aSettings.LongTimeFormat,Nesting + 1,true);
            };
          } else if ($tmp2 === "F") {
            StoreFormat(aSettings.ShortDateFormat,Nesting + 1,false);
            StoreString(" ");
            StoreFormat(aSettings.LongTimeFormat,Nesting + 1,true);
          };
          prevlasttoken = lastformattoken;
          lastformattoken = Token;
        } else {
          StoreString(Token);
        };
        FormatCurrent += Count;
      };
    };
    $mod.DecodeDateFully(DateTime,{get: function () {
        return Year;
      }, set: function (v) {
        Year = v;
      }},{get: function () {
        return Month;
      }, set: function (v) {
        Month = v;
      }},{get: function () {
        return Day;
      }, set: function (v) {
        Day = v;
      }},{get: function () {
        return DayOfWeek;
      }, set: function (v) {
        DayOfWeek = v;
      }});
    $mod.DecodeTime(DateTime,{get: function () {
        return Hour;
      }, set: function (v) {
        Hour = v;
      }},{get: function () {
        return Minute;
      }, set: function (v) {
        Minute = v;
      }},{get: function () {
        return Second;
      }, set: function (v) {
        Second = v;
      }},{get: function () {
        return MilliSecond;
      }, set: function (v) {
        MilliSecond = v;
      }});
    if (FormatStr !== "") {
      StoreFormat(FormatStr,0,false)}
     else StoreFormat("C",0,false);
    return Result;
  };
  this.CurrencyFormat = 0;
  this.NegCurrFormat = 0;
  this.CurrencyDecimals = 0;
  this.CurrencyString = "";
  this.FloattoCurr = function (Value) {
    var Result = 0;
    if (!$mod.TryFloatToCurr(Value,{get: function () {
        return Result;
      }, set: function (v) {
        Result = v;
      }})) throw $mod.EConvertError.$create("CreateFmt",[rtl.getResStr(pas.RTLConsts,"SInvalidCurrency"),pas.System.VarRecs(18,$mod.FloatToStr(Value))]);
    return Result;
  };
  this.TryFloatToCurr = function (Value, AResult) {
    var Result = false;
    Result = ((Value * 10000) >= $mod.MinCurrency) && ((Value * 10000) <= $mod.MaxCurrency);
    if (Result) AResult.set(rtl.trunc(Value * 10000));
    return Result;
  };
  this.CurrToStr = function (Value) {
    var Result = "";
    Result = $mod.FloatToStrF$1(Value / 10000,$mod.TFloatFormat.ffGeneral,-1,0,$mod.FormatSettings);
    return Result;
  };
  this.CurrToStr$1 = function (Value, aSettings) {
    var Result = "";
    Result = $mod.FloatToStrF$1(Value / 10000,$mod.TFloatFormat.ffGeneral,-1,0,aSettings);
    return Result;
  };
  this.StrToCurr = function (S) {
    var Result = 0;
    if (!$mod.TryStrToCurr(S,{get: function () {
        return Result;
      }, set: function (v) {
        Result = v;
      }})) throw $mod.EConvertError.$create("CreateFmt",[rtl.getResStr(pas.RTLConsts,"SInvalidCurrency"),pas.System.VarRecs(18,S)]);
    return Result;
  };
  this.StrToCurr$1 = function (S, aSettings) {
    var Result = 0;
    if (!$mod.TryStrToCurr$1(S,{get: function () {
        return Result;
      }, set: function (v) {
        Result = v;
      }},aSettings)) throw $mod.EConvertError.$create("CreateFmt",[rtl.getResStr(pas.RTLConsts,"SInvalidCurrency"),pas.System.VarRecs(18,S)]);
    return Result;
  };
  this.TryStrToCurr = function (S, Value) {
    var Result = false;
    var D = 0.0;
    Result = $mod.TryStrToFloat$3(S,{get: function () {
        return D;
      }, set: function (v) {
        D = v;
      }},$mod.FormatSettings);
    if (Result) Value.set(rtl.trunc(D * 10000));
    return Result;
  };
  this.TryStrToCurr$1 = function (S, Value, aSettings) {
    var Result = false;
    var D = 0.0;
    Result = $mod.TryStrToFloat$3(S,{get: function () {
        return D;
      }, set: function (v) {
        D = v;
      }},aSettings);
    if (Result) Value.set(rtl.trunc(D * 10000));
    return Result;
  };
  this.StrToCurrDef = function (S, Default) {
    var Result = 0;
    var R = 0;
    if ($mod.TryStrToCurr$1(S,{get: function () {
        return R;
      }, set: function (v) {
        R = v;
      }},$mod.FormatSettings)) {
      Result = R}
     else Result = Default;
    return Result;
  };
  this.StrToCurrDef$1 = function (S, Default, aSettings) {
    var Result = 0;
    var R = 0;
    if ($mod.TryStrToCurr$1(S,{get: function () {
        return R;
      }, set: function (v) {
        R = v;
      }},aSettings)) {
      Result = R}
     else Result = Default;
    return Result;
  };
  this.$rtti.$DynArray("TPathStrArray",{eltype: rtl.string});
  this.ChangeFileExt = function (FileName, Extension) {
    var Result = "";
    var i = 0;
    var EndSep = {};
    var SOF = false;
    i = FileName.length;
    EndSep = rtl.unionSet(rtl.unionSet(pas.System.AllowDirectorySeparators,pas.System.AllowDriveSeparators),rtl.createSet(pas.System.ExtensionSeparator.charCodeAt()));
    while ((i > 0) && !(FileName.charCodeAt(i - 1) in EndSep)) i -= 1;
    if ((i === 0) || (FileName.charAt(i - 1) !== pas.System.ExtensionSeparator)) {
      i = FileName.length + 1}
     else {
      SOF = (i === 1) || (FileName.charCodeAt(i - 1 - 1) in pas.System.AllowDirectorySeparators);
      if (SOF && !pas.System.FirstDotAtFileNameStartIsExtension) i = FileName.length + 1;
    };
    Result = pas.System.Copy(FileName,1,i - 1) + Extension;
    return Result;
  };
  this.ExtractFilePath = function (FileName) {
    var Result = "";
    var i = 0;
    var EndSep = {};
    i = FileName.length;
    EndSep = rtl.unionSet(pas.System.AllowDirectorySeparators,pas.System.AllowDriveSeparators);
    while ((i > 0) && !$mod.CharInSet$1(FileName.charAt(i - 1),EndSep)) i -= 1;
    if (i > 0) {
      Result = pas.System.Copy(FileName,1,i)}
     else Result = "";
    return Result;
  };
  this.ExtractFileDrive = function (FileName) {
    var Result = "";
    var i = 0;
    var l = 0;
    Result = "";
    l = FileName.length;
    if (l < 2) return Result;
    if ($mod.CharInSet$1(FileName.charAt(1),pas.System.AllowDriveSeparators)) {
      Result = pas.System.Copy(FileName,1,2)}
     else if ($mod.CharInSet$1(FileName.charAt(0),pas.System.AllowDirectorySeparators) && $mod.CharInSet$1(FileName.charAt(1),pas.System.AllowDirectorySeparators)) {
      i = 2;
      while ((i < l) && !$mod.CharInSet$1(FileName.charAt((i + 1) - 1),pas.System.AllowDirectorySeparators)) i += 1;
      i += 1;
      while ((i < l) && !$mod.CharInSet$1(FileName.charAt((i + 1) - 1),pas.System.AllowDirectorySeparators)) i += 1;
      Result = pas.System.Copy(FileName,1,i);
    };
    return Result;
  };
  this.ExtractFileName = function (FileName) {
    var Result = "";
    var i = 0;
    var EndSep = {};
    i = FileName.length;
    EndSep = rtl.unionSet(pas.System.AllowDirectorySeparators,pas.System.AllowDriveSeparators);
    while ((i > 0) && !$mod.CharInSet$1(FileName.charAt(i - 1),EndSep)) i -= 1;
    Result = pas.System.Copy(FileName,i + 1,2147483647);
    return Result;
  };
  this.ExtractFileExt = function (FileName) {
    var Result = "";
    var i = 0;
    var EndSep = {};
    var SOF = false;
    Result = "";
    i = FileName.length;
    EndSep = rtl.unionSet(rtl.unionSet(pas.System.AllowDirectorySeparators,pas.System.AllowDriveSeparators),rtl.createSet(pas.System.ExtensionSeparator.charCodeAt()));
    while ((i > 0) && !$mod.CharInSet$1(FileName.charAt(i - 1),EndSep)) i -= 1;
    if ((i > 0) && (FileName.charAt(i - 1) === pas.System.ExtensionSeparator)) {
      SOF = (i === 1) || (FileName.charCodeAt(i - 1 - 1) in pas.System.AllowDirectorySeparators);
      if (!SOF || pas.System.FirstDotAtFileNameStartIsExtension) Result = pas.System.Copy(FileName,i,2147483647);
    } else Result = "";
    return Result;
  };
  this.ExtractFileDir = function (FileName) {
    var Result = "";
    var i = 0;
    var EndSep = {};
    i = FileName.length;
    EndSep = rtl.unionSet(pas.System.AllowDirectorySeparators,pas.System.AllowDriveSeparators);
    while ((i > 0) && !$mod.CharInSet$1(FileName.charAt(i - 1),EndSep)) i -= 1;
    if ((i > 1) && $mod.CharInSet$1(FileName.charAt(i - 1),pas.System.AllowDirectorySeparators) && !$mod.CharInSet$1(FileName.charAt(i - 1 - 1),EndSep)) i -= 1;
    Result = pas.System.Copy(FileName,1,i);
    return Result;
  };
  this.ExtractRelativepath = function (BaseName, DestName) {
    var Result = "";
    var OneLevelBack = "";
    var Source = "";
    var Dest = "";
    var Sc = 0;
    var Dc = 0;
    var I = 0;
    var J = 0;
    var SD = [];
    var DD = [];
    OneLevelBack = ".." + pas.System.PathDelim;
    if ($mod.UpperCase($mod.ExtractFileDrive(BaseName)) !== $mod.UpperCase($mod.ExtractFileDrive(DestName))) {
      Result = DestName;
      return Result;
    };
    Source = $mod.ExcludeTrailingPathDelimiter($mod.ExtractFilePath(BaseName));
    Dest = $mod.ExcludeTrailingPathDelimiter($mod.ExtractFilePath(DestName));
    SD = $mod.GetDirs(Source);
    Sc = rtl.length(SD);
    DD = $mod.GetDirs(Dest);
    Dc = rtl.length(SD);
    I = 0;
    while ((I < Dc) && (I < Sc)) {
      if ($mod.SameText(DD[I],SD[I])) {
        I += 1}
       else break;
    };
    Result = "";
    for (var $l = I, $end = Sc; $l <= $end; $l++) {
      J = $l;
      Result = Result + OneLevelBack;
    };
    for (var $l1 = I, $end1 = Dc; $l1 <= $end1; $l1++) {
      J = $l1;
      Result = Result + DD[J] + pas.System.PathDelim;
    };
    Result = Result + $mod.ExtractFileName(DestName);
    return Result;
  };
  this.IncludeTrailingPathDelimiter = function (Path) {
    var Result = "";
    var l = 0;
    Result = Path;
    l = Result.length;
    if ((l === 0) || !$mod.CharInSet$1(Result.charAt(l - 1),pas.System.AllowDirectorySeparators)) Result = Result + pas.System.PathDelim;
    return Result;
  };
  this.ExcludeTrailingPathDelimiter = function (Path) {
    var Result = "";
    var L = 0;
    L = Path.length;
    if ((L > 0) && $mod.CharInSet$1(Path.charAt(L - 1),pas.System.AllowDirectorySeparators)) L -= 1;
    Result = pas.System.Copy(Path,1,L);
    return Result;
  };
  this.IncludeLeadingPathDelimiter = function (Path) {
    var Result = "";
    var l = 0;
    Result = Path;
    l = Result.length;
    if ((l === 0) || !$mod.CharInSet$1(Result.charAt(0),pas.System.AllowDirectorySeparators)) Result = pas.System.PathDelim + Result;
    return Result;
  };
  this.ExcludeLeadingPathDelimiter = function (Path) {
    var Result = "";
    var L = 0;
    Result = Path;
    L = Result.length;
    if ((L > 0) && $mod.CharInSet$1(Result.charAt(0),pas.System.AllowDirectorySeparators)) pas.System.Delete({get: function () {
        return Result;
      }, set: function (v) {
        Result = v;
      }},1,1);
    return Result;
  };
  this.IsPathDelimiter = function (Path, Index) {
    var Result = false;
    Result = (Index > 0) && (Index <= Path.length) && $mod.CharInSet$1(Path.charAt(Index - 1),pas.System.AllowDirectorySeparators);
    return Result;
  };
  this.SetDirSeparators = function (FileName) {
    var Result = "";
    var I = 0;
    Result = FileName;
    for (var $l = 1, $end = Result.length; $l <= $end; $l++) {
      I = $l;
      if ($mod.CharInSet$1(Result.charAt(I - 1),pas.System.AllowDirectorySeparators)) Result = rtl.setCharAt(Result,I - 1,pas.System.PathDelim);
    };
    return Result;
  };
  this.GetDirs = function (DirName) {
    var Result = [];
    var I = 0;
    var J = 0;
    var L = 0;
    var D = "";
    I = 1;
    J = 0;
    L = 0;
    Result = rtl.arraySetLength(Result,"",DirName.length);
    while (I <= DirName.length) {
      if ($mod.CharInSet$1(DirName.charAt(I - 1),pas.System.AllowDirectorySeparators)) {
        D = pas.System.Copy(DirName,J + 1,J - I);
        if (D !== "") {
          Result[L] = D;
          L += 1;
        };
        J = I;
      };
      I += 1;
    };
    Result = rtl.arraySetLength(Result,"",L);
    return Result;
  };
  this.ConcatPaths = function (Paths) {
    var Result = "";
    var I = 0;
    if (rtl.length(Paths) > 0) {
      Result = Paths[0];
      for (var $l = 1, $end = rtl.length(Paths) - 1; $l <= $end; $l++) {
        I = $l;
        Result = $mod.IncludeTrailingPathDelimiter(Result) + $mod.ExcludeLeadingPathDelimiter(Paths[I]);
      };
    } else Result = "";
    return Result;
  };
  this.GUID_NULL = pas.System.TGuid.$clone({D1: 0x00000000, D2: 0x0000, D3: 0x0000, D4: [0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00]});
  this.Supports = function (Instance, AClass, Obj) {
    var Result = false;
    Result = (Instance !== null) && (Instance.QueryInterface(pas.System.IObjectInstance,Obj) === 0) && Obj.get().$class.InheritsFrom(AClass);
    return Result;
  };
  this.Supports$1 = function (Instance, IID, Intf) {
    var Result = false;
    Result = (Instance !== null) && (Instance.QueryInterface(IID,Intf) === 0);
    return Result;
  };
  this.Supports$2 = function (Instance, IID, Intf) {
    var Result = false;
    Result = (Instance !== null) && Instance.GetInterface(IID,Intf);
    return Result;
  };
  this.Supports$3 = function (Instance, IID, Intf) {
    var Result = false;
    Result = (Instance !== null) && Instance.GetInterfaceByStr(IID,Intf);
    return Result;
  };
  this.Supports$4 = function (Instance, AClass) {
    var Result = false;
    var Temp = null;
    Result = $mod.Supports(Instance,AClass,{get: function () {
        return Temp;
      }, set: function (v) {
        Temp = v;
      }});
    return Result;
  };
  this.Supports$5 = function (Instance, IID) {
    var Result = false;
    var Temp = null;
    try {
      Result = $mod.Supports$1(Instance,IID,{get: function () {
          return Temp;
        }, set: function (v) {
          Temp = v;
        }});
    } finally {
      rtl._Release(Temp);
    };
    return Result;
  };
  this.Supports$6 = function (Instance, IID) {
    var Result = false;
    var Temp = null;
    Result = $mod.Supports$2(Instance,IID,{get: function () {
        return Temp;
      }, set: function (v) {
        Temp = v;
      }});
    if (Temp && Temp.$kind==='com') Temp._Release();
    return Result;
  };
  this.Supports$7 = function (Instance, IID) {
    var Result = false;
    var Temp = null;
    Result = $mod.Supports$3(Instance,IID,{get: function () {
        return Temp;
      }, set: function (v) {
        Temp = v;
      }});
    if (Temp && Temp.$kind==='com') Temp._Release();
    return Result;
  };
  this.Supports$8 = function (AClass, IID) {
    var Result = false;
    var maps = undefined;
    if (AClass === null) return false;
    maps = AClass["$intfmaps"];
    if (!maps) return false;
    if (maps[$mod.GUIDToString(IID)]) return true;
    Result = false;
    return Result;
  };
  this.Supports$9 = function (AClass, IID) {
    var Result = false;
    var maps = undefined;
    if (AClass === null) return false;
    maps = AClass["$intfmaps"];
    if (!maps) return false;
    if (maps[$mod.UpperCase(IID)]) return true;
    Result = false;
    return Result;
  };
  this.TryStringToGUID = function (s, Guid) {
    var Result = false;
    var re = null;
    if (s.length !== 38) return false;
    re = new RegExp("^\\{[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}\\}$");
    Result = re.test(s);
    if (!Result) {
      Guid.D1 = 0;
      return Result;
    };
    rtl.strToGUIDR(s,Guid);
    Result = true;
    return Result;
  };
  this.StringToGUID = function (S) {
    var Result = pas.System.TGuid.$new();
    if (!$mod.TryStringToGUID(S,Result)) throw $mod.EConvertError.$create("CreateFmt",[rtl.getResStr(pas.RTLConsts,"SInvalidGUID"),pas.System.VarRecs(18,S)]);
    return Result;
  };
  this.GUIDToString = function (guid) {
    var Result = "";
    Result = rtl.guidrToStr(guid);
    return Result;
  };
  this.IsEqualGUID = function (guid1, guid2) {
    var Result = false;
    var i = 0;
    if ((guid1.D1 !== guid2.D1) || (guid1.D2 !== guid2.D2) || (guid1.D3 !== guid2.D3)) return false;
    for (i = 0; i <= 7; i++) if (guid1.D4[i] !== guid2.D4[i]) return false;
    Result = true;
    return Result;
  };
  this.GuidCase = function (guid, List) {
    var Result = 0;
    for (var $l = rtl.length(List) - 1; $l >= 0; $l--) {
      Result = $l;
      if ($mod.IsEqualGUID(guid,List[Result])) return Result;
    };
    Result = -1;
    return Result;
  };
  this.CreateGUID = function (GUID) {
    var Result = 0;
    function R(B) {
      var Result = 0;
      var v = 0;
      v = pas.System.Random(256);
      while (B > 1) {
        v = (v * 256) + pas.System.Random(256);
        B -= 1;
      };
      Result = v;
      return Result;
    };
    var I = 0;
    Result = 0;
    GUID.D1 = R(4);
    GUID.D2 = R(2);
    GUID.D3 = R(2);
    for (I = 0; I <= 7; I++) GUID.D4[I] = R(1);
    return Result;
  };
  this.EncodeHTMLEntities = function (S) {
    var Result = "";
    Result = "";
    if (S === "") return Result;
    return S.replace(/[\u00A0-\u9999<>\&]/gim, function(i) {
      return '&#'+i.charCodeAt(0)+';';
    });
    return Result;
  };
  this.$rtti.$DynArray("TCharArray",{eltype: rtl.char});
  this.$rtti.$Int("TByteBitIndex",{minvalue: 0, maxvalue: 7, ordtype: 1});
  this.$rtti.$Int("TShortIntBitIndex",{minvalue: 0, maxvalue: 7, ordtype: 1});
  this.$rtti.$Int("TWordBitIndex",{minvalue: 0, maxvalue: 15, ordtype: 1});
  this.$rtti.$Int("TSmallIntBitIndex",{minvalue: 0, maxvalue: 15, ordtype: 1});
  this.$rtti.$Int("TCardinalBitIndex",{minvalue: 0, maxvalue: 31, ordtype: 1});
  this.$rtti.$Int("TIntegerBitIndex",{minvalue: 0, maxvalue: 31, ordtype: 1});
  this.$rtti.$Int("TQwordBitIndex",{minvalue: 0, maxvalue: 52, ordtype: 1});
  this.$rtti.$Int("TInt64BitIndex",{minvalue: 0, maxvalue: 52, ordtype: 1});
  this.$rtti.$Int("TNativeIntBitIndex",{minvalue: 0, maxvalue: 52, ordtype: 1});
  this.$rtti.$Int("TNativeUIntBitIndex",{minvalue: 0, maxvalue: 52, ordtype: 1});
  this.CPUEndian = this.TEndian.Big;
  rtl.createHelper(this,"TGuidHelper",null,function () {
    this.Create = function (Src, BigEndian) {
      var Result = pas.System.TGuid.$new();
      Result.$assign(Src);
      if (!BigEndian) {
        Result.D1 = $mod.SwapEndian$1(Result.D1);
        Result.D2 = $mod.SwapEndian(Result.D2);
        Result.D3 = $mod.SwapEndian(Result.D3);
      };
      return Result;
    };
    this.Create$1 = function (Buf, AStartIndex, BigEndian) {
      var Result = pas.System.TGuid.$new();
      var A = 0;
      var B = 0;
      var C = 0;
      var V = null;
      V = new DataView(Buf);
      if (BigEndian) {
        A = V.getUint32(AStartIndex);
        B = V.getUint16(AStartIndex + 4);
        C = V.getUint16(AStartIndex + 6);
      } else {
        A = $mod.SwapEndian$1(V.getUint32(AStartIndex));
        B = $mod.SwapEndian(V.getUint16(AStartIndex + 4));
        C = $mod.SwapEndian(V.getUint16(AStartIndex + 6));
      };
      Result.$assign($mod.TGuidHelper.Create$7(A,B,C,V.getUint8(AStartIndex + 8),V.getUint8(AStartIndex + 9),V.getUint8(AStartIndex + 10),V.getUint8(AStartIndex + 11),V.getUint8(AStartIndex + 12),V.getUint8(AStartIndex + 13),V.getUint8(AStartIndex + 14),V.getUint8(AStartIndex + 15)));
      return Result;
    };
    this.Create$2 = function (Data, AStartIndex, BigEndian) {
      var Result = pas.System.TGuid.$new();
      var D = null;
      if ((rtl.length(Data) - AStartIndex) < 16) throw $mod.EArgumentException.$create("CreateFmt",["The length of a GUID array must be at least %d",[]]);
      D = Uint8Array.from(Data);
      Result.$assign($mod.TGuidHelper.Create$1(D.buffer,AStartIndex,BigEndian));
      return Result;
    };
    this.Create$3 = function (B, DataEndian) {
      var Result = pas.System.TGuid.$new();
      Result.$assign($mod.TGuidHelper.Create$4(B,0,DataEndian));
      return Result;
    };
    this.Create$4 = function (B, AStartIndex, DataEndian) {
      var Result = pas.System.TGuid.$new();
      if ((rtl.length(B) - AStartIndex) < 16) throw $mod.EArgumentException.$create("CreateFmt",["The length of a GUID array must be at least %d",[]]);
      Result.$assign($mod.TGuidHelper.Create$2(B,AStartIndex,DataEndian === $mod.TEndian.Big));
      return Result;
    };
    this.Create$5 = function (S) {
      var Result = pas.System.TGuid.$new();
      Result.$assign($mod.StringToGUID(S));
      return Result;
    };
    this.Create$6 = function (A, B, C, D) {
      var Result = pas.System.TGuid.$new();
      if (rtl.length(D) !== 8) throw $mod.EArgumentException.$create("CreateFmt",["The length of a GUID array must be %d",[]]);
      Result.$assign($mod.TGuidHelper.Create$7(A >>> 0,B & 65535,C & 65535,D[0],D[1],D[2],D[3],D[4],D[5],D[6],D[7]));
      return Result;
    };
    this.Create$7 = function (A, B, C, D, E, F, G, H, I, J, K) {
      var Result = pas.System.TGuid.$new();
      Result.D1 = A;
      Result.D2 = B;
      Result.D3 = C;
      Result.D4[0] = D;
      Result.D4[1] = E;
      Result.D4[2] = F;
      Result.D4[3] = G;
      Result.D4[4] = H;
      Result.D4[5] = I;
      Result.D4[6] = J;
      Result.D4[7] = K;
      return Result;
    };
    this.NewGuid = function () {
      var Result = pas.System.TGuid.$new();
      $mod.CreateGUID(Result);
      return Result;
    };
    this.Empty = function () {
      var Result = pas.System.TGuid.$new();
      Result.$assign(pas.System.TGuid.$new());
      return Result;
    };
    this.IsEmpty = function () {
      var Result = false;
      var lCount = 0;
      Result = (this.D1 === 0) && (this.D2 === 0) && (this.D3 === 0);
      if (!Result) return Result;
      for (lCount = 0; lCount <= 7; lCount++) Result = Result && (this.D4[lCount] === 0);
      return Result;
    };
    this.ToByteArray = function (DataEndian) {
      var Result = [];
      var D = null;
      var V = null;
      var I = 0;
      D = new Uint8Array(16);
      V = new DataView(D.buffer);
      V.setUint32(0,this.D1,DataEndian === $mod.TEndian.Little);
      V.setUint16(4,this.D2,DataEndian === $mod.TEndian.Little);
      V.setUint16(6,this.D3,DataEndian === $mod.TEndian.Little);
      for (I = 0; I <= 7; I++) V.setUint8(8 + I,this.D4[I]);
      Result = rtl.arraySetLength(Result,0,16);
      for (I = 0; I <= 15; I++) Result[I] = V.getUint8(I);
      return Result;
    };
    this.ToString = function (SkipBrackets) {
      var Result = "";
      Result = $mod.GUIDToString(this);
      if (SkipBrackets) Result = pas.System.Copy(Result,2,Result.length - 2);
      return Result;
    };
  });
  this.TStringSplitOptions = {"0": "None", None: 0, "1": "ExcludeEmpty", ExcludeEmpty: 1};
  this.$rtti.$Enum("TStringSplitOptions",{minvalue: 0, maxvalue: 1, ordtype: 1, enumtype: this.TStringSplitOptions});
  rtl.createHelper(this,"TStringHelper",null,function () {
    this.Empty = "";
    this.GetChar = function (AIndex) {
      var Result = "\x00";
      Result = this.get().charAt((AIndex + 1) - 1);
      return Result;
    };
    this.GetLength = function () {
      var Result = 0;
      Result = this.get().length;
      return Result;
    };
    this.Set_Length = function (AValue) {
      this.set(rtl.strSetLength(this.get(),AValue));
    };
    this.Compare = function (A, B) {
      var Result = 0;
      Result = $mod.TStringHelper.Compare$5(A,0,B,0,B.length,{});
      return Result;
    };
    this.Compare$1 = function (A, B, IgnoreCase) {
      var Result = 0;
      if (IgnoreCase) {
        Result = $mod.TStringHelper.Compare$2(A,B,rtl.createSet(pas.System.TCompareOption.coIgnoreCase))}
       else Result = $mod.TStringHelper.Compare$2(A,B,{});
      return Result;
    };
    this.Compare$2 = function (A, B, Options) {
      var Result = 0;
      Result = $mod.TStringHelper.Compare$5(A,0,B,0,B.length,rtl.refSet(Options));
      return Result;
    };
    this.Compare$3 = function (A, IndexA, B, IndexB, ALen) {
      var Result = 0;
      Result = $mod.TStringHelper.Compare$5(A,IndexA,B,IndexB,ALen,{});
      return Result;
    };
    this.Compare$4 = function (A, IndexA, B, IndexB, ALen, IgnoreCase) {
      var Result = 0;
      if (IgnoreCase) {
        Result = $mod.TStringHelper.Compare$5(A,IndexA,B,IndexB,ALen,rtl.createSet(pas.System.TCompareOption.coIgnoreCase))}
       else Result = $mod.TStringHelper.Compare$5(A,IndexA,B,IndexB,ALen,{});
      return Result;
    };
    this.Compare$5 = function (A, IndexA, B, IndexB, ALen, Options) {
      var Result = 0;
      var AL = "";
      var BL = "";
      var lOptions = pas.JS.TLocaleCompareOptions.$new();
      AL = pas.System.Copy(A,IndexA + 1,ALen);
      BL = pas.System.Copy(B,IndexB + 1,ALen);
      if (pas.System.TCompareOption.coDigitAsNumbers in Options) lOptions.numeric = true;
      if (pas.System.TCompareOption.coIgnoreCase in Options) {
        Result = $mod.TStringHelper.UpperCase(AL).localeCompare($mod.TStringHelper.UpperCase(BL),"default",pas.JS.TLocaleCompareOptions.$clone(lOptions))}
       else Result = AL.localeCompare(BL,"default",pas.JS.TLocaleCompareOptions.$clone(lOptions));
      return Result;
    };
    this.CompareOrdinal = function (A, B) {
      var Result = 0;
      var L = 0;
      L = B.length;
      if (L > A.length) L = A.length;
      Result = $mod.TStringHelper.CompareOrdinal$1(A,0,B,0,L);
      return Result;
    };
    this.CompareOrdinal$1 = function (A, IndexA, B, IndexB, ALen) {
      var Result = 0;
      var I = 0;
      var M = 0;
      M = A.length - IndexA;
      if (M > (B.length - IndexB)) M = B.length - IndexB;
      if (M > ALen) M = ALen;
      I = 0;
      Result = 0;
      while ((Result === 0) && (I < M)) {
        Result = A.charCodeAt(IndexA + I) - B.charCodeAt(IndexB + I);
        I += 1;
      };
      return Result;
    };
    this.CompareText = function (A, B) {
      var Result = 0;
      Result = $mod.CompareText(A,B);
      return Result;
    };
    this.Copy = function (Str) {
      var Result = "";
      Result = Str;
      return Result;
    };
    this.Create = function (AChar, ACount) {
      var Result = "";
      Result = pas.System.StringOfChar(AChar,ACount);
      return Result;
    };
    this.Create$1 = function (AValue) {
      var Result = "";
      Result = $mod.TStringHelper.Create$2(AValue,0,rtl.length(AValue));
      return Result;
    };
    this.Create$2 = function (AValue, StartIndex, ALen) {
      var Result = "";
      var I = 0;
      Result = rtl.strSetLength(Result,ALen);
      for (var $l = 1, $end = ALen; $l <= $end; $l++) {
        I = $l;
        Result = rtl.setCharAt(Result,I - 1,AValue[(StartIndex + I) - 1]);
      };
      return Result;
    };
    this.EndsText = function (ASubText, AText) {
      var Result = false;
      Result = (ASubText !== "") && ($mod.CompareText(pas.System.Copy(AText,(AText.length - ASubText.length) + 1,ASubText.length),ASubText) === 0);
      return Result;
    };
    this.Equals = function (a, b) {
      var Result = false;
      Result = a === b;
      return Result;
    };
    this.Format = function (AFormat, args) {
      var Result = "";
      Result = $mod.Format(AFormat,args);
      return Result;
    };
    this.IsNullOrEmpty = function (AValue) {
      var Result = false;
      Result = AValue.length === 0;
      return Result;
    };
    this.IsNullOrWhiteSpace = function (AValue) {
      var Result = false;
      Result = $mod.Trim(AValue).length === 0;
      return Result;
    };
    this.Join = function (Separator, Values) {
      var Result = "";
      Result = Values.join(Separator);
      return Result;
    };
    this.Join$1 = function (Separator, Values) {
      var Result = "";
      Result = Values.join(Separator);
      return Result;
    };
    this.Join$2 = function (Separator, Values, StartIndex, ACount) {
      var Result = "";
      var VLen = 0;
      VLen = rtl.length(Values) - 1;
      if ((ACount < 0) || ((StartIndex > 0) && (StartIndex > VLen))) throw $mod.ERangeError.$create("Create$1",[rtl.getResStr(pas.RTLConsts,"SRangeError")]);
      if ((ACount === 0) || (VLen < 0)) {
        Result = ""}
       else Result = Values.slice(StartIndex,StartIndex + ACount).join(Separator);
      return Result;
    };
    this.LowerCase = function (S) {
      var Result = "";
      Result = $mod.LowerCase(S);
      return Result;
    };
    this.Parse = function (AValue) {
      var Result = "";
      Result = $mod.BoolToStr(AValue,false);
      return Result;
    };
    this.Parse$1 = function (AValue) {
      var Result = "";
      Result = $mod.FloatToStr(AValue);
      return Result;
    };
    this.Parse$2 = function (AValue) {
      var Result = "";
      Result = $mod.IntToStr(AValue);
      return Result;
    };
    this.Parse$3 = function (AValue) {
      var Result = "";
      Result = $mod.IntToStr(AValue);
      return Result;
    };
    this.ToBoolean = function (S) {
      var Result = false;
      Result = $mod.StrToBool(S);
      return Result;
    };
    this.ToDouble = function (S) {
      var Result = 0.0;
      Result = $mod.StrToFloat(S);
      return Result;
    };
    this.ToExtended = function (S) {
      var Result = 0.0;
      Result = $mod.StrToFloat(S);
      return Result;
    };
    this.ToNativeInt = function (S) {
      var Result = 0;
      Result = $mod.StrToInt64(S);
      return Result;
    };
    this.ToInteger = function (S) {
      var Result = 0;
      Result = $mod.StrToInt(S);
      return Result;
    };
    this.UpperCase = function (S) {
      var Result = "";
      Result = $mod.UpperCase(S);
      return Result;
    };
    this.ToCharArray = function (S) {
      var Result = [];
      var I = 0;
      var Len = 0;
      Len = S.length;
      Result = rtl.arraySetLength(Result,"\x00",Len);
      for (var $l = 1, $end = Len; $l <= $end; $l++) {
        I = $l;
        Result[I - 1] = S.charAt(I - 1);
      };
      return Result;
    };
    this.CompareTo = function (B) {
      var Result = 0;
      Result = $mod.TStringHelper.Compare(this.get(),B);
      return Result;
    };
    this.Contains = function (AValue) {
      var Result = false;
      Result = (AValue !== "") && (pas.System.Pos(AValue,this.get()) > 0);
      return Result;
    };
    this.CountChar = function (C) {
      var Result = 0;
      var S = "\x00";
      Result = 0;
      for (var $in = this.get(), $l = 0, $end = $in.length - 1; $l <= $end; $l++) {
        S = $in.charAt($l);
        if (S === C) Result += 1;
      };
      return Result;
    };
    this.DeQuotedString = function () {
      var Result = "";
      Result = $mod.TStringHelper.DeQuotedString$1.call(this,"'");
      return Result;
    };
    this.DeQuotedString$1 = function (AQuoteChar) {
      var Result = "";
      var L = 0;
      var I = 0;
      var Res = [];
      var PS = 0;
      var PD = 0;
      var IsQuote = false;
      L = this.get().length;
      if ((L < 2) || !((this.get().charAt(0) === AQuoteChar) && (this.get().charAt(L - 1) === AQuoteChar))) return this.get();
      Res = rtl.arraySetLength(Res,"\x00",L);
      IsQuote = false;
      PS = 2;
      PD = 1;
      for (var $l = 2, $end = L - 1; $l <= $end; $l++) {
        I = $l;
        if (this.get().charAt(PS - 1) === AQuoteChar) {
          IsQuote = !IsQuote;
          if (!IsQuote) {
            Result = rtl.setCharAt(Result,PD - 1,this.get().charAt(PS - 1));
            PD += 1;
          };
        } else {
          if (IsQuote) IsQuote = false;
          Result = rtl.setCharAt(Result,PD - 1,this.get().charAt(PS - 1));
          PD += 1;
        };
        PS += 1;
      };
      Result = rtl.strSetLength(Result,PD - 1);
      return Result;
    };
    this.EndsWith = function (AValue) {
      var Result = false;
      Result = $mod.TStringHelper.EndsWith$1.call(this,AValue,false);
      return Result;
    };
    this.EndsWith$1 = function (AValue, IgnoreCase) {
      var Result = false;
      var L = 0;
      var S = "";
      L = AValue.length;
      Result = L === 0;
      if (!Result) {
        S = pas.System.Copy(this.get(),($mod.TStringHelper.GetLength.call(this) - L) + 1,L);
        Result = S.length === L;
        if (Result) if (IgnoreCase) {
          Result = $mod.TStringHelper.CompareText(S,AValue) === 0}
         else Result = S === AValue;
      };
      return Result;
    };
    this.Equals$1 = function (AValue) {
      var Result = false;
      Result = this.get() === AValue;
      return Result;
    };
    this.Format$1 = function (args) {
      var Result = "";
      Result = $mod.Format(this.get(),args);
      return Result;
    };
    this.GetHashCode = function () {
      var Result = 0;
      var P = 0;
      var pmax = 0;
      var L = null;
      L = this.get();
      Result = 0;
      P = 1;
      pmax = $mod.TStringHelper.GetLength.call(this) + 1;
      while (P < pmax) {
        Result = rtl.xor(((Result << 5) - Result) >>> 0,L.charCodeAt(P));
        P += 1;
      };
      return Result;
    };
    this.IndexOf = function (AValue) {
      var Result = 0;
      Result = $mod.TStringHelper.IndexOf$4.call(this,AValue,0,$mod.TStringHelper.GetLength.call(this));
      return Result;
    };
    this.IndexOf$1 = function (AValue) {
      var Result = 0;
      Result = $mod.TStringHelper.IndexOf$5.call(this,AValue,0,$mod.TStringHelper.GetLength.call(this));
      return Result;
    };
    this.IndexOf$2 = function (AValue, StartIndex) {
      var Result = 0;
      Result = $mod.TStringHelper.IndexOf$4.call(this,AValue,StartIndex,$mod.TStringHelper.GetLength.call(this));
      return Result;
    };
    this.IndexOf$3 = function (AValue, StartIndex) {
      var Result = 0;
      Result = $mod.TStringHelper.IndexOf$5.call(this,AValue,StartIndex,$mod.TStringHelper.GetLength.call(this));
      return Result;
    };
    this.IndexOf$4 = function (AValue, StartIndex, ACount) {
      var Result = 0;
      var S = "";
      S = pas.System.Copy(this.get(),StartIndex + 1,ACount);
      Result = pas.System.Pos(AValue,S) - 1;
      if (Result !== -1) Result = Result + StartIndex;
      return Result;
    };
    this.IndexOf$5 = function (AValue, StartIndex, ACount) {
      var Result = 0;
      var S = "";
      S = pas.System.Copy(this.get(),StartIndex + 1,ACount);
      Result = pas.System.Pos(AValue,S) - 1;
      if (Result !== -1) Result = Result + StartIndex;
      return Result;
    };
    this.IndexOfUnQuoted = function (AValue, StartQuote, EndQuote, StartIndex) {
      var $Self = this;
      var Result = 0;
      var LV = 0;
      var S = "";
      function MatchAt(I) {
        var Result = false;
        var J = 0;
        J = 1;
        do {
          Result = S.charAt((I + J) - 1 - 1) === AValue.charAt(J - 1);
          J += 1;
        } while (!(!Result || (J > LV)));
        return Result;
      };
      var I = 0;
      var L = 0;
      var Q = 0;
      S = $Self.get();
      Result = -1;
      LV = AValue.length;
      L = ($mod.TStringHelper.GetLength.call($Self) - LV) + 1;
      if (L < 0) L = 0;
      I = StartIndex + 1;
      Q = 0;
      if (StartQuote === EndQuote) {
        while ((Result === -1) && (I <= L)) {
          if (S.charAt(I - 1) === StartQuote) Q = 1 - Q;
          if ((Q === 0) && MatchAt(I)) Result = I - 1;
          I += 1;
        };
      } else {
        while ((Result === -1) && (I <= L)) {
          if (S.charAt(I - 1) === StartQuote) {
            Q += 1}
           else if ((S.charAt(I - 1) === EndQuote) && (Q > 0)) Q -= 1;
          if ((Q === 0) && MatchAt(I)) Result = I - 1;
          I += 1;
        };
      };
      return Result;
    };
    this.IndexOfAny = function (AnyOf) {
      var Result = 0;
      Result = $mod.TStringHelper.IndexOfAny$1.call(this,$mod.TStringHelper.ToCharArray$1.call({get: function () {
          return AnyOf;
        }, set: function (v) {
          rtl.raiseE("EPropReadOnly");
        }}));
      return Result;
    };
    this.IndexOfAny$1 = function (AnyOf) {
      var Result = 0;
      Result = $mod.TStringHelper.IndexOfAny$5.call(this,AnyOf,0,$mod.TStringHelper.GetLength.call(this));
      return Result;
    };
    this.IndexOfAny$2 = function (AnyOf, StartIndex) {
      var Result = 0;
      Result = $mod.TStringHelper.IndexOfAny$3.call(this,$mod.TStringHelper.ToCharArray$1.call({get: function () {
          return AnyOf;
        }, set: function (v) {
          rtl.raiseE("EPropReadOnly");
        }}),StartIndex);
      return Result;
    };
    this.IndexOfAny$3 = function (AnyOf, StartIndex) {
      var Result = 0;
      Result = $mod.TStringHelper.IndexOfAny$5.call(this,AnyOf,StartIndex,$mod.TStringHelper.GetLength.call(this));
      return Result;
    };
    this.IndexOfAny$4 = function (AnyOf, StartIndex, ACount) {
      var Result = 0;
      Result = $mod.TStringHelper.IndexOfAny$5.call(this,$mod.TStringHelper.ToCharArray$1.call({get: function () {
          return AnyOf;
        }, set: function (v) {
          rtl.raiseE("EPropReadOnly");
        }}),StartIndex,ACount);
      return Result;
    };
    this.IndexOfAny$5 = function (AnyOf, StartIndex, ACount) {
      var Result = 0;
      var i = 0;
      var L = 0;
      i = StartIndex + 1;
      L = (i + ACount) - 1;
      if (L > $mod.TStringHelper.GetLength.call(this)) L = $mod.TStringHelper.GetLength.call(this);
      Result = -1;
      while ((Result === -1) && (i <= L)) {
        if ($impl.HaveChar(this.get().charAt(i - 1),AnyOf)) Result = i - 1;
        i += 1;
      };
      return Result;
    };
    this.IndexOfAny$6 = function (AnyOf) {
      var Result = 0;
      Result = $mod.TStringHelper.IndexOfAny$8.call(this,AnyOf,0,$mod.TStringHelper.GetLength.call(this));
      return Result;
    };
    this.IndexOfAny$7 = function (AnyOf, StartIndex) {
      var Result = 0;
      Result = $mod.TStringHelper.IndexOfAny$8.call(this,AnyOf,StartIndex,$mod.TStringHelper.GetLength.call(this) - StartIndex);
      return Result;
    };
    this.IndexOfAny$8 = function (AnyOf, StartIndex, ACount) {
      var Result = 0;
      var M = 0;
      Result = $mod.TStringHelper.IndexOfAny$9.call(this,AnyOf,StartIndex,ACount,{get: function () {
          return M;
        }, set: function (v) {
          M = v;
        }});
      return Result;
    };
    this.IndexOfAny$9 = function (AnyOf, StartIndex, ACount, AMatch) {
      var Result = 0;
      var L = 0;
      var I = 0;
      Result = -1;
      for (var $l = 0, $end = rtl.length(AnyOf) - 1; $l <= $end; $l++) {
        I = $l;
        L = $mod.TStringHelper.IndexOf$5.call(this,AnyOf[I],StartIndex,ACount);
        if ((L >= 0) && ((Result === -1) || (L < Result))) {
          Result = L;
          AMatch.set(I);
        };
      };
      return Result;
    };
    this.IndexOfAnyUnquoted = function (AnyOf, StartQuote, EndQuote) {
      var Result = 0;
      Result = $mod.TStringHelper.IndexOfAnyUnquoted$2.call(this,AnyOf,StartQuote,EndQuote,0,$mod.TStringHelper.GetLength.call(this));
      return Result;
    };
    this.IndexOfAnyUnquoted$1 = function (AnyOf, StartQuote, EndQuote, StartIndex) {
      var Result = 0;
      Result = $mod.TStringHelper.IndexOfAnyUnquoted$2.call(this,AnyOf,StartQuote,EndQuote,StartIndex,$mod.TStringHelper.GetLength.call(this));
      return Result;
    };
    this.IndexOfAnyUnquoted$2 = function (AnyOf, StartQuote, EndQuote, StartIndex, ACount) {
      var Result = 0;
      var I = 0;
      var L = 0;
      var Q = 0;
      Result = -1;
      L = (StartIndex + ACount) - 1;
      if (L > $mod.TStringHelper.GetLength.call(this)) L = $mod.TStringHelper.GetLength.call(this);
      I = StartIndex + 1;
      Q = 0;
      if (StartQuote === EndQuote) {
        while ((Result === -1) && (I <= L)) {
          if (this.get().charAt(I - 1) === StartQuote) Q = 1 - Q;
          if ((Q === 0) && $impl.HaveChar(this.get().charAt(I - 1),AnyOf)) Result = I - 1;
          I += 1;
        };
      } else {
        while ((Result === -1) && (I <= L)) {
          if (this.get().charAt(I - 1) === StartQuote) {
            Q += 1}
           else if ((this.get().charAt(I - 1) === EndQuote) && (Q > 0)) Q -= 1;
          if ((Q === 0) && $impl.HaveChar(this.get().charAt(I - 1),AnyOf)) Result = I - 1;
          I += 1;
        };
      };
      return Result;
    };
    this.IndexOfAnyUnquoted$3 = function (AnyOf, StartQuote, EndQuote, StartIndex, Matched) {
      var Result = 0;
      var L = 0;
      var I = 0;
      Result = -1;
      for (var $l = 0, $end = rtl.length(AnyOf) - 1; $l <= $end; $l++) {
        I = $l;
        L = $mod.TStringHelper.IndexOfUnQuoted.call(this,AnyOf[I],StartQuote,EndQuote,StartIndex);
        if ((L >= 0) && ((Result === -1) || (L < Result))) {
          Result = L;
          Matched.set(I);
        };
      };
      return Result;
    };
    this.Insert = function (StartIndex, AValue) {
      var Result = "";
      pas.System.Insert(AValue,this,StartIndex + 1);
      Result = this.get();
      return Result;
    };
    this.IsDelimiter = function (Delimiters, Index) {
      var Result = false;
      Result = $mod.IsDelimiter(Delimiters,this.get(),Index + 1);
      return Result;
    };
    this.IsEmpty = function () {
      var Result = false;
      Result = $mod.TStringHelper.GetLength.call(this) === 0;
      return Result;
    };
    var cNumbers = rtl.createSet(null,48,57);
    this.IsNumber = function () {
      var Result = false;
      var lCount = 0;
      if ($mod.TStringHelper.IsEmpty.call(this)) return false;
      for (var $l = 0, $end = $mod.TStringHelper.GetLength.call(this) - 1; $l <= $end; $l++) {
        lCount = $l;
        if (!($mod.TStringHelper.GetChar.call(this,lCount).charCodeAt() in cNumbers)) return false;
      };
      Result = true;
      return Result;
    };
    this.LastDelimiter = function (Delims) {
      var Result = 0;
      Result = $mod.LastDelimiter(Delims,this.get()) - 1;
      return Result;
    };
    this.LastIndexOf = function (AValue) {
      var Result = 0;
      Result = $mod.TStringHelper.LastIndexOf$4.call(this,AValue,$mod.TStringHelper.GetLength.call(this) - 1,$mod.TStringHelper.GetLength.call(this));
      return Result;
    };
    this.LastIndexOf$1 = function (AValue) {
      var Result = 0;
      Result = $mod.TStringHelper.LastIndexOf$5.call(this,AValue,$mod.TStringHelper.GetLength.call(this) - 1,$mod.TStringHelper.GetLength.call(this));
      return Result;
    };
    this.LastIndexOf$2 = function (AValue, AStartIndex) {
      var Result = 0;
      Result = $mod.TStringHelper.LastIndexOf$4.call(this,AValue,AStartIndex,$mod.TStringHelper.GetLength.call(this));
      return Result;
    };
    this.LastIndexOf$3 = function (AValue, AStartIndex) {
      var Result = 0;
      Result = $mod.TStringHelper.LastIndexOf$5.call(this,AValue,AStartIndex,$mod.TStringHelper.GetLength.call(this));
      return Result;
    };
    this.LastIndexOf$4 = function (AValue, AStartIndex, ACount) {
      var Result = 0;
      var Min = 0;
      Result = AStartIndex + 1;
      Min = (Result - ACount) + 1;
      if (Min < 1) Min = 1;
      while ((Result >= Min) && (this.get().charAt(Result - 1) !== AValue)) Result -= 1;
      if (Result < Min) {
        Result = -1}
       else Result = Result - 1;
      return Result;
    };
    this.LastIndexOf$5 = function (AValue, AStartIndex, ACount) {
      var Result = 0;
      Result = this.get().lastIndexOf(AValue,AStartIndex);
      if ((AStartIndex - Result) > ACount) Result = -1;
      return Result;
    };
    this.LastIndexOfAny = function (AnyOf) {
      var Result = 0;
      Result = $mod.TStringHelper.LastIndexOfAny$2.call(this,AnyOf,$mod.TStringHelper.GetLength.call(this) - 1,$mod.TStringHelper.GetLength.call(this));
      return Result;
    };
    this.LastIndexOfAny$1 = function (AnyOf, AStartIndex) {
      var Result = 0;
      Result = $mod.TStringHelper.LastIndexOfAny$2.call(this,AnyOf,AStartIndex,$mod.TStringHelper.GetLength.call(this));
      return Result;
    };
    this.LastIndexOfAny$2 = function (AnyOf, AStartIndex, ACount) {
      var Result = 0;
      var Min = 0;
      Result = AStartIndex + 1;
      Min = (Result - ACount) + 1;
      if (Min < 1) Min = 1;
      while ((Result >= Min) && !$impl.HaveChar(this.get().charAt(Result - 1),AnyOf)) Result -= 1;
      if (Result < Min) {
        Result = -1}
       else Result = Result - 1;
      return Result;
    };
    this.PadLeft = function (ATotalWidth) {
      var Result = "";
      Result = $mod.TStringHelper.PadLeft$1.call(this,ATotalWidth," ");
      return Result;
    };
    this.PadLeft$1 = function (ATotalWidth, PaddingChar) {
      var Result = "";
      var L = 0;
      Result = this.get();
      L = ATotalWidth - $mod.TStringHelper.GetLength.call(this);
      if (L > 0) Result = pas.System.StringOfChar(PaddingChar,L) + Result;
      return Result;
    };
    this.PadRight = function (ATotalWidth) {
      var Result = "";
      Result = $mod.TStringHelper.PadRight$1.call(this,ATotalWidth," ");
      return Result;
    };
    this.PadRight$1 = function (ATotalWidth, PaddingChar) {
      var Result = "";
      var L = 0;
      Result = this.get();
      L = ATotalWidth - $mod.TStringHelper.GetLength.call(this);
      if (L > 0) Result = Result + pas.System.StringOfChar(PaddingChar,L);
      return Result;
    };
    this.QuotedString = function () {
      var Result = "";
      Result = $mod.QuotedStr(this.get(),"'");
      return Result;
    };
    this.QuotedString$1 = function (AQuoteChar) {
      var Result = "";
      Result = $mod.QuotedStr(this.get(),AQuoteChar);
      return Result;
    };
    this.Remove = function (StartIndex) {
      var Result = "";
      Result = $mod.TStringHelper.Remove$1.call(this,StartIndex,$mod.TStringHelper.GetLength.call(this) - StartIndex);
      return Result;
    };
    this.Remove$1 = function (StartIndex, ACount) {
      var Result = "";
      Result = this.get();
      pas.System.Delete({get: function () {
          return Result;
        }, set: function (v) {
          Result = v;
        }},StartIndex + 1,ACount);
      return Result;
    };
    this.Replace = function (OldChar, NewChar) {
      var Result = "";
      Result = $mod.TStringHelper.Replace$1.call(this,OldChar,NewChar,rtl.createSet($mod.TStringReplaceFlag.rfReplaceAll));
      return Result;
    };
    this.Replace$1 = function (OldChar, NewChar, ReplaceFlags) {
      var Result = "";
      Result = $mod.StringReplace(this.get(),OldChar,NewChar,rtl.refSet(ReplaceFlags));
      return Result;
    };
    this.Replace$2 = function (OldValue, NewValue) {
      var Result = "";
      Result = $mod.TStringHelper.Replace$3.call(this,OldValue,NewValue,rtl.createSet($mod.TStringReplaceFlag.rfReplaceAll));
      return Result;
    };
    this.Replace$3 = function (OldValue, NewValue, ReplaceFlags) {
      var Result = "";
      Result = $mod.StringReplace(this.get(),OldValue,NewValue,rtl.refSet(ReplaceFlags));
      return Result;
    };
    this.Split = function (Separators) {
      var Result = [];
      Result = $mod.TStringHelper.Split$1.call(this,$mod.TStringHelper.ToCharArray$1.call({get: function () {
          return Separators;
        }, set: function (v) {
          rtl.raiseE("EPropReadOnly");
        }}));
      return Result;
    };
    this.Split$1 = function (Separators) {
      var Result = [];
      Result = $mod.TStringHelper.Split$21.call(this,Separators,"\x00","\x00",$mod.TStringHelper.GetLength.call(this) + 1,$mod.TStringSplitOptions.None);
      return Result;
    };
    this.Split$2 = function (Separators, ACount) {
      var Result = [];
      Result = $mod.TStringHelper.Split$3.call(this,$mod.TStringHelper.ToCharArray$1.call({get: function () {
          return Separators;
        }, set: function (v) {
          rtl.raiseE("EPropReadOnly");
        }}),ACount);
      return Result;
    };
    this.Split$3 = function (Separators, ACount) {
      var Result = [];
      Result = $mod.TStringHelper.Split$21.call(this,Separators,"\x00","\x00",ACount,$mod.TStringSplitOptions.None);
      return Result;
    };
    this.Split$4 = function (Separators, Options) {
      var Result = [];
      Result = $mod.TStringHelper.Split$5.call(this,$mod.TStringHelper.ToCharArray$1.call({get: function () {
          return Separators;
        }, set: function (v) {
          rtl.raiseE("EPropReadOnly");
        }}),Options);
      return Result;
    };
    this.Split$5 = function (Separators, Options) {
      var Result = [];
      Result = $mod.TStringHelper.Split$7.call(this,Separators,$mod.TStringHelper.GetLength.call(this) + 1,Options);
      return Result;
    };
    this.Split$6 = function (Separators, ACount, Options) {
      var Result = [];
      Result = $mod.TStringHelper.Split$7.call(this,$mod.TStringHelper.ToCharArray$1.call({get: function () {
          return Separators;
        }, set: function (v) {
          rtl.raiseE("EPropReadOnly");
        }}),ACount,Options);
      return Result;
    };
    this.Split$7 = function (Separators, ACount, Options) {
      var Result = [];
      Result = $mod.TStringHelper.Split$21.call(this,Separators,"\x00","\x00",ACount,Options);
      return Result;
    };
    this.Split$8 = function (Separators) {
      var Result = [];
      Result = $mod.TStringHelper.Split$9.call(this,Separators,$mod.TStringHelper.GetLength.call(this) + 1);
      return Result;
    };
    this.Split$9 = function (Separators, ACount) {
      var Result = [];
      Result = $mod.TStringHelper.Split$11.call(this,Separators,ACount,$mod.TStringSplitOptions.None);
      return Result;
    };
    this.Split$10 = function (Separators, Options) {
      var Result = [];
      Result = $mod.TStringHelper.Split$11.call(this,Separators,$mod.TStringHelper.GetLength.call(this) + 1,Options);
      return Result;
    };
    this.Split$11 = function (Separators, ACount, Options) {
      var Result = [];
      Result = $mod.TStringHelper.Split$26.call(this,Separators,"\x00","\x00",ACount,Options);
      return Result;
    };
    this.Split$12 = function (Separators, AQuote) {
      var Result = [];
      Result = $mod.TStringHelper.Split$13.call(this,$mod.TStringHelper.ToCharArray$1.call({get: function () {
          return Separators;
        }, set: function (v) {
          rtl.raiseE("EPropReadOnly");
        }}),AQuote);
      return Result;
    };
    this.Split$13 = function (Separators, AQuote) {
      var Result = [];
      Result = $mod.TStringHelper.Split$15.call(this,Separators,AQuote,AQuote);
      return Result;
    };
    this.Split$14 = function (Separators, AQuoteStart, AQuoteEnd) {
      var Result = [];
      Result = $mod.TStringHelper.Split$15.call(this,$mod.TStringHelper.ToCharArray$1.call({get: function () {
          return Separators;
        }, set: function (v) {
          rtl.raiseE("EPropReadOnly");
        }}),AQuoteStart,AQuoteEnd);
      return Result;
    };
    this.Split$15 = function (Separators, AQuoteStart, AQuoteEnd) {
      var Result = [];
      Result = $mod.TStringHelper.Split$17.call(this,Separators,AQuoteStart,AQuoteEnd,$mod.TStringSplitOptions.None);
      return Result;
    };
    this.Split$16 = function (Separators, AQuoteStart, AQuoteEnd, Options) {
      var Result = [];
      Result = $mod.TStringHelper.Split$17.call(this,$mod.TStringHelper.ToCharArray$1.call({get: function () {
          return Separators;
        }, set: function (v) {
          rtl.raiseE("EPropReadOnly");
        }}),AQuoteStart,AQuoteEnd,Options);
      return Result;
    };
    this.Split$17 = function (Separators, AQuoteStart, AQuoteEnd, Options) {
      var Result = [];
      Result = $mod.TStringHelper.Split$21.call(this,Separators,AQuoteStart,AQuoteEnd,$mod.TStringHelper.GetLength.call(this) + 1,Options);
      return Result;
    };
    this.Split$18 = function (Separators, AQuoteStart, AQuoteEnd, ACount) {
      var Result = [];
      Result = $mod.TStringHelper.Split$19.call(this,$mod.TStringHelper.ToCharArray$1.call({get: function () {
          return Separators;
        }, set: function (v) {
          rtl.raiseE("EPropReadOnly");
        }}),AQuoteStart,AQuoteEnd,ACount);
      return Result;
    };
    this.Split$19 = function (Separators, AQuoteStart, AQuoteEnd, ACount) {
      var Result = [];
      Result = $mod.TStringHelper.Split$21.call(this,Separators,AQuoteStart,AQuoteEnd,ACount,$mod.TStringSplitOptions.None);
      return Result;
    };
    this.Split$20 = function (Separators, AQuoteStart, AQuoteEnd, ACount, Options) {
      var Result = [];
      Result = $mod.TStringHelper.Split$21.call(this,$mod.TStringHelper.ToCharArray$1.call({get: function () {
          return Separators;
        }, set: function (v) {
          rtl.raiseE("EPropReadOnly");
        }}),AQuoteStart,AQuoteEnd,ACount,Options);
      return Result;
    };
    var BlockSize = 10;
    this.Split$21 = function (Separators, AQuoteStart, AQuoteEnd, ACount, Options) {
      var $Self = this;
      var Result = [];
      var S = "";
      function NextSep(StartIndex) {
        var Result = 0;
        if (AQuoteStart !== "\x00") {
          Result = $mod.TStringHelper.IndexOfAnyUnquoted$1.call({get: function () {
              return S;
            }, set: function (v) {
              S = v;
            }},Separators,AQuoteStart,AQuoteEnd,StartIndex)}
         else Result = $mod.TStringHelper.IndexOfAny$3.call({get: function () {
            return S;
          }, set: function (v) {
            S = v;
          }},Separators,StartIndex);
        return Result;
      };
      function MaybeGrow(Curlen) {
        if (rtl.length(Result) <= Curlen) Result = rtl.arraySetLength(Result,"",rtl.length(Result) + 10);
      };
      var Sep = 0;
      var LastSep = 0;
      var Len = 0;
      var T = "";
      S = $Self.get();
      Result = rtl.arraySetLength(Result,"",10);
      Len = 0;
      LastSep = 0;
      Sep = NextSep(0);
      while ((Sep !== -1) && ((ACount === 0) || (Len < ACount))) {
        T = $mod.TStringHelper.Substring$1.call($Self,LastSep,Sep - LastSep);
        if ((T !== "") || !($mod.TStringSplitOptions.ExcludeEmpty === Options)) {
          MaybeGrow(Len);
          Result[Len] = T;
          Len += 1;
        };
        LastSep = Sep + 1;
        Sep = NextSep(LastSep);
      };
      if ((LastSep <= $mod.TStringHelper.GetLength.call($Self)) && ((ACount === 0) || (Len < ACount))) {
        T = $mod.TStringHelper.Substring.call($Self,LastSep);
        if ((T !== "") || !($mod.TStringSplitOptions.ExcludeEmpty === Options)) {
          MaybeGrow(Len);
          Result[Len] = T;
          Len += 1;
        };
      };
      Result = rtl.arraySetLength(Result,"",Len);
      return Result;
    };
    this.Split$22 = function (Separators, AQuote) {
      var Result = [];
      Result = $mod.TStringHelper.Split$23.call(this,Separators,AQuote,AQuote);
      return Result;
    };
    this.Split$23 = function (Separators, AQuoteStart, AQuoteEnd) {
      var Result = [];
      Result = $mod.TStringHelper.Split$26.call(this,Separators,AQuoteStart,AQuoteEnd,$mod.TStringHelper.GetLength.call(this) + 1,$mod.TStringSplitOptions.None);
      return Result;
    };
    this.Split$24 = function (Separators, AQuoteStart, AQuoteEnd, Options) {
      var Result = [];
      Result = $mod.TStringHelper.Split$26.call(this,Separators,AQuoteStart,AQuoteEnd,$mod.TStringHelper.GetLength.call(this) + 1,Options);
      return Result;
    };
    this.Split$25 = function (Separators, AQuoteStart, AQuoteEnd, ACount) {
      var Result = [];
      Result = $mod.TStringHelper.Split$26.call(this,Separators,AQuoteStart,AQuoteEnd,ACount,$mod.TStringSplitOptions.None);
      return Result;
    };
    var BlockSize$1 = 10;
    this.Split$26 = function (Separators, AQuoteStart, AQuoteEnd, ACount, Options) {
      var $Self = this;
      var Result = [];
      var S = "";
      function NextSep(StartIndex, Match) {
        var Result = 0;
        if (AQuoteStart !== "\x00") {
          Result = $mod.TStringHelper.IndexOfAnyUnquoted$3.call({get: function () {
              return S;
            }, set: function (v) {
              S = v;
            }},Separators,AQuoteStart,AQuoteEnd,StartIndex,Match)}
         else Result = $mod.TStringHelper.IndexOfAny$9.call({get: function () {
            return S;
          }, set: function (v) {
            S = v;
          }},Separators,StartIndex,$mod.TStringHelper.GetLength.call($Self),Match);
        return Result;
      };
      function MaybeGrow(Curlen) {
        if (rtl.length(Result) <= Curlen) Result = rtl.arraySetLength(Result,"",rtl.length(Result) + 10);
      };
      var Sep = 0;
      var LastSep = 0;
      var Len = 0;
      var Match = 0;
      var T = "";
      S = $Self.get();
      Result = rtl.arraySetLength(Result,"",10);
      Len = 0;
      LastSep = 0;
      Sep = NextSep(0,{get: function () {
          return Match;
        }, set: function (v) {
          Match = v;
        }});
      while ((Sep !== -1) && ((ACount === 0) || (Len < ACount))) {
        T = $mod.TStringHelper.Substring$1.call($Self,LastSep,Sep - LastSep);
        if ((T !== "") || !($mod.TStringSplitOptions.ExcludeEmpty === Options)) {
          MaybeGrow(Len);
          Result[Len] = T;
          Len += 1;
        };
        LastSep = Sep + Separators[Match].length;
        Sep = NextSep(LastSep,{get: function () {
            return Match;
          }, set: function (v) {
            Match = v;
          }});
      };
      if ((LastSep <= $mod.TStringHelper.GetLength.call($Self)) && ((ACount === 0) || (Len < ACount))) {
        T = $mod.TStringHelper.Substring.call($Self,LastSep);
        if ((T !== "") || !($mod.TStringSplitOptions.ExcludeEmpty === Options)) {
          MaybeGrow(Len);
          Result[Len] = T;
          Len += 1;
        };
      };
      Result = rtl.arraySetLength(Result,"",Len);
      return Result;
    };
    this.StartsWith = function (AValue) {
      var Result = false;
      Result = $mod.TStringHelper.StartsWith$1.call(this,AValue,false);
      return Result;
    };
    this.StartsWith$1 = function (AValue, IgnoreCase) {
      var Result = false;
      var L = 0;
      var S = "";
      L = AValue.length;
      Result = L <= 0;
      if (!Result) {
        S = pas.System.Copy(this.get(),1,L);
        Result = S.length === L;
        if (Result) if (IgnoreCase) {
          Result = $mod.SameText(S,AValue)}
         else Result = $mod.SameStr(S,AValue);
      };
      return Result;
    };
    this.Substring = function (AStartIndex) {
      var Result = "";
      Result = $mod.TStringHelper.Substring$1.call(this,AStartIndex,$mod.TStringHelper.GetLength.call(this) - AStartIndex);
      return Result;
    };
    this.Substring$1 = function (AStartIndex, ALen) {
      var Result = "";
      Result = pas.System.Copy(this.get(),AStartIndex + 1,ALen);
      return Result;
    };
    this.ToBoolean$1 = function () {
      var Result = false;
      Result = $mod.StrToBool(this.get());
      return Result;
    };
    this.ToInteger$1 = function () {
      var Result = 0;
      Result = $mod.StrToInt(this.get());
      return Result;
    };
    this.ToNativeInt$1 = function () {
      var Result = 0;
      Result = $mod.StrToNativeInt(this.get());
      return Result;
    };
    this.ToDouble$1 = function () {
      var Result = 0.0;
      Result = $mod.StrToFloat(this.get());
      return Result;
    };
    this.ToExtended$1 = function () {
      var Result = 0.0;
      Result = $mod.StrToFloat(this.get());
      return Result;
    };
    this.ToCharArray$1 = function () {
      var Result = [];
      Result = $mod.TStringHelper.ToCharArray$2.call(this,0,$mod.TStringHelper.GetLength.call(this));
      return Result;
    };
    this.ToCharArray$2 = function (AStartIndex, ALen) {
      var Result = [];
      var I = 0;
      Result = rtl.arraySetLength(Result,"\x00",ALen);
      for (var $l = 0, $end = ALen - 1; $l <= $end; $l++) {
        I = $l;
        Result[I] = this.get().charAt((AStartIndex + I + 1) - 1);
      };
      return Result;
    };
    this.ToLower = function () {
      var Result = "";
      Result = $mod.TStringHelper.LowerCase(this.get());
      return Result;
    };
    this.ToLowerInvariant = function () {
      var Result = "";
      Result = $mod.TStringHelper.LowerCase(this.get());
      return Result;
    };
    this.ToUpper = function () {
      var Result = "";
      Result = $mod.TStringHelper.UpperCase(this.get());
      return Result;
    };
    this.ToUpperInvariant = function () {
      var Result = "";
      Result = $mod.TStringHelper.UpperCase(this.get());
      return Result;
    };
    this.Trim = function () {
      var Result = "";
      Result = $mod.Trim(this.get());
      return Result;
    };
    this.TrimLeft = function () {
      var Result = "";
      Result = $mod.TrimLeft(this.get());
      return Result;
    };
    this.TrimRight = function () {
      var Result = "";
      Result = $mod.TrimRight(this.get());
      return Result;
    };
    this.Trim$1 = function (ATrimChars) {
      var Result = "";
      Result = $mod.TStringHelper.TrimRight$1.call({a: $mod.TStringHelper.TrimLeft$1.call(this,ATrimChars), get: function () {
          return this.a;
        }, set: function (v) {
          this.a = v;
        }},ATrimChars);
      return Result;
    };
    this.TrimLeft$1 = function (ATrimChars) {
      var Result = "";
      var I = 0;
      var Len = 0;
      I = 1;
      Len = $mod.TStringHelper.GetLength.call(this);
      while ((I <= Len) && $impl.HaveChar(this.get().charAt(I - 1),ATrimChars)) I += 1;
      if (I === 1) {
        Result = this.get()}
       else if (I > Len) {
        Result = ""}
       else Result = pas.System.Copy(this.get(),I,(Len - I) + 1);
      return Result;
    };
    this.TrimRight$1 = function (ATrimChars) {
      var Result = "";
      var I = 0;
      var Len = 0;
      Len = $mod.TStringHelper.GetLength.call(this);
      I = Len;
      while ((I >= 1) && $impl.HaveChar(this.get().charAt(I - 1),ATrimChars)) I -= 1;
      if (I < 1) {
        Result = ""}
       else if (I === Len) {
        Result = this.get()}
       else Result = pas.System.Copy(this.get(),1,I);
      return Result;
    };
    this.TrimEnd = function (ATrimChars) {
      var Result = "";
      Result = $mod.TStringHelper.TrimRight$1.call(this,ATrimChars);
      return Result;
    };
    this.TrimStart = function (ATrimChars) {
      var Result = "";
      Result = $mod.TStringHelper.TrimLeft$1.call(this,ATrimChars);
      return Result;
    };
  });
  rtl.createHelper(this,"TDoubleHelper",null,function () {
    this.Epsilon = 4.9406564584124654418e-324;
    this.MaxValue = 1.7976931348623157081e+308;
    this.MinValue = -1.7976931348623157081e+308;
    this.GetB = function (AIndex) {
      var Result = 0;
      var F = null;
      var B = null;
      F = new Float64Array(1);
      B = new Uint8Array(F.buffer);
      F[0] = this.get();
      Result = B[AIndex];
      return Result;
    };
    this.GetW = function (AIndex) {
      var Result = 0;
      var F = null;
      var W = null;
      F = new Float64Array(1);
      W = new Uint16Array(F.buffer);
      F[0] = this.get();
      Result = W[AIndex];
      return Result;
    };
    this.GetE = function () {
      var Result = 0;
      Result = $impl.FloatToParts(this.get()).exp;
      return Result;
    };
    this.GetF = function () {
      var Result = 0;
      Result = 0;
      $impl.NotImplemented("GetF");
      return Result;
    };
    this.GetS = function () {
      var Result = false;
      Result = $impl.FloatToParts(this.get()).sign;
      return Result;
    };
    this.SetS = function (aValue) {
      var F = null;
      var B = null;
      F = new Float64Array(1);
      B = new Uint8Array(F.buffer);
      F[0] = this.get();
      if (aValue) {
        B[7] = B[7] | (1 >>> 7)}
       else B[7] = B[7] & ~(1 >>> 7);
      this.set(F[0]);
    };
    this.SetB = function (AIndex, AValue) {
      var F = null;
      var B = null;
      if (AIndex >= 8) throw $mod.ERangeError.$create("Create$1",[rtl.getResStr(pas.RTLConsts,"SRangeError")]);
      F = new Float64Array(1);
      B = new Uint8Array(F.buffer);
      F[0] = this.get();
      B[AIndex] = AValue;
      this.set(F[0]);
    };
    this.SetW = function (AIndex, AValue) {
      var F = null;
      var W = null;
      if (AIndex >= 4) throw $mod.ERangeError.$create("Create$1",[rtl.getResStr(pas.RTLConsts,"SRangeError")]);
      F = new Float64Array(1);
      W = new Uint16Array(F.buffer);
      F[0] = this.get();
      W[AIndex] = AValue;
      this.set(F[0]);
    };
    this.IsInfinity = function (AValue) {
      var Result = false;
      Result = !isFinite(AValue);
      return Result;
    };
    this.IsNan = function (AValue) {
      var Result = false;
      Result = isNaN(AValue);
      return Result;
    };
    this.IsNegativeInfinity = function (AValue) {
      var Result = false;
      return (AValue=Number.NEGATIVE_INFINITY);
      Result = AValue === 0;
      return Result;
    };
    this.IsPositiveInfinity = function (AValue) {
      var Result = false;
      return (AValue=Number.POSITIVE_INFINITY);
      Result = AValue === 0;
      return Result;
    };
    this.Parse = function (AString) {
      var Result = 0.0;
      Result = $mod.StrToFloat(AString);
      return Result;
    };
    this.ToString = function (AValue) {
      var Result = "";
      Result = $mod.FloatToStr(AValue);
      return Result;
    };
    this.ToString$1 = function (AValue, AFormat, APrecision, ADigits) {
      var Result = "";
      Result = $mod.FloatToStrF(AValue,AFormat,APrecision,ADigits);
      return Result;
    };
    this.TryParse = function (AString, AValue) {
      var Result = false;
      Result = $mod.TryStrToFloat$2(AString,AValue);
      return Result;
    };
    this.BuildUp = function (ASignFlag, AMantissa, AExponent) {
      $impl.NotImplemented("BuildUp");
      if (ASignFlag && (AMantissa > 0) && (AExponent < 0)) return;
    };
    this.Exponent = function () {
      var Result = 0;
      Result = $impl.FloatToParts(this.get()).exp;
      return Result;
    };
    this.Fraction = function () {
      var Result = 0.0;
      Result = pas.System.Frac(this.get());
      return Result;
    };
    this.IsInfinity$1 = function () {
      var Result = false;
      Result = $mod.TDoubleHelper.IsInfinity(this.get());
      return Result;
    };
    this.IsNan$1 = function () {
      var Result = false;
      Result = $mod.TDoubleHelper.IsNan(this.get());
      return Result;
    };
    this.IsNegativeInfinity$1 = function () {
      var Result = false;
      Result = $mod.TDoubleHelper.IsNegativeInfinity(this.get());
      return Result;
    };
    this.IsPositiveInfinity$1 = function () {
      var Result = false;
      Result = $mod.TDoubleHelper.IsPositiveInfinity(this.get());
      return Result;
    };
    this.Mantissa = function () {
      var Result = 0;
      Result = pas.System.Trunc($impl.FloatToParts(this.get()).mantissa);
      return Result;
    };
    this.ToString$2 = function (AFormat, APrecision, ADigits) {
      var Result = "";
      Result = $mod.FloatToStrF(this.get(),AFormat,APrecision,ADigits);
      return Result;
    };
    this.ToString$3 = function () {
      var Result = "";
      Result = $mod.FloatToStr(this.get());
      return Result;
    };
  });
  rtl.createHelper(this,"TByteHelper",null,function () {
    this.MaxValue = 255;
    this.MinValue = 0;
    this.Parse = function (AString) {
      var Result = 0;
      Result = $mod.StrToInt(AString);
      return Result;
    };
    this.Size = function () {
      var Result = 0;
      Result = 1;
      return Result;
    };
    this.ToString = function (AValue) {
      var Result = "";
      Result = $mod.IntToStr(AValue);
      return Result;
    };
    this.TryParse = function (AString, AValue) {
      var Result = false;
      var C = 0;
      pas.System.val$3(AString,AValue,{get: function () {
          return C;
        }, set: function (v) {
          C = v;
        }});
      Result = C === 0;
      return Result;
    };
    this.ToBoolean = function () {
      var Result = false;
      Result = this.get() !== 0;
      return Result;
    };
    this.ToDouble = function () {
      var Result = 0.0;
      Result = this.get();
      return Result;
    };
    this.ToExtended = function () {
      var Result = 0.0;
      Result = this.get();
      return Result;
    };
    this.ToBinString = function () {
      var Result = "";
      Result = pas.System.binstr(this.get(),$mod.TByteHelper.Size() * 8);
      return Result;
    };
    this.ToHexString = function (AMinDigits) {
      var Result = "";
      Result = $mod.IntToHex(this.get(),AMinDigits);
      return Result;
    };
    this.ToHexString$1 = function () {
      var Result = "";
      Result = $mod.IntToHex(this.get(),$mod.TByteHelper.Size() * 2);
      return Result;
    };
    this.ToString$1 = function () {
      var Result = "";
      Result = $mod.IntToStr(this.get());
      return Result;
    };
    this.SetBit = function (Index) {
      var Result = 0;
      this.set(this.get() | (1 << Index));
      Result = this.get();
      return Result;
    };
    this.ClearBit = function (Index) {
      var Result = 0;
      this.set(this.get() & ~(1 << Index));
      Result = this.get();
      return Result;
    };
    this.ToggleBit = function (Index) {
      var Result = 0;
      this.set(this.get() ^ (1 << Index));
      Result = this.get();
      return Result;
    };
    this.TestBit = function (Index) {
      var Result = false;
      Result = (this.get() & (1 << Index)) !== 0;
      return Result;
    };
  });
  rtl.createHelper(this,"TShortIntHelper",null,function () {
    this.MaxValue = 127;
    this.MinValue = -128;
    this.Parse = function (AString) {
      var Result = 0;
      Result = $mod.StrToInt(AString);
      return Result;
    };
    this.Size = function () {
      var Result = 0;
      Result = 1;
      return Result;
    };
    this.ToString = function (AValue) {
      var Result = "";
      Result = $mod.IntToStr(AValue);
      return Result;
    };
    this.TryParse = function (AString, AValue) {
      var Result = false;
      var C = 0;
      pas.System.val$2(AString,AValue,{get: function () {
          return C;
        }, set: function (v) {
          C = v;
        }});
      Result = C === 0;
      return Result;
    };
    this.ToBoolean = function () {
      var Result = false;
      Result = this.get() !== 0;
      return Result;
    };
    this.ToDouble = function () {
      var Result = 0.0;
      Result = this.get();
      return Result;
    };
    this.ToExtended = function () {
      var Result = 0.0;
      Result = this.get();
      return Result;
    };
    this.ToBinString = function () {
      var Result = "";
      Result = pas.System.binstr(this.get(),$mod.TShortIntHelper.Size() * 8);
      return Result;
    };
    this.ToHexString = function (AMinDigits) {
      var Result = "";
      var B = 0;
      var U = null;
      var S = null;
      if (this.get() >= 0) {
        B = this.get()}
       else {
        S = new Int8Array(1);
        S[0] = this.get();
        U = new Uint8Array(S);
        B = U[0];
        if (AMinDigits > 2) B = 0xFF00 + B;
      };
      Result = $mod.IntToHex(B,AMinDigits);
      return Result;
    };
    this.ToHexString$1 = function () {
      var Result = "";
      Result = $mod.TShortIntHelper.ToHexString.call(this,$mod.TShortIntHelper.Size() * 2);
      return Result;
    };
    this.ToString$1 = function () {
      var Result = "";
      Result = $mod.IntToStr(this.get());
      return Result;
    };
    this.SetBit = function (Index) {
      var Result = 0;
      this.set(this.get() | (1 << Index));
      Result = this.get();
      return Result;
    };
    this.ClearBit = function (Index) {
      var Result = 0;
      this.set(this.get() & ~(1 << Index));
      Result = this.get();
      return Result;
    };
    this.ToggleBit = function (Index) {
      var Result = 0;
      this.set(this.get() ^ (1 << Index));
      Result = this.get();
      return Result;
    };
    this.TestBit = function (Index) {
      var Result = false;
      Result = (this.get() & (1 << Index)) !== 0;
      return Result;
    };
  });
  rtl.createHelper(this,"TSmallIntHelper",null,function () {
    this.MaxValue = 32767;
    this.MinValue = -32768;
    this.Parse = function (AString) {
      var Result = 0;
      Result = $mod.StrToInt(AString);
      return Result;
    };
    this.Size = function () {
      var Result = 0;
      Result = 2;
      return Result;
    };
    this.ToString = function (AValue) {
      var Result = "";
      Result = $mod.IntToStr(AValue);
      return Result;
    };
    this.TryParse = function (AString, AValue) {
      var Result = false;
      var C = 0;
      pas.System.val$4(AString,AValue,{get: function () {
          return C;
        }, set: function (v) {
          C = v;
        }});
      Result = C === 0;
      return Result;
    };
    this.ToString$1 = function () {
      var Result = "";
      Result = $mod.IntToStr(this.get());
      return Result;
    };
    this.ToBoolean = function () {
      var Result = false;
      Result = this.get() !== 0;
      return Result;
    };
    this.ToBinString = function () {
      var Result = "";
      Result = pas.System.binstr(this.get(),$mod.TSmallIntHelper.Size() * 8);
      return Result;
    };
    this.ToHexString = function () {
      var Result = "";
      Result = $mod.TSmallIntHelper.ToHexString$1.call(this,$mod.TSmallIntHelper.Size() * 2);
      return Result;
    };
    this.ToHexString$1 = function (AMinDigits) {
      var Result = "";
      var B = 0;
      var U = null;
      var S = null;
      if (this.get() >= 0) {
        B = this.get()}
       else {
        S = new Int16Array(1);
        S[0] = this.get();
        U = new Uint16Array(S);
        B = U[0];
        if (AMinDigits > 6) {
          B = 0xFFFF0000 + B}
         else if (AMinDigits > 4) B = 0xFF0000 + B;
      };
      Result = $mod.IntToHex(B,AMinDigits);
      return Result;
    };
    this.ToDouble = function () {
      var Result = 0.0;
      Result = this.get();
      return Result;
    };
    this.ToExtended = function () {
      var Result = 0.0;
      Result = this.get();
      return Result;
    };
    this.SetBit = function (Index) {
      var Result = 0;
      this.set(this.get() | (1 << Index));
      Result = this.get();
      return Result;
    };
    this.ClearBit = function (Index) {
      var Result = 0;
      this.set(this.get() & ~(1 << Index));
      Result = this.get();
      return Result;
    };
    this.ToggleBit = function (Index) {
      var Result = 0;
      this.set(this.get() ^ (1 << Index));
      Result = this.get();
      return Result;
    };
    this.TestBit = function (Index) {
      var Result = false;
      Result = (this.get() & (1 << Index)) !== 0;
      return Result;
    };
  });
  rtl.createHelper(this,"TWordHelper",null,function () {
    this.MaxValue = 65535;
    this.MinValue = 0;
    var cBitPerByte = 8;
    this.FromBytes = function (ALow, AHigh) {
      var Result = 0;
      Result = ALow + (AHigh << 8);
      return Result;
    };
    this.Parse = function (AString) {
      var Result = 0;
      Result = $mod.StrToInt(AString);
      return Result;
    };
    this.Size = function () {
      var Result = 0;
      Result = 2;
      return Result;
    };
    var cMask = 0xFF;
    var cBitPerByte$1 = 8;
    this.ToBytes = function (ALow, AHigh) {
      ALow.set(this.get() & cMask);
      AHigh.set((this.get() & (cMask << 8)) >>> 8);
    };
    this.ToString = function (AValue) {
      var Result = "";
      Result = $mod.IntToStr(AValue);
      return Result;
    };
    this.TryParse = function (AString, AValue) {
      var Result = false;
      var C = 0;
      pas.System.val$5(AString,AValue,{get: function () {
          return C;
        }, set: function (v) {
          C = v;
        }});
      Result = C === 0;
      return Result;
    };
    this.ToBoolean = function () {
      var Result = false;
      Result = this.get() !== 0;
      return Result;
    };
    this.ToDouble = function () {
      var Result = 0.0;
      Result = this.get();
      return Result;
    };
    this.ToExtended = function () {
      var Result = 0.0;
      Result = this.get();
      return Result;
    };
    this.ToBinString = function () {
      var Result = "";
      Result = pas.System.binstr(this.get(),$mod.TWordHelper.Size() * 8);
      return Result;
    };
    this.ToHexString = function (AMinDigits) {
      var Result = "";
      Result = $mod.IntToHex(this.get(),AMinDigits);
      return Result;
    };
    this.ToHexString$1 = function () {
      var Result = "";
      Result = $mod.IntToHex(this.get(),$mod.TWordHelper.Size() * 2);
      return Result;
    };
    this.ToString$1 = function () {
      var Result = "";
      Result = $mod.IntToStr(this.get());
      return Result;
    };
    this.SetBit = function (Index) {
      var Result = 0;
      this.set(this.get() | (1 << Index));
      Result = this.get();
      return Result;
    };
    this.ClearBit = function (Index) {
      var Result = 0;
      this.set(this.get() & ~(1 << Index));
      Result = this.get();
      return Result;
    };
    this.ToggleBit = function (Index) {
      var Result = 0;
      this.set(this.get() ^ (1 << Index));
      Result = this.get();
      return Result;
    };
    this.TestBit = function (Index) {
      var Result = false;
      Result = (this.get() & (1 << Index)) !== 0;
      return Result;
    };
  });
  rtl.createHelper(this,"TCardinalHelper",null,function () {
    this.MaxValue = 4294967295;
    this.MinValue = 0;
    this.Parse = function (AString) {
      var Result = 0;
      Result = $mod.StrToInt(AString);
      return Result;
    };
    this.Size = function () {
      var Result = 0;
      Result = 4;
      return Result;
    };
    this.ToString = function (AValue) {
      var Result = "";
      Result = $mod.IntToStr(AValue);
      return Result;
    };
    this.TryParse = function (AString, AValue) {
      var Result = false;
      var C = 0;
      pas.System.val$7(AString,AValue,{get: function () {
          return C;
        }, set: function (v) {
          C = v;
        }});
      Result = C === 0;
      return Result;
    };
    this.ToBoolean = function () {
      var Result = false;
      Result = this.get() !== 0;
      return Result;
    };
    this.ToDouble = function () {
      var Result = 0.0;
      Result = this.get();
      return Result;
    };
    this.ToExtended = function () {
      var Result = 0.0;
      Result = this.get();
      return Result;
    };
    this.ToBinString = function () {
      var Result = "";
      Result = pas.System.binstr(this.get(),$mod.TCardinalHelper.Size() * 8);
      return Result;
    };
    this.ToHexString = function (AMinDigits) {
      var Result = "";
      Result = $mod.IntToHex(this.get(),AMinDigits);
      return Result;
    };
    this.ToHexString$1 = function () {
      var Result = "";
      Result = $mod.TCardinalHelper.ToHexString.call(this,$mod.TCardinalHelper.Size() * 2);
      return Result;
    };
    this.ToString$1 = function () {
      var Result = "";
      Result = $mod.IntToStr(this.get());
      return Result;
    };
    this.SetBit = function (Index) {
      var Result = 0;
      this.set(rtl.lw(this.get() | rtl.lw(1 << Index)));
      Result = this.get();
      return Result;
    };
    this.ClearBit = function (Index) {
      var Result = 0;
      this.set(rtl.lw(this.get() & rtl.lw(~rtl.lw(1 << Index))));
      Result = this.get();
      return Result;
    };
    this.ToggleBit = function (Index) {
      var Result = 0;
      this.set(rtl.lw(this.get() ^ rtl.lw(1 << Index)));
      Result = this.get();
      return Result;
    };
    this.TestBit = function (Index) {
      var Result = false;
      Result = rtl.lw(this.get() & rtl.lw(1 << Index)) !== 0;
      return Result;
    };
  });
  rtl.createHelper(this,"TIntegerHelper",null,function () {
    this.MaxValue = 2147483647;
    this.MinValue = -2147483648;
    this.Size = function () {
      var Result = 0;
      Result = 4;
      return Result;
    };
    this.ToString = function (AValue) {
      var Result = "";
      Result = $mod.IntToStr(AValue);
      return Result;
    };
    this.Parse = function (AString) {
      var Result = 0;
      Result = $mod.StrToInt(AString);
      return Result;
    };
    this.TryParse = function (AString, AValue) {
      var Result = false;
      var C = 0;
      pas.System.val$6(AString,AValue,{get: function () {
          return C;
        }, set: function (v) {
          C = v;
        }});
      Result = C === 0;
      return Result;
    };
    this.ToBoolean = function () {
      var Result = false;
      Result = this.get() !== 0;
      return Result;
    };
    this.ToDouble = function () {
      var Result = 0.0;
      Result = this.get();
      return Result;
    };
    this.ToExtended = function () {
      var Result = 0.0;
      Result = this.get();
      return Result;
    };
    this.ToBinString = function () {
      var Result = "";
      Result = pas.System.binstr(this.get(),$mod.TIntegerHelper.Size() * 8);
      return Result;
    };
    this.ToHexString = function (AMinDigits) {
      var Result = "";
      var B = 0;
      var U = null;
      var S = null;
      if (this.get() >= 0) {
        B = this.get()}
       else {
        S = new Int32Array(1);
        S[0] = this.get();
        U = new Uint32Array(S);
        B = U[0];
      };
      Result = $mod.IntToHex(B,AMinDigits);
      return Result;
    };
    this.ToHexString$1 = function () {
      var Result = "";
      Result = $mod.TIntegerHelper.ToHexString.call(this,$mod.TIntegerHelper.Size() * 2);
      return Result;
    };
    this.ToString$1 = function () {
      var Result = "";
      Result = $mod.IntToStr(this.get());
      return Result;
    };
    this.SetBit = function (Index) {
      var Result = 0;
      this.set(this.get() | (1 << Index));
      Result = this.get();
      return Result;
    };
    this.ClearBit = function (Index) {
      var Result = 0;
      this.set(this.get() & ~(1 << Index));
      Result = this.get();
      return Result;
    };
    this.ToggleBit = function (Index) {
      var Result = 0;
      this.set(this.get() ^ (1 << Index));
      Result = this.get();
      return Result;
    };
    this.TestBit = function (Index) {
      var Result = false;
      Result = (this.get() & (1 << Index)) !== 0;
      return Result;
    };
  });
  rtl.createHelper(this,"TUInt64Helper",null,function () {
    this.ToString = function (AValue) {
      var Result = "";
      Result = $mod.IntToStr(AValue);
      return Result;
    };
    this.ToString$1 = function () {
      var Result = "";
      Result = $mod.IntToStr(this.get());
      return Result;
    };
  });
  rtl.createHelper(this,"TNativeIntHelper",null,function () {
    this.MaxValue = 9007199254740991;
    this.MinValue = -9007199254740991;
    this.Parse = function (AString) {
      var Result = 0;
      Result = $mod.StrToInt(AString);
      return Result;
    };
    this.Size = function () {
      var Result = 0;
      Result = 7;
      return Result;
    };
    this.ToString = function (AValue) {
      var Result = "";
      Result = $mod.IntToStr(AValue);
      return Result;
    };
    this.TryParse = function (AString, AValue) {
      var Result = false;
      var C = 0;
      pas.System.val(AString,AValue,{get: function () {
          return C;
        }, set: function (v) {
          C = v;
        }});
      Result = C === 0;
      return Result;
    };
    this.ToBoolean = function () {
      var Result = false;
      Result = this.get() !== 0;
      return Result;
    };
    this.ToDouble = function () {
      var Result = 0.0;
      Result = this.get();
      return Result;
    };
    this.ToExtended = function () {
      var Result = 0.0;
      Result = this.get();
      return Result;
    };
    this.ToBinString = function () {
      var Result = "";
      Result = pas.System.binstr(this.get(),$mod.TNativeIntHelper.Size() * 8);
      return Result;
    };
    this.ToHexString = function (AMinDigits) {
      var Result = "";
      Result = $mod.IntToHex(this.get(),AMinDigits);
      return Result;
    };
    this.ToHexString$1 = function () {
      var Result = "";
      Result = $mod.IntToHex(this.get(),$mod.TNativeIntHelper.Size() * 2);
      return Result;
    };
    this.ToString$1 = function () {
      var Result = "";
      Result = $mod.IntToStr(this.get());
      return Result;
    };
    this.SetBit = function (Index) {
      var Result = 0;
      this.set(rtl.or(this.get(),rtl.shl(1,Index)));
      Result = this.get();
      return Result;
    };
    this.ClearBit = function (Index) {
      var Result = 0;
      this.set(rtl.and(this.get(),~rtl.shl(1,Index)));
      Result = this.get();
      return Result;
    };
    this.ToggleBit = function (Index) {
      var Result = 0;
      this.set(rtl.xor(this.get(),rtl.shl(1,Index)));
      Result = this.get();
      return Result;
    };
    this.TestBit = function (Index) {
      var Result = false;
      Result = rtl.and(this.get(),rtl.shl(1,Index)) !== 0;
      return Result;
    };
  });
  rtl.createHelper(this,"TNativeUIntHelper",null,function () {
    this.MaxValue = 9007199254740991;
    this.MinValue = 0;
    this.Parse = function (AString) {
      var Result = 0;
      Result = $mod.StrToInt(AString);
      return Result;
    };
    this.Size = function () {
      var Result = 0;
      Result = 7;
      return Result;
    };
    this.ToString = function (AValue) {
      var Result = "";
      Result = $mod.IntToStr(AValue);
      return Result;
    };
    this.TryParse = function (AString, AValue) {
      var Result = false;
      var C = 0;
      pas.System.val$1(AString,AValue,{get: function () {
          return C;
        }, set: function (v) {
          C = v;
        }});
      Result = C === 0;
      return Result;
    };
    this.ToBoolean = function () {
      var Result = false;
      Result = this.get() !== 0;
      return Result;
    };
    this.ToDouble = function () {
      var Result = 0.0;
      Result = this.get();
      return Result;
    };
    this.ToExtended = function () {
      var Result = 0.0;
      Result = this.get();
      return Result;
    };
    this.ToBinString = function () {
      var Result = "";
      Result = pas.System.binstr(this.get(),$mod.TNativeUIntHelper.Size() * 8);
      return Result;
    };
    this.ToHexString = function (AMinDigits) {
      var Result = "";
      Result = $mod.IntToHex(this.get(),AMinDigits);
      return Result;
    };
    this.ToHexString$1 = function () {
      var Result = "";
      Result = $mod.IntToHex(this.get(),$mod.TNativeUIntHelper.Size() * 2);
      return Result;
    };
    this.ToSingle = function () {
      var Result = 0.0;
      Result = this.get();
      return Result;
    };
    this.ToString$1 = function () {
      var Result = "";
      Result = $mod.IntToStr(this.get());
      return Result;
    };
    this.SetBit = function (Index) {
      var Result = 0;
      this.set(rtl.or(this.get(),rtl.shl(1,Index)));
      Result = this.get();
      return Result;
    };
    this.ClearBit = function (Index) {
      var Result = 0;
      this.set(rtl.and(this.get(),~rtl.shl(1,Index)));
      Result = this.get();
      return Result;
    };
    this.ToggleBit = function (Index) {
      var Result = 0;
      this.set(rtl.xor(this.get(),rtl.shl(1,Index)));
      Result = this.get();
      return Result;
    };
    this.TestBit = function (Index) {
      var Result = false;
      Result = rtl.and(this.get(),rtl.shl(1,Index)) !== 0;
      return Result;
    };
  });
  this.TUseBoolStrs = {"0": "False", False: 0, "1": "True", True: 1};
  this.$rtti.$Enum("TUseBoolStrs",{minvalue: 0, maxvalue: 1, ordtype: 1, enumtype: this.TUseBoolStrs});
  rtl.createHelper(this,"TBooleanHelper",null,function () {
    this.Parse = function (S) {
      var Result = false;
      Result = $mod.StrToBool(S);
      return Result;
    };
    this.Size = function () {
      var Result = 0;
      Result = 1;
      return Result;
    };
    this.ToString = function (AValue, UseBoolStrs) {
      var Result = "";
      Result = $mod.BoolToStr(AValue,UseBoolStrs === $mod.TUseBoolStrs.True);
      return Result;
    };
    this.TryToParse = function (S, AValue) {
      var Result = false;
      Result = $mod.TryStrToBool(S,AValue);
      return Result;
    };
    this.ToInteger = function () {
      var Result = 0;
      Result = (this.get() ? 1 : 0);
      return Result;
    };
    this.ToString$1 = function (UseBoolStrs) {
      var Result = "";
      Result = $mod.BoolToStr(this.get(),UseBoolStrs === $mod.TUseBoolStrs.True);
      return Result;
    };
  });
  rtl.createHelper(this,"TByteBoolHelper",null,function () {
    this.Parse = function (S) {
      var Result = false;
      Result = $mod.StrToBool(S);
      return Result;
    };
    this.Size = function () {
      var Result = 0;
      Result = 1;
      return Result;
    };
    this.ToString = function (AValue, UseBoolStrs) {
      var Result = "";
      Result = $mod.BoolToStr(AValue,UseBoolStrs);
      return Result;
    };
    this.TryToParse = function (S, AValue) {
      var Result = false;
      Result = $mod.TryStrToBool(S,AValue);
      return Result;
    };
    this.ToInteger = function () {
      var Result = 0;
      Result = (this.get() ? 1 : 0);
      return Result;
    };
    this.ToString$1 = function (UseBoolStrs) {
      var Result = "";
      Result = $mod.BoolToStr(this.get(),UseBoolStrs);
      return Result;
    };
  });
  rtl.createHelper(this,"TWordBoolHelper",null,function () {
    this.Parse = function (S) {
      var Result = false;
      Result = $mod.StrToBool(S);
      return Result;
    };
    this.Size = function () {
      var Result = 0;
      Result = 2;
      return Result;
    };
    this.ToString = function (AValue, UseBoolStrs) {
      var Result = "";
      Result = $mod.BoolToStr(AValue,UseBoolStrs);
      return Result;
    };
    this.TryToParse = function (S, AValue) {
      var Result = false;
      Result = $mod.TryStrToBool(S,AValue);
      return Result;
    };
    this.ToInteger = function () {
      var Result = 0;
      Result = (this.get() ? 1 : 0);
      return Result;
    };
    this.ToString$1 = function (UseBoolStrs) {
      var Result = "";
      Result = $mod.BoolToStr(this.get(),UseBoolStrs);
      return Result;
    };
  });
  rtl.createHelper(this,"TLongBoolHelper",null,function () {
    this.Parse = function (S) {
      var Result = false;
      Result = $mod.StrToBool(S);
      return Result;
    };
    this.Size = function () {
      var Result = 0;
      Result = 4;
      return Result;
    };
    this.ToString = function (AValue, UseBoolStrs) {
      var Result = "";
      Result = $mod.BoolToStr(AValue,UseBoolStrs);
      return Result;
    };
    this.TryToParse = function (S, AValue) {
      var Result = false;
      Result = $mod.TryStrToBool(S,AValue);
      return Result;
    };
    this.ToInteger = function () {
      var Result = 0;
      Result = (this.get() ? 1 : 0);
      return Result;
    };
    this.ToString$1 = function (UseBoolStrs) {
      var Result = "";
      Result = $mod.BoolToStr(this.get(),UseBoolStrs);
      return Result;
    };
  });
  rtl.createClass(this,"TStringBuilder",pas.System.TObject,function () {
    this.DefaultCapacity = 64;
    this.$init = function () {
      pas.System.TObject.$init.call(this);
      this.FData = "";
      this.FMaxCapacity = 0;
    };
    this.GetCapacity = function () {
      var Result = 0;
      Result = this.FData.length;
      return Result;
    };
    this.SetCapacity = function (AValue) {
      if (AValue > this.FMaxCapacity) throw $mod.ERangeError.$create("CreateFmt",[rtl.getResStr(pas.RTLConsts,"SListCapacityError"),pas.System.VarRecs(0,AValue)]);
      if (AValue < this.GetLength()) throw $mod.ERangeError.$create("CreateFmt",[rtl.getResStr(pas.RTLConsts,"SListCapacityError"),pas.System.VarRecs(0,AValue)]);
    };
    this.GetC = function (Index) {
      var Result = "\x00";
      this.CheckNegative(Index + 1,"Index");
      this.CheckRange(Index + 1,0,this.GetLength());
      Result = this.FData.charAt((Index + 1) - 1);
      return Result;
    };
    this.SetC = function (Index, AValue) {
      this.CheckNegative(Index + 1,"Index");
      this.CheckRange(Index + 1,0,this.GetLength());
      this.FData = rtl.setCharAt(this.FData,(Index + 1) - 1,AValue);
    };
    this.GetLength = function () {
      var Result = 0;
      Result = this.FData.length;
      return Result;
    };
    this.SetLength = function (AValue) {
      this.CheckNegative(AValue,"AValue");
      this.CheckRange(AValue,0,this.FMaxCapacity);
      this.FData = rtl.strSetLength(this.FData,AValue);
    };
    this.CheckRange = function (Idx, Count, MaxLen) {
      if ((Idx < 0) || ((Idx + Count) > MaxLen)) throw $mod.ERangeError.$create("CreateFmt",[rtl.getResStr(pas.RTLConsts,"SListIndexError"),pas.System.VarRecs(0,Idx)]);
    };
    this.CheckNegative = function (AValue, AName) {
      if (AValue < 0) throw $mod.ERangeError.$create("CreateFmt",[rtl.getResStr(pas.RTLConsts,"SParamIsNegative"),pas.System.VarRecs(18,AName)]);
    };
    this.DoAppend = function (S) {
      this.FData = this.FData + S;
    };
    this.DoAppend$1 = function (AValue, Idx, aCount) {
      var S = "";
      var I = 0;
      S = "";
      this.CheckRange(Idx,aCount,rtl.length(AValue));
      for (var $l = Idx, $end = (Idx + aCount) - 1; $l <= $end; $l++) {
        I = $l;
        S = S + AValue[I];
      };
      this.DoAppend(S);
    };
    this.DoInsert = function (Index, AValue) {
      this.CheckRange(Index,0,this.GetLength() - 1);
      pas.System.Insert(AValue,{p: this, get: function () {
          return this.p.FData;
        }, set: function (v) {
          this.p.FData = v;
        }},Index + 1);
    };
    this.DoInsert$1 = function (Index, AValue, StartIndex, aCharCount) {
      var I = 0;
      var S = "";
      this.CheckRange(Index,0,this.GetLength() - 1);
      this.CheckNegative(StartIndex,"StartIndex");
      this.CheckNegative(aCharCount,"SBCharCount");
      this.CheckRange(StartIndex,aCharCount,rtl.length(AValue));
      S = "";
      for (var $l = StartIndex, $end = (StartIndex + aCharCount) - 1; $l <= $end; $l++) {
        I = $l;
        S = S + AValue[I];
      };
      this.DoInsert(Index,S);
    };
    this.DoReplace = function (Index, Old, New) {
      var OVLen = 0;
      OVLen = Old.length;
      pas.System.Delete({p: this, get: function () {
          return this.p.FData;
        }, set: function (v) {
          this.p.FData = v;
        }},Index + 1,OVLen);
      pas.System.Insert(New,{p: this, get: function () {
          return this.p.FData;
        }, set: function (v) {
          this.p.FData = v;
        }},Index + 1);
    };
    this.Grow = function () {
      var NewCapacity = 0;
      NewCapacity = this.GetCapacity() * 2;
      if (NewCapacity > this.FMaxCapacity) NewCapacity = this.FMaxCapacity;
      this.SetCapacity(NewCapacity);
    };
    this.Shrink = function () {
      if (rtl.trunc(this.GetCapacity() / 4) >= this.GetLength()) this.SetCapacity(rtl.trunc(this.GetCapacity() / 2));
    };
    this.Create$1 = function () {
      this.Create$4(64,2147483647);
      return this;
    };
    this.Create$2 = function (aCapacity) {
      this.Create$4(aCapacity,2147483647);
      return this;
    };
    this.Create$3 = function (AValue) {
      this.Create$5(AValue,64);
      return this;
    };
    this.Create$4 = function (aCapacity, aMaxCapacity) {
      this.FMaxCapacity = aMaxCapacity;
      this.SetCapacity(aCapacity);
      return this;
    };
    this.Create$5 = function (AValue, aCapacity) {
      this.Create$4(aCapacity,2147483647);
      if (AValue.length > 0) this.Append$14(AValue);
      return this;
    };
    this.Create$6 = function (AValue, StartIndex, aLength, aCapacity) {
      this.Create$5(pas.System.Copy(AValue,StartIndex + 1,aLength),aCapacity);
      return this;
    };
    this.Append = function (AValue) {
      var Result = null;
      this.DoAppend($mod.BoolToStr(AValue,true));
      Result = this;
      return Result;
    };
    this.Append$1 = function (AValue) {
      var Result = null;
      this.DoAppend($mod.IntToStr(AValue));
      Result = this;
      return Result;
    };
    this.Append$2 = function (AValue) {
      var Result = null;
      this.DoAppend(AValue);
      Result = this;
      return Result;
    };
    this.Append$3 = function (AValue) {
      var Result = null;
      this.DoAppend($mod.CurrToStr(AValue));
      Result = this;
      return Result;
    };
    this.Append$4 = function (AValue) {
      var Result = null;
      this.DoAppend($mod.FloatToStr(AValue));
      Result = this;
      return Result;
    };
    this.Append$5 = function (AValue) {
      var Result = null;
      this.DoAppend($mod.IntToStr(AValue));
      Result = this;
      return Result;
    };
    this.Append$6 = function (AValue) {
      var Result = null;
      this.DoAppend($mod.IntToStr(AValue));
      Result = this;
      return Result;
    };
    this.Append$7 = function (AValue) {
      var Result = null;
      this.DoAppend($mod.IntToStr(AValue));
      Result = this;
      return Result;
    };
    this.Append$8 = function (AValue) {
      var Result = null;
      this.DoAppend(AValue.ToString());
      Result = this;
      return Result;
    };
    this.Append$9 = function (AValue) {
      var Result = null;
      this.DoAppend($mod.IntToStr(AValue));
      Result = this;
      return Result;
    };
    this.Append$10 = function (AValue) {
      var Result = null;
      this.DoAppend($mod.IntToStr(AValue));
      Result = this;
      return Result;
    };
    this.Append$11 = function (AValue) {
      var Result = null;
      var I = 0;
      var L = 0;
      I = -1;
      L = rtl.length(AValue);
      if (L === 0) return this;
      do {
        I += 1;
      } while (!((I >= L) || (AValue[I] === "\x00")));
      this.DoAppend$1(AValue,0,I);
      Result = this;
      return Result;
    };
    this.Append$12 = function (AValue) {
      var Result = null;
      this.Append$14($mod.IntToStr(AValue));
      Result = this;
      return Result;
    };
    this.Append$13 = function (AValue) {
      var Result = null;
      this.DoAppend($mod.IntToStr(AValue));
      Result = this;
      return Result;
    };
    this.Append$14 = function (AValue) {
      var Result = null;
      this.DoAppend(AValue);
      Result = this;
      return Result;
    };
    this.Append$15 = function (AValue, RepeatCount) {
      var Result = null;
      this.DoAppend(pas.System.StringOfChar(AValue,RepeatCount));
      Result = this;
      return Result;
    };
    this.Append$16 = function (AValue, StartIndex, SBCharCount) {
      var Result = null;
      this.DoAppend$1(AValue,StartIndex,SBCharCount);
      Result = this;
      return Result;
    };
    this.Append$17 = function (AValue, StartIndex, Count) {
      var Result = null;
      this.CheckRange(StartIndex,Count,AValue.length);
      this.DoAppend(pas.System.Copy(AValue,StartIndex + 1,Count));
      Result = this;
      return Result;
    };
    this.Append$18 = function (Fmt, Args) {
      var Result = null;
      this.DoAppend($mod.Format(Fmt,Args));
      Result = this;
      return Result;
    };
    this.AppendFormat = function (Fmt, Args) {
      var Result = null;
      this.DoAppend($mod.Format(Fmt,Args));
      Result = this;
      return Result;
    };
    this.AppendLine = function () {
      var Result = null;
      this.DoAppend(pas.System.sLineBreak);
      Result = this;
      return Result;
    };
    this.AppendLine$1 = function (AValue) {
      var Result = null;
      this.DoAppend(AValue);
      Result = this.AppendLine();
      return Result;
    };
    this.Clear = function () {
      this.SetLength(0);
      this.SetCapacity(64);
    };
    this.CopyTo = function (SourceIndex, Destination, DestinationIndex, Count) {
      var I = 0;
      this.CheckNegative(Count,"Count");
      this.CheckNegative(DestinationIndex,"DestinationIndex");
      this.CheckRange(DestinationIndex,Count,rtl.length(Destination.get()));
      if (Count > 0) {
        this.CheckRange(SourceIndex,Count,this.GetLength());
        for (var $l = SourceIndex + 1, $end = SourceIndex + Count; $l <= $end; $l++) {
          I = $l;
          Destination.get()[DestinationIndex] = this.FData.charAt(I - 1);
        };
      };
    };
    this.EnsureCapacity = function (aCapacity) {
      var Result = 0;
      this.CheckRange(aCapacity,0,this.FMaxCapacity);
      if (this.GetCapacity() < aCapacity) this.SetCapacity(aCapacity);
      Result = this.GetCapacity();
      return Result;
    };
    this.Equals$1 = function (StringBuilder) {
      var Result = false;
      Result = StringBuilder !== null;
      if (Result) Result = (this.GetLength() === StringBuilder.GetLength()) && (this.FMaxCapacity === StringBuilder.FMaxCapacity) && (this.FData === StringBuilder.FData.charAt(-1));
      return Result;
    };
    this.Insert = function (Index, AValue) {
      var Result = null;
      this.DoInsert(Index,$mod.BoolToStr(AValue,true));
      Result = this;
      return Result;
    };
    this.Insert$1 = function (Index, AValue) {
      var Result = null;
      this.DoInsert(Index,$mod.IntToStr(AValue));
      Result = this;
      return Result;
    };
    this.Insert$2 = function (Index, AValue) {
      var Result = null;
      this.DoInsert(Index,AValue);
      Result = this;
      return Result;
    };
    this.Insert$3 = function (Index, AValue) {
      var Result = null;
      this.DoInsert(Index,$mod.CurrToStr(AValue));
      Result = this;
      return Result;
    };
    this.Insert$4 = function (Index, AValue) {
      var Result = null;
      this.DoInsert(Index,$mod.FloatToStr(AValue));
      Result = this;
      return Result;
    };
    this.Insert$5 = function (Index, AValue) {
      var Result = null;
      this.DoInsert(Index,$mod.IntToStr(AValue));
      Result = this;
      return Result;
    };
    this.Insert$6 = function (Index, AValue) {
      var Result = null;
      this.DoInsert(Index,$mod.IntToStr(AValue));
      Result = this;
      return Result;
    };
    this.Insert$7 = function (Index, AValue) {
      var Result = null;
      this.DoInsert$1(Index,AValue,0,rtl.length(AValue));
      Result = this;
      return Result;
    };
    this.Insert$8 = function (Index, AValue) {
      var Result = null;
      this.DoInsert(Index,$mod.IntToStr(AValue));
      Result = this;
      return Result;
    };
    this.Insert$9 = function (Index, AValue) {
      var Result = null;
      this.DoInsert(Index,AValue.ToString());
      Result = this;
      return Result;
    };
    this.Insert$10 = function (Index, AValue) {
      var Result = null;
      this.DoInsert(Index,$mod.IntToStr(AValue));
      Result = this;
      return Result;
    };
    this.Insert$11 = function (Index, AValue) {
      var Result = null;
      this.DoInsert(Index,AValue);
      Result = this;
      return Result;
    };
    this.Insert$12 = function (Index, AValue) {
      var Result = null;
      this.DoInsert(Index,$mod.IntToStr(AValue));
      Result = this;
      return Result;
    };
    this.Insert$13 = function (Index, AValue) {
      var Result = null;
      this.DoInsert(Index,$mod.IntToStr(AValue));
      Result = this;
      return Result;
    };
    this.Insert$14 = function (Index, AValue) {
      var Result = null;
      this.DoInsert(Index,$mod.IntToStr(AValue));
      Result = this;
      return Result;
    };
    this.Insert$15 = function (Index, AValue, aRepeatCount) {
      var Result = null;
      var I = 0;
      for (var $l = 0, $end = aRepeatCount - 1; $l <= $end; $l++) {
        I = $l;
        this.DoInsert(Index,AValue);
      };
      Result = this;
      return Result;
    };
    this.Insert$16 = function (Index, AValue, startIndex, SBCharCount) {
      var Result = null;
      this.DoInsert$1(Index,AValue,startIndex,SBCharCount);
      Result = this;
      return Result;
    };
    this.Remove = function (StartIndex, RemLength) {
      var Result = null;
      var MoveIndex = 0;
      if (RemLength === 0) return this;
      this.CheckNegative(RemLength,"RemLength");
      this.CheckRange(StartIndex,0,this.GetLength());
      MoveIndex = StartIndex + RemLength;
      this.CheckRange(MoveIndex,0,this.GetLength());
      pas.System.Delete({p: this, get: function () {
          return this.p.FData;
        }, set: function (v) {
          this.p.FData = v;
        }},StartIndex + 1,RemLength);
      this.Shrink();
      Result = this;
      return Result;
    };
    this.Replace = function (OldValue, NewValue) {
      var Result = null;
      Result = this.Replace$1(OldValue,NewValue,0,this.GetLength());
      return Result;
    };
    this.Replace$1 = function (OldValue, NewValue, StartIndex, Count) {
      var Result = null;
      var I = 0;
      var Start = "";
      if (Count === 0) return this;
      this.CheckNegative(StartIndex,"StartIndex");
      this.CheckNegative(Count,"Count");
      this.CheckRange(StartIndex,Count,this.GetLength());
      Start = pas.System.Copy(this.FData,1,StartIndex);
      this.FData = pas.System.Copy$1(this.FData,StartIndex + 1);
      for (var $l = 1, $end = Count; $l <= $end; $l++) {
        I = $l;
        this.FData = $mod.StringReplace(this.FData,OldValue,NewValue,{});
      };
      this.FData = Start + this.FData;
      Result = this;
      return Result;
    };
    this.ToString = function () {
      var Result = "";
      Result = this.ToString$2(0,this.GetLength());
      return Result;
    };
    this.ToString$2 = function (aStartIndex, aLength) {
      var Result = "";
      this.CheckNegative(aStartIndex,"aStartIndex");
      this.CheckNegative(aLength,"aLength");
      this.CheckRange(aStartIndex,aLength,this.GetLength());
      Result = pas.System.Copy(this.FData,1 + aStartIndex,aStartIndex + aLength);
      return Result;
    };
  });
  rtl.createClass(this,"TEncoding",pas.System.TObject,function () {
    this.FANSI = null;
    this.FASCII = null;
    this.FUnicode = null;
    this.FUTF7 = null;
    this.FUTF8 = null;
    this.GetANSI = function () {
      var Result = null;
      if (!(this.FANSI != null)) $mod.TEncoding.FANSI = $mod.TANSIEncoding.$create("Create");
      Result = this.FANSI;
      return Result;
    };
    this.GetASCII = function () {
      var Result = null;
      if (!(this.FASCII != null)) $mod.TEncoding.FASCII = $mod.TASCIIEncoding.$create("Create");
      Result = this.FASCII;
      return Result;
    };
    this.GetDefault = function () {
      var Result = null;
      Result = this.GetANSI();
      return Result;
    };
    this.GetUnicode = function () {
      var Result = null;
      if (!(this.FUnicode != null)) $mod.TEncoding.FUnicode = $mod.TUnicodeEncoding.$create("Create");
      Result = this.FUnicode;
      return Result;
    };
    this.GetUTF7 = function () {
      var Result = null;
      if (!(this.FUTF7 != null)) $mod.TEncoding.FUTF7 = $mod.TUTF7Encoding.$create("Create");
      Result = this.FUTF7;
      return Result;
    };
    this.GetUTF8 = function () {
      var Result = null;
      if (!(this.FUTF8 != null)) $mod.TEncoding.FUTF8 = $mod.TUTF8Encoding.$create("Create");
      Result = this.FUTF8;
      return Result;
    };
    var cEncoding = "utf-8";
    this.GetEncoding = function () {
      var Result = "";
      Result = cEncoding;
      return Result;
    };
    this.IsStandardEncoding = function (AEncoding) {
      var Result = false;
      Result = (AEncoding !== null) && ((AEncoding === this.GetANSI()) || (AEncoding === this.GetUnicode()));
      return Result;
    };
    this.GetByteCount$1 = function (AChars, ACharCount) {
      var Result = 0;
      Result = this.GetByteCount($mod.TStringHelper.Substring$1.call({get: function () {
          return AChars;
        }, set: function (v) {
          rtl.raiseE("EPropReadOnly");
        }},0,ACharCount));
      return Result;
    };
    this.GetByteCount$2 = function (AChars, ACharIndex, ACharCount) {
      var Result = 0;
      Result = this.GetByteCount($mod.TStringHelper.Substring$1.call({get: function () {
          return AChars;
        }, set: function (v) {
          rtl.raiseE("EPropReadOnly");
        }},ACharIndex,ACharCount));
      return Result;
    };
    this.GetBytes$1 = function (AChars, ACharCount) {
      var Result = [];
      Result = this.GetBytes($mod.TStringHelper.Substring$1.call({get: function () {
          return AChars;
        }, set: function (v) {
          rtl.raiseE("EPropReadOnly");
        }},0,ACharCount));
      return Result;
    };
    this.GetBytes$2 = function (AChars, ACharIndex, ACharCount) {
      var Result = [];
      Result = this.GetBytes($mod.TStringHelper.Substring$1.call({get: function () {
          return AChars;
        }, set: function (v) {
          rtl.raiseE("EPropReadOnly");
        }},ACharIndex,ACharCount));
      return Result;
    };
    this.GetString$1 = function (ABytes, ACharCount) {
      var Result = "";
      Result = this.GetString($impl.TBytesHelper.SubBytes.call({get: function () {
          return ABytes;
        }, set: function (v) {
          rtl.raiseE("EPropReadOnly");
        }},0,ACharCount));
      return Result;
    };
    this.GetString$2 = function (ABytes, ACharIndex, ACharCount) {
      var Result = "";
      Result = this.GetString($impl.TBytesHelper.SubBytes.call({get: function () {
          return ABytes;
        }, set: function (v) {
          rtl.raiseE("EPropReadOnly");
        }},ACharIndex,ACharCount));
      return Result;
    };
  });
  rtl.createClass(this,"TANSIEncoding",this.TEncoding,function () {
    var cEncoding$1 = "windows-1252";
    this.GetEncoding = function () {
      var Result = "";
      Result = cEncoding$1;
      return Result;
    };
    this.GetByteCount = function (AChars) {
      var Result = 0;
      Result = $mod.TStringHelper.GetLength.call({get: function () {
          return AChars;
        }, set: function (v) {
          rtl.raiseE("EPropReadOnly");
        }});
      return Result;
    };
    this.GetBytes = function (AChars) {
      var Result = [];
      Result = $mod.BytesOf(AChars);
      return Result;
    };
    this.GetString = function (ABytes) {
      var Result = "";
      Result = $mod.StringOf(ABytes);
      return Result;
    };
  });
  rtl.createClass(this,"TASCIIEncoding",this.TANSIEncoding,function () {
    var cEncoding$2 = "ISO-8859-2";
    this.GetEncoding = function () {
      var Result = "";
      Result = cEncoding$2;
      return Result;
    };
  });
  rtl.createClass(this,"TUnicodeEncoding",this.TEncoding,function () {
    this.InternalGetBytes = function (AChars, ABytes) {
      var lWords = [];
      lWords = [];
      for (var lCount = 0; lCount < AChars.length; lCount++)
      lWords.push(AChars.charCodeAt(lCount));
      ABytes.set($impl.TWordsHelper.ToBytes.call({get: function () {
          return lWords;
        }, set: function (v) {
          lWords = v;
        }}));
    };
    var cEncoding$1 = "unicode";
    this.GetEncoding = function () {
      var Result = "";
      Result = cEncoding$1;
      return Result;
    };
    var cCharSize = 2;
    this.GetByteCount = function (AChars) {
      var Result = 0;
      Result = 2 * $mod.TStringHelper.GetLength.call({get: function () {
          return AChars;
        }, set: function (v) {
          rtl.raiseE("EPropReadOnly");
        }});
      return Result;
    };
    this.GetBytes = function (AChars) {
      var Result = [];
      this.InternalGetBytes(AChars,{get: function () {
          return Result;
        }, set: function (v) {
          Result = v;
        }});
      return Result;
    };
    this.GetString = function (ABytes) {
      var Result = "";
      var lWords = [];
      var lBuffer = "";
      lBuffer = $mod.TStringHelper.Empty;
      lWords = $impl.TWordsHelper.FromBytes(ABytes);
      if (rtl.length(lWords) > 0) {
        for (var lCount = 0; lCount < lWords.length; lCount++)
        lBuffer += string.fromCharCode(lWords[lCount]);
      };
      Result = lBuffer;
      return Result;
    };
  });
  rtl.createClass(this,"TUTF8Encoding",this.TEncoding,function () {
    this.BytesToMemory = function (ABytes) {
      var Result = null;
      var lArray = null;
      Result = new ArrayBuffer($impl.TBytesHelper.GetLength.call({get: function () {
          return ABytes;
        }, set: function (v) {
          ABytes = v;
        }}));
      lArray = new Uint8Array(Result);
      lArray.set(ABytes);
      return Result;
    };
    this.MemoryToBytes = function (AMem) {
      var Result = [];
      var lCount = 0;
      for (var $l = 0, $end = AMem.length - 1; $l <= $end; $l++) {
        lCount = $l;
        Result[lCount] = AMem[lCount];
      };
      return Result;
    };
    var cEncoding$1 = "utf-8";
    this.GetEncoding = function () {
      var Result = "";
      Result = cEncoding$1;
      return Result;
    };
    this.GetByteCount = function (AChars) {
      var Result = 0;
      Result = $impl.TBytesHelper.GetLength.call({a: this.GetBytes(AChars), get: function () {
          return this.a;
        }, set: function (v) {
          this.a = v;
        }});
      return Result;
    };
    this.GetBytes = function (AChars) {
      var Result = [];
      var lArray = null;
      var lEncoder = null;
      lEncoder = new TextEncoder();
      lArray = lEncoder.encode(AChars);
      Result = this.$class.MemoryToBytes(lArray);
      return Result;
    };
    this.GetString = function (ABytes) {
      var Result = "";
      var lArray = null;
      var lDecoder = null;
      lDecoder = new TextDecoder();
      lArray = this.$class.BytesToMemory(rtl.arrayRef(ABytes));
      Result = lDecoder.decode(lArray);
      return Result;
    };
  });
  rtl.createClass(this,"TUTF7Encoding",this.TUTF8Encoding,function () {
    var cEncoding$2 = "utf-7";
    this.GetEncoding = function () {
      var Result = "";
      Result = cEncoding$2;
      return Result;
    };
  });
  this.TCmdLineSwitchType = {"0": "clstValueNextParam", clstValueNextParam: 0, "1": "clstValueAppended", clstValueAppended: 1, "2": "clstValueInternalUse", clstValueInternalUse: 2};
  this.$rtti.$Enum("TCmdLineSwitchType",{minvalue: 0, maxvalue: 2, ordtype: 1, enumtype: this.TCmdLineSwitchType});
  this.$rtti.$Set("TCmdLineSwitchTypes",{comptype: this.$rtti["TCmdLineSwitchType"]});
  this.clstValueNextParamForce = this.TCmdLineSwitchType.clstValueInternalUse;
  this.SwitchChars = rtl.createSet(45);
  this.FindCmdLineSwitch = function (ASwitch) {
    var Result = false;
    Result = $mod.FindCmdLineSwitch$2(ASwitch,$mod.SwitchChars,true);
    return Result;
  };
  this.FindCmdLineSwitch$1 = function (ASwitch, AIgnoreCase) {
    var Result = false;
    Result = $mod.FindCmdLineSwitch$2(ASwitch,$mod.SwitchChars,AIgnoreCase);
    return Result;
  };
  this.FindCmdLineSwitch$2 = function (ASwitch, AChars, AIgnoreCase) {
    var Result = false;
    var lSameSwitch = null;
    var lSwitch = "";
    var lSwitches = [];
    var lValue = "";
    if (AIgnoreCase) {
      lSameSwitch = $mod.AnsiSameText}
     else lSameSwitch = $impl.EqualsStr;
    lSwitches = $impl.ParseCmdLine();
    for (var $in = lSwitches, $l = 0, $end = rtl.length($in) - 1; $l <= $end; $l++) {
      lValue = $in[$l];
      if (rtl.eqSet(AChars,{}) || $mod.CharInSet$1(lValue.charAt(0),AChars)) {
        lSwitch = $mod.TStringHelper.Substring.call({get: function () {
            return lValue;
          }, set: function (v) {
            lValue = v;
          }},1);
        if (lSameSwitch(lSwitch,ASwitch)) return true;
      };
    };
    Result = false;
    return Result;
  };
  var cDeli$1 = ":";
  this.FindCmdLineSwitch$3 = function (ASwitch, AValue, AIgnoreCase, ASwitchTypes) {
    var Result = false;
    var lCompare = null;
    var lCount = 0;
    var lParam = "";
    var lSwitches = [];
    var lSwitchLen = 0;
    var lValueOfs = 0;
    Result = false;
    AValue.set($mod.TStringHelper.Empty);
    if (AIgnoreCase) {
      lCompare = $mod.SameText}
     else lCompare = $mod.SameStr;
    lSwitchLen = $mod.TStringHelper.GetLength.call({get: function () {
        return ASwitch;
      }, set: function (v) {
        rtl.raiseE("EPropReadOnly");
      }});
    lSwitches = $impl.ParseCmdLine();
    for (var $l = 0, $end = rtl.length(lSwitches) - 1; $l <= $end; $l++) {
      lCount = $l;
      lParam = lSwitches[lCount];
      if (!$mod.CharInSet$1($mod.TStringHelper.GetChar.call({get: function () {
          return lParam;
        }, set: function (v) {
          lParam = v;
        }},0),$mod.SwitchChars)) continue;
      if (!lCompare($mod.TStringHelper.Substring$1.call({get: function () {
          return lParam;
        }, set: function (v) {
          lParam = v;
        }},1,lSwitchLen),ASwitch)) continue;
      if ($mod.TStringHelper.GetLength.call({get: function () {
          return lParam;
        }, set: function (v) {
          lParam = v;
        }}) > (lSwitchLen + 1)) {
        if (!($mod.TCmdLineSwitchType.clstValueAppended in ASwitchTypes)) continue;
        lValueOfs = lSwitchLen + 1;
        if ($mod.TStringHelper.GetChar.call({get: function () {
            return lParam;
          }, set: function (v) {
            lParam = v;
          }},lValueOfs) === cDeli$1) lValueOfs += 1;
        AValue.set($mod.TStringHelper.Substring$1.call({get: function () {
            return lParam;
          }, set: function (v) {
            lParam = v;
          }},lValueOfs,2147483647));
      } else if (($mod.TCmdLineSwitchType.clstValueNextParam in ASwitchTypes) && (lCount < (rtl.length(lSwitches) - 1)) && !$mod.CharInSet$1($mod.TStringHelper.GetChar.call({a: lCount + 1, p: lSwitches, get: function () {
          return this.p[this.a];
        }, set: function (v) {
          this.p[this.a] = v;
        }},0),$mod.SwitchChars)) AValue.set(lSwitches[lCount + 1]);
      Result = true;
      break;
    };
    return Result;
  };
  this.$rtti.$RefToProcVar("TProc",{procsig: rtl.newTIProcSig([])});
  this.$rtti.$RefToProcVar("TProc<System.Boolean>",{procsig: rtl.newTIProcSig([["AArg1",rtl.boolean]])});
  this.$rtti.$RefToProcVar("TProc<System.Longint>",{procsig: rtl.newTIProcSig([["AArg1",rtl.longint]])});
  $mod.$implcode = function () {
    rtl.createHelper($impl,"TBytesHelper",null,function () {
      this.GetLength = function () {
        var Result = 0;
        Result = rtl.length(this.get());
        return Result;
      };
      this.SetLength = function (AValue) {
        this.set(rtl.arraySetLength(this.get(),0,AValue));
      };
      this.High = function () {
        var Result = 0;
        Result = rtl.length(this.get()) - 1;
        return Result;
      };
      this.Low = function () {
        var Result = 0;
        Result = 0;
        return Result;
      };
      this.SubBytes = function (AStartIndex, ALength) {
        var Result = [];
        Result = rtl.arrayCopy(0,this.get(),AStartIndex,ALength);
        return Result;
      };
    });
    $mod.$rtti.$DynArray("TWords",{eltype: rtl.word});
    rtl.createHelper($impl,"TWordsHelper",null,function () {
      this.GetLength = function () {
        var Result = 0;
        Result = rtl.length(this.get());
        return Result;
      };
      this.SetLength = function (AValue) {
        this.set(rtl.arraySetLength(this.get(),0,AValue));
      };
      var cBytesPerWord = 2;
      this.FromBytes = function (ABytes) {
        var Result = [];
        var lCount = 0;
        var lLow = 0;
        var lHigh = 0;
        lCount = $impl.TBytesHelper.GetLength.call({get: function () {
            return ABytes;
          }, set: function (v) {
            rtl.raiseE("EPropReadOnly");
          }});
        if (pas.System.Odd(lCount)) lCount += 1;
        $impl.TWordsHelper.SetLength.call({get: function () {
            return Result;
          }, set: function (v) {
            Result = v;
          }},rtl.trunc(lCount / 2));
        lCount = $impl.TBytesHelper.Low.call({get: function () {
            return ABytes;
          }, set: function (v) {
            rtl.raiseE("EPropReadOnly");
          }});
        while (lCount <= $impl.TBytesHelper.High.call({get: function () {
            return ABytes;
          }, set: function (v) {
            rtl.raiseE("EPropReadOnly");
          }})) {
          lLow = ABytes[lCount];
          if ((lCount + 1) <= $impl.TBytesHelper.High.call({get: function () {
              return ABytes;
            }, set: function (v) {
              rtl.raiseE("EPropReadOnly");
            }})) {
            lHigh = ABytes[lCount + 1]}
           else lHigh = 0;
          Result[rtl.trunc(lCount / 2)] = $mod.TWordHelper.FromBytes(lLow,lHigh);
          lCount += 2;
        };
        return Result;
      };
      this.High = function () {
        var Result = 0;
        Result = rtl.length(this.get()) - 1;
        return Result;
      };
      this.Low = function () {
        var Result = 0;
        Result = 0;
        return Result;
      };
      var cBytesPerWord$1 = 2;
      this.ToBytes = function () {
        var Result = [];
        var lLow = 0;
        var lHigh = 0;
        var lCount = 0;
        var lNewIndex = 0;
        $impl.TBytesHelper.SetLength.call({get: function () {
            return Result;
          }, set: function (v) {
            Result = v;
          }},$impl.TWordsHelper.GetLength.call(this) * 2);
        for (var $l = $impl.TWordsHelper.Low.call(this), $end = $impl.TWordsHelper.High.call(this); $l <= $end; $l++) {
          lCount = $l;
          $mod.TWordHelper.ToBytes.call({a: lCount, p: this.get(), get: function () {
              return this.p[this.a];
            }, set: function (v) {
              this.p[this.a] = v;
            }},{get: function () {
              return lLow;
            }, set: function (v) {
              lLow = v;
            }},{get: function () {
              return lHigh;
            }, set: function (v) {
              lHigh = v;
            }});
          lNewIndex = lCount * 2;
          Result[lNewIndex] = lLow;
          Result[lNewIndex + 1] = lHigh;
        };
        return Result;
      };
    });
    $impl.DefaultShortMonthNames = ["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];
    $impl.DefaultLongMonthNames = ["January","February","March","April","May","June","July","August","September","October","November","December"];
    $impl.DefaultShortDayNames = ["Sun","Mon","Tue","Wed","Thu","Fri","Sat"];
    $impl.DefaultLongDayNames = ["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"];
    $impl.FInvariant = $mod.TFormatSettings.$new();
    $impl.FInvariantCreated = false;
    $impl.DoShowException = function (S) {
      if ($mod.OnShowException != null) {
        $mod.OnShowException(S)}
       else {
        window.alert(S);
      };
    };
    $mod.$rtti.$ProcVar("TRTLExceptionHandler",{procsig: rtl.newTIProcSig([["aError",rtl.jsvalue]])});
    $impl.OnPascalException = null;
    $impl.OnJSException = null;
    $impl.RTLExceptionHook = function (aError) {
      var S = "";
      if (pas.JS.isClassInstance(aError)) {
        if ($impl.OnPascalException != null) {
          $impl.OnPascalException(rtl.getObject(aError))}
         else $mod.ShowException(rtl.getObject(aError),null);
      } else if (rtl.isObject(aError)) {
        if ($impl.OnJSException != null) {
          $impl.OnJSException(aError)}
         else {
          if (aError.hasOwnProperty("message")) {
            S = rtl.getResStr($mod,"SErrUnknownExceptionType") + ("" + aError["message"])}
           else S = rtl.getResStr($mod,"SErrUnknownExceptionType") + aError.toString();
          $impl.DoShowException(S);
        };
      } else {
        S = rtl.getResStr($mod,"SErrUnknownExceptionType") + ("" + aError);
        $impl.DoShowException(S);
      };
    };
    $impl.CheckBoolStrs = function () {
      if (rtl.length($mod.TrueBoolStrs) === 0) {
        $mod.TrueBoolStrs = rtl.arraySetLength($mod.TrueBoolStrs,"",1);
        $mod.TrueBoolStrs[0] = "True";
      };
      if (rtl.length($mod.FalseBoolStrs) === 0) {
        $mod.FalseBoolStrs = rtl.arraySetLength($mod.FalseBoolStrs,"",1);
        $mod.FalseBoolStrs[0] = "False";
      };
    };
    $impl.feInvalidFormat = 1;
    $impl.feMissingArgument = 2;
    $impl.feInvalidArgIndex = 3;
    $impl.DoFormatError = function (ErrCode, fmt) {
      var $tmp = ErrCode;
      if ($tmp === 1) {
        throw $mod.EConvertError.$create("CreateFmt",[rtl.getResStr(pas.RTLConsts,"SInvalidFormat"),pas.System.VarRecs(18,fmt)])}
       else if ($tmp === 2) {
        throw $mod.EConvertError.$create("CreateFmt",[rtl.getResStr(pas.RTLConsts,"SArgumentMissing"),pas.System.VarRecs(18,fmt)])}
       else if ($tmp === 3) throw $mod.EConvertError.$create("CreateFmt",[rtl.getResStr(pas.RTLConsts,"SInvalidArgIndex"),pas.System.VarRecs(18,fmt)]);
    };
    $impl.maxdigits = 15;
    $impl.ReplaceDecimalSep = function (S, DS) {
      var Result = "";
      var P = 0;
      P = pas.System.Pos(".",S);
      if (P > 0) {
        Result = pas.System.Copy(S,1,P - 1) + DS + pas.System.Copy(S,P + 1,S.length - P)}
       else Result = S;
      return Result;
    };
    $impl.FormatGeneralFloat = function (Value, Precision, DS) {
      var Result = "";
      var P = 0;
      var PE = 0;
      var Q = 0;
      var Exponent = 0;
      if ((Precision === -1) || (Precision > 15)) Precision = 15;
      Result = rtl.floatToStr(Value,Precision + 7);
      Result = $mod.TrimLeft(Result);
      P = pas.System.Pos(".",Result);
      if (P === 0) return Result;
      PE = pas.System.Pos("E",Result);
      if (PE === 0) {
        Result = $impl.ReplaceDecimalSep(Result,DS);
        return Result;
      };
      Q = PE + 2;
      Exponent = 0;
      while (Q <= Result.length) {
        Exponent = ((Exponent * 10) + Result.charCodeAt(Q - 1)) - 48;
        Q += 1;
      };
      if (Result.charAt((PE + 1) - 1) === "-") Exponent = -Exponent;
      if (((P + Exponent) < PE) && (Exponent > -6)) {
        Result = rtl.strSetLength(Result,PE - 1);
        if (Exponent >= 0) {
          for (var $l = 0, $end = Exponent - 1; $l <= $end; $l++) {
            Q = $l;
            Result = rtl.setCharAt(Result,P - 1,Result.charAt((P + 1) - 1));
            P += 1;
          };
          Result = rtl.setCharAt(Result,P - 1,".");
          P = 1;
          if (Result.charAt(P - 1) === "-") P += 1;
          while ((Result.charAt(P - 1) === "0") && (P < Result.length) && (pas.System.Copy(Result,P + 1,DS.length) !== DS)) pas.System.Delete({get: function () {
              return Result;
            }, set: function (v) {
              Result = v;
            }},P,1);
        } else {
          pas.System.Insert(pas.System.Copy("00000",1,-Exponent),{get: function () {
              return Result;
            }, set: function (v) {
              Result = v;
            }},P - 1);
          Result = rtl.setCharAt(Result,P - Exponent - 1,Result.charAt(P - Exponent - 1 - 1));
          Result = rtl.setCharAt(Result,P - 1,".");
          if (Exponent !== -1) Result = rtl.setCharAt(Result,P - Exponent - 1 - 1,"0");
        };
        Q = Result.length;
        while ((Q > 0) && (Result.charAt(Q - 1) === "0")) Q -= 1;
        if (Result.charAt(Q - 1) === ".") Q -= 1;
        if ((Q === 0) || ((Q === 1) && (Result.charAt(0) === "-"))) {
          Result = "0"}
         else Result = rtl.strSetLength(Result,Q);
      } else {
        while (Result.charAt(PE - 1 - 1) === "0") {
          pas.System.Delete({get: function () {
              return Result;
            }, set: function (v) {
              Result = v;
            }},PE - 1,1);
          PE -= 1;
        };
        if (Result.charAt(PE - 1 - 1) === DS) {
          pas.System.Delete({get: function () {
              return Result;
            }, set: function (v) {
              Result = v;
            }},PE - 1,1);
          PE -= 1;
        };
        if (Result.charAt((PE + 1) - 1) === "+") {
          pas.System.Delete({get: function () {
              return Result;
            }, set: function (v) {
              Result = v;
            }},PE + 1,1)}
         else PE += 1;
        while (Result.charAt((PE + 1) - 1) === "0") pas.System.Delete({get: function () {
            return Result;
          }, set: function (v) {
            Result = v;
          }},PE + 1,1);
      };
      Result = $impl.ReplaceDecimalSep(Result,DS);
      return Result;
    };
    $impl.FormatExponentFloat = function (Value, Precision, Digits, DS) {
      var Result = "";
      var P = 0;
      DS = $mod.FormatSettings.DecimalSeparator;
      if ((Precision === -1) || (Precision > 15)) Precision = 15;
      Result = rtl.floatToStr(Value,Precision + 7);
      while (Result.charAt(0) === " ") pas.System.Delete({get: function () {
          return Result;
        }, set: function (v) {
          Result = v;
        }},1,1);
      P = pas.System.Pos("E",Result);
      if (P === 0) {
        Result = $impl.ReplaceDecimalSep(Result,DS);
        return Result;
      };
      P += 2;
      if (Digits > 4) Digits = 4;
      Digits = (Result.length - P - Digits) + 1;
      if (Digits < 0) {
        pas.System.Insert(pas.System.Copy("0000",1,-Digits),{get: function () {
            return Result;
          }, set: function (v) {
            Result = v;
          }},P)}
       else while ((Digits > 0) && (Result.charAt(P - 1) === "0")) {
        pas.System.Delete({get: function () {
            return Result;
          }, set: function (v) {
            Result = v;
          }},P,1);
        if (P > Result.length) {
          pas.System.Delete({get: function () {
              return Result;
            }, set: function (v) {
              Result = v;
            }},P - 2,2);
          break;
        };
        Digits -= 1;
      };
      Result = $impl.ReplaceDecimalSep(Result,DS);
      return Result;
    };
    $impl.FormatFixedFloat = function (Value, Digits, DS) {
      var Result = "";
      if (Digits === -1) {
        Digits = 2}
       else if (Digits > 18) Digits = 18;
      Result = rtl.floatToStr(Value,0,Digits);
      if ((Result !== "") && (Result.charAt(0) === " ")) pas.System.Delete({get: function () {
          return Result;
        }, set: function (v) {
          Result = v;
        }},1,1);
      Result = $impl.ReplaceDecimalSep(Result,DS);
      return Result;
    };
    $impl.FormatNumberFloat = function (Value, Digits, DS, TS) {
      var Result = "";
      var P = 0;
      if (Digits === -1) {
        Digits = 2}
       else if (Digits > 15) Digits = 15;
      Result = rtl.floatToStr(Value,0,Digits);
      if ((Result !== "") && (Result.charAt(0) === " ")) pas.System.Delete({get: function () {
          return Result;
        }, set: function (v) {
          Result = v;
        }},1,1);
      P = pas.System.Pos(".",Result);
      if (P <= 0) P = Result.length + 1;
      Result = $impl.ReplaceDecimalSep(Result,DS);
      P -= 3;
      if ((TS !== "") && (TS !== "\x00")) while (P > 1) {
        if (Result.charAt(P - 1 - 1) !== "-") pas.System.Insert(TS,{get: function () {
            return Result;
          }, set: function (v) {
            Result = v;
          }},P);
        P -= 3;
      };
      return Result;
    };
    $impl.RemoveLeadingNegativeSign = function (AValue, DS, aThousandSeparator) {
      var Result = false;
      var i = 0;
      var TS = "";
      var StartPos = 0;
      Result = false;
      StartPos = 2;
      TS = aThousandSeparator;
      for (var $l = StartPos, $end = AValue.get().length; $l <= $end; $l++) {
        i = $l;
        Result = (AValue.get().charCodeAt(i - 1) in rtl.createSet(48,DS.charCodeAt(),69,43)) || (AValue.get().charAt(i - 1) === TS);
        if (!Result) break;
      };
      if (Result && (AValue.get().charAt(0) === "-")) pas.System.Delete(AValue,1,1);
      return Result;
    };
    $impl.FormatNumberCurrency = function (Value, Digits, aSettings) {
      var Result = "";
      var Negative = false;
      var P = 0;
      var CS = "";
      var DS = "";
      var TS = "";
      DS = aSettings.DecimalSeparator;
      TS = aSettings.ThousandSeparator;
      CS = aSettings.CurrencyString;
      if (Digits === -1) {
        Digits = aSettings.CurrencyDecimals}
       else if (Digits > 18) Digits = 18;
      Result = rtl.floatToStr(Value / 10000,0,Digits);
      Negative = Result.charAt(0) === "-";
      if (Negative) pas.System.Delete({get: function () {
          return Result;
        }, set: function (v) {
          Result = v;
        }},1,1);
      P = pas.System.Pos(".",Result);
      if (TS !== "") {
        if (P !== 0) {
          Result = $impl.ReplaceDecimalSep(Result,DS)}
         else P = Result.length + 1;
        P -= 3;
        while (P > 1) {
          pas.System.Insert(TS,{get: function () {
              return Result;
            }, set: function (v) {
              Result = v;
            }},P);
          P -= 3;
        };
      };
      if (Negative) $impl.RemoveLeadingNegativeSign({get: function () {
          return Result;
        }, set: function (v) {
          Result = v;
        }},DS,TS);
      if (!Negative) {
        var $tmp = aSettings.CurrencyFormat;
        if ($tmp === 0) {
          Result = CS + Result}
         else if ($tmp === 1) {
          Result = Result + CS}
         else if ($tmp === 2) {
          Result = CS + " " + Result}
         else if ($tmp === 3) Result = Result + " " + CS;
      } else {
        var $tmp1 = aSettings.NegCurrFormat;
        if ($tmp1 === 0) {
          Result = "(" + CS + Result + ")"}
         else if ($tmp1 === 1) {
          Result = "-" + CS + Result}
         else if ($tmp1 === 2) {
          Result = CS + "-" + Result}
         else if ($tmp1 === 3) {
          Result = CS + Result + "-"}
         else if ($tmp1 === 4) {
          Result = "(" + Result + CS + ")"}
         else if ($tmp1 === 5) {
          Result = "-" + Result + CS}
         else if ($tmp1 === 6) {
          Result = Result + "-" + CS}
         else if ($tmp1 === 7) {
          Result = Result + CS + "-"}
         else if ($tmp1 === 8) {
          Result = "-" + Result + " " + CS}
         else if ($tmp1 === 9) {
          Result = "-" + CS + " " + Result}
         else if ($tmp1 === 10) {
          Result = Result + " " + CS + "-"}
         else if ($tmp1 === 11) {
          Result = CS + " " + Result + "-"}
         else if ($tmp1 === 12) {
          Result = CS + " " + "-" + Result}
         else if ($tmp1 === 13) {
          Result = Result + "-" + " " + CS}
         else if ($tmp1 === 14) {
          Result = "(" + CS + " " + Result + ")"}
         else if ($tmp1 === 15) Result = "(" + Result + " " + CS + ")";
      };
      return Result;
    };
    $impl.RESpecials = "([\\$\\+\\[\\]\\(\\)\\\\\\.\\*\\^\\?\\|])";
    $impl.DoEncodeDate = function (Year, Month, Day) {
      var Result = 0;
      var D = 0.0;
      if ($mod.TryEncodeDate(Year,Month,Day,{get: function () {
          return D;
        }, set: function (v) {
          D = v;
        }})) {
        Result = pas.System.Trunc(D)}
       else Result = 0;
      return Result;
    };
    $impl.DoEncodeTime = function (Hour, Minute, Second, MilliSecond) {
      var Result = 0.0;
      if (!$mod.TryEncodeTime(Hour,Minute,Second,MilliSecond,{get: function () {
          return Result;
        }, set: function (v) {
          Result = v;
        }})) Result = 0;
      return Result;
    };
    $mod.$rtti.$StaticArray("DateTimeToStrFormat$a",{dims: [2], eltype: rtl.string});
    $impl.DateTimeToStrFormat = ["c","f"];
    var WhiteSpace = " \b\t\n\f\r";
    var Digits = "0123456789";
    $impl.IntStrToDate = function (ErrorMsg, S, useformat, separator) {
      var Result = 0.0;
      function FixErrorMsg(errmarg) {
        ErrorMsg.set($mod.Format(rtl.getResStr(pas.RTLConsts,"SInvalidDateFormat"),pas.System.VarRecs(18,errmarg)));
      };
      var df = "";
      var d = 0;
      var m = 0;
      var y = 0;
      var ly = 0;
      var ld = 0;
      var lm = 0;
      var n = 0;
      var i = 0;
      var len = 0;
      var c = 0;
      var dp = 0;
      var mp = 0;
      var yp = 0;
      var which = 0;
      var s1 = "";
      var values = [];
      var YearMoreThenTwoDigits = false;
      values = rtl.arraySetLength(values,0,4);
      Result = 0;
      len = S.length;
      ErrorMsg.set("");
      while ((len > 0) && (pas.System.Pos(S.charAt(len - 1),WhiteSpace) > 0)) len -= 1;
      if (len === 0) {
        FixErrorMsg(S);
        return Result;
      };
      YearMoreThenTwoDigits = false;
      if (separator === "\x00") if ($mod.FormatSettings.DateSeparator !== "\x00") {
        separator = $mod.FormatSettings.DateSeparator}
       else separator = "-";
      df = $mod.UpperCase(useformat);
      yp = 0;
      mp = 0;
      dp = 0;
      which = 0;
      i = 0;
      while ((i < df.length) && (which < 3)) {
        i += 1;
        var $tmp = df.charAt(i - 1);
        if ($tmp === "Y") {
          if (yp === 0) {
            which += 1;
            yp = which;
          }}
         else if ($tmp === "M") {
          if (mp === 0) {
            which += 1;
            mp = which;
          }}
         else if ($tmp === "D") if (dp === 0) {
          which += 1;
          dp = which;
        };
      };
      for (i = 1; i <= 3; i++) values[i] = 0;
      s1 = "";
      n = 0;
      for (var $l = 1, $end = len; $l <= $end; $l++) {
        i = $l;
        if (pas.System.Pos(S.charAt(i - 1),Digits) > 0) s1 = s1 + S.charAt(i - 1);
        if ((separator !== " ") && (S.charAt(i - 1) === " ")) continue;
        if ((S.charAt(i - 1) === separator) || ((i === len) && (pas.System.Pos(S.charAt(i - 1),Digits) > 0))) {
          n += 1;
          if (n > 3) {
            FixErrorMsg(S);
            return Result;
          };
          if ((n === yp) && (s1.length > 2)) YearMoreThenTwoDigits = true;
          pas.System.val$6(s1,{a: n, p: values, get: function () {
              return this.p[this.a];
            }, set: function (v) {
              this.p[this.a] = v;
            }},{get: function () {
              return c;
            }, set: function (v) {
              c = v;
            }});
          if (c !== 0) {
            FixErrorMsg(S);
            return Result;
          };
          s1 = "";
        } else if (pas.System.Pos(S.charAt(i - 1),Digits) === 0) {
          FixErrorMsg(S);
          return Result;
        };
      };
      if ((which < 3) && (n > which)) {
        FixErrorMsg(S);
        return Result;
      };
      $mod.DecodeDate($mod.Date(),{get: function () {
          return ly;
        }, set: function (v) {
          ly = v;
        }},{get: function () {
          return lm;
        }, set: function (v) {
          lm = v;
        }},{get: function () {
          return ld;
        }, set: function (v) {
          ld = v;
        }});
      if (n === 3) {
        y = values[yp];
        m = values[mp];
        d = values[dp];
      } else {
        y = ly;
        if (n < 2) {
          d = values[1];
          m = lm;
        } else if (dp < mp) {
          d = values[1];
          m = values[2];
        } else {
          d = values[2];
          m = values[1];
        };
      };
      if ((y >= 0) && (y < 100) && !YearMoreThenTwoDigits) {
        ly = ly - $mod.TwoDigitYearCenturyWindow;
        y += rtl.trunc(ly / 100) * 100;
        if (($mod.TwoDigitYearCenturyWindow > 0) && (y < ly)) y += 100;
      };
      if (!$mod.TryEncodeDate(y,m,d,{get: function () {
          return Result;
        }, set: function (v) {
          Result = v;
        }})) ErrorMsg.set(rtl.getResStr(pas.RTLConsts,"SErrInvalidDate"));
      return Result;
    };
    var AMPM_None = 0;
    var AMPM_AM = 1;
    var AMPM_PM = 2;
    var tiHour = 0;
    var tiMin = 1;
    var tiSec = 2;
    var tiMSec = 3;
    var Digits$1 = "0123456789";
    $impl.IntStrToTime = function (ErrorMsg, S, Len, aSettings) {
      var Result = 0.0;
      var AmPm = 0;
      var TimeValues = [];
      function SplitElements(TimeValues, AmPm) {
        var Result = false;
        var Cur = 0;
        var Offset = 0;
        var ElemLen = 0;
        var Err = 0;
        var TimeIndex = 0;
        var FirstSignificantDigit = 0;
        var Value = 0;
        var DigitPending = false;
        var MSecPending = false;
        var AmPmStr = "";
        var CurChar = "\x00";
        var I = 0;
        var allowedchars = "";
        Result = false;
        AmPm.set(0);
        MSecPending = false;
        TimeIndex = 0;
        for (I = 0; I <= 3; I++) TimeValues.get()[I] = 0;
        Cur = 1;
        while ((Cur < Len) && (S.charAt(Cur - 1) === " ")) Cur += 1;
        Offset = Cur;
        if ((Cur > (Len - 1)) || (S.charAt(Cur - 1) === aSettings.TimeSeparator) || (S.charAt(Cur - 1) === aSettings.DecimalSeparator)) {
          return Result;
        };
        DigitPending = pas.System.Pos(S.charAt(Cur - 1),Digits$1) > 0;
        while (Cur <= Len) {
          CurChar = S.charAt(Cur - 1);
          if (pas.System.Pos(CurChar,Digits$1) > 0) {
            if (!DigitPending || (TimeIndex > 3)) {
              return Result;
            };
            Offset = Cur;
            if (CurChar !== "0") {
              FirstSignificantDigit = Offset}
             else FirstSignificantDigit = -1;
            while ((Cur < Len) && (pas.System.Pos(S.charAt((Cur + 1) - 1),Digits$1) > 0)) {
              if ((FirstSignificantDigit === -1) && (S.charAt(Cur - 1) !== "0")) FirstSignificantDigit = Cur;
              Cur += 1;
            };
            if (FirstSignificantDigit === -1) FirstSignificantDigit = Cur;
            ElemLen = (1 + Cur) - FirstSignificantDigit;
            if ((ElemLen <= 2) || ((ElemLen <= 3) && (TimeIndex === 3))) {
              pas.System.val$6(pas.System.Copy(S,FirstSignificantDigit,ElemLen),{get: function () {
                  return Value;
                }, set: function (v) {
                  Value = v;
                }},{get: function () {
                  return Err;
                }, set: function (v) {
                  Err = v;
                }});
              TimeValues.get()[TimeIndex] = Value;
              TimeIndex += 1;
              DigitPending = false;
            } else {
              return Result;
            };
          } else if (CurChar === " ") {}
          else if (CurChar === aSettings.TimeSeparator) {
            if (DigitPending || (TimeIndex > 2)) {
              return Result;
            };
            DigitPending = true;
            MSecPending = false;
          } else if (CurChar === aSettings.DecimalSeparator) {
            if (DigitPending || MSecPending || (TimeIndex !== 3)) {
              return Result;
            };
            DigitPending = true;
            MSecPending = true;
          } else {
            if ((AmPm.get() !== 0) || DigitPending) {
              return Result;
            };
            Offset = Cur;
            allowedchars = aSettings.DecimalSeparator + " ";
            if (aSettings.TimeSeparator !== "\x00") allowedchars = allowedchars + aSettings.TimeSeparator;
            while ((Cur < Len) && (pas.System.Pos(S.charAt((Cur + 1) - 1),allowedchars) === 0) && (pas.System.Pos(S.charAt((Cur + 1) - 1),Digits$1) === 0)) Cur += 1;
            ElemLen = (1 + Cur) - Offset;
            AmPmStr = pas.System.Copy(S,Offset,ElemLen);
            if ($mod.CompareText(AmPmStr,aSettings.TimeAMString) === 0) {
              AmPm.set(1)}
             else if ($mod.CompareText(AmPmStr,aSettings.TimePMString) === 0) {
              AmPm.set(2)}
             else if ($mod.CompareText(AmPmStr,"AM") === 0) {
              AmPm.set(1)}
             else if ($mod.CompareText(AmPmStr,"PM") === 0) {
              AmPm.set(2)}
             else {
              return Result;
            };
            if (TimeIndex === 0) {
              DigitPending = true;
            } else {
              TimeIndex = 3 + 1;
              DigitPending = false;
            };
          };
          Cur += 1;
        };
        if ((TimeIndex === 0) || ((AmPm.get() !== 0) && ((TimeValues.get()[0] > 12) || (TimeValues.get()[0] === 0))) || DigitPending) return Result;
        Result = true;
        return Result;
      };
      TimeValues = rtl.arraySetLength(TimeValues,0,4);
      AmPm = 0;
      if (!SplitElements({get: function () {
          return TimeValues;
        }, set: function (v) {
          TimeValues = v;
        }},{get: function () {
          return AmPm;
        }, set: function (v) {
          AmPm = v;
        }})) {
        ErrorMsg.set($mod.Format(rtl.getResStr(pas.RTLConsts,"SErrInvalidTimeFormat"),pas.System.VarRecs(18,S)));
        return Result;
      };
      if ((AmPm === 2) && (TimeValues[0] !== 12)) {
        TimeValues[0] += 12}
       else if ((AmPm === 1) && (TimeValues[0] === 12)) TimeValues[0] = 0;
      if (!$mod.TryEncodeTime(TimeValues[0],TimeValues[1],TimeValues[2],TimeValues[3],{get: function () {
          return Result;
        }, set: function (v) {
          Result = v;
        }})) ErrorMsg.set($mod.Format(rtl.getResStr(pas.RTLConsts,"SErrInvalidTimeFormat"),pas.System.VarRecs(18,S)));
      return Result;
    };
    var WhiteSpace$1 = "\t\n\r ";
    $impl.SplitDateTimeStr = function (DateTimeStr, DateStr, TimeStr, aSettings) {
      var Result = 0;
      var p = 0;
      var DummyDT = 0.0;
      Result = 0;
      DateStr.set("");
      TimeStr.set("");
      DateTimeStr = $mod.Trim(DateTimeStr);
      if (DateTimeStr.length === 0) return Result;
      if ((aSettings.DateSeparator === " ") && (aSettings.TimeSeparator === " ") && (pas.System.Pos(" ",DateTimeStr) > 0)) {
        DateStr.set(DateTimeStr);
        return 1;
      };
      p = 1;
      if (aSettings.DateSeparator !== " ") {
        while ((p < DateTimeStr.length) && !(pas.System.Pos(DateTimeStr.charAt((p + 1) - 1),WhiteSpace$1) > 0)) p += 1;
      } else {
        p = pas.System.Pos(aSettings.TimeSeparator,DateTimeStr);
        if (p !== 0) do {
          p -= 1;
        } while (!((p === 0) || (pas.System.Pos(DateTimeStr.charAt(p - 1),WhiteSpace$1) > 0)));
      };
      if (p === 0) p = DateTimeStr.length;
      DateStr.set(pas.System.Copy(DateTimeStr,1,p));
      TimeStr.set($mod.Trim(pas.System.Copy(DateTimeStr,p + 1,100)));
      if (TimeStr.get().length !== 0) {
        Result = 2}
       else {
        Result = 1;
        if (((aSettings.DateSeparator !== aSettings.TimeSeparator) && (pas.System.Pos(aSettings.TimeSeparator,DateStr.get()) > 0)) || ((aSettings.DateSeparator === aSettings.TimeSeparator) && !$mod.TryStrToDate(DateStr.get(),{get: function () {
            return DummyDT;
          }, set: function (v) {
            DummyDT = v;
          }}))) {
          TimeStr.set(DateStr.get());
          DateStr.set("");
        };
      };
      return Result;
    };
    $impl.IntTryStrToInt = function (S, res, aSep) {
      var Result = false;
      var Radix = 10;
      var N = "";
      var J = undefined;
      N = S;
      if ((pas.System.Pos(aSep,N) !== 0) || (pas.System.Pos(".",N) !== 0) || (pas.System.Pos(":",N) !== 0) || (pas.System.Pos("-",N) > 1)) return false;
      var $tmp = pas.System.Copy(N,1,1);
      if ($tmp === "$") {
        Radix = 16}
       else if ($tmp === "&") {
        Radix = 8}
       else if ($tmp === "%") Radix = 2;
      if ((Radix !== 16) && (pas.System.Pos("e",$mod.LowerCase(N)) !== 0)) return false;
      if (Radix !== 10) pas.System.Delete({get: function () {
          return N;
        }, set: function (v) {
          N = v;
        }},1,1);
      J = parseInt(N,Radix);
      Result = !isNaN(J);
      if (Result) res.set(rtl.trunc(J));
      return Result;
    };
    $impl.InitGlobalFormatSettings = function () {
      $mod.FormatSettings.$assign($mod.TFormatSettings.Create());
      $mod.TimeSeparator = $mod.FormatSettings.TimeSeparator;
      $mod.DateSeparator = $mod.FormatSettings.DateSeparator;
      $mod.ShortDateFormat = $mod.FormatSettings.ShortDateFormat;
      $mod.LongDateFormat = $mod.FormatSettings.LongDateFormat;
      $mod.ShortTimeFormat = $mod.FormatSettings.ShortTimeFormat;
      $mod.LongTimeFormat = $mod.FormatSettings.LongTimeFormat;
      $mod.DecimalSeparator = $mod.FormatSettings.DecimalSeparator;
      $mod.ThousandSeparator = $mod.FormatSettings.ThousandSeparator;
      $mod.TimeAMString = $mod.FormatSettings.TimeAMString;
      $mod.TimePMString = $mod.FormatSettings.TimePMString;
      $mod.CurrencyFormat = $mod.FormatSettings.CurrencyFormat;
      $mod.NegCurrFormat = $mod.FormatSettings.NegCurrFormat;
      $mod.CurrencyDecimals = $mod.FormatSettings.CurrencyDecimals;
      $mod.CurrencyString = $mod.FormatSettings.CurrencyString;
    };
    $impl.NotImplemented = function (S) {
      throw $mod.Exception.$create("Create$1",["Not yet implemented : " + S]);
    };
    $impl.HaveChar = function (AChar, AList) {
      var Result = false;
      var I = 0;
      I = 0;
      Result = false;
      while (!Result && (I < rtl.length(AList))) {
        Result = AList[I] === AChar;
        I += 1;
      };
      return Result;
    };
    rtl.recNewT($impl,"TFloatParts",function () {
      this.sign = false;
      this.exp = 0;
      this.mantissa = 0.0;
      this.$eq = function (b) {
        return (this.sign === b.sign) && (this.exp === b.exp) && (this.mantissa === b.mantissa);
      };
      this.$assign = function (s) {
        this.sign = s.sign;
        this.exp = s.exp;
        this.mantissa = s.mantissa;
        return this;
      };
      var $r = $mod.$rtti.$Record("TFloatParts",{});
      $r.addField("sign",rtl.boolean);
      $r.addField("exp",rtl.longint);
      $r.addField("mantissa",rtl.double);
    });
    $impl.FloatToParts = function (aValue) {
      var Result = $impl.TFloatParts.$new();
      var F = null;
      var B = null;
      F = new Float64Array(1);
      B = new Uint8Array(F.buffer);
      F[0] = aValue;
      Result.sign = (B[7] >>> 7) === 0;
      Result.exp = (((B[7] & 0x7f) << 4) | (B[6] >>> 4)) - 0x3ff;
      B[3] = 0x3F;
      B[6] = B[6] | 0xF0;
      Result.mantissa = F[0];
      return Result;
    };
    $impl.EqualsStr = function (AValue1, AValue2) {
      var Result = false;
      Result = AValue1 === AValue2;
      return Result;
    };
    var cBlank = " ";
    $impl.ParseCmdLine = function () {
      var Result = [];
      var lCount = 0;
      var lParam = "";
      var lExtraParam = "";
      var lBuffer = "";
      var lChar = "\x00";
      var lIndex = 0;
      Result = [];
      for (var $l = 1, $end = pas.System.ParamCount(); $l <= $end; $l++) {
        lCount = $l;
        lParam = pas.System.ParamStr(lCount);
        lBuffer = $mod.TStringHelper.Substring.call({get: function () {
            return lParam;
          }, set: function (v) {
            lParam = v;
          }},1);
        lExtraParam = $mod.TStringHelper.Empty;
        for (var $l1 in $mod.SwitchChars) {
          lChar = String.fromCharCode($l1);
          lIndex = $mod.TStringHelper.IndexOf$1.call({get: function () {
              return lBuffer;
            }, set: function (v) {
              lBuffer = v;
            }},cBlank + lChar);
          if (lIndex >= 0) {
            lExtraParam = $mod.TStringHelper.TrimLeft.call({a: $mod.TStringHelper.Substring.call({get: function () {
                  return lParam;
                }, set: function (v) {
                  lParam = v;
                }},lIndex + 1), get: function () {
                return this.a;
              }, set: function (v) {
                this.a = v;
              }});
            lParam = $mod.TStringHelper.TrimRight.call({a: $mod.TStringHelper.Substring$1.call({get: function () {
                  return lParam;
                }, set: function (v) {
                  lParam = v;
                }},0,lIndex + 1), get: function () {
                return this.a;
              }, set: function (v) {
                this.a = v;
              }});
            break;
          };
        };
        Result = rtl.arraySetLength(Result,"",rtl.length(Result) + 1);
        Result[rtl.length(Result) - 1] = lParam;
        if (!$mod.TStringHelper.IsEmpty.call({get: function () {
            return lExtraParam;
          }, set: function (v) {
            lExtraParam = v;
          }})) {
          Result = rtl.arraySetLength(Result,"",rtl.length(Result) + 1);
          Result[rtl.length(Result) - 1] = lExtraParam;
        };
      };
      return Result;
    };
    $mod.$resourcestrings = {SAbortError: {org: "Operation aborted"}, SApplicationException: {org: "Application raised an exception: "}, SErrUnknownExceptionType: {org: "Caught unknown exception type : "}};
  };
  $mod.$init = function () {
    (function () {
      $impl.InitGlobalFormatSettings();
    })();
    $mod.ShortMonthNames = $impl.DefaultShortMonthNames.slice(0);
    $mod.LongMonthNames = $impl.DefaultLongMonthNames.slice(0);
    $mod.ShortDayNames = $impl.DefaultShortDayNames.slice(0);
    $mod.LongDayNames = $impl.DefaultLongDayNames.slice(0);
  };
},[]);
rtl.module("TypInfo",["System","SysUtils","Types","RTLConsts","JS"],function () {
  "use strict";
  var $mod = this;
  var $impl = $mod.$impl;
  this.TCallConv = {"0": "ccReg", ccReg: 0, "1": "ccCdecl", ccCdecl: 1, "2": "ccPascal", ccPascal: 2, "3": "ccStdCall", ccStdCall: 3, "4": "ccSafeCall", ccSafeCall: 4, "5": "ccCppdecl", ccCppdecl: 5, "6": "ccFar16", ccFar16: 6, "7": "ccOldFPCCall", ccOldFPCCall: 7, "8": "ccInternProc", ccInternProc: 8, "9": "ccSysCall", ccSysCall: 9, "10": "ccSoftFloat", ccSoftFloat: 10, "11": "ccMWPascal", ccMWPascal: 11};
  this.$rtti.$Enum("TCallConv",{minvalue: 0, maxvalue: 11, ordtype: 1, enumtype: this.TCallConv});
  this.$rtti.$ExtClass("TSectionRTTI",{ancestor: pas.JS.$rtti["TJSObject"], jsclass: "rtl.tSectionRTTI"});
  this.$rtti.$ExtClass("TTypeInfoModule",{ancestor: pas.JS.$rtti["TJSObject"], jsclass: "pasmodule"});
  this.$rtti.$inherited("TTypeInfoAttributes",pas.Types.$rtti["TJSValueDynArray"],{});
  this.$rtti.$ExtClass("TTypeInfo",{jsclass: "rtl.tTypeInfo"});
  this.$rtti.$ClassRef("TTypeInfoClassOf",{instancetype: this.$rtti["TTypeInfo"]});
  this.TOrdType = {"0": "otSByte", otSByte: 0, "1": "otUByte", otUByte: 1, "2": "otSWord", otSWord: 2, "3": "otUWord", otUWord: 3, "4": "otSLong", otSLong: 4, "5": "otULong", otULong: 5, "6": "otSIntDouble", otSIntDouble: 6, "7": "otUIntDouble", otUIntDouble: 7};
  this.$rtti.$Enum("TOrdType",{minvalue: 0, maxvalue: 7, ordtype: 1, enumtype: this.TOrdType});
  this.$rtti.$ExtClass("TTypeInfoInteger",{ancestor: this.$rtti["TTypeInfo"], jsclass: "rtl.tTypeInfoInteger"});
  this.$rtti.$ExtClass("TEnumType",{jsclass: "anonymous"});
  this.$rtti.$ExtClass("TTypeInfoEnum",{ancestor: this.$rtti["TTypeInfoInteger"], jsclass: "rtl.tTypeInfoEnum"});
  this.$rtti.$ExtClass("TTypeInfoSet",{ancestor: this.$rtti["TTypeInfo"], jsclass: "rtl.tTypeInfoSet"});
  this.$rtti.$ExtClass("TTypeInfoStaticArray",{ancestor: this.$rtti["TTypeInfo"], jsclass: "rtl.tTypeInfoStaticArray"});
  this.$rtti.$ExtClass("TTypeInfoDynArray",{ancestor: this.$rtti["TTypeInfo"], jsclass: "rtl.tTypeInfoDynArray"});
  this.TParamFlag = {"0": "pfVar", pfVar: 0, "1": "pfConst", pfConst: 1, "2": "pfOut", pfOut: 2, "3": "pfArray", pfArray: 3, "4": "pfAddress", pfAddress: 4, "5": "pfReference", pfReference: 5};
  this.$rtti.$Enum("TParamFlag",{minvalue: 0, maxvalue: 5, ordtype: 1, enumtype: this.TParamFlag});
  this.$rtti.$Set("TParamFlags",{comptype: this.$rtti["TParamFlag"]});
  this.$rtti.$ExtClass("TProcedureParam",{jsclass: "anonymous"});
  this.$rtti.$DynArray("TProcedureParams",{eltype: this.$rtti["TProcedureParam"]});
  this.TProcedureFlag = {"0": "pfStatic", pfStatic: 0, "1": "pfVarargs", pfVarargs: 1, "2": "pfExternal", pfExternal: 2, "3": "pfSafeCall", pfSafeCall: 3, "4": "pfAsync", pfAsync: 4};
  this.$rtti.$Enum("TProcedureFlag",{minvalue: 0, maxvalue: 4, ordtype: 1, enumtype: this.TProcedureFlag});
  this.$rtti.$Set("TProcedureFlags",{comptype: this.$rtti["TProcedureFlag"]});
  this.$rtti.$ExtClass("TProcedureSignature",{jsclass: "anonymous"});
  this.$rtti.$ExtClass("TTypeInfoProcVar",{ancestor: this.$rtti["TTypeInfo"], jsclass: "rtl.tTypeInfoProcVar"});
  this.$rtti.$ExtClass("TTypeInfoRefToProcVar",{ancestor: this.$rtti["TTypeInfoProcVar"], jsclass: "rtl.tTypeInfoRefToProcVar"});
  this.TMethodKind = {"0": "mkProcedure", mkProcedure: 0, "1": "mkFunction", mkFunction: 1, "2": "mkConstructor", mkConstructor: 2, "3": "mkDestructor", mkDestructor: 3, "4": "mkClassProcedure", mkClassProcedure: 4, "5": "mkClassFunction", mkClassFunction: 5};
  this.$rtti.$Enum("TMethodKind",{minvalue: 0, maxvalue: 5, ordtype: 1, enumtype: this.TMethodKind});
  this.$rtti.$Set("TMethodKinds",{comptype: this.$rtti["TMethodKind"]});
  this.$rtti.$ExtClass("TTypeInfoMethodVar",{ancestor: this.$rtti["TTypeInfoProcVar"], jsclass: "rtl.tTypeInfoMethodVar"});
  this.TTypeMemberKind = {"0": "tmkUnknown", tmkUnknown: 0, "1": "tmkField", tmkField: 1, "2": "tmkMethod", tmkMethod: 2, "3": "tmkProperty", tmkProperty: 3};
  this.$rtti.$Enum("TTypeMemberKind",{minvalue: 0, maxvalue: 3, ordtype: 1, enumtype: this.TTypeMemberKind});
  this.$rtti.$Set("TTypeMemberKinds",{comptype: this.$rtti["TTypeMemberKind"]});
  this.$rtti.$ExtClass("TTypeMember",{jsclass: "rtl.tTypeMember"});
  this.$rtti.$DynArray("TTypeMemberDynArray",{eltype: this.$rtti["TTypeMember"]});
  this.$rtti.$ExtClass("TTypeMemberField",{ancestor: this.$rtti["TTypeMember"], jsclass: "rtl.tTypeMemberField"});
  this.$rtti.$ExtClass("TTypeMemberMethod",{ancestor: this.$rtti["TTypeMember"], jsclass: "rtl.tTypeMemberMethod"});
  this.$rtti.$DynArray("TTypeMemberMethodDynArray",{eltype: this.$rtti["TTypeMemberMethod"]});
  this.pfGetFunction = 1;
  this.pfSetProcedure = 2;
  this.pfStoredFalse = 4;
  this.pfStoredField = 8;
  this.pfStoredFunction = 12;
  this.pfHasIndex = 16;
  this.$rtti.$ExtClass("TTypeMemberProperty",{ancestor: this.$rtti["TTypeMember"], jsclass: "rtl.tTypeMemberProperty"});
  this.$rtti.$DynArray("TTypeMemberPropertyDynArray",{eltype: this.$rtti["TTypeMemberProperty"]});
  this.$rtti.$ExtClass("TTypeMembers",{jsclass: "rtl.tTypeMembers"});
  this.$rtti.$ExtClass("TTypeInfoStruct",{ancestor: this.$rtti["TTypeInfo"], jsclass: "rtl.tTypeInfoStruct"});
  this.$rtti.$ExtClass("TTypeInfoRecord",{ancestor: this.$rtti["TTypeInfoStruct"], jsclass: "rtl.tTypeInfoRecord"});
  this.$rtti.$ExtClass("TTypeInfoClass",{ancestor: this.$rtti["TTypeInfoStruct"], jsclass: "rtl.tTypeInfoClass"});
  this.$rtti.$ExtClass("TTypeInfoExtClass",{ancestor: this.$rtti["TTypeInfo"], jsclass: "rtl.tTypeInfoExtClass"});
  this.$rtti.$ExtClass("TTypeInfoClassRef",{ancestor: this.$rtti["TTypeInfo"], jsclass: "rtl.tTypeInfoClassRef"});
  this.$rtti.$ExtClass("TTypeInfoPointer",{ancestor: this.$rtti["TTypeInfo"], jsclass: "rtl.tTypeInfoPointer"});
  this.$rtti.$ExtClass("TInterfaceInfo",{ancestor: pas.JS.$rtti["TJSObject"], jsclass: "Object"});
  this.$rtti.$ExtClass("TTypeInfoInterface",{ancestor: this.$rtti["TTypeInfoStruct"], jsclass: "rtl.tTypeInfoInterface"});
  this.$rtti.$ExtClass("TTypeInfoHelper",{ancestor: this.$rtti["TTypeInfoStruct"], jsclass: "rtl.tTypeInfoHelper"});
  this.$rtti.$ExtClass("TReferenceVariable",{jsclass: "Object"});
  this.$rtti.$ExtClass("TInterfaceObject",{ancestor: pas.JS.$rtti["TJSObject"], jsclass: "Object"});
  rtl.createClass(this,"EPropertyError",pas.SysUtils.Exception,function () {
  });
  this.GetTypeName = function (TypeInfo) {
    var Result = "";
    Result = TypeInfo.name;
    return Result;
  };
  this.GetClassMembers = function (aTIStruct) {
    var Result = [];
    var C = null;
    var i = 0;
    var PropName = "";
    var Names = null;
    Result = [];
    Names = new Object();
    C = aTIStruct;
    while (C !== null) {
      for (var $l = 0, $end = rtl.length(C.names) - 1; $l <= $end; $l++) {
        i = $l;
        PropName = C.names[i];
        if (Names.hasOwnProperty(PropName)) continue;
        Result.push(C.members[PropName]);
        Names[PropName] = true;
      };
      if (!rtl.isExt(C,rtl.tTypeInfoClass)) break;
      C = C.ancestor;
    };
    return Result;
  };
  this.GetClassMember = function (aTIStruct, aName) {
    var Result = null;
    var C = null;
    var i = 0;
    C = aTIStruct;
    while (C !== null) {
      if (C.members.hasOwnProperty(aName)) return C.members[aName];
      if (!rtl.isExt(C,rtl.tTypeInfoClass)) break;
      C = C.ancestor;
    };
    C = aTIStruct;
    while (C !== null) {
      for (var $l = 0, $end = rtl.length(C.names) - 1; $l <= $end; $l++) {
        i = $l;
        if (pas.SysUtils.CompareText(C.names[i],aName) === 0) return C.members[C.names[i]];
      };
      if (!rtl.isExt(C,rtl.tTypeInfoClass)) break;
      C = C.ancestor;
    };
    Result = null;
    return Result;
  };
  this.GetInstanceMethod = function (Instance, aName) {
    var Result = null;
    var TI = null;
    if (Instance === null) return null;
    TI = $mod.GetClassMember(Instance.$rtti,aName);
    if (!rtl.isExt(TI,rtl.tTypeMemberMethod)) return null;
    Result = rtl.createCallback(Instance,TI.name);
    return Result;
  };
  this.GetClassMethods = function (aTIStruct) {
    var Result = [];
    var C = null;
    var i = 0;
    var Cnt = 0;
    var j = 0;
    Cnt = 0;
    C = aTIStruct;
    while (C !== null) {
      Cnt += C.methods.length;
      if (!rtl.isExt(C,rtl.tTypeInfoClass)) break;
      C = C.ancestor;
    };
    Result = rtl.arraySetLength(Result,null,Cnt);
    C = aTIStruct;
    i = 0;
    while (C !== null) {
      for (var $l = 0, $end = C.methods.length - 1; $l <= $end; $l++) {
        j = $l;
        Result[i] = C.members[C.methods[j]];
        i += 1;
      };
      if (!rtl.isExt(C,rtl.tTypeInfoClass)) break;
      C = C.ancestor;
    };
    return Result;
  };
  this.GetInterfaceMembers = function (aTIInterface) {
    var Result = [];
    var Intf = null;
    var i = 0;
    var Cnt = 0;
    var j = 0;
    Cnt = 0;
    Intf = aTIInterface;
    while (Intf !== null) {
      Cnt += rtl.length(Intf.names);
      Intf = Intf.ancestor;
    };
    Result = rtl.arraySetLength(Result,null,Cnt);
    Intf = aTIInterface;
    i = 0;
    while (Intf !== null) {
      for (var $l = 0, $end = rtl.length(Intf.names) - 1; $l <= $end; $l++) {
        j = $l;
        Result[i] = Intf.members[Intf.names[j]];
        i += 1;
      };
      Intf = Intf.ancestor;
    };
    return Result;
  };
  this.GetInterfaceMember = function (aTIInterface, aName) {
    var Result = null;
    var Intf = null;
    var i = 0;
    Intf = aTIInterface;
    while (Intf !== null) {
      if (Intf.members.hasOwnProperty(aName)) return Intf.members[aName];
      Intf = Intf.ancestor;
    };
    Intf = aTIInterface;
    while (Intf !== null) {
      for (var $l = 0, $end = rtl.length(Intf.names) - 1; $l <= $end; $l++) {
        i = $l;
        if (pas.SysUtils.CompareText(Intf.names[i],aName) === 0) return Intf.members[Intf.names[i]];
      };
      Intf = Intf.ancestor;
    };
    Result = null;
    return Result;
  };
  this.GetInterfaceMethods = function (aTIInterface) {
    var Result = [];
    var Intf = null;
    var i = 0;
    var Cnt = 0;
    var j = 0;
    Cnt = 0;
    Intf = aTIInterface;
    while (Intf !== null) {
      Cnt += Intf.methods.length;
      Intf = Intf.ancestor;
    };
    Result = rtl.arraySetLength(Result,null,Cnt);
    Intf = aTIInterface;
    i = 0;
    while (Intf !== null) {
      for (var $l = 0, $end = Intf.methods.length - 1; $l <= $end; $l++) {
        j = $l;
        Result[i] = Intf.members[Intf.methods[j]];
        i += 1;
      };
      Intf = Intf.ancestor;
    };
    return Result;
  };
  this.GetRTTIAttributes = function (Attributes) {
    var Result = [];
    var i = 0;
    var len = 0;
    var AttrClass = null;
    var ProcName = "";
    var Attr = null;
    Result = [];
    if (Attributes == undefined) return Result;
    i = 0;
    len = rtl.length(Attributes);
    while (i < len) {
      AttrClass = rtl.getObject(Attributes[i]);
      i += 1;
      ProcName = "" + Attributes[i];
      i += 1;
      if ((i < len) && rtl.isArray(Attributes[i])) {
        Attr = AttrClass.$create(ProcName,Attributes[i]);
        i += 1;
      } else Attr = AttrClass.$create(ProcName);
      Result = rtl.arrayInsert(Attr,Result,rtl.length(Result));
    };
    return Result;
  };
  this.GetPropInfos = function (aTIStruct) {
    var Result = [];
    var C = null;
    var i = 0;
    var Names = null;
    var PropName = "";
    Result = [];
    C = aTIStruct;
    Names = new Object();
    while (C !== null) {
      for (var $l = 0, $end = C.properties.length - 1; $l <= $end; $l++) {
        i = $l;
        PropName = C.properties[i];
        if (Names.hasOwnProperty(PropName)) continue;
        Result.push(C.members[PropName]);
        Names[PropName] = true;
      };
      if (!rtl.isExt(C,rtl.tTypeInfoClass)) break;
      C = C.ancestor;
    };
    return Result;
  };
  this.GetPropList = function (aTIStruct, TypeKinds, Sorted) {
    var Result = [];
    function NameSort(a, b) {
      var Result = 0;
      if (a.name < b.name) {
        Result = -1}
       else if (a.name > b.name) {
        Result = 1}
       else Result = 0;
      return Result;
    };
    var C = null;
    var i = 0;
    var Names = null;
    var PropName = "";
    var Prop = null;
    Result = [];
    C = aTIStruct;
    Names = new Object();
    while (C !== null) {
      for (var $l = 0, $end = C.properties.length - 1; $l <= $end; $l++) {
        i = $l;
        PropName = C.properties[i];
        if (Names.hasOwnProperty(PropName)) continue;
        Prop = C.members[PropName];
        if (!(Prop.typeinfo.kind in TypeKinds)) continue;
        Result.push(Prop);
        Names[PropName] = true;
      };
      if (!rtl.isExt(C,rtl.tTypeInfoClass)) break;
      C = C.ancestor;
    };
    if (Sorted) Result.sort(NameSort);
    return Result;
  };
  this.GetPropList$1 = function (aTIStruct) {
    var Result = [];
    Result = $mod.GetPropInfos(aTIStruct);
    return Result;
  };
  this.GetPropList$2 = function (AClass) {
    var Result = [];
    Result = $mod.GetPropInfos(AClass.$rtti);
    return Result;
  };
  this.GetPropList$3 = function (Instance) {
    var Result = [];
    Result = $mod.GetPropList$2(Instance.$class.ClassType());
    return Result;
  };
  this.GetPropInfo = function (TI, PropName) {
    var Result = null;
    var m = null;
    var i = 0;
    var C = null;
    C = TI;
    while (C !== null) {
      m = C.members[PropName];
      if (rtl.isExt(m,rtl.tTypeMemberProperty)) return m;
      if (!rtl.isExt(C,rtl.tTypeInfoClass)) break;
      C = C.ancestor;
    };
    Result = null;
    do {
      for (var $l = 0, $end = TI.properties.length - 1; $l <= $end; $l++) {
        i = $l;
        if (pas.SysUtils.CompareText(PropName,TI.properties[i]) === 0) {
          m = TI.members[TI.properties[i]];
          if (rtl.isExt(m,rtl.tTypeMemberProperty)) Result = m;
          return Result;
        };
      };
      if (!rtl.isExt(TI,rtl.tTypeInfoClass)) break;
      TI = TI.ancestor;
    } while (!(TI === null));
    return Result;
  };
  this.GetPropInfo$1 = function (TI, PropName, Kinds) {
    var Result = null;
    Result = $mod.GetPropInfo(TI,PropName);
    if (rtl.neSet(Kinds,{}) && (Result !== null) && !(Result.typeinfo.kind in Kinds)) Result = null;
    return Result;
  };
  this.GetPropInfo$2 = function (Instance, PropName) {
    var Result = null;
    Result = $mod.GetPropInfo$1(Instance.$rtti,PropName,{});
    return Result;
  };
  this.GetPropInfo$3 = function (Instance, PropName, Kinds) {
    var Result = null;
    Result = $mod.GetPropInfo$1(Instance.$rtti,PropName,Kinds);
    return Result;
  };
  this.GetPropInfo$4 = function (aClass, PropName) {
    var Result = null;
    Result = $mod.GetPropInfo$1(aClass.$rtti,PropName,{});
    return Result;
  };
  this.GetPropInfo$5 = function (aClass, PropName, Kinds) {
    var Result = null;
    Result = $mod.GetPropInfo$1(aClass.$rtti,PropName,Kinds);
    return Result;
  };
  this.FindPropInfo = function (Instance, PropName) {
    var Result = null;
    Result = $mod.GetPropInfo(Instance.$rtti,PropName);
    if (Result === null) throw $mod.EPropertyError.$create("CreateFmt",[rtl.getResStr(pas.RTLConsts,"SErrPropertyNotFound"),pas.System.VarRecs(18,PropName)]);
    return Result;
  };
  this.FindPropInfo$1 = function (Instance, PropName, Kinds) {
    var Result = null;
    Result = $mod.GetPropInfo$1(Instance.$rtti,PropName,Kinds);
    if (Result === null) throw $mod.EPropertyError.$create("CreateFmt",[rtl.getResStr(pas.RTLConsts,"SErrPropertyNotFound"),pas.System.VarRecs(18,PropName)]);
    return Result;
  };
  this.FindPropInfo$2 = function (aClass, PropName) {
    var Result = null;
    Result = $mod.GetPropInfo(aClass.$rtti,PropName);
    if (Result === null) throw $mod.EPropertyError.$create("CreateFmt",[rtl.getResStr(pas.RTLConsts,"SErrPropertyNotFound"),pas.System.VarRecs(18,PropName)]);
    return Result;
  };
  this.FindPropInfo$3 = function (aClass, PropName, Kinds) {
    var Result = null;
    Result = $mod.GetPropInfo$1(aClass.$rtti,PropName,Kinds);
    if (Result === null) throw $mod.EPropertyError.$create("CreateFmt",[rtl.getResStr(pas.RTLConsts,"SErrPropertyNotFound"),pas.System.VarRecs(18,PropName)]);
    return Result;
  };
  this.IsStoredProp = function (Instance, PropInfo) {
    var Result = false;
    var $tmp = PropInfo.flags & 12;
    if ($tmp === 0) {
      Result = true}
     else if ($tmp === 4) {
      Result = false}
     else if ($tmp === 8) {
      Result = !(Instance[PropInfo.stored] == false)}
     else {
      Result = Instance[PropInfo.stored]();
    };
    return Result;
  };
  this.IsStoredProp$1 = function (Instance, PropName) {
    var Result = false;
    Result = $mod.IsStoredProp(Instance,$mod.FindPropInfo(Instance,PropName));
    return Result;
  };
  this.IsPublishedProp = function (Instance, PropName) {
    var Result = false;
    Result = $mod.GetPropInfo$2(Instance,PropName) !== null;
    return Result;
  };
  this.IsPublishedProp$1 = function (aClass, PropName) {
    var Result = false;
    Result = $mod.GetPropInfo$4(aClass,PropName) !== null;
    return Result;
  };
  this.PropType = function (Instance, PropName) {
    var Result = 0;
    Result = $mod.FindPropInfo(Instance,PropName).typeinfo.kind;
    return Result;
  };
  this.PropType$1 = function (aClass, PropName) {
    var Result = 0;
    Result = $mod.FindPropInfo$2(aClass,PropName).typeinfo.kind;
    return Result;
  };
  this.PropIsType = function (Instance, PropName, TypeKind) {
    var Result = false;
    Result = $mod.PropType(Instance,PropName) === TypeKind;
    return Result;
  };
  this.PropIsType$1 = function (aClass, PropName, TypeKind) {
    var Result = false;
    Result = $mod.PropType$1(aClass,PropName) === TypeKind;
    return Result;
  };
  this.GetJSValueProp = function (Instance, TI, PropName) {
    var Result = undefined;
    var PropInfo = null;
    PropInfo = $mod.GetPropInfo(TI,PropName);
    if (PropInfo === null) throw $mod.EPropertyError.$create("CreateFmt",[rtl.getResStr(pas.RTLConsts,"SErrPropertyNotFound"),pas.System.VarRecs(18,PropName)]);
    Result = $mod.GetJSValueProp$1(Instance,PropInfo);
    return Result;
  };
  this.GetJSValueProp$1 = function (Instance, PropInfo) {
    var Result = undefined;
    var gk = 0;
    gk = $impl.GetPropGetterKind(PropInfo);
    var $tmp = gk;
    if ($tmp === $impl.TGetterKind.gkNone) {
      throw $mod.EPropertyError.$create("CreateFmt",[rtl.getResStr(pas.RTLConsts,"SCantReadPropertyS"),pas.System.VarRecs(18,PropInfo.name)])}
     else if ($tmp === $impl.TGetterKind.gkField) {
      Result = Instance[PropInfo.getter]}
     else if ($tmp === $impl.TGetterKind.gkFunction) {
      if ((16 & PropInfo.flags) > 0) {
        Result = Instance[PropInfo.getter](PropInfo.index)}
       else Result = Instance[PropInfo.getter]()}
     else if ($tmp === $impl.TGetterKind.gkFunctionWithParams) throw $mod.EPropertyError.$create("CreateFmt",[rtl.getResStr(pas.RTLConsts,"SIndexedPropertyNeedsParams"),pas.System.VarRecs(18,PropInfo.name)]);
    return Result;
  };
  this.GetJSValueProp$2 = function (Instance, PropName) {
    var Result = undefined;
    Result = $mod.GetJSValueProp$3(Instance,$mod.FindPropInfo(Instance,PropName));
    return Result;
  };
  this.GetJSValueProp$3 = function (Instance, PropInfo) {
    var Result = undefined;
    Result = $mod.GetJSValueProp$1(Instance,PropInfo);
    return Result;
  };
  this.SetJSValueProp = function (Instance, TI, PropName, Value) {
    var PropInfo = null;
    PropInfo = $mod.GetPropInfo(TI,PropName);
    if (PropInfo === null) throw $mod.EPropertyError.$create("CreateFmt",[rtl.getResStr(pas.RTLConsts,"SErrPropertyNotFound"),pas.System.VarRecs(18,PropName)]);
    $mod.SetJSValueProp$1(Instance,PropInfo,Value);
  };
  this.SetJSValueProp$1 = function (Instance, PropInfo, Value) {
    var sk = 0;
    sk = $impl.GetPropSetterKind(PropInfo);
    var $tmp = sk;
    if ($tmp === $impl.TSetterKind.skNone) {
      throw $mod.EPropertyError.$create("CreateFmt",[rtl.getResStr(pas.RTLConsts,"SCantWritePropertyS"),pas.System.VarRecs(18,PropInfo.name)])}
     else if ($tmp === $impl.TSetterKind.skField) {
      Instance[PropInfo.setter] = Value}
     else if ($tmp === $impl.TSetterKind.skProcedure) {
      if ((16 & PropInfo.flags) > 0) {
        Instance[PropInfo.setter](PropInfo.index,Value)}
       else Instance[PropInfo.setter](Value)}
     else if ($tmp === $impl.TSetterKind.skProcedureWithParams) throw $mod.EPropertyError.$create("CreateFmt",[rtl.getResStr(pas.RTLConsts,"SIndexedPropertyNeedsParams"),pas.System.VarRecs(18,PropInfo.name)]);
  };
  this.SetJSValueProp$2 = function (Instance, PropName, Value) {
    $mod.SetJSValueProp$3(Instance,$mod.FindPropInfo(Instance,PropName),Value);
  };
  this.SetJSValueProp$3 = function (Instance, PropInfo, Value) {
    $mod.SetJSValueProp$1(Instance,PropInfo,Value);
  };
  this.GetNativeIntProp = function (Instance, PropName) {
    var Result = 0;
    Result = $mod.GetNativeIntProp$1(Instance,$mod.FindPropInfo(Instance,PropName));
    return Result;
  };
  this.GetNativeIntProp$1 = function (Instance, PropInfo) {
    var Result = 0;
    Result = rtl.trunc($mod.GetJSValueProp$3(Instance,PropInfo));
    return Result;
  };
  this.SetNativeIntProp = function (Instance, PropName, Value) {
    $mod.SetJSValueProp$3(Instance,$mod.FindPropInfo(Instance,PropName),Value);
  };
  this.SetNativeIntProp$1 = function (Instance, PropInfo, Value) {
    $mod.SetJSValueProp$3(Instance,PropInfo,Value);
  };
  this.GetOrdProp = function (Instance, PropName) {
    var Result = 0;
    Result = $mod.GetOrdProp$1(Instance,$mod.FindPropInfo(Instance,PropName));
    return Result;
  };
  this.GetOrdProp$1 = function (Instance, PropInfo) {
    var Result = 0;
    var o = null;
    var Key = "";
    var n = 0;
    var v = undefined;
    if (PropInfo.typeinfo.kind === pas.System.TTypeKind.tkSet) {
      o = $mod.GetJSValueProp$3(Instance,PropInfo);
      Result = 0;
      for (Key in o) {
        n = parseInt(Key,10);
        if (n < 32) Result = Result + (1 << n);
      };
    } else if (PropInfo.typeinfo.kind === pas.System.TTypeKind.tkChar) {
      v = $mod.GetJSValueProp$3(Instance,PropInfo);
      if (rtl.isNumber(v)) {
        Result = rtl.trunc(v)}
       else {
        Key = "" + v;
        if (Key === "") {
          Result = 0}
         else Result = Key.charCodeAt(0);
      };
    } else Result = rtl.trunc($mod.GetJSValueProp$3(Instance,PropInfo));
    return Result;
  };
  this.SetOrdProp = function (Instance, PropName, Value) {
    $mod.SetOrdProp$1(Instance,$mod.FindPropInfo(Instance,PropName),Value);
  };
  this.SetOrdProp$1 = function (Instance, PropInfo, Value) {
    var o = null;
    var i = 0;
    if (PropInfo.typeinfo.kind === pas.System.TTypeKind.tkSet) {
      o = new Object();
      for (i = 0; i <= 31; i++) if (((1 << i) & Value) > 0) o["" + i] = true;
      $mod.SetJSValueProp$3(Instance,PropInfo,o);
    } else if (PropInfo.typeinfo.kind === pas.System.TTypeKind.tkChar) {
      $mod.SetJSValueProp$3(Instance,PropInfo,String.fromCharCode(Value))}
     else $mod.SetJSValueProp$3(Instance,PropInfo,Value);
  };
  this.GetEnumProp = function (Instance, PropName) {
    var Result = "";
    Result = $mod.GetEnumProp$1(Instance,$mod.FindPropInfo(Instance,PropName));
    return Result;
  };
  this.GetEnumProp$1 = function (Instance, PropInfo) {
    var Result = "";
    var n = 0;
    var TIEnum = null;
    TIEnum = rtl.asExt(PropInfo.typeinfo,rtl.tTypeInfoEnum);
    n = rtl.trunc($mod.GetJSValueProp$3(Instance,PropInfo));
    if ((n >= TIEnum.minvalue) && (n <= TIEnum.maxvalue)) {
      Result = TIEnum.enumtype[n]}
     else Result = "" + n;
    return Result;
  };
  this.SetEnumProp = function (Instance, PropName, Value) {
    $mod.SetEnumProp$1(Instance,$mod.FindPropInfo(Instance,PropName),Value);
  };
  this.SetEnumProp$1 = function (Instance, PropInfo, Value) {
    var TIEnum = null;
    var n = 0;
    TIEnum = rtl.asExt(PropInfo.typeinfo,rtl.tTypeInfoEnum);
    n = TIEnum.enumtype[Value];
    if (!pas.JS.isUndefined(n)) $mod.SetJSValueProp$3(Instance,PropInfo,n);
  };
  this.GetEnumName = function (TypeInfo, Value) {
    var Result = "";
    Result = TypeInfo.enumtype[Value];
    return Result;
  };
  this.GetEnumValue = function (TypeInfo, Name) {
    var Result = 0;
    Result = TypeInfo.enumtype[Name];
    return Result;
  };
  this.GetEnumNameCount = function (TypeInfo) {
    var Result = 0;
    var o = null;
    var l = 0;
    var r = 0;
    o = TypeInfo.enumtype;
    Result = 1;
    while (o.hasOwnProperty("" + Result)) Result = Result * 2;
    l = rtl.trunc(Result / 2);
    r = Result;
    while (l <= r) {
      Result = rtl.trunc((l + r) / 2);
      if (o.hasOwnProperty("" + Result)) {
        l = Result + 1}
       else r = Result - 1;
    };
    if (o.hasOwnProperty("" + Result)) Result += 1;
    return Result;
  };
  this.GetSetProp = function (Instance, PropName) {
    var Result = "";
    Result = $mod.GetSetProp$1(Instance,$mod.FindPropInfo(Instance,PropName));
    return Result;
  };
  this.GetSetProp$1 = function (Instance, PropInfo) {
    var Result = "";
    var o = null;
    var key = "";
    var Value = "";
    var n = 0;
    var TIEnum = null;
    var TISet = null;
    Result = "";
    TISet = rtl.asExt(PropInfo.typeinfo,rtl.tTypeInfoSet);
    TIEnum = null;
    if (rtl.isExt(TISet.comptype,rtl.tTypeInfoEnum)) TIEnum = TISet.comptype;
    o = $mod.GetJSValueProp$3(Instance,PropInfo);
    for (key in o) {
      n = parseInt(key,10);
      if ((TIEnum !== null) && (n >= TIEnum.minvalue) && (n <= TIEnum.maxvalue)) {
        Value = TIEnum.enumtype[n]}
       else Value = "" + n;
      if (Result !== "") Result = Result + ",";
      Result = Result + Value;
    };
    Result = "[" + Result + "]";
    return Result;
  };
  this.GetSetPropArray = function (Instance, PropName) {
    var Result = [];
    Result = $mod.GetSetPropArray$1(Instance,$mod.FindPropInfo(Instance,PropName));
    return Result;
  };
  this.GetSetPropArray$1 = function (Instance, PropInfo) {
    var Result = [];
    var o = null;
    var Key = "";
    Result = [];
    o = $mod.GetJSValueProp$3(Instance,PropInfo);
    for (Key in o) Result.push(parseInt(Key,10));
    return Result;
  };
  this.SetSetPropArray = function (Instance, PropName, Arr) {
    $mod.SetSetPropArray$1(Instance,$mod.FindPropInfo(Instance,PropName),Arr);
  };
  this.SetSetPropArray$1 = function (Instance, PropInfo, Arr) {
    var o = null;
    var i = 0;
    o = new Object();
    for (var $in = Arr, $l = 0, $end = rtl.length($in) - 1; $l <= $end; $l++) {
      i = $in[$l];
      o["" + i] = true;
    };
    $mod.SetJSValueProp$3(Instance,PropInfo,o);
  };
  this.GetBoolProp = function (Instance, PropName) {
    var Result = false;
    Result = $mod.GetBoolProp$1(Instance,$mod.FindPropInfo(Instance,PropName));
    return Result;
  };
  this.GetBoolProp$1 = function (Instance, PropInfo) {
    var Result = false;
    Result = !($mod.GetJSValueProp$3(Instance,PropInfo) == false);
    return Result;
  };
  this.SetBoolProp = function (Instance, PropName, Value) {
    $mod.SetBoolProp$1(Instance,$mod.FindPropInfo(Instance,PropName),Value);
  };
  this.SetBoolProp$1 = function (Instance, PropInfo, Value) {
    $mod.SetJSValueProp$3(Instance,PropInfo,Value);
  };
  this.GetStrProp = function (Instance, PropName) {
    var Result = "";
    Result = $mod.GetStrProp$1(Instance,$mod.FindPropInfo(Instance,PropName));
    return Result;
  };
  this.GetStrProp$1 = function (Instance, PropInfo) {
    var Result = "";
    Result = "" + $mod.GetJSValueProp$3(Instance,PropInfo);
    return Result;
  };
  this.SetStrProp = function (Instance, PropName, Value) {
    $mod.SetStrProp$1(Instance,$mod.FindPropInfo(Instance,PropName),Value);
  };
  this.SetStrProp$1 = function (Instance, PropInfo, Value) {
    $mod.SetJSValueProp$3(Instance,PropInfo,Value);
  };
  this.GetStringProp = function (Instance, PropName) {
    var Result = "";
    Result = $mod.GetStrProp(Instance,PropName);
    return Result;
  };
  this.GetStringProp$1 = function (Instance, PropInfo) {
    var Result = "";
    Result = $mod.GetStrProp$1(Instance,PropInfo);
    return Result;
  };
  this.SetStringProp = function (Instance, PropName, Value) {
    $mod.SetStrProp(Instance,PropName,Value);
  };
  this.SetStringProp$1 = function (Instance, PropInfo, Value) {
    $mod.SetStrProp$1(Instance,PropInfo,Value);
  };
  this.GetFloatProp = function (Instance, PropName) {
    var Result = 0.0;
    Result = $mod.GetFloatProp$1(Instance,$mod.FindPropInfo(Instance,PropName));
    return Result;
  };
  this.GetFloatProp$1 = function (Instance, PropInfo) {
    var Result = 0.0;
    Result = rtl.getNumber($mod.GetJSValueProp$3(Instance,PropInfo));
    return Result;
  };
  this.SetFloatProp = function (Instance, PropName, Value) {
    $mod.SetFloatProp$1(Instance,$mod.FindPropInfo(Instance,PropName),Value);
  };
  this.SetFloatProp$1 = function (Instance, PropInfo, Value) {
    $mod.SetJSValueProp$3(Instance,PropInfo,Value);
  };
  this.GetObjectProp = function (Instance, PropName) {
    var Result = null;
    Result = $mod.GetObjectProp$2(Instance,$mod.FindPropInfo(Instance,PropName));
    return Result;
  };
  this.GetObjectProp$1 = function (Instance, PropName, MinClass) {
    var Result = null;
    Result = $mod.GetObjectProp$2(Instance,$mod.FindPropInfo(Instance,PropName));
    if ((MinClass !== null) && (Result !== null)) if (!Result.$class.InheritsFrom(MinClass)) Result = null;
    return Result;
  };
  this.GetObjectProp$2 = function (Instance, PropInfo) {
    var Result = null;
    Result = $mod.GetObjectProp$3(Instance,PropInfo,null);
    return Result;
  };
  this.GetObjectProp$3 = function (Instance, PropInfo, MinClass) {
    var Result = null;
    var O = null;
    O = rtl.getObject($mod.GetJSValueProp$3(Instance,PropInfo));
    if ((MinClass !== null) && !O.$class.InheritsFrom(MinClass)) {
      Result = null}
     else Result = O;
    return Result;
  };
  this.SetObjectProp = function (Instance, PropName, Value) {
    $mod.SetObjectProp$1(Instance,$mod.FindPropInfo(Instance,PropName),Value);
  };
  this.SetObjectProp$1 = function (Instance, PropInfo, Value) {
    $mod.SetJSValueProp$3(Instance,PropInfo,Value);
  };
  this.GetMethodProp = function (Instance, PropInfo) {
    var Result = pas.System.TMethod.$new();
    var v = undefined;
    var fn = undefined;
    Result.Code = null;
    Result.Data = null;
    v = $mod.GetJSValueProp$3(Instance,PropInfo);
    if (!rtl.isFunction(v)) return Result;
    Result.Data = v["scope"];
    fn = v["fn"];
    if (rtl.isString(fn)) {
      if (Result.Data !== null) {
        Result.Code = Result.Data["" + fn]}
       else Result.Code = v;
    } else Result.Code = fn;
    return Result;
  };
  this.GetMethodProp$1 = function (Instance, PropName) {
    var Result = pas.System.TMethod.$new();
    Result.$assign($mod.GetMethodProp(Instance,$mod.FindPropInfo(Instance,PropName)));
    return Result;
  };
  this.SetMethodProp = function (Instance, PropInfo, Value) {
    var cb = null;
    var Code = null;
    Code = Value.Code;
    if (Code === null) {
      cb = null}
     else if (rtl.isFunction(Code)) {
      if ((Code["scope"] === Value.Data) && (rtl.isFunction(Code["fn"]) || rtl.isString(Code["fn"]))) {
        cb = Code;
      } else if (rtl.isString(Code["fn"])) {
        cb = rtl.createCallback(Value.Data,"" + Code["fn"])}
       else cb = rtl.createCallback(Value.Data,Code);
    } else cb = rtl.createCallback(Value.Data,Code);
    $mod.SetJSValueProp$3(Instance,PropInfo,cb);
  };
  this.SetMethodProp$1 = function (Instance, PropName, Value) {
    $mod.SetMethodProp(Instance,$mod.FindPropInfo(Instance,PropName),Value);
  };
  this.GetInterfaceProp = function (Instance, PropName) {
    var Result = null;
    var $ok = false;
    try {
      Result = rtl.setIntfL(Result,$mod.GetInterfaceProp$1(Instance,$mod.FindPropInfo(Instance,PropName)),true);
      $ok = true;
    } finally {
      if (!$ok) rtl._Release(Result);
    };
    return Result;
  };
  this.GetInterfaceProp$1 = function (Instance, PropInfo) {
    var Result = null;
    var gk = 0;
    var $ok = false;
    try {
      if (PropInfo.typeinfo.kind !== pas.System.TTypeKind.tkInterface) throw pas.SysUtils.Exception.$create("Create$1",["Cannot get RAW interface from IInterface interface"]);
      gk = $impl.GetPropGetterKind(PropInfo);
      var $tmp = gk;
      if ($tmp === $impl.TGetterKind.gkNone) {
        throw $mod.EPropertyError.$create("CreateFmt",[rtl.getResStr(pas.RTLConsts,"SCantReadPropertyS"),pas.System.VarRecs(18,PropInfo.name)])}
       else if ($tmp === $impl.TGetterKind.gkField) {
        Result = rtl.setIntfL(Result,rtl.getObject(Instance[PropInfo.getter]))}
       else if ($tmp === $impl.TGetterKind.gkFunction) {
        if ((16 & PropInfo.flags) > 0) {
          Result = rtl.setIntfL(Result,Instance[PropInfo.getter](PropInfo.index),true)}
         else Result = rtl.setIntfL(Result,Instance[PropInfo.getter](),true)}
       else if ($tmp === $impl.TGetterKind.gkFunctionWithParams) throw $mod.EPropertyError.$create("CreateFmt",[rtl.getResStr(pas.RTLConsts,"SIndexedPropertyNeedsParams"),pas.System.VarRecs(18,PropInfo.name)]);
      $ok = true;
    } finally {
      if (!$ok) rtl._Release(Result);
    };
    return Result;
  };
  this.SetInterfaceProp = function (Instance, PropName, Value) {
    $mod.SetInterfaceProp$1(Instance,$mod.FindPropInfo(Instance,PropName),Value);
  };
  this.SetInterfaceProp$1 = function (Instance, PropInfo, Value) {
    var sk = 0;
    var Setter = "";
    if (PropInfo.typeinfo.kind !== pas.System.TTypeKind.tkInterface) throw pas.SysUtils.Exception.$create("Create$1",["Cannot set RAW interface from IInterface interface"]);
    sk = $impl.GetPropSetterKind(PropInfo);
    Setter = PropInfo.setter;
    var $tmp = sk;
    if ($tmp === $impl.TSetterKind.skNone) {
      throw $mod.EPropertyError.$create("CreateFmt",[rtl.getResStr(pas.RTLConsts,"SCantWritePropertyS"),pas.System.VarRecs(18,PropInfo.name)])}
     else if ($tmp === $impl.TSetterKind.skField) {
      rtl.setIntfP(Instance,Setter,Value)}
     else if ($tmp === $impl.TSetterKind.skProcedure) {
      if ((16 & PropInfo.flags) > 0) {
        Instance[Setter](PropInfo.index,Value)}
       else Instance[Setter](Value)}
     else if ($tmp === $impl.TSetterKind.skProcedureWithParams) throw $mod.EPropertyError.$create("CreateFmt",[rtl.getResStr(pas.RTLConsts,"SIndexedPropertyNeedsParams"),pas.System.VarRecs(18,PropInfo.name)]);
  };
  this.GetRawInterfaceProp = function (Instance, PropName) {
    var Result = null;
    Result = $mod.GetRawInterfaceProp$1(Instance,$mod.FindPropInfo(Instance,PropName));
    return Result;
  };
  this.GetRawInterfaceProp$1 = function (Instance, PropInfo) {
    var Result = null;
    Result = $mod.GetJSValueProp$3(Instance,PropInfo);
    return Result;
  };
  this.SetRawInterfaceProp = function (Instance, PropName, Value) {
    $mod.SetRawInterfaceProp$1(Instance,$mod.FindPropInfo(Instance,PropName),Value);
  };
  this.SetRawInterfaceProp$1 = function (Instance, PropInfo, Value) {
    $mod.SetJSValueProp$3(Instance,PropInfo,Value);
  };
  $mod.$implcode = function () {
    $mod.$rtti.$ExtClass("TCreatorAttribute",{jsclass: "attr"});
    $mod.$rtti.$ClassRef("TCreatorAttributeClass",{instancetype: $mod.$rtti["TCreatorAttribute"]});
    $impl.TGetterKind = {"0": "gkNone", gkNone: 0, "1": "gkField", gkField: 1, "2": "gkFunction", gkFunction: 2, "3": "gkFunctionWithParams", gkFunctionWithParams: 3};
    $mod.$rtti.$Enum("TGetterKind",{minvalue: 0, maxvalue: 3, ordtype: 1, enumtype: $impl.TGetterKind});
    $impl.GetPropGetterKind = function (PropInfo) {
      var Result = 0;
      if (PropInfo.getter === "") {
        Result = $impl.TGetterKind.gkNone}
       else if ((1 & PropInfo.flags) > 0) {
        if (rtl.length(PropInfo.params) > 0) {
          Result = $impl.TGetterKind.gkFunctionWithParams}
         else Result = $impl.TGetterKind.gkFunction;
      } else Result = $impl.TGetterKind.gkField;
      return Result;
    };
    $impl.TSetterKind = {"0": "skNone", skNone: 0, "1": "skField", skField: 1, "2": "skProcedure", skProcedure: 2, "3": "skProcedureWithParams", skProcedureWithParams: 3};
    $mod.$rtti.$Enum("TSetterKind",{minvalue: 0, maxvalue: 3, ordtype: 1, enumtype: $impl.TSetterKind});
    $impl.GetPropSetterKind = function (PropInfo) {
      var Result = 0;
      if (PropInfo.setter === "") {
        Result = $impl.TSetterKind.skNone}
       else if ((2 & PropInfo.flags) > 0) {
        if (rtl.length(PropInfo.params) > 0) {
          Result = $impl.TSetterKind.skProcedureWithParams}
         else Result = $impl.TSetterKind.skProcedure;
      } else Result = $impl.TSetterKind.skField;
      return Result;
    };
  };
},[]);
rtl.module("Web",["System","Types","JS"],function () {
  "use strict";
  var $mod = this;
  this.$rtti.$ExtClass("TJSEvent");
  this.$rtti.$ExtClass("TJSHTMLElement");
  this.$rtti.$ExtClass("TJSWindow");
  this.$rtti.$ExtClass("TJSDOMTokenList");
  this.$rtti.$ExtClass("TJSXPathResult");
  this.$rtti.$ExtClass("TJSNodeList");
  this.$rtti.$ExtClass("TJSDocument");
  this.$rtti.$ExtClass("TJSElement");
  this.$rtti.$ExtClass("TJSCSSStyleSheet");
  this.$rtti.$ExtClass("TJSNodeFilter");
  this.$rtti.$ExtClass("TJSIDBObjectStore");
  this.$rtti.$ExtClass("TIDBDatabase");
  this.$rtti.$ExtClass("TJSIDBRequest");
  this.$rtti.$ExtClass("TJSEventTarget");
  this.$rtti.$ExtClass("TJSMouseEvent");
  this.$rtti.$ExtClass("TJSWheelEvent");
  this.$rtti.$ExtClass("TJSKeyboardEvent");
  this.$rtti.$ExtClass("TJSPointerEvent");
  this.$rtti.$ExtClass("TJSUIEvent");
  this.$rtti.$ExtClass("TJSTouchEvent");
  this.$rtti.$ExtClass("TJSInputEvent");
  this.$rtti.$ExtClass("TJSBlob");
  this.$rtti.$ExtClass("TJSPermissions");
  this.$rtti.$ExtClass("TJSFileSystemFileHandle");
  this.$rtti.$DynArray("TJSFileSystemFileHandleArray",{eltype: this.$rtti["TJSFileSystemFileHandle"]});
  this.$rtti.$ExtClass("TJSFileSystemDirectoryHandle");
  this.$rtti.$DynArray("TJSFileSystemDirectoryHandleArray",{eltype: this.$rtti["TJSFileSystemDirectoryHandle"]});
  this.$rtti.$ExtClass("TJSShowOpenFilePickerOptions");
  this.$rtti.$ExtClass("TJSShowSaveFilePickerOptions");
  this.$rtti.$ExtClass("TJSServiceWorker");
  this.$rtti.$ExtClass("TJSClient");
  this.$rtti.$ExtClass("TJSRequest");
  this.$rtti.$ExtClass("TJSResponse");
  this.$rtti.$ExtClass("TJSServiceWorkerRegistration");
  this.$rtti.$ExtClass("TJSResizeObserver");
  this.$rtti.$RefToProcVar("TJSEventHandler",{procsig: rtl.newTIProcSig([["Event",this.$rtti["TJSEvent"]]],rtl.boolean,8)});
  this.$rtti.$RefToProcVar("TJSRawEventHandler",{procsig: rtl.newTIProcSig([["Event",this.$rtti["TJSEvent"]]],null,8)});
  this.$rtti.$RefToProcVar("TJSUIEventHandler",{procsig: rtl.newTIProcSig([["aEvent",this.$rtti["TJSUIEvent"]]],rtl.boolean,8)});
  this.$rtti.$RefToProcVar("TJSPointerEventHandler",{procsig: rtl.newTIProcSig([["aEvent",this.$rtti["TJSPointerEvent"]]],rtl.boolean,8)});
  this.$rtti.$RefToProcVar("THTMLClickEventHandler",{procsig: rtl.newTIProcSig([["aEvent",this.$rtti["TJSMouseEvent"]]],rtl.boolean,8)});
  this.$rtti.$ExtClass("TJSEventTarget",{ancestor: pas.JS.$rtti["TJSObject"], jsclass: "EventTarget"});
  this.$rtti.$ExtClass("TJSNode",{ancestor: this.$rtti["TJSEventTarget"], jsclass: "Node"});
  this.$rtti.$RefToProcVar("TJSNodeListCallBack",{procsig: rtl.newTIProcSig([["currentValue",this.$rtti["TJSNode"]],["currentIndex",rtl.nativeint],["list",this.$rtti["TJSNodeList"]]])});
  this.$rtti.$MethodVar("TJSNodeListEvent",{procsig: rtl.newTIProcSig([["currentValue",this.$rtti["TJSNode"]],["currentIndex",rtl.nativeint],["list",this.$rtti["TJSNodeList"]]]), methodkind: 0});
  this.$rtti.$ExtClass("TJSNodeList",{ancestor: pas.JS.$rtti["TJSObject"], jsclass: "NodeList"});
  this.$rtti.$ExtClass("TJSAttr",{ancestor: this.$rtti["TJSNode"], jsclass: "Attr"});
  this.$rtti.$ExtClass("TJSNamedNodeMap",{ancestor: pas.JS.$rtti["TJSObject"], jsclass: "NamedNodeMap"});
  this.$rtti.$ExtClass("TJSHTMLCollection",{ancestor: pas.JS.$rtti["TJSObject"], jsclass: "HTMLCollection"});
  this.$rtti.$ProcVar("TDOMTokenlistCallBack",{procsig: rtl.newTIProcSig([["Current",rtl.jsvalue],["currentIndex",rtl.nativeint],["list",this.$rtti["TJSDOMTokenList"]]])});
  this.$rtti.$ExtClass("TJSDOMTokenList",{ancestor: pas.JS.$rtti["TJSObject"], jsclass: "DOMTokenList"});
  this.$rtti.$ExtClass("TJSDOMRect",{ancestor: pas.JS.$rtti["TJSObject"], jsclass: "DOMRect"});
  rtl.recNewT(this,"TJSClientRect",function () {
    this.left = 0.0;
    this.top = 0.0;
    this.right = 0.0;
    this.bottom = 0.0;
    this.$eq = function (b) {
      return (this.left === b.left) && (this.top === b.top) && (this.right === b.right) && (this.bottom === b.bottom);
    };
    this.$assign = function (s) {
      this.left = s.left;
      this.top = s.top;
      this.right = s.right;
      this.bottom = s.bottom;
      return this;
    };
    var $r = $mod.$rtti.$Record("TJSClientRect",{});
    $r.addField("left",rtl.double);
    $r.addField("top",rtl.double);
    $r.addField("right",rtl.double);
    $r.addField("bottom",rtl.double);
  });
  this.$rtti.$DynArray("TJSClientRectArray",{eltype: this.$rtti["TJSClientRect"]});
  this.$rtti.$ExtClass("TJSElement",{ancestor: this.$rtti["TJSNode"], jsclass: "Element"});
  rtl.recNewT(this,"TJSElementCreationOptions",function () {
    this.named = "";
    this.$eq = function (b) {
      return this.named === b.named;
    };
    this.$assign = function (s) {
      this.named = s.named;
      return this;
    };
    var $r = $mod.$rtti.$Record("TJSElementCreationOptions",{});
    $r.addField("named",rtl.string);
  });
  this.$rtti.$ExtClass("TJSDocumentType",{ancestor: this.$rtti["TJSNode"], jsclass: "DocumentType"});
  this.$rtti.$ExtClass("TJSDOMImplementation",{ancestor: pas.JS.$rtti["TJSObject"], jsclass: "DocumentImplementation"});
  this.$rtti.$ExtClass("TJSLocation",{ancestor: pas.JS.$rtti["TJSObject"], jsclass: "Location"});
  this.$rtti.$ExtClass("TJSCSSStyleDeclaration");
  this.$rtti.$ExtClass("TJSStyleSheet",{ancestor: this.$rtti["TJSEventTarget"], jsclass: "StyleSheet"});
  this.$rtti.$ExtClass("TJSCSSRule",{ancestor: pas.JS.$rtti["TJSObject"], jsclass: "CSSRule"});
  this.$rtti.$ExtClass("TJSCSSStyleRule",{ancestor: this.$rtti["TJSCSSRule"], jsclass: "CSSStyleRule"});
  this.$rtti.$ExtClass("TJSCSSRuleList",{ancestor: pas.JS.$rtti["TJSObject"], jsclass: "CSSRuleList"});
  this.$rtti.$ExtClass("TJSCSSStyleSheet",{ancestor: this.$rtti["TJSStyleSheet"], jsclass: "CSSStyleSheet"});
  this.$rtti.$ExtClass("TJSStyleSheetList",{ancestor: pas.JS.$rtti["TJSObject"], jsclass: "StyleSheetList"});
  this.$rtti.$ExtClass("TJSDocumentFragment",{ancestor: this.$rtti["TJSNode"], jsclass: "DocumentFragment"});
  rtl.recNewT(this,"TJSEventInit",function () {
    this.bubbles = false;
    this.cancelable = false;
    this.scoped = false;
    this.composed = false;
    this.$eq = function (b) {
      return (this.bubbles === b.bubbles) && (this.cancelable === b.cancelable) && (this.scoped === b.scoped) && (this.composed === b.composed);
    };
    this.$assign = function (s) {
      this.bubbles = s.bubbles;
      this.cancelable = s.cancelable;
      this.scoped = s.scoped;
      this.composed = s.composed;
      return this;
    };
    var $r = $mod.$rtti.$Record("TJSEventInit",{});
    $r.addField("bubbles",rtl.boolean);
    $r.addField("cancelable",rtl.boolean);
    $r.addField("scoped",rtl.boolean);
    $r.addField("composed",rtl.boolean);
  });
  this.$rtti.$ExtClass("TJSEvent",{ancestor: pas.JS.$rtti["TJSObject"], jsclass: "Event"});
  this.$rtti.$ExtClass("TJSXPathExpression",{ancestor: pas.JS.$rtti["TJSObject"], jsclass: "XPathExpression"});
  this.$rtti.$ExtClass("TJSXPathNSResolver",{ancestor: pas.JS.$rtti["TJSObject"], jsclass: "XPathNSResolver"});
  this.$rtti.$ExtClass("TJSCharacterData",{ancestor: this.$rtti["TJSNode"], jsclass: "CharacterData"});
  this.$rtti.$ExtClass("TJSProcessingInstruction",{ancestor: this.$rtti["TJSCharacterData"], jsclass: "ProcessingInstruction"});
  this.$rtti.$ExtClass("TJSRange",{ancestor: pas.JS.$rtti["TJSObject"], jsclass: "Range"});
  this.$rtti.$ExtClass("TJSTreeWalker",{ancestor: pas.JS.$rtti["TJSObject"], jsclass: "TreeWalker"});
  this.$rtti.$ExtClass("TJSNodeFilter",{ancestor: pas.JS.$rtti["TJSObject"], jsclass: "NodeFilter"});
  this.$rtti.$ExtClass("TJSXPathResult",{ancestor: pas.JS.$rtti["TJSObject"], jsclass: "XPathResult"});
  this.$rtti.$ExtClass("TJSSelection",{ancestor: pas.JS.$rtti["TJSObject"], jsclass: "Selection"});
  this.$rtti.$ProcVar("TJSNameSpaceMapperCallback",{procsig: rtl.newTIProcSig([["aNameSpace",rtl.string]],rtl.string)});
  this.$rtti.$ExtClass("TJSHTMLFile");
  this.$rtti.$ExtClass("TJSHTMLFileList");
  this.$rtti.$RefToProcVar("TJSDataTransferItemCallBack",{procsig: rtl.newTIProcSig([["aData",rtl.string]],null,8)});
  this.$rtti.$ExtClass("TJSDataTransferItem",{ancestor: pas.JS.$rtti["TJSObject"], jsclass: "DataTransferItem"});
  this.$rtti.$ExtClass("TJSDataTransferItemList",{ancestor: pas.JS.$rtti["TJSObject"], jsclass: "DataTransferItemList"});
  this.$rtti.$ExtClass("TJSDataTransfer",{ancestor: pas.JS.$rtti["TJSObject"], jsclass: "DataTransfer"});
  this.$rtti.$ExtClass("TJSDragEvent",{ancestor: this.$rtti["TJSEvent"], jsclass: "DragEvent"});
  this.$rtti.$RefToProcVar("TJSDragDropEventHandler",{procsig: rtl.newTIProcSig([["aEvent",this.$rtti["TJSDragEvent"]]],rtl.boolean,8)});
  this.$rtti.$ExtClass("TJSClipBoardEvent",{ancestor: this.$rtti["TJSEvent"], jsclass: "ClipboardEvent"});
  rtl.createClassExt(this,"TJSFocusEvent",Event,"",function () {
    this.$init = function () {
    };
    this.$final = function () {
    };
  });
  rtl.createClassExt(this,"TJSAnimationEvent",Event,"",function () {
    this.$init = function () {
    };
    this.$final = function () {
    };
  });
  rtl.createClassExt(this,"TJSLoadEvent",Event,"",function () {
    this.$init = function () {
    };
    this.$final = function () {
    };
  });
  this.$rtti.$ExtClass("TJSErrorEvent",{ancestor: this.$rtti["TJSEvent"], jsclass: "ErrorEvent"});
  this.$rtti.$ExtClass("TJSPromiseRejectionEvent",{ancestor: this.$rtti["TJSEvent"], jsclass: "PromiseRejectionEvent"});
  rtl.createClassExt(this,"TJSPageTransitionEvent",Event,"",function () {
    this.$init = function () {
    };
    this.$final = function () {
    };
  });
  this.$rtti.$ExtClass("TJSHashChangeEvent",{ancestor: this.$rtti["TJSEvent"], jsclass: "HashChangeEvent"});
  this.$rtti.$ExtClass("TJSPopStateEvent",{ancestor: this.$rtti["TJSEvent"], jsclass: "PopStateEvent"});
  this.$rtti.$ExtClass("TJSStorageEvent",{ancestor: this.$rtti["TJSEvent"], jsclass: "StorageEvent"});
  this.$rtti.$ExtClass("TJSProgressEvent",{ancestor: this.$rtti["TJSEvent"], jsclass: "ProgressEvent"});
  this.$rtti.$ExtClass("TJSCloseEvent",{ancestor: this.$rtti["TJSEvent"], jsclass: "CloseEvent"});
  this.$rtti.$RefToProcVar("TJSPageTransitionEventHandler",{procsig: rtl.newTIProcSig([["aEvent",this.$rtti["TJSPageTransitionEvent"]]],rtl.boolean,8)});
  this.$rtti.$RefToProcVar("TJSHashChangeEventhandler",{procsig: rtl.newTIProcSig([["aEvent",this.$rtti["TJSHashChangeEvent"]]],rtl.boolean,8)});
  this.$rtti.$RefToProcVar("TJSMouseWheelEventHandler",{procsig: rtl.newTIProcSig([["aEvent",this.$rtti["TJSWheelEvent"]]],rtl.boolean,8)});
  this.$rtti.$RefToProcVar("TJSMouseEventHandler",{procsig: rtl.newTIProcSig([["aEvent",this.$rtti["TJSMouseEvent"]]],rtl.boolean,8)});
  this.$rtti.$RefToProcVar("THTMLAnimationEventHandler",{procsig: rtl.newTIProcSig([["aEvent",this.$rtti["TJSAnimationEvent"]]],rtl.boolean,8)});
  this.$rtti.$RefToProcVar("TJSErrorEventHandler",{procsig: rtl.newTIProcSig([["aEvent",this.$rtti["TJSErrorEvent"]]],rtl.boolean,8)});
  this.$rtti.$RefToProcVar("TJSPromiseRejectionEventHandler",{procsig: rtl.newTIProcSig([["aEvent",this.$rtti["TJSPromiseRejectionEvent"]]],rtl.boolean,8)});
  this.$rtti.$RefToProcVar("TJSFocusEventHandler",{procsig: rtl.newTIProcSig([["aEvent",this.$rtti["TJSFocusEvent"]]],rtl.boolean,8)});
  this.$rtti.$RefToProcVar("TJSKeyEventhandler",{procsig: rtl.newTIProcSig([["aEvent",this.$rtti["TJSKeyboardEvent"]]],rtl.boolean,8)});
  this.$rtti.$RefToProcVar("TJSLoadEventhandler",{procsig: rtl.newTIProcSig([["aEvent",this.$rtti["TJSLoadEvent"]]],rtl.boolean,8)});
  this.$rtti.$RefToProcVar("TJSPopStateEventHandler",{procsig: rtl.newTIProcSig([["aEvent",this.$rtti["TJSPopStateEvent"]]],rtl.boolean,8)});
  this.$rtti.$RefToProcVar("TJSStorageEventHandler",{procsig: rtl.newTIProcSig([["aEvent",this.$rtti["TJSStorageEvent"]]],rtl.boolean,8)});
  this.$rtti.$RefToProcVar("TJSProgressEventhandler",{procsig: rtl.newTIProcSig([["aEvent",this.$rtti["TJSProgressEvent"]]],rtl.boolean,8)});
  this.$rtti.$RefToProcVar("TJSTouchEventHandler",{procsig: rtl.newTIProcSig([["aEvent",this.$rtti["TJSTouchEvent"]]],rtl.boolean,8)});
  this.$rtti.$ExtClass("TJSDocument",{ancestor: this.$rtti["TJSNode"], jsclass: "Document"});
  this.$rtti.$ExtClass("TJSConsole",{ancestor: pas.JS.$rtti["TJSObject"], jsclass: "Console"});
  this.$rtti.$ExtClass("TJSCryptoKey");
  this.$rtti.$ExtClass("TJSSubtleCrypto");
  rtl.recNewT(this,"Algorithm",function () {
    this.name = "";
    this.$eq = function (b) {
      return this.name === b.name;
    };
    this.$assign = function (s) {
      this.name = s.name;
      return this;
    };
    var $r = $mod.$rtti.$Record("Algorithm",{});
    $r.addField("name",rtl.string);
  });
  rtl.recNewT(this,"AesCbcParams",function () {
    this.iv = null;
    this.$eq = function (b) {
      return this.iv === b.iv;
    };
    this.$assign = function (s) {
      this.iv = s.iv;
      return this;
    };
    var $r = $mod.$rtti.$Record("AesCbcParams",{});
    $r.addField("iv",pas.JS.$rtti["TJSBufferSource"]);
  });
  rtl.recNewT(this,"AesCtrParams",function () {
    this.counter = null;
    this.$eq = function (b) {
      return (this.counter === b.counter) && (this.length === b.length);
    };
    this.$assign = function (s) {
      this.counter = s.counter;
      this.length = s.length;
      return this;
    };
    var $r = $mod.$rtti.$Record("AesCtrParams",{});
    $r.addField("counter",pas.JS.$rtti["TJSBufferSource"]);
    $r.addField("length",rtl.byte);
  });
  rtl.recNewT(this,"AesGcmParams",function () {
    this.iv = null;
    this.additionalData = null;
    this.tagLength = 0;
    this.$eq = function (b) {
      return (this.iv === b.iv) && (this.additionalData === b.additionalData) && (this.tagLength === b.tagLength);
    };
    this.$assign = function (s) {
      this.iv = s.iv;
      this.additionalData = s.additionalData;
      this.tagLength = s.tagLength;
      return this;
    };
    var $r = $mod.$rtti.$Record("AesGcmParams",{});
    $r.addField("iv",pas.JS.$rtti["TJSBufferSource"]);
    $r.addField("additionalData",pas.JS.$rtti["TJSBufferSource"]);
    $r.addField("tagLength",rtl.byte);
  });
  rtl.recNewT(this,"HmacImportParams",function () {
    this.hash = undefined;
    this.$eq = function (b) {
      return this.hash === b.hash;
    };
    this.$assign = function (s) {
      this.hash = s.hash;
      return this;
    };
    var $r = $mod.$rtti.$Record("HmacImportParams",{});
    $r.addField("hash",rtl.jsvalue);
  });
  rtl.recNewT(this,"Pbkdf2Params",function () {
    this.salt = null;
    this.iterations = 0;
    this.hash = undefined;
    this.$eq = function (b) {
      return (this.salt === b.salt) && (this.iterations === b.iterations) && (this.hash === b.hash);
    };
    this.$assign = function (s) {
      this.salt = s.salt;
      this.iterations = s.iterations;
      this.hash = s.hash;
      return this;
    };
    var $r = $mod.$rtti.$Record("Pbkdf2Params",{});
    $r.addField("salt",pas.JS.$rtti["TJSBufferSource"]);
    $r.addField("iterations",rtl.nativeint);
    $r.addField("hash",rtl.jsvalue);
  });
  rtl.recNewT(this,"RsaHashedImportParams",function () {
    this.hash = undefined;
    this.$eq = function (b) {
      return this.hash === b.hash;
    };
    this.$assign = function (s) {
      this.hash = s.hash;
      return this;
    };
    var $r = $mod.$rtti.$Record("RsaHashedImportParams",{});
    $r.addField("hash",rtl.jsvalue);
  });
  rtl.recNewT(this,"AesKeyGenParams",function () {
    this.$eq = function (b) {
      return this.length === b.length;
    };
    this.$assign = function (s) {
      this.length = s.length;
      return this;
    };
    var $r = $mod.$rtti.$Record("AesKeyGenParams",{});
    $r.addField("length",rtl.longint);
  });
  rtl.recNewT(this,"HmacKeyGenParams",function () {
    this.hash = undefined;
    this.$eq = function (b) {
      return (this.hash === b.hash) && (this.length === b.length);
    };
    this.$assign = function (s) {
      this.hash = s.hash;
      this.length = s.length;
      return this;
    };
    var $r = $mod.$rtti.$Record("HmacKeyGenParams",{});
    $r.addField("hash",rtl.jsvalue);
    $r.addField("length",rtl.longint);
  });
  rtl.recNewT(this,"RsaHashedKeyGenParams",function () {
    this.modulusLength = 0;
    this.publicExponent = null;
    this.hash = undefined;
    this.$eq = function (b) {
      return (this.modulusLength === b.modulusLength) && (this.publicExponent === b.publicExponent) && (this.hash === b.hash);
    };
    this.$assign = function (s) {
      this.modulusLength = s.modulusLength;
      this.publicExponent = s.publicExponent;
      this.hash = s.hash;
      return this;
    };
    var $r = $mod.$rtti.$Record("RsaHashedKeyGenParams",{});
    $r.addField("modulusLength",rtl.longint);
    $r.addField("publicExponent",pas.JS.$rtti["TJSUint8Array"]);
    $r.addField("hash",rtl.jsvalue);
  });
  rtl.recNewT(this,"RsaOaepParams",function () {
    this.$eq = function (b) {
      return this.label === b.label;
    };
    this.$assign = function (s) {
      this.label = s.label;
      return this;
    };
    var $r = $mod.$rtti.$Record("RsaOaepParams",{});
    $r.addField("label",pas.JS.$rtti["TJSBufferSource"]);
  });
  rtl.recNewT(this,"RsaPssParams",function () {
    this.saltLength = 0;
    this.$eq = function (b) {
      return this.saltLength === b.saltLength;
    };
    this.$assign = function (s) {
      this.saltLength = s.saltLength;
      return this;
    };
    var $r = $mod.$rtti.$Record("RsaPssParams",{});
    $r.addField("saltLength",rtl.longint);
  });
  rtl.recNewT(this,"DhKeyGenParams",function () {
    this.prime = null;
    this.generator = null;
    this.$eq = function (b) {
      return (this.prime === b.prime) && (this.generator === b.generator);
    };
    this.$assign = function (s) {
      this.prime = s.prime;
      this.generator = s.generator;
      return this;
    };
    var $r = $mod.$rtti.$Record("DhKeyGenParams",{});
    $r.addField("prime",pas.JS.$rtti["TJSUint8Array"]);
    $r.addField("generator",pas.JS.$rtti["TJSUint8Array"]);
  });
  rtl.recNewT(this,"EcKeyGenParams",function () {
    this.$eq = function (b) {
      return this.namedCurve === b.namedCurve;
    };
    this.$assign = function (s) {
      this.namedCurve = s.namedCurve;
      return this;
    };
    var $r = $mod.$rtti.$Record("EcKeyGenParams",{});
    $r.addField("namedCurve",rtl.string);
  });
  rtl.recNewT(this,"AesDerivedKeyParams",function () {
    this.$eq = function (b) {
      return this.length === b.length;
    };
    this.$assign = function (s) {
      this.length = s.length;
      return this;
    };
    var $r = $mod.$rtti.$Record("AesDerivedKeyParams",{});
    $r.addField("length",rtl.longint);
  });
  rtl.recNewT(this,"HmacDerivedKeyParams",function () {
    this.$eq = function (b) {
      return this.length === b.length;
    };
    this.$assign = function (s) {
      this.length = s.length;
      return this;
    };
    var $r = $mod.$rtti.$Record("HmacDerivedKeyParams",{});
    $r.addField("length",rtl.longint);
  });
  rtl.recNewT(this,"EcdhKeyDeriveParams",function () {
    this.$eq = function (b) {
      return this.public === b.public;
    };
    this.$assign = function (s) {
      this.public = s.public;
      return this;
    };
    var $r = $mod.$rtti.$Record("EcdhKeyDeriveParams",{});
    $r.addField("public",$mod.$rtti["TJSCryptoKey"]);
  });
  rtl.recNewT(this,"DhKeyDeriveParams",function () {
    this.$eq = function (b) {
      return this.public === b.public;
    };
    this.$assign = function (s) {
      this.public = s.public;
      return this;
    };
    var $r = $mod.$rtti.$Record("DhKeyDeriveParams",{});
    $r.addField("public",$mod.$rtti["TJSCryptoKey"]);
  });
  rtl.recNewT(this,"DhImportKeyParams",function () {
    this.prime = null;
    this.generator = null;
    this.$eq = function (b) {
      return (this.prime === b.prime) && (this.generator === b.generator);
    };
    this.$assign = function (s) {
      this.prime = s.prime;
      this.generator = s.generator;
      return this;
    };
    var $r = $mod.$rtti.$Record("DhImportKeyParams",{});
    $r.addField("prime",pas.JS.$rtti["TJSUint8Array"]);
    $r.addField("generator",pas.JS.$rtti["TJSUint8Array"]);
  });
  rtl.recNewT(this,"EcdsaParams",function () {
    this.hash = undefined;
    this.$eq = function (b) {
      return this.hash === b.hash;
    };
    this.$assign = function (s) {
      this.hash = s.hash;
      return this;
    };
    var $r = $mod.$rtti.$Record("EcdsaParams",{});
    $r.addField("hash",rtl.jsvalue);
  });
  rtl.recNewT(this,"EcKeyImportParams",function () {
    this.$eq = function (b) {
      return this.namedCurve === b.namedCurve;
    };
    this.$assign = function (s) {
      this.namedCurve = s.namedCurve;
      return this;
    };
    var $r = $mod.$rtti.$Record("EcKeyImportParams",{});
    $r.addField("namedCurve",rtl.string);
  });
  rtl.recNewT(this,"HkdfParams",function () {
    this.hash = undefined;
    this.salt = null;
    this.info = null;
    this.$eq = function (b) {
      return (this.hash === b.hash) && (this.salt === b.salt) && (this.info === b.info);
    };
    this.$assign = function (s) {
      this.hash = s.hash;
      this.salt = s.salt;
      this.info = s.info;
      return this;
    };
    var $r = $mod.$rtti.$Record("HkdfParams",{});
    $r.addField("hash",rtl.jsvalue);
    $r.addField("salt",pas.JS.$rtti["TJSBufferSource"]);
    $r.addField("info",pas.JS.$rtti["TJSBufferSource"]);
  });
  rtl.recNewT(this,"RsaOtherPrimesInfo",function () {
    this.r = "";
    this.d = "";
    this.t = "";
    this.$eq = function (b) {
      return (this.r === b.r) && (this.d === b.d) && (this.t === b.t);
    };
    this.$assign = function (s) {
      this.r = s.r;
      this.d = s.d;
      this.t = s.t;
      return this;
    };
    var $r = $mod.$rtti.$Record("RsaOtherPrimesInfo",{});
    $r.addField("r",rtl.string);
    $r.addField("d",rtl.string);
    $r.addField("t",rtl.string);
  });
  this.$rtti.$DynArray("TRsaOtherPrimesInfoDynArray",{eltype: this.$rtti["RsaOtherPrimesInfo"]});
  rtl.recNewT(this,"JsonWebKey",function () {
    this.kty = "";
    this.use = "";
    this.alg = "";
    this.ext = false;
    this.crv = "";
    this.x = "";
    this.y = "";
    this.d = "";
    this.n = "";
    this.e = "";
    this.p = "";
    this.q = "";
    this.dp = "";
    this.dq = "";
    this.qi = "";
    this.k = "";
    this.$new = function () {
      var r = Object.create(this);
      r.key_ops = [];
      r.oth = [];
      return r;
    };
    this.$eq = function (b) {
      return (this.kty === b.kty) && (this.use === b.use) && (this.key_ops === b.key_ops) && (this.alg === b.alg) && (this.ext === b.ext) && (this.crv === b.crv) && (this.x === b.x) && (this.y === b.y) && (this.d === b.d) && (this.n === b.n) && (this.e === b.e) && (this.p === b.p) && (this.q === b.q) && (this.dp === b.dp) && (this.dq === b.dq) && (this.qi === b.qi) && (this.oth === b.oth) && (this.k === b.k);
    };
    this.$assign = function (s) {
      this.kty = s.kty;
      this.use = s.use;
      this.key_ops = rtl.arrayRef(s.key_ops);
      this.alg = s.alg;
      this.ext = s.ext;
      this.crv = s.crv;
      this.x = s.x;
      this.y = s.y;
      this.d = s.d;
      this.n = s.n;
      this.e = s.e;
      this.p = s.p;
      this.q = s.q;
      this.dp = s.dp;
      this.dq = s.dq;
      this.qi = s.qi;
      this.oth = rtl.arrayRef(s.oth);
      this.k = s.k;
      return this;
    };
    var $r = $mod.$rtti.$Record("JsonWebKey",{});
    $r.addField("kty",rtl.string);
    $r.addField("use",rtl.string);
    $r.addField("key_ops",pas.Types.$rtti["TStringDynArray"]);
    $r.addField("alg",rtl.string);
    $r.addField("ext",rtl.boolean);
    $r.addField("crv",rtl.string);
    $r.addField("x",rtl.string);
    $r.addField("y",rtl.string);
    $r.addField("d",rtl.string);
    $r.addField("n",rtl.string);
    $r.addField("e",rtl.string);
    $r.addField("p",rtl.string);
    $r.addField("q",rtl.string);
    $r.addField("dp",rtl.string);
    $r.addField("dq",rtl.string);
    $r.addField("qi",rtl.string);
    $r.addField("oth",$mod.$rtti["TRsaOtherPrimesInfoDynArray"]);
    $r.addField("k",rtl.string);
  });
  rtl.recNewT(this,"CryptoKeyPair",function () {
    this.publicKey = null;
    this.privateKey = null;
    this.$eq = function (b) {
      return (this.publicKey === b.publicKey) && (this.privateKey === b.privateKey);
    };
    this.$assign = function (s) {
      this.publicKey = s.publicKey;
      this.privateKey = s.privateKey;
      return this;
    };
    var $r = $mod.$rtti.$Record("CryptoKeyPair",{});
    $r.addField("publicKey",$mod.$rtti["TJSCryptoKey"]);
    $r.addField("privateKey",$mod.$rtti["TJSCryptoKey"]);
  });
  this.$rtti.$DynArray("TKeyUsageDynArray",{eltype: rtl.string});
  this.$rtti.$ExtClass("TJSCryptoKey",{jsclass: "CryptoKey"});
  this.$rtti.$ExtClass("TJSSubtleCrypto",{jsclass: "SubtleCrypto"});
  this.$rtti.$ExtClass("TJSCrypto",{ancestor: pas.JS.$rtti["TJSObject"], jsclass: "Crypto"});
  this.$rtti.$ExtClass("TJSHistory",{ancestor: pas.JS.$rtti["TJSObject"], jsclass: "History"});
  rtl.createClass(this,"TJSIDBTransactionMode",pas.System.TObject,function () {
    this.readonly = "readonly";
    this.readwrite = "readwrite";
    this.versionchange = "versionchange";
  });
  this.$rtti.$ExtClass("TJSIDBTransaction",{ancestor: this.$rtti["TJSEventTarget"], jsclass: "IDBTransaction"});
  this.$rtti.$ExtClass("TJSIDBKeyRange",{ancestor: pas.JS.$rtti["TJSObject"], jsclass: "IDBKeyRange"});
  rtl.recNewT(this,"TJSIDBIndexParameters",function () {
    this.unique = false;
    this.multiEntry = false;
    this.locale = "";
    this.$eq = function (b) {
      return (this.unique === b.unique) && (this.multiEntry === b.multiEntry) && (this.locale === b.locale);
    };
    this.$assign = function (s) {
      this.unique = s.unique;
      this.multiEntry = s.multiEntry;
      this.locale = s.locale;
      return this;
    };
    var $r = $mod.$rtti.$Record("TJSIDBIndexParameters",{});
    $r.addField("unique",rtl.boolean);
    $r.addField("multiEntry",rtl.boolean);
    $r.addField("locale",rtl.string);
  });
  this.$rtti.$ExtClass("TJSIDBIndex",{ancestor: pas.JS.$rtti["TJSObject"], jsclass: "IDBIndex"});
  this.$rtti.$ExtClass("TJSIDBCursorDirection",{ancestor: pas.JS.$rtti["TJSObject"], jsclass: "IDBCursorDirection"});
  this.$rtti.$ExtClass("TJSIDBCursor",{ancestor: pas.JS.$rtti["TJSObject"], jsclass: "IDBCursor"});
  this.$rtti.$ExtClass("TJSIDBObjectStore",{ancestor: this.$rtti["TJSEventTarget"], jsclass: "IDBObjectStore"});
  this.$rtti.$ExtClass("TJSIDBRequest",{ancestor: this.$rtti["TJSEventTarget"], jsclass: "IDBRequest"});
  this.$rtti.$ExtClass("TJSIDBOpenDBRequest",{ancestor: this.$rtti["TJSIDBRequest"], jsclass: "IDBOpenDBRequest"});
  rtl.recNewT(this,"TJSCreateObjectStoreOptions",function () {
    this.keyPath = undefined;
    this.autoIncrement = false;
    this.$eq = function (b) {
      return (this.keyPath === b.keyPath) && (this.autoIncrement === b.autoIncrement);
    };
    this.$assign = function (s) {
      this.keyPath = s.keyPath;
      this.autoIncrement = s.autoIncrement;
      return this;
    };
    var $r = $mod.$rtti.$Record("TJSCreateObjectStoreOptions",{});
    $r.addField("keyPath",rtl.jsvalue);
    $r.addField("autoIncrement",rtl.boolean);
  });
  this.$rtti.$ExtClass("TIDBDatabase",{ancestor: this.$rtti["TJSEventTarget"], jsclass: "IDBDatabase"});
  this.$rtti.$ExtClass("TJSIDBFactory",{ancestor: this.$rtti["TJSEventTarget"], jsclass: "IDBFactory"});
  this.$rtti.$ExtClass("TJSStorage",{ancestor: this.$rtti["TJSEventTarget"], jsclass: "Storage"});
  this.$rtti.$ExtClass("TJSVisibleItem",{ancestor: pas.JS.$rtti["TJSObject"], jsclass: "IVisible"});
  this.$rtti.$ExtClass("TJSLocationBar",{ancestor: this.$rtti["TJSVisibleItem"], jsclass: "LocationBar"});
  this.$rtti.$ExtClass("TJSMenuBar",{ancestor: this.$rtti["TJSVisibleItem"], jsclass: "MenuBar"});
  this.$rtti.$ExtClass("TJSToolBar",{ancestor: this.$rtti["TJSVisibleItem"], jsclass: "ToolBar"});
  this.$rtti.$ExtClass("TJSPersonalBar",{ancestor: this.$rtti["TJSVisibleItem"], jsclass: "PersonalBar"});
  this.$rtti.$ExtClass("TJSScrollBars",{ancestor: this.$rtti["TJSVisibleItem"], jsclass: "ScrollBars"});
  rtl.recNewT(this,"TJSPositionError",function () {
    this.code = 0;
    this.message = "";
    this.$eq = function (b) {
      return (this.code === b.code) && (this.message === b.message);
    };
    this.$assign = function (s) {
      this.code = s.code;
      this.message = s.message;
      return this;
    };
    var $r = $mod.$rtti.$Record("TJSPositionError",{});
    $r.addField("code",rtl.longint);
    $r.addField("message",rtl.string);
  });
  rtl.recNewT(this,"TJSPositionOptions",function () {
    this.enableHighAccuracy = false;
    this.timeout = 0;
    this.maximumAge = 0;
    this.$eq = function (b) {
      return (this.enableHighAccuracy === b.enableHighAccuracy) && (this.timeout === b.timeout) && (this.maximumAge === b.maximumAge);
    };
    this.$assign = function (s) {
      this.enableHighAccuracy = s.enableHighAccuracy;
      this.timeout = s.timeout;
      this.maximumAge = s.maximumAge;
      return this;
    };
    var $r = $mod.$rtti.$Record("TJSPositionOptions",{});
    $r.addField("enableHighAccuracy",rtl.boolean);
    $r.addField("timeout",rtl.longint);
    $r.addField("maximumAge",rtl.longint);
  });
  rtl.recNewT(this,"TJSCoordinates",function () {
    this.latitude = 0.0;
    this.longitude = 0.0;
    this.altitude = 0.0;
    this.accuracy = 0.0;
    this.altitudeAccuracy = 0.0;
    this.heading = 0.0;
    this.speed = 0.0;
    this.$eq = function (b) {
      return (this.latitude === b.latitude) && (this.longitude === b.longitude) && (this.altitude === b.altitude) && (this.accuracy === b.accuracy) && (this.altitudeAccuracy === b.altitudeAccuracy) && (this.heading === b.heading) && (this.speed === b.speed);
    };
    this.$assign = function (s) {
      this.latitude = s.latitude;
      this.longitude = s.longitude;
      this.altitude = s.altitude;
      this.accuracy = s.accuracy;
      this.altitudeAccuracy = s.altitudeAccuracy;
      this.heading = s.heading;
      this.speed = s.speed;
      return this;
    };
    var $r = $mod.$rtti.$Record("TJSCoordinates",{});
    $r.addField("latitude",rtl.double);
    $r.addField("longitude",rtl.double);
    $r.addField("altitude",rtl.double);
    $r.addField("accuracy",rtl.double);
    $r.addField("altitudeAccuracy",rtl.double);
    $r.addField("heading",rtl.double);
    $r.addField("speed",rtl.double);
  });
  rtl.recNewT(this,"TJSPosition",function () {
    this.timestamp = "";
    this.$new = function () {
      var r = Object.create(this);
      r.coords = $mod.TJSCoordinates.$new();
      return r;
    };
    this.$eq = function (b) {
      return this.coords.$eq(b.coords) && (this.timestamp === b.timestamp);
    };
    this.$assign = function (s) {
      this.coords.$assign(s.coords);
      this.timestamp = s.timestamp;
      return this;
    };
    var $r = $mod.$rtti.$Record("TJSPosition",{});
    $r.addField("coords",$mod.$rtti["TJSCoordinates"]);
    $r.addField("timestamp",rtl.string);
  });
  this.$rtti.$ProcVar("TJSGeoLocationCallback",{procsig: rtl.newTIProcSig([["aPosition",this.$rtti["TJSPosition"]]])});
  this.$rtti.$MethodVar("TJSGeoLocationEvent",{procsig: rtl.newTIProcSig([["aPosition",this.$rtti["TJSPosition"]]]), methodkind: 0});
  this.$rtti.$ProcVar("TJSGeoLocationErrorCallback",{procsig: rtl.newTIProcSig([["aValue",this.$rtti["TJSPositionError"]]])});
  this.$rtti.$MethodVar("TJSGeoLocationErrorEvent",{procsig: rtl.newTIProcSig([["aValue",this.$rtti["TJSPositionError"]]]), methodkind: 0});
  this.$rtti.$ExtClass("TJSGeoLocation",{ancestor: pas.JS.$rtti["TJSObject"], jsclass: "GeoLocation"});
  this.$rtti.$ExtClass("TJSMediaStreamTrack",{ancestor: this.$rtti["TJSEventTarget"], jsclass: "MediaStreamTrack"});
  this.$rtti.$ExtClass("TJSMediaDevices",{ancestor: this.$rtti["TJSEventTarget"], jsclass: "MediaDevices"});
  this.$rtti.$ExtClass("TJSWorker",{ancestor: this.$rtti["TJSEventTarget"], jsclass: "Worker"});
  this.$rtti.$ExtClass("TJSMessagePort",{ancestor: this.$rtti["TJSEventTarget"], jsclass: "MessagePort"});
  this.$rtti.$DynArray("TJSMessagePortDynArray",{eltype: this.$rtti["TJSMessagePort"]});
  this.$rtti.$ExtClass("TJSSharedWorker",{ancestor: this.$rtti["TJSEventTarget"], jsclass: "SharedWorker"});
  this.$rtti.$ExtClass("TJSExtendableEvent",{ancestor: this.$rtti["TJSEvent"], jsclass: "ExtendableEvent"});
  this.$rtti.$ExtClass("TJSExtendableMessageEvent",{ancestor: this.$rtti["TJSExtendableEvent"], jsclass: "ExtendableMessageEvent"});
  this.$rtti.$ExtClass("TJSFetchEvent",{ancestor: this.$rtti["TJSExtendableEvent"], jsclass: "FetchEvent"});
  this.$rtti.$ExtClass("TJSClient",{ancestor: pas.JS.$rtti["TJSObject"], jsclass: "Client"});
  this.$rtti.$ExtClass("TJSServiceWorker",{ancestor: this.$rtti["TJSWorker"], jsclass: "ServiceWorker"});
  this.$rtti.$ExtClass("TJSNavigationPreloadState",{jsclass: "navigationPreloadState"});
  this.$rtti.$ExtClass("TJSNavigationPreload",{ancestor: pas.JS.$rtti["TJSObject"], jsclass: "navigationPreload"});
  this.$rtti.$ExtClass("TJSServiceWorkerRegistration",{ancestor: pas.JS.$rtti["TJSObject"], jsclass: "ServiceWorkerRegistration"});
  rtl.recNewT(this,"TJSServiceWorkerContainerOptions",function () {
    this.scope = "";
    this.$eq = function (b) {
      return this.scope === b.scope;
    };
    this.$assign = function (s) {
      this.scope = s.scope;
      return this;
    };
    var $r = $mod.$rtti.$Record("TJSServiceWorkerContainerOptions",{});
    $r.addField("scope",rtl.string);
  });
  this.$rtti.$ExtClass("TJSServiceWorkerContainer",{ancestor: pas.JS.$rtti["TJSObject"], jsclass: "ServiceWorkerContainer"});
  this.$rtti.$ExtClass("TJSClipboardItemOptions",{ancestor: pas.JS.$rtti["TJSObject"], jsclass: "Object"});
  this.$rtti.$ExtClass("TJSClipBoardItem",{ancestor: pas.JS.$rtti["TJSObject"], jsclass: "ClipboardItem"});
  this.$rtti.$ExtClass("TJSClipBoard",{ancestor: this.$rtti["TJSEventTarget"], jsclass: "Clipboard"});
  this.$rtti.$ExtClass("TJSNavigator",{ancestor: pas.JS.$rtti["TJSObject"], jsclass: "Navigator"});
  this.$rtti.$ExtClass("TJSTouch",{ancestor: pas.JS.$rtti["TJSObject"], jsclass: "Touch"});
  this.$rtti.$ExtClass("TJSTouchList",{ancestor: pas.JS.$rtti["TJSObject"], jsclass: "TouchList"});
  this.$rtti.$ExtClass("TJSPerformance",{ancestor: pas.JS.$rtti["TJSObject"], jsclass: "Performance"});
  this.$rtti.$ExtClass("TJSScreen",{ancestor: pas.JS.$rtti["TJSObject"], jsclass: "Screen"});
  this.$rtti.$RefToProcVar("TJSParamEnumCallBack",{procsig: rtl.newTIProcSig([["aKey",rtl.string,2],["aValue",rtl.string,2]])});
  this.$rtti.$ExtClass("TJSURLSearchParams",{ancestor: pas.JS.$rtti["TJSObject"], jsclass: "URLSearchParams"});
  this.$rtti.$ExtClass("TJSURL",{ancestor: pas.JS.$rtti["TJSObject"], jsclass: "URL"});
  this.$rtti.$DynArray("TJSURLDynArray",{eltype: this.$rtti["TJSURL"]});
  this.$rtti.$RefToProcVar("TJSTimerCallBack",{procsig: rtl.newTIProcSig([],null,8)});
  this.$rtti.$StaticArray("Theader",{dims: [2], eltype: rtl.string});
  this.$rtti.$DynArray("THeaderArray",{eltype: this.$rtti["Theader"]});
  this.$rtti.$ExtClass("TJSHTMLHeaders",{ancestor: pas.JS.$rtti["TJSObject"], jsclass: "Headers"});
  this.$rtti.$ExtClass("TJSMediaQueryList",{ancestor: pas.JS.$rtti["TJSObject"], jsclass: "MediaQueryList"});
  this.$rtti.$ExtClass("TJSReadableStream",{ancestor: pas.JS.$rtti["TJSObject"], jsclass: "ReadableStream"});
  this.$rtti.$ExtClass("TJSWritableStream",{ancestor: pas.JS.$rtti["TJSObject"], jsclass: "WritableStream"});
  this.$rtti.$ExtClass("TJSBody",{ancestor: pas.JS.$rtti["TJSObject"], jsclass: "Body"});
  this.$rtti.$ExtClass("TJSResponse",{ancestor: this.$rtti["TJSBody"], jsclass: "Response"});
  this.$rtti.$RefToProcVar("TFrameRequestCallback",{procsig: rtl.newTIProcSig([["aTime",rtl.double]])});
  this.$rtti.$ExtClass("TJSPostMessageOptions",{ancestor: pas.JS.$rtti["TJSObject"], jsclass: "Object"});
  rtl.createClass(this,"TJSIdleCallbackOptions",pas.System.TObject,function () {
    this.$init = function () {
      pas.System.TObject.$init.call(this);
      this.timeout = 0;
    };
  });
  this.$rtti.$ExtClass("TJSIdleDeadline",{jsclass: "IdleDeadline"});
  this.$rtti.$ExtClass("TJSCacheDeleteOptions",{ancestor: pas.JS.$rtti["TJSObject"], jsclass: "Object"});
  this.$rtti.$ExtClass("TJSRequest",{ancestor: pas.JS.$rtti["TJSObject"], jsclass: "Request"});
  this.$rtti.$DynArray("TJSRequestDynArray",{eltype: this.$rtti["TJSRequest"]});
  this.$rtti.$ExtClass("TJSCache",{ancestor: pas.JS.$rtti["TJSObject"], jsclass: "Cache"});
  this.$rtti.$ExtClass("TJSCacheStorage",{ancestor: pas.JS.$rtti["TJSObject"], jsclass: "CacheStorage"});
  this.$rtti.$DynArray("TJSWindowArray",{eltype: this.$rtti["TJSWindow"]});
  this.$rtti.$RefToProcVar("TIdleCallbackProc",{procsig: rtl.newTIProcSig([["idleDeadline",this.$rtti["TJSIdleDeadline"]]])});
  this.$rtti.$ExtClass("TJSWindow",{ancestor: this.$rtti["TJSEventTarget"], jsclass: "Window"});
  this.$rtti.$ExtClass("TJSCSSStyleDeclaration",{ancestor: pas.JS.$rtti["TJSObject"], jsclass: "CSSStyleDeclaration"});
  this.$rtti.$ExtClass("TJSScrollIntoViewOptions",{ancestor: pas.JS.$rtti["TJSObject"], jsclass: "Object"});
  this.$rtti.$ExtClass("TJSHTMLElement",{ancestor: this.$rtti["TJSElement"], jsclass: "HTMLElement"});
  this.$rtti.$DynArray("TJSHTMLElementArray",{eltype: this.$rtti["TJSHTMLElement"]});
  this.$rtti.$ExtClass("TJSHTMLDivElement",{ancestor: this.$rtti["TJSHTMLElement"], jsclass: "HTMLDivElement"});
  this.$rtti.$ExtClass("TJSHTMLFormControlsCollection",{ancestor: this.$rtti["TJSHTMLCollection"], jsclass: "HTMLFormControlsCollection"});
  this.$rtti.$ExtClass("TJSHTMLFormElement",{ancestor: this.$rtti["TJSHTMLElement"], jsclass: "HTMLFormElement"});
  this.$rtti.$ExtClass("TJSValidityState",{ancestor: pas.JS.$rtti["TJSObject"], jsclass: "ValidityState"});
  rtl.createClassExt(this,"TJSBlobPropertyBag",Object,"",function () {
    this.$init = function () {
    };
    this.$final = function () {
    };
    this.Create$2 = function (aType) {
      this.type = aType;
      return this;
    };
    this.Create$3 = function (aType, aEndings) {
      this.type = aType;
      this.endings = aEndings;
      return this;
    };
  });
  this.$rtti.$ExtClass("TJSBlob",{ancestor: this.$rtti["TJSEventTarget"], jsclass: "Blob"});
  this.$rtti.$ExtClass("TJSHTMLFile",{ancestor: this.$rtti["TJSBlob"], jsclass: "File"});
  this.$rtti.$ExtClass("TJSHTMLFileList",{ancestor: this.$rtti["TJSEventTarget"], jsclass: "FileList"});
  this.$rtti.$ExtClass("TJSHTMLInputElement",{ancestor: this.$rtti["TJSHTMLElement"], jsclass: "HTMLInputElement"});
  this.$rtti.$ExtClass("TJSDOMSettableTokenList",{ancestor: this.$rtti["TJSDOMTokenList"], jsclass: "DOMSettableTokenList"});
  this.$rtti.$ExtClass("TJSHTMLOutputElement",{ancestor: this.$rtti["TJSHTMLElement"], jsclass: "HTMLOutputElement"});
  this.$rtti.$ExtClass("TJSHTMLImageElement",{ancestor: this.$rtti["TJSHTMLElement"], jsclass: "Image"});
  this.$rtti.$ExtClass("TJSHTMLLinkElement",{ancestor: this.$rtti["TJSHTMLElement"], jsclass: "HTMLLinkElement"});
  this.$rtti.$ExtClass("TJSHTMLAnchorElement",{ancestor: this.$rtti["TJSHTMLElement"], jsclass: "HTMLAnchorElement"});
  this.$rtti.$ExtClass("TJSHTMLMenuElement",{ancestor: this.$rtti["TJSHTMLElement"], jsclass: "HTMLMenuElement"});
  this.$rtti.$ExtClass("TJSHTMLButtonElement",{ancestor: this.$rtti["TJSHTMLElement"], jsclass: "HTMLButtonElement"});
  this.$rtti.$ExtClass("TJSHTMLLabelElement",{ancestor: this.$rtti["TJSHTMLElement"], jsclass: "HTMLLabelElement"});
  this.$rtti.$ExtClass("TJSHTMLTextAreaElement",{ancestor: this.$rtti["TJSHTMLElement"], jsclass: "HTMLTextAreaElement"});
  this.$rtti.$ExtClass("TJSHTMLEmbedElement",{ancestor: this.$rtti["TJSHTMLElement"], jsclass: "HTMLEmbedElement"});
  this.$rtti.$ExtClass("TJSHTMLOptionElement",{ancestor: this.$rtti["TJSHTMLElement"], jsclass: "Option"});
  this.$rtti.$ExtClass("TJSHTMLOptGroupElement",{ancestor: this.$rtti["TJSHTMLElement"], jsclass: "HTMLOptGroupElement"});
  this.$rtti.$ExtClass("TJSHTMLOptionsCollection",{ancestor: this.$rtti["TJSHTMLCollection"], jsclass: "HTMLOptionsCollection"});
  this.$rtti.$ExtClass("TJSHTMLSelectElement",{ancestor: this.$rtti["TJSHTMLElement"], jsclass: "HTMLSelectElement"});
  this.$rtti.$ExtClass("TJSHTMLTableSectionElement");
  this.$rtti.$ExtClass("TJSHTMLTableRowElement");
  this.$rtti.$ExtClass("TJSHTMLTableElement",{ancestor: this.$rtti["TJSHTMLElement"], jsclass: "HTMLTableElement"});
  this.$rtti.$ExtClass("TJSHTMLTableSectionElement",{ancestor: this.$rtti["TJSHTMLElement"], jsclass: "HTMLTableSectionElement"});
  this.$rtti.$ExtClass("TJSHTMLTableCellElement",{ancestor: this.$rtti["TJSHTMLElement"], jsclass: "HTMLTableCellElement"});
  this.$rtti.$ExtClass("TJSHTMLTableRowElement",{ancestor: this.$rtti["TJSHTMLElement"], jsclass: "HTMLTableRowElement"});
  this.$rtti.$ExtClass("TJSHTMLTableDataCellElement",{ancestor: this.$rtti["TJSHTMLElement"], jsclass: "HTMLTableDataCellElement"});
  this.$rtti.$ExtClass("TJSCanvasRenderingContext2D");
  this.$rtti.$RefToProcVar("THTMLCanvasToBlobCallback",{procsig: rtl.newTIProcSig([["aBlob",this.$rtti["TJSBlob"]]],rtl.boolean,8)});
  this.$rtti.$ExtClass("TJSHTMLCanvasElement",{ancestor: this.$rtti["TJSHTMLElement"], jsclass: "HTMLCanvasElement"});
  this.$rtti.$ExtClass("TJSHTMLProgressElement",{ancestor: this.$rtti["TJSHTMLElement"], jsclass: "HTMLProgressElement"});
  this.$rtti.$ExtClass("TJSDOMException",{ancestor: pas.JS.$rtti["TJSObject"], jsclass: "DOMException"});
  this.$rtti.$ExtClass("TJSFileReader",{ancestor: this.$rtti["TJSEventTarget"], jsclass: "FileReader"});
  this.$rtti.$ExtClass("TJSCanvasGradient",{ancestor: pas.JS.$rtti["TJSObject"], jsclass: "CanvasGradient"});
  this.$rtti.$ExtClass("TJSCanvasPattern",{ancestor: pas.JS.$rtti["TJSObject"], jsclass: "CanvasPattern"});
  this.$rtti.$ExtClass("TJSPath2D",{ancestor: pas.JS.$rtti["TJSObject"], jsclass: "Path2D"});
  this.$rtti.$ExtClass("TJSImageData",{ancestor: pas.JS.$rtti["TJSObject"], jsclass: "ImageData"});
  this.$rtti.$ExtClass("TJSTextMetrics",{ancestor: pas.JS.$rtti["TJSObject"], jsclass: "TextMetrics"});
  this.$rtti.$ExtClass("TJSCanvasRenderingContext2D",{ancestor: pas.JS.$rtti["TJSObject"], jsclass: "CanvasRenderingContext2D"});
  this.$rtti.$ExtClass("TJSHTMLIFrameElement",{ancestor: this.$rtti["TJSHTMLElement"], jsclass: "HTMLIFrameElement"});
  this.$rtti.$ExtClass("TJSHTMLScriptElement",{ancestor: this.$rtti["TJSHTMLElement"], jsclass: "HTMLScriptElement"});
  this.$rtti.$ExtClass("TJSXMLHttpRequestEventTarget",{ancestor: this.$rtti["TJSEventTarget"], jsclass: "XMLHttpRequestEventTarget"});
  this.$rtti.$ExtClass("TJSXMLHttpRequestUpload",{ancestor: this.$rtti["TJSXMLHttpRequestEventTarget"], jsclass: "XMLHttpRequestUpload"});
  this.$rtti.$RefToProcVar("TJSOnReadyStateChangeHandler",{procsig: rtl.newTIProcSig([],null,8)});
  this.$rtti.$ExtClass("TJSXMLHttpRequest",{ancestor: this.$rtti["TJSXMLHttpRequestEventTarget"], jsclass: "XMLHttpRequest"});
  this.$rtti.$ExtClass("TJSUIEvent",{ancestor: this.$rtti["TJSEvent"], jsclass: "UIEvent"});
  this.$rtti.$ExtClass("TJSMouseEvent",{ancestor: this.$rtti["TJSUIEvent"], jsclass: "MouseEvent"});
  rtl.recNewT(this,"TJSWheelEventInit",function () {
    this.deltaX = 0.0;
    this.deltaY = 0.0;
    this.deltaZ = 0.0;
    this.deltaMode = 0;
    this.$eq = function (b) {
      return (this.deltaX === b.deltaX) && (this.deltaY === b.deltaY) && (this.deltaZ === b.deltaZ) && (this.deltaMode === b.deltaMode);
    };
    this.$assign = function (s) {
      this.deltaX = s.deltaX;
      this.deltaY = s.deltaY;
      this.deltaZ = s.deltaZ;
      this.deltaMode = s.deltaMode;
      return this;
    };
    var $r = $mod.$rtti.$Record("TJSWheelEventInit",{});
    $r.addField("deltaX",rtl.double);
    $r.addField("deltaY",rtl.double);
    $r.addField("deltaZ",rtl.double);
    $r.addField("deltaMode",rtl.nativeint);
  });
  this.$rtti.$ExtClass("TJSWheelEvent",{ancestor: this.$rtti["TJSMouseEvent"], jsclass: "WheelEvent"});
  this.$rtti.$ExtClass("TJSPointerEvent",{ancestor: this.$rtti["TJSMouseEvent"], jsclass: "PointerEvent"});
  this.$rtti.$ExtClass("TJSTouchEvent",{ancestor: this.$rtti["TJSUIEvent"], jsclass: "TouchEvent"});
  rtl.createClass(this,"TJSKeyNames",pas.System.TObject,function () {
    this.Alt = "Alt";
    this.AltGraph = "AltGraph";
    this.CapsLock = "CapsLock";
    this.Control = "Control";
    this.Fn = "Fn";
    this.FnLock = "FnLock";
    this.Hyper = "Hyper";
    this.Meta = "Meta";
    this.NumLock = "NumLock";
    this.ScrollLock = "ScrollLock";
    this.Shift = "Shift";
    this.Super = "Super";
    this.Symbol = "Symbol";
    this.SymbolLock = "SymbolLock";
    this.Enter = "Enter";
    this.Tab = "Tab";
    this.Space = "Space";
    this.ArrowDown = "ArrowDown";
    this.ArrowLeft = "ArrowLeft";
    this.ArrowRight = "ArrowRight";
    this.ArrowUp = "ArrowUp";
    this._End = "End";
    this.Home = "Home";
    this.PageDown = "PageDown";
    this.PageUp = "PageUp";
    this.BackSpace = "Backspace";
    this.Clear = "Clear";
    this.Copy = "Copy";
    this.CrSel = "CrSel";
    this.Cut = "Cut";
    this.Delete = "Delete";
    this.EraseEof = "EraseEof";
    this.ExSel = "ExSel";
    this.Insert = "Insert";
    this.Paste = "Paste";
    this.Redo = "Redo";
    this.Undo = "Undo";
    this.Accept = "Accept";
    this.Again = "Again";
    this.Attn = "Attn";
    this.Cancel = "Cancel";
    this.ContextMenu = "Contextmenu";
    this.Escape = "Escape";
    this.Execute = "Execute";
    this.Find = "Find";
    this.Finish = "Finish";
    this.Help = "Help";
    this.Pause = "Pause";
    this.Play = "Play";
    this.Props = "Props";
    this.Select = "Select";
    this.ZoomIn = "ZoomIn";
    this.ZoomOut = "ZoomOut";
    this.BrightnessDown = "BrightnessDown";
    this.BrightnessUp = "BrightnessUp";
    this.Eject = "Eject";
    this.LogOff = "LogOff";
    this.Power = "Power";
    this.PowerOff = "PowerOff";
    this.PrintScreen = "PrintScreen";
    this.Hibernate = "Hibernate";
    this.Standby = "Standby";
    this.WakeUp = "WakeUp";
    this.AllCandidates = "AllCandidates";
    this.Alphanumeric = "Alphanumeric";
    this.CodeInput = "CodeInput";
    this.Compose = "Compose";
    this.Convert = "Convert";
    this.Dead = "Dead";
    this.FinalMode = "FinalMode";
    this.GroupFirst = "GroupFirst";
    this.GroupLast = "GroupLast";
    this.GroupNext = "GroupNext";
    this.GroupPrevious = "GroupPrevious";
    this.ModelChange = "ModelChange";
    this.NextCandidate = "NextCandidate";
    this.NonConvert = "NonConvert";
    this.PreviousCandidate = "PreviousCandidate";
    this.Process = "Process";
    this.SingleCandidate = "SingleCandidate";
    this.HangulMode = "HangulMode";
    this.HanjaMode = "HanjaMode";
    this.JunjaMode = "JunjaMode";
    this.Eisu = "Eisu";
    this.Hankaku = "Hankaku";
    this.Hiranga = "Hiranga";
    this.HirangaKatakana = "HirangaKatakana";
    this.KanaMode = "KanaMode";
    this.Katakana = "Katakana";
    this.Romaji = "Romaji";
    this.Zenkaku = "Zenkaku";
    this.ZenkakuHanaku = "ZenkakuHanaku";
    this.F1 = "F1";
    this.F2 = "F2";
    this.F3 = "F3";
    this.F4 = "F4";
    this.F5 = "F5";
    this.F6 = "F6";
    this.F7 = "F7";
    this.F8 = "F8";
    this.F9 = "F9";
    this.F10 = "F10";
    this.F11 = "F11";
    this.F12 = "F12";
    this.F13 = "F13";
    this.F14 = "F14";
    this.F15 = "F15";
    this.F16 = "F16";
    this.F17 = "F17";
    this.F18 = "F18";
    this.F19 = "F19";
    this.F20 = "F20";
    this.Soft1 = "Soft1";
    this.Soft2 = "Soft2";
    this.Soft3 = "Soft3";
    this.Soft4 = "Soft4";
    this.Decimal = "Decimal";
    this.Key11 = "Key11";
    this.Key12 = "Key12";
    this.Multiply = "Multiply";
    this.Add = "Add";
    this.NumClear = "Clear";
    this.Divide = "Divide";
    this.Subtract = "Subtract";
    this.Separator = "Separator";
    this.AppSwitch = "AppSwitch";
    this.Call = "Call";
    this.Camera = "Camera";
    this.CameraFocus = "CameraFocus";
    this.EndCall = "EndCall";
    this.GoBack = "GoBack";
    this.GoHome = "GoHome";
    this.HeadsetHook = "HeadsetHook";
    this.LastNumberRedial = "LastNumberRedial";
    this.Notification = "Notification";
    this.MannerMode = "MannerMode";
    this.VoiceDial = "VoiceDial";
  });
  this.$rtti.$ExtClass("TJSKeyboardEvent",{ancestor: this.$rtti["TJSUIEvent"], jsclass: "KeyboardEvent"});
  this.$rtti.$ExtClass("TJSMutationObserver");
  rtl.recNewT(this,"TJSMutationRecord",function () {
    this.type_ = "";
    this.target = null;
    this.addedNodes = null;
    this.removedNodes = null;
    this.previousSibling = null;
    this.nextSibling = null;
    this.attributeName = "";
    this.attributeNamespace = "";
    this.oldValue = "";
    this.$eq = function (b) {
      return (this.type_ === b.type_) && (this.target === b.target) && (this.addedNodes === b.addedNodes) && (this.removedNodes === b.removedNodes) && (this.previousSibling === b.previousSibling) && (this.nextSibling === b.nextSibling) && (this.attributeName === b.attributeName) && (this.attributeNamespace === b.attributeNamespace) && (this.oldValue === b.oldValue);
    };
    this.$assign = function (s) {
      this.type_ = s.type_;
      this.target = s.target;
      this.addedNodes = s.addedNodes;
      this.removedNodes = s.removedNodes;
      this.previousSibling = s.previousSibling;
      this.nextSibling = s.nextSibling;
      this.attributeName = s.attributeName;
      this.attributeNamespace = s.attributeNamespace;
      this.oldValue = s.oldValue;
      return this;
    };
    var $r = $mod.$rtti.$Record("TJSMutationRecord",{});
    $r.addField("type_",rtl.string);
    $r.addField("target",$mod.$rtti["TJSNode"]);
    $r.addField("addedNodes",$mod.$rtti["TJSNodeList"]);
    $r.addField("removedNodes",$mod.$rtti["TJSNodeList"]);
    $r.addField("previousSibling",$mod.$rtti["TJSNode"]);
    $r.addField("nextSibling",$mod.$rtti["TJSNode"]);
    $r.addField("attributeName",rtl.string);
    $r.addField("attributeNamespace",rtl.string);
    $r.addField("oldValue",rtl.string);
  });
  this.$rtti.$DynArray("TJSMutationRecordArray",{eltype: this.$rtti["TJSMutationRecord"]});
  this.$rtti.$RefToProcVar("TJSMutationCallback",{procsig: rtl.newTIProcSig([["mutations",this.$rtti["TJSMutationRecordArray"]],["observer",this.$rtti["TJSMutationObserver"]]],null,8)});
  rtl.recNewT(this,"TJSMutationObserverInit",function () {
    this.attributes = false;
    this.attributeOldValue = false;
    this.characterData = false;
    this.characterDataOldValue = false;
    this.childList = false;
    this.subTree = false;
    this.attributeFilter = null;
    this.$eq = function (b) {
      return (this.attributes === b.attributes) && (this.attributeOldValue === b.attributeOldValue) && (this.characterData === b.characterData) && (this.characterDataOldValue === b.characterDataOldValue) && (this.childList === b.childList) && (this.subTree === b.subTree) && (this.attributeFilter === b.attributeFilter);
    };
    this.$assign = function (s) {
      this.attributes = s.attributes;
      this.attributeOldValue = s.attributeOldValue;
      this.characterData = s.characterData;
      this.characterDataOldValue = s.characterDataOldValue;
      this.childList = s.childList;
      this.subTree = s.subTree;
      this.attributeFilter = s.attributeFilter;
      return this;
    };
    var $r = $mod.$rtti.$Record("TJSMutationObserverInit",{});
    $r.addField("attributes",rtl.boolean);
    $r.addField("attributeOldValue",rtl.boolean);
    $r.addField("characterData",rtl.boolean);
    $r.addField("characterDataOldValue",rtl.boolean);
    $r.addField("childList",rtl.boolean);
    $r.addField("subTree",rtl.boolean);
    $r.addField("attributeFilter",pas.JS.$rtti["TJSArray"]);
  });
  this.$rtti.$ExtClass("TJSMutationObserver",{ancestor: pas.JS.$rtti["TJSObject"], jsclass: "MutationObserver"});
  this.$rtti.$DynArray("TJSMessagePortArray",{eltype: this.$rtti["TJSMessagePort"]});
  this.$rtti.$ExtClass("TJSInputEvent",{ancestor: this.$rtti["TJSUIEvent"], jsclass: "InputEvent"});
  this.$rtti.$ExtClass("TJSMessageEvent",{ancestor: this.$rtti["TJSEvent"], jsclass: "MessageEvent"});
  this.$rtti.$ExtClass("TJSWebSocket",{ancestor: this.$rtti["TJSEventTarget"], jsclass: "WebSocket"});
  this.$rtti.$ExtClass("TJSHTMLAudioTrack",{ancestor: pas.JS.$rtti["TJSObject"], jsclass: "AudioTrack"});
  this.$rtti.$ExtClass("TJSHTMLAudioTrackList",{ancestor: pas.JS.$rtti["TJSObject"], jsclass: "AudioTrackList"});
  this.$rtti.$ExtClass("TJSHTMLVideoTrack",{ancestor: pas.JS.$rtti["TJSObject"], jsclass: "VideoTrack"});
  this.$rtti.$ExtClass("TJSHTMLVideoTrackList",{ancestor: pas.JS.$rtti["TJSObject"], jsclass: "VideoTrackList"});
  this.$rtti.$ExtClass("TJSHTMLTextTrack",{ancestor: pas.JS.$rtti["TJSObject"], jsclass: "TextTrack"});
  this.$rtti.$ExtClass("TJSHTMLTextTrackList",{ancestor: pas.JS.$rtti["TJSObject"], jsclass: "TextTrackList"});
  this.$rtti.$ExtClass("TJSMEdiaError",{ancestor: pas.JS.$rtti["TJSObject"], jsclass: "MediaError"});
  this.$rtti.$ExtClass("TJSHTMLMediaStream",{ancestor: pas.JS.$rtti["TJSObject"], jsclass: "MediaStream"});
  this.$rtti.$ExtClass("TJSHTMLMediaController",{ancestor: pas.JS.$rtti["TJSObject"], jsclass: "MediaController"});
  this.$rtti.$ExtClass("TJSHTMLMediaElement",{ancestor: this.$rtti["TJSHTMLElement"], jsclass: "HTMLMediaElement"});
  this.$rtti.$ExtClass("TJSHTMLAudioElement",{ancestor: this.$rtti["TJSHTMLMediaElement"], jsclass: "HTMLAudioElement"});
  this.$rtti.$ExtClass("TJSHTMLVideoElement",{ancestor: this.$rtti["TJSHTMLMediaElement"], jsclass: "HTMLVideoElement"});
  this.$rtti.$ExtClass("TJSHTMLStyleElement",{ancestor: this.$rtti["TJSHTMLElement"], jsclass: "HTMLStyleElement"});
  this.$rtti.$ExtClass("TJSHTMLDetailsElement",{ancestor: this.$rtti["TJSHTMLElement"], jsclass: "HTMLDetailsElement"});
  this.$rtti.$ExtClass("TJSResizeObserverEntry",{ancestor: pas.JS.$rtti["TJSObject"], jsclass: "ResizeObserverEntry"});
  this.$rtti.$DynArray("TJSResizeObserverEntries",{eltype: this.$rtti["TJSResizeObserverEntry"]});
  this.$rtti.$ProcVar("TJSResizeObserverCallback",{procsig: rtl.newTIProcSig([["AEntries",this.$rtti["TJSResizeObserverEntries"]],["AObserver",this.$rtti["TJSResizeObserver"]]])});
  this.$rtti.$MethodVar("TJSResizeObserverCallbackObj",{procsig: rtl.newTIProcSig([["AEntries",this.$rtti["TJSResizeObserverEntries"]],["AObserver",this.$rtti["TJSResizeObserver"]]]), methodkind: 0});
  this.$rtti.$ExtClass("TJSResizeObserver",{ancestor: pas.JS.$rtti["TJSObject"], jsclass: "ResizeObserver"});
  this.$rtti.$DynArray("TJSFormDataEntryValueArray",{eltype: rtl.string});
  this.$rtti.$ExtClass("TJSFormData",{ancestor: pas.JS.$rtti["TJSObject"], jsclass: "FormData"});
  this.$rtti.$ExtClass("TJSHTMLTemplateElement",{ancestor: this.$rtti["TJSHTMLElement"], jsclass: "HTMLTemplateElement"});
  this.$rtti.$ExtClass("TJSHTMLOrXMLDocument",{ancestor: this.$rtti["TJSDocument"], jsclass: "Document"});
  this.$rtti.$ExtClass("TJSHTMLDocument",{ancestor: this.$rtti["TJSHTMLOrXMLDocument"], jsclass: "HTMLDocument"});
  this.$rtti.$ExtClass("TJSXMLDocument",{ancestor: this.$rtti["TJSHTMLOrXMLDocument"], jsclass: "HTMLDocument"});
  this.$rtti.$ExtClass("TDOMParser",{ancestor: pas.JS.$rtti["TJSObject"], jsclass: "DOMParser"});
  this.$rtti.$RefToProcVar("TOnChangeProcedure",{procsig: rtl.newTIProcSig([])});
  this.$rtti.$ExtClass("TJSPermissionDescriptor",{ancestor: pas.JS.$rtti["TJSObject"], jsclass: "Object"});
  this.$rtti.$ExtClass("TJSPermissionStatus",{ancestor: pas.JS.$rtti["TJSObject"], jsclass: "PermissionStatus"});
  this.$rtti.$ExtClass("TJSPermissions",{ancestor: pas.JS.$rtti["TJSObject"], jsclass: "Permissions"});
  this.$rtti.$ExtClass("TJSFileSystemHandlePermissionDescriptor",{ancestor: pas.JS.$rtti["TJSObject"], jsclass: "Object"});
  this.$rtti.$ExtClass("TJSFileSystemCreateWritableOptions",{ancestor: pas.JS.$rtti["TJSObject"], jsclass: "Object"});
  this.$rtti.$ExtClass("TJSFileSystemWritableFileStream");
  this.$rtti.$ExtClass("TJSFileSystemHandle",{ancestor: pas.JS.$rtti["TJSObject"], jsclass: "FileSystemHandle"});
  this.$rtti.$ExtClass("TJSFileSystemFileHandle",{ancestor: this.$rtti["TJSFileSystemHandle"], jsclass: "FileSystemFileHandle"});
  this.$rtti.$ExtClass("TJSGetFileHandleOptions",{jsclass: "Object"});
  this.$rtti.$ExtClass("TJSRemoveEntryOptions",{ancestor: pas.JS.$rtti["TJSObject"], jsclass: "Object"});
  this.$rtti.$ExtClass("TJSFileSystemDirectoryHandle",{ancestor: this.$rtti["TJSFileSystemHandle"], jsclass: "FileSystemDirectoryHandle"});
  this.$rtti.$ExtClass("TJSFileSystemWritableFileStream",{ancestor: this.$rtti["TJSWritableStream"], jsclass: "FileSystemWritableFileStream"});
  this.$rtti.$ExtClass("TJSShowOpenFilePickerTypeOptions",{ancestor: pas.JS.$rtti["TJSObject"], jsclass: "Object"});
  this.$rtti.$ExtClass("TJSShowOpenFilePickerOptions",{ancestor: pas.JS.$rtti["TJSObject"], jsclass: "Object"});
  this.$rtti.$ExtClass("TJSShowSaveFilePickerOptionsAccept",{ancestor: pas.JS.$rtti["TJSObject"], jsclass: "Object"});
  this.$rtti.$ExtClass("TJSShowSaveFilePickerOptions",{ancestor: pas.JS.$rtti["TJSObject"], jsclass: "Object"});
  this.HasServiceWorker = function () {
    var Result = false;
    if (window.navigator.serviceWorker) {
      return true}
     else return false;
    return Result;
  };
});
rtl.module("p2jsres",["System","Types"],function () {
  "use strict";
  var $mod = this;
  var $impl = $mod.$impl;
  this.TResourceSource = {"0": "rsJS", rsJS: 0, "1": "rsHTML", rsHTML: 1};
  this.$rtti.$Enum("TResourceSource",{minvalue: 0, maxvalue: 1, ordtype: 1, enumtype: this.TResourceSource});
  rtl.recNewT(this,"TResourceInfo",function () {
    this.name = "";
    this.encoding = "";
    this.resourceunit = "";
    this.format = "";
    this.data = "";
    this.$eq = function (b) {
      return (this.name === b.name) && (this.encoding === b.encoding) && (this.resourceunit === b.resourceunit) && (this.format === b.format) && (this.data === b.data);
    };
    this.$assign = function (s) {
      this.name = s.name;
      this.encoding = s.encoding;
      this.resourceunit = s.resourceunit;
      this.format = s.format;
      this.data = s.data;
      return this;
    };
    var $r = $mod.$rtti.$Record("TResourceInfo",{});
    $r.addField("name",rtl.string);
    $r.addField("encoding",rtl.string);
    $r.addField("resourceunit",rtl.string);
    $r.addField("format",rtl.string);
    $r.addField("data",rtl.string);
  });
  this.$rtti.$RefToProcVar("TResourceEnumCallBack",{procsig: rtl.newTIProcSig([["resName",rtl.string,2]],rtl.boolean)});
  this.$rtti.$RefToProcVar("TResourcesLoadedEnumCallBack",{procsig: rtl.newTIProcSig([["LoadedResources",rtl.string,10]])});
  this.$rtti.$RefToProcVar("TResourcesLoadErrorCallBack",{procsig: rtl.newTIProcSig([["aError",rtl.string,2]])});
  this.SetResourceSource = function (aSource) {
    var Result = 0;
    Result = $impl.gMode;
    $impl.gMode = aSource;
    return Result;
  };
  this.GetResourceNames = function () {
    var Result = [];
    Result = $mod.GetResourceNames$1($impl.gMode);
    return Result;
  };
  this.GetResourceNames$1 = function (aSource) {
    var Result = [];
    var $tmp = aSource;
    if ($tmp === $mod.TResourceSource.rsJS) {
      Result = rtl.getResourceList()}
     else if ($tmp === $mod.TResourceSource.rsHTML) Result = $impl.GetHTMLResources();
    return Result;
  };
  this.EnumResources = function (aCallback) {
    var Result = 0;
    Result = $mod.EnumResources$1($impl.gMode,aCallback);
    return Result;
  };
  this.EnumResources$1 = function (aSource, aCallback) {
    var Result = 0;
    var RL = [];
    var I = 0;
    var ContinueEnum = false;
    Result = 0;
    RL = $mod.GetResourceNames$1(aSource);
    I = 0;
    Result = rtl.length(RL);
    ContinueEnum = true;
    while ((I < Result) && ContinueEnum) {
      ContinueEnum = aCallback(RL[I]);
      I += 1;
    };
    return Result;
  };
  this.GetResourceInfo = function (aName, aInfo) {
    var Result = false;
    Result = $mod.GetResourceInfo$1($impl.gMode,aName,aInfo);
    return Result;
  };
  this.GetResourceInfo$1 = function (aSource, aName, aInfo) {
    var Result = false;
    var $tmp = aSource;
    if ($tmp === $mod.TResourceSource.rsJS) {
      Result = $impl.GetRTLResourceInfo(aName,aInfo)}
     else if ($tmp === $mod.TResourceSource.rsHTML) Result = $impl.GetHTMLResourceInfo(aName,aInfo);
    return Result;
  };
  this.LoadHTMLLinkResources = function (aURL, OnLoad, OnError) {
    function FetchOK(Res) {
      var Result = undefined;
      Result = null;
      if (!Res.ok) {
        if (OnError != null) throw new Error("HTTP Error for URL aURL, status = " + pas.SysUtils.IntToStr(Res.status) + " : " + Res.statusText);
      } else Result = Res.text();
      return Result;
    };
    function BlobOK(Res) {
      var Result = undefined;
      var ID = "";
      var Tmpl = null;
      var El = null;
      var Arr = [];
      var aParent = null;
      Result = null;
      aParent = document.head;
      if (aParent === null) aParent = document.body;
      Arr = rtl.arraySetLength(Arr,"",0);
      Tmpl = document.createElement("template");
      Tmpl.innerHTML = Res.trim();
      El = Tmpl.content.firstElementChild;
      while (El !== null) {
        if (pas.SysUtils.SameText(El.tagName,"link") && $impl.IsResourceLink(El)) {
          aParent.append(document.importNode(El,true));
          ID = El.id;
          pas.System.Delete({get: function () {
              return ID;
            }, set: function (v) {
              ID = v;
            }},1,$impl.IDPrefix.length);
          if (ID !== "") Arr.push(ID);
        };
        El = El.nextElementSibling;
      };
      if (OnLoad != null) OnLoad(Arr);
      return Result;
    };
    function DoError(aValue) {
      var Result = undefined;
      Result = null;
      if (OnError != null) if (aValue === null) OnError("Error: " + aValue.message);
      return Result;
    };
    if (!$impl.HasTemplate()) {
      if (OnError != null) OnError("No template support in this browser");
    } else window.fetch(aURL).then(FetchOK).then(BlobOK).catch(DoError);
  };
  $mod.$implcode = function () {
    $impl.gMode = 0;
    $mod.$rtti.$ExtClass("TRTLResourceInfo",{ancestor: pas.JS.$rtti["TJSObject"], jsclass: "Object"});
    $impl.GetRTLResourceInfo = function (aName, aInfo) {
      var Result = false;
      var RTLInfo = null;
      RTLInfo = rtl.getResource(pas.SysUtils.LowerCase(aName));
      Result = RTLInfo != null;
      if (Result) {
        aInfo.name = RTLInfo.name;
        aInfo.encoding = RTLInfo.encoding;
        aInfo.format = RTLInfo.format;
        aInfo.resourceunit = RTLInfo.unit;
        aInfo.data = RTLInfo.data;
      };
      return Result;
    };
    $impl.IDPrefix = "resource-";
    $impl.IsResourceLink = function (L) {
      var Result = false;
      Result = (pas.System.Copy(L.id,1,$impl.IDPrefix.length) === $impl.IDPrefix) && pas.JS.isDefined(L.dataset["unit"]) && (pas.System.Copy(L.href,1,4) === "data");
      return Result;
    };
    $impl.GetHTMLResources = function () {
      var Result = [];
      var LC = null;
      var L = null;
      var I = 0;
      var ID = "";
      Result = rtl.arraySetLength(Result,"",0);
      if (!pas.JS.isDefined(document)) return Result;
      LC = document.getElementsByTagName("link");
      for (var $l = 0, $end = LC.length - 1; $l <= $end; $l++) {
        I = $l;
        L = LC.item(I);
        ID = L.id;
        if ($impl.IsResourceLink(L)) {
          pas.System.Delete({get: function () {
              return ID;
            }, set: function (v) {
              ID = v;
            }},1,$impl.IDPrefix.length);
          if (ID !== "") Result.push(ID);
        };
      };
      return Result;
    };
    $impl.GetHTMLResourceInfo = function (aName, aInfo) {
      var Result = false;
      var el = null;
      var S = "";
      var I = 0;
      Result = false;
      if (!pas.JS.isDefined(document)) return Result;
      el = document.getElementById($impl.IDPrefix + pas.SysUtils.LowerCase(aName));
      Result = (el != null) && pas.SysUtils.SameText(el.tagName,"link");
      if (!Result) return Result;
      aInfo.name = pas.SysUtils.LowerCase(aName);
      aInfo.resourceunit = "" + el.dataset["unit"];
      S = el.href;
      S = pas.System.Copy(S,6,S.length - 5);
      I = pas.System.Pos(",",S);
      aInfo.data = pas.System.Copy(S,I + 1,S.length - 1);
      S = pas.System.Copy(S,1,I - 1);
      I = pas.System.Pos(";",S);
      if (I === 0) {
        aInfo.encoding = ""}
       else {
        aInfo.encoding = pas.System.Copy(S,I + 1,S.length - 1);
        S = pas.System.Copy(S,1,I - 1);
      };
      aInfo.format = S;
      return Result;
    };
    $impl.HasTemplate = function () {
      var Result = false;
      return ('content' in document.createElement('template'));
      Result = false;
      return Result;
    };
  };
},["SysUtils","JS","Web"]);
rtl.module("simplelinkedlist",["System"],function () {
  "use strict";
  var $mod = this;
  rtl.createClass(this,"TLinkedListItem",pas.System.TObject,function () {
    this.$init = function () {
      pas.System.TObject.$init.call(this);
      this.Next = null;
    };
    this.$final = function () {
      this.Next = undefined;
      pas.System.TObject.$final.call(this);
    };
  });
  this.$rtti.$ClassRef("TLinkedListItemClass",{instancetype: this.$rtti["TLinkedListItem"]});
  rtl.createClass(this,"TLinkedListVisitor",pas.System.TObject,function () {
  });
  rtl.createClass(this,"TLinkedList",pas.System.TObject,function () {
    this.$init = function () {
      pas.System.TObject.$init.call(this);
      this.FItemClass = null;
      this.FRoot = null;
    };
    this.$final = function () {
      this.FItemClass = undefined;
      this.FRoot = undefined;
      pas.System.TObject.$final.call(this);
    };
    this.GetCount = function () {
      var Result = 0;
      var I = null;
      I = this.FRoot;
      Result = 0;
      while (I !== null) {
        I = I.Next;
        Result += 1;
      };
      return Result;
    };
    this.Create$1 = function (AnItemClass) {
      this.FItemClass = AnItemClass;
      return this;
    };
    this.Destroy = function () {
      this.Clear();
      pas.System.TObject.Destroy.call(this);
    };
    this.Clear = function () {
      var I = null;
      I = this.FRoot;
      while (I !== null) {
        this.FRoot = I;
        I = I.Next;
        this.FRoot.Next = null;
        pas.SysUtils.FreeAndNil({p: this, get: function () {
            return this.p.FRoot;
          }, set: function (v) {
            this.p.FRoot = v;
          }});
      };
    };
    this.Add = function () {
      var Result = null;
      Result = this.FItemClass.$create("Create");
      Result.Next = this.FRoot;
      this.FRoot = Result;
      return Result;
    };
    this.ForEach = function (Visitor) {
      var I = null;
      I = this.FRoot;
      while ((I !== null) && Visitor.Visit(I)) I = I.Next;
    };
    this.RemoveItem = function (Item, FreeItem) {
      var I = null;
      if ((Item !== null) && (this.FRoot !== null)) {
        if (Item === this.FRoot) {
          this.FRoot = Item.Next}
         else {
          I = this.FRoot;
          while ((I.Next !== null) && (I.Next !== Item)) I = I.Next;
          if (I.Next === Item) I.Next = Item.Next;
        };
        if (FreeItem) Item = rtl.freeLoc(Item);
      };
    };
  });
},["SysUtils"]);
rtl.module("Classes",["System","RTLConsts","Types","SysUtils","JS","TypInfo","p2jsres"],function () {
  "use strict";
  var $mod = this;
  var $impl = $mod.$impl;
  this.$rtti.$MethodVar("TNotifyEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]]]), methodkind: 0});
  this.$rtti.$RefToProcVar("TNotifyEventRef",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]]])});
  this.$rtti.$RefToProcVar("TStringNotifyEventRef",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["aString",rtl.string,2]])});
  this.TFPObservedOperation = {"0": "ooChange", ooChange: 0, "1": "ooFree", ooFree: 1, "2": "ooAddItem", ooAddItem: 2, "3": "ooDeleteItem", ooDeleteItem: 3, "4": "ooCustom", ooCustom: 4};
  this.$rtti.$Enum("TFPObservedOperation",{minvalue: 0, maxvalue: 4, ordtype: 1, enumtype: this.TFPObservedOperation});
  rtl.createClass(this,"EStreamError",pas.SysUtils.Exception,function () {
  });
  rtl.createClass(this,"EFCreateError",this.EStreamError,function () {
  });
  rtl.createClass(this,"EFOpenError",this.EStreamError,function () {
  });
  rtl.createClass(this,"EFilerError",this.EStreamError,function () {
  });
  rtl.createClass(this,"EReadError",this.EFilerError,function () {
  });
  rtl.createClass(this,"EWriteError",this.EFilerError,function () {
  });
  rtl.createClass(this,"EClassNotFound",this.EFilerError,function () {
  });
  rtl.createClass(this,"EMethodNotFound",this.EFilerError,function () {
  });
  rtl.createClass(this,"EInvalidImage",this.EFilerError,function () {
  });
  rtl.createClass(this,"EResNotFound",pas.SysUtils.Exception,function () {
  });
  rtl.createClass(this,"EListError",pas.SysUtils.Exception,function () {
  });
  rtl.createClass(this,"EBitsError",pas.SysUtils.Exception,function () {
  });
  rtl.createClass(this,"EStringListError",this.EListError,function () {
  });
  rtl.createClass(this,"EComponentError",pas.SysUtils.Exception,function () {
  });
  rtl.createClass(this,"EParserError",pas.SysUtils.Exception,function () {
  });
  rtl.createClass(this,"EOutOfResources",pas.SysUtils.EOutOfMemory,function () {
  });
  rtl.createClass(this,"EInvalidOperation",pas.SysUtils.Exception,function () {
  });
  this.TListAssignOp = {"0": "laCopy", laCopy: 0, "1": "laAnd", laAnd: 1, "2": "laOr", laOr: 2, "3": "laXor", laXor: 3, "4": "laSrcUnique", laSrcUnique: 4, "5": "laDestUnique", laDestUnique: 5};
  this.$rtti.$Enum("TListAssignOp",{minvalue: 0, maxvalue: 5, ordtype: 1, enumtype: this.TListAssignOp});
  this.$rtti.$ProcVar("TListSortCompare",{procsig: rtl.newTIProcSig([["Item1",rtl.jsvalue],["Item2",rtl.jsvalue]],rtl.longint)});
  this.$rtti.$RefToProcVar("TListSortCompareFunc",{procsig: rtl.newTIProcSig([["Item1",rtl.jsvalue],["Item2",rtl.jsvalue]],rtl.longint)});
  this.TAlignment = {"0": "taLeftJustify", taLeftJustify: 0, "1": "taRightJustify", taRightJustify: 1, "2": "taCenter", taCenter: 2};
  this.$rtti.$Enum("TAlignment",{minvalue: 0, maxvalue: 2, ordtype: 1, enumtype: this.TAlignment});
  this.$rtti.$Class("TFPList");
  this.$rtti.$Class("TReader");
  this.$rtti.$Class("TWriter");
  this.$rtti.$Class("TFiler");
  rtl.createClass(this,"TFPListEnumerator",pas.System.TObject,function () {
    this.$init = function () {
      pas.System.TObject.$init.call(this);
      this.FList = null;
      this.FPosition = 0;
    };
    this.$final = function () {
      this.FList = undefined;
      pas.System.TObject.$final.call(this);
    };
    this.Create$1 = function (AList) {
      pas.System.TObject.Create.call(this);
      this.FList = AList;
      this.FPosition = -1;
      return this;
    };
    this.GetCurrent = function () {
      var Result = undefined;
      Result = this.FList.Get(this.FPosition);
      return Result;
    };
    this.MoveNext = function () {
      var Result = false;
      this.FPosition += 1;
      Result = this.FPosition < this.FList.FCount;
      return Result;
    };
  });
  rtl.createClass(this,"TFPList",pas.System.TObject,function () {
    this.$init = function () {
      pas.System.TObject.$init.call(this);
      this.FList = [];
      this.FCount = 0;
      this.FCapacity = 0;
    };
    this.$final = function () {
      this.FList = undefined;
      pas.System.TObject.$final.call(this);
    };
    this.CopyMove = function (aList) {
      var r = 0;
      this.Clear();
      for (var $l = 0, $end = aList.FCount - 1; $l <= $end; $l++) {
        r = $l;
        this.Add(aList.Get(r));
      };
    };
    this.MergeMove = function (aList) {
      var r = 0;
      for (var $l = 0, $end = aList.FCount - 1; $l <= $end; $l++) {
        r = $l;
        if (this.IndexOf(aList.Get(r)) < 0) this.Add(aList.Get(r));
      };
    };
    this.DoCopy = function (ListA, ListB) {
      if (ListB != null) {
        this.CopyMove(ListB)}
       else this.CopyMove(ListA);
    };
    this.DoSrcUnique = function (ListA, ListB) {
      var r = 0;
      if (ListB != null) {
        this.Clear();
        for (var $l = 0, $end = ListA.FCount - 1; $l <= $end; $l++) {
          r = $l;
          if (ListB.IndexOf(ListA.Get(r)) < 0) this.Add(ListA.Get(r));
        };
      } else {
        for (var $l1 = this.FCount - 1; $l1 >= 0; $l1--) {
          r = $l1;
          if (ListA.IndexOf(this.Get(r)) >= 0) this.Delete(r);
        };
      };
    };
    this.DoAnd = function (ListA, ListB) {
      var r = 0;
      if (ListB != null) {
        this.Clear();
        for (var $l = 0, $end = ListA.FCount - 1; $l <= $end; $l++) {
          r = $l;
          if (ListB.IndexOf(ListA.Get(r)) >= 0) this.Add(ListA.Get(r));
        };
      } else {
        for (var $l1 = this.FCount - 1; $l1 >= 0; $l1--) {
          r = $l1;
          if (ListA.IndexOf(this.Get(r)) < 0) this.Delete(r);
        };
      };
    };
    this.DoDestUnique = function (ListA, ListB) {
      var $Self = this;
      function MoveElements(Src, Dest) {
        var r = 0;
        $Self.Clear();
        for (var $l = 0, $end = Src.FCount - 1; $l <= $end; $l++) {
          r = $l;
          if (Dest.IndexOf(Src.Get(r)) < 0) $Self.Add(Src.Get(r));
        };
      };
      var Dest = null;
      if (ListB != null) {
        MoveElements(ListB,ListA)}
       else Dest = $mod.TFPList.$create("Create");
      try {
        Dest.CopyMove($Self);
        MoveElements(ListA,Dest);
      } finally {
        Dest.$destroy("Destroy");
      };
    };
    this.DoOr = function (ListA, ListB) {
      if (ListB != null) {
        this.CopyMove(ListA);
        this.MergeMove(ListB);
      } else this.MergeMove(ListA);
    };
    this.DoXOr = function (ListA, ListB) {
      var r = 0;
      var l = null;
      if (ListB != null) {
        this.Clear();
        for (var $l = 0, $end = ListA.FCount - 1; $l <= $end; $l++) {
          r = $l;
          if (ListB.IndexOf(ListA.Get(r)) < 0) this.Add(ListA.Get(r));
        };
        for (var $l1 = 0, $end1 = ListB.FCount - 1; $l1 <= $end1; $l1++) {
          r = $l1;
          if (ListA.IndexOf(ListB.Get(r)) < 0) this.Add(ListB.Get(r));
        };
      } else {
        l = $mod.TFPList.$create("Create");
        try {
          l.CopyMove(this);
          for (var $l2 = this.FCount - 1; $l2 >= 0; $l2--) {
            r = $l2;
            if (ListA.IndexOf(this.Get(r)) >= 0) this.Delete(r);
          };
          for (var $l3 = 0, $end2 = ListA.FCount - 1; $l3 <= $end2; $l3++) {
            r = $l3;
            if (l.IndexOf(ListA.Get(r)) < 0) this.Add(ListA.Get(r));
          };
        } finally {
          l.$destroy("Destroy");
        };
      };
    };
    this.Get = function (Index) {
      var Result = undefined;
      if ((Index < 0) || (Index >= this.FCount)) this.RaiseIndexError(Index);
      Result = this.FList[Index];
      return Result;
    };
    this.Put = function (Index, Item) {
      if ((Index < 0) || (Index >= this.FCount)) this.RaiseIndexError(Index);
      this.FList[Index] = Item;
    };
    this.SetCapacity = function (NewCapacity) {
      if (NewCapacity < this.FCount) this.$class.Error(rtl.getResStr(pas.RTLConsts,"SListCapacityError"),"" + NewCapacity);
      if (NewCapacity === this.FCapacity) return;
      this.FList = rtl.arraySetLength(this.FList,undefined,NewCapacity);
      this.FCapacity = NewCapacity;
    };
    this.SetCount = function (NewCount) {
      if (NewCount < 0) this.$class.Error(rtl.getResStr(pas.RTLConsts,"SListCountError"),"" + NewCount);
      if (NewCount > this.FCount) {
        if (NewCount > this.FCapacity) this.SetCapacity(NewCount);
      };
      this.FCount = NewCount;
    };
    this.RaiseIndexError = function (Index) {
      this.$class.Error(rtl.getResStr(pas.RTLConsts,"SListIndexError"),"" + Index);
    };
    this.Destroy = function () {
      this.Clear();
      pas.System.TObject.Destroy.call(this);
    };
    this.AddList = function (AList) {
      var I = 0;
      if (this.FCapacity < (this.FCount + AList.FCount)) this.SetCapacity(this.FCount + AList.FCount);
      for (var $l = 0, $end = AList.FCount - 1; $l <= $end; $l++) {
        I = $l;
        this.Add(AList.Get(I));
      };
    };
    this.Add = function (Item) {
      var Result = 0;
      if (this.FCount === this.FCapacity) this.Expand();
      this.FList[this.FCount] = Item;
      Result = this.FCount;
      this.FCount += 1;
      return Result;
    };
    this.Clear = function () {
      if (rtl.length(this.FList) > 0) {
        this.SetCount(0);
        this.SetCapacity(0);
      };
    };
    this.Delete = function (Index) {
      if ((Index < 0) || (Index >= this.FCount)) this.$class.Error(rtl.getResStr(pas.RTLConsts,"SListIndexError"),"" + Index);
      this.FCount = this.FCount - 1;
      this.FList.splice(Index,1);
      this.FCapacity -= 1;
    };
    this.Error = function (Msg, Data) {
      throw $mod.EListError.$create("CreateFmt",[Msg,pas.System.VarRecs(18,Data)]);
    };
    this.Exchange = function (Index1, Index2) {
      var Temp = undefined;
      if ((Index1 >= this.FCount) || (Index1 < 0)) this.$class.Error(rtl.getResStr(pas.RTLConsts,"SListIndexError"),"" + Index1);
      if ((Index2 >= this.FCount) || (Index2 < 0)) this.$class.Error(rtl.getResStr(pas.RTLConsts,"SListIndexError"),"" + Index2);
      Temp = this.FList[Index1];
      this.FList[Index1] = this.FList[Index2];
      this.FList[Index2] = Temp;
    };
    this.Expand = function () {
      var Result = null;
      var IncSize = 0;
      if (this.FCount < this.FCapacity) return this;
      IncSize = 4;
      if (this.FCapacity > 3) IncSize = IncSize + 4;
      if (this.FCapacity > 8) IncSize = IncSize + 8;
      if (this.FCapacity > 127) IncSize += this.FCapacity >>> 2;
      this.SetCapacity(this.FCapacity + IncSize);
      Result = this;
      return Result;
    };
    this.Extract = function (Item) {
      var Result = undefined;
      var i = 0;
      i = this.IndexOf(Item);
      if (i >= 0) {
        Result = Item;
        this.Delete(i);
      } else Result = null;
      return Result;
    };
    this.First = function () {
      var Result = undefined;
      if (this.FCount === 0) {
        Result = null}
       else Result = this.Get(0);
      return Result;
    };
    this.GetEnumerator = function () {
      var Result = null;
      Result = $mod.TFPListEnumerator.$create("Create$1",[this]);
      return Result;
    };
    this.IndexOf = function (Item) {
      var Result = 0;
      var C = 0;
      Result = 0;
      C = this.FCount;
      while ((Result < C) && (this.FList[Result] != Item)) Result += 1;
      if (Result >= C) Result = -1;
      return Result;
    };
    this.IndexOfItem = function (Item, Direction) {
      var Result = 0;
      if (Direction === pas.Types.TDirection.FromBeginning) {
        Result = this.IndexOf(Item)}
       else {
        Result = this.FCount - 1;
        while ((Result >= 0) && (this.FList[Result] != Item)) Result = Result - 1;
      };
      return Result;
    };
    this.Insert = function (Index, Item) {
      if ((Index < 0) || (Index > this.FCount)) this.$class.Error(rtl.getResStr(pas.RTLConsts,"SListIndexError"),"" + Index);
      this.FList.splice(Index,0,Item);
      this.FCapacity += 1;
      this.FCount += 1;
    };
    this.Last = function () {
      var Result = undefined;
      if (this.FCount === 0) {
        Result = null}
       else Result = this.Get(this.FCount - 1);
      return Result;
    };
    this.Move = function (CurIndex, NewIndex) {
      var Temp = undefined;
      if ((CurIndex < 0) || (CurIndex > (this.FCount - 1))) this.$class.Error(rtl.getResStr(pas.RTLConsts,"SListIndexError"),"" + CurIndex);
      if ((NewIndex < 0) || (NewIndex > (this.FCount - 1))) this.$class.Error(rtl.getResStr(pas.RTLConsts,"SListIndexError"),"" + NewIndex);
      if (CurIndex === NewIndex) return;
      Temp = this.FList[CurIndex];
      this.FList.splice(CurIndex,1);
      this.FList.splice(NewIndex,0,Temp);
    };
    this.Assign = function (ListA, AOperator, ListB) {
      var $tmp = AOperator;
      if ($tmp === $mod.TListAssignOp.laCopy) {
        this.DoCopy(ListA,ListB)}
       else if ($tmp === $mod.TListAssignOp.laSrcUnique) {
        this.DoSrcUnique(ListA,ListB)}
       else if ($tmp === $mod.TListAssignOp.laAnd) {
        this.DoAnd(ListA,ListB)}
       else if ($tmp === $mod.TListAssignOp.laDestUnique) {
        this.DoDestUnique(ListA,ListB)}
       else if ($tmp === $mod.TListAssignOp.laOr) {
        this.DoOr(ListA,ListB)}
       else if ($tmp === $mod.TListAssignOp.laXor) this.DoXOr(ListA,ListB);
    };
    this.Remove = function (Item) {
      var Result = 0;
      Result = this.IndexOf(Item);
      if (Result !== -1) this.Delete(Result);
      return Result;
    };
    this.Pack = function () {
      var Dst = 0;
      var i = 0;
      var V = undefined;
      Dst = 0;
      for (var $l = 0, $end = this.FCount - 1; $l <= $end; $l++) {
        i = $l;
        V = this.FList[i];
        if (!pas.System.Assigned(V)) continue;
        this.FList[Dst] = V;
        Dst += 1;
      };
    };
    this.Sort = function (Compare) {
      var $Self = this;
      if (!(rtl.length(this.FList) > 0) || (this.FCount < 2)) return;
      $impl.QuickSort(rtl.arrayRef(this.FList),0,this.FCount - 1,function (Item1, Item2) {
        var Result = 0;
        Result = Compare(Item1,Item2);
        return Result;
      });
    };
    this.SortList = function (Compare) {
      if (!(rtl.length(this.FList) > 0) || (this.FCount < 2)) return;
      $impl.QuickSort(rtl.arrayRef(this.FList),0,this.FCount - 1,Compare);
    };
    this.ForEachCall = function (proc2call, arg) {
      var i = 0;
      var v = undefined;
      for (var $l = 0, $end = this.FCount - 1; $l <= $end; $l++) {
        i = $l;
        v = this.FList[i];
        if (pas.System.Assigned(v)) proc2call(v,arg);
      };
    };
    this.ForEachCall$1 = function (proc2call, arg) {
      var i = 0;
      var v = undefined;
      for (var $l = 0, $end = this.FCount - 1; $l <= $end; $l++) {
        i = $l;
        v = this.FList[i];
        if (pas.System.Assigned(v)) proc2call(v,arg);
      };
    };
  });
  this.TListNotification = {"0": "lnAdded", lnAdded: 0, "1": "lnExtracted", lnExtracted: 1, "2": "lnDeleted", lnDeleted: 2};
  this.$rtti.$Enum("TListNotification",{minvalue: 0, maxvalue: 2, ordtype: 1, enumtype: this.TListNotification});
  this.$rtti.$Class("TList");
  rtl.createClass(this,"TListEnumerator",pas.System.TObject,function () {
    this.$init = function () {
      pas.System.TObject.$init.call(this);
      this.FList = null;
      this.FPosition = 0;
    };
    this.$final = function () {
      this.FList = undefined;
      pas.System.TObject.$final.call(this);
    };
    this.Create$1 = function (AList) {
      pas.System.TObject.Create.call(this);
      this.FList = AList;
      this.FPosition = -1;
      return this;
    };
    this.GetCurrent = function () {
      var Result = undefined;
      Result = this.FList.Get(this.FPosition);
      return Result;
    };
    this.MoveNext = function () {
      var Result = false;
      this.FPosition += 1;
      Result = this.FPosition < this.FList.GetCount();
      return Result;
    };
  });
  rtl.createClass(this,"TList",pas.System.TObject,function () {
    this.$init = function () {
      pas.System.TObject.$init.call(this);
      this.FList = null;
    };
    this.$final = function () {
      this.FList = undefined;
      pas.System.TObject.$final.call(this);
    };
    this.CopyMove = function (aList) {
      var r = 0;
      this.Clear();
      for (var $l = 0, $end = aList.GetCount() - 1; $l <= $end; $l++) {
        r = $l;
        this.Add(aList.Get(r));
      };
    };
    this.MergeMove = function (aList) {
      var r = 0;
      for (var $l = 0, $end = aList.GetCount() - 1; $l <= $end; $l++) {
        r = $l;
        if (this.IndexOf(aList.Get(r)) < 0) this.Add(aList.Get(r));
      };
    };
    this.DoCopy = function (ListA, ListB) {
      if (ListB != null) {
        this.CopyMove(ListB)}
       else this.CopyMove(ListA);
    };
    this.DoSrcUnique = function (ListA, ListB) {
      var r = 0;
      if (ListB != null) {
        this.Clear();
        for (var $l = 0, $end = ListA.GetCount() - 1; $l <= $end; $l++) {
          r = $l;
          if (ListB.IndexOf(ListA.Get(r)) < 0) this.Add(ListA.Get(r));
        };
      } else {
        for (var $l1 = this.GetCount() - 1; $l1 >= 0; $l1--) {
          r = $l1;
          if (ListA.IndexOf(this.Get(r)) >= 0) this.Delete(r);
        };
      };
    };
    this.DoAnd = function (ListA, ListB) {
      var r = 0;
      if (ListB != null) {
        this.Clear();
        for (var $l = 0, $end = ListA.GetCount() - 1; $l <= $end; $l++) {
          r = $l;
          if (ListB.IndexOf(ListA.Get(r)) >= 0) this.Add(ListA.Get(r));
        };
      } else {
        for (var $l1 = this.GetCount() - 1; $l1 >= 0; $l1--) {
          r = $l1;
          if (ListA.IndexOf(this.Get(r)) < 0) this.Delete(r);
        };
      };
    };
    this.DoDestUnique = function (ListA, ListB) {
      var $Self = this;
      function MoveElements(Src, Dest) {
        var r = 0;
        $Self.Clear();
        for (var $l = 0, $end = Src.GetCount() - 1; $l <= $end; $l++) {
          r = $l;
          if (Dest.IndexOf(Src.Get(r)) < 0) $Self.Add(Src.Get(r));
        };
      };
      var Dest = null;
      if (ListB != null) {
        MoveElements(ListB,ListA)}
       else try {
        Dest = $mod.TList.$create("Create$1");
        Dest.CopyMove($Self);
        MoveElements(ListA,Dest);
      } finally {
        Dest.$destroy("Destroy");
      };
    };
    this.DoOr = function (ListA, ListB) {
      if (ListB != null) {
        this.CopyMove(ListA);
        this.MergeMove(ListB);
      } else this.MergeMove(ListA);
    };
    this.DoXOr = function (ListA, ListB) {
      var r = 0;
      var l = null;
      if (ListB != null) {
        this.Clear();
        for (var $l = 0, $end = ListA.GetCount() - 1; $l <= $end; $l++) {
          r = $l;
          if (ListB.IndexOf(ListA.Get(r)) < 0) this.Add(ListA.Get(r));
        };
        for (var $l1 = 0, $end1 = ListB.GetCount() - 1; $l1 <= $end1; $l1++) {
          r = $l1;
          if (ListA.IndexOf(ListB.Get(r)) < 0) this.Add(ListB.Get(r));
        };
      } else try {
        l = $mod.TList.$create("Create$1");
        l.CopyMove(this);
        for (var $l2 = this.GetCount() - 1; $l2 >= 0; $l2--) {
          r = $l2;
          if (ListA.IndexOf(this.Get(r)) >= 0) this.Delete(r);
        };
        for (var $l3 = 0, $end2 = ListA.GetCount() - 1; $l3 <= $end2; $l3++) {
          r = $l3;
          if (l.IndexOf(ListA.Get(r)) < 0) this.Add(ListA.Get(r));
        };
      } finally {
        l.$destroy("Destroy");
      };
    };
    this.Get = function (Index) {
      var Result = undefined;
      Result = this.FList.Get(Index);
      return Result;
    };
    this.Put = function (Index, Item) {
      var V = undefined;
      V = this.Get(Index);
      this.FList.Put(Index,Item);
      if (pas.System.Assigned(V)) this.Notify(V,$mod.TListNotification.lnDeleted);
      if (pas.System.Assigned(Item)) this.Notify(Item,$mod.TListNotification.lnAdded);
    };
    this.Notify = function (aValue, Action) {
      if (pas.System.Assigned(aValue)) ;
      if (Action === $mod.TListNotification.lnExtracted) ;
    };
    this.SetCapacity = function (NewCapacity) {
      this.FList.SetCapacity(NewCapacity);
    };
    this.GetCapacity = function () {
      var Result = 0;
      Result = this.FList.FCapacity;
      return Result;
    };
    this.SetCount = function (NewCount) {
      if (NewCount < this.FList.FCount) {
        while (this.FList.FCount > NewCount) this.Delete(this.FList.FCount - 1)}
       else this.FList.SetCount(NewCount);
    };
    this.GetCount = function () {
      var Result = 0;
      Result = this.FList.FCount;
      return Result;
    };
    this.GetList = function () {
      var Result = [];
      Result = this.FList.FList;
      return Result;
    };
    this.Create$1 = function () {
      pas.System.TObject.Create.call(this);
      this.FList = $mod.TFPList.$create("Create");
      return this;
    };
    this.Destroy = function () {
      if (this.FList != null) this.Clear();
      pas.SysUtils.FreeAndNil({p: this, get: function () {
          return this.p.FList;
        }, set: function (v) {
          this.p.FList = v;
        }});
    };
    this.AddList = function (AList) {
      var I = 0;
      this.FList.AddList(AList.FList);
      for (var $l = 0, $end = AList.GetCount() - 1; $l <= $end; $l++) {
        I = $l;
        if (pas.System.Assigned(AList.Get(I))) this.Notify(AList.Get(I),$mod.TListNotification.lnAdded);
      };
    };
    this.Add = function (Item) {
      var Result = 0;
      Result = this.FList.Add(Item);
      if (pas.System.Assigned(Item)) this.Notify(Item,$mod.TListNotification.lnAdded);
      return Result;
    };
    this.Clear = function () {
      while (this.FList.FCount > 0) this.Delete(this.GetCount() - 1);
    };
    this.Delete = function (Index) {
      var V = undefined;
      V = this.FList.Get(Index);
      this.FList.Delete(Index);
      if (pas.System.Assigned(V)) this.Notify(V,$mod.TListNotification.lnDeleted);
    };
    this.Error = function (Msg, Data) {
      throw $mod.EListError.$create("CreateFmt",[Msg,pas.System.VarRecs(18,Data)]);
    };
    this.Exchange = function (Index1, Index2) {
      this.FList.Exchange(Index1,Index2);
    };
    this.Expand = function () {
      var Result = null;
      this.FList.Expand();
      Result = this;
      return Result;
    };
    this.Extract = function (Item) {
      var Result = undefined;
      var c = 0;
      c = this.FList.FCount;
      Result = this.FList.Extract(Item);
      if (c !== this.FList.FCount) this.Notify(Result,$mod.TListNotification.lnExtracted);
      return Result;
    };
    this.First = function () {
      var Result = undefined;
      Result = this.FList.First();
      return Result;
    };
    this.GetEnumerator = function () {
      var Result = null;
      Result = $mod.TListEnumerator.$create("Create$1",[this]);
      return Result;
    };
    this.IndexOf = function (Item) {
      var Result = 0;
      Result = this.FList.IndexOf(Item);
      return Result;
    };
    this.Insert = function (Index, Item) {
      this.FList.Insert(Index,Item);
      if (pas.System.Assigned(Item)) this.Notify(Item,$mod.TListNotification.lnAdded);
    };
    this.Last = function () {
      var Result = undefined;
      Result = this.FList.Last();
      return Result;
    };
    this.Move = function (CurIndex, NewIndex) {
      this.FList.Move(CurIndex,NewIndex);
    };
    this.Assign = function (ListA, AOperator, ListB) {
      var $tmp = AOperator;
      if ($tmp === $mod.TListAssignOp.laCopy) {
        this.DoCopy(ListA,ListB)}
       else if ($tmp === $mod.TListAssignOp.laSrcUnique) {
        this.DoSrcUnique(ListA,ListB)}
       else if ($tmp === $mod.TListAssignOp.laAnd) {
        this.DoAnd(ListA,ListB)}
       else if ($tmp === $mod.TListAssignOp.laDestUnique) {
        this.DoDestUnique(ListA,ListB)}
       else if ($tmp === $mod.TListAssignOp.laOr) {
        this.DoOr(ListA,ListB)}
       else if ($tmp === $mod.TListAssignOp.laXor) this.DoXOr(ListA,ListB);
    };
    this.Remove = function (Item) {
      var Result = 0;
      Result = this.IndexOf(Item);
      if (Result !== -1) this.Delete(Result);
      return Result;
    };
    this.Pack = function () {
      this.FList.Pack();
    };
    this.Sort = function (Compare) {
      this.FList.Sort(Compare);
    };
    this.SortList = function (Compare) {
      this.FList.SortList(Compare);
    };
  });
  rtl.createClass(this,"TPersistent",pas.System.TObject,function () {
    this.AssignError = function (Source) {
      var SourceName = "";
      if (Source !== null) {
        SourceName = Source.$classname}
       else SourceName = "Nil";
      throw pas.SysUtils.EConvertError.$create("Create$1",["Cannot assign a " + SourceName + " to a " + this.$classname + "."]);
    };
    this.DefineProperties = function (Filer) {
      if (Filer === null) return;
    };
    this.AssignTo = function (Dest) {
      Dest.AssignError(this);
    };
    this.GetOwner = function () {
      var Result = null;
      Result = null;
      return Result;
    };
    this.Assign = function (Source) {
      if (Source !== null) {
        Source.AssignTo(this)}
       else this.AssignError(null);
    };
    this.GetNamePath = function () {
      var Result = "";
      var OwnerName = "";
      var TheOwner = null;
      Result = this.$classname;
      TheOwner = this.GetOwner();
      if (TheOwner !== null) {
        OwnerName = TheOwner.GetNamePath();
        if (OwnerName !== "") Result = OwnerName + "." + Result;
      };
      return Result;
    };
    this.SetEvent = function (ALookupRoot, APropName, AMethodName) {
      this.SetEvent$1(this,ALookupRoot,APropName,AMethodName);
    };
    this.SetEvent$1 = function (AInstance, ALookupRoot, APropName, AMethodName) {
      var lMethod = pas.System.TMethod.$new();
      lMethod.Code = ALookupRoot.$class.MethodAddress(AMethodName);
      if (lMethod.Code != null) {
        lMethod.Data = ALookupRoot;
        pas.TypInfo.SetMethodProp$1(AInstance,APropName,lMethod);
      };
    };
  });
  this.$rtti.$ClassRef("TPersistentClass",{instancetype: this.$rtti["TPersistent"]});
  rtl.createClass(this,"TInterfacedPersistent",this.TPersistent,function () {
    this.$init = function () {
      $mod.TPersistent.$init.call(this);
      this.FOwnerInterface = null;
    };
    this.$final = function () {
      rtl.setIntfP(this,"FOwnerInterface",null);
      $mod.TPersistent.$final.call(this);
    };
    this._AddRef = function () {
      var Result = 0;
      Result = -1;
      if (this.FOwnerInterface != null) Result = this.FOwnerInterface._AddRef();
      return Result;
    };
    this._Release = function () {
      var Result = 0;
      Result = -1;
      if (this.FOwnerInterface != null) Result = this.FOwnerInterface._Release();
      return Result;
    };
    this.QueryInterface = function (IID, Obj) {
      var Result = 0;
      Result = -2147467262;
      if (this.GetInterface(IID,Obj)) Result = 0;
      return Result;
    };
    this.AfterConstruction = function () {
      try {
        pas.System.TObject.AfterConstruction.call(this);
        if (this.GetOwner() !== null) this.GetOwner().GetInterface(rtl.getIntfGUIDR(pas.System.IUnknown),{p: this, get: function () {
            return this.p.FOwnerInterface;
          }, set: function (v) {
            this.p.FOwnerInterface = v;
          }});
      } finally {
        rtl._Release(this.FOwnerInterface);
      };
    };
    rtl.addIntf(this,pas.System.IUnknown);
  });
  this.$rtti.$Class("TStrings");
  rtl.createClass(this,"TStringsEnumerator",pas.System.TObject,function () {
    this.$init = function () {
      pas.System.TObject.$init.call(this);
      this.FStrings = null;
      this.FPosition = 0;
    };
    this.$final = function () {
      this.FStrings = undefined;
      pas.System.TObject.$final.call(this);
    };
    this.Create$1 = function (AStrings) {
      pas.System.TObject.Create.call(this);
      this.FStrings = AStrings;
      this.FPosition = -1;
      return this;
    };
    this.GetCurrent = function () {
      var Result = "";
      Result = this.FStrings.Get(this.FPosition);
      return Result;
    };
    this.MoveNext = function () {
      var Result = false;
      this.FPosition += 1;
      Result = this.FPosition < this.FStrings.GetCount();
      return Result;
    };
    var $r = this.$rtti;
    $r.addMethod("Create$1",2,[["AStrings",$mod.$rtti["TStrings"]]]);
  });
  rtl.createClass(this,"TStrings",this.TPersistent,function () {
    this.$init = function () {
      $mod.TPersistent.$init.call(this);
      this.FSpecialCharsInited = false;
      this.FAlwaysQuote = false;
      this.FQuoteChar = "\x00";
      this.FDelimiter = "\x00";
      this.FNameValueSeparator = "\x00";
      this.FUpdateCount = 0;
      this.FLBS = 0;
      this.FSkipLastLineBreak = false;
      this.FStrictDelimiter = false;
      this.FLineBreak = "";
    };
    this.GetCommaText = function () {
      var Result = "";
      var C1 = "\x00";
      var C2 = "\x00";
      var FSD = false;
      this.CheckSpecialChars();
      FSD = this.FStrictDelimiter;
      C1 = this.GetDelimiter();
      C2 = this.GetQuoteChar();
      this.SetDelimiter(",");
      this.SetQuoteChar('"');
      this.FStrictDelimiter = false;
      try {
        Result = this.GetDelimitedText();
      } finally {
        this.SetDelimiter(C1);
        this.SetQuoteChar(C2);
        this.FStrictDelimiter = FSD;
      };
      return Result;
    };
    this.GetName = function (Index) {
      var Result = "";
      var V = "";
      this.GetNameValue(Index,{get: function () {
          return Result;
        }, set: function (v) {
          Result = v;
        }},{get: function () {
          return V;
        }, set: function (v) {
          V = v;
        }});
      return Result;
    };
    this.GetValue = function (Name) {
      var Result = "";
      var L = 0;
      var N = "";
      Result = "";
      L = this.IndexOfName(Name);
      if (L !== -1) this.GetNameValue(L,{get: function () {
          return N;
        }, set: function (v) {
          N = v;
        }},{get: function () {
          return Result;
        }, set: function (v) {
          Result = v;
        }});
      return Result;
    };
    this.GetLBS = function () {
      var Result = 0;
      this.CheckSpecialChars();
      Result = this.FLBS;
      return Result;
    };
    this.SetLBS = function (AValue) {
      this.CheckSpecialChars();
      this.FLBS = AValue;
    };
    this.SetCommaText = function (Value) {
      var C1 = "\x00";
      var C2 = "\x00";
      this.CheckSpecialChars();
      C1 = this.GetDelimiter();
      C2 = this.GetQuoteChar();
      this.SetDelimiter(",");
      this.SetQuoteChar('"');
      try {
        this.SetDelimitedText(Value);
      } finally {
        this.SetDelimiter(C1);
        this.SetQuoteChar(C2);
      };
    };
    this.SetValue = function (Name, Value) {
      var L = 0;
      this.CheckSpecialChars();
      L = this.IndexOfName(Name);
      if (L === -1) {
        this.Add(Name + this.FNameValueSeparator + Value)}
       else this.Put(L,Name + this.FNameValueSeparator + Value);
    };
    this.SetDelimiter = function (c) {
      this.CheckSpecialChars();
      this.FDelimiter = c;
    };
    this.SetQuoteChar = function (c) {
      this.CheckSpecialChars();
      this.FQuoteChar = c;
    };
    this.SetNameValueSeparator = function (c) {
      this.CheckSpecialChars();
      this.FNameValueSeparator = c;
    };
    this.DoSetTextStr = function (Value, DoClear) {
      var S = "";
      var P = 0;
      try {
        this.BeginUpdate();
        if (DoClear) this.Clear();
        P = 1;
        while (this.GetNextLinebreak(Value,{get: function () {
            return S;
          }, set: function (v) {
            S = v;
          }},{get: function () {
            return P;
          }, set: function (v) {
            P = v;
          }})) this.Add(S);
      } finally {
        this.EndUpdate();
      };
    };
    this.GetDelimiter = function () {
      var Result = "\x00";
      this.CheckSpecialChars();
      Result = this.FDelimiter;
      return Result;
    };
    this.GetNameValueSeparator = function () {
      var Result = "\x00";
      this.CheckSpecialChars();
      Result = this.FNameValueSeparator;
      return Result;
    };
    this.GetQuoteChar = function () {
      var Result = "\x00";
      this.CheckSpecialChars();
      Result = this.FQuoteChar;
      return Result;
    };
    this.GetLineBreak = function () {
      var Result = "";
      this.CheckSpecialChars();
      Result = this.FLineBreak;
      return Result;
    };
    this.SetLineBreak = function (S) {
      this.CheckSpecialChars();
      this.FLineBreak = S;
    };
    this.GetSkipLastLineBreak = function () {
      var Result = false;
      this.CheckSpecialChars();
      Result = this.FSkipLastLineBreak;
      return Result;
    };
    this.SetSkipLastLineBreak = function (AValue) {
      this.CheckSpecialChars();
      this.FSkipLastLineBreak = AValue;
    };
    this.ReadData = function (Reader) {
      Reader.ReadListBegin();
      this.BeginUpdate();
      try {
        this.Clear();
        while (!Reader.EndOfList()) this.Add(Reader.ReadString());
      } finally {
        this.EndUpdate();
      };
      Reader.ReadListEnd();
    };
    this.WriteData = function (Writer) {
      var i = 0;
      Writer.WriteListBegin();
      for (var $l = 0, $end = this.GetCount() - 1; $l <= $end; $l++) {
        i = $l;
        Writer.WriteString(this.Get(i));
      };
      Writer.WriteListEnd();
    };
    this.DefineProperties = function (Filer) {
      var HasData = false;
      if (Filer.FAncestor != null) {
        if (Filer.FAncestor.$class.InheritsFrom($mod.TStrings)) {
          HasData = !this.Equals$2(Filer.FAncestor)}
         else HasData = true}
       else HasData = this.GetCount() > 0;
      Filer.DefineProperty("Strings",rtl.createCallback(this,"ReadData"),rtl.createCallback(this,"WriteData"),HasData);
    };
    this.Error = function (Msg, Data) {
      throw $mod.EStringListError.$create("CreateFmt",[Msg,pas.System.VarRecs(18,pas.SysUtils.IntToStr(Data))]);
    };
    this.GetCapacity = function () {
      var Result = 0;
      Result = this.GetCount();
      return Result;
    };
    this.GetObject = function (Index) {
      var Result = null;
      if (Index === 0) ;
      Result = null;
      return Result;
    };
    this.GetTextStr = function () {
      var Result = "";
      var I = 0;
      var S = "";
      var NL = "";
      this.CheckSpecialChars();
      if (this.FLineBreak !== pas.System.sLineBreak) {
        NL = this.FLineBreak}
       else {
        var $tmp = this.FLBS;
        if ($tmp === pas.System.TTextLineBreakStyle.tlbsLF) {
          NL = "\n"}
         else if ($tmp === pas.System.TTextLineBreakStyle.tlbsCRLF) {
          NL = "\r\n"}
         else if ($tmp === pas.System.TTextLineBreakStyle.tlbsCR) NL = "\r";
      };
      Result = "";
      for (var $l = 0, $end = this.GetCount() - 1; $l <= $end; $l++) {
        I = $l;
        S = this.Get(I);
        Result = Result + S;
        if ((I < (this.GetCount() - 1)) || !this.GetSkipLastLineBreak()) Result = Result + NL;
      };
      return Result;
    };
    this.Put = function (Index, S) {
      var Obj = null;
      Obj = this.GetObject(Index);
      this.Delete(Index);
      this.InsertObject(Index,S,Obj);
    };
    this.PutObject = function (Index, AObject) {
      if (Index === 0) return;
      if (AObject === null) return;
    };
    this.SetCapacity = function (NewCapacity) {
      if (NewCapacity === 0) ;
    };
    this.SetTextStr = function (Value) {
      this.CheckSpecialChars();
      this.DoSetTextStr(Value,true);
    };
    this.SetUpdateState = function (Updating) {
      if (Updating) ;
    };
    this.DoCompareText = function (s1, s2) {
      var Result = 0;
      Result = pas.SysUtils.CompareText(s1,s2);
      return Result;
    };
    this.GetDelimitedText = function () {
      var Result = "";
      var I = 0;
      var RE = "";
      var S = "";
      var doQuote = false;
      this.CheckSpecialChars();
      Result = "";
      RE = this.GetQuoteChar() + "|" + this.GetDelimiter();
      if (!this.FStrictDelimiter) RE = " |" + RE;
      RE = "/" + RE + "/";
      for (var $l = 0, $end = this.GetCount() - 1; $l <= $end; $l++) {
        I = $l;
        S = this.Get(I);
        doQuote = this.FAlwaysQuote || (S.search(RE) !== -1);
        if (doQuote) {
          Result = Result + pas.SysUtils.QuoteString(S,this.GetQuoteChar())}
         else Result = Result + S;
        if (I < (this.GetCount() - 1)) Result = Result + this.GetDelimiter();
      };
      if ((Result.length === 0) && (this.GetCount() === 1)) Result = this.GetQuoteChar() + this.GetQuoteChar();
      return Result;
    };
    this.SetDelimitedText = function (AValue) {
      var i = 0;
      var j = 0;
      var aNotFirst = false;
      this.CheckSpecialChars();
      this.BeginUpdate();
      i = 1;
      j = 1;
      aNotFirst = false;
      try {
        this.Clear();
        if (this.FStrictDelimiter) {
          while (i <= AValue.length) {
            if (aNotFirst && (i <= AValue.length) && (AValue.charAt(i - 1) === this.FDelimiter)) i += 1;
            if (i <= AValue.length) {
              if (AValue.charAt(i - 1) === this.FQuoteChar) {
                j = i + 1;
                while ((j <= AValue.length) && ((AValue.charAt(j - 1) !== this.FQuoteChar) || (((j + 1) <= AValue.length) && (AValue.charAt((j + 1) - 1) === this.FQuoteChar)))) {
                  if ((j <= AValue.length) && (AValue.charAt(j - 1) === this.FQuoteChar)) {
                    j += 2}
                   else j += 1;
                };
                this.Add(pas.SysUtils.StringReplace(pas.System.Copy(AValue,i + 1,j - i - 1),this.FQuoteChar + this.FQuoteChar,this.FQuoteChar,rtl.createSet(pas.SysUtils.TStringReplaceFlag.rfReplaceAll)));
                i = j + 1;
              } else {
                j = i;
                while ((j <= AValue.length) && (AValue.charAt(j - 1) !== this.FDelimiter)) j += 1;
                this.Add(pas.System.Copy(AValue,i,j - i));
                i = j;
              };
            } else {
              if (aNotFirst) this.Add("");
            };
            aNotFirst = true;
          };
        } else {
          while (i <= AValue.length) {
            if (aNotFirst && (i <= AValue.length) && (AValue.charAt(i - 1) === this.FDelimiter)) i += 1;
            while ((i <= AValue.length) && (AValue.charCodeAt(i - 1) <= 32)) i += 1;
            if (i <= AValue.length) {
              if (AValue.charAt(i - 1) === this.FQuoteChar) {
                j = i + 1;
                while ((j <= AValue.length) && ((AValue.charAt(j - 1) !== this.FQuoteChar) || (((j + 1) <= AValue.length) && (AValue.charAt((j + 1) - 1) === this.FQuoteChar)))) {
                  if ((j <= AValue.length) && (AValue.charAt(j - 1) === this.FQuoteChar)) {
                    j += 2}
                   else j += 1;
                };
                this.Add(pas.SysUtils.StringReplace(pas.System.Copy(AValue,i + 1,j - i - 1),this.FQuoteChar + this.FQuoteChar,this.FQuoteChar,rtl.createSet(pas.SysUtils.TStringReplaceFlag.rfReplaceAll)));
                i = j + 1;
              } else {
                j = i;
                while ((j <= AValue.length) && (AValue.charCodeAt(j - 1) > 32) && (AValue.charAt(j - 1) !== this.FDelimiter)) j += 1;
                this.Add(pas.System.Copy(AValue,i,j - i));
                i = j;
              };
            } else {
              if (aNotFirst) this.Add("");
            };
            while ((i <= AValue.length) && (AValue.charCodeAt(i - 1) <= 32)) i += 1;
            aNotFirst = true;
          };
        };
      } finally {
        this.EndUpdate();
      };
    };
    this.GetValueFromIndex = function (Index) {
      var Result = "";
      var N = "";
      this.GetNameValue(Index,{get: function () {
          return N;
        }, set: function (v) {
          N = v;
        }},{get: function () {
          return Result;
        }, set: function (v) {
          Result = v;
        }});
      return Result;
    };
    this.SetValueFromIndex = function (Index, Value) {
      if (Value === "") {
        this.Delete(Index)}
       else {
        if (Index < 0) Index = this.Add("");
        this.CheckSpecialChars();
        this.Put(Index,this.GetName(Index) + this.FNameValueSeparator + Value);
      };
    };
    this.CheckSpecialChars = function () {
      if (!this.FSpecialCharsInited) {
        this.FQuoteChar = '"';
        this.FDelimiter = ",";
        this.FNameValueSeparator = "=";
        this.FLBS = pas.System.DefaultTextLineBreakStyle;
        this.FSpecialCharsInited = true;
        this.FLineBreak = pas.System.sLineBreak;
      };
    };
    this.GetNextLinebreak = function (Value, S, P) {
      var Result = false;
      var PPLF = 0;
      var PPCR = 0;
      var PP = 0;
      var PL = 0;
      S.set("");
      Result = false;
      if ((Value.length - P.get()) < 0) return Result;
      PPLF = Value.indexOf("\n",P.get() - 1) + 1;
      PPCR = Value.indexOf("\r",P.get() - 1) + 1;
      PL = 1;
      if ((PPLF > 0) && (PPCR > 0)) {
        if ((PPLF - PPCR) === 1) PL = 2;
        if (PPLF < PPCR) {
          PP = PPLF}
         else PP = PPCR;
      } else if ((PPLF > 0) && (PPCR < 1)) {
        PP = PPLF}
       else if ((PPCR > 0) && (PPLF < 1)) {
        PP = PPCR}
       else PP = Value.length + 1;
      S.set(pas.System.Copy(Value,P.get(),PP - P.get()));
      P.set(PP + PL);
      Result = true;
      return Result;
    };
    this.Create$1 = function () {
      pas.System.TObject.Create.call(this);
      this.FAlwaysQuote = false;
      return this;
    };
    this.Destroy = function () {
      pas.System.TObject.Destroy.call(this);
    };
    this.ToObjectArray = function () {
      var Result = [];
      Result = this.ToObjectArray$1(0,this.GetCount() - 1);
      return Result;
    };
    this.ToObjectArray$1 = function (aStart, aEnd) {
      var Result = [];
      var I = 0;
      Result = [];
      if (aStart > aEnd) return Result;
      Result = rtl.arraySetLength(Result,null,(aEnd - aStart) + 1);
      for (var $l = aStart, $end = aEnd; $l <= $end; $l++) {
        I = $l;
        Result[I - aStart] = this.GetObject(I);
      };
      return Result;
    };
    this.ToStringArray = function () {
      var Result = [];
      Result = this.ToStringArray$1(0,this.GetCount() - 1);
      return Result;
    };
    this.ToStringArray$1 = function (aStart, aEnd) {
      var Result = [];
      var I = 0;
      Result = [];
      if (aStart > aEnd) return Result;
      Result = rtl.arraySetLength(Result,"",(aEnd - aStart) + 1);
      for (var $l = aStart, $end = aEnd; $l <= $end; $l++) {
        I = $l;
        Result[I - aStart] = this.Get(I);
      };
      return Result;
    };
    this.Add = function (S) {
      var Result = 0;
      Result = this.GetCount();
      this.Insert(this.GetCount(),S);
      return Result;
    };
    this.Add$1 = function (Fmt, Args) {
      var Result = 0;
      Result = this.Add(pas.SysUtils.Format(Fmt,Args));
      return Result;
    };
    this.AddFmt = function (Fmt, Args) {
      var Result = 0;
      Result = this.Add(pas.SysUtils.Format(Fmt,Args));
      return Result;
    };
    this.AddObject = function (S, AObject) {
      var Result = 0;
      Result = this.Add(S);
      this.PutObject(Result,AObject);
      return Result;
    };
    this.AddObject$1 = function (Fmt, Args, AObject) {
      var Result = 0;
      Result = this.AddObject(pas.SysUtils.Format(Fmt,Args),AObject);
      return Result;
    };
    this.Append = function (S) {
      this.Add(S);
    };
    this.AddStrings = function (TheStrings) {
      var Runner = 0;
      for (var $l = 0, $end = TheStrings.GetCount() - 1; $l <= $end; $l++) {
        Runner = $l;
        this.AddObject(TheStrings.Get(Runner),TheStrings.GetObject(Runner));
      };
    };
    this.AddStrings$1 = function (TheStrings, ClearFirst) {
      this.BeginUpdate();
      try {
        if (ClearFirst) this.Clear();
        this.AddStrings(TheStrings);
      } finally {
        this.EndUpdate();
      };
    };
    this.AddStrings$2 = function (TheStrings) {
      var Runner = 0;
      if ((this.GetCount() + (rtl.length(TheStrings) - 1) + 1) > this.GetCapacity()) this.SetCapacity(this.GetCount() + (rtl.length(TheStrings) - 1) + 1);
      for (var $l = 0, $end = rtl.length(TheStrings) - 1; $l <= $end; $l++) {
        Runner = $l;
        this.Add(TheStrings[Runner]);
      };
    };
    this.AddStrings$3 = function (TheStrings, ClearFirst) {
      this.BeginUpdate();
      try {
        if (ClearFirst) this.Clear();
        this.AddStrings$2(TheStrings);
      } finally {
        this.EndUpdate();
      };
    };
    this.AddPair = function (AName, AValue) {
      var Result = null;
      Result = this.AddPair$1(AName,AValue,null);
      return Result;
    };
    this.AddPair$1 = function (AName, AValue, AObject) {
      var Result = null;
      Result = this;
      this.AddObject(AName + this.GetNameValueSeparator() + AValue,AObject);
      return Result;
    };
    this.AddText = function (S) {
      this.CheckSpecialChars();
      this.DoSetTextStr(S,false);
    };
    this.Assign = function (Source) {
      var S = null;
      if ($mod.TStrings.isPrototypeOf(Source)) {
        S = Source;
        this.BeginUpdate();
        try {
          this.Clear();
          this.FSpecialCharsInited = S.FSpecialCharsInited;
          this.FQuoteChar = S.FQuoteChar;
          this.FDelimiter = S.FDelimiter;
          this.FNameValueSeparator = S.FNameValueSeparator;
          this.FLBS = S.FLBS;
          this.FLineBreak = S.FLineBreak;
          this.AddStrings(S);
        } finally {
          this.EndUpdate();
        };
      } else $mod.TPersistent.Assign.call(this,Source);
    };
    this.BeginUpdate = function () {
      if (this.FUpdateCount === 0) this.SetUpdateState(true);
      this.FUpdateCount += 1;
    };
    this.EndUpdate = function () {
      if (this.FUpdateCount > 0) this.FUpdateCount -= 1;
      if (this.FUpdateCount === 0) this.SetUpdateState(false);
    };
    this.Equals = function (Obj) {
      var Result = false;
      if ($mod.TStrings.isPrototypeOf(Obj)) {
        Result = this.Equals$2(Obj)}
       else Result = pas.System.TObject.Equals.call(this,Obj);
      return Result;
    };
    this.Equals$2 = function (TheStrings) {
      var Result = false;
      var Runner = 0;
      var Nr = 0;
      Result = false;
      Nr = this.GetCount();
      if (Nr !== TheStrings.GetCount()) return Result;
      for (var $l = 0, $end = Nr - 1; $l <= $end; $l++) {
        Runner = $l;
        if (this.Get(Runner) !== TheStrings.Get(Runner)) return Result;
      };
      Result = true;
      return Result;
    };
    this.Exchange = function (Index1, Index2) {
      var Obj = null;
      var Str = "";
      this.BeginUpdate();
      try {
        Obj = this.GetObject(Index1);
        Str = this.Get(Index1);
        this.PutObject(Index1,this.GetObject(Index2));
        this.Put(Index1,this.Get(Index2));
        this.PutObject(Index2,Obj);
        this.Put(Index2,Str);
      } finally {
        this.EndUpdate();
      };
    };
    this.GetEnumerator = function () {
      var Result = null;
      Result = $mod.TStringsEnumerator.$create("Create$1",[this]);
      return Result;
    };
    this.IndexOf = function (S) {
      var Result = 0;
      Result = 0;
      while ((Result < this.GetCount()) && (this.DoCompareText(this.Get(Result),S) !== 0)) Result = Result + 1;
      if (Result === this.GetCount()) Result = -1;
      return Result;
    };
    this.IndexOfName = function (Name) {
      var Result = 0;
      var len = 0;
      var S = "";
      this.CheckSpecialChars();
      Result = 0;
      while (Result < this.GetCount()) {
        S = this.Get(Result);
        len = pas.System.Pos(this.FNameValueSeparator,S) - 1;
        if ((len >= 0) && (this.DoCompareText(Name,pas.System.Copy(S,1,len)) === 0)) return Result;
        Result += 1;
      };
      Result = -1;
      return Result;
    };
    this.IndexOfObject = function (AObject) {
      var Result = 0;
      Result = 0;
      while ((Result < this.GetCount()) && (this.GetObject(Result) !== AObject)) Result = Result + 1;
      if (Result === this.GetCount()) Result = -1;
      return Result;
    };
    this.InsertObject = function (Index, S, AObject) {
      this.Insert(Index,S);
      this.PutObject(Index,AObject);
    };
    this.Move = function (CurIndex, NewIndex) {
      var Obj = null;
      var Str = "";
      this.BeginUpdate();
      try {
        Obj = this.GetObject(CurIndex);
        Str = this.Get(CurIndex);
        this.PutObject(CurIndex,null);
        this.Delete(CurIndex);
        this.InsertObject(NewIndex,Str,Obj);
      } finally {
        this.EndUpdate();
      };
    };
    this.GetNameValue = function (Index, AName, AValue) {
      var L = 0;
      this.CheckSpecialChars();
      AValue.set(this.Get(Index));
      L = pas.System.Pos(this.FNameValueSeparator,AValue.get());
      if (L !== 0) {
        AName.set(pas.System.Copy(AValue.get(),1,L - 1));
        AValue.set(pas.System.Copy(AValue.get(),L + 1,AValue.get().length - L));
      } else AName.set("");
    };
    this.LoadFromURL = function (aURL, Async, OnLoaded, OnError) {
      var $Self = this;
      function DoLoaded(aString) {
        $Self.SetTextStr(aString);
        if (OnLoaded != null) OnLoaded($Self);
      };
      function DoError(AError) {
        if (OnError != null) {
          OnError($Self,AError)}
         else throw pas.SysUtils.EInOutError.$create("Create$1",["Failed to load from URL:" + AError]);
      };
      $impl.CheckLoadHelper();
      $impl.GlobalLoadHelper.LoadText(aURL,Async,DoLoaded,DoError);
    };
    this.LoadFromFile = function (aFileName) {
      var a = [];
      a = $impl.URLToArrayOfString(aFileName);
      this.AddStrings$3(a,true);
    };
    this.LoadFromFile$1 = function (aFileName, OnLoaded, AError) {
      var $Self = this;
      this.LoadFromURL(aFileName,false,function (Sender) {
        if (OnLoaded != null) OnLoaded();
      },function (Sender, ErrorMsg) {
        if (AError != null) AError(ErrorMsg);
      });
    };
    this.LoadFromFileAsync = function (aFileName) {
      var $Self = this;
      var Result = null;
      Result = new Promise(function (ASuccess, AFailed) {
        $impl.ReqAsync(aFileName,function (AResponse) {
          ASuccess(true);
          $Self.SetTextStr(AResponse);
        },function () {
          ASuccess(false);
        });
      });
      return Result;
    };
    this.ExtractName = function (S) {
      var Result = "";
      var L = 0;
      this.CheckSpecialChars();
      L = pas.System.Pos(this.FNameValueSeparator,S);
      if (L !== 0) {
        Result = pas.System.Copy(S,1,L - 1)}
       else Result = "";
      return Result;
    };
    this.SaveToFile = function (FileName) {
      var AText = "";
      AText = this.GetTextStr();
      var element = document.createElement('a');
      element.setAttribute('href', 'data:text/plain;charset=utf-8,' + encodeURIComponent(AText));
      if (FileName != ''){
        element.setAttribute('download', FileName);
      }
      element.style.display = 'none';
      document.body.appendChild(element);
      element.click();
      document.body.removeChild(element);
    };
    var $r = this.$rtti;
    $r.addMethod("Create$1",2,[]);
  });
  rtl.recNewT(this,"TStringItem",function () {
    this.FString = "";
    this.FObject = null;
    this.$eq = function (b) {
      return (this.FString === b.FString) && (this.FObject === b.FObject);
    };
    this.$assign = function (s) {
      this.FString = s.FString;
      this.FObject = s.FObject;
      return this;
    };
    var $r = $mod.$rtti.$Record("TStringItem",{});
    $r.addField("FString",rtl.string);
    $r.addField("FObject",pas.System.$rtti["TObject"]);
  });
  this.TStringsOption = {"0": "soStrictDelimiter", soStrictDelimiter: 0, "1": "soWriteBOM", soWriteBOM: 1, "2": "soTrailingLineBreak", soTrailingLineBreak: 2, "3": "soUseLocale", soUseLocale: 3};
  this.$rtti.$Enum("TStringsOption",{minvalue: 0, maxvalue: 3, ordtype: 1, enumtype: this.TStringsOption});
  this.$rtti.$Set("TStringsOptions",{comptype: this.$rtti["TStringsOption"]});
  this.$rtti.$DynArray("TStringItemArray",{eltype: this.$rtti["TStringItem"]});
  this.$rtti.$Class("TStringList");
  this.$rtti.$ProcVar("TStringListSortCompare",{procsig: rtl.newTIProcSig([["List",this.$rtti["TStringList"]],["Index1",rtl.longint],["Index2",rtl.longint]],rtl.longint)});
  this.TStringsSortStyle = {"0": "sslNone", sslNone: 0, "1": "sslUser", sslUser: 1, "2": "sslAuto", sslAuto: 2};
  this.$rtti.$Enum("TStringsSortStyle",{minvalue: 0, maxvalue: 2, ordtype: 1, enumtype: this.TStringsSortStyle});
  this.$rtti.$Set("TStringsSortStyles",{comptype: this.$rtti["TStringsSortStyle"]});
  rtl.createClass(this,"TStringList",this.TStrings,function () {
    this.$init = function () {
      $mod.TStrings.$init.call(this);
      this.FList = [];
      this.FCount = 0;
      this.FOnChange = null;
      this.FOnChanging = null;
      this.FDuplicates = 0;
      this.FCaseSensitive = false;
      this.FForceSort = false;
      this.FOwnsObjects = false;
      this.FSortStyle = 0;
    };
    this.$final = function () {
      this.FList = undefined;
      this.FOnChange = undefined;
      this.FOnChanging = undefined;
      $mod.TStrings.$final.call(this);
    };
    this.ExchangeItemsInt = function (Index1, Index2) {
      var S = "";
      var O = null;
      S = this.FList[Index1].FString;
      O = this.FList[Index1].FObject;
      this.FList[Index1].FString = this.FList[Index2].FString;
      this.FList[Index1].FObject = this.FList[Index2].FObject;
      this.FList[Index2].FString = S;
      this.FList[Index2].FObject = O;
    };
    this.GetSorted = function () {
      var Result = false;
      Result = this.FSortStyle in rtl.createSet($mod.TStringsSortStyle.sslUser,$mod.TStringsSortStyle.sslAuto);
      return Result;
    };
    this.Grow = function () {
      var NC = 0;
      NC = this.GetCapacity();
      if (NC >= 256) {
        NC = NC + rtl.trunc(NC / 4)}
       else if (NC === 0) {
        NC = 4}
       else NC = NC * 4;
      this.SetCapacity(NC);
    };
    this.InternalClear = function (FromIndex, ClearOnly) {
      var I = 0;
      if (FromIndex < this.FCount) {
        if (this.FOwnsObjects) {
          for (var $l = FromIndex, $end = this.FCount - 1; $l <= $end; $l++) {
            I = $l;
            this.FList[I].FString = "";
            pas.SysUtils.FreeAndNil({p: this.FList[I], get: function () {
                return this.p.FObject;
              }, set: function (v) {
                this.p.FObject = v;
              }});
          };
        } else {
          for (var $l1 = FromIndex, $end1 = this.FCount - 1; $l1 <= $end1; $l1++) {
            I = $l1;
            this.FList[I].FString = "";
          };
        };
        this.FCount = FromIndex;
      };
      if (!ClearOnly) this.SetCapacity(0);
    };
    this.QuickSort = function (L, R, CompareFn) {
      var Pivot = 0;
      var vL = 0;
      var vR = 0;
      if ((R - L) <= 1) {
        if (L < R) if (CompareFn(this,L,R) > 0) this.ExchangeItems(L,R);
        return;
      };
      vL = L;
      vR = R;
      Pivot = L + pas.System.Random(R - L);
      while (vL < vR) {
        while ((vL < Pivot) && (CompareFn(this,vL,Pivot) <= 0)) vL += 1;
        while ((vR > Pivot) && (CompareFn(this,vR,Pivot) > 0)) vR -= 1;
        this.ExchangeItems(vL,vR);
        if (Pivot === vL) {
          Pivot = vR}
         else if (Pivot === vR) Pivot = vL;
      };
      if ((Pivot - 1) >= L) this.QuickSort(L,Pivot - 1,CompareFn);
      if ((Pivot + 1) <= R) this.QuickSort(Pivot + 1,R,CompareFn);
    };
    this.SetSorted = function (Value) {
      if (Value) {
        this.SetSortStyle($mod.TStringsSortStyle.sslAuto)}
       else this.SetSortStyle($mod.TStringsSortStyle.sslNone);
    };
    this.SetCaseSensitive = function (b) {
      if (b === this.FCaseSensitive) return;
      this.FCaseSensitive = b;
      if (this.FSortStyle === $mod.TStringsSortStyle.sslAuto) {
        this.FForceSort = true;
        try {
          this.Sort();
        } finally {
          this.FForceSort = false;
        };
      };
    };
    this.SetSortStyle = function (AValue) {
      if (this.FSortStyle === AValue) return;
      if (AValue === $mod.TStringsSortStyle.sslAuto) this.Sort();
      this.FSortStyle = AValue;
    };
    this.GetTrailingLineBreak = function () {
      var Result = false;
      Result = !this.GetSkipLastLineBreak();
      return Result;
    };
    this.SetTrailingLineBreak = function (Value) {
      this.SetSkipLastLineBreak(!Value);
    };
    this.CheckIndex = function (AIndex) {
      if ((AIndex < 0) || (AIndex >= this.FCount)) this.Error(rtl.getResStr(pas.RTLConsts,"SListIndexError"),AIndex);
    };
    this.ExchangeItems = function (Index1, Index2) {
      this.ExchangeItemsInt(Index1,Index2);
    };
    this.Changed = function () {
      if (this.FUpdateCount === 0) {
        if (this.FOnChange != null) this.FOnChange(this);
      };
    };
    this.Changing = function () {
      if (this.FUpdateCount === 0) if (this.FOnChanging != null) this.FOnChanging(this);
    };
    this.Get = function (Index) {
      var Result = "";
      this.CheckIndex(Index);
      Result = this.FList[Index].FString;
      return Result;
    };
    this.GetCapacity = function () {
      var Result = 0;
      Result = rtl.length(this.FList);
      return Result;
    };
    this.GetCount = function () {
      var Result = 0;
      Result = this.FCount;
      return Result;
    };
    this.GetObject = function (Index) {
      var Result = null;
      this.CheckIndex(Index);
      Result = this.FList[Index].FObject;
      return Result;
    };
    this.Put = function (Index, S) {
      if (this.GetSorted()) this.Error(rtl.getResStr(pas.RTLConsts,"SSortedListError"),0);
      this.CheckIndex(Index);
      this.Changing();
      this.FList[Index].FString = S;
      this.Changed();
    };
    this.PutObject = function (Index, AObject) {
      this.CheckIndex(Index);
      this.Changing();
      this.FList[Index].FObject = AObject;
      this.Changed();
    };
    this.SetCapacity = function (NewCapacity) {
      if (NewCapacity < 0) this.Error(rtl.getResStr(pas.RTLConsts,"SListCapacityError"),NewCapacity);
      if (NewCapacity !== this.GetCapacity()) this.FList = rtl.arraySetLength(this.FList,$mod.TStringItem,NewCapacity);
    };
    this.SetUpdateState = function (Updating) {
      if (Updating) {
        this.Changing()}
       else this.Changed();
    };
    this.InsertItem = function (Index, S) {
      this.InsertItem$1(Index,S,null);
    };
    this.InsertItem$1 = function (Index, S, O) {
      var It = $mod.TStringItem.$new();
      this.Changing();
      if (this.FCount === this.GetCapacity()) this.Grow();
      It.FString = S;
      It.FObject = O;
      this.FList.splice(Index,0,It);
      this.FCount += 1;
      this.Changed();
    };
    this.DoCompareText = function (s1, s2) {
      var Result = 0;
      Result = this.CompareStrings(s1,s2);
      return Result;
    };
    this.CompareStrings = function (s1, s2) {
      var Result = 0;
      if (this.FCaseSensitive) {
        Result = pas.SysUtils.CompareStr(s1,s2)}
       else Result = pas.SysUtils.CompareText(s1,s2);
      return Result;
    };
    this.Create$2 = function (AOwnsObjects) {
      $mod.TStrings.Create$1.call(this);
      this.FOwnsObjects = AOwnsObjects;
      return this;
    };
    this.Create$3 = function (AQuoteChar, ADelimiter) {
      $mod.TStrings.Create$1.call(this);
      this.SetQuoteChar(AQuoteChar);
      this.SetDelimiter(ADelimiter);
      return this;
    };
    this.Create$4 = function (AQuoteChar, ADelimiter, AOptions) {
      $mod.TStrings.Create$1.call(this);
      this.SetQuoteChar(AQuoteChar);
      this.SetDelimiter(ADelimiter);
      this.FStrictDelimiter = $mod.TStringsOption.soStrictDelimiter in AOptions;
      return this;
    };
    this.Create$5 = function (ADuplicates, ASorted, ACaseSensitive) {
      $mod.TStrings.Create$1.call(this);
      this.FDuplicates = ADuplicates;
      this.SetSorted(ASorted);
      this.SetCaseSensitive(ACaseSensitive);
      return this;
    };
    this.Destroy = function () {
      this.InternalClear(0,false);
      $mod.TStrings.Destroy.call(this);
    };
    this.Add = function (S) {
      var Result = 0;
      if (!(this.FSortStyle === $mod.TStringsSortStyle.sslAuto)) {
        Result = this.FCount}
       else if (this.Find(S,{get: function () {
          return Result;
        }, set: function (v) {
          Result = v;
        }})) {
        var $tmp = this.FDuplicates;
        if ($tmp === pas.Types.TDuplicates.dupIgnore) {
          return Result}
         else if ($tmp === pas.Types.TDuplicates.dupError) this.Error(rtl.getResStr(pas.RTLConsts,"SDuplicateString"),0);
      };
      this.InsertItem(Result,S);
      return Result;
    };
    this.Clear = function () {
      if (this.FCount === 0) return;
      this.Changing();
      this.InternalClear(0,false);
      this.Changed();
    };
    this.Delete = function (Index) {
      this.CheckIndex(Index);
      this.Changing();
      if (this.FOwnsObjects) pas.SysUtils.FreeAndNil({p: this.FList[Index], get: function () {
          return this.p.FObject;
        }, set: function (v) {
          this.p.FObject = v;
        }});
      this.FList.splice(Index,1);
      this.FList[this.GetCount() - 1].FString = "";
      this.FList[this.GetCount() - 1].FObject = null;
      this.FCount -= 1;
      this.Changed();
    };
    this.Exchange = function (Index1, Index2) {
      this.CheckIndex(Index1);
      this.CheckIndex(Index2);
      this.Changing();
      this.ExchangeItemsInt(Index1,Index2);
      this.Changed();
    };
    this.Find = function (S, Index) {
      var Result = false;
      var L = 0;
      var R = 0;
      var I = 0;
      var CompareRes = 0;
      Result = false;
      Index.set(-1);
      if (!this.GetSorted()) throw $mod.EListError.$create("Create$1",[rtl.getResStr(pas.RTLConsts,"SErrFindNeedsSortedList")]);
      L = 0;
      R = this.GetCount() - 1;
      while (L <= R) {
        I = L + rtl.trunc((R - L) / 2);
        CompareRes = this.DoCompareText(S,this.FList[I].FString);
        if (CompareRes > 0) {
          L = I + 1}
         else {
          R = I - 1;
          if (CompareRes === 0) {
            Result = true;
            if (this.FDuplicates !== pas.Types.TDuplicates.dupAccept) L = I;
          };
        };
      };
      Index.set(L);
      return Result;
    };
    this.IndexOf = function (S) {
      var Result = 0;
      if (!this.GetSorted()) {
        Result = $mod.TStrings.IndexOf.call(this,S)}
       else if (!this.Find(S,{get: function () {
          return Result;
        }, set: function (v) {
          Result = v;
        }})) Result = -1;
      return Result;
    };
    this.Insert = function (Index, S) {
      if (this.FSortStyle === $mod.TStringsSortStyle.sslAuto) {
        this.Error(rtl.getResStr(pas.RTLConsts,"SSortedListError"),0)}
       else {
        if ((Index < 0) || (Index > this.FCount)) this.Error(rtl.getResStr(pas.RTLConsts,"SListIndexError"),Index);
        this.InsertItem(Index,S);
      };
    };
    this.Sort = function () {
      this.CustomSort($impl.StringListAnsiCompare);
    };
    this.CustomSort = function (CompareFn) {
      if ((this.FForceSort || !(this.FSortStyle === $mod.TStringsSortStyle.sslAuto)) && (this.FCount > 1)) {
        this.Changing();
        this.QuickSort(0,this.FCount - 1,CompareFn);
        this.Changed();
      };
    };
    var $r = this.$rtti;
    $r.addMethod("Create$2",2,[["AOwnsObjects",rtl.boolean]]);
    $r.addMethod("Create$3",2,[["AQuoteChar",rtl.char],["ADelimiter",rtl.char]]);
    $r.addMethod("Create$4",2,[["AQuoteChar",rtl.char],["ADelimiter",rtl.char],["AOptions",$mod.$rtti["TStringsOptions"]]]);
    $r.addMethod("Create$5",2,[["ADuplicates",pas.Types.$rtti["TDuplicates"]],["ASorted",rtl.boolean],["ACaseSensitive",rtl.boolean]]);
  });
  this.$rtti.$Class("TCollection");
  rtl.createClass(this,"TCollectionItem",this.TPersistent,function () {
    this.$init = function () {
      $mod.TPersistent.$init.call(this);
      this.FCollection = null;
      this.FID = 0;
      this.FUpdateCount = 0;
    };
    this.$final = function () {
      this.FCollection = undefined;
      $mod.TPersistent.$final.call(this);
    };
    this.GetIndex = function () {
      var Result = 0;
      if (this.FCollection != null) {
        Result = this.FCollection.FItems.IndexOf(this)}
       else Result = -1;
      return Result;
    };
    this.SetCollection = function (Value) {
      if (Value !== this.FCollection) {
        if (this.FCollection != null) this.FCollection.RemoveItem(this);
        if (Value != null) Value.InsertItem(this);
      };
    };
    this.Changed = function (AllItems) {
      if ((this.FCollection !== null) && (this.FCollection.FUpdateCount === 0)) {
        if (AllItems) {
          this.FCollection.Update(null)}
         else this.FCollection.Update(this);
      };
    };
    this.GetOwner = function () {
      var Result = null;
      Result = this.FCollection;
      return Result;
    };
    this.GetDisplayName = function () {
      var Result = "";
      Result = this.$classname;
      return Result;
    };
    this.SetIndex = function (Value) {
      var Temp = 0;
      Temp = this.GetIndex();
      if ((Temp > -1) && (Temp !== Value)) {
        this.FCollection.FItems.Move(Temp,Value);
        this.Changed(true);
      };
    };
    this.SetDisplayName = function (Value) {
      this.Changed(false);
      if (Value === "") ;
    };
    this.Create$1 = function (ACollection) {
      pas.System.TObject.Create.call(this);
      this.SetCollection(ACollection);
      return this;
    };
    this.Destroy = function () {
      this.SetCollection(null);
      pas.System.TObject.Destroy.call(this);
    };
    this.GetNamePath = function () {
      var Result = "";
      if (this.FCollection !== null) {
        Result = this.FCollection.GetNamePath() + "[" + pas.SysUtils.IntToStr(this.GetIndex()) + "]"}
       else Result = this.$classname;
      return Result;
    };
    var $r = this.$rtti;
    $r.addMethod("Create$1",2,[["ACollection",$mod.$rtti["TCollection"]]]);
  });
  rtl.createClass(this,"TCollectionEnumerator",pas.System.TObject,function () {
    this.$init = function () {
      pas.System.TObject.$init.call(this);
      this.FCollection = null;
      this.FPosition = 0;
    };
    this.$final = function () {
      this.FCollection = undefined;
      pas.System.TObject.$final.call(this);
    };
    this.Create$1 = function (ACollection) {
      pas.System.TObject.Create.call(this);
      this.FCollection = ACollection;
      this.FPosition = -1;
      return this;
    };
    this.GetCurrent = function () {
      var Result = null;
      Result = this.FCollection.GetItem(this.FPosition);
      return Result;
    };
    this.MoveNext = function () {
      var Result = false;
      this.FPosition += 1;
      Result = this.FPosition < this.FCollection.GetCount();
      return Result;
    };
    var $r = this.$rtti;
    $r.addMethod("Create$1",2,[["ACollection",$mod.$rtti["TCollection"]]]);
  });
  this.$rtti.$ClassRef("TCollectionItemClass",{instancetype: this.$rtti["TCollectionItem"]});
  this.TCollectionNotification = {"0": "cnAdded", cnAdded: 0, "1": "cnExtracting", cnExtracting: 1, "2": "cnDeleting", cnDeleting: 2};
  this.$rtti.$Enum("TCollectionNotification",{minvalue: 0, maxvalue: 2, ordtype: 1, enumtype: this.TCollectionNotification});
  this.$rtti.$ProcVar("TCollectionSortCompare",{procsig: rtl.newTIProcSig([["Item1",this.$rtti["TCollectionItem"]],["Item2",this.$rtti["TCollectionItem"]]],rtl.longint)});
  this.$rtti.$RefToProcVar("TCollectionSortCompareFunc",{procsig: rtl.newTIProcSig([["Item1",this.$rtti["TCollectionItem"]],["Item2",this.$rtti["TCollectionItem"]]],rtl.longint)});
  rtl.createClass(this,"TCollection",this.TPersistent,function () {
    this.$init = function () {
      $mod.TPersistent.$init.call(this);
      this.FItemClass = null;
      this.FItems = null;
      this.FUpdateCount = 0;
      this.FNextID = 0;
      this.FPropName = "";
    };
    this.$final = function () {
      this.FItemClass = undefined;
      this.FItems = undefined;
      $mod.TPersistent.$final.call(this);
    };
    this.GetCount = function () {
      var Result = 0;
      Result = this.FItems.FCount;
      return Result;
    };
    this.GetPropName = function () {
      var Result = "";
      Result = this.FPropName;
      this.SetPropName();
      Result = this.FPropName;
      return Result;
    };
    this.InsertItem = function (Item) {
      if (!this.FItemClass.isPrototypeOf(Item)) return;
      this.FItems.Add(Item);
      Item.FCollection = this;
      Item.FID = this.FNextID;
      this.FNextID += 1;
      this.SetItemName(Item);
      this.Notify(Item,$mod.TCollectionNotification.cnAdded);
      this.Changed();
    };
    this.RemoveItem = function (Item) {
      var I = 0;
      this.Notify(Item,$mod.TCollectionNotification.cnExtracting);
      I = this.FItems.IndexOfItem(Item,pas.Types.TDirection.FromEnd);
      if (I !== -1) this.FItems.Delete(I);
      Item.FCollection = null;
      this.Changed();
    };
    this.DoClear = function () {
      var Item = null;
      while (this.FItems.FCount > 0) {
        Item = rtl.getObject(this.FItems.Last());
        if (Item != null) Item.$destroy("Destroy");
      };
    };
    this.GetAttrCount = function () {
      var Result = 0;
      Result = 0;
      return Result;
    };
    this.GetAttr = function (Index) {
      var Result = "";
      Result = "";
      if (Index === 0) ;
      return Result;
    };
    this.GetItemAttr = function (Index, ItemIndex) {
      var Result = "";
      Result = rtl.getObject(this.FItems.Get(ItemIndex)).GetDisplayName();
      if (Index === 0) ;
      return Result;
    };
    this.Changed = function () {
      if (this.FUpdateCount === 0) this.Update(null);
    };
    this.GetItem = function (Index) {
      var Result = null;
      Result = rtl.getObject(this.FItems.Get(Index));
      return Result;
    };
    this.SetItem = function (Index, Value) {
      rtl.getObject(this.FItems.Get(Index)).Assign(Value);
    };
    this.SetItemName = function (Item) {
      if (Item === null) ;
    };
    this.SetPropName = function () {
      this.FPropName = "";
    };
    this.Update = function (Item) {
      if (Item === null) ;
    };
    this.Notify = function (Item, Action) {
      if (Item === null) ;
      if (Action === $mod.TCollectionNotification.cnAdded) ;
    };
    this.Create$1 = function (AItemClass) {
      pas.System.TObject.Create.call(this);
      this.FItemClass = AItemClass;
      this.FItems = $mod.TFPList.$create("Create");
      return this;
    };
    this.Destroy = function () {
      this.FUpdateCount = 1;
      try {
        this.DoClear();
      } finally {
        this.FUpdateCount = 0;
      };
      if (this.FItems != null) this.FItems.$destroy("Destroy");
      pas.System.TObject.Destroy.call(this);
    };
    this.Owner = function () {
      var Result = null;
      Result = this.GetOwner();
      return Result;
    };
    this.Add = function () {
      var Result = null;
      Result = this.FItemClass.$create("Create$1",[this]);
      return Result;
    };
    this.Assign = function (Source) {
      var I = 0;
      if ($mod.TCollection.isPrototypeOf(Source)) {
        this.Clear();
        for (var $l = 0, $end = Source.GetCount() - 1; $l <= $end; $l++) {
          I = $l;
          this.Add().Assign(Source.GetItem(I));
        };
        return;
      } else $mod.TPersistent.Assign.call(this,Source);
    };
    this.BeginUpdate = function () {
      this.FUpdateCount += 1;
    };
    this.Clear = function () {
      if (this.FItems.FCount === 0) return;
      this.BeginUpdate();
      try {
        this.DoClear();
      } finally {
        this.EndUpdate();
      };
    };
    this.EndUpdate = function () {
      if (this.FUpdateCount > 0) this.FUpdateCount -= 1;
      if (this.FUpdateCount === 0) this.Changed();
    };
    this.Delete = function (Index) {
      var Item = null;
      Item = rtl.getObject(this.FItems.Get(Index));
      this.Notify(Item,$mod.TCollectionNotification.cnDeleting);
      if (Item != null) Item.$destroy("Destroy");
    };
    this.GetEnumerator = function () {
      var Result = null;
      Result = $mod.TCollectionEnumerator.$create("Create$1",[this]);
      return Result;
    };
    this.GetNamePath = function () {
      var Result = "";
      var o = null;
      o = this.GetOwner();
      if ((o != null) && (this.GetPropName() !== "")) {
        Result = o.GetNamePath() + "." + this.GetPropName()}
       else Result = this.$classname;
      return Result;
    };
    this.Insert = function (Index) {
      var Result = null;
      Result = this.Add();
      Result.SetIndex(Index);
      return Result;
    };
    this.FindItemID = function (ID) {
      var Result = null;
      var I = 0;
      for (var $l = 0, $end = this.FItems.FCount - 1; $l <= $end; $l++) {
        I = $l;
        Result = rtl.getObject(this.FItems.Get(I));
        if (Result.FID === ID) return Result;
      };
      Result = null;
      return Result;
    };
    this.Exchange = function (Index1, index2) {
      this.FItems.Exchange(Index1,index2);
    };
    this.Sort = function (Compare) {
      this.BeginUpdate();
      try {
        this.FItems.Sort(Compare);
      } finally {
        this.EndUpdate();
      };
    };
    this.SortList = function (Compare) {
      this.BeginUpdate();
      try {
        this.FItems.SortList(Compare);
      } finally {
        this.EndUpdate();
      };
    };
    var $r = this.$rtti;
    $r.addMethod("Create$1",2,[["AItemClass",$mod.$rtti["TCollectionItemClass"]]]);
  });
  rtl.createClass(this,"TOwnedCollection",this.TCollection,function () {
    this.$init = function () {
      $mod.TCollection.$init.call(this);
      this.FOwner = null;
    };
    this.$final = function () {
      this.FOwner = undefined;
      $mod.TCollection.$final.call(this);
    };
    this.GetOwner = function () {
      var Result = null;
      Result = this.FOwner;
      return Result;
    };
    this.Create$2 = function (AOwner, AItemClass) {
      this.FOwner = AOwner;
      $mod.TCollection.Create$1.call(this,AItemClass);
      return this;
    };
    var $r = this.$rtti;
    $r.addMethod("Create$2",2,[["AOwner",$mod.$rtti["TPersistent"]],["AItemClass",$mod.$rtti["TCollectionItemClass"]]]);
  });
  this.$rtti.$Class("TComponent");
  this.TOperation = {"0": "opInsert", opInsert: 0, "1": "opRemove", opRemove: 1};
  this.$rtti.$Enum("TOperation",{minvalue: 0, maxvalue: 1, ordtype: 1, enumtype: this.TOperation});
  this.TComponentStateItem = {"0": "csLoading", csLoading: 0, "1": "csReading", csReading: 1, "2": "csWriting", csWriting: 2, "3": "csDestroying", csDestroying: 3, "4": "csDesigning", csDesigning: 4, "5": "csAncestor", csAncestor: 5, "6": "csUpdating", csUpdating: 6, "7": "csFixups", csFixups: 7, "8": "csFreeNotification", csFreeNotification: 8, "9": "csInline", csInline: 9, "10": "csDesignInstance", csDesignInstance: 10};
  this.$rtti.$Enum("TComponentStateItem",{minvalue: 0, maxvalue: 10, ordtype: 1, enumtype: this.TComponentStateItem});
  this.$rtti.$Set("TComponentState",{comptype: this.$rtti["TComponentStateItem"]});
  this.TComponentStyleItem = {"0": "csInheritable", csInheritable: 0, "1": "csCheckPropAvail", csCheckPropAvail: 1, "2": "csSubComponent", csSubComponent: 2, "3": "csTransient", csTransient: 3};
  this.$rtti.$Enum("TComponentStyleItem",{minvalue: 0, maxvalue: 3, ordtype: 1, enumtype: this.TComponentStyleItem});
  this.$rtti.$Set("TComponentStyle",{comptype: this.$rtti["TComponentStyleItem"]});
  this.$rtti.$MethodVar("TGetChildProc",{procsig: rtl.newTIProcSig([["Child",this.$rtti["TComponent"]]]), methodkind: 0});
  this.$rtti.$inherited("TComponentName",rtl.string,{});
  rtl.createClass(this,"TComponentEnumerator",pas.System.TObject,function () {
    this.$init = function () {
      pas.System.TObject.$init.call(this);
      this.FComponent = null;
      this.FPosition = 0;
    };
    this.$final = function () {
      this.FComponent = undefined;
      pas.System.TObject.$final.call(this);
    };
    this.Create$1 = function (AComponent) {
      pas.System.TObject.Create.call(this);
      this.FComponent = AComponent;
      this.FPosition = -1;
      return this;
    };
    this.GetCurrent = function () {
      var Result = null;
      Result = this.FComponent.GetComponent(this.FPosition);
      return Result;
    };
    this.MoveNext = function () {
      var Result = false;
      this.FPosition += 1;
      Result = this.FPosition < this.FComponent.GetComponentCount();
      return Result;
    };
    var $r = this.$rtti;
    $r.addMethod("Create$1",2,[["AComponent",$mod.$rtti["TComponent"]]]);
  });
  rtl.createClass(this,"TComponent",this.TPersistent,function () {
    this.$init = function () {
      $mod.TPersistent.$init.call(this);
      this.FOwner = null;
      this.FName = "";
      this.FTag = 0;
      this.FComponents = null;
      this.FFreeNotifies = null;
      this.FDesignInfo = 0;
      this.FComponentState = {};
      this.FComponentStyle = {};
      this.FLeft = 0;
      this.FTop = 0;
    };
    this.$final = function () {
      this.FOwner = undefined;
      this.FComponents = undefined;
      this.FFreeNotifies = undefined;
      this.FComponentState = undefined;
      this.FComponentStyle = undefined;
      $mod.TPersistent.$final.call(this);
    };
    this.GetComponent = function (AIndex) {
      var Result = null;
      if (!(this.FComponents != null)) {
        Result = null}
       else Result = rtl.getObject(this.FComponents.Get(AIndex));
      return Result;
    };
    this.GetComponentCount = function () {
      var Result = 0;
      if (!(this.FComponents != null)) {
        Result = 0}
       else Result = this.FComponents.FCount;
      return Result;
    };
    this.GetComponentIndex = function () {
      var Result = 0;
      if ((this.FOwner != null) && (this.FOwner.FComponents != null)) {
        Result = this.FOwner.FComponents.IndexOf(this)}
       else Result = -1;
      return Result;
    };
    this.Insert = function (AComponent) {
      if (!(this.FComponents != null)) this.FComponents = $mod.TFPList.$create("Create");
      this.FComponents.Add(AComponent);
      AComponent.FOwner = this;
    };
    this.ReadLeft = function (AReader) {
      this.FDesignInfo = (this.FDesignInfo & 0xffff0000) | (AReader.ReadInteger() & 0xffff);
    };
    this.ReadTop = function (AReader) {
      this.FDesignInfo = ((AReader.ReadInteger() & 0xffff) << 16) | (this.FDesignInfo & 0xffff);
    };
    this.Remove = function (AComponent) {
      AComponent.FOwner = null;
      if (this.FComponents != null) {
        this.FComponents.Remove(AComponent);
        if (this.FComponents.FCount === 0) {
          this.FComponents.$destroy("Destroy");
          this.FComponents = null;
        };
      };
    };
    this.RemoveNotification = function (AComponent) {
      if (this.FFreeNotifies !== null) {
        this.FFreeNotifies.Remove(AComponent);
        if (this.FFreeNotifies.FCount === 0) {
          this.FFreeNotifies.$destroy("Destroy");
          this.FFreeNotifies = null;
          this.FComponentState = rtl.excludeSet(this.FComponentState,$mod.TComponentStateItem.csFreeNotification);
        };
      };
    };
    this.SetComponentIndex = function (Value) {
      var Temp = 0;
      var Count = 0;
      if (!(this.FOwner != null)) return;
      Temp = this.GetComponentIndex();
      if (Temp < 0) return;
      if (Value < 0) Value = 0;
      Count = this.FOwner.FComponents.FCount;
      if (Value >= Count) Value = Count - 1;
      if (Value !== Temp) {
        this.FOwner.FComponents.Delete(Temp);
        this.FOwner.FComponents.Insert(Value,this);
      };
    };
    this.SetReference = function (Enable) {
      var aField = null;
      var aValue = null;
      var aOwner = null;
      if (this.FName === "") return;
      if (this.FOwner != null) {
        aOwner = this.FOwner;
        aField = this.FOwner.$class.FieldAddress(this.FName);
        if (aField != null) {
          if (Enable) {
            aValue = this}
           else aValue = null;
          aOwner["" + aField["name"]] = aValue;
        };
      };
    };
    this.WriteLeft = function (AWriter) {
      AWriter.WriteInteger(this.FDesignInfo & 0xffff);
    };
    this.WriteTop = function (AWriter) {
      AWriter.WriteInteger((this.FDesignInfo >>> 16) & 0xffff);
    };
    this.ChangeName = function (NewName) {
      this.FName = NewName;
    };
    this.DefineProperties = function (Filer) {
      var Temp = 0;
      var Ancestor = null;
      Ancestor = Filer.FAncestor;
      if (Ancestor != null) {
        Temp = Ancestor.FDesignInfo}
       else Temp = 0;
      Filer.DefineProperty("Left",rtl.createCallback(this,"ReadLeft"),rtl.createCallback(this,"WriteLeft"),(this.FDesignInfo & 0xffff) !== (Temp & 0xffff));
      Filer.DefineProperty("Top",rtl.createCallback(this,"ReadTop"),rtl.createCallback(this,"WriteTop"),(this.FDesignInfo & 0xffff0000) !== (Temp & 0xffff0000));
    };
    this.GetChildren = function (Proc, Root) {
      if (Proc === null) ;
      if (Root === null) ;
    };
    this.GetChildOwner = function () {
      var Result = null;
      Result = null;
      return Result;
    };
    this.GetChildParent = function () {
      var Result = null;
      Result = this;
      return Result;
    };
    this.GetOwner = function () {
      var Result = null;
      Result = this.FOwner;
      return Result;
    };
    this.Loaded = function () {
      this.FComponentState = rtl.excludeSet(this.FComponentState,$mod.TComponentStateItem.csLoading);
    };
    this.Loading = function () {
      this.FComponentState = rtl.includeSet(this.FComponentState,$mod.TComponentStateItem.csLoading);
    };
    this.SetWriting = function (Value) {
      if (Value) {
        this.FComponentState = rtl.includeSet(this.FComponentState,$mod.TComponentStateItem.csWriting)}
       else this.FComponentState = rtl.excludeSet(this.FComponentState,$mod.TComponentStateItem.csWriting);
    };
    this.SetReading = function (Value) {
      if (Value) {
        this.FComponentState = rtl.includeSet(this.FComponentState,$mod.TComponentStateItem.csReading)}
       else this.FComponentState = rtl.excludeSet(this.FComponentState,$mod.TComponentStateItem.csReading);
    };
    this.Notification = function (AComponent, Operation) {
      var C = 0;
      if (Operation === $mod.TOperation.opRemove) this.RemoveFreeNotification(AComponent);
      if (!(this.FComponents != null)) return;
      C = this.FComponents.FCount - 1;
      while (C >= 0) {
        rtl.getObject(this.FComponents.Get(C)).Notification(AComponent,Operation);
        C -= 1;
        if (C >= this.FComponents.FCount) C = this.FComponents.FCount - 1;
      };
    };
    this.PaletteCreated = function () {
    };
    this.ReadState = function (Reader) {
      Reader.ReadData(this);
    };
    this.SetAncestor = function (Value) {
      var Runner = 0;
      if (Value) {
        this.FComponentState = rtl.includeSet(this.FComponentState,$mod.TComponentStateItem.csAncestor)}
       else this.FComponentState = rtl.excludeSet(this.FComponentState,$mod.TComponentStateItem.csAncestor);
      if (this.FComponents != null) for (var $l = 0, $end = this.FComponents.FCount - 1; $l <= $end; $l++) {
        Runner = $l;
        rtl.getObject(this.FComponents.Get(Runner)).SetAncestor(Value);
      };
    };
    this.SetDesigning = function (Value, SetChildren) {
      var Runner = 0;
      if (Value) {
        this.FComponentState = rtl.includeSet(this.FComponentState,$mod.TComponentStateItem.csDesigning)}
       else this.FComponentState = rtl.excludeSet(this.FComponentState,$mod.TComponentStateItem.csDesigning);
      if ((this.FComponents != null) && SetChildren) for (var $l = 0, $end = this.FComponents.FCount - 1; $l <= $end; $l++) {
        Runner = $l;
        rtl.getObject(this.FComponents.Get(Runner)).SetDesigning(Value,true);
      };
    };
    this.SetDesignInstance = function (Value) {
      if (Value) {
        this.FComponentState = rtl.includeSet(this.FComponentState,$mod.TComponentStateItem.csDesignInstance)}
       else this.FComponentState = rtl.excludeSet(this.FComponentState,$mod.TComponentStateItem.csDesignInstance);
    };
    this.SetInline = function (Value) {
      if (Value) {
        this.FComponentState = rtl.includeSet(this.FComponentState,$mod.TComponentStateItem.csInline)}
       else this.FComponentState = rtl.excludeSet(this.FComponentState,$mod.TComponentStateItem.csInline);
    };
    this.SetName = function (NewName) {
      if (this.FName === NewName) return;
      if ((NewName !== "") && !pas.SysUtils.IsValidIdent(NewName,false,false)) throw $mod.EComponentError.$create("CreateFmt",[rtl.getResStr(pas.RTLConsts,"SInvalidName"),pas.System.VarRecs(18,NewName)]);
      if (this.FOwner != null) {
        this.FOwner.ValidateRename(this,this.FName,NewName)}
       else this.ValidateRename(null,this.FName,NewName);
      this.SetReference(false);
      this.ChangeName(NewName);
      this.SetReference(true);
    };
    this.SetChildOrder = function (Child, Order) {
      if (Child === null) ;
      if (Order === 0) ;
    };
    this.SetParentComponent = function (Value) {
      if (Value === null) ;
    };
    this.Updating = function () {
      this.FComponentState = rtl.includeSet(this.FComponentState,$mod.TComponentStateItem.csUpdating);
    };
    this.Updated = function () {
      this.FComponentState = rtl.excludeSet(this.FComponentState,$mod.TComponentStateItem.csUpdating);
    };
    this.ValidateRename = function (AComponent, CurName, NewName) {
      if ((AComponent !== null) && (pas.SysUtils.CompareText(CurName,NewName) !== 0) && (AComponent.FOwner === this) && (this.FindComponent(NewName) !== null)) throw $mod.EComponentError.$create("CreateFmt",[rtl.getResStr(pas.RTLConsts,"SDuplicateName"),pas.System.VarRecs(18,NewName)]);
      if (($mod.TComponentStateItem.csDesigning in this.FComponentState) && (this.FOwner !== null)) this.FOwner.ValidateRename(AComponent,CurName,NewName);
    };
    this.ValidateContainer = function (AComponent) {
      AComponent.ValidateInsert(this);
    };
    this.ValidateInsert = function (AComponent) {
      if (AComponent === null) ;
    };
    this._AddRef = function () {
      var Result = 0;
      Result = -1;
      return Result;
    };
    this.GetLeft = function () {
      var Result = 0;
      Result = this.FLeft;
      return Result;
    };
    this.GetTop = function () {
      var Result = 0;
      Result = this.FTop;
      return Result;
    };
    this.SetLeft = function (AValue) {
      this.FLeft = AValue;
    };
    this.SetTop = function (AValue) {
      this.FTop = AValue;
    };
    this._Release = function () {
      var Result = 0;
      Result = -1;
      return Result;
    };
    this.Create$1 = function (AOwner) {
      this.FComponentStyle = rtl.createSet($mod.TComponentStyleItem.csInheritable);
      if (AOwner != null) AOwner.InsertComponent(this);
      return this;
    };
    this.Destroy = function () {
      var I = 0;
      var C = null;
      this.Destroying();
      if (this.FFreeNotifies != null) {
        I = this.FFreeNotifies.FCount - 1;
        while (I >= 0) {
          C = rtl.getObject(this.FFreeNotifies.Get(I));
          this.FFreeNotifies.Delete(I);
          C.Notification(this,$mod.TOperation.opRemove);
          if (this.FFreeNotifies === null) {
            I = 0}
           else if (I > this.FFreeNotifies.FCount) I = this.FFreeNotifies.FCount;
          I -= 1;
        };
        pas.SysUtils.FreeAndNil({p: this, get: function () {
            return this.p.FFreeNotifies;
          }, set: function (v) {
            this.p.FFreeNotifies = v;
          }});
      };
      this.DestroyComponents();
      if (this.FOwner !== null) this.FOwner.RemoveComponent(this);
      pas.System.TObject.Destroy.call(this);
    };
    this.BeforeDestruction = function () {
      if (!($mod.TComponentStateItem.csDestroying in this.FComponentState)) this.Destroying();
    };
    this.DestroyComponents = function () {
      var acomponent = null;
      while (this.FComponents != null) {
        acomponent = rtl.getObject(this.FComponents.Last());
        this.Remove(acomponent);
        acomponent.$destroy("Destroy");
      };
    };
    this.Destroying = function () {
      var Runner = 0;
      if ($mod.TComponentStateItem.csDestroying in this.FComponentState) return;
      this.FComponentState = rtl.includeSet(this.FComponentState,$mod.TComponentStateItem.csDestroying);
      if (this.FComponents != null) for (var $l = 0, $end = this.FComponents.FCount - 1; $l <= $end; $l++) {
        Runner = $l;
        rtl.getObject(this.FComponents.Get(Runner)).Destroying();
      };
    };
    this.QueryInterface = function (IID, Obj) {
      var Result = 0;
      if (this.GetInterface(IID,Obj)) {
        Result = 0}
       else Result = -2147467262;
      return Result;
    };
    this.AfterLoadDFMValues = function () {
      this.EndUpdate();
      this.Loaded();
    };
    this.BeforeLoadDFMValues = function () {
      if (!($mod.TComponentStateItem.csDesigning in this.FComponentState)) this.Loading();
      this.BeginUpdate();
    };
    this.BeginUpdate = function () {
    };
    this.EndUpdate = function () {
    };
    this.WriteState = function (Writer) {
      Writer.WriteComponentData(this);
    };
    this.FindComponent = function (AName) {
      var Result = null;
      var I = 0;
      Result = null;
      if ((AName === "") || !(this.FComponents != null)) return Result;
      for (var $l = 0, $end = this.FComponents.FCount - 1; $l <= $end; $l++) {
        I = $l;
        if (pas.SysUtils.CompareText(rtl.getObject(this.FComponents.Get(I)).FName,AName) === 0) {
          Result = rtl.getObject(this.FComponents.Get(I));
          return Result;
        };
      };
      return Result;
    };
    this.FreeNotification = function (AComponent) {
      if ((this.FOwner !== null) && (AComponent === this.FOwner)) return;
      if (!(this.FFreeNotifies != null)) this.FFreeNotifies = $mod.TFPList.$create("Create");
      if (this.FFreeNotifies.IndexOf(AComponent) === -1) {
        this.FFreeNotifies.Add(AComponent);
        AComponent.FreeNotification(this);
      };
    };
    this.RemoveFreeNotification = function (AComponent) {
      this.RemoveNotification(AComponent);
      AComponent.RemoveNotification(this);
    };
    this.GetNamePath = function () {
      var Result = "";
      Result = this.FName;
      return Result;
    };
    this.GetParentComponent = function () {
      var Result = null;
      Result = null;
      return Result;
    };
    this.HasParent = function () {
      var Result = false;
      Result = false;
      return Result;
    };
    this.InsertComponent = function (AComponent) {
      AComponent.ValidateContainer(this);
      this.ValidateRename(AComponent,"",AComponent.FName);
      if (AComponent.FOwner !== null) AComponent.FOwner.RemoveComponent(AComponent);
      this.Insert(AComponent);
      if ($mod.TComponentStateItem.csDesigning in this.FComponentState) AComponent.SetDesigning(true,true);
      this.Notification(AComponent,$mod.TOperation.opInsert);
    };
    this.RemoveComponent = function (AComponent) {
      this.Notification(AComponent,$mod.TOperation.opRemove);
      this.Remove(AComponent);
      AComponent.SetDesigning(false,true);
      this.ValidateRename(AComponent,AComponent.FName,"");
    };
    this.SetSubComponent = function (ASubComponent) {
      if (ASubComponent) {
        this.FComponentStyle = rtl.includeSet(this.FComponentStyle,$mod.TComponentStyleItem.csSubComponent)}
       else this.FComponentStyle = rtl.excludeSet(this.FComponentStyle,$mod.TComponentStyleItem.csSubComponent);
    };
    this.GetEnumerator = function () {
      var Result = null;
      Result = $mod.TComponentEnumerator.$create("Create$1",[this]);
      return Result;
    };
    rtl.addIntf(this,pas.System.IUnknown);
    var $r = this.$rtti;
    $r.addMethod("Create$1",2,[["AOwner",$r]]);
    $r.addProperty("Name",6,$mod.$rtti["TComponentName"],"FName","SetName");
    $r.addProperty("Tag",0,rtl.nativeint,"FTag","FTag",{Default: 0});
  });
  this.$rtti.$ClassRef("TComponentClass",{instancetype: this.$rtti["TComponent"]});
  this.TSeekOrigin = {"0": "soBeginning", soBeginning: 0, "1": "soCurrent", soCurrent: 1, "2": "soEnd", soEnd: 2};
  this.$rtti.$Enum("TSeekOrigin",{minvalue: 0, maxvalue: 2, ordtype: 1, enumtype: this.TSeekOrigin});
  rtl.createClass(this,"TStream",pas.System.TObject,function () {
    this.$init = function () {
      pas.System.TObject.$init.call(this);
      this.FEndian = 0;
    };
    this.MakeInt = function (B, aSize, Signed) {
      var Result = 0;
      var Mem = null;
      var A = null;
      var D = null;
      var isLittle = false;
      isLittle = this.FEndian === pas.SysUtils.TEndian.Little;
      Mem = new ArrayBuffer(rtl.length(B));
      A = new Uint8Array(Mem);
      A.set(B);
      D = new DataView(Mem);
      if (Signed) {
        var $tmp = aSize;
        if ($tmp === 1) {
          Result = D.getInt8(0)}
         else if ($tmp === 2) {
          Result = D.getInt16(0,isLittle)}
         else if ($tmp === 4) {
          Result = D.getInt32(0,isLittle)}
         else if ($tmp === 8) Result = Math.round(D.getFloat64(0,isLittle));
      } else {
        var $tmp1 = aSize;
        if ($tmp1 === 1) {
          Result = D.getUint8(0)}
         else if ($tmp1 === 2) {
          Result = D.getUint16(0,isLittle)}
         else if ($tmp1 === 4) {
          Result = D.getUint32(0,isLittle)}
         else if ($tmp1 === 8) Result = Math.round(D.getFloat64(0,isLittle));
      };
      return Result;
    };
    this.MakeBytes = function (B, aSize, Signed) {
      var Result = [];
      var Mem = null;
      var A = null;
      var D = null;
      var isLittle = false;
      isLittle = this.FEndian === pas.SysUtils.TEndian.Little;
      Mem = new ArrayBuffer(aSize);
      D = new DataView(Mem);
      if (Signed) {
        var $tmp = aSize;
        if ($tmp === 1) {
          D.setInt8(0,B)}
         else if ($tmp === 2) {
          D.setInt16(0,B,isLittle)}
         else if ($tmp === 4) {
          D.setInt32(0,B,isLittle)}
         else if ($tmp === 8) D.setFloat64(0,B,isLittle);
      } else {
        var $tmp1 = aSize;
        if ($tmp1 === 1) {
          D.setUint8(0,B)}
         else if ($tmp1 === 2) {
          D.setUint16(0,B,isLittle)}
         else if ($tmp1 === 4) {
          D.setUint32(0,B,isLittle)}
         else if ($tmp1 === 8) D.setFloat64(0,B,isLittle);
      };
      Result = rtl.arraySetLength(Result,0,aSize);
      A = new Uint8Array(Mem);
      Result = $mod.TMemoryStream.MemoryToBytes$1(A);
      return Result;
    };
    this.InvalidSeek = function () {
      throw $mod.EStreamError.$create("CreateFmt",[rtl.getResStr($mod,"SStreamInvalidSeek"),pas.System.VarRecs(18,this.$classname)]);
    };
    var CSmallSize = 255;
    var CLargeMaxBuffer = 32 * 1024;
    this.Discard = function (Count) {
      var Buffer = [];
      if (Count === 0) return;
      if (Count <= 255) {
        Buffer = rtl.arraySetLength(Buffer,0,255);
        this.ReadBuffer({get: function () {
            return Buffer;
          }, set: function (v) {
            Buffer = v;
          }},Count);
      } else this.DiscardLarge(Count,32768);
    };
    this.DiscardLarge = function (Count, MaxBufferSize) {
      var Buffer = [];
      if (Count === 0) return;
      if (Count > MaxBufferSize) {
        Buffer = rtl.arraySetLength(Buffer,0,MaxBufferSize)}
       else Buffer = rtl.arraySetLength(Buffer,0,Count);
      while (Count >= rtl.length(Buffer)) {
        this.ReadBuffer({get: function () {
            return Buffer;
          }, set: function (v) {
            Buffer = v;
          }},rtl.length(Buffer));
        Count -= rtl.length(Buffer);
      };
      if (Count > 0) this.ReadBuffer({get: function () {
          return Buffer;
        }, set: function (v) {
          Buffer = v;
        }},Count);
    };
    this.FakeSeekForward = function (Offset, Origin, Pos) {
      if (Origin === $mod.TSeekOrigin.soBeginning) Offset -= Pos;
      if ((Offset < 0) || (Origin === $mod.TSeekOrigin.soEnd)) this.InvalidSeek();
      if (Offset > 0) this.Discard(Offset);
    };
    this.GetPosition = function () {
      var Result = 0;
      Result = this.Seek(0,$mod.TSeekOrigin.soCurrent);
      return Result;
    };
    this.SetPosition = function (Pos) {
      this.Seek(Pos,$mod.TSeekOrigin.soBeginning);
    };
    this.GetSize = function () {
      var Result = 0;
      var p = 0;
      p = this.Seek(0,$mod.TSeekOrigin.soCurrent);
      Result = this.Seek(0,$mod.TSeekOrigin.soEnd);
      this.Seek(p,$mod.TSeekOrigin.soBeginning);
      return Result;
    };
    this.SetSize = function (NewSize) {
      if (NewSize < 0) throw $mod.EStreamError.$create("Create$1",[rtl.getResStr($mod,"SerrInvalidStreamSize")]);
    };
    this.SetSize64 = function (NewSize) {
      this.SetSize(NewSize);
    };
    this.ReadNotImplemented = function () {
      throw $mod.EStreamError.$create("CreateFmt",[rtl.getResStr($mod,"SStreamNoReading"),pas.System.VarRecs(18,this.$classname)]);
    };
    this.WriteNotImplemented = function () {
      throw $mod.EStreamError.$create("CreateFmt",[rtl.getResStr($mod,"SStreamNoWriting"),pas.System.VarRecs(18,this.$classname)]);
    };
    this.ReadMaxSizeData = function (Buffer, aSize, aCount) {
      var Result = 0;
      var CP = 0;
      if (aCount <= aSize) {
        Result = this.Read({get: function () {
            return Buffer;
          }, set: function (v) {
            Buffer = v;
          }},aCount)}
       else {
        Result = this.Read({get: function () {
            return Buffer;
          }, set: function (v) {
            Buffer = v;
          }},aSize);
        CP = this.GetPosition();
        Result = (Result + this.Seek(aCount - aSize,$mod.TSeekOrigin.soCurrent)) - CP;
      };
      return Result;
    };
    this.ReadExactSizeData = function (Buffer, aSize, aCount) {
      if (this.ReadMaxSizeData(rtl.arrayRef(Buffer),aSize,aCount) !== aCount) throw $mod.EReadError.$create("Create$1",[rtl.getResStr($mod,"SReadError")]);
    };
    this.WriteMaxSizeData = function (Buffer, aSize, aCount) {
      var Result = 0;
      var CP = 0;
      if (aCount <= aSize) {
        Result = this.Write(Buffer,aCount)}
       else {
        Result = this.Write(Buffer,aSize);
        CP = this.GetPosition();
        Result = (Result + this.Seek(aCount - aSize,$mod.TSeekOrigin.soCurrent)) - CP;
      };
      return Result;
    };
    this.WriteExactSizeData = function (Buffer, aSize, aCount) {
      this.WriteMaxSizeData(Buffer,aSize,aCount);
    };
    this.Read = function (Buffer, Count) {
      var Result = 0;
      Result = this.Read$1(rtl.arrayRef(Buffer.get()),0,Count);
      return Result;
    };
    this.Write = function (Buffer, Count) {
      var Result = 0;
      Result = this.Write$1(Buffer,0,Count);
      return Result;
    };
    this.ReadData = function (Buffer, Count) {
      var Result = 0;
      Result = this.Read$1(rtl.arrayRef(Buffer),0,Count);
      return Result;
    };
    this.ReadData$1 = function (Buffer) {
      var Result = 0;
      var B = 0;
      Result = this.ReadData$8({get: function () {
          return B;
        }, set: function (v) {
          B = v;
        }},1);
      if (Result === 1) Buffer.set(B !== 0);
      return Result;
    };
    this.ReadData$2 = function (Buffer, Count) {
      var Result = 0;
      var B = [];
      B = rtl.arraySetLength(B,0,Count);
      Result = this.ReadMaxSizeData(rtl.arrayRef(B),1,Count);
      if (Result > 0) Buffer.set(B[0] !== 0);
      return Result;
    };
    this.ReadData$3 = function (Buffer) {
      var Result = 0;
      Result = this.ReadData$4(Buffer,2);
      return Result;
    };
    this.ReadData$4 = function (Buffer, Count) {
      var Result = 0;
      var W = 0;
      Result = this.ReadData$12({get: function () {
          return W;
        }, set: function (v) {
          W = v;
        }},Count);
      if (Result === 2) Buffer.set(String.fromCharCode(W));
      return Result;
    };
    this.ReadData$5 = function (Buffer) {
      var Result = 0;
      Result = this.ReadData$6(Buffer,1);
      return Result;
    };
    this.ReadData$6 = function (Buffer, Count) {
      var Result = 0;
      var B = [];
      B = rtl.arraySetLength(B,0,Count);
      Result = this.ReadMaxSizeData(rtl.arrayRef(B),1,Count);
      if (Result >= 1) Buffer.set(this.MakeInt(rtl.arrayRef(B),1,true));
      return Result;
    };
    this.ReadData$7 = function (Buffer) {
      var Result = 0;
      Result = this.ReadData$8(Buffer,1);
      return Result;
    };
    this.ReadData$8 = function (Buffer, Count) {
      var Result = 0;
      var B = [];
      B = rtl.arraySetLength(B,0,Count);
      Result = this.ReadMaxSizeData(rtl.arrayRef(B),1,Count);
      if (Result >= 1) Buffer.set(this.MakeInt(rtl.arrayRef(B),1,false));
      return Result;
    };
    this.ReadData$9 = function (Buffer) {
      var Result = 0;
      Result = this.ReadData$10(Buffer,2);
      return Result;
    };
    this.ReadData$10 = function (Buffer, Count) {
      var Result = 0;
      var B = [];
      B = rtl.arraySetLength(B,0,Count);
      Result = this.ReadMaxSizeData(rtl.arrayRef(B),2,Count);
      if (Result >= 2) Buffer.set(this.MakeInt(rtl.arrayRef(B),2,true));
      return Result;
    };
    this.ReadData$11 = function (Buffer) {
      var Result = 0;
      Result = this.ReadData$12(Buffer,2);
      return Result;
    };
    this.ReadData$12 = function (Buffer, Count) {
      var Result = 0;
      var B = [];
      B = rtl.arraySetLength(B,0,Count);
      Result = this.ReadMaxSizeData(rtl.arrayRef(B),2,Count);
      if (Result >= 2) Buffer.set(this.MakeInt(rtl.arrayRef(B),2,false));
      return Result;
    };
    this.ReadData$13 = function (Buffer) {
      var Result = 0;
      Result = this.ReadData$14(Buffer,4);
      return Result;
    };
    this.ReadData$14 = function (Buffer, Count) {
      var Result = 0;
      var B = [];
      B = rtl.arraySetLength(B,0,Count);
      Result = this.ReadMaxSizeData(rtl.arrayRef(B),4,Count);
      if (Result >= 4) Buffer.set(this.MakeInt(rtl.arrayRef(B),4,true));
      return Result;
    };
    this.ReadData$15 = function (Buffer) {
      var Result = 0;
      Result = this.ReadData$16(Buffer,4);
      return Result;
    };
    this.ReadData$16 = function (Buffer, Count) {
      var Result = 0;
      var B = [];
      B = rtl.arraySetLength(B,0,Count);
      Result = this.ReadMaxSizeData(rtl.arrayRef(B),4,Count);
      if (Result >= 4) Buffer.set(this.MakeInt(rtl.arrayRef(B),4,false));
      return Result;
    };
    this.ReadData$17 = function (Buffer) {
      var Result = 0;
      Result = this.ReadData$18(Buffer,8);
      return Result;
    };
    this.ReadData$18 = function (Buffer, Count) {
      var Result = 0;
      var B = [];
      B = rtl.arraySetLength(B,0,Count);
      Result = this.ReadMaxSizeData(rtl.arrayRef(B),8,8);
      if (Result >= 8) Buffer.set(this.MakeInt(rtl.arrayRef(B),8,true));
      return Result;
    };
    this.ReadData$19 = function (Buffer) {
      var Result = 0;
      Result = this.ReadData$20(Buffer,8);
      return Result;
    };
    this.ReadData$20 = function (Buffer, Count) {
      var Result = 0;
      var B = [];
      var B1 = 0;
      B = rtl.arraySetLength(B,0,Count);
      Result = this.ReadMaxSizeData(rtl.arrayRef(B),4,4);
      if (Result >= 4) {
        B1 = this.MakeInt(rtl.arrayRef(B),4,false);
        Result = Result + this.ReadMaxSizeData(rtl.arrayRef(B),4,4);
        Buffer.set(this.MakeInt(rtl.arrayRef(B),4,false));
        Buffer.set(rtl.or(rtl.shl(Buffer.get(),32),B1));
      };
      return Result;
    };
    this.ReadData$21 = function (Buffer) {
      var Result = 0;
      Result = this.ReadData$22(Buffer,8);
      return Result;
    };
    this.ReadData$22 = function (Buffer, Count) {
      var Result = 0;
      var B = [];
      var Mem = null;
      var A = null;
      var D = null;
      B = rtl.arraySetLength(B,0,Count);
      Result = this.ReadMaxSizeData(rtl.arrayRef(B),8,Count);
      if (Result >= 8) {
        Mem = new ArrayBuffer(8);
        A = new Uint8Array(Mem);
        A.set(B);
        D = new DataView(Mem);
        Buffer.set(D.getFloat64(0));
      };
      return Result;
    };
    this.ReadBuffer = function (Buffer, Count) {
      this.ReadBuffer$1(Buffer,0,Count);
    };
    this.ReadBuffer$1 = function (Buffer, Offset, Count) {
      if (this.Read$1(rtl.arrayRef(Buffer.get()),Offset,Count) !== Count) throw $mod.EStreamError.$create("Create$1",[rtl.getResStr($mod,"SReadError")]);
    };
    this.ReadBufferData = function (Buffer) {
      this.ReadBufferData$1(Buffer,1);
    };
    this.ReadBufferData$1 = function (Buffer, Count) {
      if (this.ReadData$2(Buffer,Count) !== Count) throw $mod.EStreamError.$create("Create$1",[rtl.getResStr($mod,"SReadError")]);
    };
    this.ReadBufferData$2 = function (Buffer) {
      this.ReadBufferData$3(Buffer,2);
    };
    this.ReadBufferData$3 = function (Buffer, Count) {
      if (this.ReadData$4(Buffer,Count) !== Count) throw $mod.EStreamError.$create("Create$1",[rtl.getResStr($mod,"SReadError")]);
    };
    this.ReadBufferData$4 = function (Buffer) {
      this.ReadBufferData$5(Buffer,1);
    };
    this.ReadBufferData$5 = function (Buffer, Count) {
      if (this.ReadData$6(Buffer,Count) !== Count) throw $mod.EStreamError.$create("Create$1",[rtl.getResStr($mod,"SReadError")]);
    };
    this.ReadBufferData$6 = function (Buffer) {
      this.ReadBufferData$7(Buffer,1);
    };
    this.ReadBufferData$7 = function (Buffer, Count) {
      if (this.ReadData$8(Buffer,Count) !== Count) throw $mod.EStreamError.$create("Create$1",[rtl.getResStr($mod,"SReadError")]);
    };
    this.ReadBufferData$8 = function (Buffer) {
      this.ReadBufferData$9(Buffer,2);
    };
    this.ReadBufferData$9 = function (Buffer, Count) {
      if (this.ReadData$10(Buffer,Count) !== Count) throw $mod.EStreamError.$create("Create$1",[rtl.getResStr($mod,"SReadError")]);
    };
    this.ReadBufferData$10 = function (Buffer) {
      this.ReadBufferData$11(Buffer,2);
    };
    this.ReadBufferData$11 = function (Buffer, Count) {
      if (this.ReadData$12(Buffer,Count) !== Count) throw $mod.EStreamError.$create("Create$1",[rtl.getResStr($mod,"SReadError")]);
    };
    this.ReadBufferData$12 = function (Buffer) {
      this.ReadBufferData$13(Buffer,4);
    };
    this.ReadBufferData$13 = function (Buffer, Count) {
      if (this.ReadData$14(Buffer,Count) !== Count) throw $mod.EStreamError.$create("Create$1",[rtl.getResStr($mod,"SReadError")]);
    };
    this.ReadBufferData$14 = function (Buffer) {
      this.ReadBufferData$15(Buffer,4);
    };
    this.ReadBufferData$15 = function (Buffer, Count) {
      if (this.ReadData$16(Buffer,Count) !== Count) throw $mod.EStreamError.$create("Create$1",[rtl.getResStr($mod,"SReadError")]);
    };
    this.ReadBufferData$16 = function (Buffer) {
      this.ReadBufferData$17(Buffer,8);
    };
    this.ReadBufferData$17 = function (Buffer, Count) {
      if (this.ReadData$18(Buffer,Count) !== Count) throw $mod.EStreamError.$create("Create$1",[rtl.getResStr($mod,"SReadError")]);
    };
    this.ReadBufferData$18 = function (Buffer) {
      this.ReadBufferData$19(Buffer,8);
    };
    this.ReadBufferData$19 = function (Buffer, Count) {
      if (this.ReadData$20(Buffer,Count) !== Count) throw $mod.EStreamError.$create("Create$1",[rtl.getResStr($mod,"SReadError")]);
    };
    this.ReadBufferData$20 = function (Buffer) {
      this.ReadBufferData$21(Buffer,8);
    };
    this.ReadBufferData$21 = function (Buffer, Count) {
      if (this.ReadData$22(Buffer,Count) !== Count) throw $mod.EStreamError.$create("Create$1",[rtl.getResStr($mod,"SReadError")]);
    };
    this.WriteBuffer = function (Buffer, Count) {
      this.WriteBuffer$1(Buffer,0,Count);
    };
    this.WriteBuffer$1 = function (Buffer, Offset, Count) {
      if (this.Write$1(Buffer,Offset,Count) !== Count) throw $mod.EStreamError.$create("Create$1",[rtl.getResStr($mod,"SWriteError")]);
    };
    this.WriteData = function (Buffer, Count) {
      var Result = 0;
      Result = this.Write$1(Buffer,0,Count);
      return Result;
    };
    this.WriteData$1 = function (Buffer) {
      var Result = 0;
      Result = this.WriteData$2(Buffer,1);
      return Result;
    };
    this.WriteData$2 = function (Buffer, Count) {
      var Result = 0;
      var B = 0;
      B = Buffer + 0;
      Result = this.WriteData$6(B,Count);
      return Result;
    };
    this.WriteData$3 = function (Buffer) {
      var Result = 0;
      Result = this.WriteData$4(Buffer,2);
      return Result;
    };
    this.WriteData$4 = function (Buffer, Count) {
      var Result = 0;
      var U = 0;
      U = Buffer.charCodeAt();
      Result = this.WriteData$12(U,Count);
      return Result;
    };
    this.WriteData$5 = function (Buffer) {
      var Result = 0;
      Result = this.WriteData$6(Buffer,1);
      return Result;
    };
    this.WriteData$6 = function (Buffer, Count) {
      var Result = 0;
      Result = this.WriteMaxSizeData(this.MakeBytes(Buffer,1,true),1,Count);
      return Result;
    };
    this.WriteData$7 = function (Buffer) {
      var Result = 0;
      Result = this.WriteData$8(Buffer,1);
      return Result;
    };
    this.WriteData$8 = function (Buffer, Count) {
      var Result = 0;
      Result = this.WriteMaxSizeData(this.MakeBytes(Buffer,1,false),1,Count);
      return Result;
    };
    this.WriteData$9 = function (Buffer) {
      var Result = 0;
      Result = this.WriteData$10(Buffer,2);
      return Result;
    };
    this.WriteData$10 = function (Buffer, Count) {
      var Result = 0;
      Result = this.WriteMaxSizeData(this.MakeBytes(Buffer,2,true),2,Count);
      return Result;
    };
    this.WriteData$11 = function (Buffer) {
      var Result = 0;
      Result = this.WriteData$12(Buffer,2);
      return Result;
    };
    this.WriteData$12 = function (Buffer, Count) {
      var Result = 0;
      Result = this.WriteMaxSizeData(this.MakeBytes(Buffer,2,true),2,Count);
      return Result;
    };
    this.WriteData$13 = function (Buffer) {
      var Result = 0;
      Result = this.WriteData$14(Buffer,4);
      return Result;
    };
    this.WriteData$14 = function (Buffer, Count) {
      var Result = 0;
      Result = this.WriteMaxSizeData(this.MakeBytes(Buffer,4,true),4,Count);
      return Result;
    };
    this.WriteData$15 = function (Buffer) {
      var Result = 0;
      Result = this.WriteData$16(Buffer,4);
      return Result;
    };
    this.WriteData$16 = function (Buffer, Count) {
      var Result = 0;
      Result = this.WriteMaxSizeData(this.MakeBytes(Buffer,4,false),4,Count);
      return Result;
    };
    this.WriteData$17 = function (Buffer) {
      var Result = 0;
      Result = this.WriteData$18(Buffer,8);
      return Result;
    };
    this.WriteData$18 = function (Buffer, Count) {
      var Result = 0;
      Result = this.WriteMaxSizeData(this.MakeBytes(Buffer,8,true),8,Count);
      return Result;
    };
    this.WriteData$19 = function (Buffer) {
      var Result = 0;
      Result = this.WriteData$20(Buffer,8);
      return Result;
    };
    this.WriteData$20 = function (Buffer, Count) {
      var Result = 0;
      Result = this.WriteMaxSizeData(this.MakeBytes(Buffer,8,false),8,Count);
      return Result;
    };
    this.WriteData$21 = function (Buffer) {
      var Result = 0;
      Result = this.WriteData$22(Buffer,8);
      return Result;
    };
    this.WriteData$22 = function (Buffer, Count) {
      var Result = 0;
      var Mem = null;
      var A = null;
      var D = null;
      var B = [];
      var I = 0;
      Mem = new ArrayBuffer(8);
      D = new DataView(Mem);
      D.setFloat64(0,Buffer);
      B = rtl.arraySetLength(B,0,8);
      A = new Uint8Array(Mem);
      for (I = 0; I <= 7; I++) B[I] = A[I];
      Result = this.WriteMaxSizeData(B,8,Count);
      return Result;
    };
    this.WriteBufferData = function (Buffer) {
      this.WriteBufferData$1(Buffer,4);
    };
    this.WriteBufferData$1 = function (Buffer, Count) {
      if (this.WriteData$14(Buffer,Count) !== Count) throw $mod.EStreamError.$create("Create$1",[rtl.getResStr($mod,"SWriteError")]);
    };
    this.WriteBufferData$2 = function (Buffer) {
      this.WriteBufferData$3(Buffer,1);
    };
    this.WriteBufferData$3 = function (Buffer, Count) {
      if (this.WriteData$2(Buffer,Count) !== Count) throw $mod.EStreamError.$create("Create$1",[rtl.getResStr($mod,"SWriteError")]);
    };
    this.WriteBufferData$4 = function (Buffer) {
      this.WriteBufferData$5(Buffer,2);
    };
    this.WriteBufferData$5 = function (Buffer, Count) {
      if (this.WriteData$4(Buffer,Count) !== Count) throw $mod.EStreamError.$create("Create$1",[rtl.getResStr($mod,"SWriteError")]);
    };
    this.WriteBufferData$6 = function (Buffer) {
      this.WriteBufferData$7(Buffer,1);
    };
    this.WriteBufferData$7 = function (Buffer, Count) {
      if (this.WriteData$6(Buffer,Count) !== Count) throw $mod.EStreamError.$create("Create$1",[rtl.getResStr($mod,"SWriteError")]);
    };
    this.WriteBufferData$8 = function (Buffer) {
      this.WriteBufferData$9(Buffer,1);
    };
    this.WriteBufferData$9 = function (Buffer, Count) {
      if (this.WriteData$8(Buffer,Count) !== Count) throw $mod.EStreamError.$create("Create$1",[rtl.getResStr($mod,"SWriteError")]);
    };
    this.WriteBufferData$10 = function (Buffer) {
      this.WriteBufferData$11(Buffer,2);
    };
    this.WriteBufferData$11 = function (Buffer, Count) {
      if (this.WriteData$10(Buffer,Count) !== Count) throw $mod.EStreamError.$create("Create$1",[rtl.getResStr($mod,"SWriteError")]);
    };
    this.WriteBufferData$12 = function (Buffer) {
      this.WriteBufferData$13(Buffer,2);
    };
    this.WriteBufferData$13 = function (Buffer, Count) {
      if (this.WriteData$12(Buffer,Count) !== Count) throw $mod.EStreamError.$create("Create$1",[rtl.getResStr($mod,"SWriteError")]);
    };
    this.WriteBufferData$14 = function (Buffer) {
      this.WriteBufferData$15(Buffer,4);
    };
    this.WriteBufferData$15 = function (Buffer, Count) {
      if (this.WriteData$16(Buffer,Count) !== Count) throw $mod.EStreamError.$create("Create$1",[rtl.getResStr($mod,"SWriteError")]);
    };
    this.WriteBufferData$16 = function (Buffer) {
      this.WriteBufferData$17(Buffer,8);
    };
    this.WriteBufferData$17 = function (Buffer, Count) {
      if (this.WriteData$18(Buffer,Count) !== Count) throw $mod.EStreamError.$create("Create$1",[rtl.getResStr($mod,"SWriteError")]);
    };
    this.WriteBufferData$18 = function (Buffer) {
      this.WriteBufferData$19(Buffer,8);
    };
    this.WriteBufferData$19 = function (Buffer, Count) {
      if (this.WriteData$20(Buffer,Count) !== Count) throw $mod.EStreamError.$create("Create$1",[rtl.getResStr($mod,"SWriteError")]);
    };
    this.WriteBufferData$20 = function (Buffer) {
      this.WriteBufferData$21(Buffer,8);
    };
    this.WriteBufferData$21 = function (Buffer, Count) {
      if (this.WriteData$22(Buffer,Count) !== Count) throw $mod.EStreamError.$create("Create$1",[rtl.getResStr($mod,"SWriteError")]);
    };
    var MaxSize = 0x20000;
    this.CopyFrom = function (Source, Count) {
      var Result = 0;
      var Buffer = [];
      var BufferSize = 0;
      var i = 0;
      Result = 0;
      if (Count === 0) Source.SetPosition(0);
      BufferSize = 131072;
      if ((Count > 0) && (Count < BufferSize)) BufferSize = Count;
      Buffer = rtl.arraySetLength(Buffer,0,BufferSize);
      if (Count === 0) {
        do {
          i = Source.Read({get: function () {
              return Buffer;
            }, set: function (v) {
              Buffer = v;
            }},BufferSize);
          if (i > 0) this.WriteBuffer(Buffer,i);
          Result += i;
        } while (!(i < BufferSize))}
       else while (Count > 0) {
        if (Count > BufferSize) {
          i = BufferSize}
         else i = Count;
        Source.ReadBuffer({get: function () {
            return Buffer;
          }, set: function (v) {
            Buffer = v;
          }},i);
        this.WriteBuffer(Buffer,i);
        Count -= i;
        Result += i;
      };
      return Result;
    };
    this.ReadComponent = function (Instance) {
      var Result = null;
      var Reader = null;
      Reader = $mod.TReader.$create("Create$1",[this]);
      try {
        Result = Reader.ReadRootComponent(Instance);
      } finally {
        Reader = rtl.freeLoc(Reader);
      };
      return Result;
    };
    this.ReadComponentRes = function (Instance) {
      var Result = null;
      this.ReadResHeader();
      Result = this.ReadComponent(Instance);
      return Result;
    };
    this.WriteComponent = function (Instance) {
      this.WriteDescendent(Instance,null);
    };
    this.WriteComponentRes = function (ResName, Instance) {
      this.WriteDescendentRes(ResName,Instance,null);
    };
    this.WriteDescendent = function (Instance, Ancestor) {
      var Driver = null;
      var Writer = null;
      Driver = $mod.TBinaryObjectWriter.$create("Create$1",[this]);
      try {
        Writer = $mod.TWriter.$create("Create$1",[Driver]);
        try {
          Writer.WriteDescendent(Instance,Ancestor);
        } finally {
          Writer.$destroy("Destroy");
        };
      } finally {
        Driver = rtl.freeLoc(Driver);
      };
    };
    this.WriteDescendentRes = function (ResName, Instance, Ancestor) {
      var FixupInfo = 0;
      this.WriteResourceHeader(ResName,{get: function () {
          return FixupInfo;
        }, set: function (v) {
          FixupInfo = v;
        }});
      this.WriteDescendent(Instance,Ancestor);
      this.FixupResourceHeader(FixupInfo);
    };
    this.WriteResourceHeader = function (ResName, FixupInfo) {
      var ResType = 0;
      var Flags = 0;
      var B = 0;
      var I = 0;
      ResType = 0xA;
      Flags = 0x1030;
      this.WriteByte(0xff);
      this.WriteWord(ResType);
      for (var $l = 1, $end = ResName.length; $l <= $end; $l++) {
        I = $l;
        B = ResName.charCodeAt(I - 1);
        this.WriteByte(B);
      };
      this.WriteByte(0);
      this.WriteWord(Flags);
      this.WriteDWord(0);
      FixupInfo.set(this.GetPosition());
    };
    this.FixupResourceHeader = function (FixupInfo) {
      var ResSize = 0;
      var TmpResSize = 0;
      ResSize = this.GetPosition() - FixupInfo;
      TmpResSize = ResSize >>> 0;
      this.SetPosition(FixupInfo - 4);
      this.WriteDWord(TmpResSize);
      this.SetPosition(FixupInfo + ResSize);
    };
    this.ReadResHeader = function () {
      var ResType = 0;
      var Flags = 0;
      try {
        if (this.ReadByte() !== 0xff) throw $mod.EInvalidImage.$create("Create$1",[rtl.getResStr(pas.RTLConsts,"SInvalidImage")]);
        ResType = this.ReadWord();
        if (ResType !== 0xa) throw $mod.EInvalidImage.$create("Create$1",[rtl.getResStr(pas.RTLConsts,"SInvalidImage")]);
        while (this.ReadByte() !== 0) {
        };
        Flags = this.ReadWord();
        if (Flags !== 0x1030) throw $mod.EInvalidImage.$create("Create$1",[rtl.getResStr(pas.RTLConsts,"SInvalidImage")]);
        this.ReadDWord();
      } catch ($e) {
        if ($mod.EInvalidImage.isPrototypeOf($e)) {
          throw $e}
         else {
          throw $mod.EInvalidImage.$create("Create$1",[rtl.getResStr(pas.RTLConsts,"SInvalidImage")]);
        }
      };
    };
    this.ReadByte = function () {
      var Result = 0;
      this.ReadBufferData$7({get: function () {
          return Result;
        }, set: function (v) {
          Result = v;
        }},1);
      return Result;
    };
    this.ReadWord = function () {
      var Result = 0;
      this.ReadBufferData$11({get: function () {
          return Result;
        }, set: function (v) {
          Result = v;
        }},2);
      return Result;
    };
    this.ReadDWord = function () {
      var Result = 0;
      this.ReadBufferData$15({get: function () {
          return Result;
        }, set: function (v) {
          Result = v;
        }},4);
      return Result;
    };
    this.ReadQWord = function () {
      var Result = 0;
      this.ReadBufferData$19({get: function () {
          return Result;
        }, set: function (v) {
          Result = v;
        }},8);
      return Result;
    };
    this.WriteByte = function (b) {
      this.WriteBufferData$9(b,1);
    };
    this.WriteWord = function (w) {
      this.WriteBufferData$13(w,2);
    };
    this.WriteDWord = function (d) {
      this.WriteBufferData$15(d,4);
    };
    this.WriteQWord = function (q) {
      this.WriteBufferData$19(q,8);
    };
  });
  rtl.createClass(this,"TCustomMemoryStream",this.TStream,function () {
    this.$init = function () {
      $mod.TStream.$init.call(this);
      this.FMemory = null;
      this.FDataView = null;
      this.FDataArray = null;
      this.FSize = 0;
      this.FPosition = 0;
      this.FSizeBoundsSeek = false;
    };
    this.$final = function () {
      this.FMemory = undefined;
      this.FDataView = undefined;
      this.FDataArray = undefined;
      $mod.TStream.$final.call(this);
    };
    this.GetDataArray = function () {
      var Result = null;
      if (this.FDataArray === null) this.FDataArray = new Uint8Array(this.FMemory);
      Result = this.FDataArray;
      return Result;
    };
    this.GetDataView = function () {
      var Result = null;
      if (this.FDataView === null) this.FDataView = new DataView(this.FMemory);
      Result = this.FDataView;
      return Result;
    };
    this.GetSize = function () {
      var Result = 0;
      Result = this.FSize;
      return Result;
    };
    this.GetPosition = function () {
      var Result = 0;
      Result = this.FPosition;
      return Result;
    };
    this.SetPointer = function (Ptr, ASize) {
      this.FMemory = Ptr;
      this.FSize = ASize;
      this.FDataView = null;
      this.FDataArray = null;
    };
    this.MemoryToBytes = function (Mem) {
      var Result = [];
      Result = this.MemoryToBytes$1(new Uint8Array(Mem));
      return Result;
    };
    this.MemoryToBytes$1 = function (Mem) {
      var Result = [];
      var I = 0;
      for (var $l = 0, $end = Mem.length - 1; $l <= $end; $l++) {
        I = $l;
        Result[I] = Mem[I];
      };
      return Result;
    };
    this.BytesToMemory = function (aBytes) {
      var Result = null;
      var a = null;
      Result = new ArrayBuffer(rtl.length(aBytes));
      a = new Uint8Array(Result);
      a.set(aBytes);
      return Result;
    };
    this.Read$1 = function (Buffer, Offset, Count) {
      var Result = 0;
      var I = 0;
      var Src = 0;
      var Dest = 0;
      Result = 0;
      if ((this.FSize > 0) && (this.FPosition < this.FSize) && (this.FPosition >= 0)) {
        Result = Count;
        if (Result > (this.FSize - this.FPosition)) Result = this.FSize - this.FPosition;
        Src = this.FPosition;
        Dest = Offset;
        I = 0;
        while (I < Result) {
          Buffer[Dest] = this.GetDataView().getUint8(Src);
          Src += 1;
          Dest += 1;
          I += 1;
        };
        this.FPosition = this.FPosition + Result;
      };
      return Result;
    };
    this.Seek = function (Offset, Origin) {
      var Result = 0;
      var $tmp = Origin;
      if ($tmp === $mod.TSeekOrigin.soBeginning) {
        this.FPosition = Offset}
       else if ($tmp === $mod.TSeekOrigin.soEnd) {
        this.FPosition = this.FSize + Offset}
       else if ($tmp === $mod.TSeekOrigin.soCurrent) this.FPosition = this.FPosition + Offset;
      if (this.FSizeBoundsSeek && (this.FPosition > this.FSize)) this.FPosition = this.FSize;
      Result = this.FPosition;
      return Result;
    };
    this.SaveToStream = function (Stream) {
      if (this.FSize > 0) Stream.WriteBuffer($mod.TMemoryStream.MemoryToBytes(this.FMemory),this.FSize);
    };
    this.LoadFromURL = function (aURL, Async, OnLoaded, OnError) {
      var $Self = this;
      function DoLoaded(abytes) {
        $Self.SetPointer(abytes,abytes.byteLength);
        if (OnLoaded != null) OnLoaded($Self);
      };
      function DoError(AError) {
        if (OnError != null) {
          OnError($Self,AError)}
         else throw pas.SysUtils.EInOutError.$create("Create$1",["Failed to load from URL:" + AError]);
      };
      $impl.CheckLoadHelper();
      $impl.GlobalLoadHelper.LoadBytes(aURL,Async,DoLoaded,DoError);
    };
    this.LoadFromFile = function (aFileName, OnLoaded, AError) {
      var $Self = this;
      this.LoadFromURL(aFileName,false,function (Sender) {
        if (OnLoaded != null) OnLoaded();
      },function (Sender, ErrorMsg) {
        if (AError != null) AError(ErrorMsg);
      });
    };
  });
  rtl.createClass(this,"TMemoryStream",this.TCustomMemoryStream,function () {
    this.$init = function () {
      $mod.TCustomMemoryStream.$init.call(this);
      this.FCapacity = 0;
    };
    this.SetCapacity = function (NewCapacity) {
      this.SetPointer(this.Realloc({get: function () {
          return NewCapacity;
        }, set: function (v) {
          NewCapacity = v;
        }}),this.FSize);
      this.FCapacity = NewCapacity;
    };
    this.Realloc = function (NewCapacity) {
      var Result = null;
      var GC = 0;
      var DestView = null;
      if (NewCapacity.get() < 0) {
        NewCapacity.set(0)}
       else {
        GC = this.FCapacity + rtl.trunc(this.FCapacity / 4);
        if ((NewCapacity.get() > this.FCapacity) && (NewCapacity.get() < GC)) NewCapacity.set(GC);
        NewCapacity.set((NewCapacity.get() + (4096 - 1)) & ~(4096 - 1));
      };
      if (NewCapacity.get() === this.FCapacity) {
        Result = this.FMemory}
       else if (NewCapacity.get() === 0) {
        Result = null}
       else {
        Result = new ArrayBuffer(NewCapacity.get());
        if (Result === null) throw $mod.EStreamError.$create("Create$1",[rtl.getResStr($mod,"SMemoryStreamError")]);
        DestView = new Uint8Array(Result);
        DestView.set(this.GetDataArray());
      };
      return Result;
    };
    this.Destroy = function () {
      this.Clear();
      pas.System.TObject.Destroy.call(this);
    };
    this.Clear = function () {
      this.FSize = 0;
      this.FPosition = 0;
      this.SetCapacity(0);
    };
    this.LoadFromStream = function (Stream) {
      this.SetPosition(0);
      Stream.SetPosition(0);
      this.SetSize(Stream.GetSize());
      if (this.GetSize() > 0) this.CopyFrom(Stream,0);
    };
    this.SetSize = function (NewSize) {
      this.SetCapacity(NewSize);
      this.FSize = NewSize;
      if (this.FPosition > this.FSize) this.FPosition = this.FSize;
    };
    this.Write$1 = function (Buffer, Offset, Count) {
      var Result = 0;
      var NewPos = 0;
      if ((Count === 0) || (this.FPosition < 0)) return 0;
      NewPos = this.FPosition + Count;
      if (NewPos > this.FSize) {
        if (NewPos > this.FCapacity) this.SetCapacity(NewPos);
        this.FSize = NewPos;
      };
      this.GetDataArray().set(rtl.arrayCopy(0,Buffer,Offset,Count),this.FPosition);
      this.FPosition = NewPos;
      Result = Count;
      return Result;
    };
    this.Write = function (Buffer, Count) {
      var Result = 0;
      Result = this.Write$1(Buffer,0,Count);
      return Result;
    };
  });
  rtl.createClass(this,"TBytesStream",this.TMemoryStream,function () {
    this.GetBytes = function () {
      var Result = [];
      Result = $mod.TMemoryStream.MemoryToBytes(this.FMemory);
      return Result;
    };
    this.Create$1 = function (ABytes) {
      pas.System.TObject.Create.call(this);
      this.SetPointer($mod.TMemoryStream.BytesToMemory(rtl.arrayRef(ABytes)),rtl.length(ABytes));
      this.FCapacity = rtl.length(ABytes);
      return this;
    };
    var $r = this.$rtti;
    $r.addMethod("Create$1",2,[["ABytes",pas.SysUtils.$rtti["TBytes"],2]]);
  });
  rtl.createClass(this,"TStringStream",this.TMemoryStream,function () {
    this.$init = function () {
      $mod.TMemoryStream.$init.call(this);
      this.FEncoding = null;
      this.FOwnsEncoding = false;
    };
    this.$final = function () {
      this.FEncoding = undefined;
      $mod.TMemoryStream.$final.call(this);
    };
    var Chunk = 8 * 1024;
    this.GetDataString = function () {
      var Result = "";
      var ua16 = null;
      var ua8 = null;
      var Len = 0;
      var I = 0;
      Result = "";
      if (this.FEncoding === pas.SysUtils.TEncoding.GetUnicode()) {
        ua16 = new Uint16Array(this.FMemory.slice(0,this.GetSize()));
        if (ua16 !== null) {
          Len = rtl.trunc(ua16.length / 8192);
          for (var $l = 0, $end = Len; $l <= $end; $l++) {
            I = $l;
            Result+=String.fromCharCode.apply(null,ua16.slice(I * Chunk, (I + 1) * Chunk));
          };
        };
      } else {
        ua8 = new Uint8Array(this.FMemory.slice(0,this.GetSize()));
        if (ua8 !== null) {
          return ua8.reduce(function (data, byte) {
          return data + String.fromCharCode(byte);
          }, '');
        };
      };
      return Result;
    };
    this.Create$1 = function () {
      this.Create$3("",pas.SysUtils.TEncoding.GetUnicode(),true);
      return this;
    };
    this.Create$2 = function (aString) {
      this.Create$3(aString,pas.SysUtils.TEncoding.GetUnicode(),true);
      return this;
    };
    this.Create$3 = function (AString, AEncoding, AOwnsEncoding) {
      var Len = 0;
      pas.System.TObject.Create.call(this);
      this.FEncoding = AEncoding;
      Len = AString.length;
      if (this.FEncoding === pas.SysUtils.TEncoding.GetUnicode()) {
        this.SetPointer($mod.StringToBuffer$1(AString,Len,this.FEncoding),Len * 2);
        this.FCapacity = Len * 2;
      } else {
        this.SetPointer($mod.StringToBuffer$1(AString,Len,this.FEncoding),Len);
        this.FCapacity = Len;
      };
      return this;
    };
    this.Destroy = function () {
      if (this.FOwnsEncoding) rtl.free(this,"FEncoding");
      $mod.TMemoryStream.Destroy.call(this);
    };
    this.ReadString = function (Count) {
      var Result = "";
      var B = [];
      var Buf = null;
      var BytesLeft = 0;
      BytesLeft = this.GetSize() - this.GetPosition();
      if (this.FEncoding === pas.SysUtils.TEncoding.GetUnicode()) {
        if (BytesLeft < (Count * 2)) Count = BytesLeft;
        B = rtl.arraySetLength(B,0,Count * 2);
        this.ReadBuffer$1({get: function () {
            return B;
          }, set: function (v) {
            B = v;
          }},0,Count * 2);
        Buf = this.$class.BytesToMemory(rtl.arrayRef(B));
        Result = $mod.BufferToString$1(Buf,0,Count * 2,this.FEncoding);
      } else {
        if (BytesLeft < Count) Count = BytesLeft;
        B = rtl.arraySetLength(B,0,Count);
        this.ReadBuffer$1({get: function () {
            return B;
          }, set: function (v) {
            B = v;
          }},0,Count);
        Buf = this.$class.BytesToMemory(rtl.arrayRef(B));
        Result = $mod.BufferToString$1(Buf,0,Count,this.FEncoding);
      };
      return Result;
    };
    this.WriteString = function (AString) {
      var Buf = null;
      var B = [];
      Buf = $mod.StringToBuffer$1(AString,AString.length,this.FEncoding);
      B = this.$class.MemoryToBytes(Buf);
      this.WriteBuffer(B,rtl.length(B));
    };
    var $r = this.$rtti;
    $r.addMethod("Create$1",2,[]);
    $r.addMethod("Create$2",2,[["aString",rtl.string,2]]);
    $r.addMethod("Create$3",2,[["AString",rtl.string,2],["AEncoding",pas.SysUtils.$rtti["TEncoding"]],["AOwnsEncoding",rtl.boolean]]);
  });
  rtl.createClass(this,"TResourceStream",this.TCustomMemoryStream,function () {
    this.Initialize = function (aInfo) {
      var Ptr = null;
      var S = "";
      if (aInfo.encoding === "base64") {
        S = atob(aInfo.data)}
       else if (aInfo.encoding === "text") {
        S = aInfo.data}
       else throw pas.SysUtils.ENotSupportedException.$create("CreateFmt",[rtl.getResStr(pas.RTLConsts,"SErrResourceNotBase64"),pas.System.VarRecs(18,aInfo.name)]);
      Ptr = $mod.StringToBuffer(S,S.length);
      this.SetPointer(Ptr,Ptr.byteLength);
    };
    this.Initialize$1 = function (Instance, Name, ResType) {
      var aInfo = pas.p2jsres.TResourceInfo.$new();
      if (!pas.p2jsres.GetResourceInfo(Name,aInfo)) throw $mod.EResNotFound.$create("CreateFmt",[rtl.getResStr(pas.RTLConsts,"SResNotFound"),pas.System.VarRecs(18,Name)]);
      this.Initialize(pas.p2jsres.TResourceInfo.$clone(aInfo));
    };
    this.Create$1 = function (aInfo) {
      pas.System.TObject.Create.call(this);
      this.Initialize(pas.p2jsres.TResourceInfo.$clone(aInfo));
      return this;
    };
    this.Create$2 = function (Instance, ResName, ResType) {
      pas.System.TObject.Create.call(this);
      this.Initialize$1(Instance,ResName,ResType);
      return this;
    };
    this.CreateFromID = function (Instance, ResID, ResType) {
      pas.System.TObject.Create.call(this);
      this.Initialize$1(Instance,pas.SysUtils.IntToStr(ResID),ResType);
      return this;
    };
    this.Write$1 = function (Buffer, Offset, Count) {
      var Result = 0;
      throw pas.SysUtils.ENotSupportedException.$create("Create$1",[rtl.getResStr(pas.RTLConsts,"SErrResourceStreamNoWrite")]);
      Result = 0;
      return Result;
    };
    this.Destroy = function () {
      pas.System.TObject.Destroy.call(this);
    };
    var $r = this.$rtti;
    $r.addMethod("Create$1",2,[["aInfo",pas.p2jsres.$rtti["TResourceInfo"]]]);
    $r.addMethod("Create$2",2,[["Instance",rtl.nativeint],["ResName",rtl.string,2],["ResType",rtl.string,2]]);
    $r.addMethod("CreateFromID",2,[["Instance",rtl.nativeint],["ResID",rtl.longint],["ResType",rtl.string]]);
  });
  this.TFilerFlag = {"0": "ffInherited", ffInherited: 0, "1": "ffChildPos", ffChildPos: 1, "2": "ffInline", ffInline: 2};
  this.$rtti.$Enum("TFilerFlag",{minvalue: 0, maxvalue: 2, ordtype: 1, enumtype: this.TFilerFlag});
  this.$rtti.$Set("TFilerFlags",{comptype: this.$rtti["TFilerFlag"]});
  this.$rtti.$MethodVar("TReaderProc",{procsig: rtl.newTIProcSig([["Reader",this.$rtti["TReader"]]]), methodkind: 0});
  this.$rtti.$MethodVar("TWriterProc",{procsig: rtl.newTIProcSig([["Writer",this.$rtti["TWriter"]]]), methodkind: 0});
  this.$rtti.$MethodVar("TStreamProc",{procsig: rtl.newTIProcSig([["Stream",this.$rtti["TStream"]]]), methodkind: 0});
  rtl.createClass(this,"TFiler",pas.System.TObject,function () {
    this.$init = function () {
      pas.System.TObject.$init.call(this);
      this.FRoot = null;
      this.FLookupRoot = null;
      this.FAncestor = null;
      this.FIgnoreChildren = false;
    };
    this.$final = function () {
      this.FRoot = undefined;
      this.FLookupRoot = undefined;
      this.FAncestor = undefined;
      pas.System.TObject.$final.call(this);
    };
    this.SetRoot = function (ARoot) {
      this.FRoot = ARoot;
    };
  });
  this.TValueType = {"0": "vaNull", vaNull: 0, "1": "vaList", vaList: 1, "2": "vaInt8", vaInt8: 2, "3": "vaInt16", vaInt16: 3, "4": "vaInt32", vaInt32: 4, "5": "vaDouble", vaDouble: 5, "6": "vaString", vaString: 6, "7": "vaIdent", vaIdent: 7, "8": "vaFalse", vaFalse: 8, "9": "vaTrue", vaTrue: 9, "10": "vaBinary", vaBinary: 10, "11": "vaSet", vaSet: 11, "12": "vaNil", vaNil: 12, "13": "vaCollection", vaCollection: 13, "14": "vaCurrency", vaCurrency: 14, "15": "vaDate", vaDate: 15, "16": "vaNativeInt", vaNativeInt: 16};
  this.$rtti.$Enum("TValueType",{minvalue: 0, maxvalue: 16, ordtype: 1, enumtype: this.TValueType});
  rtl.createClass(this,"TAbstractObjectReader",pas.System.TObject,function () {
    this.FlushBuffer = function () {
    };
  });
  rtl.createClass(this,"TBinaryObjectReader",this.TAbstractObjectReader,function () {
    this.$init = function () {
      $mod.TAbstractObjectReader.$init.call(this);
      this.FStream = null;
    };
    this.$final = function () {
      this.FStream = undefined;
      $mod.TAbstractObjectReader.$final.call(this);
    };
    this.ReadWord = function () {
      var Result = 0;
      this.FStream.ReadBufferData$10({get: function () {
          return Result;
        }, set: function (v) {
          Result = v;
        }});
      return Result;
    };
    this.ReadDWord = function () {
      var Result = 0;
      this.FStream.ReadBufferData$14({get: function () {
          return Result;
        }, set: function (v) {
          Result = v;
        }});
      return Result;
    };
    this.SkipProperty = function () {
      this.ReadStr();
      this.SkipValue();
    };
    this.SkipSetBody = function () {
      while (this.ReadStr().length > 0) ;
    };
    this.Create$1 = function (Stream) {
      pas.System.TObject.Create.call(this);
      if (Stream === null) throw $mod.EReadError.$create("Create$1",[rtl.getResStr(pas.RTLConsts,"SEmptyStreamIllegalReader")]);
      this.FStream = Stream;
      return this;
    };
    this.NextValue = function () {
      var Result = 0;
      Result = this.ReadValue();
      this.FStream.Seek(-1,$mod.TSeekOrigin.soCurrent);
      return Result;
    };
    this.ReadValue = function () {
      var Result = 0;
      var b = 0;
      this.FStream.ReadBufferData$6({get: function () {
          return b;
        }, set: function (v) {
          b = v;
        }});
      Result = b;
      return Result;
    };
    this.BeginRootComponent = function () {
      this.ReadSignature();
    };
    this.BeginComponent = function (Flags, AChildPos, CompClassName, CompName) {
      var Prefix = 0;
      var ValueType = 0;
      Flags.set({});
      if ((this.NextValue() & 0xf0) === 0xf0) {
        Prefix = this.ReadValue();
        Flags.set({});
        if ((Prefix & 0x1) !== 0) Flags.set(rtl.includeSet(Flags.get(),$mod.TFilerFlag.ffInherited));
        if ((Prefix & 0x2) !== 0) Flags.set(rtl.includeSet(Flags.get(),$mod.TFilerFlag.ffChildPos));
        if ((Prefix & 0x4) !== 0) Flags.set(rtl.includeSet(Flags.get(),$mod.TFilerFlag.ffInline));
        if ($mod.TFilerFlag.ffChildPos in Flags.get()) {
          ValueType = this.ReadValue();
          var $tmp = ValueType;
          if ($tmp === $mod.TValueType.vaInt8) {
            AChildPos.set(this.ReadInt8())}
           else if ($tmp === $mod.TValueType.vaInt16) {
            AChildPos.set(this.ReadInt16())}
           else if ($tmp === $mod.TValueType.vaInt32) {
            AChildPos.set(this.ReadInt32())}
           else if ($tmp === $mod.TValueType.vaNativeInt) {
            AChildPos.set(this.ReadNativeInt())}
           else {
            throw $mod.EReadError.$create("Create$1",[rtl.getResStr(pas.RTLConsts,"SInvalidPropertyValue")]);
          };
        };
      };
      CompClassName.set(this.ReadStr());
      CompName.set(this.ReadStr());
    };
    this.BeginProperty = function () {
      var Result = "";
      Result = this.ReadStr();
      return Result;
    };
    this.Read = function (Buffer, Count) {
      this.FStream.Read(Buffer,Count);
    };
    this.ReadBinary = function (DestData) {
      var BinSize = 0;
      BinSize = this.ReadDWord() & 0xFFFFFFFF;
      DestData.SetSize64(BinSize);
      DestData.CopyFrom(this.FStream,BinSize);
    };
    this.ReadFloat = function () {
      var Result = 0.0;
      this.FStream.ReadBufferData$20({get: function () {
          return Result;
        }, set: function (v) {
          Result = v;
        }});
      return Result;
    };
    this.ReadCurrency = function () {
      var Result = 0;
      Result = rtl.trunc(this.ReadFloat() * 10000);
      return Result;
    };
    this.ReadIdent = function (ValueType) {
      var Result = "";
      var i = 0;
      var c = "\x00";
      var $tmp = ValueType;
      if ($tmp === $mod.TValueType.vaIdent) {
        this.FStream.ReadBufferData$6({get: function () {
            return i;
          }, set: function (v) {
            i = v;
          }});
        Result = rtl.strSetLength(Result,i);
        for (var $l = 1, $end = Result.length; $l <= $end; $l++) {
          i = $l;
          this.FStream.ReadBufferData$2({get: function () {
              return c;
            }, set: function (v) {
              c = v;
            }});
          Result = rtl.setCharAt(Result,i - 1,c);
        };
      } else if ($tmp === $mod.TValueType.vaNil) {
        Result = "nil"}
       else if ($tmp === $mod.TValueType.vaFalse) {
        Result = "False"}
       else if ($tmp === $mod.TValueType.vaTrue) {
        Result = "True"}
       else if ($tmp === $mod.TValueType.vaNull) Result = "Null";
      return Result;
    };
    this.ReadInt8 = function () {
      var Result = 0;
      this.FStream.ReadBufferData$4({get: function () {
          return Result;
        }, set: function (v) {
          Result = v;
        }});
      return Result;
    };
    this.ReadInt16 = function () {
      var Result = 0;
      this.FStream.ReadBufferData$8({get: function () {
          return Result;
        }, set: function (v) {
          Result = v;
        }});
      return Result;
    };
    this.ReadInt32 = function () {
      var Result = 0;
      this.FStream.ReadBufferData$12({get: function () {
          return Result;
        }, set: function (v) {
          Result = v;
        }});
      return Result;
    };
    this.ReadNativeInt = function () {
      var Result = 0;
      this.FStream.ReadBufferData$16({get: function () {
          return Result;
        }, set: function (v) {
          Result = v;
        }});
      return Result;
    };
    this.ReadSet = function (EnumType) {
      var Result = 0;
      var Name = "";
      var Value = 0;
      try {
        Result = 0;
        while (true) {
          Name = this.ReadStr();
          if (Name.length === 0) break;
          Value = EnumType.enumtype[Name];
          if (Value === -1) throw $mod.EReadError.$create("Create$1",[rtl.getResStr(pas.RTLConsts,"SInvalidPropertyValue")]);
          Result = Result | (1 << Value);
        };
      } catch ($e) {
        this.SkipSetBody();
        throw $e;
      };
      return Result;
    };
    this.ReadSignature = function () {
      var Signature = 0;
      this.FStream.ReadBufferData$12({get: function () {
          return Signature;
        }, set: function (v) {
          Signature = v;
        }});
      if (Signature !== 809914452) throw $mod.EReadError.$create("Create$1",[rtl.getResStr(pas.RTLConsts,"SInvalidImage")]);
    };
    this.ReadStr = function () {
      var Result = "";
      var l = 0;
      var i = 0;
      var c = "\x00";
      this.FStream.ReadBufferData$6({get: function () {
          return l;
        }, set: function (v) {
          l = v;
        }});
      Result = rtl.strSetLength(Result,l);
      for (var $l = 1, $end = l; $l <= $end; $l++) {
        i = $l;
        this.FStream.ReadBufferData$2({get: function () {
            return c;
          }, set: function (v) {
            c = v;
          }});
        Result = rtl.setCharAt(Result,i - 1,c);
      };
      return Result;
    };
    this.ReadString = function (StringType) {
      var Result = "";
      var i = 0;
      var C = "\x00";
      Result = "";
      if (StringType !== $mod.TValueType.vaString) throw $mod.EFilerError.$create("Create$1",["Invalid string type passed to ReadString"]);
      i = this.ReadDWord();
      Result = rtl.strSetLength(Result,i);
      for (var $l = 1, $end = Result.length; $l <= $end; $l++) {
        i = $l;
        this.FStream.ReadBufferData$2({get: function () {
            return C;
          }, set: function (v) {
            C = v;
          }});
        Result = rtl.setCharAt(Result,i - 1,C);
      };
      return Result;
    };
    this.ReadWideString = function () {
      var Result = "";
      Result = this.ReadString($mod.TValueType.vaString);
      return Result;
    };
    this.ReadUnicodeString = function () {
      var Result = "";
      Result = this.ReadString($mod.TValueType.vaString);
      return Result;
    };
    this.SkipComponent = function (SkipComponentInfos) {
      var Flags = {};
      var Dummy = 0;
      var CompClassName = "";
      var CompName = "";
      if (SkipComponentInfos) this.BeginComponent({get: function () {
          return Flags;
        }, set: function (v) {
          Flags = v;
        }},{get: function () {
          return Dummy;
        }, set: function (v) {
          Dummy = v;
        }},{get: function () {
          return CompClassName;
        }, set: function (v) {
          CompClassName = v;
        }},{get: function () {
          return CompName;
        }, set: function (v) {
          CompName = v;
        }});
      while (this.NextValue() !== $mod.TValueType.vaNull) this.SkipProperty();
      this.ReadValue();
      while (this.NextValue() !== $mod.TValueType.vaNull) this.SkipComponent(true);
      this.ReadValue();
    };
    this.SkipValue = function () {
      var $Self = this;
      function SkipBytes(Count) {
        var Dummy = [];
        var SkipNow = 0;
        while (Count > 0) {
          if (Count > 1024) {
            SkipNow = 1024}
           else SkipNow = Count;
          Dummy = rtl.arraySetLength(Dummy,0,SkipNow);
          $Self.Read({get: function () {
              return Dummy;
            }, set: function (v) {
              Dummy = v;
            }},SkipNow);
          Count -= SkipNow;
        };
      };
      var Count = 0;
      var $tmp = this.ReadValue();
      if (($tmp === $mod.TValueType.vaNull) || ($tmp === $mod.TValueType.vaFalse) || ($tmp === $mod.TValueType.vaTrue) || ($tmp === $mod.TValueType.vaNil)) {}
      else if ($tmp === $mod.TValueType.vaList) {
        while (this.NextValue() !== $mod.TValueType.vaNull) this.SkipValue();
        this.ReadValue();
      } else if ($tmp === $mod.TValueType.vaInt8) {
        SkipBytes(1)}
       else if ($tmp === $mod.TValueType.vaInt16) {
        SkipBytes(2)}
       else if ($tmp === $mod.TValueType.vaInt32) {
        SkipBytes(4)}
       else if (($tmp === $mod.TValueType.vaNativeInt) || ($tmp === $mod.TValueType.vaDouble)) {
        SkipBytes(8)}
       else if ($tmp === $mod.TValueType.vaIdent) {
        this.ReadStr()}
       else if ($tmp === $mod.TValueType.vaString) {
        this.ReadString($mod.TValueType.vaString)}
       else if ($tmp === $mod.TValueType.vaBinary) {
        Count = this.ReadDWord() & 0xFFFFFFFF;
        SkipBytes(Count);
      } else if ($tmp === $mod.TValueType.vaSet) {
        this.SkipSetBody()}
       else if ($tmp === $mod.TValueType.vaCollection) {
        while (this.NextValue() !== $mod.TValueType.vaNull) {
          if (this.NextValue() in rtl.createSet($mod.TValueType.vaInt8,$mod.TValueType.vaInt16,$mod.TValueType.vaInt32)) this.SkipValue();
          SkipBytes(1);
          while (this.NextValue() !== $mod.TValueType.vaNull) this.SkipProperty();
          this.ReadValue();
        };
        this.ReadValue();
      };
    };
    var $r = this.$rtti;
    $r.addMethod("Create$1",2,[["Stream",$mod.$rtti["TStream"]]]);
  });
  this.$rtti.$MethodVar("TFindMethodEvent",{procsig: rtl.newTIProcSig([["Reader",this.$rtti["TReader"]],["MethodName",rtl.string,2],["Address",rtl.pointer,1],["error",rtl.boolean,1]]), methodkind: 0});
  this.$rtti.$MethodVar("TSetNameEvent",{procsig: rtl.newTIProcSig([["Reader",this.$rtti["TReader"]],["Component",this.$rtti["TComponent"]],["Name",rtl.string,1]]), methodkind: 0});
  this.$rtti.$MethodVar("TReferenceNameEvent",{procsig: rtl.newTIProcSig([["Reader",this.$rtti["TReader"]],["Name",rtl.string,1]]), methodkind: 0});
  this.$rtti.$MethodVar("TAncestorNotFoundEvent",{procsig: rtl.newTIProcSig([["Reader",this.$rtti["TReader"]],["ComponentName",rtl.string,2],["ComponentClass",this.$rtti["TPersistentClass"]],["Component",this.$rtti["TComponent"],1]]), methodkind: 0});
  this.$rtti.$MethodVar("TReadComponentsProc",{procsig: rtl.newTIProcSig([["Component",this.$rtti["TComponent"]]]), methodkind: 0});
  this.$rtti.$MethodVar("TReaderError",{procsig: rtl.newTIProcSig([["Reader",this.$rtti["TReader"]],["Message",rtl.string,2],["Handled",rtl.boolean,1]]), methodkind: 0});
  this.$rtti.$MethodVar("TPropertyNotFoundEvent",{procsig: rtl.newTIProcSig([["Reader",this.$rtti["TReader"]],["Instance",this.$rtti["TPersistent"]],["PropName",rtl.string,1],["IsPath",rtl.boolean],["Handled",rtl.boolean,1],["Skip",rtl.boolean,1]]), methodkind: 0});
  this.$rtti.$MethodVar("TFindComponentClassEvent",{procsig: rtl.newTIProcSig([["Reader",this.$rtti["TReader"]],["ClassName",rtl.string,2],["ComponentClass",this.$rtti["TComponentClass"],1]]), methodkind: 0});
  this.$rtti.$MethodVar("TCreateComponentEvent",{procsig: rtl.newTIProcSig([["Reader",this.$rtti["TReader"]],["ComponentClass",this.$rtti["TComponentClass"]],["Component",this.$rtti["TComponent"],1]]), methodkind: 0});
  this.$rtti.$MethodVar("TSetMethodPropertyEvent",{procsig: rtl.newTIProcSig([["Reader",this.$rtti["TReader"]],["Instance",this.$rtti["TPersistent"]],["PropInfo",pas.TypInfo.$rtti["TTypeMemberProperty"]],["TheMethodName",rtl.string,2],["Handled",rtl.boolean,1]]), methodkind: 0});
  this.$rtti.$MethodVar("TReadWriteStringPropertyEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["Instance",this.$rtti["TPersistent"],2],["PropInfo",pas.TypInfo.$rtti["TTypeMemberProperty"]],["Content",rtl.string,1]]), methodkind: 0});
  rtl.createClass(this,"TReader",this.TFiler,function () {
    this.$init = function () {
      $mod.TFiler.$init.call(this);
      this.FDriver = null;
      this.FOwner = null;
      this.FParent = null;
      this.FFixups = null;
      this.FLoaded = null;
      this.FOnFindMethod = null;
      this.FOnSetMethodProperty = null;
      this.FOnSetName = null;
      this.FOnReferenceName = null;
      this.FOnAncestorNotFound = null;
      this.FOnError = null;
      this.FOnPropertyNotFound = null;
      this.FOnFindComponentClass = null;
      this.FOnCreateComponent = null;
      this.FPropName = "";
      this.FCanHandleExcepts = false;
      this.FOnReadStringProperty = null;
    };
    this.$final = function () {
      this.FDriver = undefined;
      this.FOwner = undefined;
      this.FParent = undefined;
      this.FFixups = undefined;
      this.FLoaded = undefined;
      this.FOnFindMethod = undefined;
      this.FOnSetMethodProperty = undefined;
      this.FOnSetName = undefined;
      this.FOnReferenceName = undefined;
      this.FOnAncestorNotFound = undefined;
      this.FOnError = undefined;
      this.FOnPropertyNotFound = undefined;
      this.FOnFindComponentClass = undefined;
      this.FOnCreateComponent = undefined;
      this.FOnReadStringProperty = undefined;
      $mod.TFiler.$final.call(this);
    };
    this.DoFixupReferences = function () {
      var R = null;
      var RN = null;
      var G = null;
      var Ref = "";
      var C = null;
      var P = 0;
      var L = null;
      var $ir = rtl.createIntfRefs();
      try {
        if (this.FFixups != null) {
          L = this.FFixups;
          R = L.FRoot;
          while (R !== null) {
            RN = R.Next;
            Ref = R.FRelative;
            if (this.FOnReferenceName != null) this.FOnReferenceName(this,{get: function () {
                return Ref;
              }, set: function (v) {
                Ref = v;
              }});
            C = $mod.FindNestedComponent(R.FRoot,Ref,true);
            if (C != null) {
              if (R.FPropInfo.typeinfo.kind === pas.System.TTypeKind.tkInterface) {
                pas.TypInfo.SetInterfaceProp$1(R.Finstance,R.FPropInfo,$ir.ref(1,rtl.queryIntfT(C,pas.System.IUnknown)))}
               else pas.TypInfo.SetObjectProp$1(R.Finstance,R.FPropInfo,C)}
             else {
              P = pas.System.Pos(".",R.FRelative);
              if (P !== 0) {
                G = $impl.AddtoResolveList(R.Finstance);
                G.AddReference(R.FRoot,R.FPropInfo,pas.System.Copy(R.FRelative,1,P - 1),pas.System.Copy(R.FRelative,P + 1,R.FRelative.length - P));
              };
            };
            L.RemoveItem(R,true);
            R = RN;
          };
          pas.SysUtils.FreeAndNil({p: this, get: function () {
              return this.p.FFixups;
            }, set: function (v) {
              this.p.FFixups = v;
            }});
        };
      } finally {
        $ir.free();
      };
    };
    this.FindComponentClass = function (AClassName) {
      var $Self = this;
      var Result = null;
      var PersistentClass = null;
      function FindClassInFieldTable(Instance) {
        var Result = null;
        var aClass = null;
        var i = 0;
        var ClassTI = null;
        var MemberClassTI = null;
        var MemberTI = null;
        aClass = Instance.$class.ClassType();
        while (aClass !== null) {
          ClassTI = aClass.$rtti;
          for (var $l = 0, $end = ClassTI.fields.length - 1; $l <= $end; $l++) {
            i = $l;
            MemberTI = ClassTI.getField(i).typeinfo;
            if (MemberTI.kind === pas.System.TTypeKind.tkClass) {
              MemberClassTI = MemberTI;
              if (pas.SysUtils.SameText(MemberClassTI.name,AClassName) && rtl.is(MemberClassTI.class,$mod.TComponent)) return MemberClassTI.class;
            };
          };
          aClass = aClass.$ancestor;
        };
        return Result;
      };
      Result = null;
      Result = FindClassInFieldTable(this.FRoot);
      if ((Result === null) && (this.FLookupRoot != null) && (this.FLookupRoot !== this.FRoot)) Result = FindClassInFieldTable(this.FLookupRoot);
      if (Result === null) {
        PersistentClass = $mod.GetClass(AClassName);
        if ((PersistentClass != null) && PersistentClass.InheritsFrom($mod.TComponent)) Result = PersistentClass;
      };
      if ((Result === null) && (this.FOnFindComponentClass != null)) this.FOnFindComponentClass($Self,AClassName,{get: function () {
          return Result;
        }, set: function (v) {
          Result = v;
        }});
      if ((Result === null) || !Result.InheritsFrom($mod.TComponent)) throw $mod.EClassNotFound.$create("CreateFmt",[rtl.getResStr(pas.RTLConsts,"SClassNotFound"),pas.System.VarRecs(18,AClassName)]);
      return Result;
    };
    this.Error = function (Message) {
      var Result = false;
      Result = false;
      if (this.FOnError != null) this.FOnError(this,Message,{get: function () {
          return Result;
        }, set: function (v) {
          Result = v;
        }});
      return Result;
    };
    this.FindMethod = function (ARoot, AMethodName) {
      var Result = null;
      var ErrorResult = false;
      Result = null;
      if ((ARoot === null) || (AMethodName === "")) return Result;
      Result = ARoot.$class.MethodAddress(AMethodName);
      ErrorResult = Result === null;
      if (this.FOnFindMethod != null) this.FOnFindMethod(this,AMethodName,{get: function () {
          return Result;
        }, set: function (v) {
          Result = v;
        }},{get: function () {
          return ErrorResult;
        }, set: function (v) {
          ErrorResult = v;
        }});
      if (ErrorResult) throw $mod.EReadError.$create("Create$1",[rtl.getResStr(pas.RTLConsts,"SInvalidPropertyValue")]);
      return Result;
    };
    this.ReadProperty = function (AInstance) {
      var $Self = this;
      var Path = "";
      var Instance = null;
      var PropInfo = null;
      var Obj = null;
      var Name = "";
      var Skip = false;
      var Handled = false;
      var OldPropName = "";
      var DotPos = "";
      var NextPos = 0;
      function HandleMissingProperty(IsPath) {
        var Result = false;
        Result = true;
        if ($Self.FOnPropertyNotFound != null) {
          OldPropName = $Self.FPropName;
          Handled = false;
          Skip = false;
          $Self.FOnPropertyNotFound($Self,Instance,{p: $Self, get: function () {
              return this.p.FPropName;
            }, set: function (v) {
              this.p.FPropName = v;
            }},IsPath,{get: function () {
              return Handled;
            }, set: function (v) {
              Handled = v;
            }},{get: function () {
              return Skip;
            }, set: function (v) {
              Skip = v;
            }});
          if (Handled && !Skip && (OldPropName !== $Self.FPropName)) PropInfo = pas.TypInfo.GetPropInfo$4(Instance.$class.ClassType(),$Self.FPropName);
          if (Skip) {
            $Self.FDriver.SkipValue();
            Result = false;
            return Result;
          };
        };
        return Result;
      };
      try {
        Path = this.FDriver.BeginProperty();
        try {
          Instance = AInstance;
          this.FCanHandleExcepts = true;
          DotPos = Path;
          while (true) {
            NextPos = pas.System.Pos(".",DotPos);
            if (NextPos > 0) {
              this.FPropName = pas.System.Copy(DotPos,1,NextPos - 1)}
             else {
              this.FPropName = DotPos;
              break;
            };
            pas.System.Delete({get: function () {
                return DotPos;
              }, set: function (v) {
                DotPos = v;
              }},1,NextPos);
            PropInfo = pas.TypInfo.GetPropInfo$4(Instance.$class.ClassType(),this.FPropName);
            if (!(PropInfo != null)) {
              if (!HandleMissingProperty(true)) return;
              if (!(PropInfo != null)) this.PropertyError();
            };
            if (PropInfo.typeinfo.kind === pas.System.TTypeKind.tkClass) {
              Obj = pas.TypInfo.GetObjectProp$2(Instance,PropInfo)}
             else Obj = null;
            if (!$mod.TPersistent.isPrototypeOf(Obj)) {
              this.FDriver.SkipValue();
              throw $mod.EReadError.$create("Create$1",[rtl.getResStr(pas.RTLConsts,"SInvalidPropertyPath")]);
            };
            Instance = Obj;
          };
          PropInfo = pas.TypInfo.GetPropInfo$4(Instance.$class.ClassType(),this.FPropName);
          if (PropInfo != null) {
            this.ReadPropValue(Instance,PropInfo)}
           else {
            this.FCanHandleExcepts = false;
            Instance.DefineProperties($Self);
            this.FCanHandleExcepts = true;
            if (this.FPropName.length > 0) {
              if (!HandleMissingProperty(false)) return;
              if (!(PropInfo != null)) this.PropertyError();
            };
          };
        } catch ($e) {
          if (pas.SysUtils.Exception.isPrototypeOf($e)) {
            var e = $e;
            Name = rtl.strSetLength(Name,0);
            if (AInstance.$class.InheritsFrom($mod.TComponent)) Name = AInstance.FName;
            if (Name.length === 0) Name = AInstance.$classname;
            throw $mod.EReadError.$create("CreateFmt",[rtl.getResStr(pas.RTLConsts,"SPropertyException"),pas.System.VarRecs(18,Name,9,".",18,Path,18,e.FMessage)]);
          } else throw $e
        };
      } catch ($e) {
        if (pas.SysUtils.Exception.isPrototypeOf($e)) {
          var e = $e;
          if (!this.FCanHandleExcepts || !this.Error(e.FMessage)) throw $e;
        } else throw $e
      };
    };
    var NullMethod = pas.System.TMethod.$clone({Code: null, Data: null});
    this.ReadPropValue = function (Instance, PropInfo) {
      var PropType = null;
      var Value = 0;
      var Ident = "";
      var Method = pas.System.TMethod.$new();
      var Handled = false;
      var TmpStr = "";
      if (PropInfo.setter === "") throw $mod.EReadError.$create("Create$1",[rtl.getResStr(pas.RTLConsts,"SReadOnlyProperty")]);
      PropType = PropInfo.typeinfo;
      var $tmp = PropType.kind;
      if ($tmp === pas.System.TTypeKind.tkInteger) {
        var $tmp1 = this.FDriver.NextValue();
        if ($tmp1 === $mod.TValueType.vaIdent) {
          Ident = this.ReadIdent();
          if ($impl.GlobalIdentToInt(Ident,{get: function () {
              return Value;
            }, set: function (v) {
              Value = v;
            }})) {
            pas.TypInfo.SetOrdProp$1(Instance,PropInfo,Value)}
           else throw $mod.EReadError.$create("Create$1",[rtl.getResStr(pas.RTLConsts,"SInvalidPropertyValue")]);
        } else if ($tmp1 === $mod.TValueType.vaNativeInt) {
          pas.TypInfo.SetOrdProp$1(Instance,PropInfo,this.ReadNativeInt())}
         else if ($tmp1 === $mod.TValueType.vaCurrency) {
          pas.TypInfo.SetFloatProp$1(Instance,PropInfo,this.ReadCurrency() / 10000)}
         else {
          pas.TypInfo.SetOrdProp$1(Instance,PropInfo,this.ReadInteger());
        };
      } else if ($tmp === pas.System.TTypeKind.tkBool) {
        pas.TypInfo.SetBoolProp$1(Instance,PropInfo,this.ReadBoolean())}
       else if ($tmp === pas.System.TTypeKind.tkChar) {
        pas.TypInfo.SetOrdProp$1(Instance,PropInfo,this.ReadChar().charCodeAt())}
       else if ($tmp === pas.System.TTypeKind.tkEnumeration) {
        Value = pas.TypInfo.GetEnumValue(PropType,this.ReadIdent());
        if (Value === -1) throw $mod.EReadError.$create("Create$1",[rtl.getResStr(pas.RTLConsts,"SInvalidPropertyValue")]);
        pas.TypInfo.SetOrdProp$1(Instance,PropInfo,Value);
      } else if ($tmp === pas.System.TTypeKind.tkDouble) {
        pas.TypInfo.SetFloatProp$1(Instance,PropInfo,this.ReadFloat())}
       else if ($tmp === pas.System.TTypeKind.tkSet) {
        this.CheckValue($mod.TValueType.vaSet);
        if (PropType.comptype.kind === pas.System.TTypeKind.tkEnumeration) pas.TypInfo.SetOrdProp$1(Instance,PropInfo,this.FDriver.ReadSet(PropType.comptype));
      } else if (($tmp === pas.System.TTypeKind.tkMethod) || ($tmp === pas.System.TTypeKind.tkRefToProcVar)) {
        if (this.FDriver.NextValue() === $mod.TValueType.vaNil) {
          this.FDriver.ReadValue();
          pas.TypInfo.SetMethodProp(Instance,PropInfo,NullMethod);
        } else {
          Handled = false;
          Ident = this.ReadIdent();
          if (this.FOnSetMethodProperty != null) this.FOnSetMethodProperty(this,Instance,PropInfo,Ident,{get: function () {
              return Handled;
            }, set: function (v) {
              Handled = v;
            }});
          if (!Handled) {
            Method.Code = this.FindMethod(this.FRoot,Ident);
            Method.Data = this.FRoot;
            if (Method.Code != null) pas.TypInfo.SetMethodProp(Instance,PropInfo,Method);
          };
        }}
       else if ($tmp === pas.System.TTypeKind.tkString) {
        TmpStr = this.ReadString();
        if (this.FOnReadStringProperty != null) this.FOnReadStringProperty(this,Instance,PropInfo,{get: function () {
            return TmpStr;
          }, set: function (v) {
            TmpStr = v;
          }});
        pas.TypInfo.SetStrProp$1(Instance,PropInfo,TmpStr);
      } else if ($tmp === pas.System.TTypeKind.tkJSValue) {
        pas.TypInfo.SetJSValueProp$3(Instance,PropInfo,this.ReadVariant());
      } else if (($tmp === pas.System.TTypeKind.tkClass) || ($tmp === pas.System.TTypeKind.tkInterface)) {
        var $tmp2 = this.FDriver.NextValue();
        if ($tmp2 === $mod.TValueType.vaNil) {
          this.FDriver.ReadValue();
          pas.TypInfo.SetOrdProp$1(Instance,PropInfo,0);
        } else if ($tmp2 === $mod.TValueType.vaCollection) {
          this.FDriver.ReadValue();
          this.ReadCollection(pas.TypInfo.GetObjectProp$2(Instance,PropInfo));
        } else {
          if (!(this.FFixups != null)) this.FFixups = pas.simplelinkedlist.TLinkedList.$create("Create$1",[$impl.TLocalUnResolvedReference]);
          var $with = this.FFixups.Add();
          $with.Finstance = Instance;
          $with.FRoot = this.FRoot;
          $with.FPropInfo = PropInfo;
          $with.FRelative = this.ReadIdent();
        };
      } else {
        throw $mod.EReadError.$create("CreateFmt",[rtl.getResStr(pas.RTLConsts,"SUnknownPropertyType"),pas.System.VarRecs(18,pas.System.TTypeKind[PropType.kind])]);
      };
    };
    this.PropertyError = function () {
      this.FDriver.SkipValue();
      throw $mod.EReadError.$create("CreateFmt",[rtl.getResStr(pas.RTLConsts,"SUnknownProperty"),pas.System.VarRecs(18,this.FPropName)]);
    };
    this.ReadData = function (Instance) {
      var SavedOwner = null;
      var SavedParent = null;
      while (!this.EndOfList()) this.ReadProperty(Instance);
      this.ReadListEnd();
      SavedOwner = this.FOwner;
      SavedParent = this.FParent;
      try {
        this.FOwner = Instance.GetChildOwner();
        if (!(this.FOwner != null)) this.FOwner = this.FRoot;
        this.FParent = Instance.GetChildParent();
        while (!this.EndOfList()) this.ReadComponent(null);
        this.ReadListEnd();
      } finally {
        this.FOwner = SavedOwner;
        this.FParent = SavedParent;
      };
      if (Instance === this.FRoot) this.DoFixupReferences();
    };
    this.CreateDriver = function (Stream) {
      var Result = null;
      Result = $mod.TBinaryObjectReader.$create("Create$1",[Stream]);
      return Result;
    };
    this.Create$1 = function (Stream) {
      pas.System.TObject.Create.call(this);
      if (Stream === null) throw $mod.EReadError.$create("Create$1",[rtl.getResStr(pas.RTLConsts,"SEmptyStreamIllegalReader")]);
      this.FDriver = this.CreateDriver(Stream);
      return this;
    };
    this.Destroy = function () {
      rtl.free(this,"FDriver");
      pas.System.TObject.Destroy.call(this);
    };
    this.FlushBuffer = function () {
      this.FDriver.FlushBuffer();
    };
    this.BeginReferences = function () {
      this.FLoaded = $mod.TFPList.$create("Create");
    };
    this.CheckValue = function (Value) {
      if (this.FDriver.NextValue() !== Value) {
        throw $mod.EReadError.$create("Create$1",[rtl.getResStr(pas.RTLConsts,"SInvalidPropertyValue")])}
       else this.FDriver.ReadValue();
    };
    this.DefineProperty = function (Name, AReadData, WriteData, HasData) {
      if ((AReadData != null) && pas.SysUtils.SameText(Name,this.FPropName)) {
        AReadData(this);
        this.FPropName = rtl.strSetLength(this.FPropName,0);
      } else if ((WriteData != null) && HasData) ;
    };
    this.DefineBinaryProperty = function (Name, AReadData, WriteData, HasData) {
      var MemBuffer = null;
      if ((AReadData != null) && pas.SysUtils.SameText(Name,this.FPropName)) {
        if (this.FDriver.NextValue() !== $mod.TValueType.vaBinary) {
          this.FDriver.SkipValue();
          this.FCanHandleExcepts = true;
          throw $mod.EReadError.$create("Create$1",[rtl.getResStr(pas.RTLConsts,"SInvalidPropertyValue")]);
        } else this.FDriver.ReadValue();
        MemBuffer = $mod.TMemoryStream.$create("Create");
        try {
          this.FDriver.ReadBinary(MemBuffer);
          this.FCanHandleExcepts = true;
          AReadData(MemBuffer);
        } finally {
          MemBuffer = rtl.freeLoc(MemBuffer);
        };
        this.FPropName = rtl.strSetLength(this.FPropName,0);
      } else if ((WriteData != null) && HasData) ;
    };
    this.EndOfList = function () {
      var Result = false;
      Result = this.FDriver.NextValue() === $mod.TValueType.vaNull;
      return Result;
    };
    this.EndReferences = function () {
      rtl.free(this,"FLoaded");
      this.FLoaded = null;
    };
    this.FixupReferences = function () {
      var i = 0;
      this.DoFixupReferences();
      $impl.GlobalFixupReferences();
      for (var $l = 0, $end = this.FLoaded.FCount - 1; $l <= $end; $l++) {
        i = $l;
        rtl.getObject(this.FLoaded.Get(i)).Loaded();
      };
    };
    this.NextValue = function () {
      var Result = 0;
      Result = this.FDriver.NextValue();
      return Result;
    };
    this.Read = function (Buffer, Count) {
      this.FDriver.Read(Buffer,Count);
    };
    this.ReadBoolean = function () {
      var Result = false;
      var ValueType = 0;
      ValueType = this.FDriver.ReadValue();
      if (ValueType === $mod.TValueType.vaTrue) {
        Result = true}
       else if (ValueType === $mod.TValueType.vaFalse) {
        Result = false}
       else throw $mod.EReadError.$create("Create$1",[rtl.getResStr(pas.RTLConsts,"SInvalidPropertyValue")]);
      return Result;
    };
    this.ReadChar = function () {
      var Result = "\x00";
      var s = "";
      s = this.ReadString();
      if (s.length === 1) {
        Result = s.charAt(0)}
       else throw $mod.EReadError.$create("Create$1",[rtl.getResStr(pas.RTLConsts,"SInvalidPropertyValue")]);
      return Result;
    };
    this.ReadWideChar = function () {
      var Result = "\x00";
      var W = "";
      W = this.ReadWideString();
      if (W.length === 1) {
        Result = W.charAt(0)}
       else throw $mod.EReadError.$create("Create$1",[rtl.getResStr(pas.RTLConsts,"SInvalidPropertyValue")]);
      return Result;
    };
    this.ReadUnicodeChar = function () {
      var Result = "\x00";
      var U = "";
      U = this.ReadUnicodeString();
      if (U.length === 1) {
        Result = U.charAt(0)}
       else throw $mod.EReadError.$create("Create$1",[rtl.getResStr(pas.RTLConsts,"SInvalidPropertyValue")]);
      return Result;
    };
    this.ReadCollection = function (Collection) {
      var Item = null;
      Collection.BeginUpdate();
      if (!this.EndOfList()) Collection.Clear();
      while (!this.EndOfList()) {
        this.ReadListBegin();
        Item = Collection.Add();
        while (this.NextValue() !== $mod.TValueType.vaNull) this.ReadProperty(Item);
        this.ReadListEnd();
      };
      Collection.EndUpdate();
      this.ReadListEnd();
    };
    this.ReadComponent = function (Component) {
      var $Self = this;
      var Result = null;
      var Flags = {};
      function Recover(E, aComponent) {
        var Result = false;
        Result = false;
        if (!(($mod.TFilerFlag.ffInherited in Flags) || (Component != null))) aComponent.set(rtl.freeLoc(aComponent.get()));
        aComponent.set(null);
        $Self.FDriver.SkipComponent(false);
        Result = $Self.Error(E.FMessage);
        return Result;
      };
      var CompClassName = "";
      var Name = "";
      var n = 0;
      var ChildPos = 0;
      var SavedParent = null;
      var SavedLookupRoot = null;
      var ComponentClass = null;
      var C = null;
      var NewComponent = null;
      var SubComponents = null;
      this.FDriver.BeginComponent({get: function () {
          return Flags;
        }, set: function (v) {
          Flags = v;
        }},{get: function () {
          return ChildPos;
        }, set: function (v) {
          ChildPos = v;
        }},{get: function () {
          return CompClassName;
        }, set: function (v) {
          CompClassName = v;
        }},{get: function () {
          return Name;
        }, set: function (v) {
          Name = v;
        }});
      SavedParent = this.FParent;
      SavedLookupRoot = this.FLookupRoot;
      SubComponents = null;
      try {
        Result = Component;
        if (!(Result != null)) try {
          if ($mod.TFilerFlag.ffInherited in Flags) {
            if (this.FLookupRoot != null) {
              Result = this.FLookupRoot.FindComponent(Name)}
             else Result = null;
            if (!(Result != null)) {
              if (this.FOnAncestorNotFound != null) this.FOnAncestorNotFound($Self,Name,this.FindComponentClass(CompClassName),{get: function () {
                  return Result;
                }, set: function (v) {
                  Result = v;
                }});
              if (!(Result != null)) throw $mod.EReadError.$create("CreateFmt",[rtl.getResStr(pas.RTLConsts,"SAncestorNotFound"),pas.System.VarRecs(18,Name)]);
            };
            this.FParent = Result.GetParentComponent();
            if (!(this.FParent != null)) this.FParent = this.FRoot;
          } else {
            Result = null;
            ComponentClass = this.FindComponentClass(CompClassName);
            if (this.FOnCreateComponent != null) this.FOnCreateComponent($Self,ComponentClass,{get: function () {
                return Result;
              }, set: function (v) {
                Result = v;
              }});
            if (!(Result != null)) {
              NewComponent = Object.create(ComponentClass);
              NewComponent.$init();
              if ($mod.TFilerFlag.ffInline in Flags) NewComponent.FComponentState = rtl.unionSet(NewComponent.FComponentState,rtl.createSet($mod.TComponentStateItem.csLoading,$mod.TComponentStateItem.csInline));
              NewComponent.Create$1(this.FOwner);
              NewComponent.AfterConstruction();
              Result = NewComponent;
            };
            Result.FComponentState = rtl.includeSet(Result.FComponentState,$mod.TComponentStateItem.csLoading);
          };
        } catch ($e) {
          if (pas.SysUtils.Exception.isPrototypeOf($e)) {
            var E = $e;
            if (!Recover(E,{get: function () {
                return Result;
              }, set: function (v) {
                Result = v;
              }})) throw $e;
          } else throw $e
        };
        if (Result != null) try {
          Result.FComponentState = rtl.includeSet(Result.FComponentState,$mod.TComponentStateItem.csLoading);
          SubComponents = $mod.TList.$create("Create$1");
          for (var $l = 0, $end = Result.GetComponentCount() - 1; $l <= $end; $l++) {
            n = $l;
            C = Result.GetComponent(n);
            if ($mod.TComponentStyleItem.csSubComponent in C.FComponentStyle) {
              SubComponents.Add(C);
              C.FComponentState = rtl.includeSet(C.FComponentState,$mod.TComponentStateItem.csLoading);
            };
          };
          if (!($mod.TFilerFlag.ffInherited in Flags)) try {
            Result.SetParentComponent(this.FParent);
            if (this.FOnSetName != null) this.FOnSetName($Self,Result,{get: function () {
                return Name;
              }, set: function (v) {
                Name = v;
              }});
            Result.SetName(Name);
            if ($mod.FindGlobalComponent(Name) === Result) Result.FComponentState = rtl.includeSet(Result.FComponentState,$mod.TComponentStateItem.csInline);
          } catch ($e) {
            if (pas.SysUtils.Exception.isPrototypeOf($e)) {
              var E = $e;
              if (!Recover(E,{get: function () {
                  return Result;
                }, set: function (v) {
                  Result = v;
                }})) throw $e;
            } else throw $e
          };
          if (!(Result != null)) return Result;
          if ($mod.TComponentStateItem.csInline in Result.FComponentState) this.FLookupRoot = Result;
          Result.FComponentState = rtl.includeSet(Result.FComponentState,$mod.TComponentStateItem.csReading);
          for (var $l1 = 0, $end1 = SubComponents.GetCount() - 1; $l1 <= $end1; $l1++) {
            n = $l1;
            rtl.getObject(SubComponents.Get(n)).FComponentState = rtl.includeSet(rtl.getObject(SubComponents.Get(n)).FComponentState,$mod.TComponentStateItem.csReading);
          };
          Result.ReadState($Self);
          Result.FComponentState = rtl.excludeSet(Result.FComponentState,$mod.TComponentStateItem.csReading);
          for (var $l2 = 0, $end2 = SubComponents.GetCount() - 1; $l2 <= $end2; $l2++) {
            n = $l2;
            rtl.getObject(SubComponents.Get(n)).FComponentState = rtl.excludeSet(rtl.getObject(SubComponents.Get(n)).FComponentState,$mod.TComponentStateItem.csReading);
          };
          if ($mod.TFilerFlag.ffChildPos in Flags) this.FParent.SetChildOrder(Result,ChildPos);
          if (!(($mod.TFilerFlag.ffInherited in Flags) || ($mod.TComponentStateItem.csInline in Result.FComponentState)) || (this.FLoaded.IndexOf(Result) < 0)) {
            for (var $l3 = 0, $end3 = SubComponents.GetCount() - 1; $l3 <= $end3; $l3++) {
              n = $l3;
              this.FLoaded.Add(SubComponents.Get(n));
            };
            this.FLoaded.Add(Result);
          };
        } catch ($e) {
          if (($mod.TFilerFlag.ffInherited in Flags) || (Component != null)) Result = rtl.freeLoc(Result);
          throw $e;
        };
      } finally {
        this.FParent = SavedParent;
        this.FLookupRoot = SavedLookupRoot;
        SubComponents = rtl.freeLoc(SubComponents);
      };
      return Result;
    };
    this.ReadComponents = function (AOwner, AParent, Proc) {
      var Component = null;
      this.SetRoot(AOwner);
      this.FOwner = AOwner;
      this.FParent = AParent;
      this.BeginReferences();
      try {
        while (!this.EndOfList()) {
          this.FDriver.BeginRootComponent();
          Component = this.ReadComponent(null);
          if (Proc != null) Proc(Component);
        };
        this.ReadListEnd();
        this.FixupReferences();
      } finally {
        this.EndReferences();
      };
    };
    this.ReadFloat = function () {
      var Result = 0.0;
      if (this.FDriver.NextValue() === $mod.TValueType.vaDouble) {
        this.ReadValue();
        Result = this.FDriver.ReadFloat();
      } else Result = this.ReadNativeInt();
      return Result;
    };
    this.ReadCurrency = function () {
      var Result = 0;
      if (this.FDriver.NextValue() === $mod.TValueType.vaCurrency) {
        this.FDriver.ReadValue();
        Result = this.FDriver.ReadCurrency();
      } else Result = this.ReadInteger() * 10000;
      return Result;
    };
    this.ReadIdent = function () {
      var Result = "";
      var ValueType = 0;
      ValueType = this.FDriver.ReadValue();
      if (ValueType in rtl.createSet($mod.TValueType.vaIdent,$mod.TValueType.vaNil,$mod.TValueType.vaFalse,$mod.TValueType.vaTrue,$mod.TValueType.vaNull)) {
        Result = this.FDriver.ReadIdent(ValueType)}
       else throw $mod.EReadError.$create("Create$1",[rtl.getResStr(pas.RTLConsts,"SInvalidPropertyValue")]);
      return Result;
    };
    this.ReadInteger = function () {
      var Result = 0;
      var $tmp = this.FDriver.ReadValue();
      if ($tmp === $mod.TValueType.vaInt8) {
        Result = this.FDriver.ReadInt8()}
       else if ($tmp === $mod.TValueType.vaInt16) {
        Result = this.FDriver.ReadInt16()}
       else if ($tmp === $mod.TValueType.vaInt32) {
        Result = this.FDriver.ReadInt32()}
       else {
        throw $mod.EReadError.$create("Create$1",[rtl.getResStr(pas.RTLConsts,"SInvalidPropertyValue")]);
      };
      return Result;
    };
    this.ReadNativeInt = function () {
      var Result = 0;
      if (this.FDriver.NextValue() === $mod.TValueType.vaNativeInt) {
        this.FDriver.ReadValue();
        Result = this.FDriver.ReadNativeInt();
      } else Result = this.ReadInteger();
      return Result;
    };
    this.ReadSet = function (EnumType) {
      var Result = 0;
      if (this.FDriver.NextValue() === $mod.TValueType.vaSet) {
        this.FDriver.ReadValue();
        Result = this.FDriver.ReadSet(EnumType);
      } else Result = this.ReadInteger();
      return Result;
    };
    this.ReadListBegin = function () {
      this.CheckValue($mod.TValueType.vaList);
    };
    this.ReadListEnd = function () {
      this.CheckValue($mod.TValueType.vaNull);
    };
    this.ReadRootComponent = function (ARoot) {
      var Result = null;
      var Dummy = 0;
      var i = 0;
      var Flags = {};
      var CompClassName = "";
      var CompName = "";
      var ResultName = "";
      this.FDriver.BeginRootComponent();
      Result = null;
      try {
        this.FDriver.BeginComponent({get: function () {
            return Flags;
          }, set: function (v) {
            Flags = v;
          }},{get: function () {
            return Dummy;
          }, set: function (v) {
            Dummy = v;
          }},{get: function () {
            return CompClassName;
          }, set: function (v) {
            CompClassName = v;
          }},{get: function () {
            return CompName;
          }, set: function (v) {
            CompName = v;
          }});
        if (!(ARoot != null)) {
          Result = $mod.FindClass(CompClassName).$create("Create$1",[null]);
          Result.SetName(CompName);
        } else {
          Result = ARoot;
          if (!($mod.TComponentStateItem.csDesigning in Result.FComponentState)) {
            Result.FComponentState = rtl.unionSet(Result.FComponentState,rtl.createSet($mod.TComponentStateItem.csLoading,$mod.TComponentStateItem.csReading));
            i = 0;
            ResultName = CompName;
            while ($mod.FindGlobalComponent(ResultName) != null) {
              i += 1;
              ResultName = CompName + "_" + pas.SysUtils.IntToStr(i);
            };
            Result.SetName(ResultName);
          };
        };
        this.FRoot = Result;
        this.FLookupRoot = Result;
        if ($impl.GlobalLoaded != null) {
          this.FLoaded = $impl.GlobalLoaded}
         else this.FLoaded = $mod.TFPList.$create("Create");
        try {
          if (this.FLoaded.IndexOf(this.FRoot) < 0) this.FLoaded.Add(this.FRoot);
          this.FOwner = this.FRoot;
          this.FRoot.FComponentState = rtl.unionSet(this.FRoot.FComponentState,rtl.createSet($mod.TComponentStateItem.csLoading,$mod.TComponentStateItem.csReading));
          this.FRoot.ReadState(this);
          this.FRoot.FComponentState = rtl.excludeSet(this.FRoot.FComponentState,$mod.TComponentStateItem.csReading);
          if (!($impl.GlobalLoaded != null)) for (var $l = 0, $end = this.FLoaded.FCount - 1; $l <= $end; $l++) {
            i = $l;
            rtl.getObject(this.FLoaded.Get(i)).Loaded();
          };
        } finally {
          if (!($impl.GlobalLoaded != null)) rtl.free(this,"FLoaded");
          this.FLoaded = null;
        };
        $impl.GlobalFixupReferences();
      } catch ($e) {
        $mod.RemoveFixupReferences(ARoot,"");
        if (!(ARoot != null)) Result = rtl.freeLoc(Result);
        throw $e;
      };
      return Result;
    };
    this.ReadVariant = function () {
      var Result = undefined;
      var nv = 0;
      nv = this.NextValue();
      var $tmp = nv;
      if ($tmp === $mod.TValueType.vaNil) {
        Result = undefined;
        this.ReadValue();
      } else if ($tmp === $mod.TValueType.vaNull) {
        Result = null;
        this.ReadValue();
      } else if (($tmp === $mod.TValueType.vaInt8) || ($tmp === $mod.TValueType.vaInt16) || ($tmp === $mod.TValueType.vaInt32)) {
        Result = this.ReadInteger();
      } else if ($tmp === $mod.TValueType.vaNativeInt) {
        Result = this.ReadNativeInt();
      } else if (($tmp === $mod.TValueType.vaFalse) || ($tmp === $mod.TValueType.vaTrue)) {
        Result = nv !== $mod.TValueType.vaFalse;
        this.ReadValue();
      } else if ($tmp === $mod.TValueType.vaCurrency) {
        Result = this.ReadCurrency() / 10000;
      } else if ($tmp === $mod.TValueType.vaDouble) {
        Result = this.ReadFloat();
      } else if ($tmp === $mod.TValueType.vaString) {
        Result = this.ReadString();
      } else {
        throw $mod.EReadError.$create("CreateFmt",[rtl.getResStr(pas.RTLConsts,"SUnsupportedPropertyVariantType"),pas.System.VarRecs(0,nv)]);
      };
      return Result;
    };
    this.ReadSignature = function () {
      this.FDriver.ReadSignature();
    };
    this.ReadString = function () {
      var Result = "";
      var StringType = 0;
      StringType = this.FDriver.ReadValue();
      if (StringType === $mod.TValueType.vaString) {
        Result = this.FDriver.ReadString(StringType)}
       else throw $mod.EReadError.$create("Create$1",[rtl.getResStr(pas.RTLConsts,"SInvalidPropertyValue")]);
      return Result;
    };
    this.ReadWideString = function () {
      var Result = "";
      Result = this.ReadString();
      return Result;
    };
    this.ReadUnicodeString = function () {
      var Result = "";
      Result = this.ReadString();
      return Result;
    };
    this.ReadValue = function () {
      var Result = 0;
      Result = this.FDriver.ReadValue();
      return Result;
    };
    this.CopyValue = function (Writer) {
      var $tmp = this.FDriver.NextValue();
      if ($tmp === $mod.TValueType.vaNull) {
        Writer.WriteIdent("NULL")}
       else if ($tmp === $mod.TValueType.vaFalse) {
        Writer.WriteIdent("FALSE")}
       else if ($tmp === $mod.TValueType.vaTrue) {
        Writer.WriteIdent("TRUE")}
       else if ($tmp === $mod.TValueType.vaNil) {
        Writer.WriteIdent("NIL")}
       else if (($tmp === $mod.TValueType.vaInt8) || ($tmp === $mod.TValueType.vaInt16) || ($tmp === $mod.TValueType.vaInt32)) {
        Writer.WriteInteger(this.ReadInteger())}
       else if ($tmp === $mod.TValueType.vaDouble) {
        Writer.WriteFloat(this.ReadFloat())}
       else if ($tmp === $mod.TValueType.vaString) {
        Writer.WriteString(this.ReadString())}
       else if ($tmp === $mod.TValueType.vaIdent) {
        Writer.WriteIdent(this.ReadIdent())}
       else if ($tmp === $mod.TValueType.vaNativeInt) Writer.WriteInteger$1(this.ReadNativeInt());
    };
    var $r = this.$rtti;
    $r.addMethod("Create$1",2,[["Stream",$mod.$rtti["TStream"]]]);
  });
  rtl.createClass(this,"TAbstractObjectWriter",pas.System.TObject,function () {
  });
  rtl.createClass(this,"TBinaryObjectWriter",this.TAbstractObjectWriter,function () {
    this.$init = function () {
      $mod.TAbstractObjectWriter.$init.call(this);
      this.FStream = null;
      this.FBuffer = null;
      this.FBufSize = 0;
      this.FBufPos = 0;
      this.FBufEnd = 0;
    };
    this.$final = function () {
      this.FStream = undefined;
      $mod.TAbstractObjectWriter.$final.call(this);
    };
    this.WriteWord = function (w) {
      this.FStream.WriteBufferData$12(w);
    };
    this.WriteDWord = function (lw) {
      this.FStream.WriteBufferData$14(lw);
    };
    this.WriteValue = function (Value) {
      var b = 0;
      b = Value;
      this.FStream.WriteBufferData$8(b);
    };
    this.Create$1 = function (Stream) {
      pas.System.TObject.Create.call(this);
      if (Stream === null) throw $mod.EWriteError.$create("Create$1",[rtl.getResStr(pas.RTLConsts,"SEmptyStreamIllegalWriter")]);
      this.FStream = Stream;
      return this;
    };
    this.WriteSignature = function () {
      this.FStream.WriteBufferData$14(809914452);
    };
    this.BeginCollection = function () {
      this.WriteValue($mod.TValueType.vaCollection);
    };
    this.BeginComponent = function (Component, Flags, ChildPos) {
      var Prefix = 0;
      if (rtl.neSet(Flags,{})) {
        Prefix = 0;
        if ($mod.TFilerFlag.ffInherited in Flags) Prefix = Prefix | 0x1;
        if ($mod.TFilerFlag.ffChildPos in Flags) Prefix = Prefix | 0x2;
        if ($mod.TFilerFlag.ffInline in Flags) Prefix = Prefix | 0x4;
        Prefix = Prefix | 0xf0;
        this.FStream.WriteBufferData$8(Prefix);
        if ($mod.TFilerFlag.ffChildPos in Flags) this.WriteInteger(ChildPos);
      };
      this.WriteStr(Component.$classname);
      this.WriteStr(Component.FName);
    };
    this.BeginList = function () {
      this.WriteValue($mod.TValueType.vaList);
    };
    this.EndList = function () {
      this.WriteValue($mod.TValueType.vaNull);
    };
    this.BeginProperty = function (PropName) {
      this.WriteStr(PropName);
    };
    this.EndProperty = function () {
    };
    this.FlushBuffer = function () {
    };
    this.Write = function (Buffer, Count) {
      this.FStream.Write(Buffer,Count);
    };
    this.WriteBinary = function (Buffer, Count) {
      this.WriteValue($mod.TValueType.vaBinary);
      this.WriteDWord(Count >>> 0);
      this.FStream.Write(Buffer,Count);
    };
    this.WriteBoolean = function (Value) {
      if (Value) {
        this.WriteValue($mod.TValueType.vaTrue)}
       else this.WriteValue($mod.TValueType.vaFalse);
    };
    this.WriteFloat = function (Value) {
      this.WriteValue($mod.TValueType.vaDouble);
      this.FStream.WriteBufferData$20(Value);
    };
    this.WriteCurrency = function (Value) {
      var F = 0.0;
      this.WriteValue($mod.TValueType.vaCurrency);
      F = Value / 10000;
      this.FStream.WriteBufferData$20(F);
    };
    this.WriteIdent = function (Ident) {
      if (pas.SysUtils.UpperCase(Ident) === "NIL") {
        this.WriteValue($mod.TValueType.vaNil)}
       else if (pas.SysUtils.UpperCase(Ident) === "FALSE") {
        this.WriteValue($mod.TValueType.vaFalse)}
       else if (pas.SysUtils.UpperCase(Ident) === "TRUE") {
        this.WriteValue($mod.TValueType.vaTrue)}
       else if (pas.SysUtils.UpperCase(Ident) === "NULL") {
        this.WriteValue($mod.TValueType.vaNull)}
       else {
        this.WriteValue($mod.TValueType.vaIdent);
        this.WriteStr(Ident);
      };
    };
    this.WriteInteger = function (Value) {
      var s = 0;
      var i = 0;
      var l = 0;
      if ((Value >= -128) && (Value <= 127)) {
        this.WriteValue($mod.TValueType.vaInt8);
        s = Value;
        this.FStream.WriteBufferData$6(s);
      } else if ((Value >= -32768) && (Value <= 32767)) {
        this.WriteValue($mod.TValueType.vaInt16);
        i = Value;
        this.WriteWord(i & 65535);
      } else if ((Value >= -0x80000000) && (Value <= 0x7fffffff)) {
        this.WriteValue($mod.TValueType.vaInt32);
        l = Value;
        this.WriteDWord(l >>> 0);
      } else {
        this.WriteValue($mod.TValueType.vaNativeInt);
        this.FStream.WriteBufferData$16(Value);
      };
    };
    this.WriteNativeInt = function (Value) {
      var s = 0;
      var i = 0;
      var l = 0;
      if (Value <= 127) {
        this.WriteValue($mod.TValueType.vaInt8);
        s = Value;
        this.FStream.WriteBufferData$6(s);
      } else if (Value <= 32767) {
        this.WriteValue($mod.TValueType.vaInt16);
        i = Value;
        this.WriteWord(i & 65535);
      } else if (Value <= 0x7fffffff) {
        this.WriteValue($mod.TValueType.vaInt32);
        l = Value;
        this.WriteDWord(l >>> 0);
      } else {
        this.WriteValue($mod.TValueType.vaNativeInt);
        this.FStream.WriteBufferData$16(Value);
      };
    };
    this.WriteMethodName = function (Name) {
      if (Name.length > 0) {
        this.WriteValue($mod.TValueType.vaIdent);
        this.WriteStr(Name);
      } else this.WriteValue($mod.TValueType.vaNil);
    };
    this.WriteSet = function (Value, SetType) {
      var i = 0;
      var b = 0;
      this.WriteValue($mod.TValueType.vaSet);
      b = 1;
      for (i = 0; i <= 31; i++) {
        if ((Value & b) !== 0) {
          this.WriteStr(pas.TypInfo.GetEnumName(SetType,i));
        };
        b = b << 1;
      };
      this.WriteStr("");
    };
    this.WriteStr = function (Value) {
      var len = 0;
      var i = 0;
      var b = 0;
      len = Value.length;
      if (len > 255) len = 255;
      b = len;
      this.FStream.WriteBufferData$8(b);
      for (var $l = 1, $end = len; $l <= $end; $l++) {
        i = $l;
        this.FStream.WriteBufferData$4(Value.charAt(i - 1));
      };
    };
    this.WriteString = function (Value) {
      var i = 0;
      var len = 0;
      len = Value.length;
      this.WriteValue($mod.TValueType.vaString);
      this.WriteDWord(len);
      for (var $l = 1, $end = len; $l <= $end; $l++) {
        i = $l;
        this.FStream.WriteBufferData$4(Value.charAt(i - 1));
      };
    };
    this.WriteWideString = function (Value) {
      this.WriteString(Value);
    };
    this.WriteUnicodeString = function (Value) {
      this.WriteString(Value);
    };
    this.WriteVariant = function (VarValue) {
      if (pas.JS.isUndefined(VarValue)) {
        this.WriteValue($mod.TValueType.vaNil)}
       else if (pas.JS.isNull(VarValue)) {
        this.WriteValue($mod.TValueType.vaNull)}
       else if (rtl.isNumber(VarValue)) {
        if (pas.System.Frac(rtl.getNumber(VarValue)) === 0) {
          this.WriteInteger(rtl.trunc(VarValue))}
         else this.WriteFloat(rtl.getNumber(VarValue));
      } else if (pas.JS.isBoolean(VarValue)) {
        this.WriteBoolean(!(VarValue == false))}
       else if (rtl.isString(VarValue)) {
        this.WriteString("" + VarValue)}
       else throw $mod.EWriteError.$create("Create$1",[rtl.getResStr(pas.RTLConsts,"SUnsupportedPropertyVariantType")]);
    };
    var $r = this.$rtti;
    $r.addMethod("Create$1",2,[["Stream",$mod.$rtti["TStream"]]]);
  });
  this.$rtti.$MethodVar("TFindAncestorEvent",{procsig: rtl.newTIProcSig([["Writer",this.$rtti["TWriter"]],["Component",this.$rtti["TComponent"]],["Name",rtl.string,2],["Ancestor",this.$rtti["TComponent"],1],["RootAncestor",this.$rtti["TComponent"],1]]), methodkind: 0});
  this.$rtti.$MethodVar("TWriteMethodPropertyEvent",{procsig: rtl.newTIProcSig([["Writer",this.$rtti["TWriter"]],["Instance",this.$rtti["TPersistent"]],["PropInfo",pas.TypInfo.$rtti["TTypeMemberProperty"]],["MethodValue",pas.System.$rtti["TMethod"],2],["DefMethodValue",pas.System.$rtti["TMethod"],2],["Handled",rtl.boolean,1]]), methodkind: 0});
  rtl.createClass(this,"TWriter",this.TFiler,function () {
    this.$init = function () {
      $mod.TFiler.$init.call(this);
      this.FDriver = null;
      this.FDestroyDriver = false;
      this.FRootAncestor = null;
      this.FPropPath = "";
      this.FAncestors = null;
      this.FAncestorPos = 0;
      this.FCurrentPos = 0;
      this.FOnFindAncestor = null;
      this.FOnWriteMethodProperty = null;
      this.FOnWriteStringProperty = null;
    };
    this.$final = function () {
      this.FDriver = undefined;
      this.FRootAncestor = undefined;
      this.FAncestors = undefined;
      this.FOnFindAncestor = undefined;
      this.FOnWriteMethodProperty = undefined;
      this.FOnWriteStringProperty = undefined;
      $mod.TFiler.$final.call(this);
    };
    this.AddToAncestorList = function (Component) {
      this.FAncestors.AddObject(Component.FName,$impl.TPosComponent.$create("Create$1",[this.FAncestors.GetCount(),Component]));
    };
    this.WriteComponentData = function (Instance) {
      var Flags = {};
      Flags = {};
      if ((this.FAncestor != null) && (!($mod.TComponentStateItem.csInline in Instance.FComponentState) || (($mod.TComponentStateItem.csAncestor in Instance.FComponentState) && (this.FAncestors !== null)))) {
        Flags = rtl.createSet($mod.TFilerFlag.ffInherited)}
       else if ($mod.TComponentStateItem.csInline in Instance.FComponentState) Flags = rtl.createSet($mod.TFilerFlag.ffInline);
      if ((this.FAncestors !== null) && ((this.FCurrentPos !== this.FAncestorPos) || (this.FAncestor === null))) Flags = rtl.includeSet(Flags,$mod.TFilerFlag.ffChildPos);
      this.FDriver.BeginComponent(Instance,rtl.refSet(Flags),this.FCurrentPos);
      if (this.FAncestors !== null) this.FCurrentPos += 1;
      this.WriteProperties(Instance);
      this.WriteListEnd();
      if (!this.FIgnoreChildren) this.WriteChildren(Instance);
    };
    this.DetermineAncestor = function (Component) {
      var I = 0;
      if (!(this.FAncestors != null)) return;
      I = this.FAncestors.IndexOf(Component.FName);
      if (I === -1) {
        this.FAncestor = null;
        this.FAncestorPos = -1;
      } else {
        this.FAncestor = this.FAncestors.GetObject(I).FComponent;
        this.FAncestorPos = this.FAncestors.GetObject(I).FPos;
      };
    };
    this.DoFindAncestor = function (Component) {
      var C = null;
      if (this.FOnFindAncestor != null) if ((this.FAncestor === null) || $mod.TComponent.isPrototypeOf(this.FAncestor)) {
        C = this.FAncestor;
        this.FOnFindAncestor(this,Component,Component.FName,{get: function () {
            return C;
          }, set: function (v) {
            C = v;
          }},{p: this, get: function () {
            return this.p.FRootAncestor;
          }, set: function (v) {
            this.p.FRootAncestor = v;
          }});
        this.FAncestor = C;
      };
    };
    this.SetRoot = function (ARoot) {
      $mod.TFiler.SetRoot.call(this,ARoot);
      this.FLookupRoot = ARoot;
    };
    this.WriteBinary = function (AWriteData) {
      var MemBuffer = null;
      MemBuffer = $mod.TBytesStream.$create("Create");
      try {
        AWriteData(MemBuffer);
        this.FDriver.WriteBinary(MemBuffer.GetBytes(),MemBuffer.GetSize());
      } finally {
        MemBuffer = rtl.freeLoc(MemBuffer);
      };
    };
    this.WriteProperty = function (Instance, PropInfo) {
      var HasAncestor = false;
      var PropType = null;
      var N = 0;
      var Value = 0;
      var DefValue = 0;
      var Ident = "";
      var IntToIdentFn = null;
      var FloatValue = 0.0;
      var DefFloatValue = 0.0;
      var MethodValue = pas.System.TMethod.$new();
      var DefMethodValue = pas.System.TMethod.$new();
      var StrValue = "";
      var DefStrValue = "";
      var AncestorObj = null;
      var C = null;
      var Component = null;
      var ObjValue = null;
      var SavedAncestor = null;
      var Key = "";
      var SavedPropPath = "";
      var Name = "";
      var lMethodName = "";
      var VarValue = undefined;
      var DefVarValue = undefined;
      var BoolValue = false;
      var DefBoolValue = false;
      var Handled = false;
      var O = null;
      if (PropInfo.getter === "") return;
      PropType = PropInfo.typeinfo;
      if (PropInfo.setter === "") {
        if (PropType.kind !== pas.System.TTypeKind.tkClass) return;
        ObjValue = pas.TypInfo.GetObjectProp$2(Instance,PropInfo);
        if (!ObjValue.$class.InheritsFrom($mod.TComponent) || !($mod.TComponentStyleItem.csSubComponent in ObjValue.FComponentStyle)) return;
      };
      HasAncestor = (this.FAncestor != null) && ((Instance === this.FRoot) || (Instance.$class.ClassType() === this.FAncestor.$class.ClassType()));
      var $tmp = PropType.kind;
      if (($tmp === pas.System.TTypeKind.tkInteger) || ($tmp === pas.System.TTypeKind.tkChar) || ($tmp === pas.System.TTypeKind.tkEnumeration) || ($tmp === pas.System.TTypeKind.tkSet)) {
        Value = pas.TypInfo.GetOrdProp$1(Instance,PropInfo);
        if (HasAncestor) {
          DefValue = pas.TypInfo.GetOrdProp$1(this.FAncestor,PropInfo)}
         else {
          if (PropType.kind !== pas.System.TTypeKind.tkSet) {
            DefValue = rtl.trunc(PropInfo.Default)}
           else {
            O = PropInfo.Default;
            DefValue = 0;
            for (Key in O) {
              N = parseInt(Key,10);
              if (N < 32) DefValue = DefValue + (1 << N);
            };
          };
        };
        if ((Value !== DefValue) || (DefValue === 0x80000000)) {
          this.FDriver.BeginProperty(this.FPropPath + PropInfo.name);
          var $tmp1 = PropType.kind;
          if ($tmp1 === pas.System.TTypeKind.tkInteger) {
            IntToIdentFn = $mod.FindIntToIdent(PropInfo.typeinfo);
            if ((IntToIdentFn != null) && IntToIdentFn(Value,{get: function () {
                return Ident;
              }, set: function (v) {
                Ident = v;
              }})) {
              this.WriteIdent(Ident)}
             else this.WriteInteger(Value);
          } else if ($tmp1 === pas.System.TTypeKind.tkChar) {
            this.WriteChar(String.fromCharCode(Value))}
           else if ($tmp1 === pas.System.TTypeKind.tkSet) {
            this.FDriver.WriteSet(Value,PropType.comptype);
          } else if ($tmp1 === pas.System.TTypeKind.tkEnumeration) this.WriteIdent(pas.TypInfo.GetEnumName(PropType,Value));
          this.FDriver.EndProperty();
        };
      } else if ($tmp === pas.System.TTypeKind.tkDouble) {
        FloatValue = pas.TypInfo.GetFloatProp$1(Instance,PropInfo);
        if (HasAncestor) {
          DefFloatValue = pas.TypInfo.GetFloatProp$1(this.FAncestor,PropInfo)}
         else {
          DefFloatValue = rtl.getNumber(PropInfo.Default);
        };
        if ((FloatValue !== DefFloatValue) || (!HasAncestor && (pas.System.Int(DefFloatValue) === 0x80000000))) {
          this.FDriver.BeginProperty(this.FPropPath + PropInfo.name);
          this.WriteFloat(FloatValue);
          this.FDriver.EndProperty();
        };
      } else if ($tmp === pas.System.TTypeKind.tkMethod) {
        MethodValue.$assign(pas.TypInfo.GetMethodProp(Instance,PropInfo));
        if (HasAncestor) {
          DefMethodValue.$assign(pas.TypInfo.GetMethodProp(this.FAncestor,PropInfo))}
         else {
          DefMethodValue.Data = null;
          DefMethodValue.Code = null;
        };
        Handled = false;
        if (this.FOnWriteMethodProperty != null) this.FOnWriteMethodProperty(this,Instance,PropInfo,MethodValue,DefMethodValue,{get: function () {
            return Handled;
          }, set: function (v) {
            Handled = v;
          }});
        if (rtl.isString(MethodValue.Code)) {
          lMethodName = MethodValue.Code}
         else lMethodName = this.FLookupRoot.$class.MethodName(MethodValue.Code);
        if (!Handled && (MethodValue.Code !== DefMethodValue.Code) && (!(MethodValue.Code != null) || (lMethodName.length > 0))) {
          this.FDriver.BeginProperty(this.FPropPath + PropInfo.name);
          if (MethodValue.Code != null) {
            this.FDriver.WriteMethodName(lMethodName)}
           else this.FDriver.WriteMethodName("");
          this.FDriver.EndProperty();
        };
      } else if ($tmp === pas.System.TTypeKind.tkString) {
        StrValue = pas.TypInfo.GetStrProp$1(Instance,PropInfo);
        if (HasAncestor) {
          DefStrValue = pas.TypInfo.GetStrProp$1(this.FAncestor,PropInfo)}
         else {
          DefValue = rtl.trunc(PropInfo.Default);
          DefStrValue = rtl.strSetLength(DefStrValue,0);
        };
        if ((StrValue !== DefStrValue) || (!HasAncestor && (DefValue === 0x80000000))) {
          this.FDriver.BeginProperty(this.FPropPath + PropInfo.name);
          if (this.FOnWriteStringProperty != null) this.FOnWriteStringProperty(this,Instance,PropInfo,{get: function () {
              return StrValue;
            }, set: function (v) {
              StrValue = v;
            }});
          this.WriteString(StrValue);
          this.FDriver.EndProperty();
        };
      } else if ($tmp === pas.System.TTypeKind.tkJSValue) {
        VarValue = pas.TypInfo.GetJSValueProp$3(Instance,PropInfo);
        if (HasAncestor) {
          DefVarValue = pas.TypInfo.GetJSValueProp$3(this.FAncestor,PropInfo)}
         else DefVarValue = null;
        if (VarValue != DefVarValue) {
          this.FDriver.BeginProperty(this.FPropPath + PropInfo.name);
          this.WriteVariant(VarValue);
          this.FDriver.EndProperty();
        };
      } else if ($tmp === pas.System.TTypeKind.tkClass) {
        ObjValue = pas.TypInfo.GetObjectProp$2(Instance,PropInfo);
        if (HasAncestor) {
          AncestorObj = pas.TypInfo.GetObjectProp$2(this.FAncestor,PropInfo);
          if ($mod.TComponent.isPrototypeOf(AncestorObj) && $mod.TComponent.isPrototypeOf(ObjValue)) {
            if ((AncestorObj !== ObjValue) && (AncestorObj.FOwner === this.FRootAncestor) && (ObjValue.FOwner === this.FRoot) && (pas.SysUtils.UpperCase(AncestorObj.FName) === pas.SysUtils.UpperCase(ObjValue.FName))) {
              AncestorObj = ObjValue;
            };
          };
        } else AncestorObj = null;
        if (!(ObjValue != null)) {
          if (ObjValue !== AncestorObj) {
            this.FDriver.BeginProperty(this.FPropPath + PropInfo.name);
            this.FDriver.WriteIdent("NIL");
            this.FDriver.EndProperty();
          };
        } else if (ObjValue.$class.InheritsFrom($mod.TPersistent)) {
          if (ObjValue.$class.InheritsFrom($mod.TComponent) && (!($mod.TComponentStyleItem.csSubComponent in ObjValue.FComponentStyle) || ((ObjValue.FOwner !== Instance) && (ObjValue.FOwner !== null)))) {
            Component = ObjValue;
            if ((ObjValue !== AncestorObj) && !($mod.TComponentStyleItem.csTransient in Component.FComponentStyle)) {
              Name = "";
              C = Component;
              while ((C !== null) && (C.FName !== "")) {
                if (Name !== "") Name = "." + Name;
                if (C.FOwner === this.FLookupRoot) {
                  Name = C.FName + Name;
                  break;
                } else if (C === this.FLookupRoot) {
                  Name = "Owner" + Name;
                  break;
                };
                Name = C.FName + Name;
                C = C.FOwner;
              };
              if ((C === null) && (Component.FOwner === null)) if (Name !== "") Name = Name + ".Owner";
              if (Name.length > 0) {
                this.FDriver.BeginProperty(this.FPropPath + PropInfo.name);
                this.WriteIdent(Name);
                this.FDriver.EndProperty();
              };
            };
          } else {
            SavedAncestor = this.FAncestor;
            SavedPropPath = this.FPropPath;
            try {
              this.FPropPath = this.FPropPath + PropInfo.name + ".";
              if (HasAncestor) this.FAncestor = pas.TypInfo.GetObjectProp$2(this.FAncestor,PropInfo);
              this.WriteProperties(ObjValue);
            } finally {
              this.FAncestor = SavedAncestor;
              this.FPropPath = SavedPropPath;
            };
            if (ObjValue.$class.InheritsFrom($mod.TCollection)) {
              if (!HasAncestor || !$mod.CollectionsEqual$1(ObjValue,pas.TypInfo.GetObjectProp$2(this.FAncestor,PropInfo),this.FRoot,this.FRootAncestor)) {
                this.FDriver.BeginProperty(this.FPropPath + PropInfo.name);
                SavedPropPath = this.FPropPath;
                try {
                  this.FPropPath = rtl.strSetLength(this.FPropPath,0);
                  this.WriteCollection(ObjValue);
                } finally {
                  this.FPropPath = SavedPropPath;
                  this.FDriver.EndProperty();
                };
              };
            };
          };
        };
      } else if ($tmp === pas.System.TTypeKind.tkBool) {
        BoolValue = pas.TypInfo.GetOrdProp$1(Instance,PropInfo) !== 0;
        if (HasAncestor) {
          DefBoolValue = pas.TypInfo.GetOrdProp$1(this.FAncestor,PropInfo) !== 0}
         else {
          DefBoolValue = PropInfo.Default != 0;
          DefValue = rtl.trunc(PropInfo.Default);
        };
        if ((BoolValue !== DefBoolValue) || (DefValue === 0x80000000)) {
          this.FDriver.BeginProperty(this.FPropPath + PropInfo.name);
          this.WriteBoolean(BoolValue);
          this.FDriver.EndProperty();
        };
      } else if ($tmp === pas.System.TTypeKind.tkInterface) ;
    };
    this.WriteProperties = function (Instance) {
      var PropCount = 0;
      var i = 0;
      var PropList = [];
      PropList = pas.TypInfo.GetPropList$3(Instance);
      PropCount = rtl.length(PropList);
      if (PropCount > 0) for (var $l = 0, $end = PropCount - 1; $l <= $end; $l++) {
        i = $l;
        if (pas.TypInfo.IsStoredProp(Instance,PropList[i])) this.WriteProperty(Instance,PropList[i]);
      };
      Instance.DefineProperties(this);
    };
    this.WriteChildren = function (Component) {
      var SRoot = null;
      var SRootA = null;
      var SList = null;
      var SPos = 0;
      var I = 0;
      var SAncestorPos = 0;
      var O = null;
      SRoot = this.FRoot;
      SRootA = this.FRootAncestor;
      SList = this.FAncestors;
      SPos = this.FCurrentPos;
      SAncestorPos = this.FAncestorPos;
      try {
        this.FAncestors = null;
        this.FCurrentPos = 0;
        this.FAncestorPos = -1;
        if ($mod.TComponentStateItem.csInline in Component.FComponentState) this.FRoot = Component;
        if ($mod.TComponent.isPrototypeOf(this.FAncestor)) {
          this.FAncestors = $mod.TStringList.$create("Create$1");
          if ($mod.TComponentStateItem.csInline in this.FAncestor.FComponentState) this.FRootAncestor = this.FAncestor;
          this.FAncestor.GetChildren(rtl.createCallback(this,"AddToAncestorList"),this.FRootAncestor);
          this.FAncestors.SetSorted(true);
        };
        try {
          Component.GetChildren(rtl.createCallback(this,"WriteComponent"),this.FRoot);
        } finally {
          if (this.FAncestors != null) for (var $l = 0, $end = this.FAncestors.GetCount() - 1; $l <= $end; $l++) {
            I = $l;
            O = this.FAncestors.GetObject(I);
            this.FAncestors.PutObject(I,null);
            O = rtl.freeLoc(O);
          };
          pas.SysUtils.FreeAndNil({p: this, get: function () {
              return this.p.FAncestors;
            }, set: function (v) {
              this.p.FAncestors = v;
            }});
        };
      } finally {
        this.FAncestors = SList;
        this.FRoot = SRoot;
        this.FRootAncestor = SRootA;
        this.FCurrentPos = SPos;
        this.FAncestorPos = SAncestorPos;
      };
    };
    this.CreateDriver = function (Stream) {
      var Result = null;
      Result = $mod.TBinaryObjectWriter.$create("Create$1",[Stream]);
      return Result;
    };
    this.Create$1 = function (ADriver) {
      pas.System.TObject.Create.call(this);
      this.FDriver = ADriver;
      return this;
    };
    this.Create$2 = function (Stream) {
      pas.System.TObject.Create.call(this);
      if (Stream === null) throw $mod.EWriteError.$create("Create$1",[rtl.getResStr(pas.RTLConsts,"SEmptyStreamIllegalWriter")]);
      this.FDriver = this.CreateDriver(Stream);
      this.FDestroyDriver = true;
      return this;
    };
    this.Destroy = function () {
      if (this.FDestroyDriver) rtl.free(this,"FDriver");
      pas.System.TObject.Destroy.call(this);
    };
    this.DefineProperty = function (Name, ReadData, AWriteData, HasData) {
      if (HasData && (AWriteData != null)) {
        this.FDriver.BeginProperty(this.FPropPath + Name);
        AWriteData(this);
        this.FDriver.EndProperty();
      } else if (ReadData != null) ;
    };
    this.DefineBinaryProperty = function (Name, ReadData, AWriteData, HasData) {
      if (HasData && (AWriteData != null)) {
        this.FDriver.BeginProperty(this.FPropPath + Name);
        this.WriteBinary(AWriteData);
        this.FDriver.EndProperty();
      } else if (ReadData != null) ;
    };
    this.FlushBuffer = function () {
      this.FDriver.FlushBuffer();
    };
    this.Write = function (Buffer, Count) {
      this.FDriver.Write(Buffer,Count);
    };
    this.WriteBoolean = function (Value) {
      this.FDriver.WriteBoolean(Value);
    };
    this.WriteCollection = function (Value) {
      var i = 0;
      this.FDriver.BeginCollection();
      if (Value != null) for (var $l = 0, $end = Value.GetCount() - 1; $l <= $end; $l++) {
        i = $l;
        this.WriteListBegin();
        this.WriteProperties(Value.GetItem(i));
        this.WriteListEnd();
      };
      this.WriteListEnd();
    };
    this.WriteComponent = function (Component) {
      var SA = null;
      var SR = null;
      var SRA = null;
      SR = this.FRoot;
      SA = this.FAncestor;
      SRA = this.FRootAncestor;
      try {
        Component.FComponentState = rtl.unionSet(Component.FComponentState,rtl.createSet($mod.TComponentStateItem.csWriting));
        try {
          this.DetermineAncestor(Component);
          this.DoFindAncestor(Component);
          Component.WriteState(this);
          this.FDriver.EndList();
        } finally {
          Component.FComponentState = rtl.diffSet(Component.FComponentState,rtl.createSet($mod.TComponentStateItem.csWriting));
        };
      } finally {
        this.FAncestor = SA;
        this.FRoot = SR;
        this.FRootAncestor = SRA;
      };
    };
    this.WriteChar = function (Value) {
      this.WriteString(Value);
    };
    this.WriteWideChar = function (Value) {
      this.WriteWideString(Value);
    };
    this.WriteDescendent = function (ARoot, AAncestor) {
      this.FRoot = ARoot;
      this.FAncestor = AAncestor;
      this.FRootAncestor = AAncestor;
      this.FLookupRoot = ARoot;
      this.WriteSignature();
      this.WriteComponent(ARoot);
    };
    this.WriteFloat = function (Value) {
      this.FDriver.WriteFloat(Value);
    };
    this.WriteCurrency = function (Value) {
      this.FDriver.WriteCurrency(Value);
    };
    this.WriteIdent = function (Ident) {
      this.FDriver.WriteIdent(Ident);
    };
    this.WriteInteger = function (Value) {
      this.FDriver.WriteInteger(Value);
    };
    this.WriteInteger$1 = function (Value) {
      this.FDriver.WriteInteger(Value);
    };
    this.WriteSet = function (Value, SetType) {
      this.FDriver.WriteSet(Value,SetType);
    };
    this.WriteListBegin = function () {
      this.FDriver.BeginList();
    };
    this.WriteListEnd = function () {
      this.FDriver.EndList();
    };
    this.WriteSignature = function () {
      this.FDriver.WriteSignature();
    };
    this.WriteRootComponent = function (ARoot) {
      this.WriteDescendent(ARoot,null);
    };
    this.WriteString = function (Value) {
      this.FDriver.WriteString(Value);
    };
    this.WriteWideString = function (Value) {
      this.FDriver.WriteWideString(Value);
    };
    this.WriteUnicodeString = function (Value) {
      this.FDriver.WriteUnicodeString(Value);
    };
    this.WriteVariant = function (VarValue) {
      this.FDriver.WriteVariant(VarValue);
    };
    var $r = this.$rtti;
    $r.addMethod("Create$1",2,[["ADriver",$mod.$rtti["TAbstractObjectWriter"]]]);
    $r.addMethod("Create$2",2,[["Stream",$mod.$rtti["TStream"]]]);
  });
  this.TParserToken = {"0": "toUnknown", toUnknown: 0, "1": "toEOF", toEOF: 1, "2": "toSymbol", toSymbol: 2, "3": "ToString", ToString: 3, "4": "toInteger", toInteger: 4, "5": "toFloat", toFloat: 5, "6": "toMinus", toMinus: 6, "7": "toSetStart", toSetStart: 7, "8": "toListStart", toListStart: 8, "9": "toCollectionStart", toCollectionStart: 9, "10": "toBinaryStart", toBinaryStart: 10, "11": "toSetEnd", toSetEnd: 11, "12": "toListEnd", toListEnd: 12, "13": "toCollectionEnd", toCollectionEnd: 13, "14": "toBinaryEnd", toBinaryEnd: 14, "15": "toComma", toComma: 15, "16": "toDot", toDot: 16, "17": "toEqual", toEqual: 17, "18": "toColon", toColon: 18, "19": "toPlus", toPlus: 19};
  this.$rtti.$Enum("TParserToken",{minvalue: 0, maxvalue: 19, ordtype: 1, enumtype: this.TParserToken});
  rtl.createClass(this,"TParser",pas.System.TObject,function () {
    this.$init = function () {
      pas.System.TObject.$init.call(this);
      this.fStream = null;
      this.fBuf = [];
      this.FBufLen = 0;
      this.fPos = 0;
      this.fDeltaPos = 0;
      this.fFloatType = "\x00";
      this.fSourceLine = 0;
      this.fToken = 0;
      this.fEofReached = false;
      this.fLastTokenStr = "";
    };
    this.$final = function () {
      this.fStream = undefined;
      this.fBuf = undefined;
      pas.System.TObject.$final.call(this);
    };
    this.GetTokenName = function (aTok) {
      var Result = "";
      Result = $impl.TokNames[aTok];
      return Result;
    };
    this.LoadBuffer = function () {
      var CharsRead = 0;
      var i = 0;
      CharsRead = 0;
      for (i = 0; i <= 4095; i++) {
        if (this.fStream.ReadData$3({a: i, p: this.fBuf, get: function () {
            return this.p[this.a];
          }, set: function (v) {
            this.p[this.a] = v;
          }}) !== 2) break;
        CharsRead += 1;
      };
      this.fDeltaPos += CharsRead;
      this.fPos = 0;
      this.FBufLen = CharsRead;
      this.fEofReached = CharsRead === 0;
    };
    this.CheckLoadBuffer = function () {
      if (this.fPos >= this.FBufLen) this.LoadBuffer();
    };
    this.ProcessChar = function () {
      this.fLastTokenStr = this.fLastTokenStr + this.fBuf[this.fPos];
      this.GotoToNextChar();
    };
    this.IsNumber = function () {
      var Result = false;
      Result = this.fBuf[this.fPos].charCodeAt() in rtl.createSet(null,48,57);
      return Result;
    };
    this.IsHexNum = function () {
      var Result = false;
      Result = this.fBuf[this.fPos].charCodeAt() in rtl.createSet(null,48,57,null,65,70,null,97,102);
      return Result;
    };
    this.IsAlpha = function () {
      var Result = false;
      Result = this.fBuf[this.fPos].charCodeAt() in rtl.createSet(95,null,65,90,null,97,122);
      return Result;
    };
    this.IsAlphaNum = function () {
      var Result = false;
      Result = this.IsAlpha() || this.IsNumber();
      return Result;
    };
    this.GetHexValue = function (c) {
      var Result = 0;
      var $tmp = c;
      if (($tmp >= "0") && ($tmp <= "9")) {
        Result = c.charCodeAt() - 0x30}
       else if (($tmp >= "A") && ($tmp <= "F")) {
        Result = c.charCodeAt() - 0x37}
       else if (($tmp >= "a") && ($tmp <= "f")) Result = c.charCodeAt() - 0x57;
      return Result;
    };
    this.GetAlphaNum = function () {
      var Result = "";
      if (!this.IsAlpha()) this.ErrorFmt(rtl.getResStr(pas.RTLConsts,"SParserExpected"),pas.System.VarRecs(18,this.GetTokenName($mod.TParserToken.toSymbol)));
      Result = "";
      while (!this.fEofReached && this.IsAlphaNum()) {
        Result = Result + this.fBuf[this.fPos];
        this.GotoToNextChar();
      };
      return Result;
    };
    this.HandleNewLine = function () {
      if (this.fBuf[this.fPos] === "\r") this.GotoToNextChar();
      if (!this.fEofReached && (this.fBuf[this.fPos] === "\n")) this.GotoToNextChar();
      this.fSourceLine += 1;
      this.fDeltaPos = -(this.fPos - 1);
    };
    this.SkipBOM = function () {
    };
    this.SkipSpaces = function () {
      while (!this.fEofReached && (this.fBuf[this.fPos].charCodeAt() in rtl.createSet(32,9))) this.GotoToNextChar();
    };
    this.SkipWhitespace = function () {
      while (!this.fEofReached) {
        var $tmp = this.fBuf[this.fPos];
        if (($tmp === " ") || ($tmp === "\t")) {
          this.SkipSpaces()}
         else if (($tmp === "\n") || ($tmp === "\r")) {
          this.HandleNewLine()}
         else {
          break;
        };
      };
    };
    this.HandleEof = function () {
      this.fToken = $mod.TParserToken.toEOF;
      this.fLastTokenStr = "";
    };
    this.HandleAlphaNum = function () {
      this.fLastTokenStr = this.GetAlphaNum();
      this.fToken = $mod.TParserToken.toSymbol;
    };
    var floatPunct = {"0": "fpDot", fpDot: 0, "1": "fpE", fpE: 1};
    this.HandleNumber = function () {
      var allowed = {};
      this.fLastTokenStr = "";
      while (this.IsNumber()) this.ProcessChar();
      this.fToken = $mod.TParserToken.toInteger;
      if (this.fBuf[this.fPos].charCodeAt() in rtl.createSet(46,101,69)) {
        this.fToken = $mod.TParserToken.toFloat;
        allowed = rtl.createSet(floatPunct.fpDot,floatPunct.fpE);
        while (this.fBuf[this.fPos].charCodeAt() in rtl.createSet(46,101,69,null,48,57)) {
          var $tmp = this.fBuf[this.fPos];
          if ($tmp === ".") {
            if (floatPunct.fpDot in allowed) {
              allowed = rtl.excludeSet(allowed,floatPunct.fpDot)}
             else break}
           else if (($tmp === "E") || ($tmp === "e")) if (floatPunct.fpE in allowed) {
            allowed = {};
            this.ProcessChar();
            if (this.fBuf[this.fPos].charCodeAt() in rtl.createSet(43,45)) this.ProcessChar();
            if (!(this.fBuf[this.fPos].charCodeAt() in rtl.createSet(null,48,57))) this.ErrorFmt(rtl.getResStr(pas.RTLConsts,"SParserInvalidFloat"),pas.System.VarRecs(18,this.fLastTokenStr + this.fBuf[this.fPos]));
          } else break;
          this.ProcessChar();
        };
      };
      if (this.fBuf[this.fPos].charCodeAt() in rtl.createSet(115,83,100,68,99,67)) {
        this.fFloatType = this.fBuf[this.fPos];
        this.GotoToNextChar();
        this.fToken = $mod.TParserToken.toFloat;
      } else this.fFloatType = "\x00";
    };
    this.HandleHexNumber = function () {
      var valid = false;
      this.fLastTokenStr = "$";
      this.GotoToNextChar();
      valid = false;
      while (this.IsHexNum()) {
        valid = true;
        this.ProcessChar();
      };
      if (!valid) this.ErrorFmt(rtl.getResStr(pas.RTLConsts,"SParserInvalidInteger"),pas.System.VarRecs(18,this.fLastTokenStr));
      this.fToken = $mod.TParserToken.toInteger;
    };
    this.HandleQuotedString = function () {
      var Result = "";
      Result = "";
      this.GotoToNextChar();
      while (true) {
        var $tmp = this.fBuf[this.fPos];
        if ($tmp === "\x00") {
          this.ErrorStr(rtl.getResStr(pas.RTLConsts,"SParserUnterminatedString"))}
         else if (($tmp === "\r") || ($tmp === "\n")) {
          this.ErrorStr(rtl.getResStr(pas.RTLConsts,"SParserUnterminatedString"))}
         else if ($tmp === "'") {
          this.GotoToNextChar();
          if (this.fBuf[this.fPos] !== "'") return Result;
        };
        Result = Result + this.fBuf[this.fPos];
        this.GotoToNextChar();
      };
      return Result;
    };
    this.HandleDecimalCharacter = function () {
      var Result = "\x00";
      var i = 0;
      this.GotoToNextChar();
      i = 0;
      while (this.IsNumber() && (i < 65535)) {
        i = ((i * 10) + this.fBuf[this.fPos].charCodeAt()) - 48;
        this.GotoToNextChar();
      };
      if (i > 65535) i = 0;
      Result = String.fromCharCode(i);
      return Result;
    };
    this.HandleString = function () {
      var s = "";
      this.fLastTokenStr = "";
      while (true) {
        var $tmp = this.fBuf[this.fPos];
        if ($tmp === "'") {
          s = this.HandleQuotedString();
          this.fLastTokenStr = this.fLastTokenStr + s;
        } else if ($tmp === "#") {
          this.fLastTokenStr = this.fLastTokenStr + this.HandleDecimalCharacter();
        } else {
          break;
        };
      };
      this.fToken = $mod.TParserToken.ToString;
    };
    this.HandleMinus = function () {
      this.GotoToNextChar();
      if (this.IsNumber()) {
        this.HandleNumber();
        this.fLastTokenStr = "-" + this.fLastTokenStr;
      } else {
        this.fToken = $mod.TParserToken.toMinus;
        this.fLastTokenStr = "-";
      };
    };
    this.HandleUnknown = function () {
      this.fToken = $mod.TParserToken.toUnknown;
      this.fLastTokenStr = this.fBuf[this.fPos];
      this.GotoToNextChar();
    };
    this.GotoToNextChar = function () {
      this.fPos += 1;
      this.CheckLoadBuffer();
    };
    this.Create$1 = function (Stream) {
      this.fStream = Stream;
      this.fBuf = rtl.arraySetLength(this.fBuf,"\x00",4096);
      this.FBufLen = 0;
      this.fPos = 0;
      this.fDeltaPos = 1;
      this.fSourceLine = 1;
      this.fEofReached = false;
      this.fLastTokenStr = "";
      this.fFloatType = "\x00";
      this.fToken = $mod.TParserToken.toEOF;
      this.LoadBuffer();
      this.SkipBOM();
      this.NextToken();
      return this;
    };
    this.Destroy = function () {
      var aCount = 0;
      aCount = this.fLastTokenStr.length * 2;
      this.fStream.SetPosition(this.SourcePos() - aCount);
    };
    this.CheckToken = function (T) {
      if (this.fToken !== T) this.ErrorFmt(rtl.getResStr(pas.RTLConsts,"SParserWrongTokenType"),pas.System.VarRecs(18,this.GetTokenName(T),18,this.GetTokenName(this.fToken)));
    };
    this.CheckTokenSymbol = function (S) {
      this.CheckToken($mod.TParserToken.toSymbol);
      if (pas.SysUtils.CompareText(this.fLastTokenStr,S) !== 0) this.ErrorFmt(rtl.getResStr(pas.RTLConsts,"SParserWrongTokenSymbol"),pas.System.VarRecs(18,S,18,this.fLastTokenStr));
    };
    this.Error = function (Ident) {
      this.ErrorStr(Ident);
    };
    this.ErrorFmt = function (Ident, Args) {
      this.ErrorStr(pas.SysUtils.Format(Ident,Args));
    };
    this.ErrorStr = function (Message) {
      throw $mod.EParserError.$create("CreateFmt",[Message + rtl.getResStr(pas.RTLConsts,"SParserLocInfo"),pas.System.VarRecs(0,this.fSourceLine,0,this.fPos + this.fDeltaPos,0,this.SourcePos())]);
    };
    this.HexToBinary = function (Stream) {
      var outbuf = [];
      var b = 0;
      var i = 0;
      outbuf = rtl.arraySetLength(outbuf,0,4096);
      i = 0;
      this.SkipWhitespace();
      while (this.IsHexNum()) {
        b = this.GetHexValue(this.fBuf[this.fPos]) << 4;
        this.GotoToNextChar();
        if (!this.IsHexNum()) this.Error(rtl.getResStr(pas.RTLConsts,"SParserUnterminatedBinValue"));
        b = b | this.GetHexValue(this.fBuf[this.fPos]);
        this.GotoToNextChar();
        outbuf[i] = b;
        i += 1;
        if (i >= 4096) {
          Stream.WriteBuffer(outbuf,i);
          i = 0;
        };
        this.SkipWhitespace();
      };
      if (i > 0) Stream.WriteBuffer(outbuf,i);
      this.NextToken();
    };
    this.NextToken = function () {
      var $Self = this;
      var Result = 0;
      function SetToken(aToken) {
        $Self.fToken = aToken;
        $Self.GotoToNextChar();
      };
      this.SkipWhitespace();
      if (this.fEofReached) {
        this.HandleEof()}
       else {
        var $tmp = this.fBuf[this.fPos];
        if (($tmp === "_") || (($tmp >= "A") && ($tmp <= "Z")) || (($tmp >= "a") && ($tmp <= "z"))) {
          this.HandleAlphaNum()}
         else if ($tmp === "$") {
          this.HandleHexNumber()}
         else if ($tmp === "-") {
          this.HandleMinus()}
         else if (($tmp >= "0") && ($tmp <= "9")) {
          this.HandleNumber()}
         else if (($tmp === "'") || ($tmp === "#")) {
          this.HandleString()}
         else if ($tmp === "[") {
          SetToken($mod.TParserToken.toSetStart)}
         else if ($tmp === "(") {
          SetToken($mod.TParserToken.toListStart)}
         else if ($tmp === "<") {
          SetToken($mod.TParserToken.toCollectionStart)}
         else if ($tmp === "{") {
          SetToken($mod.TParserToken.toBinaryStart)}
         else if ($tmp === "]") {
          SetToken($mod.TParserToken.toSetEnd)}
         else if ($tmp === ")") {
          SetToken($mod.TParserToken.toListEnd)}
         else if ($tmp === ">") {
          SetToken($mod.TParserToken.toCollectionEnd)}
         else if ($tmp === "}") {
          SetToken($mod.TParserToken.toBinaryEnd)}
         else if ($tmp === ",") {
          SetToken($mod.TParserToken.toComma)}
         else if ($tmp === ".") {
          SetToken($mod.TParserToken.toDot)}
         else if ($tmp === "=") {
          SetToken($mod.TParserToken.toEqual)}
         else if ($tmp === ":") {
          SetToken($mod.TParserToken.toColon)}
         else if ($tmp === "+") {
          SetToken($mod.TParserToken.toPlus)}
         else {
          this.HandleUnknown();
        };
      };
      Result = this.fToken;
      return Result;
    };
    this.SourcePos = function () {
      var Result = 0;
      Result = (this.fStream.GetPosition() - this.FBufLen) + this.fPos;
      return Result;
    };
    this.TokenComponentIdent = function () {
      var Result = "";
      if (this.fToken !== $mod.TParserToken.toSymbol) this.ErrorFmt(rtl.getResStr(pas.RTLConsts,"SParserExpected"),pas.System.VarRecs(18,this.GetTokenName($mod.TParserToken.toSymbol)));
      this.CheckLoadBuffer();
      while (this.fBuf[this.fPos] === ".") {
        this.ProcessChar();
        this.fLastTokenStr = this.fLastTokenStr + this.GetAlphaNum();
      };
      Result = this.fLastTokenStr;
      return Result;
    };
    this.TokenFloat = function () {
      var Result = 0.0;
      var errcode = 0;
      pas.System.val$8(this.fLastTokenStr,{get: function () {
          return Result;
        }, set: function (v) {
          Result = v;
        }},{get: function () {
          return errcode;
        }, set: function (v) {
          errcode = v;
        }});
      if (errcode !== 0) this.ErrorFmt(rtl.getResStr(pas.RTLConsts,"SParserInvalidFloat"),pas.System.VarRecs(18,this.fLastTokenStr));
      return Result;
    };
    this.TokenInt = function () {
      var Result = 0;
      if (!pas.SysUtils.TryStrToInt64(this.fLastTokenStr,{get: function () {
          return Result;
        }, set: function (v) {
          Result = v;
        }})) Result = pas.SysUtils.StrToQWord(this.fLastTokenStr);
      return Result;
    };
    this.TokenString = function () {
      var Result = "";
      var $tmp = this.fToken;
      if ($tmp === $mod.TParserToken.toFloat) {
        if (this.fFloatType !== "\x00") {
          Result = this.fLastTokenStr + this.fFloatType}
         else Result = this.fLastTokenStr}
       else {
        Result = this.fLastTokenStr;
      };
      return Result;
    };
    this.TokenSymbolIs = function (S) {
      var Result = false;
      Result = (this.fToken === $mod.TParserToken.toSymbol) && (pas.SysUtils.CompareText(this.fLastTokenStr,S) === 0);
      return Result;
    };
    var $r = this.$rtti;
    $mod.$rtti.$DynArray("TParser.fBuf$a",{eltype: rtl.char});
    $r.addMethod("Create$1",2,[["Stream",$mod.$rtti["TStream"]]]);
  });
  this.TObjectTextEncoding = {"0": "oteDFM", oteDFM: 0, "1": "oteLFM", oteLFM: 1};
  this.$rtti.$Enum("TObjectTextEncoding",{minvalue: 0, maxvalue: 1, ordtype: 1, enumtype: this.TObjectTextEncoding});
  rtl.createClass(this,"TObjectStreamConverter",pas.System.TObject,function () {
    this.$init = function () {
      pas.System.TObject.$init.call(this);
      this.FIndent = "";
      this.FInput = null;
      this.FOutput = null;
      this.FEncoding = 0;
      this.FPlainStrings = false;
    };
    this.$final = function () {
      this.FInput = undefined;
      this.FOutput = undefined;
      pas.System.TObject.$final.call(this);
    };
    this.Outchars = function (S) {
      var res = "";
      var NewStr = "";
      var i = 0;
      var len = 0;
      var w = 0;
      var InString = false;
      var NewInString = false;
      if (S === "") {
        res = "''"}
       else {
        res = "";
        InString = false;
        len = S.length;
        i = 0;
        while (i < len) {
          NewInString = InString;
          w = S.charCodeAt(i);
          if (w === 39) {
            if (!InString) NewInString = true;
            NewStr = "''";
          } else if ((w >= 32) && (w < 127)) {
            if (!InString) NewInString = true;
            NewStr = String.fromCharCode(w);
          } else {
            if (InString) NewInString = false;
            NewStr = "#" + pas.SysUtils.IntToStr(w);
          };
          if (NewInString !== InString) {
            NewStr = "'" + NewStr;
            InString = NewInString;
          };
          res = res + NewStr;
          i += 1;
        };
        if (InString) res = res + "'";
      };
      this.OutStr(res);
    };
    this.OutLn = function (s) {
      this.OutStr(s + pas.System.LineEnding);
    };
    this.OutStr = function (s) {
      var I = 0;
      for (var $l = 1, $end = s.length; $l <= $end; $l++) {
        I = $l;
        this.FOutput.WriteBufferData$4(s.charAt(I - 1));
      };
    };
    this.OutString = function (s) {
      this.Outchars(s);
    };
    this.ReadWord = function () {
      var Result = 0;
      this.FInput.ReadBufferData$10({get: function () {
          return Result;
        }, set: function (v) {
          Result = v;
        }});
      return Result;
    };
    this.ReadDWord = function () {
      var Result = 0;
      this.FInput.ReadBufferData$14({get: function () {
          return Result;
        }, set: function (v) {
          Result = v;
        }});
      return Result;
    };
    this.ReadDouble = function () {
      var Result = 0.0;
      this.FInput.ReadBufferData$20({get: function () {
          return Result;
        }, set: function (v) {
          Result = v;
        }});
      return Result;
    };
    this.ReadInt = function (ValueType) {
      var Result = 0;
      var $tmp = ValueType;
      if ($tmp === $mod.TValueType.vaInt8) {
        Result = ((this.FInput.ReadByte() & 255) << 24) >> 24}
       else if ($tmp === $mod.TValueType.vaInt16) {
        Result = ((this.ReadWord() & 65535) << 16) >> 16}
       else if ($tmp === $mod.TValueType.vaInt32) {
        Result = this.ReadDWord() & 0xFFFFFFFF}
       else if ($tmp === $mod.TValueType.vaNativeInt) Result = this.ReadNativeInt();
      return Result;
    };
    this.ReadInt$1 = function () {
      var Result = 0;
      Result = this.ReadInt(this.FInput.ReadByte());
      return Result;
    };
    this.ReadNativeInt = function () {
      var Result = 0;
      this.FInput.ReadBufferData$16({get: function () {
          return Result;
        }, set: function (v) {
          Result = v;
        }});
      return Result;
    };
    this.ReadStr = function () {
      var Result = "";
      var l = 0;
      var i = 0;
      var c = "\x00";
      this.FInput.ReadBufferData$6({get: function () {
          return l;
        }, set: function (v) {
          l = v;
        }});
      Result = rtl.strSetLength(Result,l);
      for (var $l = 1, $end = l; $l <= $end; $l++) {
        i = $l;
        this.FInput.ReadBufferData$2({get: function () {
            return c;
          }, set: function (v) {
            c = v;
          }});
        Result = rtl.setCharAt(Result,i - 1,c);
      };
      return Result;
    };
    this.ReadString = function (StringType) {
      var Result = "";
      var i = 0;
      var C = "\x00";
      Result = "";
      if (StringType !== $mod.TValueType.vaString) throw $mod.EFilerError.$create("Create$1",["Invalid string type passed to ReadString"]);
      i = this.ReadDWord();
      Result = rtl.strSetLength(Result,i);
      for (var $l = 1, $end = Result.length; $l <= $end; $l++) {
        i = $l;
        this.FInput.ReadBufferData$2({get: function () {
            return C;
          }, set: function (v) {
            C = v;
          }});
        Result = rtl.setCharAt(Result,i - 1,C);
      };
      return Result;
    };
    this.ProcessBinary = function () {
      var ToDo = 0;
      var DoNow = 0;
      var i = 0;
      var lbuf = [];
      var s = "";
      ToDo = this.ReadDWord();
      lbuf = rtl.arraySetLength(lbuf,0,32);
      this.OutLn("{");
      while (ToDo > 0) {
        DoNow = ToDo;
        if (DoNow > 32) DoNow = 32;
        ToDo -= DoNow;
        s = this.FIndent + "  ";
        this.FInput.ReadBuffer({get: function () {
            return lbuf;
          }, set: function (v) {
            lbuf = v;
          }},DoNow);
        for (var $l = 0, $end = DoNow - 1; $l <= $end; $l++) {
          i = $l;
          s = s + pas.SysUtils.IntToHex(lbuf[i],2);
        };
        this.OutLn(s);
      };
      this.OutLn(this.FIndent + "}");
    };
    this.ProcessValue = function (ValueType, Indent) {
      var s = "";
      var IsFirst = false;
      var ext = 0.0;
      var $tmp = ValueType;
      if ($tmp === $mod.TValueType.vaList) {
        this.OutStr("(");
        IsFirst = true;
        while (true) {
          ValueType = this.FInput.ReadByte();
          if (ValueType === $mod.TValueType.vaNull) break;
          if (IsFirst) {
            this.OutLn("");
            IsFirst = false;
          };
          this.OutStr(Indent + "  ");
          this.ProcessValue(ValueType,Indent + "  ");
        };
        this.OutLn(Indent + ")");
      } else if ($tmp === $mod.TValueType.vaInt8) {
        this.OutLn(pas.SysUtils.IntToStr(((this.FInput.ReadByte() & 255) << 24) >> 24))}
       else if ($tmp === $mod.TValueType.vaInt16) {
        this.OutLn(pas.SysUtils.IntToStr(((this.ReadWord() & 65535) << 16) >> 16))}
       else if ($tmp === $mod.TValueType.vaInt32) {
        this.OutLn(pas.SysUtils.IntToStr(this.ReadDWord() & 0xFFFFFFFF))}
       else if ($tmp === $mod.TValueType.vaNativeInt) {
        this.OutLn(pas.SysUtils.IntToStr(this.ReadNativeInt()))}
       else if ($tmp === $mod.TValueType.vaDouble) {
        ext = this.ReadDouble();
        s = rtl.floatToStr(ext);
        this.OutLn(s);
      } else if ($tmp === $mod.TValueType.vaString) {
        if (this.FPlainStrings) {
          this.OutStr("'" + pas.SysUtils.StringReplace(this.ReadString($mod.TValueType.vaString),"'","''",rtl.createSet(pas.SysUtils.TStringReplaceFlag.rfReplaceAll)) + "'")}
         else this.OutString(this.ReadString($mod.TValueType.vaString));
        this.OutLn("");
      } else if ($tmp === $mod.TValueType.vaIdent) {
        this.OutLn(this.ReadStr())}
       else if ($tmp === $mod.TValueType.vaFalse) {
        this.OutLn("False")}
       else if ($tmp === $mod.TValueType.vaTrue) {
        this.OutLn("True")}
       else if ($tmp === $mod.TValueType.vaBinary) {
        this.ProcessBinary()}
       else if ($tmp === $mod.TValueType.vaSet) {
        this.OutStr("[");
        IsFirst = true;
        while (true) {
          s = this.ReadStr();
          if (s.length === 0) break;
          if (!IsFirst) this.OutStr(", ");
          IsFirst = false;
          this.OutStr(s);
        };
        this.OutLn("]");
      } else if ($tmp === $mod.TValueType.vaNil) {
        this.OutLn("nil")}
       else if ($tmp === $mod.TValueType.vaCollection) {
        this.OutStr("<");
        while (this.FInput.ReadByte() !== 0) {
          this.OutLn(Indent);
          this.FInput.Seek(-1,$mod.TSeekOrigin.soCurrent);
          this.OutStr(Indent + "  item");
          ValueType = this.FInput.ReadByte();
          if (ValueType !== $mod.TValueType.vaList) this.OutStr("[" + pas.SysUtils.IntToStr(this.ReadInt(ValueType)) + "]");
          this.OutLn("");
          this.ReadPropList(Indent + "    ");
          this.OutStr(Indent + "  end");
        };
        this.OutLn(">");
      } else {
        throw $mod.EReadError.$create("CreateFmt",[rtl.getResStr(pas.RTLConsts,"SErrInvalidPropertyType"),pas.System.VarRecs(0,ValueType)]);
      };
    };
    this.ReadObject = function (indent) {
      var b = 0;
      var ObjClassName = "";
      var ObjName = "";
      var ChildPos = 0;
      b = this.FInput.ReadByte();
      if ((b & 0xf0) === 0xf0) {
        if ((b & 2) !== 0) ChildPos = this.ReadInt$1();
      } else {
        b = 0;
        this.FInput.Seek(-1,$mod.TSeekOrigin.soCurrent);
      };
      ObjClassName = this.ReadStr();
      ObjName = this.ReadStr();
      this.OutStr(indent);
      if ((b & 1) !== 0) {
        this.OutStr("inherited")}
       else if ((b & 4) !== 0) {
        this.OutStr("inline")}
       else this.OutStr("object");
      this.OutStr(" ");
      if (ObjName !== "") this.OutStr(ObjName + ": ");
      this.OutStr(ObjClassName);
      if ((b & 2) !== 0) this.OutStr("[" + pas.SysUtils.IntToStr(ChildPos) + "]");
      this.OutLn("");
      this.ReadPropList(indent + "  ");
      while (this.FInput.ReadByte() !== 0) {
        this.FInput.Seek(-1,$mod.TSeekOrigin.soCurrent);
        this.ReadObject(indent + "  ");
      };
      this.OutLn(indent + "end");
    };
    this.ReadPropList = function (indent) {
      while (this.FInput.ReadByte() !== 0) {
        this.FInput.Seek(-1,$mod.TSeekOrigin.soCurrent);
        this.OutStr(indent + this.ReadStr() + " = ");
        this.ProcessValue(this.FInput.ReadByte(),indent);
      };
    };
    this.ObjectBinaryToText = function (aInput, aOutput) {
      this.ObjectBinaryToText$1(aInput,aOutput,$mod.TObjectTextEncoding.oteDFM);
    };
    this.ObjectBinaryToText$1 = function (aInput, aOutput, aEncoding) {
      this.FInput = aInput;
      this.FOutput = aOutput;
      this.FEncoding = aEncoding;
      this.Execute();
    };
    this.Execute = function () {
      var Signature = 0;
      if (this.FIndent === "") this.FIndent = "  ";
      if (!(this.FInput != null)) throw $mod.EReadError.$create("Create$1",["Missing input stream"]);
      if (!(this.FOutput != null)) throw $mod.EReadError.$create("Create$1",["Missing output stream"]);
      this.FInput.ReadBufferData$12({get: function () {
          return Signature;
        }, set: function (v) {
          Signature = v;
        }});
      if (Signature !== 809914452) throw $mod.EReadError.$create("Create$1",[rtl.getResStr(pas.RTLConsts,"SInvalidImage")]);
      this.ReadObject("");
    };
  });
  rtl.createClass(this,"TObjectTextConverter",pas.System.TObject,function () {
    this.$init = function () {
      pas.System.TObject.$init.call(this);
      this.FParser = null;
      this.FInput = null;
      this.Foutput = null;
    };
    this.$final = function () {
      this.FParser = undefined;
      this.FInput = undefined;
      this.Foutput = undefined;
      pas.System.TObject.$final.call(this);
    };
    this.WriteDouble = function (e) {
      this.Foutput.WriteBufferData$20(e);
    };
    this.WriteDWord = function (lw) {
      this.Foutput.WriteBufferData$14(lw);
    };
    this.WriteInteger = function (value) {
      if ((value >= -128) && (value <= 127)) {
        this.Foutput.WriteByte($mod.TValueType.vaInt8);
        this.Foutput.WriteByte(value & 255);
      } else if ((value >= -32768) && (value <= 32767)) {
        this.Foutput.WriteByte($mod.TValueType.vaInt16);
        this.WriteWord(value & 65535);
      } else if ((value >= -2147483648) && (value <= 2147483647)) {
        this.Foutput.WriteByte($mod.TValueType.vaInt32);
        this.WriteDWord(value >>> 0);
      } else {
        this.Foutput.WriteByte($mod.TValueType.vaNativeInt);
        this.WriteQWord(value);
      };
    };
    this.WriteQWord = function (q) {
      this.Foutput.WriteBufferData$16(q);
    };
    this.WriteString = function (s) {
      var i = 0;
      var size = 0;
      if (s.length > 255) {
        size = 255}
       else size = s.length;
      this.Foutput.WriteByte(size);
      for (var $l = 1, $end = s.length; $l <= $end; $l++) {
        i = $l;
        this.Foutput.WriteBufferData$4(s.charAt(i - 1));
      };
    };
    this.WriteWord = function (w) {
      this.Foutput.WriteBufferData$12(w);
    };
    this.WriteWString = function (s) {
      var i = 0;
      this.WriteDWord(s.length);
      for (var $l = 1, $end = s.length; $l <= $end; $l++) {
        i = $l;
        this.Foutput.WriteBufferData$4(s.charAt(i - 1));
      };
    };
    this.ProcessObject = function () {
      var Flags = 0;
      var ObjectName = "";
      var ObjectType = "";
      var ChildPos = 0;
      if (this.FParser.TokenSymbolIs("OBJECT")) {
        Flags = 0}
       else {
        if (this.FParser.TokenSymbolIs("INHERITED")) {
          Flags = 1}
         else {
          this.FParser.CheckTokenSymbol("INLINE");
          Flags = 4;
        };
      };
      this.FParser.NextToken();
      this.FParser.CheckToken($mod.TParserToken.toSymbol);
      ObjectName = "";
      ObjectType = this.FParser.TokenString();
      this.FParser.NextToken();
      if (this.FParser.fToken === $mod.TParserToken.toColon) {
        this.FParser.NextToken();
        this.FParser.CheckToken($mod.TParserToken.toSymbol);
        ObjectName = ObjectType;
        ObjectType = this.FParser.TokenString();
        this.FParser.NextToken();
        if (this.FParser.fToken === $mod.TParserToken.toSetStart) {
          this.FParser.NextToken();
          ChildPos = this.FParser.TokenInt();
          this.FParser.NextToken();
          this.FParser.CheckToken($mod.TParserToken.toSetEnd);
          this.FParser.NextToken();
          Flags = Flags | 2;
        };
      };
      if (Flags !== 0) {
        this.Foutput.WriteByte(0xf0 | Flags);
        if ((Flags & 2) !== 0) this.WriteInteger(ChildPos);
      };
      this.WriteString(ObjectType);
      this.WriteString(ObjectName);
      while (!(this.FParser.TokenSymbolIs("END") || this.FParser.TokenSymbolIs("OBJECT") || this.FParser.TokenSymbolIs("INHERITED") || this.FParser.TokenSymbolIs("INLINE"))) this.ProcessProperty();
      this.Foutput.WriteByte(0);
      while (!this.FParser.TokenSymbolIs("END")) this.ProcessObject();
      this.FParser.NextToken();
      this.Foutput.WriteByte(0);
    };
    this.ProcessProperty = function () {
      var name = "";
      this.FParser.CheckToken($mod.TParserToken.toSymbol);
      name = this.FParser.TokenString();
      while (true) {
        this.FParser.NextToken();
        if (this.FParser.fToken !== $mod.TParserToken.toDot) break;
        this.FParser.NextToken();
        this.FParser.CheckToken($mod.TParserToken.toSymbol);
        name = name + "." + this.FParser.TokenString();
      };
      this.WriteString(name);
      this.FParser.CheckToken($mod.TParserToken.toEqual);
      this.FParser.NextToken();
      this.ProcessValue();
    };
    this.ProcessValue = function () {
      var flt = 0.0;
      var stream = null;
      var $tmp = this.FParser.fToken;
      if ($tmp === $mod.TParserToken.toInteger) {
        this.WriteInteger(this.FParser.TokenInt());
        this.FParser.NextToken();
      } else if ($tmp === $mod.TParserToken.toFloat) {
        this.Foutput.WriteByte($mod.TValueType.vaDouble);
        flt = this.FParser.TokenFloat();
        this.WriteDouble(flt);
        this.FParser.NextToken();
      } else if ($tmp === $mod.TParserToken.ToString) {
        this.ProcessWideString("")}
       else if ($tmp === $mod.TParserToken.toSymbol) {
        if (pas.SysUtils.CompareText(this.FParser.TokenString(),"True") === 0) {
          this.Foutput.WriteByte($mod.TValueType.vaTrue)}
         else if (pas.SysUtils.CompareText(this.FParser.TokenString(),"False") === 0) {
          this.Foutput.WriteByte($mod.TValueType.vaFalse)}
         else if (pas.SysUtils.CompareText(this.FParser.TokenString(),"nil") === 0) {
          this.Foutput.WriteByte($mod.TValueType.vaNil)}
         else {
          this.Foutput.WriteByte($mod.TValueType.vaIdent);
          this.WriteString(this.FParser.TokenComponentIdent());
        };
        this.FParser.NextToken();
      } else if ($tmp === $mod.TParserToken.toSetStart) {
        this.FParser.NextToken();
        this.Foutput.WriteByte($mod.TValueType.vaSet);
        if (this.FParser.fToken !== $mod.TParserToken.toSetEnd) while (true) {
          this.FParser.CheckToken($mod.TParserToken.toSymbol);
          this.WriteString(this.FParser.TokenString());
          this.FParser.NextToken();
          if (this.FParser.fToken === $mod.TParserToken.toSetEnd) break;
          this.FParser.CheckToken($mod.TParserToken.toComma);
          this.FParser.NextToken();
        };
        this.Foutput.WriteByte(0);
        this.FParser.NextToken();
      } else if ($tmp === $mod.TParserToken.toListStart) {
        this.FParser.NextToken();
        this.Foutput.WriteByte($mod.TValueType.vaList);
        while (this.FParser.fToken !== $mod.TParserToken.toListEnd) this.ProcessValue();
        this.Foutput.WriteByte(0);
        this.FParser.NextToken();
      } else if ($tmp === $mod.TParserToken.toCollectionStart) {
        this.FParser.NextToken();
        this.Foutput.WriteByte($mod.TValueType.vaCollection);
        while (this.FParser.fToken !== $mod.TParserToken.toCollectionEnd) {
          this.FParser.CheckTokenSymbol("item");
          this.FParser.NextToken();
          this.Foutput.WriteByte($mod.TValueType.vaList);
          while (!this.FParser.TokenSymbolIs("end")) this.ProcessProperty();
          this.FParser.NextToken();
          this.Foutput.WriteByte(0);
        };
        this.Foutput.WriteByte(0);
        this.FParser.NextToken();
      } else if ($tmp === $mod.TParserToken.toBinaryStart) {
        this.Foutput.WriteByte($mod.TValueType.vaBinary);
        stream = $mod.TBytesStream.$create("Create");
        try {
          this.FParser.HexToBinary(stream);
          this.WriteDWord(stream.GetSize());
          this.Foutput.WriteBuffer(stream.GetBytes(),stream.GetSize());
        } finally {
          stream = rtl.freeLoc(stream);
        };
        this.FParser.NextToken();
      } else {
        this.FParser.Error(rtl.getResStr(pas.RTLConsts,"SParserInvalidProperty"));
      };
    };
    this.ProcessWideString = function (left) {
      var ws = "";
      ws = left + this.FParser.TokenString();
      while (this.FParser.NextToken() === $mod.TParserToken.toPlus) {
        this.FParser.NextToken();
        if (!(this.FParser.fToken === $mod.TParserToken.ToString)) this.FParser.CheckToken($mod.TParserToken.ToString);
        ws = ws + this.FParser.TokenString();
      };
      this.Foutput.WriteByte($mod.TValueType.vaString);
      this.WriteWString(ws);
    };
    this.ObjectTextToBinary = function (aInput, aOutput) {
      this.FInput = aInput;
      this.Foutput = aOutput;
      this.Execute();
    };
    this.Execute = function () {
      if (!(this.FInput != null)) throw $mod.EReadError.$create("Create$1",["Missing input stream"]);
      if (!(this.Foutput != null)) throw $mod.EReadError.$create("Create$1",["Missing output stream"]);
      this.FParser = $mod.TParser.$create("Create$1",[this.FInput]);
      try {
        this.Foutput.WriteBufferData$14(809914452);
        this.ProcessObject();
      } finally {
        rtl.free(this,"FParser");
      };
    };
  });
  rtl.createClass(this,"TLoadHelper",pas.System.TObject,function () {
    $mod.$rtti.$RefToProcVar("TLoadHelper.TTextLoadedCallBack",{procsig: rtl.newTIProcSig([["aText",rtl.string,2]])});
    $mod.$rtti.$RefToProcVar("TLoadHelper.TBytesLoadedCallBack",{procsig: rtl.newTIProcSig([["aBuffer",pas.JS.$rtti["TJSArrayBuffer"],2]])});
    $mod.$rtti.$RefToProcVar("TLoadHelper.TErrorCallBack",{procsig: rtl.newTIProcSig([["aError",rtl.string,2]])});
  });
  this.$rtti.$ClassRef("TLoadHelperClass",{instancetype: this.$rtti["TLoadHelper"]});
  rtl.createClass(this,"TDataModule",this.TComponent,function () {
    this.$init = function () {
      $mod.TComponent.$init.call(this);
      this.FDPos = pas.Types.TPoint.$new();
      this.FDSize = pas.Types.TPoint.$new();
      this.FDPPI = 0;
      this.FOnCreate = null;
      this.FOnDestroy = null;
      this.FOldOrder = false;
    };
    this.$final = function () {
      this.FDPos = undefined;
      this.FDSize = undefined;
      this.FOnCreate = undefined;
      this.FOnDestroy = undefined;
      $mod.TComponent.$final.call(this);
    };
    this.ReadP = function (Reader) {
      this.FDPPI = Reader.ReadInteger();
    };
    this.WriteP = function (Writer) {
      Writer.WriteInteger(this.FDPPI);
    };
    this.ReadT = function (Reader) {
      this.FDPos.y = Reader.ReadInteger();
    };
    this.WriteT = function (Writer) {
      Writer.WriteInteger(this.FDPos.y);
    };
    this.ReadL = function (Reader) {
      this.FDPos.x = Reader.ReadInteger();
    };
    this.WriteL = function (Writer) {
      Writer.WriteInteger(this.FDPos.x);
    };
    this.ReadW = function (Reader) {
      this.FDSize.x = Reader.ReadInteger();
    };
    this.WriteW = function (Writer) {
      Writer.WriteInteger(this.FDSize.x);
    };
    this.ReadH = function (Reader) {
      this.FDSize.y = Reader.ReadInteger();
    };
    this.WriteH = function (Writer) {
      Writer.WriteInteger(this.FDSize.y);
    };
    this.DoCreate = function () {
      if (this.FOnCreate != null) try {
        this.FOnCreate(this);
      } catch ($e) {
        if (!this.HandleCreateException()) throw $e;
      };
    };
    this.DoDestroy = function () {
      if (this.FOnDestroy != null) try {
        this.FOnDestroy(this);
      } catch ($e) {
        if ($mod.ApplicationHandleException != null) $mod.ApplicationHandleException(this);
      };
    };
    this.DefineProperties = function (Filer) {
      var Ancestor = null;
      var HaveData = false;
      var HavePPIData = false;
      $mod.TComponent.DefineProperties.call(this,Filer);
      Ancestor = Filer.FAncestor;
      HaveData = (Ancestor === null) || (this.FDSize.x !== Ancestor.FDSize.x) || (this.FDSize.y !== Ancestor.FDSize.y) || (this.FDPos.y !== Ancestor.FDPos.y) || (this.FDPos.x !== Ancestor.FDPos.x);
      HavePPIData = ((Ancestor != null) && (this.FDPPI !== Ancestor.FDPPI)) || (!(Ancestor != null) && (this.FDPPI !== 96));
      Filer.DefineProperty("Height",rtl.createCallback(this,"ReadH"),rtl.createCallback(this,"WriteH"),HaveData);
      Filer.DefineProperty("HorizontalOffset",rtl.createCallback(this,"ReadL"),rtl.createCallback(this,"WriteL"),HaveData);
      Filer.DefineProperty("VerticalOffset",rtl.createCallback(this,"ReadT"),rtl.createCallback(this,"WriteT"),HaveData);
      Filer.DefineProperty("Width",rtl.createCallback(this,"ReadW"),rtl.createCallback(this,"WriteW"),HaveData);
      Filer.DefineProperty("PPI",rtl.createCallback(this,"ReadP"),rtl.createCallback(this,"WriteP"),HavePPIData);
    };
    this.GetChildren = function (Proc, Root) {
      var I = 0;
      $mod.TComponent.GetChildren.call(this,Proc,Root);
      if (Root === this) for (var $l = 0, $end = this.GetComponentCount() - 1; $l <= $end; $l++) {
        I = $l;
        if (!this.GetComponent(I).HasParent()) Proc(this.GetComponent(I));
      };
    };
    this.HandleCreateException = function () {
      var Result = false;
      Result = $mod.ApplicationHandleException != null;
      if (Result) $mod.ApplicationHandleException(this);
      return Result;
    };
    this.ReadState = function (Reader) {
      this.FOldOrder = false;
      $mod.TComponent.ReadState.call(this,Reader);
    };
    this.Create$1 = function (AOwner) {
      this.CreateNew(AOwner);
      if ((this.$class.ClassType() !== $mod.TDataModule) && !($mod.TComponentStateItem.csDesigning in this.FComponentState)) {
        if (!$mod.InitInheritedComponent(this,$mod.TDataModule)) throw $mod.EStreamError.$create("CreateFmt",[rtl.getResStr(pas.RTLConsts,"SErrNoStreaming"),pas.System.VarRecs(18,this.$classname)]);
        if (this.FOldOrder) this.DoCreate();
      };
      return this;
    };
    this.CreateNew = function (AOwner) {
      this.CreateNew$1(AOwner,0);
      return this;
    };
    this.CreateNew$1 = function (AOwner, CreateMode) {
      $mod.TComponent.Create$1.call(this,AOwner);
      this.FDPPI = 96;
      if (($mod.AddDataModule != null) && (CreateMode >= 0)) $mod.AddDataModule(this);
      return this;
    };
    this.Destroy = function () {
      if (this.FOldOrder) this.DoDestroy();
      if ($mod.RemoveDataModule != null) $mod.RemoveDataModule(this);
      $mod.TComponent.Destroy.call(this);
    };
    this.AfterConstruction = function () {
      if (!this.FOldOrder) this.DoCreate();
    };
    this.BeforeDestruction = function () {
      this.Destroying();
      $mod.RemoveFixupReferences(this,"");
      if (!this.FOldOrder) this.DoDestroy();
    };
    rtl.addIntf(this,pas.System.IUnknown);
    var $r = this.$rtti;
    $r.addMethod("Create$1",2,[["AOwner",$mod.$rtti["TComponent"]]]);
    $r.addMethod("CreateNew",2,[["AOwner",$mod.$rtti["TComponent"]]]);
    $r.addMethod("CreateNew$1",2,[["AOwner",$mod.$rtti["TComponent"]],["CreateMode",rtl.longint]]);
    $r.addProperty("OnCreate",0,$mod.$rtti["TNotifyEvent"],"FOnCreate","FOnCreate");
    $r.addProperty("OnDestroy",0,$mod.$rtti["TNotifyEvent"],"FOnDestroy","FOnDestroy");
    $r.addProperty("OldCreateOrder",0,rtl.boolean,"FOldOrder","FOldOrder");
  });
  this.$rtti.$ClassRef("TDataModuleClass",{instancetype: this.$rtti["TDataModule"]});
  rtl.recNewT(this,"TIdentMapEntry",function () {
    this.Value = 0;
    this.Name = "";
    this.$eq = function (b) {
      return (this.Value === b.Value) && (this.Name === b.Name);
    };
    this.$assign = function (s) {
      this.Value = s.Value;
      this.Name = s.Name;
      return this;
    };
    var $r = $mod.$rtti.$Record("TIdentMapEntry",{});
    $r.addField("Value",rtl.longint);
    $r.addField("Name",rtl.string);
  });
  this.$rtti.$ProcVar("TIdentToInt",{procsig: rtl.newTIProcSig([["Ident",rtl.string,2],["Int",rtl.longint,1]],rtl.boolean)});
  this.$rtti.$ProcVar("TIntToIdent",{procsig: rtl.newTIProcSig([["Int",rtl.longint],["Ident",rtl.string,1]],rtl.boolean)});
  this.$rtti.$ProcVar("TFindGlobalComponent",{procsig: rtl.newTIProcSig([["Name",rtl.string,2]],this.$rtti["TComponent"])});
  this.$rtti.$ProcVar("TInitComponentHandler",{procsig: rtl.newTIProcSig([["Instance",this.$rtti["TComponent"]],["RootAncestor",pas.System.$rtti["TClass"]]],rtl.boolean)});
  rtl.createHelper(this,"TStringsHelper",null,function () {
    this.LoadFromStream = function (Stream) {
      $mod.TStringsHelper.LoadFromStream$1.call(this,Stream,pas.SysUtils.TEncoding.GetUTF8());
    };
    this.LoadFromStream$1 = function (Stream, Encoding) {
      var arr = null;
      var s = "";
      var buf = [];
      Stream.Read({get: function () {
          return buf;
        }, set: function (v) {
          buf = v;
        }},Stream.GetSize());
      arr = $mod.TMemoryStream.BytesToMemory(rtl.arrayRef(buf));
      if ((Encoding != null) && (Encoding !== Encoding.$class.GetUTF8())) {
        s = Encoding.GetEncoding();
        var enc = new TextDecoder(s);
        s = enc.decode(arr);
      } else {
        s =  String.fromCharCode.apply(null, new Uint16Array(arr));
      };
      this.SetTextStr(s);
    };
    this.SaveToStream = function (Stream) {
      $mod.TStringsHelper.SaveToStream$1.call(this,Stream,pas.SysUtils.TEncoding.GetUTF8());
    };
    this.SaveToStream$1 = function (Stream, Encoding) {
      var s = "";
      var txt = "";
      var arr = null;
      var b = [];
      var l = 0;
      s = "utf-8";
      if (Encoding != null) {
        s = Encoding.GetEncoding();
      };
      txt = this.GetTextStr();
      var enc = new TextEncoder(s);
      arr = enc.encode(txt);
      b = $mod.TMemoryStream.MemoryToBytes(arr);
      l = arr.byteLength;
      Stream.Write(b,l);
      Stream.SetPosition(0);
    };
    this.IndexOfValue = function (Value) {
      var Result = 0;
      var len = 0;
      var S = "";
      this.CheckSpecialChars();
      Result = 0;
      while (Result < this.GetCount()) {
        S = this.Get(Result);
        len = pas.System.Pos(this.FNameValueSeparator,S) + 1;
        if ((len >= 0) && (this.DoCompareText(Value,pas.System.Copy(S,len,S.length)) === 0)) return Result;
        Result += 1;
      };
      Result = -1;
      return Result;
    };
  });
  this.TMSPlatformsWeb = 1;
  rtl.createClass(this,"ComponentPlatformsAttribute",pas.System.TCustomAttribute,function () {
    this.$init = function () {
      pas.System.TCustomAttribute.$init.call(this);
      this.FPlatforms = 0;
    };
    this.Create$1 = function (Platforms) {
      this.FPlatforms = Platforms;
      return this;
    };
    var $r = this.$rtti;
    $r.addMethod("Create$1",2,[["Platforms",rtl.longword,2]]);
  });
  this.TShiftState$a = {"0": "ssShift", ssShift: 0, "1": "ssAlt", ssAlt: 1, "2": "ssCtrl", ssCtrl: 2, "3": "ssLeft", ssLeft: 3, "4": "ssRight", ssRight: 4, "5": "ssMIDdle", ssMIDdle: 5, "6": "ssDouble", ssDouble: 6, "7": "ssTouch", ssTouch: 7, "8": "ssPen", ssPen: 8, "9": "ssCommand", ssCommand: 9};
  this.$rtti.$Enum("TShiftState$a",{minvalue: 0, maxvalue: 9, ordtype: 1, enumtype: this.TShiftState$a});
  this.$rtti.$Set("TShiftState",{comptype: this.$rtti["TShiftState$a"]});
  this.RegisterInitComponentHandler = function (ComponentClass, Handler) {
    var I = 0;
    var H = null;
    if ($impl.InitHandlerList === null) $impl.InitHandlerList = $mod.TList.$create("Create$1");
    H = $impl.TInitHandler.$create("Create");
    H.AClass = ComponentClass;
    H.AHandler = Handler;
    try {
      var $with = $impl.InitHandlerList;
      I = 0;
      while ((I < $with.GetCount()) && !H.AClass.InheritsFrom(rtl.getObject($with.Get(I)).AClass)) I += 1;
      if ((I < $with.GetCount()) && (rtl.getObject($with.Get(I)).AClass === H.AClass)) {
        rtl.getObject($with.Get(I)).AHandler = Handler;
        H = rtl.freeLoc(H);
      } else $impl.InitHandlerList.Insert(I,H);
    } catch ($e) {
      H = rtl.freeLoc(H);
      throw $e;
    };
  };
  this.RegisterClass = function (AClass) {
    $impl.ClassList[AClass.$classname] = AClass;
  };
  this.RegisterClasses = function (AClasses) {
    var AClass = null;
    for (var $in = AClasses, $l = 0, $end = rtl.length($in) - 1; $l <= $end; $l++) {
      AClass = $in[$l];
      $mod.RegisterClass(AClass);
    };
  };
  this.GetClass = function (AClassName) {
    var Result = null;
    Result = null;
    if (AClassName === "") return Result;
    if (!$impl.ClassList.hasOwnProperty(AClassName)) return Result;
    Result = rtl.getObject($impl.ClassList[AClassName]);
    return Result;
  };
  this.RegisterFindGlobalComponentProc = function (AFindGlobalComponent) {
    if (!($impl.FindGlobalComponentList != null)) $impl.FindGlobalComponentList = $mod.TFPList.$create("Create");
    if ($impl.FindGlobalComponentList.IndexOf(AFindGlobalComponent) < 0) $impl.FindGlobalComponentList.Add(AFindGlobalComponent);
  };
  this.UnregisterFindGlobalComponentProc = function (AFindGlobalComponent) {
    if ($impl.FindGlobalComponentList != null) $impl.FindGlobalComponentList.Remove(AFindGlobalComponent);
  };
  this.FindGlobalComponent = function (Name) {
    var Result = null;
    var i = 0;
    Result = null;
    if ($impl.FindGlobalComponentList != null) {
      for (var $l = $impl.FindGlobalComponentList.FCount - 1; $l >= 0; $l--) {
        i = $l;
        Result = $impl.FindGlobalComponentList.Get(i)(Name);
        if (Result != null) break;
      };
    };
    return Result;
  };
  this.FindNestedComponent = function (Root, APath, CStyle) {
    var Result = null;
    function GetNextName() {
      var Result = "";
      var P = 0;
      var CM = false;
      P = pas.System.Pos(".",APath);
      CM = false;
      if (P === 0) {
        if (CStyle) {
          P = pas.System.Pos("->",APath);
          CM = P !== 0;
        };
        if (P === 0) P = APath.length + 1;
      };
      Result = pas.System.Copy(APath,1,P - 1);
      pas.System.Delete({get: function () {
          return APath;
        }, set: function (v) {
          APath = v;
        }},1,P + (CM + 0));
      return Result;
    };
    var C = null;
    var S = "";
    if (APath === "") {
      Result = null}
     else {
      Result = Root;
      while ((APath !== "") && (Result !== null)) {
        C = Result;
        S = pas.SysUtils.UpperCase(GetNextName());
        Result = C.FindComponent(S);
        if ((Result === null) && (S === "OWNER")) Result = C;
      };
    };
    return Result;
  };
  this.InitInheritedComponent = function (Instance, RootAncestor) {
    var Result = false;
    var I = 0;
    I = 0;
    if (!($impl.InitHandlerList != null)) {
      Result = true;
      return Result;
    };
    Result = false;
    var $with = $impl.InitHandlerList;
    I = 0;
    while (!Result && (I < $with.GetCount())) {
      if (Instance.$class.InheritsFrom(rtl.getObject($with.Get(I)).AClass)) Result = rtl.getObject($with.Get(I)).AHandler(Instance,RootAncestor);
      I += 1;
    };
    return Result;
  };
  this.RedirectFixupReferences = function (Root, OldRootName, NewRootName) {
    if ($impl.NeedResolving === null) return;
    $impl.VisitResolveList($impl.TRedirectReferenceVisitor.$create("Create$1",[Root,OldRootName,NewRootName]));
  };
  this.RemoveFixupReferences = function (Root, RootName) {
    if ($impl.NeedResolving === null) return;
    $impl.VisitResolveList($impl.TRemoveReferenceVisitor.$create("Create$1",[Root,RootName]));
  };
  this.RegisterIntegerConsts = function (IntegerType, IdentToIntFn, IntToIdentFn) {
    if (!($impl.IntConstList != null)) $impl.IntConstList = $mod.TFPList.$create("Create");
    $impl.IntConstList.Add($impl.TIntConst.$create("Create$1",[IntegerType,IdentToIntFn,IntToIdentFn]));
  };
  this.ExtractStrings = function (Separators, WhiteSpace, Content, Strings, AddEmptyStrings) {
    var Result = 0;
    var b = 0;
    var c = 0;
    function SkipWhitespace() {
      while (Content.charCodeAt(c - 1) in WhiteSpace) c += 1;
    };
    function AddString() {
      var l = 0;
      l = c - b;
      if ((l > 0) || AddEmptyStrings) {
        if (Strings != null) {
          if (l > 0) {
            Strings.Add(pas.System.Copy(Content,b,l))}
           else Strings.Add("");
        };
        Result += 1;
      };
    };
    var cc = "\x00";
    var quoted = "\x00";
    var aLen = 0;
    Result = 0;
    c = 1;
    quoted = "\x00";
    Separators = rtl.diffSet(rtl.unionSet(Separators,rtl.createSet(13,10)),rtl.createSet(39,34));
    SkipWhitespace();
    b = c;
    aLen = Content.length;
    while (c <= aLen) {
      cc = Content.charAt(c - 1);
      if (cc === quoted) {
        if ((c < aLen) && (Content.charAt((c + 1) - 1) === quoted)) {
          c += 1}
         else quoted = "\x00";
      } else if ((quoted === "\x00") && (cc.charCodeAt() in rtl.createSet(39,34))) quoted = cc;
      if ((quoted === "\x00") && (cc.charCodeAt() in Separators)) {
        AddString();
        c += 1;
        SkipWhitespace();
        b = c;
      } else c += 1;
    };
    if (c !== b) AddString();
    return Result;
  };
  this.IdentToInt = function (Ident, Int, map) {
    var Result = false;
    var i = 0;
    for (var $l = 0, $end = rtl.length(map) - 1; $l <= $end; $l++) {
      i = $l;
      if (pas.SysUtils.CompareText(map[i].Name,Ident) === 0) {
        Int.set(map[i].Value);
        return true;
      };
    };
    Result = false;
    return Result;
  };
  this.IntToIdent = function (Int, Ident, map) {
    var Result = false;
    var i = 0;
    for (var $l = 0, $end = rtl.length(map) - 1; $l <= $end; $l++) {
      i = $l;
      if (map[i].Value === Int) {
        Ident.set(map[i].Name);
        return true;
      };
    };
    Result = false;
    return Result;
  };
  this.FindIntToIdent = function (AIntegerType) {
    var Result = null;
    var i = 0;
    Result = null;
    if (!($impl.IntConstList != null)) return Result;
    var $with = $impl.IntConstList;
    for (var $l = 0, $end = $with.FCount - 1; $l <= $end; $l++) {
      i = $l;
      if (rtl.getObject($with.Get(i)).IntegerType === AIntegerType) return rtl.getObject($with.Get(i)).IntToIdentFn;
    };
    return Result;
  };
  this.FindIdentToInt = function (AIntegerType) {
    var Result = null;
    var i = 0;
    Result = null;
    if (!($impl.IntConstList != null)) return Result;
    var $with = $impl.IntConstList;
    for (var $l = 0, $end = $with.FCount - 1; $l <= $end; $l++) {
      i = $l;
      var $with1 = rtl.getObject($with.Get(i));
      if (rtl.getObject($with.Get(i)).IntegerType === AIntegerType) return $with1.IdentToIntFn;
    };
    return Result;
  };
  this.FindClass = function (AClassName) {
    var Result = null;
    Result = $mod.GetClass(AClassName);
    if (!(Result != null)) throw $mod.EClassNotFound.$create("CreateFmt",[rtl.getResStr(pas.RTLConsts,"SClassNotFound"),pas.System.VarRecs(18,AClassName)]);
    return Result;
  };
  this.CollectionsEqual = function (C1, C2) {
    var Result = false;
    var Comp1 = null;
    var Comp2 = null;
    Comp2 = null;
    Comp1 = $mod.TComponent.$create("Create");
    try {
      Result = $mod.CollectionsEqual$1(C1,C2,Comp1,Comp2);
    } finally {
      Comp1 = rtl.freeLoc(Comp1);
      Comp2 = rtl.freeLoc(Comp2);
    };
    return Result;
  };
  this.CollectionsEqual$1 = function (C1, C2, Owner1, Owner2) {
    var Result = false;
    function stream_collection(s, c, o) {
      var w = null;
      w = $mod.TWriter.$create("Create$2",[s]);
      try {
        w.SetRoot(o);
        w.FLookupRoot = o;
        w.WriteCollection(c);
      } finally {
        w = rtl.freeLoc(w);
      };
    };
    var s1 = null;
    var s2 = null;
    var b1 = [];
    var b2 = [];
    var I = 0;
    var Len = 0;
    Result = false;
    if ((C1.$class.ClassType() !== C2.$class.ClassType()) || (C1.GetCount() !== C2.GetCount())) return Result;
    if (C1.GetCount() === 0) {
      Result = true;
      return Result;
    };
    s2 = null;
    s1 = $mod.TBytesStream.$create("Create");
    try {
      s2 = $mod.TBytesStream.$create("Create");
      stream_collection(s1,C1,Owner1);
      stream_collection(s2,C2,Owner2);
      Result = s1.GetSize() === s2.GetSize();
      if (Result) {
        b1 = s1.GetBytes();
        b2 = s2.GetBytes();
        I = 0;
        Len = s1.GetSize();
        while (Result && (I < Len)) {
          Result = b1[I] === b2[I];
          I += 1;
        };
      };
    } finally {
      s2 = rtl.freeLoc(s2);
      s1 = rtl.freeLoc(s1);
    };
    return Result;
  };
  this.GetFixupReferenceNames = function (Root, Names) {
    if ($impl.NeedResolving === null) return;
    $impl.VisitResolveList($impl.TReferenceNamesVisitor.$create("Create$1",[Root,Names]));
  };
  this.GetFixupInstanceNames = function (Root, ReferenceRootName, Names) {
    if ($impl.NeedResolving === null) return;
    $impl.VisitResolveList($impl.TReferenceInstancesVisitor.$create("Create$1",[Root,ReferenceRootName,Names]));
  };
  this.ObjectBinaryToText = function (aInput, aOutput) {
    $mod.ObjectBinaryToText$1(aInput,aOutput,$mod.TObjectTextEncoding.oteLFM);
  };
  this.ObjectBinaryToText$1 = function (aInput, aOutput, aEncoding) {
    var Conv = null;
    Conv = $mod.TObjectStreamConverter.$create("Create");
    try {
      Conv.ObjectBinaryToText$1(aInput,aOutput,aEncoding);
    } finally {
      Conv = rtl.freeLoc(Conv);
    };
  };
  this.ObjectTextToBinary = function (aInput, aOutput) {
    var Conv = null;
    Conv = $mod.TObjectTextConverter.$create("Create");
    try {
      Conv.ObjectTextToBinary(aInput,aOutput);
    } finally {
      Conv = rtl.freeLoc(Conv);
    };
  };
  this.SetLoadHelperClass = function (aClass) {
    var Result = null;
    Result = $impl.GlobalLoadHelper;
    $impl.GlobalLoadHelper = aClass;
    return Result;
  };
  this.StringToBuffer = function (aString, aLen) {
    var Result = null;
    Result = $mod.StringToBuffer$1(aString,aLen,pas.SysUtils.TEncoding.GetUTF8());
    return Result;
  };
  this.StringToBuffer$1 = function (aString, aLen, AEncoding) {
    var Result = null;
    var I = 0;
    if (AEncoding === pas.SysUtils.TEncoding.GetUnicode()) {
      Result = new ArrayBuffer(aLen * 2);
      var $with = new Uint16Array(Result);
      for (var $l = 0, $end = aLen - 1; $l <= $end; $l++) {
        I = $l;
        $with[I] = aString.charCodeAt(I);
      };
    } else {
      Result = new ArrayBuffer(aLen);
      var $with1 = new Uint8Array(Result);
      for (var $l1 = 0, $end1 = aLen - 1; $l1 <= $end1; $l1++) {
        I = $l1;
        $with1[I] = aString.charCodeAt(I);
      };
    };
    return Result;
  };
  this.BufferToString = function (aBuffer, aPos, aLen) {
    var Result = "";
    Result = $mod.BufferToString$1(aBuffer,aPos,aLen,pas.SysUtils.TEncoding.GetUTF8());
    return Result;
  };
  this.BufferToString$1 = function (aBuffer, aPos, aLen, AEncoding) {
    var Result = "";
    var ua16 = null;
    var ua8 = null;
    Result = "";
    if (AEncoding === pas.SysUtils.TEncoding.GetUnicode()) {
      ua16 = new Uint16Array(aBuffer.slice(aPos,aLen));
      if (ua16 !== null) Result = "" + String.fromCharCode.apply(null,ua16);
    } else {
      ua8 = new Uint8Array(aBuffer.slice(aPos,aLen));
      if (ua8 !== null) Result = "" + String.fromCharCode.apply(null,ua8);
    };
    return Result;
  };
  this.BeginGlobalLoading = function () {
    $impl.GlobalLoaded = $mod.TFPList.$create("Create");
  };
  this.NotifyGlobalLoading = function () {
    var I = 0;
    var G = null;
    G = $impl.GlobalLoaded;
    for (var $l = 0, $end = G.FCount - 1; $l <= $end; $l++) {
      I = $l;
      rtl.getObject(G.Get(I)).Loaded();
    };
  };
  this.EndGlobalLoading = function () {
    rtl.free($impl,"GlobalLoaded");
  };
  this.$rtti.$MethodVar("TDataModuleNotifyEvent",{procsig: rtl.newTIProcSig([["DataModule",this.$rtti["TDataModule"]]]), methodkind: 0});
  this.$rtti.$MethodVar("TExceptionNotifyEvent",{procsig: rtl.newTIProcSig([["E",pas.SysUtils.$rtti["Exception"]]]), methodkind: 0});
  this.AddDataModule = null;
  this.RemoveDataModule = null;
  this.ApplicationHandleException = null;
  this.ApplicationShowException = null;
  this.FormResourceIsText = true;
  this.vaSingle = this.TValueType.vaDouble;
  this.vaExtended = this.TValueType.vaDouble;
  this.vaLString = this.TValueType.vaString;
  this.vaUTF8String = this.TValueType.vaString;
  this.vaUString = this.TValueType.vaString;
  this.vaWString = this.TValueType.vaString;
  this.vaQWord = this.TValueType.vaNativeInt;
  this.vaInt64 = this.TValueType.vaNativeInt;
  this.toWString = this.TParserToken.ToString;
  $mod.$implcode = function () {
    $mod.$rtti.$RefToProcVar("TReqLoadProc",{procsig: rtl.newTIProcSig([["AResponse",rtl.string]])});
    $mod.$rtti.$RefToProcVar("TReqErrorProc",{procsig: rtl.newTIProcSig([])});
    $impl.GlobalLoaded = null;
    $impl.IntConstList = null;
    $impl.GlobalLoadHelper = null;
    $impl.CheckLoadHelper = function () {
      if ($impl.GlobalLoadHelper === null) throw pas.SysUtils.EInOutError.$create("Create$1",["No support for loading URLS. Include Rtl.BrowserLoadHelper in your project uses clause"]);
    };
    $impl.CreateComponentfromRes = function (res, Inst, Component) {
      var Result = false;
      var ResStream = null;
      var Src = null;
      var aInfo = pas.p2jsres.TResourceInfo.$new();
      if (Inst === 0) ;
      Result = pas.p2jsres.GetResourceInfo(res,aInfo);
      if (Result) {
        ResStream = $mod.TResourceStream.$create("Create$1",[pas.p2jsres.TResourceInfo.$clone(aInfo)]);
        try {
          if (!$mod.FormResourceIsText) {
            Src = ResStream}
           else {
            Src = $mod.TMemoryStream.$create("Create");
            $mod.ObjectTextToBinary(ResStream,Src);
            Src.SetPosition(0);
          };
          Component.set(Src.ReadComponent(Component.get()));
        } finally {
          if (Src !== ResStream) Src = rtl.freeLoc(Src);
          ResStream = rtl.freeLoc(ResStream);
        };
      };
      return Result;
    };
    $impl.DefaultInitHandler = function (Instance, RootAncestor) {
      var Result = false;
      function doinit(_class) {
        var Result = false;
        Result = false;
        if ((_class.ClassType() === $mod.TComponent) || (_class.ClassType() === RootAncestor)) return Result;
        Result = doinit(_class.$ancestor);
        Result = $impl.CreateComponentfromRes(_class.$module.$name,0,{get: function () {
            return Instance;
          }, set: function (v) {
            Instance = v;
          }}) || Result;
        return Result;
      };
      Result = doinit(Instance.$class.ClassType());
      return Result;
    };
    rtl.createClass($impl,"TIntConst",pas.System.TObject,function () {
      this.$init = function () {
        pas.System.TObject.$init.call(this);
        this.IntegerType = null;
        this.IdentToIntFn = null;
        this.IntToIdentFn = null;
      };
      this.$final = function () {
        this.IdentToIntFn = undefined;
        this.IntToIdentFn = undefined;
        pas.System.TObject.$final.call(this);
      };
      this.Create$1 = function (AIntegerType, AIdentToInt, AIntToIdent) {
        this.IntegerType = AIntegerType;
        this.IdentToIntFn = AIdentToInt;
        this.IntToIdentFn = AIntToIdent;
        return this;
      };
      var $r = this.$rtti;
      $r.addMethod("Create$1",2,[["AIntegerType",rtl.pointer],["AIdentToInt",$mod.$rtti["TIdentToInt"]],["AIntToIdent",$mod.$rtti["TIntToIdent"]]]);
    });
    $impl.GlobalIdentToInt = function (Ident, Int) {
      var Result = false;
      var i = 0;
      Result = false;
      if (!($impl.IntConstList != null)) return Result;
      var $with = $impl.IntConstList;
      for (var $l = 0, $end = $with.FCount - 1; $l <= $end; $l++) {
        i = $l;
        if (rtl.getObject($with.Get(i)).IdentToIntFn(Ident,Int)) return true;
      };
      return Result;
    };
    $impl.QuickSort = function (aList, L, R, Compare) {
      var I = 0;
      var J = 0;
      var PivotIdx = 0;
      var P = undefined;
      var Q = undefined;
      do {
        I = L;
        J = R;
        PivotIdx = L + ((R - L) >>> 1);
        P = aList[PivotIdx];
        do {
          while ((I < PivotIdx) && (Compare(P,aList[I]) > 0)) I += 1;
          while ((J > PivotIdx) && (Compare(P,aList[J]) < 0)) J -= 1;
          if (I < J) {
            Q = aList[I];
            aList[I] = aList[J];
            aList[J] = Q;
            if (PivotIdx === I) {
              PivotIdx = J;
              I += 1;
            } else if (PivotIdx === J) {
              PivotIdx = I;
              J -= 1;
            } else {
              I += 1;
              J -= 1;
            };
          };
        } while (!(I >= J));
        if ((PivotIdx - L) < (R - PivotIdx)) {
          if ((L + 1) < PivotIdx) $impl.QuickSort(rtl.arrayRef(aList),L,PivotIdx - 1,Compare);
          L = PivotIdx + 1;
        } else {
          if ((PivotIdx + 1) < R) $impl.QuickSort(rtl.arrayRef(aList),PivotIdx + 1,R,Compare);
          if ((L + 1) < PivotIdx) {
            R = PivotIdx - 1}
           else return;
        };
      } while (!(L >= R));
    };
    $impl.URLToArrayOfString = function (URL) {
      var Result = [];
      var a = [];
      var cors_api_url = "";
      cors_api_url = "";
      var xhr = new XMLHttpRequest();
          xhr.open("GET", cors_api_url + URL, false);
          xhr.send();
      
          if (xhr.status==200)
          {
            var obj = xhr.responseText.split(/\r\n|\n/);
            for (var i = 0; i < obj.length; i++) {
              a.push(obj[i]);
            }
          };
      Result = rtl.arrayRef(a);
      return Result;
    };
    $impl.ReqAsync = function (AURL, LoadProc, ErrorProc) {
      var req = null;
      function HandleResponse(Event) {
        var Result = false;
        var s = "";
        var status = 0;
        status = Event.target.status;
        s = Event.target.responseText;
        if (rtl.trunc(status / 100) === 2) {
          LoadProc(s)}
         else ErrorProc();
        Result = true;
        return Result;
      };
      function HandleError(Event) {
        var Result = false;
        ErrorProc();
        Result = true;
        return Result;
      };
      req = new XMLHttpRequest();
      req.addEventListener("load",rtl.createSafeCallback(null,HandleResponse));
      req.addEventListener("abort",rtl.createSafeCallback(null,HandleError));
      req.addEventListener("timeout",rtl.createSafeCallback(null,HandleError));
      req.addEventListener("error",rtl.createSafeCallback(null,HandleError));
      req.open("GET",AURL);
      req.send();
    };
    $impl.StringListAnsiCompare = function (List, Index1, Index) {
      var Result = 0;
      Result = List.DoCompareText(List.FList[Index1].FString,List.FList[Index].FString);
      return Result;
    };
    $impl.TMSGrow = 4096;
    $impl.FilerSignatureInt = 809914452;
    rtl.createClass($impl,"TUnresolvedReference",pas.simplelinkedlist.TLinkedListItem,function () {
      this.$init = function () {
        pas.simplelinkedlist.TLinkedListItem.$init.call(this);
        this.FRoot = null;
        this.FPropInfo = null;
        this.FGlobal = "";
        this.FRelative = "";
      };
      this.$final = function () {
        this.FRoot = undefined;
        this.FPropInfo = undefined;
        pas.simplelinkedlist.TLinkedListItem.$final.call(this);
      };
      this.Resolve = function (Instance) {
        var Result = false;
        var C = null;
        C = $mod.FindGlobalComponent(this.FGlobal);
        Result = C !== null;
        if (Result) {
          C = $mod.FindNestedComponent(C,this.FRelative,true);
          Result = C !== null;
          if (Result) pas.TypInfo.SetObjectProp$1(Instance,this.FPropInfo,C);
        };
        return Result;
      };
      this.RootMatches = function (ARoot) {
        var Result = false;
        Result = (ARoot === null) || (ARoot === this.FRoot);
        return Result;
      };
      this.NextRef = function () {
        var Result = null;
        Result = this.Next;
        return Result;
      };
    });
    rtl.createClass($impl,"TLocalUnResolvedReference",$impl.TUnresolvedReference,function () {
      this.$init = function () {
        $impl.TUnresolvedReference.$init.call(this);
        this.Finstance = null;
      };
      this.$final = function () {
        this.Finstance = undefined;
        $impl.TUnresolvedReference.$final.call(this);
      };
      var $r = this.$rtti;
      $r.addField("Finstance",$mod.$rtti["TPersistent"]);
    });
    rtl.createClass($impl,"TUnResolvedInstance",pas.simplelinkedlist.TLinkedListItem,function () {
      this.$init = function () {
        pas.simplelinkedlist.TLinkedListItem.$init.call(this);
        this.Instance = null;
        this.FUnresolved = null;
      };
      this.$final = function () {
        this.Instance = undefined;
        this.FUnresolved = undefined;
        pas.simplelinkedlist.TLinkedListItem.$final.call(this);
      };
      this.Destroy = function () {
        rtl.free(this,"FUnresolved");
        pas.System.TObject.Destroy.call(this);
      };
      this.AddReference = function (ARoot, APropInfo, AGlobal, ARelative) {
        var Result = null;
        if (this.FUnresolved === null) this.FUnresolved = pas.simplelinkedlist.TLinkedList.$create("Create$1",[$impl.TUnresolvedReference]);
        Result = rtl.as(this.FUnresolved.Add(),$impl.TUnresolvedReference);
        Result.FGlobal = AGlobal;
        Result.FRelative = ARelative;
        Result.FPropInfo = APropInfo;
        Result.FRoot = ARoot;
        return Result;
      };
      this.RootUnresolved = function () {
        var Result = null;
        Result = null;
        if (this.FUnresolved != null) Result = this.FUnresolved.FRoot;
        return Result;
      };
      this.ResolveReferences = function () {
        var Result = false;
        var R = null;
        var RN = null;
        R = this.RootUnresolved();
        while (R !== null) {
          RN = R.NextRef();
          if (R.Resolve(this.Instance)) this.FUnresolved.RemoveItem(R,true);
          R = RN;
        };
        Result = this.RootUnresolved() === null;
        return Result;
      };
    });
    rtl.createClass($impl,"TBuildListVisitor",pas.simplelinkedlist.TLinkedListVisitor,function () {
      this.$init = function () {
        pas.simplelinkedlist.TLinkedListVisitor.$init.call(this);
        this.List = null;
      };
      this.$final = function () {
        this.List = undefined;
        pas.simplelinkedlist.TLinkedListVisitor.$final.call(this);
      };
      this.Add = function (Item) {
        if (this.List === null) this.List = $mod.TFPList.$create("Create");
        this.List.Add(Item);
      };
      this.Destroy = function () {
        var I = 0;
        if (this.List != null) for (var $l = 0, $end = this.List.FCount - 1; $l <= $end; $l++) {
          I = $l;
          $impl.NeedResolving.RemoveItem(rtl.getObject(this.List.Get(I)),true);
        };
        pas.SysUtils.FreeAndNil({p: this, get: function () {
            return this.p.List;
          }, set: function (v) {
            this.p.List = v;
          }});
        pas.System.TObject.Destroy.call(this);
      };
    });
    rtl.createClass($impl,"TResolveReferenceVisitor",$impl.TBuildListVisitor,function () {
      this.Visit = function (Item) {
        var Result = false;
        if (Item.ResolveReferences()) this.Add(Item);
        Result = true;
        return Result;
      };
      var $r = this.$rtti;
      $r.addMethod("Visit",1,[["Item",pas.simplelinkedlist.$rtti["TLinkedListItem"]]],rtl.boolean);
    });
    rtl.createClass($impl,"TRemoveReferenceVisitor",$impl.TBuildListVisitor,function () {
      this.$init = function () {
        $impl.TBuildListVisitor.$init.call(this);
        this.FRef = "";
        this.FRoot = null;
      };
      this.$final = function () {
        this.FRoot = undefined;
        $impl.TBuildListVisitor.$final.call(this);
      };
      this.Create$1 = function (ARoot, ARef) {
        this.FRoot = ARoot;
        this.FRef = pas.SysUtils.UpperCase(ARef);
        return this;
      };
      this.Visit = function (Item) {
        var Result = false;
        var I = 0;
        var UI = null;
        var R = null;
        var L = null;
        UI = Item;
        R = UI.RootUnresolved();
        L = null;
        try {
          while (R !== null) {
            if (R.RootMatches(this.FRoot) && ((this.FRef === "") || (this.FRef === pas.SysUtils.UpperCase(R.FGlobal)))) {
              if (!(L != null)) L = $mod.TFPList.$create("Create");
              L.Add(R);
            };
            R = R.NextRef();
          };
          if (L != null) {
            for (var $l = 0, $end = L.FCount - 1; $l <= $end; $l++) {
              I = $l;
              UI.FUnresolved.RemoveItem(rtl.getObject(L.Get(I)),true);
            };
          };
          if (UI.FUnresolved.FRoot === null) {
            if (this.List === null) this.List = $mod.TFPList.$create("Create");
            this.List.Add(UI);
          };
        } finally {
          L = rtl.freeLoc(L);
        };
        Result = true;
        return Result;
      };
      var $r = this.$rtti;
      $r.addMethod("Create$1",2,[["ARoot",$mod.$rtti["TComponent"]],["ARef",rtl.string,2]]);
    });
    rtl.createClass($impl,"TReferenceNamesVisitor",pas.simplelinkedlist.TLinkedListVisitor,function () {
      this.$init = function () {
        pas.simplelinkedlist.TLinkedListVisitor.$init.call(this);
        this.FList = null;
        this.FRoot = null;
      };
      this.$final = function () {
        this.FList = undefined;
        this.FRoot = undefined;
        pas.simplelinkedlist.TLinkedListVisitor.$final.call(this);
      };
      this.Visit = function (Item) {
        var Result = false;
        var R = null;
        R = Item.RootUnresolved();
        while (R !== null) {
          if (R.RootMatches(this.FRoot)) if (this.FList.IndexOf(R.FGlobal) === -1) this.FList.Add(R.FGlobal);
          R = R.NextRef();
        };
        Result = true;
        return Result;
      };
      this.Create$1 = function (ARoot, AList) {
        this.FRoot = ARoot;
        this.FList = AList;
        return this;
      };
      var $r = this.$rtti;
      $r.addMethod("Create$1",2,[["ARoot",$mod.$rtti["TComponent"]],["AList",$mod.$rtti["TStrings"]]]);
    });
    rtl.createClass($impl,"TReferenceInstancesVisitor",pas.simplelinkedlist.TLinkedListVisitor,function () {
      this.$init = function () {
        pas.simplelinkedlist.TLinkedListVisitor.$init.call(this);
        this.FList = null;
        this.FRef = "";
        this.FRoot = null;
      };
      this.$final = function () {
        this.FList = undefined;
        this.FRoot = undefined;
        pas.simplelinkedlist.TLinkedListVisitor.$final.call(this);
      };
      this.Visit = function (Item) {
        var Result = false;
        var R = null;
        R = Item.RootUnresolved();
        while (R !== null) {
          if ((this.FRoot === R.FRoot) && (this.FRef === pas.SysUtils.UpperCase(R.FGlobal))) if (this.FList.IndexOf(R.FRelative) === -1) this.FList.Add(R.FRelative);
          R = R.NextRef();
        };
        Result = true;
        return Result;
      };
      this.Create$1 = function (ARoot, ARef, AList) {
        this.FRoot = ARoot;
        this.FRef = pas.SysUtils.UpperCase(ARef);
        this.FList = AList;
        return this;
      };
      var $r = this.$rtti;
      $r.addMethod("Create$1",2,[["ARoot",$mod.$rtti["TComponent"]],["ARef",rtl.string,2],["AList",$mod.$rtti["TStrings"]]]);
    });
    rtl.createClass($impl,"TRedirectReferenceVisitor",pas.simplelinkedlist.TLinkedListVisitor,function () {
      this.$init = function () {
        pas.simplelinkedlist.TLinkedListVisitor.$init.call(this);
        this.FOld = "";
        this.FNew = "";
        this.FRoot = null;
      };
      this.$final = function () {
        this.FRoot = undefined;
        pas.simplelinkedlist.TLinkedListVisitor.$final.call(this);
      };
      this.Visit = function (Item) {
        var Result = false;
        var R = null;
        R = Item.RootUnresolved();
        while (R !== null) {
          if (R.RootMatches(this.FRoot) && (this.FOld === pas.SysUtils.UpperCase(R.FGlobal))) R.FGlobal = this.FNew;
          R = R.NextRef();
        };
        Result = true;
        return Result;
      };
      this.Create$1 = function (ARoot, AOld, ANew) {
        this.FRoot = ARoot;
        this.FOld = pas.SysUtils.UpperCase(AOld);
        this.FNew = ANew;
        return this;
      };
      var $r = this.$rtti;
      $r.addMethod("Create$1",2,[["ARoot",$mod.$rtti["TComponent"]],["AOld",rtl.string,2],["ANew",rtl.string,2]]);
    });
    $impl.NeedResolving = null;
    $impl.FindUnresolvedInstance = function (AInstance) {
      var Result = null;
      Result = null;
      if ($impl.NeedResolving != null) {
        Result = $impl.NeedResolving.FRoot;
        while ((Result !== null) && (Result.Instance !== AInstance)) Result = Result.Next;
      };
      return Result;
    };
    $impl.AddtoResolveList = function (AInstance) {
      var Result = null;
      Result = $impl.FindUnresolvedInstance(AInstance);
      if (Result === null) {
        if (!($impl.NeedResolving != null)) $impl.NeedResolving = pas.simplelinkedlist.TLinkedList.$create("Create$1",[$impl.TUnResolvedInstance]);
        Result = rtl.as($impl.NeedResolving.Add(),$impl.TUnResolvedInstance);
        Result.Instance = AInstance;
      };
      return Result;
    };
    $impl.VisitResolveList = function (V) {
      try {
        $impl.NeedResolving.ForEach(V);
      } finally {
        pas.SysUtils.FreeAndNil({get: function () {
            return V;
          }, set: function (v) {
            V = v;
          }});
      };
    };
    $impl.GlobalFixupReferences = function () {
      if ($impl.NeedResolving === null) return;
      $impl.VisitResolveList($impl.TResolveReferenceVisitor.$create("Create"));
    };
    rtl.createClass($impl,"TPosComponent",pas.System.TObject,function () {
      this.$init = function () {
        pas.System.TObject.$init.call(this);
        this.FPos = 0;
        this.FComponent = null;
      };
      this.$final = function () {
        this.FComponent = undefined;
        pas.System.TObject.$final.call(this);
      };
      this.Create$1 = function (APos, AComponent) {
        this.FPos = APos;
        this.FComponent = AComponent;
        return this;
      };
      var $r = this.$rtti;
      $r.addMethod("Create$1",2,[["APos",rtl.longint],["AComponent",$mod.$rtti["TComponent"]]]);
    });
    rtl.createClass($impl,"TInitHandler",pas.System.TObject,function () {
      this.$init = function () {
        pas.System.TObject.$init.call(this);
        this.AHandler = null;
        this.AClass = null;
      };
      this.$final = function () {
        this.AHandler = undefined;
        this.AClass = undefined;
        pas.System.TObject.$final.call(this);
      };
      var $r = this.$rtti;
      $r.addField("AHandler",$mod.$rtti["TInitComponentHandler"]);
      $r.addField("AClass",$mod.$rtti["TComponentClass"]);
    });
    $impl.ClassList = null;
    $impl.InitHandlerList = null;
    $impl.FindGlobalComponentList = null;
    $impl.ParseBufSize = 4096;
    $mod.$rtti.$StaticArray("TokNames$a",{dims: [20], eltype: rtl.string});
    $impl.TokNames = ["?","EOF","Symbol","String","Integer","Float","-","[","(","<","{","]",")",">","}",",",".","=",":","+"];
    $mod.$resourcestrings = {SStreamInvalidSeek: {org: "Seek is not implemented for class %s"}, SStreamNoReading: {org: "Stream reading is not implemented for class %s"}, SStreamNoWriting: {org: "Stream writing is not implemented for class %s"}, SReadError: {org: "Could not read data from stream"}, SWriteError: {org: "Could not write data to stream"}, SMemoryStreamError: {org: "Could not allocate memory"}, SerrInvalidStreamSize: {org: "Invalid Stream size"}};
  };
  $mod.$init = function () {
    (function () {
      $mod.RegisterInitComponentHandler($mod.TDataModule,$impl.DefaultInitHandler);
    })();
    $impl.ClassList = new Object();
  };
},["Web","simplelinkedlist"]);
rtl.module("UITypes",["System"],function () {
  "use strict";
  var $mod = this;
  this.$rtti.$inherited("TFontName",rtl.string,{});
});
rtl.module("WEBLib.Consts",["System"],function () {
  "use strict";
  var $mod = this;
  $mod.$resourcestrings = {SWarning: {org: "Warning"}, SError: {org: "Error"}, SInformation: {org: "Information"}, SConfirm: {org: "Confirm"}, SOK: {org: "OK"}, SCancel: {org: "Cancel"}, SYes: {org: "Yes"}, SNo: {org: "No"}, SAbort: {org: "Abort"}, SRetry: {org: "Retry"}, SIgnore: {org: "Ignore"}, SHelp: {org: "Help"}, SClose: {org: "Close"}, SAll: {org: "All"}, SYesToAll: {org: "Yes to all"}, SNoToAll: {org: "No to all"}, SReadError: {org: "Stream read error"}, SWriteError: {org: "Stream write error"}, SCannotGetFile: {org: "Cannot get the file from the URL %s because of the error %d!"}, SErrorLoadFromFile: {org: "There was an error during the download of the file %s!"}, SLoadFromFileAborted: {org: "The download of the file %s was aborted!"}, SWarningFR: {org: "Avertissement"}, SErrorFR: {org: "Erreur"}, SInformationFR: {org: "Information"}, SConfirmFR: {org: "Confirmer"}, SOKFR: {org: "OK"}, SCancelFR: {org: "Annuler"}, SYesFR: {org: "Oui"}, SNoFR: {org: "Non"}, SAbortFR: {org: "Interrompre"}, SRetryFR: {org: "Réessayer"}, SIgnoreFR: {org: "Ignorer"}, SHelpFR: {org: "Aide"}, SCloseFR: {org: "Fermer"}, SAllFR: {org: "Tout"}, SYesToAllFR: {org: "Oui à tout"}, SNoToAllFR: {org: "Non à tout"}, SWarningDE: {org: "Warnung"}, SErrorDE: {org: "Fehler"}, SInformationDE: {org: "Information"}, SConfirmDE: {org: "Bestätigen"}, SOKDE: {org: "OK"}, SCancelDE: {org: "Abbrechen"}, SYesDE: {org: "Ja"}, SNoDE: {org: "Nein"}, SAbortDE: {org: "Abbrechen"}, SRetryDE: {org: "Wiederholen"}, SIgnoreDE: {org: "Ignorieren"}, SHelpDE: {org: "Hilfe"}, SCloseDE: {org: "Schließen"}, SAllDE: {org: "Alles"}, SYesToAllDE: {org: "Ja auf Alles"}, SNoToAllDE: {org: "Nein auf Alles"}, SWarningES: {org: "Advertencia"}, SErrorES: {org: "Error"}, SInformationES: {org: "Información"}, SConfirmES: {org: "Confirmado"}, SOKES: {org: "OK"}, SCancelES: {org: "Cancelar"}, SYesES: {org: "Sí"}, SNoES: {org: "No"}, SAbortES: {org: "Abortar"}, SRetryES: {org: "Rever"}, SIgnoreES: {org: "Ignorar"}, SHelpES: {org: "Ayudar"}, SCloseES: {org: "Cerrar"}, SAllES: {org: "Todos"}, SYesToAllES: {org: "Sí a todo"}, SNoToAllES: {org: "No a todo"}, SWarningNL: {org: "Waarschuwing"}, SErrorNL: {org: "Fout"}, SInformationNL: {org: "Informatie"}, SConfirmNL: {org: "Bevestiging"}, SOKNL: {org: "OK"}, SCancelNL: {org: "Afbreken"}, SYesNL: {org: "Ja"}, SNoNL: {org: "Nee"}, SAbortNL: {org: "Afbreken"}, SRetryNL: {org: "Opnieuw"}, SIgnoreNL: {org: "Negeren"}, SHelpNL: {org: "Hulp"}, SCloseNL: {org: "Sluiten"}, SAllNL: {org: "Alles"}, SYesToAllNL: {org: "Ja op alles"}, SNoToAllNL: {org: "Nee op alles"}};
});
rtl.module("WEBLib.Dialogs",["System","Classes","WEBLib.Controls","Web","JS","SysUtils","WEBLib.Graphics"],function () {
  "use strict";
  var $mod = this;
  var $impl = $mod.$impl;
  this.TMsgDlgType = {"0": "mtWarning", mtWarning: 0, "1": "mtError", mtError: 1, "2": "mtInformation", mtInformation: 2, "3": "mtConfirmation", mtConfirmation: 3, "4": "mtCustom", mtCustom: 4};
  this.$rtti.$Enum("TMsgDlgType",{minvalue: 0, maxvalue: 4, ordtype: 1, enumtype: this.TMsgDlgType});
  this.TMsgDlgBtn = {"0": "mbYes", mbYes: 0, "1": "mbNo", mbNo: 1, "2": "mbOK", mbOK: 2, "3": "mbCancel", mbCancel: 3, "4": "mbAbort", mbAbort: 4, "5": "mbRetry", mbRetry: 5, "6": "mbIgnore", mbIgnore: 6, "7": "mbAll", mbAll: 7, "8": "mbNoToAll", mbNoToAll: 8, "9": "mbYesToAll", mbYesToAll: 9, "10": "mbHelp", mbHelp: 10, "11": "mbClose", mbClose: 11};
  this.$rtti.$Enum("TMsgDlgBtn",{minvalue: 0, maxvalue: 11, ordtype: 1, enumtype: this.TMsgDlgBtn});
  this.$rtti.$Set("TMsgDlgButtons",{comptype: this.$rtti["TMsgDlgBtn"]});
  this.$rtti.$RefToProcVar("TDialogResultProc",{procsig: rtl.newTIProcSig([["AValue",rtl.longint]])});
  rtl.createClass(this,"TCustomDialogButton",pas.Classes.TCollectionItem,function () {
    this.$init = function () {
      pas.Classes.TCollectionItem.$init.call(this);
      this.FCaption = "";
      this.FTag = 0;
      this.FElementClassName = "";
    };
    var $r = this.$rtti;
    $r.addProperty("Caption",0,rtl.string,"FCaption","FCaption");
    $r.addProperty("ElementClassName",0,pas["WEBLib.Controls"].$rtti["TElementClassName"],"FElementClassName","FElementClassName");
    $r.addProperty("Tag",0,rtl.longint,"FTag","FTag",{Default: 0});
  });
  rtl.createClass(this,"TCustomDialogButtons",pas.Classes.TOwnedCollection,function () {
    this.GetItem$1 = function (AIndex) {
      var Result = null;
      Result = this.GetItem(AIndex);
      return Result;
    };
    this.SetItem$1 = function (AIndex, Value) {
      this.SetItem(AIndex,Value);
    };
    this.Add$1 = function () {
      var Result = null;
      Result = pas.Classes.TCollection.Add.call(this);
      return Result;
    };
    this.Insert$1 = function (AIndex) {
      var Result = null;
      Result = pas.Classes.TCollection.Insert.call(this,AIndex);
      return Result;
    };
  });
  rtl.createClass(this,"TMessageDlg",pas["WEBLib.Controls"].TCustomControl,function () {
    this.$init = function () {
      pas["WEBLib.Controls"].TCustomControl.$init.call(this);
      this.FOpacity = 0.0;
      this.FLayer$1 = null;
      this.FDlg = null;
      this.FCancel = null;
      this.FMessage = "";
      this.FTitle = "";
      this.FMsgDlgType = 0;
      this.FOnButtonClick = null;
      this.FOnClose = null;
      this.FButtons = {};
      this.FDialogProc = null;
      this.FDialogResult = 0;
      this.FMdx = 0;
      this.FMdy = 0;
      this.FDlgX = 0;
      this.FDlgY = 0;
      this.FCaptured$1 = false;
      this.FDown = false;
      this.FElementTitleClassName = "";
      this.FElementButtonClassName = "";
      this.FElementContentClassName = "";
      this.FDialogText = null;
      this.FCustomButtons = null;
      this.FElementDialogClassName = "";
      this.FAutoLanguage = false;
      this.FUseMaterial = false;
    };
    this.$final = function () {
      this.FLayer$1 = undefined;
      this.FDlg = undefined;
      this.FCancel = undefined;
      this.FOnButtonClick = undefined;
      this.FOnClose = undefined;
      this.FButtons = undefined;
      this.FDialogProc = undefined;
      this.FDialogText = undefined;
      this.FCustomButtons = undefined;
      pas["WEBLib.Controls"].TCustomControl.$final.call(this);
    };
    this.SetDialogText = function (Value) {
      this.FDialogText.Assign(Value);
    };
    this.SetCustomButtons = function (Value) {
      this.FCustomButtons.Assign(Value);
    };
    this.CreateElement = function () {
      var Result = null;
      if (pas.Classes.TComponentStateItem.csDesigning in this.FComponentState) {
        Result = null}
       else pas["WEBLib.Controls"].TCustomControl.CreateElement.call(this);
      return Result;
    };
    var TLang = {"0": "lEN", lEN: 0, "1": "lFR", lFR: 1, "2": "lDE", lDE: 2, "3": "lES", lES: 3, "4": "lNL", lNL: 4};
    this.GetDialogText = function (Index) {
      var Result = "";
      var locl = "";
      var l = 0;
      Result = "Undefined";
      if (Index < this.FDialogText.GetCount()) Result = this.FDialogText.Get(Index);
      if (this.FAutoLanguage) {
        locl = pas["WEBLib.WebTools"].GetBrowserLocale();
        l = TLang.lEN;
        if (pas.System.Pos("es",locl) === 1) l = TLang.lES;
        if (pas.System.Pos("fr",locl) === 1) l = TLang.lFR;
        if (pas.System.Pos("de",locl) === 1) l = TLang.lDE;
        if (pas.System.Pos("nl",locl) === 1) l = TLang.lNL;
        var $tmp = l;
        if ($tmp === TLang.lES) {
          var $tmp1 = Index;
          if ($tmp1 === 0) {
            Result = rtl.getResStr(pas["WEBLib.Consts"],"SWarningES")}
           else if ($tmp1 === 1) {
            Result = rtl.getResStr(pas["WEBLib.Consts"],"SErrorES")}
           else if ($tmp1 === 2) {
            Result = rtl.getResStr(pas["WEBLib.Consts"],"SInformationES")}
           else if ($tmp1 === 3) {
            Result = rtl.getResStr(pas["WEBLib.Consts"],"SConfirmES")}
           else if ($tmp1 === 5) {
            Result = rtl.getResStr(pas["WEBLib.Consts"],"SOKES")}
           else if ($tmp1 === 6) {
            Result = rtl.getResStr(pas["WEBLib.Consts"],"SCancelES")}
           else if ($tmp1 === 7) {
            Result = rtl.getResStr(pas["WEBLib.Consts"],"SYesES")}
           else if ($tmp1 === 8) {
            Result = rtl.getResStr(pas["WEBLib.Consts"],"SNoES")}
           else if ($tmp1 === 9) {
            Result = rtl.getResStr(pas["WEBLib.Consts"],"SAbortES")}
           else if ($tmp1 === 10) {
            Result = rtl.getResStr(pas["WEBLib.Consts"],"SRetryES")}
           else if ($tmp1 === 11) {
            Result = rtl.getResStr(pas["WEBLib.Consts"],"SIgnoreES")}
           else if ($tmp1 === 12) {
            Result = rtl.getResStr(pas["WEBLib.Consts"],"SAllES")}
           else if ($tmp1 === 13) {
            Result = rtl.getResStr(pas["WEBLib.Consts"],"SYesToAllES")}
           else if ($tmp1 === 14) {
            Result = rtl.getResStr(pas["WEBLib.Consts"],"SNoToAllES")}
           else if ($tmp1 === 15) {
            Result = rtl.getResStr(pas["WEBLib.Consts"],"SHelpES")}
           else if ($tmp1 === 16) Result = rtl.getResStr(pas["WEBLib.Consts"],"SCloseES");
        } else if ($tmp === TLang.lFR) {
          var $tmp2 = Index;
          if ($tmp2 === 0) {
            Result = rtl.getResStr(pas["WEBLib.Consts"],"SWarningFR")}
           else if ($tmp2 === 1) {
            Result = rtl.getResStr(pas["WEBLib.Consts"],"SErrorFR")}
           else if ($tmp2 === 2) {
            Result = rtl.getResStr(pas["WEBLib.Consts"],"SInformationFR")}
           else if ($tmp2 === 3) {
            Result = rtl.getResStr(pas["WEBLib.Consts"],"SConfirmFR")}
           else if ($tmp2 === 5) {
            Result = rtl.getResStr(pas["WEBLib.Consts"],"SOKFR")}
           else if ($tmp2 === 6) {
            Result = rtl.getResStr(pas["WEBLib.Consts"],"SCancelFR")}
           else if ($tmp2 === 7) {
            Result = rtl.getResStr(pas["WEBLib.Consts"],"SYesFR")}
           else if ($tmp2 === 8) {
            Result = rtl.getResStr(pas["WEBLib.Consts"],"SNoFR")}
           else if ($tmp2 === 9) {
            Result = rtl.getResStr(pas["WEBLib.Consts"],"SAbortFR")}
           else if ($tmp2 === 10) {
            Result = rtl.getResStr(pas["WEBLib.Consts"],"SRetryFR")}
           else if ($tmp2 === 11) {
            Result = rtl.getResStr(pas["WEBLib.Consts"],"SIgnoreFR")}
           else if ($tmp2 === 12) {
            Result = rtl.getResStr(pas["WEBLib.Consts"],"SAllFR")}
           else if ($tmp2 === 13) {
            Result = rtl.getResStr(pas["WEBLib.Consts"],"SYesToAllFR")}
           else if ($tmp2 === 14) {
            Result = rtl.getResStr(pas["WEBLib.Consts"],"SNoToAllFR")}
           else if ($tmp2 === 15) {
            Result = rtl.getResStr(pas["WEBLib.Consts"],"SHelpFR")}
           else if ($tmp2 === 16) Result = rtl.getResStr(pas["WEBLib.Consts"],"SCloseFR");
        } else if ($tmp === TLang.lDE) {
          var $tmp3 = Index;
          if ($tmp3 === 0) {
            Result = rtl.getResStr(pas["WEBLib.Consts"],"SWarningDE")}
           else if ($tmp3 === 1) {
            Result = rtl.getResStr(pas["WEBLib.Consts"],"SErrorDE")}
           else if ($tmp3 === 2) {
            Result = rtl.getResStr(pas["WEBLib.Consts"],"SInformationDE")}
           else if ($tmp3 === 3) {
            Result = rtl.getResStr(pas["WEBLib.Consts"],"SConfirmDE")}
           else if ($tmp3 === 5) {
            Result = rtl.getResStr(pas["WEBLib.Consts"],"SOKDE")}
           else if ($tmp3 === 6) {
            Result = rtl.getResStr(pas["WEBLib.Consts"],"SCancelDE")}
           else if ($tmp3 === 7) {
            Result = rtl.getResStr(pas["WEBLib.Consts"],"SYesDE")}
           else if ($tmp3 === 8) {
            Result = rtl.getResStr(pas["WEBLib.Consts"],"SNoDE")}
           else if ($tmp3 === 9) {
            Result = rtl.getResStr(pas["WEBLib.Consts"],"SAbortDE")}
           else if ($tmp3 === 10) {
            Result = rtl.getResStr(pas["WEBLib.Consts"],"SRetryDE")}
           else if ($tmp3 === 11) {
            Result = rtl.getResStr(pas["WEBLib.Consts"],"SIgnoreDE")}
           else if ($tmp3 === 12) {
            Result = rtl.getResStr(pas["WEBLib.Consts"],"SAllDE")}
           else if ($tmp3 === 13) {
            Result = rtl.getResStr(pas["WEBLib.Consts"],"SYesToAllDE")}
           else if ($tmp3 === 14) {
            Result = rtl.getResStr(pas["WEBLib.Consts"],"SNoToAllDE")}
           else if ($tmp3 === 15) {
            Result = rtl.getResStr(pas["WEBLib.Consts"],"SHelpDE")}
           else if ($tmp3 === 16) Result = rtl.getResStr(pas["WEBLib.Consts"],"SCloseDE");
        } else if ($tmp === TLang.lNL) {
          var $tmp4 = Index;
          if ($tmp4 === 0) {
            Result = rtl.getResStr(pas["WEBLib.Consts"],"SWarningNL")}
           else if ($tmp4 === 1) {
            Result = rtl.getResStr(pas["WEBLib.Consts"],"SErrorNL")}
           else if ($tmp4 === 2) {
            Result = rtl.getResStr(pas["WEBLib.Consts"],"SInformationNL")}
           else if ($tmp4 === 3) {
            Result = rtl.getResStr(pas["WEBLib.Consts"],"SConfirmNL")}
           else if ($tmp4 === 5) {
            Result = rtl.getResStr(pas["WEBLib.Consts"],"SOKNL")}
           else if ($tmp4 === 6) {
            Result = rtl.getResStr(pas["WEBLib.Consts"],"SCancelNL")}
           else if ($tmp4 === 7) {
            Result = rtl.getResStr(pas["WEBLib.Consts"],"SYesNL")}
           else if ($tmp4 === 8) {
            Result = rtl.getResStr(pas["WEBLib.Consts"],"SNoNL")}
           else if ($tmp4 === 9) {
            Result = rtl.getResStr(pas["WEBLib.Consts"],"SAbortNL")}
           else if ($tmp4 === 10) {
            Result = rtl.getResStr(pas["WEBLib.Consts"],"SRetryNL")}
           else if ($tmp4 === 11) {
            Result = rtl.getResStr(pas["WEBLib.Consts"],"SIgnoreNL")}
           else if ($tmp4 === 12) {
            Result = rtl.getResStr(pas["WEBLib.Consts"],"SAllNL")}
           else if ($tmp4 === 13) {
            Result = rtl.getResStr(pas["WEBLib.Consts"],"SYesToAllNL")}
           else if ($tmp4 === 14) {
            Result = rtl.getResStr(pas["WEBLib.Consts"],"SNoToAllNL")}
           else if ($tmp4 === 15) {
            Result = rtl.getResStr(pas["WEBLib.Consts"],"SHelpNL")}
           else if ($tmp4 === 16) Result = rtl.getResStr(pas["WEBLib.Consts"],"SCloseNL");
        };
      };
      return Result;
    };
    this.BindEvents = function () {
    };
    this.SetDialogResult = function (Value) {
      this.FDialogResult = Value;
      if (this.FDialogResult !== 0) this.Close();
    };
    this.CreateButton = function (Caption, DoFocus, AClass) {
      var Result = null;
      Result = document.createElement("BUTTON");
      Result.innerHTML = Caption;
      if (pas["WEBLib.Forms"].Application.FMainForm.FCSSLibrary === pas["WEBLib.Controls"].TCSSLibrary.cssBootstrap) {
        Result.setAttribute("type","BUTTON");
        Result.setAttribute("class","btn " + AClass);
        Result.setAttribute("data-dismiss","modal-dialog");
      } else {
        Result.style.setProperty("width","100px");
        Result.style.setProperty("margin-left","5px");
        if (this.FElementButtonClassName !== "") {
          Result.setAttribute("class",this.FElementButtonClassName + " " + AClass)}
         else if (pas["WEBLib.Forms"].Application.FThemeButtonClassName !== "") Result.setAttribute("class",pas["WEBLib.Forms"].Application.FThemeButtonClassName + " " + AClass);
      };
      Result.id = Caption;
      Result.addEventListener("click",rtl.createSafeCallback(this,"HandleButtonClick"));
      Result.addEventListener("keydown",rtl.createSafeCallback(this,"HandleKeyDown"));
      if (DoFocus.get()) {
        setTimeout(function() {Result.focus();}, 1);
        DoFocus.set(false);
      };
      return Result;
    };
    this.HandleDocMouseMove = function (Event) {
      var Result = false;
      var deltax = 0.0;
      var deltay = 0.0;
      var el = null;
      var AEvent = null;
      AEvent = Event;
      if (this.FDown) {
        deltax = AEvent.screenX - this.FMdx;
        deltay = AEvent.screenY - this.FMdy;
        el = this.FDlg;
        el.style.setProperty("transform","");
        el.style.setProperty("position","absolute");
        el.style.setProperty("left",pas.SysUtils.IntToStr(Math.round(this.FDlgX + deltax)) + "px");
        el.style.setProperty("top",pas.SysUtils.IntToStr(Math.round(this.FDlgY + deltay)) + "px");
        el = this.FCancel;
        el.style.setProperty("position","absolute");
        el.style.setProperty("top","0");
        el.style.setProperty("right","0");
      };
      Result = true;
      return Result;
    };
    this.HandleDocMouseUp = function (Event) {
      var Result = false;
      this.FDown = false;
      document.body.removeEventListener("mousemove",rtl.createSafeCallback(this,"HandleDocMouseMove"));
      document.body.removeEventListener("mouseup",rtl.createSafeCallback(this,"HandleDocMouseUp"));
      Result = true;
      return Result;
    };
    this.HandleMouseDown = function (Event) {
      var Result = false;
      var r = null;
      var AEvent = null;
      AEvent = Event;
      this.FMdx = Math.round(AEvent.screenX);
      this.FMdy = Math.round(AEvent.screenY);
      r = this.FDlg.getBoundingClientRect();
      this.FDlgX = Math.round(pas.System.Int(r.left));
      this.FDlgY = Math.round(pas.System.Int(r.top));
      this.FDown = true;
      if (!this.FCaptured$1) {
        this.FCaptured$1 = true;
        document.body.addEventListener("mousemove",rtl.createSafeCallback(this,"HandleDocMouseMove"));
        document.body.addEventListener("mouseup",rtl.createSafeCallback(this,"HandleDocMouseUp"));
      };
      Result = true;
      return Result;
    };
    this.HandleButtonClick = function (Event) {
      var Result = false;
      var id = "";
      var i = 0;
      this.SetDialogResult(0);
      id = Event.target.getAttribute("id");
      if (id === this.GetDialogText(7)) {
        this.SetDialogResult(6)}
       else if (id === this.GetDialogText(8)) {
        this.SetDialogResult(7)}
       else if (id === this.GetDialogText(5)) {
        this.SetDialogResult(1)}
       else if (id === this.GetDialogText(6)) {
        this.SetDialogResult(2)}
       else if (id === this.GetDialogText(9)) {
        this.SetDialogResult(3)}
       else if (id === this.GetDialogText(10)) {
        this.SetDialogResult(4)}
       else if (id === this.GetDialogText(11)) {
        this.SetDialogResult(5)}
       else if (id === this.GetDialogText(12)) {
        this.SetDialogResult(12)}
       else if (id === this.GetDialogText(13)) {
        this.SetDialogResult(13)}
       else if (id === this.GetDialogText(14)) {
        this.SetDialogResult(14)}
       else if (id === this.GetDialogText(15)) {
        this.SetDialogResult(9)}
       else if (id === this.GetDialogText(16)) this.SetDialogResult(8);
      if ((this.FDialogResult === 0) && (this.FCustomButtons.GetCount() > 0)) {
        for (var $l = 0, $end = this.FCustomButtons.GetCount() - 1; $l <= $end; $l++) {
          i = $l;
          if (id === this.FCustomButtons.GetItem$1(i).FCaption) {
            this.SetDialogResult(100 + i);
            break;
          };
        };
      };
      if (this.FOnButtonClick != null) this.FOnButtonClick(this);
      Result = true;
      return Result;
    };
    this.HandleKeyDown = function (Event) {
      var Result = false;
      var k = 0;
      var AEvent = null;
      AEvent = Event;
      k = this.GetKeyCode(AEvent.key,true);
      if (!pas.System.Assigned(k)) return Result;
      if (k === 27) this.SetDialogResult(2);
      Result = true;
      return Result;
    };
    this.InitBootstrapStyle = function () {
      this.FElementButtonClassName = "btn";
      this.FElementContentClassName = "text-body";
      this.FElementTitleClassName = "text-body";
      this.FElementDialogClassName = "shadow-lg p-3 mb-5 bg-white rounded";
    };
    this.InsertInputElement = function (AElement, DoFocus) {
    };
    this.CreateInitialize = function () {
      pas["WEBLib.Controls"].TCustomControl.CreateInitialize.call(this);
      this.FOpacity = 0.2;
      this.FMessage = "";
      this.FAutoLanguage = true;
      this.FMsgDlgType = $mod.TMsgDlgType.mtInformation;
      this.FDialogText = pas.Classes.TStringList.$create("Create$1");
      this.FDialogText.SetSkipLastLineBreak(true);
      this.FDialogText.Add(rtl.getResStr(pas["WEBLib.Consts"],"SWarning"));
      this.FDialogText.Add(rtl.getResStr(pas["WEBLib.Consts"],"SError"));
      this.FDialogText.Add(rtl.getResStr(pas["WEBLib.Consts"],"SInformation"));
      this.FDialogText.Add(rtl.getResStr(pas["WEBLib.Consts"],"SConfirm"));
      this.FDialogText.Add("Custom");
      this.FDialogText.Add(rtl.getResStr(pas["WEBLib.Consts"],"SOK"));
      this.FDialogText.Add(rtl.getResStr(pas["WEBLib.Consts"],"SCancel"));
      this.FDialogText.Add(rtl.getResStr(pas["WEBLib.Consts"],"SYes"));
      this.FDialogText.Add(rtl.getResStr(pas["WEBLib.Consts"],"SNo"));
      this.FDialogText.Add(rtl.getResStr(pas["WEBLib.Consts"],"SAbort"));
      this.FDialogText.Add(rtl.getResStr(pas["WEBLib.Consts"],"SRetry"));
      this.FDialogText.Add(rtl.getResStr(pas["WEBLib.Consts"],"SIgnore"));
      this.FDialogText.Add(rtl.getResStr(pas["WEBLib.Consts"],"SAll"));
      this.FDialogText.Add(rtl.getResStr(pas["WEBLib.Consts"],"SYesToAll"));
      this.FDialogText.Add(rtl.getResStr(pas["WEBLib.Consts"],"SNoToAll"));
      this.FDialogText.Add(rtl.getResStr(pas["WEBLib.Consts"],"SHelp"));
      this.FDialogText.Add(rtl.getResStr(pas["WEBLib.Consts"],"SClose"));
      this.FMsgDlgType = $mod.TMsgDlgType.mtCustom;
      this.FUseMaterial = true;
      this.FCustomButtons = $mod.TCustomDialogButtons.$create("Create$2",[this,$mod.TCustomDialogButton]);
      this.FCustomButtons.FPropName = "CustomButtons";
    };
    this.Destroy = function () {
      rtl.free(this,"FDialogText");
      rtl.free(this,"FCustomButtons");
      pas["WEBLib.Controls"].TCustomControl.Destroy.call(this);
    };
    this.Close = function () {
      pas["WEBLib.Forms"].Application.UnLockForm(pas["WEBLib.Forms"].Application.FMainForm);
      document.body.removeChild(this.FLayer$1);
      document.body.removeChild(this.FDlg);
      this.FDown = false;
      this.FCaptured$1 = false;
      if (this.FOnClose != null) this.FOnClose(this);
      if (this.FDialogProc != null) this.FDialogProc(this.FDialogResult);
    };
    this.Show$1 = function () {
      var title = null;
      var msg = null;
      var icon = null;
      var content = null;
      var contentdiv = null;
      var bar = null;
      var edlg = null;
      var eh = null;
      var cancel = null;
      var adiv = null;
      var ldiv = null;
      var cdiv = null;
      var MsgSymbol = "";
      var MsgColor = "";
      var MsgTitle = "";
      var BorderColor = "";
      var BarBGColor = "";
      var BarHeight = "";
      var Padding = "";
      var btnFocus = false;
      var i = 0;
      if ((pas["WEBLib.Forms"].Application === null) || (pas["WEBLib.Forms"].Application.FMainForm === null)) return;
      if (this.FUseMaterial && !pas["WEBLib.Forms"].Application.HasCSS($impl.lMaterial)) this.AddControlLink("material",$impl.lMaterial);
      pas["WEBLib.Forms"].Application.LockForm(pas["WEBLib.Forms"].Application.FMainForm);
      this.FLayer$1 = document.createElement("SPAN");
      document.body.appendChild(this.FLayer$1);
      this.FLayer$1.setAttribute("tabindex","0");
      this.FLayer$1.addEventListener("keydown",rtl.createSafeCallback(this,"HandleKeyDown"));
      btnFocus = true;
      this.FMessage = $impl.StringToHTML(this.FMessage);
      var $tmp = this.FMsgDlgType;
      if ($tmp === $mod.TMsgDlgType.mtWarning) {
        MsgSymbol = "warning";
        MsgColor = "orange";
        MsgTitle = this.GetDialogText(0);
      } else if ($tmp === $mod.TMsgDlgType.mtError) {
        MsgSymbol = "cancel";
        MsgColor = "red";
        MsgTitle = this.GetDialogText(1);
      } else if ($tmp === $mod.TMsgDlgType.mtInformation) {
        MsgSymbol = "info";
        MsgColor = "blue";
        MsgTitle = this.GetDialogText(2);
      } else if ($tmp === $mod.TMsgDlgType.mtConfirmation) {
        MsgSymbol = "help";
        MsgColor = "blue";
        MsgTitle = this.GetDialogText(3);
      } else if ($tmp === $mod.TMsgDlgType.mtCustom) {
        MsgSymbol = "";
        MsgColor = "";
        MsgTitle = this.GetDialogText(4);
      };
      if (this.FTitle !== "") MsgTitle = this.FTitle;
      if (pas["WEBLib.Forms"].Application.FMainForm.FCSSLibrary === pas["WEBLib.Controls"].TCSSLibrary.cssBootstrap) {
        this.FDlg = document.createElement("DIV");
        this.FDlg.setAttribute("class","modal-dialog");
        this.FDlg.setAttribute("role","document");
        this.FDlg.style.setProperty("z-index","1999998");
        eh = document.createElement("DIV");
        eh.style.setProperty("top","0");
        eh.style.setProperty("left","0");
        eh.style.setProperty("right","0");
        eh.style.setProperty("bottom","0");
        eh.style.setProperty("z-index","1999997");
        eh.style.setProperty("display","block");
        eh.setAttribute("class","modal show fade");
        document.body.appendChild(eh);
        eh.appendChild(this.FDlg);
        ldiv = this.FDlg;
        adiv = document.createElement("DIV");
        adiv.setAttribute("class","modal-content " + this.FElementDialogClassName);
        ldiv.appendChild(adiv);
        cdiv = adiv;
        ldiv = adiv;
        adiv = document.createElement("DIV");
        adiv.setAttribute("class","modal-header");
        cdiv.appendChild(adiv);
        ldiv = adiv;
        adiv = document.createElement("H5");
        adiv.setAttribute("class","modal-title");
        adiv.innerHTML = MsgTitle;
        ldiv.appendChild(adiv);
        if ($mod.TMsgDlgBtn.mbCancel in this.FButtons) {
          adiv = document.createElement("BUTTON");
          adiv.setAttribute("type","button");
          adiv.setAttribute("class","close btn btn-danger");
          adiv.setAttribute("data-dismiss","modal-dialog");
          adiv.setAttribute("aria-label","Close");
          adiv.setAttribute("id",this.GetDialogText(6));
          adiv.addEventListener("click",rtl.createSafeCallback(this,"HandleButtonClick"));
          ldiv.appendChild(adiv);
          ldiv = adiv;
          adiv = document.createElement("SPAN");
          adiv.setAttribute("aria-hidden","true");
          adiv.setAttribute("id",this.GetDialogText(6));
          adiv.innerHTML = "&times;";
          ldiv.appendChild(adiv);
        };
        adiv = document.createElement("DIV");
        adiv.setAttribute("class","modal-body");
        cdiv.appendChild(adiv);
        ldiv = adiv;
        if (this.FMsgDlgType !== $mod.TMsgDlgType.mtCustom) {
          icon = document.createElement("SPAN");
          icon.innerHTML = '<i class="material-icons" style="color:' + MsgColor + '!important;font-size:48px!important">' + MsgSymbol + "</i>";
          icon.style.setProperty("display","inline-block");
          icon.style.setProperty("float","left");
          icon.style.setProperty("padding-right","15px");
          ldiv.appendChild(icon);
        };
        adiv = document.createElement("H6");
        adiv.innerHTML = this.FMessage;
        ldiv.appendChild(adiv);
        this.InsertInputElement(ldiv,{get: function () {
            return btnFocus;
          }, set: function (v) {
            btnFocus = v;
          }});
        adiv = document.createElement("DIV");
        adiv.setAttribute("class","modal-footer");
        cdiv.appendChild(adiv);
        ldiv = adiv;
        bar = ldiv;
        this.FDlg = eh;
      } else {
        Padding = "5";
        BarHeight = "26";
        BarBGColor = "#f1f1f1";
        BorderColor = "#ababab";
        this.FDlg = document.createElement("DIV");
        document.body.appendChild(this.FDlg);
        edlg = this.FDlg;
        if (this.FElementDialogClassName !== "") {
          edlg.setAttribute("class",this.FElementDialogClassName)}
         else {
          edlg.style.setProperty("background-color","white");
          edlg.style.setProperty("border","1px solid " + BorderColor);
          edlg.style.setProperty("font-family","Arial");
          edlg.style.setProperty("font-size","10pt");
        };
        edlg.style.setProperty("cursor","default");
        edlg.style.setProperty("position","fixed");
        edlg.style.setProperty("min-width","300px");
        edlg.style.setProperty("min-height","125px");
        edlg.style.setProperty("max-width","100%");
        edlg.style.setProperty("max-height","100%");
        edlg.style.setProperty("top","50%");
        edlg.style.setProperty("left","50%");
        edlg.style.setProperty("transform","translate(-50%, -50%)");
        edlg.style.setProperty("z-index","1999998");
        edlg.style.setProperty("box-shadow","5px 5px 5px gray");
        cancel = document.createElement("DIV");
        this.FCancel = cancel;
        cancel.innerHTML = '<i id="Cancel" class="material-icons" style="font-size:16px!important">clear</i>';
        cancel.id = "Cancel";
        cancel.style.setProperty("color",pas["WEBLib.Graphics"].ColorToHTML(pas["WEBLib.Forms"].Application.FThemeTextColor));
        cancel.style.setProperty("position","fixed");
        cancel.style.setProperty("top","0");
        cancel.style.setProperty("right","0");
        cancel.style.setProperty("padding",Padding + "px");
        cancel.style.setProperty("height",BarHeight + "px");
        cancel.style.setProperty("line-height",BarHeight + "px");
        cancel.addEventListener("click",rtl.createSafeCallback(this,"HandleButtonClick"));
        edlg.appendChild(cancel);
        title = document.createElement("DIV");
        title.innerHTML = MsgTitle;
        if (this.FElementTitleClassName !== "") {
          title.setAttribute("class",this.FElementTitleClassName);
        } else {
          title.style.setProperty("background-color",pas["WEBLib.Graphics"].ColorToHTML(pas["WEBLib.Forms"].Application.FThemeColor));
          title.style.setProperty("color",pas["WEBLib.Graphics"].ColorToHTML(pas["WEBLib.Forms"].Application.FThemeTextColor));
        };
        title.style.setProperty("cursor","move");
        title.style.setProperty("padding-left",Padding + "px");
        title.style.setProperty("height",BarHeight + "px");
        title.style.setProperty("vertical-align","middle");
        title.style.setProperty("line-height",BarHeight + "px");
        title.style.setProperty("border-bottom","1px solid " + BorderColor);
        title.style.setProperty("-moz-user-select","none");
        title.style.setProperty("-webkit-user-select","none");
        title.style.setProperty("-ms-user-select","none");
        title.style.setProperty("user-select","none");
        title.style.setProperty("-o-user-select","none");
        title.addEventListener("mousedown",rtl.createSafeCallback(this,"HandleMouseDown"));
        edlg.appendChild(title);
        msg = document.createElement("DIV");
        msg.style.setProperty("padding",Padding + "px");
        msg.style.setProperty("height","auto");
        msg.style.setProperty("min-height","50px");
        msg.style.setProperty("border-bottom","1px solid " + BorderColor);
        if (this.FMsgDlgType !== $mod.TMsgDlgType.mtCustom) {
          icon = document.createElement("DIV");
          icon.innerHTML = '<i class="material-icons" style="color:' + MsgColor + '!important;font-size:48px!important">' + MsgSymbol + "</i>";
          icon.style.setProperty("display","inline-block");
          icon.style.setProperty("float","left");
          icon.style.setProperty("padding-right","15px");
          msg.appendChild(icon);
        };
        this.FMessage = pas.SysUtils.StringReplace(this.FMessage,pas.System.sLineBreak,"<BR>",rtl.createSet(pas.SysUtils.TStringReplaceFlag.rfReplaceAll));
        contentdiv = document.createElement("DIV");
        contentdiv.innerHTML = this.FMessage;
        contentdiv.style.setProperty("height","auto");
        contentdiv.style.setProperty("min-height","50px");
        contentdiv.style.setProperty("white-space","pre-wrap");
        content = document.createElement("LABEL");
        content.innerHTML = this.FMessage;
        if (this.FElementTitleClassName !== "") {
          content.setAttribute("class",this.FElementContentClassName);
        };
        contentdiv.appendChild(content);
        msg.appendChild(content);
        this.InsertInputElement(msg,{get: function () {
            return btnFocus;
          }, set: function (v) {
            btnFocus = v;
          }});
        edlg.appendChild(msg);
        bar = document.createElement("DIV");
        bar.style.setProperty("background-color",BarBGColor);
        bar.style.setProperty("padding",Padding + "px");
        bar.style.setProperty("min-height",BarHeight + "px");
        bar.style.setProperty("height","auto");
        bar.style.setProperty("line-height",BarHeight + "px");
        bar.style.setProperty("text-align","right");
        edlg.appendChild(bar);
      };
      if (rtl.eqSet(this.FButtons,{}) && (this.FCustomButtons.GetCount() === 0)) {
        bar.appendChild(this.CreateButton(this.GetDialogText(5),{get: function () {
            return btnFocus;
          }, set: function (v) {
            btnFocus = v;
          }},""))}
       else {
        if ($mod.TMsgDlgBtn.mbYes in this.FButtons) bar.appendChild(this.CreateButton(this.GetDialogText(7),{get: function () {
            return btnFocus;
          }, set: function (v) {
            btnFocus = v;
          }},""));
        if ($mod.TMsgDlgBtn.mbNo in this.FButtons) bar.appendChild(this.CreateButton(this.GetDialogText(8),{get: function () {
            return btnFocus;
          }, set: function (v) {
            btnFocus = v;
          }},""));
        if ($mod.TMsgDlgBtn.mbOK in this.FButtons) bar.appendChild(this.CreateButton(this.GetDialogText(5),{get: function () {
            return btnFocus;
          }, set: function (v) {
            btnFocus = v;
          }},""));
        if ($mod.TMsgDlgBtn.mbCancel in this.FButtons) bar.appendChild(this.CreateButton(this.GetDialogText(6),{get: function () {
            return btnFocus;
          }, set: function (v) {
            btnFocus = v;
          }},""));
        if ($mod.TMsgDlgBtn.mbAbort in this.FButtons) bar.appendChild(this.CreateButton(this.GetDialogText(9),{get: function () {
            return btnFocus;
          }, set: function (v) {
            btnFocus = v;
          }},""));
        if ($mod.TMsgDlgBtn.mbRetry in this.FButtons) bar.appendChild(this.CreateButton(this.GetDialogText(10),{get: function () {
            return btnFocus;
          }, set: function (v) {
            btnFocus = v;
          }},""));
        if ($mod.TMsgDlgBtn.mbIgnore in this.FButtons) bar.appendChild(this.CreateButton(this.GetDialogText(11),{get: function () {
            return btnFocus;
          }, set: function (v) {
            btnFocus = v;
          }},""));
        if ($mod.TMsgDlgBtn.mbAll in this.FButtons) bar.appendChild(this.CreateButton(this.GetDialogText(12),{get: function () {
            return btnFocus;
          }, set: function (v) {
            btnFocus = v;
          }},""));
        if ($mod.TMsgDlgBtn.mbYesToAll in this.FButtons) bar.appendChild(this.CreateButton(this.GetDialogText(13),{get: function () {
            return btnFocus;
          }, set: function (v) {
            btnFocus = v;
          }},""));
        if ($mod.TMsgDlgBtn.mbNoToAll in this.FButtons) bar.appendChild(this.CreateButton(this.GetDialogText(14),{get: function () {
            return btnFocus;
          }, set: function (v) {
            btnFocus = v;
          }},""));
        if ($mod.TMsgDlgBtn.mbHelp in this.FButtons) bar.appendChild(this.CreateButton(this.GetDialogText(15),{get: function () {
            return btnFocus;
          }, set: function (v) {
            btnFocus = v;
          }},""));
        if ($mod.TMsgDlgBtn.mbClose in this.FButtons) bar.appendChild(this.CreateButton(this.GetDialogText(16),{get: function () {
            return btnFocus;
          }, set: function (v) {
            btnFocus = v;
          }},""));
      };
      for (var $l = 0, $end = this.FCustomButtons.GetCount() - 1; $l <= $end; $l++) {
        i = $l;
        bar.appendChild(this.CreateButton(this.FCustomButtons.GetItem$1(i).FCaption,{get: function () {
            return btnFocus;
          }, set: function (v) {
            btnFocus = v;
          }},this.FCustomButtons.GetItem$1(i).FElementClassName));
      };
      eh = this.FLayer$1;
      eh.style.setProperty("background-color","black");
      eh.style.setProperty("opacity",pas["WEBLib.WebTools"].DoubleToHTML(this.FOpacity));
      eh.style.setProperty("top","0");
      eh.style.setProperty("left","0");
      eh.style.setProperty("right","0");
      eh.style.setProperty("bottom","0");
      eh.style.setProperty("z-index",pas["WEBLib.Forms"].Application.MaxZIndexStr());
      eh.style.setProperty("webkit-user-select","none");
      eh.style.setProperty("moz-user-select","none");
      eh.style.setProperty("khtml-user-select","none");
      eh.style.setProperty("ms-user-select","none");
      eh.style.setProperty("user-select","none");
      eh.style.setProperty("position","fixed");
    };
    this.ShowDialog = function () {
      var Result = 0;
      Result = 0;
      this.Show$1();
      return Result;
    };
    this.ShowDialog$1 = function (Msg, DlgType, Buttons, AProc) {
      var Result = 0;
      Result = 0;
      this.FButtons = rtl.refSet(Buttons);
      this.FMessage = Msg;
      this.FMsgDlgType = DlgType;
      this.FDialogProc = AProc;
      this.SetDialogResult(0);
      this.Show$1();
      return Result;
    };
    this.ShowDialog$2 = function (Msg, DlgType, Buttons) {
      var $Self = this;
      var Result = null;
      Result = new Promise(function (ASuccess, AFailed) {
        $Self.ShowDialog$1(Msg,DlgType,rtl.refSet(Buttons),function (AResult) {
          ASuccess(AResult);
        });
      });
      return Result;
    };
    this.ShowAsync = function () {
      var $Self = this;
      var Result = null;
      Result = new Promise(function (ASuccess, AFailed) {
        $Self.ShowDialog$1($Self.FMessage,$Self.FMsgDlgType,rtl.refSet($Self.FButtons),function (AResult) {
          ASuccess(AResult);
        });
      });
      return Result;
    };
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
    var $r = this.$rtti;
    $r.addProperty("AutoLanguage",0,rtl.boolean,"FAutoLanguage","FAutoLanguage",{Default: true});
    $r.addProperty("Buttons",0,$mod.$rtti["TMsgDlgButtons"],"FButtons","FButtons",{Default: {}});
    $r.addProperty("CustomButtons",2,$mod.$rtti["TCustomDialogButtons"],"FCustomButtons","SetCustomButtons");
    $r.addProperty("DialogText",2,pas.Classes.$rtti["TStringList"],"FDialogText","SetDialogText");
    $r.addProperty("DialogType",0,$mod.$rtti["TMsgDlgType"],"FMsgDlgType","FMsgDlgType",{Default: $mod.TMsgDlgType.mtCustom});
    $r.addProperty("Message",0,rtl.string,"FMessage","FMessage");
    $r.addProperty("Opacity",0,rtl.double,"FOpacity","FOpacity");
    $r.addProperty("ElementButtonClassName",0,pas["WEBLib.Controls"].$rtti["TElementClassName"],"FElementButtonClassName","FElementButtonClassName");
    $r.addProperty("ElementDialogClassName",0,pas["WEBLib.Controls"].$rtti["TElementClassName"],"FElementDialogClassName","FElementDialogClassName");
    $r.addProperty("ElementTitleClassName",0,pas["WEBLib.Controls"].$rtti["TElementClassName"],"FElementTitleClassName","FElementTitleClassName");
    $r.addProperty("ElementContentClassName",0,pas["WEBLib.Controls"].$rtti["TElementClassName"],"FElementContentClassName","FElementContentClassName");
    $r.addProperty("Title",0,rtl.string,"FTitle","FTitle");
    $r.addProperty("UseMaterial",0,rtl.boolean,"FUseMaterial","FUseMaterial",{Default: true});
    $r.addProperty("OnButtonClick",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnButtonClick","FOnButtonClick");
    $r.addProperty("OnClose",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnClose","FOnClose");
  });
  rtl.createClass(this,"TWebMessageDlg",this.TMessageDlg,function () {
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
  });
  rtl.createClass(this,"TInputMessageDlg",this.TMessageDlg,function () {
    this.$init = function () {
      $mod.TMessageDlg.$init.call(this);
      this.FInputElement = null;
      this.FInputValue = "";
      this.FKeydownHandler = null;
      this.FKeypressHandler = null;
      this.FInputType = 0;
    };
    this.$final = function () {
      this.FInputElement = undefined;
      $mod.TMessageDlg.$final.call(this);
    };
    this.ShowAsync = function () {
      var $Self = this;
      var Result = null;
      Result = new Promise(function (ASuccess, AFailed) {
        $Self.ShowDialog$1($Self.FMessage,$Self.FMsgDlgType,rtl.refSet($Self.FButtons),function (AResult) {
          $Self.FInputValue = $Self.GetInputElementValue();
          ASuccess(AResult);
        });
      });
      return Result;
    };
    this.HandleInputKeydown = function (Event) {
      var Result = false;
      Result = true;
      if (Event.key === "Enter") {
        Event.preventDefault();
        Event.stopPropagation();
        this.SetDialogResult(1);
        Result = false;
      };
      if (Event.key === "Escape") {
        Event.preventDefault();
        Event.stopPropagation();
        this.SetDialogResult(2);
        Result = false;
      };
      return Result;
    };
    this.HandleInputKeypress = function (Event) {
      var Result = false;
      Result = true;
      Event.stopPropagation();
      return Result;
    };
    this.InsertInputElement = function (AElement, DoFocus) {
      var divel = null;
      var inputel = null;
      $mod.TMessageDlg.InsertInputElement.apply(this,arguments);
      if (this.FKeydownHandler === null) this.FKeydownHandler = rtl.createCallback(this,"HandleInputKeydown");
      if (this.FKeypressHandler === null) this.FKeypressHandler = rtl.createCallback(this,"HandleInputKeypress");
      divel = document.createElement("DIV");
      inputel = document.createElement("INPUT");
      inputel.addEventListener("keydown",this.FKeydownHandler);
      inputel.addEventListener("keypress",this.FKeypressHandler);
      divel.appendChild(inputel);
      AElement.appendChild(divel);
      this.FInputElement = inputel;
      this.FInputElement.setAttribute("type",pas["WEBLib.Controls"].InputTypeString(this.FInputType));
      divel.style.setProperty("margin-top","10px");
      this.FInputElement.style.setProperty("padding","4px");
      this.SetInputElementValue(this.FInputValue);
      this.FInputElement.style.setProperty("width","calc(100% - 80px)");
      if (DoFocus.get()) {
        setTimeout(function() {inputel.focus(); inputel.select()}, 1);
        DoFocus.set(false);
      };
    };
    this.GetInputElementValue = function () {
      var Result = "";
      Result = "";
      if (this.FInputElement != null) {
        this.FInputValue = this.FInputElement.value;
        Result = this.FInputValue;
      };
      return Result;
    };
    this.SetInputElementValue = function (AValue) {
      this.FInputElement.value = AValue;
    };
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
    var $r = this.$rtti;
    $r.addField("FInputElement",pas.Web.$rtti["TJSHTMLElement"]);
    $r.addField("FInputValue",rtl.string);
    $r.addField("FKeydownHandler",rtl.pointer);
    $r.addField("FKeypressHandler",rtl.pointer);
    $r.addProperty("InputValue",1,rtl.string,"GetInputElementValue","FInputValue");
    $r.addProperty("InputType",0,pas["WEBLib.Controls"].$rtti["TInputType"],"FInputType","FInputType",{Default: pas["WEBLib.Controls"].TInputType.itText});
  });
  rtl.createClass(this,"TWebInputMessageDlg",this.TInputMessageDlg,function () {
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
  });
  rtl.createClass(this,"TWaitMessage",pas["WEBLib.Controls"].TCustomControl,function () {
    this.$init = function () {
      pas["WEBLib.Controls"].TCustomControl.$init.call(this);
      this.FLayer$1 = null;
      this.FPicture = null;
      this.FOpacity = 0.0;
      this.FOnShow = null;
      this.FOnHide = null;
      this.FIsWaiting = false;
      this.FPictureURL = "";
      this.FTimeOut = 0;
      this.FShowID = 0;
      this.FHideID = 0;
    };
    this.$final = function () {
      this.FLayer$1 = undefined;
      this.FPicture = undefined;
      this.FOnShow = undefined;
      this.FOnHide = undefined;
      pas["WEBLib.Controls"].TCustomControl.$final.call(this);
    };
    this.SetPicture = function (Value) {
      this.FPicture.Assign(Value);
    };
    this.SetPictureURL = function (Value) {
      this.FPictureURL = Value;
    };
    this.WaitDisplayed = function () {
      if (this.FOnShow != null) this.FOnShow(this);
    };
    this.WaitHide = function () {
      if (this.FOnHide != null) this.FOnHide(this);
      this.Hide$1();
    };
    this.CreateElement = function () {
      var Result = null;
      if (pas.Classes.TComponentStateItem.csDesigning in this.FComponentState) {
        Result = null}
       else pas["WEBLib.Controls"].TCustomControl.CreateElement.call(this);
      return Result;
    };
    this.CreateInitialize = function () {
      pas["WEBLib.Controls"].TCustomControl.CreateInitialize.call(this);
      this.FOpacity = 0.2;
      this.FPicture = pas["WEBLib.Graphics"].TURLPicture.$create("Create");
      this.FIsWaiting = false;
      this.FPicture.SetData($impl.lWaitCursor);
      this.FShowID = 0;
      this.FHideID = 0;
    };
    this.Destroy = function () {
      rtl.free(this,"FPicture");
      pas["WEBLib.Controls"].TCustomControl.Destroy.call(this);
    };
    this.Show$1 = function () {
      var eh = null;
      var img = null;
      var dv = null;
      var el = null;
      this.FLayer$1 = document.createElement("SPAN");
      eh = this.FLayer$1;
      eh.style.setProperty("background-color","black");
      eh.style.setProperty("opacity",pas["WEBLib.WebTools"].DoubleToHTML(this.FOpacity));
      eh.style.setProperty("top","0");
      eh.style.setProperty("left","0");
      eh.style.setProperty("right","0");
      eh.style.setProperty("bottom","0");
      eh.style.setProperty("z-index","9999999");
      eh.style.setProperty("webkit-user-select","none");
      eh.style.setProperty("moz-user-select","none");
      eh.style.setProperty("khtml-user-select","none");
      eh.style.setProperty("ms-user-select","none");
      eh.style.setProperty("user-select","none");
      eh.style.setProperty("position","fixed");
      document.body.appendChild(this.FLayer$1);
      this.FLayer$1.setAttribute("tabindex","0");
      el = document.createElement("DIV");
      dv = el;
      this.FLayer$1.appendChild(el);
      dv.style.setProperty("position","relative");
      dv.style.setProperty("width","100%");
      dv.style.setProperty("height","100%");
      el = document.createElement("IMG");
      img = el;
      dv.appendChild(img);
      if (this.FPictureURL !== "") {
        img.setAttribute("src",this.FPictureURL)}
       else img.setAttribute("src",this.FPicture.FFilename);
      img.style.setProperty("position","absolute");
      img.style.setProperty("top","0");
      img.style.setProperty("left","0");
      img.style.setProperty("right","0");
      img.style.setProperty("bottom","0");
      img.style.setProperty("margin","auto");
      this.FIsWaiting = true;
      if (this.FOnShow != null) {
        this.FShowID = window.setTimeout(rtl.createSafeCallback(this,"WaitDisplayed"),100);
      };
      if (this.FTimeOut > 0) {
        this.FHideID = window.setTimeout(rtl.createSafeCallback(this,"WaitHide"),this.FTimeOut);
      };
    };
    this.Hide$1 = function () {
      if (this.FIsWaiting) document.body.removeChild(this.FLayer$1);
      this.FIsWaiting = false;
      if (this.FShowID > 0) window.clearTimeout(this.FShowID);
      if (this.FHideID > 0) window.clearTimeout(this.FHideID);
      this.FShowID = 0;
      this.FHideID = 0;
    };
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
    var $r = this.$rtti;
    $r.addProperty("Opacity",0,rtl.double,"FOpacity","FOpacity");
    $r.addProperty("Picture",2,pas["WEBLib.Graphics"].$rtti["TURLPicture"],"FPicture","SetPicture");
    $r.addProperty("PictureURL",2,rtl.string,"FPictureURL","SetPictureURL");
    $r.addProperty("TimeOut",0,rtl.longint,"FTimeOut","FTimeOut");
    $r.addProperty("OnHide",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnHide","FOnHide");
    $r.addProperty("OnShow",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnShow","FOnShow");
  });
  rtl.createClass(this,"TWebWaitMessage",this.TWaitMessage,function () {
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
  });
  this.$rtti.$MethodVar("TFilesDroppedEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["AFileList",pas.Classes.$rtti["TStringList"]]]), methodkind: 0});
  this.$rtti.$MethodVar("TFileAsTextEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["AFileIndex",rtl.longint],["AText",rtl.string]]), methodkind: 0});
  this.$rtti.$MethodVar("TFileAsBase64Event",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["AFileIndex",rtl.longint],["ABase64",rtl.string]]), methodkind: 0});
  this.$rtti.$MethodVar("TFileAsDataURLEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["AFileIndex",rtl.longint],["AURL",rtl.string]]), methodkind: 0});
  this.$rtti.$MethodVar("TFileAsArrayBufferEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["AFileIndex",rtl.longint],["ABuffer",pas["WEBLib.Controls"].$rtti["TJSArrayBufferRecord"]]]), methodkind: 0});
  this.$rtti.$MethodVar("TFileAsStreamEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["AFileIndex",rtl.longint],["AStream",pas.Classes.$rtti["TStream"]]]), methodkind: 0});
  this.$rtti.$MethodVar("TFileUploadEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["AFileIndex",rtl.longint]]), methodkind: 0});
  this.$rtti.$MethodVar("TFileUploadResponseEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["AFileIndex",rtl.longint],["ARequest",pas["WEBLib.Controls"].$rtti["TJSXMLHttpRequestRecord"]],["AResponse",rtl.string]]), methodkind: 0});
  this.$rtti.$MethodVar("TFileUploadErrorEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["AFileIndex",rtl.longint],["AError",rtl.string]]), methodkind: 0});
  this.$rtti.$MethodVar("TFileUploadProgressEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["AFileIndex",rtl.longint],["APosition",rtl.longint],["ATotalSize",rtl.longint]]), methodkind: 0});
  this.$rtti.$MethodVar("TFileGetAsBase64",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["ABase64",rtl.string]]), methodkind: 0});
  this.$rtti.$MethodVar("TFileGetAsText",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["AText",rtl.string]]), methodkind: 0});
  this.$rtti.$MethodVar("TFileGetAsURL",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["AURL",rtl.string]]), methodkind: 0});
  this.$rtti.$MethodVar("TFileGetAsArrayBuffer",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["ABuffer",pas["WEBLib.Controls"].$rtti["TJSArrayBufferRecord"]]]), methodkind: 0});
  this.$rtti.$MethodVar("TFileGetAsStream",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["AStream",pas.Classes.$rtti["TStream"]]]), methodkind: 0});
  this.$rtti.$RefToProcVar("TGetAsStringProc",{procsig: rtl.newTIProcSig([["AValue",rtl.string]])});
  this.$rtti.$RefToProcVar("TGetAsArrayBufferProc",{procsig: rtl.newTIProcSig([["AValue",pas.JS.$rtti["TJSArrayBuffer"]]])});
  this.$rtti.$RefToProcVar("TGetAsStreamProc",{procsig: rtl.newTIProcSig([["AStream",pas.Classes.$rtti["TStream"]]])});
  rtl.createClass(this,"TFile",pas.Classes.TCollectionItem,function () {
    this.$init = function () {
      pas.Classes.TCollectionItem.$init.call(this);
      this.FReq = null;
      this.FModified = 0.0;
      this.FName = "";
      this.FMimeType = "";
      this.FSize = 0;
      this.FFileObject = null;
      this.FTag = 0;
      this.FObject = null;
      this.FOnGetFileAsBase64 = null;
      this.FOnGetFileAsArrayBuffer = null;
      this.FOnGetFileAsText = null;
      this.FOnGetFileAsURL = null;
      this.FOnGetFileAsStream = null;
      this.FGetAsString = null;
      this.FGetAsStream = null;
      this.FGetAsArrayBuffer = null;
    };
    this.$final = function () {
      this.FReq = undefined;
      this.FFileObject = undefined;
      this.FObject = undefined;
      this.FOnGetFileAsBase64 = undefined;
      this.FOnGetFileAsArrayBuffer = undefined;
      this.FOnGetFileAsText = undefined;
      this.FOnGetFileAsURL = undefined;
      this.FOnGetFileAsStream = undefined;
      this.FGetAsString = undefined;
      this.FGetAsStream = undefined;
      this.FGetAsArrayBuffer = undefined;
      pas.Classes.TCollectionItem.$final.call(this);
    };
    this.HandleFileLoadAsText = function (Event) {
      var Result = false;
      var s = "";
      var ctrl = null;
      Result = true;
      s = Event.target.result;
      if (this.FGetAsString != null) this.FGetAsString(s);
      this.FGetAsString = null;
      if (this.FOnGetFileAsText != null) this.FOnGetFileAsText(this,s);
      ctrl = this.GetControl();
      if (ctrl != null) {
        if ($mod.TFilePicker.isPrototypeOf(ctrl) && (rtl.as(ctrl,$mod.TFilePicker).FOnFileAsText != null)) rtl.as(ctrl,$mod.TFilePicker).FOnFileAsText(ctrl,this.GetIndex(),s);
        if ($mod.TFileUpload.isPrototypeOf(ctrl) && (rtl.as(ctrl,$mod.TFileUpload).FOnFileAsText != null)) rtl.as(ctrl,$mod.TFileUpload).FOnFileAsText(ctrl,this.GetIndex(),s);
        if ($mod.TOpenDialog.isPrototypeOf(ctrl) && (rtl.as(ctrl,$mod.TOpenDialog).FOnFileAsText != null)) rtl.as(ctrl,$mod.TOpenDialog).FOnFileAsText(ctrl,this.GetIndex(),s);
      };
      return Result;
    };
    this.HandleFileLoadAsBase64 = function (Event) {
      var Result = false;
      var s = "";
      var ctrl = null;
      Result = true;
      function _arrayBufferToBase64( buffer ) {
      var binary = '';
      var bytes = new Uint8Array( buffer );
      var len = bytes.byteLength;
      for (var i = 0; i < len; i++) {
          binary += String.fromCharCode( bytes[ i ] );
      }
      return window.btoa( binary );
      }
      s = _arrayBufferToBase64(Event.target.result);
      if (this.FGetAsString != null) this.FGetAsString(s);
      this.FGetAsString = null;
      if (this.FOnGetFileAsBase64 != null) this.FOnGetFileAsBase64(this,s);
      ctrl = this.GetControl();
      if (ctrl != null) {
        if ($mod.TFilePicker.isPrototypeOf(ctrl) && (rtl.as(ctrl,$mod.TFilePicker).FOnFileAsBase64 != null)) rtl.as(ctrl,$mod.TFilePicker).FOnFileAsBase64(ctrl,this.GetIndex(),s);
        if ($mod.TFileUpload.isPrototypeOf(ctrl) && (rtl.as(ctrl,$mod.TFileUpload).FOnFileAsBase64 != null)) rtl.as(ctrl,$mod.TFileUpload).FOnFileAsBase64(ctrl,this.GetIndex(),s);
        if ($mod.TOpenDialog.isPrototypeOf(ctrl) && (rtl.as(ctrl,$mod.TOpenDialog).FOnFileAsBase64 != null)) rtl.as(ctrl,$mod.TOpenDialog).FOnFileAsBase64(ctrl,this.GetIndex(),s);
      };
      return Result;
    };
    this.HandleFileLoadAsArrayBuffer = function (Event) {
      var Result = false;
      var ja = null;
      var LJARec = pas["WEBLib.Controls"].TJSArrayBufferRecord.$new();
      var ctrl = null;
      Result = true;
      ja = Event.target.result;
      if (this.FGetAsArrayBuffer != null) {
        this.FGetAsArrayBuffer(ja);
      };
      this.FGetAsArrayBuffer = null;
      if (this.FOnGetFileAsArrayBuffer != null) {
        LJARec.jsarraybuffer = ja;
        this.FOnGetFileAsArrayBuffer(this,pas["WEBLib.Controls"].TJSArrayBufferRecord.$clone(LJARec));
      };
      ctrl = this.GetControl();
      if (ctrl != null) {
        LJARec.jsarraybuffer = ja;
        if ($mod.TFilePicker.isPrototypeOf(ctrl) && (rtl.as(ctrl,$mod.TFilePicker).FOnGetFileAsArrayBuffer != null)) rtl.as(ctrl,$mod.TFilePicker).FOnGetFileAsArrayBuffer(ctrl,this.GetIndex(),pas["WEBLib.Controls"].TJSArrayBufferRecord.$clone(LJARec));
        if ($mod.TFileUpload.isPrototypeOf(ctrl) && (rtl.as(ctrl,$mod.TFileUpload).FOnGetFileAsArrayBuffer != null)) rtl.as(ctrl,$mod.TFileUpload).FOnGetFileAsArrayBuffer(ctrl,this.GetIndex(),pas["WEBLib.Controls"].TJSArrayBufferRecord.$clone(LJARec));
        if ($mod.TOpenDialog.isPrototypeOf(ctrl) && (rtl.as(ctrl,$mod.TOpenDialog).FOnGetFileAsArrayBuffer != null)) rtl.as(ctrl,$mod.TOpenDialog).FOnGetFileAsArrayBuffer(ctrl,this.GetIndex(),pas["WEBLib.Controls"].TJSArrayBufferRecord.$clone(LJARec));
      };
      return Result;
    };
    this.HandleFileLoadAsDataURL = function (Event) {
      var Result = false;
      var s = "";
      var ctrl = null;
      Result = true;
      s = Event.target.result;
      if (this.FGetAsString != null) this.FGetAsString(s);
      this.FGetAsString = null;
      if (this.FOnGetFileAsURL != null) this.FOnGetFileAsURL(this,s);
      ctrl = this.GetControl();
      if (ctrl != null) {
        if ($mod.TFilePicker.isPrototypeOf(ctrl) && (rtl.as(ctrl,$mod.TFilePicker).FOnFileAsDataURL != null)) rtl.as(ctrl,$mod.TFilePicker).FOnFileAsDataURL(ctrl,this.GetIndex(),s);
        if ($mod.TFileUpload.isPrototypeOf(ctrl) && (rtl.as(ctrl,$mod.TFileUpload).FOnFileAsDataURL != null)) rtl.as(ctrl,$mod.TFileUpload).FOnFileAsDataURL(ctrl,this.GetIndex(),s);
        if ($mod.TWebOpenDialog.isPrototypeOf(ctrl) && (rtl.as(ctrl,$mod.TWebOpenDialog).FOnFileAsDataURL != null)) rtl.as(ctrl,$mod.TWebOpenDialog).FOnFileAsDataURL(ctrl,this.GetIndex(),s);
      };
      return Result;
    };
    this.HandleFileLoadAsStream = function (Event) {
      var Result = false;
      var ctrl = null;
      var b = [];
      var l = 0;
      var ms = null;
      var ja = null;
      Result = true;
      ja = Event.target.result;
      b = pas.Classes.TMemoryStream.MemoryToBytes(ja);
      l = ja.byteLength;
      ms = pas.Classes.TMemoryStream.$create("Create");
      ms.Write$1(b,0,l);
      ms.SetPosition(0);
      if (this.FGetAsStream != null) {
        this.FGetAsStream(ms);
      };
      this.FGetAsStream = null;
      if (this.FOnGetFileAsStream != null) {
        this.FOnGetFileAsStream(this,ms);
      };
      ctrl = this.GetControl();
      if (ctrl != null) {
        if ($mod.TFilePicker.isPrototypeOf(ctrl) && (rtl.as(ctrl,$mod.TFilePicker).FOnGetFileAsStream != null)) rtl.as(ctrl,$mod.TFilePicker).FOnGetFileAsStream(ctrl,this.GetIndex(),ms);
        if ($mod.TFileUpload.isPrototypeOf(ctrl) && (rtl.as(ctrl,$mod.TFileUpload).FOnGetFileAsStream != null)) rtl.as(ctrl,$mod.TFileUpload).FOnGetFileAsStream(ctrl,this.GetIndex(),ms);
        if ($mod.TOpenDialog.isPrototypeOf(ctrl) && (rtl.as(ctrl,$mod.TOpenDialog).FOnGetFileAsStream != null)) rtl.as(ctrl,$mod.TOpenDialog).FOnGetFileAsStream(ctrl,this.GetIndex(),ms);
      };
      ms = rtl.freeLoc(ms);
      return Result;
    };
    this.HandleFileUploadProgress = function (Event) {
      var Result = false;
      var Lloaded = 0;
      var Ltotal = 0;
      var ctrl = null;
      Lloaded = 0;
      Ltotal = 0;
      if (Event.lengthComputable) {
         Lloaded = Event.loaded;
         Ltotal = Event.total;
         //console.log(Event.loaded + " bytes of " + Event.total); } else { console.log('no calc');
      };
      ctrl = this.GetControl();
      if (ctrl != null) {
        if ($mod.TFilePicker.isPrototypeOf(ctrl) && (rtl.as(this.GetControl(),$mod.TFilePicker).FOnUploadFileProgress != null)) rtl.as(ctrl,$mod.TFilePicker).FOnUploadFileProgress(ctrl,this.GetIndex(),Lloaded,Ltotal);
        if ($mod.TFileUpload.isPrototypeOf(ctrl) && (rtl.as(this.GetControl(),$mod.TFileUpload).FOnUploadFileProgress != null)) rtl.as(ctrl,$mod.TFileUpload).FOnUploadFileProgress(ctrl,this.GetIndex(),Lloaded,Ltotal);
      };
      Result = true;
      return Result;
    };
    this.HandleFileUploadComplete = function (Event) {
      var Result = false;
      var ctrl = null;
      var LRequestRec = pas["WEBLib.Controls"].TJSXMLHttpRequestRecord.$new();
      var AResponse = "";
      Result = true;
      ctrl = this.GetControl();
      if (ctrl != null) {
        if ($mod.TFilePicker.isPrototypeOf(ctrl) && (rtl.as(ctrl,$mod.TFilePicker).FOnUploadFileComplete != null)) rtl.as(ctrl,$mod.TFilePicker).FOnUploadFileComplete(ctrl,this.GetIndex());
        if ($mod.TFilePicker.isPrototypeOf(ctrl) && (rtl.as(ctrl,$mod.TFilePicker).FOnUploadFileResponseComplete != null)) {
          LRequestRec.req = Event.target;
          AResponse = Event.target.responseText;
          rtl.as(ctrl,$mod.TFilePicker).FOnUploadFileResponseComplete(ctrl,this.GetIndex(),pas["WEBLib.Controls"].TJSXMLHttpRequestRecord.$clone(LRequestRec),AResponse);
        };
        if ($mod.TFileUpload.isPrototypeOf(ctrl) && (rtl.as(ctrl,$mod.TFileUpload).FOnUploadFileComplete != null)) rtl.as(ctrl,$mod.TFileUpload).FOnUploadFileComplete(ctrl,this.GetIndex());
        if ($mod.TFileUpload.isPrototypeOf(ctrl) && (rtl.as(ctrl,$mod.TFileUpload).FOnUploadFileResponseComplete != null)) {
          LRequestRec.req = Event.target;
          AResponse = Event.target.responseText;
          rtl.as(ctrl,$mod.TFileUpload).FOnUploadFileResponseComplete(ctrl,this.GetIndex(),pas["WEBLib.Controls"].TJSXMLHttpRequestRecord.$clone(LRequestRec),AResponse);
        };
      };
      this.FReq = null;
      return Result;
    };
    this.HandleFileUploadError = function (Event) {
      var Result = false;
      var err = "";
      var ctrl = null;
      err = Event.target.status;
      Result = true;
      ctrl = this.GetControl();
      if (ctrl != null) {
        if ($mod.TFilePicker.isPrototypeOf(ctrl) && (rtl.as(ctrl,$mod.TFilePicker).FOnUploadFileError != null)) rtl.as(ctrl,$mod.TFilePicker).FOnUploadFileError(ctrl,this.GetIndex(),err);
        if ($mod.TFileUpload.isPrototypeOf(ctrl) && (rtl.as(ctrl,$mod.TFileUpload).FOnUploadFileError != null)) rtl.as(ctrl,$mod.TFileUpload).FOnUploadFileError(ctrl,this.GetIndex(),err);
      };
      return Result;
    };
    this.HandleFileUploadAbort = function (Event) {
      var Result = false;
      var ctrl = null;
      Result = true;
      ctrl = this.GetControl();
      if (ctrl != null) {
        if ($mod.TFilePicker.isPrototypeOf(ctrl) && (rtl.as(ctrl,$mod.TFilePicker).FOnUploadFileAbort != null)) rtl.as(ctrl,$mod.TFilePicker).FOnUploadFileAbort(ctrl,this.GetIndex());
        if ($mod.TFileUpload.isPrototypeOf(ctrl) && (rtl.as(ctrl,$mod.TFileUpload).FOnUploadFileAbort != null)) rtl.as(ctrl,$mod.TFileUpload).FOnUploadFileAbort(ctrl,this.GetIndex());
      };
      return Result;
    };
    this.GetControl = function () {
      var Result = null;
      Result = null;
      if ((this.FCollection != null) && (rtl.as(this.FCollection,$mod.TFiles).Owner$1() != null)) {
        if (pas.Classes.TComponent.isPrototypeOf(rtl.as(this.FCollection,$mod.TFiles).Owner$1())) Result = rtl.as(rtl.as(this.FCollection,$mod.TFiles).Owner$1(),pas.Classes.TComponent);
      };
      return Result;
    };
    this.FileAsText = function () {
      var Result = null;
      Result = this.FileAsText$1("utf-8");
      return Result;
    };
    this.FileAsText$1 = function (AEncoding) {
      var $Self = this;
      var Result = null;
      var reader = null;
      Result = new Promise(function (ASuccess, AFailed) {
        function Loader(Event) {
          var Result = false;
          ASuccess($impl.EventResult(Event));
          return Result;
        };
        reader = new FileReader();
        reader.onload = rtl.createSafeCallback(null,Loader);
        reader.readAsText($Self.FFileObject,AEncoding);
      });
      return Result;
    };
    this.FileAsBase64 = function () {
      var $Self = this;
      var Result = null;
      var reader = null;
      Result = new Promise(function (ASuccess, AFailed) {
        function Loader(Event) {
          var Result = false;
          var s = "";
          function _arrayBufferToBase64( buffer ) {
          var binary = '';
          var bytes = new Uint8Array( buffer );
          var len = bytes.byteLength;
          for (var i = 0; i < len; i++) {
              binary += String.fromCharCode( bytes[ i ] );
          }
          return window.btoa( binary );
          }
          s = _arrayBufferToBase64(Event.target.result);
          ASuccess(s);
          return Result;
        };
        reader = new FileReader();
        reader.onload = rtl.createSafeCallback(null,Loader);
        reader.readAsArrayBuffer($Self.FFileObject);
      });
      return Result;
    };
    this.FileAsStream = function () {
      var $Self = this;
      var Result = null;
      var reader = null;
      Result = new Promise(function (ASuccess, AFailed) {
        function Loader(Event) {
          var Result = false;
          var ms = null;
          var ja = null;
          var b = [];
          var l = 0;
          ja = Event.target.result;
          b = pas.Classes.TMemoryStream.MemoryToBytes(ja);
          l = ja.byteLength;
          ms = pas.Classes.TMemoryStream.$create("Create");
          ms.Write$1(b,0,l);
          ms.SetPosition(0);
          ASuccess(ms);
          return Result;
        };
        reader = new FileReader();
        reader.onload = rtl.createSafeCallback(null,Loader);
        reader.readAsArrayBuffer($Self.FFileObject);
      });
      return Result;
    };
    this.FileAsDataURL = function () {
      var $Self = this;
      var Result = null;
      var reader = null;
      Result = new Promise(function (ASuccess, AFailed) {
        function Loader(Event) {
          var Result = false;
          var s = "";
          s = Event.target.result;
          ASuccess(s);
          return Result;
        };
        reader = new FileReader();
        reader.onload = rtl.createSafeCallback(null,Loader);
        reader.readAsDataURL($Self.FFileObject);
      });
      return Result;
    };
    this.FileAsArrayBuffer = function () {
      var $Self = this;
      var Result = null;
      var reader = null;
      Result = new Promise(function (ASuccess, AFailed) {
        function Loader(Event) {
          var Result = false;
          var arr = null;
          arr = Event.target.result;
          ASuccess(arr);
          return Result;
        };
        reader = new FileReader();
        reader.onload = rtl.createSafeCallback(null,Loader);
        reader.readAsArrayBuffer($Self.FFileObject);
      });
      return Result;
    };
    this.GetFileAsText = function () {
      var ptr = null;
      var f = null;
      ptr = rtl.createCallback(this,"HandleFileLoadAsText");
      f = this.FFileObject;
      var reader = new FileReader();
      reader.addEventListener('load',ptr);
      reader.readAsText(f);
    };
    this.GetFileAsText$1 = function (GetAsString) {
      this.FGetAsString = GetAsString;
      this.GetFileAsText();
    };
    this.GetFileAsText$2 = function (AEncoding) {
      var ptr = null;
      var f = null;
      ptr = rtl.createCallback(this,"HandleFileLoadAsText");
      f = this.FFileObject;
      var reader = new FileReader();
      reader.addEventListener('load',ptr);
      reader.readAsText(f, AEncoding);
    };
    this.GetFileAsBase64 = function () {
      var ptr = null;
      var f = null;
      ptr = rtl.createCallback(this,"HandleFileLoadAsBase64");
      f = this.FFileObject;
      var reader = new FileReader();
      reader.addEventListener('load',ptr);
      reader.readAsArrayBuffer(f);
    };
    this.GetFileAsBase64$1 = function (GetAsString) {
      this.FGetAsString = GetAsString;
      this.GetFileAsBase64();
    };
    this.GetFileAsArrayBuffer = function () {
      var ptr = null;
      var f = null;
      ptr = rtl.createCallback(this,"HandleFileLoadAsArrayBuffer");
      f = this.FFileObject;
      var reader = new FileReader();
      reader.addEventListener('load',ptr);
      reader.readAsArrayBuffer(f);
    };
    this.GetFileAsArrayBuffer$1 = function (GetAsArrayBuffer) {
      this.FGetAsArrayBuffer = GetAsArrayBuffer;
      this.GetFileAsArrayBuffer();
    };
    this.GetFileAsStream = function () {
      var ptr = null;
      var f = null;
      ptr = rtl.createCallback(this,"HandleFileLoadAsStream");
      f = this.FFileObject;
      var reader = new FileReader();
      reader.addEventListener('load',ptr);
      reader.readAsArrayBuffer(f);
    };
    this.GetFileAsStream$1 = function (GetAsStream) {
      this.FGetAsStream = GetAsStream;
      this.GetFileAsStream();
    };
    this.GetFileAsDataURL = function () {
      var ptr = null;
      var f = null;
      ptr = rtl.createCallback(this,"HandleFileLoadAsDataURL");
      f = this.FFileObject;
      var reader = new FileReader();
      reader.addEventListener('load',ptr);
      reader.readAsDataURL(f);
    };
    this.GetFileAsDataURL$1 = function (GetAsString) {
      this.FGetAsString = GetAsString;
      this.GetFileAsDataURL();
    };
    this.Upload = function (AAction) {
      var f = null;
      var fd = null;
      var ptrProgress = null;
      var ptrComplete = null;
      var ptrError = null;
      var ptrAbort = null;
      f = this.FFileObject;
      fd = new FormData();
      fd.append("file1",f);
      this.FReq = new XMLHttpRequest();
      ptrProgress = rtl.createCallback(this,"HandleFileUploadProgress");
      ptrComplete = rtl.createCallback(this,"HandleFileUploadComplete");
      ptrError = rtl.createCallback(this,"HandleFileUploadError");
      ptrAbort = rtl.createCallback(this,"HandleFileUploadAbort");
      this.FReq.addEventListener("load",ptrComplete);
      this.FReq.addEventListener("error",ptrError);
      this.FReq.addEventListener("abort",ptrAbort);
      this.FReq.upload.addEventListener("progress",ptrProgress);
      this.FReq.open("POST",AAction,true);
      this.FReq.send(fd);
    };
    this.AbortUpload = function () {
      var Result = false;
      Result = false;
      if (this.FReq != null) {
        this.FReq.abort();
        Result = true;
      };
      return Result;
    };
  });
  this.$rtti.$Class("TFilePicker");
  rtl.createClass(this,"TFiles",pas.Classes.TCollection,function () {
    this.$init = function () {
      pas.Classes.TCollection.$init.call(this);
      this.FOwner = null;
    };
    this.$final = function () {
      this.FOwner = undefined;
      pas.Classes.TCollection.$final.call(this);
    };
    this.GetItem$1 = function (Index) {
      var Result = null;
      Result = this.GetItem(Index);
      return Result;
    };
    this.SetItem$1 = function (Index, Value) {
      this.SetItem(Index,Value);
    };
    this.Create$2 = function (AOwner) {
      pas.Classes.TCollection.Create$1.call(this,$mod.TFile);
      this.FOwner = AOwner;
      return this;
    };
    this.Owner$1 = function () {
      var Result = null;
      Result = this.FOwner;
      return Result;
    };
    this.Add$1 = function () {
      var Result = null;
      Result = pas.Classes.TCollection.Add.call(this);
      return Result;
    };
    this.Insert$1 = function (Index) {
      var Result = null;
      Result = pas.Classes.TCollection.Insert.call(this,Index);
      return Result;
    };
    this.Clear$1 = function () {
      var fc = 0;
      fc = this.GetCount();
      pas.Classes.TCollection.Clear.call(this);
      if (fc > 0) {
        if ($mod.TFilePicker.isPrototypeOf(this.FOwner)) rtl.as(this.FOwner,$mod.TFilePicker).Clear();
        if ($mod.TFileUpload.isPrototypeOf(this.FOwner)) rtl.as(this.FOwner,$mod.TFileUpload).Clear();
      };
    };
    var $r = this.$rtti;
    $r.addMethod("Create$2",2,[["AOwner",pas.Classes.$rtti["TComponent"]]]);
  });
  rtl.createClass(this,"TFileUpload",pas["WEBLib.Controls"].TCustomControl,function () {
    this.$init = function () {
      pas["WEBLib.Controls"].TCustomControl.$init.call(this);
      this.FAccept = "";
      this.FCreateRef = "";
      this.FEventInit = false;
      this.FFiles = null;
      this.FFileList = null;
      this.FOnDroppedFiles = null;
      this.FMultiFile = false;
      this.FShowFiles = false;
      this.FDragCaption = "";
      this.FOnGetFileAsArrayBuffer = null;
      this.FOnFileAsText = null;
      this.FOnFileAsBase64 = null;
      this.FOnFileAsDataURL = null;
      this.FOnUploadFileAbort = null;
      this.FOnUploadFileComplete = null;
      this.FOnUploadFileProgress = null;
      this.FOnUploadFileError = null;
      this.FOnUploadFileResponseComplete = null;
      this.FOnGetFileAsStream = null;
      this.FFontHoverColor = 0;
      this.FShowPicture = false;
      this.FDragColor = 0;
    };
    this.$final = function () {
      this.FFiles = undefined;
      this.FFileList = undefined;
      this.FOnDroppedFiles = undefined;
      this.FOnGetFileAsArrayBuffer = undefined;
      this.FOnFileAsText = undefined;
      this.FOnFileAsBase64 = undefined;
      this.FOnFileAsDataURL = undefined;
      this.FOnUploadFileAbort = undefined;
      this.FOnUploadFileComplete = undefined;
      this.FOnUploadFileProgress = undefined;
      this.FOnUploadFileError = undefined;
      this.FOnUploadFileResponseComplete = undefined;
      this.FOnGetFileAsStream = undefined;
      pas["WEBLib.Controls"].TCustomControl.$final.call(this);
    };
    this.SetDragCaption = function (Value) {
      this.FDragCaption = Value;
      this.UpdateElement();
    };
    this.SetAccept = function (Value) {
      if (this.FAccept !== Value) {
        this.FAccept = Value;
        this.UpdateElement();
      };
    };
    this.SetShowPicture = function (Value) {
      if (this.FShowPicture !== Value) {
        this.FShowPicture = Value;
        this.UpdateElement();
      };
    };
    this.SetCaption = function (AValue) {
      if (this.FCaption !== AValue) {
        pas["WEBLib.Controls"].TCustomControl.SetCaption.call(this,AValue);
        this.UpdateElement();
      };
    };
    this.HandleFiles = function (files) {
      var Result = "";
      var i = 0;
      var sz = 0;
      var afile = null;
      var szFiles = "";
      var m = "";
      var d = null;
      szFiles = "";
      while (this.FFiles.GetCount() > 0) this.FFiles.Delete(0);
      while (this.FFileList.GetCount() > 0) this.FFileList.Delete(0);
      for (var $l = 0, $end = files.length - 1; $l <= $end; $l++) {
        i = $l;
        afile = files.item(i);
        d = new Date(afile.lastModified);
        m = afile.type;
        sz = afile.size;
        var $with = this.FFiles.Add$1();
        $with.FFileObject = afile;
        $with.FName = afile.name;
        $with.FMimeType = m;
        $with.FSize = sz;
        $with.FModified = pas.SysUtils.EncodeDate(d.getYear() + 1900,d.getMonth() + 1,d.getDate()) + pas.SysUtils.EncodeTime(d.getHours(),d.getMinutes(),d.getSeconds(),d.getMilliseconds());
        if (this.FFileList != null) this.FFileList.Add(afile.name);
        if (this.FShowFiles) {
          if (i > 0) szFiles = szFiles + "<br>";
          szFiles = szFiles + afile.name;
        };
        if (!this.FMultiFile) break;
      };
      Result = szFiles;
      if (this.FOnDroppedFiles != null) this.FOnDroppedFiles(this,this.FFileList);
      return Result;
    };
    this.DoHandleChange = function (e) {
      var Result = false;
      var el = null;
      var span = null;
      var curfiles = null;
      var szfiles = "";
      Result = true;
      if (this.GetElementHandle() != null) {
        el = e.target;
        if (el != null) {
          curfiles = el.files;
          szfiles = this.HandleFiles(curfiles);
          if (this.FShowFiles) {
            span = document.getElementById(this.GetID() + "fileslist");
            span.innerHTML = szfiles;
          };
        };
      };
      return Result;
    };
    this.HandleDroppedFiles = function (Event) {
      var Result = false;
      var droppedfiles = null;
      var span = null;
      var szFiles = "";
      var AEvent = null;
      Result = true;
      AEvent = Event;
      AEvent.preventDefault();
      AEvent.stopPropagation();
      droppedfiles = AEvent.dataTransfer.files;
      szFiles = this.HandleFiles(droppedfiles);
      if (this.FShowFiles) {
        span = document.getElementById(this.GetID() + "fileslist");
        span.innerHTML = szFiles;
      };
      this.GetContainer().setAttribute("class","box has-advanced-upload");
      return Result;
    };
    this.HandleDragOver = function (Event) {
      var Result = false;
      Result = true;
      Event.preventDefault();
      Event.stopPropagation();
      if (this.GetContainer() != null) this.GetContainer().setAttribute("class","box has-advanced-upload is-dragover");
      if ((this.GetElementHandle() != null) && (this.FDragColor !== -1)) this.GetElementHandle().style.setProperty("background-color",pas["WEBLib.Graphics"].ColorToHTML(this.FDragColor));
      return Result;
    };
    this.HandleDragEnd = function (Event) {
      var Result = false;
      Result = true;
      Event.preventDefault();
      Event.stopPropagation();
      if (this.GetContainer() != null) this.GetContainer().setAttribute("class","box has-advanced-upload");
      if (this.GetElementHandle() != null) {
        if ((this.FColor !== -1) && (this.FDragColor !== -1)) {
          this.GetElementHandle().style.setProperty("background-color",pas["WEBLib.Graphics"].ColorToHTML(this.FColor))}
         else this.GetElementHandle().style.removeProperty("background-color");
      };
      return Result;
    };
    this.CreateElement = function () {
      var Result = null;
      this.CreateCSS();
      this.FCreateRef = this.FName;
      Result = document.createElement("FORM");
      Result.setAttribute("method","post");
      Result.setAttribute("class","box");
      Result.setAttribute("enctype","multipart/form-data");
      Result.style.setProperty("display","flex");
      Result.style.setProperty("justify-content","center");
      Result.style.setProperty("align-items","center");
      Result.innerHTML = '<div class="box__input" style="text-align: center">' + '<svg class="box__icon" xmlns="http://www.w3.org/2000/svg" width="50" height="43" viewBox="0 0 50 43">' + '<path d="M48.4 26.5c-.9 0-1.7.7-1.7 1.7v11.6h-43.3v-11.6c0-.9-.7-1.7-1.7-1.7s-1.7.7-1.7 1.7v13.2c0 .9.7 1.7 1.7 1.7h46.7c.9 0 1.7-.7 1.7-1.7v-13.2c0-1-.7-1.7-1.7-1.7zm-24.5 6.1c.3.3.8.5 1.2.5.4 0 .9-.2 1.2-.5l10-11.6c.7-.7.7-1.7 0-2.4s-1.7-.7-2.4 0l-7.1 8.3v-25.3c0-.9-.7-1.7-1.7-1.7s-1.7.7-1.7 1.7v25.3l-7.1-8.3c-.7-.7-1.7-.7-2.4 0s-.7 1.7 0 2.4l10 11.6z"/></svg>' + '<input class="box__file" type="file" name="files[]" id="FP' + this.FName + '" data-multiple-caption="{count} files selected" multiple/>' + '<label for="FP' + this.FName + '" style="outline:none"><strong id="' + this.FName + 'lbl">' + this.FCaption + '</strong>&nbsp;<span class="box__dragndrop" id="' + this.FName + 'drag">' + this.FDragCaption + "</span>.</label>" + '<button class="box__button" type="submit">Upload</button>' + '<br><span style="display:inline-block;" id="' + this.FName + 'fileslist"></span>' + '</div><div class="box__uploading">Uploading&hellip;</div>';
      Result.addEventListener("drop",rtl.createSafeCallback(this,"HandleDroppedFiles"));
      Result.addEventListener("dragenter",rtl.createSafeCallback(this,"HandleDragOver"));
      Result.addEventListener("dragover",rtl.createSafeCallback(this,"HandleDragOver"));
      Result.addEventListener("dragend",rtl.createSafeCallback(this,"HandleDragEnd"));
      Result.addEventListener("dragleave",rtl.createSafeCallback(this,"HandleDragEnd"));
      if ($impl.isAdvancedUpload()) Result.classList.add("has-advanced-upload");
      return Result;
    };
    this.UpdateElement = function () {
      var el = null;
      pas["WEBLib.Controls"].TControl.UpdateElement.call(this);
      this.CreateCSS();
      if (this.GetElementHandle() != null) {
        this.GetElementHandle().style.setProperty("display","flex");
        el = this.GetElementHandle().children.item(0);
        el = el.children.item(0);
        if (!this.FShowPicture) {
          el.style.setProperty("display","none")}
         else el.style.removeProperty("display");
        if (this.FElementFont !== pas["WEBLib.Controls"].TElementFont.efCSS) {
          el.style.setProperty("color",pas["WEBLib.Graphics"].ColorToHTML(this.FFont.FColor))}
         else el.style.removeProperty("color");
        el = document.getElementById("FP" + this.FCreateRef);
        if (el != null) {
          if (!this.FEventInit) {
            this.FEventInit = true;
            el.addEventListener("change",rtl.createSafeCallback(this,"DoHandleChange"));
          };
          if (this.FMultiFile) {
            el.setAttribute("multiple","")}
           else el.removeAttribute("multiple");
          if (this.FAccept !== "") {
            el.setAttribute("accept",this.FAccept)}
           else el.removeAttribute("accept");
        };
        el = document.getElementById(this.FCreateRef + "lbl");
        if (el != null) {
          el.innerHTML = this.FCaption;
        };
        el = document.getElementById(this.FCreateRef + "drag");
        if (el != null) {
          el.innerHTML = this.FDragCaption;
        };
      };
    };
    this.ColorChanging = function () {
      pas["WEBLib.Controls"].TControl.ColorChanging.call(this);
      this.UpdateElement();
    };
    this.CreateCSS = function () {
      this.AddControlStyle("  \t.box" + "\t\t\t{" + " \t\t\tposition: relative;" + "\t    \tpadding: 2px 2px;" + "\t\t}" + "\t\t.box.has-advanced-upload" + "\t\t{" + "\t\t\toutline: 2px dashed #92b0b3;" + "\t\t\toutline-offset: -10px;" + "\t\t\t-webkit-transition: outline-offset .15s ease-in-out, background-color .15s linear;" + "\t\t\ttransition: outline-offset .15s ease-in-out, background-color .15s linear;" + "\t\t}" + "\t\t.box.is-dragover" + "\t\t{" + "\t\t\toutline-offset: -20px;" + "\t\t\toutline-color: #c8dadf;" + "\t\t\tbackground-color: #fff;" + "\t\t}" + "\t\t\t.box__dragndrop," + "\t\t\t.box__icon" + "\t\t\t{" + "\t\t\t\tdisplay: none;" + "\t\t\t}" + "\t\t\t.box.has-advanced-upload .box__dragndrop" + "\t\t\t{" + "\t\t\t\tdisplay: inline;" + "\t\t\t}" + "\t\t\t.box.has-advanced-upload .box__icon" + "\t\t\t{" + "\t\t\t\twidth: 100%;" + "\t\t\t\theight: 80px;" + "\t\t\t\tfill: #92b0b3;" + "\t\t\t\tdisplay: block;" + "\t\t\t\tmargin-bottom: 40px;" + "\t\t\t}" + "\t\t\t.box.is-uploading .box__input," + "\t\t\t.box.is-success .box__input," + "\t\t\t.box.is-error .box__input" + "\t\t\t{" + "\t\t\t\tvisibility: hidden;" + "\t\t\t}" + "\t\t\t.box__uploading," + "\t\t\t.box__success," + "\t\t\t.box__error" + "\t\t\t{" + "\t\t\tdisplay: none;" + "\t\t\t}" + "\t\t\t.box.is-uploading .box__uploading," + "\t\t\t.box.is-success .box__success," + "\t\t\t.box.is-error .box__error" + "\t\t\t{" + "\t\t\t\tdisplay: block;" + "\t\t\t\tposition: absolute;" + "\t\t\t\ttop: 50%;" + "       right: 0;" + "\t\t\t\tleft: 0;" + "\t   \t\t-webkit-transform: translateY( -50% );" + "\t\t\t\t\ttransform: translateY( -50% );" + "\t\t\t\t}" + "\t\t\t\t.box__uploading" + "\t\t\t\t{" + "\t\t\t\t\tfont-style: italic;" + "\t\t\t\t}" + "\t\t\t\t.box__success" + "\t\t\t\t{" + "\t\t\t\t\t-webkit-animation: appear-from-inside .25s ease-in-out;" + "\t\t\t\t\tanimation: appear-from-inside .25s ease-in-out;" + "\t\t\t\t}" + "\t\t\t\t\t@-webkit-keyframes appear-from-inside" + "\t\t\t\t\t{" + "\t\t\t\t\t\tfrom\t{ -webkit-transform: translateY( -50% ) scale( 0 ); }" + "\t\t\t\t\t\t75%\t\t{ -webkit-transform: translateY( -50% ) scale( 1.1 ); }" + "\t\t\t\t\t\tto\t\t{ -webkit-transform: translateY( -50% ) scale( 1 ); }" + "\t\t\t\t\t}" + "\t\t\t\t\t@keyframes appear-from-inside" + "\t\t\t\t\t{" + "\t\t\t\t\t\tfrom\t{ transform: translateY( -50% ) scale( 0 ); }" + "\t\t\t\t\t\t75%\t\t{ transform: translateY( -50% ) scale( 1.1 ); }" + "\t\t\t\t\t\tto\t\t{ transform: translateY( -50% ) scale( 1 ); }" + "\t\t\t\t\t}" + "\t\t\t\t.box__restart" + "\t\t\t\t{" + "\t\t\t\t\tfont-weight: 700;" + "\t\t\t\t}" + "\t\t\t\t.box__restart:focus," + "\t\t\t\t.box__restart:hover" + "\t\t\t\t{" + "\t\t\t\t\tcolor: " + pas["WEBLib.Graphics"].ColorToHTML(this.FFontHoverColor) + ";" + "\t\t\t\t}" + "\t\t\t\t.box__file" + "\t\t\t\t{" + "\t\t\t\t\twidth: 0.1px;" + "\t\t\t\t\theight: 0.1px;" + "\t\t\t\t\topacity: 0;" + "\t\t\t\t\toverflow: hidden;" + "\t\t\t\t\tposition: absolute;" + "\t\t\t\t\tz-index: -1;" + "\t\t\t\t}" + "\t\t\t\t.box__file + label" + "\t\t\t\t{" + "\t\t\t\t\ttext-overflow: ellipsis;" + "\t\t\t\t\twhite-space: nowrap;" + "\t\t\t\t\tcursor: pointer;" + "\t\t\t\t\tdisplay: inline-block;" + "\t\t\t\t\toverflow: hidden;" + "\t\t\t\t}" + "\t\t\t\t.box__file + label:hover strong," + "\t\t\t\t.box__file:focus + label strong," + "\t\t\t\t.box__file.has-focus + label strong" + "\t\t\t\t{" + "\t\t\t\t\tcolor: " + pas["WEBLib.Graphics"].ColorToHTML(this.FFontHoverColor) + ";" + "\t\t\t\t}" + "\t\t\t\t.box__file:focus + label," + "\t\t\t\t.box__file.has-focus + label" + "\t\t\t\t{" + " \t\t\t\toutline: 1px dotted #000;" + "\t\t\t\t\toutline: -webkit-focus-ring-color auto 5px;" + "\t\t\t\t}" + "\t\t\t\t.box__button" + "\t\t\t\t{" + "\t\t\t\t\tfont-weight: 700;" + "\t\t\t\t\tcolor: #e5edf1;" + "\t\t\t\t\tbackground-color: #39bfd3;" + "\t\t\t\t\tdisplay: none;" + "\t\t\t\t\tpadding: 8px 16px;" + "\t\t\t\t\tmargin: 10px auto 0;" + "\t\t\t\t}" + "\t\t\t\t\t.box__button:hover," + "\t\t\t\t\t.box__button:focus" + "\t\t\t\t\t{" + "\t\t\t\t\t\tbackground-color: #0f3c4b;" + "\t\t\t\t\t}");
    };
    this.Create$1 = function (AOwner) {
      pas["WEBLib.Controls"].TControl.Create$1.apply(this,arguments);
      this.SetColor(0xDFDAC8);
      this.FFontHoverColor = 0xd3bf39;
      this.SetCaption("Choose a file");
      this.FDragCaption = "or drag it here";
      this.FDragColor = -1;
      this.FShowPicture = true;
      this.FFiles = $mod.TFiles.$create("Create$2",[this]);
      this.FFileList = pas.Classes.TStringList.$create("Create$1");
      this.FFileList.SetSkipLastLineBreak(true);
      return this;
    };
    this.Destroy = function () {
      rtl.free(this,"FFiles");
      rtl.free(this,"FFileList");
      pas["WEBLib.Controls"].TCustomControl.Destroy.call(this);
    };
    this.CreateInitialize = function () {
      pas["WEBLib.Controls"].TCustomControl.CreateInitialize.call(this);
      this.FMultiFile = false;
      this.FShowFiles = false;
      this.FEventInit = false;
      this.SetWidth(170);
      this.SetHeight(190);
    };
    this.Clear = function () {
      var el = null;
      el = document.getElementById("FP" + this.GetID());
      if (el != null) {
        el.setAttribute("type","");
        el.setAttribute("type","file");
      };
      el = document.getElementById(this.GetID() + "fileslist");
      if (el != null) {
        el.innerHTML = "";
      };
      while (this.FFiles.GetCount() > 0) this.FFiles.Delete(0);
    };
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
    var $r = this.$rtti;
    $r.addMethod("Create$1",2,[["AOwner",pas.Classes.$rtti["TComponent"]]]);
    $r.addProperty("Accept",2,rtl.string,"FAccept","SetAccept");
    $r.addProperty("Caption",2,rtl.string,"FCaption","SetCaption");
    $r.addProperty("ChildOrder",2,rtl.longint,"FChildOrder","SetChildOrderEx",{Default: 0});
    $r.addProperty("Color",2,pas["WEBLib.Graphics"].$rtti["TColor"],"FColor","SetColor",{Default: 14670536});
    $r.addProperty("DragCaption",2,rtl.string,"FDragCaption","SetDragCaption");
    $r.addProperty("DragColor",0,pas["WEBLib.Graphics"].$rtti["TColor"],"FDragColor","FDragColor",{Default: -1});
    $r.addProperty("ElementFont",2,pas["WEBLib.Controls"].$rtti["TElementFont"],"FElementFont","SetElementFont",{Default: pas["WEBLib.Controls"].TElementFont.efProperty});
    $r.addProperty("Font",2,pas["WEBLib.Graphics"].$rtti["TFont"],"FFont","SetFont");
    $r.addProperty("FontHoverColor",0,pas["WEBLib.Graphics"].$rtti["TColor"],"FFontHoverColor","FFontHoverColor",{Default: 13877049});
    $r.addProperty("HeightPercent",2,rtl.double,"FHeightPercent","SetHeightPercent",{Default: 100});
    $r.addProperty("HeightStyle",2,pas["WEBLib.Controls"].$rtti["TSizeStyle"],"FHeightStyle","SetHeightStyle",{Default: pas["WEBLib.Controls"].TSizeStyle.ssAbsolute});
    $r.addProperty("Multifile",0,rtl.boolean,"FMultiFile","FMultiFile",{Default: false});
    $r.addProperty("ParentFont",2,rtl.boolean,"FParentFont","SetParentFont",{Default: true});
    $r.addProperty("ShowFiles",0,rtl.boolean,"FShowFiles","FShowFiles",{Default: false});
    $r.addProperty("ShowPicture",2,rtl.boolean,"FShowPicture","SetShowPicture",{Default: true});
    $r.addProperty("WidthPercent",2,rtl.double,"FWidthPercent","SetWidthPercent",{Default: 100});
    $r.addProperty("WidthStyle",2,pas["WEBLib.Controls"].$rtti["TSizeStyle"],"FWidthStyle","SetWidthStyle",{Default: pas["WEBLib.Controls"].TSizeStyle.ssAbsolute});
    $r.addProperty("OnDroppedFiles",0,$mod.$rtti["TFilesDroppedEvent"],"FOnDroppedFiles","FOnDroppedFiles");
    $r.addProperty("OnGetFileAsText",0,$mod.$rtti["TFileAsTextEvent"],"FOnFileAsText","FOnFileAsText");
    $r.addProperty("OnGetFileAsArrayBuffer",0,$mod.$rtti["TFileAsArrayBufferEvent"],"FOnGetFileAsArrayBuffer","FOnGetFileAsArrayBuffer");
    $r.addProperty("OnGetFileAsStream",0,$mod.$rtti["TFileAsStreamEvent"],"FOnGetFileAsStream","FOnGetFileAsStream");
    $r.addProperty("OnGetFileAsBase64",0,$mod.$rtti["TFileAsBase64Event"],"FOnFileAsBase64","FOnFileAsBase64");
    $r.addProperty("OnGetFileAsDataURL",0,$mod.$rtti["TFileAsDataURLEvent"],"FOnFileAsDataURL","FOnFileAsDataURL");
    $r.addProperty("OnUploadFileComplete",0,$mod.$rtti["TFileUploadEvent"],"FOnUploadFileComplete","FOnUploadFileComplete");
    $r.addProperty("OnUploadFileResponseComplete",0,$mod.$rtti["TFileUploadResponseEvent"],"FOnUploadFileResponseComplete","FOnUploadFileResponseComplete");
    $r.addProperty("OnUploadFileAbort",0,$mod.$rtti["TFileUploadEvent"],"FOnUploadFileAbort","FOnUploadFileAbort");
    $r.addProperty("OnUploadFileError",0,$mod.$rtti["TFileUploadErrorEvent"],"FOnUploadFileError","FOnUploadFileError");
    $r.addProperty("OnUploadFileProgress",0,$mod.$rtti["TFileUploadProgressEvent"],"FOnUploadFileProgress","FOnUploadFileProgress");
  });
  rtl.createClass(this,"TWebFileUpload",this.TFileUpload,function () {
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
  });
  rtl.createClass(this,"TFilePicker",pas["WEBLib.Controls"].TCustomControl,function () {
    this.$init = function () {
      pas["WEBLib.Controls"].TCustomControl.$init.call(this);
      this.FOnChange = null;
      this.FMultiFile = false;
      this.FFiles = null;
      this.FOnFileAsText = null;
      this.FOnGetFileAsArrayBuffer = null;
      this.FAccept = "";
      this.FOnFileAsBase64 = null;
      this.FChangePtr = null;
      this.FOnFileAsDataURL = null;
      this.FOnUploadFileAbort = null;
      this.FOnUploadFileComplete = null;
      this.FOnUploadFileProgress = null;
      this.FOnUploadFileError = null;
      this.FOnUploadFileResponseComplete = null;
      this.FOnGetFileAsStream = null;
    };
    this.$final = function () {
      this.FOnChange = undefined;
      this.FFiles = undefined;
      this.FOnFileAsText = undefined;
      this.FOnGetFileAsArrayBuffer = undefined;
      this.FOnFileAsBase64 = undefined;
      this.FOnFileAsDataURL = undefined;
      this.FOnUploadFileAbort = undefined;
      this.FOnUploadFileComplete = undefined;
      this.FOnUploadFileProgress = undefined;
      this.FOnUploadFileError = undefined;
      this.FOnUploadFileResponseComplete = undefined;
      this.FOnGetFileAsStream = undefined;
      pas["WEBLib.Controls"].TCustomControl.$final.call(this);
    };
    this.SetMultiFile = function (Value) {
      if (this.FMultiFile !== Value) {
        this.FMultiFile = Value;
        this.UpdateElement();
      };
    };
    this.DoHandleChange = function (e) {
      var Result = false;
      var i = 0;
      var l = 0;
      var sz = 0;
      var eh = null;
      var s = "";
      var m = "";
      var f = null;
      var d = null;
      var jsfile = null;
      Result = true;
      while (this.FFiles.GetCount() > 0) this.FFiles.Delete(0);
      eh = this.GetElementHandle();
      var curFiles = eh.files;
      l = curFiles.length;
      for (var $l = 0, $end = l - 1; $l <= $end; $l++) {
        i = $l;
        f = this.FFiles.Add$1();
        jsfile = curFiles[i];
        s = curFiles[i].name;
        m = curFiles[i].type;
        sz = curFiles[i].size;
        d = new Date(curFiles[i].lastModified);
        f.FFileObject = jsfile;
        f.FName = s;
        f.FMimeType = m;
        f.FSize = sz;
        f.FModified = pas.SysUtils.EncodeDate(d.getFullYear(),d.getMonth() + 1,d.getDate()) + pas.SysUtils.EncodeTime(d.getHours(),d.getMinutes(),d.getSeconds(),d.getMilliseconds());
      };
      if (this.FOnChange != null) this.FOnChange(this);
      return Result;
    };
    this.SetAccept = function (Value) {
      if (this.FAccept !== Value) {
        this.FAccept = Value;
        this.UpdateElement();
      };
    };
    this.UpdateElement = function () {
      pas["WEBLib.Controls"].TControl.UpdateElement.call(this);
      if (this.GetElementHandle() != null) {
        if (this.FMultiFile) {
          this.GetElementHandle().setAttribute("multiple","")}
         else this.GetElementHandle().removeAttribute("multiple");
        if (this.FAccept !== "") {
          this.GetElementHandle().setAttribute("accept",this.FAccept)}
         else this.GetElementHandle().removeAttribute("accept");
      };
    };
    this.CreateElement = function () {
      var Result = null;
      Result = document.createElement("INPUT");
      Result.setAttribute("type","file");
      return Result;
    };
    this.GetMethodPointers = function () {
      if (this.FChangePtr === null) {
        this.FChangePtr = rtl.createCallback(this,"DoHandleChange");
        pas["WEBLib.Controls"].TControl.GetMethodPointers.call(this);
      };
    };
    this.BindEvents = function () {
      var eh = null;
      pas["WEBLib.Controls"].TCustomControl.BindEvents.call(this);
      if (this.GetElementBindHandle() != null) {
        eh = this.GetElementBindHandle();
        eh.addEventListener("change",rtl.createSafeCallback(this,"DoHandleChange"));
      };
    };
    this.CreateInitialize = function () {
      pas["WEBLib.Controls"].TCustomControl.CreateInitialize.call(this);
      this.FFiles = $mod.TFiles.$create("Create$2",[this]);
      this.SetWidth(160);
      this.SetHeight(40);
    };
    this.Destroy = function () {
      rtl.free(this,"FFiles");
      pas["WEBLib.Controls"].TCustomControl.Destroy.call(this);
    };
    this.Clear = function () {
      this.GetElementHandle().setAttribute("type","");
      this.GetElementHandle().setAttribute("type","file");
      while (this.FFiles.GetCount() > 0) this.FFiles.Delete(0);
    };
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
    var $r = this.$rtti;
    $r.addProperty("Accept",2,rtl.string,"FAccept","SetAccept");
    $r.addProperty("ChildOrder",2,rtl.longint,"FChildOrder","SetChildOrderEx",{Default: 0});
    $r.addProperty("ElementClassName",2,pas["WEBLib.Controls"].$rtti["TElementClassName"],"FElementClassName","SetElementClassName");
    $r.addProperty("ElementFont",2,pas["WEBLib.Controls"].$rtti["TElementFont"],"FElementFont","SetElementFont",{Default: pas["WEBLib.Controls"].TElementFont.efProperty});
    $r.addProperty("ElementID",3,pas["WEBLib.Controls"].$rtti["TElementID"],"GetID","SetID");
    $r.addProperty("ElementPosition",2,pas["WEBLib.Controls"].$rtti["TElementPosition"],"FElementPosition","SetElementPosition",{Default: pas["WEBLib.Controls"].TElementPosition.epAbsolute});
    $r.addProperty("HeightPercent",2,rtl.double,"FHeightPercent","SetHeightPercent",{Default: 100});
    $r.addProperty("HeightStyle",2,pas["WEBLib.Controls"].$rtti["TSizeStyle"],"FHeightStyle","SetHeightStyle",{Default: pas["WEBLib.Controls"].TSizeStyle.ssAbsolute});
    $r.addProperty("Multifile",2,rtl.boolean,"FMultiFile","SetMultiFile");
    $r.addProperty("WidthPercent",2,rtl.double,"FWidthPercent","SetWidthPercent",{Default: 100});
    $r.addProperty("WidthStyle",2,pas["WEBLib.Controls"].$rtti["TSizeStyle"],"FWidthStyle","SetWidthStyle",{Default: pas["WEBLib.Controls"].TSizeStyle.ssAbsolute});
    $r.addProperty("OnChange",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnChange","FOnChange");
    $r.addProperty("OnGetFileAsText",0,$mod.$rtti["TFileAsTextEvent"],"FOnFileAsText","FOnFileAsText");
    $r.addProperty("OnGetFileAsArrayBuffer",0,$mod.$rtti["TFileAsArrayBufferEvent"],"FOnGetFileAsArrayBuffer","FOnGetFileAsArrayBuffer");
    $r.addProperty("OnGetFileAsBase64",0,$mod.$rtti["TFileAsBase64Event"],"FOnFileAsBase64","FOnFileAsBase64");
    $r.addProperty("OnGetFileAsDataURL",0,$mod.$rtti["TFileAsDataURLEvent"],"FOnFileAsDataURL","FOnFileAsDataURL");
    $r.addProperty("OnGetFileAsStream",0,$mod.$rtti["TFileAsStreamEvent"],"FOnGetFileAsStream","FOnGetFileAsStream");
    $r.addProperty("OnUploadFileComplete",0,$mod.$rtti["TFileUploadEvent"],"FOnUploadFileComplete","FOnUploadFileComplete");
    $r.addProperty("OnUploadFileResponseComplete",0,$mod.$rtti["TFileUploadResponseEvent"],"FOnUploadFileResponseComplete","FOnUploadFileResponseComplete");
    $r.addProperty("OnUploadFileAbort",0,$mod.$rtti["TFileUploadEvent"],"FOnUploadFileAbort","FOnUploadFileAbort");
    $r.addProperty("OnUploadFileError",0,$mod.$rtti["TFileUploadErrorEvent"],"FOnUploadFileError","FOnUploadFileError");
    $r.addProperty("OnUploadFileProgress",0,$mod.$rtti["TFileUploadProgressEvent"],"FOnUploadFileProgress","FOnUploadFileProgress");
  });
  rtl.createClass(this,"TWebFilePicker",this.TFilePicker,function () {
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
  });
  this.$rtti.$RefToProcVar("TOpenDialogProc",{procsig: rtl.newTIProcSig([["AFileName",rtl.string]])});
  this.TOpenOption = {"0": "ofReadOnly", ofReadOnly: 0, "1": "ofOverwritePrompt", ofOverwritePrompt: 1, "2": "ofHideReadOnly", ofHideReadOnly: 2, "3": "ofNoChangeDir", ofNoChangeDir: 3, "4": "ofShowHelp", ofShowHelp: 4, "5": "ofNoValidate", ofNoValidate: 5, "6": "ofAllowMultiSelect", ofAllowMultiSelect: 6, "7": "ofExtensionDifferent", ofExtensionDifferent: 7, "8": "ofPathMustExist", ofPathMustExist: 8, "9": "ofFileMustExist", ofFileMustExist: 9, "10": "ofCreatePrompt", ofCreatePrompt: 10, "11": "ofShareAware", ofShareAware: 11, "12": "ofNoReadOnlyReturn", ofNoReadOnlyReturn: 12, "13": "ofNoTestFileCreate", ofNoTestFileCreate: 13, "14": "ofNoNetworkButton", ofNoNetworkButton: 14, "15": "ofNoLongNames", ofNoLongNames: 15, "16": "ofOldStyleDialog", ofOldStyleDialog: 16, "17": "ofNoDereferenceLinks", ofNoDereferenceLinks: 17, "18": "ofEnableIncludeNotify", ofEnableIncludeNotify: 18, "19": "ofEnableSizing", ofEnableSizing: 19, "20": "ofDontAddToRecent", ofDontAddToRecent: 20, "21": "ofForceShowHidden", ofForceShowHidden: 21};
  this.$rtti.$Enum("TOpenOption",{minvalue: 0, maxvalue: 21, ordtype: 1, enumtype: this.TOpenOption});
  this.$rtti.$Set("TOpenOptions",{comptype: this.$rtti["TOpenOption"]});
  rtl.createClass(this,"TOpenDialog",pas.Classes.TComponent,function () {
    this.$init = function () {
      pas.Classes.TComponent.$init.call(this);
      this.FFiles = null;
      this.FOnChange = null;
      this.FFileName = "";
      this.FMultiFile = false;
      this.FFilter = "";
      this.FAccept = "";
      this.FOpenDialogProc = null;
      this.FOptions = {};
      this.FFilterIndex = 0;
      this.FOnFileAsBase64 = null;
      this.FOnGetFileAsArrayBuffer = null;
      this.FOnFileAsDataURL = null;
      this.FOnFileAsText = null;
      this.FOnGetFileAsStream = null;
    };
    this.$final = function () {
      this.FFiles = undefined;
      this.FOnChange = undefined;
      this.FOpenDialogProc = undefined;
      this.FOptions = undefined;
      this.FOnFileAsBase64 = undefined;
      this.FOnGetFileAsArrayBuffer = undefined;
      this.FOnFileAsDataURL = undefined;
      this.FOnFileAsText = undefined;
      this.FOnGetFileAsStream = undefined;
      pas.Classes.TComponent.$final.call(this);
    };
    this.HandleInputChange = function (Event) {
      var i = 0;
      var l = 0;
      var sz = 0;
      var s = "";
      var m = "";
      var f = null;
      var d = null;
      var jsfile = null;
      while (this.FFiles.GetCount() > 0) this.FFiles.Delete(0);
      var curFiles = Event.target.files;
      l = curFiles.length;
      for (var $l = 0, $end = l - 1; $l <= $end; $l++) {
        i = $l;
        f = this.FFiles.Add$1();
        jsfile = curFiles[i];
        s = curFiles[i].name;
        m = curFiles[i].type;
        sz = curFiles[i].size;
        d = new Date(curFiles[i].lastModified);
        if (i === 0) this.FFileName = s;
        f.FFileObject = jsfile;
        f.FName = s;
        f.FMimeType = m;
        f.FSize = sz;
        f.FModified = pas.SysUtils.EncodeDate(d.getFullYear(),d.getMonth() + 1,d.getDate()) + pas.SysUtils.EncodeTime(d.getHours(),d.getMinutes(),d.getSeconds(),d.getMilliseconds());
      };
      if (this.FOpenDialogProc != null) this.FOpenDialogProc(this.FFileName);
      this.FOpenDialogProc = null;
      if (this.FOnChange != null) this.FOnChange(this);
    };
    this.Create$1 = function (AOwner) {
      pas.Classes.TComponent.Create$1.call(this,AOwner);
      this.FFiles = $mod.TFiles.$create("Create$2",[this]);
      return this;
    };
    this.Create$3 = function () {
      pas.System.TObject.Create.call(this);
      this.FFiles = $mod.TFiles.$create("Create$2",[this]);
      return this;
    };
    this.Destroy = function () {
      rtl.free(this,"FFiles");
      pas.Classes.TComponent.Destroy.call(this);
    };
    this.Execute = function () {
      var ic = null;
      var fp = null;
      ic = rtl.createCallback(this,"HandleInputChange");
      fp = document.createElement("input");
      fp.setAttribute("type","file");
      if (this.FMultiFile || ($mod.TOpenOption.ofAllowMultiSelect in this.FOptions)) fp.setAttribute("multiple","");
      if (this.FAccept !== "") fp.setAttribute("accept",this.FAccept);
      fp.addEventListener("change",ic);
      fp.click();
    };
    this.Execute$1 = function (AProc) {
      this.FOpenDialogProc = AProc;
      this.Execute();
    };
    this.Perform = function () {
      var $Self = this;
      var Result = null;
      Result = new Promise(function (ASuccess, AFailed) {
        $Self.Execute$1(function (AFileName) {
          ASuccess(AFileName);
        });
      });
      return Result;
    };
    rtl.addIntf(this,pas.System.IUnknown);
    var $r = this.$rtti;
    $r.addMethod("Create$1",2,[["AOwner",pas.Classes.$rtti["TComponent"]]]);
    $r.addMethod("Create$3",2,[]);
    $r.addProperty("Accept",0,rtl.string,"FAccept","FAccept");
    $r.addProperty("MultiFile",0,rtl.boolean,"FMultiFile","FMultiFile",{Default: false});
    $r.addProperty("OnChange",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnChange","FOnChange");
    $r.addProperty("OnGetFileAsText",0,$mod.$rtti["TFileAsTextEvent"],"FOnFileAsText","FOnFileAsText");
    $r.addProperty("OnGetFileAsArrayBuffer",0,$mod.$rtti["TFileAsArrayBufferEvent"],"FOnGetFileAsArrayBuffer","FOnGetFileAsArrayBuffer");
    $r.addProperty("OnGetFileAsStream",0,$mod.$rtti["TFileAsStreamEvent"],"FOnGetFileAsStream","FOnGetFileAsStream");
    $r.addProperty("OnGetFileAsBase64",0,$mod.$rtti["TFileAsBase64Event"],"FOnFileAsBase64","FOnFileAsBase64");
    $r.addProperty("OnGetFileAsDataURL",0,$mod.$rtti["TFileAsDataURLEvent"],"FOnFileAsDataURL","FOnFileAsDataURL");
  });
  rtl.createClass(this,"TWebOpenDialog",this.TOpenDialog,function () {
    rtl.addIntf(this,pas.System.IUnknown);
  });
  this.MessageDlg = function (Msg, DlgType, Buttons, AResultProc) {
    if (!($impl.WebLibDlg != null)) {
      $impl.WebLibDlg = $mod.TMessageDlg.$create("Create$1",[null]);
      if (pas["WEBLib.Forms"].Application.FMainForm.FCSSLibrary === pas["WEBLib.Controls"].TCSSLibrary.cssBootstrap) {
        $impl.WebLibDlg.InitBootstrapStyle();
      };
    };
    $impl.WebLibDlg.ShowDialog$1(Msg,DlgType,rtl.refSet(Buttons),AResultProc);
  };
  this.ShowMessage = function (AMsg) {
    if ((pas["WEBLib.Forms"].Application !== null) && (pas["WEBLib.Forms"].Application.FMainForm !== null) && (pas["WEBLib.Forms"].Application.FMainForm.FCSSLibrary === pas["WEBLib.Controls"].TCSSLibrary.cssBootstrap)) {
      $mod.MessageDlg(AMsg,$mod.TMsgDlgType.mtInformation,rtl.createSet($mod.TMsgDlgBtn.mbOK),null);
    } else {
      alert(AMsg);
    };
  };
  this.MessageDlgAsync = async function (Msg, DlgType, Buttons) {
    var Result = 0;
    if (!($impl.WebLibDlg != null)) {
      $impl.WebLibDlg = $mod.TMessageDlg.$create("Create$1",[null]);
      if (pas["WEBLib.Forms"].Application.FMainForm.FCSSLibrary === pas["WEBLib.Controls"].TCSSLibrary.cssBootstrap) {
        $impl.WebLibDlg.InitBootstrapStyle();
      };
    };
    Result = await $impl.WebLibDlg.ShowDialog$2(Msg,DlgType,rtl.refSet(Buttons));
    return Result;
  };
  this.InputBox = function (ACaption, APrompt, ADefault) {
    var Result = "";
    var retvalue = "";
    retvalue = prompt(APrompt, ADefault);
    if (retvalue == null) {
      retvalue = "";
    };
    Result = retvalue;
    return Result;
  };
  this.InputQuery = function (ACaption, APrompt, Value) {
    var Result = false;
    var retvalue = false;
    var s = "";
    retvalue = true;
    s = Value.get();
    var text = s;
    s = prompt(APrompt, text);
    if (s == null) {
      retvalue = false;
    };
    if (retvalue) Value.set(s);
    Result = retvalue;
    return Result;
  };
  this.Confirm = function (Value) {
    var Result = false;
    var res = false;
    res = confirm(Value);
    Result = res;
    return Result;
  };
  this.InputMessageDlg = function (Msg, DlgType, Buttons, AResult, AInputType, AResultProc) {
    function ResultHandler(AModalResult) {
      if (AModalResult !== 2) AResult.set($impl.WebLibInputDlg.GetInputElementValue());
      if (AResultProc != null) AResultProc(AModalResult);
    };
    if (!($impl.WebLibInputDlg != null)) {
      $impl.WebLibInputDlg = $mod.TInputMessageDlg.$create("Create$1",[null]);
      if (pas["WEBLib.Forms"].Application.FMainForm.FCSSLibrary === pas["WEBLib.Controls"].TCSSLibrary.cssBootstrap) {
        $impl.WebLibInputDlg.InitBootstrapStyle();
      };
    };
    $impl.WebLibInputDlg.FInputValue = AResult.get();
    $impl.WebLibInputDlg.FInputType = AInputType;
    $impl.WebLibInputDlg.ShowDialog$1(Msg,DlgType,rtl.refSet(Buttons),ResultHandler);
  };
  this.InputMessageDlgAsync = async function (Msg, DlgType, Buttons, AResult, AInputType) {
    var Result = 0;
    if (!($impl.WebLibInputDlg != null)) {
      $impl.WebLibInputDlg = $mod.TInputMessageDlg.$create("Create$1",[null]);
      if (pas["WEBLib.Forms"].Application.FMainForm.FCSSLibrary === pas["WEBLib.Controls"].TCSSLibrary.cssBootstrap) {
        $impl.WebLibInputDlg.InitBootstrapStyle();
      };
    };
    $impl.WebLibInputDlg.FInputValue = AResult.get();
    $impl.WebLibInputDlg.FInputType = AInputType;
    Result = await $impl.WebLibInputDlg.ShowDialog$2(Msg,DlgType,rtl.refSet(Buttons));
    AResult.set($impl.WebLibInputDlg.GetInputElementValue());
    return Result;
  };
  $mod.$implcode = function () {
    $impl.lMaterial = "https://fonts.googleapis.com/icon?family=Material+Icons";
    $impl.lWaitCursor = "0954474946496D61676547494638396190012C01A20000FFFFFFDDDDDDBBBBBB999999FFFFFFFFFFFFFFFFFFFFFFFF21FF0B4E45545343415045322E30030100000021F90405050004002C0000000090012C0182FFFFFFDDDDD" + "DBBBBBB999999FFFFFFFFFFFFFFFFFFFFFFFF03FF48BADCFE30CA49ABBD38EBCDBBFF60288E64699E68AAAE6CEBBE702CCF746DDF78AEEF7CEFFFC0A070482C1A8FC8A472C96C3A9FD0A8744AAD5AAFD8AC76CBED7ABFE0B078" + "4C2E9BCFE8B47ACD6EBBDFF0B87C4EAFDBEFF8BC7ECFEFFBFF808182838485868788898A8B8C8D8E8F909192939495969798999A9B9C9D9E9FA0A1A2A3A4A5A6A7A8A9AAABACADAEAFB0B1B2B3B4B5B6B7B8B9BABBBCBDBEBFC" + "0C1C2C3C4C5C6C7C8C9CACBCCCDCECFD0D1D2D3D4D5D6D7D8D9DADBDCDDDEDFE0E1E2E3E4E5E6E7E8E9EAEBECEDEEEFF0F1F2F3F4F5F6F7F8F9FAFBFCFDFEFF00030A1C48B0A0C18308132A5CC8B0A1C3871023861A407180C4" + "44152B5E349431FFE346421D357E141492E24892254F062A6951E51F962EC978F400D383809B02621E09493365079C387512A9B981A806A040850A319A812906A441950261D95283530B50A34AF541B52A86AB14B26ADDDA836" + "A519F19C4E6243B15AC04B711D4B20D62B629DA0B72E7B6BD5B01EE83BC7A7F74FDCA7782DAB58105FB6DB09801E0C45CEBF62D1CF731E4B28D15642660F93266CA0F3277F6CC43F204D162492F6DDC78B4EA1D834F8376ECFA" + "B50ED31016D7B69D237604BF8779AF9EBD80A7E1D4C24BCCFC803BB44809BB2F04981E20B9F19EC48F22F7409D3AEFE676AF87D8CEA1BB79DB5DBD86EF48827C06F3F0D1A7577F41BC08A8E5E1C77F3DDFE459FFFF2624B5817" + "EFA7DD71F7D4E1058A0700702D884820B26474083081601E17E1216D7A012179E97A103141AD161771FBEB56110237A57A26C070291E2742B5A70220F2FC6B81E78378C682307E9F970E18ED865370384408220240D111669E4" + "733F90A8E493504629E594545669E5955866A9A54014FA960400608629E698648EB955973D7E59E69A6C86A9149AF321D1E69C6C0A05679A46D0A9A7993ADDE925117B060A809D7E6E9683A07BBE59287B6A225AA7548B3229A" + "7A3656E69E9A59866AAE9A69C76EAE9A7A086AAC5728A39E8E99133A06AE59FBDE198259EB0B18A657F91C1BA6A8B9FC5596588A5D22A25AF7BF9AA24B04310BBA2B145206BDD8CFF4928CB1FB34C387B19B44F503BADB0EBA1" + "402A61BAAA862DB79286605F7DDD92662BB8DB32A72A88B226E6AA8CEB5260A873F1129AAE55F3B2382EBEF77AD6EF8DFF6A682ABDFBF25BE1AC8B15CCC0BBA2FEC6B05FED36ECB09009E71B6AC402336AA2C59F32ACD9911E4" + "B3C61662473CC69C8232BCC98C99AA29CB2C6F2B27C29C62BAB5C73BD2D1BAAB3CC5AD27C73C0ECF28C70BCF3BA9C73BDF91A8DA9D22F034D30CC0D33DD74B893E13C34CE16FBBC34C75C0B1DA5C9605B7DABCD1B438D2ED5A7" + "9A7DF6C0678BFC31DB6B1F0C2FDC6E77E075DDCA898D770A77EF2D42DF7E2F4976E02F004E7890741F9E2ADA8A37EEF8E390472EF9E494576EF9E5649867AEF9E69C77EEF9E7A0872EFAE8A4976EFAE9A8A7AEFAEAACB7EEFAE" + "BB0C72EFBECB4D76EFBEDB8E7AEFBEEBCF7EEFBEFC0072FFCF0C4176FFCF1C827AFFCF2CC37EFFCF3D0472FFDF4D4576FFDF5D867AFFDF6DC77EFFDF7E0872FFEF8E497DF7D020021F90405050007002CD60060003000570082" + "FFFFFFDDDDDDBBBBBB999999FFFFFFFFFFFFFFFFFFFFFFFF03EC78BABCF3A3C9492B85D0EA7D71E6E0E67D61298DA4A9A2A95AB291BBB2B20BD7E68D8770BC73BA9F2828B4108B1D1472A85C568E4E462F9A1C5127D36B037AE" + "5AA04608191B60B879FCD9A795DC5A8D7ECB6CF04AF8F1FB2BA9DAADF3BFB7E4880707C83665186877F8960858C8E865A895A0A83940B80970C819A95679DA0A1A2A3A4A5A6A7A8A9AA2A01ADAEAFB0B1B035B2B5B6AF2EB7BA" + "B6ACBBBEB826BFC201BDC3BBB9C6B7B4C9B2ABCECFD0D1D2D3D4D53200D800A5D9DCA2DCDFDA9DE0DFE2E3E494E6E3E8E9E05AECEDEEEFDDF1F2D8F4F5EBF5E157FAFBFCF8F9D8954B178AA0B773A3E65148000021F90405050" + "007002CD60075003000570082FFFFFFDDDDDDBBBBBB999999FFFFFFFFFFFFFFFFFFFFFFFF03E978BADCFE6EC801ABBD6D4ECCFBD1A0274660388E657A8AA9BA62ADFB56B13C93B576D3B9BEE33DCA2F13940C81BD2331A844B6" + "9A8F1C14529BF24CD6AB30CBED7ABFE0B0784C2E9BCF5C817ACD6EBBDBB3B77CCE5ED1EFF3137E0F1FF1FF027A807B76837471866F688B8C8D8E8F909192930A01960166979A639A9D98609E9DA0A1A25DA4A1A6A79E5CAAABA" + "CAD9BAFB096B2B3A9B39F59B8B91000BE002FB815BFBFC1B0BDC4C5C6A7C8C9C037CC0FCECAD0A5D2D3CF3BB1C3D862D8BEDEDD61DFD95FDF63E7E3E2EAD3E1EBE6EF5EE4EECEE8F15DE9ECF5FAFB60F9FEEDE81123D3CF1EB8" + "2909000021F90405050007002CC40092004200420082FFFFFFDDDDDDBBBBBB999999FFFFFFFFFFFFFFFFFFFFFFFF03F978BADCFE508D49ABBD36EA1DB1FF15277260F98DE863AE59EA4A6CFCBEB13CBBB579CFF9B9FFC0A0704" + "82C1A8FC8A472C96C3A9FD0A8747A105805D4D7759B1D6DBFD8AE06FC1547C860B3034D5633D86D77155E96CFE957FB1D1F76F3F3767F567A8246018701377F4488888A78438D8D3B74919287406C96978999751100A1001C9C" + "98415C1AA2A2A4A54FAAAA1BA5A64CAFABB1AD4DB5A1ACB84BBAA3BC97B9BA23B2B4C422C6BEC8C9BD48BF28B29DCFCCCD9C4AD0D1CA47D9DAD7D4B52FDB45DDDEC2DCD5E692E8E1E2E342E529EF41F1F2DF44F5EA8EE4E92EE" + "7FCED764C62F74A8F837C7610CA51E886A11A870F0B1A7C006B6283040021F90405050007002CA700A4005700300082FFFFFFDDDDDDBBBBBB999999FFFFFFFFFFFFFFFFFFFFFFFF03FF78BADCFE30CA37EA9838EBCD8FFD5D28" + "8ECD675E64AA4AA7B9BEB0D7BA711DCEADAD6B78BEFF90DE0948740869C5E411942C2E2D4DE51315054E35802CE027E80A464F8C56ABF37AC1C7C9785C339B4942F53ADB76775538C99C1CB39FF148107B7413018601187E772" + "B4C11835B858786898A518F90119292138A8B458F189A87947E4997A1A2889C9D9F8319A9AAABA540A0AFA91AAC3FB5A8A2B8953BBBBC9A1BB935A71AB0C4C530C1C29BCAB3CCCD91BDD0D12BD3D4C31CCB29D9DACFDCBF2ADF" + "12C91DDD22E5E6B721E91CC71DE7E8EF58AE22F3F4D71DF7F8ED22E342F40B914F9F1B6F6B521434E889041B85FF46BCA9E26C14C5280B2FFEC8A8511307C78E353E82842172E48B6A2689844BA920010021F90405050007002" + "C9200A4005700300082FFFFFFDDDDDDBBBBBB999999FFFFFFFFFFFFFFFFFFFFFFFF03FF78BADC0E10B849ABBD38B7C8B5FFE0C78D52689E2139A26C4BA9A42BB7B03ADF606DE33CA6C7BDE0E4B7121A17C4CE71998C2C8F4DC8" + "13DA9C5289A78036201C7807996476ABED7DBF3E1D8A4CC69DCF975A8BBD75BFBD69258B5EBFDDD1714E2E7C6517028702187F785607845C8688878A8B568F90159292178B8C4B8F189A88947F4F97A1A2899C9D9F8419A9AAA" + "BA546A0AFA91AAC42B5A8A2B89541BBBC9A1EB938A71AB0C4C533C1C29BCAB3CCCD91BDD0D183AE1FC91FCB7BD9DAB720DD637C21DBDCBFDEE5E6E1E2E926C720E7E8EF20D3C8EDEED7F6EB26F3FA6FD6F46357CD443D7E6D50" + "FC03E849602185F90C026A446D18452B0B2F0AC9A8B11207C78E383E829C2172A48C82268D3CE391000021F90405050007002C8A0092004200420082FFFFFFDDDDDDBBBBBB999999FFFFFFFFFFFFFFFFFFFFFFFF03F57807DCF" + "EF0A949ABBD98C6CD5DFEE0D58D5C6882642A9DACA5BE402B4FB03ADFF578EFF9B6FFC0A070482C1A8FC8A472C96C3A9FD0A8744A3D05AE81AA0CCBD59AB8E0AC3713068F2FE5F099922EAF0F6DF73AAE3ED3CDF63BF6ADDFE7" + "FB7C8081773B028602467A85878645743F8C8C446D4191878E784096979857439B8D2003A30352A088A2A4A350A7A819AAAA4FA721B0A44EADB4B5A54DB3B9B5BCA027BABB4BBDBEB04CC6C7B14AB8C2BAC5C12CC3CDCACBB64" + "9D6D7AB48DADBC446DEA9BF47E2E3C8E1E61FD4E99B3BEC45D237F044F233F4F59140F8F9A13FFC6F26000C78606040836F10AE5178866143740431304B000021F90405050007002C8A0075003000570082FFFFFFDDDDDDBBBB" + "BB999999FFFFFFFFFFFFFFFFFFFFFFFF03E778BA0C0E2CCA496B7BCEEA4DB1E7E0E68D61298DA8A9A2A95AB2ADCBC1B1ACD1A47DE3982EF20FDF0E0811768845E304A9AC009B161C340A9B0E7BD65F26CBED7ABFE0B0784C2E9" + "BCFA1807ACD6EBBDBB6B77CCE76D1EF73157E0F37F1FF017A807B76837471866F688B8C8D8E8F909192936802960266979A639A9D98609E9D5FA19E5DA4A159A7A856AAA553ADA2AFB097A9B396ACB69FB2B35CB63203C00316" + "BC2EC1C115AD36C6C614A73ECBC7CDB13AD0D1D2B742D5C062DAC261DDDE60DDDCE3DFDAE4D563E5E2E7E6EDECE9EEF1F0D0E8F5F6CBF8CCF2F7F4F9FADBD4CDD377669F86040021F90405050007002C8A0060003000570082F" + "FFFFFDDDDDDBBBBBB999999FFFFFFFFFFFFFFFFFFFFFFFF03EB78BADCFE0B4800ABBD6D4ECCBBD29A2756E0369E4C69A2A7BAB2A24BC1AD4B8FF28DDB7A27CF3D4C2E281C122DC62389A784249B8E2734229D1EAAD39F35CA84" + "04BE811EF60006EBB0E5F4ADCB48BB61EC857BCE2A55E67454C882CF4FFB7E50806F7F83655B8687568966858C888F90835B7280949578976D849A9B5F9DA0A1A2A3A4A5A6A7A8A93A02ACADAEAFB0AF30B1B4B5AE28B6B9B52" + "7BABDB223BEC102BCC2BDB8C5B6B3C8B1AACDCECFD0D1D2D3D4CF03D703A3D8DBA0DBDED997DFDE94E2DF56E5E250E8E94DEBE64AEEE3F0F1D8EAF4D7EDF7E0F3F453F75BFD00AED3842ED43B51DCAC24000021F90405050007" + "002C8A0058004200420082FFFFFFDDDDDDBBBBBB999999FFFFFFFFFFFFFFFFFFFFFFFF03FD78BADCFE30CA062A9838EB69EDFE20D77961698EA4A96E68B5BE597BC13424D738D5E64BE007AF1BEFF75B097144A2EA584B164FB" + "B9CF31962D2A6D48FF58A2D6DB9D36A74D8057DC14EF3985CD69CD149ED9A1D76CFE9713B8AE7C0026377784A807B7C0D7E842386878822858B3D6D116F528D93818696971D13029E027083129C129F9F309A2BA6AB2F92AAAB" + "AC26AE2AB0B5B27934B5B625A235BABB9020BFC0C11BC3B0C51FC7B1C91ACBA6CDC6CF9ED119D3D4D518D7D9D6CBDCCEC3DFE0BAE2D2CCE5E3A0E8EBECEDEEEFF0F1F2F3F4F5F68603F9FAFBFCFDFCD5FE020ADCD76CA04181C" + "90E2AFC576CA1C301091F2A2C287120C08AFEA225000021F90405050007002C920058005700300082FFFFFFDDDDDDBBBBBB999999FFFFFFFFFFFFFFFFFFFFFFFF03FF78BADCFE30BE4083BC38EB3D2BE560284A9E379E285756" + "69EB76EB2BBFEB37DF676DE13CA8F723815090FAA10048406B38441947C9248AC9CCD54ED1E889DA1C3D435969902BF45E4561B188DCF59D4169F59A2DFA6EE2CA149BE88EC1E32E7B217619782F822A6F1A8687881A8412787" + "98D64897E8B80337B7C19901092388E189E0F8CA1749D8A91993CA224AA11A6ADA817A40CB2B3B411B60AA0400AAE302518B83D9BB5B00DBEBFC0BA1097B1AC1003D40381CEC2C4D20FD5D54BD847DB0DDDE47A9532E2E3E4E5" + "635C33E90CEBF2ED6DE85918F2F373653C5A19F9FA9809041850E02F82EB0C3243C84E211086DD1C1E84484D620F8A152DF2C0A8F11322C38E0F09820C996FE4C48626495A4BA921010021F90401050007002CA700580057003" + "00082FFFFFFDDDDDDBBBBBB999999FFFFFFFFFFFFFFFFFFFFFFFF03FF78BADCFE4B4801ABBD38EB36E7FE60A8759D689E22E9A16C5BA9922BCF074CD1F869E77CB8F7A28170C0FA9D02C8406B38441945C9248AC9D4C18E51A9" + "89DA343D41596D902BF45EA161E489DC057D3569F1989C3A83E34BB6CFBE892BF3746E7C70782E6C441F6F177E33878823838B8C8D7A1B8A1593949519970F7E7F34879691988539A29CA49EA6A79B179D0D993CA8AFAAB1ACB" + "3B42FB60B9F400BBA10B00AB2408EB52A92B8C6AEC22418C5BF07C10F25CA612E00DA0018D428D121DBDBDD8132CB20E2E917CD2CE71AE9F0E45538D822F0F719F3395126F7F8D2D2FCFD03D843E04082380CC643C843A13A86" + "091D8E834843E2448A332C6AC358D11422C7880A3FE6082972A4C0920517A24CB9D14402003B";
    $impl.WebLibDlg = null;
    $impl.WebLibInputDlg = null;
    $impl.EventResult = function (Event) {
      var Result = "";
      Result = Event.target.result;
      return Result;
    };
    $impl.StringToHTML = function (AValue) {
      var Result = "";
      Result = pas.SysUtils.StringReplace(AValue,"\r","<BR>",rtl.createSet(pas.SysUtils.TStringReplaceFlag.rfReplaceAll));
      Result = pas.SysUtils.StringReplace(Result,"\n","",rtl.createSet(pas.SysUtils.TStringReplaceFlag.rfReplaceAll));
      return Result;
    };
    $impl.isAdvancedUpload = function () {
      var div = document.createElement('div');
      return (('draggable' in div) || ('ondragstart' in div && 'ondrop' in div)) && 'FormData' in window && 'FileReader' in window;
    };
  };
  $mod.$init = function () {
    $impl.WebLibDlg = null;
  };
},["WEBLib.Forms","WEBLib.Consts","WEBLib.WebTools"]);
rtl.module("Math",["System"],function () {
  "use strict";
  var $mod = this;
  var $impl = $mod.$impl;
  this.MinInteger = -0xfffffffffffff - 1;
  this.MaxInteger = 0xfffffffffffff;
  this.MinDouble = 5.0e-324;
  this.MaxDouble = 1.7e+308;
  this.InRange = function (AValue, AMin, AMax) {
    return (AValue >= AMin) && (AValue <= AMax);
  };
  this.InRange$1 = function (AValue, AMin, AMax) {
    return (AValue >= AMin) && (AValue <= AMax);
  };
  this.EnsureRange = function (AValue, AMin, AMax) {
    if (AValue<AMin){ return AMin;
    } else if (AValue>AMax){ return AMax;
    } else return AValue;
  };
  this.EnsureRange$1 = function (AValue, AMin, AMax) {
    if (AValue<AMin){ return AMin;
    } else if (AValue>AMax){ return AMax;
    } else return AValue;
  };
  this.$rtti.$Int("TRoundToRange",{minvalue: -37, maxvalue: 37, ordtype: 0});
  this.RoundTo = function (AValue, Digits) {
    var Result = 0.0;
    var RV = 0.0;
    RV = $mod.IntPower(10,Digits);
    Result = Math.round(AValue / RV) * RV;
    return Result;
  };
  this.SimpleRoundTo = function (AValue, Digits) {
    var Result = 0.0;
    var RV = 0.0;
    RV = $mod.IntPower(10,-Digits);
    if (AValue < 0) {
      Result = pas.System.Int((AValue * RV) - 0.5) / RV}
     else Result = pas.System.Int((AValue * RV) + 0.5) / RV;
    return Result;
  };
  this.randg = function (mean, stddev) {
    var Result = 0.0;
    var U1 = 0.0;
    var S2 = 0.0;
    do {
      U1 = (2 * Math.random()) - 1;
      S2 = pas.System.Sqr$1(U1) + pas.System.Sqr$1((2 * Math.random()) - 1);
    } while (!(S2 < 1));
    Result = (Math.sqrt((-2 * Math.log(S2)) / S2) * U1 * stddev) + mean;
    return Result;
  };
  this.RandomRange = function (aFrom, aTo) {
    var Result = 0;
    Result = pas.System.Random(Math.abs(aFrom - aTo)) + Math.min(aTo,aFrom);
    return Result;
  };
  this.RandomRange$1 = function (aFrom, aTo) {
    var Result = 0;
    var m = 0;
    if (aFrom < aTo) {
      m = aFrom}
     else m = aTo;
    Result = pas.System.Random(Math.abs(aFrom - aTo)) + m;
    return Result;
  };
  this.$rtti.$Int("TValueSign",{minvalue: -1, maxvalue: 1, ordtype: 0});
  this.NegativeValue = -1;
  this.ZeroValue = 0;
  this.PositiveValue = 1;
  this.IsZero = function (d, Epsilon) {
    var Result = false;
    if (Epsilon === 0) Epsilon = 1E-12;
    Result = Math.abs(d) <= Epsilon;
    return Result;
  };
  this.IsZero$1 = function (d) {
    var Result = false;
    Result = Math.abs(d) <= 1E-12;
    return Result;
  };
  this.IsInfinite = function (d) {
    return (d==Infinity) || (d==-Infinity);
  };
  this.SameValue = function (A, B, Epsilon) {
    var Result = false;
    if (Epsilon === 0.0) Epsilon = Math.max(Math.min(Math.abs(A),Math.abs(B)) * 1E-12,1E-12);
    if (A > B) {
      Result = (A - B) <= Epsilon}
     else Result = (B - A) <= Epsilon;
    return Result;
  };
  this.SinCos = function (A, B, C) {
    B.set(Math.sin(A));
    C.set(Math.cos(A));
  };
  this.LogN = function (Base, A) {
    var Result = 0.0;
    Result = Math.log(A) / Math.log(Base);
    return Result;
  };
  this.Ceil = function (A) {
    var Result = 0;
    Result = pas.System.Trunc(Math.ceil(A));
    return Result;
  };
  this.Floor = function (A) {
    var Result = 0;
    Result = pas.System.Trunc(Math.floor(A));
    return Result;
  };
  this.Ceil64 = function (A) {
    var Result = 0;
    Result = pas.System.Trunc(Math.ceil(A));
    return Result;
  };
  this.Floor64 = function (A) {
    var Result = 0;
    Result = pas.System.Trunc(Math.ceil(A));
    return Result;
  };
  this.ldexp = function (x, p) {
    var Result = 0.0;
    Result = x * $mod.IntPower(2.0,p);
    return Result;
  };
  this.Frexp = function (X, Mantissa, Exponent) {
    Exponent.set(0);
    if (X !== 0) if (Math.abs(X) < 0.5) {
      do {
        X = X * 2;
        Exponent.set(Exponent.get() - 1);
      } while (!(Math.abs(X) >= 0.5))}
     else while (Math.abs(X) >= 1) {
      X = X / 2;
      Exponent.set(Exponent.get() + 1);
    };
    Mantissa.set(X);
  };
  this.lnxp1 = function (x) {
    var Result = 0.0;
    var y = 0.0;
    if (x >= 4.0) {
      Result = Math.log(1.0 + x)}
     else {
      y = 1.0 + x;
      if (y === 1.0) {
        Result = x}
       else {
        Result = Math.log(y);
        if (y > 0.0) Result = Result + ((x - (y - 1.0)) / y);
      };
    };
    return Result;
  };
  this.IntPower = function (base, exponent) {
    var Result = 0.0;
    var i = 0;
    if ((base === 0.0) && (exponent === 0)) {
      Result = 1}
     else {
      i = Math.abs(exponent);
      Result = 1.0;
      while (i > 0) {
        while ((i & 1) === 0) {
          i = i >>> 1;
          base = pas.System.Sqr$1(base);
        };
        i = i - 1;
        Result = Result * base;
      };
      if (exponent < 0) Result = 1.0 / Result;
    };
    return Result;
  };
  this.DivMod = function (Dividend, Divisor, Result, Remainder) {
    if (Dividend < 0) {
      Dividend = -Dividend;
      Result.set(-rtl.trunc(Dividend / Divisor));
      Remainder.set(-(Dividend + (Result.get() * Divisor)));
    } else {
      Result.set(rtl.trunc(Dividend / Divisor));
      Remainder.set(Dividend - (Result.get() * Divisor));
    };
  };
  this.DivMod$1 = function (Dividend, Divisor, Result, Remainder) {
    if (Dividend < 0) {
      Dividend = -Dividend;
      Result.set(-rtl.trunc(Dividend / Divisor));
      Remainder.set(-(Dividend + (Result.get() * Divisor)));
    } else {
      Result.set(rtl.trunc(Dividend / Divisor));
      Remainder.set(Dividend - (Result.get() * Divisor));
    };
  };
  this.DivMod$2 = function (Dividend, Divisor, Result, Remainder) {
    Result.set(rtl.trunc(Dividend / Divisor));
    Remainder.set(Dividend - (Result.get() * Divisor));
  };
  this.DivMod$3 = function (Dividend, Divisor, Result, Remainder) {
    if (Dividend < 0) {
      Dividend = -Dividend;
      Result.set(-rtl.trunc(Dividend / Divisor));
      Remainder.set(-(Dividend + (Result.get() * Divisor)));
    } else {
      Result.set(rtl.trunc(Dividend / Divisor));
      Remainder.set(Dividend - (Result.get() * Divisor));
    };
  };
  this.DegToRad = function (deg) {
    var Result = 0.0;
    Result = deg * (Math.PI / 180.0);
    return Result;
  };
  this.RadToDeg = function (rad) {
    var Result = 0.0;
    Result = rad * (180.0 / Math.PI);
    return Result;
  };
  this.GradToRad = function (grad) {
    var Result = 0.0;
    Result = grad * (Math.PI / 200.0);
    return Result;
  };
  this.RadToGrad = function (rad) {
    var Result = 0.0;
    Result = rad * (200.0 / Math.PI);
    return Result;
  };
  this.DegToGrad = function (deg) {
    var Result = 0.0;
    Result = deg * (200.0 / 180.0);
    return Result;
  };
  this.GradToDeg = function (grad) {
    var Result = 0.0;
    Result = grad * (180.0 / 200.0);
    return Result;
  };
  this.CycleToRad = function (cycle) {
    var Result = 0.0;
    Result = 2 * Math.PI * cycle;
    return Result;
  };
  this.RadToCycle = function (rad) {
    var Result = 0.0;
    Result = rad * (1 / (2 * Math.PI));
    return Result;
  };
  this.DegNormalize = function (deg) {
    var Result = 0.0;
    Result = deg - (pas.System.Int(deg / 360) * 360);
    if (Result < 0) Result = Result + 360;
    return Result;
  };
  this.Norm = function (data) {
    var Result = 0.0;
    Result = Math.sqrt($impl.sumofsquares(data));
    return Result;
  };
  this.Mean = function (data) {
    var Result = 0.0;
    var N = 0;
    N = rtl.length(data);
    if (N === 0) {
      Result = 0}
     else Result = $mod.Sum(data) / N;
    return Result;
  };
  this.Sum = function (data) {
    var Result = 0.0;
    var i = 0;
    var N = 0;
    N = rtl.length(data);
    Result = 0.0;
    for (var $l = 0, $end = N - 1; $l <= $end; $l++) {
      i = $l;
      Result = Result + data[i];
    };
    return Result;
  };
  this.SumsAndSquares = function (data, Sum, SumOfSquares) {
    var i = 0;
    var n = 0;
    var t = 0.0;
    var s = 0.0;
    var ss = 0.0;
    n = rtl.length(data);
    ss = 0.0;
    s = 0.0;
    for (var $l = 0, $end = n - 1; $l <= $end; $l++) {
      i = $l;
      t = data[i];
      ss = ss + pas.System.Sqr$1(t);
      s = s + t;
    };
    Sum.set(s);
    SumOfSquares.set(ss);
  };
  this.StdDev = function (data) {
    var Result = 0.0;
    Result = Math.sqrt($mod.Variance(data));
    return Result;
  };
  this.MeanAndStdDev = function (data, Mean, StdDev) {
    var I = 0;
    var N = 0;
    var M = 0.0;
    var S = 0.0;
    N = rtl.length(data);
    M = 0;
    S = 0;
    for (var $l = 0, $end = N - 1; $l <= $end; $l++) {
      I = $l;
      M = M + data[I];
      S = S + pas.System.Sqr$1(data[I]);
    };
    M = M / N;
    S = S - (N * pas.System.Sqr$1(M));
    if (N > 1) {
      S = Math.sqrt(S / (N - 1))}
     else S = 0;
    Mean.set(M);
    StdDev.set(S);
  };
  this.Variance = function (data) {
    var Result = 0.0;
    var n = 0;
    n = rtl.length(data);
    if (n === 1) {
      Result = 0}
     else Result = $mod.TotalVariance(data) / (n - 1);
    return Result;
  };
  this.TotalVariance = function (data) {
    var Result = 0.0;
    var S = 0.0;
    var SS = 0.0;
    var N = 0;
    N = rtl.length(data);
    if (rtl.length(data) === 1) {
      Result = 0}
     else {
      $mod.SumsAndSquares(data,{get: function () {
          return S;
        }, set: function (v) {
          S = v;
        }},{get: function () {
          return SS;
        }, set: function (v) {
          SS = v;
        }});
      Result = SS - (pas.System.Sqr$1(S) / N);
    };
    return Result;
  };
  this.PopNStdDev = function (data) {
    var Result = 0.0;
    Result = Math.sqrt($mod.PopNVariance(data));
    return Result;
  };
  this.PopNVariance = function (data) {
    var Result = 0.0;
    var N = 0;
    N = rtl.length(data);
    if (N === 0) {
      Result = 0}
     else Result = $mod.TotalVariance(data) / N;
    return Result;
  };
  this.MomentSkewKurtosis = function (data, m1, m2, m3, m4, skew, kurtosis) {
    var i = 0;
    var N = 0;
    var deviation = 0.0;
    var deviation2 = 0.0;
    var reciprocalN = 0.0;
    var lm1 = 0.0;
    var lm2 = 0.0;
    var lm3 = 0.0;
    var lm4 = 0.0;
    var lskew = 0.0;
    var lkurtosis = 0.0;
    N = rtl.length(data);
    lm1 = 0;
    reciprocalN = 1 / N;
    for (var $l = 0, $end = N - 1; $l <= $end; $l++) {
      i = $l;
      lm1 = lm1 + data[i];
    };
    lm1 = reciprocalN * lm1;
    lm2 = 0;
    lm3 = 0;
    lm4 = 0;
    for (var $l1 = 0, $end1 = N - 1; $l1 <= $end1; $l1++) {
      i = $l1;
      deviation = data[i] - lm1;
      deviation2 = deviation * deviation;
      lm2 = lm2 + deviation2;
      lm3 = lm3 + (deviation2 * deviation);
      lm4 = lm4 + (deviation2 * deviation2);
    };
    lm2 = reciprocalN * lm2;
    lm3 = reciprocalN * lm3;
    lm4 = reciprocalN * lm4;
    lskew = lm3 / (Math.sqrt(lm2) * lm2);
    lkurtosis = lm4 / (lm2 * lm2);
    m1.set(lm1);
    m2.set(lm2);
    m3.set(lm3);
    m4.set(lm4);
    skew.set(lskew);
    kurtosis.set(lkurtosis);
  };
  this.TPaymentTime = {"0": "ptEndOfPeriod", ptEndOfPeriod: 0, "1": "ptStartOfPeriod", ptStartOfPeriod: 1};
  this.$rtti.$Enum("TPaymentTime",{minvalue: 0, maxvalue: 1, ordtype: 1, enumtype: this.TPaymentTime});
  this.FutureValue = function (ARate, NPeriods, APayment, APresentValue, APaymentTime) {
    var Result = 0.0;
    var q = 0.0;
    var qn = 0.0;
    var factor = 0.0;
    if (ARate === 0) {
      Result = -APresentValue - (APayment * NPeriods)}
     else {
      q = 1.0 + ARate;
      qn = Math.pow(q,NPeriods);
      factor = (qn - 1) / (q - 1);
      if (APaymentTime === $mod.TPaymentTime.ptStartOfPeriod) factor = factor * q;
      Result = -((APresentValue * qn) + (APayment * factor));
    };
    return Result;
  };
  var DELTA = 0.001;
  var EPS = 1E-9;
  var MAXIT = 20;
  this.InterestRate = function (NPeriods, APayment, APresentValue, AFutureValue, APaymentTime) {
    var Result = 0.0;
    var r1 = 0.0;
    var r2 = 0.0;
    var dr = 0.0;
    var fv1 = 0.0;
    var fv2 = 0.0;
    var iteration = 0;
    iteration = 0;
    r1 = 0.05;
    do {
      r2 = r1 + 1E-3;
      fv1 = $mod.FutureValue(r1,NPeriods,APayment,APresentValue,APaymentTime);
      fv2 = $mod.FutureValue(r2,NPeriods,APayment,APresentValue,APaymentTime);
      dr = ((AFutureValue - fv1) / (fv2 - fv1)) * 1E-3;
      r1 = r1 + dr;
      iteration += 1;
    } while (!((Math.abs(dr) < 1E-9) || (iteration >= 20)));
    Result = r1;
    return Result;
  };
  this.NumberOfPeriods = function (ARate, APayment, APresentValue, AFutureValue, APaymentTime) {
    var Result = 0.0;
    var q = 0.0;
    var x1 = 0.0;
    var x2 = 0.0;
    if (ARate === 0) {
      Result = -(APresentValue + AFutureValue) / APayment}
     else {
      q = 1.0 + ARate;
      if (APaymentTime === $mod.TPaymentTime.ptStartOfPeriod) APayment = APayment * q;
      x1 = APayment - (AFutureValue * ARate);
      x2 = APayment + (APresentValue * ARate);
      if ((x2 === 0) || ((Math.sign(x1) * Math.sign(x2)) < 0)) {
        Result = Infinity}
       else {
        Result = Math.log(x1 / x2) / Math.log(q);
      };
    };
    return Result;
  };
  this.Payment = function (ARate, NPeriods, APresentValue, AFutureValue, APaymentTime) {
    var Result = 0.0;
    var q = 0.0;
    var qn = 0.0;
    var factor = 0.0;
    if (ARate === 0) {
      Result = -(AFutureValue + APresentValue) / NPeriods}
     else {
      q = 1.0 + ARate;
      qn = Math.pow(q,NPeriods);
      factor = (qn - 1) / (q - 1);
      if (APaymentTime === $mod.TPaymentTime.ptStartOfPeriod) factor = factor * q;
      Result = -(AFutureValue + (APresentValue * qn)) / factor;
    };
    return Result;
  };
  this.PresentValue = function (ARate, NPeriods, APayment, AFutureValue, APaymentTime) {
    var Result = 0.0;
    var q = 0.0;
    var qn = 0.0;
    var factor = 0.0;
    if (ARate === 0.0) {
      Result = -AFutureValue - (APayment * NPeriods)}
     else {
      q = 1.0 + ARate;
      qn = Math.pow(q,NPeriods);
      factor = (qn - 1) / (q - 1);
      if (APaymentTime === $mod.TPaymentTime.ptStartOfPeriod) factor = factor * q;
      Result = -(AFutureValue + (APayment * factor)) / qn;
    };
    return Result;
  };
  this.IfThen = function (val, ifTrue, ifFalse) {
    var Result = 0;
    if (val) {
      Result = ifTrue}
     else Result = ifFalse;
    return Result;
  };
  this.IfThen$1 = function (val, ifTrue, ifFalse) {
    var Result = 0.0;
    if (val) {
      Result = ifTrue}
     else Result = ifFalse;
    return Result;
  };
  this.$rtti.$Int("TValueRelationship",{minvalue: -1, maxvalue: 1, ordtype: 0});
  this.EqualsValue = 0;
  this.LessThanValue = -1;
  this.GreaterThanValue = 1;
  this.CompareValue = function (A, B) {
    var Result = 0;
    Result = 1;
    if (A === B) {
      Result = 0}
     else if (A < B) Result = -1;
    return Result;
  };
  this.CompareValue$1 = function (A, B) {
    var Result = 0;
    Result = 1;
    if (A === B) {
      Result = 0}
     else if (A < B) Result = -1;
    return Result;
  };
  this.CompareValue$2 = function (A, B) {
    var Result = 0;
    Result = 1;
    if (A === B) {
      Result = 0}
     else if (A < B) Result = -1;
    return Result;
  };
  this.CompareValue$3 = function (A, B, delta) {
    var Result = 0;
    Result = 1;
    if (Math.abs(A - B) <= delta) {
      Result = 0}
     else if (A < B) Result = -1;
    return Result;
  };
  this.MinValue = function (Data) {
    var Result = 0.0;
    var I = 0;
    Result = Data[0];
    for (var $l = 1, $end = rtl.length(Data) - 1; $l <= $end; $l++) {
      I = $l;
      if (Result > Data[I]) Result = Data[I];
    };
    return Result;
  };
  this.MaxValue = function (Data) {
    var Result = 0.0;
    var I = 0;
    Result = Data[0];
    for (var $l = 1, $end = rtl.length(Data) - 1; $l <= $end; $l++) {
      I = $l;
      if (Result < Data[I]) Result = Data[I];
    };
    return Result;
  };
  this.MaxIntValue = function (AData) {
    var Result = 0;
    var lCount = 0;
    Result = AData[0];
    for (var $l = 1, $end = rtl.length(AData) - 1; $l <= $end; $l++) {
      lCount = $l;
      if (Result < AData[lCount]) Result = AData[lCount];
    };
    return Result;
  };
  $mod.$implcode = function () {
    $impl.DZeroResolution = 1E-12;
    $impl.sumofsquares = function (data) {
      var Result = 0.0;
      var i = 0;
      var N = 0;
      N = rtl.length(data);
      Result = 0.0;
      for (var $l = 0, $end = N - 1; $l <= $end; $l++) {
        i = $l;
        Result = Result + pas.System.Sqr$1(data[i]);
      };
      return Result;
    };
  };
},[]);
rtl.module("RTTI",["System","JS","RTLConsts","Types","SysUtils","TypInfo"],function () {
  "use strict";
  var $mod = this;
  var $impl = $mod.$impl;
  rtl.recNewT(this,"TValue",function () {
    this.FTypeInfo = null;
    this.FData = undefined;
    this.FReferenceVariableData = false;
    this.$eq = function (b) {
      return (this.FTypeInfo === b.FTypeInfo) && (this.FData === b.FData) && (this.FReferenceVariableData === b.FReferenceVariableData);
    };
    this.$assign = function (s) {
      this.FTypeInfo = s.FTypeInfo;
      this.FData = s.FData;
      this.FReferenceVariableData = s.FReferenceVariableData;
      return this;
    };
    this.GetData = function () {
      var Result = undefined;
      if (this.FReferenceVariableData) {
        Result = this.FData.get()}
       else Result = this.FData;
      return Result;
    };
    this.GetIsEmpty = function () {
      var Result = false;
      if ((this.FTypeInfo === null) || (this.GetData() == undefined) || (this.GetData() == null)) return true;
      var $tmp = this.FTypeInfo.kind;
      if ($tmp === pas.System.TTypeKind.tkDynArray) {
        Result = this.GetArrayLength() === 0}
       else {
        Result = false;
      };
      return Result;
    };
    this.GetTypeKind = function () {
      var Result = 0;
      if (this.FTypeInfo === null) {
        Result = pas.System.TTypeKind.tkUnknown}
       else Result = this.FTypeInfo.kind;
      return Result;
    };
    this.SetData = function (Value) {
      if (this.FReferenceVariableData) {
        this.FData.set(Value)}
       else this.FData = Value;
    };
    this.Empty = function () {
      var Result = $mod.TValue.$new();
      Result.SetData(null);
      Result.FTypeInfo = null;
      return Result;
    };
    this.FromArray = function (TypeInfo, Values) {
      var Result = $mod.TValue.$new();
      var A = 0;
      var NewArray = null;
      var ElementType = null;
      if (TypeInfo.kind !== pas.System.TTypeKind.tkDynArray) throw pas.SysUtils.EInvalidCast.$create("Create$1",["Type not an array in FromArray!"]);
      ElementType = TypeInfo.eltype;
      NewArray = new Array();
      NewArray.length = rtl.length(Values);
      for (var $l = 0, $end = rtl.length(Values) - 1; $l <= $end; $l++) {
        A = $l;
        NewArray[A] = Values[A].Cast(ElementType,true).AsJSValue();
      };
      Result.SetData(NewArray);
      Result.FTypeInfo = TypeInfo;
      return Result;
    };
    this.FromJSValue = function (v) {
      var Result = $mod.TValue.$new();
      var i = 0;
      var TypeOfValue = null;
      var $tmp = typeof(v);
      if ($tmp === "number") {
        if (pas.JS.isInteger(v)) {
          i = rtl.trunc(v);
          if ((i >= -2147483648) && (i <= 2147483647)) {
            TypeOfValue = rtl.longint}
           else TypeOfValue = rtl.nativeint;
        } else TypeOfValue = rtl.double}
       else if ($tmp === "string") {
        TypeOfValue = rtl.string}
       else if ($tmp === "boolean") {
        TypeOfValue = rtl.boolean}
       else if ($tmp === "object") {
        if (v == null) {
          return $mod.TValue.Empty()}
         else if (pas.JS.isClass(v) && rtl.isExt(v,pas.System.TObject)) {
          TypeOfValue = rtl.getObject(v).$rtti}
         else if (rtl.isObject(v) && rtl.isExt(v,pas.System.TObject)) {
          TypeOfValue = rtl.getObject(v).$rtti}
         else if (pas.JS.isRecord(v)) {
          TypeOfValue = rtl.getObject(v).$rtti}
         else if (Array.isArray(v)) {
          TypeOfValue = rtl.getObject(v).$rtti}
         else throw pas.SysUtils.EInvalidCast.$create("Create$1",["Type not recognized in FromJSValue!"])}
       else {
        TypeOfValue = rtl.jsvalue;
      };
      $mod.TValue.Make(v,TypeOfValue,Result);
      return Result;
    };
    this.FromOrdinal = function (ATypeInfo, AValue) {
      var Result = $mod.TValue.$new();
      if ((ATypeInfo === null) || !(ATypeInfo.kind in rtl.createSet(pas.System.TTypeKind.tkBool,pas.System.TTypeKind.tkEnumeration,pas.System.TTypeKind.tkInteger))) throw pas.SysUtils.EInvalidCast.$create("Create$1",["Invalid type in FromOrdinal"]);
      if (ATypeInfo.kind === pas.System.TTypeKind.tkBool) {
        $mod.TValue.Make(AValue == true,ATypeInfo,Result)}
       else $mod.TValue.Make(rtl.trunc(AValue),ATypeInfo,Result);
      return Result;
    };
    this.Make = function (ABuffer, ATypeInfo, Result) {
      Result.FData = ABuffer;
      Result.FTypeInfo = ATypeInfo;
    };
    this.AsBoolean = function () {
      var Result = false;
      if (this.GetTypeKind() === pas.System.TTypeKind.tkBool) {
        Result = !(this.GetData() == false)}
       else throw pas.SysUtils.EInvalidCast.$create("Create$1",[rtl.getResStr(pas.RTLConsts,"SErrInvalidTypecast")]);
      return Result;
    };
    this.AsClass = function () {
      var Result = null;
      if (this.IsClass()) {
        Result = rtl.getObject(this.GetData())}
       else throw pas.SysUtils.EInvalidCast.$create("Create$1",[rtl.getResStr(pas.RTLConsts,"SErrInvalidTypecast")]);
      return Result;
    };
    this.AsExtended = function () {
      var Result = 0.0;
      if (rtl.isNumber(this.GetData())) {
        Result = rtl.getNumber(this.GetData())}
       else throw pas.SysUtils.EInvalidCast.$create("Create$1",[rtl.getResStr(pas.RTLConsts,"SErrInvalidTypecast")]);
      return Result;
    };
    this.AsInteger = function () {
      var Result = 0;
      if (pas.JS.isInteger(this.GetData())) {
        Result = rtl.trunc(this.GetData())}
       else throw pas.SysUtils.EInvalidCast.$create("Create$1",[rtl.getResStr(pas.RTLConsts,"SErrInvalidTypecast")]);
      return Result;
    };
    this.AsInterface = function () {
      var Result = null;
      var k = 0;
      var $ok = false;
      try {
        k = this.GetTypeKind();
        if (k === pas.System.TTypeKind.tkInterface) {
          Result = rtl.setIntfL(Result,rtl.getObject(this.GetData()))}
         else if ((k in rtl.createSet(pas.System.TTypeKind.tkClass,pas.System.TTypeKind.tkClassRef,pas.System.TTypeKind.tkUnknown)) && !rtl.isObject(this.GetData())) {
          Result = rtl.setIntfL(Result,null)}
         else throw pas.SysUtils.EInvalidCast.$create("Create$1",[rtl.getResStr(pas.RTLConsts,"SErrInvalidTypecast")]);
        $ok = true;
      } finally {
        if (!$ok) rtl._Release(Result);
      };
      return Result;
    };
    this.AsJSValue = function () {
      var Result = undefined;
      Result = this.GetData();
      return Result;
    };
    this.AsNativeInt = function () {
      var Result = 0;
      if (pas.JS.isInteger(this.GetData())) {
        Result = rtl.trunc(this.GetData())}
       else throw pas.SysUtils.EInvalidCast.$create("Create$1",[rtl.getResStr(pas.RTLConsts,"SErrInvalidTypecast")]);
      return Result;
    };
    this.AsObject = function () {
      var Result = null;
      if (this.IsObject() || (this.IsClass() && !rtl.isObject(this.GetData()))) {
        Result = rtl.getObject(this.GetData())}
       else throw pas.SysUtils.EInvalidCast.$create("Create$1",[rtl.getResStr(pas.RTLConsts,"SErrInvalidTypecast")]);
      return Result;
    };
    this.AsOrdinal = function () {
      var Result = 0;
      if (this.IsOrdinal()) {
        Result = rtl.trunc(this.GetData())}
       else throw pas.SysUtils.EInvalidCast.$create("Create$1",[rtl.getResStr(pas.RTLConsts,"SErrInvalidTypecast")]);
      return Result;
    };
    this.AsString = function () {
      var Result = "";
      if (rtl.isString(this.GetData())) {
        Result = "" + this.GetData()}
       else throw pas.SysUtils.EInvalidCast.$create("Create$1",[rtl.getResStr(pas.RTLConsts,"SErrInvalidTypecast")]);
      return Result;
    };
    this.AsUnicodeString = function () {
      var Result = "";
      Result = this.AsString();
      return Result;
    };
    this.Cast = function (ATypeInfo, EmptyAsAnyType) {
      var Result = $mod.TValue.$new();
      if (!this.TryCast(ATypeInfo,Result,EmptyAsAnyType)) throw pas.SysUtils.EInvalidCast.$create("Create$1",[""]);
      return Result;
    };
    this.IsType = function (ATypeInfo, EmptyAsAnyType) {
      var Result = false;
      var AnyValue = $mod.TValue.$new();
      Result = this.TryCast(ATypeInfo,AnyValue,EmptyAsAnyType);
      return Result;
    };
    this.GetArrayElement = function (aIndex) {
      var Result = $mod.TValue.$new();
      if (this.IsArray()) {
        var $tmp = this.GetTypeKind();
        if ($tmp === pas.System.TTypeKind.tkArray) {
          Result.FTypeInfo = this.FTypeInfo.eltype}
         else if ($tmp === pas.System.TTypeKind.tkDynArray) Result.FTypeInfo = this.FTypeInfo.eltype;
        Result.SetData(this.GetData()[aIndex]);
      } else throw pas.SysUtils.EInvalidCast.$create("Create$1",[rtl.getResStr(pas.RTLConsts,"SErrInvalidTypecast")]);
      return Result;
    };
    this.GetArrayLength = function () {
      var Result = 0;
      if (this.IsArray()) return rtl.length(this.GetData());
      throw pas.SysUtils.EInvalidCast.$create("Create$1",[rtl.getResStr(pas.RTLConsts,"SErrInvalidTypecast")]);
      return Result;
    };
    this.IsArray = function () {
      var Result = false;
      var $tmp = this.GetTypeKind();
      if ($tmp === pas.System.TTypeKind.tkDynArray) {
        return true}
       else if ($tmp === pas.System.TTypeKind.tkArray) {
        return rtl.length(this.FTypeInfo.dims) === 1}
       else {
        Result = false;
      };
      return Result;
    };
    this.IsClass = function () {
      var Result = false;
      var k = 0;
      k = this.GetTypeKind();
      Result = (k === pas.System.TTypeKind.tkClassRef) || ((k in rtl.createSet(pas.System.TTypeKind.tkClass,pas.System.TTypeKind.tkUnknown)) && !rtl.isObject(this.GetData()));
      return Result;
    };
    this.IsObject = function () {
      var Result = false;
      Result = this.GetIsEmpty() || (this.FTypeInfo.kind === pas.System.TTypeKind.tkClass);
      return Result;
    };
    this.IsObjectInstance = function () {
      var Result = false;
      Result = (this.FTypeInfo !== null) && (this.FTypeInfo.kind === pas.System.TTypeKind.tkClass);
      return Result;
    };
    this.IsOrdinal = function () {
      var Result = false;
      Result = this.GetIsEmpty() || (this.GetTypeKind() in rtl.createSet(pas.System.TTypeKind.tkBool,pas.System.TTypeKind.tkInteger,pas.System.TTypeKind.tkChar,pas.System.TTypeKind.tkEnumeration));
      return Result;
    };
    this.IsType$2 = function (ATypeInfo) {
      var Result = false;
      Result = ATypeInfo === this.FTypeInfo;
      return Result;
    };
    this.ToString = function () {
      var Result = "";
      var $tmp = this.GetTypeKind();
      if ($tmp === pas.System.TTypeKind.tkString) {
        Result = this.AsString()}
       else if ($tmp === pas.System.TTypeKind.tkInteger) {
        Result = pas.SysUtils.IntToStr(this.AsNativeInt())}
       else if ($tmp === pas.System.TTypeKind.tkBool) {
        Result = pas.SysUtils.BoolToStr(this.AsBoolean(),true)}
       else if ($tmp === pas.System.TTypeKind.tkDouble) {
        Result = pas.SysUtils.FloatToStr(this.AsExtended())}
       else {
        Result = "";
      };
      return Result;
    };
    this.TryCast = function (ATypeInfo, AResult, EmptyAsAnyType) {
      var $Self = this;
      var Result = false;
      function ConversionAccepted() {
        var Result = {};
        var $tmp = ATypeInfo.kind;
        if ($tmp === pas.System.TTypeKind.tkString) {
          return rtl.createSet(pas.System.TTypeKind.tkChar,pas.System.TTypeKind.tkString)}
         else if ($tmp === pas.System.TTypeKind.tkDouble) {
          return rtl.createSet(pas.System.TTypeKind.tkInteger,pas.System.TTypeKind.tkDouble)}
         else if ($tmp === pas.System.TTypeKind.tkEnumeration) {
          return rtl.createSet(pas.System.TTypeKind.tkInteger,pas.System.TTypeKind.tkEnumeration)}
         else {
          return rtl.createSet(ATypeInfo.kind);
        };
        return Result;
      };
      if (EmptyAsAnyType && this.GetIsEmpty()) {
        AResult.$assign(this.Empty());
        if (ATypeInfo !== null) {
          AResult.FTypeInfo = ATypeInfo;
          var $tmp = ATypeInfo.kind;
          if ($tmp === pas.System.TTypeKind.tkBool) {
            AResult.SetData(false)}
           else if ($tmp === pas.System.TTypeKind.tkChar) {
            AResult.SetData("\x00")}
           else if ($tmp === pas.System.TTypeKind.tkString) {
            AResult.SetData(pas.SysUtils.EmptyStr)}
           else if (($tmp === pas.System.TTypeKind.tkDouble) || ($tmp === pas.System.TTypeKind.tkEnumeration) || ($tmp === pas.System.TTypeKind.tkInteger)) AResult.SetData(0);
          return true;
        };
      };
      if (!EmptyAsAnyType && (this.FTypeInfo === null)) return false;
      if (this.FTypeInfo === ATypeInfo) {
        AResult.$assign($Self);
        return true;
      };
      if (ATypeInfo === null) return false;
      if (ATypeInfo === $mod.$rtti["TValue"]) {
        this.Make($Self,$mod.$rtti["TValue"],AResult);
        return true;
      };
      Result = this.FTypeInfo.kind in ConversionAccepted();
      if (Result) {
        AResult.SetData(this.FData);
        AResult.FTypeInfo = ATypeInfo;
      };
      return Result;
    };
    this.SetArrayElement = function (aIndex, AValue) {
      if (this.IsArray()) {
        this.GetData()[aIndex] = AValue.AsJSValue()}
       else throw pas.SysUtils.EInvalidCast.$create("Create$1",[rtl.getResStr(pas.RTLConsts,"SErrInvalidTypecast")]);
    };
    this.SetArrayLength = function (Size) {
      var NewArray = [];
      NewArray = this.GetData();
      NewArray = rtl.arraySetLength(NewArray,undefined,Size);
      this.SetData(NewArray);
    };
    this.From$G1 = function (Value) {
      var Result = $mod.TValue.$new();
      $mod.TValue.Make(Value,rtl.longint,Result);
      return Result;
    };
    this.From$G2 = function (Value) {
      var Result = $mod.TValue.$new();
      $mod.TValue.Make(Value,rtl.double,Result);
      return Result;
    };
    this.From$G3 = function (Value) {
      var Result = $mod.TValue.$new();
      $mod.TValue.Make(Value,rtl.string,Result);
      return Result;
    };
    this.From$G4 = function (Value) {
      var Result = $mod.TValue.$new();
      $mod.TValue.Make(Value,rtl.boolean,Result);
      return Result;
    };
    var $r = $mod.$rtti.$Record("TValue",{});
    $r.addMethod("Empty",5,[],$r,1);
    $r.addMethod("FromArray",5,[["TypeInfo",pas.TypInfo.$rtti["TTypeInfo"]],["Values",pas.System.$rtti["TArray<RTTI.TValue>"],2]],$r,1);
    $r.addMethod("FromJSValue",5,[["v",rtl.jsvalue]],$r,1);
    $r.addMethod("FromOrdinal",5,[["ATypeInfo",pas.TypInfo.$rtti["TTypeInfo"]],["AValue",rtl.jsvalue]],$r,1);
    $r.addMethod("Make",4,[["ABuffer",rtl.jsvalue,2],["ATypeInfo",rtl.pointer,2],["Result",$r,1]],null,1);
    $r.addMethod("AsBoolean",1,[],rtl.boolean);
    $r.addMethod("AsClass",1,[],pas.System.$rtti["TClass"]);
    $r.addMethod("AsExtended",1,[],pas.System.$rtti["Extended"]);
    $r.addMethod("AsInteger",1,[],rtl.longint);
    $r.addMethod("AsInterface",1,[],pas.System.$rtti["IUnknown"]);
    $r.addMethod("AsJSValue",1,[],rtl.jsvalue);
    $r.addMethod("AsNativeInt",1,[],rtl.nativeint);
    $r.addMethod("AsObject",1,[],pas.System.$rtti["TObject"]);
    $r.addMethod("AsOrdinal",1,[],rtl.nativeint);
    $r.addMethod("AsString",1,[],rtl.string);
    $r.addMethod("AsUnicodeString",1,[],rtl.string);
    $r.addMethod("Cast",1,[["ATypeInfo",pas.TypInfo.$rtti["TTypeInfo"]],["EmptyAsAnyType",rtl.boolean,2]],$r);
    $r.addMethod("IsType",1,[["ATypeInfo",pas.TypInfo.$rtti["TTypeInfo"]],["EmptyAsAnyType",rtl.boolean,2]],rtl.boolean);
    $r.addMethod("GetArrayElement",1,[["aIndex",rtl.nativeint]],$r);
    $r.addMethod("GetArrayLength",1,[],rtl.nativeint);
    $r.addMethod("IsArray",1,[],rtl.boolean);
    $r.addMethod("IsClass",1,[],rtl.boolean);
    $r.addMethod("IsObject",1,[],rtl.boolean);
    $r.addMethod("IsObjectInstance",1,[],rtl.boolean);
    $r.addMethod("IsOrdinal",1,[],rtl.boolean);
    $r.addMethod("IsType$2",1,[["ATypeInfo",pas.TypInfo.$rtti["TTypeInfo"]]],rtl.boolean);
    $r.addMethod("ToString",1,[],rtl.string);
    $r.addMethod("TryCast",1,[["ATypeInfo",pas.TypInfo.$rtti["TTypeInfo"]],["AResult",$r,4],["EmptyAsAnyType",rtl.boolean,2]],rtl.boolean);
    $r.addMethod("SetArrayElement",0,[["aIndex",rtl.nativeint],["AValue",$r,2]]);
    $r.addMethod("SetArrayLength",0,[["Size",rtl.nativeint,2]]);
    $r.addProperty("IsEmpty",1,rtl.boolean,"GetIsEmpty","");
    $r.addProperty("Kind",1,pas.System.$rtti["TTypeKind"],"GetTypeKind","");
    $r.addProperty("TypeInfo",0,pas.TypInfo.$rtti["TTypeInfo"],"FTypeInfo","");
  });
  this.$rtti.$Class("TRttiType");
  this.$rtti.$Class("TRttiInstanceType");
  this.$rtti.$Class("TRttiInstanceExternalType");
  rtl.recNewT(this,"TRTTIContext",function () {
    this.$eq = function (b) {
      return true;
    };
    this.$assign = function (s) {
      return this;
    };
    this.Create = function () {
      var Result = $mod.TRTTIContext.$new();
      $impl.TRttiPoolTypes.AcquireContext();
      return Result;
    };
    this.Free = function () {
      $impl.TRttiPoolTypes.ReleaseContext();
    };
    this.FindType = function (AQualifiedName) {
      var Result = null;
      Result = $impl.Pool.FindType(AQualifiedName);
      return Result;
    };
    this.GetType = function (aTypeInfo) {
      var Result = null;
      Result = $impl.Pool.GetType(aTypeInfo);
      return Result;
    };
    this.GetType$1 = function (aClass) {
      var Result = null;
      Result = $impl.Pool.GetType$1(aClass);
      return Result;
    };
    this.GetTypes = function () {
      var Result = [];
      var ModuleName = "";
      var ClassName = "";
      var ModuleTypes = null;
      for (var $in = Object.keys(pas), $l = 0, $end = rtl.length($in) - 1; $l <= $end; $l++) {
        ModuleName = $in[$l];
        ModuleTypes = pas[ModuleName].$rtti;
        for (ClassName in ModuleTypes) if (ModuleTypes[ClassName].hasOwnProperty("name") && (ClassName.charAt(0) !== "$")) this.GetType(ModuleTypes[ClassName]);
      };
      Result = Object.values($impl.Pool.FTypes);
      return Result;
    };
    this.KeepContext = function () {
      $impl.TRttiPoolTypes.AcquireContext();
    };
    this.DropContext = function () {
      $impl.TRttiPoolTypes.ReleaseContext();
    };
    var $r = $mod.$rtti.$Record("TRTTIContext",{});
    $r.addMethod("Create",5,[],$r,1);
    $r.addMethod("Free",0,[]);
    $r.addMethod("FindType",1,[["AQualifiedName",rtl.string,2]],$mod.$rtti["TRttiType"]);
    $r.addMethod("GetType",1,[["aTypeInfo",rtl.pointer]],$mod.$rtti["TRttiType"]);
    $r.addMethod("GetType$1",1,[["aClass",pas.System.$rtti["TClass"]]],$mod.$rtti["TRttiType"]);
    $r.addMethod("GetTypes",1,[],pas.System.$rtti["TArray<RTTI.TRttiType>"]);
    $r.addMethod("KeepContext",4,[],null,1);
    $r.addMethod("DropContext",4,[],null,1);
  });
  rtl.createClass(this,"TRttiObject",pas.System.TObject,function () {
    this.$init = function () {
      pas.System.TObject.$init.call(this);
      this.FAttributesLoaded = false;
      this.FAttributes = [];
      this.FParent = null;
      this.FHandle = null;
    };
    this.$final = function () {
      this.FAttributes = undefined;
      this.FParent = undefined;
      pas.System.TObject.$final.call(this);
    };
    this.LoadCustomAttributes = function () {
      var Result = [];
      Result = [];
      return Result;
    };
    this.Create$1 = function (AParent, AHandle) {
      this.FParent = AParent;
      this.FHandle = AHandle;
      return this;
    };
    this.Destroy = function () {
      var Attribute = null;
      for (var $in = this.FAttributes, $l = 0, $end = rtl.length($in) - 1; $l <= $end; $l++) {
        Attribute = $in[$l];
        Attribute = rtl.freeLoc(Attribute);
      };
      this.FAttributes = [];
      pas.System.TObject.Destroy.call(this);
    };
    this.GetAttributes = function () {
      var Result = [];
      if (!this.FAttributesLoaded) {
        this.FAttributes = this.LoadCustomAttributes();
        this.FAttributesLoaded = true;
      };
      Result = rtl.arrayRef(this.FAttributes);
      return Result;
    };
    this.GetAttribute$1 = function (Attribute) {
      var Result = null;
      var CustomAttribute = null;
      Result = null;
      for (var $in = this.GetAttributes(), $l = 0, $end = rtl.length($in) - 1; $l <= $end; $l++) {
        CustomAttribute = $in[$l];
        if (Attribute.isPrototypeOf(CustomAttribute)) return CustomAttribute;
      };
      return Result;
    };
    this.HasAttribute$1 = function (Attribute) {
      var Result = false;
      Result = this.GetAttribute$1(Attribute) !== null;
      return Result;
    };
  });
  rtl.createClass(this,"TRttiNamedObject",this.TRttiObject,function () {
    this.GetName = function () {
      var Result = "";
      Result = "";
      return Result;
    };
  });
  this.TMemberVisibility = {"0": "mvPrivate", mvPrivate: 0, "1": "mvProtected", mvProtected: 1, "2": "mvPublic", mvPublic: 2, "3": "mvPublished", mvPublished: 3};
  this.$rtti.$Enum("TMemberVisibility",{minvalue: 0, maxvalue: 3, ordtype: 1, enumtype: this.TMemberVisibility});
  rtl.createClass(this,"TRttiMember",this.TRttiNamedObject,function () {
    this.GetMemberTypeInfo = function () {
      var Result = null;
      Result = this.FHandle;
      return Result;
    };
    this.GetName = function () {
      var Result = "";
      Result = this.GetMemberTypeInfo().name;
      return Result;
    };
    this.GetParent = function () {
      var Result = null;
      Result = this.FParent;
      return Result;
    };
    this.GetVisibility = function () {
      var Result = 0;
      Result = $mod.TMemberVisibility.mvPublished;
      return Result;
    };
    this.LoadCustomAttributes = function () {
      var Result = [];
      Result = pas.TypInfo.GetRTTIAttributes(this.GetMemberTypeInfo().attr);
      return Result;
    };
    this.Create$2 = function (AParent, ATypeInfo) {
      if (!rtl.isExt(ATypeInfo,rtl.tTypeMember)) throw pas.SysUtils.EInvalidCast.$create("Create$1",[""]);
      $mod.TRttiObject.Create$1.call(this,AParent,ATypeInfo);
      return this;
    };
  });
  rtl.createClass(this,"TRttiField",this.TRttiMember,function () {
    this.GetFieldType = function () {
      var Result = null;
      Result = $impl.Pool.GetType(this.GetFieldTypeInfo().typeinfo);
      return Result;
    };
    this.GetFieldTypeInfo = function () {
      var Result = null;
      Result = this.FHandle;
      return Result;
    };
    this.Create$3 = function (AParent, ATypeInfo) {
      if (!rtl.isExt(ATypeInfo,rtl.tTypeMemberField)) throw pas.SysUtils.EInvalidCast.$create("Create$1",[""]);
      $mod.TRttiMember.Create$2.apply(this,arguments);
      return this;
    };
    this.GetValue = function (Instance) {
      var Result = $mod.TValue.$new();
      Result.$assign($mod.TValue.FromJSValue(Instance[this.GetName()]));
      return Result;
    };
    this.SetValue = function (Instance, AValue) {
      Instance[this.GetName()] = AValue.Cast(this.GetFieldType().GetHandle(),true).AsJSValue();
    };
  });
  rtl.createClass(this,"TRttiParameter",this.TRttiNamedObject,function () {
    this.$init = function () {
      $mod.TRttiNamedObject.$init.call(this);
      this.FParamType = null;
      this.FFlags = {};
      this.FName = "";
    };
    this.$final = function () {
      this.FParamType = undefined;
      this.FFlags = undefined;
      $mod.TRttiNamedObject.$final.call(this);
    };
    this.GetName = function () {
      var Result = "";
      Result = this.FName;
      return Result;
    };
  });
  rtl.createClass(this,"TRttiMethod",this.TRttiMember,function () {
    this.$init = function () {
      $mod.TRttiMember.$init.call(this);
      this.FParameters = [];
      this.FParametersLoaded = false;
    };
    this.$final = function () {
      this.FParameters = undefined;
      $mod.TRttiMember.$final.call(this);
    };
    this.GetIsAsyncCall = function () {
      var Result = false;
      Result = (pas.TypInfo.TProcedureFlag.pfAsync in this.GetProcedureFlags()) || ((this.GetReturnType() != null) && this.GetReturnType().GetIsInstanceExternal() && (this.GetReturnType().GetAsInstanceExternal().GetExternalName() === "Promise"));
      return Result;
    };
    this.GetIsClassMethod = function () {
      var Result = false;
      Result = this.GetMethodTypeInfo().methodkind in rtl.createSet(pas.TypInfo.TMethodKind.mkClassFunction,pas.TypInfo.TMethodKind.mkClassProcedure);
      return Result;
    };
    this.GetIsConstructor = function () {
      var Result = false;
      Result = this.GetMethodTypeInfo().methodkind === pas.TypInfo.TMethodKind.mkConstructor;
      return Result;
    };
    this.GetIsDestructor = function () {
      var Result = false;
      Result = this.GetMethodTypeInfo().methodkind === pas.TypInfo.TMethodKind.mkDestructor;
      return Result;
    };
    this.GetIsExternal = function () {
      var Result = false;
      Result = pas.TypInfo.TProcedureFlag.pfExternal in this.GetProcedureFlags();
      return Result;
    };
    this.GetIsSafeCall = function () {
      var Result = false;
      Result = pas.TypInfo.TProcedureFlag.pfSafeCall in this.GetProcedureFlags();
      return Result;
    };
    this.GetIsStatic = function () {
      var Result = false;
      Result = pas.TypInfo.TProcedureFlag.pfStatic in this.GetProcedureFlags();
      return Result;
    };
    this.GetMethodKind = function () {
      var Result = 0;
      Result = this.GetMethodTypeInfo().methodkind;
      return Result;
    };
    this.GetMethodTypeInfo = function () {
      var Result = null;
      Result = this.FHandle;
      return Result;
    };
    var PROCEDURE_FLAGS = [1,2,4,8,16];
    this.GetProcedureFlags = function () {
      var Result = {};
      var Flag = 0;
      var ProcedureFlags = 0;
      ProcedureFlags = this.GetMethodTypeInfo().procsig.flags;
      Result = {};
      for (Flag = 0; Flag <= 4; Flag++) if (rtl.and(PROCEDURE_FLAGS[Flag],ProcedureFlags) > 0) Result = rtl.unionSet(Result,rtl.createSet(Flag));
      return Result;
    };
    this.GetReturnType = function () {
      var Result = null;
      Result = $impl.Pool.GetType(this.GetMethodTypeInfo().procsig.resulttype);
      return Result;
    };
    var FLAGS_CONVERSION = [1,2,4,8,16,32];
    this.LoadParameters = function () {
      var A = 0;
      var Flag = 0;
      var Param = null;
      var RttiParam = null;
      var MethodParams = [];
      this.FParametersLoaded = true;
      MethodParams = this.GetMethodTypeInfo().procsig.params;
      this.FParameters = rtl.arraySetLength(this.FParameters,null,rtl.length(MethodParams));
      for (var $l = 0, $end = rtl.length(this.FParameters) - 1; $l <= $end; $l++) {
        A = $l;
        Param = MethodParams[A];
        RttiParam = $mod.TRttiParameter.$create("Create$1",[this,Param]);
        RttiParam.FName = Param.name;
        RttiParam.FParamType = $impl.Pool.GetType(Param.typeinfo);
        for (Flag = 0; Flag <= 5; Flag++) if (rtl.and(FLAGS_CONVERSION[Flag],Param.flags) > 0) RttiParam.FFlags = rtl.unionSet(RttiParam.FFlags,rtl.createSet(Flag));
        this.FParameters[A] = RttiParam;
      };
    };
    this.GetIsVarArgs = function () {
      var Result = false;
      Result = pas.TypInfo.TProcedureFlag.pfVarargs in this.GetProcedureFlags();
      return Result;
    };
    this.GetParameters = function () {
      var Result = [];
      if (!this.FParametersLoaded) this.LoadParameters();
      Result = rtl.arrayRef(this.FParameters);
      return Result;
    };
    this.Invoke = function (Instance, Args) {
      var Result = $mod.TValue.$new();
      var A = 0;
      var AArgs = [];
      if (this.GetReturnType() != null) Result.FTypeInfo = this.GetReturnType().GetHandle();
      AArgs = rtl.arraySetLength(AArgs,undefined,rtl.length(Args));
      for (var $l = 0, $end = rtl.length(Args) - 1; $l <= $end; $l++) {
        A = $l;
        AArgs[A] = Args[A].AsJSValue();
      };
      Result.SetData(Instance.AsJSValue()[this.GetName()].apply(Instance.AsJSValue(),AArgs));
      return Result;
    };
    this.Invoke$1 = function (Instance, Args) {
      var Result = $mod.TValue.$new();
      var v = $mod.TValue.$new();
      $mod.TValue.Make(Instance,Instance.$class.ClassInfo(),v);
      Result.$assign(this.Invoke(v,Args));
      return Result;
    };
    this.Invoke$2 = function (aClass, Args) {
      var Result = $mod.TValue.$new();
      var v = $mod.TValue.$new();
      $mod.TValue.Make(aClass,aClass.ClassInfo(),v);
      Result.$assign(this.Invoke(v,Args));
      return Result;
    };
  });
  rtl.createClass(this,"TRttiProperty",this.TRttiMember,function () {
    this.GetPropertyTypeInfo = function () {
      var Result = null;
      Result = this.FHandle;
      return Result;
    };
    this.GetPropertyType = function () {
      var Result = null;
      Result = $impl.Pool.GetType(this.GetPropertyTypeInfo().typeinfo);
      return Result;
    };
    this.GetIsWritable = function () {
      var Result = false;
      Result = this.GetPropertyTypeInfo().setter !== "";
      return Result;
    };
    this.GetIsReadable = function () {
      var Result = false;
      Result = this.GetPropertyTypeInfo().getter !== "";
      return Result;
    };
    this.GetVisibility = function () {
      var Result = 0;
      Result = $mod.TMemberVisibility.mvPublished;
      return Result;
    };
    this.Create$3 = function (AParent, ATypeInfo) {
      if (!rtl.isExt(ATypeInfo,rtl.tTypeMemberProperty)) throw pas.SysUtils.EInvalidCast.$create("Create$1",[""]);
      $mod.TRttiMember.Create$2.apply(this,arguments);
      return this;
    };
    this.GetValue = function (Instance) {
      var Result = $mod.TValue.$new();
      $mod.TValue.Make(pas.TypInfo.GetJSValueProp$1(Instance,this.GetPropertyTypeInfo()),this.GetPropertyType().GetHandle(),Result);
      return Result;
    };
    this.SetValue = function (Instance, AValue) {
      pas.TypInfo.SetJSValueProp$1(Instance,this.GetPropertyTypeInfo(),AValue.Cast(this.GetPropertyType().GetHandle(),true).AsJSValue());
    };
  });
  rtl.createClass(this,"TRttiInstanceProperty",this.TRttiProperty,function () {
  });
  rtl.createClass(this,"TRttiType",this.TRttiNamedObject,function () {
    this.GetAsInstance = function () {
      var Result = null;
      Result = rtl.as(this,$mod.TRttiInstanceType);
      return Result;
    };
    this.GetAsInstanceExternal = function () {
      var Result = null;
      Result = rtl.as(this,$mod.TRttiInstanceExternalType);
      return Result;
    };
    this.GetHandle = function () {
      var Result = null;
      Result = this.FHandle;
      return Result;
    };
    this.GetQualifiedName = function () {
      var Result = "";
      Result = pas.SysUtils.Format("%s.%s",pas.System.VarRecs(18,this.GetHandle().$module.$name,18,this.GetName()));
      return Result;
    };
    this.GetName = function () {
      var Result = "";
      Result = this.GetHandle().name;
      return Result;
    };
    this.GetIsInstance = function () {
      var Result = false;
      Result = $mod.TRttiInstanceType.isPrototypeOf(this);
      return Result;
    };
    this.GetIsInstanceExternal = function () {
      var Result = false;
      Result = $mod.TRttiInstanceExternalType.isPrototypeOf(this);
      return Result;
    };
    this.GetIsOrdinal = function () {
      var Result = false;
      Result = false;
      return Result;
    };
    this.GetIsRecord = function () {
      var Result = false;
      Result = false;
      return Result;
    };
    this.GetIsSet = function () {
      var Result = false;
      Result = false;
      return Result;
    };
    this.GetTypeKind = function () {
      var Result = 0;
      Result = this.GetHandle().kind;
      return Result;
    };
    this.GetBaseType = function () {
      var Result = null;
      Result = null;
      return Result;
    };
    this.LoadCustomAttributes = function () {
      var Result = [];
      Result = pas.TypInfo.GetRTTIAttributes(this.GetHandle().attr);
      return Result;
    };
    this.GetField = function (AName) {
      var Result = null;
      var AField = null;
      Result = null;
      for (var $in = this.GetFields(), $l = 0, $end = rtl.length($in) - 1; $l <= $end; $l++) {
        AField = $in[$l];
        if (AField.GetName() === AName) return AField;
      };
      return Result;
    };
    this.GetFields = function () {
      var Result = [];
      Result = [];
      return Result;
    };
    this.GetMethods = function () {
      var Result = [];
      Result = [];
      return Result;
    };
    this.GetMethods$1 = function (aName) {
      var Result = [];
      Result = [];
      return Result;
    };
    this.GetMethod = function (aName) {
      var Result = null;
      Result = null;
      if (aName === "") ;
      return Result;
    };
    this.GetProperty = function (AName) {
      var Result = null;
      Result = null;
      if (AName === "") ;
      return Result;
    };
    this.GetProperties = function () {
      var Result = [];
      Result = [];
      return Result;
    };
    this.GetDeclaredProperties = function () {
      var Result = [];
      Result = [];
      return Result;
    };
    this.GetDeclaredMethods = function () {
      var Result = [];
      Result = [];
      return Result;
    };
    this.GetDeclaredFields = function () {
      var Result = [];
      Result = [];
      return Result;
    };
  });
  this.$rtti.$ClassRef("TRttiTypeClass",{instancetype: this.$rtti["TRttiType"]});
  rtl.createClass(this,"TRttiStructuredType",this.TRttiType,function () {
    this.$init = function () {
      $mod.TRttiType.$init.call(this);
      this.FFields = [];
      this.FMethods = [];
      this.FProperties = [];
    };
    this.$final = function () {
      this.FFields = undefined;
      this.FMethods = undefined;
      this.FProperties = undefined;
      $mod.TRttiType.$final.call(this);
    };
    this.GetAncestor = function () {
      var Result = null;
      Result = null;
      return Result;
    };
    this.GetStructTypeInfo = function () {
      var Result = null;
      Result = this.GetHandle();
      return Result;
    };
    this.Create$1 = function (AParent, ATypeInfo) {
      if (!rtl.isExt(ATypeInfo,rtl.tTypeInfoStruct)) throw pas.SysUtils.EInvalidCast.$create("Create$1",[""]);
      $mod.TRttiObject.Create$1.apply(this,arguments);
      return this;
    };
    this.Destroy = function () {
      var Method = null;
      var Prop = null;
      for (var $in = this.FMethods, $l = 0, $end = rtl.length($in) - 1; $l <= $end; $l++) {
        Method = $in[$l];
        Method = rtl.freeLoc(Method);
      };
      for (var $in1 = this.FProperties, $l1 = 0, $end1 = rtl.length($in1) - 1; $l1 <= $end1; $l1++) {
        Prop = $in1[$l1];
        Prop = rtl.freeLoc(Prop);
      };
      $mod.TRttiObject.Destroy.call(this);
    };
    this.GetDeclaredFields = function () {
      var Result = [];
      var A = 0;
      var FieldCount = 0;
      if (!(rtl.length(this.FFields) > 0)) {
        FieldCount = this.GetStructTypeInfo().fields.length;
        this.FFields = rtl.arraySetLength(this.FFields,null,FieldCount);
        for (var $l = 0, $end = FieldCount - 1; $l <= $end; $l++) {
          A = $l;
          this.FFields[A] = $mod.TRttiField.$create("Create$3",[this,this.GetStructTypeInfo().getField(A)]);
        };
      };
      Result = rtl.arrayRef(this.FFields);
      return Result;
    };
    this.GetDeclaredMethods = function () {
      var Result = [];
      var A = 0;
      var MethodCount = 0;
      if (!(rtl.length(this.FMethods) > 0)) {
        MethodCount = this.GetStructTypeInfo().methods.length;
        this.FMethods = rtl.arraySetLength(this.FMethods,null,MethodCount);
        for (var $l = 0, $end = MethodCount - 1; $l <= $end; $l++) {
          A = $l;
          this.FMethods[A] = $mod.TRttiMethod.$create("Create$2",[this,this.GetStructTypeInfo().getMethod(A)]);
        };
      };
      Result = rtl.arrayRef(this.FMethods);
      return Result;
    };
    this.GetDeclaredProperties = function () {
      var Result = [];
      var A = 0;
      var PropCount = 0;
      if (!(rtl.length(this.FProperties) > 0)) {
        PropCount = this.GetStructTypeInfo().properties.length;
        this.FProperties = rtl.arraySetLength(this.FProperties,null,PropCount);
        for (var $l = 0, $end = PropCount - 1; $l <= $end; $l++) {
          A = $l;
          this.FProperties[A] = $mod.TRttiProperty.$create("Create$3",[this,this.GetStructTypeInfo().getProperty(A)]);
        };
      };
      Result = rtl.arrayRef(this.FProperties);
      return Result;
    };
    this.GetFields = function () {
      var Result = [];
      var A = 0;
      var Start = 0;
      var BaseClass = null;
      var Declared = [];
      BaseClass = this;
      Result = [];
      while (BaseClass != null) {
        Declared = BaseClass.GetDeclaredFields();
        Start = rtl.length(Result);
        Result = rtl.arraySetLength(Result,null,Start + rtl.length(Declared));
        for (var $l = 0, $end = rtl.length(Declared) - 1; $l <= $end; $l++) {
          A = $l;
          Result[Start + A] = Declared[A];
        };
        BaseClass = BaseClass.GetAncestor();
      };
      return Result;
    };
    this.GetMethod = function (aName) {
      var Result = null;
      var Method = null;
      for (var $in = this.GetMethods(), $l = 0, $end = rtl.length($in) - 1; $l <= $end; $l++) {
        Method = $in[$l];
        if (aName === Method.GetName()) return Method;
      };
      return Result;
    };
    this.GetMethods = function () {
      var Result = [];
      var A = 0;
      var Start = 0;
      var BaseClass = null;
      var Declared = [];
      BaseClass = this;
      Result = [];
      while (BaseClass != null) {
        Declared = BaseClass.GetDeclaredMethods();
        Start = rtl.length(Result);
        Result = rtl.arraySetLength(Result,null,Start + rtl.length(Declared));
        for (var $l = 0, $end = rtl.length(Declared) - 1; $l <= $end; $l++) {
          A = $l;
          Result[Start + A] = Declared[A];
        };
        BaseClass = BaseClass.GetAncestor();
      };
      return Result;
    };
    this.GetMethods$1 = function (aName) {
      var Result = [];
      var Method = null;
      var MethodCount = 0;
      MethodCount = 0;
      for (var $in = this.GetMethods(), $l = 0, $end = rtl.length($in) - 1; $l <= $end; $l++) {
        Method = $in[$l];
        if (aName === Method.GetName()) MethodCount += 1;
      };
      Result = rtl.arraySetLength(Result,null,MethodCount);
      for (var $in1 = this.GetMethods(), $l1 = 0, $end1 = rtl.length($in1) - 1; $l1 <= $end1; $l1++) {
        Method = $in1[$l1];
        if (aName === Method.GetName()) {
          MethodCount -= 1;
          Result[MethodCount] = Method;
        };
      };
      return Result;
    };
    this.GetProperties = function () {
      var Result = [];
      var A = 0;
      var Start = 0;
      var BaseClass = null;
      var Declared = [];
      BaseClass = this;
      Result = [];
      while (BaseClass != null) {
        Declared = BaseClass.GetDeclaredProperties();
        Start = rtl.length(Result);
        Result = rtl.arraySetLength(Result,null,Start + rtl.length(Declared));
        for (var $l = 0, $end = rtl.length(Declared) - 1; $l <= $end; $l++) {
          A = $l;
          Result[Start + A] = Declared[A];
        };
        BaseClass = BaseClass.GetAncestor();
      };
      return Result;
    };
    this.GetProperty = function (AName) {
      var Result = null;
      var Prop = null;
      var lName = "";
      lName = pas.SysUtils.LowerCase(AName);
      for (var $in = this.GetProperties(), $l = 0, $end = rtl.length($in) - 1; $l <= $end; $l++) {
        Prop = $in[$l];
        if (pas.SysUtils.LowerCase(Prop.GetName()) === lName) return Prop;
      };
      Result = null;
      return Result;
    };
  });
  rtl.createClass(this,"TRttiInstanceType",this.TRttiStructuredType,function () {
    this.GetAncestorType = function () {
      var Result = null;
      Result = rtl.as(this.FParent,$mod.TRttiInstanceType);
      return Result;
    };
    this.GetClassTypeInfo = function () {
      var Result = null;
      Result = this.GetHandle();
      return Result;
    };
    this.GetMetaClassType = function () {
      var Result = null;
      Result = this.GetClassTypeInfo().class;
      return Result;
    };
    this.GetAncestor = function () {
      var Result = null;
      Result = this.GetAncestorType();
      return Result;
    };
    this.GetBaseType = function () {
      var Result = null;
      Result = this.GetAncestorType();
      return Result;
    };
    this.Create$1 = function (AParent, ATypeInfo) {
      if (!rtl.isExt(ATypeInfo,rtl.tTypeInfoClass)) throw pas.SysUtils.EInvalidCast.$create("Create$1",[""]);
      $mod.TRttiStructuredType.Create$1.apply(this,arguments);
      return this;
    };
  });
  rtl.createClass(this,"TRttiInterfaceType",this.TRttiStructuredType,function () {
    this.GetAncestorType = function () {
      var Result = null;
      Result = rtl.as($impl.Pool.GetType(this.GetInterfaceTypeInfo().ancestor),$mod.TRttiInterfaceType);
      return Result;
    };
    this.GetGUID = function () {
      var Result = pas.System.TGuid.$new();
      var GUID = "";
      GUID = this.GetInterfaceTypeInfo().interface.$guid;
      pas.SysUtils.TryStringToGUID(GUID,Result);
      return Result;
    };
    this.GetInterfaceTypeInfo = function () {
      var Result = null;
      Result = this.GetHandle();
      return Result;
    };
    this.GetAncestor = function () {
      var Result = null;
      Result = this.GetAncestorType();
      return Result;
    };
    this.GetBaseType = function () {
      var Result = null;
      Result = this.GetAncestorType();
      return Result;
    };
    this.Create$1 = function (AParent, ATypeInfo) {
      if (!rtl.isExt(ATypeInfo,rtl.tTypeInfoInterface)) throw pas.SysUtils.EInvalidCast.$create("Create$1",[""]);
      $mod.TRttiStructuredType.Create$1.apply(this,arguments);
      return this;
    };
  });
  rtl.createClass(this,"TRttiRecordType",this.TRttiStructuredType,function () {
    this.GetRecordTypeInfo = function () {
      var Result = null;
      Result = this.GetHandle();
      return Result;
    };
    this.GetIsRecord = function () {
      var Result = false;
      Result = true;
      return Result;
    };
    this.Create$1 = function (AParent, ATypeInfo) {
      if (!rtl.isExt(ATypeInfo,rtl.tTypeInfoRecord)) throw pas.SysUtils.EInvalidCast.$create("Create$1",[""]);
      $mod.TRttiStructuredType.Create$1.apply(this,arguments);
      return this;
    };
  });
  rtl.createClass(this,"TRttiClassRefType",this.TRttiType,function () {
    this.GetClassRefTypeInfo = function () {
      var Result = null;
      Result = this.GetHandle();
      return Result;
    };
    this.GetInstanceType = function () {
      var Result = null;
      Result = rtl.as($impl.Pool.GetType(this.GetClassRefTypeInfo().instancetype),$mod.TRttiInstanceType);
      return Result;
    };
    this.GetMetaclassType = function () {
      var Result = null;
      Result = this.GetInstanceType().GetMetaClassType();
      return Result;
    };
    this.Create$1 = function (AParent, ATypeInfo) {
      if (!rtl.isExt(ATypeInfo,rtl.tTypeInfoClassRef)) throw pas.SysUtils.EInvalidCast.$create("Create$1",[""]);
      $mod.TRttiObject.Create$1.apply(this,arguments);
      return this;
    };
  });
  rtl.createClass(this,"TRttiInstanceExternalType",this.TRttiType,function () {
    this.GetAncestor = function () {
      var Result = null;
      Result = rtl.as($impl.Pool.GetType(this.GetExternalClassTypeInfo().ancestor),$mod.TRttiInstanceExternalType);
      return Result;
    };
    this.GetExternalName = function () {
      var Result = "";
      Result = this.GetExternalClassTypeInfo().jsclass;
      return Result;
    };
    this.GetExternalClassTypeInfo = function () {
      var Result = null;
      Result = this.GetHandle();
      return Result;
    };
    this.Create$1 = function (AParent, ATypeInfo) {
      if (!rtl.isExt(ATypeInfo,rtl.tTypeInfoExtClass)) throw pas.SysUtils.EInvalidCast.$create("Create$1",[""]);
      $mod.TRttiObject.Create$1.apply(this,arguments);
      return this;
    };
  });
  rtl.createClass(this,"TRttiOrdinalType",this.TRttiType,function () {
    this.GetMaxValue = function () {
      var Result = 0;
      Result = this.GetOrdinalTypeInfo().maxvalue;
      return Result;
    };
    this.GetMinValue = function () {
      var Result = 0;
      Result = this.GetOrdinalTypeInfo().minvalue;
      return Result;
    };
    this.GetOrdType = function () {
      var Result = 0;
      Result = this.GetOrdinalTypeInfo().ordtype;
      return Result;
    };
    this.GetOrdinalTypeInfo = function () {
      var Result = null;
      Result = this.GetHandle();
      return Result;
    };
    this.Create$1 = function (AParent, ATypeInfo) {
      if (!rtl.isExt(ATypeInfo,rtl.tTypeInfoInteger)) throw pas.SysUtils.EInvalidCast.$create("Create$1",[""]);
      $mod.TRttiObject.Create$1.apply(this,arguments);
      return this;
    };
  });
  rtl.createClass(this,"TRttiEnumerationType",this.TRttiOrdinalType,function () {
    this.GetEnumerationTypeInfo = function () {
      var Result = null;
      Result = this.GetHandle();
      return Result;
    };
    this.Create$1 = function (AParent, ATypeInfo) {
      if (!rtl.isExt(ATypeInfo,rtl.tTypeInfoEnum)) throw pas.SysUtils.EInvalidCast.$create("Create$1",[""]);
      $mod.TRttiOrdinalType.Create$1.apply(this,arguments);
      return this;
    };
    this.GetNames = function () {
      var Result = [];
      var A = 0;
      var NamesSize = 0;
      NamesSize = pas.TypInfo.GetEnumNameCount(this.GetEnumerationTypeInfo());
      Result = rtl.arraySetLength(Result,"",NamesSize);
      for (var $l = 0, $end = NamesSize - 1; $l <= $end; $l++) {
        A = $l;
        Result[A] = this.GetEnumerationTypeInfo().enumtype[A + this.GetMinValue()];
      };
      return Result;
    };
  });
  rtl.createClass(this,"TRttiDynamicArrayType",this.TRttiType,function () {
    this.GetDynArrayTypeInfo = function () {
      var Result = null;
      Result = this.GetHandle();
      return Result;
    };
    this.GetElementType = function () {
      var Result = null;
      Result = $impl.Pool.GetType(this.GetDynArrayTypeInfo().eltype);
      return Result;
    };
    this.Create$1 = function (AParent, ATypeInfo) {
      if (!rtl.isExt(ATypeInfo,rtl.tTypeInfoDynArray)) throw pas.SysUtils.EInvalidCast.$create("Create$1",[""]);
      $mod.TRttiObject.Create$1.apply(this,arguments);
      return this;
    };
  });
  this.$rtti.$RefToProcVar("TVirtualInterfaceInvokeEvent",{procsig: rtl.newTIProcSig([["Method",this.$rtti["TRttiMethod"]],["Args",pas.System.$rtti["TArray<RTTI.TValue>"],2],["Result",this.$rtti["TValue"],4]])});
  this.$rtti.$RefToProcVar("TVirtualInterfaceInvokeEventJS",{procsig: rtl.newTIProcSig([["aMethodName",rtl.string,2],["Args",pas.Types.$rtti["TJSValueDynArray"],2]],rtl.jsvalue)});
  rtl.createClass(this,"TVirtualInterface",pas.System.TInterfacedObject,function () {
    this.$init = function () {
      pas.System.TInterfacedObject.$init.call(this);
      this.FContext = $mod.TRTTIContext.$new();
      this.FInterfaceType = null;
      this.FOnInvoke = null;
      this.FOnInvokeJS = null;
    };
    this.$final = function () {
      this.FContext = undefined;
      this.FInterfaceType = undefined;
      this.FOnInvoke = undefined;
      this.FOnInvokeJS = undefined;
      pas.System.TInterfacedObject.$final.call(this);
    };
    this.Invoke = function (MethodName, Args) {
      var $Self = this;
      var Result = undefined;
      var Method = null;
      var Return = $mod.TValue.$new();
      function GenerateParams() {
        var Result = [];
        var A = 0;
        var Param = null;
        var Parameters = [];
        Parameters = Method.GetParameters();
        Result = rtl.arraySetLength(Result,$mod.TValue,rtl.length(Parameters));
        for (var $l = 0, $end = rtl.length(Parameters) - 1; $l <= $end; $l++) {
          A = $l;
          Param = Parameters[A];
          $mod.TValue.Make(Args[A],Param.FParamType.GetHandle(),Result[A]);
          Result[A].FReferenceVariableData = (pas.TypInfo.TParamFlag.pfVar in Param.FFlags) || (pas.TypInfo.TParamFlag.pfOut in Param.FFlags);
        };
        return Result;
      };
      if (this.FOnInvokeJS != null) {
        Result = this.FOnInvokeJS(MethodName,Args)}
       else {
        Method = this.FInterfaceType.GetMethod(MethodName);
        this.FOnInvoke(Method,GenerateParams(),Return);
        Result = Return.AsJSValue();
      };
      return Result;
    };
    this.Create$1 = function (InterfaceTypeInfo) {
      var $Self = this;
      var SelfInterfaceObject = null;
      var InterfaceObject = null;
      var Method = null;
      var MethodName = "";
      this.FContext.$assign($mod.TRTTIContext.Create());
      this.FInterfaceType = rtl.as(this.FContext.GetType(InterfaceTypeInfo),$mod.TRttiInterfaceType);
      if (this.FInterfaceType.GetInterfaceTypeInfo().interface.$kind !== "com") throw pas.SysUtils.EInvalidCast.$create("Create");
      InterfaceObject = Object.create(this.FInterfaceType.GetInterfaceTypeInfo().interface);
      InterfaceObject.$o = $Self;
      for (var $in = this.FInterfaceType.GetMethods(), $l = 0, $end = rtl.length($in) - 1; $l <= $end; $l++) {
        Method = $in[$l];
        let MethodName = Method.GetName();
        InterfaceObject[MethodName] = function () {
          var Result = undefined;
          Result = this.$o.Invoke(MethodName,arguments);
          return Result;
        };
      };
      InterfaceObject["_AddRef"] = rtl.createCallback($Self,"_AddRef");
      InterfaceObject["_Release"] = rtl.createCallback($Self,"_Release");
      InterfaceObject["QueryInterface"] = rtl.createCallback($Self,"QueryInterface");
      SelfInterfaceObject = $Self;
      SelfInterfaceObject.$intfmaps = new Object();
      SelfInterfaceObject.$intfmaps[pas.SysUtils.GUIDToString(rtl.getIntfGUIDR(pas.System.IUnknown))] = InterfaceObject;
      SelfInterfaceObject.$intfmaps[pas.SysUtils.TGuidHelper.ToString.call(this.FInterfaceType.GetGUID(),false)] = new Object();
      SelfInterfaceObject.$interfaces = new Object();
      SelfInterfaceObject.$interfaces[pas.SysUtils.TGuidHelper.ToString.call(this.FInterfaceType.GetGUID(),false)] = InterfaceObject;
      return this;
    };
    this.Create$2 = function (InterfaceTypeInfo, InvokeEvent) {
      this.Create$1(InterfaceTypeInfo);
      this.FOnInvoke = InvokeEvent;
      return this;
    };
    this.Create$3 = function (InterfaceTypeInfo, InvokeEvent) {
      this.Create$1(InterfaceTypeInfo);
      this.FOnInvokeJS = InvokeEvent;
      return this;
    };
    this.Destroy = function () {
      this.FContext.Free();
      pas.System.TObject.Destroy.call(this);
    };
    this.QueryInterface = function (iid, obj) {
      var Result = 0;
      Result = pas.System.TInterfacedObject.QueryInterface.call(this,iid,obj);
      return Result;
    };
    rtl.addIntf(this,pas.System.IUnknown);
  });
  this.CreateVirtualCorbaInterface = function (InterfaceTypeInfo, MethodImplementation, IntfVar) {
    var IntfType = InterfaceTypeInfo.interface;
    var i = Object.create(IntfType);
    var o = { $name: "virtual", $fullname: "virtual" };
    i.$o = o;
    do {
      var names = IntfType.$names;
      if (!names) break;
      for (var j=0; j<names.length; j++){
        let fnname = names[j];
        i[fnname] = function(){ return MethodImplementation(fnname,arguments); };
      }
      IntfType = Object.getPrototypeOf(IntfType);
    } while(IntfType!=null);
    IntfVar.set(i);
  };
  this.Invoke = function (ACodeAddress, AArgs, ACallConv, AResultType, AIsStatic, AIsConstructor) {
    var Result = $mod.TValue.$new();
    if (ACallConv === pas.TypInfo.TCallConv.ccReg) ;
    if (AIsStatic) ;
    if (AIsConstructor) throw pas.JS.EJS.$create("Create$1",["not supported"]);
    if (rtl.isFunction(ACodeAddress)) {
      Result.FData = ACodeAddress.apply(null,AArgs);
      if (AResultType !== null) {
        Result.FTypeInfo = AResultType}
       else Result.FTypeInfo = rtl.jsvalue;
    } else throw pas.JS.EJS.$create("Create$1",[rtl.getResStr($mod,"SErrInvokeInvalidCodeAddr")]);
    return Result;
  };
  $mod.$resourcestrings = {SErrInvokeInvalidCodeAddr: {org: "CodeAddress is not a function"}, SErrTypeIsNotEnumerated: {org: "Type %s is not an enumerated type"}};
  $mod.$implcode = function () {
    rtl.createClass($impl,"TRttiPoolTypes",pas.System.TObject,function () {
      this.$init = function () {
        pas.System.TObject.$init.call(this);
        this.FReferenceCount = 0;
        this.FTypes = null;
      };
      this.$final = function () {
        this.FTypes = undefined;
        pas.System.TObject.$final.call(this);
      };
      this.Create$1 = function () {
        pas.System.TObject.Create.call(this);
        this.FTypes = new Object();
        return this;
      };
      this.Destroy = function () {
        var Key = "";
        var RttiObject = null;
        for (Key in this.FTypes) if (this.FTypes.hasOwnProperty(Key)) {
          RttiObject = rtl.getObject(this.FTypes[Key]);
          RttiObject = rtl.freeLoc(RttiObject);
        };
      };
      this.FindType = function (AQualifiedName) {
        var Result = null;
        var ModuleName = "";
        var TypeName = "";
        var Module = null;
        var TypeFound = null;
        if (this.FTypes.hasOwnProperty(AQualifiedName)) {
          Result = rtl.getObject(this.FTypes[AQualifiedName])}
         else {
          Result = null;
          for (var $in = Object.keys(pas), $l = 0, $end = rtl.length($in) - 1; $l <= $end; $l++) {
            ModuleName = $in[$l];
            if (pas.SysUtils.TStringHelper.StartsWith.call({get: function () {
                return AQualifiedName;
              }, set: function (v) {
                rtl.raiseE("EPropReadOnly");
              }},ModuleName + ".")) {
              Module = pas[ModuleName];
              TypeName = pas.System.Copy(AQualifiedName,ModuleName.length + 2,AQualifiedName.length);
              if (Module.$rtti.hasOwnProperty(TypeName)) {
                TypeFound = Module.$rtti[TypeName];
                return this.GetType(TypeFound);
              };
            };
          };
        };
        return Result;
      };
      this.GetType = function (ATypeInfo) {
        var Result = null;
        var RttiTypeClass = [null,$mod.TRttiOrdinalType,$mod.TRttiOrdinalType,$mod.TRttiType,$mod.TRttiEnumerationType,$mod.TRttiType,$mod.TRttiType,$mod.TRttiType,$mod.TRttiType,$mod.TRttiType,$mod.TRttiType,$mod.TRttiDynamicArrayType,$mod.TRttiRecordType,$mod.TRttiInstanceType,$mod.TRttiClassRefType,$mod.TRttiType,$mod.TRttiType,$mod.TRttiType,$mod.TRttiInterfaceType,$mod.TRttiType,$mod.TRttiInstanceExternalType];
        var Name = "";
        var Parent = null;
        if (pas.JS.isNull(ATypeInfo) || pas.JS.isUndefined(ATypeInfo)) return null;
        Name = ATypeInfo.name;
        if (rtl.isModule(ATypeInfo.$module)) Name = ATypeInfo.$module.$name + "." + Name;
        if (this.FTypes.hasOwnProperty(Name)) {
          Result = rtl.getObject(this.FTypes[Name])}
         else {
          if ((ATypeInfo.kind in rtl.createSet(pas.System.TTypeKind.tkClass,pas.System.TTypeKind.tkInterface,pas.System.TTypeKind.tkHelper,pas.System.TTypeKind.tkExtClass)) && ATypeInfo.hasOwnProperty("ancestor")) {
            Parent = this.GetType(ATypeInfo["ancestor"])}
           else Parent = null;
          Result = RttiTypeClass[ATypeInfo.kind].$create("Create$1",[Parent,ATypeInfo]);
          this.FTypes[Name] = Result;
        };
        return Result;
      };
      this.GetType$1 = function (AClass) {
        var Result = null;
        if (AClass === null) return null;
        Result = this.GetType(AClass.$rtti);
        return Result;
      };
      this.AcquireContext = function () {
        var Result = null;
        if (!($impl.Pool != null)) $impl.Pool = $impl.TRttiPoolTypes.$create("Create$1");
        Result = $impl.Pool.FTypes;
        $impl.Pool.FReferenceCount += 1;
        return Result;
      };
      this.ReleaseContext = function () {
        $impl.Pool.FReferenceCount -= 1;
        if ($impl.Pool.FReferenceCount === 0) pas.SysUtils.FreeAndNil({p: $impl, get: function () {
            return this.p.Pool;
          }, set: function (v) {
            this.p.Pool = v;
          }});
      };
    });
    $impl.Pool = null;
  };
},[]);
rtl.module("WEBLib.JSON",["System","Classes","Web","JS","SysUtils","RTTI"],function () {
  "use strict";
  var $mod = this;
  var $impl = $mod.$impl;
  this.$rtti.$Class("TJSONObject");
  this.$rtti.$Class("TJSONString");
  rtl.createClass(this,"TJSONAncestor",pas.System.TObject,function () {
    this.GetStrValue = function () {
      var Result = "";
      Result = "";
      return Result;
    };
    this.SetStrValue = function (Value) {
    };
  });
  rtl.createClass(this,"TJSONValue",this.TJSONAncestor,function () {
    this.$init = function () {
      $mod.TJSONAncestor.$init.call(this);
      this.fjv = undefined;
      this.fjo = undefined;
    };
    this.GetStrValue = function () {
      var Result = "";
      Result = "" + this.fjv;
      return Result;
    };
    this.JSONValueFromJS = function (AJSValue) {
      var Result = null;
      var d = 0.0;
      Result = null;
      if (rtl.isArray(AJSValue)) {
        Result = $mod.TJSONArray.$create("Create");
        rtl.as(Result,$mod.TJSONArray).fja = AJSValue;
      } else if (rtl.isObject(AJSValue)) {
        Result = $mod.TJSONObject.$create("Create$2");
        rtl.as(Result,$mod.TJSONObject).fjo$1 = AJSValue;
      } else if (rtl.isString(AJSValue)) {
        Result = $mod.TJSONString.$create("Create");
        rtl.as(Result,$mod.TJSONString).SetStrValue("" + AJSValue);
      } else if (rtl.isNumber(AJSValue)) {
        Result = $mod.TJSONNumber.$create("Create");
        rtl.as(Result,$mod.TJSONNumber).SetStrValue("" + AJSValue);
        d = rtl.getNumber(AJSValue);
        rtl.as(Result,$mod.TJSONNumber).FDouble = d;
        if (pas.System.Frac(d) === 0) rtl.as(Result,$mod.TJSONNumber).FInt = rtl.trunc(AJSValue);
      } else if (pas.JS.isNull(AJSValue)) {
        Result = $mod.TJSONNull.$create("Create")}
       else if (pas.JS.isBoolean(AJSValue)) {
        if (pas.JS.toBoolean(AJSValue)) {
          Result = $mod.TJSONTrue.$create("Create$3")}
         else Result = $mod.TJSONFalse.$create("Create$3");
      };
      if (!(Result != null)) Result = $mod.TJSONNull.$create("Create");
      Result.fjv = AJSValue;
      return Result;
    };
    this.Create$1 = function (AJSValue) {
      pas.System.TObject.Create.call(this);
      this.fjv = AJSValue;
      return this;
    };
    this.ToString = function () {
      var Result = "";
      Result = JSON.stringify(this.fjv);
      return Result;
    };
    this.GetJSValue = function () {
      var Result = undefined;
      Result = this.fjv;
      return Result;
    };
  });
  rtl.createClass(this,"TJSONPair",pas.System.TObject,function () {
    this.$init = function () {
      pas.System.TObject.$init.call(this);
      this.fjo = undefined;
      this.fjv = null;
      this.fjs = null;
    };
    this.$final = function () {
      this.fjv = undefined;
      this.fjs = undefined;
      pas.System.TObject.$final.call(this);
    };
    this.Create$1 = function () {
      pas.System.TObject.Create.call(this);
      this.fjs = $mod.TJSONString.$create("Create");
      return this;
    };
    this.Create$2 = function (Str, Value) {
      pas.System.TObject.Create.call(this);
      this.fjs = $mod.TJSONString.$create("Create$2",[Str]);
      this.fjv = Value;
      return this;
    };
    this.Create$3 = function (Str, Value) {
      pas.System.TObject.Create.call(this);
      this.fjs = $mod.TJSONString.$create("Create$2",[Str]);
      this.fjv = $mod.TJSONString.$create("Create$2",[Value]);
      return this;
    };
    this.Destroy = function () {
      rtl.free(this,"fjs");
      pas.System.TObject.Destroy.call(this);
    };
    this.ToString = function () {
      var Result = "";
      if ($mod.TJSONObject.isPrototypeOf(this.fjv)) {
        Result = '"' + this.fjs.GetStrValue() + '":' + rtl.as(this.fjv,$mod.TJSONObject).ToJSON()}
       else {
        if ((this.fjs !== null) && (this.fjv !== null)) {
          Result = '"' + this.fjs.GetStrValue() + '":' + this.fjv.ToString()}
         else Result = "";
      };
      return Result;
    };
  });
  rtl.createClass(this,"TJSONPairList",pas.Classes.TList,function () {
  });
  rtl.createClass(this,"TJSONObject",this.TJSONValue,function () {
    this.$init = function () {
      $mod.TJSONValue.$init.call(this);
      this.fjo$1 = null;
      this.FMembers = null;
    };
    this.$final = function () {
      this.fjo$1 = undefined;
      this.FMembers = undefined;
      $mod.TJSONValue.$final.call(this);
    };
    this.GetPair = function (I) {
      var Result = null;
      var v = null;
      var l = 0;
      var s = "";
      var jv = undefined;
      if ((this.FMembers.GetCount() === 0) && (this.fjo$1 != null) && (rtl.length(Object.keys(this.fjo$1)) > 0)) {
        l = rtl.length(Object.keys(this.fjo$1));
        if (I < l) {
          jv = this.fjo$1[Object.keys(this.fjo$1)[I]];
          v = this.$class.JSONValueFromJS(jv);
          s = Object.keys(this.fjo$1)[I];
          Result = $mod.TJSONPair.$create("Create$2",[s,v]);
          return Result;
        };
      };
      if ((I >= 0) && (I < this.FMembers.GetCount())) {
        Result = rtl.getObject(this.FMembers.Get(I))}
       else Result = null;
      return Result;
    };
    this.GetCount = function () {
      var Result = 0;
      if (this.fjo$1 != null) {
        Result = rtl.length(Object.keys(this.fjo$1))}
       else if (this.FMembers != null) {
        Result = this.FMembers.GetCount()}
       else Result = 0;
      return Result;
    };
    this.GetItem = function (Index) {
      var Result = null;
      var jv = undefined;
      jv = this.fjo$1[Object.keys(this.fjo$1)[Index]];
      Result = this.$class.JSONValueFromJS(jv);
      return Result;
    };
    this.SetValues = function (Name, Value) {
      var O = null;
      O = this.fjo$1;
      O[Name] = Value;
    };
    this.AddDescendant = function (Descendent) {
      this.FMembers.Add(Descendent);
    };
    this.Create$2 = function () {
      pas.System.TObject.Create.call(this);
      this.FMembers = $mod.TJSONPairList.$create("Create$1");
      this.fjo$1 = null;
      return this;
    };
    this.Create$3 = function (AObject) {
      pas.System.TObject.Create.call(this);
      this.FMembers = $mod.TJSONPairList.$create("Create$1");
      this.fjo$1 = AObject;
      return this;
    };
    this.Destroy = function () {
      rtl.free(this,"FMembers");
      pas.System.TObject.Destroy.call(this);
    };
    this.ParseJSONValue = function (data) {
      var Result = null;
      var O = null;
      O = JSON.parse(data);
      Result = this.JSONValueFromJS(O);
      return Result;
    };
    this.GetJSONValue = function (Name) {
      var Result = "";
      var jv = undefined;
      jv = this.fjo$1[Name];
      Result = $impl.JSONObjectToString(jv);
      return Result;
    };
    this.Get = function (Name) {
      var Result = null;
      var jv = undefined;
      var jsv = null;
      var i = 0;
      var p = null;
      Result = null;
      if (this.fjo$1 != null) {
        jv = this.fjo$1[Name];
        if ((jv != undefined) || (jv === null)) {
          Result = $mod.TJSONPair.$create("Create$1");
          jsv = this.$class.JSONValueFromJS(jv);
          Result.fjo = this.fjo$1;
          Result.fjs.SetStrValue(Name);
          Result.fjv = jsv;
        };
      } else {
        for (var $l = 0, $end = this.FMembers.GetCount() - 1; $l <= $end; $l++) {
          i = $l;
          p = rtl.getObject(this.FMembers.Get(i));
          if (p.fjs.ToString() === ('"' + Name + '"')) Result = p;
        };
      };
      return Result;
    };
    this.Get$1 = function (Index) {
      var Result = null;
      Result = this.Get(Object.keys(this.fjo$1)[Index]);
      return Result;
    };
    this.GetValue$1 = function (Name) {
      var Result = null;
      var jp = null;
      Result = null;
      jp = this.Get(Name);
      if (jp != null) {
        Result = jp.fjv;
        Result.fjo = jp.fjo;
      };
      return Result;
    };
    this.GetObjectValue = function (APath) {
      var Result = null;
      Result = this.GetValue$1(APath);
      return Result;
    };
    this.SetValue = function (Name, AValue) {
      var O = null;
      O = this.fjo$1;
      O[Name] = AValue;
    };
    this.SetValue$1 = function (Name, AValue) {
      var O = null;
      O = this.fjo$1;
      O[Name] = AValue;
    };
    this.SetValue$2 = function (Name, AValue) {
      var O = null;
      O = this.fjo$1;
      O[Name] = AValue;
    };
    this.AddPair = function (Pair) {
      var Result = null;
      var o = null;
      if (Pair != null) {
        this.AddDescendant(Pair);
        if (this.fjo$1 != null) {
          o = this.fjo$1;
          if ($mod.TJSONArray.isPrototypeOf(Pair.fjv)) {
            o[Pair.fjs.FValue] = Pair.fjv.fja;
          } else {
            o[Pair.fjs.FValue] = Pair.fjv.fjv;
          };
        };
      };
      Result = this;
      return Result;
    };
    this.AddPair$1 = function (Str, Val) {
      var Result = null;
      this.AddPair($mod.TJSONPair.$create("Create$2",[Str,Val]));
      Result = this;
      return Result;
    };
    this.AddPair$2 = function (Str, Val) {
      var Result = null;
      this.AddPair($mod.TJSONPair.$create("Create$3",[Str,Val]));
      Result = this;
      return Result;
    };
    this.AddPair$3 = function (Str, Val) {
      var Result = null;
      this.AddPair($mod.TJSONPair.$create("Create$2",[Str,$mod.TJSONNumber.$create("Create$3",[Val])]));
      Result = this;
      return Result;
    };
    this.AddPair$4 = function (Str, Val) {
      var Result = null;
      this.AddPair($mod.TJSONPair.$create("Create$2",[Str,$mod.TJSONNumber.$create("Create$4",[Val])]));
      Result = this;
      return Result;
    };
    this.AddPair$5 = function (Str, Val) {
      var Result = null;
      this.AddPair($mod.TJSONPair.$create("Create$2",[Str,$mod.TJSONNumber.$create("Create$5",[Val])]));
      Result = this;
      return Result;
    };
    this.AddPair$6 = function (Str, Val) {
      var Result = null;
      this.AddPair($mod.TJSONPair.$create("Create$2",[Str,$mod.TJSONBool.$create("Create$2",[Val])]));
      Result = this;
      return Result;
    };
    this.RemovePair = function (PairName) {
      var Result = null;
      var o = null;
      var p = null;
      var i = 0;
      Result = null;
      if (this.fjo$1 != null) {
        o = this.fjo$1;
        delete o[PairName];
      } else {
        for (var $l = 0, $end = this.FMembers.GetCount() - 1; $l <= $end; $l++) {
          i = $l;
          p = rtl.getObject(this.FMembers.Get(i));
          if (p.fjs.ToString() === ('"' + PairName + '"')) {
            Result = p;
            this.FMembers.Delete(i);
            break;
          };
        };
      };
      return Result;
    };
    this.ToJSON = function () {
      var Result = "";
      var s = "";
      var Size = 0;
      var I = 0;
      var jp = null;
      if (this.fjo$1 != null) {
        Size = this.GetCount()}
       else Size = this.FMembers.GetCount();
      s = "{";
      if (Size > 0) {
        if (this.fjo$1 != null) {
          jp = this.Get$1(0);
          if (jp != null) {
            s = s + jp.ToString()}
           else s = s + '"' + Object.keys(this.fjo$1)[0] + '":null';
        } else s = s + rtl.getObject(this.FMembers.Get(0)).ToString();
      };
      for (var $l = 1, $end = Size - 1; $l <= $end; $l++) {
        I = $l;
        if (this.fjo$1 != null) {
          jp = this.Get$1(I);
          if (jp != null) {
            s = s + "," + jp.ToString()}
           else s = s + "," + '"' + Object.keys(this.fjo$1)[I] + '":null';
        } else s = s + "," + rtl.getObject(this.FMembers.Get(I)).ToString();
      };
      s = s + "}";
      Result = s;
      return Result;
    };
    this.ToString = function () {
      var Result = "";
      Result = this.ToJSON();
      return Result;
    };
  });
  rtl.createClass(this,"TJSONString",this.TJSONValue,function () {
    this.$init = function () {
      $mod.TJSONValue.$init.call(this);
      this.FValue = "";
    };
    this.GetStrValue = function () {
      var Result = "";
      Result = this.FValue;
      return Result;
    };
    this.SetStrValue = function (Value) {
      this.FValue = Value;
      this.fjv = Value;
      if (pas.System.Assigned(this.fjo)) {
        var s = Object.keys(this.fjo)[0];
        this.fjo[s] = Value;
      };
    };
    this.Create$2 = function (AString) {
      pas.System.TObject.Create.call(this);
      this.fjv = AString;
      this.FValue = AString;
      return this;
    };
  });
  rtl.createClass(this,"TJSONNumber",this.TJSONString,function () {
    this.$init = function () {
      $mod.TJSONString.$init.call(this);
      this.FInt = 0;
      this.FInt64 = 0;
      this.FDouble = 0.0;
    };
    this.GetStrValue = function () {
      var Result = "";
      Result = pas.SysUtils.FloatToStr$1(this.FDouble,pas.SysUtils.TFormatSettings.Invariant());
      return Result;
    };
    this.SetStrValue = function (Value) {
      this.FDouble = pas.SysUtils.StrToFloat$1(Value,pas.SysUtils.TFormatSettings.Invariant());
      if (pas.System.Frac(this.FDouble) === 0) {
        if (!pas.SysUtils.TryStrToInt64$1(Value,{p: this, get: function () {
            return this.p.FInt64;
          }, set: function (v) {
            this.p.FInt64 = v;
          }},pas.SysUtils.TFormatSettings.Invariant())) this.FInt64 = 0;
        this.FInt = this.FInt64;
        this.fjv = this.FInt64;
      } else this.fjv = this.FDouble;
    };
    this.Create$3 = function (ANumber) {
      pas.System.TObject.Create.call(this);
      this.fjv = ANumber;
      this.FInt = ANumber;
      this.FInt64 = ANumber;
      this.FDouble = ANumber;
      return this;
    };
    this.Create$4 = function (ANumber) {
      pas.System.TObject.Create.call(this);
      this.fjv = ANumber;
      this.FInt = ANumber & 0xFFFFFFFF;
      this.FInt64 = ANumber;
      this.FDouble = ANumber;
      return this;
    };
    this.Create$5 = function (ANumber) {
      pas.System.TObject.Create.call(this);
      this.fjv = ANumber;
      this.FInt = pas.System.Trunc(ANumber);
      this.FInt64 = pas.System.Trunc(ANumber);
      this.FDouble = ANumber;
      return this;
    };
  });
  rtl.createClass(this,"TJSONBool",this.TJSONValue,function () {
    this.$init = function () {
      $mod.TJSONValue.$init.call(this);
      this.FBool = false;
    };
    this.SetStrValue = function (Value) {
      var s = "";
      s = pas.SysUtils.UpperCase(Value);
      this.FBool = s === "TRUE";
    };
    this.Create$2 = function (AValue) {
      $mod.TJSONValue.Create$1.call(this,AValue);
      this.FBool = AValue;
      return this;
    };
  });
  rtl.createClass(this,"TJSONTrue",this.TJSONBool,function () {
    this.GetStrValue = function () {
      var Result = "";
      Result = "true";
      return Result;
    };
    this.Create$3 = function () {
      $mod.TJSONBool.Create$2.call(this,true);
      return this;
    };
    this.ToString = function () {
      var Result = "";
      Result = this.GetStrValue();
      return Result;
    };
  });
  rtl.createClass(this,"TJSONFalse",this.TJSONBool,function () {
    this.GetStrValue = function () {
      var Result = "";
      Result = "false";
      return Result;
    };
    this.Create$3 = function () {
      $mod.TJSONBool.Create$2.call(this,false);
      return this;
    };
    this.ToString = function () {
      var Result = "";
      Result = this.GetStrValue();
      return Result;
    };
  });
  rtl.createClass(this,"TJSONNull",this.TJSONValue,function () {
    this.GetStrValue = function () {
      var Result = "";
      Result = "null";
      return Result;
    };
    this.ToString = function () {
      var Result = "";
      Result = this.GetStrValue();
      return Result;
    };
  });
  this.$rtti.$Class("TJSONArray");
  rtl.createClass(this,"TJSONArrayEnumerator",pas.System.TObject,function () {
    this.$init = function () {
      pas.System.TObject.$init.call(this);
      this.FJSONArray = null;
      this.FPosition = 0;
    };
    this.$final = function () {
      this.FJSONArray = undefined;
      pas.System.TObject.$final.call(this);
    };
    this.Create$1 = function (AJSONArray) {
      pas.System.TObject.Create.call(this);
      this.FJSONArray = AJSONArray;
      this.FPosition = -1;
      return this;
    };
    this.GetCurrent = function () {
      var Result = null;
      Result = this.FJSONArray.GetItem(this.FPosition);
      return Result;
    };
    this.MoveNext = function () {
      var Result = false;
      this.FPosition += 1;
      Result = this.FPosition < this.FJSONArray.GetCount();
      return Result;
    };
  });
  rtl.createClass(this,"TJSONArray",this.TJSONValue,function () {
    this.$init = function () {
      $mod.TJSONValue.$init.call(this);
      this.fja = null;
    };
    this.$final = function () {
      this.fja = undefined;
      $mod.TJSONValue.$final.call(this);
    };
    this.GetItem = function (index) {
      var Result = null;
      var jv = undefined;
      jv = this.GetJA()[index];
      if (rtl.isExt(jv,$mod.TJSONObject,1) || rtl.isExt(jv,$mod.TJSONArray,1)) {
        Result = rtl.getObject(jv)}
       else Result = this.$class.JSONValueFromJS(jv);
      return Result;
    };
    this.SetItem = function (index, Value) {
      if ($mod.TJSONObject.isPrototypeOf(Value)) this.GetJA()[index] = Value.fjo$1;
    };
    this.GetCount = function () {
      var Result = 0;
      Result = this.GetJA().length;
      return Result;
    };
    this.GetJA = function () {
      var Result = null;
      if (!(this.fja != null)) this.fja = new Array();
      Result = this.fja;
      return Result;
    };
    this.Create$2 = function (AArray) {
      pas.System.TObject.Create.call(this);
      this.fja = AArray;
      return this;
    };
    this.GetEnumerator = function () {
      var Result = null;
      Result = $mod.TJSONArrayEnumerator.$create("Create$1",[this]);
      return Result;
    };
    this.Add = function (Element) {
      this.GetJA().push(Element);
    };
    this.Add$1 = function (Element) {
      this.GetJA().push(Element);
    };
    this.Add$2 = function (Element) {
      this.GetJA().push(Element);
    };
    this.Add$3 = function (Element) {
      this.GetJA().push(Element);
    };
    this.Add$4 = function (Element) {
      this.GetJA().push(Element);
    };
    this.Add$5 = function (Element) {
      this.GetJA().push(Element);
    };
    this.Add$6 = function (Element) {
      this.GetJA().push(Element);
    };
    this.AddElement = function (Element) {
      this.GetJA().push(Element);
    };
    this.ToJSON = function () {
      var Result = "";
      Result = this.ToString();
      return Result;
    };
    this.ToString = function () {
      var Result = "";
      var i = 0;
      var jv = null;
      var comma = "";
      Result = "[";
      comma = "";
      for (var $l = 0, $end = this.GetCount() - 1; $l <= $end; $l++) {
        i = $l;
        jv = this.GetItem(i);
        if (jv != null) {
          if ($mod.TJSONObject.isPrototypeOf(jv)) {
            Result = Result + comma + rtl.as(jv,$mod.TJSONObject).ToString();
          } else Result = Result + comma + jv.ToString();
          comma = ",";
        };
      };
      Result = Result + "]";
      return Result;
    };
  });
  rtl.createClass(this,"TJSON",pas.System.TObject,function () {
    this.Parse = function (s) {
      var Result = null;
      var O = null;
      O = JSON.parse(s);
      if (rtl.isArray(O)) {
        Result = $mod.TJSONArray.$create("Create$2",[O]);
      } else {
        Result = $mod.TJSONObject.$create("Create$3",[O]);
      };
      return Result;
    };
  });
  $mod.$implcode = function () {
    $impl.JSONObjectToString = function (v) {
      return v+"";
    };
  };
},["TypInfo"]);
rtl.module("WEBLib.Storage",["System","Web","Classes"],function () {
  "use strict";
  var $mod = this;
  this.$rtti.$MethodVar("TStorageChangeEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["AKey",rtl.string],["AOldValue",rtl.string],["ANewValue",rtl.string],["AURL",rtl.string]]), methodkind: 0});
  rtl.createClass(this,"TLocalStorage",pas.Classes.TComponent,function () {
    this.$init = function () {
      pas.Classes.TComponent.$init.call(this);
      this.FChangePtr = null;
      this.FOnChange = null;
    };
    this.$final = function () {
      this.FOnChange = undefined;
      pas.Classes.TComponent.$final.call(this);
    };
    this.SetValues = function (AKey, AValue) {
      window.localStorage.setItem(AKey,AValue);
    };
    this.GetValues = function (AKey) {
      var Result = "";
      var s = "";
      s = window.localStorage.getItem(AKey);
      if (!pas.System.Assigned(s)) {
        Result = ""}
       else Result = s;
      return Result;
    };
    this.GetKey = function (AIndex) {
      var Result = "";
      Result = window.localStorage.key(AIndex);
      return Result;
    };
    this.GetCount = function () {
      var Result = 0;
      Result = window.localStorage.length;
      return Result;
    };
    this.StorageChanged = function (AEvent) {
      var s = "";
      s = AEvent.storageArea + " ";
      if ((this.FOnChange != null) && (pas.System.Pos("OBJECT",pas.SysUtils.UpperCase(s)) > 0)) this.FOnChange(this,AEvent.key,AEvent.oldValue,AEvent.newValue,AEvent.url);
    };
    this.Create$1 = function (AOwner) {
      this.FChangePtr = rtl.createCallback(this,"StorageChanged");
      pas.Classes.TComponent.Create$1.apply(this,arguments);
      window.addEventListener("storage",this.FChangePtr);
      return this;
    };
    this.Destroy = function () {
      window.removeEventListener("storage",this.FChangePtr);
      pas.Classes.TComponent.Destroy.call(this);
    };
    this.Clear = function () {
      window.sessionStorage.clear();
    };
    this.SetValue = function (AKey, AValue) {
      window.localStorage.setItem(AKey,AValue);
    };
    this.GetValue = function (AKey) {
      var Result = "";
      var s = "";
      s = window.localStorage.getItem(AKey);
      if (!pas.System.Assigned(s)) {
        Result = ""}
       else Result = s;
      return Result;
    };
    this.RemoveKey = function (AKey) {
      window.localStorage.removeItem(AKey);
    };
    rtl.addIntf(this,pas.System.IUnknown);
    var $r = this.$rtti;
    $r.addMethod("Create$1",2,[["AOwner",pas.Classes.$rtti["TComponent"]]]);
    $r.addProperty("OnChange",0,$mod.$rtti["TStorageChangeEvent"],"FOnChange","FOnChange");
  });
  rtl.createClass(this,"TWebLocalStorage",this.TLocalStorage,function () {
    rtl.addIntf(this,pas.System.IUnknown);
  });
  rtl.createClass(this,"TSessionStorage",pas.Classes.TComponent,function () {
    this.$init = function () {
      pas.Classes.TComponent.$init.call(this);
      this.FChangePtr = null;
      this.FOnChange = null;
    };
    this.$final = function () {
      this.FOnChange = undefined;
      pas.Classes.TComponent.$final.call(this);
    };
    this.SetValues = function (AKey, AValue) {
      window.sessionStorage.setItem(AKey,AValue);
    };
    this.GetValues = function (AKey) {
      var Result = "";
      var s = "";
      s = window.sessionStorage.getItem(AKey);
      if (!pas.System.Assigned(s)) {
        Result = ""}
       else Result = s;
      return Result;
    };
    this.GetKey = function (AIndex) {
      var Result = "";
      Result = window.sessionStorage.key(AIndex);
      return Result;
    };
    this.GetCount = function () {
      var Result = 0;
      Result = window.sessionStorage.length;
      return Result;
    };
    this.StorageChanged = function (AEvent) {
      var s = "";
      s = AEvent.storageArea + " ";
      if ((this.FOnChange != null) && (pas.System.Pos("OBJECT",pas.SysUtils.UpperCase(s)) === 0)) this.FOnChange(this,AEvent.key,AEvent.oldValue,AEvent.newValue,AEvent.url);
    };
    this.Create$1 = function (AOwner) {
      this.FChangePtr = rtl.createCallback(this,"StorageChanged");
      pas.Classes.TComponent.Create$1.apply(this,arguments);
      window.addEventListener("storage",this.FChangePtr);
      return this;
    };
    this.Destroy = function () {
      window.removeEventListener("storage",this.FChangePtr);
      pas.Classes.TComponent.Destroy.call(this);
    };
    this.Clear = function () {
      window.sessionStorage.clear();
    };
    this.SetValue = function (AKey, AValue) {
      window.sessionStorage.setItem(AKey,AValue);
    };
    this.GetValue = function (AKey) {
      var Result = "";
      var s = "";
      s = window.sessionStorage.getItem(AKey);
      if (!pas.System.Assigned(s)) {
        Result = ""}
       else Result = s;
      return Result;
    };
    this.RemoveKey = function (AKey) {
      window.sessionStorage.removeItem(AKey);
    };
    rtl.addIntf(this,pas.System.IUnknown);
    var $r = this.$rtti;
    $r.addMethod("Create$1",2,[["AOwner",pas.Classes.$rtti["TComponent"]]]);
    $r.addProperty("OnChange",0,$mod.$rtti["TStorageChangeEvent"],"FOnChange","FOnChange");
  });
  rtl.createClass(this,"TWebSessionStorage",this.TSessionStorage,function () {
    rtl.addIntf(this,pas.System.IUnknown);
  });
},["SysUtils"]);
rtl.module("WEBLib.REST",["System","Classes","Web","JS","SysUtils","WEBLib.Controls","WEBLib.JSON"],function () {
  "use strict";
  var $mod = this;
  var $impl = $mod.$impl;
  this.ContentTypeJSON = "application/json;charset=UTF-8";
  this.ContentTypeForm = "application/x-www-form-urlencoded";
  this.THTTPCommand = {"0": "httpGET", httpGET: 0, "1": "httpPOST", httpPOST: 1, "2": "httpPUT", httpPUT: 2, "3": "httpDELETE", httpDELETE: 3, "4": "httpHEAD", httpHEAD: 4, "5": "httpPATCH", httpPATCH: 5, "6": "httpCUSTOM", httpCUSTOM: 6};
  this.$rtti.$Enum("THTTPCommand",{minvalue: 0, maxvalue: 6, ordtype: 1, enumtype: this.THTTPCommand});
  this.THTTPRequestResponseType = {"0": "rtDefault", rtDefault: 0, "1": "rtText", rtText: 1, "2": "rtBlob", rtBlob: 2, "3": "rtJSON", rtJSON: 3, "4": "rtDocument", rtDocument: 4, "5": "rtArrayBuffer", rtArrayBuffer: 5};
  this.$rtti.$Enum("THTTPRequestResponseType",{minvalue: 0, maxvalue: 5, ordtype: 1, enumtype: this.THTTPRequestResponseType});
  this.$rtti.$RefToProcVar("THTTPResponseProc",{procsig: rtl.newTIProcSig([["AResponse",rtl.string],["ARequest",pas.Web.$rtti["TJSXMLHttpRequest"]]])});
  this.$rtti.$RefToProcVar("THTTPErrorProc",{procsig: rtl.newTIProcSig([["ARequest",pas.Web.$rtti["TJSXMLHttpRequest"]]])});
  this.$rtti.$RefToProcVar("THTTPRequestHandler",{procsig: rtl.newTIProcSig([["Event",pas.Web.$rtti["TJSEvent"]]])});
  this.$rtti.$MethodVar("THTTPProgressEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["Position",rtl.nativeint],["Total",rtl.nativeint]]), methodkind: 0});
  rtl.createClass(this,"THttpRequest",pas.Classes.TComponent,function () {
    this.$init = function () {
      pas.Classes.TComponent.$init.call(this);
      this.FURL = "";
      this.FOnResponse = null;
      this.FOnAbort = null;
      this.FHeaders = null;
      this.FCommand = 0;
      this.FCustomCommand = "";
      this.FWithCredentials = false;
      this.FPostData = "";
      this.FOnRequestResponse = null;
      this.FPassword = "";
      this.FUser = "";
      this.FTimeout = 0;
      this.FOnTimeout = null;
      this.FOnError = null;
      this.FResponse = null;
      this.FErrorProc = null;
      this.FTimeOutProc = null;
      this.FResponseType = 0;
      this.FOnProgress = null;
    };
    this.$final = function () {
      this.FOnResponse = undefined;
      this.FOnAbort = undefined;
      this.FHeaders = undefined;
      this.FOnRequestResponse = undefined;
      this.FOnTimeout = undefined;
      this.FOnError = undefined;
      this.FResponse = undefined;
      this.FErrorProc = undefined;
      this.FTimeOutProc = undefined;
      this.FOnProgress = undefined;
      pas.Classes.TComponent.$final.call(this);
    };
    this.HandleResponse = function (Event) {
      var Result = false;
      var s = "";
      var LRequestRec = pas["WEBLib.Controls"].TJSXMLHttpRequestRecord.$new();
      LRequestRec.req = Event.target;
      s = "";
      if (this.FResponseType in rtl.createSet($mod.THTTPRequestResponseType.rtText,$mod.THTTPRequestResponseType.rtDefault)) {
        s = Event.target.responseText;
      };
      if (this.FOnRequestResponse != null) {
        this.FOnRequestResponse(this,pas["WEBLib.Controls"].TJSXMLHttpRequestRecord.$clone(LRequestRec),s);
      };
      if (this.FOnResponse != null) this.FOnResponse(this,s);
      if (this.FResponse != null) {
        this.FResponse(s,LRequestRec.req);
      };
      Result = true;
      return Result;
    };
    this.HandleAbort = function (Event) {
      var Result = false;
      if (this.FOnAbort != null) this.FOnAbort(this);
      Result = true;
      return Result;
    };
    this.HandleTimeout = function (Event) {
      var Result = false;
      if (this.FOnTimeout != null) this.FOnTimeout(this);
      if (this.FTimeOutProc != null) this.FTimeOutProc(Event.target);
      Result = true;
      return Result;
    };
    this.HandleError = function (Event) {
      var Result = false;
      var Handled = false;
      var LEventRec = pas["WEBLib.Controls"].TJSEventRecord.$new();
      var LRequestRec = pas["WEBLib.Controls"].TJSXMLHttpRequestRecord.$new();
      Result = true;
      Handled = false;
      if (this.FOnError != null) {
        LEventRec.event = Event;
        LRequestRec.req = Event.target;
        this.FOnError(this,pas["WEBLib.Controls"].TJSXMLHttpRequestRecord.$clone(LRequestRec),pas["WEBLib.Controls"].TJSEventRecord.$clone(LEventRec),{get: function () {
            return Handled;
          }, set: function (v) {
            Handled = v;
          }});
      };
      if (this.FErrorProc != null) this.FErrorProc(LRequestRec.req);
      if (!Handled) throw pas.SysUtils.Exception.$create("Create$1",["HTTP request error @" + this.FURL]);
      return Result;
    };
    this.HandleProgress = function (Event) {
      var Result = false;
      var position = 0;
      var total = 0;
      Result = true;
      position = Event.loaded;
      total = Event.total;
      if (this.FOnProgress != null) this.FOnProgress(this,position,total);
      return Result;
    };
    this.HandleReadyStateChange = function (Event) {
      var Result = false;
      var LRequestRec = pas["WEBLib.Controls"].TJSXMLHttpRequestRecord.$new();
      var sz = "";
      Result = true;
      LRequestRec.req = Event.target;
      if (LRequestRec.req.readyState === 4) {
        if ((LRequestRec.req.status >= 200) && (LRequestRec.req.status < 300)) {
          sz = LRequestRec.req.getResponseHeader("Content-Length");
          if (this.FResponse != null) {
            this.FResponse(sz,LRequestRec.req);
          };
        } else if (this.FErrorProc != null) this.FErrorProc(LRequestRec.req);
      };
      return Result;
    };
    this.SetHeaders = function (AValue) {
      this.FHeaders.Assign(AValue);
    };
    this.Create$1 = function (AOwner) {
      pas.Classes.TComponent.Create$1.apply(this,arguments);
      this.FHeaders = pas.Classes.TStringList.$create("Create$1");
      this.FResponseType = $mod.THTTPRequestResponseType.rtDefault;
      this.FCommand = $mod.THTTPCommand.httpGET;
      this.FTimeout = 0;
      this.FResponse = null;
      this.FWithCredentials = false;
      return this;
    };
    this.Destroy = function () {
      rtl.free(this,"FHeaders");
      pas.Classes.TComponent.Destroy.call(this);
    };
    this.Loaded = function () {
      var i = 0;
      var j = 0;
      var s = "";
      var flg = false;
      pas.Classes.TComponent.Loaded.call(this);
      for (var $l = 0, $end = this.FHeaders.GetCount() - 1; $l <= $end; $l++) {
        i = $l;
        s = this.FHeaders.Get(i);
        flg = false;
        for (var $l1 = 1, $end1 = s.length; $l1 <= $end1; $l1++) {
          j = $l1;
          if ((s.charAt(j - 1) === ":") && !flg) {
            s = rtl.setCharAt(s,j - 1,"=");
            flg = true;
          } else if ((s.charAt(j - 1) === "=") && flg) {
            s = rtl.setCharAt(s,j - 1,":");
          };
        };
        this.FHeaders.Put(i,s);
      };
    };
    this.GetResponseType = function (AResponseType) {
      var Result = "";
      Result = "";
      var $tmp = AResponseType;
      if ($tmp === $mod.THTTPRequestResponseType.rtText) {
        Result = "text"}
       else if ($tmp === $mod.THTTPRequestResponseType.rtBlob) {
        Result = "blob"}
       else if ($tmp === $mod.THTTPRequestResponseType.rtDocument) {
        Result = "document"}
       else if ($tmp === $mod.THTTPRequestResponseType.rtJSON) {
        Result = "json"}
       else if ($tmp === $mod.THTTPRequestResponseType.rtArrayBuffer) Result = "arraybuffer";
      return Result;
    };
    this.ExecuteSizeRequest = function (AResponse, AError, ATimeOut) {
      var i = 0;
      var req = null;
      var headname = "";
      var headvalue = "";
      this.FResponse = AResponse;
      this.FErrorProc = AError;
      this.FTimeOutProc = ATimeOut;
      req = new XMLHttpRequest();
      req.addEventListener("readystatechange",rtl.createSafeCallback(this,"HandleReadyStateChange"));
      req.addEventListener("timeout",rtl.createSafeCallback(this,"HandleTimeout"));
      req.addEventListener("error",rtl.createSafeCallback(this,"HandleError"));
      req.withCredentials = this.FWithCredentials;
      if (this.FTimeout !== 0) req.timeout = this.FTimeout;
      if (this.FUser !== "") {
        req.open("HEAD",this.FURL,true,this.FUser,this.FPassword);
        req.setRequestHeader("X-Requested-With","XMLHttpRequest");
      } else req.open("HEAD",this.FURL);
      for (var $l = 0, $end = this.FHeaders.GetCount() - 1; $l <= $end; $l++) {
        i = $l;
        this.FHeaders.GetNameValue(i,{get: function () {
            return headname;
          }, set: function (v) {
            headname = v;
          }},{get: function () {
            return headvalue;
          }, set: function (v) {
            headvalue = v;
          }});
        req.setRequestHeader(headname,headvalue);
      };
      if (this.FUser !== "") req.setRequestHeader("Authorization","Basic " + window.btoa(this.FUser + ":" + this.FPassword));
      req.send();
    };
    this.Execute = function (AResponse) {
      this.Execute$2(AResponse,null,null);
    };
    this.Execute$1 = function (AResponse, AError) {
      this.Execute$2(AResponse,AError,null);
    };
    this.Execute$2 = function (AResponse, AError, ATimeOut) {
      var i = 0;
      var cmd = "";
      var req = null;
      var headname = "";
      var headvalue = "";
      this.FResponse = AResponse;
      this.FErrorProc = AError;
      this.FTimeOutProc = ATimeOut;
      req = new XMLHttpRequest();
      req.addEventListener("load",rtl.createSafeCallback(this,"HandleResponse"));
      req.addEventListener("abort",rtl.createSafeCallback(this,"HandleAbort"));
      req.addEventListener("timeout",rtl.createSafeCallback(this,"HandleTimeout"));
      req.addEventListener("error",rtl.createSafeCallback(this,"HandleError"));
      req.addEventListener("progress",rtl.createSafeCallback(this,"HandleProgress"));
      req.responseType = $mod.THttpRequest.GetResponseType(this.FResponseType);
      req.withCredentials = this.FWithCredentials;
      cmd = $mod.HTTPCommand(this.FCommand,this.FCustomCommand);
      if (this.FTimeout !== 0) req.timeout = this.FTimeout;
      if (this.FUser !== "") {
        req.open(cmd,this.FURL,true);
        req.setRequestHeader("X-Requested-With","XMLHttpRequest");
      } else req.open(cmd,this.FURL);
      for (var $l = 0, $end = this.FHeaders.GetCount() - 1; $l <= $end; $l++) {
        i = $l;
        this.FHeaders.GetNameValue(i,{get: function () {
            return headname;
          }, set: function (v) {
            headname = v;
          }},{get: function () {
            return headvalue;
          }, set: function (v) {
            headvalue = v;
          }});
        req.setRequestHeader(headname,headvalue);
      };
      if (this.FUser !== "") req.setRequestHeader("Authorization","Basic " + window.btoa(this.FUser + ":" + this.FPassword));
      if (this.FPostData !== "") {
        req.send(this.FPostData)}
       else req.send();
    };
    this.GetSize = function () {
      var $Self = this;
      var Result = null;
      var sz = 0;
      var e = 0;
      Result = new Promise(function (ASuccess, AFailed) {
        $Self.ExecuteSizeRequest(function (AResponse, ARequest) {
          pas.System.val(AResponse,{get: function () {
              return sz;
            }, set: function (v) {
              sz = v;
            }},{get: function () {
              return e;
            }, set: function (v) {
              e = v;
            }});
          ASuccess(sz);
        },function (ARequest) {
          AFailed(0);
        },function (ARequest) {
          AFailed(ARequest);
        });
      });
      return Result;
    };
    this.Perform = function () {
      var $Self = this;
      var Result = null;
      Result = new Promise(function (ASuccess, AFailed) {
        $Self.Execute$2(function (AResponse, ARequest) {
          ASuccess(ARequest);
        },function (ARequest) {
          AFailed(ARequest);
        },function (ARequest) {
          AFailed(ARequest);
        });
      });
      return Result;
    };
    rtl.addIntf(this,pas.System.IUnknown);
    var $r = this.$rtti;
    $r.addMethod("Create$1",2,[["AOwner",pas.Classes.$rtti["TComponent"]]]);
    $r.addProperty("Command",0,$mod.$rtti["THTTPCommand"],"FCommand","FCommand");
    $r.addProperty("CustomCommand",0,rtl.string,"FCustomCommand","FCustomCommand");
    $r.addProperty("Headers",2,pas.Classes.$rtti["TStringList"],"FHeaders","SetHeaders");
    $r.addProperty("Password",0,rtl.string,"FPassword","FPassword");
    $r.addProperty("PostData",0,rtl.string,"FPostData","FPostData");
    $r.addProperty("ResponseType",0,$mod.$rtti["THTTPRequestResponseType"],"FResponseType","FResponseType",{Default: $mod.THTTPRequestResponseType.rtDefault});
    $r.addProperty("Timeout",0,rtl.longint,"FTimeout","FTimeout",{Default: 0});
    $r.addProperty("URL",0,rtl.string,"FURL","FURL");
    $r.addProperty("User",0,rtl.string,"FUser","FUser");
    $r.addProperty("WithCredentials",0,rtl.boolean,"FWithCredentials","FWithCredentials",{Default: false});
    $r.addProperty("OnError",0,pas["WEBLib.Controls"].$rtti["THTTPErrorEvent"],"FOnError","FOnError");
    $r.addProperty("OnAbort",0,pas["WEBLib.Controls"].$rtti["THTTPAbortEvent"],"FOnAbort","FOnAbort");
    $r.addProperty("OnProgress",0,$mod.$rtti["THTTPProgressEvent"],"FOnProgress","FOnProgress");
    $r.addProperty("OnRequestResponse",0,pas["WEBLib.Controls"].$rtti["THTTPRequestResponseEvent"],"FOnRequestResponse","FOnRequestResponse");
    $r.addProperty("OnResponse",0,pas["WEBLib.Controls"].$rtti["THTTPResponseEvent"],"FOnResponse","FOnResponse");
    $r.addProperty("OnTimeout",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnTimeout","FOnTimeout");
  });
  rtl.createClass(this,"TWebHTTPRequest",this.THttpRequest,function () {
    rtl.addIntf(this,pas.System.IUnknown);
  });
  this.$rtti.$MethodVar("THttpResponse",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["AResponse",rtl.string]]), methodkind: 0});
  this.$rtti.$MethodVar("TInternalHttpResponse",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["AResponse",rtl.string],["Handled",rtl.boolean,1]]), methodkind: 0});
  rtl.createClass(this,"TPersistTokens",pas.Classes.TPersistent,function () {
    this.$init = function () {
      pas.Classes.TPersistent.$init.call(this);
      this.FKey = "";
      this.FEnabled = false;
    };
    this.Create$1 = function () {
      this.FEnabled = false;
      this.FKey = "";
      return this;
    };
    this.Assign = function (Source) {
      if ($mod.TPersistTokens.isPrototypeOf(Source)) {
        this.FKey = rtl.as(Source,$mod.TPersistTokens).FKey;
        this.FEnabled = rtl.as(Source,$mod.TPersistTokens).FEnabled;
      };
    };
    var $r = this.$rtti;
    $r.addMethod("Create$1",2,[]);
    $r.addProperty("Key",0,rtl.string,"FKey","FKey");
    $r.addProperty("Enabled",0,rtl.boolean,"FEnabled","FEnabled",{Default: false});
  });
  rtl.createClass(this,"TRESTApp",pas.Classes.TPersistent,function () {
    this.$init = function () {
      pas.Classes.TPersistent.$init.call(this);
      this.FKey = "";
      this.FCallbackURL = "";
      this.FSecret = "";
      this.FAuthURL = "";
      this.FClientID = "";
    };
    this.GetKey = function () {
      var Result = "";
      if ((this.FKey !== "") && (this.FClientID === "")) {
        Result = this.FKey}
       else Result = this.FClientID;
      return Result;
    };
    this.Assign = function (Source) {
      if ($mod.TRESTApp.isPrototypeOf(Source)) {
        this.FKey = rtl.as(Source,$mod.TRESTApp).FKey;
        this.FClientID = rtl.as(Source,$mod.TRESTApp).FClientID;
        this.FCallbackURL = rtl.as(Source,$mod.TRESTApp).FCallbackURL;
        this.FSecret = rtl.as(Source,$mod.TRESTApp).FSecret;
        this.FAuthURL = rtl.as(Source,$mod.TRESTApp).FAuthURL;
      };
    };
    var $r = this.$rtti;
    $r.addProperty("AuthURL",0,rtl.string,"FAuthURL","FAuthURL");
    $r.addProperty("ClientID",0,rtl.string,"FClientID","FClientID");
    $r.addProperty("Key",0,rtl.string,"FKey","FKey");
    $r.addProperty("CallbackURL",0,rtl.string,"FCallbackURL","FCallbackURL");
    $r.addProperty("Secret",0,rtl.string,"FSecret","FSecret");
  });
  this.TAuthLocale = {"0": "lcDefault", lcDefault: 0, "1": "lcEnglish", lcEnglish: 1, "2": "lcDutch", lcDutch: 2, "3": "lcGerman", lcGerman: 3, "4": "lcFrench", lcFrench: 4, "5": "lcSpanish", lcSpanish: 5, "6": "lcItalian", lcItalian: 6, "7": "lcPortuguese", lcPortuguese: 7, "8": "lcGreek", lcGreek: 8, "9": "lcDanish", lcDanish: 9, "10": "lcRussian", lcRussian: 10, "11": "lcRomanian", lcRomanian: 11, "12": "lcSwedish", lcSwedish: 12, "13": "lcFinnish", lcFinnish: 13, "14": "lcTurkish", lcTurkish: 14, "15": "lcJapanese", lcJapanese: 15};
  this.$rtti.$Enum("TAuthLocale",{minvalue: 0, maxvalue: 15, ordtype: 1, enumtype: this.TAuthLocale});
  rtl.recNewT(this,"TCoreCloudHeader",function () {
    this.header = "";
    this.value = "";
    this.$eq = function (b) {
      return (this.header === b.header) && (this.value === b.value);
    };
    this.$assign = function (s) {
      this.header = s.header;
      this.value = s.value;
      return this;
    };
    var $r = $mod.$rtti.$Record("TCoreCloudHeader",{});
    $r.addField("header",rtl.string);
    $r.addField("value",rtl.string);
  });
  this.$rtti.$DynArray("TCoreCloudHeaders",{eltype: this.$rtti["TCoreCloudHeader"]});
  rtl.createClass(this,"TRESTClient",pas.Classes.TComponent,function () {
    this.$init = function () {
      pas.Classes.TComponent.$init.call(this);
      this.FAPIBase = "";
      this.FAccessToken = "";
      this.FRefreshToken = "";
      this.FAccessExpiry = 0.0;
      this.FRefreshExpiry = 0.0;
      this.FOnAccessToken = null;
      this.FOnAuthFailed = null;
      this.FEventRegistered = false;
      this.FOnResponse = null;
      this.FPersistTokens = null;
      this.FOnHttpResponse = null;
      this.FApp = null;
      this.FScopes = null;
      this.FLocale = 0;
      this.FOnRequestResponse = null;
      this.FOnError = null;
      this.FResponseType = 0;
      this.FLoginWidth = 0;
      this.FLoginHeight = 0;
      this.FHandleAccessTokenPtr = null;
      this.FHandleAuthClosePtr = null;
      this.FOpenResolver = null;
      this.FWithCredentials = false;
    };
    this.$final = function () {
      this.FOnAccessToken = undefined;
      this.FOnAuthFailed = undefined;
      this.FOnResponse = undefined;
      this.FPersistTokens = undefined;
      this.FOnHttpResponse = undefined;
      this.FApp = undefined;
      this.FScopes = undefined;
      this.FOnRequestResponse = undefined;
      this.FOnError = undefined;
      this.FOpenResolver = undefined;
      pas.Classes.TComponent.$final.call(this);
    };
    this.SetPersistTokens = function (Value) {
      this.FPersistTokens.Assign(Value);
    };
    this.SetApp = function (Value) {
      this.FApp.Assign(Value);
    };
    this.SetScopes = function (Value) {
      this.FScopes.Assign(Value);
    };
    this.AuthWinClosed = function () {
      if (this.FEventRegistered) this.DoAuthFailed();
    };
    this.InstallCallback = function () {
      var Result = false;
      var scriptsrc = "";
      scriptsrc = " function processAuthData(access_token) {" + 'var event = new CustomEvent("oauthcallback", {\r' + "            detail: {\r" + "                 message: access_token\r" + "            },\r" + "  bubbles: true,\r" + "  cancelable: true});\r" + "  document.dispatchEvent(event);" + "}";
      var script = document.createElement("script");
          script.innerHTML = scriptsrc;
          document.head.appendChild(script);
      
          var scr = document.createElement('script');
          scr.async = true;
          scr.defer = true;
          scr.type = 'text/javascript';
          document.body.appendChild(scr);
      Result = true;
      return Result;
    };
    this.RemoveOAuthHandler = function () {
      document.removeEventListener("oauthcallback",this.FHandleAccessTokenPtr);
      this.FEventRegistered = false;
    };
    this.DoAuthFailed = function () {
      if (this.FOnAuthFailed != null) this.FOnAuthFailed(this);
      if (this.FOpenResolver != null) {
        this.FOpenResolver(false);
        this.FOpenResolver = null;
      };
    };
    this.DoAuthSuccess = function () {
      if (this.FOpenResolver != null) {
        this.FOpenResolver(true);
        this.FOpenResolver = null;
      };
    };
    this.HandleAccessToken = function (s) {
      var Result = false;
      var token = "";
      this.RemoveOAuthHandler();
      token = s.detail.message;
      this.FAccessToken = token;
      this.WriteTokens();
      if (this.FOnAccessToken != null) this.FOnAccessToken(this);
      if (this.FOpenResolver != null) {
        this.FOpenResolver(true);
        this.FOpenResolver = null;
      };
      Result = true;
      return Result;
    };
    this.HandleResponse = function (Event) {
      var Result = false;
      var Response = "";
      var Handled = false;
      var LRequestRec = pas["WEBLib.Controls"].TJSXMLHttpRequestRecord.$new();
      LRequestRec.req = Event.target;
      Response = "";
      if (this.FResponseType in rtl.createSet($mod.THTTPRequestResponseType.rtText,$mod.THTTPRequestResponseType.rtDefault)) {
        Response = Event.target.responseText;
      };
      Handled = false;
      if (this.FOnHttpResponse != null) this.FOnHttpResponse(this,Response,{get: function () {
          return Handled;
        }, set: function (v) {
          Handled = v;
        }});
      if ((this.FOnRequestResponse != null) && !Handled) this.FOnRequestResponse(this,pas["WEBLib.Controls"].TJSXMLHttpRequestRecord.$clone(LRequestRec),Response);
      if ((this.FOnResponse != null) && !Handled) this.FOnResponse(this,Response);
      Result = true;
      return Result;
    };
    this.GetAuthURL = function () {
      var Result = "";
      Result = this.FApp.FAuthURL;
      return Result;
    };
    this.ScopeParamText = function (Delimiter, Encode) {
      var Result = "";
      var i = 0;
      var scopestr = "";
      Result = "";
      for (var $l = 0, $end = this.FScopes.GetCount() - 1; $l <= $end; $l++) {
        i = $l;
        if (Encode) {
          scopestr = encodeURIComponent(this.FScopes.Get(i))}
         else scopestr = this.FScopes.Get(i);
        if (Result === "") {
          Result = scopestr}
         else Result = Result + Delimiter + scopestr;
      };
      return Result;
    };
    this.GetLocaleParam = function () {
      var Result = "";
      Result = "";
      return Result;
    };
    this.GetJSONValue = function (o, ID) {
      var Result = null;
      var js = undefined;
      var res = false;
      var jvb = false;
      Result = null;
      js = o.fjo$1[ID];
      res = false;
      res = (js != undefined);
      if (res) {
        if (pas.JS.isBoolean(js)) {
          jvb = js;
          if (jvb) {
            Result = pas["WEBLib.JSON"].TJSONTrue.$create("Create$3")}
           else Result = pas["WEBLib.JSON"].TJSONFalse.$create("Create$3");
        };
        Result = pas["WEBLib.JSON"].TJSONValue.$create("Create$1",[js]);
      };
      return Result;
    };
    this.GetJSONObject = function (o, ID) {
      var Result = null;
      var ro = null;
      var jv = undefined;
      jv = o.fjo$1[ID];
      ro = jv;
      if (rtl.isArray(ro)) {
        Result = pas["WEBLib.JSON"].TJSONArray.$create("Create$2",[ro]);
      } else {
        Result = pas["WEBLib.JSON"].TJSONObject.$create("Create$3",[ro]);
      };
      return Result;
    };
    this.TMSUTF8Encode = function (s) {
      var Result = "";
      Result = s;
      return Result;
    };
    this.HttpRequestEvent = function (Command, URL, Data, ContentType, headers, AResponse, AError, ATimeOut) {
      var i = 0;
      var req = null;
      req = new XMLHttpRequest();
      req.addEventListener("load",rtl.createSafeCallback(null,AResponse));
      req.addEventListener("error",rtl.createSafeCallback(null,AError));
      req.addEventListener("timeout",rtl.createSafeCallback(null,ATimeOut));
      req.withCredentials = this.FWithCredentials;
      req.responseType = $mod.THttpRequest.GetResponseType(this.FResponseType);
      req.open(Command,URL,true);
      if (ContentType !== "") req.setRequestHeader("Content-Type",ContentType);
      if (this.FAccessToken !== "") req.setRequestHeader("Authorization","Bearer " + this.FAccessToken);
      if (rtl.length(headers) > 0) {
        for (var $l = 0, $end = rtl.length(headers) - 1; $l <= $end; $l++) {
          i = $l;
          req.setRequestHeader(headers[i].header,headers[i].value);
        };
      };
      if (Data === "") {
        req.send(null)}
       else req.send(Data);
    };
    this.Create$1 = function (AOwner) {
      pas.Classes.TComponent.Create$1.apply(this,arguments);
      this.FPersistTokens = $mod.TPersistTokens.$create("Create$1");
      this.FApp = $mod.TRESTApp.$create("Create");
      this.FScopes = pas.Classes.TStringList.$create("Create$1");
      this.FLocale = $mod.TAuthLocale.lcDefault;
      this.FResponseType = $mod.THTTPRequestResponseType.rtDefault;
      this.FWithCredentials = false;
      this.FLoginWidth = 800;
      this.FLoginHeight = 600;
      this.FHandleAccessTokenPtr = rtl.createCallback(this,"HandleAccessToken");
      return this;
    };
    this.Destroy = function () {
      if (this.FHandleAuthClosePtr != null) this.FHandleAuthClosePtr = null;
      rtl.free(this,"FApp");
      rtl.free(this,"FScopes");
      rtl.free(this,"FPersistTokens");
      pas.Classes.TComponent.Destroy.call(this);
    };
    this.HttpsCommand = function (Command, URL, Data, ContentType, headers) {
      var $Self = this;
      var i = 0;
      var req = null;
      var FRequestResponse = null;
      var FResponse = null;
      var FHttpResponse = null;
      function ResponseHandler(Event) {
        var Result = false;
        var Response = "";
        var Handled = false;
        var LRequestRec = pas["WEBLib.Controls"].TJSXMLHttpRequestRecord.$new();
        LRequestRec.req = Event.target;
        Response = Event.target.responseText;
        Handled = false;
        if (FHttpResponse != null) FHttpResponse($Self,Response,{get: function () {
            return Handled;
          }, set: function (v) {
            Handled = v;
          }});
        if ((FRequestResponse != null) && !Handled) {
          FRequestResponse($Self,pas["WEBLib.Controls"].TJSXMLHttpRequestRecord.$clone(LRequestRec),Response);
        };
        if ((FResponse != null) && !Handled) {
          FResponse($Self,Response);
        };
        Result = true;
        return Result;
      };
      function ErrorHandler(Event) {
        var Result = false;
        var Handled = false;
        var LEventRec = pas["WEBLib.Controls"].TJSEventRecord.$new();
        var LRequestRec = pas["WEBLib.Controls"].TJSXMLHttpRequestRecord.$new();
        Handled = false;
        if ($Self.FOnError != null) {
          LRequestRec.req = Event.target;
          LEventRec.event = Event;
          $Self.FOnError($Self,pas["WEBLib.Controls"].TJSXMLHttpRequestRecord.$clone(LRequestRec),pas["WEBLib.Controls"].TJSEventRecord.$clone(LEventRec),{get: function () {
              return Handled;
            }, set: function (v) {
              Handled = v;
            }});
        };
        if (!Handled) throw pas.SysUtils.Exception.$create("Create$1",["HTTP request error @" + URL]);
        Result = true;
        return Result;
      };
      FRequestResponse = this.FOnRequestResponse;
      FResponse = this.FOnResponse;
      FHttpResponse = this.FOnHttpResponse;
      req = new XMLHttpRequest();
      req.addEventListener("load",rtl.createSafeCallback(null,ResponseHandler));
      req.addEventListener("error",rtl.createSafeCallback(null,ErrorHandler));
      req.responseType = $mod.THttpRequest.GetResponseType(this.FResponseType);
      req.open(Command,URL,true);
      if (ContentType !== "") req.setRequestHeader("Content-Type",ContentType);
      if (this.FAccessToken !== "") req.setRequestHeader("Authorization","Bearer " + this.FAccessToken);
      if (rtl.length(headers) > 0) {
        for (var $l = 0, $end = rtl.length(headers) - 1; $l <= $end; $l++) {
          i = $l;
          req.setRequestHeader(headers[i].header,headers[i].value);
        };
      };
      if (Data === "") {
        req.send(null)}
       else req.send(Data);
    };
    this.HttpsDelete = function (URL) {
      this.HttpsCommand("DELETE",URL,"","",[]);
    };
    this.HttpsDelete$1 = function (URL, headers) {
      this.HttpsCommand("DELETE",URL,"","",rtl.arrayRef(headers));
    };
    this.HttpsGet = function (URL) {
      this.HttpsCommand("GET",URL,"","",[]);
    };
    this.HttpsGet$1 = function (URL, headers) {
      this.HttpsCommand("GET",URL,"","",rtl.arrayRef(headers));
    };
    this.HttpsPost = function (URL, Data) {
      this.HttpsPost$1(URL,"",Data);
    };
    this.HttpsPost$1 = function (URL, ContentType, Data) {
      this.HttpsCommand("POST",URL,Data,ContentType,[]);
    };
    this.HttpsPost$2 = function (URL, ContentType, Data, headers) {
      this.HttpsCommand("POST",URL,Data,ContentType,rtl.arrayRef(headers));
    };
    this.HttpsPost$3 = function (URL, headers, Data) {
      this.HttpsCommand("POST",URL,Data,"",rtl.arrayRef(headers));
    };
    this.HttpsUpdate = function (URL, headers, Data) {
      this.HttpsCommand("PUT",URL,Data,"",rtl.arrayRef(headers));
    };
    this.HttpsPut = function (URL, ContentType, Data) {
      this.HttpsCommand("PUT",URL,Data,ContentType,[]);
    };
    this.HttpRequest = function (Command, URL, Data, ContentType, headers) {
      var $Self = this;
      var Result = null;
      Result = new Promise(function (ASuccess, AFailed) {
        var i = 0;
        var req = null;
        var FRequestResponse = null;
        var FResponse = null;
        var FHttpResponse = null;
        function ResponseHandler(Event) {
          var Result = false;
          ASuccess(Event.target);
          return Result;
        };
        function ErrorHandler(Event) {
          var Result = false;
          AFailed(Event.target);
          return Result;
        };
        req = new XMLHttpRequest();
        req.addEventListener("load",rtl.createSafeCallback(null,ResponseHandler));
        req.addEventListener("error",rtl.createSafeCallback(null,ErrorHandler));
        req.withCredentials = $Self.FWithCredentials;
        req.responseType = $mod.THttpRequest.GetResponseType($Self.FResponseType);
        req.open(Command,URL,true);
        if (ContentType !== "") req.setRequestHeader("Content-Type",ContentType);
        if ($Self.FAccessToken !== "") req.setRequestHeader("Authorization","Bearer " + $Self.FAccessToken);
        if (rtl.length(headers) > 0) {
          for (var $l = 0, $end = rtl.length(headers) - 1; $l <= $end; $l++) {
            i = $l;
            req.setRequestHeader(headers[i].header,headers[i].value);
          };
        };
        if (Data === "") {
          req.send(null)}
         else req.send(Data);
      });
      return Result;
    };
    this.URLEncode = function (URI) {
      var Result = "";
      Result = encodeURIComponent(URI);
      return Result;
    };
    this.JSONEscape = function (s) {
      var Result = "";
      Result = encodeURIComponent(s);
      return Result;
    };
    this.IsoToDateTime = function (s) {
      var Result = 0.0;
      var da = 0;
      var mo = 0;
      var ye = 0;
      var ho = 0;
      var mi = 0;
      var se = 0;
      var ms = 0;
      var err = 0;
      ms = 0;
      pas.System.val$5(pas.System.Copy(s,1,4),{get: function () {
          return ye;
        }, set: function (v) {
          ye = v;
        }},{get: function () {
          return err;
        }, set: function (v) {
          err = v;
        }});
      pas.System.val$5(pas.System.Copy(s,6,2),{get: function () {
          return mo;
        }, set: function (v) {
          mo = v;
        }},{get: function () {
          return err;
        }, set: function (v) {
          err = v;
        }});
      pas.System.val$5(pas.System.Copy(s,9,2),{get: function () {
          return da;
        }, set: function (v) {
          da = v;
        }},{get: function () {
          return err;
        }, set: function (v) {
          err = v;
        }});
      pas.System.val$5(pas.System.Copy(s,12,2),{get: function () {
          return ho;
        }, set: function (v) {
          ho = v;
        }},{get: function () {
          return err;
        }, set: function (v) {
          err = v;
        }});
      pas.System.val$5(pas.System.Copy(s,15,2),{get: function () {
          return mi;
        }, set: function (v) {
          mi = v;
        }},{get: function () {
          return err;
        }, set: function (v) {
          err = v;
        }});
      pas.System.val$5(pas.System.Copy(s,18,2),{get: function () {
          return se;
        }, set: function (v) {
          se = v;
        }},{get: function () {
          return err;
        }, set: function (v) {
          err = v;
        }});
      if ((s.length >= 20) && (s.charAt(19) === ".")) {
        pas.System.val$5(pas.System.Copy(s,21,3),{get: function () {
            return ms;
          }, set: function (v) {
            ms = v;
          }},{get: function () {
            return err;
          }, set: function (v) {
            err = v;
          }});
      };
      if (ye < 1) ye = 1;
      if (mo < 1) mo = 1;
      if (da < 1) da = 1;
      Result = pas.SysUtils.EncodeDate(ye,mo,da) + pas.SysUtils.EncodeTime(ho,mi,se,ms);
      return Result;
    };
    this.IsoToDateTime$1 = function (s, IsUTC) {
      var Result = 0.0;
      var da = 0;
      var mo = 0;
      var ye = 0;
      var ho = 0;
      var mi = 0;
      var se = 0;
      var ms = 0;
      var HourOffset = 0;
      var MinuteOffset = 0;
      var err = 0;
      var delta = 0;
      var sign = "";
      HourOffset = 0;
      MinuteOffset = 0;
      ms = 0;
      delta = 0;
      pas.System.val$5(pas.System.Copy(s,1,4),{get: function () {
          return ye;
        }, set: function (v) {
          ye = v;
        }},{get: function () {
          return err;
        }, set: function (v) {
          err = v;
        }});
      pas.System.val$5(pas.System.Copy(s,6,2),{get: function () {
          return mo;
        }, set: function (v) {
          mo = v;
        }},{get: function () {
          return err;
        }, set: function (v) {
          err = v;
        }});
      pas.System.val$5(pas.System.Copy(s,9,2),{get: function () {
          return da;
        }, set: function (v) {
          da = v;
        }},{get: function () {
          return err;
        }, set: function (v) {
          err = v;
        }});
      pas.System.val$5(pas.System.Copy(s,12,2),{get: function () {
          return ho;
        }, set: function (v) {
          ho = v;
        }},{get: function () {
          return err;
        }, set: function (v) {
          err = v;
        }});
      pas.System.val$5(pas.System.Copy(s,15,2),{get: function () {
          return mi;
        }, set: function (v) {
          mi = v;
        }},{get: function () {
          return err;
        }, set: function (v) {
          err = v;
        }});
      pas.System.val$5(pas.System.Copy(s,18,2),{get: function () {
          return se;
        }, set: function (v) {
          se = v;
        }},{get: function () {
          return err;
        }, set: function (v) {
          err = v;
        }});
      if ((s.length >= 20) && (s.charAt(19) === ".")) {
        pas.System.val$5(pas.System.Copy(s,21,3),{get: function () {
            return ms;
          }, set: function (v) {
            ms = v;
          }},{get: function () {
            return err;
          }, set: function (v) {
            err = v;
          }});
        delta = 4;
      };
      if (ye < 1) ye = 1;
      if (mo < 1) mo = 1;
      if (da < 1) da = 1;
      if (s.length > (20 + delta)) {
        sign = pas.System.Copy(s,20 + delta,1);
        pas.System.val$6(pas.System.Copy(s,22 + delta,2),{get: function () {
            return HourOffset;
          }, set: function (v) {
            HourOffset = v;
          }},{get: function () {
            return err;
          }, set: function (v) {
            err = v;
          }});
        pas.System.val$6(pas.System.Copy(s,25 + delta,2),{get: function () {
            return MinuteOffset;
          }, set: function (v) {
            MinuteOffset = v;
          }},{get: function () {
            return err;
          }, set: function (v) {
            err = v;
          }});
        if (sign === "-") {
          HourOffset = HourOffset * -1;
          MinuteOffset = MinuteOffset * -1;
        };
      };
      Result = pas.SysUtils.EncodeDate(ye,mo,da) + pas.SysUtils.EncodeTime(ho,mi,se,ms);
      return Result;
    };
    this.IsoToDate = function (s) {
      var Result = 0.0;
      var da = 0;
      var mo = 0;
      var ye = 0;
      var err = 0;
      pas.System.val$5(pas.System.Copy(s,1,4),{get: function () {
          return ye;
        }, set: function (v) {
          ye = v;
        }},{get: function () {
          return err;
        }, set: function (v) {
          err = v;
        }});
      pas.System.val$5(pas.System.Copy(s,6,2),{get: function () {
          return mo;
        }, set: function (v) {
          mo = v;
        }},{get: function () {
          return err;
        }, set: function (v) {
          err = v;
        }});
      pas.System.val$5(pas.System.Copy(s,9,2),{get: function () {
          return da;
        }, set: function (v) {
          da = v;
        }},{get: function () {
          return err;
        }, set: function (v) {
          err = v;
        }});
      if (ye < 1) ye = 1;
      if (mo < 1) mo = 1;
      if (da < 1) da = 1;
      Result = pas.SysUtils.EncodeDate(ye,mo,da) + pas.SysUtils.EncodeTime(0,0,0,0);
      return Result;
    };
    this.IsoToTime = function (s) {
      var Result = 0.0;
      var ho = 0;
      var mi = 0;
      var se = 0;
      var ms = 0;
      var err = 0;
      ms = 0;
      pas.System.val$5(pas.System.Copy(s,1,2),{get: function () {
          return ho;
        }, set: function (v) {
          ho = v;
        }},{get: function () {
          return err;
        }, set: function (v) {
          err = v;
        }});
      pas.System.val$5(pas.System.Copy(s,4,2),{get: function () {
          return mi;
        }, set: function (v) {
          mi = v;
        }},{get: function () {
          return err;
        }, set: function (v) {
          err = v;
        }});
      pas.System.val$5(pas.System.Copy(s,7,2),{get: function () {
          return se;
        }, set: function (v) {
          se = v;
        }},{get: function () {
          return err;
        }, set: function (v) {
          err = v;
        }});
      if (s.length > 10) pas.System.val$5(pas.System.Copy(s,10,4),{get: function () {
          return ms;
        }, set: function (v) {
          ms = v;
        }},{get: function () {
          return err;
        }, set: function (v) {
          err = v;
        }});
      if ((ho < 0) || (ho > 23)) ho = 0;
      if ((mi < 0) || (mi > 59)) mi = 0;
      if ((se < 0) || (se > 59)) se = 0;
      if (ms < 0) ms = 0;
      Result = pas.SysUtils.EncodeTime(ho,mi,se,ms);
      return Result;
    };
    this.IsIsoDateTime = function (s) {
      var Result = false;
      var da = 0;
      var mo = 0;
      var ye = 0;
      var ho = 0;
      var mi = 0;
      var se = 0;
      var err = 0;
      Result = true;
      pas.System.val$5(pas.System.Copy(s,1,4),{get: function () {
          return ye;
        }, set: function (v) {
          ye = v;
        }},{get: function () {
          return err;
        }, set: function (v) {
          err = v;
        }});
      if (err !== 0) return false;
      if (!(pas.System.Copy(s,5,1) === "-")) return false;
      pas.System.val$5(pas.System.Copy(s,6,2),{get: function () {
          return mo;
        }, set: function (v) {
          mo = v;
        }},{get: function () {
          return err;
        }, set: function (v) {
          err = v;
        }});
      if (err !== 0) return false;
      if (!(pas.System.Copy(s,8,1) === "-")) return false;
      pas.System.val$5(pas.System.Copy(s,9,2),{get: function () {
          return da;
        }, set: function (v) {
          da = v;
        }},{get: function () {
          return err;
        }, set: function (v) {
          err = v;
        }});
      if (err !== 0) return false;
      pas.System.val$5(pas.System.Copy(s,12,2),{get: function () {
          return ho;
        }, set: function (v) {
          ho = v;
        }},{get: function () {
          return err;
        }, set: function (v) {
          err = v;
        }});
      if (err === 0) {
        if (!(pas.System.Copy(s,14,1) === ":")) return false;
        pas.System.val$5(pas.System.Copy(s,15,2),{get: function () {
            return mi;
          }, set: function (v) {
            mi = v;
          }},{get: function () {
            return err;
          }, set: function (v) {
            err = v;
          }});
        if (err !== 0) return false;
        if (!(pas.System.Copy(s,17,1) === ":")) return false;
        pas.System.val$5(pas.System.Copy(s,18,2),{get: function () {
            return se;
          }, set: function (v) {
            se = v;
          }},{get: function () {
            return err;
          }, set: function (v) {
            err = v;
          }});
        if (err !== 0) return false;
      };
      return Result;
    };
    this.GetUTCDateTime = function () {
      var Result = 0.0;
      var s = "";
      const nowt = new Date();
      s = nowt.toISOString();
      Result = this.IsoToDateTime(s);
      return Result;
    };
    this.DateTimeToWL = function (dt) {
      var Result = "";
      var da = 0;
      var mo = 0;
      var ye = 0;
      var ho = 0;
      var mi = 0;
      var se = 0;
      var ms = 0;
      pas.SysUtils.DecodeDate(dt,{get: function () {
          return ye;
        }, set: function (v) {
          ye = v;
        }},{get: function () {
          return mo;
        }, set: function (v) {
          mo = v;
        }},{get: function () {
          return da;
        }, set: function (v) {
          da = v;
        }});
      pas.SysUtils.DecodeTime(dt,{get: function () {
          return ho;
        }, set: function (v) {
          ho = v;
        }},{get: function () {
          return mi;
        }, set: function (v) {
          mi = v;
        }},{get: function () {
          return se;
        }, set: function (v) {
          se = v;
        }},{get: function () {
          return ms;
        }, set: function (v) {
          ms = v;
        }});
      Result = pas.SysUtils.IntToStr(ye) + "-" + $impl.IntToZStr(mo,2) + "-" + $impl.IntToZStr(da,2) + "T" + $impl.IntToZStr(ho,2) + ":" + $impl.IntToZStr(mi,2) + ":" + $impl.IntToZStr(se,2);
      Result = Result + "+00:00";
      return Result;
    };
    this.DateToWL = function (dt) {
      var Result = "";
      var da = 0;
      var mo = 0;
      var ye = 0;
      pas.SysUtils.DecodeDate(dt,{get: function () {
          return ye;
        }, set: function (v) {
          ye = v;
        }},{get: function () {
          return mo;
        }, set: function (v) {
          mo = v;
        }},{get: function () {
          return da;
        }, set: function (v) {
          da = v;
        }});
      Result = pas.SysUtils.IntToStr(ye) + "-" + $impl.IntToZStr(mo,2) + "-" + $impl.IntToZStr(da,2);
      return Result;
    };
    this.TimeToWL = function (dt) {
      var Result = "";
      var ho = 0;
      var mi = 0;
      var se = 0;
      var ms = 0;
      pas.SysUtils.DecodeTime(dt,{get: function () {
          return ho;
        }, set: function (v) {
          ho = v;
        }},{get: function () {
          return mi;
        }, set: function (v) {
          mi = v;
        }},{get: function () {
          return se;
        }, set: function (v) {
          se = v;
        }},{get: function () {
          return ms;
        }, set: function (v) {
          ms = v;
        }});
      Result = $impl.IntToZStr(ho,2) + ":" + $impl.IntToZStr(mi,2) + ":" + $impl.IntToZStr(se,2) + "." + pas.SysUtils.IntToStr(ms);
      return Result;
    };
    this.DateTimeToDaylightSavings = function (dt) {
      var Result = 0.0;
      Result = dt;
      return Result;
    };
    this.GetJSONProp = function (O, ID) {
      var Result = "";
      Result = O.GetJSONValue(ID);
      return Result;
    };
    this.GetJSONInt = function (O, ID) {
      var Result = 0;
      var jv = undefined;
      jv = O.fjo$1[ID];
      if (rtl.isNumber(jv)) Result = rtl.trunc(jv);
      return Result;
    };
    this.DoAuth = function () {
      var URL = "";
      var param = "";
      if (!this.FEventRegistered) {
        document.addEventListener("oauthcallback",this.FHandleAccessTokenPtr);
        this.FEventRegistered = true;
      };
      URL = this.GetAuthURL();
      param = "width=" + pas["WEBLib.Utils"].TLongIntHelper.ToString.call({p: this, get: function () {
          return this.p.FLoginWidth;
        }, set: function (v) {
          this.p.FLoginWidth = v;
        }}) + ",height=" + pas["WEBLib.Utils"].TLongIntHelper.ToString.call({p: this, get: function () {
          return this.p.FLoginHeight;
        }, set: function (v) {
          this.p.FLoginHeight = v;
        }}) + ",location=no,toolbar=no,menubar=no";
      this.FHandleAuthClosePtr = rtl.createCallback(this,"AuthWinClosed");
      var authwinfunc = this.FHandleAuthClosePtr;
          var newwindow = window.open(URL, 'oauth', param);
          var timeoutid = 0;
      
          function onWindowClosed() {
            clearTimeout(timeoutid);
            authwinfunc();
          }
      
          function checkWindowClosed() {
           if (newwindow.closed) {
              onWindowClosed();
          } else {
              timeoutid = setTimeout(checkWindowClosed, 1000); // Check every second
          }
          }
      
          checkWindowClosed();
    };
    this.Connect = function () {
      if (this.FPersistTokens.FEnabled) {
        this.ReadTokens();
      };
      if (this.FAccessToken !== "") {
        this.TestTokens();
      } else {
        this.DoAuth();
      };
    };
    this.Open = function () {
      var $Self = this;
      var Result = null;
      Result = new Promise(function (ASuccess, AFailed) {
        $Self.FOpenResolver = ASuccess;
        $Self.Connect();
      });
      return Result;
    };
    this.Authenticate = async function () {
      var $Self = this;
      var Result = null;
      Result = new Promise(function (ASuccess, AFailed) {
        var ptr = null;
        function HandleOAuthCallBack(s) {
          var Result = false;
          var token = "";
          document.removeEventListener("oauthcallback",ptr);
          token = s.detail.message;
          $Self.FAccessToken = token;
          $Self.WriteTokens();
          ASuccess($Self.FAccessToken);
          return Result;
        };
        ptr = HandleOAuthCallBack;
        document.addEventListener("oauthcallback",ptr);
        $Self.DoAuth();
      });
      return Result;
    };
    this.ReadTokens = function () {
      var ls = null;
      if (this.FPersistTokens.FEnabled && (this.FPersistTokens.FKey !== "")) {
        ls = pas["WEBLib.Storage"].TLocalStorage.$create("Create");
        this.FAccessToken = ls.GetValues(this.FPersistTokens.FKey);
        this.FRefreshToken = ls.GetValues(this.FPersistTokens.FKey + "refresh");
        this.FAccessExpiry = this.$class.IsoToDateTime(ls.GetValues(this.FPersistTokens.FKey + "accessexpiry"));
        this.FRefreshExpiry = this.$class.IsoToDateTime(ls.GetValues(this.FPersistTokens.FKey + "refreshexpiry"));
        ls = rtl.freeLoc(ls);
      };
    };
    this.WriteTokens = function () {
      var ls = null;
      if (this.FPersistTokens.FEnabled && (this.FPersistTokens.FKey !== "")) {
        ls = pas["WEBLib.Storage"].TLocalStorage.$create("Create");
        ls.SetValues(this.FPersistTokens.FKey,this.FAccessToken);
        ls.SetValues(this.FPersistTokens.FKey + "refresh",this.FRefreshToken);
        ls.SetValues(this.FPersistTokens.FKey + "accessexpiry",pas["WEBLib.Utils"].TDateTimeHelper.ToIsoString.call({p: this, get: function () {
            return this.p.FAccessExpiry;
          }, set: function (v) {
            this.p.FAccessExpiry = v;
          }},true,false));
        ls.SetValues(this.FPersistTokens.FKey + "refreshexpiry",pas["WEBLib.Utils"].TDateTimeHelper.ToIsoString.call({p: this, get: function () {
            return this.p.FRefreshExpiry;
          }, set: function (v) {
            this.p.FRefreshExpiry = v;
          }},true,false));
        ls = rtl.freeLoc(ls);
      };
    };
    this.TestTokens = async function () {
      if (this.FOnAccessToken != null) this.FOnAccessToken(this);
    };
    this.ClearTokens = function () {
      this.FAccessToken = "";
      this.WriteTokens();
    };
    rtl.addIntf(this,pas.System.IUnknown);
    var $r = this.$rtti;
    $r.addMethod("Create$1",2,[["AOwner",pas.Classes.$rtti["TComponent"]]]);
    $r.addProperty("App",2,$mod.$rtti["TRESTApp"],"FApp","SetApp");
    $r.addProperty("LoginHeight",0,rtl.longint,"FLoginHeight","FLoginHeight",{Default: 600});
    $r.addProperty("LoginWidth",0,rtl.longint,"FLoginWidth","FLoginWidth",{Default: 800});
    $r.addProperty("PersistTokens",2,$mod.$rtti["TPersistTokens"],"FPersistTokens","SetPersistTokens");
    $r.addProperty("ResponseType",0,$mod.$rtti["THTTPRequestResponseType"],"FResponseType","FResponseType",{Default: $mod.THTTPRequestResponseType.rtDefault});
    $r.addProperty("Scopes",2,pas.Classes.$rtti["TStrings"],"FScopes","SetScopes");
    $r.addProperty("WithCredentials",0,rtl.boolean,"FWithCredentials","FWithCredentials",{Default: false});
    $r.addProperty("OnAccessToken",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnAccessToken","FOnAccessToken");
    $r.addProperty("OnAuthFailed",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnAuthFailed","FOnAuthFailed");
    $r.addProperty("OnRequestResponse",0,pas["WEBLib.Controls"].$rtti["THTTPRequestResponseEvent"],"FOnRequestResponse","FOnRequestResponse");
    $r.addProperty("OnResponse",0,$mod.$rtti["THttpResponse"],"FOnResponse","FOnResponse");
    $r.addProperty("OnError",0,pas["WEBLib.Controls"].$rtti["THTTPErrorEvent"],"FOnError","FOnError");
  });
  rtl.createClass(this,"TWebRESTClient",this.TRESTClient,function () {
    rtl.addIntf(this,pas.System.IUnknown);
  });
  this.AddHeader = function (AHeaders, Header, Value) {
    AHeaders.set(rtl.arraySetLength(AHeaders.get(),$mod.TCoreCloudHeader,rtl.length(AHeaders.get()) + 1));
    AHeaders.get()[rtl.length(AHeaders.get()) - 1].header = Header;
    AHeaders.get()[rtl.length(AHeaders.get()) - 1].value = Value;
  };
  this.GetArraySize = function (ja) {
    var Result = 0;
    Result = ja.GetCount();
    return Result;
  };
  this.GetArrayItem = function (ja, Index) {
    var Result = null;
    Result = ja.GetItem(Index);
    return Result;
  };
  this.HTTPCommand = function (ACommand, ACustomCommand) {
    var Result = "";
    var cmd = "";
    var $tmp = ACommand;
    if ($tmp === $mod.THTTPCommand.httpGET) {
      cmd = "GET"}
     else if ($tmp === $mod.THTTPCommand.httpPOST) {
      cmd = "POST"}
     else if ($tmp === $mod.THTTPCommand.httpPUT) {
      cmd = "PUT"}
     else if ($tmp === $mod.THTTPCommand.httpDELETE) {
      cmd = "DELETE"}
     else if ($tmp === $mod.THTTPCommand.httpHEAD) {
      cmd = "HEAD"}
     else if ($tmp === $mod.THTTPCommand.httpPATCH) {
      cmd = "PATCH"}
     else if ($tmp === $mod.THTTPCommand.httpCUSTOM) cmd = ACustomCommand;
    Result = cmd;
    return Result;
  };
  $mod.$implcode = function () {
    $impl.IntToZStr = function (i, l) {
      var Result = "";
      var Res = "";
      Res = pas.SysUtils.IntToStr(i);
      while (Res.length < l) Res = "0" + Res;
      Result = Res;
      return Result;
    };
  };
  $mod.$init = function () {
    $mod.TRESTClient.InstallCallback();
  };
},["WEBLib.Storage","WEBLib.Utils"]);
rtl.module("WEBLib.Utils",["System","Types","Web","SysUtils","Math","Classes","JS"],function () {
  "use strict";
  var $mod = this;
  var $impl = $mod.$impl;
  this.DayMonday = 1;
  this.DayTuesday = 2;
  this.DayWednesday = 3;
  this.DayThursday = 4;
  this.DayFriday = 5;
  this.DaySaturday = 6;
  this.DaySunday = 7;
  this.MonthJanuary = 1;
  this.MonthFebruary = 2;
  this.MonthMarch = 3;
  this.MonthApril = 4;
  this.MonthMay = 5;
  this.MonthJune = 6;
  this.MonthJuly = 7;
  this.MonthAugust = 8;
  this.MonthSeptember = 9;
  this.MonthOctober = 10;
  this.MonthNovember = 11;
  this.MonthDecember = 12;
  this.$rtti.$Class("TInterfaceList");
  rtl.createClass(this,"EEncodingError",pas.SysUtils.Exception,function () {
  });
  rtl.createClass(this,"EStringStreamError",pas.Classes.EStreamError,function () {
  });
  rtl.createHelper(this,"TBytesHelper",null,function () {
    this.get_Length = function () {
      var Result = 0;
      Result = rtl.length(this.get());
      return Result;
    };
    this.set_Length = function (AValue) {
      this.set(rtl.arraySetLength(this.get(),0,AValue));
    };
    this.Compare = function (ARight) {
      var Result = 0;
      var lCount = 0;
      if ($mod.TBytesHelper.get_Length.call(this) > $mod.TBytesHelper.get_Length.call({get: function () {
          return ARight;
        }, set: function (v) {
          rtl.raiseE("EPropReadOnly");
        }})) return 1;
      if ($mod.TBytesHelper.get_Length.call(this) < $mod.TBytesHelper.get_Length.call({get: function () {
          return ARight;
        }, set: function (v) {
          rtl.raiseE("EPropReadOnly");
        }})) return -1;
      Result = 0;
      for (var $l = $mod.TBytesHelper.Low.call(this), $end = $mod.TBytesHelper.High.call(this); $l <= $end; $l++) {
        lCount = $l;
        if (this.get()[lCount] > ARight[lCount]) return 1;
        if (this.get()[lCount] < ARight[lCount]) return -1;
      };
      return Result;
    };
    this.High = function () {
      var Result = 0;
      Result = rtl.length(this.get()) - 1;
      return Result;
    };
    this.Low = function () {
      var Result = 0;
      Result = 0;
      return Result;
    };
    this.SubBytes = function (AStartIndex) {
      var Result = [];
      Result = rtl.arrayCopy(0,this.get(),AStartIndex,$mod.TBytesHelper.get_Length.call(this));
      return Result;
    };
    this.SubBytes$1 = function (AStartIndex, ALength) {
      var Result = [];
      Result = rtl.arrayCopy(0,this.get(),AStartIndex,ALength);
      return Result;
    };
  });
  this.$rtti.$DynArray("TWords",{eltype: rtl.word});
  rtl.createHelper(this,"TWordsHelper",null,function () {
    this.get_Length = function () {
      var Result = 0;
      Result = rtl.length(this.get());
      return Result;
    };
    this.set_Length = function (AValue) {
      this.set(rtl.arraySetLength(this.get(),0,AValue));
    };
    var cBytesPerWord = 2;
    this.FromBytes = function (ABytes) {
      var Result = [];
      var lCount = 0;
      var lLow = 0;
      var lHigh = 0;
      lCount = $mod.TBytesHelper.get_Length.call({get: function () {
          return ABytes;
        }, set: function (v) {
          rtl.raiseE("EPropReadOnly");
        }});
      if (pas.System.Odd(lCount)) lCount += 1;
      $mod.TWordsHelper.set_Length.call({get: function () {
          return Result;
        }, set: function (v) {
          Result = v;
        }},rtl.trunc(lCount / 2));
      lCount = $mod.TBytesHelper.Low.call({get: function () {
          return ABytes;
        }, set: function (v) {
          rtl.raiseE("EPropReadOnly");
        }});
      while (lCount <= $mod.TBytesHelper.High.call({get: function () {
          return ABytes;
        }, set: function (v) {
          rtl.raiseE("EPropReadOnly");
        }})) {
        lLow = ABytes[lCount];
        if ((lCount + 1) <= $mod.TBytesHelper.High.call({get: function () {
            return ABytes;
          }, set: function (v) {
            rtl.raiseE("EPropReadOnly");
          }})) {
          lHigh = ABytes[lCount + 1]}
         else lHigh = 0;
        Result[rtl.trunc(lCount / 2)] = pas.SysUtils.TWordHelper.FromBytes(lLow,lHigh);
        lCount += 2;
      };
      return Result;
    };
    this.High = function () {
      var Result = 0;
      Result = rtl.length(this.get()) - 1;
      return Result;
    };
    this.Low = function () {
      var Result = 0;
      Result = 0;
      return Result;
    };
    var cBytesPerWord$1 = 2;
    this.ToBytes = function () {
      var Result = [];
      var lLow = 0;
      var lHigh = 0;
      var lCount = 0;
      var lNewIndex = 0;
      $mod.TBytesHelper.set_Length.call({get: function () {
          return Result;
        }, set: function (v) {
          Result = v;
        }},$mod.TWordsHelper.get_Length.call(this) * 2);
      for (var $l = $mod.TWordsHelper.Low.call(this), $end = $mod.TWordsHelper.High.call(this); $l <= $end; $l++) {
        lCount = $l;
        pas.SysUtils.TWordHelper.ToBytes.call({a: lCount, p: this.get(), get: function () {
            return this.p[this.a];
          }, set: function (v) {
            this.p[this.a] = v;
          }},{get: function () {
            return lLow;
          }, set: function (v) {
            lLow = v;
          }},{get: function () {
            return lHigh;
          }, set: function (v) {
            lHigh = v;
          }});
        lNewIndex = lCount * 2;
        Result[lNewIndex] = lLow;
        Result[lNewIndex + 1] = lHigh;
      };
      return Result;
    };
  });
  rtl.createHelper(this,"TCharHelper",null,function () {
    this.Length = 1;
    this.Size = 2;
    var cNumChars = rtl.createSet(48,49,50,51,52,53,54,55,56,57);
    this.IsDigit = function () {
      var Result = false;
      Result = this.get().charCodeAt() in cNumChars;
      return Result;
    };
    this.ToOrd = function () {
      var Result = 0;
      Result = this.get().charCodeAt();
      return Result;
    };
    this.ToUpper = function () {
      var Result = "\x00";
      Result = $mod.TCharHelper.ToUpper$1(this.get());
      return Result;
    };
    this.ToUpper$1 = function (AValue) {
      return AValue.toUpperCase();
    };
  });
  rtl.createHelper(this,"TLongIntHelper",null,function () {
    this.Equals = function (AValue) {
      var Result = false;
      Result = this.get() === AValue;
      return Result;
    };
    this.NotEquals = function (AValue) {
      var Result = false;
      Result = !$mod.TLongIntHelper.Equals.call(this,AValue);
      return Result;
    };
    this.Parse = function (AValue) {
      var Result = 0;
      Result = pas.SysUtils.StrToInt(AValue);
      return Result;
    };
    this.ToString = function () {
      var Result = "";
      Result = $mod.TLongIntHelper.ToString$1(this.get());
      return Result;
    };
    this.ToString$1 = function (AValue) {
      return AValue.toString();
    };
    this.TryParse = function (AString, AValue) {
      var Result = false;
      Result = pas.SysUtils.TryStrToInt(AString,AValue);
      return Result;
    };
  });
  rtl.createHelper(this,"TDateTimeHelper",null,function () {
    this.Equals = function (AValue) {
      var Result = false;
      Result = pas.Math.SameValue(this.get(),AValue,0.0);
      return Result;
    };
    this.NotEquals = function (AValue) {
      var Result = false;
      Result = !pas.Math.SameValue(this.get(),AValue,0.0);
      return Result;
    };
    this.ToString = function () {
      var Result = "";
      Result = pas.SysUtils.DateTimeToStr$1(this.get(),pas.SysUtils.FormatSettings,false);
      return Result;
    };
    this.ToIsoString = function (AAddDelimiters, AAddMilliSeconds) {
      var $Self = this;
      var Result = "";
      var da = 0;
      var mo = 0;
      var ye = 0;
      var ho = 0;
      var mi = 0;
      var se = 0;
      var ms = 0;
      var dd = "";
      var td = "";
      var msec = "";
      function IntToZStr(i, l) {
        var Result = "";
        var Res = "";
        Res = pas.SysUtils.IntToStr(i);
        while (Res.length < l) Res = "0" + Res;
        Result = Res;
        return Result;
      };
      if (AAddDelimiters) {
        dd = "-";
        td = ":";
      };
      pas.SysUtils.DecodeDate($Self.get(),{get: function () {
          return ye;
        }, set: function (v) {
          ye = v;
        }},{get: function () {
          return mo;
        }, set: function (v) {
          mo = v;
        }},{get: function () {
          return da;
        }, set: function (v) {
          da = v;
        }});
      pas.SysUtils.DecodeTime($Self.get(),{get: function () {
          return ho;
        }, set: function (v) {
          ho = v;
        }},{get: function () {
          return mi;
        }, set: function (v) {
          mi = v;
        }},{get: function () {
          return se;
        }, set: function (v) {
          se = v;
        }},{get: function () {
          return ms;
        }, set: function (v) {
          ms = v;
        }});
      if (AAddMilliSeconds) msec = "." + IntToZStr(ms,3) + "Z";
      Result = IntToZStr(ye,4) + dd + IntToZStr(mo,2) + dd + IntToZStr(da,2) + "T" + IntToZStr(ho,2) + td + IntToZStr(mi,2) + td + IntToZStr(se,2) + msec;
      return Result;
    };
  });
  rtl.createHelper(this,"TStreamHelper",null,function () {
    var MaxBufSize = 0xF000;
    this.CopyFrom = function (ASource, ACount) {
      var Result = 0;
      var lBufSize = 0;
      var lCount = 0;
      var lBuffer = [];
      if (ACount <= 0) {
        ASource.SetPosition(0);
        ACount = ASource.GetSize();
      };
      Result = ACount;
      if (ACount > 61440) {
        lBufSize = 61440}
       else lBufSize = ACount;
      $mod.TBytesHelper.set_Length.call({get: function () {
          return lBuffer;
        }, set: function (v) {
          lBuffer = v;
        }},lBufSize);
      try {
        while (ACount !== 0) {
          if (ACount > lBufSize) {
            lCount = lBufSize}
           else lCount = ACount;
          ASource.ReadBuffer({get: function () {
              return lBuffer;
            }, set: function (v) {
              lBuffer = v;
            }},lCount);
          this.WriteBuffer(lBuffer,lCount);
          ACount -= lCount;
        };
      } finally {
        $mod.TBytesHelper.set_Length.call({get: function () {
            return lBuffer;
          }, set: function (v) {
            lBuffer = v;
          }},0);
      };
      return Result;
    };
  });
  rtl.createClass(this,"TTMSStringStream",pas.Classes.TBytesStream,function () {
    this.$init = function () {
      pas.Classes.TBytesStream.$init.call(this);
      this.FEncoding = null;
      this.FFileName = "";
      this.FOwnsEncoding = false;
      this.FError = null;
      this.FLoaded = null;
      this.FRequest = null;
    };
    this.$final = function () {
      this.FEncoding = undefined;
      this.FError = undefined;
      this.FLoaded = undefined;
      this.FRequest = undefined;
      pas.Classes.TBytesStream.$final.call(this);
    };
    this.GetDataString = function () {
      var Result = "";
      Result = this.FEncoding.GetString(rtl.arrayCopy(0,this.GetBytes(),0,this.GetSize()));
      return Result;
    };
    this.InternalLoadFromFileP = function (AFileName) {
      var $Self = this;
      var Result = null;
      Result = new Promise(function (AResolve, AReject) {
        $Self.LoadFromFile$3(AFileName,function () {
          AResolve(true);
        },function (AError) {
          AReject(AError);
        });
      });
      return Result;
    };
    this.OnAbort = function (AEvent) {
      var Result = false;
      Result = true;
      if (this.FError != null) this.FError(pas.SysUtils.Format(rtl.getResStr(pas["WEBLib.Consts"],"SLoadFromFileAborted"),pas.System.VarRecs(18,this.FFileName)));
      return Result;
    };
    this.OnError = function (AEvent) {
      var Result = false;
      Result = true;
      if (this.FError != null) this.FError(pas.SysUtils.Format(rtl.getResStr(pas["WEBLib.Consts"],"SErrorLoadFromFile"),pas.System.VarRecs(18,this.FFileName)));
      return Result;
    };
    var cStatusOK$1 = 200;
    var cStatusLastOK = 208;
    this.OnLoad = function (AEvent) {
      var Result = false;
      var lReq = null;
      lReq = AEvent.target;
      if ((lReq.status < 200) || (lReq.status > 208)) {
        if (this.FError != null) {
          this.FError(pas.SysUtils.Format(rtl.getResStr(pas["WEBLib.Consts"],"SCannotGetFile"),pas.System.VarRecs(18,this.FFileName,0,this.FRequest.status)));
          return Result;
        } else throw $mod.EStringStreamError.$create("CreateFmt",[rtl.getResStr(pas["WEBLib.Consts"],"SCannotGetFile"),pas.System.VarRecs(18,this.FFileName,0,lReq.status)]);
      };
      this.WriteString(lReq.responseText);
      Result = true;
      if (this.FLoaded != null) this.FLoaded();
      return Result;
    };
    this.Create$2 = function () {
      this.Create$4(pas.SysUtils.TStringHelper.Empty,pas.SysUtils.TEncoding.GetDefault(),false);
      return this;
    };
    this.Create$3 = function (AString) {
      this.Create$4(AString,pas.SysUtils.TEncoding.GetDefault(),false);
      return this;
    };
    this.Create$4 = function (AString, AEncoding, AOwnsEncoding) {
      var lBytes = [];
      pas.System.TObject.Create.call(this);
      this.FEncoding = AEncoding;
      this.FOwnsEncoding = AOwnsEncoding && !pas.SysUtils.TEncoding.IsStandardEncoding(AEncoding);
      lBytes = this.FEncoding.GetBytes(AString);
      this.SetPointer(this.$class.BytesToMemory(rtl.arrayRef(lBytes)),$mod.TBytesHelper.get_Length.call({get: function () {
          return lBytes;
        }, set: function (v) {
          lBytes = v;
        }}));
      return this;
    };
    this.Destroy = function () {
      if (this.FOwnsEncoding) rtl.free(this,"FEncoding");
      pas.Classes.TMemoryStream.Destroy.call(this);
    };
    var cStatusOK = 200;
    this.LoadFromFile$1 = function (AFileName) {
      var lStatus = 0;
      var lResponse = "";
      lResponse = pas.SysUtils.TStringHelper.Empty;
      lStatus = 200;
      var lRequest = new XMLHttpRequest();
          lRequest.open("GET", AFileName, false);
          lRequest.send();
      
          if (lRequest.status == cStatusOK)
            lResponse = lRequest.responseText
          else
            lStatus = lRequest.status;
      if (lStatus !== 200) throw $mod.EStringStreamError.$create("CreateFmt",[rtl.getResStr(pas["WEBLib.Consts"],"SCannotGetFile"),pas.System.VarRecs(18,AFileName,0,lStatus)]);
      this.WriteString(lResponse);
    };
    this.LoadFromFile$2 = function (AFileName, ALoaded) {
      this.LoadFromFile$3(AFileName,ALoaded,null);
    };
    var cAbortMethod = "abort";
    var cErrorMethod = "error";
    var cGetMethod = "GET";
    var cLoadMethod = "load";
    this.LoadFromFile$3 = function (AFileName, ALoaded, AError) {
      this.FLoaded = ALoaded;
      this.FError = AError;
      this.FFileName = AFileName;
      this.FRequest = new XMLHttpRequest();
      this.FRequest.addEventListener(cAbortMethod,rtl.createSafeCallback(this,"OnAbort"));
      this.FRequest.addEventListener(cErrorMethod,rtl.createSafeCallback(this,"OnError"));
      this.FRequest.addEventListener(cLoadMethod,rtl.createSafeCallback(this,"OnLoad"));
      try {
        this.FRequest.open(cGetMethod,AFileName,true);
        this.FRequest.send();
      } catch ($e) {
        if (pas.SysUtils.Exception.isPrototypeOf($e)) {
          var E = $e;
          if (AError != null) {
            AError(E.FMessage)}
           else throw $e;
        } else throw $e
      };
    };
    this.LoadFromFileP = async function (AFileName) {
      var Result = false;
      Result = await this.InternalLoadFromFileP(AFileName);
      return Result;
    };
    this.ReadString = function (ACount) {
      var Result = "";
      var lBytes = [];
      var lDest = [];
      var lCount = 0;
      if (ACount > (this.GetSize() - this.GetPosition())) ACount = this.GetSize() - this.GetPosition();
      $mod.TBytesHelper.set_Length.call({get: function () {
          return lDest;
        }, set: function (v) {
          lDest = v;
        }},ACount);
      lBytes = rtl.arrayRef(this.GetBytes());
      for (var $l = this.GetPosition(), $end = (ACount + this.GetPosition()) - 1; $l <= $end; $l++) {
        lCount = $l;
        lDest[lCount - this.GetPosition()] = lBytes[lCount];
      };
      Result = this.FEncoding.GetString(lDest);
      this.SetPosition(this.GetPosition() + ACount);
      return Result;
    };
    this.WriteString = function (AString) {
      var lBytes = [];
      var lData = "";
      lBytes = this.FEncoding.GetBytes(AString);
      this.Write$1(lBytes,0,$mod.TBytesHelper.get_Length.call({get: function () {
          return lBytes;
        }, set: function (v) {
          lBytes = v;
        }}));
      lData = this.GetDataString();
      if (lData !== AString) this.WriteString("");
    };
    var $r = this.$rtti;
    $r.addMethod("Create$2",2,[]);
    $r.addMethod("Create$3",2,[["AString",rtl.string,2]]);
    $r.addMethod("Create$4",2,[["AString",rtl.string,2],["AEncoding",pas.SysUtils.$rtti["TEncoding"]],["AOwnsEncoding",rtl.boolean]]);
  });
  rtl.createInterface(this,"IInterfaceList","{285DEA8A-B865-11D1-AAA7-00C04FB17A72}",["Add","Clear","Delete","Exchange","Expand","First","get_Capacity","get_Count","get_Items","IndexOf","IndexOfItem","Insert","Last","Lock","Remove","RemoveItem","set_Capacity","set_Count","set_Items","Unlock"],pas.System.IUnknown,function () {
    var $r = this.$rtti;
    $r.addMethod("Add",1,[["AItem",pas.System.$rtti["IUnknown"],2]],rtl.longint);
    $r.addMethod("Clear",0,[]);
    $r.addMethod("Delete",0,[["AIndex",rtl.longint,2]]);
    $r.addMethod("Exchange",0,[["AIndex1",rtl.longint,2],["AIndex2",rtl.longint,2]]);
    $r.addMethod("Expand",1,[],$mod.$rtti["TInterfaceList"]);
    $r.addMethod("First",1,[],pas.System.$rtti["IUnknown"]);
    $r.addMethod("get_Capacity",1,[],rtl.longint);
    $r.addMethod("get_Count",1,[],rtl.longint);
    $r.addMethod("get_Items",1,[["AIndex",rtl.longint,2]],pas.System.$rtti["IUnknown"]);
    $r.addMethod("IndexOf",1,[["AItem",pas.System.$rtti["IUnknown"],2]],rtl.longint);
    $r.addMethod("IndexOfItem",1,[["AItem",pas.System.$rtti["IUnknown"],2],["ADirection",pas.Types.$rtti["TDirection"],2]],rtl.longint);
    $r.addMethod("Insert",0,[["AIndex",rtl.longint,2],["AItem",pas.System.$rtti["IUnknown"],2]]);
    $r.addMethod("Last",1,[],pas.System.$rtti["IUnknown"]);
    $r.addMethod("Lock",0,[]);
    $r.addMethod("Remove",1,[["AItem",pas.System.$rtti["IUnknown"],2]],rtl.longint);
    $r.addMethod("RemoveItem",1,[["AItem",pas.System.$rtti["IUnknown"],2],["ADirection",pas.Types.$rtti["TDirection"],2]],rtl.longint);
    $r.addMethod("set_Capacity",0,[["AValue",rtl.longint,2]]);
    $r.addMethod("set_Count",0,[["AValue",rtl.longint,2]]);
    $r.addMethod("set_Items",0,[["AIndex",rtl.longint,2],["AItem",pas.System.$rtti["IUnknown"],2]]);
    $r.addMethod("Unlock",0,[]);
    $r.addProperty("Count",3,rtl.longint,"get_Count","set_Count");
    $r.addProperty("Items",3,pas.System.$rtti["IUnknown"],"get_Items","set_Items");
  });
  rtl.createClass(this,"TInterfaceListEnumerator",pas.System.TObject,function () {
    this.$init = function () {
      pas.System.TObject.$init.call(this);
      this.FIndex = 0;
      this.FInterfaceList = null;
    };
    this.$final = function () {
      this.FInterfaceList = undefined;
      pas.System.TObject.$final.call(this);
    };
    this.get_Current = function () {
      var Result = null;
      var $ok = false;
      try {
        Result = rtl.setIntfL(Result,this.FInterfaceList.get_Items(this.FIndex),true);
        $ok = true;
      } finally {
        if (!$ok) rtl._Release(Result);
      };
      return Result;
    };
    this.Create$1 = function (AInterfaceList) {
      pas.System.TObject.Create.call(this);
      this.FIndex = -1;
      this.FInterfaceList = AInterfaceList;
      return this;
    };
    this.MoveNext = function () {
      var Result = false;
      Result = this.FIndex < (this.FInterfaceList.get_Count() - 1);
      if (Result) this.FIndex += 1;
      return Result;
    };
  });
  rtl.createInterface(this,"IInterfaceListEx","{FDB39D70-65B9-4995-9436-6084ACA05DB3}",["GetEnumerator"],this.IInterfaceList,function () {
    var $r = this.$rtti;
    $r.addMethod("GetEnumerator",1,[],$mod.$rtti["TInterfaceListEnumerator"]);
  });
  this.$rtti.$RefToProcVar("TCompareItems",{procsig: rtl.newTIProcSig([["ALeft",pas.System.$rtti["IUnknown"],2],["ARight",pas.System.$rtti["IUnknown"],2]],pas.Math.$rtti["TValueRelationship"])});
  rtl.createInterface(this,"IInterfaceListEx2","{4FE71218-0F8F-4027-B050-5E84E2202604}",["Sort"],this.IInterfaceList,function () {
    var $r = this.$rtti;
    $r.addMethod("Sort",0,[["ACompare",$mod.$rtti["TCompareItems"],2]]);
  });
  rtl.createClass(this,"TInterfaceList",pas.System.TInterfacedObject,function () {
    this.$init = function () {
      pas.System.TInterfacedObject.$init.call(this);
      this.FList = null;
    };
    this.$final = function () {
      this.FList = undefined;
      pas.System.TInterfacedObject.$final.call(this);
    };
    this.Add = function (AItem) {
      var Result = 0;
      Result = this.FList.Add(null);
      this.set_Items(Result,AItem);
      return Result;
    };
    this.Clear = function () {
      var lCount = 0;
      for (var $l = 0, $end = this.FList.FCount - 1; $l <= $end; $l++) {
        lCount = $l;
        this.set_Items(lCount,null);
      };
      this.FList.Clear();
    };
    this.Delete = function (AIndex) {
      this.set_Items(AIndex,null);
      this.FList.Delete(AIndex);
    };
    this.Exchange = function (AIndex1, AIndex2) {
      this.FList.Exchange(AIndex1,AIndex2);
    };
    this.Expand = function () {
      var Result = null;
      this.FList.Expand();
      Result = this;
      return Result;
    };
    this.First = function () {
      var Result = null;
      var $ok = false;
      try {
        if (this.get_Count() > 0) {
          Result = rtl.setIntfL(Result,this.get_Items(0),true)}
         else Result = rtl.setIntfL(Result,null);
        $ok = true;
      } finally {
        if (!$ok) rtl._Release(Result);
      };
      return Result;
    };
    this.GetEnumerator = function () {
      var Result = null;
      Result = $mod.TInterfaceListEnumerator.$create("Create$1",[this]);
      return Result;
    };
    this.get_Capacity = function () {
      var Result = 0;
      Result = this.FList.FCapacity;
      return Result;
    };
    this.get_Count = function () {
      var Result = 0;
      Result = this.FList.FCount;
      return Result;
    };
    this.get_Items = function (AIndex) {
      var Result = null;
      var $ok = false;
      try {
        Result = rtl.setIntfL(Result,rtl.getObject(this.FList.Get(AIndex)));
        $ok = true;
      } finally {
        if (!$ok) rtl._Release(Result);
      };
      return Result;
    };
    this.IndexOf = function (AItem) {
      var Result = 0;
      Result = this.IndexOfItem(AItem,pas.Types.TDirection.FromBeginning);
      return Result;
    };
    this.IndexOfItem = function (AItem, ADirection) {
      var Result = 0;
      Result = this.FList.IndexOfItem(AItem,ADirection);
      return Result;
    };
    this.Insert = function (AIndex, AItem) {
      this.FList.Insert(AIndex,null);
      this.set_Items(AIndex,AItem);
    };
    this.Last = function () {
      var Result = null;
      var $ok = false;
      try {
        Result = rtl.setIntfL(Result,this.get_Items(this.get_Count() - 1),true);
        $ok = true;
      } finally {
        if (!$ok) rtl._Release(Result);
      };
      return Result;
    };
    this.Lock = function () {
    };
    this.Remove = function (AItem) {
      var Result = 0;
      Result = this.RemoveItem(AItem,pas.Types.TDirection.FromBeginning);
      return Result;
    };
    this.RemoveItem = function (AItem, ADirection) {
      var Result = 0;
      Result = this.FList.IndexOfItem(AItem,ADirection);
      if (Result > -1) this.Delete(Result);
      return Result;
    };
    this.set_Capacity = function (AValue) {
      this.FList.SetCapacity(AValue);
    };
    this.set_Count = function (AValue) {
      this.FList.SetCount(AValue);
    };
    this.set_Items = function (AIndex, AItem) {
      if (this.FList.Get(AIndex) != null) rtl.getObject(this.FList.Get(AIndex))._Release();
      this.FList.Put(AIndex,AItem);
      if (AItem !== null) AItem._AddRef();
    };
    this.Sort = function (ACompare) {
      $impl.FCompare = ACompare;
      try {
        this.FList.Sort($impl.InternalCompare);
      } finally {
        $impl.FCompare = null;
      };
    };
    this.Unlock = function () {
    };
    this.Create$1 = function () {
      pas.System.TObject.Create.call(this);
      this.FList = pas.Classes.TFPList.$create("Create");
      return this;
    };
    this.Destroy = function () {
      this.Clear();
      rtl.free(this,"FList");
      pas.System.TObject.Destroy.call(this);
    };
    rtl.addIntf(this,$mod.IInterfaceList);
    rtl.addIntf(this,$mod.IInterfaceListEx);
    rtl.addIntf(this,$mod.IInterfaceListEx2);
    rtl.addIntf(this,pas.System.IUnknown);
  });
  rtl.createClass(this,"TStringBuilder",pas.System.TObject,function () {
    this.$init = function () {
      pas.System.TObject.$init.call(this);
      this.FData = "";
    };
    this.get_Length = function () {
      var Result = 0;
      Result = pas.SysUtils.TStringHelper.GetLength.call({p: this, get: function () {
          return this.p.FData;
        }, set: function (v) {
          this.p.FData = v;
        }});
      return Result;
    };
    this.set_Length = function (AValue) {
      pas.SysUtils.TStringHelper.Set_Length.call({p: this, get: function () {
          return this.p.FData;
        }, set: function (v) {
          this.p.FData = v;
        }},AValue);
    };
    this.Create$1 = function (AValue) {
      pas.System.TObject.Create.call(this);
      this.FData = AValue;
      return this;
    };
    this.Append = function (AValue) {
      var Result = null;
      Result = this.Append$1($mod.TLongIntHelper.ToString.call({get: function () {
          return AValue;
        }, set: function (v) {
          rtl.raiseE("EPropReadOnly");
        }}));
      return Result;
    };
    this.Append$1 = function (AValue) {
      var Result = null;
      this.FData = this.FData + AValue;
      Result = this;
      return Result;
    };
    this.Insert = function (AIndex, AValue) {
      var Result = null;
      Result = this.Insert$1(AIndex,$mod.TLongIntHelper.ToString.call({get: function () {
          return AValue;
        }, set: function (v) {
          rtl.raiseE("EPropReadOnly");
        }}));
      return Result;
    };
    this.Insert$1 = function (AIndex, AValue) {
      var Result = null;
      pas.SysUtils.TStringHelper.Insert.call({p: this, get: function () {
          return this.p.FData;
        }, set: function (v) {
          this.p.FData = v;
        }},AIndex,AValue);
      Result = this;
      return Result;
    };
    this.ToString = function () {
      var Result = "";
      Result = this.FData;
      return Result;
    };
  });
  rtl.recNewT(this,"TSysInfo",function () {
    this.screenSize = "";
    this.browser = "";
    this.browserversion = "";
    this.browsermajorVersion = "";
    this.mobile = false;
    this.os = "";
    this.osVersion = "";
    this.cookieEnabled = false;
    this.flashVersion = "";
    this.$eq = function (b) {
      return (this.screenSize === b.screenSize) && (this.browser === b.browser) && (this.browserversion === b.browserversion) && (this.browsermajorVersion === b.browsermajorVersion) && (this.mobile === b.mobile) && (this.os === b.os) && (this.osVersion === b.osVersion) && (this.cookieEnabled === b.cookieEnabled) && (this.flashVersion === b.flashVersion);
    };
    this.$assign = function (s) {
      this.screenSize = s.screenSize;
      this.browser = s.browser;
      this.browserversion = s.browserversion;
      this.browsermajorVersion = s.browsermajorVersion;
      this.mobile = s.mobile;
      this.os = s.os;
      this.osVersion = s.osVersion;
      this.cookieEnabled = s.cookieEnabled;
      this.flashVersion = s.flashVersion;
      return this;
    };
    var $r = $mod.$rtti.$Record("TSysInfo",{});
    $r.addField("screenSize",rtl.string);
    $r.addField("browser",rtl.string);
    $r.addField("browserversion",rtl.string);
    $r.addField("browsermajorVersion",rtl.string);
    $r.addField("mobile",rtl.boolean);
    $r.addField("os",rtl.string);
    $r.addField("osVersion",rtl.string);
    $r.addField("cookieEnabled",rtl.boolean);
    $r.addField("flashVersion",rtl.string);
  });
  rtl.createHelper(this,"TJsonToObjectHelper",null,function () {
    this.FromJSON = function (JSONValue) {
      var $Self = this;
      var Context = pas.RTTI.TRTTIContext.$new();
      var TypeInfo = null;
      var v = pas.RTTI.TValue.$new();
      function ListProperties(AObject, jsv) {
        for (var key in jsv) {
          if (jsv.hasOwnProperty(key)) {
            //console.log(key + " / " + jsv[key]);
            SetProperty(AObject, key, jsv[key]);
          }
        };
      };
      function SetProperty(AObject, Name, AValue) {
        var pn = "";
        var Prop = null;
        var PropTypeInfo = null;
        if (Name === "") return;
        TypeInfo = Context.GetType$1(AObject.$class.ClassType());
        Prop = TypeInfo.GetProperty(Name);
        if (Prop != null) {
          pn = Prop.GetPropertyType().GetName();
          PropTypeInfo = Prop.GetPropertyType();
          if ((PropTypeInfo.GetTypeKind() === pas.System.TTypeKind.tkClass) && Prop.GetValue(AObject).IsObject()) {
            ListProperties(Prop.GetValue(AObject).AsObject(),AValue);
          };
          if (pn === "string") {
            v.$assign(pas.RTTI.TValue.From$G3("" + AValue));
            Prop.SetValue(AObject,v);
          };
          if (pn === "longint") {
            v.$assign(pas.RTTI.TValue.From$G1(rtl.trunc(AValue)));
            Prop.SetValue(AObject,v);
          };
          if (pn === "boolean") {
            v.$assign(pas.RTTI.TValue.From$G4(("" + AValue) === "true"));
            Prop.SetValue(AObject,v);
          };
          if (pn === "double") {
            v.$assign(pas.RTTI.TValue.From$G2(rtl.getNumber(AValue)));
            Prop.SetValue(AObject,v);
          };
          if (pn === "TDateTime") {
            v.$assign(pas.RTTI.TValue.From$G2(pas["WEBLib.REST"].TRESTClient.IsoToDateTime$1("" + AValue,true)));
            Prop.SetValue(AObject,v);
          };
          if (pn === "TDate") {
            v.$assign(pas.RTTI.TValue.From$G2(pas["WEBLib.REST"].TRESTClient.IsoToDate("" + AValue)));
            Prop.SetValue(AObject,v);
          };
          if (pn === "TTime") {
            v.$assign(pas.RTTI.TValue.From$G2(pas["WEBLib.REST"].TRESTClient.IsoToTime("" + AValue)));
            Prop.SetValue(AObject,v);
          };
        };
      };
      Context.$assign(pas.RTTI.TRTTIContext.Create());
      SetProperty($Self,"",null);
      ListProperties($Self,JSONValue);
      Context.Free();
    };
    this.FromJSON$1 = function (JSONValue) {
      var jsv = undefined;
      jsv = null;
      jsv = JSON.parse(JSONValue);
      $mod.TJsonToObjectHelper.FromJSON.call(this,jsv);
    };
    this.ToJSON = function () {
      var $Self = this;
      var Result = undefined;
      var Context = pas.RTTI.TRTTIContext.$new();
      var TypeInfo = null;
      var Prop = null;
      var jsonstr = "";
      var pn = "";
      var res = undefined;
      var PropTypeInfo = null;
      function ListProperties(AObject, ATypeInfo, js) {
        var sub = "";
        var sep = "";
        var subn = "";
        for (var $in = ATypeInfo.GetProperties(), $l = 0, $end = rtl.length($in) - 1; $l <= $end; $l++) {
          Prop = $in[$l];
          PropTypeInfo = Prop.GetPropertyType();
          sep = "";
          if (js.get().length > 1) sep = ",";
          subn = Prop.GetName();
          pn = Prop.GetPropertyType().GetName();
          if ((PropTypeInfo.GetTypeKind() === pas.System.TTypeKind.tkClass) && Prop.GetValue(AObject).IsObject()) {
            sub = "{";
            ListProperties(Prop.GetValue(AObject).AsObject(),Prop.GetPropertyType(),{get: function () {
                return sub;
              }, set: function (v) {
                sub = v;
              }});
            sub = sub + "}";
            js.set(js.get() + sep + '"' + subn + '":' + sub);
            continue;
          };
          if (pn === "string") {
            js.set(js.get() + sep + '"' + Prop.GetName() + '":' + '"' + Prop.GetValue(AObject).ToString() + '"');
          };
          if (pn === "longint") {
            js.set(js.get() + sep + '"' + Prop.GetName() + '":' + pas.SysUtils.IntToStr(Prop.GetValue(AObject).AsInteger()));
          };
          if (pn === "boolean") {
            if (Prop.GetValue(AObject).AsBoolean()) {
              js.set(js.get() + sep + '"' + Prop.GetName() + '":' + "true")}
             else js.set(js.get() + sep + '"' + Prop.GetName() + '":' + "false");
          };
          if (pn === "double") {
            js.set(js.get() + sep + '"' + Prop.GetName() + '":' + pas.SysUtils.FloatToStr(Prop.GetValue(AObject).AsExtended()));
          };
          if (pn === "TDateTime") {
            js.set(js.get() + sep + '"' + Prop.GetName() + '":' + '"' + pas["WEBLib.REST"].TRESTClient.DateTimeToWL(Prop.GetValue(AObject).AsExtended()) + '"');
          };
          if (pn === "TDate") {
            js.set(js.get() + sep + '"' + Prop.GetName() + '":' + '"' + pas["WEBLib.REST"].TRESTClient.DateToWL(Prop.GetValue(AObject).AsExtended()) + '"');
          };
          if (pn === "TTime") {
            js.set(js.get() + sep + '"' + Prop.GetName() + '":' + '"' + pas["WEBLib.REST"].TRESTClient.TimeToWL(Prop.GetValue(AObject).AsExtended()) + '"');
          };
        };
      };
      Context.$assign(pas.RTTI.TRTTIContext.Create());
      TypeInfo = Context.GetType$1($Self.$class.ClassType());
      jsonstr = "{";
      ListProperties($Self,TypeInfo,{get: function () {
          return jsonstr;
        }, set: function (v) {
          jsonstr = v;
        }});
      jsonstr = jsonstr + "}";
      res = JSON.parse(jsonstr);
      Result = res;
      Context.Free();
      return Result;
    };
  });
  this.UseVariable = function (AValue) {
  };
  this.UseVariable$1 = function (AValue) {
  };
  this.UseVariable$2 = function (AValue) {
  };
  this.ArrayBufferToBase64 = function (Buffer) {
    var Result = "";
    function _arrayBufferToBase64(buf) {
    var binary = '';
    var bytes = new Uint8Array(buf);
    var len = bytes.byteLength;
    for (var i = 0; i < len; i++) {
        binary += String.fromCharCode( bytes[i] );
    }
    return window.btoa(binary);
    }
    Result = _arrayBufferToBase64(Buffer);
    return Result;
  };
  this.Base64ToArrayBuffer = function (Base64) {
    var Result = null;
    function _base64ToArrayBuffer(data) {
            var binary_string = window.atob(data);
            var len = binary_string.length;
            var bytes = new Uint8Array(len);
            for (var i = 0; i < len; i++) {
                bytes[i] = binary_string.charCodeAt(i);
            }
            return bytes.buffer;
        }
    
        Result = _base64ToArrayBuffer(Base64);
    return Result;
  };
  this.StringToBase64 = function (AValue) {
    var Result = "";
    var res = "";
    res = window.btoa(AValue);
    Result = res;
    return Result;
  };
  this.Base64ToString = function (AValue) {
    var Result = "";
    var res = "";
    res = window.atob(AValue);
    Result = res;
    return Result;
  };
  var cSizeOfDouble = 8;
  this.SizeOf = function (AValue) {
    var Result = 0;
    Result = 8;
    return Result;
  };
  var cSizeOfInteger = 4;
  this.SizeOf$1 = function (AValue) {
    var Result = 0;
    Result = 4;
    return Result;
  };
  this.InsertAfter = function (newNode, referenceNode) {
    referenceNode.parentNode.insertBefore(newNode,referenceNode.nextSibling);
  };
  this.MatchStrEx = function (AValue1, AValue2, ACaseSensitive) {
    var Result = false;
    var ch = "\x00";
    var lastop = "\x00";
    var sep = 0;
    var cp = 0;
    var res = false;
    var newres = false;
    var CharArray = [];
    AValue1 = pas.SysUtils.Trim(AValue1);
    AValue1 = $impl.StripLogicSpaces(AValue1);
    sep = -1;
    if ($impl.VarPos("=",AValue1,{get: function () {
        return sep;
      }, set: function (v) {
        sep = v;
      }}) === 1) pas.System.Delete({get: function () {
        return AValue1;
      }, set: function (v) {
        AValue1 = v;
      }},sep,1);
    lastop = "\x00";
    res = true;
    CharArray = rtl.arraySetLength(CharArray,"\x00",5);
    CharArray[0] = "(";
    CharArray[1] = ";";
    CharArray[2] = "^";
    CharArray[3] = "&";
    CharArray[4] = "|";
    if (AValue1 === "") {
      Result = AValue2 === "";
      return Result;
    };
    if ((AValue1 !== "*") && (AValue2 === "")) {
      Result = false;
      return Result;
    };
    do {
      ch = $impl.FirstChar(CharArray,AValue1,{get: function () {
          return sep;
        }, set: function (v) {
          sep = v;
        }});
      if (ch !== "\x00") {
        if ((AValue1.length > 0) && (AValue1.charAt(0) === "(") && (pas.System.Pos("(",AValue1) > 0)) {
          cp = $impl.ClosingParenthesis(AValue1);
          newres = $mod.MatchStrEx(pas.System.Copy(AValue1,2,cp - 2),AValue2,ACaseSensitive);
          pas.System.Delete({get: function () {
              return AValue1;
            }, set: function (v) {
              AValue1 = v;
            }},1,cp);
        } else {
          newres = $mod.MatchStr(pas.System.Copy(AValue1,1,sep - 1),AValue2,ACaseSensitive);
          pas.System.Delete({get: function () {
              return AValue1;
            }, set: function (v) {
              AValue1 = v;
            }},1,sep);
        };
        if (lastop === "\x00") {
          res = newres}
         else {
          var $tmp = lastop;
          if (($tmp === ";") || ($tmp === "^") || ($tmp === "|")) {
            res = res || newres}
           else if ($tmp === "&") res = res && newres;
        };
        lastop = ch;
      };
    } while (!(ch === "\x00"));
    newres = $mod.MatchStr(AValue1,AValue2,ACaseSensitive);
    if (lastop === "\x00") {
      res = newres}
     else {
      var $tmp1 = lastop;
      if (($tmp1 === ";") || ($tmp1 === "^") || ($tmp1 === "|")) {
        res = res || newres}
       else if ($tmp1 === "&") res = res && newres;
    };
    Result = res;
    return Result;
  };
  this.MatchStr = function (AValue1, AValue2, ACaseSensitive) {
    var Result = false;
    if (ACaseSensitive) {
      Result = $impl.Matches(AValue1,AValue2)}
     else Result = $impl.Matches(pas.SysUtils.UpperCase(AValue1),pas.SysUtils.UpperCase(AValue2));
    return Result;
  };
  this.SelectElementContents = function (AElement) {
    if (window.getSelection && document.createRange) {
        var sel = window.getSelection();
        var range = document.createRange();
        range.selectNodeContents(AElement);
        sel.removeAllRanges();
        sel.addRange(range);
    } else if (document.selection && document.body.createTextRange) {
        var textRange = document.body.createTextRange();
        textRange.moveToElementText(AElement);
        textRange.select();
    };
  };
  this.FormatProp = function (AFmt, AArgs) {
    var Result = "";
    Result = pas.SysUtils.Format$1(AFmt,AArgs,pas.SysUtils.TFormatSettings.Invariant());
    return Result;
  };
  this.StringIsFloat = function (N) {
    var Result = false;
    var f = 0.0;
    Result = pas.SysUtils.TryStrToFloat$2(N,{get: function () {
        return f;
      }, set: function (v) {
        f = v;
      }});
    return Result;
  };
  this.StringIsInteger = function (N) {
    var Result = false;
    var I = 0;
    Result = true;
    if (pas.SysUtils.Trim(N) === "") return false;
    if ((pas.SysUtils.Trim(N).length > 1) && (pas.SysUtils.Trim(N).charAt(0) === "0")) return false;
    if (!(N.charCodeAt(I - 1) in rtl.createSet(null,48,57,45))) return false;
    for (var $l = 2, $end = N.length; $l <= $end; $l++) {
      I = $l;
      if (!(N.charCodeAt(I - 1) in rtl.createSet(null,48,57))) {
        Result = false;
        break;
      };
    };
    return Result;
  };
  this.MD5Hash = function (N) {
    var Result = "";
    var h = "";
    function md5(inputString) {
      var hc="0123456789abcdef";
      function rh(n) {var j,s="";for(j=0;j<=3;j++) s+=hc.charAt((n>>(j*8+4))&0x0F)+hc.charAt((n>>(j*8))&0x0F);return s;}
      function ad(x,y) {var l=(x&0xFFFF)+(y&0xFFFF);var m=(x>>16)+(y>>16)+(l>>16);return (m<<16)|(l&0xFFFF);}
      function rl(n,c)            {return (n<<c)|(n>>>(32-c));}
      function cm(q,a,b,x,s,t)    {return ad(rl(ad(ad(a,q),ad(x,t)),s),b);}
      function ff(a,b,c,d,x,s,t)  {return cm((b&c)|((~b)&d),a,b,x,s,t);}
      function gg(a,b,c,d,x,s,t)  {return cm((b&d)|(c&(~d)),a,b,x,s,t);}
      function hh(a,b,c,d,x,s,t)  {return cm(b^c^d,a,b,x,s,t);}
      function ii(a,b,c,d,x,s,t)  {return cm(c^(b|(~d)),a,b,x,s,t);}
      function sb(x) {
          var i;var nblk=((x.length+8)>>6)+1;var blks=new Array(nblk*16);for(i=0;i<nblk*16;i++) blks[i]=0;
          for(i=0;i<x.length;i++) blks[i>>2]|=x.charCodeAt(i)<<((i%4)*8);
          blks[i>>2]|=0x80<<((i%4)*8);blks[nblk*16-2]=x.length*8;return blks;
      }
      var i,x=sb(inputString),a=1732584193,b=-271733879,c=-1732584194,d=271733878,olda,oldb,oldc,oldd;
      for(i=0;i<x.length;i+=16) {olda=a;oldb=b;oldc=c;oldd=d;
          a=ff(a,b,c,d,x[i+ 0], 7, -680876936);d=ff(d,a,b,c,x[i+ 1],12, -389564586);c=ff(c,d,a,b,x[i+ 2],17,  606105819);
          b=ff(b,c,d,a,x[i+ 3],22,-1044525330);a=ff(a,b,c,d,x[i+ 4], 7, -176418897);d=ff(d,a,b,c,x[i+ 5],12, 1200080426);
          c=ff(c,d,a,b,x[i+ 6],17,-1473231341);b=ff(b,c,d,a,x[i+ 7],22,  -45705983);a=ff(a,b,c,d,x[i+ 8], 7, 1770035416);
          d=ff(d,a,b,c,x[i+ 9],12,-1958414417);c=ff(c,d,a,b,x[i+10],17,     -42063);b=ff(b,c,d,a,x[i+11],22,-1990404162);
          a=ff(a,b,c,d,x[i+12], 7, 1804603682);d=ff(d,a,b,c,x[i+13],12,  -40341101);c=ff(c,d,a,b,x[i+14],17,-1502002290);
          b=ff(b,c,d,a,x[i+15],22, 1236535329);a=gg(a,b,c,d,x[i+ 1], 5, -165796510);d=gg(d,a,b,c,x[i+ 6], 9,-1069501632);
          c=gg(c,d,a,b,x[i+11],14,  643717713);b=gg(b,c,d,a,x[i+ 0],20, -373897302);a=gg(a,b,c,d,x[i+ 5], 5, -701558691);
          d=gg(d,a,b,c,x[i+10], 9,   38016083);c=gg(c,d,a,b,x[i+15],14, -660478335);b=gg(b,c,d,a,x[i+ 4],20, -405537848);
          a=gg(a,b,c,d,x[i+ 9], 5,  568446438);d=gg(d,a,b,c,x[i+14], 9,-1019803690);c=gg(c,d,a,b,x[i+ 3],14, -187363961);
          b=gg(b,c,d,a,x[i+ 8],20, 1163531501);a=gg(a,b,c,d,x[i+13], 5,-1444681467);d=gg(d,a,b,c,x[i+ 2], 9,  -51403784);
          c=gg(c,d,a,b,x[i+ 7],14, 1735328473);b=gg(b,c,d,a,x[i+12],20,-1926607734);a=hh(a,b,c,d,x[i+ 5], 4,    -378558);
          d=hh(d,a,b,c,x[i+ 8],11,-2022574463);c=hh(c,d,a,b,x[i+11],16, 1839030562);b=hh(b,c,d,a,x[i+14],23,  -35309556);
          a=hh(a,b,c,d,x[i+ 1], 4,-1530992060);d=hh(d,a,b,c,x[i+ 4],11, 1272893353);c=hh(c,d,a,b,x[i+ 7],16, -155497632);
          b=hh(b,c,d,a,x[i+10],23,-1094730640);a=hh(a,b,c,d,x[i+13], 4,  681279174);d=hh(d,a,b,c,x[i+ 0],11, -358537222);
          c=hh(c,d,a,b,x[i+ 3],16, -722521979);b=hh(b,c,d,a,x[i+ 6],23,   76029189);a=hh(a,b,c,d,x[i+ 9], 4, -640364487);
          d=hh(d,a,b,c,x[i+12],11, -421815835);c=hh(c,d,a,b,x[i+15],16,  530742520);b=hh(b,c,d,a,x[i+ 2],23, -995338651);
          a=ii(a,b,c,d,x[i+ 0], 6, -198630844);d=ii(d,a,b,c,x[i+ 7],10, 1126891415);c=ii(c,d,a,b,x[i+14],15,-1416354905);
          b=ii(b,c,d,a,x[i+ 5],21,  -57434055);a=ii(a,b,c,d,x[i+12], 6, 1700485571);d=ii(d,a,b,c,x[i+ 3],10,-1894986606);
          c=ii(c,d,a,b,x[i+10],15,   -1051523);b=ii(b,c,d,a,x[i+ 1],21,-2054922799);a=ii(a,b,c,d,x[i+ 8], 6, 1873313359);
          d=ii(d,a,b,c,x[i+15],10,  -30611744);c=ii(c,d,a,b,x[i+ 6],15,-1560198380);b=ii(b,c,d,a,x[i+13],21, 1309151649);
          a=ii(a,b,c,d,x[i+ 4], 6, -145523070);d=ii(d,a,b,c,x[i+11],10,-1120210379);c=ii(c,d,a,b,x[i+ 2],15,  718787259);
          b=ii(b,c,d,a,x[i+ 9],21, -343485551);a=ad(a,olda);b=ad(b,oldb);c=ad(c,oldc);d=ad(d,oldd);
      }
      return rh(a)+rh(b)+rh(c)+rh(d);
    }
    h = md5(N);
    Result = h;
    return Result;
  };
  this.GetSysInfo = function () {
    var Result = $mod.TSysInfo.$new();
    function GetInfo(window)
        {
            var unknown = '-';
    
            // screen
            var screenSize = '';
            if (screen.width) {
                var width = (screen.width) ? screen.width : '';
                var height = (screen.height) ? screen.height : '';
                screenSize += '' + width + " x " + height;
            }
    
            // browser
            var nVer = navigator.appVersion;
            var nAgt = navigator.userAgent;
            var browser = navigator.appName;
            var version = '' + parseFloat(navigator.appVersion);
            var majorVersion = parseInt(navigator.appVersion, 10);
            var nameOffset, verOffset, ix;
    
            // Opera
            if ((verOffset = nAgt.indexOf('Opera')) != -1) {
                browser = 'Opera';
                version = nAgt.substring(verOffset + 6);
                if ((verOffset = nAgt.indexOf('Version')) != -1) {
                    version = nAgt.substring(verOffset + 8);
                }
            }
            // Opera Next
            if ((verOffset = nAgt.indexOf('OPR')) != -1) {
                browser = 'Opera';
                version = nAgt.substring(verOffset + 4);
            }
            // Legacy Edge
            else if ((verOffset = nAgt.indexOf('Edge')) != -1) {
                browser = 'Microsoft Legacy Edge';
                version = nAgt.substring(verOffset + 5);
            }
            // Edge (Chromium)
            else if ((verOffset = nAgt.indexOf('Edg')) != -1) {
                browser = 'Microsoft Edge';
                version = nAgt.substring(verOffset + 4);
            }
            // MSIE
            else if ((verOffset = nAgt.indexOf('MSIE')) != -1) {
                browser = 'Microsoft Internet Explorer';
                version = nAgt.substring(verOffset + 5);
            }
            // Chrome
            else if ((verOffset = nAgt.indexOf('Chrome')) != -1) {
                browser = 'Chrome';
                version = nAgt.substring(verOffset + 7);
            }
            // Safari
            else if ((verOffset = nAgt.indexOf('Safari')) != -1) {
                browser = 'Safari';
                version = nAgt.substring(verOffset + 7);
                if ((verOffset = nAgt.indexOf('Version')) != -1) {
                    version = nAgt.substring(verOffset + 8);
                }
            }
            // Firefox
            else if ((verOffset = nAgt.indexOf('Firefox')) != -1) {
                browser = 'Firefox';
                version = nAgt.substring(verOffset + 8);
            }
            // MSIE 11+
            else if (nAgt.indexOf('Trident/') != -1) {
                browser = 'Microsoft Internet Explorer';
                version = nAgt.substring(nAgt.indexOf('rv:') + 3);
            }
            // Other browsers
            else if ((nameOffset = nAgt.lastIndexOf(' ') + 1) < (verOffset = nAgt.lastIndexOf('/'))) {
                browser = nAgt.substring(nameOffset, verOffset);
                version = nAgt.substring(verOffset + 1);
                if (browser.toLowerCase() == browser.toUpperCase()) {
                    browser = navigator.appName;
                }
            }
            // trim the version string
            if ((ix = version.indexOf(';')) != -1) version = version.substring(0, ix);
            if ((ix = version.indexOf(' ')) != -1) version = version.substring(0, ix);
            if ((ix = version.indexOf(')')) != -1) version = version.substring(0, ix);
    
            majorVersion = parseInt('' + version, 10);
            if (isNaN(majorVersion)) {
                version = '' + parseFloat(navigator.appVersion);
                majorVersion = parseInt(navigator.appVersion, 10);
            }
    
            // mobile version
            var mobile = /Mobile|mini|Fennec|Android|iP(ad|od|hone)/.test(nVer);
    
            // cookie
            var cookieEnabled = (navigator.cookieEnabled) ? true : false;
    
            if (typeof navigator.cookieEnabled == 'undefined' && !cookieEnabled) {
                document.cookie = 'testcookie';
                cookieEnabled = (document.cookie.indexOf('testcookie') != -1) ? true : false;
            }
    
            // system
            var os = unknown;
            var clientStrings = [
                {s:'Windows 10', r:/(Windows 10.0|Windows NT 10.0)/},
                {s:'Windows 8.1', r:/(Windows 8.1|Windows NT 6.3)/},
                {s:'Windows 8', r:/(Windows 8|Windows NT 6.2)/},
                {s:'Windows 7', r:/(Windows 7|Windows NT 6.1)/},
                {s:'Windows Vista', r:/Windows NT 6.0/},
                {s:'Windows Server 2003', r:/Windows NT 5.2/},
                {s:'Windows XP', r:/(Windows NT 5.1|Windows XP)/},
                {s:'Windows 2000', r:/(Windows NT 5.0|Windows 2000)/},
                {s:'Windows ME', r:/(Win 9x 4.90|Windows ME)/},
                {s:'Windows 98', r:/(Windows 98|Win98)/},
                {s:'Windows 95', r:/(Windows 95|Win95|Windows_95)/},
                {s:'Windows NT 4.0', r:/(Windows NT 4.0|WinNT4.0|WinNT|Windows NT)/},
                {s:'Windows CE', r:/Windows CE/},
                {s:'Windows 3.11', r:/Win16/},
                {s:'Android', r:/Android/},
                {s:'Open BSD', r:/OpenBSD/},
                {s:'Sun OS', r:/SunOS/},
                {s:'Chrome OS', r:/CrOS/},
                {s:'Linux', r:/(Linux|X11(?!.*CrOS))/},
                {s:'iOS', r:/(iPhone|iPad|iPod)/},
                {s:'Mac OS X', r:/Mac OS X/},
                {s:'Mac OS', r:/(Mac OS|MacPPC|MacIntel|Mac_PowerPC|Macintosh)/},
                {s:'QNX', r:/QNX/},
                {s:'UNIX', r:/UNIX/},
                {s:'BeOS', r:/BeOS/},
                {s:'OS/2', r:/OS\/2/},
                {s:'Search Bot', r:/(nuhk|Googlebot|Yammybot|Openbot|Slurp|MSNBot|Ask Jeeves\/Teoma|ia_archiver)/}
            ];
            for (var id in clientStrings) {
                var cs = clientStrings[id];
                if (cs.r.test(nAgt)) {
                    os = cs.s;
                    break;
                }
            }
    
            var osVersion = unknown;
    
            if (/Windows/.test(os)) {
                osVersion = /Windows (.*)/.exec(os)[1];
                os = 'Windows';
            }
    
            switch (os) {
                case 'Mac OS':
                case 'Mac OS X':
                case 'Android':
                    osVersion = /(?:Android|Mac OS|Mac OS X|MacPPC|MacIntel|Mac_PowerPC|Macintosh) ([\.\_\d]+)/.exec(nAgt)[1];
                    break;
    
                case 'iOS':
                    osVersion = /OS (\d+)_(\d+)_?(\d+)?/.exec(nVer);
                    osVersion = osVersion[1] + '.' + osVersion[2] + '.' + (osVersion[3] | 0);
                    break;
            }
    
            // flash (you'll need to include swfobject)
            /* script src="//ajax.googleapis.com/ajax/libs/swfobject/2.2/swfobject.js" */
            var flashVersion = 'no check';
            if (typeof swfobject != 'undefined') {
                var fv = swfobject.getFlashPlayerVersion();
                if (fv.major > 0) {
                    flashVersion = fv.major + '.' + fv.minor + ' r' + fv.release;
                }
                else  {
                    flashVersion = unknown;
                }
            }
           Result.screenSize = screenSize;
           Result.browser = browser;
           Result.browserversion = version;
           Result.browsermajorVersion = majorVersion;
           Result.mobile = mobile;
           Result.os = os;
           Result.osVersion = osVersion;
           Result.cookieEnabled = cookieEnabled;
          }
          GetInfo(window);
    return Result;
  };
  $mod.$implcode = function () {
    $impl.FCompare = null;
    $impl.InternalCompare = function (AItem1, AItem2) {
      var Result = 0;
      Result = $impl.FCompare(rtl.getObject(AItem1),rtl.getObject(AItem2));
      return Result;
    };
    $impl.StripThousandSep = function (ps) {
      var Result = "";
      while (pas.System.Pos(pas.SysUtils.FormatSettings.ThousandSeparator,ps) > 0) pas.System.Delete({get: function () {
          return ps;
        }, set: function (v) {
          ps = v;
        }},pas.System.Pos(pas.SysUtils.FormatSettings.ThousandSeparator,ps),1);
      Result = ps;
      return Result;
    };
    $impl.VarPos = function (ASubValue, AValue, AResult) {
      var Result = 0;
      AResult.set(pas.System.Pos(ASubValue,AValue));
      Result = AResult.get();
      return Result;
    };
    $impl.IsDate = function (AValue, ADate) {
      var Result = false;
      var su = "";
      var ts = "";
      var da = 0;
      var mo = 0;
      var ye = 0;
      var ho = 0;
      var mi = 0;
      var se = 0;
      var err = 0;
      var dp = 0;
      var mp = 0;
      var yp = 0;
      var vp = 0;
      Result = false;
      ts = "";
      su = pas.SysUtils.UpperCase(pas.SysUtils.FormatSettings.ShortDateFormat);
      dp = pas.System.Pos("D",su);
      mp = pas.System.Pos("M",su);
      yp = pas.System.Pos("Y",su);
      da = 0;
      mo = 0;
      ye = 0;
      ho = 0;
      mi = 0;
      se = 0;
      vp = -1;
      if ($impl.VarPos(pas.SysUtils.FormatSettings.DateSeparator,AValue,{get: function () {
          return vp;
        }, set: function (v) {
          vp = v;
        }}) > 0) {
        su = pas.System.Copy(AValue,1,vp - 1);
        if ((dp < mp) && (dp < yp)) {
          pas.System.val$5(su,{get: function () {
              return da;
            }, set: function (v) {
              da = v;
            }},{get: function () {
              return err;
            }, set: function (v) {
              err = v;
            }})}
         else if ((mp < dp) && (mp < yp)) {
          pas.System.val$5(su,{get: function () {
              return mo;
            }, set: function (v) {
              mo = v;
            }},{get: function () {
              return err;
            }, set: function (v) {
              err = v;
            }})}
         else if ((yp < mp) && (yp < dp)) pas.System.val$5(su,{get: function () {
            return ye;
          }, set: function (v) {
            ye = v;
          }},{get: function () {
            return err;
          }, set: function (v) {
            err = v;
          }});
        if (err !== 0) return Result;
        pas.System.Delete({get: function () {
            return AValue;
          }, set: function (v) {
            AValue = v;
          }},1,vp);
        if ($impl.VarPos(pas.SysUtils.FormatSettings.DateSeparator,AValue,{get: function () {
            return vp;
          }, set: function (v) {
            vp = v;
          }}) > 0) {
          su = pas.System.Copy(AValue,1,vp - 1);
          if (((dp > mp) && (dp < yp)) || ((dp > yp) && (dp < mp))) {
            pas.System.val$5(su,{get: function () {
                return da;
              }, set: function (v) {
                da = v;
              }},{get: function () {
                return err;
              }, set: function (v) {
                err = v;
              }})}
           else if (((mp > dp) && (mp < yp)) || ((mp > yp) && (mp < dp))) {
            pas.System.val$5(su,{get: function () {
                return mo;
              }, set: function (v) {
                mo = v;
              }},{get: function () {
                return err;
              }, set: function (v) {
                err = v;
              }})}
           else if (((yp > mp) && (yp < dp)) || ((yp > dp) && (yp < mp))) pas.System.val$5(su,{get: function () {
              return ye;
            }, set: function (v) {
              ye = v;
            }},{get: function () {
              return err;
            }, set: function (v) {
              err = v;
            }});
          if (err !== 0) return Result;
          pas.System.Delete({get: function () {
              return AValue;
            }, set: function (v) {
              AValue = v;
            }},1,vp);
          AValue = pas.SysUtils.Trim(AValue);
          if ($impl.VarPos(" ",AValue,{get: function () {
              return vp;
            }, set: function (v) {
              vp = v;
            }}) > 0) {
            ts = pas.System.Copy(AValue,vp,AValue.length);
            AValue = pas.System.Copy(AValue,1,vp - 1);
          };
          if ((dp > mp) && (dp > yp)) {
            pas.System.val$5(AValue,{get: function () {
                return da;
              }, set: function (v) {
                da = v;
              }},{get: function () {
                return err;
              }, set: function (v) {
                err = v;
              }})}
           else if ((mp > dp) && (mp > yp)) {
            pas.System.val$5(AValue,{get: function () {
                return mo;
              }, set: function (v) {
                mo = v;
              }},{get: function () {
                return err;
              }, set: function (v) {
                err = v;
              }})}
           else if ((yp > mp) && (yp > dp)) pas.System.val$5(AValue,{get: function () {
              return ye;
            }, set: function (v) {
              ye = v;
            }},{get: function () {
              return err;
            }, set: function (v) {
              err = v;
            }});
          if (err !== 0) return Result;
          if (da > 31) return Result;
          if (mo > 12) return Result;
          if (ts !== "") {
            if ($impl.VarPos(pas.SysUtils.FormatSettings.TimeSeparator,ts,{get: function () {
                return vp;
              }, set: function (v) {
                vp = v;
              }}) > 0) {
              su = pas.System.Copy(ts,1,vp - 1);
              pas.System.val$5(su,{get: function () {
                  return ho;
                }, set: function (v) {
                  ho = v;
                }},{get: function () {
                  return err;
                }, set: function (v) {
                  err = v;
                }});
              if (err !== 0) return Result;
              if (ho > 23) return Result;
              pas.System.Delete({get: function () {
                  return ts;
                }, set: function (v) {
                  ts = v;
                }},1,vp);
              if ($impl.VarPos(pas.SysUtils.FormatSettings.TimeSeparator,ts,{get: function () {
                  return vp;
                }, set: function (v) {
                  vp = v;
                }}) > 0) {
                su = pas.System.Copy(ts,1,vp - 1);
                pas.System.val$5(su,{get: function () {
                    return mi;
                  }, set: function (v) {
                    mi = v;
                  }},{get: function () {
                    return err;
                  }, set: function (v) {
                    err = v;
                  }});
                if (err !== 0) return Result;
                pas.System.Delete({get: function () {
                    return ts;
                  }, set: function (v) {
                    ts = v;
                  }},1,vp);
                pas.System.val$5(ts,{get: function () {
                    return se;
                  }, set: function (v) {
                    se = v;
                  }},{get: function () {
                    return err;
                  }, set: function (v) {
                    err = v;
                  }});
                if (err !== 0) return Result;
                if (se > 60) return Result;
              } else {
                pas.System.val$5(su,{get: function () {
                    return mi;
                  }, set: function (v) {
                    mi = v;
                  }},{get: function () {
                    return err;
                  }, set: function (v) {
                    err = v;
                  }});
                if (err !== 0) return Result;
              };
              if (mi > 59) return Result;
              Result = true;
            };
          } else Result = true;
          try {
            ADate.set(pas.SysUtils.EncodeDate(ye,mo,da) + pas.SysUtils.EncodeTime(ho,mi,se,0));
          } catch ($e) {
            Result = false;
          };
        };
      };
      return Result;
    };
    var larger = ">";
    var smaller = "<";
    var logand = "&";
    var logor = "^";
    var asterix = "*";
    var qmark = "?";
    var negation = "!";
    $impl.Matches = function (s0a, s1a) {
      var Result = false;
      var matching = false;
      var done = false;
      var len = 0;
      var lastchar = "\x00";
      var s0 = 0;
      var s1 = 0;
      var s2 = 0;
      var s3 = 0;
      var oksmaller = false;
      var oklarger = false;
      var negflag = false;
      var compstr = "";
      var flag1 = false;
      var flag2 = false;
      var flag3 = false;
      var equal = false;
      var n1 = 0.0;
      var n2 = 0.0;
      var code1 = 0;
      var code2 = 0;
      var dt1 = 0.0;
      var dt2 = 0.0;
      var q = 0;
      var i = 0;
      i = 0;
      oksmaller = true;
      oklarger = true;
      flag1 = false;
      flag2 = false;
      flag3 = false;
      negflag = false;
      equal = false;
      s2 = pas.System.Pos(larger,s0a);
      if (s2 !== 0) {
        s2 += 1;
        if (s0a.charAt(s2 - i - 1) === "=") {
          equal = true;
          s2 += 1;
        };
        while (s0a.charAt(s2 - i - 1) === " ") s2 += 1;
        s3 = s2;
        len = 0;
        lastchar = "\x00";
        q = 0;
        while (((s2 - i) <= s0a.length) && (s0a.charAt(s2 - i - 1) !== " ") && (s2 <= s0a.length) && (pas.System.Odd(q) || ((s0a.charAt(s2 - i - 1) !== "&") && (s0a.charAt(s2 - i - 1) !== "|")))) {
          if (s0a.charAt(s2 - i - 1) === '"') q += 1;
          if ((len === 0) && (s0a.charAt(s2 - i - 1) === '"')) {
            s3 += 1}
           else len += 1;
          lastchar = s0a.charAt(s2 - i - 1);
          s2 += 1;
          if (((s2 - i) <= s0a.length) && (s0a.charAt(s2 - i - 1) === " ") && pas.System.Odd(q)) {
            lastchar = s0a.charAt(s2 - i - 1);
            s2 += 1;
          };
        };
        if ((len > 0) && (lastchar === '"')) len -= 1;
        compstr = pas.System.Copy(s0a,s3,len);
        pas.System.val$8($impl.StripThousandSep(s1a),{get: function () {
            return n1;
          }, set: function (v) {
            n1 = v;
          }},{get: function () {
            return code1;
          }, set: function (v) {
            code1 = v;
          }});
        pas.System.val$8($impl.StripThousandSep(compstr),{get: function () {
            return n2;
          }, set: function (v) {
            n2 = v;
          }},{get: function () {
            return code2;
          }, set: function (v) {
            code2 = v;
          }});
        dt2 = 0;
        if ($impl.IsDate(compstr,{get: function () {
            return dt2;
          }, set: function (v) {
            dt2 = v;
          }})) code2 = 1;
        dt1 = 0;
        if ($impl.IsDate(s1a,{get: function () {
            return dt1;
          }, set: function (v) {
            dt1 = v;
          }})) code1 = 1;
        if ((code1 === 0) && (code2 === 0)) {
          if (equal) {
            oklarger = n1 >= n2}
           else oklarger = n1 > n2;
        } else {
          if ($impl.IsDate(compstr,{get: function () {
              return dt2;
            }, set: function (v) {
              dt2 = v;
            }}) && $impl.IsDate(s1a,{get: function () {
              return dt1;
            }, set: function (v) {
              dt1 = v;
            }})) {
            if (equal) {
              oklarger = dt1 >= dt2}
             else oklarger = dt1 > dt2;
          } else {
            if (equal) {
              oklarger = pas.SysUtils.CompareStr(compstr,s1a) <= 0}
             else oklarger = pas.SysUtils.CompareStr(compstr,s1a) < 0;
          };
        };
        flag1 = true;
      };
      equal = false;
      s2 = pas.System.Pos(smaller,s0a);
      if (s2 !== 0) {
        s2 += 1;
        if (s0a.charAt(s2 - i - 1) === "=") {
          equal = true;
          s2 += 1;
        };
        lastchar = "\x00";
        while (((s2 - i) <= s0a.length) && (s0a.charAt(s2 - i - 1) === " ")) s2 += 1;
        s3 = s2;
        len = 0;
        q = 0;
        while (((s2 - i) <= s0a.length) && (s0a.charAt(s2 - i - 1) !== " ") && (s2 <= s0a.length) && (pas.System.Odd(q) || ((s0a.charAt(s2 - i - 1) !== "&") && (s0a.charAt(s2 - i - 1) !== "|")))) {
          if (s0a.charAt(s2 - i - 1) === '"') q += 1;
          if ((len === 0) && (s0a.charAt(s2 - i - 1) === '"')) {
            s3 += 1}
           else len += 1;
          lastchar = s0a.charAt(s2 - i - 1);
          s2 += 1;
        };
        if ((len > 0) && (lastchar === '"')) len -= 1;
        compstr = pas.System.Copy(s0a,s3,len);
        pas.System.val$8($impl.StripThousandSep(s1a),{get: function () {
            return n1;
          }, set: function (v) {
            n1 = v;
          }},{get: function () {
            return code1;
          }, set: function (v) {
            code1 = v;
          }});
        pas.System.val$8($impl.StripThousandSep(compstr),{get: function () {
            return n2;
          }, set: function (v) {
            n2 = v;
          }},{get: function () {
            return code2;
          }, set: function (v) {
            code2 = v;
          }});
        if ($impl.IsDate(compstr,{get: function () {
            return dt2;
          }, set: function (v) {
            dt2 = v;
          }})) code2 = 1;
        if ($impl.IsDate(s1a,{get: function () {
            return dt1;
          }, set: function (v) {
            dt1 = v;
          }})) code1 = 1;
        if ((code1 === 0) && (code2 === 0)) {
          if (equal) {
            oksmaller = n1 <= n2}
           else oksmaller = n1 < n2;
        } else {
          if ($impl.IsDate(compstr,{get: function () {
              return dt2;
            }, set: function (v) {
              dt2 = v;
            }}) && $impl.IsDate(s1a,{get: function () {
              return dt1;
            }, set: function (v) {
              dt1 = v;
            }})) {
            if (equal) {
              oksmaller = dt1 <= dt2}
             else oksmaller = dt1 < dt2;
          } else {
            if (equal) {
              oksmaller = pas.SysUtils.CompareStr(compstr,s1a) >= 0}
             else oksmaller = pas.SysUtils.CompareStr(compstr,s1a) > 0;
          };
        };
        flag2 = true;
      };
      s2 = pas.System.Pos(negation,s0a);
      if (s2 !== 0) {
        s2 += 1;
        while (s0a.charAt(s2 - i - 1) === " ") s2 += 1;
        s3 = s2;
        len = 0;
        lastchar = "\x00";
        q = 0;
        while ((s0a.charAt(s2 - i - 1) !== " ") && (s2 <= s0a.length) && (pas.System.Odd(q) || ((s0a.charAt(s2 - i - 1) !== "&") && (s0a.charAt(s2 - i - 1) !== "|")))) {
          if (s0a.charAt(s2 - i - 1) === '"') q += 1;
          if ((len === 0) && (s0a.charAt(s2 - i - 1) === '"')) {
            s3 += 1}
           else len += 1;
          lastchar = s0a.charAt(s2 - i - 1);
          s2 += 1;
        };
        if ((len > 0) && (lastchar === '"')) len -= 1;
        compstr = pas.System.Copy(s0a,s3,len);
        flag3 = true;
      };
      if (flag3) {
        if (pas.System.Pos(larger,s0a) === 0) flag1 = flag3;
        if (pas.System.Pos(smaller,s0a) === 0) flag2 = flag3;
      };
      if (pas.System.Pos(logor,s0a) !== 0) if (flag1 || flag2) {
        Result = oksmaller || oklarger;
        return Result;
      };
      if (pas.System.Pos(logand,s0a) !== 0) if (flag1 && flag2) {
        Result = oksmaller && oklarger;
        return Result;
      };
      if (((pas.System.Pos(larger,s0a) !== 0) && oklarger) || ((pas.System.Pos(smaller,s0a) !== 0) && oksmaller)) {
        Result = true;
        return Result;
      };
      s0 = 1;
      s1 = 1;
      done = (s0a === "") || (s1a === "");
      matching = true;
      while (!done && matching) {
        var $tmp = s0a.charAt(s0 - i - 1);
        if ($tmp === qmark) {
          matching = s1 <= s1a.length;
          if (matching) {
            s0 += 1;
            s1 += 1;
          };
        } else if ($tmp === negation) {
          negflag = true;
          s0 += 1;
        } else if ($tmp === '"') {
          s0 += 1;
        } else if ($tmp === asterix) {
          do {
            s0 += 1;
          } while (!(((s0 - i) > s0a.length) || (s0a.charAt(s0 - i - 1) !== asterix)));
          len = s1a.length - s1;
          s1 += len;
          matching = $impl.Matches(pas.System.Copy(s0a,s0,s0a.length),pas.System.Copy(s1a,s1,s1a.length));
          while ((len >= 0) && !matching) {
            s1 -= 1;
            len -= 1;
            matching = $impl.Matches(pas.System.Copy(s0a,s0,s0a.length),pas.System.Copy(s1a,s1,s1a.length));
          };
          if (matching) {
            s0 = s0a.length + 1;
            s1 = s1a.length + 1;
          };
        } else {
          if ((s0 <= s0a.length) && (s1 <= s1a.length)) {
            matching = s0a.charAt(s0 - i - 1) === s1a.charAt(s1 - i - 1)}
           else matching = false;
          if (matching) {
            s0 += 1;
            s1 += 1;
          };
        };
        done = (s0 > s0a.length) && (s1 > s1a.length);
      };
      if (negflag) {
        Result = !matching}
       else Result = matching;
      return Result;
    };
    $impl.StripLogicSpaces = function (AValue) {
      var Result = "";
      var i = 0;
      var k = 0;
      var q = 0;
      q = 0;
      i = 1;
      k = AValue.length;
      Result = "";
      while (i <= k) {
        if (AValue.charAt(i - 1) === '"') q += 1;
        if (AValue.charAt(i - 1) === " ") {
          if (pas.System.Odd(q)) Result = Result + AValue.charAt(i - 1);
        } else Result = Result + AValue.charAt(i - 1);
        i += 1;
      };
      return Result;
    };
    $impl.FirstChar = function (ACharset, AValue, spos) {
      var Result = "\x00";
      var i = 0;
      var q = 0;
      var j = 0;
      j = 1;
      i = 1;
      q = 0;
      spos.set(-1);
      Result = "\x00";
      while (i <= AValue.length) {
        if (AValue.charAt(i - j - 1) === '"') q += 1;
        if (pas.SysUtils.CharInSet(AValue.charAt(i - j - 1),ACharset) && !pas.System.Odd(q)) {
          spos.set(i);
          Result = AValue.charAt(i - j - 1);
          break;
        };
        i += 1;
      };
      return Result;
    };
    $impl.ClosingParenthesis = function (s1) {
      var Result = 0;
      var i = 0;
      var j = 0;
      var k = 0;
      var r = 0;
      r = 0;
      j = 0;
      k = 0;
      i = 1;
      while (i <= s1.length) {
        if (s1.charAt(i - 1) === ")") k += 1;
        if (s1.charAt(i - 1) === "(") j += 1;
        if ((s1.charAt(i - 1) === ")") && (j === k)) {
          r = i;
          break;
        };
        i += 1;
      };
      Result = r;
      return Result;
    };
  };
},["RTLConsts","WEBLib.Consts","RTTI","WEBLib.REST"]);
rtl.module("WEBLib.Controls",["System","Classes","WEBLib.Graphics","Types","SysUtils","Web","JS"],function () {
  "use strict";
  var $mod = this;
  var $impl = $mod.$impl;
  this.VK_CANCEL = 3;
  this.VK_BACK = 8;
  this.VK_TAB = 9;
  this.VK_RETURN = 13;
  this.VK_SHIFT = 16;
  this.VK_CONTROL = 17;
  this.VK_MENU = 18;
  this.VK_PAUSE = 19;
  this.VK_CAPITAL = 20;
  this.VK_ESCAPE = 27;
  this.VK_SPACE = 32;
  this.VK_PRIOR = 33;
  this.VK_NEXT = 34;
  this.VK_END = 35;
  this.VK_HOME = 36;
  this.VK_LEFT = 37;
  this.VK_UP = 38;
  this.VK_RIGHT = 39;
  this.VK_DOWN = 40;
  this.VK_PRINT = 42;
  this.VK_SNAPSHOT = 44;
  this.VK_INSERT = 45;
  this.VK_DELETE = 46;
  this.VK_HELP = 47;
  this.VK_LWIN = 91;
  this.VK_RWIN = 92;
  this.VK_NUMPAD0 = 96;
  this.VK_NUMPAD1 = 97;
  this.VK_NUMPAD2 = 98;
  this.VK_NUMPAD3 = 99;
  this.VK_NUMPAD4 = 100;
  this.VK_NUMPAD5 = 101;
  this.VK_NUMPAD6 = 102;
  this.VK_NUMPAD7 = 103;
  this.VK_NUMPAD8 = 104;
  this.VK_NUMPAD9 = 105;
  this.VK_MULTIPLY = 106;
  this.VK_ADD = 107;
  this.VK_SEPARATOR = 108;
  this.VK_SUBTRACT = 109;
  this.VK_DECIMAL = 110;
  this.VK_DIVIDE = 111;
  this.VK_F1 = 112;
  this.VK_F2 = 113;
  this.VK_F3 = 114;
  this.VK_F4 = 115;
  this.VK_F5 = 116;
  this.VK_F6 = 117;
  this.VK_F7 = 118;
  this.VK_F8 = 119;
  this.VK_F9 = 120;
  this.VK_F10 = 121;
  this.VK_F11 = 122;
  this.VK_F12 = 123;
  this.VK_F13 = 124;
  this.VK_F14 = 125;
  this.VK_F15 = 126;
  this.VK_F16 = 127;
  this.VK_F17 = 128;
  this.VK_F18 = 129;
  this.VK_F19 = 130;
  this.VK_F20 = 131;
  this.VK_F21 = 132;
  this.VK_F22 = 133;
  this.VK_F23 = 134;
  this.VK_F24 = 135;
  this.VK_NUMLOCK = 144;
  this.WHEEL_DELTA = 120;
  this.$rtti.$inherited("TCursor",rtl.longint,{});
  this.crDefault = 0;
  this.crNone = 1;
  this.crArrow = 2;
  this.crCross = 3;
  this.crIBeam = 4;
  this.crSize = 5;
  this.crSizeNESW = 6;
  this.crSizeNS = 7;
  this.crSizeNWSE = 8;
  this.crSizeWE = 9;
  this.crUpArrow = 10;
  this.crHourGlass = 11;
  this.crDrag = 12;
  this.crNoDrop = 13;
  this.crHSplit = 14;
  this.crVSplit = 15;
  this.crMultIDrag = 16;
  this.crSQLWait = 17;
  this.crNo = 18;
  this.crAppStart = 19;
  this.crHelp = 20;
  this.crHandPoint = 21;
  this.crSizeAll = 22;
  this.CSSBackground = "background-color";
  this.CSSZIndex = "z-index";
  this.$rtti.$Class("TCSSCodeManager");
  this.TCSSLibrary = {"0": "cssNone", cssNone: 0, "1": "cssBootstrap", cssBootstrap: 1};
  this.$rtti.$Enum("TCSSLibrary",{minvalue: 0, maxvalue: 1, ordtype: 1, enumtype: this.TCSSLibrary});
  this.TDragState = {"0": "dsDragEnter", dsDragEnter: 0, "1": "dsDragLeave", dsDragLeave: 1, "2": "dsDragMove", dsDragMove: 2};
  this.$rtti.$Enum("TDragState",{minvalue: 0, maxvalue: 2, ordtype: 1, enumtype: this.TDragState});
  this.TDragMode = {"0": "dmManual", dmManual: 0, "1": "dmAutomatic", dmAutomatic: 1};
  this.$rtti.$Enum("TDragMode",{minvalue: 0, maxvalue: 1, ordtype: 1, enumtype: this.TDragMode});
  this.TDragKind = {"0": "dkDrag", dkDrag: 0, "1": "dkDock", dkDock: 1};
  this.$rtti.$Enum("TDragKind",{minvalue: 0, maxvalue: 1, ordtype: 1, enumtype: this.TDragKind});
  rtl.createClass(this,"TDragObject",pas.System.TObject,function () {
  });
  this.TAlign = {"0": "alNone", alNone: 0, "1": "alTop", alTop: 1, "2": "alBottom", alBottom: 2, "3": "alLeft", alLeft: 3, "4": "alRight", alRight: 4, "5": "alClient", alClient: 5, "6": "alCustom", alCustom: 6};
  this.$rtti.$Enum("TAlign",{minvalue: 0, maxvalue: 6, ordtype: 1, enumtype: this.TAlign});
  this.TMouseButton = {"0": "mbLeft", mbLeft: 0, "1": "mbRight", mbRight: 1, "2": "mbMiddle", mbMiddle: 2};
  this.$rtti.$Enum("TMouseButton",{minvalue: 0, maxvalue: 2, ordtype: 1, enumtype: this.TMouseButton});
  this.TBorderStyle = {"0": "bsNone", bsNone: 0, "1": "bsSingle", bsSingle: 1};
  this.$rtti.$Enum("TBorderStyle",{minvalue: 0, maxvalue: 1, ordtype: 1, enumtype: this.TBorderStyle});
  this.TSizeStyle = {"0": "ssPercent", ssPercent: 0, "1": "ssAbsolute", ssAbsolute: 1, "2": "ssAuto", ssAuto: 2};
  this.$rtti.$Enum("TSizeStyle",{minvalue: 0, maxvalue: 2, ordtype: 1, enumtype: this.TSizeStyle});
  this.TScrollStyle = {"0": "ssNone", ssNone: 0, "1": "ssHorizontal", ssHorizontal: 1, "2": "ssVertical", ssVertical: 2, "3": "ssBoth", ssBoth: 3};
  this.$rtti.$Enum("TScrollStyle",{minvalue: 0, maxvalue: 3, ordtype: 1, enumtype: this.TScrollStyle});
  this.TStyleElements$a = {"0": "seFont", seFont: 0, "1": "seClient", seClient: 1, "2": "seBorder", seBorder: 2};
  this.$rtti.$Enum("TStyleElements$a",{minvalue: 0, maxvalue: 2, ordtype: 1, enumtype: this.TStyleElements$a});
  this.$rtti.$Set("TStyleElements",{comptype: this.$rtti["TStyleElements$a"]});
  this.TAnchorKind = {"0": "akLeft", akLeft: 0, "1": "akTop", akTop: 1, "2": "akRight", akRight: 2, "3": "akBottom", akBottom: 3};
  this.$rtti.$Enum("TAnchorKind",{minvalue: 0, maxvalue: 3, ordtype: 1, enumtype: this.TAnchorKind});
  this.$rtti.$Set("TAnchors",{comptype: this.$rtti["TAnchorKind"]});
  this.$rtti.$inherited("TElementClassName",rtl.string,{});
  this.$rtti.$inherited("TElementID",rtl.string,{});
  this.TElementFont = {"0": "efProperty", efProperty: 0, "1": "efCSS", efCSS: 1};
  this.$rtti.$Enum("TElementFont",{minvalue: 0, maxvalue: 1, ordtype: 1, enumtype: this.TElementFont});
  this.TElementPosition = {"0": "epAbsolute", epAbsolute: 0, "1": "epRelative", epRelative: 1, "2": "epIgnore", epIgnore: 2};
  this.$rtti.$Enum("TElementPosition",{minvalue: 0, maxvalue: 2, ordtype: 1, enumtype: this.TElementPosition});
  this.TElementEvent = {"0": "eeClick", eeClick: 0, "1": "eeMouseDown", eeMouseDown: 1, "2": "eeMouseUp", eeMouseUp: 2, "3": "eeMouseMove", eeMouseMove: 3, "4": "eeDblClick", eeDblClick: 4, "5": "eeKeyPress", eeKeyPress: 5, "6": "eeKeyDown", eeKeyDown: 6, "7": "eeKeyUp", eeKeyUp: 7};
  this.$rtti.$Enum("TElementEvent",{minvalue: 0, maxvalue: 7, ordtype: 1, enumtype: this.TElementEvent});
  this.$rtti.$Set("TEventPropagation",{comptype: this.$rtti["TElementEvent"]});
  this.TTextDirection = {"0": "tdDefault", tdDefault: 0, "1": "tdLeftToRight", tdLeftToRight: 1, "2": "tdRightToLeft", tdRightToLeft: 2, "3": "tdInherit", tdInherit: 3};
  this.$rtti.$Enum("TTextDirection",{minvalue: 0, maxvalue: 3, ordtype: 1, enumtype: this.TTextDirection});
  this.TBevelCut = {"0": "bvNone", bvNone: 0, "1": "bvLowered", bvLowered: 1, "2": "bvRaised", bvRaised: 2, "3": "bvSpace", bvSpace: 3};
  this.$rtti.$Enum("TBevelCut",{minvalue: 0, maxvalue: 3, ordtype: 1, enumtype: this.TBevelCut});
  this.TBevelEdge = {"0": "beLeft", beLeft: 0, "1": "beTop", beTop: 1, "2": "beRight", beRight: 2, "3": "beBottom", beBottom: 3};
  this.$rtti.$Enum("TBevelEdge",{minvalue: 0, maxvalue: 3, ordtype: 1, enumtype: this.TBevelEdge});
  this.$rtti.$Set("TBevelEdges",{comptype: this.$rtti["TBevelEdge"]});
  this.TBevelKind = {"0": "bkNone", bkNone: 0, "1": "bkTile", bkTile: 1, "2": "bkSoft", bkSoft: 2, "3": "bkFlat", bkFlat: 3};
  this.$rtti.$Enum("TBevelKind",{minvalue: 0, maxvalue: 3, ordtype: 1, enumtype: this.TBevelKind});
  this.TInputType = {"0": "itText", itText: 0, "1": "itEmail", itEmail: 1, "2": "itDate", itDate: 2, "3": "itDateTime", itDateTime: 3, "4": "itFile", itFile: 4, "5": "itMonth", itMonth: 5, "6": "itNumber", itNumber: 6, "7": "itPassword", itPassword: 7, "8": "itSearch", itSearch: 8, "9": "itTime", itTime: 9, "10": "itURL", itURL: 10, "11": "itWeek", itWeek: 11};
  this.$rtti.$Enum("TInputType",{minvalue: 0, maxvalue: 11, ordtype: 1, enumtype: this.TInputType});
  this.TMaterialGlyphType = {"0": "mgNormal", mgNormal: 0, "1": "mgOutlined", mgOutlined: 1, "2": "mgTwoTone", mgTwoTone: 2, "3": "mgRound", mgRound: 3, "4": "mgSharp", mgSharp: 4};
  this.$rtti.$Enum("TMaterialGlyphType",{minvalue: 0, maxvalue: 4, ordtype: 1, enumtype: this.TMaterialGlyphType});
  rtl.recNewT(this,"TJSXMLHttpRequestRecord",function () {
    this.req = null;
    this.$eq = function (b) {
      return this.req === b.req;
    };
    this.$assign = function (s) {
      this.req = s.req;
      return this;
    };
    var $r = $mod.$rtti.$Record("TJSXMLHttpRequestRecord",{});
    $r.addField("req",pas.Web.$rtti["TJSXMLHttpRequest"]);
  });
  rtl.recNewT(this,"TJSEventRecord",function () {
    this.event = null;
    this.$eq = function (b) {
      return this.event === b.event;
    };
    this.$assign = function (s) {
      this.event = s.event;
      return this;
    };
    var $r = $mod.$rtti.$Record("TJSEventRecord",{});
    $r.addField("event",pas.Web.$rtti["TJSEvent"]);
  });
  this.$rtti.$MethodVar("THTTPResponseEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["AResponse",rtl.string]]), methodkind: 0});
  this.$rtti.$MethodVar("THTTPRequestResponseEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["ARequest",this.$rtti["TJSXMLHttpRequestRecord"]],["AResponse",rtl.string]]), methodkind: 0});
  this.$rtti.$MethodVar("THTTPAbortEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]]]), methodkind: 0});
  this.$rtti.$MethodVar("THTTPErrorEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["ARequest",this.$rtti["TJSXMLHttpRequestRecord"]],["Event",this.$rtti["TJSEventRecord"]],["Handled",rtl.boolean,1]]), methodkind: 0});
  rtl.recNewT(this,"TJSHTMLElementRecord",function () {
    this.element = null;
    this.$eq = function (b) {
      return this.element === b.element;
    };
    this.$assign = function (s) {
      this.element = s.element;
      return this;
    };
    var $r = $mod.$rtti.$Record("TJSHTMLElementRecord",{});
    $r.addField("element",pas.Web.$rtti["TJSHTMLElement"]);
  });
  rtl.recNewT(this,"TJSObjectRecord",function () {
    this.jsobject = null;
    this.$eq = function (b) {
      return this.jsobject === b.jsobject;
    };
    this.$assign = function (s) {
      this.jsobject = s.jsobject;
      return this;
    };
    var $r = $mod.$rtti.$Record("TJSObjectRecord",{});
    $r.addField("jsobject",pas.JS.$rtti["TJSObject"]);
  });
  rtl.recNewT(this,"TJSArrayRecord",function () {
    this.jsarray = null;
    this.$eq = function (b) {
      return this.jsarray === b.jsarray;
    };
    this.$assign = function (s) {
      this.jsarray = s.jsarray;
      return this;
    };
    var $r = $mod.$rtti.$Record("TJSArrayRecord",{});
    $r.addField("jsarray",pas.JS.$rtti["TJSArray"]);
  });
  rtl.recNewT(this,"TJSArrayBufferRecord",function () {
    this.jsarraybuffer = null;
    this.$eq = function (b) {
      return this.jsarraybuffer === b.jsarraybuffer;
    };
    this.$assign = function (s) {
      this.jsarraybuffer = s.jsarraybuffer;
      return this;
    };
    var $r = $mod.$rtti.$Record("TJSArrayBufferRecord",{});
    $r.addField("jsarraybuffer",pas.JS.$rtti["TJSArrayBuffer"]);
  });
  rtl.createClass(this,"TDragSourceObject",pas.System.TObject,function () {
    this.$init = function () {
      pas.System.TObject.$init.call(this);
      this.FJSEvent = null;
      this.FObject = null;
    };
    this.$final = function () {
      this.FJSEvent = undefined;
      this.FObject = undefined;
      pas.System.TObject.$final.call(this);
    };
  });
  this.$rtti.$MethodVar("TNotifyEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]]]), methodkind: 0});
  this.$rtti.$MethodVar("TMouseEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["Button",this.$rtti["TMouseButton"]],["Shift",pas.Classes.$rtti["TShiftState"]],["X",rtl.longint],["Y",rtl.longint]]), methodkind: 0});
  this.$rtti.$MethodVar("TMouseWheelEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["Shift",pas.Classes.$rtti["TShiftState"]],["WheelDelta",rtl.longint],["MousePos",pas.Types.$rtti["TPoint"]],["Handled",rtl.boolean,1]]), methodkind: 0});
  this.$rtti.$MethodVar("TMouseWheelUpDownEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["Shift",pas.Classes.$rtti["TShiftState"]],["MousePos",pas.Types.$rtti["TPoint"]],["Handled",rtl.boolean,1]]), methodkind: 0});
  this.$rtti.$MethodVar("TMouseMoveEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["Shift",pas.Classes.$rtti["TShiftState"]],["X",rtl.longint],["Y",rtl.longint]]), methodkind: 0});
  this.$rtti.$MethodVar("TKeyEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["AKey",rtl.word,1],["Shift",pas.Classes.$rtti["TShiftState"]]]), methodkind: 0});
  this.$rtti.$MethodVar("TKeyPressEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["AChar",rtl.char,1]]), methodkind: 0});
  this.$rtti.$MethodVar("TTouchEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["X",rtl.longint],["Y",rtl.longint]]), methodkind: 0});
  this.TBiDiMode = {"0": "bdLeftToRight", bdLeftToRight: 0, "1": "bdRightToLeft", bdRightToLeft: 1, "2": "bdRightToLeftNoAlign", bdRightToLeftNoAlign: 2, "3": "bdRightToLeftReadingOnly", bdRightToLeftReadingOnly: 3};
  this.$rtti.$Enum("TBiDiMode",{minvalue: 0, maxvalue: 3, ordtype: 1, enumtype: this.TBiDiMode});
  this.$rtti.$MethodVar("TDragOverEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["Source",pas.System.$rtti["TObject"]],["X",rtl.longint],["Y",rtl.longint],["State",this.$rtti["TDragState"]],["Accept",rtl.boolean,1]]), methodkind: 0});
  this.$rtti.$MethodVar("TDragDropEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["Source",pas.System.$rtti["TObject"]],["X",rtl.longint],["Y",rtl.longint]]), methodkind: 0});
  this.$rtti.$MethodVar("TStartDragEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["DragObject",this.$rtti["TDragObject"],1]]), methodkind: 0});
  this.$rtti.$MethodVar("TEndDragEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["Target",pas.System.$rtti["TObject"]],["X",rtl.longint],["Y",rtl.longint]]), methodkind: 0});
  this.$rtti.$MethodVar("TScreenshotEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["ABitmap",pas["WEBLib.Graphics"].$rtti["TBitmap"]]]), methodkind: 0});
  this.TControlStyleValue = {"0": "csAcceptsControls", csAcceptsControls: 0, "1": "csSetCaption", csSetCaption: 1};
  this.$rtti.$Enum("TControlStyleValue",{minvalue: 0, maxvalue: 1, ordtype: 1, enumtype: this.TControlStyleValue});
  this.$rtti.$Set("TControlStyle",{comptype: this.$rtti["TControlStyleValue"]});
  rtl.createClass(this,"TMargins",pas.Classes.TPersistent,function () {
    this.$init = function () {
      pas.Classes.TPersistent.$init.call(this);
      this.FOnChange = null;
      this.FLeft = 0;
      this.FTop = 0;
      this.FRight = 0;
      this.FBottom = 0;
    };
    this.$final = function () {
      this.FOnChange = undefined;
      pas.Classes.TPersistent.$final.call(this);
    };
    this.SetLeft = function (Value) {
      if (Value !== this.FLeft) {
        this.FLeft = Value;
        this.DoChange();
      };
    };
    this.SetTop = function (Value) {
      if (Value !== this.FTop) {
        this.FTop = Value;
        this.DoChange();
      };
    };
    this.SetRight = function (Value) {
      if (Value !== this.FRight) {
        this.FRight = Value;
        this.DoChange();
      };
    };
    this.SetBottom = function (Value) {
      if (Value !== this.FBottom) {
        this.FBottom = Value;
        this.DoChange();
      };
    };
    this.DoChange = function () {
      if (this.FOnChange != null) this.FOnChange(this);
    };
    this.Create$1 = function () {
      this.FLeft = 3;
      this.FTop = 3;
      this.FBottom = 3;
      this.FRight = 3;
      return this;
    };
    this.Assign = function (Source) {
      if ($mod.TMargins.isPrototypeOf(Source)) {
        this.FLeft = rtl.as(Source,$mod.TMargins).FLeft;
        this.FTop = rtl.as(Source,$mod.TMargins).FTop;
        this.FBottom = rtl.as(Source,$mod.TMargins).FBottom;
        this.FRight = rtl.as(Source,$mod.TMargins).FRight;
      } else pas.Classes.TPersistent.Assign.apply(this,arguments);
    };
    var $r = this.$rtti;
    $r.addMethod("Create$1",2,[]);
    $r.addProperty("Left",2,rtl.longint,"FLeft","SetLeft",{Default: 3});
    $r.addProperty("Top",2,rtl.longint,"FTop","SetTop",{Default: 3});
    $r.addProperty("Right",2,rtl.longint,"FRight","SetRight",{Default: 3});
    $r.addProperty("Bottom",2,rtl.longint,"FBottom","SetBottom",{Default: 3});
  });
  rtl.createClass(this,"TCenter",pas.Classes.TPersistent,function () {
    this.$init = function () {
      pas.Classes.TPersistent.$init.call(this);
      this.FHorizontal = false;
      this.FVertical = false;
      this.FOnChange = null;
    };
    this.$final = function () {
      this.FOnChange = undefined;
      pas.Classes.TPersistent.$final.call(this);
    };
    this.SetHorizontal = function (Value) {
      if (this.FHorizontal !== Value) {
        this.FHorizontal = Value;
        this.DoChange();
      };
    };
    this.SetVertical = function (Value) {
      if (this.FVertical !== Value) {
        this.FVertical = Value;
        this.DoChange();
      };
    };
    this.DoChange = function () {
      if (this.FOnChange != null) this.FOnChange(this);
    };
    this.Assign = function (Source) {
      if ($mod.TCenter.isPrototypeOf(Source)) {
        this.FHorizontal = rtl.as(Source,$mod.TCenter).FHorizontal;
        this.FVertical = rtl.as(Source,$mod.TCenter).FVertical;
      };
    };
    var $r = this.$rtti;
    $r.addProperty("Horizontal",2,rtl.boolean,"FHorizontal","SetHorizontal",{Default: false});
    $r.addProperty("Vertical",2,rtl.boolean,"FVertical","SetVertical",{Default: false});
  });
  rtl.createClass(this,"TPadding",pas.Classes.TPersistent,function () {
    this.$init = function () {
      pas.Classes.TPersistent.$init.call(this);
      this.FOnChange = null;
      this.FLeft = 0;
      this.FTop = 0;
      this.FRight = 0;
      this.FBottom = 0;
    };
    this.$final = function () {
      this.FOnChange = undefined;
      pas.Classes.TPersistent.$final.call(this);
    };
    this.SetLeft = function (Value) {
      if (this.FLeft !== Value) {
        this.FLeft = Value;
        this.DoChange();
      };
    };
    this.SetTop = function (Value) {
      if (this.FTop !== Value) {
        this.FTop = Value;
        this.DoChange();
      };
    };
    this.SetRight = function (Value) {
      if (this.FRight !== Value) {
        this.FRight = Value;
        this.DoChange();
      };
    };
    this.SetBottom = function (Value) {
      if (this.FBottom !== Value) {
        this.FBottom = Value;
        this.DoChange();
      };
    };
    this.DoChange = function () {
      if (this.FOnChange != null) this.FOnChange(this);
    };
    this.Create$1 = function () {
      pas.System.TObject.Create.call(this);
      this.FLeft = 0;
      this.FTop = 0;
      this.FRight = 0;
      this.FBottom = 0;
      return this;
    };
    this.Assign = function (Source) {
      if ($mod.TPadding.isPrototypeOf(Source)) {
        this.FLeft = rtl.as(Source,$mod.TPadding).FLeft;
        this.FRight = rtl.as(Source,$mod.TPadding).FRight;
        this.FTop = rtl.as(Source,$mod.TPadding).FTop;
        this.FBottom = rtl.as(Source,$mod.TPadding).FBottom;
      };
    };
    var $r = this.$rtti;
    $r.addMethod("Create$1",2,[]);
    $r.addProperty("Left",2,rtl.longint,"FLeft","SetLeft",{Default: 0});
    $r.addProperty("Top",2,rtl.longint,"FTop","SetTop",{Default: 0});
    $r.addProperty("Right",2,rtl.longint,"FRight","SetRight",{Default: 0});
    $r.addProperty("Bottom",2,rtl.longint,"FBottom","SetBottom",{Default: 0});
  });
  rtl.createInterface(this,"IControl","{6325F220-F2E4-384C-B7C4-A6C697D13DCF}",["EnterChildren","ExitChildren"],pas.System.IUnknown,function () {
    var $r = this.$rtti;
    $r.addMethod("EnterChildren",1,[["AObject",$r]],rtl.boolean);
    $r.addMethod("ExitChildren",1,[["AObject",$r]],rtl.boolean);
  });
  rtl.createClass(this,"TControl",pas.Classes.TComponent,function () {
    this.$init = function () {
      pas.Classes.TComponent.$init.call(this);
      this.FGotFocus = false;
      this.FAcceptDrag = false;
      this.FCaptureDown = false;
      this.FMouseInsideLayer = false;
      this.FLayer = null;
      this.FCaptured = false;
      this.FControlCreated = false;
      this.FUpdateCount = 0;
      this.FBlockUpdateElement = false;
      this.FElement = null;
      this.FID = "";
      this.FNew = false;
      this.FContainer = null;
      this.FElementEvent = null;
      this.FLastElementEvent = null;
      this.FElementClassName = "";
      this.FFont = null;
      this.FParent = null;
      this.FPrevParent = null;
      this.FControls = [];
      this.FOnDragOver = null;
      this.FOnDragDrop = null;
      this.FOnStartDrag = null;
      this.FonEndDrag = null;
      this.FOnClick = null;
      this.FOnDblClick = null;
      this.FOnMouseDown = null;
      this.FOnMouseUp = null;
      this.FOnMouseMove = null;
      this.FOnKeyDown = null;
      this.FOnKeyUp = null;
      this.FOnKeyPress = null;
      this.FOnEnter = null;
      this.FOnExit = null;
      this.FEnabled = false;
      this.FHint = "";
      this.FRole = "";
      this.FShowHint = false;
      this.FTabOrder = 0;
      this.FTabStop = false;
      this.FVisible = false;
      this.FWidth = 0;
      this.FHeight = 0;
      this.FTag$1 = 0;
      this.FAlign = 0;
      this.FAnchors = {};
      this.FAlignWithMargins = false;
      this.FIsAligning = false;
      this.FOnMouseEnter = null;
      this.FOnMouseLeave = null;
      this.FCursor = 0;
      this.FDoubleBuffered = false;
      this.FControlStyle = {};
      this.FMargins = null;
      this.FCenter = null;
      this.FOnMouseWheel = null;
      this.FParentDoubleBuffered = false;
      this.FParentColor = false;
      this.FParentFont = false;
      this.FParentBiDiMode = false;
      this.FOnTouchMove = null;
      this.FOnTouchStart = null;
      this.FOnTouchEnd = null;
      this.FOnTouchCancel = null;
      this.FLinkTouchEvents = false;
      this.FWidthStyle = 0;
      this.FHeightStyle = 0;
      this.FWidthPercent = 0.0;
      this.FHeightPercent = 0.0;
      this.FOrigRect = pas.Types.TRect.$new();
      this.FOrigParentRect = pas.Types.TRect.$new();
      this.FIsResizing = false;
      this.FShowFocus = false;
      this.FBorderWidth = 0;
      this.FOrigTop = 0;
      this.FOrigLeft = 0;
      this.FUpdateTopLeft = false;
      this.FEnablePropagation = false;
      this.FParentShowHint = false;
      this.FScriptLoaded = false;
      this.FControlScriptCount = 0;
      this.FControlScriptCountLoaded = 0;
      this.FRequiredScripts = null;
      this.FElementFont = 0;
      this.FElementPosition = 0;
      this.FParentElement = null;
      this.FTagObject = null;
      this.FClipChildren = false;
      this.FTextDirection = 0;
      this.FEventStopPropagation = {};
      this.FParentElementID = "";
      this.FOnResize = null;
      this.FMouseMovePtr = null;
      this.FMouseDownPtr = null;
      this.FMouseUpPtr = null;
      this.FMouseEnterPtr = null;
      this.FMouseLeavePtr = null;
      this.FClickPtr = null;
      this.FDblClickPtr = null;
      this.FKeyDownPtr = null;
      this.FKeyUpPtr = null;
      this.FKeyPressPtr = null;
      this.FInputPtr = null;
      this.FTouchStartPtr = null;
      this.FTouchEndPtr = null;
      this.FTouchMovePtr = null;
      this.FTouchCancelPtr = null;
      this.FContextMenuPtr = null;
      this.FExitPtr = null;
      this.FEnterPtr = null;
      this.FWheelPtr = null;
      this.FLayerMouseEnterPtr = null;
      this.FLayerMouseLeavePtr = null;
      this.FScriptLoadedPtr = null;
      this.FDragStartPtr = null;
      this.FDragOverPtr = null;
      this.FDragEnterPtr = null;
      this.FDragLeavePtr = null;
      this.FDragEndPtr = null;
      this.FDragDropPtr = null;
      this.FChildOrder = 0;
      this.FAllowTouch = false;
      this.FCtl3D = false;
      this.FParentCtl3D = false;
      this.FWheelAccumulator = 0;
      this.FWheelMousePos = pas.Types.TPoint.$new();
      this.FBiDiMode = 0;
      this.FOnMouseWheelDown = null;
      this.FOnMouseWheelUp = null;
      this.FNoUserSelect = false;
      this.FEventsBound = false;
      this.FDragMode = 0;
      this.FToolTip = undefined;
      this.FDesignTime = false;
      this.FColor = 0;
    };
    this.$final = function () {
      this.FLayer = undefined;
      this.FElement = undefined;
      this.FContainer = undefined;
      this.FElementEvent = undefined;
      this.FLastElementEvent = undefined;
      this.FFont = undefined;
      this.FParent = undefined;
      this.FPrevParent = undefined;
      this.FControls = undefined;
      this.FOnDragOver = undefined;
      this.FOnDragDrop = undefined;
      this.FOnStartDrag = undefined;
      this.FonEndDrag = undefined;
      this.FOnClick = undefined;
      this.FOnDblClick = undefined;
      this.FOnMouseDown = undefined;
      this.FOnMouseUp = undefined;
      this.FOnMouseMove = undefined;
      this.FOnKeyDown = undefined;
      this.FOnKeyUp = undefined;
      this.FOnKeyPress = undefined;
      this.FOnEnter = undefined;
      this.FOnExit = undefined;
      this.FAnchors = undefined;
      this.FOnMouseEnter = undefined;
      this.FOnMouseLeave = undefined;
      this.FControlStyle = undefined;
      this.FMargins = undefined;
      this.FCenter = undefined;
      this.FOnMouseWheel = undefined;
      this.FOnTouchMove = undefined;
      this.FOnTouchStart = undefined;
      this.FOnTouchEnd = undefined;
      this.FOnTouchCancel = undefined;
      this.FOrigRect = undefined;
      this.FOrigParentRect = undefined;
      this.FRequiredScripts = undefined;
      this.FParentElement = undefined;
      this.FTagObject = undefined;
      this.FEventStopPropagation = undefined;
      this.FOnResize = undefined;
      this.FWheelMousePos = undefined;
      this.FOnMouseWheelDown = undefined;
      this.FOnMouseWheelUp = undefined;
      pas.Classes.TComponent.$final.call(this);
    };
    this.GetControlsCount = function () {
      var Result = 0;
      Result = rtl.length(this.FControls);
      return Result;
    };
    this.GetControls = function (Index) {
      var Result = null;
      Result = this.FControls[Index];
      return Result;
    };
    this.SetVisible = function (AValue) {
      if (this.FVisible !== AValue) {
        this.VisibleChanging();
        this.FVisible = AValue;
        this.UpdateElement();
        this.DoRealign();
        this.AlignControl(this);
        this.VisibleChanged();
      };
    };
    this.SetHint = function (AValue) {
      if (this.FHint !== AValue) {
        this.FHint = AValue;
        this.UpdateElement();
      };
    };
    this.SetShowHint = function (AValue) {
      if (this.FShowHint !== AValue) {
        this.FShowHint = AValue;
        this.UpdateElement();
      };
    };
    this.SetTabOrder = function (AValue) {
      if (this.FTabOrder !== AValue) {
        this.FTabOrder = AValue;
        this.UpdateElement();
      };
    };
    this.SetTabStop = function (AValue) {
      if (this.FTabStop !== AValue) {
        this.FTabStop = AValue;
        this.UpdateElement();
      };
    };
    this.SetAlign = function (Value) {
      if (this.FAlign !== Value) {
        this.FAlign = Value;
        this.DoRealign();
      };
    };
    this.SetAlignWithMargins = function (Value) {
      if (this.FAlignWithMargins !== Value) {
        this.FAlignWithMargins = Value;
        this.DoRealign();
      };
    };
    this.GetBoundsRect = function () {
      var Result = pas.Types.TRect.$new();
      Result.Left = this.GetLeft();
      Result.Top = this.GetTop();
      Result.Right = this.GetLeft() + this.GetWidth();
      Result.Bottom = this.GetTop() + this.GetHeight();
      return Result;
    };
    this.SetBoundsRect = function (Value) {
      this.SetBoundsInt(Value.Left,Value.Top,Value.Right - Value.Left,Value.Bottom - Value.Top);
    };
    this.SetID = function (Value) {
      var eh = null;
      var el = null;
      var tmp = null;
      var frm = null;
      var p = null;
      var l = 0;
      var t = 0;
      var w = 0;
      var h = 0;
      if (this.FNew && (this.FID !== Value)) {
        eh = document.getElementById(Value);
        if (eh != null) {
          l = this.FLeft;
          t = this.FTop;
          w = this.FWidth;
          h = this.FHeight;
          tmp = null;
          this.UnbindEvents();
          if (this.FContainer != null) {
            this.FParentElement = this.FContainer.parentElement;
            tmp = document.createElement("SPAN");
            this.$class.MoveElements(this.FContainer,tmp);
          };
          p = this.FParent;
          this.SetParent(null);
          this.CreateWithID(Value);
          this.SetParentComponent(p);
          this.FID = Value;
          this.FWidth = w;
          this.FHeight = h;
          this.UpdateElement();
          if (pas.Classes.TComponentStateItem.csDesigning in this.FComponentState) {
            this.FLeft = l;
            this.FTop = t;
          };
          if (tmp != null) {
            this.GetElementHandle().textContent = "";
            this.MoveElementsAndFree(tmp,this.GetElementHandle());
          };
          return;
        };
      };
      if (!this.FNew && (this.FID !== Value)) {
        w = this.FWidth;
        h = this.FHeight;
        eh = document.getElementById(this.FID);
        if (eh != null) {
          tmp = document.createElement("SPAN");
          this.$class.MoveElements(eh,tmp);
          this.UnbindEvents();
        };
        if (Value !== "") {
          eh = document.getElementById(Value);
          if (eh != null) {
            this.CreateWithID(Value);
            this.FID = Value;
            this.FWidth = w;
            this.FHeight = h;
            this.UpdateElement();
            this.MoveElementsAndFree(tmp,this.FContainer);
            return;
          };
        };
        this.FNew = true;
        this.FElement = null;
        this.CreateControl();
        if (Value === "") {
          this.CreateInitialize();
          this.FWidth = w;
          this.FHeight = h;
        };
        if (this.FParentElement != null) {
          this.FParentElement.appendChild(this.GetContainer());
        } else document.body.appendChild(this.GetContainer());
        frm = pas["WEBLib.Forms"].GetParentForm(this);
        if (frm != null) {
          this.SetParent(frm);
          this.SetElementPosition($mod.TElementPosition.epAbsolute);
          this.SetLeft(0);
          this.SetTop(0);
        };
        if (tmp != null) this.MoveElementsAndFree(tmp,this.FContainer);
        this.UpdateElement();
        this.UpdateElementSize();
      };
      this.FID = Value;
      if (this.FContainer != null) this.FContainer.setAttribute("id",Value);
    };
    this.SetMargins = function (Value) {
      this.FMargins.Assign(Value);
    };
    this.SetAnchors = function (Value) {
      if (rtl.neSet(this.FAnchors,Value)) {
        this.FAnchors = rtl.refSet(Value);
        if (!(pas.Classes.TComponentStateItem.csLoading in this.FComponentState)) {
          this.UpdateAnchoring();
        };
      };
    };
    this.GetElementEvent = function () {
      var Result = null;
      Result = this.FElementEvent;
      return Result;
    };
    this.GetClientOrigin = function () {
      var Result = pas.Types.TPoint.$new();
      var r = null;
      Result.$assign(pas.Types.Point(0,0));
      if (this.GetElementHandle() != null) {
        r = this.GetElementHandle().getBoundingClientRect();
        Result.$assign(pas.Types.Point(Math.round(r.left),Math.round(r.top)));
      };
      return Result;
    };
    this.SetBorderWidth = function (Value) {
      if (this.FBorderWidth !== Value) {
        this.FBorderWidth = Value;
        this.UpdateElement();
      };
    };
    this.GetIsLinked = function () {
      var Result = false;
      Result = !this.FNew;
      return Result;
    };
    this.SetScriptLoaded = function (Value) {
      this.FScriptLoaded = Value;
    };
    this.SetRequiredScripts = function (Value) {
      this.FRequiredScripts.Assign(Value);
    };
    this.SetElementFont = function (Value) {
      if (this.FElementFont !== Value) {
        this.FElementFont = Value;
        this.UpdateElementVisual();
      };
    };
    this.SetElementPosition = function (Value) {
      if (this.FElementPosition !== Value) {
        this.FElementPosition = Value;
        if (this.GetElementHandle() != null) {
          this.UpdateElementSize();
          this.RecreateCanvas();
          this.InternalResize();
        };
      };
    };
    this.SetParentElement = function (Value) {
      if (this.FNew) {
        this.FElementPosition = $mod.TElementPosition.epRelative;
        this.CreateControl();
        this.FParentElement = Value;
        if (this.FParentElement != null) {
          this.FParentElement.appendChild(this.GetContainer());
        };
      } else {
        if (this.FParentElement != null) this.FParentElement.removeChild(this.GetContainer());
        this.FParentElement = Value;
        if (this.FParentElement != null) this.FParentElement.appendChild(this.GetContainer());
        this.UpdateElement();
      };
      this.InitScript();
      this.Invalidate();
    };
    this.SetClipChildren = function (Value) {
      this.FClipChildren = Value;
      this.UpdateElement();
    };
    this.SetParentElementID = function (Value) {
      var el = null;
      this.FParentElementID = Value;
      el = document.getElementById(this.FParentElementID);
      if (el != null) this.SetParentElement(el);
    };
    this.SetChildOrderEx = function (Value) {
      this.FChildOrder = Value;
    };
    this.GetRole = function () {
      var Result = "";
      Result = this.FRole;
      if (this.GetElementHandle() != null) Result = this.GetElementHandle().getAttribute("role");
      return Result;
    };
    this.SetRole = function (Value) {
      this.FRole = Value;
      if (this.GetElementHandle() != null) {
        if (Value === "") {
          this.GetElementHandle().removeAttribute("role")}
         else this.GetElementHandle().setAttribute("role",Value);
      };
    };
    this.GetContainer = function () {
      var Result = null;
      Result = this.FContainer;
      return Result;
    };
    this.GetChildContainer = function () {
      var Result = null;
      Result = this.FContainer;
      return Result;
    };
    this.SetParentFont = function (Value) {
      if ((Value !== this.FParentFont) && Value && (this.FParent != null)) {
        this.BeginUpdate();
        this.FFont.Assign(this.FParent.FFont);
        this.EndUpdate();
        this.UpdateElement();
      };
      this.FParentFont = Value;
    };
    this.SetParentColor = function (Value) {
      if ((this.FParentColor !== Value) && Value && (this.FParent != null)) {
        this.SetColor(this.FParent.FColor);
      };
      this.FParentColor = Value;
    };
    this.SetDragMode = function (Value) {
      this.FDragMode = Value;
      if (Value === $mod.TDragMode.dmAutomatic) {
        this.BeginDrag()}
       else this.DisableDrag();
    };
    this.GetClientHeight = function () {
      var Result = 0;
      Result = this.GetHeight();
      return Result;
    };
    this.GetClientWidth = function () {
      var Result = 0;
      Result = this.GetWidth();
      return Result;
    };
    this.SetClientHeight = function (Value) {
      this.SetHeight(Value);
    };
    this.SetClientWidth = function (Value) {
      this.SetWidth(Value);
    };
    this.SetHeightStyle = function (Value) {
      if (this.FHeightStyle !== Value) {
        this.FHeightStyle = Value;
        if ((this.FHeightStyle === $mod.TSizeStyle.ssAuto) && (this.GetElementHandle() != null) && !this.GetIsLinked()) this.GetElementStyle().removeProperty("height");
        this.UpdateElementSize();
        this.ResetAnchoring();
        this.DoBoundsChange();
      };
    };
    this.SetWidthStyle = function (Value) {
      if (this.FWidthStyle !== Value) {
        this.FWidthStyle = Value;
        if ((this.FWidthStyle === $mod.TSizeStyle.ssAuto) && (this.GetElementHandle() != null) && !this.GetIsLinked()) this.GetElementStyle().removeProperty("width");
        this.UpdateElementSize();
        this.ResetAnchoring();
        this.DoBoundsChange();
      };
    };
    this.SetHeightPercent = function (Value) {
      if (this.FHeightPercent !== Value) {
        this.FHeightPercent = Value;
        this.UpdateElementSize();
        this.ResetAnchoring();
        this.DoBoundsChange();
      };
    };
    this.SetWidthPercent = function (Value) {
      if (this.FWidthPercent !== Value) {
        this.FWidthPercent = Value;
        this.UpdateElementSize();
        this.ResetAnchoring();
        this.DoBoundsChange();
      };
    };
    this.SetShowFocus = function (Value) {
      if (this.FShowFocus !== Value) {
        this.FShowFocus = Value;
        this.UpdateElement();
      };
    };
    this.SetWidth = function (AValue) {
      if (this.FWidth !== AValue) {
        this.FWidth = AValue;
        this.ResetAnchoring();
        this.DoBoundsChange();
        if (this.GetIsLinked() && (this.FWidthStyle === $mod.TSizeStyle.ssAbsolute) && !(pas.Classes.TComponentStateItem.csLoading in this.FComponentState) && !this.IsUpdating() && (this.GetElementHandle() != null)) {
          if (AValue >= 0) {
            this.GetElementStyle().setProperty("width",pas.SysUtils.IntToStr(AValue) + "px")}
           else this.GetElementStyle().removeProperty("width");
        };
      };
    };
    this.SetHeight = function (AValue) {
      var dr = null;
      if (this.FHeight !== AValue) {
        if ((this.FAlign in rtl.createSet($mod.TAlign.alLeft,$mod.TAlign.alRight,$mod.TAlign.alClient)) && (this.GetElementHandle() != null)) {
          dr = this.GetElementHandle().getBoundingClientRect();
          if ((dr.top + AValue) >= pas["WEBLib.Forms"].WinHeight()) {
            AValue = Math.round(pas["WEBLib.Forms"].WinHeight() - dr.top);
          };
        };
        this.FHeight = AValue;
        this.ResetAnchoring();
        this.DoBoundsChange();
        if (this.GetIsLinked() && (this.FHeightStyle === $mod.TSizeStyle.ssAbsolute) && !(pas.Classes.TComponentStateItem.csLoading in this.FComponentState) && !this.IsUpdating() && (this.GetElementHandle() != null)) {
          if (AValue >= 0) {
            this.GetElementStyle().setProperty("height",pas.SysUtils.IntToStr(AValue) + "px")}
           else this.GetElementStyle().removeProperty("height");
        };
      };
    };
    this.SetWidthInt = function (AValue) {
      this.FWidth = AValue;
    };
    this.SetHeightInt = function (AValue) {
      this.FHeight = AValue;
    };
    this.SetEnabled = function (Value) {
      if (this.FEnabled !== Value) {
        this.FEnabled = Value;
        this.UpdateElementData();
      };
    };
    this.RecreateCanvas = function () {
    };
    this.VisibleChanging = function () {
    };
    this.VisibleChanged = function () {
      var i = 0;
      for (var $l = 0, $end = this.GetControlsCount() - 1; $l <= $end; $l++) {
        i = $l;
        this.GetControls(i).VisibleChanged();
      };
    };
    this.ColorChanging = function () {
    };
    this.IncUpdateCount = function () {
      this.FUpdateCount += 1;
    };
    this.DecUpdateCount = function () {
      this.FUpdateCount -= 1;
    };
    this.FocusedControlEntered = function () {
      var p = null;
      var c = null;
      var $ir = rtl.createIntfRefs();
      try {
        p = this.FParent;
        while (p !== null) if (pas.SysUtils.Supports$1($ir.ref(1,rtl.queryIntfT(p,pas.System.IUnknown)),rtl.getIntfGUIDR($mod.IControl),{get: function () {
            return c;
          }, set: function (v) {
            c = v;
          }}) && c.EnterChildren($ir.ref(2,rtl.queryIntfT(this,$mod.IControl)))) {
          break}
         else p = p.FParent;
      } finally {
        $ir.free();
        rtl._Release(c);
      };
    };
    this.FocusedControlExited = function () {
      var p = null;
      var c = null;
      var $ir = rtl.createIntfRefs();
      try {
        p = this.FParent;
        while (p !== null) if (pas.SysUtils.Supports$1($ir.ref(1,rtl.queryIntfT(p,pas.System.IUnknown)),rtl.getIntfGUIDR($mod.IControl),{get: function () {
            return c;
          }, set: function (v) {
            c = v;
          }}) && c.ExitChildren($ir.ref(2,rtl.queryIntfT(this,$mod.IControl)))) {
          break}
         else p = p.FParent;
      } finally {
        $ir.free();
        rtl._Release(c);
      };
    };
    this.EnterChildren = function (AObject) {
      var Result = false;
      Result = false;
      return Result;
    };
    this.ExitChildren = function (AObject) {
      var Result = false;
      Result = false;
      return Result;
    };
    this.GetWidth = function () {
      var Result = 0;
      var cr = null;
      Result = this.FWidth;
      if ((this.GetElementHandle() != null) && !(pas.Classes.TComponentStateItem.csLoading in this.FComponentState)) {
        if (Result === -1) {
          Result = Math.round(pas.System.Int(this.GetElementHandle().offsetWidth));
        };
        if (this.FWidthStyle !== $mod.TSizeStyle.ssAbsolute) {
          cr = this.GetElementHandle().getBoundingClientRect();
          Result = Math.round(pas.System.Int(cr.right - cr.left));
        };
      };
      return Result;
    };
    this.GetHeight = function () {
      var Result = 0;
      var cr = null;
      Result = this.FHeight;
      if ((this.GetElementHandle() != null) && !(pas.Classes.TComponentStateItem.csLoading in this.FComponentState)) {
        if (Result === -1) {
          Result = Math.round(pas.System.Int(this.GetElementHandle().offsetHeight));
        };
        if (this.FHeightStyle !== $mod.TSizeStyle.ssAbsolute) {
          cr = this.GetElementHandle().getBoundingClientRect();
          Result = Math.round(pas.System.Int(cr.bottom - cr.top));
        };
      };
      return Result;
    };
    this.GetOuterWidth = function () {
      var Result = 0;
      Result = this.FWidth - this.FBorderWidth;
      return Result;
    };
    this.GetOuterHeight = function () {
      var Result = 0;
      Result = this.FHeight - this.FBorderWidth;
      return Result;
    };
    this.GetDesignWidth = function () {
      var Result = 0;
      Result = this.FWidth;
      return Result;
    };
    this.GetDesignHeight = function () {
      var Result = 0;
      Result = this.FHeight;
      return Result;
    };
    this.GetDesignLeft = function () {
      var Result = 0;
      Result = this.FLeft;
      return Result;
    };
    this.GetDesignTop = function () {
      var Result = 0;
      Result = this.FTop;
      return Result;
    };
    this.GetLeft = function () {
      var Result = 0;
      Result = this.FLeft;
      if ((Result === -1) && (this.GetElementHandle() != null) && !(pas.Classes.TComponentStateItem.csLoading in this.FComponentState)) Result = Math.round(this.GetElementHandle().offsetLeft);
      return Result;
    };
    this.GetTop = function () {
      var Result = 0;
      Result = this.FTop;
      if ((Result === -1) && (this.GetElementHandle() != null) && !(pas.Classes.TComponentStateItem.csLoading in this.FComponentState)) Result = Math.round(this.GetElementHandle().offsetTop);
      return Result;
    };
    this.HandleAllocated = function () {
      var Result = false;
      Result = true;
      return Result;
    };
    this.CreateElement = function () {
      var Result = null;
      Result = null;
      return Result;
    };
    this.CreateChildElements = function (AContainer) {
    };
    this.ContainerElement = function () {
      var Result = null;
      Result = document.body;
      return Result;
    };
    this.IsStructuralElement = function () {
      var Result = false;
      Result = false;
      return Result;
    };
    this.IsEnabled = function () {
      var Result = false;
      Result = this.FEnabled;
      return Result;
    };
    this.GetNewName = function () {
      var Result = "";
      var s = "";
      var lPrefix = "";
      var frm = null;
      s = this.$classname;
      pas.System.Delete({get: function () {
          return s;
        }, set: function (v) {
          s = v;
        }},1,1);
      lPrefix = "";
      frm = pas["WEBLib.Forms"].GetParentForm(this);
      if (frm != null) lPrefix = frm.$classname;
      Result = lPrefix + "_" + $mod.FindUniqueName(s);
      return Result;
    };
    this.IsInputControl = function () {
      var Result = false;
      Result = false;
      return Result;
    };
    this.UseCSSFont = function () {
      var Result = false;
      Result = !((this.FElementClassName === "") && (this.FElementFont === $mod.TElementFont.efProperty) && !this.GetIsLinked());
      return Result;
    };
    this.UseCSSFontColor = function () {
      var Result = false;
      Result = !(pas["WEBLib.Forms"].Application.FThemed && (pas["WEBLib.Graphics"].ColorToRGB(this.FFont.FColor) === pas["WEBLib.Graphics"].RGB(0,0,0)));
      return Result;
    };
    this.RecreateElement = function () {
      if (this.GetContainer() != null) {
        this.UnbindEvents();
        this.GetContainer().parentNode.removeChild(this.GetContainer());
        this.FElement = null;
        this.CreateControl();
        if ((this.FParent != null) && (this.FParent.GetContainer() != null)) this.FParent.GetChildContainer().appendChild(this.GetContainer());
      };
    };
    this.BindElement = function () {
    };
    this.CreateInitialize = function () {
      var frm = null;
      this.FDesignTime = (pas.Classes.TComponentStateItem.csDesigning in this.FComponentState) && !((pas.Classes.TComponentStateItem.csReading in this.FOwner.FComponentState) || (pas.Classes.TComponentStateItem.csLoading in this.FOwner.FComponentState));
      this.FRequiredScripts = pas.Classes.TStringList.$create("Create$1");
      this.FOrigRect.$assign(pas.Types.Rect(-1,-1,-1,-1));
      this.FClipChildren = true;
      if (this.FDesignTime) {
        frm = pas["WEBLib.Forms"].GetParentForm(this);
        if ((frm != null) && pas["WEBLib.Forms"].TForm.isPrototypeOf(frm) && (rtl.as(frm,pas["WEBLib.Forms"].TForm).FCSSLibrary !== $mod.TCSSLibrary.cssNone)) {
          this.InitCSSLibrary(rtl.as(frm,pas["WEBLib.Forms"].TForm).FCSSLibrary);
        };
      };
    };
    this.DestroyControls = function () {
      var i = 0;
      var ctrl = null;
      for (var $l = this.GetControlsCount() - 1; $l >= 0; $l--) {
        i = $l;
        ctrl = this.GetControls(i);
        ctrl = rtl.freeLoc(ctrl);
      };
    };
    this.ClearControls = function () {
      this.FControls = rtl.arraySetLength(this.FControls,null,0);
    };
    this.GetElementStyle = function () {
      var Result = null;
      Result = this.GetElementHandle().style;
      return Result;
    };
    this.InitCSSLibrary = function (ALibrary) {
    };
    this.SetControlCursor = function (Value) {
      this.FCursor = Value;
      if ((this.FElementClassName === "") && (this.GetElementHandle() != null)) {
        this.SetElementPointer(this.GetElementHandle(),Value);
      };
    };
    this.SetBiDiMode = function (Value) {
      if (this.GetElementHandle() != null) {
        if (Value === $mod.TBiDiMode.bdLeftToRight) {
          this.GetElementHandle().removeAttribute("dir")}
         else this.GetElementHandle().setAttribute("dir","rtl");
      };
    };
    this.GetMouseEventButton = function (Event) {
      var Result = 0;
      Result = $mod.TMouseButton.mbLeft;
      var $tmp = Event.button;
      if ($tmp === 0) {
        Result = $mod.TMouseButton.mbLeft}
       else if ($tmp === 1) {
        Result = $mod.TMouseButton.mbMiddle}
       else if ($tmp === 2) Result = $mod.TMouseButton.mbRight;
      return Result;
    };
    this.GetMouseEventShiftState = function (Event) {
      var Result = {};
      Result = {};
      if (Event.shiftKey) Result = rtl.unionSet(Result,rtl.createSet(pas.Classes.TShiftState$a.ssShift));
      if (Event.ctrlKey) Result = rtl.unionSet(Result,rtl.createSet(pas.Classes.TShiftState$a.ssCtrl));
      if (Event.altKey) Result = rtl.unionSet(Result,rtl.createSet(pas.Classes.TShiftState$a.ssAlt));
      if ((Event.buttons & 1) === 1) Result = rtl.unionSet(Result,rtl.createSet(pas.Classes.TShiftState$a.ssLeft));
      if ((Event.buttons & 2) === 2) Result = rtl.unionSet(Result,rtl.createSet(pas.Classes.TShiftState$a.ssRight));
      if ((Event.buttons & 4) === 4) Result = rtl.unionSet(Result,rtl.createSet(pas.Classes.TShiftState$a.ssMIDdle));
      return Result;
    };
    this.GetKeyBoardEventShiftState = function (Event) {
      var Result = {};
      Result = {};
      if (Event.shiftKey) Result = rtl.unionSet(Result,rtl.createSet(pas.Classes.TShiftState$a.ssShift));
      if (Event.ctrlKey) Result = rtl.unionSet(Result,rtl.createSet(pas.Classes.TShiftState$a.ssCtrl));
      if (Event.altKey) Result = rtl.unionSet(Result,rtl.createSet(pas.Classes.TShiftState$a.ssAlt));
      return Result;
    };
    this.GetMouseWheelEventShiftState = function (Event) {
      var Result = {};
      Result = {};
      if (Event.shiftKey) Result = rtl.unionSet(Result,rtl.createSet(pas.Classes.TShiftState$a.ssShift));
      if (Event.ctrlKey) Result = rtl.unionSet(Result,rtl.createSet(pas.Classes.TShiftState$a.ssCtrl));
      if (Event.altKey) Result = rtl.unionSet(Result,rtl.createSet(pas.Classes.TShiftState$a.ssAlt));
      return Result;
    };
    this.GetTouchEventShiftState = function (Event) {
      var Result = {};
      Result = {};
      if (Event.shiftKey) Result = rtl.unionSet(Result,rtl.createSet(pas.Classes.TShiftState$a.ssShift));
      if (Event.ctrlKey) Result = rtl.unionSet(Result,rtl.createSet(pas.Classes.TShiftState$a.ssCtrl));
      if (Event.altKey) Result = rtl.unionSet(Result,rtl.createSet(pas.Classes.TShiftState$a.ssAlt));
      return Result;
    };
    this.HandleDoClick = function (Event) {
      var Result = false;
      this.FElementEvent = Event;
      if ($mod.TElementEvent.eeClick in this.FEventStopPropagation) this.StopPropagation();
      if (this.FEnabled) this.Click();
      Result = true;
      this.FElementEvent = null;
      return Result;
    };
    this.HandleDoWheel = function (Event) {
      var Result = false;
      var ss = {};
      var h = false;
      var l = 0.0;
      var t = 0.0;
      this.FElementEvent = Event;
      this.StopPropagation();
      this.XYToClient(Event.clientX,Event.clientY,{get: function () {
          return l;
        }, set: function (v) {
          l = v;
        }},{get: function () {
          return t;
        }, set: function (v) {
          t = v;
        }});
      this.FWheelMousePos.x = Math.round(l);
      this.FWheelMousePos.y = Math.round(t);
      ss = rtl.refSet(this.GetMouseWheelEventShiftState(Event));
      h = false;
      this.MouseWheel(rtl.refSet(ss),pas.System.Trunc(-Event.deltaY),{get: function () {
          return h;
        }, set: function (v) {
          h = v;
        }});
      Result = true;
      this.FElementEvent = null;
      return Result;
    };
    this.HandleDoDblClick = function (Event) {
      var Result = false;
      this.FCaptureDown = false;
      this.FElementEvent = Event;
      if ($mod.TElementEvent.eeDblClick in this.FEventStopPropagation) this.StopPropagation();
      if (this.FEnabled) this.DblClick();
      Result = true;
      this.FElementEvent = null;
      return Result;
    };
    this.HandleDoMouseDown = function (Event) {
      var Result = false;
      var l = 0.0;
      var t = 0.0;
      var ss = {};
      var mb = 0;
      var AEvent = null;
      AEvent = Event;
      this.FElementEvent = AEvent;
      if ($mod.TElementEvent.eeMouseDown in this.FEventStopPropagation) this.StopPropagation();
      if (!this.CanFocus()) this.PreventDefault();
      $impl.FMouseX = Math.round(AEvent.clientX);
      $impl.FMouseY = Math.round(AEvent.clientY);
      this.XYToClient(AEvent.clientX,AEvent.clientY,{get: function () {
          return l;
        }, set: function (v) {
          l = v;
        }},{get: function () {
          return t;
        }, set: function (v) {
          t = v;
        }});
      if (this.HasVertScrollBar() && (l > (this.GetWidth() - $mod.GetScrollBarWidth()))) return Result;
      if (this.HasHorzScrollBar() && (t > (this.GetHeight() - $mod.GetScrollBarHeight()))) return Result;
      ss = rtl.refSet(this.GetMouseEventShiftState(AEvent));
      mb = this.GetMouseEventButton(AEvent);
      this.MouseDown(mb,rtl.refSet(ss),pas.System.Trunc(l),pas.System.Trunc(t));
      Result = true;
      this.FElementEvent = null;
      return Result;
    };
    this.HandleDoMouseUp = function (Event) {
      var Result = false;
      var l = 0.0;
      var t = 0.0;
      var ss = {};
      var mb = 0;
      var AEvent = null;
      AEvent = Event;
      this.FElementEvent = AEvent;
      if ($mod.TElementEvent.eeMouseUp in this.FEventStopPropagation) this.StopPropagation();
      this.XYToClient(AEvent.clientX,AEvent.clientY,{get: function () {
          return l;
        }, set: function (v) {
          l = v;
        }},{get: function () {
          return t;
        }, set: function (v) {
          t = v;
        }});
      if (this.HasVertScrollBar() && (l > (this.GetWidth() - $mod.GetScrollBarWidth()))) {
        this.FElementEvent = null;
        return Result;
      };
      if (this.HasHorzScrollBar() && (t > (this.GetHeight() - $mod.GetScrollBarHeight()))) {
        this.FElementEvent = null;
        return Result;
      };
      ss = rtl.refSet(this.GetMouseEventShiftState(AEvent));
      mb = this.GetMouseEventButton(AEvent);
      if (this.FDragMode === $mod.TDragMode.dmManual) this.DisableDrag();
      this.MouseUp(mb,rtl.refSet(ss),pas.System.Trunc(l),pas.System.Trunc(t));
      Result = true;
      this.FElementEvent = null;
      return Result;
    };
    this.HandleDoMouseMove = function (Event) {
      var Result = false;
      var l = 0.0;
      var t = 0.0;
      var ss = {};
      var AEvent = null;
      AEvent = Event;
      this.FElementEvent = AEvent;
      $impl.FCursorX = Math.round(AEvent.clientX);
      $impl.FCursorY = Math.round(AEvent.clientY);
      if ($mod.TElementEvent.eeMouseMove in this.FEventStopPropagation) this.StopPropagation();
      this.XYToClient(AEvent.clientX,AEvent.clientY,{get: function () {
          return l;
        }, set: function (v) {
          l = v;
        }},{get: function () {
          return t;
        }, set: function (v) {
          t = v;
        }});
      ss = rtl.refSet(this.GetMouseEventShiftState(AEvent));
      this.MouseMove(rtl.refSet(ss),pas.System.Trunc(l),pas.System.Trunc(t));
      Result = true;
      this.FElementEvent = null;
      return Result;
    };
    this.HandleDoMouseLeave = function (Event) {
      var Result = false;
      if (this.Captured()) return Result;
      Event.stopPropagation();
      this.DoMouseLeave();
      Result = true;
      return Result;
    };
    this.HandleDoContextMenu = function (Event) {
      var Result = false;
      Result = true;
      return Result;
    };
    this.LayerHandleDoMouseEnter = function (Event) {
      var Result = false;
      if ((Event.buttons === 0) && this.Captured() && !this.FMouseInsideLayer) {
        this.ReleaseCapture();
        this.HandleDoMouseUp(Event);
        this.HandleDoMouseLeave(Event);
      };
      this.FMouseInsideLayer = true;
      Result = true;
      return Result;
    };
    this.LayerHandleDoMouseLeave = function (Event) {
      var Result = false;
      this.FMouseInsideLayer = false;
      Result = true;
      return Result;
    };
    this.HandleDoMouseEnter = function (Event) {
      var Result = false;
      if (this.Captured()) return Result;
      Event.stopPropagation();
      this.DoMouseEnter();
      Result = true;
      return Result;
    };
    this.HandleDoKeyDown = function (Event) {
      var Result = false;
      var k = 0;
      var ss = {};
      var undef = false;
      var AEvent = null;
      AEvent = Event;
      this.FElementEvent = AEvent;
      if ($mod.TElementEvent.eeKeyDown in this.FEventStopPropagation) this.StopPropagation();
      undef = (AEvent.key == undefined);
      if (!undef) {
        k = this.GetKeyCode(AEvent.key,true);
        ss = rtl.refSet(this.GetKeyBoardEventShiftState(AEvent));
        this.KeyDown({get: function () {
            return k;
          }, set: function (v) {
            k = v;
          }},rtl.refSet(ss));
        if (k in rtl.createSet(13,27,9)) {
          this.KeyPreview({get: function () {
              return k;
            }, set: function (v) {
              k = v;
            }},rtl.refSet(ss));
        };
      };
      Result = true;
      if (k === 0) this.PreventDefault();
      this.FElementEvent = null;
      return Result;
    };
    this.HandleDoKeyUp = function (Event) {
      var Result = false;
      var k = 0;
      var ss = {};
      var c = "\x00";
      var undef = false;
      var AEvent = null;
      AEvent = Event;
      this.FElementEvent = AEvent;
      if ($mod.TElementEvent.eeKeyUp in this.FEventStopPropagation) this.StopPropagation();
      undef = (AEvent.key == undefined);
      if (!undef) {
        k = this.GetKeyCode(AEvent.key,true);
        ss = rtl.refSet(this.GetKeyBoardEventShiftState(AEvent));
        if (k === 27) {
          c = "\x1B";
          this.KeyPress({get: function () {
              return c;
            }, set: function (v) {
              c = v;
            }});
        };
        this.KeyUp({get: function () {
            return k;
          }, set: function (v) {
            k = v;
          }},rtl.refSet(ss));
      };
      Result = true;
      if (k === 0) this.PreventDefault();
      this.FElementEvent = null;
      return Result;
    };
    this.HandleDoKeyPress = function (Event) {
      var Result = false;
      var c = "\x00";
      var AEvent = null;
      AEvent = Event;
      this.FElementEvent = AEvent;
      if ($mod.TElementEvent.eeKeyPress in this.FEventStopPropagation) this.StopPropagation();
      if (this.IsKeyCharacter(AEvent.key)) {
        c = this.GetKeyChar(AEvent.key);
        this.KeyPress({get: function () {
            return c;
          }, set: function (v) {
            c = v;
          }});
      };
      Result = true;
      if (c === "\x00") this.PreventDefault();
      this.FElementEvent = null;
      return Result;
    };
    this.HandleDoInput = function (Event) {
      var Result = false;
      var c = "\x00";
      var stemp = "";
      if ($mod.IsAndroid()) {
        this.FElementEvent = Event;
        if ($mod.TElementEvent.eeKeyPress in this.FEventStopPropagation) this.StopPropagation();
        c = "\x00";
        if (Event.data !== "") {
          stemp = Event.data;
          if (pas.System.Assigned(stemp)) {
            c = stemp.charAt(stemp.length - 1)}
           else c = "\b";
          this.KeyPress({get: function () {
              return c;
            }, set: function (v) {
              c = v;
            }});
        };
        Result = true;
        if (c === "\x00") this.PreventDefault();
        this.FElementEvent = null;
      };
      return Result;
    };
    this.HandleDoExit = function (Event) {
      var Result = false;
      this.DoExit();
      Result = true;
      this.FocusedControlExited();
      return Result;
    };
    this.HandleDoEnter = function (Event) {
      var Result = false;
      this.FElementEvent = Event;
      this.StopPropagation();
      this.DoEnter();
      Result = true;
      this.FElementEvent = null;
      this.FGotFocus = true;
      this.FocusedControlEntered();
      return Result;
    };
    this.HandleDoTouchStart = function (Event) {
      var Result = false;
      var l = 0.0;
      var t = 0.0;
      var touch = null;
      var ss = {};
      this.FElementEvent = Event;
      this.FLastElementEvent = Event;
      this.StopPropagation();
      if (!this.FAllowTouch) this.PreventDefault();
      if (Event.touches.length > 0) {
        touch = Event.touches.item(0);
        this.XYToClient(touch.clientX,touch.clientY,{get: function () {
            return l;
          }, set: function (v) {
            l = v;
          }},{get: function () {
            return t;
          }, set: function (v) {
            t = v;
          }});
        ss = rtl.refSet(this.GetTouchEventShiftState(Event));
        if (this.FLinkTouchEvents) {
          this.MouseDown($mod.TMouseButton.mbLeft,rtl.refSet(ss),pas.System.Trunc(l),pas.System.Trunc(t));
        };
        this.TouchStart(pas.System.Trunc(l),pas.System.Trunc(t));
      };
      Result = true;
      this.FElementEvent = null;
      return Result;
    };
    this.HandleDoTouchMove = function (Event) {
      var Result = false;
      var l = 0.0;
      var t = 0.0;
      var touch = null;
      var ss = {};
      this.FElementEvent = Event;
      this.FLastElementEvent = Event;
      this.StopPropagation();
      if (!this.FAllowTouch) this.PreventDefault();
      if (this.Captured()) this.PreventDefault();
      if (Event.touches.length > 0) {
        touch = Event.touches.item(0);
        this.XYToClient(touch.clientX,touch.clientY,{get: function () {
            return l;
          }, set: function (v) {
            l = v;
          }},{get: function () {
            return t;
          }, set: function (v) {
            t = v;
          }});
        ss = rtl.refSet(this.GetTouchEventShiftState(Event));
        if (this.FLinkTouchEvents) this.MouseMove(rtl.refSet(ss),pas.System.Trunc(l),pas.System.Trunc(t));
        this.TouchMove(pas.System.Trunc(l),pas.System.Trunc(t));
      };
      this.FElementEvent = null;
      Result = true;
      return Result;
    };
    this.HandleDoTouchEnd = function (Event) {
      var Result = false;
      var l = 0.0;
      var t = 0.0;
      var touch = null;
      var ss = {};
      this.FElementEvent = Event;
      if (!this.FAllowTouch) this.PreventDefault();
      this.ReleaseCapture();
      this.StopPropagation();
      if ((this.FLastElementEvent != null) && (this.FLastElementEvent.touches.length > 0)) {
        touch = this.FLastElementEvent.touches.item(0);
        this.XYToClient(touch.clientX,touch.clientY,{get: function () {
            return l;
          }, set: function (v) {
            l = v;
          }},{get: function () {
            return t;
          }, set: function (v) {
            t = v;
          }});
        ss = rtl.refSet(this.GetTouchEventShiftState(Event));
        if (this.FLinkTouchEvents) {
          this.MouseUp($mod.TMouseButton.mbLeft,rtl.refSet(ss),pas.System.Trunc(l),pas.System.Trunc(t));
          if (this.FEnabled && !this.FAllowTouch) this.Click();
        };
        this.TouchEnd(pas.System.Trunc(l),pas.System.Trunc(t));
      };
      this.FElementEvent = null;
      Result = true;
      return Result;
    };
    this.HandleDoTouchCancel = function (Event) {
      var Result = false;
      var l = 0.0;
      var t = 0.0;
      var touch = null;
      var ss = {};
      this.FElementEvent = Event;
      this.ReleaseCapture();
      this.StopPropagation();
      if (Event.touches.length > 0) {
        touch = Event.touches.item(0);
        this.XYToClient(touch.clientX,touch.clientY,{get: function () {
            return l;
          }, set: function (v) {
            l = v;
          }},{get: function () {
            return t;
          }, set: function (v) {
            t = v;
          }});
        ss = rtl.refSet(this.GetTouchEventShiftState(Event));
        if (this.FLinkTouchEvents) {
          this.MouseUp($mod.TMouseButton.mbLeft,rtl.refSet(ss),pas.System.Trunc(l),pas.System.Trunc(t));
        };
        this.TouchCancel(pas.System.Trunc(l),pas.System.Trunc(t));
      };
      this.FElementEvent = null;
      Result = true;
      return Result;
    };
    this.HandleDoDragStart = function (Event) {
      var Result = false;
      var obj = null;
      this.FElementEvent = Event;
      Event.stopPropagation();
      obj = null;
      this.DoStartDrag({get: function () {
          return obj;
        }, set: function (v) {
          obj = v;
        }});
      if (obj != null) {
        $impl.DragObject = obj}
       else $impl.DragObject = this;
      Result = true;
      return Result;
    };
    this.HandleDoDragOver = function (Event) {
      var Result = false;
      this.FElementEvent = Event;
      Event.stopPropagation();
      this.DragOver($impl.DragObject,Event.clientX,Event.clientY,$mod.TDragState.dsDragMove,{p: this, get: function () {
          return this.p.FAcceptDrag;
        }, set: function (v) {
          this.p.FAcceptDrag = v;
        }});
      if (this.FAcceptDrag && (!this.IsInputControl() || (Event.dataTransfer.items.length === 0))) Event.preventDefault();
      Result = !this.FAcceptDrag;
      this.FElementEvent = null;
      return Result;
    };
    this.HandleDoDragEnter = function (Event) {
      var Result = false;
      this.FElementEvent = Event;
      Event.stopPropagation();
      this.FAcceptDrag = this.IsInputControl();
      this.DragOver($impl.DragObject,Event.clientX,Event.clientY,$mod.TDragState.dsDragEnter,{p: this, get: function () {
          return this.p.FAcceptDrag;
        }, set: function (v) {
          this.p.FAcceptDrag = v;
        }});
      if (this.FAcceptDrag) Event.preventDefault();
      Result = !this.FAcceptDrag;
      this.FElementEvent = null;
      return Result;
    };
    this.HandledoDragLeave = function (Event) {
      var Result = false;
      this.FElementEvent = Event;
      Event.stopPropagation();
      this.DragOver($impl.DragObject,Event.clientX,Event.clientY,$mod.TDragState.dsDragLeave,{p: this, get: function () {
          return this.p.FAcceptDrag;
        }, set: function (v) {
          this.p.FAcceptDrag = v;
        }});
      Result = true;
      this.FElementEvent = null;
      return Result;
    };
    this.HandleDoDragEnd = function (Event) {
      var Result = false;
      this.FElementEvent = Event;
      Event.stopPropagation();
      this.DoEndDrag($impl.DragObject,Event.clientX,Event.clientY);
      Result = true;
      if (this.FDragMode === $mod.TDragMode.dmManual) this.DisableDrag();
      this.FElementEvent = null;
      return Result;
    };
    this.HandleDoDragDrop = function (Event) {
      var Result = false;
      this.FElementEvent = Event;
      Event.stopPropagation();
      if (!this.FAcceptDrag) {
        Event.preventDefault()}
       else {
        if (!this.IsInputControl()) Event.preventDefault();
        this.DragDrop($impl.DragObject,Event.clientX,Event.clientY);
      };
      Result = this.FAcceptDrag;
      this.FElementEvent = null;
      return Result;
    };
    this.HandleKeyPreview = function (Key) {
    };
    this.HandleFontChanged = function (Sender) {
      if (this.FUpdateCount === 0) {
        this.SetParentFont(false);
        this.ParentFontChanged();
      };
      this.FontChanged();
    };
    this.ParentFontChanged = function () {
      var i = 0;
      for (var $l = 0, $end = this.GetControlsCount() - 1; $l <= $end; $l++) {
        i = $l;
        if (this.GetControls(i).FParentFont) {
          this.GetControls(i).FFont.Assign(this.FFont);
          this.GetControls(i).FontChanged();
          this.GetControls(i).FParentFont = true;
          this.GetControls(i).ParentFontChanged();
        };
      };
    };
    this.DoExit = function () {
      if (this.FOnExit != null) this.FOnExit(this);
    };
    this.DoEnter = function () {
      if (this.FOnEnter != null) this.FOnEnter(this);
    };
    this.Click = function () {
      if ((this.FOnClick != null) && this.IsEnabled()) this.FOnClick(this);
    };
    this.UpdateElement = function () {
      if (this.FBlockUpdateElement || (this.FUpdateCount > 0)) return;
      if ((this.GetElementHandle() != null) && (this.GetElementHandle() !== this.ContainerElement()) && !this.IsUpdating()) {
        this.UpdateElementData();
        if (!this.GetIsLinked()) {
          this.UpdateElementVisual();
        };
      };
    };
    this.UpdateElementSize = function () {
      var es = null;
      var offsLeft = 0;
      var offsTop = 0;
      var ow = 0;
      var ctrl = null;
      var cr = null;
      if (this.FBlockUpdateElement || (this.FUpdateCount > 0)) return;
      if (this.GetIsLinked()) return;
      if ((this.GetElementHandle() != null) && (this.GetElementHandle() !== this.ContainerElement())) {
        es = this.GetElementStyle();
        offsLeft = 0;
        offsTop = 0;
        ctrl = this.FParent;
        while ((ctrl != null) && (this.FElementPosition === $mod.TElementPosition.epAbsolute) && (ctrl.FElementPosition !== $mod.TElementPosition.epAbsolute) && !pas["WEBLib.Forms"].TCustomForm.isPrototypeOf(ctrl)) {
          if (ctrl.GetIsLinked() && (ctrl.GetElementHandle() != null) && (ctrl.GetElementHandle().style.getPropertyValue("position") !== "absolute")) {
            cr = ctrl.GetElementHandle().getBoundingClientRect();
            offsLeft = Math.round(cr.left);
            offsTop = Math.round(cr.top);
            if ((ctrl.FParent != null) && (ctrl.FParent.GetElementHandle() != null) && (ctrl.FParent.GetElementHandle().style.getPropertyValue("position") === "absolute")) {
              cr = ctrl.FParent.GetElementHandle().getBoundingClientRect();
              offsLeft = offsLeft - Math.round(cr.left);
              offsTop = offsTop - Math.round(cr.top);
            };
            break;
          };
          ctrl = ctrl.FParent;
        };
        if ((this.FParent != null) && this.FParent.IsStructuralElement()) {
          offsLeft = this.FParent.GetLeft();
          offsTop = this.FParent.GetTop();
        };
        if (this.FElementPosition === $mod.TElementPosition.epAbsolute) {
          if (this.FTop !== -1) {
            es.setProperty("top",pas.SysUtils.IntToStr(this.FTop + offsTop) + "px")}
           else es.setProperty("top","");
          if (this.FLeft !== -1) {
            es.setProperty("left",pas.SysUtils.IntToStr(this.FLeft + offsLeft) + "px")}
           else es.setProperty("left","");
        } else {
          es.removeProperty("top");
          es.removeProperty("left");
        };
        if (this.FWidthStyle === $mod.TSizeStyle.ssAbsolute) {
          ow = this.GetOuterWidth();
          if (this.FWidth !== -1) {
            es.setProperty("width",pas.SysUtils.IntToStr(ow) + "px")}
           else es.removeProperty("width");
        };
        if (this.FWidthStyle === $mod.TSizeStyle.ssAuto) {
          es.removeProperty("width");
        };
        if (this.FHeightStyle === $mod.TSizeStyle.ssAbsolute) {
          if (this.FHeight !== -1) {
            es.setProperty("height",pas.SysUtils.IntToStr(this.GetOuterHeight()) + "px")}
           else es.removeProperty("height");
        };
        if (this.FHeightStyle === $mod.TSizeStyle.ssAuto) {
          es.removeProperty("height");
        };
        if (this.FWidthStyle === $mod.TSizeStyle.ssPercent) {
          if (this.FWidth !== -1) {
            es.setProperty("width",pas["WEBLib.Utils"].FormatProp("%.2f%%",pas.System.VarRecs(3,this.FWidthPercent)))}
           else es.removeProperty("width");
        };
        if (this.FHeightStyle === $mod.TSizeStyle.ssPercent) {
          if (this.FHeight !== -1) {
            es.setProperty("height",pas["WEBLib.Utils"].FormatProp("%.2f%%",pas.System.VarRecs(3,this.FHeightPercent)))}
           else es.removeProperty("height");
        };
        if (this.FElementPosition === $mod.TElementPosition.epAbsolute) {
          es.setProperty("position","absolute")}
         else if (this.FElementPosition === $mod.TElementPosition.epRelative) {
          es.setProperty("position","relative")}
         else es.removeProperty("position");
        es.setProperty("box-sizing","border-box");
      };
    };
    this.UpdateElementVisual = function () {
      var eh = null;
      var es = null;
      var useCSS = false;
      eh = this.GetElementHandle();
      if (!(eh != null)) return;
      if (this.IsUpdating()) return;
      es = this.GetElementStyle();
      if (this.FParentFont && (this.FParent != null)) {
        this.FFont.FOnChange = null;
        this.FFont.Assign(this.FParent.FFont);
        this.FFont.FOnChange = rtl.createCallback(this,"HandleFontChanged");
      };
      if (this.FElementClassName === "") {
        if (!this.GetIsLinked()) {
          if (this.FClipChildren && (pas.SysUtils.LowerCase(eh.tagName) !== pas["WEBLib.WebTools"].cBodyTag)) {
            es.setProperty("overflow","hidden")}
           else es.setProperty("overflow","");
        };
        this.SetElementPointer(eh,this.FCursor);
      };
      if (this.Captured()) this.FLayer.style.setProperty("cursor",es.getPropertyValue("cursor"));
      if ((this.FElementClassName !== "") || this.CanShowFocus()) {
        es.setProperty("outline","")}
       else es.setProperty("outline","none");
      this.UpdateElementSize();
      var $tmp = this.FTextDirection;
      if ($tmp === $mod.TTextDirection.tdDefault) {
        es.removeProperty("direction")}
       else if ($tmp === $mod.TTextDirection.tdRightToLeft) {
        es.setProperty("direction","rtl")}
       else if ($tmp === $mod.TTextDirection.tdLeftToRight) {
        es.setProperty("direction","ltr")}
       else if ($tmp === $mod.TTextDirection.tdInherit) es.setProperty("direction","inherit");
      if ((this.FElementClassName === "") && this.FNoUserSelect) {
        es.setProperty("webkit-user-select","none");
        es.setProperty("moz-user-select","none");
        es.setProperty("khtml-user-select","none");
        es.setProperty("ms-user-select","none");
        es.setProperty("user-select","none");
        es.setProperty("-webkit-tap-highlight-color","transparent");
      };
      this.SetElementColor(eh,this.FColor);
      useCSS = this.UseCSSFont();
      if (!this.GetIsLinked()) $mod.SetHTMLElementFont(eh,this.FFont,useCSS);
      if (!useCSS) {
        if (this.IsEnabled() && this.UseCSSFontColor()) es.setProperty("color",pas["WEBLib.Graphics"].ColorToHTML(this.FFont.FColor));
      } else {
        es.removeProperty("color");
      };
    };
    this.UpdateElementData = function () {
      var frm = null;
      var el = null;
      var AToolTip = "";
      var ToolTipClass = "";
      var ToolTipPos = "";
      var ToolTipPause = 0;
      var ToolTipHidePause = 0;
      var tt = undefined;
      var isBootstrap = false;
      if (this.GetElementHandle() != null) {
        if (!(pas.Classes.TComponentStateItem.csDesigning in this.FComponentState)) {
          if (this.FVisible) {
            this.GetElementStyle().setProperty("display","")}
           else this.GetElementStyle().setProperty("display","none");
        };
        this.EnableTab();
        if (this.FContainer != null) {
          if (this.IsEnabled()) {
            this.FContainer.removeAttribute("disabled");
            this.FContainer.style.removeProperty("pointer-events");
          } else {
            this.FContainer.setAttribute("disabled","");
            this.FContainer.style.setProperty("pointer-events","none");
          };
        };
        if (this.GetIsLinked() && (this.FHint === "")) return;
        if ((this.FContainer != null) && (this.GetRole() !== "")) this.FContainer.setAttribute("role",this.FRole);
        frm = pas["WEBLib.Forms"].GetParentForm(this);
        isBootstrap = (frm != null) && (frm.FCSSLibrary === $mod.TCSSLibrary.cssBootstrap);
        if (isBootstrap && this.FShowHint && (this.FHint !== "")) {
          el = this.GetElementHandle();
          AToolTip = this.FHint;
          var $tmp = pas["WEBLib.Forms"].Application.FHintPosition;
          if ($tmp === pas["WEBLib.Forms"].THintPosition.hpLeft) {
            ToolTipPos = "left"}
           else if ($tmp === pas["WEBLib.Forms"].THintPosition.hpRight) {
            ToolTipPos = "right"}
           else if ($tmp === pas["WEBLib.Forms"].THintPosition.hpTop) {
            ToolTipPos = "top"}
           else if ($tmp === pas["WEBLib.Forms"].THintPosition.hpBottom) ToolTipPos = "bottom";
          ToolTipClass = pas["WEBLib.Forms"].Application.FHintClassName;
          ToolTipPause = pas["WEBLib.Forms"].Application.FHintPause;
          ToolTipHidePause = pas["WEBLib.Forms"].Application.FHintHidePause;
          tt = this.FToolTip;
          if (tt) { tt.dispose(); }
          el.setAttribute('title',AToolTip);
          tt = new bootstrap.Tooltip(el, {
          title: AToolTip,
          trigger: 'hover',
          placement: ToolTipPos,
          customClass: ToolTipClass,
          delay: { "show": ToolTipPause, "hide": ToolTipHidePause }
          });
          this.FToolTip = tt;
        } else {
          if (this.FContainer != null) {
            if (this.FShowHint && (this.FHint !== "")) {
              if (isBootstrap) {
                this.FContainer.setAttribute("data-title",this.FHint)}
               else this.FContainer.setAttribute("title",this.FHint);
            } else {
              if (isBootstrap) {
                this.FContainer.removeAttribute("data-title")}
               else this.FContainer.removeAttribute("title");
            };
          };
        };
        if (!this.IsEnabled() || (this.FElementFont === $mod.TElementFont.efCSS)) {
          this.GetElementStyle().removeProperty("color")}
         else if (this.UseCSSFontColor()) this.GetElementStyle().setProperty("color",pas["WEBLib.Graphics"].ColorToHTML(this.FFont.FColor));
      };
    };
    this.UpdateParent = function () {
      this.InternalUpdateParent();
      this.UpdateChildren(this.FPrevParent);
      this.UpdateChildren(this.FParent);
    };
    this.UpdateControlSize = function (AWidth, AHeight) {
      this.FWidth = AWidth;
      this.FHeight = AHeight;
    };
    this.InternalUpdateParent = function () {
      var p = null;
      p = this.FPrevParent;
      if (this.FNew) {
        this.CreateControl();
        if (this.GetContainer() != null) {
          if ((this.FParent != null) && !(this.FParent.GetContainer() != null)) this.FParent.CreateControl();
          if ((this.FParent !== p) && (p != null) && (p.GetContainer() != null)) {
            if (this.GetContainer().parentNode === p.GetChildContainer()) p.GetChildContainer().removeChild(this.GetContainer());
          };
          if ((this.FParent != null) && (this.FParent.GetContainer() != null)) {
            this.FParent.GetChildContainer().appendChild(this.GetContainer());
          };
        };
      };
    };
    this.UpdateChildren = function (AControl) {
      var I = 0;
      var c = null;
      if ((AControl != null) && !(pas.Classes.TComponentStateItem.csDestroying in this.FComponentState)) {
        if (AControl.FAlign !== $mod.TAlign.alNone) AControl.DoRealign();
        if ($mod.TCustomControl.isPrototypeOf(AControl)) {
          rtl.as(AControl,$mod.TCustomControl).RecreateCanvas();
          rtl.as(AControl,$mod.TCustomControl).Invalidate();
        };
        for (var $l = 0, $end = AControl.GetControlsCount() - 1; $l <= $end; $l++) {
          I = $l;
          c = AControl.GetControls(I);
          this.UpdateChildren(c);
        };
      };
    };
    this.PersistinHTML = function () {
      var i = 0;
      for (var $l = 0, $end = this.GetControlsCount() - 1; $l <= $end; $l++) {
        i = $l;
        this.GetControls(i).PersistinHTML();
      };
    };
    this.LoadFromHTML = function (HTML) {
      if (this.GetElementHandle() != null) this.GetElementHandle().outerHTML = HTML;
    };
    this.InitFromHTML = function () {
      var i = 0;
      for (var $l = 0, $end = this.GetControlsCount() - 1; $l <= $end; $l++) {
        i = $l;
        this.GetControls(i).InitFromHTML();
      };
    };
    this.SaveState = function () {
      var Result = "";
      Result = "";
      return Result;
    };
    this.LoadState = function (AState) {
    };
    this.DisableTab = function () {
      var i = 0;
      if (!(this.FTabStop && this.CanFocus())) {
        if (this.GetContainer() != null) this.GetContainer().setAttribute("tabindex","-1");
      };
      for (var $l = 0, $end = this.GetControlsCount() - 1; $l <= $end; $l++) {
        i = $l;
        this.GetControls(i).DisableTab();
      };
    };
    this.EnableTab = function () {
      var i = 0;
      if ((this.FContainer != null) && !this.GetIsLinked()) {
        if (this.FTabStop && this.CanFocus()) {
          this.FContainer.setAttribute("tabindex",pas.SysUtils.IntToStr(this.FTabOrder + 1));
        } else {
          this.FContainer.setAttribute("tabindex","-1");
        };
      };
      for (var $l = 0, $end = this.GetControlsCount() - 1; $l <= $end; $l++) {
        i = $l;
        this.GetControls(i).EnableTab();
      };
    };
    this.SetElementClassName = function (AValue) {
      if (this.FElementClassName !== AValue) {
        this.FElementClassName = AValue;
        if (this.FContainer != null) this.FContainer.setAttribute("class",AValue);
        this.UpdateElement();
      };
    };
    this.SetColor = function (AValue) {
      this.FColor = AValue;
      this.UpdateElementVisual();
      this.ColorChanging();
    };
    this.SetFont = function (AValue) {
      this.FFont.SetName(AValue.FName);
      this.FFont.SetSize(AValue.FSize);
      this.FFont.SetStyle(rtl.refSet(AValue.FStyle));
      this.FFont.SetColor(AValue.FColor);
    };
    this.SetParent = function (AValue) {
      var isNew = false;
      if (AValue != null) AValue = AValue.CanAcceptChild(this);
      isNew = this.FNew;
      if (this.FParent !== AValue) {
        if (this.FParent != null) this.FParent.UnRegisterParent(this);
        this.FPrevParent = this.FParent;
        this.FParent = AValue;
        this.FGotFocus = false;
        this.UpdateParent();
        if (!(pas.Classes.TComponentStateItem.csDestroying in this.FComponentState)) {
          if (!isNew) this.UpdateElement();
          this.InitScript();
        };
        if (this.FParent != null) this.FParent.RegisterParent(this);
        if ((pas.Classes.TComponentStateItem.csLoading in this.FComponentState) && (this.FParent != null) && !(pas.Classes.TComponentStateItem.csLoading in this.FParent.FComponentState)) this.Loaded();
        if ((AValue != null) && (this.FParent != null) && !this.FParent.IsUpdating()) {
          if (this.FAlign !== $mod.TAlign.alNone) {
            this.DoRealign()}
           else this.Realign();
        };
        if (!(pas.Classes.TComponentStateItem.csDestroying in this.FComponentState)) this.Invalidate();
      };
    };
    this.RegisterParent = function (AValue) {
      this.FControls = rtl.arraySetLength(this.FControls,null,rtl.length(this.FControls) + 1);
      this.FControls[rtl.length(this.FControls) - 1] = AValue;
    };
    this.UnRegisterParent = function (AValue) {
      var i = 0;
      var flg = false;
      flg = false;
      for (var $l = 0, $end = rtl.length(this.FControls) - 1; $l <= $end; $l++) {
        i = $l;
        if (this.FControls[i] === AValue) {
          flg = true;
        };
        if (flg && (i < (rtl.length(this.FControls) - 1))) this.FControls[i] = this.FControls[i + 1];
      };
      if (flg) this.FControls = rtl.arraySetLength(this.FControls,null,rtl.length(this.FControls) - 1);
    };
    this.CanAcceptChild = function (AValue) {
      var Result = null;
      Result = this;
      return Result;
    };
    this.SetLeft = function (AValue) {
      if (this.FLeft !== AValue) {
        this.FLeft = AValue;
        this.ResetAnchoring();
        if (!this.FUpdateTopLeft) this.FOrigLeft = AValue;
        this.UpdateElementSize();
        this.RecreateCanvas();
        this.InternalResize();
        if (!(pas.Classes.TComponentStateItem.csLoading in this.FComponentState) && (this.FAlign !== $mod.TAlign.alNone) && (this.FParent != null)) {
          this.DoRealign();
        };
      };
    };
    this.SetTop = function (AValue) {
      if (this.FTop !== AValue) {
        this.FTop = AValue;
        this.ResetAnchoring();
        if (!this.FUpdateTopLeft) this.FOrigTop = AValue;
        this.UpdateElementSize();
        this.RecreateCanvas();
        this.InternalResize();
        if (!(pas.Classes.TComponentStateItem.csLoading in this.FComponentState) && (this.FAlign !== $mod.TAlign.alNone) && (this.FParent != null)) {
          this.DoRealign();
        };
      };
    };
    this.MouseUp = function (Button, Shift, X, Y) {
      if (!this.FEnabled) return;
      if (this.FOnMouseUp != null) this.FOnMouseUp(this,Button,rtl.refSet(Shift),X,Y);
    };
    this.MouseDown = function (Button, Shift, X, Y) {
      if (!this.FEnabled) return;
      if (this.FOnMouseDown != null) this.FOnMouseDown(this,Button,rtl.refSet(Shift),X,Y);
    };
    this.MouseMove = function (Shift, X, Y) {
      if (!this.FEnabled) return;
      if (this.FOnMouseMove != null) this.FOnMouseMove(this,rtl.refSet(Shift),X,Y);
    };
    this.TouchStart = function (X, Y) {
      if (this.FOnTouchStart != null) this.FOnTouchStart(this,X,Y);
    };
    this.TouchMove = function (X, Y) {
      if (this.FOnTouchMove != null) this.FOnTouchMove(this,X,Y);
    };
    this.TouchEnd = function (X, Y) {
      if (this.FOnTouchEnd != null) this.FOnTouchEnd(this,X,Y);
    };
    this.TouchCancel = function (X, Y) {
      if (this.FOnTouchCancel != null) this.FOnTouchCancel(this,X,Y);
    };
    this.DoMouseEnter = function () {
      if (this.FOnMouseEnter != null) this.FOnMouseEnter(this);
    };
    this.DoMouseLeave = function () {
      if (this.FOnMouseLeave != null) this.FOnMouseLeave(this);
    };
    this.MouseWheel = function (Shift, WheelDelta, Handled) {
      var IsNeg = false;
      if (this.FOnMouseWheel != null) this.FOnMouseWheel(this,rtl.refSet(Shift),WheelDelta,pas.Types.TPoint.$clone(pas.Types.Point(0,0)),Handled);
      this.FWheelAccumulator += WheelDelta;
      while (Math.abs(this.FWheelAccumulator) >= 120) {
        IsNeg = this.FWheelAccumulator < 0;
        this.FWheelAccumulator = Math.abs(this.FWheelAccumulator) - 120;
        if (IsNeg) {
          if (this.FWheelAccumulator !== 0) this.FWheelAccumulator = -this.FWheelAccumulator;
          this.DoMouseWheelDown(rtl.refSet(Shift),pas.Types.TPoint.$clone(this.FWheelMousePos));
        } else this.DoMouseWheelUp(rtl.refSet(Shift),pas.Types.TPoint.$clone(this.FWheelMousePos));
      };
    };
    this.DoMouseWheelDown = function (Shift, MousePos) {
      var Result = false;
      Result = false;
      if (this.FOnMouseWheelDown != null) this.FOnMouseWheelDown(this,rtl.refSet(Shift),pas.Types.TPoint.$clone(MousePos),{get: function () {
          return Result;
        }, set: function (v) {
          Result = v;
        }});
      return Result;
    };
    this.DoMouseWheelUp = function (Shift, MousePos) {
      var Result = false;
      Result = false;
      if (this.FOnMouseWheelUp != null) this.FOnMouseWheelUp(this,rtl.refSet(Shift),pas.Types.TPoint.$clone(MousePos),{get: function () {
          return Result;
        }, set: function (v) {
          Result = v;
        }});
      return Result;
    };
    this.DblClick = function () {
      if (this.FOnDblClick != null) this.FOnDblClick(this);
    };
    this.KeyDown = function (Key, Shift) {
      if (this.FOnKeyDown != null) this.FOnKeyDown(this,Key,rtl.refSet(Shift));
    };
    this.KeyPreview = function (Key, Shift) {
      if ((this.FOwner != null) && $mod.TControl.isPrototypeOf(this.FOwner)) {
        rtl.as(this.FOwner,$mod.TControl).KeyPreview(Key,rtl.refSet(Shift));
      };
    };
    this.KeyPress = function (Key) {
      if (this.FOnKeyPress != null) this.FOnKeyPress(this,Key);
    };
    this.KeyUp = function (Key, Shift) {
      if (this.FOnKeyUp != null) this.FOnKeyUp(this,Key,rtl.refSet(Shift));
    };
    this.SetFocus = function () {
      var e = null;
      if (!this.CanFocus()) return;
      if (this.GetElementHandle() != null) {
        e = this.GetElementHandle();
        if (this.FGotFocus) {
          e.focus();
        } else {
          setTimeout(function() {e.focus();}, 1);
        };
      };
    };
    this.DoMarginsChanged = function (Sender) {
      this.DoRealign();
    };
    this.DoCenterChanged = function (Sender) {
      this.DoRealign();
    };
    this.DoRealign = function () {
      if ((this.FParent != null) && !this.FParent.IsUpdating()) {
        this.FParent.AlignControl(this.FParent);
      };
    };
    this.DoBoundsChange = function () {
      var b = false;
      var frm = null;
      this.UpdateElementSize();
      this.RecreateCanvas();
      if (this.FIsResizing) return;
      this.FIsResizing = true;
      this.InternalResize();
      this.DoRealign();
      b = false;
      frm = pas["WEBLib.Forms"].GetParentForm(this);
      if (frm != null) {
        b = frm.FIsResizing$1;
        b = b || (frm.FUpdateCount > 0);
      };
      b = b || (this.FUpdateCount > 0);
      b = b || this.FIsAligning;
      if (!b) {
        this.UpdateChildAnchoring();
      };
      this.FIsResizing = false;
    };
    this.DoEndDrag = function (Target, X, Y) {
      if (this.FonEndDrag != null) this.FonEndDrag(this,Target,X,Y);
    };
    this.DoStartDrag = function (DragObject) {
      if (this.FOnStartDrag != null) this.FOnStartDrag(this,DragObject);
    };
    this.DragOver = function (Source, X, Y, State, Accept) {
      if (this.FOnDragOver != null) this.FOnDragOver(this,Source,X,Y,State,Accept);
    };
    this.IsFocused = function () {
      var Result = false;
      Result = this.FContainer === document.activeElement;
      return Result;
    };
    this.Focused = function () {
      var Result = false;
      Result = this.FContainer === document.activeElement;
      return Result;
    };
    this.GetID = function () {
      var Result = "";
      Result = this.FID;
      return Result;
    };
    this.GetElementHandle = function () {
      var Result = null;
      Result = null;
      if ((this.FContainer != null) && this.FControlCreated) Result = this.FContainer;
      return Result;
    };
    this.GetElementBindHandle = function () {
      var Result = null;
      Result = this.GetElementHandle();
      return Result;
    };
    this.GetElement = function () {
      var Result = null;
      Result = document.getElementById(this.GetID());
      return Result;
    };
    this.GetKeyCode = function (AValue, IgnoreCase) {
      var Result = 0;
      var i = 0;
      i = -1;
      var $tmp = AValue;
      if ($tmp === "Up") {
        i = 38}
       else if ($tmp === "Down") {
        i = 40}
       else if ($tmp === "Left") {
        i = 37}
       else if ($tmp === "Right") {
        i = 39}
       else if ($tmp === "!") {
        i = 56}
       else if ($tmp === '"') {
        i = 51}
       else if ($tmp === "#") {
        i = 51}
       else if ($tmp === "$") {
        i = 186}
       else if ($tmp === "%") {
        i = 192}
       else if ($tmp === "'") {
        i = 52}
       else if ($tmp === "(") {
        i = 53}
       else if ($tmp === ")") {
        i = 219}
       else if ($tmp === "*") {
        i = 106}
       else if ($tmp === "+") {
        i = 107}
       else if ($tmp === "-") {
        i = 109}
       else if ($tmp === ",") {
        i = 44}
       else if ($tmp === ".") {
        i = 46}
       else if ($tmp === "/") {
        i = 111}
       else if ($tmp === "\\") {
        i = 226}
       else if ($tmp === "=") {
        i = 187}
       else if ($tmp === "<") {
        i = 226}
       else if ($tmp === ">") {
        i = 226}
       else if ($tmp === pas.Web.TJSKeyNames.BackSpace) {
        i = 8}
       else if ($tmp === pas.Web.TJSKeyNames.Tab) {
        i = 9}
       else if ($tmp === pas.Web.TJSKeyNames.Enter) {
        i = 13}
       else if ($tmp === pas.Web.TJSKeyNames.Shift) {
        i = 16}
       else if ($tmp === pas.Web.TJSKeyNames.Control) {
        i = 17}
       else if ($tmp === pas.Web.TJSKeyNames.Alt) {
        i = 18}
       else if ($tmp === pas.Web.TJSKeyNames.Pause) {
        i = 19}
       else if ($tmp === pas.Web.TJSKeyNames.CapsLock) {
        i = 20}
       else if ($tmp === pas.Web.TJSKeyNames.Escape) {
        i = 27}
       else if ($tmp === pas.Web.TJSKeyNames.PageUp) {
        i = 33}
       else if ($tmp === pas.Web.TJSKeyNames.PageDown) {
        i = 34}
       else if ($tmp === pas.Web.TJSKeyNames._End) {
        i = 35}
       else if ($tmp === pas.Web.TJSKeyNames.Home) {
        i = 36}
       else if ($tmp === pas.Web.TJSKeyNames.ArrowLeft) {
        i = 37}
       else if ($tmp === pas.Web.TJSKeyNames.ArrowUp) {
        i = 38}
       else if ($tmp === pas.Web.TJSKeyNames.ArrowRight) {
        i = 39}
       else if ($tmp === pas.Web.TJSKeyNames.ArrowDown) {
        i = 40}
       else if ($tmp === pas.Web.TJSKeyNames.Insert) {
        i = 45}
       else if ($tmp === pas.Web.TJSKeyNames.Delete) {
        i = 46}
       else if ($tmp === pas.Web.TJSKeyNames.F1) {
        i = 112}
       else if ($tmp === pas.Web.TJSKeyNames.F2) {
        i = 113}
       else if ($tmp === pas.Web.TJSKeyNames.F3) {
        i = 114}
       else if ($tmp === pas.Web.TJSKeyNames.F4) {
        i = 115}
       else if ($tmp === pas.Web.TJSKeyNames.F5) {
        i = 116}
       else if ($tmp === pas.Web.TJSKeyNames.F6) {
        i = 117}
       else if ($tmp === pas.Web.TJSKeyNames.F7) {
        i = 118}
       else if ($tmp === pas.Web.TJSKeyNames.F8) {
        i = 119}
       else if ($tmp === pas.Web.TJSKeyNames.F9) {
        i = 120}
       else if ($tmp === pas.Web.TJSKeyNames.F10) {
        i = 121}
       else if ($tmp === pas.Web.TJSKeyNames.F11) {
        i = 122}
       else if ($tmp === pas.Web.TJSKeyNames.F12) {
        i = 123}
       else if ($tmp === pas.Web.TJSKeyNames.F13) {
        i = 124}
       else if ($tmp === pas.Web.TJSKeyNames.F14) {
        i = 125}
       else if ($tmp === pas.Web.TJSKeyNames.F15) {
        i = 126}
       else if ($tmp === pas.Web.TJSKeyNames.F16) {
        i = 127}
       else if ($tmp === pas.Web.TJSKeyNames.F17) {
        i = 128}
       else if ($tmp === pas.Web.TJSKeyNames.F18) {
        i = 129}
       else if ($tmp === pas.Web.TJSKeyNames.F19) {
        i = 130}
       else if ($tmp === pas.Web.TJSKeyNames.F20) {
        i = 131}
       else {
        if (pas.System.Assigned(AValue) && (AValue.length > 0)) {
          i = AValue.charCodeAt(1 - 1);
          if (IgnoreCase && (i >= 97) && (i <= 122)) {
            i = i & 0xDF}
           else if ((i >= 65) && (i <= 90)) {
            i = i | 0x40}
           else if (i > 122) i = i | 0x80;
        };
      };
      Result = i;
      return Result;
    };
    this.GetKeyChar = function (AValue) {
      var Result = "\x00";
      var i = 0;
      i = -1;
      Result = "\x00";
      var $tmp = AValue;
      if ($tmp === pas.Web.TJSKeyNames.BackSpace) {
        i = 8}
       else if ($tmp === pas.Web.TJSKeyNames.Tab) {
        i = 9}
       else if ($tmp === pas.Web.TJSKeyNames.Enter) {
        i = 13}
       else if ($tmp === pas.Web.TJSKeyNames.Shift) {
        i = 16}
       else if ($tmp === pas.Web.TJSKeyNames.Control) {
        i = 17}
       else if ($tmp === pas.Web.TJSKeyNames.Alt) {
        i = 18}
       else if ($tmp === pas.Web.TJSKeyNames.Pause) {
        i = 19}
       else if ($tmp === pas.Web.TJSKeyNames.CapsLock) {
        i = 20}
       else if ($tmp === pas.Web.TJSKeyNames.Escape) {
        i = 27}
       else if ($tmp === pas.Web.TJSKeyNames.PageUp) {
        i = 33}
       else if ($tmp === pas.Web.TJSKeyNames.PageDown) {
        i = 34}
       else if ($tmp === pas.Web.TJSKeyNames._End) {
        i = 35}
       else if ($tmp === pas.Web.TJSKeyNames.Home) {
        i = 36}
       else if ($tmp === pas.Web.TJSKeyNames.ArrowLeft) {
        i = 37}
       else if ($tmp === pas.Web.TJSKeyNames.ArrowUp) {
        i = 38}
       else if ($tmp === pas.Web.TJSKeyNames.ArrowRight) {
        i = 39}
       else if ($tmp === pas.Web.TJSKeyNames.ArrowDown) {
        i = 40}
       else if ($tmp === pas.Web.TJSKeyNames.Insert) {
        i = 45}
       else if ($tmp === pas.Web.TJSKeyNames.Delete) {
        i = 46}
       else if ($tmp === pas.Web.TJSKeyNames.F1) {
        i = 112}
       else if ($tmp === pas.Web.TJSKeyNames.F2) {
        i = 113}
       else if ($tmp === pas.Web.TJSKeyNames.F3) {
        i = 114}
       else if ($tmp === pas.Web.TJSKeyNames.F4) {
        i = 115}
       else if ($tmp === pas.Web.TJSKeyNames.F5) {
        i = 116}
       else if ($tmp === pas.Web.TJSKeyNames.F6) {
        i = 117}
       else if ($tmp === pas.Web.TJSKeyNames.F7) {
        i = 118}
       else if ($tmp === pas.Web.TJSKeyNames.F8) {
        i = 119}
       else if ($tmp === pas.Web.TJSKeyNames.F9) {
        i = 120}
       else if ($tmp === pas.Web.TJSKeyNames.F10) {
        i = 121}
       else if ($tmp === pas.Web.TJSKeyNames.F11) {
        i = 122}
       else if ($tmp === pas.Web.TJSKeyNames.F12) {
        i = 123}
       else if ($tmp === pas.Web.TJSKeyNames.F13) {
        i = 124}
       else if ($tmp === pas.Web.TJSKeyNames.F14) {
        i = 125}
       else if ($tmp === pas.Web.TJSKeyNames.F15) {
        i = 126}
       else if ($tmp === pas.Web.TJSKeyNames.F16) {
        i = 127}
       else if ($tmp === pas.Web.TJSKeyNames.F17) {
        i = 128}
       else if ($tmp === pas.Web.TJSKeyNames.F18) {
        i = 129}
       else if ($tmp === pas.Web.TJSKeyNames.F19) {
        i = 130}
       else if ($tmp === pas.Web.TJSKeyNames.F20) {
        i = 131}
       else {
        Result = AValue.charAt(0);
      };
      if (i !== -1) Result = String.fromCharCode(i);
      return Result;
    };
    this.IsKeyCharacter = function (AValue) {
      var Result = false;
      var $tmp = AValue;
      if (($tmp === "Up") || ($tmp === "Down") || ($tmp === "Left") || ($tmp === "Right") || ($tmp === pas.Web.TJSKeyNames.Shift) || ($tmp === pas.Web.TJSKeyNames.Control) || ($tmp === pas.Web.TJSKeyNames.Alt) || ($tmp === pas.Web.TJSKeyNames.Pause) || ($tmp === pas.Web.TJSKeyNames.CapsLock) || ($tmp === pas.Web.TJSKeyNames.PageUp) || ($tmp === pas.Web.TJSKeyNames.PageDown) || ($tmp === pas.Web.TJSKeyNames._End) || ($tmp === pas.Web.TJSKeyNames.Home) || ($tmp === pas.Web.TJSKeyNames.ArrowLeft) || ($tmp === pas.Web.TJSKeyNames.ArrowUp) || ($tmp === pas.Web.TJSKeyNames.ArrowRight) || ($tmp === pas.Web.TJSKeyNames.ArrowDown) || ($tmp === pas.Web.TJSKeyNames.Insert) || ($tmp === pas.Web.TJSKeyNames.Delete) || ($tmp === pas.Web.TJSKeyNames.F1) || ($tmp === pas.Web.TJSKeyNames.F2) || ($tmp === pas.Web.TJSKeyNames.F3) || ($tmp === pas.Web.TJSKeyNames.F4) || ($tmp === pas.Web.TJSKeyNames.F5) || ($tmp === pas.Web.TJSKeyNames.F6) || ($tmp === pas.Web.TJSKeyNames.F7) || ($tmp === pas.Web.TJSKeyNames.F8) || ($tmp === pas.Web.TJSKeyNames.F9) || ($tmp === pas.Web.TJSKeyNames.F10) || ($tmp === pas.Web.TJSKeyNames.F11) || ($tmp === pas.Web.TJSKeyNames.F12) || ($tmp === pas.Web.TJSKeyNames.F13) || ($tmp === pas.Web.TJSKeyNames.F14) || ($tmp === pas.Web.TJSKeyNames.F15) || ($tmp === pas.Web.TJSKeyNames.F16) || ($tmp === pas.Web.TJSKeyNames.F17) || ($tmp === pas.Web.TJSKeyNames.F18) || ($tmp === pas.Web.TJSKeyNames.F19) || ($tmp === pas.Web.TJSKeyNames.F20)) {
        Result = false}
       else {
        Result = true;
      };
      return Result;
    };
    this.GetClientRect = function () {
      var Result = pas.Types.TRect.$new();
      var css = "";
      var p = 0;
      var brdr = 0;
      css = pas.SysUtils.UpperCase(this.GetStyle("border-width"));
      brdr = 0;
      p = pas.System.Pos("PX",css);
      if (p > 0) {
        pas.System.Delete({get: function () {
            return css;
          }, set: function (v) {
            css = v;
          }},p,2);
        pas.System.val$6(css,{get: function () {
            return brdr;
          }, set: function (v) {
            brdr = v;
          }},{get: function () {
            return p;
          }, set: function (v) {
            p = v;
          }});
      };
      Result.$assign(pas.Types.Rect(0,0,this.GetWidth() - (2 * brdr),this.GetHeight() - (2 * brdr)));
      return Result;
    };
    this.CreateControl = function () {
      if (!(this.FElement != null)) {
        this.FElement = this.CreateElement();
        if (this.FElement != null) {
          this.FControlCreated = true;
          this.FContainer = this.FElement;
          if (!(this.GetID() === "body")) this.GetContainer().setAttribute("id",this.GetID());
          this.GetContainer().setAttribute("zindex","0");
          if (this.FElementClassName !== "") this.GetContainer().setAttribute("class",this.FElementClassName);
          this.CreateChildElements(this.FElement);
          this.BindEvents();
          this.UpdateElement();
        };
      };
    };
    this.ClearMethodPointers = function () {
      this.FWheelPtr = null;
      this.FClickPtr = null;
      this.FDblClickPtr = null;
      this.FMouseDownPtr = null;
      this.FMouseUpPtr = null;
      this.FMouseMovePtr = null;
      this.FMouseLeavePtr = null;
      this.FMouseEnterPtr = null;
      this.FKeyDownPtr = null;
      this.FKeyUpPtr = null;
      this.FKeyPressPtr = null;
      this.FInputPtr = null;
      this.FEnterPtr = null;
      this.FExitPtr = null;
      this.FTouchStartPtr = null;
      this.FTouchEndPtr = null;
      this.FTouchMovePtr = null;
      this.FTouchCancelPtr = null;
      this.FLayerMouseLeavePtr = null;
      this.FLayerMouseEnterPtr = null;
      this.FScriptLoadedPtr = null;
      this.FContextMenuPtr = null;
    };
    this.GetMethodPointers = function () {
      if (this.FWheelPtr === null) {
        this.FWheelPtr = rtl.createCallback(this,"HandleDoWheel");
        this.FClickPtr = rtl.createCallback(this,"HandleDoClick");
        this.FDblClickPtr = rtl.createCallback(this,"HandleDoDblClick");
        this.FMouseDownPtr = rtl.createCallback(this,"HandleDoMouseDown");
        this.FMouseUpPtr = rtl.createCallback(this,"HandleDoMouseUp");
        this.FMouseMovePtr = rtl.createCallback(this,"HandleDoMouseMove");
        this.FMouseLeavePtr = rtl.createCallback(this,"HandleDoMouseLeave");
        this.FMouseEnterPtr = rtl.createCallback(this,"HandleDoMouseEnter");
        this.FKeyDownPtr = rtl.createCallback(this,"HandleDoKeyDown");
        this.FKeyUpPtr = rtl.createCallback(this,"HandleDoKeyUp");
        this.FKeyPressPtr = rtl.createCallback(this,"HandleDoKeyPress");
        this.FInputPtr = rtl.createCallback(this,"HandleDoInput");
        this.FEnterPtr = rtl.createCallback(this,"HandleDoEnter");
        this.FExitPtr = rtl.createCallback(this,"HandleDoExit");
        this.FTouchStartPtr = rtl.createCallback(this,"HandleDoTouchStart");
        this.FTouchEndPtr = rtl.createCallback(this,"HandleDoTouchEnd");
        this.FTouchMovePtr = rtl.createCallback(this,"HandleDoTouchMove");
        this.FTouchCancelPtr = rtl.createCallback(this,"HandleDoTouchCancel");
        this.FLayerMouseLeavePtr = rtl.createCallback(this,"LayerHandleDoMouseLeave");
        this.FLayerMouseEnterPtr = rtl.createCallback(this,"LayerHandleDoMouseEnter");
        this.FScriptLoadedPtr = rtl.createCallback(this,"RequiredScriptLoaded");
        this.FDragStartPtr = rtl.createCallback(this,"HandleDoDragStart");
        this.FDragOverPtr = rtl.createCallback(this,"HandleDoDragOver");
        this.FDragEnterPtr = rtl.createCallback(this,"HandleDoDragEnter");
        this.FDragLeavePtr = rtl.createCallback(this,"HandledoDragLeave");
        this.FDragEndPtr = rtl.createCallback(this,"HandleDoDragEnd");
        this.FDragDropPtr = rtl.createCallback(this,"HandleDoDragDrop");
        this.FContextMenuPtr = rtl.createCallback(this,"HandleDoContextMenu");
      };
    };
    this.EventsBound = function () {
      var Result = false;
      Result = this.FEventsBound;
      return Result;
    };
    this.BindEvents = function () {
      var eh = null;
      var wp = null;
      if (this.GetElementBindHandle() != null) {
        this.GetMethodPointers();
        this.FEventsBound = true;
        eh = this.GetElementBindHandle();
        wp = this.FWheelPtr;
        eh.addEventListener('wheel', wp, { passive:true});
        eh.addEventListener("click",this.FClickPtr);
        eh.addEventListener("dblclick",this.FDblClickPtr);
        eh.addEventListener("mousedown",this.FMouseDownPtr);
        eh.addEventListener("mouseup",this.FMouseUpPtr);
        eh.addEventListener("mousemove",this.FMouseMovePtr);
        eh.addEventListener("mouseleave",this.FMouseLeavePtr);
        eh.addEventListener("mouseenter",this.FMouseEnterPtr);
        eh.addEventListener("keydown",this.FKeyDownPtr);
        eh.addEventListener("keyup",this.FKeyUpPtr);
        eh.addEventListener("keypress",this.FKeyPressPtr);
        eh.addEventListener("input",this.FInputPtr);
        eh.addEventListener("focus",this.FEnterPtr);
        eh.addEventListener("blur",this.FExitPtr);
        wp = this.FTouchStartPtr;
        eh.addEventListener('touchstart', wp, {passive: true});
        wp = this.FTouchMovePtr;
        eh.addEventListener('touchmove', wp, {passive:true});
        eh.addEventListener("touchend",this.FTouchEndPtr);
        eh.addEventListener("touchcancel",this.FTouchCancelPtr);
        eh.addEventListener("contextmenu",this.FContextMenuPtr);
        eh.addEventListener("dragstart",this.FDragStartPtr);
        eh.addEventListener("dragover",this.FDragOverPtr);
        eh.addEventListener("dragenter",this.FDragEnterPtr);
        eh.addEventListener("dragleave",this.FDragLeavePtr);
        eh.addEventListener("dragend",this.FDragEndPtr);
        eh.addEventListener("drop",this.FDragDropPtr);
      };
    };
    this.UnbindEvents = function () {
      var eh = null;
      this.ReleaseCapture();
      if (this.GetElementBindHandle() != null) {
        eh = this.GetElementBindHandle();
        eh.removeEventListener("wheel",this.FWheelPtr);
        eh.removeEventListener("click",this.FClickPtr);
        eh.removeEventListener("dblclick",this.FDblClickPtr);
        eh.removeEventListener("mousedown",this.FMouseDownPtr);
        eh.removeEventListener("mouseup",this.FMouseUpPtr);
        eh.removeEventListener("mousemove",this.FMouseMovePtr);
        eh.removeEventListener("mouseleave",this.FMouseLeavePtr);
        eh.removeEventListener("mouseenter",this.FMouseEnterPtr);
        eh.removeEventListener("keydown",this.FKeyDownPtr);
        eh.removeEventListener("keyup",this.FKeyUpPtr);
        eh.removeEventListener("keypress",this.FKeyPressPtr);
        eh.removeEventListener("focus",this.FEnterPtr);
        eh.removeEventListener("blur",this.FExitPtr);
        eh.removeEventListener("input",this.FInputPtr);
        eh.removeEventListener("touchstart",this.FTouchStartPtr);
        eh.removeEventListener("touchmove",this.FTouchMovePtr);
        eh.removeEventListener("touchend",this.FTouchEndPtr);
        eh.removeEventListener("touchcancel",this.FTouchEndPtr);
        eh.removeEventListener("contextmenu",this.FContextMenuPtr);
      };
    };
    this.UpdatePadding = function (ARect) {
    };
    this.AlignControls = function (AControl, ARect) {
      var $Self = this;
      var j = 0;
      function DoPosition(Control, AAlign) {
        var dl = 0;
        var dt = 0;
        var dr = 0;
        var db = 0;
        if (!Control.AnchoringInitialized()) $Self.InitAnchoring();
        Control.FUpdateTopLeft = true;
        if (Control.FAlignWithMargins) {
          dl = Control.FMargins.FLeft;
          dt = Control.FMargins.FTop;
          db = Control.FMargins.FBottom;
          dr = Control.FMargins.FRight;
        } else {
          dl = 0;
          dt = 0;
          db = 0;
          dr = 0;
        };
        var $tmp = AAlign;
        if ($tmp === $mod.TAlign.alTop) {
          Control.SetBoundsInt(ARect.Left + dl,ARect.Top + dt,ARect.Right - ARect.Left - dl - dr,Control.GetHeight());
          ARect.Top = ARect.Top + Control.GetHeight() + dt + db;
        } else if ($tmp === $mod.TAlign.alBottom) {
          Control.SetBoundsInt(ARect.Left + dl,ARect.Bottom - Control.GetHeight() - db - 1,ARect.Right - ARect.Left - dl - dr - 1,Control.GetHeight());
          ARect.Bottom = ARect.Bottom - Control.GetHeight() - dt - db;
        } else if ($tmp === $mod.TAlign.alLeft) {
          Control.SetBoundsInt(ARect.Left + dl,ARect.Top + dt,Control.GetWidth(),ARect.Bottom - ARect.Top - dt - db);
          ARect.Left = ARect.Left + Control.GetWidth() + dl + dr;
        } else if ($tmp === $mod.TAlign.alRight) {
          Control.SetBoundsInt(ARect.Right - Control.GetWidth() - dr,ARect.Top + dt,Control.GetWidth(),ARect.Bottom - ARect.Top - db - dt);
          ARect.Right = ARect.Right - Control.GetWidth() - dr - dl;
        } else if ($tmp === $mod.TAlign.alClient) {
          Control.SetBoundsInt(ARect.Left + dl,ARect.Top + dt,ARect.Right - ARect.Left - dl - dr,ARect.Bottom - ARect.Top - db - dt);
        } else if ($tmp === $mod.TAlign.alCustom) {
          dl = Control.GetLeft();
          dt = Control.GetTop();
          dr = 0;
          db = 0;
          if (Control.FCenter.FVertical || Control.FCenter.FHorizontal) {
            if (Control.FCenter.FHorizontal) {
              dl = ARect.Left;
              dr = rtl.trunc((ARect.Right - ARect.Left - Control.GetWidth()) / 2);
            };
            if (Control.FCenter.FVertical) {
              dt = ARect.Top;
              db = rtl.trunc((ARect.Bottom - ARect.Top - Control.GetHeight()) / 2);
            };
            Control.SetBoundsInt(dl + dr,dt + db,Control.GetWidth(),Control.GetHeight());
          };
        };
        Control.FUpdateTopLeft = false;
      };
      function DoAlign(AAlign) {
        var i = 0;
        var j = 0;
        var ins = 0;
        var il = null;
        var b = false;
        il = pas.Classes.TList.$create("Create$1");
        for (var $l = 0, $end = $Self.GetControlsCount() - 1; $l <= $end; $l++) {
          i = $l;
          b = ($Self.GetControls(i).FCenter.FVertical || $Self.GetControls(i).FCenter.FHorizontal) && (AAlign === $mod.TAlign.alCustom);
          if (b || (($Self.GetControls(i).FAlign === AAlign) && ($Self.GetControls(i).FVisible || (pas.Classes.TComponentStateItem.csDesigning in $Self.FComponentState)))) {
            ins = il.GetCount();
            for (var $l1 = il.GetCount() - 1; $l1 >= 0; $l1--) {
              j = $l1;
              var $tmp = AAlign;
              if ($tmp === $mod.TAlign.alTop) {
                if ($Self.GetControls(i).FOrigTop < rtl.getObject(il.Get(j)).FOrigTop) ins = j}
               else if ($tmp === $mod.TAlign.alLeft) {
                if ($Self.GetControls(i).FOrigLeft < rtl.getObject(il.Get(j)).FOrigLeft) ins = j}
               else if ($tmp === $mod.TAlign.alRight) {
                if (($Self.GetControls(i).FOrigLeft + $Self.GetControls(i).GetWidth()) > (rtl.getObject(il.Get(j)).FOrigLeft + rtl.getObject(il.Get(j)).GetWidth())) ins = j}
               else if ($tmp === $mod.TAlign.alBottom) if (($Self.GetControls(i).FOrigTop + $Self.GetControls(i).GetHeight()) > (rtl.getObject(il.Get(j)).FOrigTop + rtl.getObject(il.Get(j)).GetHeight())) ins = j;
            };
            il.Insert(ins,$Self.GetControls(i));
          };
        };
        for (var $l2 = 0, $end1 = il.GetCount() - 1; $l2 <= $end1; $l2++) {
          i = $l2;
          DoPosition(rtl.getObject(il.Get(i)),AAlign);
        };
        il = rtl.freeLoc(il);
      };
      this.UpdatePadding(ARect);
      DoAlign($mod.TAlign.alTop);
      DoAlign($mod.TAlign.alBottom);
      DoAlign($mod.TAlign.alLeft);
      DoAlign($mod.TAlign.alRight);
      DoAlign($mod.TAlign.alClient);
      DoAlign($mod.TAlign.alCustom);
      for (var $l = 0, $end = this.GetControlsCount() - 1; $l <= $end; $l++) {
        j = $l;
        this.GetControls(j).AlignControl(this.GetControls(j));
      };
    };
    this.AlignControl = function (AControl) {
      var r = pas.Types.TRect.$new();
      var cr = null;
      var ovf = "";
      var ovfx = "";
      var ovfy = "";
      var eh = null;
      var el = null;
      var frm = null;
      var ctop = 0;
      var vscrl = 0;
      var sbw = 0;
      if (this.FIsAligning) return;
      if (this.IsUpdating()) return;
      if (pas.Classes.TComponentStateItem.csLoading in this.FComponentState) return;
      if ((this.FParent != null) && !this.FParent.FVisible) return;
      frm = pas["WEBLib.Forms"].GetParentForm(this);
      if ((frm != null) && frm.IsUpdating()) return;
      ctop = 0;
      if ((frm != null) && (frm.FFormContainer !== "") && pas["WEBLib.Forms"].TCustomForm.isPrototypeOf(AControl)) {
        el = document.getElementById(frm.FFormContainer);
        if (el != null) {
          cr = el.getBoundingClientRect();
          ctop = Math.round(cr.top + 1);
        };
      };
      this.FIsAligning = true;
      if (!(AControl != null)) return;
      eh = AControl.GetElementHandle();
      if (eh != null) {
        ovf = AControl.GetElementStyle().getPropertyValue("overflow");
        ovfx = AControl.GetElementStyle().getPropertyValue("overflow-x");
        ovfy = AControl.GetElementStyle().getPropertyValue("overflow-y");
        if (this.FClipChildren && (pas.SysUtils.LowerCase(eh.tagName) !== pas["WEBLib.WebTools"].cBodyTag)) {
          AControl.GetElementStyle().setProperty("overflow","hidden")}
         else AControl.GetElementStyle().setProperty("overflow","");
      };
      r.$assign(this.GetClientRect());
      r.Bottom = r.Bottom - ctop;
      if (this.GetIsLinked()) {
        cr = this.GetElementHandle().getBoundingClientRect();
        r.$assign(pas.Types.Rect(0,0,Math.round(cr.right - cr.left),Math.round(cr.bottom - cr.top)));
      };
      if (((r.Bottom + ctop) > pas["WEBLib.Forms"].WinHeight()) && (this.FHeightStyle !== $mod.TSizeStyle.ssAbsolute) && !(this.FElementPosition === $mod.TElementPosition.epAbsolute) && !this.GetIsLinked() && !(pas["WEBLib.Forms"].VSIDE != null)) {
        if (((this.FParent != null) && pas["WEBLib.Forms"].TCustomForm.isPrototypeOf(this.FParent)) || pas["WEBLib.Forms"].TCustomForm.isPrototypeOf(this)) {
          r.Bottom = pas["WEBLib.Forms"].WinHeight() - ctop;
        };
      };
      if ((eh != null) && (eh.tagName === "BODY")) {
        vscrl = 0;
        if ((document.body.scrollHeight > document.body.clientHeight) && !(pas.Classes.TComponentStateItem.csDesigning in this.FComponentState)) vscrl = 16;
        if (frm.FFormContainer !== "") {
          r.Bottom = Math.round(Math.min(r.Bottom,pas["WEBLib.Forms"].WinHeight()));
          r.Right = Math.round(Math.min(r.Right - vscrl,pas["WEBLib.Forms"].WinWidth()));
        } else {
          r.Bottom = frm.GetHeight();
          r.Right = frm.GetWidth();
        };
      };
      if (pas["WEBLib.Forms"].TCustomForm.isPrototypeOf(AControl) && !(pas["WEBLib.Forms"].VSIDE != null)) {
        if (r.Bottom > pas["WEBLib.Forms"].WinHeight()) r.Bottom = pas["WEBLib.Forms"].WinHeight();
        if (r.Right > pas["WEBLib.Forms"].WinWidth()) r.Right = pas["WEBLib.Forms"].WinWidth();
      };
      if (AControl.IsStructuralElement()) {
        r.$assign(this.FParent.GetClientRect());
      };
      if ((pas["WEBLib.Forms"].Application.CalcScrollBarWidth() < 16) && !pas["WEBLib.Forms"].TCustomForm.isPrototypeOf(AControl)) {
        if ((AControl.FParent != null) && (AControl.GetElementHandle() != null)) {
          if (AControl.GetElementHandle().scrollHeight > AControl.GetElementHandle().clientHeight) {
            sbw = pas["WEBLib.Forms"].Application.CalcScrollBarWidth();
            if (sbw === 0) sbw = 16;
            r.Right = r.Right + (17 - sbw);
          };
        };
      };
      this.AlignControls(AControl,r);
      if (eh != null) {
        AControl.GetElementStyle().setProperty("overflow",ovf);
        AControl.GetElementStyle().setProperty("overflow-x",ovfx);
        AControl.GetElementStyle().setProperty("overflow-y",ovfy);
      };
      this.FIsAligning = false;
    };
    this.InitAnchoring = function () {
      var $Self = this;
      var i = 0;
      var dx = 0;
      var dy = 0;
      function SizeBorderOffset(AObject, ax, ay) {
        var prop = null;
        ax.set(0);
        ay.set(0);
        prop = pas.TypInfo.GetPropInfo(AObject.$class.ClassInfo(),"BorderStyle");
        if (prop != null) {
          i = pas.TypInfo.GetOrdProp$1(AObject,prop);
          if (i in rtl.createSet(1,4,5)) {
            ax.set(4);
            ay.set(4);
          };
          if (i in rtl.createSet(2,3)) {
            ax.set(16);
            ay.set(16);
          };
        };
      };
      if (this.AnchoringInitialized()) return;
      dx = 0;
      dy = 0;
      if (pas["WEBLib.Forms"].TForm.isPrototypeOf($Self)) {
        if (rtl.as($Self,pas["WEBLib.Forms"].TForm).IsMiletus()) SizeBorderOffset($Self,{get: function () {
            return dx;
          }, set: function (v) {
            dx = v;
          }},{get: function () {
            return dy;
          }, set: function (v) {
            dy = v;
          }});
        this.FOrigRect.$assign(pas.Types.Rect(0,0,this.GetDesignWidth() - dx,this.GetDesignHeight() - dy));
      } else {
        this.FOrigRect.$assign(pas.Types.Rect(this.GetDesignLeft(),this.GetDesignTop(),this.GetDesignLeft() + this.GetDesignWidth(),this.GetDesignTop() + this.GetDesignHeight()));
      };
      if (this.FParent != null) {
        if (pas["WEBLib.Forms"].TForm.isPrototypeOf(this.FParent)) {
          if (rtl.as(this.FParent,pas["WEBLib.Forms"].TForm).IsMiletus()) {
            SizeBorderOffset(this.FParent,{get: function () {
                return dx;
              }, set: function (v) {
                dx = v;
              }},{get: function () {
                return dy;
              }, set: function (v) {
                dy = v;
              }});
          };
          this.FOrigParentRect.$assign(pas.Types.Rect(0,0,this.FParent.GetDesignWidth() - dx,this.FParent.GetDesignHeight() - dy));
        } else {
          if (!this.FParent.AnchoringInitialized()) this.FParent.InitAnchoring();
          this.FOrigParentRect.$assign(pas.Types.Rect(this.FParent.GetDesignLeft(),this.FParent.GetDesignTop(),this.FParent.GetDesignLeft() + this.FParent.GetDesignWidth(),this.FParent.GetDesignTop() + this.FParent.GetDesignHeight()));
        };
      };
      for (var $l = 0, $end = this.GetControlsCount() - 1; $l <= $end; $l++) {
        i = $l;
        this.GetControls(i).InitAnchoring();
      };
    };
    this.AnchoringInitialized = function () {
      var Result = false;
      Result = (this.FOrigRect.Left !== -1) || (this.FOrigRect.Top !== -1);
      return Result;
    };
    this.InitScript = function () {
    };
    this.Realign = function () {
      this.AlignControl(this);
    };
    this.Loaded = function () {
      var i = 0;
      var NodeList = null;
      var NodeLen = 0;
      var CurIdx = 0;
      var TargetIdx = 0;
      var RefNode = null;
      var TargetNode = null;
      var C = null;
      if (!(pas.Classes.TComponentStateItem.csLoading in this.FComponentState)) return;
      pas.Classes.TComponent.Loaded.call(this);
      if (this.GetChildContainer() != null) {
        NodeList = this.GetChildContainer().childNodes;
        NodeLen = NodeList.length;
        for (var $l = 0, $end = this.GetControlsCount() - 1; $l <= $end; $l++) {
          i = $l;
          C = this.GetControls(i);
          if (!((C.FElementPosition in rtl.createSet($mod.TElementPosition.epRelative,$mod.TElementPosition.epIgnore)) && !C.GetIsLinked() && (C.FChildOrder >= 0))) {
            C.Loaded();
            continue;
          };
          TargetIdx = C.FChildOrder;
          TargetNode = C.GetContainer();
          if (TargetIdx >= NodeLen) {
            this.GetChildContainer().appendChild(TargetNode);
            C.Loaded();
            continue;
          };
          // Find current index of TargetNode inside NodeList
          CurIdx = Array.prototype.indexOf.call(NodeList, TargetNode);
          // If it moves forward, compensate for the removal
          if (CurIdx !== -1 && TargetIdx > CurIdx) { TargetIdx++; };
          if (CurIdx === -1) ;
          if (TargetIdx < NodeLen) {
            RefNode = NodeList.item(TargetIdx)}
           else RefNode = null;
          if (RefNode != null) {
            this.GetChildContainer().insertBefore(TargetNode,RefNode)}
           else this.GetChildContainer().appendChild(TargetNode);
          C.Loaded();
        };
      } else {
        for (var $l1 = 0, $end1 = this.GetControlsCount() - 1; $l1 <= $end1; $l1++) {
          i = $l1;
          this.GetControls(i).Loaded();
        };
      };
      for (var $l2 = 0, $end2 = this.GetComponentCount() - 1; $l2 <= $end2; $l2++) {
        i = $l2;
        if (pas.Classes.TComponentStateItem.csLoading in this.GetComponent(i).FComponentState) this.GetComponent(i).Loaded();
      };
      var $tmp = this.FAlign;
      if ($tmp === $mod.TAlign.alClient) {
        if (this.FParent != null) this.SetBoundsInt(0,0,this.FParent.FWidth,this.FParent.FHeight);
      };
      this.Resize();
      this.UpdateElement();
    };
    this.InternalResize = function () {
      if (pas.Classes.TComponentStateItem.csLoading in this.FComponentState) return;
      this.Resize();
    };
    this.FontChanged = function () {
      this.UpdateElementVisual();
    };
    this.DisposeOf = function () {
      var t = null;
      t = this;
      t = rtl.freeLoc(t);
    };
    this.ClearChildElements = function () {
      var el = null;
      if (!(this.GetElementHandle() != null)) return;
      while (this.GetElementHandle().childElementCount > 0) {
        el = this.GetElementHandle().firstChild;
        this.GetElementHandle().removeChild(el);
      };
    };
    this.HookElement = function () {
      var el = null;
      var i = 0;
      el = document.getElementById(this.FID);
      this.FContainer = el;
      this.BindElement();
      this.BindEvents();
      for (var $l = 0, $end = this.GetControlsCount() - 1; $l <= $end; $l++) {
        i = $l;
        this.GetControls(i).HookElement();
      };
    };
    this.SetElementColor = function (AElement, AColor) {
      var noCSS = false;
      noCSS = !pas["WEBLib.Forms"].Application.FThemed && !(this.FElementClassName !== "");
      if (!this.GetIsLinked()) $mod.SetHTMLElementColor(AElement,AColor,!noCSS);
    };
    this.MoveElements = function (FromElement, ToElement) {
      if (FromElement && ToElement) {
        while (FromElement.childNodes.length) { ToElement.appendChild(FromElement.firstChild); }
      };
    };
    this.MoveElementsAndFree = function (FromElement, ToElement) {
      if (FromElement && ToElement){
        while (FromElement.childNodes.length) { ToElement.appendChild(FromElement.firstChild); }
        FromElement.remove();
      };
    };
    this.CreateWithID = function (AID) {
      var el = null;
      this.ClearMethodPointers();
      this.FUpdateCount = 0;
      this.FControlCreated = false;
      this.FLinkTouchEvents = true;
      this.FIsResizing = false;
      if (((this.FOwner != null) && (pas.Classes.TComponentStateItem.csLoading in this.FOwner.FComponentState)) || !(this.FOwner != null)) {
        if (!((this.FOwner != null) && (pas.Classes.TComponentStateItem.csDesigning in this.FOwner.FComponentState))) this.Loading();
      };
      this.FElementPosition = $mod.TElementPosition.epAbsolute;
      this.FWidthStyle = $mod.TSizeStyle.ssAbsolute;
      this.FHeightStyle = $mod.TSizeStyle.ssAbsolute;
      el = document.getElementById(AID);
      this.FNew = !(el != null);
      this.FFont = pas["WEBLib.Graphics"].TFont.$create("Create$1");
      this.FFont.FOnChange = rtl.createCallback(this,"HandleFontChanged");
      if (this.FNew) {
        this.FContainer = null;
      } else {
        this.FContainer = el;
        this.FControlCreated = true;
        this.FElementPosition = $mod.TElementPosition.epRelative;
        this.CreateChildElements(el);
        this.BindElement();
        this.BindEvents();
      };
      this.FID = AID;
      this.FEnabled = true;
      this.FVisible = true;
      this.FLeft = 0;
      this.FTop = 0;
      this.FAlign = $mod.TAlign.alNone;
      this.FAlignWithMargins = false;
      this.FIsAligning = false;
      this.FParentFont = true;
      this.FParentBiDiMode = true;
      this.FParentColor = false;
      this.FAnchors = rtl.createSet($mod.TAnchorKind.akLeft,$mod.TAnchorKind.akTop);
      this.FShowFocus = false;
      this.FBorderWidth = 0;
      this.FEnablePropagation = false;
      this.FToolTip = null;
      this.FColor = 16711422;
      this.FMargins = $mod.TMargins.$create("Create$1");
      this.FMargins.FOnChange = rtl.createCallback(this,"DoMarginsChanged");
      this.FCenter = $mod.TCenter.$create("Create");
      this.FCenter.FOnChange = rtl.createCallback(this,"DoCenterChanged");
      this.FParent = null;
      this.FPrevParent = null;
      if (!($mod.TControlStyleValue.csAcceptsControls in this.FControlStyle)) this.ClearControls();
      this.CreateInitialize();
    };
    this.AddInstanceStyle = function (css) {
      var cssname = "";
      cssname = this.FName + "_style";
      this.$class.AddInstanceStyle$1(cssname,css);
    };
    this.AddInstanceStyle$1 = function (id, css) {
      function writeStylesOnce(styleName, cssText) {
          var styleElement = document.getElementById(styleName);
          if (styleElement) {
            styleElement.innerHTML = cssText;
            return;
            }
          styleElement = document.createElement('style');
          styleElement.type = 'text/css';
          styleElement.id = styleName;
          styleElement.innerHTML = cssText;
          document.getElementsByTagName('head')[0].appendChild(styleElement);
      }
      writeStylesOnce(id,css);
    };
    this.AddControlStyle = function (css) {
      var cssname = "";
      cssname = this.$classname;
      function writeStylesOnce(styleName, cssText) {
          var styleElement = document.getElementById(styleName);
          if (styleElement) {
               styleElement.innerHTML = cssText;
            return;
            }
          styleElement = document.createElement('style');
          styleElement.type = 'text/css';
          styleElement.id = styleName;
          styleElement.innerHTML = cssText;
          document.getElementsByTagName('head')[0].appendChild(styleElement);
      }
      writeStylesOnce(cssname,css);
    };
    this.AddControlLink = function (linkid, link) {
      function writeLinkOnce(linkName, linkText) {
          var linkElement = document.getElementById(linkName);
          if (linkElement)
            return;
          linkElement = document.createElement('link');
          linkElement.id = linkName;
          linkElement.setAttribute('rel', 'stylesheet');
          linkElement.setAttribute('type', 'text/css');
          linkElement.setAttribute('href', linkText);
          document.getElementsByTagName('head')[0].appendChild(linkElement);
      }
      writeLinkOnce(linkid,link);
    };
    this.AddControlScriptLink = function (link) {
      var id = "";
      var script = null;
      id = this.$classname;
      if (!(document.getElementById(id) != null)) {
        script = document.createElement("script");
        script.id = id;
        script.src = link;
        script.type = "text/javascript";
        document.head.appendChild(script);
      };
    };
    this.AddControlScriptSource = function (source) {
      var id = "";
      var script = null;
      id = this.$classname + "SRC";
      if (!(document.getElementById(id) != null)) {
        script = document.createElement("script");
        script.id = id;
        script.innerHTML = source;
        script.type = "text/javascript";
        document.head.appendChild(script);
      };
    };
    this.AddRequiredScripts = function () {
      var Result = false;
      var i = 0;
      var j = 0;
      var el = null;
      var scr = null;
      var found = false;
      var loading = false;
      this.FControlScriptCount = 0;
      for (var $l = 0, $end = this.FRequiredScripts.GetCount() - 1; $l <= $end; $l++) {
        j = $l;
        found = false;
        loading = false;
        for (var $l1 = 0, $end1 = document.head.children.length - 1; $l1 <= $end1; $l1++) {
          i = $l1;
          el = document.head.children.item(i);
          if (el.tagName === "SCRIPT") {
            scr = el;
            if (pas.System.Pos(this.FRequiredScripts.Get(j),scr.src) > 0) {
              found = true;
              if (scr.title === "tmswebloading") {
                loading = true;
                if (!(this.FScriptLoadedPtr != null)) this.FScriptLoadedPtr = rtl.createCallback(this,"RequiredScriptLoaded");
                scr.addEventListener("load",this.FScriptLoadedPtr);
              };
              break;
            };
          };
        };
        if (!found) {
          this.FControlScriptCount += 1;
          this.AddRequiredScript(this.RequiredBaseURL() + this.FRequiredScripts.Get(j));
        };
        if (found && loading) this.FControlScriptCount += 1;
      };
      Result = this.FControlScriptCount > 0;
      return Result;
    };
    this.AddRequiredScript = function (link) {
      var id = "";
      var script = null;
      script = document.createElement("script");
      script.src = link;
      script.type = "text/javascript";
      script.title = "tmswebloading";
      if (!(this.FScriptLoadedPtr != null)) this.FScriptLoadedPtr = rtl.createCallback(this,"RequiredScriptLoaded");
      script.addEventListener("load",this.FScriptLoadedPtr);
      document.head.appendChild(script);
    };
    this.ResetAnchoring = function () {
      this.FOrigRect.$assign(pas.Types.Rect(-1,-1,-1,-1));
      this.InitAnchoring();
    };
    this.UpdateSize = function () {
      var i = 0;
      this.UpdateElementSize();
      for (var $l = 0, $end = this.GetControlsCount() - 1; $l <= $end; $l++) {
        i = $l;
        this.GetControls(i).UpdateSize();
      };
    };
    this.UpdateAnchoring = function () {
      var dxr = 0;
      var dyr = 0;
      var dxo = 0;
      var dyo = 0;
      var dxw = 0;
      var dyw = 0;
      var br = pas.Types.TRect.$new();
      var r = pas.Types.TRect.$new();
      if (pas.Classes.TComponentStateItem.csLoading in this.FComponentState) return;
      if (!this.FControlCreated) return;
      if ((this.FOrigRect.Left === -1) && (this.FOrigRect.Top === -1)) this.InitAnchoring();
      if ((this.FParent != null) && !this.FParent.AnchoringInitialized()) return;
      if (this.FAlign !== $mod.TAlign.alClient) {
        if ((this.FParent != null) && !pas["WEBLib.Forms"].TForm.isPrototypeOf(this)) {
          r.$assign(this.FParent.GetBoundsRect());
          dxr = r.Right - r.Left - (this.FOrigParentRect.Right - this.FOrigParentRect.Left);
          dyr = r.Bottom - r.Top - (this.FOrigParentRect.Bottom - this.FOrigParentRect.Top);
          br.$assign(this.FOrigRect);
          dxo = 0;
          dyo = 0;
          dxw = 0;
          dyw = 0;
          if ($mod.TAnchorKind.akRight in this.FAnchors) {
            if ($mod.TAnchorKind.akLeft in this.FAnchors) {
              dxw = dxr}
             else dxo = dxr;
          };
          if ($mod.TAnchorKind.akBottom in this.FAnchors) {
            if ($mod.TAnchorKind.akTop in this.FAnchors) {
              dyw = dyr}
             else dyo = dyr;
          };
          if (($mod.TAnchorKind.akBottom in this.FAnchors) || ($mod.TAnchorKind.akRight in this.FAnchors)) {
            this.SetBoundsInt(br.Left + dxo,br.Top + dyo,(br.Right - br.Left) + dxw,(br.Bottom - br.Top) + dyw);
          };
        };
      };
      this.UpdateChildAnchoring();
    };
    this.UpdateChildAnchoring = function () {
      var i = 0;
      for (var $l = 0, $end = this.GetControlsCount() - 1; $l <= $end; $l++) {
        i = $l;
        this.GetControls(i).UpdateAnchoring();
      };
    };
    this.SetElementPointer = function (AElement, ACursor) {
      if (ACursor !== 0) {
        AElement.style.setProperty("cursor",$mod.GetHTMLCursorName(ACursor))}
       else AElement.style.removeProperty("cursor");
    };
    this.GetWebClassName = function () {
      var Result = "";
      Result = this.$classname;
      pas.System.Delete({get: function () {
          return Result;
        }, set: function (v) {
          Result = v;
        }},1,1);
      Result = "TWeb" + Result;
      return Result;
    };
    this.GetCSSManager = function () {
      var Result = null;
      var frm = null;
      var i = 0;
      Result = null;
      frm = pas["WEBLib.Forms"].GetParentForm(this);
      if (frm != null) {
        for (var $l = 0, $end = frm.GetComponentCount() - 1; $l <= $end; $l++) {
          i = $l;
          if ($mod.TCSSCodeManager.isPrototypeOf(frm.GetComponent(i))) {
            Result = rtl.as(frm.GetComponent(i),$mod.TCSSCodeManager);
          };
        };
      };
      return Result;
    };
    this.IsUpdating = function () {
      var Result = false;
      Result = this.FUpdateCount > 0;
      return Result;
    };
    this.CanShowFocus = function () {
      var Result = false;
      Result = this.FShowFocus;
      return Result;
    };
    this.RequiredScriptLoaded = function (Event) {
      rtl.asExt(Event.target,HTMLScriptElement).title = "tmswebloaded";
      this.FControlScriptCountLoaded += 1;
    };
    this.InjectCSS = function () {
      var cssname = "";
      var css = "";
      var cssmgr = null;
      cssname = this.GetWebClassName();
      css = "";
      cssmgr = this.GetCSSManager();
      if (cssmgr != null) css = cssmgr.GetClassCSS(cssname);
      if (css !== "") this.AddControlStyle(css);
    };
    this.StartCapture = function () {
      var eh = null;
      if (!this.FCaptureDown) return;
      if (this.Captured()) this.ReleaseCapture();
      this.FMouseInsideLayer = true;
      this.FLayer = document.createElement("SPAN");
      document.body.appendChild(this.FLayer);
      eh = this.FLayer;
      eh.addEventListener("mouseenter",this.FLayerMouseEnterPtr);
      eh.addEventListener("mouseleave",this.FLayerMouseLeavePtr);
      eh.addEventListener("mousedown",this.FMouseDownPtr);
      eh.addEventListener("mouseup",this.FMouseUpPtr);
      eh.addEventListener("mousemove",this.FMouseMovePtr);
      eh.addEventListener("touchstart",this.FTouchStartPtr);
      eh.addEventListener("touchmove",this.FTouchMovePtr);
      eh.addEventListener("touchend",this.FTouchEndPtr);
      eh.addEventListener("touchcancel",this.FTouchCancelPtr);
      eh.style.setProperty("top","0");
      eh.style.setProperty("left","0");
      eh.style.setProperty("right","0");
      eh.style.setProperty("bottom","0");
      eh.style.setProperty("webkit-user-select","none");
      eh.style.setProperty("moz-user-select","none");
      eh.style.setProperty("khtml-user-select","none");
      eh.style.setProperty("ms-user-select","none");
      eh.style.setProperty("user-select","none");
      eh.style.setProperty("position","absolute");
      eh.style.setProperty($mod.CSSZIndex,"999999");
      this.FCaptured = true;
      this.UpdateElement();
    };
    this.RequiredBaseURL = function () {
      var Result = "";
      Result = "";
      return Result;
    };
    this.GetStyle = function (css) {
      var Result = "";
      var res = "";
      var el = null;
      el = this.GetElementHandle();
      res = "";
      if (!(el != null)) return Result;
      if (window.getComputedStyle) res = getComputedStyle(el, '')[css];
      if(el.currentStyle) res = el.currentStyle[css];
      Result = res;
      return Result;
    };
    this.SetBoundsInt = function (X, Y, AWidth, AHeight) {
      if ((X !== this.GetLeft()) || (Y !== this.GetTop()) || ((AWidth !== this.GetWidth()) && (this.FWidthStyle === $mod.TSizeStyle.ssAbsolute)) || ((AHeight !== this.GetHeight()) && (this.FHeightStyle === $mod.TSizeStyle.ssAbsolute)) || ((this.FParent != null) && this.FParent.GetIsLinked())) {
        this.FBlockUpdateElement = true;
        this.FLeft = X;
        this.FTop = Y;
        this.FWidth = AWidth;
        this.FHeight = AHeight;
        this.FBlockUpdateElement = false;
        this.UpdateElementSize();
        if (this.FAlign !== $mod.TAlign.alNone) {
          this.DoRealign()}
         else this.Realign();
        this.RecreateCanvas();
        this.DoBoundsChange();
        this.Invalidate();
        this.UpdateChildAnchoring();
      };
    };
    this.MoveFirst = function (AControl) {
      var i = 0;
      var fnd = false;
      fnd = false;
      for (var $l = this.GetControlsCount() - 1; $l >= 0; $l--) {
        i = $l;
        if (this.FControls[i] === AControl) fnd = true;
        if (fnd) {
          if (i > 0) {
            this.FControls[i] = this.FControls[i - 1]}
           else this.FControls[i] = AControl;
        };
      };
    };
    this.MoveLast = function (AControl) {
      var i = 0;
      var fnd = false;
      fnd = false;
      for (var $l = 0, $end = this.GetControlsCount() - 1; $l <= $end; $l++) {
        i = $l;
        if (this.FControls[i] === AControl) fnd = true;
        if (fnd) {
          if (i < (this.GetControlsCount() - 1)) {
            this.FControls[i] = this.FControls[i + 1]}
           else this.FControls[i] = AControl;
        };
      };
    };
    this.EnableDrag = function () {
      if (this.GetContainer() != null) this.GetContainer().setAttribute("draggable","true");
    };
    this.DisableDrag = function () {
      if ((this.GetContainer() != null) && (this.GetContainer().getAttribute("draggable") === "true")) this.GetContainer().setAttribute("draggable","false");
    };
    this.Create$2 = function (ID) {
      this.FGotFocus = false;
      this.FTabStop = true;
      this.FAllowTouch = true;
      this.CreateWithID(ID);
      return this;
    };
    this.Create$1 = function (AOwner) {
      var lName = "";
      var frm = null;
      var lDesign = false;
      this.FGotFocus = false;
      this.FEventsBound = false;
      this.FTabStop = true;
      this.FAllowTouch = true;
      this.FNoUserSelect = true;
      this.ClearMethodPointers();
      pas.Classes.TComponent.Create$1.call(this,AOwner);
      this.FEventStopPropagation = rtl.createSet($mod.TElementEvent.eeClick,$mod.TElementEvent.eeDblClick,$mod.TElementEvent.eeMouseUp,$mod.TElementEvent.eeMouseMove,$mod.TElementEvent.eeMouseDown,$mod.TElementEvent.eeKeyPress,$mod.TElementEvent.eeKeyDown,$mod.TElementEvent.eeKeyUp);
      this.FScriptLoaded = false;
      this.FElementFont = $mod.TElementFont.efProperty;
      this.FElementPosition = $mod.TElementPosition.epAbsolute;
      this.FParentElement = null;
      this.FTextDirection = $mod.TTextDirection.tdDefault;
      lDesign = false;
      frm = pas["WEBLib.Forms"].GetParentForm(this);
      if (frm != null) {
        lDesign = pas.Classes.TComponentStateItem.csDesigning in frm.FComponentState;
      };
      lName = this.GetNewName();
      if (lDesign) {
        this.CreateWithID("")}
       else this.CreateWithID(lName);
      if ((AOwner != null) && !(pas.Classes.TComponentStateItem.csDesigning in AOwner.FComponentState)) this.SetName(lName);
      return this;
    };
    this.Destroy = function () {
      this.UnbindEvents();
      this.DestroyControls();
      if ((this.GetContainer() != null) && (this.FParent != null) && (this.FParent.GetChildContainer() != null)) {
        if (this.FParent.GetChildContainer() === this.GetContainer().parentNode) {
          this.FParent.GetChildContainer().removeChild(this.GetContainer());
        };
        this.FContainer = null;
        this.SetParent(null);
        this.FControlCreated = false;
      };
      rtl.free(this,"FRequiredScripts");
      rtl.free(this,"FMargins");
      rtl.free(this,"FCenter");
      rtl.free(this,"FFont");
      if (pas.System.Assigned(this.FToolTip)) {
        this.FToolTip.dispose();
        this.FToolTip = null;
      };
      pas.Classes.TComponent.Destroy.call(this);
    };
    this.Assign = function (Source) {
    };
    this.DragDrop = function (Source, X, Y) {
      if (this.FOnDragDrop != null) this.FOnDragDrop(this,Source,X,Y);
    };
    this.Resize = function () {
      if (this.FOnResize != null) this.FOnResize(this);
    };
    this.Capture = function () {
      this.FCaptureDown = true;
      window.setTimeout(rtl.createSafeCallback(this,"StartCapture"),100);
    };
    this.ApplyName = function () {
      var s = "";
      var prefix = "";
      var frm = null;
      s = this.$classname;
      pas.System.Delete({get: function () {
          return s;
        }, set: function (v) {
          s = v;
        }},1,1);
      prefix = "";
      frm = pas["WEBLib.Forms"].GetParentForm(this);
      if (frm != null) prefix = frm.$classname;
      this.SetID(prefix + "_" + $mod.FindUniqueName(s));
    };
    this.ReleaseCapture = function () {
      var eh = null;
      this.FCaptureDown = false;
      if (this.FCaptured && (this.FLayer != null)) {
        eh = this.FLayer;
        eh.removeEventListener("mouseenter",this.FLayerMouseEnterPtr);
        eh.removeEventListener("mouseleave",this.FLayerMouseLeavePtr);
        eh.removeEventListener("mousedown",this.FMouseDownPtr);
        eh.removeEventListener("mouseup",this.FMouseUpPtr);
        eh.removeEventListener("mousemove",this.FMouseMovePtr);
        eh.removeEventListener("touchstart",this.FTouchStartPtr);
        eh.removeEventListener("touchmove",this.FTouchMovePtr);
        eh.removeEventListener("touchend",this.FTouchEndPtr);
        eh.removeEventListener("touchcancel",this.FTouchEndPtr);
        document.body.removeChild(eh);
        this.FCaptured = false;
        this.FLayer = null;
        this.UpdateElement();
      };
    };
    this.BringToFront = function () {
      if ((this.GetElementHandle() != null) && (this.GetElementHandle().parentElement != null)) {
        try {
          this.GetElementHandle().parentElement.appendChild(this.GetElementHandle());
          if (this.FParent != null) this.FParent.MoveLast(this);
        } catch ($e) {
        };
      };
    };
    this.SendToBack = function () {
      if ((this.GetElementHandle() != null) && (this.GetElementHandle().parentElement != null)) {
        this.GetElementHandle().parentElement.insertBefore(this.GetElementHandle(),this.GetElementHandle().parentElement.firstElementChild);
        if (this.FParent != null) this.FParent.MoveFirst(this);
      };
    };
    this.Show = function () {
      this.SetVisible(true);
    };
    this.Hide = function () {
      this.SetVisible(false);
    };
    this.PreventDefault = function () {
      if (this.GetElementEvent() != null) this.GetElementEvent().preventDefault();
    };
    this.StopPropagation = function () {
      if ((this.GetElementEvent() != null) && !this.FEnablePropagation) this.GetElementEvent().stopPropagation();
    };
    this.BeginDrag = function () {
      this.EnableDrag();
    };
    this.BeginUpdate = function () {
      this.FUpdateCount += 1;
    };
    this.EndUpdate = function () {
      if (this.FUpdateCount > 0) {
        this.FUpdateCount -= 1;
        if (this.FUpdateCount === 0) this.UpdateElement();
      };
    };
    this.Invalidate = function () {
    };
    this.SetParentComponent = function (Value) {
      if ((this.FParent !== Value) && $mod.TControl.isPrototypeOf(Value)) this.SetParent(Value);
    };
    this.SetBounds = function (X, Y, AWidth, AHeight) {
      this.SetBoundsInt(X,Y,AWidth,AHeight);
      this.FWidth = AWidth;
      this.FHeight = AHeight;
      if (!this.FUpdateTopLeft) {
        this.FOrigTop = Y;
        this.FOrigLeft = X;
      };
      this.ResetAnchoring();
      if (!(pas.Classes.TComponentStateItem.csLoading in this.FComponentState) && (this.FAlign !== $mod.TAlign.alNone) && (this.FParent != null)) {
        this.DoRealign();
      };
    };
    this.XYToClient = function (X, Y, AClientX, AClientY) {
      var p = null;
      var cr = null;
      var el = null;
      var OrigX = 0.0;
      var OrigY = 0.0;
      var norel = false;
      var formcont = false;
      var r = pas.Types.TRect.$new();
      var cs = null;
      var csx = 0;
      var csy = 0;
      var scrollx = 0;
      var scrolly = 0;
      norel = true;
      formcont = false;
      scrollx = 0;
      scrolly = 0;
      if (this.FElementPosition === $mod.TElementPosition.epAbsolute) {
        scrollx = document.body.scrollLeft + document.documentElement.scrollLeft;
        scrolly = document.body.scrollTop + document.documentElement.scrollTop;
        OrigX = X - this.GetLeft();
        OrigY = Y - this.GetTop();
      } else {
        norel = false;
        cr = this.GetElementHandle().getBoundingClientRect();
        OrigX = X - cr.left;
        OrigY = Y - cr.top;
        AClientX.set(OrigX);
        AClientY.set(OrigY);
        return;
      };
      AClientX.set(OrigX);
      AClientY.set(OrigY);
      p = this.FParent;
      if (pas["WEBLib.Forms"].TCustomForm.isPrototypeOf(this) && !(p != null) && (this.GetContainer() != null)) {
        cr = this.GetContainer().getBoundingClientRect();
        AClientX.set(AClientX.get() - cr.left);
        AClientY.set(AClientY.get() - cr.top);
      };
      while (p != null) {
        if (p.GetIsLinked()) {
          if (pas["WEBLib.Forms"].TCustomForm.isPrototypeOf(p)) {
            cr = p.GetContainer().getBoundingClientRect();
          } else {
            cr = p.GetElementHandle().getBoundingClientRect();
          };
          AClientX.set(AClientX.get() - cr.left);
          AClientY.set(AClientY.get() - cr.top);
          AClientX.set(AClientX.get() + p.GetElementHandle().scrollLeft);
          AClientY.set(AClientY.get() + p.GetElementHandle().scrollTop);
          scrollx = 0;
          scrolly = 0;
          break;
        } else if (pas["WEBLib.Forms"].TCustomForm.isPrototypeOf(p)) {
          if (rtl.as(p,pas["WEBLib.Forms"].TCustomForm).FFormContainer !== "") {
            el = document.getElementById(rtl.as(p,pas["WEBLib.Forms"].TCustomForm).FFormContainer);
            if (el != null) {
              formcont = true;
              cr = el.getBoundingClientRect();
              AClientX.set(AClientX.get() - cr.left);
              AClientY.set(AClientY.get() - cr.top);
            };
          };
          if ((rtl.as(p,pas["WEBLib.Forms"].TCustomForm).GetContainer() != null) && (rtl.as(p,pas["WEBLib.Forms"].TCustomForm).FFormContainer === "") && rtl.as(p,pas["WEBLib.Forms"].TCustomForm).FPopup) {
            cr = rtl.as(p,pas["WEBLib.Forms"].TCustomForm).GetContainer().getBoundingClientRect();
            AClientX.set(AClientX.get() - cr.left);
            AClientY.set(AClientY.get() - cr.top);
            r.$assign(rtl.as(p,pas["WEBLib.Forms"].TCustomForm).GetClientRect());
            AClientY.set(AClientY.get() + r.Top);
            scrollx = 0;
            scrolly = 0;
          };
        } else if (p.FElementPosition in rtl.createSet($mod.TElementPosition.epRelative,$mod.TElementPosition.epIgnore)) {
          if (p.GetElementHandle() != null) {
            cr = p.GetElementHandle().getBoundingClientRect();
            AClientX.set(OrigX - cr.left);
            AClientY.set(OrigY - cr.top);
            scrollx = 0;
            scrolly = 0;
            if (norel) {
              cs = window.getComputedStyle(document.documentElement);
              csx = parseInt(cs.marginLeft,10);
              csy = parseInt(cs.marginTop,10);
              AClientX.set(AClientX.get() + csx);
              AClientY.set(AClientY.get() + csy);
            };
            norel = false;
            break;
          };
        } else if ((p.FElementPosition === $mod.TElementPosition.epAbsolute) && norel) {
          AClientX.set(AClientX.get() - p.GetLeft());
          AClientY.set(AClientY.get() - p.GetTop());
          if (p.GetElementHandle() != null) {
            AClientX.set(AClientX.get() + p.GetElementHandle().scrollLeft);
            AClientY.set(AClientY.get() + p.GetElementHandle().scrollTop);
          };
          OrigX = AClientX.get();
          OrigY = AClientY.get();
        };
        p = p.FParent;
      };
      if ((this.FElementPosition === $mod.TElementPosition.epAbsolute) && !formcont) {
        AClientX.set(AClientX.get() + scrollx);
        AClientY.set(AClientY.get() + scrolly);
      };
    };
    this.ClientToXY = function (AClientX, AClientY, X, Y) {
      var p = null;
      var cr = null;
      X.set((AClientX + this.GetLeft()) - document.body.scrollLeft - document.documentElement.scrollLeft);
      Y.set((AClientY + this.GetTop()) - document.body.scrollTop - document.documentElement.scrollTop);
      p = this.FParent;
      while (p != null) {
        if (p.GetIsLinked()) {
          if (pas["WEBLib.Forms"].TCustomForm.isPrototypeOf(p)) {
            cr = p.GetContainer().getBoundingClientRect()}
           else cr = p.GetElementHandle().getBoundingClientRect();
          X.set(X.get() + cr.left);
          Y.set(Y.get() + cr.top);
        };
        if (pas["WEBLib.Forms"].TCustomForm.isPrototypeOf(p)) {
          if ((rtl.as(p,pas["WEBLib.Forms"].TCustomForm).GetContainer() != null) && (rtl.as(p,pas["WEBLib.Forms"].TCustomForm).FFormContainer === "") && (rtl.as(p,pas["WEBLib.Forms"].TCustomForm).FFormFileName !== "") && rtl.as(p,pas["WEBLib.Forms"].TCustomForm).FPopup) {
            cr = rtl.as(p,pas["WEBLib.Forms"].TCustomForm).GetContainer().getBoundingClientRect();
            X.set(X.get() + cr.left);
            Y.set(Y.get() + cr.top);
          };
        };
        if (p.FElementPosition === $mod.TElementPosition.epAbsolute) {
          X.set(X.get() + p.GetLeft());
          Y.set(Y.get() + p.GetTop());
        };
        p = p.FParent;
      };
    };
    this.GetChildren = function (Proc, Root) {
      var I = 0;
      var Control = null;
      for (var $l = 0, $end = this.GetControlsCount() - 1; $l <= $end; $l++) {
        I = $l;
        Control = this.GetControls(I);
        if ((Control.FOwner === Root) || (Root === null)) Proc(Control);
      };
    };
    this.Captured = function () {
      var Result = false;
      Result = this.FCaptured && (this.FLayer != null);
      return Result;
    };
    this.MakeScreenshot = function () {
      var Result = null;
      Result = null;
      return Result;
    };
    this.ClientToScreen = function (Point) {
      var Result = pas.Types.TPoint.$new();
      var Origin = pas.Types.TPoint.$new();
      Origin.$assign(this.GetClientOrigin());
      Result.x = Point.x + Origin.x;
      Result.y = Point.y + Origin.y;
      return Result;
    };
    this.ScreenToClient = function (Point) {
      var Result = pas.Types.TPoint.$new();
      var Origin = pas.Types.TPoint.$new();
      Origin.$assign(this.GetClientOrigin());
      Result.x = Point.x - Origin.x;
      Result.y = Point.y - Origin.y;
      return Result;
    };
    this.CanFocus = function () {
      var Result = false;
      Result = true;
      return Result;
    };
    this.HasHorzScrollBar = function () {
      var Result = false;
      Result = false;
      if (this.GetElementHandle() != null) Result = this.GetElementHandle().clientWidth < this.GetElementHandle().scrollWidth;
      return Result;
    };
    this.HasVertScrollBar = function () {
      var Result = false;
      Result = false;
      if (this.GetElementHandle() != null) Result = this.GetElementHandle().clientHeight < this.GetElementHandle().scrollHeight;
      return Result;
    };
    rtl.addIntf(this,$mod.IControl);
    rtl.addIntf(this,pas.System.IUnknown);
    var $r = this.$rtti;
    $mod.$rtti.$DynArray("TControl.FControls$a",{eltype: $r});
    $r.addMethod("Create$2",2,[["ID",rtl.string]]);
    $r.addMethod("Create$1",2,[["AOwner",pas.Classes.$rtti["TComponent"]]]);
  });
  this.TScrollBarKind = {"0": "sbHorizontal", sbHorizontal: 0, "1": "sbVertical", sbVertical: 1};
  this.$rtti.$Enum("TScrollBarKind",{minvalue: 0, maxvalue: 1, ordtype: 1, enumtype: this.TScrollBarKind});
  rtl.createClass(this,"TControlScrollBar",pas.Classes.TPersistent,function () {
    this.$init = function () {
      pas.Classes.TPersistent.$init.call(this);
      this.FKind = 0;
      this.FControl = null;
    };
    this.$final = function () {
      this.FControl = undefined;
      pas.Classes.TPersistent.$final.call(this);
    };
    this.Create$1 = function (AControl, AKind) {
      this.FControl = AControl;
      this.FKind = AKind;
      return this;
    };
    this.IsScrollBarVisible = function () {
      var Result = false;
      Result = false;
      if (this.FControl.GetElementHandle() != null) {
        if (this.FKind === $mod.TScrollBarKind.sbVertical) {
          Result = this.FControl.GetElementHandle().scrollHeight > this.FControl.GetElementHandle().clientHeight}
         else Result = this.FControl.GetElementHandle().scrollWidth > this.FControl.GetElementHandle().clientWidth;
      };
      return Result;
    };
    this.ScrollPos = function () {
      var Result = 0;
      Result = 0;
      if (this.FControl.GetElementHandle() != null) {
        if (this.FKind === $mod.TScrollBarKind.sbVertical) {
          Result = this.FControl.GetElementHandle().scrollTop}
         else Result = this.FControl.GetElementHandle().scrollLeft;
      };
      return Result;
    };
    this.Range = function () {
      var Result = 0;
      Result = 0;
      if (this.FControl.GetElementHandle() != null) {
        if (this.FKind === $mod.TScrollBarKind.sbVertical) {
          Result = this.FControl.GetElementHandle().scrollHeight}
         else Result = this.FControl.GetElementHandle().scrollWidth;
      };
      return Result;
    };
    var $r = this.$rtti;
    $r.addMethod("Create$1",2,[["AControl",$mod.$rtti["TControl"]],["AKind",$mod.$rtti["TScrollBarKind"]]]);
  });
  this.$rtti.$Class("TWinControl");
  this.$rtti.$ClassRef("TWinControlClass",{instancetype: this.$rtti["TWinControl"]});
  rtl.createClass(this,"TWinControl",this.TControl,function () {
    rtl.addIntf(this,$mod.IControl);
    rtl.addIntf(this,pas.System.IUnknown);
    var $r = this.$rtti;
    $r.addProperty("Cursor",2,$mod.$rtti["TCursor"],"FCursor","SetControlCursor",{Default: 0});
    $r.addProperty("ElementClassName",2,$mod.$rtti["TElementClassName"],"FElementClassName","SetElementClassName");
    $r.addProperty("Enabled",2,rtl.boolean,"FEnabled","SetEnabled",{Default: true});
    $r.addProperty("Height",3,rtl.longint,"GetHeight","SetHeight");
    $r.addProperty("Hint",2,rtl.string,"FHint","SetHint");
    $r.addProperty("Left",3,rtl.longint,"GetLeft","SetLeft");
    $r.addProperty("ShowHint",2,rtl.boolean,"FShowHint","SetShowHint",{Default: false});
    $r.addProperty("Tag",0,rtl.longint,"FTag$1","FTag$1",{Default: 0});
    $r.addProperty("Top",3,rtl.longint,"GetTop","SetTop");
    $r.addProperty("Visible",2,rtl.boolean,"FVisible","SetVisible",{Default: true});
    $r.addProperty("Width",3,rtl.longint,"GetWidth","SetWidth");
    $r.addProperty("OnMouseDown",0,$mod.$rtti["TMouseEvent"],"FOnMouseDown","FOnMouseDown");
    $r.addProperty("OnMouseUp",0,$mod.$rtti["TMouseEvent"],"FOnMouseUp","FOnMouseUp");
    $r.addProperty("OnMouseMove",0,$mod.$rtti["TMouseMoveEvent"],"FOnMouseMove","FOnMouseMove");
    $r.addProperty("OnMouseEnter",0,$mod.$rtti["TNotifyEvent"],"FOnMouseEnter","FOnMouseEnter");
    $r.addProperty("OnMouseLeave",0,$mod.$rtti["TNotifyEvent"],"FOnMouseLeave","FOnMouseLeave");
    $r.addProperty("OnKeyUp",0,$mod.$rtti["TKeyEvent"],"FOnKeyUp","FOnKeyUp");
    $r.addProperty("OnKeyDown",0,$mod.$rtti["TKeyEvent"],"FOnKeyDown","FOnKeyDown");
    $r.addProperty("OnKeyPress",0,$mod.$rtti["TKeyPressEvent"],"FOnKeyPress","FOnKeyPress");
    $r.addProperty("OnEnter",0,$mod.$rtti["TNotifyEvent"],"FOnEnter","FOnEnter");
    $r.addProperty("OnExit",0,$mod.$rtti["TNotifyEvent"],"FOnExit","FOnExit");
  });
  this.$rtti.$Class("TCustomControl");
  this.$rtti.$ClassRef("TCustomControlClass",{instancetype: this.$rtti["TCustomControl"]});
  rtl.createClass(this,"TCustomControl",this.TWinControl,function () {
    this.$init = function () {
      $mod.TWinControl.$init.call(this);
      this.FCaption = "";
      this.FPixelRatio = 0.0;
      this.FPainting = false;
      this.FCanvas = null;
      this.FElementCanvas = null;
      this.FBorderStyle = 0;
      this.FBorderColor = 0;
      this.FCustomBorder = false;
      this.FOnScreenShot = null;
      this.FBevelOuter = 0;
      this.FBevelWidth = 0;
      this.FBevelCut = 0;
      this.FBevelEdges = {};
      this.FBevelKind = 0;
    };
    this.$final = function () {
      this.FCanvas = undefined;
      this.FElementCanvas = undefined;
      this.FOnScreenShot = undefined;
      this.FBevelEdges = undefined;
      $mod.TWinControl.$final.call(this);
    };
    this.GetCanvas = function () {
      var Result = null;
      if (!(this.FCanvas != null)) {
        if (!this.GetIsLinked()) {
          this.CreateControl()}
         else {
          if (!(this.FElementCanvas != null)) this.FElementCanvas = document.getElementById(this.GetID());
          this.RecreateCanvas();
        };
      };
      Result = this.FCanvas;
      return Result;
    };
    this.RenderDesigning = function (ACaption, AElement, AControl, ADisplay, AImage) {
      var LContainer = null;
      var LLabel = null;
      var LDiv = null;
      var LHasLabel = false;
      LContainer = AElement;
      LLabel = LContainer.firstChild;
      LHasLabel = (LLabel != null) && (LLabel.tagName === "DIV") && (LLabel.getAttribute("data-design") === "1");
      if ((pas.Classes.TComponentStateItem.csDesigning in AControl.FComponentState) && ADisplay && (this.FElementClassName === "")) {
        LContainer.style.setProperty("border","1px solid gray");
        if (AImage === "") {
          LContainer.style.setProperty("background-color","#F0F0F0")}
         else LContainer.style.setProperty("background-color","white");
        if (LHasLabel) return;
        LContainer.innerHTML = "";
        if (AImage !== "") {
          LDiv = document.createElement("DIV");
          LDiv.style.setProperty("background-color","white");
          LDiv.style.setProperty("background-repeat","no-repeat");
          LDiv.style.setProperty("background-position-y","center");
          LDiv.style.setProperty("background-image","url(" + AImage + ")");
          LDiv.style.setProperty("background-position-x","center");
          LDiv.style.setProperty("background-size","128px");
          LDiv.style.setProperty("top","50%");
          LDiv.style.setProperty("left","50%");
          LDiv.style.setProperty("height","70%");
          LContainer.appendChild(LDiv);
        };
        LLabel = document.createElement("DIV");
        LLabel.setAttribute("data-design","1");
        LLabel.innerHTML = ACaption;
        LLabel.style.setProperty("position","relative");
        LLabel.style.setProperty("top","50%");
        LLabel.style.setProperty("left","50%");
        LLabel.style.setProperty("display","inline-block");
        LLabel.style.setProperty("transform","translateX(-50%)");
        this.FCustomBorder = true;
        LContainer.appendChild(LLabel);
      } else {
        if (LHasLabel) {
          while (LContainer.firstChild != null) LContainer.removeChild(LContainer.firstChild);
          LContainer.style.removeProperty("border");
          LContainer.style.removeProperty("background-color");
        };
      };
    };
    this.GetPixelRatio = function () {
      var Result = 0.0;
      var res = 0.0;
      var ctx = document.createElement("canvas").getContext("2d"),
          dpr = window.devicePixelRatio || 1,
          bsr = ctx.webkitBackingStorePixelRatio ||
                ctx.mozBackingStorePixelRatio ||
                ctx.msBackingStorePixelRatio ||
                ctx.oBackingStorePixelRatio ||
                ctx.backingStorePixelRatio || 1;
      res = dpr / bsr;
      Result = res;
      return Result;
    };
    this.GetContext = function () {
      var Result = null;
      var ctx = null;
      ctx = this.FElementCanvas.getContext("2d");
      Result = ctx;
      return Result;
    };
    this.RecreateCanvas = function () {
      var px = 0.0;
      var el = null;
      var h = 0;
      var w = 0;
      if (this.FElementCanvas != null) {
        if (!this.FPainting) {
          if (this.GetIsLinked()) {
            el = this.GetElementHandle();
          } else el = document.getElementById(this.GetID() + "_Canvas");
          if (el != null) {
            this.FElementCanvas = el;
            rtl.free(this,"FCanvas");
            this.FCanvas = null;
          };
          px = this.GetPixelRatio();
          h = Math.min(16383,this.GetHeight() - this.GetCanvasHeightOffset());
          w = Math.min(16383,this.GetWidth() - this.GetCanvasWidthOffset());
          if (this.FElementPosition === $mod.TElementPosition.epRelative) {
            this.FElementCanvas.style.setProperty("position","relative")}
           else this.FElementCanvas.style.setProperty("position","absolute");
          this.FElementCanvas.style.setProperty("height",pas.SysUtils.IntToStr(h) + "px");
          this.FElementCanvas.style.setProperty("width",pas.SysUtils.IntToStr(w) + "px");
          this.FElementCanvas.height = Math.round(h * px);
          this.FElementCanvas.width = Math.round(w * px);
        };
        if (!(this.FCanvas != null)) {
          this.FCanvas = pas["WEBLib.Graphics"].TCanvas.$create("Create$1",[this.FElementCanvas]);
        };
        this.FCanvas.FApplyPixelRatio = true;
        this.FCanvas.SetTransform(1,0,0,1,0,0);
      };
    };
    this.SetBorderStyle = function (AValue) {
      if (this.FBorderStyle !== AValue) {
        this.FBorderStyle = AValue;
        this.UpdateElement();
      };
    };
    this.SetBorderColor = function (AValue) {
      if (this.FBorderColor !== AValue) {
        this.FBorderColor = AValue;
        this.UpdateElement();
      };
    };
    this.SetName = function (NewName) {
      var cs = {};
      var ownername = "";
      ownername = "";
      if (!((pas["WEBLib.Forms"].VSIDE != null) && (pas.Classes.TComponentStateItem.csDesigning in this.FComponentState))) {
        if (pas["WEBLib.Forms"].TFrame.isPrototypeOf(this)) {
          ownername = "F" + $mod.FindUniqueName(this.FName) + "_";
        };
      };
      pas.Classes.TComponent.SetName.call(this,ownername + NewName);
      if (($mod.TControlStyleValue.csSetCaption in this.FControlStyle) && (pas.Classes.TComponentStateItem.csDesigning in this.FComponentState) && !(pas.Classes.TComponentStateItem.csLoading in this.FComponentState)) {
        if ((this.FOwner != null) && (pas.Classes.TComponentStateItem.csLoading in this.FOwner.FComponentState)) return;
        cs = rtl.refSet(this.FControlStyle);
        this.SetCaption(NewName);
        this.FControlStyle = rtl.refSet(cs);
      };
    };
    this.SetCaption = function (AValue) {
      this.FCaption = AValue;
      this.FControlStyle = rtl.diffSet(this.FControlStyle,rtl.createSet($mod.TControlStyleValue.csSetCaption));
    };
    this.CreateControl = function () {
      $mod.TControl.CreateControl.call(this);
      this.RecreateCanvas();
    };
    this.Loaded = function () {
      $mod.TControl.Loaded.call(this);
      this.Invalidate();
    };
    this.UpdateElementVisual = function () {
      $mod.TControl.UpdateElementVisual.call(this);
      if (this.GetElementHandle() != null) {
        if (!this.GetIsLinked() && (this.FElementClassName === "")) {
          if (this.FBorderStyle === $mod.TBorderStyle.bsSingle) {
            if (this.FCustomBorder) {
              this.GetElementStyle().setProperty("border-style","solid");
              this.GetElementStyle().setProperty("border-width","1px");
              this.GetElementStyle().setProperty("border-color",pas["WEBLib.Graphics"].ColorToHTML(this.FBorderColor));
            } else this.GetElementStyle().setProperty("border-style","");
          } else {
            this.GetElementStyle().setProperty("border-style","none");
          };
        };
        if (this.FElementClassName !== "") {
          this.GetElementStyle().removeProperty("border-style");
          this.GetElementStyle().removeProperty("border-width");
          this.GetElementStyle().removeProperty("border-color");
        };
      };
    };
    this.CreateElement = function () {
      var Result = null;
      this.FElementCanvas = document.createElement("CANVAS");
      if ($mod.TControlStyleValue.csAcceptsControls in this.FControlStyle) {
        Result = document.createElement("SPAN");
        Result.appendChild(this.FElementCanvas);
        if (this.GetID() !== "") this.FElementCanvas.setAttribute("id",this.GetID() + "_Canvas");
        this.FElementCanvas.setAttribute("zindex","-1");
      } else Result = this.FElementCanvas;
      return Result;
    };
    this.GetCanvasHeightOffset = function () {
      var Result = 0;
      Result = 0;
      return Result;
    };
    this.GetCanvasWidthOffset = function () {
      var Result = 0;
      Result = 0;
      return Result;
    };
    this.BindElement = function () {
      if ((this.GetContainer().tagName !== "CANVAS") && !this.FControlCreated) {
        this.FElementCanvas = document.createElement("CANVAS");
        this.GetContainer().appendChild(this.FElementCanvas);
      };
    };
    this.BindEvents = function () {
      $mod.TControl.BindEvents.call(this);
    };
    this.HandleScreenShot = function (Sender) {
      if (this.FOnScreenShot != null) this.FOnScreenShot(this,Sender);
    };
    this.Paint = function () {
    };
    this.CreateInitialize = function () {
      $mod.TControl.CreateInitialize.call(this);
      this.FControlStyle = rtl.unionSet(this.FControlStyle,rtl.createSet($mod.TControlStyleValue.csSetCaption));
      this.FBorderStyle = $mod.TBorderStyle.bsSingle;
      this.FBorderColor = 12632256;
      this.FPainting = false;
      this.FWidth = 100;
      this.FHeight = 25;
      this.FWidthPercent = 100;
      this.FHeightPercent = 100;
      this.FCustomBorder = false;
    };
    this.Destroy = function () {
      if (this.FCanvas != null) rtl.free(this,"FCanvas");
      $mod.TControl.Destroy.call(this);
    };
    this.MakeScreenshot = function () {
      var Result = null;
      Result = pas["WEBLib.Graphics"].TBitmap.$create("Create$3");
      Result.FOnChange = rtl.createCallback(this,"HandleScreenShot");
      Result.LoadFromCanvas(this.GetCanvas());
      return Result;
    };
    this.Resize = function () {
      $mod.TControl.Resize.call(this);
      this.Invalidate();
    };
    this.Invalidate = function () {
      var px = 0.0;
      var frm = null;
      $mod.TControl.Invalidate.call(this);
      if ((this.FParent === null) || (pas.Classes.TComponentStateItem.csDestroying in this.FComponentState)) return;
      if (!this.FVisible) return;
      if (this.FUpdateCount > 0) return;
      frm = pas["WEBLib.Forms"].GetParentForm(this);
      if (frm != null) if (frm.IsUpdating()) return;
      px = this.GetPixelRatio();
      if (px !== this.FPixelRatio) this.RecreateCanvas();
      this.FPixelRatio = this.GetPixelRatio();
      this.FPainting = true;
      if (this.FCanvas != null) this.FCanvas.Clear();
      this.Paint();
      this.FPainting = false;
    };
    this.SetFocus = function () {
      $mod.TControl.SetFocus.call(this);
    };
    this.Focused = function () {
      var Result = false;
      Result = $mod.TControl.Focused.call(this);
      return Result;
    };
    this.EndUpdate = function () {
      $mod.TControl.EndUpdate.call(this);
      if (this.FUpdateCount === 0) this.Invalidate();
    };
    rtl.addIntf(this,$mod.IControl);
    rtl.addIntf(this,pas.System.IUnknown);
  });
  rtl.createClass(this,"TjQueryCustomControl",this.TWinControl,function () {
    this.$init = function () {
      $mod.TWinControl.$init.call(this);
      this.FIsInitialized = false;
    };
    this.InitJQueryOnce = function () {
      if (this.IsUpdating()) return;
      if (this.FIsInitialized) return;
      this.FIsInitialized = true;
      this.InitJQuery();
    };
    this.CreateElement = function () {
      var Result = null;
      Result = document.createElement("DIV");
      return Result;
    };
    this.Loaded = function () {
      $mod.TControl.Loaded.call(this);
      this.InitJQueryOnce();
    };
    this.SetParent = function (AValue) {
      $mod.TControl.SetParent.apply(this,arguments);
      this.InitJQueryOnce();
    };
    this.GetJQID = function () {
      var Result = "";
      Result = "#" + this.GetID();
      return Result;
    };
    this.InitJQuery = function () {
    };
    this.CreateInitialize = function () {
      $mod.TControl.CreateInitialize.call(this);
      this.FIsInitialized = false;
    };
    rtl.addIntf(this,$mod.IControl);
    rtl.addIntf(this,pas.System.IUnknown);
    var $r = this.$rtti;
    $r.addProperty("ElementPosition",2,$mod.$rtti["TElementPosition"],"FElementPosition","SetElementPosition",{Default: $mod.TElementPosition.epAbsolute});
  });
  rtl.createClass(this,"TGraphicControl",this.TCustomControl,function () {
    rtl.addIntf(this,$mod.IControl);
    rtl.addIntf(this,pas.System.IUnknown);
  });
  rtl.createClass(this,"TScrollingGraphicControl",this.TCustomControl,function () {
    this.CreateElement = function () {
      var Result = null;
      Result = document.createElement("DIV");
      return Result;
    };
    this.UpdateElement = function () {
      $mod.TControl.UpdateElement.call(this);
      if (this.GetElementHandle() != null) this.GetElementHandle().style.setProperty("overflow","auto");
    };
    rtl.addIntf(this,$mod.IControl);
    rtl.addIntf(this,pas.System.IUnknown);
  });
  rtl.createClass(this,"TCustomHTMLDiv",this.TCustomControl,function () {
    this.CreateElement = function () {
      var Result = null;
      Result = document.createElement("DIV");
      return Result;
    };
    rtl.addIntf(this,$mod.IControl);
    rtl.addIntf(this,pas.System.IUnknown);
  });
  rtl.createClass(this,"TControlManager",pas.Classes.TComponent,function () {
    this.$init = function () {
      pas.Classes.TComponent.$init.call(this);
      this.FInstanceCount = 0;
    };
    this.Create$1 = function (AOwner) {
      pas.Classes.TComponent.Create$1.apply(this,arguments);
      this.FInstanceCount = 0;
      return this;
    };
    this.GetInstanceNumber = function () {
      var Result = 0;
      this.FInstanceCount += 1;
      Result = this.FInstanceCount;
      return Result;
    };
    this.Reset = function () {
      this.FInstanceCount = 0;
    };
    rtl.addIntf(this,pas.System.IUnknown);
    var $r = this.$rtti;
    $r.addMethod("Create$1",2,[["AOwner",pas.Classes.$rtti["TComponent"]]]);
  });
  rtl.createClass(this,"TCSSCodeFragment",pas.Classes.TCollectionItem,function () {
    this.$init = function () {
      pas.Classes.TCollectionItem.$init.call(this);
      this.FControlClassname = "";
      this.FCSS = null;
    };
    this.$final = function () {
      this.FCSS = undefined;
      pas.Classes.TCollectionItem.$final.call(this);
    };
    this.SetCSS = function (Value) {
      this.FCSS.Assign(Value);
    };
    this.Create$1 = function (Collection) {
      pas.Classes.TCollectionItem.Create$1.apply(this,arguments);
      this.FCSS = pas.Classes.TStringList.$create("Create$1");
      return this;
    };
    this.Destroy = function () {
      rtl.free(this,"FCSS");
      pas.Classes.TCollectionItem.Destroy.call(this);
    };
    var $r = this.$rtti;
    $r.addMethod("Create$1",2,[["Collection",pas.Classes.$rtti["TCollection"]]]);
    $r.addProperty("ControlClassname",0,rtl.string,"FControlClassname","FControlClassname");
    $r.addProperty("CSS",2,pas.Classes.$rtti["TStringList"],"FCSS","SetCSS");
  });
  rtl.createClass(this,"TCSSCodeFragments",pas.Classes.TOwnedCollection,function () {
    this.GetItemEx = function (Index) {
      var Result = null;
      Result = this.GetItem(Index);
      return Result;
    };
    this.SetItemEx = function (Index, Value) {
      this.SetItem(Index,Value);
    };
    this.Create$3 = function (AOwner) {
      pas.Classes.TOwnedCollection.Create$2.call(this,AOwner,$mod.TCSSCodeFragment);
      return this;
    };
    this.Add$1 = function () {
      var Result = null;
      Result = pas.Classes.TCollection.Add.call(this);
      return Result;
    };
    this.Insert$1 = function (Index) {
      var Result = null;
      Result = pas.Classes.TCollection.Insert.call(this,Index);
      return Result;
    };
    var $r = this.$rtti;
    $r.addMethod("Create$3",2,[["AOwner",pas.Classes.$rtti["TComponent"]]]);
  });
  rtl.createClass(this,"TCSSCodeManager",pas.Classes.TComponent,function () {
    this.$init = function () {
      pas.Classes.TComponent.$init.call(this);
      this.FCSSFragments = null;
    };
    this.$final = function () {
      this.FCSSFragments = undefined;
      pas.Classes.TComponent.$final.call(this);
    };
    this.SetCSSFragments = function (Value) {
      this.FCSSFragments.Assign(Value);
    };
    this.Create$1 = function (AOwner) {
      pas.Classes.TComponent.Create$1.apply(this,arguments);
      this.FCSSFragments = $mod.TCSSCodeFragments.$create("Create$3",[this]);
      this.FCSSFragments.FPropName = "CSSFragments";
      return this;
    };
    this.Destroy = function () {
      rtl.free(this,"FCSSFragments");
      pas.Classes.TComponent.Destroy.call(this);
    };
    this.GetClassFragment = function (AClassname) {
      var Result = null;
      var i = 0;
      Result = null;
      for (var $l = 0, $end = this.FCSSFragments.GetCount() - 1; $l <= $end; $l++) {
        i = $l;
        if (this.FCSSFragments.GetItemEx(i).FControlClassname === AClassname) Result = this.FCSSFragments.GetItemEx(i);
      };
      return Result;
    };
    this.GetClassCSS = function (AClassname) {
      var Result = "";
      var CSSCodeFragment = null;
      Result = "";
      CSSCodeFragment = this.GetClassFragment(AClassname);
      if (CSSCodeFragment != null) Result = CSSCodeFragment.FCSS.GetTextStr();
      return Result;
    };
    rtl.addIntf(this,pas.System.IUnknown);
    var $r = this.$rtti;
    $r.addMethod("Create$1",2,[["AOwner",pas.Classes.$rtti["TComponent"]]]);
    $r.addProperty("CSSFragments",2,$mod.$rtti["TCSSCodeFragments"],"FCSSFragments","SetCSSFragments");
  });
  rtl.createInterface(this,"ITMSFNCDataBinderBase","{778B63C9-34E3-4B65-A6B8-85E3EB1D17C3}",["DataBeginUpdate","DataEndUpdate"],pas.System.IUnknown,function () {
    var $r = this.$rtti;
    $r.addMethod("DataBeginUpdate",0,[]);
    $r.addMethod("DataEndUpdate",0,[]);
  });
  rtl.createInterface(this,"ITMSFNCDataBinderGrid","{D23BDEAA-49B1-451A-9401-0D0D11A9957A}",["SetDataColumnCount","SetDataRowCount","ClearData","GetDataRowCount","SetDataValue","SetDataHeader","DataInsertRow"],this.ITMSFNCDataBinderBase,function () {
    var $r = this.$rtti;
    $r.addMethod("SetDataColumnCount",0,[["AValue",rtl.longint]]);
    $r.addMethod("SetDataRowCount",0,[["AValue",rtl.longint]]);
    $r.addMethod("ClearData",0,[]);
    $r.addMethod("GetDataRowCount",1,[],rtl.longint);
    $r.addMethod("SetDataValue",0,[["AColumn",rtl.longint],["ARow",rtl.longint],["AValue",rtl.string]]);
    $r.addMethod("SetDataHeader",0,[["AColumn",rtl.longint],["AValue",rtl.string]]);
    $r.addMethod("DataInsertRow",0,[["AInsertPosition",rtl.longint]]);
  });
  rtl.createHelper(this,"TStringListHelper",null,function () {
    this.LoadFromJSONArray = function (ja) {
      var jsa = null;
      var i = 0;
      jsa = JSON.parse(ja);
      for (var $l = 0, $end = jsa.length - 1; $l <= $end; $l++) {
        i = $l;
        this.Add("" + jsa[i]);
      };
    };
    this.LoadFromJSONArrayURL = function (URL) {
      var $Self = this;
      var Result = null;
      var req = null;
      function ResultHandler(response) {
        var jsa = null;
        var i = 0;
        jsa = JSON.parse(response);
        for (var $l = 0, $end = jsa.length - 1; $l <= $end; $l++) {
          i = $l;
          $Self.Add("" + jsa[i]);
        };
      };
      Result = new Promise(function (ASuccess, AFailed) {
        req = new XMLHttpRequest();
        req.open("GET",URL);
        req.onload = function() {
                  if (req.status != 200) {
                    AFailed(false); }
                  else {
        
                    ResultHandler(req.response);
                    ASuccess(true);
                  }
                };
        req.send();
      });
      return Result;
    };
  });
  this.FindGlobalComponent = function (Name) {
    var Result = null;
    Result = null;
    return Result;
  };
  this.GetMousePos = function () {
    var Result = pas.Types.TPoint.$new();
    Result.$assign(pas.Types.Point($impl.FMouseX,$impl.FMouseY));
    return Result;
  };
  this.GetCursorPos = function (pt) {
    pt.x = $impl.FCursorX;
    pt.y = $impl.FCursorY;
  };
  this.FindUniqueName = function (Name) {
    var Result = "";
    Result = Name + pas.SysUtils.IntToStr($impl.ControlManager.GetInstanceNumber());
    return Result;
  };
  this.GetScrollBarHeight = function () {
    var Result = 0;
    var res = 0;
    res = $impl.ScrollBH;
    if (res === 0) {
      var outer = document.createElement("div");
            outer.style.visibility = "hidden";
            outer.style.height = "100px";
            outer.style.msOverflowStyle = "scrollbar"; // needed for WinJS apps
      
            document.body.appendChild(outer);
      
            var HeightNoScroll = outer.offsetHeight;
            // force scrollbars
            outer.style.overflow = "scroll";
      
            // add innerdiv
            var inner = document.createElement("div");
            inner.style.height = "100%";
            outer.appendChild(inner);
      
            var HeightWithScroll = inner.offsetHeight;
      
            // remove divs
            outer.parentNode.removeChild(outer);
      
            res = HeightNoScroll - HeightWithScroll;
      
            //res = 0;
      $impl.ScrollBH = res;
    };
    Result = res;
    return Result;
  };
  this.GetScrollBarWidth = function () {
    var Result = 0;
    var res = 0;
    res = $impl.ScrollBW;
    if (res === 0) {
      var outer = document.createElement("div");
            outer.style.visibility = "hidden";
            outer.style.width = "100px";
            outer.style.msOverflowStyle = "scrollbar"; // needed for WinJS apps
      
            document.body.appendChild(outer);
      
            var widthNoScroll = outer.offsetWidth;
            // force scrollbars
            outer.style.overflow = "scroll";
      
            // add innerdiv
            var inner = document.createElement("div");
            inner.style.width = "100%";
            outer.appendChild(inner);
      
            var widthWithScroll = inner.offsetWidth;
      
            // remove divs
            outer.parentNode.removeChild(outer);
      
            res = widthNoScroll - widthWithScroll;
      $impl.ScrollBW = res;
    };
    Result = res;
    return Result;
  };
  this.SetHTMLElementFont = function (AElement, AFont, UseCSS) {
    var s = "";
    if (UseCSS) {
      AElement.style.removeProperty("font-family");
      AElement.style.removeProperty("font-style");
      AElement.style.removeProperty("font-weight");
      AElement.style.removeProperty("font-size");
      AElement.style.removeProperty("text-decoration");
    } else {
      AElement.style.setProperty("font-family",AFont.FName);
      AElement.style.setProperty("font-style","normal");
      if (pas["WEBLib.Graphics"].TFontStyle.fsBold in AFont.FStyle) {
        AElement.style.setProperty("font-weight","bold")}
       else AElement.style.setProperty("font-weight","");
      if (pas["WEBLib.Graphics"].TFontStyle.fsItalic in AFont.FStyle) AElement.style.setProperty("font-style","italic");
      s = "";
      if (pas["WEBLib.Graphics"].TFontStyle.fsUnderline in AFont.FStyle) s = "underline";
      if (pas["WEBLib.Graphics"].TFontStyle.fsStrikeOut in AFont.FStyle) {
        if (s !== "") s = s + " ";
        s = s + "line-through";
      };
      if (s !== "") {
        AElement.style.setProperty("text-decoration",s)}
       else AElement.style.removeProperty("text-decoration");
      if (AFont.FSize !== 0) AElement.style.setProperty("font-size",pas.SysUtils.IntToStr(AFont.FSize) + "pt");
    };
  };
  this.SetHTMLElementColor = function (AElement, AColor, UseCSS) {
    if (UseCSS || (AColor === -1) || (AColor === 16711422)) {
      AElement.style.removeProperty($impl.cStyleBkgColor)}
     else AElement.style.setProperty($impl.cStyleBkgColor,pas["WEBLib.Graphics"].ColorToHTML(AColor));
  };
  this.GetHTMLCursorName = function (ACursor) {
    var Result = "";
    Result = "default";
    var $tmp = ACursor;
    if ($tmp === 0) {
      Result = "default"}
     else if ($tmp === 2) {
      Result = "auto"}
     else if ($tmp === 1) {
      Result = "none"}
     else if ($tmp === 3) {
      Result = "crosshair"}
     else if ($tmp === 4) {
      Result = "text"}
     else if ($tmp === 6) {
      Result = "nesw-resize"}
     else if ($tmp === 7) {
      Result = "ns-resize"}
     else if ($tmp === 8) {
      Result = "nwse-resize"}
     else if ($tmp === 9) {
      Result = "ew-resize"}
     else if ($tmp === 10) {
      Result = "n-resize"}
     else if ($tmp === 11) {
      Result = "wait"}
     else if ($tmp === 12) {
      Result = "copy"}
     else if ($tmp === 13) {
      Result = "no-drop"}
     else if ($tmp === 14) {
      Result = "col-resize"}
     else if ($tmp === 15) {
      Result = "row-resize"}
     else if ($tmp === 16) {
      Result = "copy"}
     else if ($tmp === 17) {
      Result = "progress"}
     else if ($tmp === 18) {
      Result = "not-allowed"}
     else if ($tmp === 19) {
      Result = "progress"}
     else if ($tmp === 20) {
      Result = "help"}
     else if ($tmp === 21) {
      Result = "pointer"}
     else if (($tmp === 22) || ($tmp === 5)) Result = "move";
    return Result;
  };
  this.GetHTMLElementAbsoluteRect = function (AElement) {
    var Result = pas.Types.TRect.$new();
    var s = "";
    function GetInt(AValue) {
      var Result = 0;
      var e = 0;
      AValue = pas.SysUtils.StringReplace(AValue,"px","",rtl.createSet(pas.SysUtils.TStringReplaceFlag.rfReplaceAll));
      pas.System.val$6(AValue,{get: function () {
          return Result;
        }, set: function (v) {
          Result = v;
        }},{get: function () {
          return e;
        }, set: function (v) {
          e = v;
        }});
      return Result;
    };
    s = AElement.style.getPropertyValue("left");
    Result.Left = GetInt(s);
    s = AElement.style.getPropertyValue("top");
    Result.Top = GetInt(s);
    s = AElement.style.getPropertyValue("width");
    Result.Right = Result.Left + GetInt(s);
    s = AElement.style.getPropertyValue("height");
    Result.Bottom = Result.Top + GetInt(s);
    return Result;
  };
  this.CursorToString = function (ACursor) {
    var Result = "";
    Result = "crDefault";
    var $tmp = ACursor;
    if ($tmp === 0) {
      Result = "crDefault"}
     else if ($tmp === 2) {
      Result = "crArrow"}
     else if ($tmp === 1) {
      Result = "crNone"}
     else if ($tmp === 3) {
      Result = "crCross"}
     else if ($tmp === 5) {
      Result = "ctSize"}
     else if ($tmp === 4) {
      Result = "crIBeam"}
     else if ($tmp === 6) {
      Result = "crSizeNESW"}
     else if ($tmp === 7) {
      Result = "crSizeNS"}
     else if ($tmp === 8) {
      Result = "crSizeNWSE"}
     else if ($tmp === 9) {
      Result = "crSizeWE"}
     else if ($tmp === 10) {
      Result = "crUpArrow"}
     else if ($tmp === 11) {
      Result = "crHourGlass"}
     else if ($tmp === 12) {
      Result = "crDrag"}
     else if ($tmp === 13) {
      Result = "crNoDrop"}
     else if ($tmp === 14) {
      Result = "crHSplit"}
     else if ($tmp === 15) {
      Result = "crVSplit"}
     else if ($tmp === 16) {
      Result = "crMultiDrag"}
     else if ($tmp === 17) {
      Result = "crSQLWait"}
     else if ($tmp === 18) {
      Result = "crNo"}
     else if ($tmp === 19) {
      Result = "crAppStart"}
     else if ($tmp === 20) {
      Result = "crHelp"}
     else if ($tmp === 21) {
      Result = "crHandpoint"}
     else if ($tmp === 22) Result = "crSizeAll";
    return Result;
  };
  this.StringToCursor = function (S) {
    var Result = 0;
    var us = "";
    Result = 0;
    us = pas.SysUtils.UpperCase(S);
    if (us === "CRDEFAULT") {
      Result = 0}
     else if (us === "CRARROW") {
      Result = 2}
     else if (us === "CRNONE") {
      Result = 1}
     else if (us === "CRCROSS") {
      Result = 3}
     else if (us === "CRSIZE") {
      Result = 5}
     else if (us === "CRIBEAM") {
      Result = 4}
     else if (us === "CRSIZENESW") {
      Result = 6}
     else if (us === "CRSIZENS") {
      Result = 7}
     else if (us === "CRSIZENWSE") {
      Result = 8}
     else if (us === "CRSIZEWE") {
      Result = 9}
     else if (us === "CRUPARROW") {
      Result = 10}
     else if (us === "CRHOURGLASS") {
      Result = 11}
     else if (us === "CRDRAG") {
      Result = 12}
     else if (us === "CRNODROP") {
      Result = 13}
     else if (us === "CRHSPLIT") {
      Result = 14}
     else if (us === "CRVSPLIT") {
      Result = 15}
     else if (us === "CRMULTIDRAG") {
      Result = 16}
     else if (us === "CRSQLWAIT") {
      Result = 17}
     else if (us === "CRNO") {
      Result = 18}
     else if (us === "CRAPPSTART") {
      Result = 19}
     else if (us === "CRHELP") {
      Result = 20}
     else if (us === "CRHANDPOINT") {
      Result = 21}
     else if (us === "CRSIZEALL") Result = 22;
    return Result;
  };
  this.IsAndroid = function () {
    var Result = false;
    var sagent = "";
    sagent = navigator.userAgent;
    Result = pas.System.Pos("Android",sagent) > 0;
    return Result;
  };
  this.GetMaterialClass = function (mg) {
    var Result = "";
    Result = "material-icons";
    var $tmp = mg;
    if ($tmp === $mod.TMaterialGlyphType.mgOutlined) {
      Result = "material-icons-outlined"}
     else if ($tmp === $mod.TMaterialGlyphType.mgTwoTone) {
      Result = "material-icons-two-tone"}
     else if ($tmp === $mod.TMaterialGlyphType.mgRound) {
      Result = "material-icons-round"}
     else if ($tmp === $mod.TMaterialGlyphType.mgSharp) Result = "material-icons-sharp";
    return Result;
  };
  this.InputTypeString = function (AInputType) {
    var Result = "";
    var $tmp = AInputType;
    if ($tmp === $mod.TInputType.itText) {
      Result = "text"}
     else if ($tmp === $mod.TInputType.itEmail) {
      Result = "email"}
     else if ($tmp === $mod.TInputType.itDate) {
      Result = "date"}
     else if ($tmp === $mod.TInputType.itDateTime) {
      Result = "datetime-local"}
     else if ($tmp === $mod.TInputType.itFile) {
      Result = "file"}
     else if ($tmp === $mod.TInputType.itMonth) {
      Result = "month"}
     else if ($tmp === $mod.TInputType.itNumber) {
      Result = "number"}
     else if ($tmp === $mod.TInputType.itPassword) {
      Result = "password"}
     else if ($tmp === $mod.TInputType.itSearch) {
      Result = "search"}
     else if ($tmp === $mod.TInputType.itTime) {
      Result = "time"}
     else if ($tmp === $mod.TInputType.itURL) {
      Result = "url"}
     else if ($tmp === $mod.TInputType.itWeek) Result = "week";
    return Result;
  };
  $mod.$implcode = function () {
    $impl.ControlManager = null;
    $impl.FMouseX = 0;
    $impl.FMouseY = 0;
    $impl.FCursorX = 0;
    $impl.FCursorY = 0;
    $impl.ScrollBW = 0;
    $impl.ScrollBH = 0;
    $impl.DragObject = null;
    $impl.cStyleBkgColor = "background-color";
  };
  $mod.$init = function () {
    $impl.ScrollBW = 0;
    $impl.ScrollBH = 0;
    $impl.DragObject = null;
    $impl.ControlManager = $mod.TControlManager.$create("Create$1",[null]);
  };
},["WEBLib.Dialogs","WEBLib.Forms","Math","TypInfo","WEBLib.WebTools","WEBLib.Utils"]);
rtl.module("WEBLib.WebTools",["System","Classes","Web","JS","WEBLib.Controls","WEBLib.Graphics"],function () {
  "use strict";
  var $mod = this;
  this.CRLF = "\r\n";
  this.LNBR = "<BR>";
  this.cBodyTag = "body";
  this.cHTMLExt = ".html";
  this.TOperatingSystem = {"0": "osUnknown", osUnknown: 0, "1": "osWindows", osWindows: 1, "2": "osmacOS", osmacOS: 2, "3": "osLinux", osLinux: 3, "4": "osAndroid", osAndroid: 4, "5": "osiOS", osiOS: 5};
  this.$rtti.$Enum("TOperatingSystem",{minvalue: 0, maxvalue: 5, ordtype: 1, enumtype: this.TOperatingSystem});
  this.DoubleToHTML = function (d) {
    var Result = "";
    Result = pas.SysUtils.Format$1("%g",pas.System.VarRecs(3,d),pas.SysUtils.TFormatSettings.Invariant());
    return Result;
  };
  this.MessageBeep = function (AType) {
    var snd = new Audio("data:audio/wav;base64,//uQRAAAAWMSLwUIYAAsYkXgoQwAEaYLWfkWgAI0wWs/ItAAAGDgYtAgAyN+QWaAAihwMWm4G8QQRDiMcCBcH3Cc+CDv/7xA4Tvh9Rz/y8QADBwMWgQAZG/ILNAARQ4GLTcDeI"+
        "IIhxGOBAuD7hOfBB3/94gcJ3w+o5/5eIAIAAAVwWgQAVQ2ORaIQwEMAJiDg95G4nQL7mQVWI6GwRcfsZAcsKkJvxgxEjzFUgfHoSQ9Qq7KNwqHwuB13MA4a1q/DmBrHgPcmjiGoh//EwC5nGPEmS4RcfkVK"+
    "OhJf+WOgoxJclFz3kgn//dBA+ya1GhurNn8zb//9NNutNuhz31f////9vt///z+IdAEAAAK4LQIAKobHItEIYCGAExBwe8jcToF9zIKrEdDYIuP2MgOWFSE34wYiR5iqQPj0JIeoVdlG4VD4XA67mAcNa1f"+
    "hzA1jwHuTRxDUQ//iYBczjHiTJcIuPyKlHQkv/LHQUYkuSi57yQT//uggfZNajQ3Vmz+Zt//+mm3Wm3Q576v////+32///5/EOgAAADVghQAAAAA//uQZAUAB1WI0PZugAAAAAoQwAAAEk3nRd2qAAAAACi"+
    "DgAAAAAAABCqEEQRLCgwpBGMlJkIz8jKhGvj4k6jzRnqasNKIeoh5gI7BJaC1A1AoNBjJgbyApVS4IDlZgDU5WUAxEKDNmmALHzZp0Fkz1FMTmGFl1FMEyodIavcCAUHDWrKAIA4aa2oCgILEBupZgHvAhE"+
    "BcZ6joQBxS76AgccrFlczBvKLC0QI2cBoCFvfTDAo7eoOQInqDPBtvrDEZBNYN5xwNwxQRfw8ZQ5wQVLvO8OYU+mHvFLlDh05Mdg7BT6YrRPpCBznMB2r//xKJjyyOh+cImr2/4doscwD6neZjuZR4AgAABY"+
    "AAAABy1xcdQtxYBYYZdifkUDgzzXaXn98Z0oi9ILU5mBjFANmRwlVJ3/6jYDAmxaiDG3/6xjQQCCKkRb/6kg/wW+kSJ5//rLobkLSiKmqP/0ikJuDaSaSf/6JiLYLEYnW/+kXg1WRVJL/9EmQ1YZIsv/6Qzw"+
    "y5qk7/+tEU0nkls3/zIUMPKNX/6yZLf+kFgAfgGyLFAUwY//uQZAUABcd5UiNPVXAAAApAAAAAE0VZQKw9ISAAACgAAAAAVQIygIElVrFkBS+Jhi+EAuu+lKAkYUEIsmEAEoMeDmCETMvfSHTGkF5RWH7kz/"+
    "ESHWPAq/kcCRhqBtMdokPdM7vil7RG98A2sc7zO6ZvTdM7pmOUAZTnJW+NXxqmd41dqJ6mLTXxrPpnV8avaIf5SvL7pndPvPpndJR9Kuu8fePvuiuhorgWjp7Mf/PRjxcFCPDkW31srioCExivv9lcwKEaHs"+
    "f/7ow2Fl1T/9RkXgEhYElAoCLFtMArxwivDJJ+bR1HTKJdlEoTELCIqgEwVGSQ+hIm0NbK8WXcTEI0UPoa2NbG4y2K00JEWbZavJXkYaqo9CRHS55FcZTjKEk3NKoCYUnSQ0rWxrZbFKbKIhOKPZe1cJKzZS"+
    "aQrIyULHDZmV5K4xySsDRKWOruanGtjLJXFEmwaIbDLX0hIPBUQPVFVkQkDoUNfSoDgQGKPekoxeGzA4DUvnn4bxzcZrtJyipKfPNy5w+9lnXwgqsiyHNeSVpemw4bWb9psYeq//uQZBoABQt4yMVxYAIAAA"+
    "kQoAAAHvYpL5m6AAgAACXDAAAAD59jblTirQe9upFsmZbpMudy7Lz1X1DYsxOOSWpfPqNX2WqktK0DMvuGwlbNj44TleLPQ+Gsfb+GOWOKJoIrWb3cIMeeON6lz2umTqMXV8Mj30yWPpjoSa9ujK8SyeJP5y5"+
    "mOW1D6hvLepeveEAEDo0mgCRClOEgANv3B9a6fikgUSu/DmAMATrGx7nng5p5iimPNZsfQLYB2sDLIkzRKZOHGAaUyDcpFBSLG9MCQALgAIgQs2YunOszLSAyQYPVC2YdGGeHD2dTdJk1pAHGAWDjnkcLKFym"+
    "S3RQZTInzySoBwMG0QueC3gMsCEYxUqlrcxK6k1LQQcsmyYeQPdC2YfuGPASCBkcVMQQqpVJshui1tkXQJQV0OXGAZMXSOEEBRirXbVRQW7ugq7IM7rPWSZyDlM3IuNEkxzCOJ0ny2ThNkyRai1b6ev//3dzN"+
    "GzNb//4uAvHT5sURcZCFcuKLhOFs8mLAAEAt4UWAAIABAAAAAB4qbHo0tIjVkUU//uQZAwABfSFz3ZqQAAAAAngwAAAE1HjMp2qAAAAACZDgAAAD5UkTE1UgZEUExqYynN1qZvqIOREEFmBcJQkwdxiFtw0q"+
    "EOkGYfRDifBui9MQg4QAHAqWtAWHoCxu1Yf4VfWLPIM2mHDFsbQEVGwyqQoQcwnfHeIkNt9YnkiaS1oizycqJrx4KOQjahZxWbcZgztj2c49nKmkId44S71j0c8eV9yDK6uPRzx5X18eDvjvQ6yKo9ZSS6l/"+
    "/8elePK/Lf//IInrOF/FvDoADYAGBMGb7FtErm5MXMlmPAJQVgWta7Zx2go+8xJ0UiCb8LHHdftWyLJE0QIAIsI+UbXu67dZMjmgDGCGl1H+vpF4NSDckSIkk7Vd+sxEhBQMRU8j/12UIRhzSaUdQ+rQU5kG"+
    "eFxm+hb1oh6pWWmv3uvmReDl0UnvtapVaIzo1jZbf/pD6ElLqSX+rUmOQNpJFa/r+sa4e/pBlAABoAAAAA3CUgShLdGIxsY7AUABPRrgCABdDuQ5GC7DqPQCgbbJUAoRSUj+NIEig0YfyWUho1VBBBA//uQZ"+
    "B4ABZx5zfMakeAAAAmwAAAAF5F3P0w9GtAAACfAAAAAwLhMDmAYWMgVEG1U0FIGCBgXBXAtfMH10000EEEEEECUBYln03TTTdNBDZopopYvrTTdNa325mImNg3TTPV9q3pmY0xoO6bv3r00y+IDGid/9aaaZ"+
    "TGMuj9mpu9Mpio1dXrr5HERTZSmqU36A3CumzN/9Robv/Xx4v9ijkSRSNLQhAWumap82WRSBUqXStV/YcS+XVLnSS+WLDroqArFkMEsAS+eWmrUzrO0oEmE40RlMZ5+ODIkAyKAGUwZ3mVKmcamcJnMW26MRP"+
    "gUw6j+LkhyHGVGYjSUUKNpuJUQoOIAyDvEyG8S5yfK6dhZc0Tx1KI/gviKL6qvvFs1+bWtaz58uUNnryq6kt5RzOCkPWlVqVX2a/EEBUdU1KrXLf40GoiiFXK///qpoiDXrOgqDR38JB0bw7SoL+ZB9o1RCk"+
    "QjQ2CBYZKd/+VJxZRRZlqSkKiws0WFxUyCwsKiMy7hUVFhIaCrNQsKkTIsLivwKKigsj8XYlwt/WKi2N4d//uQRCSAAjURNIHpMZBGYiaQPSYyAAABLAAAAAAAACWAAAAApUF/Mg+0aohSIRobBAsMlO//Kk"+
    "4soosy1JSFRYWaLC4qZBYWFRGZdwqKiwkNBVmoWFSJkWFxX4FFRQWR+LsS4W/rFRb////////////////////////////////////////////////////////////////////////////////////////////"+
    "////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////"+
    "////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////"+
    "/////////////VEFHAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAU291bmRib3kuZGUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMjAwNGh0dHA6Ly93d3cuc291bmRib3kuZGUAAAAAAAAAACU=");
    snd.play();
  };
  this.OutputDebugString = function (s) {
    console.log(s);
  };
  this.GetTickCount = function () {
    var Result = 0;
    var n = 0;
    var d = new Date();
    n = d.getTime();
    Result = n;
    return Result;
  };
  this.GetQueryParam = function (AName) {
    var Result = "";
    var res = "";
    $mod.HasQueryParam(AName,{get: function () {
        return res;
      }, set: function (v) {
        res = v;
      }},true);
    Result = res;
    return Result;
  };
  this.HasQueryParam = function (AName, AValue, CaseSensitive) {
    var Result = false;
    var found = false;
    var s = "";
    s = "";
    if (!CaseSensitive) AName = pas.SysUtils.UpperCase(AName);
    var query = window.location.search.substring(1);
        var res = "";
        var key = "";
        found = false;
        var vars = query.split('&');
        for (var i = 0; i < vars.length; i++) {
          var pair = vars[i].split('=');
    
          key = decodeURIComponent(pair[0]);
          if (CaseSensitive == false)
          {
            key = key.toUpperCase();
          }
    
          if (key == AName) {
              res = decodeURIComponent(pair[1]);
              found = true;
           }
        }
        s = res;
    AValue.set(s);
    Result = found;
    return Result;
  };
  this.EscapeHTML = function (AValue) {
    var Result = "";
    var s = "";
    s = AValue;
    function escapeHTML(AString) {
      return AString.replace(/&/g,'&amp;').replace(/</g,'&lt;').replace(/>/g,'&gt;');
    }
    s = escapeHTML(s);
    Result = s;
    return Result;
  };
  this.GetLocaleShortDateFormat = function (ALocale) {
    var Result = "";
    Result = pas.SysUtils.TFormatSettings.Create$1(ALocale).ShortDateFormat;
    return Result;
  };
  this.GetLocaleLongDayName = function (DayOfWeek, ALocale) {
    var Result = "";
    var res = "";
    var baseDate = new Date(2017, 0, 1); // Sunday
        baseDate.setDate(baseDate.getDate() + DayOfWeek - 1);
    
        var loc = "";
        if (ALocale == '') { loc = navigator.language; }
        else { loc = ALocale; }
    
        res = baseDate.toLocaleDateString(loc, { weekday: 'long' });
    Result = res;
    return Result;
  };
  this.GetLocaleShortDayName = function (DayOfWeek, ALocale) {
    var Result = "";
    var res = "";
    var baseDate = new Date(2017, 0, 1); // Sunday
        baseDate.setDate(baseDate.getDate() + DayOfWeek - 1);
    
        var loc = "";
        if (ALocale == '') { loc = navigator.language; }
        else { loc = ALocale; }
    
        res = baseDate.toLocaleDateString(loc, { weekday: 'short' });
    Result = res;
    return Result;
  };
  this.GetLocaleLongMonthName = function (Month, ALocale) {
    var Result = "";
    var res = "";
    var baseDate = new Date(2017, Month - 1, 1);
    
        var loc = "";
        if (ALocale == '') { loc = navigator.language; }
        else { loc = ALocale; }
    
        res = baseDate.toLocaleDateString(loc, { month: 'long' });
    Result = res;
    return Result;
  };
  this.GetLocaleShortMonthName = function (Month, ALocale) {
    var Result = "";
    var res = "";
    var baseDate = new Date(2017, Month - 1, 1);
    
        var loc = "";
        if (ALocale == '') { loc = navigator.language; }
        else { loc = ALocale; }
    
        res = baseDate.toLocaleDateString(loc, { month: 'short' });
    Result = res;
    return Result;
  };
  this.GetLocaleDecimalSeparator = function (ALocale) {
    var Result = "";
    var res = "";
    var n = 1.1;
        var loc = "";
        if (ALocale == '') { loc = navigator.language; }
        else { loc = ALocale; }
    
        n = n.toLocaleString(loc).substring(1, 2);
        res = n;
    Result = res;
    return Result;
  };
  this.GetLocaleThousandSeparator = function (ALocale) {
    var Result = "";
    var res = "";
    var n = 1000.1;
    var loc = "";
    if (ALocale == '') { loc = navigator.language; }
    else { loc = ALocale; }
    n = n.toLocaleString(loc).substring(1, 2);
    res = n;
    Result = res;
    return Result;
  };
  this.LocaleFormatCurrency = function (Value, ACurrency, ALocale) {
    var Result = "";
    var res = "";
    var loc = "";
    if (ALocale == '') { loc = navigator.language; }
    else { loc = ALocale; }
    var number = Value;
    res = number.toLocaleString(loc, { style: 'currency', currency: ACurrency });
    Result = res;
    return Result;
  };
  this.GetLocaleCurrency = function (ALocale) {
    var Result = "";
    var res = "";
    var curr =
          {"BD": "BDT", "BE": "EUR", "BF": "XOF", "BG": "BGN", "BA": "BAM", "BB": "BBD", "WF": "XPF",
           "BL": "EUR", "BM": "BMD", "BN": "BND", "BO": "BOB", "BH": "BHD", "BI": "BIF", "BJ": "XOF",
           "BT": "BTN", "JM": "JMD", "BV": "NOK", "BW": "BWP", "WS": "WST", "BQ": "USD", "BR": "BRL",
           "BS": "BSD", "JE": "GBP", "BY": "BYR", "BZ": "BZD", "RU": "RUB", "RW": "RWF", "RS": "RSD",
           "TL": "USD", "RE": "EUR", "TM": "TMT", "TJ": "TJS", "RO": "RON", "TK": "NZD", "GW": "XOF",
           "GU": "USD", "GT": "GTQ", "GS": "GBP", "GR": "EUR", "GQ": "XAF", "GP": "EUR", "JP": "JPY",
           "GY": "GYD", "GG": "GBP", "GF": "EUR", "GE": "GEL", "GD": "XCD", "GB": "GBP", "GA": "XAF",
           "SV": "USD", "GN": "GNF", "GM": "GMD", "GL": "DKK", "GI": "GIP", "GH": "GHS", "OM": "OMR",
           "TN": "TND", "JO": "JOD", "HR": "HRK", "HT": "HTG", "HU": "HUF", "HK": "HKD", "HN": "HNL",
           "HM": "AUD", "VE": "VEF", "PR": "USD", "PS": "ILS", "PW": "USD", "PT": "EUR", "SJ": "NOK",
           "PY": "PYG", "IQ": "IQD", "PA": "PAB", "PF": "XPF", "PG": "PGK", "PE": "PEN", "PK": "PKR",
           "PH": "PHP", "PN": "NZD", "PL": "PLN", "PM": "EUR", "ZM": "ZMK", "EH": "MAD", "EE": "EUR",
           "EG": "EGP", "ZA": "ZAR", "EC": "USD", "IT": "EUR", "VN": "VND", "SB": "SBD", "ET": "ETB",
           "SO": "SOS", "ZW": "ZWL", "SA": "SAR", "ES": "EUR", "ER": "ERN", "ME": "EUR", "MD": "MDL",
           "MG": "MGA", "MF": "EUR", "MA": "MAD", "MC": "EUR", "UZ": "UZS", "MM": "MMK", "ML": "XOF",
           "MO": "MOP", "MN": "MNT", "MH": "USD", "MK": "MKD", "MU": "MUR", "MT": "EUR", "MW": "MWK",
           "MV": "MVR", "MQ": "EUR", "MP": "USD", "MS": "XCD", "MR": "MRO", "IM": "GBP", "UG": "UGX",
           "TZ": "TZS", "MY": "MYR", "MX": "MXN", "IL": "ILS", "FR": "EUR", "IO": "USD", "SH": "SHP",
           "FI": "EUR", "FJ": "FJD", "FK": "FKP", "FM": "USD", "FO": "DKK", "NI": "NIO", "NL": "EUR",
           "NO": "NOK", "NA": "NAD", "VU": "VUV", "NC": "XPF", "NE": "XOF", "NF": "AUD", "NG": "NGN",
           "NZ": "NZD", "NP": "NPR", "NR": "AUD", "NU": "NZD", "CK": "NZD", "XK": "EUR", "CI": "XOF",
           "CH": "CHF", "CO": "COP", "CN": "CNY", "CM": "XAF", "CL": "CLP", "CC": "AUD", "CA": "CAD",
           "CG": "XAF", "CF": "XAF", "CD": "CDF", "CZ": "CZK", "CY": "EUR", "CX": "AUD", "CR": "CRC",
           "CW": "ANG", "CV": "CVE", "CU": "CUP", "SZ": "SZL", "SY": "SYP", "SX": "ANG", "KG": "KGS",
           "KE": "KES", "SS": "SSP", "SR": "SRD", "KI": "AUD", "KH": "KHR", "KN": "XCD", "KM": "KMF",
           "ST": "STD", "SK": "EUR", "KR": "KRW", "SI": "EUR", "KP": "KPW", "KW": "KWD", "SN": "XOF",
           "SM": "EUR", "SL": "SLL", "SC": "SCR", "KZ": "KZT", "KY": "KYD", "SG": "SGD", "SE": "SEK",
           "SD": "SDG", "DO": "DOP", "DM": "XCD", "DJ": "DJF", "DK": "DKK", "VG": "USD", "DE": "EUR",
           "YE": "YER", "DZ": "DZD", "US": "USD", "UY": "UYU", "YT": "EUR", "UM": "USD", "LB": "LBP",
           "LC": "XCD", "LA": "LAK", "TV": "AUD", "TW": "TWD", "TT": "TTD", "TR": "TRY", "LK": "LKR",
           "LI": "CHF", "LV": "EUR", "TO": "TOP", "LT": "LTL", "LU": "EUR", "LR": "LRD", "LS": "LSL",
           "TH": "THB", "TF": "EUR", "TG": "XOF", "TD": "XAF", "TC": "USD", "LY": "LYD", "VA": "EUR",
           "VC": "XCD", "AE": "AED", "AD": "EUR", "AG": "XCD", "AF": "AFN", "AI": "XCD", "VI": "USD",
           "IS": "ISK", "IR": "IRR", "AM": "AMD", "AL": "ALL", "AO": "AOA", "AQ": "", "AS": "USD",
           "AR": "ARS", "AU": "AUD", "AT": "EUR", "AW": "AWG", "IN": "INR", "AX": "EUR", "AZ": "AZN",
           "IE": "EUR", "ID": "IDR", "UA": "UAH", "QA": "QAR", "MZ": "MZN"}
    
        var loc = "";
        if (ALocale == '') { loc = navigator.language; }
        else { loc = ALocale; }
        loc = loc.substring(3,5);
        loc = loc.toUpperCase();
        res = curr[loc] || '';
    Result = res;
    return Result;
  };
  this.GetBrowserLocale = function () {
    var Result = "";
    var res = "";
    res = navigator.language;
    Result = res;
    return Result;
  };
  this.GetOperatingSystem = function () {
    var Result = 0;
    var ag = "";
    var res = false;
    Result = $mod.TOperatingSystem.osUnknown;
    ag = navigator.userAgent;
    if (pas.System.Pos("Win",ag) > 0) Result = $mod.TOperatingSystem.osWindows;
    if (pas.System.Pos("Mac",ag) > 0) Result = $mod.TOperatingSystem.osmacOS;
    if (pas.System.Pos("Linux",ag) > 0) Result = $mod.TOperatingSystem.osLinux;
    if (pas.System.Pos("Android",ag) > 0) Result = $mod.TOperatingSystem.osAndroid;
    if (pas.System.Pos("Linux",ag) > 0) Result = $mod.TOperatingSystem.osLinux;
    res = ag.match(/(iPod|iPhone|iPad)/) &&
    ag.match(/AppleWebKit/);
    if (res) Result = $mod.TOperatingSystem.osiOS;
    return Result;
  };
  this.ProcessAccelerator = function (AValue, Accelerator) {
    var Result = "";
    var i = 0;
    var l = 0;
    var res = "";
    l = AValue.length;
    Accelerator.set("");
    res = "";
    i = 1;
    while (i <= l) {
      if (AValue.charAt(i - 1) === "&") {
        if (((i + 1) <= l) && (AValue.charAt((i + 1) - 1) !== "&")) {
          res = res + "<u>" + AValue.charAt((i + 1) - 1) + "</u>";
          Accelerator.set(AValue.charAt((i + 1) - 1));
        } else if (((i + 1) <= l) && (AValue.charAt((i + 1) - 1) === "&")) res = res + "&";
        i += 2;
      } else {
        res = res + AValue.charAt(i - 1);
        i += 1;
      };
    };
    Result = res;
    return Result;
  };
  this.GetBase64Image = function (AImage, AWidth, AHeight) {
    var Result = "";
    var s = "";
    var m = null;
    s = "";
    m = AImage;
    function getBase64Image(img) {
      var canvas = document.createElement("canvas");
      if (AWidth == 0) {
        canvas.width = img.width; }
        else {
        canvas.width = AWidth; }
      if (AHeight == 0) {
      canvas.height = img.height; }
      else {
        canvas.height = AHeight; }
      var ctx = canvas.getContext("2d");
      if ((AWidth == 0) || (AHeight == 0)) {
         ctx.drawImage(img, 0, 0); }
      else {
         ctx.drawImage(img, 0, 0, AWidth, AHeight); }
      var dataURL = canvas.toDataURL("image/png");
      return dataURL.replace(/^data:image\/(png|jpg);base64,/, "");
    }
    s = getBase64Image(m);
    Result = s;
    return Result;
  };
  this.DebugBreak = function () {
    debugger;
  };
  this.HexImageDecode = function (s) {
    var Result = null;
    var i = 0;
    var j = 0;
    var l = 0;
    var res = null;
    var c1 = 0;
    var c2 = 0;
    var hdr = 0;
    l = rtl.trunc(s.length / 2);
    j = 0;
    c1 = s.charCodeAt(1 - 1) - 48;
    if (c1 >= 10) c1 = c1 - 7;
    c2 = s.charCodeAt(2 - 1) - 48;
    if (c2 >= 10) c2 = c2 - 7;
    hdr = 1 + (c2 + (c1 << 4));
    i = pas.System.Pos("4A5045474",s);
    if ((i > 1) && (i < 10)) hdr += 4;
    i = pas.System.Pos("4269746D6",s);
    if ((i > 1) && (i < 10)) hdr += 4;
    res = new Uint8Array(l - hdr);
    for (var $l = hdr + 1, $end = l; $l <= $end; $l++) {
      i = $l;
      c1 = s.charCodeAt((i * 2) - 1 - 1) - 48;
      if (c1 >= 10) c1 = c1 - 7;
      c2 = s.charCodeAt((i * 2) - 1) - 48;
      if (c2 >= 10) c2 = c2 - 7;
      c2 = c2 + (c1 << 4);
      res[j] = c2;
      j += 1;
    };
    Result = res;
    return Result;
  };
  this.HexImageEncodeFromBase64 = function (s) {
    var Result = "";
    var ja = null;
    s = s.replace(/^data:image\/\S+;base64,/, "");
    //ja = Uint8Array.from(atob(s), c => c.charCodeAt(0))
    ja = Uint8Array.from(atob(s), function(c) { return c.charCodeAt(0);} );
    Result = $mod.HexImageEncode(ja);
    return Result;
  };
  this.HexImageEncode = function (a) {
    var Result = "";
    var i = 0;
    var l = 0;
    var b = 0;
    var s = "";
    var ls = "";
    Result = "";
    l = a.length;
    if (l === 0) return Result;
    l = ((l & 0xFF) << 24) + ((l & 0xFF00) << 8) + ((l & 0xFF0000) >>> 8) + ((l & 0xFF000000) >>> 24);
    ls = "";
    if ((a[0] === 137) && (a[1] === 80)) {
      s = "TPngImage";
      b = s.length;
    };
    if ((a[0] === 0xFF) && (a[1] === 0xD8)) {
      s = "TJPEGImage";
      b = s.length;
      ls = pas.SysUtils.IntToHex(l,8);
    };
    if ((a[0] === 66) && (a[1] === 77)) {
      s = "TBitmap";
      b = s.length;
      ls = pas.SysUtils.IntToHex(l,8);
    };
    if ((a[0] === 71) && (a[1] === 73)) {
      s = "TGIFImage";
      b = s.length;
    };
    Result = pas.SysUtils.IntToHex(b,2);
    for (var $l = 1, $end = s.length; $l <= $end; $l++) {
      i = $l;
      b = s.charCodeAt(i - 1);
      Result = Result + pas.SysUtils.IntToHex(b,2);
    };
    Result = Result + ls;
    for (var $l1 = 0, $end1 = a.length - 1; $l1 <= $end1; $l1++) {
      i = $l1;
      b = a[i];
      Result = Result + pas.SysUtils.IntToHex(b,2);
    };
    return Result;
  };
  this.HexImageDecodeAsBase64 = function (s) {
    var Result = "";
    var ja = null;
    ja = $mod.HexImageDecode(s);
    s = btoa(new Uint8Array(ja).reduce(function (data, byte) {
    return data + String.fromCharCode(byte);
    }, ''));
    Result = s;
    return Result;
  };
  this.EmptyImage = function () {
    var Result = "";
    Result = "data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==";
    return Result;
  };
  this.NumAttribute = function (s) {
    var Result = "";
    var res = "";
    res = pas.SysUtils.TDoubleHelper.ToString$3.call({get: function () {
        return s;
      }, set: function (v) {
        s = v;
      }});
    Result = pas.SysUtils.StringReplace(res,",",".",rtl.createSet(pas.SysUtils.TStringReplaceFlag.rfReplaceAll));
    return Result;
  };
  this.DataURLToFile = function (AURL, FileName) {
    var Result = null;
    var afile = null;
    var arr = AURL.split(','),
    mime = arr[0].match(/:(.*?);/)[1],
    bstr = atob(arr[1]),
    n = bstr.length,
    u8arr = new Uint8Array(n);
    while(n--){
      u8arr[n] = bstr.charCodeAt(n);
    }
    afile = new File([u8arr], FileName, {type:mime});
    Result = afile;
    return Result;
  };
  this.DownloadFile = function (AFile) {
    var a = null;
    a = document.createElement("a");
    a.href = window.URL.createObjectURL(AFile);
    a.download = AFile.name;
    a.click();
  };
  this.PickerDateToDate = function (s) {
    var Result = 0.0;
    var ye = "";
    var mo = "";
    var da = "";
    var yei = 0;
    var moi = 0;
    var dai = 0;
    var e = 0;
    Result = 0;
    ye = pas.System.Copy(s,1,4);
    mo = pas.System.Copy(s,6,2);
    da = pas.System.Copy(s,9,2);
    pas.System.val$5(ye,{get: function () {
        return yei;
      }, set: function (v) {
        yei = v;
      }},{get: function () {
        return e;
      }, set: function (v) {
        e = v;
      }});
    pas.System.val$5(mo,{get: function () {
        return moi;
      }, set: function (v) {
        moi = v;
      }},{get: function () {
        return e;
      }, set: function (v) {
        e = v;
      }});
    pas.System.val$5(da,{get: function () {
        return dai;
      }, set: function (v) {
        dai = v;
      }},{get: function () {
        return e;
      }, set: function (v) {
        e = v;
      }});
    if ((yei !== 0) && (moi !== 0) && (dai !== 0)) Result = pas.SysUtils.EncodeDate(yei,moi,dai);
    return Result;
  };
  this.PickerTimeToTime = function (s) {
    var Result = 0.0;
    var ho = "";
    var mi = "";
    var se = "";
    var hoi = 0;
    var mii = 0;
    var sei = 0;
    var e = 0;
    Result = 0;
    ho = pas.System.Copy(s,1,2);
    mi = pas.System.Copy(s,4,2);
    se = pas.System.Copy(s,7,2);
    pas.System.val$5(ho,{get: function () {
        return hoi;
      }, set: function (v) {
        hoi = v;
      }},{get: function () {
        return e;
      }, set: function (v) {
        e = v;
      }});
    pas.System.val$5(mi,{get: function () {
        return mii;
      }, set: function (v) {
        mii = v;
      }},{get: function () {
        return e;
      }, set: function (v) {
        e = v;
      }});
    pas.System.val$5(se,{get: function () {
        return sei;
      }, set: function (v) {
        sei = v;
      }},{get: function () {
        return e;
      }, set: function (v) {
        e = v;
      }});
    if ((hoi >= 0) && (mii >= 0) && (sei >= 0)) Result = pas.SysUtils.EncodeTime(hoi,mii,sei,0);
    return Result;
  };
  this.URLString = function (s) {
    var Result = "";
    var res = "";
    function linkify(inputText) {
        var replacedText, replacePattern1, replacePattern2, replacePattern3;
    
        //URLs starting with http://, https://, or ftp://
        replacePattern1 = /(\b(https?|ftp):\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])/gim;
        replacedText = inputText.replace(replacePattern1, '<a href="$1" target="_blank">$1</a>');
    
        //URLs starting with "www." (without // before it, or it'd re-link the ones done above).
        replacePattern2 = /(^|[^\/])(www\.[\S]+(\b|$))/gim;
        replacedText = replacedText.replace(replacePattern2, '$1<a href="http://$2" target="_blank">$2</a>');
    
        //Change email addresses to mailto:: links.
        replacePattern3 = /(([a-zA-Z0-9\-\_\.])+@[a-zA-Z\_]+?(\.[a-zA-Z]{2,6})+)/gim;
        replacedText = replacedText.replace(replacePattern3, '<a href="mailto:$1">$1</a>');
    
        return replacedText;
        }
        res = linkify(s);
    Result = res;
    return Result;
  };
  this.IsURl = function (s) {
    var Result = false;
    var res = false;
    function CheckIsUrl(inputText) {
    if(new RegExp("([a-zA-Z0-9]+://)?([a-zA-Z0-9_]+:[a-zA-Z0-9_]+@)?([a-zA-Z0-9.-]+\\.[A-Za-z]{2,4})(:[0-9]+)?(/.*)?").test(inputText)) {
        return true;
    }
    return false;
    }
    res = CheckIsUrl(s);
    Result = res;
    return Result;
  };
  this.EmojiString = function (s) {
    var Result = "";
    var ls = null;
    var i = 0;
    var v = "";
    var k = "";
    for (var $l = 1, $end = s.length; $l <= $end; $l++) {
      i = $l;
      if (s.charAt(i - 1) === "|") s = rtl.setCharAt(s,i - 1,"¦");
    };
    ls = pas.Classes.TStringList.$create("Create$1");
    ls.AddPair(":)","&#x1F600;");
    ls.AddPair(":D","&#x1F601;");
    ls.AddPair(";)","&#x1F609;");
    ls.AddPair(":O","&#x1F62E;");
    ls.AddPair(":*","&#x1F617;");
    ls.AddPair(":P","&#x1F61C;");
    ls.AddPair(":(","&#x1F641;");
    ls.AddPair(":¦","&#x1F610;");
    ls.AddPair(":X","&#x1F910;");
    ls.AddPair("¦;)","&#x1F60E;");
    ls.AddPair(":<","&#x1F621;");
    for (var $l1 = 0, $end1 = ls.GetCount() - 1; $l1 <= $end1; $l1++) {
      i = $l1;
      v = ls.GetName(i);
      k = ls.GetValue(v);
      s = pas.SysUtils.StringReplace(s,v,k,rtl.createSet(pas.SysUtils.TStringReplaceFlag.rfReplaceAll));
    };
    ls = rtl.freeLoc(ls);
    Result = s;
    return Result;
  };
  this.HTMLToString = function (s) {
    var Result = "";
    s = pas.SysUtils.StringReplace(s,"<","&lt;",rtl.createSet(pas.SysUtils.TStringReplaceFlag.rfReplaceAll));
    Result = pas.SysUtils.StringReplace(s,">","&gt;",rtl.createSet(pas.SysUtils.TStringReplaceFlag.rfReplaceAll));
    return Result;
  };
  this.FileSizeFmt = function (Size) {
    var Result = "";
    if (Size < 1000) Result = pas.SysUtils.IntToStr(Size) + " bytes";
    if ((Size >= 1000) && (Size < 1000000)) Result = pas.SysUtils.Format("%.2f",pas.System.VarRecs(3,Size / 1000)) + " Kb";
    if ((Size >= 1000000) && (Size < 1000000000)) Result = pas.SysUtils.Format("%.2f",pas.System.VarRecs(3,Size / 1000000)) + " Mb";
    if (Size >= 1000000000) Result = pas.SysUtils.Format("%.2f",pas.System.VarRecs(3,Size / 1000000000)) + " Gb";
    return Result;
  };
  this.FileSizeFmtSpeed = function (Size) {
    var Result = "";
    if (Size < 1000) Result = pas.SysUtils.IntToStr(Size) + " bytes/sec";
    if ((Size >= 1000) && (Size < 1000000)) Result = pas.SysUtils.Format("%.2f",pas.System.VarRecs(3,Size / 1000)) + " Kb/sec";
    if ((Size >= 1000000) && (Size < 1000000000)) Result = pas.SysUtils.Format("%.2f",pas.System.VarRecs(3,Size / 1000000)) + " Mb/sec";
    if (Size >= 1000000000) Result = pas.SysUtils.Format("%.2f",pas.System.VarRecs(3,Size / 1000000000)) + " Gb/sec";
    return Result;
  };
  this.ElementVisible = function (el) {
    var Result = false;
    var p = null;
    Result = false;
    p = el;
    while (p != null) {
      if (pas.SysUtils.LowerCase(p.tagName) === $mod.cBodyTag) Result = true;
      p = p.parentElement;
    };
    if (!Result) return Result;
    while (el != null) {
      if (el.style.getPropertyValue("display") === "none") {
        Result = false;
        return Result;
      };
      p = el.parentElement;
      if (!rtl.isExt(p,HTMLElement)) return Result;
      el = p;
    };
    return Result;
  };
  this.GetMaterialGlyph = function (AGlyph, ASize, AColor, AType) {
    var Result = "";
    var s = "";
    var matclr = "";
    var matsize = "";
    s = "<i";
    s = s + ' class="' + pas["WEBLib.Controls"].GetMaterialClass(AType) + '"';
    matclr = "";
    if (AColor !== -1) matclr = "color:" + pas["WEBLib.Graphics"].ColorToHTML(AColor) + ";";
    matsize = "";
    if (ASize !== 0) matsize = "font-size:" + pas.SysUtils.IntToStr(ASize) + "px;";
    s = s + ' style="pointer-events:none;' + matclr + matsize + '"';
    Result = s + ">" + AGlyph + "</i>";
    return Result;
  };
},["SysUtils","WEBLib.Utils"]);
rtl.module("contnrs",["System","SysUtils","Classes"],function () {
  "use strict";
  var $mod = this;
  var $impl = $mod.$impl;
  this.$rtti.$RefToProcVar("TObjectListCallback",{procsig: rtl.newTIProcSig([["data",pas.System.$rtti["TObject"]],["arg",rtl.jsvalue]])});
  rtl.createClass(this,"TFPObjectList",pas.System.TObject,function () {
    this.$init = function () {
      pas.System.TObject.$init.call(this);
      this.FFreeObjects = false;
      this.FList = null;
    };
    this.$final = function () {
      this.FList = undefined;
      pas.System.TObject.$final.call(this);
    };
    this.GetCount = function () {
      var Result = 0;
      Result = this.FList.FCount;
      return Result;
    };
    this.SetCount = function (AValue) {
      if (this.FList.FCount !== AValue) this.FList.SetCount(AValue);
    };
    this.GetItem = function (Index) {
      var Result = null;
      Result = rtl.getObject(this.FList.Get(Index));
      return Result;
    };
    this.SetItem = function (Index, AObject) {
      var O = null;
      if (this.FFreeObjects) {
        O = rtl.getObject(this.FList.Get(Index));
        this.FList.Put(Index,AObject);
        O = rtl.freeLoc(O);
      } else this.FList.Put(Index,AObject);
    };
    this.SetCapacity = function (NewCapacity) {
      this.FList.SetCapacity(NewCapacity);
    };
    this.GetCapacity = function () {
      var Result = 0;
      Result = this.FList.FCapacity;
      return Result;
    };
    this.Create$1 = function () {
      pas.System.TObject.Create.call(this);
      this.FList = pas.Classes.TFPList.$create("Create");
      this.FFreeObjects = true;
      return this;
    };
    this.Create$2 = function (FreeObjects) {
      this.Create$1();
      this.FFreeObjects = FreeObjects;
      return this;
    };
    this.Destroy = function () {
      if (this.FList !== null) {
        this.Clear();
        this.FList.$destroy("Destroy");
      };
      pas.System.TObject.Destroy.call(this);
    };
    this.Clear = function () {
      var i = 0;
      var O = null;
      if (this.FFreeObjects) for (var $l = this.FList.FCount - 1; $l >= 0; $l--) {
        i = $l;
        O = rtl.getObject(this.FList.Get(i));
        this.FList.Put(i,null);
        O = rtl.freeLoc(O);
      };
      this.FList.Clear();
    };
    this.Add = function (AObject) {
      var Result = 0;
      Result = this.FList.Add(AObject);
      return Result;
    };
    this.Delete = function (Index) {
      var O = null;
      if (this.FFreeObjects) {
        O = rtl.getObject(this.FList.Get(Index));
        this.FList.Put(Index,null);
        O = rtl.freeLoc(O);
      };
      this.FList.Delete(Index);
    };
    this.Exchange = function (Index1, Index2) {
      this.FList.Exchange(Index1,Index2);
    };
    this.Expand = function () {
      var Result = null;
      this.FList.Expand();
      Result = this;
      return Result;
    };
    this.Extract = function (Item) {
      var Result = null;
      Result = rtl.getObject(this.FList.Extract(Item));
      return Result;
    };
    this.Remove = function (AObject) {
      var Result = 0;
      var O = null;
      Result = this.IndexOf(AObject);
      if (Result !== -1) {
        if (this.FFreeObjects) {
          O = rtl.getObject(this.FList.Get(Result));
          this.FList.Put(Result,null);
          O = rtl.freeLoc(O);
        };
        this.FList.Delete(Result);
      };
      return Result;
    };
    this.IndexOf = function (AObject) {
      var Result = 0;
      Result = this.FList.IndexOf(AObject);
      return Result;
    };
    this.FindInstanceOf = function (AClass, AExact, AStartAt) {
      var Result = 0;
      var I = 0;
      I = AStartAt;
      Result = -1;
      if (AExact) {
        while ((I < this.GetCount()) && (Result === -1)) if (this.GetItem(I).$class.ClassType() === AClass) {
          Result = I}
         else I += 1}
       else while ((I < this.GetCount()) && (Result === -1)) if (this.GetItem(I).$class.InheritsFrom(AClass)) {
        Result = I}
       else I += 1;
      return Result;
    };
    this.Insert = function (Index, AObject) {
      this.FList.Insert(Index,AObject);
    };
    this.First = function () {
      var Result = null;
      Result = rtl.getObject(this.FList.First());
      return Result;
    };
    this.Last = function () {
      var Result = null;
      Result = rtl.getObject(this.FList.Last());
      return Result;
    };
    this.Move = function (CurIndex, NewIndex) {
      this.FList.Move(CurIndex,NewIndex);
    };
    this.Assign = function (Obj) {
      var i = 0;
      this.Clear();
      for (var $l = 0, $end = Obj.GetCount() - 1; $l <= $end; $l++) {
        i = $l;
        this.Add(Obj.GetItem(i));
      };
    };
    this.Pack = function () {
      this.FList.Pack();
    };
    this.Sort = function (Compare) {
      this.FList.Sort(Compare);
    };
    this.ForEachCall = function (proc2call, arg) {
      this.FList.ForEachCall(proc2call,arg);
    };
  });
  rtl.createClass(this,"TObjectList",pas.Classes.TList,function () {
    this.$init = function () {
      pas.Classes.TList.$init.call(this);
      this.FFreeObjects = false;
    };
    this.Notify = function (Ptr, Action) {
      var O = null;
      if (this.FFreeObjects) if (Action === pas.Classes.TListNotification.lnDeleted) {
        O = rtl.getObject(Ptr);
        O = rtl.freeLoc(O);
      };
      pas.Classes.TList.Notify.call(this,Ptr,Action);
    };
    this.GetItem = function (Index) {
      var Result = null;
      Result = rtl.getObject(pas.Classes.TList.Get.call(this,Index));
      return Result;
    };
    this.SetItem = function (Index, AObject) {
      this.Put(Index,AObject);
    };
    this.Create$2 = function () {
      pas.Classes.TList.Create$1.call(this);
      this.FFreeObjects = true;
      return this;
    };
    this.Create$3 = function (FreeObjects) {
      pas.Classes.TList.Create$1.call(this);
      this.FFreeObjects = FreeObjects;
      return this;
    };
    this.Add$1 = function (AObject) {
      var Result = 0;
      Result = pas.Classes.TList.Add.call(this,AObject);
      return Result;
    };
    this.Extract$1 = function (Item) {
      var Result = null;
      Result = rtl.getObject(pas.Classes.TList.Extract.call(this,Item));
      return Result;
    };
    this.Remove$1 = function (AObject) {
      var Result = 0;
      Result = pas.Classes.TList.Remove.call(this,AObject);
      return Result;
    };
    this.IndexOf$1 = function (AObject) {
      var Result = 0;
      Result = pas.Classes.TList.IndexOf.call(this,AObject);
      return Result;
    };
    this.FindInstanceOf = function (AClass, AExact, AStartAt) {
      var Result = 0;
      var I = 0;
      I = AStartAt;
      Result = -1;
      if (AExact) {
        while ((I < this.GetCount()) && (Result === -1)) if (this.GetItem(I).$class.ClassType() === AClass) {
          Result = I}
         else I += 1}
       else while ((I < this.GetCount()) && (Result === -1)) if (this.GetItem(I).$class.InheritsFrom(AClass)) {
        Result = I}
       else I += 1;
      return Result;
    };
    this.Insert$1 = function (Index, AObject) {
      pas.Classes.TList.Insert.call(this,Index,AObject);
    };
    this.First$1 = function () {
      var Result = null;
      Result = rtl.getObject(pas.Classes.TList.First.call(this));
      return Result;
    };
    this.Last$1 = function () {
      var Result = null;
      Result = rtl.getObject(pas.Classes.TList.Last.call(this));
      return Result;
    };
  });
  rtl.createClass(this,"TComponentList",this.TObjectList,function () {
    this.$init = function () {
      $mod.TObjectList.$init.call(this);
      this.FNotifier = null;
    };
    this.$final = function () {
      this.FNotifier = undefined;
      $mod.TObjectList.$final.call(this);
    };
    this.Notify = function (Ptr, Action) {
      if (this.FNotifier === null) {
        this.FNotifier = $impl.TlistComponent.$create("Create$1",[null]);
        this.FNotifier.Flist = this;
      };
      if (pas.System.Assigned(Ptr)) {
        var $with = rtl.getObject(Ptr);
        var $tmp = Action;
        if ($tmp === pas.Classes.TListNotification.lnAdded) {
          $with.FreeNotification(this.FNotifier)}
         else if (($tmp === pas.Classes.TListNotification.lnExtracted) || ($tmp === pas.Classes.TListNotification.lnDeleted)) $with.RemoveFreeNotification(this.FNotifier);
      };
      $mod.TObjectList.Notify.call(this,Ptr,Action);
    };
    this.GetItems = function (Index) {
      var Result = null;
      Result = this.GetItem(Index);
      return Result;
    };
    this.SetItems = function (Index, AComponent) {
      this.Put(Index,AComponent);
    };
    this.HandleFreeNotify = function (Sender, AComponent) {
      this.Extract$2(AComponent);
      if (Sender === null) ;
    };
    this.Destroy = function () {
      pas.Classes.TList.Destroy.call(this);
      pas.SysUtils.FreeAndNil({p: this, get: function () {
          return this.p.FNotifier;
        }, set: function (v) {
          this.p.FNotifier = v;
        }});
    };
    this.Add$2 = function (AComponent) {
      var Result = 0;
      Result = $mod.TObjectList.Add$1.call(this,AComponent);
      return Result;
    };
    this.Extract$2 = function (Item) {
      var Result = null;
      Result = $mod.TObjectList.Extract$1.call(this,Item);
      return Result;
    };
    this.Remove$2 = function (AComponent) {
      var Result = 0;
      Result = $mod.TObjectList.Remove$1.call(this,AComponent);
      return Result;
    };
    this.IndexOf$2 = function (AComponent) {
      var Result = 0;
      Result = $mod.TObjectList.IndexOf$1.call(this,AComponent);
      return Result;
    };
    this.First$2 = function () {
      var Result = null;
      Result = $mod.TObjectList.First$1.call(this);
      return Result;
    };
    this.Last$2 = function () {
      var Result = null;
      Result = $mod.TObjectList.Last$1.call(this);
      return Result;
    };
    this.Insert$2 = function (Index, AComponent) {
      $mod.TObjectList.Insert$1.call(this,Index,AComponent);
    };
  });
  rtl.createClass(this,"TClassList",pas.Classes.TList,function () {
    this.GetItems = function (Index) {
      var Result = null;
      Result = rtl.getObject(this.Get(Index));
      return Result;
    };
    this.SetItems = function (Index, AClass) {
      this.Put(Index,AClass);
    };
    this.Add$1 = function (AClass) {
      var Result = 0;
      Result = pas.Classes.TList.Add.call(this,AClass);
      return Result;
    };
    this.Extract$1 = function (Item) {
      var Result = null;
      Result = rtl.getObject(pas.Classes.TList.Extract.call(this,Item));
      return Result;
    };
    this.Remove$1 = function (AClass) {
      var Result = 0;
      Result = pas.Classes.TList.Remove.call(this,AClass);
      return Result;
    };
    this.IndexOf$1 = function (AClass) {
      var Result = 0;
      Result = pas.Classes.TList.IndexOf.call(this,AClass);
      return Result;
    };
    this.First$1 = function () {
      var Result = null;
      Result = rtl.getObject(pas.Classes.TList.First.call(this));
      return Result;
    };
    this.Last$1 = function () {
      var Result = null;
      Result = rtl.getObject(pas.Classes.TList.Last.call(this));
      return Result;
    };
    this.Insert$1 = function (Index, AClass) {
      pas.Classes.TList.Insert.call(this,Index,AClass);
    };
  });
  rtl.createClass(this,"TOrderedList",pas.System.TObject,function () {
    this.$init = function () {
      pas.System.TObject.$init.call(this);
      this.FList = null;
    };
    this.$final = function () {
      this.FList = undefined;
      pas.System.TObject.$final.call(this);
    };
    this.PopItem = function () {
      var Result = undefined;
      var $with = this.FList;
      if ($with.GetCount() > 0) {
        Result = $with.Get($with.GetCount() - 1);
        $with.Delete($with.GetCount() - 1);
      } else Result = null;
      return Result;
    };
    this.PeekItem = function () {
      var Result = undefined;
      var $with = this.FList;
      Result = $with.Get($with.GetCount() - 1);
      return Result;
    };
    this.Create$1 = function () {
      this.FList = pas.Classes.TList.$create("Create$1");
      return this;
    };
    this.Destroy = function () {
      rtl.free(this,"FList");
    };
    this.Count = function () {
      var Result = 0;
      Result = this.FList.GetCount();
      return Result;
    };
    this.AtLeast = function (ACount) {
      var Result = false;
      Result = this.FList.GetCount() >= ACount;
      return Result;
    };
    this.Push = function (AItem) {
      var Result = undefined;
      this.PushItem(AItem);
      Result = AItem;
      return Result;
    };
    this.Pop = function () {
      var Result = undefined;
      if (this.AtLeast(1)) {
        Result = this.PopItem()}
       else Result = null;
      return Result;
    };
    this.Peek = function () {
      var Result = undefined;
      if (this.AtLeast(1)) {
        Result = this.PeekItem()}
       else Result = null;
      return Result;
    };
  });
  rtl.createClass(this,"TStack",this.TOrderedList,function () {
    this.PushItem = function (AItem) {
      this.FList.Add(AItem);
    };
  });
  rtl.createClass(this,"TObjectStack",this.TStack,function () {
    this.Push$1 = function (AObject) {
      var Result = null;
      Result = rtl.getObject($mod.TOrderedList.Push.call(this,AObject));
      return Result;
    };
    this.Pop$1 = function () {
      var Result = null;
      Result = rtl.getObject($mod.TOrderedList.Pop.call(this));
      return Result;
    };
    this.Peek$1 = function () {
      var Result = null;
      Result = rtl.getObject($mod.TOrderedList.Peek.call(this));
      return Result;
    };
  });
  rtl.createClass(this,"TQueue",this.TOrderedList,function () {
    this.PushItem = function (AItem) {
      var $with = this.FList;
      $with.Insert(0,AItem);
    };
  });
  rtl.createClass(this,"TObjectQueue",this.TQueue,function () {
    this.Push$1 = function (AObject) {
      var Result = null;
      Result = rtl.getObject($mod.TOrderedList.Push.call(this,AObject));
      return Result;
    };
    this.Pop$1 = function () {
      var Result = null;
      Result = rtl.getObject($mod.TOrderedList.Pop.call(this));
      return Result;
    };
    this.Peek$1 = function () {
      var Result = null;
      Result = rtl.getObject($mod.TOrderedList.Peek.call(this));
      return Result;
    };
  });
  this.$rtti.$ProcVar("THashFunction",{procsig: rtl.newTIProcSig([["S",rtl.string,2],["TableSize",rtl.longword,2]],rtl.longword)});
  rtl.createClass(this,"THTCustomNode",pas.System.TObject,function () {
    this.$init = function () {
      pas.System.TObject.$init.call(this);
      this.FKey = "";
    };
    this.CreateWith = function (AString) {
      pas.System.TObject.Create.call(this);
      this.FKey = AString;
      return this;
    };
    this.HasKey = function (AKey) {
      var Result = false;
      Result = AKey === this.FKey;
      return Result;
    };
  });
  this.$rtti.$ClassRef("THTCustomNodeClass",{instancetype: this.$rtti["THTCustomNode"]});
  rtl.createClass(this,"TFPCustomHashTable",pas.System.TObject,function () {
    this.$init = function () {
      pas.System.TObject.$init.call(this);
      this.FHashTable = null;
      this.FHashFunction = null;
      this.FCount = 0;
      this.FHashTableSize = 0;
    };
    this.$final = function () {
      this.FHashTable = undefined;
      this.FHashFunction = undefined;
      pas.System.TObject.$final.call(this);
    };
    this.GetDensity = function () {
      var Result = 0;
      Result = this.FHashTableSize - this.GetVoidSlots();
      return Result;
    };
    this.GetNumberOfCollisions = function () {
      var Result = 0;
      Result = this.FCount - (this.FHashTableSize - this.GetVoidSlots());
      return Result;
    };
    this.SetHashTableSize = function (Value) {
      var i = 0;
      var newSize = 0;
      if (Value !== this.FHashTableSize) {
        i = 0;
        while (($impl.PRIMELIST[i] < Value) && (i < 27)) i += 1;
        newSize = $impl.PRIMELIST[i];
        if (this.FCount === 0) {
          this.FHashTableSize = newSize;
          this.InitializeHashTable();
        } else this.ChangeTableSize(newSize);
      };
    };
    this.InitializeHashTable = function () {
      var i = 0;
      if (this.FHashTableSize > 0) for (var $l = 0, $end = this.FHashTableSize - 1; $l <= $end; $l++) {
        i = $l;
        this.FHashTable.Add(null);
      };
      this.FCount = 0;
    };
    this.GetVoidSlots = function () {
      var Result = 0;
      var i = 0;
      var num = 0;
      num = 0;
      if (this.FHashTableSize > 0) for (var $l = 0, $end = this.FHashTableSize - 1; $l <= $end; $l++) {
        i = $l;
        if (!(this.Chain(i) != null)) num += 1;
      };
      Result = num;
      return Result;
    };
    this.GetLoadFactor = function () {
      var Result = 0.0;
      Result = this.FCount / this.FHashTableSize;
      return Result;
    };
    this.GetAVGChainLen = function () {
      var Result = 0.0;
      Result = this.FCount / (this.FHashTableSize - this.GetVoidSlots());
      return Result;
    };
    this.GetMaxChainLength = function () {
      var Result = 0;
      var i = 0;
      Result = 0;
      if (this.FHashTableSize > 0) for (var $l = 0, $end = this.FHashTableSize - 1; $l <= $end; $l++) {
        i = $l;
        if (this.ChainLength(i) > Result) Result = this.ChainLength(i);
      };
      return Result;
    };
    this.Chain = function (index) {
      var Result = null;
      Result = this.FHashTable.GetItem(index);
      return Result;
    };
    this.ChainLength = function (ChainIndex) {
      var Result = 0;
      if (this.Chain(ChainIndex) != null) {
        Result = this.Chain(ChainIndex).GetCount()}
       else Result = 0;
      return Result;
    };
    this.FindOrCreateNew = function (aKey) {
      var Result = null;
      var hashCode = 0;
      var chn = null;
      var i = 0;
      hashCode = this.FHashFunction(aKey,this.FHashTableSize);
      chn = this.Chain(hashCode);
      if (chn != null) {
        if (chn.GetCount() > 0) for (var $l = 0, $end = chn.GetCount() - 1; $l <= $end; $l++) {
          i = $l;
          if (chn.GetItem(i).FKey === aKey) return chn.GetItem(i);
        };
      } else {
        this.FHashTable.SetItem(hashCode,$mod.TFPObjectList.$create("Create$2",[true]));
        chn = this.Chain(hashCode);
      };
      this.FCount += 1;
      Result = this.CreateNewNode(aKey);
      chn.Add(Result);
      return Result;
    };
    this.SetHashFunction = function (AHashFunction) {
      if (this.IsEmpty()) {
        this.FHashFunction = AHashFunction}
       else throw pas.SysUtils.Exception.$create("Create$1",[rtl.getResStr($mod,"NotEmptyMsg")]);
    };
    this.FindChainForAdd = function (aKey) {
      var Result = null;
      var hashCode = 0;
      var i = 0;
      hashCode = this.FHashFunction(aKey,this.FHashTableSize);
      Result = this.Chain(hashCode);
      if (Result != null) {
        if (Result.GetCount() > 0) for (var $l = 0, $end = Result.GetCount() - 1; $l <= $end; $l++) {
          i = $l;
          if (Result.GetItem(i).FKey === aKey) throw $mod.EDuplicate.$create("CreateFmt",[rtl.getResStr($mod,"DuplicateMsg"),pas.System.VarRecs(18,aKey)]);
        };
      } else {
        this.FHashTable.SetItem(hashCode,$mod.TFPObjectList.$create("Create$2",[true]));
        Result = this.Chain(hashCode);
      };
      this.FCount += 1;
      return Result;
    };
    this.Create$1 = function () {
      this.CreateWith(196613,$mod.RSHash);
      return this;
    };
    this.CreateWith = function (AHashTableSize, aHashFunc) {
      pas.System.TObject.Create.call(this);
      this.FHashTable = $mod.TFPObjectList.$create("Create$2",[true]);
      this.SetHashTableSize(AHashTableSize);
      this.FHashFunction = aHashFunc;
      return this;
    };
    this.Destroy = function () {
      rtl.free(this,"FHashTable");
      pas.System.TObject.Destroy.call(this);
    };
    this.ChangeTableSize = function (ANewSize) {
      var SavedTable = null;
      var List = null;
      var SavedTableSize = 0;
      var i = 0;
      var j = 0;
      var temp = null;
      SavedTable = this.FHashTable;
      SavedTableSize = this.FHashTableSize;
      this.FHashTableSize = ANewSize;
      this.FHashTable = $mod.TFPObjectList.$create("Create$2",[true]);
      this.InitializeHashTable();
      if (SavedTableSize > 0) for (var $l = 0, $end = SavedTableSize - 1; $l <= $end; $l++) {
        i = $l;
        List = SavedTable.GetItem(i);
        if (List != null) for (var $l1 = 0, $end1 = List.GetCount() - 1; $l1 <= $end1; $l1++) {
          j = $l1;
          temp = List.GetItem(j);
          this.AddNode(temp);
        };
      };
      SavedTable = rtl.freeLoc(SavedTable);
    };
    this.Clear = function () {
      var i = 0;
      if (this.FHashTableSize > 0) for (var $l = 0, $end = this.FHashTableSize - 1; $l <= $end; $l++) {
        i = $l;
        if (this.Chain(i) != null) this.Chain(i).Clear();
      };
      this.FCount = 0;
    };
    this.Delete = function (aKey) {
      var hashCode = 0;
      var chn = null;
      var i = 0;
      hashCode = this.FHashFunction(aKey,this.FHashTableSize);
      chn = this.Chain(hashCode);
      if (chn != null) if (chn.GetCount() > 0) for (var $l = 0, $end = chn.GetCount() - 1; $l <= $end; $l++) {
        i = $l;
        if (chn.GetItem(i).FKey === aKey) {
          chn.Delete(i);
          this.FCount -= 1;
          return;
        };
      };
    };
    this.Find = function (aKey) {
      var Result = null;
      var hashCode = 0;
      var chn = null;
      var i = 0;
      hashCode = this.FHashFunction(aKey,this.FHashTableSize);
      chn = this.Chain(hashCode);
      if (chn != null) if (chn.GetCount() > 0) for (var $l = 0, $end = chn.GetCount() - 1; $l <= $end; $l++) {
        i = $l;
        if (chn.GetItem(i).FKey === aKey) return chn.GetItem(i);
      };
      Result = null;
      return Result;
    };
    this.IsEmpty = function () {
      var Result = false;
      Result = this.FCount === 0;
      return Result;
    };
  });
  rtl.createClass(this,"THTDataNode",this.THTCustomNode,function () {
    this.$init = function () {
      $mod.THTCustomNode.$init.call(this);
      this.FData = undefined;
    };
  });
  this.$rtti.$MethodVar("TDataIteratorMethod",{procsig: rtl.newTIProcSig([["Item",rtl.jsvalue],["Key",rtl.string,2],["Continue",rtl.boolean,1]]), methodkind: 0});
  this.$rtti.$ProcVar("TDataIteratorCallBack",{procsig: rtl.newTIProcSig([["Item",rtl.jsvalue],["Key",rtl.string,2],["Continue",rtl.boolean,1]])});
  rtl.createClass(this,"TFPDataHashTable",this.TFPCustomHashTable,function () {
    this.$init = function () {
      $mod.TFPCustomHashTable.$init.call(this);
      this.FIteratorCallBack = null;
    };
    this.$final = function () {
      this.FIteratorCallBack = undefined;
      $mod.TFPCustomHashTable.$final.call(this);
    };
    this.CallbackIterator = function (Item, Key, Continue) {
      this.FIteratorCallBack(Item,Key,Continue);
    };
    this.CreateNewNode = function (aKey) {
      var Result = null;
      Result = $mod.THTDataNode.$create("CreateWith",[aKey]);
      return Result;
    };
    this.AddNode = function (ANode) {
      this.Add(ANode.FKey,ANode.FData);
    };
    this.SetData = function (index, AValue) {
      this.FindOrCreateNew(index).FData = AValue;
    };
    this.GetData = function (index) {
      var Result = undefined;
      var node = null;
      node = this.Find(index);
      if (node != null) {
        Result = node.FData}
       else Result = null;
      return Result;
    };
    this.ForEachCall = function (aMethod) {
      var Result = null;
      var i = 0;
      var j = 0;
      var continue_ = false;
      Result = null;
      continue_ = true;
      if (this.FHashTableSize > 0) for (var $l = 0, $end = this.FHashTableSize - 1; $l <= $end; $l++) {
        i = $l;
        if (this.Chain(i) != null) if (this.Chain(i).GetCount() > 0) for (var $l1 = 0, $end1 = this.Chain(i).GetCount() - 1; $l1 <= $end1; $l1++) {
          j = $l1;
          aMethod(this.Chain(i).GetItem(j).FData,this.Chain(i).GetItem(j).FKey,{get: function () {
              return continue_;
            }, set: function (v) {
              continue_ = v;
            }});
          if (!continue_) {
            Result = this.Chain(i).GetItem(j);
            return Result;
          };
        };
      };
      return Result;
    };
    this.Iterate = function (aMethod) {
      var Result = undefined;
      var N = null;
      N = this.ForEachCall(aMethod);
      if (N != null) {
        Result = N.FData}
       else Result = null;
      return Result;
    };
    this.Iterate$1 = function (aMethod) {
      var Result = undefined;
      this.FIteratorCallBack = aMethod;
      Result = this.Iterate(rtl.createCallback(this,"CallbackIterator"));
      return Result;
    };
    this.Add = function (aKey, AItem) {
      var chn = null;
      var NewNode = null;
      chn = this.FindChainForAdd(aKey);
      NewNode = this.CreateNewNode(aKey);
      NewNode.FData = AItem;
      chn.Add(NewNode);
    };
  });
  rtl.createClass(this,"THTStringNode",this.THTCustomNode,function () {
    this.$init = function () {
      $mod.THTCustomNode.$init.call(this);
      this.FData = "";
    };
  });
  this.$rtti.$MethodVar("TStringIteratorMethod",{procsig: rtl.newTIProcSig([["Item",rtl.string],["Key",rtl.string,2],["Continue",rtl.boolean,1]]), methodkind: 0});
  this.$rtti.$ProcVar("TStringIteratorCallback",{procsig: rtl.newTIProcSig([["Item",rtl.string],["Key",rtl.string,2],["Continue",rtl.boolean,1]])});
  rtl.createClass(this,"TFPStringHashTable",this.TFPCustomHashTable,function () {
    this.$init = function () {
      $mod.TFPCustomHashTable.$init.call(this);
      this.FIteratorCallBack = null;
    };
    this.$final = function () {
      this.FIteratorCallBack = undefined;
      $mod.TFPCustomHashTable.$final.call(this);
    };
    this.CallbackIterator = function (Item, Key, Continue) {
      this.FIteratorCallBack(Item,Key,Continue);
    };
    this.CreateNewNode = function (aKey) {
      var Result = null;
      Result = $mod.THTStringNode.$create("CreateWith",[aKey]);
      return Result;
    };
    this.AddNode = function (ANode) {
      this.Add(ANode.FKey,ANode.FData);
    };
    this.SetData = function (Index, AValue) {
      this.FindOrCreateNew(Index).FData = AValue;
    };
    this.GetData = function (index) {
      var Result = "";
      var node = null;
      node = this.Find(index);
      if (node != null) {
        Result = node.FData}
       else Result = "";
      return Result;
    };
    this.ForEachCall = function (aMethod) {
      var Result = null;
      var i = 0;
      var j = 0;
      var continue_ = false;
      Result = null;
      continue_ = true;
      if (this.FHashTableSize > 0) for (var $l = 0, $end = this.FHashTableSize - 1; $l <= $end; $l++) {
        i = $l;
        if (this.Chain(i) != null) if (this.Chain(i).GetCount() > 0) for (var $l1 = 0, $end1 = this.Chain(i).GetCount() - 1; $l1 <= $end1; $l1++) {
          j = $l1;
          aMethod(this.Chain(i).GetItem(j).FData,this.Chain(i).GetItem(j).FKey,{get: function () {
              return continue_;
            }, set: function (v) {
              continue_ = v;
            }});
          if (!continue_) {
            Result = this.Chain(i).GetItem(j);
            return Result;
          };
        };
      };
      return Result;
    };
    this.Iterate = function (aMethod) {
      var Result = "";
      var N = null;
      N = this.ForEachCall(aMethod);
      if (N != null) {
        Result = N.FData}
       else Result = "";
      return Result;
    };
    this.Iterate$1 = function (aMethod) {
      var Result = "";
      this.FIteratorCallBack = aMethod;
      Result = this.Iterate(rtl.createCallback(this,"CallbackIterator"));
      return Result;
    };
    this.Add = function (aKey, aItem) {
      var chn = null;
      var NewNode = null;
      chn = this.FindChainForAdd(aKey);
      NewNode = this.CreateNewNode(aKey);
      NewNode.FData = aItem;
      chn.Add(NewNode);
    };
  });
  rtl.createClass(this,"THTObjectNode",this.THTCustomNode,function () {
    this.$init = function () {
      $mod.THTCustomNode.$init.call(this);
      this.FData = null;
    };
    this.$final = function () {
      this.FData = undefined;
      $mod.THTCustomNode.$final.call(this);
    };
  });
  rtl.createClass(this,"THTOwnedObjectNode",this.THTObjectNode,function () {
    this.Destroy = function () {
      pas.SysUtils.FreeAndNil({p: this, get: function () {
          return this.p.FData;
        }, set: function (v) {
          this.p.FData = v;
        }});
      pas.System.TObject.Destroy.call(this);
    };
  });
  this.$rtti.$MethodVar("TObjectIteratorMethod",{procsig: rtl.newTIProcSig([["Item",pas.System.$rtti["TObject"]],["Key",rtl.string,2],["Continue",rtl.boolean,1]]), methodkind: 0});
  this.$rtti.$ProcVar("TObjectIteratorCallback",{procsig: rtl.newTIProcSig([["Item",pas.System.$rtti["TObject"]],["Key",rtl.string,2],["Continue",rtl.boolean,1]])});
  rtl.createClass(this,"TFPObjectHashTable",this.TFPCustomHashTable,function () {
    this.$init = function () {
      $mod.TFPCustomHashTable.$init.call(this);
      this.FOwnsObjects = false;
      this.FIteratorCallBack = null;
    };
    this.$final = function () {
      this.FIteratorCallBack = undefined;
      $mod.TFPCustomHashTable.$final.call(this);
    };
    this.CallbackIterator = function (Item, Key, Continue) {
      this.FIteratorCallBack(Item,Key,Continue);
    };
    this.CreateNewNode = function (aKey) {
      var Result = null;
      if (this.FOwnsObjects) {
        Result = $mod.THTOwnedObjectNode.$create("CreateWith",[aKey])}
       else Result = $mod.THTObjectNode.$create("CreateWith",[aKey]);
      return Result;
    };
    this.AddNode = function (ANode) {
      this.Add(ANode.FKey,ANode.FData);
    };
    this.SetData = function (Index, AObject) {
      this.FindOrCreateNew(Index).FData = AObject;
    };
    this.GetData = function (index) {
      var Result = null;
      var node = null;
      node = this.Find(index);
      if (node != null) {
        Result = node.FData}
       else Result = null;
      return Result;
    };
    this.ForEachCall = function (aMethod) {
      var Result = null;
      var i = 0;
      var j = 0;
      var continue_ = false;
      Result = null;
      continue_ = true;
      if (this.FHashTableSize > 0) for (var $l = 0, $end = this.FHashTableSize - 1; $l <= $end; $l++) {
        i = $l;
        if (this.Chain(i) != null) if (this.Chain(i).GetCount() > 0) for (var $l1 = 0, $end1 = this.Chain(i).GetCount() - 1; $l1 <= $end1; $l1++) {
          j = $l1;
          aMethod(this.Chain(i).GetItem(j).FData,this.Chain(i).GetItem(j).FKey,{get: function () {
              return continue_;
            }, set: function (v) {
              continue_ = v;
            }});
          if (!continue_) {
            Result = this.Chain(i).GetItem(j);
            return Result;
          };
        };
      };
      return Result;
    };
    this.Create$2 = function (AOwnsObjects) {
      $mod.TFPCustomHashTable.Create$1.call(this);
      this.FOwnsObjects = AOwnsObjects;
      return this;
    };
    this.CreateWith$1 = function (AHashTableSize, aHashFunc, AOwnsObjects) {
      $mod.TFPCustomHashTable.CreateWith.call(this,AHashTableSize,aHashFunc);
      this.FOwnsObjects = AOwnsObjects;
      return this;
    };
    this.Iterate = function (aMethod) {
      var Result = null;
      var N = null;
      N = this.ForEachCall(aMethod);
      if (N != null) {
        Result = N.FData}
       else Result = null;
      return Result;
    };
    this.Iterate$1 = function (aMethod) {
      var Result = null;
      this.FIteratorCallBack = aMethod;
      Result = this.Iterate(rtl.createCallback(this,"CallbackIterator"));
      return Result;
    };
    this.Add = function (aKey, AItem) {
      var chn = null;
      var NewNode = null;
      chn = this.FindChainForAdd(aKey);
      NewNode = this.CreateNewNode(aKey);
      NewNode.FData = AItem;
      chn.Add(NewNode);
    };
  });
  rtl.createClass(this,"EDuplicate",pas.SysUtils.Exception,function () {
  });
  rtl.createClass(this,"EKeyNotFound",pas.SysUtils.Exception,function () {
  });
  var b = 378551;
  this.RSHash = function (S, TableSize) {
    var Result = 0;
    var a = 0;
    var i = 0;
    a = 63689;
    Result = 0;
    if (S.length > 0) for (var $l = 1, $end = S.length; $l <= $end; $l++) {
      i = $l;
      Result = (Result * a) + S.charCodeAt(i - 1);
      a = a * 378551;
    };
    Result = rtl.lw(Result & 0x7FFFFFFF) % TableSize;
    return Result;
  };
  rtl.recNewT(this,"TBucketItem",function () {
    this.Item = undefined;
    this.Data = undefined;
    this.$eq = function (b) {
      return (this.Item === b.Item) && (this.Data === b.Data);
    };
    this.$assign = function (s) {
      this.Item = s.Item;
      this.Data = s.Data;
      return this;
    };
    var $r = $mod.$rtti.$Record("TBucketItem",{});
    $r.addField("Item",rtl.jsvalue);
    $r.addField("Data",rtl.jsvalue);
  });
  this.$rtti.$DynArray("TBucketItemArray",{eltype: this.$rtti["TBucketItem"]});
  rtl.recNewT(this,"TBucket",function () {
    this.Count = 0;
    this.$new = function () {
      var r = Object.create(this);
      r.Items = [];
      return r;
    };
    this.$eq = function (b) {
      return (this.Count === b.Count) && (this.Items === b.Items);
    };
    this.$assign = function (s) {
      this.Count = s.Count;
      this.Items = rtl.arrayRef(s.Items);
      return this;
    };
    var $r = $mod.$rtti.$Record("TBucket",{});
    $r.addField("Count",rtl.longint);
    $r.addField("Items",$mod.$rtti["TBucketItemArray"]);
  });
  this.$rtti.$DynArray("TBucketArray",{eltype: this.$rtti["TBucket"]});
  this.$rtti.$RefToProcVar("TBucketProc",{procsig: rtl.newTIProcSig([["AInfo",rtl.jsvalue],["AItem",rtl.jsvalue],["AData",rtl.jsvalue],["AContinue",rtl.boolean,4]])});
  rtl.createClass(this,"TCustomBucketList",pas.System.TObject,function () {
    this.$init = function () {
      pas.System.TObject.$init.call(this);
      this.FBuckets = [];
    };
    this.$final = function () {
      this.FBuckets = undefined;
      pas.System.TObject.$final.call(this);
    };
    this.GetBucketCount = function () {
      var Result = 0;
      Result = rtl.length(this.FBuckets);
      return Result;
    };
    this.GetData = function (AItem) {
      var Result = undefined;
      var B = 0;
      var I = 0;
      this.GetBucketItem(AItem,{get: function () {
          return B;
        }, set: function (v) {
          B = v;
        }},{get: function () {
          return I;
        }, set: function (v) {
          I = v;
        }});
      Result = this.FBuckets[B].Items[I].Data;
      return Result;
    };
    this.SetData = function (AItem, AData) {
      var B = 0;
      var I = 0;
      this.GetBucketItem(AItem,{get: function () {
          return B;
        }, set: function (v) {
          B = v;
        }},{get: function () {
          return I;
        }, set: function (v) {
          I = v;
        }});
      this.FBuckets[B].Items[I].Data = AData;
    };
    this.SetBucketCount = function (Value) {
      if (Value !== this.GetBucketCount()) this.FBuckets = rtl.arraySetLength(this.FBuckets,$mod.TBucket,Value);
    };
    this.GetBucketItem = function (AItem, ABucket, AIndex) {
      if (!this.FindItem(AItem,ABucket,AIndex)) this.Error(rtl.getResStr($mod,"SErrNoSuchItem"),pas.System.VarRecs(20,AItem));
    };
    this.AddItem = function (ABucket, AItem, AData) {
      var Result = undefined;
      var L = 0;
      L = rtl.length(this.FBuckets[ABucket].Items);
      if (this.FBuckets[ABucket].Count === L) {
        if (L < 8) {
          L = 8}
         else L = L + rtl.trunc(L / 2);
        this.FBuckets[ABucket].Items = rtl.arraySetLength(this.FBuckets[ABucket].Items,$mod.TBucketItem,L);
      };
      var $with = this.FBuckets[ABucket];
      $with.Items[$with.Count].Item = AItem;
      $with.Items[$with.Count].Data = AData;
      Result = AData;
      $with.Count += 1;
      return Result;
    };
    this.DeleteItem = function (ABucket, AIndex) {
      var Result = undefined;
      var I = 0;
      var L = 0;
      Result = this.FBuckets[ABucket].Items[AIndex].Data;
      if (this.FBuckets[ABucket].Count === 1) {
        this.FBuckets[ABucket].Items = rtl.arraySetLength(this.FBuckets[ABucket].Items,$mod.TBucketItem,0)}
       else {
        L = this.FBuckets[ABucket].Count - AIndex - 1;
        for (var $l = 0, $end = L - 1; $l <= $end; $l++) {
          I = $l;
          this.FBuckets[ABucket].Items[AIndex + I].$assign(this.FBuckets[ABucket].Items[AIndex + I + 1]);
        };
      };
      this.FBuckets[ABucket].Count -= 1;
      return Result;
    };
    this.Error = function (Msg, Args) {
      throw pas.Classes.EListError.$create("CreateFmt",[Msg,Args]);
    };
    this.FindItem = function (AItem, ABucket, AIndex) {
      var Result = false;
      var I = 0;
      var B = $mod.TBucket.$new();
      ABucket.set(this.BucketFor(AItem));
      B.$assign(this.FBuckets[ABucket.get()]);
      I = B.Count - 1;
      while ((I >= 0) && (B.Items[I].Item != AItem)) I -= 1;
      Result = I >= 0;
      if (Result) AIndex.set(I);
      return Result;
    };
    this.Destroy = function () {
      this.Clear();
      pas.System.TObject.Destroy.call(this);
    };
    this.Clear = function () {
      var B = $mod.TBucket.$new();
      var I = 0;
      var J = 0;
      for (var $l = 0, $end = rtl.length(this.FBuckets) - 1; $l <= $end; $l++) {
        I = $l;
        B.$assign(this.FBuckets[I]);
        for (var $l1 = B.Count - 1; $l1 >= 0; $l1--) {
          J = $l1;
          this.DeleteItem(I,J);
        };
      };
      this.FBuckets = rtl.arraySetLength(this.FBuckets,$mod.TBucket,0);
    };
    this.Add = function (AItem, AData) {
      var Result = undefined;
      var B = 0;
      var I = 0;
      if (this.FindItem(AItem,{get: function () {
          return B;
        }, set: function (v) {
          B = v;
        }},{get: function () {
          return I;
        }, set: function (v) {
          I = v;
        }})) this.Error(rtl.getResStr($mod,"SDuplicateItem"),pas.System.VarRecs(20,AItem));
      Result = this.AddItem(B,AItem,AData);
      return Result;
    };
    this.Assign = function (AList) {
      var I = 0;
      var J = 0;
      this.Clear();
      this.FBuckets = rtl.arraySetLength(this.FBuckets,$mod.TBucket,rtl.length(AList.FBuckets));
      for (var $l = 0, $end = this.GetBucketCount() - 1; $l <= $end; $l++) {
        I = $l;
        this.FBuckets[I].Items = rtl.arraySetLength(this.FBuckets[I].Items,$mod.TBucketItem,rtl.length(AList.FBuckets[I].Items));
        for (var $l1 = 0, $end1 = AList.FBuckets[I].Count - 1; $l1 <= $end1; $l1++) {
          J = $l1;
          var $with = AList.FBuckets[I].Items[J];
          this.AddItem(I,$with.Item,$with.Data);
        };
      };
    };
    this.Exists = function (AItem) {
      var Result = false;
      var B = 0;
      var I = 0;
      Result = this.FindItem(AItem,{get: function () {
          return B;
        }, set: function (v) {
          B = v;
        }},{get: function () {
          return I;
        }, set: function (v) {
          I = v;
        }});
      return Result;
    };
    this.Find = function (AItem, AData) {
      var Result = false;
      var B = 0;
      var I = 0;
      Result = this.FindItem(AItem,{get: function () {
          return B;
        }, set: function (v) {
          B = v;
        }},{get: function () {
          return I;
        }, set: function (v) {
          I = v;
        }});
      if (Result) AData.set(this.FBuckets[B].Items[I].Data);
      return Result;
    };
    this.ForEach = function (AProc, AInfo) {
      var Result = false;
      var I = 0;
      var J = 0;
      var S = 0;
      var Bu = $mod.TBucket.$new();
      I = 0;
      Result = true;
      S = this.GetBucketCount();
      while (Result && (I < S)) {
        J = 0;
        Bu.$assign(this.FBuckets[I]);
        while (Result && (J < Bu.Count)) {
          var $with = Bu.Items[J];
          AProc(AInfo,$with.Item,$with.Data,{get: function () {
              return Result;
            }, set: function (v) {
              Result = v;
            }});
          J += 1;
        };
        I += 1;
      };
      return Result;
    };
    this.ForEach$1 = function (AProc) {
      var Result = false;
      Result = this.ForEach(AProc,null);
      return Result;
    };
    this.Remove = function (AItem) {
      var Result = undefined;
      var B = 0;
      var I = 0;
      if (this.FindItem(AItem,{get: function () {
          return B;
        }, set: function (v) {
          B = v;
        }},{get: function () {
          return I;
        }, set: function (v) {
          I = v;
        }})) {
        Result = this.FBuckets[B].Items[I].Data;
        this.DeleteItem(B,I);
      } else Result = null;
      return Result;
    };
  });
  this.TBucketListSizes = {"0": "bl2", bl2: 0, "1": "bl4", bl4: 1, "2": "bl8", bl8: 2, "3": "bl16", bl16: 3, "4": "bl32", bl32: 4, "5": "bl64", bl64: 5, "6": "bl128", bl128: 6, "7": "bl256", bl256: 7};
  this.$rtti.$Enum("TBucketListSizes",{minvalue: 0, maxvalue: 7, ordtype: 1, enumtype: this.TBucketListSizes});
  rtl.createClass(this,"TBucketList",this.TCustomBucketList,function () {
    this.$init = function () {
      $mod.TCustomBucketList.$init.call(this);
      this.FBucketMask = 0;
    };
    this.BucketFor = function (AItem) {
      var Result = 0;
      Result = rtl.lw(rtl.lw(rtl.trunc(AItem) >>> 2) & this.FBucketMask);
      return Result;
    };
    this.Create$1 = function (ABuckets) {
      var L = 0;
      pas.System.TObject.Create.call(this);
      L = 1 << (ABuckets + 1);
      this.SetBucketCount(L);
      this.FBucketMask = L - 1;
      return this;
    };
  });
  rtl.createClass(this,"TObjectBucketList",this.TBucketList,function () {
    this.GetData$1 = function (AItem) {
      var Result = null;
      Result = rtl.getObject($mod.TCustomBucketList.GetData.call(this,AItem));
      return Result;
    };
    this.SetData$1 = function (AItem, AData) {
      $mod.TCustomBucketList.SetData.call(this,AItem,AData);
    };
    this.Add$1 = function (AItem, AData) {
      var Result = null;
      Result = rtl.getObject($mod.TCustomBucketList.Add.call(this,AItem,AData));
      return Result;
    };
    this.Remove$1 = function (AItem) {
      var Result = null;
      Result = rtl.getObject($mod.TCustomBucketList.Remove.call(this,AItem));
      return Result;
    };
  });
  $mod.$implcode = function () {
    $impl.NPRIMES = 28;
    $mod.$rtti.$StaticArray("PRIMELIST$a",{dims: [28], eltype: rtl.longword});
    $impl.PRIMELIST = [53,97,193,389,769,1543,3079,6151,12289,24593,49157,98317,196613,393241,786433,1572869,3145739,6291469,12582917,25165843,50331653,100663319,201326611,402653189,805306457,1610612741,3221225473,4294967291];
    rtl.createClass($impl,"TlistComponent",pas.Classes.TComponent,function () {
      this.$init = function () {
        pas.Classes.TComponent.$init.call(this);
        this.Flist = null;
      };
      this.$final = function () {
        this.Flist = undefined;
        pas.Classes.TComponent.$final.call(this);
      };
      this.Notification = function (AComponent, Operation) {
        if (Operation === pas.Classes.TOperation.opRemove) this.Flist.HandleFreeNotify(this,AComponent);
        pas.Classes.TComponent.Notification.apply(this,arguments);
      };
      rtl.addIntf(this,pas.System.IUnknown);
    });
    $mod.$resourcestrings = {DuplicateMsg: {org: "An item with key %0:s already exists"}, NotEmptyMsg: {org: "Hash table not empty."}, SErrNoSuchItem: {org: "No item in list for %p"}, SDuplicateItem: {org: "Item already exists in list: %p"}};
  };
},["JS"]);
rtl.module("WEBLib.Graphics",["System","Classes","Types","UITypes","Web","JS"],function () {
  "use strict";
  var $mod = this;
  var $impl = $mod.$impl;
  this.WEBDEFAULTFONT = "Arial";
  this.SysDefault = 0x20000000;
  this.clNone = -1;
  this.clBlack = 0x0;
  this.clMaroon = 0x80;
  this.clGreen = 0x8000;
  this.clOlive = 0x8080;
  this.clNavy = 0x800000;
  this.clPurple = 0x800080;
  this.clTeal = 0x808000;
  this.clGray = 0x808080;
  this.clSilver = 0xC0C0C0;
  this.clRed = 0xFF;
  this.clLime = 0xFF00;
  this.clYellow = 0xFFFF;
  this.clBlue = 0xFF0000;
  this.clFuchsia = 0xFF00FF;
  this.clAqua = 0xFFFF00;
  this.clLtGray = 0xC1C1C1;
  this.clDkGray = 0x818181;
  this.clWhite = 0xFFFFFF;
  this.clMoneyGreen = 0xC0DCC0;
  this.clSkyBlue = 0xF0CAA6;
  this.clCream = 0xF0FBFF;
  this.clMedGray = 0xA0A0A0;
  this.clDefault = 536870912;
  this.clBtnFace = 0xF0F0F0;
  this.clWindowText = 0x10101;
  this.clWindow = 0xFEFEFE;
  this.clHighlight = 0xD77800;
  this.clHighlightText = 0x30303;
  this.clInfoText = 0x20202;
  this.clInfoBk = 0xE1FFFF;
  this.clActiveCaption = 0xD1B499;
  this.clInactiveCaption = 0xDBCDBF;
  this.clInactiveCaptionText = 0x0;
  this.clHotLight = 0xCC6600;
  this.clScrollBar = 0xC8C8C8;
  this.clBackground = 15790320;
  this.clMenu = 15790320;
  this.clWindowFrame = 0x646464;
  this.clMenuText = 0;
  this.clCaptionText = 16777215;
  this.clActiveBorder = 0xB4B4B4;
  this.clAppWorkSpace = 0xABABAB;
  this.clBtnShadow = 0xA0A0A0;
  this.clGrayText = 0x6D6D6D;
  this.clBtnText = 0;
  this.clBtnHighlight = 16777215;
  this.cl3DDkShadow = 0x696969;
  this.cl3DLight = 0xE3E3E3;
  this.clMenuHighlight = 0xD77800;
  this.clMenuBar = 0xF0F0F0;
  this.clWebAliceblue = 0xFFF8F0;
  this.clWebAntiquewhite = 0xD7EBFA;
  this.clWebAqua = 0xFFFF00;
  this.clWebAquamarine = 0xD4FF7F;
  this.clWebAzure = 0xFFFFF0;
  this.clWebBeige = 0xDCF5F5;
  this.clWebBisque = 0xC4E4FF;
  this.clWebBlack = 0x0;
  this.clWebBlanchedalmond = 0xCDEBFF;
  this.clWebBlue = 0xFF0000;
  this.clWebBlueviolet = 0xE22B8A;
  this.clWebBrown = 0x2A2AA5;
  this.clWebBurlywood = 0x87B8DE;
  this.clWebCadetblue = 0xA09E5F;
  this.clWebChartreuse = 0xFF7F;
  this.clWebChocolate = 0x1E69D2;
  this.clWebCoral = 0x507FFF;
  this.clWebCornflowerblue = 0xED9564;
  this.clWebCornsilk = 0xDCF8FF;
  this.clWebCrimson = 0x3C14DC;
  this.clWebCyan = 0xFFFF00;
  this.clWebDarkblue = 0x8B0000;
  this.clWebDarkcyan = 0x8B8B00;
  this.clWebDarkgoldenrod = 0xB86B8;
  this.clWebDarkgray = 0xA9A9A9;
  this.clWebDarkgreen = 0x6400;
  this.clWebDarkgrey = 0xA9A9A9;
  this.clWebDarkkhaki = 0x6BB7BD;
  this.clWebDarkmagenta = 0x8B008B;
  this.clWebDarkolivegreen = 0x2F6B55;
  this.clWebDarkorange = 0x8CFF;
  this.clWebDarkorchid = 0xCC3299;
  this.clWebDarkred = 0x8B;
  this.clWebDarksalmon = 0x7A96E9;
  this.clWebDarkseagreen = 0x8FBC8F;
  this.clWebDarkslateblue = 0x8B3D48;
  this.clWebDarkslategray = 0x4F4F2F;
  this.clWebDarkslategrey = 0x4F4F2F;
  this.clWebDarkturquoise = 0xD1CE00;
  this.clWebDarkviolet = 0xD30094;
  this.clWebDeeppink = 0x9314FF;
  this.clWebDeepskyblue = 0xFFBF00;
  this.clWebDimgray = 0x696969;
  this.clWebDimgrey = 0x696969;
  this.clWebDodgerblue = 0xFF901E;
  this.clWebFirebrick = 0x2222B2;
  this.clWebFloralwhite = 0xF0FAFF;
  this.clWebForestgreen = 0x228B22;
  this.clWebFuchsia = 0xFF00FF;
  this.clWebGainsboro = 0xDCDCDC;
  this.clWebGhostwhite = 0xFFF8F8;
  this.clWebGold = 0xD7FF;
  this.clWebGoldenrod = 0x20A5DA;
  this.clWebGray = 0x808080;
  this.clWebGreen = 0x8000;
  this.clWebGreenyellow = 0x2FFFAD;
  this.clWebGrey = 0x808080;
  this.clWebHoneydew = 0xF0FFF0;
  this.clWebHotpink = 0xB469FF;
  this.clWebIndianred = 0x5C5CCD;
  this.clWebIndigo = 0x82004B;
  this.clWebIvory = 0xF0FFFF;
  this.clWebKhaki = 0x8CE6F0;
  this.clWebLavender = 0xFAE6E6;
  this.clWebLavenderblush = 0xF5F0FF;
  this.clWebLawngreen = 0xFC7C;
  this.clWebLemonchiffon = 0xCDFAFF;
  this.clWebLightblue = 0xE6D8AD;
  this.clWebLightcoral = 0x8080F0;
  this.clWebLightcyan = 0xFFFFE0;
  this.clWebLightgoldenrodyellow = 0xD2FAFA;
  this.clWebLightgray = 0xD3D3D3;
  this.clWebLightgreen = 0x90EE90;
  this.clWebLightgrey = 0xD3D3D3;
  this.clWebLightpink = 0xC1B6FF;
  this.clWebLightsalmon = 0x7AA0FF;
  this.clWebLightseagreen = 0xAAB220;
  this.clWebLightskyblue = 0xFACE87;
  this.clWebLightslategray = 0x998877;
  this.clWebLightslategrey = 0x998877;
  this.clWebLightsteelblue = 0xDEC4B0;
  this.clWebLightyellow = 0xE0FFFF;
  this.clWebLtGray = 0xC0C0C0;
  this.clWebMedGray = 0xA4A0A0;
  this.clWebDkGray = 0x808080;
  this.clWebMoneyGreen = 0xC0DCC0;
  this.clWebLegacySkyBlue = 0xF0CAA6;
  this.clWebCream = 0xF0FBFF;
  this.clWebLime = 0xFF00;
  this.clWebLimegreen = 0x32CD32;
  this.clWebLinen = 0xE6F0FA;
  this.clWebMagenta = 0xFF00FF;
  this.clWebMaroon = 0x80;
  this.clWebMediumaquamarine = 0xAACD66;
  this.clWebMediumblue = 0xCD0000;
  this.clWebMediumorchid = 0xD355BA;
  this.clWebMediumpurple = 0xDB7093;
  this.clWebMediumseagreen = 0x71B33C;
  this.clWebMediumslateblue = 0xEE687B;
  this.clWebMediumspringgreen = 0x9AFA00;
  this.clWebMediumturquoise = 0xCCD148;
  this.clWebMediumvioletred = 0x8515C7;
  this.clWebMidnightblue = 0x701919;
  this.clWebMintcream = 0xFAFFF5;
  this.clWebMistyrose = 0xE1E4FF;
  this.clWebMoccasin = 0xB5E4FF;
  this.clWebNavajowhite = 0xADDEFF;
  this.clWebNavy = 0x800000;
  this.clWebOldlace = 0xE6F5FD;
  this.clWebOlive = 0x8080;
  this.clWebOlivedrab = 0x238E6B;
  this.clWebOrange = 0xA5FF;
  this.clWebOrangered = 0x45FF;
  this.clWebOrchid = 0xD670DA;
  this.clWebPalegoldenrod = 0xAAE8EE;
  this.clWebPalegreen = 0x98FB98;
  this.clWebPaleturquoise = 0xEEEEAF;
  this.clWebPalevioletred = 0x9370DB;
  this.clWebPapayawhip = 0xD5EFFF;
  this.clWebPeachpuff = 0xB9DAFF;
  this.clWebPeru = 0x3F85CD;
  this.clWebPink = 0xCBC0FF;
  this.clWebPlum = 0xDDA0DD;
  this.clWebPowderblue = 0xE6E0B0;
  this.clWebPurple = 0x800080;
  this.clWebRed = 0xFF;
  this.clWebRosybrown = 0x8F8FBC;
  this.clWebRoyalblue = 0xE16941;
  this.clWebSaddlebrown = 0x13458B;
  this.clWebSalmon = 0x7280FA;
  this.clWebSandybrown = 0x60A4F4;
  this.clWebSeagreen = 0x578B2E;
  this.clWebSeashell = 0xEEF5FF;
  this.clWebSienna = 0x2D52A0;
  this.clWebSilver = 0xC0C0C0;
  this.clWebSkyblue = 0xEBCE87;
  this.clWebSlateblue = 0xCD5A6A;
  this.clWebSlategray = 0x908070;
  this.clWebSlategrey = 0x908070;
  this.clWebSnow = 0xFAFAFF;
  this.clWebSpringgreen = 0x7FFF00;
  this.clWebSteelblue = 0xB48246;
  this.clWebTan = 0x8CB4D2;
  this.clWebTeal = 0x808000;
  this.clWebThistle = 0xD8BFD8;
  this.clWebTomato = 0x4763FF;
  this.clWebTurquoise = 0xD0E040;
  this.clWebViolet = 0xEE82EE;
  this.clWebWheat = 0xB3DEF5;
  this.clWebWhite = 0xFFFFFF;
  this.clWebWhitesmoke = 0xF5F5F5;
  this.clWebYellow = 0xFFFF;
  this.clWebYellowgreen = 0x32CD9A;
  this.clAliceblue = 0xFFF8F0;
  this.clAntiquewhite = 0xD7EBFA;
  this.clAquamarine = 0xD4FF7F;
  this.clAzure = 0xFFFFF0;
  this.clBeige = 0xDCF5F5;
  this.clBisque = 0xC4E4FF;
  this.clBlanchedalmond = 0xCDEBFF;
  this.clBlueviolet = 0xE22B8A;
  this.clBrown = 0x2A2AA5;
  this.clBurlywood = 0x87B8DE;
  this.clCadetblue = 0xA09E5F;
  this.clChartreuse = 0xFF7F;
  this.clChocolate = 0x1E69D2;
  this.clCoral = 0x507FFF;
  this.clCornflowerblue = 0xED9564;
  this.clCornsilk = 0xDCF8FF;
  this.clCrimson = 0x3C14DC;
  this.clCyan = 0xFFFF00;
  this.clDarkblue = 0x8B0000;
  this.clDarkcyan = 0x8B8B00;
  this.clDarkgoldenrod = 0xB86B8;
  this.clDarkgray = 0xA9A9A9;
  this.clDarkgreen = 0x6400;
  this.clDarkgrey = 0xA9A9A9;
  this.clDarkkhaki = 0x6BB7BD;
  this.clDarkmagenta = 0x8B008B;
  this.clDarkolivegreen = 0x2F6B55;
  this.clDarkorange = 0x8CFF;
  this.clDarkorchid = 0xCC3299;
  this.clDarkred = 0x8B;
  this.clDarksalmon = 0x7A96E9;
  this.clDarkseagreen = 0x8FBC8F;
  this.clDarkslateblue = 0x8B3D48;
  this.clDarkslategray = 0x4F4F2F;
  this.clDarkslategrey = 0x4F4F2F;
  this.clDarkturquoise = 0xD1CE00;
  this.clDarkviolet = 0xD30094;
  this.clDeeppink = 0x9314FF;
  this.clDeepskyblue = 0xFFBF00;
  this.clDimgray = 0x696969;
  this.clDimgrey = 0x696969;
  this.clDodgerblue = 0xFF901E;
  this.clFirebrick = 0x2222B2;
  this.clFloralwhite = 0xF0FAFF;
  this.clForestgreen = 0x228B22;
  this.clGainsboro = 0xDCDCDC;
  this.clGhostwhite = 0xFFF8F8;
  this.clGold = 0xD7FF;
  this.clGoldenrod = 0x20A5DA;
  this.clGreenyellow = 0x2FFFAD;
  this.clGrey = 0x808080;
  this.clHoneydew = 0xF0FFF0;
  this.clHotpink = 0xB469FF;
  this.clIndianred = 0x5C5CCD;
  this.clIndigo = 0x82004B;
  this.clIvory = 0xF0FFFF;
  this.clKhaki = 0x8CE6F0;
  this.clLavender = 0xFAE6E6;
  this.clLavenderblush = 0xF5F0FF;
  this.clLawngreen = 0xFC7C;
  this.clLemonchiffon = 0xCDFAFF;
  this.clLightblue = 0xE6D8AD;
  this.clLightcoral = 0x8080F0;
  this.clLightcyan = 0xFFFFE0;
  this.clLightgoldenrodyellow = 0xD2FAFA;
  this.clLightgray = 0xD3D3D3;
  this.clLightgreen = 0x90EE90;
  this.clLightgrey = 0xD3D3D3;
  this.clLightpink = 0xC1B6FF;
  this.clLightsalmon = 0x7AA0FF;
  this.clLightseagreen = 0xAAB220;
  this.clLightskyblue = 0xFACE87;
  this.clLightslategray = 0x998877;
  this.clLightslategrey = 0x998877;
  this.clLightsteelblue = 0xDEC4B0;
  this.clLightyellow = 0xE0FFFF;
  this.clLegacySkyBlue = 0xF0CAA6;
  this.clLimegreen = 0x32CD32;
  this.clLinen = 0xE6F0FA;
  this.clMagenta = 0xFF00FF;
  this.clMediumaquamarine = 0xAACD66;
  this.clMediumblue = 0xCD0000;
  this.clMediumorchid = 0xD355BA;
  this.clMediumpurple = 0xDB7093;
  this.clMediumseagreen = 0x71B33C;
  this.clMediumslateblue = 0xEE687B;
  this.clMediumspringgreen = 0x9AFA00;
  this.clMediumturquoise = 0xCCD148;
  this.clMediumvioletred = 0x8515C7;
  this.clMidnightblue = 0x701919;
  this.clMintcream = 0xFAFFF5;
  this.clMistyrose = 0xE1E4FF;
  this.clMoccasin = 0xB5E4FF;
  this.clNavajowhite = 0xADDEFF;
  this.clOldlace = 0xE6F5FD;
  this.clOlivedrab = 0x238E6B;
  this.clOrange = 0xA5FF;
  this.clOrangered = 0x45FF;
  this.clOrchid = 0xD670DA;
  this.clPalegoldenrod = 0xAAE8EE;
  this.clPalegreen = 0x98FB98;
  this.clPaleturquoise = 0xEEEEAF;
  this.clPalevioletred = 0x9370DB;
  this.clPapayawhip = 0xD5EFFF;
  this.clPeachpuff = 0xB9DAFF;
  this.clPeru = 0x3F85CD;
  this.clPink = 0xCBC0FF;
  this.clPlum = 0xDDA0DD;
  this.clPowderblue = 0xE6E0B0;
  this.clRosybrown = 0x8F8FBC;
  this.clRoyalblue = 0xE16941;
  this.clSaddlebrown = 0x13458B;
  this.clSalmon = 0x7280FA;
  this.clSandybrown = 0x60A4F4;
  this.clSeagreen = 0x578B2E;
  this.clSeashell = 0xEEF5FF;
  this.clSienna = 0x2D52A0;
  this.clSlateblue = 0xCD5A6A;
  this.clSlategray = 0x908070;
  this.clSlategrey = 0x908070;
  this.clSnow = 0xFAFAFF;
  this.clSpringgreen = 0x7FFF00;
  this.clSteelblue = 0xB48246;
  this.clTan = 0x8CB4D2;
  this.clThistle = 0xD8BFD8;
  this.clTomato = 0x4763FF;
  this.clTurquoise = 0xD0E040;
  this.clViolet = 0xEE82EE;
  this.clWheat = 0xB3DEF5;
  this.clWhitesmoke = 0xF5F5F5;
  this.clYellowgreen = 0x32CD9A;
  this.clInactiveBorder = 0xFCF7F4;
  this.ANSI_CHARSET = 0;
  this.DEFAULT_CHARSET = 1;
  this.SYMBOL_CHARSET = 2;
  this.MAC_CHARSET = 77;
  this.SHIFTJIS_CHARSET = 128;
  this.HANGEUL_CHARSET = 129;
  this.JOHAB_CHARSET = 130;
  this.GB2312_CHARSET = 134;
  this.CHINESEBIG5_CHARSET = 136;
  this.GREEK_CHARSET = 161;
  this.TURKISH_CHARSET = 162;
  this.HEBREW_CHARSET = 177;
  this.ARABIC_CHARSET = 178;
  this.BALTIC_CHARSET = 186;
  this.RUSSIAN_CHARSET = 204;
  this.THAI_CHARSET = 222;
  this.EASTEUROPE_CHARSET = 238;
  this.OEM_CHARSET = 255;
  this.$rtti.$inherited("TColor",rtl.nativeint,{});
  this.TVerticalAlignment = {"0": "taAlignTop", taAlignTop: 0, "1": "taAlignBottom", taAlignBottom: 1, "2": "taVerticalCenter", taVerticalCenter: 2};
  this.$rtti.$Enum("TVerticalAlignment",{minvalue: 0, maxvalue: 2, ordtype: 1, enumtype: this.TVerticalAlignment});
  this.TPenStyle = {"0": "psSolid", psSolid: 0, "1": "psDash", psDash: 1, "2": "psDot", psDot: 2, "3": "psDashDot", psDashDot: 3, "4": "psDashDotDot", psDashDotDot: 4, "5": "psClear", psClear: 5, "6": "psInsideFrame", psInsideFrame: 6, "7": "psUserStyle", psUserStyle: 7, "8": "psAlternate", psAlternate: 8};
  this.$rtti.$Enum("TPenStyle",{minvalue: 0, maxvalue: 8, ordtype: 1, enumtype: this.TPenStyle});
  this.TPenMode = {"0": "pmBlack", pmBlack: 0, "1": "pmWhite", pmWhite: 1, "2": "pmNop", pmNop: 2, "3": "pmNot", pmNot: 3, "4": "pmCopy", pmCopy: 4, "5": "pmNotCopy", pmNotCopy: 5, "6": "pmMergePenNot", pmMergePenNot: 6, "7": "pmMaskPenNot", pmMaskPenNot: 7, "8": "pmMergeNotPen", pmMergeNotPen: 8, "9": "pmMaskNotPen", pmMaskNotPen: 9, "10": "pmMerge", pmMerge: 10, "11": "pmNotMerge", pmNotMerge: 11, "12": "pmMask", pmMask: 12, "13": "pmNotMask", pmNotMask: 13, "14": "pmXor", pmXor: 14, "15": "pmNotXor", pmNotXor: 15};
  this.$rtti.$Enum("TPenMode",{minvalue: 0, maxvalue: 15, ordtype: 1, enumtype: this.TPenMode});
  this.TBrushStyle = {"0": "bsSolid", bsSolid: 0, "1": "bsClear", bsClear: 1, "2": "bsHorizontal", bsHorizontal: 2, "3": "bsVertical", bsVertical: 3, "4": "bsFDiagonal", bsFDiagonal: 4, "5": "bsBDiagonal", bsBDiagonal: 5, "6": "bsCross", bsCross: 6, "7": "bsDiagCross", bsDiagCross: 7};
  this.$rtti.$Enum("TBrushStyle",{minvalue: 0, maxvalue: 7, ordtype: 1, enumtype: this.TBrushStyle});
  this.TBrushGradient = {"0": "bgNone", bgNone: 0, "1": "bgLinearVert", bgLinearVert: 1, "2": "bgLinearHorz", bgLinearHorz: 2, "3": "bgRadial", bgRadial: 3};
  this.$rtti.$Enum("TBrushGradient",{minvalue: 0, maxvalue: 3, ordtype: 1, enumtype: this.TBrushGradient});
  this.TFontStyle = {"0": "fsBold", fsBold: 0, "1": "fsItalic", fsItalic: 1, "2": "fsStrikeOut", fsStrikeOut: 2, "3": "fsUnderline", fsUnderline: 3};
  this.$rtti.$Enum("TFontStyle",{minvalue: 0, maxvalue: 3, ordtype: 1, enumtype: this.TFontStyle});
  this.$rtti.$Set("TFontStyles",{comptype: this.$rtti["TFontStyle"]});
  this.$rtti.$Int("TFontCharset",{minvalue: 0, maxvalue: 255, ordtype: 3});
  this.TTextFormats = {"0": "tfBottom", tfBottom: 0, "1": "tfCalcRect", tfCalcRect: 1, "2": "tfCenter", tfCenter: 2, "3": "tfEditControl", tfEditControl: 3, "4": "tfEndEllipsis", tfEndEllipsis: 4, "5": "tfPathEllipsis", tfPathEllipsis: 5, "6": "tfExpandTabs", tfExpandTabs: 6, "7": "tfExternalLeading", tfExternalLeading: 7, "8": "tfLeft", tfLeft: 8, "9": "tfModifyString", tfModifyString: 9, "10": "tfNoClip", tfNoClip: 10, "11": "tfNoPrefix", tfNoPrefix: 11, "12": "tfRight", tfRight: 12, "13": "tfRtlReading", tfRtlReading: 13, "14": "tfSingleLine", tfSingleLine: 14, "15": "tfTop", tfTop: 15, "16": "tfVerticalCenter", tfVerticalCenter: 16, "17": "tfWordBreak", tfWordBreak: 17, "18": "tfHidePrefix", tfHidePrefix: 18, "19": "tfNoFullWidthCharBreak", tfNoFullWidthCharBreak: 19, "20": "tfPrefixOnly", tfPrefixOnly: 20, "21": "tfTabStop", tfTabStop: 21, "22": "tfWordEllipsis", tfWordEllipsis: 22, "23": "tfComposited", tfComposited: 23};
  this.$rtti.$Enum("TTextFormats",{minvalue: 0, maxvalue: 23, ordtype: 1, enumtype: this.TTextFormats});
  this.$rtti.$Set("TTextFormat",{comptype: this.$rtti["TTextFormats"]});
  this.$rtti.$inherited("TBinaryString",rtl.string,{});
  rtl.recNewT(this,"TCanvasPointF",function () {
    this.X = 0.0;
    this.Y = 0.0;
    this.$eq = function (b) {
      return (this.X === b.X) && (this.Y === b.Y);
    };
    this.$assign = function (s) {
      this.X = s.X;
      this.Y = s.Y;
      return this;
    };
    var $r = $mod.$rtti.$Record("TCanvasPointF",{});
    $r.addField("X",rtl.double);
    $r.addField("Y",rtl.double);
  });
  rtl.recNewT(this,"TCanvasRectF",function () {
    this.Left = 0.0;
    this.Top = 0.0;
    this.Right = 0.0;
    this.Bottom = 0.0;
    this.$eq = function (b) {
      return (this.Left === b.Left) && (this.Top === b.Top) && (this.Right === b.Right) && (this.Bottom === b.Bottom);
    };
    this.$assign = function (s) {
      this.Left = s.Left;
      this.Top = s.Top;
      this.Right = s.Right;
      this.Bottom = s.Bottom;
      return this;
    };
    var $r = $mod.$rtti.$Record("TCanvasRectF",{});
    $r.addField("Left",rtl.double);
    $r.addField("Top",rtl.double);
    $r.addField("Right",rtl.double);
    $r.addField("Bottom",rtl.double);
  });
  rtl.recNewT(this,"TCanvasSizeF",function () {
    this.cx = 0.0;
    this.cy = 0.0;
    this.$eq = function (b) {
      return (this.cx === b.cx) && (this.cy === b.cy);
    };
    this.$assign = function (s) {
      this.cx = s.cx;
      this.cy = s.cy;
      return this;
    };
    var $r = $mod.$rtti.$Record("TCanvasSizeF",{});
    $r.addField("cx",rtl.double);
    $r.addField("cy",rtl.double);
  });
  rtl.createClass(this,"TPen",pas.Classes.TPersistent,function () {
    this.$init = function () {
      pas.Classes.TPersistent.$init.call(this);
      this.FWidth = 0;
      this.FColor = 0;
      this.FStyle = 0;
      this.FMode = 0;
    };
    this.SetColor = function (Value) {
      this.FColor = Value;
    };
    this.Create$1 = function () {
      this.FColor = 0;
      this.FWidth = 1;
      this.FStyle = $mod.TPenStyle.psSolid;
      this.FMode = $mod.TPenMode.pmCopy;
      return this;
    };
    this.Assign = function (Source) {
      if ($mod.TPen.isPrototypeOf(Source)) {
        this.FColor = rtl.as(Source,$mod.TPen).FColor;
        this.FStyle = rtl.as(Source,$mod.TPen).FStyle;
        this.FWidth = rtl.as(Source,$mod.TPen).FWidth;
      } else pas.Classes.TPersistent.Assign.apply(this,arguments);
    };
    var $r = this.$rtti;
    $r.addMethod("Create$1",2,[]);
    $r.addProperty("Color",2,$mod.$rtti["TColor"],"FColor","SetColor");
    $r.addProperty("Mode",0,$mod.$rtti["TPenMode"],"FMode","FMode",{Default: $mod.TPenMode.pmCopy});
    $r.addProperty("Width",0,rtl.longint,"FWidth","FWidth",{Default: 1});
    $r.addProperty("Style",0,$mod.$rtti["TPenStyle"],"FStyle","FStyle",{Default: $mod.TPenStyle.psSolid});
  });
  rtl.createClass(this,"TGradientColor",pas.Classes.TPersistent,function () {
    this.$init = function () {
      pas.Classes.TPersistent.$init.call(this);
      this.FColor = 0;
      this.FStop = 0.0;
    };
    this.Assign = function (Source) {
      if ($mod.TGradientColor.isPrototypeOf(Source)) {
        this.FColor = rtl.as(Source,$mod.TGradientColor).FColor;
        this.FStop = rtl.as(Source,$mod.TGradientColor).FStop;
      };
    };
    this.Create$1 = function () {
      this.FColor = -1;
      this.FStop = 0;
      return this;
    };
    var $r = this.$rtti;
    $r.addMethod("Create$1",2,[]);
    $r.addProperty("Stop",0,rtl.double,"FStop","FStop");
    $r.addProperty("Color",0,$mod.$rtti["TColor"],"FColor","FColor",{Default: -1});
  });
  rtl.createClass(this,"TBrush",pas.Classes.TPersistent,function () {
    this.$init = function () {
      pas.Classes.TPersistent.$init.call(this);
      this.FColor = 0;
      this.FStyle = 0;
      this.FGradientColors = null;
      this.FGradient = 0;
    };
    this.$final = function () {
      this.FGradientColors = undefined;
      pas.Classes.TPersistent.$final.call(this);
    };
    this.Create$1 = function () {
      this.FColor = 16777215;
      this.FStyle = $mod.TBrushStyle.bsSolid;
      this.FGradient = $mod.TBrushGradient.bgNone;
      this.FGradientColors = pas.Classes.TList.$create("Create$1");
      return this;
    };
    this.Destroy = function () {
      rtl.free(this,"FGradientColors");
      pas.System.TObject.Destroy.call(this);
    };
    this.Assign = function (Source) {
      if ($mod.TBrush.isPrototypeOf(Source)) {
        this.FColor = rtl.as(Source,$mod.TBrush).FColor;
        this.FStyle = rtl.as(Source,$mod.TBrush).FStyle;
      } else pas.Classes.TPersistent.Assign.apply(this,arguments);
    };
    this.AddGradientColor = function (AColor, AStop) {
      var gr = null;
      gr = $mod.TGradientColor.$create("Create$1");
      gr.FColor = AColor;
      gr.FStop = AStop;
      this.FGradientColors.Add(gr);
    };
    this.GetGradientColor = function (AIndex, AColor, AStop) {
      if (AIndex < this.FGradientColors.GetCount()) {
        AColor.set(rtl.getObject(this.FGradientColors.Get(AIndex)).FColor);
        AStop.set(rtl.getObject(this.FGradientColors.Get(AIndex)).FStop);
      } else throw pas.SysUtils.Exception.$create("Create$1",["Invalid gradient color index"]);
    };
    this.GradientCount = function () {
      var Result = 0;
      Result = this.FGradientColors.GetCount();
      return Result;
    };
    this.ClearGradient = function () {
      var i = 0;
      var gr = null;
      for (var $l = this.FGradientColors.GetCount() - 1; $l >= 0; $l--) {
        i = $l;
        gr = rtl.getObject(this.FGradientColors.Get(i));
        gr = rtl.freeLoc(gr);
        this.FGradientColors.Delete(i);
      };
    };
    var $r = this.$rtti;
    $r.addMethod("Create$1",2,[]);
    $r.addProperty("Gradient",0,$mod.$rtti["TBrushGradient"],"FGradient","FGradient");
    $r.addProperty("Color",0,$mod.$rtti["TColor"],"FColor","FColor");
    $r.addProperty("Style",0,$mod.$rtti["TBrushStyle"],"FStyle","FStyle");
  });
  rtl.createClass(this,"TFont",pas.Classes.TPersistent,function () {
    this.$init = function () {
      pas.Classes.TPersistent.$init.call(this);
      this.FName = "";
      this.FSize = 0;
      this.FColor = 0;
      this.FStyle = {};
      this.FOnChange = null;
      this.FHeight = 0;
      this.FCharset = 0;
      this.FOrientation = 0;
    };
    this.$final = function () {
      this.FStyle = undefined;
      this.FOnChange = undefined;
      pas.Classes.TPersistent.$final.call(this);
    };
    this.SetHeight = function (Value) {
      var d = 0.0;
      d = (-Value * 72) / 96;
      this.FSize = Math.round(d);
      if (this.FHeight !== Value) {
        this.FHeight = Value;
        this.DoChange();
      };
    };
    this.SetName = function (AName) {
      if (this.FName !== AName) {
        this.FName = AName;
        this.DoChange();
      };
    };
    this.SetSize = function (ASize) {
      if (this.FSize !== ASize) {
        this.FSize = ASize;
        this.DoChange();
      };
    };
    this.SetColor = function (AColor) {
      if (this.FColor !== AColor) {
        this.FColor = AColor;
        this.DoChange();
      };
    };
    this.SetStyle = function (AStyle) {
      if (rtl.neSet(this.FStyle,AStyle)) {
        this.FStyle = rtl.refSet(AStyle);
        this.DoChange();
      };
    };
    this.DoChange = function () {
      if (this.FOnChange != null) this.FOnChange(this);
    };
    this.Assign = function (Source) {
      if ($mod.TFont.isPrototypeOf(Source)) {
        this.FName = rtl.as(Source,$mod.TFont).FName;
        this.FColor = rtl.as(Source,$mod.TFont).FColor;
        this.FSize = rtl.as(Source,$mod.TFont).FSize;
        this.FStyle = rtl.refSet(rtl.as(Source,$mod.TFont).FStyle);
        this.DoChange();
      } else pas.Classes.TPersistent.Assign.apply(this,arguments);
    };
    this.Create$1 = function () {
      pas.System.TObject.Create.call(this);
      this.FName = $mod.WEBDEFAULTFONT;
      this.FSize = 8;
      this.FHeight = -11;
      this.FStyle = {};
      this.FColor = 0;
      return this;
    };
    this.ToString = function () {
      var Result = "";
      var s = "";
      s = "";
      if (($mod.TFontStyle.fsBold in this.FStyle) && ($mod.TFontStyle.fsItalic in this.FStyle)) {
        s = s + "bold italic"}
       else if ($mod.TFontStyle.fsBold in this.FStyle) {
        s = s + "bold"}
       else if ($mod.TFontStyle.fsItalic in this.FStyle) s = s + "italic";
      if (this.FSize !== 0) {
        Result = s + " " + $mod.FontSizeToHTML($mod.FontSizeToPx(this.FSize)) + " " + this.FName}
       else Result = s + " " + $mod.FontSizeToHTML($mod.FontSizeToPx(12)) + " " + this.FName;
      return Result;
    };
    var $r = this.$rtti;
    $r.addMethod("Create$1",2,[]);
    $r.addProperty("Charset",0,$mod.$rtti["TFontCharset"],"FCharset","FCharset");
    $r.addProperty("Name",2,pas.UITypes.$rtti["TFontName"],"FName","SetName");
    $r.addProperty("Height",2,rtl.longint,"FHeight","SetHeight");
    $r.addProperty("Style",2,$mod.$rtti["TFontStyles"],"FStyle","SetStyle");
    $r.addProperty("Color",2,$mod.$rtti["TColor"],"FColor","SetColor");
    $r.addProperty("Size",2,rtl.longint,"FSize","SetSize");
  });
  this.TImageType = {"0": "itBase64", itBase64: 0, "1": "itBMP", itBMP: 1, "2": "itPNG", itPNG: 2, "3": "itJPEG", itJPEG: 3, "4": "itGIF", itGIF: 4, "5": "itSVG", itSVG: 5};
  this.$rtti.$Enum("TImageType",{minvalue: 0, maxvalue: 5, ordtype: 1, enumtype: this.TImageType});
  this.$rtti.$Class("TCanvas");
  this.$rtti.$Class("TBitmap");
  this.$rtti.$RefToProcVar("TBitmapLoadedProc",{procsig: rtl.newTIProcSig([])});
  rtl.createClass(this,"TGraphic",pas.Classes.TPersistent,function () {
    this.$init = function () {
      pas.Classes.TPersistent.$init.call(this);
      this.FAddToQueue = false;
      this.FCanvasElement = null;
      this.FEmpty = false;
      this.FData = "";
      this.FDataBin = "";
      this.FCanvas = null;
      this.FOnChange = null;
      this.FImage = null;
      this.FBitmap = null;
      this.FURL = "";
      this.FLoaded = null;
      this.FUsedCanvas = false;
    };
    this.$final = function () {
      this.FCanvasElement = undefined;
      this.FCanvas = undefined;
      this.FOnChange = undefined;
      this.FImage = undefined;
      this.FBitmap = undefined;
      this.FLoaded = undefined;
      pas.Classes.TPersistent.$final.call(this);
    };
    this.SetHeight = function (Value) {
      this.FImage.height = Value;
      this.RecreateCanvas();
      this.DoChange();
    };
    this.SetWidth = function (Value) {
      this.FImage.width = Value;
      this.RecreateCanvas();
      this.DoChange();
    };
    this.GetCanvas = function () {
      var Result = null;
      if (!(this.FCanvas != null)) this.RecreateCanvas();
      Result = this.FCanvas;
      this.FUsedCanvas = true;
      return Result;
    };
    this.GetData = function () {
      var Result = "";
      Result = this.FDataBin;
      return Result;
    };
    this.SetData = function (Value) {
      var hx = "";
      if (this.FDataBin !== Value) {
        this.FDataBin = Value;
        hx = pas["WEBLib.WebTools"].HexImageDecodeAsBase64(this.FDataBin);
        if (pas.System.Pos("PHN2ZyB",hx) > 0) {
          this.LoadFromResource("data:image/svg+xml;base64," + hx)}
         else this.LoadFromResource("data:image/png;base64," + hx);
      };
    };
    this.DoChange = function () {
      var i = 0;
      this.FEmpty = (this.GetWidth() === 0) && (this.GetHeight() === 0);
      if (!this.FEmpty && (this.FData !== "") && !$impl.FCache.Exists(this.FData)) {
        $impl.FCache.Add$1($impl.TGraphicCache.$create("Create$1",[this.FImage,this.FData]));
        i = $impl.FQueue.IndexOf(this.FData);
        if ((i >= 0) && (i <= ($impl.FQueue.GetCount() - 1))) $impl.FQueue.Delete(i);
        $impl.FCacheCount -= 1;
        if ($impl.FCacheCount === 0) {
          if (pas["WEBLib.Forms"].Application.FOnImageCacheReady != null) pas["WEBLib.Forms"].Application.FOnImageCacheReady(pas["WEBLib.Forms"].Application);
        };
      };
      if (this.FOnChange != null) {
        this.FOnChange(this);
      };
      if (this.FLoaded != null) {
        this.FLoaded();
        this.FLoaded = null;
      };
    };
    this.SetURL = function (URL) {
      this.FURL = URL;
      this.LoadFromURL(URL,null);
    };
    this.GetWidth = function () {
      var Result = 0;
      var w = 0;
      w = 0;
      if (this.FImage != null) {
        w = this.FImage.width;
      };
      Result = w;
      return Result;
    };
    this.GetHeight = function () {
      var Result = 0;
      var h = 0;
      h = 0;
      if (this.FImage != null) {
        h = this.FImage.height;
      };
      Result = h;
      return Result;
    };
    this.RecreateCanvas = function () {
      if (!(this.FCanvasElement != null)) this.FCanvasElement = document.createElement("CANVAS");
      if (this.FCanvasElement != null) {
        this.FCanvasElement.height = this.GetHeight();
        this.FCanvasElement.width = this.GetWidth();
        if (!(this.FCanvas != null)) {
          this.FCanvas = $mod.TCanvas.$create("Create$1",[this.FCanvasElement]);
          this.FCanvas.FOnBeginScene = rtl.createCallback(this,"DoBeginScene");
          this.FCanvas.FOnEndScene = rtl.createCallback(this,"DoEndScene");
        };
      };
    };
    this.DoBeginScene = function (Sender) {
      this.FCanvas.Clear();
    };
    this.DoEndScene = function (Sender) {
      this.FAddToQueue = false;
      this.CaptureCanvas();
      this.FAddToQueue = true;
    };
    this.AssignEvents = function () {
      var me = this;
      this.FImage.onload = function() {
         me.DoChange();
        };
    };
    this.CreateImage = function () {
      this.FImage = new Image();
    };
    this.LoadFromCache = function (AData, ALoaded) {
      var dt = "";
      var o = null;
      var b = false;
      var s = "";
      var l = false;
      this.FData = AData;
      if (pas.System.Pos("DATA:",pas.SysUtils.UpperCase(AData)) > 0) {
        this.FDataBin = pas["WEBLib.WebTools"].HexImageEncodeFromBase64(AData);
      };
      dt = AData;
      if (dt === "") return;
      this.FLoaded = ALoaded;
      this.FUsedCanvas = false;
      if (!$impl.FCache.Find(dt,{get: function () {
          return o;
        }, set: function (v) {
          o = v;
        }})) {
        b = false;
        s = "";
        s = this.FImage.src;
        b = (s != '');
        l = b && (dt !== s);
        if (l) {
          this.CreateImage();
          this.AssignEvents();
        };
        if ((!l && ($impl.FQueue.IndexOf(dt) === -1)) || l) {
          this.FImage.src = dt;
          dt = this.FImage.src;
          this.FData = dt;
          if (pas.System.Pos("DATA:",pas.SysUtils.UpperCase(dt)) > 0) this.FDataBin = pas["WEBLib.WebTools"].HexImageEncodeFromBase64(dt);
          $impl.FCacheCount += 1;
          if (this.FAddToQueue) $impl.FQueue.Add(dt);
        } else if (!l && ($impl.FQueue.IndexOf(dt) !== -1)) {
          this.FImage.src = dt;
        };
      } else {
        this.FImage = o;
        this.DoChange();
      };
      if (this.FImage) {
        this.FEmpty = (this.FImage.src == '');
      };
    };
    this.CreateFromResource = function (AResource) {
      var Result = null;
      Result = this.CreateFromResource$1(AResource,0);
      return Result;
    };
    this.CreateFromResource$1 = function (AResource, AInstance) {
      var Result = null;
      Result = $mod.TGraphic.$create("Create$3");
      Result.LoadFromResource(AResource);
      return Result;
    };
    this.CreateFromURL = function (AURL) {
      var Result = null;
      Result = this.CreateFromURL$1(AURL,0);
      return Result;
    };
    this.CreateFromURL$1 = function (AURL, AInstance) {
      var Result = null;
      Result = $mod.TGraphic.$create("Create$3");
      Result.LoadFromURL(AURL,null);
      return Result;
    };
    this.Image = function () {
      var Result = null;
      Result = this.FImage;
      return Result;
    };
    this.Empty = function () {
      var Result = false;
      Result = this.FEmpty;
      return Result;
    };
    this.GetBase64Image = function () {
      var Result = "";
      Result = "";
      if (this.FCanvas != null) Result = this.FCanvas.GetBase64Image();
      return Result;
    };
    this.GetAsImage = function (AType) {
      var Result = "";
      Result = "";
      if (this.FCanvas != null) Result = this.FCanvas.GetAsImage(AType);
      return Result;
    };
    this.Create$1 = function (URL) {
      this.FAddToQueue = true;
      this.FEmpty = true;
      this.FData = "";
      this.FDataBin = "";
      this.Create$3();
      this.LoadFromURL(URL,null);
      return this;
    };
    this.Create$2 = function (Img) {
      this.FAddToQueue = true;
      this.FEmpty = true;
      this.FData = "";
      this.FDataBin = "";
      this.FURL = "";
      this.FImage = Img;
      this.FLoaded = null;
      return this;
    };
    this.Create$3 = function () {
      this.FAddToQueue = true;
      this.FEmpty = true;
      this.FData = "";
      this.FDataBin = "";
      this.FUsedCanvas = false;
      this.CreateImage();
      this.AssignEvents();
      return this;
    };
    this.CaptureCanvas = function () {
      if ((this.FCanvas != null) && (this.FCanvas.FElementCanvas != null)) this.LoadFromResource(this.FCanvas.FElementCanvas.toDataURL());
    };
    this.LoadFromCanvas = function (ACanvas) {
      if ((ACanvas != null) && (ACanvas.FElementCanvas != null)) this.LoadFromResource(ACanvas.FElementCanvas.toDataURL());
    };
    this.SetSize = function (AWidth, AHeight) {
      this.SetWidth(AWidth);
      this.SetHeight(AHeight);
    };
    this.Assign = function (Source) {
      var s = "";
      if ((Source != null) && $mod.TGraphic.isPrototypeOf(Source) && (rtl.as(Source,$mod.TGraphic).FCanvas != null)) {
        this.LoadFromCanvas(rtl.as(Source,$mod.TGraphic).FCanvas)}
       else if ((Source != null) && $mod.TGraphic.isPrototypeOf(Source) && (rtl.as(Source,$mod.TGraphic).FImage != null) && !rtl.as(Source,$mod.TGraphic).Empty()) {
        s = Source.FImage.src;
        this.LoadFromURL(s,null);
      } else if (!(Source != null)) {
        this.CreateImage();
        this.DoChange();
      };
    };
    this.LoadFromURL = function (AURL, ALoaded) {
      this.LoadFromURL$1(AURL,0,ALoaded);
    };
    this.LoadFromURL$1 = function (AURL, AHInstance, ALoaded) {
      this.FEmpty = true;
      this.LoadFromCache(AURL,ALoaded);
    };
    this.LoadFromFile = function (AFileName, ALoaded) {
      this.LoadFromURL$1(AFileName,0,ALoaded);
    };
    this.LoadFromResource = function (AResource) {
      this.LoadFromResource$1(AResource,0);
    };
    this.LoadFromResource$1 = function (AResource, AHInstance) {
      this.FEmpty = true;
      this.LoadFromCache(AResource,null);
    };
    this.LoadFromStream = function (AStream) {
      this.DoChange();
    };
    this.SaveToStream = function (AStream) {
      var s = "";
      var ms = null;
      s = this.GetAsImage($mod.TImageType.itBase64);
      ms = AStream;
      s = s.replace(/^data:image\/(png|jpg|jpeg);base64,/, "");
      
          var base64regex = /^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/;
          if (base64regex.test(s)) {
            var binary_string = window.atob(s);
            var len = binary_string.length;
            var bytes = new Uint8Array( len );
            for (var i = 0; i < len; i++)        {
                bytes[i] = binary_string.charCodeAt(i);
            }
            ms.Write(bytes, bytes.length);
          };
    };
    var $r = this.$rtti;
    $r.addMethod("Create$1",2,[["URL",rtl.string]]);
    $r.addMethod("Create$2",2,[["Img",pas.JS.$rtti["TJSObject"]]]);
    $r.addMethod("Create$3",2,[]);
    $r.addProperty("OnChange",0,pas.Classes.$rtti["TNotifyEvent"],"FOnChange","FOnChange");
    $r.addProperty("URL",2,rtl.string,"FURL","SetURL");
    $r.addProperty("Data",3,$mod.$rtti["TBinaryString"],"GetData","SetData");
  });
  rtl.createClass(this,"TBitmap",this.TGraphic,function () {
    this.Assign = function (Source) {
      $mod.TGraphic.Assign.call(this,Source);
    };
  });
  rtl.recNewT(this,"TMatrix",function () {
    this.m11 = 0.0;
    this.m12 = 0.0;
    this.m13 = 0.0;
    this.m21 = 0.0;
    this.m22 = 0.0;
    this.m23 = 0.0;
    this.m31 = 0.0;
    this.m32 = 0.0;
    this.m33 = 0.0;
    this.$eq = function (b) {
      return (this.m11 === b.m11) && (this.m12 === b.m12) && (this.m13 === b.m13) && (this.m21 === b.m21) && (this.m22 === b.m22) && (this.m23 === b.m23) && (this.m31 === b.m31) && (this.m32 === b.m32) && (this.m33 === b.m33);
    };
    this.$assign = function (s) {
      this.m11 = s.m11;
      this.m12 = s.m12;
      this.m13 = s.m13;
      this.m21 = s.m21;
      this.m22 = s.m22;
      this.m23 = s.m23;
      this.m31 = s.m31;
      this.m32 = s.m32;
      this.m33 = s.m33;
      return this;
    };
    var $r = $mod.$rtti.$Record("TMatrix",{});
    $r.addField("m11",rtl.double);
    $r.addField("m12",rtl.double);
    $r.addField("m13",rtl.double);
    $r.addField("m21",rtl.double);
    $r.addField("m22",rtl.double);
    $r.addField("m23",rtl.double);
    $r.addField("m31",rtl.double);
    $r.addField("m32",rtl.double);
    $r.addField("m33",rtl.double);
  });
  rtl.createClass(this,"TCanvas",pas.System.TObject,function () {
    this.$init = function () {
      pas.System.TObject.$init.call(this);
      this.FElementCanvas = null;
      this.FContext = null;
      this.FPen = null;
      this.FBrush = null;
      this.FFont = null;
      this.FPathOpen = false;
      this.FPathX = 0.0;
      this.FPathY = 0.0;
      this.FClipRect = $mod.TCanvasRectF.$new();
      this.FOnEndScene = null;
      this.FOnBeginScene = null;
      this.FApplyPixelRatio = false;
    };
    this.$final = function () {
      this.FElementCanvas = undefined;
      this.FContext = undefined;
      this.FPen = undefined;
      this.FBrush = undefined;
      this.FFont = undefined;
      this.FClipRect = undefined;
      this.FOnEndScene = undefined;
      this.FOnBeginScene = undefined;
      pas.System.TObject.$final.call(this);
    };
    this.SetClipRect = function (Value) {
      this.FClipRect.$assign(Value);
      if (this.FContext != null) {
        this.FContext.beginPath();
        this.FContext.rect(this.FClipRect.Left,this.FClipRect.Top,this.FClipRect.Right - this.FClipRect.Left,this.FClipRect.Bottom - this.FClipRect.Top);
        this.FContext.clip();
      };
    };
    this.GetAccuOffset = function (X, Y, dx, dy) {
      dx.set(0);
      dy.set(0);
      if ((this.FPen.FWidth === 1) && (this.FPen.FStyle !== $mod.TPenStyle.psClear) && (pas.System.Frac(X) === 0)) dx.set(0.5);
      if ((this.FPen.FWidth === 1) && (this.FPen.FStyle !== $mod.TPenStyle.psClear) && (pas.System.Frac(Y) === 0)) dy.set(0.5);
    };
    this.GetPixel = function (X, Y) {
      var Result = 0;
      var imgd = null;
      Result = -1;
      if (this.FContext != null) {
        imgd = this.FContext.getImageData(X,Y,1,1);
        Result = $mod.RGBA(imgd.data[0],imgd.data[1],imgd.data[2],imgd.data[3]);
      };
      return Result;
    };
    this.SetPixel = function (X, Y, Clr) {
      if (this.FContext != null) {
        this.FContext.fillStyle = $mod.ColorToHTML(Clr);
        this.FContext.fillRect(X,Y,1,1);
      };
    };
    this.ApplyStroke = function () {
      if (this.FContext != null) {
        this.FContext.lineWidth = this.FPen.FWidth;
        this.FContext.strokeStyle = $mod.ColorToHTML(this.FPen.FColor);
        var $tmp = this.FPen.FStyle;
        if ($tmp === $mod.TPenStyle.psSolid) {
          this.FContext.setLineDash([])}
         else if ($tmp === $mod.TPenStyle.psDot) {
          this.FContext.setLineDash([1,2])}
         else if ($tmp === $mod.TPenStyle.psDash) {
          this.FContext.setLineDash([8,2])}
         else if ($tmp === $mod.TPenStyle.psDashDot) {
          this.FContext.setLineDash([6,2,2,2])}
         else if ($tmp === $mod.TPenStyle.psDashDotDot) {
          this.FContext.setLineDash([6,2,2,2,2,2])}
         else if ($tmp === $mod.TPenStyle.psClear) this.FContext.setLineDash([0,0xFFFF]);
      };
    };
    this.ApplyFill = function () {
      if (this.FContext != null) this.FContext.fillStyle = $mod.ColorToHTML(this.FBrush.FColor);
    };
    this.ApplyBrush = function (X1, Y1, X2, Y2) {
      var dx = 0.0;
      var dy = 0.0;
      var p = 0.0;
      var gr = null;
      var i = 0;
      var clr = "";
      var AColor = 0;
      var AStop = 0.0;
      this.GetAccuOffset(X1,Y1,{get: function () {
          return dx;
        }, set: function (v) {
          dx = v;
        }},{get: function () {
          return dy;
        }, set: function (v) {
          dy = v;
        }});
      if (this.FBrush.FStyle in rtl.createSet($mod.TBrushStyle.bsHorizontal,$mod.TBrushStyle.bsCross)) {
        p = Y1 + dy;
        this.FContext.lineWidth = 1;
        this.FContext.strokeStyle = $mod.ColorToHTML(this.FBrush.FColor);
        while (p < Y2) {
          this.FContext.moveTo(X1,p);
          this.FContext.lineTo(X2,p);
          p = p + 8;
        };
      };
      if (this.FBrush.FStyle in rtl.createSet($mod.TBrushStyle.bsVertical,$mod.TBrushStyle.bsCross)) {
        p = X1 + dx;
        this.FContext.lineWidth = 1;
        this.FContext.strokeStyle = $mod.ColorToHTML(this.FBrush.FColor);
        while (p < X2) {
          this.FContext.moveTo(p,Y1);
          this.FContext.lineTo(p,Y2);
          p = p + 8;
        };
      };
      if (this.FBrush.FStyle in rtl.createSet($mod.TBrushStyle.bsFDiagonal,$mod.TBrushStyle.bsDiagCross)) {
        p = (X1 + dx) - (X2 - X1);
        this.FContext.lineWidth = 1;
        this.FContext.strokeStyle = $mod.ColorToHTML(this.FBrush.FColor);
        while (p < X2) {
          this.FContext.moveTo(p,Y1);
          this.FContext.lineTo(p + (Y2 - Y1),Y2);
          p = p + 8;
        };
      };
      if (this.FBrush.FStyle in rtl.createSet($mod.TBrushStyle.bsBDiagonal,$mod.TBrushStyle.bsDiagCross)) {
        p = X1 + dx;
        this.FContext.lineWidth = 1;
        this.FContext.strokeStyle = $mod.ColorToHTML(this.FBrush.FColor);
        while (p < (X2 + (X2 - X1))) {
          this.FContext.moveTo(p,Y1);
          this.FContext.lineTo(p - (Y2 - Y1),Y2);
          p = p + 8;
        };
      };
      if (this.FBrush.FGradient !== $mod.TBrushGradient.bgNone) {
        var $tmp = this.FBrush.FGradient;
        if ($tmp === $mod.TBrushGradient.bgLinearHorz) {
          gr = this.FContext.createLinearGradient(X1,Y1,X2,Y1)}
         else if ($tmp === $mod.TBrushGradient.bgLinearVert) {
          gr = this.FContext.createLinearGradient(X1,Y1,X1,Y2)}
         else if ($tmp === $mod.TBrushGradient.bgRadial) gr = this.FContext.createRadialGradient(X1 + ((X2 - X1) / 2),Y1 + ((Y2 - Y1) / 2),0,X1 + ((X2 - X1) / 2),Y1 + ((Y2 - Y1) / 2),(X2 - X1) / 2);
        clr = $mod.ColorToHTML($mod.ColorToRGB(this.FBrush.FColor));
        gr.addColorStop(0,clr);
        for (var $l = 0, $end = this.FBrush.GradientCount() - 1; $l <= $end; $l++) {
          i = $l;
          this.FBrush.GetGradientColor(i,{get: function () {
              return AColor;
            }, set: function (v) {
              AColor = v;
            }},{get: function () {
              return AStop;
            }, set: function (v) {
              AStop = v;
            }});
          clr = $mod.ColorToHTML($mod.ColorToRGB(AColor));
          gr.addColorStop(AStop,clr);
        };
        this.FContext.fillStyle = gr;
        return;
      };
      this.FContext.stroke();
    };
    this.Create$1 = function (AControl) {
      this.FElementCanvas = AControl;
      if (navigator.userAgent.indexOf('Safari') !== -1 && navigator.userAgent.indexOf('Chrome') === -1) {
            this.FContext = AControl.getContext('2d');
          } else {
            this.FContext = AControl.getContext('2d',{ willReadFrequently: true});
      //      const dpr = window.devicePixelRatio || 1;
      //      console.log(dpr);
      //      this.FContext.scale(dpr, dpr);
          };
      this.FPen = $mod.TPen.$create("Create$1");
      this.FBrush = $mod.TBrush.$create("Create$1");
      this.FPathOpen = false;
      this.FFont = $mod.TFont.$create("Create$1");
      this.FApplyPixelRatio = false;
      return this;
    };
    this.Create$2 = function () {
      this.FElementCanvas = document.createElement("CANVAS");
      this.Create$1(this.FElementCanvas);
      return this;
    };
    this.Destroy = function () {
      pas.System.TObject.Destroy.call(this);
    };
    this.SetTransform = function (m11, m12, m21, m22, dx, dy) {
      var m = $mod.TMatrix.$new();
      var px = 0.0;
      if (this.FContext != null) {
        m.$assign($impl.MatrixIdentity());
        m.m11 = m11;
        m.m12 = m12;
        m.m21 = m21;
        m.m22 = m22;
        m.m31 = dx;
        m.m32 = dy;
        if (this.FApplyPixelRatio) {
          px = $impl.GetPixelRatio(this);
          m.$assign($impl.MatrixMultiply(m,$impl.MatrixCreateScaling(px,px)));
        };
        this.FContext.setTransform(m.m11,m.m12,m.m21,m.m22,m.m31,m.m32);
      };
    };
    this.Transform = function (m11, m12, m21, m22, dx, dy) {
      if (this.FContext != null) this.FContext.transform(m11,m12,m21,m22,dx,dy);
    };
    this.Rotate = function (Angle) {
      if (this.FContext != null) this.FContext.rotate(Angle);
    };
    this.Translate = function (X, Y) {
      if (this.FContext != null) this.FContext.translate(X,Y);
    };
    this.AngleArc = function (X, Y, Radius, StartAngle, SweepAngle) {
      this.AngleArc$1(X,Y,Radius,StartAngle,SweepAngle);
    };
    this.AngleArc$1 = function (X, Y, Radius, StartAngle, SweepAngle) {
      if (this.FContext != null) {
        this.FContext.beginPath();
        this.ApplyStroke();
        this.FContext.arc(X,Y,Radius,StartAngle,StartAngle + SweepAngle);
        this.FContext.stroke();
      };
    };
    this.CopyRect = function (DestRect, Canvas, SourceRect) {
      var sw = 0;
      var sh = 0;
      var dw = 0;
      var dh = 0;
      var imgData = null;
      var ACanvas = null;
      if (this.FContext != null) {
        sw = SourceRect.Right - SourceRect.Left;
        sh = SourceRect.Bottom - SourceRect.Top;
        dw = DestRect.Right - DestRect.Left;
        dh = DestRect.Bottom - DestRect.Top;
        imgData = this.FContext.getImageData(SourceRect.Left,SourceRect.Top,sw,sh);
        ACanvas = $mod.TCanvas.$create("Create$2");
        try {
          ACanvas.FElementCanvas.width = sw;
          ACanvas.FElementCanvas.height = sh;
          ACanvas.FContext.putImageData(imgData,0,0);
          Canvas.FContext.drawImage(ACanvas.FElementCanvas,DestRect.Left,DestRect.Top,dw,dh);
        } finally {
          ACanvas = rtl.freeLoc(ACanvas);
        };
      };
    };
    this.MoveTo = function (X, Y) {
      this.MoveTo$1(X,Y);
    };
    this.MoveTo$1 = function (X, Y) {
      var dx = 0.0;
      var dy = 0.0;
      if (this.FContext != null) {
        this.FPathOpen = true;
        this.FContext.beginPath();
        this.ApplyStroke();
        dx = 0;
        dy = 0;
        this.GetAccuOffset(X,Y,{get: function () {
            return dx;
          }, set: function (v) {
            dx = v;
          }},{get: function () {
            return dy;
          }, set: function (v) {
            dy = v;
          }});
        this.FContext.moveTo(X + dx,Y + dy);
      };
    };
    this.LineTo = function (X, Y) {
      this.LineTo$1(X,Y);
    };
    this.LineTo$1 = function (X, Y) {
      var dx = 0.0;
      var dy = 0.0;
      var clr = 0;
      if (this.FContext != null) {
        dx = 0;
        dy = 0;
        this.GetAccuOffset(X,Y,{get: function () {
            return dx;
          }, set: function (v) {
            dx = v;
          }},{get: function () {
            return dy;
          }, set: function (v) {
            dy = v;
          }});
        var $tmp = this.FPen.FMode;
        if ($tmp === $mod.TPenMode.pmBlack) {
          this.FContext.strokeStyle = $mod.ColorToHTML(0)}
         else if ($tmp === $mod.TPenMode.pmWhite) {
          this.FContext.strokeStyle = $mod.ColorToHTML(16777215)}
         else if ($tmp === $mod.TPenMode.pmXor) {
          this.FContext.globalCompositeOperation = "xor"}
         else if ($tmp === $mod.TPenMode.pmMask) {
          this.FContext.globalCompositeOperation = "source-atop"}
         else if ($tmp === $mod.TPenMode.pmNotCopy) {
          clr = $mod.ColorToRGB(this.FPen.FColor) ^ 0xFFFFFFFF;
          this.FContext.strokeStyle = $mod.ColorToHTML(clr);
        } else if ($tmp === $mod.TPenMode.pmNotXor) {
          clr = $mod.ColorToRGB(this.FPen.FColor) ^ 0xFFFFFFFF;
          this.FContext.strokeStyle = $mod.ColorToHTML(clr);
          this.FContext.globalCompositeOperation = "xor";
        };
        if (!this.FPathOpen) {
          this.FContext.beginPath();
          this.ApplyStroke();
          this.FContext.moveTo(this.FPathX + dx,this.FPathY + dy);
        };
        this.FContext.lineTo(X + dx,Y + dy);
        this.FContext.stroke();
        this.FPathX = X;
        this.FPathY = Y;
        this.FPathOpen = false;
        this.FContext.globalCompositeOperation = "source-over";
      };
    };
    this.Rectangle = function (X1, Y1, X2, Y2) {
      var dx = 0.0;
      var dy = 0.0;
      if (this.FContext != null) {
        this.FContext.save();
        this.FContext.beginPath();
        this.ApplyStroke();
        this.ApplyFill();
        this.GetAccuOffset(X1,Y1,{get: function () {
            return dx;
          }, set: function (v) {
            dx = v;
          }},{get: function () {
            return dy;
          }, set: function (v) {
            dy = v;
          }});
        let region = new Path2D();
        region.rect(X1, Y1, X2- X1 + 1, Y2 - Y1 + 1);
        this.FContext.clip(region, "evenodd");
        this.ApplyBrush(X1,Y1,X2,Y2);
        if (!(this.FBrush.FStyle in rtl.createSet($mod.TBrushStyle.bsClear,$mod.TBrushStyle.bsHorizontal,$mod.TBrushStyle.bsVertical,$mod.TBrushStyle.bsCross,$mod.TBrushStyle.bsFDiagonal,$mod.TBrushStyle.bsBDiagonal,$mod.TBrushStyle.bsDiagCross))) {
          this.FContext.rect(X1 + dx,Y1 + dy,X2 - X1,Y2 - Y1);
          this.FContext.fill();
        };
        if (this.FPen.FStyle !== $mod.TPenStyle.psClear) {
          this.ApplyStroke();
          this.FContext.beginPath();
          this.FContext.rect(X1 + dx,Y1 + dy,X2 - X1,Y2 - Y1);
          this.FContext.stroke();
        };
        this.FContext.restore();
      };
    };
    this.Rectangle$1 = function (X1, Y1, X2, Y2) {
      this.Rectangle(X1,Y1,X2,Y2);
    };
    this.Rectangle$2 = function (Rect) {
      this.Rectangle$1(Rect.Left,Rect.Top,Rect.Right,Rect.Bottom);
    };
    this.Rectangle$3 = function (Rect) {
      this.Rectangle(Rect.Left,Rect.Top,Rect.Right,Rect.Bottom);
    };
    this.RoundRect = function (X1, Y1, X2, Y2, X3, Y3) {
      this.RoundRect$1(X1,Y1,X2,Y2,X3,Y3);
    };
    this.RoundRect$1 = function (X1, Y1, X2, Y2, X3, Y3) {
      var dx = 0.0;
      var dy = 0.0;
      if (this.FContext != null) {
        if (X2 < X1) return;
        if (Y2 < Y1) return;
        this.FContext.beginPath();
        this.ApplyStroke();
        this.ApplyFill();
        this.GetAccuOffset(X1,Y1,{get: function () {
            return dx;
          }, set: function (v) {
            dx = v;
          }},{get: function () {
            return dy;
          }, set: function (v) {
            dy = v;
          }});
        this.FContext.moveTo(X1 + (X3 / 2),Y1 + dy);
        this.FContext.lineTo(X2 - (X3 / 2),Y1 + dy);
        this.FContext.ellipse(X2 - dx - (X3 / 2),Y1 + dy + (Y3 / 2),X3 / 2,Y3 / 2,0,Math.PI * 1.5,0);
        this.FContext.lineTo(X2 - dx,Y2 - (Y3 / 2));
        this.FContext.ellipse(X2 - dx - (X3 / 2),Y2 - dy - (Y3 / 2),X3 / 2,Y3 / 2,0,0,Math.PI * 0.5);
        this.FContext.lineTo(X1 + (X3 / 2),Y2 - dy);
        this.FContext.ellipse(X1 + dx + (X3 / 2),Y2 - dy - (Y3 / 2),X3 / 2,Y3 / 2,0,Math.PI * 0.5,Math.PI);
        this.FContext.lineTo(X1 + dx,Y1 + (Y3 / 2) + dy);
        this.FContext.ellipse(X1 + dx + (X3 / 2),Y1 + dy + (Y3 / 2),X3 / 2,Y3 / 2,0,Math.PI,Math.PI * 1.5);
        if (this.FBrush.FStyle === $mod.TBrushStyle.bsSolid) this.FContext.fill();
        if (this.FPen.FStyle !== $mod.TPenStyle.psClear) this.FContext.stroke();
        this.FContext.save();
        let region = new Path2D();
        region.moveTo(X1 + X3/2, Y1 + dy);
        region.lineTo(X2 - X3/2, Y1 + dy);
        region.ellipse(X2 - dx - X3 / 2, Y1 + dy + Y3/2, X3 / 2, Y3 / 2, 0, Math.PI * 1.5, 0);
        region.lineTo(X2 + dx, Y2 - Y3/2 );
        region.ellipse(X2 - dx - X3 / 2, Y2 - dy - Y3/2, X3 / 2, Y3 / 2, 0, 0, Math.PI * 0.5);
        region.lineTo(X1 + X3/2, Y2 + dy);
        region.ellipse(X1 + dx + X3 / 2, Y2 - dy - Y3/2, X3 / 2, Y3 / 2, 0, Math.PI * 0.5, Math.PI);
        region.lineTo(X1 + dx, Y1 + Y3/2 + dy);
        region.ellipse(X1 + dx + X3 / 2, Y1 + dy + Y3/2, X3 / 2, Y3 / 2, 0, Math.PI, Math.PI * 1.5);
        this.FContext.clip(region, "evenodd");
        this.ApplyBrush(X1,Y1,X2,Y2);
        this.FContext.restore();
      };
    };
    this.RoundRect$2 = function (Rect, CX, CY) {
      this.RoundRect(Rect.Left,Rect.Top,Rect.Right,Rect.Bottom,CX,CY);
    };
    this.RoundRect$3 = function (Rect, CX, CY) {
      this.RoundRect$1(Rect.Left,Rect.Top,Rect.Right,Rect.Bottom,CX,CY);
    };
    this.FillRect = function (Rect) {
      this.Rectangle$1(Rect.Left,Rect.Top,Rect.Right,Rect.Bottom);
    };
    this.FillRect$1 = function (Rect) {
      this.Rectangle(Rect.Left,Rect.Top,Rect.Right,Rect.Bottom);
    };
    this.Arc = function (X1, Y1, X2, Y2, X3, Y3, X4, Y4) {
      var rx = 0;
      var ry = 0;
      var angleStart = 0.0;
      var angleEnd = 0.0;
      if (this.FContext != null) {
        rx = rtl.trunc((X2 - X1) / 2);
        ry = rtl.trunc((Y2 - Y1) / 2);
        angleStart = $impl.AngleOfPoints(X1 + rx,Y1 + ry,X4,Y4);
        angleEnd = $impl.AngleOfPoints(X1 + rx,Y1 + ry,X3,Y3);
        this.FContext.beginPath();
        this.ApplyStroke();
        this.FContext.ellipse(X1 + rx,Y1 + ry,rx,ry,0,angleStart,angleEnd);
        this.FContext.stroke();
      };
    };
    this.Ellipse = function (X1, Y1, X2, Y2) {
      this.Ellipse$1(X1,Y1,X2,Y2);
    };
    this.Ellipse$1 = function (X1, Y1, X2, Y2) {
      var w = 0.0;
      var h = 0.0;
      var kappa = 0.0;
      var ox = 0.0;
      var oy = 0.0;
      var xe = 0.0;
      var ye = 0.0;
      var xm = 0.0;
      var ym = 0.0;
      if (this.FContext != null) {
        w = X2 - X1;
        h = Y2 - Y1;
        kappa = 0.5522848;
        ox = (w / 2) * kappa;
        oy = (h / 2) * kappa;
        xe = X1 + w;
        ye = Y1 + h;
        xm = X1 + (w / 2);
        ym = Y1 + (h / 2);
        this.FContext.save();
        let region = new Path2D();
        region.moveTo(X1, ym);
        region.bezierCurveTo(X1, ym - oy, xm - ox, Y1, xm, Y1);
        region.bezierCurveTo(xm + ox, Y1, xe, ym - oy, xe, ym);
        region.bezierCurveTo(xe, ym + oy, xm + ox, ye, xm, ye);
        region.bezierCurveTo(xm - ox, ye, X1, ym + oy, X1, ym);
        region.closePath();
        this.FContext.clip(region, "evenodd");
        if (!(this.FBrush.FStyle in rtl.createSet($mod.TBrushStyle.bsSolid,$mod.TBrushStyle.bsClear)) && (this.FBrush.FGradient === $mod.TBrushGradient.bgNone)) this.ApplyBrush(X1,Y1,X2,Y2);
        this.FContext.restore();
        this.FContext.beginPath();
        this.ApplyStroke();
        if (this.FBrush.FGradient !== $mod.TBrushGradient.bgNone) {
          this.ApplyBrush(X1,Y1,X2,Y2);
        } else this.ApplyFill();
        this.FContext.moveTo(X1,ym);
        this.FContext.bezierCurveTo(X1,ym - oy,xm - ox,Y1,xm,Y1);
        this.FContext.bezierCurveTo(xm + ox,Y1,xe,ym - oy,xe,ym);
        this.FContext.bezierCurveTo(xe,ym + oy,xm + ox,ye,xm,ye);
        this.FContext.bezierCurveTo(xm - ox,ye,X1,ym + oy,X1,ym);
        this.FContext.closePath();
        if ((this.FBrush.FStyle === $mod.TBrushStyle.bsSolid) || (this.FBrush.FGradient !== $mod.TBrushGradient.bgNone)) this.FContext.fill();
        if (this.FPen.FStyle !== $mod.TPenStyle.psClear) this.FContext.stroke();
      };
    };
    this.Ellipse$2 = function (Rect) {
      this.Ellipse(Rect.Left,Rect.Top,Rect.Right,Rect.Bottom);
    };
    this.Ellipse$3 = function (Rect) {
      this.Ellipse$1(Rect.Left,Rect.Top,Rect.Right,Rect.Bottom);
    };
    this.Polyline = function (Points) {
      var l = 0;
      var i = 0;
      if (this.FContext != null) {
        l = rtl.length(Points);
        if (l === 0) return;
        this.FContext.beginPath();
        this.ApplyStroke();
        i = 0;
        this.FContext.moveTo(Points[i].x,Points[i].y);
        while (i < (l - 1)) {
          i += 1;
          this.FContext.lineTo(Points[i].x,Points[i].y);
        };
        if (this.FPen.FStyle !== $mod.TPenStyle.psClear) this.FContext.stroke();
      };
    };
    this.Polyline$1 = function (Points) {
      var l = 0;
      var i = 0;
      if (this.FContext != null) {
        l = rtl.length(Points);
        if (l === 0) return;
        this.FContext.beginPath();
        this.ApplyStroke();
        i = 0;
        this.FContext.moveTo(Points[i].X,Points[i].Y);
        while (i < (l - 1)) {
          i += 1;
          this.FContext.lineTo(Points[i].X,Points[i].Y);
        };
        if (this.FPen.FStyle !== $mod.TPenStyle.psClear) this.FContext.stroke();
      };
    };
    this.Polygon = function (Points) {
      var l = 0;
      var i = 0;
      var x1 = 0;
      var y1 = 0;
      var x2 = 0;
      var y2 = 0;
      if (this.FContext != null) {
        l = rtl.length(Points);
        if (l === 0) return;
        this.FContext.beginPath();
        this.ApplyStroke();
        x1 = 0xFFFF;
        y1 = 0xFFFF;
        x2 = 0;
        y2 = 0;
        for (var $l = 0, $end = rtl.length(Points) - 1; $l <= $end; $l++) {
          i = $l;
          if (Points[i].x < x1) x1 = Points[i].x;
          if (Points[i].y < y1) y1 = Points[i].y;
          if (Points[i].x > x2) x2 = Points[i].x;
          if (Points[i].y > y2) y2 = Points[i].y;
        };
        if (this.FBrush.FGradient !== $mod.TBrushGradient.bgNone) {
          this.ApplyBrush(x1,y1,x2,y2);
        } else this.ApplyFill();
        i = 0;
        this.FContext.moveTo(Points[i].x,Points[i].y);
        while (i < (l - 1)) {
          i += 1;
          this.FContext.lineTo(Points[i].x,Points[i].y);
        };
        this.FContext.closePath();
        if (this.FBrush.FStyle !== $mod.TBrushStyle.bsClear) this.FContext.fill();
        if (this.FPen.FStyle !== $mod.TPenStyle.psClear) this.FContext.stroke();
      };
    };
    this.Polygon$1 = function (Points) {
      var l = 0;
      var i = 0;
      var x1 = 0.0;
      var y1 = 0.0;
      var x2 = 0.0;
      var y2 = 0.0;
      if (this.FContext != null) {
        l = rtl.length(Points);
        if (l === 0) return;
        this.FContext.beginPath();
        this.ApplyStroke();
        x1 = 0xFFFF;
        y1 = 0xFFFF;
        x2 = 0;
        y2 = 0;
        for (var $l = 0, $end = rtl.length(Points) - 1; $l <= $end; $l++) {
          i = $l;
          if (Points[i].X < x1) x1 = Points[i].X;
          if (Points[i].Y < y1) y1 = Points[i].Y;
          if (Points[i].X > x2) x2 = Points[i].X;
          if (Points[i].Y > y2) y2 = Points[i].Y;
        };
        if (this.FBrush.FGradient !== $mod.TBrushGradient.bgNone) {
          this.ApplyBrush(x1,y1,x2,y2)}
         else this.ApplyFill();
        i = 0;
        this.FContext.moveTo(Points[i].X,Points[i].Y);
        while (i < (l - 1)) {
          i += 1;
          this.FContext.lineTo(Points[i].X,Points[i].Y);
        };
        this.FContext.closePath();
        if (this.FBrush.FStyle !== $mod.TBrushStyle.bsClear) this.FContext.fill();
        if (this.FPen.FStyle !== $mod.TPenStyle.psClear) this.FContext.stroke();
      };
    };
    this.TextOut = function (X, Y, Text) {
      this.TextOut$1(X,Y,Text);
    };
    this.TextOut$1 = function (X, Y, Text) {
      var tm = null;
      var DrwText = "";
      if (this.FContext != null) {
        DrwText = Text.replace('\0','');
        this.FContext.fillStyle = $mod.ColorToHTML(this.FFont.FColor);
        this.FContext.font = this.FFont.ToString();
        this.FContext.textBaseline = "top";
        this.FContext.fillText(DrwText,X,Y);
        if ($mod.TFontStyle.fsUnderline in this.FFont.FStyle) {
          tm = this.FContext.measureText(DrwText);
          this.FContext.fillRect(X,Y + (this.FFont.FSize * 1.4),tm.width,1);
        };
        if ($mod.TFontStyle.fsStrikeOut in this.FFont.FStyle) {
          tm = this.FContext.measureText(DrwText);
          this.FContext.fillRect(X,Y + (this.FFont.FSize * 0.7),tm.width,1);
        };
      };
    };
    this.Draw = function (X, Y, Graphic) {
      this.Draw$1(X,Y,Graphic);
    };
    this.Draw$1 = function (X, Y, Graphic) {
      var img = null;
      if (this.FContext != null) {
        img = Graphic.Image();
        if (img != null) {
          if (Graphic.FUsedCanvas) {
            this.FContext.drawImage(Graphic.FCanvasElement,X,Y)}
           else this.FContext.drawImage(img,X,Y);
        };
      };
    };
    this.StretchDraw = function (Rect, Graphic) {
      this.StretchDraw$1($mod.TCanvasRectF.$clone($mod.CreateCanvasRectF(Rect.Left,Rect.Top,Rect.Right,Rect.Bottom)),Graphic);
    };
    this.StretchDraw$1 = function (Rect, Graphic) {
      var img = null;
      if (this.FContext != null) {
        img = Graphic.Image();
        if (img != null) {
          if (Graphic.FUsedCanvas) {
            this.FContext.drawImage(Graphic.FCanvasElement,0,0,Graphic.GetWidth(),Graphic.GetHeight(),Rect.Left,Rect.Top,Rect.Right - Rect.Left,Rect.Bottom - Rect.Top)}
           else this.FContext.drawImage(img,0,0,Graphic.GetWidth(),Graphic.GetHeight(),Rect.Left,Rect.Top,Rect.Right - Rect.Left,Rect.Bottom - Rect.Top);
        };
      };
    };
    this.DrawFocusRect = function (Rect) {
      this.DrawFocusRect$1($mod.CreateCanvasRectF(Rect.Left,Rect.Top,Rect.Right,Rect.Bottom));
    };
    this.DrawFocusRect$1 = function (Rect) {
      var ps = 0;
      ps = this.FPen.FStyle;
      this.FPen.FStyle = $mod.TPenStyle.psDot;
      this.FPen.FWidth = 1;
      this.FPen.SetColor(0);
      this.MoveTo$1(Rect.Left,Rect.Top);
      this.LineTo$1(Rect.Right,Rect.Top);
      this.LineTo$1(Rect.Right,Rect.Bottom);
      this.LineTo$1(Rect.Left,Rect.Bottom);
      this.LineTo$1(Rect.Left,Rect.Top);
      this.FPen.FStyle = ps;
    };
    this.BeginScene = function () {
      if (this.FOnBeginScene != null) this.FOnBeginScene(this);
    };
    this.EndScene = function () {
      if (this.FOnEndScene != null) this.FOnEndScene(this);
    };
    this.PathBegin = function () {
      if (this.FContext != null) this.FContext.beginPath();
    };
    this.PathClose = function () {
      if (this.FContext != null) this.FContext.closePath();
    };
    this.PathStroke = function () {
      if (this.FContext != null) {
        this.ApplyStroke();
        this.FContext.stroke();
      };
    };
    this.PathFill = function () {
      if (this.FContext != null) {
        this.ApplyFill();
        this.ApplyBrush(10,10,50,50);
        this.FContext.fill();
      };
    };
    this.PathMoveTo = function (X, Y) {
      this.PathMoveTo$1(X,Y);
    };
    this.PathMoveTo$1 = function (X, Y) {
      var dx = 0.0;
      var dy = 0.0;
      if (this.FContext != null) {
        dx = 0;
        dy = 0;
        this.GetAccuOffset(X,Y,{get: function () {
            return dx;
          }, set: function (v) {
            dx = v;
          }},{get: function () {
            return dy;
          }, set: function (v) {
            dy = v;
          }});
        this.FContext.moveTo(X + dx,Y + dy);
      };
    };
    this.PathLineTo = function (X, Y) {
      this.PathLineTo$1(X,Y);
    };
    this.PathLineTo$1 = function (X, Y) {
      var dx = 0.0;
      var dy = 0.0;
      if (this.FContext != null) {
        dx = 0;
        dy = 0;
        this.GetAccuOffset(X,Y,{get: function () {
            return dx;
          }, set: function (v) {
            dx = v;
          }},{get: function () {
            return dy;
          }, set: function (v) {
            dy = v;
          }});
        this.FContext.lineTo(X + dx,Y + dy);
      };
    };
    this.Save = function () {
      if (this.FContext != null) this.FContext.save();
    };
    this.Clip = function () {
      if (this.FContext != null) this.FContext.clip();
    };
    this.Restore = function () {
      if (this.FContext != null) this.FContext.restore();
    };
    this.Refresh = function () {
    };
    this.Clear = function () {
      if ((this.FContext != null) && (this.FElementCanvas != null)) this.FContext.clearRect(0,0,this.FElementCanvas.width,this.FElementCanvas.height);
    };
    this.Clear$1 = function (AColor) {
      var c = 0;
      var s = 0;
      this.Clear();
      if (this.FElementCanvas != null) {
        c = this.FBrush.FColor;
        s = this.FBrush.FStyle;
        this.FBrush.FColor = AColor;
        this.FBrush.FStyle = $mod.TBrushStyle.bsSolid;
        this.FillRect(pas.Types.Rect(0,0,this.FElementCanvas.width,this.FElementCanvas.height));
        this.FBrush.FColor = c;
        this.FBrush.FStyle = s;
      };
    };
    this.TextExtent = function (Text) {
      var Result = $mod.TCanvasSizeF.$new();
      Result.cx = this.TextWidth(Text);
      Result.cy = this.TextHeight(Text);
      return Result;
    };
    this.TextRect = function (ARect, Text, WordWrap, Calculate, AHorizontalAlignment, AVerticalAlignment) {
      var Result = pas.Types.TRect.$new();
      var r = $mod.TCanvasRectF.$new();
      r.$assign(this.TextRect$1($mod.TCanvasRectF.$clone($mod.CreateCanvasRectF(ARect.Left,ARect.Top,ARect.Right,ARect.Bottom)),Text,WordWrap,Calculate,AHorizontalAlignment,AVerticalAlignment));
      Result.$assign(pas.Types.Rect(Math.round(r.Left),Math.round(r.Top),Math.round(r.Right),Math.round(r.Bottom)));
      return Result;
    };
    this.TextRect$1 = function (ARect, Text, WordWrap, Calculate, AHorizontalAlignment, AVerticalAlignment) {
      var $Self = this;
      var Result = $mod.TCanvasRectF.$new();
      var i = 0;
      var s = "";
      var sn = "";
      var st = "";
      var l = 0;
      var w = 0.0;
      var mw = 0.0;
      var f = false;
      var p = 0;
      var tw = 0.0;
      var th = 0.0;
      var lcnt = 0;
      var rs = $mod.TCanvasRectF.$new();
      var fws = 0.0;
      var ths = 0.0;
      var ww = false;
      var wwx = false;
      var fx = false;
      function DrawText(AText, AWidth, AHeight) {
        if (ww) {
          var $tmp = AHorizontalAlignment;
          if ($tmp === pas.Classes.TAlignment.taCenter) {
            $Self.TextOut$1(ARect.Left + ((ARect.Right - ARect.Left - AWidth) / 2),ARect.Top,AText)}
           else if ($tmp === pas.Classes.TAlignment.taLeftJustify) {
            $Self.TextOut$1(ARect.Left,ARect.Top,AText)}
           else if ($tmp === pas.Classes.TAlignment.taRightJustify) $Self.TextOut$1(ARect.Right - AWidth,ARect.Top,AText);
        } else {
          var $tmp1 = AHorizontalAlignment;
          if ($tmp1 === pas.Classes.TAlignment.taCenter) {
            var $tmp2 = AVerticalAlignment;
            if ($tmp2 === $mod.TVerticalAlignment.taAlignTop) {
              $Self.TextOut$1(ARect.Left + ((ARect.Right - ARect.Left - AWidth) / 2),ARect.Top,AText)}
             else if ($tmp2 === $mod.TVerticalAlignment.taVerticalCenter) {
              $Self.TextOut$1(ARect.Left + ((ARect.Right - ARect.Left - AWidth) / 2),ARect.Top + ((ARect.Bottom - ARect.Top - AHeight) / 2),AText)}
             else if ($tmp2 === $mod.TVerticalAlignment.taAlignBottom) $Self.TextOut$1(ARect.Left + ((ARect.Right - ARect.Left - AWidth) / 2),ARect.Bottom - AHeight,AText);
          } else if ($tmp1 === pas.Classes.TAlignment.taLeftJustify) {
            var $tmp3 = AVerticalAlignment;
            if ($tmp3 === $mod.TVerticalAlignment.taAlignTop) {
              $Self.TextOut$1(ARect.Left,ARect.Top,AText)}
             else if ($tmp3 === $mod.TVerticalAlignment.taVerticalCenter) {
              $Self.TextOut$1(ARect.Left,ARect.Top + ((ARect.Bottom - ARect.Top - AHeight) / 2),AText)}
             else if ($tmp3 === $mod.TVerticalAlignment.taAlignBottom) $Self.TextOut$1(ARect.Left,ARect.Bottom - AHeight,AText);
          } else if ($tmp1 === pas.Classes.TAlignment.taRightJustify) {
            var $tmp4 = AVerticalAlignment;
            if ($tmp4 === $mod.TVerticalAlignment.taAlignTop) {
              $Self.TextOut$1(ARect.Right - AWidth,ARect.Top,AText)}
             else if ($tmp4 === $mod.TVerticalAlignment.taVerticalCenter) {
              $Self.TextOut$1(ARect.Right - AWidth,ARect.Top + ((ARect.Bottom - ARect.Top - AHeight) / 2),AText)}
             else if ($tmp4 === $mod.TVerticalAlignment.taAlignBottom) $Self.TextOut$1(ARect.Right - AWidth,ARect.Bottom - AHeight,AText);
          };
        };
      };
      function FindNextWord(Text, APos) {
        var Result = "";
        var l = 0;
        var i = 0;
        Result = "";
        l = Text.length;
        if (APos.get() > l) return Result;
        i = APos.get();
        while (true) {
          if (((Text.charAt(i - 1) === "\n") && (Text.charAt(i - 1 - 1) === "\r")) || ((Text.charAt(i - 1) === "\r") && (Text.charAt(i - 1 - 1) === "\n")) || (Text.charAt(i - 1) === " ")) {
            if (Text.charAt(i - 1) === " ") {
              Result = pas.System.Copy(Text,APos.get(),i - (APos.get() - 1))}
             else Result = pas.System.Copy(Text,APos.get(),i - APos.get());
            break;
          } else if ((Text.charAt(i - 1) === "\n") || (Text.charAt(i - 1) === "\r") || (Text.charAt(i - 1) === " ")) {
            Result = pas.System.Copy(Text,APos.get(),i - (APos.get() - 1));
            break;
          } else if (i >= l) {
            Result = pas.System.Copy(Text,APos.get(),i - (APos.get() - 1));
            break;
          } else i += 1;
        };
        APos.set(i + 1);
        return Result;
      };
      ww = WordWrap || (pas.System.Pos("\r",Text) > 0) || (pas.System.Pos("\n",Text) > 0);
      wwx = !WordWrap && ((pas.System.Pos("\r",Text) > 0) || (pas.System.Pos("\n",Text) > 0));
      if (!ww) {
        w = this.TextWidth(Text);
        th = this.TextHeight(Text);
        if (!Calculate) DrawText(Text,w,th);
        Result.$assign($mod.CreateCanvasRectF(ARect.Left,ARect.Top,ARect.Left + w,ARect.Top + th));
      } else {
        rs.$assign(ARect);
        mw = 0;
        i = 1;
        ths = this.FFont.FSize * 0.5;
        lcnt = 0;
        fws = 0;
        tw = 0;
        s = FindNextWord(Text,{get: function () {
            return i;
          }, set: function (v) {
            i = v;
          }});
        w = this.TextWidth(s);
        th = this.TextHeight(s) + ths;
        mw = mw + w;
        if ((s.length > 0) && (s.charAt(s.length - 1) === " ")) mw = mw + fws;
        fx = false;
        while (i <= Text.length) {
          l = s.length;
          if ((l >= 2) && (((s.charAt(l - 1) === "\n") && (s.charAt(l - 1 - 1) === "\r")) || ((s.charAt(l - 1) === "\r") && (s.charAt(l - 1 - 1) === "\n")))) {
            s = pas.System.Copy(s,1,l - 2);
            f = true;
          } else if ((l >= 1) && ((s.charAt(l - 1) === "\n") || (s.charAt(l - 1) === "\r"))) {
            s = pas.System.Copy(s,1,l - 1);
            f = true;
          } else f = false;
          sn = FindNextWord(Text,{get: function () {
              return i;
            }, set: function (v) {
              i = v;
            }});
          w = this.TextWidth(sn);
          th = Math.max(th,this.TextHeight(sn) + ths);
          if (((ARect.Left + mw + w) > ARect.Right) || f) {
            if ((s !== "") && !fx) {
              p = s.length;
              st = pas.System.Copy(s,1,p);
              lcnt += 1;
              if (mw > tw) tw = mw;
              if (!Calculate) DrawText(st,mw,th);
              mw = 0;
            };
            s = "";
            fx = false;
            if ((wwx && f) || !wwx) {
              ARect.Top = ARect.Top + th}
             else if (wwx && !f) fx = true;
            if ((pas.System.Trunc(ARect.Top) > pas.System.Trunc((ARect.Bottom - th) + ths)) && !Calculate) break;
          };
          mw = mw + w;
          if ((sn.length > 0) && (sn.charAt(sn.length - 1) === " ")) mw = mw + fws;
          s = s + sn;
        };
        if (s !== "") {
          p = s.length;
          st = pas.System.Copy(s,1,p);
          lcnt += 1;
          if (mw > tw) tw = mw;
          if (!Calculate) DrawText(st,mw,th);
        };
        Result.$assign($mod.CreateCanvasRectF(rs.Left,rs.Top,rs.Left + tw,rs.Top + (lcnt * th)));
      };
      return Result;
    };
    this.TextRect$2 = function (ARect, Text, TextFormat) {
      var Result = $mod.TCanvasRectF.$new();
      var ha = 0;
      var va = 0;
      ha = pas.Classes.TAlignment.taLeftJustify;
      va = $mod.TVerticalAlignment.taAlignTop;
      if ($mod.TTextFormats.tfCenter in TextFormat) {
        ha = pas.Classes.TAlignment.taCenter}
       else if ($mod.TTextFormats.tfRight in TextFormat) ha = pas.Classes.TAlignment.taRightJustify;
      if ($mod.TTextFormats.tfVerticalCenter in TextFormat) {
        va = $mod.TVerticalAlignment.taVerticalCenter}
       else if ($mod.TTextFormats.tfBottom in TextFormat) va = $mod.TVerticalAlignment.taAlignBottom;
      Result.$assign(this.TextRect$1($mod.TCanvasRectF.$clone(ARect),Text,$mod.TTextFormats.tfWordBreak in TextFormat,$mod.TTextFormats.tfCalcRect in TextFormat,ha,va));
      return Result;
    };
    this.TextWidth = function (Text) {
      var Result = 0.0;
      var f = "";
      var tm = null;
      if (this.FContext != null) {
        f = this.FFont.ToString();
        this.FContext.font = f;
        tm = this.FContext.measureText(Text);
        Result = tm.width;
      };
      return Result;
    };
    this.TextHeight = function (Text) {
      var Result = 0.0;
      Result = $mod.FontSizeToPx(this.FFont.FSize);
      return Result;
    };
    this.GetBase64Image = function () {
      var Result = "";
      Result = "";
      if (this.FElementCanvas != null) Result = this.FElementCanvas.toDataURL();
      return Result;
    };
    this.GetAsImage = function (AType) {
      var Result = "";
      Result = "";
      if (this.FElementCanvas != null) {
        var $tmp = AType;
        if ($tmp === $mod.TImageType.itBase64) {
          Result = this.FElementCanvas.toDataURL()}
         else if ($tmp === $mod.TImageType.itPNG) {
          Result = this.FElementCanvas.toDataURL("image/png")}
         else if ($tmp === $mod.TImageType.itJPEG) {
          Result = this.FElementCanvas.toDataURL("image/jpeg",1.0)}
         else if ($tmp === $mod.TImageType.itBMP) {
          Result = this.FElementCanvas.toDataURL("image/bmp")}
         else if ($tmp === $mod.TImageType.itGIF) {
          Result = this.FElementCanvas.toDataURL("image/gif")}
         else if ($tmp === $mod.TImageType.itSVG) Result = this.FElementCanvas.toDataURL("image/svg+xml");
      };
      return Result;
    };
    this.DownloadImage = function (AFileName, AType) {
      var s = "";
      var el = null;
      if (this.FElementCanvas != null) {
        s = this.GetAsImage(AType);
        el = document.createElement("a");
        el.setAttribute("href",s);
        if (AFileName !== "") el.setAttribute("download",AFileName);
        el.style.setProperty("display","none");
        document.body.appendChild(el);
        el.click();
        document.body.removeChild(el);
      };
    };
  });
  rtl.createClassExt(this,"TJSCSSStyleDeclarationEx",CSSStyleDeclaration,"",function () {
    this.$init = function () {
      this.filter = "";
    };
    this.$final = function () {
    };
  });
  rtl.createClassExt(this,"TJSHTMLElementEx",HTMLElement,"",function () {
    this.$init = function () {
    };
    this.$final = function () {
    };
  });
  rtl.createClassExt(this,"TJSCanvasRenderingContext2DEx",CanvasRenderingContext2D,"",function () {
    this.$init = function () {
    };
    this.$final = function () {
    };
  });
  rtl.createClass(this,"TURLPicture",pas.Classes.TPersistent,function () {
    this.$init = function () {
      pas.Classes.TPersistent.$init.call(this);
      this.FOnChange = null;
      this.FFilename = "";
      this.FData = "";
      this.FOnDataChange = null;
      this.FWidth = 0;
      this.FHeight = 0;
    };
    this.$final = function () {
      this.FOnChange = undefined;
      this.FOnDataChange = undefined;
      pas.Classes.TPersistent.$final.call(this);
    };
    this.SetData = function (Value) {
      if (this.FData !== Value) {
        this.FData = Value;
        this.DataChanged();
      };
    };
    this.GetData = function () {
      var Result = "";
      Result = this.FData;
      return Result;
    };
    this.Changed = function () {
      if (this.FOnChange != null) this.FOnChange(this);
    };
    this.DataChanged = function () {
      if (this.FOnDataChange != null) this.FOnDataChange(this);
    };
    this.LoadFromFile = function (AFileName) {
      this.FFilename = AFileName;
      this.Changed();
    };
    this.Assign = function (Source) {
      if ($mod.TURLPicture.isPrototypeOf(Source)) {
        this.FFilename = rtl.as(Source,$mod.TURLPicture).FFilename;
        this.Changed();
      } else pas.Classes.TPersistent.Assign.apply(this,arguments);
    };
    var $r = this.$rtti;
    $r.addProperty("OnChange",0,pas.Classes.$rtti["TNotifyEvent"],"FOnChange","FOnChange");
    $r.addProperty("Data",3,$mod.$rtti["TBinaryString"],"GetData","SetData");
  });
  this.$rtti.$RefToProcVar("TThumbnailCreatedProc",{procsig: rtl.newTIProcSig([["ADataURL",rtl.string]])});
  this.ColorToRGB = function (Color) {
    var Result = 0;
    Result = Color;
    return Result;
  };
  this.ColorToHex = function (c) {
    var Result = "";
    var s = "";
    s = c.toString(16);
    
        while (s.length < 6)
        {
          s = "0" + s;
        };
    Result = pas.System.Copy(s,5,2) + pas.System.Copy(s,3,2) + pas.System.Copy(s,1,2);
    return Result;
  };
  this.ColorToHTML = function (c) {
    var Result = "";
    if ((c & 0xFFFFFFFF) === -1) {
      Result = "#00000000"}
     else if ((c & 0xFF000000) !== 0) {
      Result = "#" + $mod.ColorToHex(c & 0xFFFFFF) + pas.SysUtils.IntToHex(Math.floor((c & 0xFF000000) / 16777216) & 0xFF,2);
    } else Result = "#" + $mod.ColorToHex(c);
    return Result;
  };
  this.HTMLToColor = function (s) {
    var Result = 0;
    if (pas.System.Pos("#",s) === 1) pas.System.Delete({get: function () {
        return s;
      }, set: function (v) {
        s = v;
      }},1,1);
    Result = $mod.HexToColor(s);
    return Result;
  };
  this.ColorToString = function (Color) {
    var Result = "";
    var $tmp = Color;
    if ($tmp === -1) {
      Result = "clNone"}
     else if ($tmp === 0) {
      Result = "clBlack"}
     else if ($tmp === 128) {
      Result = "clMaroon"}
     else if ($tmp === 32768) {
      Result = "clGreen"}
     else if ($tmp === 32896) {
      Result = "clOlive"}
     else if ($tmp === 8388608) {
      Result = "clNavy"}
     else if ($tmp === 8388736) {
      Result = "clPurple"}
     else if ($tmp === 8421376) {
      Result = "clTeal"}
     else if ($tmp === 8421504) {
      Result = "clGray"}
     else if ($tmp === 12632256) {
      Result = "clSilver"}
     else if ($tmp === 255) {
      Result = "clRed"}
     else if ($tmp === 65280) {
      Result = "clLime"}
     else if ($tmp === 65535) {
      Result = "clYellow"}
     else if ($tmp === 16711680) {
      Result = "clBlue"}
     else if ($tmp === 16711935) {
      Result = "clFuchsia"}
     else if ($tmp === 16776960) {
      Result = "clAqua"}
     else if ($tmp === 16777215) {
      Result = "clWhite"}
     else if ($tmp === 12698049) {
      Result = "clLtGray"}
     else if ($tmp === 8487297) {
      Result = "clDkGray"}
     else if ($tmp === 536870912) {
      Result = "clDefault"}
     else if ($tmp === 15790320) {
      Result = "clBtnFace"}
     else if ($tmp === 65793) {
      Result = "clWindowText"}
     else if ($tmp === 16711422) {
      Result = "clWindow"}
     else if ($tmp === 14120960) {
      Result = "clHighlight"}
     else if ($tmp === 197379) {
      Result = "clHighlightText"}
     else if ($tmp === 131586) {
      Result = "clInfoText"}
     else if ($tmp === 14811135) {
      Result = "clInfoBk"}
     else if ($tmp === 13743257) {
      Result = "clActiveCaption"}
     else if ($tmp === 14405055) {
      Result = "clInactiveCaption"}
     else if ($tmp === 13395456) {
      Result = "clHotLight"}
     else {
      Result = "$" + $impl.ColorToVCL(Color);
    };
    return Result;
  };
  this.StringToColor = function (S) {
    var Result = 0;
    var us = "";
    var clr = 0;
    us = pas.SysUtils.UpperCase(S);
    if (us === "CLNONE") {
      Result = -1}
     else if (us === "CLBLACK") {
      Result = 0}
     else if (us === "CLMAROON") {
      Result = 128}
     else if (us === "CLGREEN") {
      Result = 32768}
     else if (us === "CLOLIVE") {
      Result = 32896}
     else if (us === "CLNAVY") {
      Result = 8388608}
     else if (us === "CLPURPLE") {
      Result = 8388736}
     else if (us === "CLTEAL") {
      Result = 8421376}
     else if (us === "CLGRAY") {
      Result = 8421504}
     else if (us === "CLSILVER") {
      Result = 12632256}
     else if (us === "CLRED") {
      Result = 255}
     else if (us === "CLLIME") {
      Result = 65280}
     else if (us === "CLYELLOW") {
      Result = 65535}
     else if (us === "CLBLUE") {
      Result = 16711680}
     else if (us === "CLFUCHSIA") {
      Result = 16711935}
     else if (us === "CLAQUA") {
      Result = 16776960}
     else if (us === "CLWHITE") {
      Result = 16777215}
     else if (us === "CLLTGRAY") {
      Result = 12698049}
     else if (us === "CLDKGRAY") {
      Result = 8487297}
     else if (us === "CLDEFAULT") {
      Result = 536870912}
     else if (us === "CLBTNFACE") {
      Result = 15790320}
     else if (us === "CLWINDOWTEXT") {
      Result = 65793}
     else if (us === "CLWINDOW") {
      Result = 16711422}
     else if (us === "CLHIGHLIGHT") {
      Result = 14120960}
     else if (us === "CLHIGHLIGHTTEXT") {
      Result = 16777215}
     else if (us === "CLINFOTEXT") {
      Result = 131586}
     else if (us === "CLINFOBK") {
      Result = 14811135}
     else if (us === "CLACTIVECAPTION") {
      Result = 13743257}
     else if (us === "CLINACTIVECAPTION") {
      Result = 14405055}
     else if (us === "CLHOTLIGHT") {
      Result = 13395456}
     else {
      clr = $mod.HexToColor(us);
      Result = ((clr & 0xFF) << 16) | (clr & 0xFF00) | ((clr & 0xFF0000) >>> 16) | (clr & 0xFF000000);
    };
    return Result;
  };
  this.CharsetToIdent = function (ACharSet) {
    var Result = "";
    var $tmp = ACharSet;
    if ($tmp === 0) {
      Result = "ANSI_CHARSET"}
     else if ($tmp === 1) {
      Result = "DEFAULT_CHARSET"}
     else if ($tmp === 2) {
      Result = "SYMBOL_CHARSET"}
     else if ($tmp === 77) {
      Result = "MAC_CHARSET"}
     else if ($tmp === 128) {
      Result = "SHIFTJIS_CHARSET"}
     else if ($tmp === 129) {
      Result = "HANGEUL_CHARSET"}
     else if ($tmp === 130) {
      Result = "JOHAB_CHARSET"}
     else if ($tmp === 134) {
      Result = "GB2312_CHARSET"}
     else if ($tmp === 136) {
      Result = "CHINESEBIG5_CHARSET"}
     else if ($tmp === 161) {
      Result = "GREEK_CHARSET"}
     else if ($tmp === 162) {
      Result = "TURKISH_CHARSET"}
     else if ($tmp === 177) {
      Result = "HEBREW_CHARSET"}
     else if ($tmp === 178) {
      Result = "ARABIC_CHARSET"}
     else if ($tmp === 186) {
      Result = "BALTIC_CHARSET"}
     else if ($tmp === 204) {
      Result = "RUSSIAN_CHARSET"}
     else if ($tmp === 222) {
      Result = "THAI_CHARSET"}
     else if ($tmp === 238) {
      Result = "EASTEUROPE_CHARSET"}
     else if ($tmp === 255) Result = "OEM_CHARSET";
    return Result;
  };
  this.IdentToCharset = function (S) {
    var Result = 0;
    if (S === "ANSI_CHARSET") Result = 0;
    if (S === "DEFAULT_CHARSET") Result = 1;
    if (S === "SYMBOL_CHARSET") Result = 2;
    if (S === "MAC_CHARSET") Result = 77;
    if (S === "SHIFTJIS_CHARSET") Result = 128;
    if (S === "HANGEUL_CHARSET") Result = 129;
    if (S === "JOHAB_CHARSET") Result = 130;
    if (S === "GB2312_CHARSET") Result = 134;
    if (S === "CHINESEBIG5_CHARSET") Result = 136;
    if (S === "GREEK_CHARSET") Result = 161;
    if (S === "TURKISH_CHARSET") Result = 162;
    if (S === "HEBREW_CHARSET") Result = 177;
    if (S === "ARABIC_CHARSET") Result = 178;
    if (S === "BALTIC_CHARSET") Result = 186;
    if (S === "RUSSIAN_CHARSET") Result = 204;
    if (S === "THAI_CHARSET") Result = 222;
    if (S === "EASTEUROPE_CHARSET") Result = 238;
    if (S === "OEM_CHARSET") Result = 255;
    return Result;
  };
  this.FontSizeToHTML = function (sz) {
    var Result = "";
    Result = pas.SysUtils.FloatToStr(sz) + "px";
    Result = pas.SysUtils.StringReplace(Result,",",".",rtl.createSet(pas.SysUtils.TStringReplaceFlag.rfReplaceAll));
    return Result;
  };
  this.HTMLChar = function (h) {
    var Result = 0;
    pas.System.Delete({get: function () {
        return h;
      }, set: function (v) {
        h = v;
      }},1,3);
    pas.System.Delete({get: function () {
        return h;
      }, set: function (v) {
        h = v;
      }},h.length - 1,1);
    Result = pas.SysUtils.StrToInt("0x" + h);
    return Result;
  };
  this.HexToColor = function (h) {
    var Result = 0;
    var s = "";
    var i = 0;
    s = "";
    for (var $l = 1, $end = h.length; $l <= $end; $l++) {
      i = $l;
      if (((h.charAt(i - 1) >= "0") && (h.charAt(i - 1) <= "9")) || ((h.charAt(i - 1) >= "A") && (h.charAt(i - 1) <= "F")) || ((h.charAt(i - 1) >= "a") && (h.charAt(i - 1) <= "f"))) s = s + h.charAt(i - 1);
    };
    if (s.length > 6) {
      s = "$" + pas.System.Copy(s,1,2) + pas.System.Copy(s,7,2) + pas.System.Copy(s,5,2) + pas.System.Copy(s,3,2)}
     else if (s.length === 3) {
      s = "$" + pas.System.Copy(s,3,1) + pas.System.Copy(s,3,1) + pas.System.Copy(s,2,1) + pas.System.Copy(s,2,1) + pas.System.Copy(s,1,1) + pas.System.Copy(s,1,1)}
     else s = "$" + pas.System.Copy(s,5,2) + pas.System.Copy(s,3,2) + pas.System.Copy(s,1,2);
    Result = pas.SysUtils.StrToInt64(s);
    return Result;
  };
  this.RGBToColor = function (argb) {
    var Result = 0;
    var r = "";
    var g = "";
    var b = "";
    var ri = 0;
    var gi = 0;
    var bi = 0;
    var e = 0;
    Result = -1;
    argb = pas.SysUtils.Trim(argb);
    if (pas.System.Pos("RGB",pas.SysUtils.UpperCase(argb)) > 0) {
      pas.System.Delete({get: function () {
          return argb;
        }, set: function (v) {
          argb = v;
        }},1,4);
      r = pas.System.Copy(argb,1,pas.System.Pos(",",argb) - 1);
      pas.System.Delete({get: function () {
          return argb;
        }, set: function (v) {
          argb = v;
        }},1,pas.System.Pos(",",argb) + 1);
      g = pas.System.Copy(argb,1,pas.System.Pos(",",argb) - 1);
      pas.System.Delete({get: function () {
          return argb;
        }, set: function (v) {
          argb = v;
        }},1,pas.System.Pos(",",argb) + 1);
      b = pas.System.Copy(argb,1,pas.System.Pos(")",argb) - 1);
      pas.System.val$3(r,{get: function () {
          return ri;
        }, set: function (v) {
          ri = v;
        }},{get: function () {
          return e;
        }, set: function (v) {
          e = v;
        }});
      pas.System.val$3(g,{get: function () {
          return gi;
        }, set: function (v) {
          gi = v;
        }},{get: function () {
          return e;
        }, set: function (v) {
          e = v;
        }});
      pas.System.val$3(b,{get: function () {
          return bi;
        }, set: function (v) {
          bi = v;
        }},{get: function () {
          return e;
        }, set: function (v) {
          e = v;
        }});
      Result = $mod.RGB(ri,gi,bi);
    };
    return Result;
  };
  this.FontSizeToPx = function (sz) {
    var Result = 0.0;
    Result = (sz * 96) / 72;
    return Result;
  };
  this.GetRValue = function (rgb) {
    var Result = 0;
    Result = rgb & 0xFF & 255;
    return Result;
  };
  this.GetGValue = function (rgb) {
    var Result = 0;
    Result = Math.floor(rgb / 256) & 0xFF & 255;
    return Result;
  };
  this.GetBValue = function (rgb) {
    var Result = 0;
    Result = Math.floor(rgb / 65536) & 0xFF & 255;
    return Result;
  };
  this.CreateCanvasRectF = function (Left, Top, Right, Bottom) {
    var Result = $mod.TCanvasRectF.$new();
    Result.Left = Left;
    Result.Top = Top;
    Result.Right = Right;
    Result.Bottom = Bottom;
    return Result;
  };
  this.CreateCanvasPointF = function (X, Y) {
    var Result = $mod.TCanvasPointF.$new();
    Result.X = X;
    Result.Y = Y;
    return Result;
  };
  this.CreateCanvasSizeF = function (cx, cy) {
    var Result = $mod.TCanvasSizeF.$new();
    Result.cx = cx;
    Result.cy = cy;
    return Result;
  };
  this.CanvasRectF = function (Left, Top, Right, Bottom) {
    var Result = $mod.TCanvasRectF.$new();
    Result.$assign($mod.CreateCanvasRectF(Left,Top,Right,Bottom));
    return Result;
  };
  this.CanvasPointF = function (X, Y) {
    var Result = $mod.TCanvasPointF.$new();
    Result.$assign($mod.CreateCanvasPointF(X,Y));
    return Result;
  };
  this.CanvasSizeF = function (cx, cy) {
    var Result = $mod.TCanvasSizeF.$new();
    Result.$assign($mod.CreateCanvasSizeF(cx,cy));
    return Result;
  };
  this.RGB = function (r, g, b) {
    var Result = 0;
    Result = r | (g << 8) | (b << 16);
    return Result;
  };
  this.RGBA = function (r, g, b, a) {
    var Result = 0;
    Result = r | (g << 8) | (b << 16) | (a << 24);
    return Result;
  };
  this.CSSFont = function (Font) {
    var Result = "";
    var res = "";
    var fs = "";
    res = "font-family:" + Font.FName + ";";
    res = res + "font-style: normal;";
    if ($mod.TFontStyle.fsBold in Font.FStyle) res = res + "font-weight: bold;";
    if ($mod.TFontStyle.fsItalic in Font.FStyle) res = res + "font-style: italic;";
    fs = "";
    if ($mod.TFontStyle.fsUnderline in Font.FStyle) fs = fs + " underline";
    if ($mod.TFontStyle.fsStrikeOut in Font.FStyle) fs = fs + " line-through";
    if (fs !== "") res = res + "text-decoration:" + fs + ";";
    res = res + "font-size:" + pas.SysUtils.IntToStr(Font.FSize) + "pt;";
    Result = res;
    return Result;
  };
  this.CreateThumbnail = function (ADataURL, AWidth, AHeight, UseAspectRatio, ThumbnailReady) {
    var LImg = null;
    if ((AWidth <= 0) || (AHeight <= 0)) return;
    LImg = document.createElement("IMG");
    LImg.onload = function() {
    
          var w = LImg.width;
          var h = LImg.height;
    
          var neww = AWidth;
          var newh = AHeight;
    
          if (UseAspectRatio) {
            if ((w/neww) > (h/newh))
            {
              newh = h / (w/neww);
            }
            else
            {
              neww = w / (h/newh);
            }
          }
          var LCanvas = document.createElement('CANVAS');
          var ctx = LCanvas.getContext("2d");
          ctx.drawImage(LImg, 0, 0, neww, newh);
          var res = LCanvas.toDataURL("image/png");
          ThumbnailReady(res);
        };
    LImg.setAttribute("src",ADataURL);
  };
  $mod.$implcode = function () {
    rtl.createClass($impl,"TGraphicCache",pas.System.TObject,function () {
      this.$init = function () {
        pas.System.TObject.$init.call(this);
        this.FImage = null;
        this.FID = "";
      };
      this.$final = function () {
        this.FImage = undefined;
        pas.System.TObject.$final.call(this);
      };
      this.Create$1 = function (AImage, AID) {
        this.FImage = AImage;
        this.FID = AID;
        return this;
      };
    });
    rtl.createClass($impl,"TGraphicCacheList",pas.contnrs.TObjectList,function () {
      this.Find = function (AID, FImage) {
        var Result = false;
        var I = 0;
        var it = null;
        Result = false;
        for (var $l = 0, $end = this.GetCount() - 1; $l <= $end; $l++) {
          I = $l;
          it = rtl.as(this.GetItem(I),$impl.TGraphicCache);
          if ((it.FID === AID) && (it.FImage != null)) {
            FImage.set(it.FImage);
            Result = true;
            break;
          };
        };
        return Result;
      };
      this.Exists = function (AID) {
        var Result = false;
        var I = 0;
        var it = null;
        Result = false;
        for (var $l = 0, $end = this.GetCount() - 1; $l <= $end; $l++) {
          I = $l;
          it = rtl.as(this.GetItem(I),$impl.TGraphicCache);
          if ((it.FID === AID) && (it.FImage != null)) {
            Result = true;
            break;
          };
        };
        return Result;
      };
    });
    $impl.FCache = null;
    $impl.FQueue = null;
    $impl.FCacheCount = 0;
    $impl.MatrixIdentity = function () {
      var Result = $mod.TMatrix.$new();
      Result.m11 = 1;
      Result.m12 = 0;
      Result.m13 = 0;
      Result.m21 = 0;
      Result.m22 = 1;
      Result.m23 = 0;
      Result.m31 = 0;
      Result.m32 = 0;
      Result.m33 = 1;
      return Result;
    };
    $impl.GetPixelRatio = function (ACanvas) {
      var Result = 0.0;
      var res = 0.0;
      var ca = null;
      ca = ACanvas;
      var ctx = ca.FContext,
          dpr = window.devicePixelRatio || 1,
          bsr = ctx.webkitBackingStorePixelRatio ||
                ctx.mozBackingStorePixelRatio ||
                ctx.msBackingStorePixelRatio ||
                ctx.oBackingStorePixelRatio ||
                ctx.backingStorePixelRatio || 1;
      res = dpr / bsr;
      Result = res;
      return Result;
    };
    $impl.MatrixCreateScaling = function (AScaleX, AScaleY) {
      var Result = $mod.TMatrix.$new();
      Result.$assign($impl.MatrixIdentity());
      Result.m11 = AScaleX;
      Result.m22 = AScaleY;
      return Result;
    };
    $impl.MatrixMultiply = function (AMatrix1, AMatrix2) {
      var Result = $mod.TMatrix.$new();
      Result.m11 = (AMatrix1.m11 * AMatrix2.m11) + (AMatrix1.m12 * AMatrix2.m21) + (AMatrix1.m13 * AMatrix2.m31);
      Result.m12 = (AMatrix1.m11 * AMatrix2.m12) + (AMatrix1.m12 * AMatrix2.m22) + (AMatrix1.m13 * AMatrix2.m32);
      Result.m13 = (AMatrix1.m11 * AMatrix2.m13) + (AMatrix1.m12 * AMatrix2.m23) + (AMatrix1.m13 * AMatrix2.m33);
      Result.m21 = (AMatrix1.m21 * AMatrix2.m11) + (AMatrix1.m22 * AMatrix2.m21) + (AMatrix1.m23 * AMatrix2.m31);
      Result.m22 = (AMatrix1.m21 * AMatrix2.m12) + (AMatrix1.m22 * AMatrix2.m22) + (AMatrix1.m23 * AMatrix2.m32);
      Result.m23 = (AMatrix1.m21 * AMatrix2.m13) + (AMatrix1.m22 * AMatrix2.m23) + (AMatrix1.m23 * AMatrix2.m33);
      Result.m31 = (AMatrix1.m31 * AMatrix2.m11) + (AMatrix1.m32 * AMatrix2.m21) + (AMatrix1.m33 * AMatrix2.m31);
      Result.m32 = (AMatrix1.m31 * AMatrix2.m12) + (AMatrix1.m32 * AMatrix2.m22) + (AMatrix1.m33 * AMatrix2.m32);
      Result.m33 = (AMatrix1.m31 * AMatrix2.m13) + (AMatrix1.m32 * AMatrix2.m23) + (AMatrix1.m33 * AMatrix2.m33);
      return Result;
    };
    $impl.ColorToVCL = function (c) {
      var Result = "";
      var s = "";
      s = c.toString(16);
      while (s.length < 6)
      {
        s = "0" + s;
      };
      Result = pas.System.Copy(s,1,2) + pas.System.Copy(s,3,2) + pas.System.Copy(s,5,2);
      return Result;
    };
    $impl.AngleOfPoints = function (x1, y1, x2, y2) {
      var Result = 0.0;
      var part1 = 0.0;
      var part2 = 0.0;
      var angle = 0.0;
      if ((x1 === x2) && (y1 === y2)) {
        Result = 0.0;
        return Result;
      };
      part1 = Math.abs(y2 - y1);
      if (part1 === 0) {
        part1 = 0.0000001;
        y1 = y1 + 0.0000001;
      };
      part2 = Math.abs(x2 - x1);
      if (part2 === 0) {
        part2 = 0.0000001;
        x1 = x1 + 0.0000001;
      };
      angle = Math.atan(part1 / part2);
      if ((x1 > x2) && (y1 < y2)) angle = Math.PI - angle;
      if ((x1 > x2) && (y1 > y2)) angle = angle + Math.PI;
      if ((x1 < x2) && (y1 > y2)) angle = (2 * Math.PI) - angle;
      while (angle >= (2 * Math.PI)) angle = angle - (2 * Math.PI);
      while (angle < 0) angle = angle + (2 * Math.PI);
      Result = angle;
      return Result;
    };
  };
  $mod.$init = function () {
    $impl.FCache = $impl.TGraphicCacheList.$create("Create$2");
    $impl.FQueue = pas.Classes.TStringList.$create("Create$1");
  };
},["WEBLib.Forms","WEBLib.WebTools","Math","SysUtils","contnrs"]);
rtl.module("WEBLib.Modules",["System","Classes"],function () {
  "use strict";
  var $mod = this;
  this.$rtti.$Class("TDataModule");
  this.$rtti.$ClassRef("TDataModuleClass",{instancetype: this.$rtti["TDataModule"]});
  rtl.createClass(this,"TDataModule",pas.Classes.TComponent,function () {
    this.$init = function () {
      pas.Classes.TComponent.$init.call(this);
      this.FHeight = 0;
      this.FOldCreateOrder = false;
      this.FOnCreate = null;
      this.FOnDestroy = null;
      this.FWidth = 0;
    };
    this.$final = function () {
      this.FOnCreate = undefined;
      this.FOnDestroy = undefined;
      pas.Classes.TComponent.$final.call(this);
    };
    this.DoCreate = function () {
      this.LoadDFMValues();
      if (this.FOnCreate != null) this.FOnCreate(this);
    };
    this.DoDestroy = function () {
      if (this.FOnDestroy != null) this.FOnDestroy(this);
    };
    this.LoadDFMValues = function () {
    };
    this.CreateNew = function (AOwner, Dummy) {
      pas.Classes.TComponent.Create$1.call(this,AOwner);
      return this;
    };
    this.AfterConstruction = function () {
      pas.System.TObject.AfterConstruction.call(this);
      if (!this.FOldCreateOrder) this.DoCreate();
    };
    this.BeforeDestruction = function () {
      pas.Classes.TComponent.BeforeDestruction.call(this);
      if (!this.FOldCreateOrder) this.DoDestroy();
    };
    rtl.addIntf(this,pas.System.IUnknown);
    var $r = this.$rtti;
    $r.addMethod("CreateNew",2,[["AOwner",pas.Classes.$rtti["TComponent"]],["Dummy",rtl.longint]]);
    $r.addProperty("OnCreate",0,pas.Classes.$rtti["TNotifyEvent"],"FOnCreate","FOnCreate");
    $r.addProperty("OnDestroy",0,pas.Classes.$rtti["TNotifyEvent"],"FOnDestroy","FOnDestroy");
  });
});
rtl.module("WEBLib.Lang",["System"],function () {
  "use strict";
  var $mod = this;
  this.TUILanguage = {"0": "lNone", lNone: 0, "1": "lAfar", lAfar: 1, "2": "lAbkhazian", lAbkhazian: 2, "3": "lAvestan", lAvestan: 3, "4": "lAfrikaans", lAfrikaans: 4, "5": "lAkan", lAkan: 5, "6": "lAmharic", lAmharic: 6, "7": "lAragonese", lAragonese: 7, "8": "lArabic", lArabic: 8, "9": "lAssamese", lAssamese: 9, "10": "lAvaric", lAvaric: 10, "11": "lAymara", lAymara: 11, "12": "lAzerbaijani", lAzerbaijani: 12, "13": "lBashkir", lBashkir: 13, "14": "lBelarusian", lBelarusian: 14, "15": "lBulgarian", lBulgarian: 15, "16": "lBihari", lBihari: 16, "17": "lBislama", lBislama: 17, "18": "lBambara", lBambara: 18, "19": "lBengali", lBengali: 19, "20": "lTibetan", lTibetan: 20, "21": "lBreton", lBreton: 21, "22": "lBosnian", lBosnian: 22, "23": "lCatalan", lCatalan: 23, "24": "lChechen", lChechen: 24, "25": "lChamorro", lChamorro: 25, "26": "lCorsican", lCorsican: 26, "27": "lCree", lCree: 27, "28": "lCzech", lCzech: 28, "29": "lOldSlavic", lOldSlavic: 29, "30": "lChuvash", lChuvash: 30, "31": "lWelsh", lWelsh: 31, "32": "lDanish", lDanish: 32, "33": "lGerman", lGerman: 33, "34": "lDivehi", lDivehi: 34, "35": "lDzongkha", lDzongkha: 35, "36": "lEwe", lEwe: 36, "37": "lEnglish", lEnglish: 37, "38": "lEsperanto", lEsperanto: 38, "39": "lSpanish", lSpanish: 39, "40": "lEstonian", lEstonian: 40, "41": "lBasque", lBasque: 41, "42": "lPersian", lPersian: 42, "43": "lFulah", lFulah: 43, "44": "lFinnish", lFinnish: 44, "45": "lFijian", lFijian: 45, "46": "lFaroese", lFaroese: 46, "47": "lFrench", lFrench: 47, "48": "lWesternFrisian", lWesternFrisian: 48, "49": "lIrish", lIrish: 49, "50": "lGaelic", lGaelic: 50, "51": "lGalician", lGalician: 51, "52": "lGuarani", lGuarani: 52, "53": "lGujarati", lGujarati: 53, "54": "lManx", lManx: 54, "55": "lHausa", lHausa: 55, "56": "lHebrew", lHebrew: 56, "57": "lHindi", lHindi: 57, "58": "lHiriMotu", lHiriMotu: 58, "59": "lCroatian", lCroatian: 59, "60": "lHaitian", lHaitian: 60, "61": "lHungarian", lHungarian: 61, "62": "lArmenian", lArmenian: 62, "63": "lHerero", lHerero: 63, "64": "lInterlingua", lInterlingua: 64, "65": "lIndonesian", lIndonesian: 65, "66": "lInterlingue", lInterlingue: 66, "67": "lIgbo", lIgbo: 67, "68": "lSichuanYi", lSichuanYi: 68, "69": "lInupiaq", lInupiaq: 69, "70": "lIdo", lIdo: 70, "71": "lIcelandic", lIcelandic: 71, "72": "lItalian", lItalian: 72, "73": "lInuktitut", lInuktitut: 73, "74": "lJapanese", lJapanese: 74, "75": "lJavanese", lJavanese: 75, "76": "lGeorgian", lGeorgian: 76, "77": "lKongo", lKongo: 77, "78": "lKikuyu", lKikuyu: 78, "79": "lKuanyama", lKuanyama: 79, "80": "lKazakh", lKazakh: 80, "81": "lKalaallisut", lKalaallisut: 81, "82": "lCentralKhmer", lCentralKhmer: 82, "83": "lKannada", lKannada: 83, "84": "lKorean", lKorean: 84, "85": "lKanuri", lKanuri: 85, "86": "lKashmiri", lKashmiri: 86, "87": "lKurdish", lKurdish: 87, "88": "lKomi", lKomi: 88, "89": "lCornish", lCornish: 89, "90": "lKirghiz", lKirghiz: 90, "91": "lLatin", lLatin: 91, "92": "lLuxembourgish", lLuxembourgish: 92, "93": "lGanda", lGanda: 93, "94": "lLimburgan", lLimburgan: 94, "95": "lLingala", lLingala: 95, "96": "lLao", lLao: 96, "97": "lLithuanian", lLithuanian: 97, "98": "lLubaKatanga", lLubaKatanga: 98, "99": "lLatvian", lLatvian: 99, "100": "lMalagasy", lMalagasy: 100, "101": "lMarshallese", lMarshallese: 101, "102": "lMaori", lMaori: 102, "103": "lMacedonian", lMacedonian: 103, "104": "lMalayalam", lMalayalam: 104, "105": "lMongolian", lMongolian: 105, "106": "lMarathi", lMarathi: 106, "107": "lMalay", lMalay: 107, "108": "lMaltese", lMaltese: 108, "109": "lBurmese", lBurmese: 109, "110": "lNauru", lNauru: 110, "111": "lNdebele", lNdebele: 111, "112": "lNepali", lNepali: 112, "113": "lNdonga", lNdonga: 113, "114": "lDutch", lDutch: 114, "115": "lNorwegian", lNorwegian: 115, "116": "lNavajo", lNavajo: 116, "117": "lChichewa", lChichewa: 117, "118": "lOccitan", lOccitan: 118, "119": "lOjibwa", lOjibwa: 119, "120": "lOromo", lOromo: 120, "121": "lOriya", lOriya: 121, "122": "lOssetian", lOssetian: 122, "123": "lPanjabi", lPanjabi: 123, "124": "lPali", lPali: 124, "125": "lPolish", lPolish: 125, "126": "lPushto", lPushto: 126, "127": "lPortuguese", lPortuguese: 127, "128": "lQuechua", lQuechua: 128, "129": "lRomansh", lRomansh: 129, "130": "lRundi", lRundi: 130, "131": "lRomanian", lRomanian: 131, "132": "lRussian", lRussian: 132, "133": "lKinyarwanda", lKinyarwanda: 133, "134": "lSanskrit", lSanskrit: 134, "135": "lSardinian", lSardinian: 135, "136": "lSindhi", lSindhi: 136, "137": "lNorthernSami", lNorthernSami: 137, "138": "lSango", lSango: 138, "139": "lSinhala", lSinhala: 139, "140": "lSlovak", lSlovak: 140, "141": "lSlovenian", lSlovenian: 141, "142": "lSamoan", lSamoan: 142, "143": "lShona", lShona: 143, "144": "lSomali", lSomali: 144, "145": "lAlbanian", lAlbanian: 145, "146": "lSerbian", lSerbian: 146, "147": "lSwati", lSwati: 147, "148": "lSotho", lSotho: 148, "149": "lSundanese", lSundanese: 149, "150": "lSwedish", lSwedish: 150, "151": "lSwahili", lSwahili: 151, "152": "lTamil", lTamil: 152, "153": "lTelugu", lTelugu: 153, "154": "lTajik", lTajik: 154, "155": "lThai", lThai: 155, "156": "lTigrinya", lTigrinya: 156, "157": "lTurkmen", lTurkmen: 157, "158": "lTagalog", lTagalog: 158, "159": "lTswana", lTswana: 159, "160": "lTonga", lTonga: 160, "161": "lTurkish", lTurkish: 161, "162": "lTsonga", lTsonga: 162, "163": "lTatar", lTatar: 163, "164": "lTwi", lTwi: 164, "165": "lTahitian", lTahitian: 165, "166": "lUighur", lUighur: 166, "167": "lUkrainian", lUkrainian: 167, "168": "lUrdu", lUrdu: 168, "169": "lUzbek", lUzbek: 169, "170": "lVenda", lVenda: 170, "171": "lVietnamese", lVietnamese: 171, "172": "lWalloon", lWalloon: 172, "173": "lWolof", lWolof: 173, "174": "lXhosa", lXhosa: 174, "175": "lYiddish", lYiddish: 175, "176": "lYoruba", lYoruba: 176, "177": "lZhuang", lZhuang: 177, "178": "lChinese", lChinese: 178, "179": "lZulu", lZulu: 179};
  this.$rtti.$Enum("TUILanguage",{minvalue: 0, maxvalue: 179, ordtype: 1, enumtype: this.TUILanguage});
  this.GetLanguageISO639_1Code = function (ALang) {
    var Result = "";
    var $tmp = ALang;
    if ($tmp === $mod.TUILanguage.lNone) {
      Result = ""}
     else if ($tmp === $mod.TUILanguage.lAfar) {
      Result = "aa"}
     else if ($tmp === $mod.TUILanguage.lAbkhazian) {
      Result = "ab"}
     else if ($tmp === $mod.TUILanguage.lAvestan) {
      Result = "ae"}
     else if ($tmp === $mod.TUILanguage.lAfrikaans) {
      Result = "af"}
     else if ($tmp === $mod.TUILanguage.lAkan) {
      Result = "ak"}
     else if ($tmp === $mod.TUILanguage.lAmharic) {
      Result = "am"}
     else if ($tmp === $mod.TUILanguage.lAragonese) {
      Result = "an"}
     else if ($tmp === $mod.TUILanguage.lArabic) {
      Result = "ar"}
     else if ($tmp === $mod.TUILanguage.lAssamese) {
      Result = "as"}
     else if ($tmp === $mod.TUILanguage.lAvaric) {
      Result = "av"}
     else if ($tmp === $mod.TUILanguage.lAymara) {
      Result = "ay"}
     else if ($tmp === $mod.TUILanguage.lAzerbaijani) {
      Result = "az"}
     else if ($tmp === $mod.TUILanguage.lBashkir) {
      Result = "ba"}
     else if ($tmp === $mod.TUILanguage.lBelarusian) {
      Result = "be"}
     else if ($tmp === $mod.TUILanguage.lBulgarian) {
      Result = "bg"}
     else if ($tmp === $mod.TUILanguage.lBihari) {
      Result = "bh"}
     else if ($tmp === $mod.TUILanguage.lBislama) {
      Result = "bi"}
     else if ($tmp === $mod.TUILanguage.lBambara) {
      Result = "bm"}
     else if ($tmp === $mod.TUILanguage.lBengali) {
      Result = "bn"}
     else if ($tmp === $mod.TUILanguage.lTibetan) {
      Result = "bo"}
     else if ($tmp === $mod.TUILanguage.lBreton) {
      Result = "br"}
     else if ($tmp === $mod.TUILanguage.lBosnian) {
      Result = "bd"}
     else if ($tmp === $mod.TUILanguage.lCatalan) {
      Result = "ca"}
     else if ($tmp === $mod.TUILanguage.lChechen) {
      Result = "ce"}
     else if ($tmp === $mod.TUILanguage.lChamorro) {
      Result = "ch"}
     else if ($tmp === $mod.TUILanguage.lCorsican) {
      Result = "co"}
     else if ($tmp === $mod.TUILanguage.lCree) {
      Result = "cr"}
     else if ($tmp === $mod.TUILanguage.lCzech) {
      Result = "cs"}
     else if ($tmp === $mod.TUILanguage.lOldSlavic) {
      Result = "cu"}
     else if ($tmp === $mod.TUILanguage.lChuvash) {
      Result = "cv"}
     else if ($tmp === $mod.TUILanguage.lWelsh) {
      Result = "cy"}
     else if ($tmp === $mod.TUILanguage.lDanish) {
      Result = "da"}
     else if ($tmp === $mod.TUILanguage.lGerman) {
      Result = "de"}
     else if ($tmp === $mod.TUILanguage.lDivehi) {
      Result = "dv"}
     else if ($tmp === $mod.TUILanguage.lDzongkha) {
      Result = "dz"}
     else if ($tmp === $mod.TUILanguage.lEwe) {
      Result = "ee"}
     else if ($tmp === $mod.TUILanguage.lEnglish) {
      Result = "en"}
     else if ($tmp === $mod.TUILanguage.lEsperanto) {
      Result = "eo"}
     else if ($tmp === $mod.TUILanguage.lSpanish) {
      Result = "es"}
     else if ($tmp === $mod.TUILanguage.lEstonian) {
      Result = "et"}
     else if ($tmp === $mod.TUILanguage.lBasque) {
      Result = "eu"}
     else if ($tmp === $mod.TUILanguage.lPersian) {
      Result = "fa"}
     else if ($tmp === $mod.TUILanguage.lFulah) {
      Result = "ff"}
     else if ($tmp === $mod.TUILanguage.lFinnish) {
      Result = "fi"}
     else if ($tmp === $mod.TUILanguage.lFijian) {
      Result = "fj"}
     else if ($tmp === $mod.TUILanguage.lFaroese) {
      Result = "fo"}
     else if ($tmp === $mod.TUILanguage.lFrench) {
      Result = "fr"}
     else if ($tmp === $mod.TUILanguage.lWesternFrisian) {
      Result = "fy"}
     else if ($tmp === $mod.TUILanguage.lIrish) {
      Result = "ga"}
     else if ($tmp === $mod.TUILanguage.lGaelic) {
      Result = "gd"}
     else if ($tmp === $mod.TUILanguage.lGalician) {
      Result = "gl"}
     else if ($tmp === $mod.TUILanguage.lGuarani) {
      Result = "gn"}
     else if ($tmp === $mod.TUILanguage.lGujarati) {
      Result = "gu"}
     else if ($tmp === $mod.TUILanguage.lManx) {
      Result = "gv"}
     else if ($tmp === $mod.TUILanguage.lHausa) {
      Result = "ha"}
     else if ($tmp === $mod.TUILanguage.lHebrew) {
      Result = "he"}
     else if ($tmp === $mod.TUILanguage.lHindi) {
      Result = "hi"}
     else if ($tmp === $mod.TUILanguage.lHiriMotu) {
      Result = "ho"}
     else if ($tmp === $mod.TUILanguage.lCroatian) {
      Result = "hr"}
     else if ($tmp === $mod.TUILanguage.lHaitian) {
      Result = "ht"}
     else if ($tmp === $mod.TUILanguage.lHungarian) {
      Result = "hu"}
     else if ($tmp === $mod.TUILanguage.lArmenian) {
      Result = "hy"}
     else if ($tmp === $mod.TUILanguage.lHerero) {
      Result = "hz"}
     else if ($tmp === $mod.TUILanguage.lInterlingua) {
      Result = "ia"}
     else if ($tmp === $mod.TUILanguage.lIndonesian) {
      Result = "id"}
     else if ($tmp === $mod.TUILanguage.lInterlingue) {
      Result = "ie"}
     else if ($tmp === $mod.TUILanguage.lIgbo) {
      Result = "ig"}
     else if ($tmp === $mod.TUILanguage.lSichuanYi) {
      Result = "ii"}
     else if ($tmp === $mod.TUILanguage.lInupiaq) {
      Result = "ik"}
     else if ($tmp === $mod.TUILanguage.lIdo) {
      Result = "id"}
     else if ($tmp === $mod.TUILanguage.lIcelandic) {
      Result = "is"}
     else if ($tmp === $mod.TUILanguage.lItalian) {
      Result = "it"}
     else if ($tmp === $mod.TUILanguage.lInuktitut) {
      Result = "iu"}
     else if ($tmp === $mod.TUILanguage.lJapanese) {
      Result = "ja"}
     else if ($tmp === $mod.TUILanguage.lJavanese) {
      Result = "jv"}
     else if ($tmp === $mod.TUILanguage.lGeorgian) {
      Result = "ka"}
     else if ($tmp === $mod.TUILanguage.lKongo) {
      Result = "kg"}
     else if ($tmp === $mod.TUILanguage.lKikuyu) {
      Result = "ki"}
     else if ($tmp === $mod.TUILanguage.lKuanyama) {
      Result = "kj"}
     else if ($tmp === $mod.TUILanguage.lKazakh) {
      Result = "kk"}
     else if ($tmp === $mod.TUILanguage.lKalaallisut) {
      Result = "kl"}
     else if ($tmp === $mod.TUILanguage.lCentralKhmer) {
      Result = "km"}
     else if ($tmp === $mod.TUILanguage.lKannada) {
      Result = "kn"}
     else if ($tmp === $mod.TUILanguage.lKorean) {
      Result = "ko"}
     else if ($tmp === $mod.TUILanguage.lKanuri) {
      Result = "kr"}
     else if ($tmp === $mod.TUILanguage.lKashmiri) {
      Result = "ks"}
     else if ($tmp === $mod.TUILanguage.lKurdish) {
      Result = "ku"}
     else if ($tmp === $mod.TUILanguage.lKomi) {
      Result = "kv"}
     else if ($tmp === $mod.TUILanguage.lCornish) {
      Result = "kw"}
     else if ($tmp === $mod.TUILanguage.lKirghiz) {
      Result = "ky"}
     else if ($tmp === $mod.TUILanguage.lLatin) {
      Result = "la"}
     else if ($tmp === $mod.TUILanguage.lLuxembourgish) {
      Result = "lb"}
     else if ($tmp === $mod.TUILanguage.lGanda) {
      Result = "lg"}
     else if ($tmp === $mod.TUILanguage.lLimburgan) {
      Result = "li"}
     else if ($tmp === $mod.TUILanguage.lLingala) {
      Result = "ln"}
     else if ($tmp === $mod.TUILanguage.lLao) {
      Result = "lo"}
     else if ($tmp === $mod.TUILanguage.lLithuanian) {
      Result = "lt"}
     else if ($tmp === $mod.TUILanguage.lLubaKatanga) {
      Result = "lu"}
     else if ($tmp === $mod.TUILanguage.lLatvian) {
      Result = "lv"}
     else if ($tmp === $mod.TUILanguage.lMalagasy) {
      Result = "mg"}
     else if ($tmp === $mod.TUILanguage.lMarshallese) {
      Result = "mh"}
     else if ($tmp === $mod.TUILanguage.lMaori) {
      Result = "mi"}
     else if ($tmp === $mod.TUILanguage.lMacedonian) {
      Result = "mk"}
     else if ($tmp === $mod.TUILanguage.lMalayalam) {
      Result = "ml"}
     else if ($tmp === $mod.TUILanguage.lMongolian) {
      Result = "mn"}
     else if ($tmp === $mod.TUILanguage.lMarathi) {
      Result = "mr"}
     else if ($tmp === $mod.TUILanguage.lMalay) {
      Result = "ms"}
     else if ($tmp === $mod.TUILanguage.lMaltese) {
      Result = "mt"}
     else if ($tmp === $mod.TUILanguage.lBurmese) {
      Result = "my"}
     else if ($tmp === $mod.TUILanguage.lNauru) {
      Result = "na"}
     else if ($tmp === $mod.TUILanguage.lNdebele) {
      Result = "nb"}
     else if ($tmp === $mod.TUILanguage.lNepali) {
      Result = "nd"}
     else if ($tmp === $mod.TUILanguage.lNdonga) {
      Result = "ng"}
     else if ($tmp === $mod.TUILanguage.lDutch) {
      Result = "nl"}
     else if ($tmp === $mod.TUILanguage.lNorwegian) {
      Result = "no"}
     else if ($tmp === $mod.TUILanguage.lNavajo) {
      Result = "nv"}
     else if ($tmp === $mod.TUILanguage.lChichewa) {
      Result = "ny"}
     else if ($tmp === $mod.TUILanguage.lOccitan) {
      Result = "oc"}
     else if ($tmp === $mod.TUILanguage.lOjibwa) {
      Result = "oj"}
     else if ($tmp === $mod.TUILanguage.lOromo) {
      Result = "om"}
     else if ($tmp === $mod.TUILanguage.lOriya) {
      Result = "or"}
     else if ($tmp === $mod.TUILanguage.lOssetian) {
      Result = "os"}
     else if ($tmp === $mod.TUILanguage.lPanjabi) {
      Result = "pa"}
     else if ($tmp === $mod.TUILanguage.lPali) {
      Result = "pi"}
     else if ($tmp === $mod.TUILanguage.lPolish) {
      Result = "pl"}
     else if ($tmp === $mod.TUILanguage.lPushto) {
      Result = "ps"}
     else if ($tmp === $mod.TUILanguage.lPortuguese) {
      Result = "pt"}
     else if ($tmp === $mod.TUILanguage.lQuechua) {
      Result = "qu"}
     else if ($tmp === $mod.TUILanguage.lRomansh) {
      Result = "rm"}
     else if ($tmp === $mod.TUILanguage.lRundi) {
      Result = "rn"}
     else if ($tmp === $mod.TUILanguage.lRomanian) {
      Result = "ro"}
     else if ($tmp === $mod.TUILanguage.lRussian) {
      Result = "ru"}
     else if ($tmp === $mod.TUILanguage.lKinyarwanda) {
      Result = "rw"}
     else if ($tmp === $mod.TUILanguage.lSanskrit) {
      Result = "sa"}
     else if ($tmp === $mod.TUILanguage.lSardinian) {
      Result = "sc"}
     else if ($tmp === $mod.TUILanguage.lSindhi) {
      Result = "sd"}
     else if ($tmp === $mod.TUILanguage.lNorthernSami) {
      Result = "se"}
     else if ($tmp === $mod.TUILanguage.lSango) {
      Result = "sg"}
     else if ($tmp === $mod.TUILanguage.lSinhala) {
      Result = "si"}
     else if ($tmp === $mod.TUILanguage.lSlovak) {
      Result = "sk"}
     else if ($tmp === $mod.TUILanguage.lSlovenian) {
      Result = "sl"}
     else if ($tmp === $mod.TUILanguage.lSamoan) {
      Result = "sm"}
     else if ($tmp === $mod.TUILanguage.lShona) {
      Result = "sn"}
     else if ($tmp === $mod.TUILanguage.lSomali) {
      Result = "so"}
     else if ($tmp === $mod.TUILanguage.lAlbanian) {
      Result = "sq"}
     else if ($tmp === $mod.TUILanguage.lSerbian) {
      Result = "sr"}
     else if ($tmp === $mod.TUILanguage.lSwati) {
      Result = "ss"}
     else if ($tmp === $mod.TUILanguage.lSotho) {
      Result = "st"}
     else if ($tmp === $mod.TUILanguage.lSundanese) {
      Result = "su"}
     else if ($tmp === $mod.TUILanguage.lSwedish) {
      Result = "sv"}
     else if ($tmp === $mod.TUILanguage.lSwahili) {
      Result = "sw"}
     else if ($tmp === $mod.TUILanguage.lTamil) {
      Result = "ta"}
     else if ($tmp === $mod.TUILanguage.lTelugu) {
      Result = "te"}
     else if ($tmp === $mod.TUILanguage.lTajik) {
      Result = "tg"}
     else if ($tmp === $mod.TUILanguage.lThai) {
      Result = "th"}
     else if ($tmp === $mod.TUILanguage.lTigrinya) {
      Result = "ti"}
     else if ($tmp === $mod.TUILanguage.lTurkmen) {
      Result = "tk"}
     else if ($tmp === $mod.TUILanguage.lTagalog) {
      Result = "tl"}
     else if ($tmp === $mod.TUILanguage.lTswana) {
      Result = "tn"}
     else if ($tmp === $mod.TUILanguage.lTonga) {
      Result = "to"}
     else if ($tmp === $mod.TUILanguage.lTurkish) {
      Result = "tr"}
     else if ($tmp === $mod.TUILanguage.lTsonga) {
      Result = "ts"}
     else if ($tmp === $mod.TUILanguage.lTatar) {
      Result = "tt"}
     else if ($tmp === $mod.TUILanguage.lTwi) {
      Result = "tw"}
     else if ($tmp === $mod.TUILanguage.lTahitian) {
      Result = "ty"}
     else if ($tmp === $mod.TUILanguage.lUighur) {
      Result = "ug"}
     else if ($tmp === $mod.TUILanguage.lUkrainian) {
      Result = "uk"}
     else if ($tmp === $mod.TUILanguage.lUrdu) {
      Result = "ur"}
     else if ($tmp === $mod.TUILanguage.lUzbek) {
      Result = "uz"}
     else if ($tmp === $mod.TUILanguage.lVenda) {
      Result = "ve"}
     else if ($tmp === $mod.TUILanguage.lVietnamese) {
      Result = "vi"}
     else if ($tmp === $mod.TUILanguage.lWalloon) {
      Result = "wa"}
     else if ($tmp === $mod.TUILanguage.lWolof) {
      Result = "wo"}
     else if ($tmp === $mod.TUILanguage.lXhosa) {
      Result = "xh"}
     else if ($tmp === $mod.TUILanguage.lYiddish) {
      Result = "yi"}
     else if ($tmp === $mod.TUILanguage.lYoruba) {
      Result = "yo"}
     else if ($tmp === $mod.TUILanguage.lZhuang) {
      Result = "za"}
     else if ($tmp === $mod.TUILanguage.lChinese) {
      Result = "zh"}
     else if ($tmp === $mod.TUILanguage.lZulu) Result = "zu";
    return Result;
  };
});
rtl.module("WEBLib.Menus",["System","Classes","SysUtils","WEBLib.Controls","WEBLib.Graphics","Web"],function () {
  "use strict";
  var $mod = this;
  var $impl = $mod.$impl;
  this.$rtti.$Class("TMainMenu");
  this.$rtti.$Class("TMenuItem");
  this.$rtti.$Class("TCustomMainMenu");
  this.TMenuItemAutoFlag = {"0": "maAutomatic", maAutomatic: 0, "1": "maManual", maManual: 1, "2": "maParent", maParent: 2};
  this.$rtti.$Enum("TMenuItemAutoFlag",{minvalue: 0, maxvalue: 2, ordtype: 1, enumtype: this.TMenuItemAutoFlag});
  this.TMenuBreak = {"0": "mbNone", mbNone: 0, "1": "mbBreak", mbBreak: 1, "2": "mbBarBreak", mbBarBreak: 2};
  this.$rtti.$Enum("TMenuBreak",{minvalue: 0, maxvalue: 2, ordtype: 1, enumtype: this.TMenuBreak});
  this.$rtti.$Int("THelpContext",{minvalue: -2147483647, maxvalue: 2147483647, ordtype: 4});
  this.$rtti.$inherited("TShortCut",rtl.word,{});
  this.TMainMenuHamburgerMenuVisible = {"0": "hmAlways", hmAlways: 0, "1": "hmNever", hmNever: 1, "2": "hmResponsive", hmResponsive: 2};
  this.$rtti.$Enum("TMainMenuHamburgerMenuVisible",{minvalue: 0, maxvalue: 2, ordtype: 1, enumtype: this.TMainMenuHamburgerMenuVisible});
  this.$rtti.$MethodVar("TMainMenuChangeEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["Source",this.$rtti["TMenuItem"]],["Rebuild",rtl.boolean]]), methodkind: 0});
  rtl.createClass(this,"TMenuItemList",pas.Classes.TList,function () {
    this.GetItem = function (Index) {
      var Result = null;
      Result = rtl.getObject(this.Get(Index));
      return Result;
    };
    this.PutItem = function (Index, Value) {
      this.Put(Index,Value);
    };
  });
  rtl.createClass(this,"TMenuItem",pas.Classes.TComponent,function () {
    this.$init = function () {
      pas.Classes.TComponent.$init.call(this);
      this.FOwner$1 = null;
      this.FCaption = "";
      this.FItems = null;
      this.FParentItem = null;
      this.FUpdateCount = 0;
      this.FOnClick = null;
      this.FChecked = false;
      this.FEnabled = false;
      this.FDefault = false;
      this.FAutoCheck = false;
      this.FHint = "";
      this.FAutoHotkeys = 0;
      this.FRadioItem = false;
      this.FGroupIndex = 0;
      this.FVisible = false;
      this.FShortCut = 0;
      this.FBreak = 0;
      this.FImageIndex = 0;
      this.FAutoLineReduction = 0;
      this.FHelpContext = 0;
      this.FElementClassName = "";
      this.FParentMenu = null;
    };
    this.$final = function () {
      this.FOwner$1 = undefined;
      this.FItems = undefined;
      this.FParentItem = undefined;
      this.FOnClick = undefined;
      this.FParentMenu = undefined;
      pas.Classes.TComponent.$final.call(this);
    };
    this.SetChecked = function (Value) {
      var pm = null;
      var Item = null;
      var OtherItem = null;
      var MenuOwner = null;
      var I = 0;
      if (this.FChecked !== Value) {
        this.FChecked = Value;
        MenuOwner = this.FParentMenu;
        if (MenuOwner != null) {
          if ($mod.TMenuItem.isPrototypeOf(MenuOwner) && Value) {
            Item = MenuOwner;
            for (var $l = 0, $end = Item.FItems.GetCount() - 1; $l <= $end; $l++) {
              I = $l;
              OtherItem = Item.FItems.GetItem(I);
              if (OtherItem.FRadioItem && (OtherItem !== this)) OtherItem.SetChecked(false);
            };
          };
          while (!$mod.TCustomMainMenu.isPrototypeOf(MenuOwner) && (MenuOwner != null)) {
            MenuOwner = MenuOwner.FOwner;
          };
        };
        pm = this.GetParentMenu();
        if (pm != null) pm.UpdateElement();
      };
    };
    this.SetCaption = function (Value) {
      var pm = null;
      this.FCaption = Value;
      pm = this.GetParentMenu();
      if (pm != null) pm.UpdateElement();
    };
    this.SetImageIndex = function (Value) {
      var pm = null;
      this.FImageIndex = Value;
      pm = this.GetParentMenu();
      if (pm != null) pm.UpdateElement();
    };
    this.SetEnabled = function (Value) {
      if (this.FEnabled !== Value) {
        this.FEnabled = Value;
        this.GetParentMenu().UpdateElement();
      };
    };
    this.GetMenuItem = function (AIndex) {
      var Result = null;
      Result = this.FItems.GetItem(AIndex);
      return Result;
    };
    this.SetMenuItem = function (AIndex, Value) {
      this.FItems.PutItem(AIndex,Value);
    };
    this.GetCount = function () {
      var Result = 0;
      if (this.FItems === null) {
        Result = 0}
       else Result = this.FItems.GetCount();
      return Result;
    };
    this.Create$1 = function (AOwner) {
      this.FParentMenu = null;
      if ($mod.TMainMenu.isPrototypeOf(AOwner)) this.FParentMenu = AOwner;
      pas.Classes.TComponent.Create$1.call(this,AOwner);
      this.FAutoHotkeys = $mod.TMenuItemAutoFlag.maParent;
      this.FAutoLineReduction = $mod.TMenuItemAutoFlag.maParent;
      this.FImageIndex = -1;
      this.FHint = "";
      this.FCaption = "MenuItem";
      this.FChecked = false;
      this.FEnabled = true;
      this.FDefault = false;
      this.FRadioItem = false;
      this.FVisible = true;
      this.FOwner$1 = AOwner;
      return this;
    };
    this.Destroy = function () {
      var i = 0;
      var pm = null;
      var mnu = null;
      pm = this.GetParentMenu();
      if ((this.FParentItem != null) && (pm != null)) {
        pm.BeginUpdate();
        for (var $l = this.FParentItem.FItems.GetCount() - 1; $l >= 0; $l--) {
          i = $l;
          if (this.FParentItem.FItems.GetItem(i) === this) {
            this.FParentItem.FItems.Delete(i);
          };
        };
        pm.EndUpdate();
      };
      if (this.FItems != null) {
        for (var $l1 = this.FItems.GetCount() - 1; $l1 >= 0; $l1--) {
          i = $l1;
          mnu = this.FItems.GetItem(i);
          mnu.FParentItem = null;
          mnu = rtl.freeLoc(mnu);
          this.FItems.Delete(i);
        };
      };
      pas.Classes.TComponent.Destroy.call(this);
    };
    this.Assign = function (Source) {
      var i = 0;
      var srcmenu = null;
      var mnu = null;
      var pm = null;
      if ($mod.TMenuItem.isPrototypeOf(Source)) {
        srcmenu = rtl.as(Source,$mod.TMenuItem);
        this.FAutoCheck = srcmenu.FAutoCheck;
        this.FAutoHotkeys = srcmenu.FAutoHotkeys;
        this.FAutoLineReduction = srcmenu.FAutoLineReduction;
        this.FBreak = srcmenu.FBreak;
        this.FCaption = srcmenu.FCaption;
        this.FChecked = srcmenu.FChecked;
        this.FDefault = srcmenu.FDefault;
        this.FEnabled = srcmenu.FEnabled;
        this.FGroupIndex = srcmenu.FGroupIndex;
        this.FHelpContext = srcmenu.FHelpContext;
        this.FHint = srcmenu.FHint;
        this.FImageIndex = srcmenu.FImageIndex;
        this.FRadioItem = srcmenu.FRadioItem;
        this.FShortCut = srcmenu.FShortCut;
        this.FVisible = srcmenu.FVisible;
        this.FElementClassName = srcmenu.FElementClassName;
        pm = this.GetParentMenu();
        if (this.FParentItem != null) this.SetName(pm.GetUniqueName(srcmenu.FCaption));
        if (srcmenu.FItems != null) {
          if (this.FItems != null) {
            for (var $l = this.FItems.GetCount() - 1; $l >= 0; $l--) {
              i = $l;
              this.RemoveItem(this.GetParentMenu().FParent,this.FItems.GetItem(i));
            };
            this.FItems.Clear();
          } else this.FItems = $mod.TMenuItemList.$create("Create$1");
          for (var $l1 = 0, $end = srcmenu.FItems.GetCount() - 1; $l1 <= $end; $l1++) {
            i = $l1;
            mnu = $mod.TMenuItem.$create("Create$1",[pm.FOwner]);
            mnu.FParentMenu = pm;
            mnu.FParentItem = this;
            mnu.Assign(srcmenu.FItems.GetItem(i));
            this.FItems.Add(mnu);
          };
        };
      };
    };
    this.BeginUpdate$1 = function () {
      this.FUpdateCount += 1;
    };
    this.EndUpdate$1 = function () {
      if (this.FUpdateCount > 0) {
        this.FUpdateCount -= 1;
        if (this.FUpdateCount === 0) this.GetParentMenu().UpdateElement();
      };
    };
    this.SetParentComponent = function (Value) {
      pas.Classes.TComponent.SetParentComponent.apply(this,arguments);
      this.FParentMenu = Value;
      if (Value !== null) {
        if ($mod.TCustomMainMenu.isPrototypeOf(Value)) {
          if (!Value.FItems.IsChild(this)) Value.FItems.Add(this);
        } else if ($mod.TMenuItem.isPrototypeOf(Value)) {
          if (!Value.IsChild(this)) Value.Add(this);
        };
      };
    };
    this.Add = function (Item) {
      this.Insert$1(this.GetCount(),Item);
    };
    this.Insert$1 = function (Index, Item) {
      if (this.FItems === null) this.FItems = $mod.TMenuItemList.$create("Create$1");
      this.FItems.Insert(Index,Item);
      Item.FParentItem = this;
      if (Item.GetParentMenu() != null) Item.GetParentMenu().UpdateElement();
    };
    this.IsChild = function (Item) {
      var Result = false;
      var i = 0;
      Result = false;
      if (!(this.FItems != null)) return Result;
      for (var $l = 0, $end = this.FItems.GetCount() - 1; $l <= $end; $l++) {
        i = $l;
        if (this.FItems.GetItem(i) === Item) {
          Result = true;
        };
      };
      return Result;
    };
    this.GetOwner = function () {
      var Result = null;
      Result = this.FOwner$1;
      return Result;
    };
    this.GetParentMenu = function () {
      var Result = null;
      var AOwner = null;
      Result = null;
      AOwner = this.FParentMenu;
      while ((AOwner != null) && $mod.TMenuItem.isPrototypeOf(AOwner)) {
        AOwner = AOwner.FParentMenu;
      };
      if (AOwner != null) Result = AOwner;
      return Result;
    };
    this.GetChildren = function (Proc, Root) {
      var I = 0;
      if (this.FItems != null) for (var $l = 0, $end = this.FItems.GetCount() - 1; $l <= $end; $l++) {
        I = $l;
        Proc(this.FItems.GetItem(I));
      };
    };
    this.SetChildOrder = function (Child, Order) {
      var idx = 0;
      idx = this.FItems.IndexOf(Child);
      if ((idx >= 0) && (Order < this.FItems.GetCount())) {
        this.FItems.Move(idx,Order);
      };
    };
    this.RemoveItem = function (AOwner, AItem) {
      var I = 0;
      if (AItem.FItems != null) {
        for (var $l = AItem.FItems.GetCount() - 1; $l >= 0; $l--) {
          I = $l;
          this.RemoveItem(AOwner,AItem.FItems.GetItem(I));
        };
      };
      AOwner.RemoveComponent(AItem);
    };
    this.Clear = function () {
      var i = 0;
      var mnu = null;
      for (var $l = this.GetCount() - 1; $l >= 0; $l--) {
        i = $l;
        mnu = this.FItems.GetItem(i);
        if (mnu.FItems != null) mnu.FItems.Clear();
        mnu = rtl.freeLoc(mnu);
      };
    };
    this.Click = function () {
      if (this.FOnClick != null) this.FOnClick(this);
    };
    rtl.addIntf(this,pas.System.IUnknown);
    var $r = this.$rtti;
    $r.addMethod("Create$1",2,[["AOwner",pas.Classes.$rtti["TComponent"]]]);
    $r.addProperty("AutoCheck",0,rtl.boolean,"FAutoCheck","FAutoCheck",{Default: false});
    $r.addProperty("AutoHotkeys",0,$mod.$rtti["TMenuItemAutoFlag"],"FAutoHotkeys","FAutoHotkeys",{Default: $mod.TMenuItemAutoFlag.maParent});
    $r.addProperty("AutoLineReduction",0,$mod.$rtti["TMenuItemAutoFlag"],"FAutoLineReduction","FAutoLineReduction",{Default: $mod.TMenuItemAutoFlag.maParent});
    $r.addProperty("Break",0,$mod.$rtti["TMenuBreak"],"FBreak","FBreak",{Default: $mod.TMenuBreak.mbNone});
    $r.addProperty("Caption",2,rtl.string,"FCaption","SetCaption");
    $r.addProperty("Checked",2,rtl.boolean,"FChecked","SetChecked",{Default: false});
    $r.addProperty("Default",0,rtl.boolean,"FDefault","FDefault",{Default: false});
    $r.addProperty("Enabled",2,rtl.boolean,"FEnabled","SetEnabled",{Default: true});
    $r.addProperty("GroupIndex",0,rtl.byte,"FGroupIndex","FGroupIndex",{Default: 0});
    $r.addProperty("HelpContext",0,$mod.$rtti["THelpContext"],"FHelpContext","FHelpContext",{Default: 0});
    $r.addProperty("Hint",0,rtl.string,"FHint","FHint");
    $r.addProperty("ImageIndex",2,rtl.longint,"FImageIndex","SetImageIndex",{Default: -1});
    $r.addProperty("RadioItem",0,rtl.boolean,"FRadioItem","FRadioItem",{Default: false});
    $r.addProperty("ShortCut",0,$mod.$rtti["TShortCut"],"FShortCut","FShortCut",{Default: 0});
    $r.addProperty("Visible",0,rtl.boolean,"FVisible","FVisible",{Default: true});
    $r.addProperty("ElementClassName",0,pas["WEBLib.Controls"].$rtti["TElementClassName"],"FElementClassName","FElementClassName");
    $r.addProperty("OnClick",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnClick","FOnClick");
  });
  this.$rtti.$Class("TMainMenuAppearance");
  rtl.createClass(this,"THamburgerMenu",pas.Classes.TPersistent,function () {
    this.$init = function () {
      pas.Classes.TPersistent.$init.call(this);
      this.FOwner = null;
      this.FVisible = 0;
      this.FCaption = "";
      this.FBackgroundColor = 0;
      this.FCaptionColor = 0;
      this.FResponsiveMaxWidth = 0;
    };
    this.$final = function () {
      this.FOwner = undefined;
      pas.Classes.TPersistent.$final.call(this);
    };
    this.SetVisible = function (Value) {
      if (this.FVisible !== Value) {
        this.FVisible = Value;
        this.FOwner.FOwner.UpdateElement();
      };
    };
    this.SetBackgroundColor = function (Value) {
      if (this.FBackgroundColor !== Value) {
        this.FBackgroundColor = Value;
        this.FOwner.FOwner.UpdateElement();
      };
    };
    this.SetCaption = function (Value) {
      if (this.FCaption !== Value) {
        this.FCaption = Value;
        this.FOwner.FOwner.UpdateElement();
      };
    };
    this.SetCaptionColor = function (Value) {
      if (this.FCaptionColor !== Value) {
        this.FCaptionColor = Value;
        this.FOwner.FOwner.UpdateElement();
      };
    };
    this.SetResponsiveMaxWidth = function (Value) {
      if (this.FResponsiveMaxWidth !== Value) {
        this.FResponsiveMaxWidth = Value;
        this.FOwner.FOwner.UpdateElement();
      };
    };
    this.Create$1 = function (AOwner) {
      this.FBackgroundColor = 12632256;
      this.FCaption = "Menu";
      this.FCaptionColor = 16777215;
      this.FVisible = $mod.TMainMenuHamburgerMenuVisible.hmResponsive;
      this.FResponsiveMaxWidth = 768;
      this.FOwner = AOwner;
      return this;
    };
    this.Destroy = function () {
      pas.System.TObject.Destroy.call(this);
    };
    this.Assign = function (Source) {
      pas.Classes.TPersistent.Assign.apply(this,arguments);
      if ($mod.THamburgerMenu.isPrototypeOf(Source)) {
        this.FBackgroundColor = rtl.as(Source,$mod.THamburgerMenu).FBackgroundColor;
        this.FCaption = rtl.as(Source,$mod.THamburgerMenu).FCaption;
        this.FCaptionColor = rtl.as(Source,$mod.THamburgerMenu).FCaptionColor;
        this.FVisible = rtl.as(Source,$mod.THamburgerMenu).FVisible;
        this.FResponsiveMaxWidth = rtl.as(Source,$mod.THamburgerMenu).FResponsiveMaxWidth;
      };
    };
    this.GetOwner = function () {
      var Result = null;
      Result = this.FOwner;
      return Result;
    };
    var $r = this.$rtti;
    $r.addMethod("Create$1",2,[["AOwner",$mod.$rtti["TMainMenuAppearance"]]]);
    $r.addProperty("Caption",2,rtl.string,"FCaption","SetCaption");
    $r.addProperty("CaptionColor",2,pas["WEBLib.Graphics"].$rtti["TColor"],"FCaptionColor","SetCaptionColor",{Default: 16777215});
    $r.addProperty("BackgroundColor",2,pas["WEBLib.Graphics"].$rtti["TColor"],"FBackgroundColor","SetBackgroundColor",{Default: 12632256});
    $r.addProperty("Visible",2,$mod.$rtti["TMainMenuHamburgerMenuVisible"],"FVisible","SetVisible",{Default: $mod.TMainMenuHamburgerMenuVisible.hmResponsive});
    $r.addProperty("ResponsiveMaxWidth",2,rtl.longint,"FResponsiveMaxWidth","SetResponsiveMaxWidth",{Default: 768});
  });
  rtl.createClass(this,"TMainMenuAppearance",pas.Classes.TPersistent,function () {
    this.$init = function () {
      pas.Classes.TPersistent.$init.call(this);
      this.FOwner = null;
      this.FBackgroundColor = 0;
      this.FHoverFontColor = 0;
      this.FHoverColor = 0;
      this.FImageURLs = null;
      this.FHamburgerMenu = null;
      this.FImageSize = 0;
      this.FSubmenuIndicator = "";
    };
    this.$final = function () {
      this.FOwner = undefined;
      this.FImageURLs = undefined;
      this.FHamburgerMenu = undefined;
      pas.Classes.TPersistent.$final.call(this);
    };
    this.SetBackgroundColor = function (Value) {
      if (this.FBackgroundColor !== Value) {
        this.FBackgroundColor = Value;
        this.FOwner.UpdateElement();
      };
    };
    this.SetHoverColor = function (Value) {
      if (this.FHoverColor !== Value) {
        this.FHoverColor = Value;
        this.FOwner.UpdateElement();
      };
    };
    this.SetHoverFontColor = function (Value) {
      if (this.FHoverFontColor !== Value) {
        this.FHoverFontColor = Value;
        this.FOwner.UpdateElement();
      };
    };
    this.SetImageURLs = function (Value) {
      this.FImageURLs.Assign(Value);
    };
    this.SetImageSize = function (Value) {
      if (this.FImageSize !== Value) {
        this.FImageSize = Value;
        this.FOwner.UpdateElement();
      };
    };
    this.SetSubmenuIndicator = function (Value) {
      if (this.FSubmenuIndicator !== Value) {
        this.FSubmenuIndicator = Value;
        this.FOwner.UpdateElement();
      };
    };
    this.HandleImageURLsChanged = function (Sender) {
      this.FOwner.UpdateElement();
    };
    this.Create$1 = function (AOwner) {
      this.FBackgroundColor = 0xF0F0F0;
      this.FHoverColor = 14120960;
      this.FHoverFontColor = 197379;
      this.FHamburgerMenu = $mod.THamburgerMenu.$create("Create$1",[this]);
      this.FImageURLs = pas.Classes.TStringList.$create("Create$1");
      this.FImageURLs.SetSkipLastLineBreak(true);
      this.FImageURLs.FOnChange = rtl.createCallback(this,"HandleImageURLsChanged");
      this.FImageSize = 16;
      this.FSubmenuIndicator = "&#9658;";
      this.FOwner = AOwner;
      return this;
    };
    this.Destroy = function () {
      rtl.free(this,"FHamburgerMenu");
      rtl.free(this,"FImageURLs");
      pas.System.TObject.Destroy.call(this);
    };
    this.Assign = function (Source) {
      pas.Classes.TPersistent.Assign.apply(this,arguments);
      if ($mod.TMainMenuAppearance.isPrototypeOf(Source)) {
        this.FBackgroundColor = rtl.as(Source,$mod.TMainMenuAppearance).FBackgroundColor;
        this.FHoverColor = rtl.as(Source,$mod.TMainMenuAppearance).FHoverColor;
        this.FHoverFontColor = rtl.as(Source,$mod.TMainMenuAppearance).FHoverFontColor;
        this.FHamburgerMenu.Assign(rtl.as(Source,$mod.TMainMenuAppearance).FHamburgerMenu);
        this.FImageURLs.Assign(rtl.as(Source,$mod.TMainMenuAppearance).FImageURLs);
        this.FImageSize = rtl.as(Source,$mod.TMainMenuAppearance).FImageSize;
        this.FSubmenuIndicator = rtl.as(Source,$mod.TMainMenuAppearance).FSubmenuIndicator;
      };
    };
    this.GetOwner = function () {
      var Result = null;
      Result = this.FOwner;
      return Result;
    };
    var $r = this.$rtti;
    $r.addMethod("Create$1",2,[["AOwner",$mod.$rtti["TMainMenu"]]]);
    $r.addProperty("BackgroundColor",2,pas["WEBLib.Graphics"].$rtti["TColor"],"FBackgroundColor","SetBackgroundColor",{Default: 15790320});
    $r.addProperty("HamburgerMenu",0,$mod.$rtti["THamburgerMenu"],"FHamburgerMenu","FHamburgerMenu");
    $r.addProperty("HoverColor",2,pas["WEBLib.Graphics"].$rtti["TColor"],"FHoverColor","SetHoverColor",{Default: 14120960});
    $r.addProperty("HoverFontColor",2,pas["WEBLib.Graphics"].$rtti["TColor"],"FHoverFontColor","SetHoverFontColor",{Default: 197379});
    $r.addProperty("ImageURLs",2,pas.Classes.$rtti["TStringList"],"FImageURLs","SetImageURLs");
    $r.addProperty("ImageSize",2,rtl.longint,"FImageSize","SetImageSize",{Default: 16});
    $r.addProperty("SubmenuIndicator",2,rtl.string,"FSubmenuIndicator","SetSubmenuIndicator");
  });
  rtl.createClass(this,"TCustomMainMenu",pas["WEBLib.Controls"].TCustomControl,function () {
    this.$init = function () {
      pas["WEBLib.Controls"].TCustomControl.$init.call(this);
      this.FItems = null;
      this.FOnChange = null;
    };
    this.$final = function () {
      this.FItems = undefined;
      this.FOnChange = undefined;
      pas["WEBLib.Controls"].TCustomControl.$final.call(this);
    };
    this.Loaded = function () {
      pas["WEBLib.Controls"].TCustomControl.Loaded.call(this);
      if (this.IsUpdating()) return;
      if (this.GetElementHandle() != null) this.UpdateElement();
    };
    this.UpdateElement = function () {
      pas["WEBLib.Controls"].TControl.UpdateElement.call(this);
      if (this.IsUpdating()) return;
    };
    this.GetUniqueName = function (AName) {
      var Result = "";
      var i = 0;
      var id = 0;
      var found = false;
      id = 1;
      if (AName === "") AName = this.FName + "item";
      AName = $impl.MakeValidName(AName);
      do {
        Result = AName + pas.SysUtils.IntToStr(id);
        found = true;
        for (var $l = 0, $end = this.FOwner.GetComponentCount() - 1; $l <= $end; $l++) {
          i = $l;
          if (this.FOwner.GetComponent(i).FName === Result) {
            found = false;
            id += 1;
            break;
          };
        };
      } while (!found);
      return Result;
    };
    this.SetName = function (NewName) {
      pas["WEBLib.Controls"].TCustomControl.SetName.apply(this,arguments);
      if (this.IsUpdating()) return;
      if (pas.Classes.TComponentStateItem.csLoading in this.FComponentState) return;
      this.UpdateElement();
    };
    this.CreateInitialize = function () {
      pas["WEBLib.Controls"].TCustomControl.CreateInitialize.call(this);
      this.FItems = $mod.TMenuItem.$create("Create$1",[this]);
      this.FItems.FParentMenu = this;
      this.SetWidthStyle(pas["WEBLib.Controls"].TSizeStyle.ssAuto);
      this.SetHeight(30);
    };
    this.Destroy = function () {
      rtl.free(this,"FItems");
      pas["WEBLib.Controls"].TCustomControl.Destroy.call(this);
    };
    this.GetChildren = function (Proc, Root) {
      var I = 0;
      if ((this.FItems != null) && (this.FItems.FItems != null)) {
        for (var $l = 0, $end = this.FItems.FItems.GetCount() - 1; $l <= $end; $l++) {
          I = $l;
          Proc(this.FItems.FItems.GetItem(I));
        };
      };
    };
    this.SetChildOrder = function (Child, Order) {
      var idx = 0;
      idx = this.FItems.FItems.IndexOf(Child);
      if ((idx >= 0) && (Order < this.FItems.FItems.GetCount())) {
        this.FItems.FItems.Move(idx,Order);
      };
    };
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
    var $r = this.$rtti;
    $r.addProperty("Items",0,$mod.$rtti["TMenuItem"],"FItems","");
    $r.addProperty("OnChange",0,$mod.$rtti["TMainMenuChangeEvent"],"FOnChange","FOnChange");
  });
  rtl.createClass(this,"TMainMenu",this.TCustomMainMenu,function () {
    this.$init = function () {
      $mod.TCustomMainMenu.$init.call(this);
      this.FMenu = null;
      this.FMainMenu = false;
      this.FMenuIndex = 0;
      this.FAppearance = null;
      this.FContainer$1 = null;
      this.FIsPopupMenu = false;
      this.FShowPopup = false;
      this.FAutoMerge = false;
      this.FZIndex = "";
      this.FElementItemClassName = "";
    };
    this.$final = function () {
      this.FMenu = undefined;
      this.FAppearance = undefined;
      this.FContainer$1 = undefined;
      $mod.TCustomMainMenu.$final.call(this);
    };
    this.HandleChange = function (Event) {
      var Result = false;
      var h = null;
      var it = null;
      Result = true;
      if (this.FIsPopupMenu) {
        this.FShowPopup = false;
        this.UpdateElement();
      };
      h = Event.target;
      if (!h.hasAttribute("id")) h = h.parentElement;
      it = this.GetItemByName(this.FItems,h.id);
      if (it != null) {
        if (it.FAutoCheck) it.SetChecked(!it.FChecked);
        if (this.FOnChange != null) this.FOnChange(this,it,false);
        it.Click();
      };
      return Result;
    };
    this.Loaded = function () {
      $mod.TCustomMainMenu.Loaded.call(this);
      if (this.IsUpdating()) return;
      if (!(this.FContainer$1 != null) && pas["WEBLib.Forms"].TCustomForm.isPrototypeOf(this.FParent) && (rtl.as(this.FParent,pas["WEBLib.Forms"].TCustomForm).FMenu === this)) {
        this.FContainer$1 = this.FParent;
      };
      if (this.GetElementHandle() != null) this.UpdateElement();
    };
    this.UpdateElement = function () {
      var MenuStyle = "";
      var MenuColorStyle = "";
      var MenuResponsiveStyle = "";
      var MenuImageSize = "";
      var ShowPopup = "";
      var ElHandle = null;
      var ElLabel = null;
      var ElSpan = null;
      var ElIcon = null;
      var ElCheckBox = null;
      var ElStyle = null;
      var ElScript = null;
      var ElItems = null;
      $mod.TCustomMainMenu.UpdateElement.call(this);
      if (this.IsUpdating()) return;
      if (!(this.GetElementHandle() != null) && !(this.FContainer$1 != null)) return;
      if (this.FContainer$1 != null) {
        ElHandle = this.FContainer$1.GetElementHandle();
        this.SetVisible(false);
      } else {
        ElHandle = this.GetElementHandle();
        ElHandle.style.setProperty("top",pas.SysUtils.IntToStr(this.GetTop()) + "px");
        ElHandle.style.setProperty("left",pas.SysUtils.IntToStr(this.GetLeft()) + "px");
        if ((pas.Classes.TComponentStateItem.csDesigning in this.FComponentState) && !(this.FContainer$1 != null)) this.GetElementHandle().style.setProperty("background-color","silver");
      };
      this.FMenu = ElHandle.firstChild;
      if (this.FMenu != null) this.FMenu.parentElement.removeChild(this.FMenu);
      if (pas.Classes.TComponentStateItem.csDestroying in this.FComponentState) return;
      this.FMenu = document.createElement("NAV");
      this.FMenu.setAttribute("id",this.GetID() + "menu");
      this.FMenu.innerHTML = "";
      if (this.FContainer$1 != null) {
        this.FMenu.style.setProperty("top","0");
        this.FMenu.style.setProperty("left","0");
        this.FMenu.style.setProperty("position","absolute");
        this.FMenu.style.setProperty("width","100%");
        this.FMenu.style.setProperty("z-index",this.FZIndex);
      };
      ElHandle.style.setProperty("overflow","visible");
      if (this.FAppearance.FHamburgerMenu.FVisible !== $mod.TMainMenuHamburgerMenuVisible.hmAlways) {
        if (this.FShowPopup) {
          ShowPopup = "block"}
         else ShowPopup = "none";
        MenuResponsiveStyle = "  #" + this.GetID() + "menu .main-menu {\r" + "    display: block;\r" + "  }\r" + "  #" + this.GetID() + "menu #toggle-menu {\r" + "    display: none;\r" + "  }\r" + "  #" + this.GetID() + "menu ul span.drop-label {\r" + "    display: inline-block;\r" + "  }\r" + "  #" + this.GetID() + "menu li {\r" + "    float: left;\r" + "    border-width: 0 1px 0 0;\r" + "  }\r" + "  #" + this.GetID() + "menu .popup-menu li, \r" + "  #" + this.GetID() + "menu .sub-menu li {\r" + "    float: none;\r" + "  }\r" + "  #" + this.GetID() + "menu .sub-menu {\r" + "    top: 100%;\r" + "  }\r" + "  #" + this.GetID() + "menu .popup-menu { \r" + "    top: 0;\r" + "  }\r" + "  #" + this.GetID() + "menu .popup-menu, \r" + "  #" + this.GetID() + "menu .sub-menu {\r" + "    border-width: 0;\r" + "    margin: 0;\r" + "    position: absolute;\r" + "    left: 0;\r" + "    min-width: 12em;\r" + "    z-index: 9999999;\r" + "\t   white-space: nowrap;\r" + "  }\r" + "  #" + this.GetID() + "menu .sub-menu {\r" + "    top: 100%;\r" + "  }\r" + "  #" + this.GetID() + "menu .popup-menu { \r" + "    display: " + ShowPopup + ";\r" + "  }\r" + "  #" + this.GetID() + "menu .sub-menu,\r" + "  #" + this.GetID() + 'menu input[type="checkbox"]:checked + .popup-menu,\r' + "  #" + this.GetID() + 'menu input[type="checkbox"]:checked + .sub-menu {\r' + "    display: none;\r" + "  }\r" + "  #" + this.GetID() + "menu .popup-menu li, \r" + "  #" + this.GetID() + "menu .sub-menu li {\r" + "    border-width: 1px;\r" + "  }\r" + "  #" + this.GetID() + "menu .popup-menu .sub-menu, \r" + "  #" + this.GetID() + "menu .sub-menu .sub-menu {\r" + "    top: 0;\r" + "    left: 100%;\r" + "  }\r" + "  #" + this.GetID() + 'menu li:hover > input[type="checkbox"] + .popup-menu, \r' + "  #" + this.GetID() + 'menu li:hover > input[type="checkbox"] + .sub-menu {\r' + "    display: block;\r" + "  }\r";
        if (this.FAppearance.FHamburgerMenu.FVisible === $mod.TMainMenuHamburgerMenuVisible.hmResponsive) {
          MenuResponsiveStyle = "@media only screen and (min-width: " + pas.SysUtils.IntToStr(this.FAppearance.FHamburgerMenu.FResponsiveMaxWidth) + "px) {\r" + MenuResponsiveStyle + "}";
        };
      };
      if (this.FAppearance.FImageSize > 0) {
        MenuImageSize = "  width: " + pas.SysUtils.IntToStr(this.FAppearance.FImageSize) + "px;\r" + "  height: " + pas.SysUtils.IntToStr(this.FAppearance.FImageSize) + "px;\r";
      };
      MenuStyle = "#" + this.GetID() + "menu ul {\r" + "  margin: 0;\r" + "  padding: 0;\r" + "}\r" + "#" + this.GetID() + "menu .main-menu {\r" + "  display: none;\r" + "}\r" + "#" + this.GetID() + "menu .popup-menu {\r" + "  display: block;\r" + "}\r" + "#" + this.GetID() + "menu label img.icon," + "#" + this.GetID() + "menu label span.checked {\r" + MenuImageSize + "  margin-right: 10px;\r" + "  pointer-events: none;\r" + "}\r" + "#" + this.GetID() + "tm:checked + .main-menu {\r" + "  display: block;\r" + "}\r" + "#" + this.GetID() + 'menu input[type="checkbox"],\r' + "#" + this.GetID() + "menu ul span.drop-label {\r" + "  display: none;\r" + "}\r" + "#" + this.GetID() + "menu li,\r" + "#" + this.GetID() + "menu #toggle-menu,\r" + "#" + this.GetID() + "menu .popup-menu,\r" + "#" + this.GetID() + "menu .sub-menu {\r" + "  border-width: 1px;\r" + "  border-style: solid;\r" + "  border-color: rgba(0, 0, 0, .05);\r" + "  border-bottom: 0px;\r" + "  border-top: 0px;\r" + "}\r" + "#" + this.GetID() + "menu li,\r" + "#" + this.GetID() + "menu #toggle-menu {\r" + "  border-width: 0 0 3px;\r" + "}\r" + "#" + this.GetID() + "menu .popup-menu,\r" + "#" + this.GetID() + "menu .sub-menu {\r" + "  border-width: 1px 1px 0;\r" + "  margin: 0 1em;\r" + "}\r" + "#" + this.GetID() + "menu .popup-menu li:first-child,\r" + "#" + this.GetID() + "menu .sub-menu li:first-child {\r" + "  border-top: 1px solid;\r" + "  border-color: rgba(0, 0, 0, .05);\r" + "}\r" + "#" + this.GetID() + "menu .popup-menu li:last-child,\r" + "#" + this.GetID() + "menu .sub-menu li:last-child {\r" + "  border-bottom: 1px solid;\r" + "  border-color: rgba(0, 0, 0, .05);\r" + "}\r" + "#" + this.GetID() + "menu li,\r" + "#" + this.GetID() + "menu #toggle-menu,\r" + "#" + this.GetID() + "menu li label {\r" + "  position: relative;\r" + "  display: block;\r" + "}\r" + "#" + this.GetID() + "menu #toggle-menu,\r" + "#" + this.GetID() + "menu li label { \r" + "  padding: 0.75em 1.5em;\r" + "  text-decoration: none;\r" + "}\r" + "#" + this.GetID() + "menu li span.menu-separator { \r" + "  display: block;\r" + "  width: 100%;\r" + "  height: 1px;\r" + "  background-color: rgba(0, 0, 0, .05);\r" + "}\r" + "#" + this.GetID() + "menu .popup-menu, \r" + "#" + this.GetID() + "menu .sub-menu {\r" + "  display: none;\r" + "}\r" + "#" + this.GetID() + 'menu input[type="checkbox"]:checked + .popup-menu,\r' + "#" + this.GetID() + 'menu input[type="checkbox"]:checked + .sub-menu {\r' + "  display: block;\r" + "  z-index: 3000;\r" + "}\r" + "#" + this.GetID() + "menu span.drop-icon {\r" + "  margin-left: 10px;" + "}\r" + "#" + this.GetID() + "menu span.hamburger-icon {\r" + "  float: right;\r" + "  padding: 0;\r" + "  margin: 0;\r" + "  font-weight: 900;\r" + "}\r" + "@media only screen and (max-width: 64em) and (min-width: 52.01em) {\r" + "  #" + this.GetID() + "menu li {\r" + "    width: auto;\r" + "  }\r" + "  #" + this.GetID() + "menu .sub-menu li {\r" + "    width: auto;\r" + "  }\r" + "}\r";
      MenuColorStyle = "";
      if (this.FElementClassName === "") {
        MenuColorStyle = "#" + this.GetID() + "menu .popup-menu, \r" + "#" + this.GetID() + "menu .sub-menu {\r" + "  background-color: " + pas["WEBLib.Graphics"].ColorToHTML(this.FAppearance.FBackgroundColor) + ";\r" + "}\r" + "@media only screen and (max-width: 64em) and (min-width: 52.01em) {\r" + "#" + this.GetID() + "menu .sub-menu {\r" + "  background-color: " + pas["WEBLib.Graphics"].ColorToHTML(this.FAppearance.FHamburgerMenu.FBackgroundColor) + ";\r" + "}\r" + "}\r" + "#" + this.GetID() + "menu li,\r" + "#" + this.GetID() + "menu #toggle-menu,\r" + "#" + this.GetID() + "menu li label {\r" + "}\r" + "#" + this.GetID() + "menu #toggle-menu {\r" + "  background-color: " + pas["WEBLib.Graphics"].ColorToHTML(this.FAppearance.FHamburgerMenu.FBackgroundColor) + ";\r" + "  color: " + pas["WEBLib.Graphics"].ColorToHTML(this.FAppearance.FHamburgerMenu.FCaptionColor) + ";\r" + "}\r" + "#" + this.GetID() + "menu .main-menu li label {\r" + "  background-color: " + pas["WEBLib.Graphics"].ColorToHTML(this.FAppearance.FBackgroundColor) + ";\r" + "}\r" + "#" + this.GetID() + "menu li label:hover {\r" + "  background-color: " + pas["WEBLib.Graphics"].ColorToHTML(this.FAppearance.FHoverColor) + ";\r" + "  color: " + pas["WEBLib.Graphics"].ColorToHTML(this.FAppearance.FHoverFontColor) + ";\r" + "}\r" + "#" + this.GetID() + "menu .popup-menu label:hover, \r" + "#" + this.GetID() + "menu .sub-menu label:hover {\r" + "  background-color: " + pas["WEBLib.Graphics"].ColorToHTML(this.FAppearance.FHoverColor) + ";\r" + "  color: " + pas["WEBLib.Graphics"].ColorToHTML(this.FAppearance.FHoverFontColor) + ";\r" + "}\r";
      };
      MenuStyle = MenuStyle + MenuColorStyle + MenuResponsiveStyle;
      this.FMainMenu = true;
      this.FMenuIndex = 0;
      ElStyle = document.createElement("STYLE");
      ElStyle.innerHTML = MenuStyle;
      ElScript = document.createElement("SCRIPT");
      ElScript.innerHTML = "function " + this.GetID() + "MenuClick(ctrl){" + "  el = ctrl.parentElement.parentElement;" + '  el.style.display = "none";' + '  setTimeout(function(){el.style.removeProperty("display")}, 25);' + "}" + "function " + this.GetID() + "MenuOut(ctrl){" + '  menuel = document.getElementById("' + this.GetID() + '");' + "  if(menuel) { " + '    popupel = menuel.getElementsByClassName("popup-menu");' + "    if(popupel) " + '      setTimeout(function(){popupel[0].style.display = "none"}, 25);' + "  }" + "}";
      ElLabel = document.createElement("LABEL");
      ElLabel.setAttribute("for",this.GetID() + "tm");
      ElLabel.setAttribute("id","toggle-menu");
      ElLabel.innerHTML = this.FAppearance.FHamburgerMenu.FCaption;
      ElSpan = document.createElement("SPAN");
      if (this.FElementItemClassName !== "") {
        ElSpan.setAttribute("class",this.FElementItemClassName)}
       else ElSpan.setAttribute("class","drop-label");
      ElLabel.appendChild(ElSpan);
      ElIcon = document.createElement("SPAN");
      ElIcon.setAttribute("class","hamburger-icon");
      ElIcon.innerHTML = "&#9776;";
      ElSpan.appendChild(ElIcon);
      ElCheckBox = document.createElement("INPUT");
      ElCheckBox.setAttribute("type","checkbox");
      ElCheckBox.setAttribute("id",this.GetID() + "tm");
      this.FMenu.appendChild(ElStyle);
      this.FMenu.appendChild(ElScript);
      this.FMenu.appendChild(ElLabel);
      this.FMenu.appendChild(ElCheckBox);
      ElItems = this.GetMenuSource(this.FItems);
      if (ElItems !== null) this.FMenu.appendChild(ElItems);
      ElHandle.appendChild(this.FMenu);
    };
    this.GetMenuSource = function (Item) {
      var Result = null;
      var I = 0;
      var it = null;
      var MenuClass = "";
      var ElListItem = null;
      var ElLabel = null;
      var ElCheckBox = null;
      var ElSymbol = null;
      var id = 0;
      var caption = "";
      Result = null;
      if ((Item.FItems != null) && (Item.FItems.GetCount() > 0)) {
        Result = document.createElement("UL");
        if (this.FMainMenu) {
          this.FMainMenu = false;
          if (this.FIsPopupMenu) {
            MenuClass = "popup-menu"}
           else MenuClass = "main-menu";
        } else MenuClass = "sub-menu";
        this.FMenuIndex = this.FMenuIndex + 1;
        Result.setAttribute("class",MenuClass);
        for (var $l = 0, $end = Item.FItems.GetCount() - 1; $l <= $end; $l++) {
          I = $l;
          it = Item.FItems.GetItem(I);
          id = id + 1;
          if (it.FName === "") {
            caption = pas.SysUtils.StringReplace(it.FCaption," ","",rtl.createSet(pas.SysUtils.TStringReplaceFlag.rfReplaceAll));
            caption = $impl.MakeValidName(caption);
            if (caption === "") caption = "MenuItem" + pas.SysUtils.IntToStr(id);
            it.SetName(caption + pas.SysUtils.IntToStr(id));
          };
          if (it.FVisible) {
            ElListItem = document.createElement("LI");
            if (it.FCaption !== "-") {
              ElLabel = document.createElement("LABEL");
              if (this.FElementItemClassName !== "") {
                ElLabel.setAttribute("class",this.FElementItemClassName)}
               else ElLabel.setAttribute("class","drop-label");
              ElLabel.setAttribute("title",it.FHint);
              if ((it.FImageIndex >= 0) && (this.FAppearance.FImageURLs.GetCount() > it.FImageIndex)) {
                ElLabel.innerHTML = '<img class="icon" src="' + this.FAppearance.FImageURLs.Get(it.FImageIndex) + '">'}
               else if (it.FChecked) {
                if (it.FRadioItem) {
                  ElLabel.innerHTML = '<span class="checked">&#9679;</span>'}
                 else ElLabel.innerHTML = '<span class="checked">&#10004;</span>';
              };
              ElLabel.innerHTML = ElLabel.innerHTML + it.FCaption;
            } else {
              ElLabel = document.createElement("SPAN");
              ElLabel.setAttribute("class","menu-separator");
              ElLabel.innerHTML = "";
            };
            if ((it.FItems != null) && (it.FItems.GetCount() > 0)) {
              ElSymbol = document.createElement("SPAN");
              ElSymbol.setAttribute("class","drop-icon");
              ElSymbol.innerHTML = this.FAppearance.FSubmenuIndicator;
              ElLabel.setAttribute("for","sm" + pas.SysUtils.IntToStr(this.FMenuIndex));
              ElLabel.appendChild(ElSymbol);
              if (!it.FEnabled) ElLabel.style.setProperty("color","gray");
              ElCheckBox = document.createElement("INPUT");
              ElCheckBox.setAttribute("type","checkbox");
              ElCheckBox.setAttribute("id","sm" + pas.SysUtils.IntToStr(this.FMenuIndex));
              ElListItem.appendChild(ElLabel);
              ElListItem.appendChild(ElCheckBox);
              if (it.FEnabled) ElListItem.appendChild(this.GetMenuSource(it));
            } else {
              ElLabel.setAttribute("for",this.GetID() + "tm");
              ElLabel.setAttribute("id",it.FName);
              if (it.FEnabled) {
                if (MenuClass === "sub-menu") {
                  if (it.FEnabled) ElLabel.setAttribute("onMouseUp",this.GetID() + "MenuClick(this);");
                };
                ElLabel.addEventListener("click",rtl.createSafeCallback(this,"HandleChange"));
              } else ElLabel.style.setProperty("color","gray");
              ElListItem.appendChild(ElLabel);
            };
            Result.appendChild(ElListItem);
          };
        };
      };
      return Result;
    };
    this.GetItemByName = function (AMenu, Name) {
      var Result = null;
      var I = 0;
      var it = null;
      Result = null;
      if (AMenu.FItems != null) {
        for (var $l = 0, $end = AMenu.FItems.GetCount() - 1; $l <= $end; $l++) {
          I = $l;
          it = AMenu.FItems.GetItem(I);
          if (it.FName === Name) {
            Result = it;
            if (it.FOnClick != null) Result.FOnClick = it.FOnClick;
            return Result;
          };
          if (!(Result != null)) Result = this.GetItemByName(it,Name);
        };
      };
      return Result;
    };
    this.CreateInitialize = function () {
      $mod.TCustomMainMenu.CreateInitialize.call(this);
      this.FAppearance = $mod.TMainMenuAppearance.$create("Create$1",[this]);
      this.FContainer$1 = null;
      this.FMainMenu = true;
      this.FMenuIndex = 0;
      this.FIsPopupMenu = false;
      this.FShowPopup = false;
      this.SetTop(0);
      this.SetLeft(0);
      this.SetWidth(100);
      if (pas.Classes.TComponentStateItem.csDesigning in this.FComponentState) {
        this.SetElementPosition(pas["WEBLib.Controls"].TElementPosition.epRelative);
        this.SetWidthPercent(100);
        this.SetWidthStyle(pas["WEBLib.Controls"].TSizeStyle.ssPercent);
      };
    };
    this.CreateElement = function () {
      var Result = null;
      var LLabel = null;
      if (pas.Classes.TComponentStateItem.csDesigning in this.FComponentState) {
        Result = document.createElement("DIV");
        LLabel = document.createElement("DIV");
        LLabel.innerHTML = "TWebMainMenu";
        this.SetBorderStyle(pas["WEBLib.Controls"].TBorderStyle.bsSingle);
        LLabel.setAttribute("align","center");
        LLabel.style.setProperty("border","1px solid gray");
        LLabel.style.setProperty("vertical-align","middle");
        LLabel.style.setProperty("display","table-cell");
        Result.appendChild(LLabel);
      } else {
        Result = document.createElement("DIV");
        if (this.FIsPopupMenu) Result.setAttribute("onMouseLeave",this.GetID() + "MenuOut(this);");
      };
      this.FZIndex = pas["WEBLib.Forms"].Application.MaxZIndexStr();
      pas["WEBLib.Forms"].Application.ChangeMaxZIndex(+1);
      return Result;
    };
    this.Destroy = function () {
      rtl.free(this,"FAppearance");
      $mod.TCustomMainMenu.Destroy.call(this);
    };
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
    var $r = this.$rtti;
    $r.addProperty("Appearance",0,$mod.$rtti["TMainMenuAppearance"],"FAppearance","FAppearance");
    $r.addProperty("Container",0,pas["WEBLib.Controls"].$rtti["TControl"],"FContainer$1","FContainer$1");
    $r.addProperty("ElementFont",2,pas["WEBLib.Controls"].$rtti["TElementFont"],"FElementFont","SetElementFont",{Default: pas["WEBLib.Controls"].TElementFont.efProperty});
    $r.addProperty("ElementClassName",2,pas["WEBLib.Controls"].$rtti["TElementClassName"],"FElementClassName","SetElementClassName");
    $r.addProperty("ElementItemClassName",0,pas["WEBLib.Controls"].$rtti["TElementClassName"],"FElementItemClassName","FElementItemClassName");
    $r.addProperty("Font",2,pas["WEBLib.Graphics"].$rtti["TFont"],"FFont","SetFont");
    $r.addProperty("ParentFont",2,rtl.boolean,"FParentFont","SetParentFont",{Default: true});
  });
  rtl.createClass(this,"TWebMainMenu",this.TMainMenu,function () {
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
  });
  rtl.createClass(this,"TPopupMenu",this.TMainMenu,function () {
    this.$init = function () {
      $mod.TMainMenu.$init.call(this);
      this.FOnPopup = null;
    };
    this.$final = function () {
      this.FOnPopup = undefined;
      $mod.TMainMenu.$final.call(this);
    };
    this.Create$1 = function (AOwner) {
      pas["WEBLib.Controls"].TControl.Create$1.apply(this,arguments);
      if (pas["WEBLib.Controls"].TControl.isPrototypeOf(AOwner)) this.SetParent(AOwner);
      return this;
    };
    this.CreateInitialize = function () {
      $mod.TMainMenu.CreateInitialize.call(this);
      this.FAppearance.FHamburgerMenu.SetVisible($mod.TMainMenuHamburgerMenuVisible.hmNever);
      this.FIsPopupMenu = true;
    };
    this.Popup = function (X, Y) {
      if (this.FOnPopup != null) this.FOnPopup(this);
      this.SetTop(Y);
      this.SetLeft(X);
      this.FShowPopup = true;
      this.UpdateElement();
      this.FShowPopup = false;
    };
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
    var $r = this.$rtti;
    $r.addMethod("Create$1",2,[["AOwner",pas.Classes.$rtti["TComponent"]]]);
    $r.addProperty("OnPopup",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnPopup","FOnPopup");
  });
  rtl.createClass(this,"TWebPopupMenu",this.TPopupMenu,function () {
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
  });
  this.$rtti.$Class("TWebCustomControl");
  this.$rtti.$ClassRef("TWebCustomControlClass",{instancetype: this.$rtti["TWebCustomControl"]});
  rtl.createClass(this,"TWebCustomControl",pas["WEBLib.Controls"].TCustomControl,function () {
    this.$init = function () {
      pas["WEBLib.Controls"].TCustomControl.$init.call(this);
      this.FPopupMenu = null;
    };
    this.$final = function () {
      this.FPopupMenu = undefined;
      pas["WEBLib.Controls"].TCustomControl.$final.call(this);
    };
    this.HandleDoContextMenu = function (Event) {
      var Result = false;
      var pt = pas.Types.TPoint.$new();
      var frm = null;
      var r = null;
      pas["WEBLib.Controls"].TControl.HandleDoContextMenu.apply(this,arguments);
      if (this.FPopupMenu != null) {
        Event.stopPropagation();
        Event.preventDefault();
        pt.$assign(pas.Types.Point(Math.round(Event.clientX),Math.round(Event.clientY)));
        frm = pas["WEBLib.Forms"].GetParentForm(this);
        if ((frm != null) && (frm.GetContainer() != null)) {
          r = frm.GetContainer().getBoundingClientRect();
          pt.x = pt.x - Math.round(r.left);
          pt.y = pt.y - Math.round(r.top);
        };
        this.FPopupMenu.Popup(pt.x,pt.y);
        Result = true;
      };
      return Result;
    };
    this.Notification = function (AComponent, Operation) {
      pas.Classes.TComponent.Notification.apply(this,arguments);
      if ((Operation === pas.Classes.TOperation.opRemove) && (AComponent === this.FPopupMenu)) this.FPopupMenu = null;
    };
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
  });
  rtl.createClass(this,"TWebGraphicControl",pas["WEBLib.Controls"].TGraphicControl,function () {
    this.$init = function () {
      pas["WEBLib.Controls"].TGraphicControl.$init.call(this);
      this.FPopupMenu = null;
    };
    this.$final = function () {
      this.FPopupMenu = undefined;
      pas["WEBLib.Controls"].TGraphicControl.$final.call(this);
    };
    this.HandleDoContextMenu = function (Event) {
      var Result = false;
      var pt = pas.Types.TPoint.$new();
      var frm = null;
      var r = null;
      pas["WEBLib.Controls"].TControl.HandleDoContextMenu.apply(this,arguments);
      if (this.FPopupMenu != null) {
        Event.stopPropagation();
        Event.preventDefault();
        pt.$assign(pas.Types.Point(Math.round(Event.clientX),Math.round(Event.clientY)));
        frm = pas["WEBLib.Forms"].GetParentForm(this);
        if ((frm != null) && frm.FPopup && (frm.GetContainer() != null)) {
          r = frm.GetContainer().getBoundingClientRect();
          pt.x = pt.x - Math.round(r.left);
          pt.y = pt.y - Math.round(r.top);
        };
        this.FPopupMenu.Popup(pt.x,pt.y);
        Result = true;
      };
      return Result;
    };
    this.Notification = function (AComponent, Operation) {
      pas.Classes.TComponent.Notification.apply(this,arguments);
      if ((Operation === pas.Classes.TOperation.opRemove) && (AComponent === this.FPopupMenu)) this.FPopupMenu = null;
    };
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
  });
  $mod.$implcode = function () {
    rtl.createClass($impl,"TCrackedApplication",pas["WEBLib.Forms"].TApplication,function () {
      rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
      rtl.addIntf(this,pas.System.IUnknown);
    });
    var Alpha = rtl.createSet(null,65,90,null,97,122,95);
    var AlphaNum = rtl.unionSet(Alpha,rtl.createSet(null,48,57));
    $impl.MakeValidName = function (s) {
      var Result = "";
      var i = 0;
      Result = "";
      for (var $l = 1, $end = s.length; $l <= $end; $l++) {
        i = $l;
        if (s.charCodeAt(i - 1) in AlphaNum) Result = Result + s.charAt(i - 1);
      };
      return Result;
    };
  };
},["Types","WEBLib.Forms"]);
rtl.module("WEBLib.ClientConnector",["System","Classes","WEBLib.JSON"],function () {
  "use strict";
  var $mod = this;
  var $impl = $mod.$impl;
  this.TClientConnectorIdentifier = {"0": "ciUnknown", ciUnknown: 0, "1": "ciAndroid", ciAndroid: 1, "2": "ciiOS", ciiOS: 2, "3": "ciWindows", ciWindows: 3, "4": "ciMac", ciMac: 4};
  this.$rtti.$Enum("TClientConnectorIdentifier",{minvalue: 0, maxvalue: 4, ordtype: 1, enumtype: this.TClientConnectorIdentifier});
  this.$rtti.$MethodVar("TClientConnectorReceivedMessageEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["AJSON",pas["WEBLib.JSON"].$rtti["TJSONObject"]]]), methodkind: 0});
  rtl.createClass(this,"TClientConnector",pas.Classes.TComponent,function () {
    this.$init = function () {
      pas.Classes.TComponent.$init.call(this);
      this.FOnReceivedMessage = null;
    };
    this.$final = function () {
      this.FOnReceivedMessage = undefined;
      pas.Classes.TComponent.$final.call(this);
    };
    this.Create$1 = function (AOwner) {
      pas.Classes.TComponent.Create$1.apply(this,arguments);
      pas["WEBLib.Forms"].Application.FClientConnector = this;
      return this;
    };
    this.Destroy = function () {
      pas["WEBLib.Forms"].Application.FClientConnector = null;
      pas.Classes.TComponent.Destroy.call(this);
    };
    this.Receive = function (AJSON) {
      var js = null;
      var o = null;
      var s = "";
      js = pas["WEBLib.JSON"].TJSON.$create("Create");
      s = decodeURIComponent(AJSON);
      o = js.Parse(s);
      if (this.FOnReceivedMessage != null) this.FOnReceivedMessage(this,o);
      o = rtl.freeLoc(o);
    };
    this.Send = function (AJSON) {
      var s = "";
      s = JSON.stringify(AJSON.fjo$1);
      this.SendMessage(s);
    };
    var MAXBUFFERCOUNT = 500;
    this.SendMessage = function (AMessage) {
      var $Self = this;
      var s = "";
      var cid = 0;
      var scid = "";
      var sSub = "";
      var sc = 0;
      function InternalSend(m) {
        var $tmp = cid;
        if ($tmp === $mod.TClientConnectorIdentifier.ciAndroid) {
          injectedObject.Setjsvalue(m);
          injectedObject.performClick();
        } else if (($tmp === $mod.TClientConnectorIdentifier.ciiOS) || ($tmp === $mod.TClientConnectorIdentifier.ciMac)) {
          window.webkit.messageHandlers.bridge.postMessage(m);
        } else if ($tmp === $mod.TClientConnectorIdentifier.ciWindows) {
          window.location = m;
        } else if ($tmp === $mod.TClientConnectorIdentifier.ciUnknown) pas["WEBLib.Dialogs"].ShowMessage("Please perform handshake from client first.");
      };
      s = AMessage;
      scid = window.TMSWEBCoreClientIdentifier;
      cid = $mod.TClientConnectorIdentifier.ciUnknown;
      var $tmp = pas.SysUtils.LowerCase(scid);
      if ($tmp === "android") {
        cid = $mod.TClientConnectorIdentifier.ciAndroid}
       else if ($tmp === "ios") {
        cid = $mod.TClientConnectorIdentifier.ciiOS}
       else if ($tmp === "windows") {
        cid = $mod.TClientConnectorIdentifier.ciWindows}
       else if (($tmp === "mac") || ($tmp === "macos")) cid = $mod.TClientConnectorIdentifier.ciMac;
      var $tmp1 = pas.SysUtils.LowerCase(scid);
      if (($tmp1 === "mac") || ($tmp1 === "macos") || ($tmp1 === "ios")) {
        InternalSend($impl.Prefix + encodeURIComponent(s))}
       else if (($tmp1 === "android") || ($tmp1 === "windows")) {
        InternalSend($impl.Prefix + "BUFFERSTART");
        while (s.length > 0) {
          sc = Math.min(s.length & 0xFFFFFFFF,500);
          sSub = pas.System.Copy(s,1,sc);
          pas.System.Delete({get: function () {
              return s;
            }, set: function (v) {
              s = v;
            }},1,sc);
          InternalSend($impl.Prefix + encodeURIComponent(sSub));
        };
        InternalSend($impl.Prefix + "BUFFEREND");
      };
    };
    rtl.addIntf(this,pas.System.IUnknown);
    var $r = this.$rtti;
    $r.addMethod("Create$1",2,[["AOwner",pas.Classes.$rtti["TComponent"]]]);
    $r.addProperty("OnReceivedMessage",0,$mod.$rtti["TClientConnectorReceivedMessageEvent"],"FOnReceivedMessage","FOnReceivedMessage");
  });
  rtl.createClass(this,"TWebClientConnector",this.TClientConnector,function () {
    rtl.addIntf(this,pas.System.IUnknown);
  });
  $mod.$implcode = function () {
    $impl.Prefix = "webclientevent://";
  };
},["Math","JS","WEBLib.Forms","SysUtils","WEBLib.Dialogs"]);
rtl.module("Rtl.BrowserLoadHelper",["System","Classes","SysUtils","JS","Web"],function () {
  "use strict";
  var $mod = this;
  rtl.createClass(this,"TBrowserLoadHelper",pas.Classes.TLoadHelper,function () {
    this.LoadText = function (aURL, aSync, OnLoaded, OnError) {
      var $Self = this;
      var ARequest = null;
      function doFetchOK(response) {
        var Result = undefined;
        Result = false;
        if (response.status !== 200) {
          if (OnError != null) OnError("Error " + pas.SysUtils.IntToStr(response.status) + ": " + response.statusText);
        } else response.text().then(function (value) {
          var Result = undefined;
          OnLoaded("" + value);
          return Result;
        });
        return Result;
      };
      function doFetchFail(response) {
        var Result = undefined;
        Result = false;
        OnError("Error 999: unknown error");
        return Result;
      };
      if (aSync) {
        window.fetch(aURL).then(doFetchOK).catch(doFetchFail)}
       else {
        ARequest = new XMLHttpRequest();
        ARequest.open("GET",aURL,false);
        ARequest.addEventListener("load",function (oEvent) {
          OnLoaded(ARequest.responseText);
        });
        ARequest.addEventListener("error",function (oEvent) {
          if (OnError != null) OnError(oEvent.message);
        });
        ARequest.send();
      };
    };
    this.LoadBytes = function (aURL, aSync, OnLoaded, OnError) {
      var $Self = this;
      var ARequest = null;
      function doFetchFail(response) {
        var Result = undefined;
        Result = false;
        if (rtl.isObject(response) && rtl.isExt(response,Error)) {
          OnError("Error 999: " + response.message)}
         else OnError("Error 999: unknown error");
        return Result;
      };
      function doFetchOK(response) {
        var Result = undefined;
        Result = false;
        if (response.status !== 200) {
          if (OnError != null) OnError("Error " + pas.SysUtils.IntToStr(response.status) + ": " + response.statusText);
        } else response.blob().then(function (value) {
          var Result = undefined;
          value.arrayBuffer().then(function (arr) {
            var Result = undefined;
            OnLoaded(arr);
            return Result;
          }).catch(doFetchFail);
          return Result;
        });
        return Result;
      };
      function StringToArrayBuffer(str) {
        var Result = null;
        var i = 0;
        var l = 0;
        l = str.length;
        Result = new ArrayBuffer(l * 2);
        var $with = new Uint16Array(Result);
        for (var $l = 1, $end = l; $l <= $end; $l++) {
          i = $l;
          $with[i - 1] = str.charCodeAt(i - 1);
        };
        return Result;
      };
      if (aSync) {
        window.fetch(aURL).then(doFetchOK).catch(doFetchFail)}
       else {
        ARequest = new XMLHttpRequest();
        ARequest.open("GET",aURL,false);
        ARequest.addEventListener("load",function (oEvent) {
          if (ARequest.status !== 200) {
            OnError("Error " + pas.SysUtils.IntToStr(ARequest.status) + ": " + ARequest.statusText)}
           else OnLoaded(StringToArrayBuffer(ARequest.responseText));
        });
        ARequest.addEventListener("error",function (oEvent) {
          if (OnError != null) OnError(oEvent.message);
        });
        ARequest.send();
      };
    };
  });
  $mod.$init = function () {
    pas.Classes.SetLoadHelperClass($mod.TBrowserLoadHelper);
  };
});
rtl.module("WEBLib.Forms",["System","Classes","Types","SysUtils","WEBLib.Graphics","WEBLib.Controls","WEBLib.Modules","WEBLib.Lang","WEBLib.Menus","Web","JS","WEBLib.ClientConnector","Rtl.BrowserLoadHelper"],function () {
  "use strict";
  var $mod = this;
  var $impl = $mod.$impl;
  this.WEBCOREVERSION = "2.9.2.0";
  this.idOK = 1;
  this.idCancel = 2;
  this.idAbort = 3;
  this.idRetry = 4;
  this.idIgnore = 5;
  this.idYes = 6;
  this.idNo = 7;
  this.idClose = 8;
  this.idHelp = 9;
  this.idTryAgain = 10;
  this.idContinue = 11;
  this.mrNone = 0;
  this.mrOk = 1;
  this.mrCancel = 2;
  this.mrAbort = 3;
  this.mrRetry = 4;
  this.mrIgnore = 5;
  this.mrYes = 6;
  this.mrNo = 7;
  this.mrClose = 8;
  this.mrHelp = 9;
  this.mrTryAgain = 10;
  this.mrContinue = 11;
  this.mrAll = 11 + 1;
  this.mrNoToAll = 12 + 1;
  this.mrYesToAll = 13 + 1;
  this.rgiFirst = -1024;
  this.rgiLast = -513;
  this.igiFirst = 256;
  this.igiLast = 511;
  this.clTMSBlue = 0xE39E00;
  this.clTMSWEB = 0x8F8300;
  this.$rtti.$Class("TDragDockObject");
  this.$rtti.$Class("TCustomForm");
  this.$rtti.$Int("TConstraintSize",{minvalue: 0, maxvalue: 2147483647, ordtype: 5});
  this.TCloseAction = {"0": "caNone", caNone: 0, "1": "caHide", caHide: 1, "2": "caFree", caFree: 2, "3": "caMinimize", caMinimize: 3};
  this.$rtti.$Enum("TCloseAction",{minvalue: 0, maxvalue: 3, ordtype: 1, enumtype: this.TCloseAction});
  this.TFormStyle = {"0": "fsNormal", fsNormal: 0, "1": "fsStayOnTop", fsStayOnTop: 1};
  this.$rtti.$Enum("TFormStyle",{minvalue: 0, maxvalue: 1, ordtype: 1, enumtype: this.TFormStyle});
  this.TNavigationTarget = {"0": "ntBlank", ntBlank: 0, "1": "ntPage", ntPage: 1};
  this.$rtti.$Enum("TNavigationTarget",{minvalue: 0, maxvalue: 1, ordtype: 1, enumtype: this.TNavigationTarget});
  this.$rtti.$Int("TGestureID",{minvalue: -1024, maxvalue: 511, ordtype: 2});
  this.TInteractiveGestureFlag = {"0": "gfBegin", gfBegin: 0, "1": "gfInertia", gfInertia: 1, "2": "gfEnd", gfEnd: 2};
  this.$rtti.$Enum("TInteractiveGestureFlag",{minvalue: 0, maxvalue: 2, ordtype: 1, enumtype: this.TInteractiveGestureFlag});
  this.$rtti.$Set("TInteractiveGestureFlags",{comptype: this.$rtti["TInteractiveGestureFlag"]});
  this.TMouseActivate = {"0": "maDefault", maDefault: 0, "1": "maActivate", maActivate: 1, "2": "maActivateAndEat", maActivateAndEat: 2, "3": "maNoActivate", maNoActivate: 3, "4": "maNoActivateAndEat", maNoActivateAndEat: 4};
  this.$rtti.$Enum("TMouseActivate",{minvalue: 0, maxvalue: 4, ordtype: 1, enumtype: this.TMouseActivate});
  this.TScreenOrientation = {"0": "soPortrait", soPortrait: 0, "1": "soLandscape", soLandscape: 1};
  this.$rtti.$Enum("TScreenOrientation",{minvalue: 0, maxvalue: 1, ordtype: 1, enumtype: this.TScreenOrientation});
  this.TApplicationColorScheme = {"0": "csNoScheme", csNoScheme: 0, "1": "csLight", csLight: 1, "2": "csDark", csDark: 2};
  this.$rtti.$Enum("TApplicationColorScheme",{minvalue: 0, maxvalue: 2, ordtype: 1, enumtype: this.TApplicationColorScheme});
  rtl.recNewT(this,"TSmallPoint",function () {
    this.x = 0;
    this.y = 0;
    this.$eq = function (b) {
      return (this.x === b.x) && (this.y === b.y);
    };
    this.$assign = function (s) {
      this.x = s.x;
      this.y = s.y;
      return this;
    };
    var $r = $mod.$rtti.$Record("TSmallPoint",{});
    $r.addField("x",rtl.smallint);
    $r.addField("y",rtl.smallint);
  });
  rtl.recNewT(this,"TAlignInfo",function () {
    this.AlignList = null;
    this.ControlIndex = 0;
    this.Align = 0;
    this.Scratch = 0;
    this.$eq = function (b) {
      return (this.AlignList === b.AlignList) && (this.ControlIndex === b.ControlIndex) && (this.Align === b.Align) && (this.Scratch === b.Scratch);
    };
    this.$assign = function (s) {
      this.AlignList = s.AlignList;
      this.ControlIndex = s.ControlIndex;
      this.Align = s.Align;
      this.Scratch = s.Scratch;
      return this;
    };
    var $r = $mod.$rtti.$Record("TAlignInfo",{});
    $r.addField("AlignList",pas.Classes.$rtti["TList"]);
    $r.addField("ControlIndex",rtl.longint);
    $r.addField("Align",pas["WEBLib.Controls"].$rtti["TAlign"]);
    $r.addField("Scratch",rtl.longint);
  });
  rtl.recNewT(this,"TGestureEventInfo",function () {
    this.GestureID = 0;
    this.Angle = 0.0;
    this.Distance = 0;
    this.$new = function () {
      var r = Object.create(this);
      r.Location = pas.Types.TPoint.$new();
      r.Flags = {};
      r.InertiaVector = $mod.TSmallPoint.$new();
      r.TapLocation = $mod.TSmallPoint.$new();
      return r;
    };
    this.$eq = function (b) {
      return (this.GestureID === b.GestureID) && this.Location.$eq(b.Location) && rtl.eqSet(this.Flags,b.Flags) && (this.Angle === b.Angle) && this.InertiaVector.$eq(b.InertiaVector) && (this.Distance === b.Distance) && this.TapLocation.$eq(b.TapLocation);
    };
    this.$assign = function (s) {
      this.GestureID = s.GestureID;
      this.Location.$assign(s.Location);
      this.Flags = rtl.refSet(s.Flags);
      this.Angle = s.Angle;
      this.InertiaVector.$assign(s.InertiaVector);
      this.Distance = s.Distance;
      this.TapLocation.$assign(s.TapLocation);
      return this;
    };
    var $r = $mod.$rtti.$Record("TGestureEventInfo",{});
    $r.addField("GestureID",$mod.$rtti["TGestureID"]);
    $r.addField("Location",pas.Types.$rtti["TPoint"]);
    $r.addField("Flags",$mod.$rtti["TInteractiveGestureFlags"]);
    $r.addField("Angle",rtl.double);
    $r.addField("InertiaVector",$mod.$rtti["TSmallPoint"]);
    $r.addField("Distance",rtl.longint);
    $r.addField("TapLocation",$mod.$rtti["TSmallPoint"]);
  });
  this.$rtti.$MethodVar("TCloseEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["Action",this.$rtti["TCloseAction"],1]]), methodkind: 0});
  this.$rtti.$MethodVar("TCloseQueryEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["CanClose",rtl.boolean,1]]), methodkind: 0});
  this.$rtti.$MethodVar("TOrientationChangeEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["AOrientation",this.$rtti["TScreenOrientation"]]]), methodkind: 0});
  this.$rtti.$MethodVar("TBeforeUnloadEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["AMessage",rtl.string,1]]), methodkind: 0});
  this.$rtti.$MethodVar("TAlignInsertBeforeEvent",{procsig: rtl.newTIProcSig([["Sender",pas["WEBLib.Controls"].$rtti["TWinControl"]],["C1",pas["WEBLib.Controls"].$rtti["TControl"]],["C2",pas["WEBLib.Controls"].$rtti["TControl"]]],rtl.boolean), methodkind: 1});
  this.$rtti.$MethodVar("TAlignPositionEvent",{procsig: rtl.newTIProcSig([["Sender",pas["WEBLib.Controls"].$rtti["TWinControl"]],["Control",pas["WEBLib.Controls"].$rtti["TControl"]],["NewLeft",rtl.longint,1],["NewTop",rtl.longint,1],["NewWidth",rtl.longint,1],["NewHeight",rtl.longint,1],["AlignRect",pas.Types.$rtti["TRect"],1],["AlignInfo",this.$rtti["TAlignInfo"]]]), methodkind: 0});
  this.$rtti.$MethodVar("TCanResizeEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["NewWidth",rtl.longint,1],["NewHeight",rtl.longint,1],["Resize",rtl.boolean,1]]), methodkind: 0});
  this.$rtti.$MethodVar("TConstrainedResizeEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["MinWidth",rtl.longint,1],["MinHeight",rtl.longint,1],["MaxWidth",rtl.longint,1],["MaxHeight",rtl.longint,1]]), methodkind: 0});
  this.$rtti.$MethodVar("TContextPopupEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["MousePos",pas.Types.$rtti["TPoint"]],["Handled",rtl.boolean,1]]), methodkind: 0});
  this.$rtti.$MethodVar("TDockDropEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["Source",this.$rtti["TDragDockObject"]],["X",rtl.longint],["Y",rtl.longint]]), methodkind: 0});
  this.$rtti.$MethodVar("TDockOverEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["Source",this.$rtti["TDragDockObject"]],["X",rtl.longint],["Y",rtl.longint],["State",pas["WEBLib.Controls"].$rtti["TDragState"]],["Accept",rtl.boolean,1]]), methodkind: 0});
  this.$rtti.$MethodVar("TGestureEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["EventInfo",this.$rtti["TGestureEventInfo"],2],["Handled",rtl.boolean,1]]), methodkind: 0});
  this.$rtti.$MethodVar("TGetSiteInfoEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["DockClient",pas["WEBLib.Controls"].$rtti["TControl"]],["InfluenceRect",pas.Types.$rtti["TRect"],1],["MousePos",pas.Types.$rtti["TPoint"]],["CanDock",rtl.boolean,1]]), methodkind: 0});
  this.$rtti.$MethodVar("TMouseActivateEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["Button",pas["WEBLib.Controls"].$rtti["TMouseButton"]],["Shift",pas.Classes.$rtti["TShiftState"]],["X",rtl.longint],["Y",rtl.longint],["HitTest",rtl.longint],["MouseActivate",this.$rtti["TMouseActivate"],1]]), methodkind: 0});
  this.$rtti.$MethodVar("TMouseWheelUpDownEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["Shift",pas.Classes.$rtti["TShiftState"]],["MousePos",pas.Types.$rtti["TPoint"]],["Handled",rtl.boolean,1]]), methodkind: 0});
  this.$rtti.$MethodVar("TStartDockEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["DragObject",this.$rtti["TDragDockObject"],1]]), methodkind: 0});
  this.$rtti.$MethodVar("TUnDockEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["Client",pas["WEBLib.Controls"].$rtti["TControl"]],["NewTarget",pas["WEBLib.Controls"].$rtti["TWinControl"]],["Allow",rtl.boolean,1]]), methodkind: 0});
  this.$rtti.$MethodVar("THashChangeEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["oldURL",rtl.string],["newURL",rtl.string]]), methodkind: 0});
  this.$rtti.$RefToProcVar("TModalResultProc",{procsig: rtl.newTIProcSig([["AValue",rtl.longint]])});
  this.$rtti.$RefToProcVar("TFormCreatedProc",{procsig: rtl.newTIProcSig([["AForm",pas.System.$rtti["TObject"]]])});
  this.TWindowState = {"0": "wsNormal", wsNormal: 0, "1": "wsMinimized", wsMinimized: 1, "2": "wsMaximized", wsMaximized: 2};
  this.$rtti.$Enum("TWindowState",{minvalue: 0, maxvalue: 2, ordtype: 1, enumtype: this.TWindowState});
  this.TPopupMode = {"0": "pmNone", pmNone: 0, "1": "pmAuto", pmAuto: 1, "2": "pmExplicit", pmExplicit: 2};
  this.$rtti.$Enum("TPopupMode",{minvalue: 0, maxvalue: 2, ordtype: 1, enumtype: this.TPopupMode});
  this.TPopupClose = {"0": "pcOnDeactivate", pcOnDeactivate: 0, "1": "pcNever", pcNever: 1};
  this.$rtti.$Enum("TPopupClose",{minvalue: 0, maxvalue: 1, ordtype: 1, enumtype: this.TPopupClose});
  this.TPosition = {"0": "poDesigned", poDesigned: 0, "1": "poDefault", poDefault: 1, "2": "poDefaultPosOnly", poDefaultPosOnly: 2, "3": "poDefaultSizeOnly", poDefaultSizeOnly: 3, "4": "poScreenCenter", poScreenCenter: 4, "5": "poDesktopCenter", poDesktopCenter: 5, "6": "poMainFormCenter", poMainFormCenter: 6, "7": "poOwnerFormCenter", poOwnerFormCenter: 7};
  this.$rtti.$Enum("TPosition",{minvalue: 0, maxvalue: 7, ordtype: 1, enumtype: this.TPosition});
  this.TApplicationErrorType = {"0": "aeSilent", aeSilent: 0, "1": "aeDialog", aeDialog: 1, "2": "aeAlert", aeAlert: 2, "3": "aeFooter", aeFooter: 3};
  this.$rtti.$Enum("TApplicationErrorType",{minvalue: 0, maxvalue: 3, ordtype: 1, enumtype: this.TApplicationErrorType});
  this.TFormBorderStyle = {"0": "fbNone", fbNone: 0, "1": "fbSingle", fbSingle: 1, "2": "fbSizeable", fbSizeable: 2, "3": "fbDialog", fbDialog: 3, "4": "fbDialogSizeable", fbDialogSizeable: 4};
  this.$rtti.$Enum("TFormBorderStyle",{minvalue: 0, maxvalue: 4, ordtype: 1, enumtype: this.TFormBorderStyle});
  this.$rtti.$Enum("TFormBorder",{minvalue: 0, maxvalue: 1, ordtype: 1, enumtype: this.TFormBorderStyle});
  this.TBootstrapVersion = {"0": "bv3", bv3: 0, "1": "bv4", bv4: 1, "2": "bv5", bv5: 2};
  this.$rtti.$Enum("TBootstrapVersion",{minvalue: 0, maxvalue: 2, ordtype: 1, enumtype: this.TBootstrapVersion});
  rtl.createClass(this,"TCustomSizeConstraints",pas.Classes.TPersistent,function () {
    this.$init = function () {
      pas.Classes.TPersistent.$init.call(this);
      this.FControl = null;
      this.FMaxHeight = 0;
      this.FMaxWidth = 0;
      this.FMinHeight = 0;
      this.FMinWidth = 0;
      this.FOnChange = null;
    };
    this.$final = function () {
      this.FControl = undefined;
      this.FOnChange = undefined;
      pas.Classes.TPersistent.$final.call(this);
    };
    this.SetConstraints = function (AIndex, AValue) {
      var $tmp = AIndex;
      if ($tmp === 0) {
        if (AValue !== this.FMaxHeight) {
          this.FMaxHeight = AValue;
          if ((AValue > 0) && (AValue < this.FMinHeight)) this.FMinHeight = AValue;
          this.Change();
        }}
       else if ($tmp === 1) {
        if (AValue !== this.FMaxWidth) {
          this.FMaxWidth = AValue;
          if ((AValue > 0) && (AValue < this.FMinWidth)) this.FMinWidth = AValue;
          this.Change();
        }}
       else if ($tmp === 2) {
        if (AValue !== this.FMinHeight) {
          this.FMinHeight = AValue;
          if ((this.FMaxHeight > 0) && (AValue > this.FMaxHeight)) this.FMaxHeight = AValue;
          this.Change();
        }}
       else if ($tmp === 3) if (AValue !== this.FMinWidth) {
        this.FMinWidth = AValue;
        if ((this.FMaxWidth > 0) && (AValue > this.FMaxWidth)) this.FMaxWidth = AValue;
        this.Change();
      };
    };
    this.Change = function () {
      if (this.FOnChange != null) this.FOnChange(this);
    };
    this.AssignTo = function (ADest) {
      if ($mod.TCustomSizeConstraints.isPrototypeOf(ADest)) {
        ADest.FMinHeight = this.FMinHeight;
        ADest.FMaxHeight = this.FMaxHeight;
        ADest.FMinWidth = this.FMinWidth;
        ADest.FMaxWidth = this.FMaxWidth;
        ADest.Change();
      } else pas.Classes.TPersistent.AssignTo.call(this,ADest);
    };
    this.Create$1 = function (AControl) {
      pas.System.TObject.Create.call(this);
      this.FControl = AControl;
      return this;
    };
    var $r = this.$rtti;
    $r.addMethod("Create$1",2,[["AControl",pas["WEBLib.Controls"].$rtti["TControl"]]]);
  });
  rtl.createClass(this,"TSizeConstraints",this.TCustomSizeConstraints,function () {
    var $r = this.$rtti;
    $r.addProperty("MaxHeight",18,$mod.$rtti["TConstraintSize"],"FMaxHeight","SetConstraints",{index: 0, Default: 0});
    $r.addProperty("MaxWidth",18,$mod.$rtti["TConstraintSize"],"FMaxWidth","SetConstraints",{index: 1, Default: 0});
    $r.addProperty("MinHeight",18,$mod.$rtti["TConstraintSize"],"FMinHeight","SetConstraints",{index: 2, Default: 0});
    $r.addProperty("MinWidth",18,$mod.$rtti["TConstraintSize"],"FMinWidth","SetConstraints",{index: 3, Default: 0});
  });
  rtl.createClass(this,"TDragDockObject",pas.System.TObject,function () {
    this.$init = function () {
      pas.System.TObject.$init.call(this);
      this.FBrush = null;
      this.FDockRect = pas.Types.TRect.$new();
      this.FDropAlign = 0;
      this.FDropOnControl = null;
      this.FEraseDockRect = pas.Types.TRect.$new();
      this.FEraseWhenMoving = false;
      this.FFloating = false;
      this.FFrameWidth = 0;
    };
    this.$final = function () {
      this.FBrush = undefined;
      this.FDockRect = undefined;
      this.FDropOnControl = undefined;
      this.FEraseDockRect = undefined;
      pas.System.TObject.$final.call(this);
    };
    this.Create$1 = function (AControl) {
      pas.System.TObject.Create.call(this);
      this.FBrush = pas["WEBLib.Graphics"].TBrush.$create("Create$1");
      return this;
    };
    this.Destroy = function () {
      rtl.free(this,"FBrush");
      pas.System.TObject.Destroy.call(this);
    };
    this.Assign = function (Source) {
    };
  });
  rtl.createClass(this,"TCustomForm",pas["WEBLib.Controls"].TWinControl,function () {
    this.$init = function () {
      pas["WEBLib.Controls"].TWinControl.$init.call(this);
      this.FDesignContainer = null;
      this.FLayer$1 = null;
      this.FPopup = false;
      this.FDirectForm = false;
      this.FPopupElement = null;
      this.FFormFileName = "";
      this.FFormContent = "";
      this.FFormContainer = "";
      this.FFormElement = "";
      this.FFormStyle = 0;
      this.FOnCreate = null;
      this.FOnShow = null;
      this.FModalResult = 0;
      this.FOnPaint = null;
      this.FOnDeactivate = null;
      this.FOnCloseQuery = null;
      this.FOnClose = null;
      this.FModalProc = null;
      this.FCreatedProc = null;
      this.FWindowState = 0;
      this.FCaption = "";
      this.FIsResizing$1 = false;
      this.FOnScroll = null;
      this.FOnUnload = null;
      this.FOnBeforeUnload = null;
      this.FPopupMode = 0;
      this.FPopupClose = 0;
      this.FPosition = 0;
      this.FActiveControl = null;
      this.FMdx = 0;
      this.FMdy = 0;
      this.FDlgX = 0;
      this.FDlgY = 0;
      this.FCaptured$1 = false;
      this.FDown = false;
      this.FHasCaption = false;
      this.FMoveSpan = null;
      this.FCaptionElement = null;
      this.FCaptionCloseElement = null;
      this.FBorder = 0;
      this.FShadow = false;
      this.FTimerID = 0;
      this.FOrigWidth = 0;
      this.FOrigHeight = 0;
      this.FOldWidth = 0;
      this.FOldHeight = 0;
      this.FOnDestroy = null;
      this.FPopupOpacity = 0.0;
      this.FCreating = false;
      this.FCreated = false;
      this.FShown = false;
      this.FLoadedPtr = null;
      this.FDOMContentLoadedPtr = null;
      this.FUnloadPtr = null;
      this.FBeforeUnloadPtr = null;
      this.FResizePtr = null;
      this.FScrollPtr = null;
      this.FDocMouseUpPtr = null;
      this.FDocMouseMovePtr = null;
      this.FTitleDownPtr = null;
      this.FDoClickPtr = null;
      this.FKeyDownPtr$1 = null;
      this.FOrientationChangePtr = null;
      this.FHashChangePtr = null;
      this.FCSSLibrary = 0;
      this.FNoHTML = false;
      this.FPrevActiveForm = null;
      this.FElementCaptionClassName = "";
      this.FElementPopupClassName = "";
      this.FMenu = null;
      this.FResizeObserver = null;
      this.FOnOrientationChange = null;
      this.FOnDOMContentLoaded = null;
      this.FShowClose = false;
      this.FOnHashChange = null;
    };
    this.$final = function () {
      this.FDesignContainer = undefined;
      this.FLayer$1 = undefined;
      this.FPopupElement = undefined;
      this.FOnCreate = undefined;
      this.FOnShow = undefined;
      this.FOnPaint = undefined;
      this.FOnDeactivate = undefined;
      this.FOnCloseQuery = undefined;
      this.FOnClose = undefined;
      this.FModalProc = undefined;
      this.FCreatedProc = undefined;
      this.FOnScroll = undefined;
      this.FOnUnload = undefined;
      this.FOnBeforeUnload = undefined;
      this.FActiveControl = undefined;
      this.FMoveSpan = undefined;
      this.FCaptionElement = undefined;
      this.FCaptionCloseElement = undefined;
      this.FOnDestroy = undefined;
      this.FPrevActiveForm = undefined;
      this.FMenu = undefined;
      this.FResizeObserver = undefined;
      this.FOnOrientationChange = undefined;
      this.FOnDOMContentLoaded = undefined;
      this.FOnHashChange = undefined;
      pas["WEBLib.Controls"].TWinControl.$final.call(this);
    };
    this.SetModalResult = function (Value) {
      this.FModalResult = Value;
      if (this.FModalResult !== 0) this.Close();
    };
    this.GetFormStyle = function () {
      var Result = 0;
      Result = this.FFormStyle;
      return Result;
    };
    this.SetFormStyle = function (Value) {
      this.FFormStyle = Value;
    };
    this.GetCanvas = function () {
      var Result = null;
      Result = null;
      return Result;
    };
    this.SetCaption = function (AValue) {
      if (this.FCaption !== AValue) {
        this.FCaption = AValue;
        this.UpdateElement();
      };
    };
    this.SetActiveControl = function (Value) {
      this.FActiveControl = Value;
      if (this.FActiveControl != null) this.FActiveControl.SetFocus();
    };
    this.SetShadow = function (Value) {
      if (this.FShadow !== Value) {
        this.FShadow = Value;
        this.UpdateElement();
      };
    };
    this.SetBorder = function (Value) {
      if (this.FBorder !== Value) {
        this.FBorder = Value;
        if (this.GetContainer() != null) this.AlignControl(this);
      };
    };
    this.SetFormContainer = function (Value) {
      var el = null;
      var old = null;
      var i = 0;
      old = this.GetContainer();
      if (pas.Classes.TComponentStateItem.csDesigning in this.FComponentState) {
        this.FFormContainer = Value}
       else {
        if (pas.SysUtils.UpperCase(Value) === "BODY") {
          this.FFormContainer = ""}
         else this.FFormContainer = Value;
      };
      if ((pas.Classes.TComponentStateItem.csLoading in this.FComponentState) && !(pas.Classes.TComponentStateItem.csDesigning in this.FComponentState)) return;
      if (this.FLayer$1 != null) {
        el = this.FLayer$1}
       else if (Value === "") {
        el = document.body;
      } else {
        el = document.getElementById(Value);
        if (!(el != null)) el = document.body;
      };
      if (el != null) {
        this.FContainer = el;
        if (old != null) {
          for (var $l = 0, $end = this.GetControlsCount() - 1; $l <= $end; $l++) {
            i = $l;
            if (this.GetControls(i).FParentElement === old) this.GetControls(i).FParentElement = el;
            if ((this.GetControls(i).GetElementHandle() != null) && (this.GetControls(i).GetElementHandle().parentElement === old)) {
              el.appendChild(this.GetControls(i).GetElementHandle());
            };
          };
        };
      };
    };
    this.GetActiveControl = function () {
      var Result = null;
      var i = 0;
      Result = this.FActiveControl;
      for (var $l = 0, $end = this.GetControlsCount() - 1; $l <= $end; $l++) {
        i = $l;
        if (this.GetControls(i).GetElementHandle() === document.activeElement) {
          Result = this.GetControls(i);
          break;
        };
      };
      return Result;
    };
    this.SetPosition = function (Value) {
      this.FPosition = Value;
    };
    this.ReadPixelsPerInch = function (AReader) {
    };
    this.WritePixelsPerInch = function (AWriter) {
    };
    this.SetWidth = function (AValue) {
      var eh = null;
      if (((pas.Classes.TComponentStateItem.csLoading in this.FComponentState) && (this.FFormContainer !== "")) || (!this.FPopup && !(this.GetElementHandle() != null))) {
        this.SetWidthInt(AValue);
        return;
      };
      pas["WEBLib.Controls"].TControl.SetWidth.apply(this,arguments);
      if (this.FPopup) {
        eh = this.FPopupElement;
        if (eh != null) eh.style.setProperty("width",pas.SysUtils.IntToStr(AValue) + "px");
      };
    };
    this.SetHeight = function (AValue) {
      var eh = null;
      if (((pas.Classes.TComponentStateItem.csLoading in this.FComponentState) && (this.FFormContainer !== "")) || (!this.FPopup && !(this.GetElementHandle() != null))) {
        this.SetHeightInt(AValue);
        if (this.FormContainerElement() != null) {
          if ((pas.SysUtils.UpperCase(this.FormContainerElement().tagName) !== "BODY") && !this.GetIsLinked()) this.FormContainerElement().style.setProperty("height",pas.SysUtils.IntToStr(AValue) + "px");
        };
        return;
      };
      pas["WEBLib.Controls"].TControl.SetHeight.apply(this,arguments);
      if ((this.FFormContainer !== "") && (this.FormContainerElement() != null)) {
        this.FormContainerElement().style.setProperty("height",pas.SysUtils.IntToStr(AValue) + "px");
        this.Realign();
      };
      if (this.FPopup) {
        eh = this.FPopupElement;
        if (eh != null) eh.style.setProperty("height",pas.SysUtils.IntToStr(AValue) + "px");
      };
    };
    this.SetClientHeight = function (Value) {
      if (this.FBorder in rtl.createSet($mod.TFormBorderStyle.fbDialog,$mod.TFormBorderStyle.fbDialogSizeable)) {
        this.SetHeight(Value + $mod.Application.FFormCaptionHeight);
      } else pas["WEBLib.Controls"].TControl.SetClientHeight.apply(this,arguments);
    };
    this.GetClientHeight = function () {
      var Result = 0;
      if (this.FBorder in rtl.createSet($mod.TFormBorderStyle.fbDialog,$mod.TFormBorderStyle.fbDialogSizeable)) {
        Result = this.GetHeight();
      } else Result = pas["WEBLib.Controls"].TControl.GetClientHeight.call(this);
      return Result;
    };
    this.HandleHashChange = function (Event) {
      var Result = false;
      var oldURL = "";
      var newURL = "";
      var newHash = "";
      var pc = null;
      var newform = null;
      oldURL = Event.oldURL;
      newURL = Event.newURL;
      if (this.FOnHashChange != null) {
        this.FOnHashChange(this,oldURL,newURL);
      };
      if ($mod.Application.FRouting) {
        newHash = pas.System.Copy(newURL,pas.System.Pos("#",newURL) + 1,newURL.length);
        pc = pas.Classes.GetClass("T" + this.FName);
        if ((pc != null) && ($mod.LastHash !== newHash)) {
          if ((pas.System.Pos("#" + this.FName + "?",oldURL + "?") !== 0) && (pas.System.Pos("#" + this.FName + "?",newURL + "?") === 0)) {
            this.Close();
          };
          if (!this.FPopup) {
            pc = pas.Classes.GetClass("T" + newHash);
            if (pc != null) {
              $mod.Application.AutoCreateForm(pc,{get: function () {
                  return newform;
                }, set: function (v) {
                  newform = v;
                }});
            };
          };
        };
      };
      Result = true;
      return Result;
    };
    this.HandleLoaded = function (Event) {
      var Result = false;
      this.Resize$1();
      this.InitAnchoring();
      Result = true;
      return Result;
    };
    this.HandleDOMContentLoaded = function (Event) {
      var Result = false;
      if (this.FOnDOMContentLoaded != null) this.FOnDOMContentLoaded(this);
      Result = true;
      return Result;
    };
    this.HandleScroll = function (Event) {
      var Result = false;
      if (this.FOnScroll != null) this.FOnScroll(this);
      Result = true;
      return Result;
    };
    this.HandleUnload = function (Event) {
      var Result = false;
      if (this.FOnUnload != null) this.FOnUnload(this);
      Result = true;
      return Result;
    };
    this.HandleBeforeUnload = function (Event) {
      var Result = false;
      var msg = "";
      msg = "";
      if (this.FOnBeforeUnload != null) this.FOnBeforeUnload(this,{get: function () {
          return msg;
        }, set: function (v) {
          msg = v;
        }});
      if (msg !== "") {
        Event.returnValue = msg;
        return msg;
      };
      Result = true;
      return Result;
    };
    this.HandleObserver = function () {
      var Result = false;
      this.Resize$1();
      Result = true;
      return Result;
    };
    this.HandleResize = function (Event) {
      var Result = false;
      if (this.FVisible && !(pas.Classes.TComponentStateItem.csDestroying in this.FComponentState)) {
        if (!(this.GetContainer() != null)) this.CreateControl();
        this.Resize$1();
        if (this.GetElementHandle() === document.body) window.setTimeout(rtl.createSafeCallback(this,"Resize$1"),25);
      };
      if (1 < 0) {
        this.HandleObserver();
      };
      Result = true;
      return Result;
    };
    this.HandleDocMouseMove = function (Event) {
      var Result = false;
      var deltax = 0.0;
      var deltay = 0.0;
      var el = null;
      var l = 0;
      var t = 0;
      if (this.FDown && (this.GetContainer() != null)) {
        deltax = Event.clientX - this.FMdx;
        deltay = Event.clientY - this.FMdy;
        if (this.FHasCaption && (this.FFormFileName !== "")) {
          el = this.GetContainer().parentNode}
         else el = this.GetContainer();
        el.style.setProperty("transform","");
        el.style.setProperty("position","absolute");
        l = Math.round(this.FDlgX + deltax);
        t = Math.round(this.FDlgY + deltay);
        el.style.setProperty("left",pas.SysUtils.IntToStr(l) + "px");
        el.style.setProperty("top",pas.SysUtils.IntToStr(t) + "px");
        this.FLeft = l;
        this.FTop = t;
      };
      Result = true;
      return Result;
    };
    this.HandleDocMouseUp = function (Event) {
      var Result = false;
      if (this.FDown) {
        this.FCaptured$1 = false;
        this.FDown = false;
        document.body.removeEventListener("mousemove",this.FDocMouseMovePtr);
        document.body.removeEventListener("mouseup",this.FDocMouseUpPtr);
        if (this.FMoveSpan != null) document.body.removeChild(this.FMoveSpan);
        this.FEventStopPropagation = rtl.unionSet(this.FEventStopPropagation,rtl.createSet(pas["WEBLib.Controls"].TElementEvent.eeMouseMove,pas["WEBLib.Controls"].TElementEvent.eeMouseUp));
        this.FMoveSpan = null;
      };
      Result = true;
      return Result;
    };
    this.HandleTitleDown = function (Event) {
      var Result = false;
      var r = null;
      Event.stopPropagation();
      Event.preventDefault();
      this.FPopupClose = $mod.TPopupClose.pcNever;
      this.FMdx = Math.round(Event.clientX);
      this.FMdy = Math.round(Event.clientY);
      if (this.FHasCaption && (this.FFormFileName !== "")) {
        r = this.GetContainer().parentNode.getBoundingClientRect()}
       else r = this.GetContainer().getBoundingClientRect();
      this.FDlgX = Math.round(pas.System.Int(r.left));
      this.FDlgY = Math.round(pas.System.Int(r.top));
      this.FDown = true;
      if (!this.FCaptured$1) {
        this.FCaptured$1 = true;
        this.FMoveSpan = document.createElement("SPAN");
        this.FMoveSpan.style.setProperty("top","0");
        this.FMoveSpan.style.setProperty("left","0");
        this.FMoveSpan.style.setProperty("right","0");
        this.FMoveSpan.style.setProperty("bottom","0");
        this.FMoveSpan.style.setProperty("position","absolute");
        document.body.appendChild(this.FMoveSpan);
        this.FEventStopPropagation = rtl.diffSet(this.FEventStopPropagation,rtl.createSet(pas["WEBLib.Controls"].TElementEvent.eeMouseMove,pas["WEBLib.Controls"].TElementEvent.eeMouseUp));
        document.body.addEventListener("mousemove",this.FDocMouseMovePtr);
        document.body.addEventListener("mouseup",this.FDocMouseUpPtr);
      };
      Result = true;
      return Result;
    };
    this.HandleCloseClick = function (Event) {
      var Result = false;
      var CanClose = false;
      CanClose = true;
      if (this.FOnCloseQuery != null) this.FOnCloseQuery(this,{get: function () {
          return CanClose;
        }, set: function (v) {
          CanClose = v;
        }});
      if (CanClose) this.Close();
      Result = true;
      return Result;
    };
    this.SetLeft = function (AValue) {
      var eh = null;
      pas["WEBLib.Controls"].TControl.SetLeft.apply(this,arguments);
      if (this.FPopup) {
        eh = this.FPopupElement;
        if (eh != null) eh.style.setProperty("left",pas.SysUtils.IntToStr(AValue) + "px");
      };
    };
    this.SetTop = function (AValue) {
      var eh = null;
      pas["WEBLib.Controls"].TControl.SetTop.apply(this,arguments);
      if (this.FPopup) {
        eh = this.FPopupElement;
        if (eh != null) eh.style.setProperty("top",pas.SysUtils.IntToStr(AValue) + "px");
      };
    };
    var cPixelsPerInch = "PixelsPerInch";
    this.DefineProperties = function (AFiler) {
      pas.Classes.TComponent.DefineProperties.call(this,AFiler);
      AFiler.DefineProperty(cPixelsPerInch,rtl.createCallback(this,"ReadPixelsPerInch"),rtl.createCallback(this,"WritePixelsPerInch"),false);
    };
    this.ClearMethodPointers = function () {
      pas["WEBLib.Controls"].TControl.ClearMethodPointers.call(this);
      this.FLoadedPtr = null;
      this.FDOMContentLoadedPtr = null;
      this.FUnloadPtr = null;
      this.FBeforeUnloadPtr = null;
      this.FResizePtr = null;
      this.FScrollPtr = null;
      this.FDocMouseUpPtr = null;
      this.FDocMouseMovePtr = null;
      this.FTitleDownPtr = null;
      this.FDoClickPtr = null;
      this.FKeyDownPtr$1 = null;
      this.FOrientationChangePtr = null;
      this.FHashChangePtr = null;
    };
    this.GetMethodPointers = function () {
      pas["WEBLib.Controls"].TControl.GetMethodPointers.call(this);
      if (this.FLoadedPtr === null) {
        this.FLoadedPtr = rtl.createCallback(this,"HandleLoaded");
        this.FDOMContentLoadedPtr = rtl.createCallback(this,"HandleDOMContentLoaded");
        this.FUnloadPtr = rtl.createCallback(this,"HandleUnload");
        this.FBeforeUnloadPtr = rtl.createCallback(this,"HandleBeforeUnload");
        this.FResizePtr = rtl.createCallback(this,"HandleResize");
        this.FScrollPtr = rtl.createCallback(this,"HandleScroll");
        this.FDocMouseUpPtr = rtl.createCallback(this,"HandleDocMouseUp");
        this.FDocMouseMovePtr = rtl.createCallback(this,"HandleDocMouseMove");
        this.FTitleDownPtr = rtl.createCallback(this,"HandleTitleDown");
        this.FDoClickPtr = rtl.createCallback(this,"HandleDoClick$1");
        this.FKeyDownPtr$1 = rtl.createCallback(this,"HandleKeyDown");
        this.FOrientationChangePtr = rtl.createCallback(this,"HandleOrientationChange");
        this.FHashChangePtr = rtl.createCallback(this,"HandleHashChange");
      };
    };
    this.VisibleChanged = function () {
      var LIsBody = false;
      pas["WEBLib.Controls"].TControl.VisibleChanged.call(this);
      if (this.FLayer$1 != null) {
        if (this.FVisible) {
          this.FLayer$1.style.setProperty("display","")}
         else this.FLayer$1.style.setProperty("display","none");
      } else {
        LIsBody = pas.SysUtils.LowerCase(this.GetID()) === pas["WEBLib.WebTools"].cBodyTag;
        if ((this.GetContainer() != null) && (this.FFormContainer !== "") && !LIsBody) {
          if (this.FVisible) {
            this.GetContainer().style.setProperty("display","")}
           else this.GetContainer().style.setProperty("display","none");
        };
      };
    };
    this.Resize$1 = function () {
      var i = 0;
      var ch = 0;
      var neww = 0;
      var newh = 0;
      var eh = null;
      var dr = null;
      if (pas.Classes.TComponentStateItem.csDestroying in this.FComponentState) return;
      this.FIsResizing$1 = true;
      if (this.FPopup && (this.FPopupElement != null)) {
        eh = this.FPopupElement;
        dr = eh.getBoundingClientRect();
        neww = Math.round(dr.right - dr.left - 2);
        if (this.FBorder in rtl.createSet($mod.TFormBorderStyle.fbDialog,$mod.TFormBorderStyle.fbDialogSizeable)) {
          ch = this.GetCaptionHeight();
          newh = Math.round(dr.bottom - dr.top - ch - 2);
        } else newh = Math.round(dr.bottom - dr.top - 2);
      } else {
        neww = window.innerWidth;
        newh = window.innerHeight;
      };
      this.UpdateControlSize(neww,newh);
      if (!(pas["WEBLib.Controls"].IsAndroid() && (document.activeElement.tagName === "INPUT"))) this.AlignControl(this);
      this.DoResize();
      this.FIsResizing$1 = false;
      if (!this.IsUpdating()) {
        if ((this.FOrigRect.Left === -1) && (this.FOrigRect.Top === -1)) this.InitAnchoring();
        for (var $l = 0, $end = this.GetControlsCount() - 1; $l <= $end; $l++) {
          i = $l;
          this.GetControls(i).UpdateAnchoring();
        };
      };
    };
    this.CreateControl = function () {
      var s = "";
      if (!this.FVisible && !this.FPopup) return;
      pas["WEBLib.Controls"].TControl.CreateControl.call(this);
      s = "";
      if (typeof CONTAINERID !== "undefined") {
        try {
          s = CONTAINERID;
        }
        catch(e)
        {
        }
      };
      if (s !== "") this.SetFormContainer(s);
      this.UpdateSize();
    };
    this.DoClose = function (CloseAction) {
      if ((this.FModalProc != null) && (CloseAction.get() !== $mod.TCloseAction.caNone)) {
        this.FModalProc(this.FModalResult);
        this.FModalProc = null;
      };
    };
    this.BindEvents = function () {
      var pc = null;
      var hash = "";
      pas["WEBLib.Controls"].TControl.BindEvents.call(this);
      if (document.readyState !== "loading") if (this.FOnDOMContentLoaded != null) this.FOnDOMContentLoaded(this);
      window.addEventListener("resize",this.FResizePtr);
      window.addEventListener("load",this.FLoadedPtr);
      window.addEventListener("DOMContentLoaded",this.FDOMContentLoadedPtr);
      document.addEventListener("scroll",this.FScrollPtr);
      window.addEventListener("unload",this.FUnloadPtr);
      window.addEventListener("beforeunload",this.FBeforeUnloadPtr);
      window.addEventListener("keydown",this.FKeyDownPtr$1);
      window.addEventListener("orientationchange",this.FOrientationChangePtr);
      window.addEventListener("hashchange",this.FHashChangePtr);
      pc = pas.Classes.GetClass(this.$classname);
      if ((pc != null) && !this.FPopup && $mod.Application.FRouting) {
        hash = this.$classname;
        pas.System.Delete({get: function () {
            return hash;
          }, set: function (v) {
            hash = v;
          }},1,1);
        $mod.LastHash = hash;
        window.location.hash = hash;
      };
    };
    this.UnbindEvents = function () {
      pas["WEBLib.Controls"].TControl.UnbindEvents.call(this);
      if ((this.FLayer$1 != null) && (this.FPopupClose === $mod.TPopupClose.pcOnDeactivate)) this.FLayer$1.removeEventListener("click",this.FDoClickPtr);
      if (this.FResizeObserver != null) {
        this.FResizeObserver.disconnect();
      };
      window.removeEventListener("resize",this.FResizePtr);
      window.removeEventListener("load",this.FLoadedPtr);
      window.removeEventListener("DOMContentLoaded",this.FDOMContentLoadedPtr);
      document.removeEventListener("scroll",this.FScrollPtr);
      window.removeEventListener("unload",this.FUnloadPtr);
      window.removeEventListener("beforeunload",this.FBeforeUnloadPtr);
      window.removeEventListener("keydown",this.FKeyDownPtr$1);
      window.removeEventListener("orientationchange",this.FOrientationChangePtr);
      window.removeEventListener("hashchange",this.FHashChangePtr);
    };
    this.DoCreate = function () {
      this.BeginUpdate();
      this.LoadDFMValues();
      this.Loaded();
      if (this.FOnCreate != null) this.FOnCreate(this);
      this.FCreating = false;
      this.EndUpdate();
      this.UpdateChildren(this);
      this.Realign();
      this.DoResize();
    };
    this.Realign = function () {
      var el = null;
      var dr = null;
      var r = pas.Types.TRect.$new();
      if ((this.FFormContainer !== "") && (this.FAlign !== pas["WEBLib.Controls"].TAlign.alNone)) {
        el = document.getElementById(this.FFormContainer);
        if (el != null) {
          dr = el.getBoundingClientRect();
          if ((dr.width === 0) && (dr.height === 0) && (el.style.getPropertyValue("position") === "absolute")) {
            r.$assign(pas["WEBLib.Controls"].GetHTMLElementAbsoluteRect(el));
          } else {
            r.$assign(pas.Types.Rect(Math.round(dr.left),Math.round(dr.top),Math.round(dr.right),Math.round(dr.bottom)));
          };
          this.SetBoundsInt(r.Left,r.Top,r.Right - r.Left,r.Bottom - r.Top);
        };
      };
      pas["WEBLib.Controls"].TControl.Realign.call(this);
    };
    this.DoResize = function () {
      var w = 0;
      var h = 0;
      w = this.GetWidth();
      h = this.GetHeight();
      if ((w === this.FOldWidth) && (h === this.FOldHeight)) return;
      this.FOldWidth = w;
      this.FOldHeight = h;
      if (this.FOnResize != null) this.FOnResize(this);
    };
    this.DoShow = function () {
      this.DoAutoFocus();
      if ((this.FOnShow != null) && !this.FShown) {
        this.FShown = true;
        this.FOnShow(this);
      };
    };
    this.DoAutoFocus = function () {
      var i = 0;
      for (var $l = 0, $end = this.GetControlsCount() - 1; $l <= $end; $l++) {
        i = $l;
        if ((this.GetControls(i).FTabOrder === 0) && this.GetControls(i).FTabStop) {
          this.GetControls(i).SetFocus();
        };
      };
    };
    this.Paint = function () {
    };
    this.HandleDoClick$1 = function (Event) {
      var Result = false;
      Event.stopPropagation();
      if (this.FPopupClose === $mod.TPopupClose.pcOnDeactivate) this.Close();
      Result = true;
      return Result;
    };
    this.HandleKeyDown = function (Event) {
      var Result = false;
      var k = 0;
      k = this.GetKeyCode(Event.key,true);
      if (!pas.System.Assigned(k)) return Result;
      if ((k === 27) && !(pas.Classes.TComponentStateItem.csDesigning in this.FComponentState) && this.FPopup) {
        this.Close();
      };
      Result = true;
      return Result;
    };
    this.HandleOrientationChange = function (Event) {
      var Result = false;
      var so = 0;
      var isPortrait = false;
      this.Resize$1();
      this.Realign();
      Result = true;
      if (this.FOnOrientationChange != null) {
        var mql = window.matchMedia("(orientation: portrait)");
        isPortrait = (mql.matches);
        if (isPortrait) {
          so = $mod.TScreenOrientation.soLandscape}
         else so = $mod.TScreenOrientation.soPortrait;
        this.FOnOrientationChange(this,so);
      };
      if (this.FOnResize != null) this.FOnResize(this);
      return Result;
    };
    this.HandleDoResize = function () {
      var dr = null;
      var neww = 0;
      var newh = 0;
      dr = this.GetContainer().getBoundingClientRect();
      neww = Math.round(dr.right - dr.left);
      newh = Math.round(dr.bottom - dr.top);
      if ((neww !== this.FOrigWidth) || (newh !== this.FOrigHeight)) {
        this.SetWidth(neww);
        this.SetHeight(newh);
        dr = this.GetContainer().getBoundingClientRect();
        this.FOrigWidth = Math.round(dr.right - dr.left);
        this.FOrigHeight = Math.round(dr.bottom - dr.top);
        this.AlignControl(this);
      };
    };
    this.KeyPreview = function (Key, Shift) {
      var i = 0;
      var lt = 0;
      var ft = 0;
      var lti = 0;
      var fti = 0;
      lt = -1;
      ft = 0xFFFF;
      for (var $l = 0, $end = this.GetControlsCount() - 1; $l <= $end; $l++) {
        i = $l;
        if (!this.GetControls(i).FVisible && this.GetControls(i).FEnabled) continue;
        if (this.GetControls(i).FTabOrder < ft) {
          ft = this.GetControls(i).FTabOrder;
          fti = i;
        };
        if (this.GetControls(i).FTabOrder > lt) {
          lt = this.GetControls(i).FTabOrder;
          lti = i;
        };
        if ((Key.get() === 13) || (Key.get() === 27)) this.GetControls(i).HandleKeyPreview(Key.get());
      };
      if ($mod.Application.FMainForm === this) return;
      if ((Key.get() === 9) && !(pas.Classes.TShiftState$a.ssShift in Shift) && (lti < this.GetControlsCount()) && (fti >= 0) && (fti !== lti)) {
        if (this.GetControls(lti).Focused()) {
          this.GetControls(fti).SetFocus();
          Key.set(0);
        };
      };
      if ((Key.get() === 9) && (pas.Classes.TShiftState$a.ssShift in Shift) && (fti >= 0) && (lti < this.GetControlsCount()) && (fti !== lti)) {
        if (this.GetControls(fti).Focused()) {
          this.GetControls(lti).SetFocus();
          Key.set(0);
        };
      };
    };
    this.GetWidth = function () {
      var Result = 0;
      var dr = null;
      var el = null;
      if (this.FFormElement !== "") {
        el = document.getElementById(this.FFormElement);
        if (el != null) {
          dr = el.getBoundingClientRect();
          Result = Math.round(dr.right - dr.left);
          return Result;
        };
      };
      if (this.GetElementHandle() === document.body) {
        dr = document.documentElement.getBoundingClientRect();
        Result = Math.round(dr.width);
        if (Result > window.innerWidth) Result = window.innerWidth;
      } else {
        if (this.FPopup) {
          Result = pas["WEBLib.Controls"].TControl.GetWidth.call(this)}
         else {
          Result = Math.round(this.GetElementHandle().offsetWidth);
          if (Result === 0) {
            if (this.FFormContainer !== "") {
              Result = pas["WEBLib.Controls"].TControl.GetWidth.call(this)}
             else Result = window.innerWidth;
          };
        };
      };
      return Result;
    };
    this.GetHeight = function () {
      var Result = 0;
      var d = 0;
      var s = "";
      var css = null;
      var el = null;
      var dr = null;
      if (this.FFormElement !== "") {
        el = document.getElementById(this.FFormElement);
        if (el != null) {
          dr = el.getBoundingClientRect();
          Result = Math.round(dr.bottom - dr.top);
          return Result;
        };
      };
      if (this.GetElementHandle() === document.body) {
        css = window.getComputedStyle(this.GetElementHandle());
        s = css.getPropertyValue("margin-top");
        s = pas.System.Copy(s,1,s.length - 2);
        d = Math.round(pas.SysUtils.StrToFloat$1(s,pas.SysUtils.TFormatSettings.Invariant()) - 2);
        dr = document.documentElement.getBoundingClientRect();
        Result = Math.round(dr.height);
        if (Result > window.innerHeight) Result = window.innerHeight - Math.max(0,d);
      } else {
        if (this.FPopup) {
          Result = pas["WEBLib.Controls"].TControl.GetHeight.call(this);
        } else {
          Result = Math.round(this.GetElementHandle().offsetHeight);
          if (Result === 0) {
            if (this.FFormContainer !== "") {
              Result = pas["WEBLib.Controls"].TControl.GetHeight.call(this)}
             else Result = window.innerHeight;
          };
        };
      };
      return Result;
    };
    this.GetLeft = function () {
      var Result = 0;
      var el = null;
      var dr = null;
      if (this.FPopup) {
        Result = pas["WEBLib.Controls"].TControl.GetLeft.call(this);
      } else {
        if (this.FFormElement !== "") {
          el = document.getElementById(this.FFormElement);
          if (el != null) {
            dr = el.getBoundingClientRect();
            Result = Math.round(dr.left);
          };
        } else {
          el = null;
          if (this.FFormContainer !== "") el = document.getElementById(this.FFormContainer);
          if (!(el != null)) el = this.GetElementHandle();
          Result = Math.round(el.offsetLeft);
        };
      };
      return Result;
    };
    this.GetTop = function () {
      var Result = 0;
      var el = null;
      var dr = null;
      if (this.FPopup) {
        Result = pas["WEBLib.Controls"].TControl.GetTop.call(this)}
       else {
        if (this.FFormElement !== "") {
          el = document.getElementById(this.FFormElement);
          if (el != null) {
            dr = el.getBoundingClientRect();
            Result = Math.round(dr.top);
          };
        } else {
          el = null;
          if (this.FFormContainer !== "") el = document.getElementById(this.FFormContainer);
          if (!(el != null)) el = this.GetElementHandle();
          Result = Math.round(el.offsetTop);
        };
      };
      return Result;
    };
    this.GetClientRect = function () {
      var Result = pas.Types.TRect.$new();
      Result.$assign(pas["WEBLib.Controls"].TControl.GetClientRect.call(this));
      return Result;
    };
    this.CreateElement = function () {
      var Result = null;
      var eh = null;
      var caph = null;
      if (!this.FPopup && (this.FormContainerElement() != null)) {
        Result = this.FormContainerElement();
        return Result;
      };
      Result = document.createElement("DIV");
      this.FLayer$1 = this.CreateLayer();
      document.body.appendChild(this.FLayer$1);
      eh = this.FLayer$1;
      if (this.FPopupClose === $mod.TPopupClose.pcOnDeactivate) {
        this.GetMethodPointers();
        eh.addEventListener("click",this.FDoClickPtr);
      };
      eh.style.setProperty(pas["WEBLib.Controls"].CSSZIndex,$mod.Application.MaxZIndexStr());
      if (this.FBorder === $mod.TFormBorderStyle.fbSizeable) {
        Result.style.setProperty("resize","both");
        Result.style.setProperty("overflow","auto");
      };
      this.FHasCaption = false;
      if (this.FBorder in rtl.createSet($mod.TFormBorderStyle.fbSizeable,$mod.TFormBorderStyle.fbDialog,$mod.TFormBorderStyle.fbDialogSizeable)) {
        caph = this.CreateCaption();
        Result.appendChild(caph);
      };
      return Result;
    };
    this.UpdateElement = function () {
      var clr = "";
      var el = null;
      if (this.FCreating) return;
      pas["WEBLib.Controls"].TControl.UpdateElement.call(this);
      if (this.IsUpdating()) return;
      if ((this.GetElementHandle() != null) || (this.GetContainer() != null)) {
        if (this.FCaption !== "") {
          if (!this.FPopup) {
            window.document.title = this.FCaption}
           else {
            if (this.FCaptionElement != null) {
              el = this.FCaptionElement.childNodes.item(0);
              if (el != null) el.nodeValue = this.FCaption;
              if (this.FShowClose && !(this.FCaptionCloseElement != null)) {
                this.FCaptionCloseElement = document.createElement("SPAN");
                this.FCaptionCloseElement.style.setProperty("float","right");
                this.FCaptionCloseElement.style.setProperty("cursor","default");
                this.FCaptionCloseElement.style.setProperty("margin-right","8px");
                this.FCaptionCloseElement.innerHTML = "&#x2716;";
                this.FCaptionElement.appendChild(this.FCaptionCloseElement);
                this.FCaptionCloseElement.addEventListener("click",rtl.createSafeCallback(this,"HandleCloseClick"));
              };
              pas["WEBLib.Controls"].SetHTMLElementFont(this.FCaptionElement,this.FFont,!((this.FElementCaptionClassName === "") && (this.FElementFont === pas["WEBLib.Controls"].TElementFont.efProperty)));
            };
          };
        };
      };
      if (this.GetContainer() != null) {
        clr = pas["WEBLib.Graphics"].ColorToHTML(this.FColor);
        if (this.GetContainer() != null) {
          if ((this.FColor !== -1) && (this.FColor !== 16777215) && !this.FPopup && (this.FElementClassName === "")) this.GetContainer().style.setProperty(pas["WEBLib.Controls"].CSSBackground,clr);
          if (!this.FPopup && (this.FCSSLibrary !== pas["WEBLib.Controls"].TCSSLibrary.cssNone)) document.body.style.removeProperty(pas["WEBLib.Controls"].CSSBackground);
          if ((this.FElementClassName !== "") || (this.FColor === -1) || ((this.FColor === 16777215) && !this.FPopup)) this.GetContainer().style.removeProperty(pas["WEBLib.Controls"].CSSBackground);
          if ((this.FElementClassName === "") && !this.FPopup) {
            document.documentElement.style.setProperty('height','100%');
          };
          pas["WEBLib.Controls"].SetHTMLElementFont(this.GetContainer(),this.FFont,!((this.FElementClassName === "") && (this.FElementFont === pas["WEBLib.Controls"].TElementFont.efProperty)));
        };
        if (this.FPopup) {
          if (!(this.FPopupElement != null)) this.FPopupElement = this.GetContainer();
          if (this.FElementPopupClassName !== "") {
            this.GetContainer().style.removeProperty("border");
            this.FPopupElement.setAttribute("class",this.FElementPopupClassName);
          } else {
            if (this.FShadow) {
              this.FPopupElement.style.setProperty("box-shadow","3px 3px 3px silver");
            } else {
              this.FPopupElement.style.removeProperty("box-shadow");
            };
            this.FPopupElement.style.setProperty("border","1px solid gray");
          };
          if ((this.FCSSLibrary === pas["WEBLib.Controls"].TCSSLibrary.cssBootstrap) && (this.FElementClassName === "")) {
            this.FPopupElement.setAttribute("class","card");
            this.FPopupElement.style.setProperty("display","block");
            this.GetContainer().style.removeProperty("box-shadow");
          };
        } else {
          this.GetContainer().style.removeProperty("box-shadow");
        };
      };
    };
    this.ContainerElement = function () {
      var Result = null;
      Result = this.FormContainerElement();
      return Result;
    };
    this.FormContainerElement = function () {
      var Result = null;
      if (pas.Classes.TComponentStateItem.csDesigning in this.FComponentState) {
        if (this.FDesignContainer != null) Result = this.FDesignContainer;
      };
      if (this.FFormContainer !== "") {
        Result = document.getElementById(this.FFormContainer);
        if (!(Result != null)) Result = document.body;
      } else {
        Result = document.body;
      };
      return Result;
    };
    this.GetElementBindHandle = function () {
      var Result = null;
      if (pas.Classes.TComponentStateItem.csDesigning in this.FComponentState) {
        Result = window;
        return Result;
      };
      if (this.FFormContainer !== "") {
        Result = window;
      } else {
        if (!this.FPopup) {
          Result = window;
        } else Result = pas["WEBLib.Controls"].TControl.GetElementBindHandle.call(this);
      };
      return Result;
    };
    this.GetElementHandle = function () {
      var Result = null;
      if (this.FPopup) {
        Result = pas["WEBLib.Controls"].TControl.GetElementHandle.call(this);
        if (!(Result != null)) Result = this.FPopupElement;
      } else Result = this.FormContainerElement();
      return Result;
    };
    this.SetElementClassName = function (AValue) {
      pas["WEBLib.Controls"].TControl.SetElementClassName.apply(this,arguments);
      if (this.FPopup && (this.FPopupElement != null)) {
        this.FPopupElement.setAttribute("class",AValue);
      };
    };
    this.CloseQuery = function () {
      var Result = false;
      Result = true;
      if (this.FOnCloseQuery != null) this.FOnCloseQuery(this,{get: function () {
          return Result;
        }, set: function (v) {
          Result = v;
        }});
      return Result;
    };
    this.LoadDFMValues = function () {
    };
    this.Init = function () {
    };
    this.IsFocused = function () {
      var Result = false;
      Result = false;
      return Result;
    };
    this.CreateLayer = function () {
      var Result = null;
      Result = document.createElement("SPAN");
      Result.style.setProperty("top","0");
      Result.style.setProperty("left","0");
      Result.style.setProperty("right","0");
      Result.style.setProperty("bottom","0");
      Result.style.setProperty("webkit-user-select","none");
      Result.style.setProperty("moz-user-select","none");
      Result.style.setProperty("khtml-user-select","none");
      Result.style.setProperty("ms-user-select","none");
      Result.style.setProperty("user-select","none");
      Result.style.setProperty("position","absolute");
      Result.style.setProperty("z-index",$mod.Application.MaxZIndexStr());
      return Result;
    };
    this.CreateCaption = function () {
      var Result = null;
      var BarHeight = "";
      BarHeight = pas.SysUtils.IntToStr($mod.Application.FFormCaptionHeight);
      this.FCaptionElement = document.createElement("DIV");
      this.FCaptionElement.innerHTML = this.FCaption;
      this.FCaptionElement.style.setProperty(pas["WEBLib.Controls"].CSSBackground,pas["WEBLib.Graphics"].ColorToHTML($mod.Application.FThemeColor));
      this.FCaptionElement.style.setProperty("color",pas["WEBLib.Graphics"].ColorToHTML($mod.Application.FThemeTextColor));
      this.FCaptionElement.style.setProperty("cursor","move");
      this.FCaptionElement.style.setProperty("height",BarHeight + "px");
      this.FCaptionElement.style.setProperty("line-height",BarHeight + "px");
      this.FCaptionElement.style.setProperty("border-bottom","1px solid black");
      this.FCaptionElement.style.setProperty("padding-left","4px");
      this.FCaptionElement.style.setProperty("-moz-user-select","none");
      this.FCaptionElement.style.setProperty("-webkit-user-select","none");
      this.FCaptionElement.style.setProperty("-ms-user-select","none");
      this.FCaptionElement.style.setProperty("user-select","none");
      this.FCaptionElement.style.setProperty("-o-user-select","none");
      if (this.FElementCaptionClassName !== "") this.FCaptionElement.setAttribute("class",this.FElementCaptionClassName);
      pas["WEBLib.Controls"].SetHTMLElementFont(this.FCaptionElement,this.FFont,!((this.FElementCaptionClassName === "") && (this.FElementFont === pas["WEBLib.Controls"].TElementFont.efProperty)));
      if (!(this.FTitleDownPtr != null)) this.GetMethodPointers();
      this.FCaptionElement.innerHTML = this.FCaption;
      this.FCaptionElement.addEventListener("mousedown",this.FTitleDownPtr);
      this.FHasCaption = true;
      Result = this.FCaptionElement;
      return Result;
    };
    this.GetCaptionHeight = function () {
      var Result = 0;
      var r = null;
      Result = 0;
      if ((this.FCaptionElement != null) && (this.FBorder in rtl.createSet($mod.TFormBorderStyle.fbDialog,$mod.TFormBorderStyle.fbDialogSizeable))) {
        r = this.FCaptionElement.getBoundingClientRect();
        Result = Math.round(r.bottom - r.top);
      };
      return Result;
    };
    this.SetColorScheme = function (AScheme) {
      var s = "";
      if (!$mod.Application.FThemed) return;
      var $tmp = AScheme;
      if ($tmp === $mod.TApplicationColorScheme.csDark) {
        this.SetColor(0x202124);
        s = "label,option,td,table,ul,li {background-color: #202124; color: #BEC1C6;}" + "\r\n" + "body,input,textarea,select,fieldset {background-color: #202124; color: #BEC1C6; border: 1px solid gray;}" + "\r\n" + "input:focus, textarea:focus, select:focus, span:focus { border: 1px solid silver; outline: none !important;}";
        this.AddCSS("appscheme",s);
      } else if ($tmp === $mod.TApplicationColorScheme.csLight) {
        this.SetColor(16777215);
        this.RemoveCSS("appscheme");
      };
    };
    this.SetCSSLibrary = function (ALibrary) {
      this.FCSSLibrary = ALibrary;
      if ((ALibrary === pas["WEBLib.Controls"].TCSSLibrary.cssBootstrap) && (pas.Classes.TComponentStateItem.csDesigning in this.FComponentState) && !(pas.Classes.TComponentStateItem.csLoading in this.FComponentState)) this.SetElementFont(pas["WEBLib.Controls"].TElementFont.efCSS);
    };
    this.SetFormPos = function () {
      if (!(this.GetContainer() != null)) return;
      if (this.FPosition === $mod.TPosition.poScreenCenter) {
        this.FLeft = Math.round(($mod.WinWidth() - this.GetWidth()) / 2) + window.scrollX;
        this.FTop = Math.round(($mod.WinHeight() - this.GetHeight()) / 2) + window.scrollY;
      };
      this.GetContainer().style.setProperty("position","absolute");
      this.GetContainer().style.setProperty("width",pas.SysUtils.IntToStr(this.GetWidth()) + "px");
      this.GetContainer().style.setProperty("height",pas.SysUtils.IntToStr(this.GetHeight()) + "px");
      this.GetContainer().style.setProperty("left",pas.SysUtils.IntToStr(this.GetLeft()) + "px");
      this.GetContainer().style.setProperty("top",pas.SysUtils.IntToStr(this.GetTop()) + "px");
    };
    this.GetHTMLFileName = function (ADirectForm) {
      var Result = "";
      if (ADirectForm) {
        Result = ""}
       else Result = this.$module.$name + $mod.Application.GetFormExtension();
      return Result;
    };
    this.LoadedDone = function () {
      $mod.Application.TriggerNotification();
    };
    this.Loaded = function () {
      var el = null;
      pas["WEBLib.Controls"].TControl.Loaded.call(this);
      if ((this.FFormContainer !== "") && (this.FElementClassName !== "")) {
        el = this.FormContainerElement();
        if (el != null) {
          el.setAttribute("class",this.FElementClassName);
        };
      };
      this.LoadedDone();
    };
    this.ColorChanging = function () {
      pas["WEBLib.Controls"].TControl.ColorChanging.call(this);
      if (this.GetContainer() != null) {
        this.GetContainer().style.setProperty(pas["WEBLib.Controls"].CSSBackground,pas["WEBLib.Graphics"].ColorToHTML(this.FColor));
      };
    };
    this.CreateInitialize = function () {
      pas["WEBLib.Controls"].TControl.CreateInitialize.call(this);
      this.FAllowTouch = true;
      this.FModalResult = 0;
      this.FFormStyle = $mod.TFormStyle.fsNormal;
      this.FBorder = $mod.TFormBorderStyle.fbSizeable;
      this.FShadow = true;
      this.FShowClose = true;
      this.FTimerID = -1;
      this.FCaptionElement = null;
      this.FColor = 16777215;
      window.addEventListener("load",this.FLoadedPtr);
    };
    this.Create$2 = function (id) {
      this.FNoHTML = false;
      this.FCreating = true;
      this.FFormContainer = id;
      if (id === "") {
        pas["WEBLib.Controls"].TControl.Create$2.call(this,pas["WEBLib.WebTools"].cBodyTag)}
       else pas["WEBLib.Controls"].TControl.Create$2.call(this,id);
      this.FFormElement = "";
      this.FModalResult = 0;
      this.FFormStyle = $mod.TFormStyle.fsNormal;
      this.DoCreate();
      return this;
    };
    this.Create$5 = function (id, AReference) {
      this.FCreating = true;
      this.FFormContainer = id;
      pas["WEBLib.Controls"].TControl.Create$2.call(this,id);
      AReference.set(this);
      this.FFormElement = "";
      this.FModalResult = 0;
      this.FFormStyle = $mod.TFormStyle.fsNormal;
      this.DoCreate();
      return this;
    };
    this.Create$1 = function (AOwner) {
      this.FNoHTML = false;
      this.FCreating = true;
      this.FResizeObserver = null;
      pas["WEBLib.Controls"].TControl.Create$1.apply(this,arguments);
      this.FBorder = $mod.TFormBorderStyle.fbSingle;
      this.FFormFileName = "";
      this.FPopupMode = $mod.TPopupMode.pmNone;
      this.FPopupClose = $mod.TPopupClose.pcOnDeactivate;
      this.FPopup = true;
      this.FPosition = $mod.TPosition.poScreenCenter;
      this.FPopupOpacity = 1.0;
      this.FCreated = true;
      return this;
    };
    this.Create$7 = function (AOwner, IsPopup, ABorder, ATitle) {
      this.FNoHTML = false;
      this.FCreating = true;
      this.FResizeObserver = null;
      pas["WEBLib.Controls"].TControl.Create$1.call(this,AOwner);
      this.FBorder = ABorder;
      this.FCaption = ATitle;
      this.FFormFileName = "";
      this.FPopupMode = $mod.TPopupMode.pmNone;
      this.FPopupClose = $mod.TPopupClose.pcOnDeactivate;
      this.FPopup = IsPopup;
      this.FPosition = $mod.TPosition.poScreenCenter;
      this.FPopupOpacity = 1.0;
      return this;
    };
    this.CreateNew = function (AOwner, Dummy) {
      this.Create$1(AOwner);
      return this;
    };
    this.CreateNew$1 = function (AFileName) {
      this.FCreating = true;
      pas["WEBLib.Controls"].TControl.Create$2.call(this,pas["WEBLib.WebTools"].cBodyTag);
      this.FFormFileName = AFileName;
      if (this.FFormFileName !== "") $mod.Application.LoadForm(this,AFileName);
      return this;
    };
    this.CreateNew$2 = function () {
      var AFileName = "";
      this.FCreating = true;
      AFileName = this.$class.GetHTMLFileName(false);
      pas["WEBLib.Controls"].TControl.Create$2.call(this,pas["WEBLib.WebTools"].cBodyTag);
      this.FFormFileName = AFileName;
      if (this.FFormFileName !== "") $mod.Application.LoadForm(this,AFileName);
      return this;
    };
    this.CreateNew$3 = function (AProc) {
      this.FCreatedProc = AProc;
      this.CreateNew$2();
      return this;
    };
    this.CreateNew$4 = function (AElementID, AProc) {
      this.CreateNew$5(AElementID,"",AProc);
      return this;
    };
    this.CreateNew$5 = function (AElementID, AFileName, AProc) {
      this.FCreating = true;
      this.FFormContainer = AElementID;
      pas["WEBLib.Controls"].TControl.Create$2.call(this,AElementID);
      this.FCreatedProc = AProc;
      this.FFormElement = AElementID;
      if (AFileName === "") AFileName = this.$class.GetHTMLFileName(false);
      if (AFileName !== "") {
        $mod.Application.LoadForm(this,AFileName)}
       else if (this.FCreatedProc != null) this.FCreatedProc(this);
      return this;
    };
    this.CreateNewDirect = function (AElementID, AProc) {
      this.FCreating = true;
      this.FFormContainer = AElementID;
      pas["WEBLib.Controls"].TControl.Create$2.call(this,AElementID);
      this.FCreatedProc = AProc;
      this.FFormElement = AElementID;
      this.Init();
      this.LoadDFMValues();
      if (this.FCreatedProc != null) this.FCreatedProc(this);
      return this;
    };
    this.CreateDialog = function (ACaption) {
      var AFileName = "";
      this.FCreating = true;
      AFileName = this.$class.GetHTMLFileName(false);
      pas["WEBLib.Controls"].TControl.Create$2.call(this,pas["WEBLib.WebTools"].cBodyTag);
      this.SetCaption(ACaption);
      this.FPopup = true;
      this.SetBorder($mod.TFormBorderStyle.fbDialog);
      this.FFormFileName = AFileName;
      $mod.Application.LoadForm(this,AFileName);
      return this;
    };
    this.CreateDialogNew = function (ACaption) {
      var AFileName = "";
      this.FNoHTML = true;
      this.FCreating = true;
      AFileName = this.$class.GetHTMLFileName(false);
      pas["WEBLib.Controls"].TControl.Create$2.call(this,pas["WEBLib.WebTools"].cBodyTag);
      this.SetCaption(ACaption);
      this.FPopup = true;
      this.SetPosition($mod.TPosition.poScreenCenter);
      this.SetBorder($mod.TFormBorderStyle.fbDialog);
      this.FFormFileName = AFileName;
      return this;
    };
    this.Load = function () {
      var $Self = this;
      var Result = null;
      this.FShown = false;
      this.FFormFileName = this.$class.GetHTMLFileName(this.FDirectForm);
      this.Loading();
      if (this.FFormFileName === "") {
        this.Init();
        this.LoadDFMValues();
        Result = new Promise(function (ASuccess, AFailed) {
          ASuccess($Self);
        });
      } else {
        Result = new Promise(function (ASuccess, AFailed) {
          $mod.Application.LoadForm$1($Self,$Self.FFormFileName,function (AForm) {
            ASuccess(AForm);
          });
        });
      };
      return Result;
    };
    this.Execute = function () {
      var $Self = this;
      var Result = null;
      Result = new Promise(function (ASuccess, AFailed) {
        $Self.ShowModal$1(function (AValue) {
          ASuccess(AValue);
        });
      });
      return Result;
    };
    this.LoadAndExecute = function () {
      var $Self = this;
      var Result = null;
      async function LoadAsync() {
        var Result = false;
        Result = await $Self.Load();
        return Result;
      };
      LoadAsync();
      Result = new Promise(function (ASuccess, AFailed) {
        $Self.ShowModal$1(function (AValue) {
          ASuccess(AValue);
        });
      });
      return Result;
    };
    this.Destroy = function () {
      if (this.FVisible) this.Close();
      if (this.FOnDestroy != null) this.FOnDestroy(this);
      pas["WEBLib.Controls"].TControl.Destroy.call(this);
      if (this.FLayer$1 != null) {
        if (this.FormContainerElement() === this.FLayer$1.parentNode) this.FormContainerElement().removeChild(this.FLayer$1);
        this.FLayer$1 = null;
      };
    };
    this.Close = function () {
      var lAction = 0;
      var el = null;
      if (this.CloseQuery()) {
        this.UnbindEvents();
        lAction = $mod.TCloseAction.caHide;
        if (this.FTimerID !== -1) {
          window.clearInterval(this.FTimerID);
          this.FTimerID = -1;
        };
        if (this.FOnClose != null) this.FOnClose(this,{get: function () {
            return lAction;
          }, set: function (v) {
            lAction = v;
          }});
        if (lAction !== $mod.TCloseAction.caNone) {
          if (this.FLayer$1 != null) {
            if (this.GetContainer().parentNode === this.FLayer$1) {
              this.FLayer$1.removeChild(this.GetContainer());
            } else {
              if (this.GetContainer().parentNode.parentNode === this.FLayer$1) this.FLayer$1.removeChild(this.GetContainer().parentNode);
            };
            this.FContainer = null;
            if (this.FormContainerElement() === this.FLayer$1.parentNode) {
              this.FormContainerElement().removeChild(this.FLayer$1);
              $mod.Application.ChangeMaxZIndex(-1);
            };
            this.FLayer$1 = null;
          };
          if (this.FFormFileName === "") {
            if ((this.FFormElement !== "") && (this.GetContainer() != null)) {
              this.GetContainer().innerHTML = "";
              this.FContainer = null;
            } else if (this.GetContainer() != null) {
              if (this.FormContainerElement() === this.GetContainer().parentNode) this.FormContainerElement().removeChild(this.GetContainer());
              this.FContainer = null;
            };
          } else {
            if (this.FFormElement !== "") {
              this.GetContainer().innerHTML = "";
              this.FContainer = null;
            };
          };
          if ((this.FFormElement !== this.FFormContainer) && (this.FFormElement !== "")) {
            el = document.getElementById(this.FFormElement);
            if (el != null) el.innerHTML = "";
          };
          this.DoClose({get: function () {
              return lAction;
            }, set: function (v) {
              lAction = v;
            }});
          if ((lAction === $mod.TCloseAction.caFree) && !(pas.Classes.TComponentStateItem.csDestroying in this.FComponentState)) {
            this.SetVisible(false);
            $impl.ReleaseForm(this);
            if ($mod.Application.FMainForm === this) $mod.Application.FMainForm = null;
          };
          $mod.Application.FActiveForm = this.FPrevActiveForm;
          this.FShown = false;
          this.SetVisible(false);
        };
      };
    };
    this.GetUniqueComponentName = function (AComponent) {
      var Result = "";
      var s = "";
      var i = 0;
      var j = 0;
      var found = false;
      i = 1;
      do {
        found = false;
        s = pas.System.Copy(this.$classname,2,this.$classname.length) + "_" + pas.System.Copy(AComponent.$classname,2,AComponent.$classname.length) + pas.SysUtils.IntToStr(i);
        i += 1;
        for (var $l = 0, $end = this.GetComponentCount() - 1; $l <= $end; $l++) {
          j = $l;
          if (this.GetComponent(j).FName === s) {
            found = true;
            break;
          };
        };
      } while (!(found === false));
      Result = s;
      return Result;
    };
    this.IsMiletus = function () {
      var Result = false;
      var cl = null;
      cl = this.$class.ClassType();
      Result = false;
      do {
        cl = cl.$ancestor;
        if ((cl != null) && (cl.$classname === "TMiletusForm")) {
          Result = true;
          break;
        };
      } while (!(!(cl != null) || (cl.$classname === "TForm")));
      return Result;
    };
    this.PreventDefault$1 = function () {
      this.GetElementEvent().preventDefault();
    };
    this.SetBounds = function (X, Y, AWidth, AHeight) {
      if (pas.Classes.TComponentStateItem.csDesigning in this.FComponentState) {
        this.Resize$1();
        this.SetBoundsInt(X,Y,AWidth,AHeight);
      } else pas["WEBLib.Controls"].TControl.SetBounds.call(this,X,Y,AWidth,AHeight);
    };
    this.SelectFirst = function () {
      if (this.GetControlsCount() > 0) this.GetControls(0).SetFocus();
    };
    this.SelectNext = function (CurControl, GoForward, CheckTabStop) {
      var i = 0;
      if (this.GetControlsCount() > 0) {
        for (var $l = 0, $end = this.GetControlsCount() - 1; $l <= $end; $l++) {
          i = $l;
          if (this.GetControls(i) === CurControl) {
            if (GoForward) {
              if ((i + 1) <= (this.GetControlsCount() - 1)) {
                this.GetControls(i + 1).SetFocus()}
               else this.GetControls(0).SetFocus();
            } else {
              if ((i - 1) >= 0) {
                this.GetControls(i - 1).SetFocus()}
               else this.GetControls(this.GetControlsCount() - 1).SetFocus();
            };
            break;
          };
        };
      };
    };
    this.Show$1 = function () {
      var dr = null;
      if (this.FCreating && this.FPopup) {
        $mod.Application.ChangeMaxZIndex(+1);
        this.FCreating = false;
        this.UpdateElement();
      };
      if (this.FFormFileName === "") {
        if (!(this.GetContainer() != null)) {
          if (this.FPopup) {
            this.FContainer = this.CreateElement();
            this.FPopupElement = this.GetContainer();
            this.SetFormPos();
            this.UpdateElement();
            this.FLayer$1.appendChild(this.GetContainer());
          } else {
            this.FContainer = this.CreateLayer();
            this.GetContainer().style.setProperty(pas["WEBLib.Controls"].CSSBackground,pas["WEBLib.Graphics"].ColorToHTML(this.FColor));
            document.body.appendChild(this.GetContainer());
          };
        } else {
          if (this.FPopup) {
            this.SetFormPos();
            this.FLayer$1.appendChild(this.GetContainer());
          } else {
            if (this.FLayer$1 != null) {
              this.FLayer$1.appendChild(this.GetContainer());
            } else {
              document.body.appendChild(this.GetContainer());
            };
          };
        };
        if (this.FPopup) {
          if (this.FBorder === $mod.TFormBorderStyle.fbSizeable) {
            dr = this.GetContainer().getBoundingClientRect();
            this.FOrigWidth = Math.round(dr.right - dr.left);
            this.FOrigHeight = Math.round(dr.bottom - dr.top);
            this.FTimerID = window.setInterval(rtl.createSafeCallback(this,"HandleDoResize"),100);
          } else {
            this.GetContainer().style.setProperty("resize","");
            this.GetContainer().style.setProperty("overflow","");
          };
        };
      };
      this.SetVisible(true);
      this.DoShow();
    };
    this.ShowModal = function () {
      var Result = 0;
      Result = this.ShowModal$1(null);
      return Result;
    };
    this.ShowModal$1 = function (AProc) {
      var Result = 0;
      if (this.FNoHTML || (this.FFormFileName === "")) {
        this.FPrevActiveForm = $mod.Application.FActiveForm;
        $mod.Application.FActiveForm = this;
        if (!this.FCreated) $mod.Application.CreateNewForm(this,"");
      };
      Result = 0;
      this.FNoHTML = false;
      this.FModalProc = AProc;
      this.SetModalResult(0);
      this.Show$1();
      return Result;
    };
    this.AddCSS = function (id, css) {
      function writeStylesOnce(styleName, cssText) {
          var styleElement = document.getElementById(styleName);
          if (styleElement) {
               styleElement.innerHTML = cssText;
            return;
            }
          styleElement = document.createElement('style');
          styleElement.type = 'text/css';
          styleElement.id = styleName;
          styleElement.innerHTML = cssText;
          document.getElementsByTagName('head')[0].appendChild(styleElement);
      }
      writeStylesOnce(id,css);
    };
    this.RemoveCSS = function (id) {
      var el = null;
      el = document.getElementById(id);
      if (el != null) document.head.removeChild(el);
    };
    this.UpdateCSS = function (id, css) {
      this.RemoveCSS(id);
      this.AddCSS(id,css);
    };
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
    var $r = this.$rtti;
    $r.addMethod("Create$2",2,[["id",rtl.string]]);
    $r.addMethod("Create$5",2,[["id",rtl.string],["AReference",null,1]]);
    $r.addMethod("Create$1",2,[["AOwner",pas.Classes.$rtti["TComponent"]]]);
    $r.addMethod("Create$7",2,[["AOwner",pas.Classes.$rtti["TComponent"]],["IsPopup",rtl.boolean],["ABorder",$mod.$rtti["TFormBorderStyle"]],["ATitle",rtl.string]]);
    $r.addMethod("CreateNew",2,[["AOwner",pas.Classes.$rtti["TComponent"]],["Dummy",rtl.longint]]);
    $r.addMethod("CreateNew$1",2,[["AFileName",rtl.string]]);
    $r.addMethod("CreateNew$2",2,[]);
    $r.addMethod("CreateNew$3",2,[["AProc",$mod.$rtti["TFormCreatedProc"]]]);
    $r.addMethod("CreateNew$4",2,[["AElementID",rtl.string],["AProc",$mod.$rtti["TFormCreatedProc"]]]);
    $r.addMethod("CreateNew$5",2,[["AElementID",rtl.string],["AFileName",rtl.string],["AProc",$mod.$rtti["TFormCreatedProc"]]]);
    $r.addMethod("CreateNewDirect",2,[["AElementID",rtl.string],["AProc",$mod.$rtti["TFormCreatedProc"]]]);
    $r.addMethod("CreateDialog",2,[["ACaption",rtl.string]]);
    $r.addMethod("CreateDialogNew",2,[["ACaption",rtl.string]]);
  });
  this.$rtti.$Class("TForm");
  this.$rtti.$ClassRef("TFormClass",{instancetype: this.$rtti["TForm"]});
  rtl.createClass(this,"TForm",this.TCustomForm,function () {
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
    var $r = this.$rtti;
    $r.addProperty("Align",2,pas["WEBLib.Controls"].$rtti["TAlign"],"FAlign","SetAlign",{Default: pas["WEBLib.Controls"].TAlign.alNone});
    $r.addProperty("Caption",2,rtl.string,"FCaption","SetCaption");
    $r.addProperty("Color",2,pas["WEBLib.Graphics"].$rtti["TColor"],"FColor","SetColor");
    $r.addProperty("CSSLibrary",2,pas["WEBLib.Controls"].$rtti["TCSSLibrary"],"FCSSLibrary","SetCSSLibrary",{Default: pas["WEBLib.Controls"].TCSSLibrary.cssNone});
    $r.addProperty("ElementClassName",2,pas["WEBLib.Controls"].$rtti["TElementClassName"],"FElementClassName","SetElementClassName");
    $r.addProperty("ElementFont",2,pas["WEBLib.Controls"].$rtti["TElementFont"],"FElementFont","SetElementFont",{Default: pas["WEBLib.Controls"].TElementFont.efProperty});
    $r.addProperty("ElementPosition",2,pas["WEBLib.Controls"].$rtti["TElementPosition"],"FElementPosition","SetElementPosition",{Default: pas["WEBLib.Controls"].TElementPosition.epAbsolute});
    $r.addProperty("Font",2,pas["WEBLib.Graphics"].$rtti["TFont"],"FFont","SetFont");
    $r.addProperty("FormContainer",2,pas["WEBLib.Controls"].$rtti["TElementID"],"FFormContainer","SetFormContainer");
    $r.addProperty("FormStyle",3,$mod.$rtti["TFormStyle"],"GetFormStyle","SetFormStyle");
    $r.addProperty("Menu",0,pas["WEBLib.Controls"].$rtti["TCustomControl"],"FMenu","FMenu");
    $r.addProperty("ParentFont",2,rtl.boolean,"FParentFont","SetParentFont",{Default: true});
    $r.addProperty("Shadow",2,rtl.boolean,"FShadow","SetShadow",{Default: true});
    $r.addProperty("ShowClose",0,rtl.boolean,"FShowClose","FShowClose",{Default: true});
    $r.addProperty("TabOrder",2,rtl.longint,"FTabOrder","SetTabOrder");
    $r.addProperty("TabStop",2,rtl.boolean,"FTabStop","SetTabStop",{Default: true});
    $r.addProperty("OnBeforeUnload",0,$mod.$rtti["TBeforeUnloadEvent"],"FOnBeforeUnload","FOnBeforeUnload");
    $r.addProperty("OnClick",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnClick","FOnClick");
    $r.addProperty("OnClose",0,$mod.$rtti["TCloseEvent"],"FOnClose","FOnClose");
    $r.addProperty("OnCloseQuery",0,$mod.$rtti["TCloseQueryEvent"],"FOnCloseQuery","FOnCloseQuery");
    $r.addProperty("OnCreate",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnCreate","FOnCreate");
    $r.addProperty("OnDblClick",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnDblClick","FOnDblClick");
    $r.addProperty("OnDeactivate",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnDeactivate","FOnDeactivate");
    $r.addProperty("OnDestroy",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnDestroy","FOnDestroy");
    $r.addProperty("OnDOMContentLoaded",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnDOMContentLoaded","FOnDOMContentLoaded");
    $r.addProperty("OnHashChange",0,$mod.$rtti["THashChangeEvent"],"FOnHashChange","FOnHashChange");
    $r.addProperty("OnResize",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnResize","FOnResize");
    $r.addProperty("OnShow",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnShow","FOnShow");
    $r.addProperty("OnScroll",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnScroll","FOnScroll");
    $r.addProperty("OnOrientationChange",0,$mod.$rtti["TOrientationChangeEvent"],"FOnOrientationChange","FOnOrientationChange");
    $r.addProperty("OnPaint",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnPaint","FOnPaint");
    $r.addProperty("OnTouchStart",0,pas["WEBLib.Controls"].$rtti["TTouchEvent"],"FOnTouchStart","FOnTouchStart");
    $r.addProperty("OnTouchMove",0,pas["WEBLib.Controls"].$rtti["TTouchEvent"],"FOnTouchMove","FOnTouchMove");
    $r.addProperty("OnTouchEnd",0,pas["WEBLib.Controls"].$rtti["TTouchEvent"],"FOnTouchEnd","FOnTouchEnd");
    $r.addProperty("OnUnload",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnUnload","FOnUnload");
  });
  this.$rtti.$ClassRef("TWebFormClass",{instancetype: this.$rtti["TForm"]});
  rtl.createClass(this,"TCustomFrame",pas["WEBLib.Controls"].TCustomHTMLDiv,function () {
    this.$init = function () {
      pas["WEBLib.Controls"].TCustomHTMLDiv.$init.call(this);
      this.FAutoScroll = false;
      this.FAutoSize = false;
      this.FBiDiMode$1 = 0;
      this.FConstraints = null;
      this.FCtl3D$1 = false;
      this.FDockSite = false;
      this.FDragCursor = 0;
      this.FDragKind = 0;
      this.FDragMode$1 = 0;
      this.FOnAlignInsertBefore = null;
      this.FOnAlignPosition = null;
      this.FOnCanResize = null;
      this.FOnConstrainedResize = null;
      this.FOnContextPopup = null;
      this.FOnDockDrop = null;
      this.FOnDockOver = null;
      this.FOnEndDock = null;
      this.FOnGesture = null;
      this.FOnGetSiteInfo = null;
      this.FOnMouseActivate = null;
      this.FOnMouseWheelDown$1 = null;
      this.FOnMouseWheelUp$1 = null;
      this.FOnStartDock = null;
      this.FOnUnDock = null;
      this.FPadding = null;
      this.FParentBackground = false;
      this.FParentCtl3D$1 = false;
      this.FPopupMenu = null;
    };
    this.$final = function () {
      this.FConstraints = undefined;
      this.FOnAlignInsertBefore = undefined;
      this.FOnAlignPosition = undefined;
      this.FOnCanResize = undefined;
      this.FOnConstrainedResize = undefined;
      this.FOnContextPopup = undefined;
      this.FOnDockDrop = undefined;
      this.FOnDockOver = undefined;
      this.FOnEndDock = undefined;
      this.FOnGesture = undefined;
      this.FOnGetSiteInfo = undefined;
      this.FOnMouseActivate = undefined;
      this.FOnMouseWheelDown$1 = undefined;
      this.FOnMouseWheelUp$1 = undefined;
      this.FOnStartDock = undefined;
      this.FOnUnDock = undefined;
      this.FPadding = undefined;
      this.FPopupMenu = undefined;
      pas["WEBLib.Controls"].TCustomHTMLDiv.$final.call(this);
    };
    var cMethodGet = "GET";
    var cTypeLoad = "load";
    this.LoadHTMLFile = function (AId) {
      var $Self = this;
      var lFileName = "";
      var lRequest = null;
      function DoStatusCreate(AEvent) {
        var Result = false;
        var lElement = null;
        var lResponse = "";
        if (AEvent === null) return false;
        lResponse = AEvent.target.responseText;
        lElement = document.getElementById(AId);
        lElement.innerHTML = lResponse;
        Result = true;
        return Result;
      };
      lFileName = this.$class.GetHTMLFileName();
      if (lFileName !== "") {
        lRequest = new XMLHttpRequest();
        lRequest.addEventListener(cTypeLoad,rtl.createSafeCallback(null,DoStatusCreate));
        lRequest.open(cMethodGet,lFileName);
        lRequest.send();
      };
    };
    this.SetConstraints = function (AValue) {
      this.FConstraints.Assign(AValue);
    };
    this.SetPopupMenu = function (AValue) {
      this.FPopupMenu = AValue;
    };
    this.SetPadding = function (AValue) {
      this.FPadding.Assign(AValue);
    };
    this.GetHTMLFileName = function () {
      var Result = "";
      Result = this.$module.$name + $mod.Application.GetFormExtension();
      return Result;
    };
    this.LoadDFMValues = function () {
    };
    this.UpdateElement = function () {
      var nocolor = false;
      pas["WEBLib.Controls"].TControl.UpdateElement.call(this);
      nocolor = this.FColor in rtl.createSet(15790320,-1,16777215,16711422);
      if ((this.GetElementHandle() != null) && !this.IsUpdating() && (pas.Classes.TComponentStateItem.csDesigning in this.FComponentState) && nocolor) {
        this.GetElementHandle().style.setProperty("background-color",pas["WEBLib.Graphics"].ColorToHTML(0xF0F0F0));
      };
    };
    this.Create$2 = function (AId) {
      pas["WEBLib.Controls"].TControl.Create$2.call(this,AId);
      this.FPadding = pas["WEBLib.Controls"].TPadding.$create("Create$1");
      this.LoadHTMLFile(AId);
      return this;
    };
    this.Create$1 = function (AOwner) {
      pas["WEBLib.Controls"].TControl.Create$1.call(this,AOwner);
      this.FPadding = pas["WEBLib.Controls"].TPadding.$create("Create$1");
      this.FConstraints = $mod.TSizeConstraints.$create("Create$1",[this]);
      return this;
    };
    this.CreateNew = function (AOwner) {
      this.Create$1(AOwner);
      this.BeforeLoadDFMValues();
      try {
        this.LoadFromForm();
      } finally {
        this.AfterLoadDFMValues();
      };
      return this;
    };
    this.Destroy = function () {
      rtl.free(this,"FConstraints");
      rtl.free(this,"FPadding");
      pas["WEBLib.Controls"].TCustomControl.Destroy.call(this);
    };
    this.LoadFromForm = function () {
      this.LoadDFMValues();
    };
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
    var $r = this.$rtti;
    $r.addMethod("Create$2",2,[["AId",rtl.string]]);
    $r.addMethod("Create$1",2,[["AOwner",pas.Classes.$rtti["TComponent"]]]);
    $r.addMethod("CreateNew",2,[["AOwner",pas.Classes.$rtti["TComponent"]]]);
  });
  this.$rtti.$Class("TFrame");
  this.$rtti.$ClassRef("TFrameClass",{instancetype: this.$rtti["TFrame"]});
  rtl.createClass(this,"TFrame",this.TCustomFrame,function () {
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
    var $r = this.$rtti;
    $r.addProperty("Align",2,pas["WEBLib.Controls"].$rtti["TAlign"],"FAlign","SetAlign",{Default: pas["WEBLib.Controls"].TAlign.alNone});
    $r.addProperty("Anchors",2,pas["WEBLib.Controls"].$rtti["TAnchors"],"FAnchors","SetAnchors",{Default: rtl.createSet(pas["WEBLib.Controls"].TAnchorKind.akLeft,pas["WEBLib.Controls"].TAnchorKind.akTop)});
    $r.addProperty("AutoScroll",0,rtl.boolean,"FAutoScroll","FAutoScroll",{Default: false});
    $r.addProperty("AutoSize",0,rtl.boolean,"FAutoSize","FAutoSize",{Default: false});
    $r.addProperty("BiDiMode",4,pas["WEBLib.Controls"].$rtti["TBiDiMode"],"FBiDiMode$1","FBiDiMode$1");
    $r.addProperty("Constraints",2,$mod.$rtti["TSizeConstraints"],"FConstraints","SetConstraints");
    $r.addProperty("DockSite",0,rtl.boolean,"FDockSite","FDockSite",{Default: false});
    $r.addProperty("DoubleBuffered",0,rtl.boolean,"FDoubleBuffered","FDoubleBuffered",{Default: false});
    $r.addProperty("DragCursor",0,pas["WEBLib.Controls"].$rtti["TCursor"],"FDragCursor","FDragCursor",{Default: 12});
    $r.addProperty("DragKind",0,pas["WEBLib.Controls"].$rtti["TDragKind"],"FDragKind","FDragKind",{Default: pas["WEBLib.Controls"].TDragKind.dkDrag});
    $r.addProperty("DragMode",0,pas["WEBLib.Controls"].$rtti["TDragMode"],"FDragMode$1","FDragMode$1",{Default: pas["WEBLib.Controls"].TDragMode.dmManual});
    $r.addProperty("Enabled",2,rtl.boolean,"FEnabled","SetEnabled",{Default: true});
    $r.addProperty("Color",2,pas["WEBLib.Graphics"].$rtti["TColor"],"FColor","SetColor");
    $r.addProperty("Ctl3D",4,rtl.boolean,"FCtl3D$1","FCtl3D$1");
    $r.addProperty("Font",2,pas["WEBLib.Graphics"].$rtti["TFont"],"FFont","SetFont");
    $r.addProperty("Padding",2,pas["WEBLib.Controls"].$rtti["TPadding"],"FPadding","SetPadding");
    $r.addProperty("ParentBackground",0,rtl.boolean,"FParentBackground","FParentBackground",{Default: true});
    $r.addProperty("ParentBiDiMode",0,rtl.boolean,"FParentBiDiMode","FParentBiDiMode",{Default: true});
    $r.addProperty("ParentColor",2,rtl.boolean,"FParentColor","SetParentColor",{Default: false});
    $r.addProperty("ParentCtl3D",0,rtl.boolean,"FParentCtl3D$1","FParentCtl3D$1",{Default: true});
    $r.addProperty("ParentDoubleBuffered",0,rtl.boolean,"FParentDoubleBuffered","FParentDoubleBuffered",{Default: true});
    $r.addProperty("ParentFont",2,rtl.boolean,"FParentFont","SetParentFont",{Default: true});
    $r.addProperty("ParentShowHint",0,rtl.boolean,"FParentShowHint","FParentShowHint");
    $r.addProperty("PopupMenu",2,pas["WEBLib.Menus"].$rtti["TPopupMenu"],"FPopupMenu","SetPopupMenu");
    $r.addProperty("ShowHint",2,rtl.boolean,"FShowHint","SetShowHint",{Default: false});
    $r.addProperty("TabOrder",2,rtl.longint,"FTabOrder","SetTabOrder");
    $r.addProperty("TabStop",2,rtl.boolean,"FTabStop","SetTabStop",{Default: true});
    $r.addProperty("Visible",2,rtl.boolean,"FVisible","SetVisible",{Default: true});
    $r.addProperty("OnAlignInsertBefore",0,$mod.$rtti["TAlignInsertBeforeEvent"],"FOnAlignInsertBefore","FOnAlignInsertBefore");
    $r.addProperty("OnAlignPosition",0,$mod.$rtti["TAlignPositionEvent"],"FOnAlignPosition","FOnAlignPosition");
    $r.addProperty("OnCanResize",0,$mod.$rtti["TCanResizeEvent"],"FOnCanResize","FOnCanResize");
    $r.addProperty("OnClick",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnClick","FOnClick");
    $r.addProperty("OnConstrainedResize",0,$mod.$rtti["TConstrainedResizeEvent"],"FOnConstrainedResize","FOnConstrainedResize");
    $r.addProperty("OnContextPopup",0,$mod.$rtti["TContextPopupEvent"],"FOnContextPopup","FOnContextPopup");
    $r.addProperty("OnDblClick",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnDblClick","FOnDblClick");
    $r.addProperty("OnDockDrop",0,$mod.$rtti["TDockDropEvent"],"FOnDockDrop","FOnDockDrop");
    $r.addProperty("OnDockOver",0,$mod.$rtti["TDockOverEvent"],"FOnDockOver","FOnDockOver");
    $r.addProperty("OnDragDrop",0,pas["WEBLib.Controls"].$rtti["TDragDropEvent"],"FOnDragDrop","FOnDragDrop");
    $r.addProperty("OnDragOver",0,pas["WEBLib.Controls"].$rtti["TDragOverEvent"],"FOnDragOver","FOnDragOver");
    $r.addProperty("OnEndDock",0,pas["WEBLib.Controls"].$rtti["TEndDragEvent"],"FOnEndDock","FOnEndDock");
    $r.addProperty("OnEndDrag",0,pas["WEBLib.Controls"].$rtti["TEndDragEvent"],"FonEndDrag","FonEndDrag");
    $r.addProperty("OnEnter",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnEnter","FOnEnter");
    $r.addProperty("OnExit",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnExit","FOnExit");
    $r.addProperty("OnGesture",0,$mod.$rtti["TGestureEvent"],"FOnGesture","FOnGesture");
    $r.addProperty("OnGetSiteInfo",0,$mod.$rtti["TGetSiteInfoEvent"],"FOnGetSiteInfo","FOnGetSiteInfo");
    $r.addProperty("OnMouseActivate",0,$mod.$rtti["TMouseActivateEvent"],"FOnMouseActivate","FOnMouseActivate");
    $r.addProperty("OnMouseDown",0,pas["WEBLib.Controls"].$rtti["TMouseEvent"],"FOnMouseDown","FOnMouseDown");
    $r.addProperty("OnMouseEnter",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnMouseEnter","FOnMouseEnter");
    $r.addProperty("OnMouseLeave",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnMouseLeave","FOnMouseLeave");
    $r.addProperty("OnMouseMove",0,pas["WEBLib.Controls"].$rtti["TMouseMoveEvent"],"FOnMouseMove","FOnMouseMove");
    $r.addProperty("OnMouseUp",0,pas["WEBLib.Controls"].$rtti["TMouseEvent"],"FOnMouseUp","FOnMouseUp");
    $r.addProperty("OnMouseWheel",0,pas["WEBLib.Controls"].$rtti["TMouseWheelEvent"],"FOnMouseWheel","FOnMouseWheel");
    $r.addProperty("OnMouseWheelDown",0,$mod.$rtti["TMouseWheelUpDownEvent"],"FOnMouseWheelDown$1","FOnMouseWheelDown$1");
    $r.addProperty("OnMouseWheelUp",0,$mod.$rtti["TMouseWheelUpDownEvent"],"FOnMouseWheelUp$1","FOnMouseWheelUp$1");
    $r.addProperty("OnResize",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnResize","FOnResize");
    $r.addProperty("OnStartDock",0,$mod.$rtti["TStartDockEvent"],"FOnStartDock","FOnStartDock");
    $r.addProperty("OnStartDrag",0,pas["WEBLib.Controls"].$rtti["TStartDragEvent"],"FOnStartDrag","FOnStartDrag");
    $r.addProperty("OnUnDock",0,$mod.$rtti["TUnDockEvent"],"FOnUnDock","FOnUnDock");
  });
  rtl.recNewT(this,"TApplicationError",function () {
    this.AMessage = "";
    this.AFile = "";
    this.ALineNumber = 0;
    this.AColNumber = 0;
    this.AStack = "";
    this.AError = null;
    this.$eq = function (b) {
      return (this.AMessage === b.AMessage) && (this.AFile === b.AFile) && (this.ALineNumber === b.ALineNumber) && (this.AColNumber === b.AColNumber) && (this.AStack === b.AStack) && (this.AError === b.AError);
    };
    this.$assign = function (s) {
      this.AMessage = s.AMessage;
      this.AFile = s.AFile;
      this.ALineNumber = s.ALineNumber;
      this.AColNumber = s.AColNumber;
      this.AStack = s.AStack;
      this.AError = s.AError;
      return this;
    };
    var $r = $mod.$rtti.$Record("TApplicationError",{});
    $r.addField("AMessage",rtl.string);
    $r.addField("AFile",rtl.string);
    $r.addField("ALineNumber",rtl.longint);
    $r.addField("AColNumber",rtl.longint);
    $r.addField("AStack",rtl.string);
    $r.addField("AError",pas.JS.$rtti["TJSObject"]);
  });
  this.THintPosition = {"0": "hpLeft", hpLeft: 0, "1": "hpTop", hpTop: 1, "2": "hpRight", hpRight: 2, "3": "hpBottom", hpBottom: 3};
  this.$rtti.$Enum("THintPosition",{minvalue: 0, maxvalue: 3, ordtype: 1, enumtype: this.THintPosition});
  this.TOnlineStatus = {"0": "osOnline", osOnline: 0, "1": "osOffline", osOffline: 1};
  this.$rtti.$Enum("TOnlineStatus",{minvalue: 0, maxvalue: 1, ordtype: 1, enumtype: this.TOnlineStatus});
  this.$rtti.$MethodVar("TApplicationErrorEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["AError",this.$rtti["TApplicationError"]],["Handled",rtl.boolean,1]]), methodkind: 0});
  this.$rtti.$MethodVar("TApplicationHashChangeEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["AHash",rtl.string],["Handled",rtl.boolean,1]]), methodkind: 0});
  this.$rtti.$MethodVar("TApplicationOnlineChangeEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["AStatus",this.$rtti["TOnlineStatus"]]]), methodkind: 0});
  this.$rtti.$MethodVar("TApplicationActiveChangeEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["Active",rtl.boolean]]), methodkind: 0});
  this.$rtti.$MethodVar("TApplicationCallBackEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["AQuery",rtl.string]]), methodkind: 0});
  this.$rtti.$MethodVar("TApplicationExceptionEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["E",pas.SysUtils.$rtti["Exception"]]]), methodkind: 0});
  this.$rtti.$MethodVar("TApplicationPopStateEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["State",rtl.jsvalue]]), methodkind: 0});
  this.$rtti.$MethodVar("TApplicationAutoCreateFormEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["AInstanceClass",this.$rtti["TFormClass"]],["AReference",null,1]]), methodkind: 0});
  rtl.createClass(this,"TApplication",pas["WEBLib.Controls"].TControl,function () {
    this.$init = function () {
      pas["WEBLib.Controls"].TControl.$init.call(this);
      this.FAppContainer = "";
      this.FMainFormOnTaskBar = false;
      this.FCanCreateForm = false;
      this.FAppInitializing = false;
      this.FLastReq = null;
      this.FFormCaptionHeight = 0;
      this.FActiveForm = null;
      this.FMainForm = null;
      this.FLoadForm = null;
      this.FInitFormClassName = "";
      this.FFormStack = null;
      this.FParameters = null;
      this.FIsRedirect = false;
      this.FLanguage = 0;
      this.FOnImageCacheReady = null;
      this.FOnError = null;
      this.FOnHashChange = null;
      this.FAutoFormRoute = false;
      this.FErrorType = 0;
      this.FClientConnector = null;
      this.FOnOnlineChange = null;
      this.FOnActivate = null;
      this.FThemeTextColor = 0;
      this.FThemeColor = 0;
      this.FThemed = false;
      this.FThemeButtonClassName = "";
      this.FOnOAuthToken = null;
      this.FOnOAuthCallBack = null;
      this.FOnFontCacheReady = null;
      this.FOnPopState = null;
      this.FMaxZIndex = 0;
      this.FCreatedProc = null;
      this.FHandleOAuth = false;
      this.FHintPause = 0;
      this.FHintHidePause = 0;
      this.FHintPosition = 0;
      this.FHintClassName = "";
      this.FOnExit$1 = null;
      this.FOnException = null;
      this.FOnAutoCreateForm = null;
      this.FRouting = false;
      this.FSBW = 0;
    };
    this.$final = function () {
      this.FLastReq = undefined;
      this.FActiveForm = undefined;
      this.FMainForm = undefined;
      this.FLoadForm = undefined;
      this.FFormStack = undefined;
      this.FParameters = undefined;
      this.FOnImageCacheReady = undefined;
      this.FOnError = undefined;
      this.FOnHashChange = undefined;
      this.FClientConnector = undefined;
      this.FOnOnlineChange = undefined;
      this.FOnActivate = undefined;
      this.FOnOAuthToken = undefined;
      this.FOnOAuthCallBack = undefined;
      this.FOnFontCacheReady = undefined;
      this.FOnPopState = undefined;
      this.FCreatedProc = undefined;
      this.FOnExit$1 = undefined;
      this.FOnException = undefined;
      this.FOnAutoCreateForm = undefined;
      pas["WEBLib.Controls"].TControl.$final.call(this);
    };
    this.DoFormLoad = function (Event) {
      var Result = false;
      var LResponse = "";
      LResponse = Event.target.responseText;
      this.CreateNewForm(this.FLoadForm,LResponse);
      if (this.FCreatedProc != null) {
        this.FCreatedProc(this);
        this.FCreatedProc = null;
      };
      Result = true;
      return Result;
    };
    this.DoFormAbort = function (Event) {
      var Result = false;
      pas["WEBLib.Dialogs"].ShowMessage("Failed to load form HTML template file");
      Result = true;
      return Result;
    };
    this.DoHandleError = function (Event) {
      var Result = false;
      var err = $mod.TApplicationError.$new();
      var el = null;
      var sp = null;
      var x = null;
      var msg = "";
      var pmsg = "";
      var pstack = "";
      var s = "";
      var isError = false;
      var isPromise = false;
      var jserror = undefined;
      var ex = null;
      isError = true;
      isPromise = false;
      jserror = null;
      err.AFile = "";
      err.ALineNumber = 0;
      err.AColNumber = 0;
      err.AError = null;
      if (Event.message == undefined) {
        isError = false;
        if (Event instanceof PromiseRejectionEvent)
        {
          isError = true;
          isPromise = true;
          pmsg = Event.reason.FMessage;
          pstack = Event.reason.FStack;
          jserror = Event.reason;
        }
      };
      if (!isPromise && (Event.message === "ResizeObserver loop limit exceeded")) return Result;
      if (!isPromise && (Event.message === "ResizeObserver loop completed with undelivered notifications.")) return Result;
      if (!isError) {
        err.AMessage = "Undefined JavaScript exception";
        err.AFile = "";
        err.ALineNumber = 0;
        err.AColNumber = 0;
        err.AError = null;
        if (this.FOnError != null) this.FOnError(this,$mod.TApplicationError.$clone(err),{get: function () {
            return Result;
          }, set: function (v) {
            Result = v;
          }});
        return Result;
      };
      if (isPromise) {
        err.AMessage = pmsg;
        err.AStack = pstack;
        err.AError = jserror;
      } else {
        err.AMessage = Event.message;
        err.AFile = Event.filename;
        err.ALineNumber = Event.lineno;
        err.AColNumber = Event.colno;
        err.AError = Event.error;
        err.AStack = "";
      };
      s = "";
      if (Event.error != null) {
        if (Event.error.stack) {
          err.AStack = Event.error.stack;
        }
        if (Event.error.fMessage) {
          err.AMessage = Event.error.fMessage;
        };
        function objToString (obj) {
              var str = '';
              for (var p in obj) {
                  if (obj.hasOwnProperty(p)) {
                      str += p + '::' + obj[p] + '\n';
                  }
              }
              return str;
              }
        
              // detect if it was an RTL exception
              if (Event.error.hasOwnProperty('FJSError'))
              {
                jserror = Event.error['FJSError'];
              }
        
              s = objToString(Event.error);
      };
      if (pas.System.Assigned(jserror)) {
        ex = err.AError; //Event.error;
        if (this.FOnException != null) this.FOnException(this,ex);
      };
      Result = false;
      msg = "ERROR<br>" + err.AMessage + " | " + s + err.AStack + "<BR> at " + err.AFile + " [" + pas.SysUtils.IntToStr(err.ALineNumber) + ":" + pas.SysUtils.IntToStr(err.AColNumber) + "]";
      var $tmp = this.FErrorType;
      if ($tmp === $mod.TApplicationErrorType.aeFooter) {
        el = document.getElementById("tmserrormessage");
        if (el != null) {
          rtl.asExt(el.firstChild,HTMLElement).innerHTML = msg;
        } else {
          el = document.createElement("DIV");
          el.setAttribute("id","tmserrormessage");
          el.style.setProperty("position","absolute");
          el.style.setProperty("font-family","Courier");
          el.style.setProperty("font-size","8pt");
          el.style.setProperty("bottom","0");
          el.style.setProperty("width","100%");
          el.style.setProperty("height","100px");
          el.style.setProperty("background","#ff0000");
          el.style.setProperty("color","#ffffff");
          document.body.style.setProperty("padding","0");
          document.body.style.setProperty("margin","0");
          sp = document.createElement("SPAN");
          sp.style.setProperty("margin-left","4px");
          sp.style.setProperty("float","left");
          sp.style.setProperty("overflow","hidden");
          sp.style.setProperty("display","block");
          sp.innerHTML = msg;
          el.appendChild(sp);
          x = document.createElement("SPAN");
          x.style.setProperty("font-family","Courier");
          x.style.setProperty("font-size","8pt");
          x.style.setProperty("font-weight","bold");
          x.style.setProperty("position","absolute");
          x.style.setProperty("width","20px");
          x.style.setProperty("vertical-align","top");
          x.style.setProperty("cursor","pointer");
          x.style.setProperty("text-align","right");
          x.style.setProperty("right","4px");
          x.style.setProperty("display","block");
          x.innerHTML = "X";
          x.onclick = rtl.createSafeCallback(this,"DoErrorClose");
          el.appendChild(x);
          document.body.appendChild(el);
        };
      } else if ($tmp === $mod.TApplicationErrorType.aeAlert) {
        window.alert(msg)}
       else if ($tmp === $mod.TApplicationErrorType.aeDialog) {
        this.AddControlLink("googlematerial","https://fonts.googleapis.com/icon?family=Material+Icons");
        pas["WEBLib.Dialogs"].MessageDlg(msg,pas["WEBLib.Dialogs"].TMsgDlgType.mtError,rtl.createSet(pas["WEBLib.Dialogs"].TMsgDlgBtn.mbOK),null);
      };
      if (this.FOnError != null) this.FOnError(this,$mod.TApplicationError.$clone(err),{get: function () {
          return Result;
        }, set: function (v) {
          Result = v;
        }});
      return Result;
    };
    this.DoHandleExit = function (Event) {
      var Result = false;
      Result = true;
      if (this.FOnExit$1 != null) this.FOnExit$1(this);
      return Result;
    };
    this.DoHashChange = function (Event) {
      var Result = false;
      var s = "";
      var fc = null;
      var frm = null;
      var bdy = null;
      var Handled = false;
      Result = true;
      if (!this.FAutoFormRoute) return Result;
      s  = location.hash;
      pas.System.Delete({get: function () {
          return s;
        }, set: function (v) {
          s = v;
        }},1,1);
      Handled = false;
      if (this.FOnHashChange != null) this.FOnHashChange(this,s,{get: function () {
          return Handled;
        }, set: function (v) {
          Handled = v;
        }});
      if (Handled) return Result;
      if (s === "") s = this.FInitFormClassName;
      if (s !== "") {
        if (this.FInitFormClassName === "") this.FInitFormClassName = this.FActiveForm.$classname;
        fc = pas.Classes.GetClass(s);
        if (fc != null) {
          bdy = document.body;
          this.CreateForm$6(fc,bdy,{get: function () {
              return frm;
            }, set: function (v) {
              frm = v;
            }});
        };
      };
      return Result;
    };
    this.DoPopState = function (Event) {
      var Result = false;
      if (this.FOnPopState != null) this.FOnPopState(this,Event.state);
      Result = true;
      return Result;
    };
    this.DoErrorClose = function (Event) {
      var Result = false;
      document.body.removeChild(Event.target.parentElement);
      Result = true;
      return Result;
    };
    this.DoUpdateOnlineStatus = function (Event) {
      var Result = false;
      Result = true;
      if (this.FOnOnlineChange != null) {
        if (window.navigator.onLine) {
          this.FOnOnlineChange(this,$mod.TOnlineStatus.osOnline)}
         else this.FOnOnlineChange(this,$mod.TOnlineStatus.osOffline);
      };
      return Result;
    };
    this.DoVisibilityChange = function (Event) {
      var Result = false;
      var res = false;
      Result = true;
      res = document.visibilityState === "visible";
      if (this.FOnActivate != null) this.FOnActivate(this,res);
      return Result;
    };
    this.SetLanguage = function (Value) {
      this.FLanguage = Value;
    };
    this.GetIsOnline = function () {
      var Result = false;
      Result = window.navigator.onLine;
      return Result;
    };
    this.GetIsMobile = function () {
      var Result = false;
      var mob = false;
      function TestMobile() {
            var check = false;
           (function(a){if(/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino|android|ipad|playbook|silk/i.test(a)||/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(a.substr(0,4))) check = true;})(navigator.userAgent||navigator.vendor||window.opera);
           return check;
           };
      
          mob = TestMobile();
      Result = mob;
      return Result;
    };
    this.GetIsPWA = function () {
      var Result = false;
      var pwa = false;
      pwa = ('standalone' in window.navigator) && (window.navigator.standalone);
      Result = pwa;
      return Result;
    };
    this.InternalDownloadFile = function (AData, AFileName, AType, ANewTab) {
      var lElement = document.createElement('a');
      var lBlob = new Blob([AData], {type: AType})
      var lUrl = window.URL.createObjectURL(lBlob);
      lElement.href = lUrl;
      if (AFileName != ''){
        lElement.setAttribute('download', AFileName);
      }
      lElement.style.display = 'none';
      if (ANewTab == true) {
        lElement.target = '_blank';
      }
      document.body.appendChild(lElement);
      lElement.click();
      document.body.removeChild(lElement);
    };
    this.CreateNewForm = function (AForm, HTML) {
      var eh = null;
      var op = null;
      var span = null;
      var childspan = null;
      var formspan = null;
      var l = 0;
      var t = 0;
      var w = 0;
      var h = 0;
      var LCreatedProc = null;
      var LCaptionDiv = null;
      var LCaptionHeight = 0;
      var ro = null;
      if (this.FMainForm === null) this.FMainForm = AForm;
      span = null;
      formspan = null;
      LCaptionHeight = 0;
      if (!AForm.FPopup && (AForm.FFormElement !== "")) {
        AForm.FLayer$1 = null;
        eh = document.getElementById(AForm.FFormElement);
        if (eh != null) {
          eh.innerHTML = HTML;
          if ((AForm.FElementClassName === "") && (AForm.FCSSLibrary === pas["WEBLib.Controls"].TCSSLibrary.cssNone)) eh.style.setProperty(pas["WEBLib.Controls"].CSSBackground,pas["WEBLib.Graphics"].ColorToHTML(AForm.FColor));
        };
      } else {
        AForm.ClearControls();
        AForm.FLayer$1 = AForm.CreateLayer();
        document.body.appendChild(AForm.FLayer$1);
        eh = AForm.FLayer$1;
        if (AForm.FPopup && (AForm.FPopupOpacity < 1)) {
          op = AForm.CreateLayer();
          op.style.setProperty(pas["WEBLib.Controls"].CSSBackground,"black");
          op.style.setProperty("opacity",pas["WEBLib.WebTools"].DoubleToHTML(AForm.FPopupOpacity));
          op.style.setProperty(pas["WEBLib.Controls"].CSSZIndex,$mod.Application.MaxZIndexStr());
          eh.appendChild(op);
        };
        $mod.Application.ChangeMaxZIndex(+1);
        span = document.createElement("DIV");
        span.style.setProperty(pas["WEBLib.Controls"].CSSZIndex,$mod.Application.MaxZIndexStr());
        AForm.FPopupElement = span;
        if (AForm.FBorder in rtl.createSet($mod.TFormBorderStyle.fbDialog,$mod.TFormBorderStyle.fbDialogSizeable)) {
          span.style.setProperty("resize","both");
          span.style.setProperty("overflow","auto");
          ro = null;
          try
          {
          var frm = AForm;
          ro = new ResizeObserver( function(entries)  {
             window.requestAnimationFrame(() => {
                if (!Array.isArray(entries) || !entries.length) {
                  return;
                }
             entries.forEach( function(entry) {
               frm.HandleObserver();
               });
               } );
          });
            // Observe the scrollingElement for when the window gets resized
            ro.observe(span);
          }
          catch(err)
          {
            span.style.removeProperty('resize');
            span.style.removeProperty('overflow');
          };
          AForm.FResizeObserver = ro;
        };
        if (AForm.FElementClassName !== "") span.setAttribute("class",AForm.FElementClassName);
        if (AForm.FShadow && AForm.FPopup) span.style.setProperty("box-shadow","3px 3px 3px silver");
        eh.appendChild(span);
        AForm.GetMethodPointers();
        if (AForm.FBorder in rtl.createSet($mod.TFormBorderStyle.fbDialog,$mod.TFormBorderStyle.fbDialogSizeable)) {
          LCaptionDiv = AForm.CreateCaption();
          span.appendChild(LCaptionDiv);
          childspan = document.createElement("DIV");
          childspan.style.setProperty("position","absolute");
          childspan.style.setProperty("width","100%");
          childspan.setAttribute("id","childspan");
          span.appendChild(childspan);
          formspan = childspan;
          LCaptionHeight = $mod.Application.FFormCaptionHeight;
        } else {
          formspan = span;
        };
        formspan.innerHTML = HTML;
        AForm.FContainer = formspan;
      };
      AForm.Init();
      AForm.LoadDFMValues();
      if ((AForm.FBorder in rtl.createSet($mod.TFormBorderStyle.fbDialog,$mod.TFormBorderStyle.fbDialogSizeable)) && (AForm.FElementCaptionClassName !== "")) {
        LCaptionDiv.classList.add(AForm.FElementCaptionClassName);
        LCaptionDiv.style.removeProperty("background-color");
        LCaptionDiv.style.removeProperty("color");
      };
      if (AForm.FLayer$1 != null) {
        if (!AForm.FPopup) {
          if (AForm.FElementClassName === "") {
            if (AForm.FColor !== -1) {
              eh.style.setProperty(pas["WEBLib.Controls"].CSSBackground,pas["WEBLib.Graphics"].ColorToHTML(AForm.FColor))}
             else eh.style.setProperty(pas["WEBLib.Controls"].CSSBackground,"white");
          } else eh.setAttribute("class",AForm.FElementClassName);
          if ((AForm.FCSSLibrary === pas["WEBLib.Controls"].TCSSLibrary.cssBootstrap) && (AForm.FElementClassName === "")) {
            eh.setAttribute("class","card");
            eh.style.removeProperty("background-color");
            eh.style.setProperty("display","block");
          };
        };
      };
      if ((span != null) && (AForm.FFormContainer === "") && AForm.FPopup && (AForm.FPosition === $mod.TPosition.poScreenCenter)) {
        span.style.setProperty("position","absolute");
        l = Math.max(0,Math.round(($mod.WinWidth() - AForm.GetWidth()) / 2)) + window.scrollX;
        t = Math.max(0,Math.round(($mod.WinHeight() - AForm.GetHeight()) / 2)) + window.scrollY;
        w = AForm.GetWidth();
        h = AForm.GetClientHeight() + LCaptionHeight;
        AForm.FTop = t;
        AForm.FLeft = l;
        AForm.SetWidthInt(w);
        AForm.SetHeightInt(h);
        if ((AForm.FElementClassName === "") && (AForm.FCSSLibrary === pas["WEBLib.Controls"].TCSSLibrary.cssNone)) {
          span.style.setProperty(pas["WEBLib.Controls"].CSSBackground,pas["WEBLib.Graphics"].ColorToHTML(AForm.FColor));
          span.style.setProperty("border","1px Black solid");
        };
        span.style.setProperty("top",pas.SysUtils.IntToStr(t) + "px");
        span.style.setProperty("left",pas.SysUtils.IntToStr(l) + "px");
        span.style.setProperty("width",pas.SysUtils.IntToStr(w) + "px");
        span.style.setProperty("height",pas.SysUtils.IntToStr(h) + "px");
      };
      if (formspan != null) this.ActivateChildScripts(formspan);
      if (AForm.FOnCreate != null) AForm.FOnCreate(AForm);
      if (AForm.FCreatedProc != null) {
        LCreatedProc = AForm.FCreatedProc;
        AForm.FCreatedProc = null;
        LCreatedProc(AForm);
      };
      AForm.Loaded();
      AForm.InitAnchoring();
      AForm.UpdateChildAnchoring();
      AForm.FCreating = false;
      AForm.UpdateElement();
      if (!AForm.EventsBound()) AForm.BindEvents();
      AForm.Resize$1();
      AForm.DoShow();
    };
    this.GetFormExtension = function () {
      var Result = "";
      if (this.FLanguage !== pas["WEBLib.Lang"].TUILanguage.lNone) {
        Result = "_" + pas["WEBLib.Lang"].GetLanguageISO639_1Code(this.FLanguage) + pas["WEBLib.WebTools"].cHTMLExt}
       else Result = pas["WEBLib.WebTools"].cHTMLExt;
      return Result;
    };
    var sExternalBrowserAuthorizationOK = '<div class="text2">Application succesfully authorized</div>You can close this browser window';
    var sExternalBrowserAuthorizationFailed = '<div class="text2">Application authorization failed</div><br/>Please try again.';
    var LB = "\r\n";
    var ImageFail = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAYAAACqaXHeA" + "AAACXBIWXMAAA7DAAAOwwHHb6hkAAABtElEQVR4nO2bUY7CMAxEhz0NB+EgrDjXCg6yB+E4+9NKCAiN" + "7XHcjf1+ED+Z6ahNHScFiqIoBNwvp+v9crpG+3hG6+sgFQFwXv7ejj+/31JBDyy+ugN4ElkJD8Hqqyu" + "AhohYjA3D12YAGyIiMSYsXx8D6BTpFmPB9NUMQCjSJcaA7ettAEqRTTErHr5eAjCKfBSz4OXryzhgiz" + "OzWCJd/Fs8HoFHzHeCtxf2JNgt3MMID8zXoMpAtDarEDIbidJklMJUQ6MDty6GNDSNRdxtluWwhReDU" + "fONKADAx2jkZCsOAOAaXn4pY2let6oAAN/qTIG61lAHAOwmBFO1aQoACA/BXGqbAwDCQqCsOCkBAMND" + "oC23aQEAw0Kg9hqoAQDuIdAbLfQAALcQXFptLgEA9BDc+oxeLbF/Qz0C7AFTT4KpX4OpC6HUpXDqxVD" + "q5fBOLn5lbEMkdUssdVM0dVs89cZI6q2x1JujqbfHUx+Q2MPFj/LidUqsKajB05NXS4y6Zl/GurHGe6" + "QOSpLF5jgqqxSb67C0UGzO4/KdYnN/MLEhluOTmYZY+MWvDPU122dzRVHk5g+X6Lw5aVkK9AAAAABJRU5ErkJggg==";
    var ImageSuccess = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAYAAACqaX" + "HeAAAACXBIWXMAAA7DAAAOwwHHb6hkAAACC0lEQVR4nO2Zv3GDMBSHv+QyQEbICM4EOW+Q9BS4o2QTU" + "9LZBQNkg6zgETyCR0iRkOMIAv3Xk0+/zsiI931nI3iCkpKSkpKSkpKSkpJ7SDN0x2bo3nW//xCymNhp" + "hu4E1MAN2PdVe9k6524ETODHXIHXvmpva+c9BqwpWhbgAV6Ar61zsxeggB+z+x1XJmsBG/Bj6mboWtV" + "gtvcATfhpPvqq/ZwfzFKABTwoVobsBFjCj7kyWxmyugc4wsPCypCNAA/wY/L7C3iEP/dVe5geEC8gJD" + "wIFxAaHgQLiAEPQgXEggeBAmLCgzABseFBkIAU8CBEQCp4ECAgJTwYChibCzYXWpmv9jCVFTwYCJgVa" + "31BxXwucapFS4CiWOsLS4EHDQEbxRoXIAkeNgRoFqtdiDR4WBFgWOxmQRLhQdEQsSi2bobuqBqUCg8L" + "vwDHYg991Z49zjeNd3iYCfBU7J8E6fAAT7PPOw9znpqhA3hDODz8F7Dnp2vqKmJ1O8ogQeFh+R7wjB8" + "JrgkOD4plUICEKPCw/hyQSkI0eNh+EowtISo86L0LxJIQHR703wZDS0gCD2b9gFASksGDeUfIt4Sk8G" + "DRE/QoITk8WDZFPUgQAQ8OXWEHCWLgwbEtbiFBFDx42BcwkCAOHjxtjGhIEAkPHneGViSIhQfPW2MLE" + "kTDQ4C9wYmEi3T4kpKSkm+5ax+YhPsUTQAAAABJRU5ErkJggg==";
    var PlaceHolderImage = "#PLACEHOLDERIMAGE#";
    var PlaceHolderText = "#PLACEHOLDERTEXT#";
    var PlaceHolderColor = "#PLACEHOLDERCOLOR#";
    var AuthHTMLTemplate = "<!doctype html>" + LB + '<html lang="en">' + LB + "<head>" + LB + "  <title>Authentication Result</title>" + LB + '  <meta name="viewport" content="width=device-width, initial-scale=1">' + LB + "</head>" + LB + "<body>" + LB + "<style>" + LB + "  hr" + LB + "  {" + LB + "    border: none;" + LB + "    height: 1px;" + LB + "    background-color: rgb(171, 171, 171);" + LB + "  }" + LB + "  div.container" + LB + "  {" + LB + "    position: fixed;" + LB + "    font-family: Arial;" + LB + "    font-size: 12pt;" + LB + "    max-width: 100%;" + LB + "    max-height: 100%;" + LB + "    top: 50%;" + LB + "    left: 50%;" + LB + "    transform: translate(-50%, -50%);" + LB + "  }" + LB + "  div.section" + LB + "  {" + LB + "    display: inline-block;" + LB + "    margin: 15px;" + LB + "    padding: 5px;" + LB + "    float: left;" + LB + "  }" + LB + "  div.image img" + LB + "  {" + LB + "    height: 100%;" + LB + "  }" + LB + "  div.text" + LB + "  {" + LB + "    padding-top: 15px;" + LB + "  }" + LB + "  div.text2" + LB + "  {" + LB + "    font-size: 18pt;" + LB + "    color: #PLACEHOLDERCOLOR#;" + LB + "  }" + LB + "  span.title" + LB + "  {" + LB + "    font-size: 26px;" + LB + "  }" + LB + "</style>" + LB + '  <div class="container">' + LB + '  <div class="section image">' + LB + '    <img src="#PLACEHOLDERIMAGE#">' + LB + "  </div>" + LB + '  <div class="section text">' + LB + "  #PLACEHOLDERTEXT#" + LB + "  </div>" + LB + "  </div>" + LB + " </body>" + LB + "</html>";
    this.GetAuthorizationPageHTML = function (AAuthorizationSuccess) {
      var $Self = this;
      var Result = "";
      function ReplacePlaceHolders(APlaceHolders, APlaceHolderValues) {
        var Result = "";
        var I = 0;
        var s = "";
        s = AuthHTMLTemplate;
        for (var $l = 0, $end = rtl.length(APlaceHolders) - 1; $l <= $end; $l++) {
          I = $l;
          s = pas.SysUtils.StringReplace(s,APlaceHolders[I],APlaceHolderValues[I],rtl.createSet(pas.SysUtils.TStringReplaceFlag.rfReplaceAll));
        };
        Result = s;
        return Result;
      };
      if (AAuthorizationSuccess) {
        Result = ReplacePlaceHolders([PlaceHolderImage,PlaceHolderText,PlaceHolderColor],[ImageSuccess,sExternalBrowserAuthorizationOK,"rgb(104, 164, 144)"])}
       else Result = ReplacePlaceHolders([PlaceHolderImage,PlaceHolderText,PlaceHolderColor],[ImageFail,sExternalBrowserAuthorizationFailed,"rgb(216, 99, 68)"]);
      return Result;
    };
    this.GetColorScheme = function () {
      var Result = 0;
      Result = $mod.TApplicationColorScheme.csNoScheme;
      if (window.matchMedia("(prefers-color-scheme)").media !== "not all") {
        if (window.matchMedia("(prefers-color-scheme: dark)").matches) {
          Result = $mod.TApplicationColorScheme.csDark}
         else Result = $mod.TApplicationColorScheme.csLight;
      };
      return Result;
    };
    this.GetActive = function () {
      var Result = false;
      Result = !document.hidden;
      return Result;
    };
    this.GetBootstrapVersion = function () {
      var Result = 0;
      var bv = "";
      bv = "";
      if (typeof bootstrap !== 'undefined') {
        bv = bootstrap.Tooltip.VERSION;
      };
      Result = $mod.TBootstrapVersion.bv3;
      if (pas.System.Pos("4.",bv) === 1) {
        Result = $mod.TBootstrapVersion.bv4}
       else if (pas.System.Pos("5.",bv) === 1) Result = $mod.TBootstrapVersion.bv5;
      return Result;
    };
    this.ReloadForm = function () {
      var $Self = this;
      var lFileName = "";
      function DoStatusCreate(Event) {
        var Result = false;
        var i = 0;
        var ctl = null;
        var s = "";
        var sl = null;
        var response = "";
        response = Event.target.responseText;
        sl = pas.Classes.TStringList.$create("Create$1");
        for (var $l = $Self.FActiveForm.GetControlsCount() - 1; $l >= 0; $l--) {
          i = $l;
          ctl = $Self.FActiveForm.GetControls(i);
          s = ctl.SaveState();
          ctl.GetElementHandle().id = ctl.FName;
          s = ctl.FName + "=" + s;
          sl.Add(s);
        };
        for (var $l1 = $Self.FActiveForm.GetControlsCount() - 1; $l1 >= 0; $l1--) {
          i = $l1;
          ctl = $Self.FActiveForm.GetControls(i);
          $Self.FActiveForm.RemoveComponent(ctl);
          ctl = rtl.freeLoc(ctl);
        };
        $Self.FActiveForm.ClearControls();
        $Self.FActiveForm.UnbindEvents();
        document.body.innerHTML = response;
        $Self.FActiveForm.CreateControl();
        $Self.FActiveForm.DoCreate();
        $Self.FActiveForm.Init();
        for (var $l2 = $Self.FActiveForm.GetControlsCount() - 1; $l2 >= 0; $l2--) {
          i = $l2;
          ctl = $Self.FActiveForm.GetControls(i);
          s = sl.GetValue(ctl.FName);
          if (s !== "") ctl.LoadState(s);
        };
        sl = rtl.freeLoc(sl);
        $Self.FActiveForm.DoShow();
        Result = true;
        return Result;
      };
      lFileName = this.FActiveForm.$class.GetHTMLFileName(false);
      this.FLastReq = new XMLHttpRequest();
      this.FLastReq.addEventListener("load",rtl.createSafeCallback(null,DoStatusCreate));
      this.FLastReq.open("GET",lFileName);
      this.FLastReq.send();
    };
    this.ActivateChildScripts = function (AElement) {
      function nodeScriptReplace(node) {
                  if ( nodeScriptIs(node) === true ) {
                          node.parentNode.replaceChild( nodeScriptClone(node) , node );
                  }
                  else {
                          var i        = 0;
                          var children = node.childNodes;
                          while ( i < children.length ) {
                                  nodeScriptReplace( children[i++] );
                          }
                  }
      
                  return node;
          }
          function nodeScriptIs(node) {
                  return node.tagName === 'SCRIPT';
          }
          function nodeScriptClone(node){
                  var script  = document.createElement("script");
                  script.async = false;
                  script.text = node.innerHTML;
                  for( var i = node.attributes.length-1; i >= 0; i-- ) {
                          script.setAttribute( node.attributes[i].name, node.attributes[i].value );
                  }
                  return script;
          }
          nodeScriptReplace(AElement);
    };
    this.ChangeMaxZIndex = function (Delta) {
      this.FMaxZIndex = this.FMaxZIndex + Delta;
    };
    this.TriggerNotification = function () {
    };
    this.AutoCreateForm = function (AInstanceClass, AReference) {
      if (this.FOnAutoCreateForm != null) {
        this.FOnAutoCreateForm(this,AInstanceClass,AReference)}
       else this.CreateForm(AInstanceClass,AReference);
    };
    this.SetHash = function (AValue) {
      window.location.hash = AValue;
    };
    this.GetHash = function () {
      var Result = "";
      var s = "";
      s = window.location.hash;
      if ((s.length > 0) && (s.charAt(0) === "#")) pas.System.Delete({get: function () {
          return s;
        }, set: function (v) {
          s = v;
        }},1,1);
      Result = s;
      return Result;
    };
    this.PushForm = function (AForm) {
      var i = 0;
      for (var $l = 0, $end = AForm.GetControlsCount() - 1; $l <= $end; $l++) {
        i = $l;
        AForm.GetControls(i).PersistinHTML();
      };
      AForm.FFormContent = document.body.innerHTML;
      for (var $l1 = 0, $end1 = AForm.GetControlsCount() - 1; $l1 <= $end1; $l1++) {
        i = $l1;
        AForm.GetControls(i).DisableTab();
      };
      this.FFormStack.Add(AForm);
    };
    this.PopForm = function () {
      var Result = null;
      var i = 0;
      var frm = "";
      if (this.FFormStack.GetCount() > 0) {
        Result = rtl.getObject(this.FFormStack.Get(this.FFormStack.GetCount() - 1));
        frm = Result.FFormContent;
        this.FFormStack.Delete(this.FFormStack.GetCount() - 1);
        document.body.innerHTML = frm;
        Result.InitFromHTML();
        Result.BindEvents();
        for (var $l = 0, $end = Result.GetControlsCount() - 1; $l <= $end; $l++) {
          i = $l;
          Result.GetControls(i).HookElement();
        };
        for (var $l1 = 0, $end1 = Result.GetControlsCount() - 1; $l1 <= $end1; $l1++) {
          i = $l1;
          Result.GetControls(i).RecreateCanvas();
          Result.GetControls(i).InternalResize();
        };
        $mod.Application.FActiveForm = Result;
      };
      return Result;
    };
    this.LockForm = function (AForm) {
      var i = 0;
      for (var $l = 0, $end = AForm.GetControlsCount() - 1; $l <= $end; $l++) {
        i = $l;
        AForm.GetControls(i).DisableTab();
      };
    };
    this.UnLockForm = function (AForm) {
      var i = 0;
      for (var $l = 0, $end = AForm.GetControlsCount() - 1; $l <= $end; $l++) {
        i = $l;
        AForm.GetControls(i).EnableTab();
      };
    };
    this.Create$1 = function (AOwner) {
      this.FFormStack = pas.Classes.TList.$create("Create$1");
      this.FParameters = pas.Classes.TStringList.$create("Create$1");
      this.FAppContainer = pas["WEBLib.WebTools"].cBodyTag;
      this.FMainForm = null;
      this.FActiveForm = null;
      this.FInitFormClassName = "";
      this.FIsRedirect = false;
      this.FAutoFormRoute = false;
      this.FThemed = false;
      this.FThemeColor = 14917120;
      this.FThemeTextColor = 16777215;
      this.FFormCaptionHeight = 22;
      this.FMaxZIndex = 998;
      this.FHandleOAuth = true;
      this.FHintPause = 200;
      this.FHintHidePause = 250;
      this.FHintPosition = $mod.THintPosition.hpTop;
      this.FHintClassName = "";
      this.FSBW = -1;
      window.addEventListener("error",rtl.createCallback(this,"DoHandleError"));
      window.addEventListener("unhandledrejection",rtl.createCallback(this,"DoHandleError"));
      window.addEventListener("beforeunload",rtl.createSafeCallback(this,"DoHandleExit"));
      this.FErrorType = $mod.TApplicationErrorType.aeSilent;
      return this;
    };
    this.Destroy = function () {
      rtl.free(this,"FFormStack");
      rtl.free(this,"FParameters");
      pas["WEBLib.Controls"].TControl.Destroy.call(this);
    };
    this.MaxZIndexStr = function () {
      var Result = "";
      Result = pas.SysUtils.IntToStr(this.FMaxZIndex);
      return Result;
    };
    this.IsPWAInstalled = function () {
      var $Self = this;
      var Result = null;
      var b = false;
      var s = "";
      b = false;
      s = window.location.hostname;
      Result = new Promise(async function (ASuccess, AFailed) {
        if ('getInstalledRelatedApps' in window.navigator) {
         const relatedApps = await navigator.getInstalledRelatedApps();
         relatedApps.forEach((app) => {
            if (app.id.indexOf(s) >= 0)
            {
              b = true;
            }
         });
        };
        ASuccess(b);
      });
      return Result;
    };
    this.CalcScrollBarWidth = function () {
      var Result = 0;
      var res = 0;
      if (this.FSBW !== -1) {
        Result = this.FSBW;
        return Result;
      };
      function getScrollbarWidth() {
            // Create a temporary div element
            const div = document.createElement('div');
      
            // Apply styles to force a scrollbar
            div.style.overflow = 'scroll';
            div.style.position = 'absolute';
            div.style.top = '-9999px'; // Move it off-screen
            div.style.width = '100px';
            div.style.height = '100px';
      
            // Append the div to the body
            document.body.appendChild(div);
      
            // Calculate the scrollbar width
            const scrollbarWidth = div.offsetWidth - div.clientWidth;
      
            // Remove the temporary element
            document.body.removeChild(div);
      
            res = scrollbarWidth;
          }
          getScrollbarWidth();
      this.FSBW = res;
      Result = this.FSBW;
      return Result;
    };
    this.GoBack = function () {
      window.history.back();
    };
    this.CreateNewForm$1 = function (AInstanceClass) {
      var Result = null;
      if (!($mod.VSIDE != null)) {
        Result = AInstanceClass.$create("Create$2",[pas["WEBLib.WebTools"].cBodyTag])}
       else Result = AInstanceClass.$create("Create$2",[""]);
      return Result;
    };
    this.CreateNewForm$2 = function (AInstanceClass, AElementID) {
      var Result = null;
      var el = null;
      var AForm = null;
      el = document.getElementById(AElementID);
      AForm = AInstanceClass.$create("Create$2",[AElementID]);
      AForm.FDesignContainer = el;
      AForm.SetFormContainer(AElementID);
      AForm.FFormElement = AElementID;
      AForm.CreateControl();
      AForm.FContainer = el;
      AForm.Init();
      Result = AForm;
      return Result;
    };
    this.CreateForm = function (AInstanceClass, AReference) {
      this.CreateForm$2(AInstanceClass,this.FAppContainer,AReference,null);
    };
    this.CreateForm$1 = function (AInstanceClass, AElementID, AReference) {
      this.CreateForm$2(AInstanceClass,AElementID,AReference,null);
    };
    this.CreateForm$2 = function (AInstanceClass, AElementID, AReference, AProc) {
      this.CreateForm$3(AInstanceClass,AElementID,AReference,AProc,true);
    };
    this.CreateForm$3 = function (AInstanceClass, AElementID, AReference, AProc, LoadHTML) {
      var $Self = this;
      var LFileName = "";
      function DoStatusCreate(Event) {
        var Result = false;
        var LElem = null;
        var LForm = null;
        var LResponse = "";
        var LIsBody = false;
        var LisLoaded = false;
        LisLoaded = Event != null;
        if (LisLoaded) {
          LResponse = Event.target.responseText;
          LIsBody = pas.SysUtils.LowerCase(AElementID) === pas["WEBLib.WebTools"].cBodyTag;
          if (LIsBody) {
            LElem = document.body}
           else LElem = document.getElementById(AElementID);
          LElem.innerHTML = LResponse;
        } else {
          LElem = document.body;
        };
        LForm = AInstanceClass.$create("Create$5",[AElementID,AReference]);
        LForm.FFormFileName = LFileName;
        if (LForm.FFormContainer === "") LForm.SetFormContainer(AElementID);
        if (!LIsBody) {
          LForm.FFormElement = AElementID;
          LForm.FContainer = LElem;
        };
        LForm.CreateControl();
        LForm.Init();
        LForm.SetColorScheme($mod.Application.GetColorScheme());
        LForm.FPrevActiveForm = $Self.FActiveForm;
        $Self.FActiveForm = LForm;
        if ($Self.FMainForm === null) $Self.FMainForm = LForm;
        if (AProc != null) AProc(LForm);
        Result = true;
        if (LisLoaded) $Self.ActivateChildScripts(LElem);
        $Self.FActiveForm.DoShow();
        $Self.FActiveForm.Resize$1();
        return Result;
      };
      if (this.FIsRedirect) return;
      if (this.FAppInitializing) {
        if (this.FCanCreateForm) {
          this.FCanCreateForm = false}
         else return;
      };
      LFileName = AInstanceClass.GetHTMLFileName(false);
      if ((LFileName !== "") && LoadHTML) {
        this.FLastReq = new XMLHttpRequest();
        this.FLastReq.addEventListener("load",rtl.createSafeCallback(null,DoStatusCreate));
        this.FLastReq.open("GET",LFileName);
        this.FLastReq.send();
      } else {
        DoStatusCreate(null);
      };
    };
    this.CreateForm$4 = function (AInstanceClass, AReference) {
      var lModule = null;
      lModule = AInstanceClass.$create("Create$1",[this]);
      AReference.set(lModule);
    };
    var cHTMLCode = '<html><head><meta http-equiv="Content-type" content="text/html; ' + 'charset=utf-8" /><title>TMS Web Project</title><style></style></head>' + "<body></body></html>";
    this.CreateForm$5 = function (AInstanceClass, AReference) {
      var lFrame = null;
      var lForm = null;
      lForm = $impl.TFramePreviewForm.$create("Create$1",[$mod.Application]);
      lFrame = AInstanceClass.$create("Create$1",[lForm]);
      lForm.FFrame = lFrame;
      lForm.FPopup = false;
      AReference.set(lFrame);
      $mod.Application.FActiveForm = lForm;
      $mod.Application.CreateNewForm(lForm,cHTMLCode);
    };
    this.CreateForm$6 = function (AInstanceClass, AElement, AReference) {
      this.CreateForm$2(AInstanceClass,AElement.id,AReference,null);
    };
    this.CreateFormDirect = function (AInstanceClass, AReference) {
      this.CreateForm$3(AInstanceClass,this.FAppContainer,AReference,null,false);
    };
    this.CreateFormDirect$1 = function (AInstanceClass, AElementID, AReference) {
      this.CreateForm$3(AInstanceClass,AElementID,AReference,null,false);
    };
    this.CreateFormDirect$2 = function (AInstanceClass, AReference) {
      this.CreateForm$4(AInstanceClass,AReference);
    };
    this.CreateFormDirect$3 = function (AInstanceClass, AReference) {
      this.CreateForm$5(AInstanceClass,AReference);
    };
    this.LoadForm = function (AForm, AFormFile) {
      AForm.FPrevActiveForm = this.FActiveForm;
      this.FActiveForm = AForm;
      this.FLoadForm = AForm;
      if (this.FMainForm === null) this.FMainForm = AForm;
      this.FLastReq = new XMLHttpRequest();
      this.FLastReq.addEventListener("load",rtl.createSafeCallback(this,"DoFormLoad"));
      this.FLastReq.addEventListener("abort",rtl.createSafeCallback(this,"DoFormAbort"));
      this.FLastReq.open("GET",AFormFile);
      this.FLastReq.send();
    };
    this.LoadForm$1 = function (AForm, AFormFile, FormLoaded) {
      this.FCreatedProc = FormLoaded;
      this.LoadForm(AForm,AFormFile);
    };
    this.ChangeCSS = function (id, href) {
      var styleElement = document.getElementById(id);
      if (styleElement) {
        styleElement.href = href;
        return;
      };
    };
    this.InsertCSS = function (id, href) {
      var styleElement = null;
      styleElement = document.getElementById(id);
      if (styleElement != null) {
        styleElement.href = href;
        return;
      };
      styleElement = document.createElement("link");
      styleElement.id = id;
      styleElement.rel = 'stylesheet';
      styleElement.href = href;
      document.getElementsByTagName("head").item(0).appendChild(styleElement);
    };
    this.RemoveCSS = function (id) {
      var styleElement = null;
      styleElement = document.getElementById(id);
      if (styleElement != null) {
        styleElement.parentNode.removeChild(styleElement);
      };
    };
    this.HasCSS = function (href) {
      var Result = false;
      var els = null;
      var i = 0;
      var s = "";
      Result = false;
      els = document.querySelectorAll("head > link");
      for (var $l = 0, $end = els.length - 1; $l <= $end; $l++) {
        i = $l;
        s = els.item(i).href;
        if (pas.SysUtils.CompareText(s,href) === 0) {
          Result = true;
          break;
        };
      };
      return Result;
    };
    this.ChangeLanguage = function (Value) {
      this.FLanguage = Value;
      if (this.FMainForm != null) this.ReloadForm();
    };
    this.Initialize = function () {
      var query = "";
      var token = "";
      var p = 0;
      var b = false;
      this.FCanCreateForm = true;
      this.FAppInitializing = true;
      this.FParameters.Clear();
      query = window.location.href;
      this.InitFormatSettings(pas["WEBLib.WebTools"].GetBrowserLocale());
      this.FParameters.SetDelimiter("&");
      this.FParameters.FStrictDelimiter = true;
      p = pas.System.Pos("?",query);
      if (p > 0) query = pas.System.Copy(query,p + 1,query.length);
      this.FParameters.SetDelimitedText(query);
      b = (window.name == "Authentication");
      if (this.FOnOAuthCallBack != null) {
        if ((this.FParameters.IndexOfName("oauthcallback") !== -1) || b) {
          this.FOnOAuthCallBack(this,query);
          this.FIsRedirect = true;
          document.body.innerHTML = this.GetAuthorizationPageHTML(true);
          return;
        };
      };
      if ((this.FParameters.IndexOfName("code") !== -1) && this.FHandleOAuth) {
        if (this.FOnOAuthToken != null) this.FOnOAuthToken(this,query);
        this.FIsRedirect = true;
        token = this.FParameters.GetValue("code");
        if (window.opener && window.opener.processAuthData){
          window.opener.processAuthData(token);
          window.close();
        };
      };
      window.addEventListener("hashchange",rtl.createSafeCallback(this,"DoHashChange"));
      window.addEventListener("online",rtl.createSafeCallback(this,"DoUpdateOnlineStatus"));
      window.addEventListener("offline",rtl.createSafeCallback(this,"DoUpdateOnlineStatus"));
      window.addEventListener("popstate",rtl.createCallback(this,"DoPopState"));
      document.addEventListener("visibilitychange",rtl.createSafeCallback(this,"DoVisibilityChange"));
      if (window.opener !== null) if (this.FParameters.IndexOfName("access_token") !== -1) {
        this.FIsRedirect = true;
        token = this.FParameters.GetValue("access_token");
        if (window.opener && window.opener.processAuthData){
          window.opener.processAuthData(token);
            window.close();
        };
      };
    };
    this.Route = function () {
      var Result = false;
      var frm = null;
      var hash = "";
      var pc = null;
      var i = 0;
      Result = false;
      this.FRouting = true;
      hash = window.location.hash;
      if (hash !== "") {
        hash = rtl.setCharAt(hash,0,"T");
        i = pas.System.Pos("?",hash);
        if (i > 0) hash = rtl.strSetLength(hash,i - 1);
        pc = pas.Classes.GetClass(hash);
        if (pc != null) {
          Result = true;
          $mod.Application.AutoCreateForm(pc,{get: function () {
              return frm;
            }, set: function (v) {
              frm = v;
            }});
        };
      };
      return Result;
    };
    this.InitFormatSettings = function (BrowserLocale) {
      var timestr = "";
      var i = 0;
      var locale = "";
      locale = BrowserLocale;
      pas.SysUtils.FormatSettings.ShortDateFormat = pas["WEBLib.WebTools"].GetLocaleShortDateFormat(locale);
      if (pas.System.Pos("/",pas.SysUtils.FormatSettings.ShortDateFormat) > 0) pas.SysUtils.FormatSettings.DateSeparator = "/";
      if (pas.System.Pos(".",pas.SysUtils.FormatSettings.ShortDateFormat) > 0) pas.SysUtils.FormatSettings.DateSeparator = ".";
      if (pas.System.Pos("-",pas.SysUtils.FormatSettings.ShortDateFormat) > 0) pas.SysUtils.FormatSettings.DateSeparator = "-";
      var event = new Date('Jan 1, 1980 06:07:08 GMT+00:00');
      var loc = "";
      if (locale == "") { loc = navigator.language; } else
      { loc = locale; }
      timestr = event.toLocaleTimeString(loc);
      if (pas.System.Pos(":",timestr) > 0) pas.SysUtils.FormatSettings.TimeSeparator = ":";
      if (pas.System.Pos(".",timestr) > 0) pas.SysUtils.FormatSettings.TimeSeparator = ".";
      if (pas.System.Pos("-",timestr) > 0) pas.SysUtils.FormatSettings.TimeSeparator = "-";
      for (i = 1; i <= 7; i++) {
        pas.SysUtils.FormatSettings.ShortDayNames[i - 1] = pas["WEBLib.WebTools"].GetLocaleShortDayName(i,locale);
        pas.SysUtils.FormatSettings.LongDayNames[i - 1] = pas["WEBLib.WebTools"].GetLocaleLongDayName(i,locale);
      };
      for (i = 1; i <= 12; i++) {
        pas.SysUtils.FormatSettings.ShortMonthNames[i - 1] = pas["WEBLib.WebTools"].GetLocaleShortMonthName(i,locale);
        pas.SysUtils.FormatSettings.LongMonthNames[i - 1] = pas["WEBLib.WebTools"].GetLocaleLongMonthName(i,locale);
      };
      pas.SysUtils.FormatSettings.DecimalSeparator = pas["WEBLib.WebTools"].GetLocaleDecimalSeparator("");
      if (pas.SysUtils.FormatSettings.DecimalSeparator === ".") {
        pas.SysUtils.FormatSettings.ThousandSeparator = ","}
       else pas.SysUtils.FormatSettings.ThousandSeparator = ".";
    };
    this.ReceiveMessageFromClient = function (AMessage) {
      if (this.FClientConnector != null) this.FClientConnector.Receive(AMessage);
    };
    this.RouteForm = function (AParameter) {
      var frm = null;
      var fc = null;
      fc = pas.Classes.GetClass(AParameter);
      $mod.Application.CreateForm(fc,{get: function () {
          return frm;
        }, set: function (v) {
          frm = v;
        }});
    };
    this.Run = function () {
      this.FCanCreateForm = true;
      this.FAppInitializing = false;
    };
    this.RunScript = function (Source) {
      eval(Source);
    };
    this.Terminate = function () {
      window.location.href = "about:blank";
    };
    this.Navigate = function (AURL, ATarget) {
      if (ATarget === $mod.TNavigationTarget.ntBlank) {
        window.open(AURL,"_blank")}
       else window.location.href = AURL;
    };
    this.Download = function (AURL) {
      window.location.href = AURL;
    };
    this.DownloadTextFile = function (AText, AFileName) {
      var element = document.createElement('a');
      element.setAttribute('href', 'data:text/plain;charset=utf-8,' + encodeURIComponent(AText));
      if (AFileName != ''){
        element.setAttribute('download', AFileName);
      }
      element.style.display = 'none';
      document.body.appendChild(element);
      element.click();
      document.body.removeChild(element);
    };
    this.DownloadBinaryFile = function (AData, AFileName, ANewTab) {
      var lElement = document.createElement('a');
          var lUrl = window.URL.createObjectURL(AData);
          lElement.href = lUrl;
      
          if (AFileName != ''){
            lElement.setAttribute('download', AFileName);
          }
      
          lElement.style.display = 'none';
          if (ANewTab == true) {
            lElement.target = '_blank';
          }
          document.body.appendChild(lElement);
          lElement.click();
          document.body.removeChild(lElement);
    };
    this.DownloadBinaryFile$1 = function (AData, AFileName, ANewTab) {
      this.DownloadBinaryFile$2(Uint8Array.from(AData),AFileName,ANewTab);
    };
    this.DownloadBinaryFile$2 = function (AData, AFileName, ANewTab) {
      this.InternalDownloadFile(AData,AFileName,"octet/stream",ANewTab);
    };
    this.DownloadPDFFile = function (AData, AFileName, ANewTab) {
      this.DownloadPDFFile$1(Uint8Array.from(AData),AFileName,ANewTab);
    };
    this.DownloadPDFFile$1 = function (AData, AFileName, ANewTab) {
      this.InternalDownloadFile(AData,AFileName,"application/pdf",ANewTab);
    };
    this.EXEName = function () {
      var Result = "";
      Result = window.document.location.href;
      return Result;
    };
    this.IDETheme = function () {
      var Result = "";
      var s = "";
      Result = "";
      if (!($mod.VSIDE != null)) return Result;
      s = pas["WEBLib.Forms"].VSIDE.theme;
      Result = s;
      return Result;
    };
    this.IDECSS = function () {
      var Result = "";
      Result = "";
      if (this.IDETheme() === "vscode-light") {
        Result = ".IDECaption { background-color: #F0F0F0 !important; color: #555555 !important; border: 1px solid #DDDDDD !important}" + "\r\n" + ".IDEBkg { background-color: white !important; color: #555555 !important; border: 1px solid #DDDDDD !important}" + "\r\n" + ".IDEButton { background-color: #FAFAFA !important; font-size:10pt; color: #555555 !important; border: 1px solid #DDDDDD !important}" + "\r\n" + ".IDEButton:hover {background-color:#F0F0F0 !important}" + "\r\n" + ".IDEFont {font-size:10pt !important}";
      };
      if (this.IDETheme() === "vscode") {
        Result = ".IDECaption,.IDEButton { background-color: #3F3E43 !important; color: #FFFFFF !important; border: 1px solid #35353A !important}" + "\r\n" + ".IDEBkg { background-color: #2A2A2C !important; color: #A9ACB4 !important; border: 1px solid #35353A !important}" + "\r\n" + ".IDEButton:hover {background-color:#434857 !important}" + "\r\n" + ".IDEFont {font-size:10pt !important}";
      };
      return Result;
    };
    this.Version = function () {
      var Result = "";
      Result = $mod.WEBCOREVERSION;
      return Result;
    };
    this.IDEMessage = function (Msg) {
      pas["WEBLib.Forms"].VSIDE.ShowMessage(Msg);
    };
    this.IDEOpenURL = function (URL) {
      pas["WEBLib.Forms"].VSIDE.Open(URL);
    };
    this.NeedsFormRouting = function () {
      var Result = false;
      var s = "";
      Result = pas["WEBLib.WebTools"].HasQueryParam("form",{get: function () {
          return s;
        }, set: function (v) {
          s = v;
        }},true);
      if (Result) this.RouteForm(s);
      return Result;
    };
    this.ObjectURL = function (AFile) {
      var Result = "";
      var res = "";
      res = URL.createObjectURL(AFile);
      Result = res;
      return Result;
    };
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
    var $r = this.$rtti;
    $r.addMethod("Create$1",2,[["AOwner",pas.Classes.$rtti["TComponent"]]]);
  });
  this.GetParentForm = function (AControl) {
    var Result = null;
    var FOwner = null;
    Result = null;
    FOwner = AControl;
    while ((FOwner != null) && !$mod.TCustomForm.isPrototypeOf(FOwner)) {
      if ((FOwner === AControl) && (FOwner.FOwner === null)) {
        FOwner = AControl.FParent}
       else FOwner = FOwner.FOwner;
    };
    if ((FOwner != null) && $mod.TCustomForm.isPrototypeOf(FOwner)) Result = rtl.as(FOwner,$mod.TCustomForm);
    return Result;
  };
  this.Log = function (v) {
    console.log(v);
  };
  this.Log$1 = function (arr) {
    var i = 0;
    var s = "";
    s = "[";
    for (var $l = 0, $end = rtl.length(arr) - 1; $l <= $end; $l++) {
      i = $l;
      function isPrimitive(test) {
              return (test !== Object(test));
            };
      
            if (isPrimitive(arr[i])) {
               var su1 = arr[i].toString();
               if (s != "[") { s = s + ","; }
               s = s + su1;
               }
            else
            {
              console.log(arr[i]);
               if (s != "[") { s = s + ","; }
               s = s + "#object";
            };
    };
    s = s + "]";
    $mod.Log(s);
  };
  this.WinWidth = function () {
    var Result = 0;
    var w = 0;
    if ($mod.VSIDE != null) {
      w = pas["WEBLib.Forms"].VSIDE.clientWidth();
    } else w = window.innerWidth;
    Result = w;
    return Result;
  };
  this.WinHeight = function () {
    var Result = 0;
    var h = 0;
    if ($mod.VSIDE != null) {
      h = pas["WEBLib.Forms"].VSIDE.clientHeight();
    } else h = window.innerHeight;
    Result = h;
    return Result;
  };
  this.Sleep = function (milliseconds) {
    var Result = null;
    Result = new Promise(function (resolve, reject) {
      window.setTimeout(function () {
        resolve(milliseconds);
      },milliseconds);
    });
    return Result;
  };
  this.Application = null;
  this.HandShakeScript = null;
  this.VSIDE = null;
  this.LastHash = "";
  $mod.$implcode = function () {
    rtl.createClass($impl,"TFramePreviewForm",$mod.TForm,function () {
      this.$init = function () {
        $mod.TForm.$init.call(this);
        this.FFrame = null;
      };
      this.$final = function () {
        this.FFrame = undefined;
        $mod.TForm.$final.call(this);
      };
      this.LoadDFMValues = function () {
        $mod.TCustomForm.LoadDFMValues.call(this);
        this.FFrame.SetParentComponent(this);
        this.FFrame.LoadFromForm();
        this.FFrame.BeforeLoadDFMValues();
        try {
          this.FFrame.SetName("Frame1");
          this.FFrame.SetLeft(0);
          this.FFrame.SetTop(0);
          this.FFrame.SetWidth(640);
          this.FFrame.SetHeight(480);
        } finally {
          this.FFrame.AfterLoadDFMValues();
        };
        this.SetName("Form1");
        this.SetLeft(0);
        this.SetTop(0);
        this.SetWidth(640);
        this.SetHeight(480);
      };
      rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
      rtl.addIntf(this,pas.System.IUnknown);
    });
    $impl.ReleaseForm = function (AForm) {
      AForm = rtl.freeLoc(AForm);
      AForm = null;
    };
  };
  $mod.$init = function () {
    $mod.HandShakeScript = document.createElement("script");
    $mod.HandShakeScript.id = "HandShakeScript";
    $mod.HandShakeScript.type = "text/javascript";
    $mod.HandShakeScript.innerHTML = "var IDE = null;" + "\r\n" + 'var TMSWEBCoreClientIdentifier = "unknown";' + "\r\n" + 'var TMSWEBCoreOAuthCallback = "unknown";' + "\r\n" + "function HandShake(cid){" + "\r\n" + "  TMSWEBCoreClientIdentifier = cid;" + "\r\n" + "}";
    document.body.appendChild($mod.HandShakeScript);
    $mod.Application = $mod.TApplication.$create("Create$1",[null]);
  };
},["WEBLib.Dialogs","WEBLib.WebTools","WEBLib.JSON","WEBLib.Utils","Math"]);
rtl.module("WEBLib.StdCtrls",["System","Classes","WEBLib.Controls","SysUtils","Web","WEBLib.Graphics","Types","WEBLib.WebTools","WEBLib.Forms","WEBLib.Menus"],function () {
  "use strict";
  var $mod = this;
  this.TEditCharCase = {"0": "wecLowerCase", wecLowerCase: 0, "1": "wecNormal", wecNormal: 1, "2": "wecMixedCase", wecMixedCase: 2, "3": "wecUpperCase", wecUpperCase: 3};
  this.$rtti.$Enum("TEditCharCase",{minvalue: 0, maxvalue: 3, ordtype: 1, enumtype: this.TEditCharCase});
  this.TCheckBoxState = {"0": "cbChecked", cbChecked: 0, "1": "cbGrayed", cbGrayed: 1, "2": "cbUnchecked", cbUnchecked: 2};
  this.$rtti.$Enum("TCheckBoxState",{minvalue: 0, maxvalue: 2, ordtype: 1, enumtype: this.TCheckBoxState});
  this.TDateTimeKind = {"0": "dtkDate", dtkDate: 0, "1": "dtkTime", dtkTime: 1};
  this.$rtti.$Enum("TDateTimeKind",{minvalue: 0, maxvalue: 1, ordtype: 1, enumtype: this.TDateTimeKind});
  this.TEllipsisPosition = {"0": "epEndEllipsis", epEndEllipsis: 0, "1": "epNone", epNone: 1, "2": "epPathEllipsis", epPathEllipsis: 2, "3": "epWordEllipsis", epWordEllipsis: 3};
  this.$rtti.$Enum("TEllipsisPosition",{minvalue: 0, maxvalue: 3, ordtype: 1, enumtype: this.TEllipsisPosition});
  this.TTextLayout = {"0": "tlTop", tlTop: 0, "1": "tlCenter", tlCenter: 1, "2": "tlBottom", tlBottom: 2};
  this.$rtti.$Enum("TTextLayout",{minvalue: 0, maxvalue: 2, ordtype: 1, enumtype: this.TTextLayout});
  this.TSysLinkType = {"0": "sltID", sltID: 0, "1": "sltURL", sltURL: 1};
  this.$rtti.$Enum("TSysLinkType",{minvalue: 0, maxvalue: 1, ordtype: 1, enumtype: this.TSysLinkType});
  this.TAutoCompletion = {"0": "acOff", acOff: 0, "1": "acHonorificPrefix", acHonorificPrefix: 1, "2": "acGivenName", acGivenName: 2, "3": "acAdditionalName", acAdditionalName: 3, "4": "acFamilyName", acFamilyName: 4, "5": "acHonorificSuffix", acHonorificSuffix: 5, "6": "acNickName", acNickName: 6, "7": "acEmail", acEmail: 7, "8": "acUserName", acUserName: 8, "9": "acNewPassword", acNewPassword: 9, "10": "acCurrentPassword", acCurrentPassword: 10, "11": "acOrganizationTitle", acOrganizationTitle: 11, "12": "acOrganization", acOrganization: 12, "13": "acStreetAddress", acStreetAddress: 13, "14": "acAddressLine1", acAddressLine1: 14, "15": "acAddressLine2", acAddressLine2: 15, "16": "acAddressLine3", acAddressLine3: 16, "17": "acAddressLevel1", acAddressLevel1: 17, "18": "acAddressLevel2", acAddressLevel2: 18, "19": "acAddressLevel3", acAddressLevel3: 19, "20": "acAddressLevel4", acAddressLevel4: 20, "21": "acCountry", acCountry: 21, "22": "acCountryName", acCountryName: 22, "23": "acPostalCode", acPostalCode: 23, "24": "acCCName", acCCName: 24, "25": "acCCGivenName", acCCGivenName: 25, "26": "acCCAdditionalName", acCCAdditionalName: 26, "27": "acCCFamilyName", acCCFamilyName: 27, "28": "acCCNumber", acCCNumber: 28, "29": "acExpiry", acExpiry: 29, "30": "acExpiryMonth", acExpiryMonth: 30, "31": "acExpiryYear", acExpiryYear: 31, "32": "acCSC", acCSC: 32, "33": "acType", acType: 33, "34": "acTransactionCurrency", acTransactionCurrency: 34, "35": "acTransactionAmount", acTransactionAmount: 35, "36": "acLanguage", acLanguage: 36, "37": "acBirthday", acBirthday: 37, "38": "acBirthdayDay", acBirthdayDay: 38, "39": "acBirthDayMonth", acBirthDayMonth: 39, "40": "acBirthDayYear", acBirthDayYear: 40, "41": "acSex", acSex: 41, "42": "acTelephone", acTelephone: 42, "43": "acTelephoneCountryCode", acTelephoneCountryCode: 43, "44": "acTelephoneNational", acTelephoneNational: 44, "45": "acTelephoneAreaCode", acTelephoneAreaCode: 45, "46": "acTelephoneLocal", acTelephoneLocal: 46, "47": "acTelephoneExtension", acTelephoneExtension: 47, "48": "acIMPP", acIMPP: 48, "49": "acURL", acURL: 49, "50": "acPhoto", acPhoto: 50, "51": "acNone", acNone: 51, "52": "acNope", acNope: 52};
  this.$rtti.$Enum("TAutoCompletion",{minvalue: 0, maxvalue: 52, ordtype: 1, enumtype: this.TAutoCompletion});
  this.TEditType = {"0": "weString", weString: 0, "1": "weFloat", weFloat: 1, "2": "weHex", weHex: 2, "3": "weNumeric", weNumeric: 3, "4": "weSignedFloat", weSignedFloat: 4, "5": "weSignedNumeric", weSignedNumeric: 5, "6": "weSearch", weSearch: 6};
  this.$rtti.$Enum("TEditType",{minvalue: 0, maxvalue: 6, ordtype: 1, enumtype: this.TEditType});
  this.THTMLType = {"0": "tLABELTAG", tLABELTAG: 0, "1": "tSPAN", tSPAN: 1, "2": "tDIV", tDIV: 2, "3": "tH1", tH1: 3, "4": "tH2", tH2: 4, "5": "tH3", tH3: 5, "6": "tH4", tH4: 6, "7": "tH5", tH5: 7, "8": "tH6", tH6: 8, "9": "tP", tP: 9};
  this.$rtti.$Enum("THTMLType",{minvalue: 0, maxvalue: 9, ordtype: 1, enumtype: this.THTMLType});
  this.$rtti.$MethodVar("TLinkClickEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["Link",rtl.string],["LinkType",this.$rtti["TSysLinkType"]]]), methodkind: 0});
  rtl.createClass(this,"TCustomLabel",pas["WEBLib.Menus"].TWebCustomControl,function () {
    this.$init = function () {
      pas["WEBLib.Menus"].TWebCustomControl.$init.call(this);
      this.FContent = null;
      this.FAutoSize = false;
      this.FEllipsisPosition = 0;
      this.FWordWrap = false;
      this.FAlignment = 0;
      this.FLayout = 0;
      this.FTransparent = false;
      this.FHTMLType = 0;
      this.FFocusControl = null;
      this.FShowAccelChar = false;
      this.FColor$1 = 0;
      this.FHasAccel = false;
      this.FHasHTML = false;
      this.FElementLabelClassName = "";
      this.FOrigWidth = 0;
      this.FOldWidth = 0;
      this.FOldHeight = 0;
      this.FHTML = "";
    };
    this.$final = function () {
      this.FContent = undefined;
      this.FFocusControl = undefined;
      pas["WEBLib.Menus"].TWebCustomControl.$final.call(this);
    };
    this.SetLayout = function (Value) {
      if (this.FLayout !== Value) {
        this.FLayout = Value;
        this.UpdateElementVisual();
      };
    };
    this.SetAlignment = function (Value) {
      if (this.FAlignment !== Value) {
        this.FAlignment = Value;
        this.UpdateElementVisual();
      };
    };
    this.GetContentHandle = function () {
      var Result = null;
      Result = this.FContent;
      return Result;
    };
    this.SetTransparent = function (Value) {
      if (this.FTransparent !== Value) {
        this.FTransparent = Value;
        this.UpdateElementVisual();
      };
    };
    this.SetHTMLType = function (Value) {
      var el = null;
      if (this.FHTMLType !== Value) {
        this.FHTMLType = Value;
        if (this.FHTMLType in rtl.createSet(null,$mod.THTMLType.tH1,$mod.THTMLType.tH6)) this.SetElementFont(pas["WEBLib.Controls"].TElementFont.efCSS);
        if ((this.GetElementHandle() != null) && (this.FContent != null)) {
          el = this.GetElementHandle().firstChild;
          if ((el != null) && (el.getAttribute("data-lbl") === "lbl")) {
            this.GetElementHandle().removeChild(this.FContent);
            this.FContent = this.CreateLabelElement();
            this.GetElementHandle().appendChild(this.FContent);
            this.UpdateElement();
          };
        };
      };
    };
    this.SetColorEx = function (Value) {
      this.FColor$1 = Value;
      if ((pas.Classes.TComponentStateItem.csDesigning in this.FComponentState) && (this.FColor$1 !== 16777215)) this.SetTransparent(false);
      this.UpdateElement();
    };
    this.SetElementLabelClassName = function (Value) {
      if (this.FElementLabelClassName !== Value) {
        this.FElementLabelClassName = Value;
        this.UpdateElement();
      };
    };
    this.SetHTML = function (Value) {
      if (this.FHTML !== Value) {
        this.FHTML = Value;
        this.UpdateElementData();
      };
    };
    this.SetWidth = function (AValue) {
      if ((AValue !== -1) && (pas.Classes.TComponentStateItem.csLoading in this.FComponentState)) this.FOrigWidth = AValue;
      pas["WEBLib.Controls"].TControl.SetWidth.apply(this,arguments);
    };
    this.CreateElement = function () {
      var Result = null;
      Result = document.createElement("DIV");
      this.FContent = this.CreateLabelElement();
      Result.appendChild(this.FContent);
      return Result;
    };
    this.CreateLabelElement = function () {
      var Result = null;
      Result = null;
      var $tmp = this.FHTMLType;
      if ($tmp === $mod.THTMLType.tSPAN) {
        Result = document.createElement("SPAN")}
       else if ($tmp === $mod.THTMLType.tDIV) {
        Result = document.createElement("DIV")}
       else if ($tmp === $mod.THTMLType.tH1) {
        Result = document.createElement("H1")}
       else if ($tmp === $mod.THTMLType.tH2) {
        Result = document.createElement("H2")}
       else if ($tmp === $mod.THTMLType.tH3) {
        Result = document.createElement("H3")}
       else if ($tmp === $mod.THTMLType.tH4) {
        Result = document.createElement("H4")}
       else if ($tmp === $mod.THTMLType.tH5) {
        Result = document.createElement("H5")}
       else if ($tmp === $mod.THTMLType.tH6) {
        Result = document.createElement("H6")}
       else if ($tmp === $mod.THTMLType.tLABELTAG) {
        Result = document.createElement("LABEL")}
       else if ($tmp === $mod.THTMLType.tP) Result = document.createElement("P");
      Result.setAttribute("data-lbl","lbl");
      return Result;
    };
    this.GetDisplayText = function () {
      var Result = "";
      Result = this.FCaption;
      return Result;
    };
    this.CanShowFocus = function () {
      var Result = false;
      Result = false;
      return Result;
    };
    this.SetParent = function (AValue) {
      pas["WEBLib.Controls"].TControl.SetParent.apply(this,arguments);
      if (this.FAutoSize && (this.FAlignment !== pas.Classes.TAlignment.taLeftJustify) && (this.FOrigWidth !== -1)) {
        this.SetLeft((this.GetLeft() + this.FOrigWidth) - this.GetWidth());
        this.FOrigWidth = -1;
      };
    };
    this.BindElement = function () {
      this.FContent = this.GetContainer().firstElementChild;
    };
    this.Loaded = function () {
      pas["WEBLib.Controls"].TCustomControl.Loaded.call(this);
      if (this.FShowAccelChar && (this.FFocusControl != null)) this.UpdateElementData();
    };
    this.UpdateAutoSize = function () {
      if (this.FAutoSize && (this.FAlign === pas["WEBLib.Controls"].TAlign.alNone)) {
        if ((this.GetElementHandle() != null) && pas["WEBLib.WebTools"].ElementVisible(this.GetElementHandle())) {
          this.SetWidth(-1);
          this.SetHeight(-1);
        };
        this.FEllipsisPosition = $mod.TEllipsisPosition.epNone;
      };
    };
    this.UpdateElementData = function () {
      var lTxt = "";
      var acc = "";
      var ml = false;
      var contentelement = null;
      pas["WEBLib.Controls"].TControl.UpdateElementData.call(this);
      acc = "";
      lTxt = this.GetDisplayText();
      if (this.FShowAccelChar && (pas.System.Pos("&",lTxt) > 0)) {
        lTxt = pas["WEBLib.WebTools"].ProcessAccelerator(lTxt,{get: function () {
            return acc;
          }, set: function (v) {
            acc = v;
          }})}
       else {
        if (this.FHTML === "") {
          lTxt = pas["WEBLib.WebTools"].HTMLToString(lTxt)}
         else lTxt = this.FHTML;
      };
      ml = false;
      if (pas.System.Pos("\r",lTxt) > 0) {
        ml = true;
        if (pas.System.Pos("\n",lTxt) > 0) lTxt = pas.SysUtils.StringReplace(lTxt,"\n","",rtl.createSet(pas.SysUtils.TStringReplaceFlag.rfReplaceAll,pas.SysUtils.TStringReplaceFlag.rfIgnoreCase));
        lTxt = pas.SysUtils.StringReplace(lTxt,"\r","<BR>",rtl.createSet(pas.SysUtils.TStringReplaceFlag.rfReplaceAll,pas.SysUtils.TStringReplaceFlag.rfIgnoreCase));
      } else if (pas.System.Pos("\n",lTxt) > 0) {
        ml = true;
        lTxt = pas.SysUtils.StringReplace(lTxt,"\n","<BR>",rtl.createSet(pas.SysUtils.TStringReplaceFlag.rfReplaceAll,pas.SysUtils.TStringReplaceFlag.rfIgnoreCase));
      };
      if (this.GetIsLinked() && (lTxt === "") && (pas.Classes.TComponentStateItem.csLoading in this.FComponentState)) return;
      if (this.GetContentHandle() != null) {
        if (this.GetIsLinked()) {
          contentelement = this.GetContentHandle();
          if (this.GetID() !== "") {
            contentelement = document.getElementById(this.GetID());
          };
          if (contentelement != null) {
            if (pas.System.Assigned(this.GetContentHandle().nodeValue)) {
              contentelement.nodeValue = lTxt}
             else if (contentelement.childElementCount === 0) contentelement.innerHTML = lTxt;
          };
        } else {
          if ((this.GetContentHandle().childElementCount > 0) && pas.System.Assigned(this.GetContentHandle().nodeValue) && !this.FHasAccel && !this.FHasHTML && !ml) {
            this.GetContentHandle().nodeValue = lTxt;
          } else {
            this.GetContentHandle().innerHTML = lTxt;
          };
        };
      } else this.GetElementHandle().innerHTML = lTxt;
      this.FHasHTML = pas.System.Pos("</",lTxt) > 0;
      this.FHasAccel = acc !== "";
      if ((acc !== "") && (this.FFocusControl != null)) {
        this.GetContentHandle().setAttribute("accesskey",acc);
        this.GetContentHandle().setAttribute("for",this.FFocusControl.GetID());
      };
    };
    this.UpdateElementVisual = function () {
      var ow = 0;
      var oh = 0;
      pas["WEBLib.Controls"].TCustomControl.UpdateElementVisual.call(this);
      if (this.IsUpdating()) return;
      if (this.GetElementHandle() != null) {
        oh = Math.round(this.GetElementHandle().offsetHeight);
        ow = Math.round(this.GetElementHandle().offsetWidth);
        if (oh > 0) this.FOldHeight = oh;
        if (ow > 0) this.FOldWidth = ow;
        if (this.FVisible && (!this.FAutoSize || (this.FAlign !== pas["WEBLib.Controls"].TAlign.alNone)) && ((this.FAlignment !== pas.Classes.TAlignment.taLeftJustify) || (this.FLayout !== $mod.TTextLayout.tlTop))) this.GetElementHandle().style.setProperty("display","table");
        this.GetElementHandle().setAttribute("zindex","1");
        if (this.FAutoSize && (this.FAlign === pas["WEBLib.Controls"].TAlign.alNone) && !(pas.Classes.TComponentStateItem.csDesigning in this.FComponentState)) {
          this.GetElementHandle().style.setProperty("overflow","")}
         else this.GetElementHandle().style.setProperty("overflow","hidden");
      };
      if (this.GetContentHandle() != null) {
        var $tmp = this.FLayout;
        if ($tmp === $mod.TTextLayout.tlTop) {
          this.GetContentHandle().style.setProperty("vertical-align","top")}
         else if ($tmp === $mod.TTextLayout.tlCenter) {
          this.GetContentHandle().style.setProperty("vertical-align","middle")}
         else if ($tmp === $mod.TTextLayout.tlBottom) this.GetContentHandle().style.setProperty("vertical-align","bottom");
        var $tmp1 = this.FAlignment;
        if ($tmp1 === pas.Classes.TAlignment.taLeftJustify) {
          this.GetContentHandle().style.removeProperty("text-align")}
         else if ($tmp1 === pas.Classes.TAlignment.taCenter) {
          this.GetContentHandle().style.setProperty("text-align","center")}
         else if ($tmp1 === pas.Classes.TAlignment.taRightJustify) this.GetContentHandle().style.setProperty("text-align","right");
        pas["WEBLib.Controls"].SetHTMLElementColor(this.GetElementHandle(),this.FColor$1,this.FTransparent || (this.FColor$1 === -1) || (this.FColor$1 === 16711422));
        pas["WEBLib.Controls"].SetHTMLElementColor(this.GetContentHandle(),this.FColor$1,this.FTransparent || (this.FColor$1 === -1) || (this.FColor$1 === 16711422));
        this.GetContentHandle().style.setProperty("display","table-cell");
        if (this.FElementClassName === "") {
          if (this.FEnabled && (this.FElementFont === pas["WEBLib.Controls"].TElementFont.efProperty) && !this.GetIsLinked()) {
            this.GetContentHandle().style.setProperty("color",pas["WEBLib.Graphics"].ColorToHTML(this.FFont.FColor))}
           else this.GetContentHandle().style.removeProperty("color");
          this.SetElementPointer(this.GetContentHandle(),this.FCursor);
          pas["WEBLib.Controls"].SetHTMLElementFont(this.GetContentHandle(),this.FFont,!((this.FElementFont === pas["WEBLib.Controls"].TElementFont.efProperty) && !this.GetIsLinked()));
        } else {
          this.GetContentHandle().style.removeProperty("color");
          pas["WEBLib.Controls"].SetHTMLElementFont(this.GetContentHandle(),this.FFont,true);
        };
        if (this.FElementLabelClassName !== "") {
          this.GetContentHandle().setAttribute("class",this.FElementLabelClassName)}
         else this.GetContentHandle().removeAttribute("class");
        if ((this.FElementPosition === pas["WEBLib.Controls"].TElementPosition.epAbsolute) || (this.FWidthStyle === pas["WEBLib.Controls"].TSizeStyle.ssAbsolute)) {
          if (this.FEllipsisPosition === $mod.TEllipsisPosition.epNone) {
            this.GetContentHandle().style.setProperty("text-overflow","clip")}
           else this.GetContentHandle().style.setProperty("text-overflow","ellipsis");
        } else this.GetContentHandle().style.removeProperty("text-overflow");
        if (this.FWordWrap) {
          this.GetContentHandle().style.setProperty("white-space","normal")}
         else this.GetContentHandle().style.setProperty("white-space","nowrap");
        this.GetElementHandle().style.setProperty("user-select","");
        if (this.FCursor === 0) this.GetElementHandle().style.setProperty("cursor","");
        if (this.FAutoSize && (this.FAlign === pas["WEBLib.Controls"].TAlign.alNone) && !(pas.Classes.TComponentStateItem.csDesigning in this.FComponentState)) {
          this.GetElementHandle().style.removeProperty("width");
          this.GetElementHandle().style.removeProperty("height");
        };
      };
    };
    this.UpdateElementSize = function () {
      pas["WEBLib.Controls"].TControl.UpdateElementSize.call(this);
      if (this.FAutoSize && (this.FAlign === pas["WEBLib.Controls"].TAlign.alNone) && (this.GetElementHandle() != null)) {
        if (!(pas.Classes.TComponentStateItem.csDesigning in this.FComponentState)) {
          this.GetElementHandle().style.removeProperty("width");
          this.GetElementHandle().style.removeProperty("height");
        };
      };
      if ((this.GetContentHandle() != null) && (this.FAlign in rtl.createSet(pas["WEBLib.Controls"].TAlign.alLeft,pas["WEBLib.Controls"].TAlign.alRight,pas["WEBLib.Controls"].TAlign.alClient)) && !this.FAutoSize && (this.FLayout in rtl.createSet($mod.TTextLayout.tlCenter,$mod.TTextLayout.tlBottom))) {
        this.GetContentHandle().style.setProperty("height",pas.SysUtils.TIntegerHelper.ToString$1.call({p: this.GetHeight(), get: function () {
            return this.p;
          }, set: function (v) {
            this.p = v;
          }}) + "px");
      };
    };
    this.SetAutoSize = function (AValue) {
      if (this.FAutoSize !== AValue) {
        this.FAutoSize = AValue;
        this.UpdateAutoSize();
        this.UpdateElement();
      };
    };
    this.SetCaption = function (AValue) {
      var dw = 0;
      if (this.FCaption !== AValue) {
        dw = this.GetWidth();
        pas["WEBLib.Controls"].TCustomControl.SetCaption.call(this,AValue);
        this.UpdateAutoSize();
        this.UpdateElement();
        dw = dw - this.GetWidth();
        if (this.FAutoSize && (this.FAlignment !== pas.Classes.TAlignment.taLeftJustify) && (dw !== 0) && (pas["WEBLib.Controls"].TAnchorKind.akRight in this.FAnchors) && !this.IsUpdating()) this.SetLeft(this.GetLeft() + dw);
      };
    };
    this.SetControlCursor = function (Value) {
      pas["WEBLib.Controls"].TControl.SetControlCursor.apply(this,arguments);
      if ((this.FElementClassName === "") && (this.GetContentHandle() != null)) this.SetElementPointer(this.GetContentHandle(),this.FCursor);
    };
    this.SetEllipsisPosition = function (AValue) {
      if (this.FEllipsisPosition !== AValue) {
        this.FEllipsisPosition = AValue;
        if (this.FEllipsisPosition !== $mod.TEllipsisPosition.epNone) this.FAutoSize = false;
        this.UpdateElement();
      };
    };
    this.GetWidth = function () {
      var Result = 0;
      if (this.FAutoSize && (this.GetElementHandle() != null) && (this.FParent != null)) {
        Result = Math.round(this.GetElementHandle().offsetWidth);
        if (Result === 0) Result = pas["WEBLib.Controls"].TControl.GetWidth.call(this);
        if ((Result === 0) && (this.FCaption !== "") && (pas.Classes.TComponentStateItem.csDesigning in this.FComponentState)) Result = this.FOldWidth;
      } else Result = pas["WEBLib.Controls"].TControl.GetWidth.call(this);
      return Result;
    };
    this.GetHeight = function () {
      var Result = 0;
      if (this.FAutoSize && (this.GetElementHandle() != null) && (this.FParent != null)) {
        Result = Math.round(this.GetElementHandle().offsetHeight);
        if (Result === 0) Result = pas["WEBLib.Controls"].TControl.GetHeight.call(this);
        if ((Result === 0) && (this.FCaption !== "") && (pas.Classes.TComponentStateItem.csDesigning in this.FComponentState)) Result = this.FOldHeight;
      } else Result = pas["WEBLib.Controls"].TControl.GetHeight.call(this);
      return Result;
    };
    this.InitCSSLibrary = function (ALibrary) {
      if (ALibrary === pas["WEBLib.Controls"].TCSSLibrary.cssBootstrap) {
        this.SetElementFont(pas["WEBLib.Controls"].TElementFont.efCSS);
        this.SetHeightStyle(pas["WEBLib.Controls"].TSizeStyle.ssAuto);
      };
    };
    this.CreateInitialize = function () {
      pas["WEBLib.Controls"].TCustomControl.CreateInitialize.call(this);
      this.FAutoSize = true;
      this.FLayout = $mod.TTextLayout.tlTop;
      this.FEllipsisPosition = $mod.TEllipsisPosition.epNone;
      this.FColor$1 = 16777215;
      this.FTransparent = true;
      this.FAlignment = pas.Classes.TAlignment.taLeftJustify;
      this.SetTabStop(false);
      this.FShowAccelChar = true;
    };
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
  });
  rtl.createClass(this,"TLabel",this.TCustomLabel,function () {
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
    var $r = this.$rtti;
    $r.addProperty("Align",2,pas["WEBLib.Controls"].$rtti["TAlign"],"FAlign","SetAlign",{Default: pas["WEBLib.Controls"].TAlign.alNone});
    $r.addProperty("Alignment",2,pas.Classes.$rtti["TAlignment"],"FAlignment","SetAlignment",{Default: pas.Classes.TAlignment.taLeftJustify});
    $r.addProperty("AlignWithMargins",2,rtl.boolean,"FAlignWithMargins","SetAlignWithMargins",{Default: false});
    $r.addProperty("Anchors",2,pas["WEBLib.Controls"].$rtti["TAnchors"],"FAnchors","SetAnchors",{Default: rtl.createSet(pas["WEBLib.Controls"].TAnchorKind.akLeft,pas["WEBLib.Controls"].TAnchorKind.akTop)});
    $r.addProperty("AutoSize",2,rtl.boolean,"FAutoSize","SetAutoSize",{Default: true});
    $r.addProperty("Caption",2,rtl.string,"FCaption","SetCaption");
    $r.addProperty("ChildOrder",2,rtl.longint,"FChildOrder","SetChildOrderEx",{Default: 0});
    $r.addProperty("Color",2,pas["WEBLib.Graphics"].$rtti["TColor"],"FColor$1","SetColorEx",{Default: 16777215});
    $r.addProperty("DragMode",2,pas["WEBLib.Controls"].$rtti["TDragMode"],"FDragMode","SetDragMode",{Default: pas["WEBLib.Controls"].TDragMode.dmManual});
    $r.addProperty("EllipsisPosition",2,$mod.$rtti["TEllipsisPosition"],"FEllipsisPosition","SetEllipsisPosition",{Default: $mod.TEllipsisPosition.epNone});
    $r.addProperty("Enabled",2,rtl.boolean,"FEnabled","SetEnabled",{Default: true});
    $r.addProperty("ElementClassName",2,pas["WEBLib.Controls"].$rtti["TElementClassName"],"FElementClassName","SetElementClassName");
    $r.addProperty("ElementLabelClassName",2,pas["WEBLib.Controls"].$rtti["TElementClassName"],"FElementLabelClassName","SetElementLabelClassName");
    $r.addProperty("ElementID",3,pas["WEBLib.Controls"].$rtti["TElementID"],"GetID","SetID");
    $r.addProperty("ElementFont",2,pas["WEBLib.Controls"].$rtti["TElementFont"],"FElementFont","SetElementFont",{Default: pas["WEBLib.Controls"].TElementFont.efProperty});
    $r.addProperty("ElementPosition",2,pas["WEBLib.Controls"].$rtti["TElementPosition"],"FElementPosition","SetElementPosition",{Default: pas["WEBLib.Controls"].TElementPosition.epAbsolute});
    $r.addProperty("FocusControl",0,pas["WEBLib.Controls"].$rtti["TWinControl"],"FFocusControl","FFocusControl");
    $r.addProperty("Font",2,pas["WEBLib.Graphics"].$rtti["TFont"],"FFont","SetFont");
    $r.addProperty("Height",3,rtl.longint,"GetHeight","SetHeight");
    $r.addProperty("HeightPercent",2,rtl.double,"FHeightPercent","SetHeightPercent",{Default: 100});
    $r.addProperty("HeightStyle",2,pas["WEBLib.Controls"].$rtti["TSizeStyle"],"FHeightStyle","SetHeightStyle",{Default: pas["WEBLib.Controls"].TSizeStyle.ssAbsolute});
    $r.addProperty("Hint",2,rtl.string,"FHint","SetHint");
    $r.addProperty("HTML",2,rtl.string,"FHTML","SetHTML");
    $r.addProperty("HTMLType",2,$mod.$rtti["THTMLType"],"FHTMLType","SetHTMLType",{Default: $mod.THTMLType.tLABELTAG});
    $r.addProperty("Layout",2,$mod.$rtti["TTextLayout"],"FLayout","SetLayout",{Default: $mod.TTextLayout.tlTop});
    $r.addProperty("Left",3,rtl.longint,"GetLeft","SetLeft");
    $r.addProperty("Margins",2,pas["WEBLib.Controls"].$rtti["TMargins"],"FMargins","SetMargins");
    $r.addProperty("ParentFont",2,rtl.boolean,"FParentFont","SetParentFont",{Default: true});
    $r.addProperty("PopupMenu",0,pas["WEBLib.Menus"].$rtti["TPopupMenu"],"FPopupMenu","FPopupMenu");
    $r.addProperty("ShowAccelChar",0,rtl.boolean,"FShowAccelChar","FShowAccelChar",{Default: true});
    $r.addProperty("ShowHint",2,rtl.boolean,"FShowHint","SetShowHint",{Default: false});
    $r.addProperty("TextDirection",0,pas["WEBLib.Controls"].$rtti["TTextDirection"],"FTextDirection","FTextDirection",{Default: pas["WEBLib.Controls"].TTextDirection.tdDefault});
    $r.addProperty("Top",3,rtl.longint,"GetTop","SetTop");
    $r.addProperty("Transparent",2,rtl.boolean,"FTransparent","SetTransparent",{Default: true});
    $r.addProperty("Visible",2,rtl.boolean,"FVisible","SetVisible",{Default: true});
    $r.addProperty("Width",3,rtl.longint,"GetWidth","SetWidth");
    $r.addProperty("WidthPercent",2,rtl.double,"FWidthPercent","SetWidthPercent",{Default: 100});
    $r.addProperty("WidthStyle",2,pas["WEBLib.Controls"].$rtti["TSizeStyle"],"FWidthStyle","SetWidthStyle",{Default: pas["WEBLib.Controls"].TSizeStyle.ssAbsolute});
    $r.addProperty("WordWrap",0,rtl.boolean,"FWordWrap","FWordWrap",{Default: false});
    $r.addProperty("OnClick",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnClick","FOnClick");
    $r.addProperty("OnDblClick",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnDblClick","FOnDblClick");
    $r.addProperty("OnTouchStart",0,pas["WEBLib.Controls"].$rtti["TTouchEvent"],"FOnTouchStart","FOnTouchStart");
    $r.addProperty("OnTouchEnd",0,pas["WEBLib.Controls"].$rtti["TTouchEvent"],"FOnTouchEnd","FOnTouchEnd");
    $r.addProperty("OnTouchMove",0,pas["WEBLib.Controls"].$rtti["TTouchEvent"],"FOnTouchMove","FOnTouchMove");
    $r.addProperty("OnTouchCancel",0,pas["WEBLib.Controls"].$rtti["TTouchEvent"],"FOnTouchCancel","FOnTouchCancel");
    $r.addProperty("OnDragOver",0,pas["WEBLib.Controls"].$rtti["TDragOverEvent"],"FOnDragOver","FOnDragOver");
    $r.addProperty("OnDragDrop",0,pas["WEBLib.Controls"].$rtti["TDragDropEvent"],"FOnDragDrop","FOnDragDrop");
    $r.addProperty("OnStartDrag",0,pas["WEBLib.Controls"].$rtti["TStartDragEvent"],"FOnStartDrag","FOnStartDrag");
    $r.addProperty("OnEndDrag",0,pas["WEBLib.Controls"].$rtti["TEndDragEvent"],"FonEndDrag","FonEndDrag");
  });
  rtl.createClass(this,"TWebLabel",this.TLabel,function () {
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
  });
  rtl.createClass(this,"TCustomInput",pas["WEBLib.Menus"].TWebCustomControl,function () {
    this.IsInputControl = function () {
      var Result = false;
      Result = true;
      return Result;
    };
    this.GetInputType = function () {
      var Result = "";
      Result = "EDIT";
      return Result;
    };
    this.CreateElement = function () {
      var Result = null;
      Result = document.createElement("INPUT");
      Result.setAttribute("type",this.GetInputType());
      return Result;
    };
    this.UpdateElementVisual = function () {
      pas["WEBLib.Controls"].TCustomControl.UpdateElementVisual.call(this);
      if ((this.GetContainer() != null) && !this.GetIsLinked()) {
        this.GetContainer().style.setProperty("-moz-box-sizing","border-box");
        this.GetContainer().style.setProperty("-webkit-box-sizing","border-box");
        this.GetContainer().style.setProperty("box-sizing","border-box");
      };
    };
    this.LoadState = function (AState) {
      this.GetElementHandle().value = AState;
    };
    this.SaveState = function () {
      var Result = "";
      Result = this.GetElementHandle().value;
      return Result;
    };
    this.CreateInitialize = function () {
      pas["WEBLib.Controls"].TCustomControl.CreateInitialize.call(this);
      this.SetShowFocus(true);
      this.FNoUserSelect = false;
    };
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
  });
  rtl.createClass(this,"TCustomEdit",this.TCustomInput,function () {
    this.$init = function () {
      $mod.TCustomInput.$init.call(this);
      this.FCharCase = 0;
      this.FMaxLength = 0;
      this.FReadOnly = false;
      this.FText = "";
      this.FTextHint = "";
      this.FSelStart = 0;
      this.FAlignment = 0;
      this.FHideSelection = false;
      this.FPasswordChar = "\x00";
      this.FOnChange = null;
      this.FAutoSize = false;
      this.FAutoSelect = false;
      this.FSelLength = 0;
      this.FNumeric = false;
      this.FAutoCompletion = 0;
      this.FEditType = 0;
      this.FRequired = false;
      this.FAutoFocus = false;
      this.FPattern = "";
      this.FHandlePastePtr = null;
      this.FHandleCutPtr = null;
      this.FHandleChangePtr = null;
      this.FHandleInvalidPtr = null;
      this.FHandleSearchPtr = null;
      this.FSpellCheck = false;
      this.FRequiredText = "";
      this.FOnSearch = null;
    };
    this.$final = function () {
      this.FOnChange = undefined;
      this.FOnSearch = undefined;
      $mod.TCustomInput.$final.call(this);
    };
    this.SetAlignment = function (Value) {
      this.FAlignment = Value;
      this.UpdateElement();
    };
    this.SetHideSelection = function (Value) {
      if (this.FHideSelection !== Value) {
        this.FHideSelection = Value;
        this.UpdateElement();
      };
    };
    this.SetAutoSelect = function (Value) {
      if (this.FAutoSelect !== Value) {
        this.FAutoSelect = Value;
        this.UpdateElement();
      };
    };
    this.SetAutoSize = function (Value) {
      if (this.FAutoSize !== Value) {
        this.FAutoSize = Value;
        this.UpdateElement();
      };
    };
    this.SetSelLength = function (Value) {
      this.FSelLength = Value;
      this.UpdateElement();
    };
    this.SetSelStart = function (Value) {
      this.FSelStart = Value;
      this.UpdateElement();
    };
    this.SetPasswordChar = function (Value) {
      this.FPasswordChar = Value;
      this.UpdateElement();
    };
    this.SetNumeric = function (Value) {
      this.FNumeric = Value;
      this.UpdateElement();
    };
    this.SetAutoCompletion = function (Value) {
      if (this.FAutoCompletion !== Value) {
        this.FAutoCompletion = Value;
        this.UpdateElement();
      };
    };
    this.SetAutoFocus = function (Value) {
      if (this.FAutoFocus !== Value) {
        this.FAutoFocus = Value;
        this.UpdateElement();
      };
    };
    this.SetRequired = function (Value) {
      if (this.FRequired !== Value) {
        this.FRequired = Value;
        this.UpdateElement();
      };
    };
    this.SetPattern = function (Value) {
      if (this.FPattern !== Value) {
        this.FPattern = Value;
        this.UpdateElement();
      };
    };
    this.GetSelLength = function () {
      var Result = 0;
      Result = -1;
      if (this.GetElementInputHandle() != null) Result = this.GetElementInputHandle().selectionEnd - this.GetElementInputHandle().selectionStart;
      return Result;
    };
    this.GetSelStart = function () {
      var Result = 0;
      Result = -1;
      if (this.GetElementInputHandle() != null) Result = this.GetElementInputHandle().selectionStart;
      return Result;
    };
    this.SetEditType = function (Value) {
      if (this.FEditType !== Value) {
        this.FEditType = Value;
        this.UpdateElement();
      };
    };
    this.GetSelText = function () {
      var Result = "";
      Result = pas.System.Copy(this.GetText(),this.GetSelStart() + 1,this.GetSelLength());
      return Result;
    };
    this.SetSpellCheck = function (Value) {
      if (this.FSpellCheck !== Value) {
        this.FSpellCheck = Value;
        this.UpdateElement();
      };
    };
    this.GetElementInputHandle = function () {
      var Result = null;
      Result = this.GetContainer();
      return Result;
    };
    this.DoHandlePaste = function (Event) {
      var Result = false;
      var s = "";
      var clp = false;
      clp = false;
      var clipboardData = Event.clipboardData || window.clipboardData;
      if (clipboardData) {
      s = clipboardData.getData('Text');
      clp = true;
      };
      if (clp && (!this.CanPaste(s) || !this.Validate(s))) {
        Event.preventDefault();
        Event.stopPropagation();
      };
      Result = false;
      return Result;
    };
    this.DoHandleCut = function (Event) {
      var Result = false;
      if (!this.CanCut()) {
        Event.preventDefault();
        Event.stopPropagation();
      };
      Result = false;
      return Result;
    };
    this.DoHandleChange = function (Event) {
      var Result = false;
      this.Change();
      Result = true;
      if (this.FRequiredText !== "") {
        this.GetElementInputHandle().setCustomValidity("");
      };
      return Result;
    };
    this.DoHandleInvalid = function (Event) {
      var Result = false;
      this.GetElementInputHandle().setCustomValidity(this.FRequiredText);
      Result = true;
      return Result;
    };
    this.DoHandleSearch = function (Event) {
      var Result = false;
      Result = true;
      if (this.FOnSearch != null) this.FOnSearch(this);
      return Result;
    };
    this.IsCustomEditor = function () {
      var Result = false;
      Result = false;
      return Result;
    };
    this.KeyPress = function (Key) {
      var isValid = false;
      pas["WEBLib.Controls"].TControl.KeyPress.call(this,Key);
      isValid = true;
      var $tmp = this.FEditType;
      if ($tmp === $mod.TEditType.weNumeric) {
        isValid = Key.get().charCodeAt() in rtl.createSet(null,48,57)}
       else if ($tmp === $mod.TEditType.weSignedNumeric) {
        isValid = Key.get().charCodeAt() in rtl.createSet(null,48,57,43,45)}
       else if ($tmp === $mod.TEditType.weFloat) {
        isValid = Key.get().charCodeAt() in rtl.createSet(null,48,57,44,46)}
       else if ($tmp === $mod.TEditType.weSignedFloat) {
        isValid = Key.get().charCodeAt() in rtl.createSet(null,48,57,44,46,43,45)}
       else if ($tmp === $mod.TEditType.weHex) isValid = Key.get().charCodeAt() in rtl.createSet(null,48,57,null,65,70);
      if (!isValid) Key.set("\x00");
    };
    this.DoEnter = function () {
      var el = null;
      pas["WEBLib.Controls"].TControl.DoEnter.call(this);
      if (this.FAutoSelect && (this.GetElementInputHandle() != null)) {
        el = this.GetElementInputHandle();
        el.select();
      };
    };
    this.GetInputType = function () {
      var Result = "";
      if (this.FPasswordChar !== "\x00") {
        Result = "PASSWORD"}
       else if (this.FNumeric) {
        Result = "NUMBER"}
       else if (this.FEditType in rtl.createSet($mod.TEditType.weFloat,$mod.TEditType.weNumeric)) {
        Result = "TEL"}
       else if (this.FEditType === $mod.TEditType.weSearch) {
        Result = "SEARCH"}
       else Result = "TEXT";
      return Result;
    };
    this.PersistinHTML = function () {
      this.GetElementInputHandle().setAttribute("value",this.GetText());
    };
    this.GetText = function () {
      var Result = "";
      Result = this.FText;
      if (this.GetElementInputHandle() != null) Result = this.GetElementInputHandle().value;
      if (this.FCharCase === $mod.TEditCharCase.wecUpperCase) Result = pas.SysUtils.UpperCase(Result);
      if (this.FCharCase === $mod.TEditCharCase.wecLowerCase) Result = pas.SysUtils.LowerCase(Result);
      return Result;
    };
    this.GetDisplayText = function () {
      var Result = "";
      Result = this.FText;
      return Result;
    };
    this.IsReadOnly = function () {
      var Result = false;
      Result = this.FReadOnly;
      return Result;
    };
    this.Validate = function (AValue) {
      var Result = false;
      var i = 0;
      var Key = "\x00";
      var isvalid = false;
      Result = true;
      for (var $l = 1, $end = AValue.length; $l <= $end; $l++) {
        i = $l;
        Key = AValue.charAt(i - 1);
        isvalid = true;
        var $tmp = this.FEditType;
        if ($tmp === $mod.TEditType.weNumeric) {
          isvalid = Key.charCodeAt() in rtl.createSet(null,48,57)}
         else if ($tmp === $mod.TEditType.weSignedNumeric) {
          isvalid = Key.charCodeAt() in rtl.createSet(null,48,57,43,45)}
         else if ($tmp === $mod.TEditType.weFloat) {
          isvalid = Key.charCodeAt() in rtl.createSet(null,48,57,44,46)}
         else if ($tmp === $mod.TEditType.weSignedFloat) {
          isvalid = Key.charCodeAt() in rtl.createSet(null,48,57,44,46,43,45)}
         else if ($tmp === $mod.TEditType.weHex) isvalid = Key.charCodeAt() in rtl.createSet(null,48,57,null,65,70);
        if (!isvalid) {
          Result = false;
          break;
        };
      };
      return Result;
    };
    this.ClearMethodPointers = function () {
      pas["WEBLib.Controls"].TControl.ClearMethodPointers.call(this);
      this.FHandlePastePtr = null;
      this.FHandleCutPtr = null;
      this.FHandleChangePtr = null;
      this.FHandleInvalidPtr = null;
      this.FHandleSearchPtr = null;
    };
    this.GetMethodPointers = function () {
      pas["WEBLib.Controls"].TControl.GetMethodPointers.call(this);
      this.FHandlePastePtr = rtl.createCallback(this,"DoHandlePaste");
      this.FHandleCutPtr = rtl.createCallback(this,"DoHandleCut");
      this.FHandleChangePtr = rtl.createCallback(this,"DoHandleChange");
      this.FHandleInvalidPtr = rtl.createCallback(this,"DoHandleInvalid");
      this.FHandleSearchPtr = rtl.createCallback(this,"DoHandleSearch");
    };
    this.BindEvents = function () {
      pas["WEBLib.Controls"].TCustomControl.BindEvents.call(this);
      if (this.GetElementInputHandle() != null) {
        this.GetElementInputHandle().addEventListener("input",this.FHandleChangePtr);
        this.GetElementInputHandle().addEventListener("paste",this.FHandlePastePtr);
        this.GetElementInputHandle().addEventListener("cut",this.FHandleCutPtr);
        this.GetElementInputHandle().addEventListener("invalid",this.FHandleInvalidPtr);
        this.GetElementInputHandle().addEventListener("search",this.FHandleSearchPtr);
      };
    };
    this.UnbindEvents = function () {
      pas["WEBLib.Controls"].TControl.UnbindEvents.call(this);
      if (this.GetElementInputHandle() != null) {
        this.GetElementInputHandle().removeEventListener("input",this.FHandleChangePtr);
        this.GetElementInputHandle().removeEventListener("paste",this.FHandlePastePtr);
        this.GetElementInputHandle().removeEventListener("cut",this.FHandleCutPtr);
        this.GetElementInputHandle().removeEventListener("invalid",this.FHandleInvalidPtr);
        this.GetElementInputHandle().removeEventListener("search",this.FHandleSearchPtr);
      };
    };
    this.UpdateElementData = function () {
      var eh = null;
      var ss = 0;
      var sl = 0;
      var isNum = false;
      var doAc = false;
      pas["WEBLib.Controls"].TControl.UpdateElementData.call(this);
      if (this.GetElementInputHandle() != null) {
        if (!this.GetIsLinked()) {
          var $tmp = this.FCharCase;
          if ($tmp === $mod.TEditCharCase.wecUpperCase) {
            this.GetElementInputHandle().style.setProperty("text-transform","uppercase")}
           else if ($tmp === $mod.TEditCharCase.wecLowerCase) {
            this.GetElementInputHandle().style.setProperty("text-transform","lowercase")}
           else if ($tmp === $mod.TEditCharCase.wecMixedCase) {
            this.GetElementInputHandle().style.setProperty("text-transform","capitalize")}
           else if ($tmp === $mod.TEditCharCase.wecNormal) this.GetElementInputHandle().style.setProperty("text-transform","initial");
        };
        this.GetElementInputHandle().readOnly = this.IsReadOnly();
        if (this.FTextHint !== "") this.GetElementInputHandle().placeholder = this.FTextHint;
        doAc = true;
        if (this.GetIsLinked()) {
          doAc = !this.GetElementInputHandle().hasAttribute("autocomplete");
        };
        if (doAc) {
          if (this.FAutoCompletion === $mod.TAutoCompletion.acNope) {
            this.GetElementInputHandle().setAttribute("autocomplete","nope");
            if (!this.GetIsLinked()) this.GetElementInputHandle().removeAttribute("name");
          } else if (this.FAutoCompletion === $mod.TAutoCompletion.acNone) {
            this.GetElementInputHandle().setAttribute("autocomplete","off");
            if (!this.GetIsLinked()) this.GetElementInputHandle().removeAttribute("name");
          } else if (this.FAutoCompletion !== $mod.TAutoCompletion.acOff) {
            this.GetElementInputHandle().setAttribute("autocomplete","on");
            if (!this.GetIsLinked()) this.GetElementInputHandle().setAttribute("name",$mod.GetAutoCompletionName(this.FAutoCompletion));
          } else {
            this.GetElementInputHandle().removeAttribute("autocomplete");
            if (!this.GetIsLinked()) this.GetElementInputHandle().removeAttribute("name");
          };
        };
        if (!this.GetIsLinked()) {
          this.GetElementInputHandle().setAttribute("type",this.GetInputType());
          this.GetElementInputHandle().setAttribute("role","textbox");
          var $tmp1 = this.FAlignment;
          if ($tmp1 === pas.Classes.TAlignment.taLeftJustify) {
            this.GetElementInputHandle().style.removeProperty("text-align")}
           else if ($tmp1 === pas.Classes.TAlignment.taCenter) {
            this.GetElementInputHandle().style.setProperty("text-align","center")}
           else if ($tmp1 === pas.Classes.TAlignment.taRightJustify) this.GetElementInputHandle().style.setProperty("text-align","right");
        };
        if (this.FRequired) {
          this.GetElementInputHandle().setAttribute("required","")}
         else if (!this.GetIsLinked()) this.GetElementInputHandle().removeAttribute("required");
        if (this.FAutoFocus) {
          this.GetElementInputHandle().setAttribute("autofocus","")}
         else if (!this.GetIsLinked()) this.GetElementInputHandle().removeAttribute("autofocus");
        if (this.FPattern !== "") {
          this.GetElementInputHandle().setAttribute("pattern",this.FPattern)}
         else this.GetElementInputHandle().removeAttribute("pattern");
        if (this.FMaxLength <= 0) {
          this.GetElementInputHandle().removeAttribute("maxLength")}
         else this.GetElementInputHandle().maxLength = this.FMaxLength;
        this.GetElementInputHandle().value = this.GetDisplayText();
        isNum = pas.SysUtils.UpperCase(this.GetInputType()) === "NUMBER";
        if (!this.FSpellCheck) {
          this.GetElementInputHandle().setAttribute("spellcheck","false")}
         else this.GetElementInputHandle().removeAttribute("spellcheck");
        if (!isNum && !this.GetIsLinked() && !this.IsCustomEditor()) {
          ss = this.FSelStart;
          sl = this.FSelStart + this.FSelLength;
          eh = this.GetElementInputHandle();
          setTimeout(function() {
            eh.setSelectionRange(ss, sl);
          }, 1);
        };
      };
    };
    this.SetCharCase = function (AValue) {
      if (this.FCharCase !== AValue) {
        this.FCharCase = AValue;
        this.UpdateElement();
      };
    };
    this.SetMaxLength = function (AValue) {
      if (this.FMaxLength !== AValue) {
        this.FMaxLength = AValue;
        this.UpdateElementData();
      };
    };
    this.SetReadOnly = function (AValue) {
      if (this.FReadOnly !== AValue) {
        this.FReadOnly = AValue;
        this.UpdateElement();
      };
    };
    this.SetText = function (AValue) {
      this.FText = AValue;
      if (this.GetElementInputHandle() != null) {
        this.GetElementInputHandle().value = this.GetDisplayText();
        this.GetElementInputHandle().readOnly = this.IsReadOnly();
      };
    };
    this.SetTextHint = function (AValue) {
      this.FTextHint = AValue;
      this.UpdateElement();
    };
    this.CanPaste = function (AValue) {
      var Result = false;
      Result = true;
      return Result;
    };
    this.CanCut = function () {
      var Result = false;
      Result = true;
      return Result;
    };
    this.InitCSSLibrary = function (ALibrary) {
      if (ALibrary === pas["WEBLib.Controls"].TCSSLibrary.cssBootstrap) {
        this.SetElementFont(pas["WEBLib.Controls"].TElementFont.efCSS);
        this.SetElementClassName("form-control");
        this.SetHeightStyle(pas["WEBLib.Controls"].TSizeStyle.ssAuto);
      };
    };
    this.CreateInitialize = function () {
      $mod.TCustomInput.CreateInitialize.call(this);
      this.FAutoCompletion = $mod.TAutoCompletion.acOff;
      this.FEditType = $mod.TEditType.weString;
      this.FText = "";
      this.FCharCase = $mod.TEditCharCase.wecNormal;
      this.FMaxLength = 0;
      this.FReadOnly = false;
      this.FTextHint = "";
      this.FPasswordChar = "\x00";
      this.FSpellCheck = true;
      this.FAutoSelect = true;
      this.SetHeight(25);
    };
    this.Clear = function () {
      this.SetText("");
    };
    this.ClearSelection = function () {
      var s = "";
      s = this.GetText();
      this.SetText(pas.System.Copy(s,1,this.GetSelStart()) + pas.System.Copy(s,this.GetSelStart() + this.GetSelLength(),s.length));
    };
    this.Change = function () {
      if (this.GetElementHandle() != null) this.FText = this.GetElementInputHandle().value;
      if (this.FOnChange != null) this.FOnChange(this);
    };
    this.SelectAll = function () {
      if (this.GetElementInputHandle() != null) this.GetElementInputHandle().select();
    };
    this.CopyToClipboard = function () {
      var s = "";
      s = this.GetText();
      navigator.clipboard.writeText(s);
    };
    this.SetSelection = function (ASelStart, ASelLength) {
      var eh = null;
      this.FSelStart = ASelStart;
      this.FSelLength = ASelLength;
      eh = this.GetElementInputHandle();
      if (eh != null) {
        eh.setSelectionRange(ASelStart, ASelStart + ASelLength);
      };
    };
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
  });
  rtl.createClass(this,"TEdit",this.TCustomEdit,function () {
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
    var $r = this.$rtti;
    $r.addProperty("Alignment",2,pas.Classes.$rtti["TAlignment"],"FAlignment","SetAlignment");
    $r.addProperty("Align",2,pas["WEBLib.Controls"].$rtti["TAlign"],"FAlign","SetAlign",{Default: pas["WEBLib.Controls"].TAlign.alNone});
    $r.addProperty("AlignWithMargins",2,rtl.boolean,"FAlignWithMargins","SetAlignWithMargins",{Default: false});
    $r.addProperty("Anchors",2,pas["WEBLib.Controls"].$rtti["TAnchors"],"FAnchors","SetAnchors",{Default: rtl.createSet(pas["WEBLib.Controls"].TAnchorKind.akLeft,pas["WEBLib.Controls"].TAnchorKind.akTop)});
    $r.addProperty("AutoCompletion",2,$mod.$rtti["TAutoCompletion"],"FAutoCompletion","SetAutoCompletion",{Default: $mod.TAutoCompletion.acOff});
    $r.addProperty("AutoFocus",2,rtl.boolean,"FAutoFocus","SetAutoFocus",{Default: false});
    $r.addProperty("AutoSize",2,rtl.boolean,"FAutoSize","SetAutoSize",{Default: false});
    $r.addProperty("AutoSelect",2,rtl.boolean,"FAutoSelect","SetAutoSelect",{Default: true});
    $r.addProperty("BiDiMode",2,pas["WEBLib.Controls"].$rtti["TBiDiMode"],"FBiDiMode","SetBiDiMode",{Default: pas["WEBLib.Controls"].TBiDiMode.bdLeftToRight});
    $r.addProperty("BorderStyle",2,pas["WEBLib.Controls"].$rtti["TBorderStyle"],"FBorderStyle","SetBorderStyle",{Default: pas["WEBLib.Controls"].TBorderStyle.bsSingle});
    $r.addProperty("Center",0,pas["WEBLib.Controls"].$rtti["TCenter"],"FCenter","");
    $r.addProperty("CharCase",2,$mod.$rtti["TEditCharCase"],"FCharCase","SetCharCase",{Default: $mod.TEditCharCase.wecNormal});
    $r.addProperty("ChildOrder",2,rtl.longint,"FChildOrder","SetChildOrderEx",{Default: 0});
    $r.addProperty("Color",2,pas["WEBLib.Graphics"].$rtti["TColor"],"FColor","SetColor");
    $r.addProperty("DragMode",2,pas["WEBLib.Controls"].$rtti["TDragMode"],"FDragMode","SetDragMode",{Default: pas["WEBLib.Controls"].TDragMode.dmManual});
    $r.addProperty("EditType",2,$mod.$rtti["TEditType"],"FEditType","SetEditType",{Default: $mod.TEditType.weString});
    $r.addProperty("ElementClassName",2,pas["WEBLib.Controls"].$rtti["TElementClassName"],"FElementClassName","SetElementClassName");
    $r.addProperty("ElementID",3,pas["WEBLib.Controls"].$rtti["TElementID"],"GetID","SetID");
    $r.addProperty("ElementFont",2,pas["WEBLib.Controls"].$rtti["TElementFont"],"FElementFont","SetElementFont",{Default: pas["WEBLib.Controls"].TElementFont.efProperty});
    $r.addProperty("ElementPosition",2,pas["WEBLib.Controls"].$rtti["TElementPosition"],"FElementPosition","SetElementPosition",{Default: pas["WEBLib.Controls"].TElementPosition.epAbsolute});
    $r.addProperty("Enabled",2,rtl.boolean,"FEnabled","SetEnabled",{Default: true});
    $r.addProperty("Font",2,pas["WEBLib.Graphics"].$rtti["TFont"],"FFont","SetFont");
    $r.addProperty("Height",3,rtl.longint,"GetHeight","SetHeight");
    $r.addProperty("HeightPercent",2,rtl.double,"FHeightPercent","SetHeightPercent",{Default: 100});
    $r.addProperty("HeightStyle",2,pas["WEBLib.Controls"].$rtti["TSizeStyle"],"FHeightStyle","SetHeightStyle",{Default: pas["WEBLib.Controls"].TSizeStyle.ssAbsolute});
    $r.addProperty("Hint",2,rtl.string,"FHint","SetHint");
    $r.addProperty("HideSelection",2,rtl.boolean,"FHideSelection","SetHideSelection");
    $r.addProperty("Left",3,rtl.longint,"GetLeft","SetLeft");
    $r.addProperty("ParentFont",2,rtl.boolean,"FParentFont","SetParentFont",{Default: true});
    $r.addProperty("PasswordChar",2,rtl.char,"FPasswordChar","SetPasswordChar",{Default: "\x00"});
    $r.addProperty("Pattern",2,rtl.string,"FPattern","SetPattern");
    $r.addProperty("Margins",2,pas["WEBLib.Controls"].$rtti["TMargins"],"FMargins","SetMargins");
    $r.addProperty("MaxLength",2,rtl.longint,"FMaxLength","SetMaxLength",{Default: 0});
    $r.addProperty("PopupMenu",0,pas["WEBLib.Menus"].$rtti["TPopupMenu"],"FPopupMenu","FPopupMenu");
    $r.addProperty("ReadOnly",2,rtl.boolean,"FReadOnly","SetReadOnly",{Default: false});
    $r.addProperty("Required",2,rtl.boolean,"FRequired","SetRequired",{Default: false});
    $r.addProperty("RequiredText",0,rtl.string,"FRequiredText","FRequiredText");
    $r.addProperty("ShowFocus",2,rtl.boolean,"FShowFocus","SetShowFocus",{Default: false});
    $r.addProperty("ShowHint",2,rtl.boolean,"FShowHint","SetShowHint",{Default: false});
    $r.addProperty("SpellCheck",2,rtl.boolean,"FSpellCheck","SetSpellCheck",{Default: true});
    $r.addProperty("TabOrder",2,rtl.longint,"FTabOrder","SetTabOrder");
    $r.addProperty("TabStop",2,rtl.boolean,"FTabStop","SetTabStop",{Default: true});
    $r.addProperty("Text",3,rtl.string,"GetText","SetText");
    $r.addProperty("TextDirection",0,pas["WEBLib.Controls"].$rtti["TTextDirection"],"FTextDirection","FTextDirection",{Default: pas["WEBLib.Controls"].TTextDirection.tdDefault});
    $r.addProperty("TextHint",2,rtl.string,"FTextHint","SetTextHint");
    $r.addProperty("Top",3,rtl.longint,"GetTop","SetTop");
    $r.addProperty("Visible",2,rtl.boolean,"FVisible","SetVisible",{Default: true});
    $r.addProperty("Width",3,rtl.longint,"GetWidth","SetWidth");
    $r.addProperty("WidthPercent",2,rtl.double,"FWidthPercent","SetWidthPercent",{Default: 100});
    $r.addProperty("WidthStyle",2,pas["WEBLib.Controls"].$rtti["TSizeStyle"],"FWidthStyle","SetWidthStyle",{Default: pas["WEBLib.Controls"].TSizeStyle.ssAbsolute});
    $r.addProperty("OnChange",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnChange","FOnChange");
    $r.addProperty("OnClick",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnClick","FOnClick");
    $r.addProperty("OnDblClick",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnDblClick","FOnDblClick");
    $r.addProperty("OnKeyDown",0,pas["WEBLib.Controls"].$rtti["TKeyEvent"],"FOnKeyDown","FOnKeyDown");
    $r.addProperty("OnKeyPress",0,pas["WEBLib.Controls"].$rtti["TKeyPressEvent"],"FOnKeyPress","FOnKeyPress");
    $r.addProperty("OnKeyUp",0,pas["WEBLib.Controls"].$rtti["TKeyEvent"],"FOnKeyUp","FOnKeyUp");
    $r.addProperty("OnMouseDown",0,pas["WEBLib.Controls"].$rtti["TMouseEvent"],"FOnMouseDown","FOnMouseDown");
    $r.addProperty("OnMouseUp",0,pas["WEBLib.Controls"].$rtti["TMouseEvent"],"FOnMouseUp","FOnMouseUp");
    $r.addProperty("OnMouseMove",0,pas["WEBLib.Controls"].$rtti["TMouseMoveEvent"],"FOnMouseMove","FOnMouseMove");
    $r.addProperty("OnMouseLeave",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnMouseLeave","FOnMouseLeave");
    $r.addProperty("OnMouseEnter",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnMouseEnter","FOnMouseEnter");
    $r.addProperty("OnEnter",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnEnter","FOnEnter");
    $r.addProperty("OnExit",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnExit","FOnExit");
    $r.addProperty("OnDragDrop",0,pas["WEBLib.Controls"].$rtti["TDragDropEvent"],"FOnDragDrop","FOnDragDrop");
    $r.addProperty("OnDragOver",0,pas["WEBLib.Controls"].$rtti["TDragOverEvent"],"FOnDragOver","FOnDragOver");
    $r.addProperty("OnEndDrag",0,pas["WEBLib.Controls"].$rtti["TEndDragEvent"],"FonEndDrag","FonEndDrag");
    $r.addProperty("OnSearch",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnSearch","FOnSearch");
    $r.addProperty("OnStartDrag",0,pas["WEBLib.Controls"].$rtti["TStartDragEvent"],"FOnStartDrag","FOnStartDrag");
  });
  rtl.createClass(this,"TWebEdit",this.TEdit,function () {
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
  });
  rtl.createClass(this,"TSpinEdit",this.TCustomInput,function () {
    this.$init = function () {
      $mod.TCustomInput.$init.call(this);
      this.FIncrement = 0;
      this.FMaxValue = 0;
      this.FMinValue = 0;
      this.FValue = 0;
      this.FAutoSize = false;
      this.FOnChange = null;
      this.FReadOnly = false;
      this.FHandleChangePtr = null;
      this.FHandleInvalidPtr = null;
      this.FRequiredText = "";
      this.FRequired = false;
    };
    this.$final = function () {
      this.FOnChange = undefined;
      $mod.TCustomInput.$final.call(this);
    };
    this.GetText = function () {
      var Result = "";
      Result = pas.SysUtils.IntToStr(this.GetValue());
      return Result;
    };
    this.SetText = function (Value) {
      var i = 0;
      i = 0;
      if (pas.SysUtils.TryStrToInt(Value,{get: function () {
          return i;
        }, set: function (v) {
          i = v;
        }})) {
        this.SetValue(i)}
       else this.SetValue(0);
    };
    this.GetElementInputHandle = function () {
      var Result = null;
      Result = this.GetContainer();
      return Result;
    };
    this.SetReadOnly = function (Value) {
      if (this.FReadOnly !== Value) {
        this.FReadOnly = Value;
        this.UpdateElement();
      };
    };
    this.SetRequired = function (Value) {
      if (this.FRequired !== Value) {
        this.FRequired = Value;
        this.UpdateElement();
      };
    };
    this.KeyPress = function (Key) {
      if (!(Key.get().charCodeAt() in rtl.createSet(null,48,57))) {
        Key.set("\x00");
        this.PreventDefault();
        this.StopPropagation();
      };
      pas["WEBLib.Controls"].TControl.KeyPress.apply(this,arguments);
    };
    this.PersistinHTML = function () {
      this.GetElementInputHandle().setAttribute("value",pas.SysUtils.IntToStr(this.GetValue()));
    };
    this.GetInputType = function () {
      var Result = "";
      Result = "NUMBER";
      return Result;
    };
    this.UpdateElementData = function () {
      pas["WEBLib.Controls"].TControl.UpdateElementData.call(this);
      if (this.GetContainer() != null) {
        this.GetContainer().setAttribute("inputmode","numeric");
        this.GetContainer().setAttribute("pattern","[0-9]*");
        this.GetContainer().value = this.GetDisplayText();
        this.GetElementInputHandle().readOnly = this.IsReadOnly();
        if (this.FRequired) {
          this.GetElementInputHandle().setAttribute("required","")}
         else this.GetElementInputHandle().removeAttribute("required");
      };
    };
    this.GetValue = function () {
      var Result = 0;
      var s = "";
      Result = this.FValue;
      if (!(this.GetContainer() != null)) return Result;
      s = this.GetContainer().value;
      if (s !== "") Result = pas.SysUtils.StrToInt(s);
      return Result;
    };
    this.SetIncrement = function (AValue) {
      this.FIncrement = AValue;
      if (this.GetContainer() != null) this.GetContainer().setAttribute("step",pas.SysUtils.IntToStr(AValue));
    };
    this.SetMaxValue = function (AValue) {
      this.FMaxValue = AValue;
      if (this.GetContainer() != null) this.GetContainer().setAttribute("max",pas.SysUtils.IntToStr(AValue));
    };
    this.SetMinValue = function (AValue) {
      this.FMinValue = AValue;
      if (this.GetContainer() != null) this.GetContainer().setAttribute("min",pas.SysUtils.IntToStr(AValue));
    };
    this.SetValue = function (AValue) {
      this.FValue = AValue;
      this.UpdateElement();
    };
    this.DoHandleChange = function (Event) {
      var Result = false;
      this.Change();
      Result = true;
      if (this.FRequiredText !== "") {
        this.GetElementInputHandle().setCustomValidity("");
      };
      return Result;
    };
    this.DoHandleInvalid = function (Event) {
      var Result = false;
      this.GetElementInputHandle().setCustomValidity(this.FRequiredText);
      Result = true;
      return Result;
    };
    this.IsReadOnly = function () {
      var Result = false;
      Result = this.FReadOnly;
      return Result;
    };
    this.GetDisplayText = function () {
      var Result = "";
      Result = pas.SysUtils.IntToStr(this.FValue);
      return Result;
    };
    this.BindEvents = function () {
      pas["WEBLib.Controls"].TCustomControl.BindEvents.call(this);
      if (this.GetElementInputHandle() != null) {
        this.GetElementInputHandle().addEventListener("input",this.FHandleChangePtr);
        this.GetElementInputHandle().addEventListener("invalid",this.FHandleInvalidPtr);
      };
    };
    this.UnbindEvents = function () {
      pas["WEBLib.Controls"].TControl.UnbindEvents.call(this);
      if (this.GetElementInputHandle() != null) {
        this.GetElementInputHandle().removeEventListener("input",this.FHandleChangePtr);
        this.GetElementInputHandle().removeEventListener("invalid",this.FHandleInvalidPtr);
      };
    };
    this.Change = function () {
      this.FValue = this.GetValue();
      if (this.FOnChange != null) this.FOnChange(this);
    };
    this.ClearMethodPointers = function () {
      pas["WEBLib.Controls"].TControl.ClearMethodPointers.call(this);
      this.FHandleChangePtr = null;
      this.FHandleInvalidPtr = null;
    };
    this.GetMethodPointers = function () {
      pas["WEBLib.Controls"].TControl.GetMethodPointers.call(this);
      this.FHandleChangePtr = rtl.createCallback(this,"DoHandleChange");
      this.FHandleInvalidPtr = rtl.createCallback(this,"DoHandleInvalid");
    };
    this.InitCSSLibrary = function (ALibrary) {
      if (ALibrary === pas["WEBLib.Controls"].TCSSLibrary.cssBootstrap) {
        this.SetElementFont(pas["WEBLib.Controls"].TElementFont.efCSS);
        this.SetElementClassName("form-control");
        this.SetHeightStyle(pas["WEBLib.Controls"].TSizeStyle.ssAuto);
      };
    };
    this.CreateInitialize = function () {
      $mod.TCustomInput.CreateInitialize.call(this);
      this.FIncrement = 1;
      this.FMaxValue = 100;
      this.FMinValue = 0;
      this.SetShowFocus(true);
      this.SetHeight(25);
      this.AddControlStyle('input[type="number"]::-webkit-inner-spin-button { opacity: 1 !important; }');
    };
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
    var $r = this.$rtti;
    $r.addProperty("Align",2,pas["WEBLib.Controls"].$rtti["TAlign"],"FAlign","SetAlign",{Default: pas["WEBLib.Controls"].TAlign.alNone});
    $r.addProperty("AlignWithMargins",2,rtl.boolean,"FAlignWithMargins","SetAlignWithMargins",{Default: false});
    $r.addProperty("Anchors",2,pas["WEBLib.Controls"].$rtti["TAnchors"],"FAnchors","SetAnchors",{Default: rtl.createSet(pas["WEBLib.Controls"].TAnchorKind.akLeft,pas["WEBLib.Controls"].TAnchorKind.akTop)});
    $r.addProperty("AutoSize",0,rtl.boolean,"FAutoSize","FAutoSize");
    $r.addProperty("BiDiMode",2,pas["WEBLib.Controls"].$rtti["TBiDiMode"],"FBiDiMode","SetBiDiMode",{Default: pas["WEBLib.Controls"].TBiDiMode.bdLeftToRight});
    $r.addProperty("BorderStyle",2,pas["WEBLib.Controls"].$rtti["TBorderStyle"],"FBorderStyle","SetBorderStyle",{Default: pas["WEBLib.Controls"].TBorderStyle.bsSingle});
    $r.addProperty("ChildOrder",2,rtl.longint,"FChildOrder","SetChildOrderEx",{Default: 0});
    $r.addProperty("Color",2,pas["WEBLib.Graphics"].$rtti["TColor"],"FColor","SetColor");
    $r.addProperty("DragMode",2,pas["WEBLib.Controls"].$rtti["TDragMode"],"FDragMode","SetDragMode",{Default: pas["WEBLib.Controls"].TDragMode.dmManual});
    $r.addProperty("ElementClassName",2,pas["WEBLib.Controls"].$rtti["TElementClassName"],"FElementClassName","SetElementClassName");
    $r.addProperty("ElementID",3,pas["WEBLib.Controls"].$rtti["TElementID"],"GetID","SetID");
    $r.addProperty("ElementFont",2,pas["WEBLib.Controls"].$rtti["TElementFont"],"FElementFont","SetElementFont",{Default: pas["WEBLib.Controls"].TElementFont.efProperty});
    $r.addProperty("ElementPosition",2,pas["WEBLib.Controls"].$rtti["TElementPosition"],"FElementPosition","SetElementPosition",{Default: pas["WEBLib.Controls"].TElementPosition.epAbsolute});
    $r.addProperty("Enabled",2,rtl.boolean,"FEnabled","SetEnabled",{Default: true});
    $r.addProperty("Font",2,pas["WEBLib.Graphics"].$rtti["TFont"],"FFont","SetFont");
    $r.addProperty("Height",3,rtl.longint,"GetHeight","SetHeight");
    $r.addProperty("HeightPercent",2,rtl.double,"FHeightPercent","SetHeightPercent",{Default: 100});
    $r.addProperty("HeightStyle",2,pas["WEBLib.Controls"].$rtti["TSizeStyle"],"FHeightStyle","SetHeightStyle",{Default: pas["WEBLib.Controls"].TSizeStyle.ssAbsolute});
    $r.addProperty("Hint",2,rtl.string,"FHint","SetHint");
    $r.addProperty("Increment",2,rtl.longint,"FIncrement","SetIncrement");
    $r.addProperty("Left",3,rtl.longint,"GetLeft","SetLeft");
    $r.addProperty("Margins",2,pas["WEBLib.Controls"].$rtti["TMargins"],"FMargins","SetMargins");
    $r.addProperty("MaxValue",2,rtl.longint,"FMaxValue","SetMaxValue",{Default: 100});
    $r.addProperty("MinValue",2,rtl.longint,"FMinValue","SetMinValue",{Default: 0});
    $r.addProperty("ParentFont",2,rtl.boolean,"FParentFont","SetParentFont",{Default: true});
    $r.addProperty("ReadOnly",2,rtl.boolean,"FReadOnly","SetReadOnly",{Default: false});
    $r.addProperty("Required",2,rtl.boolean,"FRequired","SetRequired",{Default: false});
    $r.addProperty("RequiredText",0,rtl.string,"FRequiredText","FRequiredText");
    $r.addProperty("Role",3,rtl.string,"GetRole","SetRole");
    $r.addProperty("ShowFocus",2,rtl.boolean,"FShowFocus","SetShowFocus",{Default: false});
    $r.addProperty("ShowHint",2,rtl.boolean,"FShowHint","SetShowHint",{Default: false});
    $r.addProperty("TabStop",2,rtl.boolean,"FTabStop","SetTabStop",{Default: true});
    $r.addProperty("TabOrder",2,rtl.longint,"FTabOrder","SetTabOrder");
    $r.addProperty("TextDirection",0,pas["WEBLib.Controls"].$rtti["TTextDirection"],"FTextDirection","FTextDirection",{Default: pas["WEBLib.Controls"].TTextDirection.tdDefault});
    $r.addProperty("Value",3,rtl.longint,"GetValue","SetValue");
    $r.addProperty("Visible",2,rtl.boolean,"FVisible","SetVisible",{Default: true});
    $r.addProperty("Width",3,rtl.longint,"GetWidth","SetWidth");
    $r.addProperty("WidthPercent",2,rtl.double,"FWidthPercent","SetWidthPercent",{Default: 100});
    $r.addProperty("WidthStyle",2,pas["WEBLib.Controls"].$rtti["TSizeStyle"],"FWidthStyle","SetWidthStyle",{Default: pas["WEBLib.Controls"].TSizeStyle.ssAbsolute});
    $r.addProperty("OnChange",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnChange","FOnChange");
    $r.addProperty("OnClick",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnClick","FOnClick");
    $r.addProperty("OnDblClick",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnDblClick","FOnDblClick");
    $r.addProperty("OnKeyDown",0,pas["WEBLib.Controls"].$rtti["TKeyEvent"],"FOnKeyDown","FOnKeyDown");
    $r.addProperty("OnKeyPress",0,pas["WEBLib.Controls"].$rtti["TKeyPressEvent"],"FOnKeyPress","FOnKeyPress");
    $r.addProperty("OnKeyUp",0,pas["WEBLib.Controls"].$rtti["TKeyEvent"],"FOnKeyUp","FOnKeyUp");
    $r.addProperty("OnMouseDown",0,pas["WEBLib.Controls"].$rtti["TMouseEvent"],"FOnMouseDown","FOnMouseDown");
    $r.addProperty("OnMouseUp",0,pas["WEBLib.Controls"].$rtti["TMouseEvent"],"FOnMouseUp","FOnMouseUp");
    $r.addProperty("OnMouseMove",0,pas["WEBLib.Controls"].$rtti["TMouseMoveEvent"],"FOnMouseMove","FOnMouseMove");
    $r.addProperty("OnMouseLeave",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnMouseLeave","FOnMouseLeave");
    $r.addProperty("OnMouseEnter",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnMouseEnter","FOnMouseEnter");
    $r.addProperty("OnEnter",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnEnter","FOnEnter");
    $r.addProperty("OnExit",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnExit","FOnExit");
    $r.addProperty("OnDragDrop",0,pas["WEBLib.Controls"].$rtti["TDragDropEvent"],"FOnDragDrop","FOnDragDrop");
    $r.addProperty("OnDragOver",0,pas["WEBLib.Controls"].$rtti["TDragOverEvent"],"FOnDragOver","FOnDragOver");
    $r.addProperty("OnEndDrag",0,pas["WEBLib.Controls"].$rtti["TEndDragEvent"],"FonEndDrag","FonEndDrag");
    $r.addProperty("OnStartDrag",0,pas["WEBLib.Controls"].$rtti["TStartDragEvent"],"FOnStartDrag","FOnStartDrag");
  });
  rtl.createClass(this,"TWebSpinEdit",this.TSpinEdit,function () {
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
  });
  rtl.createClass(this,"TDateTimePicker",this.TCustomInput,function () {
    this.$init = function () {
      $mod.TCustomInput.$init.call(this);
      this.FDate = 0.0;
      this.FTime = 0.0;
      this.FKind = 0;
      this.FOnChange = null;
      this.FReadOnly = false;
      this.FElementCheck = null;
      this.FElementPicker = null;
      this.FShowCheckBox = false;
      this.FClickPtr$1 = null;
      this.FHandleChangePtr = null;
      this.FFocusPtr = null;
      this.FBlurPtr = null;
      this.FChecked = false;
      this.FShowSeconds = false;
      this.FAutoDropDown = false;
      this.FIsBootstrap = false;
      this.FMax = 0.0;
      this.FMin = 0.0;
    };
    this.$final = function () {
      this.FOnChange = undefined;
      this.FElementCheck = undefined;
      this.FElementPicker = undefined;
      $mod.TCustomInput.$final.call(this);
    };
    this.SetDate = function (AValue) {
      if (this.FDate !== AValue) {
        this.FDate = pas.System.Int(AValue);
        this.FTime = 0;
        this.UpdateElementData();
      };
    };
    this.GetDate = function () {
      var Result = 0.0;
      var str = "";
      Result = pas.System.Int(this.FDate) + pas.System.Frac(this.FTime);
      if (!(this.GetElementPicker() != null)) return Result;
      str = this.GetElementPicker().value;
      if (this.FKind === $mod.TDateTimeKind.dtkDate) {
        Result = pas["WEBLib.WebTools"].PickerDateToDate(str) + pas.System.Frac(this.FTime);
      } else Result = this.FTime;
      return Result;
    };
    this.SetTime = function (AValue) {
      if (this.FTime !== AValue) {
        this.FDate = 0;
        this.FTime = AValue;
        this.UpdateElementData();
      };
    };
    this.GetTime = function () {
      var Result = 0.0;
      var str = "";
      if (this.FDate > 0) {
        Result = pas.System.Frac(this.FTime) + pas.System.Int(this.FDate)}
       else Result = pas.System.Frac(this.FTime);
      if (!(this.GetElementPicker() != null)) return Result;
      str = this.GetElementPicker().value;
      if (this.FKind === $mod.TDateTimeKind.dtkTime) {
        Result = pas["WEBLib.WebTools"].PickerTimeToTime(str) + pas.System.Int(this.FDate);
      } else Result = this.FTime;
      return Result;
    };
    this.SetKind = function (AValue) {
      var dt = 0.0;
      this.FKind = AValue;
      if (this.GetElementPicker() != null) {
        dt = pas.System.Int(this.FDate) + pas.System.Frac(this.FTime);
        if (AValue === $mod.TDateTimeKind.dtkDate) {
          this.GetElementPicker().setAttribute("type","DATE")}
         else this.GetElementPicker().setAttribute("type","TIME");
        this.SetDate(dt);
        this.SetTime(dt);
        this.UpdateElement();
      };
    };
    this.SetText = function (Value) {
      if (!(this.GetElementPicker() != null)) return;
    };
    this.GetText = function () {
      var Result = "";
      Result = "";
      if (!(this.GetElementPicker() != null)) return Result;
      Result = this.GetElementPicker().value;
      return Result;
    };
    this.SetReadOnly = function (Value) {
      this.FReadOnly = Value;
      this.UpdateElement();
    };
    this.SetShowCheckBox = function (Value) {
      if (this.FShowCheckBox !== Value) {
        this.FShowCheckBox = Value;
        this.UpdateElementVisual();
      };
    };
    this.SetChecked = function (Value) {
      if (this.FChecked !== Value) {
        this.FChecked = Value;
        this.UpdateElementVisual();
      };
    };
    this.GetDateTime = function () {
      var Result = 0.0;
      Result = pas.System.Int(this.FDate) + pas.System.Frac(this.FTime);
      return Result;
    };
    this.SetDateTime = function (Value) {
      this.FDate = pas.System.Int(Value);
      this.FTime = pas.System.Frac(Value);
      this.UpdateElementData();
    };
    this.SetShowSeconds = function (Value) {
      if (this.FShowSeconds !== Value) {
        this.FShowSeconds = Value;
        this.UpdateElement();
      };
    };
    this.SetMax = function (Value) {
      if (this.FMax !== Value) {
        this.FMax = Value;
        this.UpdateElementData();
      };
    };
    this.SetMin = function (Value) {
      if (this.FMin !== Value) {
        this.FMin = Value;
        this.UpdateElementData();
      };
    };
    this.DoCheckClick = function (Event) {
      var Result = false;
      this.FChecked = this.FElementCheck.checked;
      if (this.FChecked) {
        this.GetElementPicker().removeAttribute("disabled")}
       else this.GetElementPicker().setAttribute("disabled","true");
      Result = true;
      return Result;
    };
    this.DoPickerFocus = function (Event) {
      var Result = false;
      if (!this.GetIsLinked() && !this.FIsBootstrap) this.GetElementHandle().style.setProperty("outline","auto");
      Result = true;
      this.DoEnter();
      return Result;
    };
    this.DoPickerBlur = function (Event) {
      var Result = false;
      if (!this.GetIsLinked() && !this.FIsBootstrap) this.GetElementHandle().style.setProperty("outline","none");
      Result = true;
      this.DoExit();
      return Result;
    };
    this.DoHandleChange = function (Event) {
      var Result = false;
      this.Change();
      Result = true;
      return Result;
    };
    this.HandleDoEnter = function (Event) {
      var Result = false;
      var el = null;
      Result = pas["WEBLib.Controls"].TControl.HandleDoEnter.call(this,Event);
      if (this.FAutoDropDown) {
        el = this.GetElementPicker();
        el.showPicker();
      };
      return Result;
    };
    this.GetElementBindHandle = function () {
      var Result = null;
      Result = this.GetElementPicker();
      return Result;
    };
    this.BindEvents = function () {
      pas["WEBLib.Controls"].TCustomControl.BindEvents.call(this);
      if (this.FElementCheck != null) this.FElementCheck.addEventListener("click",this.FClickPtr$1);
      if (this.GetElementPicker() != null) {
        this.GetElementPicker().addEventListener("input",this.FHandleChangePtr);
        this.GetElementPicker().addEventListener("focus",this.FFocusPtr);
        this.GetElementPicker().addEventListener("blur",this.FBlurPtr);
      };
    };
    this.UnbindEvents = function () {
      pas["WEBLib.Controls"].TControl.UnbindEvents.call(this);
      if (this.FElementCheck != null) this.FElementCheck.removeEventListener("click",this.FClickPtr$1);
      if (this.GetElementPicker() != null) {
        this.GetElementPicker().removeEventListener("input",this.FHandleChangePtr);
        this.GetElementPicker().removeEventListener("focus",this.FFocusPtr);
        this.GetElementPicker().removeEventListener("blur",this.FBlurPtr);
      };
    };
    this.UpdateElementData = function () {
      var el = null;
      var s = "";
      var i = 0;
      var d = 0;
      var m = 0;
      var y = 0;
      pas["WEBLib.Controls"].TControl.UpdateElementData.call(this);
      el = this.GetElementPicker();
      if (el != null) {
        el.setAttribute("step","1");
        var $tmp = this.FKind;
        if ($tmp === $mod.TDateTimeKind.dtkTime) {
          if (this.FShowSeconds) {
            s = pas.SysUtils.FormatDateTime("HH:MM:SS",this.FTime)}
           else s = pas.SysUtils.FormatDateTime("HH:MM",this.FTime);
          for (var $l = 1, $end = s.length; $l <= $end; $l++) {
            i = $l;
            if (!(s.charCodeAt(i - 1) in rtl.createSet(null,48,57))) s = rtl.setCharAt(s,i - 1,":");
          };
          el.value = s;
          if (!this.FShowSeconds) el.setAttribute("step","60");
        } else if ($tmp === $mod.TDateTimeKind.dtkDate) {
          if (this.FDate === 0) {
            el.value = ""}
           else {
            s = pas.SysUtils.FormatDateTime("yyyy-MM-dd",this.FDate);
            for (var $l1 = 1, $end1 = s.length; $l1 <= $end1; $l1++) {
              i = $l1;
              if (!(s.charCodeAt(i - 1) in rtl.createSet(null,48,57))) s = rtl.setCharAt(s,i - 1,"-");
            };
            el.value = s;
          };
        };
        if (this.FTabStop) {
          el.setAttribute("tabindex",pas.SysUtils.IntToStr(this.FTabOrder))}
         else el.setAttribute("tabindex","-1");
        if (this.FKind === $mod.TDateTimeKind.dtkDate) {
          if (this.FMin !== 0) {
            pas.SysUtils.DecodeDate(this.FMin,{get: function () {
                return y;
              }, set: function (v) {
                y = v;
              }},{get: function () {
                return m;
              }, set: function (v) {
                m = v;
              }},{get: function () {
                return d;
              }, set: function (v) {
                d = v;
              }});
            el.setAttribute("min",pas.SysUtils.Format("%d",pas.System.VarRecs(0,y)) + "-" + pas.SysUtils.Format("%.*d",pas.System.VarRecs(0,2,0,m)) + "-" + pas.SysUtils.Format("%.*d",pas.System.VarRecs(0,2,0,d)));
          } else el.removeAttribute("min");
          if (this.FMax !== 0) {
            pas.SysUtils.DecodeDate(this.FMax,{get: function () {
                return y;
              }, set: function (v) {
                y = v;
              }},{get: function () {
                return m;
              }, set: function (v) {
                m = v;
              }},{get: function () {
                return d;
              }, set: function (v) {
                d = v;
              }});
            el.setAttribute("max",pas.SysUtils.Format("%d",pas.System.VarRecs(0,y)) + "-" + pas.SysUtils.Format("%.*d",pas.System.VarRecs(0,2,0,m)) + "-" + pas.SysUtils.Format("%.*d",pas.System.VarRecs(0,2,0,d)));
          } else el.removeAttribute("max");
        };
        el.readOnly = this.IsReadOnly();
        if (this.IsEnabled()) {
          el.removeAttribute("disabled")}
         else el.setAttribute("disabled","");
      };
    };
    this.UpdateElementVisual = function () {
      var frm = null;
      $mod.TCustomInput.UpdateElementVisual.call(this);
      frm = pas["WEBLib.Forms"].GetParentForm(this);
      this.FIsBootstrap = (frm != null) && (frm.FCSSLibrary === pas["WEBLib.Controls"].TCSSLibrary.cssBootstrap) && (this.FElementClassName !== "");
      if ((this.GetElementPicker() != null) && (this.GetElementHandle() != null) && (this.FElementCheck != null)) {
        this.FElementCheck.setAttribute("type","CHECKBOX");
        if (this.FKind === $mod.TDateTimeKind.dtkDate) {
          this.GetElementPicker().setAttribute("type","DATE")}
         else this.GetElementPicker().setAttribute("type","TIME");
        if (this.FElementClassName === "") {
          this.GetElementPicker().style.setProperty("border","none");
          this.GetElementPicker().style.setProperty("border-width","0px");
          this.GetElementPicker().style.setProperty("outline","none");
          this.GetElementPicker().style.setProperty("font-family","inherit");
          this.GetElementPicker().style.setProperty("font-size","inherit");
          this.GetElementPicker().style.setProperty("width","100%");
          this.GetElementPicker().style.setProperty("height","100%");
        } else {
          if (this.FIsBootstrap) {
            this.GetElementPicker().setAttribute("class",this.FElementClassName);
            this.GetElementHandle().removeAttribute("class");
          };
        };
        if (!this.GetIsLinked()) {
          this.GetElementHandle().style.setProperty("padding","1px");
          this.GetElementHandle().style.setProperty("outline","none");
        };
        if ((this.FBorderStyle === pas["WEBLib.Controls"].TBorderStyle.bsSingle) && (this.FElementClassName === "")) {
          if (!this.FEnabled) {
            this.GetElementHandle().style.setProperty("border","1px silver solid")}
           else this.GetElementHandle().style.setProperty("border","1px solid");
          this.GetElementHandle().style.setProperty("border-radius","3px");
        } else {
          if (this.FIsBootstrap) {
            this.GetElementHandle().style.removeProperty("border");
            this.GetElementHandle().style.removeProperty("box-sizing");
          };
        };
        if (this.FElementCheck != null) {
          if (this.FShowCheckBox) {
            this.FElementCheck.style.setProperty("display","")}
           else this.FElementCheck.style.setProperty("display","none");
        };
        if (this.FShowCheckBox) {
          if (this.FChecked) {
            this.GetElementPicker().removeAttribute("disabled")}
           else this.GetElementPicker().setAttribute("disabled","true");
        };
      };
    };
    this.CreateElement = function () {
      var Result = null;
      Result = document.createElement("DIV");
      this.FElementCheck = document.createElement("INPUT");
      this.FElementPicker = document.createElement("INPUT");
      Result.appendChild(this.FElementCheck);
      Result.appendChild(this.FElementPicker);
      return Result;
    };
    this.GetInputType = function () {
      var Result = "";
      if (this.FKind === $mod.TDateTimeKind.dtkDate) {
        Result = "DATE"}
       else Result = "TIME";
      return Result;
    };
    this.Change = function () {
      this.FTime = this.GetTime();
      this.FDate = this.GetDate();
      if (this.FOnChange != null) this.FOnChange(this);
    };
    this.IsReadOnly = function () {
      var Result = false;
      Result = this.FReadOnly;
      return Result;
    };
    this.ClearMethodPointers = function () {
      pas["WEBLib.Controls"].TControl.ClearMethodPointers.call(this);
      this.FHandleChangePtr = null;
      this.FBlurPtr = null;
      this.FFocusPtr = null;
      this.FClickPtr$1 = null;
    };
    this.GetMethodPointers = function () {
      pas["WEBLib.Controls"].TControl.GetMethodPointers.call(this);
      this.FHandleChangePtr = rtl.createCallback(this,"DoHandleChange");
      this.FClickPtr$1 = rtl.createCallback(this,"DoCheckClick");
      this.FFocusPtr = rtl.createCallback(this,"DoPickerFocus");
      this.FBlurPtr = rtl.createCallback(this,"DoPickerBlur");
    };
    this.GetElementPicker = function () {
      var Result = null;
      if (this.GetIsLinked()) {
        Result = this.GetElementHandle()}
       else Result = this.FElementPicker;
      return Result;
    };
    this.SetEnabled = function (Value) {
      var el = null;
      pas["WEBLib.Controls"].TControl.SetEnabled.apply(this,arguments);
      el = this.GetElementPicker();
      if (el != null) {
        if (Value) {
          el.removeAttribute("disabled")}
         else el.setAttribute("disabled","");
      };
    };
    this.InitCSSLibrary = function (ALibrary) {
      if (ALibrary === pas["WEBLib.Controls"].TCSSLibrary.cssBootstrap) {
        this.SetElementFont(pas["WEBLib.Controls"].TElementFont.efCSS);
        this.SetElementClassName("form-control");
        this.SetHeightStyle(pas["WEBLib.Controls"].TSizeStyle.ssAuto);
      };
    };
    this.CreateInitialize = function () {
      $mod.TCustomInput.CreateInitialize.call(this);
      this.FMin = 0;
      this.FMax = 0;
      this.SetDate(pas.SysUtils.Now());
      this.SetShowFocus(true);
      if (pas.Classes.TComponentStateItem.csDesigning in this.FComponentState) {
        this.SetWidth(170);
        this.SetHeight(25);
      };
      this.FDate = pas.System.Int(pas.SysUtils.Now());
      this.FTime = 0;
      this.FReadOnly = false;
      this.FShowSeconds = true;
      this.FIsBootstrap = false;
    };
    this.Clear = function () {
      this.GetElementPicker().value = "";
    };
    this.SetFocus = function () {
      if (this.GetElementPicker() != null) {
        this.GetElementPicker().focus();
      };
    };
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
    var $r = this.$rtti;
    $r.addProperty("Align",2,pas["WEBLib.Controls"].$rtti["TAlign"],"FAlign","SetAlign",{Default: pas["WEBLib.Controls"].TAlign.alNone});
    $r.addProperty("AlignWithMargins",2,rtl.boolean,"FAlignWithMargins","SetAlignWithMargins",{Default: false});
    $r.addProperty("Anchors",2,pas["WEBLib.Controls"].$rtti["TAnchors"],"FAnchors","SetAnchors",{Default: rtl.createSet(pas["WEBLib.Controls"].TAnchorKind.akLeft,pas["WEBLib.Controls"].TAnchorKind.akTop)});
    $r.addProperty("AutoDropDown",0,rtl.boolean,"FAutoDropDown","FAutoDropDown",{Default: false});
    $r.addProperty("BorderStyle",2,pas["WEBLib.Controls"].$rtti["TBorderStyle"],"FBorderStyle","SetBorderStyle",{Default: pas["WEBLib.Controls"].TBorderStyle.bsSingle});
    $r.addProperty("Checked",2,rtl.boolean,"FChecked","SetChecked",{Default: false});
    $r.addProperty("ChildOrder",2,rtl.longint,"FChildOrder","SetChildOrderEx",{Default: 0});
    $r.addProperty("Color",2,pas["WEBLib.Graphics"].$rtti["TColor"],"FColor","SetColor");
    $r.addProperty("Date",3,pas.System.$rtti["TDate"],"GetDate","SetDate");
    $r.addProperty("DragMode",2,pas["WEBLib.Controls"].$rtti["TDragMode"],"FDragMode","SetDragMode",{Default: pas["WEBLib.Controls"].TDragMode.dmManual});
    $r.addProperty("ElementClassName",2,pas["WEBLib.Controls"].$rtti["TElementClassName"],"FElementClassName","SetElementClassName");
    $r.addProperty("ElementID",3,pas["WEBLib.Controls"].$rtti["TElementID"],"GetID","SetID");
    $r.addProperty("ElementFont",2,pas["WEBLib.Controls"].$rtti["TElementFont"],"FElementFont","SetElementFont",{Default: pas["WEBLib.Controls"].TElementFont.efProperty});
    $r.addProperty("ElementPosition",2,pas["WEBLib.Controls"].$rtti["TElementPosition"],"FElementPosition","SetElementPosition",{Default: pas["WEBLib.Controls"].TElementPosition.epAbsolute});
    $r.addProperty("Font",2,pas["WEBLib.Graphics"].$rtti["TFont"],"FFont","SetFont");
    $r.addProperty("Height",3,rtl.longint,"GetHeight","SetHeight");
    $r.addProperty("HeightPercent",2,rtl.double,"FHeightPercent","SetHeightPercent",{Default: 100});
    $r.addProperty("HeightStyle",2,pas["WEBLib.Controls"].$rtti["TSizeStyle"],"FHeightStyle","SetHeightStyle",{Default: pas["WEBLib.Controls"].TSizeStyle.ssAbsolute});
    $r.addProperty("Hint",2,rtl.string,"FHint","SetHint");
    $r.addProperty("Kind",2,$mod.$rtti["TDateTimeKind"],"FKind","SetKind");
    $r.addProperty("Left",3,rtl.longint,"GetLeft","SetLeft");
    $r.addProperty("Margins",2,pas["WEBLib.Controls"].$rtti["TMargins"],"FMargins","SetMargins");
    $r.addProperty("Max",2,pas.System.$rtti["TDateTime"],"FMax","SetMax");
    $r.addProperty("Min",2,pas.System.$rtti["TDateTime"],"FMin","SetMin");
    $r.addProperty("ParentFont",2,rtl.boolean,"FParentFont","SetParentFont",{Default: true});
    $r.addProperty("ReadOnly",2,rtl.boolean,"FReadOnly","SetReadOnly",{Default: false});
    $r.addProperty("Role",3,rtl.string,"GetRole","SetRole");
    $r.addProperty("ShowCheckBox",2,rtl.boolean,"FShowCheckBox","SetShowCheckBox",{Default: false});
    $r.addProperty("ShowFocus",2,rtl.boolean,"FShowFocus","SetShowFocus",{Default: false});
    $r.addProperty("ShowHint",2,rtl.boolean,"FShowHint","SetShowHint",{Default: false});
    $r.addProperty("ShowSeconds",2,rtl.boolean,"FShowSeconds","SetShowSeconds",{Default: true});
    $r.addProperty("TabStop",2,rtl.boolean,"FTabStop","SetTabStop",{Default: true});
    $r.addProperty("TabOrder",2,rtl.longint,"FTabOrder","SetTabOrder");
    $r.addProperty("Text",3,rtl.string,"GetText","SetText");
    $r.addProperty("TextDirection",0,pas["WEBLib.Controls"].$rtti["TTextDirection"],"FTextDirection","FTextDirection",{Default: pas["WEBLib.Controls"].TTextDirection.tdDefault});
    $r.addProperty("Time",3,pas.System.$rtti["TTime"],"GetTime","SetTime");
    $r.addProperty("Top",3,rtl.longint,"GetTop","SetTop");
    $r.addProperty("Visible",2,rtl.boolean,"FVisible","SetVisible",{Default: true});
    $r.addProperty("Width",3,rtl.longint,"GetWidth","SetWidth");
    $r.addProperty("WidthPercent",2,rtl.double,"FWidthPercent","SetWidthPercent",{Default: 100});
    $r.addProperty("WidthStyle",2,pas["WEBLib.Controls"].$rtti["TSizeStyle"],"FWidthStyle","SetWidthStyle",{Default: pas["WEBLib.Controls"].TSizeStyle.ssAbsolute});
    $r.addProperty("OnClick",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnClick","FOnClick");
    $r.addProperty("OnChange",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnChange","FOnChange");
    $r.addProperty("OnDblClick",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnDblClick","FOnDblClick");
    $r.addProperty("OnKeyDown",0,pas["WEBLib.Controls"].$rtti["TKeyEvent"],"FOnKeyDown","FOnKeyDown");
    $r.addProperty("OnKeyPress",0,pas["WEBLib.Controls"].$rtti["TKeyPressEvent"],"FOnKeyPress","FOnKeyPress");
    $r.addProperty("OnKeyUp",0,pas["WEBLib.Controls"].$rtti["TKeyEvent"],"FOnKeyUp","FOnKeyUp");
    $r.addProperty("OnMouseDown",0,pas["WEBLib.Controls"].$rtti["TMouseEvent"],"FOnMouseDown","FOnMouseDown");
    $r.addProperty("OnMouseUp",0,pas["WEBLib.Controls"].$rtti["TMouseEvent"],"FOnMouseUp","FOnMouseUp");
    $r.addProperty("OnMouseMove",0,pas["WEBLib.Controls"].$rtti["TMouseMoveEvent"],"FOnMouseMove","FOnMouseMove");
    $r.addProperty("OnMouseLeave",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnMouseLeave","FOnMouseLeave");
    $r.addProperty("OnMouseEnter",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnMouseEnter","FOnMouseEnter");
    $r.addProperty("OnEnter",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnEnter","FOnEnter");
    $r.addProperty("OnExit",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnExit","FOnExit");
    $r.addProperty("OnDragDrop",0,pas["WEBLib.Controls"].$rtti["TDragDropEvent"],"FOnDragDrop","FOnDragDrop");
    $r.addProperty("OnDragOver",0,pas["WEBLib.Controls"].$rtti["TDragOverEvent"],"FOnDragOver","FOnDragOver");
    $r.addProperty("OnEndDrag",0,pas["WEBLib.Controls"].$rtti["TEndDragEvent"],"FonEndDrag","FonEndDrag");
    $r.addProperty("OnStartDrag",0,pas["WEBLib.Controls"].$rtti["TStartDragEvent"],"FOnStartDrag","FOnStartDrag");
  });
  rtl.createClass(this,"TWebDateTimePicker",this.TDateTimePicker,function () {
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
  });
  rtl.createClass(this,"TButton",pas["WEBLib.Menus"].TWebCustomControl,function () {
    this.$init = function () {
      pas["WEBLib.Menus"].TWebCustomControl.$init.call(this);
      this.FModalResult = 0;
      this.FDefault = false;
      this.FCancel = false;
      this.FButtonType = "";
    };
    this.SetButtonType = function (Value) {
      this.FButtonType = Value;
      this.UpdateElementData();
    };
    this.SetDefault = function (Value) {
      this.FDefault = Value;
      if (this.FDefault) this.SetFocus();
    };
    this.CreateElement = function () {
      var Result = null;
      Result = document.createElement("BUTTON");
      Result.setAttribute("type","BUTTON");
      return Result;
    };
    this.SetCaption = function (AValue) {
      if (this.FCaption !== AValue) {
        pas["WEBLib.Controls"].TCustomControl.SetCaption.call(this,AValue);
        this.UpdateElementData();
      };
    };
    this.UpdateElementData = function () {
      var acc = "";
      pas["WEBLib.Controls"].TControl.UpdateElementData.call(this);
      if (this.GetIsLinked() && (this.FCaption === "")) return;
      if (this.GetElementHandle() != null) {
        if ((this.GetElementHandle().childElementCount === 0) || (pas.System.Pos("</",this.FCaption) > 0) || !this.GetIsLinked()) {
          this.GetElementHandle().innerHTML = pas["WEBLib.WebTools"].ProcessAccelerator(this.FCaption,{get: function () {
              return acc;
            }, set: function (v) {
              acc = v;
            }});
        };
        if (acc !== "") this.GetElementHandle().setAttribute("accesskey",acc);
        this.GetElementHandle().setAttribute("role","button");
        this.GetElementHandle().setAttribute("aria-label",this.FCaption);
        if (this.FButtonType !== "") {
          this.GetElementHandle().setAttribute("type",this.FButtonType)}
         else this.GetElementHandle().setAttribute("type","BUTTON");
      };
    };
    this.UpdateElementVisual = function () {
      var ecn = "";
      pas["WEBLib.Controls"].TCustomControl.UpdateElementVisual.call(this);
      if (this.GetElementHandle() != null) {
        this.GetElementHandle().style.removeProperty("outline");
        this.GetElementHandle().style.removeProperty("user-select");
        ecn = pas.SysUtils.UpperCase(this.FElementClassName);
        if ((ecn === "BTN") || (pas.System.Pos("BTN ",ecn) > 0)) ;
      };
    };
    this.HandleKeyPreview = function (Key) {
      pas["WEBLib.Controls"].TControl.HandleKeyPreview.apply(this,arguments);
      if (this.FDefault && (Key === 13)) {
        this.Click();
      };
      if (this.FCancel && (Key === 27)) {
        this.Click();
      };
    };
    this.InitCSSLibrary = function (ALibrary) {
      if (ALibrary === pas["WEBLib.Controls"].TCSSLibrary.cssBootstrap) {
        this.SetElementClassName("btn btn-light");
        this.SetElementFont(pas["WEBLib.Controls"].TElementFont.efCSS);
        this.SetHeightStyle(pas["WEBLib.Controls"].TSizeStyle.ssAuto);
      };
    };
    this.CreateInitialize = function () {
      pas["WEBLib.Controls"].TCustomControl.CreateInitialize.call(this);
      if ((pas.Classes.TComponentStateItem.csDesigning in this.FComponentState) && (this.FCaption === "")) this.SetCaption(this.FName);
      this.SetColor(-1);
      this.FModalResult = 0;
    };
    this.Click = function () {
      var frm = null;
      pas["WEBLib.Controls"].TControl.Click.call(this);
      if (this.FModalResult !== 0) {
        frm = pas["WEBLib.Forms"].GetParentForm(this);
        if (frm != null) frm.SetModalResult(this.FModalResult);
      };
    };
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
    var $r = this.$rtti;
    $r.addProperty("Align",2,pas["WEBLib.Controls"].$rtti["TAlign"],"FAlign","SetAlign",{Default: pas["WEBLib.Controls"].TAlign.alNone});
    $r.addProperty("AlignWithMargins",2,rtl.boolean,"FAlignWithMargins","SetAlignWithMargins",{Default: false});
    $r.addProperty("Anchors",2,pas["WEBLib.Controls"].$rtti["TAnchors"],"FAnchors","SetAnchors",{Default: rtl.createSet(pas["WEBLib.Controls"].TAnchorKind.akLeft,pas["WEBLib.Controls"].TAnchorKind.akTop)});
    $r.addProperty("BiDiMode",2,pas["WEBLib.Controls"].$rtti["TBiDiMode"],"FBiDiMode","SetBiDiMode",{Default: pas["WEBLib.Controls"].TBiDiMode.bdLeftToRight});
    $r.addProperty("BorderStyle",2,pas["WEBLib.Controls"].$rtti["TBorderStyle"],"FBorderStyle","SetBorderStyle",{Default: pas["WEBLib.Controls"].TBorderStyle.bsSingle});
    $r.addProperty("ButtonType",2,rtl.string,"FButtonType","SetButtonType");
    $r.addProperty("Caption",2,rtl.string,"FCaption","SetCaption");
    $r.addProperty("Cancel",0,rtl.boolean,"FCancel","FCancel",{Default: false});
    $r.addProperty("Center",0,pas["WEBLib.Controls"].$rtti["TCenter"],"FCenter","");
    $r.addProperty("ChildOrder",2,rtl.longint,"FChildOrder","SetChildOrderEx",{Default: 0});
    $r.addProperty("Color",2,pas["WEBLib.Graphics"].$rtti["TColor"],"FColor","SetColor");
    $r.addProperty("Default",2,rtl.boolean,"FDefault","SetDefault",{Default: false});
    $r.addProperty("DragMode",2,pas["WEBLib.Controls"].$rtti["TDragMode"],"FDragMode","SetDragMode",{Default: pas["WEBLib.Controls"].TDragMode.dmManual});
    $r.addProperty("ElementClassName",2,pas["WEBLib.Controls"].$rtti["TElementClassName"],"FElementClassName","SetElementClassName");
    $r.addProperty("ElementID",3,pas["WEBLib.Controls"].$rtti["TElementID"],"GetID","SetID");
    $r.addProperty("ElementFont",2,pas["WEBLib.Controls"].$rtti["TElementFont"],"FElementFont","SetElementFont",{Default: pas["WEBLib.Controls"].TElementFont.efProperty});
    $r.addProperty("ElementPosition",2,pas["WEBLib.Controls"].$rtti["TElementPosition"],"FElementPosition","SetElementPosition",{Default: pas["WEBLib.Controls"].TElementPosition.epAbsolute});
    $r.addProperty("Enabled",2,rtl.boolean,"FEnabled","SetEnabled",{Default: true});
    $r.addProperty("Font",2,pas["WEBLib.Graphics"].$rtti["TFont"],"FFont","SetFont");
    $r.addProperty("Height",3,rtl.longint,"GetHeight","SetHeight");
    $r.addProperty("HeightPercent",2,rtl.double,"FHeightPercent","SetHeightPercent",{Default: 100});
    $r.addProperty("HeightStyle",2,pas["WEBLib.Controls"].$rtti["TSizeStyle"],"FHeightStyle","SetHeightStyle",{Default: pas["WEBLib.Controls"].TSizeStyle.ssAbsolute});
    $r.addProperty("Hint",2,rtl.string,"FHint","SetHint");
    $r.addProperty("Left",3,rtl.longint,"GetLeft","SetLeft");
    $r.addProperty("Margins",2,pas["WEBLib.Controls"].$rtti["TMargins"],"FMargins","SetMargins");
    $r.addProperty("ModalResult",0,rtl.longint,"FModalResult","FModalResult",{Default: 0});
    $r.addProperty("PopupMenu",0,pas["WEBLib.Menus"].$rtti["TPopupMenu"],"FPopupMenu","FPopupMenu");
    $r.addProperty("Role",3,rtl.string,"GetRole","SetRole");
    $r.addProperty("ParentFont",2,rtl.boolean,"FParentFont","SetParentFont",{Default: true});
    $r.addProperty("ShowHint",2,rtl.boolean,"FShowHint","SetShowHint",{Default: false});
    $r.addProperty("TabOrder",2,rtl.longint,"FTabOrder","SetTabOrder");
    $r.addProperty("TabStop",2,rtl.boolean,"FTabStop","SetTabStop",{Default: true});
    $r.addProperty("TextDirection",0,pas["WEBLib.Controls"].$rtti["TTextDirection"],"FTextDirection","FTextDirection",{Default: pas["WEBLib.Controls"].TTextDirection.tdDefault});
    $r.addProperty("Top",3,rtl.longint,"GetTop","SetTop");
    $r.addProperty("Visible",2,rtl.boolean,"FVisible","SetVisible",{Default: true});
    $r.addProperty("Width",3,rtl.longint,"GetWidth","SetWidth");
    $r.addProperty("WidthPercent",2,rtl.double,"FWidthPercent","SetWidthPercent",{Default: 100});
    $r.addProperty("WidthStyle",2,pas["WEBLib.Controls"].$rtti["TSizeStyle"],"FWidthStyle","SetWidthStyle",{Default: pas["WEBLib.Controls"].TSizeStyle.ssAbsolute});
    $r.addProperty("OnClick",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnClick","FOnClick");
    $r.addProperty("OnKeyDown",0,pas["WEBLib.Controls"].$rtti["TKeyEvent"],"FOnKeyDown","FOnKeyDown");
    $r.addProperty("OnKeyPress",0,pas["WEBLib.Controls"].$rtti["TKeyPressEvent"],"FOnKeyPress","FOnKeyPress");
    $r.addProperty("OnKeyUp",0,pas["WEBLib.Controls"].$rtti["TKeyEvent"],"FOnKeyUp","FOnKeyUp");
    $r.addProperty("OnMouseDown",0,pas["WEBLib.Controls"].$rtti["TMouseEvent"],"FOnMouseDown","FOnMouseDown");
    $r.addProperty("OnMouseUp",0,pas["WEBLib.Controls"].$rtti["TMouseEvent"],"FOnMouseUp","FOnMouseUp");
    $r.addProperty("OnMouseMove",0,pas["WEBLib.Controls"].$rtti["TMouseMoveEvent"],"FOnMouseMove","FOnMouseMove");
    $r.addProperty("OnMouseLeave",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnMouseLeave","FOnMouseLeave");
    $r.addProperty("OnMouseEnter",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnMouseEnter","FOnMouseEnter");
    $r.addProperty("OnEnter",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnEnter","FOnEnter");
    $r.addProperty("OnExit",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnExit","FOnExit");
    $r.addProperty("OnDragDrop",0,pas["WEBLib.Controls"].$rtti["TDragDropEvent"],"FOnDragDrop","FOnDragDrop");
    $r.addProperty("OnDragOver",0,pas["WEBLib.Controls"].$rtti["TDragOverEvent"],"FOnDragOver","FOnDragOver");
    $r.addProperty("OnEndDrag",0,pas["WEBLib.Controls"].$rtti["TEndDragEvent"],"FonEndDrag","FonEndDrag");
    $r.addProperty("OnStartDrag",0,pas["WEBLib.Controls"].$rtti["TStartDragEvent"],"FOnStartDrag","FOnStartDrag");
  });
  rtl.createClass(this,"TWebButton",this.TButton,function () {
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
  });
  rtl.createClass(this,"TCheckBox",pas["WEBLib.Menus"].TWebCustomControl,function () {
    this.$init = function () {
      pas["WEBLib.Menus"].TWebCustomControl.$init.call(this);
      this.FChecked = false;
      this.FState = 0;
      this.FElementButtonClassName = "";
      this.FElementLabelClassName = "";
      this.FOnCheckClick = null;
      this.FAlignment = 0;
      this.FAllowGrayed = false;
    };
    this.$final = function () {
      this.FOnCheckClick = undefined;
      pas["WEBLib.Menus"].TWebCustomControl.$final.call(this);
    };
    this.SetAlignment = function (Value) {
      if (this.FAlignment !== Value) {
        this.FAlignment = Value;
        this.UpdateElementVisual();
      };
    };
    this.Loaded = function () {
      var lbl = null;
      pas["WEBLib.Controls"].TCustomControl.Loaded.call(this);
      if (this.GetContainer() != null) {
        if (!this.GetIsLinked()) {
          lbl = this.GetContainer().children.item(1);
          lbl.onclick = rtl.createSafeCallback(this,"HandleLabelClick");
        };
      };
    };
    this.UpdateElementData = function () {
      var chk = null;
      var btn = null;
      pas["WEBLib.Controls"].TControl.UpdateElementData.call(this);
      if (this.GetContainer() != null) {
        chk = this.GetCheckElement();
        if (chk != null) {
          chk.disabled = !this.IsEnabled();
          chk.checked = this.FChecked;
          chk.indeterminate = this.GetState() === $mod.TCheckBoxState.cbGrayed;
        };
        if (!this.GetIsLinked()) {
          if (this.FCaption !== "") this.GetContainer().lastElementChild.innerHTML = this.FCaption;
          this.GetElementHandle().setAttribute("tabindex","-1");
          btn = this.GetElementHandle().firstChild;
          btn.setAttribute("tabindex","-1");
        };
        if (this.FTabStop) this.GetContainer().setAttribute("tabindex",pas.SysUtils.IntToStr(this.FTabOrder));
      };
    };
    this.UpdateElementSize = function () {
      pas["WEBLib.Controls"].TControl.UpdateElementSize.call(this);
      if ((this.GetContainer() != null) && !this.GetIsLinked() && (this.FElementPosition === pas["WEBLib.Controls"].TElementPosition.epAbsolute)) {
        if (this.FHeightStyle !== pas["WEBLib.Controls"].TSizeStyle.ssAuto) {
          this.GetContainer().firstElementChild.style.setProperty("height","100%")}
         else this.GetContainer().firstElementChild.style.removeProperty("height");
      };
    };
    this.UpdateElementVisual = function () {
      var btn = null;
      var lbl = null;
      var frm = null;
      var isbs = false;
      pas["WEBLib.Controls"].TCustomControl.UpdateElementVisual.call(this);
      if (this.GetElementHandle() != null) {
        btn = this.GetElementHandle().firstChild;
        if (btn != null) {
          if (btn.style != null) btn.style.setProperty("margin-right","4px");
          if (this.FElementClassName === "") {
            btn.style.setProperty("vertical-align","middle");
            btn.style.setProperty("margin-top","0px");
          };
          if (this.FElementButtonClassName !== "") {
            btn.setAttribute("class",this.FElementButtonClassName)}
           else btn.removeAttribute("class");
        };
        lbl = this.GetElementHandle().lastElementChild;
        if (lbl != null) {
          if (this.FElementLabelClassName !== "") {
            lbl.setAttribute("class",this.FElementLabelClassName)}
           else lbl.removeAttribute("class");
        };
        if (!this.FTabStop || !this.FShowFocus || (this.FElementClassName !== "")) this.GetElementHandle().style.setProperty("outline","none");
        if (!this.GetIsLinked()) {
          this.GetElementHandle().style.setProperty("user-select","none");
          if (this.FElementPosition === pas["WEBLib.Controls"].TElementPosition.epAbsolute) {
            if (this.FElementButtonClassName === "") {
              if (this.FAlignment === pas.Classes.TAlignment.taRightJustify) {
                btn.style.removeProperty("float");
              } else {
                btn.style.setProperty("float","right");
              };
              if (this.FHeightStyle === pas["WEBLib.Controls"].TSizeStyle.ssAuto) {
                btn.style.removeProperty("height")}
               else if (this.FElementPosition === pas["WEBLib.Controls"].TElementPosition.epAbsolute) btn.style.setProperty("height","100%");
              btn.style.setProperty("vertical-align","middle");
              if (!$mod.TCheckGroup.isPrototypeOf(this.FParent)) {
                btn.style.setProperty("margin-top","0px");
                btn.style.setProperty("margin-bottom","0px");
              };
            };
            frm = pas["WEBLib.Forms"].GetParentForm(this);
            isbs = (frm != null) && (frm.FCSSLibrary === pas["WEBLib.Controls"].TCSSLibrary.cssBootstrap);
            if ((this.FElementLabelClassName === "") || isbs) {
              lbl = this.GetContainer().lastElementChild;
              lbl.style.setProperty("vertical-align","middle");
              lbl.style.setProperty("min-height","100%");
              lbl.style.setProperty("height","100%");
              lbl.style.setProperty("overflow","hidden");
              lbl.style.setProperty("display","inline-flex");
              lbl.style.setProperty("align-items","center");
            };
          };
        };
      };
    };
    this.PersistinHTML = function () {
      var cb = null;
      if (!(this.GetContainer() != null)) return;
      cb = this.GetCheckElement();
      if (cb.checked) {
        cb.setAttribute("checked","checked")}
       else cb.removeAttribute("checked");
    };
    this.CreateElement = function () {
      var Result = null;
      var btn = null;
      var lbl = null;
      Result = document.createElement("SPAN");
      btn = document.createElement("INPUT");
      lbl = document.createElement("SPAN");
      btn.setAttribute("TYPE","CHECKBOX");
      btn.setAttribute("id",this.GetID() + "ck");
      btn.setAttribute("role","checkbox");
      lbl.setAttribute("id",this.GetID() + "lbl");
      lbl.setAttribute("value",this.GetID());
      Result.appendChild(btn);
      Result.appendChild(lbl);
      rtl.asExt(btn,HTMLInputElement).onclick = rtl.createSafeCallback(this,"HandleCheckClick");
      return Result;
    };
    this.SetChecked = function (AValue) {
      this.FChecked = AValue;
      if (AValue) {
        this.FState = $mod.TCheckBoxState.cbChecked}
       else this.FState = $mod.TCheckBoxState.cbUnchecked;
      this.UpdateElement();
    };
    this.GetChecked = function () {
      var Result = false;
      var el = null;
      if (this.GetContainer() != null) {
        el = this.GetCheckElement();
        if (el != null) this.FChecked = el.checked;
      };
      Result = this.FChecked;
      return Result;
    };
    this.SetState = function (AValue) {
      this.FState = AValue;
      this.FChecked = this.FState === $mod.TCheckBoxState.cbChecked;
      this.UpdateElement();
    };
    this.GetState = function () {
      var Result = 0;
      Result = this.FState;
      return Result;
    };
    this.SetCaption = function (AValue) {
      if (this.FCaption !== AValue) {
        pas["WEBLib.Controls"].TCustomControl.SetCaption.call(this,AValue);
        if (this.GetContainer() != null) {
          if (this.GetIsLinked()) {
            if ((this.GetContainer().lastElementChild != null) && (this.GetContainer().lastElementChild.tagName === "SPAN")) this.GetContainer().lastElementChild.innerHTML = AValue;
          } else if (this.GetContainer().lastElementChild != null) this.GetContainer().lastElementChild.innerHTML = AValue;
        };
      };
    };
    this.SetEnabled = function (Value) {
      var el = null;
      pas["WEBLib.Controls"].TControl.SetEnabled.apply(this,arguments);
      if (this.GetContainer() != null) {
        el = this.GetCheckElement();
        if (el != null) el.disabled = !Value;
      };
    };
    this.HandleLabelClick = function (Event) {
      var Result = false;
      var chk = null;
      if ((this.GetContainer() != null) && this.FEnabled) {
        if (this.FAllowGrayed) {
          if (this.FState === $mod.TCheckBoxState.cbUnchecked) {
            this.FState = $mod.TCheckBoxState.cbGrayed}
           else if (this.FState === $mod.TCheckBoxState.cbGrayed) {
            this.FState = $mod.TCheckBoxState.cbChecked}
           else if (this.FState === $mod.TCheckBoxState.cbChecked) this.FState = $mod.TCheckBoxState.cbUnchecked;
          chk = this.GetCheckElement();
          chk.checked = this.FState === $mod.TCheckBoxState.cbChecked;
          chk.indeterminate = this.FState === $mod.TCheckBoxState.cbGrayed;
        } else {
          chk = this.GetCheckElement();
          chk.checked = !chk.checked;
        };
      };
      this.DoCheckClick();
      Result = true;
      return Result;
    };
    this.HandleCheckClick = function (Event) {
      var Result = false;
      var chk = null;
      if (this.FAllowGrayed && this.FEnabled) {
        if (this.FState === $mod.TCheckBoxState.cbUnchecked) {
          this.FState = $mod.TCheckBoxState.cbGrayed}
         else if (this.FState === $mod.TCheckBoxState.cbGrayed) {
          this.FState = $mod.TCheckBoxState.cbChecked}
         else if (this.FState === $mod.TCheckBoxState.cbChecked) this.FState = $mod.TCheckBoxState.cbUnchecked;
        chk = this.GetCheckElement();
        chk.checked = this.FState === $mod.TCheckBoxState.cbChecked;
        chk.indeterminate = this.FState === $mod.TCheckBoxState.cbGrayed;
      };
      this.DoCheckClick();
      Result = true;
      return Result;
    };
    this.Click = function () {
      pas["WEBLib.Controls"].TControl.Click.call(this);
      if (!this.FAllowGrayed) {
        this.FChecked = this.GetChecked();
        if (this.FChecked) {
          this.FState = $mod.TCheckBoxState.cbChecked}
         else this.FState = $mod.TCheckBoxState.cbUnchecked;
      };
      this.SetFocus();
    };
    this.DoCheckClick = function () {
      if (this.FOnCheckClick != null) this.FOnCheckClick(this);
    };
    this.GetCheckElement = function () {
      var Result = null;
      if (this.GetIsLinked()) {
        if (this.GetElementHandle().tagName === "INPUT") {
          Result = this.GetElementHandle()}
         else Result = this.GetContainer().firstElementChild;
      } else Result = this.GetContainer().firstElementChild;
      return Result;
    };
    this.KeyPress = function (ch) {
      var chk = null;
      pas["WEBLib.Controls"].TControl.KeyPress.apply(this,arguments);
      if (ch.get() === " ") {
        if ((this.GetContainer() != null) && !this.GetIsLinked()) {
          chk = this.GetCheckElement();
          chk.checked = !chk.checked;
        };
      };
    };
    this.LoadState = function (AState) {
      var cb = null;
      if (!(this.GetContainer() != null)) return;
      cb = this.GetCheckElement();
      cb.checked = AState === "1";
    };
    this.SaveState = function () {
      var Result = "";
      var cb = null;
      if (!(this.GetContainer() != null)) return Result;
      cb = this.GetCheckElement();
      if (cb.checked) {
        Result = "1"}
       else Result = "0";
      return Result;
    };
    this.InitCSSLibrary = function (ALibrary) {
      if (ALibrary === pas["WEBLib.Controls"].TCSSLibrary.cssBootstrap) {
        this.SetElementFont(pas["WEBLib.Controls"].TElementFont.efCSS);
        this.SetElementClassName("custom-control custom-checkbox");
        this.FElementButtonClassName = "custom-control-input";
        this.FElementLabelClassName = "custom-control-label";
        this.SetHeightStyle(pas["WEBLib.Controls"].TSizeStyle.ssAuto);
      };
    };
    this.CreateInitialize = function () {
      pas["WEBLib.Controls"].TCustomControl.CreateInitialize.call(this);
      this.SetColor(-1);
      this.FChecked = false;
      this.FState = $mod.TCheckBoxState.cbUnchecked;
      this.SetAlignment(pas.Classes.TAlignment.taRightJustify);
      if ((pas.Classes.TComponentStateItem.csDesigning in this.FComponentState) && (this.FCaption === "")) this.SetCaption(this.FName);
      this.SetShowFocus(true);
    };
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
    var $r = this.$rtti;
    $r.addProperty("Align",2,pas["WEBLib.Controls"].$rtti["TAlign"],"FAlign","SetAlign",{Default: pas["WEBLib.Controls"].TAlign.alNone});
    $r.addProperty("Alignment",2,pas.Classes.$rtti["TAlignment"],"FAlignment","SetAlignment",{Default: pas.Classes.TAlignment.taRightJustify});
    $r.addProperty("AlignWithMargins",2,rtl.boolean,"FAlignWithMargins","SetAlignWithMargins",{Default: false});
    $r.addProperty("AllowGrayed",0,rtl.boolean,"FAllowGrayed","FAllowGrayed",{Default: false});
    $r.addProperty("Anchors",2,pas["WEBLib.Controls"].$rtti["TAnchors"],"FAnchors","SetAnchors",{Default: rtl.createSet(pas["WEBLib.Controls"].TAnchorKind.akLeft,pas["WEBLib.Controls"].TAnchorKind.akTop)});
    $r.addProperty("Caption",2,rtl.string,"FCaption","SetCaption");
    $r.addProperty("Checked",3,rtl.boolean,"GetChecked","SetChecked",{Default: false});
    $r.addProperty("ChildOrder",2,rtl.longint,"FChildOrder","SetChildOrderEx",{Default: 0});
    $r.addProperty("Color",2,pas["WEBLib.Graphics"].$rtti["TColor"],"FColor","SetColor",{Default: -1});
    $r.addProperty("DragMode",2,pas["WEBLib.Controls"].$rtti["TDragMode"],"FDragMode","SetDragMode",{Default: pas["WEBLib.Controls"].TDragMode.dmManual});
    $r.addProperty("ElementClassName",2,pas["WEBLib.Controls"].$rtti["TElementClassName"],"FElementClassName","SetElementClassName");
    $r.addProperty("ElementButtonClassName",0,pas["WEBLib.Controls"].$rtti["TElementClassName"],"FElementButtonClassName","FElementButtonClassName");
    $r.addProperty("ElementLabelClassName",0,pas["WEBLib.Controls"].$rtti["TElementClassName"],"FElementLabelClassName","FElementLabelClassName");
    $r.addProperty("ElementID",3,pas["WEBLib.Controls"].$rtti["TElementID"],"GetID","SetID");
    $r.addProperty("ElementFont",2,pas["WEBLib.Controls"].$rtti["TElementFont"],"FElementFont","SetElementFont",{Default: pas["WEBLib.Controls"].TElementFont.efProperty});
    $r.addProperty("ElementPosition",2,pas["WEBLib.Controls"].$rtti["TElementPosition"],"FElementPosition","SetElementPosition",{Default: pas["WEBLib.Controls"].TElementPosition.epAbsolute});
    $r.addProperty("Enabled",2,rtl.boolean,"FEnabled","SetEnabled",{Default: true});
    $r.addProperty("Font",2,pas["WEBLib.Graphics"].$rtti["TFont"],"FFont","SetFont");
    $r.addProperty("Height",3,rtl.longint,"GetHeight","SetHeight");
    $r.addProperty("HeightPercent",2,rtl.double,"FHeightPercent","SetHeightPercent",{Default: 100});
    $r.addProperty("HeightStyle",2,pas["WEBLib.Controls"].$rtti["TSizeStyle"],"FHeightStyle","SetHeightStyle",{Default: pas["WEBLib.Controls"].TSizeStyle.ssAbsolute});
    $r.addProperty("Hint",2,rtl.string,"FHint","SetHint");
    $r.addProperty("Left",3,rtl.longint,"GetLeft","SetLeft");
    $r.addProperty("Margins",2,pas["WEBLib.Controls"].$rtti["TMargins"],"FMargins","SetMargins");
    $r.addProperty("ParentFont",2,rtl.boolean,"FParentFont","SetParentFont",{Default: true});
    $r.addProperty("PopupMenu",0,pas["WEBLib.Menus"].$rtti["TPopupMenu"],"FPopupMenu","FPopupMenu");
    $r.addProperty("Role",3,rtl.string,"GetRole","SetRole");
    $r.addProperty("ShowFocus",2,rtl.boolean,"FShowFocus","SetShowFocus",{Default: false});
    $r.addProperty("ShowHint",2,rtl.boolean,"FShowHint","SetShowHint",{Default: false});
    $r.addProperty("State",3,$mod.$rtti["TCheckBoxState"],"GetState","SetState",{Default: $mod.TCheckBoxState.cbUnchecked});
    $r.addProperty("TabOrder",2,rtl.longint,"FTabOrder","SetTabOrder");
    $r.addProperty("TabStop",2,rtl.boolean,"FTabStop","SetTabStop",{Default: true});
    $r.addProperty("Top",3,rtl.longint,"GetTop","SetTop");
    $r.addProperty("Visible",2,rtl.boolean,"FVisible","SetVisible",{Default: true});
    $r.addProperty("Width",3,rtl.longint,"GetWidth","SetWidth");
    $r.addProperty("WidthPercent",2,rtl.double,"FWidthPercent","SetWidthPercent",{Default: 100});
    $r.addProperty("WidthStyle",2,pas["WEBLib.Controls"].$rtti["TSizeStyle"],"FWidthStyle","SetWidthStyle",{Default: pas["WEBLib.Controls"].TSizeStyle.ssAbsolute});
    $r.addProperty("OnClick",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnClick","FOnClick");
    $r.addProperty("OnKeyDown",0,pas["WEBLib.Controls"].$rtti["TKeyEvent"],"FOnKeyDown","FOnKeyDown");
    $r.addProperty("OnKeyPress",0,pas["WEBLib.Controls"].$rtti["TKeyPressEvent"],"FOnKeyPress","FOnKeyPress");
    $r.addProperty("OnKeyUp",0,pas["WEBLib.Controls"].$rtti["TKeyEvent"],"FOnKeyUp","FOnKeyUp");
    $r.addProperty("OnMouseDown",0,pas["WEBLib.Controls"].$rtti["TMouseEvent"],"FOnMouseDown","FOnMouseDown");
    $r.addProperty("OnMouseUp",0,pas["WEBLib.Controls"].$rtti["TMouseEvent"],"FOnMouseUp","FOnMouseUp");
    $r.addProperty("OnMouseMove",0,pas["WEBLib.Controls"].$rtti["TMouseMoveEvent"],"FOnMouseMove","FOnMouseMove");
    $r.addProperty("OnMouseLeave",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnMouseLeave","FOnMouseLeave");
    $r.addProperty("OnMouseEnter",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnMouseEnter","FOnMouseEnter");
    $r.addProperty("OnEnter",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnEnter","FOnEnter");
    $r.addProperty("OnExit",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnExit","FOnExit");
    $r.addProperty("OnDragDrop",0,pas["WEBLib.Controls"].$rtti["TDragDropEvent"],"FOnDragDrop","FOnDragDrop");
    $r.addProperty("OnDragOver",0,pas["WEBLib.Controls"].$rtti["TDragOverEvent"],"FOnDragOver","FOnDragOver");
    $r.addProperty("OnEndDrag",0,pas["WEBLib.Controls"].$rtti["TEndDragEvent"],"FonEndDrag","FonEndDrag");
    $r.addProperty("OnStartDrag",0,pas["WEBLib.Controls"].$rtti["TStartDragEvent"],"FOnStartDrag","FOnStartDrag");
  });
  rtl.createClass(this,"TWebCheckBox",this.TCheckBox,function () {
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
  });
  rtl.createClass(this,"TRadioButton",pas["WEBLib.Menus"].TWebCustomControl,function () {
    this.$init = function () {
      pas["WEBLib.Menus"].TWebCustomControl.$init.call(this);
      this.FChecked = false;
      this.FGroupName = "";
      this.FElementButtonClassName = "";
      this.FElementLabelClassName = "";
    };
    this.PersistinHTML = function () {
      var rb = null;
      if (!(this.GetContainer() != null)) return;
      rb = this.GetRadioElement();
      if (rb.checked) {
        rb.setAttribute("checked","checked")}
       else rb.removeAttribute("checked");
    };
    this.CreateElement = function () {
      var Result = null;
      var btn = null;
      var lbl = null;
      Result = document.createElement("SPAN");
      btn = document.createElement("INPUT");
      lbl = document.createElement("SPAN");
      Result.addEventListener("click",rtl.createSafeCallback(this,"HandleLabelClick"));
      btn.setAttribute("TYPE","RADIO");
      btn.setAttribute("id",this.GetID() + "rd");
      btn.setAttribute("name",this.FGroupName);
      btn.setAttribute("role","radio");
      btn.setAttribute("tabindex","-1");
      btn.addEventListener("click",rtl.createSafeCallback(this,"HandleRadioClick"));
      lbl.setAttribute("id",this.GetID() + "lbl");
      lbl.setAttribute("value",this.GetID());
      Result.appendChild(btn);
      Result.appendChild(lbl);
      return Result;
    };
    this.SetChecked = function (AValue) {
      var el = null;
      this.FChecked = AValue;
      if (this.GetContainer() != null) {
        el = this.GetRadioElement();
        if (el != null) el.checked = AValue;
      };
    };
    this.GetChecked = function () {
      var Result = false;
      var el = null;
      Result = this.FChecked;
      if (this.GetContainer() != null) {
        el = this.GetRadioElement();
        if (el != null) Result = el.checked;
      };
      return Result;
    };
    this.SetEnabled = function (Value) {
      var el = null;
      pas["WEBLib.Controls"].TControl.SetEnabled.apply(this,arguments);
      if (this.GetContainer() != null) {
        el = this.GetRadioElement();
        if (el != null) el.disabled = !Value;
      };
    };
    this.SetCaption = function (AValue) {
      if (this.FCaption !== AValue) {
        pas["WEBLib.Controls"].TCustomControl.SetCaption.call(this,AValue);
        if ((this.GetContainer() != null) && !this.GetIsLinked()) this.GetContainer().lastElementChild.innerHTML = AValue;
      };
    };
    this.SetGroupName = function (AValue) {
      this.FGroupName = AValue;
      this.UpdateElementData();
    };
    this.HandleLabelClick = function (Event) {
      var Result = false;
      var rb = null;
      if ((this.GetContainer() != null) && this.FEnabled) {
        rb = this.GetRadioElement();
        rb.checked = true;
      };
      Result = true;
      return Result;
    };
    this.HandleRadioClick = function (Event) {
      var Result = false;
      this.SetFocus();
      Result = true;
      return Result;
    };
    this.UpdateElementSize = function () {
      pas["WEBLib.Controls"].TControl.UpdateElementSize.call(this);
      if ((this.GetContainer() != null) && !this.GetIsLinked()) {
        if (this.FHeightStyle !== pas["WEBLib.Controls"].TSizeStyle.ssAuto) {
          this.GetContainer().firstElementChild.style.setProperty("height","100%")}
         else this.GetContainer().firstElementChild.style.removeProperty("height");
      };
    };
    this.UpdateElementData = function () {
      var btn = null;
      pas["WEBLib.Controls"].TControl.UpdateElementData.call(this);
      if (this.GetContainer() != null) {
        if (this.GetIsLinked()) {
          this.GetElementHandle().setAttribute("name",this.FGroupName)}
         else {
          this.GetContainer().firstElementChild.setAttribute("name",this.FGroupName);
          btn = this.GetElementHandle().firstChild;
          btn.disabled = !this.FEnabled;
        };
        if (!this.GetIsLinked()) {
          if (this.FCaption !== "") this.GetContainer().lastElementChild.innerHTML = this.FCaption;
          this.GetElementHandle().setAttribute("tabindex","-1");
          if (this.FTabStop && (btn != null)) btn.setAttribute("tabindex","-1");
        };
        if (this.FTabStop) this.GetContainer().setAttribute("tabindex",pas.SysUtils.IntToStr(this.FTabOrder));
      };
    };
    this.UpdateElementVisual = function () {
      var btn = null;
      var lbl = null;
      var isbs = false;
      var frm = null;
      pas["WEBLib.Controls"].TCustomControl.UpdateElementVisual.call(this);
      if (this.GetElementHandle() != null) {
        if (!this.GetIsLinked()) {
          btn = this.GetElementHandle().firstChild;
          btn.style.setProperty("margin-right","4px");
          btn.style.setProperty("vertical-align","middle");
          btn.style.setProperty("margin-top","0px");
          if (btn != null) {
            if (this.FElementButtonClassName !== "") {
              btn.setAttribute("class",this.FElementButtonClassName)}
             else btn.removeAttribute("class");
          };
          lbl = this.GetElementHandle().lastElementChild;
          if (lbl != null) {
            if (this.FElementLabelClassName !== "") {
              lbl.setAttribute("class",this.FElementLabelClassName)}
             else lbl.removeAttribute("class");
          };
        };
        if (!this.FTabStop || !this.FShowFocus || (this.FElementClassName !== "")) this.GetElementHandle().style.setProperty("outline","none");
        if (!this.GetIsLinked()) {
          this.GetElementHandle().style.setProperty("user-select","none");
          this.GetElementHandle().style.setProperty("white-space","normal");
          if (this.FElementPosition === pas["WEBLib.Controls"].TElementPosition.epAbsolute) {
            if (this.FElementButtonClassName === "") {
              if (this.FHeightStyle !== pas["WEBLib.Controls"].TSizeStyle.ssAuto) {
                btn.style.setProperty("height","100%")}
               else btn.style.removeProperty("height");
              btn.style.setProperty("vertical-align","middle");
              if (!$mod.TRadioGroup.isPrototypeOf(this.FParent)) {
                btn.style.setProperty("margin-top","0px");
                btn.style.setProperty("margin-bottom","0px");
              };
            };
            frm = pas["WEBLib.Forms"].GetParentForm(this);
            isbs = (frm != null) && (frm.FCSSLibrary === pas["WEBLib.Controls"].TCSSLibrary.cssBootstrap);
            if ((this.FElementLabelClassName === "") || isbs) {
              lbl = this.GetContainer().lastElementChild;
              lbl.style.setProperty("vertical-align","middle");
              lbl.style.setProperty("min-height","100%");
              lbl.style.setProperty("height","100%");
              if (!$mod.TRadioGroup.isPrototypeOf(this.FParent)) lbl.style.setProperty("position","absolute");
              lbl.style.setProperty("overflow","hidden");
              lbl.style.setProperty("display","inline-flex");
              lbl.style.setProperty("align-items","center");
            };
          };
        };
      };
    };
    this.GetRadioElement = function () {
      var Result = null;
      if (this.GetIsLinked()) {
        Result = this.GetElementHandle()}
       else Result = this.GetContainer().firstElementChild;
      return Result;
    };
    this.KeyPress = function (ch) {
      var rb = null;
      pas["WEBLib.Controls"].TControl.KeyPress.apply(this,arguments);
      if (ch.get() === " ") {
        rb = this.GetRadioElement();
        rb.checked = true;
      };
    };
    this.LoadState = function (AState) {
      var rb = null;
      if (!(this.GetContainer() != null)) return;
      rb = this.GetRadioElement();
      rb.checked = AState === "1";
    };
    this.SaveState = function () {
      var Result = "";
      var rb = null;
      if (!(this.GetContainer() != null)) return Result;
      rb = this.GetRadioElement();
      if (rb.checked) {
        Result = "1"}
       else Result = "0";
      return Result;
    };
    this.InitCSSLibrary = function (ALibrary) {
      if (ALibrary === pas["WEBLib.Controls"].TCSSLibrary.cssBootstrap) {
        this.SetElementFont(pas["WEBLib.Controls"].TElementFont.efCSS);
        this.SetElementClassName("form-control");
        this.SetHeightStyle(pas["WEBLib.Controls"].TSizeStyle.ssAuto);
      };
    };
    this.CreateInitialize = function () {
      pas["WEBLib.Controls"].TCustomControl.CreateInitialize.call(this);
      this.SetColor(-1);
      if ((pas.Classes.TComponentStateItem.csDesigning in this.FComponentState) && (this.FCaption === "")) this.SetCaption(this.FName);
      this.FGroupName = "";
      this.SetShowFocus(true);
    };
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
    var $r = this.$rtti;
    $r.addProperty("Align",2,pas["WEBLib.Controls"].$rtti["TAlign"],"FAlign","SetAlign",{Default: pas["WEBLib.Controls"].TAlign.alNone});
    $r.addProperty("AlignWithMargins",2,rtl.boolean,"FAlignWithMargins","SetAlignWithMargins",{Default: false});
    $r.addProperty("Anchors",2,pas["WEBLib.Controls"].$rtti["TAnchors"],"FAnchors","SetAnchors",{Default: rtl.createSet(pas["WEBLib.Controls"].TAnchorKind.akLeft,pas["WEBLib.Controls"].TAnchorKind.akTop)});
    $r.addProperty("Caption",2,rtl.string,"FCaption","SetCaption");
    $r.addProperty("Checked",3,rtl.boolean,"GetChecked","SetChecked",{Default: false});
    $r.addProperty("ChildOrder",2,rtl.longint,"FChildOrder","SetChildOrderEx",{Default: 0});
    $r.addProperty("Color",2,pas["WEBLib.Graphics"].$rtti["TColor"],"FColor","SetColor",{Default: -1});
    $r.addProperty("DragMode",2,pas["WEBLib.Controls"].$rtti["TDragMode"],"FDragMode","SetDragMode",{Default: pas["WEBLib.Controls"].TDragMode.dmManual});
    $r.addProperty("ElementClassName",2,pas["WEBLib.Controls"].$rtti["TElementClassName"],"FElementClassName","SetElementClassName");
    $r.addProperty("ElementButtonClassName",0,pas["WEBLib.Controls"].$rtti["TElementClassName"],"FElementButtonClassName","FElementButtonClassName");
    $r.addProperty("ElementLabelClassName",0,pas["WEBLib.Controls"].$rtti["TElementClassName"],"FElementLabelClassName","FElementLabelClassName");
    $r.addProperty("ElementID",3,pas["WEBLib.Controls"].$rtti["TElementID"],"GetID","SetID");
    $r.addProperty("ElementFont",2,pas["WEBLib.Controls"].$rtti["TElementFont"],"FElementFont","SetElementFont",{Default: pas["WEBLib.Controls"].TElementFont.efProperty});
    $r.addProperty("ElementPosition",2,pas["WEBLib.Controls"].$rtti["TElementPosition"],"FElementPosition","SetElementPosition",{Default: pas["WEBLib.Controls"].TElementPosition.epAbsolute});
    $r.addProperty("Enabled",2,rtl.boolean,"FEnabled","SetEnabled",{Default: true});
    $r.addProperty("Font",2,pas["WEBLib.Graphics"].$rtti["TFont"],"FFont","SetFont");
    $r.addProperty("GroupName",2,rtl.string,"FGroupName","SetGroupName");
    $r.addProperty("Height",3,rtl.longint,"GetHeight","SetHeight");
    $r.addProperty("HeightPercent",2,rtl.double,"FHeightPercent","SetHeightPercent",{Default: 100});
    $r.addProperty("HeightStyle",2,pas["WEBLib.Controls"].$rtti["TSizeStyle"],"FHeightStyle","SetHeightStyle",{Default: pas["WEBLib.Controls"].TSizeStyle.ssAbsolute});
    $r.addProperty("Hint",2,rtl.string,"FHint","SetHint");
    $r.addProperty("Left",3,rtl.longint,"GetLeft","SetLeft");
    $r.addProperty("ParentFont",2,rtl.boolean,"FParentFont","SetParentFont",{Default: true});
    $r.addProperty("PopupMenu",0,pas["WEBLib.Menus"].$rtti["TPopupMenu"],"FPopupMenu","FPopupMenu");
    $r.addProperty("Role",3,rtl.string,"GetRole","SetRole");
    $r.addProperty("ShowFocus",2,rtl.boolean,"FShowFocus","SetShowFocus",{Default: false});
    $r.addProperty("ShowHint",2,rtl.boolean,"FShowHint","SetShowHint",{Default: false});
    $r.addProperty("TabOrder",2,rtl.longint,"FTabOrder","SetTabOrder");
    $r.addProperty("TabStop",2,rtl.boolean,"FTabStop","SetTabStop",{Default: true});
    $r.addProperty("Visible",2,rtl.boolean,"FVisible","SetVisible",{Default: true});
    $r.addProperty("Width",3,rtl.longint,"GetWidth","SetWidth");
    $r.addProperty("WidthPercent",2,rtl.double,"FWidthPercent","SetWidthPercent",{Default: 100});
    $r.addProperty("WidthStyle",2,pas["WEBLib.Controls"].$rtti["TSizeStyle"],"FWidthStyle","SetWidthStyle",{Default: pas["WEBLib.Controls"].TSizeStyle.ssAbsolute});
    $r.addProperty("OnClick",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnClick","FOnClick");
    $r.addProperty("OnDblClick",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnDblClick","FOnDblClick");
    $r.addProperty("OnKeyDown",0,pas["WEBLib.Controls"].$rtti["TKeyEvent"],"FOnKeyDown","FOnKeyDown");
    $r.addProperty("OnKeyPress",0,pas["WEBLib.Controls"].$rtti["TKeyPressEvent"],"FOnKeyPress","FOnKeyPress");
    $r.addProperty("OnKeyUp",0,pas["WEBLib.Controls"].$rtti["TKeyEvent"],"FOnKeyUp","FOnKeyUp");
    $r.addProperty("OnMouseDown",0,pas["WEBLib.Controls"].$rtti["TMouseEvent"],"FOnMouseDown","FOnMouseDown");
    $r.addProperty("OnMouseUp",0,pas["WEBLib.Controls"].$rtti["TMouseEvent"],"FOnMouseUp","FOnMouseUp");
    $r.addProperty("OnMouseMove",0,pas["WEBLib.Controls"].$rtti["TMouseMoveEvent"],"FOnMouseMove","FOnMouseMove");
    $r.addProperty("OnMouseLeave",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnMouseLeave","FOnMouseLeave");
    $r.addProperty("OnMouseEnter",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnMouseEnter","FOnMouseEnter");
    $r.addProperty("OnEnter",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnEnter","FOnEnter");
    $r.addProperty("OnExit",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnExit","FOnExit");
    $r.addProperty("OnDragDrop",0,pas["WEBLib.Controls"].$rtti["TDragDropEvent"],"FOnDragDrop","FOnDragDrop");
    $r.addProperty("OnDragOver",0,pas["WEBLib.Controls"].$rtti["TDragOverEvent"],"FOnDragOver","FOnDragOver");
    $r.addProperty("OnEndDrag",0,pas["WEBLib.Controls"].$rtti["TEndDragEvent"],"FonEndDrag","FonEndDrag");
    $r.addProperty("OnStartDrag",0,pas["WEBLib.Controls"].$rtti["TStartDragEvent"],"FOnStartDrag","FOnStartDrag");
  });
  rtl.createClass(this,"TWebRadioButton",this.TRadioButton,function () {
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
  });
  rtl.createClass(this,"TListBox",pas["WEBLib.Menus"].TWebCustomControl,function () {
    this.$init = function () {
      pas["WEBLib.Menus"].TWebCustomControl.$init.call(this);
      this.FItems = null;
      this.FItemIndex = 0;
      this.FMultiSelect = false;
      this.FSelected = null;
      this.FItemHeight = 0;
      this.FSorted = false;
      this.FOnChange = null;
      this.FHandleChangePtr = null;
      this.FElementItemClassName = "";
    };
    this.$final = function () {
      this.FItems = undefined;
      this.FSelected = undefined;
      this.FOnChange = undefined;
      pas["WEBLib.Menus"].TWebCustomControl.$final.call(this);
    };
    this.SetItemHeight = function (Value) {
      this.FItemHeight = Value;
    };
    this.SetSorted = function (Value) {
      this.FSorted = Value;
      this.FItems.SetSorted(Value);
    };
    this.GetCount = function () {
      var Result = 0;
      Result = this.FItems.GetCount();
      return Result;
    };
    this.GetElementSelectHandle = function () {
      var Result = null;
      Result = this.GetContainer();
      return Result;
    };
    this.GetSelCount = function () {
      var Result = 0;
      var i = 0;
      Result = 0;
      if (this.GetContainer() != null) {
        for (var $l = 0, $end = this.FItems.GetCount() - 1; $l <= $end; $l++) {
          i = $l;
          if (this.GetContainer().options.item(i).selected) Result += 1;
        };
      };
      return Result;
    };
    this.GetValues = function (AIndex) {
      var Result = "";
      var opt = null;
      var el = null;
      if ((AIndex >= 0) && (AIndex < this.FItems.GetCount())) {
        el = this.GetElementHandle();
        opt = el.options.item(AIndex);
        Result = opt.getAttribute("value");
      };
      return Result;
    };
    this.SetValues = function (AIndex, Value) {
      var opt = null;
      var el = null;
      if ((AIndex >= 0) && (AIndex < this.FItems.GetCount())) {
        el = this.GetElementHandle();
        opt = el.options.item(AIndex);
        opt.setAttribute("value",Value);
      };
    };
    this.DoHandleChange = function (Event) {
      var Result = false;
      this.Change();
      Result = true;
      return Result;
    };
    this.DoItemsChange = function (Sender) {
      this.DoUpdateList();
    };
    this.DoUpdateList = function () {
      var i = 0;
      var j = 0;
      var opt = null;
      var k = "";
      var v = "";
      var s = "";
      if (!(this.GetContainer() != null)) return;
      if (this.IsUpdating()) return;
      if (this.GetElementHandle().tagName !== "SELECT") return;
      for (var $l = this.GetContainer().options.length - 1; $l >= 0; $l--) {
        i = $l;
        this.GetContainer().remove(i);
      };
      for (var $l1 = 0, $end = this.FItems.GetCount() - 1; $l1 <= $end; $l1++) {
        i = $l1;
        s = this.FItems.Get(i);
        k = s;
        v = s;
        j = pas.System.Pos(this.FItems.GetNameValueSeparator(),s);
        if (j > 0) {
          v = pas.System.Copy(s,1,j - 1);
          k = pas.System.Copy(s,j + 1,0xFFFF);
        } else k = "";
        opt = new Option(v);
        if (k !== "") opt.setAttribute("value",k);
        opt.setAttribute("role","listitem");
        if (this.FElementItemClassName !== "") opt.setAttribute("class",this.FElementItemClassName);
        if (this.FDragMode === pas["WEBLib.Controls"].TDragMode.dmAutomatic) opt.setAttribute("draggable","true");
        this.GetContainer().add(opt);
      };
      this.UpdateElementData();
    };
    this.PersistinHTML = function () {
      var i = 0;
      if (!(this.GetContainer() != null)) return;
      if (this.GetElementHandle().tagName !== "SELECT") return;
      for (var $l = 0, $end = this.GetContainer().options.length - 1; $l <= $end; $l++) {
        i = $l;
        if (this.GetContainer().options.item(i).selected) {
          this.GetContainer().options.item(i).setAttribute("selected","selected")}
         else this.GetContainer().options.item(i).removeAttribute("selected");
      };
    };
    this.GetItemIndex = function () {
      var Result = 0;
      Result = this.FItemIndex;
      if (this.GetContainer() != null) Result = this.GetContainer().selectedIndex;
      return Result;
    };
    this.CreateElement = function () {
      var Result = null;
      Result = document.createElement("SELECT");
      Result.setAttribute("Size","2");
      return Result;
    };
    this.GetSelected = function (AIndex) {
      var Result = false;
      if (AIndex < this.FSelected.GetCount()) {
        Result = !(this.FSelected.Get(AIndex) == false)}
       else Result = false;
      if (this.GetElementHandle().tagName !== "SELECT") return Result;
      if ((this.GetContainer() != null) && (AIndex < this.GetContainer().options.length)) Result = this.GetContainer().options.item(AIndex).selected;
      return Result;
    };
    this.SetSelected = function (AIndex, AValue) {
      while (AIndex >= this.FSelected.GetCount()) this.FSelected.Add(false);
      this.FSelected.Put(AIndex,AValue);
      if (this.GetContainer() != null) {
        this.GetContainer().options.item(AIndex).selected = AValue;
      };
    };
    this.SetItems = function (AItems) {
      this.FItems.Assign(AItems);
    };
    this.SetItemIndex = function (AIndex) {
      if (this.FItemIndex !== AIndex) {
        this.FItemIndex = AIndex;
        this.UpdateElement();
      };
    };
    this.SetMultiSelect = function (AValue) {
      this.FMultiSelect = AValue;
      if (this.GetContainer() != null) this.GetContainer().multiple = AValue;
    };
    this.Loaded = function () {
      pas["WEBLib.Controls"].TCustomControl.Loaded.call(this);
      this.DoUpdateList();
      this.UpdateElement();
    };
    this.UpdateElementData = function () {
      var i = 0;
      var b = false;
      pas["WEBLib.Controls"].TControl.UpdateElementData.call(this);
      if (this.GetElementSelectHandle() != null) {
        this.GetElementSelectHandle().style.setProperty("overflow","auto");
        if (!this.FMultiSelect) {
          this.GetElementSelectHandle().selectedIndex = this.FItemIndex}
         else {
          for (var $l = 0, $end = this.FItems.GetCount() - 1; $l <= $end; $l++) {
            i = $l;
            if (this.FSelected.GetCount() > i) {
              b = !(this.FSelected.Get(i) == false);
              if (this.GetContainer() != null) this.GetContainer().options.item(i).selected = b;
            };
          };
        };
      };
    };
    this.UpdateElementVisual = function () {
      pas["WEBLib.Controls"].TCustomControl.UpdateElementVisual.call(this);
      if (this.GetElementSelectHandle() != null) {
        this.GetElementSelectHandle().style.setProperty("overflow","auto");
        this.GetElementSelectHandle().setAttribute("role","listbox");
        this.GetElementSelectHandle().setAttribute("aria-busy","true");
      };
    };
    this.UpdateParent = function () {
      pas["WEBLib.Controls"].TControl.UpdateParent.call(this);
      this.DoUpdateList();
    };
    this.BindEvents = function () {
      pas["WEBLib.Controls"].TCustomControl.BindEvents.call(this);
      if (this.GetElementHandle() != null) {
        this.GetElementHandle().addEventListener("change",this.FHandleChangePtr);
      };
    };
    this.UnbindEvents = function () {
      pas["WEBLib.Controls"].TControl.UnbindEvents.call(this);
      if (this.GetElementHandle() != null) {
        this.GetElementHandle().removeEventListener("change",this.FHandleChangePtr);
      };
    };
    this.Change = function () {
      if (this.FOnChange != null) this.FOnChange(this);
    };
    this.SaveState = function () {
      var Result = "";
      var i = 0;
      var s = "";
      for (var $l = 0, $end = this.FItems.GetCount() - 1; $l <= $end; $l++) {
        i = $l;
        if (this.GetSelected(i)) {
          s = s + ",1"}
         else s = s + ",0";
      };
      pas.System.Delete({get: function () {
          return s;
        }, set: function (v) {
          s = v;
        }},1,1);
      Result = s;
      return Result;
    };
    this.LoadState = function (AState) {
      var sl = null;
      var i = 0;
      sl = pas.Classes.TStringList.$create("Create$1");
      sl.SetDelimiter(",");
      sl.SetCommaText(AState);
      for (var $l = 0, $end = sl.GetCount() - 1; $l <= $end; $l++) {
        i = $l;
        this.SetSelected(i,sl.Get(i) === "1");
      };
      sl = rtl.freeLoc(sl);
    };
    this.EnableDrag = function () {
      var I = 0;
      if (!(this.GetContainer() != null)) return;
      for (var $l = 0, $end = this.GetContainer().options.length - 1; $l <= $end; $l++) {
        I = $l;
        this.GetContainer().options.item(I).setAttribute("draggable","true");
      };
    };
    this.DisableDrag = function () {
      var I = 0;
      if (!(this.GetContainer() != null)) return;
      for (var $l = 0, $end = this.GetContainer().options.length - 1; $l <= $end; $l++) {
        I = $l;
        this.GetContainer().options.item(I).setAttribute("draggable","false");
      };
    };
    this.ClearMethodPointers = function () {
      pas["WEBLib.Controls"].TControl.ClearMethodPointers.call(this);
      this.FHandleChangePtr = null;
    };
    this.GetMethodPointers = function () {
      pas["WEBLib.Controls"].TControl.GetMethodPointers.call(this);
      this.FHandleChangePtr = rtl.createCallback(this,"DoHandleChange");
    };
    this.InitCSSLibrary = function (ALibrary) {
      if (ALibrary === pas["WEBLib.Controls"].TCSSLibrary.cssBootstrap) {
        this.SetElementFont(pas["WEBLib.Controls"].TElementFont.efCSS);
        this.SetElementClassName("form-control");
      };
    };
    this.CreateInitialize = function () {
      pas["WEBLib.Controls"].TCustomControl.CreateInitialize.call(this);
      this.FItems = pas.Classes.TStringList.$create("Create$1");
      this.FItems.SetSkipLastLineBreak(true);
      this.FItems.FOnChange = rtl.createCallback(this,"DoItemsChange");
      this.FMultiSelect = false;
      this.FSelected = pas.Classes.TList.$create("Create$1");
      this.FItemIndex = -1;
      this.SetShowFocus(true);
      if (pas.Classes.TComponentStateItem.csDesigning in this.FComponentState) {
        this.SetWidth(160);
        this.SetHeight(180);
      };
    };
    this.Destroy = function () {
      rtl.free(this,"FItems");
      rtl.free(this,"FSelected");
      pas["WEBLib.Controls"].TCustomControl.Destroy.call(this);
    };
    this.EndUpdate = function () {
      pas["WEBLib.Controls"].TCustomControl.EndUpdate.call(this);
      this.DoUpdateList();
    };
    this.ClearSelection = function () {
      var i = 0;
      this.SetItemIndex(-1);
      if (!(this.GetContainer() != null)) return;
      if (this.GetElementHandle().tagName !== "SELECT") return;
      for (var $l = 0, $end = this.GetContainer().options.length - 1; $l <= $end; $l++) {
        i = $l;
        this.GetContainer().options.item(i).selected = false;
      };
    };
    this.SelectAll = function () {
      var i = 0;
      if (!(this.GetContainer() != null)) return;
      if (this.GetElementHandle().tagName !== "SELECT") return;
      for (var $l = 0, $end = this.GetContainer().options.length - 1; $l <= $end; $l++) {
        i = $l;
        this.SetSelected(i,true);
        this.GetContainer().options.item(i).selected = true;
      };
    };
    this.DeleteSelected = function () {
      var i = 0;
      this.FItems.BeginUpdate();
      for (var $l = this.FItems.GetCount() - 1; $l >= 0; $l--) {
        i = $l;
        if (this.GetSelected(i)) this.FItems.Delete(i);
      };
      this.FItems.EndUpdate();
    };
    this.AddItem = function (Item, AObject) {
      this.FItems.AddObject(Item,AObject);
    };
    this.Clear = function () {
      this.BeginUpdate();
      this.FItems.Clear();
      this.EndUpdate();
    };
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
    var $r = this.$rtti;
    $r.addProperty("Align",2,pas["WEBLib.Controls"].$rtti["TAlign"],"FAlign","SetAlign",{Default: pas["WEBLib.Controls"].TAlign.alNone});
    $r.addProperty("AlignWithMargins",2,rtl.boolean,"FAlignWithMargins","SetAlignWithMargins",{Default: false});
    $r.addProperty("Anchors",2,pas["WEBLib.Controls"].$rtti["TAnchors"],"FAnchors","SetAnchors",{Default: rtl.createSet(pas["WEBLib.Controls"].TAnchorKind.akLeft,pas["WEBLib.Controls"].TAnchorKind.akTop)});
    $r.addProperty("BiDiMode",2,pas["WEBLib.Controls"].$rtti["TBiDiMode"],"FBiDiMode","SetBiDiMode",{Default: pas["WEBLib.Controls"].TBiDiMode.bdLeftToRight});
    $r.addProperty("BorderStyle",2,pas["WEBLib.Controls"].$rtti["TBorderStyle"],"FBorderStyle","SetBorderStyle",{Default: pas["WEBLib.Controls"].TBorderStyle.bsSingle});
    $r.addProperty("ChildOrder",2,rtl.longint,"FChildOrder","SetChildOrderEx",{Default: 0});
    $r.addProperty("Color",2,pas["WEBLib.Graphics"].$rtti["TColor"],"FColor","SetColor");
    $r.addProperty("DragMode",2,pas["WEBLib.Controls"].$rtti["TDragMode"],"FDragMode","SetDragMode",{Default: pas["WEBLib.Controls"].TDragMode.dmManual});
    $r.addProperty("Font",2,pas["WEBLib.Graphics"].$rtti["TFont"],"FFont","SetFont");
    $r.addProperty("ElementClassName",2,pas["WEBLib.Controls"].$rtti["TElementClassName"],"FElementClassName","SetElementClassName");
    $r.addProperty("ElementItemClassName",0,rtl.string,"FElementItemClassName","FElementItemClassName");
    $r.addProperty("ElementID",3,pas["WEBLib.Controls"].$rtti["TElementID"],"GetID","SetID");
    $r.addProperty("ElementFont",2,pas["WEBLib.Controls"].$rtti["TElementFont"],"FElementFont","SetElementFont",{Default: pas["WEBLib.Controls"].TElementFont.efProperty});
    $r.addProperty("ElementPosition",2,pas["WEBLib.Controls"].$rtti["TElementPosition"],"FElementPosition","SetElementPosition",{Default: pas["WEBLib.Controls"].TElementPosition.epAbsolute});
    $r.addProperty("Enabled",2,rtl.boolean,"FEnabled","SetEnabled",{Default: true});
    $r.addProperty("Height",3,rtl.longint,"GetHeight","SetHeight");
    $r.addProperty("HeightPercent",2,rtl.double,"FHeightPercent","SetHeightPercent",{Default: 100});
    $r.addProperty("HeightStyle",2,pas["WEBLib.Controls"].$rtti["TSizeStyle"],"FHeightStyle","SetHeightStyle",{Default: pas["WEBLib.Controls"].TSizeStyle.ssAbsolute});
    $r.addProperty("Hint",2,rtl.string,"FHint","SetHint");
    $r.addProperty("ItemHeight",2,rtl.longint,"FItemHeight","SetItemHeight");
    $r.addProperty("ItemIndex",3,rtl.longint,"GetItemIndex","SetItemIndex",{Default: -1});
    $r.addProperty("Items",2,pas.Classes.$rtti["TStrings"],"FItems","SetItems");
    $r.addProperty("Left",3,rtl.longint,"GetLeft","SetLeft");
    $r.addProperty("MultiSelect",2,rtl.boolean,"FMultiSelect","SetMultiSelect");
    $r.addProperty("ParentColor",2,rtl.boolean,"FParentColor","SetParentColor",{Default: false});
    $r.addProperty("ParentFont",2,rtl.boolean,"FParentFont","SetParentFont",{Default: true});
    $r.addProperty("PopupMenu",0,pas["WEBLib.Menus"].$rtti["TPopupMenu"],"FPopupMenu","FPopupMenu");
    $r.addProperty("Role",3,rtl.string,"GetRole","SetRole");
    $r.addProperty("ShowFocus",2,rtl.boolean,"FShowFocus","SetShowFocus",{Default: false});
    $r.addProperty("ShowHint",2,rtl.boolean,"FShowHint","SetShowHint",{Default: false});
    $r.addProperty("TabOrder",2,rtl.longint,"FTabOrder","SetTabOrder");
    $r.addProperty("TabStop",2,rtl.boolean,"FTabStop","SetTabStop",{Default: true});
    $r.addProperty("TextDirection",0,pas["WEBLib.Controls"].$rtti["TTextDirection"],"FTextDirection","FTextDirection",{Default: pas["WEBLib.Controls"].TTextDirection.tdDefault});
    $r.addProperty("Top",3,rtl.longint,"GetTop","SetTop");
    $r.addProperty("Visible",2,rtl.boolean,"FVisible","SetVisible",{Default: true});
    $r.addProperty("Width",3,rtl.longint,"GetWidth","SetWidth");
    $r.addProperty("WidthPercent",2,rtl.double,"FWidthPercent","SetWidthPercent",{Default: 100});
    $r.addProperty("WidthStyle",2,pas["WEBLib.Controls"].$rtti["TSizeStyle"],"FWidthStyle","SetWidthStyle",{Default: pas["WEBLib.Controls"].TSizeStyle.ssAbsolute});
    $r.addProperty("OnChange",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnChange","FOnChange");
    $r.addProperty("OnClick",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnClick","FOnClick");
    $r.addProperty("OnDblClick",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnDblClick","FOnDblClick");
    $r.addProperty("OnKeyDown",0,pas["WEBLib.Controls"].$rtti["TKeyEvent"],"FOnKeyDown","FOnKeyDown");
    $r.addProperty("OnKeyPress",0,pas["WEBLib.Controls"].$rtti["TKeyPressEvent"],"FOnKeyPress","FOnKeyPress");
    $r.addProperty("OnKeyUp",0,pas["WEBLib.Controls"].$rtti["TKeyEvent"],"FOnKeyUp","FOnKeyUp");
    $r.addProperty("OnMouseDown",0,pas["WEBLib.Controls"].$rtti["TMouseEvent"],"FOnMouseDown","FOnMouseDown");
    $r.addProperty("OnMouseUp",0,pas["WEBLib.Controls"].$rtti["TMouseEvent"],"FOnMouseUp","FOnMouseUp");
    $r.addProperty("OnMouseMove",0,pas["WEBLib.Controls"].$rtti["TMouseMoveEvent"],"FOnMouseMove","FOnMouseMove");
    $r.addProperty("OnMouseLeave",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnMouseLeave","FOnMouseLeave");
    $r.addProperty("OnMouseEnter",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnMouseEnter","FOnMouseEnter");
    $r.addProperty("OnMouseWheel",0,pas["WEBLib.Controls"].$rtti["TMouseWheelEvent"],"FOnMouseWheel","FOnMouseWheel");
    $r.addProperty("OnEnter",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnEnter","FOnEnter");
    $r.addProperty("OnExit",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnExit","FOnExit");
    $r.addProperty("OnDragDrop",0,pas["WEBLib.Controls"].$rtti["TDragDropEvent"],"FOnDragDrop","FOnDragDrop");
    $r.addProperty("OnDragOver",0,pas["WEBLib.Controls"].$rtti["TDragOverEvent"],"FOnDragOver","FOnDragOver");
    $r.addProperty("OnEndDrag",0,pas["WEBLib.Controls"].$rtti["TEndDragEvent"],"FonEndDrag","FonEndDrag");
    $r.addProperty("OnStartDrag",0,pas["WEBLib.Controls"].$rtti["TStartDragEvent"],"FOnStartDrag","FOnStartDrag");
  });
  rtl.createClass(this,"TWebListBox",this.TListBox,function () {
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
  });
  this.TComboBoxStyle = {"0": "csDropDownList", csDropDownList: 0, "1": "csDropDown", csDropDown: 1};
  this.$rtti.$Enum("TComboBoxStyle",{minvalue: 0, maxvalue: 1, ordtype: 1, enumtype: this.TComboBoxStyle});
  rtl.createClass(this,"TCustomComboBox",pas["WEBLib.Menus"].TWebCustomControl,function () {
    this.$init = function () {
      pas["WEBLib.Menus"].TWebCustomControl.$init.call(this);
      this.FItems = null;
      this.FItemIndex = 0;
      this.FStyle = 0;
      this.FDroppedDown = false;
      this.FOnChange = null;
      this.FTextHint = "";
      this.FListName = "";
      this.FText = "";
      this.FHandleChangePtr = null;
      this.FHandleInputPtr = null;
      this.FHandleFocusInPtr = null;
      this.FHandleFocusOutPtr = null;
      this.FOnFocusOut = null;
      this.FOnFocusIn = null;
      this.FRequired = false;
      this.FRequiredText = "";
      this.FHandleInvalidPtr = null;
      this.FSorted = false;
    };
    this.$final = function () {
      this.FItems = undefined;
      this.FOnChange = undefined;
      this.FOnFocusOut = undefined;
      this.FOnFocusIn = undefined;
      pas["WEBLib.Menus"].TWebCustomControl.$final.call(this);
    };
    this.GetText = function () {
      var Result = "";
      var el = null;
      var AName = "";
      var AValue = "";
      Result = "";
      if (this.FStyle === $mod.TComboBoxStyle.csDropDown) {
        if (this.GetElementHandle() != null) Result = this.GetElementHandle().value;
      } else if (this.GetItemIndex() >= 0) {
        if (this.GetItemIndex() < this.FItems.GetCount()) {
          this.FItems.GetNameValue(this.GetItemIndex(),{get: function () {
              return AName;
            }, set: function (v) {
              AName = v;
            }},{get: function () {
              return AValue;
            }, set: function (v) {
              AValue = v;
            }});
          if ((AName !== "") && (AValue !== "")) {
            Result = AName}
           else Result = this.FItems.Get(this.GetItemIndex());
        } else {
          if (this.GetIsLinked()) {
            if (this.GetItemIndex() < this.GetElementHandle().childElementCount) {
              el = this.GetElementHandle().children.item(this.GetItemIndex());
              if (el.tagName === "OPTION") Result = el.innerHTML;
            };
          };
        };
      };
      return Result;
    };
    this.SetText = function (Value) {
      var I = 0;
      var AName = "";
      var AValue = "";
      if (this.FStyle === $mod.TComboBoxStyle.csDropDown) {
        this.FText = Value;
        this.UpdateElement();
      } else {
        for (var $l = 0, $end = this.FItems.GetCount() - 1; $l <= $end; $l++) {
          I = $l;
          this.FItems.GetNameValue(I,{get: function () {
              return AName;
            }, set: function (v) {
              AName = v;
            }},{get: function () {
              return AValue;
            }, set: function (v) {
              AValue = v;
            }});
          if ((Value === this.FItems.Get(I)) || (Value === AName)) this.SetItemIndex(I);
        };
      };
    };
    this.SetStyle = function (Value) {
      if (this.FStyle !== Value) {
        this.FStyle = Value;
        if (!this.GetIsLinked()) this.RecreateElement();
      };
    };
    this.SetDroppedDown = function (Value) {
      this.FDroppedDown = Value;
    };
    this.GetElementSelectHandle = function () {
      var Result = null;
      Result = this.GetContainer();
      return Result;
    };
    this.SetTextHint = function (Value) {
      if (this.FTextHint !== Value) {
        this.FTextHint = Value;
        this.DoUpdateList();
      };
    };
    this.GetValues = function (AIndex) {
      var Result = "";
      var opt = null;
      var el = null;
      if ((AIndex >= 0) && (AIndex < this.FItems.GetCount())) {
        el = this.GetElementHandle();
        opt = el.options.item(AIndex);
        Result = opt.getAttribute("value");
      };
      return Result;
    };
    this.SetValues = function (AIndex, Value) {
      var opt = null;
      var el = null;
      if ((AIndex >= 0) && (AIndex < this.FItems.GetCount())) {
        el = this.GetElementHandle();
        opt = el.options.item(AIndex);
        opt.setAttribute("value",Value);
      };
    };
    this.SetRequired = function (Value) {
      if (this.FRequired !== Value) {
        this.FRequired = Value;
        this.UpdateElement();
      };
    };
    this.SetSorted = function (Value) {
      this.FItems.SetSorted(true);
      this.FSorted = Value;
    };
    this.DoHandleChange = function (Event) {
      var Result = false;
      this.Change();
      Result = true;
      if (this.FRequiredText !== "") {
        this.GetElementHandle().setCustomValidity("");
      };
      Result = true;
      return Result;
    };
    this.DoHandleInput = function (Event) {
      var Result = false;
      if (this.FStyle === $mod.TComboBoxStyle.csDropDown) this.Change();
      Result = true;
      return Result;
    };
    this.DoHandleFocusIn = function (Event) {
      var Result = false;
      if (this.FOnFocusIn != null) this.FOnFocusIn(this);
      Result = true;
      return Result;
    };
    this.DoHandleFocusOut = function (Event) {
      var Result = false;
      if (this.FOnFocusOut != null) this.FOnFocusOut(this);
      Result = true;
      return Result;
    };
    this.DoHandleInvalid = function (Event) {
      var Result = false;
      this.GetElementHandle().setCustomValidity(this.FRequiredText);
      Result = true;
      return Result;
    };
    this.DoItemsChange = function (Sender) {
      this.DoUpdateList();
    };
    this.ClearMethodPointers = function () {
      pas["WEBLib.Controls"].TControl.ClearMethodPointers.call(this);
      this.FHandleChangePtr = null;
      this.FHandleInputPtr = null;
      this.FHandleInvalidPtr = null;
    };
    this.GetMethodPointers = function () {
      pas["WEBLib.Controls"].TControl.GetMethodPointers.call(this);
      this.FHandleChangePtr = rtl.createCallback(this,"DoHandleChange");
      this.FHandleInputPtr = rtl.createCallback(this,"DoHandleInput");
      this.FHandleFocusInPtr = rtl.createCallback(this,"DoHandleFocusIn");
      this.FHandleFocusOutPtr = rtl.createCallback(this,"DoHandleFocusOut");
      this.FHandleInvalidPtr = rtl.createCallback(this,"DoHandleInvalid");
    };
    this.AddTextHint = function () {
      var opt = null;
      if ((this.FTextHint !== "") && (this.FStyle === $mod.TComboBoxStyle.csDropDownList)) {
        opt = document.createElement("OPTION");
        opt.setAttribute("value","");
        opt.setAttribute("disabled","true");
        opt.setAttribute("selected","true");
        opt.setAttribute("hidden","true");
        opt.innerHTML = this.FTextHint;
        this.GetContainer().appendChild(opt);
      };
    };
    this.DoUpdateList = function () {
      var i = 0;
      var j = 0;
      var s = "";
      var k = "";
      var v = "";
      var opt = null;
      var el = null;
      if (!(this.GetContainer() != null)) return;
      if (this.GetElementHandle().tagName === "INPUT") {
        this.GetElementHandle().value = this.GetText();
        el = document.getElementById(this.FName + "_LIST");
        if (el != null) el.parentNode.removeChild(el);
        if (this.FTextHint !== "") this.GetElementHandle().placeholder = this.FTextHint;
        el = document.createElement("DATALIST");
        el.setAttribute("id",this.FListName);
        document.body.appendChild(el);
        for (var $l = 0, $end = this.FItems.GetCount() - 1; $l <= $end; $l++) {
          i = $l;
          s = this.FItems.Get(i);
          opt = document.createElement("OPTION");
          k = s;
          v = s;
          j = pas.System.Pos(this.FItems.GetNameValueSeparator(),s);
          if (j > 0) {
            v = pas.System.Copy(s,1,j - 1);
            k = pas.System.Copy(s,j + 1,0xFFFF);
          };
          opt.setAttribute("value",k);
          opt.innerHTML = v;
          el.appendChild(opt);
        };
      } else {
        if (this.GetElementHandle().tagName !== "SELECT") return;
        for (var $l1 = this.GetContainer().options.length - 1; $l1 >= 0; $l1--) {
          i = $l1;
          this.GetContainer().remove(i);
        };
        this.AddTextHint();
        for (var $l2 = 0, $end1 = this.FItems.GetCount() - 1; $l2 <= $end1; $l2++) {
          i = $l2;
          s = this.FItems.Get(i);
          opt = document.createElement("OPTION");
          k = s;
          v = s;
          j = pas.System.Pos(this.FItems.GetNameValueSeparator(),s);
          if (j > 0) {
            v = pas.System.Copy(s,1,j - 1);
            k = pas.System.Copy(s,j + 1,0xFFFF);
          };
          opt.setAttribute("value",k);
          opt.innerHTML = v;
          this.GetContainer().appendChild(opt);
        };
      };
      this.UpdateElement();
    };
    this.LoadState = function (AState) {
      var idx = 0;
      var e = 0;
      pas.System.val$6(AState,{get: function () {
          return idx;
        }, set: function (v) {
          idx = v;
        }},{get: function () {
          return e;
        }, set: function (v) {
          e = v;
        }});
      if (e === 0) this.SetItemIndex(idx);
    };
    this.SaveState = function () {
      var Result = "";
      Result = pas.SysUtils.IntToStr(this.GetItemIndex());
      return Result;
    };
    this.GetItemIndex = function () {
      var Result = 0;
      if (this.FStyle === $mod.TComboBoxStyle.csDropDown) {
        Result = this.FItems.IndexOf(this.FText);
      } else {
        Result = this.FItemIndex;
        if (this.GetContainer() != null) {
          Result = this.GetContainer().selectedIndex;
          if (this.FTextHint !== "") Result = Result - 1;
        };
      };
      return Result;
    };
    this.CreateElement = function () {
      var Result = null;
      if (this.FStyle === $mod.TComboBoxStyle.csDropDownList) {
        Result = document.createElement("SELECT")}
       else {
        Result = document.createElement("INPUT");
        this.FListName = this.FName + "_LIST";
        Result.setAttribute("list",this.FListName);
      };
      return Result;
    };
    this.BindEvents = function () {
      pas["WEBLib.Controls"].TCustomControl.BindEvents.call(this);
      if (this.GetElementHandle() != null) {
        this.GetElementHandle().addEventListener("input",this.FHandleInputPtr);
        this.GetElementHandle().addEventListener("change",this.FHandleChangePtr);
        this.GetElementHandle().addEventListener("focusin",this.FHandleFocusInPtr);
        this.GetElementHandle().addEventListener("focusout",this.FHandleFocusOutPtr);
        this.GetElementHandle().addEventListener("invalid",this.FHandleInvalidPtr);
      };
    };
    this.UnbindEvents = function () {
      pas["WEBLib.Controls"].TControl.UnbindEvents.call(this);
      if (this.GetElementHandle() != null) {
        this.GetElementHandle().removeEventListener("input",this.FHandleInputPtr);
        this.GetElementHandle().removeEventListener("change",this.FHandleChangePtr);
        this.GetElementHandle().removeEventListener("focusin",this.FHandleFocusInPtr);
        this.GetElementHandle().removeEventListener("focusout",this.FHandleFocusOutPtr);
        this.GetElementHandle().removeEventListener("invalid",this.FHandleInvalidPtr);
      };
    };
    this.UpdateElementData = function () {
      var d = 0;
      pas["WEBLib.Controls"].TControl.UpdateElementData.call(this);
      if (this.FRequired) {
        this.GetElementHandle().setAttribute("required","")}
       else if (!this.GetIsLinked()) this.GetElementHandle().removeAttribute("required");
      if (this.FStyle === $mod.TComboBoxStyle.csDropDown) {
        if (this.GetElementHandle() != null) {
          this.GetElementHandle().value = this.FText;
          this.FListName = this.FName + "_LIST";
          this.GetElementHandle().setAttribute("list",this.FListName);
        };
      } else if (this.GetElementSelectHandle() != null) {
        d = 0;
        if (this.FTextHint !== "") d = 1;
        this.GetElementSelectHandle().selectedIndex = this.FItemIndex + d;
        this.GetElementSelectHandle().setAttribute("role","combobox");
      };
    };
    this.UpdateElementVisual = function () {
      pas["WEBLib.Controls"].TCustomControl.UpdateElementVisual.call(this);
    };
    this.UpdateParent = function () {
      pas["WEBLib.Controls"].TControl.UpdateParent.call(this);
      this.DoUpdateList();
    };
    this.SetItems = function (AItems) {
      this.FItems.Assign(AItems);
    };
    this.SetItemIndex = function (AIndex) {
      if (this.FItemIndex !== AIndex) {
        this.FItemIndex = AIndex;
        if ((AIndex >= 0) && (this.FStyle in rtl.createSet($mod.TComboBoxStyle.csDropDown,$mod.TComboBoxStyle.csDropDownList)) && (AIndex < this.FItems.GetCount())) this.FText = this.FItems.Get(AIndex);
        this.UpdateElement();
      };
    };
    this.Loaded = function () {
      pas["WEBLib.Controls"].TCustomControl.Loaded.call(this);
      this.DoUpdateList();
    };
    this.Change = function () {
      this.FItemIndex = this.GetItemIndex();
      if (this.FOnChange != null) this.FOnChange(this);
    };
    this.PersistinHTML = function () {
      var sel = null;
      pas["WEBLib.Controls"].TControl.PersistinHTML.call(this);
      sel = this.GetElementHandle().children.item(this.GetItemIndex());
      if (sel != null) sel.setAttribute("selected","selected");
    };
    this.InitCSSLibrary = function (ALibrary) {
      if (ALibrary === pas["WEBLib.Controls"].TCSSLibrary.cssBootstrap) {
        this.SetElementFont(pas["WEBLib.Controls"].TElementFont.efCSS);
        this.SetElementClassName("form-select");
        this.SetHeightStyle(pas["WEBLib.Controls"].TSizeStyle.ssAuto);
      };
    };
    this.CreateInitialize = function () {
      pas["WEBLib.Controls"].TCustomControl.CreateInitialize.call(this);
      this.FItems = pas.Classes.TStringList.$create("Create$1");
      this.FItems.FOnChange = rtl.createCallback(this,"DoItemsChange");
      this.FItemIndex = -1;
      this.FStyle = $mod.TComboBoxStyle.csDropDownList;
      this.SetShowFocus(true);
      this.SetHeight(25);
    };
    this.Destroy = function () {
      rtl.free(this,"FItems");
      pas["WEBLib.Controls"].TCustomControl.Destroy.call(this);
    };
    this.Clear = function () {
      this.FItems.Clear();
    };
    this.AddItem = function (Item, AObject) {
      this.FItems.AddObject(Item,AObject);
    };
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
  });
  rtl.createClass(this,"TComboBox",this.TCustomComboBox,function () {
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
    var $r = this.$rtti;
    $r.addProperty("Align",2,pas["WEBLib.Controls"].$rtti["TAlign"],"FAlign","SetAlign",{Default: pas["WEBLib.Controls"].TAlign.alNone});
    $r.addProperty("AlignWithMargins",2,rtl.boolean,"FAlignWithMargins","SetAlignWithMargins",{Default: false});
    $r.addProperty("Anchors",2,pas["WEBLib.Controls"].$rtti["TAnchors"],"FAnchors","SetAnchors",{Default: rtl.createSet(pas["WEBLib.Controls"].TAnchorKind.akLeft,pas["WEBLib.Controls"].TAnchorKind.akTop)});
    $r.addProperty("BiDiMode",2,pas["WEBLib.Controls"].$rtti["TBiDiMode"],"FBiDiMode","SetBiDiMode",{Default: pas["WEBLib.Controls"].TBiDiMode.bdLeftToRight});
    $r.addProperty("BorderStyle",2,pas["WEBLib.Controls"].$rtti["TBorderStyle"],"FBorderStyle","SetBorderStyle",{Default: pas["WEBLib.Controls"].TBorderStyle.bsSingle});
    $r.addProperty("ChildOrder",2,rtl.longint,"FChildOrder","SetChildOrderEx",{Default: 0});
    $r.addProperty("Color",2,pas["WEBLib.Graphics"].$rtti["TColor"],"FColor","SetColor");
    $r.addProperty("DragMode",2,pas["WEBLib.Controls"].$rtti["TDragMode"],"FDragMode","SetDragMode",{Default: pas["WEBLib.Controls"].TDragMode.dmManual});
    $r.addProperty("ElementClassName",2,pas["WEBLib.Controls"].$rtti["TElementClassName"],"FElementClassName","SetElementClassName");
    $r.addProperty("ElementID",3,pas["WEBLib.Controls"].$rtti["TElementID"],"GetID","SetID");
    $r.addProperty("ElementFont",2,pas["WEBLib.Controls"].$rtti["TElementFont"],"FElementFont","SetElementFont",{Default: pas["WEBLib.Controls"].TElementFont.efProperty});
    $r.addProperty("ElementPosition",2,pas["WEBLib.Controls"].$rtti["TElementPosition"],"FElementPosition","SetElementPosition",{Default: pas["WEBLib.Controls"].TElementPosition.epAbsolute});
    $r.addProperty("Enabled",2,rtl.boolean,"FEnabled","SetEnabled",{Default: true});
    $r.addProperty("Font",2,pas["WEBLib.Graphics"].$rtti["TFont"],"FFont","SetFont");
    $r.addProperty("Height",3,rtl.longint,"GetHeight","SetHeight");
    $r.addProperty("HeightPercent",2,rtl.double,"FHeightPercent","SetHeightPercent",{Default: 100});
    $r.addProperty("HeightStyle",2,pas["WEBLib.Controls"].$rtti["TSizeStyle"],"FHeightStyle","SetHeightStyle",{Default: pas["WEBLib.Controls"].TSizeStyle.ssAbsolute});
    $r.addProperty("Hint",2,rtl.string,"FHint","SetHint");
    $r.addProperty("ItemIndex",3,rtl.longint,"GetItemIndex","SetItemIndex",{Default: -1});
    $r.addProperty("Items",2,pas.Classes.$rtti["TStrings"],"FItems","SetItems");
    $r.addProperty("Left",3,rtl.longint,"GetLeft","SetLeft");
    $r.addProperty("OnFocusIn",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnFocusIn","FOnFocusIn");
    $r.addProperty("OnFocusOut",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnFocusOut","FOnFocusOut");
    $r.addProperty("ParentFont",2,rtl.boolean,"FParentFont","SetParentFont",{Default: true});
    $r.addProperty("Required",2,rtl.boolean,"FRequired","SetRequired",{Default: false});
    $r.addProperty("RequiredText",0,rtl.string,"FRequiredText","FRequiredText");
    $r.addProperty("Role",3,rtl.string,"GetRole","SetRole");
    $r.addProperty("ShowFocus",2,rtl.boolean,"FShowFocus","SetShowFocus",{Default: false});
    $r.addProperty("ShowHint",2,rtl.boolean,"FShowHint","SetShowHint",{Default: false});
    $r.addProperty("Style",2,$mod.$rtti["TComboBoxStyle"],"FStyle","SetStyle");
    $r.addProperty("TabOrder",2,rtl.longint,"FTabOrder","SetTabOrder");
    $r.addProperty("TabStop",2,rtl.boolean,"FTabStop","SetTabStop",{Default: true});
    $r.addProperty("Text",3,rtl.string,"GetText","SetText");
    $r.addProperty("TextDirection",0,pas["WEBLib.Controls"].$rtti["TTextDirection"],"FTextDirection","FTextDirection",{Default: pas["WEBLib.Controls"].TTextDirection.tdDefault});
    $r.addProperty("TextHint",2,rtl.string,"FTextHint","SetTextHint");
    $r.addProperty("Top",3,rtl.longint,"GetTop","SetTop");
    $r.addProperty("Visible",2,rtl.boolean,"FVisible","SetVisible",{Default: true});
    $r.addProperty("Width",3,rtl.longint,"GetWidth","SetWidth");
    $r.addProperty("WidthPercent",2,rtl.double,"FWidthPercent","SetWidthPercent",{Default: 100});
    $r.addProperty("WidthStyle",2,pas["WEBLib.Controls"].$rtti["TSizeStyle"],"FWidthStyle","SetWidthStyle",{Default: pas["WEBLib.Controls"].TSizeStyle.ssAbsolute});
    $r.addProperty("OnChange",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnChange","FOnChange");
    $r.addProperty("OnClick",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnClick","FOnClick");
    $r.addProperty("OnDblClick",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnDblClick","FOnDblClick");
    $r.addProperty("OnKeyDown",0,pas["WEBLib.Controls"].$rtti["TKeyEvent"],"FOnKeyDown","FOnKeyDown");
    $r.addProperty("OnKeyPress",0,pas["WEBLib.Controls"].$rtti["TKeyPressEvent"],"FOnKeyPress","FOnKeyPress");
    $r.addProperty("OnKeyUp",0,pas["WEBLib.Controls"].$rtti["TKeyEvent"],"FOnKeyUp","FOnKeyUp");
    $r.addProperty("OnMouseDown",0,pas["WEBLib.Controls"].$rtti["TMouseEvent"],"FOnMouseDown","FOnMouseDown");
    $r.addProperty("OnMouseUp",0,pas["WEBLib.Controls"].$rtti["TMouseEvent"],"FOnMouseUp","FOnMouseUp");
    $r.addProperty("OnMouseMove",0,pas["WEBLib.Controls"].$rtti["TMouseMoveEvent"],"FOnMouseMove","FOnMouseMove");
    $r.addProperty("OnMouseLeave",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnMouseLeave","FOnMouseLeave");
    $r.addProperty("OnMouseEnter",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnMouseEnter","FOnMouseEnter");
    $r.addProperty("OnEnter",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnEnter","FOnEnter");
    $r.addProperty("OnExit",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnExit","FOnExit");
    $r.addProperty("OnDragDrop",0,pas["WEBLib.Controls"].$rtti["TDragDropEvent"],"FOnDragDrop","FOnDragDrop");
    $r.addProperty("OnDragOver",0,pas["WEBLib.Controls"].$rtti["TDragOverEvent"],"FOnDragOver","FOnDragOver");
    $r.addProperty("OnEndDrag",0,pas["WEBLib.Controls"].$rtti["TEndDragEvent"],"FonEndDrag","FonEndDrag");
    $r.addProperty("OnStartDrag",0,pas["WEBLib.Controls"].$rtti["TStartDragEvent"],"FOnStartDrag","FOnStartDrag");
  });
  rtl.createClass(this,"TWebComboBox",this.TComboBox,function () {
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
  });
  rtl.createClass(this,"TFontPicker",this.TCustomComboBox,function () {
    this.CreateInitialize = function () {
      var $Self = this;
      var tst = false;
      function Add(s) {
        tst = d.detect(s);
        if (tst) $Self.FItems.Add(s);
      };
      $mod.TCustomComboBox.CreateInitialize.call(this);
      var Detector = function() {
          // a font will be compared against all the three default fonts.
          // and if it doesn't match all 3 then that font is not available.
          var baseFonts = ['monospace', 'sans-serif', 'serif'];
      
          //we use m or w because these two characters take up the maximum width.
          // And we use a LLi so that the same matching fonts can get separated
          var testString = "mmmmmmmmmmlli";
      
          //we test using 72px font size, we may use any size. I guess larger the better.
          var testSize = '72px';
      
          var h = document.getElementsByTagName("body")[0];
      
          // create a SPAN in the document to get the width of the text we use to test
          var s = document.createElement("span");
          s.style.fontSize = testSize;
          s.innerHTML = testString;
          var defaultWidth = {};
          var defaultHeight = {};
          for (var index in baseFonts) {
              //get the default width for the three base fonts
              s.style.fontFamily = baseFonts[index];
              h.appendChild(s);
              defaultWidth[baseFonts[index]] = s.offsetWidth; //width for the default font
              defaultHeight[baseFonts[index]] = s.offsetHeight; //height for the defualt font
              h.removeChild(s);
          }
      
          function detect(font) {
              var detected = false;
              for (var index in baseFonts) {
                  s.style.fontFamily = font + ',' + baseFonts[index]; // name of the font along with the base font for fallback.
                  h.appendChild(s);
                  var matched = (s.offsetWidth != defaultWidth[baseFonts[index]] || s.offsetHeight != defaultHeight[baseFonts[index]]);
                  h.removeChild(s);
                  detected = detected || matched;
              }
              return detected;
          }
      
          this.detect = detect;
          };
      
          var d = new Detector();
          //tst = d.detect("Arial");
      Add("Arial");
      Add("Arial Black");
      Add("Arial Narrow");
      Add("Courier");
      Add("Courier New");
      Add("Georgia");
      Add("Lucida Console");
      Add("Modena");
      Add("Monotype Corsiva");
      Add("Papyrus");
      Add("Tahoma");
      Add("Times");
      Add("Times New Roman");
      Add("Trebuchet MS");
      Add("Verdana");
      Add("Verona");
    };
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
    var $r = this.$rtti;
    $r.addProperty("Align",2,pas["WEBLib.Controls"].$rtti["TAlign"],"FAlign","SetAlign",{Default: pas["WEBLib.Controls"].TAlign.alNone});
    $r.addProperty("AlignWithMargins",2,rtl.boolean,"FAlignWithMargins","SetAlignWithMargins",{Default: false});
    $r.addProperty("Color",2,pas["WEBLib.Graphics"].$rtti["TColor"],"FColor","SetColor");
    $r.addProperty("ElementClassName",2,pas["WEBLib.Controls"].$rtti["TElementClassName"],"FElementClassName","SetElementClassName");
    $r.addProperty("ElementID",3,pas["WEBLib.Controls"].$rtti["TElementID"],"GetID","SetID");
    $r.addProperty("ElementFont",2,pas["WEBLib.Controls"].$rtti["TElementFont"],"FElementFont","SetElementFont",{Default: pas["WEBLib.Controls"].TElementFont.efProperty});
    $r.addProperty("ElementPosition",2,pas["WEBLib.Controls"].$rtti["TElementPosition"],"FElementPosition","SetElementPosition",{Default: pas["WEBLib.Controls"].TElementPosition.epAbsolute});
    $r.addProperty("Enabled",2,rtl.boolean,"FEnabled","SetEnabled",{Default: true});
    $r.addProperty("Font",2,pas["WEBLib.Graphics"].$rtti["TFont"],"FFont","SetFont");
    $r.addProperty("Height",3,rtl.longint,"GetHeight","SetHeight");
    $r.addProperty("Hint",2,rtl.string,"FHint","SetHint");
    $r.addProperty("ItemIndex",3,rtl.longint,"GetItemIndex","SetItemIndex",{Default: -1});
    $r.addProperty("Left",3,rtl.longint,"GetLeft","SetLeft");
    $r.addProperty("ShowHint",2,rtl.boolean,"FShowHint","SetShowHint",{Default: false});
    $r.addProperty("TabOrder",2,rtl.longint,"FTabOrder","SetTabOrder");
    $r.addProperty("TabStop",2,rtl.boolean,"FTabStop","SetTabStop",{Default: true});
    $r.addProperty("Text",3,rtl.string,"GetText","SetText");
    $r.addProperty("Top",3,rtl.longint,"GetTop","SetTop");
    $r.addProperty("Visible",2,rtl.boolean,"FVisible","SetVisible",{Default: true});
    $r.addProperty("Width",3,rtl.longint,"GetWidth","SetWidth");
    $r.addProperty("WidthPercent",2,rtl.double,"FWidthPercent","SetWidthPercent",{Default: 100});
    $r.addProperty("OnChange",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnChange","FOnChange");
    $r.addProperty("OnClick",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnClick","FOnClick");
    $r.addProperty("OnDblClick",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnDblClick","FOnDblClick");
    $r.addProperty("OnKeyDown",0,pas["WEBLib.Controls"].$rtti["TKeyEvent"],"FOnKeyDown","FOnKeyDown");
    $r.addProperty("OnKeyPress",0,pas["WEBLib.Controls"].$rtti["TKeyPressEvent"],"FOnKeyPress","FOnKeyPress");
    $r.addProperty("OnKeyUp",0,pas["WEBLib.Controls"].$rtti["TKeyEvent"],"FOnKeyUp","FOnKeyUp");
    $r.addProperty("OnMouseDown",0,pas["WEBLib.Controls"].$rtti["TMouseEvent"],"FOnMouseDown","FOnMouseDown");
    $r.addProperty("OnMouseUp",0,pas["WEBLib.Controls"].$rtti["TMouseEvent"],"FOnMouseUp","FOnMouseUp");
    $r.addProperty("OnMouseMove",0,pas["WEBLib.Controls"].$rtti["TMouseMoveEvent"],"FOnMouseMove","FOnMouseMove");
    $r.addProperty("OnMouseLeave",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnMouseLeave","FOnMouseLeave");
    $r.addProperty("OnMouseEnter",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnMouseEnter","FOnMouseEnter");
    $r.addProperty("OnEnter",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnEnter","FOnEnter");
    $r.addProperty("OnExit",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnExit","FOnExit");
  });
  rtl.createClass(this,"TWebFontPicker",this.TFontPicker,function () {
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
  });
  this.TFontSizePickerMode = {"0": "fmPointSize", fmPointSize: 0, "1": "fmRelativeSize", fmRelativeSize: 1};
  this.$rtti.$Enum("TFontSizePickerMode",{minvalue: 0, maxvalue: 1, ordtype: 1, enumtype: this.TFontSizePickerMode});
  rtl.createClass(this,"TFontSizePicker",this.TCustomComboBox,function () {
    this.$init = function () {
      $mod.TCustomComboBox.$init.call(this);
      this.FPickerMode = 0;
    };
    this.SetPickerMode = function (AValue) {
      this.FPickerMode = AValue;
      this.Init();
    };
    this.Init = function () {
      this.FItems.Clear();
      var $tmp = this.FPickerMode;
      if ($tmp === $mod.TFontSizePickerMode.fmPointSize) {
        this.FItems.Add("8");
        this.FItems.Add("9");
        this.FItems.Add("10");
        this.FItems.Add("11");
        this.FItems.Add("12");
        this.FItems.Add("14");
        this.FItems.Add("16");
        this.FItems.Add("18");
        this.FItems.Add("20");
        this.FItems.Add("22");
        this.FItems.Add("24");
        this.FItems.Add("26");
        this.FItems.Add("28");
        this.FItems.Add("36");
        this.FItems.Add("48");
        this.FItems.Add("72");
      } else if ($tmp === $mod.TFontSizePickerMode.fmRelativeSize) {
        this.FItems.Add("8");
        this.FItems.Add("9");
        this.FItems.Add("10");
        this.FItems.Add("14");
        this.FItems.Add("18");
        this.FItems.Add("24");
        this.FItems.Add("36");
      };
    };
    this.CreateInitialize = function () {
      $mod.TCustomComboBox.CreateInitialize.call(this);
      this.SetPickerMode($mod.TFontSizePickerMode.fmPointSize);
    };
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
    var $r = this.$rtti;
    $r.addProperty("Align",2,pas["WEBLib.Controls"].$rtti["TAlign"],"FAlign","SetAlign",{Default: pas["WEBLib.Controls"].TAlign.alNone});
    $r.addProperty("AlignWithMargins",2,rtl.boolean,"FAlignWithMargins","SetAlignWithMargins",{Default: false});
    $r.addProperty("Color",2,pas["WEBLib.Graphics"].$rtti["TColor"],"FColor","SetColor");
    $r.addProperty("ElementClassName",2,pas["WEBLib.Controls"].$rtti["TElementClassName"],"FElementClassName","SetElementClassName");
    $r.addProperty("ElementID",3,pas["WEBLib.Controls"].$rtti["TElementID"],"GetID","SetID");
    $r.addProperty("ElementFont",2,pas["WEBLib.Controls"].$rtti["TElementFont"],"FElementFont","SetElementFont",{Default: pas["WEBLib.Controls"].TElementFont.efProperty});
    $r.addProperty("ElementPosition",2,pas["WEBLib.Controls"].$rtti["TElementPosition"],"FElementPosition","SetElementPosition",{Default: pas["WEBLib.Controls"].TElementPosition.epAbsolute});
    $r.addProperty("Enabled",2,rtl.boolean,"FEnabled","SetEnabled",{Default: true});
    $r.addProperty("Font",2,pas["WEBLib.Graphics"].$rtti["TFont"],"FFont","SetFont");
    $r.addProperty("Height",3,rtl.longint,"GetHeight","SetHeight");
    $r.addProperty("HeightPercent",2,rtl.double,"FHeightPercent","SetHeightPercent",{Default: 100});
    $r.addProperty("HeightStyle",2,pas["WEBLib.Controls"].$rtti["TSizeStyle"],"FHeightStyle","SetHeightStyle",{Default: pas["WEBLib.Controls"].TSizeStyle.ssAbsolute});
    $r.addProperty("Hint",2,rtl.string,"FHint","SetHint");
    $r.addProperty("ItemIndex",3,rtl.longint,"GetItemIndex","SetItemIndex",{Default: -1});
    $r.addProperty("Left",3,rtl.longint,"GetLeft","SetLeft");
    $r.addProperty("PickerMode",2,$mod.$rtti["TFontSizePickerMode"],"FPickerMode","SetPickerMode");
    $r.addProperty("ShowHint",2,rtl.boolean,"FShowHint","SetShowHint",{Default: false});
    $r.addProperty("TabOrder",2,rtl.longint,"FTabOrder","SetTabOrder");
    $r.addProperty("TabStop",2,rtl.boolean,"FTabStop","SetTabStop",{Default: true});
    $r.addProperty("Text",3,rtl.string,"GetText","SetText");
    $r.addProperty("Top",3,rtl.longint,"GetTop","SetTop");
    $r.addProperty("Visible",2,rtl.boolean,"FVisible","SetVisible",{Default: true});
    $r.addProperty("Width",3,rtl.longint,"GetWidth","SetWidth");
    $r.addProperty("WidthPercent",2,rtl.double,"FWidthPercent","SetWidthPercent",{Default: 100});
    $r.addProperty("WidthStyle",2,pas["WEBLib.Controls"].$rtti["TSizeStyle"],"FWidthStyle","SetWidthStyle",{Default: pas["WEBLib.Controls"].TSizeStyle.ssAbsolute});
    $r.addProperty("OnChange",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnChange","FOnChange");
    $r.addProperty("OnClick",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnClick","FOnClick");
    $r.addProperty("OnDblClick",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnDblClick","FOnDblClick");
    $r.addProperty("OnKeyDown",0,pas["WEBLib.Controls"].$rtti["TKeyEvent"],"FOnKeyDown","FOnKeyDown");
    $r.addProperty("OnKeyPress",0,pas["WEBLib.Controls"].$rtti["TKeyPressEvent"],"FOnKeyPress","FOnKeyPress");
    $r.addProperty("OnKeyUp",0,pas["WEBLib.Controls"].$rtti["TKeyEvent"],"FOnKeyUp","FOnKeyUp");
    $r.addProperty("OnMouseDown",0,pas["WEBLib.Controls"].$rtti["TMouseEvent"],"FOnMouseDown","FOnMouseDown");
    $r.addProperty("OnMouseUp",0,pas["WEBLib.Controls"].$rtti["TMouseEvent"],"FOnMouseUp","FOnMouseUp");
    $r.addProperty("OnMouseMove",0,pas["WEBLib.Controls"].$rtti["TMouseMoveEvent"],"FOnMouseMove","FOnMouseMove");
    $r.addProperty("OnMouseLeave",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnMouseLeave","FOnMouseLeave");
    $r.addProperty("OnMouseEnter",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnMouseEnter","FOnMouseEnter");
    $r.addProperty("OnEnter",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnEnter","FOnEnter");
    $r.addProperty("OnExit",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnExit","FOnExit");
  });
  rtl.createClass(this,"TLineSpacingPicker",this.TCustomComboBox,function () {
    this.CreateInitialize = function () {
      $mod.TCustomComboBox.CreateInitialize.call(this);
      this.FItems.Clear();
      this.FItems.Add("1");
      this.FItems.Add("1.5");
      this.FItems.Add("2");
    };
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
    var $r = this.$rtti;
    $r.addProperty("Align",2,pas["WEBLib.Controls"].$rtti["TAlign"],"FAlign","SetAlign",{Default: pas["WEBLib.Controls"].TAlign.alNone});
    $r.addProperty("AlignWithMargins",2,rtl.boolean,"FAlignWithMargins","SetAlignWithMargins",{Default: false});
    $r.addProperty("Color",2,pas["WEBLib.Graphics"].$rtti["TColor"],"FColor","SetColor");
    $r.addProperty("ElementClassName",2,pas["WEBLib.Controls"].$rtti["TElementClassName"],"FElementClassName","SetElementClassName");
    $r.addProperty("ElementID",3,pas["WEBLib.Controls"].$rtti["TElementID"],"GetID","SetID");
    $r.addProperty("ElementFont",2,pas["WEBLib.Controls"].$rtti["TElementFont"],"FElementFont","SetElementFont",{Default: pas["WEBLib.Controls"].TElementFont.efProperty});
    $r.addProperty("ElementPosition",2,pas["WEBLib.Controls"].$rtti["TElementPosition"],"FElementPosition","SetElementPosition",{Default: pas["WEBLib.Controls"].TElementPosition.epAbsolute});
    $r.addProperty("Enabled",2,rtl.boolean,"FEnabled","SetEnabled",{Default: true});
    $r.addProperty("Font",2,pas["WEBLib.Graphics"].$rtti["TFont"],"FFont","SetFont");
    $r.addProperty("Height",3,rtl.longint,"GetHeight","SetHeight");
    $r.addProperty("HeightPercent",2,rtl.double,"FHeightPercent","SetHeightPercent",{Default: 100});
    $r.addProperty("HeightStyle",2,pas["WEBLib.Controls"].$rtti["TSizeStyle"],"FHeightStyle","SetHeightStyle",{Default: pas["WEBLib.Controls"].TSizeStyle.ssAbsolute});
    $r.addProperty("Hint",2,rtl.string,"FHint","SetHint");
    $r.addProperty("ItemIndex",3,rtl.longint,"GetItemIndex","SetItemIndex",{Default: -1});
    $r.addProperty("Left",3,rtl.longint,"GetLeft","SetLeft");
    $r.addProperty("ShowHint",2,rtl.boolean,"FShowHint","SetShowHint",{Default: false});
    $r.addProperty("TabOrder",2,rtl.longint,"FTabOrder","SetTabOrder");
    $r.addProperty("TabStop",2,rtl.boolean,"FTabStop","SetTabStop",{Default: true});
    $r.addProperty("Text",3,rtl.string,"GetText","SetText");
    $r.addProperty("Top",3,rtl.longint,"GetTop","SetTop");
    $r.addProperty("Visible",2,rtl.boolean,"FVisible","SetVisible",{Default: true});
    $r.addProperty("Width",3,rtl.longint,"GetWidth","SetWidth");
    $r.addProperty("WidthPercent",2,rtl.double,"FWidthPercent","SetWidthPercent",{Default: 100});
    $r.addProperty("WidthStyle",2,pas["WEBLib.Controls"].$rtti["TSizeStyle"],"FWidthStyle","SetWidthStyle",{Default: pas["WEBLib.Controls"].TSizeStyle.ssAbsolute});
    $r.addProperty("OnChange",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnChange","FOnChange");
    $r.addProperty("OnClick",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnClick","FOnClick");
    $r.addProperty("OnDblClick",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnDblClick","FOnDblClick");
    $r.addProperty("OnKeyDown",0,pas["WEBLib.Controls"].$rtti["TKeyEvent"],"FOnKeyDown","FOnKeyDown");
    $r.addProperty("OnKeyPress",0,pas["WEBLib.Controls"].$rtti["TKeyPressEvent"],"FOnKeyPress","FOnKeyPress");
    $r.addProperty("OnKeyUp",0,pas["WEBLib.Controls"].$rtti["TKeyEvent"],"FOnKeyUp","FOnKeyUp");
    $r.addProperty("OnMouseDown",0,pas["WEBLib.Controls"].$rtti["TMouseEvent"],"FOnMouseDown","FOnMouseDown");
    $r.addProperty("OnMouseUp",0,pas["WEBLib.Controls"].$rtti["TMouseEvent"],"FOnMouseUp","FOnMouseUp");
    $r.addProperty("OnMouseMove",0,pas["WEBLib.Controls"].$rtti["TMouseMoveEvent"],"FOnMouseMove","FOnMouseMove");
    $r.addProperty("OnMouseLeave",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnMouseLeave","FOnMouseLeave");
    $r.addProperty("OnMouseEnter",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnMouseEnter","FOnMouseEnter");
    $r.addProperty("OnEnter",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnEnter","FOnEnter");
    $r.addProperty("OnExit",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnExit","FOnExit");
  });
  rtl.createClass(this,"TWebFontSizePicker",this.TFontSizePicker,function () {
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
  });
  rtl.createClass(this,"TCustomMemo",pas["WEBLib.Menus"].TWebCustomControl,function () {
    this.$init = function () {
      pas["WEBLib.Menus"].TWebCustomControl.$init.call(this);
      this.FWordWrap = false;
      this.FBlockChange = false;
      this.FLines = null;
      this.FSelStart = 0;
      this.FSelLength = 0;
      this.FCaretPosition = pas.Types.TPoint.$new();
      this.FAutoSize = false;
      this.FOnChange = null;
      this.FReadOnly = false;
      this.FTextHint = "";
      this.FHandleChangePtr = null;
      this.FHandlePastePtr = null;
      this.FHandleCutPtr = null;
      this.FHandleInputPtr = null;
      this.FHandleInvalidPtr = null;
      this.FWantTabs = false;
      this.FAutoCompletion = 0;
      this.FSpellCheck = false;
      this.FModified = false;
      this.FScrollbars = 0;
      this.FRequiredText = "";
      this.FRequired = false;
    };
    this.$final = function () {
      this.FLines = undefined;
      this.FCaretPosition = undefined;
      this.FOnChange = undefined;
      pas["WEBLib.Menus"].TWebCustomControl.$final.call(this);
    };
    this.GetText = function () {
      var Result = "";
      if (this.GetElementInputHandle() != null) {
        this.FBlockChange = true;
        this.FLines.SetTextStr(this.GetElementInputHandle().value);
        this.FBlockChange = false;
      };
      Result = this.FLines.GetTextStr();
      return Result;
    };
    this.SetText = function (Value) {
      this.FLines.SetTextStr(Value);
    };
    this.SetSelLength = function (Value) {
      if (this.FSelLength !== Value) {
        this.FSelLength = Value;
        this.UpdateElement();
      };
    };
    this.SetSelStart = function (Value) {
      if (this.FSelStart !== Value) {
        this.FSelStart = Value;
        this.UpdateElement();
      };
    };
    this.SetAutoSize = function (Value) {
      if (this.FAutoSize !== Value) {
        this.FAutoSize = Value;
        this.UpdateElement();
      };
    };
    this.GetElementInputHandle = function () {
      var Result = null;
      Result = this.GetContainer();
      return Result;
    };
    this.SetReadOnly = function (Value) {
      if (this.FReadOnly !== Value) {
        this.FReadOnly = Value;
        this.UpdateElement();
      };
    };
    this.GetSelLength = function () {
      var Result = 0;
      Result = -1;
      if (this.GetElementInputHandle() != null) Result = this.GetElementInputHandle().selectionEnd - this.GetElementInputHandle().selectionStart;
      return Result;
    };
    this.GetSelStart = function () {
      var Result = 0;
      Result = -1;
      if (this.GetElementInputHandle() != null) Result = this.GetElementInputHandle().selectionStart;
      return Result;
    };
    this.SetTextHint = function (Value) {
      if (this.FTextHint !== Value) {
        this.FTextHint = Value;
        this.UpdateElement();
      };
    };
    this.SetAutoCompletion = function (Value) {
      if (this.FAutoCompletion !== Value) {
        this.FAutoCompletion = Value;
        this.UpdateElementData();
      };
    };
    this.SetSpellCheck = function (Value) {
      if (this.FSpellCheck !== Value) {
        this.FSpellCheck = Value;
        this.UpdateElement();
      };
    };
    this.SetWantTabs = function (Value) {
      if (this.FWantTabs !== Value) {
        this.FWantTabs = Value;
        this.UpdateElement();
      };
    };
    this.SetWordWrap = function (Value) {
      if (this.FWordWrap !== Value) {
        this.FWordWrap = Value;
        this.UpdateElement();
      };
    };
    this.GetCaretPos = function () {
      var Result = pas.Types.TPoint.$new();
      Result.$assign(this.GetCaret());
      return Result;
    };
    this.SetCaretPos = function (Value) {
      this.SetCaret(Value.x,Value.y);
    };
    this.SetScrollBars = function (Value) {
      if (this.FScrollbars !== Value) {
        this.FScrollbars = Value;
        this.UpdateElement();
      };
    };
    this.GetSelText = function () {
      var Result = "";
      Result = "";
      if (this.GetElementInputHandle() != null) Result = pas.SysUtils.TStringHelper.Substring$1.call({p: this.GetElementInputHandle(), get: function () {
          return this.p.value;
        }, set: function (v) {
          this.p.value = v;
        }},this.GetSelStart(),this.GetSelStart() + this.GetSelLength());
      return Result;
    };
    this.SetRequired = function (Value) {
      if (this.FRequired !== Value) {
        this.FRequired = Value;
        this.UpdateElement();
      };
    };
    this.IsInputControl = function () {
      var Result = false;
      Result = true;
      return Result;
    };
    this.HandleDoKeyDown = function (Event) {
      var Result = false;
      var eh = null;
      var AEvent = null;
      AEvent = Event;
      if ((this.GetKeyCode(AEvent.key,true) === 9) && this.FWantTabs) {
        eh = this.GetElementInputHandle();
        var sstart = eh.selectionStart;
              var send = eh.selectionEnd;
        
              eh.value = eh.value.substring(0, sstart) + "\t" +eh.value.substring(send);
              // put caret at right position again
              eh.selectionStart = eh.selectionEnd = sstart + 1;
        
              AEvent.stopPropagation();
              AEvent.preventDefault();
      } else pas["WEBLib.Controls"].TControl.HandleDoKeyDown.apply(this,arguments);
      return Result;
    };
    this.CreateElement = function () {
      var Result = null;
      Result = document.createElement("TEXTAREA");
      return Result;
    };
    this.DoHandlePaste = function (Event) {
      var Result = false;
      var s = "";
      var clp = false;
      clp = false;
      var clipboardData = Event.clipboardData || window.clipboardData;
      if (clipboardData) {
        s = clipboardData.getData('Text');
        clp = true;
      };
      if (clp && !this.CanPaste(s)) {
        Event.preventDefault();
        Event.stopPropagation();
      };
      Result = false;
      return Result;
    };
    this.DoHandleCut = function (Event) {
      var Result = false;
      if (!this.CanCut()) {
        Event.preventDefault();
        Event.stopPropagation();
      };
      Result = false;
      return Result;
    };
    this.DoHandleInput = function (Event) {
      var Result = false;
      this.GetText();
      this.Change();
      if (this.FAutoSize) this.DoAutoSize();
      Result = true;
      return Result;
    };
    this.DoHandleChange = function (Event) {
      var Result = false;
      this.FModified = true;
      this.Change();
      if (this.FRequiredText !== "") {
        this.GetElementInputHandle().setCustomValidity("");
      };
      Result = true;
      return Result;
    };
    this.DoHandleInvalid = function (Event) {
      var Result = false;
      this.GetElementInputHandle().setCustomValidity(this.FRequiredText);
      Result = true;
      return Result;
    };
    this.IsReadOnly = function () {
      var Result = false;
      Result = this.FReadOnly;
      return Result;
    };
    this.PersistinHTML = function () {
      this.GetElementInputHandle().innerHTML = this.FLines.GetTextStr();
    };
    this.GetDisplayText = function () {
      var Result = "";
      Result = this.FLines.GetTextStr();
      return Result;
    };
    this.DoAutoSize = function () {
      var sh = 0;
      var el = null;
      this.GetElementInputHandle().style.setProperty("overflow","hidden");
      this.GetElementInputHandle().style.setProperty("height","auto");
      el = this.GetElementInputHandle();
      sh = el.scrollHeight;
      this.GetElementInputHandle().style.setProperty("height",pas.SysUtils.TIntegerHelper.ToString$1.call({get: function () {
          return sh;
        }, set: function (v) {
          sh = v;
        }}) + "px");
    };
    this.BindEvents = function () {
      pas["WEBLib.Controls"].TCustomControl.BindEvents.call(this);
      if (this.GetElementInputHandle() != null) {
        this.GetElementInputHandle().addEventListener("input",this.FHandleInputPtr);
        this.GetElementInputHandle().addEventListener("change",this.FHandleChangePtr);
        this.GetElementInputHandle().addEventListener("paste",this.FHandlePastePtr);
        this.GetElementInputHandle().addEventListener("cut",this.FHandleCutPtr);
        this.GetElementInputHandle().addEventListener("invalid",this.FHandleInvalidPtr);
      };
    };
    this.UnbindEvents = function () {
      pas["WEBLib.Controls"].TControl.UnbindEvents.call(this);
      if (this.GetElementInputHandle() != null) {
        this.GetElementInputHandle().removeEventListener("input",this.FHandleInputPtr);
        this.GetElementInputHandle().removeEventListener("change",this.FHandleChangePtr);
        this.GetElementInputHandle().removeEventListener("paste",this.FHandlePastePtr);
        this.GetElementInputHandle().removeEventListener("cut",this.FHandleCutPtr);
        this.GetElementInputHandle().removeEventListener("invalid",this.FHandleInvalidPtr);
      };
    };
    this.UpdateElementData = function () {
      var ss = 0;
      var sl = 0;
      var e = null;
      pas["WEBLib.Controls"].TControl.UpdateElementData.call(this);
      if ((this.GetElementInputHandle() != null) && !this.FBlockChange) {
        if (this.FRequired) {
          this.GetElementInputHandle().setAttribute("required","")}
         else if (!this.GetIsLinked()) this.GetElementInputHandle().removeAttribute("required");
        this.GetElementInputHandle().value = this.GetDisplayText();
        if (this.GetElementInputHandle().tagName === "TEXTAREA") {
          this.GetElementInputHandle().setSelectionRange(this.GetSelStart(),this.GetSelStart() + this.GetSelLength());
        };
        if (!this.GetIsLinked()) {
          this.GetElementInputHandle().style.setProperty("resize","none");
        };
        this.GetElementInputHandle().readOnly = this.IsReadOnly();
        if (this.FTextHint !== "") this.GetElementInputHandle().placeholder = this.FTextHint;
        if (!this.GetIsLinked()) {
          if (this.FAutoCompletion === $mod.TAutoCompletion.acNone) {
            this.GetElementInputHandle().setAttribute("autocomplete","none");
            if (!this.GetIsLinked()) this.GetElementInputHandle().removeAttribute("name");
          } else if (this.FAutoCompletion !== $mod.TAutoCompletion.acOff) {
            this.GetElementInputHandle().setAttribute("autocomplete","on");
            if (!this.GetIsLinked()) this.GetElementInputHandle().setAttribute("name",$mod.GetAutoCompletionName(this.FAutoCompletion));
          } else {
            this.GetElementInputHandle().removeAttribute("autocomplete");
            if (!this.GetIsLinked()) this.GetElementInputHandle().removeAttribute("name");
          };
          ss = this.FSelStart;
          sl = this.FSelStart + this.FSelLength;
          e = this.GetElementInputHandle();
          setTimeout(function() {
            e.setSelectionRange(ss, sl);
          }, 1);
        };
      };
    };
    this.UpdateElementVisual = function () {
      pas["WEBLib.Controls"].TCustomControl.UpdateElementVisual.call(this);
      if ((this.GetElementInputHandle() != null) && !this.FBlockChange && !this.GetIsLinked()) {
        if (this.FAutoSize) {
          this.GetElementInputHandle().style.setProperty("overflow","hidden");
          this.GetElementInputHandle().style.setProperty("height","auto");
        } else {
          this.GetElementInputHandle().style.setProperty("overflow","auto");
          var $tmp = this.FScrollbars;
          if ($tmp === pas["WEBLib.Controls"].TScrollStyle.ssNone) {
            this.GetElementInputHandle().style.setProperty("overflow","hidden");
          } else if ($tmp === pas["WEBLib.Controls"].TScrollStyle.ssVertical) {
            this.GetElementInputHandle().style.removeProperty("overflow");
            this.GetElementInputHandle().style.setProperty("overflow-x","hidden");
            this.GetElementInputHandle().style.setProperty("overflow-y","auto");
          } else if ($tmp === pas["WEBLib.Controls"].TScrollStyle.ssHorizontal) {
            this.GetElementInputHandle().style.removeProperty("overflow");
            this.GetElementInputHandle().style.setProperty("overflow-x","auto");
            this.GetElementInputHandle().style.setProperty("overflow-y","hidden");
          } else if ($tmp === pas["WEBLib.Controls"].TScrollStyle.ssBoth) {
            this.GetElementInputHandle().style.setProperty("overflow","auto");
          };
        };
        this.GetElementInputHandle().style.setProperty("margin","0");
        if ((this.FColor !== -1) && (this.FColor !== 16711422)) {
          this.GetElementInputHandle().style.setProperty("background-color",pas["WEBLib.Graphics"].ColorToHTML(this.FColor))}
         else this.GetElementInputHandle().style.removeProperty("background-color");
        if (!this.FSpellCheck) {
          this.GetElementInputHandle().setAttribute("spellcheck","false")}
         else if (this.GetElementInputHandle().hasAttribute("spellcheck")) this.GetElementInputHandle().removeAttribute("spellcheck");
        if (!this.FWordWrap) {
          this.GetElementInputHandle().setAttribute("wrap","off")}
         else if (this.GetElementInputHandle().hasAttribute("wrap")) this.GetElementInputHandle().removeAttribute("wrap");
      };
    };
    this.UpdateElementSize = function () {
      pas["WEBLib.Controls"].TControl.UpdateElementSize.call(this);
      if (this.FAutoSize) this.DoAutoSize();
    };
    this.SetLines = function (ALines) {
      this.FLines.Assign(ALines);
    };
    this.ClearMethodPointers = function () {
      pas["WEBLib.Controls"].TControl.ClearMethodPointers.call(this);
      this.FHandleChangePtr = null;
      this.FHandleInputPtr = null;
      this.FHandlePastePtr = null;
      this.FHandleCutPtr = null;
      this.FHandleInvalidPtr = null;
    };
    this.GetMethodPointers = function () {
      pas["WEBLib.Controls"].TControl.GetMethodPointers.call(this);
      this.FHandleChangePtr = rtl.createCallback(this,"DoHandleChange");
      this.FHandleInputPtr = rtl.createCallback(this,"DoHandleInput");
      this.FHandlePastePtr = rtl.createCallback(this,"DoHandlePaste");
      this.FHandleCutPtr = rtl.createCallback(this,"DoHandleCut");
      this.FHandleInvalidPtr = rtl.createCallback(this,"DoHandleInvalid");
    };
    this.DoLinesChange = function (Sender) {
      if ((this.GetElementInputHandle() != null) && !this.FBlockChange) {
        this.GetElementInputHandle().value = this.GetDisplayText();
        this.GetElementInputHandle().readOnly = this.IsReadOnly();
      };
    };
    this.CanPaste = function (AValue) {
      var Result = false;
      Result = true;
      return Result;
    };
    this.CanCut = function () {
      var Result = false;
      Result = true;
      return Result;
    };
    this.SaveState = function () {
      var Result = "";
      Result = this.FLines.GetTextStr();
      return Result;
    };
    this.LoadState = function (AState) {
      this.FLines.SetTextStr(AState);
    };
    this.Change = function () {
      if (this.FOnChange != null) this.FOnChange(this);
    };
    this.SetCaret = function (x, y) {
      var i = 0;
      var l = 0;
      l = 0;
      for (var $l = 0, $end = this.FLines.GetCount() - 1; $l <= $end; $l++) {
        i = $l;
        if (i < y) l = l + this.FLines.Get(i).length + 1;
      };
      this.SetSelStart(l + x);
    };
    this.GetCaret = function () {
      var Result = pas.Types.TPoint.$new();
      var l = 0;
      var i = 0;
      var ll = 0;
      var tl = 0;
      var ss = 0;
      l = 0;
      tl = 0;
      ss = this.GetSelStart();
      for (var $l = 0, $end = this.FLines.GetCount() - 1; $l <= $end; $l++) {
        i = $l;
        ll = this.FLines.Get(i).length + 1;
        if (ss > (tl + ll)) {
          l += 1;
          tl = tl + ll;
        } else {
          break;
        };
      };
      Result.x = ss - tl;
      Result.y = l;
      return Result;
    };
    this.InitCSSLibrary = function (ALibrary) {
      if (ALibrary === pas["WEBLib.Controls"].TCSSLibrary.cssBootstrap) {
        this.SetElementFont(pas["WEBLib.Controls"].TElementFont.efCSS);
        this.SetElementClassName("form-control");
      };
    };
    this.CreateInitialize = function () {
      pas["WEBLib.Controls"].TCustomControl.CreateInitialize.call(this);
      this.FSpellCheck = true;
      this.FLines = pas.Classes.TStringList.$create("Create$1");
      this.FLines.SetSkipLastLineBreak(true);
      this.FLines.FOnChange = rtl.createCallback(this,"DoLinesChange");
      if (pas.Classes.TComponentStateItem.csDesigning in this.FComponentState) {
        this.SetWidth(400);
        this.SetHeight(300);
      };
      this.SetShowFocus(true);
      this.SetClipChildren(false);
      this.FWantTabs = false;
      this.FAutoSize = false;
      this.FAutoCompletion = $mod.TAutoCompletion.acOff;
      this.FWordWrap = true;
      this.FScrollbars = pas["WEBLib.Controls"].TScrollStyle.ssBoth;
      this.FNoUserSelect = false;
    };
    this.Destroy = function () {
      rtl.free(this,"FLines");
      pas["WEBLib.Controls"].TCustomControl.Destroy.call(this);
    };
    this.Clear = function () {
      this.FLines.Clear();
    };
    this.SelectAll = function () {
      if (this.GetElementInputHandle() != null) this.GetElementInputHandle().select();
    };
    this.CopyToClipboard = function () {
      var s = "";
      s = this.GetText();
      navigator.clipboard.writeText(s);
    };
    this.ScrollBy = function (DeltaX, DeltaY) {
      if (this.GetElementHandle() != null) {
        this.GetElementHandle().scrollTop = this.GetElementHandle().scrollTop + DeltaY;
        this.GetElementHandle().scrollLeft = this.GetElementHandle().scrollLeft + DeltaX;
      };
    };
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
  });
  rtl.createClass(this,"TMemo",this.TCustomMemo,function () {
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
    var $r = this.$rtti;
    $r.addProperty("Align",2,pas["WEBLib.Controls"].$rtti["TAlign"],"FAlign","SetAlign",{Default: pas["WEBLib.Controls"].TAlign.alNone});
    $r.addProperty("AlignWithMargins",2,rtl.boolean,"FAlignWithMargins","SetAlignWithMargins",{Default: false});
    $r.addProperty("Anchors",2,pas["WEBLib.Controls"].$rtti["TAnchors"],"FAnchors","SetAnchors",{Default: rtl.createSet(pas["WEBLib.Controls"].TAnchorKind.akLeft,pas["WEBLib.Controls"].TAnchorKind.akTop)});
    $r.addProperty("AutoSize",2,rtl.boolean,"FAutoSize","SetAutoSize");
    $r.addProperty("BiDiMode",2,pas["WEBLib.Controls"].$rtti["TBiDiMode"],"FBiDiMode","SetBiDiMode",{Default: pas["WEBLib.Controls"].TBiDiMode.bdLeftToRight});
    $r.addProperty("BorderStyle",2,pas["WEBLib.Controls"].$rtti["TBorderStyle"],"FBorderStyle","SetBorderStyle",{Default: pas["WEBLib.Controls"].TBorderStyle.bsSingle});
    $r.addProperty("ChildOrder",2,rtl.longint,"FChildOrder","SetChildOrderEx",{Default: 0});
    $r.addProperty("Color",2,pas["WEBLib.Graphics"].$rtti["TColor"],"FColor","SetColor");
    $r.addProperty("DragMode",2,pas["WEBLib.Controls"].$rtti["TDragMode"],"FDragMode","SetDragMode",{Default: pas["WEBLib.Controls"].TDragMode.dmManual});
    $r.addProperty("ElementClassName",2,pas["WEBLib.Controls"].$rtti["TElementClassName"],"FElementClassName","SetElementClassName");
    $r.addProperty("ElementID",3,pas["WEBLib.Controls"].$rtti["TElementID"],"GetID","SetID");
    $r.addProperty("ElementFont",2,pas["WEBLib.Controls"].$rtti["TElementFont"],"FElementFont","SetElementFont",{Default: pas["WEBLib.Controls"].TElementFont.efProperty});
    $r.addProperty("ElementPosition",2,pas["WEBLib.Controls"].$rtti["TElementPosition"],"FElementPosition","SetElementPosition",{Default: pas["WEBLib.Controls"].TElementPosition.epAbsolute});
    $r.addProperty("Enabled",2,rtl.boolean,"FEnabled","SetEnabled",{Default: true});
    $r.addProperty("Font",2,pas["WEBLib.Graphics"].$rtti["TFont"],"FFont","SetFont");
    $r.addProperty("Height",3,rtl.longint,"GetHeight","SetHeight");
    $r.addProperty("HeightPercent",2,rtl.double,"FHeightPercent","SetHeightPercent",{Default: 100});
    $r.addProperty("HeightStyle",2,pas["WEBLib.Controls"].$rtti["TSizeStyle"],"FHeightStyle","SetHeightStyle",{Default: pas["WEBLib.Controls"].TSizeStyle.ssAbsolute});
    $r.addProperty("Hint",2,rtl.string,"FHint","SetHint");
    $r.addProperty("Left",3,rtl.longint,"GetLeft","SetLeft");
    $r.addProperty("Lines",2,pas.Classes.$rtti["TStrings"],"FLines","SetLines");
    $r.addProperty("Margins",2,pas["WEBLib.Controls"].$rtti["TMargins"],"FMargins","SetMargins");
    $r.addProperty("ParentColor",2,rtl.boolean,"FParentColor","SetParentColor",{Default: false});
    $r.addProperty("ParentFont",2,rtl.boolean,"FParentFont","SetParentFont",{Default: true});
    $r.addProperty("PopupMenu",0,pas["WEBLib.Menus"].$rtti["TPopupMenu"],"FPopupMenu","FPopupMenu");
    $r.addProperty("ReadOnly",2,rtl.boolean,"FReadOnly","SetReadOnly");
    $r.addProperty("Required",2,rtl.boolean,"FRequired","SetRequired",{Default: false});
    $r.addProperty("RequiredText",0,rtl.string,"FRequiredText","FRequiredText");
    $r.addProperty("Role",3,rtl.string,"GetRole","SetRole");
    $r.addProperty("SelStart",3,rtl.longint,"GetSelStart","SetSelStart");
    $r.addProperty("SelLength",3,rtl.longint,"GetSelLength","SetSelLength");
    $r.addProperty("ShowFocus",2,rtl.boolean,"FShowFocus","SetShowFocus",{Default: false});
    $r.addProperty("ShowHint",2,rtl.boolean,"FShowHint","SetShowHint",{Default: false});
    $r.addProperty("Spellcheck",2,rtl.boolean,"FSpellCheck","SetSpellCheck",{Default: true});
    $r.addProperty("TabOrder",2,rtl.longint,"FTabOrder","SetTabOrder");
    $r.addProperty("TabStop",2,rtl.boolean,"FTabStop","SetTabStop",{Default: true});
    $r.addProperty("TextDirection",0,pas["WEBLib.Controls"].$rtti["TTextDirection"],"FTextDirection","FTextDirection",{Default: pas["WEBLib.Controls"].TTextDirection.tdDefault});
    $r.addProperty("Top",3,rtl.longint,"GetTop","SetTop");
    $r.addProperty("Visible",2,rtl.boolean,"FVisible","SetVisible",{Default: true});
    $r.addProperty("Width",3,rtl.longint,"GetWidth","SetWidth");
    $r.addProperty("WidthPercent",2,rtl.double,"FWidthPercent","SetWidthPercent",{Default: 100});
    $r.addProperty("WidthStyle",2,pas["WEBLib.Controls"].$rtti["TSizeStyle"],"FWidthStyle","SetWidthStyle",{Default: pas["WEBLib.Controls"].TSizeStyle.ssAbsolute});
    $r.addProperty("OnChange",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnChange","FOnChange");
    $r.addProperty("OnClick",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnClick","FOnClick");
    $r.addProperty("OnDblClick",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnDblClick","FOnDblClick");
    $r.addProperty("OnKeyDown",0,pas["WEBLib.Controls"].$rtti["TKeyEvent"],"FOnKeyDown","FOnKeyDown");
    $r.addProperty("OnKeyPress",0,pas["WEBLib.Controls"].$rtti["TKeyPressEvent"],"FOnKeyPress","FOnKeyPress");
    $r.addProperty("OnKeyUp",0,pas["WEBLib.Controls"].$rtti["TKeyEvent"],"FOnKeyUp","FOnKeyUp");
    $r.addProperty("OnMouseDown",0,pas["WEBLib.Controls"].$rtti["TMouseEvent"],"FOnMouseDown","FOnMouseDown");
    $r.addProperty("OnMouseUp",0,pas["WEBLib.Controls"].$rtti["TMouseEvent"],"FOnMouseUp","FOnMouseUp");
    $r.addProperty("OnMouseMove",0,pas["WEBLib.Controls"].$rtti["TMouseMoveEvent"],"FOnMouseMove","FOnMouseMove");
    $r.addProperty("OnMouseLeave",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnMouseLeave","FOnMouseLeave");
    $r.addProperty("OnMouseEnter",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnMouseEnter","FOnMouseEnter");
    $r.addProperty("OnMouseWheel",0,pas["WEBLib.Controls"].$rtti["TMouseWheelEvent"],"FOnMouseWheel","FOnMouseWheel");
    $r.addProperty("OnEnter",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnEnter","FOnEnter");
    $r.addProperty("OnExit",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnExit","FOnExit");
    $r.addProperty("OnDragDrop",0,pas["WEBLib.Controls"].$rtti["TDragDropEvent"],"FOnDragDrop","FOnDragDrop");
    $r.addProperty("OnDragOver",0,pas["WEBLib.Controls"].$rtti["TDragOverEvent"],"FOnDragOver","FOnDragOver");
    $r.addProperty("OnEndDrag",0,pas["WEBLib.Controls"].$rtti["TEndDragEvent"],"FonEndDrag","FonEndDrag");
    $r.addProperty("OnStartDrag",0,pas["WEBLib.Controls"].$rtti["TStartDragEvent"],"FOnStartDrag","FOnStartDrag");
  });
  rtl.createClass(this,"TWebMemo",this.TMemo,function () {
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
  });
  rtl.createClass(this,"TControlGroup",pas["WEBLib.Menus"].TWebCustomControl,function () {
    this.$init = function () {
      pas["WEBLib.Menus"].TWebCustomControl.$init.call(this);
      this.FControls$1 = null;
      this.FOldCount = 0;
      this.FColumns = 0;
      this.FItems = null;
      this.FOnChange = null;
      this.FElementButtonClassName = "";
      this.FElementLabelClassName = "";
      this.FElementGroupClassName = "";
      this.FControlPosition = 0;
      this.FElementLegendClassName = "";
    };
    this.$final = function () {
      this.FControls$1 = undefined;
      this.FItems = undefined;
      this.FOnChange = undefined;
      pas["WEBLib.Menus"].TWebCustomControl.$final.call(this);
    };
    this.SetControlPosition = function (Value) {
      if (this.FControlPosition !== Value) {
        this.FControlPosition = Value;
        this.DoUpdateList();
      };
    };
    this.CreateElement = function () {
      var Result = null;
      var legend = null;
      Result = document.createElement("FIELDSET");
      legend = document.createElement("LEGEND");
      Result.appendChild(legend);
      legend.innerHTML = this.FCaption;
      legend.setAttribute("class","w-auto " + this.FElementLegendClassName);
      if (this.FCaption === "") {
        legend.style.setProperty("display","none")}
       else legend.style.setProperty("display","");
      legend.style.setProperty("float","none");
      Result.style.setProperty("display","inline-block");
      Result.style.setProperty("-webkit-padding-before","0px");
      Result.style.setProperty("-webkit-padding-after","0px");
      Result.style.setProperty("-webkit-padding-end","0px");
      Result.style.setProperty("-webkit-padding-start","0px");
      Result.style.setProperty("border","1px");
      return Result;
    };
    this.DoHandleChange = function (Event) {
      var Result = false;
      this.Change();
      Result = true;
      return Result;
    };
    this.DoHandleClick = function (AControl) {
      this.Change();
    };
    this.DoItemsChange = function (Sender) {
      this.DoUpdateList();
    };
    this.DoControlClick = function (Sender) {
      this.DoHandleClick(rtl.as(Sender,pas["WEBLib.Controls"].TCustomControl));
    };
    this.SetCaption = function (AValue) {
      var el = null;
      pas["WEBLib.Controls"].TCustomControl.SetCaption.call(this,AValue);
      if (!(this.GetContainer() != null)) return;
      el = this.GetContainer().firstElementChild;
      if (el != null) {
        el.innerHTML = AValue;
        if (AValue === "") {
          el.style.setProperty("display","none")}
         else el.style.setProperty("display","");
      };
    };
    this.SetColumns = function (AValue) {
      if ((this.FColumns > 0) && (this.FColumns !== AValue)) {
        this.FColumns = AValue;
        this.DoUpdateList();
      };
    };
    this.SetItems = function (AItems) {
      this.FItems.Assign(AItems);
      this.DoUpdateList();
    };
    this.DoUpdateList = function () {
      var i = 0;
      var s = "";
      var rd = null;
      var dx = 0;
      var dy = 0;
      var dc = 0;
      var col = 0;
      var row = 0;
      var ypos = 0;
      var legend = null;
      var chk = [];
      if (!(this.GetContainer() != null)) return;
      if (this.FItems.GetCount() === 0) return;
      dy = Math.round(this.FFont.FSize * 2.5);
      dx = rtl.trunc(this.GetWidth() / this.FColumns);
      if (this.FCaption !== "") {
        dc = this.FFont.FSize}
       else dc = 4;
      col = 0;
      row = 0;
      if (this.FOldCount > 0) chk = rtl.arraySetLength(chk,false,this.FOldCount);
      for (var $l = 0, $end = this.FOldCount - 1; $l <= $end; $l++) {
        i = $l;
        rd = rtl.getObject(this.FControls$1.Get(i));
        if ($mod.TRadioButton.isPrototypeOf(rd)) chk[i] = rtl.as(rd,$mod.TRadioButton).GetChecked();
        if ($mod.TCheckBox.isPrototypeOf(rd)) chk[i] = rtl.as(rd,$mod.TCheckBox).GetChecked();
        rd = rtl.freeLoc(rd);
      };
      this.FControls$1.Clear();
      while (this.GetContainer().childElementCount > 0) this.GetContainer().removeChild(this.GetContainer().firstChild);
      if (this.FCaption !== "") {
        legend = document.createElement("LEGEND");
        this.GetElementHandle().appendChild(legend);
        legend.innerHTML = this.FCaption;
        legend.setAttribute("class","w-auto " + this.FElementLegendClassName);
        legend.style.setProperty("float","none");
        pas["WEBLib.Controls"].SetHTMLElementFont(legend,this.FFont,!((this.FElementFont === pas["WEBLib.Controls"].TElementFont.efProperty) && (this.FElementClassName === "")));
      };
      if (this.FElementGroupClassName !== "") {
        this.GetElementHandle().setAttribute("class",this.FElementGroupClassName)}
       else this.GetElementHandle().setAttribute("class","border p-2");
      this.GetContainer().style.setProperty("margin","0px");
      for (var $l1 = 0, $end1 = this.FItems.GetCount() - 1; $l1 <= $end1; $l1++) {
        i = $l1;
        ypos = dc + (row * dy);
        s = this.FItems.Get(i);
        rd = this.CreateGroupControl(4 + (col * dx),ypos,i,s,this.FControlPosition,this.GetGroupControlState(i),true);
        rd.SetEnabled(this.FEnabled);
        this.FControls$1.Add(rd);
        if (i <= this.FOldCount) {
          if ($mod.TRadioButton.isPrototypeOf(rd)) rtl.as(rd,$mod.TRadioButton).SetChecked(chk[i]);
          if ($mod.TCheckBox.isPrototypeOf(rd)) rtl.as(rd,$mod.TCheckBox).SetChecked(chk[i]);
        };
        if (!this.GetIsLinked()) {
          rd.GetContainer().style.setProperty("float","left");
          rd.GetContainer().style.setProperty("width",pas.SysUtils.IntToStr(pas.System.Trunc(100 / this.FColumns) - 5) + "%");
          if (this.FTabStop) {
            rd.GetContainer().setAttribute("tabindex",pas.SysUtils.TIntegerHelper.ToString$1.call({p: this, get: function () {
                return this.p.FTabOrder;
              }, set: function (v) {
                this.p.FTabOrder = v;
              }}));
            this.GetContainer().setAttribute("tabindex","-1");
          } else rd.GetContainer().setAttribute("tabindex","-1");
        };
        if ((i % this.FColumns) === 0) rd.GetContainer().style.setProperty("clear","left");
        this.GetElementHandle().appendChild(rd.GetContainer());
        if (col < (this.FColumns - 1)) {
          col += 1}
         else {
          col = 0;
          row += 1;
        };
      };
      this.FOldCount = this.FItems.GetCount();
    };
    this.Change = function () {
      if (this.FOnChange != null) this.FOnChange(this);
    };
    this.Loaded = function () {
      pas["WEBLib.Controls"].TCustomControl.Loaded.call(this);
      this.DoUpdateList();
    };
    this.FontChanged = function () {
      pas["WEBLib.Controls"].TControl.FontChanged.call(this);
      this.DoUpdateList();
    };
    this.CreateGroupControl = function (ALeft, ATop, AIndex, ACaption, APosition, AState, AEnabled) {
      var Result = null;
      Result = null;
      return Result;
    };
    this.GetGroupControlState = function (AIndex) {
      var Result = false;
      Result = false;
      return Result;
    };
    this.GetGroupControl = function (AIndex) {
      var Result = null;
      Result = rtl.getObject(this.FControls$1.Get(AIndex));
      return Result;
    };
    this.SetEnabled = function (Value) {
      var i = 0;
      pas["WEBLib.Controls"].TControl.SetEnabled.apply(this,arguments);
      for (var $l = 0, $end = this.FControls$1.GetCount() - 1; $l <= $end; $l++) {
        i = $l;
        rtl.getObject(this.FControls$1.Get(i)).SetEnabled(Value);
      };
    };
    this.CreateInitialize = function () {
      pas["WEBLib.Controls"].TCustomControl.CreateInitialize.call(this);
      this.FColumns = 1;
      this.FControls$1 = pas.Classes.TList.$create("Create$1");
      this.FItems = pas.Classes.TStringList.$create("Create$1");
      this.FItems.FOnChange = rtl.createCallback(this,"DoItemsChange");
      this.FOldCount = -1;
      this.FControlPosition = pas["WEBLib.Controls"].TElementPosition.epAbsolute;
      if (pas.Classes.TComponentStateItem.csDesigning in this.FComponentState) {
        this.SetWidth(200);
        this.SetHeight(200);
      };
    };
    this.Destroy = function () {
      rtl.free(this,"FControls$1");
      rtl.free(this,"FItems");
      pas["WEBLib.Controls"].TCustomControl.Destroy.call(this);
    };
    this.EndUpdate = function () {
      pas["WEBLib.Controls"].TCustomControl.EndUpdate.call(this);
      this.DoUpdateList();
    };
    this.SetHeight = function (AValue) {
      pas["WEBLib.Controls"].TControl.SetHeight.apply(this,arguments);
      this.DoUpdateList();
    };
    this.SetWidth = function (AValue) {
      pas["WEBLib.Controls"].TControl.SetWidth.apply(this,arguments);
      this.DoUpdateList();
    };
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
    var $r = this.$rtti;
    $r.addProperty("Align",2,pas["WEBLib.Controls"].$rtti["TAlign"],"FAlign","SetAlign",{Default: pas["WEBLib.Controls"].TAlign.alNone});
    $r.addProperty("AlignWithMargins",2,rtl.boolean,"FAlignWithMargins","SetAlignWithMargins",{Default: false});
    $r.addProperty("Anchors",2,pas["WEBLib.Controls"].$rtti["TAnchors"],"FAnchors","SetAnchors",{Default: rtl.createSet(pas["WEBLib.Controls"].TAnchorKind.akLeft,pas["WEBLib.Controls"].TAnchorKind.akTop)});
    $r.addProperty("Caption",2,rtl.string,"FCaption","SetCaption");
    $r.addProperty("ChildOrder",2,rtl.longint,"FChildOrder","SetChildOrderEx",{Default: 0});
    $r.addProperty("Columns",2,rtl.longint,"FColumns","SetColumns");
    $r.addProperty("ControlPosition",2,pas["WEBLib.Controls"].$rtti["TElementPosition"],"FControlPosition","SetControlPosition",{Default: pas["WEBLib.Controls"].TElementPosition.epAbsolute});
    $r.addProperty("DragMode",2,pas["WEBLib.Controls"].$rtti["TDragMode"],"FDragMode","SetDragMode",{Default: pas["WEBLib.Controls"].TDragMode.dmManual});
    $r.addProperty("ElementClassName",2,pas["WEBLib.Controls"].$rtti["TElementClassName"],"FElementClassName","SetElementClassName");
    $r.addProperty("ElementButtonClassName",0,pas["WEBLib.Controls"].$rtti["TElementClassName"],"FElementButtonClassName","FElementButtonClassName");
    $r.addProperty("ElementGroupClassName",0,pas["WEBLib.Controls"].$rtti["TElementClassName"],"FElementGroupClassName","FElementGroupClassName");
    $r.addProperty("ElementLabelClassName",0,pas["WEBLib.Controls"].$rtti["TElementClassName"],"FElementLabelClassName","FElementLabelClassName");
    $r.addProperty("ElementLegendClassName",0,pas["WEBLib.Controls"].$rtti["TElementClassName"],"FElementLegendClassName","FElementLegendClassName");
    $r.addProperty("ElementID",3,pas["WEBLib.Controls"].$rtti["TElementID"],"GetID","SetID");
    $r.addProperty("ElementFont",2,pas["WEBLib.Controls"].$rtti["TElementFont"],"FElementFont","SetElementFont",{Default: pas["WEBLib.Controls"].TElementFont.efProperty});
    $r.addProperty("ElementPosition",2,pas["WEBLib.Controls"].$rtti["TElementPosition"],"FElementPosition","SetElementPosition",{Default: pas["WEBLib.Controls"].TElementPosition.epAbsolute});
    $r.addProperty("Enabled",2,rtl.boolean,"FEnabled","SetEnabled",{Default: true});
    $r.addProperty("Font",2,pas["WEBLib.Graphics"].$rtti["TFont"],"FFont","SetFont");
    $r.addProperty("Height",3,rtl.longint,"GetHeight","SetHeight");
    $r.addProperty("HeightPercent",2,rtl.double,"FHeightPercent","SetHeightPercent",{Default: 100});
    $r.addProperty("HeightStyle",2,pas["WEBLib.Controls"].$rtti["TSizeStyle"],"FHeightStyle","SetHeightStyle",{Default: pas["WEBLib.Controls"].TSizeStyle.ssAbsolute});
    $r.addProperty("Items",2,pas.Classes.$rtti["TStrings"],"FItems","SetItems");
    $r.addProperty("Margins",2,pas["WEBLib.Controls"].$rtti["TMargins"],"FMargins","SetMargins");
    $r.addProperty("ParentFont",2,rtl.boolean,"FParentFont","SetParentFont",{Default: true});
    $r.addProperty("PopupMenu",0,pas["WEBLib.Menus"].$rtti["TPopupMenu"],"FPopupMenu","FPopupMenu");
    $r.addProperty("Role",3,rtl.string,"GetRole","SetRole");
    $r.addProperty("TabStop",2,rtl.boolean,"FTabStop","SetTabStop",{Default: true});
    $r.addProperty("TabOrder",2,rtl.longint,"FTabOrder","SetTabOrder");
    $r.addProperty("Visible",2,rtl.boolean,"FVisible","SetVisible",{Default: true});
    $r.addProperty("Width",3,rtl.longint,"GetWidth","SetWidth");
    $r.addProperty("WidthPercent",2,rtl.double,"FWidthPercent","SetWidthPercent",{Default: 100});
    $r.addProperty("WidthStyle",2,pas["WEBLib.Controls"].$rtti["TSizeStyle"],"FWidthStyle","SetWidthStyle",{Default: pas["WEBLib.Controls"].TSizeStyle.ssAbsolute});
    $r.addProperty("OnChange",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnChange","FOnChange");
    $r.addProperty("OnDragDrop",0,pas["WEBLib.Controls"].$rtti["TDragDropEvent"],"FOnDragDrop","FOnDragDrop");
    $r.addProperty("OnDragOver",0,pas["WEBLib.Controls"].$rtti["TDragOverEvent"],"FOnDragOver","FOnDragOver");
    $r.addProperty("OnEndDrag",0,pas["WEBLib.Controls"].$rtti["TEndDragEvent"],"FonEndDrag","FonEndDrag");
    $r.addProperty("OnStartDrag",0,pas["WEBLib.Controls"].$rtti["TStartDragEvent"],"FOnStartDrag","FOnStartDrag");
  });
  rtl.createClass(this,"TRadioGroup",this.TControlGroup,function () {
    this.$init = function () {
      $mod.TControlGroup.$init.call(this);
      this.FItemIndex = 0;
      this.FOldItemIndex = 0;
    };
    this.DoHandleClick = function (AControl) {
      if (this.GetItemIndex() === this.FOldItemIndex) return;
      this.Change();
      this.FOldItemIndex = this.GetItemIndex();
    };
    this.GetItemIndex = function () {
      var Result = 0;
      var el = null;
      var i = 0;
      Result = this.FItemIndex;
      for (var $l = 0, $end = this.FItems.GetCount() - 1; $l <= $end; $l++) {
        i = $l;
        el = document.getElementById(this.GetID() + pas.SysUtils.IntToStr(i) + "rd");
        if (el != null) {
          if (el.checked) Result = i;
        };
      };
      return Result;
    };
    this.SetItemIndex = function (AIndex) {
      var el = null;
      if ((AIndex === -1) && (this.GetItemIndex() >= 0)) {
        el = document.getElementById(this.GetID() + pas.SysUtils.IntToStr(this.GetItemIndex()) + "rd");
        if (el != null) el.checked = false;
        this.FItemIndex = -1;
      } else {
        this.FItemIndex = AIndex;
        if ((AIndex >= 0) && (AIndex < this.FItems.GetCount())) {
          el = document.getElementById(this.GetID() + pas.SysUtils.IntToStr(AIndex) + "rd");
          if (el != null) el.checked = true;
        };
      };
    };
    this.CreateGroupControl = function (ALeft, ATop, AIndex, ACaption, APosition, AState, AEnabled) {
      var Result = null;
      var rd = null;
      var id = "";
      id = this.GetID();
      if (id === "") id = this.FName;
      rd = $mod.TRadioButton.$create("Create$2",[id + pas.SysUtils.IntToStr(AIndex)]);
      rd.SetElementPosition(APosition);
      rd.SetElementFont(this.FElementFont);
      rd.SetElementClassName(this.FElementClassName);
      rd.FElementButtonClassName = this.FElementButtonClassName;
      rd.FElementLabelClassName = this.FElementLabelClassName;
      rd.SetHeightStyle(pas["WEBLib.Controls"].TSizeStyle.ssAuto);
      rd.SetParentFont(false);
      rd.FFont.Assign(this.FFont);
      rd.SetParent(this);
      rd.SetCaption(ACaption);
      rd.SetGroupName(id);
      rd.SetTop(ATop);
      rd.SetLeft(ALeft);
      rd.SetWidthStyle(pas["WEBLib.Controls"].TSizeStyle.ssAuto);
      rd.SetWidthPercent(100);
      rd.FOnClick = rtl.createCallback(this,"DoControlClick");
      rd.SetChecked(AState);
      rd.SetEnabled(AEnabled);
      rd.FTag$1 = AIndex;
      rd.SetTabStop(true);
      Result = rd;
      return Result;
    };
    this.GetGroupControlState = function (AIndex) {
      var Result = false;
      Result = AIndex === this.FItemIndex;
      return Result;
    };
    this.LoadState = function (AState) {
      var idx = 0;
      var e = 0;
      pas.System.val$6(AState,{get: function () {
          return idx;
        }, set: function (v) {
          idx = v;
        }},{get: function () {
          return e;
        }, set: function (v) {
          e = v;
        }});
      if (e === 0) this.SetItemIndex(idx);
    };
    this.SaveState = function () {
      var Result = "";
      Result = pas.SysUtils.IntToStr(this.GetItemIndex());
      return Result;
    };
    this.CreateInitialize = function () {
      $mod.TControlGroup.CreateInitialize.call(this);
      this.FItemIndex = -1;
      this.FOldItemIndex = -2;
    };
    this.SetFocus = function () {
      var idx = 0;
      var rd = null;
      if (this.FItems.GetCount() === 0) return;
      idx = this.GetItemIndex();
      if (idx < 0) idx = 0;
      rd = this.GetGroupControl(idx);
      if (rd != null) rd.SetFocus();
    };
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
    var $r = this.$rtti;
    $r.addProperty("ItemIndex",3,rtl.longint,"GetItemIndex","SetItemIndex");
  });
  rtl.createClass(this,"TWebRadioGroup",this.TRadioGroup,function () {
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
  });
  this.$rtti.$MethodVar("TCheckClickEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["AIndex",rtl.longint]]), methodkind: 0});
  rtl.createClass(this,"TCheckGroup",this.TControlGroup,function () {
    this.$init = function () {
      $mod.TControlGroup.$init.call(this);
      this.FOnCheckClick = null;
    };
    this.$final = function () {
      this.FOnCheckClick = undefined;
      $mod.TControlGroup.$final.call(this);
    };
    this.GetChecked = function (AIndex) {
      var Result = false;
      Result = rtl.as(this.GetGroupControl(AIndex),$mod.TCheckBox).GetChecked();
      return Result;
    };
    this.SetChecked = function (AIndex, Value) {
      rtl.as(this.GetGroupControl(AIndex),$mod.TCheckBox).SetChecked(Value);
    };
    this.DoHandleClick = function (AControl) {
      $mod.TControlGroup.DoHandleClick.apply(this,arguments);
      if (this.FOnCheckClick != null) this.FOnCheckClick(this,AControl.FTag$1);
    };
    this.CreateGroupControl = function (ALeft, ATop, AIndex, ACaption, APosition, AState, AEnabled) {
      var Result = null;
      var cb = null;
      var id = "";
      id = this.GetID();
      if (id === "") id = this.FName;
      cb = $mod.TCheckBox.$create("Create$2",[id + pas.SysUtils.IntToStr(AIndex)]);
      cb.SetCaption(ACaption);
      cb.SetElementPosition(APosition);
      cb.SetElementFont(this.FElementFont);
      cb.SetElementClassName(this.FElementClassName);
      cb.FElementButtonClassName = this.FElementButtonClassName;
      cb.FElementLabelClassName = this.FElementLabelClassName;
      cb.SetParentFont(false);
      cb.FFont.Assign(this.FFont);
      cb.SetParent(this);
      cb.SetTop(ATop);
      cb.SetLeft(ALeft);
      cb.SetWidthStyle(pas["WEBLib.Controls"].TSizeStyle.ssPercent);
      cb.SetWidthPercent(100);
      cb.SetHeightStyle(pas["WEBLib.Controls"].TSizeStyle.ssAuto);
      cb.FOnCheckClick = rtl.createCallback(this,"DoControlClick");
      cb.SetChecked(AState);
      cb.SetEnabled(AEnabled);
      cb.FTag$1 = AIndex;
      cb.SetTabStop(true);
      Result = cb;
      return Result;
    };
    this.GetGroupControlState = function (AIndex) {
      var Result = false;
      Result = false;
      return Result;
    };
    this.SaveState = function () {
      var Result = "";
      var i = 0;
      var s = "";
      s = "";
      for (var $l = 0, $end = this.FItems.GetCount() - 1; $l <= $end; $l++) {
        i = $l;
        if (this.GetChecked(i)) {
          s = s + ",1"}
         else s = s + ",0";
      };
      pas.System.Delete({get: function () {
          return s;
        }, set: function (v) {
          s = v;
        }},1,1);
      Result = s;
      return Result;
    };
    this.LoadState = function (AState) {
      var sl = null;
      var i = 0;
      sl = pas.Classes.TStringList.$create("Create$1");
      sl.SetDelimiter(",");
      sl.SetCommaText(AState);
      for (var $l = 0, $end = sl.GetCount() - 1; $l <= $end; $l++) {
        i = $l;
        this.SetChecked(i,sl.Get(i) === "1");
      };
      sl = rtl.freeLoc(sl);
    };
    this.CreateInitialize = function () {
      $mod.TControlGroup.CreateInitialize.call(this);
    };
    this.SetFocus = function () {
      var cb = null;
      if (this.FItems.GetCount() > 0) {
        cb = this.GetGroupControl(0);
        if (cb != null) cb.SetFocus();
      };
    };
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
    var $r = this.$rtti;
    $r.addProperty("OnCheckClick",0,$mod.$rtti["TCheckClickEvent"],"FOnCheckClick","FOnCheckClick");
  });
  rtl.createClass(this,"TWebCheckGroup",this.TCheckGroup,function () {
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
  });
  rtl.createClass(this,"TColorPicker",this.TCustomInput,function () {
    this.$init = function () {
      $mod.TCustomInput.$init.call(this);
      this.FColor$1 = 0;
      this.FOnSelect = null;
      this.FHandleChangePtr = null;
    };
    this.$final = function () {
      this.FOnSelect = undefined;
      $mod.TCustomInput.$final.call(this);
    };
    this.GetElementInputHandle = function () {
      var Result = null;
      Result = this.GetContainer();
      return Result;
    };
    this.UpdateElementVisual = function () {
      $mod.TCustomInput.UpdateElementVisual.call(this);
      if (this.GetElementHandle() != null) {
        this.GetElementHandle().style.setProperty("padding","0px");
        this.GetElementHandle().style.setProperty("width",pas.SysUtils.IntToStr(this.GetWidth() - 2) + "px");
        this.GetElementHandle().style.setProperty("height",pas.SysUtils.IntToStr(this.GetHeight() - 2) + "px");
        this.GetElementHandle().style.setProperty("min-width","32px");
      };
    };
    this.DoHandleChange = function (Event) {
      var Result = false;
      this.Select();
      Result = true;
      return Result;
    };
    this.GetInputType = function () {
      var Result = "";
      Result = "COLOR";
      return Result;
    };
    this.GetColor = function () {
      var Result = 0;
      Result = this.FColor$1;
      if (this.GetContainer() != null) Result = pas["WEBLib.Graphics"].HexToColor(this.GetContainer().value);
      return Result;
    };
    this.SetColor$1 = function (AValue) {
      this.FColor$1 = AValue;
      if (this.GetContainer() != null) this.GetContainer().value = pas["WEBLib.Graphics"].ColorToHTML(AValue);
    };
    this.BindEvents = function () {
      pas["WEBLib.Controls"].TCustomControl.BindEvents.call(this);
      if (this.GetElementInputHandle() != null) {
        this.GetElementInputHandle().addEventListener("input",this.FHandleChangePtr);
      };
    };
    this.UnbindEvents = function () {
      pas["WEBLib.Controls"].TControl.UnbindEvents.call(this);
      if (this.GetElementInputHandle() != null) {
        this.GetElementInputHandle().removeEventListener("input",this.FHandleChangePtr);
      };
    };
    this.Select = function () {
      if (this.FOnSelect != null) this.FOnSelect(this);
    };
    this.ClearMethodPointers = function () {
      pas["WEBLib.Controls"].TControl.ClearMethodPointers.call(this);
      this.FHandleChangePtr = null;
    };
    this.GetMethodPointers = function () {
      pas["WEBLib.Controls"].TControl.GetMethodPointers.call(this);
      this.FHandleChangePtr = rtl.createCallback(this,"DoHandleChange");
    };
    this.InitCSSLibrary = function (ALibrary) {
      if (ALibrary === pas["WEBLib.Controls"].TCSSLibrary.cssBootstrap) {
        this.SetElementClassName("form-control");
        this.SetElementFont(pas["WEBLib.Controls"].TElementFont.efCSS);
        this.SetHeightStyle(pas["WEBLib.Controls"].TSizeStyle.ssAuto);
      };
    };
    this.CreateInitialize = function () {
      $mod.TCustomInput.CreateInitialize.call(this);
      this.FColor$1 = 0;
    };
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
    var $r = this.$rtti;
    $r.addProperty("Align",2,pas["WEBLib.Controls"].$rtti["TAlign"],"FAlign","SetAlign",{Default: pas["WEBLib.Controls"].TAlign.alNone});
    $r.addProperty("AlignWithMargins",2,rtl.boolean,"FAlignWithMargins","SetAlignWithMargins",{Default: false});
    $r.addProperty("Anchors",2,pas["WEBLib.Controls"].$rtti["TAnchors"],"FAnchors","SetAnchors",{Default: rtl.createSet(pas["WEBLib.Controls"].TAnchorKind.akLeft,pas["WEBLib.Controls"].TAnchorKind.akTop)});
    $r.addProperty("ChildOrder",2,rtl.longint,"FChildOrder","SetChildOrderEx",{Default: 0});
    $r.addProperty("Color",3,pas["WEBLib.Graphics"].$rtti["TColor"],"GetColor","SetColor$1");
    $r.addProperty("DragMode",2,pas["WEBLib.Controls"].$rtti["TDragMode"],"FDragMode","SetDragMode",{Default: pas["WEBLib.Controls"].TDragMode.dmManual});
    $r.addProperty("ElementClassName",2,pas["WEBLib.Controls"].$rtti["TElementClassName"],"FElementClassName","SetElementClassName");
    $r.addProperty("ElementID",3,pas["WEBLib.Controls"].$rtti["TElementID"],"GetID","SetID");
    $r.addProperty("ElementFont",2,pas["WEBLib.Controls"].$rtti["TElementFont"],"FElementFont","SetElementFont",{Default: pas["WEBLib.Controls"].TElementFont.efProperty});
    $r.addProperty("ElementPosition",2,pas["WEBLib.Controls"].$rtti["TElementPosition"],"FElementPosition","SetElementPosition",{Default: pas["WEBLib.Controls"].TElementPosition.epAbsolute});
    $r.addProperty("Enabled",2,rtl.boolean,"FEnabled","SetEnabled",{Default: true});
    $r.addProperty("Height",3,rtl.longint,"GetHeight","SetHeight");
    $r.addProperty("HeightPercent",2,rtl.double,"FHeightPercent","SetHeightPercent",{Default: 100});
    $r.addProperty("Left",3,rtl.longint,"GetLeft","SetLeft");
    $r.addProperty("Margins",2,pas["WEBLib.Controls"].$rtti["TMargins"],"FMargins","SetMargins");
    $r.addProperty("Role",3,rtl.string,"GetRole","SetRole");
    $r.addProperty("Top",3,rtl.longint,"GetTop","SetTop");
    $r.addProperty("Visible",2,rtl.boolean,"FVisible","SetVisible",{Default: true});
    $r.addProperty("Width",3,rtl.longint,"GetWidth","SetWidth");
    $r.addProperty("WidthPercent",2,rtl.double,"FWidthPercent","SetWidthPercent",{Default: 100});
    $r.addProperty("OnClick",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnClick","FOnClick");
    $r.addProperty("OnSelect",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnSelect","FOnSelect");
    $r.addProperty("OnDragDrop",0,pas["WEBLib.Controls"].$rtti["TDragDropEvent"],"FOnDragDrop","FOnDragDrop");
    $r.addProperty("OnDragOver",0,pas["WEBLib.Controls"].$rtti["TDragOverEvent"],"FOnDragOver","FOnDragOver");
    $r.addProperty("OnEndDrag",0,pas["WEBLib.Controls"].$rtti["TEndDragEvent"],"FonEndDrag","FonEndDrag");
    $r.addProperty("OnStartDrag",0,pas["WEBLib.Controls"].$rtti["TStartDragEvent"],"FOnStartDrag","FOnStartDrag");
  });
  rtl.createClass(this,"TWebColorPicker",this.TColorPicker,function () {
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
  });
  rtl.createClass(this,"TScrollBarContent",pas["WEBLib.Controls"].TCustomControl,function () {
    this.CreateElement = function () {
      var Result = null;
      Result = document.createElement("SPAN");
      return Result;
    };
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
  });
  rtl.createClass(this,"TScrollBar",pas["WEBLib.Controls"].TCustomControl,function () {
    this.$init = function () {
      pas["WEBLib.Controls"].TCustomControl.$init.call(this);
      this.FBlockScrolling = false;
      this.FScrolling = false;
      this.FContent = null;
      this.FKind = 0;
      this.FPosition = 0;
      this.FSmallChange = 0;
      this.FMax = 0;
      this.FMin = 0;
      this.FLargeChange = 0;
      this.FPageSize = 0;
      this.FOnChange = null;
      this.FScrollPtr = null;
    };
    this.$final = function () {
      this.FContent = undefined;
      this.FOnChange = undefined;
      pas["WEBLib.Controls"].TCustomControl.$final.call(this);
    };
    this.SetKind = function (Value) {
      if (this.FKind !== Value) {
        this.FKind = Value;
        var $tmp = this.FKind;
        if ($tmp === pas["WEBLib.Controls"].TScrollBarKind.sbHorizontal) {
          this.SetBounds(this.GetLeft(),this.GetTop(),this.GetHeight(),17);
        } else if ($tmp === pas["WEBLib.Controls"].TScrollBarKind.sbVertical) {
          this.SetBounds(this.GetLeft(),this.GetTop(),17,this.GetWidth());
        };
        this.UpdateElement();
        this.UpdateContent();
      };
    };
    this.SetPosition = function (Value) {
      if (this.FPosition !== Value) {
        this.FPosition = Value;
        this.UpdateContent();
      };
    };
    this.SetMax = function (Value) {
      if (this.FMax !== Value) {
        this.FMax = Value;
        this.UpdateContent();
      };
    };
    this.SetMin = function (Value) {
      if (this.FMin !== Value) {
        this.FMin = Value;
        this.UpdateContent();
      };
    };
    this.SetPageSize = function (Value) {
      if (this.FPageSize !== Value) {
        this.FPageSize = Value;
        this.UpdateContent();
      };
    };
    this.GetPosition = function () {
      var Result = 0;
      Result = 0;
      if (this.GetElement() != null) {
        var $tmp = this.FKind;
        if ($tmp === pas["WEBLib.Controls"].TScrollBarKind.sbHorizontal) {
          Result = Math.round(this.GetValue(this.GetElement().scrollLeft))}
         else if ($tmp === pas["WEBLib.Controls"].TScrollBarKind.sbVertical) Result = Math.round(this.GetValue(this.GetElement().scrollTop));
      } else Result = this.FPosition;
      return Result;
    };
    this.GetPageSize = function () {
      var Result = 0;
      Result = this.FPageSize;
      if (Result === 0) Result = 25;
      return Result;
    };
    this.GetValue = function (XYPos) {
      var Result = 0.0;
      Result = 0;
      if (this.FContent != null) {
        var $tmp = this.FKind;
        if ($tmp === pas["WEBLib.Controls"].TScrollBarKind.sbHorizontal) {
          if (this.FContent.GetWidth() > 0) Result = (XYPos / this.FContent.GetWidth()) * (this.FMax - this.FMin);
        } else if ($tmp === pas["WEBLib.Controls"].TScrollBarKind.sbVertical) {
          if (this.FContent.GetHeight() > 0) Result = (XYPos / this.FContent.GetHeight()) * (this.FMax - this.FMin);
        };
      };
      return Result;
    };
    this.CreateElement = function () {
      var Result = null;
      Result = document.createElement("SPAN");
      return Result;
    };
    this.DoScroll = function (Event) {
      var Result = false;
      if (!this.FBlockScrolling) {
        this.FScrolling = true;
        if (this.FOnChange != null) this.FOnChange(this);
        this.FScrolling = false;
        Result = true;
      } else Result = false;
      this.FBlockScrolling = false;
      return Result;
    };
    this.BindEvents = function () {
      pas["WEBLib.Controls"].TCustomControl.BindEvents.call(this);
      if (this.GetElementHandle() != null) this.GetElementHandle().addEventListener("scroll",this.FScrollPtr);
    };
    this.UnbindEvents = function () {
      pas["WEBLib.Controls"].TControl.UnbindEvents.call(this);
      if (this.GetElementHandle() != null) this.GetElementHandle().removeEventListener("scroll",this.FScrollPtr);
    };
    this.UpdateElementVisual = function () {
      pas["WEBLib.Controls"].TCustomControl.UpdateElementVisual.call(this);
      if (this.GetElementHandle() != null) {
        this.GetElementHandle().style.setProperty("overflow","auto");
        var $tmp = this.FKind;
        if ($tmp === pas["WEBLib.Controls"].TScrollBarKind.sbHorizontal) {
          this.GetElementHandle().style.setProperty("overflow-y","hidden");
          this.GetElementHandle().style.setProperty("overflow-x","");
        } else if ($tmp === pas["WEBLib.Controls"].TScrollBarKind.sbVertical) {
          this.GetElementHandle().style.setProperty("overflow-y","");
          this.GetElementHandle().style.setProperty("overflow-x","hidden");
        };
      };
    };
    this.UpdateContent = function () {
      var x = 0;
      var y = 0;
      var w = 0;
      var h = 0;
      var ps = 0;
      var v = 0.0;
      if (!(this.FContent != null) || !(this.GetElementHandle() != null) || this.FScrolling) return;
      ps = this.GetPageSize();
      v = (this.FMax - this.FMin) / ps;
      var $tmp = this.FKind;
      if ($tmp === pas["WEBLib.Controls"].TScrollBarKind.sbHorizontal) {
        y = 0;
        h = this.GetHeight();
        w = Math.round(v * this.GetWidth());
        x = Math.round(((this.FPosition - this.FMin) / (this.FMax - this.FMin)) * w);
      } else if ($tmp === pas["WEBLib.Controls"].TScrollBarKind.sbVertical) {
        x = 0;
        w = this.GetWidth();
        h = Math.round(v * this.GetHeight());
        y = Math.round(((this.FPosition - this.FMin) / (this.FMax - this.FMin)) * h);
      };
      this.FContent.SetBounds(0,0,w,h);
      this.FBlockScrolling = true;
      this.GetElementHandle().scrollLeft = x;
      this.GetElementHandle().scrollTop = y;
    };
    this.Loaded = function () {
      pas["WEBLib.Controls"].TCustomControl.Loaded.call(this);
      this.UpdateContent();
    };
    this.ClearMethodPointers = function () {
      pas["WEBLib.Controls"].TControl.ClearMethodPointers.call(this);
      this.FScrollPtr = null;
    };
    this.GetMethodPointers = function () {
      pas["WEBLib.Controls"].TControl.GetMethodPointers.call(this);
      this.FScrollPtr = rtl.createCallback(this,"DoScroll");
    };
    this.CreateInitialize = function () {
      pas["WEBLib.Controls"].TCustomControl.CreateInitialize.call(this);
      this.SetTabStop(true);
      this.FKind = pas["WEBLib.Controls"].TScrollBarKind.sbHorizontal;
      this.FPosition = 0;
      this.FMin = 0;
      this.FMax = 100;
      this.FSmallChange = 1;
      this.FLargeChange = 1;
      this.FContent = $mod.TScrollBarContent.$create("Create$1",[this]);
      this.FContent.SetParent(this);
      this.FContent.SetWidth(121);
      this.FContent.SetHeight(17);
      if (pas.Classes.TComponentStateItem.csDesigning in this.FComponentState) {
        this.SetWidth(121);
        this.SetHeight(17);
      };
      this.UpdateContent();
    };
    this.Destroy = function () {
      rtl.free(this,"FContent");
      pas["WEBLib.Controls"].TCustomControl.Destroy.call(this);
    };
    this.SetBounds = function (X, Y, AWidth, AHeight) {
      pas["WEBLib.Controls"].TControl.SetBounds.apply(this,arguments);
      this.UpdateContent();
    };
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
    var $r = this.$rtti;
    $r.addProperty("Align",2,pas["WEBLib.Controls"].$rtti["TAlign"],"FAlign","SetAlign",{Default: pas["WEBLib.Controls"].TAlign.alNone});
    $r.addProperty("AlignWithMargins",2,rtl.boolean,"FAlignWithMargins","SetAlignWithMargins",{Default: false});
    $r.addProperty("DragMode",2,pas["WEBLib.Controls"].$rtti["TDragMode"],"FDragMode","SetDragMode",{Default: pas["WEBLib.Controls"].TDragMode.dmManual});
    $r.addProperty("Height",3,rtl.longint,"GetHeight","SetHeight");
    $r.addProperty("Kind",2,pas["WEBLib.Controls"].$rtti["TScrollBarKind"],"FKind","SetKind");
    $r.addProperty("Position",3,rtl.longint,"GetPosition","SetPosition");
    $r.addProperty("Left",3,rtl.longint,"GetLeft","SetLeft");
    $r.addProperty("SmallChange",0,rtl.longint,"FSmallChange","FSmallChange");
    $r.addProperty("LargeChange",0,rtl.longint,"FLargeChange","FLargeChange");
    $r.addProperty("Max",2,rtl.longint,"FMax","SetMax");
    $r.addProperty("Min",2,rtl.longint,"FMin","SetMin");
    $r.addProperty("PageSize",3,rtl.longint,"GetPageSize","SetPageSize");
    $r.addProperty("Top",3,rtl.longint,"GetTop","SetTop");
    $r.addProperty("Visible",2,rtl.boolean,"FVisible","SetVisible",{Default: true});
    $r.addProperty("Width",3,rtl.longint,"GetWidth","SetWidth");
    $r.addProperty("OnChange",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnChange","FOnChange");
    $r.addProperty("OnDragDrop",0,pas["WEBLib.Controls"].$rtti["TDragDropEvent"],"FOnDragDrop","FOnDragDrop");
    $r.addProperty("OnDragOver",0,pas["WEBLib.Controls"].$rtti["TDragOverEvent"],"FOnDragOver","FOnDragOver");
    $r.addProperty("OnEndDrag",0,pas["WEBLib.Controls"].$rtti["TEndDragEvent"],"FonEndDrag","FonEndDrag");
    $r.addProperty("OnStartDrag",0,pas["WEBLib.Controls"].$rtti["TStartDragEvent"],"FOnStartDrag","FOnStartDrag");
  });
  rtl.createClass(this,"TWebScrollBar",this.TScrollBar,function () {
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
  });
  this.GetAutoCompletionName = function (aAutoCompletion) {
    var Result = "";
    var $tmp = aAutoCompletion;
    if ($tmp === $mod.TAutoCompletion.acOff) {
      Result = ""}
     else if ($tmp === $mod.TAutoCompletion.acHonorificPrefix) {
      Result = "honorific-prefix"}
     else if ($tmp === $mod.TAutoCompletion.acGivenName) {
      Result = "given-name"}
     else if ($tmp === $mod.TAutoCompletion.acAdditionalName) {
      Result = "additional-name"}
     else if ($tmp === $mod.TAutoCompletion.acFamilyName) {
      Result = "family-name"}
     else if ($tmp === $mod.TAutoCompletion.acHonorificSuffix) {
      Result = "honorific-suffix"}
     else if ($tmp === $mod.TAutoCompletion.acNickName) {
      Result = "nickname"}
     else if ($tmp === $mod.TAutoCompletion.acEmail) {
      Result = "email"}
     else if ($tmp === $mod.TAutoCompletion.acUserName) {
      Result = "username"}
     else if ($tmp === $mod.TAutoCompletion.acNewPassword) {
      Result = "new-password"}
     else if ($tmp === $mod.TAutoCompletion.acCurrentPassword) {
      Result = "current-password"}
     else if ($tmp === $mod.TAutoCompletion.acOrganizationTitle) {
      Result = "organization-title"}
     else if ($tmp === $mod.TAutoCompletion.acOrganization) {
      Result = "organization"}
     else if ($tmp === $mod.TAutoCompletion.acStreetAddress) {
      Result = "street-address"}
     else if ($tmp === $mod.TAutoCompletion.acAddressLine1) {
      Result = "address-line1"}
     else if ($tmp === $mod.TAutoCompletion.acAddressLine2) {
      Result = "address-line2"}
     else if ($tmp === $mod.TAutoCompletion.acAddressLine3) {
      Result = "address-line3"}
     else if ($tmp === $mod.TAutoCompletion.acAddressLevel1) {
      Result = "address-level1"}
     else if ($tmp === $mod.TAutoCompletion.acAddressLevel2) {
      Result = "address-level2"}
     else if ($tmp === $mod.TAutoCompletion.acAddressLevel3) {
      Result = "address-level3"}
     else if ($tmp === $mod.TAutoCompletion.acAddressLevel4) {
      Result = "address-level4"}
     else if ($tmp === $mod.TAutoCompletion.acCountry) {
      Result = "country"}
     else if ($tmp === $mod.TAutoCompletion.acCountryName) {
      Result = "country-name"}
     else if ($tmp === $mod.TAutoCompletion.acPostalCode) {
      Result = "postal-code"}
     else if ($tmp === $mod.TAutoCompletion.acCCName) {
      Result = "cc-name"}
     else if ($tmp === $mod.TAutoCompletion.acCCGivenName) {
      Result = "cc-given-name"}
     else if ($tmp === $mod.TAutoCompletion.acCCAdditionalName) {
      Result = "cc-additional-name"}
     else if ($tmp === $mod.TAutoCompletion.acCCFamilyName) {
      Result = "cc-family-name"}
     else if ($tmp === $mod.TAutoCompletion.acCCNumber) {
      Result = "cc-number"}
     else if ($tmp === $mod.TAutoCompletion.acExpiry) {
      Result = "cc-exp"}
     else if ($tmp === $mod.TAutoCompletion.acExpiryMonth) {
      Result = "cc-exp-month"}
     else if ($tmp === $mod.TAutoCompletion.acExpiryYear) {
      Result = "cc-exp-year"}
     else if ($tmp === $mod.TAutoCompletion.acCSC) {
      Result = "cc-csc"}
     else if ($tmp === $mod.TAutoCompletion.acType) {
      Result = "cc-type"}
     else if ($tmp === $mod.TAutoCompletion.acTransactionCurrency) {
      Result = "transaction-currency"}
     else if ($tmp === $mod.TAutoCompletion.acTransactionAmount) {
      Result = "transaction-amount"}
     else if ($tmp === $mod.TAutoCompletion.acLanguage) {
      Result = "language"}
     else if ($tmp === $mod.TAutoCompletion.acBirthday) {
      Result = "bday"}
     else if ($tmp === $mod.TAutoCompletion.acBirthdayDay) {
      Result = "bday-day"}
     else if ($tmp === $mod.TAutoCompletion.acBirthDayMonth) {
      Result = "bday-month"}
     else if ($tmp === $mod.TAutoCompletion.acBirthDayYear) {
      Result = "bday-year"}
     else if ($tmp === $mod.TAutoCompletion.acSex) {
      Result = "sex"}
     else if ($tmp === $mod.TAutoCompletion.acTelephone) {
      Result = "tel"}
     else if ($tmp === $mod.TAutoCompletion.acTelephoneCountryCode) {
      Result = "tel-country-code"}
     else if ($tmp === $mod.TAutoCompletion.acTelephoneNational) {
      Result = "tel-national"}
     else if ($tmp === $mod.TAutoCompletion.acTelephoneAreaCode) {
      Result = "tel-area-code"}
     else if ($tmp === $mod.TAutoCompletion.acTelephoneLocal) {
      Result = "tel-local"}
     else if ($tmp === $mod.TAutoCompletion.acTelephoneExtension) {
      Result = "tel-extension"}
     else if ($tmp === $mod.TAutoCompletion.acIMPP) {
      Result = "impp"}
     else if ($tmp === $mod.TAutoCompletion.acURL) {
      Result = "url"}
     else if ($tmp === $mod.TAutoCompletion.acPhoto) {
      Result = "photo"}
     else if ($tmp === $mod.TAutoCompletion.acNope) Result = "nope";
    return Result;
  };
});
rtl.module("WEBLib.ExtCtrls",["System","Classes","SysUtils","Types","WEBLib.Controls","WEBLib.StdCtrls","WEBLib.Graphics","Web","JS","WEBLib.WebTools","WEBLib.Menus","WEBLib.REST"],function () {
  "use strict";
  var $mod = this;
  var $impl = $mod.$impl;
  this.TLinkTarget = {"0": "ltCurrentTab", ltCurrentTab: 0, "1": "ltNewTab", ltNewTab: 1};
  this.$rtti.$Enum("TLinkTarget",{minvalue: 0, maxvalue: 1, ordtype: 1, enumtype: this.TLinkTarget});
  rtl.createClass(this,"TCustomLinkLabel",pas["WEBLib.StdCtrls"].TCustomLabel,function () {
    this.$init = function () {
      pas["WEBLib.StdCtrls"].TCustomLabel.$init.call(this);
      this.FDisplText = "";
      this.FOnLinkClick = null;
      this.FWidthStyle$1 = 0;
      this.FHeightPercent$1 = 0.0;
      this.FHeightStyle$1 = 0;
      this.FWidthPercent$1 = 0.0;
      this.FTarget = 0;
    };
    this.$final = function () {
      this.FOnLinkClick = undefined;
      pas["WEBLib.StdCtrls"].TCustomLabel.$final.call(this);
    };
    this.SetTarget = function (Value) {
      if (this.FTarget !== Value) {
        this.FTarget = Value;
        this.SetCaption(this.FCaption);
      };
    };
    this.SetWidthStyle$1 = function (Value) {
      this.FWidthStyle$1 = Value;
    };
    this.SetHeightStyle$1 = function (Value) {
      this.FHeightStyle$1 = Value;
    };
    this.SetHeightPercent$1 = function (Value) {
      this.FHeightPercent$1 = Value;
    };
    this.SetWidthPercent$1 = function (Value) {
      this.FWidthPercent$1 = Value;
    };
    this.GetOuterWidth = function () {
      var Result = 0;
      if (this.FAlign !== pas["WEBLib.Controls"].TAlign.alNone) {
        Result = pas["WEBLib.Controls"].TControl.GetOuterWidth.call(this)}
       else Result = this.GetWidth();
      return Result;
    };
    this.GetOuterHeight = function () {
      var Result = 0;
      if (this.FAlign !== pas["WEBLib.Controls"].TAlign.alNone) {
        Result = pas["WEBLib.Controls"].TControl.GetOuterHeight.call(this)}
       else Result = this.GetHeight();
      return Result;
    };
    this.GetDisplayText = function () {
      var Result = "";
      Result = this.FDisplText;
      return Result;
    };
    this.SetCaption = function (AValue) {
      var iopen = 0;
      var iopena = 0;
      var iopeni = 0;
      var iopenend = 0;
      var iopenendt = 0;
      var iclose = 0;
      var scaption = "";
      var shref = "";
      var stext = "";
      var sanchor = "";
      var sid = "";
      var stype = "";
      var slcaption = "";
      var anchor = null;
      var span = null;
      var contentelement = null;
      pas["WEBLib.StdCtrls"].TCustomLabel.SetCaption.call(this,AValue);
      if (!(this.GetContainer() != null)) return;
      contentelement = this.GetContentHandle();
      if (this.GetID() !== "") {
        contentelement = document.getElementById(this.GetID());
      };
      if ((contentelement != null) && pas.System.Assigned(contentelement.nodeValue)) contentelement.nodeValue = "";
      scaption = AValue;
      slcaption = pas.SysUtils.LowerCase(scaption);
      if ((pas.System.Pos("https://",slcaption) === 1) || (pas.System.Pos("http://",slcaption) === 1)) {
        scaption = '<a href="' + scaption + '"';
        if (this.FTarget === $mod.TLinkTarget.ltNewTab) scaption = scaption + ' target="_blank"';
        scaption = scaption + ">" + this.FCaption + "</a>";
        if (!(this.FOnLinkClick != null)) {
          contentelement.innerHTML = scaption;
          return;
        };
      };
      sanchor = '<a href="';
      sid = '<a id="';
      if ((this.FOnLinkClick != null) && ((pas.System.Pos(sanchor,scaption) > 0) || (pas.System.Pos(sid,scaption) > 0))) {
        contentelement.innerHTML = "";
        while ((pas.System.Pos(sanchor,scaption) > 0) || (pas.System.Pos(sid,scaption) > 0)) {
          iopena = pas.System.Pos(sanchor,scaption);
          iopeni = pas.System.Pos(sid,scaption);
          if (((iopena < iopeni) || (iopeni <= 0)) && (iopena > 0)) {
            stype = "#url#";
            iopen = iopena + sanchor.length;
          } else {
            stype = "#id#";
            iopen = iopeni + sid.length;
          };
          iopenend = pas.System.Pos('">',scaption);
          iopenendt = pas.System.Pos('" ',scaption);
          if ((iopenendt > 0) && (iopenendt < iopenend)) iopenend = iopenendt;
          iclose = pas.System.Pos("</a>",scaption);
          shref = pas.System.Copy(scaption,iopen,iopenend - iopen);
          iopenend = pas.System.Pos('">',scaption);
          iclose = pas.System.Pos("</a>",scaption);
          stext = pas.System.Copy(scaption,iopenend + 2,iclose - (iopenend + 2));
          span = document.createElement("SPAN");
          span.innerHTML = pas.System.Copy(scaption,0,iopen);
          contentelement.appendChild(span);
          anchor = document.createElement("A");
          anchor.setAttribute("href","#");
          anchor.setAttribute("id",stype + shref);
          anchor.innerHTML = stext;
          anchor.onclick = rtl.createSafeCallback(this,"DoLinkClick");
          contentelement.appendChild(anchor);
          pas.System.Delete({get: function () {
              return scaption;
            }, set: function (v) {
              scaption = v;
            }},1,pas.System.Pos("</a>",scaption) + 3);
        };
        span = document.createElement("SPAN");
        span.innerHTML = scaption;
        contentelement.appendChild(span);
        this.FDisplText = scaption;
      } else {
        this.FDisplText = pas.SysUtils.StringReplace(AValue,"> <",">&nbsp;<",rtl.createSet(pas.SysUtils.TStringReplaceFlag.rfReplaceAll));
        if ((contentelement != null) && pas.System.Assigned(contentelement.nodeValue)) {
          contentelement.nodeValue = this.FDisplText}
         else if ((contentelement != null) && (contentelement.childElementCount <= 1)) contentelement.innerHTML = this.FDisplText;
      };
    };
    this.DoLinkClick = function (Event) {
      var Result = false;
      var slink = "";
      var stype = "";
      var svalue = "";
      var ltype = 0;
      svalue = Event.target.getAttribute("id");
      stype = "#url#";
      ltype = pas["WEBLib.StdCtrls"].TSysLinkType.sltURL;
      if (!(pas.System.Pos(stype,svalue) > 0)) {
        stype = "#id#";
        ltype = pas["WEBLib.StdCtrls"].TSysLinkType.sltID;
      };
      slink = pas.SysUtils.StringReplace(svalue,stype,"",{});
      if (this.FOnLinkClick != null) this.FOnLinkClick(this,slink,ltype);
      Result = true;
      return Result;
    };
    this.Create$1 = function (AOwner) {
      pas["WEBLib.Controls"].TControl.Create$1.apply(this,arguments);
      this.FWidthStyle$1 = pas["WEBLib.Controls"].TSizeStyle.ssAbsolute;
      this.FWidthPercent$1 = 100;
      this.FHeightStyle$1 = pas["WEBLib.Controls"].TSizeStyle.ssAbsolute;
      this.FHeightPercent$1 = 100;
      this.SetTransparent(true);
      return this;
    };
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
    var $r = this.$rtti;
    $r.addMethod("Create$1",2,[["AOwner",pas.Classes.$rtti["TComponent"]]]);
    $r.addProperty("Align",2,pas["WEBLib.Controls"].$rtti["TAlign"],"FAlign","SetAlign",{Default: pas["WEBLib.Controls"].TAlign.alNone});
    $r.addProperty("Alignment",2,pas.Classes.$rtti["TAlignment"],"FAlignment","SetAlignment",{Default: pas.Classes.TAlignment.taLeftJustify});
    $r.addProperty("AlignWithMargins",2,rtl.boolean,"FAlignWithMargins","SetAlignWithMargins",{Default: false});
    $r.addProperty("Anchors",2,pas["WEBLib.Controls"].$rtti["TAnchors"],"FAnchors","SetAnchors",{Default: rtl.createSet(pas["WEBLib.Controls"].TAnchorKind.akLeft,pas["WEBLib.Controls"].TAnchorKind.akTop)});
    $r.addProperty("AutoSize",2,rtl.boolean,"FAutoSize","SetAutoSize",{Default: true});
    $r.addProperty("Caption",2,rtl.string,"FCaption","SetCaption");
    $r.addProperty("Color",2,pas["WEBLib.Graphics"].$rtti["TColor"],"FColor$1","SetColorEx",{Default: 16777215});
    $r.addProperty("DragMode",2,pas["WEBLib.Controls"].$rtti["TDragMode"],"FDragMode","SetDragMode",{Default: pas["WEBLib.Controls"].TDragMode.dmManual});
    $r.addProperty("EllipsisPosition",2,pas["WEBLib.StdCtrls"].$rtti["TEllipsisPosition"],"FEllipsisPosition","SetEllipsisPosition",{Default: pas["WEBLib.StdCtrls"].TEllipsisPosition.epNone});
    $r.addProperty("ElementClassName",2,pas["WEBLib.Controls"].$rtti["TElementClassName"],"FElementClassName","SetElementClassName");
    $r.addProperty("ElementID",3,pas["WEBLib.Controls"].$rtti["TElementID"],"GetID","SetID");
    $r.addProperty("ElementFont",2,pas["WEBLib.Controls"].$rtti["TElementFont"],"FElementFont","SetElementFont",{Default: pas["WEBLib.Controls"].TElementFont.efProperty});
    $r.addProperty("ElementPosition",2,pas["WEBLib.Controls"].$rtti["TElementPosition"],"FElementPosition","SetElementPosition",{Default: pas["WEBLib.Controls"].TElementPosition.epAbsolute});
    $r.addProperty("Enabled",2,rtl.boolean,"FEnabled","SetEnabled",{Default: true});
    $r.addProperty("Font",2,pas["WEBLib.Graphics"].$rtti["TFont"],"FFont","SetFont");
    $r.addProperty("Height",3,rtl.longint,"GetHeight","SetHeight");
    $r.addProperty("Hint",2,rtl.string,"FHint","SetHint");
    $r.addProperty("Layout",2,pas["WEBLib.StdCtrls"].$rtti["TTextLayout"],"FLayout","SetLayout",{Default: pas["WEBLib.StdCtrls"].TTextLayout.tlTop});
    $r.addProperty("Left",3,rtl.longint,"GetLeft","SetLeft");
    $r.addProperty("Margins",2,pas["WEBLib.Controls"].$rtti["TMargins"],"FMargins","SetMargins");
    $r.addProperty("ShowHint",2,rtl.boolean,"FShowHint","SetShowHint",{Default: false});
    $r.addProperty("Target",2,$mod.$rtti["TLinkTarget"],"FTarget","SetTarget",{Default: $mod.TLinkTarget.ltCurrentTab});
    $r.addProperty("Top",3,rtl.longint,"GetTop","SetTop");
    $r.addProperty("Transparent",2,rtl.boolean,"FTransparent","SetTransparent",{Default: true});
    $r.addProperty("Visible",2,rtl.boolean,"FVisible","SetVisible",{Default: true});
    $r.addProperty("Width",3,rtl.longint,"GetWidth","SetWidth");
    $r.addProperty("WordWrap",0,rtl.boolean,"FWordWrap","FWordWrap",{Default: false});
    $r.addProperty("HeightStyle",2,pas["WEBLib.Controls"].$rtti["TSizeStyle"],"FHeightStyle$1","SetHeightStyle$1",{Default: pas["WEBLib.Controls"].TSizeStyle.ssAbsolute});
    $r.addProperty("WidthStyle",2,pas["WEBLib.Controls"].$rtti["TSizeStyle"],"FWidthStyle$1","SetWidthStyle$1",{Default: pas["WEBLib.Controls"].TSizeStyle.ssAbsolute});
    $r.addProperty("HeightPercent",2,rtl.double,"FHeightPercent$1","SetHeightPercent$1",{Default: 100});
    $r.addProperty("WidthPercent",2,rtl.double,"FWidthPercent$1","SetWidthPercent$1",{Default: 100});
    $r.addProperty("OnClick",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnClick","FOnClick");
    $r.addProperty("OnDblClick",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnDblClick","FOnDblClick");
    $r.addProperty("OnLinkClick",0,pas["WEBLib.StdCtrls"].$rtti["TLinkClickEvent"],"FOnLinkClick","FOnLinkClick");
    $r.addProperty("OnDragDrop",0,pas["WEBLib.Controls"].$rtti["TDragDropEvent"],"FOnDragDrop","FOnDragDrop");
    $r.addProperty("OnDragOver",0,pas["WEBLib.Controls"].$rtti["TDragOverEvent"],"FOnDragOver","FOnDragOver");
    $r.addProperty("OnEndDrag",0,pas["WEBLib.Controls"].$rtti["TEndDragEvent"],"FonEndDrag","FonEndDrag");
    $r.addProperty("OnStartDrag",0,pas["WEBLib.Controls"].$rtti["TStartDragEvent"],"FOnStartDrag","FOnStartDrag");
  });
  rtl.createClass(this,"TLinkLabel",this.TCustomLinkLabel,function () {
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
    var $r = this.$rtti;
    $r.addProperty("Caption",2,rtl.string,"FCaption","SetCaption");
    $r.addProperty("ParentFont",2,rtl.boolean,"FParentFont","SetParentFont",{Default: true});
  });
  rtl.createClass(this,"TWebLinkLabel",this.TLinkLabel,function () {
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
  });
  this.TTrackBarOrientation = {"0": "trHorizontal", trHorizontal: 0, "1": "trVertical", trVertical: 1};
  this.$rtti.$Enum("TTrackBarOrientation",{minvalue: 0, maxvalue: 1, ordtype: 1, enumtype: this.TTrackBarOrientation});
  rtl.createClass(this,"TTrackBar",pas["WEBLib.StdCtrls"].TCustomInput,function () {
    this.$init = function () {
      pas["WEBLib.StdCtrls"].TCustomInput.$init.call(this);
      this.FMax = 0;
      this.FMin = 0;
      this.FPosition = 0;
      this.FOnChange = null;
      this.FOrientation = 0;
    };
    this.$final = function () {
      this.FOnChange = undefined;
      pas["WEBLib.StdCtrls"].TCustomInput.$final.call(this);
    };
    this.SetOrientation = function (Value) {
      var ow = 0;
      var oh = 0;
      if (this.FOrientation !== Value) {
        ow = this.GetWidth();
        oh = this.GetHeight();
        this.FOrientation = Value;
        if (!(pas.Classes.TComponentStateItem.csLoading in this.FComponentState)) {
          this.SetWidth(oh);
          this.SetHeight(ow);
        };
        this.UpdateElement();
      };
    };
    this.GetElementInputHandle = function () {
      var Result = null;
      Result = this.GetContainer();
      return Result;
    };
    this.GetInputType = function () {
      var Result = "";
      Result = "range";
      return Result;
    };
    this.DoHandleChange = function (Event) {
      var Result = false;
      var el = null;
      el = this.GetElementHandle();
      this.FPosition = el.value;
      this.Change();
      Result = true;
      return Result;
    };
    this.BindEvents = function () {
      pas["WEBLib.Controls"].TCustomControl.BindEvents.call(this);
      if (this.GetElementHandle() != null) {
        this.GetElementHandle().oninput = rtl.createSafeCallback(this,"DoHandleChange");
      };
    };
    this.SetMax = function (AValue) {
      if (this.FMax !== AValue) {
        this.FMax = AValue;
        this.DoUpdate();
      };
    };
    this.SetMin = function (AValue) {
      if (this.FMin !== AValue) {
        this.FMin = AValue;
        this.DoUpdate();
      };
    };
    this.SetPosition = function (AValue) {
      if (this.FPosition !== AValue) {
        this.FPosition = AValue;
        this.DoUpdate();
      };
    };
    this.GetPosition = function () {
      var Result = 0;
      var s = "";
      Result = this.FPosition;
      if (!(this.GetContainer() != null)) return Result;
      s = this.GetContainer().value;
      if (s !== "") Result = pas.SysUtils.StrToInt(s);
      return Result;
    };
    this.DoUpdate = function () {
      var el = null;
      if (!(this.GetContainer() != null)) return;
      this.GetContainer().setAttribute("max",pas.SysUtils.IntToStr(this.FMax));
      this.GetContainer().setAttribute("min",pas.SysUtils.IntToStr(this.FMin));
      el = this.GetElementHandle();
      el.value = this.FPosition;
      el.setAttribute('value',this.FPosition);
    };
    this.Change = function () {
      if (this.FOnChange != null) this.FOnChange(this);
    };
    this.CreateControl = function () {
      pas["WEBLib.Controls"].TCustomControl.CreateControl.call(this);
      this.DoUpdate();
    };
    this.UpdateElementVisual = function () {
      var el = null;
      pas["WEBLib.StdCtrls"].TCustomInput.UpdateElementVisual.call(this);
      el = this.GetElementHandle();
      if (this.FOrientation === $mod.TTrackBarOrientation.trHorizontal) {
        el.removeAttribute("orient");
        el.style.removeProperty("writing-mode");
        el.style.removeProperty("-webkit-appearance");
        el.style.removeProperty("height");
        if (this.FWidthStyle === pas["WEBLib.Controls"].TSizeStyle.ssAbsolute) el.style.setProperty("width",pas.SysUtils.IntToStr(this.GetWidth()));
      } else {
        el.setAttribute("orient","vertical");
        el.style.setProperty("writing-mode","bt-lt");
        el.style.setProperty("-webkit-appearance","slider-vertical");
        el.style.removeProperty("width");
        if (this.FHeightStyle === pas["WEBLib.Controls"].TSizeStyle.ssAbsolute) el.style.setProperty("height",pas.SysUtils.IntToStr(this.GetHeight()));
        el.style.setProperty("width","22px");
      };
    };
    this.CreateInitialize = function () {
      pas["WEBLib.StdCtrls"].TCustomInput.CreateInitialize.call(this);
      this.FMax = 100;
      this.FMin = 0;
      this.FPosition = 0;
    };
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
    var $r = this.$rtti;
    $r.addProperty("Align",2,pas["WEBLib.Controls"].$rtti["TAlign"],"FAlign","SetAlign",{Default: pas["WEBLib.Controls"].TAlign.alNone});
    $r.addProperty("AlignWithMargins",2,rtl.boolean,"FAlignWithMargins","SetAlignWithMargins",{Default: false});
    $r.addProperty("Anchors",2,pas["WEBLib.Controls"].$rtti["TAnchors"],"FAnchors","SetAnchors",{Default: rtl.createSet(pas["WEBLib.Controls"].TAnchorKind.akLeft,pas["WEBLib.Controls"].TAnchorKind.akTop)});
    $r.addProperty("DragMode",2,pas["WEBLib.Controls"].$rtti["TDragMode"],"FDragMode","SetDragMode",{Default: pas["WEBLib.Controls"].TDragMode.dmManual});
    $r.addProperty("ElementClassName",2,pas["WEBLib.Controls"].$rtti["TElementClassName"],"FElementClassName","SetElementClassName");
    $r.addProperty("ElementID",3,pas["WEBLib.Controls"].$rtti["TElementID"],"GetID","SetID");
    $r.addProperty("ElementFont",2,pas["WEBLib.Controls"].$rtti["TElementFont"],"FElementFont","SetElementFont",{Default: pas["WEBLib.Controls"].TElementFont.efProperty});
    $r.addProperty("ElementPosition",2,pas["WEBLib.Controls"].$rtti["TElementPosition"],"FElementPosition","SetElementPosition",{Default: pas["WEBLib.Controls"].TElementPosition.epAbsolute});
    $r.addProperty("Enabled",2,rtl.boolean,"FEnabled","SetEnabled",{Default: true});
    $r.addProperty("Height",3,rtl.longint,"GetHeight","SetHeight");
    $r.addProperty("HeightPercent",2,rtl.double,"FHeightPercent","SetHeightPercent",{Default: 100});
    $r.addProperty("HeightStyle",2,pas["WEBLib.Controls"].$rtti["TSizeStyle"],"FHeightStyle","SetHeightStyle",{Default: pas["WEBLib.Controls"].TSizeStyle.ssAbsolute});
    $r.addProperty("Left",3,rtl.longint,"GetLeft","SetLeft");
    $r.addProperty("Margins",2,pas["WEBLib.Controls"].$rtti["TMargins"],"FMargins","SetMargins");
    $r.addProperty("Max",2,rtl.longint,"FMax","SetMax",{Default: 10});
    $r.addProperty("Min",2,rtl.longint,"FMin","SetMin",{Default: 0});
    $r.addProperty("Orientation",2,$mod.$rtti["TTrackBarOrientation"],"FOrientation","SetOrientation",{Default: $mod.TTrackBarOrientation.trHorizontal});
    $r.addProperty("Position",3,rtl.longint,"GetPosition","SetPosition",{Default: 0});
    $r.addProperty("Role",3,rtl.string,"GetRole","SetRole");
    $r.addProperty("ShowHint",2,rtl.boolean,"FShowHint","SetShowHint",{Default: false});
    $r.addProperty("TabOrder",2,rtl.longint,"FTabOrder","SetTabOrder");
    $r.addProperty("TabStop",2,rtl.boolean,"FTabStop","SetTabStop",{Default: true});
    $r.addProperty("Top",3,rtl.longint,"GetTop","SetTop");
    $r.addProperty("Visible",2,rtl.boolean,"FVisible","SetVisible",{Default: true});
    $r.addProperty("Width",3,rtl.longint,"GetWidth","SetWidth");
    $r.addProperty("WidthPercent",2,rtl.double,"FWidthPercent","SetWidthPercent",{Default: 100});
    $r.addProperty("WidthStyle",2,pas["WEBLib.Controls"].$rtti["TSizeStyle"],"FWidthStyle","SetWidthStyle",{Default: pas["WEBLib.Controls"].TSizeStyle.ssAbsolute});
    $r.addProperty("OnClick",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnClick","FOnClick");
    $r.addProperty("OnMouseDown",0,pas["WEBLib.Controls"].$rtti["TMouseEvent"],"FOnMouseDown","FOnMouseDown");
    $r.addProperty("OnMouseUp",0,pas["WEBLib.Controls"].$rtti["TMouseEvent"],"FOnMouseUp","FOnMouseUp");
    $r.addProperty("OnChange",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnChange","FOnChange");
    $r.addProperty("OnDragDrop",0,pas["WEBLib.Controls"].$rtti["TDragDropEvent"],"FOnDragDrop","FOnDragDrop");
    $r.addProperty("OnDragOver",0,pas["WEBLib.Controls"].$rtti["TDragOverEvent"],"FOnDragOver","FOnDragOver");
    $r.addProperty("OnEndDrag",0,pas["WEBLib.Controls"].$rtti["TEndDragEvent"],"FonEndDrag","FonEndDrag");
    $r.addProperty("OnStartDrag",0,pas["WEBLib.Controls"].$rtti["TStartDragEvent"],"FOnStartDrag","FOnStartDrag");
  });
  rtl.createClass(this,"TWebTrackBar",this.TTrackBar,function () {
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
  });
  rtl.createClass(this,"TTimer",pas.Classes.TComponent,function () {
    this.$init = function () {
      pas.Classes.TComponent.$init.call(this);
      this.FInterval = 0;
      this.FTimerID = 0;
      this.FOnTimer = null;
      this.FEnabled = false;
    };
    this.$final = function () {
      this.FOnTimer = undefined;
      pas.Classes.TComponent.$final.call(this);
    };
    this.SetEnabled = function (Value) {
      this.FEnabled = Value;
      this.DoUpdateTimer();
    };
    this.SetInterval = function (AValue) {
      this.FInterval = AValue;
      this.DoUpdateTimer();
    };
    this.DoTimer = function () {
      if (this.FOnTimer != null) this.FOnTimer(this);
    };
    this.DoUpdateTimer = function () {
      this.DoClearTimer();
      if (this.FEnabled) this.FTimerID = window.setInterval(rtl.createSafeCallback(this,"DoTimer"),this.FInterval);
    };
    this.DoClearTimer = function () {
      if (this.FTimerID !== -1) {
        window.clearInterval(this.FTimerID);
        this.FTimerID = -1;
      };
    };
    this.Create$1 = function (AOwner) {
      pas.Classes.TComponent.Create$1.apply(this,arguments);
      this.FInterval = 1000;
      this.FTimerID = -1;
      this.SetEnabled(true);
      return this;
    };
    this.Destroy = function () {
      this.DoClearTimer();
      pas.Classes.TComponent.Destroy.call(this);
    };
    rtl.addIntf(this,pas.System.IUnknown);
    var $r = this.$rtti;
    $r.addMethod("Create$1",2,[["AOwner",pas.Classes.$rtti["TComponent"]]]);
    $r.addProperty("Enabled",2,rtl.boolean,"FEnabled","SetEnabled",{Default: true});
    $r.addProperty("Interval",2,rtl.longint,"FInterval","SetInterval",{Default: 1000});
    $r.addProperty("OnTimer",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnTimer","FOnTimer");
  });
  rtl.createClass(this,"TWebTimer",this.TTimer,function () {
    rtl.addIntf(this,pas.System.IUnknown);
  });
  this.$rtti.$MethodVar("TGeolocationEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["Lat",rtl.double],["Lon",rtl.double],["Alt",rtl.double]]), methodkind: 0});
  this.$rtti.$MethodVar("TGeolocationExEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["Lat",rtl.double],["Lon",rtl.double],["Alt",rtl.double],["Accuracy",rtl.double]]), methodkind: 0});
  this.$rtti.$MethodVar("TGeolocationErrorEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["ACode",rtl.longint],["AMessage",rtl.string]]), methodkind: 0});
  this.$rtti.$RefToProcVar("TGeolocationResponseProc",{procsig: rtl.newTIProcSig([["APosition",pas.Web.$rtti["TJSPosition"]]])});
  rtl.createClass(this,"TGeoLocation",pas.Classes.TComponent,function () {
    this.$init = function () {
      pas.Classes.TComponent.$init.call(this);
      this.FOnGeolocation = null;
      this.FWidth = 0;
      this.FHeight = 0;
      this.FMaximumAge = 0;
      this.FTimeOut = 0;
      this.FHighPrecision = false;
      this.FTrackID = 0;
      this.FOnGeolocationUpdate = null;
      this.FOnGeolocationEx = null;
      this.FOnGeolocationError = null;
      this.FOnGeolocationUpdateEx = null;
    };
    this.$final = function () {
      this.FOnGeolocation = undefined;
      this.FOnGeolocationUpdate = undefined;
      this.FOnGeolocationEx = undefined;
      this.FOnGeolocationError = undefined;
      this.FOnGeolocationUpdateEx = undefined;
      pas.Classes.TComponent.$final.call(this);
    };
    this.DoHandleGeolocation = function (APosition) {
      if (this.FOnGeolocation != null) this.FOnGeolocation(this,APosition.coords.latitude,APosition.coords.longitude,APosition.coords.altitude);
      if (this.FOnGeolocationEx != null) this.FOnGeolocationEx(this,APosition.coords.latitude,APosition.coords.longitude,APosition.coords.altitude,APosition.coords.accuracy);
    };
    this.DoHandleError = function (AValue) {
      if (this.FOnGeolocationError != null) this.FOnGeolocationError(this,AValue.code,AValue.message);
    };
    this.DoHandleGeolocationAsync = function (AProc) {
      var $Self = this;
      var posopt = pas.Web.TJSPositionOptions.$new();
      function Handler(APosition) {
        AProc(pas.Web.TJSPosition.$clone(APosition));
      };
      posopt.enableHighAccuracy = this.FHighPrecision;
      posopt.timeout = this.FTimeOut;
      posopt.maximumAge = this.FMaximumAge;
      navigator.geolocation.getCurrentPosition(Handler,null,pas.Web.TJSPositionOptions.$clone(posopt));
    };
    this.DoHandleGeolocationUpdate = function (APosition) {
      if (this.FOnGeolocationUpdate != null) this.FOnGeolocationUpdate(this,APosition.coords.latitude,APosition.coords.longitude,APosition.coords.altitude);
      if (this.FOnGeolocationUpdateEx != null) this.FOnGeolocationUpdateEx(this,APosition.coords.latitude,APosition.coords.longitude,APosition.coords.altitude,APosition.coords.accuracy);
    };
    this.Create$1 = function (AOwner) {
      pas.Classes.TComponent.Create$1.apply(this,arguments);
      this.FHighPrecision = false;
      this.FTimeOut = 60000;
      this.FMaximumAge = 0;
      this.FTrackID = -1;
      return this;
    };
    this.HasGeolocation = function () {
      var Result = false;
      Result = navigator.geolocation != null;
      return Result;
    };
    this.GetGeolocation = function () {
      var posopt = pas.Web.TJSPositionOptions.$new();
      if (navigator.geolocation != null) {
        posopt.enableHighAccuracy = this.FHighPrecision;
        posopt.timeout = this.FTimeOut;
        posopt.maximumAge = this.FMaximumAge;
        navigator.geolocation.getCurrentPosition(rtl.createCallback(this,"DoHandleGeolocation"),rtl.createCallback(this,"DoHandleError"),pas.Web.TJSPositionOptions.$clone(posopt));
      };
    };
    this.GetGeolocationAsync = function () {
      var $Self = this;
      var Result = null;
      var posopt = pas.Web.TJSPositionOptions.$new();
      Result = new Promise(function (ASuccess, AFailed) {
        if (navigator.geolocation != null) {
          $Self.DoHandleGeolocationAsync(function (APosition) {
            ASuccess(pas.Web.TJSPosition.$clone(APosition));
          });
        } else AFailed(null);
      });
      return Result;
    };
    this.StartTracking = function () {
      var posopt = pas.Web.TJSPositionOptions.$new();
      if (this.FTrackID !== -1) this.StopTracking();
      if (navigator.geolocation != null) {
        posopt.enableHighAccuracy = this.FHighPrecision;
        posopt.timeout = this.FTimeOut;
        posopt.maximumAge = this.FMaximumAge;
        this.FTrackID = navigator.geolocation.watchPosition(rtl.createCallback(this,"DoHandleGeolocationUpdate"),rtl.createCallback(this,"DoHandleError"),pas.Web.TJSPositionOptions.$clone(posopt));
      };
    };
    this.StopTracking = function () {
      if ((navigator.geolocation != null) && (this.FTrackID !== -1)) {
        navigator.geolocation.clearWatch(this.FTrackID);
        this.FTrackID = -1;
      };
    };
    rtl.addIntf(this,pas.System.IUnknown);
    var $r = this.$rtti;
    $r.addMethod("Create$1",2,[["AOwner",pas.Classes.$rtti["TComponent"]]]);
    $r.addProperty("HighPrecision",0,rtl.boolean,"FHighPrecision","FHighPrecision",{Default: false});
    $r.addProperty("TimeOut",0,rtl.longint,"FTimeOut","FTimeOut",{Default: 60000});
    $r.addProperty("MaximumAge",0,rtl.longint,"FMaximumAge","FMaximumAge",{Default: 0});
    $r.addProperty("OnGeolocation",0,$mod.$rtti["TGeolocationEvent"],"FOnGeolocation","FOnGeolocation");
    $r.addProperty("OnGeolocationEx",0,$mod.$rtti["TGeolocationExEvent"],"FOnGeolocationEx","FOnGeolocationEx");
    $r.addProperty("OnGeolocationError",0,$mod.$rtti["TGeolocationErrorEvent"],"FOnGeolocationError","FOnGeolocationError");
    $r.addProperty("OnGeolocationUpdate",0,$mod.$rtti["TGeolocationEvent"],"FOnGeolocationUpdate","FOnGeolocationUpdate");
    $r.addProperty("OnGeolocationUpdateEx",0,$mod.$rtti["TGeolocationExEvent"],"FOnGeolocationUpdateEx","FOnGeolocationUpdateEx");
  });
  rtl.createClass(this,"TWebGeoLocation",this.TGeoLocation,function () {
    rtl.addIntf(this,pas.System.IUnknown);
  });
  rtl.createClass(this,"TPaintBox",pas["WEBLib.Menus"].TWebGraphicControl,function () {
    this.$init = function () {
      pas["WEBLib.Menus"].TWebGraphicControl.$init.call(this);
      this.FOnPaint = null;
    };
    this.$final = function () {
      this.FOnPaint = undefined;
      pas["WEBLib.Menus"].TWebGraphicControl.$final.call(this);
    };
    this.Paint = function () {
      pas["WEBLib.Controls"].TCustomControl.Paint.call(this);
      if (this.FOnPaint != null) this.FOnPaint(this);
    };
    this.UpdateElementVisual = function () {
      pas["WEBLib.Controls"].TCustomControl.UpdateElementVisual.call(this);
      if (pas.Classes.TComponentStateItem.csDesigning in this.FComponentState) {
        this.GetElementHandle().style.setProperty("border","1px dotted gray");
      };
    };
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
    var $r = this.$rtti;
    $r.addProperty("Align",2,pas["WEBLib.Controls"].$rtti["TAlign"],"FAlign","SetAlign",{Default: pas["WEBLib.Controls"].TAlign.alNone});
    $r.addProperty("AlignWithMargins",2,rtl.boolean,"FAlignWithMargins","SetAlignWithMargins",{Default: false});
    $r.addProperty("Anchors",2,pas["WEBLib.Controls"].$rtti["TAnchors"],"FAnchors","SetAnchors",{Default: rtl.createSet(pas["WEBLib.Controls"].TAnchorKind.akLeft,pas["WEBLib.Controls"].TAnchorKind.akTop)});
    $r.addProperty("DragMode",2,pas["WEBLib.Controls"].$rtti["TDragMode"],"FDragMode","SetDragMode",{Default: pas["WEBLib.Controls"].TDragMode.dmManual});
    $r.addProperty("ElementID",3,pas["WEBLib.Controls"].$rtti["TElementID"],"GetID","SetID");
    $r.addProperty("ElementFont",2,pas["WEBLib.Controls"].$rtti["TElementFont"],"FElementFont","SetElementFont",{Default: pas["WEBLib.Controls"].TElementFont.efProperty});
    $r.addProperty("ElementPosition",2,pas["WEBLib.Controls"].$rtti["TElementPosition"],"FElementPosition","SetElementPosition",{Default: pas["WEBLib.Controls"].TElementPosition.epAbsolute});
    $r.addProperty("Enabled",2,rtl.boolean,"FEnabled","SetEnabled",{Default: true});
    $r.addProperty("HeightPercent",2,rtl.double,"FHeightPercent","SetHeightPercent",{Default: 100});
    $r.addProperty("HeightStyle",2,pas["WEBLib.Controls"].$rtti["TSizeStyle"],"FHeightStyle","SetHeightStyle",{Default: pas["WEBLib.Controls"].TSizeStyle.ssAbsolute});
    $r.addProperty("Margins",2,pas["WEBLib.Controls"].$rtti["TMargins"],"FMargins","SetMargins");
    $r.addProperty("PopupMenu",0,pas["WEBLib.Menus"].$rtti["TPopupMenu"],"FPopupMenu","FPopupMenu");
    $r.addProperty("WidthPercent",2,rtl.double,"FWidthPercent","SetWidthPercent",{Default: 100});
    $r.addProperty("WidthStyle",2,pas["WEBLib.Controls"].$rtti["TSizeStyle"],"FWidthStyle","SetWidthStyle",{Default: pas["WEBLib.Controls"].TSizeStyle.ssAbsolute});
    $r.addProperty("OnClick",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnClick","FOnClick");
    $r.addProperty("OnDblClick",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnDblClick","FOnDblClick");
    $r.addProperty("OnMouseWheel",0,pas["WEBLib.Controls"].$rtti["TMouseWheelEvent"],"FOnMouseWheel","FOnMouseWheel");
    $r.addProperty("OnPaint",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnPaint","FOnPaint");
    $r.addProperty("OnTouchStart",0,pas["WEBLib.Controls"].$rtti["TTouchEvent"],"FOnTouchStart","FOnTouchStart");
    $r.addProperty("OnTouchMove",0,pas["WEBLib.Controls"].$rtti["TTouchEvent"],"FOnTouchMove","FOnTouchMove");
    $r.addProperty("OnTouchEnd",0,pas["WEBLib.Controls"].$rtti["TTouchEvent"],"FOnTouchEnd","FOnTouchEnd");
    $r.addProperty("OnDragDrop",0,pas["WEBLib.Controls"].$rtti["TDragDropEvent"],"FOnDragDrop","FOnDragDrop");
    $r.addProperty("OnDragOver",0,pas["WEBLib.Controls"].$rtti["TDragOverEvent"],"FOnDragOver","FOnDragOver");
    $r.addProperty("OnEndDrag",0,pas["WEBLib.Controls"].$rtti["TEndDragEvent"],"FonEndDrag","FonEndDrag");
    $r.addProperty("OnStartDrag",0,pas["WEBLib.Controls"].$rtti["TStartDragEvent"],"FOnStartDrag","FOnStartDrag");
  });
  rtl.createClass(this,"TWebPaintBox",this.TPaintBox,function () {
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
  });
  this.$rtti.$RefToProcVar("TImageLoadedProc",{procsig: rtl.newTIProcSig([["AEvent",pas.Web.$rtti["TJSEvent"]]])});
  this.$rtti.$RefToProcVar("TImageErrorProc",{procsig: rtl.newTIProcSig([["AEvent",pas.Web.$rtti["TJSEvent"]]])});
  rtl.createClass(this,"TCustomImageControl",pas["WEBLib.Menus"].TWebCustomControl,function () {
    this.$init = function () {
      pas["WEBLib.Menus"].TWebCustomControl.$init.call(this);
      this.FURL = "";
      this.FPicture = null;
      this.FAutoSize = false;
      this.FOnLoaded = null;
      this.FOnError = null;
      this.FImageLoadPtr = null;
      this.FImageErrorPtr = null;
      this.FImageLoaded = null;
      this.FImageError = null;
    };
    this.$final = function () {
      this.FPicture = undefined;
      this.FOnLoaded = undefined;
      this.FOnError = undefined;
      this.FImageLoaded = undefined;
      this.FImageError = undefined;
      pas["WEBLib.Menus"].TWebCustomControl.$final.call(this);
    };
    this.SetURL = function (AURL) {
      this.FURL = AURL;
      this.SetContainerURL(AURL);
    };
    this.GetBase64Img = function () {
      var Result = "";
      Result = pas["WEBLib.WebTools"].GetBase64Image(this.GetElementHandle(),0,0);
      return Result;
    };
    this.HandleImageLoad = function (AEvent) {
      var Result = false;
      var el = null;
      var w = 0;
      var h = 0;
      el = this.GetElementHandle();
      w = el.naturalWidth;
      h = el.naturalHeight;
      this.FPicture.FWidth = w;
      this.FPicture.FHeight = h;
      if (this.FOnLoaded != null) this.FOnLoaded(this);
      if (this.FImageLoaded != null) this.FImageLoaded(AEvent);
      Result = true;
      return Result;
    };
    this.HandleError = function (AEvent) {
      var Result = false;
      var Handled = false;
      var LEventRec = pas["WEBLib.Controls"].TJSEventRecord.$new();
      var LRequestRec = pas["WEBLib.Controls"].TJSXMLHttpRequestRecord.$new();
      Result = true;
      Handled = false;
      if (this.FOnError != null) {
        LEventRec.event = AEvent;
        LRequestRec.req = AEvent.target;
        this.FOnError(this,pas["WEBLib.Controls"].TJSXMLHttpRequestRecord.$clone(LRequestRec),pas["WEBLib.Controls"].TJSEventRecord.$clone(LEventRec),{get: function () {
            return Handled;
          }, set: function (v) {
            Handled = v;
          }});
      };
      if (this.FImageError != null) this.FImageError(AEvent);
      if (!Handled && !(pas.Classes.TComponentStateItem.csDesigning in this.FComponentState) && (this.FURL !== "")) throw pas.SysUtils.Exception.$create("Create$1",["Error loading image " + this.FURL]);
      return Result;
    };
    this.SetPicture = function (Value) {
      this.FPicture.Assign(Value);
    };
    this.PictureChanged = function (Sender) {
      this.SetURL(this.FPicture.FFilename);
      this.UpdateElement();
    };
    this.PictureDataChanged = function (Sender) {
      this.SetContainerURL("data:image/png;base64," + pas["WEBLib.WebTools"].HexImageDecodeAsBase64(this.FPicture.GetData()));
    };
    this.CreateElement = function () {
      var Result = null;
      Result = document.createElement("IMG");
      if (this.FURL !== "") Result.setAttribute("src",this.FURL);
      return Result;
    };
    this.UpdateElement = function () {
      pas["WEBLib.Controls"].TControl.UpdateElement.call(this);
      if (this.FAutoSize && (this.GetElementHandle() != null)) {
        this.GetElementHandle().style.removeProperty("width");
        this.GetElementHandle().style.removeProperty("height");
      };
    };
    this.SetContainerURL = function (AURL) {
      if (this.GetContainer() != null) {
        if (AURL === "") {
          this.GetContainer().removeAttribute("src")}
         else this.GetContainer().setAttribute("src",AURL);
        this.UpdateElement();
      };
    };
    this.BindEvents = function () {
      pas["WEBLib.Controls"].TCustomControl.BindEvents.call(this);
      if (this.GetElementBindHandle() != null) {
        this.GetElementBindHandle().addEventListener("load",this.FImageLoadPtr);
        if (!(pas.Classes.TComponentStateItem.csDesigning in this.FComponentState)) this.GetElementBindHandle().addEventListener("error",this.FImageErrorPtr);
      };
    };
    this.UnbindEvents = function () {
      var eh = null;
      pas["WEBLib.Controls"].TControl.UnbindEvents.call(this);
      if (this.GetElementBindHandle() != null) {
        eh = this.GetElementBindHandle();
        eh.removeEventListener("load",this.FImageLoadPtr);
        if (!(pas.Classes.TComponentStateItem.csDesigning in this.FComponentState)) eh.removeEventListener("error",this.FImageErrorPtr);
      };
    };
    this.ClearMethodPointers = function () {
      pas["WEBLib.Controls"].TControl.ClearMethodPointers.call(this);
      this.FImageLoadPtr = null;
      this.FImageErrorPtr = null;
    };
    this.GetMethodPointers = function () {
      pas["WEBLib.Controls"].TControl.GetMethodPointers.call(this);
      if (this.FImageLoadPtr === null) this.FImageLoadPtr = rtl.createCallback(this,"HandleImageLoad");
      if (this.FImageErrorPtr === null) this.FImageErrorPtr = rtl.createCallback(this,"HandleError");
    };
    this.CreateInitialize = function () {
      pas["WEBLib.Controls"].TCustomControl.CreateInitialize.call(this);
      this.FPicture = pas["WEBLib.Graphics"].TURLPicture.$create("Create");
      this.FPicture.FOnChange = rtl.createCallback(this,"PictureChanged");
      this.FPicture.FOnDataChange = rtl.createCallback(this,"PictureDataChanged");
      this.SetColor(-1);
      this.SetTabStop(false);
      if (pas.Classes.TComponentStateItem.csDesigning in this.FComponentState) {
        this.SetWidth(400);
        this.SetHeight(300);
      };
    };
    this.Destroy = function () {
      rtl.free(this,"FPicture");
      pas["WEBLib.Controls"].TCustomControl.Destroy.call(this);
    };
    this.Clear = function () {
      this.SetURL($impl.emptyimgres);
    };
    this.DataURL = function () {
      var Result = "";
      Result = "data:image/png;base64," + this.GetBase64Img();
      return Result;
    };
    this.DataURL$1 = function (AWidth, AHeight) {
      var Result = "";
      Result = "data:image/png;base64," + pas["WEBLib.WebTools"].GetBase64Image(this.GetElementHandle(),AWidth,AHeight);
      return Result;
    };
    this.ResizeImage = function () {
      this.ResizeImage$2(this.GetWidth(),this.GetHeight(),false);
    };
    this.ResizeImage$1 = function (AWidth, AHeight) {
      this.ResizeImage$2(AWidth,AHeight,false);
    };
    this.ResizeImage$2 = function (AWidth, AHeight, AspectRatio) {
      var w = 0;
      var h = 0;
      var r = 0.0;
      if (AspectRatio) {
        if ((this.ImageWidth() === AWidth) || (this.ImageHeight() === AHeight)) return;
      } else {
        if ((this.ImageWidth() === AWidth) && (this.ImageHeight() === AHeight)) return;
      };
      if ((AWidth === 0) || (AHeight === 0)) return;
      w = AWidth;
      h = AHeight;
      if (AspectRatio) {
        if ((this.ImageWidth() / w) > (this.ImageHeight() / h)) {
          r = this.ImageWidth() / w}
         else r = this.ImageHeight() / h;
        w = Math.round(this.ImageWidth() / r);
        h = Math.round(this.ImageHeight() / r);
      };
      this.SetURL("data:image/png;base64," + pas["WEBLib.WebTools"].GetBase64Image(this.GetElementHandle(),w,h));
    };
    this.ImageWidth = function () {
      var Result = 0;
      var el = null;
      var w = 0;
      Result = -1;
      if (this.GetElementHandle() != null) {
        el = this.GetElementHandle();
        w = el.naturalWidth;
        Result = w;
      };
      return Result;
    };
    this.ImageHeight = function () {
      var Result = 0;
      var el = null;
      var h = 0;
      Result = -1;
      if (this.GetElementHandle() != null) {
        el = this.GetElementHandle();
        h = el.naturalHeight;
        Result = h;
      };
      return Result;
    };
    this.LoadFromArrayBuffer = function (AArray) {
      var uint8b = null;
      var dataUri = "";
      uint8b = new Uint8Array(AArray);
      dataUri = btoa(new Uint8Array(uint8b).reduce(function (data, byte) {
      return data + String.fromCharCode(byte);
      }, ''));
      this.SetURL("data:image/jpeg;base64," + dataUri);
    };
    this.SaveToArrayBuffer = function (AArray) {
      AArray = pas["WEBLib.Utils"].Base64ToArrayBuffer(this.GetBase64Img());
    };
    this.LoadFromURL = function (AURL) {
      var $Self = this;
      var Result = null;
      Result = new Promise(function (ASuccess, AFailed) {
        $Self.LoadFromURL$1(AURL,function (AEvent) {
          ASuccess(AEvent);
        },function (AEvent) {
          AFailed(AEvent);
        });
      });
      return Result;
    };
    this.LoadFromURL$1 = function (AURL, ImageLoaded, ImageError) {
      this.FImageLoaded = ImageLoaded;
      this.FImageError = ImageError;
      this.SetURL(AURL);
    };
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
    var $r = this.$rtti;
    $r.addProperty("Align",2,pas["WEBLib.Controls"].$rtti["TAlign"],"FAlign","SetAlign",{Default: pas["WEBLib.Controls"].TAlign.alNone});
    $r.addProperty("AlignWithMargins",2,rtl.boolean,"FAlignWithMargins","SetAlignWithMargins",{Default: false});
    $r.addProperty("Anchors",2,pas["WEBLib.Controls"].$rtti["TAnchors"],"FAnchors","SetAnchors",{Default: rtl.createSet(pas["WEBLib.Controls"].TAnchorKind.akLeft,pas["WEBLib.Controls"].TAnchorKind.akTop)});
    $r.addProperty("AutoSize",0,rtl.boolean,"FAutoSize","FAutoSize",{Default: false});
    $r.addProperty("Center",0,pas["WEBLib.Controls"].$rtti["TCenter"],"FCenter","");
    $r.addProperty("ChildOrder",2,rtl.longint,"FChildOrder","SetChildOrderEx",{Default: 0});
    $r.addProperty("DragMode",2,pas["WEBLib.Controls"].$rtti["TDragMode"],"FDragMode","SetDragMode",{Default: pas["WEBLib.Controls"].TDragMode.dmManual});
    $r.addProperty("ElementClassName",2,pas["WEBLib.Controls"].$rtti["TElementClassName"],"FElementClassName","SetElementClassName");
    $r.addProperty("ElementFont",2,pas["WEBLib.Controls"].$rtti["TElementFont"],"FElementFont","SetElementFont",{Default: pas["WEBLib.Controls"].TElementFont.efProperty});
    $r.addProperty("ElementID",3,pas["WEBLib.Controls"].$rtti["TElementID"],"GetID","SetID");
    $r.addProperty("ElementPosition",2,pas["WEBLib.Controls"].$rtti["TElementPosition"],"FElementPosition","SetElementPosition",{Default: pas["WEBLib.Controls"].TElementPosition.epAbsolute});
    $r.addProperty("HeightPercent",2,rtl.double,"FHeightPercent","SetHeightPercent",{Default: 100});
    $r.addProperty("HeightStyle",2,pas["WEBLib.Controls"].$rtti["TSizeStyle"],"FHeightStyle","SetHeightStyle",{Default: pas["WEBLib.Controls"].TSizeStyle.ssAbsolute});
    $r.addProperty("Margins",2,pas["WEBLib.Controls"].$rtti["TMargins"],"FMargins","SetMargins");
    $r.addProperty("PopupMenu",0,pas["WEBLib.Menus"].$rtti["TPopupMenu"],"FPopupMenu","FPopupMenu");
    $r.addProperty("ShowHint",2,rtl.boolean,"FShowHint","SetShowHint",{Default: false});
    $r.addProperty("WidthPercent",2,rtl.double,"FWidthPercent","SetWidthPercent",{Default: 100});
    $r.addProperty("WidthStyle",2,pas["WEBLib.Controls"].$rtti["TSizeStyle"],"FWidthStyle","SetWidthStyle",{Default: pas["WEBLib.Controls"].TSizeStyle.ssAbsolute});
    $r.addProperty("OnClick",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnClick","FOnClick");
    $r.addProperty("OnDblClick",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnDblClick","FOnDblClick");
    $r.addProperty("OnError",0,pas["WEBLib.Controls"].$rtti["THTTPErrorEvent"],"FOnError","FOnError");
    $r.addProperty("OnLoaded",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnLoaded","FOnLoaded");
    $r.addProperty("OnDragDrop",0,pas["WEBLib.Controls"].$rtti["TDragDropEvent"],"FOnDragDrop","FOnDragDrop");
    $r.addProperty("OnDragOver",0,pas["WEBLib.Controls"].$rtti["TDragOverEvent"],"FOnDragOver","FOnDragOver");
    $r.addProperty("OnEndDrag",0,pas["WEBLib.Controls"].$rtti["TEndDragEvent"],"FonEndDrag","FonEndDrag");
    $r.addProperty("OnStartDrag",0,pas["WEBLib.Controls"].$rtti["TStartDragEvent"],"FOnStartDrag","FOnStartDrag");
  });
  rtl.createClass(this,"TImageControl",this.TCustomImageControl,function () {
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
    var $r = this.$rtti;
    $r.addProperty("Picture",2,pas["WEBLib.Graphics"].$rtti["TURLPicture"],"FPicture","SetPicture");
    $r.addProperty("URL",2,rtl.string,"FURL","SetURL");
  });
  rtl.createClass(this,"TWebImageControl",this.TImageControl,function () {
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
  });
  this.$rtti.$Class("TImageZoomControl");
  rtl.createClass(this,"TImageZoomAppearance",pas.Classes.TPersistent,function () {
    this.$init = function () {
      pas.Classes.TPersistent.$init.call(this);
      this.FOwner = null;
      this.FHeightPercent = 0;
      this.FWidthPercent = 0;
      this.FResponsiveHeightPercent = 0;
      this.FResponsiveWidthPercent = 0;
      this.FResponsiveMaxWidth = 0;
    };
    this.$final = function () {
      this.FOwner = undefined;
      pas.Classes.TPersistent.$final.call(this);
    };
    this.SetHeightPercent = function (Value) {
      if ((this.FHeightPercent !== Value) && (this.FHeightPercent <= 100)) {
        this.FHeightPercent = Value;
        this.FOwner.UpdateElement();
      };
    };
    this.SetWidthPercent = function (Value) {
      if ((this.FWidthPercent !== Value) && (this.FWidthPercent <= 100)) {
        this.FWidthPercent = Value;
        this.FOwner.UpdateElement();
      };
    };
    this.SetResponsiveHeightPercent = function (Value) {
      if ((this.FResponsiveHeightPercent !== Value) && (this.FResponsiveHeightPercent <= 100)) {
        this.FResponsiveHeightPercent = Value;
        this.FOwner.UpdateElement();
      };
    };
    this.SetResponsiveWidthPercent = function (Value) {
      if ((this.FResponsiveWidthPercent !== Value) && (this.FResponsiveWidthPercent <= 100)) {
        this.FResponsiveWidthPercent = Value;
        this.FOwner.UpdateElement();
      };
    };
    this.SetResponsiveMaxWidth = function (Value) {
      if ((this.FResponsiveMaxWidth !== Value) && (this.FResponsiveMaxWidth >= 0)) {
        this.FResponsiveMaxWidth = Value;
        this.FOwner.UpdateElement();
      };
    };
    this.Create$1 = function (AOwner) {
      this.FHeightPercent = 100;
      this.FWidthPercent = 100;
      this.FResponsiveHeightPercent = 100;
      this.FResponsiveWidthPercent = 100;
      this.FResponsiveMaxWidth = 768;
      this.FOwner = AOwner;
      return this;
    };
    this.Destroy = function () {
      pas.System.TObject.Destroy.call(this);
    };
    this.Assign = function (Source) {
      pas.Classes.TPersistent.Assign.apply(this,arguments);
      if ($mod.TImageZoomAppearance.isPrototypeOf(Source)) {
        this.FHeightPercent = rtl.as(Source,$mod.TImageZoomAppearance).FHeightPercent;
        this.FWidthPercent = rtl.as(Source,$mod.TImageZoomAppearance).FWidthPercent;
        this.FResponsiveHeightPercent = rtl.as(Source,$mod.TImageZoomAppearance).FResponsiveHeightPercent;
        this.FResponsiveWidthPercent = rtl.as(Source,$mod.TImageZoomAppearance).FResponsiveWidthPercent;
        this.FResponsiveMaxWidth = rtl.as(Source,$mod.TImageZoomAppearance).FResponsiveMaxWidth;
      };
    };
    this.GetOwner = function () {
      var Result = null;
      Result = this.FOwner;
      return Result;
    };
    var $r = this.$rtti;
    $r.addMethod("Create$1",2,[["AOwner",$mod.$rtti["TImageZoomControl"]]]);
    $r.addProperty("HeightPercent",2,rtl.longint,"FHeightPercent","SetHeightPercent",{Default: 100});
    $r.addProperty("WidthPercent",2,rtl.longint,"FWidthPercent","SetWidthPercent",{Default: 100});
    $r.addProperty("ResponsiveHeightPercent",2,rtl.longint,"FResponsiveHeightPercent","SetResponsiveHeightPercent",{Default: 100});
    $r.addProperty("ResponsiveWidthPercent",2,rtl.longint,"FResponsiveWidthPercent","SetResponsiveWidthPercent",{Default: 100});
    $r.addProperty("ResponsiveMaxWidth",2,rtl.longint,"FResponsiveMaxWidth","SetResponsiveMaxWidth",{Default: 768});
  });
  rtl.createClass(this,"TImageZoomControl",this.TCustomImageControl,function () {
    this.$init = function () {
      $mod.TCustomImageControl.$init.call(this);
      this.FStyle = null;
      this.FOverlay = null;
      this.FPictureZoom = null;
      this.FURLZoom = "";
      this.FPictureZoomDataURL = "";
      this.FAppearance = null;
      this.FZoomBkgOpacity = 0.0;
      this.FZoomBkgColor = 0;
    };
    this.$final = function () {
      this.FStyle = undefined;
      this.FOverlay = undefined;
      this.FPictureZoom = undefined;
      this.FAppearance = undefined;
      $mod.TCustomImageControl.$final.call(this);
    };
    this.SetPictureZoom = function (Value) {
      this.FPictureZoom.Assign(Value);
    };
    this.SetURLZoom = function (Value) {
      if (this.FURLZoom !== Value) {
        this.FURLZoom = Value;
        this.UpdateElement();
      };
    };
    this.PictureZoomChanged = function (Sender) {
      this.SetURLZoom(this.FPictureZoom.FFilename);
      this.FPictureZoomDataURL = "";
      this.UpdateElement();
    };
    this.PictureZoomDataChanged = function (Sender) {
      this.FPictureZoomDataURL = "data:image/png;base64," + pas["WEBLib.WebTools"].HexImageDecodeAsBase64(this.FPictureZoom.GetData());
      this.UpdateElement();
    };
    this.UpdateElement = function () {
      var PopupImage = "";
      var Popup = null;
      var r = 0;
      var g = 0;
      var b = 0;
      var l = 0;
      var op = "";
      $mod.TCustomImageControl.UpdateElement.call(this);
      if (!(this.GetElementHandle() != null)) return;
      if (this.FOverlay != null) {
        this.GetElementHandle().setAttribute("onClick",'document.getElementById("' + this.FName + 'myModal").style.display = "block"');
        if (this.FPictureZoomDataURL !== "") {
          PopupImage = this.FPictureZoomDataURL}
         else PopupImage = this.FURLZoom;
        if (PopupImage === "") PopupImage = this.FURL;
        if (this.GetIsLinked() && (PopupImage === "")) {
          PopupImage = this.GetElementHandle().getAttribute("src");
        };
        op = pas.SysUtils.FloatToStr(this.FZoomBkgOpacity);
        pas.SysUtils.StringReplace(op,",",".",rtl.createSet(pas.SysUtils.TStringReplaceFlag.rfReplaceAll));
        l = pas["WEBLib.Graphics"].ColorToRGB(this.FZoomBkgColor);
        r = pas["WEBLib.Graphics"].GetRValue(l);
        g = pas["WEBLib.Graphics"].GetGValue(l);
        b = pas["WEBLib.Graphics"].GetBValue(l);
        this.FStyle.innerHTML = "." + this.FName + "modal-overlay {\r" + "  display: none;\r" + "  position: fixed;\r" + "  z-index: 99999999;\r" + "  width: 100%;\r" + "  height: 100%;\r" + "  overflow: hidden;\r" + "  top: 50%;\r" + "  left: 50%;\r" + "  -ms-transform: translate(-50%, -50%);\r" + "  transform: translate(-50%, -50%);\r" + "  background-color: rgba(" + pas.SysUtils.TByteHelper.ToString$1.call({get: function () {
            return r;
          }, set: function (v) {
            r = v;
          }}) + "," + pas.SysUtils.TByteHelper.ToString$1.call({get: function () {
            return g;
          }, set: function (v) {
            g = v;
          }}) + "," + pas.SysUtils.TByteHelper.ToString$1.call({get: function () {
            return b;
          }, set: function (v) {
            b = v;
          }}) + ",0.2);\r" + "}\r" + "." + this.FName + "modal {\r" + "  display: block;\r" + "  position: absolute;\r" + "  z-index: 99999999;\r" + "  width: " + pas.SysUtils.IntToStr(this.FAppearance.FWidthPercent) + "%;\r" + "  height: " + pas.SysUtils.IntToStr(this.FAppearance.FHeightPercent) + "%;\r" + "  overflow: hidden;\r" + "  top: 50%;\r" + "  left: 50%;\r" + "  -ms-transform: translate(-50%, -50%);\r" + "  transform: translate(-50%, -50%);\r" + "  background-color: rgba(" + pas.SysUtils.TByteHelper.ToString$1.call({get: function () {
            return r;
          }, set: function (v) {
            r = v;
          }}) + "," + pas.SysUtils.TByteHelper.ToString$1.call({get: function () {
            return g;
          }, set: function (v) {
            g = v;
          }}) + "," + pas.SysUtils.TByteHelper.ToString$1.call({get: function () {
            return b;
          }, set: function (v) {
            b = v;
          }}) + "," + op + ");\r" + "}\r" + "." + this.FName + "modal-content {\r" + "  display: block;\r" + "  margin: 0;\r" + "  position: absolute;\r" + "  top: 50%;\r" + "  left: 50%;\r" + "  -ms-transform: translate(-50%, -50%);\r" + "  transform: translate(-50%, -50%);\r" + "  max-width: 100%;\r" + "  max-height: 100%;\r" + "}\r" + "." + this.FName + "close {\r" + "  z-index: 99999999;\r" + "  position: absolute;\r" + "  top: 15px;\r" + "  right: 35px;\r" + "  color: #f1f1f1;\r" + "  font-size: 40px;\r" + "  font-weight: bold;\r" + "  transition: 0.3s;\r" + "}\r" + "." + this.FName + "close:hover,\r" + "." + this.FName + "close:focus {\r" + "  color: #bbb;\r" + "  text-decoration: none;\r" + "  cursor: pointer;\r" + "}\r" + "@media only screen and (max-width: 769px) {\r" + "\t." + this.FName + "modal {\r" + "  width: " + pas.SysUtils.IntToStr(this.FAppearance.FResponsiveWidthPercent) + "%;\r" + "  height: " + pas.SysUtils.IntToStr(this.FAppearance.FResponsiveHeightPercent) + "%;\r" + "\t}\r" + "}\r";
        this.FOverlay.setAttribute("onClick",'this.style.display = "none";');
        this.FOverlay.setAttribute("id",this.FName + "myModal");
        this.FOverlay.setAttribute("class",this.FName + "modal-overlay");
        while (this.FOverlay.firstChild != null) this.FOverlay.removeChild(this.FOverlay.firstChild);
        Popup = document.createElement("DIV");
        Popup.setAttribute("class",this.FName + "modal");
        Popup.innerHTML = '<span class="' + this.FName + 'close">&times;</span>' + '<img class="' + this.FName + 'modal-content" src="' + PopupImage + '">';
        this.FOverlay.innerHTML = "";
        this.FOverlay.appendChild(Popup);
      };
    };
    this.CreateInitialize = function () {
      $mod.TCustomImageControl.CreateInitialize.call(this);
      this.FAppearance = $mod.TImageZoomAppearance.$create("Create$1",[this]);
      this.FPictureZoom = pas["WEBLib.Graphics"].TURLPicture.$create("Create");
      this.FPictureZoom.FOnChange = rtl.createCallback(this,"PictureZoomChanged");
      this.FPictureZoom.FOnDataChange = rtl.createCallback(this,"PictureZoomDataChanged");
      this.FPictureZoomDataURL = "";
      this.FZoomBkgColor = 0;
      this.FZoomBkgOpacity = 0.9;
      this.FStyle = document.createElement("STYLE");
      this.FOverlay = document.createElement("DIV");
      document.body.appendChild(this.FStyle);
      document.body.appendChild(this.FOverlay);
      if (pas.Classes.TComponentStateItem.csDesigning in this.FComponentState) {
        this.SetWidth(100);
        this.SetHeight(75);
      };
    };
    this.CreateElement = function () {
      var Result = null;
      Result = $mod.TCustomImageControl.CreateElement.call(this);
      return Result;
    };
    this.Destroy = function () {
      rtl.free(this,"FAppearance");
      rtl.free(this,"FPictureZoom");
      $mod.TCustomImageControl.Destroy.call(this);
    };
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
    var $r = this.$rtti;
    $r.addProperty("Appearance",0,$mod.$rtti["TImageZoomAppearance"],"FAppearance","FAppearance");
    $r.addProperty("Picture",2,pas["WEBLib.Graphics"].$rtti["TURLPicture"],"FPicture","SetPicture");
    $r.addProperty("PopupMenu",0,pas["WEBLib.Menus"].$rtti["TPopupMenu"],"FPopupMenu","FPopupMenu");
    $r.addProperty("URL",2,rtl.string,"FURL","SetURL");
    $r.addProperty("PictureZoom",2,pas["WEBLib.Graphics"].$rtti["TURLPicture"],"FPictureZoom","SetPictureZoom");
    $r.addProperty("URLZoom",2,rtl.string,"FURLZoom","SetURLZoom");
    $r.addProperty("ZoomBkgColor",0,pas["WEBLib.Graphics"].$rtti["TColor"],"FZoomBkgColor","FZoomBkgColor",{Default: 0});
    $r.addProperty("ZoomBkgOpacity",0,rtl.double,"FZoomBkgOpacity","FZoomBkgOpacity");
  });
  rtl.createClass(this,"TWebImageZoomControl",this.TImageZoomControl,function () {
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
  });
  rtl.createClass(this,"TCustomPanel",pas["WEBLib.Menus"].TWebCustomControl,function () {
    this.$init = function () {
      pas["WEBLib.Menus"].TWebCustomControl.$init.call(this);
      this.FAutoSize = false;
      this.FIsSizing = false;
      this.FPadding = null;
      this.FShowCaption = false;
      this.FLabel = null;
      this.FPanelBody = null;
      this.FElementBodyClassName = "";
      this.FAlignment = 0;
    };
    this.$final = function () {
      this.FPadding = undefined;
      this.FLabel = undefined;
      this.FPanelBody = undefined;
      pas["WEBLib.Menus"].TWebCustomControl.$final.call(this);
    };
    this.SetShowCaption = function (Value) {
      if (this.FShowCaption !== Value) {
        this.FShowCaption = Value;
        this.UpdateElementVisual();
      };
    };
    this.SetPadding = function (Value) {
      this.FPadding.Assign(Value);
      this.Realign();
    };
    this.SetAlignment = function (Value) {
      if (this.FAlignment !== Value) {
        this.FAlignment = Value;
        this.UpdateElement();
      };
    };
    this.CreateElement = function () {
      var Result = null;
      Result = document.createElement("SPAN");
      this.FPanelBody = document.createElement("DIV");
      this.FPanelBody.setAttribute("class","card-body");
      Result.appendChild(this.FPanelBody);
      return Result;
    };
    this.SetCaption = function (AValue) {
      pas["WEBLib.Controls"].TCustomControl.SetCaption.call(this,AValue);
      if ((this.GetElementHandle() != null) && this.FShowCaption) {
        if (!(this.FLabel != null)) {
          this.FLabel = document.createElement("SPAN");
          this.FLabel.innerHTML = this.FCaption;
          if (this.GetChildContainer() != null) {
            this.GetChildContainer().appendChild(this.FLabel)}
           else this.GetElementHandle().appendChild(this.FLabel);
          this.UpdateElementVisual();
        } else {
          this.FLabel.innerHTML = this.FCaption;
        };
      };
    };
    this.SetBorderStyle = function (AValue) {
      pas["WEBLib.Controls"].TCustomControl.SetBorderStyle.apply(this,arguments);
      this.UpdateElement();
    };
    this.SetAutoSize = function (AValue) {
      this.FAutoSize = AValue;
      if (this.FAutoSize && !this.IsUpdating()) {
        this.DoAutoSize();
      };
    };
    this.UpdateElementVisual = function () {
      pas["WEBLib.Controls"].TCustomControl.UpdateElementVisual.call(this);
      if (this.GetElementHandle() != null) {
        if (!this.GetIsLinked()) {
          if (this.FAutoSize) {
            this.GetElementHandle().style.setProperty("overflow","");
            this.GetElementHandle().style.setProperty("white-space","normal");
            if (this.FVisible) this.GetElementHandle().style.setProperty("display","inline");
          } else {
            this.GetElementHandle().style.setProperty("overflow","hidden");
            this.GetElementHandle().style.setProperty("white-space","nowrap");
            if (this.FVisible) this.GetElementHandle().style.setProperty("display","inline-block");
          };
          this.GetElementHandle().style.setProperty("padding-left",pas.SysUtils.IntToStr(this.FPadding.FLeft) + "px");
          this.GetElementHandle().style.setProperty("padding-right",pas.SysUtils.IntToStr(this.FPadding.FRight) + "px");
          this.GetElementHandle().style.setProperty("padding-top",pas.SysUtils.IntToStr(this.FPadding.FTop) + "px");
          this.GetElementHandle().style.setProperty("padding-bottom",pas.SysUtils.IntToStr(this.FPadding.FBottom) + "px");
          this.GetElementHandle().style.setProperty("box-sizing","border-box");
          if (this.FElementBodyClassName !== "") {
            this.GetChildContainer().setAttribute("class",this.FElementBodyClassName)}
           else this.GetChildContainer().removeAttribute("class");
        };
        if (this.FLabel != null) {
          if (this.FShowCaption) {
            this.FLabel.innerHTML = this.FCaption}
           else this.FLabel.innerHTML = "";
          if (this.FVisible) {
            this.GetElementHandle().style.setProperty("display","flex");
            var $tmp = this.FAlignment;
            if ($tmp === pas.Classes.TAlignment.taLeftJustify) {
              this.GetElementHandle().style.setProperty("justify-content","flex-start")}
             else if ($tmp === pas.Classes.TAlignment.taCenter) {
              this.GetElementHandle().style.setProperty("justify-content","center")}
             else if ($tmp === pas.Classes.TAlignment.taRightJustify) this.GetElementHandle().style.setProperty("justify-content","flex-end");
            this.GetElementHandle().style.setProperty("align-items","center");
          };
        };
        this.GetElementHandle().style.setProperty("user-select","");
        if (this.FCursor === 0) this.GetElementHandle().style.setProperty("cursor","");
      };
    };
    this.GetOuterWidth = function () {
      var Result = 0;
      Result = pas["WEBLib.Controls"].TControl.GetOuterWidth.call(this);
      return Result;
    };
    this.GetOuterHeight = function () {
      var Result = 0;
      Result = pas["WEBLib.Controls"].TControl.GetOuterHeight.call(this);
      return Result;
    };
    this.GetChildContainer = function () {
      var Result = null;
      if (this.FPanelBody != null) {
        Result = this.FPanelBody}
       else Result = pas["WEBLib.Controls"].TControl.GetChildContainer.call(this);
      return Result;
    };
    this.RegisterParent = function (AValue) {
      pas["WEBLib.Controls"].TControl.RegisterParent.apply(this,arguments);
      if (this.FAutoSize) this.DoAutoSize();
    };
    this.UnRegisterParent = function (AValue) {
      pas["WEBLib.Controls"].TControl.UnRegisterParent.apply(this,arguments);
      if (this.FAutoSize) this.DoAutoSize();
    };
    this.UpdatePadding = function (ARect) {
      ARect.Left = this.FPadding.FLeft;
      ARect.Top = this.FPadding.FTop;
      ARect.Right = ARect.Right - this.FPadding.FRight;
      ARect.Bottom = ARect.Bottom - this.FPadding.FBottom;
    };
    this.DoAutoSize = function () {
      var i = 0;
      var minx = 0;
      var miny = 0;
      var maxx = 0;
      var maxy = 0;
      var r = null;
      var el = null;
      if (this.FIsSizing) return;
      this.FIsSizing = true;
      if ((this.FWidthStyle === pas["WEBLib.Controls"].TSizeStyle.ssAbsolute) && (this.FHeightStyle === pas["WEBLib.Controls"].TSizeStyle.ssAbsolute)) {
        maxx = 0;
        maxy = 0;
        minx = 0xFFFF;
        miny = 0xFFFF;
        for (var $l = 0, $end = this.GetControlsCount() - 1; $l <= $end; $l++) {
          i = $l;
          if (this.GetControls(i).FWidthStyle === pas["WEBLib.Controls"].TSizeStyle.ssAbsolute) {
            if ((this.GetControls(i).GetLeft() + this.GetControls(i).GetWidth()) > maxx) maxx = this.GetControls(i).GetLeft() + this.GetControls(i).GetWidth();
            if (this.GetControls(i).GetLeft() < minx) minx = this.GetControls(i).GetLeft();
          } else {
            el = this.GetControls(i).GetElementHandle();
            if (el != null) {
              r = el.getBoundingClientRect();
              if (((r.x - this.GetLeft()) + r.width) > maxx) maxx = Math.round((r.x - this.GetLeft()) + r.width);
              minx = 0;
            };
          };
          if (this.GetControls(i).FHeightStyle === pas["WEBLib.Controls"].TSizeStyle.ssAbsolute) {
            if ((this.GetControls(i).GetTop() + this.GetControls(i).GetHeight()) > maxy) maxy = this.GetControls(i).GetTop() + this.GetControls(i).GetHeight();
            if (this.GetControls(i).GetTop() < miny) miny = this.GetControls(i).GetTop();
          } else {
            el = this.GetControls(i).GetElementHandle();
            if (el != null) {
              r = el.getBoundingClientRect();
              if (((r.y - this.GetTop()) + r.height) > maxy) maxy = Math.round((r.y - this.GetTop()) + r.height);
              miny = 0;
            };
          };
        };
        if (pas.Classes.TComponentStateItem.csDesigning in this.FComponentState) {
          if ((this.GetControlsCount() === 0) || (maxx === 0) || (maxy === 0)) return;
        };
        if (this.FBorderStyle === pas["WEBLib.Controls"].TBorderStyle.bsSingle) {
          maxx += 1;
          maxy += 1;
        };
        for (var $l1 = 0, $end1 = this.GetControlsCount() - 1; $l1 <= $end1; $l1++) {
          i = $l1;
          this.GetControls(i).SetLeft(this.GetControls(i).GetLeft() - minx);
          this.GetControls(i).SetTop(this.GetControls(i).GetTop() - miny);
        };
        this.SetWidth(maxx - minx);
        this.SetHeight(maxy - miny);
      } else {
        this.SetWidth(-1);
        this.SetHeight(-1);
      };
      this.UpdateElement();
      this.FIsSizing = false;
    };
    this.AlignControl = function (AControl) {
      pas["WEBLib.Controls"].TControl.AlignControl.apply(this,arguments);
      if (this.FAutoSize) this.DoAutoSize();
    };
    this.CreateInitialize = function () {
      pas["WEBLib.Controls"].TCustomControl.CreateInitialize.call(this);
      if (pas.Classes.TComponentStateItem.csDesigning in this.FComponentState) this.FEnablePropagation = true;
      this.FAutoSize = false;
      this.FAlignment = pas.Classes.TAlignment.taCenter;
      this.SetColor(15790320);
      this.SetTabStop(false);
      this.FCustomBorder = true;
      this.SetShowCaption(true);
      this.FControlStyle = rtl.unionSet(this.FControlStyle,rtl.createSet(pas["WEBLib.Controls"].TControlStyleValue.csAcceptsControls));
      this.FLabel = null;
      this.FPadding = pas["WEBLib.Controls"].TPadding.$create("Create$1");
      if (pas.Classes.TComponentStateItem.csDesigning in this.FComponentState) {
        this.SetWidth(400);
        this.SetHeight(300);
      };
    };
    this.Destroy = function () {
      rtl.free(this,"FPadding");
      pas["WEBLib.Controls"].TCustomControl.Destroy.call(this);
    };
    this.EndUpdate = function () {
      pas["WEBLib.Controls"].TCustomControl.EndUpdate.call(this);
      if (this.FAutoSize) this.SetAutoSize(true);
    };
    this.SetBounds = function (X, Y, AWidth, AHeight) {
      pas["WEBLib.Controls"].TControl.SetBounds.apply(this,arguments);
      if (this.FAutoSize) this.DoAutoSize();
    };
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
  });
  rtl.createClass(this,"TPanel",this.TCustomPanel,function () {
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
    var $r = this.$rtti;
    $r.addProperty("Align",2,pas["WEBLib.Controls"].$rtti["TAlign"],"FAlign","SetAlign",{Default: pas["WEBLib.Controls"].TAlign.alNone});
    $r.addProperty("Alignment",2,pas.Classes.$rtti["TAlignment"],"FAlignment","SetAlignment",{Default: pas.Classes.TAlignment.taCenter});
    $r.addProperty("AlignWithMargins",2,rtl.boolean,"FAlignWithMargins","SetAlignWithMargins",{Default: false});
    $r.addProperty("Anchors",2,pas["WEBLib.Controls"].$rtti["TAnchors"],"FAnchors","SetAnchors",{Default: rtl.createSet(pas["WEBLib.Controls"].TAnchorKind.akLeft,pas["WEBLib.Controls"].TAnchorKind.akTop)});
    $r.addProperty("AutoSize",2,rtl.boolean,"FAutoSize","SetAutoSize",{Default: false});
    $r.addProperty("BorderColor",2,pas["WEBLib.Graphics"].$rtti["TColor"],"FBorderColor","SetBorderColor",{Default: 12632256});
    $r.addProperty("BorderStyle",2,pas["WEBLib.Controls"].$rtti["TBorderStyle"],"FBorderStyle","SetBorderStyle",{Default: pas["WEBLib.Controls"].TBorderStyle.bsSingle});
    $r.addProperty("Caption",2,rtl.string,"FCaption","SetCaption");
    $r.addProperty("Center",0,pas["WEBLib.Controls"].$rtti["TCenter"],"FCenter","");
    $r.addProperty("ChildOrder",2,rtl.longint,"FChildOrder","SetChildOrderEx",{Default: 0});
    $r.addProperty("Color",2,pas["WEBLib.Graphics"].$rtti["TColor"],"FColor","SetColor");
    $r.addProperty("DragMode",2,pas["WEBLib.Controls"].$rtti["TDragMode"],"FDragMode","SetDragMode",{Default: pas["WEBLib.Controls"].TDragMode.dmManual});
    $r.addProperty("ElementBodyClassName",0,pas["WEBLib.Controls"].$rtti["TElementClassName"],"FElementBodyClassName","FElementBodyClassName");
    $r.addProperty("ElementID",3,pas["WEBLib.Controls"].$rtti["TElementID"],"GetID","SetID");
    $r.addProperty("ElementFont",2,pas["WEBLib.Controls"].$rtti["TElementFont"],"FElementFont","SetElementFont",{Default: pas["WEBLib.Controls"].TElementFont.efProperty});
    $r.addProperty("ElementPosition",2,pas["WEBLib.Controls"].$rtti["TElementPosition"],"FElementPosition","SetElementPosition",{Default: pas["WEBLib.Controls"].TElementPosition.epAbsolute});
    $r.addProperty("Font",2,pas["WEBLib.Graphics"].$rtti["TFont"],"FFont","SetFont");
    $r.addProperty("HeightPercent",2,rtl.double,"FHeightPercent","SetHeightPercent",{Default: 100});
    $r.addProperty("HeightStyle",2,pas["WEBLib.Controls"].$rtti["TSizeStyle"],"FHeightStyle","SetHeightStyle",{Default: pas["WEBLib.Controls"].TSizeStyle.ssAbsolute});
    $r.addProperty("Margins",2,pas["WEBLib.Controls"].$rtti["TMargins"],"FMargins","SetMargins");
    $r.addProperty("Padding",2,pas["WEBLib.Controls"].$rtti["TPadding"],"FPadding","SetPadding");
    $r.addProperty("ParentFont",2,rtl.boolean,"FParentFont","SetParentFont",{Default: true});
    $r.addProperty("PopupMenu",0,pas["WEBLib.Menus"].$rtti["TPopupMenu"],"FPopupMenu","FPopupMenu");
    $r.addProperty("Role",3,rtl.string,"GetRole","SetRole");
    $r.addProperty("ShowCaption",2,rtl.boolean,"FShowCaption","SetShowCaption",{Default: true});
    $r.addProperty("TabOrder",2,rtl.longint,"FTabOrder","SetTabOrder");
    $r.addProperty("TabStop",2,rtl.boolean,"FTabStop","SetTabStop",{Default: true});
    $r.addProperty("WidthPercent",2,rtl.double,"FWidthPercent","SetWidthPercent",{Default: 100});
    $r.addProperty("WidthStyle",2,pas["WEBLib.Controls"].$rtti["TSizeStyle"],"FWidthStyle","SetWidthStyle",{Default: pas["WEBLib.Controls"].TSizeStyle.ssAbsolute});
    $r.addProperty("OnClick",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnClick","FOnClick");
    $r.addProperty("OnDblClick",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnDblClick","FOnDblClick");
    $r.addProperty("OnDragDrop",0,pas["WEBLib.Controls"].$rtti["TDragDropEvent"],"FOnDragDrop","FOnDragDrop");
    $r.addProperty("OnDragOver",0,pas["WEBLib.Controls"].$rtti["TDragOverEvent"],"FOnDragOver","FOnDragOver");
    $r.addProperty("OnEndDrag",0,pas["WEBLib.Controls"].$rtti["TEndDragEvent"],"FonEndDrag","FonEndDrag");
    $r.addProperty("OnStartDrag",0,pas["WEBLib.Controls"].$rtti["TStartDragEvent"],"FOnStartDrag","FOnStartDrag");
    $r.addProperty("OnTouchStart",0,pas["WEBLib.Controls"].$rtti["TTouchEvent"],"FOnTouchStart","FOnTouchStart");
    $r.addProperty("OnTouchMove",0,pas["WEBLib.Controls"].$rtti["TTouchEvent"],"FOnTouchMove","FOnTouchMove");
    $r.addProperty("OnTouchEnd",0,pas["WEBLib.Controls"].$rtti["TTouchEvent"],"FOnTouchEnd","FOnTouchEnd");
    $r.addProperty("OnTouchCancel",0,pas["WEBLib.Controls"].$rtti["TTouchEvent"],"FOnTouchCancel","FOnTouchCancel");
  });
  rtl.createClass(this,"TDivPanel",this.TPanel,function () {
    this.CreateElement = function () {
      var Result = null;
      Result = document.createElement("DIV");
      return Result;
    };
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
  });
  rtl.createClass(this,"TWebPanel",this.TPanel,function () {
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
  });
  rtl.createClass(this,"TCustomGroupBox",pas["WEBLib.Menus"].TWebCustomControl,function () {
    this.$init = function () {
      pas["WEBLib.Menus"].TWebCustomControl.$init.call(this);
      this.FCaption$1 = "";
      this.FLegend = null;
      this.FFieldSet = null;
      this.FElementLegendClassName = "";
      this.FPadding = null;
    };
    this.$final = function () {
      this.FLegend = undefined;
      this.FFieldSet = undefined;
      this.FPadding = undefined;
      pas["WEBLib.Menus"].TWebCustomControl.$final.call(this);
    };
    this.SetElementLegendClassName = function (Value) {
      if (this.FElementLegendClassName !== Value) {
        this.FElementLegendClassName = Value;
        this.UpdateElementVisual();
      };
    };
    this.SetPadding = function (Value) {
      this.FPadding.Assign(Value);
      this.Realign();
    };
    this.UpdatePadding = function (ARect) {
      ARect.Left = this.FPadding.FLeft;
      ARect.Top = this.FPadding.FTop;
      ARect.Right = ARect.Right - this.FPadding.FRight;
      ARect.Bottom = ARect.Bottom - this.FPadding.FBottom;
    };
    this.SetFieldSetSize = function () {
      var dx = 0;
      var dy = 0;
      if (this.FFieldSet != null) {
        dx = 4;
        dy = 2;
        if ((this.FElementClassName !== "") || (this.FElementLegendClassName !== "")) {
          dx = 0;
          dy = 0;
        };
        if (this.FWidthStyle === pas["WEBLib.Controls"].TSizeStyle.ssAbsolute) {
          this.FFieldSet.style.setProperty("width",pas.SysUtils.IntToStr(this.GetWidth() - dx) + "px")}
         else this.FFieldSet.style.setProperty("width","90%");
        if (this.FHeightStyle === pas["WEBLib.Controls"].TSizeStyle.ssAbsolute) {
          this.FFieldSet.style.setProperty("height",pas.SysUtils.IntToStr(this.GetHeight() - dy) + "px")}
         else this.FFieldSet.style.setProperty("height","90%");
      };
    };
    this.SetCaption = function (Value) {
      if (this.FCaption$1 !== Value) {
        this.FCaption$1 = Value;
        this.UpdateElementData();
      };
    };
    this.CreateElement = function () {
      var Result = null;
      Result = document.createElement("DIV");
      this.FFieldSet = document.createElement("FIELDSET");
      Result.appendChild(this.FFieldSet);
      this.FLegend = document.createElement("LEGEND");
      this.FFieldSet.appendChild(this.FLegend);
      this.FLegend.innerHTML = this.FCaption$1;
      return Result;
    };
    this.UpdateElementData = function () {
      pas["WEBLib.Controls"].TControl.UpdateElementData.call(this);
      if (this.FLegend != null) {
        this.FLegend.innerHTML = this.FCaption$1;
      };
    };
    this.UpdateElementVisual = function () {
      pas["WEBLib.Controls"].TCustomControl.UpdateElementVisual.call(this);
      if (this.GetElementHandle() != null) {
        this.GetElementHandle().style.removeProperty("background-color");
      };
      if (this.FLegend != null) {
        this.FLegend.setAttribute("class","w-auto " + this.FElementLegendClassName);
        this.FLegend.style.setProperty("float","none");
      };
      if (this.FFieldSet != null) {
        this.FFieldSet.style.setProperty("background-color",pas["WEBLib.Graphics"].ColorToHTML(this.FColor));
        this.FFieldSet.style.setProperty("overflow","visible");
        this.SetFieldSetSize();
        this.FFieldSet.style.setProperty("white-space","nowrap");
        this.FFieldSet.style.setProperty("padding-left",pas.SysUtils.IntToStr(this.FPadding.FLeft) + "px");
        this.FFieldSet.style.setProperty("padding-right",pas.SysUtils.IntToStr(this.FPadding.FRight) + "px");
        this.FFieldSet.style.setProperty("padding-top",pas.SysUtils.IntToStr(this.FPadding.FTop) + "px");
        this.FFieldSet.style.setProperty("padding-bottom",pas.SysUtils.IntToStr(this.FPadding.FBottom) + "px");
        if (this.FVisible) this.FFieldSet.style.setProperty("display","inline-block");
        this.FFieldSet.style.setProperty("webkit-user-select","none");
        this.FFieldSet.style.setProperty("moz-user-select","none");
        this.FFieldSet.style.setProperty("khtml-user-select","none");
        this.FFieldSet.style.setProperty("ms-user-select","none");
        this.FFieldSet.style.setProperty("user-select","none");
        this.FFieldSet.style.setProperty("border","1px solid " + pas["WEBLib.Graphics"].ColorToHTML(this.FBorderColor));
      };
    };
    this.SetBoundsInt = function (X, Y, AWidth, AHeight) {
      pas["WEBLib.Controls"].TControl.SetBoundsInt.apply(this,arguments);
      this.SetFieldSetSize();
    };
    this.InitCSSLibrary = function (ALibrary) {
      if (ALibrary === pas["WEBLib.Controls"].TCSSLibrary.cssBootstrap) {
        this.SetElementLegendClassName("h6");
      };
    };
    this.Destroy = function () {
      rtl.free(this,"FPadding");
      pas["WEBLib.Controls"].TCustomControl.Destroy.call(this);
    };
    this.CreateInitialize = function () {
      pas["WEBLib.Controls"].TCustomControl.CreateInitialize.call(this);
      this.FEnablePropagation = true;
      this.FControlStyle = rtl.unionSet(this.FControlStyle,rtl.createSet(pas["WEBLib.Controls"].TControlStyleValue.csAcceptsControls));
      this.SetColor(15790320);
      this.FPadding = pas["WEBLib.Controls"].TPadding.$create("Create$1");
      if (pas.Classes.TComponentStateItem.csDesigning in this.FComponentState) {
        this.SetWidth(400);
        this.SetHeight(300);
      };
    };
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
  });
  rtl.createClass(this,"TGroupBox",this.TCustomGroupBox,function () {
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
    var $r = this.$rtti;
    $r.addProperty("Align",2,pas["WEBLib.Controls"].$rtti["TAlign"],"FAlign","SetAlign",{Default: pas["WEBLib.Controls"].TAlign.alNone});
    $r.addProperty("AlignWithMargins",2,rtl.boolean,"FAlignWithMargins","SetAlignWithMargins",{Default: false});
    $r.addProperty("Anchors",2,pas["WEBLib.Controls"].$rtti["TAnchors"],"FAnchors","SetAnchors",{Default: rtl.createSet(pas["WEBLib.Controls"].TAnchorKind.akLeft,pas["WEBLib.Controls"].TAnchorKind.akTop)});
    $r.addProperty("BorderColor",2,pas["WEBLib.Graphics"].$rtti["TColor"],"FBorderColor","SetBorderColor",{Default: 12632256});
    $r.addProperty("Caption",2,rtl.string,"FCaption$1","SetCaption");
    $r.addProperty("Color",2,pas["WEBLib.Graphics"].$rtti["TColor"],"FColor","SetColor");
    $r.addProperty("DragMode",2,pas["WEBLib.Controls"].$rtti["TDragMode"],"FDragMode","SetDragMode",{Default: pas["WEBLib.Controls"].TDragMode.dmManual});
    $r.addProperty("ElementFont",2,pas["WEBLib.Controls"].$rtti["TElementFont"],"FElementFont","SetElementFont",{Default: pas["WEBLib.Controls"].TElementFont.efProperty});
    $r.addProperty("ElementID",3,pas["WEBLib.Controls"].$rtti["TElementID"],"GetID","SetID");
    $r.addProperty("ElementLegendClassName",2,pas["WEBLib.Controls"].$rtti["TElementClassName"],"FElementLegendClassName","SetElementLegendClassName");
    $r.addProperty("ElementPosition",2,pas["WEBLib.Controls"].$rtti["TElementPosition"],"FElementPosition","SetElementPosition",{Default: pas["WEBLib.Controls"].TElementPosition.epAbsolute});
    $r.addProperty("Font",2,pas["WEBLib.Graphics"].$rtti["TFont"],"FFont","SetFont");
    $r.addProperty("HeightPercent",2,rtl.double,"FHeightPercent","SetHeightPercent",{Default: 100});
    $r.addProperty("HeightStyle",2,pas["WEBLib.Controls"].$rtti["TSizeStyle"],"FHeightStyle","SetHeightStyle",{Default: pas["WEBLib.Controls"].TSizeStyle.ssAbsolute});
    $r.addProperty("Margins",2,pas["WEBLib.Controls"].$rtti["TMargins"],"FMargins","SetMargins");
    $r.addProperty("ParentFont",2,rtl.boolean,"FParentFont","SetParentFont",{Default: true});
    $r.addProperty("PopupMenu",0,pas["WEBLib.Menus"].$rtti["TPopupMenu"],"FPopupMenu","FPopupMenu");
    $r.addProperty("Role",3,rtl.string,"GetRole","SetRole");
    $r.addProperty("WidthPercent",2,rtl.double,"FWidthPercent","SetWidthPercent",{Default: 100});
    $r.addProperty("WidthStyle",2,pas["WEBLib.Controls"].$rtti["TSizeStyle"],"FWidthStyle","SetWidthStyle",{Default: pas["WEBLib.Controls"].TSizeStyle.ssAbsolute});
    $r.addProperty("OnDragDrop",0,pas["WEBLib.Controls"].$rtti["TDragDropEvent"],"FOnDragDrop","FOnDragDrop");
    $r.addProperty("OnDragOver",0,pas["WEBLib.Controls"].$rtti["TDragOverEvent"],"FOnDragOver","FOnDragOver");
    $r.addProperty("OnEndDrag",0,pas["WEBLib.Controls"].$rtti["TEndDragEvent"],"FonEndDrag","FonEndDrag");
    $r.addProperty("OnStartDrag",0,pas["WEBLib.Controls"].$rtti["TStartDragEvent"],"FOnStartDrag","FOnStartDrag");
    $r.addProperty("OnTouchStart",0,pas["WEBLib.Controls"].$rtti["TTouchEvent"],"FOnTouchStart","FOnTouchStart");
    $r.addProperty("OnTouchMove",0,pas["WEBLib.Controls"].$rtti["TTouchEvent"],"FOnTouchMove","FOnTouchMove");
    $r.addProperty("OnTouchEnd",0,pas["WEBLib.Controls"].$rtti["TTouchEvent"],"FOnTouchEnd","FOnTouchEnd");
    $r.addProperty("OnTouchCancel",0,pas["WEBLib.Controls"].$rtti["TTouchEvent"],"FOnTouchCancel","FOnTouchCancel");
  });
  rtl.createClass(this,"TWebGroupBox",this.TGroupBox,function () {
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
  });
  rtl.createClass(this,"TScrollBox",this.TCustomPanel,function () {
    this.$init = function () {
      $mod.TCustomPanel.$init.call(this);
      this.FAutoScroll = false;
      this.FScrollBars = 0;
      this.FScrollPtr = null;
      this.FOnScroll = null;
      this.FVertScrollBar = null;
      this.FHorzScrollBar = null;
    };
    this.$final = function () {
      this.FOnScroll = undefined;
      this.FVertScrollBar = undefined;
      this.FHorzScrollBar = undefined;
      $mod.TCustomPanel.$final.call(this);
    };
    this.GetScrollLeft = function () {
      var Result = 0;
      Result = this.GetElementHandle().scrollLeft;
      return Result;
    };
    this.GetScrollTop = function () {
      var Result = 0;
      Result = this.GetElementHandle().scrollTop;
      return Result;
    };
    this.SetScrollLeft = function (Value) {
      this.GetElementHandle().scrollLeft = Value;
    };
    this.SetScrollTop = function (Value) {
      this.GetElementHandle().scrollTop = Value;
    };
    this.SetScrollBars = function (Value) {
      if (this.FScrollBars !== Value) {
        this.FScrollBars = Value;
        this.UpdateElement();
      };
    };
    this.UpdateElement = function () {
      pas["WEBLib.Controls"].TControl.UpdateElement.call(this);
      if ((this.GetElementHandle() != null) && !this.IsUpdating()) {
        var $tmp = this.FScrollBars;
        if ($tmp === pas["WEBLib.Controls"].TScrollStyle.ssNone) {
          this.GetElementHandle().style.setProperty("overflow","hidden");
        } else if ($tmp === pas["WEBLib.Controls"].TScrollStyle.ssVertical) {
          this.GetElementHandle().style.removeProperty("overflow");
          this.GetElementHandle().style.setProperty("overflow-x","hidden");
          this.GetElementHandle().style.setProperty("overflow-y","auto");
        } else if ($tmp === pas["WEBLib.Controls"].TScrollStyle.ssHorizontal) {
          this.GetElementHandle().style.removeProperty("overflow");
          this.GetElementHandle().style.setProperty("overflow-x","auto");
          this.GetElementHandle().style.setProperty("overflow-y","hidden");
        } else if ($tmp === pas["WEBLib.Controls"].TScrollStyle.ssBoth) {
          this.GetElementHandle().style.setProperty("overflow","auto");
        };
        if (this.FVisible && !this.GetIsLinked()) this.GetElementHandle().style.setProperty("display","inline-block");
      };
    };
    this.SetAutoScroll = function (AValue) {
      this.FAutoScroll = AValue;
    };
    this.GetClientRect = function () {
      var Result = pas.Types.TRect.$new();
      var dw = 0;
      var dh = 0;
      dw = 0;
      dh = 0;
      if ((this.GetElementHandle().scrollHeight > this.GetElementHandle().clientHeight) && (this.FScrollBars in rtl.createSet(pas["WEBLib.Controls"].TScrollStyle.ssBoth,pas["WEBLib.Controls"].TScrollStyle.ssVertical))) dw = pas["WEBLib.Controls"].GetScrollBarWidth();
      if ((this.GetElementHandle().scrollWidth > this.GetElementHandle().clientWidth) && (this.FScrollBars in rtl.createSet(pas["WEBLib.Controls"].TScrollStyle.ssBoth,pas["WEBLib.Controls"].TScrollStyle.ssHorizontal))) dh = pas["WEBLib.Controls"].GetScrollBarHeight();
      Result.$assign(pas.Types.Rect(0,0,this.GetElementHandle().clientWidth - dw,this.GetElementHandle().clientHeight - dh));
      return Result;
    };
    this.HandleDoScroll = function (Event) {
      var Result = false;
      this.DoScroll();
      Result = true;
      return Result;
    };
    this.DoScroll = function () {
      if (this.FOnScroll != null) this.FOnScroll(this);
    };
    this.ClearMethodPointers = function () {
      pas["WEBLib.Controls"].TControl.ClearMethodPointers.call(this);
      this.FScrollPtr = null;
    };
    this.GetMethodPointers = function () {
      pas["WEBLib.Controls"].TControl.GetMethodPointers.call(this);
      if (this.FScrollPtr === null) {
        this.FScrollPtr = rtl.createCallback(this,"HandleDoScroll");
      };
    };
    this.BindEvents = function () {
      var eh = null;
      pas["WEBLib.Controls"].TCustomControl.BindEvents.call(this);
      if (this.GetElementBindHandle() != null) {
        eh = this.GetElementBindHandle();
        eh.addEventListener("scroll",this.FScrollPtr);
      };
    };
    this.UnbindEvents = function () {
      var eh = null;
      pas["WEBLib.Controls"].TControl.UnbindEvents.call(this);
      if (this.GetElementBindHandle() != null) {
        eh = this.GetElementBindHandle();
        eh.removeEventListener("scroll",this.FScrollPtr);
      };
    };
    this.CreateInitialize = function () {
      $mod.TCustomPanel.CreateInitialize.call(this);
      this.FAutoScroll = true;
      this.FScrollBars = pas["WEBLib.Controls"].TScrollStyle.ssBoth;
      this.FHorzScrollBar = pas["WEBLib.Controls"].TControlScrollBar.$create("Create$1",[this,pas["WEBLib.Controls"].TScrollBarKind.sbHorizontal]);
      this.FVertScrollBar = pas["WEBLib.Controls"].TControlScrollBar.$create("Create$1",[this,pas["WEBLib.Controls"].TScrollBarKind.sbVertical]);
    };
    this.Destroy = function () {
      rtl.free(this,"FHorzScrollBar");
      rtl.free(this,"FVertScrollBar");
      $mod.TCustomPanel.Destroy.call(this);
    };
    this.ScrollBy = function (DeltaX, DeltaY) {
      this.SetScrollLeft(this.GetScrollLeft() + DeltaX);
      this.SetScrollTop(this.GetScrollTop() + DeltaY);
    };
    this.EndUpdate = function () {
      $mod.TCustomPanel.EndUpdate.call(this);
      this.AlignControl(this);
      this.AlignControl(this);
    };
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
    var $r = this.$rtti;
    $r.addProperty("Align",2,pas["WEBLib.Controls"].$rtti["TAlign"],"FAlign","SetAlign",{Default: pas["WEBLib.Controls"].TAlign.alNone});
    $r.addProperty("AlignWithMargins",2,rtl.boolean,"FAlignWithMargins","SetAlignWithMargins",{Default: false});
    $r.addProperty("Anchors",2,pas["WEBLib.Controls"].$rtti["TAnchors"],"FAnchors","SetAnchors",{Default: rtl.createSet(pas["WEBLib.Controls"].TAnchorKind.akLeft,pas["WEBLib.Controls"].TAnchorKind.akTop)});
    $r.addProperty("AutoScroll",2,rtl.boolean,"FAutoScroll","SetAutoScroll");
    $r.addProperty("BorderColor",2,pas["WEBLib.Graphics"].$rtti["TColor"],"FBorderColor","SetBorderColor",{Default: 12632256});
    $r.addProperty("BorderStyle",2,pas["WEBLib.Controls"].$rtti["TBorderStyle"],"FBorderStyle","SetBorderStyle",{Default: pas["WEBLib.Controls"].TBorderStyle.bsSingle});
    $r.addProperty("Color",2,pas["WEBLib.Graphics"].$rtti["TColor"],"FColor","SetColor");
    $r.addProperty("DragMode",2,pas["WEBLib.Controls"].$rtti["TDragMode"],"FDragMode","SetDragMode",{Default: pas["WEBLib.Controls"].TDragMode.dmManual});
    $r.addProperty("ElementFont",2,pas["WEBLib.Controls"].$rtti["TElementFont"],"FElementFont","SetElementFont",{Default: pas["WEBLib.Controls"].TElementFont.efProperty});
    $r.addProperty("ElementID",3,pas["WEBLib.Controls"].$rtti["TElementID"],"GetID","SetID");
    $r.addProperty("ElementPosition",2,pas["WEBLib.Controls"].$rtti["TElementPosition"],"FElementPosition","SetElementPosition",{Default: pas["WEBLib.Controls"].TElementPosition.epAbsolute});
    $r.addProperty("HeightPercent",2,rtl.double,"FHeightPercent","SetHeightPercent",{Default: 100});
    $r.addProperty("HeightStyle",2,pas["WEBLib.Controls"].$rtti["TSizeStyle"],"FHeightStyle","SetHeightStyle",{Default: pas["WEBLib.Controls"].TSizeStyle.ssAbsolute});
    $r.addProperty("Margins",2,pas["WEBLib.Controls"].$rtti["TMargins"],"FMargins","SetMargins");
    $r.addProperty("Padding",2,pas["WEBLib.Controls"].$rtti["TPadding"],"FPadding","SetPadding");
    $r.addProperty("PopupMenu",0,pas["WEBLib.Menus"].$rtti["TPopupMenu"],"FPopupMenu","FPopupMenu");
    $r.addProperty("Role",3,rtl.string,"GetRole","SetRole");
    $r.addProperty("ScrollBars",2,pas["WEBLib.Controls"].$rtti["TScrollStyle"],"FScrollBars","SetScrollBars");
    $r.addProperty("WidthPercent",2,rtl.double,"FWidthPercent","SetWidthPercent",{Default: 100});
    $r.addProperty("WidthStyle",2,pas["WEBLib.Controls"].$rtti["TSizeStyle"],"FWidthStyle","SetWidthStyle",{Default: pas["WEBLib.Controls"].TSizeStyle.ssAbsolute});
    $r.addProperty("OnClick",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnClick","FOnClick");
    $r.addProperty("OnDblClick",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnDblClick","FOnDblClick");
    $r.addProperty("OnMouseDown",0,pas["WEBLib.Controls"].$rtti["TMouseEvent"],"FOnMouseDown","FOnMouseDown");
    $r.addProperty("OnMouseMove",0,pas["WEBLib.Controls"].$rtti["TMouseMoveEvent"],"FOnMouseMove","FOnMouseMove");
    $r.addProperty("OnMouseUp",0,pas["WEBLib.Controls"].$rtti["TMouseEvent"],"FOnMouseUp","FOnMouseUp");
    $r.addProperty("OnResize",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnResize","FOnResize");
    $r.addProperty("OnDragDrop",0,pas["WEBLib.Controls"].$rtti["TDragDropEvent"],"FOnDragDrop","FOnDragDrop");
    $r.addProperty("OnDragOver",0,pas["WEBLib.Controls"].$rtti["TDragOverEvent"],"FOnDragOver","FOnDragOver");
    $r.addProperty("OnEndDrag",0,pas["WEBLib.Controls"].$rtti["TEndDragEvent"],"FonEndDrag","FonEndDrag");
    $r.addProperty("OnScroll",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnScroll","FOnScroll");
    $r.addProperty("OnStartDrag",0,pas["WEBLib.Controls"].$rtti["TStartDragEvent"],"FOnStartDrag","FOnStartDrag");
    $r.addProperty("OnTouchStart",0,pas["WEBLib.Controls"].$rtti["TTouchEvent"],"FOnTouchStart","FOnTouchStart");
    $r.addProperty("OnTouchMove",0,pas["WEBLib.Controls"].$rtti["TTouchEvent"],"FOnTouchMove","FOnTouchMove");
    $r.addProperty("OnTouchEnd",0,pas["WEBLib.Controls"].$rtti["TTouchEvent"],"FOnTouchEnd","FOnTouchEnd");
    $r.addProperty("OnTouchCancel",0,pas["WEBLib.Controls"].$rtti["TTouchEvent"],"FOnTouchCancel","FOnTouchCancel");
  });
  rtl.createClass(this,"TWebScrollBox",this.TScrollBox,function () {
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
  });
  rtl.createClass(this,"TSplitter",pas["WEBLib.Controls"].TCustomControl,function () {
    this.$init = function () {
      pas["WEBLib.Controls"].TCustomControl.$init.call(this);
      this.FLayer$1 = null;
      this.FTouched = false;
      this.FFirstMove = false;
      this.FSplitControl = null;
      this.FSplitPos = 0;
      this.FSizing = false;
      this.FSizingX = 0.0;
      this.FSizingY = 0.0;
      this.FOriginalWidth = 0;
      this.FOriginalHeight = 0;
      this.FGripColor = 0;
      this.FOnMoved = null;
      this.FOnMove = null;
    };
    this.$final = function () {
      this.FLayer$1 = undefined;
      this.FSplitControl = undefined;
      this.FOnMoved = undefined;
      this.FOnMove = undefined;
      pas["WEBLib.Controls"].TCustomControl.$final.call(this);
    };
    this.SetGripColor = function (Value) {
      if (this.FGripColor !== Value) {
        this.FGripColor = Value;
        this.Invalidate();
      };
    };
    this.CreateElement = function () {
      var Result = null;
      Result = pas["WEBLib.Controls"].TCustomControl.CreateElement.call(this);
      return Result;
    };
    this.UpdateElement = function () {
      pas["WEBLib.Controls"].TControl.UpdateElement.call(this);
    };
    this.UpdateElementSize = function () {
      pas["WEBLib.Controls"].TControl.UpdateElementSize.call(this);
    };
    this.ColorChanging = function () {
      pas["WEBLib.Controls"].TControl.ColorChanging.call(this);
      this.Invalidate();
    };
    this.DoSizeStart = function (X, Y) {
      var r = pas.Types.TRect.$new();
      var rc = pas.Types.TRect.$new();
      var i = 0;
      var c = null;
      var eh = null;
      this.FSizing = true;
      Y = Y - document.documentElement.scrollTop;
      r.$assign(pas.Types.Rect(this.GetLeft(),this.GetTop(),this.GetLeft() + this.GetWidth(),this.GetTop() + this.GetHeight()));
      if (this.FParent != null) {
        if (this.FAlign in rtl.createSet(pas["WEBLib.Controls"].TAlign.alRight,pas["WEBLib.Controls"].TAlign.alBottom)) {
          for (var $l = 0, $end = this.FParent.GetControlsCount() - 1; $l <= $end; $l++) {
            i = $l;
            c = this.FParent.GetControls(i);
            rc.$assign(pas.Types.Rect(c.GetLeft(),c.GetTop(),c.GetLeft() + c.GetWidth(),c.GetTop() + c.GetHeight()));
            if ((this.FAlign === pas["WEBLib.Controls"].TAlign.alRight) && (c !== this) && ((r.Left - rc.Right) < 4) && ((r.Left - rc.Right) >= 0)) {
              this.FSplitPos = rc.Left;
            };
            if ((this.FAlign === pas["WEBLib.Controls"].TAlign.alBottom) && (c !== this) && ((r.Top - rc.Bottom) < 4) && ((r.Top - rc.Bottom) >= -4)) {
              this.FSplitPos = rc.Top;
            };
          };
        };
        for (var $l1 = 0, $end1 = this.FParent.GetControlsCount() - 1; $l1 <= $end1; $l1++) {
          i = $l1;
          c = this.FParent.GetControls(i);
          rc.$assign(pas.Types.Rect(c.GetLeft(),c.GetTop(),c.GetLeft() + c.GetWidth(),c.GetTop() + c.GetHeight()));
          if ((c.FAlign === this.FAlign) && (c !== this)) {
            if ((this.FAlign === pas["WEBLib.Controls"].TAlign.alLeft) && ((rc.Right - r.Left) < 4)) {
              this.FSplitControl = c;
              this.FOriginalWidth = this.FSplitControl.GetWidth();
              this.FSizing = true;
              this.FSizingX = X;
              this.FSizingY = Y;
              break;
            };
            if ((this.FAlign === pas["WEBLib.Controls"].TAlign.alRight) && ((rc.Left - r.Right) < 4)) {
              this.FSplitControl = c;
              this.FSplitPos = rc.Right - this.FSplitPos - this.GetWidth();
              this.FOriginalWidth = this.FSplitControl.GetWidth();
              this.FSizing = true;
              this.FSizingX = X;
              this.FSizingY = Y;
              break;
            };
            if ((this.FAlign === pas["WEBLib.Controls"].TAlign.alTop) && ((rc.Bottom - r.Top) < 4)) {
              this.FSplitControl = c;
              this.FOriginalHeight = this.FSplitControl.GetHeight();
              this.FSizing = true;
              this.FSizingX = X;
              this.FSizingY = Y;
              break;
            };
            if ((this.FAlign === pas["WEBLib.Controls"].TAlign.alBottom) && ((rc.Top - r.Bottom) < 4)) {
              this.FSplitControl = c;
              this.FSplitPos = rc.Bottom - this.FSplitPos - this.GetHeight();
              this.FOriginalHeight = this.FSplitControl.GetHeight();
              this.FSizing = true;
              this.FSizingX = X;
              this.FSizingY = Y;
              break;
            };
          };
        };
      };
      this.FLayer$1 = document.createElement("SPAN");
      document.body.appendChild(this.FLayer$1);
      eh = this.FLayer$1;
      eh.style.setProperty("top","0");
      eh.style.setProperty("left","0");
      eh.style.setProperty("right","0");
      eh.style.setProperty("bottom","0");
      eh.style.setProperty("z-index","99999999");
      eh.style.setProperty("webkit-user-select","none");
      eh.style.setProperty("moz-user-select","none");
      eh.style.setProperty("khtml-user-select","none");
      eh.style.setProperty("ms-user-select","none");
      eh.style.setProperty("user-select","none");
      eh.style.setProperty("position","fixed");
      if (this.FAlign in rtl.createSet(pas["WEBLib.Controls"].TAlign.alLeft,pas["WEBLib.Controls"].TAlign.alRight)) eh.style.setProperty("cursor","col-resize");
      if (this.FAlign in rtl.createSet(pas["WEBLib.Controls"].TAlign.alTop,pas["WEBLib.Controls"].TAlign.alBottom)) eh.style.setProperty("cursor","row-resize");
      this.FFirstMove = true;
      this.FSizing = true;
      eh.addEventListener("mousemove",rtl.createSafeCallback(this,"HandleDocDoMouseMove"));
      eh.addEventListener("mouseup",rtl.createSafeCallback(this,"HandleDocDoMouseUp"));
      eh.addEventListener("touchmove",rtl.createCallback(this,"HandleDocDoTouchMove"));
      eh.addEventListener("touchend",rtl.createCallback(this,"HandleDocDoTouchEnd"));
    };
    this.HandleDoTouchStart = function (Event) {
      var Result = false;
      var l = 0.0;
      var t = 0.0;
      var touch = null;
      this.StopPropagation();
      this.PreventDefault();
      if (Event.touches.length > 0) {
        touch = Event.touches.item(0);
        this.FTouched = true;
        this.Invalidate();
        this.Invalidate();
        this.XYToClient(touch.clientX,touch.clientY,{get: function () {
            return l;
          }, set: function (v) {
            l = v;
          }},{get: function () {
            return t;
          }, set: function (v) {
            t = v;
          }});
        this.DoSizeStart(Math.round(l),Math.round(t));
      };
      Result = false;
      return Result;
    };
    this.HandleDocDoMouseMove = function (Event) {
      var Result = false;
      var dx = 0;
      var dy = 0;
      if (this.FSizing && (this.FSplitControl != null)) {
        if (this.FFirstMove) {
          this.FSizingX = Event.clientX;
          this.FSizingY = Event.clientY - document.documentElement.scrollTop;
          this.FFirstMove = false;
        } else {
          dx = Math.round(Event.clientX - this.FSizingX);
          dy = Math.round(Event.clientY - document.documentElement.scrollTop - this.FSizingY);
          if (this.FAlign === pas["WEBLib.Controls"].TAlign.alLeft) this.FSplitControl.SetWidth(Math.max(0,this.FOriginalWidth + dx));
          if (this.FAlign === pas["WEBLib.Controls"].TAlign.alRight) this.FSplitControl.SetWidth(Math.max(0,Math.min(this.FSplitPos,this.FOriginalWidth - dx)));
          if (this.FAlign === pas["WEBLib.Controls"].TAlign.alTop) this.FSplitControl.SetHeight(Math.max(0,this.FOriginalHeight + dy));
          if (this.FAlign === pas["WEBLib.Controls"].TAlign.alBottom) this.FSplitControl.SetHeight(Math.max(0,Math.min(this.FSplitPos,this.FOriginalHeight - dy)));
          this.DoRealign();
          if (this.FOnMove != null) this.FOnMove(this);
        };
      };
      Result = true;
      return Result;
    };
    this.HandleDocDoMouseUp = function (Event) {
      var Result = false;
      this.FSizing = false;
      this.FSplitControl = null;
      this.FFirstMove = true;
      this.FLayer$1.parentNode.removeChild(this.FLayer$1);
      Result = true;
      if (this.FOnMoved != null) this.FOnMoved(this);
      return Result;
    };
    this.HandleDocDoTouchMove = function (Event) {
      var Result = false;
      var touch = null;
      var dx = 0;
      var dy = 0;
      this.StopPropagation();
      if (Event.touches.length > 0) {
        touch = Event.touches.item(0);
        if (this.FSizing && (this.FSplitControl != null)) {
          if (this.FFirstMove) {
            this.FSizingX = touch.clientX;
            this.FSizingY = touch.clientY;
            this.FFirstMove = false;
          } else {
            dx = Math.round(touch.clientX - this.FSizingX);
            dy = Math.round(touch.clientY - this.FSizingY);
            if (this.FAlign === pas["WEBLib.Controls"].TAlign.alLeft) this.FSplitControl.SetWidth(this.FOriginalWidth + dx);
            if (this.FAlign === pas["WEBLib.Controls"].TAlign.alRight) this.FSplitControl.SetWidth(this.FOriginalWidth - dx);
            if (this.FAlign === pas["WEBLib.Controls"].TAlign.alTop) this.FSplitControl.SetHeight(this.FOriginalHeight + dy);
            if (this.FAlign === pas["WEBLib.Controls"].TAlign.alBottom) this.FSplitControl.SetHeight(this.FOriginalHeight - dy);
            this.DoRealign();
            if (this.FOnMove != null) this.FOnMove(this);
          };
        };
      };
      Result = true;
      return Result;
    };
    this.HandleDocDoTouchEnd = function (Event) {
      var Result = false;
      this.FTouched = false;
      this.Invalidate();
      this.FSizing = false;
      this.FSplitControl = null;
      this.FFirstMove = true;
      this.FLayer$1.parentNode.removeChild(this.FLayer$1);
      Result = true;
      if (this.FOnMoved != null) this.FOnMoved(this);
      return Result;
    };
    this.DoMouseEnter = function () {
      pas["WEBLib.Controls"].TControl.DoMouseEnter.call(this);
      if (this.FAlign in rtl.createSet(pas["WEBLib.Controls"].TAlign.alLeft,pas["WEBLib.Controls"].TAlign.alRight)) this.SetControlCursor(14);
      if (this.FAlign in rtl.createSet(pas["WEBLib.Controls"].TAlign.alTop,pas["WEBLib.Controls"].TAlign.alBottom)) this.SetControlCursor(15);
    };
    this.MouseUp = function (Button, Shift, X, Y) {
      pas["WEBLib.Controls"].TControl.MouseUp.apply(this,arguments);
      this.FSizing = false;
      this.FSplitControl = null;
    };
    this.MouseDown = function (Button, Shift, X, Y) {
      pas["WEBLib.Controls"].TControl.MouseDown.apply(this,arguments);
      this.DoSizeStart(X,Y);
    };
    this.Paint = function () {
      var xofs = 0;
      var dx = 0;
      var yofs = 0;
      var dy = 0;
      var i = 0;
      if (this.FTouched) {
        this.GetCanvas().FBrush.FColor = 8421504;
        this.GetCanvas().FPen.SetColor(8421504);
      } else {
        this.GetCanvas().FBrush.FColor = this.FColor;
        this.GetCanvas().FPen.SetColor(this.FColor);
      };
      this.GetCanvas().FBrush.FStyle = pas["WEBLib.Graphics"].TBrushStyle.bsSolid;
      this.GetCanvas().Rectangle$2(this.GetClientRect());
      if (this.FAlign in rtl.createSet(pas["WEBLib.Controls"].TAlign.alLeft,pas["WEBLib.Controls"].TAlign.alRight)) {
        dx = 0;
        dy = 6;
        yofs = rtl.trunc(this.GetHeight() / 2) - 9;
        xofs = rtl.trunc(this.GetWidth() / 2);
      };
      if (this.FAlign in rtl.createSet(pas["WEBLib.Controls"].TAlign.alTop,pas["WEBLib.Controls"].TAlign.alBottom)) {
        dx = 6;
        dy = 0;
        xofs = rtl.trunc(this.GetWidth() / 2) - 9;
        yofs = rtl.trunc(this.GetHeight() / 2) - 1;
      };
      this.GetCanvas().FBrush.FColor = this.FGripColor;
      this.GetCanvas().FPen.SetColor(this.FGripColor);
      for (i = 0; i <= 2; i++) {
        this.GetCanvas().Rectangle$1(xofs,yofs,xofs + 2,yofs + 2);
        xofs = xofs + dx;
        yofs = yofs + dy;
      };
    };
    this.CreateInitialize = function () {
      pas["WEBLib.Controls"].TCustomControl.CreateInitialize.call(this);
      this.SetControlCursor(14);
      if (pas.Classes.TComponentStateItem.csDesigning in this.FComponentState) {
        this.SetWidth(6);
        this.SetHeight(100);
      };
      this.SetAlign(pas["WEBLib.Controls"].TAlign.alLeft);
      this.FSplitControl = null;
      this.SetGripColor(16777215);
    };
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
    var $r = this.$rtti;
    $r.addProperty("Align",2,pas["WEBLib.Controls"].$rtti["TAlign"],"FAlign","SetAlign",{Default: pas["WEBLib.Controls"].TAlign.alNone});
    $r.addProperty("AlignWithMargins",2,rtl.boolean,"FAlignWithMargins","SetAlignWithMargins",{Default: false});
    $r.addProperty("Color",2,pas["WEBLib.Graphics"].$rtti["TColor"],"FColor","SetColor");
    $r.addProperty("HeightPercent",2,rtl.double,"FHeightPercent","SetHeightPercent",{Default: 100});
    $r.addProperty("HeightStyle",2,pas["WEBLib.Controls"].$rtti["TSizeStyle"],"FHeightStyle","SetHeightStyle",{Default: pas["WEBLib.Controls"].TSizeStyle.ssAbsolute});
    $r.addProperty("ElementFont",2,pas["WEBLib.Controls"].$rtti["TElementFont"],"FElementFont","SetElementFont",{Default: pas["WEBLib.Controls"].TElementFont.efProperty});
    $r.addProperty("ElementID",3,pas["WEBLib.Controls"].$rtti["TElementID"],"GetID","SetID");
    $r.addProperty("ElementPosition",2,pas["WEBLib.Controls"].$rtti["TElementPosition"],"FElementPosition","SetElementPosition",{Default: pas["WEBLib.Controls"].TElementPosition.epAbsolute});
    $r.addProperty("GripColor",2,pas["WEBLib.Graphics"].$rtti["TColor"],"FGripColor","SetGripColor",{Default: 16777215});
    $r.addProperty("Margins",2,pas["WEBLib.Controls"].$rtti["TMargins"],"FMargins","SetMargins");
    $r.addProperty("WidthPercent",2,rtl.double,"FWidthPercent","SetWidthPercent",{Default: 100});
    $r.addProperty("WidthStyle",2,pas["WEBLib.Controls"].$rtti["TSizeStyle"],"FWidthStyle","SetWidthStyle",{Default: pas["WEBLib.Controls"].TSizeStyle.ssAbsolute});
    $r.addProperty("OnClick",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnClick","FOnClick");
    $r.addProperty("OnTouchStart",0,pas["WEBLib.Controls"].$rtti["TTouchEvent"],"FOnTouchStart","FOnTouchStart");
    $r.addProperty("OnTouchMove",0,pas["WEBLib.Controls"].$rtti["TTouchEvent"],"FOnTouchMove","FOnTouchMove");
    $r.addProperty("OnTouchEnd",0,pas["WEBLib.Controls"].$rtti["TTouchEvent"],"FOnTouchEnd","FOnTouchEnd");
    $r.addProperty("OnTouchCancel",0,pas["WEBLib.Controls"].$rtti["TTouchEvent"],"FOnTouchCancel","FOnTouchCancel");
    $r.addProperty("OnMove",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnMove","FOnMove");
    $r.addProperty("OnMoved",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnMoved","FOnMoved");
  });
  rtl.createClass(this,"TWebSplitter",this.TSplitter,function () {
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
  });
  this.TVerticalAlignment = {"0": "vaTop", vaTop: 0, "1": "vaCenter", vaCenter: 1, "2": "vaBottom", vaBottom: 2};
  this.$rtti.$Enum("TVerticalAlignment",{minvalue: 0, maxvalue: 2, ordtype: 1, enumtype: this.TVerticalAlignment});
  this.TGridPanelExpandStyle = {"0": "esAddRows", esAddRows: 0, "1": "esAddColumns", esAddColumns: 1};
  this.$rtti.$Enum("TGridPanelExpandStyle",{minvalue: 0, maxvalue: 1, ordtype: 1, enumtype: this.TGridPanelExpandStyle});
  rtl.createClass(this,"TGridPanelRow",pas.Classes.TCollectionItem,function () {
    this.$init = function () {
      pas.Classes.TCollectionItem.$init.call(this);
      this.FSizeStyle = 0;
      this.FValue = 0;
      this.FMarginBottom = 0;
      this.FMarginTop = 0;
      this.FAlignment = 0;
      this.FElementClassName = "";
    };
    this.SetMarginBottom = function (Value) {
      if (this.FMarginBottom !== Value) {
        this.FMarginBottom = Value;
        this.FCollection.Update(this);
      };
    };
    this.SetMarginTop = function (Value) {
      if (this.FMarginTop !== Value) {
        this.FMarginTop = Value;
        this.FCollection.Update(this);
      };
    };
    this.SetSizeStyle = function (Value) {
      if (this.FSizeStyle !== Value) {
        this.FSizeStyle = Value;
        this.FCollection.Update(this);
      };
    };
    this.SetValue = function (Value) {
      if (this.FValue !== Value) {
        this.FValue = Value;
        this.FCollection.Update(this);
      };
    };
    this.HeightAttribute = function () {
      var Result = "";
      Result = "";
      var $tmp = this.FSizeStyle;
      if ($tmp === pas["WEBLib.Controls"].TSizeStyle.ssPercent) {
        Result = pas.SysUtils.IntToStr(this.FValue) + "%"}
       else if ($tmp === pas["WEBLib.Controls"].TSizeStyle.ssAbsolute) Result = pas.SysUtils.IntToStr(this.FValue) + "px";
      return Result;
    };
    this.Create$1 = function (ACollection) {
      pas.Classes.TCollectionItem.Create$1.apply(this,arguments);
      this.FSizeStyle = pas["WEBLib.Controls"].TSizeStyle.ssPercent;
      this.FAlignment = $mod.TVerticalAlignment.vaTop;
      this.FMarginTop = 0;
      this.FMarginBottom = 0;
      return this;
    };
    this.Assign = function (Source) {
      if ($mod.TGridPanelRow.isPrototypeOf(Source)) {
        this.FAlignment = rtl.as(Source,$mod.TGridPanelRow).FAlignment;
        this.FSizeStyle = rtl.as(Source,$mod.TGridPanelRow).FSizeStyle;
        this.FElementClassName = rtl.as(Source,$mod.TGridPanelRow).FElementClassName;
        this.FValue = rtl.as(Source,$mod.TGridPanelRow).FValue;
        this.FMarginTop = rtl.as(Source,$mod.TGridPanelRow).FMarginTop;
        this.FMarginBottom = rtl.as(Source,$mod.TGridPanelRow).FMarginBottom;
      };
    };
    var $r = this.$rtti;
    $r.addMethod("Create$1",2,[["ACollection",pas.Classes.$rtti["TCollection"]]]);
    $r.addProperty("Alignment",0,$mod.$rtti["TVerticalAlignment"],"FAlignment","FAlignment",{Default: $mod.TVerticalAlignment.vaTop});
    $r.addProperty("ElementClassName",0,rtl.string,"FElementClassName","FElementClassName");
    $r.addProperty("MarginTop",2,rtl.longint,"FMarginTop","SetMarginTop");
    $r.addProperty("MarginBottom",2,rtl.longint,"FMarginBottom","SetMarginBottom");
    $r.addProperty("SizeStyle",2,pas["WEBLib.Controls"].$rtti["TSizeStyle"],"FSizeStyle","SetSizeStyle");
    $r.addProperty("Value",2,rtl.longint,"FValue","SetValue");
  });
  rtl.createClass(this,"TGridPanelRows",pas.Classes.TOwnedCollection,function () {
    this.$init = function () {
      pas.Classes.TOwnedCollection.$init.call(this);
      this.FOnChange = null;
    };
    this.$final = function () {
      this.FOnChange = undefined;
      pas.Classes.TOwnedCollection.$final.call(this);
    };
    this.GetItem$1 = function (Index) {
      var Result = null;
      Result = this.GetItem(Index);
      return Result;
    };
    this.SetItem$1 = function (Index, Value) {
      this.SetItem(Index,Value);
    };
    this.Update = function (Item) {
      pas.Classes.TCollection.Update.apply(this,arguments);
      if (this.FOnChange != null) this.FOnChange(this);
    };
    this.Create$3 = function (AOwner) {
      pas.Classes.TOwnedCollection.Create$2.call(this,AOwner,$mod.TGridPanelRow);
      return this;
    };
    this.Add$1 = function () {
      var Result = null;
      Result = pas.Classes.TCollection.Add.call(this);
      return Result;
    };
    this.Insert$1 = function (Index) {
      var Result = null;
      Result = pas.Classes.TCollection.Insert.call(this,Index);
      return Result;
    };
    var $r = this.$rtti;
    $r.addMethod("Create$3",2,[["AOwner",pas.Classes.$rtti["TComponent"]]]);
  });
  rtl.createClass(this,"TGridPanelColumn",pas.Classes.TCollectionItem,function () {
    this.$init = function () {
      pas.Classes.TCollectionItem.$init.call(this);
      this.FSizeStyle = 0;
      this.FValue = 0;
      this.FMarginLeft = 0;
      this.FAlignment = 0;
      this.FMarginRight = 0;
      this.FElementClassName = "";
    };
    this.SetMarginLeft = function (Value) {
      if (this.FMarginLeft !== Value) {
        this.FMarginLeft = Value;
        this.FCollection.Update(this);
      };
    };
    this.SetMarginRight = function (Value) {
      if (this.FMarginRight !== Value) {
        this.FMarginRight = Value;
        this.FCollection.Update(this);
      };
    };
    this.SetSizeStyle = function (Value) {
      if (this.FSizeStyle !== Value) {
        this.FSizeStyle = Value;
        this.FCollection.Update(this);
      };
    };
    this.SetValue = function (Value) {
      if (this.FValue !== Value) {
        this.FValue = Value;
        this.FCollection.Update(this);
      };
    };
    this.WidthAttribute = function () {
      var Result = "";
      Result = "";
      var $tmp = this.FSizeStyle;
      if ($tmp === pas["WEBLib.Controls"].TSizeStyle.ssPercent) {
        Result = pas.SysUtils.IntToStr(this.FValue) + "%"}
       else if ($tmp === pas["WEBLib.Controls"].TSizeStyle.ssAbsolute) Result = pas.SysUtils.IntToStr(this.FValue) + "px";
      return Result;
    };
    this.Create$1 = function (ACollection) {
      pas.Classes.TCollectionItem.Create$1.apply(this,arguments);
      this.FSizeStyle = pas["WEBLib.Controls"].TSizeStyle.ssPercent;
      this.FValue = 0;
      this.FMarginLeft = 0;
      this.FMarginRight = 0;
      this.FAlignment = pas.Classes.TAlignment.taLeftJustify;
      return this;
    };
    this.Assign = function (Source) {
      if ($mod.TGridPanelColumn.isPrototypeOf(Source)) {
        this.FAlignment = rtl.as(Source,$mod.TGridPanelColumn).FAlignment;
        this.FSizeStyle = rtl.as(Source,$mod.TGridPanelColumn).FSizeStyle;
        this.FElementClassName = rtl.as(Source,$mod.TGridPanelColumn).FElementClassName;
        this.FValue = rtl.as(Source,$mod.TGridPanelColumn).FValue;
        this.FMarginLeft = rtl.as(Source,$mod.TGridPanelColumn).FMarginLeft;
        this.FMarginRight = rtl.as(Source,$mod.TGridPanelColumn).FMarginRight;
      };
    };
    var $r = this.$rtti;
    $r.addMethod("Create$1",2,[["ACollection",pas.Classes.$rtti["TCollection"]]]);
    $r.addProperty("Alignment",0,pas.Classes.$rtti["TAlignment"],"FAlignment","FAlignment",{Default: pas.Classes.TAlignment.taLeftJustify});
    $r.addProperty("ElementClassName",0,rtl.string,"FElementClassName","FElementClassName");
    $r.addProperty("MarginLeft",2,rtl.longint,"FMarginLeft","SetMarginLeft",{Default: 0});
    $r.addProperty("MarginRight",2,rtl.longint,"FMarginRight","SetMarginRight",{Default: 0});
    $r.addProperty("SizeStyle",2,pas["WEBLib.Controls"].$rtti["TSizeStyle"],"FSizeStyle","SetSizeStyle",{Default: pas["WEBLib.Controls"].TSizeStyle.ssPercent});
    $r.addProperty("Value",2,rtl.longint,"FValue","SetValue");
  });
  rtl.createClass(this,"TGridPanelColumns",pas.Classes.TOwnedCollection,function () {
    this.$init = function () {
      pas.Classes.TOwnedCollection.$init.call(this);
      this.FOnChange = null;
    };
    this.$final = function () {
      this.FOnChange = undefined;
      pas.Classes.TOwnedCollection.$final.call(this);
    };
    this.GetItem$1 = function (Index) {
      var Result = null;
      Result = this.GetItem(Index);
      return Result;
    };
    this.SetItem$1 = function (Index, Value) {
      this.SetItem(Index,Value);
    };
    this.Update = function (Item) {
      pas.Classes.TCollection.Update.apply(this,arguments);
      if (this.FOnChange != null) this.FOnChange(this);
    };
    this.Create$3 = function (AOwner) {
      pas.Classes.TOwnedCollection.Create$2.call(this,AOwner,$mod.TGridPanelColumn);
      return this;
    };
    this.Add$1 = function () {
      var Result = null;
      Result = pas.Classes.TCollection.Add.call(this);
      return Result;
    };
    this.Insert$1 = function (Index) {
      var Result = null;
      Result = pas.Classes.TCollection.Insert.call(this,Index);
      return Result;
    };
    var $r = this.$rtti;
    $r.addMethod("Create$3",2,[["AOwner",pas.Classes.$rtti["TComponent"]]]);
  });
  rtl.createClass(this,"TControlCollectionItem",pas.Classes.TCollectionItem,function () {
    this.$init = function () {
      pas.Classes.TCollectionItem.$init.call(this);
      this.FControl = null;
      this.FRow = 0;
      this.FColumn = 0;
    };
    this.$final = function () {
      this.FControl = undefined;
      pas.Classes.TCollectionItem.$final.call(this);
    };
    this.Assign = function (Source) {
      if ($mod.TControlCollectionItem.isPrototypeOf(Source)) {
        this.FColumn = rtl.as(Source,$mod.TControlCollectionItem).FColumn;
        this.FRow = rtl.as(Source,$mod.TControlCollectionItem).FRow;
        this.FControl = rtl.as(Source,$mod.TControlCollectionItem).FControl;
      };
    };
    var $r = this.$rtti;
    $r.addProperty("Column",0,rtl.longint,"FColumn","FColumn");
    $r.addProperty("Row",0,rtl.longint,"FRow","FRow");
    $r.addProperty("Control",0,pas["WEBLib.Controls"].$rtti["TWinControl"],"FControl","FControl");
  });
  rtl.createClass(this,"TControlCollection",pas.Classes.TOwnedCollection,function () {
    this.GetItem$1 = function (Index) {
      var Result = null;
      Result = this.GetItem(Index);
      return Result;
    };
    this.SetItem$1 = function (Index, Value) {
      this.SetItem(Index,Value);
    };
    this.Create$3 = function (AOwner) {
      pas.Classes.TOwnedCollection.Create$2.call(this,AOwner,$mod.TControlCollectionItem);
      return this;
    };
    this.Add$1 = function () {
      var Result = null;
      Result = pas.Classes.TCollection.Add.call(this);
      return Result;
    };
    this.Insert$1 = function (Index) {
      var Result = null;
      Result = pas.Classes.TCollection.Insert.call(this,Index);
      return Result;
    };
    this.FindItem = function (AControl) {
      var Result = null;
      var i = 0;
      Result = null;
      for (var $l = 0, $end = this.GetCount() - 1; $l <= $end; $l++) {
        i = $l;
        if (this.GetItem$1(i).FControl === AControl) {
          Result = this.GetItem$1(i);
          return Result;
        };
      };
      return Result;
    };
    this.GetItemAtCell = function (ACol, ARow) {
      var Result = null;
      var i = 0;
      Result = null;
      if ((this.Owner() != null) && $mod.TGridPanel.isPrototypeOf(this.Owner())) {
        i = ACol + (rtl.as(this.Owner(),$mod.TGridPanel).FColumnCollection.GetCount() * ARow);
        if (i < this.GetCount()) Result = this.GetItem$1(i);
      };
      return Result;
    };
    var $r = this.$rtti;
    $r.addMethod("Create$3",2,[["AOwner",pas.Classes.$rtti["TComponent"]]]);
  });
  rtl.createClass(this,"TGridPanel",pas["WEBLib.Menus"].TWebCustomControl,function () {
    this.$init = function () {
      pas["WEBLib.Menus"].TWebCustomControl.$init.call(this);
      this.FDesignTime$1 = false;
      this.FUpdateTable = false;
      this.FColCount = 0;
      this.FRowCollection = null;
      this.FColumnCollection = null;
      this.FControlCollection = null;
      this.FGridLineWidth = 0;
      this.FGridLineColor = 0;
      this.FExpandStyle = 0;
      this.FTbl = null;
      this.FTblBody = null;
    };
    this.$final = function () {
      this.FRowCollection = undefined;
      this.FColumnCollection = undefined;
      this.FControlCollection = undefined;
      this.FTbl = undefined;
      this.FTblBody = undefined;
      pas["WEBLib.Menus"].TWebCustomControl.$final.call(this);
    };
    this.SetColumnCollection = function (Value) {
      this.FColumnCollection.Assign(Value);
    };
    this.SetRowCollection = function (Value) {
      this.FRowCollection.Assign(Value);
    };
    this.SetControlCollection = function (Value) {
      this.FControlCollection.Assign(Value);
    };
    this.CreateTable = function () {
      var Result = null;
      var row = null;
      var j = 0;
      var ps = "";
      this.FTbl = document.createElement("table");
      this.FTbl.setAttribute("width","100%");
      this.FTbl.setAttribute("height","100%");
      if (this.FElementClassName !== "") {
        this.FTbl.setAttribute("class",this.FElementClassName)}
       else {
        if ((this.FGridLineColor !== -1) && (this.FGridLineWidth > 0)) {
          ps = pas.SysUtils.IntToStr(this.FGridLineWidth) + "px solid " + pas["WEBLib.Graphics"].ColorToHTML(this.FGridLineColor)}
         else {
          if (pas.Classes.TComponentStateItem.csDesigning in this.FComponentState) {
            ps = "1px dotted gray"}
           else ps = "0px";
        };
        this.FTbl.style.setProperty("border",ps);
        this.FTbl.style.setProperty("border-collapse","collapse");
      };
      pas["WEBLib.Controls"].SetHTMLElementColor(this.FTbl,this.FColor,!((this.FElementClassName === "") && !this.GetIsLinked()));
      this.FTblBody = document.createElement("tbody");
      for (var $l = 0, $end = this.FRowCollection.GetCount() - 1; $l <= $end; $l++) {
        j = $l;
        row = this.CreateRow(j);
        this.FTblBody.appendChild(row);
      };
      this.FTbl.appendChild(this.FTblBody);
      Result = this.FTbl;
      return Result;
    };
    this.CreateRow = function (AIndex) {
      var Result = null;
      var row = null;
      var cell = null;
      var i = 0;
      var ps = "";
      if ((this.FGridLineColor !== -1) && (this.FGridLineWidth > 0)) {
        ps = pas.SysUtils.IntToStr(this.FGridLineWidth) + "px solid " + pas["WEBLib.Graphics"].ColorToHTML(this.FGridLineColor)}
       else {
        if (pas.Classes.TComponentStateItem.csDesigning in this.FComponentState) {
          ps = "1px dotted gray"}
         else ps = "0px";
      };
      row = document.createElement("tr");
      if (this.FElementClassName === "") row.style.setProperty("border",ps);
      if (AIndex < this.FRowCollection.GetCount()) {
        if (this.FRowCollection.GetItem$1(AIndex).FMarginTop !== 0) row.style.setProperty("margin-top",pas.SysUtils.IntToStr(this.FRowCollection.GetItem$1(AIndex).FMarginTop));
        if (this.FRowCollection.GetItem$1(AIndex).FMarginBottom !== 0) row.style.setProperty("margin-bottom",pas.SysUtils.IntToStr(this.FRowCollection.GetItem$1(AIndex).FMarginBottom));
        if (this.FRowCollection.GetItem$1(AIndex).FElementClassName !== "") {
          row.setAttribute("class",this.FRowCollection.GetItem$1(AIndex).FElementClassName);
        };
        var $tmp = this.FRowCollection.GetItem$1(AIndex).FAlignment;
        if ($tmp === $mod.TVerticalAlignment.vaCenter) {
          row.setAttribute("valign","middle")}
         else if ($tmp === $mod.TVerticalAlignment.vaBottom) row.setAttribute("valign","bottom");
        if (this.FElementClassName === "") row.style.setProperty("border",ps);
        row.setAttribute("height",this.FRowCollection.GetItem$1(AIndex).HeightAttribute());
      };
      for (var $l = 0, $end = this.FColumnCollection.GetCount() - 1; $l <= $end; $l++) {
        i = $l;
        cell = document.createElement("td");
        if (this.FElementClassName === "") cell.style.setProperty("border",ps);
        if (this.FColumnCollection.GetItem$1(i).FMarginLeft !== 0) cell.style.setProperty("padding-left",pas.SysUtils.IntToStr(this.FColumnCollection.GetItem$1(i).FMarginLeft) + "px");
        if (this.FColumnCollection.GetItem$1(i).FMarginRight !== 0) cell.style.setProperty("padding-right",pas.SysUtils.IntToStr(this.FColumnCollection.GetItem$1(i).FMarginRight) + "px");
        if (this.FColumnCollection.GetItem$1(i).FElementClassName !== "") {
          cell.setAttribute("class",this.FColumnCollection.GetItem$1(i).FElementClassName);
        };
        var $tmp1 = this.FColumnCollection.GetItem$1(i).FAlignment;
        if ($tmp1 === pas.Classes.TAlignment.taCenter) {
          cell.setAttribute("align","center")}
         else if ($tmp1 === pas.Classes.TAlignment.taRightJustify) cell.setAttribute("align","right");
        cell.setAttribute("id",this.FName + "R" + pas.SysUtils.IntToStr(AIndex) + "C" + pas.SysUtils.IntToStr(i));
        if (AIndex === 0) {
          cell.style.setProperty("width",this.FColumnCollection.GetItem$1(i).WidthAttribute());
        };
        row.appendChild(cell);
      };
      Result = row;
      return Result;
    };
    this.CreateElement = function () {
      var Result = null;
      Result = document.createElement("SPAN");
      return Result;
    };
    this.AlignControl = function (AControl) {
      if (!(pas.Classes.TComponentStateItem.csDestroying in this.FComponentState)) this.UpdateTable();
      pas["WEBLib.Controls"].TControl.AlignControl.apply(this,arguments);
    };
    this.UpdateTable = function () {
      var i = 0;
      var j = 0;
      var k = 0;
      var mw = 0;
      var numrows = 0;
      var fragment = null;
      var destid = "";
      var control = null;
      var el = null;
      var row = null;
      var isPercent = false;
      var f = 0.0;
      if (!(this.FTblBody != null)) return;
      if (this.IsUpdating()) return;
      if (pas.Classes.TComponentStateItem.csDestroying in this.FComponentState) return;
      isPercent = true;
      mw = 0;
      for (var $l = 0, $end = this.FRowCollection.GetCount() - 1; $l <= $end; $l++) {
        i = $l;
        if (this.FRowCollection.GetItem$1(i).FSizeStyle !== pas["WEBLib.Controls"].TSizeStyle.ssPercent) {
          isPercent = false;
          break;
        } else mw = mw + this.FRowCollection.GetItem$1(i).FValue;
      };
      if (isPercent && (mw > 100)) {
        f = mw / 100;
        for (var $l1 = 0, $end1 = this.FRowCollection.GetCount() - 1; $l1 <= $end1; $l1++) {
          i = $l1;
          this.FRowCollection.GetItem$1(i).FValue = pas.System.Trunc(this.FRowCollection.GetItem$1(i).FValue / f);
        };
      };
      isPercent = true;
      mw = 0;
      for (var $l2 = 0, $end2 = this.FColumnCollection.GetCount() - 1; $l2 <= $end2; $l2++) {
        i = $l2;
        if (this.FColumnCollection.GetItem$1(i).FSizeStyle !== pas["WEBLib.Controls"].TSizeStyle.ssPercent) {
          isPercent = false;
          break;
        } else mw = mw + this.FColumnCollection.GetItem$1(i).FValue;
      };
      if (isPercent && (mw > 100)) {
        f = mw / 100;
        for (var $l3 = 0, $end3 = this.FColumnCollection.GetCount() - 1; $l3 <= $end3; $l3++) {
          i = $l3;
          this.FColumnCollection.GetItem$1(i).FValue = pas.System.Trunc(this.FColumnCollection.GetItem$1(i).FValue / f);
        };
      };
      numrows = this.FRowCollection.GetCount();
      if (this.FColCount !== this.FColumnCollection.GetCount()) numrows = 0;
      while (this.FTblBody.childNodes.length > numrows) {
        this.FTblBody.removeChild(this.FTblBody.childNodes.item(this.FTblBody.childNodes.length - 1));
      };
      while (this.FTblBody.childNodes.length < this.FRowCollection.GetCount()) {
        row = this.CreateRow(this.FTblBody.childNodes.length);
        this.FTblBody.appendChild(row);
      };
      for (var $l4 = 0, $end4 = this.FRowCollection.GetCount() - 1; $l4 <= $end4; $l4++) {
        i = $l4;
        row = this.FTblBody.childNodes.item(i);
        row.setAttribute("height",this.FRowCollection.GetItem$1(i).HeightAttribute());
      };
      i = 0;
      j = 0;
      for (var $l5 = 0, $end5 = this.FControlCollection.GetCount() - 1; $l5 <= $end5; $l5++) {
        k = $l5;
        if (this.FControlCollection.GetItem$1(k).FControl != null) {
          fragment = document.createDocumentFragment();
          control = this.FControlCollection.GetItem$1(k).FControl;
          this.FControlCollection.GetItem$1(k).FColumn = i;
          this.FControlCollection.GetItem$1(k).FRow = j;
          control.SetElementPosition(pas["WEBLib.Controls"].TElementPosition.epRelative);
          control.SetChildOrderEx(-1);
          if (control.FAlign === pas["WEBLib.Controls"].TAlign.alLeft) {
            control.SetHeightStyle(pas["WEBLib.Controls"].TSizeStyle.ssPercent);
            control.SetHeightPercent(100);
            if (control.GetElementHandle() != null) control.GetElementHandle().style.setProperty("float","left");
          };
          if (control.FAlign === pas["WEBLib.Controls"].TAlign.alRight) {
            control.SetHeightStyle(pas["WEBLib.Controls"].TSizeStyle.ssPercent);
            control.SetHeightPercent(100);
            if (control.GetElementHandle() != null) control.GetElementHandle().style.setProperty("float","right");
          };
          if (control.FAlign in rtl.createSet(pas["WEBLib.Controls"].TAlign.alTop,pas["WEBLib.Controls"].TAlign.alBottom)) {
            control.SetWidthStyle(pas["WEBLib.Controls"].TSizeStyle.ssPercent);
            control.SetWidthPercent(100);
          };
          if (control.FAlign === pas["WEBLib.Controls"].TAlign.alClient) {
            control.SetWidthStyle(pas["WEBLib.Controls"].TSizeStyle.ssPercent);
            control.SetHeightStyle(pas["WEBLib.Controls"].TSizeStyle.ssPercent);
            control.SetWidthPercent(100);
            control.SetHeightPercent(100);
          };
          row = this.FTblBody.childNodes.item(j);
          if ((row != null) && (j < this.FRowCollection.GetCount())) {
            row.setAttribute("height",this.FRowCollection.GetItem$1(j).HeightAttribute());
            if (this.FRowCollection.GetItem$1(j).FElementClassName !== "") {
              row.setAttribute("class",this.FRowCollection.GetItem$1(j).FElementClassName)}
             else row.removeAttribute("class");
          };
          if (control.GetElementHandle() != null) fragment.appendChild(control.GetElementHandle());
          destid = this.FName + "R" + pas.SysUtils.IntToStr(j) + "C" + pas.SysUtils.IntToStr(i);
          el = document.getElementById(destid);
          if (!(el != null)) {
            row = this.CreateRow(j);
            this.FTblBody.appendChild(row);
            el = document.getElementById(destid);
            if (this.FRowCollection.GetCount() > j) row.setAttribute("height",this.FRowCollection.GetItem$1(j).HeightAttribute());
          } else {
            if ((j === 0) && (i < this.FColumnCollection.GetCount())) {
              if (this.FColumnCollection.GetItem$1(i).FSizeStyle === pas["WEBLib.Controls"].TSizeStyle.ssAbsolute) {
                this.FTbl.removeAttribute("width");
                this.FTbl.removeAttribute("height");
              } else {
                this.FTbl.setAttribute("width","100%");
                this.FTbl.setAttribute("height","100%");
              };
              el.style.setProperty("width",this.FColumnCollection.GetItem$1(i).WidthAttribute());
            };
          };
          if (el != null) {
            el.appendChild(fragment);
            if (control.FAlign === pas["WEBLib.Controls"].TAlign.alTop) el.style.setProperty("vertical-align","top");
            if (control.FAlign === pas["WEBLib.Controls"].TAlign.alBottom) el.style.setProperty("vertical-align","bottom");
          };
          i += 1;
          if (i === this.FColumnCollection.GetCount()) {
            i = 0;
            j += 1;
          };
        };
      };
      for (var $l6 = 0, $end6 = this.FColumnCollection.GetCount() - 1; $l6 <= $end6; $l6++) {
        i = $l6;
        destid = this.FName + "R0C" + pas.SysUtils.IntToStr(i);
        el = document.getElementById(destid);
        if (el != null) el.style.setProperty("width",this.FColumnCollection.GetItem$1(i).WidthAttribute());
      };
      this.FColCount = this.FColumnCollection.GetCount();
    };
    this.UpdateElement = function () {
      pas["WEBLib.Controls"].TControl.UpdateElement.call(this);
      if ((this.GetElementHandle() != null) && !this.IsUpdating()) {
        this.GetElementHandle().style.setProperty("user-select","");
        if (this.FCursor === 0) this.GetElementHandle().style.setProperty("cursor","");
        if (this.FUpdateTable && (this.GetContainer() != null)) {
          this.GetContainer().appendChild(this.CreateTable());
          this.UpdateTable();
          this.FUpdateTable = false;
        };
      };
    };
    this.UpdateElementVisual = function () {
      pas["WEBLib.Controls"].TCustomControl.UpdateElementVisual.call(this);
      if (pas.Classes.TComponentStateItem.csDesigning in this.FComponentState) {
        this.GetElementHandle().style.setProperty("border","1px dotted gray");
      };
      if (!this.GetIsLinked() && (this.FTbl != null)) {
        if (this.FColor !== -1) {
          this.FTbl.style.setProperty("background-color",pas["WEBLib.Graphics"].ColorToHTML(this.FColor))}
         else this.FTbl.style.removeProperty("background-color");
      };
    };
    this.RegisterParent = function (AValue) {
      pas["WEBLib.Controls"].TControl.RegisterParent.apply(this,arguments);
      if (!this.IsUpdating() && !(pas.Classes.TComponentStateItem.csLoading in this.FComponentState)) {
        if (pas.Classes.TComponentStateItem.csLoading in AValue.FComponentState) return;
        this.FControlCollection.Add$1().FControl = AValue;
        if (this.FControlCollection.GetCount() > (this.FColumnCollection.GetCount() * this.FRowCollection.GetCount())) {
          if (this.FExpandStyle === $mod.TGridPanelExpandStyle.esAddRows) {
            this.FRowCollection.Add$1()}
           else this.FColumnCollection.Add$1();
        };
        this.UpdateTable();
      };
    };
    this.TableChanged = function (Sender) {
      this.UpdateTable();
    };
    this.Notification = function (AComponent, Operation) {
      var i = 0;
      var destid = "";
      var el = null;
      if ((Operation === pas.Classes.TOperation.opRemove) && !(pas.Classes.TComponentStateItem.csDestroying in this.FComponentState)) {
        for (var $l = this.FControlCollection.GetCount() - 1; $l >= 0; $l--) {
          i = $l;
          if (this.FControlCollection.GetItem$1(i).FControl === AComponent) {
            destid = this.FName + "R" + pas.SysUtils.IntToStr(this.FControlCollection.GetItem$1(i).FRow) + "C" + pas.SysUtils.IntToStr(this.FControlCollection.GetItem$1(i).FColumn);
            el = document.getElementById(destid);
            el.removeChild(el.firstChild);
            this.FControlCollection.GetItem$1(i).FControl = null;
            this.FControlCollection.Delete(i);
          };
        };
        this.UpdateTable();
      };
      pas["WEBLib.Menus"].TWebCustomControl.Notification.apply(this,arguments);
    };
    this.CreateInitialize = function () {
      pas["WEBLib.Controls"].TCustomControl.CreateInitialize.call(this);
      this.FDesignTime$1 = (pas.Classes.TComponentStateItem.csDesigning in this.FComponentState) && !((pas.Classes.TComponentStateItem.csReading in this.FOwner.FComponentState) || (pas.Classes.TComponentStateItem.csLoading in this.FOwner.FComponentState));
      this.FEnablePropagation = true;
      this.FControlStyle = rtl.unionSet(this.FControlStyle,rtl.createSet(pas["WEBLib.Controls"].TControlStyleValue.csAcceptsControls));
      this.FUpdateTable = true;
      this.FColCount = -1;
      this.FRowCollection = $mod.TGridPanelRows.$create("Create$3",[this]);
      this.FRowCollection.FPropName = "RowCollection";
      if (this.FDesignTime$1 && !(pas.Classes.TComponentStateItem.csLoading in this.FComponentState)) {
        this.FRowCollection.Add$1();
        this.FRowCollection.GetItem$1(0).SetValue(100);
        this.FRowCollection.GetItem$1(0).SetSizeStyle(pas["WEBLib.Controls"].TSizeStyle.ssPercent);
      };
      this.FColumnCollection = $mod.TGridPanelColumns.$create("Create$3",[this]);
      this.FColumnCollection.FPropName = "ColumnCollection";
      if (this.FDesignTime$1 && !(pas.Classes.TComponentStateItem.csLoading in this.FComponentState)) {
        this.FColumnCollection.Add$1();
        this.FColumnCollection.Add$1();
        this.FColumnCollection.GetItem$1(0).SetValue(50);
        this.FColumnCollection.GetItem$1(1).SetValue(50);
        this.FColumnCollection.GetItem$1(0).SetSizeStyle(pas["WEBLib.Controls"].TSizeStyle.ssPercent);
        this.FColumnCollection.GetItem$1(1).SetSizeStyle(pas["WEBLib.Controls"].TSizeStyle.ssPercent);
      };
      this.FRowCollection.FOnChange = rtl.createCallback(this,"TableChanged");
      this.FColumnCollection.FOnChange = rtl.createCallback(this,"TableChanged");
      this.FControlCollection = $mod.TControlCollection.$create("Create$3",[this]);
      if (pas.Classes.TComponentStateItem.csDesigning in this.FComponentState) {
        this.SetWidth(400);
        this.SetHeight(300);
      };
    };
    this.Destroy = function () {
      rtl.free(this,"FRowCollection");
      rtl.free(this,"FColumnCollection");
      rtl.free(this,"FControlCollection");
      pas["WEBLib.Controls"].TCustomControl.Destroy.call(this);
    };
    this.AddControl = function (AControl) {
      this.FControlCollection.Add$1().FControl = AControl;
      AControl.SetParent(this);
      if (this.FControlCollection.GetCount() > (this.FColumnCollection.GetCount() * this.FRowCollection.GetCount())) {
        if (this.FExpandStyle === $mod.TGridPanelExpandStyle.esAddRows) {
          this.FRowCollection.Add$1()}
         else this.FColumnCollection.Add$1();
      };
    };
    this.RemoveControl = function (AControl) {
      var i = 0;
      var r = 0;
      var c = 0;
      var row = null;
      var d = 0.0;
      for (var $l = 0, $end = this.FControlCollection.GetCount() - 1; $l <= $end; $l++) {
        i = $l;
        if (this.FControlCollection.GetItem$1(i).FControl === AControl) {
          r = this.FControlCollection.GetItem$1(i).FRow;
          c = this.FControlCollection.GetItem$1(i).FColumn;
          row = this.FTblBody.childNodes.item(r);
          row.childNodes.item(c).innerHTML = "";
          this.FControlCollection.Delete(i);
          break;
        };
      };
      if (this.FColumnCollection.GetCount() > 0) {
        d = this.FControlCollection.GetCount() / this.FColumnCollection.GetCount();
        if (pas.System.Frac(d) > 0) d = pas.System.Trunc(d + 1);
        while (d < this.FRowCollection.GetCount()) {
          this.FRowCollection.Delete(this.FRowCollection.GetCount() - 1);
        };
      };
    };
    this.EndUpdate = function () {
      pas["WEBLib.Controls"].TCustomControl.EndUpdate.call(this);
      this.UpdateTable();
    };
    this.RemoveControls = function () {
      var i = 0;
      for (var $l = this.FControlCollection.GetCount() - 1; $l >= 0; $l--) {
        i = $l;
        this.RemoveControl(this.FControlCollection.GetItem$1(i).FControl);
      };
    };
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
    var $r = this.$rtti;
    $r.addProperty("Align",2,pas["WEBLib.Controls"].$rtti["TAlign"],"FAlign","SetAlign",{Default: pas["WEBLib.Controls"].TAlign.alNone});
    $r.addProperty("AlignWithMargins",2,rtl.boolean,"FAlignWithMargins","SetAlignWithMargins",{Default: false});
    $r.addProperty("Anchors",2,pas["WEBLib.Controls"].$rtti["TAnchors"],"FAnchors","SetAnchors",{Default: rtl.createSet(pas["WEBLib.Controls"].TAnchorKind.akLeft,pas["WEBLib.Controls"].TAnchorKind.akTop)});
    $r.addProperty("Color",2,pas["WEBLib.Graphics"].$rtti["TColor"],"FColor","SetColor");
    $r.addProperty("ControlCollection",2,$mod.$rtti["TControlCollection"],"FControlCollection","SetControlCollection");
    $r.addProperty("ColumnCollection",2,$mod.$rtti["TGridPanelColumns"],"FColumnCollection","SetColumnCollection");
    $r.addProperty("DragMode",2,pas["WEBLib.Controls"].$rtti["TDragMode"],"FDragMode","SetDragMode",{Default: pas["WEBLib.Controls"].TDragMode.dmManual});
    $r.addProperty("ElementFont",2,pas["WEBLib.Controls"].$rtti["TElementFont"],"FElementFont","SetElementFont",{Default: pas["WEBLib.Controls"].TElementFont.efProperty});
    $r.addProperty("ElementID",3,pas["WEBLib.Controls"].$rtti["TElementID"],"GetID","SetID");
    $r.addProperty("ElementPosition",2,pas["WEBLib.Controls"].$rtti["TElementPosition"],"FElementPosition","SetElementPosition",{Default: pas["WEBLib.Controls"].TElementPosition.epAbsolute});
    $r.addProperty("ExpandStyle",0,$mod.$rtti["TGridPanelExpandStyle"],"FExpandStyle","FExpandStyle",{Default: $mod.TGridPanelExpandStyle.esAddRows});
    $r.addProperty("GridLineWidth",0,rtl.longint,"FGridLineWidth","FGridLineWidth",{Default: 0});
    $r.addProperty("GridLineColor",0,pas["WEBLib.Graphics"].$rtti["TColor"],"FGridLineColor","FGridLineColor",{Default: 0});
    $r.addProperty("HeightPercent",2,rtl.double,"FHeightPercent","SetHeightPercent",{Default: 100});
    $r.addProperty("HeightStyle",2,pas["WEBLib.Controls"].$rtti["TSizeStyle"],"FHeightStyle","SetHeightStyle",{Default: pas["WEBLib.Controls"].TSizeStyle.ssAbsolute});
    $r.addProperty("Margins",2,pas["WEBLib.Controls"].$rtti["TMargins"],"FMargins","SetMargins");
    $r.addProperty("PopupMenu",0,pas["WEBLib.Menus"].$rtti["TPopupMenu"],"FPopupMenu","FPopupMenu");
    $r.addProperty("Role",3,rtl.string,"GetRole","SetRole");
    $r.addProperty("RowCollection",2,$mod.$rtti["TGridPanelRows"],"FRowCollection","SetRowCollection");
    $r.addProperty("WidthPercent",2,rtl.double,"FWidthPercent","SetWidthPercent",{Default: 100});
    $r.addProperty("WidthStyle",2,pas["WEBLib.Controls"].$rtti["TSizeStyle"],"FWidthStyle","SetWidthStyle",{Default: pas["WEBLib.Controls"].TSizeStyle.ssAbsolute});
    $r.addProperty("OnDragDrop",0,pas["WEBLib.Controls"].$rtti["TDragDropEvent"],"FOnDragDrop","FOnDragDrop");
    $r.addProperty("OnDragOver",0,pas["WEBLib.Controls"].$rtti["TDragOverEvent"],"FOnDragOver","FOnDragOver");
    $r.addProperty("OnEndDrag",0,pas["WEBLib.Controls"].$rtti["TEndDragEvent"],"FonEndDrag","FonEndDrag");
    $r.addProperty("OnStartDrag",0,pas["WEBLib.Controls"].$rtti["TStartDragEvent"],"FOnStartDrag","FOnStartDrag");
    $r.addProperty("OnTouchStart",0,pas["WEBLib.Controls"].$rtti["TTouchEvent"],"FOnTouchStart","FOnTouchStart");
    $r.addProperty("OnTouchMove",0,pas["WEBLib.Controls"].$rtti["TTouchEvent"],"FOnTouchMove","FOnTouchMove");
    $r.addProperty("OnTouchEnd",0,pas["WEBLib.Controls"].$rtti["TTouchEvent"],"FOnTouchEnd","FOnTouchEnd");
    $r.addProperty("OnTouchCancel",0,pas["WEBLib.Controls"].$rtti["TTouchEvent"],"FOnTouchCancel","FOnTouchCancel");
  });
  rtl.createClass(this,"TWebGridPanel",this.TGridPanel,function () {
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
  });
  this.TMultiMediaType = {"0": "mtVideo", mtVideo: 0, "1": "mtAudio", mtAudio: 1};
  this.$rtti.$Enum("TMultiMediaType",{minvalue: 0, maxvalue: 1, ordtype: 1, enumtype: this.TMultiMediaType});
  this.TMultiMediaControl = {"0": "mcFullscreen", mcFullscreen: 0, "1": "mcDownload", mcDownload: 1, "2": "mcRemoteplayback", mcRemoteplayback: 2, "3": "mcPlaybackrate", mcPlaybackrate: 3, "4": "mcPictureInPicture", mcPictureInPicture: 4};
  this.$rtti.$Enum("TMultiMediaControl",{minvalue: 0, maxvalue: 4, ordtype: 1, enumtype: this.TMultiMediaControl});
  this.$rtti.$Set("TMultiMediaControls",{comptype: this.$rtti["TMultiMediaControl"]});
  this.$rtti.$Int("TMultiMediaVolume",{minvalue: 0, maxvalue: 100, ordtype: 1});
  this.TMultiMediaPreload = {"0": "mpAuto", mpAuto: 0, "1": "mpNone", mpNone: 1, "2": "mpMetadata", mpMetadata: 2};
  this.$rtti.$Enum("TMultiMediaPreload",{minvalue: 0, maxvalue: 2, ordtype: 1, enumtype: this.TMultiMediaPreload});
  rtl.createClass(this,"TMultimediaPlayer",pas["WEBLib.Controls"].TCustomControl,function () {
    this.$init = function () {
      pas["WEBLib.Controls"].TCustomControl.$init.call(this);
      this.FURL = "";
      this.FMultimediaType = 0;
      this.FAutoPlay = false;
      this.FControls$1 = false;
      this.FMuted = false;
      this.FLoop = false;
      this.FVolume = 0;
      this.FPlaybackRate = 0.0;
      this.FContextMenu = false;
      this.FPoster = "";
      this.FHideControls = {};
      this.FPreload = 0;
    };
    this.$final = function () {
      this.FHideControls = undefined;
      pas["WEBLib.Controls"].TCustomControl.$final.call(this);
    };
    this.SetAutoPlay = function (Value) {
      if (this.FAutoPlay !== Value) {
        this.FAutoPlay = Value;
        this.UpdateElement();
      };
    };
    this.SetControls = function (Value) {
      if (this.FControls$1 !== Value) {
        this.FControls$1 = Value;
        this.UpdateElement();
      };
    };
    this.SetMuted = function (Value) {
      var el = null;
      if (this.FMuted !== Value) {
        this.FMuted = Value;
        if (this.GetElementHandle() != null) {
          el = this.GetElementHandle();
          el.muted = Value;
        };
      };
    };
    this.SetLoop = function (Value) {
      var el = null;
      if (this.FLoop !== Value) {
        this.FLoop = Value;
        if (this.GetElementHandle() != null) {
          el = this.GetElementHandle();
          el.loop = Value;
        };
      };
    };
    this.SetURL = function (Value) {
      if (this.FURL !== Value) {
        this.FURL = Value;
        this.UpdateElement();
      };
    };
    this.SetVolume = function (Value) {
      var el = null;
      if ((this.FVolume !== Value) && (Value >= 0) && (Value <= 100)) {
        this.FVolume = Value;
        if (this.GetElementHandle() != null) {
          el = this.GetElementHandle();
          el.volume = Value/100;
        };
      };
    };
    this.GetCurrentTime = function () {
      var Result = 0.0;
      var el = null;
      var i = 0.0;
      el = this.GetElementHandle();
      if (el != null) {
        i = el.currentTime;
      };
      Result = i;
      return Result;
    };
    this.SetCurrentTime = function (Value) {
      var el = null;
      el = this.GetElementHandle();
      if (el != null) el.currentTime = Value;
    };
    this.GetDuration = function () {
      var Result = 0.0;
      var el = null;
      var i = 0.0;
      el = this.GetElementHandle();
      if (el != null) {
        i = el.duration;
      };
      Result = i;
      return Result;
    };
    this.GetEnded = function () {
      var Result = false;
      var el = null;
      var e = false;
      el = this.GetElementHandle();
      if (el != null) {
        e = el.ended;
      };
      Result = e;
      return Result;
    };
    this.GetPaused = function () {
      var Result = false;
      var el = null;
      var e = false;
      el = this.GetElementHandle();
      if (el != null) {
        e = el.paused;
      };
      Result = e;
      return Result;
    };
    this.SetPlaybackRate = function (Value) {
      if (this.FPlaybackRate !== Value) {
        this.FPlaybackRate = Value;
        this.UpdateElement();
      };
    };
    this.SetContextMenu = function (Value) {
      if (this.FContextMenu !== Value) {
        this.FContextMenu = Value;
        this.UpdateElement();
      };
    };
    this.SetPoster = function (Value) {
      var el = null;
      if (this.FPoster !== Value) {
        this.FPoster = Value;
        if (this.GetElementHandle() != null) {
          el = this.GetElementHandle();
          el.poster = Value;
        };
      };
    };
    this.SetHideControls = function (Value) {
      if (rtl.neSet(this.FHideControls,Value)) {
        this.FHideControls = rtl.refSet(Value);
        this.UpdateElement();
      };
    };
    this.SetPreload = function (Value) {
      var s = "";
      var el = null;
      if (this.FPreload !== Value) {
        this.FPreload = Value;
        if (this.GetElementHandle() != null) {
          el = this.GetElementHandle();
          var $tmp = Value;
          if ($tmp === $mod.TMultiMediaPreload.mpNone) {
            s = "none"}
           else if ($tmp === $mod.TMultiMediaPreload.mpAuto) {
            s = "auto"}
           else if ($tmp === $mod.TMultiMediaPreload.mpMetadata) s = "metadata";
          el.preload = s;
        };
      };
    };
    this.CreateElement = function () {
      var Result = null;
      var el = null;
      var src = null;
      var p = "";
      if (this.FMultimediaType === $mod.TMultiMediaType.mtVideo) {
        el = document.createElement("VIDEO")}
       else el = document.createElement("AUDIO");
      src = document.createElement("SOURCE");
      var $tmp = this.FPreload;
      if ($tmp === $mod.TMultiMediaPreload.mpNone) {
        p = "none"}
       else if ($tmp === $mod.TMultiMediaPreload.mpAuto) {
        p = "auto"}
       else if ($tmp === $mod.TMultiMediaPreload.mpMetadata) p = "metadata";
      el.defaultPlaybackRate = this.FPlaybackRate;
      el.preload = p;
      el.appendChild(src);
      Result = el;
      return Result;
    };
    this.UpdateElement = function () {
      var $Self = this;
      var el = null;
      var vid = null;
      var nocontrols = "";
      function booltoattr(b) {
        var Result = "";
        if (b) {
          Result = "true"}
         else Result = "false";
        return Result;
      };
      pas["WEBLib.Controls"].TControl.UpdateElement.call(this);
      if (this.GetElementHandle() != null) {
        vid = this.GetElementHandle();
        vid.controls = this.FControls;
        vid.defaultPlaybackRate = this.FPlaybackRate;
        vid.playbackRate = this.FPlaybackRate;
        vid.muted = this.FMuted;
        if (this.FControls$1) {
          this.GetElementHandle().setAttribute("controls","")}
         else this.GetElementHandle().removeAttribute("controls");
        if (this.FAutoPlay) {
          this.GetElementHandle().setAttribute("autoplay",booltoattr(this.FAutoPlay))}
         else this.GetElementHandle().removeAttribute("autoplay");
        if (this.FMuted) {
          this.GetElementHandle().setAttribute("muted",booltoattr(this.FMuted))}
         else this.GetElementHandle().removeAttribute("muted");
        if (!this.FContextMenu) {
          this.GetElementHandle().setAttribute("oncontextmenu","return false;")}
         else this.GetElementHandle().removeAttribute("oncontextmenu");
        this.GetElementHandle().setAttribute("volume",pas["WEBLib.Utils"].FormatProp("%.2f",pas.System.VarRecs(3,this.FVolume / 100)));
        this.GetElementHandle().setAttribute("src",this.FURL);
        nocontrols = "";
        if ($mod.TMultiMediaControl.mcFullscreen in this.FHideControls) nocontrols = "nofullscreen ";
        if ($mod.TMultiMediaControl.mcDownload in this.FHideControls) nocontrols = nocontrols + "nodownload ";
        if ($mod.TMultiMediaControl.mcRemoteplayback in this.FHideControls) nocontrols = nocontrols + "noremoteplayback ";
        if ($mod.TMultiMediaControl.mcPlaybackrate in this.FHideControls) nocontrols = nocontrols + "noplaybackrate ";
        if (nocontrols !== "") {
          this.GetElementHandle().setAttribute("controlsList",nocontrols)}
         else if (this.GetElementHandle().hasAttribute("controlsList")) this.GetElementHandle().removeAttribute("controlsList");
        if ($mod.TMultiMediaControl.mcPictureInPicture in this.FHideControls) {
          this.GetElementHandle().setAttribute("disablePictureInPicture","")}
         else if (this.GetElementHandle().hasAttribute("disablePictureInPicture")) this.GetElementHandle().removeAttribute("disablePictureInPicture");
      };
    };
    this.CreateInitialize = function () {
      pas["WEBLib.Controls"].TCustomControl.CreateInitialize.call(this);
      this.FVolume = 100;
      this.FPlaybackRate = 1;
      this.FMuted = false;
      this.FAutoPlay = false;
      this.FContextMenu = true;
      this.FPreload = $mod.TMultiMediaPreload.mpAuto;
      if (pas.Classes.TComponentStateItem.csDesigning in this.FComponentState) {
        this.SetWidth(400);
        this.SetHeight(300);
      };
    };
    this.Play = function () {
      var el = null;
      el = this.GetElementHandle();
      if (el != null) el.play();
    };
    this.Pause = function () {
      var el = null;
      el = this.GetElementHandle();
      if (el != null) {
        el.pause();
      };
    };
    this.ReLoad = function () {
      var el = null;
      el = this.GetElementHandle();
      if (el != null) el.load();
    };
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
    var $r = this.$rtti;
    $r.addProperty("AlignWithMargins",2,rtl.boolean,"FAlignWithMargins","SetAlignWithMargins",{Default: false});
    $r.addProperty("AutoPlay",2,rtl.boolean,"FAutoPlay","SetAutoPlay");
    $r.addProperty("Controls",2,rtl.boolean,"FControls$1","SetControls");
    $r.addProperty("ContextMenu",2,rtl.boolean,"FContextMenu","SetContextMenu",{Default: true});
    $r.addProperty("HideControls",2,$mod.$rtti["TMultiMediaControls"],"FHideControls","SetHideControls");
    $r.addProperty("HeightPercent",2,rtl.double,"FHeightPercent","SetHeightPercent",{Default: 100});
    $r.addProperty("HeightStyle",2,pas["WEBLib.Controls"].$rtti["TSizeStyle"],"FHeightStyle","SetHeightStyle",{Default: pas["WEBLib.Controls"].TSizeStyle.ssAbsolute});
    $r.addProperty("Loop",2,rtl.boolean,"FLoop","SetLoop");
    $r.addProperty("Margins",2,pas["WEBLib.Controls"].$rtti["TMargins"],"FMargins","SetMargins");
    $r.addProperty("MultimediaType",0,$mod.$rtti["TMultiMediaType"],"FMultimediaType","FMultimediaType");
    $r.addProperty("Muted",2,rtl.boolean,"FMuted","SetMuted");
    $r.addProperty("PlaybackRate",2,rtl.double,"FPlaybackRate","SetPlaybackRate");
    $r.addProperty("Poster",2,rtl.string,"FPoster","SetPoster");
    $r.addProperty("Preload",2,$mod.$rtti["TMultiMediaPreload"],"FPreload","SetPreload");
    $r.addProperty("URL",2,rtl.string,"FURL","SetURL");
    $r.addProperty("Volume",2,$mod.$rtti["TMultiMediaVolume"],"FVolume","SetVolume");
    $r.addProperty("WidthPercent",2,rtl.double,"FWidthPercent","SetWidthPercent",{Default: 100});
    $r.addProperty("WidthStyle",2,pas["WEBLib.Controls"].$rtti["TSizeStyle"],"FWidthStyle","SetWidthStyle",{Default: pas["WEBLib.Controls"].TSizeStyle.ssAbsolute});
    $r.addProperty("OnMouseDown",0,pas["WEBLib.Controls"].$rtti["TMouseEvent"],"FOnMouseDown","FOnMouseDown");
    $r.addProperty("OnMouseUp",0,pas["WEBLib.Controls"].$rtti["TMouseEvent"],"FOnMouseUp","FOnMouseUp");
    $r.addProperty("OnMouseMove",0,pas["WEBLib.Controls"].$rtti["TMouseMoveEvent"],"FOnMouseMove","FOnMouseMove");
  });
  rtl.createClass(this,"TWebMultiMediaPlayer",this.TMultimediaPlayer,function () {
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
  });
  rtl.createClass(this,"THTMLContainer",pas["WEBLib.Controls"].TCustomControl,function () {
    this.$init = function () {
      pas["WEBLib.Controls"].TCustomControl.$init.call(this);
      this.FHTML = null;
      this.FScrollStyle = 0;
      this.FURL = "";
      this.FOnLoaded = null;
    };
    this.$final = function () {
      this.FHTML = undefined;
      this.FOnLoaded = undefined;
      pas["WEBLib.Controls"].TCustomControl.$final.call(this);
    };
    this.SetHTML = function (Value) {
      this.FHTML.Assign(Value);
    };
    this.SetURL = function (Value) {
      this.FURL = Value;
      this.LoadFromURL(this.FURL);
    };
    this.CreateElement = function () {
      var Result = null;
      Result = document.createElement("DIV");
      return Result;
    };
    this.UpdateElement = function () {
      var TextFound = false;
      pas["WEBLib.Controls"].TControl.UpdateElement.call(this);
      if (!this.IsUpdating() && (this.GetElementHandle() != null) && (this.GetContainer() != null)) {
        if (this.FElementClassName !== "") {
          this.GetElementHandle().style.removeProperty("border");
          this.GetElementHandle().style.removeProperty("background-color");
        } else this.GetElementHandle().style.setProperty("white-space","normal");
        if (this.FHTML != null) {
          TextFound = this.FHTML.GetTextStr() !== "";
          this.GetContainer().innerHTML = this.FHTML.GetTextStr();
        };
        if (!this.GetIsLinked() && (pas.Classes.TComponentStateItem.csDesigning in this.FComponentState)) this.RenderDesigning(this.$classname,this.GetContainer(),this,!TextFound,"");
        if (!this.GetIsLinked()) {
          pas["WEBLib.Controls"].SetHTMLElementFont(this.GetElementHandle(),this.FFont,this.FElementFont === pas["WEBLib.Controls"].TElementFont.efCSS);
        };
        var $tmp = this.FScrollStyle;
        if ($tmp === pas["WEBLib.Controls"].TScrollStyle.ssBoth) {
          this.GetElementHandle().style.setProperty("overflow","auto")}
         else if ($tmp === pas["WEBLib.Controls"].TScrollStyle.ssNone) {
          this.GetElementHandle().style.setProperty("overflow","")}
         else if ($tmp === pas["WEBLib.Controls"].TScrollStyle.ssVertical) {
          this.GetElementHandle().style.setProperty("overflow-y","auto")}
         else if ($tmp === pas["WEBLib.Controls"].TScrollStyle.ssHorizontal) this.GetElementHandle().style.setProperty("overflow-x","auto");
      };
    };
    this.HTMLChanged = function (Sender) {
      this.UpdateElement();
    };
    this.DoLoaded = function () {
      if (this.FOnLoaded != null) this.FOnLoaded(this);
    };
    this.CreateInitialize = function () {
      pas["WEBLib.Controls"].TCustomControl.CreateInitialize.call(this);
      this.FHTML = pas.Classes.TStringList.$create("Create$1");
      this.FHTML.SetSkipLastLineBreak(true);
      this.FHTML.FOnChange = rtl.createCallback(this,"HTMLChanged");
      this.FScrollStyle = pas["WEBLib.Controls"].TScrollStyle.ssBoth;
      if (pas.Classes.TComponentStateItem.csDesigning in this.FComponentState) {
        this.SetWidth(240);
        this.SetHeight(160);
      };
    };
    this.Destroy = function () {
      rtl.free(this,"FHTML");
      pas["WEBLib.Controls"].TCustomControl.Destroy.call(this);
    };
    this.LoadFromURL = function (AURL) {
      var $Self = this;
      var Result = null;
      var wr = null;
      Result = new Promise(function (ASuccess, AFailed) {
        wr = pas["WEBLib.REST"].TWebHTTPRequest.$create("Create$1",[$Self]);
        wr.FURL = AURL;
        wr.Execute$1(function (AResponse, ARequest) {
          $Self.FHTML.SetTextStr(AResponse);
          $Self.DoLoaded();
          ASuccess(true);
        },function (ARequest) {
          AFailed(false);
        });
      });
      return Result;
    };
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
    var $r = this.$rtti;
    $r.addProperty("Align",2,pas["WEBLib.Controls"].$rtti["TAlign"],"FAlign","SetAlign",{Default: pas["WEBLib.Controls"].TAlign.alNone});
    $r.addProperty("AlignWithMargins",2,rtl.boolean,"FAlignWithMargins","SetAlignWithMargins",{Default: false});
    $r.addProperty("Anchors",2,pas["WEBLib.Controls"].$rtti["TAnchors"],"FAnchors","SetAnchors",{Default: rtl.createSet(pas["WEBLib.Controls"].TAnchorKind.akLeft,pas["WEBLib.Controls"].TAnchorKind.akTop)});
    $r.addProperty("DragMode",2,pas["WEBLib.Controls"].$rtti["TDragMode"],"FDragMode","SetDragMode",{Default: pas["WEBLib.Controls"].TDragMode.dmManual});
    $r.addProperty("ElementFont",2,pas["WEBLib.Controls"].$rtti["TElementFont"],"FElementFont","SetElementFont",{Default: pas["WEBLib.Controls"].TElementFont.efProperty});
    $r.addProperty("ElementID",3,pas["WEBLib.Controls"].$rtti["TElementID"],"GetID","SetID");
    $r.addProperty("ElementPosition",2,pas["WEBLib.Controls"].$rtti["TElementPosition"],"FElementPosition","SetElementPosition",{Default: pas["WEBLib.Controls"].TElementPosition.epAbsolute});
    $r.addProperty("Font",2,pas["WEBLib.Graphics"].$rtti["TFont"],"FFont","SetFont");
    $r.addProperty("HeightPercent",2,rtl.double,"FHeightPercent","SetHeightPercent",{Default: 100});
    $r.addProperty("HeightStyle",2,pas["WEBLib.Controls"].$rtti["TSizeStyle"],"FHeightStyle","SetHeightStyle",{Default: pas["WEBLib.Controls"].TSizeStyle.ssAbsolute});
    $r.addProperty("HTML",2,pas.Classes.$rtti["TStringList"],"FHTML","SetHTML");
    $r.addProperty("Margins",2,pas["WEBLib.Controls"].$rtti["TMargins"],"FMargins","SetMargins");
    $r.addProperty("ParentFont",2,rtl.boolean,"FParentFont","SetParentFont",{Default: true});
    $r.addProperty("Role",3,rtl.string,"GetRole","SetRole");
    $r.addProperty("ScrollStyle",0,pas["WEBLib.Controls"].$rtti["TScrollStyle"],"FScrollStyle","FScrollStyle");
    $r.addProperty("URL",2,rtl.string,"FURL","SetURL");
    $r.addProperty("WidthPercent",2,rtl.double,"FWidthPercent","SetWidthPercent",{Default: 100});
    $r.addProperty("WidthStyle",2,pas["WEBLib.Controls"].$rtti["TSizeStyle"],"FWidthStyle","SetWidthStyle",{Default: pas["WEBLib.Controls"].TSizeStyle.ssAbsolute});
    $r.addProperty("OnClick",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnClick","FOnClick");
    $r.addProperty("OnDblClick",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnDblClick","FOnDblClick");
    $r.addProperty("OnLoaded",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnLoaded","FOnLoaded");
    $r.addProperty("OnMouseDown",0,pas["WEBLib.Controls"].$rtti["TMouseEvent"],"FOnMouseDown","FOnMouseDown");
    $r.addProperty("OnMouseMove",0,pas["WEBLib.Controls"].$rtti["TMouseMoveEvent"],"FOnMouseMove","FOnMouseMove");
    $r.addProperty("OnMouseUp",0,pas["WEBLib.Controls"].$rtti["TMouseEvent"],"FOnMouseUp","FOnMouseUp");
    $r.addProperty("OnMouseLeave",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnMouseLeave","FOnMouseLeave");
    $r.addProperty("OnMouseEnter",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnMouseEnter","FOnMouseEnter");
    $r.addProperty("OnTouchEnd",0,pas["WEBLib.Controls"].$rtti["TTouchEvent"],"FOnTouchEnd","FOnTouchEnd");
    $r.addProperty("OnTouchCancel",0,pas["WEBLib.Controls"].$rtti["TTouchEvent"],"FOnTouchCancel","FOnTouchCancel");
    $r.addProperty("OnTouchStart",0,pas["WEBLib.Controls"].$rtti["TTouchEvent"],"FOnTouchStart","FOnTouchStart");
    $r.addProperty("OnTouchMove",0,pas["WEBLib.Controls"].$rtti["TTouchEvent"],"FOnTouchMove","FOnTouchMove");
    $r.addProperty("OnDragDrop",0,pas["WEBLib.Controls"].$rtti["TDragDropEvent"],"FOnDragDrop","FOnDragDrop");
    $r.addProperty("OnDragOver",0,pas["WEBLib.Controls"].$rtti["TDragOverEvent"],"FOnDragOver","FOnDragOver");
    $r.addProperty("OnEndDrag",0,pas["WEBLib.Controls"].$rtti["TEndDragEvent"],"FonEndDrag","FonEndDrag");
    $r.addProperty("OnStartDrag",0,pas["WEBLib.Controls"].$rtti["TStartDragEvent"],"FOnStartDrag","FOnStartDrag");
  });
  rtl.createClass(this,"TWebHTMLContainer",this.THTMLContainer,function () {
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
  });
  rtl.createClass(this,"THTMLForm",pas["WEBLib.Controls"].TCustomControl,function () {
    this.$init = function () {
      pas["WEBLib.Controls"].TCustomControl.$init.call(this);
      this.FOnSubmit = null;
      this.FAction = "";
    };
    this.$final = function () {
      this.FOnSubmit = undefined;
      pas["WEBLib.Controls"].TCustomControl.$final.call(this);
    };
    this.SetAction = function (Value) {
      var el = null;
      this.FAction = Value;
      if (!(pas.Classes.TComponentStateItem.csDesigning in this.FComponentState)) {
        if (this.GetIsLinked()) {
          el = this.GetElementHandle()}
         else el = this.GetChildContainer();
        if (el != null) el.setAttribute("action",this.FAction);
      };
    };
    this.UpdateElement = function () {
      if (!(this.GetElementHandle() != null)) return;
      pas["WEBLib.Controls"].TControl.UpdateElement.call(this);
      if (pas.Classes.TComponentStateItem.csDesigning in this.FComponentState) this.GetElementHandle().style.setProperty("background","repeating-linear-gradient(45deg,#EEEEEE 10px,#EEEEEE 10px, #ffffff 20px)");
    };
    this.CreateElement = function () {
      var Result = null;
      Result = document.createElement("DIV");
      Result.appendChild(document.createElement("FORM"));
      return Result;
    };
    this.DoHandleSubmit = function (Event) {
      var Result = false;
      this.FElementEvent = Event;
      if (this.FOnSubmit != null) this.FOnSubmit(this);
      Result = true;
      return Result;
    };
    this.GetChildContainer = function () {
      var Result = null;
      if (pas.Classes.TComponentStateItem.csDesigning in this.FComponentState) {
        Result = this.GetElementHandle()}
       else {
        if (this.GetIsLinked()) {
          Result = this.GetElementHandle()}
         else Result = this.GetElementHandle().firstChild;
      };
      return Result;
    };
    this.BindEvents = function () {
      pas["WEBLib.Controls"].TCustomControl.BindEvents.call(this);
      this.GetChildContainer().addEventListener("submit",rtl.createSafeCallback(this,"DoHandleSubmit"));
    };
    this.CheckValidity = function () {
      var Result = false;
      var el = null;
      var res = false;
      el = this.GetElementHandle();
      res = el.checkValidity();
      Result = res;
      return Result;
    };
    this.CreateInitialize = function () {
      pas["WEBLib.Controls"].TCustomControl.CreateInitialize.call(this);
      this.FEnablePropagation = true;
      this.FControlStyle = rtl.unionSet(this.FControlStyle,rtl.createSet(pas["WEBLib.Controls"].TControlStyleValue.csAcceptsControls));
      if (pas.Classes.TComponentStateItem.csDesigning in this.FComponentState) {
        this.SetWidth(400);
        this.SetHeight(300);
      };
    };
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
    var $r = this.$rtti;
    $r.addProperty("Action",2,rtl.string,"FAction","SetAction");
    $r.addProperty("Align",2,pas["WEBLib.Controls"].$rtti["TAlign"],"FAlign","SetAlign",{Default: pas["WEBLib.Controls"].TAlign.alNone});
    $r.addProperty("Anchors",2,pas["WEBLib.Controls"].$rtti["TAnchors"],"FAnchors","SetAnchors",{Default: rtl.createSet(pas["WEBLib.Controls"].TAnchorKind.akLeft,pas["WEBLib.Controls"].TAnchorKind.akTop)});
    $r.addProperty("ElementPosition",2,pas["WEBLib.Controls"].$rtti["TElementPosition"],"FElementPosition","SetElementPosition",{Default: pas["WEBLib.Controls"].TElementPosition.epAbsolute});
    $r.addProperty("ElementFont",2,pas["WEBLib.Controls"].$rtti["TElementFont"],"FElementFont","SetElementFont",{Default: pas["WEBLib.Controls"].TElementFont.efProperty});
    $r.addProperty("ElementID",3,pas["WEBLib.Controls"].$rtti["TElementID"],"GetID","SetID");
    $r.addProperty("Font",2,pas["WEBLib.Graphics"].$rtti["TFont"],"FFont","SetFont");
    $r.addProperty("HeightPercent",2,rtl.double,"FHeightPercent","SetHeightPercent",{Default: 100});
    $r.addProperty("HeightStyle",2,pas["WEBLib.Controls"].$rtti["TSizeStyle"],"FHeightStyle","SetHeightStyle",{Default: pas["WEBLib.Controls"].TSizeStyle.ssAbsolute});
    $r.addProperty("Role",3,rtl.string,"GetRole","SetRole");
    $r.addProperty("WidthPercent",2,rtl.double,"FWidthPercent","SetWidthPercent",{Default: 100});
    $r.addProperty("WidthStyle",2,pas["WEBLib.Controls"].$rtti["TSizeStyle"],"FWidthStyle","SetWidthStyle",{Default: pas["WEBLib.Controls"].TSizeStyle.ssAbsolute});
    $r.addProperty("OnSubmit",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnSubmit","FOnSubmit");
  });
  rtl.createClass(this,"TWebHTMLForm",this.THTMLForm,function () {
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
  });
  rtl.createClass(this,"TBadge",pas["WEBLib.Controls"].TCustomControl,function () {
    this.$init = function () {
      pas["WEBLib.Controls"].TCustomControl.$init.call(this);
      this.FTextColor = 0;
      this.FText = "";
    };
    this.SetTextColor = function (Value) {
      this.FTextColor = Value;
      this.UpdateElement();
    };
    this.SetText = function (Value) {
      this.FText = Value;
      this.UpdateElement();
    };
    this.CreateElement = function () {
      var Result = null;
      Result = document.createElement("SPAN");
      return Result;
    };
    this.UpdateElement = function () {
      pas["WEBLib.Controls"].TControl.UpdateElement.call(this);
      if (this.GetElementHandle() != null) {
        this.GetElementHandle().innerHTML = this.FText;
        if (this.FElementClassName === "") {
          this.GetElementHandle().setAttribute("class","tmsbadge");
          this.GetElementHandle().style.setProperty("color",pas["WEBLib.Graphics"].ColorToHTML(this.FTextColor));
        } else {
          this.GetElementHandle().style.removeProperty("color");
        };
        this.GetElementHandle().style.removeProperty("width");
        this.GetElementHandle().style.removeProperty("height");
      };
    };
    this.SetElementClassName = function (AValue) {
      pas["WEBLib.Controls"].TControl.SetElementClassName.apply(this,arguments);
      this.UpdateElement();
    };
    this.CreateInitialize = function () {
      var css = "";
      pas["WEBLib.Controls"].TCustomControl.CreateInitialize.call(this);
      this.SetColor(255);
      this.FTextColor = 16777215;
      this.FText = "1";
      css = "span.tmsbadge {" + "  background: #FF0000;" + "  border-radius: 0.8em;" + "  -moz-border-radius: 0.8em;" + "  -webkit-border-radius: 0.8em;" + "  color: #ffffff;" + "  display: inline-block;" + "  line-height: 1.6em;" + "  margin-right: 5px;" + "  text-align: center;" + "  width: 1.6em;" + "}";
      this.AddControlStyle(css);
      if (pas.Classes.TComponentStateItem.csDesigning in this.FComponentState) {
        this.SetWidth(20);
        this.SetHeight(20);
      };
    };
    this.Destroy = function () {
      pas["WEBLib.Controls"].TCustomControl.Destroy.call(this);
    };
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
    var $r = this.$rtti;
    $r.addProperty("Align",2,pas["WEBLib.Controls"].$rtti["TAlign"],"FAlign","SetAlign",{Default: pas["WEBLib.Controls"].TAlign.alNone});
    $r.addProperty("AlignWithMargins",2,rtl.boolean,"FAlignWithMargins","SetAlignWithMargins",{Default: false});
    $r.addProperty("Anchors",2,pas["WEBLib.Controls"].$rtti["TAnchors"],"FAnchors","SetAnchors",{Default: rtl.createSet(pas["WEBLib.Controls"].TAnchorKind.akLeft,pas["WEBLib.Controls"].TAnchorKind.akTop)});
    $r.addProperty("Color",2,pas["WEBLib.Graphics"].$rtti["TColor"],"FColor","SetColor",{Default: 255});
    $r.addProperty("ElementFont",2,pas["WEBLib.Controls"].$rtti["TElementFont"],"FElementFont","SetElementFont",{Default: pas["WEBLib.Controls"].TElementFont.efProperty});
    $r.addProperty("ElementID",3,pas["WEBLib.Controls"].$rtti["TElementID"],"GetID","SetID");
    $r.addProperty("ElementPosition",2,pas["WEBLib.Controls"].$rtti["TElementPosition"],"FElementPosition","SetElementPosition",{Default: pas["WEBLib.Controls"].TElementPosition.epAbsolute});
    $r.addProperty("HeightPercent",2,rtl.double,"FHeightPercent","SetHeightPercent",{Default: 100});
    $r.addProperty("HeightStyle",2,pas["WEBLib.Controls"].$rtti["TSizeStyle"],"FHeightStyle","SetHeightStyle",{Default: pas["WEBLib.Controls"].TSizeStyle.ssAbsolute});
    $r.addProperty("Margins",2,pas["WEBLib.Controls"].$rtti["TMargins"],"FMargins","SetMargins");
    $r.addProperty("Role",3,rtl.string,"GetRole","SetRole");
    $r.addProperty("Text",2,rtl.string,"FText","SetText");
    $r.addProperty("TextColor",2,pas["WEBLib.Graphics"].$rtti["TColor"],"FTextColor","SetTextColor");
    $r.addProperty("WidthPercent",2,rtl.double,"FWidthPercent","SetWidthPercent",{Default: 100});
    $r.addProperty("WidthStyle",2,pas["WEBLib.Controls"].$rtti["TSizeStyle"],"FWidthStyle","SetWidthStyle",{Default: pas["WEBLib.Controls"].TSizeStyle.ssAbsolute});
    $r.addProperty("OnClick",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnClick","FOnClick");
    $r.addProperty("OnDblClick",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnDblClick","FOnDblClick");
    $r.addProperty("OnMouseDown",0,pas["WEBLib.Controls"].$rtti["TMouseEvent"],"FOnMouseDown","FOnMouseDown");
    $r.addProperty("OnMouseUp",0,pas["WEBLib.Controls"].$rtti["TMouseEvent"],"FOnMouseUp","FOnMouseUp");
    $r.addProperty("OnMouseMove",0,pas["WEBLib.Controls"].$rtti["TMouseMoveEvent"],"FOnMouseMove","FOnMouseMove");
  });
  rtl.createClass(this,"TWebBadge",this.TBadge,function () {
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
  });
  rtl.createClass(this,"TAccordionSection",pas.Classes.TCollectionItem,function () {
    this.$init = function () {
      pas.Classes.TCollectionItem.$init.call(this);
      this.FCaption = "";
      this.FContent = "";
      this.FTag = 0;
      this.FExpanded = false;
      this.FControl = null;
    };
    this.$final = function () {
      this.FControl = undefined;
      pas.Classes.TCollectionItem.$final.call(this);
    };
    this.SetExpanded = function (Value) {
      if (this.FExpanded !== Value) {
        this.FExpanded = Value;
        if (this.FExpanded) {
          rtl.as(rtl.as(this.FCollection,$mod.TAccordionSections).Owner(),$mod.TAccordion).Expand(this)}
         else rtl.as(rtl.as(this.FCollection,$mod.TAccordionSections).Owner(),$mod.TAccordion).Collapse(this);
      };
    };
    this.SetCaption = function (Value) {
      this.FCaption = Value;
      rtl.as(this.FCollection,$mod.TAccordionSections).Update(this);
    };
    this.SetContent = function (Value) {
      this.FContent = Value;
      rtl.as(this.FCollection,$mod.TAccordionSections).Update(this);
    };
    this.Assign = function (Source) {
      if ($mod.TAccordionSection.isPrototypeOf(Source)) {
        this.FCaption = rtl.as(Source,$mod.TAccordionSection).FCaption;
        this.FContent = rtl.as(Source,$mod.TAccordionSection).FContent;
        this.FTag = rtl.as(Source,$mod.TAccordionSection).FTag;
      };
    };
    this.CaptionElement = function () {
      var Result = null;
      Result = document.getElementById(rtl.as(rtl.as(this.FCollection,$mod.TAccordionSections).Owner(),$mod.TAccordion).FName + "_" + pas.SysUtils.IntToStr(this.GetIndex()));
      return Result;
    };
    this.PanelElement = function () {
      var Result = null;
      var el = null;
      el = this.CaptionElement();
      Result = el.nextElementSibling;
      return Result;
    };
    var $r = this.$rtti;
    $r.addProperty("Caption",2,rtl.string,"FCaption","SetCaption");
    $r.addProperty("Content",2,rtl.string,"FContent","SetContent");
    $r.addProperty("Tag",0,rtl.longint,"FTag","FTag");
  });
  rtl.createClass(this,"TAccordionSections",pas.Classes.TOwnedCollection,function () {
    this.$init = function () {
      pas.Classes.TOwnedCollection.$init.call(this);
      this.FOnChange = null;
    };
    this.$final = function () {
      this.FOnChange = undefined;
      pas.Classes.TOwnedCollection.$final.call(this);
    };
    this.GetItem$1 = function (Index) {
      var Result = null;
      Result = this.GetItem(Index);
      return Result;
    };
    this.SetItem$1 = function (Index, Value) {
      this.SetItem(Index,Value);
    };
    this.Update = function (Item) {
      pas.Classes.TCollection.Update.apply(this,arguments);
      if ((this.FOnChange != null) && (this.FUpdateCount === 0)) this.FOnChange(this);
    };
    this.Create$3 = function (AOwner) {
      pas.Classes.TOwnedCollection.Create$2.call(this,AOwner,$mod.TAccordionSection);
      return this;
    };
    this.Add$1 = function () {
      var Result = null;
      Result = pas.Classes.TCollection.Add.call(this);
      return Result;
    };
    this.Insert$1 = function (Index) {
      var Result = null;
      Result = pas.Classes.TCollection.Insert.call(this,Index);
      return Result;
    };
    var $r = this.$rtti;
    $r.addMethod("Create$3",2,[["AOwner",pas.Classes.$rtti["TComponent"]]]);
  });
  this.$rtti.$MethodVar("TAccordionSectionEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["ASection",this.$rtti["TAccordionSection"]]]), methodkind: 0});
  this.$rtti.$MethodVar("TAccordionSectionAllowEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["ASection",this.$rtti["TAccordionSection"]],["Allow",rtl.boolean,1]]), methodkind: 0});
  this.$rtti.$MethodVar("TAccordionSectionRenderEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["ASection",this.$rtti["TAccordionSection"]],["ACaption",pas["WEBLib.Controls"].$rtti["TJSHTMLElementRecord"]],["APanel",pas["WEBLib.Controls"].$rtti["TJSHTMLElementRecord"]]]), methodkind: 0});
  rtl.createClass(this,"TAccordion",pas["WEBLib.Controls"].TCustomControl,function () {
    this.$init = function () {
      pas["WEBLib.Controls"].TCustomControl.$init.call(this);
      this.FStyleRendered = false;
      this.FSections = null;
      this.FOnCollapsing = null;
      this.FOnExpanding = null;
      this.FOnCollapsed = null;
      this.FOnExpanded = null;
      this.FOnRenderSection = null;
      this.FElementSectionClassName = "";
      this.FElementContentClassName = "";
    };
    this.$final = function () {
      this.FSections = undefined;
      this.FOnCollapsing = undefined;
      this.FOnExpanding = undefined;
      this.FOnCollapsed = undefined;
      this.FOnExpanded = undefined;
      this.FOnRenderSection = undefined;
      pas["WEBLib.Controls"].TCustomControl.$final.call(this);
    };
    this.SetSections = function (Value) {
      this.FSections.Assign(Value);
    };
    this.CreateElement = function () {
      var Result = null;
      Result = document.createElement("DIV");
      return Result;
    };
    this.UpdateElement = function () {
      pas["WEBLib.Controls"].TControl.UpdateElement.call(this);
    };
    this.RenderAccordion = function () {
      var i = 0;
      var sp = null;
      var btn = null;
      var divel = null;
      var p = null;
      var LCaptionElementRec = pas["WEBLib.Controls"].TJSHTMLElementRecord.$new();
      var LPanelElementRec = pas["WEBLib.Controls"].TJSHTMLElementRecord.$new();
      if (this.GetElementHandle().childNodes.length > 0) {
        while (this.GetElementHandle().firstChild != null) this.GetElementHandle().removeChild(this.GetElementHandle().firstChild);
        if (this.FElementClassName !== "") {
          this.GetElementHandle().style.removeProperty("border");
          this.GetElementHandle().style.removeProperty("background-color");
        };
      };
      sp = document.createElement("SPAN");
      this.GetElementHandle().appendChild(sp);
      for (var $l = 0, $end = this.FSections.GetCount() - 1; $l <= $end; $l++) {
        i = $l;
        btn = document.createElement("BUTTON");
        btn.innerHTML = this.FSections.GetItem$1(i).FCaption;
        btn.setAttribute("id",this.FName + "_" + pas.SysUtils.IntToStr(i));
        btn.setAttribute("class","accordion_" + this.FName);
        if (this.FElementSectionClassName !== "") btn.classList.add(this.FElementSectionClassName);
        btn.addEventListener("click",rtl.createSafeCallback(this,"DoAccordionClick"));
        divel = document.createElement("DIV");
        divel.setAttribute("class","accordionpanel_" + this.FName);
        p = document.createElement("P");
        p.style.setProperty("user-select","text");
        if (this.FElementContentClassName !== "") p.setAttribute("class",this.FElementContentClassName);
        p.innerHTML = this.FSections.GetItem$1(i).FContent;
        sp.appendChild(btn);
        sp.appendChild(divel);
        divel.appendChild(p);
        if (this.FOnRenderSection != null) {
          LCaptionElementRec.element = btn;
          LPanelElementRec.element = p;
          this.FOnRenderSection(this,this.FSections.GetItem$1(i),pas["WEBLib.Controls"].TJSHTMLElementRecord.$clone(LCaptionElementRec),pas["WEBLib.Controls"].TJSHTMLElementRecord.$clone(LPanelElementRec));
        };
      };
      if (!this.GetIsLinked() && (pas.Classes.TComponentStateItem.csDesigning in this.FComponentState)) this.RenderDesigning(this.$classname,this.GetContainer(),this,this.FSections.GetCount() === 0,"");
    };
    this.RenderStyle = function () {
      var css = "";
      if (this.FStyleRendered) return;
      this.FStyleRendered = true;
      css = ".accordion_" + this.FName + " {" + "background-color: #eee;" + "color: #444;" + "cursor: pointer;" + "padding: 18px;" + "width: 100%;" + "text-align: left;" + "border: none;" + "outline: none;" + "transition: 0.4s;" + "}" + "\r\n" + ".accordionactive_" + this.FName + ", .accordion_" + this.FName + "::hover {" + "background-color: #ccc;" + "}" + "\r\n" + ".accordionactive_" + this.FName + "::before {" + "transform: rotate(90deg);" + "}" + "\r\n" + ".accordion_" + this.FName + "::before {" + '  content: "\\25B6";' + "  font-size: 13px;" + "  display: inline-block;" + "  margin-right: 5px;" + "}" + "\r\n" + ".accordionpanel_" + this.FName + " {" + "padding: 0 18px;" + "max-height: 0;" + "overflow: hidden;" + "transition: max-height 0.2s ease-out;" + "}";
      this.AddInstanceStyle(css);
    };
    this.SectionsChanged = function (Sender) {
      if (!this.IsUpdating()) {
        this.RenderStyle();
        this.RenderAccordion();
      };
    };
    this.DoAccordionClick = function (Event) {
      var Result = false;
      var el = null;
      var pnl = null;
      var s = "";
      var Allow = false;
      var ASection = null;
      var i = 0;
      var e = 0;
      el = Event.srcElement;
      Allow = true;
      ASection = null;
      if (el.hasAttribute("id")) {
        s = el.getAttribute("id");
        s = pas.System.Copy(s,pas.System.Pos(this.FName,s) + this.FName.length + 1,s.length);
        pas.System.val$6(s,{get: function () {
            return i;
          }, set: function (v) {
            i = v;
          }},{get: function () {
            return e;
          }, set: function (v) {
            e = v;
          }});
        if ((e === 0) && (i < this.FSections.GetCount())) ASection = this.FSections.GetItem$1(i);
      };
      if (el.classList.contains("accordionactive_" + this.FName)) {
        if (this.FOnCollapsing != null) this.FOnCollapsing(this,ASection,{get: function () {
            return Allow;
          }, set: function (v) {
            Allow = v;
          }});
      } else {
        if (this.FOnExpanding != null) this.FOnExpanding(this,ASection,{get: function () {
            return Allow;
          }, set: function (v) {
            Allow = v;
          }});
      };
      if (!Allow) return Result;
      el.classList.toggle("accordionactive_" + this.FName);
      pnl = el.nextElementSibling;
      if (ASection.FControl != null) {
        ASection.FControl.SetElementPosition(pas["WEBLib.Controls"].TElementPosition.epRelative);
        pnl.appendChild(ASection.FControl.GetElementHandle());
        ASection.FControl.SetVisible(true);
      };
      s = pnl.style.getPropertyValue("max-height");
      if ((s !== "0px") && (s !== "")) {
        pnl.style.setProperty("max-height","0");
      } else {
        pnl.style.setProperty("max-height",pas.SysUtils.IntToStr(pnl.scrollHeight) + "px");
      };
      if (el.classList.contains("accordionactive_" + this.FName)) {
        ASection.FExpanded = true;
        if (this.FOnExpanded != null) this.FOnExpanded(this,ASection);
      } else {
        ASection.FExpanded = false;
        if (this.FOnCollapsed != null) this.FOnCollapsed(this,ASection);
      };
      Result = true;
      return Result;
    };
    this.UpdateElementVisual = function () {
      pas["WEBLib.Controls"].TCustomControl.UpdateElementVisual.call(this);
      this.GetElementHandle().style.setProperty("overflow-y","auto");
      this.GetElementHandle().style.setProperty("overflow-x","hidden");
    };
    this.Expand = function (ASection) {
      var el = null;
      var pnl = null;
      var LClass = "";
      el = ASection.CaptionElement();
      pnl = el.nextElementSibling;
      if (ASection.FControl != null) {
        ASection.FControl.SetElementPosition(pas["WEBLib.Controls"].TElementPosition.epRelative);
        pnl.appendChild(ASection.FControl.GetElementHandle());
        ASection.FControl.SetVisible(true);
      };
      LClass = "accordionactive_" + this.FName;
      if (!el.classList.contains(LClass)) el.classList.add(LClass);
      pnl.style.setProperty("max-height",pas.SysUtils.IntToStr(pnl.scrollHeight) + "px");
    };
    this.Collapse = function (ASection) {
      var el = null;
      var pnl = null;
      var LClass = "";
      el = ASection.CaptionElement();
      LClass = "accordionactive_" + this.FName;
      if (el.classList.contains(LClass)) el.classList.remove(LClass);
      pnl = el.nextElementSibling;
      pnl.style.setProperty("max-height","0");
    };
    this.SetElementClassName = function (AValue) {
      pas["WEBLib.Controls"].TControl.SetElementClassName.apply(this,arguments);
      if (this.FElementClassName !== "") this.RenderAccordion();
    };
    this.Loaded = function () {
      var i = 0;
      pas["WEBLib.Controls"].TCustomControl.Loaded.call(this);
      for (var $l = 0, $end = this.FSections.GetCount() - 1; $l <= $end; $l++) {
        i = $l;
        if (this.FSections.GetItem$1(i).FControl != null) this.FSections.GetItem$1(i).FControl.SetVisible(false);
      };
    };
    this.CreateInitialize = function () {
      pas["WEBLib.Controls"].TCustomControl.CreateInitialize.call(this);
      this.FSections = $mod.TAccordionSections.$create("Create$3",[this]);
      this.FSections.FOnChange = rtl.createCallback(this,"SectionsChanged");
      this.FSections.FPropName = "Sections";
      this.FStyleRendered = false;
      if (pas.Classes.TComponentStateItem.csDesigning in this.FComponentState) {
        this.SetWidth(400);
        this.SetHeight(300);
      };
    };
    this.Destroy = function () {
      rtl.free(this,"FSections");
      pas["WEBLib.Controls"].TCustomControl.Destroy.call(this);
    };
    this.EndUpdate = function () {
      pas["WEBLib.Controls"].TCustomControl.EndUpdate.call(this);
      this.RenderStyle();
      this.RenderAccordion();
    };
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
    var $r = this.$rtti;
    $r.addProperty("Align",2,pas["WEBLib.Controls"].$rtti["TAlign"],"FAlign","SetAlign",{Default: pas["WEBLib.Controls"].TAlign.alNone});
    $r.addProperty("AlignWithMargins",2,rtl.boolean,"FAlignWithMargins","SetAlignWithMargins",{Default: false});
    $r.addProperty("Anchors",2,pas["WEBLib.Controls"].$rtti["TAnchors"],"FAnchors","SetAnchors",{Default: rtl.createSet(pas["WEBLib.Controls"].TAnchorKind.akLeft,pas["WEBLib.Controls"].TAnchorKind.akTop)});
    $r.addProperty("Margins",2,pas["WEBLib.Controls"].$rtti["TMargins"],"FMargins","SetMargins");
    $r.addProperty("HeightPercent",2,rtl.double,"FHeightPercent","SetHeightPercent",{Default: 100});
    $r.addProperty("HeightStyle",2,pas["WEBLib.Controls"].$rtti["TSizeStyle"],"FHeightStyle","SetHeightStyle",{Default: pas["WEBLib.Controls"].TSizeStyle.ssAbsolute});
    $r.addProperty("ElementSectionClassName",0,pas["WEBLib.Controls"].$rtti["TElementClassName"],"FElementSectionClassName","FElementSectionClassName");
    $r.addProperty("ElementContentClassName",0,pas["WEBLib.Controls"].$rtti["TElementClassName"],"FElementContentClassName","FElementContentClassName");
    $r.addProperty("ElementClassName",2,pas["WEBLib.Controls"].$rtti["TElementClassName"],"FElementClassName","SetElementClassName");
    $r.addProperty("ElementID",3,pas["WEBLib.Controls"].$rtti["TElementID"],"GetID","SetID");
    $r.addProperty("ElementFont",2,pas["WEBLib.Controls"].$rtti["TElementFont"],"FElementFont","SetElementFont",{Default: pas["WEBLib.Controls"].TElementFont.efProperty});
    $r.addProperty("ElementPosition",2,pas["WEBLib.Controls"].$rtti["TElementPosition"],"FElementPosition","SetElementPosition",{Default: pas["WEBLib.Controls"].TElementPosition.epAbsolute});
    $r.addProperty("Role",3,rtl.string,"GetRole","SetRole");
    $r.addProperty("Sections",2,$mod.$rtti["TAccordionSections"],"FSections","SetSections");
    $r.addProperty("WidthPercent",2,rtl.double,"FWidthPercent","SetWidthPercent",{Default: 100});
    $r.addProperty("WidthStyle",2,pas["WEBLib.Controls"].$rtti["TSizeStyle"],"FWidthStyle","SetWidthStyle",{Default: pas["WEBLib.Controls"].TSizeStyle.ssAbsolute});
    $r.addProperty("OnCollapsed",0,$mod.$rtti["TAccordionSectionEvent"],"FOnCollapsed","FOnCollapsed");
    $r.addProperty("OnCollapsing",0,$mod.$rtti["TAccordionSectionAllowEvent"],"FOnCollapsing","FOnCollapsing");
    $r.addProperty("OnExpanded",0,$mod.$rtti["TAccordionSectionEvent"],"FOnExpanded","FOnExpanded");
    $r.addProperty("OnExpanding",0,$mod.$rtti["TAccordionSectionAllowEvent"],"FOnExpanding","FOnExpanding");
    $r.addProperty("OnRenderSection",0,$mod.$rtti["TAccordionSectionRenderEvent"],"FOnRenderSection","FOnRenderSection");
    $r.addProperty("OnTouchStart",0,pas["WEBLib.Controls"].$rtti["TTouchEvent"],"FOnTouchStart","FOnTouchStart");
    $r.addProperty("OnTouchMove",0,pas["WEBLib.Controls"].$rtti["TTouchEvent"],"FOnTouchMove","FOnTouchMove");
    $r.addProperty("OnTouchEnd",0,pas["WEBLib.Controls"].$rtti["TTouchEvent"],"FOnTouchEnd","FOnTouchEnd");
    $r.addProperty("OnTouchCancel",0,pas["WEBLib.Controls"].$rtti["TTouchEvent"],"FOnTouchCancel","FOnTouchCancel");
  });
  rtl.createClass(this,"TWebAccordion",this.TAccordion,function () {
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
  });
  this.TGridStyle = {"0": "gTemplateColumns", gTemplateColumns: 0, "1": "gTemplateRows", gTemplateRows: 1};
  this.$rtti.$Enum("TGridStyle",{minvalue: 0, maxvalue: 1, ordtype: 1, enumtype: this.TGridStyle});
  rtl.createClass(this,"TResponsiveLayoutItem",pas.Classes.TCollectionItem,function () {
    this.$init = function () {
      pas.Classes.TCollectionItem.$init.call(this);
      this.FWidth = 0;
      this.FStyleType = 0;
      this.FStyle = "";
      this.FColumnGap = "";
      this.FRowGap = "";
      this.FTag = 0;
      this.FDescription = "";
      this.FMargins = null;
    };
    this.$final = function () {
      this.FMargins = undefined;
      pas.Classes.TCollectionItem.$final.call(this);
    };
    this.SetMargins = function (Value) {
      this.FMargins.Assign(Value);
      this.FCollection.Update(this);
    };
    this.SetColumnGap = function (Value) {
      if (this.FColumnGap !== Value) {
        this.FColumnGap = Value;
        this.FCollection.Update(this);
      };
    };
    this.SetRowGap = function (Value) {
      if (this.FRowGap !== Value) {
        this.FRowGap = Value;
        this.FCollection.Update(this);
      };
    };
    this.SetStyle = function (Value) {
      if (this.FStyle !== Value) {
        this.FStyle = Value;
        this.FCollection.Update(this);
      };
    };
    this.SetStyleType = function (Value) {
      if (this.FStyleType !== Value) {
        this.FStyleType = Value;
        this.FCollection.Update(this);
      };
    };
    this.SetWidth = function (Value) {
      if (this.FWidth !== Value) {
        this.FWidth = Value;
        this.FCollection.Update(this);
      };
    };
    this.Create$1 = function (AOwner) {
      this.FMargins = pas["WEBLib.Controls"].TMargins.$create("Create$1");
      this.FMargins.SetLeft(0);
      this.FMargins.SetTop(0);
      this.FMargins.SetRight(0);
      this.FMargins.SetBottom(0);
      pas.Classes.TCollectionItem.Create$1.apply(this,arguments);
      return this;
    };
    this.Destroy = function () {
      rtl.free(this,"FMargins");
      pas.Classes.TCollectionItem.Destroy.call(this);
    };
    this.Assign = function (Source) {
      if ($mod.TResponsiveLayoutItem.isPrototypeOf(Source)) {
        this.FColumnGap = rtl.as(Source,$mod.TResponsiveLayoutItem).FColumnGap;
        this.FDescription = rtl.as(Source,$mod.TResponsiveLayoutItem).FDescription;
        this.FRowGap = rtl.as(Source,$mod.TResponsiveLayoutItem).FRowGap;
        this.FWidth = rtl.as(Source,$mod.TResponsiveLayoutItem).FWidth;
        this.FStyle = rtl.as(Source,$mod.TResponsiveLayoutItem).FStyle;
        this.FStyleType = rtl.as(Source,$mod.TResponsiveLayoutItem).FStyleType;
        this.FTag = rtl.as(Source,$mod.TResponsiveLayoutItem).FTag;
        this.FMargins.Assign(rtl.as(Source,$mod.TResponsiveLayoutItem).FMargins);
      };
    };
    var $r = this.$rtti;
    $r.addMethod("Create$1",2,[["AOwner",pas.Classes.$rtti["TCollection"]]]);
    $r.addProperty("ColumnGap",2,rtl.string,"FColumnGap","SetColumnGap");
    $r.addProperty("Description",0,rtl.string,"FDescription","FDescription");
    $r.addProperty("Margins",2,pas["WEBLib.Controls"].$rtti["TMargins"],"FMargins","SetMargins");
    $r.addProperty("RowGap",2,rtl.string,"FRowGap","SetRowGap");
    $r.addProperty("StyleType",2,$mod.$rtti["TGridStyle"],"FStyleType","SetStyleType");
    $r.addProperty("Style",2,rtl.string,"FStyle","SetStyle");
    $r.addProperty("Tag",0,rtl.longint,"FTag","FTag");
    $r.addProperty("Width",2,rtl.longint,"FWidth","SetWidth");
  });
  rtl.createClass(this,"TResponsiveLayout",pas.Classes.TOwnedCollection,function () {
    this.$init = function () {
      pas.Classes.TOwnedCollection.$init.call(this);
      this.FOnChange = null;
    };
    this.$final = function () {
      this.FOnChange = undefined;
      pas.Classes.TOwnedCollection.$final.call(this);
    };
    this.GetItem$1 = function (Index) {
      var Result = null;
      Result = this.GetItem(Index);
      return Result;
    };
    this.SetItem$1 = function (Index, Value) {
      this.SetItem(Index,Value);
    };
    this.Update = function (Item) {
      pas.Classes.TCollection.Update.apply(this,arguments);
      if (this.FOnChange != null) this.FOnChange(this);
    };
    this.GetLayoutForWidth = function (w) {
      var Result = null;
      var i = 0;
      var d = 0;
      var j = 0;
      var l = 0;
      var mx = 0;
      Result = null;
      if (this.GetCount() === 0) return Result;
      d = 0xFFFF;
      j = -1;
      mx = 0;
      for (var $l = 0, $end = this.GetCount() - 1; $l <= $end; $l++) {
        i = $l;
        if (this.GetItem$1(i).FWidth > mx) {
          mx = this.GetItem$1(i).FWidth;
          l = i;
        };
        if (w < this.GetItem$1(i).FWidth) {
          if ((this.GetItem$1(i).FWidth - w) < d) {
            d = this.GetItem$1(i).FWidth - w;
            j = i;
          };
        };
      };
      if (j === -1) j = l;
      Result = this.GetItem$1(j);
      return Result;
    };
    this.Create$3 = function (AOwner) {
      pas.Classes.TOwnedCollection.Create$2.call(this,AOwner,$mod.TResponsiveLayoutItem);
      return this;
    };
    this.Add$1 = function (AWidth, AStyle) {
      var Result = null;
      Result = this.Add$2();
      Result.SetWidth(AWidth);
      Result.SetStyle(AStyle);
      return Result;
    };
    this.Add$2 = function () {
      var Result = null;
      Result = pas.Classes.TCollection.Add.call(this);
      return Result;
    };
    this.Insert$1 = function (Index) {
      var Result = null;
      Result = pas.Classes.TCollection.Insert.call(this,Index);
      return Result;
    };
    var $r = this.$rtti;
    $r.addMethod("Create$3",2,[["AOwner",pas.Classes.$rtti["TComponent"]]]);
  });
  this.$rtti.$MethodVar("TResponsiveLayoutChangeEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["ALayout",this.$rtti["TResponsiveLayoutItem"]]]), methodkind: 0});
  rtl.createClass(this,"TResponsiveGridPanel",pas["WEBLib.Controls"].TCustomControl,function () {
    this.$init = function () {
      pas["WEBLib.Controls"].TCustomControl.$init.call(this);
      this.FDesignTime$1 = false;
      this.FLabel = null;
      this.FLayout = null;
      this.FActiveLayoutItem = null;
      this.FOldWidth = 0;
      this.FControlCollection = null;
      this.FOnLayoutChange = null;
      this.FResizePtr = null;
    };
    this.$final = function () {
      this.FLabel = undefined;
      this.FLayout = undefined;
      this.FActiveLayoutItem = undefined;
      this.FControlCollection = undefined;
      this.FOnLayoutChange = undefined;
      pas["WEBLib.Controls"].TCustomControl.$final.call(this);
    };
    this.SetControlCollection = function (Value) {
      this.FControlCollection.Assign(Value);
    };
    this.HandleResize = function (Event) {
      var Result = false;
      var w = 0;
      if (pas.Classes.TComponentStateItem.csDestroying in this.FComponentState) return Result;
      Result = true;
      w = this.GetWidth();
      if (this.FOldWidth !== w) {
        this.FOldWidth = w;
        this.Resize();
      };
      return Result;
    };
    this.SetResponsiveStyle = function () {
      var li = null;
      var w = 0;
      var lGap = "";
      if (!(this.FLayout != null)) return;
      if (pas.Classes.TComponentStateItem.csDestroying in this.FComponentState) return;
      if (!(this.GetElementHandle() != null)) return;
      w = this.GetWidth();
      li = this.FLayout.GetLayoutForWidth(w);
      if (li != null) {
        if (li.FStyleType === $mod.TGridStyle.gTemplateColumns) {
          this.GetElementHandle().style.setProperty("grid-template-columns",li.FStyle);
          this.GetElementHandle().style.removeProperty("grid-template-rows");
        } else {
          this.GetElementHandle().style.removeProperty("grid-template-columns");
          this.GetElementHandle().style.setProperty("grid-template-rows",li.FStyle);
        };
        lGap = li.FRowGap;
        if (pas.SysUtils.TStringHelper.IsNumber.call({get: function () {
            return lGap;
          }, set: function (v) {
            lGap = v;
          }})) lGap = lGap + "px";
        this.GetElementHandle().style.setProperty("grid-row-gap",lGap);
        lGap = li.FColumnGap;
        if (pas.SysUtils.TStringHelper.IsNumber.call({get: function () {
            return lGap;
          }, set: function (v) {
            lGap = v;
          }})) lGap = lGap + "px";
        this.GetElementHandle().style.setProperty("grid-column-gap",lGap);
        this.GetElementHandle().style.setProperty("padding-left",pas.SysUtils.IntToStr(li.FMargins.FLeft) + "px");
        this.GetElementHandle().style.setProperty("padding-top",pas.SysUtils.IntToStr(li.FMargins.FTop) + "px");
        this.GetElementHandle().style.setProperty("padding-right",pas.SysUtils.IntToStr(li.FMargins.FRight) + "px");
        this.GetElementHandle().style.setProperty("padding-bottom",pas.SysUtils.IntToStr(li.FMargins.FBottom) + "px");
      };
      if (li !== this.FActiveLayoutItem) {
        this.FActiveLayoutItem = li;
        if (this.FOnLayoutChange != null) this.FOnLayoutChange(this,this.FActiveLayoutItem);
      };
    };
    this.BindEvents = function () {
      pas["WEBLib.Controls"].TCustomControl.BindEvents.call(this);
      this.FResizePtr = rtl.createCallback(this,"HandleResize");
      document.defaultView.addEventListener("resize",this.FResizePtr);
    };
    this.UnbindEvents = function () {
      pas["WEBLib.Controls"].TControl.UnbindEvents.call(this);
      if (this.FResizePtr != null) {
        document.defaultView.removeEventListener("resize",this.FResizePtr);
        this.FResizePtr = null;
      };
    };
    this.UpdateControls = function () {
      var i = 0;
      var j = 0;
      var k = 0;
      var el = null;
      var sp = null;
      var fragment = null;
      var control = null;
      if (pas.Classes.TComponentStateItem.csLoading in this.FComponentState) return;
      if (this.IsUpdating()) return;
      if (!(this.GetElementHandle() != null)) return;
      if ((this.FControlCollection.GetCount() > 0) && (this.FLabel != null)) {
        this.GetElementHandle().removeChild(this.FLabel);
        this.FLabel = null;
        this.GetElementHandle().style.setProperty("display","grid");
      };
      if (pas.Classes.TComponentStateItem.csDesigning in this.FComponentState) {
        for (var $l = this.GetElementHandle().childElementCount - 1; $l >= 0; $l--) {
          i = $l;
          if (this.GetElementHandle().children.item(i).tagName === "SPAN") this.GetElementHandle().removeChild(this.GetElementHandle().children.item(i));
        };
        for (var $l1 = 0, $end = this.FLayout.GetCount() - 1; $l1 <= $end; $l1++) {
          i = $l1;
          sp = document.createElement("SPAN");
          sp.style.setProperty("position","absolute");
          sp.style.setProperty("width","4px");
          sp.style.setProperty("height","12px");
          sp.style.setProperty("background-color","red");
          sp.style.setProperty("top","0px");
          sp.style.setProperty("left",pas.SysUtils.IntToStr(this.FLayout.GetItem$1(i).FWidth) + "px");
          this.GetElementHandle().appendChild(sp);
        };
      };
      for (var $l2 = 0, $end1 = this.FControlCollection.GetCount() - 1; $l2 <= $end1; $l2++) {
        i = $l2;
        if (this.GridElementCount() <= i) {
          el = document.createElement("DIV");
          el.setAttribute("data","grid");
          if (pas.Classes.TComponentStateItem.csDesigning in this.FComponentState) el.style.setProperty("border","1px silver dotted");
          this.GetElementHandle().appendChild(el);
        } else {
          k = 0;
          for (var $l3 = 0, $end2 = this.GetElementHandle().childElementCount - 1; $l3 <= $end2; $l3++) {
            j = $l3;
            el = this.GetElementHandle().children.item(j);
            if (el.getAttribute("data") === "grid") {
              if (k === i) {
                break}
               else k += 1;
            };
          };
        };
        fragment = document.createDocumentFragment();
        control = this.FControlCollection.GetItem$1(i).FControl;
        if (control != null) {
          control.SetElementPosition(pas["WEBLib.Controls"].TElementPosition.epRelative);
          control.SetChildOrderEx(-1);
          if (control.GetElementHandle() != null) {
            fragment.appendChild(control.GetElementHandle());
            el.appendChild(fragment);
          };
        };
      };
      this.UpdateElement();
    };
    this.CreateElement = function () {
      var Result = null;
      if ((pas.Classes.TComponentStateItem.csDesigning in this.FComponentState) && (this.FControlCollection.GetCount() === 0)) {
        Result = document.createElement("DIV");
        this.FLabel = document.createElement("DIV");
        this.FLabel.innerHTML = this.$classname;
        this.SetBorderStyle(pas["WEBLib.Controls"].TBorderStyle.bsSingle);
        this.FLabel.setAttribute("align","center");
        this.FLabel.style.setProperty("border","1px solid silver");
        this.FLabel.style.setProperty("vertical-align","middle");
        this.FLabel.style.setProperty("display","table-cell");
        Result.appendChild(this.FLabel);
      } else {
        Result = document.createElement("DIV");
      };
      return Result;
    };
    this.GridElementCount = function () {
      var Result = 0;
      var i = 0;
      var el = null;
      Result = 0;
      for (var $l = 0, $end = this.GetElementHandle().childElementCount - 1; $l <= $end; $l++) {
        i = $l;
        el = this.GetElementHandle().children.item(i);
        if (el.getAttribute("data") === "grid") Result += 1;
      };
      return Result;
    };
    this.UpdateElement = function () {
      pas["WEBLib.Controls"].TControl.UpdateElement.call(this);
      if (pas.Classes.TComponentStateItem.csDestroying in this.FComponentState) return;
      if (!(this.GetElementHandle() != null)) return;
      if (pas.Classes.TComponentStateItem.csDesigning in this.FComponentState) {
        if (this.FControlCollection.GetCount() === 0) {
          this.GetElementHandle().style.setProperty("display","table");
          if (this.FColor === -1) this.GetElementHandle().style.setProperty("background-color","silver");
        };
      };
      if (pas.Classes.TComponentStateItem.csDesigning in this.FComponentState) {
        this.GetElementHandle().style.setProperty("border","1px silver dotted");
      };
      this.GetElementHandle().style.setProperty("display","grid");
      this.SetResponsiveStyle();
    };
    this.Loaded = function () {
      pas["WEBLib.Controls"].TCustomControl.Loaded.call(this);
      this.UpdateControls();
    };
    this.RegisterParent = function (AValue) {
      pas["WEBLib.Controls"].TControl.RegisterParent.apply(this,arguments);
      if (!this.IsUpdating() && !(pas.Classes.TComponentStateItem.csLoading in this.FComponentState)) {
        this.FControlCollection.Add$1().FControl = AValue;
        this.UpdateControls();
      };
    };
    this.Notification = function (AComponent, Operation) {
      var i = 0;
      var upd = false;
      var el = null;
      upd = false;
      if ((Operation === pas.Classes.TOperation.opRemove) && !(pas.Classes.TComponentStateItem.csDestroying in this.FComponentState)) {
        for (var $l = this.FControlCollection.GetCount() - 1; $l >= 0; $l--) {
          i = $l;
          if (this.FControlCollection.GetItem$1(i).FControl === AComponent) {
            el = this.GetElementHandle().children.item(i);
            while (el.childElementCount > 0) el.removeChild(el.firstChild);
            this.FControlCollection.GetItem$1(i).FControl = null;
            this.FControlCollection.Delete(i);
            upd = true;
          };
        };
      };
      pas.Classes.TComponent.Notification.apply(this,arguments);
      if (upd) this.UpdateControls();
    };
    this.LayoutChanged = function (Sender) {
      if (this.IsUpdating() || (pas.Classes.TComponentStateItem.csLoading in this.FComponentState)) return;
      this.UpdateControls();
    };
    this.Create$1 = function (AOwner) {
      pas["WEBLib.Controls"].TControl.Create$1.apply(this,arguments);
      this.FResizePtr = null;
      return this;
    };
    this.Destroy = function () {
      rtl.free(this,"FControlCollection");
      rtl.free(this,"FLayout");
      pas["WEBLib.Controls"].TCustomControl.Destroy.call(this);
    };
    this.CreateInitialize = function () {
      var li = null;
      pas["WEBLib.Controls"].TCustomControl.CreateInitialize.call(this);
      this.FDesignTime$1 = (pas.Classes.TComponentStateItem.csDesigning in this.FComponentState) && !((pas.Classes.TComponentStateItem.csReading in this.FOwner.FComponentState) || (pas.Classes.TComponentStateItem.csLoading in this.FOwner.FComponentState));
      this.FEnablePropagation = true;
      this.FControlStyle = rtl.unionSet(this.FControlStyle,rtl.createSet(pas["WEBLib.Controls"].TControlStyleValue.csAcceptsControls));
      this.FControlCollection = $mod.TControlCollection.$create("Create$3",[this]);
      this.FControlCollection.FPropName = "ControlCollection";
      if (pas.Classes.TComponentStateItem.csDesigning in this.FComponentState) {
        this.SetWidth(400);
        this.SetHeight(300);
      };
      this.FLabel = null;
      this.FActiveLayoutItem = null;
      this.FLayout = $mod.TResponsiveLayout.$create("Create$3",[this]);
      this.FLayout.FOnChange = rtl.createCallback(this,"LayoutChanged");
      this.FLayout.FPropName = "Layout";
      if (this.FDesignTime$1) {
        li = this.FLayout.Add$2();
        li.FDescription = "Smartphone";
        li.SetWidth(575);
        li.SetStyle("1fr");
        li = this.FLayout.Add$2();
        li.FDescription = "Tablet";
        li.SetWidth(768);
        li.SetStyle("1fr 1fr");
        li = this.FLayout.Add$2();
        li.FDescription = "Desktop";
        li.SetWidth(991);
        li.SetStyle("1fr 1fr 1fr");
        li = this.FLayout.Add$2();
        li.FDescription = "Large Desktop";
        li.SetWidth(1199);
        li.SetStyle("1fr 1fr 1fr 1fr");
      };
    };
    this.AlignControls = function (AControl, Rect) {
      pas["WEBLib.Controls"].TControl.AlignControls.apply(this,arguments);
      this.Resize();
    };
    this.GetChildren = function (Proc, Root) {
      pas["WEBLib.Controls"].TControl.GetChildren.apply(this,arguments);
    };
    this.Resize = function () {
      pas["WEBLib.Controls"].TCustomControl.Resize.call(this);
      this.SetResponsiveStyle();
    };
    this.AddControl = function (AControl) {
      this.FControlCollection.Add$1().FControl = AControl;
      AControl.SetParent(this);
    };
    this.RemoveControl = function (AControl) {
      var i = 0;
      for (var $l = 0, $end = this.FControlCollection.GetCount() - 1; $l <= $end; $l++) {
        i = $l;
        if (this.FControlCollection.GetItem$1(i).FControl === AControl) {
          this.FControlCollection.Delete(i);
          break;
        };
      };
    };
    this.RemoveControls = function () {
      var i = 0;
      for (var $l = this.FControlCollection.GetCount() - 1; $l >= 0; $l--) {
        i = $l;
        this.FControlCollection.Delete(i);
      };
    };
    this.EndUpdate = function () {
      pas["WEBLib.Controls"].TCustomControl.EndUpdate.call(this);
      this.UpdateControls();
    };
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
    var $r = this.$rtti;
    $r.addMethod("Create$1",2,[["AOwner",pas.Classes.$rtti["TComponent"]]]);
    $r.addProperty("Align",2,pas["WEBLib.Controls"].$rtti["TAlign"],"FAlign","SetAlign",{Default: pas["WEBLib.Controls"].TAlign.alNone});
    $r.addProperty("AlignWithMargins",2,rtl.boolean,"FAlignWithMargins","SetAlignWithMargins",{Default: false});
    $r.addProperty("Anchors",2,pas["WEBLib.Controls"].$rtti["TAnchors"],"FAnchors","SetAnchors",{Default: rtl.createSet(pas["WEBLib.Controls"].TAnchorKind.akLeft,pas["WEBLib.Controls"].TAnchorKind.akTop)});
    $r.addProperty("ChildOrder",2,rtl.longint,"FChildOrder","SetChildOrderEx",{Default: 0});
    $r.addProperty("Color",2,pas["WEBLib.Graphics"].$rtti["TColor"],"FColor","SetColor");
    $r.addProperty("ControlCollection",2,$mod.$rtti["TControlCollection"],"FControlCollection","SetControlCollection");
    $r.addProperty("ElementClassName",2,pas["WEBLib.Controls"].$rtti["TElementClassName"],"FElementClassName","SetElementClassName");
    $r.addProperty("ElementFont",2,pas["WEBLib.Controls"].$rtti["TElementFont"],"FElementFont","SetElementFont",{Default: pas["WEBLib.Controls"].TElementFont.efProperty});
    $r.addProperty("ElementID",3,pas["WEBLib.Controls"].$rtti["TElementID"],"GetID","SetID");
    $r.addProperty("ElementPosition",2,pas["WEBLib.Controls"].$rtti["TElementPosition"],"FElementPosition","SetElementPosition",{Default: pas["WEBLib.Controls"].TElementPosition.epAbsolute});
    $r.addProperty("HeightPercent",2,rtl.double,"FHeightPercent","SetHeightPercent",{Default: 100});
    $r.addProperty("HeightStyle",2,pas["WEBLib.Controls"].$rtti["TSizeStyle"],"FHeightStyle","SetHeightStyle",{Default: pas["WEBLib.Controls"].TSizeStyle.ssAbsolute});
    $r.addProperty("Hint",2,rtl.string,"FHint","SetHint");
    $r.addProperty("Layout",0,$mod.$rtti["TResponsiveLayout"],"FLayout","FLayout");
    $r.addProperty("Margins",2,pas["WEBLib.Controls"].$rtti["TMargins"],"FMargins","SetMargins");
    $r.addProperty("Role",3,rtl.string,"GetRole","SetRole");
    $r.addProperty("ShowHint",2,rtl.boolean,"FShowHint","SetShowHint",{Default: false});
    $r.addProperty("Visible",2,rtl.boolean,"FVisible","SetVisible",{Default: true});
    $r.addProperty("WidthPercent",2,rtl.double,"FWidthPercent","SetWidthPercent",{Default: 100});
    $r.addProperty("WidthStyle",2,pas["WEBLib.Controls"].$rtti["TSizeStyle"],"FWidthStyle","SetWidthStyle",{Default: pas["WEBLib.Controls"].TSizeStyle.ssAbsolute});
    $r.addProperty("OnLayoutChange",0,$mod.$rtti["TResponsiveLayoutChangeEvent"],"FOnLayoutChange","FOnLayoutChange");
  });
  rtl.createClass(this,"TWebResponsiveGridPanel",this.TResponsiveGridPanel,function () {
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
  });
  rtl.createClass(this,"TLookupValueItem",pas.Classes.TCollectionItem,function () {
    this.$init = function () {
      pas.Classes.TCollectionItem.$init.call(this);
      this.FValue = "";
      this.FDisplayText = "";
    };
    var $r = this.$rtti;
    $r.addProperty("Value",0,rtl.string,"FValue","FValue");
    $r.addProperty("DisplayText",0,rtl.string,"FDisplayText","FDisplayText");
  });
  rtl.createClass(this,"TLookupValues",pas.Classes.TOwnedCollection,function () {
    this.$init = function () {
      pas.Classes.TOwnedCollection.$init.call(this);
      this.FOnChange = null;
    };
    this.$final = function () {
      this.FOnChange = undefined;
      pas.Classes.TOwnedCollection.$final.call(this);
    };
    this.GetItem$1 = function (Index) {
      var Result = null;
      Result = this.GetItem(Index);
      return Result;
    };
    this.SetItem$1 = function (Index, Value) {
      this.SetItem(Index,Value);
    };
    this.DoChange = function () {
      if (this.FOnChange != null) this.FOnChange(this);
    };
    this.Update = function (Item) {
      pas.Classes.TCollection.Update.apply(this,arguments);
      if (Item === null) this.DoChange();
    };
    this.Create$3 = function (AOwner) {
      pas.Classes.TOwnedCollection.Create$2.call(this,AOwner,$mod.TLookupValueItem);
      return this;
    };
    this.AddPair = function (AValue, ADisplayText) {
      var lv = null;
      lv = pas.Classes.TCollection.Add.call(this);
      lv.FValue = AValue;
      lv.FDisplayText = ADisplayText;
      if (this.FUpdateCount === 0) this.DoChange();
    };
    this.InsertPair = function (Index, AValue, ADisplayText) {
      var lv = null;
      lv = pas.Classes.TCollection.Insert.call(this,Index);
      lv.FValue = AValue;
      lv.FDisplayText = ADisplayText;
      if (this.FUpdateCount === 0) this.DoChange();
    };
    this.Add$1 = function () {
      var Result = null;
      Result = pas.Classes.TCollection.Add.call(this);
      return Result;
    };
    this.Insert$1 = function (Index) {
      var Result = null;
      Result = pas.Classes.TCollection.Insert.call(this,Index);
      return Result;
    };
    var $r = this.$rtti;
    $r.addMethod("Create$3",2,[["AOwner",pas.Classes.$rtti["TComponent"]]]);
  });
  rtl.createClass(this,"TCustomLookupComboBox",pas["WEBLib.StdCtrls"].TCustomComboBox,function () {
    this.$init = function () {
      pas["WEBLib.StdCtrls"].TCustomComboBox.$init.call(this);
      this.FLookupValues = null;
    };
    this.$final = function () {
      this.FLookupValues = undefined;
      pas["WEBLib.StdCtrls"].TCustomComboBox.$final.call(this);
    };
    this.SetLookupValues = function (Value) {
      this.FLookupValues.Assign(Value);
    };
    this.GetDisplayText = function () {
      var Result = "";
      Result = "";
      if (this.GetItemIndex() >= 0) Result = this.FLookupValues.GetItem$1(this.GetItemIndex()).FDisplayText;
      return Result;
    };
    this.GetValue = function () {
      var Result = "";
      Result = "";
      if (this.GetItemIndex() >= 0) Result = this.FLookupValues.GetItem$1(this.GetItemIndex()).FValue;
      return Result;
    };
    this.SetDisplayText = function (Value) {
      var i = 0;
      var idx = 0;
      idx = -1;
      for (var $l = 0, $end = this.FLookupValues.GetCount() - 1; $l <= $end; $l++) {
        i = $l;
        if (this.FLookupValues.GetItem$1(i).FDisplayText === Value) {
          idx = i;
          break;
        };
      };
      this.SetItemIndex(idx);
    };
    this.SetValue = function (Value) {
      var i = 0;
      var idx = 0;
      idx = -1;
      for (var $l = 0, $end = this.FLookupValues.GetCount() - 1; $l <= $end; $l++) {
        i = $l;
        if (this.FLookupValues.GetItem$1(i).FValue === Value) {
          idx = i;
          break;
        };
      };
      this.SetItemIndex(idx);
    };
    this.ValuesChanged = function (Sender) {
      this.DoUpdateList();
    };
    this.DoUpdateList = function () {
      var i = 0;
      var opt = null;
      if (!(this.GetContainer() != null)) return;
      for (var $l = this.GetContainer().options.length - 1; $l >= 0; $l--) {
        i = $l;
        this.GetContainer().remove(i);
      };
      this.AddTextHint();
      for (var $l1 = 0, $end = this.FLookupValues.GetCount() - 1; $l1 <= $end; $l1++) {
        i = $l1;
        opt = document.createElement("OPTION");
        opt.setAttribute("value",this.FLookupValues.GetItem$1(i).FValue);
        opt.innerHTML = this.FLookupValues.GetItem$1(i).FDisplayText;
        this.GetContainer().appendChild(opt);
      };
      this.UpdateElement();
    };
    this.InitCSSLibrary = function (ALibrary) {
      if (ALibrary === pas["WEBLib.Controls"].TCSSLibrary.cssBootstrap) {
        this.SetElementFont(pas["WEBLib.Controls"].TElementFont.efCSS);
        this.SetElementClassName("custom-select");
      };
    };
    this.Destroy = function () {
      rtl.free(this,"FLookupValues");
      pas["WEBLib.StdCtrls"].TCustomComboBox.Destroy.call(this);
    };
    this.CreateInitialize = function () {
      pas["WEBLib.StdCtrls"].TCustomComboBox.CreateInitialize.call(this);
      this.FLookupValues = $mod.TLookupValues.$create("Create$3",[this]);
      this.FLookupValues.FPropName = "LookupValues";
      this.FLookupValues.FOnChange = rtl.createCallback(this,"ValuesChanged");
    };
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
    var $r = this.$rtti;
    $r.addProperty("Align",2,pas["WEBLib.Controls"].$rtti["TAlign"],"FAlign","SetAlign",{Default: pas["WEBLib.Controls"].TAlign.alNone});
    $r.addProperty("AlignWithMargins",2,rtl.boolean,"FAlignWithMargins","SetAlignWithMargins",{Default: false});
    $r.addProperty("Anchors",2,pas["WEBLib.Controls"].$rtti["TAnchors"],"FAnchors","SetAnchors",{Default: rtl.createSet(pas["WEBLib.Controls"].TAnchorKind.akLeft,pas["WEBLib.Controls"].TAnchorKind.akTop)});
    $r.addProperty("Color",2,pas["WEBLib.Graphics"].$rtti["TColor"],"FColor","SetColor");
    $r.addProperty("ElementClassName",2,pas["WEBLib.Controls"].$rtti["TElementClassName"],"FElementClassName","SetElementClassName");
    $r.addProperty("ElementID",3,pas["WEBLib.Controls"].$rtti["TElementID"],"GetID","SetID");
    $r.addProperty("ElementFont",2,pas["WEBLib.Controls"].$rtti["TElementFont"],"FElementFont","SetElementFont",{Default: pas["WEBLib.Controls"].TElementFont.efProperty});
    $r.addProperty("ElementPosition",2,pas["WEBLib.Controls"].$rtti["TElementPosition"],"FElementPosition","SetElementPosition",{Default: pas["WEBLib.Controls"].TElementPosition.epAbsolute});
    $r.addProperty("Enabled",2,rtl.boolean,"FEnabled","SetEnabled",{Default: true});
    $r.addProperty("Font",2,pas["WEBLib.Graphics"].$rtti["TFont"],"FFont","SetFont");
    $r.addProperty("Height",3,rtl.longint,"GetHeight","SetHeight");
    $r.addProperty("HeightPercent",2,rtl.double,"FHeightPercent","SetHeightPercent",{Default: 100});
    $r.addProperty("HeightStyle",2,pas["WEBLib.Controls"].$rtti["TSizeStyle"],"FHeightStyle","SetHeightStyle",{Default: pas["WEBLib.Controls"].TSizeStyle.ssAbsolute});
    $r.addProperty("Hint",2,rtl.string,"FHint","SetHint");
    $r.addProperty("ItemIndex",3,rtl.longint,"GetItemIndex","SetItemIndex",{Default: -1});
    $r.addProperty("Left",3,rtl.longint,"GetLeft","SetLeft");
    $r.addProperty("Margins",2,pas["WEBLib.Controls"].$rtti["TMargins"],"FMargins","SetMargins");
    $r.addProperty("ParentFont",2,rtl.boolean,"FParentFont","SetParentFont",{Default: true});
    $r.addProperty("Role",3,rtl.string,"GetRole","SetRole");
    $r.addProperty("ShowFocus",2,rtl.boolean,"FShowFocus","SetShowFocus",{Default: false});
    $r.addProperty("ShowHint",2,rtl.boolean,"FShowHint","SetShowHint",{Default: false});
    $r.addProperty("TabOrder",2,rtl.longint,"FTabOrder","SetTabOrder");
    $r.addProperty("TabStop",2,rtl.boolean,"FTabStop","SetTabStop",{Default: true});
    $r.addProperty("TextDirection",0,pas["WEBLib.Controls"].$rtti["TTextDirection"],"FTextDirection","FTextDirection",{Default: pas["WEBLib.Controls"].TTextDirection.tdDefault});
    $r.addProperty("TextHint",2,rtl.string,"FTextHint","SetTextHint");
    $r.addProperty("Top",3,rtl.longint,"GetTop","SetTop");
    $r.addProperty("Visible",2,rtl.boolean,"FVisible","SetVisible",{Default: true});
    $r.addProperty("Width",3,rtl.longint,"GetWidth","SetWidth");
    $r.addProperty("WidthPercent",2,rtl.double,"FWidthPercent","SetWidthPercent",{Default: 100});
    $r.addProperty("WidthStyle",2,pas["WEBLib.Controls"].$rtti["TSizeStyle"],"FWidthStyle","SetWidthStyle",{Default: pas["WEBLib.Controls"].TSizeStyle.ssAbsolute});
    $r.addProperty("OnChange",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnChange","FOnChange");
    $r.addProperty("OnClick",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnClick","FOnClick");
    $r.addProperty("OnDblClick",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnDblClick","FOnDblClick");
    $r.addProperty("OnKeyDown",0,pas["WEBLib.Controls"].$rtti["TKeyEvent"],"FOnKeyDown","FOnKeyDown");
    $r.addProperty("OnKeyPress",0,pas["WEBLib.Controls"].$rtti["TKeyPressEvent"],"FOnKeyPress","FOnKeyPress");
    $r.addProperty("OnKeyUp",0,pas["WEBLib.Controls"].$rtti["TKeyEvent"],"FOnKeyUp","FOnKeyUp");
    $r.addProperty("OnMouseDown",0,pas["WEBLib.Controls"].$rtti["TMouseEvent"],"FOnMouseDown","FOnMouseDown");
    $r.addProperty("OnMouseUp",0,pas["WEBLib.Controls"].$rtti["TMouseEvent"],"FOnMouseUp","FOnMouseUp");
    $r.addProperty("OnMouseMove",0,pas["WEBLib.Controls"].$rtti["TMouseMoveEvent"],"FOnMouseMove","FOnMouseMove");
    $r.addProperty("OnMouseLeave",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnMouseLeave","FOnMouseLeave");
    $r.addProperty("OnMouseEnter",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnMouseEnter","FOnMouseEnter");
    $r.addProperty("OnEnter",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnEnter","FOnEnter");
    $r.addProperty("OnExit",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnExit","FOnExit");
  });
  rtl.createClass(this,"TLookupComboBox",this.TCustomLookupComboBox,function () {
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
    var $r = this.$rtti;
    $r.addProperty("LookupValues",2,$mod.$rtti["TLookupValues"],"FLookupValues","SetLookupValues");
  });
  rtl.createClass(this,"TWebLookupComboBox",this.TLookupComboBox,function () {
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
  });
  rtl.createClass(this,"TCustomListBox",pas["WEBLib.Menus"].TWebCustomControl,function () {
    this.$init = function () {
      pas["WEBLib.Menus"].TWebCustomControl.$init.call(this);
      this.FItems = null;
      this.FItemIndex = 0;
      this.FItemHeight = 0;
      this.FSorted = false;
      this.FOnChange = null;
      this.FHandleChangePtr = null;
      this.FElementItemClassName = "";
    };
    this.$final = function () {
      this.FItems = undefined;
      this.FOnChange = undefined;
      pas["WEBLib.Menus"].TWebCustomControl.$final.call(this);
    };
    this.SetItemHeight = function (Value) {
      this.FItemHeight = Value;
    };
    this.SetSorted = function (Value) {
      this.FSorted = Value;
      this.FItems.Sort();
    };
    this.GetCount = function () {
      var Result = 0;
      Result = this.FItems.GetCount();
      return Result;
    };
    this.GetItemElement = function (i) {
      var Result = null;
      Result = null;
      if ((this.GetContainer() != null) && (i < this.GetContainer().children.length)) Result = this.GetContainer().children.item(i);
      return Result;
    };
    this.DoHandleChange = function (Event) {
      var Result = false;
      this.Change();
      Result = true;
      return Result;
    };
    this.DoItemsChange = function (Sender) {
      this.DoUpdateList();
    };
    this.KeyDown = function (Key, Shift) {
      pas["WEBLib.Controls"].TControl.KeyDown.apply(this,arguments);
      if (Key.get() === 40) {
        this.SetItemIndex(this.GetItemIndex() + 1);
        Key.set(0);
      };
      if (Key.get() === 36) {
        this.SetItemIndex(0);
        Key.set(0);
      };
      if (Key.get() === 34) {
        this.SetItemIndex(this.GetItemIndex() + 4);
        Key.set(0);
      };
      if (Key.get() === 33) {
        this.SetItemIndex(this.GetItemIndex() - 4);
        Key.set(0);
      };
      if (Key.get() === 35) {
        this.SetItemIndex(this.FItems.GetCount() - 1);
        Key.set(0);
      };
      if (Key.get() === 38) {
        this.SetItemIndex(this.GetItemIndex() - 1);
        Key.set(0);
      };
    };
    this.DoUpdateList = function () {
      var i = 0;
      var opt = null;
      var chk = null;
      var txt = null;
      if (!(this.GetContainer() != null)) return;
      if (this.IsUpdating()) return;
      if (this.GetElementHandle().tagName !== "DIV") return;
      while (this.GetContainer().firstChild != null) this.GetContainer().removeChild(this.GetContainer().lastChild);
      for (var $l = 0, $end = this.FItems.GetCount() - 1; $l <= $end; $l++) {
        i = $l;
        opt = document.createElement("LABEL");
        chk = document.createElement("INPUT");
        chk.setAttribute("type","checkbox");
        chk.style.setProperty("vertical-align","middle");
        opt.style.setProperty("vertical-align","middle");
        opt.appendChild(chk);
        opt.style.setProperty("display","block");
        txt = document.createTextNode(this.FItems.Get(i));
        opt.appendChild(txt);
        if (this.FElementItemClassName !== "") opt.setAttribute("class",this.FElementItemClassName);
        if (this.FDragMode === pas["WEBLib.Controls"].TDragMode.dmAutomatic) opt.setAttribute("draggable","true");
        this.GetContainer().appendChild(opt);
      };
      this.UpdateElementData();
    };
    this.PersistinHTML = function () {
      if (!(this.GetContainer() != null)) return;
      if (this.GetElementHandle().tagName !== "DIV") return;
    };
    this.SetItemIndex = function (Value) {
      var el = null;
      el = this.GetItemElement(Value);
      if (el != null) el.firstChild.focus();
    };
    this.GetItemIndex = function () {
      var Result = 0;
      var i = 0;
      var el = null;
      Result = this.FItemIndex;
      if (this.GetContainer() != null) {
        for (var $l = 0, $end = this.FItems.GetCount() - 1; $l <= $end; $l++) {
          i = $l;
          el = this.GetItemElement(i);
          if (el != null) el = el.firstChild;
          if (el != null) {
            if (el === document.activeElement) {
              Result = i;
              break;
            };
          };
        };
      };
      return Result;
    };
    this.CreateElement = function () {
      var Result = null;
      Result = document.createElement("DIV");
      return Result;
    };
    this.SetItems = function (AItems) {
      this.FItems.Assign(AItems);
    };
    this.Loaded = function () {
      pas["WEBLib.Controls"].TCustomControl.Loaded.call(this);
      this.DoUpdateList();
      this.UpdateElement();
    };
    this.UpdateElementData = function () {
      pas["WEBLib.Controls"].TControl.UpdateElementData.call(this);
      if (this.GetElementHandle() != null) {
        this.GetElementHandle().style.setProperty("overflow","auto");
      };
    };
    this.UpdateElementVisual = function () {
      pas["WEBLib.Controls"].TCustomControl.UpdateElementVisual.call(this);
      if (this.GetElementHandle() != null) {
        this.GetElementHandle().style.setProperty("overflow","auto");
      };
    };
    this.UpdateParent = function () {
      pas["WEBLib.Controls"].TControl.UpdateParent.call(this);
      this.DoUpdateList();
    };
    this.BindEvents = function () {
      pas["WEBLib.Controls"].TCustomControl.BindEvents.call(this);
      if (this.GetElementHandle() != null) {
        this.GetElementHandle().addEventListener("change",this.FHandleChangePtr);
      };
    };
    this.UnbindEvents = function () {
      pas["WEBLib.Controls"].TControl.UnbindEvents.call(this);
      if (this.GetElementHandle() != null) {
        this.GetElementHandle().removeEventListener("change",this.FHandleChangePtr);
      };
    };
    this.Change = function () {
      if (this.FOnChange != null) this.FOnChange(this);
    };
    this.EnableDrag = function () {
      var I = 0;
      if (!(this.GetContainer() != null)) return;
      for (var $l = 0, $end = this.GetContainer().options.length - 1; $l <= $end; $l++) {
        I = $l;
        this.GetContainer().options.item(I).setAttribute("draggable","true");
      };
    };
    this.DisableDrag = function () {
      var I = 0;
      if (!(this.GetContainer() != null)) return;
      for (var $l = 0, $end = this.GetContainer().children.length - 1; $l <= $end; $l++) {
        I = $l;
        this.GetContainer().children.item(I).setAttribute("draggable","false");
      };
    };
    this.ClearMethodPointers = function () {
      pas["WEBLib.Controls"].TControl.ClearMethodPointers.call(this);
      this.FHandleChangePtr = null;
    };
    this.GetMethodPointers = function () {
      pas["WEBLib.Controls"].TControl.GetMethodPointers.call(this);
      this.FHandleChangePtr = rtl.createCallback(this,"DoHandleChange");
    };
    this.CreateInitialize = function () {
      pas["WEBLib.Controls"].TCustomControl.CreateInitialize.call(this);
      this.FItems = pas.Classes.TStringList.$create("Create$1");
      this.FItems.SetSkipLastLineBreak(true);
      this.FItems.FOnChange = rtl.createCallback(this,"DoItemsChange");
      this.FItemIndex = -1;
      this.SetBorderStyle(pas["WEBLib.Controls"].TBorderStyle.bsSingle);
      this.FCustomBorder = true;
      this.SetShowFocus(true);
      if (pas.Classes.TComponentStateItem.csDesigning in this.FComponentState) {
        this.SetWidth(160);
        this.SetHeight(180);
      };
    };
    this.Destroy = function () {
      rtl.free(this,"FItems");
      pas["WEBLib.Controls"].TCustomControl.Destroy.call(this);
    };
    this.EndUpdate = function () {
      pas["WEBLib.Controls"].TCustomControl.EndUpdate.call(this);
      this.DoUpdateList();
    };
    this.AddItem = function (Item, AObject) {
      this.FItems.AddObject(Item,AObject);
    };
    this.SetFilter = function (AExpression, CaseSensitive) {
      var i = 0;
      var re = null;
      if (CaseSensitive) {
        re = new RegExp(AExpression)}
       else re = new RegExp(AExpression,"i");
      for (var $l = 0, $end = this.FItems.GetCount() - 1; $l <= $end; $l++) {
        i = $l;
        if (!re.test(this.FItems.Get(i))) {
          this.GetItemElement(i).style.setProperty("display","none");
        } else this.GetItemElement(i).style.setProperty("display","block");
      };
    };
    this.RemoveFilter = function () {
      var i = 0;
      for (var $l = 0, $end = this.FItems.GetCount() - 1; $l <= $end; $l++) {
        i = $l;
        this.GetItemElement(i).style.setProperty("display","block");
      };
    };
    this.Clear = function () {
      this.BeginUpdate();
      this.FItems.Clear();
      this.EndUpdate();
    };
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
  });
  rtl.createClass(this,"TImageListBox",this.TCustomListBox,function () {
    this.DoUpdateList = function () {
      var i = 0;
      var opt = null;
      var img = null;
      if (!(this.GetContainer() != null)) return;
      if (this.IsUpdating()) return;
      if (this.GetElementHandle().tagName !== "DIV") return;
      while (this.GetContainer().firstChild != null) this.GetContainer().removeChild(this.GetContainer().lastChild);
      for (var $l = 0, $end = this.FItems.GetCount() - 1; $l <= $end; $l++) {
        i = $l;
        opt = document.createElement("LABEL");
        img = document.createElement("IMG");
        img.setAttribute("src",this.FItems.Get(i));
        img.style.setProperty("display","inline-block");
        opt.appendChild(img);
        opt.style.setProperty("display","block");
        if (this.FElementItemClassName !== "") opt.setAttribute("class",this.FElementItemClassName);
        if (this.FDragMode === pas["WEBLib.Controls"].TDragMode.dmAutomatic) opt.setAttribute("draggable","true");
        this.GetContainer().appendChild(opt);
      };
      this.UpdateElementData();
    };
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
    var $r = this.$rtti;
    $r.addProperty("Align",2,pas["WEBLib.Controls"].$rtti["TAlign"],"FAlign","SetAlign",{Default: pas["WEBLib.Controls"].TAlign.alNone});
    $r.addProperty("AlignWithMargins",2,rtl.boolean,"FAlignWithMargins","SetAlignWithMargins",{Default: false});
    $r.addProperty("Anchors",2,pas["WEBLib.Controls"].$rtti["TAnchors"],"FAnchors","SetAnchors",{Default: rtl.createSet(pas["WEBLib.Controls"].TAnchorKind.akLeft,pas["WEBLib.Controls"].TAnchorKind.akTop)});
    $r.addProperty("BiDiMode",2,pas["WEBLib.Controls"].$rtti["TBiDiMode"],"FBiDiMode","SetBiDiMode",{Default: pas["WEBLib.Controls"].TBiDiMode.bdLeftToRight});
    $r.addProperty("BorderStyle",2,pas["WEBLib.Controls"].$rtti["TBorderStyle"],"FBorderStyle","SetBorderStyle",{Default: pas["WEBLib.Controls"].TBorderStyle.bsSingle});
    $r.addProperty("ChildOrder",2,rtl.longint,"FChildOrder","SetChildOrderEx",{Default: 0});
    $r.addProperty("Color",2,pas["WEBLib.Graphics"].$rtti["TColor"],"FColor","SetColor");
    $r.addProperty("DragMode",2,pas["WEBLib.Controls"].$rtti["TDragMode"],"FDragMode","SetDragMode",{Default: pas["WEBLib.Controls"].TDragMode.dmManual});
    $r.addProperty("Font",2,pas["WEBLib.Graphics"].$rtti["TFont"],"FFont","SetFont");
    $r.addProperty("ElementClassName",2,pas["WEBLib.Controls"].$rtti["TElementClassName"],"FElementClassName","SetElementClassName");
    $r.addProperty("ElementItemClassName",0,rtl.string,"FElementItemClassName","FElementItemClassName");
    $r.addProperty("ElementID",3,pas["WEBLib.Controls"].$rtti["TElementID"],"GetID","SetID");
    $r.addProperty("ElementFont",2,pas["WEBLib.Controls"].$rtti["TElementFont"],"FElementFont","SetElementFont",{Default: pas["WEBLib.Controls"].TElementFont.efProperty});
    $r.addProperty("ElementPosition",2,pas["WEBLib.Controls"].$rtti["TElementPosition"],"FElementPosition","SetElementPosition",{Default: pas["WEBLib.Controls"].TElementPosition.epAbsolute});
    $r.addProperty("Enabled",2,rtl.boolean,"FEnabled","SetEnabled",{Default: true});
    $r.addProperty("Height",3,rtl.longint,"GetHeight","SetHeight");
    $r.addProperty("HeightPercent",2,rtl.double,"FHeightPercent","SetHeightPercent",{Default: 100});
    $r.addProperty("HeightStyle",2,pas["WEBLib.Controls"].$rtti["TSizeStyle"],"FHeightStyle","SetHeightStyle",{Default: pas["WEBLib.Controls"].TSizeStyle.ssAbsolute});
    $r.addProperty("Hint",2,rtl.string,"FHint","SetHint");
    $r.addProperty("ItemHeight",2,rtl.longint,"FItemHeight","SetItemHeight");
    $r.addProperty("Items",2,pas.Classes.$rtti["TStrings"],"FItems","SetItems");
    $r.addProperty("Left",3,rtl.longint,"GetLeft","SetLeft");
    $r.addProperty("ParentColor",2,rtl.boolean,"FParentColor","SetParentColor",{Default: false});
    $r.addProperty("ParentFont",2,rtl.boolean,"FParentFont","SetParentFont",{Default: true});
    $r.addProperty("PopupMenu",0,pas["WEBLib.Menus"].$rtti["TPopupMenu"],"FPopupMenu","FPopupMenu");
    $r.addProperty("Role",3,rtl.string,"GetRole","SetRole");
    $r.addProperty("ShowFocus",2,rtl.boolean,"FShowFocus","SetShowFocus",{Default: false});
    $r.addProperty("ShowHint",2,rtl.boolean,"FShowHint","SetShowHint",{Default: false});
    $r.addProperty("TabOrder",2,rtl.longint,"FTabOrder","SetTabOrder");
    $r.addProperty("TabStop",2,rtl.boolean,"FTabStop","SetTabStop",{Default: true});
    $r.addProperty("Top",3,rtl.longint,"GetTop","SetTop");
    $r.addProperty("Visible",2,rtl.boolean,"FVisible","SetVisible",{Default: true});
    $r.addProperty("Width",3,rtl.longint,"GetWidth","SetWidth");
    $r.addProperty("WidthPercent",2,rtl.double,"FWidthPercent","SetWidthPercent",{Default: 100});
    $r.addProperty("WidthStyle",2,pas["WEBLib.Controls"].$rtti["TSizeStyle"],"FWidthStyle","SetWidthStyle",{Default: pas["WEBLib.Controls"].TSizeStyle.ssAbsolute});
    $r.addProperty("OnChange",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnChange","FOnChange");
    $r.addProperty("OnClick",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnClick","FOnClick");
    $r.addProperty("OnDblClick",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnDblClick","FOnDblClick");
    $r.addProperty("OnKeyDown",0,pas["WEBLib.Controls"].$rtti["TKeyEvent"],"FOnKeyDown","FOnKeyDown");
    $r.addProperty("OnKeyPress",0,pas["WEBLib.Controls"].$rtti["TKeyPressEvent"],"FOnKeyPress","FOnKeyPress");
    $r.addProperty("OnKeyUp",0,pas["WEBLib.Controls"].$rtti["TKeyEvent"],"FOnKeyUp","FOnKeyUp");
    $r.addProperty("OnMouseDown",0,pas["WEBLib.Controls"].$rtti["TMouseEvent"],"FOnMouseDown","FOnMouseDown");
    $r.addProperty("OnMouseUp",0,pas["WEBLib.Controls"].$rtti["TMouseEvent"],"FOnMouseUp","FOnMouseUp");
    $r.addProperty("OnMouseMove",0,pas["WEBLib.Controls"].$rtti["TMouseMoveEvent"],"FOnMouseMove","FOnMouseMove");
    $r.addProperty("OnMouseLeave",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnMouseLeave","FOnMouseLeave");
    $r.addProperty("OnMouseEnter",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnMouseEnter","FOnMouseEnter");
    $r.addProperty("OnMouseWheel",0,pas["WEBLib.Controls"].$rtti["TMouseWheelEvent"],"FOnMouseWheel","FOnMouseWheel");
    $r.addProperty("OnEnter",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnEnter","FOnEnter");
    $r.addProperty("OnExit",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnExit","FOnExit");
    $r.addProperty("OnDragDrop",0,pas["WEBLib.Controls"].$rtti["TDragDropEvent"],"FOnDragDrop","FOnDragDrop");
    $r.addProperty("OnDragOver",0,pas["WEBLib.Controls"].$rtti["TDragOverEvent"],"FOnDragOver","FOnDragOver");
    $r.addProperty("OnEndDrag",0,pas["WEBLib.Controls"].$rtti["TEndDragEvent"],"FonEndDrag","FonEndDrag");
    $r.addProperty("OnStartDrag",0,pas["WEBLib.Controls"].$rtti["TStartDragEvent"],"FOnStartDrag","FOnStartDrag");
  });
  rtl.createClass(this,"TWebImageListBox",this.TImageListBox,function () {
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
  });
  rtl.createClass(this,"TSearchEdit",pas["WEBLib.StdCtrls"].TCustomEdit,function () {
    this.$init = function () {
      pas["WEBLib.StdCtrls"].TCustomEdit.$init.call(this);
      this.FSearchElement = null;
      this.FClearElement = null;
      this.FInputElement = null;
      this.FClearPtr = null;
      this.FSearchPtr = null;
      this.FOnSearchClick = null;
      this.FOnClearClick = null;
      this.FClearImageURL = "";
      this.FSearchImageURL = "";
    };
    this.$final = function () {
      this.FSearchElement = undefined;
      this.FClearElement = undefined;
      this.FInputElement = undefined;
      this.FOnSearchClick = undefined;
      this.FOnClearClick = undefined;
      pas["WEBLib.StdCtrls"].TCustomEdit.$final.call(this);
    };
    this.SetClearImageURL = function (Value) {
      this.FClearImageURL = Value;
    };
    this.SetSearchImageURL = function (Value) {
      this.FSearchImageURL = Value;
    };
    this.GetElementBindHandle = function () {
      var Result = null;
      Result = this.FInputElement;
      return Result;
    };
    this.GetElementInputHandle = function () {
      var Result = null;
      Result = this.FInputElement;
      return Result;
    };
    this.UpdateElementVisual = function () {
      pas["WEBLib.StdCtrls"].TCustomInput.UpdateElementVisual.call(this);
      if (this.FSearchElement != null) {
        if (this.FSearchImageURL !== "") {
          this.FSearchElement.setAttribute("src",this.FSearchImageURL)}
         else this.FSearchElement.setAttribute("src",$impl.btnsearchres);
      };
      if (this.FClearElement != null) {
        if (this.FClearImageURL !== "") {
          this.FClearElement.setAttribute("src",this.FClearImageURL)}
         else this.FClearElement.setAttribute("src",$impl.btnclearres);
      };
    };
    this.CreateChildElements = function (AContainer) {
      var FTable = null;
      var FRow = null;
      var FCell = null;
      pas["WEBLib.Controls"].TControl.CreateChildElements.apply(this,arguments);
      this.FSearchElement = document.createElement("IMG");
      this.FClearElement = document.createElement("IMG");
      this.FInputElement = document.createElement("INPUT");
      FTable = document.createElement("TABLE");
      FTable.style.setProperty("height","100%");
      FRow = document.createElement("TR");
      AContainer.appendChild(FTable);
      FTable.appendChild(FRow);
      FCell = document.createElement("TD");
      FRow.appendChild(FCell);
      FCell.appendChild(this.FSearchElement);
      FCell = document.createElement("TD");
      FRow.appendChild(FCell);
      FCell.appendChild(this.FInputElement);
      FCell = document.createElement("TD");
      FRow.appendChild(FCell);
      FCell.appendChild(this.FClearElement);
      this.FSearchElement.setAttribute("src",$impl.btnsearchres);
      this.FClearElement.setAttribute("src",$impl.btnclearres);
    };
    this.BindEvents = function () {
      pas["WEBLib.StdCtrls"].TCustomEdit.BindEvents.call(this);
      if (this.FClearElement != null) this.FClearElement.addEventListener("click",this.FClearPtr);
      if (this.FSearchElement != null) this.FSearchElement.addEventListener("click",this.FSearchPtr);
    };
    this.HandleDoClear = function (Event) {
      var Result = false;
      if (this.FOnClearClick != null) this.FOnClearClick(this);
      this.FInputElement.value = '';
      this.FInputElement.focus();
      Result = true;
      return Result;
    };
    this.HandleDoSearch = function (Event) {
      var Result = false;
      if (this.FOnSearchClick != null) this.FOnSearchClick(this);
      Result = true;
      return Result;
    };
    this.CreateElement = function () {
      var Result = null;
      Result = document.createElement("DIV");
      return Result;
    };
    this.UpdateElement = function () {
      pas["WEBLib.Controls"].TControl.UpdateElement.call(this);
      if ((this.GetElementHandle() != null) && (this.GetElementHandle() !== this.ContainerElement()) && !this.IsUpdating()) {
        if ((this.FElementClassName === "") && (this.FBorderStyle === pas["WEBLib.Controls"].TBorderStyle.bsSingle)) {
          this.GetElementHandle().style.setProperty("border","1px solid gray");
          this.GetElementHandle().style.setProperty("border-radius","4px");
        };
        this.FInputElement.style.setProperty("border","none");
        this.FInputElement.style.setProperty("outline","none");
        this.FInputElement.parentElement.style.setProperty("vertical-align","middle");
        this.FInputElement.parentElement.style.setProperty("width","100%");
        this.FSearchElement.parentElement.style.setProperty("vertical-align","middle");
        this.FClearElement.parentElement.style.setProperty("vertical-align","middle");
        if (this.FElementPosition === pas["WEBLib.Controls"].TElementPosition.epAbsolute) {
          this.FInputElement.style.setProperty("width","100%")}
         else this.FInputElement.style.removeProperty("width");
      };
    };
    this.SetEnabled = function (Value) {
      pas["WEBLib.Controls"].TControl.SetEnabled.apply(this,arguments);
      if (this.GetElementInputHandle() != null) {
        if (Value) {
          this.GetElementInputHandle().removeAttribute("disabled")}
         else this.GetElementInputHandle().setAttribute("disabled","");
      };
    };
    this.ClearMethodPointers = function () {
      pas["WEBLib.StdCtrls"].TCustomEdit.ClearMethodPointers.call(this);
      this.FClearPtr = null;
      this.FSearchPtr = null;
    };
    this.GetMethodPointers = function () {
      pas["WEBLib.StdCtrls"].TCustomEdit.GetMethodPointers.call(this);
      if (this.FClearPtr === null) this.FClearPtr = rtl.createCallback(this,"HandleDoClear");
      if (this.FSearchPtr === null) this.FSearchPtr = rtl.createCallback(this,"HandleDoSearch");
    };
    this.SetFocus = function () {
      var eh = null;
      if (this.GetElementInputHandle() != null) {
        eh = this.GetElementInputHandle();
        eh.focus();
      };
    };
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
    var $r = this.$rtti;
    $r.addProperty("Alignment",2,pas.Classes.$rtti["TAlignment"],"FAlignment","SetAlignment");
    $r.addProperty("AutoCompletion",2,pas["WEBLib.StdCtrls"].$rtti["TAutoCompletion"],"FAutoCompletion","SetAutoCompletion",{Default: pas["WEBLib.StdCtrls"].TAutoCompletion.acOff});
    $r.addProperty("AutoSelect",2,rtl.boolean,"FAutoSelect","SetAutoSelect",{Default: true});
    $r.addProperty("AutoFocus",2,rtl.boolean,"FAutoFocus","SetAutoFocus",{Default: false});
    $r.addProperty("AutoSize",2,rtl.boolean,"FAutoSize","SetAutoSize",{Default: false});
    $r.addProperty("BorderStyle",2,pas["WEBLib.Controls"].$rtti["TBorderStyle"],"FBorderStyle","SetBorderStyle",{Default: pas["WEBLib.Controls"].TBorderStyle.bsSingle});
    $r.addProperty("CharCase",2,pas["WEBLib.StdCtrls"].$rtti["TEditCharCase"],"FCharCase","SetCharCase",{Default: pas["WEBLib.StdCtrls"].TEditCharCase.wecNormal});
    $r.addProperty("Color",2,pas["WEBLib.Graphics"].$rtti["TColor"],"FColor","SetColor");
    $r.addProperty("Font",2,pas["WEBLib.Graphics"].$rtti["TFont"],"FFont","SetFont");
    $r.addProperty("HideSelection",2,rtl.boolean,"FHideSelection","SetHideSelection");
    $r.addProperty("MaxLength",2,rtl.longint,"FMaxLength","SetMaxLength",{Default: 0});
    $r.addProperty("PasswordChar",2,rtl.char,"FPasswordChar","SetPasswordChar",{Default: "\x00"});
    $r.addProperty("Pattern",2,rtl.string,"FPattern","SetPattern");
    $r.addProperty("ReadOnly",2,rtl.boolean,"FReadOnly","SetReadOnly",{Default: false});
    $r.addProperty("Required",2,rtl.boolean,"FRequired","SetRequired",{Default: false});
    $r.addProperty("RequiredText",0,rtl.string,"FRequiredText","FRequiredText");
    $r.addProperty("TextHint",2,rtl.string,"FTextHint","SetTextHint");
    $r.addMethod("SetFocus",0,[]);
    $r.addProperty("Text",3,rtl.string,"GetText","SetText");
    $r.addProperty("OnChange",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnChange","FOnChange");
    $r.addProperty("OnClick",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnClick","FOnClick");
    $r.addProperty("OnDblClick",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnDblClick","FOnDblClick");
    $r.addProperty("OnKeyDown",0,pas["WEBLib.Controls"].$rtti["TKeyEvent"],"FOnKeyDown","FOnKeyDown");
    $r.addProperty("OnKeyPress",0,pas["WEBLib.Controls"].$rtti["TKeyPressEvent"],"FOnKeyPress","FOnKeyPress");
    $r.addProperty("OnKeyUp",0,pas["WEBLib.Controls"].$rtti["TKeyEvent"],"FOnKeyUp","FOnKeyUp");
    $r.addProperty("OnMouseDown",0,pas["WEBLib.Controls"].$rtti["TMouseEvent"],"FOnMouseDown","FOnMouseDown");
    $r.addProperty("OnMouseUp",0,pas["WEBLib.Controls"].$rtti["TMouseEvent"],"FOnMouseUp","FOnMouseUp");
    $r.addProperty("OnMouseMove",0,pas["WEBLib.Controls"].$rtti["TMouseMoveEvent"],"FOnMouseMove","FOnMouseMove");
    $r.addProperty("OnMouseLeave",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnMouseLeave","FOnMouseLeave");
    $r.addProperty("OnMouseEnter",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnMouseEnter","FOnMouseEnter");
    $r.addProperty("OnEnter",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnEnter","FOnEnter");
    $r.addProperty("OnExit",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnExit","FOnExit");
    $r.addProperty("OnDragDrop",0,pas["WEBLib.Controls"].$rtti["TDragDropEvent"],"FOnDragDrop","FOnDragDrop");
    $r.addProperty("OnDragOver",0,pas["WEBLib.Controls"].$rtti["TDragOverEvent"],"FOnDragOver","FOnDragOver");
    $r.addProperty("OnEndDrag",0,pas["WEBLib.Controls"].$rtti["TEndDragEvent"],"FonEndDrag","FonEndDrag");
    $r.addProperty("OnStartDrag",0,pas["WEBLib.Controls"].$rtti["TStartDragEvent"],"FOnStartDrag","FOnStartDrag");
    $r.addProperty("OnClearClick",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnClearClick","FOnClearClick");
    $r.addProperty("OnSearchClick",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnSearchClick","FOnSearchClick");
  });
  rtl.createClass(this,"TWebSearchEdit",this.TSearchEdit,function () {
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
    var $r = this.$rtti;
    $r.addProperty("Alignment",2,pas.Classes.$rtti["TAlignment"],"FAlignment","SetAlignment");
    $r.addProperty("Align",2,pas["WEBLib.Controls"].$rtti["TAlign"],"FAlign","SetAlign",{Default: pas["WEBLib.Controls"].TAlign.alNone});
    $r.addProperty("AlignWithMargins",2,rtl.boolean,"FAlignWithMargins","SetAlignWithMargins",{Default: false});
    $r.addProperty("Anchors",2,pas["WEBLib.Controls"].$rtti["TAnchors"],"FAnchors","SetAnchors",{Default: rtl.createSet(pas["WEBLib.Controls"].TAnchorKind.akLeft,pas["WEBLib.Controls"].TAnchorKind.akTop)});
    $r.addProperty("AutoCompletion",2,pas["WEBLib.StdCtrls"].$rtti["TAutoCompletion"],"FAutoCompletion","SetAutoCompletion",{Default: pas["WEBLib.StdCtrls"].TAutoCompletion.acOff});
    $r.addProperty("AutoFocus",2,rtl.boolean,"FAutoFocus","SetAutoFocus",{Default: false});
    $r.addProperty("AutoSize",2,rtl.boolean,"FAutoSize","SetAutoSize",{Default: false});
    $r.addProperty("AutoSelect",2,rtl.boolean,"FAutoSelect","SetAutoSelect",{Default: true});
    $r.addProperty("BiDiMode",2,pas["WEBLib.Controls"].$rtti["TBiDiMode"],"FBiDiMode","SetBiDiMode",{Default: pas["WEBLib.Controls"].TBiDiMode.bdLeftToRight});
    $r.addProperty("BorderStyle",2,pas["WEBLib.Controls"].$rtti["TBorderStyle"],"FBorderStyle","SetBorderStyle",{Default: pas["WEBLib.Controls"].TBorderStyle.bsSingle});
    $r.addProperty("CharCase",2,pas["WEBLib.StdCtrls"].$rtti["TEditCharCase"],"FCharCase","SetCharCase",{Default: pas["WEBLib.StdCtrls"].TEditCharCase.wecNormal});
    $r.addProperty("ChildOrder",2,rtl.longint,"FChildOrder","SetChildOrderEx",{Default: 0});
    $r.addProperty("ClearImageURL",2,rtl.string,"FClearImageURL","SetClearImageURL");
    $r.addProperty("Color",2,pas["WEBLib.Graphics"].$rtti["TColor"],"FColor","SetColor");
    $r.addProperty("DragMode",2,pas["WEBLib.Controls"].$rtti["TDragMode"],"FDragMode","SetDragMode",{Default: pas["WEBLib.Controls"].TDragMode.dmManual});
    $r.addProperty("EditType",2,pas["WEBLib.StdCtrls"].$rtti["TEditType"],"FEditType","SetEditType",{Default: pas["WEBLib.StdCtrls"].TEditType.weString});
    $r.addProperty("ElementClassName",2,pas["WEBLib.Controls"].$rtti["TElementClassName"],"FElementClassName","SetElementClassName");
    $r.addProperty("ElementID",3,pas["WEBLib.Controls"].$rtti["TElementID"],"GetID","SetID");
    $r.addProperty("ElementFont",2,pas["WEBLib.Controls"].$rtti["TElementFont"],"FElementFont","SetElementFont",{Default: pas["WEBLib.Controls"].TElementFont.efProperty});
    $r.addProperty("ElementPosition",2,pas["WEBLib.Controls"].$rtti["TElementPosition"],"FElementPosition","SetElementPosition",{Default: pas["WEBLib.Controls"].TElementPosition.epAbsolute});
    $r.addProperty("Enabled",2,rtl.boolean,"FEnabled","SetEnabled",{Default: true});
    $r.addProperty("Font",2,pas["WEBLib.Graphics"].$rtti["TFont"],"FFont","SetFont");
    $r.addProperty("Height",3,rtl.longint,"GetHeight","SetHeight");
    $r.addProperty("HeightPercent",2,rtl.double,"FHeightPercent","SetHeightPercent",{Default: 100});
    $r.addProperty("HeightStyle",2,pas["WEBLib.Controls"].$rtti["TSizeStyle"],"FHeightStyle","SetHeightStyle",{Default: pas["WEBLib.Controls"].TSizeStyle.ssAbsolute});
    $r.addProperty("Hint",2,rtl.string,"FHint","SetHint");
    $r.addProperty("HideSelection",2,rtl.boolean,"FHideSelection","SetHideSelection");
    $r.addProperty("Left",3,rtl.longint,"GetLeft","SetLeft");
    $r.addProperty("ParentFont",2,rtl.boolean,"FParentFont","SetParentFont",{Default: true});
    $r.addProperty("PasswordChar",2,rtl.char,"FPasswordChar","SetPasswordChar",{Default: "\x00"});
    $r.addProperty("Pattern",2,rtl.string,"FPattern","SetPattern");
    $r.addProperty("Margins",2,pas["WEBLib.Controls"].$rtti["TMargins"],"FMargins","SetMargins");
    $r.addProperty("MaxLength",2,rtl.longint,"FMaxLength","SetMaxLength",{Default: 0});
    $r.addProperty("PopupMenu",0,pas["WEBLib.Menus"].$rtti["TPopupMenu"],"FPopupMenu","FPopupMenu");
    $r.addProperty("ReadOnly",2,rtl.boolean,"FReadOnly","SetReadOnly",{Default: false});
    $r.addProperty("Required",2,rtl.boolean,"FRequired","SetRequired",{Default: false});
    $r.addProperty("SearchImageURL",2,rtl.string,"FSearchImageURL","SetSearchImageURL");
    $r.addProperty("ShowFocus",2,rtl.boolean,"FShowFocus","SetShowFocus",{Default: false});
    $r.addProperty("ShowHint",2,rtl.boolean,"FShowHint","SetShowHint",{Default: false});
    $r.addProperty("SpellCheck",2,rtl.boolean,"FSpellCheck","SetSpellCheck",{Default: true});
    $r.addProperty("TabOrder",2,rtl.longint,"FTabOrder","SetTabOrder");
    $r.addProperty("TabStop",2,rtl.boolean,"FTabStop","SetTabStop",{Default: true});
    $r.addProperty("Text",3,rtl.string,"GetText","SetText");
    $r.addProperty("TextDirection",0,pas["WEBLib.Controls"].$rtti["TTextDirection"],"FTextDirection","FTextDirection",{Default: pas["WEBLib.Controls"].TTextDirection.tdDefault});
    $r.addProperty("TextHint",2,rtl.string,"FTextHint","SetTextHint");
    $r.addProperty("Top",3,rtl.longint,"GetTop","SetTop");
    $r.addProperty("Visible",2,rtl.boolean,"FVisible","SetVisible",{Default: true});
    $r.addProperty("Width",3,rtl.longint,"GetWidth","SetWidth");
    $r.addProperty("WidthPercent",2,rtl.double,"FWidthPercent","SetWidthPercent",{Default: 100});
    $r.addProperty("WidthStyle",2,pas["WEBLib.Controls"].$rtti["TSizeStyle"],"FWidthStyle","SetWidthStyle",{Default: pas["WEBLib.Controls"].TSizeStyle.ssAbsolute});
    $r.addProperty("OnChange",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnChange","FOnChange");
    $r.addProperty("OnClick",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnClick","FOnClick");
    $r.addProperty("OnDblClick",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnDblClick","FOnDblClick");
    $r.addProperty("OnKeyDown",0,pas["WEBLib.Controls"].$rtti["TKeyEvent"],"FOnKeyDown","FOnKeyDown");
    $r.addProperty("OnKeyPress",0,pas["WEBLib.Controls"].$rtti["TKeyPressEvent"],"FOnKeyPress","FOnKeyPress");
    $r.addProperty("OnKeyUp",0,pas["WEBLib.Controls"].$rtti["TKeyEvent"],"FOnKeyUp","FOnKeyUp");
    $r.addProperty("OnMouseDown",0,pas["WEBLib.Controls"].$rtti["TMouseEvent"],"FOnMouseDown","FOnMouseDown");
    $r.addProperty("OnMouseUp",0,pas["WEBLib.Controls"].$rtti["TMouseEvent"],"FOnMouseUp","FOnMouseUp");
    $r.addProperty("OnMouseMove",0,pas["WEBLib.Controls"].$rtti["TMouseMoveEvent"],"FOnMouseMove","FOnMouseMove");
    $r.addProperty("OnMouseLeave",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnMouseLeave","FOnMouseLeave");
    $r.addProperty("OnMouseEnter",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnMouseEnter","FOnMouseEnter");
    $r.addProperty("OnEnter",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnEnter","FOnEnter");
    $r.addProperty("OnExit",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnExit","FOnExit");
    $r.addProperty("OnDragDrop",0,pas["WEBLib.Controls"].$rtti["TDragDropEvent"],"FOnDragDrop","FOnDragDrop");
    $r.addProperty("OnDragOver",0,pas["WEBLib.Controls"].$rtti["TDragOverEvent"],"FOnDragOver","FOnDragOver");
    $r.addProperty("OnEndDrag",0,pas["WEBLib.Controls"].$rtti["TEndDragEvent"],"FonEndDrag","FonEndDrag");
    $r.addProperty("OnStartDrag",0,pas["WEBLib.Controls"].$rtti["TStartDragEvent"],"FOnStartDrag","FOnStartDrag");
    $r.addProperty("OnClearClick",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnClearClick","FOnClearClick");
    $r.addProperty("OnSearchClick",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnSearchClick","FOnSearchClick");
  });
  rtl.createClass(this,"TEditButton",pas.Classes.TPersistent,function () {
    this.$init = function () {
      pas.Classes.TPersistent.$init.call(this);
      this.FMaterialGlyph = "";
      this.FWidth = 0;
      this.FMaterialGlyphColor = 0;
      this.FCaption = "";
      this.FMaterialGlyphType = 0;
      this.FMaterialGlyphSize = 0;
      this.FOnChange = null;
    };
    this.$final = function () {
      this.FOnChange = undefined;
      pas.Classes.TPersistent.$final.call(this);
    };
    this.SetMaterialGlyph = function (Value) {
      this.FMaterialGlyph = Value;
      this.Changed();
    };
    this.SetMaterialGlyphSize = function (Value) {
      this.FMaterialGlyphSize = Value;
      this.Changed();
    };
    this.SetMaterialGlyphType = function (Value) {
      this.FMaterialGlyphType = Value;
      this.Changed();
    };
    this.SetMaterialGyphColor = function (Value) {
      this.FMaterialGlyphColor = Value;
      this.Changed();
    };
    this.SetCaption = function (Value) {
      this.FCaption = Value;
      this.Changed();
    };
    this.SetWidth = function (Value) {
      this.FWidth = Value;
      this.Changed();
    };
    this.Changed = function () {
      if (this.FOnChange != null) this.FOnChange(this);
    };
    this.Create$1 = function () {
      pas.System.TObject.Create.call(this);
      this.FWidth = 24;
      this.FCaption = "";
      this.FMaterialGlyphColor = -1;
      this.FMaterialGlyphSize = 18;
      this.FMaterialGlyphType = pas["WEBLib.Controls"].TMaterialGlyphType.mgNormal;
      return this;
    };
    this.Assign = function (Source) {
      if ($mod.TEditButton.isPrototypeOf(Source)) {
        this.FWidth = rtl.as(Source,$mod.TEditButton).FWidth;
        this.FMaterialGlyph = rtl.as(Source,$mod.TEditButton).FMaterialGlyph;
        this.FMaterialGlyphSize = rtl.as(Source,$mod.TEditButton).FMaterialGlyphSize;
        this.FMaterialGlyphColor = rtl.as(Source,$mod.TEditButton).FMaterialGlyphColor;
        this.FCaption = rtl.as(Source,$mod.TEditButton).FCaption;
      };
    };
    var $r = this.$rtti;
    $r.addMethod("Create$1",2,[]);
    $r.addProperty("Caption",2,rtl.string,"FCaption","SetCaption");
    $r.addProperty("MaterialGlyph",2,rtl.string,"FMaterialGlyph","SetMaterialGlyph");
    $r.addProperty("MaterialGlyphColor",2,pas["WEBLib.Graphics"].$rtti["TColor"],"FMaterialGlyphColor","SetMaterialGyphColor",{Default: -1});
    $r.addProperty("MaterialGlyphSize",2,rtl.longint,"FMaterialGlyphSize","SetMaterialGlyphSize",{Default: 18});
    $r.addProperty("MaterialGlyphType",2,pas["WEBLib.Controls"].$rtti["TMaterialGlyphType"],"FMaterialGlyphType","SetMaterialGlyphType",{Default: pas["WEBLib.Controls"].TMaterialGlyphType.mgNormal});
    $r.addProperty("Width",2,rtl.longint,"FWidth","SetWidth",{Default: 24});
  });
  rtl.createClass(this,"TEditBtn",pas["WEBLib.StdCtrls"].TCustomEdit,function () {
    this.$init = function () {
      pas["WEBLib.StdCtrls"].TCustomEdit.$init.call(this);
      this.FBtnElement = null;
      this.FInputElement = null;
      this.FBtnClickPtr = null;
      this.FOnBtnClick = null;
      this.FButton = null;
      this.FElementInputClassName = "";
      this.FElementButtonClassName = "";
    };
    this.$final = function () {
      this.FBtnElement = undefined;
      this.FInputElement = undefined;
      this.FOnBtnClick = undefined;
      this.FButton = undefined;
      pas["WEBLib.StdCtrls"].TCustomEdit.$final.call(this);
    };
    this.SetButton = function (Value) {
      this.FButton.Assign(Value);
    };
    this.SetElementInputClassName = function (Value) {
      if (this.FElementInputClassName !== Value) {
        this.FElementInputClassName = Value;
        this.UpdateElement();
      };
    };
    this.SetElementButtonClassName = function (Value) {
      if (this.FElementButtonClassName !== Value) {
        this.FElementButtonClassName = Value;
        this.UpdateElement();
      };
    };
    this.HandleDoBtnClick = function (Event) {
      var Result = false;
      if (this.FOnBtnClick != null) this.FOnBtnClick(this);
      Result = true;
      return Result;
    };
    this.GetElementBindHandle = function () {
      var Result = null;
      Result = this.FInputElement;
      return Result;
    };
    this.GetElementInputHandle = function () {
      var Result = null;
      Result = this.FInputElement;
      return Result;
    };
    this.CreateElement = function () {
      var Result = null;
      var FTable = null;
      var FRow = null;
      var FCell1 = null;
      var FCell2 = null;
      Result = document.createElement("DIV");
      this.FBtnElement = document.createElement("BUTTON");
      this.FInputElement = document.createElement("INPUT");
      FTable = document.createElement("TABLE");
      FRow = document.createElement("TR");
      Result.appendChild(FTable);
      FTable.appendChild(FRow);
      FCell1 = document.createElement("TD");
      FRow.appendChild(FCell1);
      FCell1.appendChild(this.FInputElement);
      FCell2 = document.createElement("TD");
      FRow.appendChild(FCell2);
      FCell2.appendChild(this.FBtnElement);
      this.FBtnElement.innerHTML = "&nbsp;";
      FTable.style.setProperty("border","none");
      FTable.style.setProperty("border-collapse","collapse");
      FTable.style.setProperty("height","100%");
      return Result;
    };
    this.UpdateElement = function () {
      var h = 0;
      pas["WEBLib.Controls"].TControl.UpdateElement.call(this);
      if ((this.GetElementHandle() != null) && (this.GetElementHandle() !== this.ContainerElement()) && !this.IsUpdating()) {
        this.FInputElement.style.setProperty("outline","none");
        this.FInputElement.style.setProperty("box-sizing","unset");
        if (this.FElementPosition === pas["WEBLib.Controls"].TElementPosition.epAbsolute) {
          this.FInputElement.style.setProperty("width","100%")}
         else this.FInputElement.style.removeProperty("width");
        h = this.GetHeight() - 6 - 4;
        this.FInputElement.style.setProperty("height",pas["WEBLib.Utils"].TLongIntHelper.ToString.call({get: function () {
            return h;
          }, set: function (v) {
            h = v;
          }}) + "px");
        if (this.FElementInputClassName !== "") {
          this.FInputElement.setAttribute("class",this.FElementInputClassName)}
         else this.FInputElement.removeAttribute("class");
        if (this.FElementButtonClassName !== "") {
          this.FBtnElement.setAttribute("class",this.FElementButtonClassName)}
         else this.FBtnElement.removeAttribute("class");
        h = this.GetHeight() - 4;
        this.FBtnElement.style.setProperty("width",pas["WEBLib.Utils"].TLongIntHelper.ToString.call({p: this.FButton, get: function () {
            return this.p.FWidth;
          }, set: function (v) {
            this.p.FWidth = v;
          }}) + "px");
        this.FBtnElement.style.setProperty("padding","0");
        this.FBtnElement.style.setProperty("height",pas["WEBLib.Utils"].TLongIntHelper.ToString.call({get: function () {
            return h;
          }, set: function (v) {
            h = v;
          }}) + "px");
        pas["WEBLib.Controls"].SetHTMLElementFont(this.FInputElement,this.FFont,this.FElementFont === pas["WEBLib.Controls"].TElementFont.efCSS);
        if (this.FButton.FCaption !== "") this.FBtnElement.innerHTML = this.FButton.FCaption;
        if (this.FButton.FMaterialGlyph !== "") {
          this.FBtnElement.innerHTML = pas["WEBLib.WebTools"].GetMaterialGlyph(this.FButton.FMaterialGlyph,this.FButton.FMaterialGlyphSize,this.FButton.FMaterialGlyphColor,this.FButton.FMaterialGlyphType);
        };
        this.GetElementHandle().style.setProperty("border","none");
      };
    };
    this.ClearMethodPointers = function () {
      pas["WEBLib.StdCtrls"].TCustomEdit.ClearMethodPointers.call(this);
      this.FBtnClickPtr = null;
    };
    this.GetMethodPointers = function () {
      pas["WEBLib.StdCtrls"].TCustomEdit.GetMethodPointers.call(this);
      if (this.FBtnClickPtr === null) this.FBtnClickPtr = rtl.createCallback(this,"HandleDoBtnClick");
    };
    this.BindEvents = function () {
      pas["WEBLib.StdCtrls"].TCustomEdit.BindEvents.call(this);
      if (this.FBtnElement != null) this.FBtnElement.addEventListener("click",this.FBtnClickPtr);
    };
    this.ButtonChanged = function (Sender) {
      this.UpdateElement();
    };
    this.InitCSSLibrary = function (ALibrary) {
      if (ALibrary === pas["WEBLib.Controls"].TCSSLibrary.cssBootstrap) {
        this.SetElementFont(pas["WEBLib.Controls"].TElementFont.efCSS);
        this.SetElementClassName("");
        this.SetElementInputClassName("form-control");
        this.SetElementButtonClassName("btn btn-primary");
        this.SetHeightStyle(pas["WEBLib.Controls"].TSizeStyle.ssAuto);
      };
    };
    this.Create$1 = function (AOwner) {
      pas["WEBLib.Controls"].TControl.Create$1.apply(this,arguments);
      this.FButton = $mod.TEditButton.$create("Create$1");
      this.FButton.FOnChange = rtl.createCallback(this,"ButtonChanged");
      return this;
    };
    this.Destroy = function () {
      rtl.free(this,"FButton");
      pas["WEBLib.Controls"].TCustomControl.Destroy.call(this);
    };
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
    var $r = this.$rtti;
    $r.addMethod("Create$1",2,[["AOwner",pas.Classes.$rtti["TComponent"]]]);
  });
  rtl.createClass(this,"TWebEditBtn",this.TEditBtn,function () {
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
    var $r = this.$rtti;
    $r.addProperty("Alignment",2,pas.Classes.$rtti["TAlignment"],"FAlignment","SetAlignment");
    $r.addProperty("Align",2,pas["WEBLib.Controls"].$rtti["TAlign"],"FAlign","SetAlign",{Default: pas["WEBLib.Controls"].TAlign.alNone});
    $r.addProperty("AlignWithMargins",2,rtl.boolean,"FAlignWithMargins","SetAlignWithMargins",{Default: false});
    $r.addProperty("Anchors",2,pas["WEBLib.Controls"].$rtti["TAnchors"],"FAnchors","SetAnchors",{Default: rtl.createSet(pas["WEBLib.Controls"].TAnchorKind.akLeft,pas["WEBLib.Controls"].TAnchorKind.akTop)});
    $r.addProperty("AutoCompletion",2,pas["WEBLib.StdCtrls"].$rtti["TAutoCompletion"],"FAutoCompletion","SetAutoCompletion",{Default: pas["WEBLib.StdCtrls"].TAutoCompletion.acOff});
    $r.addProperty("AutoFocus",2,rtl.boolean,"FAutoFocus","SetAutoFocus",{Default: false});
    $r.addProperty("AutoSize",2,rtl.boolean,"FAutoSize","SetAutoSize",{Default: false});
    $r.addProperty("AutoSelect",2,rtl.boolean,"FAutoSelect","SetAutoSelect",{Default: true});
    $r.addProperty("BiDiMode",2,pas["WEBLib.Controls"].$rtti["TBiDiMode"],"FBiDiMode","SetBiDiMode",{Default: pas["WEBLib.Controls"].TBiDiMode.bdLeftToRight});
    $r.addProperty("BorderStyle",2,pas["WEBLib.Controls"].$rtti["TBorderStyle"],"FBorderStyle","SetBorderStyle",{Default: pas["WEBLib.Controls"].TBorderStyle.bsSingle});
    $r.addProperty("Button",2,$mod.$rtti["TEditButton"],"FButton","SetButton");
    $r.addProperty("CharCase",2,pas["WEBLib.StdCtrls"].$rtti["TEditCharCase"],"FCharCase","SetCharCase",{Default: pas["WEBLib.StdCtrls"].TEditCharCase.wecNormal});
    $r.addProperty("ChildOrder",2,rtl.longint,"FChildOrder","SetChildOrderEx",{Default: 0});
    $r.addProperty("Color",2,pas["WEBLib.Graphics"].$rtti["TColor"],"FColor","SetColor");
    $r.addProperty("DragMode",2,pas["WEBLib.Controls"].$rtti["TDragMode"],"FDragMode","SetDragMode",{Default: pas["WEBLib.Controls"].TDragMode.dmManual});
    $r.addProperty("EditType",2,pas["WEBLib.StdCtrls"].$rtti["TEditType"],"FEditType","SetEditType",{Default: pas["WEBLib.StdCtrls"].TEditType.weString});
    $r.addProperty("ElementClassName",2,pas["WEBLib.Controls"].$rtti["TElementClassName"],"FElementClassName","SetElementClassName");
    $r.addProperty("ElementID",3,pas["WEBLib.Controls"].$rtti["TElementID"],"GetID","SetID");
    $r.addProperty("ElementFont",2,pas["WEBLib.Controls"].$rtti["TElementFont"],"FElementFont","SetElementFont",{Default: pas["WEBLib.Controls"].TElementFont.efProperty});
    $r.addProperty("ElementPosition",2,pas["WEBLib.Controls"].$rtti["TElementPosition"],"FElementPosition","SetElementPosition",{Default: pas["WEBLib.Controls"].TElementPosition.epAbsolute});
    $r.addProperty("Enabled",2,rtl.boolean,"FEnabled","SetEnabled",{Default: true});
    $r.addProperty("Font",2,pas["WEBLib.Graphics"].$rtti["TFont"],"FFont","SetFont");
    $r.addProperty("Height",3,rtl.longint,"GetHeight","SetHeight");
    $r.addProperty("HeightPercent",2,rtl.double,"FHeightPercent","SetHeightPercent",{Default: 100});
    $r.addProperty("HeightStyle",2,pas["WEBLib.Controls"].$rtti["TSizeStyle"],"FHeightStyle","SetHeightStyle",{Default: pas["WEBLib.Controls"].TSizeStyle.ssAbsolute});
    $r.addProperty("Hint",2,rtl.string,"FHint","SetHint");
    $r.addProperty("HideSelection",2,rtl.boolean,"FHideSelection","SetHideSelection");
    $r.addProperty("Left",3,rtl.longint,"GetLeft","SetLeft");
    $r.addProperty("ParentFont",2,rtl.boolean,"FParentFont","SetParentFont",{Default: true});
    $r.addProperty("PasswordChar",2,rtl.char,"FPasswordChar","SetPasswordChar",{Default: "\x00"});
    $r.addProperty("Pattern",2,rtl.string,"FPattern","SetPattern");
    $r.addProperty("Margins",2,pas["WEBLib.Controls"].$rtti["TMargins"],"FMargins","SetMargins");
    $r.addProperty("MaxLength",2,rtl.longint,"FMaxLength","SetMaxLength",{Default: 0});
    $r.addProperty("PopupMenu",0,pas["WEBLib.Menus"].$rtti["TPopupMenu"],"FPopupMenu","FPopupMenu");
    $r.addProperty("ReadOnly",2,rtl.boolean,"FReadOnly","SetReadOnly",{Default: false});
    $r.addProperty("Required",2,rtl.boolean,"FRequired","SetRequired",{Default: false});
    $r.addProperty("RequiredText",0,rtl.string,"FRequiredText","FRequiredText");
    $r.addProperty("ShowFocus",2,rtl.boolean,"FShowFocus","SetShowFocus",{Default: false});
    $r.addProperty("ShowHint",2,rtl.boolean,"FShowHint","SetShowHint",{Default: false});
    $r.addProperty("SpellCheck",2,rtl.boolean,"FSpellCheck","SetSpellCheck",{Default: true});
    $r.addProperty("TabOrder",2,rtl.longint,"FTabOrder","SetTabOrder");
    $r.addProperty("TabStop",2,rtl.boolean,"FTabStop","SetTabStop",{Default: true});
    $r.addProperty("Text",3,rtl.string,"GetText","SetText");
    $r.addProperty("TextDirection",0,pas["WEBLib.Controls"].$rtti["TTextDirection"],"FTextDirection","FTextDirection",{Default: pas["WEBLib.Controls"].TTextDirection.tdDefault});
    $r.addProperty("TextHint",2,rtl.string,"FTextHint","SetTextHint");
    $r.addProperty("Top",3,rtl.longint,"GetTop","SetTop");
    $r.addProperty("Visible",2,rtl.boolean,"FVisible","SetVisible",{Default: true});
    $r.addProperty("Width",3,rtl.longint,"GetWidth","SetWidth");
    $r.addProperty("WidthPercent",2,rtl.double,"FWidthPercent","SetWidthPercent",{Default: 100});
    $r.addProperty("WidthStyle",2,pas["WEBLib.Controls"].$rtti["TSizeStyle"],"FWidthStyle","SetWidthStyle",{Default: pas["WEBLib.Controls"].TSizeStyle.ssAbsolute});
    $r.addProperty("OnChange",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnChange","FOnChange");
    $r.addProperty("OnClick",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnClick","FOnClick");
    $r.addProperty("OnDblClick",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnDblClick","FOnDblClick");
    $r.addProperty("OnKeyDown",0,pas["WEBLib.Controls"].$rtti["TKeyEvent"],"FOnKeyDown","FOnKeyDown");
    $r.addProperty("OnKeyPress",0,pas["WEBLib.Controls"].$rtti["TKeyPressEvent"],"FOnKeyPress","FOnKeyPress");
    $r.addProperty("OnKeyUp",0,pas["WEBLib.Controls"].$rtti["TKeyEvent"],"FOnKeyUp","FOnKeyUp");
    $r.addProperty("OnMouseDown",0,pas["WEBLib.Controls"].$rtti["TMouseEvent"],"FOnMouseDown","FOnMouseDown");
    $r.addProperty("OnMouseUp",0,pas["WEBLib.Controls"].$rtti["TMouseEvent"],"FOnMouseUp","FOnMouseUp");
    $r.addProperty("OnMouseMove",0,pas["WEBLib.Controls"].$rtti["TMouseMoveEvent"],"FOnMouseMove","FOnMouseMove");
    $r.addProperty("OnMouseLeave",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnMouseLeave","FOnMouseLeave");
    $r.addProperty("OnMouseEnter",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnMouseEnter","FOnMouseEnter");
    $r.addProperty("OnEnter",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnEnter","FOnEnter");
    $r.addProperty("OnExit",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnExit","FOnExit");
    $r.addProperty("OnDragDrop",0,pas["WEBLib.Controls"].$rtti["TDragDropEvent"],"FOnDragDrop","FOnDragDrop");
    $r.addProperty("OnDragOver",0,pas["WEBLib.Controls"].$rtti["TDragOverEvent"],"FOnDragOver","FOnDragOver");
    $r.addProperty("OnEndDrag",0,pas["WEBLib.Controls"].$rtti["TEndDragEvent"],"FonEndDrag","FonEndDrag");
    $r.addProperty("OnStartDrag",0,pas["WEBLib.Controls"].$rtti["TStartDragEvent"],"FOnStartDrag","FOnStartDrag");
    $r.addProperty("OnBtnClick",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnBtnClick","FOnBtnClick");
  });
  $mod.$implcode = function () {
    $impl.btnclearres = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAACXBIWXMAAAsTAAALEwEAmpwYAAAA70lEQVQ4jbWSzQ2CQBCFl5OROgSKgAMmHExUDia2QUSswqg9GK1COfnTjCbagm/Cw2wQFw46yZcM+5jZ+Vml/mQ2iMEcpPTt" + "NoEWyMAdHMCaiH9jMssUvAcn0KvRHXAGu29JMgZ3DBWKdgGzqmCz7PLmAfA1PQAT+q4q2unqCcaq6LM0nz/1QcjkoabnYKgnWIBlpSq59QGeIKpoK1Vs6G0ZD9smkM2kphYClh21bUGGKD07/I4rATKTKX1P1QxRsSTZc9MaryCpE+VxyCORPbs1usfgrWp4jS" + "lLPIINyXmWmIJ1k/5GTJbS/+j5J/YC/YEx2smgMEoAAAAASUVORK5CYII=";
    $impl.btnsearchres = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAACXBIWXMAAAsTAAALEwEAmpwYAAABNUlEQVQ4jZWSPU7DQBCFU5ECiEBU/AgEcmXJtvxbuAo0pOAE1CAaAigViFNBOAMRFengBNCCwgH4XrQrBXntkJGePLsz782" + "Pt9WqMc/z2mma9sEITAzk9xWr400tiqJtEsdJkjzwPfR9f0WQD4bcvyqnqfIY3OpcFMU+hHMIazaH2L1EnJ0QvFJl45/iX8dxvOXIG4LLigCEFwLdLMsO8G/qxiR2pJ24OpiYeS/AZp1AWZarynUJfElgdmaXsZsOXXy7BPSruk3keSMM7BKbjLynyhLZ9h6X" + "bwIidw3k6W9k1KUKmW8vz/MNEt45P+rxhGG4LMw+JHaw4ySbc890MgDPWiz4sU/5T2Uudk3LJ2Y5x6quFzhvD1ZgZMm2sjr6F9kIfARBsC6RhclG4AzypzpZmIz9Aj6Qcv0OcR9YAAAAAElFTkSuQmCC";
    $impl.emptyimgres = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNkYAAAAAYAAjCB0C8AAAAASUVORK5CYII=";
  };
},["WEBLib.Utils","Math"]);
rtl.module("WEBLib.TreeNodes",["System","Classes","Types","SysUtils","Web"],function () {
  "use strict";
  var $mod = this;
  this.$rtti.$Class("TTreeNode");
  this.$rtti.$Class("TTreeNodes");
  rtl.createClass(this,"TDbgList",pas.Classes.TList,function () {
    this.GetItemsEx = function (Index) {
      var Result = null;
      if (Index >= this.GetCount()) {
        throw pas.SysUtils.Exception.$create("Create$1",["Index out of bounds in list read access"]);
      };
      if (Index < this.GetCount()) {
        Result = rtl.getObject(this.Get(Index))}
       else Result = null;
      return Result;
    };
    this.SetItemsEx = function (Index, Value) {
      if (Index >= this.GetCount()) {
        throw pas.SysUtils.Exception.$create("Create$1",["Index out of bounds in list write access"]);
      };
      if (Index < this.GetCount()) this.Put(Index,Value);
    };
    this.AssignList = function (ListA) {
      var I = 0;
      this.Clear();
      for (var $l = 0, $end = ListA.GetCount() - 1; $l <= $end; $l++) {
        I = $l;
        this.Add(ListA.Get(I));
      };
    };
  });
  this.TNodeType = {"0": "ntText", ntText: 0, "1": "ntCheckbox", ntCheckbox: 1, "2": "ntRadioButton", ntRadioButton: 2};
  this.$rtti.$Enum("TNodeType",{minvalue: 0, maxvalue: 2, ordtype: 1, enumtype: this.TNodeType});
  this.$rtti.$Pointer("PNodeInfo",{reftype: this.$rtti["TNodeInfo"]});
  rtl.recNewT(this,"TNodeInfo",function () {
    this.SelectedIndex = 0;
    this.StateIndex = 0;
    this.OverlayIndex = 0;
    this.Data = null;
    this.Count = 0;
    this.Text = "";
    this.NodeType = 0;
    this.Checked = false;
    this.ImageURL = "";
    this.ImageCollapsedURL = "";
    this.URL = "";
    this.Tag = 0;
    this.Hint = "";
    this.IsExpanded = false;
    this.$eq = function (b) {
      return (this.SelectedIndex === b.SelectedIndex) && (this.StateIndex === b.StateIndex) && (this.OverlayIndex === b.OverlayIndex) && (this.Data === b.Data) && (this.Count === b.Count) && (this.Text === b.Text) && (this.NodeType === b.NodeType) && (this.Checked === b.Checked) && (this.ImageURL === b.ImageURL) && (this.ImageCollapsedURL === b.ImageCollapsedURL) && (this.URL === b.URL) && (this.Tag === b.Tag) && (this.Hint === b.Hint) && (this.IsExpanded === b.IsExpanded);
    };
    this.$assign = function (s) {
      this.SelectedIndex = s.SelectedIndex;
      this.StateIndex = s.StateIndex;
      this.OverlayIndex = s.OverlayIndex;
      this.Data = s.Data;
      this.Count = s.Count;
      this.Text = s.Text;
      this.NodeType = s.NodeType;
      this.Checked = s.Checked;
      this.ImageURL = s.ImageURL;
      this.ImageCollapsedURL = s.ImageCollapsedURL;
      this.URL = s.URL;
      this.Tag = s.Tag;
      this.Hint = s.Hint;
      this.IsExpanded = s.IsExpanded;
      return this;
    };
    var $r = $mod.$rtti.$Record("TNodeInfo",{});
    $r.addField("SelectedIndex",rtl.longint);
    $r.addField("StateIndex",rtl.longint);
    $r.addField("OverlayIndex",rtl.longint);
    $r.addField("Data",rtl.pointer);
    $r.addField("Count",rtl.longint);
    $r.addField("Text",rtl.string);
    $r.addField("NodeType",$mod.$rtti["TNodeType"]);
    $r.addField("Checked",rtl.boolean);
    $r.addField("ImageURL",rtl.string);
    $r.addField("ImageCollapsedURL",rtl.string);
    $r.addField("URL",rtl.string);
    $r.addField("Tag",rtl.longint);
    $r.addField("Hint",rtl.string);
    $r.addField("IsExpanded",rtl.boolean);
  });
  rtl.recNewT(this,"TNodeDataInfo",function () {
    this.SelectedIndex = 0;
    this.StateIndex = 0;
    this.OverlayIndex = 0;
    this.Data = null;
    this.Count = 0;
    this.NodeType = 0;
    this.Checked = false;
    this.Tag = 0;
    this.IsExpanded = false;
    this.TextLen = 0;
    this.HintLen = 0;
    this.URLLen = 0;
    this.ImageURLLen = 0;
    this.ImageCollapsedURLLen = 0;
    this.$eq = function (b) {
      return (this.SelectedIndex === b.SelectedIndex) && (this.StateIndex === b.StateIndex) && (this.OverlayIndex === b.OverlayIndex) && (this.Data === b.Data) && (this.Count === b.Count) && (this.NodeType === b.NodeType) && (this.Checked === b.Checked) && (this.Tag === b.Tag) && (this.IsExpanded === b.IsExpanded) && (this.TextLen === b.TextLen) && (this.HintLen === b.HintLen) && (this.URLLen === b.URLLen) && (this.ImageURLLen === b.ImageURLLen) && (this.ImageCollapsedURLLen === b.ImageCollapsedURLLen);
    };
    this.$assign = function (s) {
      this.SelectedIndex = s.SelectedIndex;
      this.StateIndex = s.StateIndex;
      this.OverlayIndex = s.OverlayIndex;
      this.Data = s.Data;
      this.Count = s.Count;
      this.NodeType = s.NodeType;
      this.Checked = s.Checked;
      this.Tag = s.Tag;
      this.IsExpanded = s.IsExpanded;
      this.TextLen = s.TextLen;
      this.HintLen = s.HintLen;
      this.URLLen = s.URLLen;
      this.ImageURLLen = s.ImageURLLen;
      this.ImageCollapsedURLLen = s.ImageCollapsedURLLen;
      return this;
    };
    var $r = $mod.$rtti.$Record("TNodeDataInfo",{});
    $r.addField("SelectedIndex",rtl.longint);
    $r.addField("StateIndex",rtl.longint);
    $r.addField("OverlayIndex",rtl.longint);
    $r.addField("Data",rtl.pointer);
    $r.addField("Count",rtl.longint);
    $r.addField("NodeType",$mod.$rtti["TNodeType"]);
    $r.addField("Checked",rtl.boolean);
    $r.addField("Tag",rtl.longint);
    $r.addField("IsExpanded",rtl.boolean);
    $r.addField("TextLen",rtl.byte);
    $r.addField("HintLen",rtl.byte);
    $r.addField("URLLen",rtl.byte);
    $r.addField("ImageURLLen",rtl.byte);
    $r.addField("ImageCollapsedURLLen",rtl.byte);
  });
  this.$rtti.$ClassRef("TTreeNodeClass",{instancetype: this.$rtti["TTreeNode"]});
  rtl.createClass(this,"TTreeNode",pas.Classes.TPersistent,function () {
    this.$init = function () {
      pas.Classes.TPersistent.$init.call(this);
      this.FOwner = null;
      this.FText = "";
      this.FData = null;
      this.FDeleting = false;
      this.FIsExpanded = false;
      this.FFirstChild = null;
      this.FNextSibling = null;
      this.FPrevSibling = null;
      this.FParentNode = null;
      this.FShowText = false;
      this.FImageCollapsedURL = "";
      this.FImageURL = "";
      this.FNodeType = 0;
      this.FURL = "";
      this.FChecked = false;
      this.FTag = 0;
      this.FHint = "";
      this.FSelected = false;
    };
    this.$final = function () {
      this.FOwner = undefined;
      this.FData = undefined;
      this.FFirstChild = undefined;
      this.FNextSibling = undefined;
      this.FPrevSibling = undefined;
      this.FParentNode = undefined;
      pas.Classes.TPersistent.$final.call(this);
    };
    this.GetLevel = function () {
      var Result = 0;
      var Node = null;
      Result = 0;
      Node = this.GetParent();
      while (Node !== null) {
        Result += 1;
        Node = Node.GetParent();
      };
      return Result;
    };
    this.GetParent = function () {
      var Result = null;
      Result = this.FParentNode;
      return Result;
    };
    this.GetIndex = function () {
      var Result = 0;
      var Node = null;
      Result = -1;
      Node = this;
      while (Node != null) {
        Result += 1;
        Node = Node.GetPrevSibling();
      };
      return Result;
    };
    this.GetItem = function (Index) {
      var Result = null;
      Result = this.GetFirstChild();
      while ((Result !== null) && (Index > 0)) {
        Result = this.GetNextChild(Result);
        Index -= 1;
      };
      if (Result === null) throw pas.SysUtils.Exception.$create("Create$1",["Invalid index"]);
      return Result;
    };
    this.GetCount = function () {
      var Result = 0;
      var Node = null;
      Result = 0;
      Node = this.GetFirstChild();
      while (Node != null) {
        Result += 1;
        Node = Node.GetNextChild(Node);
      };
      return Result;
    };
    this.SetData = function (Value) {
      if (!this.FDeleting && (Value !== this.FData)) {
        this.FData = Value;
      };
    };
    this.SetItem = function (Index, Value) {
      this.GetItem(Index).Assign(Value);
    };
    this.SetText = function (S) {
      if (!this.FDeleting && (S !== this.FText)) {
        this.FText = S;
      };
    };
    this.GetHasChildren = function () {
      var Result = false;
      Result = this.FFirstChild != null;
      return Result;
    };
    this.SetShowText = function (Value) {
      this.FShowText = Value;
    };
    this.SetChecked = function (Value) {
      this.FChecked = Value;
    };
    this.SetImageCollapsedURL = function (Value) {
      this.FImageCollapsedURL = Value;
    };
    this.SetImageURL = function (Value) {
      this.FImageURL = Value;
    };
    this.SetNodeType = function (Value) {
      this.FNodeType = Value;
    };
    this.SetURL = function (Value) {
      this.FURL = Value;
    };
    this.SetTag = function (Value) {
      this.FTag = Value;
    };
    this.SetHint = function (Value) {
      this.FHint = Value;
    };
    this.SetIsExpanded = function (Value) {
      if (this.FIsExpanded !== Value) {
        this.FIsExpanded = Value;
        if (this.FOwner != null) if (this.FOwner.FOnExpandedChange != null) this.FOwner.FOnExpandedChange(this.FOwner,this);
      };
    };
    this.SetSelected = function (Value) {
      if (this.FSelected !== Value) {
        this.FSelected = Value;
        this.FOwner.SelectionChange(this,Value);
      };
    };
    this.GetAbsoluteIndex = function () {
      var Result = 0;
      var Node = null;
      if (this.IsFirstNode()) {
        Result = 0}
       else {
        Result = -1;
        Node = this;
        while (Node !== null) {
          Result += 1;
          Node = Node.GetPrev();
        };
      };
      return Result;
    };
    this.CompareCount = function (CompareMe) {
      var Result = false;
      var Count = 0;
      var Node = null;
      Count = 0;
      Result = false;
      Node = this.GetFirstChild();
      while (Node !== null) {
        Count += 1;
        Node = Node.GetNextChild(Node);
        if (Count > CompareMe) return Result;
      };
      if (Count === CompareMe) Result = true;
      return Result;
    };
    this.IsEqual = function (Node) {
      var Result = false;
      Result = (this.FText === Node.FText) && (this.FData === Node.FData);
      return Result;
    };
    this.Select = function () {
      this.FSelected = true;
    };
    this.UnSelect = function () {
      this.FSelected = false;
    };
    this.IndexOf = function (Value) {
      var Result = 0;
      var Node = null;
      Result = -1;
      Node = this.GetFirstChild();
      while (Node !== null) {
        Result += 1;
        if (Node === Value) break;
        Node = this.GetNextChild(Node);
      };
      if (Node === null) Result = -1;
      return Result;
    };
    this.Create$1 = function (AOwner) {
      pas.System.TObject.Create.call(this);
      this.FOwner = AOwner;
      this.FShowText = true;
      this.FNodeType = $mod.TNodeType.ntText;
      this.FChecked = false;
      this.FIsExpanded = false;
      this.FTag = 0;
      return this;
    };
    this.Destroy = function () {
      var N = null;
      var PN = null;
      var NN = null;
      var i = 0;
      this.FDeleting = true;
      this.DeleteChildren();
      N = this.GetParent();
      if ((((N !== null) && !N.FDeleting) || (N === null)) && !this.FOwner.FDeleting && (this.FOwner != null) && (this.FOwner.FOwner != null) && !(pas.Classes.TComponentStateItem.csDestroying in this.FOwner.FOwner.FComponentState)) {
        PN = this.GetPrevSibling();
        NN = this.GetNextSibling();
        if (!(NN != null)) {
          if (this.IsFirstNode()) {
            this.FOwner.FFirstNode = null}
           else if ((this.GetParent() != null) && this.IsFirstChild()) {
            this.GetParent().FFirstChild = null}
           else {
            if (PN != null) PN.FNextSibling = null;
          };
        } else if (!(PN != null)) {
          if (this.IsFirstNode()) {
            this.FOwner.FFirstNode = NN;
            NN.FPrevSibling = PN;
          } else if ((this.GetParent() != null) && this.IsFirstChild()) this.GetParent().FFirstChild = NN;
        } else {
          PN.FNextSibling = NN;
          NN.FPrevSibling = PN;
        };
      };
      if (!(this.GetParent() != null)) {
        i = this.FOwner.FNodeList.IndexOf(this);
        if (i >= 0) {
          this.FOwner.FNodeList.Delete(i);
        };
      };
      this.SetData(null);
      pas.System.TObject.Destroy.call(this);
    };
    this.AddFirstChild = function (S) {
      var Result = null;
      Result = this.AddFirstChild$1(S,null);
      return Result;
    };
    this.AddFirstChild$1 = function (S, Data) {
      var Result = null;
      if (!(this.FFirstChild != null)) {
        Result = this.FOwner.InsertNode(this,null,true)}
       else Result = this.FOwner.InsertNode(null,this.FFirstChild,true);
      Result.SetText(S);
      Result.SetData(Data);
      return Result;
    };
    this.AddChild = function (S) {
      var Result = null;
      Result = this.AddChild$1(S,null);
      return Result;
    };
    this.AddChild$1 = function (S, Data) {
      var Result = null;
      var N = null;
      N = this.GetLastChild();
      if (N != null) {
        Result = this.FOwner.InsertNode(null,N,false)}
       else Result = this.FOwner.InsertNode(this,null,false);
      Result.SetText(S);
      Result.SetData(Data);
      return Result;
    };
    this.Assign = function (Source) {
      var Node = null;
      if (!this.FDeleting && $mod.TTreeNode.isPrototypeOf(Source)) {
        Node = Source;
        this.SetText(Node.FText);
        this.SetData(Node.FData);
        this.SetShowText(Node.FShowText);
        this.SetNodeType(Node.FNodeType);
        this.SetChecked(Node.FChecked);
        this.SetURL(Node.FURL);
        this.SetHint(Node.FHint);
        this.SetImageURL(Node.FImageURL);
        this.SetImageCollapsedURL(Node.FImageCollapsedURL);
        this.SetTag(Node.FTag);
        this.FIsExpanded = Node.FIsExpanded;
      } else pas.Classes.TPersistent.Assign.call(this,Source);
    };
    this.Expand = function (Recurse) {
      var i = 0;
      this.SetIsExpanded(true);
      if (Recurse) {
        for (var $l = 0, $end = this.GetCount() - 1; $l <= $end; $l++) {
          i = $l;
          this.GetItem(i).Expand(Recurse);
        };
      };
    };
    this.Collapse = function (Recurse) {
      var i = 0;
      this.SetIsExpanded(false);
      if (Recurse) {
        for (var $l = 0, $end = this.GetCount() - 1; $l <= $end; $l++) {
          i = $l;
          this.GetItem(i).Collapse(Recurse);
        };
      };
    };
    this.Delete = function () {
      if (!this.FDeleting) this.Free();
    };
    this.DeleteChildren = function () {
      var ChildList = null;
      var N = null;
      var i = 0;
      ChildList = $mod.TDbgList.$create("Create$1");
      N = this.GetFirstChild();
      if (N !== null) {
        do {
          ChildList.Add(N);
          N = N.GetNextSibling();
        } while (!(N === null));
      };
      for (var $l = ChildList.GetCount() - 1; $l >= 0; $l--) {
        i = $l;
        N = ChildList.GetItemsEx(i);
        N = rtl.freeLoc(N);
        ChildList.GetItemsEx(i).Delete();
      };
      ChildList = rtl.freeLoc(ChildList);
    };
    this.GetFirstChild = function () {
      var Result = null;
      Result = this.FFirstChild;
      return Result;
    };
    this.GetLastChild = function () {
      var Result = null;
      var Node = null;
      Result = this.GetFirstChild();
      if (Result !== null) {
        Node = Result;
        do {
          Result = Node;
          Node = Result.GetNextSibling();
        } while (!(Node === null));
      };
      return Result;
    };
    this.GetNextChild = function (Value) {
      var Result = null;
      if (Value !== null) {
        Result = Value.GetNextSibling()}
       else Result = null;
      return Result;
    };
    this.GetNextSibling = function () {
      var Result = null;
      Result = this.FNextSibling;
      return Result;
    };
    this.GetPrevChild = function (Value) {
      var Result = null;
      if (Value !== null) {
        Result = Value.GetPrevSibling()}
       else Result = null;
      return Result;
    };
    this.GetPrevSibling = function () {
      var Result = null;
      Result = this.FPrevSibling;
      return Result;
    };
    this.HasAsParent = function (Value) {
      var Result = false;
      if (Value !== null) {
        if (this.GetParent() === null) {
          Result = false}
         else if (this.GetParent() === Value) {
          Result = true}
         else Result = this.GetParent().HasAsParent(Value);
      } else Result = true;
      return Result;
    };
    this.IsFirstNode = function () {
      var Result = false;
      Result = this === this.FOwner.FFirstNode;
      return Result;
    };
    this.IsFirstChild = function () {
      var Result = false;
      Result = this.IsFirstNode() || ((this.GetParent() != null) && (this.GetParent().GetFirstChild() === this));
      return Result;
    };
    this.GetNext = function () {
      var Result = null;
      var p = null;
      Result = null;
      if (this.GetCount() > 0) {
        Result = this.GetItem(0)}
       else {
        Result = this.GetNextSibling();
        if (!(Result != null)) {
          p = this;
          do {
            p = p.GetParent();
            if (p != null) Result = p.GetNextSibling();
          } while (!(!(p != null) || (Result != null)));
        };
      };
      return Result;
    };
    this.GetPrev = function () {
      var Result = null;
      var cn = null;
      Result = this.GetPrevSibling();
      if (Result != null) {
        cn = Result;
        do {
          if (cn.GetCount() > 0) {
            Result = cn.GetItem(cn.GetCount() - 1);
            cn = Result;
          };
        } while (!(cn.GetCount() === 0));
      } else Result = this.GetParent();
      return Result;
    };
    var $r = this.$rtti;
    $r.addMethod("Create$1",2,[["AOwner",$mod.$rtti["TTreeNodes"]]]);
  });
  this.$rtti.$MethodVar("TSelectNodeEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["ANode",this.$rtti["TTreeNode"]],["IsSelected",rtl.boolean]]), methodkind: 0});
  this.$rtti.$MethodVar("TNodeEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["ANode",this.$rtti["TTreeNode"]]]), methodkind: 0});
  rtl.createClass(this,"TTreeNodes",pas.Classes.TPersistent,function () {
    this.$init = function () {
      pas.Classes.TPersistent.$init.call(this);
      this.FOwner = null;
      this.FFirstNode = null;
      this.FNodeList = null;
      this.FDeleting = false;
      this.FReading = false;
      this.FOnChange = null;
      this.FOnExpandedChange = null;
      this.FOnSelectionChange = null;
    };
    this.$final = function () {
      this.FOwner = undefined;
      this.FFirstNode = undefined;
      this.FNodeList = undefined;
      this.FOnChange = undefined;
      this.FOnExpandedChange = undefined;
      this.FOnSelectionChange = undefined;
      pas.Classes.TPersistent.$final.call(this);
    };
    this.GetNodeFromIndex = function (Index) {
      var Result = null;
      var i = 0;
      var idx = 0;
      var child = null;
      Result = null;
      idx = 0;
      for (var $l = 0, $end = this.FNodeList.GetCount() - 1; $l <= $end; $l++) {
        i = $l;
        child = this.FNodeList.GetItemsEx(i);
        do {
          if (Index === idx) {
            Result = child;
            return Result;
          };
          child = child.GetNext();
          idx += 1;
        } while (!(child === null));
      };
      return Result;
    };
    this.GetSiblingCount = function () {
      var Result = 0;
      Result = this.FNodeList.GetCount();
      return Result;
    };
    this.GetSiblingFromIndex = function (Index) {
      var Result = null;
      Result = null;
      if ((Index >= 0) && (Index < this.FNodeList.GetCount())) Result = this.FNodeList.GetItemsEx(Index);
      return Result;
    };
    this.SetItem = function (Index, Value) {
      if ((Index >= 0) && (Index < this.FNodeList.GetCount())) this.GetNodeFromIndex(Index).Assign(Value);
    };
    this.GetCount = function () {
      var $Self = this;
      var Result = 0;
      var i = 0;
      function GetChildCount(tn) {
        var Result = 0;
        var j = 0;
        Result = tn.GetCount();
        for (var $l = 0, $end = tn.GetCount() - 1; $l <= $end; $l++) {
          j = $l;
          Result = Result + GetChildCount(tn.GetItem(j));
        };
        return Result;
      };
      Result = this.FNodeList.GetCount();
      for (var $l = 0, $end = this.FNodeList.GetCount() - 1; $l <= $end; $l++) {
        i = $l;
        Result = Result + GetChildCount(this.FNodeList.GetItemsEx(i));
      };
      return Result;
    };
    this.InsertNode = function (ParentNode, DesNode, InsertBefore) {
      var Result = null;
      var N = null;
      Result = null;
      if (!(DesNode != null)) {
        if (ParentNode != null) {
          N = ParentNode.GetLastChild();
          if (N != null) {
            this.InsertNode(null,N,false);
            return Result;
          } else {
            Result = this.CreateNode();
            ParentNode.FFirstChild = Result;
            Result.FParentNode = ParentNode;
            return Result;
          };
        } else {
          if (!(this.FFirstNode != null)) {
            Result = this.CreateNode();
            this.FFirstNode = Result;
            this.FNodeList.Add(Result);
          };
        };
      } else {
        Result = this.CreateNode();
        if (InsertBefore) {
          if (this.IsVeryFirstNode(DesNode)) {
            this.FFirstNode = Result;
            Result.FNextSibling = DesNode;
            DesNode.FPrevSibling = Result;
            this.FNodeList.Insert(0,Result);
          } else {
            if (DesNode.IsFirstChild() && (DesNode.GetParent() != null)) {
              DesNode.GetParent().FFirstChild = Result;
              Result.FNextSibling = DesNode;
              DesNode.FPrevSibling = Result;
              Result.FParentNode = DesNode.GetParent();
            } else {
              Result.FPrevSibling = DesNode.FPrevSibling;
              Result.FNextSibling = DesNode;
              DesNode.FPrevSibling = Result;
              Result.FParentNode = DesNode.GetParent();
              if (Result.FPrevSibling != null) Result.FPrevSibling.FNextSibling = Result;
            };
          };
        } else {
          Result.FNextSibling = DesNode.FNextSibling;
          Result.FPrevSibling = DesNode;
          DesNode.FNextSibling = Result;
          if (Result.FNextSibling != null) Result.FNextSibling.FPrevSibling = Result;
          Result.FParentNode = DesNode.GetParent();
          if (!(DesNode.GetParent() != null)) this.FNodeList.Add(Result);
        };
      };
      return Result;
    };
    this.IsVeryFirstNode = function (Node) {
      var Result = false;
      Result = (Node != null) && (Node === this.FFirstNode);
      return Result;
    };
    this.SelectionChange = function (Node, IsSelected) {
      if (this.FOnSelectionChange != null) this.FOnSelectionChange(this,Node,IsSelected);
    };
    this.CreateNode = function () {
      var Result = null;
      var LClass = null;
      LClass = $mod.TTreeNode;
      Result = LClass.$create("Create$1",[this]);
      return Result;
    };
    this.Create$1 = function (AOwner) {
      pas.System.TObject.Create.call(this);
      this.FOwner = AOwner;
      this.FFirstNode = null;
      this.FNodeList = $mod.TDbgList.$create("Create$1");
      return this;
    };
    this.Destroy = function () {
      this.FDeleting = true;
      this.Clear();
      rtl.free(this,"FNodeList");
      pas.System.TObject.Destroy.call(this);
    };
    this.AddFirst = function (S) {
      var Result = null;
      Result = this.AddFirst$1(null,S);
      return Result;
    };
    this.AddFirst$1 = function (Data, S) {
      var Result = null;
      if (!(this.FFirstNode != null)) {
        Result = this.InsertNode(null,null,true);
      } else {
        Result = this.InsertNode(null,this.FFirstNode,true);
      };
      Result.SetText(S);
      Result.SetData(Data);
      return Result;
    };
    this.Add = function (Sibling, S) {
      var Result = null;
      Result = this.Add$1(Sibling,S,null);
      return Result;
    };
    this.Add$1 = function (Sibling, S, Data) {
      var Result = null;
      Result = this.InsertNode(Sibling,this.GetLastNode(),false);
      Result.SetText(S);
      Result.SetData(Data);
      return Result;
    };
    this.Add$2 = function (S) {
      var Result = null;
      Result = this.Add$3(S,null);
      return Result;
    };
    this.Add$3 = function (S, Data) {
      var Result = null;
      Result = this.InsertNode(null,this.GetLastNode(),false);
      Result.SetText(S);
      Result.SetData(Data);
      return Result;
    };
    this.AddChild = function (Parent, S) {
      var Result = null;
      if (Parent === null) {
        Result = this.Add$3(S,null)}
       else Result = this.AddChild$1(Parent,S,null);
      return Result;
    };
    this.AddChild$1 = function (Parent, S, Data) {
      var Result = null;
      Result = null;
      if (Parent != null) {
        Result = Parent.AddChild$1(S,Data)}
       else Result = this.Add$3(S,Data);
      return Result;
    };
    this.AddChildFirst = function (Parent, S) {
      var Result = null;
      Result = this.AddChildFirst$1(Parent,S,null);
      return Result;
    };
    this.AddChildFirst$1 = function (Parent, S, Data) {
      var Result = null;
      Result = null;
      if (Parent != null) Result = Parent.AddFirstChild$1(S,Data);
      return Result;
    };
    this.Assign = function (Source) {
      if ($mod.TTreeNodes.isPrototypeOf(Source)) {
        this.Clear();
      } else pas.Classes.TPersistent.Assign.call(this,Source);
    };
    this.BeginUpdate = function () {
    };
    this.EndUpdate = function () {
    };
    this.Clear = function () {
      var i = 0;
      for (var $l = this.FNodeList.GetCount() - 1; $l >= 0; $l--) {
        i = $l;
        this.FNodeList.GetItemsEx(i).Delete();
      };
      this.FNodeList.Clear();
    };
    this.Delete = function (Node) {
      Node.Delete();
    };
    this.GetFirstNode = function () {
      var Result = null;
      Result = this.FFirstNode;
      return Result;
    };
    this.GetLastNode = function () {
      var Result = null;
      Result = this.FFirstNode;
      if (Result != null) while (Result.GetNextSibling() !== null) Result = Result.GetNextSibling();
      return Result;
    };
    this.Insert = function (Sibling, S) {
      var Result = null;
      Result = this.InsertObject(Sibling,S,null);
      return Result;
    };
    this.InsertObject = function (Sibling, S, Data) {
      var Result = null;
      Result = this.InsertNode(null,Sibling,true);
      if (Result != null) {
        Result.SetText(S);
        Result.SetData(Data);
      };
      return Result;
    };
    this.Changed = function () {
      if (this.FOnChange != null) this.FOnChange(this);
    };
    var $r = this.$rtti;
    $r.addMethod("Create$1",2,[["AOwner",pas.Classes.$rtti["TComponent"]]]);
  });
},["Math"]);
rtl.module("WEBLib.Buttons",["System","Classes","SysUtils","WEBLib.Controls","Web","WEBLib.Graphics","WEBLib.StdCtrls","WEBLib.ComCtrls","WEBLib.ExtCtrls","WEBLib.Forms","WEBLib.Menus"],function () {
  "use strict";
  var $mod = this;
  var $impl = $mod.$impl;
  this.TButtonLayout = {"0": "blGlyphLeft", blGlyphLeft: 0, "1": "blGlyphRight", blGlyphRight: 1, "2": "blGlyphTop", blGlyphTop: 2, "3": "blGlyphBottom", blGlyphBottom: 3};
  this.$rtti.$Enum("TButtonLayout",{minvalue: 0, maxvalue: 3, ordtype: 1, enumtype: this.TButtonLayout});
  rtl.createClass(this,"TCustomSpeedButton",pas["WEBLib.Menus"].TWebCustomControl,function () {
    this.$init = function () {
      pas["WEBLib.Menus"].TWebCustomControl.$init.call(this);
      this.FMaterialGlyph = "";
      this.FColor$1 = 0;
      this.FIntColor = 0;
      this.FDown = false;
      this.FFlat = false;
      this.FGroupIndex = 0;
      this.FAllowAllUp = false;
      this.FGlyph = null;
      this.FLayout = 0;
      this.FGlyphURL = "";
      this.FMaterialGlyphSize = 0;
      this.FMaterialGlyphColor = 0;
      this.FMaterialGlyphType = 0;
      this.FGlyphSize = 0;
    };
    this.$final = function () {
      this.FGlyph = undefined;
      pas["WEBLib.Menus"].TWebCustomControl.$final.call(this);
    };
    this.SetMaterialGlyph = function (AValue) {
      if (this.FMaterialGlyph !== AValue) {
        this.FMaterialGlyph = AValue;
        this.UpdateElement();
      };
    };
    this.SetColorEx = function (AValue) {
      if (this.FColor$1 !== AValue) {
        this.FColor$1 = AValue;
        this.FIntColor = AValue;
        this.UpdateElement();
      };
    };
    this.SetIntColor = function (AValue) {
      if (this.FIntColor !== AValue) {
        this.FIntColor = AValue;
        this.UpdateElement();
      };
    };
    this.SetGroupIndex = function (AValue) {
      this.FGroupIndex = AValue;
    };
    this.SetDown = function (AValue) {
      if (this.FDown !== AValue) {
        this.FDown = AValue;
        this.UpdateElement();
      };
    };
    this.SetFlat = function (Value) {
      if (this.FFlat !== Value) {
        this.FFlat = Value;
        this.RecreateElement();
      };
    };
    this.SetGlyph = function (Value) {
      this.FGlyph.Assign(Value);
      this.UpdateElement();
    };
    this.SetGlyphURL = function (Value) {
      if (this.FGlyphURL !== Value) {
        this.FGlyphURL = Value;
        this.RecreateElement();
      };
    };
    this.SetMaterialGlyphSize = function (Value) {
      if ((Value > 0) && (Value < 100)) {
        this.FMaterialGlyphSize = Value;
        this.UpdateElement();
      };
    };
    this.SetMaterialGyphColor = function (Value) {
      if (this.FMaterialGlyphColor !== Value) {
        this.FMaterialGlyphColor = Value;
        this.UpdateElement();
      };
    };
    this.SetMaterialGlyphType = function (Value) {
      if (this.FMaterialGlyphType !== Value) {
        this.FMaterialGlyphType = Value;
        this.UpdateElement();
      };
    };
    this.SetGlyphSize = function (Value) {
      if (this.FGlyphSize !== Value) {
        this.FGlyphSize = Value;
        this.UpdateElement();
      };
    };
    this.SetEnabled = function (Value) {
      pas["WEBLib.Controls"].TControl.SetEnabled.apply(this,arguments);
      this.UpdateElement();
    };
    this.SetCaption = function (AValue) {
      if (this.FCaption !== AValue) {
        pas["WEBLib.Controls"].TCustomControl.SetCaption.call(this,AValue);
        this.UpdateElement();
      };
    };
    this.CreateElement = function () {
      var Result = null;
      if (this.FFlat) {
        Result = document.createElement("SPAN")}
       else {
        Result = document.createElement("BUTTON");
        Result.setAttribute("type","BUTTON");
      };
      return Result;
    };
    this.UpdateElement = function () {
      var s = "";
      var inactive = "";
      var noptr = "";
      var icn = "";
      var imgsrc = "";
      var gs = "";
      var matclr = "";
      var cap = "";
      var acc = "";
      pas["WEBLib.Controls"].TControl.UpdateElement.call(this);
      if (!this.IsUpdating() && (this.FMaterialGlyph !== "")) this.AddControlLink("googlematerial","https://fonts.googleapis.com/icon?family=Material+Icons");
      if (this.GetElementHandle() != null) {
        this.GetElementHandle().style.setProperty("vertical-align","middle");
        this.GetElementHandle().style.setProperty("overflow","hidden");
        this.GetElementHandle().style.setProperty("padding","0px");
        this.GetElementHandle().style.setProperty("text-align","center");
        this.GetElementHandle().style.setProperty("min-width","32px");
        if (this.FFlat && this.FVisible) {
          this.GetElementHandle().style.setProperty("display","flex");
          this.GetElementHandle().style.setProperty("justify-content","center");
        };
        s = "";
        inactive = "";
        noptr = "";
        if (!this.FEnabled) inactive = " md-light md-inactive";
        noptr = "pointer-events:none";
        if (this.FMaterialGlyph !== "") {
          matclr = "";
          if (this.FMaterialGlyphColor !== -1) {
            if (this.FEnabled) {
              matclr = ";color:" + pas["WEBLib.Graphics"].ColorToHTML(this.FMaterialGlyphColor)}
             else matclr = ";color:" + pas["WEBLib.Graphics"].ColorToHTML(0xA0A0A0);
          };
          icn = '<i class="' + pas["WEBLib.Controls"].GetMaterialClass(this.FMaterialGlyphType) + inactive + '" style="' + noptr + ";font-size:" + pas.SysUtils.IntToStr(this.FMaterialGlyphSize) + "px" + matclr + '">' + this.FMaterialGlyph + "</i>";
        };
        if (this.FGlyph.GetData() !== "") {
          imgsrc = "data:image/jpeg;base64," + pas["WEBLib.WebTools"].HexImageDecodeAsBase64(this.FGlyph.GetData())}
         else if (this.FGlyph.FFilename !== "") {
          imgsrc = this.FGlyph.FFilename}
         else if (this.FGlyphURL !== "") imgsrc = this.FGlyphURL;
        gs = "";
        if (this.FGlyphSize !== 0) gs = "width:" + pas.SysUtils.TIntegerHelper.ToString$1.call({p: this, get: function () {
            return this.p.FGlyphSize;
          }, set: function (v) {
            this.p.FGlyphSize = v;
          }}) + "px";
        if (imgsrc !== "") icn = '<img style="' + noptr + ";vertical-align:middle;" + gs + '" src="' + imgsrc + '">';
        if ((this.GetElementHandle().childElementCount === 0) || !this.GetIsLinked()) cap = pas["WEBLib.WebTools"].ProcessAccelerator(this.FCaption,{get: function () {
            return acc;
          }, set: function (v) {
            acc = v;
          }});
        if (acc !== "") this.GetElementHandle().setAttribute("accesskey",acc);
        if (this.FTabStop) {
          this.GetElementHandle().setAttribute("tabindex",pas.SysUtils.IntToStr(this.FTabOrder))}
         else this.GetElementHandle().setAttribute("tabindex","-1");
        var $tmp = this.FLayout;
        if ($tmp === $mod.TButtonLayout.blGlyphLeft) {
          s = '<table border="0" align="center" style="' + noptr + '"><tr><td style="border:none">' + icn + '</td><td style="border:none">' + cap + "</td></tr></table>"}
         else if ($tmp === $mod.TButtonLayout.blGlyphRight) {
          s = '<table border="0" align="center" style="' + noptr + '"><tr><td style="border:none">' + cap + '</td><td style="border:none">' + icn + "</td></tr></table>"}
         else if ($tmp === $mod.TButtonLayout.blGlyphTop) {
          s = '<table border="0" align="center" style="' + noptr + '"><tr><td style="border:none">' + icn + '</td></tr><tr><td style="border:none">' + cap + "</td></tr></table>"}
         else if ($tmp === $mod.TButtonLayout.blGlyphBottom) s = '<table border="0" align="center" style="' + noptr + '"><tr><td style="border:none">' + cap + '</td></tr><tr><td style="border:none">' + icn + "</td></tr></table>";
        this.GetElementHandle().innerHTML = s;
        pas["WEBLib.Controls"].SetHTMLElementFont(this.GetElementHandle().firstChild,this.FFont,!((this.FElementClassName === "") && (this.FElementFont === pas["WEBLib.Controls"].TElementFont.efProperty)));
        if (!this.IsEnabled()) {
          this.GetElementHandle().style.removeProperty("color")}
         else if ((this.FElementFont === pas["WEBLib.Controls"].TElementFont.efProperty) && (this.FElementClassName === "")) {
          this.GetElementHandle().style.setProperty("color",pas["WEBLib.Graphics"].ColorToHTML(this.FFont.FColor));
          if (pas.Classes.TComponentStateItem.csDesigning in this.FComponentState) this.GetElementHandle().firstChild.style.setProperty("color",pas["WEBLib.Graphics"].ColorToHTML(this.FFont.FColor));
        };
      };
    };
    this.UpdateElementVisual = function () {
      var clr = 0;
      pas["WEBLib.Controls"].TCustomControl.UpdateElementVisual.call(this);
      if (this.GetElementHandle() != null) {
        if (this.FDown) {
          clr = 8421504}
         else clr = this.FIntColor;
        if ((clr !== -1) && (this.FElementClassName === "")) {
          this.GetElementHandle().style.setProperty("background-color",pas["WEBLib.Graphics"].ColorToHTML(clr))}
         else this.GetElementHandle().style.setProperty("background-color","");
        if (this.GetElementHandle().firstChild != null) pas["WEBLib.Controls"].SetHTMLElementFont(this.GetElementHandle().firstChild,this.FFont,!((this.FElementClassName === "") && (this.FElementFont === pas["WEBLib.Controls"].TElementFont.efProperty)));
        if (!this.IsEnabled()) {
          this.GetElementHandle().style.removeProperty("color")}
         else if ((this.FElementFont === pas["WEBLib.Controls"].TElementFont.efProperty) && (this.FElementClassName === "")) {
          this.GetElementHandle().style.setProperty("color",pas["WEBLib.Graphics"].ColorToHTML(this.FFont.FColor));
          if ((pas.Classes.TComponentStateItem.csDesigning in this.FComponentState) && (this.GetElementHandle().firstChild != null)) this.GetElementHandle().firstChild.style.setProperty("color",pas["WEBLib.Graphics"].ColorToHTML(this.FFont.FColor));
        };
      };
    };
    this.UpdateGroup = function () {
      var i = 0;
      if (this.FParent != null) {
        for (var $l = 0, $end = this.FParent.GetControlsCount() - 1; $l <= $end; $l++) {
          i = $l;
          if ((this.FParent.GetControls(i) !== this) && $mod.TSpeedButton.isPrototypeOf(this.FParent.GetControls(i)) && (rtl.as(this.FParent.GetControls(i),$mod.TSpeedButton).FGroupIndex === this.FGroupIndex)) rtl.as(this.FParent.GetControls(i),$mod.TSpeedButton).SetDown(false);
        };
      };
    };
    this.DoMouseLeave = function () {
      var frm = null;
      pas["WEBLib.Controls"].TControl.DoMouseLeave.call(this);
      frm = pas["WEBLib.Forms"].GetParentForm(this);
      if ((frm != null) && (frm.FCSSLibrary === pas["WEBLib.Controls"].TCSSLibrary.cssBootstrap) && this.FShowHint && (this.FHint !== "")) return;
      this.SetIntColor(this.FColor$1);
    };
    this.DoMouseEnter = function () {
      var frm = null;
      pas["WEBLib.Controls"].TControl.DoMouseEnter.call(this);
      frm = pas["WEBLib.Forms"].GetParentForm(this);
      if ((frm != null) && (frm.FCSSLibrary === pas["WEBLib.Controls"].TCSSLibrary.cssBootstrap) && this.FShowHint && (this.FHint !== "")) return;
      if (this.FEnabled) this.SetIntColor(12632256);
    };
    this.MouseUp = function (Button, Shift, X, Y) {
      pas["WEBLib.Controls"].TControl.MouseUp.apply(this,arguments);
      if (this.FEnabled) this.SetIntColor(12632256);
    };
    this.MouseDown = function (Button, Shift, X, Y) {
      pas["WEBLib.Controls"].TControl.MouseDown.apply(this,arguments);
      if (!this.FEnabled) return;
      this.SetIntColor(8421504);
      if (this.FGroupIndex > 0) {
        if (this.FDown && this.FAllowAllUp) {
          this.SetDown(false)}
         else {
          this.SetDown(true);
          this.UpdateGroup();
        };
      };
    };
    this.GlyphChanged = function (Sender) {
      this.UpdateElement();
    };
    this.InitCSSLibrary = function (ALibrary) {
      if (ALibrary === pas["WEBLib.Controls"].TCSSLibrary.cssBootstrap) {
        this.SetElementClassName("btn btn-light");
        this.SetElementFont(pas["WEBLib.Controls"].TElementFont.efCSS);
        this.SetHeightStyle(pas["WEBLib.Controls"].TSizeStyle.ssAuto);
      };
    };
    this.Destroy = function () {
      rtl.free(this,"FGlyph");
      pas["WEBLib.Controls"].TCustomControl.Destroy.call(this);
    };
    this.CreateInitialize = function () {
      pas["WEBLib.Controls"].TCustomControl.CreateInitialize.call(this);
      this.FColor$1 = -1;
      this.FIntColor = -1;
      this.FGroupIndex = 0;
      this.FDown = false;
      this.FFlat = false;
      this.FGlyph = pas["WEBLib.Graphics"].TURLPicture.$create("Create");
      this.FGlyph.FOnChange = rtl.createCallback(this,"GlyphChanged");
      this.FGlyph.FOnDataChange = rtl.createCallback(this,"GlyphChanged");
      this.FLayout = $mod.TButtonLayout.blGlyphLeft;
      this.FMaterialGlyphSize = 18;
      this.FMaterialGlyphColor = -1;
      this.FMaterialGlyphType = pas["WEBLib.Controls"].TMaterialGlyphType.mgNormal;
    };
    this.CanFocus = function () {
      var Result = false;
      Result = false;
      return Result;
    };
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
  });
  rtl.createClass(this,"TSpeedButton",this.TCustomSpeedButton,function () {
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
    var $r = this.$rtti;
    $r.addProperty("Align",2,pas["WEBLib.Controls"].$rtti["TAlign"],"FAlign","SetAlign",{Default: pas["WEBLib.Controls"].TAlign.alNone});
    $r.addProperty("AlignWithMargins",2,rtl.boolean,"FAlignWithMargins","SetAlignWithMargins",{Default: false});
    $r.addProperty("Anchors",2,pas["WEBLib.Controls"].$rtti["TAnchors"],"FAnchors","SetAnchors",{Default: rtl.createSet(pas["WEBLib.Controls"].TAnchorKind.akLeft,pas["WEBLib.Controls"].TAnchorKind.akTop)});
    $r.addProperty("AllowAllUp",0,rtl.boolean,"FAllowAllUp","FAllowAllUp");
    $r.addProperty("Caption",2,rtl.string,"FCaption","SetCaption");
    $r.addProperty("Color",2,pas["WEBLib.Graphics"].$rtti["TColor"],"FColor$1","SetColorEx",{Default: -1});
    $r.addProperty("Down",2,rtl.boolean,"FDown","SetDown");
    $r.addProperty("ElementClassName",2,pas["WEBLib.Controls"].$rtti["TElementClassName"],"FElementClassName","SetElementClassName");
    $r.addProperty("ElementID",3,pas["WEBLib.Controls"].$rtti["TElementID"],"GetID","SetID");
    $r.addProperty("ElementFont",2,pas["WEBLib.Controls"].$rtti["TElementFont"],"FElementFont","SetElementFont",{Default: pas["WEBLib.Controls"].TElementFont.efProperty});
    $r.addProperty("ElementPosition",2,pas["WEBLib.Controls"].$rtti["TElementPosition"],"FElementPosition","SetElementPosition",{Default: pas["WEBLib.Controls"].TElementPosition.epAbsolute});
    $r.addProperty("Enabled",2,rtl.boolean,"FEnabled","SetEnabled",{Default: true});
    $r.addProperty("Flat",2,rtl.boolean,"FFlat","SetFlat",{Default: false});
    $r.addProperty("Font",2,pas["WEBLib.Graphics"].$rtti["TFont"],"FFont","SetFont");
    $r.addProperty("Glyph",2,pas["WEBLib.Graphics"].$rtti["TURLPicture"],"FGlyph","SetGlyph");
    $r.addProperty("GlyphURL",2,rtl.string,"FGlyphURL","SetGlyphURL");
    $r.addProperty("GlyphSize",2,rtl.longint,"FGlyphSize","SetGlyphSize",{Default: 0});
    $r.addProperty("GroupIndex",2,rtl.longint,"FGroupIndex","SetGroupIndex");
    $r.addProperty("Height",3,rtl.longint,"GetHeight","SetHeight");
    $r.addProperty("HeightPercent",2,rtl.double,"FHeightPercent","SetHeightPercent",{Default: 100});
    $r.addProperty("HeightStyle",2,pas["WEBLib.Controls"].$rtti["TSizeStyle"],"FHeightStyle","SetHeightStyle",{Default: pas["WEBLib.Controls"].TSizeStyle.ssAbsolute});
    $r.addProperty("Hint",2,rtl.string,"FHint","SetHint");
    $r.addProperty("Layout",0,$mod.$rtti["TButtonLayout"],"FLayout","FLayout",{Default: $mod.TButtonLayout.blGlyphLeft});
    $r.addProperty("Margins",2,pas["WEBLib.Controls"].$rtti["TMargins"],"FMargins","SetMargins");
    $r.addProperty("MaterialGlyph",2,rtl.string,"FMaterialGlyph","SetMaterialGlyph");
    $r.addProperty("MaterialGlyphColor",2,pas["WEBLib.Graphics"].$rtti["TColor"],"FMaterialGlyphColor","SetMaterialGyphColor",{Default: -1});
    $r.addProperty("MaterialGlyphSize",2,rtl.longint,"FMaterialGlyphSize","SetMaterialGlyphSize",{Default: 18});
    $r.addProperty("MaterialGlyphType",2,pas["WEBLib.Controls"].$rtti["TMaterialGlyphType"],"FMaterialGlyphType","SetMaterialGlyphType",{Default: pas["WEBLib.Controls"].TMaterialGlyphType.mgNormal});
    $r.addProperty("ParentFont",2,rtl.boolean,"FParentFont","SetParentFont",{Default: true});
    $r.addProperty("PopupMenu",0,pas["WEBLib.Menus"].$rtti["TPopupMenu"],"FPopupMenu","FPopupMenu");
    $r.addProperty("ShowHint",2,rtl.boolean,"FShowHint","SetShowHint",{Default: false});
    $r.addProperty("TabOrder",2,rtl.longint,"FTabOrder","SetTabOrder");
    $r.addProperty("TabStop",2,rtl.boolean,"FTabStop","SetTabStop",{Default: true});
    $r.addProperty("Visible",2,rtl.boolean,"FVisible","SetVisible",{Default: true});
    $r.addProperty("Width",3,rtl.longint,"GetWidth","SetWidth");
    $r.addProperty("WidthPercent",2,rtl.double,"FWidthPercent","SetWidthPercent",{Default: 100});
    $r.addProperty("WidthStyle",2,pas["WEBLib.Controls"].$rtti["TSizeStyle"],"FWidthStyle","SetWidthStyle",{Default: pas["WEBLib.Controls"].TSizeStyle.ssAbsolute});
    $r.addProperty("OnClick",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnClick","FOnClick");
    $r.addProperty("OnDblClick",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnDblClick","FOnDblClick");
    $r.addProperty("OnKeyDown",0,pas["WEBLib.Controls"].$rtti["TKeyEvent"],"FOnKeyDown","FOnKeyDown");
    $r.addProperty("OnKeyPress",0,pas["WEBLib.Controls"].$rtti["TKeyPressEvent"],"FOnKeyPress","FOnKeyPress");
    $r.addProperty("OnKeyUp",0,pas["WEBLib.Controls"].$rtti["TKeyEvent"],"FOnKeyUp","FOnKeyUp");
    $r.addProperty("OnMouseDown",0,pas["WEBLib.Controls"].$rtti["TMouseEvent"],"FOnMouseDown","FOnMouseDown");
    $r.addProperty("OnMouseUp",0,pas["WEBLib.Controls"].$rtti["TMouseEvent"],"FOnMouseUp","FOnMouseUp");
    $r.addProperty("OnMouseMove",0,pas["WEBLib.Controls"].$rtti["TMouseMoveEvent"],"FOnMouseMove","FOnMouseMove");
    $r.addProperty("OnMouseLeave",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnMouseLeave","FOnMouseLeave");
    $r.addProperty("OnMouseEnter",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnMouseEnter","FOnMouseEnter");
    $r.addProperty("OnEnter",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnEnter","FOnEnter");
    $r.addProperty("OnExit",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnExit","FOnExit");
  });
  rtl.createClass(this,"TWebSpeedButton",this.TSpeedButton,function () {
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
  });
  rtl.createClass(this,"TCustomBitBtn",pas["WEBLib.Controls"].TCustomControl,function () {
    this.$init = function () {
      pas["WEBLib.Controls"].TCustomControl.$init.call(this);
      this.FMaterialGlyph = "";
      this.FLayout = 0;
      this.FFlat = false;
      this.FGlyph = null;
      this.FColor$1 = 0;
      this.FIntColor = 0;
      this.FAlignment = 0;
      this.FGlyphURL = "";
      this.FMaterialGlyphSize = 0;
      this.FMaterialGlyphColor = 0;
      this.FMaterialGlyphType = 0;
      this.FGlyphSize = 0;
      this.FModalResult = 0;
      this.FDefault = false;
      this.FCancel = false;
    };
    this.$final = function () {
      this.FGlyph = undefined;
      pas["WEBLib.Controls"].TCustomControl.$final.call(this);
    };
    this.SetFlat = function (Value) {
      if (this.FFlat !== Value) {
        this.FFlat = Value;
        this.RecreateElement();
      };
    };
    this.SetGlyph = function (Value) {
      this.FGlyph.Assign(Value);
      this.UpdateElement();
    };
    this.SetLayout = function (Value) {
      if (this.FLayout !== Value) {
        this.FLayout = Value;
        this.UpdateElement();
      };
    };
    this.SetMaterialGlyph = function (Value) {
      if (this.FMaterialGlyph !== Value) {
        this.FMaterialGlyph = Value;
        this.UpdateElement();
      };
    };
    this.SetColorEx = function (Value) {
      if (this.FColor$1 !== Value) {
        this.FColor$1 = Value;
        this.SetColor(Value);
        this.UpdateElement();
      };
    };
    this.SetIntColor = function (Value) {
      this.FIntColor = Value;
    };
    this.SetAlignment = function (Value) {
      if (this.FAlignment !== Value) {
        this.FAlignment = Value;
        this.UpdateElement();
      };
    };
    this.SetGlyphURL = function (Value) {
      if (this.FGlyphURL !== Value) {
        this.FGlyphURL = Value;
        this.UpdateElement();
      };
    };
    this.SetMaterialGlyphSize = function (Value) {
      if ((Value > 0) && (Value < 100)) {
        this.FMaterialGlyphSize = Value;
        this.UpdateElement();
      };
    };
    this.SetMaterialGyphColor = function (Value) {
      if (this.FMaterialGlyphColor !== Value) {
        this.FMaterialGlyphColor = Value;
        this.UpdateElement();
      };
    };
    this.SetMaterialGlyphType = function (Value) {
      if (this.FMaterialGlyphType !== Value) {
        this.FMaterialGlyphType = Value;
        this.UpdateElement();
      };
    };
    this.SetGlyphSize = function (Value) {
      if (this.FGlyphSize !== Value) {
        this.FGlyphSize = Value;
        this.UpdateElement();
      };
    };
    this.SetCaption = function (AValue) {
      if (this.FCaption !== AValue) {
        pas["WEBLib.Controls"].TCustomControl.SetCaption.call(this,AValue);
        this.UpdateElement();
      };
    };
    this.CreateElement = function () {
      var Result = null;
      if (this.FFlat) {
        Result = document.createElement("SPAN")}
       else {
        Result = document.createElement("BUTTON");
        Result.setAttribute("type","BUTTON");
      };
      return Result;
    };
    this.UpdateElement = function () {
      var s = "";
      var inactive = "";
      var noptr = "";
      var matgl = "";
      var imgsrc = "";
      var matclr = "";
      var cap = "";
      var acc = "";
      var gs = "";
      pas["WEBLib.Controls"].TControl.UpdateElement.call(this);
      if (this.GetElementHandle() != null) {
        if ((this.FColor$1 !== -1) && !this.FFlat) {
          this.GetElementHandle().style.setProperty("background-color",pas["WEBLib.Graphics"].ColorToHTML(this.FColor$1))}
         else this.GetElementHandle().style.setProperty("background-color","");
        this.GetElementHandle().style.setProperty("vertical-align","middle");
        if (this.FVisible) this.GetElementHandle().style.setProperty("display","table");
        this.GetElementHandle().style.setProperty("overflow","hidden");
        this.GetElementHandle().style.setProperty("padding","0px");
        var $tmp = this.FAlignment;
        if ($tmp === pas.Classes.TAlignment.taLeftJustify) {
          this.GetElementHandle().style.setProperty("text-align","left")}
         else if ($tmp === pas.Classes.TAlignment.taCenter) {
          this.GetElementHandle().style.setProperty("text-align","center")}
         else if ($tmp === pas.Classes.TAlignment.taRightJustify) this.GetElementHandle().style.setProperty("text-align","right");
        s = "";
        inactive = "";
        noptr = "";
        matgl = "";
        if (!this.FEnabled) inactive = " md-light md-inactive";
        noptr = "pointer-events:none";
        if (this.FMaterialGlyph !== "") {
          matclr = "";
          if (this.FMaterialGlyphColor !== -1) matclr = ";color:" + pas["WEBLib.Graphics"].ColorToHTML(this.FMaterialGlyphColor);
          matgl = '<i class="' + pas["WEBLib.Controls"].GetMaterialClass(this.FMaterialGlyphType) + inactive + '" style="vertical-align:middle;' + noptr + ";font-size:" + pas.SysUtils.IntToStr(this.FMaterialGlyphSize) + "px" + matclr + '">' + this.FMaterialGlyph + "</i>";
        };
        if ((this.GetElementHandle().childElementCount === 0) || !this.GetIsLinked()) cap = pas["WEBLib.WebTools"].ProcessAccelerator(this.FCaption,{get: function () {
            return acc;
          }, set: function (v) {
            acc = v;
          }});
        if (acc !== "") this.GetElementHandle().setAttribute("accesskey",acc);
        if (cap !== "") s = '<span style="' + noptr + '">' + cap + "</span>";
        gs = "";
        if (this.FGlyphSize !== 0) gs = "width:" + pas.SysUtils.TIntegerHelper.ToString$1.call({p: this, get: function () {
            return this.p.FGlyphSize;
          }, set: function (v) {
            this.p.FGlyphSize = v;
          }}) + "px;";
        if (this.FGlyph.GetData() !== "") {
          imgsrc = "data:image/jpeg;base64," + pas["WEBLib.WebTools"].HexImageDecodeAsBase64(this.FGlyph.GetData())}
         else if (this.FGlyph.FFilename !== "") {
          imgsrc = this.FGlyph.FFilename}
         else if (this.FGlyphURL !== "") imgsrc = this.FGlyphURL;
        var $tmp1 = this.FLayout;
        if ($tmp1 === $mod.TButtonLayout.blGlyphLeft) {
          if (matgl !== "") {
            if (cap !== "") {
              s = matgl + "&nbsp;" + s}
             else s = matgl;
          };
          if (imgsrc !== "") s = '<img style="vertical-align:middle;' + gs + '" src="' + imgsrc + '">&nbsp;' + s;
        } else if ($tmp1 === $mod.TButtonLayout.blGlyphRight) {
          if (matgl !== "") {
            if (cap !== "") {
              s = s + "&nbsp;" + matgl}
             else s = matgl;
          };
          if (imgsrc !== "") s = s + '&nbsp;<img style="' + gs + '" src="' + imgsrc + '">';
        } else if ($tmp1 === $mod.TButtonLayout.blGlyphTop) {
          if (matgl !== "") {
            if (cap !== "") {
              s = matgl + "<br>" + s}
             else s = matgl;
          };
          if (imgsrc !== "") s = '<img style="' + gs + '" src="' + imgsrc + '"><br>' + s;
        } else if ($tmp1 === $mod.TButtonLayout.blGlyphBottom) {
          if (matgl !== "") {
            if (cap !== "") {
              s = s + "<br>" + matgl}
             else s = matgl;
          };
          if (imgsrc !== "") s = s + '<br><img style="' + gs + '" src="' + imgsrc + '">';
        };
        this.GetElementHandle().innerHTML = s;
        pas["WEBLib.Controls"].SetHTMLElementFont(this.GetElementHandle(),this.FFont,!((this.FElementClassName === "") && (this.FElementFont === pas["WEBLib.Controls"].TElementFont.efProperty)));
      };
    };
    this.UpdateElementVisual = function () {
      pas["WEBLib.Controls"].TCustomControl.UpdateElementVisual.call(this);
      if (this.GetElementHandle() != null) {
        this.GetElementHandle().style.removeProperty("outline");
        this.GetElementHandle().style.removeProperty("user-select");
      };
    };
    this.Click = function () {
      var frm = null;
      pas["WEBLib.Controls"].TControl.Click.call(this);
      if (this.FModalResult !== 0) {
        frm = pas["WEBLib.Forms"].GetParentForm(this);
        if (frm != null) frm.SetModalResult(this.FModalResult);
      };
    };
    this.GlyphChanged = function (Sender) {
      this.UpdateElement();
    };
    this.HandleKeyPreview = function (Key) {
      pas["WEBLib.Controls"].TControl.HandleKeyPreview.apply(this,arguments);
      if (this.FDefault && (Key === 13)) {
        this.Click();
      };
      if (this.FCancel && (Key === 27)) {
        this.Click();
      };
    };
    this.InitCSSLibrary = function (ALibrary) {
      if (ALibrary === pas["WEBLib.Controls"].TCSSLibrary.cssBootstrap) {
        this.SetElementClassName("btn btn-light");
        this.SetElementFont(pas["WEBLib.Controls"].TElementFont.efCSS);
        this.SetHeightStyle(pas["WEBLib.Controls"].TSizeStyle.ssAuto);
      };
    };
    this.Destroy = function () {
      rtl.free(this,"FGlyph");
      pas["WEBLib.Controls"].TCustomControl.Destroy.call(this);
    };
    this.CreateInitialize = function () {
      pas["WEBLib.Controls"].TCustomControl.CreateInitialize.call(this);
      this.FColor$1 = -1;
      this.FIntColor = -1;
      this.FFlat = false;
      this.SetWidth(80);
      this.SetHeight(25);
      this.FAlignment = pas.Classes.TAlignment.taCenter;
      this.FGlyph = pas["WEBLib.Graphics"].TURLPicture.$create("Create");
      this.FGlyph.FOnChange = rtl.createCallback(this,"GlyphChanged");
      this.FGlyph.FOnDataChange = rtl.createCallback(this,"GlyphChanged");
      this.FGlyphSize = 0;
      this.FMaterialGlyphSize = 18;
      this.FMaterialGlyphColor = -1;
      this.FMaterialGlyphType = pas["WEBLib.Controls"].TMaterialGlyphType.mgNormal;
      this.FModalResult = 0;
    };
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
  });
  rtl.createClass(this,"TBitBtn",this.TCustomBitBtn,function () {
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
    var $r = this.$rtti;
    $r.addProperty("Align",2,pas["WEBLib.Controls"].$rtti["TAlign"],"FAlign","SetAlign",{Default: pas["WEBLib.Controls"].TAlign.alNone});
    $r.addProperty("AlignWithMargins",2,rtl.boolean,"FAlignWithMargins","SetAlignWithMargins",{Default: false});
    $r.addProperty("Alignment",2,pas.Classes.$rtti["TAlignment"],"FAlignment","SetAlignment",{Default: pas.Classes.TAlignment.taCenter});
    $r.addProperty("Anchors",2,pas["WEBLib.Controls"].$rtti["TAnchors"],"FAnchors","SetAnchors",{Default: rtl.createSet(pas["WEBLib.Controls"].TAnchorKind.akLeft,pas["WEBLib.Controls"].TAnchorKind.akTop)});
    $r.addProperty("Cancel",0,rtl.boolean,"FCancel","FCancel",{Default: false});
    $r.addProperty("Caption",2,rtl.string,"FCaption","SetCaption");
    $r.addProperty("Color",2,pas["WEBLib.Graphics"].$rtti["TColor"],"FColor$1","SetColorEx");
    $r.addProperty("Default",0,rtl.boolean,"FDefault","FDefault",{Default: false});
    $r.addProperty("DragMode",2,pas["WEBLib.Controls"].$rtti["TDragMode"],"FDragMode","SetDragMode",{Default: pas["WEBLib.Controls"].TDragMode.dmManual});
    $r.addProperty("ElementClassName",2,pas["WEBLib.Controls"].$rtti["TElementClassName"],"FElementClassName","SetElementClassName");
    $r.addProperty("ElementID",3,pas["WEBLib.Controls"].$rtti["TElementID"],"GetID","SetID");
    $r.addProperty("ElementFont",2,pas["WEBLib.Controls"].$rtti["TElementFont"],"FElementFont","SetElementFont",{Default: pas["WEBLib.Controls"].TElementFont.efProperty});
    $r.addProperty("ElementPosition",2,pas["WEBLib.Controls"].$rtti["TElementPosition"],"FElementPosition","SetElementPosition",{Default: pas["WEBLib.Controls"].TElementPosition.epAbsolute});
    $r.addProperty("Enabled",2,rtl.boolean,"FEnabled","SetEnabled",{Default: true});
    $r.addProperty("Font",2,pas["WEBLib.Graphics"].$rtti["TFont"],"FFont","SetFont");
    $r.addProperty("Flat",2,rtl.boolean,"FFlat","SetFlat",{Default: false});
    $r.addProperty("Glyph",2,pas["WEBLib.Graphics"].$rtti["TURLPicture"],"FGlyph","SetGlyph");
    $r.addProperty("GlyphURL",2,rtl.string,"FGlyphURL","SetGlyphURL");
    $r.addProperty("GlyphSize",2,rtl.longint,"FGlyphSize","SetGlyphSize",{Default: 0});
    $r.addProperty("Height",3,rtl.longint,"GetHeight","SetHeight");
    $r.addProperty("HeightPercent",2,rtl.double,"FHeightPercent","SetHeightPercent",{Default: 100});
    $r.addProperty("HeightStyle",2,pas["WEBLib.Controls"].$rtti["TSizeStyle"],"FHeightStyle","SetHeightStyle",{Default: pas["WEBLib.Controls"].TSizeStyle.ssAbsolute});
    $r.addProperty("Hint",2,rtl.string,"FHint","SetHint");
    $r.addProperty("Layout",2,$mod.$rtti["TButtonLayout"],"FLayout","SetLayout",{Default: $mod.TButtonLayout.blGlyphLeft});
    $r.addProperty("MaterialGlyph",2,rtl.string,"FMaterialGlyph","SetMaterialGlyph");
    $r.addProperty("MaterialGlyphColor",2,pas["WEBLib.Graphics"].$rtti["TColor"],"FMaterialGlyphColor","SetMaterialGyphColor",{Default: -1});
    $r.addProperty("MaterialGlyphSize",2,rtl.longint,"FMaterialGlyphSize","SetMaterialGlyphSize",{Default: 18});
    $r.addProperty("MaterialGlyphType",2,pas["WEBLib.Controls"].$rtti["TMaterialGlyphType"],"FMaterialGlyphType","SetMaterialGlyphType",{Default: pas["WEBLib.Controls"].TMaterialGlyphType.mgNormal});
    $r.addProperty("ModalResult",0,rtl.longint,"FModalResult","FModalResult",{Default: 0});
    $r.addProperty("ParentFont",2,rtl.boolean,"FParentFont","SetParentFont",{Default: true});
    $r.addProperty("ShowHint",2,rtl.boolean,"FShowHint","SetShowHint",{Default: false});
    $r.addProperty("TabOrder",2,rtl.longint,"FTabOrder","SetTabOrder");
    $r.addProperty("TabStop",2,rtl.boolean,"FTabStop","SetTabStop",{Default: true});
    $r.addProperty("Visible",2,rtl.boolean,"FVisible","SetVisible",{Default: true});
    $r.addProperty("Width",3,rtl.longint,"GetWidth","SetWidth");
    $r.addProperty("WidthPercent",2,rtl.double,"FWidthPercent","SetWidthPercent",{Default: 100});
    $r.addProperty("WidthStyle",2,pas["WEBLib.Controls"].$rtti["TSizeStyle"],"FWidthStyle","SetWidthStyle",{Default: pas["WEBLib.Controls"].TSizeStyle.ssAbsolute});
    $r.addProperty("OnClick",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnClick","FOnClick");
    $r.addProperty("OnDblClick",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnDblClick","FOnDblClick");
    $r.addProperty("OnKeyDown",0,pas["WEBLib.Controls"].$rtti["TKeyEvent"],"FOnKeyDown","FOnKeyDown");
    $r.addProperty("OnKeyPress",0,pas["WEBLib.Controls"].$rtti["TKeyPressEvent"],"FOnKeyPress","FOnKeyPress");
    $r.addProperty("OnKeyUp",0,pas["WEBLib.Controls"].$rtti["TKeyEvent"],"FOnKeyUp","FOnKeyUp");
    $r.addProperty("OnMouseDown",0,pas["WEBLib.Controls"].$rtti["TMouseEvent"],"FOnMouseDown","FOnMouseDown");
    $r.addProperty("OnMouseUp",0,pas["WEBLib.Controls"].$rtti["TMouseEvent"],"FOnMouseUp","FOnMouseUp");
    $r.addProperty("OnMouseMove",0,pas["WEBLib.Controls"].$rtti["TMouseMoveEvent"],"FOnMouseMove","FOnMouseMove");
    $r.addProperty("OnMouseLeave",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnMouseLeave","FOnMouseLeave");
    $r.addProperty("OnMouseEnter",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnMouseEnter","FOnMouseEnter");
    $r.addProperty("OnEnter",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnEnter","FOnEnter");
    $r.addProperty("OnExit",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnExit","FOnExit");
    $r.addProperty("OnDragDrop",0,pas["WEBLib.Controls"].$rtti["TDragDropEvent"],"FOnDragDrop","FOnDragDrop");
    $r.addProperty("OnDragOver",0,pas["WEBLib.Controls"].$rtti["TDragOverEvent"],"FOnDragOver","FOnDragOver");
    $r.addProperty("OnEndDrag",0,pas["WEBLib.Controls"].$rtti["TEndDragEvent"],"FonEndDrag","FonEndDrag");
    $r.addProperty("OnStartDrag",0,pas["WEBLib.Controls"].$rtti["TStartDragEvent"],"FOnStartDrag","FOnStartDrag");
  });
  rtl.createClass(this,"TWebBitBtn",this.TBitBtn,function () {
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
  });
  rtl.createClass(this,"TCustomToolBar",pas["WEBLib.Controls"].TCustomControl,function () {
    this.CreateElement = function () {
      var Result = null;
      var el = null;
      Result = document.createElement("SPAN");
      if (pas.Classes.TComponentStateItem.csDesigning in this.FComponentState) {
        el = document.createElement("DIV");
        el.style.setProperty("z-index","10");
        el.style.setProperty("width","100%");
        el.style.setProperty("height","100%");
        el.style.setProperty("webkit-user-select","none");
        el.style.setProperty("moz-user-select","none");
        el.style.setProperty("khtml-user-select","none");
        el.style.setProperty("ms-user-select","none");
        el.style.setProperty("user-select","none");
        el.style.setProperty("position","absolute");
        Result.appendChild(el);
      };
      return Result;
    };
    this.UpdateElement = function () {
      pas["WEBLib.Controls"].TControl.UpdateElement.call(this);
      if (this.GetElementHandle() != null) {
        this.GetElementHandle().style.setProperty("display","flex");
        this.GetElementHandle().style.setProperty("flex-wrap","wrap");
        this.GetElementHandle().style.setProperty("padding","2px");
      };
    };
    this.CreateInitialize = function () {
      pas["WEBLib.Controls"].TCustomControl.CreateInitialize.call(this);
      this.SetColor(0xCFCFCF);
      this.FControlStyle = rtl.unionSet(this.FControlStyle,rtl.createSet(pas["WEBLib.Controls"].TControlStyleValue.csAcceptsControls));
      this.SetWidth(300);
      this.SetHeight(32);
    };
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
  });
  rtl.createClass(this,"TToolBar",this.TCustomToolBar,function () {
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
    var $r = this.$rtti;
    $r.addProperty("Align",2,pas["WEBLib.Controls"].$rtti["TAlign"],"FAlign","SetAlign",{Default: pas["WEBLib.Controls"].TAlign.alNone});
    $r.addProperty("AlignWithMargins",2,rtl.boolean,"FAlignWithMargins","SetAlignWithMargins",{Default: false});
    $r.addProperty("Anchors",2,pas["WEBLib.Controls"].$rtti["TAnchors"],"FAnchors","SetAnchors",{Default: rtl.createSet(pas["WEBLib.Controls"].TAnchorKind.akLeft,pas["WEBLib.Controls"].TAnchorKind.akTop)});
    $r.addProperty("Color",2,pas["WEBLib.Graphics"].$rtti["TColor"],"FColor","SetColor",{Default: 13619151});
    $r.addProperty("DragMode",2,pas["WEBLib.Controls"].$rtti["TDragMode"],"FDragMode","SetDragMode",{Default: pas["WEBLib.Controls"].TDragMode.dmManual});
    $r.addProperty("Enabled",2,rtl.boolean,"FEnabled","SetEnabled",{Default: true});
    $r.addProperty("ElementClassName",2,pas["WEBLib.Controls"].$rtti["TElementClassName"],"FElementClassName","SetElementClassName");
    $r.addProperty("ElementID",3,pas["WEBLib.Controls"].$rtti["TElementID"],"GetID","SetID");
    $r.addProperty("ElementFont",2,pas["WEBLib.Controls"].$rtti["TElementFont"],"FElementFont","SetElementFont",{Default: pas["WEBLib.Controls"].TElementFont.efProperty});
    $r.addProperty("ElementPosition",2,pas["WEBLib.Controls"].$rtti["TElementPosition"],"FElementPosition","SetElementPosition",{Default: pas["WEBLib.Controls"].TElementPosition.epAbsolute});
    $r.addProperty("Height",3,rtl.longint,"GetHeight","SetHeight");
    $r.addProperty("HeightPercent",2,rtl.double,"FHeightPercent","SetHeightPercent",{Default: 100});
    $r.addProperty("HeightStyle",2,pas["WEBLib.Controls"].$rtti["TSizeStyle"],"FHeightStyle","SetHeightStyle",{Default: pas["WEBLib.Controls"].TSizeStyle.ssAbsolute});
    $r.addProperty("Hint",2,rtl.string,"FHint","SetHint");
    $r.addProperty("Left",3,rtl.longint,"GetLeft","SetLeft");
    $r.addProperty("Margins",2,pas["WEBLib.Controls"].$rtti["TMargins"],"FMargins","SetMargins");
    $r.addProperty("ShowHint",2,rtl.boolean,"FShowHint","SetShowHint",{Default: false});
    $r.addProperty("Top",3,rtl.longint,"GetTop","SetTop");
    $r.addProperty("Visible",2,rtl.boolean,"FVisible","SetVisible",{Default: true});
    $r.addProperty("Width",3,rtl.longint,"GetWidth","SetWidth");
    $r.addProperty("WidthPercent",2,rtl.double,"FWidthPercent","SetWidthPercent",{Default: 100});
    $r.addProperty("WidthStyle",2,pas["WEBLib.Controls"].$rtti["TSizeStyle"],"FWidthStyle","SetWidthStyle",{Default: pas["WEBLib.Controls"].TSizeStyle.ssAbsolute});
    $r.addProperty("OnClick",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnClick","FOnClick");
    $r.addProperty("OnDblClick",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnDblClick","FOnDblClick");
    $r.addProperty("OnDragDrop",0,pas["WEBLib.Controls"].$rtti["TDragDropEvent"],"FOnDragDrop","FOnDragDrop");
    $r.addProperty("OnDragOver",0,pas["WEBLib.Controls"].$rtti["TDragOverEvent"],"FOnDragOver","FOnDragOver");
    $r.addProperty("OnEndDrag",0,pas["WEBLib.Controls"].$rtti["TEndDragEvent"],"FonEndDrag","FonEndDrag");
    $r.addProperty("OnStartDrag",0,pas["WEBLib.Controls"].$rtti["TStartDragEvent"],"FOnStartDrag","FOnStartDrag");
  });
  rtl.createClass(this,"TWebToolBar",this.TToolBar,function () {
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
  });
  this.TRichEditBtn = {"0": "reFont", reFont: 0, "1": "reFontSize", reFontSize: 1, "2": "reBold", reBold: 2, "3": "reItalic", reItalic: 3, "4": "reUnderline", reUnderline: 4, "5": "reStrikeThrough", reStrikeThrough: 5, "6": "reAlignLeft", reAlignLeft: 6, "7": "reAlignCenter", reAlignCenter: 7, "8": "reAlignRight", reAlignRight: 8, "9": "reUnorderedList", reUnorderedList: 9, "10": "reOrderedList", reOrderedList: 10, "11": "reForegroundColor", reForegroundColor: 11, "12": "reBackgroundColor", reBackgroundColor: 12, "13": "reHyperlink", reHyperlink: 13, "14": "reImageInsert", reImageInsert: 14, "15": "reLineSpacing", reLineSpacing: 15};
  this.$rtti.$Enum("TRichEditBtn",{minvalue: 0, maxvalue: 15, ordtype: 1, enumtype: this.TRichEditBtn});
  this.$rtti.$Set("TRichEditButtonSet",{comptype: this.$rtti["TRichEditBtn"]});
  rtl.createClass(this,"TRichEditToolBar",this.TToolBar,function () {
    this.$init = function () {
      $mod.TToolBar.$init.call(this);
      this.FBold = null;
      this.FItalic = null;
      this.FUnderline = null;
      this.FStrikeThrough = null;
      this.FAlignLeft = null;
      this.FAlignCenter = null;
      this.FAlignRight = null;
      this.FUList = null;
      this.FOList = null;
      this.FURL = null;
      this.FRichEdit = null;
      this.FFnt = null;
      this.FFntSize = null;
      this.FFgClr = null;
      this.FBkClr = null;
      this.FImage = null;
      this.FLineSpacing = null;
      this.FOnSpeedButtonClick = null;
      this.FTextColor = 0;
      this.FBackgroundColor = 0;
      this.FVisibleButtons = {};
      this.FHints = null;
      this.FBtnID = "";
      this.FFilePicker = null;
      this.FPtrFileLoad = null;
    };
    this.$final = function () {
      this.FBold = undefined;
      this.FItalic = undefined;
      this.FUnderline = undefined;
      this.FStrikeThrough = undefined;
      this.FAlignLeft = undefined;
      this.FAlignCenter = undefined;
      this.FAlignRight = undefined;
      this.FUList = undefined;
      this.FOList = undefined;
      this.FURL = undefined;
      this.FRichEdit = undefined;
      this.FFnt = undefined;
      this.FFntSize = undefined;
      this.FFgClr = undefined;
      this.FBkClr = undefined;
      this.FImage = undefined;
      this.FLineSpacing = undefined;
      this.FOnSpeedButtonClick = undefined;
      this.FVisibleButtons = undefined;
      this.FHints = undefined;
      this.FFilePicker = undefined;
      $mod.TToolBar.$final.call(this);
    };
    this.SetRichEdit = function (AValue) {
      if (AValue != null) {
        this.FRichEdit = AValue;
        this.FRichEdit.FOwner$1 = this;
        this.FRichEdit.FOnAttributesChanged = rtl.createCallback(this,"HandleAttributeChanged");
      };
    };
    this.GetRichEdit = function () {
      var Result = null;
      Result = this.FRichEdit;
      return Result;
    };
    this.SetTextColor = function (Value) {
      this.FTextColor = Value;
      this.FFgClr.SetColor$1(Value);
    };
    this.SetBackgroundColor = function (Value) {
      this.FBackgroundColor = Value;
      this.FBkClr.SetColor$1(Value);
    };
    this.SetVisibleButtons = function (Value) {
      this.FVisibleButtons = rtl.refSet(Value);
      this.UpdateButtons();
    };
    this.SetHints = function (Value) {
      this.FHints.Assign(Value);
    };
    this.HandleDoFileLoad = function (Event) {
      var $Self = this;
      var Result = false;
      function InsertImage(DataURL) {
        $Self.GetRichEdit().InsertImage(DataURL);
      };
      if (1 < 0) InsertImage("");
      var file = this.FFilePicker.files[0];
          var reader  = new FileReader();
      
          reader.addEventListener("load", function () {
              InsertImage(reader.result);
          }, false);
      
          if (file)
              reader.readAsDataURL(file);
      Result = true;
      return Result;
    };
    this.Notification = function (AComponent, Operation) {
      pas.Classes.TComponent.Notification.apply(this,arguments);
      if ((Operation === pas.Classes.TOperation.opRemove) && (AComponent === this.FRichEdit)) {
        this.FRichEdit = null;
      };
    };
    this.CreateButton = function (btn, BtnID, Glyph, Hint) {
      btn.set($mod.TSpeedButton.$create("Create$2",[BtnID]));
      btn.get().SetName(BtnID);
      btn.get().SetFlat(true);
      btn.get().SetElementPosition(pas["WEBLib.Controls"].TElementPosition.epRelative);
      btn.get().SetParent(this);
      btn.get().SetMaterialGlyph(Glyph);
      btn.get().SetTop(0);
      btn.get().SetWidth(32);
      btn.get().SetHeight(24);
      btn.get().SetHint(Hint);
      btn.get().SetShowHint(Hint !== "");
      btn.get().SetEnabled(true);
      btn.get().FOnClick = rtl.createCallback(this,"HandleSpeedButtonClick");
    };
    this.HandleSpeedButtonClick = function (Sender) {
      var BID = "";
      if (this.GetRichEdit() != null) {
        BID = Sender.GetID();
        if (BID === (this.FBtnID + "_bold")) {
          if (pas["WEBLib.Graphics"].TFontStyle.fsBold in this.GetRichEdit().FSelAttributes.FStyle) {
            this.GetRichEdit().FSelAttributes.SetStyle(rtl.diffSet(this.GetRichEdit().FSelAttributes.FStyle,rtl.createSet(pas["WEBLib.Graphics"].TFontStyle.fsBold)))}
           else this.GetRichEdit().FSelAttributes.SetStyle(rtl.unionSet(this.GetRichEdit().FSelAttributes.FStyle,rtl.createSet(pas["WEBLib.Graphics"].TFontStyle.fsBold)));
        } else if (BID === (this.FBtnID + "_italic")) {
          if (pas["WEBLib.Graphics"].TFontStyle.fsItalic in this.GetRichEdit().FSelAttributes.FStyle) {
            this.GetRichEdit().FSelAttributes.SetStyle(rtl.diffSet(this.GetRichEdit().FSelAttributes.FStyle,rtl.createSet(pas["WEBLib.Graphics"].TFontStyle.fsItalic)))}
           else this.GetRichEdit().FSelAttributes.SetStyle(rtl.unionSet(this.GetRichEdit().FSelAttributes.FStyle,rtl.createSet(pas["WEBLib.Graphics"].TFontStyle.fsItalic)));
        } else if (BID === (this.FBtnID + "_underline")) {
          if (pas["WEBLib.Graphics"].TFontStyle.fsUnderline in this.GetRichEdit().FSelAttributes.FStyle) {
            this.GetRichEdit().FSelAttributes.SetStyle(rtl.diffSet(this.GetRichEdit().FSelAttributes.FStyle,rtl.createSet(pas["WEBLib.Graphics"].TFontStyle.fsUnderline)))}
           else this.GetRichEdit().FSelAttributes.SetStyle(rtl.unionSet(this.GetRichEdit().FSelAttributes.FStyle,rtl.createSet(pas["WEBLib.Graphics"].TFontStyle.fsUnderline)));
        } else if (BID === (this.FBtnID + "_strikethrough")) {
          if (pas["WEBLib.Graphics"].TFontStyle.fsStrikeOut in this.GetRichEdit().FSelAttributes.FStyle) {
            this.GetRichEdit().FSelAttributes.SetStyle(rtl.diffSet(this.GetRichEdit().FSelAttributes.FStyle,rtl.createSet(pas["WEBLib.Graphics"].TFontStyle.fsStrikeOut)))}
           else this.GetRichEdit().FSelAttributes.SetStyle(rtl.unionSet(this.GetRichEdit().FSelAttributes.FStyle,rtl.createSet(pas["WEBLib.Graphics"].TFontStyle.fsStrikeOut)));
        } else if (BID === (this.FBtnID + "_alignleft")) {
          this.GetRichEdit().FSelAttributes.SetAlignment(pas.Classes.TAlignment.taLeftJustify)}
         else if (BID === (this.FBtnID + "_aligncenter")) {
          this.GetRichEdit().FSelAttributes.SetAlignment(pas.Classes.TAlignment.taCenter)}
         else if (BID === (this.FBtnID + "_alignright")) {
          this.GetRichEdit().FSelAttributes.SetAlignment(pas.Classes.TAlignment.taRightJustify)}
         else if (BID === (this.FBtnID + "_olist")) {
          this.GetRichEdit().FSelAttributes.SetOrderedList(!this.GetRichEdit().FSelAttributes.FOrderedList)}
         else if (BID === (this.FBtnID + "_ulist")) {
          this.GetRichEdit().FSelAttributes.SetUnOrderedList(!this.GetRichEdit().FSelAttributes.FUnOrderedList)}
         else if (BID === (this.FBtnID + "_url")) {
          this.GetRichEdit().FSelAttributes.Link()}
         else if (BID === (this.FBtnID + "_image")) this.FFilePicker.click();
      };
      if (this.FOnSpeedButtonClick != null) this.FOnSpeedButtonClick(Sender);
    };
    this.FgSelect = function (Sender) {
      if (this.GetRichEdit() != null) this.GetRichEdit().FSelAttributes.SetColor(this.FFgClr.GetColor());
    };
    this.BkSelect = function (Sender) {
      if (this.GetRichEdit() != null) this.GetRichEdit().FSelAttributes.SetBackColor(this.FBkClr.GetColor());
    };
    this.FntChange = function (Sender) {
      if (this.GetRichEdit() != null) this.GetRichEdit().FSelAttributes.SetName(this.FFnt.FItems.Get(this.FFnt.GetItemIndex()));
    };
    this.FntSizeChange = function (Sender) {
      if (this.GetRichEdit() != null) this.GetRichEdit().FSelAttributes.SetHeight(this.FFntSize.GetItemIndex() + 1);
    };
    this.LineSpacingChange = function (Sender) {
      var spacing = 0.0;
      var $tmp = this.FLineSpacing.GetItemIndex();
      if ($tmp === 0) {
        spacing = 1}
       else if ($tmp === 1) {
        spacing = 1.5}
       else if ($tmp === 2) spacing = 2;
      this.FRichEdit.SetSelectionSpacing(spacing);
    };
    this.UpdateButtons = function () {
      if (this.IsUpdating()) return;
      this.FBold.SetVisible($mod.TRichEditBtn.reBold in this.FVisibleButtons);
      this.FItalic.SetVisible($mod.TRichEditBtn.reItalic in this.FVisibleButtons);
      this.FUnderline.SetVisible($mod.TRichEditBtn.reUnderline in this.FVisibleButtons);
      this.FStrikeThrough.SetVisible($mod.TRichEditBtn.reStrikeThrough in this.FVisibleButtons);
      this.FAlignLeft.SetVisible($mod.TRichEditBtn.reAlignLeft in this.FVisibleButtons);
      this.FAlignCenter.SetVisible($mod.TRichEditBtn.reAlignCenter in this.FVisibleButtons);
      this.FAlignRight.SetVisible($mod.TRichEditBtn.reAlignRight in this.FVisibleButtons);
      this.FUList.SetVisible($mod.TRichEditBtn.reUnorderedList in this.FVisibleButtons);
      this.FOList.SetVisible($mod.TRichEditBtn.reOrderedList in this.FVisibleButtons);
      this.FFnt.SetVisible($mod.TRichEditBtn.reFont in this.FVisibleButtons);
      this.FFntSize.SetVisible($mod.TRichEditBtn.reFontSize in this.FVisibleButtons);
      this.FFgClr.SetVisible($mod.TRichEditBtn.reForegroundColor in this.FVisibleButtons);
      this.FBkClr.SetVisible($mod.TRichEditBtn.reBackgroundColor in this.FVisibleButtons);
      this.FURL.SetVisible($mod.TRichEditBtn.reHyperlink in this.FVisibleButtons);
      this.FImage.SetVisible($mod.TRichEditBtn.reImageInsert in this.FVisibleButtons);
      this.FLineSpacing.SetVisible($mod.TRichEditBtn.reLineSpacing in this.FVisibleButtons);
      if (this.FElementPosition === pas["WEBLib.Controls"].TElementPosition.epRelative) {
        if (this.GetElementHandle() != null) {
          this.GetElementHandle().style.setProperty("display","flex");
          this.GetElementHandle().style.setProperty("flex-wrap","wrap");
          this.GetElementHandle().style.setProperty("padding","2px");
        };
      };
      while (this.FHints.GetCount() < 14) this.FHints.Add("");
      this.FBold.SetHint(this.FHints.Get(0));
      this.FItalic.SetHint(this.FHints.Get(1));
      this.FUnderline.SetHint(this.FHints.Get(2));
      this.FStrikeThrough.SetHint(this.FHints.Get(3));
      this.FFgClr.SetHint(this.FHints.Get(4));
      this.FBkClr.SetHint(this.FHints.Get(5));
      this.FAlignLeft.SetHint(this.FHints.Get(6));
      this.FAlignCenter.SetHint(this.FHints.Get(7));
      this.FAlignRight.SetHint(this.FHints.Get(8));
      this.FUList.SetHint(this.FHints.Get(9));
      this.FOList.SetHint(this.FHints.Get(10));
      this.FURL.SetHint(this.FHints.Get(11));
      this.FImage.SetHint(this.FHints.Get(12));
      this.FLineSpacing.SetHint(this.FHints.Get(13));
    };
    this.UpdateElement = function () {
      $mod.TCustomToolBar.UpdateElement.call(this);
      if (this.GetElementHandle() != null) {
        this.GetElementHandle().style.setProperty("height","32px");
      };
    };
    this.Loaded = function () {
      pas["WEBLib.Controls"].TCustomControl.Loaded.call(this);
      this.UpdateButtons();
      this.InitButtons();
    };
    this.HandleAttributeChanged = function (Sender, Attributes) {
      this.FFnt.SetItemIndex(Math.max(0,this.FFnt.FItems.IndexOf(Attributes.FontName)));
      this.FFntSize.SetItemIndex(Math.max(0,this.FFntSize.FItems.IndexOf(Attributes.FontSize)));
      this.FBold.SetDown(Attributes.IsBold);
      this.FItalic.SetDown(Attributes.IsItalic);
      this.FUnderline.SetDown(Attributes.IsUnderline);
      this.FStrikeThrough.SetDown(Attributes.IsStrikeOut);
      this.FAlignLeft.SetDown(Attributes.IsLeft);
      this.FAlignRight.SetDown(Attributes.IsRight);
      this.FAlignCenter.SetDown(Attributes.IsCenter);
      if (Attributes.FontColor !== "") {
        this.FFgClr.SetColor$1(pas["WEBLib.Graphics"].HexToColor(Attributes.FontColor));
      };
      if (Attributes.BkColor !== "") {
        this.FBkClr.SetColor$1(pas["WEBLib.Graphics"].RGBToColor(Attributes.BkColor));
      };
    };
    this.GetChildren = function (Proc, Root) {
    };
    this.InitButtons = function () {
      var $Self = this;
      var Result = false;
      function HandleTimeOut() {
        var i = 0;
        for (var $l = 0, $end = $Self.GetControlsCount() - 1; $l <= $end; $l++) {
          i = $l;
          $Self.GetControls(i).UpdateElement();
        };
      };
      Result = true;
      if (!this.GetIsLinked()) return Result;
      if (1 < 0) HandleTimeOut();
      setTimeout(function() {HandleTimeOut();}, 10);
      return Result;
    };
    this.SetParent = function (AValue) {
      pas["WEBLib.Controls"].TControl.SetParent.apply(this,arguments);
      if (!(pas.Classes.TComponentStateItem.csLoading in this.FComponentState)) this.InitButtons();
    };
    this.CreateInitialize = function () {
      $mod.TCustomToolBar.CreateInitialize.call(this);
      this.FVisibleButtons = rtl.createSet($mod.TRichEditBtn.reFont,$mod.TRichEditBtn.reFontSize,$mod.TRichEditBtn.reBold,$mod.TRichEditBtn.reItalic,$mod.TRichEditBtn.reUnderline,$mod.TRichEditBtn.reStrikeThrough,$mod.TRichEditBtn.reAlignLeft,$mod.TRichEditBtn.reAlignCenter,$mod.TRichEditBtn.reAlignRight,$mod.TRichEditBtn.reUnorderedList,$mod.TRichEditBtn.reOrderedList,$mod.TRichEditBtn.reForegroundColor,$mod.TRichEditBtn.reBackgroundColor,$mod.TRichEditBtn.reHyperlink,$mod.TRichEditBtn.reImageInsert,$mod.TRichEditBtn.reLineSpacing);
      this.SetRichEdit(null);
      this.SetWidth(540);
      this.SetHeight(32);
      this.FPtrFileLoad = rtl.createCallback(this,"HandleDoFileLoad");
      this.FControlStyle = rtl.diffSet(this.FControlStyle,rtl.createSet(pas["WEBLib.Controls"].TControlStyleValue.csAcceptsControls));
      this.FTextColor = 0;
      this.FBackgroundColor = 16777215;
      this.FBtnID = pas["WEBLib.Controls"].FindUniqueName("RETBBtn");
      this.FHints = pas.Classes.TStringList.$create("Create$1");
      this.FHints.Add("Bold");
      this.FHints.Add("Italic");
      this.FHints.Add("Underline");
      this.FHints.Add("Strike Throught");
      this.FHints.Add("Text Color");
      this.FHints.Add("Background Color");
      this.FHints.Add("Align left");
      this.FHints.Add("Align center");
      this.FHints.Add("Align right");
      this.FHints.Add("Numbered list");
      this.FHints.Add("List");
      this.FHints.Add("Hyperlink");
      this.FHints.Add("Insert image");
      this.FHints.Add("Line spacing");
      this.FLineSpacing = pas["WEBLib.StdCtrls"].TLineSpacingPicker.$create("Create$1",[this]);
      this.FLineSpacing.SetName(this.FBtnID + "_linespacing");
      this.FLineSpacing.SetElementPosition(pas["WEBLib.Controls"].TElementPosition.epRelative);
      this.FLineSpacing.SetParent(this);
      this.FLineSpacing.SetWidth(40);
      this.FLineSpacing.SetItemIndex(0);
      this.FLineSpacing.SetShowHint(true);
      this.FLineSpacing.SetHint(this.FHints.Get(13));
      this.FLineSpacing.FOnChange = rtl.createCallback(this,"LineSpacingChange");
      this.FFilePicker = document.createElement("INPUT");
      this.FFilePicker.setAttribute("type","file");
      this.FFilePicker.style.setProperty("visibility","hidden");
      this.FFilePicker.addEventListener("change",this.FPtrFileLoad);
      this.GetElementHandle().appendChild(this.FFilePicker);
      this.CreateButton({p: this, get: function () {
          return this.p.FImage;
        }, set: function (v) {
          this.p.FImage = v;
        }},this.FBtnID + "_image","&#xE3f4;",this.FHints.Get(12));
      this.CreateButton({p: this, get: function () {
          return this.p.FURL;
        }, set: function (v) {
          this.p.FURL = v;
        }},this.FBtnID + "_url","&#xE250;",this.FHints.Get(11));
      this.CreateButton({p: this, get: function () {
          return this.p.FUList;
        }, set: function (v) {
          this.p.FUList = v;
        }},this.FBtnID + "_ulist","&#xE241;",this.FHints.Get(10));
      this.CreateButton({p: this, get: function () {
          return this.p.FOList;
        }, set: function (v) {
          this.p.FOList = v;
        }},this.FBtnID + "_olist","&#xE242;",this.FHints.Get(9));
      this.CreateButton({p: this, get: function () {
          return this.p.FAlignRight;
        }, set: function (v) {
          this.p.FAlignRight = v;
        }},this.FBtnID + "_alignright","&#xE237;",this.FHints.Get(8));
      this.CreateButton({p: this, get: function () {
          return this.p.FAlignCenter;
        }, set: function (v) {
          this.p.FAlignCenter = v;
        }},this.FBtnID + "_aligncenter","&#xE234;",this.FHints.Get(7));
      this.CreateButton({p: this, get: function () {
          return this.p.FAlignLeft;
        }, set: function (v) {
          this.p.FAlignLeft = v;
        }},this.FBtnID + "_alignleft","&#xE236;",this.FHints.Get(6));
      this.FBkClr = pas["WEBLib.StdCtrls"].TWebColorPicker.$create("Create$1",[this]);
      this.FBkClr.SetName(this.FBtnID + "_bkclr");
      this.FBkClr.SetElementPosition(pas["WEBLib.Controls"].TElementPosition.epRelative);
      this.FBkClr.SetParent(this);
      this.FBkClr.SetHint(this.FHints.Get(5));
      this.FBkClr.SetWidth(32);
      this.FBkClr.SetHeight(24);
      this.FBkClr.SetColor$1(16777215);
      this.FBkClr.FOnSelect = rtl.createCallback(this,"BkSelect");
      this.FBkClr.SetShowHint(true);
      this.FFgClr = pas["WEBLib.StdCtrls"].TWebColorPicker.$create("Create$1",[this]);
      this.FFgClr.SetName(this.FBtnID + "_fgclr");
      this.FFgClr.SetElementPosition(pas["WEBLib.Controls"].TElementPosition.epRelative);
      this.FFgClr.SetParent(this);
      this.FFgClr.SetHint(this.FHints.Get(4));
      this.FFgClr.SetWidth(32);
      this.FFgClr.SetHeight(24);
      this.FFgClr.SetColor$1(0);
      this.FFgClr.FOnSelect = rtl.createCallback(this,"FgSelect");
      this.FFgClr.SetShowHint(true);
      this.CreateButton({p: this, get: function () {
          return this.p.FStrikeThrough;
        }, set: function (v) {
          this.p.FStrikeThrough = v;
        }},this.FBtnID + "_strikethrough","&#xE257;",this.FHints.Get(3));
      this.CreateButton({p: this, get: function () {
          return this.p.FUnderline;
        }, set: function (v) {
          this.p.FUnderline = v;
        }},this.FBtnID + "_underline","&#xE249;",this.FHints.Get(2));
      this.CreateButton({p: this, get: function () {
          return this.p.FItalic;
        }, set: function (v) {
          this.p.FItalic = v;
        }},this.FBtnID + "_italic","&#xE23F;",this.FHints.Get(1));
      this.CreateButton({p: this, get: function () {
          return this.p.FBold;
        }, set: function (v) {
          this.p.FBold = v;
        }},this.FBtnID + "_bold","&#xE238;",this.FHints.Get(0));
      this.FFntSize = pas["WEBLib.StdCtrls"].TFontSizePicker.$create("Create$1",[this]);
      this.FFntSize.SetName(this.FBtnID + "_fontsize");
      this.FFntSize.SetElementPosition(pas["WEBLib.Controls"].TElementPosition.epRelative);
      this.FFntSize.SetParent(this);
      this.FFntSize.SetWidth(50);
      this.FFntSize.SetPickerMode(pas["WEBLib.StdCtrls"].TFontSizePickerMode.fmRelativeSize);
      this.FFntSize.SetItemIndex(0);
      this.FFntSize.FOnChange = rtl.createCallback(this,"FntSizeChange");
      this.FFnt = pas["WEBLib.StdCtrls"].TFontPicker.$create("Create$1",[this]);
      this.FFnt.SetElementPosition(pas["WEBLib.Controls"].TElementPosition.epRelative);
      this.FFnt.SetName(this.FBtnID + "_fontname");
      this.FFnt.SetParent(this);
      this.FFnt.SetWidth(150);
      this.FFnt.SetItemIndex(0);
      this.FFnt.FOnChange = rtl.createCallback(this,"FntChange");
    };
    this.Destroy = function () {
      rtl.free(this,"FHints");
      if (this.FRichEdit != null) this.FRichEdit.FOnAttributesChanged = null;
      pas["WEBLib.Controls"].TCustomControl.Destroy.call(this);
    };
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
    var $r = this.$rtti;
    $r.addProperty("BackgroundColor",2,pas["WEBLib.Graphics"].$rtti["TColor"],"FBackgroundColor","SetBackgroundColor",{Default: 16777215});
    $r.addProperty("Hints",2,pas.Classes.$rtti["TStrings"],"FHints","SetHints");
    $r.addProperty("RichEdit",3,pas["WEBLib.ComCtrls"].$rtti["TRichEdit"],"GetRichEdit","SetRichEdit");
    $r.addProperty("TextColor",2,pas["WEBLib.Graphics"].$rtti["TColor"],"FTextColor","SetTextColor",{Default: 0});
    $r.addProperty("VisibleButtons",2,$mod.$rtti["TRichEditButtonSet"],"FVisibleButtons","SetVisibleButtons");
    $r.addProperty("OnSpeedButtonClick",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnSpeedButtonClick","FOnSpeedButtonClick");
  });
  rtl.createClass(this,"TWebRichEditToolBar",this.TRichEditToolBar,function () {
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
  });
  this.TToggleButtonStyle = {"0": "tsRectangular", tsRectangular: 0, "1": "tsRounded", tsRounded: 1};
  this.$rtti.$Enum("TToggleButtonStyle",{minvalue: 0, maxvalue: 1, ordtype: 1, enumtype: this.TToggleButtonStyle});
  rtl.createClass(this,"TToggleButton",pas["WEBLib.Controls"].TCustomControl,function () {
    this.$init = function () {
      pas["WEBLib.Controls"].TCustomControl.$init.call(this);
      this.FChecked = false;
      this.FLabel = null;
      this.FInput = null;
      this.FSlider = null;
      this.FStyle = 0;
    };
    this.$final = function () {
      this.FLabel = undefined;
      this.FInput = undefined;
      this.FSlider = undefined;
      pas["WEBLib.Controls"].TCustomControl.$final.call(this);
    };
    this.SetStyle = function (Value) {
      if (this.FStyle !== Value) {
        this.FStyle = Value;
        this.UpdateElement();
      };
    };
    this.GetChecked = function () {
      var Result = false;
      if (this.GetContainer() != null) this.FChecked = this.FInput.checked;
      Result = this.FChecked;
      return Result;
    };
    this.SetChecked = function (Value) {
      this.FChecked = Value;
      this.UpdateElement();
    };
    this.HandleDoClick = function (Event) {
      var Result = false;
      this.FElementEvent = Event;
      this.StopPropagation();
      if (Event.target === this.FInput) {
        if (this.FOnClick != null) this.FOnClick(this);
      };
      Result = true;
      this.FElementEvent = null;
      return Result;
    };
    this.UpdateElement = function () {
      pas["WEBLib.Controls"].TControl.UpdateElement.call(this);
      if (!this.IsUpdating() && (this.FLabel != null)) {
        this.UpdateCSS();
        this.InjectCSS();
        this.FLabel.setAttribute("class",this.FName + "_switch");
        this.FInput.checked = this.FChecked;
        if (this.FStyle === $mod.TToggleButtonStyle.tsRectangular) {
          this.FSlider.setAttribute("class",this.FName + "_slider")}
         else this.FSlider.setAttribute("class",this.FName + "_slider round");
      };
    };
    this.UpdateCSS = function () {
      var css = "";
      var wpx = "";
      var hpx = "";
      var hwpx = "";
      var wspx = "";
      var hspx = "";
      wpx = pas.SysUtils.TIntegerHelper.ToString$1.call({p: this.GetWidth(), get: function () {
          return this.p;
        }, set: function (v) {
          this.p = v;
        }}) + "px";
      hpx = pas.SysUtils.TIntegerHelper.ToString$1.call({p: this.GetHeight(), get: function () {
          return this.p;
        }, set: function (v) {
          this.p = v;
        }}) + "px";
      hwpx = pas.SysUtils.TIntegerHelper.ToString$1.call({a: rtl.trunc(this.GetWidth() / 2), get: function () {
          return this.a;
        }, set: function (v) {
          this.a = v;
        }}) + "px";
      wspx = pas.SysUtils.TIntegerHelper.ToString$1.call({a: rtl.trunc(this.GetWidth() / 2) - 8, get: function () {
          return this.a;
        }, set: function (v) {
          rtl.raiseE("EPropReadOnly");
        }}) + "px";
      hspx = pas.SysUtils.TIntegerHelper.ToString$1.call({a: this.GetHeight() - 8, get: function () {
          return this.a;
        }, set: function (v) {
          rtl.raiseE("EPropReadOnly");
        }}) + "px";
      css = "." + this.FName + "_switch {" + "position: relative;" + "display: inline-block;" + "width: " + wpx + ";" + "height: " + hpx + ";" + "}" + ".switch input {display:none;}" + "." + this.FName + "_slider {" + "position: absolute;" + "cursor: pointer;" + "top: 0;" + "left: 0;" + "right: 0;" + "bottom: 0;" + "background-color: #ccc;" + "-webkit-transition: .4s;" + "transition: .4s;" + "}" + "." + this.FName + "_slider:before {" + "position: absolute;" + 'content: "";' + "height: " + hspx + ";" + "width: " + wspx + ";" + "left: 4px;" + "bottom: 4px;" + "background-color: white;" + "-webkit-transition: .4s;" + "transition: .4s;" + "}" + "input:checked + ." + this.FName + "_slider {" + "background-color: #2196F3;" + "}" + "input:focus + ." + this.FName + "_slider {" + "box-shadow: 0 0 1px #2196F3;" + "}" + "input:checked + ." + this.FName + "_slider:before {" + "-webkit-transform: translateX(" + hwpx + ");" + "-ms-transform: translateX(" + hwpx + ");" + "transform: translateX(" + hwpx + ");" + "}" + "/* Rounded sliders */" + "." + this.FName + "_slider.round {" + "border-radius: " + wspx + ";" + "}" + "." + this.FName + "_slider.round:before {" + "border-radius: 50%;" + "}";
      this.AddInstanceStyle(css);
    };
    this.CreateElement = function () {
      var Result = null;
      Result = document.createElement("span");
      this.FLabel = document.createElement("label");
      this.FInput = document.createElement("input");
      this.FSlider = document.createElement("span");
      this.FInput.setAttribute("type","checkbox");
      this.FInput.style.setProperty("display","none");
      Result.appendChild(this.FLabel);
      this.FLabel.appendChild(this.FInput);
      this.FLabel.appendChild(this.FSlider);
      return Result;
    };
    this.Loaded = function () {
      pas["WEBLib.Controls"].TCustomControl.Loaded.call(this);
    };
    this.Resize = function () {
      pas["WEBLib.Controls"].TCustomControl.Resize.call(this);
      this.UpdateCSS();
    };
    this.CreateInitialize = function () {
      pas["WEBLib.Controls"].TCustomControl.CreateInitialize.call(this);
      this.SetWidth(48);
      this.SetHeight(24);
    };
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
    var $r = this.$rtti;
    $r.addProperty("Anchors",2,pas["WEBLib.Controls"].$rtti["TAnchors"],"FAnchors","SetAnchors",{Default: rtl.createSet(pas["WEBLib.Controls"].TAnchorKind.akLeft,pas["WEBLib.Controls"].TAnchorKind.akTop)});
    $r.addProperty("Checked",3,rtl.boolean,"GetChecked","SetChecked");
    $r.addProperty("DragMode",2,pas["WEBLib.Controls"].$rtti["TDragMode"],"FDragMode","SetDragMode",{Default: pas["WEBLib.Controls"].TDragMode.dmManual});
    $r.addProperty("ElementClassName",2,pas["WEBLib.Controls"].$rtti["TElementClassName"],"FElementClassName","SetElementClassName");
    $r.addProperty("ElementID",3,pas["WEBLib.Controls"].$rtti["TElementID"],"GetID","SetID");
    $r.addProperty("ElementFont",2,pas["WEBLib.Controls"].$rtti["TElementFont"],"FElementFont","SetElementFont",{Default: pas["WEBLib.Controls"].TElementFont.efProperty});
    $r.addProperty("ElementPosition",2,pas["WEBLib.Controls"].$rtti["TElementPosition"],"FElementPosition","SetElementPosition",{Default: pas["WEBLib.Controls"].TElementPosition.epAbsolute});
    $r.addProperty("Style",2,$mod.$rtti["TToggleButtonStyle"],"FStyle","SetStyle",{Default: $mod.TToggleButtonStyle.tsRectangular});
    $r.addProperty("Visible",2,rtl.boolean,"FVisible","SetVisible",{Default: true});
    $r.addProperty("OnClick",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnClick","FOnClick");
    $r.addProperty("OnMouseDown",0,pas["WEBLib.Controls"].$rtti["TMouseEvent"],"FOnMouseDown","FOnMouseDown");
    $r.addProperty("OnMouseUp",0,pas["WEBLib.Controls"].$rtti["TMouseEvent"],"FOnMouseUp","FOnMouseUp");
    $r.addProperty("OnMouseMove",0,pas["WEBLib.Controls"].$rtti["TMouseMoveEvent"],"FOnMouseMove","FOnMouseMove");
    $r.addProperty("OnMouseLeave",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnMouseLeave","FOnMouseLeave");
    $r.addProperty("OnMouseEnter",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnMouseEnter","FOnMouseEnter");
    $r.addProperty("OnEnter",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnEnter","FOnEnter");
    $r.addProperty("OnExit",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnExit","FOnExit");
    $r.addProperty("OnDragDrop",0,pas["WEBLib.Controls"].$rtti["TDragDropEvent"],"FOnDragDrop","FOnDragDrop");
    $r.addProperty("OnDragOver",0,pas["WEBLib.Controls"].$rtti["TDragOverEvent"],"FOnDragOver","FOnDragOver");
    $r.addProperty("OnEndDrag",0,pas["WEBLib.Controls"].$rtti["TEndDragEvent"],"FonEndDrag","FonEndDrag");
    $r.addProperty("OnStartDrag",0,pas["WEBLib.Controls"].$rtti["TStartDragEvent"],"FOnStartDrag","FOnStartDrag");
  });
  rtl.createClass(this,"TWebToggleButton",this.TToggleButton,function () {
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
  });
  $mod.$implcode = function () {
    rtl.createClass($impl,"TRichEditorCracker",pas["WEBLib.ComCtrls"].TRichEdit,function () {
      rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
      rtl.addIntf(this,pas.System.IUnknown);
    });
  };
},["WEBLib.WebTools","Math"]);
rtl.module("WEBLib.ComCtrls",["System","Classes","SysUtils","Web","WEBLib.Controls","WEBLib.Graphics","WEBLib.ExtCtrls","WEBLib.TreeNodes","WEBLib.Menus"],function () {
  "use strict";
  var $mod = this;
  var $impl = $mod.$impl;
  this.$rtti.$Class("TCustomRichEdit");
  rtl.createClass(this,"TTextAttributes",pas.Classes.TPersistent,function () {
    this.$init = function () {
      pas.Classes.TPersistent.$init.call(this);
      this.RichEdit = null;
      this.FAlignment = 0;
      this.FIsBold = false;
      this.FIsItalic = false;
      this.FIsUnderline = false;
      this.FIsStrikeOut = false;
      this.FBackColor = 0;
      this.FColor = 0;
      this.FHeight = 0;
      this.FName = "";
      this.FOrderedList = false;
      this.FSize = 0;
      this.FStyle = {};
      this.FUnOrderedList = false;
    };
    this.$final = function () {
      this.RichEdit = undefined;
      this.FStyle = undefined;
      pas.Classes.TPersistent.$final.call(this);
    };
    this.SetAlignment = function (Value) {
      this.FAlignment = Value;
      var $tmp = this.FAlignment;
      if ($tmp === pas.Classes.TAlignment.taLeftJustify) {
        this.RichEdit.DoEditAction("justifyleft")}
       else if ($tmp === pas.Classes.TAlignment.taCenter) {
        this.RichEdit.DoEditAction("justifycenter")}
       else if ($tmp === pas.Classes.TAlignment.taRightJustify) this.RichEdit.DoEditAction("justifyright");
    };
    this.SetBackColor = function (Value) {
      this.FColor = Value;
      this.RichEdit.DoEditAction$1("hiliteColor",pas["WEBLib.Graphics"].ColorToHTML(Value));
    };
    this.SetColor = function (Value) {
      this.FColor = Value;
      this.RichEdit.DoEditAction$1("foreColor",pas["WEBLib.Graphics"].ColorToHTML(Value));
    };
    this.SetHeight = function (Value) {
      var eh = null;
      var fs = "";
      if ((Value > 0) && (Value < 8)) {
        this.FSize = Value;
        this.FHeight = Value;
        fs = pas.SysUtils.IntToStr(Value);
        this.RichEdit.DoEditAction$1("fontSize",fs);
        fs = this.FontSizeToEM(Value);
        eh = this.RichEdit.GetElementHandle();
        var selection = window.getSelection();
        if (selection.rangeCount > 0) {
          var range = selection.getRangeAt(0);
          const selectedElements = eh.querySelectorAll('*');
          selectedElements.forEach(element => {
            if (range.intersectsNode(element)) {
              if (element.tagName == "LI") {
                element.style.setProperty("font-size",fs);
              }
            }
          });
        };
      };
    };
    this.SetName = function (Value) {
      this.FName = Value;
      this.RichEdit.DoEditAction$1("fontName",Value);
    };
    this.SetOrderedList = function (Value) {
      if (this.FOrderedList !== Value) this.RichEdit.DoEditAction("insertorderedlist");
      this.FOrderedList = Value;
    };
    this.SetSize = function (Value) {
      if ((Value > 0) && (Value < 8)) {
        this.FSize = Value;
        this.FHeight = Value;
        this.RichEdit.DoEditAction$1("fontSize",pas.SysUtils.IntToStr(Value));
        var selection = window.getSelection();
      };
    };
    this.SetStyle = function (Value) {
      this.FStyle = rtl.refSet(Value);
      if ((pas["WEBLib.Graphics"].TFontStyle.fsBold in this.FStyle) && !this.FIsBold) {
        this.RichEdit.DoEditAction("bold");
        this.FIsBold = true;
      };
      if (!(pas["WEBLib.Graphics"].TFontStyle.fsBold in this.FStyle) && this.FIsBold) {
        this.RichEdit.DoEditAction("bold");
        this.FIsBold = false;
      };
      if ((pas["WEBLib.Graphics"].TFontStyle.fsItalic in this.FStyle) && !this.FIsItalic) {
        this.RichEdit.DoEditAction("italic");
        this.FIsItalic = true;
      };
      if (!(pas["WEBLib.Graphics"].TFontStyle.fsItalic in this.FStyle) && this.FIsItalic) {
        this.RichEdit.DoEditAction("italic");
        this.FIsItalic = false;
      };
      if ((pas["WEBLib.Graphics"].TFontStyle.fsUnderline in this.FStyle) && !this.FIsUnderline) {
        this.RichEdit.DoEditAction("underline");
        this.FIsUnderline = true;
      };
      if (!(pas["WEBLib.Graphics"].TFontStyle.fsUnderline in this.FStyle) && this.FIsUnderline) {
        this.RichEdit.DoEditAction("underline");
        this.FIsUnderline = false;
      };
      if ((pas["WEBLib.Graphics"].TFontStyle.fsStrikeOut in this.FStyle) && !this.FIsStrikeOut) {
        this.RichEdit.DoEditAction("strikethrough");
        this.FIsStrikeOut = true;
      };
      if (!(pas["WEBLib.Graphics"].TFontStyle.fsStrikeOut in this.FStyle) && this.FIsStrikeOut) {
        this.RichEdit.DoEditAction("strikethrough");
        this.FIsStrikeOut = false;
      };
    };
    this.SetUnOrderedList = function (Value) {
      if (this.FUnOrderedList !== Value) this.RichEdit.DoEditAction("insertunorderedlist");
      this.FUnOrderedList = Value;
    };
    this.AssignTo = function (Dest) {
      if (pas["WEBLib.Graphics"].TFont.isPrototypeOf(Dest)) {
        Dest.SetColor(this.FColor);
        Dest.SetName(this.FName);
        Dest.SetStyle(rtl.refSet(this.FStyle));
        Dest.SetSize(this.FSize);
      } else if ($mod.TTextAttributes.isPrototypeOf(Dest)) {
        Dest.SetColor(this.FColor);
        Dest.SetName(this.FName);
        Dest.SetStyle(rtl.refSet(this.FStyle));
      } else pas.Classes.TPersistent.AssignTo.call(this,Dest);
    };
    this.FontSizeToEM = function (Value) {
      var Result = "";
      Result = "0.63";
      var $tmp = Value;
      if ($tmp === 1) {
        Result = "0.63em"}
       else if ($tmp === 2) {
        Result = "0.82em"}
       else if ($tmp === 3) {
        Result = "1.0em"}
       else if ($tmp === 4) {
        Result = "1.13em"}
       else if ($tmp === 5) {
        Result = "1.5em"}
       else if ($tmp === 6) {
        Result = "2em"}
       else if ($tmp === 7) Result = "3em";
      return Result;
    };
    this.Create$1 = function (AOwner) {
      pas.System.TObject.Create.call(this);
      this.RichEdit = AOwner;
      this.FAlignment = pas.Classes.TAlignment.taLeftJustify;
      this.FIsBold = false;
      this.FIsItalic = false;
      this.FIsUnderline = false;
      this.FIsStrikeOut = false;
      this.FOrderedList = false;
      this.FUnOrderedList = false;
      return this;
    };
    this.Assign = function (Source) {
      if (pas["WEBLib.Graphics"].TFont.isPrototypeOf(Source)) {
        this.SetColor(Source.FColor);
        this.SetName(Source.FName);
        this.SetStyle(rtl.refSet(Source.FStyle));
        this.SetSize(Source.FSize);
      } else if ($mod.TTextAttributes.isPrototypeOf(Source)) {
        this.SetColor(Source.FColor);
        this.SetName(Source.FName);
        this.SetStyle(rtl.refSet(Source.FStyle));
        this.SetSize(Source.FSize);
      } else pas.Classes.TPersistent.Assign.call(this,Source);
    };
    this.Cut = function () {
      this.RichEdit.DoEditAction("cut");
    };
    this.Copy = function () {
      this.RichEdit.DoEditAction("copy");
    };
    this.Paste = function () {
      this.RichEdit.DoEditAction("paste");
    };
    this.Image = function () {
      this.RichEdit.DoImageAction();
    };
    this.Link = function () {
      this.RichEdit.DoLinkAction();
    };
    var $r = this.$rtti;
    $r.addMethod("Create$1",2,[["AOwner",$mod.$rtti["TCustomRichEdit"]]]);
  });
  rtl.recNewT(this,"TSelAttributes",function () {
    this.FontName = "";
    this.FontSize = "";
    this.FontColor = "";
    this.BkColor = "";
    this.IsBold = false;
    this.IsItalic = false;
    this.IsStrikeOut = false;
    this.IsUnderline = false;
    this.IsLeft = false;
    this.IsRight = false;
    this.IsCenter = false;
    this.$eq = function (b) {
      return (this.FontName === b.FontName) && (this.FontSize === b.FontSize) && (this.FontColor === b.FontColor) && (this.BkColor === b.BkColor) && (this.IsBold === b.IsBold) && (this.IsItalic === b.IsItalic) && (this.IsStrikeOut === b.IsStrikeOut) && (this.IsUnderline === b.IsUnderline) && (this.IsLeft === b.IsLeft) && (this.IsRight === b.IsRight) && (this.IsCenter === b.IsCenter);
    };
    this.$assign = function (s) {
      this.FontName = s.FontName;
      this.FontSize = s.FontSize;
      this.FontColor = s.FontColor;
      this.BkColor = s.BkColor;
      this.IsBold = s.IsBold;
      this.IsItalic = s.IsItalic;
      this.IsStrikeOut = s.IsStrikeOut;
      this.IsUnderline = s.IsUnderline;
      this.IsLeft = s.IsLeft;
      this.IsRight = s.IsRight;
      this.IsCenter = s.IsCenter;
      return this;
    };
    var $r = $mod.$rtti.$Record("TSelAttributes",{});
    $r.addField("FontName",rtl.string);
    $r.addField("FontSize",rtl.string);
    $r.addField("FontColor",rtl.string);
    $r.addField("BkColor",rtl.string);
    $r.addField("IsBold",rtl.boolean);
    $r.addField("IsItalic",rtl.boolean);
    $r.addField("IsStrikeOut",rtl.boolean);
    $r.addField("IsUnderline",rtl.boolean);
    $r.addField("IsLeft",rtl.boolean);
    $r.addField("IsRight",rtl.boolean);
    $r.addField("IsCenter",rtl.boolean);
  });
  this.$rtti.$MethodVar("TAttributesChangeEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["Attributes",this.$rtti["TSelAttributes"]]]), methodkind: 0});
  rtl.createClass(this,"TCustomRichEdit",pas["WEBLib.Menus"].TWebCustomControl,function () {
    this.$init = function () {
      pas["WEBLib.Menus"].TWebCustomControl.$init.call(this);
      this.FOwner$1 = null;
      this.FLines = null;
      this.FSelAttributes = null;
      this.FAutoSize = false;
      this.FOnSelectionChange = null;
      this.FShowFocus$1 = false;
      this.FInsertLineBreaks = false;
      this.FWantTabs = false;
      this.FReadOnly = false;
      this.FOnChange = null;
      this.FOnAttributesChanged = null;
      this.FWantImages = false;
    };
    this.$final = function () {
      this.FOwner$1 = undefined;
      this.FLines = undefined;
      this.FSelAttributes = undefined;
      this.FOnSelectionChange = undefined;
      this.FOnChange = undefined;
      this.FOnAttributesChanged = undefined;
      pas["WEBLib.Menus"].TWebCustomControl.$final.call(this);
    };
    this.GetText = function () {
      var Result = "";
      if (this.GetElementHandle() != null) this.FLines.SetTextStr(this.GetElementHandle().innerHTML);
      Result = this.FLines.GetTextStr();
      return Result;
    };
    this.GetPlainText = function () {
      var Result = "";
      Result = "";
      if (this.GetElementHandle() != null) Result = this.GetElementHandle().innerText;
      return Result;
    };
    this.SetText = function (Value) {
      this.FLines.SetTextStr(Value);
      this.UpdateElement();
    };
    this.SetSelAttributes = function (Value) {
      this.FSelAttributes.Assign(Value);
    };
    this.SetAutoSize = function (Value) {
      if (this.FAutoSize !== Value) {
        this.FAutoSize = Value;
        this.UpdateElement();
      };
    };
    this.SetReadOnly = function (Value) {
      if (this.FReadOnly !== Value) {
        this.FReadOnly = Value;
        if (this.GetElementHandle() != null) {
          if (this.FReadOnly) {
            this.GetElementHandle().contentEditable = "false"}
           else this.GetElementHandle().contentEditable = "true";
        };
      };
    };
    this.GetLines = function () {
      var Result = null;
      Result = this.FLines;
      return Result;
    };
    this.GetSelStart = function () {
      var Result = 0;
      var res = 0;
      var el = null;
      el = this.GetElementHandle();
      const selection = window.getSelection();
      const range = selection.getRangeAt(0);
      const preSelectionRange = range.cloneRange();
      preSelectionRange.selectNodeContents(el);
      preSelectionRange.setEnd(range.startContainer, range.startOffset);
      res = preSelectionRange.toString().length;
      Result = res;
      return Result;
    };
    this.SetSelStart = function (Value) {
      var el = null;
      el = this.GetElementHandle();
      const range = document.createRange();
          const sel = window.getSelection();
      
          var i = 0;
          while (i < el.childNodes.length) {
            if (Value <=el.childNodes[i].textContent.length) {
              range.setStart(el.childNodes[i], Value);
            }
            else {
               Value = Value - el.childNodes[i].textContent.length;
            }
            i++;
          }
          range.collapse(true);
          sel.removeAllRanges();
          sel.addRange(range);
    };
    this.CreateElement = function () {
      var Result = null;
      Result = document.createElement("DIV");
      Result.style.setProperty("white-space","normal");
      return Result;
    };
    this.ElementIFrameHandle = function () {
      var Result = null;
      Result = null;
      if (this.GetElementHandle() != null) {
        Result = document;
      };
      return Result;
    };
    this.UpdateElement = function () {
      var i = 0;
      var s = "";
      pas["WEBLib.Controls"].TControl.UpdateElement.call(this);
      if (this.ElementIFrameHandle() != null) ;
      if (this.GetElementHandle() != null) {
        s = "";
        for (var $l = 0, $end = this.FLines.GetCount() - 1; $l <= $end; $l++) {
          i = $l;
          if (i > 0) s = s + "<br>";
          s = s + this.FLines.Get(i);
        };
        this.GetElementHandle().innerHTML = s;
        if (this.FReadOnly) {
          this.GetElementHandle().contentEditable = "false"}
         else this.GetElementHandle().contentEditable = "true";
        this.GetElementHandle().style.setProperty("overflow","auto");
        this.GetElementHandle().style.setProperty("padding","3px");
        if (this.FBorderStyle === pas["WEBLib.Controls"].TBorderStyle.bsSingle) {
          this.GetElementHandle().style.setProperty("border","1px solid silver")}
         else this.GetElementHandle().style.setProperty("border","");
      };
    };
    this.Loaded = function () {
      var doc = null;
      var el = null;
      pas["WEBLib.Controls"].TCustomControl.Loaded.call(this);
      if (this.ElementIFrameHandle() != null) {
        doc = this.ElementIFrameHandle();
        el = this.GetElementHandle();
        el.onclick = rtl.createSafeCallback(this,"HandleDoClick");
        el.ondblclick = rtl.createSafeCallback(this,"HandleDoDblClick");
        el.addEventListener("mousedown",rtl.createSafeCallback(this,"HandleDoMouseDown"));
        el.addEventListener("mouseup",rtl.createSafeCallback(this,"HandleDoMouseUp"));
        el.addEventListener("mousemove",rtl.createSafeCallback(this,"HandleDoMouseMove"));
        el.addEventListener("keydown",rtl.createSafeCallback(this,"HandleDoKeyDown"));
        el.addEventListener("keyup",rtl.createSafeCallback(this,"HandleDoKeyUp"));
        el.addEventListener("keypress",rtl.createSafeCallback(this,"HandleDoKeyPress"));
        el.onfocus = rtl.createSafeCallback(this,"HandleDoEnter");
        el.onblur = rtl.createSafeCallback(this,"HandleDoExit");
        doc.onselectionchange = rtl.createSafeCallback(this,"HandleDoSelectionChange");
      };
    };
    this.SetShowFocus$1 = function (Value) {
      if (this.FShowFocus$1 !== Value) {
        this.FShowFocus$1 = Value;
        this.UpdateElement();
      };
    };
    this.CanShowFocus = function () {
      var Result = false;
      Result = this.FShowFocus$1;
      return Result;
    };
    this.DoHandleInput = function (Event) {
      this.DoChange();
    };
    this.DoHandlePaste = function (Event) {
      if (this.FWantImages) return;
      var pastedData = Event.clipboardData.getData('text');
      var regex = /^[a-zA-Z0-9@  `!@#$%^&*()_+\-=\[\]{};':"\\|,.<>\/?~]/;
      if (regex.test(pastedData) !== true) {
              Event.preventDefault();
      };
    };
    this.HandleDoSelectionChange = function (Event) {
      var Result = false;
      var Attr = $mod.TSelAttributes.$new();
      if (this.FOwner$1 != null) {
        rtl.as(this.FOwner$1,pas["WEBLib.Buttons"].TRichEditToolBar).SetTextColor(0x1);
        rtl.as(this.FOwner$1,pas["WEBLib.Buttons"].TRichEditToolBar).SetBackgroundColor(0x1);
      };
      Attr.$assign(this.GetSelectionAttributes(document.getSelection()));
      this.FSelAttributes.SetStyle({});
      if (Attr.IsBold) this.FSelAttributes.SetStyle(rtl.unionSet(this.FSelAttributes.FStyle,rtl.createSet(pas["WEBLib.Graphics"].TFontStyle.fsBold)));
      if (Attr.IsItalic) this.FSelAttributes.SetStyle(rtl.unionSet(this.FSelAttributes.FStyle,rtl.createSet(pas["WEBLib.Graphics"].TFontStyle.fsItalic)));
      if (Attr.IsUnderline) this.FSelAttributes.SetStyle(rtl.unionSet(this.FSelAttributes.FStyle,rtl.createSet(pas["WEBLib.Graphics"].TFontStyle.fsUnderline)));
      if (Attr.IsStrikeOut) this.FSelAttributes.SetStyle(rtl.unionSet(this.FSelAttributes.FStyle,rtl.createSet(pas["WEBLib.Graphics"].TFontStyle.fsStrikeOut)));
      if (this.FOnSelectionChange != null) this.FOnSelectionChange(this);
      Result = true;
      return Result;
    };
    this.HandleDoKeyDown = function (Event) {
      var Result = false;
      var AEvent = null;
      Result = false;
      AEvent = Event;
      if ((AEvent.ctrlKey === true) && (AEvent.key === "Control") && this.FReadOnly) {
        this.GetElementHandle().contentEditable = "false";
      };
      if ((this.GetKeyCode(AEvent.key,true) === 13) && this.FInsertLineBreaks) {
        this.InsertHTML("<br>")}
       else if ((this.GetKeyCode(AEvent.key,true) === 9) && this.FWantTabs) {
        this.InsertHTML("<span style=white-space:pre>&#9;</span>")}
       else {
        Result = true;
      };
      pas["WEBLib.Controls"].TControl.HandleDoKeyDown.apply(this,arguments);
      return Result;
    };
    this.HandleDoKeyUp = function (Event) {
      var Result = false;
      var AEvent = null;
      Result = false;
      AEvent = Event;
      if ((AEvent.ctrlKey === false) && (AEvent.key === "Control") && !this.FReadOnly) {
        this.GetElementHandle().contentEditable = "true";
      };
      pas["WEBLib.Controls"].TControl.HandleDoKeyUp.apply(this,arguments);
      return Result;
    };
    this.SetLines = function (ALines) {
      this.FLines.Assign(ALines);
    };
    this.DoLinesChange = function (Sender) {
      this.UpdateElement();
    };
    this.DoChange = function () {
      if (this.FOnChange != null) this.FOnChange(this);
    };
    this.BindEvents = function () {
      pas["WEBLib.Controls"].TCustomControl.BindEvents.call(this);
      this.GetContainer().addEventListener("input",rtl.createSafeCallback(this,"DoHandleInput"));
      this.GetContainer().addEventListener("paste",rtl.createSafeCallback(this,"DoHandlePaste"));
    };
    this.GetSelectionAttributes = function (selnode) {
      var Result = $mod.TSelAttributes.$new();
      var el = null;
      var fn = "";
      var fs = "";
      var fc = "";
      var fbk = "";
      var found = false;
      var Attr = $mod.TSelAttributes.$new();
      el = null;
      if (selnode.focusNode) {
        el = selnode.focusNode.parentElement;
      };
      do {
        found = false;
        if (el != null) {
          if (el.tagName === "B") {
            found = true;
            Attr.IsBold = true;
          };
          if (el.tagName === "I") {
            found = true;
            Attr.IsItalic = true;
          };
          if (el.tagName === "U") {
            found = true;
            Attr.IsUnderline = true;
          };
          if (el.tagName === "STRIKE") {
            found = true;
            Attr.IsStrikeOut = true;
          };
          if (el.tagName === "SPAN") {
            fbk = el.style.getPropertyValue("background-color");
            if (fbk == null) {
            fbk = ''; };
            Attr.BkColor = fbk;
            found = true;
          };
          if (el.tagName === "DIV") {
            fbk = el.style.getPropertyValue("text-align");
            if (fbk == null) {
            fbk = ''; };
            if (fbk === "center") Attr.IsCenter = true;
            if (fbk === "right") Attr.IsRight = true;
            if (fbk === "left") Attr.IsLeft = true;
            found = true;
          };
          if (el.tagName === "FONT") {
            fn = el.getAttribute("face");
            if (fn == null) {
            fn = ''; };
            fs = el.getAttribute("size");
            if (fs == null) {
            fs = ''; };
            fc = el.getAttribute("color");
            if (fc == null) {
            fc = ''; };
            fbk = el.style.getPropertyValue("background-color");
            if (fbk == null) {
            fbk = ''; };
            found = true;
            Attr.FontName = fn;
            Attr.FontColor = fc;
            if (fs !== "") {
              if (fs === "7") fs = "36";
              if (fs === "6") fs = "24";
              if (fs === "5") fs = "18";
              if (fs === "4") fs = "14";
              if (fs === "3") fs = "10";
              if (fs === "2") fs = "9";
              if (fs === "1") fs = "8";
            };
            Attr.FontSize = fs;
            Attr.BkColor = fbk;
          };
          el = el.parentElement;
          if (el === this.GetElementHandle()) found = false;
        };
      } while (found);
      Result.$assign(Attr);
      if (this.FOnAttributesChanged != null) this.FOnAttributesChanged(this,$mod.TSelAttributes.$clone(Attr));
      return Result;
    };
    this.CreateInitialize = function () {
      pas["WEBLib.Controls"].TCustomControl.CreateInitialize.call(this);
      this.FLines = pas.Classes.TStringList.$create("Create$1");
      this.FLines.FOnChange = rtl.createCallback(this,"DoLinesChange");
      this.FSelAttributes = $mod.TTextAttributes.$create("Create$1",[this]);
      this.FShowFocus$1 = true;
      this.FWantImages = true;
      this.FInsertLineBreaks = false;
      if (pas.Classes.TComponentStateItem.csDesigning in this.FComponentState) {
        this.SetWidth(400);
        this.SetHeight(300);
      };
    };
    this.Destroy = function () {
      rtl.free(this,"FLines");
      pas["WEBLib.Controls"].TCustomControl.Destroy.call(this);
    };
    this.GetContent = function () {
      var Result = "";
      Result = this.GetText();
      return Result;
    };
    this.GetSelection = function () {
      var Result = "";
      var res = "";
      res = "";
      // window.getSelection() gives you a Selection object representing the range of text selected by the user or the current position of the caret.
      if (window.getSelection) {
        res = window.getSelection().toString();
      };
      Result = res;
      return Result;
    };
    this.DoSelectAction = function (StartPosition, EndPosition) {
      var s = "";
      var sstart = 0;
      var send = 0;
      var el = null;
      var range = null;
      var textNodes = null;
      var textNode = null;
      var i = 0;
      var foundStart = false;
      var charCount = 0;
      var endCharCount = 0;
      var sel = null;
      s = this.GetID();
      sstart = StartPosition;
      send = EndPosition;
      el = document.getElementById(s);
      if (el != null) {
        range = document.createRange();
        range.selectNodeContents(el);
        textNodes = pas.Classes.TList.$create("Create$1");
        $impl.GetTextNodes(el,textNodes);
        foundStart = false;
        charCount = 0;
        endCharCount = 0;
        for (var $l = 0, $end = textNodes.GetCount() - 1; $l <= $end; $l++) {
          i = $l;
          textNode = textNodes.Get(i);
          endCharCount = charCount + textNode.nodeValue.length;
          if (!foundStart && (sstart >= charCount) && ((sstart < endCharCount) || ((sstart === endCharCount) && (i <= textNodes.GetCount())))) {
            range.setStart(textNode,sstart - charCount);
            foundStart = true;
          };
          if (foundStart && (send <= endCharCount)) {
            range.setEnd(textNode,send - charCount);
            break;
          };
          charCount = endCharCount;
        };
        sel = document.getSelection();
        sel.removeAllRanges();
        sel.addRange(range);
        textNodes = rtl.freeLoc(textNodes);
      };
    };
    this.DoEditAction = function (ActionString) {
      if (this.ElementIFrameHandle() != null) {
        this.ElementIFrameHandle().execCommand(ActionString,false);
      };
    };
    this.DoEditAction$1 = function (ActionString, Data) {
      if (this.ElementIFrameHandle() != null) {
        this.ElementIFrameHandle().execCommand(ActionString,false,Data);
      };
    };
    this.SelectText = function (StartPosition, EndPosition) {
      this.DoSelectAction(StartPosition,EndPosition);
    };
    this.SetSelectionSpacing = function (ASpacing) {
      var $Self = this;
      var sel = null;
      var range = null;
      var node = null;
      var pNode = null;
      var i = 0;
      var lh = "";
      function getNextNode(anode) {
        var Result = null;
        if (anode.firstChild != null) {
          Result = anode.firstChild}
         else while (anode != null) {
          if (anode.nextSibling != null) {
            Result = anode.nextSibling;
            break;
          };
          anode = anode.parentNode;
        };
        return Result;
      };
      sel = document.getSelection();
      if (!(sel != null)) return;
      lh = pas["WEBLib.Utils"].FormatProp("%g",pas.System.VarRecs(3,ASpacing));
      for (var $l = 0, $end = sel.rangeCount - 1; $l <= $end; $l++) {
        i = $l;
        range = sel.getRangeAt(i);
        node = range.startContainer;
        if (node.nodeName === "#text") {
          pNode = node.parentNode;
          if (pNode.nodeName === "DIV") pNode.style.setProperty("line-height",lh);
        };
        while (node !== range.endContainer) {
          node = getNextNode(node);
          if (node.nodeName === "DIV") node.style.setProperty("line-height",lh);
        };
      };
    };
    this.DoImageAction = function () {
      var url = "";
      if (this.GetElementHandle() != null) {
        url = window.prompt("Enter Image URL:","http://");
        if (pas.System.Assigned(url)) {
          if ((url !== "") && (url !== "http://") && (url !== "https://")) this.DoEditAction$1("insertImage",url);
        };
      };
    };
    this.DoLinkAction = function () {
      var url = "";
      if (this.GetElementHandle() != null) {
        url = window.prompt("Enter URL:","http://");
        if (pas.System.Assigned(url)) {
          if ((url !== "") && (url !== "http://") && (url !== "https://")) this.DoEditAction$1("createLink",url);
        };
      };
    };
    this.AppendHTML = function (HTML) {
      var sel = null;
      var range = null;
      var el = null;
      var frag = null;
      var node = null;
      var lastNode = null;
      sel = null;
      if (this.Focused()) {
        sel = document.getSelection();
        range = sel.getRangeAt(0);
        range.deleteContents();
      } else {
        range = document.createRange();
        node = this.GetElementHandle().firstChild;
        lastNode = node;
        while (node != null) {
          node = node.nextSibling;
          if (node != null) lastNode = node;
        };
        if (lastNode != null) {
          range.setStartAfter(lastNode);
          range.setEndAfter(lastNode);
        } else {
          range.setStart(this.GetElementHandle(),0);
          range.setEnd(this.GetElementHandle(),0);
        };
      };
      el = document.createElement("div");
      el.innerHTML = HTML;
      frag = document.createDocumentFragment();
      node = el.firstChild;
      while (node === el.firstChild) {
        lastNode = frag.appendChild(node);
        range.insertNode(frag);
      };
      if (lastNode != null) {
        range = range.cloneRange();
        range.setStartAfter(lastNode);
        range.collapse();
        if (sel != null) {
          sel.removeAllRanges();
          sel.addRange(range);
        };
      };
    };
    this.AppendLineBreak = function () {
      this.AppendHTML("<BR>");
    };
    this.InsertHTML = function (HTML) {
      var sel = null;
      var range = null;
      var el = null;
      var frag = null;
      var node = null;
      var lastNode = null;
      sel = null;
      if (this.Focused()) {
        sel = document.getSelection();
        range = sel.getRangeAt(0);
        range.deleteContents();
      } else {
        range = document.createRange();
        range.setStart(this.GetElementHandle(),0);
        range.setEnd(this.GetElementHandle(),0);
      };
      el = document.createElement("div");
      el.innerHTML = HTML;
      frag = document.createDocumentFragment();
      node = el.firstChild;
      while (node === el.firstChild) {
        lastNode = frag.appendChild(node);
        range.insertNode(frag);
      };
      if (lastNode != null) {
        range = range.cloneRange();
        range.setStartAfter(lastNode);
        range.collapse();
        if (sel != null) {
          sel.removeAllRanges();
          sel.addRange(range);
        };
      };
    };
    this.InsertLineBreak = function () {
      this.InsertHTML("<BR>");
    };
    this.InsertImage = function (DataURL) {
      this.DoEditAction$1("insertImage",DataURL);
    };
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
  });
  rtl.createClass(this,"TRichEdit",this.TCustomRichEdit,function () {
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
    var $r = this.$rtti;
    $r.addProperty("Align",2,pas["WEBLib.Controls"].$rtti["TAlign"],"FAlign","SetAlign",{Default: pas["WEBLib.Controls"].TAlign.alNone});
    $r.addProperty("AlignWithMargins",2,rtl.boolean,"FAlignWithMargins","SetAlignWithMargins",{Default: false});
    $r.addProperty("Anchors",2,pas["WEBLib.Controls"].$rtti["TAnchors"],"FAnchors","SetAnchors",{Default: rtl.createSet(pas["WEBLib.Controls"].TAnchorKind.akLeft,pas["WEBLib.Controls"].TAnchorKind.akTop)});
    $r.addProperty("AutoSize",2,rtl.boolean,"FAutoSize","SetAutoSize",{Default: false});
    $r.addProperty("ElementClassName",2,pas["WEBLib.Controls"].$rtti["TElementClassName"],"FElementClassName","SetElementClassName");
    $r.addProperty("ElementFont",2,pas["WEBLib.Controls"].$rtti["TElementFont"],"FElementFont","SetElementFont",{Default: pas["WEBLib.Controls"].TElementFont.efProperty});
    $r.addProperty("ElementID",3,pas["WEBLib.Controls"].$rtti["TElementID"],"GetID","SetID");
    $r.addProperty("ElementPosition",2,pas["WEBLib.Controls"].$rtti["TElementPosition"],"FElementPosition","SetElementPosition",{Default: pas["WEBLib.Controls"].TElementPosition.epAbsolute});
    $r.addProperty("Font",2,pas["WEBLib.Graphics"].$rtti["TFont"],"FFont","SetFont");
    $r.addProperty("Color",2,pas["WEBLib.Graphics"].$rtti["TColor"],"FColor","SetColor");
    $r.addProperty("DragMode",2,pas["WEBLib.Controls"].$rtti["TDragMode"],"FDragMode","SetDragMode",{Default: pas["WEBLib.Controls"].TDragMode.dmManual});
    $r.addProperty("BorderStyle",2,pas["WEBLib.Controls"].$rtti["TBorderStyle"],"FBorderStyle","SetBorderStyle",{Default: pas["WEBLib.Controls"].TBorderStyle.bsSingle});
    $r.addProperty("Height",3,rtl.longint,"GetHeight","SetHeight");
    $r.addProperty("HeightPercent",2,rtl.double,"FHeightPercent","SetHeightPercent",{Default: 100});
    $r.addProperty("HeightStyle",2,pas["WEBLib.Controls"].$rtti["TSizeStyle"],"FHeightStyle","SetHeightStyle",{Default: pas["WEBLib.Controls"].TSizeStyle.ssAbsolute});
    $r.addProperty("InsertLineBreaks",0,rtl.boolean,"FInsertLineBreaks","FInsertLineBreaks",{Default: false});
    $r.addProperty("Lines",3,pas.Classes.$rtti["TStrings"],"GetLines","SetLines");
    $r.addProperty("Margins",2,pas["WEBLib.Controls"].$rtti["TMargins"],"FMargins","SetMargins");
    $r.addProperty("ReadOnly",2,rtl.boolean,"FReadOnly","SetReadOnly",{Default: false});
    $r.addProperty("PopupMenu",0,pas["WEBLib.Menus"].$rtti["TPopupMenu"],"FPopupMenu","FPopupMenu");
    $r.addProperty("WantTabs",0,rtl.boolean,"FWantTabs","FWantTabs",{Default: false});
    $r.addProperty("Width",3,rtl.longint,"GetWidth","SetWidth");
    $r.addProperty("WidthPercent",2,rtl.double,"FWidthPercent","SetWidthPercent",{Default: 100});
    $r.addProperty("WidthStyle",2,pas["WEBLib.Controls"].$rtti["TSizeStyle"],"FWidthStyle","SetWidthStyle",{Default: pas["WEBLib.Controls"].TSizeStyle.ssAbsolute});
    $r.addProperty("OnChange",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnChange","FOnChange");
    $r.addProperty("OnClick",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnClick","FOnClick");
    $r.addProperty("OnDblClick",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnDblClick","FOnDblClick");
    $r.addProperty("OnSelectionChange",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnSelectionChange","FOnSelectionChange");
    $r.addProperty("OnKeyDown",0,pas["WEBLib.Controls"].$rtti["TKeyEvent"],"FOnKeyDown","FOnKeyDown");
    $r.addProperty("OnKeyPress",0,pas["WEBLib.Controls"].$rtti["TKeyPressEvent"],"FOnKeyPress","FOnKeyPress");
    $r.addProperty("OnKeyUp",0,pas["WEBLib.Controls"].$rtti["TKeyEvent"],"FOnKeyUp","FOnKeyUp");
    $r.addProperty("OnMouseDown",0,pas["WEBLib.Controls"].$rtti["TMouseEvent"],"FOnMouseDown","FOnMouseDown");
    $r.addProperty("OnMouseUp",0,pas["WEBLib.Controls"].$rtti["TMouseEvent"],"FOnMouseUp","FOnMouseUp");
    $r.addProperty("OnMouseMove",0,pas["WEBLib.Controls"].$rtti["TMouseMoveEvent"],"FOnMouseMove","FOnMouseMove");
    $r.addProperty("OnMouseLeave",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnMouseLeave","FOnMouseLeave");
    $r.addProperty("OnMouseEnter",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnMouseEnter","FOnMouseEnter");
    $r.addProperty("OnEnter",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnEnter","FOnEnter");
    $r.addProperty("OnExit",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnExit","FOnExit");
    $r.addProperty("OnDragDrop",0,pas["WEBLib.Controls"].$rtti["TDragDropEvent"],"FOnDragDrop","FOnDragDrop");
    $r.addProperty("OnDragOver",0,pas["WEBLib.Controls"].$rtti["TDragOverEvent"],"FOnDragOver","FOnDragOver");
    $r.addProperty("OnEndDrag",0,pas["WEBLib.Controls"].$rtti["TEndDragEvent"],"FonEndDrag","FonEndDrag");
    $r.addProperty("OnStartDrag",0,pas["WEBLib.Controls"].$rtti["TStartDragEvent"],"FOnStartDrag","FOnStartDrag");
  });
  rtl.createClass(this,"TWebRichEdit",this.TRichEdit,function () {
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
  });
  rtl.createClass(this,"TTabSet",pas["WEBLib.Menus"].TWebCustomControl,function () {
    this.$init = function () {
      pas["WEBLib.Menus"].TWebCustomControl.$init.call(this);
      this.FItems = null;
      this.FItemIndex = 0;
      this.FSelectedColor = 0;
      this.FOnChange = null;
      this.FSelectedTextColor = 0;
      this.FElementTabActiveClassName = "";
      this.FElementTabClassName = "";
      this.FElementTabItemClassName = "";
      this.FUseHash = false;
    };
    this.$final = function () {
      this.FItems = undefined;
      this.FOnChange = undefined;
      pas["WEBLib.Menus"].TWebCustomControl.$final.call(this);
    };
    this.SetSelectedColor = function (Value) {
      if (this.FSelectedColor !== Value) {
        this.FSelectedColor = Value;
        this.DoUpdateList();
      };
    };
    this.SetSelectedTextColor = function (Value) {
      if (this.FSelectedColor !== Value) {
        this.FSelectedTextColor = Value;
        this.DoUpdateList();
      };
    };
    this.CreateElement = function () {
      var Result = null;
      Result = document.createElement("SPAN");
      return Result;
    };
    this.HandleDoClick = function (Event) {
      var Result = false;
      var sid = "";
      var cid = "";
      var i = 0;
      var el = null;
      el = Event.target;
      sid = "";
      if (el.hasAttribute("id")) sid = el.getAttribute("id");
      if (sid !== "") {
        cid = this.GetID();
        if (cid === "") cid = this.FName;
        sid = pas.SysUtils.StringReplace(sid,cid + "_","",{});
        if (pas.SysUtils.TryStrToInt(sid,{get: function () {
            return i;
          }, set: function (v) {
            i = v;
          }})) {
          this.FItemIndex = i;
          this.DoUpdateList();
        };
        pas["WEBLib.Controls"].TControl.HandleDoClick.apply(this,arguments);
      };
      Result = true;
      return Result;
    };
    this.HandleDoChange = function (Event) {
      var Result = false;
      if (this.FOnChange != null) this.FOnChange(this);
      Result = true;
      return Result;
    };
    this.HandleDoItemMouseOut = function (Event) {
      var Result = false;
      var el = null;
      Result = true;
      el = Event.relatedTarget;
      if (el != null) {
        if (el.nodeName === "A") el.style.setProperty("background-color","");
      };
      return Result;
    };
    this.HandleDoItemMouseOver = function (Event) {
      var Result = false;
      var el = null;
      Result = true;
      el = Event.relatedTarget;
      if (el != null) {
        if (el.nodeName === "A") el.style.setProperty("background-color","lightgray");
      };
      return Result;
    };
    this.BindEvents = function () {
      pas["WEBLib.Controls"].TCustomControl.BindEvents.call(this);
      if (this.GetElementHandle() != null) {
        this.GetElementHandle().onchange = rtl.createSafeCallback(this,"HandleDoChange");
      };
    };
    this.SetItems = function (AItems) {
      this.FItems.Assign(AItems);
    };
    this.SetItemIndex = function (AIndex) {
      if (this.FItemIndex !== AIndex) {
        this.FItemIndex = AIndex;
        this.DoUpdateList();
      };
    };
    this.DoUpdateList = function () {
      var i = 0;
      var s = "";
      var cid = "";
      var ul = null;
      var li = null;
      var a = null;
      if (!(this.GetContainer() != null)) return;
      while (this.GetContainer().firstChild != null) this.GetContainer().removeChild(this.GetContainer().firstChild);
      this.GetContainer().setAttribute("class","");
      ul = document.createElement("UL");
      ul.setAttribute("class",this.FElementClassName);
      if (this.FElementClassName !== "") {
        ul.setAttribute("role","tablist")}
       else {
        ul.style.setProperty("list-style-type","none");
        ul.style.setProperty("margin","0");
        ul.style.setProperty("padding","0");
        ul.style.setProperty("display","inline-block");
      };
      this.GetContainer().appendChild(ul);
      for (var $l = 0, $end = this.FItems.GetCount() - 1; $l <= $end; $l++) {
        i = $l;
        s = this.FItems.Get(i);
        li = document.createElement("LI");
        if (this.FElementClassName !== "") {
          if (this.FElementTabItemClassName === "") {
            li.setAttribute("class","nav-item")}
           else li.setAttribute("class",this.FElementTabItemClassName);
        } else {
          li.style.setProperty("float","left");
          li.style.setProperty("border-bottom","1px solid lightgray");
        };
        pas["WEBLib.Controls"].SetHTMLElementFont(li,this.FFont,!((this.FElementClassName === "") && (this.FElementFont === pas["WEBLib.Controls"].TElementFont.efProperty)));
        if (this.FDragMode === pas["WEBLib.Controls"].TDragMode.dmAutomatic) li.setAttribute("draggable","true");
        ul.appendChild(li);
        if (!this.FEnabled) {
          a = document.createElement("SPAN")}
         else {
          a = document.createElement("A");
          if (this.FUseHash) a.setAttribute("href","#" + s);
        };
        a.innerHTML = s;
        cid = this.GetID();
        if (cid === "") cid = this.FName;
        a.setAttribute("id",cid + "_" + pas.SysUtils.IntToStr(i));
        if (this.FElementClassName !== "") {
          if (this.FItemIndex === i) {
            if (this.FElementTabActiveClassName === "") {
              a.setAttribute("class","nav-link active")}
             else a.setAttribute("class",this.FElementTabActiveClassName);
          } else {
            if (this.FElementTabClassName === "") {
              a.setAttribute("class","nav-link")}
             else a.setAttribute("class",this.FElementTabClassName);
          };
          a.setAttribute("role","tab");
          a.setAttribute("data-toggle","tab");
          a.setAttribute("aria-controls",s);
          if (this.FItemIndex === i) {
            a.setAttribute("aria-selected","true")}
           else a.setAttribute("aria-selected","false");
          if (this.FDragMode === pas["WEBLib.Controls"].TDragMode.dmAutomatic) a.setAttribute("draggable","false");
        } else {
          a.style.setProperty("display","block");
          a.style.setProperty("text-align","center");
          a.style.setProperty("padding","3px 15px");
          a.style.setProperty("text-decoration","none");
          a.style.setProperty("min-width","50px");
          a.style.setProperty("color","inherit");
          a.style.setProperty("font-family","inherit");
          a.style.setProperty("font-style","inherit");
          a.style.setProperty("font-size","inherit");
          if (!this.FEnabled) a.style.setProperty("pointer-events","none");
          if (this.FDragMode === pas["WEBLib.Controls"].TDragMode.dmAutomatic) a.setAttribute("draggable","false");
          if (this.FItemIndex === i) {
            if (this.FSelectedColor !== -1) a.style.setProperty("background-color",pas["WEBLib.Graphics"].ColorToHTML(this.FSelectedColor));
            if (this.FSelectedTextColor !== -1) a.style.setProperty("color",pas["WEBLib.Graphics"].ColorToHTML(this.FSelectedTextColor));
          };
        };
        li.appendChild(a);
      };
      if (!this.GetIsLinked() && (pas.Classes.TComponentStateItem.csDesigning in this.FComponentState)) this.RenderDesigning("TWebTabSet",this.GetContainer(),this,this.FItems.GetCount() === 0,"");
      this.UpdateElement();
    };
    this.Loaded = function () {
      pas["WEBLib.Controls"].TCustomControl.Loaded.call(this);
      this.DoUpdateList();
    };
    this.ItemsChanged = function (Sender) {
      this.DoUpdateList();
    };
    this.EnableDrag = function () {
      var $Self = this;
      function AddDraggableAttribute(AElement) {
        var I = 0;
        for (var $l = 0, $end = AElement.children.length - 1; $l <= $end; $l++) {
          I = $l;
          if (AElement.children.item(I).tagName === "LI") {
            AElement.children.item(I).setAttribute("draggable","true");
            AddDraggableAttribute(AElement.children.item(I));
          } else if (AElement.children.item(I).tagName === "A") {
            AElement.children.item(I).setAttribute("draggable","false")}
           else AddDraggableAttribute(AElement.children.item(I));
        };
      };
      if (!(this.GetContainer() != null)) return;
      AddDraggableAttribute(this.GetContainer());
    };
    this.DisableDrag = function () {
      var $Self = this;
      function RemoveDraggableAttribute(AElement) {
        var I = 0;
        for (var $l = 0, $end = AElement.children.length - 1; $l <= $end; $l++) {
          I = $l;
          if (AElement.children.item(I).tagName === "LI") {
            AElement.children.item(I).removeAttribute("draggable");
            RemoveDraggableAttribute(AElement.children.item(I));
          } else if (AElement.children.item(I).tagName === "A") {
            AElement.children.item(I).removeAttribute("draggable")}
           else RemoveDraggableAttribute(AElement.children.item(I));
        };
      };
      if (!(this.GetContainer() != null)) return;
      RemoveDraggableAttribute(this.GetContainer());
    };
    this.CreateInitialize = function () {
      pas["WEBLib.Controls"].TCustomControl.CreateInitialize.call(this);
      this.FItems = pas.Classes.TStringList.$create("Create$1");
      this.FItems.FOnChange = rtl.createCallback(this,"ItemsChanged");
      this.FItemIndex = 0;
      this.FSelectedColor = 12632256;
      this.FSelectedTextColor = 0;
      this.FUseHash = true;
    };
    this.Destroy = function () {
      rtl.free(this,"FItems");
      pas["WEBLib.Controls"].TCustomControl.Destroy.call(this);
    };
    this.EndUpdate = function () {
      pas["WEBLib.Controls"].TCustomControl.EndUpdate.call(this);
      this.DoUpdateList();
    };
    this.Clear = function () {
      this.FItems.Clear();
    };
    this.SelectNextTab = function (GoForward) {
      if (GoForward) {
        if (this.FItemIndex < (this.FItems.GetCount() - 1)) {
          this.SetItemIndex(this.FItemIndex + 1)}
         else this.SetItemIndex(0);
      } else {
        if (this.FItemIndex > 0) {
          this.SetItemIndex(this.FItemIndex - 1)}
         else this.SetItemIndex(this.FItems.GetCount() - 1);
      };
    };
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
    var $r = this.$rtti;
    $r.addProperty("Align",2,pas["WEBLib.Controls"].$rtti["TAlign"],"FAlign","SetAlign",{Default: pas["WEBLib.Controls"].TAlign.alNone});
    $r.addProperty("AlignWithMargins",2,rtl.boolean,"FAlignWithMargins","SetAlignWithMargins",{Default: false});
    $r.addProperty("Anchors",2,pas["WEBLib.Controls"].$rtti["TAnchors"],"FAnchors","SetAnchors",{Default: rtl.createSet(pas["WEBLib.Controls"].TAnchorKind.akLeft,pas["WEBLib.Controls"].TAnchorKind.akTop)});
    $r.addProperty("Color",2,pas["WEBLib.Graphics"].$rtti["TColor"],"FColor","SetColor");
    $r.addProperty("DragMode",2,pas["WEBLib.Controls"].$rtti["TDragMode"],"FDragMode","SetDragMode",{Default: pas["WEBLib.Controls"].TDragMode.dmManual});
    $r.addProperty("ElementClassName",2,pas["WEBLib.Controls"].$rtti["TElementClassName"],"FElementClassName","SetElementClassName");
    $r.addProperty("ElementTabClassName",0,pas["WEBLib.Controls"].$rtti["TElementClassName"],"FElementTabClassName","FElementTabClassName");
    $r.addProperty("ElementTabActiveClassName",0,pas["WEBLib.Controls"].$rtti["TElementClassName"],"FElementTabActiveClassName","FElementTabActiveClassName");
    $r.addProperty("ElementTabItemClassName",0,pas["WEBLib.Controls"].$rtti["TElementClassName"],"FElementTabItemClassName","FElementTabItemClassName");
    $r.addProperty("ElementFont",2,pas["WEBLib.Controls"].$rtti["TElementFont"],"FElementFont","SetElementFont",{Default: pas["WEBLib.Controls"].TElementFont.efProperty});
    $r.addProperty("ElementID",3,pas["WEBLib.Controls"].$rtti["TElementID"],"GetID","SetID");
    $r.addProperty("ElementPosition",2,pas["WEBLib.Controls"].$rtti["TElementPosition"],"FElementPosition","SetElementPosition",{Default: pas["WEBLib.Controls"].TElementPosition.epAbsolute});
    $r.addProperty("Enabled",2,rtl.boolean,"FEnabled","SetEnabled",{Default: true});
    $r.addProperty("Font",2,pas["WEBLib.Graphics"].$rtti["TFont"],"FFont","SetFont");
    $r.addProperty("Height",3,rtl.longint,"GetHeight","SetHeight");
    $r.addProperty("HeightPercent",2,rtl.double,"FHeightPercent","SetHeightPercent",{Default: 100});
    $r.addProperty("HeightStyle",2,pas["WEBLib.Controls"].$rtti["TSizeStyle"],"FHeightStyle","SetHeightStyle",{Default: pas["WEBLib.Controls"].TSizeStyle.ssAbsolute});
    $r.addProperty("Hint",2,rtl.string,"FHint","SetHint");
    $r.addProperty("ItemIndex",2,rtl.longint,"FItemIndex","SetItemIndex");
    $r.addProperty("Items",2,pas.Classes.$rtti["TStringList"],"FItems","SetItems");
    $r.addProperty("Left",3,rtl.longint,"GetLeft","SetLeft");
    $r.addProperty("Margins",2,pas["WEBLib.Controls"].$rtti["TMargins"],"FMargins","SetMargins");
    $r.addProperty("ParentFont",2,rtl.boolean,"FParentFont","SetParentFont",{Default: true});
    $r.addProperty("PopupMenu",0,pas["WEBLib.Menus"].$rtti["TPopupMenu"],"FPopupMenu","FPopupMenu");
    $r.addProperty("ShowHint",2,rtl.boolean,"FShowHint","SetShowHint",{Default: false});
    $r.addProperty("SelectedColor",2,pas["WEBLib.Graphics"].$rtti["TColor"],"FSelectedColor","SetSelectedColor",{Default: 12632256});
    $r.addProperty("SelectedTextColor",2,pas["WEBLib.Graphics"].$rtti["TColor"],"FSelectedTextColor","SetSelectedTextColor",{Default: 0});
    $r.addProperty("TabOrder",2,rtl.longint,"FTabOrder","SetTabOrder");
    $r.addProperty("TabStop",2,rtl.boolean,"FTabStop","SetTabStop",{Default: true});
    $r.addProperty("Top",3,rtl.longint,"GetTop","SetTop");
    $r.addProperty("UseHash",0,rtl.boolean,"FUseHash","FUseHash",{Default: true});
    $r.addProperty("Visible",2,rtl.boolean,"FVisible","SetVisible",{Default: true});
    $r.addProperty("Width",3,rtl.longint,"GetWidth","SetWidth");
    $r.addProperty("WidthPercent",2,rtl.double,"FWidthPercent","SetWidthPercent",{Default: 100});
    $r.addProperty("WidthStyle",2,pas["WEBLib.Controls"].$rtti["TSizeStyle"],"FWidthStyle","SetWidthStyle",{Default: pas["WEBLib.Controls"].TSizeStyle.ssAbsolute});
    $r.addProperty("OnChange",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnChange","FOnChange");
    $r.addProperty("OnClick",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnClick","FOnClick");
    $r.addProperty("OnDblClick",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnDblClick","FOnDblClick");
    $r.addProperty("OnKeyDown",0,pas["WEBLib.Controls"].$rtti["TKeyEvent"],"FOnKeyDown","FOnKeyDown");
    $r.addProperty("OnKeyPress",0,pas["WEBLib.Controls"].$rtti["TKeyPressEvent"],"FOnKeyPress","FOnKeyPress");
    $r.addProperty("OnKeyUp",0,pas["WEBLib.Controls"].$rtti["TKeyEvent"],"FOnKeyUp","FOnKeyUp");
    $r.addProperty("OnMouseDown",0,pas["WEBLib.Controls"].$rtti["TMouseEvent"],"FOnMouseDown","FOnMouseDown");
    $r.addProperty("OnMouseUp",0,pas["WEBLib.Controls"].$rtti["TMouseEvent"],"FOnMouseUp","FOnMouseUp");
    $r.addProperty("OnMouseMove",0,pas["WEBLib.Controls"].$rtti["TMouseMoveEvent"],"FOnMouseMove","FOnMouseMove");
    $r.addProperty("OnMouseLeave",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnMouseLeave","FOnMouseLeave");
    $r.addProperty("OnMouseEnter",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnMouseEnter","FOnMouseEnter");
    $r.addProperty("OnEnter",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnEnter","FOnEnter");
    $r.addProperty("OnExit",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnExit","FOnExit");
    $r.addProperty("OnDragDrop",0,pas["WEBLib.Controls"].$rtti["TDragDropEvent"],"FOnDragDrop","FOnDragDrop");
    $r.addProperty("OnDragOver",0,pas["WEBLib.Controls"].$rtti["TDragOverEvent"],"FOnDragOver","FOnDragOver");
    $r.addProperty("OnEndDrag",0,pas["WEBLib.Controls"].$rtti["TEndDragEvent"],"FonEndDrag","FonEndDrag");
    $r.addProperty("OnStartDrag",0,pas["WEBLib.Controls"].$rtti["TStartDragEvent"],"FOnStartDrag","FOnStartDrag");
  });
  rtl.createClass(this,"TWebTabSet",this.TTabSet,function () {
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
  });
  rtl.createClass(this,"TTabSheet",pas["WEBLib.ExtCtrls"].TCustomPanel,function () {
    this.$init = function () {
      pas["WEBLib.ExtCtrls"].TCustomPanel.$init.call(this);
      this.FTabVisible = false;
      this.FTabEnabled = false;
      this.FPosUpdating = false;
      this.FOnShow = null;
      this.FOnHide = null;
      this.FMaterialGlyph = "";
      this.FMaterialGlyphColor = 0;
      this.FMaterialGlyphType = 0;
      this.FMaterialGlyphSize = 0;
    };
    this.$final = function () {
      this.FOnShow = undefined;
      this.FOnHide = undefined;
      pas["WEBLib.ExtCtrls"].TCustomPanel.$final.call(this);
    };
    this.SetTabVisible = function (Value) {
      if (this.FTabVisible !== Value) {
        this.FTabVisible = Value;
        if (this.FParent != null) {
          if ($mod.TPageControl.isPrototypeOf(this.FParent)) rtl.as(this.FParent,$mod.TPageControl).DoUpdateList();
        };
      };
    };
    this.SetTabEnabled = function (Value) {
      if (this.FTabEnabled !== Value) {
        this.FTabEnabled = Value;
        if (this.FParent != null) {
          if ($mod.TPageControl.isPrototypeOf(this.FParent)) rtl.as(this.FParent,$mod.TPageControl).DoUpdateList();
        };
      };
    };
    this.GetPageIndex = function () {
      var Result = 0;
      var i = 0;
      var j = 0;
      var FPageControl = null;
      Result = -1;
      if ($mod.TPageControl.isPrototypeOf(this.FParent)) {
        FPageControl = rtl.as(this.FParent,$mod.TPageControl);
        j = 0;
        for (var $l = 0, $end = FPageControl.GetControlsCount() - 1; $l <= $end; $l++) {
          i = $l;
          if ($mod.TTabSheet.isPrototypeOf(FPageControl.GetControls(i))) {
            if (FPageControl.GetControls(i) === this) {
              Result = j;
            } else j += 1;
          };
        };
      };
      return Result;
    };
    this.SetPageIndex = function (Value) {
    };
    this.SetMaterialGlyph = function (Value) {
      if (this.FMaterialGlyph !== Value) {
        this.FMaterialGlyph = Value;
        if ($mod.TPageControl.isPrototypeOf(this.FParent)) rtl.as(this.FParent,$mod.TPageControl).DoUpdateList();
      };
    };
    this.SetMaterialGlyphColor = function (Value) {
      if (this.FMaterialGlyphColor !== Value) {
        this.FMaterialGlyphColor = Value;
        if ($mod.TPageControl.isPrototypeOf(this.FParent)) rtl.as(this.FParent,$mod.TPageControl).DoUpdateList();
      };
    };
    this.SetMaterialGlyphSize = function (Value) {
      if (this.FMaterialGlyphSize !== Value) {
        this.FMaterialGlyphSize = Value;
        if ($mod.TPageControl.isPrototypeOf(this.FParent)) rtl.as(this.FParent,$mod.TPageControl).DoUpdateList();
      };
    };
    this.SetMaterialGlyphType = function (Value) {
      if (this.FMaterialGlyphType !== Value) {
        this.FMaterialGlyphType = Value;
        if ($mod.TPageControl.isPrototypeOf(this.FParent)) rtl.as(this.FParent,$mod.TPageControl).DoUpdateList();
      };
    };
    this.SetCaption = function (AValue) {
      pas["WEBLib.ExtCtrls"].TCustomPanel.SetCaption.apply(this,arguments);
      if (this.FParent != null) {
        if ($mod.TPageControl.isPrototypeOf(this.FParent)) rtl.as(this.FParent,$mod.TPageControl).DoUpdateList();
      };
    };
    this.SetParent = function (AValue) {
      if ($mod.TTabSheet.isPrototypeOf(AValue)) {
        if ($mod.TPageControl.isPrototypeOf(rtl.as(AValue,$mod.TTabSheet).FParent)) AValue = rtl.as(AValue,$mod.TTabSheet).FParent;
      };
      pas["WEBLib.Controls"].TControl.SetParent.call(this,AValue);
      if (this.FParent != null) {
        if ($mod.TPageControl.isPrototypeOf(this.FParent)) {
          rtl.as(this.FParent,$mod.TPageControl).DoUpdateList();
        };
      };
    };
    this.ResetUpdate = function () {
      pas["WEBLib.ExtCtrls"].TCustomPanel.EndUpdate.call(this);
    };
    this.CreateInitialize = function () {
      pas["WEBLib.ExtCtrls"].TCustomPanel.CreateInitialize.call(this);
      this.FEnablePropagation = true;
      this.FControlStyle = rtl.unionSet(this.FControlStyle,rtl.createSet(pas["WEBLib.Controls"].TControlStyleValue.csAcceptsControls));
      this.SetColor(16777215);
      this.SetTabVisible(true);
      this.SetTabEnabled(true);
      this.SetShowCaption(false);
      this.FPosUpdating = false;
      this.FMaterialGlyphSize = 18;
      this.FMaterialGlyphType = pas["WEBLib.Controls"].TMaterialGlyphType.mgNormal;
      this.FMaterialGlyphColor = -1;
    };
    this.EndUpdate = function () {
      pas["WEBLib.ExtCtrls"].TCustomPanel.EndUpdate.call(this);
      if (this.FParent != null) {
        if ($mod.TPageControl.isPrototypeOf(this.FParent)) rtl.as(this.FParent,$mod.TPageControl).DoUpdateList();
      };
    };
    this.SetBounds = function (X, Y, AWidth, AHeight) {
      pas["WEBLib.ExtCtrls"].TCustomPanel.SetBounds.apply(this,arguments);
      if ($mod.TPageControl.isPrototypeOf(this.FParent) && !this.FPosUpdating) {
        this.FPosUpdating = true;
        rtl.as(this.FParent,$mod.TPageControl).DoUpdateList();
        this.FPosUpdating = false;
      };
    };
    this.Destroy = function () {
      var p = null;
      p = null;
      if (this.FParent != null) {
        if ($mod.TPageControl.isPrototypeOf(this.FParent)) {
          p = rtl.as(this.FParent,$mod.TPageControl);
        };
      };
      pas["WEBLib.ExtCtrls"].TCustomPanel.Destroy.call(this);
      if (p != null) {
        p.DoUpdateList();
        p.SetTabIndex(0);
      };
    };
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
    var $r = this.$rtti;
    $r.addProperty("Alignment",2,pas.Classes.$rtti["TAlignment"],"FAlignment","SetAlignment",{Default: pas.Classes.TAlignment.taCenter});
    $r.addProperty("AlignWithMargins",2,rtl.boolean,"FAlignWithMargins","SetAlignWithMargins",{Default: false});
    $r.addProperty("BorderColor",2,pas["WEBLib.Graphics"].$rtti["TColor"],"FBorderColor","SetBorderColor",{Default: 12632256});
    $r.addProperty("BorderStyle",2,pas["WEBLib.Controls"].$rtti["TBorderStyle"],"FBorderStyle","SetBorderStyle",{Default: pas["WEBLib.Controls"].TBorderStyle.bsSingle});
    $r.addProperty("Caption",2,rtl.string,"FCaption","SetCaption");
    $r.addProperty("Color",2,pas["WEBLib.Graphics"].$rtti["TColor"],"FColor","SetColor");
    $r.addProperty("DragMode",2,pas["WEBLib.Controls"].$rtti["TDragMode"],"FDragMode","SetDragMode",{Default: pas["WEBLib.Controls"].TDragMode.dmManual});
    $r.addProperty("ElementBodyClassName",0,pas["WEBLib.Controls"].$rtti["TElementClassName"],"FElementBodyClassName","FElementBodyClassName");
    $r.addProperty("ElementID",3,pas["WEBLib.Controls"].$rtti["TElementID"],"GetID","SetID");
    $r.addProperty("ElementFont",2,pas["WEBLib.Controls"].$rtti["TElementFont"],"FElementFont","SetElementFont",{Default: pas["WEBLib.Controls"].TElementFont.efProperty});
    $r.addProperty("ElementPosition",2,pas["WEBLib.Controls"].$rtti["TElementPosition"],"FElementPosition","SetElementPosition",{Default: pas["WEBLib.Controls"].TElementPosition.epAbsolute});
    $r.addProperty("Font",2,pas["WEBLib.Graphics"].$rtti["TFont"],"FFont","SetFont");
    $r.addProperty("HeightPercent",2,rtl.double,"FHeightPercent","SetHeightPercent",{Default: 100});
    $r.addProperty("HeightStyle",2,pas["WEBLib.Controls"].$rtti["TSizeStyle"],"FHeightStyle","SetHeightStyle",{Default: pas["WEBLib.Controls"].TSizeStyle.ssAbsolute});
    $r.addProperty("Margins",2,pas["WEBLib.Controls"].$rtti["TMargins"],"FMargins","SetMargins");
    $r.addProperty("MaterialGlyph",2,rtl.string,"FMaterialGlyph","SetMaterialGlyph");
    $r.addProperty("MaterialGlyphColor",2,pas["WEBLib.Graphics"].$rtti["TColor"],"FMaterialGlyphColor","SetMaterialGlyphColor",{Default: -1});
    $r.addProperty("MaterialGlyphSize",2,rtl.longint,"FMaterialGlyphSize","SetMaterialGlyphSize",{Default: 18});
    $r.addProperty("MaterialGlyphType",2,pas["WEBLib.Controls"].$rtti["TMaterialGlyphType"],"FMaterialGlyphType","SetMaterialGlyphType",{Default: pas["WEBLib.Controls"].TMaterialGlyphType.mgNormal});
    $r.addProperty("Padding",2,pas["WEBLib.Controls"].$rtti["TPadding"],"FPadding","SetPadding");
    $r.addProperty("PageIndex",7,rtl.longint,"GetPageIndex","SetPageIndex");
    $r.addProperty("ParentFont",2,rtl.boolean,"FParentFont","SetParentFont",{Default: true});
    $r.addProperty("Role",3,rtl.string,"GetRole","SetRole");
    $r.addProperty("WidthPercent",2,rtl.double,"FWidthPercent","SetWidthPercent",{Default: 100});
    $r.addProperty("WidthStyle",2,pas["WEBLib.Controls"].$rtti["TSizeStyle"],"FWidthStyle","SetWidthStyle",{Default: pas["WEBLib.Controls"].TSizeStyle.ssAbsolute});
    $r.addProperty("TabVisible",2,rtl.boolean,"FTabVisible","SetTabVisible",{Default: true});
    $r.addProperty("TabEnabled",2,rtl.boolean,"FTabEnabled","SetTabEnabled",{Default: true});
    $r.addProperty("Visible",2,rtl.boolean,"FVisible","SetVisible",{Default: true});
    $r.addProperty("OnClick",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnClick","FOnClick");
    $r.addProperty("OnDblClick",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnDblClick","FOnDblClick");
    $r.addProperty("OnHide",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnHide","FOnHide");
    $r.addProperty("OnMouseDown",0,pas["WEBLib.Controls"].$rtti["TMouseEvent"],"FOnMouseDown","FOnMouseDown");
    $r.addProperty("OnMouseMove",0,pas["WEBLib.Controls"].$rtti["TMouseMoveEvent"],"FOnMouseMove","FOnMouseMove");
    $r.addProperty("OnMouseUp",0,pas["WEBLib.Controls"].$rtti["TMouseEvent"],"FOnMouseUp","FOnMouseUp");
    $r.addProperty("OnDragDrop",0,pas["WEBLib.Controls"].$rtti["TDragDropEvent"],"FOnDragDrop","FOnDragDrop");
    $r.addProperty("OnDragOver",0,pas["WEBLib.Controls"].$rtti["TDragOverEvent"],"FOnDragOver","FOnDragOver");
    $r.addProperty("OnEndDrag",0,pas["WEBLib.Controls"].$rtti["TEndDragEvent"],"FonEndDrag","FonEndDrag");
    $r.addProperty("OnShow",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnShow","FOnShow");
    $r.addProperty("OnStartDrag",0,pas["WEBLib.Controls"].$rtti["TStartDragEvent"],"FOnStartDrag","FOnStartDrag");
  });
  rtl.createClass(this,"TWebTabSheet",this.TTabSheet,function () {
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
  });
  rtl.createClass(this,"TPageControl",pas["WEBLib.Menus"].TWebCustomControl,function () {
    this.$init = function () {
      pas["WEBLib.Menus"].TWebCustomControl.$init.call(this);
      this.FDesignTime$1 = false;
      this.FPrevTabIndex = 0;
      this.FItems = null;
      this.FTabIndex = 0;
      this.FSelectedColor = 0;
      this.FOnChange = null;
      this.FSelectedTextColor = 0;
      this.FDisabledTextColor = 0;
      this.FShowTabs = false;
      this.FOldVisible = false;
      this.FUseHash = false;
      this.FElementTabActiveClassName = "";
      this.FElementTabClassName = "";
      this.FElementTabItemClassName = "";
    };
    this.$final = function () {
      this.FItems = undefined;
      this.FOnChange = undefined;
      pas["WEBLib.Menus"].TWebCustomControl.$final.call(this);
    };
    this.SetSelectedColor = function (AValue) {
      if (this.FSelectedColor !== AValue) {
        this.FSelectedColor = AValue;
        this.DoUpdateList();
      };
    };
    this.SetItems = function (AItems) {
      this.FItems.Assign(AItems);
    };
    this.SetTabIndex = function (AIndex) {
      if (pas.Classes.TComponentStateItem.csLoading in this.FComponentState) this.FTabIndex = AIndex;
      if ((this.FTabIndex !== AIndex) && (AIndex >= 0) && (AIndex < this.PageCount())) {
        this.FTabIndex = AIndex;
        this.FPrevTabIndex = this.FTabIndex;
        this.DoUpdateList();
      };
    };
    this.GetActivePage = function () {
      var Result = null;
      var pi = 0;
      Result = null;
      pi = this.GetActivePageIndex();
      if (pi >= 0) Result = this.GetPage(pi);
      return Result;
    };
    this.GetActivePageIndex = function () {
      var Result = 0;
      Result = -1;
      if ((this.PageCount() >= 0) && (this.FTabIndex >= 0) && (this.FTabIndex < this.PageCount())) Result = this.FTabIndex;
      return Result;
    };
    this.SetActivePageIndex = function (Value) {
      if ((Value >= 0) && (Value < this.PageCount())) this.SetTabIndex(Value);
    };
    this.SetSelectedTextColor = function (Value) {
      if (this.FSelectedTextColor !== Value) {
        this.FSelectedTextColor = Value;
        this.DoUpdateList();
      };
    };
    this.SetActivePage = function (Value) {
      var i = 0;
      for (var $l = 0, $end = this.GetControlsCount() - 1; $l <= $end; $l++) {
        i = $l;
        if (this.GetControls(i) === Value) {
          this.SetActivePageIndex(i);
          break;
        };
      };
    };
    this.SetShowTabs = function (Value) {
      if (this.FShowTabs !== Value) {
        this.FShowTabs = Value;
        this.DoUpdateList();
      };
    };
    this.SetDisabledTextColor = function (Value) {
      if (this.FDisabledTextColor !== Value) {
        this.FDisabledTextColor = Value;
        this.DoUpdateList();
      };
    };
    this.GetPage = function (Index) {
      var Result = null;
      var c = 0;
      var i = 0;
      c = -1;
      Result = null;
      for (var $l = 0, $end = this.GetControlsCount() - 1; $l <= $end; $l++) {
        i = $l;
        if ($mod.TTabSheet.isPrototypeOf(this.GetControls(i))) c += 1;
        if (c === Index) {
          Result = rtl.as(this.GetControls(i),$mod.TTabSheet);
          break;
        };
      };
      return Result;
    };
    this.CreateElement = function () {
      var Result = null;
      Result = document.createElement("SPAN");
      return Result;
    };
    this.HandleDoClick = function (Event) {
      var Result = false;
      var sid = "";
      var cid = "";
      var i = 0;
      var el = null;
      var ts = null;
      el = Event.target;
      sid = "";
      if (el.hasAttribute("id")) sid = el.getAttribute("id");
      if (sid !== "") {
        cid = this.GetID();
        if (cid === "") cid = this.FName;
        sid = pas.SysUtils.StringReplace(sid,cid + "_","",{});
        if (pas.SysUtils.TryStrToInt(sid,{get: function () {
            return i;
          }, set: function (v) {
            i = v;
          }})) {
          if (this.FTabIndex !== -1) {
            ts = this.GetPage(this.FTabIndex);
            if ((ts != null) && (ts.FOnHide != null)) ts.FOnHide(ts);
          };
          this.FTabIndex = i;
          this.DoUpdateList();
          if (this.FTabIndex !== -1) {
            ts = this.GetPage(this.FTabIndex);
            if ((ts != null) && (ts.FOnShow != null)) ts.FOnShow(ts);
          };
        };
        pas["WEBLib.Controls"].TControl.HandleDoClick.apply(this,arguments);
      };
      Result = true;
      return Result;
    };
    this.HandleDoChange = function (Event) {
      var Result = false;
      if (this.FPrevTabIndex !== this.FTabIndex) {
        this.FPrevTabIndex = this.FTabIndex;
        if (this.FOnChange != null) this.FOnChange(this);
      };
      Result = true;
      return Result;
    };
    this.HandleDoItemMouseOut = function (Event) {
      var Result = false;
      var el = null;
      Result = true;
      el = Event.relatedTarget;
      if (el != null) {
        if (el.nodeName === "A") el.style.setProperty("background-color","");
      };
      return Result;
    };
    this.HandleDoItemMouseOver = function (Event) {
      var Result = false;
      var el = null;
      Result = true;
      el = Event.relatedTarget;
      if (el != null) {
        if (el.nodeName === "A") el.style.setProperty("background-color","lightgray");
      };
      return Result;
    };
    this.CanAcceptChild = function (AValue) {
      var Result = null;
      Result = pas["WEBLib.Controls"].TControl.CanAcceptChild.apply(this,arguments);
      if ((AValue != null) && !$mod.TTabSheet.isPrototypeOf(AValue)) {
        Result = this.FParent;
      };
      return Result;
    };
    this.BindEvents = function () {
      pas["WEBLib.Controls"].TCustomControl.BindEvents.call(this);
      if (this.GetElementHandle() != null) {
        this.GetElementHandle().onclick = rtl.createSafeCallback(this,"HandleDoChange");
      };
    };
    this.GetChildren = function (Proc, Root) {
      var i = 0;
      for (var $l = 0, $end = this.GetControlsCount() - 1; $l <= $end; $l++) {
        i = $l;
        if ($mod.TTabSheet.isPrototypeOf(this.GetControls(i))) {
          Proc(this.GetControls(i));
        };
      };
    };
    this.UpdateElement = function () {
      pas["WEBLib.Controls"].TControl.UpdateElement.call(this);
    };
    this.DoUpdateList = function () {
      var i = 0;
      var vistabindex = 0;
      var ena = null;
      var s = "";
      var cid = "";
      var shidden = "";
      var n = null;
      var ul = null;
      var li = null;
      var a = null;
      var tabs = null;
      var tab = null;
      var LLabel = null;
      var LHasLabel = false;
      var matclr = "";
      var icn = "";
      var noptr = "";
      var inactive = "";
      var th = 0;
      if (!(this.GetContainer() != null)) return;
      if (!(this.GetElementHandle() != null) || this.IsUpdating()) return;
      tab = null;
      if (this.GetControlsCount() > 0) {
        this.SetBorderStyle(pas["WEBLib.Controls"].TBorderStyle.bsNone);
        LLabel = this.GetElementHandle().firstChild;
        LHasLabel = (LLabel != null) && (LLabel.tagName === "DIV") && (LLabel.getAttribute("data-design") === "1");
        if (LHasLabel) {
          this.GetElementHandle().removeChild(this.GetElementHandle().firstChild);
          this.GetElementHandle().style.removeProperty("border");
        };
        tabs = pas.Classes.TStringList.$create("Create$1");
        shidden = "{#hidden#}";
        vistabindex = this.FTabIndex;
        for (var $l = 0, $end = this.GetControlsCount() - 1; $l <= $end; $l++) {
          i = $l;
          if ((pas.Classes.TComponentStateItem.csDestroying in this.GetControls(i).FComponentState) && (i <= this.FTabIndex)) vistabindex += 1;
          if ($mod.TTabSheet.isPrototypeOf(this.GetControls(i)) && !(pas.Classes.TComponentStateItem.csDestroying in this.GetControls(i).FComponentState)) {
            tab = this.GetControls(i);
            icn = "";
            if (tab.FTabEnabled) {
              ena = this}
             else ena = null;
            if (tab.FTabVisible) {
              if (tab.FMaterialGlyph !== "") {
                matclr = "";
                inactive = "";
                if (!tab.FEnabled) inactive = " md-light md-inactive";
                if (tab.FMaterialGlyphColor !== -1) matclr = ";color:" + pas["WEBLib.Graphics"].ColorToHTML(tab.FMaterialGlyphColor);
                noptr = "pointer-events:none";
                icn = '<i class="' + pas["WEBLib.Controls"].GetMaterialClass(tab.FMaterialGlyphType) + inactive + '" style="' + noptr + ";font-size:" + pas.SysUtils.IntToStr(tab.FMaterialGlyphSize) + "px" + matclr + '">' + tab.FMaterialGlyph + "</i>&nbsp;";
              };
              tabs.AddObject(icn + tab.FCaption,ena);
            } else tabs.AddObject(shidden,ena);
            tab.BeginUpdate();
            if (vistabindex === i) {
              tab.SetAlign(pas["WEBLib.Controls"].TAlign.alClient)}
             else tab.SetAlign(pas["WEBLib.Controls"].TAlign.alNone);
            tab.SetAlignWithMargins(true);
            tab.FMargins.SetLeft(0);
            tab.FMargins.SetRight(0);
            tab.FMargins.SetBottom(0);
            tab.SetVisible(vistabindex === i);
            tab.ResetUpdate();
            if (vistabindex === i) tab.GetElementHandle().parentElement.insertBefore(tab.GetElementHandle(),null);
            tab.GetElementHandle().style.setProperty("background-color",pas["WEBLib.Graphics"].ColorToHTML(tab.FColor));
          };
        };
        cid = this.GetID();
        if (cid === "") cid = this.FName;
        for (var $l1 = 0, $end1 = this.GetContainer().childNodes.length - 1; $l1 <= $end1; $l1++) {
          i = $l1;
          n = this.GetContainer().childNodes.item(i);
          if ((n != null) && (n.getAttribute("id") === (cid + "_UL"))) this.GetContainer().removeChild(n);
        };
        this.GetContainer().setAttribute("class","");
        if (!this.FEnabled) {
          this.GetElementHandle().style.setProperty("pointer-events","none")}
         else this.GetElementHandle().style.setProperty("pointer-events","auto");
        if (this.FShowTabs) {
          ul = document.createElement("UL");
          ul.setAttribute("class",this.FElementClassName);
          ul.setAttribute("id",cid + "_UL");
          if (this.FElementClassName !== "") {
            ul.setAttribute("role","tablist")}
           else {
            ul.style.setProperty("list-style-type","none");
            ul.style.setProperty("margin","0");
            ul.style.setProperty("padding","0");
            ul.style.setProperty("display","inline-block");
          };
          this.GetContainer().appendChild(ul);
        };
        for (var $l2 = 0, $end2 = tabs.GetCount() - 1; $l2 <= $end2; $l2++) {
          i = $l2;
          s = tabs.Get(i);
          if ((s !== shidden) && this.FShowTabs) {
            if (s === "") s = "tab" + pas.SysUtils.IntToStr(i);
            li = document.createElement("LI");
            if (this.FElementClassName !== "") {
              if (this.FElementTabItemClassName === "") {
                li.setAttribute("class","nav-item")}
               else li.setAttribute("class",this.FElementTabItemClassName);
            } else {
              li.style.setProperty("float","left");
              if (this.FBorderStyle !== pas["WEBLib.Controls"].TBorderStyle.bsNone) li.style.setProperty("border-bottom","1px solid lightgray");
            };
            if (tabs.GetObject(i) === null) {
              li.style.setProperty("pointer-events","none");
              li.style.setProperty("color",pas["WEBLib.Graphics"].ColorToHTML(this.FDisabledTextColor));
            };
            if (this.FDragMode === pas["WEBLib.Controls"].TDragMode.dmAutomatic) li.setAttribute("draggable","true");
            pas["WEBLib.Controls"].SetHTMLElementFont(li,this.FFont,!((this.FElementClassName === "") && (this.FElementFont === pas["WEBLib.Controls"].TElementFont.efProperty)));
            ul.appendChild(li);
            if (!this.FEnabled) {
              a = document.createElement("SPAN")}
             else {
              a = document.createElement("A");
              if (this.FUseHash) a.setAttribute("href","#" + s);
            };
            if (this.FDragMode === pas["WEBLib.Controls"].TDragMode.dmAutomatic) a.setAttribute("draggable","false");
            a.innerHTML = s;
            a.setAttribute("id",cid + "_" + pas.SysUtils.IntToStr(i));
            if (this.FElementClassName !== "") {
              if (this.FTabIndex === i) {
                if (this.FElementTabActiveClassName === "") {
                  a.setAttribute("class","nav-link active")}
                 else a.setAttribute("class",this.FElementTabActiveClassName);
              } else {
                if (this.FElementTabClassName === "") {
                  a.setAttribute("class","nav-link")}
                 else a.setAttribute("class",this.FElementTabClassName);
              };
              a.setAttribute("role","tab");
              a.setAttribute("data-toggle","tab");
              a.setAttribute("aria-controls",s);
              if (this.FTabIndex === i) {
                a.setAttribute("aria-selected","true")}
               else a.setAttribute("aria-selected","false");
            } else {
              a.style.setProperty("display","block");
              a.style.setProperty("text-align","center");
              a.style.setProperty("padding","3px 15px");
              a.style.setProperty("text-decoration","none");
              a.style.setProperty("min-width","50px");
              a.style.setProperty("color","inherit");
              a.style.setProperty("font-family","inherit");
              a.style.setProperty("font-style","inherit");
              a.style.setProperty("font-size","inherit");
              if (this.FTabIndex === i) {
                if (this.FSelectedColor !== -1) a.style.setProperty("background-color",pas["WEBLib.Graphics"].ColorToHTML(this.FSelectedColor));
                if (this.FSelectedTextColor !== -1) a.style.setProperty("color",pas["WEBLib.Graphics"].ColorToHTML(this.FSelectedTextColor));
              };
            };
            li.appendChild(a);
          };
        };
        for (var $l3 = 0, $end3 = this.GetControlsCount() - 1; $l3 <= $end3; $l3++) {
          i = $l3;
          if ($mod.TTabSheet.isPrototypeOf(this.GetControls(i))) {
            if (this.FShowTabs) {
              th = Math.round(ul.offsetHeight) - 1}
             else th = 0;
            this.GetControls(i).FMargins.SetTop(th);
            this.GetControls(i).GetElementHandle().style.setProperty("white-space","");
          };
        };
        tabs = rtl.freeLoc(tabs);
      } else {
        if (!this.GetIsLinked()) {
          this.ClearChildElements();
          if (pas.Classes.TComponentStateItem.csDesigning in this.FComponentState) {
            this.RenderDesigning("TWebPageControl",this.GetContainer(),this,true,"");
          };
        };
      };
      this.DoUpdateResize();
      if (tab != null) {
        tab.SetAlign(pas["WEBLib.Controls"].TAlign.alNone);
        tab.SetAlign(pas["WEBLib.Controls"].TAlign.alClient);
      };
      this.UpdateElement();
      if (!this.GetIsLinked() && (this.GetControlsCount() === 0)) {
        this.GetElementHandle().style.setProperty("border","1px solid lightgray");
      };
    };
    this.DoUpdateResize = function () {
      var i = 0;
      var vistabindex = 0;
      for (var $l = 0, $end = this.GetControlsCount() - 1; $l <= $end; $l++) {
        i = $l;
        if ($mod.TTabSheet.isPrototypeOf(this.GetControls(i))) this.GetControls(i).SetVisible(false);
      };
      for (var $l1 = 0, $end1 = this.GetControlsCount() - 1; $l1 <= $end1; $l1++) {
        i = $l1;
        if ($mod.TTabSheet.isPrototypeOf(this.GetControls(i))) {
          this.GetControls(i).SetVisible(true);
          this.GetControls(i).SetAlign(pas["WEBLib.Controls"].TAlign.alNone);
          this.GetControls(i).SetAlign(pas["WEBLib.Controls"].TAlign.alClient);
          this.GetControls(i).SetVisible(false);
        };
      };
      vistabindex = this.FTabIndex;
      for (var $l2 = 0, $end2 = this.GetControlsCount() - 1; $l2 <= $end2; $l2++) {
        i = $l2;
        if ((pas.Classes.TComponentStateItem.csDestroying in this.GetControls(i).FComponentState) && (i <= this.FTabIndex)) vistabindex += 1;
        if ($mod.TTabSheet.isPrototypeOf(this.GetControls(i))) {
          this.GetControls(i).SetVisible(vistabindex === i);
        };
      };
    };
    this.Loaded = function () {
      pas["WEBLib.Controls"].TCustomControl.Loaded.call(this);
      this.DoUpdateList();
      this.SetTabIndex(this.FTabIndex);
      this.FOldVisible = this.FVisible;
    };
    this.VisibleChanged = function () {
      pas["WEBLib.Controls"].TControl.VisibleChanged.call(this);
      if (this.FOldVisible !== this.FVisible) {
        this.DoUpdateList();
        this.FOldVisible = this.FVisible;
      };
    };
    this.ItemsChanged = function (Sender) {
      var i = 0;
      var ts = null;
      if ((this.PageCount() === 0) && (this.FItems.GetCount() > 0) && (this.GetElementHandle().childElementCount > 0)) {
        this.GetElementHandle().removeChild(this.GetElementHandle().firstChild);
      };
      for (var $l = 0, $end = this.FItems.GetCount() - 1; $l <= $end; $l++) {
        i = $l;
        if (this.PageCount() <= i) {
          ts = $mod.TTabSheet.$create("Create$1",[this.FOwner]);
          ts.SetParent(this);
          ts.SetName(this.FName + "sheet" + pas.SysUtils.IntToStr(i + 1));
        };
        this.GetPage(i).SetCaption(this.FItems.Get(i));
      };
      for (var $l1 = this.PageCount() - 1; $l1 >= 0; $l1--) {
        i = $l1;
        if (i >= this.FItems.GetCount()) {
          ts = this.GetPage(i);
          ts = rtl.freeLoc(ts);
        };
      };
      this.DoUpdateList();
    };
    this.SetParent = function (AValue) {
      var ts = null;
      var frm = null;
      pas["WEBLib.Controls"].TControl.SetParent.apply(this,arguments);
      if (this.FDesignTime$1) {
        frm = pas["WEBLib.Forms"].GetParentForm(this);
        this.FDesignTime$1 = false;
        ts = $mod.TWebTabSheet.$create("Create$1",[frm]);
        ts.SetParent(this);
        ts.SetCaption("Page1");
        ts.SetName(this.GetUniqueName());
        ts = $mod.TWebTabSheet.$create("Create$1",[frm]);
        ts.SetParent(this);
        ts.SetCaption("Page2");
        ts.SetName(this.GetUniqueName());
      };
      this.DoUpdateList();
    };
    this.GetUniqueName = function () {
      var Result = "";
      var i = 0;
      var id = 0;
      var found = false;
      var AName = "";
      id = 1;
      AName = this.FName + "sheet";
      do {
        Result = AName + pas.SysUtils.IntToStr(id);
        found = true;
        for (var $l = 0, $end = this.FOwner.GetComponentCount() - 1; $l <= $end; $l++) {
          i = $l;
          if (this.FOwner.GetComponent(i).FName === Result) {
            found = false;
            id += 1;
            break;
          };
        };
      } while (!found);
      return Result;
    };
    this.EnableDrag = function () {
      var $Self = this;
      function AddDraggableAttribute(AElement) {
        var I = 0;
        var tn = "";
        for (var $l = 0, $end = AElement.children.length - 1; $l <= $end; $l++) {
          I = $l;
          tn = AElement.children.item(I).tagName;
          if (tn === "LI") {
            AElement.children.item(I).setAttribute("draggable","true");
            AddDraggableAttribute(AElement.children.item(I));
          } else if (tn === "A") {
            AElement.children.item(I).setAttribute("draggable","false")}
           else if (tn === "UL") AddDraggableAttribute(AElement.children.item(I));
        };
      };
      if (!(this.GetContainer() != null)) return;
      AddDraggableAttribute(this.GetContainer());
    };
    this.DisableDrag = function () {
      var $Self = this;
      function RemoveDraggableAttribute(AElement) {
        var I = 0;
        var tn = "";
        for (var $l = 0, $end = AElement.children.length - 1; $l <= $end; $l++) {
          I = $l;
          tn = AElement.children.item(I).tagName;
          if (tn === "LI") {
            AElement.children.item(I).removeAttribute("draggable");
            RemoveDraggableAttribute(AElement.children.item(I));
          } else if (tn === "A") {
            AElement.children.item(I).removeAttribute("draggable")}
           else if (tn === "UL") RemoveDraggableAttribute(AElement.children.item(I));
        };
      };
      if (!(this.GetContainer() != null)) return;
      RemoveDraggableAttribute(this.GetContainer());
    };
    this.CreateInitialize = function () {
      pas["WEBLib.Controls"].TCustomControl.CreateInitialize.call(this);
      this.FDesignTime$1 = (pas.Classes.TComponentStateItem.csDesigning in this.FComponentState) && !((pas.Classes.TComponentStateItem.csReading in this.FOwner.FComponentState) || (pas.Classes.TComponentStateItem.csLoading in this.FOwner.FComponentState));
      this.FControlStyle = rtl.unionSet(this.FControlStyle,rtl.createSet(pas["WEBLib.Controls"].TControlStyleValue.csAcceptsControls));
      this.SetBorderStyle(pas["WEBLib.Controls"].TBorderStyle.bsNone);
      this.FItems = pas.Classes.TStringList.$create("Create$1");
      this.FItems.FOnChange = rtl.createCallback(this,"ItemsChanged");
      this.FTabIndex = 0;
      this.FPrevTabIndex = this.FTabIndex;
      this.FShowTabs = true;
      this.FUseHash = true;
      this.SetTabStop(false);
      this.FSelectedColor = 12632256;
      this.FSelectedTextColor = 0;
      if (pas.Classes.TComponentStateItem.csDesigning in this.FComponentState) {
        this.SetWidth(400);
        this.SetHeight(300);
      };
      this.FEnablePropagation = true;
      this.FOldVisible = true;
    };
    this.Destroy = function () {
      rtl.free(this,"FItems");
      pas["WEBLib.Controls"].TCustomControl.Destroy.call(this);
    };
    this.Clear = function () {
      this.FItems.Clear();
    };
    this.EndUpdate = function () {
      pas["WEBLib.Controls"].TCustomControl.EndUpdate.call(this);
      this.DoUpdateList();
    };
    this.SelectNextPage = function (GoForward) {
      if (GoForward) {
        if (this.FTabIndex < (this.PageCount() - 1)) {
          this.SetTabIndex(this.FTabIndex + 1)}
         else this.SetTabIndex(0);
      } else {
        if (this.FTabIndex > 0) {
          this.SetTabIndex(this.FTabIndex - 1)}
         else this.SetTabIndex(this.PageCount() - 1);
      };
    };
    this.PageCount = function () {
      var Result = 0;
      var i = 0;
      Result = 0;
      for (var $l = 0, $end = this.GetControlsCount() - 1; $l <= $end; $l++) {
        i = $l;
        if ($mod.TTabSheet.isPrototypeOf(this.GetControls(i))) Result += 1;
      };
      return Result;
    };
    this.PageIndexFromElement = function (AElement) {
      var Result = 0;
      var sid = "";
      var cid = "";
      var i = 0;
      Result = -1;
      sid = "";
      if (AElement.tagName === "LI") AElement = AElement.firstChild;
      if (AElement.hasAttribute("id")) sid = AElement.getAttribute("id");
      if (sid !== "") {
        cid = this.GetID();
        if (cid === "") cid = this.FName;
        sid = pas.SysUtils.StringReplace(sid,cid + "_","",{});
        if (pas.SysUtils.TryStrToInt(sid,{get: function () {
            return i;
          }, set: function (v) {
            i = v;
          }})) Result = i;
      };
      return Result;
    };
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
    var $r = this.$rtti;
    $r.addProperty("Align",2,pas["WEBLib.Controls"].$rtti["TAlign"],"FAlign","SetAlign",{Default: pas["WEBLib.Controls"].TAlign.alNone});
    $r.addProperty("AlignWithMargins",2,rtl.boolean,"FAlignWithMargins","SetAlignWithMargins",{Default: false});
    $r.addProperty("Anchors",2,pas["WEBLib.Controls"].$rtti["TAnchors"],"FAnchors","SetAnchors",{Default: rtl.createSet(pas["WEBLib.Controls"].TAnchorKind.akLeft,pas["WEBLib.Controls"].TAnchorKind.akTop)});
    $r.addProperty("BorderStyle",2,pas["WEBLib.Controls"].$rtti["TBorderStyle"],"FBorderStyle","SetBorderStyle",{Default: pas["WEBLib.Controls"].TBorderStyle.bsNone});
    $r.addProperty("ChildOrder",2,rtl.longint,"FChildOrder","SetChildOrderEx",{Default: 0});
    $r.addProperty("DisabledTextColor",2,pas["WEBLib.Graphics"].$rtti["TColor"],"FDisabledTextColor","SetDisabledTextColor",{Default: 8421504});
    $r.addProperty("DragMode",2,pas["WEBLib.Controls"].$rtti["TDragMode"],"FDragMode","SetDragMode",{Default: pas["WEBLib.Controls"].TDragMode.dmManual});
    $r.addProperty("ElementClassName",2,pas["WEBLib.Controls"].$rtti["TElementClassName"],"FElementClassName","SetElementClassName");
    $r.addProperty("ElementTabClassName",0,pas["WEBLib.Controls"].$rtti["TElementClassName"],"FElementTabClassName","FElementTabClassName");
    $r.addProperty("ElementTabActiveClassName",0,pas["WEBLib.Controls"].$rtti["TElementClassName"],"FElementTabActiveClassName","FElementTabActiveClassName");
    $r.addProperty("ElementTabItemClassName",0,pas["WEBLib.Controls"].$rtti["TElementClassName"],"FElementTabItemClassName","FElementTabItemClassName");
    $r.addProperty("ElementFont",2,pas["WEBLib.Controls"].$rtti["TElementFont"],"FElementFont","SetElementFont",{Default: pas["WEBLib.Controls"].TElementFont.efProperty});
    $r.addProperty("ElementID",3,pas["WEBLib.Controls"].$rtti["TElementID"],"GetID","SetID");
    $r.addProperty("ElementPosition",2,pas["WEBLib.Controls"].$rtti["TElementPosition"],"FElementPosition","SetElementPosition",{Default: pas["WEBLib.Controls"].TElementPosition.epAbsolute});
    $r.addProperty("Enabled",2,rtl.boolean,"FEnabled","SetEnabled",{Default: true});
    $r.addProperty("Font",2,pas["WEBLib.Graphics"].$rtti["TFont"],"FFont","SetFont");
    $r.addProperty("Height",3,rtl.longint,"GetHeight","SetHeight");
    $r.addProperty("HeightPercent",2,rtl.double,"FHeightPercent","SetHeightPercent",{Default: 100});
    $r.addProperty("HeightStyle",2,pas["WEBLib.Controls"].$rtti["TSizeStyle"],"FHeightStyle","SetHeightStyle",{Default: pas["WEBLib.Controls"].TSizeStyle.ssAbsolute});
    $r.addProperty("Hint",2,rtl.string,"FHint","SetHint");
    $r.addProperty("TabIndex",2,rtl.longint,"FTabIndex","SetTabIndex");
    $r.addProperty("Left",3,rtl.longint,"GetLeft","SetLeft");
    $r.addProperty("Margins",2,pas["WEBLib.Controls"].$rtti["TMargins"],"FMargins","SetMargins");
    $r.addProperty("ParentFont",2,rtl.boolean,"FParentFont","SetParentFont",{Default: true});
    $r.addProperty("PopupMenu",0,pas["WEBLib.Menus"].$rtti["TPopupMenu"],"FPopupMenu","FPopupMenu");
    $r.addProperty("ShowHint",2,rtl.boolean,"FShowHint","SetShowHint",{Default: false});
    $r.addProperty("ShowTabs",2,rtl.boolean,"FShowTabs","SetShowTabs",{Default: true});
    $r.addProperty("SelectedColor",2,pas["WEBLib.Graphics"].$rtti["TColor"],"FSelectedColor","SetSelectedColor",{Default: 12632256});
    $r.addProperty("SelectedTextColor",2,pas["WEBLib.Graphics"].$rtti["TColor"],"FSelectedTextColor","SetSelectedTextColor",{Default: 0});
    $r.addProperty("TabOrder",2,rtl.longint,"FTabOrder","SetTabOrder");
    $r.addProperty("TabStop",2,rtl.boolean,"FTabStop","SetTabStop",{Default: true});
    $r.addProperty("Top",3,rtl.longint,"GetTop","SetTop");
    $r.addProperty("UseHash",0,rtl.boolean,"FUseHash","FUseHash",{Default: true});
    $r.addProperty("Visible",2,rtl.boolean,"FVisible","SetVisible",{Default: true});
    $r.addProperty("Width",3,rtl.longint,"GetWidth","SetWidth");
    $r.addProperty("WidthPercent",2,rtl.double,"FWidthPercent","SetWidthPercent",{Default: 100});
    $r.addProperty("WidthStyle",2,pas["WEBLib.Controls"].$rtti["TSizeStyle"],"FWidthStyle","SetWidthStyle",{Default: pas["WEBLib.Controls"].TSizeStyle.ssAbsolute});
    $r.addProperty("OnChange",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnChange","FOnChange");
    $r.addProperty("OnClick",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnClick","FOnClick");
    $r.addProperty("OnDblClick",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnDblClick","FOnDblClick");
    $r.addProperty("OnKeyDown",0,pas["WEBLib.Controls"].$rtti["TKeyEvent"],"FOnKeyDown","FOnKeyDown");
    $r.addProperty("OnKeyPress",0,pas["WEBLib.Controls"].$rtti["TKeyPressEvent"],"FOnKeyPress","FOnKeyPress");
    $r.addProperty("OnKeyUp",0,pas["WEBLib.Controls"].$rtti["TKeyEvent"],"FOnKeyUp","FOnKeyUp");
    $r.addProperty("OnMouseDown",0,pas["WEBLib.Controls"].$rtti["TMouseEvent"],"FOnMouseDown","FOnMouseDown");
    $r.addProperty("OnMouseUp",0,pas["WEBLib.Controls"].$rtti["TMouseEvent"],"FOnMouseUp","FOnMouseUp");
    $r.addProperty("OnMouseMove",0,pas["WEBLib.Controls"].$rtti["TMouseMoveEvent"],"FOnMouseMove","FOnMouseMove");
    $r.addProperty("OnMouseLeave",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnMouseLeave","FOnMouseLeave");
    $r.addProperty("OnMouseEnter",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnMouseEnter","FOnMouseEnter");
    $r.addProperty("OnEnter",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnEnter","FOnEnter");
    $r.addProperty("OnExit",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnExit","FOnExit");
    $r.addProperty("OnDragDrop",0,pas["WEBLib.Controls"].$rtti["TDragDropEvent"],"FOnDragDrop","FOnDragDrop");
    $r.addProperty("OnDragOver",0,pas["WEBLib.Controls"].$rtti["TDragOverEvent"],"FOnDragOver","FOnDragOver");
    $r.addProperty("OnEndDrag",0,pas["WEBLib.Controls"].$rtti["TEndDragEvent"],"FonEndDrag","FonEndDrag");
    $r.addProperty("OnStartDrag",0,pas["WEBLib.Controls"].$rtti["TStartDragEvent"],"FOnStartDrag","FOnStartDrag");
  });
  rtl.createClass(this,"TWebPageControl",this.TPageControl,function () {
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
  });
  this.TProgressBarStyle = {"0": "pbstNormal", pbstNormal: 0, "1": "pbstMarquee", pbstMarquee: 1, "2": "pbstDiv", pbstDiv: 2};
  this.$rtti.$Enum("TProgressBarStyle",{minvalue: 0, maxvalue: 2, ordtype: 1, enumtype: this.TProgressBarStyle});
  this.TProgressBarValue = {"0": "pbvNone", pbvNone: 0, "1": "pbvPercentage", pbvPercentage: 1, "2": "pbvAbsolute", pbvAbsolute: 2};
  this.$rtti.$Enum("TProgressBarValue",{minvalue: 0, maxvalue: 2, ordtype: 1, enumtype: this.TProgressBarValue});
  rtl.createClass(this,"TProgressBar",pas["WEBLib.Menus"].TWebCustomControl,function () {
    this.$init = function () {
      pas["WEBLib.Menus"].TWebCustomControl.$init.call(this);
      this.FMax = 0;
      this.FMin = 0;
      this.FPosition = 0;
      this.FStyle = 0;
      this.FElementBarClassName = "";
      this.FValue = 0;
      this.FValueColor = 0;
    };
    this.SetStyle = function (Value) {
      if (this.FStyle !== Value) {
        this.FStyle = Value;
        if (this.GetElementHandle() != null) {
          this.CreateProgressElement(this.GetElementHandle());
          this.DoUpdate();
        };
      };
    };
    this.SetElementBarClassName = function (Value) {
      this.FElementBarClassName = Value;
      this.DoUpdate();
    };
    this.SetValue = function (Value) {
      this.FValue = Value;
      this.DoUpdate();
    };
    this.SetValueColor = function (Value) {
      if (this.FValueColor !== Value) {
        this.FValueColor = Value;
        this.UpdateElementVisual();
      };
    };
    this.CreateElement = function () {
      var Result = null;
      Result = document.createElement("SPAN");
      this.CreateProgressElement(Result);
      return Result;
    };
    this.SetMax = function (AValue) {
      this.FMax = AValue;
      this.DoUpdate();
    };
    this.SetMin = function (AValue) {
      this.FMin = AValue;
      this.DoUpdate();
    };
    this.SetPosition = function (AValue) {
      if ((AValue >= this.FMin) && (AValue <= this.FMax)) {
        this.FPosition = AValue;
        this.DoUpdate();
      };
    };
    this.DoUpdate = function () {
      var pvalue = 0;
      var maxvalue = 0;
      var el = null;
      var pos = 0;
      if (!(this.GetContainer() != null)) return;
      if (this.FMax !== this.FMin) {
        pos = Math.round(((this.FPosition - this.FMin) / (this.FMax - this.FMin)) * 100)}
       else pos = 0;
      if (this.GetIsLinked()) {
        if (this.GetElementHandle().tagName === "DIV") {
          if (this.GetElementHandle().getAttribute("role") === "progressbar") {
            this.GetElementHandle().style.setProperty("width",pas.SysUtils.IntToStr(pos) + "%")}
           else this.GetElementHandle().innerHTML = pas.SysUtils.IntToStr(pos);
        } else this.GetElementHandle().setAttribute("value",pas.SysUtils.IntToStr(pos));
        return;
      };
      if (this.FStyle === $mod.TProgressBarStyle.pbstDiv) {
        el = this.GetElementHandle().firstChild;
        if (this.FElementClassName !== "") {
          el.setAttribute("class",this.FElementClassName);
          this.GetElementHandle().removeAttribute("class");
        };
        el.style.setProperty("height",pas.SysUtils.IntToStr(this.GetHeight()) + "px");
        if (this.FWidthStyle === pas["WEBLib.Controls"].TSizeStyle.ssAbsolute) el.style.setProperty("width",pas.SysUtils.IntToStr(this.GetWidth()) + "px");
        el = el.firstChild;
        el.style.setProperty("background-color","#3397FD");
        if (this.FElementBarClassName !== "") el.setAttribute("class",this.FElementBarClassName);
        el.setAttribute("role","progressbar");
        el.style.setProperty("width",pas.SysUtils.IntToStr(pos) + "%");
        var $tmp = this.FValue;
        if ($tmp === $mod.TProgressBarValue.pbvPercentage) {
          el.innerHTML = pas.SysUtils.IntToStr(pos) + "%"}
         else if ($tmp === $mod.TProgressBarValue.pbvAbsolute) {
          el.innerHTML = pas.SysUtils.IntToStr(this.FPosition)}
         else if ($tmp === $mod.TProgressBarValue.pbvNone) el.innerHTML = "&nbsp;";
      } else {
        el = this.GetElementHandle().firstChild;
        el.style.setProperty("width","100%");
        el.style.setProperty("height","100%");
        pvalue = this.FPosition - this.FMin;
        maxvalue = this.FMax - this.FMin;
        el.setAttribute("max",pas.SysUtils.IntToStr(maxvalue));
        if (this.FStyle === $mod.TProgressBarStyle.pbstNormal) {
          el.setAttribute("value",pas.SysUtils.IntToStr(pvalue))}
         else el.removeAttribute("value");
      };
    };
    this.UpdateElementVisual = function () {
      var el = null;
      pas["WEBLib.Controls"].TCustomControl.UpdateElementVisual.call(this);
      if (this.FValueColor !== -1) {
        if (this.FStyle === $mod.TProgressBarStyle.pbstDiv) {
          el = this.GetElementHandle().firstChild;
          el = el.firstChild;
          el.style.setProperty("background-color",pas["WEBLib.Graphics"].ColorToHTML(this.FValueColor));
        } else {
          el = this.GetElementHandle().firstChild;
          el.style.setProperty("accent-color",pas["WEBLib.Graphics"].ColorToHTML(this.FValueColor));
        };
      };
    };
    this.CreateProgressElement = function (AElement) {
      var d = null;
      while (AElement.firstChild != null) AElement.removeChild(AElement.firstChild);
      if (this.FStyle === $mod.TProgressBarStyle.pbstDiv) {
        d = document.createElement("DIV");
        d.appendChild(document.createElement("DIV"));
      } else d = document.createElement("PROGRESS");
      AElement.appendChild(d);
    };
    this.CreateInitialize = function () {
      pas["WEBLib.Controls"].TCustomControl.CreateInitialize.call(this);
      this.FMax = 100;
      this.FMin = 0;
      this.FPosition = 0;
      this.FStyle = $mod.TProgressBarStyle.pbstNormal;
      this.FValueColor = -1;
    };
    this.AfterLoadDFMValues = function () {
      pas.Classes.TComponent.AfterLoadDFMValues.call(this);
      this.DoUpdate();
    };
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
    var $r = this.$rtti;
    $r.addProperty("Align",2,pas["WEBLib.Controls"].$rtti["TAlign"],"FAlign","SetAlign",{Default: pas["WEBLib.Controls"].TAlign.alNone});
    $r.addProperty("AlignWithMargins",2,rtl.boolean,"FAlignWithMargins","SetAlignWithMargins",{Default: false});
    $r.addProperty("Anchors",2,pas["WEBLib.Controls"].$rtti["TAnchors"],"FAnchors","SetAnchors",{Default: rtl.createSet(pas["WEBLib.Controls"].TAnchorKind.akLeft,pas["WEBLib.Controls"].TAnchorKind.akTop)});
    $r.addProperty("DragMode",2,pas["WEBLib.Controls"].$rtti["TDragMode"],"FDragMode","SetDragMode",{Default: pas["WEBLib.Controls"].TDragMode.dmManual});
    $r.addProperty("ElementBarClassName",2,rtl.string,"FElementBarClassName","SetElementBarClassName");
    $r.addProperty("ElementPosition",2,pas["WEBLib.Controls"].$rtti["TElementPosition"],"FElementPosition","SetElementPosition",{Default: pas["WEBLib.Controls"].TElementPosition.epAbsolute});
    $r.addProperty("Height",3,rtl.longint,"GetHeight","SetHeight");
    $r.addProperty("HeightPercent",2,rtl.double,"FHeightPercent","SetHeightPercent",{Default: 100});
    $r.addProperty("HeightStyle",2,pas["WEBLib.Controls"].$rtti["TSizeStyle"],"FHeightStyle","SetHeightStyle",{Default: pas["WEBLib.Controls"].TSizeStyle.ssAbsolute});
    $r.addProperty("Left",3,rtl.longint,"GetLeft","SetLeft");
    $r.addProperty("Margins",2,pas["WEBLib.Controls"].$rtti["TMargins"],"FMargins","SetMargins");
    $r.addProperty("Max",2,rtl.longint,"FMax","SetMax");
    $r.addProperty("Min",2,rtl.longint,"FMin","SetMin");
    $r.addProperty("PopupMenu",0,pas["WEBLib.Menus"].$rtti["TPopupMenu"],"FPopupMenu","FPopupMenu");
    $r.addProperty("Position",2,rtl.longint,"FPosition","SetPosition");
    $r.addProperty("Style",2,$mod.$rtti["TProgressBarStyle"],"FStyle","SetStyle");
    $r.addProperty("Top",3,rtl.longint,"GetTop","SetTop");
    $r.addProperty("Value",2,$mod.$rtti["TProgressBarValue"],"FValue","SetValue");
    $r.addProperty("ValueColor",2,pas["WEBLib.Graphics"].$rtti["TColor"],"FValueColor","SetValueColor",{Default: -1});
    $r.addProperty("Visible",2,rtl.boolean,"FVisible","SetVisible",{Default: true});
    $r.addProperty("Width",3,rtl.longint,"GetWidth","SetWidth");
    $r.addProperty("WidthPercent",2,rtl.double,"FWidthPercent","SetWidthPercent",{Default: 100});
    $r.addProperty("WidthStyle",2,pas["WEBLib.Controls"].$rtti["TSizeStyle"],"FWidthStyle","SetWidthStyle",{Default: pas["WEBLib.Controls"].TSizeStyle.ssAbsolute});
    $r.addProperty("OnDragDrop",0,pas["WEBLib.Controls"].$rtti["TDragDropEvent"],"FOnDragDrop","FOnDragDrop");
    $r.addProperty("OnDragOver",0,pas["WEBLib.Controls"].$rtti["TDragOverEvent"],"FOnDragOver","FOnDragOver");
    $r.addProperty("OnEndDrag",0,pas["WEBLib.Controls"].$rtti["TEndDragEvent"],"FonEndDrag","FonEndDrag");
    $r.addProperty("OnStartDrag",0,pas["WEBLib.Controls"].$rtti["TStartDragEvent"],"FOnStartDrag","FOnStartDrag");
  });
  rtl.createClass(this,"TWebProgressBar",this.TProgressBar,function () {
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
  });
  this.$rtti.$MethodVar("TTreeViewNodeEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["Node",pas["WEBLib.TreeNodes"].$rtti["TTreeNode"]]]), methodkind: 0});
  this.$rtti.$MethodVar("TTreeViewNodeStateEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["Node",pas["WEBLib.TreeNodes"].$rtti["TTreeNode"]],["AState",rtl.boolean]]), methodkind: 0});
  this.$rtti.$MethodVar("TTreeViewNodeAllowEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["Node",pas["WEBLib.TreeNodes"].$rtti["TTreeNode"]],["Allow",rtl.boolean,1]]), methodkind: 0});
  this.$rtti.$MethodVar("TTreeViewNodeRenderEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["Node",pas["WEBLib.TreeNodes"].$rtti["TTreeNode"]],["AElement",pas["WEBLib.Controls"].$rtti["TJSHTMLElementRecord"]]]), methodkind: 0});
  rtl.createClass(this,"TTreeView",pas["WEBLib.Menus"].TWebCustomControl,function () {
    this.$init = function () {
      pas["WEBLib.Menus"].TWebCustomControl.$init.call(this);
      this.FItems = null;
      this.FSelected = null;
      this.FOnCollapsing = null;
      this.FOnExpanding = null;
      this.FOnCollapsed = null;
      this.FOnExpanded = null;
      this.FOnClickNode = null;
      this.FOnDblClickNode = null;
      this.FOnRenderNode = null;
      this.FAutoExpand = false;
      this.FOnChange = null;
      this.FOnChanging = null;
      this.FElementNodeSelectedClassName = "";
      this.FElementNodeClassName = "";
      this.FOnClickRadio = null;
      this.FOnClickCheckBox = null;
    };
    this.$final = function () {
      this.FItems = undefined;
      this.FSelected = undefined;
      this.FOnCollapsing = undefined;
      this.FOnExpanding = undefined;
      this.FOnCollapsed = undefined;
      this.FOnExpanded = undefined;
      this.FOnClickNode = undefined;
      this.FOnDblClickNode = undefined;
      this.FOnRenderNode = undefined;
      this.FOnChange = undefined;
      this.FOnChanging = undefined;
      this.FOnClickRadio = undefined;
      this.FOnClickCheckBox = undefined;
      pas["WEBLib.Menus"].TWebCustomControl.$final.call(this);
    };
    this.SetItems = function (Value) {
      this.FItems.Assign(Value);
    };
    this.GetSelected = function () {
      var Result = null;
      Result = this.FSelected;
      return Result;
    };
    this.SetSelected = function (Value) {
      var el = null;
      if (this.FSelected != null) {
        this.FSelected.UnSelect();
        el = this.GetNodeElement(this.FSelected);
        if (el != null) {
          el.classList.toggle("TVSELECTED");
          if (this.FElementNodeSelectedClassName !== "") el.classList.toggle(this.FElementNodeSelectedClassName);
        };
      };
      this.FSelected = Value;
      if (this.FSelected != null) this.FSelected.Select();
      el = this.GetNodeElement(this.FSelected);
      if (el != null) {
        el.classList.toggle("TVSELECTED");
        if (this.FElementNodeSelectedClassName !== "") el.classList.toggle(this.FElementNodeSelectedClassName);
      };
    };
    this.SetElementNodeClassName = function (Value) {
      if (this.FElementNodeClassName !== Value) {
        this.FElementNodeClassName = Value;
        this.UpdateElement();
      };
    };
    this.SetElementNodeSelectedClassName = function (Value) {
      if (this.FElementNodeSelectedClassName !== Value) {
        this.FElementNodeSelectedClassName = Value;
        this.UpdateElement();
      };
    };
    this.GetTopItem = function () {
      var Result = null;
      var el = null;
      var tn = null;
      var h = 0.0;
      Result = null;
      if (this.FItems.GetSiblingCount() === 0) return Result;
      h = this.GetElementHandle().getBoundingClientRect().top;
      tn = this.FItems.GetSiblingFromIndex(0);
      while (tn != null) {
        el = this.GetNodeElement(tn);
        if (el.getBoundingClientRect().top >= h) {
          Result = tn;
          break;
        };
        tn = tn.GetNext();
      };
      return Result;
    };
    this.SetTopItem = function (Value) {
      var el = null;
      var h = 0.0;
      var ch = 0.0;
      if (!(Value != null)) throw pas.SysUtils.Exception.$create("Create$1",["Value is not assigned"]);
      el = this.GetNodeElement(Value);
      h = el.getBoundingClientRect().top + this.GetElementHandle().scrollTop;
      ch = this.GetElementHandle().getBoundingClientRect().top;
      this.GetElementHandle().scrollTop = Math.round(h - ch);
    };
    this.DoRenderNode = function (ANode, AElement) {
      var LElementRec = pas["WEBLib.Controls"].TJSHTMLElementRecord.$new();
      if (this.FOnRenderNode != null) {
        LElementRec.element = AElement;
        this.FOnRenderNode(this,ANode,pas["WEBLib.Controls"].TJSHTMLElementRecord.$clone(LElementRec));
      };
    };
    this.RenderControl = function (ANode, AElementName) {
      var Result = "";
      var chk = "";
      var rname = "";
      var l = 0;
      chk = "";
      if (ANode.FChecked) chk = " checked";
      rname = AElementName;
      l = rname.length;
      if (pas.System.Pos("_",rname) > 0) {
        while (rname.charAt(l - 1) !== "_") {
          l -= 1;
        };
        rname = pas.System.Copy(rname,1,l - 1);
      };
      var $tmp = ANode.FNodeType;
      if ($tmp === pas["WEBLib.TreeNodes"].TNodeType.ntCheckbox) {
        Result = '<input type="checkbox"' + chk + "></input>&nbsp;" + ANode.FText}
       else if ($tmp === pas["WEBLib.TreeNodes"].TNodeType.ntRadioButton) {
        Result = '<input type="radio"' + chk + ' name="' + rname + '"></input>&nbsp;' + ANode.FText}
       else if ($tmp === pas["WEBLib.TreeNodes"].TNodeType.ntText) Result = ANode.FText;
      return Result;
    };
    this.RenderNode = function (ANode, AElementName) {
      var Result = null;
      Result = document.createElement("SPAN");
      if (AElementName !== "") Result.setAttribute("id",AElementName);
      Result.innerHTML = this.RenderControl(ANode,AElementName);
      Result.classList.add("TVNODE");
      if (this.FElementNodeClassName !== "") Result.classList.add(this.FElementNodeClassName);
      if (this.GetSelected() != null) {
        if (this.GetSelected() === ANode) {
          Result.classList.add("TVSELECTED");
          if (this.FElementNodeSelectedClassName !== "") Result.classList.add(this.FElementNodeSelectedClassName);
        };
      };
      if (ANode.FHint !== "") Result.setAttribute("title",ANode.FHint);
      return Result;
    };
    this.RenderNodes = function () {
      var $Self = this;
      function RenderChildNode(LinkElement, ANode, AElementName) {
        var sp = null;
        var nd = null;
        sp = document.createElement("SPAN");
        if (AElementName !== "") sp.setAttribute("id",AElementName);
        sp.addEventListener("click",rtl.createSafeCallback($Self,"HandleNode"));
        sp.addEventListener("dblclick",rtl.createSafeCallback($Self,"HandleDblClick"));
        nd = document.createElement("SPAN");
        if ($Self.FAutoExpand) nd.style.setProperty("pointer-events","none");
        nd.innerHTML = $Self.RenderControl(ANode,AElementName);
        nd.classList.add("TVNODE");
        if ($Self.FElementNodeClassName !== "") nd.classList.add($Self.FElementNodeClassName);
        if (!$Self.FAutoExpand) nd.classList.add("TVNOCURSOR");
        if ($Self.GetSelected() != null) {
          if ($Self.GetSelected() === ANode) {
            nd.classList.add("TVSELECTED");
            if ($Self.FElementNodeSelectedClassName !== "") nd.classList.add($Self.FElementNodeSelectedClassName);
          };
        };
        if (ANode.FHint !== "") nd.setAttribute("title",ANode.FHint);
        LinkElement.appendChild(sp);
        sp.appendChild(nd);
        if (ANode.FIsExpanded) {
          sp.setAttribute("class","TVCARET TVCARET-DOWN")}
         else sp.setAttribute("class","TVCARET");
        $Self.DoRenderNode(ANode,nd);
      };
      function FillChilds(ParentElement, ParentName, ANode) {
        var i = 0;
        var ul = null;
        var nd = null;
        var li = null;
        var nn = "";
        ul = document.createElement("UL");
        ul.setAttribute("class","TVUL");
        ul.setAttribute("id",ParentName);
        if ($Self.FDragMode === pas["WEBLib.Controls"].TDragMode.dmAutomatic) ul.setAttribute("draggable","true");
        ParentElement.appendChild(ul);
        if (!(ANode != null)) {
          for (var $l = 0, $end = $Self.FItems.GetSiblingCount() - 1; $l <= $end; $l++) {
            i = $l;
            nn = ParentName + "_" + pas.SysUtils.IntToStr(i);
            li = document.createElement("LI");
            if ($Self.FDragMode === pas["WEBLib.Controls"].TDragMode.dmAutomatic) li.setAttribute("draggable","true");
            ul.appendChild(li);
            if ($Self.FItems.GetSiblingFromIndex(i).GetCount() > 0) {
              RenderChildNode(li,$Self.FItems.GetSiblingFromIndex(i),nn);
              FillChilds(li,nn,$Self.FItems.GetSiblingFromIndex(i));
            } else {
              nd = $Self.RenderNode($Self.FItems.GetSiblingFromIndex(i),nn);
              li.appendChild(nd);
              $Self.DoRenderNode($Self.FItems.GetSiblingFromIndex(i),nd);
              nd.addEventListener("click",rtl.createSafeCallback($Self,"HandleClick"));
              nd.addEventListener("dblclick",rtl.createSafeCallback($Self,"HandleDblClick"));
            };
          };
        } else {
          if (ANode.FIsExpanded) {
            ul.setAttribute("class","TVNESTED TVUL TVACTIVE")}
           else ul.setAttribute("class","TVNESTED TVUL");
          for (var $l1 = 0, $end1 = ANode.GetCount() - 1; $l1 <= $end1; $l1++) {
            i = $l1;
            nn = ParentName + "_" + pas.SysUtils.IntToStr(i);
            li = document.createElement("LI");
            if ($Self.FDragMode === pas["WEBLib.Controls"].TDragMode.dmAutomatic) li.setAttribute("draggable","true");
            ul.appendChild(li);
            if (ANode.GetItem(i).GetCount() > 0) {
              RenderChildNode(li,ANode.GetItem(i),nn);
              FillChilds(li,nn,ANode.GetItem(i));
            } else {
              nd = $Self.RenderNode(ANode.GetItem(i),nn);
              li.appendChild(nd);
              $Self.DoRenderNode(ANode.GetItem(i),nd);
              nd.addEventListener("click",rtl.createSafeCallback($Self,"HandleClick"));
              nd.addEventListener("dblclick",rtl.createSafeCallback($Self,"HandleDblClick"));
            };
          };
        };
      };
      if (!(this.GetElementHandle() != null)) return;
      while (this.GetElementHandle().childNodes.length > 0) this.GetElementHandle().removeChild(this.GetElementHandle().firstChild);
      FillChilds(this.GetElementHandle(),this.FormPrefix() + this.FName,null);
      this.GetElementHandle().style.setProperty("overflow","auto");
    };
    this.CreateNodes = function () {
      var Result = null;
      Result = pas["WEBLib.TreeNodes"].TTreeNodes.$create("Create$1",[this]);
      return Result;
    };
    this.CreateElement = function () {
      var Result = null;
      var tn = null;
      if (pas.Classes.TComponentStateItem.csDesigning in this.FComponentState) {
        this.BeginUpdate();
        tn = this.FItems.Add$2('<font color="#E5413C" style="font-size:10pt">&#x25FC;</font> Item 1');
        this.FItems.AddChild(tn,"Child Item 1");
        tn = this.FItems.Add$2('<font color="#F39527" style="font-size:10pt">&#x25FC;</font> Item 2');
        this.FItems.AddChild(tn,"Child Item 2");
        tn = this.FItems.Add$2('<font color="#BDC6CB" style="font-size:10pt">&#x25FC;</font> Item 3');
        this.FItems.AddChild(tn,"Child Item 3");
        this.EndUpdate();
      };
      Result = document.createElement("DIV");
      return Result;
    };
    this.DoNodesChanged = function (Sender) {
    };
    this.DoExpandedChanged = function (Sender, ANode) {
      var el = null;
      var su = null;
      var i = 0;
      if (ANode.GetCount() > 0) {
        el = this.GetNodeElement(ANode);
        if ((el != null) && (el.parentElement != null) && (el.parentElement.parentElement != null)) {
          su = el.parentElement.parentElement.querySelector(".TVNESTED");
          if (su != null) {
            if (ANode.FIsExpanded) {
              su.classList.add("TVACTIVE")}
             else su.classList.remove("TVACTIVE");
            el.parentElement.classList.toggle("TVCARET-DOWN");
          };
        };
        if (this.FAutoExpand) {
          for (var $l = 0, $end = ANode.GetCount() - 1; $l <= $end; $l++) {
            i = $l;
            if (ANode.GetItem(i).GetCount() > 0) {
              ANode.GetItem(i).SetIsExpanded(ANode.FIsExpanded);
            };
          };
        };
      };
    };
    this.DoSelectionChanged = function (Sender, ANode, IsSelected) {
      if (IsSelected) {
        this.SetSelected(ANode)}
       else this.SetSelected(null);
    };
    this.HandleNode = function (Event) {
      var Result = false;
      var el = null;
      var n = null;
      var Allow = false;
      el = Event.srcElement;
      if ((el != null) && el.hasAttribute("id")) {
        n = this.GetNodeFromID(el.getAttribute("id"));
        Allow = true;
        if (n.FIsExpanded) {
          if (this.FOnCollapsing != null) this.FOnCollapsing(this,n,{get: function () {
              return Allow;
            }, set: function (v) {
              Allow = v;
            }});
        } else {
          if (this.FOnExpanding != null) this.FOnExpanding(this,n,{get: function () {
              return Allow;
            }, set: function (v) {
              Allow = v;
            }});
        };
        if (Allow) {
          n.SetIsExpanded(!n.FIsExpanded);
          if (n.FIsExpanded) {
            if (this.FOnExpanded != null) this.FOnExpanded(this,n);
          } else {
            if (this.FOnCollapsed != null) this.FOnCollapsed(this,n);
          };
        };
        this.DoChangeSelection(n);
        if (this.FOnClickNode != null) this.FOnClickNode(this,n);
        Result = true;
        Event.preventDefault();
      } else {
        if (el != null) {
          el = el.parentElement;
          if (el.hasAttribute("id")) {
            n = this.GetNodeFromID(el.getAttribute("id"));
            this.DoChangeSelection(n);
            if (this.FOnClickNode != null) this.FOnClickNode(this,n);
            Result = true;
            Event.preventDefault();
          };
        };
      };
      return Result;
    };
    this.HandleClick = function (Event) {
      var Result = false;
      var n = null;
      var el = null;
      var chk = null;
      Result = true;
      el = Event.srcElement;
      while ((el != null) && (el.tagName !== "SPAN")) el = el.parentElement;
      if (el != null) {
        if (el.hasAttribute("id")) {
          n = this.GetNodeFromID(el.getAttribute("id"));
          if (n.FNodeType in rtl.createSet(pas["WEBLib.TreeNodes"].TNodeType.ntCheckbox,pas["WEBLib.TreeNodes"].TNodeType.ntRadioButton)) {
            chk = el.firstChild;
            if (chk.tagName === "INPUT") {
              if (chk.getAttribute("type") === "radio") {
                this.ClickRadio(n,chk.checked)}
               else this.ClickCheck(n,chk.checked);
              n.SetChecked(chk.checked);
            };
          };
          if (this.FOnClick != null) this.FOnClick(this);
          if (n != null) {
            this.DoChangeSelection(n);
            if (this.FOnClickNode != null) this.FOnClickNode(this,n);
          };
        };
      };
      return Result;
    };
    this.HandleDblClick = function (Event) {
      var Result = false;
      var n = null;
      var c = null;
      var el = null;
      var Allow = false;
      Result = true;
      el = Event.srcElement;
      while ((el != null) && (el.tagName !== "SPAN")) el = el.parentElement;
      if (el != null) {
        if (!el.hasAttribute("id")) el = el.parentElement;
        if (el.hasAttribute("id")) {
          n = this.GetNodeFromID(el.getAttribute("id"));
          if (this.FOnDblClick != null) this.FOnDblClick(this);
          if (n != null) {
            this.DoChangeSelection(n);
            Allow = true;
            c = n.GetFirstChild();
            if (c != null) {
              if (n.FIsExpanded) {
                if (this.FOnCollapsing != null) this.FOnCollapsing(this,n,{get: function () {
                    return Allow;
                  }, set: function (v) {
                    Allow = v;
                  }});
              } else {
                if (this.FOnExpanding != null) this.FOnExpanding(this,n,{get: function () {
                    return Allow;
                  }, set: function (v) {
                    Allow = v;
                  }});
              };
              if (Allow) {
                n.SetIsExpanded(!n.FIsExpanded);
                if (n.FIsExpanded) {
                  if (this.FOnExpanded != null) this.FOnExpanded(this,n);
                } else if (!n.FIsExpanded) {
                  if (this.FOnCollapsed != null) this.FOnCollapsed(this,n);
                };
              };
            };
            if ((n != null) && (this.FOnDblClickNode != null)) this.FOnDblClickNode(this,n);
          };
        };
      };
      Event.stopPropagation();
      Result = true;
      return Result;
    };
    this.ClickCheck = function (ANode, AState) {
      if (this.FOnClickCheckBox != null) this.FOnClickCheckBox(this,ANode,AState);
    };
    this.ClickRadio = function (ANode, AState) {
      if (this.FOnClickRadio != null) this.FOnClickRadio(this,ANode,AState);
    };
    this.KeyDown = function (Key, Shift) {
      var tn = null;
      var sn = null;
      var ln = null;
      var c = null;
      var Allow = false;
      tn = this.GetSelected();
      if (Key.get() === 36) {
        if (this.FItems.GetSiblingFromIndex(0) != null) this.DoChangeSelection(this.FItems.GetSiblingFromIndex(0));
      };
      if ((Key.get() === 35) && (this.FItems.GetSiblingCount() > 0)) {
        tn = this.FItems.GetSiblingFromIndex(this.FItems.GetSiblingCount() - 1);
        while (tn.FIsExpanded) {
          if (tn.GetCount() > 0) tn = tn.GetItem(tn.GetCount() - 1);
        };
        this.DoChangeSelection(tn);
      };
      if (Key.get() === 40) {
        if (tn != null) {
          if (tn.FIsExpanded && (tn.GetCount() > 0)) {
            tn = tn.GetFirstChild();
          } else tn = tn.GetNextSibling();
          if (!(tn != null)) {
            tn = this.GetSelected();
            sn = tn;
            while (!(sn.GetNextSibling() != null) && (sn.GetParent() != null)) {
              sn = sn.GetParent();
              if (sn != null) ln = sn.GetNextSibling();
              if (ln != null) {
                tn = ln;
              };
            };
          };
          if (tn != null) this.DoChangeSelection(tn);
        };
      };
      if (Key.get() === 38) {
        if (tn != null) {
          tn = tn.GetPrevSibling();
          if (tn != null) {
            sn = tn;
            while ((sn != null) && sn.FIsExpanded && (sn.GetCount() > 0)) {
              sn = sn.GetItem(tn.GetCount() - 1);
              if (sn != null) tn = sn;
            };
            this.DoChangeSelection(tn);
          } else {
            tn = this.GetSelected().GetParent();
            if (tn != null) this.DoChangeSelection(tn);
          };
        };
      };
      if (Key.get() === 39) {
        if (tn != null) {
          c = tn.GetFirstChild();
          if (c != null) {
            Allow = true;
            if (this.FOnExpanding != null) this.FOnExpanding(this,this.GetSelected(),{get: function () {
                return Allow;
              }, set: function (v) {
                Allow = v;
              }});
            if (Allow) {
              this.GetSelected().SetIsExpanded(true);
              if (this.FOnExpanded != null) this.FOnExpanded(this,this.GetSelected());
            };
          };
        };
      };
      if (Key.get() === 37) {
        if (tn != null) {
          c = tn.GetFirstChild();
          if (c != null) {
            Allow = true;
            if (this.FOnCollapsing != null) this.FOnCollapsing(this,this.GetSelected(),{get: function () {
                return Allow;
              }, set: function (v) {
                Allow = v;
              }});
            if (Allow) {
              this.GetSelected().SetIsExpanded(false);
              if (this.FOnCollapsed != null) this.FOnCollapsed(this,this.GetSelected());
            };
          };
        };
      };
      if (Key.get() in rtl.createSet(37,39,40,38)) {
        Key.set(0);
        return;
      };
      pas["WEBLib.Controls"].TControl.KeyDown.apply(this,arguments);
    };
    this.DoChangeSelection = function (NewNode) {
      var Allow = false;
      Allow = true;
      if ((this.FOnChanging != null) && (NewNode !== this.GetSelected())) this.FOnChanging(this,NewNode,{get: function () {
          return Allow;
        }, set: function (v) {
          Allow = v;
        }});
      if (Allow && (this.GetSelected() !== NewNode)) {
        this.SetSelected(NewNode);
        if (this.FOnChange != null) this.FOnChange(this,NewNode);
      };
    };
    this.EnableDrag = function () {
      var $Self = this;
      function AddDraggableAttribute(AElement) {
        var I = 0;
        for (var $l = 0, $end = AElement.children.length - 1; $l <= $end; $l++) {
          I = $l;
          if (AElement.children.item(I).tagName === "LI") {
            AElement.children.item(I).setAttribute("draggable","true");
            AddDraggableAttribute(AElement.children.item(I));
          } else AddDraggableAttribute(AElement.children.item(I));
        };
      };
      if (!(this.GetContainer() != null)) return;
      AddDraggableAttribute(this.GetContainer());
    };
    this.DisableDrag = function () {
      var $Self = this;
      function RemoveDraggableAttribute(AElement) {
        var I = 0;
        for (var $l = 0, $end = AElement.children.length - 1; $l <= $end; $l++) {
          I = $l;
          if (AElement.children.item(I).tagName === "LI") {
            AElement.children.item(I).removeAttribute("draggable");
            RemoveDraggableAttribute(AElement.children.item(I));
          } else RemoveDraggableAttribute(AElement.children.item(I));
        };
      };
      if (!(this.GetContainer() != null)) return;
      RemoveDraggableAttribute(this.GetContainer());
    };
    this.FormPrefix = function () {
      var Result = "";
      var frm = null;
      Result = "";
      frm = pas["WEBLib.Forms"].GetParentForm(this);
      if (frm != null) Result = frm.$classname;
      return Result;
    };
    this.InitCSSLibrary = function (ALibrary) {
      if (ALibrary === pas["WEBLib.Controls"].TCSSLibrary.cssBootstrap) {
        this.SetElementFont(pas["WEBLib.Controls"].TElementFont.efCSS);
      };
    };
    this.CreateInitialize = function () {
      var css = "";
      pas["WEBLib.Controls"].TCustomControl.CreateInitialize.call(this);
      this.FSelected = null;
      this.FItems = this.CreateNodes();
      this.FItems.FOnChange = rtl.createCallback(this,"DoNodesChanged");
      this.FItems.FOnExpandedChange = rtl.createCallback(this,"DoExpandedChanged");
      this.FItems.FOnSelectionChange = rtl.createCallback(this,"DoSelectionChanged");
      css = ".TVUL {" + " list-style-type: none;" + " margin: 0;" + " padding-left: 15px;" + "}" + "\r\n" + " .TVCARET {" + "  cursor: pointer;" + "  user-select: none;" + "}" + "\r\n" + ".TVCARET::before {" + 'content: "\\25B6";' + "display: inline-block;" + "margin-right: 6px;" + "}" + "\r\n" + ".TVCARET-DOWN::before {" + "transform: rotate(90deg);" + "}" + "\r\n" + ".TVNESTED {" + "  display: none;" + "}" + "\r\n" + ".TVACTIVE {" + "  display: block;" + "}" + "\r\n" + ".TVNODE {" + " padding: 3px;" + " display: inline-block;" + "}" + "\r\n" + ".TVNOCURSOR {" + " cursor: initial;" + "}" + "\r\n" + ".TVSELECTED {" + "  background-color: #0000ff;" + "  color: #ffffff;" + "}";
      this.AddControlStyle(css);
      if (pas.Classes.TComponentStateItem.csDesigning in this.FComponentState) {
        this.SetWidth(200);
        this.SetHeight(200);
      };
    };
    this.Destroy = function () {
      rtl.free(this,"FItems");
      pas["WEBLib.Controls"].TCustomControl.Destroy.call(this);
    };
    this.BeginUpdate = function () {
      pas["WEBLib.Controls"].TControl.BeginUpdate.call(this);
    };
    this.EndUpdate = function () {
      pas["WEBLib.Controls"].TCustomControl.EndUpdate.call(this);
      if (!this.IsUpdating()) {
        this.SetSelected(null);
        this.RenderNodes();
      };
    };
    this.GetNodeFromID = function (AId) {
      var Result = null;
      var s = "";
      var sl = null;
      var n = null;
      var i = 0;
      var j = 0;
      var e = 0;
      Result = null;
      s = AId;
      s = pas.System.Copy(s,((this.FormPrefix() + this.FName)).length + 2,s.length);
      if (s !== "") {
        sl = pas.Classes.TStringList.$create("Create$1");
        sl.SetDelimiter("_");
        sl.FStrictDelimiter = true;
        sl.SetDelimitedText(s);
        n = null;
        for (var $l = 0, $end = sl.GetCount() - 1; $l <= $end; $l++) {
          i = $l;
          pas.System.val$6(sl.Get(i),{get: function () {
              return j;
            }, set: function (v) {
              j = v;
            }},{get: function () {
              return e;
            }, set: function (v) {
              e = v;
            }});
          if (i === 0) {
            n = this.FItems.GetSiblingFromIndex(j)}
           else n = n.GetItem(j);
        };
        sl = rtl.freeLoc(sl);
        Result = n;
      };
      return Result;
    };
    this.GetNodeElement = function (ANode) {
      var Result = null;
      var s = "";
      var tn = null;
      Result = null;
      tn = ANode;
      if (!(tn != null)) return Result;
      s = "";
      do {
        if (s === "") {
          s = pas.SysUtils.IntToStr(tn.GetIndex())}
         else s = pas.SysUtils.IntToStr(tn.GetIndex()) + "_" + s;
        tn = tn.GetParent();
      } while (tn != null);
      s = this.FormPrefix() + this.FName + "_" + s;
      Result = document.getElementById(s);
      if (Result != null) {
        if (Result.classList.contains("TVCARET")) Result = Result.firstChild;
      };
      return Result;
    };
    this.Select = function (ANode) {
      this.SetSelected(ANode);
    };
    this.FullExpand = function () {
      var i = 0;
      for (var $l = 0, $end = this.FItems.GetSiblingCount() - 1; $l <= $end; $l++) {
        i = $l;
        this.FItems.GetSiblingFromIndex(i).Expand(true);
      };
    };
    this.FullCollapse = function () {
      var i = 0;
      for (var $l = 0, $end = this.FItems.GetSiblingCount() - 1; $l <= $end; $l++) {
        i = $l;
        this.FItems.GetSiblingFromIndex(i).Collapse(true);
      };
    };
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
    var $r = this.$rtti;
    $r.addProperty("Align",2,pas["WEBLib.Controls"].$rtti["TAlign"],"FAlign","SetAlign",{Default: pas["WEBLib.Controls"].TAlign.alNone});
    $r.addProperty("AlignWithMargins",2,rtl.boolean,"FAlignWithMargins","SetAlignWithMargins",{Default: false});
    $r.addProperty("Anchors",2,pas["WEBLib.Controls"].$rtti["TAnchors"],"FAnchors","SetAnchors",{Default: rtl.createSet(pas["WEBLib.Controls"].TAnchorKind.akLeft,pas["WEBLib.Controls"].TAnchorKind.akTop)});
    $r.addProperty("AutoExpand",0,rtl.boolean,"FAutoExpand","FAutoExpand");
    $r.addProperty("DragMode",2,pas["WEBLib.Controls"].$rtti["TDragMode"],"FDragMode","SetDragMode",{Default: pas["WEBLib.Controls"].TDragMode.dmManual});
    $r.addProperty("ElementNodeClassName",2,pas["WEBLib.Controls"].$rtti["TElementClassName"],"FElementNodeClassName","SetElementNodeClassName");
    $r.addProperty("ElementNodeSelectedClassName",2,pas["WEBLib.Controls"].$rtti["TElementClassName"],"FElementNodeSelectedClassName","SetElementNodeSelectedClassName");
    $r.addProperty("ElementClassName",2,pas["WEBLib.Controls"].$rtti["TElementClassName"],"FElementClassName","SetElementClassName");
    $r.addProperty("ElementID",3,pas["WEBLib.Controls"].$rtti["TElementID"],"GetID","SetID");
    $r.addProperty("ElementFont",2,pas["WEBLib.Controls"].$rtti["TElementFont"],"FElementFont","SetElementFont",{Default: pas["WEBLib.Controls"].TElementFont.efProperty});
    $r.addProperty("ElementPosition",2,pas["WEBLib.Controls"].$rtti["TElementPosition"],"FElementPosition","SetElementPosition",{Default: pas["WEBLib.Controls"].TElementPosition.epAbsolute});
    $r.addProperty("Font",2,pas["WEBLib.Graphics"].$rtti["TFont"],"FFont","SetFont");
    $r.addProperty("HeightPercent",2,rtl.double,"FHeightPercent","SetHeightPercent",{Default: 100});
    $r.addProperty("HeightStyle",2,pas["WEBLib.Controls"].$rtti["TSizeStyle"],"FHeightStyle","SetHeightStyle",{Default: pas["WEBLib.Controls"].TSizeStyle.ssAbsolute});
    $r.addProperty("Items",2,pas["WEBLib.TreeNodes"].$rtti["TTreeNodes"],"FItems","SetItems");
    $r.addProperty("Margins",2,pas["WEBLib.Controls"].$rtti["TMargins"],"FMargins","SetMargins");
    $r.addProperty("ParentFont",2,rtl.boolean,"FParentFont","SetParentFont",{Default: true});
    $r.addProperty("PopupMenu",0,pas["WEBLib.Menus"].$rtti["TPopupMenu"],"FPopupMenu","FPopupMenu");
    $r.addProperty("WidthPercent",2,rtl.double,"FWidthPercent","SetWidthPercent",{Default: 100});
    $r.addProperty("WidthStyle",2,pas["WEBLib.Controls"].$rtti["TSizeStyle"],"FWidthStyle","SetWidthStyle",{Default: pas["WEBLib.Controls"].TSizeStyle.ssAbsolute});
    $r.addProperty("OnClick",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnClick","FOnClick");
    $r.addProperty("OnClickCheckBox",0,$mod.$rtti["TTreeViewNodeStateEvent"],"FOnClickCheckBox","FOnClickCheckBox");
    $r.addProperty("OnClickRadio",0,$mod.$rtti["TTreeViewNodeStateEvent"],"FOnClickRadio","FOnClickRadio");
    $r.addProperty("OnDblClick",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnDblClick","FOnDblClick");
    $r.addProperty("OnClickNode",0,$mod.$rtti["TTreeViewNodeEvent"],"FOnClickNode","FOnClickNode");
    $r.addProperty("OnDblClickNode",0,$mod.$rtti["TTreeViewNodeEvent"],"FOnDblClickNode","FOnDblClickNode");
    $r.addProperty("OnRenderNode",0,$mod.$rtti["TTreeViewNodeRenderEvent"],"FOnRenderNode","FOnRenderNode");
    $r.addProperty("OnChange",0,$mod.$rtti["TTreeViewNodeEvent"],"FOnChange","FOnChange");
    $r.addProperty("OnChanging",0,$mod.$rtti["TTreeViewNodeAllowEvent"],"FOnChanging","FOnChanging");
    $r.addProperty("OnCollapsed",0,$mod.$rtti["TTreeViewNodeEvent"],"FOnCollapsed","FOnCollapsed");
    $r.addProperty("OnCollapsing",0,$mod.$rtti["TTreeViewNodeAllowEvent"],"FOnCollapsing","FOnCollapsing");
    $r.addProperty("OnExpanded",0,$mod.$rtti["TTreeViewNodeEvent"],"FOnExpanded","FOnExpanded");
    $r.addProperty("OnExpanding",0,$mod.$rtti["TTreeViewNodeAllowEvent"],"FOnExpanding","FOnExpanding");
    $r.addProperty("OnDragDrop",0,pas["WEBLib.Controls"].$rtti["TDragDropEvent"],"FOnDragDrop","FOnDragDrop");
    $r.addProperty("OnDragOver",0,pas["WEBLib.Controls"].$rtti["TDragOverEvent"],"FOnDragOver","FOnDragOver");
    $r.addProperty("OnEndDrag",0,pas["WEBLib.Controls"].$rtti["TEndDragEvent"],"FonEndDrag","FonEndDrag");
    $r.addProperty("OnStartDrag",0,pas["WEBLib.Controls"].$rtti["TStartDragEvent"],"FOnStartDrag","FOnStartDrag");
  });
  rtl.createClass(this,"TWebTreeView",this.TTreeView,function () {
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
  });
  $mod.$implcode = function () {
    rtl.createClass($impl,"TTreeNodeEx",pas["WEBLib.TreeNodes"].TTreeNode,function () {
    });
    rtl.createClass($impl,"TTreeNodesEx",pas["WEBLib.TreeNodes"].TTreeNodes,function () {
    });
    $impl.GetTextNodes = function (node, nodes) {
      var children = null;
      var i = 0;
      var j = 0;
      var childlist = null;
      if (node.nodeType === 3) {
        nodes.Add(node)}
       else {
        children = node.childNodes;
        childlist = pas.Classes.TList.$create("Create$1");
        for (var $l = 0, $end = children.length - 1; $l <= $end; $l++) {
          i = $l;
          $impl.GetTextNodes(children.item(i),childlist);
          for (var $l1 = 0, $end1 = childlist.GetCount() - 1; $l1 <= $end1; $l1++) {
            j = $l1;
            nodes.Add(childlist.Get(j));
          };
        };
        childlist = rtl.freeLoc(childlist);
      };
    };
  };
},["WEBLib.Buttons","WEBLib.Forms","WEBLib.Utils"]);
rtl.module("WEBLib.Imaging.pngImage",["System"],function () {
  "use strict";
  var $mod = this;
  $mod.$init = function () {
  };
});
rtl.module("Unit1",["System","SysUtils","Classes","WEBLib.Graphics","WEBLib.Forms","WEBLib.ComCtrls","WEBLib.Buttons","WEBLib.StdCtrls","WEBLib.StdCtrls","WEBLib.Controls","WEBLib.Imaging.pngImage","WEBLib.ExtCtrls","WEBLib.Dialogs","WEBLib.Controls"],function () {
  "use strict";
  var $mod = this;
  rtl.createClass(this,"TForm4",pas["WEBLib.Forms"].TForm,function () {
    this.$init = function () {
      pas["WEBLib.Forms"].TForm.$init.call(this);
      this.WebPageControl1 = null;
      this.WebTabsheet1 = null;
      this.WebTabsheet2 = null;
      this.WebRichEdit1 = null;
      this.WebRichEditToolBar1 = null;
      this.WebMemo1 = null;
      this.WebLabel1 = null;
      this.WebLabel2 = null;
      this.WebButton1 = null;
    };
    this.$final = function () {
      this.WebPageControl1 = undefined;
      this.WebTabsheet1 = undefined;
      this.WebTabsheet2 = undefined;
      this.WebRichEdit1 = undefined;
      this.WebRichEditToolBar1 = undefined;
      this.WebMemo1 = undefined;
      this.WebLabel1 = undefined;
      this.WebLabel2 = undefined;
      this.WebButton1 = undefined;
      pas["WEBLib.Forms"].TForm.$final.call(this);
    };
    this.WebButton1Click = function (Sender) {
      this.WebRichEdit1.GetLines().Add(this.WebMemo1.GetText());
    };
    this.LoadDFMValues = function () {
      pas["WEBLib.Forms"].TCustomForm.LoadDFMValues.call(this);
      this.WebLabel1 = pas["WEBLib.StdCtrls"].TLabel.$create("Create$2",["title"]);
      this.WebLabel2 = pas["WEBLib.StdCtrls"].TLabel.$create("Create$2",["description"]);
      this.WebPageControl1 = pas["WEBLib.ComCtrls"].TPageControl.$create("Create$1",[this]);
      this.WebTabsheet1 = pas["WEBLib.ComCtrls"].TTabSheet.$create("Create$1",[this]);
      this.WebMemo1 = pas["WEBLib.StdCtrls"].TMemo.$create("Create$1",[this]);
      this.WebTabsheet2 = pas["WEBLib.ComCtrls"].TTabSheet.$create("Create$1",[this]);
      this.WebRichEditToolBar1 = pas["WEBLib.Buttons"].TRichEditToolBar.$create("Create$2",[""]);
      this.WebRichEdit1 = pas["WEBLib.ComCtrls"].TRichEdit.$create("Create$1",[this]);
      this.WebButton1 = pas["WEBLib.StdCtrls"].TButton.$create("Create$1",[this]);
      this.WebLabel1.BeforeLoadDFMValues();
      this.WebLabel2.BeforeLoadDFMValues();
      this.WebPageControl1.BeforeLoadDFMValues();
      this.WebTabsheet1.BeforeLoadDFMValues();
      this.WebMemo1.BeforeLoadDFMValues();
      this.WebTabsheet2.BeforeLoadDFMValues();
      this.WebRichEditToolBar1.BeforeLoadDFMValues();
      this.WebRichEdit1.BeforeLoadDFMValues();
      this.WebButton1.BeforeLoadDFMValues();
      try {
        this.SetName("Form4");
        this.SetWidth(1087);
        this.SetHeight(792);
        this.FFont.FCharset = 1;
        this.FFont.SetColor(65793);
        this.FFont.SetHeight(-13);
        this.FFont.SetName("Tahoma");
        this.FFont.SetStyle({});
        this.SetFormContainer("appcontent");
        this.SetParentFont(false);
        this.WebLabel1.SetParentComponent(this);
        this.WebLabel1.SetName("WebLabel1");
        this.WebLabel1.SetLeft(67);
        this.WebLabel1.SetTop(608);
        this.WebLabel1.SetWidth(200);
        this.WebLabel1.SetHeight(16);
        this.WebLabel1.SetCaption("RichEditor control on a pagecontrol");
        this.WebLabel1.SetHeightPercent(100.000000000000000000);
        this.WebLabel1.SetWidthPercent(100.000000000000000000);
        this.WebLabel2.SetParentComponent(this);
        this.WebLabel2.SetName("WebLabel2");
        this.WebLabel2.SetLeft(67);
        this.WebLabel2.SetTop(630);
        this.WebLabel2.SetWidth(418);
        this.WebLabel2.SetHeight(32);
        this.WebLabel2.SetCaption("A page control with a TWebMemo sheet and a TWebRichEdit sheet. The TWebRichEdit is connected to a toolbar.");
        this.WebLabel2.SetHeightPercent(100.000000000000000000);
        this.WebLabel2.FWordWrap = true;
        this.WebLabel2.SetWidthStyle(pas["WEBLib.Controls"].TSizeStyle.ssPercent);
        this.WebLabel2.SetWidthPercent(100.000000000000000000);
        this.WebPageControl1.SetParentComponent(this);
        this.WebPageControl1.SetName("WebPageControl1");
        this.WebPageControl1.SetLeft(67);
        this.WebPageControl1.SetTop(24);
        this.WebPageControl1.SetWidth(974);
        this.WebPageControl1.SetHeight(657);
        this.WebPageControl1.SetTabIndex(0);
        this.WebPageControl1.SetTabOrder(0);
        this.WebTabsheet1.SetParentComponent(this.WebPageControl1);
        this.WebTabsheet1.SetName("WebTabSheet1");
        this.WebTabsheet1.SetLeft(0);
        this.WebTabsheet1.SetTop(20);
        this.WebTabsheet1.SetWidth(974);
        this.WebTabsheet1.SetHeight(637);
        this.WebTabsheet1.SetCaption("Memo");
        this.WebMemo1.SetParentComponent(this.WebTabsheet1);
        this.WebMemo1.SetName("WebMemo1");
        this.WebMemo1.SetLeft(16);
        this.WebMemo1.SetTop(16);
        this.WebMemo1.SetWidth(729);
        this.WebMemo1.SetHeight(473);
        this.WebMemo1.SetHeightPercent(100.000000000000000000);
        this.WebMemo1.FLines.BeginUpdate();
        try {
          this.WebMemo1.FLines.Clear();
          this.WebMemo1.FLines.Add("WebMemo1");
        } finally {
          this.WebMemo1.FLines.EndUpdate();
        };
        this.WebMemo1.SetSelLength(0);
        this.WebMemo1.SetSelStart(0);
        this.WebMemo1.SetWidthPercent(100.000000000000000000);
        this.WebTabsheet2.SetParentComponent(this.WebPageControl1);
        this.WebTabsheet2.SetName("WebTabSheet2");
        this.WebTabsheet2.SetLeft(0);
        this.WebTabsheet2.SetTop(20);
        this.WebTabsheet2.SetWidth(974);
        this.WebTabsheet2.SetHeight(637);
        this.WebTabsheet2.SetCaption("Richeditor");
        this.WebRichEditToolBar1.SetParentComponent(this.WebTabsheet2);
        this.WebRichEditToolBar1.SetName("WebRichEditToolBar1");
        this.WebRichEditToolBar1.SetLeft(16);
        this.WebRichEditToolBar1.SetTop(16);
        this.WebRichEditToolBar1.SetWidth(729);
        this.WebRichEditToolBar1.SetHeight(32);
        this.WebRichEditToolBar1.SetElementClassName("");
        this.WebRichEditToolBar1.FHints.BeginUpdate();
        try {
          this.WebRichEditToolBar1.FHints.Clear();
          this.WebRichEditToolBar1.FHints.Add("Bold");
          this.WebRichEditToolBar1.FHints.Add("Italic");
          this.WebRichEditToolBar1.FHints.Add("Underline");
          this.WebRichEditToolBar1.FHints.Add("Strike Throught");
          this.WebRichEditToolBar1.FHints.Add("Text Color");
          this.WebRichEditToolBar1.FHints.Add("Background Color");
          this.WebRichEditToolBar1.FHints.Add("Align lef");
          this.WebRichEditToolBar1.FHints.Add("Align center");
          this.WebRichEditToolBar1.FHints.Add("Align right");
          this.WebRichEditToolBar1.FHints.Add("Numbered list");
          this.WebRichEditToolBar1.FHints.Add("List");
        } finally {
          this.WebRichEditToolBar1.FHints.EndUpdate();
        };
        this.WebRichEditToolBar1.SetRichEdit(this.WebRichEdit1);
        this.WebRichEdit1.SetParentComponent(this.WebTabsheet2);
        this.WebRichEdit1.SetName("WebRichEdit1");
        this.WebRichEdit1.SetLeft(16);
        this.WebRichEdit1.SetTop(54);
        this.WebRichEdit1.SetWidth(955);
        this.WebRichEdit1.SetHeight(579);
        this.WebRichEdit1.SetBorderStyle(pas["WEBLib.Controls"].TBorderStyle.bsSingle);
        this.WebRichEdit1.SetColor(16777215);
        this.WebButton1.SetParentComponent(this);
        this.WebButton1.SetName("WebButton1");
        this.WebButton1.SetLeft(480);
        this.WebButton1.SetTop(720);
        this.WebButton1.SetWidth(96);
        this.WebButton1.SetHeight(25);
        this.WebButton1.SetCaption("WebButton1");
        this.WebButton1.SetChildOrderEx(3);
        this.WebButton1.SetHeightPercent(100.000000000000000000);
        this.WebButton1.SetWidthPercent(100.000000000000000000);
        this.SetEvent$1(this.WebButton1,this,"OnClick","WebButton1Click");
      } finally {
        this.WebLabel1.AfterLoadDFMValues();
        this.WebLabel2.AfterLoadDFMValues();
        this.WebPageControl1.AfterLoadDFMValues();
        this.WebTabsheet1.AfterLoadDFMValues();
        this.WebMemo1.AfterLoadDFMValues();
        this.WebTabsheet2.AfterLoadDFMValues();
        this.WebRichEditToolBar1.AfterLoadDFMValues();
        this.WebRichEdit1.AfterLoadDFMValues();
        this.WebButton1.AfterLoadDFMValues();
      };
    };
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
    var $r = this.$rtti;
    $r.addField("WebPageControl1",pas["WEBLib.ComCtrls"].$rtti["TPageControl"]);
    $r.addField("WebTabsheet1",pas["WEBLib.ComCtrls"].$rtti["TTabSheet"]);
    $r.addField("WebTabsheet2",pas["WEBLib.ComCtrls"].$rtti["TTabSheet"]);
    $r.addField("WebRichEdit1",pas["WEBLib.ComCtrls"].$rtti["TRichEdit"]);
    $r.addField("WebRichEditToolBar1",pas["WEBLib.Buttons"].$rtti["TRichEditToolBar"]);
    $r.addField("WebMemo1",pas["WEBLib.StdCtrls"].$rtti["TMemo"]);
    $r.addField("WebLabel1",pas["WEBLib.StdCtrls"].$rtti["TLabel"]);
    $r.addField("WebLabel2",pas["WEBLib.StdCtrls"].$rtti["TLabel"]);
    $r.addField("WebButton1",pas["WEBLib.StdCtrls"].$rtti["TButton"]);
    $r.addMethod("WebButton1Click",0,[["Sender",pas.System.$rtti["TObject"]]]);
  });
  this.Form4 = null;
});
rtl.module("program",["System","WEBLib.Forms","Unit1"],function () {
  "use strict";
  var $mod = this;
  $mod.$implcode = function () {
    pas.System.$rtti["TArray<RTTI.TValue>"].eltype = pas.RTTI.$rtti["TValue"];
    pas.System.$rtti["TArray<RTTI.TRttiType>"].eltype = pas.RTTI.$rtti["TRttiType"];
    pas.System.$rtti["TArray<RTTI.TRttiField>"].eltype = pas.RTTI.$rtti["TRttiField"];
    pas.System.$rtti["TArray<RTTI.TRttiParameter>"].eltype = pas.RTTI.$rtti["TRttiParameter"];
    pas.System.$rtti["TArray<RTTI.TRttiMethod>"].eltype = pas.RTTI.$rtti["TRttiMethod"];
    pas.System.$rtti["TArray<RTTI.TRttiProperty>"].eltype = pas.RTTI.$rtti["TRttiProperty"];
    pas.System.$rtti["TArray<Classes.TPersistentClass>"].eltype = pas.Classes.$rtti["TPersistentClass"];
  };
  $mod.$main = function () {
    pas["WEBLib.Forms"].Application.Initialize();
    pas["WEBLib.Forms"].Application.FMainFormOnTaskBar = true;
    pas["WEBLib.Forms"].Application.CreateForm(pas.Unit1.TForm4,{p: pas.Unit1, get: function () {
        return this.p.Form4;
      }, set: function (v) {
        this.p.Form4 = v;
      }});
    pas["WEBLib.Forms"].Application.Run();
  };
});
//# sourceMappingURL=TMSWeb_RichEditor.js.map
