text: !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@lrnwebcomponents/simple-tooltip/simple-tooltip.js"),require("@lrnwebcomponents/hexagon-loader/hexagon-loader.js"),require("lit"),require("@lrnwebcomponents/simple-colors/simple-colors.js"),require("@lrnwebcomponents/simple-icon/lib/simple-icon-lite.js"),require("@lrnwebcomponents/simple-icon/lib/simple-icons.js"),require("@lrnwebcomponents/simple-icon/lib/simple-icon-button-lite.js"),require("@lrnwebcomponents/intersection-element/lib/IntersectionObserverMixin.js")):"function"==typeof define&&define.amd?define(["exports","@lrnwebcomponents/simple-tooltip/simple-tooltip.js","@lrnwebcomponents/hexagon-loader/hexagon-loader.js","lit","@lrnwebcomponents/simple-colors/simple-colors.js","@lrnwebcomponents/simple-icon/lib/simple-icon-lite.js","@lrnwebcomponents/simple-icon/lib/simple-icons.js","@lrnwebcomponents/simple-icon/lib/simple-icon-button-lite.js","@lrnwebcomponents/intersection-element/lib/IntersectionObserverMixin.js"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).CsvRender={},null,null,e.lit,e.simpleColors_js,null,null,null,e.IntersectionObserverMixin_js)}(this,(function(e,t,n,o,r,i,l,a,c){"use strict";function s(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);t&&(o=o.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,o)}return n}function u(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?s(Object(n),!0).forEach((function(t){b(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):s(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function p(e,t,n,o,r,i,l){try{var a=e[i](l),c=a.value}catch(e){return void n(e)}a.done?t(c):Promise.resolve(c).then(o,r)}function f(e,t){for(var n=0;n<t.length;n++){var o=t[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}function b(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function d(e){return d=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},d(e)}function m(e,t){return m=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},m(e,t)}function h(e,t){if(t&&("object"==typeof t||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}function y(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,o=d(e);if(t){var r=d(this).constructor;n=Reflect.construct(o,arguments,r)}else n=o.apply(this,arguments);return h(this,n)}}function g(e,t){for(;!Object.prototype.hasOwnProperty.call(e,t)&&null!==(e=d(e)););return e}function v(){return v="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(e,t,n){var o=g(e,t);if(o){var r=Object.getOwnPropertyDescriptor(o,t);return r.get?r.get.call(arguments.length<3?e:n):r.value}},v.apply(this,arguments)}function w(e,t){return t||(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}}))}function j(e){return function(e){if(Array.isArray(e))return O(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e,t){if(!e)return;if("string"==typeof e)return O(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return O(e,t)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function O(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,o=new Array(t);n<t;n++)o[n]=e[n];return o}var x,k,S,P,_,R,D=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&m(e,t)}(c,e);var t,n,r,i,l,a=y(c);function c(){var e;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,c),(e=a.call(this)).loading=!1,e.table=[],e.tableHeadings=[],e.tableData="",e}return t=c,n=[{key:"updated",value:function(e){var t=this;v(d(c.prototype),"updated",this)&&v(d(c.prototype),"updated",this).call(this,e),e.forEach((function(e,n){"elementVisible"==n&&t.elementVisible,["dataSource","elementVisible"].includes(n)&&t.dataSource&&t.elementVisible&&(clearTimeout(t.__debouce),t.loading=!0,t.__debouce=setTimeout((function(){t.loadCSVData()}),500))}))}},{key:"render",value:function(){return o.html(x||(x=w(['\n      <hexagon-loader\n        id="loading"\n        accent-color="','"\n        ?loading="','"\n        item-count="4"\n        size="small"\n      ></hexagon-loader>\n      <a href="','" id="download" tabindex="-1">\n        <simple-icon-button-lite\n          id="ficon"\n          icon="file-download"\n        ></simple-icon-button-lite>\n      </a>\n      <simple-tooltip for="ficon" offset="14" position="top"\n        >Download table data</simple-tooltip\n      >\n      <table class="table" summary="','">\n        ',"\n        <thead>\n          <tr>\n            ","\n          </tr>\n        </thead>\n        <tbody>\n          ","\n        </tbody>\n      </table>\n    "])),this.accentColor,this.loading,this.dataSource,this.summary,this.caption?o.html(k||(k=w(["\n              <caption>\n                ","\n              </caption>\n            "])),this.caption):"",this.tableHeadings.map((function(e){return o.html(S||(S=w([' <th scope="col">',"</th> "])),e)})),this.table.map((function(e){return o.html(P||(P=w(["\n              <tr>\n                ","\n              </tr>\n            "])),e.map((function(e){return o.html(_||(_=w([" <td>","</td> "])),e)})))})))}},{key:"handleResponse",value:function(){this.table=this.CSVtoArray(this.tableData),this.tableHeadings=this.table.shift(),this.loading=!1}},{key:"CSVtoArray",value:function(e){var t,n="",o=[""],r=[o],i=0,l=0,a=!0;for(t in e)'"'===(t=e[t])?(a&&t===n&&(o[i]+=t),a=!a):","===t&&a?t=o[++i]="":"\n"===t&&a?("\r"===n&&(o[i]=o[i].slice(0,-1)),o=r[++l]=[t=""],i=0):o[i]+=t,n=t;return r}},{key:"loadCSVData",value:(i=regeneratorRuntime.mark((function e(){var t=this;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,fetch(this.dataSource,{method:this.method}).then((function(e){if(e.ok)return e.text()})).then((function(e){t.tableData=e,t.handleResponse()}));case 2:case"end":return e.stop()}}),e,this)})),l=function(){var e=this,t=arguments;return new Promise((function(n,o){var r=i.apply(e,t);function l(e){p(r,n,o,l,a,"next",e)}function a(e){p(r,n,o,l,a,"throw",e)}l(void 0)}))},function(){return l.apply(this,arguments)})}],r=[{key:"styles",get:function(){return[].concat(j(v(d(c),"styles",this)),[o.css(R||(R=w(['\n        :host {\n          display: block;\n        }\n        .table {\n          width: 100%;\n          border: 1px solid var(--simple-colors-default-theme-accent-6);\n          border-collapse: collapse;\n          white-space: nowrap;\n          font-size: 16px;\n          background-color: var(--simple-colors-default-theme-grey-1);\n        }\n        .table thead {\n          padding-bottom: 0.16px;\n          position: sticky;\n        }\n        .table caption {\n          background-color: var(--simple-colors-default-theme-accent-1);\n          font-weight: bold;\n          padding: 8px;\n          border: 1px solid var(--simple-colors-default-theme-accent-6);\n          border-bottom: none;\n        }\n        :host(:not([accent-color])) .table caption,\n        :host([accent-color="grey"]) .table caption {\n          background-color: var(--simple-colors-default-theme-accent-2);\n        }\n        .table tbody tr {\n          position: relative;\n          height: 48px;\n          -webkit-transition-duration: 0.28s;\n          transition-duration: 0.28s;\n          -webkit-transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);\n          transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);\n          -webkit-transition-property: background-color;\n          transition-property: background-color;\n        }\n        .table tbody tr:hover {\n          background-color: var(--simple-colors-default-theme-accent-1);\n        }\n        :host(:not([accent-color])) .table tbody tr:hover,\n        :host([accent-color="grey"]) .table tbody tr:hover {\n          background-color: var(--simple-colors-default-theme-accent-2);\n        }\n        .table td,\n        .table thead th,\n        .table th {\n          padding: 0 1.125em;\n          text-align: left;\n        }\n        .table td {\n          border-top: 1px solid var(--simple-colors-default-theme-accent-6);\n          border-bottom: 1px solid var(--simple-colors-default-theme-accent-6);\n        }\n        .table th {\n          position: relative;\n          vertical-align: bottom;\n          text-overflow: ellipsis;\n          font-size: 16px;\n          font-weight: bold;\n          line-height: 24px;\n          letter-spacing: 0;\n          color: rgba(0, 0, 0, 0.54);\n          height: 48px;\n          padding-bottom: 8px;\n          box-sizing: border-box;\n        }\n        #loading {\n          position: absolute;\n          left: calc(50% - 70px);\n        }\n        simple-icon-lite {\n          display: inline-flex;\n          margin: 0;\n          padding: 0;\n        }\n        #download button:hover,\n        #download button:focus,\n        #download button:active {\n          color: var(--simple-colors-default-theme-accent-8);\n          outline: 2px solid var(--simple-colors-default-theme-accent-6);\n        }\n      '])))])}},{key:"tag",get:function(){return"csv-render"}},{key:"properties",get:function(){return u(u({},v(d(c),"properties",this)),{},{dataSource:{type:String,attribute:"data-source"},loading:{type:Boolean},caption:{type:String},summary:{type:String},table:{type:Array},tableHeadings:{type:Array},tableData:{type:String,attribute:"table-data"}})}}],n&&f(t.prototype,n),r&&f(t,r),c}(c.IntersectionObserverMixin(r.SimpleColors));window.customElements.define(D.tag,D),e.CsvRender=D,Object.defineProperty(e,"__esModule",{value:!0})}));
  