/* -*- coding: utf-8 -*- Copyright 2025 dpa-IT Services GmbH Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ (()=>{"use strict";class t extends HTMLElement{constructor(t=!0){super(),t&&this.attachShadow({mode:"open"}),this.idPrefix="dnlembed-"}connectedCallback(){this.setupComponent(),this.updateComponent(),this.polyfill(),window.addEventListener("message",(t=>this.resize(t)))}attributeChangedCallback(t,e,n){e&&(this.updateComponent(),this.polyfill())}disconnectedCallback(){this.shadowRoot?this.shadowRoot.innerHTML="":this.innerHTML=""}setupComponent(){console.log("setupComponent must be implemented by subclass")}updateComponent(){console.log("updateComponent must be implemented by subclass")}resize(t){console.log("Resize method must be implemented by subclass")}polyfill(){if("undefined"==typeof ShadyCSS)return;if(!this.shadowRoot)return;const t=document.createElement("template");t.innerHTML=this.shadowRoot.innerHTML,function(t,e){void 0!==window.ShadyCSS&&!1===window.ShadyCSS.nativeShadow&&window.ShadyCSS.prepareTemplate(t,e)}(t,this.localName),this.shadowRoot.innerHTML=t.innerHTML}}const e=(t,e)=>{customElements.get(t)||customElements.define(t,e)};e("dnl-dwchart",class extends t{static get observedAttributes(){return["src"]}constructor(){super(),this.idPrefix="dwchart-"}setupComponent(){const t=document.createElement("style");t.textContent="\n :host{\n display: flex;\n margin: 0 auto;\n max-width: 800px;\n }\n \n iframe{\n border: none;\n width: 100%;\n }",this.shadowRoot.appendChild(t),this.iframe=document.createElement("iframe"),this.iframe.frameborder="0",this.shadowRoot.appendChild(this.iframe)}updateComponent(){const{iframe:t,idPrefix:e}=this,n=this.getAttribute("src");if(!n)return void console.error("No dw-source specified");t.src=n;let i=new URL(n).pathname.split("/")[1];t.id=e+i}resize(t){if(void 0!==t.data["datawrapper-height"])for(var e in t.data["datawrapper-height"])e==this.iframe.id.slice(this.idPrefix.length)&&(this.iframe.style.height=t.data["datawrapper-height"][e]+"px")}}),e("dnl-image",class extends t{static get observedAttributes(){return["src","alt","title","caption","creditline"]}constructor(){super()}setupComponent(){this.classList.add("empty"),this.figure=document.createElement("figure"),this.img=document.createElement("img"),this.figcaption=document.createElement("figcaption"),this.caption=document.createElement("p"),this.creditline=document.createElement("p");const{figure:t,figcaption:e,img:n,caption:i,creditline:s,shadowRoot:r}=this;t.setAttribute("part","figure"),e.setAttribute("part","figcaption"),n.setAttribute("part","img"),i.setAttribute("part","caption"),s.setAttribute("part","creditline");let o=document.createElement("style");o.textContent="\n :host{\n display: block;\n margin: 0 auto;\n max-width: 800px;\n }\n \n :host(.empty){\n display: none;\n }\n\n figure{\n margin: 0;\n position: relative;\n }\n\n img{\n display: block;\n height: auto;\n width: 100%;\n }\n\n figcaption{\n background: rgba(255, 255, 255, 0.8);\n bottom: 0;\n box-sizing: border-box;\n display: block;\n left: 0;\n padding: 15px;\n position: absolute;\n width: 100%;\n }\n\n :host(.is-feature) figcaption{\n padding: 0;\n position: relative;\n }\n\n figcaption p{\n margin: 0;\n }\n\n figcaption p.title{\n font-weight: 600;\n margin-bottom: 3px;\n }\n\n figcaption p.title+p.caption{\n font-size: .7em\n }\n\n p.creditline{\n font-size: .7em;\n font-style: italic;\n text-align: right;\n }\n ",r.appendChild(o),t.appendChild(n),i.classList.add("caption"),e.appendChild(i),s.classList.add("creditline"),e.appendChild(s),t.appendChild(e),r.appendChild(t)}updateComponent(){const{img:t,caption:e,creditline:n,figcaption:i}=this;if(!this.getAttribute("src"))return void this.classList.add("empty");t.setAttribute("src",this.getAttribute("src")),t.setAttribute("alt",this.getAttribute("alt"));const s=this.figcaption.querySelector("p.title"),r=this.getAttribute("title");if(null!==s)if(r){const t=document.createElement("p");t.classList.add("title"),t.innerHTML=this.getAttribute("title"),i.prepend(t)}else s.setAttribute("part","title"),s.innerHTML=r;else if(r){const t=document.createElement("p");t.classList.add("title"),t.innerHTML=this.getAttribute("title"),i.prepend(t)}e.innerHTML=this.getAttribute("caption"),n.innerHTML=`Foto: ${this.getAttribute("creditline")}`,this.classList.remove("empty")}resize(){}}),e("dnl-twitterembed",class extends t{static get observedAttributes(){return["src"]}constructor(){super(!1)}setupComponent(){const t=document.createElement("style");t.textContent="\n :host{\n align-items: center;\n display: flex;\n justify-content: center;\n margin: 0 auto;\n max-width: 800px;\n width: 100%;\n }\n div.container{\n align-items: center;\n display: flex;\n justify-content: center;\n width: 100%;\n }\n\n div.container iframe {\n min-height: 10px;\n min-width: 10px;\n }\n ",this.appendChild(t)}updateComponent(){console.log("Update tweet");const t=this.getAttribute("src");if(!t)return void console.error("no twitter-src");const e=new URL(t).pathname.split("/");let n;if("status"===e[2])if(n=e[3],void 0===window.twttr){let t=function(t){let e=document.querySelectorAll(`script[src="${t}"]`);if(0==e.length){let e=document.createElement("script");return e.setAttribute("src",t),e.setAttribute("async","async"),document.body.appendChild(e),e}return e[0]}("https://platform.twitter.com/widgets.js");const e=t.onload;t.onload=()=>{e&&e(),this._createTweet(n)}}else this._createTweet(n);else console.error("Specified Tweet-URL "+t+" does not match required format")}_createTweet(t){this.content&&this.removeChild(this.content),this.content=document.createElement("div"),this.content.classList.add("container"),window.twttr.widgets.createTweet(t,this.content,{conversation:"none",dnt:!0}).then(this._addErrorMessage.bind(this)),this.appendChild(this.content)}_addErrorMessage(t){void 0===t&&(this.content.innerHTML=`

Der hier zuvor eingegebette Tweet ist nicht (mehr) verfügbar.

`)}resize(t){}}),e("dnl-youtubeembed",class extends t{static get observedAttributes(){return["src"]}constructor(){super()}setupComponent(){const{shadowRoot:t}=this;let e=document.createElement("style");e.textContent="\n :host{\n align-items: center;\n display: flex;\n justify-content: center;\n margin: 0 auto;\n max-width: 800px;\n width: 100%\n } \n .wrapper{\n padding-bottom: 56.25%;\n position: relative;\n width: 100%;\n } \n iframe{\n height: 100%;\n left: 0;\n position: absolute;\n top: 0;\n width: 100%;\n }",t.appendChild(e);const n=document.createElement("div");n.classList.add("wrapper"),this.iframe=document.createElement("iframe"),this.iframe.setAttribute("frameborder","0"),this.iframe.setAttribute("allow","accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture"),n.appendChild(this.iframe),t.appendChild(n),this.polyfill()}updateComponent(){const t=this.getAttribute("src");t?this.iframe.src=t:console.error("No youtube-source found")}resize(t){}}),e("dnl-wgchart",class extends t{static get observedAttributes(){return["src"]}constructor(){super(),this.idPrefix="wg-"}setupComponent(){this.iframe=document.createElement("iframe");const{shadowRoot:t,iframe:e}=this;e.setAttribute("frameborder","0"),t.appendChild(e);const n=document.createElement("style");n.textContent="\n :host{\n display: block;\n margin: 0 auto;\n max-width: 800px;\n }\n iframe{\n border: none;\n height: 520px;\n width: 100%;\n }\n ",t.appendChild(n),e.style="height: 1px;min-height:1px;",t.appendChild(e),this.polyfill()}updateComponent(){const{iframe:t,idPrefix:e}=this,n=this.getAttribute("src");n||console.error("No webchart-source specified");let i=new URL(n);this.origin=i.origin,t.id=e+function(t){let e,n,i=0;if(0===t.length)return i;for(e=0;ei.searchParams.set(t,e))):Object.entries({id:t.id,childId:t.id,clientHeight:1}).forEach((([t,e])=>i.searchParams.set(t,e))),t.src=i.toString()}resize(t){if(t.origin==this.origin)if(t.data.embed==this.iframe.id)this.iframe.style.height=`${t.data.height}px`;else if("string"==typeof t.data&&"pym"==t.data.slice(0,3)){let e=t.data.split("x");e[2]==this.iframe.id&&(this.iframe.style.height=e.slice(-1)+"px")}}})})(); //# sourceMappingURL=dnl_embeds.js.map