@kosatyi/ejs 0.0.100 → 0.0.101

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -577,6 +577,8 @@ function createBuffer() {
577
577
  return buffer
578
578
  }
579
579
 
580
+ const PARENT = Symbol('ContextScope.parentTemplate');
581
+
580
582
  const createContextScope = (config, methods) => {
581
583
  const {
582
584
  BLOCKS,
@@ -587,14 +589,20 @@ const createContextScope = (config, methods) => {
587
589
  SAFE,
588
590
  SCOPE,
589
591
  COMPONENT,
590
- ELEMENT,
592
+ ELEMENT
591
593
  } = config.vars;
594
+ /**
595
+ *
596
+ * @type {symbol}
597
+ */
598
+
592
599
  /**
593
600
  * @name ContextScope
594
601
  * @param data
595
602
  * @constructor
596
603
  */
597
604
  function ContextScope(data) {
605
+ this[PARENT] = null;
598
606
  this[BLOCKS] = {};
599
607
  this[MACRO] = {};
600
608
  Object.assign(
@@ -604,28 +612,45 @@ const createContextScope = (config, methods) => {
604
612
  }
605
613
  Object.assign(ContextScope.prototype, methods);
606
614
  Object.defineProperty(ContextScope.prototype, BUFFER, {
607
- value: createBuffer(),
615
+ value: createBuffer()
608
616
  });
609
617
  Object.defineProperty(ContextScope.prototype, BLOCKS, {
610
618
  value: {},
611
- writable: true,
619
+ writable: true
612
620
  });
613
621
  Object.defineProperty(ContextScope.prototype, MACRO, {
614
622
  value: {},
615
- writable: true,
623
+ writable: true
616
624
  });
617
625
  Object.defineProperty(ContextScope.prototype, LAYOUT, {
618
626
  value: false,
619
- writable: true,
627
+ writable: true
620
628
  });
621
629
  Object.defineProperty(ContextScope.prototype, EXTEND, {
622
630
  value: false,
623
- writable: true,
631
+ writable: true
632
+ });
633
+ Object.defineProperty(ContextScope.prototype, PARENT, {
634
+ value: null,
635
+ writable: true
624
636
  });
625
637
  Object.defineProperties(ContextScope.prototype, {
638
+ /** @type {function} */
639
+ setParentTemplate:{
640
+ value(value){
641
+ this[PARENT] = value;
642
+ return this
643
+ }
644
+ },
645
+ /** @type {function} */
646
+ getParentTemplate: {
647
+ value(){
648
+ return this[PARENT]
649
+ }
650
+ },
626
651
  /** @type {function} */
627
652
  useSafeValue: {
628
- get: () => safeValue,
653
+ get: () => safeValue
629
654
  },
630
655
  /** @type {function} */
631
656
  useComponent: {
@@ -637,7 +662,7 @@ const createContextScope = (config, methods) => {
637
662
  throw new Error(`${COMPONENT} must be a function`)
638
663
  }
639
664
  }
640
- },
665
+ }
641
666
  },
642
667
  /** @type {function} */
643
668
  useElement: {
@@ -649,49 +674,52 @@ const createContextScope = (config, methods) => {
649
674
  throw new Error(`${ELEMENT} must be a function`)
650
675
  }
651
676
  }
652
- },
677
+ }
653
678
  },
654
679
  /** @type {()=>this[MACRO]} */
655
680
  getMacro: {
656
681
  value() {
657
682
  return this[MACRO]
658
- },
683
+ }
659
684
  },
660
685
  /** @type {function} */
661
686
  getBuffer: {
662
687
  value() {
663
688
  return this[BUFFER]
664
- },
689
+ }
665
690
  },
666
691
  /** @type {function} */
667
692
  getBlocks: {
668
693
  value() {
669
694
  return this[BLOCKS]
670
- },
695
+ }
671
696
  },
697
+
672
698
  /** @type {function} */
673
699
  setExtend: {
674
700
  value(value) {
675
701
  this[EXTEND] = value;
676
- },
702
+ return this
703
+ }
677
704
  },
678
705
  /** @type {function} */
679
706
  getExtend: {
680
707
  value() {
681
708
  return this[EXTEND]
682
- },
709
+ }
683
710
  },
684
711
  /** @type {function} */
685
712
  setLayout: {
686
713
  value(layout) {
687
714
  this[LAYOUT] = layout;
688
- },
715
+ return this
716
+ }
689
717
  },
690
718
  /** @type {function} */
691
719
  getLayout: {
692
720
  value() {
693
721
  return this[LAYOUT]
694
- },
722
+ }
695
723
  },
696
724
  /** @type {function} */
697
725
  clone: {
@@ -701,14 +729,14 @@ const createContextScope = (config, methods) => {
701
729
  filter.push(BLOCKS);
702
730
  }
703
731
  return omit(this, filter)
704
- },
732
+ }
705
733
  },
706
734
  /** @type {function} */
707
735
  extend: {
708
736
  value(layout) {
709
737
  this.setExtend(true);
710
738
  this.setLayout(layout);
711
- },
739
+ }
712
740
  },
713
741
  /** @type {function} */
714
742
  echo: {
@@ -716,21 +744,21 @@ const createContextScope = (config, methods) => {
716
744
  const buffer = this.getBuffer();
717
745
  const params = [].slice.call(arguments);
718
746
  params.forEach(buffer);
719
- },
747
+ }
720
748
  },
721
749
  /** @type {function} */
722
750
  fn: {
723
751
  value(callback) {
724
752
  const buffer = this.getBuffer();
725
753
  const context = this;
726
- return function () {
754
+ return function() {
727
755
  if (isFunction(callback)) {
728
756
  buffer.backup();
729
757
  buffer(callback.apply(context, arguments));
730
758
  return buffer.restore()
731
759
  }
732
760
  }
733
- },
761
+ }
734
762
  },
735
763
  /** @type {function} */
736
764
  macro: {
@@ -738,10 +766,10 @@ const createContextScope = (config, methods) => {
738
766
  const list = this.getMacro();
739
767
  const macro = this.fn(callback);
740
768
  const context = this;
741
- list[name] = function () {
769
+ list[name] = function() {
742
770
  return context.echo(macro.apply(undefined, arguments))
743
771
  };
744
- },
772
+ }
745
773
  },
746
774
  /** @type {function} */
747
775
  call: {
@@ -752,7 +780,7 @@ const createContextScope = (config, methods) => {
752
780
  if (isFunction(macro)) {
753
781
  return macro.apply(macro, params)
754
782
  }
755
- },
783
+ }
756
784
  },
757
785
  /** @type {function} */
758
786
  block: {
@@ -776,13 +804,13 @@ const createContextScope = (config, methods) => {
776
804
  }
777
805
  };
778
806
  this.echo(current()(next()));
779
- },
807
+ }
780
808
  },
781
809
  /** @type {function} */
782
810
  hasBlock: {
783
811
  value(name) {
784
812
  return this.getBlocks().hasOwnProperty(name)
785
- },
813
+ }
786
814
  },
787
815
  /** @type {function} */
788
816
  include: {
@@ -791,7 +819,7 @@ const createContextScope = (config, methods) => {
791
819
  const params = extend(context, data || {});
792
820
  const promise = this.render(path, params);
793
821
  this.echo(promise);
794
- },
822
+ }
795
823
  },
796
824
  /** @type {function} */
797
825
  use: {
@@ -799,18 +827,18 @@ const createContextScope = (config, methods) => {
799
827
  this.echo(
800
828
  Promise.resolve(this.require(path)).then((exports) => {
801
829
  const list = this.getMacro();
802
- each(exports, function (macro, name) {
830
+ each(exports, function(macro, name) {
803
831
  list[[namespace, name].join('.')] = macro;
804
832
  });
805
833
  })
806
834
  );
807
- },
835
+ }
808
836
  },
809
837
  /** @type {function} */
810
838
  async: {
811
839
  value(promise, callback) {
812
840
  this.echo(Promise.resolve(promise).then(callback));
813
- },
841
+ }
814
842
  },
815
843
  /** @type {function} */
816
844
  get: {
@@ -819,29 +847,29 @@ const createContextScope = (config, methods) => {
819
847
  const result = path.shift();
820
848
  const prop = path.pop();
821
849
  return hasProp(result, prop) ? result[prop] : defaults
822
- },
850
+ }
823
851
  },
824
852
  /** @type {function} */
825
853
  set: {
826
854
  value(name, value) {
827
855
  const path = getPath(this, name, false);
828
- const result = path.shift();
856
+ const result= path.shift();
829
857
  const prop = path.pop();
830
- if (this.getExtend() && hasProp(result, prop)) {
858
+ if (this.getParentTemplate() && hasProp(result, prop)) {
831
859
  return result[prop]
832
860
  }
833
861
  return (result[prop] = value)
834
- },
862
+ }
835
863
  },
836
864
  /** @type {function} */
837
865
  each: {
838
- value: function (object, callback) {
866
+ value: function(object, callback) {
839
867
  if (isString(object)) {
840
868
  object = this.get(object, []);
841
869
  }
842
870
  each(object, callback);
843
871
  },
844
- writable: true,
872
+ writable: true
845
873
  },
846
874
  /** @type {function} */
847
875
  el: {
@@ -853,28 +881,33 @@ const createContextScope = (config, methods) => {
853
881
  )
854
882
  );
855
883
  },
856
- writable: true,
884
+ writable: true
857
885
  },
858
886
  /** @type {function} */
859
887
  ui: {
860
- value(layout) {},
861
- writable: true,
862
- },
888
+ value(layout) {
889
+ },
890
+ writable: true
891
+ }
863
892
  });
864
893
  return ContextScope
865
894
  };
866
895
 
867
896
  class Context {
868
897
  #scope
898
+
869
899
  constructor(config, methods) {
870
900
  this.configure(config, methods);
871
901
  }
902
+
872
903
  create(data) {
873
904
  return new this.#scope(data)
874
905
  }
906
+
875
907
  configure(config, methods) {
876
908
  this.#scope = createContextScope(config, methods);
877
909
  }
910
+
878
911
  helpers(methods) {
879
912
  extend(this.#scope.prototype, methods || {});
880
913
  }
@@ -887,6 +920,7 @@ class EJS {
887
920
  #compiler
888
921
  #cache
889
922
  #template
923
+
890
924
  constructor(options) {
891
925
  configSchema(this.#config, options || {});
892
926
  this.#context = new Context(this.#config, this.#extend);
@@ -894,19 +928,11 @@ class EJS {
894
928
  this.#cache = new Cache(this.#config);
895
929
  this.#template = new Template(this.#config, this.#cache, this.#compiler);
896
930
  //
897
- bindContext(this, [
898
- 'configure',
899
- 'create',
900
- 'render',
901
- 'require',
902
- 'context',
903
- 'preload',
904
- 'compile',
905
- 'helpers',
906
- ]);
931
+ bindContext(this, ['configure', 'create', 'render', 'require', 'context', 'preload', 'compile', 'helpers']);
907
932
  //
908
933
  this.helpers({ require: this.require, render: this.render });
909
934
  }
935
+
910
936
  configure(options) {
911
937
  configSchema(this.#config, options || {});
912
938
  this.#context.configure(this.#config, this.#extend);
@@ -915,18 +941,30 @@ class EJS {
915
941
  this.#template.configure(this.#config);
916
942
  return this.#config
917
943
  }
944
+ filePath(name) {
945
+ return ext(name, this.#config.extension)
946
+ }
947
+ require(name) {
948
+ const scope = this.context({});
949
+ return this.#output(this.filePath(name), scope).then(() => scope.getMacro())
950
+ }
918
951
  render(name, data) {
919
- const filepath = ext(name, this.#config.extension);
920
952
  const scope = this.context(data);
921
- return this.#output(filepath, scope).then((content) => {
953
+ return this.#output(this.filePath(name), scope).then(this.outputContent(name,scope))
954
+ }
955
+ outputContent(name,scope){
956
+ return (content) => {
922
957
  if (scope.getExtend()) {
923
958
  scope.setExtend(false);
924
- const layout = scope.getLayout();
925
- const data = scope.clone();
926
- return this.render(layout, data)
959
+ return this.renderLayout(scope.getLayout(),scope,name)
927
960
  }
928
961
  return content
929
- })
962
+ }
963
+ }
964
+ renderLayout(name, data, parent) {
965
+ const scope = this.context(data);
966
+ if (parent) scope.setParentTemplate(parent);
967
+ return this.#output(this.filePath(name), scope).then(this.outputContent(name,scope))
930
968
  }
931
969
  helpers(methods) {
932
970
  this.#context.helpers(extend(this.#extend, methods));
@@ -937,30 +975,21 @@ class EJS {
937
975
  compile(content, path) {
938
976
  return this.#compiler.compile(content, path)
939
977
  }
978
+
940
979
  preload(list) {
941
980
  return this.#cache.load(list || {})
942
981
  }
982
+
943
983
  create(options) {
944
984
  return new this.constructor(options)
945
985
  }
946
- require(name) {
947
- const filepath = ext(name, this.#config.extension);
948
- const scope = this.context({});
949
- return this.#output(filepath, scope).then(() => scope.getMacro())
950
- }
986
+
987
+
951
988
  #output(path, scope) {
952
989
  const { globalHelpers } = this.#config;
953
- const params = [
954
- scope,
955
- scope.getBuffer(),
956
- scope.useSafeValue,
957
- scope.useComponent,
958
- scope.useElement,
959
- ].concat(
960
- globalHelpers
961
- .filter((name) => isFunction(scope[name]))
962
- .map((name) => scope[name].bind(scope))
963
- );
990
+ const params = [scope, scope.getBuffer(), scope.useSafeValue, scope.useComponent, scope.useElement].concat(globalHelpers
991
+ .filter((name) => isFunction(scope[name]))
992
+ .map((name) => scope[name].bind(scope)));
964
993
  return this.#template
965
994
  .get(path)
966
995
  .then((callback) => callback.apply(scope, params))
@@ -705,6 +705,7 @@
705
705
  return buffer;
706
706
  }
707
707
 
708
+ var PARENT = Symbol('ContextScope.parentTemplate');
708
709
  var createContextScope = function createContextScope(config, methods) {
709
710
  var _config$vars = config.vars,
710
711
  BLOCKS = _config$vars.BLOCKS,
@@ -716,12 +717,18 @@
716
717
  SCOPE = _config$vars.SCOPE,
717
718
  COMPONENT = _config$vars.COMPONENT,
718
719
  ELEMENT = _config$vars.ELEMENT;
720
+ /**
721
+ *
722
+ * @type {symbol}
723
+ */
724
+
719
725
  /**
720
726
  * @name ContextScope
721
727
  * @param data
722
728
  * @constructor
723
729
  */
724
730
  function ContextScope(data) {
731
+ this[PARENT] = null;
725
732
  this[BLOCKS] = {};
726
733
  this[MACRO] = {};
727
734
  Object.assign(this, omit(data, [SCOPE, BUFFER, SAFE, COMPONENT, ELEMENT]));
@@ -746,7 +753,24 @@
746
753
  value: false,
747
754
  writable: true
748
755
  });
756
+ Object.defineProperty(ContextScope.prototype, PARENT, {
757
+ value: null,
758
+ writable: true
759
+ });
749
760
  Object.defineProperties(ContextScope.prototype, {
761
+ /** @type {function} */
762
+ setParentTemplate: {
763
+ value: function value(_value) {
764
+ this[PARENT] = _value;
765
+ return this;
766
+ }
767
+ },
768
+ /** @type {function} */
769
+ getParentTemplate: {
770
+ value: function value() {
771
+ return this[PARENT];
772
+ }
773
+ },
750
774
  /** @type {function} */
751
775
  useSafeValue: {
752
776
  get: function get() {
@@ -797,8 +821,9 @@
797
821
  },
798
822
  /** @type {function} */
799
823
  setExtend: {
800
- value: function value(_value) {
801
- this[EXTEND] = _value;
824
+ value: function value(_value2) {
825
+ this[EXTEND] = _value2;
826
+ return this;
802
827
  }
803
828
  },
804
829
  /** @type {function} */
@@ -811,6 +836,7 @@
811
836
  setLayout: {
812
837
  value: function value(layout) {
813
838
  this[LAYOUT] = layout;
839
+ return this;
814
840
  }
815
841
  },
816
842
  /** @type {function} */
@@ -949,14 +975,14 @@
949
975
  },
950
976
  /** @type {function} */
951
977
  set: {
952
- value: function value(name, _value2) {
978
+ value: function value(name, _value3) {
953
979
  var path = getPath(this, name, false);
954
980
  var result = path.shift();
955
981
  var prop = path.pop();
956
- if (this.getExtend() && hasProp(result, prop)) {
982
+ if (this.getParentTemplate() && hasProp(result, prop)) {
957
983
  return result[prop];
958
984
  }
959
- return result[prop] = _value2;
985
+ return result[prop] = _value3;
960
986
  }
961
987
  },
962
988
  /** @type {function} */
@@ -1052,21 +1078,43 @@
1052
1078
  _classPrivateFieldGet2(_template, this).configure(_classPrivateFieldGet2(_config, this));
1053
1079
  return _classPrivateFieldGet2(_config, this);
1054
1080
  }
1081
+ }, {
1082
+ key: "filePath",
1083
+ value: function filePath(name) {
1084
+ return ext(name, _classPrivateFieldGet2(_config, this).extension);
1085
+ }
1086
+ }, {
1087
+ key: "require",
1088
+ value: function require(name) {
1089
+ var scope = this.context({});
1090
+ return _assertClassBrand(_EJS_brand, this, _output).call(this, this.filePath(name), scope).then(function () {
1091
+ return scope.getMacro();
1092
+ });
1093
+ }
1055
1094
  }, {
1056
1095
  key: "render",
1057
1096
  value: function render(name, data) {
1058
- var _this = this;
1059
- var filepath = ext(name, _classPrivateFieldGet2(_config, this).extension);
1060
1097
  var scope = this.context(data);
1061
- return _assertClassBrand(_EJS_brand, this, _output).call(this, filepath, scope).then(function (content) {
1098
+ return _assertClassBrand(_EJS_brand, this, _output).call(this, this.filePath(name), scope).then(this.outputContent(name, scope));
1099
+ }
1100
+ }, {
1101
+ key: "outputContent",
1102
+ value: function outputContent(name, scope) {
1103
+ var _this = this;
1104
+ return function (content) {
1062
1105
  if (scope.getExtend()) {
1063
1106
  scope.setExtend(false);
1064
- var layout = scope.getLayout();
1065
- var _data = scope.clone();
1066
- return _this.render(layout, _data);
1107
+ return _this.renderLayout(scope.getLayout(), scope, name);
1067
1108
  }
1068
1109
  return content;
1069
- });
1110
+ };
1111
+ }
1112
+ }, {
1113
+ key: "renderLayout",
1114
+ value: function renderLayout(name, data, parent) {
1115
+ var scope = this.context(data);
1116
+ if (parent) scope.setParentTemplate(parent);
1117
+ return _assertClassBrand(_EJS_brand, this, _output).call(this, this.filePath(name), scope).then(this.outputContent(name, scope));
1070
1118
  }
1071
1119
  }, {
1072
1120
  key: "helpers",
@@ -1093,15 +1141,6 @@
1093
1141
  value: function create(options) {
1094
1142
  return new this.constructor(options);
1095
1143
  }
1096
- }, {
1097
- key: "require",
1098
- value: function require(name) {
1099
- var filepath = ext(name, _classPrivateFieldGet2(_config, this).extension);
1100
- var scope = this.context({});
1101
- return _assertClassBrand(_EJS_brand, this, _output).call(this, filepath, scope).then(function () {
1102
- return scope.getMacro();
1103
- });
1104
- }
1105
1144
  }]);
1106
1145
  }();
1107
1146
  function _output(path, scope) {
@@ -1 +1 @@
1
- !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).ejs={})}(this,(function(t){"use strict";function e(t,e,n){if("function"==typeof t?t===e:t.has(e))return arguments.length<3?e:n;throw new TypeError("Private element is not present on this object")}function n(t,e,n){return e=h(e),function(t,e){if(e&&("object"==typeof e||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(t,p()?Reflect.construct(e,n||[],h(t).constructor):e.apply(t,n))}function r(t,e){if(e.has(t))throw new TypeError("Cannot initialize the same private elements twice on an object")}function i(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function o(t,n){return t.get(e(t,n))}function u(t,e,n){r(t,e),e.set(t,n)}function c(t,n,r){return t.set(e(t,n),r),r}function s(t,e){r(t,e),e.add(t)}function a(t,e,n){return e&&function(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,y(r.key),r)}}(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t}function f(t,e,n){return(e=y(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function h(t){return h=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},h(t)}function l(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&v(t,e)}function p(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(p=function(){return!!t})()}function v(t,e){return v=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},v(t,e)}function y(t){var e=function(t,e){if("object"!=typeof t||!t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var r=n.call(t,e);if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t,"string");return"symbol"==typeof e?e:e+""}function g(t){var e="function"==typeof Map?new Map:void 0;return g=function(t){if(null===t||!function(t){try{return-1!==Function.toString.call(t).indexOf("[native code]")}catch(e){return"function"==typeof t}}(t))return t;if("function"!=typeof t)throw new TypeError("Super expression must either be null or a function");if(void 0!==e){if(e.has(t))return e.get(t);e.set(t,n)}function n(){return function(t,e,n){if(p())return Reflect.construct.apply(null,arguments);var r=[null];r.push.apply(r,e);var i=new(t.bind.apply(t,r));return n&&v(i,n.prototype),i}(t,arguments,h(this).constructor)}return n.prototype=Object.create(t.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),v(n,t)},g(t)}var d=function(){var t=[].slice.call(arguments),e=t.shift();return t.filter(e).pop()},b=function(t){return Array.isArray(t)},w=function(t){return"function"==typeof t},m=function(t){return"string"==typeof t},k=function(t){return"boolean"==typeof t},E=function(t){return void 0===t},j="[object process]"===Object.prototype.toString.call("undefined"!=typeof process?process:0),O={"'":"'","\\":"\\","\r":"r","\n":"n","\t":"t","\u2028":"u2028","\u2029":"u2029"},x={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#x27;"},P=function(t){return new RegExp(["[",Object.keys(t).join(""),"]"].join(""),"g")},M=P(x),S=P(O),F=function(){return(""+(arguments.length>0&&void 0!==arguments[0]?arguments[0]:"")).replace(M,(function(t){return x[t]}))},T=function(t,e){var n=t;return null==n?"":!0===Boolean(e)?F(n):n},W=function(t,e){if(!1===function(t,e){return Boolean(t instanceof e)}(t,e))throw new TypeError("".concat(t," in not instance of ").concat(e))},B=function(t,e,n){for(var r=t,i=String(e).split("."),o=i.pop(),u=0;u<i.length;u++){var c=i[u];if(w(r.toJSON)&&(r=r.toJSON()),n&&!1===r.hasOwnProperty(c)){r={};break}r=r[c]=r[c]||{}}return w(r.toJSON)&&(r=r.toJSON()),[r,o]},R=function(t,e){var n=t.split(".").pop();return n!==e&&(t=[t,e].join(".")),t},A=function(t){for(var e=arguments.length,n=new Array(e>1?e-1:0),r=1;r<e;r++)n[r-1]=arguments[r];return n.filter((function(t){return t})).reduce((function(t,e){return Object.assign(t,e)}),t)},N=function(){},C=function(t,e){var n;for(n in t)L(t,n)&&e(t[n],n,t)},$=function(t,e){return function(t,e){var n=t instanceof Array,r=n?[]:{};return C(t,(function(t,i,o){var u=e(t,i,o);!1===E(u)&&(n?r.push(u):r[i]=u)})),r}(t,(function(t,n){if(-1===e.indexOf(n))return t}))},L=function(t,e){return t&&t.hasOwnProperty(e)},U={export:"ejsPrecompiled",cache:!0,chokidar:null,path:"views",resolver:function(t,e){return Promise.resolve(["resolver is not defined",t,e].join(" "))},extension:"ejs",rmWhitespace:!0,withObject:!0,globalHelpers:[],vars:{SCOPE:"ejs",COMPONENT:"ui",ELEMENT:"el",EXTEND:"$$e",BUFFER:"$$a",LAYOUT:"$$l",BLOCKS:"$$b",MACRO:"$$m",SAFE:"$$v"},token:{start:"<%",end:"%>",regex:"([\\s\\S]+?)"}},_=function(t,e){A(t,{path:d(m,U.path,t.path,e.path),export:d(m,U.export,t.export,e.export),resolver:d(w,U.resolver,t.resolver,e.resolver),extension:d(m,U.extension,t.extension,e.extension),withObject:d(k,U.withObject,t.withObject,e.withObject),rmWhitespace:d(k,U.rmWhitespace,t.rmWhitespace,e.rmWhitespace),cache:d(k,U.cache,t.cache,e.cache),token:A({},U.token,t.token,e.token),vars:A({},U.vars,t.vars,e.vars),globalHelpers:d(b,U.globalHelpers,t.globalHelpers,e.globalHelpers)})},H="undefined"!=typeof globalThis?globalThis:window||self,q=new WeakMap,J=new WeakMap,D=function(){return a((function t(e){i(this,t),u(this,q,!0),u(this,J,{}),this.configure(e)}),[{key:"load",value:function(t){o(q,this)&&A(o(J,this),t||{})}},{key:"get",value:function(t){if(o(q,this))return o(J,this)[t]}},{key:"set",value:function(t,e){o(q,this)&&(o(J,this)[t]=e)}},{key:"exist",value:function(t){return L(o(J,this),t)}},{key:"clear",value:function(){c(J,this,{})}},{key:"remove",value:function(t){delete o(J,this)[t]}},{key:"resolve",value:function(t){return Promise.resolve(this.get(t))}},{key:"configure",value:function(t){c(q,this,t.cache),!1===j&&this.load(H[t.export])}}])}(),K=new WeakMap,V=new WeakMap,X=function(){return a((function t(e){i(this,t),u(this,K,{}),u(this,V,[{symbol:"-",format:function(t){return"')\n".concat(this.BUFFER,"(").concat(this.SAFE,"(").concat(t,",1))\n").concat(this.BUFFER,"('")}},{symbol:"=",format:function(t){return"')\n".concat(this.BUFFER,"(").concat(this.SAFE,"(").concat(t,"))\n").concat(this.BUFFER,"('")}},{symbol:"#",format:function(t){return"')\n/**".concat(t,"**/\n").concat(this.BUFFER,"('")}},{symbol:"",format:function(t){return"')\n".concat(t.trim(),"\n").concat(this.BUFFER,"('")}}]),this.configure(e)}),[{key:"configure",value:function(t){var e=this;o(K,this).withObject=t.withObject,o(K,this).rmWhitespace=t.rmWhitespace,o(K,this).token=t.token,o(K,this).vars=t.vars,o(K,this).globalHelpers=t.globalHelpers,o(K,this).matches=[],o(K,this).formats=[],o(K,this).slurp={match:"[s\t\n]*",start:[o(K,this).token.start,"_"],end:["_",o(K,this).token.end]},o(V,this).forEach((function(t){o(K,e).matches.push(o(K,e).token.start.concat(t.symbol).concat(o(K,e).token.regex).concat(o(K,e).token.end)),o(K,e).formats.push(t.format.bind(o(K,e).vars))})),o(K,this).regex=new RegExp(o(K,this).matches.join("|").concat("|$"),"g"),o(K,this).slurpStart=new RegExp([o(K,this).slurp.match,o(K,this).slurp.start.join("")].join(""),"gm"),o(K,this).slurpEnd=new RegExp([o(K,this).slurp.end.join(""),o(K,this).slurp.match].join(""),"gm")}},{key:"compile",value:function(t,e){var n=this,r=o(K,this).vars,i=r.SCOPE,u=r.SAFE,c=r.BUFFER,s=r.COMPONENT,a=r.ELEMENT,f=o(K,this).globalHelpers;o(K,this).rmWhitespace&&(t=String(t).replace(/[\r\n]+/g,"\n").replace(/^\s+|\s+$/gm,"")),t=String(t).replace(o(K,this).slurpStart,o(K,this).token.start).replace(o(K,this).slurpEnd,o(K,this).token.end);var h,l,p,v="".concat(c,"('");h=o(K,this).regex,l=function(e,r,i){v+=(""+t.slice(r,i)).replace(S,(function(t){return"\\"+O[t]})),e.forEach((function(t,e){t&&(v+=o(K,n).formats[e](t))}))},p=0,t.replace(h,(function(){var t=[].slice.call(arguments,0,-1),e=t.pop(),n=t.shift();return l(t,p,e),p=e+n.length,n})),v="try{".concat(v+="');","}catch(e){return ").concat(c,".error(e)}"),o(K,this).withObject&&(v="with(".concat(i,"){").concat(v,"}")),v="".concat(c,".start();").concat(v,"return ").concat(c,".end();"),v+="\n//# sourceURL=".concat(e);var y=null,g=[i,c,u,s,a].concat(f);try{(y=Function.apply(null,g.concat(v))).source="(function(".concat(g.join(","),"){\n").concat(v,"\n});")}catch(t){throw t.filename=e,t.source=v,t}return y}}])}(),Y=new WeakMap,z=new WeakMap,G=new WeakMap,I=new WeakMap,Q=new WeakSet,Z=function(){return a((function t(e,n,r){i(this,t),s(this,Q),u(this,Y,void 0),u(this,z,void 0),u(this,G,void 0),u(this,I,void 0),W(n,D),W(r,X),c(z,this,n),c(G,this,r),this.configure(e)}),[{key:"configure",value:function(t){c(Y,this,t.path),w(t.resolver)&&c(I,this,t.resolver)}},{key:"get",value:function(t){var n=this;return o(z,this).exist(t)?o(z,this).resolve(t):e(Q,this,tt).call(this,t).then((function(r){return e(Q,n,et).call(n,t,e(Q,n,nt).call(n,r,t))}))}}])}();function tt(t){return o(I,this).call(this,o(Y,this),t)}function et(t,e){return o(z,this).set(t,e),e}function nt(t,e){return w(t)?t:o(G,this).compile(t,e)}var rt=["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"],it=" ",ot='"',ut="/",ct="<",st=">",at=function(t,e,n){var r=[],i=-1===rt.indexOf(t),o=function(t,e){var n=[];return C(t,(function(t,r,i){var o=e(t,r,i);!1===E(o)&&n.push(o)})),n}(e,(function(t,e){if(null!=t)return[F(e),[ot,F(t),ot].join("")].join("=")})).join(it);return r.push([ct,t,it,o,st].join("")),n&&i&&r.push(n instanceof Array?n.join(""):n),i&&r.push([ct,ut,t,st].join("")),r.join("")},ft=function(t){function e(t){var r;return i(this,e),f(r=n(this,e),"code",0),r.message=t,r}return l(e,t),a(e,[{key:"getCode",value:function(){return this.code}},{key:"getMessage",value:function(){return this.message}},{key:"toString",value:function(){return this.getMessage()}}])}(g(Error)),ht=function(t){function e(){var t;i(this,e);for(var r=arguments.length,o=new Array(r),u=0;u<r;u++)o[u]=arguments[u];return f(t=n(this,e,[].concat(o)),"code",404),t}return l(e,t),a(e)}(ft),lt=function(t){function e(){var t;i(this,e);for(var r=arguments.length,o=new Array(r),u=0;u<r;u++)o[u]=arguments[u];return f(t=n(this,e,[].concat(o)),"code",500),t}return l(e,t),a(e)}(ft);function pt(t){return Promise.all(t||[]).then((function(t){return t.join("")})).catch((function(t){return t}))}function vt(){var t=[],e=[],n=function(t){e.push(t)};return n.start=function(){e=[]},n.backup=function(){t.push(e.concat()),e=[]},n.restore=function(){var n=e.concat();return e=t.pop(),pt(n)},n.error=function(t){return e=t,Promise.reject(new lt(e.message));var e},n.end=function(){return pt(e)},n}var yt=new WeakMap,gt=function(){return a((function t(e,n){i(this,t),u(this,yt,void 0),this.configure(e,n)}),[{key:"create",value:function(t){return new(o(yt,this))(t)}},{key:"configure",value:function(t,e){c(yt,this,function(t,e){var n=t.vars,r=n.BLOCKS,i=n.MACRO,o=n.EXTEND,u=n.LAYOUT,c=n.BUFFER,s=n.SAFE,a=n.SCOPE,f=n.COMPONENT,h=n.ELEMENT;function l(t){this[r]={},this[i]={},Object.assign(this,$(t,[a,c,s,f,h]))}return Object.assign(l.prototype,e),Object.defineProperty(l.prototype,c,{value:vt()}),Object.defineProperty(l.prototype,r,{value:{},writable:!0}),Object.defineProperty(l.prototype,i,{value:{},writable:!0}),Object.defineProperty(l.prototype,u,{value:!1,writable:!0}),Object.defineProperty(l.prototype,o,{value:!1,writable:!0}),Object.defineProperties(l.prototype,{useSafeValue:{get:function(){return T}},useComponent:{get:function(){return w(this[f])?this[f].bind(this):function(){throw new Error("".concat(f," must be a function"))}}},useElement:{get:function(){return w(this[h])?this[h].bind(this):function(){throw new Error("".concat(h," must be a function"))}}},getMacro:{value:function(){return this[i]}},getBuffer:{value:function(){return this[c]}},getBlocks:{value:function(){return this[r]}},setExtend:{value:function(t){this[o]=t}},getExtend:{value:function(){return this[o]}},setLayout:{value:function(t){this[u]=t}},getLayout:{value:function(){return this[u]}},clone:{value:function(t){var e=[u,o,c];return!0===t&&e.push(r),$(this,e)}},extend:{value:function(t){this.setExtend(!0),this.setLayout(t)}},echo:{value:function(t){var e=this.getBuffer();[].slice.call(arguments).forEach(e)}},fn:{value:function(t){var e=this.getBuffer(),n=this;return function(){if(w(t))return e.backup(),e(t.apply(n,arguments)),e.restore()}}},macro:{value:function(t,e){var n=this.getMacro(),r=this.fn(e),i=this;n[t]=function(){return i.echo(r.apply(void 0,arguments))}}},call:{value:function(t){var e=this.getMacro()[t],n=[].slice.call(arguments,1);if(w(e))return e.apply(e,n)}},block:{value:function(t,e){var n=this,r=this.getBlocks();if(r[t]=r[t]||[],r[t].push(this.fn(e)),!this.getExtend()){var i=Object.assign([],r[t]),o=function(){return i.shift()},u=function(){var t=o();return t?function(){n.echo(t(u()))}:N};this.echo(o()(u()))}}},hasBlock:{value:function(t){return this.getBlocks().hasOwnProperty(t)}},include:{value:function(t,e,n){var r=!1===n?{}:this.clone(!0),i=A(r,e||{}),o=this.render(t,i);this.echo(o)}},use:{value:function(t,e){var n=this;this.echo(Promise.resolve(this.require(t)).then((function(t){var r=n.getMacro();C(t,(function(t,n){r[[e,n].join(".")]=t}))})))}},async:{value:function(t,e){this.echo(Promise.resolve(t).then(e))}},get:{value:function(t,e){var n=B(this,t,!0),r=n.shift(),i=n.pop();return L(r,i)?r[i]:e}},set:{value:function(t,e){var n=B(this,t,!1),r=n.shift(),i=n.pop();return this.getExtend()&&L(r,i)?r[i]:r[i]=e}},each:{value:function(t,e){m(t)&&(t=this.get(t,[])),C(t,e)},writable:!0},el:{value:function(t,e,n){n=w(n)?this.fn(n)():n,this.echo(Promise.resolve(n).then((function(n){return at(t,e,n)})))},writable:!0},ui:{value:function(t){},writable:!0}}),l}(t,e))}},{key:"helpers",value:function(t){A(o(yt,this).prototype,t||{})}}])}(),dt=new WeakMap,bt=new WeakMap,wt=new WeakMap,mt=new WeakMap,kt=new WeakMap,Et=new WeakMap,jt=new WeakSet,Ot=function(){return a((function t(e){i(this,t),s(this,jt),u(this,dt,{}),u(this,bt,{}),u(this,wt,void 0),u(this,mt,void 0),u(this,kt,void 0),u(this,Et,void 0),_(o(dt,this),e||{}),c(wt,this,new gt(o(dt,this),o(bt,this))),c(mt,this,new X(o(dt,this))),c(kt,this,new D(o(dt,this))),c(Et,this,new Z(o(dt,this),o(kt,this),o(mt,this))),function(t){(arguments.length>1&&void 0!==arguments[1]?arguments[1]:[]).forEach((function(e){e in t&&(t[e]=t[e].bind(t))}))}(this,["configure","create","render","require","context","preload","compile","helpers"]),this.helpers({require:this.require,render:this.render})}),[{key:"configure",value:function(t){return _(o(dt,this),t||{}),o(wt,this).configure(o(dt,this),o(bt,this)),o(mt,this).configure(o(dt,this)),o(kt,this).configure(o(dt,this)),o(Et,this).configure(o(dt,this)),o(dt,this)}},{key:"render",value:function(t,n){var r=this,i=R(t,o(dt,this).extension),u=this.context(n);return e(jt,this,xt).call(this,i,u).then((function(t){if(u.getExtend()){u.setExtend(!1);var e=u.getLayout(),n=u.clone();return r.render(e,n)}return t}))}},{key:"helpers",value:function(t){o(wt,this).helpers(A(o(bt,this),t))}},{key:"context",value:function(t){return o(wt,this).create(t)}},{key:"compile",value:function(t,e){return o(mt,this).compile(t,e)}},{key:"preload",value:function(t){return o(kt,this).load(t||{})}},{key:"create",value:function(t){return new this.constructor(t)}},{key:"require",value:function(t){var n=R(t,o(dt,this).extension),r=this.context({});return e(jt,this,xt).call(this,n,r).then((function(){return r.getMacro()}))}}])}();function xt(t,e){var n=o(dt,this).globalHelpers,r=[e,e.getBuffer(),e.useSafeValue,e.useComponent,e.useElement].concat(n.filter((function(t){return w(e[t])})).map((function(t){return e[t].bind(e)})));return o(Et,this).get(t).then((function(t){return t.apply(e,r)}))}var Pt=new Ot({resolver:function(t,e){return fetch(function(t,e){return(e=[t,e].join("/")).replace(/\/\//g,"/")}(t,e)).then((function(t){return t.text()}),(function(t){return new ft(t)}))}}),Mt=Pt.render,St=Pt.context,Ft=Pt.compile,Tt=Pt.helpers,Wt=Pt.preload,Bt=Pt.configure,Rt=Pt.create;t.TemplateError=ft,t.TemplateNotFound=ht,t.TemplateSyntaxError=lt,t.compile=Ft,t.configure=Bt,t.context=St,t.create=Rt,t.helpers=Tt,t.preload=Wt,t.render=Mt}));
1
+ !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).ejs={})}(this,(function(t){"use strict";function e(t,e,n){if("function"==typeof t?t===e:t.has(e))return arguments.length<3?e:n;throw new TypeError("Private element is not present on this object")}function n(t,e,n){return e=h(e),function(t,e){if(e&&("object"==typeof e||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(t,p()?Reflect.construct(e,n||[],h(t).constructor):e.apply(t,n))}function r(t,e){if(e.has(t))throw new TypeError("Cannot initialize the same private elements twice on an object")}function i(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function o(t,n){return t.get(e(t,n))}function u(t,e,n){r(t,e),e.set(t,n)}function c(t,n,r){return t.set(e(t,n),r),r}function a(t,e){r(t,e),e.add(t)}function s(t,e,n){return e&&function(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,y(r.key),r)}}(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t}function f(t,e,n){return(e=y(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function h(t){return h=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},h(t)}function l(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&v(t,e)}function p(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(p=function(){return!!t})()}function v(t,e){return v=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},v(t,e)}function y(t){var e=function(t,e){if("object"!=typeof t||!t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var r=n.call(t,e);if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t,"string");return"symbol"==typeof e?e:e+""}function g(t){var e="function"==typeof Map?new Map:void 0;return g=function(t){if(null===t||!function(t){try{return-1!==Function.toString.call(t).indexOf("[native code]")}catch(e){return"function"==typeof t}}(t))return t;if("function"!=typeof t)throw new TypeError("Super expression must either be null or a function");if(void 0!==e){if(e.has(t))return e.get(t);e.set(t,n)}function n(){return function(t,e,n){if(p())return Reflect.construct.apply(null,arguments);var r=[null];r.push.apply(r,e);var i=new(t.bind.apply(t,r));return n&&v(i,n.prototype),i}(t,arguments,h(this).constructor)}return n.prototype=Object.create(t.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),v(n,t)},g(t)}var d=function(){var t=[].slice.call(arguments),e=t.shift();return t.filter(e).pop()},b=function(t){return Array.isArray(t)},m=function(t){return"function"==typeof t},w=function(t){return"string"==typeof t},k=function(t){return"boolean"==typeof t},j=function(t){return void 0===t},E="[object process]"===Object.prototype.toString.call("undefined"!=typeof process?process:0),O={"'":"'","\\":"\\","\r":"r","\n":"n","\t":"t","\u2028":"u2028","\u2029":"u2029"},x={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#x27;"},P=function(t){return new RegExp(["[",Object.keys(t).join(""),"]"].join(""),"g")},S=P(x),M=P(O),T=function(){return(""+(arguments.length>0&&void 0!==arguments[0]?arguments[0]:"")).replace(S,(function(t){return x[t]}))},F=function(t,e){var n=t;return null==n?"":!0===Boolean(e)?T(n):n},W=function(t,e){if(!1===function(t,e){return Boolean(t instanceof e)}(t,e))throw new TypeError("".concat(t," in not instance of ").concat(e))},B=function(t,e,n){for(var r=t,i=String(e).split("."),o=i.pop(),u=0;u<i.length;u++){var c=i[u];if(m(r.toJSON)&&(r=r.toJSON()),n&&!1===r.hasOwnProperty(c)){r={};break}r=r[c]=r[c]||{}}return m(r.toJSON)&&(r=r.toJSON()),[r,o]},R=function(t){for(var e=arguments.length,n=new Array(e>1?e-1:0),r=1;r<e;r++)n[r-1]=arguments[r];return n.filter((function(t){return t})).reduce((function(t,e){return Object.assign(t,e)}),t)},C=function(){},A=function(t,e){var n;for(n in t)L(t,n)&&e(t[n],n,t)},N=function(t,e){return function(t,e){var n=t instanceof Array,r=n?[]:{};return A(t,(function(t,i,o){var u=e(t,i,o);!1===j(u)&&(n?r.push(u):r[i]=u)})),r}(t,(function(t,n){if(-1===e.indexOf(n))return t}))},L=function(t,e){return t&&t.hasOwnProperty(e)},$={export:"ejsPrecompiled",cache:!0,chokidar:null,path:"views",resolver:function(t,e){return Promise.resolve(["resolver is not defined",t,e].join(" "))},extension:"ejs",rmWhitespace:!0,withObject:!0,globalHelpers:[],vars:{SCOPE:"ejs",COMPONENT:"ui",ELEMENT:"el",EXTEND:"$$e",BUFFER:"$$a",LAYOUT:"$$l",BLOCKS:"$$b",MACRO:"$$m",SAFE:"$$v"},token:{start:"<%",end:"%>",regex:"([\\s\\S]+?)"}},U=function(t,e){R(t,{path:d(w,$.path,t.path,e.path),export:d(w,$.export,t.export,e.export),resolver:d(m,$.resolver,t.resolver,e.resolver),extension:d(w,$.extension,t.extension,e.extension),withObject:d(k,$.withObject,t.withObject,e.withObject),rmWhitespace:d(k,$.rmWhitespace,t.rmWhitespace,e.rmWhitespace),cache:d(k,$.cache,t.cache,e.cache),token:R({},$.token,t.token,e.token),vars:R({},$.vars,t.vars,e.vars),globalHelpers:d(b,$.globalHelpers,t.globalHelpers,e.globalHelpers)})},_="undefined"!=typeof globalThis?globalThis:window||self,H=new WeakMap,q=new WeakMap,J=function(){return s((function t(e){i(this,t),u(this,H,!0),u(this,q,{}),this.configure(e)}),[{key:"load",value:function(t){o(H,this)&&R(o(q,this),t||{})}},{key:"get",value:function(t){if(o(H,this))return o(q,this)[t]}},{key:"set",value:function(t,e){o(H,this)&&(o(q,this)[t]=e)}},{key:"exist",value:function(t){return L(o(q,this),t)}},{key:"clear",value:function(){c(q,this,{})}},{key:"remove",value:function(t){delete o(q,this)[t]}},{key:"resolve",value:function(t){return Promise.resolve(this.get(t))}},{key:"configure",value:function(t){c(H,this,t.cache),!1===E&&this.load(_[t.export])}}])}(),D=new WeakMap,K=new WeakMap,V=function(){return s((function t(e){i(this,t),u(this,D,{}),u(this,K,[{symbol:"-",format:function(t){return"')\n".concat(this.BUFFER,"(").concat(this.SAFE,"(").concat(t,",1))\n").concat(this.BUFFER,"('")}},{symbol:"=",format:function(t){return"')\n".concat(this.BUFFER,"(").concat(this.SAFE,"(").concat(t,"))\n").concat(this.BUFFER,"('")}},{symbol:"#",format:function(t){return"')\n/**".concat(t,"**/\n").concat(this.BUFFER,"('")}},{symbol:"",format:function(t){return"')\n".concat(t.trim(),"\n").concat(this.BUFFER,"('")}}]),this.configure(e)}),[{key:"configure",value:function(t){var e=this;o(D,this).withObject=t.withObject,o(D,this).rmWhitespace=t.rmWhitespace,o(D,this).token=t.token,o(D,this).vars=t.vars,o(D,this).globalHelpers=t.globalHelpers,o(D,this).matches=[],o(D,this).formats=[],o(D,this).slurp={match:"[s\t\n]*",start:[o(D,this).token.start,"_"],end:["_",o(D,this).token.end]},o(K,this).forEach((function(t){o(D,e).matches.push(o(D,e).token.start.concat(t.symbol).concat(o(D,e).token.regex).concat(o(D,e).token.end)),o(D,e).formats.push(t.format.bind(o(D,e).vars))})),o(D,this).regex=new RegExp(o(D,this).matches.join("|").concat("|$"),"g"),o(D,this).slurpStart=new RegExp([o(D,this).slurp.match,o(D,this).slurp.start.join("")].join(""),"gm"),o(D,this).slurpEnd=new RegExp([o(D,this).slurp.end.join(""),o(D,this).slurp.match].join(""),"gm")}},{key:"compile",value:function(t,e){var n=this,r=o(D,this).vars,i=r.SCOPE,u=r.SAFE,c=r.BUFFER,a=r.COMPONENT,s=r.ELEMENT,f=o(D,this).globalHelpers;o(D,this).rmWhitespace&&(t=String(t).replace(/[\r\n]+/g,"\n").replace(/^\s+|\s+$/gm,"")),t=String(t).replace(o(D,this).slurpStart,o(D,this).token.start).replace(o(D,this).slurpEnd,o(D,this).token.end);var h,l,p,v="".concat(c,"('");h=o(D,this).regex,l=function(e,r,i){v+=(""+t.slice(r,i)).replace(M,(function(t){return"\\"+O[t]})),e.forEach((function(t,e){t&&(v+=o(D,n).formats[e](t))}))},p=0,t.replace(h,(function(){var t=[].slice.call(arguments,0,-1),e=t.pop(),n=t.shift();return l(t,p,e),p=e+n.length,n})),v="try{".concat(v+="');","}catch(e){return ").concat(c,".error(e)}"),o(D,this).withObject&&(v="with(".concat(i,"){").concat(v,"}")),v="".concat(c,".start();").concat(v,"return ").concat(c,".end();"),v+="\n//# sourceURL=".concat(e);var y=null,g=[i,c,u,a,s].concat(f);try{(y=Function.apply(null,g.concat(v))).source="(function(".concat(g.join(","),"){\n").concat(v,"\n});")}catch(t){throw t.filename=e,t.source=v,t}return y}}])}(),X=new WeakMap,Y=new WeakMap,z=new WeakMap,G=new WeakMap,I=new WeakSet,Q=function(){return s((function t(e,n,r){i(this,t),a(this,I),u(this,X,void 0),u(this,Y,void 0),u(this,z,void 0),u(this,G,void 0),W(n,J),W(r,V),c(Y,this,n),c(z,this,r),this.configure(e)}),[{key:"configure",value:function(t){c(X,this,t.path),m(t.resolver)&&c(G,this,t.resolver)}},{key:"get",value:function(t){var n=this;return o(Y,this).exist(t)?o(Y,this).resolve(t):e(I,this,Z).call(this,t).then((function(r){return e(I,n,tt).call(n,t,e(I,n,et).call(n,r,t))}))}}])}();function Z(t){return o(G,this).call(this,o(X,this),t)}function tt(t,e){return o(Y,this).set(t,e),e}function et(t,e){return m(t)?t:o(z,this).compile(t,e)}var nt=["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"],rt=" ",it='"',ot="/",ut="<",ct=">",at=function(t,e,n){var r=[],i=-1===nt.indexOf(t),o=function(t,e){var n=[];return A(t,(function(t,r,i){var o=e(t,r,i);!1===j(o)&&n.push(o)})),n}(e,(function(t,e){if(null!=t)return[T(e),[it,T(t),it].join("")].join("=")})).join(rt);return r.push([ut,t,rt,o,ct].join("")),n&&i&&r.push(n instanceof Array?n.join(""):n),i&&r.push([ut,ot,t,ct].join("")),r.join("")},st=function(t){function e(t){var r;return i(this,e),f(r=n(this,e),"code",0),r.message=t,r}return l(e,t),s(e,[{key:"getCode",value:function(){return this.code}},{key:"getMessage",value:function(){return this.message}},{key:"toString",value:function(){return this.getMessage()}}])}(g(Error)),ft=function(t){function e(){var t;i(this,e);for(var r=arguments.length,o=new Array(r),u=0;u<r;u++)o[u]=arguments[u];return f(t=n(this,e,[].concat(o)),"code",404),t}return l(e,t),s(e)}(st),ht=function(t){function e(){var t;i(this,e);for(var r=arguments.length,o=new Array(r),u=0;u<r;u++)o[u]=arguments[u];return f(t=n(this,e,[].concat(o)),"code",500),t}return l(e,t),s(e)}(st);function lt(t){return Promise.all(t||[]).then((function(t){return t.join("")})).catch((function(t){return t}))}function pt(){var t=[],e=[],n=function(t){e.push(t)};return n.start=function(){e=[]},n.backup=function(){t.push(e.concat()),e=[]},n.restore=function(){var n=e.concat();return e=t.pop(),lt(n)},n.error=function(t){return e=t,Promise.reject(new ht(e.message));var e},n.end=function(){return lt(e)},n}var vt=Symbol("ContextScope.parentTemplate"),yt=new WeakMap,gt=function(){return s((function t(e,n){i(this,t),u(this,yt,void 0),this.configure(e,n)}),[{key:"create",value:function(t){return new(o(yt,this))(t)}},{key:"configure",value:function(t,e){c(yt,this,function(t,e){var n=t.vars,r=n.BLOCKS,i=n.MACRO,o=n.EXTEND,u=n.LAYOUT,c=n.BUFFER,a=n.SAFE,s=n.SCOPE,f=n.COMPONENT,h=n.ELEMENT;function l(t){this[vt]=null,this[r]={},this[i]={},Object.assign(this,N(t,[s,c,a,f,h]))}return Object.assign(l.prototype,e),Object.defineProperty(l.prototype,c,{value:pt()}),Object.defineProperty(l.prototype,r,{value:{},writable:!0}),Object.defineProperty(l.prototype,i,{value:{},writable:!0}),Object.defineProperty(l.prototype,u,{value:!1,writable:!0}),Object.defineProperty(l.prototype,o,{value:!1,writable:!0}),Object.defineProperty(l.prototype,vt,{value:null,writable:!0}),Object.defineProperties(l.prototype,{setParentTemplate:{value:function(t){return this[vt]=t,this}},getParentTemplate:{value:function(){return this[vt]}},useSafeValue:{get:function(){return F}},useComponent:{get:function(){return m(this[f])?this[f].bind(this):function(){throw new Error("".concat(f," must be a function"))}}},useElement:{get:function(){return m(this[h])?this[h].bind(this):function(){throw new Error("".concat(h," must be a function"))}}},getMacro:{value:function(){return this[i]}},getBuffer:{value:function(){return this[c]}},getBlocks:{value:function(){return this[r]}},setExtend:{value:function(t){return this[o]=t,this}},getExtend:{value:function(){return this[o]}},setLayout:{value:function(t){return this[u]=t,this}},getLayout:{value:function(){return this[u]}},clone:{value:function(t){var e=[u,o,c];return!0===t&&e.push(r),N(this,e)}},extend:{value:function(t){this.setExtend(!0),this.setLayout(t)}},echo:{value:function(t){var e=this.getBuffer();[].slice.call(arguments).forEach(e)}},fn:{value:function(t){var e=this.getBuffer(),n=this;return function(){if(m(t))return e.backup(),e(t.apply(n,arguments)),e.restore()}}},macro:{value:function(t,e){var n=this.getMacro(),r=this.fn(e),i=this;n[t]=function(){return i.echo(r.apply(void 0,arguments))}}},call:{value:function(t){var e=this.getMacro()[t],n=[].slice.call(arguments,1);if(m(e))return e.apply(e,n)}},block:{value:function(t,e){var n=this,r=this.getBlocks();if(r[t]=r[t]||[],r[t].push(this.fn(e)),!this.getExtend()){var i=Object.assign([],r[t]),o=function(){return i.shift()},u=function(){var t=o();return t?function(){n.echo(t(u()))}:C};this.echo(o()(u()))}}},hasBlock:{value:function(t){return this.getBlocks().hasOwnProperty(t)}},include:{value:function(t,e,n){var r=!1===n?{}:this.clone(!0),i=R(r,e||{}),o=this.render(t,i);this.echo(o)}},use:{value:function(t,e){var n=this;this.echo(Promise.resolve(this.require(t)).then((function(t){var r=n.getMacro();A(t,(function(t,n){r[[e,n].join(".")]=t}))})))}},async:{value:function(t,e){this.echo(Promise.resolve(t).then(e))}},get:{value:function(t,e){var n=B(this,t,!0),r=n.shift(),i=n.pop();return L(r,i)?r[i]:e}},set:{value:function(t,e){var n=B(this,t,!1),r=n.shift(),i=n.pop();return this.getParentTemplate()&&L(r,i)?r[i]:r[i]=e}},each:{value:function(t,e){w(t)&&(t=this.get(t,[])),A(t,e)},writable:!0},el:{value:function(t,e,n){n=m(n)?this.fn(n)():n,this.echo(Promise.resolve(n).then((function(n){return at(t,e,n)})))},writable:!0},ui:{value:function(t){},writable:!0}}),l}(t,e))}},{key:"helpers",value:function(t){R(o(yt,this).prototype,t||{})}}])}(),dt=new WeakMap,bt=new WeakMap,mt=new WeakMap,wt=new WeakMap,kt=new WeakMap,jt=new WeakMap,Et=new WeakSet,Ot=function(){return s((function t(e){i(this,t),a(this,Et),u(this,dt,{}),u(this,bt,{}),u(this,mt,void 0),u(this,wt,void 0),u(this,kt,void 0),u(this,jt,void 0),U(o(dt,this),e||{}),c(mt,this,new gt(o(dt,this),o(bt,this))),c(wt,this,new V(o(dt,this))),c(kt,this,new J(o(dt,this))),c(jt,this,new Q(o(dt,this),o(kt,this),o(wt,this))),function(t){(arguments.length>1&&void 0!==arguments[1]?arguments[1]:[]).forEach((function(e){e in t&&(t[e]=t[e].bind(t))}))}(this,["configure","create","render","require","context","preload","compile","helpers"]),this.helpers({require:this.require,render:this.render})}),[{key:"configure",value:function(t){return U(o(dt,this),t||{}),o(mt,this).configure(o(dt,this),o(bt,this)),o(wt,this).configure(o(dt,this)),o(kt,this).configure(o(dt,this)),o(jt,this).configure(o(dt,this)),o(dt,this)}},{key:"filePath",value:function(t){return function(t,e){var n=t.split(".").pop();return n!==e&&(t=[t,e].join(".")),t}(t,o(dt,this).extension)}},{key:"require",value:function(t){var n=this.context({});return e(Et,this,xt).call(this,this.filePath(t),n).then((function(){return n.getMacro()}))}},{key:"render",value:function(t,n){var r=this.context(n);return e(Et,this,xt).call(this,this.filePath(t),r).then(this.outputContent(t,r))}},{key:"outputContent",value:function(t,e){var n=this;return function(r){return e.getExtend()?(e.setExtend(!1),n.renderLayout(e.getLayout(),e,t)):r}}},{key:"renderLayout",value:function(t,n,r){var i=this.context(n);return r&&i.setParentTemplate(r),e(Et,this,xt).call(this,this.filePath(t),i).then(this.outputContent(t,i))}},{key:"helpers",value:function(t){o(mt,this).helpers(R(o(bt,this),t))}},{key:"context",value:function(t){return o(mt,this).create(t)}},{key:"compile",value:function(t,e){return o(wt,this).compile(t,e)}},{key:"preload",value:function(t){return o(kt,this).load(t||{})}},{key:"create",value:function(t){return new this.constructor(t)}}])}();function xt(t,e){var n=o(dt,this).globalHelpers,r=[e,e.getBuffer(),e.useSafeValue,e.useComponent,e.useElement].concat(n.filter((function(t){return m(e[t])})).map((function(t){return e[t].bind(e)})));return o(jt,this).get(t).then((function(t){return t.apply(e,r)}))}var Pt=new Ot({resolver:function(t,e){return fetch(function(t,e){return(e=[t,e].join("/")).replace(/\/\//g,"/")}(t,e)).then((function(t){return t.text()}),(function(t){return new st(t)}))}}),St=Pt.render,Mt=Pt.context,Tt=Pt.compile,Ft=Pt.helpers,Wt=Pt.preload,Bt=Pt.configure,Rt=Pt.create;t.TemplateError=st,t.TemplateNotFound=ft,t.TemplateSyntaxError=ht,t.compile=Tt,t.configure=Bt,t.context=Mt,t.create=Rt,t.helpers=Ft,t.preload=Wt,t.render=St}));