text: import findConfig from"find-config";import helper from"think-helper";import slash from"slash";import path from"path";import Tag from"nunjucks-tag";import ViewNunjucks from"think-view-nunjucks";import nunjucks from"nunjucks";function createCommonjsModule(e,t){return e(t={exports:{}},t.exports),t.exports}var _global=createCommonjsModule(function(e){var t=e.exports="undefined"!=typeof window&&window.Math==Math?window:"undefined"!=typeof self&&self.Math==Math?self:Function("return this")();"number"==typeof __g&&(__g=t)}),hasOwnProperty={}.hasOwnProperty,_has=function(e,t){return hasOwnProperty.call(e,t)},_fails=function(e){try{return!!e()}catch(e){return!0}},_descriptors=!_fails(function(){return 7!=Object.defineProperty({},"a",{get:function(){return 7}}).a}),_core=createCommonjsModule(function(e){var t=e.exports={version:"2.5.7"};"number"==typeof __e&&(__e=t)}),_core_1=_core.version,_aFunction=function(e){if("function"!=typeof e)throw TypeError(e+" is not a function!");return e},_ctx=function(e,t,r){if(_aFunction(e),void 0===t)return e;switch(r){case 1:return function(r){return e.call(t,r)};case 2:return function(r,o){return e.call(t,r,o)};case 3:return function(r,o,n){return e.call(t,r,o,n)}}return function(){return e.apply(t,arguments)}},_isObject=function(e){return"object"==typeof e?null!==e:"function"==typeof e},_anObject=function(e){if(!_isObject(e))throw TypeError(e+" is not an object!");return e},document$1=_global.document,is=_isObject(document$1)&&_isObject(document$1.createElement),_domCreate=function(e){return is?document$1.createElement(e):{}},_ie8DomDefine=!_descriptors&&!_fails(function(){return 7!=Object.defineProperty(_domCreate("div"),"a",{get:function(){return 7}}).a}),_toPrimitive=function(e,t){if(!_isObject(e))return e;var r,o;if(t&&"function"==typeof(r=e.toString)&&!_isObject(o=r.call(e)))return o;if("function"==typeof(r=e.valueOf)&&!_isObject(o=r.call(e)))return o;if(!t&&"function"==typeof(r=e.toString)&&!_isObject(o=r.call(e)))return o;throw TypeError("Can't convert object to primitive value")},dP=Object.defineProperty,f=_descriptors?Object.defineProperty:function(e,t,r){if(_anObject(e),t=_toPrimitive(t,!0),_anObject(r),_ie8DomDefine)try{return dP(e,t,r)}catch(e){}if("get"in r||"set"in r)throw TypeError("Accessors not supported!");return"value"in r&&(e[t]=r.value),e},_objectDp={f:f},_propertyDesc=function(e,t){return{enumerable:!(1&e),configurable:!(2&e),writable:!(4&e),value:t}},_hide=_descriptors?function(e,t,r){return _objectDp.f(e,t,_propertyDesc(1,r))}:function(e,t,r){return e[t]=r,e},PROTOTYPE="prototype",$export=function(e,t,r){var o,n,i,s=e&$export.F,a=e&$export.G,c=e&$export.S,u=e&$export.P,l=e&$export.B,f=e&$export.W,_=a?_core:_core[t]||(_core[t]={}),p=_[PROTOTYPE],y=a?_global:c?_global[t]:(_global[t]||{})[PROTOTYPE];for(o in a&&(r=t),r)(n=!s&&y&&void 0!==y[o])&&_has(_,o)||(i=n?y[o]:r[o],_[o]=a&&"function"!=typeof y[o]?r[o]:l&&n?_ctx(i,_global):f&&y[o]==i?function(e){var t=function(t,r,o){if(this instanceof e){switch(arguments.length){case 0:return new e;case 1:return new e(t);case 2:return new e(t,r)}return new e(t,r,o)}return e.apply(this,arguments)};return t[PROTOTYPE]=e[PROTOTYPE],t}(i):u&&"function"==typeof i?_ctx(Function.call,i):i,u&&((_.virtual||(_.virtual={}))[o]=i,e&$export.R&&p&&!p[o]&&_hide(p,o,i)))};$export.F=1,$export.G=2,$export.S=4,$export.P=8,$export.B=16,$export.W=32,$export.U=64,$export.R=128;var _export=$export,_redefine=_hide,id=0,px=Math.random(),_uid=function(e){return"Symbol(".concat(void 0===e?"":e,")_",(++id+px).toString(36))},_meta=createCommonjsModule(function(e){var t=_uid("meta"),r=_objectDp.f,o=0,n=Object.isExtensible||function(){return!0},i=!_fails(function(){return n(Object.preventExtensions({}))}),s=function(e){r(e,t,{value:{i:"O"+ ++o,w:{}}})},a=e.exports={KEY:t,NEED:!1,fastKey:function(e,r){if(!_isObject(e))return"symbol"==typeof e?e:("string"==typeof e?"S":"P")+e;if(!_has(e,t)){if(!n(e))return"F";if(!r)return"E";s(e)}return e[t].i},getWeak:function(e,r){if(!_has(e,t)){if(!n(e))return!0;if(!r)return!1;s(e)}return e[t].w},onFreeze:function(e){return i&&a.NEED&&n(e)&&!_has(e,t)&&s(e),e}}}),_meta_1=_meta.KEY,_meta_2=_meta.NEED,_meta_3=_meta.fastKey,_meta_4=_meta.getWeak,_meta_5=_meta.onFreeze,_library=!0,_shared=createCommonjsModule(function(e){var t=_global["__core-js_shared__"]||(_global["__core-js_shared__"]={});(e.exports=function(e,r){return t[e]||(t[e]=void 0!==r?r:{})})("versions",[]).push({version:_core.version,mode:"pure",copyright:"© 2018 Denis Pushkarev (zloirock.ru)"})}),_wks=createCommonjsModule(function(e){var t=_shared("wks"),r=_global.Symbol,o="function"==typeof r;(e.exports=function(e){return t[e]||(t[e]=o&&r[e]||(o?r:_uid)("Symbol."+e))}).store=t}),def=_objectDp.f,TAG=_wks("toStringTag"),_setToStringTag=function(e,t,r){e&&!_has(e=r?e:e.prototype,TAG)&&def(e,TAG,{configurable:!0,value:t})},f$1=_wks,_wksExt={f:f$1},defineProperty=_objectDp.f,_wksDefine=function(e){var t=_core.Symbol||(_core.Symbol={});"_"==e.charAt(0)||e in t||defineProperty(t,e,{value:_wksExt.f(e)})},toString={}.toString,_cof=function(e){return toString.call(e).slice(8,-1)},_iobject=Object("z").propertyIsEnumerable(0)?Object:function(e){return"String"==_cof(e)?e.split(""):Object(e)},_defined=function(e){if(null==e)throw TypeError("Can't call method on  "+e);return e},_toIobject=function(e){return _iobject(_defined(e))},ceil=Math.ceil,floor=Math.floor,_toInteger=function(e){return isNaN(e=+e)?0:(e>0?floor:ceil)(e)},min=Math.min,_toLength=function(e){return e>0?min(_toInteger(e),9007199254740991):0},max=Math.max,min$1=Math.min,_toAbsoluteIndex=function(e,t){return(e=_toInteger(e))<0?max(e+t,0):min$1(e,t)},_arrayIncludes=function(e){return function(t,r,o){var n,i=_toIobject(t),s=_toLength(i.length),a=_toAbsoluteIndex(o,s);if(e&&r!=r){for(;s>a;)if((n=i[a++])!=n)return!0}else for(;s>a;a++)if((e||a in i)&&i[a]===r)return e||a||0;return!e&&-1}},shared=_shared("keys"),_sharedKey=function(e){return shared[e]||(shared[e]=_uid(e))},arrayIndexOf=_arrayIncludes(!1),IE_PROTO=_sharedKey("IE_PROTO"),_objectKeysInternal=function(e,t){var r,o=_toIobject(e),n=0,i=[];for(r in o)r!=IE_PROTO&&_has(o,r)&&i.push(r);for(;t.length>n;)_has(o,r=t[n++])&&(~arrayIndexOf(i,r)||i.push(r));return i},_enumBugKeys="constructor,hasOwnProperty,isPrototypeOf,propertyIsEnumerable,toLocaleString,toString,valueOf".split(","),_objectKeys=Object.keys||function(e){return _objectKeysInternal(e,_enumBugKeys)},f$2=Object.getOwnPropertySymbols,_objectGops={f:f$2},f$3={}.propertyIsEnumerable,_objectPie={f:f$3},_enumKeys=function(e){var t=_objectKeys(e),r=_objectGops.f;if(r)for(var o,n=r(e),i=_objectPie.f,s=0;n.length>s;)i.call(e,o=n[s++])&&t.push(o);return t},_isArray=Array.isArray||function(e){return"Array"==_cof(e)},_objectDps=_descriptors?Object.defineProperties:function(e,t){_anObject(e);for(var r,o=_objectKeys(t),n=o.length,i=0;n>i;)_objectDp.f(e,r=o[i++],t[r]);return e},document$2=_global.document,_html=document$2&&document$2.documentElement,IE_PROTO$1=_sharedKey("IE_PROTO"),Empty=function(){},PROTOTYPE$1="prototype",createDict=function(){var e,t=_domCreate("iframe"),r=_enumBugKeys.length;for(t.style.display="none",_html.appendChild(t),t.src="javascript:",(e=t.contentWindow.document).open(),e.write("<script>document.F=Object<\/script>"),e.close(),createDict=e.F;r--;)delete createDict[PROTOTYPE$1][_enumBugKeys[r]];return createDict()},_objectCreate=Object.create||function(e,t){var r;return null!==e?(Empty[PROTOTYPE$1]=_anObject(e),r=new Empty,Empty[PROTOTYPE$1]=null,r[IE_PROTO$1]=e):r=createDict(),void 0===t?r:_objectDps(r,t)},hiddenKeys=_enumBugKeys.concat("length","prototype"),f$4=Object.getOwnPropertyNames||function(e){return _objectKeysInternal(e,hiddenKeys)},_objectGopn={f:f$4},gOPN=_objectGopn.f,toString$1={}.toString,windowNames="object"==typeof window&&window&&Object.getOwnPropertyNames?Object.getOwnPropertyNames(window):[],getWindowNames=function(e){try{return gOPN(e)}catch(e){return windowNames.slice()}},f$5=function(e){return windowNames&&"[object Window]"==toString$1.call(e)?getWindowNames(e):gOPN(_toIobject(e))},_objectGopnExt={f:f$5},gOPD=Object.getOwnPropertyDescriptor,f$6=_descriptors?gOPD:function(e,t){if(e=_toIobject(e),t=_toPrimitive(t,!0),_ie8DomDefine)try{return gOPD(e,t)}catch(e){}if(_has(e,t))return _propertyDesc(!_objectPie.f.call(e,t),e[t])},_objectGopd={f:f$6},META=_meta.KEY,gOPD$1=_objectGopd.f,dP$1=_objectDp.f,gOPN$1=_objectGopnExt.f,$Symbol=_global.Symbol,$JSON=_global.JSON,_stringify=$JSON&&$JSON.stringify,PROTOTYPE$2="prototype",HIDDEN=_wks("_hidden"),TO_PRIMITIVE=_wks("toPrimitive"),isEnum={}.propertyIsEnumerable,SymbolRegistry=_shared("symbol-registry"),AllSymbols=_shared("symbols"),OPSymbols=_shared("op-symbols"),ObjectProto=Object[PROTOTYPE$2],USE_NATIVE="function"==typeof $Symbol,QObject=_global.QObject,setter=!QObject||!QObject[PROTOTYPE$2]||!QObject[PROTOTYPE$2].findChild,setSymbolDesc=_descriptors&&_fails(function(){return 7!=_objectCreate(dP$1({},"a",{get:function(){return dP$1(this,"a",{value:7}).a}})).a})?function(e,t,r){var o=gOPD$1(ObjectProto,t);o&&delete ObjectProto[t],dP$1(e,t,r),o&&e!==ObjectProto&&dP$1(ObjectProto,t,o)}:dP$1,wrap=function(e){var t=AllSymbols[e]=_objectCreate($Symbol[PROTOTYPE$2]);return t._k=e,t},isSymbol=USE_NATIVE&&"symbol"==typeof $Symbol.iterator?function(e){return"symbol"==typeof e}:function(e){return e instanceof $Symbol},$defineProperty=function(e,t,r){return e===ObjectProto&&$defineProperty(OPSymbols,t,r),_anObject(e),t=_toPrimitive(t,!0),_anObject(r),_has(AllSymbols,t)?(r.enumerable?(_has(e,HIDDEN)&&e[HIDDEN][t]&&(e[HIDDEN][t]=!1),r=_objectCreate(r,{enumerable:_propertyDesc(0,!1)})):(_has(e,HIDDEN)||dP$1(e,HIDDEN,_propertyDesc(1,{})),e[HIDDEN][t]=!0),setSymbolDesc(e,t,r)):dP$1(e,t,r)},$defineProperties=function(e,t){_anObject(e);for(var r,o=_enumKeys(t=_toIobject(t)),n=0,i=o.length;i>n;)$defineProperty(e,r=o[n++],t[r]);return e},$create=function(e,t){return void 0===t?_objectCreate(e):$defineProperties(_objectCreate(e),t)},$propertyIsEnumerable=function(e){var t=isEnum.call(this,e=_toPrimitive(e,!0));return!(this===ObjectProto&&_has(AllSymbols,e)&&!_has(OPSymbols,e))&&(!(t||!_has(this,e)||!_has(AllSymbols,e)||_has(this,HIDDEN)&&this[HIDDEN][e])||t)},$getOwnPropertyDescriptor=function(e,t){if(e=_toIobject(e),t=_toPrimitive(t,!0),e!==ObjectProto||!_has(AllSymbols,t)||_has(OPSymbols,t)){var r=gOPD$1(e,t);return!r||!_has(AllSymbols,t)||_has(e,HIDDEN)&&e[HIDDEN][t]||(r.enumerable=!0),r}},$getOwnPropertyNames=function(e){for(var t,r=gOPN$1(_toIobject(e)),o=[],n=0;r.length>n;)_has(AllSymbols,t=r[n++])||t==HIDDEN||t==META||o.push(t);return o},$getOwnPropertySymbols=function(e){for(var t,r=e===ObjectProto,o=gOPN$1(r?OPSymbols:_toIobject(e)),n=[],i=0;o.length>i;)!_has(AllSymbols,t=o[i++])||r&&!_has(ObjectProto,t)||n.push(AllSymbols[t]);return n};USE_NATIVE||(_redefine(($Symbol=function(){if(this instanceof $Symbol)throw TypeError("Symbol is not a constructor!");var e=_uid(arguments.length>0?arguments[0]:void 0),t=function(r){this===ObjectProto&&t.call(OPSymbols,r),_has(this,HIDDEN)&&_has(this[HIDDEN],e)&&(this[HIDDEN][e]=!1),setSymbolDesc(this,e,_propertyDesc(1,r))};return _descriptors&&setter&&setSymbolDesc(ObjectProto,e,{configurable:!0,set:t}),wrap(e)})[PROTOTYPE$2],"toString",function(){return this._k}),_objectGopd.f=$getOwnPropertyDescriptor,_objectDp.f=$defineProperty,_objectGopn.f=_objectGopnExt.f=$getOwnPropertyNames,_objectPie.f=$propertyIsEnumerable,_objectGops.f=$getOwnPropertySymbols,_descriptors&&!_library&&_redefine(ObjectProto,"propertyIsEnumerable",$propertyIsEnumerable,!0),_wksExt.f=function(e){return wrap(_wks(e))}),_export(_export.G+_export.W+_export.F*!USE_NATIVE,{Symbol:$Symbol});for(var es6Symbols="hasInstance,isConcatSpreadable,iterator,match,replace,search,species,split,toPrimitive,toStringTag,unscopables".split(","),j=0;es6Symbols.length>j;)_wks(es6Symbols[j++]);for(var wellKnownSymbols=_objectKeys(_wks.store),k=0;wellKnownSymbols.length>k;)_wksDefine(wellKnownSymbols[k++]);_export(_export.S+_export.F*!USE_NATIVE,"Symbol",{for:function(e){return _has(SymbolRegistry,e+="")?SymbolRegistry[e]:SymbolRegistry[e]=$Symbol(e)},keyFor:function(e){if(!isSymbol(e))throw TypeError(e+" is not a symbol!");for(var t in SymbolRegistry)if(SymbolRegistry[t]===e)return t},useSetter:function(){setter=!0},useSimple:function(){setter=!1}}),_export(_export.S+_export.F*!USE_NATIVE,"Object",{create:$create,defineProperty:$defineProperty,defineProperties:$defineProperties,getOwnPropertyDescriptor:$getOwnPropertyDescriptor,getOwnPropertyNames:$getOwnPropertyNames,getOwnPropertySymbols:$getOwnPropertySymbols}),$JSON&&_export(_export.S+_export.F*(!USE_NATIVE||_fails(function(){var e=$Symbol();return"[null]"!=_stringify([e])||"{}"!=_stringify({a:e})||"{}"!=_stringify(Object(e))})),"JSON",{stringify:function(e){for(var t,r,o=[e],n=1;arguments.length>n;)o.push(arguments[n++]);if(r=t=o[1],(_isObject(t)||void 0!==e)&&!isSymbol(e))return _isArray(t)||(t=function(e,t){if("function"==typeof r&&(t=r.call(this,e,t)),!isSymbol(t))return t}),o[1]=t,_stringify.apply($JSON,o)}}),$Symbol[PROTOTYPE$2][TO_PRIMITIVE]||_hide($Symbol[PROTOTYPE$2],TO_PRIMITIVE,$Symbol[PROTOTYPE$2].valueOf),_setToStringTag($Symbol,"Symbol"),_setToStringTag(Math,"Math",!0),_setToStringTag(_global.JSON,"JSON",!0);var getOwnPropertySymbols=_core.Object.getOwnPropertySymbols,getOwnPropertySymbols$1=getOwnPropertySymbols,_toObject=function(e){return Object(_defined(e))},_objectSap=function(e,t){var r=(_core.Object||{})[e]||Object[e],o={};o[e]=t(r),_export(_export.S+_export.F*_fails(function(){r(1)}),"Object",o)};_objectSap("keys",function(){return function(e){return _objectKeys(_toObject(e))}});var keys=_core.Object.keys,keys$1=keys;function _objectWithoutPropertiesLoose(e,t){if(null==e)return{};var r,o,n={},i=keys$1(e);for(o=0;o<i.length;o++)r=i[o],t.indexOf(r)>=0||(n[r]=e[r]);return n}function _objectWithoutProperties(e,t){if(null==e)return{};var r,o,n=_objectWithoutPropertiesLoose(e,t);if(getOwnPropertySymbols$1){var i=getOwnPropertySymbols$1(e);for(o=0;o<i.length;o++)r=i[o],t.indexOf(r)>=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(n[r]=e[r])}return n}function _arrayWithHoles(e){if(Array.isArray(e))return e}var _iterStep=function(e,t){return{value:t,done:!!e}},_iterators={},IteratorPrototype={};_hide(IteratorPrototype,_wks("iterator"),function(){return this});var _iterCreate=function(e,t,r){e.prototype=_objectCreate(IteratorPrototype,{next:_propertyDesc(1,r)}),_setToStringTag(e,t+" Iterator")},IE_PROTO$2=_sharedKey("IE_PROTO"),ObjectProto$1=Object.prototype,_objectGpo=Object.getPrototypeOf||function(e){return e=_toObject(e),_has(e,IE_PROTO$2)?e[IE_PROTO$2]:"function"==typeof e.constructor&&e instanceof e.constructor?e.constructor.prototype:e instanceof Object?ObjectProto$1:null},ITERATOR=_wks("iterator"),BUGGY=!([].keys&&"next"in[].keys()),FF_ITERATOR="@@iterator",KEYS="keys",VALUES="values",returnThis=function(){return this},_iterDefine=function(e,t,r,o,n,i,s){_iterCreate(r,t,o);var a,c,u,l=function(e){if(!BUGGY&&e in y)return y[e];switch(e){case KEYS:case VALUES:return function(){return new r(this,e)}}return function(){return new r(this,e)}},f=t+" Iterator",_=n==VALUES,p=!1,y=e.prototype,h=y[ITERATOR]||y[FF_ITERATOR]||n&&y[n],m=h||l(n),b=n?_?l("entries"):m:void 0,d="Array"==t&&y.entries||h;if(d&&(u=_objectGpo(d.call(new e)))!==Object.prototype&&u.next&&_setToStringTag(u,f,!0),_&&h&&h.name!==VALUES&&(p=!0,m=function(){return h.call(this)}),s&&(BUGGY||p||!y[ITERATOR])&&_hide(y,ITERATOR,m),_iterators[t]=m,_iterators[f]=returnThis,n)if(a={values:_?m:l(VALUES),keys:i?m:l(KEYS),entries:b},s)for(c in a)c in y||_redefine(y,c,a[c]);else _export(_export.P+_export.F*(BUGGY||p),t,a);return a},es6_array_iterator=_iterDefine(Array,"Array",function(e,t){this._t=_toIobject(e),this._i=0,this._k=t},function(){var e=this._t,t=this._k,r=this._i++;return!e||r>=e.length?(this._t=void 0,_iterStep(1)):_iterStep(0,"keys"==t?r:"values"==t?e[r]:[r,e[r]])},"values");_iterators.Arguments=_iterators.Array;for(var TO_STRING_TAG=_wks("toStringTag"),DOMIterables="CSSRuleList,CSSStyleDeclaration,CSSValueList,ClientRectList,DOMRectList,DOMStringList,DOMTokenList,DataTransferItemList,FileList,HTMLAllCollection,HTMLCollection,HTMLFormElement,HTMLSelectElement,MediaList,MimeTypeArray,NamedNodeMap,NodeList,PaintRequestList,Plugin,PluginArray,SVGLengthList,SVGNumberList,SVGPathSegList,SVGPointList,SVGStringList,SVGTransformList,SourceBufferList,StyleSheetList,TextTrackCueList,TextTrackList,TouchList".split(","),i=0;i<DOMIterables.length;i++){var NAME=DOMIterables[i],Collection=_global[NAME],proto=Collection&&Collection.prototype;proto&&!proto[TO_STRING_TAG]&&_hide(proto,TO_STRING_TAG,NAME),_iterators[NAME]=_iterators.Array}var _stringAt=function(e){return function(t,r){var o,n,i=String(_defined(t)),s=_toInteger(r),a=i.length;return s<0||s>=a?e?"":void 0:(o=i.charCodeAt(s))<55296||o>56319||s+1===a||(n=i.charCodeAt(s+1))<56320||n>57343?e?i.charAt(s):o:e?i.slice(s,s+2):n-56320+(o-55296<<10)+65536}},$at=_stringAt(!0);_iterDefine(String,"String",function(e){this._t=String(e),this._i=0},function(){var e,t=this._t,r=this._i;return r>=t.length?{value:void 0,done:!0}:(e=$at(t,r),this._i+=e.length,{value:e,done:!1})});var TAG$1=_wks("toStringTag"),ARG="Arguments"==_cof(function(){return arguments}()),tryGet=function(e,t){try{return e[t]}catch(e){}},_classof=function(e){var t,r,o;return void 0===e?"Undefined":null===e?"Null":"string"==typeof(r=tryGet(t=Object(e),TAG$1))?r:ARG?_cof(t):"Object"==(o=_cof(t))&&"function"==typeof t.callee?"Arguments":o},ITERATOR$1=_wks("iterator"),core_getIteratorMethod=_core.getIteratorMethod=function(e){if(null!=e)return e[ITERATOR$1]||e["@@iterator"]||_iterators[_classof(e)]},core_getIterator=_core.getIterator=function(e){var t=core_getIteratorMethod(e);if("function"!=typeof t)throw TypeError(e+" is not iterable!");return _anObject(t.call(e))},getIterator=core_getIterator,getIterator$1=getIterator;function _iterableToArrayLimit(e,t){var r=[],o=!0,n=!1,i=void 0;try{for(var s,a=getIterator$1(e);!(o=(s=a.next()).done)&&(r.push(s.value),!t||r.length!==t);o=!0);}catch(e){n=!0,i=e}finally{try{o||null==a.return||a.return()}finally{if(n)throw i}}return r}function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}function _slicedToArray(e,t){return _arrayWithHoles(e)||_iterableToArrayLimit(e,t)||_nonIterableRest()}_wksDefine("asyncIterator"),_wksDefine("observable");var defer,channel,port,symbol=_core.Symbol,symbol$1=symbol,_anInstance=function(e,t,r,o){if(!(e instanceof t)||void 0!==o&&o in e)throw TypeError(r+": incorrect invocation!");return e},_iterCall=function(e,t,r,o){try{return o?t(_anObject(r)[0],r[1]):t(r)}catch(t){var n=e.return;throw void 0!==n&&_anObject(n.call(e)),t}},ITERATOR$2=_wks("iterator"),ArrayProto=Array.prototype,_isArrayIter=function(e){return void 0!==e&&(_iterators.Array===e||ArrayProto[ITERATOR$2]===e)},_forOf=createCommonjsModule(function(e){var t={},r={},o=e.exports=function(e,o,n,i,s){var a,c,u,l,f=s?function(){return e}:core_getIteratorMethod(e),_=_ctx(n,i,o?2:1),p=0;if("function"!=typeof f)throw TypeError(e+" is not iterable!");if(_isArrayIter(f)){for(a=_toLength(e.length);a>p;p++)if((l=o?_(_anObject(c=e[p])[0],c[1]):_(e[p]))===t||l===r)return l}else for(u=f.call(e);!(c=u.next()).done;)if((l=_iterCall(u,_,c.value,o))===t||l===r)return l};o.BREAK=t,o.RETURN=r}),SPECIES=_wks("species"),_speciesConstructor=function(e,t){var r,o=_anObject(e).constructor;return void 0===o||null==(r=_anObject(o)[SPECIES])?t:_aFunction(r)},_invoke=function(e,t,r){var o=void 0===r;switch(t.length){case 0:return o?e():e.call(r);case 1:return o?e(t[0]):e.call(r,t[0]);case 2:return o?e(t[0],t[1]):e.call(r,t[0],t[1]);case 3:return o?e(t[0],t[1],t[2]):e.call(r,t[0],t[1],t[2]);case 4:return o?e(t[0],t[1],t[2],t[3]):e.call(r,t[0],t[1],t[2],t[3])}return e.apply(r,t)},process=_global.process,setTask=_global.setImmediate,clearTask=_global.clearImmediate,MessageChannel=_global.MessageChannel,Dispatch=_global.Dispatch,counter=0,queue={},ONREADYSTATECHANGE="onreadystatechange",run=function(){var e=+this;if(queue.hasOwnProperty(e)){var t=queue[e];delete queue[e],t()}},listener=function(e){run.call(e.data)};setTask&&clearTask||(setTask=function(e){for(var t=[],r=1;arguments.length>r;)t.push(arguments[r++]);return queue[++counter]=function(){_invoke("function"==typeof e?e:Function(e),t)},defer(counter),counter},clearTask=function(e){delete queue[e]},"process"==_cof(process)?defer=function(e){process.nextTick(_ctx(run,e,1))}:Dispatch&&Dispatch.now?defer=function(e){Dispatch.now(_ctx(run,e,1))}:MessageChannel?(port=(channel=new MessageChannel).port2,channel.port1.onmessage=listener,defer=_ctx(port.postMessage,port,1)):_global.addEventListener&&"function"==typeof postMessage&&!_global.importScripts?(defer=function(e){_global.postMessage(e+"","*")},_global.addEventListener("message",listener,!1)):defer=ONREADYSTATECHANGE in _domCreate("script")?function(e){_html.appendChild(_domCreate("script"))[ONREADYSTATECHANGE]=function(){_html.removeChild(this),run.call(e)}}:function(e){setTimeout(_ctx(run,e,1),0)});var _task={set:setTask,clear:clearTask},macrotask=_task.set,Observer=_global.MutationObserver||_global.WebKitMutationObserver,process$1=_global.process,Promise=_global.Promise,isNode="process"==_cof(process$1),_microtask=function(){var e,t,r,o=function(){var o,n;for(isNode&&(o=process$1.domain)&&o.exit();e;){n=e.fn,e=e.next;try{n()}catch(o){throw e?r():t=void 0,o}}t=void 0,o&&o.enter()};if(isNode)r=function(){process$1.nextTick(o)};else if(!Observer||_global.navigator&&_global.navigator.standalone)if(Promise&&Promise.resolve){var n=Promise.resolve(void 0);r=function(){n.then(o)}}else r=function(){macrotask.call(_global,o)};else{var i=!0,s=document.createTextNode("");new Observer(o).observe(s,{characterData:!0}),r=function(){s.data=i=!i}}return function(o){var n={fn:o,next:void 0};t&&(t.next=n),e||(e=n,r()),t=n}};function PromiseCapability(e){var t,r;this.promise=new e(function(e,o){if(void 0!==t||void 0!==r)throw TypeError("Bad Promise constructor");t=e,r=o}),this.resolve=_aFunction(t),this.reject=_aFunction(r)}var f$7=function(e){return new PromiseCapability(e)},_newPromiseCapability={f:f$7},_perform=function(e){try{return{e:!1,v:e()}}catch(e){return{e:!0,v:e}}},navigator=_global.navigator,_userAgent=navigator&&navigator.userAgent||"",_promiseResolve=function(e,t){if(_anObject(e),_isObject(t)&&t.constructor===e)return t;var r=_newPromiseCapability.f(e);return(0,r.resolve)(t),r.promise},_redefineAll=function(e,t,r){for(var o in t)r&&e[o]?e[o]=t[o]:_hide(e,o,t[o]);return e},SPECIES$1=_wks("species"),_setSpecies=function(e){var t="function"==typeof _core[e]?_core[e]:_global[e];_descriptors&&t&&!t[SPECIES$1]&&_objectDp.f(t,SPECIES$1,{configurable:!0,get:function(){return this}})},ITERATOR$3=_wks("iterator"),SAFE_CLOSING=!1;try{var riter=[7][ITERATOR$3]();riter.return=function(){SAFE_CLOSING=!0}}catch(e){}var Internal,newGenericPromiseCapability,OwnPromiseCapability,Wrapper,_iterDetect=function(e,t){if(!t&&!SAFE_CLOSING)return!1;var r=!1;try{var o=[7],n=o[ITERATOR$3]();n.next=function(){return{done:r=!0}},o[ITERATOR$3]=function(){return n},e(o)}catch(e){}return r},task=_task.set,microtask=_microtask(),PROMISE="Promise",TypeError$1=_global.TypeError,process$2=_global.process,versions=process$2&&process$2.versions,v8=versions&&versions.v8||"",$Promise=_global[PROMISE],isNode$1="process"==_classof(process$2),empty=function(){},newPromiseCapability=newGenericPromiseCapability=_newPromiseCapability.f,USE_NATIVE$1=!!function(){try{var e=$Promise.resolve(1),t=(e.constructor={})[_wks("species")]=function(e){e(empty,empty)};return(isNode$1||"function"==typeof PromiseRejectionEvent)&&e.then(empty)instanceof t&&0!==v8.indexOf("6.6")&&-1===_userAgent.indexOf("Chrome/66")}catch(e){}}(),isThenable=function(e){var t;return!(!_isObject(e)||"function"!=typeof(t=e.then))&&t},notify=function(e,t){if(!e._n){e._n=!0;var r=e._c;microtask(function(){for(var o=e._v,n=1==e._s,i=0,s=function(t){var r,i,s,a=n?t.ok:t.fail,c=t.resolve,u=t.reject,l=t.domain;try{a?(n||(2==e._h&&onHandleUnhandled(e),e._h=1),!0===a?r=o:(l&&l.enter(),r=a(o),l&&(l.exit(),s=!0)),r===t.promise?u(TypeError$1("Promise-chain cycle")):(i=isThenable(r))?i.call(r,c,u):c(r)):u(o)}catch(e){l&&!s&&l.exit(),u(e)}};r.length>i;)s(r[i++]);e._c=[],e._n=!1,t&&!e._h&&onUnhandled(e)})}},onUnhandled=function(e){task.call(_global,function(){var t,r,o,n=e._v,i=isUnhandled(e);if(i&&(t=_perform(function(){isNode$1?process$2.emit("unhandledRejection",n,e):(r=_global.onunhandledrejection)?r({promise:e,reason:n}):(o=_global.console)&&o.error&&o.error("Unhandled promise rejection",n)}),e._h=isNode$1||isUnhandled(e)?2:1),e._a=void 0,i&&t.e)throw t.v})},isUnhandled=function(e){return 1!==e._h&&0===(e._a||e._c).length},onHandleUnhandled=function(e){task.call(_global,function(){var t;isNode$1?process$2.emit("rejectionHandled",e):(t=_global.onrejectionhandled)&&t({promise:e,reason:e._v})})},$reject=function(e){var t=this;t._d||(t._d=!0,(t=t._w||t)._v=e,t._s=2,t._a||(t._a=t._c.slice()),notify(t,!0))},$resolve=function(e){var t,r=this;if(!r._d){r._d=!0,r=r._w||r;try{if(r===e)throw TypeError$1("Promise can't be resolved itself");(t=isThenable(e))?microtask(function(){var o={_w:r,_d:!1};try{t.call(e,_ctx($resolve,o,1),_ctx($reject,o,1))}catch(e){$reject.call(o,e)}}):(r._v=e,r._s=1,notify(r,!1))}catch(e){$reject.call({_w:r,_d:!1},e)}}};USE_NATIVE$1||($Promise=function(e){_anInstance(this,$Promise,PROMISE,"_h"),_aFunction(e),Internal.call(this);try{e(_ctx($resolve,this,1),_ctx($reject,this,1))}catch(e){$reject.call(this,e)}},(Internal=function(e){this._c=[],this._a=void 0,this._s=0,this._d=!1,this._v=void 0,this._h=0,this._n=!1}).prototype=_redefineAll($Promise.prototype,{then:function(e,t){var r=newPromiseCapability(_speciesConstructor(this,$Promise));return r.ok="function"!=typeof e||e,r.fail="function"==typeof t&&t,r.domain=isNode$1?process$2.domain:void 0,this._c.push(r),this._a&&this._a.push(r),this._s&&notify(this,!1),r.promise},catch:function(e){return this.then(void 0,e)}}),OwnPromiseCapability=function(){var e=new Internal;this.promise=e,this.resolve=_ctx($resolve,e,1),this.reject=_ctx($reject,e,1)},_newPromiseCapability.f=newPromiseCapability=function(e){return e===$Promise||e===Wrapper?new OwnPromiseCapability(e):newGenericPromiseCapability(e)}),_export(_export.G+_export.W+_export.F*!USE_NATIVE$1,{Promise:$Promise}),_setToStringTag($Promise,PROMISE),_setSpecies(PROMISE),Wrapper=_core[PROMISE],_export(_export.S+_export.F*!USE_NATIVE$1,PROMISE,{reject:function(e){var t=newPromiseCapability(this);return(0,t.reject)(e),t.promise}}),_export(_export.S+_export.F*_library,PROMISE,{resolve:function(e){return _promiseResolve(_library&&this===Wrapper?$Promise:this,e)}}),_export(_export.S+_export.F*!(USE_NATIVE$1&&_iterDetect(function(e){$Promise.all(e).catch(empty)})),PROMISE,{all:function(e){var t=this,r=newPromiseCapability(t),o=r.resolve,n=r.reject,i=_perform(function(){var r=[],i=0,s=1;_forOf(e,!1,function(e){var a=i++,c=!1;r.push(void 0),s++,t.resolve(e).then(function(e){c||(c=!0,r[a]=e,--s||o(r))},n)}),--s||o(r)});return i.e&&n(i.v),r.promise},race:function(e){var t=this,r=newPromiseCapability(t),o=r.reject,n=_perform(function(){_forOf(e,!1,function(e){t.resolve(e).then(r.resolve,o)})});return n.e&&o(n.v),r.promise}}),_export(_export.P+_export.R,"Promise",{finally:function(e){var t=_speciesConstructor(this,_core.Promise||_global.Promise),r="function"==typeof e;return this.then(r?function(r){return _promiseResolve(t,e()).then(function(){return r})}:e,r?function(r){return _promiseResolve(t,e()).then(function(){throw r})}:e)}}),_export(_export.S,"Promise",{try:function(e){var t=_newPromiseCapability.f(this),r=_perform(e);return(r.e?t.reject:t.resolve)(r.v),t.promise}});var promise=_core.Promise,promise$1=promise;function _AwaitValue(e){this.wrapped=e}function AsyncGenerator(e){var t,r;function o(t,r){try{var i=e[t](r),s=i.value,a=s instanceof _AwaitValue;promise$1.resolve(a?s.wrapped:s).then(function(e){a?o("next",e):n(i.done?"return":"normal",e)},function(e){o("throw",e)})}catch(e){n("throw",e)}}function n(e,n){switch(e){case"return":t.resolve({value:n,done:!0});break;case"throw":t.reject(n);break;default:t.resolve({value:n,done:!1})}(t=t.next)?o(t.key,t.arg):r=null}this._invoke=function(e,n){return new promise$1(function(i,s){var a={key:e,arg:n,resolve:i,reject:s,next:null};r?r=r.next=a:(t=r=a,o(e,n))})},"function"!=typeof e.return&&(this.return=void 0)}function _wrapAsyncGenerator(e){return function(){return new AsyncGenerator(e.apply(this,arguments))}}function _awaitAsyncGenerator(e){return new _AwaitValue(e)}"function"==typeof symbol$1&&symbol$1.asyncIterator&&(AsyncGenerator.prototype[symbol$1.asyncIterator]=function(){return this}),AsyncGenerator.prototype.next=function(e){return this._invoke("next",e)},AsyncGenerator.prototype.throw=function(e){return this._invoke("throw",e)},AsyncGenerator.prototype.return=function(e){return this._invoke("return",e)};var iterator=_wksExt.f("iterator"),iterator$1=iterator;function _asyncIterator(e){var t;if("function"==typeof symbol$1){if(symbol$1.asyncIterator&&null!=(t=e[symbol$1.asyncIterator]))return t.call(e);if(iterator$1&&null!=(t=e[iterator$1]))return t.call(e)}throw new TypeError("Object is not async iterable")}function _asyncGeneratorDelegate(e,t){var r={},o=!1;function n(r,n){return o=!0,n=new promise$1(function(t){t(e[r](n))}),{done:!1,value:t(n)}}return"function"==typeof symbol$1&&iterator$1&&(r[iterator$1]=function(){return this}),r.next=function(e){return o?(o=!1,e):n("next",e)},"function"==typeof e.throw&&(r.throw=function(e){if(o)throw o=!1,e;return n("throw",e)}),"function"==typeof e.return&&(r.return=function(e){return n("return",e)}),r}const defaultConfig={isDebug:!1,isCache:!0,bundleDirName:"dist",statsFile:"webpack-stats.json",pollInterval:500,timeoutThreshold:5e3,ignores:[".hot-update.js",".map"]},defaultConfigName="thinkjs-webpack-loader-config.js",userConfigCreator=(e,t="development")=>{const r=findConfig.require(defaultConfigName,{home:!1});if(r&&r[t]&&r[t][e])return r[t][e];let o=findConfig("package.json",{home:!1});if(o&&(o=require(o)).config&&o.config["thinkjs-webpack-loader"]&&o.config["thinkjs-webpack-loader"].config){const r=require.resolve(o.config["thinkjs-webpack-loader"].config);return require(r)[t][e]}},loadConfig=(e,t)=>helper.extend({},defaultConfig,userConfigCreator(e,t)||{}),map={"":{name:"div",attr:""},js:{name:"script",attr:"src"},css:{name:"link",attr:"href"}};class UtilityToolFactory{static wait(e){return new promise$1(t=>setTimeout(t,e))}static throttle(e,t=160){let r,o=new Date;return function(){const n=this,i=arguments,s=new Date-0;clearTimeout(r),s-o>=t?(e.apply(n,i),o=s):r=setTimeout(()=>e.apply(n,i),t)}}}class FileLoader{constructor(e="default",{env:t}){this.name=void 0,this.config=void 0,this.config=loadConfig(this.name=e,t)}loadAsset(){const e=this.config.statsFile,t=findConfig.require(e,{home:!1});return t||null}getAsset(){const e=this.config,t=(void 0===e?{}:e).isCache,r=this.name;return t?(FileLoader.asset[r]||(FileLoader.asset[r]=this.loadAsset()),FileLoader.asset[r]):this.loadAsset()}chunksFilter(e){const t=this.config.ignores;return e.filter(({name:e})=>!t.some(t=>new RegExp(t,"gi").test(e))).map(e=>this.getChunkUrl(e))}getChunkUrl(e){const t=e.publicPath,r=e.name;if(t)return t;const o=this.config.bundleDirName,n=findConfig(r,{home:!1,cwd:path.join("www",o)}),i=findConfig("www",{home:!1});return`/${slash(path.relative(i,n))}`}async getBundle(e){const t=this,r=this.config,o=r.isDebug,n=r.timeoutThreshold,i=r.pollInterval;let s=this.getAsset();if(o){const e=(p=_wrapAsyncGenerator(function*(){try{for(;;)yield _awaitAsyncGenerator(UtilityToolFactory.wait(i)),yield t.getAsset()}catch(e){}}),function(){return p.apply(this,arguments)}),r=+new Date,o=e();var a,c=!0,u=!1;try{for(var l,f,_=_asyncIterator(o);c=(l=await _.next()).done,f=await l.value,!c;c=!0){const e=f;if(new Date-r>=n&&o.throw(new Error("compile timeout")),"done"===e.status){s=e;break}}}catch(e){u=!0,a=e}finally{try{c||null==_.return||await _.return()}finally{if(u)throw a}}}var p;switch(s.status){case"done":{const t=s.chunks[e];return t?this.chunksFilter(t):new Error("chunks not found")}case"error":return new Error("compile error")}}}FileLoader.asset={};const loader={};class FileLoaderFactory{getLoader({baseConfig:e,groupName:t}={baseConfig:{}}){return loader[t]||(loader[t]=new FileLoader(t,e)),loader[t]}getBundle(e,t,r){var o=this;return _wrapAsyncGenerator(function*(){let n=yield _awaitAsyncGenerator(o.getLoader(r).getBundle(e));return t&&(n=yield*_asyncGeneratorDelegate(_asyncIterator(o.bundleFilter(n,t)),_awaitAsyncGenerator)),n})()}*bundleFilter(e,t){if(!e)return[];const r=new RegExp(`.${t}$`,"g");for(const t of e)r.test(t)&&(yield t)}async getAttrs(e,t="",r,o=""){const n=this.getBundle(e,t,r),i=[];var s,a=!0,c=!1;try{for(var u,l,f=_asyncIterator(n);a=(u=await f.next()).done,l=await u.value,!a;a=!0){const e=l;i.push(e)}}catch(e){c=!0,s=e}finally{try{a||null==f.return||await f.return()}finally{if(c)throw s}}return i}}var fileLoaderFactory=new FileLoaderFactory;const map$1=map;class RenderExtension extends Tag{constructor(e){super("custom"),this.config=void 0,this.config=e}async render(e,t,r){const o=await this.attrsFilter(t);return super.render(e,o,r)}tagNameCreator(e){let t=-1,r="";for(let o=0,n=e.length;o<n;o++)if(map$1[e[o]]){r=map$1[e[o]].name,t=o;break}return t<0&&(r=map$1[""].name),this.nodeName=r,t}async attrsFilter(e){const t=_slicedToArray(e,4),r=t[0],o=t[1],n=t[2],i=t[3],s=this.tagNameCreator(e),a={baseConfig:this.config,groupName:n};s>-1&&(e=e.filter((e,t)=>t!==s));const c=_slicedToArray(await fileLoaderFactory.getAttrs(r,o,a,i),1)[0];return o&&map$1[o].attr&&e.push(`${map$1[o].attr} = ${c}`),e.filter(e=>![r,n].some(t=>t===e))}}class WebpackLoader extends ViewNunjucks{constructor(e,t,r){super(e,t,r)}render(){const e=this.viewFile,t=this.handleOptions,r=t.loader,o=_objectWithoutProperties(t,["loader"]),n=this.config,i=(void 0===n?{}:n).viewPath;let s="",a=void 0;e.indexOf(i)?s=o:(s=i,a=o);const c=nunjucks.configure(s,a);return c.addExtension("custom",new RenderExtension(r)),helper.promisify(c.render,c)(e,this.viewData)}}export default WebpackLoader;
  