@tindtechnologies/universalviewer
Version:
The Universal Viewer is a community-developed open source project on a mission to help you share your 📚📜📰📽️📻🗿 with the 🌎
2 lines (1 loc) • 8.63 kB
JavaScript
import"./chunk-YAXTLTJC.js";var y=function(){function e(){this.start=0,this.end=0,this.previous=null,this.parent=null,this.rules=null,this.parsedCssText="",this.cssText="",this.atRule=!1,this.type=0,this.keyframesName="",this.selector="",this.parsedSelector=""}return e}();function V(e){return e=k(e),b(O(e),e)}function k(e){return e.replace(f.comments,"").replace(f.port,"")}function O(e){var r=new y;r.start=0,r.end=e.length;for(var t=r,n=0,a=e.length;n<a;n++)if(e[n]===G){t.rules||(t.rules=[]);var s=t,i=s.rules[s.rules.length-1]||null;t=new y,t.start=n+1,t.parent=s,t.previous=i,s.rules.push(t)}else e[n]===T&&(t.end=n+1,t=t.parent||r);return r}function b(e,r){var t=r.substring(e.start,e.end-1);if(e.parsedCssText=e.cssText=t.trim(),e.parent){var n=e.previous?e.previous.end:e.parent.start;t=r.substring(n,e.start-1),t=U(t),t=t.replace(f.multipleSpaces," "),t=t.substring(t.lastIndexOf(";")+1);var a=e.parsedSelector=e.selector=t.trim();e.atRule=a.indexOf(F)===0,e.atRule?a.indexOf(P)===0?e.type=c.MEDIA_RULE:a.match(f.keyframesRule)&&(e.type=c.KEYFRAMES_RULE,e.keyframesName=e.selector.split(f.multipleSpaces).pop()):a.indexOf(D)===0?e.type=c.MIXIN_RULE:e.type=c.STYLE_RULE}var s=e.rules;if(s)for(var i=0,o=s.length,u=void 0;i<o&&(u=s[i]);i++)b(u,r);return e}function U(e){return e.replace(/\\([0-9a-f]{1,6})\s/gi,function(){for(var r=arguments[1],t=6-r.length;t--;)r="0"+r;return"\\"+r})}var c={STYLE_RULE:1,KEYFRAMES_RULE:7,MEDIA_RULE:4,MIXIN_RULE:1e3},G="{",T="}",f={comments:/\/\*[^*]*\*+([^/*][^*]*\*+)*\//gim,port:/@import[^;]*;/gim,customProp:/(?:^[^;\-\s}]+)?--[^;{}]*?:[^{};]*?(?:[;\n]|$)/gim,mixinProp:/(?:^[^;\-\s}]+)?--[^;{}]*?:[^{};]*?{[^}]*?}(?:[;\n]|$)?/gim,mixinApply:/@apply\s*\(?[^);]*\)?\s*(?:[;\n]|$)?/gim,varApply:/[^;:]*?:[^;]*?var\([^;]*\)(?:[;\n]|$)?/gim,keyframesRule:/^@[^\s]*keyframes/,multipleSpaces:/\s+/g},D="--",P="@media",F="@";function E(e,r,t){e.lastIndex=0;var n=r.substring(t).match(e);if(n){var a=t+n.index;return{start:a,end:a+n[0].length}}return null}var $=/\bvar\(/,j=/\B--[\w-]+\s*:/,B=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//gim,H=/^[\t ]+\n/gm;function X(e,r,t){return e[r]?e[r]:t?p(t,e):""}function Y(e,r){for(var t=0,n=r;n<e.length;n++){var a=e[n];if(a==="(")t++;else if(a===")"&&(t--,t<=0))return n+1}return n}function W(e,r){var t=E($,e,r);if(!t)return null;var n=Y(e,t.start),a=e.substring(t.end,n-1),s=a.split(","),i=s[0],o=s.slice(1);return{start:t.start,end:n,propName:i.trim(),fallback:o.length>0?o.join(",").trim():void 0}}function q(e,r,t){var n=W(e,t);if(!n)return r.push(e.substring(t,e.length)),e.length;var a=n.propName,s=n.fallback!=null?h(n.fallback):void 0;return r.push(e.substring(t,n.start),function(i){return X(i,a,s)}),n.end}function p(e,r){for(var t="",n=0;n<e.length;n++){var a=e[n];t+=typeof a=="string"?a:a(r)}return t}function z(e,r){for(var t=!1,n=!1,a=r;a<e.length;a++){var s=e[a];if(t)n&&s==='"'&&(t=!1),!n&&s==="'"&&(t=!1);else if(s==='"')t=!0,n=!0;else if(s==="'")t=!0,n=!1;else{if(s===";")return a+1;if(s==="}")return a}}return a}function K(e){for(var r="",t=0;;){var n=E(j,e,t),a=n?n.start:e.length;if(r+=e.substring(t,a),n)t=z(e,a);else break}return r}function h(e){var r=0;e=e.replace(B,""),e=K(e).replace(H,"");for(var t=[];r<e.length;)r=q(e,t,r);return t}function R(e){var r={};e.forEach(function(o){o.declarations.forEach(function(u){r[u.prop]=u.value})});for(var t={},n=Object.entries(r),a=function(o){var u=!1;if(n.forEach(function(S){var d=S[0],N=S[1],g=p(N,t);g!==t[d]&&(t[d]=g,u=!0)}),!u)return"break"},s=0;s<10;s++){var i=a();if(i==="break")break}return t}function x(e,r){if(r===void 0&&(r=0),!e.rules)return[];var t=[];return e.rules.filter(function(n){return n.type===c.STYLE_RULE}).forEach(function(n){var a=Q(n.cssText);a.length>0&&n.parsedSelector.split(",").forEach(function(s){s=s.trim(),t.push({selector:s,declarations:a,specificity:Z(),nu:r})}),r++}),t}function Z(e){return 1}var A="!important",J=/(?:^|[;\s{]\s*)(--[\w-]*?)\s*:\s*(?:((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};{])+)|\{([^}]*)\}(?:(?=[;\s}])|$))/gm;function Q(e){for(var r=[],t;t=J.exec(e.trim());){var n=ee(t[2]),a=n.value,s=n.important;r.push({prop:t[1].trim(),value:h(a),important:s})}return r}function ee(e){var r=/\s+/gim;e=e.replace(r," ").trim();var t=e.endsWith(A);return t&&(e=e.substr(0,e.length-A.length).trim()),{value:e,important:t}}function te(e,r,t){var n=[],a=re(r,e);t.forEach(function(o){return n.push(o)}),a.forEach(function(o){return n.push(o)});var s=_(n),i=s.filter(function(o){return ae(e,o.selector)});return ne(i)}function re(e,r){for(var t=[];r;){var n=e.get(r);n&&t.push(n),r=r.parentElement}return t}function _(e){var r=[];return e.forEach(function(t){r.push.apply(r,t.selectors)}),r}function ne(e){return e.sort(function(r,t){return r.specificity===t.specificity?r.nu-t.nu:r.specificity-t.specificity}),e}function ae(e,r){return r===":root"||r==="html"||e.matches(r)}function C(e){var r=V(e),t=h(e),n=x(r);return{original:e,template:t,selectors:n,usesCssVars:t.length>1}}function v(e,r){if(e.some(function(n){return n.styleEl===r}))return!1;var t=C(r.textContent);return t.styleEl=r,e.push(t),!0}function M(e){var r=_(e),t=R(r);e.forEach(function(n){n.usesCssVars&&(n.styleEl.textContent=p(n.template,t))})}function se(e,r){var t=e.template.map(function(a){return typeof a=="string"?w(a,e.scopeId,r):a}),n=e.selectors.map(function(a){return Object.assign(Object.assign({},a),{selector:w(a.selector,e.scopeId,r)})});return Object.assign(Object.assign({},e),{template:t,selectors:n,scopeId:r})}function w(e,r,t){return e=ie(e,"\\."+r,"."+t),e}function ie(e,r,t){return e.replace(new RegExp(r,"g"),t)}function oe(e,r){return L(e,r),le(e,r)}function ue(e,r){var t=new MutationObserver(function(){L(e,r)&&M(r)});t.observe(document.head,{childList:!0})}function le(e,r){for(var t=[],n=e.querySelectorAll('link[rel="stylesheet"][href]:not([data-no-shim])'),a=0;a<n.length;a++)t.push(I(e,r,n[a]));return Promise.all(t)}function L(e,r){var t=Array.from(e.querySelectorAll("style:not([data-styles]):not([data-no-shim])"));return t.map(function(n){return v(r,n)}).some(Boolean)}function I(e,r,t){var n=t.href;return fetch(n).then(function(a){return a.text()}).then(function(a){if(fe(a)&&t.parentNode){pe(a)&&(a=he(a,n));var s=e.createElement("style");s.setAttribute("data-styles",""),s.textContent=a,v(r,s),t.parentNode.insertBefore(s,t),t.remove()}}).catch(function(a){console.error(a)})}var ce=/[\s;{]--[-a-zA-Z0-9]+\s*:/m;function fe(e){return e.indexOf("var(")>-1||ce.test(e)}var m=/url[\s]*\([\s]*['"]?(?!(?:https?|data)\:|\/)([^\'\"\)]*)[\s]*['"]?\)[\s]*/gim;function pe(e){return m.lastIndex=0,m.test(e)}function he(e,r){var t=r.replace(/[^/]*$/,"");return e.replace(m,function(n,a){var s=t+a;return n.replace(a,s)})}var ve=function(){function e(r,t){this.win=r,this.doc=t,this.count=0,this.hostStyleMap=new WeakMap,this.hostScopeMap=new WeakMap,this.globalScopes=[],this.scopesMap=new Map,this.didInit=!1}return e.prototype.initShim=function(){var r=this;return this.didInit?Promise.resolve():(this.didInit=!0,new Promise(function(t){r.win.requestAnimationFrame(function(){ue(r.doc,r.globalScopes),oe(r.doc,r.globalScopes).then(function(){return t()})})}))},e.prototype.addLink=function(r){var t=this;return I(this.doc,this.globalScopes,r).then(function(){t.updateGlobal()})},e.prototype.addGlobalStyle=function(r){v(this.globalScopes,r)&&this.updateGlobal()},e.prototype.createHostStyle=function(r,t,n,a){if(this.hostScopeMap.has(r))throw new Error("host style already created");var s=this.registerHostTemplate(n,t,a),i=this.doc.createElement("style");return i.setAttribute("data-no-shim",""),s.usesCssVars?a?(i["s-sc"]=t=s.scopeId+"-"+this.count,i.textContent="/*needs update*/",this.hostStyleMap.set(r,i),this.hostScopeMap.set(r,se(s,t)),this.count++):(s.styleEl=i,s.usesCssVars||(i.textContent=p(s.template,{})),this.globalScopes.push(s),this.updateGlobal(),this.hostScopeMap.set(r,s)):i.textContent=n,i},e.prototype.removeHost=function(r){var t=this.hostStyleMap.get(r);t&&t.remove(),this.hostStyleMap.delete(r),this.hostScopeMap.delete(r)},e.prototype.updateHost=function(r){var t=this.hostScopeMap.get(r);if(t&&t.usesCssVars&&t.isScoped){var n=this.hostStyleMap.get(r);if(n){var a=te(r,this.hostScopeMap,this.globalScopes),s=R(a);n.textContent=p(t.template,s)}}},e.prototype.updateGlobal=function(){M(this.globalScopes)},e.prototype.registerHostTemplate=function(r,t,n){var a=this.scopesMap.get(t);return a||(a=C(r),a.scopeId=t,a.isScoped=n,this.scopesMap.set(t,a)),a},e}(),l=window;function me(){return!(l.CSS&&l.CSS.supports&&l.CSS.supports("color","var(--c)"))}!l.__stencil_cssshim&&me()&&(l.__stencil_cssshim=new ve(l,document));