import*as e from"highlight.js/lib/core";import*as t from"lit";import*as r from"lit/decorators.js";import*as i from"lit/directives/class-map.js";import*as o from"lit/directives/if-defined.js";import*as a from"lit/directives/style-map.js";var s,n,p={6436(e,t,r){r.d(t,{b:()=>i}),r(5983);var i,o=r(7704),a=r(4084),s=r(6579),n=r(2927),p=r(8899),l=r(3517),c=r(3241),f=function(e,t,r,i){var o,a=arguments.length,s=a<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,r):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,r,i);else for(var n=e.length-1;n>=0;n--)(o=e[n])&&(s=(a<3?o(s):a>3?o(t,r,s):o(t,r))||s);return a>3&&s&&Object.defineProperty(t,r,s),s},m=function(e,t,r,i){return new(r||(r=Promise))(function(o,a){function s(e){try{p(i.next(e))}catch(e){a(e)}}function n(e){try{p(i.throw(e))}catch(e){a(e)}}function p(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r(function(e){e(t)})).then(s,n)}p((i=i.apply(e,t||[])).next())})};!function(e){let t=class extends n.LitElement{constructor(){super(...arguments),this.acceptLanguage="javascript",this.getLocalization="Input File",this.acceptTypes="",this.fileName=""}static get styles(){return[a.A,c.A]}triggerFileLoad(e){e.preventDefault(),this.input.click()}handleFile(e){return m(this,void 0,void 0,function*(){e.preventDefault();const t=this.input.files;if(t&&0!==t.length)for(const e of t){this.fileName=e.name;try{yield this.readFile(e)}catch(e){console.error("Error reading file",e)}}})}readFile(e){return new Promise((t,r)=>{const i=new FileReader;i.onload=e=>{t(e.target.result)},i.onerror=e=>r(e),i.readAsText(e)})}importLanguage(e){return m(this,void 0,void 0,function*(){try{const{default:t}=yield import(`highlight.js/lib/languages/${e}`);s.default.registerLanguage(`${e}`,t),this.setAcceptTypes()}catch(e){console.warn("Please set correct language name")}})}getAllAcceptTypes(){const e=s.default.listLanguages();return e.length?e.map(e=>s.default.getLanguage(`${e}`).aliases).map(e=>e.map(e=>`.${e}`)).join(","):""}setAcceptTypes(){this.acceptTypes=this.getAllAcceptTypes()}updated(e){super.updated(e),e.has("acceptLanguage")&&this.importLanguage(this.acceptLanguage)}render(){return n.html`
        <div class="md-input-file">
          <label for="file-input">
            <md-button color="blue" class="md-input-file-btn" @click=${this.triggerFileLoad}>
              ${this.getLocalization.trim()}
            </md-button>
            ${this.fileName.length?this.fileName:n.nothing}
          </label>
          <input
            type="file"
            id="file-input"
            name="file-input"
            accept=${(0,l.ifDefined)(this.acceptTypes||void 0)}
            @change=${e=>this.handleFile(e)}
          />
        </div>
      `}};f([(0,p.property)({type:String,attribute:"accept-language"})],t.prototype,"acceptLanguage",void 0),f([(0,p.property)({type:String})],t.prototype,"getLocalization",void 0),f([(0,p.query)("input[type='file']")],t.prototype,"input",void 0),f([(0,p.state)()],t.prototype,"acceptTypes",void 0),f([(0,p.state)()],t.prototype,"fileName",void 0),t=f([(0,o.wW)("md-input-file")],t),e.ELEMENT=t}(i||(i={}))},2364(e,t,r){new WeakMap},7704(e,t,r){r.d(t,{wW:()=>i.w}),r(2364),r(3203),r(9938),r(5201),r(4781),r(608);var i=r(9609)},6579(t,r,i){var o,a;t.exports=(o={default:()=>e.default},a={},i.d(a,o),a)},2927(e,r,i){var o,a;e.exports=(o={LitElement:()=>t.LitElement,css:()=>t.css,html:()=>t.html,nothing:()=>t.nothing},a={},i.d(a,o),a)},8899(e,t,i){var o,a;e.exports=(o={property:()=>r.property,query:()=>r.query,state:()=>r.state},a={},i.d(a,o),a)},4955(e,t,r){var o,a;e.exports=(o={classMap:()=>i.classMap},a={},r.d(a,o),a)},3517(e,t,r){var i,a;e.exports=(i={ifDefined:()=>o.ifDefined},a={},r.d(a,i),a)},1156(e,t,r){var i,o;e.exports=(i={styleMap:()=>a.styleMap},o={},r.d(o,i),o)}},l={};function c(e){var t=l[e];if(void 0!==t)return t.exports;var r=l[e]={exports:{}};return p[e](r,r.exports,c),r.exports}c.m=p,s=[],c.O=(e,t,r,i)=>{if(!t){var o=1/0;for(l=0;l<s.length;l++){for(var[t,r,i]=s[l],a=!0,n=0;n<t.length;n++)(!1&i||o>=i)&&Object.keys(c.O).every(e=>c.O[e](t[n]))?t.splice(n--,1):(a=!1,i<o&&(o=i));if(a){s.splice(l--,1);var p=r();void 0!==p&&(e=p)}}return e}i=i||0;for(var l=s.length;l>0&&s[l-1][2]>i;l--)s[l]=s[l-1];s[l]=[t,r,i]},c.d=(e,t)=>{for(var r in t)c.o(t,r)&&!c.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},c.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);export{c as __webpack_require__};n={502:0,561:0,1745:0,2364:0,2942:0,4545:0,4928:0,5323:0,5369:0,6060:0,7032:0,7704:0,8111:0,8180:0,8442:0,9983:0},c.C=e=>{var t,r,{__webpack_esm_ids__:i,__webpack_esm_modules__:o,__webpack_esm_runtime__:a}=e,s=0;for(t in o)c.o(o,t)&&(c.m[t]=o[t]);for(a&&a(c);s<i.length;s++)r=i[s],c.o(n,r)&&n[r]&&n[r][0](),n[i[s]]=0;c.O()},c.O.j=e=>0===n[e];import*as f from"../9609.js";c.C(f);import*as m from"../4084.js";c.C(m);import*as u from"../3305.js";c.C(u);import*as d from"../4739.js";c.C(d);import*as g from"../7154.js";c.C(g);import*as h from"../9773.js";c.C(h);import*as v from"../5983.js";c.C(v);import*as y from"../9938.js";c.C(y);import*as j from"../4781.js";c.C(j);import*as b from"../5201.js";c.C(b);import*as L from"../8227.js";c.C(L);import*as _ from"../2900.js";c.C(_);import*as x from"../3203.js";c.C(x);import*as w from"../3241.js";c.C(w);var C=c.O(void 0,[9609,4084,3305,4739,7154,9773,5983,9938,4781,5201,8227,2900,3203,3241],()=>c(6436));const O=(C=c.O(C)).b;export{O as InputFile};