import{i as e}from"./quantity-C85AP0-L.js";var t=`haeltbis-shopping-email`;function n(){return localStorage.getItem(t)??``}function r(e){localStorage.setItem(t,e.trim())}function i(e){return e.filter(e=>!e.checked)}function a(t){let n=i(t);if(!n.length)return`Einkaufsliste ist leer.`;let r=n.map((t,n)=>{let r=t.quantity!=null&&t.unit?e(t.quantity,t.unit,t.customUnitLabel):``;return`${n+1}. ${t.name}${r?` – ${r}`:``}`});return[`Ha(e)ltBis Einkaufsliste (${new Date().toLocaleDateString(`de-DE`,{day:`2-digit`,month:`2-digit`,year:`numeric`})})`,``,...r,``,`${n.length} Artikel`].join(`
`)}function o(e){return[`Name;Menge;Einheit;Quelle`,...i(e).map(e=>{let t=e.quantity==null?``:String(e.quantity),n=e.unit??``;return[e.name,t,n,e.source].map(s).join(`;`)})].join(`
`)}function s(e){return/[;"\n]/.test(e)?`"${e.replace(/"/g,`""`)}"`:e}function c(e,t,n){let r=new Blob([t],{type:`${n};charset=utf-8`}),i=URL.createObjectURL(r),a=document.createElement(`a`);a.href=i,a.download=e,a.click(),URL.revokeObjectURL(i)}function l(e,t){let r=a(e),i=`Ha(e)ltBis%20Einkaufsliste`,o=encodeURIComponent(r),s=(t??n()).trim(),c=s?`mailto:${encodeURIComponent(s)}?subject=${i}&body=${o}`:`mailto:?subject=${i}&body=${o}`;window.location.href=c}async function u(e){let t=a(e);if(navigator.share)try{return await navigator.share({title:`Ha(e)ltBis Einkaufsliste`,text:t}),`shared`}catch(e){if(e instanceof DOMException&&e.name===`AbortError`)return`unsupported`}return navigator.clipboard?.writeText?(await navigator.clipboard.writeText(t),`copied`):`unsupported`}async function d(e){try{return await navigator.clipboard.writeText(a(e)),!0}catch{return!1}}function f(e,t){e&&requestAnimationFrame(()=>{requestAnimationFrame(()=>{e.scrollIntoView({behavior:`smooth`,block:t?.block??`nearest`,inline:`nearest`})})})}export{a,l as c,o as i,r as l,d as n,n as o,c as r,i as s,f as t,u};