You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

8 lines
9.4 KiB
JavaScript

/**
* Bundled by jsDelivr using Rollup v2.60.2 and Terser v5.10.0.
* Original file: /npm/incremental-dom@0.7.0/dist/incremental-dom-cjs.js
*
* Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files
*/
var t={};Object.defineProperty(t,"__esModule",{value:!0});let e="key";let n=!1,r=!1,o=!1;function l(t){if(!t)throw new Error("Expected value to be defined");return t}function i(t){if(!o)throw new Error("Cannot call "+t+"() unless in patch.")}function c(t){if(n)throw new Error(t+"() can not be called between elementOpenStart() and elementOpenEnd().")}function s(t){if(r)throw new Error(t+"() may not be called inside an element that has called skip().")}function u(t){if(!n)throw new Error(t+"() can only be called after calling elementOpenStart().")}function a(t){o=null!=t}function f(t){const e=n;return n=t,e}function p(t){const e=r;return r=t,e}const d=Object.prototype.hasOwnProperty;function h(){}function m(){return new h}function g(t,e){for(;t.length>e;)t.pop()}h.prototype=Object.create(null);const y={default:"__default"};function w(t,e,n){if(null==n)t.removeAttribute(e);else{const r=function(t){return 0===t.lastIndexOf("xml:",0)?"http://www.w3.org/XML/1998/namespace":0===t.lastIndexOf("xlink:",0)?"http://www.w3.org/1999/xlink":null}(e);r?t.setAttributeNS(r,e,String(n)):t.setAttribute(e,String(n))}}function b(t,e,n){t[e]=n}function O(t,e,n){e.indexOf("-")>=0?t.setProperty(e,n):t[e]=n}const x=m();function A(t,e,n){(x[e]||x[y.default])(t,e,n)}x[y.default]=function(t,e,n){const r=typeof n;"object"===r||"function"===r?b(t,e,n):w(t,e,n)},x.style=function(t,e,n){l("style"in t);const r=t.style;if("string"==typeof n)r.cssText=n;else{r.cssText="";for(const t in n)o=n,i=t,d.call(o,i)&&O(r,t,n[t])}var o,i};const S={nodesCreated:null,nodesDeleted:null};class E{constructor(){this.created=[],this.deleted=[]}markCreated(t){this.created.push(t)}markDeleted(t){this.deleted.push(t)}notifyChanges(){S.nodesCreated&&this.created.length>0&&S.nodesCreated(this.created),S.nodesDeleted&&this.deleted.length>0&&S.nodesDeleted(this.deleted)}}function C(t){return 1===t.nodeType}const D="undefined"!=typeof Node&&Node.prototype.getRootNode||function(){let t=this,e=t;for(;t;)e=t,t=t.parentNode;return e};function _(t,e){const n=function(t){const e=D.call(t);return function(t){return 11===t.nodeType||9===t.nodeType}(e)?e.activeElement:null}(t);return n&&t.contains(n)?function(t,e){const n=[];let r=t;for(;r!==e;){const t=l(r);n.push(t),r=t.parentNode}return n}(n,e):[]}class k{constructor(t,e,n){this._attrsArr=null,this.staticsApplied=!1,this.nameOrCtor=t,this.key=e,this.text=n}hasEmptyAttrsArr(){const t=this._attrsArr;return!t||!t.length}getAttrsArr(t){return this._attrsArr||(this._attrsArr=function(t){const e=new Array(t);return g(e,0),e}(t))}}function N(t,e,n,r){const o=new k(e,n,r);return t.__incrementalDOMData=o,o}function v(t,n){if(t.__incrementalDOMData)return t.__incrementalDOMData;const r=C(t)?t.localName:t.nodeName,o=e,l=C(t)&&null!=o?t.getAttribute(o):null,i=N(t,r,C(t)?l||n:null);return C(t)&&function(t,e){const n=t.attributes,r=n.length;if(!r)return;const o=e.getAttrsArr(r);for(let t=0,e=0;t<r;t+=1,e+=2){const r=n[t],l=r.name,i=r.value;o[e]=l,o[e+1]=i}}(t,i),i}function M(t,e){return v(t,e)}function P(t,e,n,r){let o;if("function"==typeof n)o=new n;else{const r=function(t,e){return"svg"===t?"http://www.w3.org/2000/svg":"math"===t?"http://www.w3.org/1998/Math/MathML":null==e||"foreignObject"===M(e).nameOrCtor?null:e.namespaceURI}(n,e);o=r?t.createElementNS(r,n):t.createElement(n)}return N(o,n,r),o}function I(t,e,n,r,o){return e==n&&r==o}let T=null,j=null,K=null,B=null,L=[],R=I,z=[],V=[];function W(){return z}function q(){return V}function U(t,e,n){const r=M(t,n);return R(t,e,r.nameOrCtor,n,r.key)}function X(t,e,n){const r=t;let o=e;for(;o!==n;){const t=o.nextSibling;r.removeChild(o),T.markDeleted(o),o=t}}function F(){return j?j.nextSibling:K.firstChild}function G(){K=j,j=null}function H(){X(K,F(),null),j=K,K=K.parentNode}function J(){j=F()}function Q(t,e){let n;return n="#text"===t?function(t){const e=t.createTextNode("");return N(e,"#text",null),e}(B):P(B,K,t,e),T.markCreated(n),n}function Y(t,e){J();const n=function(t,e,n){if(!t)return null;let r=t;do{if(U(r,e,n))return r}while(n&&(r=r.nextSibling));return null}(j,t,e),r=n||Q(t,e);r!==j&&(L.indexOf(r)>=0?function(t,e,n){const r=e.nextSibling;let o=n;for(;null!==o&&o!==e;){const e=o.nextSibling;t.insertBefore(o,r),o=e}}(K,r,j):K.insertBefore(r,j),j=r)}function Z(t,e){return Y(t,e),G(),K}function $(){return p(!1),H(),j}function tt(){return Y("#text",null),j}function et(){return i("currentElement"),c("currentElement"),K}function nt(t,e={}){const{matches:r=I}=e;return(e,o,l)=>{const i=T,c=B,s=L,u=z,d=V,h=j,m=K,g=R;let y=!1,w=!1;B=e.ownerDocument,T=new E,R=r,z=[],V=[],j=null,K=e.parentNode,L=_(e,K),y=f(!1),w=p(!1),a(T);try{const r=t(e,o,l);return function(){if(n)throw new Error("elementOpenEnd() must be called after calling elementOpenStart().")}(),r}finally{T.notifyChanges(),B=c,T=i,R=g,z=u,V=d,j=h,K=m,L=s,f(y),p(w),a(T)}}}function rt(t){return nt(((t,e,n)=>(j=t,G(),e(n),H(),function(t,e){if(t===e)return;let n=t;const r=[];for(;n&&n!==e;)r.push(n.nodeName.toLowerCase()),n=n.parentNode;throw new Error("One or more tags were not closed:\n"+r.join("\n"))}(j,t),t)),t)}function ot(t){return nt(((t,e,n)=>{const r={nextSibling:t};let o=null,i=null;return o=t.nextSibling,i=t.previousSibling,j=r,e(n),K||console.warn("patchOuter requires the node have a parent if there is a key."),function(t,e,n,r){const o=l(t),i=l(e),c=i.nextSibling===n&&i.previousSibling===r,s=i.nextSibling===o.nextSibling&&i.previousSibling===r;if(!c&&!s&&i!==o)throw new Error("There must be exactly one top level call corresponding to the patched element.")}(r,j,o,i),K&&X(K,F(),t.nextSibling),r===j?null:j}),t)}const lt=rt(),it=ot(),ct=[];let st=0;function ut(t,e,n,r){ct.push(t),ct.push(e),ct.push(n),ct.push(r)}const at=m();function ft(t,e,n,r){const o=!t.length;let l=0;for(;l<e.length;l+=2){const i=e[l];if(o)t[l]=i;else if(t[l]!==i)break;const c=e[l+1];(o||t[l+1]!==c)&&(t[l+1]=c,ut(r,n,i,c))}if(l<e.length||l<t.length){const o=l;for(l=o;l<t.length;l+=2)at[t[l]]=t[l+1];for(l=o;l<e.length;l+=2){const o=e[l],i=e[l+1];at[o]!==i&&ut(r,n,o,i),t[l]=o,t[l+1]=i,delete at[o]}g(t,e.length);for(const t in at)ut(r,n,t,void 0),delete at[t]}!function(){const t=st,e=ct.length;st=e;for(let n=t;n<e;n+=4)(0,ct[n])(ct[n+1],ct[n+2],ct[n+3]);st=t,g(ct,t)}()}const pt=m();function dt(t,e){const n=q();ft(e.getAttrsArr(n.length),n,t,A),g(n,0)}function ht(t,e,n){if(e.staticsApplied)return;if(e.staticsApplied=!0,!n||!n.length)return;if(e.hasEmptyAttrsArr()){for(let e=0;e<n.length;e+=2)A(t,n[e],n[e+1]);return}for(let t=0;t<n.length;t+=2)pt[n[t]]=t+1;const r=e.getAttrsArr(0);let o=0;for(let t=0;t<r.length;t+=2){const e=r[t],l=r[t+1],i=pt[e];i?n[i]===l&&delete pt[e]:(r[o]=e,r[o+1]=l,o+=2)}g(r,o);for(const e in pt)A(t,e,n[pt[e]]),delete pt[e]}function mt(t,e,n){const r=W();c("elementOpenStart"),f(!0),r[0]=t,r[1]=e,r[2]=n}function gt(t,e){const n=q();i("attr"),n.push(t),n.push(e)}function yt(){const t=W();u("elementOpenEnd"),f(!1);const e=Z(t[0],t[1]),n=M(e);return ht(e,n,t[2]),dt(e,n),g(t,0),e}function wt(t,e,n,...r){c("elementOpen"),s("elementOpen"),mt(t,e,n);for(let t=3;t<arguments.length;t+=2)gt(arguments[t],arguments[t+1]);return yt()}function bt(t){c("elementClose");const e=$();return function(t,e){if(t!==e)throw new Error('Received a call to close "'+e+'" but "'+t+'" was open.')}(M(e).nameOrCtor,t),e}var Ot=t.applyAttr=w,xt=t.applyProp=b,At=t.attributes=x,St=t.alignWithDOM=Y,Et=t.close=$,Ct=t.createPatchInner=rt,Dt=t.createPatchOuter=ot,_t=t.currentElement=et,kt=t.currentPointer=function(){return i("currentPointer"),c("currentPointer"),F()},Nt=t.open=Z,vt=t.patch=lt,Mt=t.patchInner=lt,Pt=t.patchOuter=it,It=t.skip=function(){!function(t,e){if(null!==e)throw new Error(t+"() must come before any child declarations inside the current element.")}("skip",j),p(!0),j=K.lastChild},Tt=t.skipNode=J,jt=t.setKeyAttributeName=function(t){e=t},Kt=t.clearCache=function t(e){e.__incrementalDOMData=null;for(let n=e.firstChild;n;n=n.nextSibling)t(n)},Bt=t.getKey=function(t){return l(t.__incrementalDOMData),M(t).key},Lt=t.importNode=function t(e){v(e);for(let n=e.firstChild;n;n=n.nextSibling)t(n)},Rt=t.isDataInitialized=function(t){return Boolean(t.__incrementalDOMData)},zt=t.notifications=S,Vt=t.symbols=y,Wt=t.applyAttrs=function(){const t=et();dt(t,M(t))},qt=t.applyStatics=function(t){const e=et();ht(e,M(e),t)},Ut=t.attr=gt,Xt=t.elementClose=bt,Ft=t.elementOpen=wt,Gt=t.elementOpenEnd=yt,Ht=t.elementOpenStart=mt,Jt=t.elementVoid=function(t,e,n,...r){return wt.apply(null,arguments),bt(t)},Qt=t.key=function(t){const e=W();u("key"),l(e),e[1]=t},Yt=t.text=function(t,...e){c("text"),s("text");const n=tt(),r=M(n);if(r.text!==t){r.text=t;let e=t;for(let t=1;t<arguments.length;t+=1){e=(0,arguments[t])(e)}n.data!==e&&(n.data=e)}return n},Zt=t.__esModule;export{Zt as __esModule,St as alignWithDOM,Ot as applyAttr,Wt as applyAttrs,xt as applyProp,qt as applyStatics,Ut as attr,At as attributes,Kt as clearCache,Et as close,Ct as createPatchInner,Dt as createPatchOuter,_t as currentElement,kt as currentPointer,t as default,Xt as elementClose,Ft as elementOpen,Gt as elementOpenEnd,Ht as elementOpenStart,Jt as elementVoid,Bt as getKey,Lt as importNode,Rt as isDataInitialized,Qt as key,zt as notifications,Nt as open,vt as patch,Mt as patchInner,Pt as patchOuter,jt as setKeyAttributeName,It as skip,Tt as skipNode,Vt as symbols,Yt as text};