Object.defineProperty(exports,"__esModule",{value:!0}),exports.HaxPreferencesDialog=void 0;var e=require("lit"),t=require("@lrnwebcomponents/hax-body-behaviors/lib/HAXFields.js");require("@lrnwebcomponents/simple-icon/lib/simple-icon-lite.js"),require("@lrnwebcomponents/simple-icon/lib/simple-icon-button.js"),require("@lrnwebcomponents/simple-fields/simple-fields.js");var r=require("./hax-store.js"),n=require("mobx");function _typeof(e){return(_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function _typeof(e){return typeof e}:function _typeof(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function ownKeys(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function _objectSpread(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?ownKeys(r,!0).forEach((function(t){_defineProperty(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):ownKeys(r).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function _defineProperty(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function _toConsumableArray(e){return function _arrayWithoutHoles(e){if(Array.isArray(e)){for(var t=0,r=new Array(e.length);t<e.length;t++)r[t]=e[t];return r}}(e)||function _iterableToArray(e){if(Symbol.iterator in Object(e)||"[object Arguments]"===Object.prototype.toString.call(e))return Array.from(e)}(e)||function _nonIterableSpread(){throw new TypeError("Invalid attempt to spread non-iterable instance")}()}function _templateObject3_02bc7750feba11eb8439e3eec9305af7(){var e=_taggedTemplateLiteral(['<a\n            href="https://haxtheweb.org/"\n            rel="noopener"\n            id="link"\n            target="_blank"\n            part="haxlink"\n            >Learn more about HAX</a\n          >']);return _templateObject3_02bc7750feba11eb8439e3eec9305af7=function _templateObject3_02bc7750feba11eb8439e3eec9305af7(){return e},e}function _templateObject2_02bc7750feba11eb8439e3eec9305af7(){var e=_taggedTemplateLiteral(['\n      <div style="height: 100%; overflow: auto;" class="pref-container">\n        <simple-fields\n          id="settingsform"\n          .schematizer="','"\n          .elementizer="','"\n        >\n        </simple-fields>\n      </div>\n      <hr />\n      <br />\n      <br />\n      ',"\n    "]);return _templateObject2_02bc7750feba11eb8439e3eec9305af7=function _templateObject2_02bc7750feba11eb8439e3eec9305af7(){return e},e}function _templateObject_02bc7750feba11eb8439e3eec9305af7(){var e=_taggedTemplateLiteral(["\n        :host {\n          display: block;\n        }\n        .pref-container {\n          text-align: left;\n        }\n        simple-icon-button {\n          float: right;\n        }\n      "]);return _templateObject_02bc7750feba11eb8439e3eec9305af7=function _templateObject_02bc7750feba11eb8439e3eec9305af7(){return e},e}function _taggedTemplateLiteral(e,t){return t||(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}}))}function _possibleConstructorReturn(e,t){return!t||"object"!==_typeof(t)&&"function"!=typeof t?function _assertThisInitialized(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e):t}function _getPrototypeOf(e){return(_getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf:function _getPrototypeOf(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function _defineProperties(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function _createClass(e,t,r){return t&&_defineProperties(e.prototype,t),r&&_defineProperties(e,r),e}function _setPrototypeOf(e,t){return(_setPrototypeOf=Object.setPrototypeOf||function _setPrototypeOf(e,t){return e.__proto__=t,e})(e,t)}var o=function(o){function HaxPreferencesDialog(){var e;return function _classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,HaxPreferencesDialog),(e=_possibleConstructorReturn(this,_getPrototypeOf(HaxPreferencesDialog).call(this))).hideLink=!1,e.title="Advanced settings",e.schema=[{property:"haxVoiceCommands",title:"Voice commands",description:"Experimental: Voice based control system",inputMethod:"boolean",value:!1},{property:"haxUiTheme",title:"HAX UI Theme",description:"Change the theme of the HAX interface (not the site's content).",inputMethod:"radio",options:{hax:"Default (light)",haxdark:"Dark",system:"System Default"},value:"hax"}],e.schemaValues={haxVoiceCommands:!1},(0,n.autorun)((function(){e.globalPreferences=(0,n.toJS)(r.HAXStore.globalPreferences),e.schemaValues=(0,n.toJS)(r.HAXStore.globalPreferences)})),e}return function _inherits(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&&_setPrototypeOf(e,t)}(HaxPreferencesDialog,e.LitElement),_createClass(HaxPreferencesDialog,null,[{key:"styles",get:function get(){return[(0,e.css)(_templateObject_02bc7750feba11eb8439e3eec9305af7())]}}]),_createClass(HaxPreferencesDialog,[{key:"closeBtn",value:function closeBtn(e){this.dispatchEvent(new CustomEvent("hax-tray-button-click",{bubbles:!0,cancelable:!0,composed:!0,detail:{eventName:"open-preferences",index:0,value:!0}}))}},{key:"render",value:function render(){return(0,e.html)(_templateObject2_02bc7750feba11eb8439e3eec9305af7(),t.HaxSchematizer,t.HaxElementizer,this.hideLink?"":(0,e.html)(_templateObject3_02bc7750feba11eb8439e3eec9305af7()))}},{key:"firstUpdated",value:function firstUpdated(e){this.shadowRoot.querySelector("#settingsform").fields=_toConsumableArray(this.schema),this.shadowRoot.querySelector("#settingsform").value=_objectSpread({},this.schemaValues),this.shadowRoot.querySelector("#settingsform").addEventListener("value-changed",this.__valueChangedEvent.bind(this))}},{key:"__valueChangedEvent",value:function __valueChangedEvent(e){e.detail.value&&(r.HAXStore.globalPreferences=_objectSpread({},e.detail.value))}},{key:"reloadPreferencesForm",value:function reloadPreferencesForm(){this.shadowRoot.querySelector("#settingsform").fields=_toConsumableArray(this.schema),this.shadowRoot.querySelector("#settingsform").value=_objectSpread({},this.schemaValues)}}],[{key:"tag",get:function get(){return"hax-preferences-dialog"}},{key:"properties",get:function get(){return{hideLink:{type:Boolean},title:{type:String},schema:{type:Object},globalPreferences:{type:Object}}}}]),HaxPreferencesDialog}();exports.HaxPreferencesDialog=o,window.customElements.define(o.tag,o);