sortable-dnd
Version:
JS library for drag-and-drop lists, supports sortable and draggable
7 lines (6 loc) • 18.6 kB
JavaScript
/*!
* sortable-dnd v0.7.1
* open source under the MIT license
* https://github.com/mfuu/sortable-dnd#readme
*/
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t="undefined"!=typeof globalThis?globalThis:t||self).Sortable=e()}(this,function(){"use strict";function t(){return t=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var o in n)({}).hasOwnProperty.call(n,o)&&(t[o]=n[o])}return t},t.apply(null,arguments)}function e(t){return e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},e(t)}var n={capture:!1,passive:!1},o=/\s+/g;function i(t){if("undefined"!=typeof window&&window.navigator)return!!navigator.userAgent.match(t)}var r=i(/(?:Trident.*rv[ :]?11\.|msie|iemobile|Windows Phone)/i),a=i(/Edge/i),l=i(/safari/i)&&!i(/chrome/i)&&!i(/android/i),s=function(){var t=!1;return document.addEventListener("checkIfSupportPassive",null,{get passive(){return t=!0,!0}}),t}();function c(t,e,o){window.addEventListener?t.addEventListener(e,o,!(!s&&r)&&n):window.attachEvent?t.attachEvent("on"+e,o):t["on"+e]=o}function h(t,e,o){window.removeEventListener?t.removeEventListener(e,o,!(!s&&r)&&n):window.detachEvent?t.detachEvent("on"+e,o):t["on"+e]=null}function u(){return document.scrollingElement||document.documentElement}function d(t,e,n){if(t.getBoundingClientRect||t===window){var o,i,r,a,l,s,c;if(t!==window&&t.parentNode&&t!==u()?(i=(o=t.getBoundingClientRect()).top,r=o.left,a=o.bottom,l=o.right,s=o.height,c=o.width):(i=0,r=0,a=window.innerHeight,l=window.innerWidth,s=window.innerHeight,c=window.innerWidth),e&&t!==window){n=n||t.parentNode;do{if(n&&n.getBoundingClientRect){var h=n.getBoundingClientRect();i-=h.top+parseInt(S(n,"border-top-width")),r-=h.left+parseInt(S(n,"border-left-width")),a=i+o.height,l=r+o.width;break}}while(n=n.parentNode)}return{top:i,left:r,bottom:a,right:l,width:c,height:s}}}function p(t,e,n,o){if(t){n=n||document;do{if(null!=e&&(">"===e[0]?t.parentNode===n&&y(t,e):y(t,e))||o&&t===n)return t;if(t===n)break}while(t=t.parentNode);return null}}function f(t,e){if(!t||!e)return!1;if(e.compareDocumentPosition)return!!(16&e.compareDocumentPosition(t));if(e.contains&&1===t.nodeType)return e.contains(t)&&e!==t;for(;t=t.parentNode;)if(t===e)return!0;return!1}function m(t,e){for(var n=t.lastElementChild;n&&(n===tt.ghost||"none"===S(n,"display")||e&&!y(n,e));)n=n.previousElementSibling;return n||null}function v(t,e){if(!t||!t.parentNode)return-1;for(var n=0;t=t.previousElementSibling;)t===tt.ghost||"TEMPLATE"===t.nodeName.toUpperCase()||"none"===S(t,"display")||e&&!y(t,e)||n++;return n}function g(t,e,n,o){for(var i=0,r=0,a=t.children;i<a.length;){if(a[i]!==tt.ghost&&"none"!==S(a[i],"display")&&p(a[i],n,t,!1)&&(o||a[i]!==tt.dragged)){if(r===e)return a[i];r++}i++}return null}function w(t,e){var n=S(t),o=parseInt(n.width)-parseInt(n.paddingLeft)-parseInt(n.paddingRight)-parseInt(n.borderLeftWidth)-parseInt(n.borderRightWidth),i=g(t,0,e),l=g(t,1,e),s=i&&S(i),c=l&&S(l),h=s&&parseInt(s.marginLeft)+parseInt(s.marginRight)+d(i).width,u=c&&parseInt(c.marginLeft)+parseInt(c.marginRight)+d(l).width,p=a||r?"cssFloat":"float";if("flex"===n.display)return"column"===n.flexDirection||"column-reverse"===n.flexDirection?"vertical":"horizontal";if("grid"===n.display)return n.gridTemplateColumns.split(" ").length<=1?"vertical":"horizontal";if(i&&s.float&&"none"!==s.float){var f="left"===s.float?"left":"right";return!l||"both"!==c.clear&&c.clear!==f?"horizontal":"vertical"}return i&&("block"===s.display||"flex"===s.display||"table"===s.display||"grid"===s.display||h>=o&&"none"===n[p]||l&&"none"===n[p]&&h+u>o)?"vertical":"horizontal"}function b(t,e,n){if(t&&e)if(t.classList)t.classList[n?"add":"remove"](e);else{var i=(" "+t.className+" ").replace(o," ").replace(" "+e+" "," ");t.className=(i+(n?" "+e:"")).replace(o," ")}}function y(t,e){if(e){if(">"===e[0]&&(e=e.substring(1)),t)try{if(t.matches)return t.matches(e);if(t.msMatchesSelector)return t.msMatchesSelector(e);if(t.webkitMatchesSelector)return t.webkitMatchesSelector(e)}catch(t){return!1}return!1}}function S(t,e,n){var o=t&&t.style;if(o){if(void 0===n)return document.defaultView&&document.defaultView.getComputedStyle?n=document.defaultView.getComputedStyle(t,""):t.currentStyle&&(n=t.currentStyle),void 0===e?n:n[e];e in o||-1!==e.indexOf("webkit")||(e="-webkit-"+e),o[e]=n+("string"==typeof n?"":"px")}}function _(t,e){return Math.round(t.top)===Math.round(e.top)&&Math.round(t.left)===Math.round(e.left)&&Math.round(t.height)===Math.round(e.height)&&Math.round(t.width)===Math.round(e.width)}function x(t,e){var n,o,i=(o=e,(n=t).compareDocumentPosition?n.compareDocumentPosition(o):n.contains?(n!=o&&n.contains(o)&&16)+(n!=o&&o.contains(n)&&8)+(n.sourceIndex>=0&&o.sourceIndex>=0?(n.sourceIndex<o.sourceIndex&&4)+(n.sourceIndex>o.sourceIndex&&2):1):0);return 2===i?1:4===i?-1:0}function E(t){void 0!==t.preventDefault&&t.cancelable&&t.preventDefault()}function I(e){var n=e.sortable,o=e.name,i=e.evt,r=n.options[o];if("function"==typeof r)return r(t({},i))}function C(t){if("function"==typeof t){for(var e=arguments.length,n=new Array(e>1?e-1:0),o=1;o<e;o++)n[o-1]=arguments[o];return t.apply(void 0,n)}return t}var M="Sortable"+Date.now();function D(t){this.options=t,this.scrollEl=null,this.autoScrollInterval=null}function T(t){this.options=t,this.animationStack=[],this.animationCallbackId=null}function N(t,e){return Math.sqrt(Math.pow(t.left-e.left,2)+Math.pow(t.top-e.top,2))}D.prototype={nulling:function(){this.autoScrollInterval&&(clearInterval(this.autoScrollInterval),this.autoScrollInterval=null)},onStarted:function(){this.nulling(),this.autoScrollInterval=setInterval(this.autoScroll.bind(this))},onMove:function(t,e,n,o){var i=n?n[M].options:o;!n||i.autoScroll?(this.options=i,this.scrollEl=function(t,e){if(!t||!t.getBoundingClientRect)return u();var n=t,o=!1;do{if(n.clientWidth<n.scrollWidth||n.clientHeight<n.scrollHeight){var i=S(n);if(n.clientWidth<n.scrollWidth&&("auto"==i.overflowX||"scroll"==i.overflowX)||n.clientHeight<n.scrollHeight&&("auto"==i.overflowY||"scroll"==i.overflowY)){if(!n.getBoundingClientRect||n===document.body)return u();if(o||e)return n;o=!0}}}while(n=n.parentNode);return u()}(t,!0),this.moveEvent=e):this.scrollEl=null},autoScroll:function(){var t=this.options,e=this.moveEvent,n=this.scrollEl,o=t.scrollThreshold,i=t.scrollSpeed;if(n&&void 0!==e.clientX&&void 0!==e.clientY){var r=d(n);if(r){var a=e.clientX,l=e.clientY,s=r.top,c=r.right,h=r.bottom,u=r.left,p=r.height,f=r.width;if(!(l<s||a>c||l>h||a<u)){var m=n.scrollTop,v=n.scrollLeft,g=n.scrollHeight,w=n.scrollWidth;n.scrollLeft+=this.getScrollOffset(a,u,c,o,i.x,v,w,f),n.scrollTop+=this.getScrollOffset(l,s,h,o,i.y,m,g,p)}}}},getScrollOffset:function(t,e,n,o,i,r,a,l){return r>0&&t>=e&&t<=e+o?Math.max(-1,(t-e)/o-1)*i:r+l<a&&t<=n&&t>=n-o?Math.min(1,(t-n)/o+1)*i:0}},T.prototype={collect:function(t){if(t){for(var e=d(t),n=window.innerWidth||document.documentElement.clientWidth||document.body.clientWidth,o=window.innerHeight||document.documentElement.clientHeight||document.body.clientHeight,i=Math.min(e.right,n),r=Math.min(e.bottom,o),a=Array.prototype.slice.call(t.children),l=[],s=0,c=a.length;s<c;s++){var h=a[s];if(h!==tt.ghost&&"none"!==S(h,"display")){var u=d(h);if(!(u.bottom<0||u.right<0)){if(0===l.length&&h.previousElementSibling){var p=h.previousElementSibling;do{if(p&&p!==tt.ghost&&"none"!==S(p,"display"))break}while(p=p.previousElementSibling);p&&l.push({el:p,rect:d(p)})}if(u.top-u.height>r||u.left-u.width>i){l.push({el:h,rect:u});break}l.push({el:h,rect:u})}}}this.animationStack.push(l)}},animate:function(t){var e=this,n=this.animationStack.pop(),o=this.options.animation;if(!n||!o)return clearTimeout(this.animationCallbackId),void("function"==typeof t&&t());var i=0;n.forEach(function(t){var n=0,r=t.el,a=d(r),l=t.rect,s=r.prevToRect,c=r.prevFromRect;if(r.animating&&c&&s&&_(l,a)){var h=function(t,e){var n="";if("string"==typeof t)n=t;else do{var o=S(t,"transform");o&&"none"!==o&&(n=o+" "+n)}while(!e&&(t=t.parentNode));var i=window.DOMMatrix||window.WebKitCSSMatrix||window.CSSMatrix||window.MSCSSMatrix;return i&&new i(n)}(r,!0);if(h)n=N({top:a.top-h.f,left:a.left-h.e},a)/N(c,s)*o}_(l,a)||(r.prevFromRect=l,r.prevToRect=a,n||(n=o),e.execute(r,l,a,n)),n&&(i=Math.max(i,n))}),clearTimeout(this.animationCallbackId),i?this.animationCallbackId=setTimeout(function(){"function"==typeof t&&t()},i):"function"==typeof t&&t()},execute:function(t,e,n,o){var i=this.options.easing||"",r=e.left-n.left,a=e.top-n.top;S(t,"transition",""),S(t,"transform","translate3d(".concat(r,"px, ").concat(a,"px, 0)")),this.repaintDummy=function(t){return t.offsetWidth}(t),S(t,"transition","transform ".concat(o,"ms ").concat(i)),S(t,"transform","translate3d(0px, 0px, 0px)"),"number"==typeof t.animating&&clearTimeout(t.animating),t.animating=setTimeout(function(){S(t,"transition",""),S(t,"transform",""),t.prevFromRect=null,t.prevToRect=null,t.animating=null},o)}};var P,O,R,k,H,X,Y,L,W,B,A,z,j,F,G,U,V,q,K,J,Q,Z=[];function $(t){var n,o,i,r={},a=t.group;a&&"object"===e(a)||(a={name:a,pull:!0,put:!0,revertDrag:!0}),r.name=a.name,r.pull=null===(n=a.pull)||void 0===n||n,r.put=null===(o=a.put)||void 0===o||o,r.revertDrag=null===(i=a.revertDrag)||void 0===i||i,t.group=r}function tt(e,n){if(!e||!e.nodeType||1!==e.nodeType)throw"Sortable-dnd: `el` must be an HTMLElement, not ".concat({}.toString.call(e));e[M]=this,this.el=e,this.options=n=t({},n);var o={store:null,group:"",handle:null,draggable:">*",sortable:!0,disabled:!1,customGhost:null,lockAxis:"",direction:"",animation:150,easing:"",chosenClass:"",placeholderClass:"",ghostClass:"",ghostStyle:{},ghostContainer:null,appendToBody:!1,autoScroll:!0,scrollThreshold:55,scrollSpeed:{x:10,y:10},delay:0,delayOnTouchOnly:!1,swapOnDrop:!0,removeCloneOnDrop:!0,dropOnAnimationEnd:!1,supportTouch:"ontouchstart"in window,touchStartThreshold:(Number.parseInt?Number:window).parseInt(window.devicePixelRatio,10)||1,emptyInsertThreshold:-1};for(var i in o)!(i in n)&&(n[i]=o[i]);for(var r in $(n),this)"_"===r.charAt(0)&&"function"==typeof this[r]&&(this[r]=this[r].bind(this));c(e,n.supportTouch?"touchstart":"mousedown",this._onDrag),this.autoScroller=new D(n),this.animator=new T(n),Z.push(e)}return tt.prototype={constructor:tt,_onDrag:function(t){var e=this,n=this.el,o=this.options,i=o.handle,s=t.touches&&t.touches[0],h=(s||t).target,u=n.ownerDocument;if(!R&&!o.disabled&&o.group.pull&&!(/mousedown|pointerdown/.test(t.type)&&0!==t.button||l&&h&&"SELECT"===h.tagName.toUpperCase())){var d=p(h,o.draggable,n);d&&!d.animating&&(G={event:t,clientX:(s||t).clientX,clientY:(s||t).clientY},R=d,c(q=s?R:document,"mouseup",this._onDrop),c(q,"touchend",this._onDrop),c(q,"touchcancel",this._onDrop),"function"==typeof i&&!i(t)||"string"==typeof i&&!p(h,i,R)||(!o.delay||o.delayOnTouchOnly&&!s||a||r?this._onStart(s,t):(c(u,"touchmove",this._delayedMoveHandler),c(u,"mousemove",this._delayedMoveHandler),c(u,"mouseup",this._cancelStart),c(u,"touchend",this._cancelStart),c(u,"touchcancel",this._cancelStart),this._dragStartTimer=setTimeout(function(){return e._onStart(s,t)},o.delay))))}},_delayedMoveHandler:function(t){var e=t.touches?t.touches[0]:t;Math.max(Math.abs(e.clientX-G.clientX),Math.abs(e.clientY-G.clientY))>=Math.floor(this.options.touchStartThreshold/(window.devicePixelRatio||1))&&this._cancelStart()},_cancelStart:function(){var t=this.el.ownerDocument;clearTimeout(this._dragStartTimer),h(t,"touchmove",this._delayedMoveHandler),h(t,"mousemove",this._delayedMoveHandler),h(t,"mouseup",this._cancelStart),h(t,"touchend",this._cancelStart),h(t,"touchcancel",this._cancelStart)},_onStart:function(t,e){E(e);var n=this.el,o=this.options,i=v(R);z=i,j=i,F=i,P=n,O=n,X=n,W=R,B=R.parentNode,A=o.group.pull,J=R,K={to:n,target:R,newIndex:i,relative:0},Y=R.cloneNode(!0),tt.dragged=R,tt.clone=Y,tt.active=this,I({sortable:this,name:"onChoose",evt:this._getEventProperties(e)}),b(R,o.chosenClass,!0),c(q,t?"touchmove":"mousemove",this._nearestSortable);try{document.selection?setTimeout(function(){return document.selection.empty()},0):window.getSelection().removeAllRanges()}catch(t){}c(document,"selectstart",E),l&&S(document.body,"user-select","none")},_onStarted:function(){var t=this.options;this.animator.collect(B),this._appendGhost(),b(Y,t.chosenClass,!0),b(Y,t.placeholderClass,!0),R.parentNode.insertBefore(Y,R),S(R,"display","none"),I({sortable:this,name:"onDrag",evt:this._getEventProperties(G.event)}),this.animator.animate(),this.autoScroller.onStarted()},_appendGhost:function(){if(!L){var e=this.options,n=e.appendToBody?document.body:C(e.ghostContainer,this)||this.el,o=C(e.customGhost,Y)||Y;b(L=o.cloneNode(!0),e.ghostClass,!0);var i=d(R),r=t({position:"fixed",top:i.top,left:i.left,width:i.width,height:i.height,margin:0,zIndex:1e5,opacity:"0.8",overflow:"hidden",boxSizing:"border-box",transform:"",transition:"",pointerEvents:"none"},e.ghostStyle);for(var a in r)S(L,a,r[a]);tt.ghost=L,n.appendChild(L);var l=(G.clientX-i.left)/parseInt(L.style.width)*100,s=(G.clientY-i.top)/parseInt(L.style.height)*100;S(L,"transform-origin","".concat(l,"% ").concat(s,"%")),S(L,"will-change","transform")}},_nearestSortable:function(t){E(t);var e=t.touches&&t.touches[0]||t;if(R&&function(t){var e=U||G;return!(void 0!==t.clientX&&void 0!==t.clientY&&Math.abs(t.clientX-e.clientX)<=0&&Math.abs(t.clientY-e.clientY)<=0)}(e)){!U&&this._onStarted();var n=this.options.lockAxis,o="x"===n?G.clientX:e.clientX,i="y"===n?G.clientY:e.clientY,r=document.elementFromPoint(o,i),a=o-G.clientX,l=i-G.clientY;U={event:t,clientX:o,clientY:i},S(L,"transform","translate3d(".concat(a,"px, ").concat(l,"px, 0)"));var s,c,h,u=(s=o,c=i,Z.reduce(function(t,e){var n=e[M].options.emptyInsertThreshold;if(null!=n){var o=d(e),i=s>=o.left-n&&s<=o.right+n,r=c>=o.top-n&&c<=o.bottom+n;return i&&r&&(!h||h&&o.left>=h.left&&o.right<=h.right&&o.top>=h.top&&o.bottom<=h.bottom)&&(t=e,h=o),t}},null));u&&u[M]._onMove(t,r),this.autoScroller.onMove(r,U,u,this.options)}},_allowPut:function(){var t=this.options.group,e=X[M].options.group;return this.el===X||!!t.put&&(t.put.join&&t.put.indexOf(e.name)>-1||e.name&&t.name&&e.name===t.name)},_getDirection:function(){var t=this.options.draggable,e=this.options.direction;return e?C(e,U.event,Y,this):w(B,t)},_allowSwap:function(){var t=d(k),e="vertical"===this._getDirection(),n=e?"top":"left",o=e?"bottom":"right",i=k[e?"offsetHeight":"offsetWidth"],r=e?U.clientY:U.clientX,a=r>=t[n]&&r<t[o]-i/2?-1:1,l=g(B,0,this.options.draggable),s=m(B),c=d(l),h=d(s);if(k===B||f(B,k))return Y===l&&r<c[n]?(H=k,!0):Y===s&&r>h[o]&&(H=k.nextSibling,!0);var u=x(Y,k);return H=u<0?k.nextSibling:k,V!==k?(Q=a,!0):Q!==a&&(Q=a,a<0?u>0:u<0)},_onMove:function(t,e){var n=this.el,o=this.options;if(!o.disabled&&this._allowPut()){if(k=p(e,o.draggable,n),I({sortable:this,name:"onMove",evt:this._getEventProperties(t,{target:k})}),o.sortable||n!==X)return n===O||e!==n&&m(n)?void(k&&!k.animating&&!f(k,Y)&&this._allowSwap()&&(k!==Y&&H!==Y?(n!==O?this._onInsert(t):k!==R&&this._onChange(t),V=k):V=k)):(k=V=null,void this._onInsert(t));O!==X&&(k=V=R,Q=0,this._onInsert(t))}},_onInsert:function(t){var e=this.el,n=k||Y,o="clone"===A&&e!==X&&O===X,i="clone"===A&&e===X&&O!==X,r=f(k,document),a=k===R&&!r,l=O[M],s=X[M];P=e,z=v(Y),W=n,B=r?k.parentNode:e,l.animator.collect(Y.parentNode),this.animator.collect(B),o&&(K.target=J,K.newIndex=z,K.relative=J===R?0:x(Y,J),S(R,"display",""),s.options.group.revertDrag||Y.parentNode.insertBefore(R,Y)),i&&(z=v(R),S(R,"display","none")),S(Y,"display",a?"none":""),k&&r?B.insertBefore(Y,Q<0?k:k.nextSibling):B.appendChild(Y),j=a?F:v(Y),o&&s.options.group.revertDrag&&(K.target=R,K.newIndex=F,K.relative=0,I({sortable:s,name:"onChange",evt:this._getEventProperties(t,{to:X,target:R,newIndex:F,revertDrag:!0})})),o||I({sortable:l,name:"onRemove",evt:this._getEventProperties(t,{newIndex:-1})}),i&&n!==R&&(J=n,I({sortable:this,name:"onChange",evt:this._getEventProperties(t,{from:X,backToOrigin:!0})})),i||I({sortable:this,name:"onAdd",evt:this._getEventProperties(t,{oldIndex:-1})}),l.animator.animate(),this.animator.animate(),O=e},_onChange:function(t){var e=this.el;this.animator.collect(B),z=v(Y),B=k.parentNode,W=k,e===X&&(J=k),B.insertBefore(Y,H),j=v(Y),I({sortable:this,name:"onChange",evt:this._getEventProperties(t)}),this.animator.animate(),O=e},_onDrop:function(t){var e=this,n=this.options;if(this._cancelStart(),h(q,"touchmove",this._nearestSortable),h(q,"mousemove",this._nearestSortable),h(q,"mouseup",this._onDrop),h(q,"touchend",this._onDrop),h(q,"touchcancel",this._onDrop),h(document,"selectstart",E),l&&S(document.body,"user-select",""),L&&L.parentNode&&L.parentNode.removeChild(L),X)if(O=X,z=F,W===Y&&(W=R),b(R,n.chosenClass,!1),I({sortable:this,name:"onUnchoose",evt:this._getEventProperties(t)}),U){this.animator.collect(B),b(Y,n.chosenClass,!1),b(Y,n.placeholderClass,!1);var o=this._getEventProperties(t);!n.dropOnAnimationEnd&&this._onEnd(o),this.animator.animate(function(){n.dropOnAnimationEnd&&e._onEnd(o)})}else this._nulling();else this._nulling()},_onEnd:function(e){var n=this.options,o="clone"===A,i=O===P;o&&!i||!C(n.swapOnDrop,e)||B.insertBefore(R,Y),o&&!i||!C(n.removeCloneOnDrop,e)||Y&&Y.parentNode&&Y.parentNode.removeChild(Y),S(R,"display",""),O!==P&&I({sortable:O[M],name:"onDrop",evt:t({},e,o?K:{newIndex:-1})}),I({sortable:P[M],name:"onDrop",evt:t({},e,i?{}:{oldIndex:-1})}),this._nulling()},_getEventProperties:function(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},o={};return o.event=e,o.to=P,o.from=O,o.node=R,o.clone=Y,o.target=W,o.oldIndex=z,o.newIndex=j,o.pullMode=A,t(o,n),o.relative=W===R?0:x(Y,W),o},_nulling:function(){P=O=R=k=H=X=Y=L=W=B=A=z=j=F=G=U=V=q=K=J=Q=tt.clone=tt.ghost=tt.active=tt.dragged=null,this.autoScroller.nulling()},destroy:function(){this._cancelStart(),this._nulling(),h(this.el,"touchstart",this._onDrag),h(this.el,"mousedown",this._onDrag);var t=Z.indexOf(this.el);t>-1&&Z.splice(t,1),this.el[M]=this.animator=this.autoScroller=null},option:function(t,e){if(void 0===e)return this.options[t];this.options[t]=e,this.animator.options[t]=e,this.autoScroller.options[t]=e,"group"===t&&$(this.options)}},tt.utils={on:c,off:h,css:S,index:v,matches:y,closest:p,getRect:d,toggleClass:b,detectDirection:w},tt.get=function(t){return t[M]},tt.create=function(t,e){return new tt(t,e)},tt});