forked from WebReflection/lighterhtml
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathes.js
More file actions
8 lines (8 loc) 路 12.9 KB
/
Copy pathes.js
File metadata and controls
8 lines (8 loc) 路 12.9 KB
1
2
3
4
5
6
7
8
/*! (c) Andrea Giammarchi - ISC */var lighterhtml=function(e){"use strict";
/*! (c) Andrea Giammarchi - ISC *//*! (c) Andrea Giammarchi - ISC */var t,n="-"+Math.random().toFixed(6)+"%",r=!1;try{"content"in(t=document.createElement("template"))&&(t.innerHTML='<p tabindex="'+n+'"></p>',t.content.childNodes[0].getAttribute("tabindex")==n)||(n="_dt: "+n.slice(1,-1)+";",r=!0)}catch(e){}var o="\x3c!--"+n+"--\x3e",a=8,s=1,i=3,l=/^(?:style|textarea)$/i,c=/^(?:area|base|br|col|embed|hr|img|input|keygen|link|menuitem|meta|param|source|track|wbr)$/i;
/*! (c) Andrea Giammarchi - ISC */
function u(e){return e.join(o).replace(m,x).replace(g,w)}/*! (c) Andrea Giammarchi - ISC */var f=" \\f\\n\\r\\t",h="[^"+f+"\\/>\"'=]+",p="["+f+"]+"+h,d="<([A-Za-z]+[A-Za-z0-9:._-]*)((?:",v="(?:\\s*=\\s*(?:'[^']*?'|\"[^\"]*?\"|<[^>]*?>|"+h.replace("\\/","")+"))?)",g=new RegExp(d+p+v+"+)(["+f+"]*/?>)","g"),m=new RegExp(d+p+v+"*)(["+f+"]*/>)","g"),y=new RegExp("("+p+"\\s*=\\s*)(['\"]?)"+o+"\\2","gi");function w(e,t,n,r){return"<"+t+n.replace(y,b)+r}function b(e,t,r){return t+(r||'"')+n+(r||'"')}function x(e,t,n){return c.test(t)?e:"<"+t+n+"></"+t+">"}
/*! (c) Andrea Giammarchi - ISC *//*! (c) Andrea Giammarchi - ISC */var N=function(e){var t="fragment",n=function(e){var t=r("template");return t.innerHTML=e,t.content};return function(e,t){return("svg"===t?o:n)(e)};function r(n){return n===t?e.createDocumentFragment():e.createElementNS("http://www.w3.org/1999/xhtml",n)}function o(e){var n=r(t),o=r("div");return o.innerHTML='<svg xmlns="http://www.w3.org/2000/svg">'+e+"</svg>",function(e,t){for(var n=t.length;n--;)e.appendChild(t[0])}(n,o.firstChild.childNodes),n}}(document);const{indexOf:k}=[],C=(e,t,n,r,o,a)=>{const s="selectedIndex"in t;let i=s;for(;r<o;){const o=e(n[r],1);if(t.insertBefore(o,a),s&&i&&o.selected){i=!i;let{selectedIndex:e}=t;t.selectedIndex=e<0?r:k.call(t.querySelectorAll("option"),o)}r++}},E=(e,t)=>e==t,A=e=>e,S=(e,t,n,r,o,a,s)=>{const i=a-o;if(i<1)return-1;for(;n-t>=i;){let i=t,l=o;for(;i<n&&l<a&&s(e[i],r[l]);)i++,l++;if(l===a)return t;t=i+1}return-1},L=(e,t,n,r,o)=>n<r?e(t[n],0):0<n?e(t[n-1],-0).nextSibling:o,j=(e,t,n,r)=>{for(;n<r;)D(e(t[n++],-1))},T=(e,t,n)=>{let r=1,o=t;for(;r<o;){const t=(r+o)/2>>>0;n<e[t]?o=t:r=t+1}return r},M=(e,t,n,r,o,a,s,i,l,c,u,f,h)=>{((e,t,n,r,o,a,s,i,l)=>{const c=new Map,u=e.length;let f=s,h=0;for(;h<u;)switch(e[h++]){case 0:o++,f++;break;case 1:c.set(r[o],1),C(t,n,r,o++,o,f<i?t(a[f],0):l);break;case-1:f++}for(h=0;h<u;)switch(e[h++]){case 0:s++;break;case-1:c.has(a[s])?s++:j(t,a,s++,s)}})(((e,t,n,r,o,a,s)=>{const i=n+a,l=[];let c,u,f,h,p,d,v;e:for(c=0;c<=i;c++){if(c>50)return null;for(v=c-1,p=c?l[c-1]:[0,0],d=l[c]=[],u=-c;u<=c;u+=2){for(f=(h=u===-c||u!==c&&p[v+u-1]<p[v+u+1]?p[v+u+1]:p[v+u-1]+1)-u;h<a&&f<n&&s(r[o+h],e[t+f]);)h++,f++;if(h===a&&f===n)break e;d[c+u]=h}}const g=Array(c/2+i/2);let m=g.length-1;for(c=l.length-1;c>=0;c--){for(;h>0&&f>0&&s(r[o+h-1],e[t+f-1]);)g[m--]=0,h--,f--;if(!c)break;v=c-1,p=c?l[c-1]:[0,0],(u=h-f)===-c||u!==c&&p[v+u-1]<p[v+u+1]?(f--,g[m--]=1):(h--,g[m--]=-1)}return g})(n,r,a,s,i,c,f)||((e,t,n,r,o,a,s,i)=>{let l=0,c=r<i?r:i;const u=Array(c++),f=Array(c);f[0]=-1;for(let e=1;e<c;e++)f[e]=s;const h=new Map;for(let e=a;e<s;e++)h.set(o[e],e);for(let r=t;r<n;r++){const t=h.get(e[r]);null!=t&&-1<(l=T(f,c,t))&&(f[l]=t,u[l]={newi:r,oldi:t,prev:u[l-1]})}for(l=--c,--s;f[l]>s;)--l;c=i+r-l;const p=Array(c);let d=u[l];for(--n;d;){const{newi:e,oldi:t}=d;for(;n>e;)p[--c]=1,--n;for(;s>t;)p[--c]=-1,--s;p[--c]=0,--n,--s,d=d.prev}for(;n>=t;)p[--c]=1,--n;for(;s>=a;)p[--c]=-1,--s;return p})(n,r,o,a,s,i,l,c),e,t,n,r,s,i,u,h)},D=e=>(e.remove||O).call(e);function O(){const{parentNode:e}=this;e&&e.removeChild(this)}
/*! (c) 2018 Andrea Giammarchi (ISC) */const $=(e,t,n,r)=>{r||(r={});const o=r.compare||E,a=r.node||A,s=null==r.before?null:a(r.before,0),i=t.length;let l=i,c=0,u=n.length,f=0;for(;c<l&&f<u&&o(t[c],n[f]);)c++,f++;for(;c<l&&f<u&&o(t[l-1],n[u-1]);)l--,u--;const h=c===l,p=f===u;if(h&&p)return n;if(h&&f<u)return C(a,e,n,f,u,L(a,t,c,i,s)),n;if(p&&c<l)return j(a,t,c,l),n;const d=l-c,v=u-f;let g=-1;if(d<v){if(-1<(g=S(n,f,u,t,c,l,o)))return C(a,e,n,f,g,a(t[c],0)),C(a,e,n,g+d,u,L(a,t,l,i,s)),n}else if(v<d&&-1<(g=S(t,c,l,n,f,u,o)))return j(a,t,c,g),j(a,t,g+v,l),n;return d<2||v<2?(C(a,e,n,f,u,a(t[c],0)),j(a,t,c,l),n):d===v&&((e,t,n,r,o,a)=>{for(;r<o&&a(n[r],e[t-1]);)r++,t--;return 0===t})(n,u,t,c,l,o)?(C(a,e,n,f,u,L(a,t,l,i,s)),n):(M(a,e,n,f,u,v,t,c,l,d,i,o,s),n)};/*! (c) Andrea Giammarchi - ISC */var _=String.prototype.trim;function G(e,t){for(var n=t.length,r=0;r<n;)e=e.childNodes[t[r++]];return e}function V(e,t,a,s){for(var i=new Map,l=e.attributes,c=[],u=c.slice.call(l,0),f=u.length,h=0;h<f;){var p,d=u[h++],v=d.value===n;if(v||1<(p=d.value.split(o)).length){var g=d.name;if(!i.has(g)){var m=a.shift().replace(v?/^(?:|[\S\s]*?\s)(\S+?)\s*=\s*('|")?$/:new RegExp("^(?:|[\\S\\s]*?\\s)("+g+")\\s*=\\s*('|\")[\\S\\s]*","i"),"$1"),y=l[m]||l[m.toLowerCase()];if(i.set(g,y),v)t.push(z(y,s,m,null));else{for(var w=p.length-2;w--;)a.shift();t.push(z(y,s,m,p))}}c.push(d)}}h=0;for(var b=(0<(f=c.length)&&r&&!("ownerSVGElement"in e));h<f;){var x=c[h++];b&&(x.value=""),e.removeAttribute(x.name)}var N=e.nodeName;if(/^script$/i.test(N)){var k=document.createElement(N);for(f=l.length,h=0;h<f;)k.setAttributeNode(l[h++].cloneNode(!0));k.textContent=e.textContent,e.parentNode.replaceChild(k,e)}}function R(e,t){return{type:"any",node:e,path:t}}function z(e,t,n,r){return{type:"attr",node:e,path:t,name:n,sparse:r}}function H(e,t){return{type:"text",node:e,path:t}}var W=document.importNode,Z=String.prototype.trim,F=new WeakMap,I=new WeakMap;function B(e,t){var r=(e.convert||u)(t),c=e.transform;c&&(r=c(r));var f=N(r,e.type);!function(e){var t=e.childNodes,n=t.length;for(;n--;){var r=t[n];1!==r.nodeType&&0===Z.call(r.textContent).length&&e.removeChild(r)}}
/*! (c) Andrea Giammarchi - ISC */(f);/*! (c) Andrea Giammarchi - ISC */var h=[];!function e(t,r,c,u){for(var f=t.childNodes,h=f.length,p=0;p<h;){var d=f[p];switch(d.nodeType){case s:var v=u.concat(p);V(d,r,c,v),e(d,r,c,v);break;case a:var g=d.textContent;if(g===n)c.shift(),r.push(l.test(t.nodeName)?H(t,u):R(d,u.concat(p)));else switch(g.slice(0,2)){case"/*":if("*/"!==g.slice(-2))break;case"馃懟":t.removeChild(d),p--,h--}break;case i:l.test(t.nodeName)&&_.call(d.textContent)===o&&(c.shift(),r.push(H(t,u)))}p++}}(f,h,t.slice(0),[]);var p={content:f,updates:function(n){for(var r=[],o=h.length,a=0,s=0;a<o;){var i=h[a++],l=G(n,i.path);switch(i.type){case"any":r.push({fn:e.any(l,[]),sparse:!1});break;case"attr":var c=i.sparse,u=e.attribute(l,i.name,i.node);null===c?r.push({fn:u,sparse:!1}):(s+=c.length-2,r.push({fn:u,sparse:!0,values:c}));break;case"text":r.push({fn:e.text(l),sparse:!1}),l.textContent=""}}return o+=s,function(){var e=arguments.length;if(o!==e-1)throw new Error(e-1+" values instead of "+o+"\n"+t.join("${value}"));for(var a=1,s=1;a<e;){var i=r[a-s];if(i.sparse){var l=i.values,c=l[0],u=1,f=l.length;for(s+=f-2;u<f;)c+=arguments[a++]+l[u++];i.fn(c)}else i.fn(arguments[a++])}return n}}};return F.set(t,p),p}function q(e,t){var n=F.get(t)||B(e,t),r=W.call(document,n.content,!0),o={content:r,template:t,updates:n.updates(r)};return I.set(e,o),o}var P=function(){var e=/acit|ex(?:s|g|n|p|$)|rph|ows|mnc|ntw|ine[ch]|zoo|^ord/i,t=/([^A-Z])([A-Z]+)/g;return function(e,t){return"ownerSVGElement"in e?function(e,t){var n;t?n=t.cloneNode(!0):(e.setAttribute("style","--hyper:style;"),n=e.getAttributeNode("style"));return n.value="",e.setAttributeNode(n),r(n,!0)}(e,t):r(e.style,!1)};function n(e,t,n){return t+"-"+n.toLowerCase()}function r(r,o){var a,s;return function(i){var l,c,u,f;switch(typeof i){case"object":if(i){if("object"===a){if(!o&&s!==i)for(c in s)c in i||(r[c]="")}else o?r.value="":r.cssText="";for(c in l=o?{}:r,i)u="number"!=typeof(f=i[c])||e.test(c)?f:f+"px",!o&&/^--/.test(c)?l.setProperty(c,u):l[c]=u;a="object",o?r.value=function(e){var r,o=[];for(r in e)o.push(r.replace(t,n),":",e[r],";");return o.join("")}(s=l):s=i;break}default:s!=i&&(a="string",s=i,o?r.value=i||"":r.cssText=i||"")}}}}(),J=function(e,t){return(t=n.prototype).ELEMENT_NODE=1,t.nodeType=111,t.remove=function(e){var t=this.childNodes,n=this.firstChild,r=this.lastChild;if(this._=null,e&&2===t.length)r.parentNode.removeChild(r);else{var o=this.ownerDocument.createRange();o.setStartBefore(e?t[1]:n),o.setEndAfter(r),o.deleteContents()}return n},t.valueOf=function(e){var t=this._,n=null==t;if(n&&(t=this._=this.ownerDocument.createDocumentFragment()),n||e)for(var r=this.childNodes,o=0,a=r.length;o<a;o++)t.appendChild(r[o]);return t},n;function n(t){var n=this.childNodes=e.call(t,0);this.firstChild=n[0],this.lastChild=n[n.length-1],this.ownerDocument=n[0].ownerDocument,this._=null}}([].slice);
/*! (c) Andrea Giammarchi - ISC */const{isArray:K}=Array,{create:Q,freeze:U,keys:X}=Object,Y=J.prototype.nodeType,ee=(e,t)=>e.nodeType===Y?1/t<0?t?e.remove(!0):e.lastChild:t?e.valueOf(!0):e.firstChild:e,te=(e,t)=>{let n,r=!1;const o=t.cloneNode(!0);return t=>{n!==t&&(n=t,o.value!==t&&(null==t?(r&&(r=!1,e.removeAttributeNode(o)),o.value=t):(o.value=t,r||(r=!0,e.setAttributeNode(o)))))}},ne=(e,t)=>{let n;return r=>{n!==r&&(n=r,e[t]!==r&&(null==r?(e[t]="",e.removeAttribute(t)):e[t]=r))}},re=/^(?:form|list)$/i,oe=[].slice,ae=(e,t)=>e.ownerDocument.createTextNode(t);function se(e){return this.type=e,t=this,function(e){/*! (c) Andrea Giammarchi - ISC */var n=I.get(t);return null!=n&&n.template===e||(n=q(t,e)),n.updates.apply(null,arguments),n.content};var t}function ie(e){return e(this)}se.prototype={attribute(e,t,n){switch(t){case"class":if("ownerSVGElement"in e)return te(e,n);t="className";case"data":case"props":return ne(e,t);case"style":return P(e,n,"ownerSVGElement"in e);case"ref":return(e=>t=>{t.current=e})(e);default:return"."===t.slice(0,1)?((e,t,n)=>n?n=>{try{e[t]=n}catch(r){e.setAttribute(t,n)}}:n=>{e[t]=n})(e,t.slice(1),"ownerSVGElement"in e):"on"===t.slice(0,2)?((e,t)=>{let n,r=t.slice(2);return t.toLowerCase()in e&&(r=r.toLowerCase()),t=>{n!==t&&(n&&e.removeEventListener(r,n,!1),n=t,t&&e.addEventListener(r,t,!1))}})(e,t):t in e&&!("ownerSVGElement"in e||re.test(t))?ne(e,t):te(e,n)}},any(e,t){const n={node:ee,before:e},r="ownerSVGElement"in e?"svg":"html";let o,a=!1;const s=i=>{switch(typeof i){case"string":case"number":case"boolean":a?o!==i&&(o=i,t[0].textContent=i):(a=!0,o=i,t=$(e.parentNode,t,[ae(e,i)],n));break;case"function":s(i(e));break;case"object":case"undefined":if(null==i){a=!1,t=$(e.parentNode,t,[],n);break}default:if(a=!1,o=i,K(i))if(0===i.length)t.length&&(t=$(e.parentNode,t,[],n));else switch(typeof i[0]){case"string":case"number":case"boolean":s(String(i));break;case"function":s(i.map(ie,e));break;case"object":K(i[0])&&(i=i.concat.apply([],i));default:t=$(e.parentNode,t,i,n)}else(e=>"ELEMENT_NODE"in e)(i)?t=$(e.parentNode,t,11===i.nodeType?oe.call(i.childNodes):[i],n):"text"in i?s(String(i.text)):"any"in i?s(i.any):"html"in i?t=$(e.parentNode,t,oe.call(N([].concat(i.html).join(""),r).childNodes),n):"length"in i&&s(oe.call(i))}};return s},text(e){let t;const n=r=>{if(t!==r){t=r;const o=typeof r;"object"===o&&r?"text"in r?n(String(r.text)):"any"in r?n(r.any):"html"in r?n([].concat(r.html).join("")):"length"in r&&n(oe.call(r).join("")):"function"===o?n(r(e)):e.textContent=null==r?"":r}};return n}};const le=se.prototype,ce=new WeakMap,ue=e=>({html:fe("html",e),svg:fe("svg",e),render(t,n){const r="function"==typeof n?n():n,o=ce.get(t)||pe(t),a=r instanceof me?he(e,o,r):r;return a!==o.wire&&(o.wire=a,t.textContent="",t.appendChild(a.valueOf(!0))),t}}),fe=(e,t)=>{const n=new WeakMap;return r.for=(e,o)=>{const a=n.get(e)||(e=>{const t=Q(null);return n.set(e,t),t})(e);return a[o]||(a[o]=(e=>(function(){return he(t,e,r.apply(null,arguments))}))({sub:[],stack:[],wire:null}))},r.node=function(){return he(t,{sub:[],stack:[],wire:null},r.apply(null,arguments)).valueOf(!0)},r;function r(){return new me(e,arguments)}},he=(e,t,n)=>{const{sub:r,stack:o}=t,a={a:0,aLength:r.length,i:0,iLength:o.length},s=de(e,t,n,a),{a:i,i:l,aLength:c,iLength:u}=a;return i+1<c&&r.splice(i+1),l+1<u&&o.splice(l+1),s},pe=e=>{const t={sub:[],stack:[],wire:null};return ce.set(e,t),t},de=(e,t,n,r)=>{const{stack:o}=t,{i:a,iLength:s}=r,{type:i,args:l}=n;a===s&&(r.iLength=o.push({type:i,id:l[0],tag:null,wire:null})),ve(e,t,l,r);const c=o[a];return a<s&&c.id===l[0]&&c.type===i?c.tag.apply(null,l):(c.type=i,c.id=l[0],c.tag=new e(i),c.wire=ge(c.tag.apply(null,l))),c.wire},ve=(e,t,n,r)=>{for(let o=1,{length:a}=n;o<a;o++){const a=n[o];if("object"==typeof a&&a)if(a instanceof me)r.i++,n[o]=de(e,t,a,r);else if(K(a))for(let n=0,{length:o}=a;n<o;n++){const o=a[n];if("object"==typeof o&&o&&o instanceof me){const{sub:s}=t,{a:i,aLength:l}=r;i===l&&(r.aLength=s.push({sub:[],stack:[],wire:null})),r.a++,a[n]=he(e,s[i],o)}}}},ge=e=>{const t=e.childNodes,{length:n}=t;return 1===n?t[0]:n?new J(t):e};function me(e,t){this.type=e,this.args=t}U(me);const{render:ye,html:we,svg:be}=ue(se);return e.Hole=me,e.custom=e=>{const t=Q(le);return X(e).forEach(n=>{t[n]=e[n](t[n]||("convert"===n?u:String))}),n.prototype=t,ue(n);function n(){return se.apply(this,arguments)}},e.html=we,e.render=ye,e.svg=be,e}({});