nextcloud/core/vendor/css-vars-ponyfill/dist/css-vars-ponyfill.min.js

10 lines
15 KiB
JavaScript
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/*!
* css-vars-ponyfill
* v1.7.2
* https://github.com/jhildenbiddle/css-vars-ponyfill
* (c) 2018 John Hildenbiddle <http://hildenbiddle.com>
* MIT license
*/
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):e.cssVars=n()}(this,function(){"use strict";function e(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r={mimeType:n.mimeType||null,onBeforeSend:n.onBeforeSend||Function.prototype,onSuccess:n.onSuccess||Function.prototype,onError:n.onError||Function.prototype,onComplete:n.onComplete||Function.prototype},t=Array.isArray(e)?e:[e],o=Array.apply(null,Array(t.length)).map(function(e){return null});function s(e,n){r.onError(e,t[n],n)}function a(e,n){var s=r.onSuccess(e,t[n],n);e=!1===s?"":s||e,o[n]=e,-1===o.indexOf(null)&&r.onComplete(o)}t.forEach(function(e,n){var t=document.createElement("a");t.setAttribute("href",e),t.href=t.href;var o=t.host!==location.host,i=t.protocol===location.protocol;if(o&&"undefined"!=typeof XDomainRequest)if(i){var u=new XDomainRequest;u.open("GET",e),u.timeout=0,u.onprogress=Function.prototype,u.ontimeout=Function.prototype,u.onload=function(){a(u.responseText,n)},u.onerror=function(e){s(u,n)},setTimeout(function(){u.send()},0)}else console.log("Internet Explorer 9 Cross-Origin (CORS) requests must use the same protocol"),s(null,n);else{var c=new XMLHttpRequest;c.open("GET",e),r.mimeType&&c.overrideMimeType&&c.overrideMimeType(r.mimeType),r.onBeforeSend(c,e,n),c.onreadystatechange=function(){4===c.readyState&&(200===c.status?a(c.responseText,n):s(c,n))},c.send()}})}function n(n){var t={cssComments:/\/\*[\s\S]+?\*\//g,cssImports:/(?:@import\s*)(?:url\(\s*)?(?:['"])([^'"]*)(?:['"])(?:\s*\))?(?:[^;]*;)/g},o={include:n.include||'style,link[rel="stylesheet"]',exclude:n.exclude||null,filter:n.filter||null,onBeforeSend:n.onBeforeSend||Function.prototype,onSuccess:n.onSuccess||Function.prototype,onError:n.onError||Function.prototype,onComplete:n.onComplete||Function.prototype},s=Array.apply(null,document.querySelectorAll(o.include)).filter(function(e){return n=e,r=o.exclude,!(n.matches||n.matchesSelector||n.webkitMatchesSelector||n.mozMatchesSelector||n.msMatchesSelector||n.oMatchesSelector).call(n,r);var n,r}),a=Array.apply(null,Array(s.length)).map(function(e){return null});function i(){if(-1===a.indexOf(null)){var e=a.join("");o.onComplete(e,a,s)}}function u(n,r,t,s){var u=o.onSuccess(n,t,s);(function n(r,t,s,a){var i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:[];var u=arguments.length>5&&void 0!==arguments[5]?arguments[5]:[];var l=c(r,s,u);l.rules.length?e(l.absoluteUrls,{onBeforeSend:function(e,n,r){o.onBeforeSend(e,t,n)},onSuccess:function(e,n,r){var s=o.onSuccess(e,t,n),a=c(e=!1===s?"":s||e,n,u);return a.rules.forEach(function(n,r){e=e.replace(n,a.absoluteRules[r])}),e},onError:function(e,o,c){i.push({xhr:e,url:o}),u.push(l.rules[c]),n(r,t,s,a,i,u)},onComplete:function(e){e.forEach(function(e,n){r=r.replace(l.rules[n],e)}),n(r,t,s,a,i,u)}}):a(r,i)})(n=!1===u?"":u||n,t,s,function(e,n){null===a[r]&&(n.forEach(function(e){return o.onError(e.xhr,t,e.url)}),!o.filter||o.filter.test(e)?a[r]=e:a[r]="",i())})}function c(e,n){var o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[],s={};return s.rules=(e.replace(t.cssComments,"").match(t.cssImports)||[]).filter(function(e){return-1===o.indexOf(e)}),s.urls=s.rules.map(function(e){return e.replace(t.cssImports,"$1")}),s.absoluteUrls=s.urls.map(function(e){return r(e,n)}),s.absoluteRules=s.rules.map(function(e,t){var o=s.urls[t],a=r(s.absoluteUrls[t],n);return e.replace(o,a)}),s}s.length?s.forEach(function(n,t){var s=n.getAttribute("href"),c=n.getAttribute("rel"),l="LINK"===n.nodeName&&s&&c&&"stylesheet"===c.toLowerCase(),f="STYLE"===n.nodeName;l?e(s,{mimeType:"text/css",onBeforeSend:function(e,r,t){o.onBeforeSend(e,n,r)},onSuccess:function(e,o,a){var i=r(s,location.href);u(e,t,n,i)},onError:function(e,r,s){a[t]="",o.onError(e,n,r),i()}}):f?u(n.textContent,t,n,location.href):(a[t]="",i())}):o.onComplete("",[])}function r(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:location.href,r=document.implementation.createHTMLDocument(""),t=r.createElement("base"),o=r.createElement("a");return r.head.appendChild(t),r.body.appendChild(o),t.href=n,o.href=e,o.href}function t(){for(var e=function(e){return e instanceof Object&&e.constructor===Object},n=arguments.length,r=Array(n),o=0;o<n;o++)r[o]=arguments[o];return r.reduce(function(n,r){return Object.keys(r).forEach(function(o){var s=n[o],a=r[o];e(s)&&e(a)?n[o]=t(s,a):n[o]=a}),n},{})}var o=s;function s(e,n,r){e instanceof RegExp&&(e=a(e,r)),n instanceof RegExp&&(n=a(n,r));var t=i(e,n,r);return t&&{start:t[0],end:t[1],pre:r.slice(0,t[0]),body:r.slice(t[0]+e.length,t[1]),post:r.slice(t[1]+n.length)}}function a(e,n){var r=n.match(e);return r?r[0]:null}function i(e,n,r){var t,o,s,a,i,u=r.indexOf(e),c=r.indexOf(n,u+1),l=u;if(u>=0&&c>0){for(t=[],s=r.length;l>=0&&!i;)l==u?(t.push(l),u=r.indexOf(e,l+1)):1==t.length?i=[t.pop(),c]:((o=t.pop())<s&&(s=o,a=c),c=r.indexOf(n,l+1)),l=u<c&&u>=0?u:c;t.length&&(i=[s,a])}return i}function u(e){function n(e){throw new Error("CSS parse error: "+e)}function r(n){var r=n.exec(e);if(r)return e=e.slice(r[0].length),r}function t(){r(/^\s*/)}function o(){return r(/^{\s*/)}function s(){return r(/^}/)}function a(){if(t(),"/"===e[0]&&"*"===e[1]){for(var r=2;e[r]&&("*"!==e[r]||"/"!==e[r+1]);)r++;if(!e[r])return n("end of comment is missing");var o=e.slice(2,r);return e=e.slice(r+2),{type:"comment",comment:o}}}function i(){for(var e=[],n=void 0;n=a();)e.push(n);return e}function u(){for(t();"}"===e[0];)n("extra closing bracket");var o=r(/^(("(?:\\"|[^"])*"|'(?:\\'|[^'])*'|[^{])+)/);if(o)return o[0].trim().replace(/\/\*([^*]|[\r\n]|(\*+([^*/]|[\r\n])))*\*\/+/g,"").replace(/"(?:\\"|[^"])*"|'(?:\\'|[^'])*'/g,function(e){return e.replace(/,/g,"")}).split(/\s*(?![^(]*\)),\s*/).map(function(e){return e.replace(/\u200C/g,",")})}function c(){r(/^([;\s]*)+/);var e=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,t=r(/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/);if(t){if(t=t[0].trim(),!r(/^:\s*/))return n("property missing ':'");var o=r(/^((?:\/\*.*?\*\/|'(?:\\'|.)*?'|"(?:\\"|.)*?"|\((\s*'(?:\\'|.)*?'|"(?:\\"|.)*?"|[^)]*?)\s*\)|[^};])+)/),s={type:"declaration",property:t.replace(e,""),value:o?o[0].replace(e,"").trim():""};return r(/^[;\s]*/),s}}function l(){if(!o())return n("missing '{'");for(var e=void 0,r=i();e=c();)r.push(e),r=r.concat(i());return s()?r:n("missing '}'")}function f(){t();for(var e=[],n=void 0;n=r(/^((\d+\.\d+|\.\d+|\d+)%?|[a-z]+)\s*/);)e.push(n[1]),r(/^,\s*/);if(e.length)return{type:"keyframe",values:e,declarations:l()}}function p(){if(t(),"@"===e[0])return function(){var e=r(/^@([-\w]+)?keyframes\s*/);if(e){var t=e[1];if(!(e=r(/^([-\w]+)\s*/)))return n("@keyframes missing name");var a=e[1];if(!o())return n("@keyframes missing '{'");for(var u=void 0,c=i();u=f();)c.push(u),c=c.concat(i());return s()?{type:"keyframes",name:a,vendor:t,keyframes:c}:n("@keyframes missing '}'")}}()||function(){var e=r(/^@supports *([^{]+)/);if(e)return{type:"supports",supports:e[1].trim(),rules:d()}}()||function(){if(r(/^@host\s*/))return{type:"host",rules:d()}}()||function(){var e=r(/^@media *([^{]+)/);if(e)return{type:"media",media:e[1].trim(),rules:d()}}()||function(){var e=r(/^@custom-media\s+(--[^\s]+)\s*([^{;]+);/);if(e)return{type:"custom-media",name:e[1].trim(),media:e[2].trim()}}()||function(){if(r(/^@page */))return{type:"page",selectors:u()||[],declarations:l()}}()||function(){var e=r(/^@([-\w]+)?document *([^{]+)/);if(e)return{type:"document",document:e[2].trim(),vendor:e[1]?e[1].trim():null,rules:d()}}()||function(){if(r(/^@font-face\s*/))return{type:"font-face",declarations:l()}}()||function(){var e=r(/^@(import|charset|namespace)\s*([^;]+);/);if(e)return{type:e[1],name:e[2].trim()}}()}function d(r){if(!r&&!o())return n("missing '{'");for(var t,a=void 0,c=i();e.length&&(r||"}"!==e[0])&&(a=p()||(void 0,(t=u()||[]).length||n("selector missing"),{type:"rule",selectors:t,declarations:l()}));)c.push(a),c=c.concat(i());return r||s()?c:n("missing '}'")}return{type:"stylesheet",stylesheet:{rules:d(!0),errors:[]}}}s.range=i;var c={},l="--",f="var";function p(e){var n,r,s={},a=t({fixNestedCalc:!0,onlyVars:!0,persist:!1,preserve:!1,variables:{},onWarning:function(){}},arguments.length>1&&void 0!==arguments[1]?arguments[1]:{}),i=a.persist?c:a.variables,p=u(e);if(a.onlyVars&&(p.stylesheet.rules=function e(n){return n.filter(function(n){if(n.declarations){var r=n.declarations.filter(function(e){var n=e.property&&0===e.property.indexOf(l),r=e.value&&e.value.indexOf(f+"(")>-1;return n||r});return"font-face"!==n.type&&(n.declarations=r),Boolean(r.length)}return n.keyframes?Boolean(n.keyframes.filter(function(e){return Boolean(e.declarations.filter(function(e){var n=e.property&&0===e.property.indexOf(l),r=e.value&&e.value.indexOf(f+"(")>-1;return n||r}).length)}).length):!n.rules||(n.rules=e(n.rules).filter(function(e){return e.declarations&&e.declarations.length}),Boolean(n.rules.length))})}(p.stylesheet.rules)),p.stylesheet.rules.forEach(function(e){var n=[];if("rule"===e.type&&1===e.selectors.length&&":root"===e.selectors[0]&&(e.declarations.forEach(function(e,r){var t=e.property,o=e.value;t&&0===t.indexOf(l)&&(s[t]=o,n.push(r))}),!a.preserve))for(var r=n.length-1;r>=0;r--)e.declarations.splice(n[r],1)}),Object.keys(a.variables).forEach(function(e){var n="--"+e.replace(/^-+/,""),r=a.variables[e];e!==n&&(a.variables[n]=r,delete a.variables[e]),a.persist&&(c[n]=r)}),Object.keys(i).length){var m={declarations:[],selectors:[":root"],type:"rule"};Object.keys(i).forEach(function(e){s[e]=i[e],m.declarations.push({type:"declaration",property:e,value:i[e]}),a.persist&&(c[e]=i[e])}),a.preserve&&p.stylesheet.rules.push(m)}return function e(n,r){n.rules.forEach(function(t){t.rules?e(t,r):t.keyframes?t.keyframes.forEach(function(e){"keyframe"===e.type&&r(e.declarations,t)}):t.declarations&&r(t.declarations,n)})}(p.stylesheet,function(e,n){for(var r=void 0,t=void 0,o=void 0,i=0;i<e.length;i++)o=(r=e[i]).value,"declaration"===r.type&&o&&-1!==o.indexOf(f+"(")&&"undefined"!==(t=d(o,s,a))&&(a.preserve?(e.splice(i,0,{type:r.type,property:r.property,value:t}),i++):r.value=t)}),a.fixNestedCalc&&(n=p.stylesheet.rules,r=/(-[a-z]+-)?calc\(/,n.forEach(function(e){e.declarations&&e.declarations.forEach(function(e){for(var n=e.value,t="";r.test(n);){var s=o("calc(",")",n||"");for(n=n.slice(s.end);r.test(s.body);){var a=o(r,")",s.body);s.body=a.pre+"("+a.body+")"+a.post}t+=s.pre+"calc("+s.body,t+=r.test(n)?"":")"+s.post}e.value=t||e.value})})),function(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",r=arguments[2],t={charset:function(e){return"@charset "+e.name+";"},comment:function(e){return 0===e.comment.indexOf("__CSSVARSPONYFILL")?"/*"+e.comment+"*/":""},"custom-media":function(e){return"@custom-media "+e.name+" "+e.media+";"},declaration:function(e){return e.property+":"+e.value+";"},document:function(e){return"@"+(e.vendor||"")+"document "+e.document+"{"+o(e.rules)+"}"},"font-face":function(e){return"@font-face{"+o(e.declarations)+"}"},host:function(e){return"@host{"+o(e.rules)+"}"},import:function(e){return"@import "+e.name+";"},keyframe:function(e){return e.values.join(",")+"{"+o(e.declarations)+"}"},keyframes:function(e){return"@"+(e.vendor||"")+"keyframes "+e.name+"{"+o(e.keyframes)+"}"},media:function(e){return"@media "+e.media+"{"+o(e.rules)+"}"},namespace:function(e){return"@namespace "+e.name+";"},page:function(e){return"@page "+(e.selectors.length?e.selectors.join(", "):"")+"{"+o(e.declarations)+"}"},rule:function(e){var n=e.declarations;if(n.length)return e.selectors.join(",")+"{"+o(n)+"}"},supports:function(e){return"@supports "+e.supports+"{"+o(e.rules)+"}"}};function o(e){for(var o="",s=0;s<e.length;s++){var a=e[s];r&&r(a);var i=t[a.type](a);i&&(o+=i,i.length&&a.selectors&&(o+=n))}return o}return o(e.stylesheet.rules)}(p)}function d(e,n,r){var t=o("(",")",e),s=e.indexOf("var("),a=o("(",")",e.substring(s)).body,i="CSS transform warning:";t||r.onWarning(i+' missing closing ")" in the value "'+e+'"'),""===a&&r.onWarning(i+" var() must contain a non-whitespace string");var u=f+"("+a+")",c=a.replace(/([\w-]+)(?:\s*,\s*)?(.*)?/,function(e,t,o){var s=n[t];return s||o||r.onWarning(i+' variable "'+t+'" is undefined'),!s&&o?o:s});return-1!==(e=e.split(u).join(c)).indexOf(f+"(")&&(e=d(e,n,r)),e}var m="css-vars-ponyfill",v={include:"style,link[rel=stylesheet]",exclude:"",fixNestedCalc:!0,onlyLegacy:!0,onlyVars:!1,preserve:!1,silent:!1,updateDOM:!0,updateURLs:!0,variables:{},onBeforeSend:function(){},onSuccess:function(){},onWarning:function(){},onError:function(){},onComplete:function(){}},y={cssComments:/\/\*[\s\S]+?\*\//g,cssUrls:/url\((?!['"]?(?:data|http|\/\/):)['"]?([^'")]*)['"]?\)/g,cssVars:/(?:(?::root\s*{\s*[^;]*;*\s*)|(?:var\(\s*))(--[^:)]+)(?:\s*[:)])/};function h(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:location.href,r=document.implementation.createHTMLDocument(""),t=r.createElement("base"),o=r.createElement("a");return r.head.appendChild(t),r.body.appendChild(o),t.href=n,o.href=e,o.href}return function e(){var r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},o=t(v,r);function s(e,n,r,t){o.silent||console.error(e+"\n",n),o.onError(e,n,r,t)}function a(e){o.silent||console.warn(e),o.onWarning(e)}if("loading"!==document.readyState){var i=window.CSS&&window.CSS.supports&&window.CSS.supports("(--a: 0)");if(i&&o.onlyLegacy)i&&o.updateDOM&&Object.keys(o.variables).forEach(function(e){var n="--"+e.replace(/^-+/,""),r=o.variables[e];document.documentElement.style.setProperty(n,r)});else{var u=m;n({include:o.include,exclude:"#"+u+(o.exclude?","+o.exclude:""),filter:o.onlyVars?y.cssVars:null,onBeforeSend:o.onBeforeSend,onSuccess:function(e,n,r){var t=o.onSuccess(e,n,r);return e=!1===t?"":t||e,o.updateURLs&&(e.replace(y.cssComments,"").match(y.cssUrls)||[]).forEach(function(n){var t=n.replace(y.cssUrls,"$1"),o=h(t,r);e=e.replace(n,n.replace(t,o))}),e},onError:function(e,n,r){var t=e.responseURL||h(r,location.href),o=e.statusText?"("+e.statusText+")":"Unspecified Error"+(0===e.status?" (possibly CORS related)":"");s("CSS XHR Error: "+t+" "+e.status+" "+o,n,e,t)},onComplete:function(e,n,r){var t=/\/\*__CSSVARSPONYFILL-(\d+)__\*\//g,i=null;e=n.map(function(e,n){return y.cssVars.test(e)?e:"/*__CSSVARSPONYFILL-"+n+"__*/"}).join("");try{e=p(e,{fixNestedCalc:o.fixNestedCalc,onlyVars:o.onlyVars,persist:o.updateDOM,preserve:o.preserve,variables:o.variables,onWarning:a});for(var c=t.exec(e);null!==c;){var l=c[0],f=c[1];e=e.replace(l,n[f]),c=t.exec(e)}if(o.updateDOM&&r&&r.length){var d=r[r.length-1];(i=document.querySelector("#"+u)||document.createElement("style")).setAttribute("id",u),i.textContent!==e&&(i.textContent=e),d.nextSibling!==i&&d.parentNode.insertBefore(i,d.nextSibling)}}catch(e){var m=!1;n.forEach(function(e,n){try{e=p(e,o)}catch(e){var t=r[n-0];m=!0,s(e.message,t)}}),m||s(e.message||e)}o.onComplete(e,i)}})}}else document.addEventListener("DOMContentLoaded",function n(t){e(r),document.removeEventListener("DOMContentLoaded",n)})}});
//# sourceMappingURL=css-vars-ponyfill.min.js.map