@innovastudio/contentbuilder-blocks-runtime 1.0.5 → 1.0.6

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.
@@ -10765,8 +10765,12 @@ class vn {
10765
10765
  };
10766
10766
  this.refreshLightbox(e), document.querySelectorAll(".is-lightbox,.block-click").forEach((t) => {
10767
10767
  const n = (s) => {
10768
- let r = t.getAttribute("href") || t.getAttribute("data-modal-url");
10769
- this.openLightbox(r, t, e), s.preventDefault(), s.stopImmediatePropagation();
10768
+ if (t.closest('[contenteditable="true"]'))
10769
+ return s.preventDefault(), !1;
10770
+ {
10771
+ let r = t.getAttribute("href") || t.getAttribute("data-modal-url");
10772
+ this.openLightbox(r, t, e), s.preventDefault(), s.stopImmediatePropagation();
10773
+ }
10770
10774
  };
10771
10775
  t.addEventListener("click", n), t._lightboxHandler = n;
10772
10776
  });
@@ -508,7 +508,7 @@ ${q.data}
508
508
  `}}this.tokenInput+=y,this.tokenOutput+=k}return!0}catch(l){return l.name==="AbortError"?this.settings.consoleLog&&console.log("Request aborted by user."):console.error("Error:",l),!1}}async assistant(e,i,t,n){this.controller=new AbortController,this.signal=this.controller.signal;let s=.6,r=.9,o=1;n||(n=[]);let a=this.settings.model;n.length>0&&(a=this.settings.model2);const d={assistantId:this.settings.assistantId,question:e,context:i,system:t,functs:n,temperature:s,topP:r,num:o,model:a,customData:this.settings.customData};try{let u={"Content-Type":"application/json",...this.settings.headers},h=await(await fetch(this.settings.assistantUrl,{signal:this.signal,method:"POST",headers:u,body:JSON.stringify(d)})).json();return h.error?(console.log(`Error:
509
509
  `+h.error),!1):(h.usage&&(this.tokenInput+=h.usage.prompt_tokens,this.tokenOutput+=h.usage.completion_tokens),h.answer.content[0].text.value)}catch(u){return u.name==="AbortError"?this.settings.consoleLog&&console.log("Request aborted by user."):console.error("Error:",u),!1}}async assistantStream(e,i,t,n,s){this.controller=new AbortController,this.signal=this.controller.signal;let r=.6,o=.9,a=1;n||(n=[]);const d={assistantId:this.settings.assistantId,question:e,context:i,system:t,functs:n,temperature:r,topP:o,num:a,model:this.settings.model,customData:this.settings.customData};try{let u={"Content-Type":"application/json",...this.settings.headers};const l=await fetch(this.settings.assistantStreamUrl,{signal:this.signal,method:"POST",headers:u,body:JSON.stringify(d)});if(!l.ok)return console.error("Error:",l.statusText),!1;const h=l.body.getReader(),p=new TextDecoder;let b="",w=!1;for(;!w;){const{done:_,value:g}=await h.read();if(w=_,w)break;const v=p.decode(g,{stream:!0});b+=v;const f=b.split(`
510
510
  `);b="";for(const m of f)if(m.trim()!=="")if(m.startsWith("data:")){const y=m.slice(5).trim();y==="[DONE]"&&this.settings.consoleLog&&console.log("Stream completed.");try{const k=JSON.parse(y);if(k.choices&&k.choices[0].delta&&k.choices[0].delta.content){const x=k.choices[0].delta.content;s&&s(x)}}catch{b+=m+`
511
- `}}else{const y=JSON.parse(m);this.tokenInput+=y.prompt_tokens,this.tokenOutput+=y.completion_tokens;break}}return!0}catch(u){return u.name==="AbortError"?this.settings.consoleLog&&console.log("Request aborted by user."):console.error("Error:",u),!1}}hexToRgb(e){const i=e.replace("#",""),t=parseInt(i,16),n=t>>16&255,s=t>>8&255,r=t&255;return{red:n,green:s,blue:r}}getId(e="id"){return`${e}-${Math.random().toString(36).substr(2,9)}`}appendHtml(e,i){e&&i&&e.insertAdjacentHTML("beforeend",i)}cleanup(){if(this.element){let e=this.element.querySelectorAll('input[type="text"], input[type="number"], input[type="email"], input[type="tel"], input[type="url"], textarea');e.forEach(i=>{i.removeEventListener("input",this.inputListener)}),e=this.element.querySelectorAll('input[type="date"], input[type="radio"], input[type="checkbox"]'),e.forEach(i=>{i.removeEventListener("change",this.changeListener)}),this.debounceTimeout&&(clearTimeout(this.debounceTimeout),this.debounceTimeout=null)}}destroy(){try{if(this._scrollListener){let e;this.settings.isBuilder?e=document.querySelector(this.settings.previewSelector):e=this.element;const i=e.querySelector(".submit-container"),t=this.getScrollableParent(i);t?t.removeEventListener("scroll",this._scrollListener):window.removeEventListener("scroll",this._scrollListener),window.removeEventListener("resize",this._scrollListener)}}catch{}this.element&&(this.cleanup(),this.element.innerHTML="",this.element=null);for(const e in this.listeners)this.listeners[e].clear();this.listeners={}}out(e){let i=this.settings.lang[e];return i||e}}class mn{constructor(e={}){const i={skin:"light"};this.settings={...i,...e},window.Glide=Rs,window.FormViewer=gn}init(){this.blockInit();const e={touchNavigation:!0,selector:".glightbox",loop:!0,autoplayVideos:!0,zoomable:!0,slideEffect:"slide",descPosition:"bottom",skin:this.settings.skin};this.refreshLightbox(e),document.querySelectorAll(".is-lightbox,.block-click").forEach(t=>{const n=s=>{let r=t.getAttribute("href")||t.getAttribute("data-modal-url");this.openLightbox(r,t,e),s.preventDefault(),s.stopImmediatePropagation()};t.addEventListener("click",n),t._lightboxHandler=n})}refreshLightbox(e){this.glightbox&&this.glightbox.destroy(),this.glightbox=new jt(e),window.GLightbox=jt.default}openLightbox(e,i,t){let n=[],s=0;if(i){const o=i.closest("[data-gallery]");let a=[];o?a=o.querySelectorAll(".is-lightbox"):document.querySelectorAll(".is-lightbox,.block-click").forEach(u=>{u.closest("[data-gallery]")||a.push(u)}),a.forEach((d,u)=>{let l=d.getAttribute("href");l||(l=d.getAttribute("data-modal-url")),n.push({href:l}),e===l&&(s=u)})}const r=document.activeElement;r?.blur(),n.length>0?(this.glightbox.setElements(n),this.glightbox.openAt(s)):(this.glightbox.setElements([{href:e}]),this.glightbox.open()),this.glightbox.on("close",()=>{this.refreshLightbox(t),r?.focus()})}blockInit(){const e={start:()=>{document.querySelectorAll(".is-block").forEach(t=>{t.hasAttribute("data--t")||t.setAttribute("data--t",t.style.top),t.hasAttribute("data--l")||t.setAttribute("data--l",t.style.left),t.hasAttribute("data--b")||t.setAttribute("data--b",t.style.bottom),t.hasAttribute("data--r")||t.setAttribute("data--r",t.style.right),t.hasAttribute("data--w")||t.setAttribute("data--w",t.style.width),t.hasAttribute("data--h")||t.setAttribute("data--h",t.style.height),t.removeAttribute("data-prev"),t.removeAttribute("data-fluid"),t.removeAttribute("data-fluid-val"),t.classList.remove("fluid"),t.style.transition=""})},apply:(t,n,s)=>{if(n&&t.getAttribute("data-prev")!==n+""){if(s||(t.style.transition="all 0.35s ease"),n!==1e4){if(t.setAttribute("data-breakpoint",n),t.hasAttribute("data--t-"+n)){let r=t.getAttribute("data--t-"+n);t.style.top=r}if(t.hasAttribute("data--l-"+n)){let r=t.getAttribute("data--l-"+n);t.style.left=r}if(t.hasAttribute("data--b-"+n)){let r=t.getAttribute("data--b-"+n);t.style.bottom=r}if(t.hasAttribute("data--r-"+n)){let r=t.getAttribute("data--r-"+n);t.style.right=r}if(t.hasAttribute("data--w-"+n)){let r=t.getAttribute("data--w-"+n);t.style.width=r}if(t.hasAttribute("data--h-"+n)){let r=t.getAttribute("data--h-"+n);t.style.height=r}if(t.hasAttribute("data--transform-"+n)){let r=t.getAttribute("data--transform-"+n);t.style.transform=r,t.setAttribute("data--transform-val",n)}}else{if(t.removeAttribute("data-breakpoint"),t.hasAttribute("data--t")){let r=t.getAttribute("data--t");t.style.top=r}if(t.hasAttribute("data--l")){let r=t.getAttribute("data--l");t.style.left=r}if(t.hasAttribute("data--b")){let r=t.getAttribute("data--b");t.style.bottom=r}if(t.hasAttribute("data--r")){let r=t.getAttribute("data--r");t.style.right=r}if(t.hasAttribute("data--w")){let r=t.getAttribute("data--w");t.style.width=r}if(t.hasAttribute("data--h")){let r=t.getAttribute("data--h");t.style.height=r}if(t.hasAttribute("data--transform")){let r=t.getAttribute("data--transform");t.style.transform=r,t.setAttribute("data--transform-val","")}}t.setAttribute("data-prev",n),setTimeout(()=>{s||(t.style.transition="")},400)}},applyFluid:(t,n)=>{t.classList.toggle("fluid",n==="yes"),t.setAttribute("data-fluid",n)},resize:t=>{const n=window.innerWidth;document.querySelectorAll(".is-box").forEach(s=>{let r=[];const o=s.attributes;for(let a=0;a<o.length;a++){let u=o[a].name.match(/^data--h-(\d+)$/);if(u){const l=parseInt(u[1],10);r.push(l)}}r=[...new Set(r)],r.sort((a,d)=>d-a);for(let a=0;a<r.length;a++){const d=r[a];if(a===0){if(n>d){let u=s.getAttribute("data--h");u?s.style.height=u:s.style.height=""}}else{const u=r[a-1];if(u>=n&&n>d){let l=s.getAttribute("data--h-"+u);l&&(s.style.height=l)}}}if(r.length>0&&r[r.length-1]>=n){const d=r[r.length-1];let u=s.getAttribute("data--h-"+d);u&&(s.style.height=u)}}),document.querySelectorAll(".is-block").forEach(s=>{if(!s.classList.contains("locked")){s.offsetWidth+60>n&&!s.classList.contains("fluid")&&(s.setAttribute("data-fluid-val",s.offsetWidth),e.applyFluid(s,"yes"));let a=s.getAttribute("data-fluid-val");a&&parseInt(a)+60<=n&&s.classList.contains("fluid")&&e.applyFluid(s,"no")}let r=[];const o=s.attributes;for(let a=0;a<o.length;a++){const d=o[a].name;let u=d.match(/^data--t-(\d+)$/);if(u){const l=parseInt(u[1],10);r.push(l)}if(u=d.match(/^data--w-(\d+)$/),u){const l=parseInt(u[1],10);r.push(l)}if(u=d.match(/^data--transform-(\d+)$/),u){const l=parseInt(u[1],10);r.push(l)}}r=[...new Set(r)],r.sort((a,d)=>d-a);for(let a=0;a<r.length;a++){const d=r[a];if(a===0)n>d&&e.apply(s,1e4,t);else{const u=r[a-1];u>=n&&n>d&&e.apply(s,u,t)}}if(r.length>0){const a=r[r.length-1];a>=n&&e.apply(s,a,t)}})},render:()=>{e.start(),e.resize(!0)},renderPageCss:t=>{const n=document.querySelector(t);n.classList.add("is-page");const r=n.querySelector("[data-pagesize]").getAttribute("data-pagesize"),o=document.querySelector("#__css_pagesize");o&&o.remove();let a="";if(r){const d=r.split(",");let u=d[0].trim(),l=d[1].trim();d.length===3?a=`
511
+ `}}else{const y=JSON.parse(m);this.tokenInput+=y.prompt_tokens,this.tokenOutput+=y.completion_tokens;break}}return!0}catch(u){return u.name==="AbortError"?this.settings.consoleLog&&console.log("Request aborted by user."):console.error("Error:",u),!1}}hexToRgb(e){const i=e.replace("#",""),t=parseInt(i,16),n=t>>16&255,s=t>>8&255,r=t&255;return{red:n,green:s,blue:r}}getId(e="id"){return`${e}-${Math.random().toString(36).substr(2,9)}`}appendHtml(e,i){e&&i&&e.insertAdjacentHTML("beforeend",i)}cleanup(){if(this.element){let e=this.element.querySelectorAll('input[type="text"], input[type="number"], input[type="email"], input[type="tel"], input[type="url"], textarea');e.forEach(i=>{i.removeEventListener("input",this.inputListener)}),e=this.element.querySelectorAll('input[type="date"], input[type="radio"], input[type="checkbox"]'),e.forEach(i=>{i.removeEventListener("change",this.changeListener)}),this.debounceTimeout&&(clearTimeout(this.debounceTimeout),this.debounceTimeout=null)}}destroy(){try{if(this._scrollListener){let e;this.settings.isBuilder?e=document.querySelector(this.settings.previewSelector):e=this.element;const i=e.querySelector(".submit-container"),t=this.getScrollableParent(i);t?t.removeEventListener("scroll",this._scrollListener):window.removeEventListener("scroll",this._scrollListener),window.removeEventListener("resize",this._scrollListener)}}catch{}this.element&&(this.cleanup(),this.element.innerHTML="",this.element=null);for(const e in this.listeners)this.listeners[e].clear();this.listeners={}}out(e){let i=this.settings.lang[e];return i||e}}class mn{constructor(e={}){const i={skin:"light"};this.settings={...i,...e},window.Glide=Rs,window.FormViewer=gn}init(){this.blockInit();const e={touchNavigation:!0,selector:".glightbox",loop:!0,autoplayVideos:!0,zoomable:!0,slideEffect:"slide",descPosition:"bottom",skin:this.settings.skin};this.refreshLightbox(e),document.querySelectorAll(".is-lightbox,.block-click").forEach(t=>{const n=s=>{if(t.closest('[contenteditable="true"]'))return s.preventDefault(),!1;{let r=t.getAttribute("href")||t.getAttribute("data-modal-url");this.openLightbox(r,t,e),s.preventDefault(),s.stopImmediatePropagation()}};t.addEventListener("click",n),t._lightboxHandler=n})}refreshLightbox(e){this.glightbox&&this.glightbox.destroy(),this.glightbox=new jt(e),window.GLightbox=jt.default}openLightbox(e,i,t){let n=[],s=0;if(i){const o=i.closest("[data-gallery]");let a=[];o?a=o.querySelectorAll(".is-lightbox"):document.querySelectorAll(".is-lightbox,.block-click").forEach(u=>{u.closest("[data-gallery]")||a.push(u)}),a.forEach((d,u)=>{let l=d.getAttribute("href");l||(l=d.getAttribute("data-modal-url")),n.push({href:l}),e===l&&(s=u)})}const r=document.activeElement;r?.blur(),n.length>0?(this.glightbox.setElements(n),this.glightbox.openAt(s)):(this.glightbox.setElements([{href:e}]),this.glightbox.open()),this.glightbox.on("close",()=>{this.refreshLightbox(t),r?.focus()})}blockInit(){const e={start:()=>{document.querySelectorAll(".is-block").forEach(t=>{t.hasAttribute("data--t")||t.setAttribute("data--t",t.style.top),t.hasAttribute("data--l")||t.setAttribute("data--l",t.style.left),t.hasAttribute("data--b")||t.setAttribute("data--b",t.style.bottom),t.hasAttribute("data--r")||t.setAttribute("data--r",t.style.right),t.hasAttribute("data--w")||t.setAttribute("data--w",t.style.width),t.hasAttribute("data--h")||t.setAttribute("data--h",t.style.height),t.removeAttribute("data-prev"),t.removeAttribute("data-fluid"),t.removeAttribute("data-fluid-val"),t.classList.remove("fluid"),t.style.transition=""})},apply:(t,n,s)=>{if(n&&t.getAttribute("data-prev")!==n+""){if(s||(t.style.transition="all 0.35s ease"),n!==1e4){if(t.setAttribute("data-breakpoint",n),t.hasAttribute("data--t-"+n)){let r=t.getAttribute("data--t-"+n);t.style.top=r}if(t.hasAttribute("data--l-"+n)){let r=t.getAttribute("data--l-"+n);t.style.left=r}if(t.hasAttribute("data--b-"+n)){let r=t.getAttribute("data--b-"+n);t.style.bottom=r}if(t.hasAttribute("data--r-"+n)){let r=t.getAttribute("data--r-"+n);t.style.right=r}if(t.hasAttribute("data--w-"+n)){let r=t.getAttribute("data--w-"+n);t.style.width=r}if(t.hasAttribute("data--h-"+n)){let r=t.getAttribute("data--h-"+n);t.style.height=r}if(t.hasAttribute("data--transform-"+n)){let r=t.getAttribute("data--transform-"+n);t.style.transform=r,t.setAttribute("data--transform-val",n)}}else{if(t.removeAttribute("data-breakpoint"),t.hasAttribute("data--t")){let r=t.getAttribute("data--t");t.style.top=r}if(t.hasAttribute("data--l")){let r=t.getAttribute("data--l");t.style.left=r}if(t.hasAttribute("data--b")){let r=t.getAttribute("data--b");t.style.bottom=r}if(t.hasAttribute("data--r")){let r=t.getAttribute("data--r");t.style.right=r}if(t.hasAttribute("data--w")){let r=t.getAttribute("data--w");t.style.width=r}if(t.hasAttribute("data--h")){let r=t.getAttribute("data--h");t.style.height=r}if(t.hasAttribute("data--transform")){let r=t.getAttribute("data--transform");t.style.transform=r,t.setAttribute("data--transform-val","")}}t.setAttribute("data-prev",n),setTimeout(()=>{s||(t.style.transition="")},400)}},applyFluid:(t,n)=>{t.classList.toggle("fluid",n==="yes"),t.setAttribute("data-fluid",n)},resize:t=>{const n=window.innerWidth;document.querySelectorAll(".is-box").forEach(s=>{let r=[];const o=s.attributes;for(let a=0;a<o.length;a++){let u=o[a].name.match(/^data--h-(\d+)$/);if(u){const l=parseInt(u[1],10);r.push(l)}}r=[...new Set(r)],r.sort((a,d)=>d-a);for(let a=0;a<r.length;a++){const d=r[a];if(a===0){if(n>d){let u=s.getAttribute("data--h");u?s.style.height=u:s.style.height=""}}else{const u=r[a-1];if(u>=n&&n>d){let l=s.getAttribute("data--h-"+u);l&&(s.style.height=l)}}}if(r.length>0&&r[r.length-1]>=n){const d=r[r.length-1];let u=s.getAttribute("data--h-"+d);u&&(s.style.height=u)}}),document.querySelectorAll(".is-block").forEach(s=>{if(!s.classList.contains("locked")){s.offsetWidth+60>n&&!s.classList.contains("fluid")&&(s.setAttribute("data-fluid-val",s.offsetWidth),e.applyFluid(s,"yes"));let a=s.getAttribute("data-fluid-val");a&&parseInt(a)+60<=n&&s.classList.contains("fluid")&&e.applyFluid(s,"no")}let r=[];const o=s.attributes;for(let a=0;a<o.length;a++){const d=o[a].name;let u=d.match(/^data--t-(\d+)$/);if(u){const l=parseInt(u[1],10);r.push(l)}if(u=d.match(/^data--w-(\d+)$/),u){const l=parseInt(u[1],10);r.push(l)}if(u=d.match(/^data--transform-(\d+)$/),u){const l=parseInt(u[1],10);r.push(l)}}r=[...new Set(r)],r.sort((a,d)=>d-a);for(let a=0;a<r.length;a++){const d=r[a];if(a===0)n>d&&e.apply(s,1e4,t);else{const u=r[a-1];u>=n&&n>d&&e.apply(s,u,t)}}if(r.length>0){const a=r[r.length-1];a>=n&&e.apply(s,a,t)}})},render:()=>{e.start(),e.resize(!0)},renderPageCss:t=>{const n=document.querySelector(t);n.classList.add("is-page");const r=n.querySelector("[data-pagesize]").getAttribute("data-pagesize"),o=document.querySelector("#__css_pagesize");o&&o.remove();let a="";if(r){const d=r.split(",");let u=d[0].trim(),l=d[1].trim();d.length===3?a=`
512
512
  <style id="__css_pagesize">
513
513
  .is-page {
514
514
  position: relative;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@innovastudio/contentbuilder-blocks-runtime",
3
3
  "type": "module",
4
- "version": "1.0.5",
4
+ "version": "1.0.6",
5
5
  "description": "Runtime libraries for ContentBuilder generated content",
6
6
  "main": "dist/contentbuilder-blocks-runtime.esm.js",
7
7
  "module": "dist/contentbuilder-blocks-runtime.esm.js",