UNPKG

iobroker.lovelace

Version:

With this adapter you can build visualization for ioBroker with Home Assistant Lovelace UI

10 lines 16.8 kB
"use strict";(self.rspackChunkhome_assistant_frontend=self.rspackChunkhome_assistant_frontend||[]).push([[33887],{67258:function(e,t,i){i.d(t,{d:function(){return a}});const a=e=>{switch(e.language){case"cs":case"de":case"fi":case"fr":case"sk":case"sv":return" ";default:return""}}},41060:function(e,t,i){i.a(e,async function(e,t){try{i(18111),i(61701),i(62953);var a=i(40445),o=i(5124),r=i(67576),s=i(6412),n=i(44537),l=i(1087),d=i(67258),c=i(46187),p=i(18350),h=i(26300),u=i(94355),g=e([p,h,u]);[p,h,u]=g.then?(await g)():g;let v,m,f,b,y,_,$,k,M=e=>e;const w="M19,4H15.5L14.5,3H9.5L8.5,4H5V6H19M6,19A2,2 0 0,0 8,21H16A2,2 0 0,0 18,19V7H6V19Z",x="M14,2H6A2,2 0 0,0 4,4V20A2,2 0 0,0 6,22H18A2,2 0 0,0 20,20V8L14,2M13.5,16V19H10.5V16H8L12,12L16,16H13.5M13,9V3.5L18.5,9H13Z";class C extends o.WF{firstUpdated(e){super.firstUpdated(e),this.autoOpenFileDialog&&this._openFilePicker()}get _name(){if(void 0===this.value)return"";if("string"==typeof this.value)return this.value;return(this.value instanceof FileList?Array.from(this.value):(0,n.e)(this.value)).map(e=>e.name).join(", ")}render(){const e=this.localize||this.hass.localize;return(0,o.qy)(v||(v=M` ${0} `),this.uploading?(0,o.qy)(m||(m=M`<div class="container"> <div class="uploading"> <span class="header">${0}</span> ${0} </div> <ha-progress-bar .indeterminate="${0}" .value="${0}" loading></ha-progress-bar> </div>`),this.uploadingLabel||(this.value?e("ui.components.file-upload.uploading_name",{name:this._name}):e("ui.components.file-upload.uploading")),this.progress?(0,o.qy)(f||(f=M`<div class="progress"> ${0}${0}% </div>`),this.progress,this.hass&&(0,d.d)(this.hass.locale)):o.s6,!this.progress,this.progress):(0,o.qy)(b||(b=M`<label for="${0}" class="container ${0}" @drop="${0}" @dragenter="${0}" @dragover="${0}" @dragleave="${0}" @dragend="${0}">${0} <input id="input" type="file" class="file" .accept="${0}" .multiple="${0}" @change="${0}"></label>`),this.value?"":"input",(0,s.H)({dragged:this._drag,multiple:this.multiple,value:Boolean(this.value)}),this._handleDrop,this._handleDragStart,this._handleDragStart,this._handleDragEnd,this._handleDragEnd,this.value?"string"==typeof this.value?(0,o.qy)(_||(_=M`<div class="row"> <div class="value" @click="${0}"> <ha-svg-icon .path="${0}"></ha-svg-icon> ${0} </div> <ha-icon-button @click="${0}" .label="${0}" .path="${0}"></ha-icon-button> </div>`),this._openFilePicker,this.icon||x,this.value,this._clearValue,this.deleteLabel||e("ui.common.delete"),w):(this.value instanceof FileList?Array.from(this.value):(0,n.e)(this.value)).map(t=>(0,o.qy)($||($=M`<div class="row"> <div class="value" @click="${0}"> <ha-svg-icon .path="${0}"></ha-svg-icon> ${0} - ${0} </div> <ha-icon-button @click="${0}" .label="${0}" .path="${0}"></ha-icon-button> </div>`),this._openFilePicker,this.icon||x,t.name,(0,c.A)(t.size),this._clearValue,this.deleteLabel||e("ui.common.delete"),w)):(0,o.qy)(y||(y=M`<ha-button size="small" appearance="filled" @click="${0}"> <ha-svg-icon slot="start" .path="${0}"></ha-svg-icon> ${0} </ha-button> <span class="secondary">${0}</span> <span class="supports">${0}</span>`),this._openFilePicker,this.icon||x,this.label||e("ui.components.file-upload.label"),this.secondary||e("ui.components.file-upload.secondary"),this.supports),this.accept,this.multiple,this._handleFilePicked))}_openFilePicker(){var e;null===(e=this._input)||void 0===e||e.click()}_handleDrop(e){var t;e.preventDefault(),e.stopPropagation(),null!==(t=e.dataTransfer)&&void 0!==t&&t.files&&(0,l.r)(this,"file-picked",{files:this.multiple||1===e.dataTransfer.files.length?Array.from(e.dataTransfer.files):[e.dataTransfer.files[0]]}),this._drag=!1}_handleDragStart(e){e.preventDefault(),e.stopPropagation(),this._drag=!0}_handleDragEnd(e){e.preventDefault(),e.stopPropagation(),this._drag=!1}_handleFilePicked(e){0!==e.target.files.length&&(this.value=e.target.files,(0,l.r)(this,"file-picked",{files:e.target.files}))}_clearValue(e){e.preventDefault(),this._input.value="",this.value=void 0,(0,l.r)(this,"change"),(0,l.r)(this,"files-cleared")}constructor(...e){super(...e),this.multiple=!1,this.disabled=!1,this.uploading=!1,this.autoOpenFileDialog=!1,this._drag=!1}}C.styles=(0,o.AH)(k||(k=M`:host{display:block;height:240px}:host([disabled]){pointer-events:none;color:var(--disabled-text-color)}.container{position:relative;display:flex;flex-direction:column;justify-content:center;align-items:center;border:solid 1px var(--mdc-text-field-idle-line-color,rgba(0,0,0,.42));border-radius:var(--mdc-shape-small,var(--ha-border-radius-sm));height:100%}.row{display:flex;align-items:center}label.container{border:dashed 1px var(--mdc-text-field-idle-line-color,rgba(0,0,0,.42));cursor:pointer}.container .uploading{display:flex;flex-direction:column;width:100%;align-items:flex-start;padding:0 32px;box-sizing:border-box}:host([disabled]) .container{border-color:var(--disabled-color)}label.dragged,label:hover{border-style:solid}label.dragged{border-color:var(--primary-color)}.dragged:before{position:absolute;top:0;right:0;bottom:0;left:0;background-color:var(--primary-color);content:"";opacity:var(--dark-divider-opacity);pointer-events:none;border-radius:var(--mdc-shape-small,4px)}label.value{cursor:default}label.value.multiple{justify-content:unset;overflow:auto}.highlight{color:var(--primary-color)}ha-button{margin-bottom:8px}.supports{color:var(--secondary-text-color);font-size:var(--ha-font-size-s)}:host([disabled]) .secondary{color:var(--disabled-text-color)}input.file{display:none}.value{cursor:pointer}.value ha-svg-icon{margin-right:8px;margin-inline-end:8px;margin-inline-start:initial}ha-button{--mdc-button-outline-color:var(--primary-color);--ha-icon-button-size:24px}ha-progress-bar{width:100%;padding:8px 32px;box-sizing:border-box}.header{font-weight:var(--ha-font-weight-medium)}.progress{color:var(--secondary-text-color)}button.link{background:0 0;border:none;padding:0;font-size:var(--ha-font-size-m);color:var(--primary-color);text-decoration:underline;cursor:pointer}`)),(0,a.Cg)([(0,r.MZ)({attribute:!1})],C.prototype,"hass",void 0),(0,a.Cg)([(0,r.MZ)({attribute:!1})],C.prototype,"localize",void 0),(0,a.Cg)([(0,r.MZ)()],C.prototype,"accept",void 0),(0,a.Cg)([(0,r.MZ)()],C.prototype,"icon",void 0),(0,a.Cg)([(0,r.MZ)()],C.prototype,"label",void 0),(0,a.Cg)([(0,r.MZ)()],C.prototype,"secondary",void 0),(0,a.Cg)([(0,r.MZ)({attribute:"uploading-label"})],C.prototype,"uploadingLabel",void 0),(0,a.Cg)([(0,r.MZ)({attribute:"delete-label"})],C.prototype,"deleteLabel",void 0),(0,a.Cg)([(0,r.MZ)()],C.prototype,"supports",void 0),(0,a.Cg)([(0,r.MZ)({type:Object})],C.prototype,"value",void 0),(0,a.Cg)([(0,r.MZ)({type:Boolean})],C.prototype,"multiple",void 0),(0,a.Cg)([(0,r.MZ)({type:Boolean,reflect:!0})],C.prototype,"disabled",void 0),(0,a.Cg)([(0,r.MZ)({type:Boolean})],C.prototype,"uploading",void 0),(0,a.Cg)([(0,r.MZ)({type:Number})],C.prototype,"progress",void 0),(0,a.Cg)([(0,r.MZ)({type:Boolean,attribute:"auto-open-file-dialog"})],C.prototype,"autoOpenFileDialog",void 0),(0,a.Cg)([(0,r.wk)()],C.prototype,"_drag",void 0),(0,a.Cg)([(0,r.P)("#input")],C.prototype,"_input",void 0),C=(0,a.Cg)([(0,r.EM)("ha-file-upload")],C),t()}catch(v){t(v)}})},44002:function(e,t,i){i.a(e,async function(e,t){try{i(74423),i(3362),i(62953);var a=i(40445),o=i(5124),r=i(67576),s=i(1087),n=i(14503),l=i(3129),d=i(65063),c=i(4658),p=i(18350),h=i(41060),u=i(95287),g=e([p,h]);[p,h]=g.then?(await g)():g;let v,m,f,b,y,_=e=>e;const $="M18 15V18H15V20H18V23H20V20H23V18H20V15H18M13.3 21H5C3.9 21 3 20.1 3 19V5C3 3.9 3.9 3 5 3H19C20.1 3 21 3.9 21 5V13.3C20.4 13.1 19.7 13 19 13C17.9 13 16.8 13.3 15.9 13.9L14.5 12L11 16.5L8.5 13.5L5 18H13.1C13 18.3 13 18.7 13 19C13 19.7 13.1 20.4 13.3 21Z";class k extends o.WF{render(){if(!this.value){const e=this.secondary||(this.selectMedia?(0,o.qy)(v||(v=_`${0}`),this.hass.localize("ui.components.picture-upload.secondary",{select_media:(0,o.qy)(m||(m=_`<button class="link" @click="${0}"> ${0} </button>`),this._chooseMedia,this.hass.localize("ui.components.picture-upload.select_media"))})):void 0);return(0,o.qy)(f||(f=_` <ha-file-upload .hass="${0}" .icon="${0}" .label="${0}" .secondary="${0}" .supports="${0}" .uploading="${0}" @file-picked="${0}" @change="${0}" accept="image/png, image/jpeg, image/gif"></ha-file-upload> `),this.hass,$,this.label||this.hass.localize("ui.components.picture-upload.label"),e,this.supports||this.hass.localize("ui.components.picture-upload.supported_formats"),this._uploading,this._handleFilePicked,this._handleFileCleared)}return(0,o.qy)(b||(b=_`<div class="center-vertical"> <div class="value"> <img .src="${0}" alt="${0}"> <div> <ha-button appearance="plain" size="small" variant="danger" @click="${0}"> ${0} </ha-button> </div> </div> </div>`),this.value,this.currentImageAltText||this.hass.localize("ui.components.picture-upload.current_image_alt"),this._handleChangeClick,this.hass.localize("ui.components.picture-upload.clear_picture"))}_handleChangeClick(){this.value=null,(0,s.r)(this,"change")}async _handleFilePicked(e){const t=e.detail.files[0];this.crop?this._cropFile(t):this._uploadFile(t)}async _handleFileCleared(){this.value=null}async _cropFile(e,t){["image/png","image/jpeg","image/gif"].includes(e.type)?(0,c.Q)(this,{file:e,options:this.cropOptions||{round:!1,aspectRatio:NaN},croppedCallback:i=>{t&&i===e?(this.value=(0,l.Q0)(t,this.size,this.original),(0,s.r)(this,"change")):this._uploadFile(i)}}):(0,d.showAlertDialog)(this,{text:this.hass.localize("ui.components.picture-upload.unsupported_format")})}async _uploadFile(e){if(["image/png","image/jpeg","image/gif"].includes(e.type)){this._uploading=!0;try{const t=await(0,l.mF)(this.hass,e);if(this.fullMedia){const e={media_content_id:`${l.AP}/${t.id}`,media_content_type:t.content_type,title:t.name,media_class:"image",can_play:!0,can_expand:!1,can_search:!1,thumbnail:(0,l.Q0)(t.id,256)},i=[{},{media_content_type:"app",media_content_id:l.AP}];(0,s.r)(this,"media-picked",{item:e,navigateIds:i})}else this.value=(0,l.Q0)(t.id,this.size,this.original),(0,s.r)(this,"change")}catch(t){(0,d.showAlertDialog)(this,{text:t.toString()})}finally{this._uploading=!1}}else(0,d.showAlertDialog)(this,{text:this.hass.localize("ui.components.picture-upload.unsupported_format")})}static get styles(){return[n.RF,(0,o.AH)(y||(y=_`:host{display:block;height:240px}ha-file-upload{height:100%}.center-vertical{display:flex;align-items:center;height:100%}.value{width:100%;display:flex;flex-direction:column;align-items:center}img{max-width:100%;max-height:200px;margin-bottom:4px;border-radius:var(--file-upload-image-border-radius);transition:opacity .3s;opacity:var(--picture-opacity, 1)}img:hover{opacity:1}`))]}constructor(...e){super(...e),this.value=null,this.crop=!1,this.selectMedia=!1,this.fullMedia=!1,this.original=!1,this.size=512,this._uploading=!1,this._chooseMedia=()=>{(0,u.O)(this,{action:"pick",entityId:"browser",accept:["image/*"],navigateIds:this.fullMedia?void 0:[{media_content_id:void 0,media_content_type:void 0},{media_content_id:l.AP,media_content_type:"app"}],minimumNavigateLevel:this.fullMedia?void 0:2,hideContentType:!0,contentIdHelper:this.contentIdHelper,mediaPickedCallback:async e=>{if(this.fullMedia)return void(0,s.r)(this,"media-picked",e);const t=(0,l.pD)(e.item.media_content_id);if(t)if(this.crop){const a=(0,l.Q0)(t,void 0,!0);let o;try{o=await(0,l.M5)(this.hass,a)}catch(i){return void(0,d.showAlertDialog)(this,{text:i.toString()})}const r={type:e.item.media_content_type},s=new File([o],e.item.title,r);this._cropFile(s,t)}else this.value=(0,l.Q0)(t,this.size,this.original),(0,s.r)(this,"change")}})}}}(0,a.Cg)([(0,r.MZ)()],k.prototype,"value",void 0),(0,a.Cg)([(0,r.MZ)()],k.prototype,"label",void 0),(0,a.Cg)([(0,r.MZ)()],k.prototype,"secondary",void 0),(0,a.Cg)([(0,r.MZ)()],k.prototype,"supports",void 0),(0,a.Cg)([(0,r.MZ)({attribute:!1})],k.prototype,"currentImageAltText",void 0),(0,a.Cg)([(0,r.MZ)({type:Boolean})],k.prototype,"crop",void 0),(0,a.Cg)([(0,r.MZ)({type:Boolean,attribute:"select-media"})],k.prototype,"selectMedia",void 0),(0,a.Cg)([(0,r.MZ)({type:Boolean,attribute:"full-media"})],k.prototype,"fullMedia",void 0),(0,a.Cg)([(0,r.MZ)({attribute:!1})],k.prototype,"contentIdHelper",void 0),(0,a.Cg)([(0,r.MZ)({attribute:!1})],k.prototype,"cropOptions",void 0),(0,a.Cg)([(0,r.MZ)({type:Boolean})],k.prototype,"original",void 0),(0,a.Cg)([(0,r.MZ)({type:Number})],k.prototype,"size",void 0),(0,a.Cg)([(0,r.wk)()],k.prototype,"_uploading",void 0),k=(0,a.Cg)([(0,r.EM)("ha-picture-upload")],k),t()}catch(v){t(v)}})},95287:function(e,t,i){i.d(t,{O:function(){return o}});i(3362),i(62953);var a=i(1087);const o=(e,t)=>{(0,a.r)(e,"show-dialog",{dialogTag:"dialog-media-player-browse",dialogImport:()=>Promise.all([i.e(39763),i.e(32450),i.e(46095),i.e(7305),i.e(92769),i.e(34995),i.e(3283),i.e(80131),i.e(70183),i.e(56704),i.e(3469),i.e(62574),i.e(26092),i.e(39005),i.e(8851),i.e(91845),i.e(57296),i.e(93152)]).then(i.bind(i,93565)),dialogParams:t})}},94355:function(e,t,i){i.a(e,async function(e,t){try{i(62953);var a=i(40445),o=i(88590),r=i(5124),s=i(67576),n=e([o]);o=(n.then?(await n)():n)[0];let l,d=e=>e;class c extends o.A{static get styles(){return[o.A.styles,(0,r.AH)(l||(l=d`:host{--indicator-color:var( --ha-progress-bar-indicator-color, var(--ha-color-on-primary-normal) );--track-color:var( --ha-progress-bar-track-color, var(--ha-color-fill-neutral-normal-hover) );--track-height:var(--ha-progress-bar-track-height, 12px);--wa-transition-slow:var(--ha-animation-duration-slow);position:relative}.progress-bar{border-radius:var(--ha-progress-bar-border-radius,var(--ha-border-radius-pill))}.indicator{background:var(--ha-progress-bar-indicator-background,var(--indicator-color))}:host([indeterminate]) .indicator{animation:wa-progress-indeterminate var(--ha-progress-bar-animation-duration,2.5s) infinite cubic-bezier(.37,0,.63,1)}@keyframes slide-highlight{0%{transform:translateX(-200%)}100%{transform:translateX(200%)}}:host([loading]:not([indeterminate])) .progress-bar::after{content:"";position:absolute;inset:0;background:linear-gradient(90deg,transparent 0%,oklch(from var(--indicator-color) 85% c h) 50%,transparent 100%);opacity:.5;animation:slide-highlight var(--ha-progress-bar-animation-duration,2.5s) infinite cubic-bezier(.37,0,.63,1);width:50%}:host::after{--width:var( --ha-progress-bar-indicator-highlight-width, calc(var(--track-height) * 2) );width:var(--width);height:var(--ha-progress-bar-indicator-highlight-height,calc(var(--track-height) * 2));content:"";position:absolute;inset-inline-start:clamp(var(--width)/ 2,var(--percentage,0%),calc(100% - var(--width)/ 2));top:50%;transform:translate(-50%,-50%);background-image:var(--ha-progress-bar-indicator-highlight-image);background-size:contain;background-repeat:no-repeat;background-position:center;pointer-events:none;transition:inset-inline-start var(--wa-transition-slow, 200ms) var(--wa-transition-easing, ease)}:host([indeterminate])::after{display:none}`))]}constructor(...e){super(...e),this.loading=!1}}(0,a.Cg)([(0,s.MZ)({type:Boolean,reflect:!0})],c.prototype,"loading",void 0),c=(0,a.Cg)([(0,s.EM)("ha-progress-bar")],c),t()}catch(l){t(l)}})},3129:function(e,t,i){i.d(t,{AP:function(){return o},M5:function(){return d},Q0:function(){return s},mF:function(){return n},pD:function(){return r},vS:function(){return l}});i(16280),i(3362);const a="/api/image/serve/",o="media-source://image_upload",r=e=>{let t;if(e.startsWith(a)){t=e.substring(17);const i=t.indexOf("/");i>=0&&(t=t.substring(0,i))}else e.startsWith(o)&&(t=e.substring(o.length+1));return t},s=(e,t,i=!1)=>{if(!i&&!t)throw new Error("Size must be provided if original is false");return i?`/api/image/serve/${e}/original`:`/api/image/serve/${e}/${t}x${t}`},n=async(e,t)=>{const i=new FormData;i.append("file",t);const a=await e.fetchWithAuth("/api/image/upload",{method:"POST",body:i});if(413===a.status)throw new Error(`Uploaded image is too large (${t.name})`);if(200!==a.status)throw new Error("Unknown error");return a.json()},l=(e,t)=>e.callWS({type:"image/delete",image_id:t}),d=async(e,t)=>{const i=await fetch(e.hassUrl(t));if(!i.ok)throw new Error(`Failed to fetch image: ${i.statusText?i.statusText:i.status}`);return i.blob()}},4658:function(e,t,i){i.d(t,{Q:function(){return r}});i(3362),i(62953);var a=i(1087);const o=()=>Promise.all([i.e(78661),i.e(27441)]).then(i.bind(i,97424)),r=(e,t)=>{(0,a.r)(e,"show-dialog",{dialogTag:"image-cropper-dialog",dialogImport:o,dialogParams:t})}},46187:function(e,t,i){i.d(t,{A:function(){return a}});const a=(e=0,t=2)=>{if(0===e)return"0 Bytes";t=t<0?0:t;const i=Math.floor(Math.log(e)/Math.log(1024));return`${parseFloat((e/1024**i).toFixed(t))} ${["Bytes","KB","MB","GB","TB","PB","EB","ZB","YB"][i]}`}}}]);