var __awaiter=this&&this.__awaiter||function(t,e,r,n){return new(r||(r=Promise))(function(i,o){function a(t){try{s(n.next(t))}catch(t){o(t)}}function u(t){try{s(n["throw"](t))}catch(t){o(t)}}function s(t){t.done?i(t.value):new r(function(e){e(t.value)}).then(a,u)}s((n=n.apply(t,e||[])).next())})};var __generator=this&&this.__generator||function(t,e){var r={label:0,sent:function(){if(o[0]&1)throw o[1];return o[1]},trys:[],ops:[]},n,i,o,a;return a={next:u(0),throw:u(1),return:u(2)},typeof Symbol==="function"&&(a[Symbol.iterator]=function(){return this}),a;function u(t){return function(e){return s([t,e])}}function s(a){if(n)throw new TypeError("Generator is already executing.");while(r)try{if(n=1,i&&(o=a[0]&2?i["return"]:a[0]?i["throw"]||((o=i["return"])&&o.call(i),0):i.next)&&!(o=o.call(i,a[1])).done)return o;if(i=0,o)a=[a[0]&2,o.value];switch(a[0]){case 0:case 1:o=a;break;case 4:r.label++;return{value:a[1],done:false};case 5:r.label++;i=a[1];a=[0];continue;case 7:a=r.ops.pop();r.trys.pop();continue;default:if(!(o=r.trys,o=o.length>0&&o[o.length-1])&&(a[0]===6||a[0]===2)){r=0;continue}if(a[0]===3&&(!o||a[1]>o[0]&&a[1]<o[3])){r.label=a[1];break}if(a[0]===6&&r.label<o[1]){r.label=o[1];o=a;break}if(o&&r.label<o[2]){r.label=o[2];r.ops.push(a);break}if(o[2])r.ops.pop();r.trys.pop();continue}a=e.call(t,r)}catch(t){a=[6,t];i=0}finally{n=o=0}if(a[0]&5)throw a[1];return{value:a[0]?a[1]:void 0,done:true}}};System.register(["./p-b236363f.system.js","./p-1939e1c4.system.js"],function(t){"use strict";var e,r,n,i,o;return{setters:[function(t){e=t.r;r=t.e;n=t.h;i=t.d},function(t){o=t._}],execute:function(){var a=function(){function t(t){e(this,t);this.formId="gl-form-"+u++;this.translateText=false;this.glFormCancel=r(this,"glFormCancel",7);this.glFormFeatureChanged=r(this,"glFormFeatureChanged",7);this.glFormSubmit=r(this,"glFormSubmit",7)}t.prototype.componentWillLoad=function(){return __awaiter(this,void 0,void 0,function(){var t,e;return __generator(this,function(r){switch(r.label){case 0:return[4,fetch(this.schema)];case 1:t=r.sent();e=this;return[4,t.json()];case 2:e._schema=r.sent();return[2]}})})};t.prototype.componentDidLoad=function(){var t=this.createFormPage(this.label);this.el.querySelector("ion-nav").setRoot(t)};t.prototype.setValue=function(t){if(!this.feature)return;this.feature.properties=this.feature.properties||{};this.feature.properties[t.detail.field.attribute]=t.detail.value;this.glFormFeatureChanged.emit({formId:this.formId,feature:this.feature})};t.prototype.handleFacet=function(t){var e=this.createFormPage(t.detail.label,t.detail.value);this.el.querySelector("ion-nav").push(e)};t.prototype.cancel=function(){return __awaiter(this,void 0,void 0,function(){return __generator(this,function(t){this.glFormCancel.emit({formId:this.formId,feature:this.feature});return[2]})})};t.prototype.submit=function(){return __awaiter(this,void 0,void 0,function(){return __generator(this,function(t){this.glFormSubmit.emit({formId:this.formId,feature:this.feature});return[2]})})};t.prototype.createFormPage=function(t,e){var r=document.createElement("gl-form-page");r.formFacet=e;r.facets=this.filter(this._schema.facets||[],e);r.fields=this.filter(this._schema.fields||[],e);r.root=!e;if(t)r.label=t;if(this.submitText)r.submitText=this.submitText;if(this.cancelText)r.cancelText=this.cancelText;return r};t.prototype.filter=function(t,e){var r=this;return t.filter(function(t){var r=t.facets||[];if(!r.length&&!e)return true;for(var n=0,i=r;n<i.length;n++){var o=i[n];var a=o.replace(/[.?+^$[\]\\(){}|-]/g,"\\$&");var u=new RegExp("^"+a.split("*").join(".*")+"$");if(u.test(e))return true}return false}).map(function(t){var n=Object.assign({},t);if(r.translateText)n.label=o(t.label);if(t.options)n.options=r.filter(t.options,e);return n})};t.prototype.render=function(){return n("ion-nav",null)};Object.defineProperty(t.prototype,"el",{get:function(){return i(this)},enumerable:true,configurable:true});return t}();t("gl_form",a);var u=0}}});