import{r as t,c as e,h as i,g as s}from"./p-823ca21f.js";import{GcConsole as o}from"../gc-core-assets/lib/GcConsole";import{GcFiles as a}from"../gc-core-assets/lib/GcFiles";import{GcLocalStorage as n}from"../gc-core-assets/lib/GcLocalStorage";import{ActionRegistry as c}from"../gc-widget-menu/lib/ActionRegistry";import{GcUtils as d}from"../gc-core-assets/lib/GcUtils";const r=':host{margin:auto}:host gc-widget-dialog{width:650px;height:650px}:host #icon-min,:host #icon-close{--gc-color:"white",\n      width: 40px}:host gc-widget-button[slot=icon-area]{--gc-dialog-button-padding:0px}';const h=new o("gc-widget-readme");let l=class{constructor(i){t(this,i);this.cssPropertyChanged=e(this,"css-property-changed",7);this.expanded=false;this.renderDialog=false;this.getDontShowReadMeCheckbox=()=>n.getItem(`${this.projectName+this.projectVersion}_dontshowreadmeagain`)==="true"?true:false;this.setDontShowReadMeCheckbox=t=>{n.setItem(`${this.projectName+this.projectVersion}_dontshowreadmeagain`,t.detail.value.toString())};this._refresh=0;this.hidden=false}onExpandedChanged(t){if(t){const t=window.innerWidth-12;const e=window.innerHeight-12;this.dialogEl.setCSSProperty("width",`${t}px`);this.dialogEl.setCSSProperty("height",`${e}px`)}else{this.dialogEl.setCSSProperty("width","650px");this.dialogEl.setCSSProperty("height","650px")}}connectedCallback(){c.registerAction("cmd_open_readme",{run:async()=>{if(this.dialogEl)await this.dialogEl.open();else h.error("No README.md file found")}})}disconnectedCallback(){c.unregisterAction("cmd_open_readme")}componentDidRender(){if(!(this.getDontShowReadMeCheckbox()||d.isInDesigner||d.isInPreview)){if(this.dialogEl){this.dialogEl.open(true)}}}async componentWillRender(){this.projectName?null:this.projectName=await a.getProjectName();this.projectVersion?null:this.projectVersion=await a.getProjectVersion();this.renderDialog=await this.doesReadMeExist()}async doesReadMeExist(){try{await a.readTextFile("./README.md");return true}catch(t){return false}}render(){return this.renderDialog?i("gc-widget-dialog",{id:"readmeElementDialog",heading:"README.md",ref:t=>this.dialogEl=t,closeOnEsc:true},i("gc-widget-markdown",{file:"./README.md"}),i("gc-widget-checkbox",{checked:this.getDontShowReadMeCheckbox(),slot:"action-bar",id:"dontShowCheckbox","onChecked-changed":this.setDontShowReadMeCheckbox,label:"Don't show again"}),i("gc-widget-button",{id:"READMEOkButton",class:"dialog-confirm",slot:"action-bar",label:"OK"}),i("gc-widget-button",{icon:this.expanded?"round:action:close_fullscreen":"round:action:open_in_full",slot:"icon-area",id:"readmeWinToggle",onClick:()=>this.expanded=!this.expanded}),i("gc-widget-button",{icon:"round:navigation:close",slot:"icon-area",id:"readmeWinClose",class:"dialog-dismiss"})):i("div",{style:{display:"none"}})}async setCSSProperty(t,e){e=e.trim();if(await this.getCSSProperty(t)!==e){this.el.style.setProperty(t,e);this.cssPropertyChanged.emit({name:t,value:e})}}async getCSSProperty(t){return getComputedStyle(this.el).getPropertyValue(t).trim()}async refresh(){this._refresh++}get el(){return s(this)}static get watchers(){return{expanded:["onExpandedChanged"]}}};l.style=r;export{l as gc_widget_readme};
//# sourceMappingURL=p-e09d1583.entry.js.map