useblocks 1.0.12 → 1.0.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "useblocks",
3
- "version": "1.0.12",
3
+ "version": "1.0.13",
4
4
  "private": false,
5
5
  "main": "useblocks.js",
6
6
  "module": "useblocks-esm.js",
package/plugin.html CHANGED
@@ -1,9 +1,22 @@
1
- <!doctype html><html lang="en"><head><script id="plugin-script" src="emailmaker.js?d0d4a29d7e7662e4f171"></script></head><body><button id="change_theme" style="width: 150px; height: 30px">Click Me</button><div style="background: white; width: 100%; height: 50px; display: flex; justify-content: center; align-items: center"></div><div id="test" style="padding: 0px; background: #fff; height: 100vh;"></div><script async defer="defer">// import { init } from "./emailmaker-esm.js?d0d4a29d7e7662e4f171";
1
+ <!doctype html><html lang="en"><head><script id="plugin-script" src="emailmaker.js?ff17ca6787f92aa4360f"></script></head><body><button id="change_theme" style="width: 150px; height: 30px">Click Me</button><div style="background: white; width: 100%; height: 50px; display: flex; justify-content: center; align-items: center"></div><div id="test" style="padding: 0px; background: #fff; height: 100vh;"></div><script async defer="defer">// import { init } from "./emailmaker-esm.js?ff17ca6787f92aa4360f";
2
2
  const auth_jwt = {
3
3
  username: "****",
4
4
  password: "****"
5
5
  };
6
6
 
7
+ const systemfields =
8
+ [
9
+ {
10
+ "label": "Дополнительное поле «Имя»",
11
+ "value": "Name"
12
+ },
13
+ {
14
+ "label": "Имя получателя",
15
+ "value": "ToName"
16
+ },
17
+ ];
18
+
19
+
7
20
  const auth_client = {
8
21
  client_id: "****",
9
22
  client_secret: "****"
@@ -41,7 +54,7 @@
41
54
  const BLOCKS_KEY = "blocks";
42
55
  const COMMENTS_KEY = "blocks";
43
56
  const RESOURSE = 'aaa.bbb.xyz.com';
44
-
57
+ let _instance = undefined;
45
58
  const options = {
46
59
  getAuthToken,
47
60
  previewIconEnabled: true,
@@ -50,8 +63,12 @@
50
63
  handleEmailChanged(event) {
51
64
  console.log(event);
52
65
  },
53
- handleSaveEmail(event) {
54
- console.log(event);
66
+ handleLoad(instance) {
67
+ _instance = instance;
68
+ },
69
+ async handleSaveEmail({ value }) {
70
+ const email = await _instance.compileEmail(value);
71
+ console.log(email);
55
72
  },
56
73
  handleCloneEmail(event) {
57
74
  console.log(event);
@@ -114,11 +131,53 @@
114
131
  emailDropdownMenuLock: true,
115
132
  emailDropdownMenuRemove: true,
116
133
  // Стилизация через token
134
+ mergeTags: {
135
+ "syntax": [
136
+ "{{%value%}}"
137
+ ],
138
+ "items": [
139
+ {
140
+ "label": "Системные",
141
+ "value": "System",
142
+ "children": systemfields
143
+ },
144
+ {
145
+ "label": "Пользовательские",
146
+ "value": "User",
147
+ "children": systemfields
148
+ }
149
+ ]
150
+ }
117
151
 
118
152
  }
153
+
119
154
  };
120
155
  async function init() {
121
156
  const instance = await emailmaker.init(options);
157
+ instance.handleSaveEmail(async ({ value, patch, prev }) => {
158
+ const _email = await instance.compileEmail(value);
159
+ console.log(_email);
160
+ });
161
+ instance.setConfig({
162
+ ...options.config,
163
+ mergeTags: {
164
+ "syntax": [
165
+ "{{%value%}}"
166
+ ],
167
+ "items": [
168
+ {
169
+ "label": "Системные",
170
+ "value": "System",
171
+ "children": systemfields
172
+ },
173
+ {
174
+ "label": "Пользовательские",
175
+ "value": "User",
176
+ "children": systemfields
177
+ }
178
+ ]
179
+ }
180
+ });
122
181
  // await instance.show({
123
182
  // email: {
124
183
  // "id": "3769995",
@@ -1,4 +1,4 @@
1
- <!doctype html><html lang="en"><head><script id="plugin-script" src="emailmaker.js?d0d4a29d7e7662e4f171"></script></head><body><div id="test" style="padding: 0px; background: #fff; height: 100vh;"></div><script async defer="defer">const getAuthToken = async () => {
1
+ <!doctype html><html lang="en"><head><script id="plugin-script" src="emailmaker.js?ff17ca6787f92aa4360f"></script></head><body><div id="test" style="padding: 0px; background: #fff; height: 100vh;"></div><script async defer="defer">const getAuthToken = async () => {
2
2
 
3
3
  var requestOptions = {
4
4
  method: 'POST',
@@ -1,4 +1,4 @@
1
- <!doctype html><html lang="en"><head><script id="plugin-script" src="emailmaker.js?d0d4a29d7e7662e4f171"></script></head><body><div id="test" style="padding: 0px; background: #fff; height: 100vh;"></div><script async defer="defer">// import { init } from "./emailmaker-esm.js?d0d4a29d7e7662e4f171";
1
+ <!doctype html><html lang="en"><head><script id="plugin-script" src="emailmaker.js?ff17ca6787f92aa4360f"></script></head><body><div id="test" style="padding: 0px; background: #fff; height: 100vh;"></div><script async defer="defer">// import { init } from "./emailmaker-esm.js?ff17ca6787f92aa4360f";
2
2
  const auth_jwt = {
3
3
  username: "****",
4
4
  password: "****"
package/plugin_s.html CHANGED
@@ -1,4 +1,4 @@
1
- <!doctype html><html lang="en"><head><script id="plugin-script" src="emailmaker.js?d0d4a29d7e7662e4f171"></script></head><body><div id="test" style="padding: 0px; background: #fff; height: 100vh;"></div><script async defer="defer">const getAuthToken = async () => {
1
+ <!doctype html><html lang="en"><head><script id="plugin-script" src="emailmaker.js?ff17ca6787f92aa4360f"></script></head><body><div id="test" style="padding: 0px; background: #fff; height: 100vh;"></div><script async defer="defer">const getAuthToken = async () => {
2
2
 
3
3
  var requestOptions = {
4
4
  method: 'POST',
@@ -0,0 +1 @@
1
+ "use strict";(globalThis.webpackChunkemail_maker=globalThis.webpackChunkemail_maker||[]).push([[1472,5974],{90854:(e,t,r)=>{r.d(t,{A6:()=>l,BF:()=>u,Lv:()=>f,ST:()=>m,TM:()=>n,b6:()=>y,d1:()=>g,ir:()=>d,rq:()=>h,uE:()=>i,vq:()=>c,wz:()=>p});const o=new Set(["area","br","col","embed","hr","img","input","link","meta","param"]);function n(e){return"<!DOCTYPE "+e.name+(e.publicId?' PUBLIC "'+e.publicId+'"':"")+(!e.publicId&&e.systemId?" SYSTEM":"")+(e.systemId?' "'+e.systemId+'"':"")+">"}const s=Object.create(null);function a(e,t){const r=s[e]||(s[e]=Object.create(null));let o=r[t];if("boolean"!==typeof o){const n=document.createElement(e)[t.toLowerCase().replace(/[^a-zA-Z0-9]+(.)/g,((e,t)=>t.toUpperCase()))];o=r[t]="undefined"!==typeof n&&"boolean"!==typeof n}return o}function c(e){return e.nodeType===Node.ELEMENT_NODE}function i(e){return c(e)&&!e.ownerSVGElement}function l(e){return"IMG"===e.tagName}function u(e){return"FORM"===e.tagName}function m(e){return"STYLE"===e.tagName}function p(e){return e.nodeType===Node.DOCUMENT_NODE}function d(e){return e.nodeType===Node.TEXT_NODE}function f(e){return"TABLE"===e.tagName}async function h(e,t=5e3){return"undefined"===typeof e.complete||e.complete?getComputedStyle(e):new Promise(((r,o)=>{setTimeout(r,t),e.onload=()=>r(getComputedStyle(e)),e.onerror=e=>console.log(e)}))}function y(e){if(c(e))return function(e){const t=e.tagName.toLowerCase(),r=function(e){const t=e.tagName.toLowerCase();let r="";for(const o of e.attributes){const e=o.name,n=o.value;r+=""!==n||"em"===e||a(t,e)?` ${e}="${n.replaceAll('"',"'")}"`:` ${e}`}return r}(e);return o.has(t)?`<${t}${r}>`:m(e)?`<${t}${r}>${e.innerHTML}</${t}>`:`<${t}${r}>${function(e){let t="";for(const r of e.childNodes)t+=y(r);return t}(e)}</${t}>`}(e);if(p(e))return[...e.childNodes].map((e=>y(e))).join("");if(function(e){return e.nodeType===Node.DOCUMENT_TYPE_NODE}(e))return n(e);const t=document.createElement("div");return t.appendChild(e.cloneNode(!0)),t.innerHTML}function g(e,t){for(const s of e.childNodes)s.remove();let r=t.find((e=>function(e){return"HTML"===e.tagName}(e))),o=t.find((e=>function(e){return"BODY"===e.tagName}(e))),n=e;r||(r=e.createElement("html"),e.appendChild(r),n=r,o||(o=e.createElement("body"),r.appendChild(o),n=o));for(const s of t)n===e&&d(s)?n.appendChild(e.createComment(`%%%{{{${s.data}}}}%%%`)):n.appendChild(s)}},84007:(e,t,r)=>{r.d(t,{$$:()=>m,Os:()=>l});var o=r(16799),n=r(8357),s=r(61704);const a=["area","base","br","col","embed","hr","img","input","link","meta","source","track","wbr"],c=new o.H(a),i=new n.X(c);function l(e,t,r){try{e.setAttribute(t,r)}catch{let o=e.tagName.toLowerCase();"html"===o&&(o="div");const n=`<${o} ${t}="${r}"/>`;let s=function(e){let t;switch(e){case"tr":t=document.createElement("table");break;case"td":t=document.createElement("tr");break;case"head":case"body":t=document.createElement("html");break;case"DocumentType":case"html":{const e=document.implementation.createHTMLDocument();for(const t of[...e.childNodes])t.remove();return e}default:t=document.createElement("div")}return t}(o);if(s instanceof Document)return;s.innerHTML=n;const a=1===s.children.length?s.firstElementChild:s.getElementsByTagName(o)[0];if(!a)throw new Error("targetElement is not defined");const c=a.getAttributeNode(t);c&&e.setAttributeNode(c.cloneNode())}}function u(e,t=!0){let r=e.content;switch(e.type){case s.Z.ROOT:{const r=document.implementation.createHTMLDocument();for(const e of[...r.childNodes])r.removeChild(e);if(t)for(const t of e.children)r.appendChild(u(t));return r}case s.Z.DOCTYPE:return(new DOMParser).parseFromString(`<!DOCTYPE${e.content}>`,"text/html").doctype;case s.Z.COMMENT:return document.createComment(r||"");case s.Z.ELEMENT:if(e.tag){const r=document.createElement(e.tag);if(e.attributes)for(const t of e.attributeNames){const n=e.attributes[t];try{l(r,t,"string"===typeof n?n:"")}catch(o){}}if(t)for(const t of e.children)r.appendChild(u(t));return r}return document.createTextNode("<");case s.Z.HTML:return function(e){if(e){const t=document.createElement("div");return t.insertAdjacentHTML("afterbegin",e),t.firstChild||document.createTextNode("")}return document.createTextNode("")}(r||"");default:throw new Error("unsupported node")}}function m(e){var t;return(t=e,i.parse(t)).roots.map((e=>u(e)))}},85974:(e,t,r)=>{r.d(t,{Km:()=>P,Sc:()=>S,Nh:()=>T});var o=r(90854),n=r(84007),s=r(74851),a=r(69279);const c='<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">',i="<!doctype html>";var l=r(97717);async function u(e,t={}){const r=document.createElement("amp-img"),s=await(0,o.rq)(e),a=null!==s&&void 0!==s&&s.height?`${parseInt(s.height)}px`:"",c=null!==s&&void 0!==s&&s.width?`${parseInt(s.width)}px`:"",i=e.src||e.srcset.split(",")[0];"100%"===e.style.width&&e.style.removeProperty("width"),"100%"===e.style.maxWidth&&e.style.removeProperty("max-width"),t={...(0,l.gu)(e),alt:e.alt,width:c,height:a,src:i,layout:"responsive",...t};for(const o of Object.keys(t))(0,n.Os)(r,o,t[o]);return r}function m(e){const t=document.createElement("img"),{layout:r,height:o,...s}=(0,l.gu)(e),a="responsive"===r;for(const c of Object.keys(s))(0,n.Os)(t,c,s[c]);return a&&(t.style.maxWidth=s.width||"0px",t.style.width="100%"),t}var p=r(59896),d=r(91981),f=r(91391);var h=r(80424);const y=new Map;const g=new Map;const v="$GLOBAL_ATTRS",w=new Map;async function b(){if(!w.size){var e;const t=null===(e=(await(0,h.F)()).attrLists.find((e=>e.name===v)))||void 0===e?void 0:e.attrs;if(t)for(const e of t)w.set(e.name,e)}return w}function T(e){var t;return(0,o.vq)(e)&&(e.tagName.startsWith("AMP")||"FORM"===e.tagName||"TEMPLATE"===e.tagName&&"amp-mustache"===(null===(t=e.getAttribute("type"))||void 0===t?void 0:t.toLowerCase()))}function A(e,t,r){var n,s,a;if(t)if((0,o.vq)(e))switch(e.tagName.toLowerCase()){case"body":case r("script"):case"style":case"meta":case"title":return;case"head":case"html":i();break;default:c()||i()}else(0,o.wz)(e)?i():(0,o.ir)(e)&&(null!==(n=e.textContent)&&void 0!==n&&n.trim()||null!==(s=e.nextSibling)&&void 0!==s&&null!==(a=s.textContent)&&void 0!==a&&a.trim()&&(0,o.ir)(e.nextSibling))&&c();function c(){const r=t.compareDocumentPosition(e);if(!(8&r)){if(2&r)return t.insertBefore(e,t.firstChild),!0;if(4&r)return t.appendChild(e),!0}return!1}function i(){const o=[...e.childNodes];for(let e=o.length-1;e>=0;e--)A(o[e],t,r)}}async function x(e,t){const r=e=>t.replaceSelectors(e.toLowerCase());if(t.replaceImages&&await async function(e){const t=e.querySelectorAll("img");for(const o of t)o.replaceWith(await u(o));const r=e.querySelectorAll("picture");for(const o of r){const e=o.querySelector("img");if(e){const t=await u(e);o.replaceWith(t)}else o.remove()}}(e),t.injectExtensions){const T=t.replaceSelectors(f.Vq);if(!e.querySelector(T)){const x=t.createElementFn("script");x.setAttribute("src",f.zq),x.setAttribute("async","");(0,l.xy)(e).appendChild(x)}}t.injectRequiredTags&&((0,d.y)(e,t.createElementFn,r),function(e){const t=e.doctype;if(t){if((0,o.TM)(t)===i)return;const r=(new DOMParser).parseFromString(i,"text/html").doctype;e.replaceChild(r,t)}else{const t=(new DOMParser).parseFromString(i,"text/html").doctype;e.insertBefore(t,e.firstChild)}}(e),(0,s.R)(e),(0,p.C)(e)),t.replaceStylesAndLinks&&(0,a.Q)(e);const c=await(0,h.F)(),m=await async function(){if(!y.size){const e=await(0,h.F)(),t=e.tags;for(let r=0;r<t.length;r++){const o=t[r],{selector:n,attrs:s,attrLists:a}=o,c=(null===a||void 0===a?void 0:a.flatMap((t=>e.attrLists.filter((({name:e})=>e===t)).flatMap((e=>e.attrs)))))||[];y.set(n,{...o,priority:r,attrs:new Map([...s,...c].map((e=>[e.name,e])))})}}return y}(),v=new Set(t.removeUnsupportedTags?e.querySelectorAll("*"):[]),w=new Map;for(let[E,S]of m){E=r(E);let P=e.querySelectorAll(E);t.injectRequiredTags&&S.required&&!P.length&&(P=[...P,t.createElementFn(S.name)]);for(const C of P){const N=w.get(C);N&&N.priority>S.priority||w.set(C,S)}}for(let[L,$]of w){const O=$.requiredParent?"$ROOT"===$.requiredParent?e:e.querySelector($.requiredParent):null;!O||L.parentNode&&!t.moveInvalidTagPosition?L.parentNode||e.body.appendChild(L):O!==L.parentNode&&("HEAD"===$.name?O.insertBefore(L,O.firstChild):O.appendChild(L)),t.removeUnsupportedTags&&v.delete(L);const R=await b();if(t.removeUnsupportedAttributes||t.injectRequiredAttributes){const M=$.attrs,q=t.injectRequiredAttributes?new Set([...M].map((([e,t])=>t)).filter((e=>e.required&&e.value))):void 0,k=L.getAttributeNames();for(const D of k){const I=M.get(D)||R.get(D);if(I){if("id"===D||"class"===D||"style"===D){null===q||void 0===q||q.delete(I);continue}if(t.removeUnsupportedAttributes){const H=L.getAttribute(D);if(I.value&&I.value.indexOf(H)<0&&L.removeAttribute(D),I.valueRegex){new RegExp(I.valueRegex).test(H)||L.removeAttribute(D)}if(I.disallowedValueRegex){new RegExp(I.disallowedValueRegex).test(H)&&L.removeAttribute(D)}const F=I.valueUrl;if(F)if(""===H)F.allowEmpty||L.removeAttribute(D);else if(H.indexOf("\x3c!--")>0&&H.indexOf("--\x3e")>0);else if(!F.allowRelative)if(H.startsWith("#")||H.startsWith("/"))L.removeAttribute(D);else{const U=F.protocol.length?F.protocol:["https"];let j=H.substring(0,H.indexOf(":"));if(j)if(U.indexOf(j)<0){let W=U[0]+H.substring(H.indexOf(":"));URL.canParse(W)?(0,n.Os)(L,D,W):L.removeAttribute(D)}else URL.canParse(H)||L.removeAttribute(D);else{let z=U[0]+H;URL.canParse(z)?(0,n.Os)(L,D,z):L.removeAttribute(D)}}}null===q||void 0===q||q.delete(I)}else{if("id"===D||"class"===D||"style"===D)continue;t.removeUnsupportedAttributes&&L.removeAttribute(D)}}if(q)for(const B of q)(0,n.Os)(L,B.name,B.value[0])}}t.moveInvalidTagPosition&&A(e,e.body,r);for(const Q of v)Q.remove();if(t.removeUnsupportedStyles){const _=e.querySelectorAll("*"),Y=await async function(){if(!g.size){const e=await(0,h.F)();for(const t of e.declarations)g.set(t.name,t)}return g}();function Z(e){const t=e.cssText.replaceAll(/\".*\"/g,"").replaceAll(/\'.*\'/g,"").replaceAll(/\/\*.*\*\/|(-moz-|-ms-|-o-|-webkit-)+\w+(?=:)/g,"").match(/[a-z-]+(?=:[^before|after|hover])/gi)||[];for(const r of t){if(!r)continue;const t=e.getPropertyValue(r);"important"===e.getPropertyPriority(r)&&e.setProperty(r,t);const o=Y.get(r);if(o){if(o.value)o.value.indexOf(t)<0&&e.removeProperty(r);else if(o.valueRegex){new RegExp(o.valueRegex).test(t)||e.removeProperty(r)}}else e.removeProperty(r)}}function V(e){return"CSSStyleRule"===e.constructor.name}function G(e){return"CSSMediaRule"===e.constructor.name}function X(e){const t=e.cssRules;for(let r=t.length-1;r>=0;r--){const o=t[r];V(o)?o.selectorText.indexOf("[")>=0||o.selectorText.indexOf(":")>=0?e.deleteRule(r):(Z(o.style),o.style.cssText||e.deleteRule(r)):G(o)?(X(o),o.cssRules.length||e.deleteRule(r)):e.deleteRule(r)}}for(const J of _)if((0,o.uE)(J)){const ee=J.getAttribute("style");ee&&(Z(J.style),J.style.length?J.style.cssText!==ee&&J.setAttribute("style",J.style.cssText):J.removeAttribute("style"))}const K=e.querySelector("style[amp-custom]");if(K){const te=K.sheet;te&&(X(te),K.innerHTML=[...te.cssRules].map((e=>e.cssText)).join("\n"))}}await async function(e,t,r){for(const{name:s,versions:a}of t){let t=!1;switch(s){case"amp-mustache":t=!!e.querySelector("template[type='amp-mustache']"),t||(t=!!e.querySelector(r.replaceSelectors(r.replaceSelectors("script[template='amp-mustache']"))));break;case"amp-form":t=!!e.querySelector(s),!t&&r.formsAsAmpForms&&"amp-form"===s&&(t=!!e.querySelector("form"));break;case"amp-bind":t=!!e.querySelector(s),t||(t=!!e.querySelector("[on]"));break;default:t=!!e.querySelector(s)}if(t){const t=r.replaceSelectors("amp-mustache"===s?`script[async][custom-template='${s}']`:`script[async][custom-element='${s}']`);if(!e.querySelector(t)){const t=(0,l.xy)(e),c=r.createElementFn("script"),i=(o=s,n=a.findLast((e=>"latest"!==e))||"v0",`${f.gP}/${o.toLowerCase()}-${n}.js`);c.setAttribute("async",""),c.setAttribute("amp-mustache"===s?"custom-template":"custom-element",s),c.setAttribute("src",i),t.appendChild(c),t.appendChild(e.createTextNode("\n"))}}}var o,n}(e,c.extensions,t)}function E(e,t){return Object.keys(t).reduce(((e,r)=>e.replaceAll(r,t[r])),e)}function S(e,t={}){const{correct:r=!0,injectExtensions:o=!0,mappedTags:n={}}=t;return x(e,{replaceImages:r,replaceStylesAndLinks:r,injectRequiredTags:r,injectExtensions:o,formsAsAmpForms:o,injectRequiredAttributes:r,moveInvalidTagPosition:r,removeUnsupportedTags:r,removeUnsupportedAttributes:r,removeUnsupportedStyles:r,createElementFn:t=>e.createElement(n[t.toLowerCase()]||t),replaceSelectors:e=>E(e.toLowerCase(),n)})}function P(e,t={}){const{correct:r=!0,removeExtensions:n=!0,mappedTags:u={}}=t,p=t=>e.createElement(u[t.toLowerCase()]||t),d=e=>E(e,u);if(r){!function(e){const t=e.querySelectorAll("amp-img");for(const r of t)r.replaceWith(m(r))}(e),function(e){const t=e.doctype;if(t&&(0,o.TM)(t).toLowerCase()===i){const r=(new DOMParser).parseFromString(c,"text/html").doctype;e.replaceChild(r,t)}}(e),(0,a.h)(e),(0,s.C)(e);const t=(0,l.ep)(e);t.removeAttribute("\u26a14email"),t.removeAttribute("data-css-strict")}n&&function(e,t){const r=e.querySelectorAll("*"),o=e.querySelectorAll(t.replaceSelectors("script[src]"));for(const s of o){var n;null!==(n=s.getAttribute("src"))&&void 0!==n&&n.startsWith(f.gP)&&s.remove()}for(const s of r)T(s)&&"FORM"!==s.tagName&&s.remove()}(e,{formsAsAmpForms:t.removeExtensions,createElementFn:p,replaceSelectors:d})}},7205:(e,t,r)=>{r.d(t,{A:()=>c});const o=(e,t)=>t.some((t=>t instanceof RegExp?t.test(e):t===e)),n=new Set(["https:","http:","file:"]),s=e=>{try{const{protocol:t}=new URL(e);return t.endsWith(":")&&!t.includes(".")&&!n.has(t)}catch{return!1}},a=(e,{stripHash:t})=>{var r,o;const n=/^data:(?<type>[^,]*?),(?<data>[^#]*?)(?:#(?<hash>.*))?$/.exec(e);if(!n)throw new Error(`Invalid URL: ${e}`);let{type:s,data:a,hash:c}=n.groups;const i=s.split(";");c=t?"":c;let l=!1;"base64"===i[i.length-1]&&(i.pop(),l=!0);const u=null!==(r=null===(o=i.shift())||void 0===o?void 0:o.toLowerCase())&&void 0!==r?r:"",m=[...i.map((e=>{let[t,r=""]=e.split("=").map((e=>e.trim()));return"charset"===t&&(r=r.toLowerCase(),"us-ascii"===r)?"":`${t}${r?`=${r}`:""}`})).filter(Boolean)];return l&&m.push("base64"),(m.length>0||u&&"text/plain"!==u)&&m.unshift(u),`data:${m.join(";")},${l?a.trim():a}${c?`#${c}`:""}`};function c(e,t){if("string"!==typeof(t={defaultProtocol:"http",normalizeProtocol:!0,forceHttp:!1,forceHttps:!1,stripAuthentication:!0,stripHash:!1,stripTextFragment:!0,stripWWW:!0,removeQueryParameters:[/^utm_\w+/i],removeTrailingSlash:!0,removeSingleSlash:!0,removeDirectoryIndex:!1,removeExplicitPort:!1,sortQueryParameters:!0,...t}).defaultProtocol||t.defaultProtocol.endsWith(":")||(t.defaultProtocol=`${t.defaultProtocol}:`),e=e.trim(),/^data:/i.test(e))return a(e,t);if(s(e))return e;const r=e.startsWith("//");!r&&/^\.*\//.test(e)||(e=e.replace(/^(?!(?:\w+:)?\/\/)|^\/\//,t.defaultProtocol));const n=new URL(e);if(t.forceHttp&&t.forceHttps)throw new Error("The `forceHttp` and `forceHttps` options cannot be used together");if(t.forceHttp&&"https:"===n.protocol&&(n.protocol="http:"),t.forceHttps&&"http:"===n.protocol&&(n.protocol="https:"),t.stripAuthentication&&(n.username="",n.password=""),t.stripHash?n.hash="":t.stripTextFragment&&(n.hash=n.hash.replace(/#?:~:text.*?$/i,"")),n.pathname){const e=/\b[a-z][a-z\d+\-.]{1,50}:\/\//g;let t=0,r="";for(;;){const o=e.exec(n.pathname);if(!o)break;const s=o[0],a=o.index;r+=n.pathname.slice(t,a).replace(/\/{2,}/g,"/"),r+=s,t=a+s.length}r+=n.pathname.slice(t,n.pathname.length).replace(/\/{2,}/g,"/"),n.pathname=r}if(n.pathname)try{n.pathname=decodeURI(n.pathname)}catch{}if(!0===t.removeDirectoryIndex&&(t.removeDirectoryIndex=[/^index\.[a-z]+$/]),Array.isArray(t.removeDirectoryIndex)&&t.removeDirectoryIndex.length>0){let e=n.pathname.split("/");const r=e[e.length-1];o(r,t.removeDirectoryIndex)&&(e=e.slice(0,-1),n.pathname=e.slice(1).join("/")+"/")}if(n.hostname&&(n.hostname=n.hostname.replace(/\.$/,""),t.stripWWW&&/^www\.(?!www\.)[a-z\-\d]{1,63}\.[a-z.\-\d]{2,63}$/.test(n.hostname)&&(n.hostname=n.hostname.replace(/^www\./,""))),Array.isArray(t.removeQueryParameters))for(const s of[...n.searchParams.keys()])o(s,t.removeQueryParameters)&&n.searchParams.delete(s);if(Array.isArray(t.keepQueryParameters)||!0!==t.removeQueryParameters||(n.search=""),Array.isArray(t.keepQueryParameters)&&t.keepQueryParameters.length>0)for(const s of[...n.searchParams.keys()])o(s,t.keepQueryParameters)||n.searchParams.delete(s);if(t.sortQueryParameters){n.searchParams.sort();try{n.search=decodeURIComponent(n.search)}catch{}}t.removeTrailingSlash&&(n.pathname=n.pathname.replace(/\/$/,"")),t.removeExplicitPort&&n.port&&(n.port="");const c=e;return e=n.toString(),t.removeSingleSlash||"/"!==n.pathname||c.endsWith("/")||""!==n.hash||(e=e.replace(/\/$/,"")),(t.removeTrailingSlash||"/"===n.pathname)&&""===n.hash&&t.removeSingleSlash&&(e=e.replace(/\/$/,"")),r&&!t.normalizeProtocol&&(e=e.replace(/^http:\/\//,"//")),t.stripProtocol&&(e=e.replace(/^(?:https?:)?\/\//,"")),e}}}]);