{"version":3,"file":"share.7917909a.js","sources":["app/assets/vite/utils/share.ts"],"sourcesContent":["export interface ShareHost {\n url: string;\n name: string;\n copied: boolean;\n render: () => HTMLElement;\n}\n\nexport type ShareType =\n | \"facebook\"\n | \"twitter\"\n | \"linkedin\"\n | \"telegram\"\n | \"whatsapp\";\n\nfunction openUrl(url: string, width = 640, height = 480) {\n const left = screen.width / 2 - width / 2;\n const top = screen.height * 0.3 - height / 2;\n const opt = `width=${width},height=${height},left=${left},top=${top},menubar=no,status=no,location=no`;\n\n window.open(url, \"popup\", opt);\n}\n\nexport const supportsNative =\n !!window.navigator.share &&\n !!navigator.maxTouchPoints &&\n navigator.maxTouchPoints > 2;\n\nexport function share(host: ShareHost) {\n const { name, url } = host;\n\n window.navigator.share({ url });\n}\n\nexport function shareSocial(shareType: ShareType) {\n return (host: ShareHost) => {\n const { name, url } = host;\n\n switch (shareType) {\n case \"facebook\":\n openUrl(\n `http://www.facebook.com/sharer/sharer.php?u=${host.url}`,\n 555,\n 400\n );\n break;\n case \"twitter\":\n openUrl(\n `https://twitter.com/intent/tweet?url=${url}&text=${name}`,\n 650,\n 300\n );\n break;\n case \"linkedin\":\n openUrl(\n `https://www.linkedin.com/shareArticle?mini=true&url=${url}&title=${name}&summary=`\n );\n break;\n case \"telegram\":\n openUrl(`https://telegram.me/share/url?text=${name}&url=${url}`);\n break;\n case \"whatsapp\":\n window.open(`whatsapp://send?text=${name}%0A${url}`, \"_top\");\n break;\n default:\n throw TypeError(\"Invalid share type\");\n }\n };\n}\n\nexport function copy(host: ShareHost, event: Event) {\n const input = host.render().querySelector(\"input\") as HTMLInputElement;\n\n event.preventDefault();\n input.focus();\n input.select();\n document.execCommand(\"copy\");\n\n input.selectionStart = 0;\n input.selectionEnd = 0;\n\n host.copied = true;\n\n setTimeout(() => {\n host.copied = false;\n }, 2000);\n}\n"],"names":["openUrl","url","width","height","opt","screen","window","open","supportsNative","navigator","share","maxTouchPoints","host","name","shareSocial","shareType","TypeError","copy","event","input","render","querySelector","preventDefault","focus","select","document","execCommand","selectionStart","selectionEnd","copied","setTimeout"],"mappings":"AAcA,SAASA,EAAQC,EAAaC,EAAQ,IAAKC,EAAS,KAClD,MAEMC,EAAM,SAASF,YAAgBC,UAFxBE,OAAOH,MAAQ,EAAIA,EAAQ,SACZ,GAAhBG,OAAOF,OAAeA,EAAS,qCAGpCG,OAAAC,KAAKN,EAAK,QAASG,GAGf,MAAAI,IACTF,OAAOG,UAAUC,SACjBD,UAAUE,gBACZF,UAAUE,eAAiB,EAEtB,SAASD,EAAME,GACd,MAAAC,KAAEA,EAAMZ,IAAAA,GAAQW,EAEtBN,OAAOG,UAAUC,MAAM,CAAET,IAAAA,IAGpB,SAASa,EAAYC,GAC1B,OAAQH,IACA,MAAAC,KAAEA,EAAMZ,IAAAA,GAAQW,EAEd,OAAAG,GACD,IAAA,WACHf,EACE,+CAA+CY,EAAKX,MACpD,IACA,KAEF,MACG,IAAA,UACHD,EACE,wCAAwCC,UAAYY,IACpD,IACA,KAEF,MACG,IAAA,WACHb,EACE,uDAAuDC,WAAaY,cAEtE,MACG,IAAA,WACKb,EAAA,sCAAsCa,SAAYZ,KAC1D,MACG,IAAA,WACHK,OAAOC,KAAK,wBAAwBM,OAAUZ,IAAO,QACrD,MAAA,QAEA,MAAMe,UAAU,wBAKR,SAAAC,EAAKL,EAAiBM,GACpC,MAAMC,EAAQP,EAAKQ,SAASC,cAAc,SAE1CH,EAAMI,iBACNH,EAAMI,QACNJ,EAAMK,SACNC,SAASC,YAAY,QAErBP,EAAMQ,eAAiB,EACvBR,EAAMS,aAAe,EAErBhB,EAAKiB,QAAS,EAEdC,YAAW,KACTlB,EAAKiB,QAAS,IACb"}