455 lines
590 KiB
JavaScript
455 lines
590 KiB
JavaScript
|
|
var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t),e=null),t.exports),s=(e,n)=>{let r={};for(var i in e)t(r,i,{get:e[i],enumerable:!0});return n||t(r,Symbol.toStringTag,{value:`Module`}),r},c=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},l=(n,r,a)=>(a=n==null?{}:e(i(n)),c(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,n));(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),e.crossOrigin===`use-credentials`?t.credentials=`include`:e.crossOrigin===`anonymous`?t.credentials=`omit`:t.credentials=`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var u=o((e=>{var t=Symbol.for(`react.transitional.element`),n=Symbol.for(`react.portal`),r=Symbol.for(`react.fragment`),i=Symbol.for(`react.strict_mode`),a=Symbol.for(`react.profiler`),o=Symbol.for(`react.consumer`),s=Symbol.for(`react.context`),c=Symbol.for(`react.forward_ref`),l=Symbol.for(`react.suspense`),u=Symbol.for(`react.memo`),d=Symbol.for(`react.lazy`),f=Symbol.for(`react.activity`),p=Symbol.iterator;function m(e){return typeof e!=`object`||!e?null:(e=p&&e[p]||e[`@@iterator`],typeof e==`function`?e:null)}var h={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},g=Object.assign,_={};function v(e,t,n){this.props=e,this.context=t,this.refs=_,this.updater=n||h}v.prototype.isReactComponent={},v.prototype.setState=function(e,t){if(typeof e!=`object`&&typeof e!=`function`&&e!=null)throw Error(`takes an object of state variables to update or a function which returns an object of state variables.`);this.updater.enqueueSetState(this,e,t,`setState`)},v.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,`forceUpdate`)};function y(){}y.prototype=v.prototype;function b(e,t,n){this.props=e,this.context=t,this.refs=_,this.updater=n||h}var x=b.prototype=new y;x.constructor=b,g(x,v.prototype),x.isPureReactComponent=!0;var S=Array.isArray;function C(){}var w={H:null,A:null,T:null,S:null},T=Object.prototype.hasOwnProperty;function E(e,n,r){var i=r.ref;return{$$typeof:t,type:e,key:n,ref:i===void 0?null:i,props:r}}function D(e,t){return E(e.type,t,e.props)}function O(e){return typeof e==`object`&&!!e&&e.$$typeof===t}function k(e){var t={"=":`=0`,":":`=2`};return`$`+e.replace(/[=:]/g,function(e){return t[e]})}var A=/\/+/g;function j(e,t){return typeof e==`object`&&e&&e.key!=null?k(``+e.key):t.toString(36)}function M(e){switch(e.status){case`fulfilled`:return e.value;case`rejected`:throw e.reason;default:switch(typeof e.status==`string`?e.then(C,C):(e.status=`pending`,e.then(function(t){e.status===`pending`&&(e.status=`fulfilled`,e.value=t)},function(t){e.status===`pending`&&(e.status=`rejected`,e.reason=t)})),e.status){case`fulfilled`:return e.value;case`rejected`:throw e.reason}}throw e}function N(e,r,i,a,o){var s=typeof e;(s===`undefined`||s===`boolean`)&&(e=null);var c=!1;if(e===null)c=!0;else switch(s){case`bigint`:case`string`:case`number`:c=!0;break;case`object`:switch(e.$$typeof){case t:case n:c=!0;break;case d:return c=e._init,N(c(e._payload),r,i,a,o)}}if(c)return o=o(e),c=a===``?`.`+j(e,0):a,S(o)?(i=``,c!=null&&(i=c.replace(A,`$&/`)+`/`),N(o,r,i,``,function(e){return e})):o!=null&&(O(o)&&(o=D(o,i+(o.key==null||e&&e.key===o.key?``:(``+o.key).replace(A,`$&/`)+`/`)+c)),r.push(o)),1;c=0;var l=a==
|
||
|
|
at`)?` (<anonymous>)`:-1<e.stack.indexOf(`@`)?`@unknown:0:0`:``}return`
|
||
|
|
`+he+e+ge}var ve=!1;function ye(e,t){if(!e||ve)return``;ve=!0;var n=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var r={DetermineComponentFrameRoot:function(){try{if(t){var n=function(){throw Error()};if(Object.defineProperty(n.prototype,"props",{set:function(){throw Error()}}),typeof Reflect==`object`&&Reflect.construct){try{Reflect.construct(n,[])}catch(e){var r=e}Reflect.construct(e,[],n)}else{try{n.call()}catch(e){r=e}e.call(n.prototype)}}else{try{throw Error()}catch(e){r=e}(n=e())&&typeof n.catch==`function`&&n.catch(function(){})}}catch(e){if(e&&r&&typeof e.stack==`string`)return[e.stack,r.stack]}return[null,null]}};r.DetermineComponentFrameRoot.displayName=`DetermineComponentFrameRoot`;var i=Object.getOwnPropertyDescriptor(r.DetermineComponentFrameRoot,`name`);i&&i.configurable&&Object.defineProperty(r.DetermineComponentFrameRoot,"name",{value:`DetermineComponentFrameRoot`});var a=r.DetermineComponentFrameRoot(),o=a[0],s=a[1];if(o&&s){var c=o.split(`
|
||
|
|
`),l=s.split(`
|
||
|
|
`);for(i=r=0;r<c.length&&!c[r].includes(`DetermineComponentFrameRoot`);)r++;for(;i<l.length&&!l[i].includes(`DetermineComponentFrameRoot`);)i++;if(r===c.length||i===l.length)for(r=c.length-1,i=l.length-1;1<=r&&0<=i&&c[r]!==l[i];)i--;for(;1<=r&&0<=i;r--,i--)if(c[r]!==l[i]){if(r!==1||i!==1)do if(r--,i--,0>i||c[r]!==l[i]){var u=`
|
||
|
|
`+c[r].replace(` at new `,` at `);return e.displayName&&u.includes(`<anonymous>`)&&(u=u.replace(`<anonymous>`,e.displayName)),u}while(1<=r&&0<=i);break}}}finally{ve=!1,Error.prepareStackTrace=n}return(n=e?e.displayName||e.name:``)?_e(n):``}function be(e,t){switch(e.tag){case 26:case 27:case 5:return _e(e.type);case 16:return _e(`Lazy`);case 13:return e.child!==t&&t!==null?_e(`Suspense Fallback`):_e(`Suspense`);case 19:return _e(`SuspenseList`);case 0:case 15:return ye(e.type,!1);case 11:return ye(e.type.render,!1);case 1:return ye(e.type,!0);case 31:return _e(`Activity`);default:return``}}function xe(e){try{var t=``,n=null;do t+=be(e,n),n=e,e=e.return;while(e);return t}catch(e){return`
|
||
|
|
Error generating stack: `+e.message+`
|
||
|
|
`+e.stack}}var Se=Object.prototype.hasOwnProperty,Ce=t.unstable_scheduleCallback,we=t.unstable_cancelCallback,Te=t.unstable_shouldYield,Ee=t.unstable_requestPaint,De=t.unstable_now,Oe=t.unstable_getCurrentPriorityLevel,ke=t.unstable_ImmediatePriority,Ae=t.unstable_UserBlockingPriority,je=t.unstable_NormalPriority,Me=t.unstable_LowPriority,Ne=t.unstable_IdlePriority,Pe=t.log,Fe=t.unstable_setDisableYieldValue,Ie=null,Le=null;function Re(e){if(typeof Pe==`function`&&Fe(e),Le&&typeof Le.setStrictMode==`function`)try{Le.setStrictMode(Ie,e)}catch{}}var ze=Math.clz32?Math.clz32:He,Be=Math.log,Ve=Math.LN2;function He(e){return e>>>=0,e===0?32:31-(Be(e)/Ve|0)|0}var Ue=256,We=262144,Ge=4194304;function Ke(e){var t=e&42;if(t!==0)return t;switch(e&-e){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:return e&261888;case 262144:case 524288:case 1048576:case 2097152:return e&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return e&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return e}}function qe(e,t,n){var r=e.pendingLanes;if(r===0)return 0;var i=0,a=e.suspendedLanes,o=e.pingedLanes;e=e.warmLanes;var s=r&134217727;return s===0?(s=r&~a,s===0?o===0?n||(n=r&~e,n!==0&&(i=Ke(n))):i=Ke(o):i=Ke(s)):(r=s&~a,r===0?(o&=s,o===0?n||(n=s&~e,n!==0&&(i=Ke(n))):i=Ke(o)):i=Ke(r)),i===0?0:t!==0&&t!==i&&(t&a)===0&&(a=i&-i,n=t&-t,a>=n||a===32&&n&4194048)?t:i}function Je(e,t){return(e.pendingLanes&~(e.suspendedLanes&~e.pingedLanes)&t)===0}function Ye(e,t){switch(e){case 1:case 2:case 4:case 8:case 64:return t+250;case 16:case 32:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return t+5e3;case 4194304:case 8388608:case 16777216:case 33554432:return-1;case 67108864:case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function Xe(){var e=Ge;return Ge<<=1,!(Ge&62914560)&&(Ge=4194304),e}function Ze(e){for(var t=[],n=0;31>n;n++)t.push(e);return t}function Qe(e,t){e.pendingLanes|=t,t!==268435456&&(e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0)}function $e(e,t,n,r,i,a){var o=e.pendingLanes;e.pendingLanes=n,e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0,e.expiredLanes&=n,e.entangledLanes&=n,e.errorRecoveryDisabledLanes&=n,e.shellSuspendCounter=0;var s=e.entanglements,c=e.expirationTimes,l=e.hiddenUpdates;for(n=o&~n;0<n;){var u=31-ze(n),d=1<<u;s[u]=0,c[u]=-1;var f=l[u];if(f!==null)for(l[u]=null,u=0;u<f.length;u++){var p=f[u];p!==null&&(p.lane&=-536870913)}n&=~d}r!==0&&et(e,r,0),a!==0&&i===0&&e.tag!==0&&(e.suspendedLanes|=a&~(o&~t))}function et(e,t,n){e.pendingLanes|=t,e.suspendedLanes&=~t;var r=31-ze(t);e.entangledLanes|=t,e.entanglements[r]=e.entanglements[r]|1073741824|n&261930}function tt(e,t){var n=e.entangledLanes|=t;for(e=e.entanglements;n;){var r=31-ze(n),i=1<<r;i&t|e[r]&t&&(e[r]|=t),n&=~i}}function nt(e,t){var n=t&-t;return n=n&42?1:rt(n),(n&(e.suspendedLanes|t))===0?n:0}function rt(e){switch(e){case 2:e=1;break;case 8:e=4;break;case 32:e=16;break;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:case 4194304:case 8388608:case 16777216:case 33554432:e=128;break;case 268435456:e=134217728;break;default:e=0}return e}function it(e){return e&=-e,2<e?8<e?e&134217727?32:268435456:8:2}function at(){var e=F.p;return e===0?(e=window.event,e===void 0?32:mp(e.type)):e}function ot(e,t){var n=F.p;try{return F.p=e,t()}finally{F.p=n}}var st=Math.random().toString(36).slice(2),ct=`__reactFiber$`+st,lt=`__reactProps$`+st,ut=`__reactContainer$`+st,dt=`__reactEvents$`+st,ft=`__reactListeners$`+st,pt=`__reactHandles$`+st,mt=`__reactResources$`+st,ht=`__reactMarker$`+st;function gt(e){delete e[ct],d
|
||
|
|
`).replace(Ad,``)}function Md(e,t){return t=jd(t),jd(e)===t}function $(e,t,n,r,a,o){switch(n){case`children`:typeof r==`string`?t===`body`||t===`textarea`&&r===``||qt(e,r):(typeof r==`number`||typeof r==`bigint`)&&t!==`body`&&qt(e,``+r);break;case`className`:jt(e,`class`,r);break;case`tabIndex`:jt(e,`tabindex`,r);break;case`dir`:case`role`:case`viewBox`:case`width`:case`height`:jt(e,n,r);break;case`style`:Xt(e,r,o);break;case`data`:if(t!==`object`){jt(e,`data`,r);break}case`src`:case`href`:if(r===``&&(t!==`a`||n!==`href`)){e.removeAttribute(n);break}if(r==null||typeof r==`function`||typeof r==`symbol`||typeof r==`boolean`){e.removeAttribute(n);break}r=en(``+r),e.setAttribute(n,r);break;case`action`:case`formAction`:if(typeof r==`function`){e.setAttribute(n,`javascript:throw new Error('A React form was unexpectedly submitted. If you called form.submit() manually, consider using form.requestSubmit() instead. If you\\'re trying to use event.stopPropagation() in a submit event handler, consider also calling event.preventDefault().')`);break}else typeof o==`function`&&(n===`formAction`?(t!==`input`&&$(e,t,`name`,a.name,a,null),$(e,t,`formEncType`,a.formEncType,a,null),$(e,t,`formMethod`,a.formMethod,a,null),$(e,t,`formTarget`,a.formTarget,a,null)):($(e,t,`encType`,a.encType,a,null),$(e,t,`method`,a.method,a,null),$(e,t,`target`,a.target,a,null)));if(r==null||typeof r==`symbol`||typeof r==`boolean`){e.removeAttribute(n);break}r=en(``+r),e.setAttribute(n,r);break;case`onClick`:r!=null&&(e.onclick=tn);break;case`onScroll`:r!=null&&Q(`scroll`,e);break;case`onScrollEnd`:r!=null&&Q(`scrollend`,e);break;case`dangerouslySetInnerHTML`:if(r!=null){if(typeof r!=`object`||!(`__html`in r))throw Error(i(61));if(n=r.__html,n!=null){if(a.children!=null)throw Error(i(60));e.innerHTML=n}}break;case`multiple`:e.multiple=r&&typeof r!=`function`&&typeof r!=`symbol`;break;case`muted`:e.muted=r&&typeof r!=`function`&&typeof r!=`symbol`;break;case`suppressContentEditableWarning`:case`suppressHydrationWarning`:case`defaultValue`:case`defaultChecked`:case`innerHTML`:case`ref`:break;case`autoFocus`:break;case`xlinkHref`:if(r==null||typeof r==`function`||typeof r==`boolean`||typeof r==`symbol`){e.removeAttribute(`xlink:href`);break}n=en(``+r),e.setAttributeNS(`http://www.w3.org/1999/xlink`,`xlink:href`,n);break;case`contentEditable`:case`spellCheck`:case`draggable`:case`value`:case`autoReverse`:case`externalResourcesRequired`:case`focusable`:case`preserveAlpha`:r!=null&&typeof r!=`function`&&typeof r!=`symbol`?e.setAttribute(n,``+r):e.removeAttribute(n);break;case`inert`:case`allowFullScreen`:case`async`:case`autoPlay`:case`controls`:case`default`:case`defer`:case`disabled`:case`disablePictureInPicture`:case`disableRemotePlayback`:case`formNoValidate`:case`hidden`:case`loop`:case`noModule`:case`noValidate`:case`open`:case`playsInline`:case`readOnly`:case`required`:case`reversed`:case`scoped`:case`seamless`:case`itemScope`:r&&typeof r!=`function`&&typeof r!=`symbol`?e.setAttribute(n,``):e.removeAttribute(n);break;case`capture`:case`download`:!0===r?e.setAttribute(n,``):!1!==r&&r!=null&&typeof r!=`function`&&typeof r!=`symbol`?e.setAttribute(n,r):e.removeAttribute(n);break;case`cols`:case`rows`:case`size`:case`span`:r!=null&&typeof r!=`function`&&typeof r!=`symbol`&&!isNaN(r)&&1<=r?e.setAttribute(n,r):e.removeAttribute(n);break;case`rowSpan`:case`start`:r==null||typeof r==`function`||typeof r==`symbol`||isNaN(r)?e.removeAttribute(n):e.setAttribute(n,r);break;case`popover`:Q(`beforetoggle`,e),Q(`toggle`,e),At(e,`popover`,r);break;case`xlinkActuate`:Mt(e,`http://www.w3.org/1999/xlink`,`xlink:actuate`,r);break;case`xlinkArcrole`:Mt(e,`http://www.w3.org/1999/xlink`,`xlink:arcrole`,r);break;case`xlinkRole`:Mt(e,`http://www.w3.org/1999/xlink`,`xlink:role`,r);break;case`xlinkShow`:Mt(e,`http://www.w3.org/1999/xlink`,`xlink:show`,r);break;case`xlinkTitle`:Mt(e,`http://www.w3.org/1999/xlink`,`xlink:title`,r);break;case`xlinkType`:Mt(e,`http://www.w3.org/1999/xlink`,`xlink:type`,r);break;case`xmlBase`:Mt(e,`http://www.w3.org/XML/1998/namespace`,`xml:base`,r);break
|
||
|
|
|
||
|
|
Please change the parent <Route path="${e}"> to <Route path="${e===`/`?`*`:`${e}/*`}">.`)}let u=it(),d;if(t){let e=typeof t==`string`?N(t):t;D(c===`/`||e.pathname?.startsWith(c),`When overriding the location using \`<Routes location>\` or \`useRoutes(routes, location)\`, the location pathname must begin with the portion of the URL pathname that was matched by all parent routes. The current pathname base is "${c}" but pathname "${e.pathname}" was given in the \`location\` prop.`),d=e}else d=u;let f=d.pathname||`/`,p=f;if(c!==`/`){let e=c.replace(/^\//,``).split(`/`);p=`/`+f.replace(/^\//,``).split(`/`).slice(e.length).join(`/`)}let m=n&&n.state.matches.length?n.state.matches.map(e=>Object.assign(e,{route:n.manifest[e.route.id]||e.route})):P(e,{pathname:p});O(l||m!=null,`No routes matched location "${d.pathname}${d.search}${d.hash}" `),O(m==null||m[m.length-1].route.element!==void 0||m[m.length-1].route.Component!==void 0||m[m.length-1].route.lazy!==void 0,`Matched leaf route at location "${d.pathname}${d.search}${d.hash}" does not have an element or Component. This means it will render an <Outlet /> with a null value by default resulting in an "empty" page.`);let h=yt(m&&m.map(e=>Object.assign({},e,{params:Object.assign({},o,e.params),pathname:Oe([c,r.encodeLocation?r.encodeLocation(e.pathname.replace(/%/g,`%25`).replace(/\?/g,`%3F`).replace(/#/g,`%23`)).pathname:e.pathname]),pathnameBase:e.pathnameBase===`/`?c:Oe([c,r.encodeLocation?r.encodeLocation(e.pathnameBase.replace(/%/g,`%25`).replace(/\?/g,`%3F`).replace(/#/g,`%23`)).pathname:e.pathnameBase])})),i,n);return t&&h?v.createElement(Je.Provider,{value:{location:{pathname:`/`,search:``,hash:``,state:null,key:`default`,mask:void 0,...d},navigationType:`POP`}},h):h}function pt(){let e=Ot(),t=Pe(e)?`${e.status} ${e.statusText}`:e instanceof Error?e.message:JSON.stringify(e),n=e instanceof Error?e.stack:null,r=`rgba(200,200,200, 0.5)`,i={padding:`0.5rem`,backgroundColor:r},a={padding:`2px 4px`,backgroundColor:r},o=null;return console.error(`Error handled by React Router default ErrorBoundary:`,e),o=v.createElement(v.Fragment,null,v.createElement(`p`,null,`💿 Hey developer 👋`),v.createElement(`p`,null,`You can provide a way better UX than this when your app throws errors by providing your own `,v.createElement(`code`,{style:a},`ErrorBoundary`),` or`,` `,v.createElement(`code`,{style:a},`errorElement`),` prop on your route.`)),v.createElement(v.Fragment,null,v.createElement(`h2`,null,`Unexpected Application Error!`),v.createElement(`h3`,{style:{fontStyle:`italic`}},t),n?v.createElement(`pre`,{style:i},n):null,o)}var mt=v.createElement(pt,null),ht=class extends v.Component{constructor(e){super(e),this.state={location:e.location,revalidation:e.revalidation,error:e.error}}static getDerivedStateFromError(e){return{error:e}}static getDerivedStateFromProps(e,t){return t.location!==e.location||t.revalidation!==`idle`&&e.revalidation===`idle`?{error:e.error,location:e.location,revalidation:e.revalidation}:{error:e.error===void 0?t.error:e.error,location:t.location,revalidation:e.revalidation||t.revalidation}}componentDidCatch(e,t){this.props.onError?this.props.onError(e,t):console.error(`React Router caught the following error during render`,e)}render(){let e=this.state.error;if(this.context&&typeof e==`object`&&e&&`digest`in e&&typeof e.digest==`string`){let t=tt(e.digest);t&&(e=t)}let t=e===void 0?this.props.children:v.createElement(Ye.Provider,{value:this.props.routeContext},v.createElement(Xe.Provider,{value:e,children:this.props.component}));return this.context?v.createElement(_t,{error:e},t):t}};ht.contextType=He;var gt=new WeakMap;function _t({children:e,error:t}){let{basename:n}=v.useContext(qe);if(typeof t==`object`&&t&&`digest`in t&&typeof t.digest==`string`){let e=et(t.digest);if(e){let r=gt.get(t);if(r)throw r;let i=Le(e.location,n);if(Ie&&!gt.get(t))if(i.isExternal||e.reloadDocument)window.location.href=i.absoluteURL||i.to;else{let n=Promise.resolve().then(()=>window.__reactRouterDataRouter.navigate(i.to,{replace:e.replace}));throw gt.set(t,n),n}return v.createEle
|
||
|
|
`).forEach(function(e){i=e.indexOf(`:`),n=e.substring(0,i).trim().toLowerCase(),r=e.substring(i+1).trim(),!(!n||t[n]&&ni[n])&&(n===`set-cookie`?t[n]?t[n].push(r):t[n]=[r]:t[n]=t[n]?t[n]+`, `+r:r)}),t};function ii(e){let t=0,n=e.length;for(;t<n;){let n=e.charCodeAt(t);if(n!==9&&n!==32)break;t+=1}for(;n>t;){let t=e.charCodeAt(n-1);if(t!==9&&t!==32)break;--n}return t===0&&n===e.length?e:e.slice(t,n)}var ai=RegExp(`[\\u0000-\\u0008\\u000a-\\u001f\\u007f]+`,`g`),oi=RegExp(`[^\\u0009\\u0020-\\u007e\\u0080-\\u00ff]+`,`g`);function si(e,t){return L.isArray(e)?e.map(e=>si(e,t)):ii(String(e).replace(t,``))}var ci=e=>si(e,ai),li=e=>si(e,oi);function ui(e){let t=Object.create(null);return L.forEach(e.toJSON(),(e,n)=>{t[n]=li(e)}),t}var di=Symbol(`internals`);function fi(e){return e&&String(e).trim().toLowerCase()}function pi(e){return e===!1||e==null?e:L.isArray(e)?e.map(pi):ci(String(e))}function mi(e){let t=Object.create(null),n=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g,r;for(;r=n.exec(e);)t[r[1]]=r[2];return t}var hi=e=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(e.trim());function gi(e,t,n,r,i){if(L.isFunction(r))return r.call(this,t,n);if(i&&(t=n),L.isString(t)){if(L.isString(r))return t.indexOf(r)!==-1;if(L.isRegExp(r))return r.test(t)}}function _i(e){return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(e,t,n)=>t.toUpperCase()+n)}function vi(e,t){let n=L.toCamelCase(` `+t);[`get`,`set`,`has`].forEach(r=>{Object.defineProperty(e,r+n,{__proto__:null,value:function(e,n,i){return this[r].call(this,t,e,n,i)},configurable:!0})})}var R=class{constructor(e){e&&this.set(e)}set(e,t,n){let r=this;function i(e,t,n){let i=fi(t);if(!i)throw Error(`header name must be a non-empty string`);let a=L.findKey(r,i);(!a||r[a]===void 0||n===!0||n===void 0&&r[a]!==!1)&&(r[a||t]=pi(e))}let a=(e,t)=>L.forEach(e,(e,n)=>i(e,n,t));if(L.isPlainObject(e)||e instanceof this.constructor)a(e,t);else if(L.isString(e)&&(e=e.trim())&&!hi(e))a(ri(e),t);else if(L.isObject(e)&&L.isIterable(e)){let n={},r,i;for(let t of e){if(!L.isArray(t))throw TypeError(`Object iterator must return a key-value pair`);n[i=t[0]]=(r=n[i])?L.isArray(r)?[...r,t[1]]:[r,t[1]]:t[1]}a(n,t)}else e!=null&&i(t,e,n);return this}get(e,t){if(e=fi(e),e){let n=L.findKey(this,e);if(n){let e=this[n];if(!t)return e;if(t===!0)return mi(e);if(L.isFunction(t))return t.call(this,e,n);if(L.isRegExp(t))return t.exec(e);throw TypeError(`parser must be boolean|regexp|function`)}}}has(e,t){if(e=fi(e),e){let n=L.findKey(this,e);return!!(n&&this[n]!==void 0&&(!t||gi(this,this[n],n,t)))}return!1}delete(e,t){let n=this,r=!1;function i(e){if(e=fi(e),e){let i=L.findKey(n,e);i&&(!t||gi(n,n[i],i,t))&&(delete n[i],r=!0)}}return L.isArray(e)?e.forEach(i):i(e),r}clear(e){let t=Object.keys(this),n=t.length,r=!1;for(;n--;){let i=t[n];(!e||gi(this,this[i],i,e,!0))&&(delete this[i],r=!0)}return r}normalize(e){let t=this,n={};return L.forEach(this,(r,i)=>{let a=L.findKey(n,i);if(a){t[a]=pi(r),delete t[i];return}let o=e?_i(i):String(i).trim();o!==i&&delete t[i],t[o]=pi(r),n[o]=!0}),this}concat(...e){return this.constructor.concat(this,...e)}toJSON(e){let t=Object.create(null);return L.forEach(this,(n,r)=>{n!=null&&n!==!1&&(t[r]=e&&L.isArray(n)?n.join(`, `):n)}),t}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([e,t])=>e+`: `+t).join(`
|
||
|
|
`)}getSetCookie(){return this.get(`set-cookie`)||[]}get[Symbol.toStringTag](){return`AxiosHeaders`}static from(e){return e instanceof this?e:new this(e)}static concat(e,...t){let n=new this(e);return t.forEach(e=>n.set(e)),n}static accessor(e){let t=(this[di]=this[di]={accessors:{}}).accessors,n=this.prototype;function r(e){let r=fi(e);t[r]||(vi(n,e),t[r]=!0)}return L.isArray(e)?e.forEach(r):r(e),this}};R.accessor([`Content-Type`,`Content-Length`,`Accept`,`Accept-Encoding`,`User-Agent`,`Authorization`]),L.reduceDescriptors(R.prototype,({value:e},t)=>{let n=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(e){this[n]=e}}}),L.freezeMethods(R);var yi=`[REDACTED ****]`;function bi(e){if(L.hasOwnProp(e,`toJSON`))return!0;let t=Object.getPrototypeOf(e);for(;t&&t!==Object.prototype;){if(L.hasOwnProp(t,`toJSON`))return!0;t=Object.getPrototypeOf(t)}return!1}function xi(e,t){let n=new Set(t.map(e=>String(e).toLowerCase())),r=[],i=e=>{if(typeof e!=`object`||!e||L.isBuffer(e))return e;if(r.indexOf(e)!==-1)return;e instanceof R&&(e=e.toJSON()),r.push(e);let t;if(L.isArray(e))t=[],e.forEach((e,n)=>{let r=i(e);L.isUndefined(r)||(t[n]=r)});else{if(!L.isPlainObject(e)&&bi(e))return r.pop(),e;t=Object.create(null);for(let[r,a]of Object.entries(e)){let e=n.has(r.toLowerCase())?yi:i(a);L.isUndefined(e)||(t[r]=e)}}return r.pop(),t};return i(e)}var z=class e extends Error{static from(t,n,r,i,a,o){let s=new e(t.message,n||t.code,r,i,a);return s.cause=t,s.name=t.name,t.status!=null&&s.status==null&&(s.status=t.status),o&&Object.assign(s,o),s}constructor(e,t,n,r,i){super(e),Object.defineProperty(this,"message",{__proto__:null,value:e,enumerable:!0,writable:!0,configurable:!0}),this.name=`AxiosError`,this.isAxiosError=!0,t&&(this.code=t),n&&(this.config=n),r&&(this.request=r),i&&(this.response=i,this.status=i.status)}toJSON(){let e=this.config,t=e&&L.hasOwnProp(e,`redact`)?e.redact:void 0,n=L.isArray(t)&&t.length>0?xi(e,t):L.toJSONObject(e);return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:n,code:this.code,status:this.status}}};z.ERR_BAD_OPTION_VALUE=`ERR_BAD_OPTION_VALUE`,z.ERR_BAD_OPTION=`ERR_BAD_OPTION`,z.ECONNABORTED=`ECONNABORTED`,z.ETIMEDOUT=`ETIMEDOUT`,z.ECONNREFUSED=`ECONNREFUSED`,z.ERR_NETWORK=`ERR_NETWORK`,z.ERR_FR_TOO_MANY_REDIRECTS=`ERR_FR_TOO_MANY_REDIRECTS`,z.ERR_DEPRECATED=`ERR_DEPRECATED`,z.ERR_BAD_RESPONSE=`ERR_BAD_RESPONSE`,z.ERR_BAD_REQUEST=`ERR_BAD_REQUEST`,z.ERR_CANCELED=`ERR_CANCELED`,z.ERR_NOT_SUPPORT=`ERR_NOT_SUPPORT`,z.ERR_INVALID_URL=`ERR_INVALID_URL`,z.ERR_FORM_DATA_DEPTH_EXCEEDED=`ERR_FORM_DATA_DEPTH_EXCEEDED`;function Si(e){return L.isPlainObject(e)||L.isArray(e)}function Ci(e){return L.endsWith(e,`[]`)?e.slice(0,-2):e}function wi(e,t,n){return e?e.concat(t).map(function(e,t){return e=Ci(e),!n&&t?`[`+e+`]`:e}).join(n?`.`:``):t}function Ti(e){return L.isArray(e)&&!e.some(Si)}var Ei=L.toFlatObject(L,{},null,function(e){return/^is[A-Z]/.test(e)});function Di(e,t,n){if(!L.isObject(e))throw TypeError(`target must be an object`);t||=new FormData,n=L.toFlatObject(n,{metaTokens:!0,dots:!1,indexes:!1},!1,function(e,t){return!L.isUndefined(t[e])});let r=n.metaTokens,i=n.visitor||d,a=n.dots,o=n.indexes,s=n.Blob||typeof Blob<`u`&&Blob,c=n.maxDepth===void 0?100:n.maxDepth,l=s&&L.isSpecCompliantForm(t);if(!L.isFunction(i))throw TypeError(`visitor must be a function`);function u(e){if(e===null)return``;if(L.isDate(e))return e.toISOString();if(L.isBoolean(e))return e.toString();if(!l&&L.isBlob(e))throw new z(`Blob is not supported. Use a Buffer instead.`);return L.isArrayBuffer(e)||L.isTypedArray(e)?l&&typeof Blob==`function`?new Blob([e]):Buffer.from(e):e}function d(e,n,i){let s=e;if(L.isReactNative(t)&&L.isReactNativeBlob(e))return t.append(wi(i,n,a),u(e)),!1;if(e&&!i&&typeof e==`object`){if(L.endsWith(n,`{}`))n=r?n:n.slice(0,-2),e=JSON.stringify(e);else if(L.isArray(e)&&Ti(e)||(L.isFileList(e)||L.endsWith(n,`[]`))&&(s=L.toArray(e)))return n=Ci(n),s.forEach(function(e,r){!(L.isUndefined
|
||
|
|
`+e.map(Aa).join(`
|
||
|
|
`):` `+Aa(e[0]):`as no adapter specified`),`ERR_NOT_SUPPORT`)}return i}var Na={getAdapter:Ma,adapters:ka};function Pa(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new Xi(null,e)}function Fa(e){return Pa(e),e.headers=R.from(e.headers),e.data=Ji.call(e,e.transformRequest),[`post`,`put`,`patch`].indexOf(e.method)!==-1&&e.headers.setContentType(`application/x-www-form-urlencoded`,!1),Na.getAdapter(e.adapter||qi.adapter,e)(e).then(function(t){Pa(e),e.response=t;try{t.data=Ji.call(e,e.transformResponse,t)}finally{delete e.response}return t.headers=R.from(t.headers),t},function(t){if(!Yi(t)&&(Pa(e),t&&t.response)){e.response=t.response;try{t.response.data=Ji.call(e,e.transformResponse,t.response)}finally{delete e.response}t.response.headers=R.from(t.response.headers)}return Promise.reject(t)})}var Ia={};[`object`,`boolean`,`number`,`function`,`string`,`symbol`].forEach((e,t)=>{Ia[e]=function(n){return typeof n===e||`a`+(t<1?`n `:` `)+e}});var La={};Ia.transitional=function(e,t,n){function r(e,t){return`[Axios v`+Sa+`] Transitional option '`+e+`'`+t+(n?`. `+n:``)}return(n,i,a)=>{if(e===!1)throw new z(r(i,` has been removed`+(t?` in `+t:``)),z.ERR_DEPRECATED);return t&&!La[i]&&(La[i]=!0,console.warn(r(i,` has been deprecated since v`+t+` and will be removed in the near future`))),e?e(n,i,a):!0}},Ia.spelling=function(e){return(t,n)=>(console.warn(`${n} is likely a misspelling of ${e}`),!0)};function Ra(e,t,n){if(typeof e!=`object`)throw new z(`options must be an object`,z.ERR_BAD_OPTION_VALUE);let r=Object.keys(e),i=r.length;for(;i-- >0;){let a=r[i],o=Object.prototype.hasOwnProperty.call(t,a)?t[a]:void 0;if(o){let t=e[a],n=t===void 0||o(t,a,e);if(n!==!0)throw new z(`option `+a+` must be `+n,z.ERR_BAD_OPTION_VALUE);continue}if(n!==!0)throw new z(`Unknown option `+a,z.ERR_BAD_OPTION)}}var za={assertOptions:Ra,validators:Ia},Ba=za.validators,Va=class{constructor(e){this.defaults=e||{},this.interceptors={request:new B,response:new B}}async request(e,t){try{return await this._request(e,t)}catch(e){if(e instanceof Error){let t={};Error.captureStackTrace?Error.captureStackTrace(t):t=Error();let n=(()=>{if(!t.stack)return``;let e=t.stack.indexOf(`
|
||
|
|
`);return e===-1?``:t.stack.slice(e+1)})();try{if(!e.stack)e.stack=n;else if(n){let t=n.indexOf(`
|
||
|
|
`),r=t===-1?-1:n.indexOf(`
|
||
|
|
`,t+1),i=r===-1?``:n.slice(r+1);String(e.stack).endsWith(i)||(e.stack+=`
|
||
|
|
`+n)}}catch{}}throw e}}_request(e,t){typeof e==`string`?(t||={},t.url=e):t=e||{},t=ua(this.defaults,t);let{transitional:n,paramsSerializer:r,headers:i}=t;n!==void 0&&za.assertOptions(n,{silentJSONParsing:Ba.transitional(Ba.boolean),forcedJSONParsing:Ba.transitional(Ba.boolean),clarifyTimeoutError:Ba.transitional(Ba.boolean),legacyInterceptorReqResOrdering:Ba.transitional(Ba.boolean)},!1),r!=null&&(L.isFunction(r)?t.paramsSerializer={serialize:r}:za.assertOptions(r,{encode:Ba.function,serialize:Ba.function},!0)),t.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls===void 0?t.allowAbsoluteUrls=!0:t.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls),za.assertOptions(t,{baseUrl:Ba.spelling(`baseURL`),withXsrfToken:Ba.spelling(`withXSRFToken`)},!0),t.method=(t.method||this.defaults.method||`get`).toLowerCase();let a=i&&L.merge(i.common,i[t.method]);i&&L.forEach([`delete`,`get`,`head`,`post`,`put`,`patch`,`query`,`common`],e=>{delete i[e]}),t.headers=R.concat(a,i);let o=[],s=!0;this.interceptors.request.forEach(function(e){if(typeof e.runWhen==`function`&&e.runWhen(t)===!1)return;s&&=e.synchronous;let n=t.transitional||V;n&&n.legacyInterceptorReqResOrdering?o.unshift(e.fulfilled,e.rejected):o.push(e.fulfilled,e.rejected)});let c=[];this.interceptors.response.forEach(function(e){c.push(e.fulfilled,e.rejected)});let l,u=0,d;if(!s){let e=[Fa.bind(this),void 0];for(e.unshift(...o),e.push(...c),d=e.length,l=Promise.resolve(t);u<d;)l=l.then(e[u++],e[u++]);return l}d=o.length;let f=t;for(;u<d;){let e=o[u++],t=o[u++];try{f=e(f)}catch(e){t.call(this,e);break}}try{l=Fa.call(this,f)}catch(e){return Promise.reject(e)}for(u=0,d=c.length;u<d;)l=l.then(c[u++],c[u++]);return l}getUri(e){return e=ua(this.defaults,e),Mi(ca(e.baseURL,e.url,e.allowAbsoluteUrls),e.params,e.paramsSerializer)}};L.forEach([`delete`,`get`,`head`,`options`],function(e){Va.prototype[e]=function(t,n){return this.request(ua(n||{},{method:e,url:t,data:(n||{}).data}))}}),L.forEach([`post`,`put`,`patch`,`query`],function(e){function t(t){return function(n,r,i){return this.request(ua(i||{},{method:e,headers:t?{"Content-Type":`multipart/form-data`}:{},url:n,data:r}))}}Va.prototype[e]=t(),e!==`query`&&(Va.prototype[e+`Form`]=t(!0))});var Ha=class e{constructor(e){if(typeof e!=`function`)throw TypeError(`executor must be a function.`);let t;this.promise=new Promise(function(e){t=e});let n=this;this.promise.then(e=>{if(!n._listeners)return;let t=n._listeners.length;for(;t-- >0;)n._listeners[t](e);n._listeners=null}),this.promise.then=e=>{let t,r=new Promise(e=>{n.subscribe(e),t=e}).then(e);return r.cancel=function(){n.unsubscribe(t)},r},e(function(e,r,i){n.reason||(n.reason=new Xi(e,r,i),t(n.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(e){if(this.reason){e(this.reason);return}this._listeners?this._listeners.push(e):this._listeners=[e]}unsubscribe(e){if(!this._listeners)return;let t=this._listeners.indexOf(e);t!==-1&&this._listeners.splice(t,1)}toAbortSignal(){let e=new AbortController,t=t=>{e.abort(t)};return this.subscribe(t),e.signal.unsubscribe=()=>this.unsubscribe(t),e.signal}static source(){let t;return{token:new e(function(e){t=e}),cancel:t}}};function Ua(e){return function(t){return e.apply(null,t)}}function Wa(e){return L.isObject(e)&&e.isAxiosError===!0}var Ga={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,
|
||
|
|
`),i=-1,a={},o=[],s=0;s<r.length;s++){if(!e[s]){i+=r[s].length;continue}for(var c=0;c<r[s].length;c++){i++;var l=e[s][c];l&&Object.keys(l).length>0&&(t.util.hasStyleChanged(a,l,!0)?o.push({start:i,end:i+1,style:l}):o[o.length-1].end++),a=l||{}}}return o},stylesFromArray:function(e,t){if(!Array.isArray(e))return e;for(var n=t.split(`
|
||
|
|
`),r=-1,i=0,a={},o=0;o<n.length;o++)for(var s=0;s<n[o].length;s++)r++,e[i]&&e[i].start<=r&&r<e[i].end&&(a[o]=a[o]||{},a[o][s]=Object.assign({},e[i].style),r===e[i].end-1&&i++);return a}}})(e),(function(){var e=Array.prototype.join,n={m:2,l:2,h:1,v:1,c:6,s:4,q:4,t:2,a:7},r={m:`l`,M:`L`};function i(e,n,r,i,a,o,s,c,l,u,d){var f=t.util.cos(e),p=t.util.sin(e),m=t.util.cos(n),h=t.util.sin(n),g=r*a*m-i*o*h+s,_=i*a*m+r*o*h+c;return[`C`,u+l*(-r*a*p-i*o*f),d+l*(-i*a*p+r*o*f),g+l*(r*a*h+i*o*m),_+l*(i*a*h-r*o*m),g,_]}function a(e,n,r,a,s,c,l){var u=Math.PI,d=l*u/180,f=t.util.sin(d),p=t.util.cos(d),m=0,h=0;r=Math.abs(r),a=Math.abs(a);var g=-p*e*.5-f*n*.5,_=-p*n*.5+f*e*.5,v=r*r,y=a*a,b=_*_,x=g*g,S=v*y-v*b-y*x,C=0;if(S<0){var w=Math.sqrt(1-S/(v*y));r*=w,a*=w}else C=(s===c?-1:1)*Math.sqrt(S/(v*b+y*x));var T=C*r*_/a,E=-C*a*g/r,D=p*T-f*E+e*.5,O=f*T+p*E+n*.5,k=o(1,0,(g-T)/r,(_-E)/a),A=o((g-T)/r,(_-E)/a,(-g-T)/r,(-_-E)/a);c===0&&A>0?A-=2*u:c===1&&A<0&&(A+=2*u);for(var j=Math.ceil(Math.abs(A/u*2)),M=[],N=A/j,ee=8/3*Math.sin(N/4)*Math.sin(N/4)/Math.sin(N/2),te=k+N,P=0;P<j;P++)M[P]=i(k,te,p,f,r,a,D,O,ee,m,h),m=M[P][5],h=M[P][6],k=te,te+=N;return M}function o(e,t,n,r){var i=Math.atan2(t,e),a=Math.atan2(r,n);return a>=i?a-i:2*Math.PI-(i-a)}function s(n,r,i,a,o,s,c,l){var u;if(t.cachesBoundsOfCurve&&(u=e.call(arguments),t.boundsOfCurveCache[u]))return t.boundsOfCurveCache[u];var d=Math.sqrt,f=Math.min,p=Math.max,m=Math.abs,h=[],g=[[],[]],_,v=6*n-12*i+6*o,y,b,x,S,C,w;_=-3*n+9*i-9*o+3*c,y=3*i-3*n;for(var T=0;T<2;++T){if(T>0&&(v=6*r-12*a+6*s,_=-3*r+9*a-9*s+3*l,y=3*a-3*r),m(_)<1e-12){if(m(v)<1e-12)continue;b=-y/v,0<b&&b<1&&h.push(b);continue}C=v*v-4*y*_,!(C<0)&&(w=d(C),x=(-v+w)/(2*_),0<x&&x<1&&h.push(x),S=(-v-w)/(2*_),0<S&&S<1&&h.push(S))}for(var E,D,O=h.length,k=O,A;O--;)b=h[O],A=1-b,E=A*A*A*n+3*A*A*b*i+3*A*b*b*o+b*b*b*c,g[0][O]=E,D=A*A*A*r+3*A*A*b*a+3*A*b*b*s+b*b*b*l,g[1][O]=D;g[0][k]=n,g[1][k]=r,g[0][k+1]=c,g[1][k+1]=l;var j=[{x:f.apply(null,g[0]),y:f.apply(null,g[1])},{x:p.apply(null,g[0]),y:p.apply(null,g[1])}];return t.cachesBoundsOfCurve&&(t.boundsOfCurveCache[u]=j),j}function c(e,t,n){for(var r=n[1],i=n[2],o=n[3],s=n[4],c=n[5],l=n[6],u=n[7],d=a(l-e,u-t,r,i,s,c,o),f=0,p=d.length;f<p;f++)d[f][1]+=e,d[f][2]+=t,d[f][3]+=e,d[f][4]+=t,d[f][5]+=e,d[f][6]+=t;return d}function l(e){var t=0,n=0,r=e.length,i=0,a=0,o,s,l,u=[],d,f,p;for(s=0;s<r;++s){switch(l=!1,o=e[s].slice(0),o[0]){case`l`:o[0]=`L`,o[1]+=t,o[2]+=n;case`L`:t=o[1],n=o[2];break;case`h`:o[1]+=t;case`H`:o[0]=`L`,o[2]=n,t=o[1];break;case`v`:o[1]+=n;case`V`:o[0]=`L`,n=o[1],o[1]=t,o[2]=n;break;case`m`:o[0]=`M`,o[1]+=t,o[2]+=n;case`M`:t=o[1],n=o[2],i=o[1],a=o[2];break;case`c`:o[0]=`C`,o[1]+=t,o[2]+=n,o[3]+=t,o[4]+=n,o[5]+=t,o[6]+=n;case`C`:f=o[3],p=o[4],t=o[5],n=o[6];break;case`s`:o[0]=`S`,o[1]+=t,o[2]+=n,o[3]+=t,o[4]+=n;case`S`:d===`C`?(f=2*t-f,p=2*n-p):(f=t,p=n),t=o[3],n=o[4],o[0]=`C`,o[5]=o[3],o[6]=o[4],o[3]=o[1],o[4]=o[2],o[1]=f,o[2]=p,f=o[3],p=o[4];break;case`q`:o[0]=`Q`,o[1]+=t,o[2]+=n,o[3]+=t,o[4]+=n;case`Q`:f=o[1],p=o[2],t=o[3],n=o[4];break;case`t`:o[0]=`T`,o[1]+=t,o[2]+=n;case`T`:d===`Q`?(f=2*t-f,p=2*n-p):(f=t,p=n),o[0]=`Q`,t=o[1],n=o[2],o[1]=f,o[2]=p,o[3]=t,o[4]=n;break;case`a`:o[0]=`A`,o[6]+=t,o[7]+=n;case`A`:l=!0,u=u.concat(c(t,n,o)),t=o[6],n=o[7];break;case`z`:case`Z`:t=i,n=a;break;default:}l||u.push(o),d=o[0]}return u}function u(e,t,n,r){return Math.sqrt((n-e)*(n-e)+(r-t)*(r-t))}function d(e){return e*e*e}function f(e){return 3*e*e*(1-e)}function p(e){return 3*e*(1-e)*(1-e)}function m(e){return(1-e)*(1-e)*(1-e)}function h(e,t,n,r,i,a,o,s){return function(c){var l=d(c),u=f(c),h=p(c),g=m(c);return{x:o*l+i*u+n*h+e*g,y:s*l+a*u+r*h+t*g}}}function g(e,t,n,r,i,a,o,s){return function(c){var l=1-c,u=3*l*l*(n-e)+6*l*c*(i-n)+3*c*c*(o-i),d=3*l*l*(r-t)+6*l*c*(a-r)+3*c*c*(s-a);return Math.atan2(d,u)}}function _(e){return e*e}function v(e){return 2*e*(1-e)}function y(e){return(1-e)*(1-e)}function b(e,t,n,r,i,a){return function(o){var s=_(o),c=v(o),l=y(o);return{x:i*s+n*c+e*l,y:a*s+r*c+t*l}}}function x(e,t,n,r,i,a){return function(o){var s=1-o,c=2*s*(n-e)+2*o*(i-n),l=2*s*(r-t)+2*o*(a-r);return Mat
|
||
|
|
`]:this.type===`radial`&&(s=[`<radialGradient `,c,` cx="`,u?r.x1:r.x2,`" cy="`,u?r.y1:r.y2,`" r="`,u?r.r1:r.r2,`" fx="`,u?r.x2:r.x1,`" fy="`,u?r.y2:r.y1,`">
|
||
|
|
`]),this.type===`radial`){if(u)for(l=l.concat(),l.reverse(),a=0,o=l.length;a<o;a++)l[a].offset=1-l[a].offset;var g=Math.min(r.r1,r.r2);if(g>0){var _=g/Math.max(r.r1,r.r2);for(a=0,o=l.length;a<o;a++)l[a].offset+=_*(1-l[a].offset)}}for(a=0,o=l.length;a<o;a++){var v=l[a];s.push(`<stop `,`offset="`,v.offset*100+`%`,`" style="stop-color:`,v.color,v.opacity===void 0?`;`:`;stop-opacity: `+v.opacity,`"/>
|
||
|
|
`)}return s.push(this.type===`linear`?`</linearGradient>
|
||
|
|
`:`</radialGradient>
|
||
|
|
`),s.join(``)},toLive:function(e){var n,r=t.util.object.clone(this.coords),i,a;if(this.type){for(this.type===`linear`?n=e.createLinearGradient(r.x1,r.y1,r.x2,r.y2):this.type===`radial`&&(n=e.createRadialGradient(r.x1,r.y1,r.r1,r.x2,r.y2,r.r2)),i=0,a=this.colorStops.length;i<a;i++){var o=this.colorStops[i].color,s=this.colorStops[i].opacity,c=this.colorStops[i].offset;s!==void 0&&(o=new t.Color(o).setAlpha(s).toRgba()),n.addColorStop(c,o)}return n}}}),t.util.object.extend(t.Gradient,{fromElement:function(i,o,s,c){var l=parseFloat(s)/(/%$/.test(s)?100:1);l=l<0?0:l>1?1:l,isNaN(l)&&(l=1);var u=i.getElementsByTagName(`stop`),d,f=i.getAttribute(`gradientUnits`)===`userSpaceOnUse`?`pixels`:`percentage`,p=i.getAttribute(`gradientTransform`)||``,m=[],h,g,_=0,v=0,y;for(i.nodeName===`linearGradient`||i.nodeName===`LINEARGRADIENT`?(d=`linear`,h=n(i)):(d=`radial`,h=r(i)),g=u.length;g--;)m.push(e(u[g],l));return y=t.parseTransformAttribute(p),a(o,h,c,f),f===`pixels`&&(_=-o.left,v=-o.top),new t.Gradient({id:i.getAttribute(`id`),type:d,coords:h,colorStops:m,gradientUnits:f,gradientTransform:y,offsetX:_,offsetY:v})}});function a(e,t,n,r){var i,a;Object.keys(t).forEach(function(e){i=t[e],i===`Infinity`?a=1:i===`-Infinity`?a=0:(a=parseFloat(t[e],10),typeof i==`string`&&/^(\d+\.\d+)%|(\d+)%$/.test(i)&&(a*=.01,r===`pixels`&&((e===`x1`||e===`x2`||e===`r2`)&&(a*=n.viewBoxWidth||n.width),(e===`y1`||e===`y2`)&&(a*=n.viewBoxHeight||n.height)))),t[e]=a})}})(),(function(){var e=t.util.toFixed;t.Pattern=t.util.createClass({repeat:`repeat`,offsetX:0,offsetY:0,crossOrigin:``,patternTransform:null,initialize:function(e,n){if(e||={},this.id=t.Object.__uid++,this.setOptions(e),!e.source||e.source&&typeof e.source!=`string`){n&&n(this);return}else{var r=this;this.source=t.util.createImage(),t.util.loadImage(e.source,function(e,t){r.source=e,n&&n(r,t)},null,this.crossOrigin)}},toObject:function(n){var r=t.Object.NUM_FRACTION_DIGITS,i,a;return typeof this.source.src==`string`?i=this.source.src:typeof this.source==`object`&&this.source.toDataURL&&(i=this.source.toDataURL()),a={type:`pattern`,source:i,repeat:this.repeat,crossOrigin:this.crossOrigin,offsetX:e(this.offsetX,r),offsetY:e(this.offsetY,r),patternTransform:this.patternTransform?this.patternTransform.concat():null},t.util.populateWithProperties(this,a,n),a},toSVG:function(e){var t=typeof this.source==`function`?this.source():this.source,n=t.width/e.width,r=t.height/e.height,i=this.offsetX/e.width,a=this.offsetY/e.height,o=``;return(this.repeat===`repeat-x`||this.repeat===`no-repeat`)&&(r=1,a&&(r+=Math.abs(a))),(this.repeat===`repeat-y`||this.repeat===`no-repeat`)&&(n=1,i&&(n+=Math.abs(i))),t.src?o=t.src:t.toDataURL&&(o=t.toDataURL()),`<pattern id="SVGID_`+this.id+`" x="`+i+`" y="`+a+`" width="`+n+`" height="`+r+`">
|
||
|
|
<image x="0" y="0" width="`+t.width+`" height="`+t.height+`" xlink:href="`+o+`"></image>
|
||
|
|
</pattern>
|
||
|
|
`},setOptions:function(e){for(var t in e)this[t]=e[t]},toLive:function(e){var t=this.source;return!t||t.src!==void 0&&(!t.complete||t.naturalWidth===0||t.naturalHeight===0)?``:e.createPattern(t,this.repeat)}})})(),(function(e){var t=e.fabric||={},n=t.util.toFixed;if(t.Shadow){t.warn(`fabric.Shadow is already defined.`);return}t.Shadow=t.util.createClass({color:`rgb(0,0,0)`,blur:0,offsetX:0,offsetY:0,affectStroke:!1,includeDefaultValues:!0,nonScaling:!1,initialize:function(e){for(var n in typeof e==`string`&&(e=this._parseShadow(e)),e)this[n]=e[n];this.id=t.Object.__uid++},_parseShadow:function(e){var n=e.trim(),r=t.Shadow.reOffsetsAndBlur.exec(n)||[];return{color:(n.replace(t.Shadow.reOffsetsAndBlur,``)||`rgb(0,0,0)`).trim(),offsetX:parseFloat(r[1],10)||0,offsetY:parseFloat(r[2],10)||0,blur:parseFloat(r[3],10)||0}},toString:function(){return[this.offsetX,this.offsetY,this.blur,this.color].join(`px `)},toSVG:function(e){var r=40,i=40,a=t.Object.NUM_FRACTION_DIGITS,o=t.util.rotateVector({x:this.offsetX,y:this.offsetY},t.util.degreesToRadians(-e.angle)),s=20,c=new t.Color(this.color);return e.width&&e.height&&(r=n((Math.abs(o.x)+this.blur)/e.width,a)*100+s,i=n((Math.abs(o.y)+this.blur)/e.height,a)*100+s),e.flipX&&(o.x*=-1),e.flipY&&(o.y*=-1),`<filter id="SVGID_`+this.id+`" y="-`+i+`%" height="`+(100+2*i)+`%" x="-`+r+`%" width="`+(100+2*r)+`%" >
|
||
|
|
<feGaussianBlur in="SourceAlpha" stdDeviation="`+n(this.blur?this.blur/2:0,a)+`"></feGaussianBlur>
|
||
|
|
<feOffset dx="`+n(o.x,a)+`" dy="`+n(o.y,a)+`" result="oBlur" ></feOffset>
|
||
|
|
<feFlood flood-color="`+c.toRgb()+`" flood-opacity="`+c.getAlpha()+`"/>
|
||
|
|
<feComposite in2="oBlur" operator="in" />
|
||
|
|
<feMerge>
|
||
|
|
<feMergeNode></feMergeNode>
|
||
|
|
<feMergeNode in="SourceGraphic"></feMergeNode>
|
||
|
|
</feMerge>
|
||
|
|
</filter>
|
||
|
|
`},toObject:function(){if(this.includeDefaultValues)return{color:this.color,blur:this.blur,offsetX:this.offsetX,offsetY:this.offsetY,affectStroke:this.affectStroke,nonScaling:this.nonScaling};var e={},n=t.Shadow.prototype;return[`color`,`blur`,`offsetX`,`offsetY`,`affectStroke`,`nonScaling`].forEach(function(t){this[t]!==n[t]&&(e[t]=this[t])},this),e}}),t.Shadow.reOffsetsAndBlur=/(?:\s|^)(-?\d+(?:\.\d*)?(?:px)?(?:\s?|$))?(-?\d+(?:\.\d*)?(?:px)?(?:\s?|$))?(\d+(?:\.\d*)?(?:px)?)?(?:\s?|$)(?:$|\s)/})(e),(function(){if(t.StaticCanvas){t.warn(`fabric.StaticCanvas is already defined.`);return}var e=t.util.object.extend,n=t.util.getElementOffset,r=t.util.removeFromArray,i=t.util.toFixed,a=t.util.transformPoint,o=t.util.invertTransform,s=t.util.getNodeCanvas,c=t.util.createCanvasElement,l=Error("Could not initialize `canvas` element");t.StaticCanvas=t.util.createClass(t.CommonMethods,{initialize:function(e,t){t||={},this.renderAndResetBound=this.renderAndReset.bind(this),this.requestRenderAllBound=this.requestRenderAll.bind(this),this._initStatic(e,t)},backgroundColor:``,backgroundImage:null,overlayColor:``,overlayImage:null,includeDefaultValues:!0,stateful:!1,renderOnAddRemove:!0,controlsAboveOverlay:!1,allowTouchScrolling:!1,imageSmoothingEnabled:!0,viewportTransform:t.iMatrix.concat(),backgroundVpt:!0,overlayVpt:!0,enableRetinaScaling:!0,vptCoords:{},skipOffscreen:!0,clipPath:void 0,_initStatic:function(e,t){var n=this.requestRenderAllBound;this._objects=[],this._createLowerCanvas(e),this._initOptions(t),this.interactive||this._initRetinaScaling(),t.overlayImage&&this.setOverlayImage(t.overlayImage,n),t.backgroundImage&&this.setBackgroundImage(t.backgroundImage,n),t.backgroundColor&&this.setBackgroundColor(t.backgroundColor,n),t.overlayColor&&this.setOverlayColor(t.overlayColor,n),this.calcOffset()},_isRetinaScaling:function(){return t.devicePixelRatio>1&&this.enableRetinaScaling},getRetinaScaling:function(){return this._isRetinaScaling()?Math.max(1,t.devicePixelRatio):1},_initRetinaScaling:function(){if(this._isRetinaScaling()){var e=t.devicePixelRatio;this.__initRetinaScaling(e,this.lowerCanvasEl,this.contextContainer),this.upperCanvasEl&&this.__initRetinaScaling(e,this.upperCanvasEl,this.contextTop)}},__initRetinaScaling:function(e,t,n){t.setAttribute(`width`,this.width*e),t.setAttribute(`height`,this.height*e),n.scale(e,e)},calcOffset:function(){return this._offset=n(this.lowerCanvasEl),this},setOverlayImage:function(e,t,n){return this.__setBgOverlayImage(`overlayImage`,e,t,n)},setBackgroundImage:function(e,t,n){return this.__setBgOverlayImage(`backgroundImage`,e,t,n)},setOverlayColor:function(e,t){return this.__setBgOverlayColor(`overlayColor`,e,t)},setBackgroundColor:function(e,t){return this.__setBgOverlayColor(`backgroundColor`,e,t)},__setBgOverlayImage:function(e,n,r,i){return typeof n==`string`?t.util.loadImage(n,function(n,a){if(n){var o=new t.Image(n,i);this[e]=o,o.canvas=this}r&&r(n,a)},this,i&&i.crossOrigin):(i&&n.setOptions(i),this[e]=n,n&&(n.canvas=this),r&&r(n,!1)),this},__setBgOverlayColor:function(e,t,n){return this[e]=t,this._initGradient(t,e),this._initPattern(t,e,n),this},_createCanvasElement:function(){var e=c();if(!e||(e.style||={},e.getContext===void 0))throw l;return e},_initOptions:function(e){var t=this.lowerCanvasEl;this._setOptions(e),this.width=this.width||parseInt(t.width,10)||0,this.height=this.height||parseInt(t.height,10)||0,this.lowerCanvasEl.style&&(t.width=this.width,t.height=this.height,t.style.width=this.width+`px`,t.style.height=this.height+`px`,this.viewportTransform=this.viewportTransform.slice())},_createLowerCanvas:function(e){e&&e.getContext?this.lowerCanvasEl=e:this.lowerCanvasEl=t.util.getById(e)||this._createCanvasElement(),t.util.addClass(this.lowerCanvasEl,`lower-canvas`),this._originalCanvasStyle=this.lowerCanvasEl.style,this.interactive&&this._applyCanvasStyle(this.lowerCanvasEl),this.contextContainer=this.lowerCanvasEl.getContext(`2d`)},getWidth:function(){return this.width},getHeight:function(){return this.height},setWidth:function(e,t){return this.setDimensions({width:e
|
||
|
|
`),this._setSVGBgOverlayColor(n,`background`),this._setSVGBgOverlayImage(n,`backgroundImage`,t),this._setSVGObjects(n,t),this.clipPath&&n.push(`</g>
|
||
|
|
`),this._setSVGBgOverlayColor(n,`overlay`),this._setSVGBgOverlayImage(n,`overlayImage`,t),n.push(`</svg>`),n.join(``)},_setSVGPreamble:function(e,t){t.suppressPreamble||e.push(`<?xml version="1.0" encoding="`,t.encoding||`UTF-8`,`" standalone="no" ?>
|
||
|
|
`,`<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" `,`"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
||
|
|
`)},_setSVGHeader:function(e,n){var r=n.width||this.width,a=n.height||this.height,o,s=`viewBox="0 0 `+this.width+` `+this.height+`" `,c=t.Object.NUM_FRACTION_DIGITS;n.viewBox?s=`viewBox="`+n.viewBox.x+` `+n.viewBox.y+` `+n.viewBox.width+` `+n.viewBox.height+`" `:this.svgViewportTransformation&&(o=this.viewportTransform,s=`viewBox="`+i(-o[4]/o[0],c)+` `+i(-o[5]/o[3],c)+` `+i(this.width/o[0],c)+` `+i(this.height/o[3],c)+`" `),e.push(`<svg `,`xmlns="http://www.w3.org/2000/svg" `,`xmlns:xlink="http://www.w3.org/1999/xlink" `,`version="1.1" `,`width="`,r,`" `,`height="`,a,`" `,s,`xml:space="preserve">
|
||
|
|
`,`<desc>Created with Fabric.js `,t.version,`</desc>
|
||
|
|
`,`<defs>
|
||
|
|
`,this.createSVGFontFacesMarkup(),this.createSVGRefElementsMarkup(),this.createSVGClipPathMarkup(n),`</defs>
|
||
|
|
`)},createSVGClipPathMarkup:function(e){var n=this.clipPath;return n?(n.clipPathId=`CLIPPATH_`+ t.Object.__uid++,`<clipPath id="`+n.clipPathId+`" >
|
||
|
|
`+this.clipPath.toClipPathSVG(e.reviver)+`</clipPath>
|
||
|
|
`):``},createSVGRefElementsMarkup:function(){var e=this;return[`background`,`overlay`].map(function(n){var r=e[n+`Color`];if(r&&r.toLive){var i=e[n+`Vpt`],a=e.viewportTransform,o={width:e.width/(i?a[0]:1),height:e.height/(i?a[3]:1)};return r.toSVG(o,{additionalTransform:i?t.util.matrixToSVG(a):``})}}).join(``)},createSVGFontFacesMarkup:function(){var e=``,n={},r,i,a,o,s,c,l,u,d,f=t.fontPaths,p=[];for(this._objects.forEach(function e(t){p.push(t),t._objects&&t._objects.forEach(e)}),u=0,d=p.length;u<d;u++)if(r=p[u],i=r.fontFamily,!(r.type.indexOf(`text`)===-1||n[i]||!f[i])&&(n[i]=!0,r.styles))for(s in a=r.styles,a)for(l in o=a[s],o)c=o[l],i=c.fontFamily,!n[i]&&f[i]&&(n[i]=!0);for(var m in n)e+=[` @font-face {
|
||
|
|
`,` font-family: '`,m,`';
|
||
|
|
`,` src: url('`,f[m],`');
|
||
|
|
`,` }
|
||
|
|
`].join(``);return e&&=[` <style type="text/css">`,`<![CDATA[
|
||
|
|
`,e,`]]>`,`</style>
|
||
|
|
`].join(``),e},_setSVGObjects:function(e,t){var n,r,i,a=this._objects;for(r=0,i=a.length;r<i;r++)n=a[r],!n.excludeFromExport&&this._setSVGObject(e,n,t)},_setSVGObject:function(e,t,n){e.push(t.toSVG(n))},_setSVGBgOverlayImage:function(e,t,n){this[t]&&!this[t].excludeFromExport&&this[t].toSVG&&e.push(this[t].toSVG(n))},_setSVGBgOverlayColor:function(e,n){var r=this[n+`Color`],i=this.viewportTransform,a=this.width,o=this.height;if(r)if(r.toLive){var s=r.repeat,c=t.util.invertTransform(i),l=this[n+`Vpt`]?t.util.matrixToSVG(c):``;e.push(`<rect transform="`+l+` translate(`,a/2,`,`,o/2,`)"`,` x="`,r.offsetX-a/2,`" y="`,r.offsetY-o/2,`" `,`width="`,s===`repeat-y`||s===`no-repeat`?r.source.width:a,`" height="`,s===`repeat-x`||s===`no-repeat`?r.source.height:o,`" fill="url(#SVGID_`+r.id+`)"`,`></rect>
|
||
|
|
`)}else e.push(`<rect x="0" y="0" width="100%" height="100%" `,`fill="`,r,`"`,`></rect>
|
||
|
|
`)},sendToBack:function(e){if(!e)return this;var t=this._activeObject,n,i,a;if(e===t&&e.type===`activeSelection`)for(a=t._objects,n=a.length;n--;)i=a[n],r(this._objects,i),this._objects.unshift(i);else r(this._objects,e),this._objects.unshift(e);return this.renderOnAddRemove&&this.requestRenderAll(),this},bringToFront:function(e){if(!e)return this;var t=this._activeObject,n,i,a;if(e===t&&e.type===`activeSelection`)for(a=t._objects,n=0;n<a.length;n++)i=a[n],r(this._objects,i),this._objects.push(i);else r(this._objects,e),this._objects.push(e);return this.renderOnAddRemove&&this.requestRenderAll(),this},sendBackwards:function(e,t){if(!e)return this;var n=this._activeObject,i,a,o,s,c,l=0;if(e===n&&e.type===`activeSelection`)for(c=n._objects,i=0;i<c.length;i++)a=c[i],o=this._objects.indexOf(a),o>0+l&&(s=o-1,r(this._objects,a),this._objects.splice(s,0,a)),l++;else o=this._objects.indexOf(e),o!==0&&(s=this._findNewLowerIndex(e,o,t),r(this._objects,e),this._objects.splice(s,0,e));return this.renderOnAddRemove&&this.requestRenderAll(),this},_findNewLowerIndex:function(e,t,n){var r,i;if(n){for(r=t,i=t-1;i>=0;--i)if(e.intersectsWithObject(this._objects[i])||e.isContainedWithinObject(this._objects[i])||this._objects[i].isContainedWithinObject(e)){r=i;break}}else r=t-1;return r},bringForward:function(e,t){if(!e)return this;var n=this._activeObject,i,a,o,s,c,l=0;if(e===n&&e.type===`activeSelection`)for(c=n._objects,i=c.length;i--;)a=c[i],o=this._objects.indexOf(a),o<this._objects.length-1-l&&(s=o+1,r(this._objects,a),this._objects.splice(s,0,a)),l++;else o=this._objects.indexOf(e),o!==this._objects.length-1&&(s=this._findNewUpperIndex(e,o,t),r(this._objects,e),this._objects.splice(s,0,e));return this.renderOnAddRemove&&this.requestRenderAll(),this},_findNewUpperIndex:function(e,t,n){var r,i,a;if(n){for(r=t,i=t+1,a=this._objects.length;i<a;++i)if(e.intersectsWithObject(this._objects[i])||e.isContainedWithinObject(this._objects[i])||this._objects[i].isContainedWithinObject(e)){r=i;break}}else r=t+1;return r},moveTo:function(e,t){return r(this._objects,e),this._objects.splice(t,0,e),this.renderOnAddRemove&&this.requestRenderAll()},dispose:function(){return this.isRendering&&=(t.util.cancelAnimFrame(this.isRendering),0),this.forEachObject(function(e){e.dispose&&e.dispose()}),this._objects=[],this.backgroundImage&&this.backgroundImage.dispose&&this.backgroundImage.dispose(),this.backgroundImage=null,this.overlayImage&&this.overlayImage.dispose&&this.overlayImage.dispose(),this.overlayImage=null,this._iTextInstances=null,this.contextContainer=null,this.lowerCanvasEl.classList.remove(`lower-canvas`),t.util.setStyle(this.lowerCanvasEl,this._originalCanvasStyle),delete this._originalCanvasStyle,this.lowerCanvasEl.setAttribute(`width`,this.width),this.lowerCanvasEl.setAttribute(`height`,this.height),t.util.cleanUpJsdomNode(this.lowerCanvasEl),this.lowerCanvasEl=void 0,this},toString:function(){return`#<fabric.Canvas (`+this.complexity()+`): { objects: `+this._objects.length+` }>`}}),e(t.StaticCanvas.prototype,t.Observable),e(t.StaticCanvas.prototype,t.Collection),e(t.StaticCanvas.prototype,t.DataURLExporter),e(t.StaticCanvas,{EMPTY_JSON:`{"objects": [], "background": "white"}`,supports:function(e){var t=c();if(!t||!t.getContext)return null;var n=t.getContext(`2d`);if(!n)return null;switch(e){case`setLineDash`:return n.setLineDash!==void 0;default:return null}}}),t.StaticCanvas.prototype.toJSON=t.StaticCanvas.prototype.toObject,t.isLikelyNode&&(t.StaticCanvas.prototype.createPNGStream=function(){var e=s(this.lowerCanvasEl);return e&&e.createPNGStream()},t.StaticCanvas.prototype.createJPEGStream=function(e){var t=s(this.lowerCanvasEl);return t&&t.createJPEGStream(e)})})(),t.BaseBrush=t.util.createClass({color:`rgb(0, 0, 0)`,width:1,shadow:null,strokeLineCap:`round`,strokeLineJoin:`round`,strokeMiterLimit:10,strokeDashArray:null,limitedToCanvasSize:!1,_setBrushStyles:function(e){e.strokeStyle=this.color,e.lineWidth=this.width,e.lineCap=this.strokeLineCap,e.miterLimit=this.strokeMiterLimit,e.lineJoin=this.strokeLineJoin,e.setLineDash(this.strokeD
|
||
|
|
`)}},toSVG:function(e){return this._createBaseSVGMarkup(this._toSVG(e),{reviver:e})},toClipPathSVG:function(e){return` `+this._createBaseClipPathSVGMarkup(this._toSVG(e),{reviver:e})},_createBaseClipPathSVGMarkup:function(e,t){t||={};var n=t.reviver,r=t.additionalTransform||``,i=[this.getSvgTransform(!0,r),this.getSvgCommons()].join(``),a=e.indexOf(`COMMON_PARTS`);return e[a]=i,n?n(e.join(``)):e.join(``)},_createBaseSVGMarkup:function(e,n){n||={};var r=n.noStyle,i=n.reviver,a=r?``:`style="`+this.getSvgStyles()+`" `,o=n.withShadow?`style="`+this.getSvgFilter()+`" `:``,s=this.clipPath,c=this.strokeUniform?`vector-effect="non-scaling-stroke" `:``,l=s&&s.absolutePositioned,u=this.stroke,d=this.fill,f=this.shadow,p,m=[],h,g=e.indexOf(`COMMON_PARTS`),_=n.additionalTransform;return s&&(s.clipPathId=`CLIPPATH_`+ t.Object.__uid++,h=`<clipPath id="`+s.clipPathId+`" >
|
||
|
|
`+s.toClipPathSVG(i)+`</clipPath>
|
||
|
|
`),l&&m.push(`<g `,o,this.getSvgCommons(),` >
|
||
|
|
`),m.push(`<g `,this.getSvgTransform(!1),l?``:o+this.getSvgCommons(),` >
|
||
|
|
`),p=[a,c,r?``:this.addPaintOrder(),` `,_?`transform="`+_+`" `:``].join(``),e[g]=p,d&&d.toLive&&m.push(d.toSVG(this)),u&&u.toLive&&m.push(u.toSVG(this)),f&&m.push(f.toSVG(this)),s&&m.push(h),m.push(e.join(``)),m.push(`</g>
|
||
|
|
`),l&&m.push(`</g>
|
||
|
|
`),i?i(m.join(``)):m.join(``)},addPaintOrder:function(){return this.paintFirst===`fill`?``:` paint-order="`+this.paintFirst+`" `}})})(),(function(){var e=t.util.object.extend,n=`stateProperties`;function r(t,n,r){var i={};r.forEach(function(e){i[e]=t[e]}),e(t[n],i,!0)}function i(e,t,n){if(e===t)return!0;if(Array.isArray(e)){if(!Array.isArray(t)||e.length!==t.length)return!1;for(var r=0,a=e.length;r<a;r++)if(!i(e[r],t[r]))return!1;return!0}else if(e&&typeof e==`object`){var o=Object.keys(e),s;if(!t||typeof t!=`object`||!n&&o.length!==Object.keys(t).length)return!1;for(var r=0,a=o.length;r<a;r++)if(s=o[r],!(s===`canvas`||s===`group`)&&!i(e[s],t[s]))return!1;return!0}}t.util.object.extend(t.Object.prototype,{hasStateChanged:function(e){e||=n;var t=`_`+e;return Object.keys(this[t]).length<this[e].length?!0:!i(this[t],this,!0)},saveState:function(e){var t=e&&e.propertySet||n,i=`_`+t;return this[i]?(r(this,i,this[t]),e&&e.stateProperties&&r(this,i,e.stateProperties),this):this.setupState(e)},setupState:function(e){e||={};var t=e.propertySet||n;return e.propertySet=t,this[`_`+t]={},this.saveState(e),this}})})(),(function(){var e=t.util.degreesToRadians;t.util.object.extend(t.Object.prototype,{_findTargetCorner:function(e,t){if(!this.hasControls||this.group||!this.canvas||this.canvas._activeObject!==this)return!1;var n=e.x,r=e.y,i,a,o=Object.keys(this.oCoords),s=o.length-1,c;for(this.__corner=0;s>=0;s--)if(c=o[s],this.isControlVisible(c)&&(a=this._getImageLines(t?this.oCoords[c].touchCorner:this.oCoords[c].corner),i=this._findCrossPoints({x:n,y:r},a),i!==0&&i%2==1))return this.__corner=c,c;return!1},forEachControl:function(e){for(var t in this.controls)e(this.controls[t],t,this)},_setCornerCoords:function(){var e=this.oCoords;for(var t in e){var n=this.controls[t];e[t].corner=n.calcCornerCoords(this.angle,this.cornerSize,e[t].x,e[t].y,!1),e[t].touchCorner=n.calcCornerCoords(this.angle,this.touchCornerSize,e[t].x,e[t].y,!0)}},drawSelectionBackground:function(t){if(!this.selectionBackgroundColor||this.canvas&&!this.canvas.interactive||this.canvas&&this.canvas._activeObject!==this)return this;t.save();var n=this.getCenterPoint(),r=this._calculateCurrentDimensions(),i=this.canvas.viewportTransform;return t.translate(n.x,n.y),t.scale(1/i[0],1/i[3]),t.rotate(e(this.angle)),t.fillStyle=this.selectionBackgroundColor,t.fillRect(-r.x/2,-r.y/2,r.x,r.y),t.restore(),this},drawBorders:function(e,t){t||={};var n=this._calculateCurrentDimensions(),r=this.borderScaleFactor,i=n.x+r,a=n.y+r,o=t.hasControls===void 0?this.hasControls:t.hasControls,s=!1;return e.save(),e.strokeStyle=t.borderColor||this.borderColor,this._setLineDash(e,t.borderDashArray||this.borderDashArray),e.strokeRect(-i/2,-a/2,i,a),o&&(e.beginPath(),this.forEachControl(function(t,n,r){t.withConnection&&t.getVisibility(r,n)&&(s=!0,e.moveTo(t.x*i,t.y*a),e.lineTo(t.x*i+t.offsetX,t.y*a+t.offsetY))}),s&&e.stroke()),e.restore(),this},drawBordersInGroup:function(e,n,r){r||={};var i=t.util.sizeAfterTransform(this.width,this.height,n),a=this.strokeWidth,o=this.strokeUniform,s=this.borderScaleFactor,c=i.x+a*(o?this.canvas.getZoom():n.scaleX)+s,l=i.y+a*(o?this.canvas.getZoom():n.scaleY)+s;return e.save(),this._setLineDash(e,r.borderDashArray||this.borderDashArray),e.strokeStyle=r.borderColor||this.borderColor,e.strokeRect(-c/2,-l/2,c,l),e.restore(),this},drawControls:function(e,n){n||={},e.save();var r=1,i,a;return this.canvas&&(r=this.canvas.getRetinaScaling()),e.setTransform(r,0,0,r,0,0),e.strokeStyle=e.fillStyle=n.cornerColor||this.cornerColor,this.transparentCorners||(e.strokeStyle=n.cornerStrokeColor||this.cornerStrokeColor),this._setLineDash(e,n.cornerDashArray||this.cornerDashArray),this.setCoords(),this.group&&(i=this.group.calcTransformMatrix()),this.forEachControl(function(r,o,s){a=s.oCoords[o],r.getVisibility(s,o)&&(i&&(a=t.util.transformPoint(a,i)),r.render(e,a.x,a.y,n,s))}),e.restore(),this},isControlVisible:function(e){return this.controls[e]&&this.controls[e].getVisibility(this,e)},setControlVisible:function(e,t){return this._controlsVisibility||={},this._controlsVisibility[e
|
||
|
|
`]}}),t.Line.ATTRIBUTE_NAMES=t.SHARED_ATTRIBUTES.concat(`x1 y1 x2 y2`.split(` `)),t.Line.fromElement=function(e,r,i){i||={};var a=t.parseAttributes(e,t.Line.ATTRIBUTE_NAMES),o=[a.x1||0,a.y1||0,a.x2||0,a.y2||0];r(new t.Line(o,n(a,i)))},t.Line.fromObject=function(e,n){function i(e){delete e.points,n&&n(e)}var a=r(e,!0);a.points=[e.x1,e.y1,e.x2,e.y2],t.Object._fromObject(`Line`,a,i,`points`)};function a(e,t){var n=e.origin,r=e.axis1,i=e.axis2,a=e.dimension,o=t.nearest,s=t.center,c=t.farthest;return function(){switch(this.get(n)){case o:return Math.min(this.get(r),this.get(i));case s:return Math.min(this.get(r),this.get(i))+.5*this.get(a);case c:return Math.max(this.get(r),this.get(i))}}}})(e),(function(e){var t=e.fabric||={},n=t.util.degreesToRadians;if(t.Circle){t.warn(`fabric.Circle is already defined.`);return}t.Circle=t.util.createClass(t.Object,{type:`circle`,radius:0,startAngle:0,endAngle:360,cacheProperties:t.Object.prototype.cacheProperties.concat(`radius`,`startAngle`,`endAngle`),_set:function(e,t){return this.callSuper(`_set`,e,t),e===`radius`&&this.setRadius(t),this},toObject:function(e){return this.callSuper(`toObject`,[`radius`,`startAngle`,`endAngle`].concat(e))},_toSVG:function(){var e,r=0,i=0,a=(this.endAngle-this.startAngle)%360;if(a===0)e=[`<circle `,`COMMON_PARTS`,`cx="`+r+`" cy="`+i+`" `,`r="`,this.radius,`" />
|
||
|
|
`];else{var o=n(this.startAngle),s=n(this.endAngle),c=this.radius,l=t.util.cos(o)*c,u=t.util.sin(o)*c,d=t.util.cos(s)*c,f=t.util.sin(s)*c,p=a>180?`1`:`0`;e=[`<path d="M `+l+` `+u,` A `+c+` `+c,` 0 `,+p+` 1`,` `+d+` `+f,`" `,`COMMON_PARTS`,` />
|
||
|
|
`]}return e},_render:function(e){e.beginPath(),e.arc(0,0,this.radius,n(this.startAngle),n(this.endAngle),!1),this._renderPaintInOrder(e)},getRadiusX:function(){return this.get(`radius`)*this.get(`scaleX`)},getRadiusY:function(){return this.get(`radius`)*this.get(`scaleY`)},setRadius:function(e){return this.radius=e,this.set(`width`,e*2).set(`height`,e*2)}}),t.Circle.ATTRIBUTE_NAMES=t.SHARED_ATTRIBUTES.concat(`cx cy r`.split(` `)),t.Circle.fromElement=function(e,n){var i=t.parseAttributes(e,t.Circle.ATTRIBUTE_NAMES);if(!r(i))throw Error("value of `r` attribute is required and can not be negative");i.left=(i.left||0)-i.radius,i.top=(i.top||0)-i.radius,n(new t.Circle(i))};function r(e){return`radius`in e&&e.radius>=0}t.Circle.fromObject=function(e,n){t.Object._fromObject(`Circle`,e,n)}})(e),(function(e){var t=e.fabric||={};if(t.Triangle){t.warn(`fabric.Triangle is already defined`);return}t.Triangle=t.util.createClass(t.Object,{type:`triangle`,width:100,height:100,_render:function(e){var t=this.width/2,n=this.height/2;e.beginPath(),e.moveTo(-t,n),e.lineTo(0,-n),e.lineTo(t,n),e.closePath(),this._renderPaintInOrder(e)},_toSVG:function(){var e=this.width/2,t=this.height/2;return[`<polygon `,`COMMON_PARTS`,`points="`,[-e+` `+t,`0 `+-t,e+` `+t].join(`,`),`" />`]}}),t.Triangle.fromObject=function(e,n){return t.Object._fromObject(`Triangle`,e,n)}})(e),(function(e){var t=e.fabric||={},n=Math.PI*2;if(t.Ellipse){t.warn(`fabric.Ellipse is already defined.`);return}t.Ellipse=t.util.createClass(t.Object,{type:`ellipse`,rx:0,ry:0,cacheProperties:t.Object.prototype.cacheProperties.concat(`rx`,`ry`),initialize:function(e){this.callSuper(`initialize`,e),this.set(`rx`,e&&e.rx||0),this.set(`ry`,e&&e.ry||0)},_set:function(e,t){switch(this.callSuper(`_set`,e,t),e){case`rx`:this.rx=t,this.set(`width`,t*2);break;case`ry`:this.ry=t,this.set(`height`,t*2);break}return this},getRx:function(){return this.get(`rx`)*this.get(`scaleX`)},getRy:function(){return this.get(`ry`)*this.get(`scaleY`)},toObject:function(e){return this.callSuper(`toObject`,[`rx`,`ry`].concat(e))},_toSVG:function(){return[`<ellipse `,`COMMON_PARTS`,`cx="0" cy="0" `,`rx="`,this.rx,`" ry="`,this.ry,`" />
|
||
|
|
`]},_render:function(e){e.beginPath(),e.save(),e.transform(1,0,0,this.ry/this.rx,0,0),e.arc(0,0,this.rx,0,n,!1),e.restore(),this._renderPaintInOrder(e)}}),t.Ellipse.ATTRIBUTE_NAMES=t.SHARED_ATTRIBUTES.concat(`cx cy rx ry`.split(` `)),t.Ellipse.fromElement=function(e,n){var r=t.parseAttributes(e,t.Ellipse.ATTRIBUTE_NAMES);r.left=(r.left||0)-r.rx,r.top=(r.top||0)-r.ry,n(new t.Ellipse(r))},t.Ellipse.fromObject=function(e,n){t.Object._fromObject(`Ellipse`,e,n)}})(e),(function(e){var t=e.fabric||={},n=t.util.object.extend;if(t.Rect){t.warn(`fabric.Rect is already defined`);return}t.Rect=t.util.createClass(t.Object,{stateProperties:t.Object.prototype.stateProperties.concat(`rx`,`ry`),type:`rect`,rx:0,ry:0,cacheProperties:t.Object.prototype.cacheProperties.concat(`rx`,`ry`),initialize:function(e){this.callSuper(`initialize`,e),this._initRxRy()},_initRxRy:function(){this.rx&&!this.ry?this.ry=this.rx:this.ry&&!this.rx&&(this.rx=this.ry)},_render:function(e){var t=this.rx?Math.min(this.rx,this.width/2):0,n=this.ry?Math.min(this.ry,this.height/2):0,r=this.width,i=this.height,a=-this.width/2,o=-this.height/2,s=t!==0||n!==0,c=.4477152502;e.beginPath(),e.moveTo(a+t,o),e.lineTo(a+r-t,o),s&&e.bezierCurveTo(a+r-c*t,o,a+r,o+c*n,a+r,o+n),e.lineTo(a+r,o+i-n),s&&e.bezierCurveTo(a+r,o+i-c*n,a+r-c*t,o+i,a+r-t,o+i),e.lineTo(a+t,o+i),s&&e.bezierCurveTo(a+c*t,o+i,a,o+i-c*n,a,o+i-n),e.lineTo(a,o+n),s&&e.bezierCurveTo(a,o+c*n,a+c*t,o,a+t,o),e.closePath(),this._renderPaintInOrder(e)},toObject:function(e){return this.callSuper(`toObject`,[`rx`,`ry`].concat(e))},_toSVG:function(){return[`<rect `,`COMMON_PARTS`,`x="`,-this.width/2,`" y="`,-this.height/2,`" rx="`,this.rx,`" ry="`,this.ry,`" width="`,this.width,`" height="`,this.height,`" />
|
||
|
|
`]}}),t.Rect.ATTRIBUTE_NAMES=t.SHARED_ATTRIBUTES.concat(`x y rx ry width height`.split(` `)),t.Rect.fromElement=function(e,r,i){if(!e)return r(null);i||={};var a=t.parseAttributes(e,t.Rect.ATTRIBUTE_NAMES);a.left=a.left||0,a.top=a.top||0,a.height=a.height||0,a.width=a.width||0;var o=new t.Rect(n(i?t.util.object.clone(i):{},a));o.visible=o.visible&&o.width>0&&o.height>0,r(o)},t.Rect.fromObject=function(e,n){return t.Object._fromObject(`Rect`,e,n)}})(e),(function(e){var t=e.fabric||={},n=t.util.object.extend,r=t.util.array.min,i=t.util.array.max,a=t.util.toFixed,o=t.util.projectStrokeOnPoints;if(t.Polyline){t.warn(`fabric.Polyline is already defined`);return}t.Polyline=t.util.createClass(t.Object,{type:`polyline`,points:null,exactBoundingBox:!1,cacheProperties:t.Object.prototype.cacheProperties.concat(`points`),initialize:function(e,t){t||={},this.points=e||[],this.callSuper(`initialize`,t),this._setPositionDimensions(t)},_projectStrokeOnPoints:function(){return o(this.points,this,!0)},_setPositionDimensions:function(e){var t=this._calcDimensions(e),n,r=this.exactBoundingBox?this.strokeWidth:0;this.width=t.width-r,this.height=t.height-r,e.fromSVG||(n=this.translateToGivenOrigin({x:t.left-this.strokeWidth/2+r/2,y:t.top-this.strokeWidth/2+r/2},`left`,`top`,this.originX,this.originY)),e.left===void 0&&(this.left=e.fromSVG?t.left:n.x),e.top===void 0&&(this.top=e.fromSVG?t.top:n.y),this.pathOffset={x:t.left+this.width/2+r/2,y:t.top+this.height/2+r/2}},_calcDimensions:function(){var e=this.exactBoundingBox?this._projectStrokeOnPoints():this.points,t=r(e,`x`)||0,n=r(e,`y`)||0,a=i(e,`x`)||0,o=i(e,`y`)||0;return{left:t,top:n,width:a-t,height:o-n}},toObject:function(e){return n(this.callSuper(`toObject`,e),{points:this.points.concat()})},_toSVG:function(){for(var e=[],n=this.pathOffset.x,r=this.pathOffset.y,i=t.Object.NUM_FRACTION_DIGITS,o=0,s=this.points.length;o<s;o++)e.push(a(this.points[o].x-n,i),`,`,a(this.points[o].y-r,i),` `);return[`<`+this.type+` `,`COMMON_PARTS`,`points="`,e.join(``),`" />
|
||
|
|
`]},commonRender:function(e){var t,n=this.points.length,r=this.pathOffset.x,i=this.pathOffset.y;if(!n||isNaN(this.points[n-1].y))return!1;e.beginPath(),e.moveTo(this.points[0].x-r,this.points[0].y-i);for(var a=0;a<n;a++)t=this.points[a],e.lineTo(t.x-r,t.y-i);return!0},_render:function(e){this.commonRender(e)&&this._renderPaintInOrder(e)},complexity:function(){return this.get(`points`).length}}),t.Polyline.ATTRIBUTE_NAMES=t.SHARED_ATTRIBUTES.concat(),t.Polyline.fromElementGenerator=function(e){return function(r,i,a){if(!r)return i(null);a||={};var o=t.parsePointsAttribute(r.getAttribute(`points`)),s=t.parseAttributes(r,t[e].ATTRIBUTE_NAMES);s.fromSVG=!0,i(new t[e](o,n(s,a)))}},t.Polyline.fromElement=t.Polyline.fromElementGenerator(`Polyline`),t.Polyline.fromObject=function(e,n){return t.Object._fromObject(`Polyline`,e,n,`points`)}})(e),(function(e){var t=e.fabric||={},n=t.util.projectStrokeOnPoints;if(t.Polygon){t.warn(`fabric.Polygon is already defined`);return}t.Polygon=t.util.createClass(t.Polyline,{type:`polygon`,_projectStrokeOnPoints:function(){return n(this.points,this)},_render:function(e){this.commonRender(e)&&(e.closePath(),this._renderPaintInOrder(e))}}),t.Polygon.ATTRIBUTE_NAMES=t.SHARED_ATTRIBUTES.concat(),t.Polygon.fromElement=t.Polyline.fromElementGenerator(`Polygon`),t.Polygon.fromObject=function(e,n){t.Object._fromObject(`Polygon`,e,n,`points`)}})(e),(function(e){var t=e.fabric||={},n=t.util.array.min,r=t.util.array.max,i=t.util.object.extend,a=t.util.object.clone,o=t.util.toFixed;if(t.Path){t.warn(`fabric.Path is already defined`);return}t.Path=t.util.createClass(t.Object,{type:`path`,path:null,cacheProperties:t.Object.prototype.cacheProperties.concat(`path`,`fillRule`),stateProperties:t.Object.prototype.stateProperties.concat(`path`),initialize:function(e,t){t=a(t||{}),delete t.path,this.callSuper(`initialize`,t),this._setPath(e||[],t)},_setPath:function(e,n){this.path=t.util.makePathSimpler(Array.isArray(e)?e:t.util.parsePath(e)),t.Polyline.prototype._setPositionDimensions.call(this,n||{})},_renderPathCommands:function(e){var t,n=0,r=0,i=0,a=0,o=0,s=0,c=-this.pathOffset.x,l=-this.pathOffset.y;e.beginPath();for(var u=0,d=this.path.length;u<d;++u)switch(t=this.path[u],t[0]){case`L`:i=t[1],a=t[2],e.lineTo(i+c,a+l);break;case`M`:i=t[1],a=t[2],n=i,r=a,e.moveTo(i+c,a+l);break;case`C`:i=t[5],a=t[6],o=t[3],s=t[4],e.bezierCurveTo(t[1]+c,t[2]+l,o+c,s+l,i+c,a+l);break;case`Q`:e.quadraticCurveTo(t[1]+c,t[2]+l,t[3]+c,t[4]+l),i=t[3],a=t[4],o=t[1],s=t[2];break;case`z`:case`Z`:i=n,a=r,e.closePath();break}},_render:function(e){this._renderPathCommands(e),this._renderPaintInOrder(e)},toString:function(){return`#<fabric.Path (`+this.complexity()+`): { "top": `+this.top+`, "left": `+this.left+` }>`},toObject:function(e){return i(this.callSuper(`toObject`,e),{path:this.path.map(function(e){return e.slice()})})},toDatalessObject:function(e){var t=this.toObject([`sourcePath`].concat(e));return t.sourcePath&&delete t.path,t},_toSVG:function(){return[`<path `,`COMMON_PARTS`,`d="`,t.util.joinPath(this.path),`" stroke-linecap="round" `,`/>
|
||
|
|
`]},_getOffsetTransform:function(){var e=t.Object.NUM_FRACTION_DIGITS;return` translate(`+o(-this.pathOffset.x,e)+`, `+o(-this.pathOffset.y,e)+`)`},toClipPathSVG:function(e){var t=this._getOffsetTransform();return` `+this._createBaseClipPathSVGMarkup(this._toSVG(),{reviver:e,additionalTransform:t})},toSVG:function(e){var t=this._getOffsetTransform();return this._createBaseSVGMarkup(this._toSVG(),{reviver:e,additionalTransform:t})},complexity:function(){return this.path.length},_calcDimensions:function(){for(var e=[],i=[],a,o=0,s=0,c=0,l=0,u,d=0,f=this.path.length;d<f;++d){switch(a=this.path[d],a[0]){case`L`:c=a[1],l=a[2],u=[];break;case`M`:c=a[1],l=a[2],o=c,s=l,u=[];break;case`C`:u=t.util.getBoundsOfCurve(c,l,a[1],a[2],a[3],a[4],a[5],a[6]),c=a[5],l=a[6];break;case`Q`:u=t.util.getBoundsOfCurve(c,l,a[1],a[2],a[1],a[2],a[3],a[4]),c=a[3],l=a[4];break;case`z`:case`Z`:c=o,l=s;break}u.forEach(function(t){e.push(t.x),i.push(t.y)}),e.push(c),i.push(l)}var p=n(e)||0,m=n(i)||0,h=r(e)||0,g=r(i)||0;return{left:p,top:m,width:h-p,height:g-m}}}),t.Path.fromObject=function(e,n){if(typeof e.sourcePath==`string`){var r=e.sourcePath;t.loadSVGFromURL(r,function(r){var i=r[0];i.setOptions(e),e.clipPath?t.util.enlivenObjects([e.clipPath],function(e){i.clipPath=e[0],n&&n(i)}):n&&n(i)})}else t.Object._fromObject(`Path`,e,n,`path`)},t.Path.ATTRIBUTE_NAMES=t.SHARED_ATTRIBUTES.concat([`d`]),t.Path.fromElement=function(e,n,r){var a=t.parseAttributes(e,t.Path.ATTRIBUTE_NAMES);a.fromSVG=!0,n(new t.Path(a.d,i(a,r)))}})(e),(function(e){var t=e.fabric||={},n=t.util.array.min,r=t.util.array.max;t.Group||(t.Group=t.util.createClass(t.Object,t.Collection,{type:`group`,strokeWidth:0,subTargetCheck:!1,cacheProperties:[],useSetOnGroup:!1,initialize:function(e,t,n){t||={},this._objects=[],n&&this.callSuper(`initialize`,t),this._objects=e||[];for(var r=this._objects.length;r--;)this._objects[r].group=this;if(n)this._updateObjectsACoords();else{var i=t&&t.centerPoint;t.originX!==void 0&&(this.originX=t.originX),t.originY!==void 0&&(this.originY=t.originY),i||this._calcBounds(),this._updateObjectsCoords(i),delete t.centerPoint,this.callSuper(`initialize`,t)}this.setCoords()},_updateObjectsACoords:function(){for(var e=!0,t=this._objects.length;t--;)this._objects[t].setCoords(e)},_updateObjectsCoords:function(e){for(var e=e||this.getCenterPoint(),t=this._objects.length;t--;)this._updateObjectCoords(this._objects[t],e)},_updateObjectCoords:function(e,t){var n=e.left,r=e.top;e.set({left:n-t.x,top:r-t.y}),e.group=this,e.setCoords(!0)},toString:function(){return`#<fabric.Group: (`+this.complexity()+`)>`},addWithUpdate:function(e){var n=!!this.group;return this._restoreObjectsState(),t.util.resetObjectTransform(this),e&&(n&&t.util.removeTransformFromObject(e,this.group.calcTransformMatrix()),this._objects.push(e),e.group=this,e._set(`canvas`,this.canvas)),this._calcBounds(),this._updateObjectsCoords(),this.dirty=!0,n?this.group.addWithUpdate():this.setCoords(),this},removeWithUpdate:function(e){return this._restoreObjectsState(),t.util.resetObjectTransform(this),this.remove(e),this._calcBounds(),this._updateObjectsCoords(),this.setCoords(),this.dirty=!0,this},_onObjectAdded:function(e){this.dirty=!0,e.group=this,e._set(`canvas`,this.canvas)},_onObjectRemoved:function(e){this.dirty=!0,delete e.group},_set:function(e,n){var r=this._objects.length;if(this.useSetOnGroup)for(;r--;)this._objects[r].setOnGroup(e,n);if(e===`canvas`)for(;r--;)this._objects[r]._set(e,n);t.Object.prototype._set.call(this,e,n)},toObject:function(e){var n=this.includeDefaultValues,r=this._objects.filter(function(e){return!e.excludeFromExport}).map(function(t){var r=t.includeDefaultValues;t.includeDefaultValues=n;var i=t.toObject(e);return t.includeDefaultValues=r,i}),i=t.Object.prototype.toObject.call(this,e);return i.objects=r,i},toDatalessObject:function(e){var n,r=this.sourcePath;if(r)n=r;else{var i=this.includeDefaultValues;n=this._objects.map(function(t){var n=t.includeDefaultValues;t.includeDefaultValues=i;var r=t.toDatalessObject(e);return t.includeDefaultValues=n,r})}var a=t.Object.prototype
|
||
|
|
`],n=0,r=this._objects.length;n<r;n++)t.push(` `,this._objects[n].toSVG(e));return t.push(`</g>
|
||
|
|
`),t},getSvgStyles:function(){var e=this.opacity!==void 0&&this.opacity!==1?`opacity: `+this.opacity+`;`:``,t=this.visible?``:` visibility: hidden;`;return[e,this.getSvgFilter(),t].join(``)},toClipPathSVG:function(e){for(var t=[],n=0,r=this._objects.length;n<r;n++)t.push(` `,this._objects[n].toClipPathSVG(e));return this._createBaseClipPathSVGMarkup(t,{reviver:e})}}),t.Group.fromObject=function(e,n){var r=e.objects,i=t.util.object.clone(e,!0);if(delete i.objects,typeof r==`string`){t.loadSVGFromURL(r,function(a){var o=t.util.groupSVGElements(a,e,r),s=i.clipPath;delete i.clipPath,o.set(i),s?t.util.enlivenObjects([s],function(e){o.clipPath=e[0],n&&n(o)}):n&&n(o)});return}t.util.enlivenObjects(r,function(r){t.util.enlivenObjectEnlivables(e,i,function(){n&&n(new t.Group(r,i,!0))})})})})(e),(function(e){var t=e.fabric||={};t.ActiveSelection||(t.ActiveSelection=t.util.createClass(t.Group,{type:`activeSelection`,initialize:function(e,n){n||={},this._objects=e||[];for(var r=this._objects.length;r--;)this._objects[r].group=this;n.originX&&(this.originX=n.originX),n.originY&&(this.originY=n.originY),this._calcBounds(),this._updateObjectsCoords(),t.Object.prototype.initialize.call(this,n),this.setCoords()},toGroup:function(){var e=this._objects.concat();this._objects=[];var n=t.Object.prototype.toObject.call(this),r=new t.Group([]);if(delete n.type,r.set(n),e.forEach(function(e){e.canvas.remove(e),e.group=r}),r._objects=e,!this.canvas)return r;var i=this.canvas;return i.add(r),i._activeObject=r,r.setCoords(),r},onDeselect:function(){return this.destroy(),!1},toString:function(){return`#<fabric.ActiveSelection: (`+this.complexity()+`)>`},shouldCache:function(){return!1},isOnACache:function(){return!1},_renderControls:function(e,t,n){e.save(),e.globalAlpha=this.isMoving?this.borderOpacityWhenMoving:1,n||={},n.hasControls===void 0&&(n.hasControls=!1),n.forActiveSelection=!0;for(var r=0,i=this._objects.length;r<i;r++)this._objects[r]._renderControls(e,n);this.callSuper(`_renderControls`,e,t),e.restore()}}),t.ActiveSelection.fromObject=function(e,n){t.util.enlivenObjects(e.objects,function(r){delete e.objects,n&&n(new t.ActiveSelection(r,e,!0))})})})(e),(function(e){var n=t.util.object.extend;if(e.fabric||={},e.fabric.Image){t.warn(`fabric.Image is already defined.`);return}t.Image=t.util.createClass(t.Object,{type:`image`,strokeWidth:0,srcFromAttribute:!1,_lastScaleX:1,_lastScaleY:1,_filterScalingX:1,_filterScalingY:1,minimumScaleTrigger:.5,stateProperties:t.Object.prototype.stateProperties.concat(`cropX`,`cropY`),cacheProperties:t.Object.prototype.cacheProperties.concat(`cropX`,`cropY`),cacheKey:``,cropX:0,cropY:0,imageSmoothing:!0,initialize:function(e,n){n||={},this.filters=[],this.cacheKey=`texture`+ t.Object.__uid++,this.callSuper(`initialize`,n),this._initElement(e,n)},getElement:function(){return this._element||{}},setElement:function(e,t){return this.removeTexture(this.cacheKey),this.removeTexture(this.cacheKey+`_filtered`),this._element=e,this._originalElement=e,this._initConfig(t),this.filters.length!==0&&this.applyFilters(),this.resizeFilter&&this.applyResizeFilters(),this},removeTexture:function(e){var n=t.filterBackend;n&&n.evictCachesForKey&&n.evictCachesForKey(e)},dispose:function(){this.callSuper(`dispose`),this.removeTexture(this.cacheKey),this.removeTexture(this.cacheKey+`_filtered`),this._cacheContext=void 0,[`_originalElement`,`_element`,`_filteredEl`,`_cacheCanvas`].forEach((function(e){t.util.cleanUpJsdomNode(this[e]),this[e]=void 0}).bind(this))},getCrossOrigin:function(){return this._originalElement&&(this._originalElement.crossOrigin||null)},getOriginalSize:function(){var e=this.getElement();return{width:e.naturalWidth||e.width,height:e.naturalHeight||e.height}},_stroke:function(e){if(!(!this.stroke||this.strokeWidth===0)){var t=this.width/2,n=this.height/2;e.beginPath(),e.moveTo(-t,-n),e.lineTo(t,-n),e.lineTo(t,n),e.lineTo(-t,n),e.lineTo(-t,-n),e.closePath()}},toObject:function(e){var t=[];this.filters.forEach(function(e){e&&t.push(e.toObject())});var r=n(this.callSuper(`toObject`,[`cropX`,`cropY`].concat(e))
|
||
|
|
`,` <rect x="`+a+`" y="`+o+`" width="`+this.width+`" height="`+this.height+`" />
|
||
|
|
`,`</clipPath>
|
||
|
|
`),s=` clip-path="url(#imageCrop_`+l+`)" `}if(this.imageSmoothing||(c=`" image-rendering="optimizeSpeed`),n.push(` <image `,`COMMON_PARTS`,`xlink:href="`,this.getSvgSrc(!0),`" x="`,a-this.cropX,`" y="`,o-this.cropY,`" width="`,i.width||i.naturalWidth,`" height="`,i.height||i.height,c,`"`,s,`></image>
|
||
|
|
`),this.stroke||this.strokeDashArray){var u=this.fill;this.fill=null,r=[` <rect `,`x="`,a,`" y="`,o,`" width="`,this.width,`" height="`,this.height,`" style="`,this.getSvgStyles(),`"/>
|
||
|
|
`],this.fill=u}return e=this.paintFirst===`fill`?e.concat(n,r):e.concat(r,n),e},getSrc:function(e){var t=e?this._element:this._originalElement;return t?t.toDataURL?t.toDataURL():this.srcFromAttribute?t.getAttribute(`src`):t.src:this.src||``},setSrc:function(e,n,r){return t.util.loadImage(e,function(e,t){this.setElement(e,r),this._setWidthHeight(),n&&n(this,t)},this,r&&r.crossOrigin),this},toString:function(){return`#<fabric.Image: { src: "`+this.getSrc()+`" }>`},applyResizeFilters:function(){var e=this.resizeFilter,n=this.minimumScaleTrigger,r=this.getTotalObjectScaling(),i=r.scaleX,a=r.scaleY,o=this._filteredEl||this._originalElement;if(this.group&&this.set(`dirty`,!0),!e||i>n&&a>n){this._element=o,this._filterScalingX=1,this._filterScalingY=1,this._lastScaleX=i,this._lastScaleY=a;return}t.filterBackend||=t.initFilterBackend();var s=t.util.createCanvasElement(),c=this._filteredEl?this.cacheKey+`_filtered`:this.cacheKey,l=o.width,u=o.height;s.width=l,s.height=u,this._element=s,this._lastScaleX=e.scaleX=i,this._lastScaleY=e.scaleY=a,t.filterBackend.applyFilters([e],o,l,u,this._element,c),this._filterScalingX=s.width/this._originalElement.width,this._filterScalingY=s.height/this._originalElement.height},applyFilters:function(e){if(e=e||this.filters||[],e=e.filter(function(e){return e&&!e.isNeutralState()}),this.set(`dirty`,!0),this.removeTexture(this.cacheKey+`_filtered`),e.length===0)return this._element=this._originalElement,this._filteredEl=null,this._filterScalingX=1,this._filterScalingY=1,this;var n=this._originalElement,r=n.naturalWidth||n.width,i=n.naturalHeight||n.height;if(this._element===this._originalElement){var a=t.util.createCanvasElement();a.width=r,a.height=i,this._element=a,this._filteredEl=a}else this._element=this._filteredEl,this._filteredEl.getContext(`2d`).clearRect(0,0,r,i),this._lastScaleX=1,this._lastScaleY=1;return t.filterBackend||=t.initFilterBackend(),t.filterBackend.applyFilters(e,this._originalElement,r,i,this._element,this.cacheKey),(this._originalElement.width!==this._element.width||this._originalElement.height!==this._element.height)&&(this._filterScalingX=this._element.width/this._originalElement.width,this._filterScalingY=this._element.height/this._originalElement.height),this},_render:function(e){t.util.setImageSmoothing(e,this.imageSmoothing),this.isMoving!==!0&&this.resizeFilter&&this._needsResize()&&this.applyResizeFilters(),this._stroke(e),this._renderPaintInOrder(e)},drawCacheOnCanvas:function(e){t.util.setImageSmoothing(e,this.imageSmoothing),t.Object.prototype.drawCacheOnCanvas.call(this,e)},shouldCache:function(){return this.needsItsOwnCache()},_renderFill:function(e){var t=this._element;if(t){var n=this._filterScalingX,r=this._filterScalingY,i=this.width,a=this.height,o=Math.min,s=Math.max,c=s(this.cropX,0),l=s(this.cropY,0),u=t.naturalWidth||t.width,d=t.naturalHeight||t.height,f=c*n,p=l*r,m=o(i*n,u-f),h=o(a*r,d-p),g=-i/2,_=-a/2,v=o(i,u/n-c),y=o(a,d/r-l);t&&e.drawImage(t,f,p,m,h,g,_,v,y)}},_needsResize:function(){var e=this.getTotalObjectScaling();return e.scaleX!==this._lastScaleX||e.scaleY!==this._lastScaleY},_resetWidthHeight:function(){this.set(this.getOriginalSize())},_initElement:function(e,n){this.setElement(t.util.getById(e),n),t.util.addClass(this.getElement(),t.Image.CSS_CANVAS)},_initConfig:function(e){e||={},this.setOptions(e),this._setWidthHeight(e)},_initFilters:function(e,n){e&&e.length?t.util.enlivenObjects(e,function(e){n&&n(e)},`fabric.Image.filters`):n&&n()},_setWidthHeight:function(e){e||={};var t=this.getElement();this.width=e.width||t.naturalWidth||t.width||0,this.height=e.height||t.naturalHeight||t.height||0},parsePreserveAspectRatioAttribute:function(){var e=t.util.parsePreserveAspectRatioAttribute(this.preserveAspectRatio||``),n=this._element.width,r=this._element.height,i=1,a=1,o=0,s=0,c=0,l=0,u,d=this.width,f=this.height,p={width:d,height:f};return e&&(e.alignX!==`none`||e.alignY!==`none`)?(e.meetOrSlice===`meet`&&(i=a=t.util.findScaleToFit(this._element,p),u=(d-n*i)/2,e.alignX===`Min`&&(o=-u),e.alignX===`Max`&&(o=u),u=(f-r*a)/2,e.alignY===`Min`&&(s=
|
||
|
|
void main(){}`,r=e.createShader(e.FRAGMENT_SHADER);return e.shaderSource(r,n),e.compileShader(r),!!e.getShaderParameter(r,e.COMPILE_STATUS)}t.isWebglSupported=function(n){if(t.isLikelyNode)return!1;n||=t.WebglFilterBackend.prototype.tileSize;var r=document.createElement(`canvas`),i=r.getContext(`webgl`)||r.getContext(`experimental-webgl`),a=!1;if(i){t.maxTextureSize=i.getParameter(i.MAX_TEXTURE_SIZE),a=t.maxTextureSize>=n;for(var o=[`highp`,`mediump`,`lowp`],s=0;s<3;s++)if(e(i,o[s])){t.webGlPrecision=o[s];break}}return this.isSupported=a,a},t.WebglFilterBackend=n;function n(e){e&&e.tileSize&&(this.tileSize=e.tileSize),this.setupGLContext(this.tileSize,this.tileSize),this.captureGPUInfo()}n.prototype={tileSize:2048,resources:{},setupGLContext:function(e,t){this.dispose(),this.createWebGLCanvas(e,t),this.aPosition=new Float32Array([0,0,0,1,1,0,1,1]),this.chooseFastestCopyGLTo2DMethod(e,t)},chooseFastestCopyGLTo2DMethod:function(e,n){var r=window.performance!==void 0,o;try{new ImageData(1,1),o=!0}catch{o=!1}if(r&&o&&typeof ArrayBuffer<`u`&&typeof Uint8ClampedArray<`u`){var s=t.util.createCanvasElement(),c=new ArrayBuffer(e*n*4);if(t.forceGLPutImageData){this.imageBuffer=c,this.copyGLTo2D=a;return}var l={imageBuffer:c,destinationWidth:e,destinationHeight:n,targetCanvas:s},u,d,f;s.width=e,s.height=n,u=window.performance.now(),i.call(l,this.gl,l),d=window.performance.now()-u,u=window.performance.now(),a.call(l,this.gl,l),f=window.performance.now()-u,d>f?(this.imageBuffer=c,this.copyGLTo2D=a):this.copyGLTo2D=i}},createWebGLCanvas:function(e,n){var r=t.util.createCanvasElement();r.width=e,r.height=n;var i={alpha:!0,premultipliedAlpha:!1,depth:!1,stencil:!1,antialias:!1},a=r.getContext(`webgl`,i);a||=r.getContext(`experimental-webgl`,i),a&&(a.clearColor(0,0,0,0),this.canvas=r,this.gl=a)},applyFilters:function(e,t,n,i,a,o){var s=this.gl,c;o&&(c=this.getCachedTexture(o,t));var l={originalWidth:t.width||t.originalWidth,originalHeight:t.height||t.originalHeight,sourceWidth:n,sourceHeight:i,destinationWidth:n,destinationHeight:i,context:s,sourceTexture:this.createTexture(s,n,i,!c&&t),targetTexture:this.createTexture(s,n,i),originalTexture:c||this.createTexture(s,n,i,!c&&t),passes:e.length,webgl:!0,aPosition:this.aPosition,programCache:this.programCache,pass:0,filterBackend:this,targetCanvas:a},u=s.createFramebuffer();return s.bindFramebuffer(s.FRAMEBUFFER,u),e.forEach(function(e){e&&e.applyTo(l)}),r(l),this.copyGLTo2D(s,l),s.bindTexture(s.TEXTURE_2D,null),s.deleteTexture(l.sourceTexture),s.deleteTexture(l.targetTexture),s.deleteFramebuffer(u),a.getContext(`2d`).setTransform(1,0,0,1,0,0),l},dispose:function(){this.canvas&&(this.canvas=null,this.gl=null),this.clearWebGLCaches()},clearWebGLCaches:function(){this.programCache={},this.textureCache={}},createTexture:function(e,t,n,r,i){var a=e.createTexture();return e.bindTexture(e.TEXTURE_2D,a),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,i||e.NEAREST),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,i||e.NEAREST),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE),r?e.texImage2D(e.TEXTURE_2D,0,e.RGBA,e.RGBA,e.UNSIGNED_BYTE,r):e.texImage2D(e.TEXTURE_2D,0,e.RGBA,t,n,0,e.RGBA,e.UNSIGNED_BYTE,null),a},getCachedTexture:function(e,t){if(this.textureCache[e])return this.textureCache[e];var n=this.createTexture(this.gl,t.width,t.height,t);return this.textureCache[e]=n,n},evictCachesForKey:function(e){this.textureCache[e]&&(this.gl.deleteTexture(this.textureCache[e]),delete this.textureCache[e])},copyGLTo2D:i,captureGPUInfo:function(){if(this.gpuInfo)return this.gpuInfo;var e=this.gl,t={renderer:``,vendor:``};if(!e)return t;var n=e.getExtension(`WEBGL_debug_renderer_info`);if(n){var r=e.getParameter(n.UNMASKED_RENDERER_WEBGL),i=e.getParameter(n.UNMASKED_VENDOR_WEBGL);r&&(t.renderer=r.toLowerCase()),i&&(t.vendor=i.toLowerCase())}return this.gpuInfo=t,t}}})();function r(e){var t=e.targetCanvas,n=t.width,r=t.height,i=e.destinationWidth,a=e.destinationHeight;(n!==i||r!==a)&&(t.width=i,t.height=a)}function i(e,t){var n=e.c
|
||
|
|
varying vec2 vTexCoord;
|
||
|
|
void main() {
|
||
|
|
vTexCoord = aPosition;
|
||
|
|
gl_Position = vec4(aPosition * 2.0 - 1.0, 0.0, 1.0);
|
||
|
|
}`,fragmentSource:`precision highp float;
|
||
|
|
varying vec2 vTexCoord;
|
||
|
|
uniform sampler2D uTexture;
|
||
|
|
void main() {
|
||
|
|
gl_FragColor = texture2D(uTexture, vTexCoord);
|
||
|
|
}`,initialize:function(e){e&&this.setOptions(e)},setOptions:function(e){for(var t in e)this[t]=e[t]},createProgram:function(e,n,r){n||=this.fragmentSource,r||=this.vertexSource,t.webGlPrecision!==`highp`&&(n=n.replace(/precision highp float/g,`precision `+t.webGlPrecision+` float`));var i=e.createShader(e.VERTEX_SHADER);if(e.shaderSource(i,r),e.compileShader(i),!e.getShaderParameter(i,e.COMPILE_STATUS))throw Error(`Vertex shader compile error for `+this.type+`: `+e.getShaderInfoLog(i));var a=e.createShader(e.FRAGMENT_SHADER);if(e.shaderSource(a,n),e.compileShader(a),!e.getShaderParameter(a,e.COMPILE_STATUS))throw Error(`Fragment shader compile error for `+this.type+`: `+e.getShaderInfoLog(a));var o=e.createProgram();if(e.attachShader(o,i),e.attachShader(o,a),e.linkProgram(o),!e.getProgramParameter(o,e.LINK_STATUS))throw Error('Shader link error for "${this.type}" '+e.getProgramInfoLog(o));var s=this.getAttributeLocations(e,o),c=this.getUniformLocations(e,o)||{};return c.uStepW=e.getUniformLocation(o,`uStepW`),c.uStepH=e.getUniformLocation(o,`uStepH`),{program:o,attributeLocations:s,uniformLocations:c}},getAttributeLocations:function(e,t){return{aPosition:e.getAttribLocation(t,`aPosition`)}},getUniformLocations:function(){return{}},sendAttributeData:function(e,t,n){var r=t.aPosition,i=e.createBuffer();e.bindBuffer(e.ARRAY_BUFFER,i),e.enableVertexAttribArray(r),e.vertexAttribPointer(r,2,e.FLOAT,!1,0,0),e.bufferData(e.ARRAY_BUFFER,n,e.STATIC_DRAW)},_setupFrameBuffer:function(e){var t=e.context,n,r;e.passes>1?(n=e.destinationWidth,r=e.destinationHeight,(e.sourceWidth!==n||e.sourceHeight!==r)&&(t.deleteTexture(e.targetTexture),e.targetTexture=e.filterBackend.createTexture(t,n,r)),t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,e.targetTexture,0)):(t.bindFramebuffer(t.FRAMEBUFFER,null),t.finish())},_swapTextures:function(e){e.passes--,e.pass++;var t=e.targetTexture;e.targetTexture=e.sourceTexture,e.sourceTexture=t},isNeutralState:function(){var e=this.mainParameter,n=t.Image.filters[this.type].prototype;if(e)if(Array.isArray(n[e])){for(var r=n[e].length;r--;)if(this[e][r]!==n[e][r])return!1;return!0}else return n[e]===this[e];else return!1},applyTo:function(e){e.webgl?(this._setupFrameBuffer(e),this.applyToWebGL(e),this._swapTextures(e)):this.applyTo2d(e)},retrieveShader:function(e){return e.programCache.hasOwnProperty(this.type)||(e.programCache[this.type]=this.createProgram(e.context)),e.programCache[this.type]},applyToWebGL:function(e){var t=e.context,n=this.retrieveShader(e);e.pass===0&&e.originalTexture?t.bindTexture(t.TEXTURE_2D,e.originalTexture):t.bindTexture(t.TEXTURE_2D,e.sourceTexture),t.useProgram(n.program),this.sendAttributeData(t,n.attributeLocations,e.aPosition),t.uniform1f(n.uniformLocations.uStepW,1/e.sourceWidth),t.uniform1f(n.uniformLocations.uStepH,1/e.sourceHeight),this.sendUniformData(t,n.uniformLocations),t.viewport(0,0,e.destinationWidth,e.destinationHeight),t.drawArrays(t.TRIANGLE_STRIP,0,4)},bindAdditionalTexture:function(e,t,n){e.activeTexture(n),e.bindTexture(e.TEXTURE_2D,t),e.activeTexture(e.TEXTURE0)},unbindAdditionalTexture:function(e,t){e.activeTexture(t),e.bindTexture(e.TEXTURE_2D,null),e.activeTexture(e.TEXTURE0)},getMainParameter:function(){return this[this.mainParameter]},setMainParameter:function(e){this[this.mainParameter]=e},sendUniformData:function(){},createHelpLayer:function(e){if(!e.helpLayer){var t=document.createElement(`canvas`);t.width=e.sourceWidth,t.height=e.sourceHeight,e.helpLayer=t}},toObject:function(){var e={type:this.type},t=this.mainParameter;return t&&(e[t]=this[t]),e},toJSON:function(){return this.toObject()}}),t.Image.filters.BaseFilter.fromObject=function(e,n){var r=new t.Image.filters[e.type](e);return n&&n(r),r},(function(e){var t=e.fabric||={},n=t.Image.filters,r=t.util.createClass;n.ColorMatrix=r(n.BaseFilter,{type:`ColorMatrix`,fragmentSource:`precision highp float;
|
||
|
|
uniform sampler2D uTexture;
|
||
|
|
varying vec2 vTexCoord;
|
||
|
|
uniform mat4 uColorMatrix;
|
||
|
|
uniform vec4 uConstants;
|
||
|
|
void main() {
|
||
|
|
vec4 color = texture2D(uTexture, vTexCoord);
|
||
|
|
color *= uColorMatrix;
|
||
|
|
color += uConstants;
|
||
|
|
gl_FragColor = color;
|
||
|
|
}`,matrix:[1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1,0],mainParameter:`matrix`,colorsOnly:!0,initialize:function(e){this.callSuper(`initialize`,e),this.matrix=this.matrix.slice(0)},applyTo2d:function(e){var t=e.imageData.data,n=t.length,r=this.matrix,i,a,o,s,c,l=this.colorsOnly;for(c=0;c<n;c+=4)i=t[c],a=t[c+1],o=t[c+2],l?(t[c]=i*r[0]+a*r[1]+o*r[2]+r[4]*255,t[c+1]=i*r[5]+a*r[6]+o*r[7]+r[9]*255,t[c+2]=i*r[10]+a*r[11]+o*r[12]+r[14]*255):(s=t[c+3],t[c]=i*r[0]+a*r[1]+o*r[2]+s*r[3]+r[4]*255,t[c+1]=i*r[5]+a*r[6]+o*r[7]+s*r[8]+r[9]*255,t[c+2]=i*r[10]+a*r[11]+o*r[12]+s*r[13]+r[14]*255,t[c+3]=i*r[15]+a*r[16]+o*r[17]+s*r[18]+r[19]*255)},getUniformLocations:function(e,t){return{uColorMatrix:e.getUniformLocation(t,`uColorMatrix`),uConstants:e.getUniformLocation(t,`uConstants`)}},sendUniformData:function(e,t){var n=this.matrix,r=[n[0],n[1],n[2],n[3],n[5],n[6],n[7],n[8],n[10],n[11],n[12],n[13],n[15],n[16],n[17],n[18]],i=[n[4],n[9],n[14],n[19]];e.uniformMatrix4fv(t.uColorMatrix,!1,r),e.uniform4fv(t.uConstants,i)}}),t.Image.filters.ColorMatrix.fromObject=t.Image.filters.BaseFilter.fromObject})(e),(function(e){var t=e.fabric||={},n=t.Image.filters,r=t.util.createClass;n.Brightness=r(n.BaseFilter,{type:`Brightness`,fragmentSource:`precision highp float;
|
||
|
|
uniform sampler2D uTexture;
|
||
|
|
uniform float uBrightness;
|
||
|
|
varying vec2 vTexCoord;
|
||
|
|
void main() {
|
||
|
|
vec4 color = texture2D(uTexture, vTexCoord);
|
||
|
|
color.rgb += uBrightness;
|
||
|
|
gl_FragColor = color;
|
||
|
|
}`,brightness:0,mainParameter:`brightness`,applyTo2d:function(e){if(this.brightness!==0){var t=e.imageData.data,n,r=t.length,i=Math.round(this.brightness*255);for(n=0;n<r;n+=4)t[n]=t[n]+i,t[n+1]=t[n+1]+i,t[n+2]=t[n+2]+i}},getUniformLocations:function(e,t){return{uBrightness:e.getUniformLocation(t,`uBrightness`)}},sendUniformData:function(e,t){e.uniform1f(t.uBrightness,this.brightness)}}),t.Image.filters.Brightness.fromObject=t.Image.filters.BaseFilter.fromObject})(e),(function(e){var t=e.fabric||={},n=t.util.object.extend,r=t.Image.filters,i=t.util.createClass;r.Convolute=i(r.BaseFilter,{type:`Convolute`,opaque:!1,matrix:[0,0,0,0,1,0,0,0,0],fragmentSource:{Convolute_3_1:`precision highp float;
|
||
|
|
uniform sampler2D uTexture;
|
||
|
|
uniform float uMatrix[9];
|
||
|
|
uniform float uStepW;
|
||
|
|
uniform float uStepH;
|
||
|
|
varying vec2 vTexCoord;
|
||
|
|
void main() {
|
||
|
|
vec4 color = vec4(0, 0, 0, 0);
|
||
|
|
for (float h = 0.0; h < 3.0; h+=1.0) {
|
||
|
|
for (float w = 0.0; w < 3.0; w+=1.0) {
|
||
|
|
vec2 matrixPos = vec2(uStepW * (w - 1), uStepH * (h - 1));
|
||
|
|
color += texture2D(uTexture, vTexCoord + matrixPos) * uMatrix[int(h * 3.0 + w)];
|
||
|
|
}
|
||
|
|
}
|
||
|
|
gl_FragColor = color;
|
||
|
|
}`,Convolute_3_0:`precision highp float;
|
||
|
|
uniform sampler2D uTexture;
|
||
|
|
uniform float uMatrix[9];
|
||
|
|
uniform float uStepW;
|
||
|
|
uniform float uStepH;
|
||
|
|
varying vec2 vTexCoord;
|
||
|
|
void main() {
|
||
|
|
vec4 color = vec4(0, 0, 0, 1);
|
||
|
|
for (float h = 0.0; h < 3.0; h+=1.0) {
|
||
|
|
for (float w = 0.0; w < 3.0; w+=1.0) {
|
||
|
|
vec2 matrixPos = vec2(uStepW * (w - 1.0), uStepH * (h - 1.0));
|
||
|
|
color.rgb += texture2D(uTexture, vTexCoord + matrixPos).rgb * uMatrix[int(h * 3.0 + w)];
|
||
|
|
}
|
||
|
|
}
|
||
|
|
float alpha = texture2D(uTexture, vTexCoord).a;
|
||
|
|
gl_FragColor = color;
|
||
|
|
gl_FragColor.a = alpha;
|
||
|
|
}`,Convolute_5_1:`precision highp float;
|
||
|
|
uniform sampler2D uTexture;
|
||
|
|
uniform float uMatrix[25];
|
||
|
|
uniform float uStepW;
|
||
|
|
uniform float uStepH;
|
||
|
|
varying vec2 vTexCoord;
|
||
|
|
void main() {
|
||
|
|
vec4 color = vec4(0, 0, 0, 0);
|
||
|
|
for (float h = 0.0; h < 5.0; h+=1.0) {
|
||
|
|
for (float w = 0.0; w < 5.0; w+=1.0) {
|
||
|
|
vec2 matrixPos = vec2(uStepW * (w - 2.0), uStepH * (h - 2.0));
|
||
|
|
color += texture2D(uTexture, vTexCoord + matrixPos) * uMatrix[int(h * 5.0 + w)];
|
||
|
|
}
|
||
|
|
}
|
||
|
|
gl_FragColor = color;
|
||
|
|
}`,Convolute_5_0:`precision highp float;
|
||
|
|
uniform sampler2D uTexture;
|
||
|
|
uniform float uMatrix[25];
|
||
|
|
uniform float uStepW;
|
||
|
|
uniform float uStepH;
|
||
|
|
varying vec2 vTexCoord;
|
||
|
|
void main() {
|
||
|
|
vec4 color = vec4(0, 0, 0, 1);
|
||
|
|
for (float h = 0.0; h < 5.0; h+=1.0) {
|
||
|
|
for (float w = 0.0; w < 5.0; w+=1.0) {
|
||
|
|
vec2 matrixPos = vec2(uStepW * (w - 2.0), uStepH * (h - 2.0));
|
||
|
|
color.rgb += texture2D(uTexture, vTexCoord + matrixPos).rgb * uMatrix[int(h * 5.0 + w)];
|
||
|
|
}
|
||
|
|
}
|
||
|
|
float alpha = texture2D(uTexture, vTexCoord).a;
|
||
|
|
gl_FragColor = color;
|
||
|
|
gl_FragColor.a = alpha;
|
||
|
|
}`,Convolute_7_1:`precision highp float;
|
||
|
|
uniform sampler2D uTexture;
|
||
|
|
uniform float uMatrix[49];
|
||
|
|
uniform float uStepW;
|
||
|
|
uniform float uStepH;
|
||
|
|
varying vec2 vTexCoord;
|
||
|
|
void main() {
|
||
|
|
vec4 color = vec4(0, 0, 0, 0);
|
||
|
|
for (float h = 0.0; h < 7.0; h+=1.0) {
|
||
|
|
for (float w = 0.0; w < 7.0; w+=1.0) {
|
||
|
|
vec2 matrixPos = vec2(uStepW * (w - 3.0), uStepH * (h - 3.0));
|
||
|
|
color += texture2D(uTexture, vTexCoord + matrixPos) * uMatrix[int(h * 7.0 + w)];
|
||
|
|
}
|
||
|
|
}
|
||
|
|
gl_FragColor = color;
|
||
|
|
}`,Convolute_7_0:`precision highp float;
|
||
|
|
uniform sampler2D uTexture;
|
||
|
|
uniform float uMatrix[49];
|
||
|
|
uniform float uStepW;
|
||
|
|
uniform float uStepH;
|
||
|
|
varying vec2 vTexCoord;
|
||
|
|
void main() {
|
||
|
|
vec4 color = vec4(0, 0, 0, 1);
|
||
|
|
for (float h = 0.0; h < 7.0; h+=1.0) {
|
||
|
|
for (float w = 0.0; w < 7.0; w+=1.0) {
|
||
|
|
vec2 matrixPos = vec2(uStepW * (w - 3.0), uStepH * (h - 3.0));
|
||
|
|
color.rgb += texture2D(uTexture, vTexCoord + matrixPos).rgb * uMatrix[int(h * 7.0 + w)];
|
||
|
|
}
|
||
|
|
}
|
||
|
|
float alpha = texture2D(uTexture, vTexCoord).a;
|
||
|
|
gl_FragColor = color;
|
||
|
|
gl_FragColor.a = alpha;
|
||
|
|
}`,Convolute_9_1:`precision highp float;
|
||
|
|
uniform sampler2D uTexture;
|
||
|
|
uniform float uMatrix[81];
|
||
|
|
uniform float uStepW;
|
||
|
|
uniform float uStepH;
|
||
|
|
varying vec2 vTexCoord;
|
||
|
|
void main() {
|
||
|
|
vec4 color = vec4(0, 0, 0, 0);
|
||
|
|
for (float h = 0.0; h < 9.0; h+=1.0) {
|
||
|
|
for (float w = 0.0; w < 9.0; w+=1.0) {
|
||
|
|
vec2 matrixPos = vec2(uStepW * (w - 4.0), uStepH * (h - 4.0));
|
||
|
|
color += texture2D(uTexture, vTexCoord + matrixPos) * uMatrix[int(h * 9.0 + w)];
|
||
|
|
}
|
||
|
|
}
|
||
|
|
gl_FragColor = color;
|
||
|
|
}`,Convolute_9_0:`precision highp float;
|
||
|
|
uniform sampler2D uTexture;
|
||
|
|
uniform float uMatrix[81];
|
||
|
|
uniform float uStepW;
|
||
|
|
uniform float uStepH;
|
||
|
|
varying vec2 vTexCoord;
|
||
|
|
void main() {
|
||
|
|
vec4 color = vec4(0, 0, 0, 1);
|
||
|
|
for (float h = 0.0; h < 9.0; h+=1.0) {
|
||
|
|
for (float w = 0.0; w < 9.0; w+=1.0) {
|
||
|
|
vec2 matrixPos = vec2(uStepW * (w - 4.0), uStepH * (h - 4.0));
|
||
|
|
color.rgb += texture2D(uTexture, vTexCoord + matrixPos).rgb * uMatrix[int(h * 9.0 + w)];
|
||
|
|
}
|
||
|
|
}
|
||
|
|
float alpha = texture2D(uTexture, vTexCoord).a;
|
||
|
|
gl_FragColor = color;
|
||
|
|
gl_FragColor.a = alpha;
|
||
|
|
}`},retrieveShader:function(e){var t=Math.sqrt(this.matrix.length),n=this.type+`_`+t+`_`+ +!!this.opaque,r=this.fragmentSource[n];return e.programCache.hasOwnProperty(n)||(e.programCache[n]=this.createProgram(e.context,r)),e.programCache[n]},applyTo2d:function(e){var t=e.imageData,n=t.data,r=this.matrix,i=Math.round(Math.sqrt(r.length)),a=Math.floor(i/2),o=t.width,s=t.height,c=e.ctx.createImageData(o,s),l=c.data,u=+!!this.opaque,d,f,p,m,h,g,_,v,y,b,x,S,C;for(x=0;x<s;x++)for(b=0;b<o;b++){for(h=(x*o+b)*4,d=0,f=0,p=0,m=0,C=0;C<i;C++)for(S=0;S<i;S++)_=x+C-a,g=b+S-a,!(_<0||_>=s||g<0||g>=o)&&(v=(_*o+g)*4,y=r[C*i+S],d+=n[v]*y,f+=n[v+1]*y,p+=n[v+2]*y,u||(m+=n[v+3]*y));l[h]=d,l[h+1]=f,l[h+2]=p,u?l[h+3]=n[h+3]:l[h+3]=m}e.imageData=c},getUniformLocations:function(e,t){return{uMatrix:e.getUniformLocation(t,`uMatrix`),uOpaque:e.getUniformLocation(t,`uOpaque`),uHalfSize:e.getUniformLocation(t,`uHalfSize`),uSize:e.getUniformLocation(t,`uSize`)}},sendUniformData:function(e,t){e.uniform1fv(t.uMatrix,this.matrix)},toObject:function(){return n(this.callSuper(`toObject`),{opaque:this.opaque,matrix:this.matrix})}}),t.Image.filters.Convolute.fromObject=t.Image.filters.BaseFilter.fromObject})(e),(function(e){var t=e.fabric||={},n=t.Image.filters,r=t.util.createClass;n.Grayscale=r(n.BaseFilter,{type:`Grayscale`,fragmentSource:{average:`precision highp float;
|
||
|
|
uniform sampler2D uTexture;
|
||
|
|
varying vec2 vTexCoord;
|
||
|
|
void main() {
|
||
|
|
vec4 color = texture2D(uTexture, vTexCoord);
|
||
|
|
float average = (color.r + color.b + color.g) / 3.0;
|
||
|
|
gl_FragColor = vec4(average, average, average, color.a);
|
||
|
|
}`,lightness:`precision highp float;
|
||
|
|
uniform sampler2D uTexture;
|
||
|
|
uniform int uMode;
|
||
|
|
varying vec2 vTexCoord;
|
||
|
|
void main() {
|
||
|
|
vec4 col = texture2D(uTexture, vTexCoord);
|
||
|
|
float average = (max(max(col.r, col.g),col.b) + min(min(col.r, col.g),col.b)) / 2.0;
|
||
|
|
gl_FragColor = vec4(average, average, average, col.a);
|
||
|
|
}`,luminosity:`precision highp float;
|
||
|
|
uniform sampler2D uTexture;
|
||
|
|
uniform int uMode;
|
||
|
|
varying vec2 vTexCoord;
|
||
|
|
void main() {
|
||
|
|
vec4 col = texture2D(uTexture, vTexCoord);
|
||
|
|
float average = 0.21 * col.r + 0.72 * col.g + 0.07 * col.b;
|
||
|
|
gl_FragColor = vec4(average, average, average, col.a);
|
||
|
|
}`},mode:`average`,mainParameter:`mode`,applyTo2d:function(e){var t=e.imageData.data,n,r=t.length,i,a=this.mode;for(n=0;n<r;n+=4)a===`average`?i=(t[n]+t[n+1]+t[n+2])/3:a===`lightness`?i=(Math.min(t[n],t[n+1],t[n+2])+Math.max(t[n],t[n+1],t[n+2]))/2:a===`luminosity`&&(i=.21*t[n]+.72*t[n+1]+.07*t[n+2]),t[n]=i,t[n+1]=i,t[n+2]=i},retrieveShader:function(e){var t=this.type+`_`+this.mode;if(!e.programCache.hasOwnProperty(t)){var n=this.fragmentSource[this.mode];e.programCache[t]=this.createProgram(e.context,n)}return e.programCache[t]},getUniformLocations:function(e,t){return{uMode:e.getUniformLocation(t,`uMode`)}},sendUniformData:function(e,t){e.uniform1i(t.uMode,1)},isNeutralState:function(){return!1}}),t.Image.filters.Grayscale.fromObject=t.Image.filters.BaseFilter.fromObject})(e),(function(e){var t=e.fabric||={},n=t.Image.filters,r=t.util.createClass;n.Invert=r(n.BaseFilter,{type:`Invert`,fragmentSource:`precision highp float;
|
||
|
|
uniform sampler2D uTexture;
|
||
|
|
uniform int uInvert;
|
||
|
|
varying vec2 vTexCoord;
|
||
|
|
void main() {
|
||
|
|
vec4 color = texture2D(uTexture, vTexCoord);
|
||
|
|
if (uInvert == 1) {
|
||
|
|
gl_FragColor = vec4(1.0 - color.r,1.0 -color.g,1.0 -color.b,color.a);
|
||
|
|
} else {
|
||
|
|
gl_FragColor = color;
|
||
|
|
}
|
||
|
|
}`,invert:!0,mainParameter:`invert`,applyTo2d:function(e){var t=e.imageData.data,n,r=t.length;for(n=0;n<r;n+=4)t[n]=255-t[n],t[n+1]=255-t[n+1],t[n+2]=255-t[n+2]},isNeutralState:function(){return!this.invert},getUniformLocations:function(e,t){return{uInvert:e.getUniformLocation(t,`uInvert`)}},sendUniformData:function(e,t){e.uniform1i(t.uInvert,this.invert)}}),t.Image.filters.Invert.fromObject=t.Image.filters.BaseFilter.fromObject})(e),(function(e){var t=e.fabric||={},n=t.util.object.extend,r=t.Image.filters,i=t.util.createClass;r.Noise=i(r.BaseFilter,{type:`Noise`,fragmentSource:`precision highp float;
|
||
|
|
uniform sampler2D uTexture;
|
||
|
|
uniform float uStepH;
|
||
|
|
uniform float uNoise;
|
||
|
|
uniform float uSeed;
|
||
|
|
varying vec2 vTexCoord;
|
||
|
|
float rand(vec2 co, float seed, float vScale) {
|
||
|
|
return fract(sin(dot(co.xy * vScale ,vec2(12.9898 , 78.233))) * 43758.5453 * (seed + 0.01) / 2.0);
|
||
|
|
}
|
||
|
|
void main() {
|
||
|
|
vec4 color = texture2D(uTexture, vTexCoord);
|
||
|
|
color.rgb += (0.5 - rand(vTexCoord, uSeed, 0.1 / uStepH)) * uNoise;
|
||
|
|
gl_FragColor = color;
|
||
|
|
}`,mainParameter:`noise`,noise:0,applyTo2d:function(e){if(this.noise!==0){var t=e.imageData.data,n,r=t.length,i=this.noise,a;for(n=0,r=t.length;n<r;n+=4)a=(.5-Math.random())*i,t[n]+=a,t[n+1]+=a,t[n+2]+=a}},getUniformLocations:function(e,t){return{uNoise:e.getUniformLocation(t,`uNoise`),uSeed:e.getUniformLocation(t,`uSeed`)}},sendUniformData:function(e,t){e.uniform1f(t.uNoise,this.noise/255),e.uniform1f(t.uSeed,Math.random())},toObject:function(){return n(this.callSuper(`toObject`),{noise:this.noise})}}),t.Image.filters.Noise.fromObject=t.Image.filters.BaseFilter.fromObject})(e),(function(e){var t=e.fabric||={},n=t.Image.filters,r=t.util.createClass;n.Pixelate=r(n.BaseFilter,{type:`Pixelate`,blocksize:4,mainParameter:`blocksize`,fragmentSource:`precision highp float;
|
||
|
|
uniform sampler2D uTexture;
|
||
|
|
uniform float uBlocksize;
|
||
|
|
uniform float uStepW;
|
||
|
|
uniform float uStepH;
|
||
|
|
varying vec2 vTexCoord;
|
||
|
|
void main() {
|
||
|
|
float blockW = uBlocksize * uStepW;
|
||
|
|
float blockH = uBlocksize * uStepW;
|
||
|
|
int posX = int(vTexCoord.x / blockW);
|
||
|
|
int posY = int(vTexCoord.y / blockH);
|
||
|
|
float fposX = float(posX);
|
||
|
|
float fposY = float(posY);
|
||
|
|
vec2 squareCoords = vec2(fposX * blockW, fposY * blockH);
|
||
|
|
vec4 color = texture2D(uTexture, squareCoords);
|
||
|
|
gl_FragColor = color;
|
||
|
|
}`,applyTo2d:function(e){var t=e.imageData,n=t.data,r=t.height,i=t.width,a,o,s,c,l,u,d,f,p,m,h;for(o=0;o<r;o+=this.blocksize)for(s=0;s<i;s+=this.blocksize)for(a=o*4*i+s*4,c=n[a],l=n[a+1],u=n[a+2],d=n[a+3],m=Math.min(o+this.blocksize,r),h=Math.min(s+this.blocksize,i),f=o;f<m;f++)for(p=s;p<h;p++)a=f*4*i+p*4,n[a]=c,n[a+1]=l,n[a+2]=u,n[a+3]=d},isNeutralState:function(){return this.blocksize===1},getUniformLocations:function(e,t){return{uBlocksize:e.getUniformLocation(t,`uBlocksize`),uStepW:e.getUniformLocation(t,`uStepW`),uStepH:e.getUniformLocation(t,`uStepH`)}},sendUniformData:function(e,t){e.uniform1f(t.uBlocksize,this.blocksize)}}),t.Image.filters.Pixelate.fromObject=t.Image.filters.BaseFilter.fromObject})(e),(function(e){var t=e.fabric||={},n=t.util.object.extend,r=t.Image.filters,i=t.util.createClass;r.RemoveColor=i(r.BaseFilter,{type:`RemoveColor`,color:`#FFFFFF`,fragmentSource:`precision highp float;
|
||
|
|
uniform sampler2D uTexture;
|
||
|
|
uniform vec4 uLow;
|
||
|
|
uniform vec4 uHigh;
|
||
|
|
varying vec2 vTexCoord;
|
||
|
|
void main() {
|
||
|
|
gl_FragColor = texture2D(uTexture, vTexCoord);
|
||
|
|
if(all(greaterThan(gl_FragColor.rgb,uLow.rgb)) && all(greaterThan(uHigh.rgb,gl_FragColor.rgb))) {
|
||
|
|
gl_FragColor.a = 0.0;
|
||
|
|
}
|
||
|
|
}`,distance:.02,useAlpha:!1,applyTo2d:function(e){var n=e.imageData.data,r,i=this.distance*255,a,o,s,c=new t.Color(this.color).getSource(),l=[c[0]-i,c[1]-i,c[2]-i],u=[c[0]+i,c[1]+i,c[2]+i];for(r=0;r<n.length;r+=4)a=n[r],o=n[r+1],s=n[r+2],a>l[0]&&o>l[1]&&s>l[2]&&a<u[0]&&o<u[1]&&s<u[2]&&(n[r+3]=0)},getUniformLocations:function(e,t){return{uLow:e.getUniformLocation(t,`uLow`),uHigh:e.getUniformLocation(t,`uHigh`)}},sendUniformData:function(e,n){var r=new t.Color(this.color).getSource(),i=parseFloat(this.distance),a=[0+r[0]/255-i,0+r[1]/255-i,0+r[2]/255-i,1],o=[r[0]/255+i,r[1]/255+i,r[2]/255+i,1];e.uniform4fv(n.uLow,a),e.uniform4fv(n.uHigh,o)},toObject:function(){return n(this.callSuper(`toObject`),{color:this.color,distance:this.distance})}}),t.Image.filters.RemoveColor.fromObject=t.Image.filters.BaseFilter.fromObject})(e),(function(e){var t=e.fabric||={},n=t.Image.filters,r=t.util.createClass,i={Brownie:[.5997,.34553,-.27082,0,.186,-.0377,.86095,.15059,0,-.1449,.24113,-.07441,.44972,0,-.02965,0,0,0,1,0],Vintage:[.62793,.32021,-.03965,0,.03784,.02578,.64411,.03259,0,.02926,.0466,-.08512,.52416,0,.02023,0,0,0,1,0],Kodachrome:[1.12855,-.39673,-.03992,0,.24991,-.16404,1.08352,-.05498,0,.09698,-.16786,-.56034,1.60148,0,.13972,0,0,0,1,0],Technicolor:[1.91252,-.85453,-.09155,0,.04624,-.30878,1.76589,-.10601,0,-.27589,-.2311,-.75018,1.84759,0,.12137,0,0,0,1,0],Polaroid:[1.438,-.062,-.062,0,0,-.122,1.378,-.122,0,0,-.016,-.016,1.483,0,0,0,0,0,1,0],Sepia:[.393,.769,.189,0,0,.349,.686,.168,0,0,.272,.534,.131,0,0,0,0,0,1,0],BlackWhite:[1.5,1.5,1.5,0,-1,1.5,1.5,1.5,0,-1,1.5,1.5,1.5,0,-1,0,0,0,1,0]};for(var a in i)n[a]=r(n.ColorMatrix,{type:a,matrix:i[a],mainParameter:!1,colorsOnly:!0}),t.Image.filters[a].fromObject=t.Image.filters.BaseFilter.fromObject})(e),(function(e){var t=e.fabric,n=t.Image.filters,r=t.util.createClass;n.BlendColor=r(n.BaseFilter,{type:`BlendColor`,color:`#F95C63`,mode:`multiply`,alpha:1,fragmentSource:{multiply:`gl_FragColor.rgb *= uColor.rgb;
|
||
|
|
`,screen:`gl_FragColor.rgb = 1.0 - (1.0 - gl_FragColor.rgb) * (1.0 - uColor.rgb);
|
||
|
|
`,add:`gl_FragColor.rgb += uColor.rgb;
|
||
|
|
`,diff:`gl_FragColor.rgb = abs(gl_FragColor.rgb - uColor.rgb);
|
||
|
|
`,subtract:`gl_FragColor.rgb -= uColor.rgb;
|
||
|
|
`,lighten:`gl_FragColor.rgb = max(gl_FragColor.rgb, uColor.rgb);
|
||
|
|
`,darken:`gl_FragColor.rgb = min(gl_FragColor.rgb, uColor.rgb);
|
||
|
|
`,exclusion:`gl_FragColor.rgb += uColor.rgb - 2.0 * (uColor.rgb * gl_FragColor.rgb);
|
||
|
|
`,overlay:`if (uColor.r < 0.5) {
|
||
|
|
gl_FragColor.r *= 2.0 * uColor.r;
|
||
|
|
} else {
|
||
|
|
gl_FragColor.r = 1.0 - 2.0 * (1.0 - gl_FragColor.r) * (1.0 - uColor.r);
|
||
|
|
}
|
||
|
|
if (uColor.g < 0.5) {
|
||
|
|
gl_FragColor.g *= 2.0 * uColor.g;
|
||
|
|
} else {
|
||
|
|
gl_FragColor.g = 1.0 - 2.0 * (1.0 - gl_FragColor.g) * (1.0 - uColor.g);
|
||
|
|
}
|
||
|
|
if (uColor.b < 0.5) {
|
||
|
|
gl_FragColor.b *= 2.0 * uColor.b;
|
||
|
|
} else {
|
||
|
|
gl_FragColor.b = 1.0 - 2.0 * (1.0 - gl_FragColor.b) * (1.0 - uColor.b);
|
||
|
|
}
|
||
|
|
`,tint:`gl_FragColor.rgb *= (1.0 - uColor.a);
|
||
|
|
gl_FragColor.rgb += uColor.rgb;
|
||
|
|
`},buildSource:function(e){return`precision highp float;
|
||
|
|
uniform sampler2D uTexture;
|
||
|
|
uniform vec4 uColor;
|
||
|
|
varying vec2 vTexCoord;
|
||
|
|
void main() {
|
||
|
|
vec4 color = texture2D(uTexture, vTexCoord);
|
||
|
|
gl_FragColor = color;
|
||
|
|
if (color.a > 0.0) {
|
||
|
|
`+this.fragmentSource[e]+`}
|
||
|
|
}`},retrieveShader:function(e){var t=this.type+`_`+this.mode,n;return e.programCache.hasOwnProperty(t)||(n=this.buildSource(this.mode),e.programCache[t]=this.createProgram(e.context,n)),e.programCache[t]},applyTo2d:function(e){var n=e.imageData.data,r=n.length,i,a,o,s,c,l,u,d=1-this.alpha;u=new t.Color(this.color).getSource(),i=u[0]*this.alpha,a=u[1]*this.alpha,o=u[2]*this.alpha;for(var f=0;f<r;f+=4)switch(s=n[f],c=n[f+1],l=n[f+2],this.mode){case`multiply`:n[f]=s*i/255,n[f+1]=c*a/255,n[f+2]=l*o/255;break;case`screen`:n[f]=255-(255-s)*(255-i)/255,n[f+1]=255-(255-c)*(255-a)/255,n[f+2]=255-(255-l)*(255-o)/255;break;case`add`:n[f]=s+i,n[f+1]=c+a,n[f+2]=l+o;break;case`diff`:case`difference`:n[f]=Math.abs(s-i),n[f+1]=Math.abs(c-a),n[f+2]=Math.abs(l-o);break;case`subtract`:n[f]=s-i,n[f+1]=c-a,n[f+2]=l-o;break;case`darken`:n[f]=Math.min(s,i),n[f+1]=Math.min(c,a),n[f+2]=Math.min(l,o);break;case`lighten`:n[f]=Math.max(s,i),n[f+1]=Math.max(c,a),n[f+2]=Math.max(l,o);break;case`overlay`:n[f]=i<128?2*s*i/255:255-2*(255-s)*(255-i)/255,n[f+1]=a<128?2*c*a/255:255-2*(255-c)*(255-a)/255,n[f+2]=o<128?2*l*o/255:255-2*(255-l)*(255-o)/255;break;case`exclusion`:n[f]=i+s-2*i*s/255,n[f+1]=a+c-2*a*c/255,n[f+2]=o+l-2*o*l/255;break;case`tint`:n[f]=i+s*d,n[f+1]=a+c*d,n[f+2]=o+l*d}},getUniformLocations:function(e,t){return{uColor:e.getUniformLocation(t,`uColor`)}},sendUniformData:function(e,n){var r=new t.Color(this.color).getSource();r[0]=this.alpha*r[0]/255,r[1]=this.alpha*r[1]/255,r[2]=this.alpha*r[2]/255,r[3]=this.alpha,e.uniform4fv(n.uColor,r)},toObject:function(){return{type:this.type,color:this.color,mode:this.mode,alpha:this.alpha}}}),t.Image.filters.BlendColor.fromObject=t.Image.filters.BaseFilter.fromObject})(e),(function(e){var t=e.fabric,n=t.Image.filters,r=t.util.createClass;n.BlendImage=r(n.BaseFilter,{type:`BlendImage`,image:null,mode:`multiply`,alpha:1,vertexSource:`attribute vec2 aPosition;
|
||
|
|
varying vec2 vTexCoord;
|
||
|
|
varying vec2 vTexCoord2;
|
||
|
|
uniform mat3 uTransformMatrix;
|
||
|
|
void main() {
|
||
|
|
vTexCoord = aPosition;
|
||
|
|
vTexCoord2 = (uTransformMatrix * vec3(aPosition, 1.0)).xy;
|
||
|
|
gl_Position = vec4(aPosition * 2.0 - 1.0, 0.0, 1.0);
|
||
|
|
}`,fragmentSource:{multiply:`precision highp float;
|
||
|
|
uniform sampler2D uTexture;
|
||
|
|
uniform sampler2D uImage;
|
||
|
|
uniform vec4 uColor;
|
||
|
|
varying vec2 vTexCoord;
|
||
|
|
varying vec2 vTexCoord2;
|
||
|
|
void main() {
|
||
|
|
vec4 color = texture2D(uTexture, vTexCoord);
|
||
|
|
vec4 color2 = texture2D(uImage, vTexCoord2);
|
||
|
|
color.rgba *= color2.rgba;
|
||
|
|
gl_FragColor = color;
|
||
|
|
}`,mask:`precision highp float;
|
||
|
|
uniform sampler2D uTexture;
|
||
|
|
uniform sampler2D uImage;
|
||
|
|
uniform vec4 uColor;
|
||
|
|
varying vec2 vTexCoord;
|
||
|
|
varying vec2 vTexCoord2;
|
||
|
|
void main() {
|
||
|
|
vec4 color = texture2D(uTexture, vTexCoord);
|
||
|
|
vec4 color2 = texture2D(uImage, vTexCoord2);
|
||
|
|
color.a = color2.a;
|
||
|
|
gl_FragColor = color;
|
||
|
|
}`},retrieveShader:function(e){var t=this.type+`_`+this.mode,n=this.fragmentSource[this.mode];return e.programCache.hasOwnProperty(t)||(e.programCache[t]=this.createProgram(e.context,n)),e.programCache[t]},applyToWebGL:function(e){var t=e.context,n=this.createTexture(e.filterBackend,this.image);this.bindAdditionalTexture(t,n,t.TEXTURE1),this.callSuper(`applyToWebGL`,e),this.unbindAdditionalTexture(t,t.TEXTURE1)},createTexture:function(e,t){return e.getCachedTexture(t.cacheKey,t._element)},calculateMatrix:function(){var e=this.image,t=e._element.width,n=e._element.height;return[1/e.scaleX,0,0,0,1/e.scaleY,0,-e.left/t,-e.top/n,1]},applyTo2d:function(e){var n=e.imageData,r=e.filterBackend.resources,i=n.data,a=i.length,o=n.width,s=n.height,c,l,u,d,f,p,m,h,g,_,v=this.image,y;r.blendImage||=t.util.createCanvasElement(),g=r.blendImage,_=g.getContext(`2d`),g.width!==o||g.height!==s?(g.width=o,g.height=s):_.clearRect(0,0,o,s),_.setTransform(v.scaleX,0,0,v.scaleY,v.left,v.top),_.drawImage(v._element,0,0,o,s),y=_.getImageData(0,0,o,s).data;for(var b=0;b<a;b+=4)switch(f=i[b],p=i[b+1],m=i[b+2],h=i[b+3],c=y[b],l=y[b+1],u=y[b+2],d=y[b+3],this.mode){case`multiply`:i[b]=f*c/255,i[b+1]=p*l/255,i[b+2]=m*u/255,i[b+3]=h*d/255;break;case`mask`:i[b+3]=d;break}},getUniformLocations:function(e,t){return{uTransformMatrix:e.getUniformLocation(t,`uTransformMatrix`),uImage:e.getUniformLocation(t,`uImage`)}},sendUniformData:function(e,t){var n=this.calculateMatrix();e.uniform1i(t.uImage,1),e.uniformMatrix3fv(t.uTransformMatrix,!1,n)},toObject:function(){return{type:this.type,image:this.image&&this.image.toObject(),mode:this.mode,alpha:this.alpha}}}),t.Image.filters.BlendImage.fromObject=function(e,n){t.Image.fromObject(e.image,function(r){var i=t.util.object.clone(e);i.image=r,n(new t.Image.filters.BlendImage(i))})}})(e),(function(e){var t=e.fabric||={},n=Math.pow,r=Math.floor,i=Math.sqrt,a=Math.abs,o=Math.round,s=Math.sin,c=Math.ceil,l=t.Image.filters,u=t.util.createClass;l.Resize=u(l.BaseFilter,{type:`Resize`,resizeType:`hermite`,scaleX:1,scaleY:1,lanczosLobes:3,getUniformLocations:function(e,t){return{uDelta:e.getUniformLocation(t,`uDelta`),uTaps:e.getUniformLocation(t,`uTaps`)}},sendUniformData:function(e,t){e.uniform2fv(t.uDelta,this.horizontal?[1/this.width,0]:[0,1/this.height]),e.uniform1fv(t.uTaps,this.taps)},retrieveShader:function(e){var t=this.getFilterWindow(),n=this.type+`_`+t;if(!e.programCache.hasOwnProperty(n)){var r=this.generateShader(t);e.programCache[n]=this.createProgram(e.context,r)}return e.programCache[n]},getFilterWindow:function(){var e=this.tempScale;return Math.ceil(this.lanczosLobes/e)},getTaps:function(){for(var e=this.lanczosCreate(this.lanczosLobes),t=this.tempScale,n=this.getFilterWindow(),r=Array(n),i=1;i<=n;i++)r[i-1]=e(i*t);return r},generateShader:function(e){for(var t=Array(e),n=this.fragmentSourceTOP,e,r=1;r<=e;r++)t[r-1]=r+`.0 * uDelta`;return n+=`uniform float uTaps[`+e+`];
|
||
|
|
`,n+=`void main() {
|
||
|
|
`,n+=` vec4 color = texture2D(uTexture, vTexCoord);
|
||
|
|
`,n+=` float sum = 1.0;
|
||
|
|
`,t.forEach(function(e,t){n+=` color += texture2D(uTexture, vTexCoord + `+e+`) * uTaps[`+t+`];
|
||
|
|
`,n+=` color += texture2D(uTexture, vTexCoord - `+e+`) * uTaps[`+t+`];
|
||
|
|
`,n+=` sum += 2.0 * uTaps[`+t+`];
|
||
|
|
`}),n+=` gl_FragColor = color / sum;
|
||
|
|
`,n+=`}`,n},fragmentSourceTOP:`precision highp float;
|
||
|
|
uniform sampler2D uTexture;
|
||
|
|
uniform vec2 uDelta;
|
||
|
|
varying vec2 vTexCoord;
|
||
|
|
`,applyTo:function(e){e.webgl?(e.passes++,this.width=e.sourceWidth,this.horizontal=!0,this.dW=Math.round(this.width*this.scaleX),this.dH=e.sourceHeight,this.tempScale=this.dW/this.width,this.taps=this.getTaps(),e.destinationWidth=this.dW,this._setupFrameBuffer(e),this.applyToWebGL(e),this._swapTextures(e),e.sourceWidth=e.destinationWidth,this.height=e.sourceHeight,this.horizontal=!1,this.dH=Math.round(this.height*this.scaleY),this.tempScale=this.dH/this.height,this.taps=this.getTaps(),e.destinationHeight=this.dH,this._setupFrameBuffer(e),this.applyToWebGL(e),this._swapTextures(e),e.sourceHeight=e.destinationHeight):this.applyTo2d(e)},isNeutralState:function(){return this.scaleX===1&&this.scaleY===1},lanczosCreate:function(e){return function(t){if(t>=e||t<=-e)return 0;if(t<1.1920929e-7&&t>-1.1920929e-7)return 1;t*=Math.PI;var n=t/e;return s(t)/t*s(n)/n}},applyTo2d:function(e){var t=e.imageData,n=this.scaleX,r=this.scaleY;this.rcpScaleX=1/n,this.rcpScaleY=1/r;var i=t.width,a=t.height,s=o(i*n),c=o(a*r),l;this.resizeType===`sliceHack`?l=this.sliceByTwo(e,i,a,s,c):this.resizeType===`hermite`?l=this.hermiteFastResize(e,i,a,s,c):this.resizeType===`bilinear`?l=this.bilinearFiltering(e,i,a,s,c):this.resizeType===`lanczos`&&(l=this.lanczosResize(e,i,a,s,c)),e.imageData=l},sliceByTwo:function(e,n,i,a,o){var s=e.imageData,c=.5,l=!1,u=!1,d=n*c,f=i*c,p=t.filterBackend.resources,m,h,g=0,_=0,v=n,y=0;for(p.sliceByTwo||=document.createElement(`canvas`),m=p.sliceByTwo,(m.width<n*1.5||m.height<i)&&(m.width=n*1.5,m.height=i),h=m.getContext(`2d`),h.clearRect(0,0,n*1.5,i),h.putImageData(s,0,0),a=r(a),o=r(o);!l||!u;)n=d,i=f,a<r(d*c)?d=r(d*c):(d=a,l=!0),o<r(f*c)?f=r(f*c):(f=o,u=!0),h.drawImage(m,g,_,n,i,v,y,d,f),g=v,_=y,y+=f;return h.getImageData(g,_,a,o)},lanczosResize:function(e,t,o,s,l){function u(e){var c,w,T,E,D,O,k,A,j,M,N;for(S.x=(e+.5)*h,C.x=r(S.x),c=0;c<l;c++){for(S.y=(c+.5)*g,C.y=r(S.y),D=0,O=0,k=0,A=0,j=0,w=C.x-y;w<=C.x+y;w++)if(!(w<0||w>=t)){M=r(1e3*a(w-S.x)),x[M]||(x[M]={});for(var ee=C.y-b;ee<=C.y+b;ee++)ee<0||ee>=o||(N=r(1e3*a(ee-S.y)),x[M][N]||(x[M][N]=m(i(n(M*_,2)+n(N*v,2))/1e3)),T=x[M][N],T>0&&(E=(ee*t+w)*4,D+=T,O+=T*d[E],k+=T*d[E+1],A+=T*d[E+2],j+=T*d[E+3]))}E=(c*s+e)*4,p[E]=O/D,p[E+1]=k/D,p[E+2]=A/D,p[E+3]=j/D}return++e<s?u(e):f}var d=e.imageData.data,f=e.ctx.createImageData(s,l),p=f.data,m=this.lanczosCreate(this.lanczosLobes),h=this.rcpScaleX,g=this.rcpScaleY,_=2/this.rcpScaleX,v=2/this.rcpScaleY,y=c(h*this.lanczosLobes/2),b=c(g*this.lanczosLobes/2),x={},S={},C={};return u(0)},bilinearFiltering:function(e,t,n,i,a){var o,s,c,l,u,d,f,p,m,h,g,_,v=0,y,b=this.rcpScaleX,x=this.rcpScaleY,S=4*(t-1),C=e.imageData.data,w=e.ctx.createImageData(i,a),T=w.data;for(f=0;f<a;f++)for(p=0;p<i;p++)for(u=r(b*p),d=r(x*f),m=b*p-u,h=x*f-d,y=4*(d*t+u),g=0;g<4;g++)o=C[y+g],s=C[y+4+g],c=C[y+S+g],l=C[y+S+4+g],_=o*(1-m)*(1-h)+s*m*(1-h)+c*h*(1-m)+l*m*h,T[v++]=_;return w},hermiteFastResize:function(e,t,n,o,s){for(var l=this.rcpScaleX,u=this.rcpScaleY,d=c(l/2),f=c(u/2),p=e.imageData.data,m=e.ctx.createImageData(o,s),h=m.data,g=0;g<s;g++)for(var _=0;_<o;_++){for(var v=(_+g*o)*4,y=0,b=0,x=0,S=0,C=0,w=0,T=0,E=(g+.5)*u,D=r(g*u);D<(g+1)*u;D++)for(var O=a(E-(D+.5))/f,k=(_+.5)*l,A=O*O,j=r(_*l);j<(_+1)*l;j++){var M=a(k-(j+.5))/d,N=i(A+M*M);N>1&&N<-1||(y=2*N*N*N-3*N*N+1,y>0&&(M=4*(j+D*t),T+=y*p[M+3],x+=y,p[M+3]<255&&(y=y*p[M+3]/250),S+=y*p[M],C+=y*p[M+1],w+=y*p[M+2],b+=y))}h[v]=S/b,h[v+1]=C/b,h[v+2]=w/b,h[v+3]=T/x}return m},toObject:function(){return{type:this.type,scaleX:this.scaleX,scaleY:this.scaleY,resizeType:this.resizeType,lanczosLobes:this.lanczosLobes}}}),t.Image.filters.Resize.fromObject=t.Image.filters.BaseFilter.fromObject})(e),(function(e){var t=e.fabric||={},n=t.Image.filters,r=t.util.createClass;n.Contrast=r(n.BaseFilter,{type:`Contrast`,fragmentSource:`precision highp float;
|
||
|
|
uniform sampler2D uTexture;
|
||
|
|
uniform float uContrast;
|
||
|
|
varying vec2 vTexCoord;
|
||
|
|
void main() {
|
||
|
|
vec4 color = texture2D(uTexture, vTexCoord);
|
||
|
|
float contrastF = 1.015 * (uContrast + 1.0) / (1.0 * (1.015 - uContrast));
|
||
|
|
color.rgb = contrastF * (color.rgb - 0.5) + 0.5;
|
||
|
|
gl_FragColor = color;
|
||
|
|
}`,contrast:0,mainParameter:`contrast`,applyTo2d:function(e){if(this.contrast!==0){var t=e.imageData,n,r,i=t.data,r=i.length,a=Math.floor(this.contrast*255),o=259*(a+255)/(255*(259-a));for(n=0;n<r;n+=4)i[n]=o*(i[n]-128)+128,i[n+1]=o*(i[n+1]-128)+128,i[n+2]=o*(i[n+2]-128)+128}},getUniformLocations:function(e,t){return{uContrast:e.getUniformLocation(t,`uContrast`)}},sendUniformData:function(e,t){e.uniform1f(t.uContrast,this.contrast)}}),t.Image.filters.Contrast.fromObject=t.Image.filters.BaseFilter.fromObject})(e),(function(e){var t=e.fabric||={},n=t.Image.filters,r=t.util.createClass;n.Saturation=r(n.BaseFilter,{type:`Saturation`,fragmentSource:`precision highp float;
|
||
|
|
uniform sampler2D uTexture;
|
||
|
|
uniform float uSaturation;
|
||
|
|
varying vec2 vTexCoord;
|
||
|
|
void main() {
|
||
|
|
vec4 color = texture2D(uTexture, vTexCoord);
|
||
|
|
float rgMax = max(color.r, color.g);
|
||
|
|
float rgbMax = max(rgMax, color.b);
|
||
|
|
color.r += rgbMax != color.r ? (rgbMax - color.r) * uSaturation : 0.00;
|
||
|
|
color.g += rgbMax != color.g ? (rgbMax - color.g) * uSaturation : 0.00;
|
||
|
|
color.b += rgbMax != color.b ? (rgbMax - color.b) * uSaturation : 0.00;
|
||
|
|
gl_FragColor = color;
|
||
|
|
}`,saturation:0,mainParameter:`saturation`,applyTo2d:function(e){if(this.saturation!==0){var t=e.imageData.data,n=t.length,r=-this.saturation,i,a;for(i=0;i<n;i+=4)a=Math.max(t[i],t[i+1],t[i+2]),t[i]+=a===t[i]?0:(a-t[i])*r,t[i+1]+=a===t[i+1]?0:(a-t[i+1])*r,t[i+2]+=a===t[i+2]?0:(a-t[i+2])*r}},getUniformLocations:function(e,t){return{uSaturation:e.getUniformLocation(t,`uSaturation`)}},sendUniformData:function(e,t){e.uniform1f(t.uSaturation,-this.saturation)}}),t.Image.filters.Saturation.fromObject=t.Image.filters.BaseFilter.fromObject})(e),(function(e){var t=e.fabric||={},n=t.Image.filters,r=t.util.createClass;n.Vibrance=r(n.BaseFilter,{type:`Vibrance`,fragmentSource:`precision highp float;
|
||
|
|
uniform sampler2D uTexture;
|
||
|
|
uniform float uVibrance;
|
||
|
|
varying vec2 vTexCoord;
|
||
|
|
void main() {
|
||
|
|
vec4 color = texture2D(uTexture, vTexCoord);
|
||
|
|
float max = max(color.r, max(color.g, color.b));
|
||
|
|
float avg = (color.r + color.g + color.b) / 3.0;
|
||
|
|
float amt = (abs(max - avg) * 2.0) * uVibrance;
|
||
|
|
color.r += max != color.r ? (max - color.r) * amt : 0.00;
|
||
|
|
color.g += max != color.g ? (max - color.g) * amt : 0.00;
|
||
|
|
color.b += max != color.b ? (max - color.b) * amt : 0.00;
|
||
|
|
gl_FragColor = color;
|
||
|
|
}`,vibrance:0,mainParameter:`vibrance`,applyTo2d:function(e){if(this.vibrance!==0){var t=e.imageData.data,n=t.length,r=-this.vibrance,i,a,o,s;for(i=0;i<n;i+=4)a=Math.max(t[i],t[i+1],t[i+2]),o=(t[i]+t[i+1]+t[i+2])/3,s=Math.abs(a-o)*2/255*r,t[i]+=a===t[i]?0:(a-t[i])*s,t[i+1]+=a===t[i+1]?0:(a-t[i+1])*s,t[i+2]+=a===t[i+2]?0:(a-t[i+2])*s}},getUniformLocations:function(e,t){return{uVibrance:e.getUniformLocation(t,`uVibrance`)}},sendUniformData:function(e,t){e.uniform1f(t.uVibrance,-this.vibrance)}}),t.Image.filters.Vibrance.fromObject=t.Image.filters.BaseFilter.fromObject})(e),(function(e){var t=e.fabric||={},n=t.Image.filters,r=t.util.createClass;n.Blur=r(n.BaseFilter,{type:`Blur`,fragmentSource:`precision highp float;
|
||
|
|
uniform sampler2D uTexture;
|
||
|
|
uniform vec2 uDelta;
|
||
|
|
varying vec2 vTexCoord;
|
||
|
|
const float nSamples = 15.0;
|
||
|
|
vec3 v3offset = vec3(12.9898, 78.233, 151.7182);
|
||
|
|
float random(vec3 scale) {
|
||
|
|
return fract(sin(dot(gl_FragCoord.xyz, scale)) * 43758.5453);
|
||
|
|
}
|
||
|
|
void main() {
|
||
|
|
vec4 color = vec4(0.0);
|
||
|
|
float total = 0.0;
|
||
|
|
float offset = random(v3offset);
|
||
|
|
for (float t = -nSamples; t <= nSamples; t++) {
|
||
|
|
float percent = (t + offset - 0.5) / nSamples;
|
||
|
|
float weight = 1.0 - abs(percent);
|
||
|
|
color += texture2D(uTexture, vTexCoord + uDelta * percent) * weight;
|
||
|
|
total += weight;
|
||
|
|
}
|
||
|
|
gl_FragColor = color / total;
|
||
|
|
}`,blur:0,mainParameter:`blur`,applyTo:function(e){e.webgl?(this.aspectRatio=e.sourceWidth/e.sourceHeight,e.passes++,this._setupFrameBuffer(e),this.horizontal=!0,this.applyToWebGL(e),this._swapTextures(e),this._setupFrameBuffer(e),this.horizontal=!1,this.applyToWebGL(e),this._swapTextures(e)):this.applyTo2d(e)},applyTo2d:function(e){e.imageData=this.simpleBlur(e)},simpleBlur:function(e){var n=e.filterBackend.resources,r,i,a=e.imageData.width,o=e.imageData.height;n.blurLayer1||(n.blurLayer1=t.util.createCanvasElement(),n.blurLayer2=t.util.createCanvasElement()),r=n.blurLayer1,i=n.blurLayer2,(r.width!==a||r.height!==o)&&(i.width=r.width=a,i.height=r.height=o);var s=r.getContext(`2d`),c=i.getContext(`2d`),l=15,u,d,f,p,m=this.blur*.06*.5;for(s.putImageData(e.imageData,0,0),c.clearRect(0,0,a,o),p=-l;p<=l;p++)u=(Math.random()-.5)/4,d=p/l,f=m*d*a+u,c.globalAlpha=1-Math.abs(d),c.drawImage(r,f,u),s.drawImage(i,0,0),c.globalAlpha=1,c.clearRect(0,0,i.width,i.height);for(p=-l;p<=l;p++)u=(Math.random()-.5)/4,d=p/l,f=m*d*o+u,c.globalAlpha=1-Math.abs(d),c.drawImage(r,u,f),s.drawImage(i,0,0),c.globalAlpha=1,c.clearRect(0,0,i.width,i.height);e.ctx.drawImage(r,0,0);var h=e.ctx.getImageData(0,0,r.width,r.height);return s.globalAlpha=1,s.clearRect(0,0,r.width,r.height),h},getUniformLocations:function(e,t){return{delta:e.getUniformLocation(t,`uDelta`)}},sendUniformData:function(e,t){var n=this.chooseRightDelta();e.uniform2fv(t.delta,n)},chooseRightDelta:function(){var e=1,t=[0,0],n;return this.horizontal?this.aspectRatio>1&&(e=1/this.aspectRatio):this.aspectRatio<1&&(e=this.aspectRatio),n=e*this.blur*.12,this.horizontal?t[0]=n:t[1]=n,t}}),n.Blur.fromObject=t.Image.filters.BaseFilter.fromObject})(e),(function(e){var t=e.fabric||={},n=t.Image.filters,r=t.util.createClass;n.Gamma=r(n.BaseFilter,{type:`Gamma`,fragmentSource:`precision highp float;
|
||
|
|
uniform sampler2D uTexture;
|
||
|
|
uniform vec3 uGamma;
|
||
|
|
varying vec2 vTexCoord;
|
||
|
|
void main() {
|
||
|
|
vec4 color = texture2D(uTexture, vTexCoord);
|
||
|
|
vec3 correction = (1.0 / uGamma);
|
||
|
|
color.r = pow(color.r, correction.r);
|
||
|
|
color.g = pow(color.g, correction.g);
|
||
|
|
color.b = pow(color.b, correction.b);
|
||
|
|
gl_FragColor = color;
|
||
|
|
gl_FragColor.rgb *= color.a;
|
||
|
|
}`,gamma:[1,1,1],mainParameter:`gamma`,initialize:function(e){this.gamma=[1,1,1],n.BaseFilter.prototype.initialize.call(this,e)},applyTo2d:function(e){var t=e.imageData.data,n=this.gamma,r=t.length,i=1/n[0],a=1/n[1],o=1/n[2],s;for(this.rVals||(this.rVals=new Uint8Array(256),this.gVals=new Uint8Array(256),this.bVals=new Uint8Array(256)),s=0,r=256;s<r;s++)this.rVals[s]=(s/255)**i*255,this.gVals[s]=(s/255)**a*255,this.bVals[s]=(s/255)**o*255;for(s=0,r=t.length;s<r;s+=4)t[s]=this.rVals[t[s]],t[s+1]=this.gVals[t[s+1]],t[s+2]=this.bVals[t[s+2]]},getUniformLocations:function(e,t){return{uGamma:e.getUniformLocation(t,`uGamma`)}},sendUniformData:function(e,t){e.uniform3fv(t.uGamma,this.gamma)}}),t.Image.filters.Gamma.fromObject=t.Image.filters.BaseFilter.fromObject})(e),(function(e){var t=e.fabric||={},n=t.Image.filters,r=t.util.createClass;n.Composed=r(n.BaseFilter,{type:`Composed`,subFilters:[],initialize:function(e){this.callSuper(`initialize`,e),this.subFilters=this.subFilters.slice(0)},applyTo:function(e){e.passes+=this.subFilters.length-1,this.subFilters.forEach(function(t){t.applyTo(e)})},toObject:function(){return t.util.object.extend(this.callSuper(`toObject`),{subFilters:this.subFilters.map(function(e){return e.toObject()})})},isNeutralState:function(){return!this.subFilters.some(function(e){return!e.isNeutralState()})}}),t.Image.filters.Composed.fromObject=function(e,n){var r=(e.subFilters||[]).map(function(e){return new t.Image.filters[e.type](e)}),i=new t.Image.filters.Composed({subFilters:r});return n&&n(i),i}})(e),(function(e){var t=e.fabric||={},n=t.Image.filters,r=t.util.createClass;n.HueRotation=r(n.ColorMatrix,{type:`HueRotation`,rotation:0,mainParameter:`rotation`,calculateMatrix:function(){var e=this.rotation*Math.PI,n=t.util.cos(e),r=t.util.sin(e),i=1/3,a=Math.sqrt(i)*r,o=1-n;this.matrix=[1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1,0],this.matrix[0]=n+o/3,this.matrix[1]=i*o-a,this.matrix[2]=i*o+a,this.matrix[5]=i*o+a,this.matrix[6]=n+i*o,this.matrix[7]=i*o-a,this.matrix[10]=i*o-a,this.matrix[11]=i*o+a,this.matrix[12]=n+i*o},isNeutralState:function(e){return this.calculateMatrix(),n.BaseFilter.prototype.isNeutralState.call(this,e)},applyTo:function(e){this.calculateMatrix(),n.BaseFilter.prototype.applyTo.call(this,e)}}),t.Image.filters.HueRotation.fromObject=t.Image.filters.BaseFilter.fromObject})(e),(function(e){var t=e.fabric||={},n=t.util.object.clone;if(t.Text){t.warn(`fabric.Text is already defined`);return}var r=`fontFamily fontWeight fontSize text underline overline linethrough textAlign fontStyle lineHeight textBackgroundColor charSpacing styles direction path pathStartOffset pathSide pathAlign`.split(` `);t.Text=t.util.createClass(t.Object,{_dimensionAffectingProps:[`fontSize`,`fontWeight`,`fontFamily`,`fontStyle`,`lineHeight`,`text`,`charSpacing`,`textAlign`,`styles`,`path`,`pathStartOffset`,`pathSide`,`pathAlign`],_reNewline:/\r?\n/,_reSpacesAndTabs:/[ \t\r]/g,_reSpaceAndTab:/[ \t\r]/,_reWords:/\S+/g,type:`text`,fontSize:40,fontWeight:`normal`,fontFamily:`Times New Roman`,underline:!1,overline:!1,linethrough:!1,textAlign:`left`,fontStyle:`normal`,lineHeight:1.16,superscript:{size:.6,baseline:-.35},subscript:{size:.6,baseline:.11},textBackgroundColor:``,stateProperties:t.Object.prototype.stateProperties.concat(r),cacheProperties:t.Object.prototype.cacheProperties.concat(r),stroke:null,shadow:null,path:null,pathStartOffset:0,pathSide:`left`,pathAlign:`baseline`,_fontSizeFraction:.222,offsets:{underline:.1,linethrough:-.315,overline:-.88},_fontSizeMult:1.13,charSpacing:0,styles:null,_measuringContext:null,deltaY:0,direction:`ltr`,_styleProperties:[`stroke`,`strokeWidth`,`fill`,`fontFamily`,`fontSize`,`fontWeight`,`fontStyle`,`underline`,`overline`,`linethrough`,`deltaY`,`textBackgroundColor`],__charBounds:[],CACHE_FONT_SIZE:400,MIN_TEXT_WIDTH:2,initialize:function(e,t){this.styles=t&&t.styles||{},this.text=e,this.__skipDimension=!0,this.callSuper(`initialize`,t),this.path&&this.setPathInfo(),this.__skipDimension=!1,this.initDimensions(),this.setCoords(),this.setupState({propertySet:`_dimensionAffectingProp
|
||
|
|
`],a=[],o=0;o<n.length;o++)r[o]=t.util.string.graphemeSplit(n[o]),a=a.concat(r[o],i);return a.pop(),{_unwrappedLines:r,lines:n,graphemeText:a,graphemeLines:r}},toObject:function(e){var n=r.concat(e),i=this.callSuper(`toObject`,n);return i.styles=t.util.stylesToArray(this.styles,this.text),i.path&&=this.path.toObject(),i},set:function(e,t){this.callSuper(`set`,e,t);var n=!1,r=!1;if(typeof e==`object`)for(var i in e)i===`path`&&this.setPathInfo(),n||=this._dimensionAffectingProps.indexOf(i)!==-1,r||=i===`path`;else n=this._dimensionAffectingProps.indexOf(e)!==-1,r=e===`path`;return r&&this.setPathInfo(),n&&(this.initDimensions(),this.setCoords()),this},complexity:function(){return 1}}),t.Text.ATTRIBUTE_NAMES=t.SHARED_ATTRIBUTES.concat(`x y dx dy font-family font-style font-weight font-size letter-spacing text-decoration text-anchor`.split(` `)),t.Text.DEFAULT_SVG_FONT_SIZE=16,t.Text.fromElement=function(e,r,i){if(!e)return r(null);var a=t.parseAttributes(e,t.Text.ATTRIBUTE_NAMES),o=a.textAnchor||`left`;if(i=t.util.object.extend(i?n(i):{},a),i.top=i.top||0,i.left=i.left||0,a.textDecoration){var s=a.textDecoration;s.indexOf(`underline`)!==-1&&(i.underline=!0),s.indexOf(`overline`)!==-1&&(i.overline=!0),s.indexOf(`line-through`)!==-1&&(i.linethrough=!0),delete i.textDecoration}`dx`in a&&(i.left+=a.dx),`dy`in a&&(i.top+=a.dy),`fontSize`in i||(i.fontSize=t.Text.DEFAULT_SVG_FONT_SIZE);var c=``;`textContent`in e?c=e.textContent:`firstChild`in e&&e.firstChild!==null&&`data`in e.firstChild&&e.firstChild.data!==null&&(c=e.firstChild.data),c=c.replace(/^\s+|\s+$|\n+/g,``).replace(/\s+/g,` `);var l=i.strokeWidth;i.strokeWidth=0;var u=new t.Text(c,i),d=u.getScaledHeight()/u.height,f=((u.height+u.strokeWidth)*u.lineHeight-u.height)*d,p=u.getScaledHeight()+f,m=0;o===`center`&&(m=u.getScaledWidth()/2),o===`right`&&(m=u.getScaledWidth()),u.set({left:u.left-m,top:u.top-(p-u.fontSize*(.07+u._fontSizeFraction))/u.lineHeight,strokeWidth:l===void 0?1:l}),r(u)},t.Text.fromObject=function(e,r){var i=n(e),a=e.path;return delete i.path,t.Object._fromObject(`Text`,i,function(n){n.styles=t.util.stylesFromArray(e.styles,e.text),a?t.Object._fromObject(`Path`,a,function(e){n.set(`path`,e),r(n)},`path`):r(n)},`text`)},t.Text.genericFonts=[`sans-serif`,`serif`,`cursive`,`fantasy`,`monospace`],t.util.createAccessors&&t.util.createAccessors(t.Text)})(e),(function(){t.util.object.extend(t.Text.prototype,{isEmptyStyles:function(e){if(!this.styles||e!==void 0&&!this.styles[e])return!0;var t=e===void 0?this.styles:{line:this.styles[e]};for(var n in t)for(var r in t[n])for(var i in t[n][r])return!1;return!0},styleHas:function(e,t){if(!this.styles||!e||e===``||t!==void 0&&!this.styles[t])return!1;var n=t===void 0?this.styles:{0:this.styles[t]};for(var r in n)for(var i in n[r])if(n[r][i][e]!==void 0)return!0;return!1},cleanStyle:function(e){if(!this.styles||!e||e===``)return!1;var t=this.styles,n=0,r,i,a=!0,o=0,s;for(var c in t){for(var l in r=0,t[c]){var s=t[c][l],u=s.hasOwnProperty(e);n++,u?(i?s[e]!==i&&(a=!1):i=s[e],s[e]===this[e]&&delete s[e]):a=!1,Object.keys(s).length===0?delete t[c][l]:r++}r===0&&delete t[c]}for(var d=0;d<this._textLines.length;d++)o+=this._textLines[d].length;a&&n===o&&(this[e]=i,this.removeStyle(e))},removeStyle:function(e){if(!(!this.styles||!e||e===``)){var t=this.styles,n,r,i;for(r in t){for(i in n=t[r],n)delete n[i][e],Object.keys(n[i]).length===0&&delete n[i];Object.keys(n).length===0&&delete t[r]}}},_extendStyles:function(e,n){var r=this.get2DCursorLocation(e);this._getLineStyle(r.lineIndex)||this._setLineStyle(r.lineIndex),this._getStyleDeclaration(r.lineIndex,r.charIndex)||this._setStyleDeclaration(r.lineIndex,r.charIndex,{}),t.util.object.extend(this._getStyleDeclaration(r.lineIndex,r.charIndex),n)},get2DCursorLocation:function(e,t){e===void 0&&(e=this.selectionStart);for(var n=t?this._unwrappedTextLines:this._textLines,r=n.length,i=0;i<r;i++){if(e<=n[i].length)return{lineIndex:i,charIndex:e};e-=n[i].length+this.missingNewlineOffset(i,t)}return{lineIndex:i-1,charIndex:n[i-1].length<e?n[i-1].length:e}},getSelectionStyles:function
|
||
|
|
`?(a++,i[a]=0):i[a]++;i[0]>0&&(this.insertCharStyleObject(r.lineIndex,r.charIndex,i[0],n),n&&=n.slice(i[0]+1)),a&&this.insertNewlineStyleObject(r.lineIndex,r.charIndex+i[0],a);for(var o=1;o<a;o++)i[o]>0?this.insertCharStyleObject(r.lineIndex+o,0,i[o],n):n&&this.styles[r.lineIndex+o]&&n[0]&&(this.styles[r.lineIndex+o][0]=n[0]),n&&=n.slice(i[o]+1);i[o]>0&&this.insertCharStyleObject(r.lineIndex+o,0,i[o],n)},setSelectionStartEndWithShift:function(e,t,n){n<=e?(t===e?this._selectionDirection=`left`:this._selectionDirection===`right`&&(this._selectionDirection=`left`,this.selectionEnd=e),this.selectionStart=n):n>e&&n<t?this._selectionDirection===`right`?this.selectionEnd=n:this.selectionStart=n:(t===e?this._selectionDirection=`right`:this._selectionDirection===`left`&&(this._selectionDirection=`right`,this.selectionStart=t),this.selectionEnd=n)},setSelectionInBoundaries:function(){var e=this.text.length;this.selectionStart>e?this.selectionStart=e:this.selectionStart<0&&(this.selectionStart=0),this.selectionEnd>e?this.selectionEnd=e:this.selectionEnd<0&&(this.selectionEnd=0)}})})(),t.util.object.extend(t.IText.prototype,{initDoubleClickSimulation:function(){this.__lastClickTime=+new Date,this.__lastLastClickTime=+new Date,this.__lastPointer={},this.on(`mousedown`,this.onMouseDown)},onMouseDown:function(e){if(this.canvas){this.__newClickTime=+new Date;var t=e.pointer;this.isTripleClick(t)&&(this.fire(`tripleclick`,e),this._stopEvent(e.e)),this.__lastLastClickTime=this.__lastClickTime,this.__lastClickTime=this.__newClickTime,this.__lastPointer=t,this.__lastIsEditing=this.isEditing,this.__lastSelected=this.selected}},isTripleClick:function(e){return this.__newClickTime-this.__lastClickTime<500&&this.__lastClickTime-this.__lastLastClickTime<500&&this.__lastPointer.x===e.x&&this.__lastPointer.y===e.y},_stopEvent:function(e){e.preventDefault&&e.preventDefault(),e.stopPropagation&&e.stopPropagation()},initCursorSelectionHandlers:function(){this.initMousedownHandler(),this.initMouseupHandler(),this.initClicks()},doubleClickHandler:function(e){this.isEditing&&this.selectWord(this.getSelectionStartFromPointer(e.e))},tripleClickHandler:function(e){this.isEditing&&this.selectLine(this.getSelectionStartFromPointer(e.e))},initClicks:function(){this.on(`mousedblclick`,this.doubleClickHandler),this.on(`tripleclick`,this.tripleClickHandler)},_mouseDownHandler:function(e){!this.canvas||!this.editable||e.e.button&&e.e.button!==1||(this.__isMousedown=!0,this.selected&&(this.inCompositionMode=!1,this.setCursorByClick(e.e)),this.isEditing&&(this.__selectionStartOnMouseDown=this.selectionStart,this.selectionStart===this.selectionEnd&&this.abortCursorAnimation(),this.renderCursorOrSelection()))},_mouseDownHandlerBefore:function(e){!this.canvas||!this.editable||e.e.button&&e.e.button!==1||(this.selected=this===this.canvas._activeObject)},initMousedownHandler:function(){this.on(`mousedown`,this._mouseDownHandler),this.on(`mousedown:before`,this._mouseDownHandlerBefore)},initMouseupHandler:function(){this.on(`mouseup`,this.mouseUpHandler)},mouseUpHandler:function(e){if(this.__isMousedown=!1,!(!this.editable||this.group||e.transform&&e.transform.actionPerformed||e.e.button&&e.e.button!==1)){if(this.canvas){var t=this.canvas._activeObject;if(t&&t!==this)return}this.__lastSelected&&!this.__corner?(this.selected=!1,this.__lastSelected=!1,this.enterEditing(e.e),this.selectionStart===this.selectionEnd?this.initDelayedCursor(!0):this.renderCursorOrSelection()):this.selected=!0}},setCursorByClick:function(e){var t=this.getSelectionStartFromPointer(e),n=this.selectionStart,r=this.selectionEnd;e.shiftKey?this.setSelectionStartEndWithShift(n,r,t):(this.selectionStart=t,this.selectionEnd=t),this.isEditing&&(this._fireSelectionChanged(),this._updateTextarea())},getSelectionStartFromPointer:function(e){for(var t=this.getLocalPointer(e),n=0,r=0,i=0,a=0,o=0,s,c,l=0,u=this._textLines.length;l<u&&i<=t.y;l++)i+=this.getHeightOfLine(l)*this.scaleY,o=l,l>0&&(a+=this._textLines[l-1].length+this.missingNewlineOffset(l-1));s=this._getLineLeftOffset(o),r=s*this.scaleX,c=this._te
|
||
|
|
`]},_getSVGTextAndBg:function(e,t){var n=[],r=[],i=e,a;this._setSVGBg(r);for(var o=0,s=this._textLines.length;o<s;o++)a=this._getLineLeftOffset(o),(this.textBackgroundColor||this.styleHas(`textBackgroundColor`,o))&&this._setSVGTextLineBg(r,o,t+a,i),this._setSVGTextLineText(n,o,t+a,i),i+=this.getHeightOfLine(o);return{textSpans:n,textBgRects:r}},_createTextCharSpan:function(o,s,c,l,u){var d=o!==o.trim()||o.match(a),f=this.getSvgSpanStyles(s,d),p=f?`style="`+f+`"`:``,m=s.deltaY,h=``,g=t.Object.NUM_FRACTION_DIGITS,_=``;if(m&&(h=` dy="`+e(m,g)+`" `),u.renderLeft!==void 0){var v=u.angle;_=` rotate="`+e(n(v),t.Object.NUM_FRACTION_DIGITS)+`" `;var y=u.width/2,b=r({angle:n(v)});b[4]=u.renderLeft,b[5]=u.renderTop;var x=i({x:-y,y:0},b);c=x.x,l=x.y}return[`<tspan x="`,e(c,g),`" y="`,e(l,g),`" `,h,p,_,`>`,t.util.string.escapeXml(o),`</tspan>`].join(``)},_setSVGTextLineText:function(e,n,r,i){var a=this.getHeightOfLine(n),o=this.textAlign.indexOf(`justify`)!==-1,s,c,l=``,u,d,f=0,p=this._textLines[n],m;i+=a*(1-this._fontSizeFraction)/this.lineHeight;for(var h=0,g=p.length-1;h<=g;h++)m=h===g||this.charSpacing||this.path,l+=p[h],u=this.__charBounds[n][h],f===0?(r+=u.kernedWidth-u.width,f+=u.width):f+=u.kernedWidth,o&&!m&&this._reSpaceAndTab.test(p[h])&&(m=!0),m||=(s||=this.getCompleteStyleDeclaration(n,h),c=this.getCompleteStyleDeclaration(n,h+1),t.util.hasStyleChanged(s,c,!0)),m&&(d=this._getStyleDeclaration(n,h)||{},e.push(this._createTextCharSpan(l,d,r,i,u)),l=``,s=c,r+=f,f=0)},_pushTextBgRect:function(n,r,i,a,o,s){var c=t.Object.NUM_FRACTION_DIGITS;n.push(` <rect `,this._getFillAttributes(r),` x="`,e(i,c),`" y="`,e(a,c),`" width="`,e(o,c),`" height="`,e(s,c),`"></rect>
|
||
|
|
`)},_setSVGTextLineBg:function(e,t,n,r){for(var i=this._textLines[t],a=this.getHeightOfLine(t)/this.lineHeight,o=0,s=0,c,l,u=this.getValueOfPropertyAt(t,0,`textBackgroundColor`),d=0,f=i.length;d<f;d++)c=this.__charBounds[t][d],l=this.getValueOfPropertyAt(t,d,`textBackgroundColor`),l===u?o+=c.kernedWidth:(u&&this._pushTextBgRect(e,u,n+s,r,o,a),s=c.left,o=c.width,u=l);l&&this._pushTextBgRect(e,l,n+s,r,o,a)},_getFillAttributes:function(e){var n=e&&typeof e==`string`?new t.Color(e):``;return!n||!n.getSource()||n.getAlpha()===1?`fill="`+e+`"`:`opacity="`+n.getAlpha()+`" fill="`+n.setAlpha(1).toRgb()+`"`},_getSVGLineTopOffset:function(e){for(var t=0,n=0,r=0;r<e;r++)t+=this.getHeightOfLine(r);return n=this.getHeightOfLine(r),{lineTop:t,offset:(this._fontSizeMult-this._fontSizeFraction)*n/(this.lineHeight*this._fontSizeMult)}},getSvgStyles:function(e){return t.Object.prototype.getSvgStyles.call(this,e)+` white-space: pre;`}})})(),(function(e){var t=e.fabric||={};t.Textbox=t.util.createClass(t.IText,t.Observable,{type:`textbox`,minWidth:20,dynamicMinWidth:2,__cachedLines:null,lockScalingFlip:!0,noScaleCache:!1,_dimensionAffectingProps:t.Text.prototype._dimensionAffectingProps.concat(`width`),_wordJoiners:/[ \t\r]/,splitByGrapheme:!1,initDimensions:function(){this.__skipDimension||(this.isEditing&&this.initDelayedCursor(),this.clearContextTop(),this._clearCache(),this.dynamicMinWidth=0,this._styleMap=this._generateStyleMap(this._splitText()),this.dynamicMinWidth>this.width&&this._set(`width`,this.dynamicMinWidth),this.textAlign.indexOf(`justify`)!==-1&&this.enlargeSpaces(),this.height=this.calcTextHeight(),this.saveState({propertySet:`_dimensionAffectingProps`}))},_generateStyleMap:function(e){for(var t=0,n=0,r=0,i={},a=0;a<e.graphemeLines.length;a++)e.graphemeText[r]===`
|
||
|
|
`&&a>0?(n=0,r++,t++):!this.splitByGrapheme&&this._reSpaceAndTab.test(e.graphemeText[r])&&a>0&&(n++,r++),i[a]={line:t,offset:n},r+=e.graphemeLines[a].length,n+=e.graphemeLines[a].length;return i},styleHas:function(e,n){if(this._styleMap&&!this.isWrapping){var r=this._styleMap[n];r&&(n=r.line)}return t.Text.prototype.styleHas.call(this,e,n)},isEmptyStyles:function(e){if(!this.styles)return!0;var t=0,n=e+1,r,i,a=!1,o=this._styleMap[e],s=this._styleMap[e+1];for(var c in o&&(e=o.line,t=o.offset),s&&(n=s.line,a=n===e,r=s.offset),i=e===void 0?this.styles:{line:this.styles[e]},i)for(var l in i[c])if(l>=t&&(!a||l<r))for(var u in i[c][l])return!1;return!0},_getStyleDeclaration:function(e,t){if(this._styleMap&&!this.isWrapping){var n=this._styleMap[e];if(!n)return null;e=n.line,t=n.offset+t}return this.callSuper(`_getStyleDeclaration`,e,t)},_setStyleDeclaration:function(e,t,n){var r=this._styleMap[e];e=r.line,t=r.offset+t,this.styles[e][t]=n},_deleteStyleDeclaration:function(e,t){var n=this._styleMap[e];e=n.line,t=n.offset+t,delete this.styles[e][t]},_getLineStyle:function(e){var t=this._styleMap[e];return!!this.styles[t.line]},_setLineStyle:function(e){var t=this._styleMap[e];this.styles[t.line]={}},_wrapText:function(e,t){var n=[],r;for(this.isWrapping=!0,r=0;r<e.length;r++)n=n.concat(this._wrapLine(e[r],r,t));return this.isWrapping=!1,n},_measureWord:function(e,t,n){var r=0,i,a=!0;n||=0;for(var o=0,s=e.length;o<s;o++){var c=this._getGraphemeBox(e[o],t,o+n,i,a);r+=c.kernedWidth,i=e[o]}return r},_wrapLine:function(e,n,r,i){var a=0,o=this.splitByGrapheme,s=[],c=[],l=o?t.util.string.graphemeSplit(e):e.split(this._wordJoiners),u=``,d=0,f=o?``:` `,p=0,m=0,h=0,g=!0,_=this._getWidthOfCharSpacing(),i=i||0;l.length===0&&l.push([]),r-=i;for(var v=0;v<l.length;v++)u=o?l[v]:t.util.string.graphemeSplit(l[v]),p=this._measureWord(u,n,d),d+=u.length,a+=m+p-_,a>r&&!g?(s.push(c),c=[],a=p,g=!0):a+=_,!g&&!o&&c.push(f),c=c.concat(u),m=o?0:this._measureWord([f],n,d),d++,g=!1,p>h&&(h=p);return v&&s.push(c),h+i>this.dynamicMinWidth&&(this.dynamicMinWidth=h-_+i),s},isEndOfWrapping:function(e){return!this._styleMap[e+1]||this._styleMap[e+1].line!==this._styleMap[e].line},missingNewlineOffset:function(e,t){return this.splitByGrapheme&&!t?+!!this.isEndOfWrapping(e):1},_splitTextIntoLines:function(e){for(var n=t.Text.prototype._splitTextIntoLines.call(this,e),r=this._wrapText(n.lines,this.width),i=Array(r.length),a=0;a<r.length;a++)i[a]=r[a].join(``);return n.lines=i,n.graphemeLines=r,n},getMinWidth:function(){return Math.max(this.minWidth,this.dynamicMinWidth)},_removeExtraneousStyles:function(){var e={};for(var t in this._styleMap)this._textLines[t]&&(e[this._styleMap[t].line]=1);for(var t in this.styles)e[t]||delete this.styles[t]},toObject:function(e){return this.callSuper(`toObject`,[`minWidth`,`splitByGrapheme`].concat(e))}}),t.Textbox.fromObject=function(e,n){var r=t.util.stylesFromArray(e.styles,e.text),i=Object.assign({},e,{styles:r});return delete i.path,t.Object._fromObject(`Textbox`,i,function(r){e.path?t.Object._fromObject(`Path`,e.path,function(e){r.set(`path`,e),n(r)},`path`):n(r)},`text`)}})(e),(function(){var e=t.controlsUtils,n=e.scaleSkewCursorStyleHandler,r=e.scaleCursorStyleHandler,i=e.scalingEqually,a=e.scalingYOrSkewingX,o=e.scalingXOrSkewingY,s=e.scaleOrSkewActionName,c=t.Object.prototype.controls;if(c.ml=new t.Control({x:-.5,y:0,cursorStyleHandler:n,actionHandler:o,getActionName:s}),c.mr=new t.Control({x:.5,y:0,cursorStyleHandler:n,actionHandler:o,getActionName:s}),c.mb=new t.Control({x:0,y:.5,cursorStyleHandler:n,actionHandler:a,getActionName:s}),c.mt=new t.Control({x:0,y:-.5,cursorStyleHandler:n,actionHandler:a,getActionName:s}),c.tl=new t.Control({x:-.5,y:-.5,cursorStyleHandler:r,actionHandler:i}),c.tr=new t.Control({x:.5,y:-.5,cursorStyleHandler:r,actionHandler:i}),c.bl=new t.Control({x:-.5,y:.5,cursorStyleHandler:r,actionHandler:i}),c.br=new t.Control({x:.5,y:.5,cursorStyleHandler:r,actionHandler:i}),c.mtr=new t.Control({x:0,y:-.5,actionHandler:e.rotationWithSnapping,cursorStyleHandler:e.rotationStyleHandler,offsetY:-40,withCon
|