@pairbo/ui-kit 0.4.15 → 0.4.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/page-manager.js
CHANGED
|
@@ -6,15 +6,15 @@
|
|
|
6
6
|
* @license
|
|
7
7
|
* Copyright 2019 Google LLC
|
|
8
8
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
9
|
-
*/const Pr=globalThis,bo=Pr.ShadowRoot&&(Pr.ShadyCSS===void 0||Pr.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,vo=Symbol(),ra=new WeakMap;let Dl=class{constructor(t,e,i){if(this._$cssResult$=!0,i!==vo)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=t,this.t=e}get styleSheet(){let t=this.o;const e=this.t;if(bo&&t===void 0){const i=e!==void 0&&e.length===1;i&&(t=ra.get(e)),t===void 0&&((this.o=t=new CSSStyleSheet).replaceSync(this.cssText),i&&ra.set(e,t))}return t}toString(){return this.cssText}};const
|
|
9
|
+
*/const Pr=globalThis,bo=Pr.ShadowRoot&&(Pr.ShadyCSS===void 0||Pr.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,vo=Symbol(),ra=new WeakMap;let Dl=class{constructor(t,e,i){if(this._$cssResult$=!0,i!==vo)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=t,this.t=e}get styleSheet(){let t=this.o;const e=this.t;if(bo&&t===void 0){const i=e!==void 0&&e.length===1;i&&(t=ra.get(e)),t===void 0&&((this.o=t=new CSSStyleSheet).replaceSync(this.cssText),i&&ra.set(e,t))}return t}toString(){return this.cssText}};const Kr=r=>new Dl(typeof r=="string"?r:r+"",void 0,vo),gt=(r,...t)=>{const e=r.length===1?r[0]:t.reduce((i,s,n)=>i+(o=>{if(o._$cssResult$===!0)return o.cssText;if(typeof o=="number")return o;throw Error("Value passed to 'css' function must be a 'css' function result: "+o+". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.")})(s)+r[n+1],r[0]);return new Dl(e,r,vo)},wh=(r,t)=>{if(bo)r.adoptedStyleSheets=t.map(e=>e instanceof CSSStyleSheet?e:e.styleSheet);else for(const e of t){const i=document.createElement("style"),s=Pr.litNonce;s!==void 0&&i.setAttribute("nonce",s),i.textContent=e.cssText,r.appendChild(i)}},na=bo?r=>r:r=>r instanceof CSSStyleSheet?(t=>{let e="";for(const i of t.cssRules)e+=i.cssText;return Kr(e)})(r):r;/**
|
|
10
10
|
* @license
|
|
11
11
|
* Copyright 2017 Google LLC
|
|
12
12
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
13
|
-
*/const{is:
|
|
13
|
+
*/const{is:Ch,defineProperty:Sh,getOwnPropertyDescriptor:Th,getOwnPropertyNames:Eh,getOwnPropertySymbols:Oh,getPrototypeOf:kh}=Object,pi=globalThis,oa=pi.trustedTypes,Ph=oa?oa.emptyScript:"",Cn=pi.reactiveElementPolyfillSupport,Es=(r,t)=>r,Fr={toAttribute(r,t){switch(t){case Boolean:r=r?Ph:null;break;case Object:case Array:r=r==null?r:JSON.stringify(r)}return r},fromAttribute(r,t){let e=r;switch(t){case Boolean:e=r!==null;break;case Number:e=r===null?null:Number(r);break;case Object:case Array:try{e=JSON.parse(r)}catch{e=null}}return e}},yo=(r,t)=>!Ch(r,t),aa={attribute:!0,type:String,converter:Fr,reflect:!1,useDefault:!1,hasChanged:yo};Symbol.metadata??(Symbol.metadata=Symbol("metadata")),pi.litPropertyMetadata??(pi.litPropertyMetadata=new WeakMap);let Wi=class extends HTMLElement{static addInitializer(t){this._$Ei(),(this.l??(this.l=[])).push(t)}static get observedAttributes(){return this.finalize(),this._$Eh&&[...this._$Eh.keys()]}static createProperty(t,e=aa){if(e.state&&(e.attribute=!1),this._$Ei(),this.prototype.hasOwnProperty(t)&&((e=Object.create(e)).wrapped=!0),this.elementProperties.set(t,e),!e.noAccessor){const i=Symbol(),s=this.getPropertyDescriptor(t,i,e);s!==void 0&&Sh(this.prototype,t,s)}}static getPropertyDescriptor(t,e,i){const{get:s,set:n}=Th(this.prototype,t)??{get(){return this[e]},set(o){this[e]=o}};return{get:s,set(o){const a=s==null?void 0:s.call(this);n==null||n.call(this,o),this.requestUpdate(t,a,i)},configurable:!0,enumerable:!0}}static getPropertyOptions(t){return this.elementProperties.get(t)??aa}static _$Ei(){if(this.hasOwnProperty(Es("elementProperties")))return;const t=kh(this);t.finalize(),t.l!==void 0&&(this.l=[...t.l]),this.elementProperties=new Map(t.elementProperties)}static finalize(){if(this.hasOwnProperty(Es("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(Es("properties"))){const e=this.properties,i=[...Eh(e),...Oh(e)];for(const s of i)this.createProperty(s,e[s])}const t=this[Symbol.metadata];if(t!==null){const e=litPropertyMetadata.get(t);if(e!==void 0)for(const[i,s]of e)this.elementProperties.set(i,s)}this._$Eh=new Map;for(const[e,i]of this.elementProperties){const s=this._$Eu(e,i);s!==void 0&&this._$Eh.set(s,e)}this.elementStyles=this.finalizeStyles(this.styles)}static finalizeStyles(t){const e=[];if(Array.isArray(t)){const i=new Set(t.flat(1/0).reverse());for(const s of i)e.unshift(na(s))}else t!==void 0&&e.push(na(t));return e}static _$Eu(t,e){const i=e.attribute;return i===!1?void 0:typeof i=="string"?i:typeof t=="string"?t.toLowerCase():void 0}constructor(){super(),this._$Ep=void 0,this.isUpdatePending=!1,this.hasUpdated=!1,this._$Em=null,this._$Ev()}_$Ev(){var t;this._$ES=new Promise(e=>this.enableUpdating=e),this._$AL=new Map,this._$E_(),this.requestUpdate(),(t=this.constructor.l)==null||t.forEach(e=>e(this))}addController(t){var e;(this._$EO??(this._$EO=new Set)).add(t),this.renderRoot!==void 0&&this.isConnected&&((e=t.hostConnected)==null||e.call(t))}removeController(t){var e;(e=this._$EO)==null||e.delete(t)}_$E_(){const t=new Map,e=this.constructor.elementProperties;for(const i of e.keys())this.hasOwnProperty(i)&&(t.set(i,this[i]),delete this[i]);t.size>0&&(this._$Ep=t)}createRenderRoot(){const t=this.shadowRoot??this.attachShadow(this.constructor.shadowRootOptions);return wh(t,this.constructor.elementStyles),t}connectedCallback(){var t;this.renderRoot??(this.renderRoot=this.createRenderRoot()),this.enableUpdating(!0),(t=this._$EO)==null||t.forEach(e=>{var i;return(i=e.hostConnected)==null?void 0:i.call(e)})}enableUpdating(t){}disconnectedCallback(){var t;(t=this._$EO)==null||t.forEach(e=>{var i;return(i=e.hostDisconnected)==null?void 0:i.call(e)})}attributeChangedCallback(t,e,i){this._$AK(t,i)}_$ET(t,e){var n;const i=this.constructor.elementProperties.get(t),s=this.constructor._$Eu(t,i);if(s!==void 0&&i.reflect===!0){const o=(((n=i.converter)==null?void 0:n.toAttribute)!==void 0?i.converter:Fr).toAttribute(e,i.type);this._$Em=t,o==null?this.removeAttribute(s):this.setAttribute(s,o),this._$Em=null}}_$AK(t,e){var n,o;const i=this.constructor,s=i._$Eh.get(t);if(s!==void 0&&this._$Em!==s){const a=i.getPropertyOptions(s),l=typeof a.converter=="function"?{fromAttribute:a.converter}:((n=a.converter)==null?void 0:n.fromAttribute)!==void 0?a.converter:Fr;this._$Em=s;const c=l.fromAttribute(e,a.type);this[s]=c??((o=this._$Ej)==null?void 0:o.get(s))??c,this._$Em=null}}requestUpdate(t,e,i,s=!1,n){var o;if(t!==void 0){const a=this.constructor;if(s===!1&&(n=this[t]),i??(i=a.getPropertyOptions(t)),!((i.hasChanged??yo)(n,e)||i.useDefault&&i.reflect&&n===((o=this._$Ej)==null?void 0:o.get(t))&&!this.hasAttribute(a._$Eu(t,i))))return;this.C(t,e,i)}this.isUpdatePending===!1&&(this._$ES=this._$EP())}C(t,e,{useDefault:i,reflect:s,wrapped:n},o){i&&!(this._$Ej??(this._$Ej=new Map)).has(t)&&(this._$Ej.set(t,o??e??this[t]),n!==!0||o!==void 0)||(this._$AL.has(t)||(this.hasUpdated||i||(e=void 0),this._$AL.set(t,e)),s===!0&&this._$Em!==t&&(this._$Eq??(this._$Eq=new Set)).add(t))}async _$EP(){this.isUpdatePending=!0;try{await this._$ES}catch(e){Promise.reject(e)}const t=this.scheduleUpdate();return t!=null&&await t,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){var i;if(!this.isUpdatePending)return;if(!this.hasUpdated){if(this.renderRoot??(this.renderRoot=this.createRenderRoot()),this._$Ep){for(const[n,o]of this._$Ep)this[n]=o;this._$Ep=void 0}const s=this.constructor.elementProperties;if(s.size>0)for(const[n,o]of s){const{wrapped:a}=o,l=this[n];a!==!0||this._$AL.has(n)||l===void 0||this.C(n,void 0,o,l)}}let t=!1;const e=this._$AL;try{t=this.shouldUpdate(e),t?(this.willUpdate(e),(i=this._$EO)==null||i.forEach(s=>{var n;return(n=s.hostUpdate)==null?void 0:n.call(s)}),this.update(e)):this._$EM()}catch(s){throw t=!1,this._$EM(),s}t&&this._$AE(e)}willUpdate(t){}_$AE(t){var e;(e=this._$EO)==null||e.forEach(i=>{var s;return(s=i.hostUpdated)==null?void 0:s.call(i)}),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(t)),this.updated(t)}_$EM(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$ES}shouldUpdate(t){return!0}update(t){this._$Eq&&(this._$Eq=this._$Eq.forEach(e=>this._$ET(e,this[e]))),this._$EM()}updated(t){}firstUpdated(t){}};Wi.elementStyles=[],Wi.shadowRootOptions={mode:"open"},Wi[Es("elementProperties")]=new Map,Wi[Es("finalized")]=new Map,Cn==null||Cn({ReactiveElement:Wi}),(pi.reactiveElementVersions??(pi.reactiveElementVersions=[])).push("2.1.2");/**
|
|
14
14
|
* @license
|
|
15
15
|
* Copyright 2017 Google LLC
|
|
16
16
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
17
|
-
*/const
|
|
17
|
+
*/const Ah={attribute:!0,type:String,converter:Fr,reflect:!1,hasChanged:yo},Dh=(r=Ah,t,e)=>{const{kind:i,metadata:s}=e;let n=globalThis.litPropertyMetadata.get(s);if(n===void 0&&globalThis.litPropertyMetadata.set(s,n=new Map),i==="setter"&&((r=Object.create(r)).wrapped=!0),n.set(e.name,r),i==="accessor"){const{name:o}=e;return{set(a){const l=t.get.call(this);t.set.call(this,a),this.requestUpdate(o,l,r,!0,a)},init(a){return a!==void 0&&this.C(o,void 0,r,a),a}}}if(i==="setter"){const{name:o}=e;return function(a){const l=this[o];t.call(this,a),this.requestUpdate(o,l,r,!0,a)}}throw Error("Unsupported decorator location: "+i)};function C(r){return(t,e)=>typeof e=="object"?Dh(r,t,e):((i,s,n)=>{const o=s.hasOwnProperty(n);return s.constructor.createProperty(n,i),o?Object.getOwnPropertyDescriptor(s,n):void 0})(r,t,e)}/**
|
|
18
18
|
* @license
|
|
19
19
|
* Copyright 2017 Google LLC
|
|
20
20
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
@@ -30,17 +30,17 @@
|
|
|
30
30
|
* @license
|
|
31
31
|
* Copyright 2017 Google LLC
|
|
32
32
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
33
|
-
*/let
|
|
33
|
+
*/let Mh;function _o(r){return(t,e)=>Ml(t,e,{get(){return(this.renderRoot??Mh??(Mh=document.createDocumentFragment())).querySelectorAll(r)}})}/**
|
|
34
34
|
* @license
|
|
35
35
|
* Copyright 2017 Google LLC
|
|
36
36
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
37
|
-
*/const Os=globalThis,la=r=>r,jr=Os.trustedTypes,ca=jr?jr.createPolicy("lit-html",{createHTML:r=>r}):void 0,Il="$lit$",hi=`lit$${Math.random().toFixed(9).slice(2)}$`,Ll="?"+hi,
|
|
38
|
-
\f\r]`,us=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,ha=/-->/g,da=/>/g,
|
|
39
|
-
\f\r"'\`<>=]|("|')|))|$)`,"g"),ua=/'/g,pa=/"/g,Fl=/^(?:script|style|textarea|title)$/i,
|
|
37
|
+
*/const Os=globalThis,la=r=>r,jr=Os.trustedTypes,ca=jr?jr.createPolicy("lit-html",{createHTML:r=>r}):void 0,Il="$lit$",hi=`lit$${Math.random().toFixed(9).slice(2)}$`,Ll="?"+hi,Ih=`<${Ll}>`,Li=document,Fs=()=>Li.createComment(""),js=r=>r===null||typeof r!="object"&&typeof r!="function",xo=Array.isArray,Lh=r=>xo(r)||typeof(r==null?void 0:r[Symbol.iterator])=="function",Sn=`[
|
|
38
|
+
\f\r]`,us=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,ha=/-->/g,da=/>/g,wi=RegExp(`>|${Sn}(?:([^\\s"'>=/]+)(${Sn}*=${Sn}*(?:[^
|
|
39
|
+
\f\r"'\`<>=]|("|')|))|$)`,"g"),ua=/'/g,pa=/"/g,Fl=/^(?:script|style|textarea|title)$/i,Fh=r=>(t,...e)=>({_$litType$:r,strings:t,values:e}),j=Fh(1),fe=Symbol.for("lit-noChange"),K=Symbol.for("lit-nothing"),ga=new WeakMap,ki=Li.createTreeWalker(Li,129);function jl(r,t){if(!xo(r)||!r.hasOwnProperty("raw"))throw Error("invalid template strings array");return ca!==void 0?ca.createHTML(t):t}const jh=(r,t)=>{const e=r.length-1,i=[];let s,n=t===2?"<svg>":t===3?"<math>":"",o=us;for(let a=0;a<e;a++){const l=r[a];let c,h,d=-1,u=0;for(;u<l.length&&(o.lastIndex=u,h=o.exec(l),h!==null);)u=o.lastIndex,o===us?h[1]==="!--"?o=ha:h[1]!==void 0?o=da:h[2]!==void 0?(Fl.test(h[2])&&(s=RegExp("</"+h[2],"g")),o=wi):h[3]!==void 0&&(o=wi):o===wi?h[0]===">"?(o=s??us,d=-1):h[1]===void 0?d=-2:(d=o.lastIndex-h[2].length,c=h[1],o=h[3]===void 0?wi:h[3]==='"'?pa:ua):o===pa||o===ua?o=wi:o===ha||o===da?o=us:(o=wi,s=void 0);const p=o===wi&&r[a+1].startsWith("/>")?" ":"";n+=o===us?l+Ih:d>=0?(i.push(c),l.slice(0,d)+Il+l.slice(d)+hi+p):l+hi+(d===-2?a:p)}return[jl(r,n+(r[e]||"<?>")+(t===2?"</svg>":t===3?"</math>":"")),i]};let Yn=class $l{constructor({strings:t,_$litType$:e},i){let s;this.parts=[];let n=0,o=0;const a=t.length-1,l=this.parts,[c,h]=jh(t,e);if(this.el=$l.createElement(c,i),ki.currentNode=this.el.content,e===2||e===3){const d=this.el.content.firstChild;d.replaceWith(...d.childNodes)}for(;(s=ki.nextNode())!==null&&l.length<a;){if(s.nodeType===1){if(s.hasAttributes())for(const d of s.getAttributeNames())if(d.endsWith(Il)){const u=h[o++],p=s.getAttribute(d).split(hi),g=/([.?@])?(.*)/.exec(u);l.push({type:1,index:n,name:g[2],strings:p,ctor:g[1]==="."?Rh:g[1]==="?"?Bh:g[1]==="@"?zh:Jr}),s.removeAttribute(d)}else d.startsWith(hi)&&(l.push({type:6,index:n}),s.removeAttribute(d));if(Fl.test(s.tagName)){const d=s.textContent.split(hi),u=d.length-1;if(u>0){s.textContent=jr?jr.emptyScript:"";for(let p=0;p<u;p++)s.append(d[p],Fs()),ki.nextNode(),l.push({type:2,index:++n});s.append(d[u],Fs())}}}else if(s.nodeType===8)if(s.data===Ll)l.push({type:2,index:n});else{let d=-1;for(;(d=s.data.indexOf(hi,d+1))!==-1;)l.push({type:7,index:n}),d+=hi.length-1}n++}}static createElement(t,e){const i=Li.createElement("template");return i.innerHTML=t,i}};function ts(r,t,e=r,i){var o,a;if(t===fe)return t;let s=i!==void 0?(o=e._$Co)==null?void 0:o[i]:e._$Cl;const n=js(t)?void 0:t._$litDirective$;return(s==null?void 0:s.constructor)!==n&&((a=s==null?void 0:s._$AO)==null||a.call(s,!1),n===void 0?s=void 0:(s=new n(r),s._$AT(r,e,i)),i!==void 0?(e._$Co??(e._$Co=[]))[i]=s:e._$Cl=s),s!==void 0&&(t=ts(r,s._$AS(r,t.values),s,i)),t}let $h=class{constructor(t,e){this._$AV=[],this._$AN=void 0,this._$AD=t,this._$AM=e}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}u(t){const{el:{content:e},parts:i}=this._$AD,s=((t==null?void 0:t.creationScope)??Li).importNode(e,!0);ki.currentNode=s;let n=ki.nextNode(),o=0,a=0,l=i[0];for(;l!==void 0;){if(o===l.index){let c;l.type===2?c=new Zr(n,n.nextSibling,this,t):l.type===1?c=new l.ctor(n,l.name,l.strings,this,t):l.type===6&&(c=new Hh(n,this,t)),this._$AV.push(c),l=i[++a]}o!==(l==null?void 0:l.index)&&(n=ki.nextNode(),o++)}return ki.currentNode=Li,s}p(t){let e=0;for(const i of this._$AV)i!==void 0&&(i.strings!==void 0?(i._$AI(t,i,e),e+=i.strings.length-2):i._$AI(t[e])),e++}},Zr=class Rl{get _$AU(){var t;return((t=this._$AM)==null?void 0:t._$AU)??this._$Cv}constructor(t,e,i,s){this.type=2,this._$AH=K,this._$AN=void 0,this._$AA=t,this._$AB=e,this._$AM=i,this.options=s,this._$Cv=(s==null?void 0:s.isConnected)??!0}get parentNode(){let t=this._$AA.parentNode;const e=this._$AM;return e!==void 0&&(t==null?void 0:t.nodeType)===11&&(t=e.parentNode),t}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(t,e=this){t=ts(this,t,e),js(t)?t===K||t==null||t===""?(this._$AH!==K&&this._$AR(),this._$AH=K):t!==this._$AH&&t!==fe&&this._(t):t._$litType$!==void 0?this.$(t):t.nodeType!==void 0?this.T(t):Lh(t)?this.k(t):this._(t)}O(t){return this._$AA.parentNode.insertBefore(t,this._$AB)}T(t){this._$AH!==t&&(this._$AR(),this._$AH=this.O(t))}_(t){this._$AH!==K&&js(this._$AH)?this._$AA.nextSibling.data=t:this.T(Li.createTextNode(t)),this._$AH=t}$(t){var n;const{values:e,_$litType$:i}=t,s=typeof i=="number"?this._$AC(t):(i.el===void 0&&(i.el=Yn.createElement(jl(i.h,i.h[0]),this.options)),i);if(((n=this._$AH)==null?void 0:n._$AD)===s)this._$AH.p(e);else{const o=new $h(s,this),a=o.u(this.options);o.p(e),this.T(a),this._$AH=o}}_$AC(t){let e=ga.get(t.strings);return e===void 0&&ga.set(t.strings,e=new Yn(t)),e}k(t){xo(this._$AH)||(this._$AH=[],this._$AR());const e=this._$AH;let i,s=0;for(const n of t)s===e.length?e.push(i=new Rl(this.O(Fs()),this.O(Fs()),this,this.options)):i=e[s],i._$AI(n),s++;s<e.length&&(this._$AR(i&&i._$AB.nextSibling,s),e.length=s)}_$AR(t=this._$AA.nextSibling,e){var i;for((i=this._$AP)==null?void 0:i.call(this,!1,!0,e);t!==this._$AB;){const s=la(t).nextSibling;la(t).remove(),t=s}}setConnected(t){var e;this._$AM===void 0&&(this._$Cv=t,(e=this._$AP)==null||e.call(this,t))}},Jr=class{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(t,e,i,s,n){this.type=1,this._$AH=K,this._$AN=void 0,this.element=t,this.name=e,this._$AM=s,this.options=n,i.length>2||i[0]!==""||i[1]!==""?(this._$AH=Array(i.length-1).fill(new String),this.strings=i):this._$AH=K}_$AI(t,e=this,i,s){const n=this.strings;let o=!1;if(n===void 0)t=ts(this,t,e,0),o=!js(t)||t!==this._$AH&&t!==fe,o&&(this._$AH=t);else{const a=t;let l,c;for(t=n[0],l=0;l<n.length-1;l++)c=ts(this,a[i+l],e,l),c===fe&&(c=this._$AH[l]),o||(o=!js(c)||c!==this._$AH[l]),c===K?t=K:t!==K&&(t+=(c??"")+n[l+1]),this._$AH[l]=c}o&&!s&&this.j(t)}j(t){t===K?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,t??"")}},Rh=class extends Jr{constructor(){super(...arguments),this.type=3}j(t){this.element[this.name]=t===K?void 0:t}},Bh=class extends Jr{constructor(){super(...arguments),this.type=4}j(t){this.element.toggleAttribute(this.name,!!t&&t!==K)}},zh=class extends Jr{constructor(t,e,i,s,n){super(t,e,i,s,n),this.type=5}_$AI(t,e=this){if((t=ts(this,t,e,0)??K)===fe)return;const i=this._$AH,s=t===K&&i!==K||t.capture!==i.capture||t.once!==i.once||t.passive!==i.passive,n=t!==K&&(i===K||s);s&&this.element.removeEventListener(this.name,this,i),n&&this.element.addEventListener(this.name,this,t),this._$AH=t}handleEvent(t){var e;typeof this._$AH=="function"?this._$AH.call(((e=this.options)==null?void 0:e.host)??this.element,t):this._$AH.handleEvent(t)}},Hh=class{constructor(t,e,i){this.element=t,this.type=6,this._$AN=void 0,this._$AM=e,this.options=i}get _$AU(){return this._$AM._$AU}_$AI(t){ts(this,t)}};const Vh={I:Zr},Tn=Os.litHtmlPolyfillSupport;Tn==null||Tn(Yn,Zr),(Os.litHtmlVersions??(Os.litHtmlVersions=[])).push("3.3.2");const Bl=(r,t,e)=>{const i=(e==null?void 0:e.renderBefore)??t;let s=i._$litPart$;if(s===void 0){const n=(e==null?void 0:e.renderBefore)??null;i._$litPart$=s=new Zr(t.insertBefore(Fs(),n),n,void 0,e??{})}return s._$AI(r),s};/**
|
|
40
40
|
* @license
|
|
41
41
|
* Copyright 2017 Google LLC
|
|
42
42
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
43
|
-
*/const
|
|
43
|
+
*/const Mi=globalThis;let ks=class extends Wi{constructor(){super(...arguments),this.renderOptions={host:this},this._$Do=void 0}createRenderRoot(){var e;const t=super.createRenderRoot();return(e=this.renderOptions).renderBefore??(e.renderBefore=t.firstChild),t}update(t){const e=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(t),this._$Do=Bl(e,this.renderRoot,this.renderOptions)}connectedCallback(){var t;super.connectedCallback(),(t=this._$Do)==null||t.setConnected(!0)}disconnectedCallback(){var t;super.disconnectedCallback(),(t=this._$Do)==null||t.setConnected(!1)}render(){return fe}};var Al;ks._$litElement$=!0,ks.finalized=!0,(Al=Mi.litElementHydrateSupport)==null||Al.call(Mi,{LitElement:ks});const En=Mi.litElementPolyfillSupport;En==null||En({LitElement:ks});(Mi.litElementVersions??(Mi.litElementVersions=[])).push("4.2.2");const Ot=gt`
|
|
44
44
|
:host {
|
|
45
45
|
box-sizing: border-box;
|
|
46
46
|
text-shadow: none;
|
|
@@ -57,7 +57,7 @@
|
|
|
57
57
|
[hidden] {
|
|
58
58
|
display: none !important;
|
|
59
59
|
}
|
|
60
|
-
`;class kt extends ks{emit(t,e){const i=new CustomEvent(t,{bubbles:!0,cancelable:!0,composed:!0,detail:{},...e});return this.dispatchEvent(i),i}}const
|
|
60
|
+
`;class kt extends ks{emit(t,e){const i=new CustomEvent(t,{bubbles:!0,cancelable:!0,composed:!0,detail:{},...e});return this.dispatchEvent(i),i}}const Nh=gt`
|
|
61
61
|
:host {
|
|
62
62
|
display: block;
|
|
63
63
|
width: 100%;
|
|
@@ -216,7 +216,7 @@
|
|
|
216
216
|
height: 100%;
|
|
217
217
|
padding: var(--pbo-spacing-large);
|
|
218
218
|
}
|
|
219
|
-
`,
|
|
219
|
+
`,Uh=gt`
|
|
220
220
|
:host {
|
|
221
221
|
display: block;
|
|
222
222
|
}
|
|
@@ -224,7 +224,7 @@
|
|
|
224
224
|
* @license
|
|
225
225
|
* Copyright 2021 Google LLC
|
|
226
226
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
227
|
-
*/function*zl(r,t){if(r!==void 0){let e=0;for(const i of r)yield t(i,e++)}}const
|
|
227
|
+
*/function*zl(r,t){if(r!==void 0){let e=0;for(const i of r)yield t(i,e++)}}const Wh=gt`
|
|
228
228
|
:host {
|
|
229
229
|
display: block;
|
|
230
230
|
--title-font-size: 18.75px;
|
|
@@ -414,7 +414,7 @@
|
|
|
414
414
|
justify-content: center;
|
|
415
415
|
align-items: center;
|
|
416
416
|
}
|
|
417
|
-
`,Gh=".splide__container{box-sizing:border-box;position:relative}.splide__list{backface-visibility:hidden;display:-ms-flexbox;display:flex;height:100%;margin:0!important;padding:0!important}.splide.is-initialized:not(.is-active) .splide__list{display:block}.splide__pagination{-ms-flex-align:center;align-items:center;display:-ms-flexbox;display:flex;-ms-flex-wrap:wrap;flex-wrap:wrap;-ms-flex-pack:center;justify-content:center;margin:0;pointer-events:none}.splide__pagination li{display:inline-block;line-height:1;list-style-type:none;margin:0;pointer-events:auto}.splide:not(.is-overflow) .splide__pagination{display:none}.splide__progress__bar{width:0}.splide{position:relative;visibility:hidden}.splide.is-initialized,.splide.is-rendered{visibility:visible}.splide__slide{backface-visibility:hidden;box-sizing:border-box;-ms-flex-negative:0;flex-shrink:0;list-style-type:none!important;margin:0;position:relative}.splide__slide img{vertical-align:bottom}.splide__spinner{animation:splide-loading 1s linear infinite;border:2px solid #999;border-left-color:transparent;border-radius:50%;bottom:0;contain:strict;display:inline-block;height:20px;left:0;margin:auto;position:absolute;right:0;top:0;width:20px}.splide__sr{clip:rect(0 0 0 0);border:0;height:1px;margin:-1px;overflow:hidden;padding:0;position:absolute;width:1px}.splide__toggle.is-active .splide__toggle__play,.splide__toggle__pause{display:none}.splide__toggle.is-active .splide__toggle__pause{display:inline}.splide__track{overflow:hidden;position:relative;z-index:0}@keyframes splide-loading{0%{transform:rotate(0)}to{transform:rotate(1turn)}}.splide__track--draggable{-webkit-touch-callout:none;-webkit-user-select:none;-ms-user-select:none;user-select:none}.splide__track--fade>.splide__list>.splide__slide{margin:0!important;opacity:0;z-index:0}.splide__track--fade>.splide__list>.splide__slide.is-active{opacity:1;z-index:1}.splide--rtl{direction:rtl}.splide__track--ttb>.splide__list{display:block}.splide__arrow{-ms-flex-align:center;align-items:center;background:#ccc;border:0;border-radius:50%;cursor:pointer;display:-ms-flexbox;display:flex;height:2em;-ms-flex-pack:center;justify-content:center;opacity:.7;padding:0;position:absolute;top:50%;transform:translateY(-50%);width:2em;z-index:1}.splide__arrow svg{fill:#000;height:1.2em;width:1.2em}.splide__arrow:hover:not(:disabled){opacity:.9}.splide__arrow:disabled{opacity:.3}.splide__arrow:focus-visible{outline:3px solid #0bf;outline-offset:3px}.splide__arrow--prev{left:1em}.splide__arrow--prev svg{transform:scaleX(-1)}.splide__arrow--next{right:1em}.splide.is-focus-in .splide__arrow:focus{outline:3px solid #0bf;outline-offset:3px}.splide__pagination{bottom:.5em;left:0;padding:0 1em;position:absolute;right:0;z-index:1}.splide__pagination__page{background:#ccc;border:0;border-radius:50%;display:inline-block;height:8px;margin:3px;opacity:.7;padding:0;position:relative;transition:transform .2s linear;width:8px}.splide__pagination__page.is-active{background:#fff;transform:scale(1.4);z-index:1}.splide__pagination__page:hover{cursor:pointer;opacity:.9}.splide__pagination__page:focus-visible{outline:3px solid #0bf;outline-offset:3px}.splide.is-focus-in .splide__pagination__page:focus{outline:3px solid #0bf;outline-offset:3px}.splide__progress__bar{background:#ccc;height:3px}.splide__slide{-webkit-tap-highlight-color:rgba(0,0,0,0)}.splide__slide:focus{outline:0}@supports (outline-offset:-3px){.splide__slide:focus-visible{outline:3px solid #0bf;outline-offset:-3px}}@media screen and (-ms-high-contrast:none){.splide__slide:focus-visible{border:3px solid #0bf}}@supports (outline-offset:-3px){.splide.is-focus-in .splide__slide:focus{outline:3px solid #0bf;outline-offset:-3px}}@media screen and (-ms-high-contrast:none){.splide.is-focus-in .splide__slide:focus{border:3px solid #0bf}.splide.is-focus-in .splide__track>.splide__list>.splide__slide:focus{border-color:#0bf}}.splide__toggle{cursor:pointer}.splide__toggle:focus-visible{outline:3px solid #0bf;outline-offset:3px}.splide.is-focus-in .splide__toggle:focus{outline:3px solid #0bf;outline-offset:3px}.splide__track--nav>.splide__list>.splide__slide{border:3px solid transparent;cursor:pointer}.splide__track--nav>.splide__list>.splide__slide.is-active{border:3px solid #000}.splide__arrows--rtl .splide__arrow--prev{left:auto;right:1em}.splide__arrows--rtl .splide__arrow--prev svg{transform:scaleX(1)}.splide__arrows--rtl .splide__arrow--next{left:1em;right:auto}.splide__arrows--rtl .splide__arrow--next svg{transform:scaleX(-1)}.splide__arrows--ttb .splide__arrow{left:50%;transform:translate(-50%)}.splide__arrows--ttb .splide__arrow--prev{top:1em}.splide__arrows--ttb .splide__arrow--prev svg{transform:rotate(-90deg)}.splide__arrows--ttb .splide__arrow--next{bottom:1em;top:auto}.splide__arrows--ttb .splide__arrow--next svg{transform:rotate(90deg)}.splide__pagination--ttb{bottom:0;display:-ms-flexbox;display:flex;-ms-flex-direction:column;flex-direction:column;left:auto;padding:1em 0;right:.5em;top:0}";function wo(r){return typeof r=="number"}function Gn(r){return typeof r=="string"}function Qr(r){return typeof r=="boolean"}function fa(r){return Object.prototype.toString.call(r)==="[object Object]"}function ct(r){return Math.abs(r)}function Co(r){return Math.sign(r)}function Ps(r,t){return ct(r-t)}function Xh(r,t){if(r===0||t===0||ct(r)<=ct(t))return 0;const e=Ps(ct(r),ct(t));return ct(e/r)}function Kh(r){return Math.round(r*100)/100}function $s(r){return Rs(r).map(Number)}function Te(r){return r[Gs(r)]}function Gs(r){return Math.max(0,r.length-1)}function So(r,t){return t===Gs(r)}function ma(r,t=0){return Array.from(Array(r),(e,i)=>t+i)}function Rs(r){return Object.keys(r)}function Hl(r,t){return[r,t].reduce((e,i)=>(Rs(i).forEach(s=>{const n=e[s],o=i[s],a=fa(n)&&fa(o);e[s]=a?Hl(n,o):o}),e),{})}function Xn(r,t){return typeof t.MouseEvent<"u"&&r instanceof t.MouseEvent}function qh(r,t){const e={start:i,center:s,end:n};function i(){return 0}function s(l){return n(l)/2}function n(l){return t-l}function o(l,c){return Gn(r)?e[r](l):r(t,l,c)}return{measure:o}}function Bs(){let r=[];function t(s,n,o,a={passive:!0}){let l;if("addEventListener"in s)s.addEventListener(n,o,a),l=()=>s.removeEventListener(n,o,a);else{const c=s;c.addListener(o),l=()=>c.removeListener(o)}return r.push(l),i}function e(){r=r.filter(s=>s())}const i={add:t,clear:e};return i}function Zh(r,t,e,i){const s=Bs(),n=1e3/60;let o=null,a=0,l=0;function c(){s.add(r,"visibilitychange",()=>{r.hidden&&g()})}function h(){p(),s.clear()}function d(m){if(!l)return;o||(o=m,e(),e());const b=m-o;for(o=m,a+=b;a>=n;)e(),a-=n;const _=a/n;i(_),l&&(l=t.requestAnimationFrame(d))}function u(){l||(l=t.requestAnimationFrame(d))}function p(){t.cancelAnimationFrame(l),o=null,a=0,l=0}function g(){o=null,a=0}return{init:c,destroy:h,start:u,stop:p,update:e,render:i}}function Jh(r,t){const e=t==="rtl",i=r==="y",s=i?"y":"x",n=i?"x":"y",o=!i&&e?-1:1,a=h(),l=d();function c(g){const{height:f,width:m}=g;return i?f:m}function h(){return i?"top":e?"right":"left"}function d(){return i?"bottom":e?"left":"right"}function u(g){return g*o}return{scroll:s,cross:n,startEdge:a,endEdge:l,measureSize:c,direction:u}}function Fi(r=0,t=0){const e=ct(r-t);function i(c){return c<r}function s(c){return c>t}function n(c){return i(c)||s(c)}function o(c){return n(c)?i(c)?r:t:c}function a(c){return e?c-e*Math.ceil((c-t)/e):c}return{length:e,max:t,min:r,constrain:o,reachedAny:n,reachedMax:s,reachedMin:i,removeOffset:a}}function Vl(r,t,e){const{constrain:i}=Fi(0,r),s=r+1;let n=o(t);function o(u){return e?ct((s+u)%s):i(u)}function a(){return n}function l(u){return n=o(u),d}function c(u){return h().set(a()+u)}function h(){return Vl(r,a(),e)}const d={get:a,set:l,add:c,clone:h};return d}function Qh(r,t,e,i,s,n,o,a,l,c,h,d,u,p,g,f,m,b,_){const{cross:w,direction:S}=r,T=["INPUT","SELECT","TEXTAREA"],k={passive:!1},O=Bs(),E=Bs(),P=Fi(50,225).constrain(p.measure(20)),R={mouse:300,touch:400},L={mouse:500,touch:600},F=g?43:25;let H=!1,M=0,U=0,X=!1,Q=!1,N=!1,Ct=!1;function Ut(D){if(!_)return;function tt(Yt){(Qr(_)||_(D,Yt))&&ae(Yt)}const St=t;O.add(St,"dragstart",Yt=>Yt.preventDefault(),k).add(St,"touchmove",()=>{},k).add(St,"touchend",()=>{}).add(St,"touchstart",tt).add(St,"mousedown",tt).add(St,"touchcancel",jt).add(St,"contextmenu",jt).add(St,"click",le,!0)}function Wt(){O.clear(),E.clear()}function Pe(){const D=Ct?e:t;E.add(D,"touchmove",At,k).add(D,"touchend",jt).add(D,"mousemove",At,k).add(D,"mouseup",jt)}function de(D){const tt=D.nodeName||"";return T.includes(tt)}function Ft(){return(g?L:R)[Ct?"mouse":"touch"]}function Ae(D,tt){const St=d.add(Co(D)*-1),Yt=h.byDistance(D,!g).distance;return g||ct(D)<P?Yt:m&&tt?Yt*.5:h.byIndex(St.get(),0).distance}function ae(D){const tt=Xn(D,i);Ct=tt,N=g&&tt&&!D.buttons&&H,H=Ps(s.get(),o.get())>=2,!(tt&&D.button!==0)&&(de(D.target)||(X=!0,n.pointerDown(D),c.useFriction(0).useDuration(0),s.set(o),Pe(),M=n.readPoint(D),U=n.readPoint(D,w),u.emit("pointerDown")))}function At(D){if(!Xn(D,i)&&D.touches.length>=2)return jt(D);const St=n.readPoint(D),Yt=n.readPoint(D,w),De=Ps(St,M),Ve=Ps(Yt,U);if(!Q&&!Ct&&(!D.cancelable||(Q=De>Ve,!Q)))return jt(D);const xi=n.pointerMove(D);De>f&&(N=!0),c.useFriction(.3).useDuration(.75),a.start(),s.add(S(xi)),D.preventDefault()}function jt(D){const St=h.byDistance(0,!1).index!==d.get(),Yt=n.pointerUp(D)*Ft(),De=Ae(S(Yt),St),Ve=Xh(Yt,De),xi=F-10*Ve,oi=b+Ve/50;Q=!1,X=!1,E.clear(),c.useDuration(xi).useFriction(oi),l.distance(De,!g),Ct=!1,u.emit("pointerUp")}function le(D){N&&(D.stopPropagation(),D.preventDefault(),N=!1)}function vt(){return X}return{init:Ut,destroy:Wt,pointerDown:vt}}function td(r,t){let i,s;function n(d){return d.timeStamp}function o(d,u){const g=`client${(u||r.scroll)==="x"?"X":"Y"}`;return(Xn(d,t)?d:d.touches[0])[g]}function a(d){return i=d,s=d,o(d)}function l(d){const u=o(d)-o(s),p=n(d)-n(i)>170;return s=d,p&&(i=d),u}function c(d){if(!i||!s)return 0;const u=o(s)-o(i),p=n(d)-n(i),g=n(d)-n(s)>170,f=u/p;return p&&!g&&ct(f)>.1?f:0}return{pointerDown:a,pointerMove:l,pointerUp:c,readPoint:o}}function ed(){function r(e){const{offsetTop:i,offsetLeft:s,offsetWidth:n,offsetHeight:o}=e;return{top:i,right:s+n,bottom:i+o,left:s,width:n,height:o}}return{measure:r}}function id(r){function t(i){return r*(i/100)}return{measure:t}}function sd(r,t,e,i,s,n,o){const a=[r].concat(i);let l,c,h=[],d=!1;function u(m){return s.measureSize(o.measure(m))}function p(m){if(!n)return;c=u(r),h=i.map(u);function b(_){for(const w of _){if(d)return;const S=w.target===r,T=i.indexOf(w.target),k=S?c:h[T],O=u(S?r:i[T]);if(ct(O-k)>=.5){m.reInit(),t.emit("resize");break}}}l=new ResizeObserver(_=>{(Qr(n)||n(m,_))&&b(_)}),e.requestAnimationFrame(()=>{a.forEach(_=>l.observe(_))})}function g(){d=!0,l&&l.disconnect()}return{init:p,destroy:g}}function rd(r,t,e,i,s,n){let o=0,a=0,l=s,c=n,h=r.get(),d=0;function u(){const k=i.get()-r.get(),O=!l;let E=0;return O?(o=0,e.set(i),r.set(i),E=k):(e.set(r),o+=k/l,o*=c,h+=o,r.add(o),E=h-d),a=Co(E),d=h,T}function p(){const k=i.get()-t.get();return ct(k)<.001}function g(){return l}function f(){return a}function m(){return o}function b(){return w(s)}function _(){return S(n)}function w(k){return l=k,T}function S(k){return c=k,T}const T={direction:f,duration:g,velocity:m,seek:u,settled:p,useBaseFriction:_,useBaseDuration:b,useFriction:S,useDuration:w};return T}function nd(r,t,e,i,s){const n=s.measure(10),o=s.measure(50),a=Fi(.1,.99);let l=!1;function c(){return!(l||!r.reachedAny(e.get())||!r.reachedAny(t.get()))}function h(p){if(!c())return;const g=r.reachedMin(t.get())?"min":"max",f=ct(r[g]-t.get()),m=e.get()-t.get(),b=a.constrain(f/o);e.subtract(m*b),!p&&ct(m)<n&&(e.set(r.constrain(e.get())),i.useDuration(25).useBaseFriction())}function d(p){l=!p}return{shouldConstrain:c,constrain:h,toggleActive:d}}function od(r,t,e,i,s){const n=Fi(-t+r,0),o=d(),a=h(),l=u();function c(g,f){return Ps(g,f)<=1}function h(){const g=o[0],f=Te(o),m=o.lastIndexOf(g),b=o.indexOf(f)+1;return Fi(m,b)}function d(){return e.map((g,f)=>{const{min:m,max:b}=n,_=n.constrain(g),w=!f,S=So(e,f);return w?b:S||c(m,_)?m:c(b,_)?b:_}).map(g=>parseFloat(g.toFixed(3)))}function u(){if(t<=r+s)return[n.max];if(i==="keepSnaps")return o;const{min:g,max:f}=a;return o.slice(g,f)}return{snapsContained:l,scrollContainLimit:a}}function ad(r,t,e){const i=t[0],s=e?i-r:Te(t);return{limit:Fi(s,i)}}function ld(r,t,e,i){const n=t.min+.1,o=t.max+.1,{reachedMin:a,reachedMax:l}=Fi(n,o);function c(u){return u===1?l(e.get()):u===-1?a(e.get()):!1}function h(u){if(!c(u))return;const p=r*(u*-1);i.forEach(g=>g.add(p))}return{loop:h}}function cd(r){const{max:t,length:e}=r;function i(n){const o=n-t;return e?o/-e:0}return{get:i}}function hd(r,t,e,i,s){const{startEdge:n,endEdge:o}=r,{groupSlides:a}=s,l=d().map(t.measure),c=u(),h=p();function d(){return a(i).map(f=>Te(f)[o]-f[0][n]).map(ct)}function u(){return i.map(f=>e[n]-f[n]).map(f=>-ct(f))}function p(){return a(c).map(f=>f[0]).map((f,m)=>f+l[m])}return{snaps:c,snapsAligned:h}}function dd(r,t,e,i,s,n){const{groupSlides:o}=s,{min:a,max:l}=i,c=h();function h(){const u=o(n),p=!r||t==="keepSnaps";return e.length===1?[n]:p?u:u.slice(a,l).map((g,f,m)=>{const b=!f,_=So(m,f);if(b){const w=Te(m[0])+1;return ma(w)}if(_){const w=Gs(n)-Te(m)[0]+1;return ma(w,Te(m)[0])}return g})}return{slideRegistry:c}}function ud(r,t,e,i,s){const{reachedAny:n,removeOffset:o,constrain:a}=i;function l(g){return g.concat().sort((f,m)=>ct(f)-ct(m))[0]}function c(g){const f=r?o(g):a(g),m=t.map((_,w)=>({diff:h(_-f,0),index:w})).sort((_,w)=>ct(_.diff)-ct(w.diff)),{index:b}=m[0];return{index:b,distance:f}}function h(g,f){const m=[g,g+e,g-e];if(!r)return g;if(!f)return l(m);const b=m.filter(_=>Co(_)===f);return b.length?l(b):Te(m)-e}function d(g,f){const m=t[g]-s.get(),b=h(m,f);return{index:g,distance:b}}function u(g,f){const m=s.get()+g,{index:b,distance:_}=c(m),w=!r&&n(m);if(!f||w)return{index:b,distance:g};const S=t[b]-_,T=g+h(S,0);return{index:b,distance:T}}return{byDistance:u,byIndex:d,shortcut:h}}function pd(r,t,e,i,s,n,o){function a(d){const u=d.distance,p=d.index!==t.get();n.add(u),u&&(i.duration()?r.start():(r.update(),r.render(1),r.update())),p&&(e.set(t.get()),t.set(d.index),o.emit("select"))}function l(d,u){const p=s.byDistance(d,u);a(p)}function c(d,u){const p=t.clone().set(d),g=s.byIndex(p.get(),u);a(g)}return{distance:l,index:c}}function gd(r,t,e,i,s,n,o,a){const l={passive:!0,capture:!0};let c=0;function h(p){if(!a)return;function g(f){if(new Date().getTime()-c>10)return;o.emit("slideFocusStart"),r.scrollLeft=0;const _=e.findIndex(w=>w.includes(f));wo(_)&&(s.useDuration(0),i.index(_,0),o.emit("slideFocus"))}n.add(document,"keydown",d,!1),t.forEach((f,m)=>{n.add(f,"focus",b=>{(Qr(a)||a(p,b))&&g(m)},l)})}function d(p){p.code==="Tab"&&(c=new Date().getTime())}return{init:h}}function Cs(r){let t=r;function e(){return t}function i(l){t=o(l)}function s(l){t+=o(l)}function n(l){t-=o(l)}function o(l){return wo(l)?l:l.get()}return{get:e,set:i,add:s,subtract:n}}function Nl(r,t){const e=r.scroll==="x"?o:a,i=t.style;let s=null,n=!1;function o(u){return`translate3d(${u}px,0px,0px)`}function a(u){return`translate3d(0px,${u}px,0px)`}function l(u){if(n)return;const p=Kh(r.direction(u));p!==s&&(i.transform=e(p),s=p)}function c(u){n=!u}function h(){n||(i.transform="",t.getAttribute("style")||t.removeAttribute("style"))}return{clear:h,to:l,toggleActive:c}}function fd(r,t,e,i,s,n,o,a,l){const h=$s(s),d=$s(s).reverse(),u=b().concat(_());function p(O,E){return O.reduce((P,R)=>P-s[R],E)}function g(O,E){return O.reduce((P,R)=>p(P,E)>0?P.concat([R]):P,[])}function f(O){return n.map((E,P)=>({start:E-i[P]+.5+O,end:E+t-.5+O}))}function m(O,E,P){const R=f(E);return O.map(L=>{const F=P?0:-e,H=P?e:0,M=P?"end":"start",U=R[L][M];return{index:L,loopPoint:U,slideLocation:Cs(-1),translate:Nl(r,l[L]),target:()=>a.get()>U?F:H}})}function b(){const O=o[0],E=g(d,O);return m(E,e,!1)}function _(){const O=t-o[0]-1,E=g(h,O);return m(E,-e,!0)}function w(){return u.every(({index:O})=>{const E=h.filter(P=>P!==O);return p(E,t)<=.1})}function S(){u.forEach(O=>{const{target:E,translate:P,slideLocation:R}=O,L=E();L!==R.get()&&(P.to(L),R.set(L))})}function T(){u.forEach(O=>O.translate.clear())}return{canLoop:w,clear:T,loop:S,loopPoints:u}}function md(r,t,e){let i,s=!1;function n(l){if(!e)return;function c(h){for(const d of h)if(d.type==="childList"){l.reInit(),t.emit("slidesChanged");break}}i=new MutationObserver(h=>{s||(Qr(e)||e(l,h))&&c(h)}),i.observe(r,{childList:!0})}function o(){i&&i.disconnect(),s=!0}return{init:n,destroy:o}}function bd(r,t,e,i){const s={};let n=null,o=null,a,l=!1;function c(){a=new IntersectionObserver(g=>{l||(g.forEach(f=>{const m=t.indexOf(f.target);s[m]=f}),n=null,o=null,e.emit("slidesInView"))},{root:r.parentElement,threshold:i}),t.forEach(g=>a.observe(g))}function h(){a&&a.disconnect(),l=!0}function d(g){return Rs(s).reduce((f,m)=>{const b=parseInt(m),{isIntersecting:_}=s[b];return(g&&_||!g&&!_)&&f.push(b),f},[])}function u(g=!0){if(g&&n)return n;if(!g&&o)return o;const f=d(g);return g&&(n=f),g||(o=f),f}return{init:c,destroy:h,get:u}}function vd(r,t,e,i,s,n){const{measureSize:o,startEdge:a,endEdge:l}=r,c=e[0]&&s,h=g(),d=f(),u=e.map(o),p=m();function g(){if(!c)return 0;const _=e[0];return ct(t[a]-_[a])}function f(){if(!c)return 0;const _=n.getComputedStyle(Te(i));return parseFloat(_.getPropertyValue(`margin-${l}`))}function m(){return e.map((_,w,S)=>{const T=!w,k=So(S,w);return T?u[w]+h:k?u[w]+d:S[w+1][a]-_[a]}).map(ct)}return{slideSizes:u,slideSizesWithGaps:p,startGap:h,endGap:d}}function yd(r,t,e,i,s,n,o,a,l){const{startEdge:c,endEdge:h,direction:d}=r,u=wo(e);function p(b,_){return $s(b).filter(w=>w%_===0).map(w=>b.slice(w,w+_))}function g(b){return b.length?$s(b).reduce((_,w,S)=>{const T=Te(_)||0,k=T===0,O=w===Gs(b),E=s[c]-n[T][c],P=s[c]-n[w][h],R=!i&&k?d(o):0,L=!i&&O?d(a):0,F=ct(P-L-(E+R));return S&&F>t+l&&_.push(w),O&&_.push(b.length),_},[]).map((_,w,S)=>{const T=Math.max(S[w-1]||0);return b.slice(T,_)}):[]}function f(b){return u?p(b,e):g(b)}return{groupSlides:f}}function _d(r,t,e,i,s,n,o){const{align:a,axis:l,direction:c,startIndex:h,loop:d,duration:u,dragFree:p,dragThreshold:g,inViewThreshold:f,slidesToScroll:m,skipSnaps:b,containScroll:_,watchResize:w,watchSlides:S,watchDrag:T,watchFocus:k}=n,O=2,E=ed(),P=E.measure(t),R=e.map(E.measure),L=Jh(l,c),F=L.measureSize(P),H=id(F),M=qh(a,F),U=!d&&!!_,X=d||!!_,{slideSizes:Q,slideSizesWithGaps:N,startGap:Ct,endGap:Ut}=vd(L,P,R,e,X,s),Wt=yd(L,F,m,d,P,R,Ct,Ut,O),{snaps:Pe,snapsAligned:de}=hd(L,M,P,R,Wt),Ft=-Te(Pe)+Te(N),{snapsContained:Ae,scrollContainLimit:ae}=od(F,Ft,de,_,O),At=U?Ae:de,{limit:jt}=ad(Ft,At,d),le=Vl(Gs(At),h,d),vt=le.clone(),at=$s(e),D=({dragHandler:Vi,scrollBody:xn,scrollBounds:wn,options:{loop:tr}})=>{tr||wn.constrain(Vi.pointerDown()),xn.seek()},tt=({scrollBody:Vi,translate:xn,location:wn,offsetLocation:tr,previousLocation:fh,scrollLooper:mh,slideLooper:bh,dragHandler:vh,animation:yh,eventHandler:Jo,scrollBounds:_h,options:{loop:Qo}},ta)=>{const ea=Vi.settled(),xh=!_h.shouldConstrain(),ia=Qo?ea:ea&&xh,sa=ia&&!vh.pointerDown();sa&&yh.stop();const wh=wn.get()*ta+fh.get()*(1-ta);tr.set(wh),Qo&&(mh.loop(Vi.direction()),bh.loop()),xn.to(tr.get()),sa&&Jo.emit("settle"),ia||Jo.emit("scroll")},St=Zh(i,s,()=>D(_n),Vi=>tt(_n,Vi)),Yt=.68,De=At[le.get()],Ve=Cs(De),xi=Cs(De),oi=Cs(De),wi=Cs(De),ds=rd(Ve,oi,xi,wi,u,Yt),vn=ud(d,At,Ft,jt,wi),yn=pd(St,le,vt,ds,vn,wi,o),Ko=cd(jt),qo=Bs(),ph=bd(t,e,o,f),{slideRegistry:Zo}=dd(U,_,At,ae,Wt,at),gh=gd(r,e,Zo,yn,ds,qo,o,k),_n={ownerDocument:i,ownerWindow:s,eventHandler:o,containerRect:P,slideRects:R,animation:St,axis:L,dragHandler:Qh(L,r,i,s,wi,td(L,s),Ve,St,yn,ds,vn,le,o,H,p,g,b,Yt,T),eventStore:qo,percentOfView:H,index:le,indexPrevious:vt,limit:jt,location:Ve,offsetLocation:oi,previousLocation:xi,options:n,resizeHandler:sd(t,o,s,e,L,w,E),scrollBody:ds,scrollBounds:nd(jt,oi,wi,ds,H),scrollLooper:ld(Ft,jt,oi,[Ve,oi,xi,wi]),scrollProgress:Ko,scrollSnapList:At.map(Ko.get),scrollSnaps:At,scrollTarget:vn,scrollTo:yn,slideLooper:fd(L,F,Ft,Q,N,Pe,At,oi,e),slideFocus:gh,slidesHandler:md(t,o,S),slidesInView:ph,slideIndexes:at,slideRegistry:Zo,slidesToScroll:Wt,target:wi,translate:Nl(L,t)};return _n}function xd(){let r={},t;function e(c){t=c}function i(c){return r[c]||[]}function s(c){return i(c).forEach(h=>h(t,c)),l}function n(c,h){return r[c]=i(c).concat([h]),l}function o(c,h){return r[c]=i(c).filter(d=>d!==h),l}function a(){r={}}const l={init:e,emit:s,off:o,on:n,clear:a};return l}const wd={align:"center",axis:"x",container:null,slides:null,containScroll:"trimSnaps",direction:"ltr",slidesToScroll:1,inViewThreshold:0,breakpoints:{},dragFree:!1,dragThreshold:10,loop:!1,skipSnaps:!1,duration:25,startIndex:0,active:!0,watchDrag:!0,watchResize:!0,watchSlides:!0,watchFocus:!0};function Cd(r){function t(n,o){return Hl(n,o||{})}function e(n){const o=n.breakpoints||{},a=Rs(o).filter(l=>r.matchMedia(l).matches).map(l=>o[l]).reduce((l,c)=>t(l,c),{});return t(n,a)}function i(n){return n.map(o=>Rs(o.breakpoints||{})).reduce((o,a)=>o.concat(a),[]).map(r.matchMedia)}return{mergeOptions:t,optionsAtMedia:e,optionsMediaQueries:i}}function Sd(r){let t=[];function e(n,o){return t=o.filter(({options:a})=>r.optionsAtMedia(a).active!==!1),t.forEach(a=>a.init(n,r)),o.reduce((a,l)=>Object.assign(a,{[l.name]:l}),{})}function i(){t=t.filter(n=>n.destroy())}return{init:e,destroy:i}}function To(r,t,e){const i=r.ownerDocument,s=i.defaultView,n=Cd(s),o=Sd(n),a=Bs(),l=xd(),{mergeOptions:c,optionsAtMedia:h,optionsMediaQueries:d}=n,{on:u,off:p,emit:g}=l,f=L;let m=!1,b,_=c(wd,To.globalOptions),w=c(_),S=[],T,k,O;function E(){const{container:at,slides:D}=w;k=(Gn(at)?r.querySelector(at):at)||r.children[0];const St=Gn(D)?k.querySelectorAll(D):D;O=[].slice.call(St||k.children)}function P(at){const D=_d(r,k,O,i,s,at,l);if(at.loop&&!D.slideLooper.canLoop()){const tt=Object.assign({},at,{loop:!1});return P(tt)}return D}function R(at,D){m||(_=c(_,at),w=h(_),S=D||S,E(),b=P(w),d([_,...S.map(({options:tt})=>tt)]).forEach(tt=>a.add(tt,"change",L)),w.active&&(b.translate.to(b.location.get()),b.animation.init(),b.slidesInView.init(),b.slideFocus.init(vt),b.eventHandler.init(vt),b.resizeHandler.init(vt),b.slidesHandler.init(vt),b.options.loop&&b.slideLooper.loop(),k.offsetParent&&O.length&&b.dragHandler.init(vt),T=o.init(vt,S)))}function L(at,D){const tt=Wt();F(),R(c({startIndex:tt},at),D),l.emit("reInit")}function F(){b.dragHandler.destroy(),b.eventStore.clear(),b.translate.clear(),b.slideLooper.clear(),b.resizeHandler.destroy(),b.slidesHandler.destroy(),b.slidesInView.destroy(),b.animation.destroy(),o.destroy(),a.clear()}function H(){m||(m=!0,a.clear(),F(),l.emit("destroy"),l.clear())}function M(at,D,tt){!w.active||m||(b.scrollBody.useBaseFriction().useDuration(D===!0?0:w.duration),b.scrollTo.index(at,tt||0))}function U(at){const D=b.index.add(1).get();M(D,at,-1)}function X(at){const D=b.index.add(-1).get();M(D,at,1)}function Q(){return b.index.add(1).get()!==Wt()}function N(){return b.index.add(-1).get()!==Wt()}function Ct(){return b.scrollSnapList}function Ut(){return b.scrollProgress.get(b.offsetLocation.get())}function Wt(){return b.index.get()}function Pe(){return b.indexPrevious.get()}function de(){return b.slidesInView.get()}function Ft(){return b.slidesInView.get(!1)}function Ae(){return T}function ae(){return b}function At(){return r}function jt(){return k}function le(){return O}const vt={canScrollNext:Q,canScrollPrev:N,containerNode:jt,internalEngine:ae,destroy:H,off:p,on:u,emit:g,plugins:Ae,previousScrollSnap:Pe,reInit:f,rootNode:At,scrollNext:U,scrollPrev:X,scrollProgress:Ut,scrollSnapList:Ct,scrollTo:M,selectedScrollSnap:Wt,slideNodes:le,slidesInView:de,slidesNotInView:Ft};return R(t,e),setTimeout(()=>l.emit("init"),0),vt}To.globalOptions=void 0;const Td=ft`
|
|
417
|
+
`,Yh=".splide__container{box-sizing:border-box;position:relative}.splide__list{backface-visibility:hidden;display:-ms-flexbox;display:flex;height:100%;margin:0!important;padding:0!important}.splide.is-initialized:not(.is-active) .splide__list{display:block}.splide__pagination{-ms-flex-align:center;align-items:center;display:-ms-flexbox;display:flex;-ms-flex-wrap:wrap;flex-wrap:wrap;-ms-flex-pack:center;justify-content:center;margin:0;pointer-events:none}.splide__pagination li{display:inline-block;line-height:1;list-style-type:none;margin:0;pointer-events:auto}.splide:not(.is-overflow) .splide__pagination{display:none}.splide__progress__bar{width:0}.splide{position:relative;visibility:hidden}.splide.is-initialized,.splide.is-rendered{visibility:visible}.splide__slide{backface-visibility:hidden;box-sizing:border-box;-ms-flex-negative:0;flex-shrink:0;list-style-type:none!important;margin:0;position:relative}.splide__slide img{vertical-align:bottom}.splide__spinner{animation:splide-loading 1s linear infinite;border:2px solid #999;border-left-color:transparent;border-radius:50%;bottom:0;contain:strict;display:inline-block;height:20px;left:0;margin:auto;position:absolute;right:0;top:0;width:20px}.splide__sr{clip:rect(0 0 0 0);border:0;height:1px;margin:-1px;overflow:hidden;padding:0;position:absolute;width:1px}.splide__toggle.is-active .splide__toggle__play,.splide__toggle__pause{display:none}.splide__toggle.is-active .splide__toggle__pause{display:inline}.splide__track{overflow:hidden;position:relative;z-index:0}@keyframes splide-loading{0%{transform:rotate(0)}to{transform:rotate(1turn)}}.splide__track--draggable{-webkit-touch-callout:none;-webkit-user-select:none;-ms-user-select:none;user-select:none}.splide__track--fade>.splide__list>.splide__slide{margin:0!important;opacity:0;z-index:0}.splide__track--fade>.splide__list>.splide__slide.is-active{opacity:1;z-index:1}.splide--rtl{direction:rtl}.splide__track--ttb>.splide__list{display:block}.splide__arrow{-ms-flex-align:center;align-items:center;background:#ccc;border:0;border-radius:50%;cursor:pointer;display:-ms-flexbox;display:flex;height:2em;-ms-flex-pack:center;justify-content:center;opacity:.7;padding:0;position:absolute;top:50%;transform:translateY(-50%);width:2em;z-index:1}.splide__arrow svg{fill:#000;height:1.2em;width:1.2em}.splide__arrow:hover:not(:disabled){opacity:.9}.splide__arrow:disabled{opacity:.3}.splide__arrow:focus-visible{outline:3px solid #0bf;outline-offset:3px}.splide__arrow--prev{left:1em}.splide__arrow--prev svg{transform:scaleX(-1)}.splide__arrow--next{right:1em}.splide.is-focus-in .splide__arrow:focus{outline:3px solid #0bf;outline-offset:3px}.splide__pagination{bottom:.5em;left:0;padding:0 1em;position:absolute;right:0;z-index:1}.splide__pagination__page{background:#ccc;border:0;border-radius:50%;display:inline-block;height:8px;margin:3px;opacity:.7;padding:0;position:relative;transition:transform .2s linear;width:8px}.splide__pagination__page.is-active{background:#fff;transform:scale(1.4);z-index:1}.splide__pagination__page:hover{cursor:pointer;opacity:.9}.splide__pagination__page:focus-visible{outline:3px solid #0bf;outline-offset:3px}.splide.is-focus-in .splide__pagination__page:focus{outline:3px solid #0bf;outline-offset:3px}.splide__progress__bar{background:#ccc;height:3px}.splide__slide{-webkit-tap-highlight-color:rgba(0,0,0,0)}.splide__slide:focus{outline:0}@supports (outline-offset:-3px){.splide__slide:focus-visible{outline:3px solid #0bf;outline-offset:-3px}}@media screen and (-ms-high-contrast:none){.splide__slide:focus-visible{border:3px solid #0bf}}@supports (outline-offset:-3px){.splide.is-focus-in .splide__slide:focus{outline:3px solid #0bf;outline-offset:-3px}}@media screen and (-ms-high-contrast:none){.splide.is-focus-in .splide__slide:focus{border:3px solid #0bf}.splide.is-focus-in .splide__track>.splide__list>.splide__slide:focus{border-color:#0bf}}.splide__toggle{cursor:pointer}.splide__toggle:focus-visible{outline:3px solid #0bf;outline-offset:3px}.splide.is-focus-in .splide__toggle:focus{outline:3px solid #0bf;outline-offset:3px}.splide__track--nav>.splide__list>.splide__slide{border:3px solid transparent;cursor:pointer}.splide__track--nav>.splide__list>.splide__slide.is-active{border:3px solid #000}.splide__arrows--rtl .splide__arrow--prev{left:auto;right:1em}.splide__arrows--rtl .splide__arrow--prev svg{transform:scaleX(1)}.splide__arrows--rtl .splide__arrow--next{left:1em;right:auto}.splide__arrows--rtl .splide__arrow--next svg{transform:scaleX(-1)}.splide__arrows--ttb .splide__arrow{left:50%;transform:translate(-50%)}.splide__arrows--ttb .splide__arrow--prev{top:1em}.splide__arrows--ttb .splide__arrow--prev svg{transform:rotate(-90deg)}.splide__arrows--ttb .splide__arrow--next{bottom:1em;top:auto}.splide__arrows--ttb .splide__arrow--next svg{transform:rotate(90deg)}.splide__pagination--ttb{bottom:0;display:-ms-flexbox;display:flex;-ms-flex-direction:column;flex-direction:column;left:auto;padding:1em 0;right:.5em;top:0}";function wo(r){return typeof r=="number"}function Gn(r){return typeof r=="string"}function Qr(r){return typeof r=="boolean"}function fa(r){return Object.prototype.toString.call(r)==="[object Object]"}function ct(r){return Math.abs(r)}function Co(r){return Math.sign(r)}function Ps(r,t){return ct(r-t)}function Gh(r,t){if(r===0||t===0||ct(r)<=ct(t))return 0;const e=Ps(ct(r),ct(t));return ct(e/r)}function Xh(r){return Math.round(r*100)/100}function $s(r){return Rs(r).map(Number)}function Te(r){return r[Gs(r)]}function Gs(r){return Math.max(0,r.length-1)}function So(r,t){return t===Gs(r)}function ma(r,t=0){return Array.from(Array(r),(e,i)=>t+i)}function Rs(r){return Object.keys(r)}function Hl(r,t){return[r,t].reduce((e,i)=>(Rs(i).forEach(s=>{const n=e[s],o=i[s],a=fa(n)&&fa(o);e[s]=a?Hl(n,o):o}),e),{})}function Xn(r,t){return typeof t.MouseEvent<"u"&&r instanceof t.MouseEvent}function qh(r,t){const e={start:i,center:s,end:n};function i(){return 0}function s(l){return n(l)/2}function n(l){return t-l}function o(l,c){return Gn(r)?e[r](l):r(t,l,c)}return{measure:o}}function Bs(){let r=[];function t(s,n,o,a={passive:!0}){let l;if("addEventListener"in s)s.addEventListener(n,o,a),l=()=>s.removeEventListener(n,o,a);else{const c=s;c.addListener(o),l=()=>c.removeListener(o)}return r.push(l),i}function e(){r=r.filter(s=>s())}const i={add:t,clear:e};return i}function Kh(r,t,e,i){const s=Bs(),n=1e3/60;let o=null,a=0,l=0;function c(){s.add(r,"visibilitychange",()=>{r.hidden&&g()})}function h(){p(),s.clear()}function d(m){if(!l)return;o||(o=m,e(),e());const b=m-o;for(o=m,a+=b;a>=n;)e(),a-=n;const _=a/n;i(_),l&&(l=t.requestAnimationFrame(d))}function u(){l||(l=t.requestAnimationFrame(d))}function p(){t.cancelAnimationFrame(l),o=null,a=0,l=0}function g(){o=null,a=0}return{init:c,destroy:h,start:u,stop:p,update:e,render:i}}function Zh(r,t){const e=t==="rtl",i=r==="y",s=i?"y":"x",n=i?"x":"y",o=!i&&e?-1:1,a=h(),l=d();function c(g){const{height:f,width:m}=g;return i?f:m}function h(){return i?"top":e?"right":"left"}function d(){return i?"bottom":e?"left":"right"}function u(g){return g*o}return{scroll:s,cross:n,startEdge:a,endEdge:l,measureSize:c,direction:u}}function Fi(r=0,t=0){const e=ct(r-t);function i(c){return c<r}function s(c){return c>t}function n(c){return i(c)||s(c)}function o(c){return n(c)?i(c)?r:t:c}function a(c){return e?c-e*Math.ceil((c-t)/e):c}return{length:e,max:t,min:r,constrain:o,reachedAny:n,reachedMax:s,reachedMin:i,removeOffset:a}}function Vl(r,t,e){const{constrain:i}=Fi(0,r),s=r+1;let n=o(t);function o(u){return e?ct((s+u)%s):i(u)}function a(){return n}function l(u){return n=o(u),d}function c(u){return h().set(a()+u)}function h(){return Vl(r,a(),e)}const d={get:a,set:l,add:c,clone:h};return d}function Jh(r,t,e,i,s,n,o,a,l,c,h,d,u,p,g,f,m,b,_){const{cross:w,direction:S}=r,T=["INPUT","SELECT","TEXTAREA"],k={passive:!1},O=Bs(),E=Bs(),P=Fi(50,225).constrain(p.measure(20)),R={mouse:300,touch:400},L={mouse:500,touch:600},F=g?43:25;let H=!1,M=0,U=0,X=!1,J=!1,N=!1,wt=!1;function Ut(D){if(!_)return;function Q(Yt){(Qr(_)||_(D,Yt))&&ae(Yt)}const Ct=t;O.add(Ct,"dragstart",Yt=>Yt.preventDefault(),k).add(Ct,"touchmove",()=>{},k).add(Ct,"touchend",()=>{}).add(Ct,"touchstart",Q).add(Ct,"mousedown",Q).add(Ct,"touchcancel",Ft).add(Ct,"contextmenu",Ft).add(Ct,"click",le,!0)}function Wt(){O.clear(),E.clear()}function Pe(){const D=wt?e:t;E.add(D,"touchmove",At,k).add(D,"touchend",Ft).add(D,"mousemove",At,k).add(D,"mouseup",Ft)}function de(D){const Q=D.nodeName||"";return T.includes(Q)}function Lt(){return(g?L:R)[wt?"mouse":"touch"]}function Ae(D,Q){const Ct=d.add(Co(D)*-1),Yt=h.byDistance(D,!g).distance;return g||ct(D)<P?Yt:m&&Q?Yt*.5:h.byIndex(Ct.get(),0).distance}function ae(D){const Q=Xn(D,i);wt=Q,N=g&&Q&&!D.buttons&&H,H=Ps(s.get(),o.get())>=2,!(Q&&D.button!==0)&&(de(D.target)||(X=!0,n.pointerDown(D),c.useFriction(0).useDuration(0),s.set(o),Pe(),M=n.readPoint(D),U=n.readPoint(D,w),u.emit("pointerDown")))}function At(D){if(!Xn(D,i)&&D.touches.length>=2)return Ft(D);const Ct=n.readPoint(D),Yt=n.readPoint(D,w),De=Ps(Ct,M),Ve=Ps(Yt,U);if(!J&&!wt&&(!D.cancelable||(J=De>Ve,!J)))return Ft(D);const _i=n.pointerMove(D);De>f&&(N=!0),c.useFriction(.3).useDuration(.75),a.start(),s.add(S(_i)),D.preventDefault()}function Ft(D){const Ct=h.byDistance(0,!1).index!==d.get(),Yt=n.pointerUp(D)*Lt(),De=Ae(S(Yt),Ct),Ve=Gh(Yt,De),_i=F-10*Ve,oi=b+Ve/50;J=!1,X=!1,E.clear(),c.useDuration(_i).useFriction(oi),l.distance(De,!g),wt=!1,u.emit("pointerUp")}function le(D){N&&(D.stopPropagation(),D.preventDefault(),N=!1)}function bt(){return X}return{init:Ut,destroy:Wt,pointerDown:bt}}function Qh(r,t){let i,s;function n(d){return d.timeStamp}function o(d,u){const g=`client${(u||r.scroll)==="x"?"X":"Y"}`;return(Xn(d,t)?d:d.touches[0])[g]}function a(d){return i=d,s=d,o(d)}function l(d){const u=o(d)-o(s),p=n(d)-n(i)>170;return s=d,p&&(i=d),u}function c(d){if(!i||!s)return 0;const u=o(s)-o(i),p=n(d)-n(i),g=n(d)-n(s)>170,f=u/p;return p&&!g&&ct(f)>.1?f:0}return{pointerDown:a,pointerMove:l,pointerUp:c,readPoint:o}}function td(){function r(e){const{offsetTop:i,offsetLeft:s,offsetWidth:n,offsetHeight:o}=e;return{top:i,right:s+n,bottom:i+o,left:s,width:n,height:o}}return{measure:r}}function ed(r){function t(i){return r*(i/100)}return{measure:t}}function id(r,t,e,i,s,n,o){const a=[r].concat(i);let l,c,h=[],d=!1;function u(m){return s.measureSize(o.measure(m))}function p(m){if(!n)return;c=u(r),h=i.map(u);function b(_){for(const w of _){if(d)return;const S=w.target===r,T=i.indexOf(w.target),k=S?c:h[T],O=u(S?r:i[T]);if(ct(O-k)>=.5){m.reInit(),t.emit("resize");break}}}l=new ResizeObserver(_=>{(Qr(n)||n(m,_))&&b(_)}),e.requestAnimationFrame(()=>{a.forEach(_=>l.observe(_))})}function g(){d=!0,l&&l.disconnect()}return{init:p,destroy:g}}function sd(r,t,e,i,s,n){let o=0,a=0,l=s,c=n,h=r.get(),d=0;function u(){const k=i.get()-r.get(),O=!l;let E=0;return O?(o=0,e.set(i),r.set(i),E=k):(e.set(r),o+=k/l,o*=c,h+=o,r.add(o),E=h-d),a=Co(E),d=h,T}function p(){const k=i.get()-t.get();return ct(k)<.001}function g(){return l}function f(){return a}function m(){return o}function b(){return w(s)}function _(){return S(n)}function w(k){return l=k,T}function S(k){return c=k,T}const T={direction:f,duration:g,velocity:m,seek:u,settled:p,useBaseFriction:_,useBaseDuration:b,useFriction:S,useDuration:w};return T}function rd(r,t,e,i,s){const n=s.measure(10),o=s.measure(50),a=Fi(.1,.99);let l=!1;function c(){return!(l||!r.reachedAny(e.get())||!r.reachedAny(t.get()))}function h(p){if(!c())return;const g=r.reachedMin(t.get())?"min":"max",f=ct(r[g]-t.get()),m=e.get()-t.get(),b=a.constrain(f/o);e.subtract(m*b),!p&&ct(m)<n&&(e.set(r.constrain(e.get())),i.useDuration(25).useBaseFriction())}function d(p){l=!p}return{shouldConstrain:c,constrain:h,toggleActive:d}}function nd(r,t,e,i,s){const n=Fi(-t+r,0),o=d(),a=h(),l=u();function c(g,f){return Ps(g,f)<=1}function h(){const g=o[0],f=Te(o),m=o.lastIndexOf(g),b=o.indexOf(f)+1;return Fi(m,b)}function d(){return e.map((g,f)=>{const{min:m,max:b}=n,_=n.constrain(g),w=!f,S=So(e,f);return w?b:S||c(m,_)?m:c(b,_)?b:_}).map(g=>parseFloat(g.toFixed(3)))}function u(){if(t<=r+s)return[n.max];if(i==="keepSnaps")return o;const{min:g,max:f}=a;return o.slice(g,f)}return{snapsContained:l,scrollContainLimit:a}}function od(r,t,e){const i=t[0],s=e?i-r:Te(t);return{limit:Fi(s,i)}}function ad(r,t,e,i){const n=t.min+.1,o=t.max+.1,{reachedMin:a,reachedMax:l}=Fi(n,o);function c(u){return u===1?l(e.get()):u===-1?a(e.get()):!1}function h(u){if(!c(u))return;const p=r*(u*-1);i.forEach(g=>g.add(p))}return{loop:h}}function ld(r){const{max:t,length:e}=r;function i(n){const o=n-t;return e?o/-e:0}return{get:i}}function cd(r,t,e,i,s){const{startEdge:n,endEdge:o}=r,{groupSlides:a}=s,l=d().map(t.measure),c=u(),h=p();function d(){return a(i).map(f=>Te(f)[o]-f[0][n]).map(ct)}function u(){return i.map(f=>e[n]-f[n]).map(f=>-ct(f))}function p(){return a(c).map(f=>f[0]).map((f,m)=>f+l[m])}return{snaps:c,snapsAligned:h}}function hd(r,t,e,i,s,n){const{groupSlides:o}=s,{min:a,max:l}=i,c=h();function h(){const u=o(n),p=!r||t==="keepSnaps";return e.length===1?[n]:p?u:u.slice(a,l).map((g,f,m)=>{const b=!f,_=So(m,f);if(b){const w=Te(m[0])+1;return ma(w)}if(_){const w=Gs(n)-Te(m)[0]+1;return ma(w,Te(m)[0])}return g})}return{slideRegistry:c}}function dd(r,t,e,i,s){const{reachedAny:n,removeOffset:o,constrain:a}=i;function l(g){return g.concat().sort((f,m)=>ct(f)-ct(m))[0]}function c(g){const f=r?o(g):a(g),m=t.map((_,w)=>({diff:h(_-f,0),index:w})).sort((_,w)=>ct(_.diff)-ct(w.diff)),{index:b}=m[0];return{index:b,distance:f}}function h(g,f){const m=[g,g+e,g-e];if(!r)return g;if(!f)return l(m);const b=m.filter(_=>Co(_)===f);return b.length?l(b):Te(m)-e}function d(g,f){const m=t[g]-s.get(),b=h(m,f);return{index:g,distance:b}}function u(g,f){const m=s.get()+g,{index:b,distance:_}=c(m),w=!r&&n(m);if(!f||w)return{index:b,distance:g};const S=t[b]-_,T=g+h(S,0);return{index:b,distance:T}}return{byDistance:u,byIndex:d,shortcut:h}}function ud(r,t,e,i,s,n,o){function a(d){const u=d.distance,p=d.index!==t.get();n.add(u),u&&(i.duration()?r.start():(r.update(),r.render(1),r.update())),p&&(e.set(t.get()),t.set(d.index),o.emit("select"))}function l(d,u){const p=s.byDistance(d,u);a(p)}function c(d,u){const p=t.clone().set(d),g=s.byIndex(p.get(),u);a(g)}return{distance:l,index:c}}function pd(r,t,e,i,s,n,o,a){const l={passive:!0,capture:!0};let c=0;function h(p){if(!a)return;function g(f){if(new Date().getTime()-c>10)return;o.emit("slideFocusStart"),r.scrollLeft=0;const _=e.findIndex(w=>w.includes(f));wo(_)&&(s.useDuration(0),i.index(_,0),o.emit("slideFocus"))}n.add(document,"keydown",d,!1),t.forEach((f,m)=>{n.add(f,"focus",b=>{(Qr(a)||a(p,b))&&g(m)},l)})}function d(p){p.code==="Tab"&&(c=new Date().getTime())}return{init:h}}function Cs(r){let t=r;function e(){return t}function i(l){t=o(l)}function s(l){t+=o(l)}function n(l){t-=o(l)}function o(l){return wo(l)?l:l.get()}return{get:e,set:i,add:s,subtract:n}}function Nl(r,t){const e=r.scroll==="x"?o:a,i=t.style;let s=null,n=!1;function o(u){return`translate3d(${u}px,0px,0px)`}function a(u){return`translate3d(0px,${u}px,0px)`}function l(u){if(n)return;const p=Xh(r.direction(u));p!==s&&(i.transform=e(p),s=p)}function c(u){n=!u}function h(){n||(i.transform="",t.getAttribute("style")||t.removeAttribute("style"))}return{clear:h,to:l,toggleActive:c}}function gd(r,t,e,i,s,n,o,a,l){const h=$s(s),d=$s(s).reverse(),u=b().concat(_());function p(O,E){return O.reduce((P,R)=>P-s[R],E)}function g(O,E){return O.reduce((P,R)=>p(P,E)>0?P.concat([R]):P,[])}function f(O){return n.map((E,P)=>({start:E-i[P]+.5+O,end:E+t-.5+O}))}function m(O,E,P){const R=f(E);return O.map(L=>{const F=P?0:-e,H=P?e:0,M=P?"end":"start",U=R[L][M];return{index:L,loopPoint:U,slideLocation:Cs(-1),translate:Nl(r,l[L]),target:()=>a.get()>U?F:H}})}function b(){const O=o[0],E=g(d,O);return m(E,e,!1)}function _(){const O=t-o[0]-1,E=g(h,O);return m(E,-e,!0)}function w(){return u.every(({index:O})=>{const E=h.filter(P=>P!==O);return p(E,t)<=.1})}function S(){u.forEach(O=>{const{target:E,translate:P,slideLocation:R}=O,L=E();L!==R.get()&&(P.to(L),R.set(L))})}function T(){u.forEach(O=>O.translate.clear())}return{canLoop:w,clear:T,loop:S,loopPoints:u}}function fd(r,t,e){let i,s=!1;function n(l){if(!e)return;function c(h){for(const d of h)if(d.type==="childList"){l.reInit(),t.emit("slidesChanged");break}}i=new MutationObserver(h=>{s||(Qr(e)||e(l,h))&&c(h)}),i.observe(r,{childList:!0})}function o(){i&&i.disconnect(),s=!0}return{init:n,destroy:o}}function md(r,t,e,i){const s={};let n=null,o=null,a,l=!1;function c(){a=new IntersectionObserver(g=>{l||(g.forEach(f=>{const m=t.indexOf(f.target);s[m]=f}),n=null,o=null,e.emit("slidesInView"))},{root:r.parentElement,threshold:i}),t.forEach(g=>a.observe(g))}function h(){a&&a.disconnect(),l=!0}function d(g){return Rs(s).reduce((f,m)=>{const b=parseInt(m),{isIntersecting:_}=s[b];return(g&&_||!g&&!_)&&f.push(b),f},[])}function u(g=!0){if(g&&n)return n;if(!g&&o)return o;const f=d(g);return g&&(n=f),g||(o=f),f}return{init:c,destroy:h,get:u}}function bd(r,t,e,i,s,n){const{measureSize:o,startEdge:a,endEdge:l}=r,c=e[0]&&s,h=g(),d=f(),u=e.map(o),p=m();function g(){if(!c)return 0;const _=e[0];return ct(t[a]-_[a])}function f(){if(!c)return 0;const _=n.getComputedStyle(Te(i));return parseFloat(_.getPropertyValue(`margin-${l}`))}function m(){return e.map((_,w,S)=>{const T=!w,k=So(S,w);return T?u[w]+h:k?u[w]+d:S[w+1][a]-_[a]}).map(ct)}return{slideSizes:u,slideSizesWithGaps:p,startGap:h,endGap:d}}function vd(r,t,e,i,s,n,o,a,l){const{startEdge:c,endEdge:h,direction:d}=r,u=wo(e);function p(b,_){return $s(b).filter(w=>w%_===0).map(w=>b.slice(w,w+_))}function g(b){return b.length?$s(b).reduce((_,w,S)=>{const T=Te(_)||0,k=T===0,O=w===Gs(b),E=s[c]-n[T][c],P=s[c]-n[w][h],R=!i&&k?d(o):0,L=!i&&O?d(a):0,F=ct(P-L-(E+R));return S&&F>t+l&&_.push(w),O&&_.push(b.length),_},[]).map((_,w,S)=>{const T=Math.max(S[w-1]||0);return b.slice(T,_)}):[]}function f(b){return u?p(b,e):g(b)}return{groupSlides:f}}function yd(r,t,e,i,s,n,o){const{align:a,axis:l,direction:c,startIndex:h,loop:d,duration:u,dragFree:p,dragThreshold:g,inViewThreshold:f,slidesToScroll:m,skipSnaps:b,containScroll:_,watchResize:w,watchSlides:S,watchDrag:T,watchFocus:k}=n,O=2,E=td(),P=E.measure(t),R=e.map(E.measure),L=Zh(l,c),F=L.measureSize(P),H=ed(F),M=qh(a,F),U=!d&&!!_,X=d||!!_,{slideSizes:J,slideSizesWithGaps:N,startGap:wt,endGap:Ut}=bd(L,P,R,e,X,s),Wt=vd(L,F,m,d,P,R,wt,Ut,O),{snaps:Pe,snapsAligned:de}=cd(L,M,P,R,Wt),Lt=-Te(Pe)+Te(N),{snapsContained:Ae,scrollContainLimit:ae}=nd(F,Lt,de,_,O),At=U?Ae:de,{limit:Ft}=od(Lt,At,d),le=Vl(Gs(At),h,d),bt=le.clone(),at=$s(e),D=({dragHandler:Vi,scrollBody:xn,scrollBounds:wn,options:{loop:tr}})=>{tr||wn.constrain(Vi.pointerDown()),xn.seek()},Q=({scrollBody:Vi,translate:xn,location:wn,offsetLocation:tr,previousLocation:gh,scrollLooper:fh,slideLooper:mh,dragHandler:bh,animation:vh,eventHandler:Jo,scrollBounds:yh,options:{loop:Qo}},ta)=>{const ea=Vi.settled(),_h=!yh.shouldConstrain(),ia=Qo?ea:ea&&_h,sa=ia&&!bh.pointerDown();sa&&vh.stop();const xh=wn.get()*ta+gh.get()*(1-ta);tr.set(xh),Qo&&(fh.loop(Vi.direction()),mh.loop()),xn.to(tr.get()),sa&&Jo.emit("settle"),ia||Jo.emit("scroll")},Ct=Kh(i,s,()=>D(_n),Vi=>Q(_n,Vi)),Yt=.68,De=At[le.get()],Ve=Cs(De),_i=Cs(De),oi=Cs(De),xi=Cs(De),ds=sd(Ve,oi,_i,xi,u,Yt),vn=dd(d,At,Lt,Ft,xi),yn=ud(Ct,le,bt,ds,vn,xi,o),qo=ld(Ft),Ko=Bs(),uh=md(t,e,o,f),{slideRegistry:Zo}=hd(U,_,At,ae,Wt,at),ph=pd(r,e,Zo,yn,ds,Ko,o,k),_n={ownerDocument:i,ownerWindow:s,eventHandler:o,containerRect:P,slideRects:R,animation:Ct,axis:L,dragHandler:Jh(L,r,i,s,xi,Qh(L,s),Ve,Ct,yn,ds,vn,le,o,H,p,g,b,Yt,T),eventStore:Ko,percentOfView:H,index:le,indexPrevious:bt,limit:Ft,location:Ve,offsetLocation:oi,previousLocation:_i,options:n,resizeHandler:id(t,o,s,e,L,w,E),scrollBody:ds,scrollBounds:rd(Ft,oi,xi,ds,H),scrollLooper:ad(Lt,Ft,oi,[Ve,oi,_i,xi]),scrollProgress:qo,scrollSnapList:At.map(qo.get),scrollSnaps:At,scrollTarget:vn,scrollTo:yn,slideLooper:gd(L,F,Lt,J,N,Pe,At,oi,e),slideFocus:ph,slidesHandler:fd(t,o,S),slidesInView:uh,slideIndexes:at,slideRegistry:Zo,slidesToScroll:Wt,target:xi,translate:Nl(L,t)};return _n}function _d(){let r={},t;function e(c){t=c}function i(c){return r[c]||[]}function s(c){return i(c).forEach(h=>h(t,c)),l}function n(c,h){return r[c]=i(c).concat([h]),l}function o(c,h){return r[c]=i(c).filter(d=>d!==h),l}function a(){r={}}const l={init:e,emit:s,off:o,on:n,clear:a};return l}const xd={align:"center",axis:"x",container:null,slides:null,containScroll:"trimSnaps",direction:"ltr",slidesToScroll:1,inViewThreshold:0,breakpoints:{},dragFree:!1,dragThreshold:10,loop:!1,skipSnaps:!1,duration:25,startIndex:0,active:!0,watchDrag:!0,watchResize:!0,watchSlides:!0,watchFocus:!0};function wd(r){function t(n,o){return Hl(n,o||{})}function e(n){const o=n.breakpoints||{},a=Rs(o).filter(l=>r.matchMedia(l).matches).map(l=>o[l]).reduce((l,c)=>t(l,c),{});return t(n,a)}function i(n){return n.map(o=>Rs(o.breakpoints||{})).reduce((o,a)=>o.concat(a),[]).map(r.matchMedia)}return{mergeOptions:t,optionsAtMedia:e,optionsMediaQueries:i}}function Cd(r){let t=[];function e(n,o){return t=o.filter(({options:a})=>r.optionsAtMedia(a).active!==!1),t.forEach(a=>a.init(n,r)),o.reduce((a,l)=>Object.assign(a,{[l.name]:l}),{})}function i(){t=t.filter(n=>n.destroy())}return{init:e,destroy:i}}function To(r,t,e){const i=r.ownerDocument,s=i.defaultView,n=wd(s),o=Cd(n),a=Bs(),l=_d(),{mergeOptions:c,optionsAtMedia:h,optionsMediaQueries:d}=n,{on:u,off:p,emit:g}=l,f=L;let m=!1,b,_=c(xd,To.globalOptions),w=c(_),S=[],T,k,O;function E(){const{container:at,slides:D}=w;k=(Gn(at)?r.querySelector(at):at)||r.children[0];const Ct=Gn(D)?k.querySelectorAll(D):D;O=[].slice.call(Ct||k.children)}function P(at){const D=yd(r,k,O,i,s,at,l);if(at.loop&&!D.slideLooper.canLoop()){const Q=Object.assign({},at,{loop:!1});return P(Q)}return D}function R(at,D){m||(_=c(_,at),w=h(_),S=D||S,E(),b=P(w),d([_,...S.map(({options:Q})=>Q)]).forEach(Q=>a.add(Q,"change",L)),w.active&&(b.translate.to(b.location.get()),b.animation.init(),b.slidesInView.init(),b.slideFocus.init(bt),b.eventHandler.init(bt),b.resizeHandler.init(bt),b.slidesHandler.init(bt),b.options.loop&&b.slideLooper.loop(),k.offsetParent&&O.length&&b.dragHandler.init(bt),T=o.init(bt,S)))}function L(at,D){const Q=Wt();F(),R(c({startIndex:Q},at),D),l.emit("reInit")}function F(){b.dragHandler.destroy(),b.eventStore.clear(),b.translate.clear(),b.slideLooper.clear(),b.resizeHandler.destroy(),b.slidesHandler.destroy(),b.slidesInView.destroy(),b.animation.destroy(),o.destroy(),a.clear()}function H(){m||(m=!0,a.clear(),F(),l.emit("destroy"),l.clear())}function M(at,D,Q){!w.active||m||(b.scrollBody.useBaseFriction().useDuration(D===!0?0:w.duration),b.scrollTo.index(at,Q||0))}function U(at){const D=b.index.add(1).get();M(D,at,-1)}function X(at){const D=b.index.add(-1).get();M(D,at,1)}function J(){return b.index.add(1).get()!==Wt()}function N(){return b.index.add(-1).get()!==Wt()}function wt(){return b.scrollSnapList}function Ut(){return b.scrollProgress.get(b.offsetLocation.get())}function Wt(){return b.index.get()}function Pe(){return b.indexPrevious.get()}function de(){return b.slidesInView.get()}function Lt(){return b.slidesInView.get(!1)}function Ae(){return T}function ae(){return b}function At(){return r}function Ft(){return k}function le(){return O}const bt={canScrollNext:J,canScrollPrev:N,containerNode:Ft,internalEngine:ae,destroy:H,off:p,on:u,emit:g,plugins:Ae,previousScrollSnap:Pe,reInit:f,rootNode:At,scrollNext:U,scrollPrev:X,scrollProgress:Ut,scrollSnapList:wt,scrollTo:M,selectedScrollSnap:Wt,slideNodes:le,slidesInView:de,slidesNotInView:Lt};return R(t,e),setTimeout(()=>l.emit("init"),0),bt}To.globalOptions=void 0;const Sd=gt`
|
|
418
418
|
:host,
|
|
419
419
|
:host * {
|
|
420
420
|
max-height: 100%;
|
|
@@ -470,7 +470,7 @@
|
|
|
470
470
|
* @license
|
|
471
471
|
* Copyright 2018 Google LLC
|
|
472
472
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
473
|
-
*/const me=tn(class extends en{constructor(r){var t;if(super(r),r.type!==ci.ATTRIBUTE||r.name!=="class"||((t=r.strings)==null?void 0:t.length)>2)throw Error("`classMap()` can only be used in the `class` attribute and must be the only part in the attribute.")}render(r){return" "+Object.keys(r).filter(t=>r[t]).join(" ")+" "}update(r,[t]){var i,s;if(this.st===void 0){this.st=new Set,r.strings!==void 0&&(this.nt=new Set(r.strings.join(" ").split(/\s/).filter(n=>n!=="")));for(const n in t)t[n]&&!((i=this.nt)!=null&&i.has(n))&&this.st.add(n);return this.render(t)}const e=r.element.classList;for(const n of this.st)n in t||(e.remove(n),this.st.delete(n));for(const n in t){const o=!!t[n];o===this.st.has(n)||(s=this.nt)!=null&&s.has(n)||(o?(e.add(n),this.st.add(n)):(e.remove(n),this.st.delete(n)))}return fe}});function
|
|
473
|
+
*/const me=tn(class extends en{constructor(r){var t;if(super(r),r.type!==ci.ATTRIBUTE||r.name!=="class"||((t=r.strings)==null?void 0:t.length)>2)throw Error("`classMap()` can only be used in the `class` attribute and must be the only part in the attribute.")}render(r){return" "+Object.keys(r).filter(t=>r[t]).join(" ")+" "}update(r,[t]){var i,s;if(this.st===void 0){this.st=new Set,r.strings!==void 0&&(this.nt=new Set(r.strings.join(" ").split(/\s/).filter(n=>n!=="")));for(const n in t)t[n]&&!((i=this.nt)!=null&&i.has(n))&&this.st.add(n);return this.render(t)}const e=r.element.classList;for(const n of this.st)n in t||(e.remove(n),this.st.delete(n));for(const n in t){const o=!!t[n];o===this.st.has(n)||(s=this.nt)!=null&&s.has(n)||(o?(e.add(n),this.st.add(n)):(e.remove(n),this.st.delete(n)))}return fe}});function it(r,t){const e={waitUntilFirstUpdate:!1,...t};return function(i,s){const n=Array.isArray(r)?r:[r],{update:o}=i;i.update=function(a){n.forEach(l=>{const c=l;if(a.has(c)){const h=a.get(c),d=this[c];h!==d&&(!e.waitUntilFirstUpdate||this.hasUpdated)&&this[s](h,d)}}),o.call(this,a)}}}var Td=Object.defineProperty,Ed=Object.getOwnPropertyDescriptor,ze=(r,t,e,i)=>{for(var s=i>1?void 0:i?Ed(t,e):t,n=r.length-1,o;n>=0;n--)(o=r[n])&&(s=(i?o(t,e,s):o(s))||s);return i&&s&&Td(t,e,s),s};let ne=class extends kt{constructor(){super(...arguments),this.skeletonHeight="2000px",this.skeletonWidth="1429px",this.src="",this.alt="",this.placeholder="",this.skeleton=!1,this.loaded=!1}handleSrcChange(){this.loaded=!1}handleError(){this.loaded=!0,this.placeholder&&(this.src=this.placeholder)}handleOnLoad(){this.loaded=!0}firstUpdated(){this.skeleton||(this.imgEl.onload=()=>this.handleOnLoad())}render(){return this.skeleton?j`<div class="skeleton"></div>`:j`
|
|
474
474
|
${this.loaded?"":j` <div class="skeleton"></div>`}
|
|
475
475
|
<img
|
|
476
476
|
src=${this.src}
|
|
@@ -478,7 +478,7 @@
|
|
|
478
478
|
class=${me({loaded:this.loaded,hidden:!this.loaded})}
|
|
479
479
|
@error=${()=>this.handleError()}
|
|
480
480
|
/>
|
|
481
|
-
`}};ne.styles=[Ot,
|
|
481
|
+
`}};ne.styles=[Ot,Sd];ze([C()],ne.prototype,"skeletonHeight",2);ze([C()],ne.prototype,"skeletonWidth",2);ze([C()],ne.prototype,"src",2);ze([C()],ne.prototype,"alt",2);ze([C()],ne.prototype,"placeholder",2);ze([C({type:Boolean})],ne.prototype,"skeleton",2);ze([I()],ne.prototype,"loaded",2);ze([z("img")],ne.prototype,"imgEl",2);ze([it("src")],ne.prototype,"handleSrcChange",1);ne=ze([Et("pbo-image")],ne);var Od=Object.defineProperty,kd=Object.getOwnPropertyDescriptor,ke=(r,t,e,i)=>{for(var s=i>1?void 0:i?kd(t,e):t,n=r.length-1,o;n>=0;n--)(o=r[n])&&(s=(i?o(t,e,s):o(s))||s);return i&&s&&Od(t,e,s),s};let qt=class extends kt{constructor(){super(...arguments),this.cards=[],this.skeleton=!1,this.title="",this.firstUpdated=()=>{const r={align:"start",axis:"x",loop:!1},t=To(this.emblaViewport,r);if(this.skeleton)return;const e=this.addPrevNextBtnsClickHandlers(t,this.emblaPrevButton,this.emblaNextButton),i=()=>{const s=t.canScrollPrev()||t.canScrollNext();this.emblaPrevButton.style.visibility=s?"visible":"hidden",this.emblaNextButton.style.visibility=s?"visible":"hidden"};t.on("destroy",e),t.on("init",i),t.on("reInit",i)},this.disconnectedCallback=()=>{var r;super.disconnectedCallback(),(r=this.imageSplide)==null||r.destroy()},this.clickHandler=r=>{const t=r.target;this.emit("pbo-category-card-selected",{detail:{cardId:t.dataset.cardId||"unknown"}})},this.addTogglePrevNextBtnsActive=(r,t,e)=>{const i=()=>{r.canScrollPrev()?t.removeAttribute("disabled"):t.setAttribute("disabled","disabled"),r.canScrollNext()?e.removeAttribute("disabled"):e.setAttribute("disabled","disabled")};return r.on("select",i).on("init",i).on("reInit",i),()=>{t.removeAttribute("disabled"),e.removeAttribute("disabled")}}}updateArrowVisibility(){const r=this.imageCarousel.querySelector(".splide__arrow--next"),t=this.imageCarousel.querySelector(".splide__arrow--prev");r.style.visibility=r.disabled?"hidden":"visible",t.style.visibility=t.disabled?"hidden":"visible"}addPrevNextBtnsClickHandlers(r,t,e){const i=()=>{r.scrollPrev()},s=()=>{r.scrollNext()};t.addEventListener("click",i,!1),e.addEventListener("click",s,!1);const n=this.addTogglePrevNextBtnsActive(r,t,e);return()=>{n(),t.removeEventListener("click",i,!1),e.removeEventListener("click",s,!1)}}render(){return this.skeleton?j`
|
|
482
482
|
<div class="category-container skeleton">
|
|
483
483
|
<div class="title"></div>
|
|
484
484
|
<section class="embla">
|
|
@@ -551,7 +551,7 @@
|
|
|
551
551
|
</button>
|
|
552
552
|
</div>
|
|
553
553
|
</div>
|
|
554
|
-
`}};
|
|
554
|
+
`}};qt.styles=[Ot,Wh,Kr(Yh)];qt.dependencies={"pbo-image":ne};ke([C({type:Array})],qt.prototype,"cards",2);ke([C({type:Boolean,reflect:!0})],qt.prototype,"skeleton",2);ke([C({type:String})],qt.prototype,"title",2);ke([z("#category-carousel")],qt.prototype,"imageCarousel",2);ke([z(".embla")],qt.prototype,"emblaNode",2);ke([z(".embla__viewport")],qt.prototype,"emblaViewport",2);ke([z(".embla__button--prev")],qt.prototype,"emblaPrevButton",2);ke([z(".embla__button--next")],qt.prototype,"emblaNextButton",2);ke([z(".embla__container")],qt.prototype,"emblaContainerEl",2);ke([I()],qt.prototype,"imageSplide",2);qt=ke([Et("pbo-category")],qt);var Pd=Object.defineProperty,Ad=Object.getOwnPropertyDescriptor,Eo=(r,t,e,i)=>{for(var s=i>1?void 0:i?Ad(t,e):t,n=r.length-1,o;n>=0;n--)(o=r[n])&&(s=(i?o(t,e,s):o(s))||s);return i&&s&&Pd(t,e,s),s};let ji=class extends kt{constructor(){super(...arguments),this.categories=[],this.loading=!0}render(){return this.loading?j`
|
|
555
555
|
<pbo-category skeleton></pbo-category>
|
|
556
556
|
<pbo-category skeleton></pbo-category>
|
|
557
557
|
`:j`
|
|
@@ -562,7 +562,7 @@
|
|
|
562
562
|
exportparts="category-title"
|
|
563
563
|
>
|
|
564
564
|
</pbo-category>`)}
|
|
565
|
-
`}};ji.styles=[Ot,
|
|
565
|
+
`}};ji.styles=[Ot,Uh];ji.dependencies={"pbo-category":qt};Eo([C({type:Array})],ji.prototype,"categories",2);Eo([C({type:Boolean,reflect:!0})],ji.prototype,"loading",2);ji=Eo([Et("pbo-card-selection")],ji);const Dd=gt`
|
|
566
566
|
:host {
|
|
567
567
|
display: inline-block;
|
|
568
568
|
position: relative;
|
|
@@ -1223,12 +1223,12 @@
|
|
|
1223
1223
|
* @license
|
|
1224
1224
|
* Copyright 2020 Google LLC
|
|
1225
1225
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
1226
|
-
*/const Ul=Symbol.for(""),
|
|
1227
|
-
take care to ensure page security.`)})(i)+r[s+1],r[0]),r:Ul}),va=new Map,
|
|
1226
|
+
*/const Ul=Symbol.for(""),Md=r=>{if((r==null?void 0:r.r)===Ul)return r==null?void 0:r._$litStatic$},ba=(r,...t)=>({_$litStatic$:t.reduce((e,i,s)=>e+(n=>{if(n._$litStatic$!==void 0)return n._$litStatic$;throw Error(`Value passed to 'literal' function must be a 'literal' result: ${n}. Use 'unsafeStatic' to pass non-literal values, but
|
|
1227
|
+
take care to ensure page security.`)})(i)+r[s+1],r[0]),r:Ul}),va=new Map,Id=r=>(t,...e)=>{const i=e.length;let s,n;const o=[],a=[];let l,c=0,h=!1;for(;c<i;){for(l=t[c];c<i&&(n=e[c],(s=Md(n))!==void 0);)l+=s+t[++c],h=!0;c!==i&&a.push(n),o.push(l),c++}if(c===i&&o.push(t[i]),h){const d=o.join("$$lit$$");(t=va.get(d))===void 0&&(o.raw=o,va.set(d,t=o)),e=a}return r(t,...e)},ya=Id(j);class Xs{constructor(t,...e){this.slotNames=[],this.handleSlotChange=i=>{const s=i.target;(this.slotNames.includes("[default]")&&!s.name||s.name&&this.slotNames.includes(s.name))&&this.host.requestUpdate()},(this.host=t).addController(this),this.slotNames=e}hasDefaultSlot(){return[...this.host.childNodes].some(t=>{var e;if(t.nodeType===t.TEXT_NODE&&((e=t.textContent)==null?void 0:e.trim())!=="")return!0;if(t.nodeType===t.ELEMENT_NODE){const i=t;if(i.tagName.toLowerCase()==="pbo-visually-hidden")return!1;if(!i.hasAttribute("slot"))return!0}return!1})}hasNamedSlot(t){return this.host.querySelector(`:scope > [slot="${t}"]`)!==null}test(t){return t==="[default]"?this.hasDefaultSlot():this.hasNamedSlot(t)}hostConnected(){this.host.shadowRoot.addEventListener("slotchange",this.handleSlotChange)}hostDisconnected(){this.host.shadowRoot.removeEventListener("slotchange",this.handleSlotChange)}}const ps=new WeakMap,gs=new WeakMap,fs=new WeakMap,On=new WeakSet,er=new WeakMap;class Oo{constructor(t,e){this.handleFormData=i=>{const s=this.options.disabled(this.host),n=this.options.name(this.host),o=this.options.value(this.host),a=this.host.tagName.toLowerCase()==="pbo-button";this.host.isConnected&&!s&&!a&&typeof n=="string"&&n.length>0&&typeof o<"u"&&(Array.isArray(o)?o.forEach(l=>{i.formData.append(n,l.toString())}):i.formData.append(n,o.toString()))},this.handleFormSubmit=i=>{var o;const s=this.options.disabled(this.host),n=this.options.reportValidity;this.form&&!this.form.noValidate&&((o=ps.get(this.form))==null||o.forEach(a=>{this.setUserInteracted(a,!0)})),this.form&&!this.form.noValidate&&!s&&!n(this.host)&&(i==null||i.preventDefault(),i==null||i.stopImmediatePropagation())},this.handleFormReset=()=>{this.options.setValue(this.host,this.options.defaultValue(this.host)),this.setUserInteracted(this.host,!1),er.set(this.host,[])},this.handleInteraction=i=>{const s=er.get(this.host);s.includes(i.type)||s.push(i.type),s.length===this.options.assumeInteractionOn.length&&this.setUserInteracted(this.host,!0)},this.checkFormValidity=()=>{if(this.form&&!this.form.noValidate){const i=this.form.querySelectorAll("*");for(const s of i)if(typeof s.checkValidity=="function"&&!s.checkValidity())return!1}return!0},this.doAction=(i,s)=>{if(this.form){const n=document.createElement("button");n.type=i,n.style.position="absolute",n.style.width="0",n.style.height="0",n.style.clipPath="inset(50%)",n.style.overflow="hidden",n.style.whiteSpace="nowrap",s&&(n.name=s.name,n.value=s.value,["formation","formenctype","formmethod","formnovalidate","formtarget"].forEach(o=>{s.hasAttribute(o)&&n.setAttribute(o,s.getAttribute(o))})),this.form.append(n),n.click(),n.remove()}},(this.host=t).addController(this),this.options={form:i=>{const s=i.form;if(s){const o=i.getRootNode().querySelector(`#${s}`);if(o)return o}return i.closest("form")},name:i=>i.name,value:i=>i.value,defaultValue:i=>i.defaultValue,disabled:i=>i.disabled??!1,reportValidity:i=>typeof i.reportValidity=="function"?i.reportValidity():!0,checkValidity:i=>typeof i.checkValidity=="function"?i.checkValidity():!0,setValue:(i,s)=>i.value=s,assumeInteractionOn:["pbo-input"],...e}}hostConnected(){const t=this.options.form(this.host);t&&this.attachForm(t),er.set(this.host,[]),this.options.assumeInteractionOn.forEach(e=>{this.host.addEventListener(e,this.handleInteraction)})}hostDisconnected(){this.detachForm(),er.delete(this.host),this.options.assumeInteractionOn.forEach(t=>{this.host.removeEventListener(t,this.handleInteraction)})}hostUpdated(){const t=this.options.form(this.host);t||this.detachForm(),t&&this.form!==t&&(this.detachForm(),this.attachForm(t)),this.host.hasUpdated&&this.setValidity(this.host.validity.valid)}attachForm(t){t?(this.form=t,ps.has(this.form)?ps.get(this.form).add(this.host):ps.set(this.form,new Set([this.host])),this.form.addEventListener("formdata",this.handleFormData),this.form.addEventListener("submit",this.handleFormSubmit),this.form.addEventListener("reset",this.handleFormReset),gs.has(this.form)||(gs.set(this.form,this.form.reportValidity),this.form.reportValidity=()=>this.reportFormValidity()),fs.has(this.form)||(fs.set(this.form,this.form.checkValidity),this.form.checkValidity=()=>this.checkFormValidity())):this.form=void 0}detachForm(){if(!this.form)return;const t=ps.get(this.form);t&&(t.delete(this.host),t.size<=0&&(this.form.removeEventListener("formdata",this.handleFormData),this.form.removeEventListener("submit",this.handleFormSubmit),this.form.removeEventListener("reset",this.handleFormReset),gs.has(this.form)&&(this.form.reportValidity=gs.get(this.form),gs.delete(this.form)),fs.has(this.form)&&(this.form.checkValidity=fs.get(this.form),fs.delete(this.form)),this.form=void 0))}reportFormValidity(){if(this.form&&!this.form.noValidate){const t=this.form.querySelectorAll("*");for(const e of t)if(typeof e.reportValidity=="function"&&!e.reportValidity())return!1}return!0}setUserInteracted(t,e){e?On.add(t):On.delete(t),t.requestUpdate()}getForm(){return this.form??null}reset(t){this.doAction("reset",t)}submit(t){this.doAction("submit",t)}setValidity(t){const e=this.host,i=!!On.has(e),s=!!e.required;e.toggleAttribute("data-required",s),e.toggleAttribute("data-optional",!s),e.toggleAttribute("data-invalid",!t),e.toggleAttribute("data-valid",t),e.toggleAttribute("data-user-invalid",i&&!t),e.toggleAttribute("data-user-valid",i&&t)}updateValidity(){const t=this.host;this.setValidity(t.validity.valid)}emitInvalidEvent(t){const e=new CustomEvent("pbo-invalid",{bubbles:!1,composed:!1,cancelable:!0,detail:{}});t||e.preventDefault(),this.host.dispatchEvent(e)||t==null||t.preventDefault()}}const sn=Object.freeze({badInput:!1,customError:!1,patternMismatch:!1,rangeOverflow:!1,rangeUnderflow:!1,stepMismatch:!1,tooLong:!1,tooShort:!1,typeMismatch:!1,valid:!0,valueMissing:!1}),Ld=Object.freeze({...sn,valid:!1,valueMissing:!1}),Fd=Object.freeze({...sn,valid:!1,customError:!0});/**
|
|
1228
1228
|
* @license
|
|
1229
1229
|
* Copyright 2018 Google LLC
|
|
1230
1230
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
1231
|
-
*/const
|
|
1231
|
+
*/const Ci=r=>r??K,jd=gt`
|
|
1232
1232
|
:host {
|
|
1233
1233
|
--track-width: 2px;
|
|
1234
1234
|
--track-color: rgb(128 128 128 / 25%);
|
|
@@ -1285,20 +1285,20 @@
|
|
|
1285
1285
|
stroke-dasharray: 0.05em, 3em;
|
|
1286
1286
|
}
|
|
1287
1287
|
}
|
|
1288
|
-
`;var
|
|
1288
|
+
`;var $d=Object.getOwnPropertyDescriptor,Rd=(r,t,e,i)=>{for(var s=i>1?void 0:i?$d(t,e):t,n=r.length-1,o;n>=0;n--)(o=r[n])&&(s=o(s)||s);return s};let zs=class extends kt{render(){return j`
|
|
1289
1289
|
<svg part="base" class="spinner" role="progressbar" aria-label="loading">
|
|
1290
1290
|
<circle class="spinner__track"></circle>
|
|
1291
1291
|
<circle class="spinner__indicator"></circle>
|
|
1292
1292
|
</svg>
|
|
1293
|
-
`}};zs.styles=[Ot
|
|
1293
|
+
`}};zs.styles=[Ot,jd];zs=Rd([Et("pbo-spinner")],zs);var Bd=Object.defineProperty,zd=Object.getOwnPropertyDescriptor,Rt=(r,t,e,i)=>{for(var s=i>1?void 0:i?zd(t,e):t,n=r.length-1,o;n>=0;n--)(o=r[n])&&(s=(i?o(t,e,s):o(s))||s);return i&&s&&Bd(t,e,s),s};let ht=class extends kt{constructor(){super(...arguments),this.formControlController=new Oo(this,{assumeInteractionOn:["click"]}),this.hasSlotController=new Xs(this,"[prefix]","prefix","suffix"),this.disabled=!1,this.href="",this.name="",this.value="",this.variant="default",this.outline=!1,this.size="medium",this.circle=!1,this.type="button",this.colorBlock=!1,this.loading=!1,this.error=!1,this.isIconButton=!1,this.hasFocus=!1}get validity(){return this.isButton()?this.button.validity:sn}get validationMessage(){return this.isButton()?this.button.validationMessage:""}handleBlur(){this.hasFocus=!1,this.emit("pbo-blur")}handleFocus(){this.hasFocus=!0,this.emit("pbo-focus")}handleInvalid(){}handleClick(){this.type==="submit"&&this.formControlController.submit(this),this.type==="reset"&&this.formControlController.reset(this)}isButton(){return!this.href}isLink(){return!!this.href}doAction(r,t){}click(){this.button.click()}focus(){this.button.focus()}blur(){this.button.blur()}checkValidity(){return this.isButton()?this.button.checkValidity():!0}getForm(){return this.formControlController.getForm()}reset(r){this.doAction("reset",r)}submit(r){this.doAction("submit",r)}render(){const r=this.isLink(),t=r?ba`a`:ba`button`;return ya`
|
|
1294
1294
|
<${t}
|
|
1295
1295
|
part="base"
|
|
1296
1296
|
class= ${me({button:!0,"button--default":this.variant==="default","button--primary":this.variant==="primary","button--success":this.variant==="success","button--neutral":this.variant==="neutral","button--warning":this.variant==="warning","button--danger":this.variant==="danger","button--text":this.variant==="text","button--small":this.size==="small","button--medium":this.size==="medium","button--large":this.size==="large","button--standard":!this.outline,"button--outline":this.outline,"button--focused":this.hasFocus,"button--loading":this.loading,"button--has-label":this.hasSlotController.test("[default]"),"button--has-prefix":this.hasSlotController.test("prefix"),"button--has-suffix":this.hasSlotController.test("suffix"),"button--circle":this.circle,"button--disabled":this.disabled})}
|
|
1297
|
-
?disabled=${
|
|
1297
|
+
?disabled=${Ci(r?void 0:this.disabled)}
|
|
1298
1298
|
aria-busy=${this.loading?"true":"false"}
|
|
1299
1299
|
tabindex=${this.disabled?"-1":"0"}
|
|
1300
1300
|
href="${this.href}"
|
|
1301
|
-
name=${
|
|
1301
|
+
name=${Ci(r?void 0:this.name)}
|
|
1302
1302
|
@blur=${this.handleBlur}
|
|
1303
1303
|
@focus=${this.handleFocus}
|
|
1304
1304
|
@invalid=${this.isButton()?this.handleInvalid:null}
|
|
@@ -1308,7 +1308,7 @@
|
|
|
1308
1308
|
<slot part="label" class="button__label"></slot>
|
|
1309
1309
|
<slot name="suffix" part="suffix" class="button__suffix"></slot>
|
|
1310
1310
|
${this.loading?ya`<pbo-spinner part="spinner"></pbo-spinner>`:""}
|
|
1311
|
-
</${t}>`}};ht.styles=[Ot,
|
|
1311
|
+
</${t}>`}};ht.styles=[Ot,Dd];ht.dependencies={"pbo-spinner":zs};Rt([z(".button")],ht.prototype,"button",2);Rt([z(".button--loading pbo-spinner")],ht.prototype,"spinner",2);Rt([C({type:Boolean,reflect:!0})],ht.prototype,"disabled",2);Rt([C()],ht.prototype,"href",2);Rt([C()],ht.prototype,"name",2);Rt([C()],ht.prototype,"value",2);Rt([C({reflect:!0})],ht.prototype,"variant",2);Rt([C({type:Boolean,reflect:!0})],ht.prototype,"outline",2);Rt([C({reflect:!0})],ht.prototype,"size",2);Rt([C({type:Boolean,reflect:!0})],ht.prototype,"circle",2);Rt([C({reflect:!0})],ht.prototype,"type",2);Rt([C({type:Boolean,reflect:!0,attribute:"color-block"})],ht.prototype,"colorBlock",2);Rt([C({type:Boolean,reflect:!0})],ht.prototype,"loading",2);Rt([C({type:Boolean,reflect:!0})],ht.prototype,"error",2);Rt([I()],ht.prototype,"isIconButton",2);Rt([I()],ht.prototype,"hasFocus",2);ht=Rt([Et("pbo-button")],ht);const Hd=gt`
|
|
1312
1312
|
:host {
|
|
1313
1313
|
display: block;
|
|
1314
1314
|
}
|
|
@@ -1380,7 +1380,7 @@
|
|
|
1380
1380
|
grid-column: 7 / 11;
|
|
1381
1381
|
}
|
|
1382
1382
|
}
|
|
1383
|
-
`,
|
|
1383
|
+
`,Vd=gt`
|
|
1384
1384
|
:host {
|
|
1385
1385
|
display: block;
|
|
1386
1386
|
}
|
|
@@ -1425,7 +1425,7 @@
|
|
|
1425
1425
|
.skip::part(label) {
|
|
1426
1426
|
font-size: 14px;
|
|
1427
1427
|
}
|
|
1428
|
-
`,
|
|
1428
|
+
`,Nd=gt`
|
|
1429
1429
|
:host {
|
|
1430
1430
|
display: block;
|
|
1431
1431
|
}
|
|
@@ -1448,7 +1448,7 @@
|
|
|
1448
1448
|
.form-control__label > slot {
|
|
1449
1449
|
font-size: 16.5px;
|
|
1450
1450
|
}
|
|
1451
|
-
`;/*! choices.js v11.1.0 | © 2025 Josh Johnson | https://github.com/jshjohnson/Choices#readme */var Kn=function(r,t){return Kn=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,i){e.__proto__=i}||function(e,i){for(var s in i)Object.prototype.hasOwnProperty.call(i,s)&&(e[s]=i[s])},Kn(r,t)};function Wl(r,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");Kn(r,t);function e(){this.constructor=r}r.prototype=t===null?Object.create(t):(e.prototype=t.prototype,new e)}var Jt=function(){return Jt=Object.assign||function(t){for(var e,i=1,s=arguments.length;i<s;i++){e=arguments[i];for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])}return t},Jt.apply(this,arguments)};function Wd(r,t,e){for(var i=0,s=t.length,n;i<s;i++)(n||!(i in t))&&(n||(n=Array.prototype.slice.call(t,0,i)),n[i]=t[i]);return r.concat(n||Array.prototype.slice.call(t))}var yt={ADD_CHOICE:"ADD_CHOICE",REMOVE_CHOICE:"REMOVE_CHOICE",FILTER_CHOICES:"FILTER_CHOICES",ACTIVATE_CHOICES:"ACTIVATE_CHOICES",CLEAR_CHOICES:"CLEAR_CHOICES",ADD_GROUP:"ADD_GROUP",ADD_ITEM:"ADD_ITEM",REMOVE_ITEM:"REMOVE_ITEM",HIGHLIGHT_ITEM:"HIGHLIGHT_ITEM"},Zt={showDropdown:"showDropdown",hideDropdown:"hideDropdown",change:"change",choice:"choice",search:"search",addItem:"addItem",removeItem:"removeItem",highlightItem:"highlightItem",highlightChoice:"highlightChoice",unhighlightItem:"unhighlightItem"},Ht={TAB_KEY:9,SHIFT_KEY:16,BACK_KEY:46,DELETE_KEY:8,ENTER_KEY:13,A_KEY:65,ESC_KEY:27,UP_KEY:38,DOWN_KEY:40,PAGE_UP_KEY:33,PAGE_DOWN_KEY:34},Yd=["fuseOptions","classNames"],di={Text:"text",SelectOne:"select-one",SelectMultiple:"select-multiple"},_a=function(r){return{type:yt.ADD_CHOICE,choice:r}},Gd=function(r){return{type:yt.REMOVE_CHOICE,choice:r}},Xd=function(r){return{type:yt.FILTER_CHOICES,results:r}},Kd=function(r){return{type:yt.ACTIVATE_CHOICES,active:r}},qd=function(r){return{type:yt.ADD_GROUP,group:r}},xa=function(r){return{type:yt.ADD_ITEM,item:r}},wa=function(r){return{type:yt.REMOVE_ITEM,item:r}},ir=function(r,t){return{type:yt.HIGHLIGHT_ITEM,item:r,highlighted:t}},Zd=function(r,t){return Math.floor(Math.random()*(t-r)+r)},Ca=function(r){return Array.from({length:r},function(){return Zd(0,36).toString(36)}).join("")},Jd=function(r,t){var e=r.id||r.name&&"".concat(r.name,"-").concat(Ca(2))||Ca(4);return e=e.replace(/(:|\.|\[|\]|,)/g,""),e="".concat(t,"-").concat(e),e},Qd=function(r,t,e){e===void 0&&(e=1);for(var i="".concat(e>0?"next":"previous","ElementSibling"),s=r[i];s;){if(s.matches(t))return s;s=s[i]}return null},tu=function(r,t,e){e===void 0&&(e=1);var i;return e>0?i=t.scrollTop+t.offsetHeight>=r.offsetTop+r.offsetHeight:i=r.offsetTop>=t.scrollTop,i},rn=function(r){if(typeof r!="string"){if(r==null)return"";if(typeof r=="object"){if("raw"in r)return rn(r.raw);if("trusted"in r)return r.trusted}return r}return r.replace(/&/g,"&").replace(/>/g,">").replace(/</g,"<").replace(/'/g,"'").replace(/"/g,""")},eu=(function(){var r=document.createElement("div");return function(t){r.innerHTML=t.trim();for(var e=r.children[0];r.firstChild;)r.removeChild(r.firstChild);return e}})(),As=function(r,t){return typeof r=="function"?r(rn(t),t):r},Sa=function(r){return typeof r=="function"?r():r},Ai=function(r){if(typeof r=="string")return r;if(typeof r=="object"){if("trusted"in r)return r.trusted;if("raw"in r)return r.raw}return""},Yl=function(r){if(typeof r=="string")return r;if(typeof r=="object"){if("escaped"in r)return r.escaped;if("trusted"in r)return r.trusted}return""},ko=function(r,t){return r?Yl(t):rn(t)},Ne=function(r,t,e){r.innerHTML=ko(t,e)},iu=function(r,t){var e=r.value,i=r.label,s=i===void 0?e:i,n=t.value,o=t.label,a=o===void 0?n:o;return Ai(s).localeCompare(Ai(a),[],{sensitivity:"base",ignorePunctuation:!0,numeric:!0})},su=function(r,t){return r.rank-t.rank},ru=function(r,t,e){e===void 0&&(e=null);var i=new CustomEvent(t,{detail:e,bubbles:!0,cancelable:!0});return r.dispatchEvent(i)},nu=function(r,t){var e=Object.keys(r).sort(),i=Object.keys(t).sort();return e.filter(function(s){return i.indexOf(s)<0})},nn=function(r){return Array.isArray(r)?r:[r]},ms=function(r){return r&&Array.isArray(r)?r.map(function(t){return".".concat(t)}).join(""):".".concat(r)},B=function(r,t){var e;(e=r.classList).add.apply(e,nn(t))},Ie=function(r,t){var e;(e=r.classList).remove.apply(e,nn(t))},ou=function(r){if(typeof r<"u")try{return JSON.parse(r)}catch{return r}return{}},au=function(r,t,e){var i=r.itemEl;i&&(Ie(i,e),B(i,t))},lu=(function(){function r(t){var e=t.element,i=t.type,s=t.classNames;this.element=e,this.classNames=s,this.type=i,this.isActive=!1}return r.prototype.show=function(){return B(this.element,this.classNames.activeState),this.element.setAttribute("aria-expanded","true"),this.isActive=!0,this},r.prototype.hide=function(){return Ie(this.element,this.classNames.activeState),this.element.setAttribute("aria-expanded","false"),this.isActive=!1,this},r})(),Ta=(function(){function r(t){var e=t.element,i=t.type,s=t.classNames,n=t.position;this.element=e,this.classNames=s,this.type=i,this.position=n,this.isOpen=!1,this.isFlipped=!1,this.isDisabled=!1,this.isLoading=!1}return r.prototype.shouldFlip=function(t,e){var i=!1;return this.position==="auto"?i=this.element.getBoundingClientRect().top-e>=0&&!window.matchMedia("(min-height: ".concat(t+1,"px)")).matches:this.position==="top"&&(i=!0),i},r.prototype.setActiveDescendant=function(t){this.element.setAttribute("aria-activedescendant",t)},r.prototype.removeActiveDescendant=function(){this.element.removeAttribute("aria-activedescendant")},r.prototype.open=function(t,e){B(this.element,this.classNames.openState),this.element.setAttribute("aria-expanded","true"),this.isOpen=!0,this.shouldFlip(t,e)&&(B(this.element,this.classNames.flippedState),this.isFlipped=!0)},r.prototype.close=function(){Ie(this.element,this.classNames.openState),this.element.setAttribute("aria-expanded","false"),this.removeActiveDescendant(),this.isOpen=!1,this.isFlipped&&(Ie(this.element,this.classNames.flippedState),this.isFlipped=!1)},r.prototype.addFocusState=function(){B(this.element,this.classNames.focusState)},r.prototype.removeFocusState=function(){Ie(this.element,this.classNames.focusState)},r.prototype.enable=function(){Ie(this.element,this.classNames.disabledState),this.element.removeAttribute("aria-disabled"),this.type===di.SelectOne&&this.element.setAttribute("tabindex","0"),this.isDisabled=!1},r.prototype.disable=function(){B(this.element,this.classNames.disabledState),this.element.setAttribute("aria-disabled","true"),this.type===di.SelectOne&&this.element.setAttribute("tabindex","-1"),this.isDisabled=!0},r.prototype.wrap=function(t){var e=this.element,i=t.parentNode;i&&(t.nextSibling?i.insertBefore(e,t.nextSibling):i.appendChild(e)),e.appendChild(t)},r.prototype.unwrap=function(t){var e=this.element,i=e.parentNode;i&&(i.insertBefore(t,e),i.removeChild(e))},r.prototype.addLoadingState=function(){B(this.element,this.classNames.loadingState),this.element.setAttribute("aria-busy","true"),this.isLoading=!0},r.prototype.removeLoadingState=function(){Ie(this.element,this.classNames.loadingState),this.element.removeAttribute("aria-busy"),this.isLoading=!1},r})(),cu=(function(){function r(t){var e=t.element,i=t.type,s=t.classNames,n=t.preventPaste;this.element=e,this.type=i,this.classNames=s,this.preventPaste=n,this.isFocussed=this.element.isEqualNode(document.activeElement),this.isDisabled=e.disabled,this._onPaste=this._onPaste.bind(this),this._onInput=this._onInput.bind(this),this._onFocus=this._onFocus.bind(this),this._onBlur=this._onBlur.bind(this)}return Object.defineProperty(r.prototype,"placeholder",{set:function(t){this.element.placeholder=t},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"value",{get:function(){return this.element.value},set:function(t){this.element.value=t},enumerable:!1,configurable:!0}),r.prototype.addEventListeners=function(){var t=this.element;t.addEventListener("paste",this._onPaste),t.addEventListener("input",this._onInput,{passive:!0}),t.addEventListener("focus",this._onFocus,{passive:!0}),t.addEventListener("blur",this._onBlur,{passive:!0})},r.prototype.removeEventListeners=function(){var t=this.element;t.removeEventListener("input",this._onInput),t.removeEventListener("paste",this._onPaste),t.removeEventListener("focus",this._onFocus),t.removeEventListener("blur",this._onBlur)},r.prototype.enable=function(){var t=this.element;t.removeAttribute("disabled"),this.isDisabled=!1},r.prototype.disable=function(){var t=this.element;t.setAttribute("disabled",""),this.isDisabled=!0},r.prototype.focus=function(){this.isFocussed||this.element.focus()},r.prototype.blur=function(){this.isFocussed&&this.element.blur()},r.prototype.clear=function(t){return t===void 0&&(t=!0),this.element.value="",t&&this.setWidth(),this},r.prototype.setWidth=function(){var t=this.element;t.style.minWidth="".concat(t.placeholder.length+1,"ch"),t.style.width="".concat(t.value.length+1,"ch")},r.prototype.setActiveDescendant=function(t){this.element.setAttribute("aria-activedescendant",t)},r.prototype.removeActiveDescendant=function(){this.element.removeAttribute("aria-activedescendant")},r.prototype._onInput=function(){this.type!==di.SelectOne&&this.setWidth()},r.prototype._onPaste=function(t){this.preventPaste&&t.preventDefault()},r.prototype._onFocus=function(){this.isFocussed=!0},r.prototype._onBlur=function(){this.isFocussed=!1},r})(),hu=4,Ea=(function(){function r(t){var e=t.element;this.element=e,this.scrollPos=this.element.scrollTop,this.height=this.element.offsetHeight}return r.prototype.prepend=function(t){var e=this.element.firstElementChild;e?this.element.insertBefore(t,e):this.element.append(t)},r.prototype.scrollToTop=function(){this.element.scrollTop=0},r.prototype.scrollToChildElement=function(t,e){var i=this;if(t){var s=this.element.offsetHeight,n=this.element.scrollTop+s,o=t.offsetHeight,a=t.offsetTop+o,l=e>0?this.element.scrollTop+a-n:t.offsetTop;requestAnimationFrame(function(){i._animateScroll(l,e)})}},r.prototype._scrollDown=function(t,e,i){var s=(i-t)/e,n=s>1?s:1;this.element.scrollTop=t+n},r.prototype._scrollUp=function(t,e,i){var s=(t-i)/e,n=s>1?s:1;this.element.scrollTop=t-n},r.prototype._animateScroll=function(t,e){var i=this,s=hu,n=this.element.scrollTop,o=!1;e>0?(this._scrollDown(n,s,t),n<t&&(o=!0)):(this._scrollUp(n,s,t),n>t&&(o=!0)),o&&requestAnimationFrame(function(){i._animateScroll(t,e)})},r})(),Gl=(function(){function r(t){var e=t.element,i=t.classNames;this.element=e,this.classNames=i,this.isDisabled=!1}return Object.defineProperty(r.prototype,"isActive",{get:function(){return this.element.dataset.choice==="active"},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"dir",{get:function(){return this.element.dir},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"value",{get:function(){return this.element.value},set:function(t){this.element.setAttribute("value",t),this.element.value=t},enumerable:!1,configurable:!0}),r.prototype.conceal=function(){var t=this.element;B(t,this.classNames.input),t.hidden=!0,t.tabIndex=-1;var e=t.getAttribute("style");e&&t.setAttribute("data-choice-orig-style",e),t.setAttribute("data-choice","active")},r.prototype.reveal=function(){var t=this.element;Ie(t,this.classNames.input),t.hidden=!1,t.removeAttribute("tabindex");var e=t.getAttribute("data-choice-orig-style");e?(t.removeAttribute("data-choice-orig-style"),t.setAttribute("style",e)):t.removeAttribute("style"),t.removeAttribute("data-choice")},r.prototype.enable=function(){this.element.removeAttribute("disabled"),this.element.disabled=!1,this.isDisabled=!1},r.prototype.disable=function(){this.element.setAttribute("disabled",""),this.element.disabled=!0,this.isDisabled=!0},r.prototype.triggerEvent=function(t,e){ru(this.element,t,e||{})},r})(),du=(function(r){Wl(t,r);function t(){return r!==null&&r.apply(this,arguments)||this}return t})(Gl),Ss=function(r,t){return t===void 0&&(t=!0),typeof r>"u"?t:!!r},Xl=function(r){if(typeof r=="string"&&(r=r.split(" ").filter(function(t){return t.length})),Array.isArray(r)&&r.length)return r},Me=function(r,t,e){if(e===void 0&&(e=!0),typeof r=="string"){var i=rn(r),s=e||i===r?r:{escaped:i,raw:r},n=Me({value:r,label:s,selected:!0},!1);return n}var o=r;if("choices"in o){if(!t)throw new TypeError("optGroup is not allowed");var a=o,l=a.choices.map(function(u){return Me(u,!1)}),c={id:0,label:Ai(a.label)||a.value,active:!!l.length,disabled:!!a.disabled,choices:l};return c}var h=o,d={id:0,group:null,score:0,rank:0,value:h.value,label:h.label||h.value,active:Ss(h.active),selected:Ss(h.selected,!1),disabled:Ss(h.disabled,!1),placeholder:Ss(h.placeholder,!1),highlighted:!1,labelClass:Xl(h.labelClass),labelDescription:h.labelDescription,customProperties:h.customProperties};return d},uu=function(r){return r.tagName==="INPUT"},Kl=function(r){return r.tagName==="SELECT"},pu=function(r){return r.tagName==="OPTION"},gu=function(r){return r.tagName==="OPTGROUP"},fu=(function(r){Wl(t,r);function t(e){var i=e.element,s=e.classNames,n=e.template,o=e.extractPlaceholder,a=r.call(this,{element:i,classNames:s})||this;return a.template=n,a.extractPlaceholder=o,a}return Object.defineProperty(t.prototype,"placeholderOption",{get:function(){return this.element.querySelector('option[value=""]')||this.element.querySelector("option[placeholder]")},enumerable:!1,configurable:!0}),t.prototype.addOptions=function(e){var i=this,s=document.createDocumentFragment();e.forEach(function(n){var o=n;if(!o.element){var a=i.template(o);s.appendChild(a),o.element=a}}),this.element.appendChild(s)},t.prototype.optionsAsChoices=function(){var e=this,i=[];return this.element.querySelectorAll(":scope > option, :scope > optgroup").forEach(function(s){pu(s)?i.push(e._optionToChoice(s)):gu(s)&&i.push(e._optgroupToChoice(s))}),i},t.prototype._optionToChoice=function(e){return!e.hasAttribute("value")&&e.hasAttribute("placeholder")&&(e.setAttribute("value",""),e.value=""),{id:0,group:null,score:0,rank:0,value:e.value,label:e.label,element:e,active:!0,selected:this.extractPlaceholder?e.selected:e.hasAttribute("selected"),disabled:e.disabled,highlighted:!1,placeholder:this.extractPlaceholder&&(!e.value||e.hasAttribute("placeholder")),labelClass:typeof e.dataset.labelClass<"u"?Xl(e.dataset.labelClass):void 0,labelDescription:typeof e.dataset.labelDescription<"u"?e.dataset.labelDescription:void 0,customProperties:ou(e.dataset.customProperties)}},t.prototype._optgroupToChoice=function(e){var i=this,s=e.querySelectorAll("option"),n=Array.from(s).map(function(o){return i._optionToChoice(o)});return{id:0,label:e.label||"",element:e,active:!!n.length,disabled:e.disabled,choices:n}},t})(Gl),mu={containerOuter:["choices"],containerInner:["choices__inner"],input:["choices__input"],inputCloned:["choices__input--cloned"],list:["choices__list"],listItems:["choices__list--multiple"],listSingle:["choices__list--single"],listDropdown:["choices__list--dropdown"],item:["choices__item"],itemSelectable:["choices__item--selectable"],itemDisabled:["choices__item--disabled"],itemChoice:["choices__item--choice"],description:["choices__description"],placeholder:["choices__placeholder"],group:["choices__group"],groupHeading:["choices__heading"],button:["choices__button"],activeState:["is-active"],focusState:["is-focused"],openState:["is-open"],disabledState:["is-disabled"],highlightedState:["is-highlighted"],selectedState:["is-selected"],flippedState:["is-flipped"],loadingState:["is-loading"],notice:["choices__notice"],addChoice:["choices__item--selectable","add-choice"],noResults:["has-no-results"],noChoices:["has-no-choices"]},Oa={items:[],choices:[],silent:!1,renderChoiceLimit:-1,maxItemCount:-1,closeDropdownOnSelect:"auto",singleModeForMultiSelect:!1,addChoices:!1,addItems:!0,addItemFilter:function(r){return!!r&&r!==""},removeItems:!0,removeItemButton:!1,removeItemButtonAlignLeft:!1,editItems:!1,allowHTML:!1,allowHtmlUserInput:!1,duplicateItemsAllowed:!0,delimiter:",",paste:!0,searchEnabled:!0,searchChoices:!0,searchFloor:1,searchResultLimit:4,searchFields:["label","value"],position:"auto",resetScrollPosition:!0,shouldSort:!0,shouldSortItems:!1,sorter:iu,shadowRoot:null,placeholder:!0,placeholderValue:null,searchPlaceholderValue:null,prependValue:null,appendValue:null,renderSelectedChoices:"auto",loadingText:"Loading...",noResultsText:"No results found",noChoicesText:"No choices to choose from",itemSelectText:"Press to select",uniqueItemText:"Only unique values can be added",customAddItemText:"Only values matching specific conditions can be added",addItemText:function(r){return'Press Enter to add <b>"'.concat(r,'"</b>')},removeItemIconText:function(){return"Remove item"},removeItemLabelText:function(r){return"Remove item: ".concat(r)},maxItemText:function(r){return"Only ".concat(r," values can be added")},valueComparer:function(r,t){return r===t},fuseOptions:{includeScore:!0},labelId:"",callbackOnInit:null,callbackOnCreateTemplates:null,classNames:mu,appendGroupInSearch:!1},ka=function(r){var t=r.itemEl;t&&(t.remove(),r.itemEl=void 0)};function bu(r,t,e){var i=r,s=!0;switch(t.type){case yt.ADD_ITEM:{t.item.selected=!0;var n=t.item.element;n&&(n.selected=!0,n.setAttribute("selected","")),i.push(t.item);break}case yt.REMOVE_ITEM:{t.item.selected=!1;var n=t.item.element;if(n){n.selected=!1,n.removeAttribute("selected");var o=n.parentElement;o&&Kl(o)&&o.type===di.SelectOne&&(o.value="")}ka(t.item),i=i.filter(function(h){return h.id!==t.item.id});break}case yt.REMOVE_CHOICE:{ka(t.choice),i=i.filter(function(c){return c.id!==t.choice.id});break}case yt.HIGHLIGHT_ITEM:{var a=t.highlighted,l=i.find(function(c){return c.id===t.item.id});l&&l.highlighted!==a&&(l.highlighted=a,e&&au(l,a?e.classNames.highlightedState:e.classNames.selectedState,a?e.classNames.selectedState:e.classNames.highlightedState));break}default:{s=!1;break}}return{state:i,update:s}}function vu(r,t){var e=r,i=!0;switch(t.type){case yt.ADD_GROUP:{e.push(t.group);break}case yt.CLEAR_CHOICES:{e=[];break}default:{i=!1;break}}return{state:e,update:i}}function yu(r,t,e){var i=r,s=!0;switch(t.type){case yt.ADD_CHOICE:{i.push(t.choice);break}case yt.REMOVE_CHOICE:{t.choice.choiceEl=void 0,t.choice.group&&(t.choice.group.choices=t.choice.group.choices.filter(function(o){return o.id!==t.choice.id})),i=i.filter(function(o){return o.id!==t.choice.id});break}case yt.ADD_ITEM:case yt.REMOVE_ITEM:{t.item.choiceEl=void 0;break}case yt.FILTER_CHOICES:{var n=[];t.results.forEach(function(o){n[o.item.id]=o}),i.forEach(function(o){var a=n[o.id];a!==void 0?(o.score=a.score,o.rank=a.rank,o.active=!0):(o.score=0,o.rank=0,o.active=!1),e&&e.appendGroupInSearch&&(o.choiceEl=void 0)});break}case yt.ACTIVATE_CHOICES:{i.forEach(function(o){o.active=t.active,e&&e.appendGroupInSearch&&(o.choiceEl=void 0)});break}case yt.CLEAR_CHOICES:{i=[];break}default:{s=!1;break}}return{state:i,update:s}}var Pa={groups:vu,items:bu,choices:yu},_u=(function(){function r(t){this._state=this.defaultState,this._listeners=[],this._txn=0,this._context=t}return Object.defineProperty(r.prototype,"defaultState",{get:function(){return{groups:[],items:[],choices:[]}},enumerable:!1,configurable:!0}),r.prototype.changeSet=function(t){return{groups:t,items:t,choices:t}},r.prototype.reset=function(){this._state=this.defaultState;var t=this.changeSet(!0);this._txn?this._changeSet=t:this._listeners.forEach(function(e){return e(t)})},r.prototype.subscribe=function(t){return this._listeners.push(t),this},r.prototype.dispatch=function(t){var e=this,i=this._state,s=!1,n=this._changeSet||this.changeSet(!1);Object.keys(Pa).forEach(function(o){var a=Pa[o](i[o],t,e._context);a.update&&(s=!0,n[o]=!0,i[o]=a.state)}),s&&(this._txn?this._changeSet=n:this._listeners.forEach(function(o){return o(n)}))},r.prototype.withTxn=function(t){this._txn++;try{t()}finally{if(this._txn=Math.max(0,this._txn-1),!this._txn){var e=this._changeSet;e&&(this._changeSet=void 0,this._listeners.forEach(function(i){return i(e)}))}}},Object.defineProperty(r.prototype,"state",{get:function(){return this._state},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"items",{get:function(){return this.state.items},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"highlightedActiveItems",{get:function(){return this.items.filter(function(t){return t.active&&t.highlighted})},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"choices",{get:function(){return this.state.choices},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"activeChoices",{get:function(){return this.choices.filter(function(t){return t.active})},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"searchableChoices",{get:function(){return this.choices.filter(function(t){return!t.disabled&&!t.placeholder})},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"groups",{get:function(){return this.state.groups},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"activeGroups",{get:function(){var t=this;return this.state.groups.filter(function(e){var i=e.active&&!e.disabled,s=t.state.choices.some(function(n){return n.active&&!n.disabled});return i&&s},[])},enumerable:!1,configurable:!0}),r.prototype.inTxn=function(){return this._txn>0},r.prototype.getChoiceById=function(t){return this.activeChoices.find(function(e){return e.id===t})},r.prototype.getGroupById=function(t){return this.groups.find(function(e){return e.id===t})},r})(),$t={noChoices:"no-choices",noResults:"no-results",addChoice:"add-choice",generic:""};function xu(r,t,e){return(t=Cu(t))in r?Object.defineProperty(r,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):r[t]=e,r}function Aa(r,t){var e=Object.keys(r);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(r);t&&(i=i.filter(function(s){return Object.getOwnPropertyDescriptor(r,s).enumerable})),e.push.apply(e,i)}return e}function Gi(r){for(var t=1;t<arguments.length;t++){var e=arguments[t]!=null?arguments[t]:{};t%2?Aa(Object(e),!0).forEach(function(i){xu(r,i,e[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(e)):Aa(Object(e)).forEach(function(i){Object.defineProperty(r,i,Object.getOwnPropertyDescriptor(e,i))})}return r}function wu(r,t){if(typeof r!="object"||!r)return r;var e=r[Symbol.toPrimitive];if(e!==void 0){var i=e.call(r,t);if(typeof i!="object")return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(r)}function Cu(r){var t=wu(r,"string");return typeof t=="symbol"?t:t+""}function Ze(r){return Array.isArray?Array.isArray(r):Jl(r)==="[object Array]"}function Su(r){if(typeof r=="string")return r;let t=r+"";return t=="0"&&1/r==-1/0?"-0":t}function Tu(r){return r==null?"":Su(r)}function Fe(r){return typeof r=="string"}function ql(r){return typeof r=="number"}function Eu(r){return r===!0||r===!1||Ou(r)&&Jl(r)=="[object Boolean]"}function Zl(r){return typeof r=="object"}function Ou(r){return Zl(r)&&r!==null}function he(r){return r!=null}function kn(r){return!r.trim().length}function Jl(r){return r==null?r===void 0?"[object Undefined]":"[object Null]":Object.prototype.toString.call(r)}const ku="Incorrect 'index' type",Pu=r=>`Invalid value for key ${r}`,Au=r=>`Pattern length exceeds max of ${r}.`,Du=r=>`Missing ${r} property in key`,Mu=r=>`Property 'weight' in key '${r}' must be a positive integer`,Da=Object.prototype.hasOwnProperty;class Iu{constructor(t){this._keys=[],this._keyMap={};let e=0;t.forEach(i=>{let s=Ql(i);this._keys.push(s),this._keyMap[s.id]=s,e+=s.weight}),this._keys.forEach(i=>{i.weight/=e})}get(t){return this._keyMap[t]}keys(){return this._keys}toJSON(){return JSON.stringify(this._keys)}}function Ql(r){let t=null,e=null,i=null,s=1,n=null;if(Fe(r)||Ze(r))i=r,t=Ma(r),e=qn(r);else{if(!Da.call(r,"name"))throw new Error(Du("name"));const o=r.name;if(i=o,Da.call(r,"weight")&&(s=r.weight,s<=0))throw new Error(Mu(o));t=Ma(o),e=qn(o),n=r.getFn}return{path:t,id:e,weight:s,src:i,getFn:n}}function Ma(r){return Ze(r)?r:r.split(".")}function qn(r){return Ze(r)?r.join("."):r}function Lu(r,t){let e=[],i=!1;const s=(n,o,a)=>{if(he(n))if(!o[a])e.push(n);else{let l=o[a];const c=n[l];if(!he(c))return;if(a===o.length-1&&(Fe(c)||ql(c)||Eu(c)))e.push(Tu(c));else if(Ze(c)){i=!0;for(let h=0,d=c.length;h<d;h+=1)s(c[h],o,a+1)}else o.length&&s(c,o,a+1)}};return s(r,Fe(t)?t.split("."):t,0),i?e:e[0]}const Fu={includeMatches:!1,findAllMatches:!1,minMatchCharLength:1},ju={isCaseSensitive:!1,includeScore:!1,keys:[],shouldSort:!0,sortFn:(r,t)=>r.score===t.score?r.idx<t.idx?-1:1:r.score<t.score?-1:1},$u={location:0,threshold:.6,distance:100},Ru={useExtendedSearch:!1,getFn:Lu,ignoreLocation:!1,ignoreFieldNorm:!1,fieldNormWeight:1};var $=Gi(Gi(Gi(Gi({},ju),Fu),$u),Ru);const Bu=/[^ ]+/g;function zu(r=1,t=3){const e=new Map,i=Math.pow(10,t);return{get(s){const n=s.match(Bu).length;if(e.has(n))return e.get(n);const o=1/Math.pow(n,.5*r),a=parseFloat(Math.round(o*i)/i);return e.set(n,a),a},clear(){e.clear()}}}class Po{constructor({getFn:t=$.getFn,fieldNormWeight:e=$.fieldNormWeight}={}){this.norm=zu(e,3),this.getFn=t,this.isCreated=!1,this.setIndexRecords()}setSources(t=[]){this.docs=t}setIndexRecords(t=[]){this.records=t}setKeys(t=[]){this.keys=t,this._keysMap={},t.forEach((e,i)=>{this._keysMap[e.id]=i})}create(){this.isCreated||!this.docs.length||(this.isCreated=!0,Fe(this.docs[0])?this.docs.forEach((t,e)=>{this._addString(t,e)}):this.docs.forEach((t,e)=>{this._addObject(t,e)}),this.norm.clear())}add(t){const e=this.size();Fe(t)?this._addString(t,e):this._addObject(t,e)}removeAt(t){this.records.splice(t,1);for(let e=t,i=this.size();e<i;e+=1)this.records[e].i-=1}getValueForItemAtKeyId(t,e){return t[this._keysMap[e]]}size(){return this.records.length}_addString(t,e){if(!he(t)||kn(t))return;let i={v:t,i:e,n:this.norm.get(t)};this.records.push(i)}_addObject(t,e){let i={i:e,$:{}};this.keys.forEach((s,n)=>{let o=s.getFn?s.getFn(t):this.getFn(t,s.path);if(he(o)){if(Ze(o)){let a=[];const l=[{nestedArrIndex:-1,value:o}];for(;l.length;){const{nestedArrIndex:c,value:h}=l.pop();if(he(h))if(Fe(h)&&!kn(h)){let d={v:h,i:c,n:this.norm.get(h)};a.push(d)}else Ze(h)&&h.forEach((d,u)=>{l.push({nestedArrIndex:u,value:d})})}i.$[n]=a}else if(Fe(o)&&!kn(o)){let a={v:o,n:this.norm.get(o)};i.$[n]=a}}}),this.records.push(i)}toJSON(){return{keys:this.keys,records:this.records}}}function tc(r,t,{getFn:e=$.getFn,fieldNormWeight:i=$.fieldNormWeight}={}){const s=new Po({getFn:e,fieldNormWeight:i});return s.setKeys(r.map(Ql)),s.setSources(t),s.create(),s}function Hu(r,{getFn:t=$.getFn,fieldNormWeight:e=$.fieldNormWeight}={}){const{keys:i,records:s}=r,n=new Po({getFn:t,fieldNormWeight:e});return n.setKeys(i),n.setIndexRecords(s),n}function sr(r,{errors:t=0,currentLocation:e=0,expectedLocation:i=0,distance:s=$.distance,ignoreLocation:n=$.ignoreLocation}={}){const o=t/r.length;if(n)return o;const a=Math.abs(i-e);return s?o+a/s:a?1:o}function Vu(r=[],t=$.minMatchCharLength){let e=[],i=-1,s=-1,n=0;for(let o=r.length;n<o;n+=1){let a=r[n];a&&i===-1?i=n:!a&&i!==-1&&(s=n-1,s-i+1>=t&&e.push([i,s]),i=-1)}return r[n-1]&&n-i>=t&&e.push([i,n-1]),e}const Ti=32;function Nu(r,t,e,{location:i=$.location,distance:s=$.distance,threshold:n=$.threshold,findAllMatches:o=$.findAllMatches,minMatchCharLength:a=$.minMatchCharLength,includeMatches:l=$.includeMatches,ignoreLocation:c=$.ignoreLocation}={}){if(t.length>Ti)throw new Error(Au(Ti));const h=t.length,d=r.length,u=Math.max(0,Math.min(i,d));let p=n,g=u;const f=a>1||l,m=f?Array(d):[];let b;for(;(b=r.indexOf(t,g))>-1;){let O=sr(t,{currentLocation:b,expectedLocation:u,distance:s,ignoreLocation:c});if(p=Math.min(O,p),g=b+h,f){let E=0;for(;E<h;)m[b+E]=1,E+=1}}g=-1;let _=[],w=1,S=h+d;const T=1<<h-1;for(let O=0;O<h;O+=1){let E=0,P=S;for(;E<P;)sr(t,{errors:O,currentLocation:u+P,expectedLocation:u,distance:s,ignoreLocation:c})<=p?E=P:S=P,P=Math.floor((S-E)/2+E);S=P;let R=Math.max(1,u-P+1),L=o?d:Math.min(u+P,d)+h,F=Array(L+2);F[L+1]=(1<<O)-1;for(let M=L;M>=R;M-=1){let U=M-1,X=e[r.charAt(U)];if(f&&(m[U]=+!!X),F[M]=(F[M+1]<<1|1)&X,O&&(F[M]|=(_[M+1]|_[M])<<1|1|_[M+1]),F[M]&T&&(w=sr(t,{errors:O,currentLocation:U,expectedLocation:u,distance:s,ignoreLocation:c}),w<=p)){if(p=w,g=U,g<=u)break;R=Math.max(1,2*u-g)}}if(sr(t,{errors:O+1,currentLocation:u,expectedLocation:u,distance:s,ignoreLocation:c})>p)break;_=F}const k={isMatch:g>=0,score:Math.max(.001,w)};if(f){const O=Vu(m,a);O.length?l&&(k.indices=O):k.isMatch=!1}return k}function Uu(r){let t={};for(let e=0,i=r.length;e<i;e+=1){const s=r.charAt(e);t[s]=(t[s]||0)|1<<i-e-1}return t}class ec{constructor(t,{location:e=$.location,threshold:i=$.threshold,distance:s=$.distance,includeMatches:n=$.includeMatches,findAllMatches:o=$.findAllMatches,minMatchCharLength:a=$.minMatchCharLength,isCaseSensitive:l=$.isCaseSensitive,ignoreLocation:c=$.ignoreLocation}={}){if(this.options={location:e,threshold:i,distance:s,includeMatches:n,findAllMatches:o,minMatchCharLength:a,isCaseSensitive:l,ignoreLocation:c},this.pattern=l?t:t.toLowerCase(),this.chunks=[],!this.pattern.length)return;const h=(u,p)=>{this.chunks.push({pattern:u,alphabet:Uu(u),startIndex:p})},d=this.pattern.length;if(d>Ti){let u=0;const p=d%Ti,g=d-p;for(;u<g;)h(this.pattern.substr(u,Ti),u),u+=Ti;if(p){const f=d-Ti;h(this.pattern.substr(f),f)}}else h(this.pattern,0)}searchIn(t){const{isCaseSensitive:e,includeMatches:i}=this.options;if(e||(t=t.toLowerCase()),this.pattern===t){let g={isMatch:!0,score:0};return i&&(g.indices=[[0,t.length-1]]),g}const{location:s,distance:n,threshold:o,findAllMatches:a,minMatchCharLength:l,ignoreLocation:c}=this.options;let h=[],d=0,u=!1;this.chunks.forEach(({pattern:g,alphabet:f,startIndex:m})=>{const{isMatch:b,score:_,indices:w}=Nu(t,g,f,{location:s+m,distance:n,threshold:o,findAllMatches:a,minMatchCharLength:l,includeMatches:i,ignoreLocation:c});b&&(u=!0),d+=_,b&&w&&(h=[...h,...w])});let p={isMatch:u,score:u?d/this.chunks.length:1};return u&&i&&(p.indices=h),p}}class vi{constructor(t){this.pattern=t}static isMultiMatch(t){return Ia(t,this.multiRegex)}static isSingleMatch(t){return Ia(t,this.singleRegex)}search(){}}function Ia(r,t){const e=r.match(t);return e?e[1]:null}class Wu extends vi{constructor(t){super(t)}static get type(){return"exact"}static get multiRegex(){return/^="(.*)"$/}static get singleRegex(){return/^=(.*)$/}search(t){const e=t===this.pattern;return{isMatch:e,score:e?0:1,indices:[0,this.pattern.length-1]}}}class Yu extends vi{constructor(t){super(t)}static get type(){return"inverse-exact"}static get multiRegex(){return/^!"(.*)"$/}static get singleRegex(){return/^!(.*)$/}search(t){const i=t.indexOf(this.pattern)===-1;return{isMatch:i,score:i?0:1,indices:[0,t.length-1]}}}class Gu extends vi{constructor(t){super(t)}static get type(){return"prefix-exact"}static get multiRegex(){return/^\^"(.*)"$/}static get singleRegex(){return/^\^(.*)$/}search(t){const e=t.startsWith(this.pattern);return{isMatch:e,score:e?0:1,indices:[0,this.pattern.length-1]}}}class Xu extends vi{constructor(t){super(t)}static get type(){return"inverse-prefix-exact"}static get multiRegex(){return/^!\^"(.*)"$/}static get singleRegex(){return/^!\^(.*)$/}search(t){const e=!t.startsWith(this.pattern);return{isMatch:e,score:e?0:1,indices:[0,t.length-1]}}}class Ku extends vi{constructor(t){super(t)}static get type(){return"suffix-exact"}static get multiRegex(){return/^"(.*)"\$$/}static get singleRegex(){return/^(.*)\$$/}search(t){const e=t.endsWith(this.pattern);return{isMatch:e,score:e?0:1,indices:[t.length-this.pattern.length,t.length-1]}}}class qu extends vi{constructor(t){super(t)}static get type(){return"inverse-suffix-exact"}static get multiRegex(){return/^!"(.*)"\$$/}static get singleRegex(){return/^!(.*)\$$/}search(t){const e=!t.endsWith(this.pattern);return{isMatch:e,score:e?0:1,indices:[0,t.length-1]}}}class ic extends vi{constructor(t,{location:e=$.location,threshold:i=$.threshold,distance:s=$.distance,includeMatches:n=$.includeMatches,findAllMatches:o=$.findAllMatches,minMatchCharLength:a=$.minMatchCharLength,isCaseSensitive:l=$.isCaseSensitive,ignoreLocation:c=$.ignoreLocation}={}){super(t),this._bitapSearch=new ec(t,{location:e,threshold:i,distance:s,includeMatches:n,findAllMatches:o,minMatchCharLength:a,isCaseSensitive:l,ignoreLocation:c})}static get type(){return"fuzzy"}static get multiRegex(){return/^"(.*)"$/}static get singleRegex(){return/^(.*)$/}search(t){return this._bitapSearch.searchIn(t)}}class sc extends vi{constructor(t){super(t)}static get type(){return"include"}static get multiRegex(){return/^'"(.*)"$/}static get singleRegex(){return/^'(.*)$/}search(t){let e=0,i;const s=[],n=this.pattern.length;for(;(i=t.indexOf(this.pattern,e))>-1;)e=i+n,s.push([i,e-1]);const o=!!s.length;return{isMatch:o,score:o?0:1,indices:s}}}const Zn=[Wu,sc,Gu,Xu,qu,Ku,Yu,ic],La=Zn.length,Zu=/ +(?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)/,Ju="|";function Qu(r,t={}){return r.split(Ju).map(e=>{let i=e.trim().split(Zu).filter(n=>n&&!!n.trim()),s=[];for(let n=0,o=i.length;n<o;n+=1){const a=i[n];let l=!1,c=-1;for(;!l&&++c<La;){const h=Zn[c];let d=h.isMultiMatch(a);d&&(s.push(new h(d,t)),l=!0)}if(!l)for(c=-1;++c<La;){const h=Zn[c];let d=h.isSingleMatch(a);if(d){s.push(new h(d,t));break}}}return s})}const tp=new Set([ic.type,sc.type]);class ep{constructor(t,{isCaseSensitive:e=$.isCaseSensitive,includeMatches:i=$.includeMatches,minMatchCharLength:s=$.minMatchCharLength,ignoreLocation:n=$.ignoreLocation,findAllMatches:o=$.findAllMatches,location:a=$.location,threshold:l=$.threshold,distance:c=$.distance}={}){this.query=null,this.options={isCaseSensitive:e,includeMatches:i,minMatchCharLength:s,findAllMatches:o,ignoreLocation:n,location:a,threshold:l,distance:c},this.pattern=e?t:t.toLowerCase(),this.query=Qu(this.pattern,this.options)}static condition(t,e){return e.useExtendedSearch}searchIn(t){const e=this.query;if(!e)return{isMatch:!1,score:1};const{includeMatches:i,isCaseSensitive:s}=this.options;t=s?t:t.toLowerCase();let n=0,o=[],a=0;for(let l=0,c=e.length;l<c;l+=1){const h=e[l];o.length=0,n=0;for(let d=0,u=h.length;d<u;d+=1){const p=h[d],{isMatch:g,indices:f,score:m}=p.search(t);if(g){if(n+=1,a+=m,i){const b=p.constructor.type;tp.has(b)?o=[...o,...f]:o.push(f)}}else{a=0,n=0,o.length=0;break}}if(n){let d={isMatch:!0,score:a/n};return i&&(d.indices=o),d}}return{isMatch:!1,score:1}}}const Jn=[];function ip(...r){Jn.push(...r)}function Qn(r,t){for(let e=0,i=Jn.length;e<i;e+=1){let s=Jn[e];if(s.condition(r,t))return new s(r,t)}return new ec(r,t)}const $r={AND:"$and",OR:"$or"},to={PATH:"$path",PATTERN:"$val"},eo=r=>!!(r[$r.AND]||r[$r.OR]),sp=r=>!!r[to.PATH],rp=r=>!Ze(r)&&Zl(r)&&!eo(r),Fa=r=>({[$r.AND]:Object.keys(r).map(t=>({[t]:r[t]}))});function rc(r,t,{auto:e=!0}={}){const i=s=>{let n=Object.keys(s);const o=sp(s);if(!o&&n.length>1&&!eo(s))return i(Fa(s));if(rp(s)){const l=o?s[to.PATH]:n[0],c=o?s[to.PATTERN]:s[l];if(!Fe(c))throw new Error(Pu(l));const h={keyId:qn(l),pattern:c};return e&&(h.searcher=Qn(c,t)),h}let a={children:[],operator:n[0]};return n.forEach(l=>{const c=s[l];Ze(c)&&c.forEach(h=>{a.children.push(i(h))})}),a};return eo(r)||(r=Fa(r)),i(r)}function np(r,{ignoreFieldNorm:t=$.ignoreFieldNorm}){r.forEach(e=>{let i=1;e.matches.forEach(({key:s,norm:n,score:o})=>{const a=s?s.weight:null;i*=Math.pow(o===0&&a?Number.EPSILON:o,(a||1)*(t?1:n))}),e.score=i})}function op(r,t){const e=r.matches;t.matches=[],he(e)&&e.forEach(i=>{if(!he(i.indices)||!i.indices.length)return;const{indices:s,value:n}=i;let o={indices:s,value:n};i.key&&(o.key=i.key.src),i.idx>-1&&(o.refIndex=i.idx),t.matches.push(o)})}function ap(r,t){t.score=r.score}function lp(r,t,{includeMatches:e=$.includeMatches,includeScore:i=$.includeScore}={}){const s=[];return e&&s.push(op),i&&s.push(ap),r.map(n=>{const{idx:o}=n,a={item:t[o],refIndex:o};return s.length&&s.forEach(l=>{l(n,a)}),a})}class is{constructor(t,e={},i){this.options=Gi(Gi({},$),e),this.options.useExtendedSearch,this._keyStore=new Iu(this.options.keys),this.setCollection(t,i)}setCollection(t,e){if(this._docs=t,e&&!(e instanceof Po))throw new Error(ku);this._myIndex=e||tc(this.options.keys,this._docs,{getFn:this.options.getFn,fieldNormWeight:this.options.fieldNormWeight})}add(t){he(t)&&(this._docs.push(t),this._myIndex.add(t))}remove(t=()=>!1){const e=[];for(let i=0,s=this._docs.length;i<s;i+=1){const n=this._docs[i];t(n,i)&&(this.removeAt(i),i-=1,s-=1,e.push(n))}return e}removeAt(t){this._docs.splice(t,1),this._myIndex.removeAt(t)}getIndex(){return this._myIndex}search(t,{limit:e=-1}={}){const{includeMatches:i,includeScore:s,shouldSort:n,sortFn:o,ignoreFieldNorm:a}=this.options;let l=Fe(t)?Fe(this._docs[0])?this._searchStringList(t):this._searchObjectList(t):this._searchLogical(t);return np(l,{ignoreFieldNorm:a}),n&&l.sort(o),ql(e)&&e>-1&&(l=l.slice(0,e)),lp(l,this._docs,{includeMatches:i,includeScore:s})}_searchStringList(t){const e=Qn(t,this.options),{records:i}=this._myIndex,s=[];return i.forEach(({v:n,i:o,n:a})=>{if(!he(n))return;const{isMatch:l,score:c,indices:h}=e.searchIn(n);l&&s.push({item:n,idx:o,matches:[{score:c,value:n,norm:a,indices:h}]})}),s}_searchLogical(t){const e=rc(t,this.options),i=(a,l,c)=>{if(!a.children){const{keyId:d,searcher:u}=a,p=this._findMatches({key:this._keyStore.get(d),value:this._myIndex.getValueForItemAtKeyId(l,d),searcher:u});return p&&p.length?[{idx:c,item:l,matches:p}]:[]}const h=[];for(let d=0,u=a.children.length;d<u;d+=1){const p=a.children[d],g=i(p,l,c);if(g.length)h.push(...g);else if(a.operator===$r.AND)return[]}return h},s=this._myIndex.records,n={},o=[];return s.forEach(({$:a,i:l})=>{if(he(a)){let c=i(e,a,l);c.length&&(n[l]||(n[l]={idx:l,item:a,matches:[]},o.push(n[l])),c.forEach(({matches:h})=>{n[l].matches.push(...h)}))}}),o}_searchObjectList(t){const e=Qn(t,this.options),{keys:i,records:s}=this._myIndex,n=[];return s.forEach(({$:o,i:a})=>{if(!he(o))return;let l=[];i.forEach((c,h)=>{l.push(...this._findMatches({key:c,value:o[h],searcher:e}))}),l.length&&n.push({idx:a,item:o,matches:l})}),n}_findMatches({key:t,value:e,searcher:i}){if(!he(e))return[];let s=[];if(Ze(e))e.forEach(({v:n,i:o,n:a})=>{if(!he(n))return;const{isMatch:l,score:c,indices:h}=i.searchIn(n);l&&s.push({score:c,key:t,value:n,idx:o,norm:a,indices:h})});else{const{v:n,n:o}=e,{isMatch:a,score:l,indices:c}=i.searchIn(n);a&&s.push({score:l,key:t,value:n,norm:o,indices:c})}return s}}is.version="7.0.0";is.createIndex=tc;is.parseIndex=Hu;is.config=$;is.parseQuery=rc;ip(ep);var cp=(function(){function r(t){this._haystack=[],this._fuseOptions=Jt(Jt({},t.fuseOptions),{keys:Wd([],t.searchFields),includeMatches:!0})}return r.prototype.index=function(t){this._haystack=t,this._fuse&&this._fuse.setCollection(t)},r.prototype.reset=function(){this._haystack=[],this._fuse=void 0},r.prototype.isEmptyIndex=function(){return!this._haystack.length},r.prototype.search=function(t){this._fuse||(this._fuse=new is(this._haystack,this._fuseOptions));var e=this._fuse.search(t);return e.map(function(i,s){return{item:i.item,score:i.score||0,rank:s+1}})},r})();function hp(r){return new cp(r)}var dp=function(r){for(var t in r)if(Object.prototype.hasOwnProperty.call(r,t))return!1;return!0},Pn=function(r,t,e){var i=r.dataset,s=t.customProperties,n=t.labelClass,o=t.labelDescription;n&&(i.labelClass=nn(n).join(" ")),o&&(i.labelDescription=o),e&&s&&(typeof s=="string"?i.customProperties=s:typeof s=="object"&&!dp(s)&&(i.customProperties=JSON.stringify(s)))},ja=function(r,t,e){var i=t&&r.querySelector("label[for='".concat(t,"']")),s=i&&i.innerText;s&&e.setAttribute("aria-label",s)},up={containerOuter:function(r,t,e,i,s,n,o){var a=r.classNames.containerOuter,l=document.createElement("div");return B(l,a),l.dataset.type=n,t&&(l.dir=t),i&&(l.tabIndex=0),e&&(l.setAttribute("role",s?"combobox":"listbox"),s?l.setAttribute("aria-autocomplete","list"):o||ja(this._docRoot,this.passedElement.element.id,l),l.setAttribute("aria-haspopup","true"),l.setAttribute("aria-expanded","false")),o&&l.setAttribute("aria-labelledby",o),l},containerInner:function(r){var t=r.classNames.containerInner,e=document.createElement("div");return B(e,t),e},itemList:function(r,t){var e=r.searchEnabled,i=r.classNames,s=i.list,n=i.listSingle,o=i.listItems,a=document.createElement("div");return B(a,s),B(a,t?n:o),this._isSelectElement&&e&&a.setAttribute("role","listbox"),a},placeholder:function(r,t){var e=r.allowHTML,i=r.classNames.placeholder,s=document.createElement("div");return B(s,i),Ne(s,e,t),s},item:function(r,t,e){var i=r.allowHTML,s=r.removeItemButtonAlignLeft,n=r.removeItemIconText,o=r.removeItemLabelText,a=r.classNames,l=a.item,c=a.button,h=a.highlightedState,d=a.itemSelectable,u=a.placeholder,p=Ai(t.value),g=document.createElement("div");if(B(g,l),t.labelClass){var f=document.createElement("span");Ne(f,i,t.label),B(f,t.labelClass),g.appendChild(f)}else Ne(g,i,t.label);if(g.dataset.item="",g.dataset.id=t.id,g.dataset.value=p,Pn(g,t,!0),(t.disabled||this.containerOuter.isDisabled)&&g.setAttribute("aria-disabled","true"),this._isSelectElement&&(g.setAttribute("aria-selected","true"),g.setAttribute("role","option")),t.placeholder&&(B(g,u),g.dataset.placeholder=""),B(g,t.highlighted?h:d),e){t.disabled&&Ie(g,d),g.dataset.deletable="";var m=document.createElement("button");m.type="button",B(m,c),Ne(m,!0,As(n,t.value));var b=As(o,t.value);b&&m.setAttribute("aria-label",b),m.dataset.button="",s?g.insertAdjacentElement("afterbegin",m):g.appendChild(m)}return g},choiceList:function(r,t){var e=r.classNames.list,i=document.createElement("div");return B(i,e),t||i.setAttribute("aria-multiselectable","true"),i.setAttribute("role","listbox"),i},choiceGroup:function(r,t){var e=r.allowHTML,i=r.classNames,s=i.group,n=i.groupHeading,o=i.itemDisabled,a=t.id,l=t.label,c=t.disabled,h=Ai(l),d=document.createElement("div");B(d,s),c&&B(d,o),d.setAttribute("role","group"),d.dataset.group="",d.dataset.id=a,d.dataset.value=h,c&&d.setAttribute("aria-disabled","true");var u=document.createElement("div");return B(u,n),Ne(u,e,l||""),d.appendChild(u),d},choice:function(r,t,e,i){var s=r.allowHTML,n=r.classNames,o=n.item,a=n.itemChoice,l=n.itemSelectable,c=n.selectedState,h=n.itemDisabled,d=n.description,u=n.placeholder,p=t.label,g=Ai(t.value),f=document.createElement("div");f.id=t.elementId,B(f,o),B(f,a),i&&typeof p=="string"&&(p=ko(s,p),p+=" (".concat(i,")"),p={trusted:p});var m=f;if(t.labelClass){var b=document.createElement("span");Ne(b,s,p),B(b,t.labelClass),m=b,f.appendChild(b)}else Ne(f,s,p);if(t.labelDescription){var _="".concat(t.elementId,"-description");m.setAttribute("aria-describedby",_);var w=document.createElement("span");Ne(w,s,t.labelDescription),w.id=_,B(w,d),f.appendChild(w)}return t.selected&&B(f,c),t.placeholder&&B(f,u),f.setAttribute("role",t.group?"treeitem":"option"),f.dataset.choice="",f.dataset.id=t.id,f.dataset.value=g,e&&(f.dataset.selectText=e),t.group&&(f.dataset.groupId="".concat(t.group.id)),Pn(f,t,!1),t.disabled?(B(f,h),f.dataset.choiceDisabled="",f.setAttribute("aria-disabled","true")):(B(f,l),f.dataset.choiceSelectable=""),f},input:function(r,t){var e=r.classNames,i=e.input,s=e.inputCloned,n=r.labelId,o=document.createElement("input");return o.type="search",B(o,i),B(o,s),o.autocomplete="off",o.autocapitalize="off",o.spellcheck=!1,o.setAttribute("aria-autocomplete","list"),t?o.setAttribute("aria-label",t):n||ja(this._docRoot,this.passedElement.element.id,o),o},dropdown:function(r){var t=r.classNames,e=t.list,i=t.listDropdown,s=document.createElement("div");return B(s,e),B(s,i),s.setAttribute("aria-expanded","false"),s},notice:function(r,t,e){var i=r.classNames,s=i.item,n=i.itemChoice,o=i.addChoice,a=i.noResults,l=i.noChoices,c=i.notice;e===void 0&&(e=$t.generic);var h=document.createElement("div");switch(Ne(h,!0,t),B(h,s),B(h,n),B(h,c),e){case $t.addChoice:B(h,o);break;case $t.noResults:B(h,a);break;case $t.noChoices:B(h,l);break}return e===$t.addChoice&&(h.dataset.choiceSelectable="",h.dataset.choice=""),h},option:function(r){var t=Ai(r.label),e=new Option(t,r.value,!1,r.selected);return Pn(e,r,!0),e.disabled=r.disabled,r.selected&&e.setAttribute("selected",""),e}},pp="-ms-scroll-limit"in document.documentElement.style&&"-ms-ime-align"in document.documentElement.style,gp={},An=function(r){if(r)return r.dataset.id?parseInt(r.dataset.id,10):void 0},bs="[data-choice-selectable]",nc=(function(){function r(t,e){t===void 0&&(t="[data-choice]"),e===void 0&&(e={});var i=this;this.initialisedOK=void 0,this._hasNonChoicePlaceholder=!1,this._lastAddedChoiceId=0,this._lastAddedGroupId=0;var s=r.defaults;this.config=Jt(Jt(Jt({},s.allOptions),s.options),e),Yd.forEach(function(b){i.config[b]=Jt(Jt(Jt({},s.allOptions[b]),s.options[b]),e[b])});var n=this.config;n.silent||this._validateConfig();var o=n.shadowRoot||document.documentElement;this._docRoot=o;var a=typeof t=="string"?o.querySelector(t):t;if(!a||typeof a!="object"||!(uu(a)||Kl(a)))throw TypeError(!a&&typeof t=="string"?"Selector ".concat(t," failed to find an element"):"Expected one of the following types text|select-one|select-multiple");var l=a.type,c=l===di.Text;(c||n.maxItemCount!==1)&&(n.singleModeForMultiSelect=!1),n.singleModeForMultiSelect&&(l=di.SelectMultiple);var h=l===di.SelectOne,d=l===di.SelectMultiple,u=h||d;if(this._elementType=l,this._isTextElement=c,this._isSelectOneElement=h,this._isSelectMultipleElement=d,this._isSelectElement=h||d,this._canAddUserChoices=c&&n.addItems||u&&n.addChoices,typeof n.renderSelectedChoices!="boolean"&&(n.renderSelectedChoices=n.renderSelectedChoices==="always"||h),n.closeDropdownOnSelect==="auto"?n.closeDropdownOnSelect=c||h||n.singleModeForMultiSelect:n.closeDropdownOnSelect=Ss(n.closeDropdownOnSelect),n.placeholder&&(n.placeholderValue?this._hasNonChoicePlaceholder=!0:a.dataset.placeholder&&(this._hasNonChoicePlaceholder=!0,n.placeholderValue=a.dataset.placeholder)),e.addItemFilter&&typeof e.addItemFilter!="function"){var p=e.addItemFilter instanceof RegExp?e.addItemFilter:new RegExp(e.addItemFilter);n.addItemFilter=p.test.bind(p)}if(this._isTextElement)this.passedElement=new du({element:a,classNames:n.classNames});else{var g=a;this.passedElement=new fu({element:g,classNames:n.classNames,template:function(b){return i._templates.option(b)},extractPlaceholder:n.placeholder&&!this._hasNonChoicePlaceholder})}if(this.initialised=!1,this._store=new _u(n),this._currentValue="",n.searchEnabled=!c&&n.searchEnabled||d,this._canSearch=n.searchEnabled,this._isScrollingOnIe=!1,this._highlightPosition=0,this._wasTap=!0,this._placeholderValue=this._generatePlaceholderValue(),this._baseId=Jd(a,"choices-"),this._direction=a.dir,!this._direction){var f=window.getComputedStyle(a).direction,m=window.getComputedStyle(document.documentElement).direction;f!==m&&(this._direction=f)}if(this._idNames={itemChoice:"item-choice"},this._templates=s.templates,this._render=this._render.bind(this),this._onFocus=this._onFocus.bind(this),this._onBlur=this._onBlur.bind(this),this._onKeyUp=this._onKeyUp.bind(this),this._onKeyDown=this._onKeyDown.bind(this),this._onInput=this._onInput.bind(this),this._onClick=this._onClick.bind(this),this._onTouchMove=this._onTouchMove.bind(this),this._onTouchEnd=this._onTouchEnd.bind(this),this._onMouseDown=this._onMouseDown.bind(this),this._onMouseOver=this._onMouseOver.bind(this),this._onFormReset=this._onFormReset.bind(this),this._onSelectKey=this._onSelectKey.bind(this),this._onEnterKey=this._onEnterKey.bind(this),this._onEscapeKey=this._onEscapeKey.bind(this),this._onDirectionKey=this._onDirectionKey.bind(this),this._onDeleteKey=this._onDeleteKey.bind(this),this.passedElement.isActive){n.silent||console.warn("Trying to initialise Choices on element already initialised",{element:t}),this.initialised=!0,this.initialisedOK=!1;return}this.init(),this._initialItems=this._store.items.map(function(b){return b.value})}return Object.defineProperty(r,"defaults",{get:function(){return Object.preventExtensions({get options(){return gp},get allOptions(){return Oa},get templates(){return up}})},enumerable:!1,configurable:!0}),r.prototype.init=function(){if(!(this.initialised||this.initialisedOK!==void 0)){this._searcher=hp(this.config),this._loadChoices(),this._createTemplates(),this._createElements(),this._createStructure(),this._isTextElement&&!this.config.addItems||this.passedElement.element.hasAttribute("disabled")||this.passedElement.element.closest("fieldset:disabled")?this.disable():(this.enable(),this._addEventListeners()),this._initStore(),this.initialised=!0,this.initialisedOK=!0;var t=this.config.callbackOnInit;typeof t=="function"&&t.call(this)}},r.prototype.destroy=function(){this.initialised&&(this._removeEventListeners(),this.passedElement.reveal(),this.containerOuter.unwrap(this.passedElement.element),this._store._listeners=[],this.clearStore(!1),this._stopSearch(),this._templates=r.defaults.templates,this.initialised=!1,this.initialisedOK=void 0)},r.prototype.enable=function(){return this.passedElement.isDisabled&&this.passedElement.enable(),this.containerOuter.isDisabled&&(this._addEventListeners(),this.input.enable(),this.containerOuter.enable()),this},r.prototype.disable=function(){return this.passedElement.isDisabled||this.passedElement.disable(),this.containerOuter.isDisabled||(this._removeEventListeners(),this.input.disable(),this.containerOuter.disable()),this},r.prototype.highlightItem=function(t,e){if(e===void 0&&(e=!0),!t||!t.id)return this;var i=this._store.items.find(function(s){return s.id===t.id});return!i||i.highlighted?this:(this._store.dispatch(ir(i,!0)),e&&this.passedElement.triggerEvent(Zt.highlightItem,this._getChoiceForOutput(i)),this)},r.prototype.unhighlightItem=function(t,e){if(e===void 0&&(e=!0),!t||!t.id)return this;var i=this._store.items.find(function(s){return s.id===t.id});return!i||!i.highlighted?this:(this._store.dispatch(ir(i,!1)),e&&this.passedElement.triggerEvent(Zt.unhighlightItem,this._getChoiceForOutput(i)),this)},r.prototype.highlightAll=function(){var t=this;return this._store.withTxn(function(){t._store.items.forEach(function(e){e.highlighted||(t._store.dispatch(ir(e,!0)),t.passedElement.triggerEvent(Zt.highlightItem,t._getChoiceForOutput(e)))})}),this},r.prototype.unhighlightAll=function(){var t=this;return this._store.withTxn(function(){t._store.items.forEach(function(e){e.highlighted&&(t._store.dispatch(ir(e,!1)),t.passedElement.triggerEvent(Zt.highlightItem,t._getChoiceForOutput(e)))})}),this},r.prototype.removeActiveItemsByValue=function(t){var e=this;return this._store.withTxn(function(){e._store.items.filter(function(i){return i.value===t}).forEach(function(i){return e._removeItem(i)})}),this},r.prototype.removeActiveItems=function(t){var e=this;return this._store.withTxn(function(){e._store.items.filter(function(i){var s=i.id;return s!==t}).forEach(function(i){return e._removeItem(i)})}),this},r.prototype.removeHighlightedItems=function(t){var e=this;return t===void 0&&(t=!1),this._store.withTxn(function(){e._store.highlightedActiveItems.forEach(function(i){e._removeItem(i),t&&e._triggerChange(i.value)})}),this},r.prototype.showDropdown=function(t){var e=this;return this.dropdown.isActive?this:(t===void 0&&(t=!this._canSearch),requestAnimationFrame(function(){e.dropdown.show();var i=e.dropdown.element.getBoundingClientRect();e.containerOuter.open(i.bottom,i.height),t||e.input.focus(),e.passedElement.triggerEvent(Zt.showDropdown)}),this)},r.prototype.hideDropdown=function(t){var e=this;return this.dropdown.isActive?(requestAnimationFrame(function(){e.dropdown.hide(),e.containerOuter.close(),!t&&e._canSearch&&(e.input.removeActiveDescendant(),e.input.blur()),e.passedElement.triggerEvent(Zt.hideDropdown)}),this):this},r.prototype.getValue=function(t){var e=this,i=this._store.items.map(function(s){return t?s.value:e._getChoiceForOutput(s)});return this._isSelectOneElement||this.config.singleModeForMultiSelect?i[0]:i},r.prototype.setValue=function(t){var e=this;return this.initialisedOK?(this._store.withTxn(function(){t.forEach(function(i){i&&e._addChoice(Me(i,!1))})}),this._searcher.reset(),this):(this._warnChoicesInitFailed("setValue"),this)},r.prototype.setChoiceByValue=function(t){var e=this;return this.initialisedOK?this._isTextElement?this:(this._store.withTxn(function(){var i=Array.isArray(t)?t:[t];i.forEach(function(s){return e._findAndSelectChoiceByValue(s)}),e.unhighlightAll()}),this._searcher.reset(),this):(this._warnChoicesInitFailed("setChoiceByValue"),this)},r.prototype.setChoices=function(t,e,i,s,n,o){var a=this;if(t===void 0&&(t=[]),e===void 0&&(e="value"),i===void 0&&(i="label"),s===void 0&&(s=!1),n===void 0&&(n=!0),o===void 0&&(o=!1),!this.initialisedOK)return this._warnChoicesInitFailed("setChoices"),this;if(!this._isSelectElement)throw new TypeError("setChoices can't be used with INPUT based Choices");if(typeof e!="string"||!e)throw new TypeError("value parameter must be a name of 'value' field in passed objects");if(typeof t=="function"){var l=t(this);if(typeof Promise=="function"&&l instanceof Promise)return new Promise(function(c){return requestAnimationFrame(c)}).then(function(){return a._handleLoadingState(!0)}).then(function(){return l}).then(function(c){return a.setChoices(c,e,i,s,n,o)}).catch(function(c){a.config.silent||console.error(c)}).then(function(){return a._handleLoadingState(!1)}).then(function(){return a});if(!Array.isArray(l))throw new TypeError(".setChoices first argument function must return either array of choices or Promise, got: ".concat(typeof l));return this.setChoices(l,e,i,!1)}if(!Array.isArray(t))throw new TypeError(".setChoices must be called either with array of choices with a function resulting into Promise of array of choices");return this.containerOuter.removeLoadingState(),this._store.withTxn(function(){n&&(a._isSearching=!1),s&&a.clearChoices(!0,o);var c=e==="value",h=i==="label";t.forEach(function(d){if("choices"in d){var u=d;h||(u=Jt(Jt({},u),{label:u[i]})),a._addGroup(Me(u,!0))}else{var p=d;(!h||!c)&&(p=Jt(Jt({},p),{value:p[e],label:p[i]}));var g=Me(p,!1);a._addChoice(g),g.placeholder&&!a._hasNonChoicePlaceholder&&(a._placeholderValue=Yl(g.label))}}),a.unhighlightAll()}),this._searcher.reset(),this},r.prototype.refresh=function(t,e,i){var s=this;return t===void 0&&(t=!1),e===void 0&&(e=!1),i===void 0&&(i=!1),this._isSelectElement?(this._store.withTxn(function(){var n=s.passedElement.optionsAsChoices(),o={};i||s._store.items.forEach(function(l){l.id&&l.active&&l.selected&&(o[l.value]=!0)}),s.clearStore(!1);var a=function(l){i?s._store.dispatch(wa(l)):o[l.value]&&(l.selected=!0)};n.forEach(function(l){if("choices"in l){l.choices.forEach(a);return}a(l)}),s._addPredefinedChoices(n,e,t),s._isSearching&&s._searchChoices(s.input.value)}),this):(this.config.silent||console.warn("refresh method can only be used on choices backed by a <select> element"),this)},r.prototype.removeChoice=function(t){var e=this._store.choices.find(function(i){return i.value===t});return e?(this._clearNotice(),this._store.dispatch(Gd(e)),this._searcher.reset(),e.selected&&this.passedElement.triggerEvent(Zt.removeItem,this._getChoiceForOutput(e)),this):this},r.prototype.clearChoices=function(t,e){var i=this;return t===void 0&&(t=!0),e===void 0&&(e=!1),t&&(e?this.passedElement.element.replaceChildren(""):this.passedElement.element.querySelectorAll(":not([selected])").forEach(function(s){s.remove()})),this.itemList.element.replaceChildren(""),this.choiceList.element.replaceChildren(""),this._clearNotice(),this._store.withTxn(function(){var s=e?[]:i._store.items;i._store.reset(),s.forEach(function(n){i._store.dispatch(_a(n)),i._store.dispatch(xa(n))})}),this._searcher.reset(),this},r.prototype.clearStore=function(t){return t===void 0&&(t=!0),this.clearChoices(t,!0),this._stopSearch(),this._lastAddedChoiceId=0,this._lastAddedGroupId=0,this},r.prototype.clearInput=function(){var t=!this._isSelectOneElement;return this.input.clear(t),this._stopSearch(),this},r.prototype._validateConfig=function(){var t=this.config,e=nu(t,Oa);e.length&&console.warn("Unknown config option(s) passed",e.join(", ")),t.allowHTML&&t.allowHtmlUserInput&&(t.addItems&&console.warn("Warning: allowHTML/allowHtmlUserInput/addItems all being true is strongly not recommended and may lead to XSS attacks"),t.addChoices&&console.warn("Warning: allowHTML/allowHtmlUserInput/addChoices all being true is strongly not recommended and may lead to XSS attacks"))},r.prototype._render=function(t){t===void 0&&(t={choices:!0,groups:!0,items:!0}),!this._store.inTxn()&&(this._isSelectElement&&(t.choices||t.groups)&&this._renderChoices(),t.items&&this._renderItems())},r.prototype._renderChoices=function(){var t=this;if(this._canAddItems()){var e=this,i=e.config,s=e._isSearching,n=this._store,o=n.activeGroups,a=n.activeChoices,l=0;if(s&&i.searchResultLimit>0?l=i.searchResultLimit:i.renderChoiceLimit>0&&(l=i.renderChoiceLimit),this._isSelectElement){var c=a.filter(function(g){return!g.element});c.length&&this.passedElement.addOptions(c)}var h=document.createDocumentFragment(),d=function(g){return g.filter(function(f){return!f.placeholder&&(s?!!f.rank:i.renderSelectedChoices||!f.selected)})},u=!1,p=function(g,f,m){s?g.sort(su):i.shouldSort&&g.sort(i.sorter);var b=g.length;b=!f&&l&&b>l?l:b,b--,g.every(function(_,w){var S=_.choiceEl||t._templates.choice(i,_,i.itemSelectText,m);return _.choiceEl=S,h.appendChild(S),(s||!_.selected)&&(u=!0),w<b})};a.length&&(i.resetScrollPosition&&requestAnimationFrame(function(){return t.choiceList.scrollToTop()}),!this._hasNonChoicePlaceholder&&!s&&this._isSelectOneElement&&p(a.filter(function(g){return g.placeholder&&!g.group}),!1,void 0),o.length&&!s?(i.shouldSort&&o.sort(i.sorter),p(a.filter(function(g){return!g.placeholder&&!g.group}),!1,void 0),o.forEach(function(g){var f=d(g.choices);if(f.length){if(g.label){var m=g.groupEl||t._templates.choiceGroup(t.config,g);g.groupEl=m,m.remove(),h.appendChild(m)}p(f,!0,i.appendGroupInSearch&&s?g.label:void 0)}})):p(d(a),!1,void 0)),!u&&(s||!h.children.length||!i.renderSelectedChoices)&&(this._notice||(this._notice={text:Sa(s?i.noResultsText:i.noChoicesText),type:s?$t.noResults:$t.noChoices}),h.replaceChildren("")),this._renderNotice(h),this.choiceList.element.replaceChildren(h),u&&this._highlightChoice()}},r.prototype._renderItems=function(){var t=this,e=this._store.items||[],i=this.itemList.element,s=this.config,n=document.createDocumentFragment(),o=function(d){return i.querySelector('[data-item][data-id="'.concat(d.id,'"]'))},a=function(d){var u=d.itemEl;u&&u.parentElement||(u=o(d)||t._templates.item(s,d,s.removeItemButton),d.itemEl=u,n.appendChild(u))};e.forEach(a);var l=!!n.childNodes.length;if(this._isSelectOneElement){var c=i.children.length;if(l||c>1){var h=i.querySelector(ms(s.classNames.placeholder));h&&h.remove()}else!l&&!c&&this._placeholderValue&&(l=!0,a(Me({selected:!0,value:"",label:this._placeholderValue,placeholder:!0},!1)))}l&&(i.append(n),s.shouldSortItems&&!this._isSelectOneElement&&(e.sort(s.sorter),e.forEach(function(d){var u=o(d);u&&(u.remove(),n.append(u))}),i.append(n))),this._isTextElement&&(this.passedElement.value=e.map(function(d){var u=d.value;return u}).join(s.delimiter))},r.prototype._displayNotice=function(t,e,i){i===void 0&&(i=!0);var s=this._notice;if(s&&(s.type===e&&s.text===t||s.type===$t.addChoice&&(e===$t.noResults||e===$t.noChoices))){i&&this.showDropdown(!0);return}this._clearNotice(),this._notice=t?{text:t,type:e}:void 0,this._renderNotice(),i&&t&&this.showDropdown(!0)},r.prototype._clearNotice=function(){if(this._notice){var t=this.choiceList.element.querySelector(ms(this.config.classNames.notice));t&&t.remove(),this._notice=void 0}},r.prototype._renderNotice=function(t){var e=this._notice;if(e){var i=this._templates.notice(this.config,e.text,e.type);t?t.append(i):this.choiceList.prepend(i)}},r.prototype._getChoiceForOutput=function(t,e){return{id:t.id,highlighted:t.highlighted,labelClass:t.labelClass,labelDescription:t.labelDescription,customProperties:t.customProperties,disabled:t.disabled,active:t.active,label:t.label,placeholder:t.placeholder,value:t.value,groupValue:t.group?t.group.label:void 0,element:t.element,keyCode:e}},r.prototype._triggerChange=function(t){t!=null&&this.passedElement.triggerEvent(Zt.change,{value:t})},r.prototype._handleButtonAction=function(t){var e=this,i=this._store.items;if(!(!i.length||!this.config.removeItems||!this.config.removeItemButton)){var s=t&&An(t.parentElement),n=s&&i.find(function(o){return o.id===s});n&&this._store.withTxn(function(){if(e._removeItem(n),e._triggerChange(n.value),e._isSelectOneElement&&!e._hasNonChoicePlaceholder){var o=(e.config.shouldSort?e._store.choices.reverse():e._store.choices).find(function(a){return a.placeholder});o&&(e._addItem(o),e.unhighlightAll(),o.value&&e._triggerChange(o.value))}})}},r.prototype._handleItemAction=function(t,e){var i=this;e===void 0&&(e=!1);var s=this._store.items;if(!(!s.length||!this.config.removeItems||this._isSelectOneElement)){var n=An(t);n&&(s.forEach(function(o){o.id===n&&!o.highlighted?i.highlightItem(o):!e&&o.highlighted&&i.unhighlightItem(o)}),this.input.focus())}},r.prototype._handleChoiceAction=function(t){var e=this,i=An(t),s=i&&this._store.getChoiceById(i);if(!s||s.disabled)return!1;var n=this.dropdown.isActive;if(!s.selected){if(!this._canAddItems())return!0;this._store.withTxn(function(){e._addItem(s,!0,!0),e.clearInput(),e.unhighlightAll()}),this._triggerChange(s.value)}return n&&this.config.closeDropdownOnSelect&&(this.hideDropdown(!0),this.containerOuter.element.focus()),!0},r.prototype._handleBackspace=function(t){var e=this.config;if(!(!e.removeItems||!t.length)){var i=t[t.length-1],s=t.some(function(n){return n.highlighted});e.editItems&&!s&&i?(this.input.value=i.value,this.input.setWidth(),this._removeItem(i),this._triggerChange(i.value)):(s||this.highlightItem(i,!1),this.removeHighlightedItems(!0))}},r.prototype._loadChoices=function(){var t,e=this,i=this.config;if(this._isTextElement){if(this._presetChoices=i.items.map(function(o){return Me(o,!1)}),this.passedElement.value){var s=this.passedElement.value.split(i.delimiter).map(function(o){return Me(o,!1,e.config.allowHtmlUserInput)});this._presetChoices=this._presetChoices.concat(s)}this._presetChoices.forEach(function(o){o.selected=!0})}else if(this._isSelectElement){this._presetChoices=i.choices.map(function(o){return Me(o,!0)});var n=this.passedElement.optionsAsChoices();n&&(t=this._presetChoices).push.apply(t,n)}},r.prototype._handleLoadingState=function(t){t===void 0&&(t=!0);var e=this.itemList.element;t?(this.disable(),this.containerOuter.addLoadingState(),this._isSelectOneElement?e.replaceChildren(this._templates.placeholder(this.config,this.config.loadingText)):this.input.placeholder=this.config.loadingText):(this.enable(),this.containerOuter.removeLoadingState(),this._isSelectOneElement?(e.replaceChildren(""),this._render()):this.input.placeholder=this._placeholderValue||"")},r.prototype._handleSearch=function(t){if(this.input.isFocussed)if(t!==null&&typeof t<"u"&&t.length>=this.config.searchFloor){var e=this.config.searchChoices?this._searchChoices(t):0;e!==null&&this.passedElement.triggerEvent(Zt.search,{value:t,resultCount:e})}else this._store.choices.some(function(i){return!i.active})&&this._stopSearch()},r.prototype._canAddItems=function(){var t=this.config,e=t.maxItemCount,i=t.maxItemText;return!t.singleModeForMultiSelect&&e>0&&e<=this._store.items.length?(this.choiceList.element.replaceChildren(""),this._notice=void 0,this._displayNotice(typeof i=="function"?i(e):i,$t.addChoice),!1):(this._notice&&this._notice.type===$t.addChoice&&this._clearNotice(),!0)},r.prototype._canCreateItem=function(t){var e=this.config,i=!0,s="";if(i&&typeof e.addItemFilter=="function"&&!e.addItemFilter(t)&&(i=!1,s=As(e.customAddItemText,t)),i){var n=this._store.choices.find(function(o){return e.valueComparer(o.value,t)});if(n){if(this._isSelectElement)return this._displayNotice("",$t.addChoice),!1;e.duplicateItemsAllowed||(i=!1,s=As(e.uniqueItemText,t))}}return i&&(s=As(e.addItemText,t)),s&&this._displayNotice(s,$t.addChoice),i},r.prototype._searchChoices=function(t){var e=t.trim().replace(/\s{2,}/," ");if(!e.length||e===this._currentValue)return null;var i=this._searcher;i.isEmptyIndex()&&i.index(this._store.searchableChoices);var s=i.search(e);this._currentValue=e,this._highlightPosition=0,this._isSearching=!0;var n=this._notice,o=n&&n.type;return o!==$t.addChoice&&(s.length?this._clearNotice():this._displayNotice(Sa(this.config.noResultsText),$t.noResults)),this._store.dispatch(Xd(s)),s.length},r.prototype._stopSearch=function(){this._isSearching&&(this._currentValue="",this._isSearching=!1,this._clearNotice(),this._store.dispatch(Kd(!0)),this.passedElement.triggerEvent(Zt.search,{value:"",resultCount:0}))},r.prototype._addEventListeners=function(){var t=this._docRoot,e=this.containerOuter.element,i=this.input.element;t.addEventListener("touchend",this._onTouchEnd,!0),e.addEventListener("keydown",this._onKeyDown,!0),e.addEventListener("mousedown",this._onMouseDown,!0),t.addEventListener("click",this._onClick,{passive:!0}),t.addEventListener("touchmove",this._onTouchMove,{passive:!0}),this.dropdown.element.addEventListener("mouseover",this._onMouseOver,{passive:!0}),this._isSelectOneElement&&(e.addEventListener("focus",this._onFocus,{passive:!0}),e.addEventListener("blur",this._onBlur,{passive:!0})),i.addEventListener("keyup",this._onKeyUp,{passive:!0}),i.addEventListener("input",this._onInput,{passive:!0}),i.addEventListener("focus",this._onFocus,{passive:!0}),i.addEventListener("blur",this._onBlur,{passive:!0}),i.form&&i.form.addEventListener("reset",this._onFormReset,{passive:!0}),this.input.addEventListeners()},r.prototype._removeEventListeners=function(){var t=this._docRoot,e=this.containerOuter.element,i=this.input.element;t.removeEventListener("touchend",this._onTouchEnd,!0),e.removeEventListener("keydown",this._onKeyDown,!0),e.removeEventListener("mousedown",this._onMouseDown,!0),t.removeEventListener("click",this._onClick),t.removeEventListener("touchmove",this._onTouchMove),this.dropdown.element.removeEventListener("mouseover",this._onMouseOver),this._isSelectOneElement&&(e.removeEventListener("focus",this._onFocus),e.removeEventListener("blur",this._onBlur)),i.removeEventListener("keyup",this._onKeyUp),i.removeEventListener("input",this._onInput),i.removeEventListener("focus",this._onFocus),i.removeEventListener("blur",this._onBlur),i.form&&i.form.removeEventListener("reset",this._onFormReset),this.input.removeEventListeners()},r.prototype._onKeyDown=function(t){var e=t.keyCode,i=this.dropdown.isActive,s=t.key.length===1||t.key.length===2&&t.key.charCodeAt(0)>=55296||t.key==="Unidentified";switch(!this._isTextElement&&!i&&e!==Ht.ESC_KEY&&e!==Ht.TAB_KEY&&e!==Ht.SHIFT_KEY&&(this.showDropdown(),!this.input.isFocussed&&s&&(this.input.value+=t.key,t.key===" "&&t.preventDefault())),e){case Ht.A_KEY:return this._onSelectKey(t,this.itemList.element.hasChildNodes());case Ht.ENTER_KEY:return this._onEnterKey(t,i);case Ht.ESC_KEY:return this._onEscapeKey(t,i);case Ht.UP_KEY:case Ht.PAGE_UP_KEY:case Ht.DOWN_KEY:case Ht.PAGE_DOWN_KEY:return this._onDirectionKey(t,i);case Ht.DELETE_KEY:case Ht.BACK_KEY:return this._onDeleteKey(t,this._store.items,this.input.isFocussed)}},r.prototype._onKeyUp=function(){this._canSearch=this.config.searchEnabled},r.prototype._onInput=function(){var t=this.input.value;if(!t){this._isTextElement?this.hideDropdown(!0):this._stopSearch();return}this._canAddItems()&&(this._canSearch&&this._handleSearch(t),this._canAddUserChoices&&(this._canCreateItem(t),this._isSelectElement&&(this._highlightPosition=0,this._highlightChoice())))},r.prototype._onSelectKey=function(t,e){if((t.ctrlKey||t.metaKey)&&e){this._canSearch=!1;var i=this.config.removeItems&&!this.input.value&&this.input.element===document.activeElement;i&&this.highlightAll()}},r.prototype._onEnterKey=function(t,e){var i=this,s=this.input.value,n=t.target;if(t.preventDefault(),n&&n.hasAttribute("data-button")){this._handleButtonAction(n);return}if(!e){(this._isSelectElement||this._notice)&&this.showDropdown();return}var o=this.dropdown.element.querySelector(ms(this.config.classNames.highlightedState));if(!(o&&this._handleChoiceAction(o))){if(!n||!s){this.hideDropdown(!0);return}if(this._canAddItems()){var a=!1;this._store.withTxn(function(){if(a=i._findAndSelectChoiceByValue(s,!0),!a){if(!i._canAddUserChoices||!i._canCreateItem(s))return;i._addChoice(Me(s,!1,i.config.allowHtmlUserInput),!0,!0),a=!0}i.clearInput(),i.unhighlightAll()}),a&&(this._triggerChange(s),this.config.closeDropdownOnSelect&&this.hideDropdown(!0))}}},r.prototype._onEscapeKey=function(t,e){e&&(t.stopPropagation(),this.hideDropdown(!0),this._stopSearch(),this.containerOuter.element.focus())},r.prototype._onDirectionKey=function(t,e){var i=t.keyCode;if(e||this._isSelectOneElement){this.showDropdown(),this._canSearch=!1;var s=i===Ht.DOWN_KEY||i===Ht.PAGE_DOWN_KEY?1:-1,n=t.metaKey||i===Ht.PAGE_DOWN_KEY||i===Ht.PAGE_UP_KEY,o=void 0;if(n)s>0?o=this.dropdown.element.querySelector("".concat(bs,":last-of-type")):o=this.dropdown.element.querySelector(bs);else{var a=this.dropdown.element.querySelector(ms(this.config.classNames.highlightedState));a?o=Qd(a,bs,s):o=this.dropdown.element.querySelector(bs)}o&&(tu(o,this.choiceList.element,s)||this.choiceList.scrollToChildElement(o,s),this._highlightChoice(o)),t.preventDefault()}},r.prototype._onDeleteKey=function(t,e,i){!this._isSelectOneElement&&!t.target.value&&i&&(this._handleBackspace(e),t.preventDefault())},r.prototype._onTouchMove=function(){this._wasTap&&(this._wasTap=!1)},r.prototype._onTouchEnd=function(t){var e=(t||t.touches[0]).target,i=this._wasTap&&this.containerOuter.element.contains(e);if(i){var s=e===this.containerOuter.element||e===this.containerInner.element;s&&(this._isTextElement?this.input.focus():this._isSelectMultipleElement&&this.showDropdown()),t.stopPropagation()}this._wasTap=!0},r.prototype._onMouseDown=function(t){var e=t.target;if(e instanceof HTMLElement){if(pp&&this.choiceList.element.contains(e)){var i=this.choiceList.element.firstElementChild;this._isScrollingOnIe=this._direction==="ltr"?t.offsetX>=i.offsetWidth:t.offsetX<i.offsetLeft}if(e!==this.input.element){var s=e.closest("[data-button],[data-item],[data-choice]");s instanceof HTMLElement&&("button"in s.dataset?this._handleButtonAction(s):"item"in s.dataset?this._handleItemAction(s,t.shiftKey):"choice"in s.dataset&&this._handleChoiceAction(s)),t.preventDefault()}}},r.prototype._onMouseOver=function(t){var e=t.target;e instanceof HTMLElement&&"choice"in e.dataset&&this._highlightChoice(e)},r.prototype._onClick=function(t){var e=t.target,i=this.containerOuter,s=i.element.contains(e);s?!this.dropdown.isActive&&!i.isDisabled?this._isTextElement?document.activeElement!==this.input.element&&this.input.focus():(this.showDropdown(),i.element.focus()):this._isSelectOneElement&&e!==this.input.element&&!this.dropdown.element.contains(e)&&this.hideDropdown():(i.removeFocusState(),this.hideDropdown(!0),this.unhighlightAll())},r.prototype._onFocus=function(t){var e=t.target,i=this.containerOuter,s=e&&i.element.contains(e);if(s){var n=e===this.input.element;this._isTextElement?n&&i.addFocusState():this._isSelectMultipleElement?n&&(this.showDropdown(!0),i.addFocusState()):(i.addFocusState(),n&&this.showDropdown(!0))}},r.prototype._onBlur=function(t){var e=t.target,i=this.containerOuter,s=e&&i.element.contains(e);s&&!this._isScrollingOnIe?e===this.input.element?(i.removeFocusState(),this.hideDropdown(!0),(this._isTextElement||this._isSelectMultipleElement)&&this.unhighlightAll()):e===this.containerOuter.element&&(i.removeFocusState(),this._canSearch||this.hideDropdown(!0)):(this._isScrollingOnIe=!1,this.input.element.focus())},r.prototype._onFormReset=function(){var t=this;this._store.withTxn(function(){t.clearInput(),t.hideDropdown(),t.refresh(!1,!1,!0),t._initialItems.length&&t.setChoiceByValue(t._initialItems)})},r.prototype._highlightChoice=function(t){t===void 0&&(t=null);var e=Array.from(this.dropdown.element.querySelectorAll(bs));if(e.length){var i=t,s=this.config.classNames.highlightedState,n=Array.from(this.dropdown.element.querySelectorAll(ms(s)));n.forEach(function(o){Ie(o,s),o.setAttribute("aria-selected","false")}),i?this._highlightPosition=e.indexOf(i):(e.length>this._highlightPosition?i=e[this._highlightPosition]:i=e[e.length-1],i||(i=e[0])),B(i,s),i.setAttribute("aria-selected","true"),this.passedElement.triggerEvent(Zt.highlightChoice,{el:i}),this.dropdown.isActive&&(this.input.setActiveDescendant(i.id),this.containerOuter.setActiveDescendant(i.id))}},r.prototype._addItem=function(t,e,i){if(e===void 0&&(e=!0),i===void 0&&(i=!1),!t.id)throw new TypeError("item.id must be set before _addItem is called for a choice/item");(this.config.singleModeForMultiSelect||this._isSelectOneElement)&&this.removeActiveItems(t.id),this._store.dispatch(xa(t)),e&&(this.passedElement.triggerEvent(Zt.addItem,this._getChoiceForOutput(t)),i&&this.passedElement.triggerEvent(Zt.choice,this._getChoiceForOutput(t)))},r.prototype._removeItem=function(t){if(t.id){this._store.dispatch(wa(t));var e=this._notice;e&&e.type===$t.noChoices&&this._clearNotice(),this.passedElement.triggerEvent(Zt.removeItem,this._getChoiceForOutput(t))}},r.prototype._addChoice=function(t,e,i){if(e===void 0&&(e=!0),i===void 0&&(i=!1),t.id)throw new TypeError("Can not re-add a choice which has already been added");var s=this.config;if(!(!s.duplicateItemsAllowed&&this._store.choices.find(function(a){return s.valueComparer(a.value,t.value)}))){this._lastAddedChoiceId++,t.id=this._lastAddedChoiceId,t.elementId="".concat(this._baseId,"-").concat(this._idNames.itemChoice,"-").concat(t.id);var n=s.prependValue,o=s.appendValue;n&&(t.value=n+t.value),o&&(t.value+=o.toString()),(n||o)&&t.element&&(t.element.value=t.value),this._clearNotice(),this._store.dispatch(_a(t)),t.selected&&this._addItem(t,e,i)}},r.prototype._addGroup=function(t,e){var i=this;if(e===void 0&&(e=!0),t.id)throw new TypeError("Can not re-add a group which has already been added");this._store.dispatch(qd(t)),t.choices&&(this._lastAddedGroupId++,t.id=this._lastAddedGroupId,t.choices.forEach(function(s){s.group=t,t.disabled&&(s.disabled=!0),i._addChoice(s,e)}))},r.prototype._createTemplates=function(){var t=this,e=this.config.callbackOnCreateTemplates,i={};typeof e=="function"&&(i=e.call(this,eu,ko,nn));var s={};Object.keys(this._templates).forEach(function(n){n in i?s[n]=i[n].bind(t):s[n]=t._templates[n].bind(t)}),this._templates=s},r.prototype._createElements=function(){var t=this._templates,e=this,i=e.config,s=e._isSelectOneElement,n=i.position,o=i.classNames,a=this._elementType;this.containerOuter=new Ta({element:t.containerOuter(i,this._direction,this._isSelectElement,s,i.searchEnabled,a,i.labelId),classNames:o,type:a,position:n}),this.containerInner=new Ta({element:t.containerInner(i),classNames:o,type:a,position:n}),this.input=new cu({element:t.input(i,this._placeholderValue),classNames:o,type:a,preventPaste:!i.paste}),this.choiceList=new Ea({element:t.choiceList(i,s)}),this.itemList=new Ea({element:t.itemList(i,s)}),this.dropdown=new lu({element:t.dropdown(i),classNames:o,type:a})},r.prototype._createStructure=function(){var t=this,e=t.containerInner,i=t.containerOuter,s=t.passedElement,n=this.dropdown.element;s.conceal(),e.wrap(s.element),i.wrap(e.element),this._isSelectOneElement?this.input.placeholder=this.config.searchPlaceholderValue||"":(this._placeholderValue&&(this.input.placeholder=this._placeholderValue),this.input.setWidth()),i.element.appendChild(e.element),i.element.appendChild(n),e.element.appendChild(this.itemList.element),n.appendChild(this.choiceList.element),this._isSelectOneElement?this.config.searchEnabled&&n.insertBefore(this.input.element,n.firstChild):e.element.appendChild(this.input.element),this._highlightPosition=0,this._isSearching=!1},r.prototype._initStore=function(){var t=this;this._store.subscribe(this._render).withTxn(function(){t._addPredefinedChoices(t._presetChoices,t._isSelectOneElement&&!t._hasNonChoicePlaceholder,!1)}),(!this._store.choices.length||this._isSelectOneElement&&this._hasNonChoicePlaceholder)&&this._render()},r.prototype._addPredefinedChoices=function(t,e,i){var s=this;if(e===void 0&&(e=!1),i===void 0&&(i=!0),e){var n=t.findIndex(function(o){return o.selected})===-1;n&&t.some(function(o){return o.disabled||"choices"in o?!1:(o.selected=!0,!0)})}t.forEach(function(o){"choices"in o?s._isSelectElement&&s._addGroup(o,i):s._addChoice(o,i)})},r.prototype._findAndSelectChoiceByValue=function(t,e){var i=this;e===void 0&&(e=!1);var s=this._store.choices.find(function(n){return i.config.valueComparer(n.value,t)});return s&&!s.disabled&&!s.selected?(this._addItem(s,!0,e),!0):!1},r.prototype._generatePlaceholderValue=function(){var t=this.config;if(!t.placeholder)return null;if(this._hasNonChoicePlaceholder)return t.placeholderValue;if(this._isSelectElement){var e=this.passedElement.placeholderOption;return e?e.text:null}return null},r.prototype._warnChoicesInitFailed=function(t){if(!this.config.silent)if(this.initialised){if(!this.initialisedOK)throw new TypeError("".concat(t," called for an element which has multiple instances of Choices initialised on it"))}else throw new TypeError("".concat(t," called on a non-initialised instance of Choices"))},r.version="11.1.0",r})();const oc='.choices{position:relative;overflow:hidden;margin-bottom:24px;font-size:16px}.choices:focus{outline:none}.choices:last-child{margin-bottom:0}.choices.is-open{overflow:visible}.choices.is-disabled .choices__inner,.choices.is-disabled .choices__input{background-color:#eaeaea;cursor:not-allowed;-webkit-user-select:none;user-select:none}.choices.is-disabled .choices__item{cursor:not-allowed}.choices [hidden]{display:none!important}.choices[data-type*=select-one]{cursor:pointer}.choices[data-type*=select-one] .choices__inner{padding-bottom:7.5px}.choices[data-type*=select-one] .choices__input{display:block;width:100%;padding:10px;border-bottom:1px solid #ddd;background-color:#fff;margin:0}.choices[data-type*=select-one] .choices__button{background-image:url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMjEiIGhlaWdodD0iMjEiIHZpZXdCb3g9IjAgMCAyMSAyMSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48ZyBmaWxsPSIjMDAwIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiPjxwYXRoIGQ9Ik0yLjU5Mi4wNDRsMTguMzY0IDE4LjM2NC0yLjU0OCAyLjU0OEwuMDQ0IDIuNTkyeiIvPjxwYXRoIGQ9Ik0wIDE4LjM2NEwxOC4zNjQgMGwyLjU0OCAyLjU0OEwyLjU0OCAyMC45MTJ6Ii8+PC9nPjwvc3ZnPg==);padding:0;background-size:8px;position:absolute;top:50%;right:0;margin-top:-10px;margin-right:25px;height:20px;width:20px;border-radius:10em;opacity:.25}.choices[data-type*=select-one] .choices__button:hover,.choices[data-type*=select-one] .choices__button:focus{opacity:1}.choices[data-type*=select-one] .choices__button:focus{box-shadow:0 0 0 2px #005f75}.choices[data-type*=select-one] .choices__item[data-placeholder] .choices__button{display:none}.choices[data-type*=select-one]:after{content:"";height:0;width:0;border-style:solid;border-color:#333 transparent transparent transparent;border-width:5px;position:absolute;right:11.5px;top:50%;margin-top:-2.5px;pointer-events:none}.choices[data-type*=select-one].is-open:after{border-color:transparent transparent #333;margin-top:-7.5px}.choices[data-type*=select-one][dir=rtl]:after{left:11.5px;right:auto}.choices[data-type*=select-one][dir=rtl] .choices__button{right:auto;left:0;margin-left:25px;margin-right:0}.choices[data-type*=select-multiple] .choices__inner,.choices[data-type*=text] .choices__inner{cursor:text}.choices[data-type*=select-multiple] .choices__button,.choices[data-type*=text] .choices__button{position:relative;display:inline-block;margin:0 -4px 0 8px;padding-left:16px;border-left:1px solid #003642;background-image:url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMjEiIGhlaWdodD0iMjEiIHZpZXdCb3g9IjAgMCAyMSAyMSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48ZyBmaWxsPSIjRkZGIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiPjxwYXRoIGQ9Ik0yLjU5Mi4wNDRsMTguMzY0IDE4LjM2NC0yLjU0OCAyLjU0OEwuMDQ0IDIuNTkyeiIvPjxwYXRoIGQ9Ik0wIDE4LjM2NEwxOC4zNjQgMGwyLjU0OCAyLjU0OEwyLjU0OCAyMC45MTJ6Ii8+PC9nPjwvc3ZnPg==);background-size:8px;width:8px;line-height:1;opacity:.75;border-radius:0}.choices[data-type*=select-multiple] .choices__button:hover,.choices[data-type*=select-multiple] .choices__button:focus,.choices[data-type*=text] .choices__button:hover,.choices[data-type*=text] .choices__button:focus{opacity:1}.choices__inner{display:inline-block;vertical-align:top;width:100%;background-color:#f9f9f9;padding:7.5px 7.5px 3.75px;border:1px solid #ddd;border-radius:2.5px;font-size:14px;min-height:44px;overflow:hidden}.is-focused .choices__inner,.is-open .choices__inner{border-color:#b7b7b7}.is-open .choices__inner{border-radius:2.5px 2.5px 0 0}.is-flipped.is-open .choices__inner{border-radius:0 0 2.5px 2.5px}.choices__list{margin:0;padding-left:0;list-style:none}.choices__list--single{display:inline-block;padding:4px 16px 4px 4px;width:100%}[dir=rtl] .choices__list--single{padding-right:4px;padding-left:16px}.choices__list--single .choices__item{width:100%}.choices__list--multiple{display:inline}.choices__list--multiple .choices__item{display:inline-block;vertical-align:middle;border-radius:20px;padding:4px 10px;font-size:12px;font-weight:500;margin-right:3.75px;margin-bottom:3.75px;background-color:#005f75;border:1px solid #004a5c;color:#fff;word-break:break-all;box-sizing:border-box}.choices__list--multiple .choices__item[data-deletable]{padding-right:5px}[dir=rtl] .choices__list--multiple .choices__item{margin-right:0;margin-left:3.75px}.choices__list--multiple .choices__item.is-highlighted{background-color:#004a5c;border:1px solid #003642}.is-disabled .choices__list--multiple .choices__item{background-color:#aaa;border:1px solid #919191}.choices__list--dropdown,.choices__list[aria-expanded]{display:none;z-index:1;position:absolute;width:100%;background-color:#fff;border:1px solid #ddd;top:100%;margin-top:-1px;border-bottom-left-radius:2.5px;border-bottom-right-radius:2.5px;overflow:hidden;word-break:break-all}.is-active.choices__list--dropdown,.is-active.choices__list[aria-expanded]{display:block}.is-open .choices__list--dropdown,.is-open .choices__list[aria-expanded]{border-color:#b7b7b7}.is-flipped .choices__list--dropdown,.is-flipped .choices__list[aria-expanded]{top:auto;bottom:100%;margin-top:0;margin-bottom:-1px;border-radius:.25rem .25rem 0 0}.choices__list--dropdown .choices__list,.choices__list[aria-expanded] .choices__list{position:relative;max-height:300px;overflow:auto;-webkit-overflow-scrolling:touch;will-change:scroll-position}.choices__list--dropdown .choices__item,.choices__list[aria-expanded] .choices__item{position:relative;padding:10px;font-size:14px}[dir=rtl] .choices__list--dropdown .choices__item,[dir=rtl] .choices__list[aria-expanded] .choices__item{text-align:right}@media(min-width:640px){.choices__list--dropdown .choices__item--selectable[data-select-text],.choices__list[aria-expanded] .choices__item--selectable[data-select-text]{padding-right:100px}.choices__list--dropdown .choices__item--selectable[data-select-text]:after,.choices__list[aria-expanded] .choices__item--selectable[data-select-text]:after{content:attr(data-select-text);font-size:12px;opacity:0;position:absolute;right:10px;top:50%;transform:translateY(-50%)}[dir=rtl] .choices__list--dropdown .choices__item--selectable[data-select-text],[dir=rtl] .choices__list[aria-expanded] .choices__item--selectable[data-select-text]{text-align:right;padding-left:100px;padding-right:10px}[dir=rtl] .choices__list--dropdown .choices__item--selectable[data-select-text]:after,[dir=rtl] .choices__list[aria-expanded] .choices__item--selectable[data-select-text]:after{right:auto;left:10px}}.choices__list--dropdown .choices__item--selectable.is-highlighted,.choices__list[aria-expanded] .choices__item--selectable.is-highlighted{background-color:#f2f2f2}.choices__list--dropdown .choices__item--selectable.is-highlighted:after,.choices__list[aria-expanded] .choices__item--selectable.is-highlighted:after{opacity:.5}.choices__item{cursor:default}.choices__item--selectable{cursor:pointer}.choices__item--disabled{cursor:not-allowed;-webkit-user-select:none;user-select:none;opacity:.5}.choices__heading{font-weight:600;font-size:12px;padding:10px;border-bottom:1px solid #f7f7f7;color:gray}.choices__button{text-indent:-9999px;-webkit-appearance:none;-moz-appearance:none;appearance:none;border:0;background-color:transparent;background-repeat:no-repeat;background-position:center;cursor:pointer}.choices__button:focus{outline:none}.choices__input{display:inline-block;vertical-align:baseline;background-color:#f9f9f9;font-size:14px;margin-bottom:5px;border:0;border-radius:0;max-width:100%;padding:4px 0 4px 2px}.choices__input:focus{outline:0}.choices__input::-webkit-search-decoration,.choices__input::-webkit-search-cancel-button,.choices__input::-webkit-search-results-button,.choices__input::-webkit-search-results-decoration{display:none}.choices__input::-ms-clear,.choices__input::-ms-reveal{display:none;width:0;height:0}[dir=rtl] .choices__input{padding-right:2px;padding-left:0}.choices__placeholder{opacity:.5}',Ks=ft`
|
|
1451
|
+
`;/*! choices.js v11.1.0 | © 2025 Josh Johnson | https://github.com/jshjohnson/Choices#readme */var qn=function(r,t){return qn=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,i){e.__proto__=i}||function(e,i){for(var s in i)Object.prototype.hasOwnProperty.call(i,s)&&(e[s]=i[s])},qn(r,t)};function Wl(r,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");qn(r,t);function e(){this.constructor=r}r.prototype=t===null?Object.create(t):(e.prototype=t.prototype,new e)}var Jt=function(){return Jt=Object.assign||function(t){for(var e,i=1,s=arguments.length;i<s;i++){e=arguments[i];for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])}return t},Jt.apply(this,arguments)};function Ud(r,t,e){for(var i=0,s=t.length,n;i<s;i++)(n||!(i in t))&&(n||(n=Array.prototype.slice.call(t,0,i)),n[i]=t[i]);return r.concat(n||Array.prototype.slice.call(t))}var vt={ADD_CHOICE:"ADD_CHOICE",REMOVE_CHOICE:"REMOVE_CHOICE",FILTER_CHOICES:"FILTER_CHOICES",ACTIVATE_CHOICES:"ACTIVATE_CHOICES",CLEAR_CHOICES:"CLEAR_CHOICES",ADD_GROUP:"ADD_GROUP",ADD_ITEM:"ADD_ITEM",REMOVE_ITEM:"REMOVE_ITEM",HIGHLIGHT_ITEM:"HIGHLIGHT_ITEM"},Zt={showDropdown:"showDropdown",hideDropdown:"hideDropdown",change:"change",choice:"choice",search:"search",addItem:"addItem",removeItem:"removeItem",highlightItem:"highlightItem",highlightChoice:"highlightChoice",unhighlightItem:"unhighlightItem"},zt={TAB_KEY:9,SHIFT_KEY:16,BACK_KEY:46,DELETE_KEY:8,ENTER_KEY:13,A_KEY:65,ESC_KEY:27,UP_KEY:38,DOWN_KEY:40,PAGE_UP_KEY:33,PAGE_DOWN_KEY:34},Wd=["fuseOptions","classNames"],di={Text:"text",SelectOne:"select-one",SelectMultiple:"select-multiple"},_a=function(r){return{type:vt.ADD_CHOICE,choice:r}},Yd=function(r){return{type:vt.REMOVE_CHOICE,choice:r}},Gd=function(r){return{type:vt.FILTER_CHOICES,results:r}},Xd=function(r){return{type:vt.ACTIVATE_CHOICES,active:r}},qd=function(r){return{type:vt.ADD_GROUP,group:r}},xa=function(r){return{type:vt.ADD_ITEM,item:r}},wa=function(r){return{type:vt.REMOVE_ITEM,item:r}},ir=function(r,t){return{type:vt.HIGHLIGHT_ITEM,item:r,highlighted:t}},Kd=function(r,t){return Math.floor(Math.random()*(t-r)+r)},Ca=function(r){return Array.from({length:r},function(){return Kd(0,36).toString(36)}).join("")},Zd=function(r,t){var e=r.id||r.name&&"".concat(r.name,"-").concat(Ca(2))||Ca(4);return e=e.replace(/(:|\.|\[|\]|,)/g,""),e="".concat(t,"-").concat(e),e},Jd=function(r,t,e){e===void 0&&(e=1);for(var i="".concat(e>0?"next":"previous","ElementSibling"),s=r[i];s;){if(s.matches(t))return s;s=s[i]}return null},Qd=function(r,t,e){e===void 0&&(e=1);var i;return e>0?i=t.scrollTop+t.offsetHeight>=r.offsetTop+r.offsetHeight:i=r.offsetTop>=t.scrollTop,i},rn=function(r){if(typeof r!="string"){if(r==null)return"";if(typeof r=="object"){if("raw"in r)return rn(r.raw);if("trusted"in r)return r.trusted}return r}return r.replace(/&/g,"&").replace(/>/g,">").replace(/</g,"<").replace(/'/g,"'").replace(/"/g,""")},tu=(function(){var r=document.createElement("div");return function(t){r.innerHTML=t.trim();for(var e=r.children[0];r.firstChild;)r.removeChild(r.firstChild);return e}})(),As=function(r,t){return typeof r=="function"?r(rn(t),t):r},Sa=function(r){return typeof r=="function"?r():r},Pi=function(r){if(typeof r=="string")return r;if(typeof r=="object"){if("trusted"in r)return r.trusted;if("raw"in r)return r.raw}return""},Yl=function(r){if(typeof r=="string")return r;if(typeof r=="object"){if("escaped"in r)return r.escaped;if("trusted"in r)return r.trusted}return""},ko=function(r,t){return r?Yl(t):rn(t)},Ne=function(r,t,e){r.innerHTML=ko(t,e)},eu=function(r,t){var e=r.value,i=r.label,s=i===void 0?e:i,n=t.value,o=t.label,a=o===void 0?n:o;return Pi(s).localeCompare(Pi(a),[],{sensitivity:"base",ignorePunctuation:!0,numeric:!0})},iu=function(r,t){return r.rank-t.rank},su=function(r,t,e){e===void 0&&(e=null);var i=new CustomEvent(t,{detail:e,bubbles:!0,cancelable:!0});return r.dispatchEvent(i)},ru=function(r,t){var e=Object.keys(r).sort(),i=Object.keys(t).sort();return e.filter(function(s){return i.indexOf(s)<0})},nn=function(r){return Array.isArray(r)?r:[r]},ms=function(r){return r&&Array.isArray(r)?r.map(function(t){return".".concat(t)}).join(""):".".concat(r)},B=function(r,t){var e;(e=r.classList).add.apply(e,nn(t))},Ie=function(r,t){var e;(e=r.classList).remove.apply(e,nn(t))},nu=function(r){if(typeof r<"u")try{return JSON.parse(r)}catch{return r}return{}},ou=function(r,t,e){var i=r.itemEl;i&&(Ie(i,e),B(i,t))},au=(function(){function r(t){var e=t.element,i=t.type,s=t.classNames;this.element=e,this.classNames=s,this.type=i,this.isActive=!1}return r.prototype.show=function(){return B(this.element,this.classNames.activeState),this.element.setAttribute("aria-expanded","true"),this.isActive=!0,this},r.prototype.hide=function(){return Ie(this.element,this.classNames.activeState),this.element.setAttribute("aria-expanded","false"),this.isActive=!1,this},r})(),Ta=(function(){function r(t){var e=t.element,i=t.type,s=t.classNames,n=t.position;this.element=e,this.classNames=s,this.type=i,this.position=n,this.isOpen=!1,this.isFlipped=!1,this.isDisabled=!1,this.isLoading=!1}return r.prototype.shouldFlip=function(t,e){var i=!1;return this.position==="auto"?i=this.element.getBoundingClientRect().top-e>=0&&!window.matchMedia("(min-height: ".concat(t+1,"px)")).matches:this.position==="top"&&(i=!0),i},r.prototype.setActiveDescendant=function(t){this.element.setAttribute("aria-activedescendant",t)},r.prototype.removeActiveDescendant=function(){this.element.removeAttribute("aria-activedescendant")},r.prototype.open=function(t,e){B(this.element,this.classNames.openState),this.element.setAttribute("aria-expanded","true"),this.isOpen=!0,this.shouldFlip(t,e)&&(B(this.element,this.classNames.flippedState),this.isFlipped=!0)},r.prototype.close=function(){Ie(this.element,this.classNames.openState),this.element.setAttribute("aria-expanded","false"),this.removeActiveDescendant(),this.isOpen=!1,this.isFlipped&&(Ie(this.element,this.classNames.flippedState),this.isFlipped=!1)},r.prototype.addFocusState=function(){B(this.element,this.classNames.focusState)},r.prototype.removeFocusState=function(){Ie(this.element,this.classNames.focusState)},r.prototype.enable=function(){Ie(this.element,this.classNames.disabledState),this.element.removeAttribute("aria-disabled"),this.type===di.SelectOne&&this.element.setAttribute("tabindex","0"),this.isDisabled=!1},r.prototype.disable=function(){B(this.element,this.classNames.disabledState),this.element.setAttribute("aria-disabled","true"),this.type===di.SelectOne&&this.element.setAttribute("tabindex","-1"),this.isDisabled=!0},r.prototype.wrap=function(t){var e=this.element,i=t.parentNode;i&&(t.nextSibling?i.insertBefore(e,t.nextSibling):i.appendChild(e)),e.appendChild(t)},r.prototype.unwrap=function(t){var e=this.element,i=e.parentNode;i&&(i.insertBefore(t,e),i.removeChild(e))},r.prototype.addLoadingState=function(){B(this.element,this.classNames.loadingState),this.element.setAttribute("aria-busy","true"),this.isLoading=!0},r.prototype.removeLoadingState=function(){Ie(this.element,this.classNames.loadingState),this.element.removeAttribute("aria-busy"),this.isLoading=!1},r})(),lu=(function(){function r(t){var e=t.element,i=t.type,s=t.classNames,n=t.preventPaste;this.element=e,this.type=i,this.classNames=s,this.preventPaste=n,this.isFocussed=this.element.isEqualNode(document.activeElement),this.isDisabled=e.disabled,this._onPaste=this._onPaste.bind(this),this._onInput=this._onInput.bind(this),this._onFocus=this._onFocus.bind(this),this._onBlur=this._onBlur.bind(this)}return Object.defineProperty(r.prototype,"placeholder",{set:function(t){this.element.placeholder=t},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"value",{get:function(){return this.element.value},set:function(t){this.element.value=t},enumerable:!1,configurable:!0}),r.prototype.addEventListeners=function(){var t=this.element;t.addEventListener("paste",this._onPaste),t.addEventListener("input",this._onInput,{passive:!0}),t.addEventListener("focus",this._onFocus,{passive:!0}),t.addEventListener("blur",this._onBlur,{passive:!0})},r.prototype.removeEventListeners=function(){var t=this.element;t.removeEventListener("input",this._onInput),t.removeEventListener("paste",this._onPaste),t.removeEventListener("focus",this._onFocus),t.removeEventListener("blur",this._onBlur)},r.prototype.enable=function(){var t=this.element;t.removeAttribute("disabled"),this.isDisabled=!1},r.prototype.disable=function(){var t=this.element;t.setAttribute("disabled",""),this.isDisabled=!0},r.prototype.focus=function(){this.isFocussed||this.element.focus()},r.prototype.blur=function(){this.isFocussed&&this.element.blur()},r.prototype.clear=function(t){return t===void 0&&(t=!0),this.element.value="",t&&this.setWidth(),this},r.prototype.setWidth=function(){var t=this.element;t.style.minWidth="".concat(t.placeholder.length+1,"ch"),t.style.width="".concat(t.value.length+1,"ch")},r.prototype.setActiveDescendant=function(t){this.element.setAttribute("aria-activedescendant",t)},r.prototype.removeActiveDescendant=function(){this.element.removeAttribute("aria-activedescendant")},r.prototype._onInput=function(){this.type!==di.SelectOne&&this.setWidth()},r.prototype._onPaste=function(t){this.preventPaste&&t.preventDefault()},r.prototype._onFocus=function(){this.isFocussed=!0},r.prototype._onBlur=function(){this.isFocussed=!1},r})(),cu=4,Ea=(function(){function r(t){var e=t.element;this.element=e,this.scrollPos=this.element.scrollTop,this.height=this.element.offsetHeight}return r.prototype.prepend=function(t){var e=this.element.firstElementChild;e?this.element.insertBefore(t,e):this.element.append(t)},r.prototype.scrollToTop=function(){this.element.scrollTop=0},r.prototype.scrollToChildElement=function(t,e){var i=this;if(t){var s=this.element.offsetHeight,n=this.element.scrollTop+s,o=t.offsetHeight,a=t.offsetTop+o,l=e>0?this.element.scrollTop+a-n:t.offsetTop;requestAnimationFrame(function(){i._animateScroll(l,e)})}},r.prototype._scrollDown=function(t,e,i){var s=(i-t)/e,n=s>1?s:1;this.element.scrollTop=t+n},r.prototype._scrollUp=function(t,e,i){var s=(t-i)/e,n=s>1?s:1;this.element.scrollTop=t-n},r.prototype._animateScroll=function(t,e){var i=this,s=cu,n=this.element.scrollTop,o=!1;e>0?(this._scrollDown(n,s,t),n<t&&(o=!0)):(this._scrollUp(n,s,t),n>t&&(o=!0)),o&&requestAnimationFrame(function(){i._animateScroll(t,e)})},r})(),Gl=(function(){function r(t){var e=t.element,i=t.classNames;this.element=e,this.classNames=i,this.isDisabled=!1}return Object.defineProperty(r.prototype,"isActive",{get:function(){return this.element.dataset.choice==="active"},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"dir",{get:function(){return this.element.dir},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"value",{get:function(){return this.element.value},set:function(t){this.element.setAttribute("value",t),this.element.value=t},enumerable:!1,configurable:!0}),r.prototype.conceal=function(){var t=this.element;B(t,this.classNames.input),t.hidden=!0,t.tabIndex=-1;var e=t.getAttribute("style");e&&t.setAttribute("data-choice-orig-style",e),t.setAttribute("data-choice","active")},r.prototype.reveal=function(){var t=this.element;Ie(t,this.classNames.input),t.hidden=!1,t.removeAttribute("tabindex");var e=t.getAttribute("data-choice-orig-style");e?(t.removeAttribute("data-choice-orig-style"),t.setAttribute("style",e)):t.removeAttribute("style"),t.removeAttribute("data-choice")},r.prototype.enable=function(){this.element.removeAttribute("disabled"),this.element.disabled=!1,this.isDisabled=!1},r.prototype.disable=function(){this.element.setAttribute("disabled",""),this.element.disabled=!0,this.isDisabled=!0},r.prototype.triggerEvent=function(t,e){su(this.element,t,e||{})},r})(),hu=(function(r){Wl(t,r);function t(){return r!==null&&r.apply(this,arguments)||this}return t})(Gl),Ss=function(r,t){return t===void 0&&(t=!0),typeof r>"u"?t:!!r},Xl=function(r){if(typeof r=="string"&&(r=r.split(" ").filter(function(t){return t.length})),Array.isArray(r)&&r.length)return r},Me=function(r,t,e){if(e===void 0&&(e=!0),typeof r=="string"){var i=rn(r),s=e||i===r?r:{escaped:i,raw:r},n=Me({value:r,label:s,selected:!0},!1);return n}var o=r;if("choices"in o){if(!t)throw new TypeError("optGroup is not allowed");var a=o,l=a.choices.map(function(u){return Me(u,!1)}),c={id:0,label:Pi(a.label)||a.value,active:!!l.length,disabled:!!a.disabled,choices:l};return c}var h=o,d={id:0,group:null,score:0,rank:0,value:h.value,label:h.label||h.value,active:Ss(h.active),selected:Ss(h.selected,!1),disabled:Ss(h.disabled,!1),placeholder:Ss(h.placeholder,!1),highlighted:!1,labelClass:Xl(h.labelClass),labelDescription:h.labelDescription,customProperties:h.customProperties};return d},du=function(r){return r.tagName==="INPUT"},ql=function(r){return r.tagName==="SELECT"},uu=function(r){return r.tagName==="OPTION"},pu=function(r){return r.tagName==="OPTGROUP"},gu=(function(r){Wl(t,r);function t(e){var i=e.element,s=e.classNames,n=e.template,o=e.extractPlaceholder,a=r.call(this,{element:i,classNames:s})||this;return a.template=n,a.extractPlaceholder=o,a}return Object.defineProperty(t.prototype,"placeholderOption",{get:function(){return this.element.querySelector('option[value=""]')||this.element.querySelector("option[placeholder]")},enumerable:!1,configurable:!0}),t.prototype.addOptions=function(e){var i=this,s=document.createDocumentFragment();e.forEach(function(n){var o=n;if(!o.element){var a=i.template(o);s.appendChild(a),o.element=a}}),this.element.appendChild(s)},t.prototype.optionsAsChoices=function(){var e=this,i=[];return this.element.querySelectorAll(":scope > option, :scope > optgroup").forEach(function(s){uu(s)?i.push(e._optionToChoice(s)):pu(s)&&i.push(e._optgroupToChoice(s))}),i},t.prototype._optionToChoice=function(e){return!e.hasAttribute("value")&&e.hasAttribute("placeholder")&&(e.setAttribute("value",""),e.value=""),{id:0,group:null,score:0,rank:0,value:e.value,label:e.label,element:e,active:!0,selected:this.extractPlaceholder?e.selected:e.hasAttribute("selected"),disabled:e.disabled,highlighted:!1,placeholder:this.extractPlaceholder&&(!e.value||e.hasAttribute("placeholder")),labelClass:typeof e.dataset.labelClass<"u"?Xl(e.dataset.labelClass):void 0,labelDescription:typeof e.dataset.labelDescription<"u"?e.dataset.labelDescription:void 0,customProperties:nu(e.dataset.customProperties)}},t.prototype._optgroupToChoice=function(e){var i=this,s=e.querySelectorAll("option"),n=Array.from(s).map(function(o){return i._optionToChoice(o)});return{id:0,label:e.label||"",element:e,active:!!n.length,disabled:e.disabled,choices:n}},t})(Gl),fu={containerOuter:["choices"],containerInner:["choices__inner"],input:["choices__input"],inputCloned:["choices__input--cloned"],list:["choices__list"],listItems:["choices__list--multiple"],listSingle:["choices__list--single"],listDropdown:["choices__list--dropdown"],item:["choices__item"],itemSelectable:["choices__item--selectable"],itemDisabled:["choices__item--disabled"],itemChoice:["choices__item--choice"],description:["choices__description"],placeholder:["choices__placeholder"],group:["choices__group"],groupHeading:["choices__heading"],button:["choices__button"],activeState:["is-active"],focusState:["is-focused"],openState:["is-open"],disabledState:["is-disabled"],highlightedState:["is-highlighted"],selectedState:["is-selected"],flippedState:["is-flipped"],loadingState:["is-loading"],notice:["choices__notice"],addChoice:["choices__item--selectable","add-choice"],noResults:["has-no-results"],noChoices:["has-no-choices"]},Oa={items:[],choices:[],silent:!1,renderChoiceLimit:-1,maxItemCount:-1,closeDropdownOnSelect:"auto",singleModeForMultiSelect:!1,addChoices:!1,addItems:!0,addItemFilter:function(r){return!!r&&r!==""},removeItems:!0,removeItemButton:!1,removeItemButtonAlignLeft:!1,editItems:!1,allowHTML:!1,allowHtmlUserInput:!1,duplicateItemsAllowed:!0,delimiter:",",paste:!0,searchEnabled:!0,searchChoices:!0,searchFloor:1,searchResultLimit:4,searchFields:["label","value"],position:"auto",resetScrollPosition:!0,shouldSort:!0,shouldSortItems:!1,sorter:eu,shadowRoot:null,placeholder:!0,placeholderValue:null,searchPlaceholderValue:null,prependValue:null,appendValue:null,renderSelectedChoices:"auto",loadingText:"Loading...",noResultsText:"No results found",noChoicesText:"No choices to choose from",itemSelectText:"Press to select",uniqueItemText:"Only unique values can be added",customAddItemText:"Only values matching specific conditions can be added",addItemText:function(r){return'Press Enter to add <b>"'.concat(r,'"</b>')},removeItemIconText:function(){return"Remove item"},removeItemLabelText:function(r){return"Remove item: ".concat(r)},maxItemText:function(r){return"Only ".concat(r," values can be added")},valueComparer:function(r,t){return r===t},fuseOptions:{includeScore:!0},labelId:"",callbackOnInit:null,callbackOnCreateTemplates:null,classNames:fu,appendGroupInSearch:!1},ka=function(r){var t=r.itemEl;t&&(t.remove(),r.itemEl=void 0)};function mu(r,t,e){var i=r,s=!0;switch(t.type){case vt.ADD_ITEM:{t.item.selected=!0;var n=t.item.element;n&&(n.selected=!0,n.setAttribute("selected","")),i.push(t.item);break}case vt.REMOVE_ITEM:{t.item.selected=!1;var n=t.item.element;if(n){n.selected=!1,n.removeAttribute("selected");var o=n.parentElement;o&&ql(o)&&o.type===di.SelectOne&&(o.value="")}ka(t.item),i=i.filter(function(h){return h.id!==t.item.id});break}case vt.REMOVE_CHOICE:{ka(t.choice),i=i.filter(function(c){return c.id!==t.choice.id});break}case vt.HIGHLIGHT_ITEM:{var a=t.highlighted,l=i.find(function(c){return c.id===t.item.id});l&&l.highlighted!==a&&(l.highlighted=a,e&&ou(l,a?e.classNames.highlightedState:e.classNames.selectedState,a?e.classNames.selectedState:e.classNames.highlightedState));break}default:{s=!1;break}}return{state:i,update:s}}function bu(r,t){var e=r,i=!0;switch(t.type){case vt.ADD_GROUP:{e.push(t.group);break}case vt.CLEAR_CHOICES:{e=[];break}default:{i=!1;break}}return{state:e,update:i}}function vu(r,t,e){var i=r,s=!0;switch(t.type){case vt.ADD_CHOICE:{i.push(t.choice);break}case vt.REMOVE_CHOICE:{t.choice.choiceEl=void 0,t.choice.group&&(t.choice.group.choices=t.choice.group.choices.filter(function(o){return o.id!==t.choice.id})),i=i.filter(function(o){return o.id!==t.choice.id});break}case vt.ADD_ITEM:case vt.REMOVE_ITEM:{t.item.choiceEl=void 0;break}case vt.FILTER_CHOICES:{var n=[];t.results.forEach(function(o){n[o.item.id]=o}),i.forEach(function(o){var a=n[o.id];a!==void 0?(o.score=a.score,o.rank=a.rank,o.active=!0):(o.score=0,o.rank=0,o.active=!1),e&&e.appendGroupInSearch&&(o.choiceEl=void 0)});break}case vt.ACTIVATE_CHOICES:{i.forEach(function(o){o.active=t.active,e&&e.appendGroupInSearch&&(o.choiceEl=void 0)});break}case vt.CLEAR_CHOICES:{i=[];break}default:{s=!1;break}}return{state:i,update:s}}var Pa={groups:bu,items:mu,choices:vu},yu=(function(){function r(t){this._state=this.defaultState,this._listeners=[],this._txn=0,this._context=t}return Object.defineProperty(r.prototype,"defaultState",{get:function(){return{groups:[],items:[],choices:[]}},enumerable:!1,configurable:!0}),r.prototype.changeSet=function(t){return{groups:t,items:t,choices:t}},r.prototype.reset=function(){this._state=this.defaultState;var t=this.changeSet(!0);this._txn?this._changeSet=t:this._listeners.forEach(function(e){return e(t)})},r.prototype.subscribe=function(t){return this._listeners.push(t),this},r.prototype.dispatch=function(t){var e=this,i=this._state,s=!1,n=this._changeSet||this.changeSet(!1);Object.keys(Pa).forEach(function(o){var a=Pa[o](i[o],t,e._context);a.update&&(s=!0,n[o]=!0,i[o]=a.state)}),s&&(this._txn?this._changeSet=n:this._listeners.forEach(function(o){return o(n)}))},r.prototype.withTxn=function(t){this._txn++;try{t()}finally{if(this._txn=Math.max(0,this._txn-1),!this._txn){var e=this._changeSet;e&&(this._changeSet=void 0,this._listeners.forEach(function(i){return i(e)}))}}},Object.defineProperty(r.prototype,"state",{get:function(){return this._state},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"items",{get:function(){return this.state.items},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"highlightedActiveItems",{get:function(){return this.items.filter(function(t){return t.active&&t.highlighted})},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"choices",{get:function(){return this.state.choices},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"activeChoices",{get:function(){return this.choices.filter(function(t){return t.active})},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"searchableChoices",{get:function(){return this.choices.filter(function(t){return!t.disabled&&!t.placeholder})},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"groups",{get:function(){return this.state.groups},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"activeGroups",{get:function(){var t=this;return this.state.groups.filter(function(e){var i=e.active&&!e.disabled,s=t.state.choices.some(function(n){return n.active&&!n.disabled});return i&&s},[])},enumerable:!1,configurable:!0}),r.prototype.inTxn=function(){return this._txn>0},r.prototype.getChoiceById=function(t){return this.activeChoices.find(function(e){return e.id===t})},r.prototype.getGroupById=function(t){return this.groups.find(function(e){return e.id===t})},r})(),jt={noChoices:"no-choices",noResults:"no-results",addChoice:"add-choice",generic:""};function _u(r,t,e){return(t=wu(t))in r?Object.defineProperty(r,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):r[t]=e,r}function Aa(r,t){var e=Object.keys(r);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(r);t&&(i=i.filter(function(s){return Object.getOwnPropertyDescriptor(r,s).enumerable})),e.push.apply(e,i)}return e}function Gi(r){for(var t=1;t<arguments.length;t++){var e=arguments[t]!=null?arguments[t]:{};t%2?Aa(Object(e),!0).forEach(function(i){_u(r,i,e[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(e)):Aa(Object(e)).forEach(function(i){Object.defineProperty(r,i,Object.getOwnPropertyDescriptor(e,i))})}return r}function xu(r,t){if(typeof r!="object"||!r)return r;var e=r[Symbol.toPrimitive];if(e!==void 0){var i=e.call(r,t);if(typeof i!="object")return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(r)}function wu(r){var t=xu(r,"string");return typeof t=="symbol"?t:t+""}function Ze(r){return Array.isArray?Array.isArray(r):Jl(r)==="[object Array]"}function Cu(r){if(typeof r=="string")return r;let t=r+"";return t=="0"&&1/r==-1/0?"-0":t}function Su(r){return r==null?"":Cu(r)}function Fe(r){return typeof r=="string"}function Kl(r){return typeof r=="number"}function Tu(r){return r===!0||r===!1||Eu(r)&&Jl(r)=="[object Boolean]"}function Zl(r){return typeof r=="object"}function Eu(r){return Zl(r)&&r!==null}function he(r){return r!=null}function kn(r){return!r.trim().length}function Jl(r){return r==null?r===void 0?"[object Undefined]":"[object Null]":Object.prototype.toString.call(r)}const Ou="Incorrect 'index' type",ku=r=>`Invalid value for key ${r}`,Pu=r=>`Pattern length exceeds max of ${r}.`,Au=r=>`Missing ${r} property in key`,Du=r=>`Property 'weight' in key '${r}' must be a positive integer`,Da=Object.prototype.hasOwnProperty;class Mu{constructor(t){this._keys=[],this._keyMap={};let e=0;t.forEach(i=>{let s=Ql(i);this._keys.push(s),this._keyMap[s.id]=s,e+=s.weight}),this._keys.forEach(i=>{i.weight/=e})}get(t){return this._keyMap[t]}keys(){return this._keys}toJSON(){return JSON.stringify(this._keys)}}function Ql(r){let t=null,e=null,i=null,s=1,n=null;if(Fe(r)||Ze(r))i=r,t=Ma(r),e=Kn(r);else{if(!Da.call(r,"name"))throw new Error(Au("name"));const o=r.name;if(i=o,Da.call(r,"weight")&&(s=r.weight,s<=0))throw new Error(Du(o));t=Ma(o),e=Kn(o),n=r.getFn}return{path:t,id:e,weight:s,src:i,getFn:n}}function Ma(r){return Ze(r)?r:r.split(".")}function Kn(r){return Ze(r)?r.join("."):r}function Iu(r,t){let e=[],i=!1;const s=(n,o,a)=>{if(he(n))if(!o[a])e.push(n);else{let l=o[a];const c=n[l];if(!he(c))return;if(a===o.length-1&&(Fe(c)||Kl(c)||Tu(c)))e.push(Su(c));else if(Ze(c)){i=!0;for(let h=0,d=c.length;h<d;h+=1)s(c[h],o,a+1)}else o.length&&s(c,o,a+1)}};return s(r,Fe(t)?t.split("."):t,0),i?e:e[0]}const Lu={includeMatches:!1,findAllMatches:!1,minMatchCharLength:1},Fu={isCaseSensitive:!1,includeScore:!1,keys:[],shouldSort:!0,sortFn:(r,t)=>r.score===t.score?r.idx<t.idx?-1:1:r.score<t.score?-1:1},ju={location:0,threshold:.6,distance:100},$u={useExtendedSearch:!1,getFn:Iu,ignoreLocation:!1,ignoreFieldNorm:!1,fieldNormWeight:1};var $=Gi(Gi(Gi(Gi({},Fu),Lu),ju),$u);const Ru=/[^ ]+/g;function Bu(r=1,t=3){const e=new Map,i=Math.pow(10,t);return{get(s){const n=s.match(Ru).length;if(e.has(n))return e.get(n);const o=1/Math.pow(n,.5*r),a=parseFloat(Math.round(o*i)/i);return e.set(n,a),a},clear(){e.clear()}}}class Po{constructor({getFn:t=$.getFn,fieldNormWeight:e=$.fieldNormWeight}={}){this.norm=Bu(e,3),this.getFn=t,this.isCreated=!1,this.setIndexRecords()}setSources(t=[]){this.docs=t}setIndexRecords(t=[]){this.records=t}setKeys(t=[]){this.keys=t,this._keysMap={},t.forEach((e,i)=>{this._keysMap[e.id]=i})}create(){this.isCreated||!this.docs.length||(this.isCreated=!0,Fe(this.docs[0])?this.docs.forEach((t,e)=>{this._addString(t,e)}):this.docs.forEach((t,e)=>{this._addObject(t,e)}),this.norm.clear())}add(t){const e=this.size();Fe(t)?this._addString(t,e):this._addObject(t,e)}removeAt(t){this.records.splice(t,1);for(let e=t,i=this.size();e<i;e+=1)this.records[e].i-=1}getValueForItemAtKeyId(t,e){return t[this._keysMap[e]]}size(){return this.records.length}_addString(t,e){if(!he(t)||kn(t))return;let i={v:t,i:e,n:this.norm.get(t)};this.records.push(i)}_addObject(t,e){let i={i:e,$:{}};this.keys.forEach((s,n)=>{let o=s.getFn?s.getFn(t):this.getFn(t,s.path);if(he(o)){if(Ze(o)){let a=[];const l=[{nestedArrIndex:-1,value:o}];for(;l.length;){const{nestedArrIndex:c,value:h}=l.pop();if(he(h))if(Fe(h)&&!kn(h)){let d={v:h,i:c,n:this.norm.get(h)};a.push(d)}else Ze(h)&&h.forEach((d,u)=>{l.push({nestedArrIndex:u,value:d})})}i.$[n]=a}else if(Fe(o)&&!kn(o)){let a={v:o,n:this.norm.get(o)};i.$[n]=a}}}),this.records.push(i)}toJSON(){return{keys:this.keys,records:this.records}}}function tc(r,t,{getFn:e=$.getFn,fieldNormWeight:i=$.fieldNormWeight}={}){const s=new Po({getFn:e,fieldNormWeight:i});return s.setKeys(r.map(Ql)),s.setSources(t),s.create(),s}function zu(r,{getFn:t=$.getFn,fieldNormWeight:e=$.fieldNormWeight}={}){const{keys:i,records:s}=r,n=new Po({getFn:t,fieldNormWeight:e});return n.setKeys(i),n.setIndexRecords(s),n}function sr(r,{errors:t=0,currentLocation:e=0,expectedLocation:i=0,distance:s=$.distance,ignoreLocation:n=$.ignoreLocation}={}){const o=t/r.length;if(n)return o;const a=Math.abs(i-e);return s?o+a/s:a?1:o}function Hu(r=[],t=$.minMatchCharLength){let e=[],i=-1,s=-1,n=0;for(let o=r.length;n<o;n+=1){let a=r[n];a&&i===-1?i=n:!a&&i!==-1&&(s=n-1,s-i+1>=t&&e.push([i,s]),i=-1)}return r[n-1]&&n-i>=t&&e.push([i,n-1]),e}const Si=32;function Vu(r,t,e,{location:i=$.location,distance:s=$.distance,threshold:n=$.threshold,findAllMatches:o=$.findAllMatches,minMatchCharLength:a=$.minMatchCharLength,includeMatches:l=$.includeMatches,ignoreLocation:c=$.ignoreLocation}={}){if(t.length>Si)throw new Error(Pu(Si));const h=t.length,d=r.length,u=Math.max(0,Math.min(i,d));let p=n,g=u;const f=a>1||l,m=f?Array(d):[];let b;for(;(b=r.indexOf(t,g))>-1;){let O=sr(t,{currentLocation:b,expectedLocation:u,distance:s,ignoreLocation:c});if(p=Math.min(O,p),g=b+h,f){let E=0;for(;E<h;)m[b+E]=1,E+=1}}g=-1;let _=[],w=1,S=h+d;const T=1<<h-1;for(let O=0;O<h;O+=1){let E=0,P=S;for(;E<P;)sr(t,{errors:O,currentLocation:u+P,expectedLocation:u,distance:s,ignoreLocation:c})<=p?E=P:S=P,P=Math.floor((S-E)/2+E);S=P;let R=Math.max(1,u-P+1),L=o?d:Math.min(u+P,d)+h,F=Array(L+2);F[L+1]=(1<<O)-1;for(let M=L;M>=R;M-=1){let U=M-1,X=e[r.charAt(U)];if(f&&(m[U]=+!!X),F[M]=(F[M+1]<<1|1)&X,O&&(F[M]|=(_[M+1]|_[M])<<1|1|_[M+1]),F[M]&T&&(w=sr(t,{errors:O,currentLocation:U,expectedLocation:u,distance:s,ignoreLocation:c}),w<=p)){if(p=w,g=U,g<=u)break;R=Math.max(1,2*u-g)}}if(sr(t,{errors:O+1,currentLocation:u,expectedLocation:u,distance:s,ignoreLocation:c})>p)break;_=F}const k={isMatch:g>=0,score:Math.max(.001,w)};if(f){const O=Hu(m,a);O.length?l&&(k.indices=O):k.isMatch=!1}return k}function Nu(r){let t={};for(let e=0,i=r.length;e<i;e+=1){const s=r.charAt(e);t[s]=(t[s]||0)|1<<i-e-1}return t}class ec{constructor(t,{location:e=$.location,threshold:i=$.threshold,distance:s=$.distance,includeMatches:n=$.includeMatches,findAllMatches:o=$.findAllMatches,minMatchCharLength:a=$.minMatchCharLength,isCaseSensitive:l=$.isCaseSensitive,ignoreLocation:c=$.ignoreLocation}={}){if(this.options={location:e,threshold:i,distance:s,includeMatches:n,findAllMatches:o,minMatchCharLength:a,isCaseSensitive:l,ignoreLocation:c},this.pattern=l?t:t.toLowerCase(),this.chunks=[],!this.pattern.length)return;const h=(u,p)=>{this.chunks.push({pattern:u,alphabet:Nu(u),startIndex:p})},d=this.pattern.length;if(d>Si){let u=0;const p=d%Si,g=d-p;for(;u<g;)h(this.pattern.substr(u,Si),u),u+=Si;if(p){const f=d-Si;h(this.pattern.substr(f),f)}}else h(this.pattern,0)}searchIn(t){const{isCaseSensitive:e,includeMatches:i}=this.options;if(e||(t=t.toLowerCase()),this.pattern===t){let g={isMatch:!0,score:0};return i&&(g.indices=[[0,t.length-1]]),g}const{location:s,distance:n,threshold:o,findAllMatches:a,minMatchCharLength:l,ignoreLocation:c}=this.options;let h=[],d=0,u=!1;this.chunks.forEach(({pattern:g,alphabet:f,startIndex:m})=>{const{isMatch:b,score:_,indices:w}=Vu(t,g,f,{location:s+m,distance:n,threshold:o,findAllMatches:a,minMatchCharLength:l,includeMatches:i,ignoreLocation:c});b&&(u=!0),d+=_,b&&w&&(h=[...h,...w])});let p={isMatch:u,score:u?d/this.chunks.length:1};return u&&i&&(p.indices=h),p}}class bi{constructor(t){this.pattern=t}static isMultiMatch(t){return Ia(t,this.multiRegex)}static isSingleMatch(t){return Ia(t,this.singleRegex)}search(){}}function Ia(r,t){const e=r.match(t);return e?e[1]:null}class Uu extends bi{constructor(t){super(t)}static get type(){return"exact"}static get multiRegex(){return/^="(.*)"$/}static get singleRegex(){return/^=(.*)$/}search(t){const e=t===this.pattern;return{isMatch:e,score:e?0:1,indices:[0,this.pattern.length-1]}}}class Wu extends bi{constructor(t){super(t)}static get type(){return"inverse-exact"}static get multiRegex(){return/^!"(.*)"$/}static get singleRegex(){return/^!(.*)$/}search(t){const i=t.indexOf(this.pattern)===-1;return{isMatch:i,score:i?0:1,indices:[0,t.length-1]}}}class Yu extends bi{constructor(t){super(t)}static get type(){return"prefix-exact"}static get multiRegex(){return/^\^"(.*)"$/}static get singleRegex(){return/^\^(.*)$/}search(t){const e=t.startsWith(this.pattern);return{isMatch:e,score:e?0:1,indices:[0,this.pattern.length-1]}}}class Gu extends bi{constructor(t){super(t)}static get type(){return"inverse-prefix-exact"}static get multiRegex(){return/^!\^"(.*)"$/}static get singleRegex(){return/^!\^(.*)$/}search(t){const e=!t.startsWith(this.pattern);return{isMatch:e,score:e?0:1,indices:[0,t.length-1]}}}class Xu extends bi{constructor(t){super(t)}static get type(){return"suffix-exact"}static get multiRegex(){return/^"(.*)"\$$/}static get singleRegex(){return/^(.*)\$$/}search(t){const e=t.endsWith(this.pattern);return{isMatch:e,score:e?0:1,indices:[t.length-this.pattern.length,t.length-1]}}}class qu extends bi{constructor(t){super(t)}static get type(){return"inverse-suffix-exact"}static get multiRegex(){return/^!"(.*)"\$$/}static get singleRegex(){return/^!(.*)\$$/}search(t){const e=!t.endsWith(this.pattern);return{isMatch:e,score:e?0:1,indices:[0,t.length-1]}}}class ic extends bi{constructor(t,{location:e=$.location,threshold:i=$.threshold,distance:s=$.distance,includeMatches:n=$.includeMatches,findAllMatches:o=$.findAllMatches,minMatchCharLength:a=$.minMatchCharLength,isCaseSensitive:l=$.isCaseSensitive,ignoreLocation:c=$.ignoreLocation}={}){super(t),this._bitapSearch=new ec(t,{location:e,threshold:i,distance:s,includeMatches:n,findAllMatches:o,minMatchCharLength:a,isCaseSensitive:l,ignoreLocation:c})}static get type(){return"fuzzy"}static get multiRegex(){return/^"(.*)"$/}static get singleRegex(){return/^(.*)$/}search(t){return this._bitapSearch.searchIn(t)}}class sc extends bi{constructor(t){super(t)}static get type(){return"include"}static get multiRegex(){return/^'"(.*)"$/}static get singleRegex(){return/^'(.*)$/}search(t){let e=0,i;const s=[],n=this.pattern.length;for(;(i=t.indexOf(this.pattern,e))>-1;)e=i+n,s.push([i,e-1]);const o=!!s.length;return{isMatch:o,score:o?0:1,indices:s}}}const Zn=[Uu,sc,Yu,Gu,qu,Xu,Wu,ic],La=Zn.length,Ku=/ +(?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)/,Zu="|";function Ju(r,t={}){return r.split(Zu).map(e=>{let i=e.trim().split(Ku).filter(n=>n&&!!n.trim()),s=[];for(let n=0,o=i.length;n<o;n+=1){const a=i[n];let l=!1,c=-1;for(;!l&&++c<La;){const h=Zn[c];let d=h.isMultiMatch(a);d&&(s.push(new h(d,t)),l=!0)}if(!l)for(c=-1;++c<La;){const h=Zn[c];let d=h.isSingleMatch(a);if(d){s.push(new h(d,t));break}}}return s})}const Qu=new Set([ic.type,sc.type]);class tp{constructor(t,{isCaseSensitive:e=$.isCaseSensitive,includeMatches:i=$.includeMatches,minMatchCharLength:s=$.minMatchCharLength,ignoreLocation:n=$.ignoreLocation,findAllMatches:o=$.findAllMatches,location:a=$.location,threshold:l=$.threshold,distance:c=$.distance}={}){this.query=null,this.options={isCaseSensitive:e,includeMatches:i,minMatchCharLength:s,findAllMatches:o,ignoreLocation:n,location:a,threshold:l,distance:c},this.pattern=e?t:t.toLowerCase(),this.query=Ju(this.pattern,this.options)}static condition(t,e){return e.useExtendedSearch}searchIn(t){const e=this.query;if(!e)return{isMatch:!1,score:1};const{includeMatches:i,isCaseSensitive:s}=this.options;t=s?t:t.toLowerCase();let n=0,o=[],a=0;for(let l=0,c=e.length;l<c;l+=1){const h=e[l];o.length=0,n=0;for(let d=0,u=h.length;d<u;d+=1){const p=h[d],{isMatch:g,indices:f,score:m}=p.search(t);if(g){if(n+=1,a+=m,i){const b=p.constructor.type;Qu.has(b)?o=[...o,...f]:o.push(f)}}else{a=0,n=0,o.length=0;break}}if(n){let d={isMatch:!0,score:a/n};return i&&(d.indices=o),d}}return{isMatch:!1,score:1}}}const Jn=[];function ep(...r){Jn.push(...r)}function Qn(r,t){for(let e=0,i=Jn.length;e<i;e+=1){let s=Jn[e];if(s.condition(r,t))return new s(r,t)}return new ec(r,t)}const $r={AND:"$and",OR:"$or"},to={PATH:"$path",PATTERN:"$val"},eo=r=>!!(r[$r.AND]||r[$r.OR]),ip=r=>!!r[to.PATH],sp=r=>!Ze(r)&&Zl(r)&&!eo(r),Fa=r=>({[$r.AND]:Object.keys(r).map(t=>({[t]:r[t]}))});function rc(r,t,{auto:e=!0}={}){const i=s=>{let n=Object.keys(s);const o=ip(s);if(!o&&n.length>1&&!eo(s))return i(Fa(s));if(sp(s)){const l=o?s[to.PATH]:n[0],c=o?s[to.PATTERN]:s[l];if(!Fe(c))throw new Error(ku(l));const h={keyId:Kn(l),pattern:c};return e&&(h.searcher=Qn(c,t)),h}let a={children:[],operator:n[0]};return n.forEach(l=>{const c=s[l];Ze(c)&&c.forEach(h=>{a.children.push(i(h))})}),a};return eo(r)||(r=Fa(r)),i(r)}function rp(r,{ignoreFieldNorm:t=$.ignoreFieldNorm}){r.forEach(e=>{let i=1;e.matches.forEach(({key:s,norm:n,score:o})=>{const a=s?s.weight:null;i*=Math.pow(o===0&&a?Number.EPSILON:o,(a||1)*(t?1:n))}),e.score=i})}function np(r,t){const e=r.matches;t.matches=[],he(e)&&e.forEach(i=>{if(!he(i.indices)||!i.indices.length)return;const{indices:s,value:n}=i;let o={indices:s,value:n};i.key&&(o.key=i.key.src),i.idx>-1&&(o.refIndex=i.idx),t.matches.push(o)})}function op(r,t){t.score=r.score}function ap(r,t,{includeMatches:e=$.includeMatches,includeScore:i=$.includeScore}={}){const s=[];return e&&s.push(np),i&&s.push(op),r.map(n=>{const{idx:o}=n,a={item:t[o],refIndex:o};return s.length&&s.forEach(l=>{l(n,a)}),a})}class is{constructor(t,e={},i){this.options=Gi(Gi({},$),e),this.options.useExtendedSearch,this._keyStore=new Mu(this.options.keys),this.setCollection(t,i)}setCollection(t,e){if(this._docs=t,e&&!(e instanceof Po))throw new Error(Ou);this._myIndex=e||tc(this.options.keys,this._docs,{getFn:this.options.getFn,fieldNormWeight:this.options.fieldNormWeight})}add(t){he(t)&&(this._docs.push(t),this._myIndex.add(t))}remove(t=()=>!1){const e=[];for(let i=0,s=this._docs.length;i<s;i+=1){const n=this._docs[i];t(n,i)&&(this.removeAt(i),i-=1,s-=1,e.push(n))}return e}removeAt(t){this._docs.splice(t,1),this._myIndex.removeAt(t)}getIndex(){return this._myIndex}search(t,{limit:e=-1}={}){const{includeMatches:i,includeScore:s,shouldSort:n,sortFn:o,ignoreFieldNorm:a}=this.options;let l=Fe(t)?Fe(this._docs[0])?this._searchStringList(t):this._searchObjectList(t):this._searchLogical(t);return rp(l,{ignoreFieldNorm:a}),n&&l.sort(o),Kl(e)&&e>-1&&(l=l.slice(0,e)),ap(l,this._docs,{includeMatches:i,includeScore:s})}_searchStringList(t){const e=Qn(t,this.options),{records:i}=this._myIndex,s=[];return i.forEach(({v:n,i:o,n:a})=>{if(!he(n))return;const{isMatch:l,score:c,indices:h}=e.searchIn(n);l&&s.push({item:n,idx:o,matches:[{score:c,value:n,norm:a,indices:h}]})}),s}_searchLogical(t){const e=rc(t,this.options),i=(a,l,c)=>{if(!a.children){const{keyId:d,searcher:u}=a,p=this._findMatches({key:this._keyStore.get(d),value:this._myIndex.getValueForItemAtKeyId(l,d),searcher:u});return p&&p.length?[{idx:c,item:l,matches:p}]:[]}const h=[];for(let d=0,u=a.children.length;d<u;d+=1){const p=a.children[d],g=i(p,l,c);if(g.length)h.push(...g);else if(a.operator===$r.AND)return[]}return h},s=this._myIndex.records,n={},o=[];return s.forEach(({$:a,i:l})=>{if(he(a)){let c=i(e,a,l);c.length&&(n[l]||(n[l]={idx:l,item:a,matches:[]},o.push(n[l])),c.forEach(({matches:h})=>{n[l].matches.push(...h)}))}}),o}_searchObjectList(t){const e=Qn(t,this.options),{keys:i,records:s}=this._myIndex,n=[];return s.forEach(({$:o,i:a})=>{if(!he(o))return;let l=[];i.forEach((c,h)=>{l.push(...this._findMatches({key:c,value:o[h],searcher:e}))}),l.length&&n.push({idx:a,item:o,matches:l})}),n}_findMatches({key:t,value:e,searcher:i}){if(!he(e))return[];let s=[];if(Ze(e))e.forEach(({v:n,i:o,n:a})=>{if(!he(n))return;const{isMatch:l,score:c,indices:h}=i.searchIn(n);l&&s.push({score:c,key:t,value:n,idx:o,norm:a,indices:h})});else{const{v:n,n:o}=e,{isMatch:a,score:l,indices:c}=i.searchIn(n);a&&s.push({score:l,key:t,value:n,norm:o,indices:c})}return s}}is.version="7.0.0";is.createIndex=tc;is.parseIndex=zu;is.config=$;is.parseQuery=rc;ep(tp);var lp=(function(){function r(t){this._haystack=[],this._fuseOptions=Jt(Jt({},t.fuseOptions),{keys:Ud([],t.searchFields),includeMatches:!0})}return r.prototype.index=function(t){this._haystack=t,this._fuse&&this._fuse.setCollection(t)},r.prototype.reset=function(){this._haystack=[],this._fuse=void 0},r.prototype.isEmptyIndex=function(){return!this._haystack.length},r.prototype.search=function(t){this._fuse||(this._fuse=new is(this._haystack,this._fuseOptions));var e=this._fuse.search(t);return e.map(function(i,s){return{item:i.item,score:i.score||0,rank:s+1}})},r})();function cp(r){return new lp(r)}var hp=function(r){for(var t in r)if(Object.prototype.hasOwnProperty.call(r,t))return!1;return!0},Pn=function(r,t,e){var i=r.dataset,s=t.customProperties,n=t.labelClass,o=t.labelDescription;n&&(i.labelClass=nn(n).join(" ")),o&&(i.labelDescription=o),e&&s&&(typeof s=="string"?i.customProperties=s:typeof s=="object"&&!hp(s)&&(i.customProperties=JSON.stringify(s)))},ja=function(r,t,e){var i=t&&r.querySelector("label[for='".concat(t,"']")),s=i&&i.innerText;s&&e.setAttribute("aria-label",s)},dp={containerOuter:function(r,t,e,i,s,n,o){var a=r.classNames.containerOuter,l=document.createElement("div");return B(l,a),l.dataset.type=n,t&&(l.dir=t),i&&(l.tabIndex=0),e&&(l.setAttribute("role",s?"combobox":"listbox"),s?l.setAttribute("aria-autocomplete","list"):o||ja(this._docRoot,this.passedElement.element.id,l),l.setAttribute("aria-haspopup","true"),l.setAttribute("aria-expanded","false")),o&&l.setAttribute("aria-labelledby",o),l},containerInner:function(r){var t=r.classNames.containerInner,e=document.createElement("div");return B(e,t),e},itemList:function(r,t){var e=r.searchEnabled,i=r.classNames,s=i.list,n=i.listSingle,o=i.listItems,a=document.createElement("div");return B(a,s),B(a,t?n:o),this._isSelectElement&&e&&a.setAttribute("role","listbox"),a},placeholder:function(r,t){var e=r.allowHTML,i=r.classNames.placeholder,s=document.createElement("div");return B(s,i),Ne(s,e,t),s},item:function(r,t,e){var i=r.allowHTML,s=r.removeItemButtonAlignLeft,n=r.removeItemIconText,o=r.removeItemLabelText,a=r.classNames,l=a.item,c=a.button,h=a.highlightedState,d=a.itemSelectable,u=a.placeholder,p=Pi(t.value),g=document.createElement("div");if(B(g,l),t.labelClass){var f=document.createElement("span");Ne(f,i,t.label),B(f,t.labelClass),g.appendChild(f)}else Ne(g,i,t.label);if(g.dataset.item="",g.dataset.id=t.id,g.dataset.value=p,Pn(g,t,!0),(t.disabled||this.containerOuter.isDisabled)&&g.setAttribute("aria-disabled","true"),this._isSelectElement&&(g.setAttribute("aria-selected","true"),g.setAttribute("role","option")),t.placeholder&&(B(g,u),g.dataset.placeholder=""),B(g,t.highlighted?h:d),e){t.disabled&&Ie(g,d),g.dataset.deletable="";var m=document.createElement("button");m.type="button",B(m,c),Ne(m,!0,As(n,t.value));var b=As(o,t.value);b&&m.setAttribute("aria-label",b),m.dataset.button="",s?g.insertAdjacentElement("afterbegin",m):g.appendChild(m)}return g},choiceList:function(r,t){var e=r.classNames.list,i=document.createElement("div");return B(i,e),t||i.setAttribute("aria-multiselectable","true"),i.setAttribute("role","listbox"),i},choiceGroup:function(r,t){var e=r.allowHTML,i=r.classNames,s=i.group,n=i.groupHeading,o=i.itemDisabled,a=t.id,l=t.label,c=t.disabled,h=Pi(l),d=document.createElement("div");B(d,s),c&&B(d,o),d.setAttribute("role","group"),d.dataset.group="",d.dataset.id=a,d.dataset.value=h,c&&d.setAttribute("aria-disabled","true");var u=document.createElement("div");return B(u,n),Ne(u,e,l||""),d.appendChild(u),d},choice:function(r,t,e,i){var s=r.allowHTML,n=r.classNames,o=n.item,a=n.itemChoice,l=n.itemSelectable,c=n.selectedState,h=n.itemDisabled,d=n.description,u=n.placeholder,p=t.label,g=Pi(t.value),f=document.createElement("div");f.id=t.elementId,B(f,o),B(f,a),i&&typeof p=="string"&&(p=ko(s,p),p+=" (".concat(i,")"),p={trusted:p});var m=f;if(t.labelClass){var b=document.createElement("span");Ne(b,s,p),B(b,t.labelClass),m=b,f.appendChild(b)}else Ne(f,s,p);if(t.labelDescription){var _="".concat(t.elementId,"-description");m.setAttribute("aria-describedby",_);var w=document.createElement("span");Ne(w,s,t.labelDescription),w.id=_,B(w,d),f.appendChild(w)}return t.selected&&B(f,c),t.placeholder&&B(f,u),f.setAttribute("role",t.group?"treeitem":"option"),f.dataset.choice="",f.dataset.id=t.id,f.dataset.value=g,e&&(f.dataset.selectText=e),t.group&&(f.dataset.groupId="".concat(t.group.id)),Pn(f,t,!1),t.disabled?(B(f,h),f.dataset.choiceDisabled="",f.setAttribute("aria-disabled","true")):(B(f,l),f.dataset.choiceSelectable=""),f},input:function(r,t){var e=r.classNames,i=e.input,s=e.inputCloned,n=r.labelId,o=document.createElement("input");return o.type="search",B(o,i),B(o,s),o.autocomplete="off",o.autocapitalize="off",o.spellcheck=!1,o.setAttribute("aria-autocomplete","list"),t?o.setAttribute("aria-label",t):n||ja(this._docRoot,this.passedElement.element.id,o),o},dropdown:function(r){var t=r.classNames,e=t.list,i=t.listDropdown,s=document.createElement("div");return B(s,e),B(s,i),s.setAttribute("aria-expanded","false"),s},notice:function(r,t,e){var i=r.classNames,s=i.item,n=i.itemChoice,o=i.addChoice,a=i.noResults,l=i.noChoices,c=i.notice;e===void 0&&(e=jt.generic);var h=document.createElement("div");switch(Ne(h,!0,t),B(h,s),B(h,n),B(h,c),e){case jt.addChoice:B(h,o);break;case jt.noResults:B(h,a);break;case jt.noChoices:B(h,l);break}return e===jt.addChoice&&(h.dataset.choiceSelectable="",h.dataset.choice=""),h},option:function(r){var t=Pi(r.label),e=new Option(t,r.value,!1,r.selected);return Pn(e,r,!0),e.disabled=r.disabled,r.selected&&e.setAttribute("selected",""),e}},up="-ms-scroll-limit"in document.documentElement.style&&"-ms-ime-align"in document.documentElement.style,pp={},An=function(r){if(r)return r.dataset.id?parseInt(r.dataset.id,10):void 0},bs="[data-choice-selectable]",nc=(function(){function r(t,e){t===void 0&&(t="[data-choice]"),e===void 0&&(e={});var i=this;this.initialisedOK=void 0,this._hasNonChoicePlaceholder=!1,this._lastAddedChoiceId=0,this._lastAddedGroupId=0;var s=r.defaults;this.config=Jt(Jt(Jt({},s.allOptions),s.options),e),Wd.forEach(function(b){i.config[b]=Jt(Jt(Jt({},s.allOptions[b]),s.options[b]),e[b])});var n=this.config;n.silent||this._validateConfig();var o=n.shadowRoot||document.documentElement;this._docRoot=o;var a=typeof t=="string"?o.querySelector(t):t;if(!a||typeof a!="object"||!(du(a)||ql(a)))throw TypeError(!a&&typeof t=="string"?"Selector ".concat(t," failed to find an element"):"Expected one of the following types text|select-one|select-multiple");var l=a.type,c=l===di.Text;(c||n.maxItemCount!==1)&&(n.singleModeForMultiSelect=!1),n.singleModeForMultiSelect&&(l=di.SelectMultiple);var h=l===di.SelectOne,d=l===di.SelectMultiple,u=h||d;if(this._elementType=l,this._isTextElement=c,this._isSelectOneElement=h,this._isSelectMultipleElement=d,this._isSelectElement=h||d,this._canAddUserChoices=c&&n.addItems||u&&n.addChoices,typeof n.renderSelectedChoices!="boolean"&&(n.renderSelectedChoices=n.renderSelectedChoices==="always"||h),n.closeDropdownOnSelect==="auto"?n.closeDropdownOnSelect=c||h||n.singleModeForMultiSelect:n.closeDropdownOnSelect=Ss(n.closeDropdownOnSelect),n.placeholder&&(n.placeholderValue?this._hasNonChoicePlaceholder=!0:a.dataset.placeholder&&(this._hasNonChoicePlaceholder=!0,n.placeholderValue=a.dataset.placeholder)),e.addItemFilter&&typeof e.addItemFilter!="function"){var p=e.addItemFilter instanceof RegExp?e.addItemFilter:new RegExp(e.addItemFilter);n.addItemFilter=p.test.bind(p)}if(this._isTextElement)this.passedElement=new hu({element:a,classNames:n.classNames});else{var g=a;this.passedElement=new gu({element:g,classNames:n.classNames,template:function(b){return i._templates.option(b)},extractPlaceholder:n.placeholder&&!this._hasNonChoicePlaceholder})}if(this.initialised=!1,this._store=new yu(n),this._currentValue="",n.searchEnabled=!c&&n.searchEnabled||d,this._canSearch=n.searchEnabled,this._isScrollingOnIe=!1,this._highlightPosition=0,this._wasTap=!0,this._placeholderValue=this._generatePlaceholderValue(),this._baseId=Zd(a,"choices-"),this._direction=a.dir,!this._direction){var f=window.getComputedStyle(a).direction,m=window.getComputedStyle(document.documentElement).direction;f!==m&&(this._direction=f)}if(this._idNames={itemChoice:"item-choice"},this._templates=s.templates,this._render=this._render.bind(this),this._onFocus=this._onFocus.bind(this),this._onBlur=this._onBlur.bind(this),this._onKeyUp=this._onKeyUp.bind(this),this._onKeyDown=this._onKeyDown.bind(this),this._onInput=this._onInput.bind(this),this._onClick=this._onClick.bind(this),this._onTouchMove=this._onTouchMove.bind(this),this._onTouchEnd=this._onTouchEnd.bind(this),this._onMouseDown=this._onMouseDown.bind(this),this._onMouseOver=this._onMouseOver.bind(this),this._onFormReset=this._onFormReset.bind(this),this._onSelectKey=this._onSelectKey.bind(this),this._onEnterKey=this._onEnterKey.bind(this),this._onEscapeKey=this._onEscapeKey.bind(this),this._onDirectionKey=this._onDirectionKey.bind(this),this._onDeleteKey=this._onDeleteKey.bind(this),this.passedElement.isActive){n.silent||console.warn("Trying to initialise Choices on element already initialised",{element:t}),this.initialised=!0,this.initialisedOK=!1;return}this.init(),this._initialItems=this._store.items.map(function(b){return b.value})}return Object.defineProperty(r,"defaults",{get:function(){return Object.preventExtensions({get options(){return pp},get allOptions(){return Oa},get templates(){return dp}})},enumerable:!1,configurable:!0}),r.prototype.init=function(){if(!(this.initialised||this.initialisedOK!==void 0)){this._searcher=cp(this.config),this._loadChoices(),this._createTemplates(),this._createElements(),this._createStructure(),this._isTextElement&&!this.config.addItems||this.passedElement.element.hasAttribute("disabled")||this.passedElement.element.closest("fieldset:disabled")?this.disable():(this.enable(),this._addEventListeners()),this._initStore(),this.initialised=!0,this.initialisedOK=!0;var t=this.config.callbackOnInit;typeof t=="function"&&t.call(this)}},r.prototype.destroy=function(){this.initialised&&(this._removeEventListeners(),this.passedElement.reveal(),this.containerOuter.unwrap(this.passedElement.element),this._store._listeners=[],this.clearStore(!1),this._stopSearch(),this._templates=r.defaults.templates,this.initialised=!1,this.initialisedOK=void 0)},r.prototype.enable=function(){return this.passedElement.isDisabled&&this.passedElement.enable(),this.containerOuter.isDisabled&&(this._addEventListeners(),this.input.enable(),this.containerOuter.enable()),this},r.prototype.disable=function(){return this.passedElement.isDisabled||this.passedElement.disable(),this.containerOuter.isDisabled||(this._removeEventListeners(),this.input.disable(),this.containerOuter.disable()),this},r.prototype.highlightItem=function(t,e){if(e===void 0&&(e=!0),!t||!t.id)return this;var i=this._store.items.find(function(s){return s.id===t.id});return!i||i.highlighted?this:(this._store.dispatch(ir(i,!0)),e&&this.passedElement.triggerEvent(Zt.highlightItem,this._getChoiceForOutput(i)),this)},r.prototype.unhighlightItem=function(t,e){if(e===void 0&&(e=!0),!t||!t.id)return this;var i=this._store.items.find(function(s){return s.id===t.id});return!i||!i.highlighted?this:(this._store.dispatch(ir(i,!1)),e&&this.passedElement.triggerEvent(Zt.unhighlightItem,this._getChoiceForOutput(i)),this)},r.prototype.highlightAll=function(){var t=this;return this._store.withTxn(function(){t._store.items.forEach(function(e){e.highlighted||(t._store.dispatch(ir(e,!0)),t.passedElement.triggerEvent(Zt.highlightItem,t._getChoiceForOutput(e)))})}),this},r.prototype.unhighlightAll=function(){var t=this;return this._store.withTxn(function(){t._store.items.forEach(function(e){e.highlighted&&(t._store.dispatch(ir(e,!1)),t.passedElement.triggerEvent(Zt.highlightItem,t._getChoiceForOutput(e)))})}),this},r.prototype.removeActiveItemsByValue=function(t){var e=this;return this._store.withTxn(function(){e._store.items.filter(function(i){return i.value===t}).forEach(function(i){return e._removeItem(i)})}),this},r.prototype.removeActiveItems=function(t){var e=this;return this._store.withTxn(function(){e._store.items.filter(function(i){var s=i.id;return s!==t}).forEach(function(i){return e._removeItem(i)})}),this},r.prototype.removeHighlightedItems=function(t){var e=this;return t===void 0&&(t=!1),this._store.withTxn(function(){e._store.highlightedActiveItems.forEach(function(i){e._removeItem(i),t&&e._triggerChange(i.value)})}),this},r.prototype.showDropdown=function(t){var e=this;return this.dropdown.isActive?this:(t===void 0&&(t=!this._canSearch),requestAnimationFrame(function(){e.dropdown.show();var i=e.dropdown.element.getBoundingClientRect();e.containerOuter.open(i.bottom,i.height),t||e.input.focus(),e.passedElement.triggerEvent(Zt.showDropdown)}),this)},r.prototype.hideDropdown=function(t){var e=this;return this.dropdown.isActive?(requestAnimationFrame(function(){e.dropdown.hide(),e.containerOuter.close(),!t&&e._canSearch&&(e.input.removeActiveDescendant(),e.input.blur()),e.passedElement.triggerEvent(Zt.hideDropdown)}),this):this},r.prototype.getValue=function(t){var e=this,i=this._store.items.map(function(s){return t?s.value:e._getChoiceForOutput(s)});return this._isSelectOneElement||this.config.singleModeForMultiSelect?i[0]:i},r.prototype.setValue=function(t){var e=this;return this.initialisedOK?(this._store.withTxn(function(){t.forEach(function(i){i&&e._addChoice(Me(i,!1))})}),this._searcher.reset(),this):(this._warnChoicesInitFailed("setValue"),this)},r.prototype.setChoiceByValue=function(t){var e=this;return this.initialisedOK?this._isTextElement?this:(this._store.withTxn(function(){var i=Array.isArray(t)?t:[t];i.forEach(function(s){return e._findAndSelectChoiceByValue(s)}),e.unhighlightAll()}),this._searcher.reset(),this):(this._warnChoicesInitFailed("setChoiceByValue"),this)},r.prototype.setChoices=function(t,e,i,s,n,o){var a=this;if(t===void 0&&(t=[]),e===void 0&&(e="value"),i===void 0&&(i="label"),s===void 0&&(s=!1),n===void 0&&(n=!0),o===void 0&&(o=!1),!this.initialisedOK)return this._warnChoicesInitFailed("setChoices"),this;if(!this._isSelectElement)throw new TypeError("setChoices can't be used with INPUT based Choices");if(typeof e!="string"||!e)throw new TypeError("value parameter must be a name of 'value' field in passed objects");if(typeof t=="function"){var l=t(this);if(typeof Promise=="function"&&l instanceof Promise)return new Promise(function(c){return requestAnimationFrame(c)}).then(function(){return a._handleLoadingState(!0)}).then(function(){return l}).then(function(c){return a.setChoices(c,e,i,s,n,o)}).catch(function(c){a.config.silent||console.error(c)}).then(function(){return a._handleLoadingState(!1)}).then(function(){return a});if(!Array.isArray(l))throw new TypeError(".setChoices first argument function must return either array of choices or Promise, got: ".concat(typeof l));return this.setChoices(l,e,i,!1)}if(!Array.isArray(t))throw new TypeError(".setChoices must be called either with array of choices with a function resulting into Promise of array of choices");return this.containerOuter.removeLoadingState(),this._store.withTxn(function(){n&&(a._isSearching=!1),s&&a.clearChoices(!0,o);var c=e==="value",h=i==="label";t.forEach(function(d){if("choices"in d){var u=d;h||(u=Jt(Jt({},u),{label:u[i]})),a._addGroup(Me(u,!0))}else{var p=d;(!h||!c)&&(p=Jt(Jt({},p),{value:p[e],label:p[i]}));var g=Me(p,!1);a._addChoice(g),g.placeholder&&!a._hasNonChoicePlaceholder&&(a._placeholderValue=Yl(g.label))}}),a.unhighlightAll()}),this._searcher.reset(),this},r.prototype.refresh=function(t,e,i){var s=this;return t===void 0&&(t=!1),e===void 0&&(e=!1),i===void 0&&(i=!1),this._isSelectElement?(this._store.withTxn(function(){var n=s.passedElement.optionsAsChoices(),o={};i||s._store.items.forEach(function(l){l.id&&l.active&&l.selected&&(o[l.value]=!0)}),s.clearStore(!1);var a=function(l){i?s._store.dispatch(wa(l)):o[l.value]&&(l.selected=!0)};n.forEach(function(l){if("choices"in l){l.choices.forEach(a);return}a(l)}),s._addPredefinedChoices(n,e,t),s._isSearching&&s._searchChoices(s.input.value)}),this):(this.config.silent||console.warn("refresh method can only be used on choices backed by a <select> element"),this)},r.prototype.removeChoice=function(t){var e=this._store.choices.find(function(i){return i.value===t});return e?(this._clearNotice(),this._store.dispatch(Yd(e)),this._searcher.reset(),e.selected&&this.passedElement.triggerEvent(Zt.removeItem,this._getChoiceForOutput(e)),this):this},r.prototype.clearChoices=function(t,e){var i=this;return t===void 0&&(t=!0),e===void 0&&(e=!1),t&&(e?this.passedElement.element.replaceChildren(""):this.passedElement.element.querySelectorAll(":not([selected])").forEach(function(s){s.remove()})),this.itemList.element.replaceChildren(""),this.choiceList.element.replaceChildren(""),this._clearNotice(),this._store.withTxn(function(){var s=e?[]:i._store.items;i._store.reset(),s.forEach(function(n){i._store.dispatch(_a(n)),i._store.dispatch(xa(n))})}),this._searcher.reset(),this},r.prototype.clearStore=function(t){return t===void 0&&(t=!0),this.clearChoices(t,!0),this._stopSearch(),this._lastAddedChoiceId=0,this._lastAddedGroupId=0,this},r.prototype.clearInput=function(){var t=!this._isSelectOneElement;return this.input.clear(t),this._stopSearch(),this},r.prototype._validateConfig=function(){var t=this.config,e=ru(t,Oa);e.length&&console.warn("Unknown config option(s) passed",e.join(", ")),t.allowHTML&&t.allowHtmlUserInput&&(t.addItems&&console.warn("Warning: allowHTML/allowHtmlUserInput/addItems all being true is strongly not recommended and may lead to XSS attacks"),t.addChoices&&console.warn("Warning: allowHTML/allowHtmlUserInput/addChoices all being true is strongly not recommended and may lead to XSS attacks"))},r.prototype._render=function(t){t===void 0&&(t={choices:!0,groups:!0,items:!0}),!this._store.inTxn()&&(this._isSelectElement&&(t.choices||t.groups)&&this._renderChoices(),t.items&&this._renderItems())},r.prototype._renderChoices=function(){var t=this;if(this._canAddItems()){var e=this,i=e.config,s=e._isSearching,n=this._store,o=n.activeGroups,a=n.activeChoices,l=0;if(s&&i.searchResultLimit>0?l=i.searchResultLimit:i.renderChoiceLimit>0&&(l=i.renderChoiceLimit),this._isSelectElement){var c=a.filter(function(g){return!g.element});c.length&&this.passedElement.addOptions(c)}var h=document.createDocumentFragment(),d=function(g){return g.filter(function(f){return!f.placeholder&&(s?!!f.rank:i.renderSelectedChoices||!f.selected)})},u=!1,p=function(g,f,m){s?g.sort(iu):i.shouldSort&&g.sort(i.sorter);var b=g.length;b=!f&&l&&b>l?l:b,b--,g.every(function(_,w){var S=_.choiceEl||t._templates.choice(i,_,i.itemSelectText,m);return _.choiceEl=S,h.appendChild(S),(s||!_.selected)&&(u=!0),w<b})};a.length&&(i.resetScrollPosition&&requestAnimationFrame(function(){return t.choiceList.scrollToTop()}),!this._hasNonChoicePlaceholder&&!s&&this._isSelectOneElement&&p(a.filter(function(g){return g.placeholder&&!g.group}),!1,void 0),o.length&&!s?(i.shouldSort&&o.sort(i.sorter),p(a.filter(function(g){return!g.placeholder&&!g.group}),!1,void 0),o.forEach(function(g){var f=d(g.choices);if(f.length){if(g.label){var m=g.groupEl||t._templates.choiceGroup(t.config,g);g.groupEl=m,m.remove(),h.appendChild(m)}p(f,!0,i.appendGroupInSearch&&s?g.label:void 0)}})):p(d(a),!1,void 0)),!u&&(s||!h.children.length||!i.renderSelectedChoices)&&(this._notice||(this._notice={text:Sa(s?i.noResultsText:i.noChoicesText),type:s?jt.noResults:jt.noChoices}),h.replaceChildren("")),this._renderNotice(h),this.choiceList.element.replaceChildren(h),u&&this._highlightChoice()}},r.prototype._renderItems=function(){var t=this,e=this._store.items||[],i=this.itemList.element,s=this.config,n=document.createDocumentFragment(),o=function(d){return i.querySelector('[data-item][data-id="'.concat(d.id,'"]'))},a=function(d){var u=d.itemEl;u&&u.parentElement||(u=o(d)||t._templates.item(s,d,s.removeItemButton),d.itemEl=u,n.appendChild(u))};e.forEach(a);var l=!!n.childNodes.length;if(this._isSelectOneElement){var c=i.children.length;if(l||c>1){var h=i.querySelector(ms(s.classNames.placeholder));h&&h.remove()}else!l&&!c&&this._placeholderValue&&(l=!0,a(Me({selected:!0,value:"",label:this._placeholderValue,placeholder:!0},!1)))}l&&(i.append(n),s.shouldSortItems&&!this._isSelectOneElement&&(e.sort(s.sorter),e.forEach(function(d){var u=o(d);u&&(u.remove(),n.append(u))}),i.append(n))),this._isTextElement&&(this.passedElement.value=e.map(function(d){var u=d.value;return u}).join(s.delimiter))},r.prototype._displayNotice=function(t,e,i){i===void 0&&(i=!0);var s=this._notice;if(s&&(s.type===e&&s.text===t||s.type===jt.addChoice&&(e===jt.noResults||e===jt.noChoices))){i&&this.showDropdown(!0);return}this._clearNotice(),this._notice=t?{text:t,type:e}:void 0,this._renderNotice(),i&&t&&this.showDropdown(!0)},r.prototype._clearNotice=function(){if(this._notice){var t=this.choiceList.element.querySelector(ms(this.config.classNames.notice));t&&t.remove(),this._notice=void 0}},r.prototype._renderNotice=function(t){var e=this._notice;if(e){var i=this._templates.notice(this.config,e.text,e.type);t?t.append(i):this.choiceList.prepend(i)}},r.prototype._getChoiceForOutput=function(t,e){return{id:t.id,highlighted:t.highlighted,labelClass:t.labelClass,labelDescription:t.labelDescription,customProperties:t.customProperties,disabled:t.disabled,active:t.active,label:t.label,placeholder:t.placeholder,value:t.value,groupValue:t.group?t.group.label:void 0,element:t.element,keyCode:e}},r.prototype._triggerChange=function(t){t!=null&&this.passedElement.triggerEvent(Zt.change,{value:t})},r.prototype._handleButtonAction=function(t){var e=this,i=this._store.items;if(!(!i.length||!this.config.removeItems||!this.config.removeItemButton)){var s=t&&An(t.parentElement),n=s&&i.find(function(o){return o.id===s});n&&this._store.withTxn(function(){if(e._removeItem(n),e._triggerChange(n.value),e._isSelectOneElement&&!e._hasNonChoicePlaceholder){var o=(e.config.shouldSort?e._store.choices.reverse():e._store.choices).find(function(a){return a.placeholder});o&&(e._addItem(o),e.unhighlightAll(),o.value&&e._triggerChange(o.value))}})}},r.prototype._handleItemAction=function(t,e){var i=this;e===void 0&&(e=!1);var s=this._store.items;if(!(!s.length||!this.config.removeItems||this._isSelectOneElement)){var n=An(t);n&&(s.forEach(function(o){o.id===n&&!o.highlighted?i.highlightItem(o):!e&&o.highlighted&&i.unhighlightItem(o)}),this.input.focus())}},r.prototype._handleChoiceAction=function(t){var e=this,i=An(t),s=i&&this._store.getChoiceById(i);if(!s||s.disabled)return!1;var n=this.dropdown.isActive;if(!s.selected){if(!this._canAddItems())return!0;this._store.withTxn(function(){e._addItem(s,!0,!0),e.clearInput(),e.unhighlightAll()}),this._triggerChange(s.value)}return n&&this.config.closeDropdownOnSelect&&(this.hideDropdown(!0),this.containerOuter.element.focus()),!0},r.prototype._handleBackspace=function(t){var e=this.config;if(!(!e.removeItems||!t.length)){var i=t[t.length-1],s=t.some(function(n){return n.highlighted});e.editItems&&!s&&i?(this.input.value=i.value,this.input.setWidth(),this._removeItem(i),this._triggerChange(i.value)):(s||this.highlightItem(i,!1),this.removeHighlightedItems(!0))}},r.prototype._loadChoices=function(){var t,e=this,i=this.config;if(this._isTextElement){if(this._presetChoices=i.items.map(function(o){return Me(o,!1)}),this.passedElement.value){var s=this.passedElement.value.split(i.delimiter).map(function(o){return Me(o,!1,e.config.allowHtmlUserInput)});this._presetChoices=this._presetChoices.concat(s)}this._presetChoices.forEach(function(o){o.selected=!0})}else if(this._isSelectElement){this._presetChoices=i.choices.map(function(o){return Me(o,!0)});var n=this.passedElement.optionsAsChoices();n&&(t=this._presetChoices).push.apply(t,n)}},r.prototype._handleLoadingState=function(t){t===void 0&&(t=!0);var e=this.itemList.element;t?(this.disable(),this.containerOuter.addLoadingState(),this._isSelectOneElement?e.replaceChildren(this._templates.placeholder(this.config,this.config.loadingText)):this.input.placeholder=this.config.loadingText):(this.enable(),this.containerOuter.removeLoadingState(),this._isSelectOneElement?(e.replaceChildren(""),this._render()):this.input.placeholder=this._placeholderValue||"")},r.prototype._handleSearch=function(t){if(this.input.isFocussed)if(t!==null&&typeof t<"u"&&t.length>=this.config.searchFloor){var e=this.config.searchChoices?this._searchChoices(t):0;e!==null&&this.passedElement.triggerEvent(Zt.search,{value:t,resultCount:e})}else this._store.choices.some(function(i){return!i.active})&&this._stopSearch()},r.prototype._canAddItems=function(){var t=this.config,e=t.maxItemCount,i=t.maxItemText;return!t.singleModeForMultiSelect&&e>0&&e<=this._store.items.length?(this.choiceList.element.replaceChildren(""),this._notice=void 0,this._displayNotice(typeof i=="function"?i(e):i,jt.addChoice),!1):(this._notice&&this._notice.type===jt.addChoice&&this._clearNotice(),!0)},r.prototype._canCreateItem=function(t){var e=this.config,i=!0,s="";if(i&&typeof e.addItemFilter=="function"&&!e.addItemFilter(t)&&(i=!1,s=As(e.customAddItemText,t)),i){var n=this._store.choices.find(function(o){return e.valueComparer(o.value,t)});if(n){if(this._isSelectElement)return this._displayNotice("",jt.addChoice),!1;e.duplicateItemsAllowed||(i=!1,s=As(e.uniqueItemText,t))}}return i&&(s=As(e.addItemText,t)),s&&this._displayNotice(s,jt.addChoice),i},r.prototype._searchChoices=function(t){var e=t.trim().replace(/\s{2,}/," ");if(!e.length||e===this._currentValue)return null;var i=this._searcher;i.isEmptyIndex()&&i.index(this._store.searchableChoices);var s=i.search(e);this._currentValue=e,this._highlightPosition=0,this._isSearching=!0;var n=this._notice,o=n&&n.type;return o!==jt.addChoice&&(s.length?this._clearNotice():this._displayNotice(Sa(this.config.noResultsText),jt.noResults)),this._store.dispatch(Gd(s)),s.length},r.prototype._stopSearch=function(){this._isSearching&&(this._currentValue="",this._isSearching=!1,this._clearNotice(),this._store.dispatch(Xd(!0)),this.passedElement.triggerEvent(Zt.search,{value:"",resultCount:0}))},r.prototype._addEventListeners=function(){var t=this._docRoot,e=this.containerOuter.element,i=this.input.element;t.addEventListener("touchend",this._onTouchEnd,!0),e.addEventListener("keydown",this._onKeyDown,!0),e.addEventListener("mousedown",this._onMouseDown,!0),t.addEventListener("click",this._onClick,{passive:!0}),t.addEventListener("touchmove",this._onTouchMove,{passive:!0}),this.dropdown.element.addEventListener("mouseover",this._onMouseOver,{passive:!0}),this._isSelectOneElement&&(e.addEventListener("focus",this._onFocus,{passive:!0}),e.addEventListener("blur",this._onBlur,{passive:!0})),i.addEventListener("keyup",this._onKeyUp,{passive:!0}),i.addEventListener("input",this._onInput,{passive:!0}),i.addEventListener("focus",this._onFocus,{passive:!0}),i.addEventListener("blur",this._onBlur,{passive:!0}),i.form&&i.form.addEventListener("reset",this._onFormReset,{passive:!0}),this.input.addEventListeners()},r.prototype._removeEventListeners=function(){var t=this._docRoot,e=this.containerOuter.element,i=this.input.element;t.removeEventListener("touchend",this._onTouchEnd,!0),e.removeEventListener("keydown",this._onKeyDown,!0),e.removeEventListener("mousedown",this._onMouseDown,!0),t.removeEventListener("click",this._onClick),t.removeEventListener("touchmove",this._onTouchMove),this.dropdown.element.removeEventListener("mouseover",this._onMouseOver),this._isSelectOneElement&&(e.removeEventListener("focus",this._onFocus),e.removeEventListener("blur",this._onBlur)),i.removeEventListener("keyup",this._onKeyUp),i.removeEventListener("input",this._onInput),i.removeEventListener("focus",this._onFocus),i.removeEventListener("blur",this._onBlur),i.form&&i.form.removeEventListener("reset",this._onFormReset),this.input.removeEventListeners()},r.prototype._onKeyDown=function(t){var e=t.keyCode,i=this.dropdown.isActive,s=t.key.length===1||t.key.length===2&&t.key.charCodeAt(0)>=55296||t.key==="Unidentified";switch(!this._isTextElement&&!i&&e!==zt.ESC_KEY&&e!==zt.TAB_KEY&&e!==zt.SHIFT_KEY&&(this.showDropdown(),!this.input.isFocussed&&s&&(this.input.value+=t.key,t.key===" "&&t.preventDefault())),e){case zt.A_KEY:return this._onSelectKey(t,this.itemList.element.hasChildNodes());case zt.ENTER_KEY:return this._onEnterKey(t,i);case zt.ESC_KEY:return this._onEscapeKey(t,i);case zt.UP_KEY:case zt.PAGE_UP_KEY:case zt.DOWN_KEY:case zt.PAGE_DOWN_KEY:return this._onDirectionKey(t,i);case zt.DELETE_KEY:case zt.BACK_KEY:return this._onDeleteKey(t,this._store.items,this.input.isFocussed)}},r.prototype._onKeyUp=function(){this._canSearch=this.config.searchEnabled},r.prototype._onInput=function(){var t=this.input.value;if(!t){this._isTextElement?this.hideDropdown(!0):this._stopSearch();return}this._canAddItems()&&(this._canSearch&&this._handleSearch(t),this._canAddUserChoices&&(this._canCreateItem(t),this._isSelectElement&&(this._highlightPosition=0,this._highlightChoice())))},r.prototype._onSelectKey=function(t,e){if((t.ctrlKey||t.metaKey)&&e){this._canSearch=!1;var i=this.config.removeItems&&!this.input.value&&this.input.element===document.activeElement;i&&this.highlightAll()}},r.prototype._onEnterKey=function(t,e){var i=this,s=this.input.value,n=t.target;if(t.preventDefault(),n&&n.hasAttribute("data-button")){this._handleButtonAction(n);return}if(!e){(this._isSelectElement||this._notice)&&this.showDropdown();return}var o=this.dropdown.element.querySelector(ms(this.config.classNames.highlightedState));if(!(o&&this._handleChoiceAction(o))){if(!n||!s){this.hideDropdown(!0);return}if(this._canAddItems()){var a=!1;this._store.withTxn(function(){if(a=i._findAndSelectChoiceByValue(s,!0),!a){if(!i._canAddUserChoices||!i._canCreateItem(s))return;i._addChoice(Me(s,!1,i.config.allowHtmlUserInput),!0,!0),a=!0}i.clearInput(),i.unhighlightAll()}),a&&(this._triggerChange(s),this.config.closeDropdownOnSelect&&this.hideDropdown(!0))}}},r.prototype._onEscapeKey=function(t,e){e&&(t.stopPropagation(),this.hideDropdown(!0),this._stopSearch(),this.containerOuter.element.focus())},r.prototype._onDirectionKey=function(t,e){var i=t.keyCode;if(e||this._isSelectOneElement){this.showDropdown(),this._canSearch=!1;var s=i===zt.DOWN_KEY||i===zt.PAGE_DOWN_KEY?1:-1,n=t.metaKey||i===zt.PAGE_DOWN_KEY||i===zt.PAGE_UP_KEY,o=void 0;if(n)s>0?o=this.dropdown.element.querySelector("".concat(bs,":last-of-type")):o=this.dropdown.element.querySelector(bs);else{var a=this.dropdown.element.querySelector(ms(this.config.classNames.highlightedState));a?o=Jd(a,bs,s):o=this.dropdown.element.querySelector(bs)}o&&(Qd(o,this.choiceList.element,s)||this.choiceList.scrollToChildElement(o,s),this._highlightChoice(o)),t.preventDefault()}},r.prototype._onDeleteKey=function(t,e,i){!this._isSelectOneElement&&!t.target.value&&i&&(this._handleBackspace(e),t.preventDefault())},r.prototype._onTouchMove=function(){this._wasTap&&(this._wasTap=!1)},r.prototype._onTouchEnd=function(t){var e=(t||t.touches[0]).target,i=this._wasTap&&this.containerOuter.element.contains(e);if(i){var s=e===this.containerOuter.element||e===this.containerInner.element;s&&(this._isTextElement?this.input.focus():this._isSelectMultipleElement&&this.showDropdown()),t.stopPropagation()}this._wasTap=!0},r.prototype._onMouseDown=function(t){var e=t.target;if(e instanceof HTMLElement){if(up&&this.choiceList.element.contains(e)){var i=this.choiceList.element.firstElementChild;this._isScrollingOnIe=this._direction==="ltr"?t.offsetX>=i.offsetWidth:t.offsetX<i.offsetLeft}if(e!==this.input.element){var s=e.closest("[data-button],[data-item],[data-choice]");s instanceof HTMLElement&&("button"in s.dataset?this._handleButtonAction(s):"item"in s.dataset?this._handleItemAction(s,t.shiftKey):"choice"in s.dataset&&this._handleChoiceAction(s)),t.preventDefault()}}},r.prototype._onMouseOver=function(t){var e=t.target;e instanceof HTMLElement&&"choice"in e.dataset&&this._highlightChoice(e)},r.prototype._onClick=function(t){var e=t.target,i=this.containerOuter,s=i.element.contains(e);s?!this.dropdown.isActive&&!i.isDisabled?this._isTextElement?document.activeElement!==this.input.element&&this.input.focus():(this.showDropdown(),i.element.focus()):this._isSelectOneElement&&e!==this.input.element&&!this.dropdown.element.contains(e)&&this.hideDropdown():(i.removeFocusState(),this.hideDropdown(!0),this.unhighlightAll())},r.prototype._onFocus=function(t){var e=t.target,i=this.containerOuter,s=e&&i.element.contains(e);if(s){var n=e===this.input.element;this._isTextElement?n&&i.addFocusState():this._isSelectMultipleElement?n&&(this.showDropdown(!0),i.addFocusState()):(i.addFocusState(),n&&this.showDropdown(!0))}},r.prototype._onBlur=function(t){var e=t.target,i=this.containerOuter,s=e&&i.element.contains(e);s&&!this._isScrollingOnIe?e===this.input.element?(i.removeFocusState(),this.hideDropdown(!0),(this._isTextElement||this._isSelectMultipleElement)&&this.unhighlightAll()):e===this.containerOuter.element&&(i.removeFocusState(),this._canSearch||this.hideDropdown(!0)):(this._isScrollingOnIe=!1,this.input.element.focus())},r.prototype._onFormReset=function(){var t=this;this._store.withTxn(function(){t.clearInput(),t.hideDropdown(),t.refresh(!1,!1,!0),t._initialItems.length&&t.setChoiceByValue(t._initialItems)})},r.prototype._highlightChoice=function(t){t===void 0&&(t=null);var e=Array.from(this.dropdown.element.querySelectorAll(bs));if(e.length){var i=t,s=this.config.classNames.highlightedState,n=Array.from(this.dropdown.element.querySelectorAll(ms(s)));n.forEach(function(o){Ie(o,s),o.setAttribute("aria-selected","false")}),i?this._highlightPosition=e.indexOf(i):(e.length>this._highlightPosition?i=e[this._highlightPosition]:i=e[e.length-1],i||(i=e[0])),B(i,s),i.setAttribute("aria-selected","true"),this.passedElement.triggerEvent(Zt.highlightChoice,{el:i}),this.dropdown.isActive&&(this.input.setActiveDescendant(i.id),this.containerOuter.setActiveDescendant(i.id))}},r.prototype._addItem=function(t,e,i){if(e===void 0&&(e=!0),i===void 0&&(i=!1),!t.id)throw new TypeError("item.id must be set before _addItem is called for a choice/item");(this.config.singleModeForMultiSelect||this._isSelectOneElement)&&this.removeActiveItems(t.id),this._store.dispatch(xa(t)),e&&(this.passedElement.triggerEvent(Zt.addItem,this._getChoiceForOutput(t)),i&&this.passedElement.triggerEvent(Zt.choice,this._getChoiceForOutput(t)))},r.prototype._removeItem=function(t){if(t.id){this._store.dispatch(wa(t));var e=this._notice;e&&e.type===jt.noChoices&&this._clearNotice(),this.passedElement.triggerEvent(Zt.removeItem,this._getChoiceForOutput(t))}},r.prototype._addChoice=function(t,e,i){if(e===void 0&&(e=!0),i===void 0&&(i=!1),t.id)throw new TypeError("Can not re-add a choice which has already been added");var s=this.config;if(!(!s.duplicateItemsAllowed&&this._store.choices.find(function(a){return s.valueComparer(a.value,t.value)}))){this._lastAddedChoiceId++,t.id=this._lastAddedChoiceId,t.elementId="".concat(this._baseId,"-").concat(this._idNames.itemChoice,"-").concat(t.id);var n=s.prependValue,o=s.appendValue;n&&(t.value=n+t.value),o&&(t.value+=o.toString()),(n||o)&&t.element&&(t.element.value=t.value),this._clearNotice(),this._store.dispatch(_a(t)),t.selected&&this._addItem(t,e,i)}},r.prototype._addGroup=function(t,e){var i=this;if(e===void 0&&(e=!0),t.id)throw new TypeError("Can not re-add a group which has already been added");this._store.dispatch(qd(t)),t.choices&&(this._lastAddedGroupId++,t.id=this._lastAddedGroupId,t.choices.forEach(function(s){s.group=t,t.disabled&&(s.disabled=!0),i._addChoice(s,e)}))},r.prototype._createTemplates=function(){var t=this,e=this.config.callbackOnCreateTemplates,i={};typeof e=="function"&&(i=e.call(this,tu,ko,nn));var s={};Object.keys(this._templates).forEach(function(n){n in i?s[n]=i[n].bind(t):s[n]=t._templates[n].bind(t)}),this._templates=s},r.prototype._createElements=function(){var t=this._templates,e=this,i=e.config,s=e._isSelectOneElement,n=i.position,o=i.classNames,a=this._elementType;this.containerOuter=new Ta({element:t.containerOuter(i,this._direction,this._isSelectElement,s,i.searchEnabled,a,i.labelId),classNames:o,type:a,position:n}),this.containerInner=new Ta({element:t.containerInner(i),classNames:o,type:a,position:n}),this.input=new lu({element:t.input(i,this._placeholderValue),classNames:o,type:a,preventPaste:!i.paste}),this.choiceList=new Ea({element:t.choiceList(i,s)}),this.itemList=new Ea({element:t.itemList(i,s)}),this.dropdown=new au({element:t.dropdown(i),classNames:o,type:a})},r.prototype._createStructure=function(){var t=this,e=t.containerInner,i=t.containerOuter,s=t.passedElement,n=this.dropdown.element;s.conceal(),e.wrap(s.element),i.wrap(e.element),this._isSelectOneElement?this.input.placeholder=this.config.searchPlaceholderValue||"":(this._placeholderValue&&(this.input.placeholder=this._placeholderValue),this.input.setWidth()),i.element.appendChild(e.element),i.element.appendChild(n),e.element.appendChild(this.itemList.element),n.appendChild(this.choiceList.element),this._isSelectOneElement?this.config.searchEnabled&&n.insertBefore(this.input.element,n.firstChild):e.element.appendChild(this.input.element),this._highlightPosition=0,this._isSearching=!1},r.prototype._initStore=function(){var t=this;this._store.subscribe(this._render).withTxn(function(){t._addPredefinedChoices(t._presetChoices,t._isSelectOneElement&&!t._hasNonChoicePlaceholder,!1)}),(!this._store.choices.length||this._isSelectOneElement&&this._hasNonChoicePlaceholder)&&this._render()},r.prototype._addPredefinedChoices=function(t,e,i){var s=this;if(e===void 0&&(e=!1),i===void 0&&(i=!0),e){var n=t.findIndex(function(o){return o.selected})===-1;n&&t.some(function(o){return o.disabled||"choices"in o?!1:(o.selected=!0,!0)})}t.forEach(function(o){"choices"in o?s._isSelectElement&&s._addGroup(o,i):s._addChoice(o,i)})},r.prototype._findAndSelectChoiceByValue=function(t,e){var i=this;e===void 0&&(e=!1);var s=this._store.choices.find(function(n){return i.config.valueComparer(n.value,t)});return s&&!s.disabled&&!s.selected?(this._addItem(s,!0,e),!0):!1},r.prototype._generatePlaceholderValue=function(){var t=this.config;if(!t.placeholder)return null;if(this._hasNonChoicePlaceholder)return t.placeholderValue;if(this._isSelectElement){var e=this.passedElement.placeholderOption;return e?e.text:null}return null},r.prototype._warnChoicesInitFailed=function(t){if(!this.config.silent)if(this.initialised){if(!this.initialisedOK)throw new TypeError("".concat(t," called for an element which has multiple instances of Choices initialised on it"))}else throw new TypeError("".concat(t," called on a non-initialised instance of Choices"))},r.version="11.1.0",r})();const oc='.choices{position:relative;overflow:hidden;margin-bottom:24px;font-size:16px}.choices:focus{outline:none}.choices:last-child{margin-bottom:0}.choices.is-open{overflow:visible}.choices.is-disabled .choices__inner,.choices.is-disabled .choices__input{background-color:#eaeaea;cursor:not-allowed;-webkit-user-select:none;user-select:none}.choices.is-disabled .choices__item{cursor:not-allowed}.choices [hidden]{display:none!important}.choices[data-type*=select-one]{cursor:pointer}.choices[data-type*=select-one] .choices__inner{padding-bottom:7.5px}.choices[data-type*=select-one] .choices__input{display:block;width:100%;padding:10px;border-bottom:1px solid #ddd;background-color:#fff;margin:0}.choices[data-type*=select-one] .choices__button{background-image:url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMjEiIGhlaWdodD0iMjEiIHZpZXdCb3g9IjAgMCAyMSAyMSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48ZyBmaWxsPSIjMDAwIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiPjxwYXRoIGQ9Ik0yLjU5Mi4wNDRsMTguMzY0IDE4LjM2NC0yLjU0OCAyLjU0OEwuMDQ0IDIuNTkyeiIvPjxwYXRoIGQ9Ik0wIDE4LjM2NEwxOC4zNjQgMGwyLjU0OCAyLjU0OEwyLjU0OCAyMC45MTJ6Ii8+PC9nPjwvc3ZnPg==);padding:0;background-size:8px;position:absolute;top:50%;right:0;margin-top:-10px;margin-right:25px;height:20px;width:20px;border-radius:10em;opacity:.25}.choices[data-type*=select-one] .choices__button:hover,.choices[data-type*=select-one] .choices__button:focus{opacity:1}.choices[data-type*=select-one] .choices__button:focus{box-shadow:0 0 0 2px #005f75}.choices[data-type*=select-one] .choices__item[data-placeholder] .choices__button{display:none}.choices[data-type*=select-one]:after{content:"";height:0;width:0;border-style:solid;border-color:#333 transparent transparent transparent;border-width:5px;position:absolute;right:11.5px;top:50%;margin-top:-2.5px;pointer-events:none}.choices[data-type*=select-one].is-open:after{border-color:transparent transparent #333;margin-top:-7.5px}.choices[data-type*=select-one][dir=rtl]:after{left:11.5px;right:auto}.choices[data-type*=select-one][dir=rtl] .choices__button{right:auto;left:0;margin-left:25px;margin-right:0}.choices[data-type*=select-multiple] .choices__inner,.choices[data-type*=text] .choices__inner{cursor:text}.choices[data-type*=select-multiple] .choices__button,.choices[data-type*=text] .choices__button{position:relative;display:inline-block;margin:0 -4px 0 8px;padding-left:16px;border-left:1px solid #003642;background-image:url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMjEiIGhlaWdodD0iMjEiIHZpZXdCb3g9IjAgMCAyMSAyMSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48ZyBmaWxsPSIjRkZGIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiPjxwYXRoIGQ9Ik0yLjU5Mi4wNDRsMTguMzY0IDE4LjM2NC0yLjU0OCAyLjU0OEwuMDQ0IDIuNTkyeiIvPjxwYXRoIGQ9Ik0wIDE4LjM2NEwxOC4zNjQgMGwyLjU0OCAyLjU0OEwyLjU0OCAyMC45MTJ6Ii8+PC9nPjwvc3ZnPg==);background-size:8px;width:8px;line-height:1;opacity:.75;border-radius:0}.choices[data-type*=select-multiple] .choices__button:hover,.choices[data-type*=select-multiple] .choices__button:focus,.choices[data-type*=text] .choices__button:hover,.choices[data-type*=text] .choices__button:focus{opacity:1}.choices__inner{display:inline-block;vertical-align:top;width:100%;background-color:#f9f9f9;padding:7.5px 7.5px 3.75px;border:1px solid #ddd;border-radius:2.5px;font-size:14px;min-height:44px;overflow:hidden}.is-focused .choices__inner,.is-open .choices__inner{border-color:#b7b7b7}.is-open .choices__inner{border-radius:2.5px 2.5px 0 0}.is-flipped.is-open .choices__inner{border-radius:0 0 2.5px 2.5px}.choices__list{margin:0;padding-left:0;list-style:none}.choices__list--single{display:inline-block;padding:4px 16px 4px 4px;width:100%}[dir=rtl] .choices__list--single{padding-right:4px;padding-left:16px}.choices__list--single .choices__item{width:100%}.choices__list--multiple{display:inline}.choices__list--multiple .choices__item{display:inline-block;vertical-align:middle;border-radius:20px;padding:4px 10px;font-size:12px;font-weight:500;margin-right:3.75px;margin-bottom:3.75px;background-color:#005f75;border:1px solid #004a5c;color:#fff;word-break:break-all;box-sizing:border-box}.choices__list--multiple .choices__item[data-deletable]{padding-right:5px}[dir=rtl] .choices__list--multiple .choices__item{margin-right:0;margin-left:3.75px}.choices__list--multiple .choices__item.is-highlighted{background-color:#004a5c;border:1px solid #003642}.is-disabled .choices__list--multiple .choices__item{background-color:#aaa;border:1px solid #919191}.choices__list--dropdown,.choices__list[aria-expanded]{display:none;z-index:1;position:absolute;width:100%;background-color:#fff;border:1px solid #ddd;top:100%;margin-top:-1px;border-bottom-left-radius:2.5px;border-bottom-right-radius:2.5px;overflow:hidden;word-break:break-all}.is-active.choices__list--dropdown,.is-active.choices__list[aria-expanded]{display:block}.is-open .choices__list--dropdown,.is-open .choices__list[aria-expanded]{border-color:#b7b7b7}.is-flipped .choices__list--dropdown,.is-flipped .choices__list[aria-expanded]{top:auto;bottom:100%;margin-top:0;margin-bottom:-1px;border-radius:.25rem .25rem 0 0}.choices__list--dropdown .choices__list,.choices__list[aria-expanded] .choices__list{position:relative;max-height:300px;overflow:auto;-webkit-overflow-scrolling:touch;will-change:scroll-position}.choices__list--dropdown .choices__item,.choices__list[aria-expanded] .choices__item{position:relative;padding:10px;font-size:14px}[dir=rtl] .choices__list--dropdown .choices__item,[dir=rtl] .choices__list[aria-expanded] .choices__item{text-align:right}@media(min-width:640px){.choices__list--dropdown .choices__item--selectable[data-select-text],.choices__list[aria-expanded] .choices__item--selectable[data-select-text]{padding-right:100px}.choices__list--dropdown .choices__item--selectable[data-select-text]:after,.choices__list[aria-expanded] .choices__item--selectable[data-select-text]:after{content:attr(data-select-text);font-size:12px;opacity:0;position:absolute;right:10px;top:50%;transform:translateY(-50%)}[dir=rtl] .choices__list--dropdown .choices__item--selectable[data-select-text],[dir=rtl] .choices__list[aria-expanded] .choices__item--selectable[data-select-text]{text-align:right;padding-left:100px;padding-right:10px}[dir=rtl] .choices__list--dropdown .choices__item--selectable[data-select-text]:after,[dir=rtl] .choices__list[aria-expanded] .choices__item--selectable[data-select-text]:after{right:auto;left:10px}}.choices__list--dropdown .choices__item--selectable.is-highlighted,.choices__list[aria-expanded] .choices__item--selectable.is-highlighted{background-color:#f2f2f2}.choices__list--dropdown .choices__item--selectable.is-highlighted:after,.choices__list[aria-expanded] .choices__item--selectable.is-highlighted:after{opacity:.5}.choices__item{cursor:default}.choices__item--selectable{cursor:pointer}.choices__item--disabled{cursor:not-allowed;-webkit-user-select:none;user-select:none;opacity:.5}.choices__heading{font-weight:600;font-size:12px;padding:10px;border-bottom:1px solid #f7f7f7;color:gray}.choices__button{text-indent:-9999px;-webkit-appearance:none;-moz-appearance:none;appearance:none;border:0;background-color:transparent;background-repeat:no-repeat;background-position:center;cursor:pointer}.choices__button:focus{outline:none}.choices__input{display:inline-block;vertical-align:baseline;background-color:#f9f9f9;font-size:14px;margin-bottom:5px;border:0;border-radius:0;max-width:100%;padding:4px 0 4px 2px}.choices__input:focus{outline:0}.choices__input::-webkit-search-decoration,.choices__input::-webkit-search-cancel-button,.choices__input::-webkit-search-results-button,.choices__input::-webkit-search-results-decoration{display:none}.choices__input::-ms-clear,.choices__input::-ms-reveal{display:none;width:0;height:0}[dir=rtl] .choices__input{padding-right:2px;padding-left:0}.choices__placeholder{opacity:.5}',qs=gt`
|
|
1452
1452
|
.form-control .form-control__label {
|
|
1453
1453
|
display: none;
|
|
1454
1454
|
}
|
|
@@ -1504,7 +1504,7 @@
|
|
|
1504
1504
|
.form-control--has-help-text.form-control--radio-group .form-control__help-text {
|
|
1505
1505
|
margin-top: var(--pbo-spacing-2x);
|
|
1506
1506
|
}
|
|
1507
|
-
`;var
|
|
1507
|
+
`;var gp=Object.defineProperty,fp=Object.getOwnPropertyDescriptor,Bi=(r,t,e,i)=>{for(var s=i>1?void 0:i?fp(t,e):t,n=r.length-1,o;n>=0;n--)(o=r[n])&&(s=(i?o(t,e,s):o(s))||s);return i&&s&&gp(t,e,s),s};let $e=class extends kt{constructor(){super(...arguments),this.hasSlotController=new Xs(this,"help-text","label"),this.fonts=[{value:"comic",label:"🖊️ Comic Sans",font:"'Comic Sans MS', cursive"},{value:"times",label:"🔤 Times New Roman",font:"'Times New Roman', serif"},{value:"arial",label:"📜 Arial",font:"'Arial', sans-serif"},{value:"mono",label:"💻 Monospace",font:"'Courier New', monospace"}],this.disabled=!1,this.size="medium",this.label="",this._handleDocumentClick=r=>{var e;const t=r.composedPath();this&&!t.includes(this)&&((e=this._choices)==null||e.hideDropdown())}}get value(){var r;return(r=this._choices)==null?void 0:r.getValue().value}handleDisabledChanged(){var r;this._choices&&this.disabled?this._choices.disable():(r=this._choices)==null||r.enable()}firstUpdated(){this._initializeChoices(),this.handleDisabledChanged(),document.addEventListener("click",this._handleDocumentClick,!0)}disconnectedCallback(){super.disconnectedCallback(),document.removeEventListener("click",this._handleDocumentClick,!0)}_initializeChoices(){var r;(r=this._choices)==null||r.destroy(),this._choices=new nc(this.choiceEl,{allowHTML:!0,searchEnabled:!1,shouldSort:!1,removeItemButton:!1,shadowRoot:this.shadowRoot,choices:this.fonts.map((t,e)=>({value:t.value,label:t.label,customProperties:{font:t.font},selected:e===0})),placeholder:!1,shouldSortItems:!1,itemSelectText:"",callbackOnCreateTemplates:function(t,e,i){return{item:({classNames:s},n)=>{var a;const o=[i(s.item).join(" "),i(n.highlighted?s.highlightedState:s.itemSelectable).join(" ")].join(" ");return t(`
|
|
1508
1508
|
<div
|
|
1509
1509
|
class="${o}"
|
|
1510
1510
|
data-item
|
|
@@ -1539,7 +1539,7 @@
|
|
|
1539
1539
|
<slot name="label">${this.label}</slot>
|
|
1540
1540
|
</label>
|
|
1541
1541
|
</div>
|
|
1542
|
-
<select part="base" class="js-choice"></select>`}};$e.styles=[Ot,
|
|
1542
|
+
<select part="base" class="js-choice"></select>`}};$e.styles=[Ot,Nd,qs,Kr(oc)];Bi([C({type:Array})],$e.prototype,"fonts",2);Bi([C({type:Boolean,reflect:!0})],$e.prototype,"disabled",2);Bi([C()],$e.prototype,"size",2);Bi([C()],$e.prototype,"label",2);Bi([z(".js-choice")],$e.prototype,"choiceEl",2);Bi([it("disabled",{waitUntilFirstUpdate:!0})],$e.prototype,"handleDisabledChanged",1);$e=Bi([Et("pbo-font-selector")],$e);const mp=gt`
|
|
1543
1543
|
:host {
|
|
1544
1544
|
display: block;
|
|
1545
1545
|
position: relative;
|
|
@@ -1728,11 +1728,11 @@
|
|
|
1728
1728
|
* @license
|
|
1729
1729
|
* Copyright 2020 Google LLC
|
|
1730
1730
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
1731
|
-
*/const{I:
|
|
1731
|
+
*/const{I:bp}=Vh,$a=r=>r,Ra=(r,t)=>(r==null?void 0:r._$litType$)!==void 0,vp=r=>{var t;return((t=r==null?void 0:r._$litType$)==null?void 0:t.h)!=null},yp=r=>r.strings===void 0,Ba=()=>document.createComment(""),za=(r,t,e)=>{var n;const i=r._$AA.parentNode,s=r._$AB;if(e===void 0){const o=i.insertBefore(Ba(),s),a=i.insertBefore(Ba(),s);e=new bp(o,a,r,r.options)}else{const o=e._$AB.nextSibling,a=e._$AM,l=a!==r;if(l){let c;(n=e._$AQ)==null||n.call(e,r),e._$AM=r,e._$AP!==void 0&&(c=r._$AU)!==a._$AU&&e._$AP(c)}if(o!==s||l){let c=e._$AA;for(;c!==o;){const h=$a(c).nextSibling;$a(i).insertBefore(c,s),c=h}}}return e},_p={},io=(r,t=_p)=>r._$AH=t,Ha=r=>r._$AH,xp=r=>{r._$AR()};/**
|
|
1732
1732
|
* @license
|
|
1733
1733
|
* Copyright 2020 Google LLC
|
|
1734
1734
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
1735
|
-
*/const
|
|
1735
|
+
*/const wp=tn(class extends en{constructor(r){if(super(r),r.type!==ci.PROPERTY&&r.type!==ci.ATTRIBUTE&&r.type!==ci.BOOLEAN_ATTRIBUTE)throw Error("The `live` directive is not allowed on child or event bindings");if(!yp(r))throw Error("`live` bindings can only contain a single expression")}render(r){return r}update(r,[t]){if(t===fe||t===K)return t;const e=r.element,i=r.name;if(r.type===ci.PROPERTY){if(t===e[i])return fe}else if(r.type===ci.BOOLEAN_ATTRIBUTE){if(!!t===e.hasAttribute(i))return fe}else if(r.type===ci.ATTRIBUTE&&e.getAttribute(i)===t+"")return fe;return io(r),t}});var Cp=Object.defineProperty,Sp=Object.getOwnPropertyDescriptor,It=(r,t,e,i)=>{for(var s=i>1?void 0:i?Sp(t,e):t,n=r.length-1,o;n>=0;n--)(o=r[n])&&(s=(i?o(t,e,s):o(s))||s);return i&&s&&Cp(t,e,s),s};let pt=class extends kt{constructor(){super(...arguments),this.formControlController=new Oo(this,{assumeInteractionOn:["pbo-input"]}),this.hasSlotController=new Xs(this,"help-text"),this.hasFocus=!1,this.name="",this.value="",this.size="medium",this.filled=!1,this.title="",this.placeholder="",this.rows=4,this.resize="vertical",this.disabled=!1,this.readonly=!1,this.form="",this.required=!1,this.helpText=""}get validity(){return this.input.validity}get validationMessage(){return this.input.validationMessage}firstUpdated(){this.formControlController.updateValidity()}handleChange(){const r=this.removeEmojis(this.input.value);r!==this.input.value&&(this.input.value=r),this.value=r,this.emit("pbo-change")}handleBlur(){this.hasFocus=!1,this.emit("pbo-blur")}handleFocus(){this.hasFocus=!0,this.emit("pbo-focus")}handleInput(){const r=this.removeEmojis(this.input.value);if(r!==this.input.value){this.input.value=r;try{this.input.setSelectionRange(r.length,r.length)}catch{}}this.value=r,this.emit("pbo-input")}handleInvalid(r){this.formControlController.setValidity(!1),this.formControlController.emitInvalidEvent(r)}focus(r){this.input.focus(r)}blur(){this.input.blur()}select(){this.input.select()}scrollPosition(r){if(r){typeof r.top=="number"&&(this.input.scrollTop=r.top),typeof r.left=="number"&&(this.input.scrollLeft=r.left);return}return{top:this.input.scrollTop,left:this.input.scrollTop}}setSelectionRange(r,t,e="none"){this.input.setSelectionRange(r,t,e)}setRangeText(r,t,e,i="preserve"){const s=t??this.input.selectionStart,n=e??this.input.selectionEnd;this.input.setRangeText(r,s,n,i),this.value!==this.input.value&&(this.value=this.input.value)}removeEmojis(r){const t=/(\u00a9|\u00ae|[\u2000-\u3300]|\ud83c[\ud000-\udfff]|\ud83d[\ud000-\udfff]|\ud83e[\ud000-\udfff])/g;return r.replace(t,"")}checkValidity(){return this.input.checkValidity()}getForm(){return this.formControlController.getForm()}reportValidity(){return this.input.reportValidity()}setCustomValidity(r){this.input.setCustomValidity(r),this.formControlController.updateValidity()}render(){const r=this.hasSlotController.test("help-text"),t=this.helpText?!0:!!r;return j` <div
|
|
1736
1736
|
part="form-control"
|
|
1737
1737
|
class=${me({"form-control":!0,"form-control--small":this.size==="small","form-control--medium":this.size==="medium","form-control--large":this.size==="large","form-control--has-help-text":t,invalid:!0})}
|
|
1738
1738
|
>
|
|
@@ -1746,15 +1746,15 @@
|
|
|
1746
1746
|
id="input"
|
|
1747
1747
|
class="textarea__control"
|
|
1748
1748
|
title=${this.title}
|
|
1749
|
-
name=${
|
|
1750
|
-
.value=${
|
|
1749
|
+
name=${Ci(this.name)}
|
|
1750
|
+
.value=${wp(this.value)}
|
|
1751
1751
|
?disabled=${this.disabled}
|
|
1752
1752
|
?readonly=${this.readonly}
|
|
1753
1753
|
?required=${this.required}
|
|
1754
|
-
placeholder=${
|
|
1755
|
-
rows=${
|
|
1756
|
-
minlength=${
|
|
1757
|
-
maxlength=${
|
|
1754
|
+
placeholder=${Ci(this.placeholder)}
|
|
1755
|
+
rows=${Ci(this.rows)}
|
|
1756
|
+
minlength=${Ci(this.minlength)}
|
|
1757
|
+
maxlength=${Ci(this.maxlength)}
|
|
1758
1758
|
aria-describedby="help-text"
|
|
1759
1759
|
@change=${this.handleChange}
|
|
1760
1760
|
@input=${this.handleInput}
|
|
@@ -1778,7 +1778,7 @@
|
|
|
1778
1778
|
>
|
|
1779
1779
|
<slot name="help-text">${this.helpText}</slot>
|
|
1780
1780
|
</div>
|
|
1781
|
-
</div>`}};
|
|
1781
|
+
</div>`}};pt.styles=[Ot,mp,qs];It([z(".textarea__control")],pt.prototype,"input",2);It([z(".textarea__size-adjuster")],pt.prototype,"sizeAdjuster",2);It([I()],pt.prototype,"hasFocus",2);It([C()],pt.prototype,"name",2);It([C()],pt.prototype,"value",2);It([C({reflect:!0})],pt.prototype,"size",2);It([C({type:Boolean,reflect:!0})],pt.prototype,"filled",2);It([C()],pt.prototype,"title",2);It([C()],pt.prototype,"placeholder",2);It([C({type:Number})],pt.prototype,"rows",2);It([C()],pt.prototype,"resize",2);It([C({type:Boolean,reflect:!0})],pt.prototype,"disabled",2);It([C({type:Boolean,reflect:!0})],pt.prototype,"readonly",2);It([C({reflect:!0})],pt.prototype,"form",2);It([C({type:Boolean,reflect:!0})],pt.prototype,"required",2);It([C({type:Number})],pt.prototype,"minlength",2);It([C({type:Number})],pt.prototype,"maxlength",2);It([C({attribute:"help-text"})],pt.prototype,"helpText",2);pt=It([Et("pbo-textarea")],pt);const Tp=gt`
|
|
1782
1782
|
:host {
|
|
1783
1783
|
display: block;
|
|
1784
1784
|
}
|
|
@@ -1814,7 +1814,7 @@
|
|
|
1814
1814
|
.form-control__label > slot {
|
|
1815
1815
|
font-size: 16.5px;
|
|
1816
1816
|
}
|
|
1817
|
-
`,
|
|
1817
|
+
`,Ep=gt`
|
|
1818
1818
|
:host {
|
|
1819
1819
|
display: inline-block;
|
|
1820
1820
|
}
|
|
@@ -1823,7 +1823,7 @@
|
|
|
1823
1823
|
/* display: flex; */
|
|
1824
1824
|
/* flex-wrap: nowrap; */
|
|
1825
1825
|
}
|
|
1826
|
-
`;var
|
|
1826
|
+
`;var Op=Object.defineProperty,kp=Object.getOwnPropertyDescriptor,on=(r,t,e,i)=>{for(var s=i>1?void 0:i?kp(t,e):t,n=r.length-1,o;n>=0;n--)(o=r[n])&&(s=(i?o(t,e,s):o(s))||s);return i&&s&&Op(t,e,s),s};let $i=class extends kt{constructor(){super(...arguments),this.disableRole=!1,this.label=""}handleFocus(r){const t=vs(r.target);t==null||t.toggleAttribute("data-pbo-button-group__button--focus",!0)}handleBlur(r){const t=vs(r.target);t==null||t.toggleAttribute("data-pbo-button-group__button--focus",!1)}handleMouseOver(r){const t=vs(r.target);t==null||t.toggleAttribute("data-pbo-button-group__button--hover",!0)}handleMouseOut(r){const t=vs(r.target);t==null||t.toggleAttribute("data-pbo-button-group__button--hover",!1)}handleSlotChange(){const r=[...this.defaultSlot.assignedElements({flatten:!0})];r.forEach(t=>{const e=r.indexOf(t),i=vs(t);i&&(i.toggleAttribute("data-pbo-button-group__button",!0),i.toggleAttribute("data-pbo-button-group__button--first",e===0),i.toggleAttribute("data-pbo-button-group__button--inner",e>0&&e<r.length-1),i.toggleAttribute("data-pbo-button-group__button--last",e===r.length-1),i.toggleAttribute("data-pbo-button-group__button--radio",i.tagName.toLowerCase()==="pbo-radio-button"))})}render(){return j`
|
|
1827
1827
|
<div
|
|
1828
1828
|
part="base"
|
|
1829
1829
|
class=${me({"button-group":!0})}
|
|
@@ -1836,7 +1836,7 @@
|
|
|
1836
1836
|
>
|
|
1837
1837
|
<slot @slotchange=${this.handleSlotChange}></slot>
|
|
1838
1838
|
</div>
|
|
1839
|
-
`}};$i.styles=[Ot,
|
|
1839
|
+
`}};$i.styles=[Ot,Ep];on([z("slot")],$i.prototype,"defaultSlot",2);on([I()],$i.prototype,"disableRole",2);on([C()],$i.prototype,"label",2);$i=on([Et("pbo-button-group")],$i);function vs(r){const t="pbo-button, pbo-radio-button";return r.closest(t)??r.querySelector(t)}var Pp=Object.defineProperty,Ap=Object.getOwnPropertyDescriptor,Vt=(r,t,e,i)=>{for(var s=i>1?void 0:i?Ap(t,e):t,n=r.length-1,o;n>=0;n--)(o=r[n])&&(s=(i?o(t,e,s):o(s))||s);return i&&s&&Pp(t,e,s),s};let ut=class extends kt{constructor(){super(...arguments),this.formControlController=new Oo(this),this.hasSlotController=new Xs(this,"help-text","label"),this.customValidityMessage="",this._value="",this.hasButtonGroup=!0,this.errorMessage="",this.defaultValue="",this.required=!1,this.name="option",this.value="",this.helpText="",this.label="",this.iconGroup=!1,this.size="medium",this.disabled=!1,this.form=""}handleValueChange(){this.hasUpdated&&this.updateCheckedRadio()}get validity(){const r=this.required&&!this.value;return this.customValidityMessage!==""?Fd:r?Ld:sn}get validationMessage(){const r=this.required&&!this.value;return this.customValidityMessage!==""?this.customValidityMessage:r?this.validationInput.validationMessage:""}connectedCallback(){super.connectedCallback(),this.defaultValue=this.value}checkValidity(){const r=this.required&&!this.value,t=this.customValidityMessage!=="";return r||t?(this.formControlController.emitInvalidEvent(),!1):!0}getForm(){return this.formControlController.getForm()}reportValidity(){const r=this.validity.valid;return this.errorMessage=this.customValidityMessage||r?"":this.validationInput.validationMessage,this.formControlController.setValidity(r),this.validationInput.hidden=!0,clearTimeout(this.validationTimeout),r||(this.validationInput.hidden=!1,this.validationInput.reportValidity(),this.validationTimeout=setTimeout(()=>this.validationInput.hidden=!0,1e4)),r}setCustomValidity(r){this.customValidityMessage=r,this.errorMessage=r,this.validationInput.setCustomValidity(r),this.formControlController.updateValidity()}getAllRadios(){return[...this.querySelectorAll("pbo-radio, pbo-radio-button")]}updateCheckedRadio(){this.getAllRadios().forEach(t=>t.checked=t.value===this.value),this.formControlController.setValidity(this.validity.valid)}handleRadioClick(r){const t=r.target.closest("pbo-radio-button"),e=this.getAllRadios(),i=this.value;!t||t.disabled||(this.value=t.value,e.forEach(s=>s.checked=s===t),this.value!==i&&(this.emit("pbo-change"),this.emit("pbo-input")))}handleLabelClick(){this.focus()}handleKeyDown(r){const t=this.getAllRadios().filter(n=>!n.disabled);if(t.length===0)return;const e=t.findIndex(n=>n.checked);let i=e;if(r.key==="ArrowRight"||r.key==="ArrowDown")r.preventDefault(),i=(e+1)%t.length;else if(r.key==="ArrowLeft"||r.key==="ArrowUp")r.preventDefault(),i=(e-1+t.length)%t.length;else return;const s=this.value;this.value=t[i].value,t.forEach(n=>n.checked=n===t[i]),t[i].focus(),this.value!==s&&(this.emit("pbo-change"),this.emit("pbo-input"))}syncRadios(){if(customElements.get("pbo-radio")&&customElements.get("pbo-radio-button")){this.syncRadioElements();return}if(customElements.get("pbo-radio")){this.syncRadioElements();return}else customElements.whenDefined("pbo-radio").then(()=>{this.syncRadios()});if(customElements.get("pbo-radio-button")){this.syncRadioElements();return}else customElements.whenDefined("pbo-radio-button").then(()=>{this.syncRadios()})}async syncRadioElements(){var t;const r=this.getAllRadios();if(await Promise.all(r.map(async e=>{await e.updateComplete,e.checked=e.value===this.value})),this.hasButtonGroup=r.some(e=>e.tagName.toLowerCase()==="pbo-radio-button"),r.length>0&&!r.some(e=>e.checked))if(this.hasButtonGroup){const e=(t=r[0].shadowRoot)==null?void 0:t.querySelector("button");e&&e.setAttribute("tabindex","0")}else r[0].setAttribute("tabindex","0")}handleInvalid(r){this.formControlController.setValidity(!1),this.formControlController.emitInvalidEvent(r)}render(){const r=this.hasSlotController.test("label"),t=this.hasSlotController.test("help-text"),e=this.helpText?!0:!!t,i=this.label?!0:!!r;return j`
|
|
1840
1840
|
<fieldset
|
|
1841
1841
|
role="radiogroup"
|
|
1842
1842
|
part="form-control"
|
|
@@ -1890,7 +1890,7 @@
|
|
|
1890
1890
|
<slot name="help-text">${this.helpText}</slot>
|
|
1891
1891
|
</div>
|
|
1892
1892
|
</fieldset>
|
|
1893
|
-
`}};
|
|
1893
|
+
`}};ut.styles=[Ot,Tp,qs];ut.dependencies={"pbo-button-group":$i};Vt([z("slot:not([name])")],ut.prototype,"defaultSlot",2);Vt([z(".radio-group__validation-input")],ut.prototype,"validationInput",2);Vt([I()],ut.prototype,"hasButtonGroup",2);Vt([I()],ut.prototype,"errorMessage",2);Vt([I()],ut.prototype,"defaultValue",2);Vt([C({type:Boolean,reflect:!0})],ut.prototype,"required",2);Vt([C()],ut.prototype,"name",2);Vt([C({reflect:!0})],ut.prototype,"value",2);Vt([C({attribute:"help-text"})],ut.prototype,"helpText",2);Vt([C()],ut.prototype,"label",2);Vt([C({type:Boolean,reflect:!0,attribute:"icon-group"})],ut.prototype,"iconGroup",2);Vt([C()],ut.prototype,"size",2);Vt([C({type:Boolean,reflect:!0})],ut.prototype,"disabled",2);Vt([C({reflect:!0})],ut.prototype,"form",2);Vt([it("value")],ut.prototype,"handleValueChange",1);ut=Vt([Et("pbo-radio-group")],ut);const Ii=()=>/Mobi|Android|iPhone|iPad|iPod/i.test(navigator.userAgent),ys=r=>r!=null,ac=r=>Object.entries(r).reduce((t,[e,i])=>(i==null||(t[e]=i),t),{}),Dp=(r,t)=>Math.sqrt(Math.pow(t.x-r.x,2)+Math.pow(t.y-r.y,2));var Mp=Object.defineProperty,Ip=Object.getOwnPropertyDescriptor,ot=(r,t,e,i)=>{for(var s=i>1?void 0:i?Ip(t,e):t,n=r.length-1,o;n>=0;n--)(o=r[n])&&(s=(i?o(t,e,s):o(s))||s);return i&&s&&Mp(t,e,s),s};let Z=class extends kt{constructor(){super(...arguments),this.resizeTimeout=null,this.cardInnerImageUrl="../../../public/Greeting Card from Pairbo.png",this.card=null,this.submitTypeForm=async r=>{console.error("submitTypingForm function not implemented",r)},this.loading=!1,this.disabled=!1,this.onClose=()=>{},this.ctaButtonPrimaryLabel="Add to Cart",this.hideColor=!1,this.CTA_STATES={danger:{type:"danger",message:"Add a message to Continue"},primary:{type:"primary",message:this.ctaButtonPrimaryLabel}},this.windowHeight=window.innerHeight,this.charsNum=0,this.ctaButtonState=this.CTA_STATES.primary,this.validationError="",this.wrappedSubmitTypeForm=async r=>{console.warn("submitTypingForm function not implemented",r)},this.processedMessage="",this.maxChars=223,this.handleTextareaBlur=()=>{let r=this;for(;r;){const{overflow:t,overflowY:e}=getComputedStyle(r);if(/(auto|scroll)/.test(t+e)){r.scrollTo({top:r.scrollHeight,behavior:"smooth"});return}r=r.parentElement??r.getRootNode().host??null}},this.handleTypeCanvasProcessed=r=>{const t=r;this.processedMessage=t.detail.message},this.handleResize=()=>{this.resizeTimeout&&window.clearTimeout(this.resizeTimeout),this.resizeTimeout=window.setTimeout(()=>{this.windowHeight=window.innerHeight},50)}}handleCardChange(){this.card&&(this.card.hasEditorial===void 0&&(this.maxChars=223),this.maxChars=this.card.hasEditorial?223:600)}updateWrappedSubmitTypeForm(){this.wrappedSubmitTypeForm=async r=>{this.loading=!0,this.disabled=!0;try{await this.submitTypeForm(r),this.onClose(),this.emit("pbo-type-form-submitted")}catch(t){throw this.validationError="Something went wrong. Please try again.",t}finally{this.loading=!1,this.disabled=!1}}}firstUpdated(){this.CTA_STATES.primary.message=this.ctaButtonPrimaryLabel,this.textarea.addEventListener("blur",this.handleTextareaBlur)}get formData(){var t,e,i,s,n,o,a,l,c;const r={pboCardId:((t=this.card)==null?void 0:t.pboId)||"Unknown",productId:(e=this.card)==null?void 0:e.productId,barcode:(i=this.card)==null?void 0:i.barcode,sku:(s=this.card)==null?void 0:s.sku,variantId:(n=this.card)==null?void 0:n.variantId,font:((o=this.fontSelector)==null?void 0:o.value)||"",text:((a=this.textarea)==null?void 0:a.value)||"",processedMessage:this.processedMessage,color:this.hideColor?"rgb(0,0,0)":((l=this.textColor)==null?void 0:l.value)||"",alignment:((c=this.textAlignment)==null?void 0:c.value)||""};return ac(r)}handleFormChange(r){var t;this.ctaButtonState=this.CTA_STATES.primary,this.validationError="",this.charsNum=((t=this.textarea)==null?void 0:t.value.length)||0,this.emit("pbo-type-form-change",{detail:this.formData})}hostConnected(){this.addEventListener("pbo-change",this.handleFormChange)}hostDisconnected(){this.removeEventListener("pbo-change",this.handleFormChange)}submitFormHandler(r){var e;r.preventDefault();const t=(e=r.submitter)==null?void 0:e.name;if(this.ctaButtonState.type==="danger"){t==="skip"&&this.wrappedSubmitTypeForm(this.formData);return}if(this.textarea.value===""||this.textarea.value===null||this.textarea.value===void 0){this.ctaButtonState=this.CTA_STATES.danger,this.textarea.focus();return}this.wrappedSubmitTypeForm(this.formData)}connectedCallback(){super.connectedCallback(),window.addEventListener("resize",this.handleResize),window.addEventListener("pbo-type-canvas-processed",this.handleTypeCanvasProcessed)}disconnectedCallback(){super.disconnectedCallback(),window.removeEventListener("resize",this.handleResize),window.removeEventListener("pbo-type-canvas-processed",this.handleTypeCanvasProcessed),this.resizeTimeout&&window.clearTimeout(this.resizeTimeout)}render(){const r=this.maxChars-this.charsNum;return j`
|
|
1894
1894
|
<form class="typing-form" @submit=${this.submitFormHandler}>
|
|
1895
1895
|
<pbo-textarea
|
|
1896
1896
|
exportparts="textarea:editor-textarea"
|
|
@@ -2034,11 +2034,11 @@
|
|
|
2034
2034
|
`:""}
|
|
2035
2035
|
</div>
|
|
2036
2036
|
</form>
|
|
2037
|
-
`}};Z.styles=[Ot,
|
|
2037
|
+
`}};Z.styles=[Ot,qs,Vd];Z.dependencies={"pbo-font-selector":$e,"pbo-textarea":pt,"pbo-color-radio-group":ut,"pbo-radio-group":ut,"pbo-radio-button":ut,"pbo-button":ht};ot([C({type:String,reflect:!0})],Z.prototype,"cardInnerImageUrl",2);ot([C()],Z.prototype,"card",2);ot([C()],Z.prototype,"submitTypeForm",2);ot([C({type:Boolean,reflect:!0})],Z.prototype,"loading",2);ot([C({type:Boolean,reflect:!0})],Z.prototype,"disabled",2);ot([C({type:Function})],Z.prototype,"onClose",2);ot([C({type:String,attribute:"cta-primary-label"})],Z.prototype,"ctaButtonPrimaryLabel",2);ot([C({type:Boolean,attribute:"hide-type-form-color-block"})],Z.prototype,"hideColor",2);ot([z(".greeting-text")],Z.prototype,"textarea",2);ot([z(".font-selector")],Z.prototype,"fontSelector",2);ot([z(".text-color")],Z.prototype,"textColor",2);ot([z(".text-alignment")],Z.prototype,"textAlignment",2);ot([z(".typing-form")],Z.prototype,"typingForm",2);ot([_o(".cta-buttons pbo-button")],Z.prototype,"ctaButtons",2);ot([I()],Z.prototype,"CTA_STATES",2);ot([I()],Z.prototype,"windowHeight",2);ot([I()],Z.prototype,"charsNum",2);ot([I()],Z.prototype,"ctaButtonState",2);ot([I()],Z.prototype,"validationError",2);ot([I()],Z.prototype,"wrappedSubmitTypeForm",2);ot([I()],Z.prototype,"processedMessage",2);ot([I()],Z.prototype,"maxChars",2);ot([it("card")],Z.prototype,"handleCardChange",1);ot([it("submitTypeForm")],Z.prototype,"updateWrappedSubmitTypeForm",1);Z=ot([Et("pbo-type-form")],Z);/**
|
|
2038
2038
|
* @license
|
|
2039
2039
|
* Copyright 2017 Google LLC
|
|
2040
2040
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
2041
|
-
*/const Va=r=>
|
|
2041
|
+
*/const Va=r=>vp(r)?r._$litType$.h:r.strings,Dn=tn(class extends en{constructor(r){super(r),this.et=new WeakMap}render(r){return[r]}update(r,[t]){const e=Ra(this.it)?Va(this.it):null,i=Ra(t)?Va(t):null;if(e!==null&&(i===null||e!==i)){const s=Ha(r).pop();let n=this.et.get(e);if(n===void 0){const o=document.createDocumentFragment();n=Bl(K,o),n.setConnected(!1),this.et.set(e,n)}io(n,[s]),za(n,void 0,s)}if(i!==null){if(e===null||e!==i){const s=this.et.get(i);if(s!==void 0){const n=Ha(s).pop();xp(r),za(r,void 0,n),io(r,[n])}}this.it=t}else this.it=void 0;return this.render(t)}}),Lp=gt`
|
|
2042
2042
|
:host {
|
|
2043
2043
|
display: block;
|
|
2044
2044
|
width: 100%;
|
|
@@ -2182,7 +2182,7 @@
|
|
|
2182
2182
|
* @license
|
|
2183
2183
|
* Copyright 2018 Google LLC
|
|
2184
2184
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
2185
|
-
*/const
|
|
2185
|
+
*/const lc="important",Fp=" !"+lc,pe=tn(class extends en{constructor(r){var t;if(super(r),r.type!==ci.ATTRIBUTE||r.name!=="style"||((t=r.strings)==null?void 0:t.length)>2)throw Error("The `styleMap` directive must be used in the `style` attribute and must be the only part in the attribute.")}render(r){return Object.keys(r).reduce((t,e)=>{const i=r[e];return i==null?t:t+`${e=e.includes("-")?e:e.replace(/(?:^(webkit|moz|ms|o)|)(?=[A-Z])/g,"-$&").toLowerCase()}:${i};`},"")}update(r,[t]){const{style:e}=r.element;if(this.ft===void 0)return this.ft=new Set(Object.keys(t)),this.render(t);for(const i of this.ft)t[i]==null&&(this.ft.delete(i),i.includes("-")?e.removeProperty(i):e[i]=null);for(const i in t){const s=t[i];if(s!=null){this.ft.add(i);const n=typeof s=="string"&&s.endsWith(Fp);i.includes("-")||n?e.setProperty(i,n?s.slice(0,-11):s,n?lc:""):e[i]=s}}return fe}}),jp=gt`
|
|
2186
2186
|
:host {
|
|
2187
2187
|
--size: 70%;
|
|
2188
2188
|
--header-spacing: var(--pbo-spacing-large);
|
|
@@ -2267,7 +2267,7 @@
|
|
|
2267
2267
|
width: 100%;
|
|
2268
2268
|
height: var(--size);
|
|
2269
2269
|
}
|
|
2270
|
-
`;var $p=Object.defineProperty,Rp=Object.getOwnPropertyDescriptor,
|
|
2270
|
+
`;var $p=Object.defineProperty,Rp=Object.getOwnPropertyDescriptor,vi=(r,t,e,i)=>{for(var s=i>1?void 0:i?Rp(t,e):t,n=r.length-1,o;n>=0;n--)(o=r[n])&&(s=(i?o(t,e,s):o(s))||s);return i&&s&&$p(t,e,s),s};let Oe=class extends kt{constructor(){super(...arguments),this.open=!1,this.placement="bottom",this.radius=!0,this.contained=!1,this.label="",this.handleKeyDown=r=>{r.key==="Escape"&&this.open&&(r.stopPropagation(),this.requestClose("keyboard"))}}requestClose(r){this.hide()}connectedCallback(){super.connectedCallback(),this.addEventListener("keydown",this.handleKeyDown)}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("keydown",this.handleKeyDown)}async hide(){this.open=!1,this.emit("pbo-after-drawer-closed")}async show(){this.open||(this.open=!0)}handleOpenChange(){this.open?this.drawer.hidden=!1:this.drawer.hidden=!0}firstUpdated(){this.drawer.hidden=!this.open}render(){return j`
|
|
2271
2271
|
<div
|
|
2272
2272
|
part="base"
|
|
2273
2273
|
class=${me({drawer:!0,"drawer--bottom":this.placement==="bottom","drawer--top":this.placement==="top","drawer--left":this.placement==="left","drawer--right":this.placement==="right","drawer--open":this.open,"drawer--contained":this.contained})}
|
|
@@ -2289,7 +2289,7 @@
|
|
|
2289
2289
|
<slot part="body" class="drawer__body"></slot>
|
|
2290
2290
|
</div>
|
|
2291
2291
|
</div>
|
|
2292
|
-
`}};Oe.styles=[Ot,jp];
|
|
2292
|
+
`}};Oe.styles=[Ot,jp];vi([z(".drawer")],Oe.prototype,"drawer",2);vi([C({type:Boolean,reflect:!0})],Oe.prototype,"open",2);vi([C({reflect:!0})],Oe.prototype,"placement",2);vi([C({type:Boolean,reflect:!0})],Oe.prototype,"radius",2);vi([C({type:Boolean,reflect:!0})],Oe.prototype,"contained",2);vi([C({type:String})],Oe.prototype,"label",2);vi([it("open",{waitUntilFirstUpdate:!0})],Oe.prototype,"handleOpenChange",1);Oe=vi([Et("pbo-drawer")],Oe);const Bp=gt`
|
|
2293
2293
|
:host {
|
|
2294
2294
|
display: block;
|
|
2295
2295
|
width: 100%;
|
|
@@ -2317,17 +2317,17 @@
|
|
|
2317
2317
|
display: block;
|
|
2318
2318
|
object-fit: contain;
|
|
2319
2319
|
}
|
|
2320
|
-
`;function v(r,t,e){return(t=(function(i){var s=(function(n,o){if(typeof n!="object"||!n)return n;var a=n[Symbol.toPrimitive];if(a!==void 0){var l=a.call(n,o);if(typeof l!="object")return l;throw new TypeError("@@toPrimitive must return a primitive value.")}return(o==="string"?String:Number)(n)})(i,"string");return typeof s=="symbol"?s:s+""})(t))in r?Object.defineProperty(r,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):r[t]=e,r}function Na(r,t){var e=Object.keys(r);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(r);t&&(i=i.filter((function(s){return Object.getOwnPropertyDescriptor(r,s).enumerable}))),e.push.apply(e,i)}return e}function y(r){for(var t=1;t<arguments.length;t++){var e=arguments[t]!=null?arguments[t]:{};t%2?Na(Object(e),!0).forEach((function(i){v(r,i,e[i])})):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(e)):Na(Object(e)).forEach((function(i){Object.defineProperty(r,i,Object.getOwnPropertyDescriptor(e,i))}))}return r}function rt(r,t){if(r==null)return{};var e,i,s=(function(o,a){if(o==null)return{};var l={};for(var c in o)if({}.hasOwnProperty.call(o,c)){if(a.indexOf(c)>=0)continue;l[c]=o[c]}return l})(r,t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(r);for(i=0;i<n.length;i++)e=n[i],t.indexOf(e)>=0||{}.propertyIsEnumerable.call(r,e)&&(s[e]=r[e])}return s}function He(r,t){return t||(t=r.slice(0)),Object.freeze(Object.defineProperties(r,{raw:{value:Object.freeze(t)}}))}class Ua{constructor(){v(this,"browserShadowBlurConstant",1),v(this,"DPI",96),v(this,"devicePixelRatio",typeof window<"u"?window.devicePixelRatio:1),v(this,"perfLimitSizeTotal",2097152),v(this,"maxCacheSideLimit",4096),v(this,"minCacheSideLimit",256),v(this,"disableStyleCopyPaste",!1),v(this,"enableGLFiltering",!0),v(this,"textureSize",4096),v(this,"forceGLPutImageData",!1),v(this,"cachesBoundsOfCurve",!1),v(this,"fontPaths",{}),v(this,"NUM_FRACTION_DIGITS",4)}}const W=new class extends Ua{constructor(r){super(),this.configure(r)}configure(){let r=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};Object.assign(this,r)}addFonts(){let r=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};this.fontPaths=y(y({},this.fontPaths),r)}removeFonts(){(arguments.length>0&&arguments[0]!==void 0?arguments[0]:[]).forEach((r=>{delete this.fontPaths[r]}))}clearFonts(){this.fontPaths={}}restoreDefaults(r){const t=new Ua,e=(r==null?void 0:r.reduce(((i,s)=>(i[s]=t[s],i)),{}))||t;this.configure(e)}},
|
|
2321
|
-
void main(){}`),s=t.createShader(t.FRAGMENT_SHADER);return!!s&&(t.shaderSource(s,i),t.compileShader(s),!!t.getShaderParameter(s,t.COMPILE_STATUS))}queryWebGL(t){const e=t.getContext("webgl");e&&(this.maxTextureSize=e.getParameter(e.MAX_TEXTURE_SIZE),this.GLPrecision=["highp","mediump","lowp"].find((i=>this.testPrecision(e,i))),e.getExtension("WEBGL_lose_context").loseContext(),mi("log","WebGL: max texture size ".concat(this.maxTextureSize)))}isSupported(t){return!!this.maxTextureSize&&this.maxTextureSize>=t}}const Np={};let Wa;const Re=()=>Wa||(Wa={document,window,isTouchSupported:"ontouchstart"in window||"ontouchstart"in document||window&&window.navigator&&window.navigator.maxTouchPoints>0,WebGLProbe:new Vp,dispose(){},copyPasteData:Np}),ss=()=>Re().document,an=()=>Re().window,hc=()=>{var r;return Math.max((r=W.devicePixelRatio)!==null&&r!==void 0?r:an().devicePixelRatio,1)},Ds=new class{constructor(){v(this,"boundsOfCurveCache",{}),this.charWidthsCache=new Map}getFontCache(r){let{fontFamily:t,fontStyle:e,fontWeight:i}=r;t=t.toLowerCase();const s=this.charWidthsCache;s.has(t)||s.set(t,new Map);const n=s.get(t),o="".concat(e.toLowerCase(),"_").concat((i+"").toLowerCase());return n.has(o)||n.set(o,new Map),n.get(o)}clearFontCache(r){r?this.charWidthsCache.delete((r||"").toLowerCase()):this.charWidthsCache=new Map}limitDimsByArea(r){const{perfLimitSizeTotal:t}=W,e=Math.sqrt(t*r);return[Math.floor(e),Math.floor(t/e)]}},so="6.9.1";function Ar(){}const qs=Math.PI/2,Rr=2*Math.PI,Ao=Math.PI/180,qt=Object.freeze([1,0,0,1,0,0]),Do=16,ai=.4477152502,V="center",Y="left",ie="top",ro="bottom",_t="right",se="none",Mo=/\r?\n/,dc="moving",ln="scaling",uc="rotating",Io="rotate",pc="skewing",Hs="resizing",Up="modifyPoly",Wp="modifyPath",Br="changed",cn="scale",oe="scaleX",be="scaleY",rs="skewX",ns="skewY",Dt="fill",re="stroke",zr="modified",Ni="json",Mn="svg",A=new class{constructor(){this[Ni]=new Map,this[Mn]=new Map}has(r){return this[Ni].has(r)}getClass(r){const t=this[Ni].get(r);if(!t)throw new je("No class registered for ".concat(r));return t}setClass(r,t){t?this[Ni].set(t,r):(this[Ni].set(r.type,r),this[Ni].set(r.type.toLowerCase(),r))}getSVGClass(r){return this[Mn].get(r)}setSVGClass(r,t){this[Mn].set(t??r.type.toLowerCase(),r)}},Hr=new class extends Array{remove(r){const t=this.indexOf(r);t>-1&&this.splice(t,1)}cancelAll(){const r=this.splice(0);return r.forEach((t=>t.abort())),r}cancelByCanvas(r){if(!r)return[];const t=this.filter((e=>{var i;return e.target===r||typeof e.target=="object"&&((i=e.target)===null||i===void 0?void 0:i.canvas)===r}));return t.forEach((e=>e.abort())),t}cancelByTarget(r){if(!r)return[];const t=this.filter((e=>e.target===r));return t.forEach((e=>e.abort())),t}};class Yp{constructor(){v(this,"__eventListeners",{})}on(t,e){if(this.__eventListeners||(this.__eventListeners={}),typeof t=="object")return Object.entries(t).forEach((i=>{let[s,n]=i;this.on(s,n)})),()=>this.off(t);if(e){const i=t;return this.__eventListeners[i]||(this.__eventListeners[i]=[]),this.__eventListeners[i].push(e),()=>this.off(i,e)}return()=>!1}once(t,e){if(typeof t=="object"){const i=[];return Object.entries(t).forEach((s=>{let[n,o]=s;i.push(this.once(n,o))})),()=>i.forEach((s=>s()))}if(e){const i=this.on(t,(function(){for(var s=arguments.length,n=new Array(s),o=0;o<s;o++)n[o]=arguments[o];e.call(this,...n),i()}));return i}return()=>!1}_removeEventListener(t,e){if(this.__eventListeners[t])if(e){const i=this.__eventListeners[t],s=i.indexOf(e);s>-1&&i.splice(s,1)}else this.__eventListeners[t]=[]}off(t,e){if(this.__eventListeners)if(t===void 0)for(const i in this.__eventListeners)this._removeEventListener(i);else typeof t=="object"?Object.entries(t).forEach((i=>{let[s,n]=i;this._removeEventListener(s,n)})):this._removeEventListener(t,e)}fire(t,e){var i;if(!this.__eventListeners)return;const s=(i=this.__eventListeners[t])===null||i===void 0?void 0:i.concat();if(s)for(let n=0;n<s.length;n++)s[n].call(this,e||{})}}const Yi=(r,t)=>{const e=r.indexOf(t);return e!==-1&&r.splice(e,1),r},Je=r=>{if(r===0)return 1;switch(Math.abs(r)/qs){case 1:case 3:return 0;case 2:return-1}return Math.cos(r)},Qe=r=>{if(r===0)return 0;const t=r/qs,e=Math.sign(r);switch(t){case 1:return e;case 2:return 0;case 3:return-e}return Math.sin(r)};class x{constructor(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:0,e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0;typeof t=="object"?(this.x=t.x,this.y=t.y):(this.x=t,this.y=e)}add(t){return new x(this.x+t.x,this.y+t.y)}addEquals(t){return this.x+=t.x,this.y+=t.y,this}scalarAdd(t){return new x(this.x+t,this.y+t)}scalarAddEquals(t){return this.x+=t,this.y+=t,this}subtract(t){return new x(this.x-t.x,this.y-t.y)}subtractEquals(t){return this.x-=t.x,this.y-=t.y,this}scalarSubtract(t){return new x(this.x-t,this.y-t)}scalarSubtractEquals(t){return this.x-=t,this.y-=t,this}multiply(t){return new x(this.x*t.x,this.y*t.y)}scalarMultiply(t){return new x(this.x*t,this.y*t)}scalarMultiplyEquals(t){return this.x*=t,this.y*=t,this}divide(t){return new x(this.x/t.x,this.y/t.y)}scalarDivide(t){return new x(this.x/t,this.y/t)}scalarDivideEquals(t){return this.x/=t,this.y/=t,this}eq(t){return this.x===t.x&&this.y===t.y}lt(t){return this.x<t.x&&this.y<t.y}lte(t){return this.x<=t.x&&this.y<=t.y}gt(t){return this.x>t.x&&this.y>t.y}gte(t){return this.x>=t.x&&this.y>=t.y}lerp(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:.5;return e=Math.max(Math.min(1,e),0),new x(this.x+(t.x-this.x)*e,this.y+(t.y-this.y)*e)}distanceFrom(t){const e=this.x-t.x,i=this.y-t.y;return Math.sqrt(e*e+i*i)}midPointFrom(t){return this.lerp(t)}min(t){return new x(Math.min(this.x,t.x),Math.min(this.y,t.y))}max(t){return new x(Math.max(this.x,t.x),Math.max(this.y,t.y))}toString(){return"".concat(this.x,",").concat(this.y)}setXY(t,e){return this.x=t,this.y=e,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setFromPoint(t){return this.x=t.x,this.y=t.y,this}swap(t){const e=this.x,i=this.y;this.x=t.x,this.y=t.y,t.x=e,t.y=i}clone(){return new x(this.x,this.y)}rotate(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:Lo;const i=Qe(t),s=Je(t),n=this.subtract(e);return new x(n.x*s-n.y*i,n.x*i+n.y*s).add(e)}transform(t){let e=arguments.length>1&&arguments[1]!==void 0&&arguments[1];return new x(t[0]*this.x+t[2]*this.y+(e?0:t[4]),t[1]*this.x+t[3]*this.y+(e?0:t[5]))}}const Lo=new x(0,0),Dr=r=>!!r&&Array.isArray(r._objects);function gc(r){class t extends r{constructor(){super(...arguments),v(this,"_objects",[])}_onObjectAdded(i){}_onObjectRemoved(i){}_onStackOrderChanged(i){}add(){for(var i=arguments.length,s=new Array(i),n=0;n<i;n++)s[n]=arguments[n];const o=this._objects.push(...s);return s.forEach((a=>this._onObjectAdded(a))),o}insertAt(i){for(var s=arguments.length,n=new Array(s>1?s-1:0),o=1;o<s;o++)n[o-1]=arguments[o];return this._objects.splice(i,0,...n),n.forEach((a=>this._onObjectAdded(a))),this._objects.length}remove(){const i=this._objects,s=[];for(var n=arguments.length,o=new Array(n),a=0;a<n;a++)o[a]=arguments[a];return o.forEach((l=>{const c=i.indexOf(l);c!==-1&&(i.splice(c,1),s.push(l),this._onObjectRemoved(l))})),s}forEachObject(i){this.getObjects().forEach(((s,n,o)=>i(s,n,o)))}getObjects(){for(var i=arguments.length,s=new Array(i),n=0;n<i;n++)s[n]=arguments[n];return s.length===0?[...this._objects]:this._objects.filter((o=>o.isType(...s)))}item(i){return this._objects[i]}isEmpty(){return this._objects.length===0}size(){return this._objects.length}contains(i,s){return!!this._objects.includes(i)||!!s&&this._objects.some((n=>n instanceof t&&n.contains(i,!0)))}complexity(){return this._objects.reduce(((i,s)=>i+=s.complexity?s.complexity():0),0)}sendObjectToBack(i){return!(!i||i===this._objects[0])&&(Yi(this._objects,i),this._objects.unshift(i),this._onStackOrderChanged(i),!0)}bringObjectToFront(i){return!(!i||i===this._objects[this._objects.length-1])&&(Yi(this._objects,i),this._objects.push(i),this._onStackOrderChanged(i),!0)}sendObjectBackwards(i,s){if(!i)return!1;const n=this._objects.indexOf(i);if(n!==0){const o=this.findNewLowerIndex(i,n,s);return Yi(this._objects,i),this._objects.splice(o,0,i),this._onStackOrderChanged(i),!0}return!1}bringObjectForward(i,s){if(!i)return!1;const n=this._objects.indexOf(i);if(n!==this._objects.length-1){const o=this.findNewUpperIndex(i,n,s);return Yi(this._objects,i),this._objects.splice(o,0,i),this._onStackOrderChanged(i),!0}return!1}moveObjectTo(i,s){return i!==this._objects[s]&&(Yi(this._objects,i),this._objects.splice(s,0,i),this._onStackOrderChanged(i),!0)}findNewLowerIndex(i,s,n){let o;if(n){o=s;for(let a=s-1;a>=0;--a)if(i.isOverlapping(this._objects[a])){o=a;break}}else o=s-1;return o}findNewUpperIndex(i,s,n){let o;if(n){o=s;for(let a=s+1;a<this._objects.length;++a)if(i.isOverlapping(this._objects[a])){o=a;break}}else o=s+1;return o}collectObjects(i){let{left:s,top:n,width:o,height:a}=i,{includeIntersecting:l=!0}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};const c=[],h=new x(s,n),d=h.add(new x(o,a));for(let u=this._objects.length-1;u>=0;u--){const p=this._objects[u];p.selectable&&p.visible&&(l&&p.intersectsWithRect(h,d)||p.isContainedWithinRect(h,d)||l&&p.containsPoint(h)||l&&p.containsPoint(d))&&c.push(p)}return c}}return t}class fc extends Yp{_setOptions(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};for(const e in t)this.set(e,t[e])}_setObject(t){for(const e in t)this._set(e,t[e])}set(t,e){return typeof t=="object"?this._setObject(t):this._set(t,e),this}_set(t,e){this[t]=e}toggle(t){const e=this.get(t);return typeof e=="boolean"&&this.set(t,!e),this}get(t){return this[t]}}function Mr(r){return an().requestAnimationFrame(r)}function Gp(r){return an().cancelAnimationFrame(r)}let Xp=0;const bi=()=>Xp++,ti=()=>{const r=ss().createElement("canvas");if(!r||r.getContext===void 0)throw new je("Failed to create `canvas` element");return r},Kp=()=>ss().createElement("img"),ve=r=>{const t=ti();return t.width=r.width,t.height=r.height,t},mc=(r,t,e)=>r.toDataURL("image/".concat(t),e),bc=(r,t,e)=>new Promise(((i,s)=>{r.toBlob(i,"image/".concat(t),e)})),xt=r=>r*Ao,ei=r=>r/Ao,qp=r=>r.every(((t,e)=>t===qt[e])),Qt=(r,t,e)=>new x(r).transform(t,e),Ce=r=>{const t=1/(r[0]*r[3]-r[1]*r[2]),e=[t*r[3],-t*r[1],-t*r[2],t*r[0],0,0],{x:i,y:s}=new x(r[4],r[5]).transform(e,!0);return e[4]=-i,e[5]=-s,e},Rt=(r,t,e)=>[r[0]*t[0]+r[2]*t[1],r[1]*t[0]+r[3]*t[1],r[0]*t[2]+r[2]*t[3],r[1]*t[2]+r[3]*t[3],e?0:r[0]*t[4]+r[2]*t[5]+r[4],e?0:r[1]*t[4]+r[3]*t[5]+r[5]],Fo=(r,t)=>r.reduceRight(((e,i)=>i&&e?Rt(i,e,t):i||e),void 0)||qt.concat(),vc=r=>{let[t,e]=r;return Math.atan2(e,t)},Vr=r=>{const t=vc(r),e=Math.pow(r[0],2)+Math.pow(r[1],2),i=Math.sqrt(e),s=(r[0]*r[3]-r[2]*r[1])/i,n=Math.atan2(r[0]*r[2]+r[1]*r[3],e);return{angle:ei(t),scaleX:i,scaleY:s,skewX:ei(n),skewY:0,translateX:r[4]||0,translateY:r[5]||0}},Zs=function(r){return[1,0,0,1,r,arguments.length>1&&arguments[1]!==void 0?arguments[1]:0]};function os(){let{angle:r=0}=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},{x:t=0,y:e=0}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};const i=xt(r),s=Je(i),n=Qe(i);return[s,n,-n,s,t?t-(s*t-n*e):0,e?e-(n*t+s*e):0]}const jo=function(r){return[r,0,0,arguments.length>1&&arguments[1]!==void 0?arguments[1]:r,0,0]},yc=r=>Math.tan(xt(r)),_c=r=>[1,0,yc(r),1,0,0],xc=r=>[1,yc(r),0,1,0,0],hn=r=>{let{scaleX:t=1,scaleY:e=1,flipX:i=!1,flipY:s=!1,skewX:n=0,skewY:o=0}=r,a=jo(i?-t:t,s?-e:e);return n&&(a=Rt(a,_c(n),!0)),o&&(a=Rt(a,xc(o),!0)),a},Zp=r=>{const{translateX:t=0,translateY:e=0,angle:i=0}=r;let s=Zs(t,e);i&&(s=Rt(s,os({angle:i})));const n=hn(r);return qp(n)||(s=Rt(s,n)),s},Ir=function(r){let{signal:t,crossOrigin:e=null}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return new Promise((function(i,s){if(t&&t.aborted)return s(new zp("loadImage"));const n=Kp();let o;t&&(o=function(l){n.src="",s(l)},t.addEventListener("abort",o,{once:!0}));const a=function(){n.onload=n.onerror=null,o&&(t==null||t.removeEventListener("abort",o)),i(n)};r?(n.onload=a,n.onerror=function(){o&&(t==null||t.removeEventListener("abort",o)),s(new je("Error loading ".concat(n.src)))},e&&(n.crossOrigin=e),n.src=r):a()}))},Vs=function(r){let{signal:t,reviver:e=Ar}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return new Promise(((i,s)=>{const n=[];t&&t.addEventListener("abort",s,{once:!0}),Promise.all(r.map((o=>A.getClass(o.type).fromObject(o,{signal:t}).then((a=>(e(o,a),n.push(a),a)))))).then(i).catch((o=>{n.forEach((a=>{a.dispose&&a.dispose()})),s(o)})).finally((()=>{t&&t.removeEventListener("abort",s)}))}))},dn=function(r){let{signal:t}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return new Promise(((e,i)=>{const s=[];t&&t.addEventListener("abort",i,{once:!0});const n=Object.values(r).map((a=>a&&a.type&&A.has(a.type)?Vs([a],{signal:t}).then((l=>{let[c]=l;return s.push(c),c})):a)),o=Object.keys(r);Promise.all(n).then((a=>a.reduce(((l,c,h)=>(l[o[h]]=c,l)),{}))).then(e).catch((a=>{s.forEach((l=>{l.dispose&&l.dispose()})),i(a)})).finally((()=>{t&&t.removeEventListener("abort",i)}))}))},as=function(r){return(arguments.length>1&&arguments[1]!==void 0?arguments[1]:[]).reduce(((t,e)=>(e in r&&(t[e]=r[e]),t)),{})},$o=(r,t)=>Object.keys(r).reduce(((e,i)=>(t(r[i],i,r)&&(e[i]=r[i]),e)),{}),et=(r,t)=>parseFloat(Number(r).toFixed(t)),Ns=r=>"matrix("+r.map((t=>et(t,W.NUM_FRACTION_DIGITS))).join(" ")+")",ge=r=>!!r&&r.toLive!==void 0,Ya=r=>!!r&&typeof r.toObject=="function",Ga=r=>!!r&&r.offsetX!==void 0&&"source"in r,Ei=r=>!!r&&"multiSelectionStacking"in r;function wc(r){const t=r&&we(r);let e=0,i=0;if(!r||!t)return{left:e,top:i};let s=r;const n=t.documentElement,o=t.body||{scrollLeft:0,scrollTop:0};for(;s&&(s.parentNode||s.host)&&(s=s.parentNode||s.host,s===t?(e=o.scrollLeft||n.scrollLeft||0,i=o.scrollTop||n.scrollTop||0):(e+=s.scrollLeft||0,i+=s.scrollTop||0),s.nodeType!==1||s.style.position!=="fixed"););return{left:e,top:i}}const we=r=>r.ownerDocument||null,Cc=r=>{var t;return((t=r.ownerDocument)===null||t===void 0?void 0:t.defaultView)||null},Sc=function(r,t,e){let{width:i,height:s}=e,n=arguments.length>3&&arguments[3]!==void 0?arguments[3]:1;r.width=i,r.height=s,n>1&&(r.setAttribute("width",(i*n).toString()),r.setAttribute("height",(s*n).toString()),t.scale(n,n))},no=(r,t)=>{let{width:e,height:i}=t;e&&(r.style.width=typeof e=="number"?"".concat(e,"px"):e),i&&(r.style.height=typeof i=="number"?"".concat(i,"px"):i)};function Xa(r){return r.onselectstart!==void 0&&(r.onselectstart=()=>!1),r.style.userSelect=se,r}class Tc{constructor(t){v(this,"_originalCanvasStyle",void 0),v(this,"lower",void 0);const e=this.createLowerCanvas(t);this.lower={el:e,ctx:e.getContext("2d")}}createLowerCanvas(t){const e=(i=t)&&i.getContext!==void 0?t:t&&ss().getElementById(t)||ti();var i;if(e.hasAttribute("data-fabric"))throw new je("Trying to initialize a canvas that has already been initialized. Did you forget to dispose the canvas?");return this._originalCanvasStyle=e.style.cssText,e.setAttribute("data-fabric","main"),e.classList.add("lower-canvas"),e}cleanupDOM(t){let{width:e,height:i}=t;const{el:s}=this.lower;s.classList.remove("lower-canvas"),s.removeAttribute("data-fabric"),s.setAttribute("width","".concat(e)),s.setAttribute("height","".concat(i)),s.style.cssText=this._originalCanvasStyle||"",this._originalCanvasStyle=void 0}setDimensions(t,e){const{el:i,ctx:s}=this.lower;Sc(i,s,t,e)}setCSSDimensions(t){no(this.lower.el,t)}calcOffset(){return(function(t){var e;const i=t&&we(t),s={left:0,top:0};if(!i)return s;const n=((e=Cc(t))===null||e===void 0?void 0:e.getComputedStyle(t,null))||{};s.left+=parseInt(n.borderLeftWidth,10)||0,s.top+=parseInt(n.borderTopWidth,10)||0,s.left+=parseInt(n.paddingLeft,10)||0,s.top+=parseInt(n.paddingTop,10)||0;let o={left:0,top:0};const a=i.documentElement;t.getBoundingClientRect!==void 0&&(o=t.getBoundingClientRect());const l=wc(t);return{left:o.left+l.left-(a.clientLeft||0)+s.left,top:o.top+l.top-(a.clientTop||0)+s.top}})(this.lower.el)}dispose(){Re().dispose(this.lower.el),delete this.lower}}const Jp={backgroundVpt:!0,backgroundColor:"",overlayVpt:!0,overlayColor:"",includeDefaultValues:!0,svgViewportTransformation:!0,renderOnAddRemove:!0,skipOffscreen:!0,enableRetinaScaling:!0,imageSmoothingEnabled:!0,controlsAboveOverlay:!1,allowTouchScrolling:!1,viewportTransform:[...qt]},Qp=["objects"];class Js extends gc(fc){get lowerCanvasEl(){var t;return(t=this.elements.lower)===null||t===void 0?void 0:t.el}get contextContainer(){var t;return(t=this.elements.lower)===null||t===void 0?void 0:t.ctx}static getDefaults(){return Js.ownDefaults}constructor(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};super(),Object.assign(this,this.constructor.getDefaults()),this.set(e),this.initElements(t),this._setDimensionsImpl({width:this.width||this.elements.lower.el.width||0,height:this.height||this.elements.lower.el.height||0}),this.skipControlsDrawing=!1,this.viewportTransform=[...this.viewportTransform],this.calcViewportBoundaries()}initElements(t){this.elements=new Tc(t)}add(){const t=super.add(...arguments);return arguments.length>0&&this.renderOnAddRemove&&this.requestRenderAll(),t}insertAt(t){for(var e=arguments.length,i=new Array(e>1?e-1:0),s=1;s<e;s++)i[s-1]=arguments[s];const n=super.insertAt(t,...i);return i.length>0&&this.renderOnAddRemove&&this.requestRenderAll(),n}remove(){const t=super.remove(...arguments);return t.length>0&&this.renderOnAddRemove&&this.requestRenderAll(),t}_onObjectAdded(t){t.canvas&&t.canvas!==this&&(mi("warn",`Canvas is trying to add an object that belongs to a different canvas.
|
|
2322
|
-
Resulting to default behavior: removing object from previous canvas and adding to new canvas`),t.canvas.remove(t)),t._set("canvas",this),t.setCoords(),this.fire("object:added",{target:t}),t.fire("added",{target:this})}_onObjectRemoved(t){t._set("canvas",void 0),this.fire("object:removed",{target:t}),t.fire("removed",{target:this})}_onStackOrderChanged(){this.renderOnAddRemove&&this.requestRenderAll()}getRetinaScaling(){return this.enableRetinaScaling?
|
|
2320
|
+
`;function v(r,t,e){return(t=(function(i){var s=(function(n,o){if(typeof n!="object"||!n)return n;var a=n[Symbol.toPrimitive];if(a!==void 0){var l=a.call(n,o);if(typeof l!="object")return l;throw new TypeError("@@toPrimitive must return a primitive value.")}return(o==="string"?String:Number)(n)})(i,"string");return typeof s=="symbol"?s:s+""})(t))in r?Object.defineProperty(r,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):r[t]=e,r}function Na(r,t){var e=Object.keys(r);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(r);t&&(i=i.filter((function(s){return Object.getOwnPropertyDescriptor(r,s).enumerable}))),e.push.apply(e,i)}return e}function y(r){for(var t=1;t<arguments.length;t++){var e=arguments[t]!=null?arguments[t]:{};t%2?Na(Object(e),!0).forEach((function(i){v(r,i,e[i])})):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(e)):Na(Object(e)).forEach((function(i){Object.defineProperty(r,i,Object.getOwnPropertyDescriptor(e,i))}))}return r}function rt(r,t){if(r==null)return{};var e,i,s=(function(o,a){if(o==null)return{};var l={};for(var c in o)if({}.hasOwnProperty.call(o,c)){if(a.indexOf(c)>=0)continue;l[c]=o[c]}return l})(r,t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(r);for(i=0;i<n.length;i++)e=n[i],t.indexOf(e)>=0||{}.propertyIsEnumerable.call(r,e)&&(s[e]=r[e])}return s}function He(r,t){return t||(t=r.slice(0)),Object.freeze(Object.defineProperties(r,{raw:{value:Object.freeze(t)}}))}class Ua{constructor(){v(this,"browserShadowBlurConstant",1),v(this,"DPI",96),v(this,"devicePixelRatio",typeof window<"u"?window.devicePixelRatio:1),v(this,"perfLimitSizeTotal",2097152),v(this,"maxCacheSideLimit",4096),v(this,"minCacheSideLimit",256),v(this,"disableStyleCopyPaste",!1),v(this,"enableGLFiltering",!0),v(this,"textureSize",4096),v(this,"forceGLPutImageData",!1),v(this,"cachesBoundsOfCurve",!1),v(this,"fontPaths",{}),v(this,"NUM_FRACTION_DIGITS",4)}}const W=new class extends Ua{constructor(r){super(),this.configure(r)}configure(){let r=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};Object.assign(this,r)}addFonts(){let r=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};this.fontPaths=y(y({},this.fontPaths),r)}removeFonts(){(arguments.length>0&&arguments[0]!==void 0?arguments[0]:[]).forEach((r=>{delete this.fontPaths[r]}))}clearFonts(){this.fontPaths={}}restoreDefaults(r){const t=new Ua,e=(r==null?void 0:r.reduce(((i,s)=>(i[s]=t[s],i)),{}))||t;this.configure(e)}},fi=function(r){for(var t=arguments.length,e=new Array(t>1?t-1:0),i=1;i<t;i++)e[i-1]=arguments[i];return console[r]("fabric",...e)};class je extends Error{constructor(t,e){super("fabric: ".concat(t),e)}}class zp extends je{constructor(t){super("".concat(t," 'options.signal' is in 'aborted' state"))}}class Hp{}class Vp extends Hp{testPrecision(t,e){const i="precision ".concat(e,` float;
|
|
2321
|
+
void main(){}`),s=t.createShader(t.FRAGMENT_SHADER);return!!s&&(t.shaderSource(s,i),t.compileShader(s),!!t.getShaderParameter(s,t.COMPILE_STATUS))}queryWebGL(t){const e=t.getContext("webgl");e&&(this.maxTextureSize=e.getParameter(e.MAX_TEXTURE_SIZE),this.GLPrecision=["highp","mediump","lowp"].find((i=>this.testPrecision(e,i))),e.getExtension("WEBGL_lose_context").loseContext(),fi("log","WebGL: max texture size ".concat(this.maxTextureSize)))}isSupported(t){return!!this.maxTextureSize&&this.maxTextureSize>=t}}const Np={};let Wa;const Re=()=>Wa||(Wa={document,window,isTouchSupported:"ontouchstart"in window||"ontouchstart"in document||window&&window.navigator&&window.navigator.maxTouchPoints>0,WebGLProbe:new Vp,dispose(){},copyPasteData:Np}),ss=()=>Re().document,an=()=>Re().window,cc=()=>{var r;return Math.max((r=W.devicePixelRatio)!==null&&r!==void 0?r:an().devicePixelRatio,1)},Ds=new class{constructor(){v(this,"boundsOfCurveCache",{}),this.charWidthsCache=new Map}getFontCache(r){let{fontFamily:t,fontStyle:e,fontWeight:i}=r;t=t.toLowerCase();const s=this.charWidthsCache;s.has(t)||s.set(t,new Map);const n=s.get(t),o="".concat(e.toLowerCase(),"_").concat((i+"").toLowerCase());return n.has(o)||n.set(o,new Map),n.get(o)}clearFontCache(r){r?this.charWidthsCache.delete((r||"").toLowerCase()):this.charWidthsCache=new Map}limitDimsByArea(r){const{perfLimitSizeTotal:t}=W,e=Math.sqrt(t*r);return[Math.floor(e),Math.floor(t/e)]}},so="6.9.1";function Ar(){}const Ks=Math.PI/2,Rr=2*Math.PI,Ao=Math.PI/180,Kt=Object.freeze([1,0,0,1,0,0]),Do=16,ai=.4477152502,V="center",Y="left",ie="top",ro="bottom",yt="right",se="none",Mo=/\r?\n/,hc="moving",ln="scaling",dc="rotating",Io="rotate",uc="skewing",Hs="resizing",Up="modifyPoly",Wp="modifyPath",Br="changed",cn="scale",oe="scaleX",be="scaleY",rs="skewX",ns="skewY",Dt="fill",re="stroke",zr="modified",Ni="json",Mn="svg",A=new class{constructor(){this[Ni]=new Map,this[Mn]=new Map}has(r){return this[Ni].has(r)}getClass(r){const t=this[Ni].get(r);if(!t)throw new je("No class registered for ".concat(r));return t}setClass(r,t){t?this[Ni].set(t,r):(this[Ni].set(r.type,r),this[Ni].set(r.type.toLowerCase(),r))}getSVGClass(r){return this[Mn].get(r)}setSVGClass(r,t){this[Mn].set(t??r.type.toLowerCase(),r)}},Hr=new class extends Array{remove(r){const t=this.indexOf(r);t>-1&&this.splice(t,1)}cancelAll(){const r=this.splice(0);return r.forEach((t=>t.abort())),r}cancelByCanvas(r){if(!r)return[];const t=this.filter((e=>{var i;return e.target===r||typeof e.target=="object"&&((i=e.target)===null||i===void 0?void 0:i.canvas)===r}));return t.forEach((e=>e.abort())),t}cancelByTarget(r){if(!r)return[];const t=this.filter((e=>e.target===r));return t.forEach((e=>e.abort())),t}};class Yp{constructor(){v(this,"__eventListeners",{})}on(t,e){if(this.__eventListeners||(this.__eventListeners={}),typeof t=="object")return Object.entries(t).forEach((i=>{let[s,n]=i;this.on(s,n)})),()=>this.off(t);if(e){const i=t;return this.__eventListeners[i]||(this.__eventListeners[i]=[]),this.__eventListeners[i].push(e),()=>this.off(i,e)}return()=>!1}once(t,e){if(typeof t=="object"){const i=[];return Object.entries(t).forEach((s=>{let[n,o]=s;i.push(this.once(n,o))})),()=>i.forEach((s=>s()))}if(e){const i=this.on(t,(function(){for(var s=arguments.length,n=new Array(s),o=0;o<s;o++)n[o]=arguments[o];e.call(this,...n),i()}));return i}return()=>!1}_removeEventListener(t,e){if(this.__eventListeners[t])if(e){const i=this.__eventListeners[t],s=i.indexOf(e);s>-1&&i.splice(s,1)}else this.__eventListeners[t]=[]}off(t,e){if(this.__eventListeners)if(t===void 0)for(const i in this.__eventListeners)this._removeEventListener(i);else typeof t=="object"?Object.entries(t).forEach((i=>{let[s,n]=i;this._removeEventListener(s,n)})):this._removeEventListener(t,e)}fire(t,e){var i;if(!this.__eventListeners)return;const s=(i=this.__eventListeners[t])===null||i===void 0?void 0:i.concat();if(s)for(let n=0;n<s.length;n++)s[n].call(this,e||{})}}const Yi=(r,t)=>{const e=r.indexOf(t);return e!==-1&&r.splice(e,1),r},Je=r=>{if(r===0)return 1;switch(Math.abs(r)/Ks){case 1:case 3:return 0;case 2:return-1}return Math.cos(r)},Qe=r=>{if(r===0)return 0;const t=r/Ks,e=Math.sign(r);switch(t){case 1:return e;case 2:return 0;case 3:return-e}return Math.sin(r)};class x{constructor(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:0,e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0;typeof t=="object"?(this.x=t.x,this.y=t.y):(this.x=t,this.y=e)}add(t){return new x(this.x+t.x,this.y+t.y)}addEquals(t){return this.x+=t.x,this.y+=t.y,this}scalarAdd(t){return new x(this.x+t,this.y+t)}scalarAddEquals(t){return this.x+=t,this.y+=t,this}subtract(t){return new x(this.x-t.x,this.y-t.y)}subtractEquals(t){return this.x-=t.x,this.y-=t.y,this}scalarSubtract(t){return new x(this.x-t,this.y-t)}scalarSubtractEquals(t){return this.x-=t,this.y-=t,this}multiply(t){return new x(this.x*t.x,this.y*t.y)}scalarMultiply(t){return new x(this.x*t,this.y*t)}scalarMultiplyEquals(t){return this.x*=t,this.y*=t,this}divide(t){return new x(this.x/t.x,this.y/t.y)}scalarDivide(t){return new x(this.x/t,this.y/t)}scalarDivideEquals(t){return this.x/=t,this.y/=t,this}eq(t){return this.x===t.x&&this.y===t.y}lt(t){return this.x<t.x&&this.y<t.y}lte(t){return this.x<=t.x&&this.y<=t.y}gt(t){return this.x>t.x&&this.y>t.y}gte(t){return this.x>=t.x&&this.y>=t.y}lerp(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:.5;return e=Math.max(Math.min(1,e),0),new x(this.x+(t.x-this.x)*e,this.y+(t.y-this.y)*e)}distanceFrom(t){const e=this.x-t.x,i=this.y-t.y;return Math.sqrt(e*e+i*i)}midPointFrom(t){return this.lerp(t)}min(t){return new x(Math.min(this.x,t.x),Math.min(this.y,t.y))}max(t){return new x(Math.max(this.x,t.x),Math.max(this.y,t.y))}toString(){return"".concat(this.x,",").concat(this.y)}setXY(t,e){return this.x=t,this.y=e,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setFromPoint(t){return this.x=t.x,this.y=t.y,this}swap(t){const e=this.x,i=this.y;this.x=t.x,this.y=t.y,t.x=e,t.y=i}clone(){return new x(this.x,this.y)}rotate(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:Lo;const i=Qe(t),s=Je(t),n=this.subtract(e);return new x(n.x*s-n.y*i,n.x*i+n.y*s).add(e)}transform(t){let e=arguments.length>1&&arguments[1]!==void 0&&arguments[1];return new x(t[0]*this.x+t[2]*this.y+(e?0:t[4]),t[1]*this.x+t[3]*this.y+(e?0:t[5]))}}const Lo=new x(0,0),Dr=r=>!!r&&Array.isArray(r._objects);function pc(r){class t extends r{constructor(){super(...arguments),v(this,"_objects",[])}_onObjectAdded(i){}_onObjectRemoved(i){}_onStackOrderChanged(i){}add(){for(var i=arguments.length,s=new Array(i),n=0;n<i;n++)s[n]=arguments[n];const o=this._objects.push(...s);return s.forEach((a=>this._onObjectAdded(a))),o}insertAt(i){for(var s=arguments.length,n=new Array(s>1?s-1:0),o=1;o<s;o++)n[o-1]=arguments[o];return this._objects.splice(i,0,...n),n.forEach((a=>this._onObjectAdded(a))),this._objects.length}remove(){const i=this._objects,s=[];for(var n=arguments.length,o=new Array(n),a=0;a<n;a++)o[a]=arguments[a];return o.forEach((l=>{const c=i.indexOf(l);c!==-1&&(i.splice(c,1),s.push(l),this._onObjectRemoved(l))})),s}forEachObject(i){this.getObjects().forEach(((s,n,o)=>i(s,n,o)))}getObjects(){for(var i=arguments.length,s=new Array(i),n=0;n<i;n++)s[n]=arguments[n];return s.length===0?[...this._objects]:this._objects.filter((o=>o.isType(...s)))}item(i){return this._objects[i]}isEmpty(){return this._objects.length===0}size(){return this._objects.length}contains(i,s){return!!this._objects.includes(i)||!!s&&this._objects.some((n=>n instanceof t&&n.contains(i,!0)))}complexity(){return this._objects.reduce(((i,s)=>i+=s.complexity?s.complexity():0),0)}sendObjectToBack(i){return!(!i||i===this._objects[0])&&(Yi(this._objects,i),this._objects.unshift(i),this._onStackOrderChanged(i),!0)}bringObjectToFront(i){return!(!i||i===this._objects[this._objects.length-1])&&(Yi(this._objects,i),this._objects.push(i),this._onStackOrderChanged(i),!0)}sendObjectBackwards(i,s){if(!i)return!1;const n=this._objects.indexOf(i);if(n!==0){const o=this.findNewLowerIndex(i,n,s);return Yi(this._objects,i),this._objects.splice(o,0,i),this._onStackOrderChanged(i),!0}return!1}bringObjectForward(i,s){if(!i)return!1;const n=this._objects.indexOf(i);if(n!==this._objects.length-1){const o=this.findNewUpperIndex(i,n,s);return Yi(this._objects,i),this._objects.splice(o,0,i),this._onStackOrderChanged(i),!0}return!1}moveObjectTo(i,s){return i!==this._objects[s]&&(Yi(this._objects,i),this._objects.splice(s,0,i),this._onStackOrderChanged(i),!0)}findNewLowerIndex(i,s,n){let o;if(n){o=s;for(let a=s-1;a>=0;--a)if(i.isOverlapping(this._objects[a])){o=a;break}}else o=s-1;return o}findNewUpperIndex(i,s,n){let o;if(n){o=s;for(let a=s+1;a<this._objects.length;++a)if(i.isOverlapping(this._objects[a])){o=a;break}}else o=s+1;return o}collectObjects(i){let{left:s,top:n,width:o,height:a}=i,{includeIntersecting:l=!0}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};const c=[],h=new x(s,n),d=h.add(new x(o,a));for(let u=this._objects.length-1;u>=0;u--){const p=this._objects[u];p.selectable&&p.visible&&(l&&p.intersectsWithRect(h,d)||p.isContainedWithinRect(h,d)||l&&p.containsPoint(h)||l&&p.containsPoint(d))&&c.push(p)}return c}}return t}class gc extends Yp{_setOptions(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};for(const e in t)this.set(e,t[e])}_setObject(t){for(const e in t)this._set(e,t[e])}set(t,e){return typeof t=="object"?this._setObject(t):this._set(t,e),this}_set(t,e){this[t]=e}toggle(t){const e=this.get(t);return typeof e=="boolean"&&this.set(t,!e),this}get(t){return this[t]}}function Mr(r){return an().requestAnimationFrame(r)}function Gp(r){return an().cancelAnimationFrame(r)}let Xp=0;const mi=()=>Xp++,ti=()=>{const r=ss().createElement("canvas");if(!r||r.getContext===void 0)throw new je("Failed to create `canvas` element");return r},qp=()=>ss().createElement("img"),ve=r=>{const t=ti();return t.width=r.width,t.height=r.height,t},fc=(r,t,e)=>r.toDataURL("image/".concat(t),e),mc=(r,t,e)=>new Promise(((i,s)=>{r.toBlob(i,"image/".concat(t),e)})),_t=r=>r*Ao,ei=r=>r/Ao,Kp=r=>r.every(((t,e)=>t===Kt[e])),Qt=(r,t,e)=>new x(r).transform(t,e),Ce=r=>{const t=1/(r[0]*r[3]-r[1]*r[2]),e=[t*r[3],-t*r[1],-t*r[2],t*r[0],0,0],{x:i,y:s}=new x(r[4],r[5]).transform(e,!0);return e[4]=-i,e[5]=-s,e},$t=(r,t,e)=>[r[0]*t[0]+r[2]*t[1],r[1]*t[0]+r[3]*t[1],r[0]*t[2]+r[2]*t[3],r[1]*t[2]+r[3]*t[3],e?0:r[0]*t[4]+r[2]*t[5]+r[4],e?0:r[1]*t[4]+r[3]*t[5]+r[5]],Fo=(r,t)=>r.reduceRight(((e,i)=>i&&e?$t(i,e,t):i||e),void 0)||Kt.concat(),bc=r=>{let[t,e]=r;return Math.atan2(e,t)},Vr=r=>{const t=bc(r),e=Math.pow(r[0],2)+Math.pow(r[1],2),i=Math.sqrt(e),s=(r[0]*r[3]-r[2]*r[1])/i,n=Math.atan2(r[0]*r[2]+r[1]*r[3],e);return{angle:ei(t),scaleX:i,scaleY:s,skewX:ei(n),skewY:0,translateX:r[4]||0,translateY:r[5]||0}},Zs=function(r){return[1,0,0,1,r,arguments.length>1&&arguments[1]!==void 0?arguments[1]:0]};function os(){let{angle:r=0}=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},{x:t=0,y:e=0}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};const i=_t(r),s=Je(i),n=Qe(i);return[s,n,-n,s,t?t-(s*t-n*e):0,e?e-(n*t+s*e):0]}const jo=function(r){return[r,0,0,arguments.length>1&&arguments[1]!==void 0?arguments[1]:r,0,0]},vc=r=>Math.tan(_t(r)),yc=r=>[1,0,vc(r),1,0,0],_c=r=>[1,vc(r),0,1,0,0],hn=r=>{let{scaleX:t=1,scaleY:e=1,flipX:i=!1,flipY:s=!1,skewX:n=0,skewY:o=0}=r,a=jo(i?-t:t,s?-e:e);return n&&(a=$t(a,yc(n),!0)),o&&(a=$t(a,_c(o),!0)),a},Zp=r=>{const{translateX:t=0,translateY:e=0,angle:i=0}=r;let s=Zs(t,e);i&&(s=$t(s,os({angle:i})));const n=hn(r);return Kp(n)||(s=$t(s,n)),s},Ir=function(r){let{signal:t,crossOrigin:e=null}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return new Promise((function(i,s){if(t&&t.aborted)return s(new zp("loadImage"));const n=qp();let o;t&&(o=function(l){n.src="",s(l)},t.addEventListener("abort",o,{once:!0}));const a=function(){n.onload=n.onerror=null,o&&(t==null||t.removeEventListener("abort",o)),i(n)};r?(n.onload=a,n.onerror=function(){o&&(t==null||t.removeEventListener("abort",o)),s(new je("Error loading ".concat(n.src)))},e&&(n.crossOrigin=e),n.src=r):a()}))},Vs=function(r){let{signal:t,reviver:e=Ar}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return new Promise(((i,s)=>{const n=[];t&&t.addEventListener("abort",s,{once:!0}),Promise.all(r.map((o=>A.getClass(o.type).fromObject(o,{signal:t}).then((a=>(e(o,a),n.push(a),a)))))).then(i).catch((o=>{n.forEach((a=>{a.dispose&&a.dispose()})),s(o)})).finally((()=>{t&&t.removeEventListener("abort",s)}))}))},dn=function(r){let{signal:t}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return new Promise(((e,i)=>{const s=[];t&&t.addEventListener("abort",i,{once:!0});const n=Object.values(r).map((a=>a&&a.type&&A.has(a.type)?Vs([a],{signal:t}).then((l=>{let[c]=l;return s.push(c),c})):a)),o=Object.keys(r);Promise.all(n).then((a=>a.reduce(((l,c,h)=>(l[o[h]]=c,l)),{}))).then(e).catch((a=>{s.forEach((l=>{l.dispose&&l.dispose()})),i(a)})).finally((()=>{t&&t.removeEventListener("abort",i)}))}))},as=function(r){return(arguments.length>1&&arguments[1]!==void 0?arguments[1]:[]).reduce(((t,e)=>(e in r&&(t[e]=r[e]),t)),{})},$o=(r,t)=>Object.keys(r).reduce(((e,i)=>(t(r[i],i,r)&&(e[i]=r[i]),e)),{}),tt=(r,t)=>parseFloat(Number(r).toFixed(t)),Ns=r=>"matrix("+r.map((t=>tt(t,W.NUM_FRACTION_DIGITS))).join(" ")+")",ge=r=>!!r&&r.toLive!==void 0,Ya=r=>!!r&&typeof r.toObject=="function",Ga=r=>!!r&&r.offsetX!==void 0&&"source"in r,Ti=r=>!!r&&"multiSelectionStacking"in r;function xc(r){const t=r&&we(r);let e=0,i=0;if(!r||!t)return{left:e,top:i};let s=r;const n=t.documentElement,o=t.body||{scrollLeft:0,scrollTop:0};for(;s&&(s.parentNode||s.host)&&(s=s.parentNode||s.host,s===t?(e=o.scrollLeft||n.scrollLeft||0,i=o.scrollTop||n.scrollTop||0):(e+=s.scrollLeft||0,i+=s.scrollTop||0),s.nodeType!==1||s.style.position!=="fixed"););return{left:e,top:i}}const we=r=>r.ownerDocument||null,wc=r=>{var t;return((t=r.ownerDocument)===null||t===void 0?void 0:t.defaultView)||null},Cc=function(r,t,e){let{width:i,height:s}=e,n=arguments.length>3&&arguments[3]!==void 0?arguments[3]:1;r.width=i,r.height=s,n>1&&(r.setAttribute("width",(i*n).toString()),r.setAttribute("height",(s*n).toString()),t.scale(n,n))},no=(r,t)=>{let{width:e,height:i}=t;e&&(r.style.width=typeof e=="number"?"".concat(e,"px"):e),i&&(r.style.height=typeof i=="number"?"".concat(i,"px"):i)};function Xa(r){return r.onselectstart!==void 0&&(r.onselectstart=()=>!1),r.style.userSelect=se,r}class Sc{constructor(t){v(this,"_originalCanvasStyle",void 0),v(this,"lower",void 0);const e=this.createLowerCanvas(t);this.lower={el:e,ctx:e.getContext("2d")}}createLowerCanvas(t){const e=(i=t)&&i.getContext!==void 0?t:t&&ss().getElementById(t)||ti();var i;if(e.hasAttribute("data-fabric"))throw new je("Trying to initialize a canvas that has already been initialized. Did you forget to dispose the canvas?");return this._originalCanvasStyle=e.style.cssText,e.setAttribute("data-fabric","main"),e.classList.add("lower-canvas"),e}cleanupDOM(t){let{width:e,height:i}=t;const{el:s}=this.lower;s.classList.remove("lower-canvas"),s.removeAttribute("data-fabric"),s.setAttribute("width","".concat(e)),s.setAttribute("height","".concat(i)),s.style.cssText=this._originalCanvasStyle||"",this._originalCanvasStyle=void 0}setDimensions(t,e){const{el:i,ctx:s}=this.lower;Cc(i,s,t,e)}setCSSDimensions(t){no(this.lower.el,t)}calcOffset(){return(function(t){var e;const i=t&&we(t),s={left:0,top:0};if(!i)return s;const n=((e=wc(t))===null||e===void 0?void 0:e.getComputedStyle(t,null))||{};s.left+=parseInt(n.borderLeftWidth,10)||0,s.top+=parseInt(n.borderTopWidth,10)||0,s.left+=parseInt(n.paddingLeft,10)||0,s.top+=parseInt(n.paddingTop,10)||0;let o={left:0,top:0};const a=i.documentElement;t.getBoundingClientRect!==void 0&&(o=t.getBoundingClientRect());const l=xc(t);return{left:o.left+l.left-(a.clientLeft||0)+s.left,top:o.top+l.top-(a.clientTop||0)+s.top}})(this.lower.el)}dispose(){Re().dispose(this.lower.el),delete this.lower}}const Jp={backgroundVpt:!0,backgroundColor:"",overlayVpt:!0,overlayColor:"",includeDefaultValues:!0,svgViewportTransformation:!0,renderOnAddRemove:!0,skipOffscreen:!0,enableRetinaScaling:!0,imageSmoothingEnabled:!0,controlsAboveOverlay:!1,allowTouchScrolling:!1,viewportTransform:[...Kt]},Qp=["objects"];class Js extends pc(gc){get lowerCanvasEl(){var t;return(t=this.elements.lower)===null||t===void 0?void 0:t.el}get contextContainer(){var t;return(t=this.elements.lower)===null||t===void 0?void 0:t.ctx}static getDefaults(){return Js.ownDefaults}constructor(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};super(),Object.assign(this,this.constructor.getDefaults()),this.set(e),this.initElements(t),this._setDimensionsImpl({width:this.width||this.elements.lower.el.width||0,height:this.height||this.elements.lower.el.height||0}),this.skipControlsDrawing=!1,this.viewportTransform=[...this.viewportTransform],this.calcViewportBoundaries()}initElements(t){this.elements=new Sc(t)}add(){const t=super.add(...arguments);return arguments.length>0&&this.renderOnAddRemove&&this.requestRenderAll(),t}insertAt(t){for(var e=arguments.length,i=new Array(e>1?e-1:0),s=1;s<e;s++)i[s-1]=arguments[s];const n=super.insertAt(t,...i);return i.length>0&&this.renderOnAddRemove&&this.requestRenderAll(),n}remove(){const t=super.remove(...arguments);return t.length>0&&this.renderOnAddRemove&&this.requestRenderAll(),t}_onObjectAdded(t){t.canvas&&t.canvas!==this&&(fi("warn",`Canvas is trying to add an object that belongs to a different canvas.
|
|
2322
|
+
Resulting to default behavior: removing object from previous canvas and adding to new canvas`),t.canvas.remove(t)),t._set("canvas",this),t.setCoords(),this.fire("object:added",{target:t}),t.fire("added",{target:this})}_onObjectRemoved(t){t._set("canvas",void 0),this.fire("object:removed",{target:t}),t.fire("removed",{target:this})}_onStackOrderChanged(){this.renderOnAddRemove&&this.requestRenderAll()}getRetinaScaling(){return this.enableRetinaScaling?cc():1}calcOffset(){return this._offset=this.elements.calcOffset()}getWidth(){return this.width}getHeight(){return this.height}setWidth(t,e){return this.setDimensions({width:t},e)}setHeight(t,e){return this.setDimensions({height:t},e)}_setDimensionsImpl(t){let{cssOnly:e=!1,backstoreOnly:i=!1}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(!e){const s=y({width:this.width,height:this.height},t);this.elements.setDimensions(s,this.getRetinaScaling()),this.hasLostContext=!0,this.width=s.width,this.height=s.height}i||this.elements.setCSSDimensions(t),this.calcOffset()}setDimensions(t,e){this._setDimensionsImpl(t,e),e&&e.cssOnly||this.requestRenderAll()}getZoom(){return this.viewportTransform[0]}setViewportTransform(t){this.viewportTransform=t,this.calcViewportBoundaries(),this.renderOnAddRemove&&this.requestRenderAll()}zoomToPoint(t,e){const i=t,s=[...this.viewportTransform],n=Qt(t,Ce(s));s[0]=e,s[3]=e;const o=Qt(n,s);s[4]+=i.x-o.x,s[5]+=i.y-o.y,this.setViewportTransform(s)}setZoom(t){this.zoomToPoint(new x(0,0),t)}absolutePan(t){const e=[...this.viewportTransform];return e[4]=-t.x,e[5]=-t.y,this.setViewportTransform(e)}relativePan(t){return this.absolutePan(new x(-t.x-this.viewportTransform[4],-t.y-this.viewportTransform[5]))}getElement(){return this.elements.lower.el}clearContext(t){t.clearRect(0,0,this.width,this.height)}getContext(){return this.elements.lower.ctx}clear(){this.remove(...this.getObjects()),this.backgroundImage=void 0,this.overlayImage=void 0,this.backgroundColor="",this.overlayColor="",this.clearContext(this.getContext()),this.fire("canvas:cleared"),this.renderOnAddRemove&&this.requestRenderAll()}renderAll(){this.cancelRequestedRender(),this.destroyed||this.renderCanvas(this.getContext(),this._objects)}renderAndReset(){this.nextRenderHandle=0,this.renderAll()}requestRenderAll(){this.nextRenderHandle||this.disposed||this.destroyed||(this.nextRenderHandle=Mr((()=>this.renderAndReset())))}calcViewportBoundaries(){const t=this.width,e=this.height,i=Ce(this.viewportTransform),s=Qt({x:0,y:0},i),n=Qt({x:t,y:e},i),o=s.min(n),a=s.max(n);return this.vptCoords={tl:o,tr:new x(a.x,o.y),bl:new x(o.x,a.y),br:a}}cancelRequestedRender(){this.nextRenderHandle&&(Gp(this.nextRenderHandle),this.nextRenderHandle=0)}drawControls(t){}renderCanvas(t,e){if(this.destroyed)return;const i=this.viewportTransform,s=this.clipPath;this.calcViewportBoundaries(),this.clearContext(t),t.imageSmoothingEnabled=this.imageSmoothingEnabled,t.patternQuality="best",this.fire("before:render",{ctx:t}),this._renderBackground(t),t.save(),t.transform(i[0],i[1],i[2],i[3],i[4],i[5]),this._renderObjects(t,e),t.restore(),this.controlsAboveOverlay||this.skipControlsDrawing||this.drawControls(t),s&&(s._set("canvas",this),s.shouldCache(),s._transformDone=!0,s.renderCache({forClipping:!0}),this.drawClipPathOnCanvas(t,s)),this._renderOverlay(t),this.controlsAboveOverlay&&!this.skipControlsDrawing&&this.drawControls(t),this.fire("after:render",{ctx:t}),this.__cleanupTask&&(this.__cleanupTask(),this.__cleanupTask=void 0)}drawClipPathOnCanvas(t,e){const i=this.viewportTransform;t.save(),t.transform(...i),t.globalCompositeOperation="destination-in",e.transform(t),t.scale(1/e.zoomX,1/e.zoomY),t.drawImage(e._cacheCanvas,-e.cacheTranslationX,-e.cacheTranslationY),t.restore()}_renderObjects(t,e){for(let i=0,s=e.length;i<s;++i)e[i]&&e[i].render(t)}_renderBackgroundOrOverlay(t,e){const i=this["".concat(e,"Color")],s=this["".concat(e,"Image")],n=this.viewportTransform,o=this["".concat(e,"Vpt")];if(!i&&!s)return;const a=ge(i);if(i){if(t.save(),t.beginPath(),t.moveTo(0,0),t.lineTo(this.width,0),t.lineTo(this.width,this.height),t.lineTo(0,this.height),t.closePath(),t.fillStyle=a?i.toLive(t):i,o&&t.transform(...n),a){t.transform(1,0,0,1,i.offsetX||0,i.offsetY||0);const l=i.gradientTransform||i.patternTransform;l&&t.transform(...l)}t.fill(),t.restore()}if(s){t.save();const{skipOffscreen:l}=this;this.skipOffscreen=o,o&&t.transform(...n),s.render(t),this.skipOffscreen=l,t.restore()}}_renderBackground(t){this._renderBackgroundOrOverlay(t,"background")}_renderOverlay(t){this._renderBackgroundOrOverlay(t,"overlay")}getCenter(){return{top:this.height/2,left:this.width/2}}getCenterPoint(){return new x(this.width/2,this.height/2)}centerObjectH(t){return this._centerObject(t,new x(this.getCenterPoint().x,t.getCenterPoint().y))}centerObjectV(t){return this._centerObject(t,new x(t.getCenterPoint().x,this.getCenterPoint().y))}centerObject(t){return this._centerObject(t,this.getCenterPoint())}viewportCenterObject(t){return this._centerObject(t,this.getVpCenter())}viewportCenterObjectH(t){return this._centerObject(t,new x(this.getVpCenter().x,t.getCenterPoint().y))}viewportCenterObjectV(t){return this._centerObject(t,new x(t.getCenterPoint().x,this.getVpCenter().y))}getVpCenter(){return Qt(this.getCenterPoint(),Ce(this.viewportTransform))}_centerObject(t,e){t.setXY(e,V,V),t.setCoords(),this.renderOnAddRemove&&this.requestRenderAll()}toDatalessJSON(t){return this.toDatalessObject(t)}toObject(t){return this._toObjectMethod("toObject",t)}toJSON(){return this.toObject()}toDatalessObject(t){return this._toObjectMethod("toDatalessObject",t)}_toObjectMethod(t,e){const i=this.clipPath,s=i&&!i.excludeFromExport?this._toObject(i,t,e):null;return y(y(y({version:so},as(this,e)),{},{objects:this._objects.filter((n=>!n.excludeFromExport)).map((n=>this._toObject(n,t,e)))},this.__serializeBgOverlay(t,e)),s?{clipPath:s}:null)}_toObject(t,e,i){let s;this.includeDefaultValues||(s=t.includeDefaultValues,t.includeDefaultValues=!1);const n=t[e](i);return this.includeDefaultValues||(t.includeDefaultValues=!!s),n}__serializeBgOverlay(t,e){const i={},s=this.backgroundImage,n=this.overlayImage,o=this.backgroundColor,a=this.overlayColor;return ge(o)?o.excludeFromExport||(i.background=o.toObject(e)):o&&(i.background=o),ge(a)?a.excludeFromExport||(i.overlay=a.toObject(e)):a&&(i.overlay=a),s&&!s.excludeFromExport&&(i.backgroundImage=this._toObject(s,t,e)),n&&!n.excludeFromExport&&(i.overlayImage=this._toObject(n,t,e)),i}toSVG(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},e=arguments.length>1?arguments[1]:void 0;t.reviver=e;const i=[];return this._setSVGPreamble(i,t),this._setSVGHeader(i,t),this.clipPath&&i.push('<g clip-path="url(#'.concat(this.clipPath.clipPathId,`)" >
|
|
2323
2323
|
`)),this._setSVGBgOverlayColor(i,"background"),this._setSVGBgOverlayImage(i,"backgroundImage",e),this._setSVGObjects(i,e),this.clipPath&&i.push(`</g>
|
|
2324
2324
|
`),this._setSVGBgOverlayColor(i,"overlay"),this._setSVGBgOverlayImage(i,"overlayImage",e),i.push("</svg>"),i.join("")}_setSVGPreamble(t,e){e.suppressPreamble||t.push('<?xml version="1.0" encoding="',e.encoding||"UTF-8",`" standalone="no" ?>
|
|
2325
2325
|
`,'<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" ',`"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
|
2326
|
-
`)}_setSVGHeader(t,e){const i=e.width||"".concat(this.width),s=e.height||"".concat(this.height),n=W.NUM_FRACTION_DIGITS,o=e.viewBox;let a;if(o)a='viewBox="'.concat(o.x," ").concat(o.y," ").concat(o.width," ").concat(o.height,'" ');else if(this.svgViewportTransformation){const l=this.viewportTransform;a='viewBox="'.concat(
|
|
2326
|
+
`)}_setSVGHeader(t,e){const i=e.width||"".concat(this.width),s=e.height||"".concat(this.height),n=W.NUM_FRACTION_DIGITS,o=e.viewBox;let a;if(o)a='viewBox="'.concat(o.x," ").concat(o.y," ").concat(o.width," ").concat(o.height,'" ');else if(this.svgViewportTransformation){const l=this.viewportTransform;a='viewBox="'.concat(tt(-l[4]/l[0],n)," ").concat(tt(-l[5]/l[3],n)," ").concat(tt(this.width/l[0],n)," ").concat(tt(this.height/l[3],n),'" ')}else a='viewBox="0 0 '.concat(this.width," ").concat(this.height,'" ');t.push("<svg ",'xmlns="http://www.w3.org/2000/svg" ','xmlns:xlink="http://www.w3.org/1999/xlink" ','version="1.1" ','width="',i,'" ','height="',s,'" ',a,`xml:space="preserve">
|
|
2327
2327
|
`,"<desc>Created with Fabric.js ",so,`</desc>
|
|
2328
2328
|
`,`<defs>
|
|
2329
2329
|
`,this.createSVGFontFacesMarkup(),this.createSVGRefElementsMarkup(),this.createSVGClipPathMarkup(e),`</defs>
|
|
2330
|
-
`)}createSVGClipPathMarkup(t){const e=this.clipPath;return e?(e.clipPathId="CLIPPATH_".concat(
|
|
2330
|
+
`)}createSVGClipPathMarkup(t){const e=this.clipPath;return e?(e.clipPathId="CLIPPATH_".concat(mi()),'<clipPath id="'.concat(e.clipPathId,`" >
|
|
2331
2331
|
`).concat(e.toClipPathSVG(t.reviver),`</clipPath>
|
|
2332
2332
|
`)):""}createSVGRefElementsMarkup(){return["background","overlay"].map((t=>{const e=this["".concat(t,"Color")];if(ge(e)){const i=this["".concat(t,"Vpt")],s=this.viewportTransform,n={isType:()=>!1,width:this.width/(i?s[0]:1),height:this.height/(i?s[3]:1)};return e.toSVG(n,{additionalTransform:i?Ns(s):""})}})).join("")}createSVGFontFacesMarkup(){const t=[],e={},i=W.fontPaths;this._objects.forEach((function n(o){t.push(o),Dr(o)&&o._objects.forEach(n)})),t.forEach((n=>{if(!(o=n)||typeof o._renderText!="function")return;var o;const{styles:a,fontFamily:l}=n;!e[l]&&i[l]&&(e[l]=!0,a&&Object.values(a).forEach((c=>{Object.values(c).forEach((h=>{let{fontFamily:d=""}=h;!e[d]&&i[d]&&(e[d]=!0)}))})))}));const s=Object.keys(e).map((n=>` @font-face {
|
|
2333
2333
|
font-family: '`.concat(n,`';
|
|
@@ -2337,15 +2337,15 @@ Resulting to default behavior: removing object from previous canvas and adding t
|
|
|
2337
2337
|
`.concat(s,`]]></style>
|
|
2338
2338
|
`):""}_setSVGObjects(t,e){this.forEachObject((i=>{i.excludeFromExport||this._setSVGObject(t,i,e)}))}_setSVGObject(t,e,i){t.push(e.toSVG(i))}_setSVGBgOverlayImage(t,e,i){const s=this[e];s&&!s.excludeFromExport&&s.toSVG&&t.push(s.toSVG(i))}_setSVGBgOverlayColor(t,e){const i=this["".concat(e,"Color")];if(i)if(ge(i)){const s=i.repeat||"",n=this.width,o=this.height,a=this["".concat(e,"Vpt")]?Ns(Ce(this.viewportTransform)):"";t.push('<rect transform="'.concat(a," translate(").concat(n/2,",").concat(o/2,')" x="').concat(i.offsetX-n/2,'" y="').concat(i.offsetY-o/2,'" width="').concat(s!=="repeat-y"&&s!=="no-repeat"||!Ga(i)?n:i.source.width,'" height="').concat(s!=="repeat-x"&&s!=="no-repeat"||!Ga(i)?o:i.source.height,'" fill="url(#SVGID_').concat(i.id,`)"></rect>
|
|
2339
2339
|
`))}else t.push('<rect x="0" y="0" width="100%" height="100%" ','fill="',i,'"',`></rect>
|
|
2340
|
-
`)}loadFromJSON(t,e){let{signal:i}=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};if(!t)return Promise.reject(new je("`json` is undefined"));const s=typeof t=="string"?JSON.parse(t):t,{objects:n=[]}=s,o=rt(s,Qp),{backgroundImage:a,background:l,overlayImage:c,overlay:h,clipPath:d}=o,u=this.renderOnAddRemove;return this.renderOnAddRemove=!1,Promise.all([Vs(n,{reviver:e,signal:i}),dn({backgroundImage:a,backgroundColor:l,overlayImage:c,overlayColor:h,clipPath:d},{signal:i})]).then((p=>{let[g,f]=p;return this.clear(),this.add(...g),this.set(o),this.set(f),this.renderOnAddRemove=u,this}))}clone(t){const e=this.toObject(t);return this.cloneWithoutData().loadFromJSON(e)}cloneWithoutData(){const t=ve(this);return new this.constructor(t)}toDataURL(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};const{format:e="png",quality:i=1,multiplier:s=1,enableRetinaScaling:n=!1}=t,o=s*(n?this.getRetinaScaling():1);return mc(this.toCanvasElement(o,t),e,i)}toBlob(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};const{format:e="png",quality:i=1,multiplier:s=1,enableRetinaScaling:n=!1}=t,o=s*(n?this.getRetinaScaling():1);return bc(this.toCanvasElement(o,t),e,i)}toCanvasElement(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:1,{width:e,height:i,left:s,top:n,filter:o}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};const a=(e||this.width)*t,l=(i||this.height)*t,c=this.getZoom(),h=this.width,d=this.height,u=this.skipControlsDrawing,p=c*t,g=this.viewportTransform,f=[p,0,0,p,(g[4]-(s||0))*t,(g[5]-(n||0))*t],m=this.enableRetinaScaling,b=ve({width:a,height:l}),_=o?this._objects.filter((w=>o(w))):this._objects;return this.enableRetinaScaling=!1,this.viewportTransform=f,this.width=a,this.height=l,this.skipControlsDrawing=!0,this.calcViewportBoundaries(),this.renderCanvas(b.getContext("2d"),_),this.viewportTransform=g,this.width=h,this.height=d,this.calcViewportBoundaries(),this.enableRetinaScaling=m,this.skipControlsDrawing=u,b}dispose(){return!this.disposed&&this.elements.cleanupDOM({width:this.width,height:this.height}),Hr.cancelByCanvas(this),this.disposed=!0,new Promise(((t,e)=>{const i=()=>{this.destroy(),t(!0)};i.kill=e,this.__cleanupTask&&this.__cleanupTask.kill("aborted"),this.destroyed?t(!1):this.nextRenderHandle?this.__cleanupTask=i:i()}))}destroy(){this.destroyed=!0,this.cancelRequestedRender(),this.forEachObject((t=>t.dispose())),this._objects=[],this.backgroundImage&&this.backgroundImage.dispose(),this.backgroundImage=void 0,this.overlayImage&&this.overlayImage.dispose(),this.overlayImage=void 0,this.elements.dispose()}toString(){return"#<Canvas (".concat(this.complexity(),"): { objects: ").concat(this._objects.length," }>")}}v(Js,"ownDefaults",Jp);const tg=["touchstart","touchmove","touchend"],eg=r=>{const t=wc(r.target),e=(function(i){const s=i.changedTouches;return s&&s[0]?s[0]:i})(r);return new x(e.clientX+t.left,e.clientY+t.top)},oo=r=>tg.includes(r.type)||r.pointerType==="touch",Ka=r=>{r.preventDefault(),r.stopPropagation()},Ke=r=>{let t=0,e=0,i=0,s=0;for(let n=0,o=r.length;n<o;n++){const{x:a,y:l}=r[n];(a>i||!n)&&(i=a),(a<t||!n)&&(t=a),(l>s||!n)&&(s=l),(l<e||!n)&&(e=l)}return{left:t,top:e,width:i-t,height:s-e}},ig=["translateX","translateY","scaleX","scaleY"],sg=(r,t)=>Nr(r,Rt(t,r.calcOwnMatrix())),Nr=(r,t)=>{const e=Vr(t),{translateX:i,translateY:s,scaleX:n,scaleY:o}=e,a=rt(e,ig),l=new x(i,s);r.flipX=!1,r.flipY=!1,Object.assign(r,a),r.set({scaleX:n,scaleY:o}),r.setPositionByOrigin(l,V,V)},rg=r=>{r.scaleX=1,r.scaleY=1,r.skewX=0,r.skewY=0,r.flipX=!1,r.flipY=!1,r.rotate(0)},Ec=r=>({scaleX:r.scaleX,scaleY:r.scaleY,skewX:r.skewX,skewY:r.skewY,angle:r.angle,left:r.left,flipX:r.flipX,flipY:r.flipY,top:r.top}),Ro=(r,t,e)=>{const i=r/2,s=t/2,n=[new x(-i,-s),new x(i,-s),new x(-i,s),new x(i,s)].map((a=>a.transform(e))),o=Ke(n);return new x(o.width,o.height)},un=function(){let r=arguments.length>0&&arguments[0]!==void 0?arguments[0]:qt;return Rt(Ce(arguments.length>1&&arguments[1]!==void 0?arguments[1]:qt),r)},Zi=function(r){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:qt,e=arguments.length>2&&arguments[2]!==void 0?arguments[2]:qt;return r.transform(un(t,e))},ng=function(r){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:qt,e=arguments.length>2&&arguments[2]!==void 0?arguments[2]:qt;return r.transform(un(t,e),!0)},og=(r,t,e)=>{const i=un(t,e);return Nr(r,Rt(i,r.calcOwnMatrix())),i},Oc=(r,t)=>{var e;const{transform:{target:i}}=t;(e=i.canvas)===null||e===void 0||e.fire("object:".concat(r),y(y({},t),{},{target:i})),i.fire(r,t)},ag={left:-.5,top:-.5,center:0,bottom:.5,right:.5},Tt=r=>typeof r=="string"?ag[r]:r-.5,Ur="not-allowed";function kc(r){return Tt(r.originX)===Tt(V)&&Tt(r.originY)===Tt(V)}function qa(r){return .5-Tt(r)}const Ee=(r,t)=>r[t],Pc=(r,t,e,i)=>({e:r,transform:t,pointer:new x(e,i)});function Ac(r,t){const e=r.getTotalAngle()+ei(Math.atan2(t.y,t.x))+360;return Math.round(e%360/45)}function Bo(r,t,e,i,s){var n;let{target:o,corner:a}=r;const l=o.controls[a],c=((n=o.canvas)===null||n===void 0?void 0:n.getZoom())||1,h=o.padding/c,d=(function(u,p,g,f){const m=u.getRelativeCenterPoint(),b=g!==void 0&&f!==void 0?u.translateToGivenOrigin(m,V,V,g,f):new x(u.left,u.top);return(u.angle?p.rotate(-xt(u.angle),m):p).subtract(b)})(o,new x(i,s),t,e);return d.x>=h&&(d.x-=h),d.x<=-h&&(d.x+=h),d.y>=h&&(d.y-=h),d.y<=h&&(d.y+=h),d.x-=l.offsetX,d.y-=l.offsetY,d}const lg=(r,t,e,i)=>{const{target:s,offsetX:n,offsetY:o}=t,a=e-n,l=i-o,c=!Ee(s,"lockMovementX")&&s.left!==a,h=!Ee(s,"lockMovementY")&&s.top!==l;return c&&s.set(Y,a),h&&s.set(ie,l),(c||h)&&Oc(dc,Pc(r,t,e,i)),c||h},Wr=r=>r.replace(/\s+/g," "),Za={aliceblue:"#F0F8FF",antiquewhite:"#FAEBD7",aqua:"#0FF",aquamarine:"#7FFFD4",azure:"#F0FFFF",beige:"#F5F5DC",bisque:"#FFE4C4",black:"#000",blanchedalmond:"#FFEBCD",blue:"#00F",blueviolet:"#8A2BE2",brown:"#A52A2A",burlywood:"#DEB887",cadetblue:"#5F9EA0",chartreuse:"#7FFF00",chocolate:"#D2691E",coral:"#FF7F50",cornflowerblue:"#6495ED",cornsilk:"#FFF8DC",crimson:"#DC143C",cyan:"#0FF",darkblue:"#00008B",darkcyan:"#008B8B",darkgoldenrod:"#B8860B",darkgray:"#A9A9A9",darkgrey:"#A9A9A9",darkgreen:"#006400",darkkhaki:"#BDB76B",darkmagenta:"#8B008B",darkolivegreen:"#556B2F",darkorange:"#FF8C00",darkorchid:"#9932CC",darkred:"#8B0000",darksalmon:"#E9967A",darkseagreen:"#8FBC8F",darkslateblue:"#483D8B",darkslategray:"#2F4F4F",darkslategrey:"#2F4F4F",darkturquoise:"#00CED1",darkviolet:"#9400D3",deeppink:"#FF1493",deepskyblue:"#00BFFF",dimgray:"#696969",dimgrey:"#696969",dodgerblue:"#1E90FF",firebrick:"#B22222",floralwhite:"#FFFAF0",forestgreen:"#228B22",fuchsia:"#F0F",gainsboro:"#DCDCDC",ghostwhite:"#F8F8FF",gold:"#FFD700",goldenrod:"#DAA520",gray:"#808080",grey:"#808080",green:"#008000",greenyellow:"#ADFF2F",honeydew:"#F0FFF0",hotpink:"#FF69B4",indianred:"#CD5C5C",indigo:"#4B0082",ivory:"#FFFFF0",khaki:"#F0E68C",lavender:"#E6E6FA",lavenderblush:"#FFF0F5",lawngreen:"#7CFC00",lemonchiffon:"#FFFACD",lightblue:"#ADD8E6",lightcoral:"#F08080",lightcyan:"#E0FFFF",lightgoldenrodyellow:"#FAFAD2",lightgray:"#D3D3D3",lightgrey:"#D3D3D3",lightgreen:"#90EE90",lightpink:"#FFB6C1",lightsalmon:"#FFA07A",lightseagreen:"#20B2AA",lightskyblue:"#87CEFA",lightslategray:"#789",lightslategrey:"#789",lightsteelblue:"#B0C4DE",lightyellow:"#FFFFE0",lime:"#0F0",limegreen:"#32CD32",linen:"#FAF0E6",magenta:"#F0F",maroon:"#800000",mediumaquamarine:"#66CDAA",mediumblue:"#0000CD",mediumorchid:"#BA55D3",mediumpurple:"#9370DB",mediumseagreen:"#3CB371",mediumslateblue:"#7B68EE",mediumspringgreen:"#00FA9A",mediumturquoise:"#48D1CC",mediumvioletred:"#C71585",midnightblue:"#191970",mintcream:"#F5FFFA",mistyrose:"#FFE4E1",moccasin:"#FFE4B5",navajowhite:"#FFDEAD",navy:"#000080",oldlace:"#FDF5E6",olive:"#808000",olivedrab:"#6B8E23",orange:"#FFA500",orangered:"#FF4500",orchid:"#DA70D6",palegoldenrod:"#EEE8AA",palegreen:"#98FB98",paleturquoise:"#AFEEEE",palevioletred:"#DB7093",papayawhip:"#FFEFD5",peachpuff:"#FFDAB9",peru:"#CD853F",pink:"#FFC0CB",plum:"#DDA0DD",powderblue:"#B0E0E6",purple:"#800080",rebeccapurple:"#639",red:"#F00",rosybrown:"#BC8F8F",royalblue:"#4169E1",saddlebrown:"#8B4513",salmon:"#FA8072",sandybrown:"#F4A460",seagreen:"#2E8B57",seashell:"#FFF5EE",sienna:"#A0522D",silver:"#C0C0C0",skyblue:"#87CEEB",slateblue:"#6A5ACD",slategray:"#708090",slategrey:"#708090",snow:"#FFFAFA",springgreen:"#00FF7F",steelblue:"#4682B4",tan:"#D2B48C",teal:"#008080",thistle:"#D8BFD8",tomato:"#FF6347",turquoise:"#40E0D0",violet:"#EE82EE",wheat:"#F5DEB3",white:"#FFF",whitesmoke:"#F5F5F5",yellow:"#FF0",yellowgreen:"#9ACD32"},In=(r,t,e)=>(e<0&&(e+=1),e>1&&(e-=1),e<1/6?r+6*(t-r)*e:e<.5?t:e<2/3?r+(t-r)*(2/3-e)*6:r),Ja=(r,t,e,i)=>{r/=255,t/=255,e/=255;const s=Math.max(r,t,e),n=Math.min(r,t,e);let o,a;const l=(s+n)/2;if(s===n)o=a=0;else{const c=s-n;switch(a=l>.5?c/(2-s-n):c/(s+n),s){case r:o=(t-e)/c+(t<e?6:0);break;case t:o=(e-r)/c+2;break;case e:o=(r-t)/c+4}o/=6}return[Math.round(360*o),Math.round(100*a),Math.round(100*l),i]},Qa=function(){let r=arguments.length>0&&arguments[0]!==void 0?arguments[0]:"1";return parseFloat(r)/(r.endsWith("%")?100:1)},rr=r=>Math.min(Math.round(r),255).toString(16).toUpperCase().padStart(2,"0"),tl=r=>{let[t,e,i,s=1]=r;const n=Math.round(.3*t+.59*e+.11*i);return[n,n,n,s]};class K{constructor(t){if(v(this,"isUnrecognised",!1),t)if(t instanceof K)this.setSource([...t._source]);else if(Array.isArray(t)){const[e,i,s,n=1]=t;this.setSource([e,i,s,n])}else this.setSource(this._tryParsingColor(t));else this.setSource([0,0,0,1])}_tryParsingColor(t){return(t=t.toLowerCase())in Za&&(t=Za[t]),t==="transparent"?[255,255,255,0]:K.sourceFromHex(t)||K.sourceFromRgb(t)||K.sourceFromHsl(t)||(this.isUnrecognised=!0)&&[0,0,0,1]}getSource(){return this._source}setSource(t){this._source=t}toRgb(){const[t,e,i]=this.getSource();return"rgb(".concat(t,",").concat(e,",").concat(i,")")}toRgba(){return"rgba(".concat(this.getSource().join(","),")")}toHsl(){const[t,e,i]=Ja(...this.getSource());return"hsl(".concat(t,",").concat(e,"%,").concat(i,"%)")}toHsla(){const[t,e,i,s]=Ja(...this.getSource());return"hsla(".concat(t,",").concat(e,"%,").concat(i,"%,").concat(s,")")}toHex(){return this.toHexa().slice(0,6)}toHexa(){const[t,e,i,s]=this.getSource();return"".concat(rr(t)).concat(rr(e)).concat(rr(i)).concat(rr(Math.round(255*s)))}getAlpha(){return this.getSource()[3]}setAlpha(t){return this._source[3]=t,this}toGrayscale(){return this.setSource(tl(this.getSource())),this}toBlackWhite(t){const[e,,,i]=tl(this.getSource()),s=e<(t||127)?0:255;return this.setSource([s,s,s,i]),this}overlayWith(t){t instanceof K||(t=new K(t));const e=this.getSource(),i=t.getSource(),[s,n,o]=e.map(((a,l)=>Math.round(.5*a+.5*i[l])));return this.setSource([s,n,o,e[3]]),this}static fromRgb(t){return K.fromRgba(t)}static fromRgba(t){return new K(K.sourceFromRgb(t))}static sourceFromRgb(t){const e=Wr(t).match(/^rgba?\(\s?(\d{0,3}(?:\.\d+)?%?)\s?[\s|,]\s?(\d{0,3}(?:\.\d+)?%?)\s?[\s|,]\s?(\d{0,3}(?:\.\d+)?%?)\s?(?:\s?[,/]\s?(\d{0,3}(?:\.\d+)?%?)\s?)?\)$/i);if(e){const[i,s,n]=e.slice(1,4).map((o=>{const a=parseFloat(o);return o.endsWith("%")?Math.round(2.55*a):a}));return[i,s,n,Qa(e[4])]}}static fromHsl(t){return K.fromHsla(t)}static fromHsla(t){return new K(K.sourceFromHsl(t))}static sourceFromHsl(t){const e=Wr(t).match(/^hsla?\(\s?([+-]?\d{0,3}(?:\.\d+)?(?:deg|turn|rad)?)\s?[\s|,]\s?(\d{0,3}(?:\.\d+)?%?)\s?[\s|,]\s?(\d{0,3}(?:\.\d+)?%?)\s?(?:\s?[,/]\s?(\d*(?:\.\d+)?%?)\s?)?\)$/i);if(!e)return;const i=(K.parseAngletoDegrees(e[1])%360+360)%360/360,s=parseFloat(e[2])/100,n=parseFloat(e[3])/100;let o,a,l;if(s===0)o=a=l=n;else{const c=n<=.5?n*(s+1):n+s-n*s,h=2*n-c;o=In(h,c,i+1/3),a=In(h,c,i),l=In(h,c,i-1/3)}return[Math.round(255*o),Math.round(255*a),Math.round(255*l),Qa(e[4])]}static fromHex(t){return new K(K.sourceFromHex(t))}static sourceFromHex(t){if(t.match(/^#?(([0-9a-f]){3,4}|([0-9a-f]{2}){3,4})$/i)){const e=t.slice(t.indexOf("#")+1);let i;i=e.length<=4?e.split("").map((l=>l+l)):e.match(/.{2}/g);const[s,n,o,a=255]=i.map((l=>parseInt(l,16)));return[s,n,o,a/255]}}static parseAngletoDegrees(t){const e=t.toLowerCase(),i=parseFloat(e);return e.includes("rad")?ei(i):e.includes("turn")?360*i:i}}const Ji=function(r){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:Do;const e=/\D{0,2}$/.exec(r),i=parseFloat(r),s=W.DPI;switch(e==null?void 0:e[0]){case"mm":return i*s/25.4;case"cm":return i*s/2.54;case"in":return i*s;case"pt":return i*s/72;case"pc":return i*s/72*12;case"em":return i*t;default:return i}},cg=r=>{const[t,e]=r.trim().split(" "),[i,s]=(n=t)&&n!==se?[n.slice(1,4),n.slice(5,8)]:n===se?[n,n]:["Mid","Mid"];var n;return{meetOrSlice:e||"meet",alignX:i,alignY:s}},Us=function(r,t){let e,i,s=!(arguments.length>2&&arguments[2]!==void 0)||arguments[2];if(t)if(t.toLive)e="url(#SVGID_".concat(t.id,")");else{const n=new K(t),o=n.getAlpha();e=n.toRgb(),o!==1&&(i=o.toString())}else e="none";return s?"".concat(r,": ").concat(e,"; ").concat(i?"".concat(r,"-opacity: ").concat(i,"; "):""):"".concat(r,'="').concat(e,'" ').concat(i?"".concat(r,'-opacity="').concat(i,'" '):"")};class Dc{getSvgStyles(t){const e=this.fillRule?this.fillRule:"nonzero",i=this.strokeWidth?this.strokeWidth:"0",s=this.strokeDashArray?this.strokeDashArray.join(" "):se,n=this.strokeDashOffset?this.strokeDashOffset:"0",o=this.strokeLineCap?this.strokeLineCap:"butt",a=this.strokeLineJoin?this.strokeLineJoin:"miter",l=this.strokeMiterLimit?this.strokeMiterLimit:"4",c=this.opacity!==void 0?this.opacity:"1",h=this.visible?"":" visibility: hidden;",d=t?"":this.getSvgFilter(),u=Us(Dt,this.fill);return[Us(re,this.stroke),"stroke-width: ",i,"; ","stroke-dasharray: ",s,"; ","stroke-linecap: ",o,"; ","stroke-dashoffset: ",n,"; ","stroke-linejoin: ",a,"; ","stroke-miterlimit: ",l,"; ",u,"fill-rule: ",e,"; ","opacity: ",c,";",d,h].join("")}getSvgFilter(){return this.shadow?"filter: url(#SVGID_".concat(this.shadow.id,");"):""}getSvgCommons(){return[this.id?'id="'.concat(this.id,'" '):"",this.clipPath?'clip-path="url(#'.concat(this.clipPath.clipPathId,')" '):""].join("")}getSvgTransform(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"";const i=t?this.calcTransformMatrix():this.calcOwnMatrix(),s='transform="'.concat(Ns(i));return"".concat(s).concat(e,'" ')}_toSVG(t){return[""]}toSVG(t){return this._createBaseSVGMarkup(this._toSVG(t),{reviver:t})}toClipPathSVG(t){return" "+this._createBaseClipPathSVGMarkup(this._toSVG(t),{reviver:t})}_createBaseClipPathSVGMarkup(t){let{reviver:e,additionalTransform:i=""}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};const s=[this.getSvgTransform(!0,i),this.getSvgCommons()].join(""),n=t.indexOf("COMMON_PARTS");return t[n]=s,e?e(t.join("")):t.join("")}_createBaseSVGMarkup(t){let{noStyle:e,reviver:i,withShadow:s,additionalTransform:n}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};const o=e?"":'style="'.concat(this.getSvgStyles(),'" '),a=s?'style="'.concat(this.getSvgFilter(),'" '):"",l=this.clipPath,c=this.strokeUniform?'vector-effect="non-scaling-stroke" ':"",h=l&&l.absolutePositioned,d=this.stroke,u=this.fill,p=this.shadow,g=[],f=t.indexOf("COMMON_PARTS");let m;l&&(l.clipPathId="CLIPPATH_".concat(bi()),m='<clipPath id="'.concat(l.clipPathId,`" >
|
|
2340
|
+
`)}loadFromJSON(t,e){let{signal:i}=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};if(!t)return Promise.reject(new je("`json` is undefined"));const s=typeof t=="string"?JSON.parse(t):t,{objects:n=[]}=s,o=rt(s,Qp),{backgroundImage:a,background:l,overlayImage:c,overlay:h,clipPath:d}=o,u=this.renderOnAddRemove;return this.renderOnAddRemove=!1,Promise.all([Vs(n,{reviver:e,signal:i}),dn({backgroundImage:a,backgroundColor:l,overlayImage:c,overlayColor:h,clipPath:d},{signal:i})]).then((p=>{let[g,f]=p;return this.clear(),this.add(...g),this.set(o),this.set(f),this.renderOnAddRemove=u,this}))}clone(t){const e=this.toObject(t);return this.cloneWithoutData().loadFromJSON(e)}cloneWithoutData(){const t=ve(this);return new this.constructor(t)}toDataURL(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};const{format:e="png",quality:i=1,multiplier:s=1,enableRetinaScaling:n=!1}=t,o=s*(n?this.getRetinaScaling():1);return fc(this.toCanvasElement(o,t),e,i)}toBlob(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};const{format:e="png",quality:i=1,multiplier:s=1,enableRetinaScaling:n=!1}=t,o=s*(n?this.getRetinaScaling():1);return mc(this.toCanvasElement(o,t),e,i)}toCanvasElement(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:1,{width:e,height:i,left:s,top:n,filter:o}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};const a=(e||this.width)*t,l=(i||this.height)*t,c=this.getZoom(),h=this.width,d=this.height,u=this.skipControlsDrawing,p=c*t,g=this.viewportTransform,f=[p,0,0,p,(g[4]-(s||0))*t,(g[5]-(n||0))*t],m=this.enableRetinaScaling,b=ve({width:a,height:l}),_=o?this._objects.filter((w=>o(w))):this._objects;return this.enableRetinaScaling=!1,this.viewportTransform=f,this.width=a,this.height=l,this.skipControlsDrawing=!0,this.calcViewportBoundaries(),this.renderCanvas(b.getContext("2d"),_),this.viewportTransform=g,this.width=h,this.height=d,this.calcViewportBoundaries(),this.enableRetinaScaling=m,this.skipControlsDrawing=u,b}dispose(){return!this.disposed&&this.elements.cleanupDOM({width:this.width,height:this.height}),Hr.cancelByCanvas(this),this.disposed=!0,new Promise(((t,e)=>{const i=()=>{this.destroy(),t(!0)};i.kill=e,this.__cleanupTask&&this.__cleanupTask.kill("aborted"),this.destroyed?t(!1):this.nextRenderHandle?this.__cleanupTask=i:i()}))}destroy(){this.destroyed=!0,this.cancelRequestedRender(),this.forEachObject((t=>t.dispose())),this._objects=[],this.backgroundImage&&this.backgroundImage.dispose(),this.backgroundImage=void 0,this.overlayImage&&this.overlayImage.dispose(),this.overlayImage=void 0,this.elements.dispose()}toString(){return"#<Canvas (".concat(this.complexity(),"): { objects: ").concat(this._objects.length," }>")}}v(Js,"ownDefaults",Jp);const tg=["touchstart","touchmove","touchend"],eg=r=>{const t=xc(r.target),e=(function(i){const s=i.changedTouches;return s&&s[0]?s[0]:i})(r);return new x(e.clientX+t.left,e.clientY+t.top)},oo=r=>tg.includes(r.type)||r.pointerType==="touch",qa=r=>{r.preventDefault(),r.stopPropagation()},qe=r=>{let t=0,e=0,i=0,s=0;for(let n=0,o=r.length;n<o;n++){const{x:a,y:l}=r[n];(a>i||!n)&&(i=a),(a<t||!n)&&(t=a),(l>s||!n)&&(s=l),(l<e||!n)&&(e=l)}return{left:t,top:e,width:i-t,height:s-e}},ig=["translateX","translateY","scaleX","scaleY"],sg=(r,t)=>Nr(r,$t(t,r.calcOwnMatrix())),Nr=(r,t)=>{const e=Vr(t),{translateX:i,translateY:s,scaleX:n,scaleY:o}=e,a=rt(e,ig),l=new x(i,s);r.flipX=!1,r.flipY=!1,Object.assign(r,a),r.set({scaleX:n,scaleY:o}),r.setPositionByOrigin(l,V,V)},rg=r=>{r.scaleX=1,r.scaleY=1,r.skewX=0,r.skewY=0,r.flipX=!1,r.flipY=!1,r.rotate(0)},Tc=r=>({scaleX:r.scaleX,scaleY:r.scaleY,skewX:r.skewX,skewY:r.skewY,angle:r.angle,left:r.left,flipX:r.flipX,flipY:r.flipY,top:r.top}),Ro=(r,t,e)=>{const i=r/2,s=t/2,n=[new x(-i,-s),new x(i,-s),new x(-i,s),new x(i,s)].map((a=>a.transform(e))),o=qe(n);return new x(o.width,o.height)},un=function(){let r=arguments.length>0&&arguments[0]!==void 0?arguments[0]:Kt;return $t(Ce(arguments.length>1&&arguments[1]!==void 0?arguments[1]:Kt),r)},Zi=function(r){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:Kt,e=arguments.length>2&&arguments[2]!==void 0?arguments[2]:Kt;return r.transform(un(t,e))},ng=function(r){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:Kt,e=arguments.length>2&&arguments[2]!==void 0?arguments[2]:Kt;return r.transform(un(t,e),!0)},og=(r,t,e)=>{const i=un(t,e);return Nr(r,$t(i,r.calcOwnMatrix())),i},Ec=(r,t)=>{var e;const{transform:{target:i}}=t;(e=i.canvas)===null||e===void 0||e.fire("object:".concat(r),y(y({},t),{},{target:i})),i.fire(r,t)},ag={left:-.5,top:-.5,center:0,bottom:.5,right:.5},St=r=>typeof r=="string"?ag[r]:r-.5,Ur="not-allowed";function Oc(r){return St(r.originX)===St(V)&&St(r.originY)===St(V)}function Ka(r){return .5-St(r)}const Ee=(r,t)=>r[t],kc=(r,t,e,i)=>({e:r,transform:t,pointer:new x(e,i)});function Pc(r,t){const e=r.getTotalAngle()+ei(Math.atan2(t.y,t.x))+360;return Math.round(e%360/45)}function Bo(r,t,e,i,s){var n;let{target:o,corner:a}=r;const l=o.controls[a],c=((n=o.canvas)===null||n===void 0?void 0:n.getZoom())||1,h=o.padding/c,d=(function(u,p,g,f){const m=u.getRelativeCenterPoint(),b=g!==void 0&&f!==void 0?u.translateToGivenOrigin(m,V,V,g,f):new x(u.left,u.top);return(u.angle?p.rotate(-_t(u.angle),m):p).subtract(b)})(o,new x(i,s),t,e);return d.x>=h&&(d.x-=h),d.x<=-h&&(d.x+=h),d.y>=h&&(d.y-=h),d.y<=h&&(d.y+=h),d.x-=l.offsetX,d.y-=l.offsetY,d}const lg=(r,t,e,i)=>{const{target:s,offsetX:n,offsetY:o}=t,a=e-n,l=i-o,c=!Ee(s,"lockMovementX")&&s.left!==a,h=!Ee(s,"lockMovementY")&&s.top!==l;return c&&s.set(Y,a),h&&s.set(ie,l),(c||h)&&Ec(hc,kc(r,t,e,i)),c||h},Wr=r=>r.replace(/\s+/g," "),Za={aliceblue:"#F0F8FF",antiquewhite:"#FAEBD7",aqua:"#0FF",aquamarine:"#7FFFD4",azure:"#F0FFFF",beige:"#F5F5DC",bisque:"#FFE4C4",black:"#000",blanchedalmond:"#FFEBCD",blue:"#00F",blueviolet:"#8A2BE2",brown:"#A52A2A",burlywood:"#DEB887",cadetblue:"#5F9EA0",chartreuse:"#7FFF00",chocolate:"#D2691E",coral:"#FF7F50",cornflowerblue:"#6495ED",cornsilk:"#FFF8DC",crimson:"#DC143C",cyan:"#0FF",darkblue:"#00008B",darkcyan:"#008B8B",darkgoldenrod:"#B8860B",darkgray:"#A9A9A9",darkgrey:"#A9A9A9",darkgreen:"#006400",darkkhaki:"#BDB76B",darkmagenta:"#8B008B",darkolivegreen:"#556B2F",darkorange:"#FF8C00",darkorchid:"#9932CC",darkred:"#8B0000",darksalmon:"#E9967A",darkseagreen:"#8FBC8F",darkslateblue:"#483D8B",darkslategray:"#2F4F4F",darkslategrey:"#2F4F4F",darkturquoise:"#00CED1",darkviolet:"#9400D3",deeppink:"#FF1493",deepskyblue:"#00BFFF",dimgray:"#696969",dimgrey:"#696969",dodgerblue:"#1E90FF",firebrick:"#B22222",floralwhite:"#FFFAF0",forestgreen:"#228B22",fuchsia:"#F0F",gainsboro:"#DCDCDC",ghostwhite:"#F8F8FF",gold:"#FFD700",goldenrod:"#DAA520",gray:"#808080",grey:"#808080",green:"#008000",greenyellow:"#ADFF2F",honeydew:"#F0FFF0",hotpink:"#FF69B4",indianred:"#CD5C5C",indigo:"#4B0082",ivory:"#FFFFF0",khaki:"#F0E68C",lavender:"#E6E6FA",lavenderblush:"#FFF0F5",lawngreen:"#7CFC00",lemonchiffon:"#FFFACD",lightblue:"#ADD8E6",lightcoral:"#F08080",lightcyan:"#E0FFFF",lightgoldenrodyellow:"#FAFAD2",lightgray:"#D3D3D3",lightgrey:"#D3D3D3",lightgreen:"#90EE90",lightpink:"#FFB6C1",lightsalmon:"#FFA07A",lightseagreen:"#20B2AA",lightskyblue:"#87CEFA",lightslategray:"#789",lightslategrey:"#789",lightsteelblue:"#B0C4DE",lightyellow:"#FFFFE0",lime:"#0F0",limegreen:"#32CD32",linen:"#FAF0E6",magenta:"#F0F",maroon:"#800000",mediumaquamarine:"#66CDAA",mediumblue:"#0000CD",mediumorchid:"#BA55D3",mediumpurple:"#9370DB",mediumseagreen:"#3CB371",mediumslateblue:"#7B68EE",mediumspringgreen:"#00FA9A",mediumturquoise:"#48D1CC",mediumvioletred:"#C71585",midnightblue:"#191970",mintcream:"#F5FFFA",mistyrose:"#FFE4E1",moccasin:"#FFE4B5",navajowhite:"#FFDEAD",navy:"#000080",oldlace:"#FDF5E6",olive:"#808000",olivedrab:"#6B8E23",orange:"#FFA500",orangered:"#FF4500",orchid:"#DA70D6",palegoldenrod:"#EEE8AA",palegreen:"#98FB98",paleturquoise:"#AFEEEE",palevioletred:"#DB7093",papayawhip:"#FFEFD5",peachpuff:"#FFDAB9",peru:"#CD853F",pink:"#FFC0CB",plum:"#DDA0DD",powderblue:"#B0E0E6",purple:"#800080",rebeccapurple:"#639",red:"#F00",rosybrown:"#BC8F8F",royalblue:"#4169E1",saddlebrown:"#8B4513",salmon:"#FA8072",sandybrown:"#F4A460",seagreen:"#2E8B57",seashell:"#FFF5EE",sienna:"#A0522D",silver:"#C0C0C0",skyblue:"#87CEEB",slateblue:"#6A5ACD",slategray:"#708090",slategrey:"#708090",snow:"#FFFAFA",springgreen:"#00FF7F",steelblue:"#4682B4",tan:"#D2B48C",teal:"#008080",thistle:"#D8BFD8",tomato:"#FF6347",turquoise:"#40E0D0",violet:"#EE82EE",wheat:"#F5DEB3",white:"#FFF",whitesmoke:"#F5F5F5",yellow:"#FF0",yellowgreen:"#9ACD32"},In=(r,t,e)=>(e<0&&(e+=1),e>1&&(e-=1),e<1/6?r+6*(t-r)*e:e<.5?t:e<2/3?r+(t-r)*(2/3-e)*6:r),Ja=(r,t,e,i)=>{r/=255,t/=255,e/=255;const s=Math.max(r,t,e),n=Math.min(r,t,e);let o,a;const l=(s+n)/2;if(s===n)o=a=0;else{const c=s-n;switch(a=l>.5?c/(2-s-n):c/(s+n),s){case r:o=(t-e)/c+(t<e?6:0);break;case t:o=(e-r)/c+2;break;case e:o=(r-t)/c+4}o/=6}return[Math.round(360*o),Math.round(100*a),Math.round(100*l),i]},Qa=function(){let r=arguments.length>0&&arguments[0]!==void 0?arguments[0]:"1";return parseFloat(r)/(r.endsWith("%")?100:1)},rr=r=>Math.min(Math.round(r),255).toString(16).toUpperCase().padStart(2,"0"),tl=r=>{let[t,e,i,s=1]=r;const n=Math.round(.3*t+.59*e+.11*i);return[n,n,n,s]};class q{constructor(t){if(v(this,"isUnrecognised",!1),t)if(t instanceof q)this.setSource([...t._source]);else if(Array.isArray(t)){const[e,i,s,n=1]=t;this.setSource([e,i,s,n])}else this.setSource(this._tryParsingColor(t));else this.setSource([0,0,0,1])}_tryParsingColor(t){return(t=t.toLowerCase())in Za&&(t=Za[t]),t==="transparent"?[255,255,255,0]:q.sourceFromHex(t)||q.sourceFromRgb(t)||q.sourceFromHsl(t)||(this.isUnrecognised=!0)&&[0,0,0,1]}getSource(){return this._source}setSource(t){this._source=t}toRgb(){const[t,e,i]=this.getSource();return"rgb(".concat(t,",").concat(e,",").concat(i,")")}toRgba(){return"rgba(".concat(this.getSource().join(","),")")}toHsl(){const[t,e,i]=Ja(...this.getSource());return"hsl(".concat(t,",").concat(e,"%,").concat(i,"%)")}toHsla(){const[t,e,i,s]=Ja(...this.getSource());return"hsla(".concat(t,",").concat(e,"%,").concat(i,"%,").concat(s,")")}toHex(){return this.toHexa().slice(0,6)}toHexa(){const[t,e,i,s]=this.getSource();return"".concat(rr(t)).concat(rr(e)).concat(rr(i)).concat(rr(Math.round(255*s)))}getAlpha(){return this.getSource()[3]}setAlpha(t){return this._source[3]=t,this}toGrayscale(){return this.setSource(tl(this.getSource())),this}toBlackWhite(t){const[e,,,i]=tl(this.getSource()),s=e<(t||127)?0:255;return this.setSource([s,s,s,i]),this}overlayWith(t){t instanceof q||(t=new q(t));const e=this.getSource(),i=t.getSource(),[s,n,o]=e.map(((a,l)=>Math.round(.5*a+.5*i[l])));return this.setSource([s,n,o,e[3]]),this}static fromRgb(t){return q.fromRgba(t)}static fromRgba(t){return new q(q.sourceFromRgb(t))}static sourceFromRgb(t){const e=Wr(t).match(/^rgba?\(\s?(\d{0,3}(?:\.\d+)?%?)\s?[\s|,]\s?(\d{0,3}(?:\.\d+)?%?)\s?[\s|,]\s?(\d{0,3}(?:\.\d+)?%?)\s?(?:\s?[,/]\s?(\d{0,3}(?:\.\d+)?%?)\s?)?\)$/i);if(e){const[i,s,n]=e.slice(1,4).map((o=>{const a=parseFloat(o);return o.endsWith("%")?Math.round(2.55*a):a}));return[i,s,n,Qa(e[4])]}}static fromHsl(t){return q.fromHsla(t)}static fromHsla(t){return new q(q.sourceFromHsl(t))}static sourceFromHsl(t){const e=Wr(t).match(/^hsla?\(\s?([+-]?\d{0,3}(?:\.\d+)?(?:deg|turn|rad)?)\s?[\s|,]\s?(\d{0,3}(?:\.\d+)?%?)\s?[\s|,]\s?(\d{0,3}(?:\.\d+)?%?)\s?(?:\s?[,/]\s?(\d*(?:\.\d+)?%?)\s?)?\)$/i);if(!e)return;const i=(q.parseAngletoDegrees(e[1])%360+360)%360/360,s=parseFloat(e[2])/100,n=parseFloat(e[3])/100;let o,a,l;if(s===0)o=a=l=n;else{const c=n<=.5?n*(s+1):n+s-n*s,h=2*n-c;o=In(h,c,i+1/3),a=In(h,c,i),l=In(h,c,i-1/3)}return[Math.round(255*o),Math.round(255*a),Math.round(255*l),Qa(e[4])]}static fromHex(t){return new q(q.sourceFromHex(t))}static sourceFromHex(t){if(t.match(/^#?(([0-9a-f]){3,4}|([0-9a-f]{2}){3,4})$/i)){const e=t.slice(t.indexOf("#")+1);let i;i=e.length<=4?e.split("").map((l=>l+l)):e.match(/.{2}/g);const[s,n,o,a=255]=i.map((l=>parseInt(l,16)));return[s,n,o,a/255]}}static parseAngletoDegrees(t){const e=t.toLowerCase(),i=parseFloat(e);return e.includes("rad")?ei(i):e.includes("turn")?360*i:i}}const Ji=function(r){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:Do;const e=/\D{0,2}$/.exec(r),i=parseFloat(r),s=W.DPI;switch(e==null?void 0:e[0]){case"mm":return i*s/25.4;case"cm":return i*s/2.54;case"in":return i*s;case"pt":return i*s/72;case"pc":return i*s/72*12;case"em":return i*t;default:return i}},cg=r=>{const[t,e]=r.trim().split(" "),[i,s]=(n=t)&&n!==se?[n.slice(1,4),n.slice(5,8)]:n===se?[n,n]:["Mid","Mid"];var n;return{meetOrSlice:e||"meet",alignX:i,alignY:s}},Us=function(r,t){let e,i,s=!(arguments.length>2&&arguments[2]!==void 0)||arguments[2];if(t)if(t.toLive)e="url(#SVGID_".concat(t.id,")");else{const n=new q(t),o=n.getAlpha();e=n.toRgb(),o!==1&&(i=o.toString())}else e="none";return s?"".concat(r,": ").concat(e,"; ").concat(i?"".concat(r,"-opacity: ").concat(i,"; "):""):"".concat(r,'="').concat(e,'" ').concat(i?"".concat(r,'-opacity="').concat(i,'" '):"")};class Ac{getSvgStyles(t){const e=this.fillRule?this.fillRule:"nonzero",i=this.strokeWidth?this.strokeWidth:"0",s=this.strokeDashArray?this.strokeDashArray.join(" "):se,n=this.strokeDashOffset?this.strokeDashOffset:"0",o=this.strokeLineCap?this.strokeLineCap:"butt",a=this.strokeLineJoin?this.strokeLineJoin:"miter",l=this.strokeMiterLimit?this.strokeMiterLimit:"4",c=this.opacity!==void 0?this.opacity:"1",h=this.visible?"":" visibility: hidden;",d=t?"":this.getSvgFilter(),u=Us(Dt,this.fill);return[Us(re,this.stroke),"stroke-width: ",i,"; ","stroke-dasharray: ",s,"; ","stroke-linecap: ",o,"; ","stroke-dashoffset: ",n,"; ","stroke-linejoin: ",a,"; ","stroke-miterlimit: ",l,"; ",u,"fill-rule: ",e,"; ","opacity: ",c,";",d,h].join("")}getSvgFilter(){return this.shadow?"filter: url(#SVGID_".concat(this.shadow.id,");"):""}getSvgCommons(){return[this.id?'id="'.concat(this.id,'" '):"",this.clipPath?'clip-path="url(#'.concat(this.clipPath.clipPathId,')" '):""].join("")}getSvgTransform(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"";const i=t?this.calcTransformMatrix():this.calcOwnMatrix(),s='transform="'.concat(Ns(i));return"".concat(s).concat(e,'" ')}_toSVG(t){return[""]}toSVG(t){return this._createBaseSVGMarkup(this._toSVG(t),{reviver:t})}toClipPathSVG(t){return" "+this._createBaseClipPathSVGMarkup(this._toSVG(t),{reviver:t})}_createBaseClipPathSVGMarkup(t){let{reviver:e,additionalTransform:i=""}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};const s=[this.getSvgTransform(!0,i),this.getSvgCommons()].join(""),n=t.indexOf("COMMON_PARTS");return t[n]=s,e?e(t.join("")):t.join("")}_createBaseSVGMarkup(t){let{noStyle:e,reviver:i,withShadow:s,additionalTransform:n}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};const o=e?"":'style="'.concat(this.getSvgStyles(),'" '),a=s?'style="'.concat(this.getSvgFilter(),'" '):"",l=this.clipPath,c=this.strokeUniform?'vector-effect="non-scaling-stroke" ':"",h=l&&l.absolutePositioned,d=this.stroke,u=this.fill,p=this.shadow,g=[],f=t.indexOf("COMMON_PARTS");let m;l&&(l.clipPathId="CLIPPATH_".concat(mi()),m='<clipPath id="'.concat(l.clipPathId,`" >
|
|
2341
2341
|
`).concat(l.toClipPathSVG(i),`</clipPath>
|
|
2342
2342
|
`)),h&&g.push("<g ",a,this.getSvgCommons(),` >
|
|
2343
2343
|
`),g.push("<g ",this.getSvgTransform(!1),h?"":a+this.getSvgCommons(),` >
|
|
2344
2344
|
`);const b=[o,c,e?"":this.addPaintOrder()," ",n?'transform="'.concat(n,'" '):""].join("");return t[f]=b,ge(u)&&g.push(u.toSVG(this)),ge(d)&&g.push(d.toSVG(this)),p&&g.push(p.toSVG(this)),l&&g.push(m),g.push(t.join("")),g.push(`</g>
|
|
2345
2345
|
`),h&&g.push(`</g>
|
|
2346
|
-
`),i?i(g.join("")):g.join("")}addPaintOrder(){return this.paintFirst!==Dt?' paint-order="'.concat(this.paintFirst,'" '):""}}function pn(r){return new RegExp("^("+r.join("|")+")\\b","i")}const Ri="textDecorationThickness",
|
|
2347
|
-
<feGaussianBlur in="SourceAlpha" stdDeviation="`).concat(
|
|
2348
|
-
<feOffset dx="`).concat(
|
|
2346
|
+
`),i?i(g.join("")):g.join("")}addPaintOrder(){return this.paintFirst!==Dt?' paint-order="'.concat(this.paintFirst,'" '):""}}function pn(r){return new RegExp("^("+r.join("|")+")\\b","i")}const Ri="textDecorationThickness",Dc=["fontSize","fontWeight","fontFamily","fontStyle"],Mc=["underline","overline","linethrough"],Ic=[...Dc,"lineHeight","text","charSpacing","textAlign","styles","path","pathStartOffset","pathSide","pathAlign"],Lc=[...Ic,...Mc,"textBackgroundColor","direction",Ri],hg=[...Dc,...Mc,re,"strokeWidth",Dt,"deltaY","textBackgroundColor",Ri],dg={_reNewline:Mo,_reSpacesAndTabs:/[ \t\r]/g,_reSpaceAndTab:/[ \t\r]/,_reWords:/\S+/g,fontSize:40,fontWeight:"normal",fontFamily:"Times New Roman",underline:!1,overline:!1,linethrough:!1,textAlign:Y,fontStyle:"normal",lineHeight:1.16,textBackgroundColor:"",stroke:null,shadow:null,path:void 0,pathStartOffset:0,pathSide:Y,pathAlign:"baseline",charSpacing:0,deltaY:0,direction:"ltr",CACHE_FONT_SIZE:400,MIN_TEXT_WIDTH:2,superscript:{size:.6,baseline:-.35},subscript:{size:.6,baseline:.11},_fontSizeFraction:.222,offsets:{underline:.1,linethrough:-.28167,overline:-.81333},_fontSizeMult:1.13,[Ri]:66.667},Le="justify",Yr="justify-left",Ms="justify-right",Is="justify-center";var el,il,sl;const Se=String.raw(el||(el=He(["[-+]?(?:d*.d+|d+.?)(?:[eE][-+]?d+)?"],["[-+]?(?:\\d*\\.\\d+|\\d+\\.?)(?:[eE][-+]?\\d+)?"]))),Ln=String.raw(il||(il=He(["(?:s*,?s+|s*,s*)"],["(?:\\s*,?\\s+|\\s*,\\s*)"]))),ug=new RegExp("(normal|italic)?\\s*(normal|small-caps)?\\s*(normal|bold|bolder|lighter|100|200|300|400|500|600|700|800|900)?\\s*("+Se+"(?:px|cm|mm|em|pt|pc|in)*)(?:\\/(normal|"+Se+"))?\\s+(.*)"),pg={cx:Y,x:Y,r:"radius",cy:ie,y:ie,display:"visible",visibility:"visible",transform:"transformMatrix","fill-opacity":"fillOpacity","fill-rule":"fillRule","font-family":"fontFamily","font-size":"fontSize","font-style":"fontStyle","font-weight":"fontWeight","letter-spacing":"charSpacing","paint-order":"paintFirst","stroke-dasharray":"strokeDashArray","stroke-dashoffset":"strokeDashOffset","stroke-linecap":"strokeLineCap","stroke-linejoin":"strokeLineJoin","stroke-miterlimit":"strokeMiterLimit","stroke-opacity":"strokeOpacity","stroke-width":"strokeWidth","text-decoration":"textDecoration","text-anchor":"textAnchor",opacity:"opacity","clip-path":"clipPath","clip-rule":"clipRule","vector-effect":"strokeUniform","image-rendering":"imageSmoothing","text-decoration-thickness":Ri},Fn="font-size",jn="clip-path";pn(["path","circle","polygon","polyline","ellipse","rect","line","image","text"]);pn(["symbol","image","marker","pattern","view","svg"]);const rl=pn(["symbol","g","a","svg","clipPath","defs"]);new RegExp(String.raw(sl||(sl=He(["^s*(",")","(",")","(",")","(",")s*$"],["^\\s*(",")","(",")","(",")","(",")\\s*$"])),Se,Ln,Se,Ln,Se,Ln,Se));const gg=new x(1,0),Fc=new x,jc=(r,t)=>r.rotate(t),ao=(r,t)=>new x(t).subtract(r),lo=r=>r.distanceFrom(Fc),co=(r,t)=>Math.atan2(Ls(r,t),mg(r,t)),fg=r=>co(gg,r),zo=r=>r.eq(Fc)?r:r.scalarDivide(lo(r)),$c=function(r){let t=!(arguments.length>1&&arguments[1]!==void 0)||arguments[1];return zo(new x(-r.y,r.x).scalarMultiply(t?1:-1))},Ls=(r,t)=>r.x*t.y-r.y*t.x,mg=(r,t)=>r.x*t.x+r.y*t.y,nl=(r,t,e)=>{if(r.eq(t)||r.eq(e))return!0;const i=Ls(t,e),s=Ls(t,r),n=Ls(e,r);return i>=0?s>=0&&n<=0:!(s<=0&&n>=0)},ol="(-?\\d+(?:\\.\\d*)?(?:px)?(?:\\s?|$))?",al=new RegExp("(?:\\s|^)"+ol+ol+"("+Se+"?(?:px)?)?(?:\\s?|$)(?:$|\\s)");class Ke{constructor(t){const e=typeof t=="string"?Ke.parseShadow(t):t;Object.assign(this,Ke.ownDefaults,e),this.id=mi()}static parseShadow(t){const e=t.trim(),[,i=0,s=0,n=0]=(al.exec(e)||[]).map((o=>parseFloat(o)||0));return{color:(e.replace(al,"")||"rgb(0,0,0)").trim(),offsetX:i,offsetY:s,blur:n}}toString(){return[this.offsetX,this.offsetY,this.blur,this.color].join("px ")}toSVG(t){const e=jc(new x(this.offsetX,this.offsetY),_t(-t.angle)),i=new q(this.color);let s=40,n=40;return t.width&&t.height&&(s=100*tt((Math.abs(e.x)+this.blur)/t.width,W.NUM_FRACTION_DIGITS)+20,n=100*tt((Math.abs(e.y)+this.blur)/t.height,W.NUM_FRACTION_DIGITS)+20),t.flipX&&(e.x*=-1),t.flipY&&(e.y*=-1),'<filter id="SVGID_'.concat(this.id,'" y="-').concat(n,'%" height="').concat(100+2*n,'%" x="-').concat(s,'%" width="').concat(100+2*s,`%" >
|
|
2347
|
+
<feGaussianBlur in="SourceAlpha" stdDeviation="`).concat(tt(this.blur?this.blur/2:0,W.NUM_FRACTION_DIGITS),`"></feGaussianBlur>
|
|
2348
|
+
<feOffset dx="`).concat(tt(e.x,W.NUM_FRACTION_DIGITS),'" dy="').concat(tt(e.y,W.NUM_FRACTION_DIGITS),`" result="oBlur" ></feOffset>
|
|
2349
2349
|
<feFlood flood-color="`).concat(i.toRgb(),'" flood-opacity="').concat(i.getAlpha(),`"/>
|
|
2350
2350
|
<feComposite in2="oBlur" operator="in" />
|
|
2351
2351
|
<feMerge>
|
|
@@ -2353,32 +2353,32 @@ Resulting to default behavior: removing object from previous canvas and adding t
|
|
|
2353
2353
|
<feMergeNode in="SourceGraphic"></feMergeNode>
|
|
2354
2354
|
</feMerge>
|
|
2355
2355
|
</filter>
|
|
2356
|
-
`)}toObject(){const t={color:this.color,blur:this.blur,offsetX:this.offsetX,offsetY:this.offsetY,affectStroke:this.affectStroke,nonScaling:this.nonScaling,type:this.constructor.type},e=qe.ownDefaults;return this.includeDefaultValues?t:$o(t,((i,s)=>i!==e[s]))}static async fromObject(t){return new this(t)}}v(qe,"ownDefaults",{color:"rgb(0,0,0)",blur:0,offsetX:0,offsetY:0,affectStroke:!1,includeDefaultValues:!0,nonScaling:!1}),v(qe,"type","shadow"),A.setClass(qe,"shadow");const es=(r,t,e)=>Math.max(r,Math.min(t,e)),bg=[ie,Y,oe,be,"flipX","flipY","originX","originY","angle","opacity","globalCompositeOperation","shadow","visible",rs,ns],ri=[Dt,re,"strokeWidth","strokeDashArray","width","height","paintFirst","strokeUniform","strokeLineCap","strokeDashOffset","strokeLineJoin","strokeMiterLimit","backgroundColor","clipPath"],vg={top:0,left:0,width:0,height:0,angle:0,flipX:!1,flipY:!1,scaleX:1,scaleY:1,minScaleLimit:0,skewX:0,skewY:0,originX:Y,originY:ie,strokeWidth:1,strokeUniform:!1,padding:0,opacity:1,paintFirst:Dt,fill:"rgb(0,0,0)",fillRule:"nonzero",stroke:null,strokeDashArray:null,strokeDashOffset:0,strokeLineCap:"butt",strokeLineJoin:"miter",strokeMiterLimit:4,globalCompositeOperation:"source-over",backgroundColor:"",shadow:null,visible:!0,includeDefaultValues:!0,excludeFromExport:!1,objectCaching:!0,clipPath:void 0,inverted:!1,absolutePositioned:!1,centeredRotation:!0,centeredScaling:!1,dirty:!0},yg=(r,t,e,i)=>-e*Math.cos(r/i*qs)+e+t,_g=()=>!1;class Ho{constructor(t){let{startValue:e,byValue:i,duration:s=500,delay:n=0,easing:o=yg,onStart:a=Ar,onChange:l=Ar,onComplete:c=Ar,abort:h=_g,target:d}=t;v(this,"_state","pending"),v(this,"durationProgress",0),v(this,"valueProgress",0),this.tick=this.tick.bind(this),this.duration=s,this.delay=n,this.easing=o,this._onStart=a,this._onChange=l,this._onComplete=c,this._abort=h,this.target=d,this.startValue=e,this.byValue=i,this.value=this.startValue,this.endValue=Object.freeze(this.calculate(this.duration).value)}get state(){return this._state}isDone(){return this._state==="aborted"||this._state==="completed"}start(){const t=e=>{this._state==="pending"&&(this.startTime=e||+new Date,this._state="running",this._onStart(),this.tick(this.startTime))};this.register(),this.delay>0?setTimeout((()=>Mr(t)),this.delay):Mr(t)}tick(t){const e=(t||+new Date)-this.startTime,i=Math.min(e,this.duration);this.durationProgress=i/this.duration;const{value:s,valueProgress:n}=this.calculate(i);this.value=Object.freeze(s),this.valueProgress=n,this._state!=="aborted"&&(this._abort(this.value,this.valueProgress,this.durationProgress)?(this._state="aborted",this.unregister()):e>=this.duration?(this.durationProgress=this.valueProgress=1,this._onChange(this.endValue,this.valueProgress,this.durationProgress),this._state="completed",this._onComplete(this.endValue,this.valueProgress,this.durationProgress),this.unregister()):(this._onChange(this.value,this.valueProgress,this.durationProgress),Mr(this.tick)))}register(){Hr.push(this)}unregister(){Hr.remove(this)}abort(){this._state="aborted",this.unregister()}}const xg=["startValue","endValue"];class wg extends Ho{constructor(t){let{startValue:e=0,endValue:i=100}=t;super(y(y({},rt(t,xg)),{},{startValue:e,byValue:i-e}))}calculate(t){const e=this.easing(t,this.startValue,this.byValue,this.duration);return{value:e,valueProgress:Math.abs((e-this.startValue)/this.byValue)}}}const Cg=["startValue","endValue"];class Sg extends Ho{constructor(t){let{startValue:e=[0],endValue:i=[100]}=t;super(y(y({},rt(t,Cg)),{},{startValue:e,byValue:i.map(((s,n)=>s-e[n]))}))}calculate(t){const e=this.startValue.map(((i,s)=>this.easing(t,i,this.byValue[s],this.duration,s)));return{value:e,valueProgress:Math.abs((e[0]-this.startValue[0])/this.byValue[0])}}}const Tg=["startValue","endValue","easing","onChange","onComplete","abort"],Eg=(r,t,e,i)=>t+e*(1-Math.cos(r/i*qs)),$n=r=>r&&((t,e,i)=>r(new K(t).toRgba(),e,i));class Og extends Ho{constructor(t){let{startValue:e,endValue:i,easing:s=Eg,onChange:n,onComplete:o,abort:a}=t,l=rt(t,Tg);const c=new K(e).getSource(),h=new K(i).getSource();super(y(y({},l),{},{startValue:c,byValue:h.map(((d,u)=>d-c[u])),easing:s,onChange:$n(n),onComplete:$n(o),abort:$n(a)}))}calculate(t){const[e,i,s,n]=this.startValue.map(((a,l)=>this.easing(t,a,this.byValue[l],this.duration,l))),o=[...[e,i,s].map(Math.round),es(0,n,1)];return{value:o,valueProgress:o.map(((a,l)=>this.byValue[l]!==0?Math.abs((a-this.startValue[l])/this.byValue[l]):0)).find((a=>a!==0))||0}}}function Bc(r){const t=(e=>Array.isArray(e.startValue)||Array.isArray(e.endValue))(r)?new Sg(r):new wg(r);return t.start(),t}function kg(r){const t=new Og(r);return t.start(),t}class lt{constructor(t){this.status=t,this.points=[]}includes(t){return this.points.some((e=>e.eq(t)))}append(){for(var t=arguments.length,e=new Array(t),i=0;i<t;i++)e[i]=arguments[i];return this.points=this.points.concat(e.filter((s=>!this.includes(s)))),this}static isPointContained(t,e,i){let s=arguments.length>3&&arguments[3]!==void 0&&arguments[3];if(e.eq(i))return t.eq(e);if(e.x===i.x)return t.x===e.x&&(s||t.y>=Math.min(e.y,i.y)&&t.y<=Math.max(e.y,i.y));if(e.y===i.y)return t.y===e.y&&(s||t.x>=Math.min(e.x,i.x)&&t.x<=Math.max(e.x,i.x));{const n=ao(e,i),o=ao(e,t).divide(n);return s?Math.abs(o.x)===Math.abs(o.y):o.x===o.y&&o.x>=0&&o.x<=1}}static isPointInPolygon(t,e){const i=new x(t).setX(Math.min(t.x-1,...e.map((n=>n.x))));let s=0;for(let n=0;n<e.length;n++){const o=this.intersectSegmentSegment(e[n],e[(n+1)%e.length],t,i);if(o.includes(t))return!0;s+=+(o.status==="Intersection")}return s%2==1}static intersectLineLine(t,e,i,s){let n=!(arguments.length>4&&arguments[4]!==void 0)||arguments[4],o=!(arguments.length>5&&arguments[5]!==void 0)||arguments[5];const a=e.x-t.x,l=e.y-t.y,c=s.x-i.x,h=s.y-i.y,d=t.x-i.x,u=t.y-i.y,p=c*u-h*d,g=a*u-l*d,f=h*a-c*l;if(f!==0){const m=p/f,b=g/f;return(n||0<=m&&m<=1)&&(o||0<=b&&b<=1)?new lt("Intersection").append(new x(t.x+m*a,t.y+m*l)):new lt}if(p===0||g===0){const m=n||o||lt.isPointContained(t,i,s)||lt.isPointContained(e,i,s)||lt.isPointContained(i,t,e)||lt.isPointContained(s,t,e);return new lt(m?"Coincident":void 0)}return new lt("Parallel")}static intersectSegmentLine(t,e,i,s){return lt.intersectLineLine(t,e,i,s,!1,!0)}static intersectSegmentSegment(t,e,i,s){return lt.intersectLineLine(t,e,i,s,!1,!1)}static intersectLinePolygon(t,e,i){let s=!(arguments.length>3&&arguments[3]!==void 0)||arguments[3];const n=new lt,o=i.length;for(let a,l,c,h=0;h<o;h++){if(a=i[h],l=i[(h+1)%o],c=lt.intersectLineLine(t,e,a,l,s,!1),c.status==="Coincident")return c;n.append(...c.points)}return n.points.length>0&&(n.status="Intersection"),n}static intersectSegmentPolygon(t,e,i){return lt.intersectLinePolygon(t,e,i,!1)}static intersectPolygonPolygon(t,e){const i=new lt,s=t.length,n=[];for(let o=0;o<s;o++){const a=t[o],l=t[(o+1)%s],c=lt.intersectSegmentPolygon(a,l,e);c.status==="Coincident"?(n.push(c),i.append(a,l)):i.append(...c.points)}return n.length>0&&n.length===t.length?new lt("Coincident"):(i.points.length>0&&(i.status="Intersection"),i)}static intersectPolygonRectangle(t,e,i){const s=e.min(i),n=e.max(i),o=new x(n.x,s.y),a=new x(s.x,n.y);return lt.intersectPolygonPolygon(t,[s,o,n,a])}}class Pg extends fc{getX(){return this.getXY().x}setX(t){this.setXY(this.getXY().setX(t))}getY(){return this.getXY().y}setY(t){this.setXY(this.getXY().setY(t))}getRelativeX(){return this.left}setRelativeX(t){this.left=t}getRelativeY(){return this.top}setRelativeY(t){this.top=t}getXY(){const t=this.getRelativeXY();return this.group?Qt(t,this.group.calcTransformMatrix()):t}setXY(t,e,i){this.group&&(t=Qt(t,Ce(this.group.calcTransformMatrix()))),this.setRelativeXY(t,e,i)}getRelativeXY(){return new x(this.left,this.top)}setRelativeXY(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:this.originX,i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:this.originY;this.setPositionByOrigin(t,e,i)}isStrokeAccountedForInDimensions(){return!1}getCoords(){const{tl:t,tr:e,br:i,bl:s}=this.aCoords||(this.aCoords=this.calcACoords()),n=[t,e,i,s];if(this.group){const o=this.group.calcTransformMatrix();return n.map((a=>Qt(a,o)))}return n}intersectsWithRect(t,e){return lt.intersectPolygonRectangle(this.getCoords(),t,e).status==="Intersection"}intersectsWithObject(t){const e=lt.intersectPolygonPolygon(this.getCoords(),t.getCoords());return e.status==="Intersection"||e.status==="Coincident"||t.isContainedWithinObject(this)||this.isContainedWithinObject(t)}isContainedWithinObject(t){return this.getCoords().every((e=>t.containsPoint(e)))}isContainedWithinRect(t,e){const{left:i,top:s,width:n,height:o}=this.getBoundingRect();return i>=t.x&&i+n<=e.x&&s>=t.y&&s+o<=e.y}isOverlapping(t){return this.intersectsWithObject(t)||this.isContainedWithinObject(t)||t.isContainedWithinObject(this)}containsPoint(t){return lt.isPointInPolygon(t,this.getCoords())}isOnScreen(){if(!this.canvas)return!1;const{tl:t,br:e}=this.canvas.vptCoords;return!!this.getCoords().some((i=>i.x<=e.x&&i.x>=t.x&&i.y<=e.y&&i.y>=t.y))||!!this.intersectsWithRect(t,e)||this.containsPoint(t.midPointFrom(e))}isPartiallyOnScreen(){if(!this.canvas)return!1;const{tl:t,br:e}=this.canvas.vptCoords;return this.intersectsWithRect(t,e)?!0:this.getCoords().every((i=>(i.x>=e.x||i.x<=t.x)&&(i.y>=e.y||i.y<=t.y)))&&this.containsPoint(t.midPointFrom(e))}getBoundingRect(){return Ke(this.getCoords())}getScaledWidth(){return this._getTransformedDimensions().x}getScaledHeight(){return this._getTransformedDimensions().y}scale(t){this._set(oe,t),this._set(be,t),this.setCoords()}scaleToWidth(t){const e=this.getBoundingRect().width/this.getScaledWidth();return this.scale(t/this.width/e)}scaleToHeight(t){const e=this.getBoundingRect().height/this.getScaledHeight();return this.scale(t/this.height/e)}getCanvasRetinaScaling(){var t;return((t=this.canvas)===null||t===void 0?void 0:t.getRetinaScaling())||1}getTotalAngle(){return this.group?ei(vc(this.calcTransformMatrix())):this.angle}getViewportTransform(){var t;return((t=this.canvas)===null||t===void 0?void 0:t.viewportTransform)||qt.concat()}calcACoords(){const t=os({angle:this.angle}),{x:e,y:i}=this.getRelativeCenterPoint(),s=Zs(e,i),n=Rt(s,t),o=this._getTransformedDimensions(),a=o.x/2,l=o.y/2;return{tl:Qt({x:-a,y:-l},n),tr:Qt({x:a,y:-l},n),bl:Qt({x:-a,y:l},n),br:Qt({x:a,y:l},n)}}setCoords(){this.aCoords=this.calcACoords()}transformMatrixKey(){let t=arguments.length>0&&arguments[0]!==void 0&&arguments[0],e=[];return!t&&this.group&&(e=this.group.transformMatrixKey(t)),e.push(this.top,this.left,this.width,this.height,this.scaleX,this.scaleY,this.angle,this.strokeWidth,this.skewX,this.skewY,+this.flipX,+this.flipY,Tt(this.originX),Tt(this.originY)),e}calcTransformMatrix(){let t=arguments.length>0&&arguments[0]!==void 0&&arguments[0],e=this.calcOwnMatrix();if(t||!this.group)return e;const i=this.transformMatrixKey(t),s=this.matrixCache;return s&&s.key.every(((n,o)=>n===i[o]))?s.value:(this.group&&(e=Rt(this.group.calcTransformMatrix(!1),e)),this.matrixCache={key:i,value:e},e)}calcOwnMatrix(){const t=this.transformMatrixKey(!0),e=this.ownMatrixCache;if(e&&e.key===t)return e.value;const i=this.getRelativeCenterPoint(),s={angle:this.angle,translateX:i.x,translateY:i.y,scaleX:this.scaleX,scaleY:this.scaleY,skewX:this.skewX,skewY:this.skewY,flipX:this.flipX,flipY:this.flipY},n=Zp(s);return this.ownMatrixCache={key:t,value:n},n}_getNonTransformedDimensions(){return new x(this.width,this.height).scalarAdd(this.strokeWidth)}_calculateCurrentDimensions(t){return this._getTransformedDimensions(t).transform(this.getViewportTransform(),!0).scalarAdd(2*this.padding)}_getTransformedDimensions(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};const e=y({scaleX:this.scaleX,scaleY:this.scaleY,skewX:this.skewX,skewY:this.skewY,width:this.width,height:this.height,strokeWidth:this.strokeWidth},t),i=e.strokeWidth;let s=i,n=0;this.strokeUniform&&(s=0,n=i);const o=e.width+s,a=e.height+s;let l;return l=e.skewX===0&&e.skewY===0?new x(o*e.scaleX,a*e.scaleY):Ro(o,a,hn(e)),l.scalarAdd(n)}translateToGivenOrigin(t,e,i,s,n){let o=t.x,a=t.y;const l=Tt(s)-Tt(e),c=Tt(n)-Tt(i);if(l||c){const h=this._getTransformedDimensions();o+=l*h.x,a+=c*h.y}return new x(o,a)}translateToCenterPoint(t,e,i){if(e===V&&i===V)return t;const s=this.translateToGivenOrigin(t,e,i,V,V);return this.angle?s.rotate(xt(this.angle),t):s}translateToOriginPoint(t,e,i){const s=this.translateToGivenOrigin(t,V,V,e,i);return this.angle?s.rotate(xt(this.angle),t):s}getCenterPoint(){const t=this.getRelativeCenterPoint();return this.group?Qt(t,this.group.calcTransformMatrix()):t}getRelativeCenterPoint(){return this.translateToCenterPoint(new x(this.left,this.top),this.originX,this.originY)}getPointByOrigin(t,e){return this.translateToOriginPoint(this.getRelativeCenterPoint(),t,e)}setPositionByOrigin(t,e,i){const s=this.translateToCenterPoint(t,e,i),n=this.translateToOriginPoint(s,this.originX,this.originY);this.set({left:n.x,top:n.y})}_getLeftTopCoords(){return this.translateToOriginPoint(this.getRelativeCenterPoint(),Y,ie)}}const Ag=["type"],Dg=["extraParam"];let Ue=class Lr extends Pg{static getDefaults(){return Lr.ownDefaults}get type(){const t=this.constructor.type;return t==="FabricObject"?"object":t.toLowerCase()}set type(t){mi("warn","Setting type has no effect",t)}constructor(t){super(),v(this,"_cacheContext",null),Object.assign(this,Lr.ownDefaults),this.setOptions(t)}_createCacheCanvas(){this._cacheCanvas=ti(),this._cacheContext=this._cacheCanvas.getContext("2d"),this._updateCacheCanvas(),this.dirty=!0}_limitCacheSize(t){const e=t.width,i=t.height,s=W.maxCacheSideLimit,n=W.minCacheSideLimit;if(e<=s&&i<=s&&e*i<=W.perfLimitSizeTotal)return e<n&&(t.width=n),i<n&&(t.height=n),t;const o=e/i,[a,l]=Ds.limitDimsByArea(o),c=es(n,a,s),h=es(n,l,s);return e>c&&(t.zoomX/=e/c,t.width=c,t.capped=!0),i>h&&(t.zoomY/=i/h,t.height=h,t.capped=!0),t}_getCacheCanvasDimensions(){const t=this.getTotalObjectScaling(),e=this._getTransformedDimensions({skewX:0,skewY:0}),i=e.x*t.x/this.scaleX,s=e.y*t.y/this.scaleY;return{width:Math.ceil(i+2),height:Math.ceil(s+2),zoomX:t.x,zoomY:t.y,x:i,y:s}}_updateCacheCanvas(){const t=this._cacheCanvas,e=this._cacheContext,{width:i,height:s,zoomX:n,zoomY:o,x:a,y:l}=this._limitCacheSize(this._getCacheCanvasDimensions()),c=i!==t.width||s!==t.height,h=this.zoomX!==n||this.zoomY!==o;if(!t||!e)return!1;if(c||h){i!==t.width||s!==t.height?(t.width=i,t.height=s):(e.setTransform(1,0,0,1,0,0),e.clearRect(0,0,t.width,t.height));const d=a/2,u=l/2;return this.cacheTranslationX=Math.round(t.width/2-d)+d,this.cacheTranslationY=Math.round(t.height/2-u)+u,e.translate(this.cacheTranslationX,this.cacheTranslationY),e.scale(n,o),this.zoomX=n,this.zoomY=o,!0}return!1}setOptions(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};this._setOptions(t)}transform(t){const e=this.group&&!this.group._transformDone||this.group&&this.canvas&&t===this.canvas.contextTop,i=this.calcTransformMatrix(!e);t.transform(i[0],i[1],i[2],i[3],i[4],i[5])}getObjectScaling(){if(!this.group)return new x(Math.abs(this.scaleX),Math.abs(this.scaleY));const t=Vr(this.calcTransformMatrix());return new x(Math.abs(t.scaleX),Math.abs(t.scaleY))}getTotalObjectScaling(){const t=this.getObjectScaling();if(this.canvas){const e=this.canvas.getZoom(),i=this.getCanvasRetinaScaling();return t.scalarMultiply(e*i)}return t}getObjectOpacity(){let t=this.opacity;return this.group&&(t*=this.group.getObjectOpacity()),t}_constrainScale(t){return Math.abs(t)<this.minScaleLimit?t<0?-this.minScaleLimit:this.minScaleLimit:t===0?1e-4:t}_set(t,e){t!==oe&&t!==be||(e=this._constrainScale(e)),t===oe&&e<0?(this.flipX=!this.flipX,e*=-1):t==="scaleY"&&e<0?(this.flipY=!this.flipY,e*=-1):t!=="shadow"||!e||e instanceof qe||(e=new qe(e));const i=this[t]!==e;return this[t]=e,i&&this.constructor.cacheProperties.includes(t)&&(this.dirty=!0),this.parent&&(this.dirty||i&&this.constructor.stateProperties.includes(t))&&this.parent._set("dirty",!0),this}isNotVisible(){return this.opacity===0||!this.width&&!this.height&&this.strokeWidth===0||!this.visible}render(t){this.isNotVisible()||this.canvas&&this.canvas.skipOffscreen&&!this.group&&!this.isOnScreen()||(t.save(),this._setupCompositeOperation(t),this.drawSelectionBackground(t),this.transform(t),this._setOpacity(t),this._setShadow(t),this.shouldCache()?(this.renderCache(),this.drawCacheOnCanvas(t)):(this._removeCacheCanvas(),this.drawObject(t,!1,{}),this.dirty=!1),t.restore())}drawSelectionBackground(t){}renderCache(t){if(t=t||{},this._cacheCanvas&&this._cacheContext||this._createCacheCanvas(),this.isCacheDirty()&&this._cacheContext){const{zoomX:e,zoomY:i,cacheTranslationX:s,cacheTranslationY:n}=this,{width:o,height:a}=this._cacheCanvas;this.drawObject(this._cacheContext,t.forClipping,{zoomX:e,zoomY:i,cacheTranslationX:s,cacheTranslationY:n,width:o,height:a,parentClipPaths:[]}),this.dirty=!1}}_removeCacheCanvas(){this._cacheCanvas=void 0,this._cacheContext=null}hasStroke(){return this.stroke&&this.stroke!=="transparent"&&this.strokeWidth!==0}hasFill(){return this.fill&&this.fill!=="transparent"}needsItsOwnCache(){return!!(this.paintFirst===re&&this.hasFill()&&this.hasStroke()&&this.shadow)||!!this.clipPath}shouldCache(){return this.ownCaching=this.objectCaching&&(!this.parent||!this.parent.isOnACache())||this.needsItsOwnCache(),this.ownCaching}willDrawShadow(){return!!this.shadow&&(this.shadow.offsetX!==0||this.shadow.offsetY!==0)}drawClipPathOnCache(t,e,i){t.save(),e.inverted?t.globalCompositeOperation="destination-out":t.globalCompositeOperation="destination-in",t.setTransform(1,0,0,1,0,0),t.drawImage(i,0,0),t.restore()}drawObject(t,e,i){const s=this.fill,n=this.stroke;e?(this.fill="black",this.stroke="",this._setClippingProperties(t)):this._renderBackground(t),this._render(t),this._drawClipPath(t,this.clipPath,i),this.fill=s,this.stroke=n}createClipPathLayer(t,e){const i=ve(e),s=i.getContext("2d");if(s.translate(e.cacheTranslationX,e.cacheTranslationY),s.scale(e.zoomX,e.zoomY),t._cacheCanvas=i,e.parentClipPaths.forEach((n=>{n.transform(s)})),e.parentClipPaths.push(t),t.absolutePositioned){const n=Ce(this.calcTransformMatrix());s.transform(n[0],n[1],n[2],n[3],n[4],n[5])}return t.transform(s),t.drawObject(s,!0,e),i}_drawClipPath(t,e,i){if(!e)return;e._transformDone=!0;const s=this.createClipPathLayer(e,i);this.drawClipPathOnCache(t,e,s)}drawCacheOnCanvas(t){t.scale(1/this.zoomX,1/this.zoomY),t.drawImage(this._cacheCanvas,-this.cacheTranslationX,-this.cacheTranslationY)}isCacheDirty(){let t=arguments.length>0&&arguments[0]!==void 0&&arguments[0];if(this.isNotVisible())return!1;const e=this._cacheCanvas,i=this._cacheContext;return!(!e||!i||t||!this._updateCacheCanvas())||!!(this.dirty||this.clipPath&&this.clipPath.absolutePositioned)&&(e&&i&&!t&&(i.save(),i.setTransform(1,0,0,1,0,0),i.clearRect(0,0,e.width,e.height),i.restore()),!0)}_renderBackground(t){if(!this.backgroundColor)return;const e=this._getNonTransformedDimensions();t.fillStyle=this.backgroundColor,t.fillRect(-e.x/2,-e.y/2,e.x,e.y),this._removeShadow(t)}_setOpacity(t){this.group&&!this.group._transformDone?t.globalAlpha=this.getObjectOpacity():t.globalAlpha*=this.opacity}_setStrokeStyles(t,e){const i=e.stroke;i&&(t.lineWidth=e.strokeWidth,t.lineCap=e.strokeLineCap,t.lineDashOffset=e.strokeDashOffset,t.lineJoin=e.strokeLineJoin,t.miterLimit=e.strokeMiterLimit,ge(i)?i.gradientUnits==="percentage"||i.gradientTransform||i.patternTransform?this._applyPatternForTransformedGradient(t,i):(t.strokeStyle=i.toLive(t),this._applyPatternGradientTransform(t,i)):t.strokeStyle=e.stroke)}_setFillStyles(t,e){let{fill:i}=e;i&&(ge(i)?(t.fillStyle=i.toLive(t),this._applyPatternGradientTransform(t,i)):t.fillStyle=i)}_setClippingProperties(t){t.globalAlpha=1,t.strokeStyle="transparent",t.fillStyle="#000000"}_setLineDash(t,e){e&&e.length!==0&&t.setLineDash(e)}_setShadow(t){if(!this.shadow)return;const e=this.shadow,i=this.canvas,s=this.getCanvasRetinaScaling(),[n,,,o]=(i==null?void 0:i.viewportTransform)||qt,a=n*s,l=o*s,c=e.nonScaling?new x(1,1):this.getObjectScaling();t.shadowColor=e.color,t.shadowBlur=e.blur*W.browserShadowBlurConstant*(a+l)*(c.x+c.y)/4,t.shadowOffsetX=e.offsetX*a*c.x,t.shadowOffsetY=e.offsetY*l*c.y}_removeShadow(t){this.shadow&&(t.shadowColor="",t.shadowBlur=t.shadowOffsetX=t.shadowOffsetY=0)}_applyPatternGradientTransform(t,e){if(!ge(e))return{offsetX:0,offsetY:0};const i=e.gradientTransform||e.patternTransform,s=-this.width/2+e.offsetX||0,n=-this.height/2+e.offsetY||0;return e.gradientUnits==="percentage"?t.transform(this.width,0,0,this.height,s,n):t.transform(1,0,0,1,s,n),i&&t.transform(i[0],i[1],i[2],i[3],i[4],i[5]),{offsetX:s,offsetY:n}}_renderPaintInOrder(t){this.paintFirst===re?(this._renderStroke(t),this._renderFill(t)):(this._renderFill(t),this._renderStroke(t))}_render(t){}_renderFill(t){this.fill&&(t.save(),this._setFillStyles(t,this),this.fillRule==="evenodd"?t.fill("evenodd"):t.fill(),t.restore())}_renderStroke(t){if(this.stroke&&this.strokeWidth!==0){if(this.shadow&&!this.shadow.affectStroke&&this._removeShadow(t),t.save(),this.strokeUniform){const e=this.getObjectScaling();t.scale(1/e.x,1/e.y)}this._setLineDash(t,this.strokeDashArray),this._setStrokeStyles(t,this),t.stroke(),t.restore()}}_applyPatternForTransformedGradient(t,e){var i;const s=this._limitCacheSize(this._getCacheCanvasDimensions()),n=this.getCanvasRetinaScaling(),o=s.x/this.scaleX/n,a=s.y/this.scaleY/n,l=ve({width:Math.ceil(o),height:Math.ceil(a)}),c=l.getContext("2d");c&&(c.beginPath(),c.moveTo(0,0),c.lineTo(o,0),c.lineTo(o,a),c.lineTo(0,a),c.closePath(),c.translate(o/2,a/2),c.scale(s.zoomX/this.scaleX/n,s.zoomY/this.scaleY/n),this._applyPatternGradientTransform(c,e),c.fillStyle=e.toLive(t),c.fill(),t.translate(-this.width/2-this.strokeWidth/2,-this.height/2-this.strokeWidth/2),t.scale(n*this.scaleX/s.zoomX,n*this.scaleY/s.zoomY),t.strokeStyle=(i=c.createPattern(l,"no-repeat"))!==null&&i!==void 0?i:"")}_findCenterFromElement(){return new x(this.left+this.width/2,this.top+this.height/2)}clone(t){const e=this.toObject(t);return this.constructor.fromObject(e)}cloneAsImage(t){const e=this.toCanvasElement(t);return new(A.getClass("image"))(e)}toCanvasElement(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};const e=Ec(this),i=this.group,s=this.shadow,n=Math.abs,o=t.enableRetinaScaling?hc():1,a=(t.multiplier||1)*o,l=t.canvasProvider||(_=>new Js(_,{enableRetinaScaling:!1,renderOnAddRemove:!1,skipOffscreen:!1}));delete this.group,t.withoutTransform&&rg(this),t.withoutShadow&&(this.shadow=null),t.viewportTransform&&og(this,this.getViewportTransform()),this.setCoords();const c=ti(),h=this.getBoundingRect(),d=this.shadow,u=new x;if(d){const _=d.blur,w=d.nonScaling?new x(1,1):this.getObjectScaling();u.x=2*Math.round(n(d.offsetX)+_)*n(w.x),u.y=2*Math.round(n(d.offsetY)+_)*n(w.y)}const p=h.width+u.x,g=h.height+u.y;c.width=Math.ceil(p),c.height=Math.ceil(g);const f=l(c);t.format==="jpeg"&&(f.backgroundColor="#fff"),this.setPositionByOrigin(new x(f.width/2,f.height/2),V,V);const m=this.canvas;f._objects=[this],this.set("canvas",f),this.setCoords();const b=f.toCanvasElement(a||1,t);return this.set("canvas",m),this.shadow=s,i&&(this.group=i),this.set(e),this.setCoords(),f._objects=[],f.destroy(),b}toDataURL(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};return mc(this.toCanvasElement(t),t.format||"png",t.quality||1)}toBlob(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};return bc(this.toCanvasElement(t),t.format||"png",t.quality||1)}isType(){for(var t=arguments.length,e=new Array(t),i=0;i<t;i++)e[i]=arguments[i];return e.includes(this.constructor.type)||e.includes(this.type)}complexity(){return 1}toJSON(){return this.toObject()}rotate(t){const{centeredRotation:e,originX:i,originY:s}=this;if(e){const{x:n,y:o}=this.getRelativeCenterPoint();this.originX=V,this.originY=V,this.left=n,this.top=o}if(this.set("angle",t),e){const{x:n,y:o}=this.translateToOriginPoint(this.getRelativeCenterPoint(),i,s);this.left=n,this.top=o,this.originX=i,this.originY=s}}setOnGroup(){}_setupCompositeOperation(t){this.globalCompositeOperation&&(t.globalCompositeOperation=this.globalCompositeOperation)}dispose(){Hr.cancelByTarget(this),this.off(),this._set("canvas",void 0),this._cacheCanvas&&Re().dispose(this._cacheCanvas),this._cacheCanvas=void 0,this._cacheContext=null}animate(t,e){return Object.entries(t).reduce(((i,s)=>{let[n,o]=s;return i[n]=this._animate(n,o,e),i}),{})}_animate(t,e){let i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};const s=t.split("."),n=this.constructor.colorProperties.includes(s[s.length-1]),{abort:o,startValue:a,onChange:l,onComplete:c}=i,h=y(y({},i),{},{target:this,startValue:a??s.reduce(((d,u)=>d[u]),this),endValue:e,abort:o==null?void 0:o.bind(this),onChange:(d,u,p)=>{s.reduce(((g,f,m)=>(m===s.length-1&&(g[f]=d),g[f])),this),l&&l(d,u,p)},onComplete:(d,u,p)=>{this.setCoords(),c&&c(d,u,p)}});return n?kg(h):Bc(h)}isDescendantOf(t){const{parent:e,group:i}=this;return e===t||i===t||!!e&&e.isDescendantOf(t)||!!i&&i!==e&&i.isDescendantOf(t)}getAncestors(){const t=[];let e=this;do e=e.parent,e&&t.push(e);while(e);return t}findCommonAncestors(t){if(this===t)return{fork:[],otherFork:[],common:[this,...this.getAncestors()]};const e=this.getAncestors(),i=t.getAncestors();if(e.length===0&&i.length>0&&this===i[i.length-1])return{fork:[],otherFork:[t,...i.slice(0,i.length-1)],common:[this]};for(let s,n=0;n<e.length;n++){if(s=e[n],s===t)return{fork:[this,...e.slice(0,n)],otherFork:[],common:e.slice(n)};for(let o=0;o<i.length;o++){if(this===i[o])return{fork:[],otherFork:[t,...i.slice(0,o)],common:[this,...e]};if(s===i[o])return{fork:[this,...e.slice(0,n)],otherFork:[t,...i.slice(0,o)],common:e.slice(n)}}}return{fork:[this,...e],otherFork:[t,...i],common:[]}}hasCommonAncestors(t){const e=this.findCommonAncestors(t);return e&&!!e.common.length}isInFrontOf(t){if(this===t)return;const e=this.findCommonAncestors(t);if(e.fork.includes(t))return!0;if(e.otherFork.includes(this))return!1;const i=e.common[0]||this.canvas;if(!i)return;const s=e.fork.pop(),n=e.otherFork.pop(),o=i._objects.indexOf(s),a=i._objects.indexOf(n);return o>-1&&o>a}toObject(){const t=(arguments.length>0&&arguments[0]!==void 0?arguments[0]:[]).concat(Lr.customProperties,this.constructor.customProperties||[]);let e;const i=W.NUM_FRACTION_DIGITS,{clipPath:s,fill:n,stroke:o,shadow:a,strokeDashArray:l,left:c,top:h,originX:d,originY:u,width:p,height:g,strokeWidth:f,strokeLineCap:m,strokeDashOffset:b,strokeLineJoin:_,strokeUniform:w,strokeMiterLimit:S,scaleX:T,scaleY:k,angle:O,flipX:E,flipY:P,opacity:R,visible:L,backgroundColor:F,fillRule:H,paintFirst:M,globalCompositeOperation:U,skewX:X,skewY:Q}=this;s&&!s.excludeFromExport&&(e=s.toObject(t.concat("inverted","absolutePositioned")));const N=Ut=>et(Ut,i),Ct=y(y({},as(this,t)),{},{type:this.constructor.type,version:so,originX:d,originY:u,left:N(c),top:N(h),width:N(p),height:N(g),fill:Ya(n)?n.toObject():n,stroke:Ya(o)?o.toObject():o,strokeWidth:N(f),strokeDashArray:l&&l.concat(),strokeLineCap:m,strokeDashOffset:b,strokeLineJoin:_,strokeUniform:w,strokeMiterLimit:N(S),scaleX:N(T),scaleY:N(k),angle:N(O),flipX:E,flipY:P,opacity:N(R),shadow:a&&a.toObject(),visible:L,backgroundColor:F,fillRule:H,paintFirst:M,globalCompositeOperation:U,skewX:N(X),skewY:N(Q)},e?{clipPath:e}:null);return this.includeDefaultValues?Ct:this._removeDefaultValues(Ct)}toDatalessObject(t){return this.toObject(t)}_removeDefaultValues(t){const e=this.constructor.getDefaults(),i=Object.keys(e).length>0?e:Object.getPrototypeOf(this);return $o(t,((s,n)=>{if(n===Y||n===ie||n==="type")return!0;const o=i[n];return s!==o&&!(Array.isArray(s)&&Array.isArray(o)&&s.length===0&&o.length===0)}))}toString(){return"#<".concat(this.constructor.type,">")}static _fromObject(t){let e=rt(t,Ag),i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},{extraParam:s}=i,n=rt(i,Dg);return dn(e,n).then((o=>s?(delete o[s],new this(e[s],o)):new this(o)))}static fromObject(t,e){return this._fromObject(t,e)}};v(Ue,"stateProperties",bg),v(Ue,"cacheProperties",ri),v(Ue,"ownDefaults",vg),v(Ue,"type","FabricObject"),v(Ue,"colorProperties",[Dt,re,"backgroundColor"]),v(Ue,"customProperties",[]),A.setClass(Ue),A.setClass(Ue,"object");const ls=(r,t,e)=>(i,s,n,o)=>{const a=t(i,s,n,o);return a&&Oc(r,y(y({},Pc(i,s,n,o)),e)),a};function cs(r){return(t,e,i,s)=>{const{target:n,originX:o,originY:a}=e,l=n.getRelativeCenterPoint(),c=n.translateToOriginPoint(l,o,a),h=r(t,e,i,s);return n.setPositionByOrigin(c,e.originX,e.originY),h}}const ll=ls(Hs,cs(((r,t,e,i)=>{const s=Bo(t,t.originX,t.originY,e,i);if(Tt(t.originX)===Tt(V)||Tt(t.originX)===Tt(_t)&&s.x<0||Tt(t.originX)===Tt(Y)&&s.x>0){const{target:n}=t,o=n.strokeWidth/(n.strokeUniform?n.scaleX:1),a=kc(t)?2:1,l=n.width,c=Math.abs(s.x*a/n.scaleX)-o;return n.set("width",Math.max(c,1)),l!==n.width}return!1})));function Mg(r,t,e,i,s){i=i||{};const n=this.sizeX||i.cornerSize||s.cornerSize,o=this.sizeY||i.cornerSize||s.cornerSize,a=i.transparentCorners!==void 0?i.transparentCorners:s.transparentCorners,l=a?re:Dt,c=!a&&(i.cornerStrokeColor||s.cornerStrokeColor);let h,d=t,u=e;r.save(),r.fillStyle=i.cornerColor||s.cornerColor||"",r.strokeStyle=i.cornerStrokeColor||s.cornerStrokeColor||"",n>o?(h=n,r.scale(1,o/n),u=e*n/o):o>n?(h=o,r.scale(n/o,1),d=t*o/n):h=n,r.beginPath(),r.arc(d,u,h/2,0,Rr,!1),r[l](),c&&r.stroke(),r.restore()}function Ig(r,t,e,i,s){i=i||{};const n=this.sizeX||i.cornerSize||s.cornerSize,o=this.sizeY||i.cornerSize||s.cornerSize,a=i.transparentCorners!==void 0?i.transparentCorners:s.transparentCorners,l=a?re:Dt,c=!a&&(i.cornerStrokeColor||s.cornerStrokeColor),h=n/2,d=o/2;r.save(),r.fillStyle=i.cornerColor||s.cornerColor||"",r.strokeStyle=i.cornerStrokeColor||s.cornerStrokeColor||"",r.translate(t,e);const u=s.getTotalAngle();r.rotate(xt(u)),r["".concat(l,"Rect")](-h,-d,n,o),c&&r.strokeRect(-h,-d,n,o),r.restore()}class _e{constructor(t){v(this,"visible",!0),v(this,"actionName",cn),v(this,"angle",0),v(this,"x",0),v(this,"y",0),v(this,"offsetX",0),v(this,"offsetY",0),v(this,"sizeX",0),v(this,"sizeY",0),v(this,"touchSizeX",0),v(this,"touchSizeY",0),v(this,"cursorStyle","crosshair"),v(this,"withConnection",!1),Object.assign(this,t)}shouldActivate(t,e,i,s){var n;let{tl:o,tr:a,br:l,bl:c}=s;return((n=e.canvas)===null||n===void 0?void 0:n.getActiveObject())===e&&e.isControlVisible(t)&<.isPointInPolygon(i,[o,a,l,c])}getActionHandler(t,e,i){return this.actionHandler}getMouseDownHandler(t,e,i){return this.mouseDownHandler}getMouseUpHandler(t,e,i){return this.mouseUpHandler}cursorStyleHandler(t,e,i){return e.cursorStyle}getActionName(t,e,i){return e.actionName}getVisibility(t,e){var i,s;return(i=(s=t._controlsVisibility)===null||s===void 0?void 0:s[e])!==null&&i!==void 0?i:this.visible}setVisibility(t,e,i){this.visible=t}positionHandler(t,e,i,s){return new x(this.x*t.x+this.offsetX,this.y*t.y+this.offsetY).transform(e)}calcCornerCoords(t,e,i,s,n,o){const a=Fo([Zs(i,s),os({angle:t}),jo((n?this.touchSizeX:this.sizeX)||e,(n?this.touchSizeY:this.sizeY)||e)]);return{tl:new x(-.5,-.5).transform(a),tr:new x(.5,-.5).transform(a),br:new x(.5,.5).transform(a),bl:new x(-.5,.5).transform(a)}}render(t,e,i,s,n){((s=s||{}).cornerStyle||n.cornerStyle)==="circle"?Mg.call(this,t,e,i,s,n):Ig.call(this,t,e,i,s,n)}}const Lg=(r,t,e)=>e.lockRotation?Ur:t.cursorStyle,Fg=ls(uc,cs(((r,t,e,i)=>{let{target:s,ex:n,ey:o,theta:a,originX:l,originY:c}=t;const h=s.translateToOriginPoint(s.getRelativeCenterPoint(),l,c);if(Ee(s,"lockRotation"))return!1;const d=Math.atan2(o-h.y,n-h.x),u=Math.atan2(i-h.y,e-h.x);let p=ei(u-d+a);if(s.snapAngle&&s.snapAngle>0){const f=s.snapAngle,m=s.snapThreshold||f,b=Math.ceil(p/f)*f,_=Math.floor(p/f)*f;Math.abs(p-_)<m?p=_:Math.abs(p-b)<m&&(p=b)}p<0&&(p=360+p),p%=360;const g=s.angle!==p;return s.angle=p,g})));function zc(r,t){const e=t.canvas,i=r[e.uniScaleKey];return e.uniformScaling&&!i||!e.uniformScaling&&i}function Hc(r,t,e){const i=Ee(r,"lockScalingX"),s=Ee(r,"lockScalingY");if(i&&s||!t&&(i||s)&&e||i&&t==="x"||s&&t==="y")return!0;const{width:n,height:o,strokeWidth:a}=r;return n===0&&a===0&&t!=="y"||o===0&&a===0&&t!=="x"}const jg=["e","se","s","sw","w","nw","n","ne","e"],Ts=(r,t,e)=>{const i=zc(r,e);if(Hc(e,t.x!==0&&t.y===0?"x":t.x===0&&t.y!==0?"y":"",i))return Ur;const s=Ac(e,t);return"".concat(jg[s],"-resize")};function Vo(r,t,e,i){let s=arguments.length>4&&arguments[4]!==void 0?arguments[4]:{};const n=t.target,o=s.by,a=zc(r,n);let l,c,h,d,u,p;if(Hc(n,o,a))return!1;if(t.gestureScale)c=t.scaleX*t.gestureScale,h=t.scaleY*t.gestureScale;else{if(l=Bo(t,t.originX,t.originY,e,i),u=o!=="y"?Math.sign(l.x||t.signX||1):1,p=o!=="x"?Math.sign(l.y||t.signY||1):1,t.signX||(t.signX=u),t.signY||(t.signY=p),Ee(n,"lockScalingFlip")&&(t.signX!==u||t.signY!==p))return!1;if(d=n._getTransformedDimensions(),a&&!o){const m=Math.abs(l.x)+Math.abs(l.y),{original:b}=t,_=m/(Math.abs(d.x*b.scaleX/n.scaleX)+Math.abs(d.y*b.scaleY/n.scaleY));c=b.scaleX*_,h=b.scaleY*_}else c=Math.abs(l.x*n.scaleX/d.x),h=Math.abs(l.y*n.scaleY/d.y);kc(t)&&(c*=2,h*=2),t.signX!==u&&o!=="y"&&(t.originX=qa(t.originX),c*=-1,t.signX=u),t.signY!==p&&o!=="x"&&(t.originY=qa(t.originY),h*=-1,t.signY=p)}const g=n.scaleX,f=n.scaleY;return o?(o==="x"&&n.set(oe,c),o==="y"&&n.set(be,h)):(!Ee(n,"lockScalingX")&&n.set(oe,c),!Ee(n,"lockScalingY")&&n.set(be,h)),g!==n.scaleX||f!==n.scaleY}const nr=ls(ln,cs(((r,t,e,i)=>Vo(r,t,e,i)))),$g=ls(ln,cs(((r,t,e,i)=>Vo(r,t,e,i,{by:"x"})))),Rg=ls(ln,cs(((r,t,e,i)=>Vo(r,t,e,i,{by:"y"})))),Bg=["target","ex","ey","skewingSide"],Rn={x:{counterAxis:"y",scale:oe,skew:rs,lockSkewing:"lockSkewingX",origin:"originX",flip:"flipX"},y:{counterAxis:"x",scale:be,skew:ns,lockSkewing:"lockSkewingY",origin:"originY",flip:"flipY"}},zg=["ns","nesw","ew","nwse"],Hg=(r,t,e)=>{if(t.x!==0&&Ee(e,"lockSkewingY")||t.y!==0&&Ee(e,"lockSkewingX"))return Ur;const i=Ac(e,t)%4;return"".concat(zg[i],"-resize")};function Vc(r,t,e,i,s){const{target:n}=e,{counterAxis:o,origin:a,lockSkewing:l,skew:c,flip:h}=Rn[r];if(Ee(n,l))return!1;const{origin:d,flip:u}=Rn[o],p=Tt(e[d])*(n[u]?-1:1),g=-Math.sign(p)*(n[h]?-1:1),f=.5*-((n[c]===0&&Bo(e,V,V,i,s)[r]>0||n[c]>0?1:-1)*g)+.5;return ls(pc,cs(((b,_,w,S)=>(function(T,k,O){let{target:E,ex:P,ey:R,skewingSide:L}=k,F=rt(k,Bg);const{skew:H}=Rn[T],M=O.subtract(new x(P,R)).divide(new x(E.scaleX,E.scaleY))[T],U=E[H],X=F[H],Q=Math.tan(xt(X)),N=T==="y"?E._getTransformedDimensions({scaleX:1,scaleY:1,skewX:0}).x:E._getTransformedDimensions({scaleX:1,scaleY:1}).y,Ct=2*M*L/Math.max(N,1)+Q,Ut=ei(Math.atan(Ct));E.set(H,Ut);const Wt=U!==E[H];if(Wt&&T==="y"){const{skewX:Pe,scaleX:de}=E,Ft=E._getTransformedDimensions({skewY:U}),Ae=E._getTransformedDimensions(),ae=Pe!==0?Ft.x/Ae.x:1;ae!==1&&E.set(oe,ae*de)}return Wt})(r,_,new x(w,S)))))(t,y(y({},e),{},{[a]:f,skewingSide:g}),i,s)}const Vg=(r,t,e,i)=>Vc("x",r,t,e,i),Ng=(r,t,e,i)=>Vc("y",r,t,e,i);function gn(r,t){return r[t.canvas.altActionKey]}const or=(r,t,e)=>{const i=gn(r,e);return t.x===0?i?rs:be:t.y===0?i?ns:oe:""},Xi=(r,t,e)=>gn(r,e)?Hg(0,t,e):Ts(r,t,e),cl=(r,t,e,i)=>gn(r,t.target)?Ng(r,t,e,i):$g(r,t,e,i),hl=(r,t,e,i)=>gn(r,t.target)?Vg(r,t,e,i):Rg(r,t,e,i),Nc=()=>({ml:new _e({x:-.5,y:0,cursorStyleHandler:Xi,actionHandler:cl,getActionName:or}),mr:new _e({x:.5,y:0,cursorStyleHandler:Xi,actionHandler:cl,getActionName:or}),mb:new _e({x:0,y:.5,cursorStyleHandler:Xi,actionHandler:hl,getActionName:or}),mt:new _e({x:0,y:-.5,cursorStyleHandler:Xi,actionHandler:hl,getActionName:or}),tl:new _e({x:-.5,y:-.5,cursorStyleHandler:Ts,actionHandler:nr}),tr:new _e({x:.5,y:-.5,cursorStyleHandler:Ts,actionHandler:nr}),bl:new _e({x:-.5,y:.5,cursorStyleHandler:Ts,actionHandler:nr}),br:new _e({x:.5,y:.5,cursorStyleHandler:Ts,actionHandler:nr}),mtr:new _e({x:0,y:-.5,actionHandler:Fg,cursorStyleHandler:Lg,offsetY:-40,withConnection:!0,actionName:Io})}),Ug=()=>({mr:new _e({x:.5,y:0,actionHandler:ll,cursorStyleHandler:Xi,actionName:Hs}),ml:new _e({x:-.5,y:0,actionHandler:ll,cursorStyleHandler:Xi,actionName:Hs})}),Wg=()=>y(y({},Nc()),Ug());class Ws extends Ue{static getDefaults(){return y(y({},super.getDefaults()),Ws.ownDefaults)}constructor(t){super(),Object.assign(this,this.constructor.createControls(),Ws.ownDefaults),this.setOptions(t)}static createControls(){return{controls:Nc()}}_updateCacheCanvas(){const t=this.canvas;if(this.noScaleCache&&t&&t._currentTransform){const e=t._currentTransform,i=e.target,s=e.action;if(this===i&&s&&s.startsWith(cn))return!1}return super._updateCacheCanvas()}getActiveControl(){const t=this.__corner;return t?{key:t,control:this.controls[t],coord:this.oCoords[t]}:void 0}findControl(t){let e=arguments.length>1&&arguments[1]!==void 0&&arguments[1];if(!this.hasControls||!this.canvas)return;this.__corner=void 0;const i=Object.entries(this.oCoords);for(let s=i.length-1;s>=0;s--){const[n,o]=i[s],a=this.controls[n];if(a.shouldActivate(n,this,t,e?o.touchCorner:o.corner))return this.__corner=n,{key:n,control:a,coord:this.oCoords[n]}}}calcOCoords(){const t=this.getViewportTransform(),e=this.getCenterPoint(),i=Zs(e.x,e.y),s=os({angle:this.getTotalAngle()-(this.group&&this.flipX?180:0)}),n=Rt(i,s),o=Rt(t,n),a=Rt(o,[1/t[0],0,0,1/t[3],0,0]),l=this.group?Vr(this.calcTransformMatrix()):void 0;l&&(l.scaleX=Math.abs(l.scaleX),l.scaleY=Math.abs(l.scaleY));const c=this._calculateCurrentDimensions(l),h={};return this.forEachControl(((d,u)=>{const p=d.positionHandler(c,a,this,d);h[u]=Object.assign(p,this._calcCornerCoords(d,p))})),h}_calcCornerCoords(t,e){const i=this.getTotalAngle();return{corner:t.calcCornerCoords(i,this.cornerSize,e.x,e.y,!1,this),touchCorner:t.calcCornerCoords(i,this.touchCornerSize,e.x,e.y,!0,this)}}setCoords(){super.setCoords(),this.canvas&&(this.oCoords=this.calcOCoords())}forEachControl(t){for(const e in this.controls)t(this.controls[e],e,this)}drawSelectionBackground(t){if(!this.selectionBackgroundColor||this.canvas&&this.canvas._activeObject!==this)return;t.save();const e=this.getRelativeCenterPoint(),i=this._calculateCurrentDimensions(),s=this.getViewportTransform();t.translate(e.x,e.y),t.scale(1/s[0],1/s[3]),t.rotate(xt(this.angle)),t.fillStyle=this.selectionBackgroundColor,t.fillRect(-i.x/2,-i.y/2,i.x,i.y),t.restore()}strokeBorders(t,e){t.strokeRect(-e.x/2,-e.y/2,e.x,e.y)}_drawBorders(t,e){let i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};const s=y({hasControls:this.hasControls,borderColor:this.borderColor,borderDashArray:this.borderDashArray},i);t.save(),t.strokeStyle=s.borderColor,this._setLineDash(t,s.borderDashArray),this.strokeBorders(t,e),s.hasControls&&this.drawControlsConnectingLines(t,e),t.restore()}_renderControls(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};const{hasBorders:i,hasControls:s}=this,n=y({hasBorders:i,hasControls:s},e),o=this.getViewportTransform(),a=n.hasBorders,l=n.hasControls,c=Rt(o,this.calcTransformMatrix()),h=Vr(c);t.save(),t.translate(h.translateX,h.translateY),t.lineWidth=this.borderScaleFactor,this.group===this.parent&&(t.globalAlpha=this.isMoving?this.borderOpacityWhenMoving:1),this.flipX&&(h.angle-=180),t.rotate(xt(this.group?h.angle:this.angle)),a&&this.drawBorders(t,h,e),l&&this.drawControls(t,e),t.restore()}drawBorders(t,e,i){let s;if(i&&i.forActiveSelection||this.group){const n=Ro(this.width,this.height,hn(e)),o=this.isStrokeAccountedForInDimensions()?Lo:(this.strokeUniform?new x().scalarAdd(this.canvas?this.canvas.getZoom():1):new x(e.scaleX,e.scaleY)).scalarMultiply(this.strokeWidth);s=n.add(o).scalarAdd(this.borderScaleFactor).scalarAdd(2*this.padding)}else s=this._calculateCurrentDimensions().scalarAdd(this.borderScaleFactor);this._drawBorders(t,s,i)}drawControlsConnectingLines(t,e){let i=!1;t.beginPath(),this.forEachControl(((s,n)=>{s.withConnection&&s.getVisibility(this,n)&&(i=!0,t.moveTo(s.x*e.x,s.y*e.y),t.lineTo(s.x*e.x+s.offsetX,s.y*e.y+s.offsetY))})),i&&t.stroke()}drawControls(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};t.save();const i=this.getCanvasRetinaScaling(),{cornerStrokeColor:s,cornerDashArray:n,cornerColor:o}=this,a=y({cornerStrokeColor:s,cornerDashArray:n,cornerColor:o},e);t.setTransform(i,0,0,i,0,0),t.strokeStyle=t.fillStyle=a.cornerColor,this.transparentCorners||(t.strokeStyle=a.cornerStrokeColor),this._setLineDash(t,a.cornerDashArray),this.forEachControl(((l,c)=>{if(l.getVisibility(this,c)){const h=this.oCoords[c];l.render(t,h.x,h.y,a,this)}})),t.restore()}isControlVisible(t){return this.controls[t]&&this.controls[t].getVisibility(this,t)}setControlVisible(t,e){this._controlsVisibility||(this._controlsVisibility={}),this._controlsVisibility[t]=e}setControlsVisibility(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};Object.entries(t).forEach((e=>{let[i,s]=e;return this.setControlVisible(i,s)}))}clearContextTop(t){if(!this.canvas)return;const e=this.canvas.contextTop;if(!e)return;const i=this.canvas.viewportTransform;e.save(),e.transform(i[0],i[1],i[2],i[3],i[4],i[5]),this.transform(e);const s=this.width+4,n=this.height+4;return e.clearRect(-s/2,-n/2,s,n),t||e.restore(),e}onDeselect(t){return!1}onSelect(t){return!1}shouldStartDragging(t){return!1}onDragStart(t){return!1}canDrop(t){return!1}renderDragSourceEffect(t){}renderDropTargetEffect(t){}}function Uc(r,t){return t.forEach((e=>{Object.getOwnPropertyNames(e.prototype).forEach((i=>{i!=="constructor"&&Object.defineProperty(r.prototype,i,Object.getOwnPropertyDescriptor(e.prototype,i)||Object.create(null))}))})),r}v(Ws,"ownDefaults",{noScaleCache:!0,lockMovementX:!1,lockMovementY:!1,lockRotation:!1,lockScalingX:!1,lockScalingY:!1,lockSkewingX:!1,lockSkewingY:!1,lockScalingFlip:!1,cornerSize:13,touchCornerSize:24,transparentCorners:!0,cornerColor:"rgb(178,204,255)",cornerStrokeColor:"",cornerStyle:"rect",cornerDashArray:null,hasControls:!0,borderColor:"rgb(178,204,255)",borderDashArray:null,borderOpacityWhenMoving:.4,borderScaleFactor:1,hasBorders:!0,selectionBackgroundColor:"",selectable:!0,evented:!0,perPixelTargetFind:!1,activeOn:"down",hoverCursor:null,moveCursor:null});class Vt extends Ws{}Uc(Vt,[Dc]),A.setClass(Vt),A.setClass(Vt,"object");const Yg=(r,t,e,i)=>{const s=2*(i=Math.round(i))+1,{data:n}=r.getImageData(t-i,e-i,s,s);for(let o=3;o<n.length;o+=4)if(n[o]>0)return!1;return!0};class Wc{constructor(t){this.options=t,this.strokeProjectionMagnitude=this.options.strokeWidth/2,this.scale=new x(this.options.scaleX,this.options.scaleY),this.strokeUniformScalar=this.options.strokeUniform?new x(1/this.options.scaleX,1/this.options.scaleY):new x(1,1)}createSideVector(t,e){const i=ao(t,e);return this.options.strokeUniform?i.multiply(this.scale):i}projectOrthogonally(t,e,i){return this.applySkew(t.add(this.calcOrthogonalProjection(t,e,i)))}isSkewed(){return this.options.skewX!==0||this.options.skewY!==0}applySkew(t){const e=new x(t);return e.y+=e.x*Math.tan(xt(this.options.skewY)),e.x+=e.y*Math.tan(xt(this.options.skewX)),e}scaleUnitVector(t,e){return t.multiply(this.strokeUniformScalar).scalarMultiply(e)}}const Gg=new x;class Qi extends Wc{static getOrthogonalRotationFactor(t,e){const i=e?co(t,e):fg(t);return Math.abs(i)<qs?-1:1}constructor(t,e,i,s){super(s),v(this,"AB",void 0),v(this,"AC",void 0),v(this,"alpha",void 0),v(this,"bisector",void 0),this.A=new x(t),this.B=new x(e),this.C=new x(i),this.AB=this.createSideVector(this.A,this.B),this.AC=this.createSideVector(this.A,this.C),this.alpha=co(this.AB,this.AC),this.bisector=zo($c(this.AB.eq(Gg)?this.AC:this.AB,this.alpha/2))}calcOrthogonalProjection(t,e){let i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:this.strokeProjectionMagnitude;const s=this.createSideVector(t,e),n=Rc(s),o=Qi.getOrthogonalRotationFactor(n,this.bisector);return this.scaleUnitVector(n,i*o)}projectBevel(){const t=[];return(this.alpha%Rr==0?[this.B]:[this.B,this.C]).forEach((e=>{t.push(this.projectOrthogonally(this.A,e)),t.push(this.projectOrthogonally(this.A,e,-this.strokeProjectionMagnitude))})),t}projectMiter(){const t=[],e=Math.abs(this.alpha),i=1/Math.sin(e/2),s=this.scaleUnitVector(this.bisector,-this.strokeProjectionMagnitude*i),n=this.options.strokeUniform?lo(this.scaleUnitVector(this.bisector,this.options.strokeMiterLimit)):this.options.strokeMiterLimit;return lo(s)/this.strokeProjectionMagnitude<=n&&t.push(this.applySkew(this.A.add(s))),t.push(...this.projectBevel()),t}projectRoundNoSkew(t,e){const i=[],s=new x(Qi.getOrthogonalRotationFactor(this.bisector),Qi.getOrthogonalRotationFactor(new x(this.bisector.y,this.bisector.x)));return[new x(1,0).scalarMultiply(this.strokeProjectionMagnitude).multiply(this.strokeUniformScalar).multiply(s),new x(0,1).scalarMultiply(this.strokeProjectionMagnitude).multiply(this.strokeUniformScalar).multiply(s)].forEach((n=>{nl(n,t,e)&&i.push(this.A.add(n))})),i}projectRoundWithSkew(t,e){const i=[],{skewX:s,skewY:n,scaleX:o,scaleY:a,strokeUniform:l}=this.options,c=new x(Math.tan(xt(s)),Math.tan(xt(n))),h=this.strokeProjectionMagnitude,d=l?h/a/Math.sqrt(1/a**2+1/o**2*c.y**2):h/Math.sqrt(1+c.y**2),u=new x(Math.sqrt(Math.max(h**2-d**2,0)),d),p=l?h/Math.sqrt(1+c.x**2*(1/a)**2/(1/o+1/o*c.x*c.y)**2):h/Math.sqrt(1+c.x**2/(1+c.x*c.y)**2),g=new x(p,Math.sqrt(Math.max(h**2-p**2,0)));return[g,g.scalarMultiply(-1),u,u.scalarMultiply(-1)].map((f=>this.applySkew(l?f.multiply(this.strokeUniformScalar):f))).forEach((f=>{nl(f,t,e)&&i.push(this.applySkew(this.A).add(f))})),i}projectRound(){const t=[];t.push(...this.projectBevel());const e=this.alpha%Rr==0,i=this.applySkew(this.A),s=t[e?0:2].subtract(i),n=t[e?1:0].subtract(i),o=e?this.applySkew(this.AB.scalarMultiply(-1)):this.applySkew(this.bisector.multiply(this.strokeUniformScalar).scalarMultiply(-1)),a=Ls(s,o)>0,l=a?s:n,c=a?n:s;return this.isSkewed()?t.push(...this.projectRoundWithSkew(l,c)):t.push(...this.projectRoundNoSkew(l,c)),t}projectPoints(){switch(this.options.strokeLineJoin){case"miter":return this.projectMiter();case"round":return this.projectRound();default:return this.projectBevel()}}project(){return this.projectPoints().map((t=>({originPoint:this.A,projectedPoint:t,angle:this.alpha,bisector:this.bisector})))}}class dl extends Wc{constructor(t,e,i){super(i),this.A=new x(t),this.T=new x(e)}calcOrthogonalProjection(t,e){let i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:this.strokeProjectionMagnitude;const s=this.createSideVector(t,e);return this.scaleUnitVector(Rc(s),i)}projectButt(){return[this.projectOrthogonally(this.A,this.T,this.strokeProjectionMagnitude),this.projectOrthogonally(this.A,this.T,-this.strokeProjectionMagnitude)]}projectRound(){const t=[];if(!this.isSkewed()&&this.A.eq(this.T)){const e=new x(1,1).scalarMultiply(this.strokeProjectionMagnitude).multiply(this.strokeUniformScalar);t.push(this.applySkew(this.A.add(e)),this.applySkew(this.A.subtract(e)))}else t.push(...new Qi(this.A,this.T,this.T,this.options).projectRound());return t}projectSquare(){const t=[];if(this.A.eq(this.T)){const e=new x(1,1).scalarMultiply(this.strokeProjectionMagnitude).multiply(this.strokeUniformScalar);t.push(this.A.add(e),this.A.subtract(e))}else{const e=this.calcOrthogonalProjection(this.A,this.T,this.strokeProjectionMagnitude),i=this.scaleUnitVector(zo(this.createSideVector(this.A,this.T)),-this.strokeProjectionMagnitude),s=this.A.add(i);t.push(s.add(e),s.subtract(e))}return t.map((e=>this.applySkew(e)))}projectPoints(){switch(this.options.strokeLineCap){case"round":return this.projectRound();case"square":return this.projectSquare();default:return this.projectButt()}}project(){return this.projectPoints().map((t=>({originPoint:this.A,projectedPoint:t})))}}const Xg=function(r,t){let e=arguments.length>2&&arguments[2]!==void 0&&arguments[2];const i=[];if(r.length===0)return i;const s=r.reduce(((n,o)=>(n[n.length-1].eq(o)||n.push(new x(o)),n)),[new x(r[0])]);if(s.length===1)e=!0;else if(!e){const n=s[0],o=((a,l)=>{for(let c=a.length-1;c>=0;c--)if(l(a[c],c,a))return c;return-1})(s,(a=>!a.eq(n)));s.splice(o+1)}return s.forEach(((n,o,a)=>{let l,c;o===0?(c=a[1],l=e?n:a[a.length-1]):o===a.length-1?(l=a[o-1],c=e?n:a[0]):(l=a[o-1],c=a[o+1]),e&&a.length===1?i.push(...new dl(n,n,t).project()):!e||o!==0&&o!==a.length-1?i.push(...new Qi(n,l,c,t).project()):i.push(...new dl(n,o===0?c:l,t).project())})),i},No=r=>{const t={};return Object.keys(r).forEach((e=>{t[e]={},Object.keys(r[e]).forEach((i=>{t[e][i]=y({},r[e][i])}))})),t},Kg=r=>r.replace(/&/g,"&").replace(/"/g,""").replace(/'/g,"'").replace(/</g,"<").replace(/>/g,">");let _s;const Uo=r=>{if(_s||_s||(_s="Intl"in an()&&"Segmenter"in Intl&&new Intl.Segmenter(void 0,{granularity:"grapheme"})),_s){const t=_s.segment(r);return Array.from(t).map((e=>{let{segment:i}=e;return i}))}return qg(r)},qg=r=>{const t=[];for(let e,i=0;i<r.length;i++)(e=Zg(r,i))!==!1&&t.push(e);return t},Zg=(r,t)=>{const e=r.charCodeAt(t);if(isNaN(e))return"";if(e<55296||e>57343)return r.charAt(t);if(55296<=e&&e<=56319){if(r.length<=t+1)throw"High surrogate without following low surrogate";const s=r.charCodeAt(t+1);if(56320>s||s>57343)throw"High surrogate without following low surrogate";return r.charAt(t)+r.charAt(t+1)}if(t===0)throw"Low surrogate without preceding high surrogate";const i=r.charCodeAt(t-1);if(55296>i||i>56319)throw"Low surrogate without preceding high surrogate";return!1},Wo=function(r,t){let e=arguments.length>2&&arguments[2]!==void 0&&arguments[2];return r.fill!==t.fill||r.stroke!==t.stroke||r.strokeWidth!==t.strokeWidth||r.fontSize!==t.fontSize||r.fontFamily!==t.fontFamily||r.fontWeight!==t.fontWeight||r.fontStyle!==t.fontStyle||r.textDecorationThickness!==t.textDecorationThickness||r.textBackgroundColor!==t.textBackgroundColor||r.deltaY!==t.deltaY||e&&(r.overline!==t.overline||r.underline!==t.underline||r.linethrough!==t.linethrough)},Jg=(r,t)=>{const e=t.split(`
|
|
2357
|
-
`),i=[];let s=-1,n={};r=No(r);for(let o=0;o<e.length;o++){const a=Uo(e[o]);if(r[o])for(let l=0;l<a.length;l++){s++;const c=r[o][l];c&&Object.keys(c).length>0&&(Wo(n,c,!0)?i.push({start:s,end:s+1,style:c}):i[i.length-1].end++),n=c||{}}else s+=a.length,n={}}return i},Qg=(r,t)=>{if(!Array.isArray(r))return No(r);const e=t.split(Mo),i={};let s=-1,n=0;for(let o=0;o<e.length;o++){const a=Uo(e[o]);for(let l=0;l<a.length;l++)s++,r[n]&&r[n].start<=s&&s<r[n].end&&(i[o]=i[o]||{},i[o][l]=y({},r[n].style),s===r[n].end-1&&n++)}return i},
|
|
2358
|
-
`)]}static async fromElement(t,e,i){const s=ni(t,this.ATTRIBUTE_NAMES,i),{left:n=0,top:o=0,width:a=0,height:l=0,visible:c=!0}=s,h=rt(s,xf);return new this(y(y(y({},e),h),{},{left:n,top:o,width:a,height:l,visible:!!(c&&a&&l)}))}}v(ee,"type","Rect"),v(ee,"cacheProperties",[...ri,...Yc]),v(ee,"ownDefaults",{rx:0,ry:0}),v(ee,"ATTRIBUTE_NAMES",[..._i,"x","y","rx","ry","width","height"]),A.setClass(ee),A.setSVGClass(ee);const Ge="initialization",Gr="added",Go="removed",Xr="imperative",Gc=(r,t)=>{const{strokeUniform:e,strokeWidth:i,width:s,height:n,group:o}=t,a=o&&o!==r?un(o.calcTransformMatrix(),r.calcTransformMatrix()):null,l=a?t.getRelativeCenterPoint().transform(a):t.getRelativeCenterPoint(),c=!t.isStrokeAccountedForInDimensions(),h=e&&c?ng(new x(i,i),void 0,r.calcTransformMatrix()):Lo,d=!e&&c?i:0,u=Ro(s+d,n+d,Fo([a,t.calcOwnMatrix()],!0)).add(h).scalarDivide(2);return[l.subtract(u),l.add(u)]};class fn{calcLayoutResult(t,e){if(this.shouldPerformLayout(t))return this.calcBoundingBox(e,t)}shouldPerformLayout(t){let{type:e,prevStrategy:i,strategy:s}=t;return e===Ge||e===Xr||!!i&&s!==i}shouldLayoutClipPath(t){let{type:e,target:{clipPath:i}}=t;return e!==Ge&&i&&!i.absolutePositioned}getInitialSize(t,e){return e.size}calcBoundingBox(t,e){const{type:i,target:s}=e;if(i===Xr&&e.overrides)return e.overrides;if(t.length===0)return;const{left:n,top:o,width:a,height:l}=Ke(t.map((d=>Gc(s,d))).reduce(((d,u)=>d.concat(u)),[])),c=new x(a,l),h=new x(n,o).add(c.scalarDivide(2));if(i===Ge){const d=this.getInitialSize(e,{size:c,center:h});return{center:h,relativeCorrection:new x(0,0),size:d}}return{center:h.transform(s.calcOwnMatrix()),size:c}}}v(fn,"type","strategy");class uo extends fn{shouldPerformLayout(t){return!0}}v(uo,"type","fit-content"),A.setClass(uo);const wf=["strategy"],Cf=["target","strategy","bubbles","prevStrategy"],Xc="layoutManager";class Ys{constructor(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:new uo;v(this,"strategy",void 0),this.strategy=t,this._subscriptions=new Map}performLayout(t){const e=y(y({bubbles:!0,strategy:this.strategy},t),{},{prevStrategy:this._prevLayoutStrategy,stopPropagation(){this.bubbles=!1}});this.onBeforeLayout(e);const i=this.getLayoutResult(e);i&&this.commitLayout(e,i),this.onAfterLayout(e,i),this._prevLayoutStrategy=e.strategy}attachHandlers(t,e){const{target:i}=e;return[zr,dc,Hs,uc,ln,pc,Br,Up,Wp].map((s=>t.on(s,(n=>this.performLayout(s===zr?{type:"object_modified",trigger:s,e:n,target:i}:{type:"object_modifying",trigger:s,e:n,target:i})))))}subscribe(t,e){this.unsubscribe(t,e);const i=this.attachHandlers(t,e);this._subscriptions.set(t,i)}unsubscribe(t,e){(this._subscriptions.get(t)||[]).forEach((i=>i())),this._subscriptions.delete(t)}unsubscribeTargets(t){t.targets.forEach((e=>this.unsubscribe(e,t)))}subscribeTargets(t){t.targets.forEach((e=>this.subscribe(e,t)))}onBeforeLayout(t){const{target:e,type:i}=t,{canvas:s}=e;if(i===Ge||i===Gr?this.subscribeTargets(t):i===Go&&this.unsubscribeTargets(t),e.fire("layout:before",{context:t}),s&&s.fire("object:layout:before",{target:e,context:t}),i===Xr&&t.deep){const n=rt(t,wf);e.forEachObject((o=>o.layoutManager&&o.layoutManager.performLayout(y(y({},n),{},{bubbles:!1,target:o}))))}}getLayoutResult(t){const{target:e,strategy:i,type:s}=t,n=i.calcLayoutResult(t,e.getObjects());if(!n)return;const o=s===Ge?new x:e.getRelativeCenterPoint(),{center:a,correction:l=new x,relativeCorrection:c=new x}=n,h=o.subtract(a).add(l).transform(s===Ge?qt:Ce(e.calcOwnMatrix()),!0).add(c);return{result:n,prevCenter:o,nextCenter:a,offset:h}}commitLayout(t,e){const{target:i}=t,{result:{size:s},nextCenter:n}=e;var o,a;i.set({width:s.x,height:s.y}),this.layoutObjects(t,e),t.type===Ge?i.set({left:(o=t.x)!==null&&o!==void 0?o:n.x+s.x*Tt(i.originX),top:(a=t.y)!==null&&a!==void 0?a:n.y+s.y*Tt(i.originY)}):(i.setPositionByOrigin(n,V,V),i.setCoords(),i.set("dirty",!0))}layoutObjects(t,e){const{target:i}=t;i.forEachObject((s=>{s.group===i&&this.layoutObject(t,e,s)})),t.strategy.shouldLayoutClipPath(t)&&this.layoutObject(t,e,i.clipPath)}layoutObject(t,e,i){let{offset:s}=e;i.set({left:i.left+s.x,top:i.top+s.y})}onAfterLayout(t,e){const{target:i,strategy:s,bubbles:n,prevStrategy:o}=t,a=rt(t,Cf),{canvas:l}=i;i.fire("layout:after",{context:t,result:e}),l&&l.fire("object:layout:after",{context:t,result:e,target:i});const c=i.parent;n&&c!=null&&c.layoutManager&&((a.path||(a.path=[])).push(i),c.layoutManager.performLayout(y(y({},a),{},{target:c}))),i.set("dirty",!0)}dispose(){const{_subscriptions:t}=this;t.forEach((e=>e.forEach((i=>i())))),t.clear()}toObject(){return{type:Xc,strategy:this.strategy.constructor.type}}toJSON(){return this.toObject()}}A.setClass(Ys,Xc);const Sf=["type","objects","layoutManager"];class Tf extends Ys{performLayout(){}}class fi extends gc(Vt){static getDefaults(){return y(y({},super.getDefaults()),fi.ownDefaults)}constructor(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};super(),v(this,"_activeObjects",[]),v(this,"__objectSelectionTracker",void 0),v(this,"__objectSelectionDisposer",void 0),Object.assign(this,fi.ownDefaults),this.setOptions(e),this.groupInit(t,e)}groupInit(t,e){var i;this._objects=[...t],this.__objectSelectionTracker=this.__objectSelectionMonitor.bind(this,!0),this.__objectSelectionDisposer=this.__objectSelectionMonitor.bind(this,!1),this.forEachObject((s=>{this.enterGroup(s,!1)})),this.layoutManager=(i=e.layoutManager)!==null&&i!==void 0?i:new Ys,this.layoutManager.performLayout({type:Ge,target:this,targets:[...t],x:e.left,y:e.top})}canEnterGroup(t){return t===this||this.isDescendantOf(t)?(mi("error","Group: circular object trees are not supported, this call has no effect"),!1):this._objects.indexOf(t)===-1||(mi("error","Group: duplicate objects are not supported inside group, this call has no effect"),!1)}_filterObjectsBeforeEnteringGroup(t){return t.filter(((e,i,s)=>this.canEnterGroup(e)&&s.indexOf(e)===i))}add(){for(var t=arguments.length,e=new Array(t),i=0;i<t;i++)e[i]=arguments[i];const s=this._filterObjectsBeforeEnteringGroup(e),n=super.add(...s);return this._onAfterObjectsChange(Gr,s),n}insertAt(t){for(var e=arguments.length,i=new Array(e>1?e-1:0),s=1;s<e;s++)i[s-1]=arguments[s];const n=this._filterObjectsBeforeEnteringGroup(i),o=super.insertAt(t,...n);return this._onAfterObjectsChange(Gr,n),o}remove(){const t=super.remove(...arguments);return this._onAfterObjectsChange(Go,t),t}_onObjectAdded(t){this.enterGroup(t,!0),this.fire("object:added",{target:t}),t.fire("added",{target:this})}_onObjectRemoved(t,e){this.exitGroup(t,e),this.fire("object:removed",{target:t}),t.fire("removed",{target:this})}_onAfterObjectsChange(t,e){this.layoutManager.performLayout({type:t,targets:e,target:this})}_onStackOrderChanged(){this._set("dirty",!0)}_set(t,e){const i=this[t];return super._set(t,e),t==="canvas"&&i!==e&&(this._objects||[]).forEach((s=>{s._set(t,e)})),this}_shouldSetNestedCoords(){return this.subTargetCheck}removeAll(){return this._activeObjects=[],this.remove(...this._objects)}__objectSelectionMonitor(t,e){let{target:i}=e;const s=this._activeObjects;if(t)s.push(i),this._set("dirty",!0);else if(s.length>0){const n=s.indexOf(i);n>-1&&(s.splice(n,1),this._set("dirty",!0))}}_watchObject(t,e){t&&this._watchObject(!1,e),t?(e.on("selected",this.__objectSelectionTracker),e.on("deselected",this.__objectSelectionDisposer)):(e.off("selected",this.__objectSelectionTracker),e.off("deselected",this.__objectSelectionDisposer))}enterGroup(t,e){t.group&&t.group.remove(t),t._set("parent",this),this._enterGroup(t,e)}_enterGroup(t,e){e&&Nr(t,Rt(Ce(this.calcTransformMatrix()),t.calcTransformMatrix())),this._shouldSetNestedCoords()&&t.setCoords(),t._set("group",this),t._set("canvas",this.canvas),this._watchObject(!0,t);const i=this.canvas&&this.canvas.getActiveObject&&this.canvas.getActiveObject();i&&(i===t||t.isDescendantOf(i))&&this._activeObjects.push(t)}exitGroup(t,e){this._exitGroup(t,e),t._set("parent",void 0),t._set("canvas",void 0)}_exitGroup(t,e){t._set("group",void 0),e||(Nr(t,Rt(this.calcTransformMatrix(),t.calcTransformMatrix())),t.setCoords()),this._watchObject(!1,t);const i=this._activeObjects.length>0?this._activeObjects.indexOf(t):-1;i>-1&&this._activeObjects.splice(i,1)}shouldCache(){const t=Vt.prototype.shouldCache.call(this);if(t){for(let e=0;e<this._objects.length;e++)if(this._objects[e].willDrawShadow())return this.ownCaching=!1,!1}return t}willDrawShadow(){if(super.willDrawShadow())return!0;for(let t=0;t<this._objects.length;t++)if(this._objects[t].willDrawShadow())return!0;return!1}isOnACache(){return this.ownCaching||!!this.parent&&this.parent.isOnACache()}drawObject(t,e,i){this._renderBackground(t);for(let n=0;n<this._objects.length;n++){var s;const o=this._objects[n];(s=this.canvas)!==null&&s!==void 0&&s.preserveObjectStacking&&o.group!==this?(t.save(),t.transform(...Ce(this.calcTransformMatrix())),o.render(t),t.restore()):o.group===this&&o.render(t)}this._drawClipPath(t,this.clipPath,i)}setCoords(){super.setCoords(),this._shouldSetNestedCoords()&&this.forEachObject((t=>t.setCoords()))}triggerLayout(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};this.layoutManager.performLayout(y({target:this,type:Xr},t))}render(t){this._transformDone=!0,super.render(t),this._transformDone=!1}__serializeObjects(t,e){const i=this.includeDefaultValues;return this._objects.filter((function(s){return!s.excludeFromExport})).map((function(s){const n=s.includeDefaultValues;s.includeDefaultValues=i;const o=s[t||"toObject"](e);return s.includeDefaultValues=n,o}))}toObject(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[];const e=this.layoutManager.toObject();return y(y(y({},super.toObject(["subTargetCheck","interactive",...t])),e.strategy!=="fit-content"||this.includeDefaultValues?{layoutManager:e}:{}),{},{objects:this.__serializeObjects("toObject",t)})}toString(){return"#<Group: (".concat(this.complexity(),")>")}dispose(){this.layoutManager.unsubscribeTargets({targets:this.getObjects(),target:this}),this._activeObjects=[],this.forEachObject((t=>{this._watchObject(!1,t),t.dispose()})),super.dispose()}_createSVGBgRect(t){if(!this.backgroundColor)return"";const e=ee.prototype._toSVG.call(this),i=e.indexOf("COMMON_PARTS");e[i]='for="group" ';const s=e.join("");return t?t(s):s}_toSVG(t){const e=["<g ","COMMON_PARTS",` >
|
|
2356
|
+
`)}toObject(){const t={color:this.color,blur:this.blur,offsetX:this.offsetX,offsetY:this.offsetY,affectStroke:this.affectStroke,nonScaling:this.nonScaling,type:this.constructor.type},e=Ke.ownDefaults;return this.includeDefaultValues?t:$o(t,((i,s)=>i!==e[s]))}static async fromObject(t){return new this(t)}}v(Ke,"ownDefaults",{color:"rgb(0,0,0)",blur:0,offsetX:0,offsetY:0,affectStroke:!1,includeDefaultValues:!0,nonScaling:!1}),v(Ke,"type","shadow"),A.setClass(Ke,"shadow");const es=(r,t,e)=>Math.max(r,Math.min(t,e)),bg=[ie,Y,oe,be,"flipX","flipY","originX","originY","angle","opacity","globalCompositeOperation","shadow","visible",rs,ns],ri=[Dt,re,"strokeWidth","strokeDashArray","width","height","paintFirst","strokeUniform","strokeLineCap","strokeDashOffset","strokeLineJoin","strokeMiterLimit","backgroundColor","clipPath"],vg={top:0,left:0,width:0,height:0,angle:0,flipX:!1,flipY:!1,scaleX:1,scaleY:1,minScaleLimit:0,skewX:0,skewY:0,originX:Y,originY:ie,strokeWidth:1,strokeUniform:!1,padding:0,opacity:1,paintFirst:Dt,fill:"rgb(0,0,0)",fillRule:"nonzero",stroke:null,strokeDashArray:null,strokeDashOffset:0,strokeLineCap:"butt",strokeLineJoin:"miter",strokeMiterLimit:4,globalCompositeOperation:"source-over",backgroundColor:"",shadow:null,visible:!0,includeDefaultValues:!0,excludeFromExport:!1,objectCaching:!0,clipPath:void 0,inverted:!1,absolutePositioned:!1,centeredRotation:!0,centeredScaling:!1,dirty:!0},yg=(r,t,e,i)=>-e*Math.cos(r/i*Ks)+e+t,_g=()=>!1;class Ho{constructor(t){let{startValue:e,byValue:i,duration:s=500,delay:n=0,easing:o=yg,onStart:a=Ar,onChange:l=Ar,onComplete:c=Ar,abort:h=_g,target:d}=t;v(this,"_state","pending"),v(this,"durationProgress",0),v(this,"valueProgress",0),this.tick=this.tick.bind(this),this.duration=s,this.delay=n,this.easing=o,this._onStart=a,this._onChange=l,this._onComplete=c,this._abort=h,this.target=d,this.startValue=e,this.byValue=i,this.value=this.startValue,this.endValue=Object.freeze(this.calculate(this.duration).value)}get state(){return this._state}isDone(){return this._state==="aborted"||this._state==="completed"}start(){const t=e=>{this._state==="pending"&&(this.startTime=e||+new Date,this._state="running",this._onStart(),this.tick(this.startTime))};this.register(),this.delay>0?setTimeout((()=>Mr(t)),this.delay):Mr(t)}tick(t){const e=(t||+new Date)-this.startTime,i=Math.min(e,this.duration);this.durationProgress=i/this.duration;const{value:s,valueProgress:n}=this.calculate(i);this.value=Object.freeze(s),this.valueProgress=n,this._state!=="aborted"&&(this._abort(this.value,this.valueProgress,this.durationProgress)?(this._state="aborted",this.unregister()):e>=this.duration?(this.durationProgress=this.valueProgress=1,this._onChange(this.endValue,this.valueProgress,this.durationProgress),this._state="completed",this._onComplete(this.endValue,this.valueProgress,this.durationProgress),this.unregister()):(this._onChange(this.value,this.valueProgress,this.durationProgress),Mr(this.tick)))}register(){Hr.push(this)}unregister(){Hr.remove(this)}abort(){this._state="aborted",this.unregister()}}const xg=["startValue","endValue"];class wg extends Ho{constructor(t){let{startValue:e=0,endValue:i=100}=t;super(y(y({},rt(t,xg)),{},{startValue:e,byValue:i-e}))}calculate(t){const e=this.easing(t,this.startValue,this.byValue,this.duration);return{value:e,valueProgress:Math.abs((e-this.startValue)/this.byValue)}}}const Cg=["startValue","endValue"];class Sg extends Ho{constructor(t){let{startValue:e=[0],endValue:i=[100]}=t;super(y(y({},rt(t,Cg)),{},{startValue:e,byValue:i.map(((s,n)=>s-e[n]))}))}calculate(t){const e=this.startValue.map(((i,s)=>this.easing(t,i,this.byValue[s],this.duration,s)));return{value:e,valueProgress:Math.abs((e[0]-this.startValue[0])/this.byValue[0])}}}const Tg=["startValue","endValue","easing","onChange","onComplete","abort"],Eg=(r,t,e,i)=>t+e*(1-Math.cos(r/i*Ks)),$n=r=>r&&((t,e,i)=>r(new q(t).toRgba(),e,i));class Og extends Ho{constructor(t){let{startValue:e,endValue:i,easing:s=Eg,onChange:n,onComplete:o,abort:a}=t,l=rt(t,Tg);const c=new q(e).getSource(),h=new q(i).getSource();super(y(y({},l),{},{startValue:c,byValue:h.map(((d,u)=>d-c[u])),easing:s,onChange:$n(n),onComplete:$n(o),abort:$n(a)}))}calculate(t){const[e,i,s,n]=this.startValue.map(((a,l)=>this.easing(t,a,this.byValue[l],this.duration,l))),o=[...[e,i,s].map(Math.round),es(0,n,1)];return{value:o,valueProgress:o.map(((a,l)=>this.byValue[l]!==0?Math.abs((a-this.startValue[l])/this.byValue[l]):0)).find((a=>a!==0))||0}}}function Rc(r){const t=(e=>Array.isArray(e.startValue)||Array.isArray(e.endValue))(r)?new Sg(r):new wg(r);return t.start(),t}function kg(r){const t=new Og(r);return t.start(),t}class lt{constructor(t){this.status=t,this.points=[]}includes(t){return this.points.some((e=>e.eq(t)))}append(){for(var t=arguments.length,e=new Array(t),i=0;i<t;i++)e[i]=arguments[i];return this.points=this.points.concat(e.filter((s=>!this.includes(s)))),this}static isPointContained(t,e,i){let s=arguments.length>3&&arguments[3]!==void 0&&arguments[3];if(e.eq(i))return t.eq(e);if(e.x===i.x)return t.x===e.x&&(s||t.y>=Math.min(e.y,i.y)&&t.y<=Math.max(e.y,i.y));if(e.y===i.y)return t.y===e.y&&(s||t.x>=Math.min(e.x,i.x)&&t.x<=Math.max(e.x,i.x));{const n=ao(e,i),o=ao(e,t).divide(n);return s?Math.abs(o.x)===Math.abs(o.y):o.x===o.y&&o.x>=0&&o.x<=1}}static isPointInPolygon(t,e){const i=new x(t).setX(Math.min(t.x-1,...e.map((n=>n.x))));let s=0;for(let n=0;n<e.length;n++){const o=this.intersectSegmentSegment(e[n],e[(n+1)%e.length],t,i);if(o.includes(t))return!0;s+=+(o.status==="Intersection")}return s%2==1}static intersectLineLine(t,e,i,s){let n=!(arguments.length>4&&arguments[4]!==void 0)||arguments[4],o=!(arguments.length>5&&arguments[5]!==void 0)||arguments[5];const a=e.x-t.x,l=e.y-t.y,c=s.x-i.x,h=s.y-i.y,d=t.x-i.x,u=t.y-i.y,p=c*u-h*d,g=a*u-l*d,f=h*a-c*l;if(f!==0){const m=p/f,b=g/f;return(n||0<=m&&m<=1)&&(o||0<=b&&b<=1)?new lt("Intersection").append(new x(t.x+m*a,t.y+m*l)):new lt}if(p===0||g===0){const m=n||o||lt.isPointContained(t,i,s)||lt.isPointContained(e,i,s)||lt.isPointContained(i,t,e)||lt.isPointContained(s,t,e);return new lt(m?"Coincident":void 0)}return new lt("Parallel")}static intersectSegmentLine(t,e,i,s){return lt.intersectLineLine(t,e,i,s,!1,!0)}static intersectSegmentSegment(t,e,i,s){return lt.intersectLineLine(t,e,i,s,!1,!1)}static intersectLinePolygon(t,e,i){let s=!(arguments.length>3&&arguments[3]!==void 0)||arguments[3];const n=new lt,o=i.length;for(let a,l,c,h=0;h<o;h++){if(a=i[h],l=i[(h+1)%o],c=lt.intersectLineLine(t,e,a,l,s,!1),c.status==="Coincident")return c;n.append(...c.points)}return n.points.length>0&&(n.status="Intersection"),n}static intersectSegmentPolygon(t,e,i){return lt.intersectLinePolygon(t,e,i,!1)}static intersectPolygonPolygon(t,e){const i=new lt,s=t.length,n=[];for(let o=0;o<s;o++){const a=t[o],l=t[(o+1)%s],c=lt.intersectSegmentPolygon(a,l,e);c.status==="Coincident"?(n.push(c),i.append(a,l)):i.append(...c.points)}return n.length>0&&n.length===t.length?new lt("Coincident"):(i.points.length>0&&(i.status="Intersection"),i)}static intersectPolygonRectangle(t,e,i){const s=e.min(i),n=e.max(i),o=new x(n.x,s.y),a=new x(s.x,n.y);return lt.intersectPolygonPolygon(t,[s,o,n,a])}}class Pg extends gc{getX(){return this.getXY().x}setX(t){this.setXY(this.getXY().setX(t))}getY(){return this.getXY().y}setY(t){this.setXY(this.getXY().setY(t))}getRelativeX(){return this.left}setRelativeX(t){this.left=t}getRelativeY(){return this.top}setRelativeY(t){this.top=t}getXY(){const t=this.getRelativeXY();return this.group?Qt(t,this.group.calcTransformMatrix()):t}setXY(t,e,i){this.group&&(t=Qt(t,Ce(this.group.calcTransformMatrix()))),this.setRelativeXY(t,e,i)}getRelativeXY(){return new x(this.left,this.top)}setRelativeXY(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:this.originX,i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:this.originY;this.setPositionByOrigin(t,e,i)}isStrokeAccountedForInDimensions(){return!1}getCoords(){const{tl:t,tr:e,br:i,bl:s}=this.aCoords||(this.aCoords=this.calcACoords()),n=[t,e,i,s];if(this.group){const o=this.group.calcTransformMatrix();return n.map((a=>Qt(a,o)))}return n}intersectsWithRect(t,e){return lt.intersectPolygonRectangle(this.getCoords(),t,e).status==="Intersection"}intersectsWithObject(t){const e=lt.intersectPolygonPolygon(this.getCoords(),t.getCoords());return e.status==="Intersection"||e.status==="Coincident"||t.isContainedWithinObject(this)||this.isContainedWithinObject(t)}isContainedWithinObject(t){return this.getCoords().every((e=>t.containsPoint(e)))}isContainedWithinRect(t,e){const{left:i,top:s,width:n,height:o}=this.getBoundingRect();return i>=t.x&&i+n<=e.x&&s>=t.y&&s+o<=e.y}isOverlapping(t){return this.intersectsWithObject(t)||this.isContainedWithinObject(t)||t.isContainedWithinObject(this)}containsPoint(t){return lt.isPointInPolygon(t,this.getCoords())}isOnScreen(){if(!this.canvas)return!1;const{tl:t,br:e}=this.canvas.vptCoords;return!!this.getCoords().some((i=>i.x<=e.x&&i.x>=t.x&&i.y<=e.y&&i.y>=t.y))||!!this.intersectsWithRect(t,e)||this.containsPoint(t.midPointFrom(e))}isPartiallyOnScreen(){if(!this.canvas)return!1;const{tl:t,br:e}=this.canvas.vptCoords;return this.intersectsWithRect(t,e)?!0:this.getCoords().every((i=>(i.x>=e.x||i.x<=t.x)&&(i.y>=e.y||i.y<=t.y)))&&this.containsPoint(t.midPointFrom(e))}getBoundingRect(){return qe(this.getCoords())}getScaledWidth(){return this._getTransformedDimensions().x}getScaledHeight(){return this._getTransformedDimensions().y}scale(t){this._set(oe,t),this._set(be,t),this.setCoords()}scaleToWidth(t){const e=this.getBoundingRect().width/this.getScaledWidth();return this.scale(t/this.width/e)}scaleToHeight(t){const e=this.getBoundingRect().height/this.getScaledHeight();return this.scale(t/this.height/e)}getCanvasRetinaScaling(){var t;return((t=this.canvas)===null||t===void 0?void 0:t.getRetinaScaling())||1}getTotalAngle(){return this.group?ei(bc(this.calcTransformMatrix())):this.angle}getViewportTransform(){var t;return((t=this.canvas)===null||t===void 0?void 0:t.viewportTransform)||Kt.concat()}calcACoords(){const t=os({angle:this.angle}),{x:e,y:i}=this.getRelativeCenterPoint(),s=Zs(e,i),n=$t(s,t),o=this._getTransformedDimensions(),a=o.x/2,l=o.y/2;return{tl:Qt({x:-a,y:-l},n),tr:Qt({x:a,y:-l},n),bl:Qt({x:-a,y:l},n),br:Qt({x:a,y:l},n)}}setCoords(){this.aCoords=this.calcACoords()}transformMatrixKey(){let t=arguments.length>0&&arguments[0]!==void 0&&arguments[0],e=[];return!t&&this.group&&(e=this.group.transformMatrixKey(t)),e.push(this.top,this.left,this.width,this.height,this.scaleX,this.scaleY,this.angle,this.strokeWidth,this.skewX,this.skewY,+this.flipX,+this.flipY,St(this.originX),St(this.originY)),e}calcTransformMatrix(){let t=arguments.length>0&&arguments[0]!==void 0&&arguments[0],e=this.calcOwnMatrix();if(t||!this.group)return e;const i=this.transformMatrixKey(t),s=this.matrixCache;return s&&s.key.every(((n,o)=>n===i[o]))?s.value:(this.group&&(e=$t(this.group.calcTransformMatrix(!1),e)),this.matrixCache={key:i,value:e},e)}calcOwnMatrix(){const t=this.transformMatrixKey(!0),e=this.ownMatrixCache;if(e&&e.key===t)return e.value;const i=this.getRelativeCenterPoint(),s={angle:this.angle,translateX:i.x,translateY:i.y,scaleX:this.scaleX,scaleY:this.scaleY,skewX:this.skewX,skewY:this.skewY,flipX:this.flipX,flipY:this.flipY},n=Zp(s);return this.ownMatrixCache={key:t,value:n},n}_getNonTransformedDimensions(){return new x(this.width,this.height).scalarAdd(this.strokeWidth)}_calculateCurrentDimensions(t){return this._getTransformedDimensions(t).transform(this.getViewportTransform(),!0).scalarAdd(2*this.padding)}_getTransformedDimensions(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};const e=y({scaleX:this.scaleX,scaleY:this.scaleY,skewX:this.skewX,skewY:this.skewY,width:this.width,height:this.height,strokeWidth:this.strokeWidth},t),i=e.strokeWidth;let s=i,n=0;this.strokeUniform&&(s=0,n=i);const o=e.width+s,a=e.height+s;let l;return l=e.skewX===0&&e.skewY===0?new x(o*e.scaleX,a*e.scaleY):Ro(o,a,hn(e)),l.scalarAdd(n)}translateToGivenOrigin(t,e,i,s,n){let o=t.x,a=t.y;const l=St(s)-St(e),c=St(n)-St(i);if(l||c){const h=this._getTransformedDimensions();o+=l*h.x,a+=c*h.y}return new x(o,a)}translateToCenterPoint(t,e,i){if(e===V&&i===V)return t;const s=this.translateToGivenOrigin(t,e,i,V,V);return this.angle?s.rotate(_t(this.angle),t):s}translateToOriginPoint(t,e,i){const s=this.translateToGivenOrigin(t,V,V,e,i);return this.angle?s.rotate(_t(this.angle),t):s}getCenterPoint(){const t=this.getRelativeCenterPoint();return this.group?Qt(t,this.group.calcTransformMatrix()):t}getRelativeCenterPoint(){return this.translateToCenterPoint(new x(this.left,this.top),this.originX,this.originY)}getPointByOrigin(t,e){return this.translateToOriginPoint(this.getRelativeCenterPoint(),t,e)}setPositionByOrigin(t,e,i){const s=this.translateToCenterPoint(t,e,i),n=this.translateToOriginPoint(s,this.originX,this.originY);this.set({left:n.x,top:n.y})}_getLeftTopCoords(){return this.translateToOriginPoint(this.getRelativeCenterPoint(),Y,ie)}}const Ag=["type"],Dg=["extraParam"];let Ue=class Lr extends Pg{static getDefaults(){return Lr.ownDefaults}get type(){const t=this.constructor.type;return t==="FabricObject"?"object":t.toLowerCase()}set type(t){fi("warn","Setting type has no effect",t)}constructor(t){super(),v(this,"_cacheContext",null),Object.assign(this,Lr.ownDefaults),this.setOptions(t)}_createCacheCanvas(){this._cacheCanvas=ti(),this._cacheContext=this._cacheCanvas.getContext("2d"),this._updateCacheCanvas(),this.dirty=!0}_limitCacheSize(t){const e=t.width,i=t.height,s=W.maxCacheSideLimit,n=W.minCacheSideLimit;if(e<=s&&i<=s&&e*i<=W.perfLimitSizeTotal)return e<n&&(t.width=n),i<n&&(t.height=n),t;const o=e/i,[a,l]=Ds.limitDimsByArea(o),c=es(n,a,s),h=es(n,l,s);return e>c&&(t.zoomX/=e/c,t.width=c,t.capped=!0),i>h&&(t.zoomY/=i/h,t.height=h,t.capped=!0),t}_getCacheCanvasDimensions(){const t=this.getTotalObjectScaling(),e=this._getTransformedDimensions({skewX:0,skewY:0}),i=e.x*t.x/this.scaleX,s=e.y*t.y/this.scaleY;return{width:Math.ceil(i+2),height:Math.ceil(s+2),zoomX:t.x,zoomY:t.y,x:i,y:s}}_updateCacheCanvas(){const t=this._cacheCanvas,e=this._cacheContext,{width:i,height:s,zoomX:n,zoomY:o,x:a,y:l}=this._limitCacheSize(this._getCacheCanvasDimensions()),c=i!==t.width||s!==t.height,h=this.zoomX!==n||this.zoomY!==o;if(!t||!e)return!1;if(c||h){i!==t.width||s!==t.height?(t.width=i,t.height=s):(e.setTransform(1,0,0,1,0,0),e.clearRect(0,0,t.width,t.height));const d=a/2,u=l/2;return this.cacheTranslationX=Math.round(t.width/2-d)+d,this.cacheTranslationY=Math.round(t.height/2-u)+u,e.translate(this.cacheTranslationX,this.cacheTranslationY),e.scale(n,o),this.zoomX=n,this.zoomY=o,!0}return!1}setOptions(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};this._setOptions(t)}transform(t){const e=this.group&&!this.group._transformDone||this.group&&this.canvas&&t===this.canvas.contextTop,i=this.calcTransformMatrix(!e);t.transform(i[0],i[1],i[2],i[3],i[4],i[5])}getObjectScaling(){if(!this.group)return new x(Math.abs(this.scaleX),Math.abs(this.scaleY));const t=Vr(this.calcTransformMatrix());return new x(Math.abs(t.scaleX),Math.abs(t.scaleY))}getTotalObjectScaling(){const t=this.getObjectScaling();if(this.canvas){const e=this.canvas.getZoom(),i=this.getCanvasRetinaScaling();return t.scalarMultiply(e*i)}return t}getObjectOpacity(){let t=this.opacity;return this.group&&(t*=this.group.getObjectOpacity()),t}_constrainScale(t){return Math.abs(t)<this.minScaleLimit?t<0?-this.minScaleLimit:this.minScaleLimit:t===0?1e-4:t}_set(t,e){t!==oe&&t!==be||(e=this._constrainScale(e)),t===oe&&e<0?(this.flipX=!this.flipX,e*=-1):t==="scaleY"&&e<0?(this.flipY=!this.flipY,e*=-1):t!=="shadow"||!e||e instanceof Ke||(e=new Ke(e));const i=this[t]!==e;return this[t]=e,i&&this.constructor.cacheProperties.includes(t)&&(this.dirty=!0),this.parent&&(this.dirty||i&&this.constructor.stateProperties.includes(t))&&this.parent._set("dirty",!0),this}isNotVisible(){return this.opacity===0||!this.width&&!this.height&&this.strokeWidth===0||!this.visible}render(t){this.isNotVisible()||this.canvas&&this.canvas.skipOffscreen&&!this.group&&!this.isOnScreen()||(t.save(),this._setupCompositeOperation(t),this.drawSelectionBackground(t),this.transform(t),this._setOpacity(t),this._setShadow(t),this.shouldCache()?(this.renderCache(),this.drawCacheOnCanvas(t)):(this._removeCacheCanvas(),this.drawObject(t,!1,{}),this.dirty=!1),t.restore())}drawSelectionBackground(t){}renderCache(t){if(t=t||{},this._cacheCanvas&&this._cacheContext||this._createCacheCanvas(),this.isCacheDirty()&&this._cacheContext){const{zoomX:e,zoomY:i,cacheTranslationX:s,cacheTranslationY:n}=this,{width:o,height:a}=this._cacheCanvas;this.drawObject(this._cacheContext,t.forClipping,{zoomX:e,zoomY:i,cacheTranslationX:s,cacheTranslationY:n,width:o,height:a,parentClipPaths:[]}),this.dirty=!1}}_removeCacheCanvas(){this._cacheCanvas=void 0,this._cacheContext=null}hasStroke(){return this.stroke&&this.stroke!=="transparent"&&this.strokeWidth!==0}hasFill(){return this.fill&&this.fill!=="transparent"}needsItsOwnCache(){return!!(this.paintFirst===re&&this.hasFill()&&this.hasStroke()&&this.shadow)||!!this.clipPath}shouldCache(){return this.ownCaching=this.objectCaching&&(!this.parent||!this.parent.isOnACache())||this.needsItsOwnCache(),this.ownCaching}willDrawShadow(){return!!this.shadow&&(this.shadow.offsetX!==0||this.shadow.offsetY!==0)}drawClipPathOnCache(t,e,i){t.save(),e.inverted?t.globalCompositeOperation="destination-out":t.globalCompositeOperation="destination-in",t.setTransform(1,0,0,1,0,0),t.drawImage(i,0,0),t.restore()}drawObject(t,e,i){const s=this.fill,n=this.stroke;e?(this.fill="black",this.stroke="",this._setClippingProperties(t)):this._renderBackground(t),this._render(t),this._drawClipPath(t,this.clipPath,i),this.fill=s,this.stroke=n}createClipPathLayer(t,e){const i=ve(e),s=i.getContext("2d");if(s.translate(e.cacheTranslationX,e.cacheTranslationY),s.scale(e.zoomX,e.zoomY),t._cacheCanvas=i,e.parentClipPaths.forEach((n=>{n.transform(s)})),e.parentClipPaths.push(t),t.absolutePositioned){const n=Ce(this.calcTransformMatrix());s.transform(n[0],n[1],n[2],n[3],n[4],n[5])}return t.transform(s),t.drawObject(s,!0,e),i}_drawClipPath(t,e,i){if(!e)return;e._transformDone=!0;const s=this.createClipPathLayer(e,i);this.drawClipPathOnCache(t,e,s)}drawCacheOnCanvas(t){t.scale(1/this.zoomX,1/this.zoomY),t.drawImage(this._cacheCanvas,-this.cacheTranslationX,-this.cacheTranslationY)}isCacheDirty(){let t=arguments.length>0&&arguments[0]!==void 0&&arguments[0];if(this.isNotVisible())return!1;const e=this._cacheCanvas,i=this._cacheContext;return!(!e||!i||t||!this._updateCacheCanvas())||!!(this.dirty||this.clipPath&&this.clipPath.absolutePositioned)&&(e&&i&&!t&&(i.save(),i.setTransform(1,0,0,1,0,0),i.clearRect(0,0,e.width,e.height),i.restore()),!0)}_renderBackground(t){if(!this.backgroundColor)return;const e=this._getNonTransformedDimensions();t.fillStyle=this.backgroundColor,t.fillRect(-e.x/2,-e.y/2,e.x,e.y),this._removeShadow(t)}_setOpacity(t){this.group&&!this.group._transformDone?t.globalAlpha=this.getObjectOpacity():t.globalAlpha*=this.opacity}_setStrokeStyles(t,e){const i=e.stroke;i&&(t.lineWidth=e.strokeWidth,t.lineCap=e.strokeLineCap,t.lineDashOffset=e.strokeDashOffset,t.lineJoin=e.strokeLineJoin,t.miterLimit=e.strokeMiterLimit,ge(i)?i.gradientUnits==="percentage"||i.gradientTransform||i.patternTransform?this._applyPatternForTransformedGradient(t,i):(t.strokeStyle=i.toLive(t),this._applyPatternGradientTransform(t,i)):t.strokeStyle=e.stroke)}_setFillStyles(t,e){let{fill:i}=e;i&&(ge(i)?(t.fillStyle=i.toLive(t),this._applyPatternGradientTransform(t,i)):t.fillStyle=i)}_setClippingProperties(t){t.globalAlpha=1,t.strokeStyle="transparent",t.fillStyle="#000000"}_setLineDash(t,e){e&&e.length!==0&&t.setLineDash(e)}_setShadow(t){if(!this.shadow)return;const e=this.shadow,i=this.canvas,s=this.getCanvasRetinaScaling(),[n,,,o]=(i==null?void 0:i.viewportTransform)||Kt,a=n*s,l=o*s,c=e.nonScaling?new x(1,1):this.getObjectScaling();t.shadowColor=e.color,t.shadowBlur=e.blur*W.browserShadowBlurConstant*(a+l)*(c.x+c.y)/4,t.shadowOffsetX=e.offsetX*a*c.x,t.shadowOffsetY=e.offsetY*l*c.y}_removeShadow(t){this.shadow&&(t.shadowColor="",t.shadowBlur=t.shadowOffsetX=t.shadowOffsetY=0)}_applyPatternGradientTransform(t,e){if(!ge(e))return{offsetX:0,offsetY:0};const i=e.gradientTransform||e.patternTransform,s=-this.width/2+e.offsetX||0,n=-this.height/2+e.offsetY||0;return e.gradientUnits==="percentage"?t.transform(this.width,0,0,this.height,s,n):t.transform(1,0,0,1,s,n),i&&t.transform(i[0],i[1],i[2],i[3],i[4],i[5]),{offsetX:s,offsetY:n}}_renderPaintInOrder(t){this.paintFirst===re?(this._renderStroke(t),this._renderFill(t)):(this._renderFill(t),this._renderStroke(t))}_render(t){}_renderFill(t){this.fill&&(t.save(),this._setFillStyles(t,this),this.fillRule==="evenodd"?t.fill("evenodd"):t.fill(),t.restore())}_renderStroke(t){if(this.stroke&&this.strokeWidth!==0){if(this.shadow&&!this.shadow.affectStroke&&this._removeShadow(t),t.save(),this.strokeUniform){const e=this.getObjectScaling();t.scale(1/e.x,1/e.y)}this._setLineDash(t,this.strokeDashArray),this._setStrokeStyles(t,this),t.stroke(),t.restore()}}_applyPatternForTransformedGradient(t,e){var i;const s=this._limitCacheSize(this._getCacheCanvasDimensions()),n=this.getCanvasRetinaScaling(),o=s.x/this.scaleX/n,a=s.y/this.scaleY/n,l=ve({width:Math.ceil(o),height:Math.ceil(a)}),c=l.getContext("2d");c&&(c.beginPath(),c.moveTo(0,0),c.lineTo(o,0),c.lineTo(o,a),c.lineTo(0,a),c.closePath(),c.translate(o/2,a/2),c.scale(s.zoomX/this.scaleX/n,s.zoomY/this.scaleY/n),this._applyPatternGradientTransform(c,e),c.fillStyle=e.toLive(t),c.fill(),t.translate(-this.width/2-this.strokeWidth/2,-this.height/2-this.strokeWidth/2),t.scale(n*this.scaleX/s.zoomX,n*this.scaleY/s.zoomY),t.strokeStyle=(i=c.createPattern(l,"no-repeat"))!==null&&i!==void 0?i:"")}_findCenterFromElement(){return new x(this.left+this.width/2,this.top+this.height/2)}clone(t){const e=this.toObject(t);return this.constructor.fromObject(e)}cloneAsImage(t){const e=this.toCanvasElement(t);return new(A.getClass("image"))(e)}toCanvasElement(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};const e=Tc(this),i=this.group,s=this.shadow,n=Math.abs,o=t.enableRetinaScaling?cc():1,a=(t.multiplier||1)*o,l=t.canvasProvider||(_=>new Js(_,{enableRetinaScaling:!1,renderOnAddRemove:!1,skipOffscreen:!1}));delete this.group,t.withoutTransform&&rg(this),t.withoutShadow&&(this.shadow=null),t.viewportTransform&&og(this,this.getViewportTransform()),this.setCoords();const c=ti(),h=this.getBoundingRect(),d=this.shadow,u=new x;if(d){const _=d.blur,w=d.nonScaling?new x(1,1):this.getObjectScaling();u.x=2*Math.round(n(d.offsetX)+_)*n(w.x),u.y=2*Math.round(n(d.offsetY)+_)*n(w.y)}const p=h.width+u.x,g=h.height+u.y;c.width=Math.ceil(p),c.height=Math.ceil(g);const f=l(c);t.format==="jpeg"&&(f.backgroundColor="#fff"),this.setPositionByOrigin(new x(f.width/2,f.height/2),V,V);const m=this.canvas;f._objects=[this],this.set("canvas",f),this.setCoords();const b=f.toCanvasElement(a||1,t);return this.set("canvas",m),this.shadow=s,i&&(this.group=i),this.set(e),this.setCoords(),f._objects=[],f.destroy(),b}toDataURL(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};return fc(this.toCanvasElement(t),t.format||"png",t.quality||1)}toBlob(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};return mc(this.toCanvasElement(t),t.format||"png",t.quality||1)}isType(){for(var t=arguments.length,e=new Array(t),i=0;i<t;i++)e[i]=arguments[i];return e.includes(this.constructor.type)||e.includes(this.type)}complexity(){return 1}toJSON(){return this.toObject()}rotate(t){const{centeredRotation:e,originX:i,originY:s}=this;if(e){const{x:n,y:o}=this.getRelativeCenterPoint();this.originX=V,this.originY=V,this.left=n,this.top=o}if(this.set("angle",t),e){const{x:n,y:o}=this.translateToOriginPoint(this.getRelativeCenterPoint(),i,s);this.left=n,this.top=o,this.originX=i,this.originY=s}}setOnGroup(){}_setupCompositeOperation(t){this.globalCompositeOperation&&(t.globalCompositeOperation=this.globalCompositeOperation)}dispose(){Hr.cancelByTarget(this),this.off(),this._set("canvas",void 0),this._cacheCanvas&&Re().dispose(this._cacheCanvas),this._cacheCanvas=void 0,this._cacheContext=null}animate(t,e){return Object.entries(t).reduce(((i,s)=>{let[n,o]=s;return i[n]=this._animate(n,o,e),i}),{})}_animate(t,e){let i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};const s=t.split("."),n=this.constructor.colorProperties.includes(s[s.length-1]),{abort:o,startValue:a,onChange:l,onComplete:c}=i,h=y(y({},i),{},{target:this,startValue:a??s.reduce(((d,u)=>d[u]),this),endValue:e,abort:o==null?void 0:o.bind(this),onChange:(d,u,p)=>{s.reduce(((g,f,m)=>(m===s.length-1&&(g[f]=d),g[f])),this),l&&l(d,u,p)},onComplete:(d,u,p)=>{this.setCoords(),c&&c(d,u,p)}});return n?kg(h):Rc(h)}isDescendantOf(t){const{parent:e,group:i}=this;return e===t||i===t||!!e&&e.isDescendantOf(t)||!!i&&i!==e&&i.isDescendantOf(t)}getAncestors(){const t=[];let e=this;do e=e.parent,e&&t.push(e);while(e);return t}findCommonAncestors(t){if(this===t)return{fork:[],otherFork:[],common:[this,...this.getAncestors()]};const e=this.getAncestors(),i=t.getAncestors();if(e.length===0&&i.length>0&&this===i[i.length-1])return{fork:[],otherFork:[t,...i.slice(0,i.length-1)],common:[this]};for(let s,n=0;n<e.length;n++){if(s=e[n],s===t)return{fork:[this,...e.slice(0,n)],otherFork:[],common:e.slice(n)};for(let o=0;o<i.length;o++){if(this===i[o])return{fork:[],otherFork:[t,...i.slice(0,o)],common:[this,...e]};if(s===i[o])return{fork:[this,...e.slice(0,n)],otherFork:[t,...i.slice(0,o)],common:e.slice(n)}}}return{fork:[this,...e],otherFork:[t,...i],common:[]}}hasCommonAncestors(t){const e=this.findCommonAncestors(t);return e&&!!e.common.length}isInFrontOf(t){if(this===t)return;const e=this.findCommonAncestors(t);if(e.fork.includes(t))return!0;if(e.otherFork.includes(this))return!1;const i=e.common[0]||this.canvas;if(!i)return;const s=e.fork.pop(),n=e.otherFork.pop(),o=i._objects.indexOf(s),a=i._objects.indexOf(n);return o>-1&&o>a}toObject(){const t=(arguments.length>0&&arguments[0]!==void 0?arguments[0]:[]).concat(Lr.customProperties,this.constructor.customProperties||[]);let e;const i=W.NUM_FRACTION_DIGITS,{clipPath:s,fill:n,stroke:o,shadow:a,strokeDashArray:l,left:c,top:h,originX:d,originY:u,width:p,height:g,strokeWidth:f,strokeLineCap:m,strokeDashOffset:b,strokeLineJoin:_,strokeUniform:w,strokeMiterLimit:S,scaleX:T,scaleY:k,angle:O,flipX:E,flipY:P,opacity:R,visible:L,backgroundColor:F,fillRule:H,paintFirst:M,globalCompositeOperation:U,skewX:X,skewY:J}=this;s&&!s.excludeFromExport&&(e=s.toObject(t.concat("inverted","absolutePositioned")));const N=Ut=>tt(Ut,i),wt=y(y({},as(this,t)),{},{type:this.constructor.type,version:so,originX:d,originY:u,left:N(c),top:N(h),width:N(p),height:N(g),fill:Ya(n)?n.toObject():n,stroke:Ya(o)?o.toObject():o,strokeWidth:N(f),strokeDashArray:l&&l.concat(),strokeLineCap:m,strokeDashOffset:b,strokeLineJoin:_,strokeUniform:w,strokeMiterLimit:N(S),scaleX:N(T),scaleY:N(k),angle:N(O),flipX:E,flipY:P,opacity:N(R),shadow:a&&a.toObject(),visible:L,backgroundColor:F,fillRule:H,paintFirst:M,globalCompositeOperation:U,skewX:N(X),skewY:N(J)},e?{clipPath:e}:null);return this.includeDefaultValues?wt:this._removeDefaultValues(wt)}toDatalessObject(t){return this.toObject(t)}_removeDefaultValues(t){const e=this.constructor.getDefaults(),i=Object.keys(e).length>0?e:Object.getPrototypeOf(this);return $o(t,((s,n)=>{if(n===Y||n===ie||n==="type")return!0;const o=i[n];return s!==o&&!(Array.isArray(s)&&Array.isArray(o)&&s.length===0&&o.length===0)}))}toString(){return"#<".concat(this.constructor.type,">")}static _fromObject(t){let e=rt(t,Ag),i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},{extraParam:s}=i,n=rt(i,Dg);return dn(e,n).then((o=>s?(delete o[s],new this(e[s],o)):new this(o)))}static fromObject(t,e){return this._fromObject(t,e)}};v(Ue,"stateProperties",bg),v(Ue,"cacheProperties",ri),v(Ue,"ownDefaults",vg),v(Ue,"type","FabricObject"),v(Ue,"colorProperties",[Dt,re,"backgroundColor"]),v(Ue,"customProperties",[]),A.setClass(Ue),A.setClass(Ue,"object");const ls=(r,t,e)=>(i,s,n,o)=>{const a=t(i,s,n,o);return a&&Ec(r,y(y({},kc(i,s,n,o)),e)),a};function cs(r){return(t,e,i,s)=>{const{target:n,originX:o,originY:a}=e,l=n.getRelativeCenterPoint(),c=n.translateToOriginPoint(l,o,a),h=r(t,e,i,s);return n.setPositionByOrigin(c,e.originX,e.originY),h}}const ll=ls(Hs,cs(((r,t,e,i)=>{const s=Bo(t,t.originX,t.originY,e,i);if(St(t.originX)===St(V)||St(t.originX)===St(yt)&&s.x<0||St(t.originX)===St(Y)&&s.x>0){const{target:n}=t,o=n.strokeWidth/(n.strokeUniform?n.scaleX:1),a=Oc(t)?2:1,l=n.width,c=Math.abs(s.x*a/n.scaleX)-o;return n.set("width",Math.max(c,1)),l!==n.width}return!1})));function Mg(r,t,e,i,s){i=i||{};const n=this.sizeX||i.cornerSize||s.cornerSize,o=this.sizeY||i.cornerSize||s.cornerSize,a=i.transparentCorners!==void 0?i.transparentCorners:s.transparentCorners,l=a?re:Dt,c=!a&&(i.cornerStrokeColor||s.cornerStrokeColor);let h,d=t,u=e;r.save(),r.fillStyle=i.cornerColor||s.cornerColor||"",r.strokeStyle=i.cornerStrokeColor||s.cornerStrokeColor||"",n>o?(h=n,r.scale(1,o/n),u=e*n/o):o>n?(h=o,r.scale(n/o,1),d=t*o/n):h=n,r.beginPath(),r.arc(d,u,h/2,0,Rr,!1),r[l](),c&&r.stroke(),r.restore()}function Ig(r,t,e,i,s){i=i||{};const n=this.sizeX||i.cornerSize||s.cornerSize,o=this.sizeY||i.cornerSize||s.cornerSize,a=i.transparentCorners!==void 0?i.transparentCorners:s.transparentCorners,l=a?re:Dt,c=!a&&(i.cornerStrokeColor||s.cornerStrokeColor),h=n/2,d=o/2;r.save(),r.fillStyle=i.cornerColor||s.cornerColor||"",r.strokeStyle=i.cornerStrokeColor||s.cornerStrokeColor||"",r.translate(t,e);const u=s.getTotalAngle();r.rotate(_t(u)),r["".concat(l,"Rect")](-h,-d,n,o),c&&r.strokeRect(-h,-d,n,o),r.restore()}class _e{constructor(t){v(this,"visible",!0),v(this,"actionName",cn),v(this,"angle",0),v(this,"x",0),v(this,"y",0),v(this,"offsetX",0),v(this,"offsetY",0),v(this,"sizeX",0),v(this,"sizeY",0),v(this,"touchSizeX",0),v(this,"touchSizeY",0),v(this,"cursorStyle","crosshair"),v(this,"withConnection",!1),Object.assign(this,t)}shouldActivate(t,e,i,s){var n;let{tl:o,tr:a,br:l,bl:c}=s;return((n=e.canvas)===null||n===void 0?void 0:n.getActiveObject())===e&&e.isControlVisible(t)&<.isPointInPolygon(i,[o,a,l,c])}getActionHandler(t,e,i){return this.actionHandler}getMouseDownHandler(t,e,i){return this.mouseDownHandler}getMouseUpHandler(t,e,i){return this.mouseUpHandler}cursorStyleHandler(t,e,i){return e.cursorStyle}getActionName(t,e,i){return e.actionName}getVisibility(t,e){var i,s;return(i=(s=t._controlsVisibility)===null||s===void 0?void 0:s[e])!==null&&i!==void 0?i:this.visible}setVisibility(t,e,i){this.visible=t}positionHandler(t,e,i,s){return new x(this.x*t.x+this.offsetX,this.y*t.y+this.offsetY).transform(e)}calcCornerCoords(t,e,i,s,n,o){const a=Fo([Zs(i,s),os({angle:t}),jo((n?this.touchSizeX:this.sizeX)||e,(n?this.touchSizeY:this.sizeY)||e)]);return{tl:new x(-.5,-.5).transform(a),tr:new x(.5,-.5).transform(a),br:new x(.5,.5).transform(a),bl:new x(-.5,.5).transform(a)}}render(t,e,i,s,n){((s=s||{}).cornerStyle||n.cornerStyle)==="circle"?Mg.call(this,t,e,i,s,n):Ig.call(this,t,e,i,s,n)}}const Lg=(r,t,e)=>e.lockRotation?Ur:t.cursorStyle,Fg=ls(dc,cs(((r,t,e,i)=>{let{target:s,ex:n,ey:o,theta:a,originX:l,originY:c}=t;const h=s.translateToOriginPoint(s.getRelativeCenterPoint(),l,c);if(Ee(s,"lockRotation"))return!1;const d=Math.atan2(o-h.y,n-h.x),u=Math.atan2(i-h.y,e-h.x);let p=ei(u-d+a);if(s.snapAngle&&s.snapAngle>0){const f=s.snapAngle,m=s.snapThreshold||f,b=Math.ceil(p/f)*f,_=Math.floor(p/f)*f;Math.abs(p-_)<m?p=_:Math.abs(p-b)<m&&(p=b)}p<0&&(p=360+p),p%=360;const g=s.angle!==p;return s.angle=p,g})));function Bc(r,t){const e=t.canvas,i=r[e.uniScaleKey];return e.uniformScaling&&!i||!e.uniformScaling&&i}function zc(r,t,e){const i=Ee(r,"lockScalingX"),s=Ee(r,"lockScalingY");if(i&&s||!t&&(i||s)&&e||i&&t==="x"||s&&t==="y")return!0;const{width:n,height:o,strokeWidth:a}=r;return n===0&&a===0&&t!=="y"||o===0&&a===0&&t!=="x"}const jg=["e","se","s","sw","w","nw","n","ne","e"],Ts=(r,t,e)=>{const i=Bc(r,e);if(zc(e,t.x!==0&&t.y===0?"x":t.x===0&&t.y!==0?"y":"",i))return Ur;const s=Pc(e,t);return"".concat(jg[s],"-resize")};function Vo(r,t,e,i){let s=arguments.length>4&&arguments[4]!==void 0?arguments[4]:{};const n=t.target,o=s.by,a=Bc(r,n);let l,c,h,d,u,p;if(zc(n,o,a))return!1;if(t.gestureScale)c=t.scaleX*t.gestureScale,h=t.scaleY*t.gestureScale;else{if(l=Bo(t,t.originX,t.originY,e,i),u=o!=="y"?Math.sign(l.x||t.signX||1):1,p=o!=="x"?Math.sign(l.y||t.signY||1):1,t.signX||(t.signX=u),t.signY||(t.signY=p),Ee(n,"lockScalingFlip")&&(t.signX!==u||t.signY!==p))return!1;if(d=n._getTransformedDimensions(),a&&!o){const m=Math.abs(l.x)+Math.abs(l.y),{original:b}=t,_=m/(Math.abs(d.x*b.scaleX/n.scaleX)+Math.abs(d.y*b.scaleY/n.scaleY));c=b.scaleX*_,h=b.scaleY*_}else c=Math.abs(l.x*n.scaleX/d.x),h=Math.abs(l.y*n.scaleY/d.y);Oc(t)&&(c*=2,h*=2),t.signX!==u&&o!=="y"&&(t.originX=Ka(t.originX),c*=-1,t.signX=u),t.signY!==p&&o!=="x"&&(t.originY=Ka(t.originY),h*=-1,t.signY=p)}const g=n.scaleX,f=n.scaleY;return o?(o==="x"&&n.set(oe,c),o==="y"&&n.set(be,h)):(!Ee(n,"lockScalingX")&&n.set(oe,c),!Ee(n,"lockScalingY")&&n.set(be,h)),g!==n.scaleX||f!==n.scaleY}const nr=ls(ln,cs(((r,t,e,i)=>Vo(r,t,e,i)))),$g=ls(ln,cs(((r,t,e,i)=>Vo(r,t,e,i,{by:"x"})))),Rg=ls(ln,cs(((r,t,e,i)=>Vo(r,t,e,i,{by:"y"})))),Bg=["target","ex","ey","skewingSide"],Rn={x:{counterAxis:"y",scale:oe,skew:rs,lockSkewing:"lockSkewingX",origin:"originX",flip:"flipX"},y:{counterAxis:"x",scale:be,skew:ns,lockSkewing:"lockSkewingY",origin:"originY",flip:"flipY"}},zg=["ns","nesw","ew","nwse"],Hg=(r,t,e)=>{if(t.x!==0&&Ee(e,"lockSkewingY")||t.y!==0&&Ee(e,"lockSkewingX"))return Ur;const i=Pc(e,t)%4;return"".concat(zg[i],"-resize")};function Hc(r,t,e,i,s){const{target:n}=e,{counterAxis:o,origin:a,lockSkewing:l,skew:c,flip:h}=Rn[r];if(Ee(n,l))return!1;const{origin:d,flip:u}=Rn[o],p=St(e[d])*(n[u]?-1:1),g=-Math.sign(p)*(n[h]?-1:1),f=.5*-((n[c]===0&&Bo(e,V,V,i,s)[r]>0||n[c]>0?1:-1)*g)+.5;return ls(uc,cs(((b,_,w,S)=>(function(T,k,O){let{target:E,ex:P,ey:R,skewingSide:L}=k,F=rt(k,Bg);const{skew:H}=Rn[T],M=O.subtract(new x(P,R)).divide(new x(E.scaleX,E.scaleY))[T],U=E[H],X=F[H],J=Math.tan(_t(X)),N=T==="y"?E._getTransformedDimensions({scaleX:1,scaleY:1,skewX:0}).x:E._getTransformedDimensions({scaleX:1,scaleY:1}).y,wt=2*M*L/Math.max(N,1)+J,Ut=ei(Math.atan(wt));E.set(H,Ut);const Wt=U!==E[H];if(Wt&&T==="y"){const{skewX:Pe,scaleX:de}=E,Lt=E._getTransformedDimensions({skewY:U}),Ae=E._getTransformedDimensions(),ae=Pe!==0?Lt.x/Ae.x:1;ae!==1&&E.set(oe,ae*de)}return Wt})(r,_,new x(w,S)))))(t,y(y({},e),{},{[a]:f,skewingSide:g}),i,s)}const Vg=(r,t,e,i)=>Hc("x",r,t,e,i),Ng=(r,t,e,i)=>Hc("y",r,t,e,i);function gn(r,t){return r[t.canvas.altActionKey]}const or=(r,t,e)=>{const i=gn(r,e);return t.x===0?i?rs:be:t.y===0?i?ns:oe:""},Xi=(r,t,e)=>gn(r,e)?Hg(0,t,e):Ts(r,t,e),cl=(r,t,e,i)=>gn(r,t.target)?Ng(r,t,e,i):$g(r,t,e,i),hl=(r,t,e,i)=>gn(r,t.target)?Vg(r,t,e,i):Rg(r,t,e,i),Vc=()=>({ml:new _e({x:-.5,y:0,cursorStyleHandler:Xi,actionHandler:cl,getActionName:or}),mr:new _e({x:.5,y:0,cursorStyleHandler:Xi,actionHandler:cl,getActionName:or}),mb:new _e({x:0,y:.5,cursorStyleHandler:Xi,actionHandler:hl,getActionName:or}),mt:new _e({x:0,y:-.5,cursorStyleHandler:Xi,actionHandler:hl,getActionName:or}),tl:new _e({x:-.5,y:-.5,cursorStyleHandler:Ts,actionHandler:nr}),tr:new _e({x:.5,y:-.5,cursorStyleHandler:Ts,actionHandler:nr}),bl:new _e({x:-.5,y:.5,cursorStyleHandler:Ts,actionHandler:nr}),br:new _e({x:.5,y:.5,cursorStyleHandler:Ts,actionHandler:nr}),mtr:new _e({x:0,y:-.5,actionHandler:Fg,cursorStyleHandler:Lg,offsetY:-40,withConnection:!0,actionName:Io})}),Ug=()=>({mr:new _e({x:.5,y:0,actionHandler:ll,cursorStyleHandler:Xi,actionName:Hs}),ml:new _e({x:-.5,y:0,actionHandler:ll,cursorStyleHandler:Xi,actionName:Hs})}),Wg=()=>y(y({},Vc()),Ug());class Ws extends Ue{static getDefaults(){return y(y({},super.getDefaults()),Ws.ownDefaults)}constructor(t){super(),Object.assign(this,this.constructor.createControls(),Ws.ownDefaults),this.setOptions(t)}static createControls(){return{controls:Vc()}}_updateCacheCanvas(){const t=this.canvas;if(this.noScaleCache&&t&&t._currentTransform){const e=t._currentTransform,i=e.target,s=e.action;if(this===i&&s&&s.startsWith(cn))return!1}return super._updateCacheCanvas()}getActiveControl(){const t=this.__corner;return t?{key:t,control:this.controls[t],coord:this.oCoords[t]}:void 0}findControl(t){let e=arguments.length>1&&arguments[1]!==void 0&&arguments[1];if(!this.hasControls||!this.canvas)return;this.__corner=void 0;const i=Object.entries(this.oCoords);for(let s=i.length-1;s>=0;s--){const[n,o]=i[s],a=this.controls[n];if(a.shouldActivate(n,this,t,e?o.touchCorner:o.corner))return this.__corner=n,{key:n,control:a,coord:this.oCoords[n]}}}calcOCoords(){const t=this.getViewportTransform(),e=this.getCenterPoint(),i=Zs(e.x,e.y),s=os({angle:this.getTotalAngle()-(this.group&&this.flipX?180:0)}),n=$t(i,s),o=$t(t,n),a=$t(o,[1/t[0],0,0,1/t[3],0,0]),l=this.group?Vr(this.calcTransformMatrix()):void 0;l&&(l.scaleX=Math.abs(l.scaleX),l.scaleY=Math.abs(l.scaleY));const c=this._calculateCurrentDimensions(l),h={};return this.forEachControl(((d,u)=>{const p=d.positionHandler(c,a,this,d);h[u]=Object.assign(p,this._calcCornerCoords(d,p))})),h}_calcCornerCoords(t,e){const i=this.getTotalAngle();return{corner:t.calcCornerCoords(i,this.cornerSize,e.x,e.y,!1,this),touchCorner:t.calcCornerCoords(i,this.touchCornerSize,e.x,e.y,!0,this)}}setCoords(){super.setCoords(),this.canvas&&(this.oCoords=this.calcOCoords())}forEachControl(t){for(const e in this.controls)t(this.controls[e],e,this)}drawSelectionBackground(t){if(!this.selectionBackgroundColor||this.canvas&&this.canvas._activeObject!==this)return;t.save();const e=this.getRelativeCenterPoint(),i=this._calculateCurrentDimensions(),s=this.getViewportTransform();t.translate(e.x,e.y),t.scale(1/s[0],1/s[3]),t.rotate(_t(this.angle)),t.fillStyle=this.selectionBackgroundColor,t.fillRect(-i.x/2,-i.y/2,i.x,i.y),t.restore()}strokeBorders(t,e){t.strokeRect(-e.x/2,-e.y/2,e.x,e.y)}_drawBorders(t,e){let i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};const s=y({hasControls:this.hasControls,borderColor:this.borderColor,borderDashArray:this.borderDashArray},i);t.save(),t.strokeStyle=s.borderColor,this._setLineDash(t,s.borderDashArray),this.strokeBorders(t,e),s.hasControls&&this.drawControlsConnectingLines(t,e),t.restore()}_renderControls(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};const{hasBorders:i,hasControls:s}=this,n=y({hasBorders:i,hasControls:s},e),o=this.getViewportTransform(),a=n.hasBorders,l=n.hasControls,c=$t(o,this.calcTransformMatrix()),h=Vr(c);t.save(),t.translate(h.translateX,h.translateY),t.lineWidth=this.borderScaleFactor,this.group===this.parent&&(t.globalAlpha=this.isMoving?this.borderOpacityWhenMoving:1),this.flipX&&(h.angle-=180),t.rotate(_t(this.group?h.angle:this.angle)),a&&this.drawBorders(t,h,e),l&&this.drawControls(t,e),t.restore()}drawBorders(t,e,i){let s;if(i&&i.forActiveSelection||this.group){const n=Ro(this.width,this.height,hn(e)),o=this.isStrokeAccountedForInDimensions()?Lo:(this.strokeUniform?new x().scalarAdd(this.canvas?this.canvas.getZoom():1):new x(e.scaleX,e.scaleY)).scalarMultiply(this.strokeWidth);s=n.add(o).scalarAdd(this.borderScaleFactor).scalarAdd(2*this.padding)}else s=this._calculateCurrentDimensions().scalarAdd(this.borderScaleFactor);this._drawBorders(t,s,i)}drawControlsConnectingLines(t,e){let i=!1;t.beginPath(),this.forEachControl(((s,n)=>{s.withConnection&&s.getVisibility(this,n)&&(i=!0,t.moveTo(s.x*e.x,s.y*e.y),t.lineTo(s.x*e.x+s.offsetX,s.y*e.y+s.offsetY))})),i&&t.stroke()}drawControls(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};t.save();const i=this.getCanvasRetinaScaling(),{cornerStrokeColor:s,cornerDashArray:n,cornerColor:o}=this,a=y({cornerStrokeColor:s,cornerDashArray:n,cornerColor:o},e);t.setTransform(i,0,0,i,0,0),t.strokeStyle=t.fillStyle=a.cornerColor,this.transparentCorners||(t.strokeStyle=a.cornerStrokeColor),this._setLineDash(t,a.cornerDashArray),this.forEachControl(((l,c)=>{if(l.getVisibility(this,c)){const h=this.oCoords[c];l.render(t,h.x,h.y,a,this)}})),t.restore()}isControlVisible(t){return this.controls[t]&&this.controls[t].getVisibility(this,t)}setControlVisible(t,e){this._controlsVisibility||(this._controlsVisibility={}),this._controlsVisibility[t]=e}setControlsVisibility(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};Object.entries(t).forEach((e=>{let[i,s]=e;return this.setControlVisible(i,s)}))}clearContextTop(t){if(!this.canvas)return;const e=this.canvas.contextTop;if(!e)return;const i=this.canvas.viewportTransform;e.save(),e.transform(i[0],i[1],i[2],i[3],i[4],i[5]),this.transform(e);const s=this.width+4,n=this.height+4;return e.clearRect(-s/2,-n/2,s,n),t||e.restore(),e}onDeselect(t){return!1}onSelect(t){return!1}shouldStartDragging(t){return!1}onDragStart(t){return!1}canDrop(t){return!1}renderDragSourceEffect(t){}renderDropTargetEffect(t){}}function Nc(r,t){return t.forEach((e=>{Object.getOwnPropertyNames(e.prototype).forEach((i=>{i!=="constructor"&&Object.defineProperty(r.prototype,i,Object.getOwnPropertyDescriptor(e.prototype,i)||Object.create(null))}))})),r}v(Ws,"ownDefaults",{noScaleCache:!0,lockMovementX:!1,lockMovementY:!1,lockRotation:!1,lockScalingX:!1,lockScalingY:!1,lockSkewingX:!1,lockSkewingY:!1,lockScalingFlip:!1,cornerSize:13,touchCornerSize:24,transparentCorners:!0,cornerColor:"rgb(178,204,255)",cornerStrokeColor:"",cornerStyle:"rect",cornerDashArray:null,hasControls:!0,borderColor:"rgb(178,204,255)",borderDashArray:null,borderOpacityWhenMoving:.4,borderScaleFactor:1,hasBorders:!0,selectionBackgroundColor:"",selectable:!0,evented:!0,perPixelTargetFind:!1,activeOn:"down",hoverCursor:null,moveCursor:null});class Ht extends Ws{}Nc(Ht,[Ac]),A.setClass(Ht),A.setClass(Ht,"object");const Yg=(r,t,e,i)=>{const s=2*(i=Math.round(i))+1,{data:n}=r.getImageData(t-i,e-i,s,s);for(let o=3;o<n.length;o+=4)if(n[o]>0)return!1;return!0};class Uc{constructor(t){this.options=t,this.strokeProjectionMagnitude=this.options.strokeWidth/2,this.scale=new x(this.options.scaleX,this.options.scaleY),this.strokeUniformScalar=this.options.strokeUniform?new x(1/this.options.scaleX,1/this.options.scaleY):new x(1,1)}createSideVector(t,e){const i=ao(t,e);return this.options.strokeUniform?i.multiply(this.scale):i}projectOrthogonally(t,e,i){return this.applySkew(t.add(this.calcOrthogonalProjection(t,e,i)))}isSkewed(){return this.options.skewX!==0||this.options.skewY!==0}applySkew(t){const e=new x(t);return e.y+=e.x*Math.tan(_t(this.options.skewY)),e.x+=e.y*Math.tan(_t(this.options.skewX)),e}scaleUnitVector(t,e){return t.multiply(this.strokeUniformScalar).scalarMultiply(e)}}const Gg=new x;class Qi extends Uc{static getOrthogonalRotationFactor(t,e){const i=e?co(t,e):fg(t);return Math.abs(i)<Ks?-1:1}constructor(t,e,i,s){super(s),v(this,"AB",void 0),v(this,"AC",void 0),v(this,"alpha",void 0),v(this,"bisector",void 0),this.A=new x(t),this.B=new x(e),this.C=new x(i),this.AB=this.createSideVector(this.A,this.B),this.AC=this.createSideVector(this.A,this.C),this.alpha=co(this.AB,this.AC),this.bisector=zo(jc(this.AB.eq(Gg)?this.AC:this.AB,this.alpha/2))}calcOrthogonalProjection(t,e){let i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:this.strokeProjectionMagnitude;const s=this.createSideVector(t,e),n=$c(s),o=Qi.getOrthogonalRotationFactor(n,this.bisector);return this.scaleUnitVector(n,i*o)}projectBevel(){const t=[];return(this.alpha%Rr==0?[this.B]:[this.B,this.C]).forEach((e=>{t.push(this.projectOrthogonally(this.A,e)),t.push(this.projectOrthogonally(this.A,e,-this.strokeProjectionMagnitude))})),t}projectMiter(){const t=[],e=Math.abs(this.alpha),i=1/Math.sin(e/2),s=this.scaleUnitVector(this.bisector,-this.strokeProjectionMagnitude*i),n=this.options.strokeUniform?lo(this.scaleUnitVector(this.bisector,this.options.strokeMiterLimit)):this.options.strokeMiterLimit;return lo(s)/this.strokeProjectionMagnitude<=n&&t.push(this.applySkew(this.A.add(s))),t.push(...this.projectBevel()),t}projectRoundNoSkew(t,e){const i=[],s=new x(Qi.getOrthogonalRotationFactor(this.bisector),Qi.getOrthogonalRotationFactor(new x(this.bisector.y,this.bisector.x)));return[new x(1,0).scalarMultiply(this.strokeProjectionMagnitude).multiply(this.strokeUniformScalar).multiply(s),new x(0,1).scalarMultiply(this.strokeProjectionMagnitude).multiply(this.strokeUniformScalar).multiply(s)].forEach((n=>{nl(n,t,e)&&i.push(this.A.add(n))})),i}projectRoundWithSkew(t,e){const i=[],{skewX:s,skewY:n,scaleX:o,scaleY:a,strokeUniform:l}=this.options,c=new x(Math.tan(_t(s)),Math.tan(_t(n))),h=this.strokeProjectionMagnitude,d=l?h/a/Math.sqrt(1/a**2+1/o**2*c.y**2):h/Math.sqrt(1+c.y**2),u=new x(Math.sqrt(Math.max(h**2-d**2,0)),d),p=l?h/Math.sqrt(1+c.x**2*(1/a)**2/(1/o+1/o*c.x*c.y)**2):h/Math.sqrt(1+c.x**2/(1+c.x*c.y)**2),g=new x(p,Math.sqrt(Math.max(h**2-p**2,0)));return[g,g.scalarMultiply(-1),u,u.scalarMultiply(-1)].map((f=>this.applySkew(l?f.multiply(this.strokeUniformScalar):f))).forEach((f=>{nl(f,t,e)&&i.push(this.applySkew(this.A).add(f))})),i}projectRound(){const t=[];t.push(...this.projectBevel());const e=this.alpha%Rr==0,i=this.applySkew(this.A),s=t[e?0:2].subtract(i),n=t[e?1:0].subtract(i),o=e?this.applySkew(this.AB.scalarMultiply(-1)):this.applySkew(this.bisector.multiply(this.strokeUniformScalar).scalarMultiply(-1)),a=Ls(s,o)>0,l=a?s:n,c=a?n:s;return this.isSkewed()?t.push(...this.projectRoundWithSkew(l,c)):t.push(...this.projectRoundNoSkew(l,c)),t}projectPoints(){switch(this.options.strokeLineJoin){case"miter":return this.projectMiter();case"round":return this.projectRound();default:return this.projectBevel()}}project(){return this.projectPoints().map((t=>({originPoint:this.A,projectedPoint:t,angle:this.alpha,bisector:this.bisector})))}}class dl extends Uc{constructor(t,e,i){super(i),this.A=new x(t),this.T=new x(e)}calcOrthogonalProjection(t,e){let i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:this.strokeProjectionMagnitude;const s=this.createSideVector(t,e);return this.scaleUnitVector($c(s),i)}projectButt(){return[this.projectOrthogonally(this.A,this.T,this.strokeProjectionMagnitude),this.projectOrthogonally(this.A,this.T,-this.strokeProjectionMagnitude)]}projectRound(){const t=[];if(!this.isSkewed()&&this.A.eq(this.T)){const e=new x(1,1).scalarMultiply(this.strokeProjectionMagnitude).multiply(this.strokeUniformScalar);t.push(this.applySkew(this.A.add(e)),this.applySkew(this.A.subtract(e)))}else t.push(...new Qi(this.A,this.T,this.T,this.options).projectRound());return t}projectSquare(){const t=[];if(this.A.eq(this.T)){const e=new x(1,1).scalarMultiply(this.strokeProjectionMagnitude).multiply(this.strokeUniformScalar);t.push(this.A.add(e),this.A.subtract(e))}else{const e=this.calcOrthogonalProjection(this.A,this.T,this.strokeProjectionMagnitude),i=this.scaleUnitVector(zo(this.createSideVector(this.A,this.T)),-this.strokeProjectionMagnitude),s=this.A.add(i);t.push(s.add(e),s.subtract(e))}return t.map((e=>this.applySkew(e)))}projectPoints(){switch(this.options.strokeLineCap){case"round":return this.projectRound();case"square":return this.projectSquare();default:return this.projectButt()}}project(){return this.projectPoints().map((t=>({originPoint:this.A,projectedPoint:t})))}}const Xg=function(r,t){let e=arguments.length>2&&arguments[2]!==void 0&&arguments[2];const i=[];if(r.length===0)return i;const s=r.reduce(((n,o)=>(n[n.length-1].eq(o)||n.push(new x(o)),n)),[new x(r[0])]);if(s.length===1)e=!0;else if(!e){const n=s[0],o=((a,l)=>{for(let c=a.length-1;c>=0;c--)if(l(a[c],c,a))return c;return-1})(s,(a=>!a.eq(n)));s.splice(o+1)}return s.forEach(((n,o,a)=>{let l,c;o===0?(c=a[1],l=e?n:a[a.length-1]):o===a.length-1?(l=a[o-1],c=e?n:a[0]):(l=a[o-1],c=a[o+1]),e&&a.length===1?i.push(...new dl(n,n,t).project()):!e||o!==0&&o!==a.length-1?i.push(...new Qi(n,l,c,t).project()):i.push(...new dl(n,o===0?c:l,t).project())})),i},No=r=>{const t={};return Object.keys(r).forEach((e=>{t[e]={},Object.keys(r[e]).forEach((i=>{t[e][i]=y({},r[e][i])}))})),t},qg=r=>r.replace(/&/g,"&").replace(/"/g,""").replace(/'/g,"'").replace(/</g,"<").replace(/>/g,">");let _s;const Uo=r=>{if(_s||_s||(_s="Intl"in an()&&"Segmenter"in Intl&&new Intl.Segmenter(void 0,{granularity:"grapheme"})),_s){const t=_s.segment(r);return Array.from(t).map((e=>{let{segment:i}=e;return i}))}return Kg(r)},Kg=r=>{const t=[];for(let e,i=0;i<r.length;i++)(e=Zg(r,i))!==!1&&t.push(e);return t},Zg=(r,t)=>{const e=r.charCodeAt(t);if(isNaN(e))return"";if(e<55296||e>57343)return r.charAt(t);if(55296<=e&&e<=56319){if(r.length<=t+1)throw"High surrogate without following low surrogate";const s=r.charCodeAt(t+1);if(56320>s||s>57343)throw"High surrogate without following low surrogate";return r.charAt(t)+r.charAt(t+1)}if(t===0)throw"Low surrogate without preceding high surrogate";const i=r.charCodeAt(t-1);if(55296>i||i>56319)throw"Low surrogate without preceding high surrogate";return!1},Wo=function(r,t){let e=arguments.length>2&&arguments[2]!==void 0&&arguments[2];return r.fill!==t.fill||r.stroke!==t.stroke||r.strokeWidth!==t.strokeWidth||r.fontSize!==t.fontSize||r.fontFamily!==t.fontFamily||r.fontWeight!==t.fontWeight||r.fontStyle!==t.fontStyle||r.textDecorationThickness!==t.textDecorationThickness||r.textBackgroundColor!==t.textBackgroundColor||r.deltaY!==t.deltaY||e&&(r.overline!==t.overline||r.underline!==t.underline||r.linethrough!==t.linethrough)},Jg=(r,t)=>{const e=t.split(`
|
|
2357
|
+
`),i=[];let s=-1,n={};r=No(r);for(let o=0;o<e.length;o++){const a=Uo(e[o]);if(r[o])for(let l=0;l<a.length;l++){s++;const c=r[o][l];c&&Object.keys(c).length>0&&(Wo(n,c,!0)?i.push({start:s,end:s+1,style:c}):i[i.length-1].end++),n=c||{}}else s+=a.length,n={}}return i},Qg=(r,t)=>{if(!Array.isArray(r))return No(r);const e=t.split(Mo),i={};let s=-1,n=0;for(let o=0;o<e.length;o++){const a=Uo(e[o]);for(let l=0;l<a.length;l++)s++,r[n]&&r[n].start<=s&&s<r[n].end&&(i[o]=i[o]||{},i[o][l]=y({},r[n].style),s===r[n].end-1&&n++)}return i},yi=["display","transform",Dt,"fill-opacity","fill-rule","opacity",re,"stroke-dasharray","stroke-linecap","stroke-dashoffset","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","id","paint-order","vector-effect","instantiated_by_use","clip-path"];function ul(r,t){const e=r.nodeName,i=r.getAttribute("class"),s=r.getAttribute("id"),n="(?![a-zA-Z\\-]+)";let o;if(o=new RegExp("^"+e,"i"),t=t.replace(o,""),s&&t.length&&(o=new RegExp("#"+s+n,"i"),t=t.replace(o,"")),i&&t.length){const a=i.split(" ");for(let l=a.length;l--;)o=new RegExp("\\."+a[l]+n,"i"),t=t.replace(o,"")}return t.length===0}function tf(r,t){let e=!0;const i=ul(r,t.pop());return i&&t.length&&(e=(function(s,n){let o,a=!0;for(;s.parentElement&&s.parentElement.nodeType===1&&n.length;)a&&(o=n.pop()),a=ul(s=s.parentElement,o);return n.length===0})(r,t)),i&&e&&t.length===0}const ef=r=>{var t;return(t=pg[r])!==null&&t!==void 0?t:r},sf=new RegExp("(".concat(Se,")"),"gi"),rf=r=>Wr(r.replace(sf," $1 ").replace(/,/gi," "));var pl,gl,fl,ml,bl,vl,yl;const Xt="(".concat(Se,")"),nf=String.raw(pl||(pl=He(["(skewX)(",")"],["(skewX)\\(","\\)"])),Xt),of=String.raw(gl||(gl=He(["(skewY)(",")"],["(skewY)\\(","\\)"])),Xt),af=String.raw(fl||(fl=He(["(rotate)(","(?: "," ",")?)"],["(rotate)\\(","(?: "," ",")?\\)"])),Xt,Xt,Xt),lf=String.raw(ml||(ml=He(["(scale)(","(?: ",")?)"],["(scale)\\(","(?: ",")?\\)"])),Xt,Xt),cf=String.raw(bl||(bl=He(["(translate)(","(?: ",")?)"],["(translate)\\(","(?: ",")?\\)"])),Xt,Xt),hf=String.raw(vl||(vl=He(["(matrix)("," "," "," "," "," ",")"],["(matrix)\\("," "," "," "," "," ","\\)"])),Xt,Xt,Xt,Xt,Xt,Xt),Yo="(?:".concat(hf,"|").concat(cf,"|").concat(af,"|").concat(lf,"|").concat(nf,"|").concat(of,")"),df="(?:".concat(Yo,"*)"),uf=String.raw(yl||(yl=He(["^s*(?:","?)s*$"],["^\\s*(?:","?)\\s*$"])),df),pf=new RegExp(uf),gf=new RegExp(Yo),ff=new RegExp(Yo,"g");function ho(r){const t=[];if(!(r=rf(r).replace(/\s*([()])\s*/gi,"$1"))||r&&!pf.test(r))return[...Kt];for(const e of r.matchAll(ff)){const i=gf.exec(e[0]);if(!i)continue;let s=Kt;const n=i.filter((g=>!!g)),[,o,...a]=n,[l,c,h,d,u,p]=a.map((g=>parseFloat(g)));switch(o){case"translate":s=Zs(l,c);break;case Io:s=os({angle:l},{x:c,y:h});break;case cn:s=jo(l,c);break;case rs:s=yc(l);break;case ns:s=_c(l);break;case"matrix":s=[l,c,h,d,u,p]}t.push(s)}return Fo(t)}function mf(r,t,e,i){const s=Array.isArray(t);let n,o=t;if(r!==Dt&&r!==re||t!==se){if(r==="strokeUniform")return t==="non-scaling-stroke";if(r==="strokeDashArray")o=t===se?null:t.replace(/,/g," ").split(/\s+/).map(parseFloat);else if(r==="transformMatrix")o=e&&e.transformMatrix?$t(e.transformMatrix,ho(t)):ho(t);else if(r==="visible")o=t!==se&&t!=="hidden",e&&e.visible===!1&&(o=!1);else if(r==="opacity")o=parseFloat(t),e&&e.opacity!==void 0&&(o*=e.opacity);else if(r==="textAnchor")o=t==="start"?Y:t==="end"?yt:V;else if(r==="charSpacing"||r===Ri)n=Ji(t,i)/i*1e3;else if(r==="paintFirst"){const a=t.indexOf(Dt),l=t.indexOf(re);o=Dt,(a>-1&&l>-1&&l<a||a===-1&&l>-1)&&(o=re)}else{if(r==="href"||r==="xlink:href"||r==="font"||r==="id")return t;if(r==="imageSmoothing")return t==="optimizeQuality";n=s?t.map(Ji):Ji(t,i)}}else o="";return!s&&isNaN(n)?o:n}function bf(r,t){const e=r.match(ug);if(!e)return;const i=e[1],s=e[3],n=e[4],o=e[5],a=e[6];i&&(t.fontStyle=i),s&&(t.fontWeight=isNaN(parseFloat(s))?s:parseFloat(s)),n&&(t.fontSize=Ji(n)),a&&(t.fontFamily=a),o&&(t.lineHeight=o==="normal"?1:o)}function vf(r,t){r.replace(/;\s*$/,"").split(";").forEach((e=>{if(!e)return;const[i,s]=e.split(":");t[i.trim().toLowerCase()]=s.trim()}))}function yf(r){const t={},e=r.getAttribute("style");return e&&(typeof e=="string"?vf(e,t):(function(i,s){Object.entries(i).forEach((n=>{let[o,a]=n;a!==void 0&&(s[o.toLowerCase()]=a)}))})(e,t)),t}const _f={stroke:"strokeOpacity",fill:"fillOpacity"};function ni(r,t,e){if(!r)return{};let i,s={},n=Do;r.parentNode&&rl.test(r.parentNode.nodeName)&&(s=ni(r.parentElement,t,e),s.fontSize&&(i=n=Ji(s.fontSize)));const o=y(y(y({},t.reduce(((c,h)=>{const d=r.getAttribute(h);return d&&(c[h]=d),c}),{})),(function(c){let h=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},d={};for(const u in h)tf(c,u.split(" "))&&(d=y(y({},d),h[u]));return d})(r,e)),yf(r));o[jn]&&r.setAttribute(jn,o[jn]),o[Fn]&&(i=Ji(o[Fn],n),o[Fn]="".concat(i));const a={};for(const c in o){const h=ef(c),d=mf(h,o[c],s,i);a[h]=d}a&&a.font&&bf(a.font,a);const l=y(y({},s),a);return rl.test(r.nodeName)?l:(function(c){const h=Ht.getDefaults();return Object.entries(_f).forEach((d=>{let[u,p]=d;if(c[p]===void 0||c[u]==="")return;if(c[u]===void 0){if(!h[u])return;c[u]=h[u]}if(c[u].indexOf("url(")===0)return;const g=new q(c[u]);c[u]=g.setAlpha(tt(g.getAlpha()*c[p],2)).toRgba()})),c})(l)}const xf=["left","top","width","height","visible"],Wc=["rx","ry"];class ee extends Ht{static getDefaults(){return y(y({},super.getDefaults()),ee.ownDefaults)}constructor(t){super(),Object.assign(this,ee.ownDefaults),this.setOptions(t),this._initRxRy()}_initRxRy(){const{rx:t,ry:e}=this;t&&!e?this.ry=t:e&&!t&&(this.rx=e)}_render(t){const{width:e,height:i}=this,s=-e/2,n=-i/2,o=this.rx?Math.min(this.rx,e/2):0,a=this.ry?Math.min(this.ry,i/2):0,l=o!==0||a!==0;t.beginPath(),t.moveTo(s+o,n),t.lineTo(s+e-o,n),l&&t.bezierCurveTo(s+e-ai*o,n,s+e,n+ai*a,s+e,n+a),t.lineTo(s+e,n+i-a),l&&t.bezierCurveTo(s+e,n+i-ai*a,s+e-ai*o,n+i,s+e-o,n+i),t.lineTo(s+o,n+i),l&&t.bezierCurveTo(s+ai*o,n+i,s,n+i-ai*a,s,n+i-a),t.lineTo(s,n+a),l&&t.bezierCurveTo(s,n+ai*a,s+ai*o,n,s+o,n),t.closePath(),this._renderPaintInOrder(t)}toObject(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[];return super.toObject([...Wc,...t])}_toSVG(){const{width:t,height:e,rx:i,ry:s}=this;return["<rect ","COMMON_PARTS",'x="'.concat(-t/2,'" y="').concat(-e/2,'" rx="').concat(i,'" ry="').concat(s,'" width="').concat(t,'" height="').concat(e,`" />
|
|
2358
|
+
`)]}static async fromElement(t,e,i){const s=ni(t,this.ATTRIBUTE_NAMES,i),{left:n=0,top:o=0,width:a=0,height:l=0,visible:c=!0}=s,h=rt(s,xf);return new this(y(y(y({},e),h),{},{left:n,top:o,width:a,height:l,visible:!!(c&&a&&l)}))}}v(ee,"type","Rect"),v(ee,"cacheProperties",[...ri,...Wc]),v(ee,"ownDefaults",{rx:0,ry:0}),v(ee,"ATTRIBUTE_NAMES",[...yi,"x","y","rx","ry","width","height"]),A.setClass(ee),A.setSVGClass(ee);const Ge="initialization",Gr="added",Go="removed",Xr="imperative",Yc=(r,t)=>{const{strokeUniform:e,strokeWidth:i,width:s,height:n,group:o}=t,a=o&&o!==r?un(o.calcTransformMatrix(),r.calcTransformMatrix()):null,l=a?t.getRelativeCenterPoint().transform(a):t.getRelativeCenterPoint(),c=!t.isStrokeAccountedForInDimensions(),h=e&&c?ng(new x(i,i),void 0,r.calcTransformMatrix()):Lo,d=!e&&c?i:0,u=Ro(s+d,n+d,Fo([a,t.calcOwnMatrix()],!0)).add(h).scalarDivide(2);return[l.subtract(u),l.add(u)]};class fn{calcLayoutResult(t,e){if(this.shouldPerformLayout(t))return this.calcBoundingBox(e,t)}shouldPerformLayout(t){let{type:e,prevStrategy:i,strategy:s}=t;return e===Ge||e===Xr||!!i&&s!==i}shouldLayoutClipPath(t){let{type:e,target:{clipPath:i}}=t;return e!==Ge&&i&&!i.absolutePositioned}getInitialSize(t,e){return e.size}calcBoundingBox(t,e){const{type:i,target:s}=e;if(i===Xr&&e.overrides)return e.overrides;if(t.length===0)return;const{left:n,top:o,width:a,height:l}=qe(t.map((d=>Yc(s,d))).reduce(((d,u)=>d.concat(u)),[])),c=new x(a,l),h=new x(n,o).add(c.scalarDivide(2));if(i===Ge){const d=this.getInitialSize(e,{size:c,center:h});return{center:h,relativeCorrection:new x(0,0),size:d}}return{center:h.transform(s.calcOwnMatrix()),size:c}}}v(fn,"type","strategy");class uo extends fn{shouldPerformLayout(t){return!0}}v(uo,"type","fit-content"),A.setClass(uo);const wf=["strategy"],Cf=["target","strategy","bubbles","prevStrategy"],Gc="layoutManager";class Ys{constructor(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:new uo;v(this,"strategy",void 0),this.strategy=t,this._subscriptions=new Map}performLayout(t){const e=y(y({bubbles:!0,strategy:this.strategy},t),{},{prevStrategy:this._prevLayoutStrategy,stopPropagation(){this.bubbles=!1}});this.onBeforeLayout(e);const i=this.getLayoutResult(e);i&&this.commitLayout(e,i),this.onAfterLayout(e,i),this._prevLayoutStrategy=e.strategy}attachHandlers(t,e){const{target:i}=e;return[zr,hc,Hs,dc,ln,uc,Br,Up,Wp].map((s=>t.on(s,(n=>this.performLayout(s===zr?{type:"object_modified",trigger:s,e:n,target:i}:{type:"object_modifying",trigger:s,e:n,target:i})))))}subscribe(t,e){this.unsubscribe(t,e);const i=this.attachHandlers(t,e);this._subscriptions.set(t,i)}unsubscribe(t,e){(this._subscriptions.get(t)||[]).forEach((i=>i())),this._subscriptions.delete(t)}unsubscribeTargets(t){t.targets.forEach((e=>this.unsubscribe(e,t)))}subscribeTargets(t){t.targets.forEach((e=>this.subscribe(e,t)))}onBeforeLayout(t){const{target:e,type:i}=t,{canvas:s}=e;if(i===Ge||i===Gr?this.subscribeTargets(t):i===Go&&this.unsubscribeTargets(t),e.fire("layout:before",{context:t}),s&&s.fire("object:layout:before",{target:e,context:t}),i===Xr&&t.deep){const n=rt(t,wf);e.forEachObject((o=>o.layoutManager&&o.layoutManager.performLayout(y(y({},n),{},{bubbles:!1,target:o}))))}}getLayoutResult(t){const{target:e,strategy:i,type:s}=t,n=i.calcLayoutResult(t,e.getObjects());if(!n)return;const o=s===Ge?new x:e.getRelativeCenterPoint(),{center:a,correction:l=new x,relativeCorrection:c=new x}=n,h=o.subtract(a).add(l).transform(s===Ge?Kt:Ce(e.calcOwnMatrix()),!0).add(c);return{result:n,prevCenter:o,nextCenter:a,offset:h}}commitLayout(t,e){const{target:i}=t,{result:{size:s},nextCenter:n}=e;var o,a;i.set({width:s.x,height:s.y}),this.layoutObjects(t,e),t.type===Ge?i.set({left:(o=t.x)!==null&&o!==void 0?o:n.x+s.x*St(i.originX),top:(a=t.y)!==null&&a!==void 0?a:n.y+s.y*St(i.originY)}):(i.setPositionByOrigin(n,V,V),i.setCoords(),i.set("dirty",!0))}layoutObjects(t,e){const{target:i}=t;i.forEachObject((s=>{s.group===i&&this.layoutObject(t,e,s)})),t.strategy.shouldLayoutClipPath(t)&&this.layoutObject(t,e,i.clipPath)}layoutObject(t,e,i){let{offset:s}=e;i.set({left:i.left+s.x,top:i.top+s.y})}onAfterLayout(t,e){const{target:i,strategy:s,bubbles:n,prevStrategy:o}=t,a=rt(t,Cf),{canvas:l}=i;i.fire("layout:after",{context:t,result:e}),l&&l.fire("object:layout:after",{context:t,result:e,target:i});const c=i.parent;n&&c!=null&&c.layoutManager&&((a.path||(a.path=[])).push(i),c.layoutManager.performLayout(y(y({},a),{},{target:c}))),i.set("dirty",!0)}dispose(){const{_subscriptions:t}=this;t.forEach((e=>e.forEach((i=>i())))),t.clear()}toObject(){return{type:Gc,strategy:this.strategy.constructor.type}}toJSON(){return this.toObject()}}A.setClass(Ys,Gc);const Sf=["type","objects","layoutManager"];class Tf extends Ys{performLayout(){}}class gi extends pc(Ht){static getDefaults(){return y(y({},super.getDefaults()),gi.ownDefaults)}constructor(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};super(),v(this,"_activeObjects",[]),v(this,"__objectSelectionTracker",void 0),v(this,"__objectSelectionDisposer",void 0),Object.assign(this,gi.ownDefaults),this.setOptions(e),this.groupInit(t,e)}groupInit(t,e){var i;this._objects=[...t],this.__objectSelectionTracker=this.__objectSelectionMonitor.bind(this,!0),this.__objectSelectionDisposer=this.__objectSelectionMonitor.bind(this,!1),this.forEachObject((s=>{this.enterGroup(s,!1)})),this.layoutManager=(i=e.layoutManager)!==null&&i!==void 0?i:new Ys,this.layoutManager.performLayout({type:Ge,target:this,targets:[...t],x:e.left,y:e.top})}canEnterGroup(t){return t===this||this.isDescendantOf(t)?(fi("error","Group: circular object trees are not supported, this call has no effect"),!1):this._objects.indexOf(t)===-1||(fi("error","Group: duplicate objects are not supported inside group, this call has no effect"),!1)}_filterObjectsBeforeEnteringGroup(t){return t.filter(((e,i,s)=>this.canEnterGroup(e)&&s.indexOf(e)===i))}add(){for(var t=arguments.length,e=new Array(t),i=0;i<t;i++)e[i]=arguments[i];const s=this._filterObjectsBeforeEnteringGroup(e),n=super.add(...s);return this._onAfterObjectsChange(Gr,s),n}insertAt(t){for(var e=arguments.length,i=new Array(e>1?e-1:0),s=1;s<e;s++)i[s-1]=arguments[s];const n=this._filterObjectsBeforeEnteringGroup(i),o=super.insertAt(t,...n);return this._onAfterObjectsChange(Gr,n),o}remove(){const t=super.remove(...arguments);return this._onAfterObjectsChange(Go,t),t}_onObjectAdded(t){this.enterGroup(t,!0),this.fire("object:added",{target:t}),t.fire("added",{target:this})}_onObjectRemoved(t,e){this.exitGroup(t,e),this.fire("object:removed",{target:t}),t.fire("removed",{target:this})}_onAfterObjectsChange(t,e){this.layoutManager.performLayout({type:t,targets:e,target:this})}_onStackOrderChanged(){this._set("dirty",!0)}_set(t,e){const i=this[t];return super._set(t,e),t==="canvas"&&i!==e&&(this._objects||[]).forEach((s=>{s._set(t,e)})),this}_shouldSetNestedCoords(){return this.subTargetCheck}removeAll(){return this._activeObjects=[],this.remove(...this._objects)}__objectSelectionMonitor(t,e){let{target:i}=e;const s=this._activeObjects;if(t)s.push(i),this._set("dirty",!0);else if(s.length>0){const n=s.indexOf(i);n>-1&&(s.splice(n,1),this._set("dirty",!0))}}_watchObject(t,e){t&&this._watchObject(!1,e),t?(e.on("selected",this.__objectSelectionTracker),e.on("deselected",this.__objectSelectionDisposer)):(e.off("selected",this.__objectSelectionTracker),e.off("deselected",this.__objectSelectionDisposer))}enterGroup(t,e){t.group&&t.group.remove(t),t._set("parent",this),this._enterGroup(t,e)}_enterGroup(t,e){e&&Nr(t,$t(Ce(this.calcTransformMatrix()),t.calcTransformMatrix())),this._shouldSetNestedCoords()&&t.setCoords(),t._set("group",this),t._set("canvas",this.canvas),this._watchObject(!0,t);const i=this.canvas&&this.canvas.getActiveObject&&this.canvas.getActiveObject();i&&(i===t||t.isDescendantOf(i))&&this._activeObjects.push(t)}exitGroup(t,e){this._exitGroup(t,e),t._set("parent",void 0),t._set("canvas",void 0)}_exitGroup(t,e){t._set("group",void 0),e||(Nr(t,$t(this.calcTransformMatrix(),t.calcTransformMatrix())),t.setCoords()),this._watchObject(!1,t);const i=this._activeObjects.length>0?this._activeObjects.indexOf(t):-1;i>-1&&this._activeObjects.splice(i,1)}shouldCache(){const t=Ht.prototype.shouldCache.call(this);if(t){for(let e=0;e<this._objects.length;e++)if(this._objects[e].willDrawShadow())return this.ownCaching=!1,!1}return t}willDrawShadow(){if(super.willDrawShadow())return!0;for(let t=0;t<this._objects.length;t++)if(this._objects[t].willDrawShadow())return!0;return!1}isOnACache(){return this.ownCaching||!!this.parent&&this.parent.isOnACache()}drawObject(t,e,i){this._renderBackground(t);for(let n=0;n<this._objects.length;n++){var s;const o=this._objects[n];(s=this.canvas)!==null&&s!==void 0&&s.preserveObjectStacking&&o.group!==this?(t.save(),t.transform(...Ce(this.calcTransformMatrix())),o.render(t),t.restore()):o.group===this&&o.render(t)}this._drawClipPath(t,this.clipPath,i)}setCoords(){super.setCoords(),this._shouldSetNestedCoords()&&this.forEachObject((t=>t.setCoords()))}triggerLayout(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};this.layoutManager.performLayout(y({target:this,type:Xr},t))}render(t){this._transformDone=!0,super.render(t),this._transformDone=!1}__serializeObjects(t,e){const i=this.includeDefaultValues;return this._objects.filter((function(s){return!s.excludeFromExport})).map((function(s){const n=s.includeDefaultValues;s.includeDefaultValues=i;const o=s[t||"toObject"](e);return s.includeDefaultValues=n,o}))}toObject(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[];const e=this.layoutManager.toObject();return y(y(y({},super.toObject(["subTargetCheck","interactive",...t])),e.strategy!=="fit-content"||this.includeDefaultValues?{layoutManager:e}:{}),{},{objects:this.__serializeObjects("toObject",t)})}toString(){return"#<Group: (".concat(this.complexity(),")>")}dispose(){this.layoutManager.unsubscribeTargets({targets:this.getObjects(),target:this}),this._activeObjects=[],this.forEachObject((t=>{this._watchObject(!1,t),t.dispose()})),super.dispose()}_createSVGBgRect(t){if(!this.backgroundColor)return"";const e=ee.prototype._toSVG.call(this),i=e.indexOf("COMMON_PARTS");e[i]='for="group" ';const s=e.join("");return t?t(s):s}_toSVG(t){const e=["<g ","COMMON_PARTS",` >
|
|
2359
2359
|
`],i=this._createSVGBgRect(t);i&&e.push(" ",i);for(let s=0;s<this._objects.length;s++)e.push(" ",this._objects[s].toSVG(t));return e.push(`</g>
|
|
2360
|
-
`),e}getSvgStyles(){const t=this.opacity!==void 0&&this.opacity!==1?"opacity: ".concat(this.opacity,";"):"",e=this.visible?"":" visibility: hidden;";return[t,this.getSvgFilter(),e].join("")}toClipPathSVG(t){const e=[],i=this._createSVGBgRect(t);i&&e.push(" ",i);for(let s=0;s<this._objects.length;s++)e.push(" ",this._objects[s].toClipPathSVG(t));return this._createBaseClipPathSVGMarkup(e,{reviver:t})}static fromObject(t,e){let{type:i,objects:s=[],layoutManager:n}=t,o=rt(t,Sf);return Promise.all([Vs(s,e),dn(o,e)]).then((a=>{let[l,c]=a;const h=new this(l,y(y(y({},o),c),{},{layoutManager:new Tf}));if(n){const d=A.getClass(n.type),u=A.getClass(n.strategy);h.layoutManager=new d(new u)}else h.layoutManager=new Ys;return h.layoutManager.subscribeTargets({type:Ge,target:h,targets:h.getObjects()}),h.setCoords(),h}))}}v(fi,"type","Group"),v(fi,"ownDefaults",{strokeWidth:0,subTargetCheck:!1,interactive:!1}),A.setClass(fi);const Ef=(r,t)=>Math.min(t.width/r.width,t.height/r.height),Of=(r,t)=>Math.max(t.width/r.width,t.height/r.height),po="\\s*,?\\s*",xs="".concat(po,"(").concat(Se,")"),kf="".concat(xs).concat(xs).concat(xs).concat(po,"([01])").concat(po,"([01])").concat(xs).concat(xs),Pf={m:"l",M:"L"},Af=(r,t,e,i,s,n,o,a,l,c,h)=>{const d=Je(r),u=Qe(r),p=Je(t),g=Qe(t),f=e*s*p-i*n*g+o,m=i*s*p+e*n*g+a;return["C",c+l*(-e*s*u-i*n*d),h+l*(-i*s*u+e*n*d),f+l*(e*s*g+i*n*p),m+l*(i*s*g-e*n*p),f,m]},_l=(r,t,e,i)=>{const s=Math.atan2(t,r),n=Math.atan2(i,e);return n>=s?n-s:2*Math.PI-(s-n)};function xl(r,t,e,i,s,n,o,a){let l;if(W.cachesBoundsOfCurve&&(l=[...arguments].join(),Ds.boundsOfCurveCache[l]))return Ds.boundsOfCurveCache[l];const c=Math.sqrt,h=Math.abs,d=[],u=[[0,0],[0,0]];let p=6*r-12*e+6*s,g=-3*r+9*e-9*s+3*o,f=3*e-3*r;for(let S=0;S<2;++S){if(S>0&&(p=6*t-12*i+6*n,g=-3*t+9*i-9*n+3*a,f=3*i-3*t),h(g)<1e-12){if(h(p)<1e-12)continue;const P=-f/p;0<P&&P<1&&d.push(P);continue}const T=p*p-4*f*g;if(T<0)continue;const k=c(T),O=(-p+k)/(2*g);0<O&&O<1&&d.push(O);const E=(-p-k)/(2*g);0<E&&E<1&&d.push(E)}let m=d.length;const b=m,_=Kc(r,t,e,i,s,n,o,a);for(;m--;){const{x:S,y:T}=_(d[m]);u[0][m]=S,u[1][m]=T}u[0][b]=r,u[1][b]=t,u[0][b+1]=o,u[1][b+1]=a;const w=[new x(Math.min(...u[0]),Math.min(...u[1])),new x(Math.max(...u[0]),Math.max(...u[1]))];return W.cachesBoundsOfCurve&&(Ds.boundsOfCurveCache[l]=w),w}const Df=(r,t,e)=>{let[i,s,n,o,a,l,c,h]=e;const d=((u,p,g,f,m,b,_)=>{if(g===0||f===0)return[];let w=0,S=0,T=0;const k=Math.PI,O=_*Ao,E=Qe(O),P=Je(O),R=.5*(-P*u-E*p),L=.5*(-P*p+E*u),F=g**2,H=f**2,M=L**2,U=R**2,X=F*H-F*M-H*U;let Q=Math.abs(g),N=Math.abs(f);if(X<0){const vt=Math.sqrt(1-X/(F*H));Q*=vt,N*=vt}else T=(m===b?-1:1)*Math.sqrt(X/(F*M+H*U));const Ct=T*Q*L/N,Ut=-T*N*R/Q,Wt=P*Ct-E*Ut+.5*u,Pe=E*Ct+P*Ut+.5*p;let de=_l(1,0,(R-Ct)/Q,(L-Ut)/N),Ft=_l((R-Ct)/Q,(L-Ut)/N,(-R-Ct)/Q,(-L-Ut)/N);b===0&&Ft>0?Ft-=2*k:b===1&&Ft<0&&(Ft+=2*k);const Ae=Math.ceil(Math.abs(Ft/k*2)),ae=[],At=Ft/Ae,jt=8/3*Math.sin(At/4)*Math.sin(At/4)/Math.sin(At/2);let le=de+At;for(let vt=0;vt<Ae;vt++)ae[vt]=Af(de,le,P,E,Q,N,Wt,Pe,jt,w,S),w=ae[vt][5],S=ae[vt][6],de=le,le+=At;return ae})(c-r,h-t,s,n,a,l,o);for(let u=0,p=d.length;u<p;u++)d[u][1]+=r,d[u][2]+=t,d[u][3]+=r,d[u][4]+=t,d[u][5]+=r,d[u][6]+=t;return d},Mf=r=>{let t=0,e=0,i=0,s=0;const n=[];let o,a=0,l=0;for(const c of r){const h=[...c];let d;switch(h[0]){case"l":h[1]+=t,h[2]+=e;case"L":t=h[1],e=h[2],d=["L",t,e];break;case"h":h[1]+=t;case"H":t=h[1],d=["L",t,e];break;case"v":h[1]+=e;case"V":e=h[1],d=["L",t,e];break;case"m":h[1]+=t,h[2]+=e;case"M":t=h[1],e=h[2],i=h[1],s=h[2],d=["M",t,e];break;case"c":h[1]+=t,h[2]+=e,h[3]+=t,h[4]+=e,h[5]+=t,h[6]+=e;case"C":a=h[3],l=h[4],t=h[5],e=h[6],d=["C",h[1],h[2],a,l,t,e];break;case"s":h[1]+=t,h[2]+=e,h[3]+=t,h[4]+=e;case"S":o==="C"?(a=2*t-a,l=2*e-l):(a=t,l=e),t=h[3],e=h[4],d=["C",a,l,h[1],h[2],t,e],a=d[3],l=d[4];break;case"q":h[1]+=t,h[2]+=e,h[3]+=t,h[4]+=e;case"Q":a=h[1],l=h[2],t=h[3],e=h[4],d=["Q",a,l,t,e];break;case"t":h[1]+=t,h[2]+=e;case"T":o==="Q"?(a=2*t-a,l=2*e-l):(a=t,l=e),t=h[1],e=h[2],d=["Q",a,l,t,e];break;case"a":h[6]+=t,h[7]+=e;case"A":Df(t,e,h).forEach((u=>n.push(u))),t=h[6],e=h[7];break;case"z":case"Z":t=i,e=s,d=["Z"]}d?(n.push(d),o=d[0]):o=""}return n},Kr=(r,t,e,i)=>Math.sqrt((e-r)**2+(i-t)**2),Kc=(r,t,e,i,s,n,o,a)=>l=>{const c=l**3,h=(p=>3*p**2*(1-p))(l),d=(p=>3*p*(1-p)**2)(l),u=(p=>(1-p)**3)(l);return new x(o*c+s*h+e*d+r*u,a*c+n*h+i*d+t*u)},qc=r=>r**2,Zc=r=>2*r*(1-r),Jc=r=>(1-r)**2,If=(r,t,e,i,s,n,o,a)=>l=>{const c=qc(l),h=Zc(l),d=Jc(l),u=3*(d*(e-r)+h*(s-e)+c*(o-s)),p=3*(d*(i-t)+h*(n-i)+c*(a-n));return Math.atan2(p,u)},Lf=(r,t,e,i,s,n)=>o=>{const a=qc(o),l=Zc(o),c=Jc(o);return new x(s*a+e*l+r*c,n*a+i*l+t*c)},Ff=(r,t,e,i,s,n)=>o=>{const a=1-o,l=2*(a*(e-r)+o*(s-e)),c=2*(a*(i-t)+o*(n-i));return Math.atan2(c,l)},wl=(r,t,e)=>{let i=new x(t,e),s=0;for(let n=1;n<=100;n+=1){const o=r(n/100);s+=Kr(i.x,i.y,o.x,o.y),i=o}return s},jf=(r,t)=>{let e,i=0,s=0,n={x:r.x,y:r.y},o=y({},n),a=.01,l=0;const c=r.iterator,h=r.angleFinder;for(;s<t&&a>1e-4;)o=c(i),l=i,e=Kr(n.x,n.y,o.x,o.y),e+s>t?(i-=a,a/=2):(n=o,i+=a,s+=e);return y(y({},o),{},{angle:h(l)})},Qc=r=>{let t,e,i=0,s=0,n=0,o=0,a=0;const l=[];for(const c of r){const h={x:s,y:n,command:c[0],length:0};switch(c[0]){case"M":e=h,e.x=o=s=c[1],e.y=a=n=c[2];break;case"L":e=h,e.length=Kr(s,n,c[1],c[2]),s=c[1],n=c[2];break;case"C":t=Kc(s,n,c[1],c[2],c[3],c[4],c[5],c[6]),e=h,e.iterator=t,e.angleFinder=If(s,n,c[1],c[2],c[3],c[4],c[5],c[6]),e.length=wl(t,s,n),s=c[5],n=c[6];break;case"Q":t=Lf(s,n,c[1],c[2],c[3],c[4]),e=h,e.iterator=t,e.angleFinder=Ff(s,n,c[1],c[2],c[3],c[4]),e.length=wl(t,s,n),s=c[3],n=c[4];break;case"Z":e=h,e.destX=o,e.destY=a,e.length=Kr(s,n,o,a),s=o,n=a}i+=e.length,l.push(e)}return l.push({length:i,x:s,y:n}),l},$f=function(r,t){let e=arguments.length>2&&arguments[2]!==void 0?arguments[2]:Qc(r),i=0;for(;t-e[i].length>0&&i<e.length-2;)t-=e[i].length,i++;const s=e[i],n=t/s.length,o=r[i];switch(s.command){case"M":return{x:s.x,y:s.y,angle:0};case"Z":return y(y({},new x(s.x,s.y).lerp(new x(s.destX,s.destY),n)),{},{angle:Math.atan2(s.destY-s.y,s.destX-s.x)});case"L":return y(y({},new x(s.x,s.y).lerp(new x(o[1],o[2]),n)),{},{angle:Math.atan2(o[2]-s.y,o[1]-s.x)});case"C":case"Q":return jf(s,t)}},Rf=new RegExp("[mzlhvcsqta][^mzlhvcsqta]*","gi"),Cl=new RegExp(kf,"g"),Bf=new RegExp(Se,"gi"),zf={m:2,l:2,h:1,v:1,c:6,s:4,q:4,t:2,a:7},Hf=r=>{var t;const e=[],i=(t=r.match(Rf))!==null&&t!==void 0?t:[];for(const s of i){const n=s[0];if(n==="z"||n==="Z"){e.push([n]);continue}const o=zf[n.toLowerCase()];let a=[];if(n==="a"||n==="A"){Cl.lastIndex=0;for(let l=null;l=Cl.exec(s);)a.push(...l.slice(1))}else a=s.match(Bf)||[];for(let l=0;l<a.length;l+=o){const c=new Array(o),h=Pf[n];c[0]=l>0&&h?h:n;for(let d=0;d<o;d++)c[d+1]=parseFloat(a[l+d]);e.push(c)}}return e},Vf=(r,t)=>r.map((e=>e.map(((i,s)=>s===0||t===void 0?i:et(i,t))).join(" "))).join(" ");function go(r,t){const e=r.style;e&&t&&(typeof t=="string"?e.cssText+=";"+t:Object.entries(t).forEach((i=>{let[s,n]=i;return e.setProperty(s,n)})))}class Nf extends Tc{constructor(t){let{allowTouchScrolling:e=!1,containerClass:i=""}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};super(t),v(this,"upper",void 0),v(this,"container",void 0);const{el:s}=this.lower,n=this.createUpperCanvas();this.upper={el:n,ctx:n.getContext("2d")},this.applyCanvasStyle(s,{allowTouchScrolling:e}),this.applyCanvasStyle(n,{allowTouchScrolling:e,styles:{position:"absolute",left:"0",top:"0"}});const o=this.createContainerElement();o.classList.add(i),s.parentNode&&s.parentNode.replaceChild(o,s),o.append(s,n),this.container=o}createUpperCanvas(){const{el:t}=this.lower,e=ti();return e.className=t.className,e.classList.remove("lower-canvas"),e.classList.add("upper-canvas"),e.setAttribute("data-fabric","top"),e.style.cssText=t.style.cssText,e.setAttribute("draggable","true"),e}createContainerElement(){const t=ss().createElement("div");return t.setAttribute("data-fabric","wrapper"),go(t,{position:"relative"}),Xa(t),t}applyCanvasStyle(t,e){const{styles:i,allowTouchScrolling:s}=e;go(t,y(y({},i),{},{"touch-action":s?"manipulation":se})),Xa(t)}setDimensions(t,e){super.setDimensions(t,e);const{el:i,ctx:s}=this.upper;Sc(i,s,t,e)}setCSSDimensions(t){super.setCSSDimensions(t),no(this.upper.el,t),no(this.container,t)}cleanupDOM(t){const e=this.container,{el:i}=this.lower,{el:s}=this.upper;super.cleanupDOM(t),e.removeChild(s),e.removeChild(i),e.parentNode&&e.parentNode.replaceChild(i,e)}dispose(){super.dispose(),Re().dispose(this.upper.el),delete this.upper,delete this.container}}class mn extends Js{constructor(){super(...arguments),v(this,"targets",[]),v(this,"_hoveredTargets",[]),v(this,"_currentTransform",null),v(this,"_groupSelector",null),v(this,"contextTopDirty",!1)}static getDefaults(){return y(y({},super.getDefaults()),mn.ownDefaults)}get upperCanvasEl(){var t;return(t=this.elements.upper)===null||t===void 0?void 0:t.el}get contextTop(){var t;return(t=this.elements.upper)===null||t===void 0?void 0:t.ctx}get wrapperEl(){return this.elements.container}initElements(t){this.elements=new Nf(t,{allowTouchScrolling:this.allowTouchScrolling,containerClass:this.containerClass}),this._createCacheCanvas()}_onObjectAdded(t){this._objectsToRender=void 0,super._onObjectAdded(t)}_onObjectRemoved(t){this._objectsToRender=void 0,t===this._activeObject&&(this.fire("before:selection:cleared",{deselected:[t]}),this._discardActiveObject(),this.fire("selection:cleared",{deselected:[t]}),t.fire("deselected",{target:t})),t===this._hoveredTarget&&(this._hoveredTarget=void 0,this._hoveredTargets=[]),super._onObjectRemoved(t)}_onStackOrderChanged(){this._objectsToRender=void 0,super._onStackOrderChanged()}_chooseObjectsToRender(){const t=this._activeObject;return!this.preserveObjectStacking&&t?this._objects.filter((e=>!e.group&&e!==t)).concat(t):this._objects}renderAll(){this.cancelRequestedRender(),this.destroyed||(!this.contextTopDirty||this._groupSelector||this.isDrawingMode||(this.clearContext(this.contextTop),this.contextTopDirty=!1),this.hasLostContext&&(this.renderTopLayer(this.contextTop),this.hasLostContext=!1),!this._objectsToRender&&(this._objectsToRender=this._chooseObjectsToRender()),this.renderCanvas(this.getContext(),this._objectsToRender))}renderTopLayer(t){t.save(),this.isDrawingMode&&this._isCurrentlyDrawing&&(this.freeDrawingBrush&&this.freeDrawingBrush._render(),this.contextTopDirty=!0),this.selection&&this._groupSelector&&(this._drawSelection(t),this.contextTopDirty=!0),t.restore()}renderTop(){const t=this.contextTop;this.clearContext(t),this.renderTopLayer(t),this.fire("after:render",{ctx:t})}setTargetFindTolerance(t){t=Math.round(t),this.targetFindTolerance=t;const e=this.getRetinaScaling(),i=Math.ceil((2*t+1)*e);this.pixelFindCanvasEl.width=this.pixelFindCanvasEl.height=i,this.pixelFindContext.scale(e,e)}isTargetTransparent(t,e,i){const s=this.targetFindTolerance,n=this.pixelFindContext;this.clearContext(n),n.save(),n.translate(-e+s,-i+s),n.transform(...this.viewportTransform);const o=t.selectionBackgroundColor;t.selectionBackgroundColor="",t.render(n),t.selectionBackgroundColor=o,n.restore();const a=Math.round(s*this.getRetinaScaling());return Yg(n,a,a,a)}_isSelectionKeyPressed(t){const e=this.selectionKey;return!!e&&(Array.isArray(e)?!!e.find((i=>!!i&&t[i]===!0)):t[e])}_shouldClearSelection(t,e){const i=this.getActiveObjects(),s=this._activeObject;return!!(!e||e&&s&&i.length>1&&i.indexOf(e)===-1&&s!==e&&!this._isSelectionKeyPressed(t)||e&&!e.evented||e&&!e.selectable&&s&&s!==e)}_shouldCenterTransform(t,e,i){if(!t)return;let s;return e===cn||e===oe||e===be||e===Hs?s=this.centeredScaling||t.centeredScaling:e===Io&&(s=this.centeredRotation||t.centeredRotation),s?!i:i}_getOriginFromCorner(t,e){const i={x:t.originX,y:t.originY};return e&&(["ml","tl","bl"].includes(e)?i.x=_t:["mr","tr","br"].includes(e)&&(i.x=Y),["tl","mt","tr"].includes(e)?i.y=ro:["bl","mb","br"].includes(e)&&(i.y=ie)),i}_setupCurrentTransform(t,e,i){var s;const n=e.group?Zi(this.getScenePoint(t),void 0,e.group.calcTransformMatrix()):this.getScenePoint(t),{key:o="",control:a}=e.getActiveControl()||{},l=i&&a?(s=a.getActionHandler(t,e,a))===null||s===void 0?void 0:s.bind(a):lg,c=((p,g,f,m)=>{if(!g||!p)return"drag";const b=m.controls[g];return b.getActionName(f,b,m)})(i,o,t,e),h=t[this.centeredKey],d=this._shouldCenterTransform(e,c,h)?{x:V,y:V}:this._getOriginFromCorner(e,o),u={target:e,action:c,actionHandler:l,actionPerformed:!1,corner:o,scaleX:e.scaleX,scaleY:e.scaleY,skewX:e.skewX,skewY:e.skewY,offsetX:n.x-e.left,offsetY:n.y-e.top,originX:d.x,originY:d.y,ex:n.x,ey:n.y,lastX:n.x,lastY:n.y,theta:xt(e.angle),width:e.width,height:e.height,shiftKey:t.shiftKey,altKey:h,original:y(y({},Ec(e)),{},{originX:d.x,originY:d.y})};this._currentTransform=u,this.fire("before:transform",{e:t,transform:u})}setCursor(t){this.upperCanvasEl.style.cursor=t}_drawSelection(t){const{x:e,y:i,deltaX:s,deltaY:n}=this._groupSelector,o=new x(e,i).transform(this.viewportTransform),a=new x(e+s,i+n).transform(this.viewportTransform),l=this.selectionLineWidth/2;let c=Math.min(o.x,a.x),h=Math.min(o.y,a.y),d=Math.max(o.x,a.x),u=Math.max(o.y,a.y);this.selectionColor&&(t.fillStyle=this.selectionColor,t.fillRect(c,h,d-c,u-h)),this.selectionLineWidth&&this.selectionBorderColor&&(t.lineWidth=this.selectionLineWidth,t.strokeStyle=this.selectionBorderColor,c+=l,h+=l,d-=l,u-=l,Vt.prototype._setLineDash.call(this,t,this.selectionDashArray),t.strokeRect(c,h,d-c,u-h))}findTarget(t){if(this.skipTargetFind)return;const e=this.getViewportPoint(t),i=this._activeObject,s=this.getActiveObjects();if(this.targets=[],i&&s.length>=1){if(i.findControl(e,oo(t))||s.length>1&&this.searchPossibleTargets([i],e))return i;if(i===this.searchPossibleTargets([i],e)){if(this.preserveObjectStacking){const n=this.targets;this.targets=[];const o=this.searchPossibleTargets(this._objects,e);return t[this.altSelectionKey]&&o&&o!==i?(this.targets=n,i):o}return i}}return this.searchPossibleTargets(this._objects,e)}_pointIsInObjectSelectionArea(t,e){let i=t.getCoords();const s=this.getZoom(),n=t.padding/s;if(n){const[o,a,l,c]=i,h=Math.atan2(a.y-o.y,a.x-o.x),d=Je(h)*n,u=Qe(h)*n,p=d+u,g=d-u;i=[new x(o.x-g,o.y-p),new x(a.x+p,a.y-g),new x(l.x+g,l.y+p),new x(c.x-p,c.y+g)]}return lt.isPointInPolygon(e,i)}_checkTarget(t,e){return!!(t&&t.visible&&t.evented&&this._pointIsInObjectSelectionArea(t,Zi(e,void 0,this.viewportTransform))&&(!this.perPixelTargetFind&&!t.perPixelTargetFind||t.isEditing||!this.isTargetTransparent(t,e.x,e.y)))}_searchPossibleTargets(t,e){let i=t.length;for(;i--;){const s=t[i];if(this._checkTarget(s,e)){if(Dr(s)&&s.subTargetCheck){const n=this._searchPossibleTargets(s._objects,e);n&&this.targets.push(n)}return s}}}searchPossibleTargets(t,e){const i=this._searchPossibleTargets(t,e);if(i&&Dr(i)&&i.interactive&&this.targets[0]){const s=this.targets;for(let n=s.length-1;n>0;n--){const o=s[n];if(!Dr(o)||!o.interactive)return o}return s[0]}return i}getViewportPoint(t){return this._pointer?this._pointer:this.getPointer(t,!0)}getScenePoint(t){return this._absolutePointer?this._absolutePointer:this.getPointer(t)}getPointer(t){let e=arguments.length>1&&arguments[1]!==void 0&&arguments[1];const i=this.upperCanvasEl,s=i.getBoundingClientRect();let n=eg(t),o=s.width||0,a=s.height||0;o&&a||(ie in s&&ro in s&&(a=Math.abs(s.top-s.bottom)),_t in s&&Y in s&&(o=Math.abs(s.right-s.left))),this.calcOffset(),n.x=n.x-this._offset.left,n.y=n.y-this._offset.top,e||(n=Zi(n,void 0,this.viewportTransform));const l=this.getRetinaScaling();l!==1&&(n.x/=l,n.y/=l);const c=o===0||a===0?new x(1,1):new x(i.width/o,i.height/a);return n.multiply(c)}_setDimensionsImpl(t,e){this._resetTransformEventData(),super._setDimensionsImpl(t,e),this._isCurrentlyDrawing&&this.freeDrawingBrush&&this.freeDrawingBrush._setBrushStyles(this.contextTop)}_createCacheCanvas(){this.pixelFindCanvasEl=ti(),this.pixelFindContext=this.pixelFindCanvasEl.getContext("2d",{willReadFrequently:!0}),this.setTargetFindTolerance(this.targetFindTolerance)}getTopContext(){return this.elements.upper.ctx}getSelectionContext(){return this.elements.upper.ctx}getSelectionElement(){return this.elements.upper.el}getActiveObject(){return this._activeObject}getActiveObjects(){const t=this._activeObject;return Ei(t)?t.getObjects():t?[t]:[]}_fireSelectionEvents(t,e){let i=!1,s=!1;const n=this.getActiveObjects(),o=[],a=[];t.forEach((l=>{n.includes(l)||(i=!0,l.fire("deselected",{e,target:l}),a.push(l))})),n.forEach((l=>{t.includes(l)||(i=!0,l.fire("selected",{e,target:l}),o.push(l))})),t.length>0&&n.length>0?(s=!0,i&&this.fire("selection:updated",{e,selected:o,deselected:a})):n.length>0?(s=!0,this.fire("selection:created",{e,selected:o})):t.length>0&&(s=!0,this.fire("selection:cleared",{e,deselected:a})),s&&(this._objectsToRender=void 0)}setActiveObject(t,e){const i=this.getActiveObjects(),s=this._setActiveObject(t,e);return this._fireSelectionEvents(i,e),s}_setActiveObject(t,e){const i=this._activeObject;return i!==t&&!(!this._discardActiveObject(e,t)&&this._activeObject)&&!t.onSelect({e})&&(this._activeObject=t,Ei(t)&&i!==t&&t.set("canvas",this),t.setCoords(),!0)}_discardActiveObject(t,e){const i=this._activeObject;return!!i&&!i.onDeselect({e:t,object:e})&&(this._currentTransform&&this._currentTransform.target===i&&this.endCurrentTransform(t),Ei(i)&&i===this._hoveredTarget&&(this._hoveredTarget=void 0),this._activeObject=void 0,!0)}discardActiveObject(t){const e=this.getActiveObjects(),i=this.getActiveObject();e.length&&this.fire("before:selection:cleared",{e:t,deselected:[i]});const s=this._discardActiveObject(t);return this._fireSelectionEvents(e,t),s}endCurrentTransform(t){const e=this._currentTransform;this._finalizeCurrentTransform(t),e&&e.target&&(e.target.isMoving=!1),this._currentTransform=null}_finalizeCurrentTransform(t){const e=this._currentTransform,i=e.target,s={e:t,target:i,transform:e,action:e.action};i._scaling&&(i._scaling=!1),i.setCoords(),e.actionPerformed&&(this.fire("object:modified",s),i.fire(zr,s))}setViewportTransform(t){super.setViewportTransform(t);const e=this._activeObject;e&&e.setCoords()}destroy(){const t=this._activeObject;Ei(t)&&(t.removeAll(),t.dispose()),delete this._activeObject,super.destroy(),this.pixelFindContext=null,this.pixelFindCanvasEl=void 0}clear(){this.discardActiveObject(),this._activeObject=void 0,this.clearContext(this.contextTop),super.clear()}drawControls(t){const e=this._activeObject;e&&e._renderControls(t)}_toObject(t,e,i){const s=this._realizeGroupTransformOnObject(t),n=super._toObject(t,e,i);return t.set(s),n}_realizeGroupTransformOnObject(t){const{group:e}=t;if(e&&Ei(e)&&this._activeObject===e){const i=as(t,["angle","flipX","flipY",Y,oe,be,rs,ns,ie]);return sg(t,e.calcOwnMatrix()),i}return{}}_setSVGObject(t,e,i){const s=this._realizeGroupTransformOnObject(e);super._setSVGObject(t,e,i),e.set(s)}}v(mn,"ownDefaults",{uniformScaling:!0,uniScaleKey:"shiftKey",centeredScaling:!1,centeredRotation:!1,centeredKey:"altKey",altActionKey:"shiftKey",selection:!0,selectionKey:"shiftKey",selectionColor:"rgba(100, 100, 255, 0.3)",selectionDashArray:[],selectionBorderColor:"rgba(255, 255, 255, 0.3)",selectionLineWidth:1,selectionFullyContained:!1,hoverCursor:"move",moveCursor:"move",defaultCursor:"default",freeDrawingCursor:"crosshair",notAllowedCursor:"not-allowed",perPixelTargetFind:!1,targetFindTolerance:0,skipTargetFind:!1,stopContextMenu:!1,fireRightClick:!1,fireMiddleClick:!1,enablePointerEvents:!1,containerClass:"canvas-container",preserveObjectStacking:!1});class Uf{constructor(t){v(this,"targets",[]),v(this,"__disposer",void 0);const e=()=>{const{hiddenTextarea:s}=t.getActiveObject()||{};s&&s.focus()},i=t.upperCanvasEl;i.addEventListener("click",e),this.__disposer=()=>i.removeEventListener("click",e)}exitTextEditing(){this.target=void 0,this.targets.forEach((t=>{t.isEditing&&t.exitEditing()}))}add(t){this.targets.push(t)}remove(t){this.unregister(t),Yi(this.targets,t)}register(t){this.target=t}unregister(t){t===this.target&&(this.target=void 0)}onMouseMove(t){var e;!((e=this.target)===null||e===void 0)&&e.isEditing&&this.target.updateSelectionOnMouseMove(t)}clear(){this.targets=[],this.target=void 0}dispose(){this.clear(),this.__disposer(),delete this.__disposer}}const Wf=["target","oldTarget","fireCanvas","e"],ce={passive:!1},Ui=(r,t)=>{const e=r.getViewportPoint(t),i=r.getScenePoint(t);return{viewportPoint:e,scenePoint:i,pointer:e,absolutePointer:i}},li=function(r){for(var t=arguments.length,e=new Array(t>1?t-1:0),i=1;i<t;i++)e[i-1]=arguments[i];return r.addEventListener(...e)},ue=function(r){for(var t=arguments.length,e=new Array(t>1?t-1:0),i=1;i<t;i++)e[i-1]=arguments[i];return r.removeEventListener(...e)},Yf={mouse:{in:"over",out:"out",targetIn:"mouseover",targetOut:"mouseout",canvasIn:"mouse:over",canvasOut:"mouse:out"},drag:{in:"enter",out:"leave",targetIn:"dragenter",targetOut:"dragleave",canvasIn:"drag:enter",canvasOut:"drag:leave"}};class fo extends mn{constructor(t){super(t,arguments.length>1&&arguments[1]!==void 0?arguments[1]:{}),v(this,"_isClick",void 0),v(this,"textEditingManager",new Uf(this)),["_onMouseDown","_onTouchStart","_onMouseMove","_onMouseUp","_onTouchEnd","_onResize","_onMouseWheel","_onMouseOut","_onMouseEnter","_onContextMenu","_onClick","_onDragStart","_onDragEnd","_onDragProgress","_onDragOver","_onDragEnter","_onDragLeave","_onDrop"].forEach((e=>{this[e]=this[e].bind(this)})),this.addOrRemove(li,"add")}_getEventPrefix(){return this.enablePointerEvents?"pointer":"mouse"}addOrRemove(t,e){const i=this.upperCanvasEl,s=this._getEventPrefix();t(Cc(i),"resize",this._onResize),t(i,s+"down",this._onMouseDown),t(i,"".concat(s,"move"),this._onMouseMove,ce),t(i,"".concat(s,"out"),this._onMouseOut),t(i,"".concat(s,"enter"),this._onMouseEnter),t(i,"wheel",this._onMouseWheel,{passive:!1}),t(i,"contextmenu",this._onContextMenu),t(i,"click",this._onClick),t(i,"dblclick",this._onClick),t(i,"dragstart",this._onDragStart),t(i,"dragend",this._onDragEnd),t(i,"dragover",this._onDragOver),t(i,"dragenter",this._onDragEnter),t(i,"dragleave",this._onDragLeave),t(i,"drop",this._onDrop),this.enablePointerEvents||t(i,"touchstart",this._onTouchStart,ce)}removeListeners(){this.addOrRemove(ue,"remove");const t=this._getEventPrefix(),e=we(this.upperCanvasEl);ue(e,"".concat(t,"up"),this._onMouseUp),ue(e,"touchend",this._onTouchEnd,ce),ue(e,"".concat(t,"move"),this._onMouseMove,ce),ue(e,"touchmove",this._onMouseMove,ce),clearTimeout(this._willAddMouseDown)}_onMouseWheel(t){this.__onMouseWheel(t)}_onMouseOut(t){const e=this._hoveredTarget,i=y({e:t},Ui(this,t));this.fire("mouse:out",y(y({},i),{},{target:e})),this._hoveredTarget=void 0,e&&e.fire("mouseout",y({},i)),this._hoveredTargets.forEach((s=>{this.fire("mouse:out",y(y({},i),{},{target:s})),s&&s.fire("mouseout",y({},i))})),this._hoveredTargets=[]}_onMouseEnter(t){this._currentTransform||this.findTarget(t)||(this.fire("mouse:over",y({e:t},Ui(this,t))),this._hoveredTarget=void 0,this._hoveredTargets=[])}_onDragStart(t){this._isClick=!1;const e=this.getActiveObject();if(e&&e.onDragStart(t)){this._dragSource=e;const i={e:t,target:e};return this.fire("dragstart",i),e.fire("dragstart",i),void li(this.upperCanvasEl,"drag",this._onDragProgress)}Ka(t)}_renderDragEffects(t,e,i){let s=!1;const n=this._dropTarget;n&&n!==e&&n!==i&&(n.clearContextTop(),s=!0),e==null||e.clearContextTop(),i!==e&&(i==null||i.clearContextTop());const o=this.contextTop;o.save(),o.transform(...this.viewportTransform),e&&(o.save(),e.transform(o),e.renderDragSourceEffect(t),o.restore(),s=!0),i&&(o.save(),i.transform(o),i.renderDropTargetEffect(t),o.restore(),s=!0),o.restore(),s&&(this.contextTopDirty=!0)}_onDragEnd(t){const e=!!t.dataTransfer&&t.dataTransfer.dropEffect!==se,i=e?this._activeObject:void 0,s={e:t,target:this._dragSource,subTargets:this.targets,dragSource:this._dragSource,didDrop:e,dropTarget:i};ue(this.upperCanvasEl,"drag",this._onDragProgress),this.fire("dragend",s),this._dragSource&&this._dragSource.fire("dragend",s),delete this._dragSource,this._onMouseUp(t)}_onDragProgress(t){const e={e:t,target:this._dragSource,dragSource:this._dragSource,dropTarget:this._draggedoverTarget};this.fire("drag",e),this._dragSource&&this._dragSource.fire("drag",e)}findDragTargets(t){return this.targets=[],{target:this._searchPossibleTargets(this._objects,this.getViewportPoint(t)),targets:[...this.targets]}}_onDragOver(t){const e="dragover",{target:i,targets:s}=this.findDragTargets(t),n=this._dragSource,o={e:t,target:i,subTargets:s,dragSource:n,canDrop:!1,dropTarget:void 0};let a;this.fire(e,o),this._fireEnterLeaveEvents(i,o),i&&(i.canDrop(t)&&(a=i),i.fire(e,o));for(let l=0;l<s.length;l++){const c=s[l];c.canDrop(t)&&(a=c),c.fire(e,o)}this._renderDragEffects(t,n,a),this._dropTarget=a}_onDragEnter(t){const{target:e,targets:i}=this.findDragTargets(t),s={e:t,target:e,subTargets:i,dragSource:this._dragSource};this.fire("dragenter",s),this._fireEnterLeaveEvents(e,s)}_onDragLeave(t){const e={e:t,target:this._draggedoverTarget,subTargets:this.targets,dragSource:this._dragSource};this.fire("dragleave",e),this._fireEnterLeaveEvents(void 0,e),this._renderDragEffects(t,this._dragSource),this._dropTarget=void 0,this.targets=[],this._hoveredTargets=[]}_onDrop(t){const{target:e,targets:i}=this.findDragTargets(t),s=this._basicEventHandler("drop:before",y({e:t,target:e,subTargets:i,dragSource:this._dragSource},Ui(this,t)));s.didDrop=!1,s.dropTarget=void 0,this._basicEventHandler("drop",s),this.fire("drop:after",s)}_onContextMenu(t){const e=this.findTarget(t),i=this.targets||[],s=this._basicEventHandler("contextmenu:before",{e:t,target:e,subTargets:i});return this.stopContextMenu&&Ka(t),this._basicEventHandler("contextmenu",s),!1}_onClick(t){const e=t.detail;e>3||e<2||(this._cacheTransformEventData(t),e==2&&t.type==="dblclick"&&this._handleEvent(t,"dblclick"),e==3&&this._handleEvent(t,"tripleclick"),this._resetTransformEventData())}getPointerId(t){const e=t.changedTouches;return e?e[0]&&e[0].identifier:this.enablePointerEvents?t.pointerId:-1}_isMainEvent(t){return t.isPrimary===!0||t.isPrimary!==!1&&(t.type==="touchend"&&t.touches.length===0||!t.changedTouches||t.changedTouches[0].identifier===this.mainTouchId)}_onTouchStart(t){let e=!this.allowTouchScrolling;const i=this._activeObject;this.mainTouchId===void 0&&(this.mainTouchId=this.getPointerId(t)),this.__onMouseDown(t),(this.isDrawingMode||i&&this._target===i)&&(e=!0),e&&t.preventDefault(),this._resetTransformEventData();const s=this.upperCanvasEl,n=this._getEventPrefix(),o=we(s);li(o,"touchend",this._onTouchEnd,ce),e&&li(o,"touchmove",this._onMouseMove,ce),ue(s,"".concat(n,"down"),this._onMouseDown)}_onMouseDown(t){this.__onMouseDown(t),this._resetTransformEventData();const e=this.upperCanvasEl,i=this._getEventPrefix();ue(e,"".concat(i,"move"),this._onMouseMove,ce);const s=we(e);li(s,"".concat(i,"up"),this._onMouseUp),li(s,"".concat(i,"move"),this._onMouseMove,ce)}_onTouchEnd(t){if(t.touches.length>0)return;this.__onMouseUp(t),this._resetTransformEventData(),delete this.mainTouchId;const e=this._getEventPrefix(),i=we(this.upperCanvasEl);ue(i,"touchend",this._onTouchEnd,ce),ue(i,"touchmove",this._onMouseMove,ce),this._willAddMouseDown&&clearTimeout(this._willAddMouseDown),this._willAddMouseDown=setTimeout((()=>{li(this.upperCanvasEl,"".concat(e,"down"),this._onMouseDown),this._willAddMouseDown=0}),400)}_onMouseUp(t){this.__onMouseUp(t),this._resetTransformEventData();const e=this.upperCanvasEl,i=this._getEventPrefix();if(this._isMainEvent(t)){const s=we(this.upperCanvasEl);ue(s,"".concat(i,"up"),this._onMouseUp),ue(s,"".concat(i,"move"),this._onMouseMove,ce),li(e,"".concat(i,"move"),this._onMouseMove,ce)}}_onMouseMove(t){const e=this.getActiveObject();!this.allowTouchScrolling&&(!e||!e.shouldStartDragging(t))&&t.preventDefault&&t.preventDefault(),this.__onMouseMove(t)}_onResize(){this.calcOffset(),this._resetTransformEventData()}_shouldRender(t){const e=this.getActiveObject();return!!e!=!!t||e&&t&&e!==t}__onMouseUp(t){var e;this._cacheTransformEventData(t),this._handleEvent(t,"up:before");const i=this._currentTransform,s=this._isClick,n=this._target,{button:o}=t;if(o)return(this.fireMiddleClick&&o===1||this.fireRightClick&&o===2)&&this._handleEvent(t,"up"),void this._resetTransformEventData();if(this.isDrawingMode&&this._isCurrentlyDrawing)return void this._onMouseUpInDrawingMode(t);if(!this._isMainEvent(t))return;let a,l,c=!1;if(i&&(this._finalizeCurrentTransform(t),c=i.actionPerformed),!s){const h=n===this._activeObject;this.handleSelection(t),c||(c=this._shouldRender(n)||!h&&n===this._activeObject)}if(n){const h=n.findControl(this.getViewportPoint(t),oo(t)),{key:d,control:u}=h||{};if(l=d,n.selectable&&n!==this._activeObject&&n.activeOn==="up")this.setActiveObject(n,t),c=!0;else if(u){const p=u.getMouseUpHandler(t,n,u);p&&(a=this.getScenePoint(t),p.call(u,t,i,a.x,a.y))}n.isMoving=!1}if(i&&(i.target!==n||i.corner!==l)){const h=i.target&&i.target.controls[i.corner],d=h&&h.getMouseUpHandler(t,i.target,h);a=a||this.getScenePoint(t),d&&d.call(h,t,i,a.x,a.y)}this._setCursorFromEvent(t,n),this._handleEvent(t,"up"),this._groupSelector=null,this._currentTransform=null,n&&(n.__corner=void 0),c?this.requestRenderAll():s||(e=this._activeObject)!==null&&e!==void 0&&e.isEditing||this.renderTop()}_basicEventHandler(t,e){const{target:i,subTargets:s=[]}=e;this.fire(t,e),i&&i.fire(t,e);for(let n=0;n<s.length;n++)s[n]!==i&&s[n].fire(t,e);return e}_handleEvent(t,e,i){const s=this._target,n=this.targets||[],o=y(y(y({e:t,target:s,subTargets:n},Ui(this,t)),{},{transform:this._currentTransform},e==="up:before"||e==="up"?{isClick:this._isClick,currentTarget:this.findTarget(t),currentSubTargets:this.targets}:{}),e==="down:before"||e==="down"?i:{});this.fire("mouse:".concat(e),o),s&&s.fire("mouse".concat(e),o);for(let a=0;a<n.length;a++)n[a]!==s&&n[a].fire("mouse".concat(e),o)}_onMouseDownInDrawingMode(t){this._isCurrentlyDrawing=!0,this.getActiveObject()&&(this.discardActiveObject(t),this.requestRenderAll());const e=this.getScenePoint(t);this.freeDrawingBrush&&this.freeDrawingBrush.onMouseDown(e,{e:t,pointer:e}),this._handleEvent(t,"down",{alreadySelected:!1})}_onMouseMoveInDrawingMode(t){if(this._isCurrentlyDrawing){const e=this.getScenePoint(t);this.freeDrawingBrush&&this.freeDrawingBrush.onMouseMove(e,{e:t,pointer:e})}this.setCursor(this.freeDrawingCursor),this._handleEvent(t,"move")}_onMouseUpInDrawingMode(t){const e=this.getScenePoint(t);this.freeDrawingBrush?this._isCurrentlyDrawing=!!this.freeDrawingBrush.onMouseUp({e:t,pointer:e}):this._isCurrentlyDrawing=!1,this._handleEvent(t,"up")}__onMouseDown(t){this._isClick=!0,this._cacheTransformEventData(t),this._handleEvent(t,"down:before");let e=this._target,i=!!e&&e===this._activeObject;const{button:s}=t;if(s)return(this.fireMiddleClick&&s===1||this.fireRightClick&&s===2)&&this._handleEvent(t,"down",{alreadySelected:i}),void this._resetTransformEventData();if(this.isDrawingMode)return void this._onMouseDownInDrawingMode(t);if(!this._isMainEvent(t)||this._currentTransform)return;let n=this._shouldRender(e),o=!1;if(this.handleMultiSelection(t,e)?(e=this._activeObject,o=!0,n=!0):this._shouldClearSelection(t,e)&&this.discardActiveObject(t),this.selection&&(!e||!e.selectable&&!e.isEditing&&e!==this._activeObject)){const a=this.getScenePoint(t);this._groupSelector={x:a.x,y:a.y,deltaY:0,deltaX:0}}if(i=!!e&&e===this._activeObject,e){e.selectable&&e.activeOn==="down"&&this.setActiveObject(e,t);const a=e.findControl(this.getViewportPoint(t),oo(t));if(e===this._activeObject&&(a||!o)){this._setupCurrentTransform(t,e,i);const l=a?a.control:void 0,c=this.getScenePoint(t),h=l&&l.getMouseDownHandler(t,e,l);h&&h.call(l,t,this._currentTransform,c.x,c.y)}}n&&(this._objectsToRender=void 0),this._handleEvent(t,"down",{alreadySelected:i}),n&&this.requestRenderAll()}_resetTransformEventData(){this._target=this._pointer=this._absolutePointer=void 0}_cacheTransformEventData(t){this._resetTransformEventData(),this._pointer=this.getViewportPoint(t),this._absolutePointer=Zi(this._pointer,void 0,this.viewportTransform),this._target=this._currentTransform?this._currentTransform.target:this.findTarget(t)}__onMouseMove(t){if(this._isClick=!1,this._cacheTransformEventData(t),this._handleEvent(t,"move:before"),this.isDrawingMode)return void this._onMouseMoveInDrawingMode(t);if(!this._isMainEvent(t))return;const e=this._groupSelector;if(e){const i=this.getScenePoint(t);e.deltaX=i.x-e.x,e.deltaY=i.y-e.y,this.renderTop()}else if(this._currentTransform)this._transformObject(t);else{const i=this.findTarget(t);this._setCursorFromEvent(t,i),this._fireOverOutEvents(t,i)}this.textEditingManager.onMouseMove(t),this._handleEvent(t,"move"),this._resetTransformEventData()}_fireOverOutEvents(t,e){const i=this._hoveredTarget,s=this._hoveredTargets,n=this.targets,o=Math.max(s.length,n.length);this.fireSyntheticInOutEvents("mouse",{e:t,target:e,oldTarget:i,fireCanvas:!0});for(let a=0;a<o;a++)n[a]===e||s[a]&&s[a]===i||this.fireSyntheticInOutEvents("mouse",{e:t,target:n[a],oldTarget:s[a]});this._hoveredTarget=e,this._hoveredTargets=this.targets.concat()}_fireEnterLeaveEvents(t,e){const i=this._draggedoverTarget,s=this._hoveredTargets,n=this.targets,o=Math.max(s.length,n.length);this.fireSyntheticInOutEvents("drag",y(y({},e),{},{target:t,oldTarget:i,fireCanvas:!0}));for(let a=0;a<o;a++)this.fireSyntheticInOutEvents("drag",y(y({},e),{},{target:n[a],oldTarget:s[a]}));this._draggedoverTarget=t}fireSyntheticInOutEvents(t,e){let{target:i,oldTarget:s,fireCanvas:n,e:o}=e,a=rt(e,Wf);const{targetIn:l,targetOut:c,canvasIn:h,canvasOut:d}=Yf[t],u=s!==i;if(s&&u){const p=y(y({},a),{},{e:o,target:s,nextTarget:i},Ui(this,o));n&&this.fire(d,p),s.fire(c,p)}if(i&&u){const p=y(y({},a),{},{e:o,target:i,previousTarget:s},Ui(this,o));n&&this.fire(h,p),i.fire(l,p)}}__onMouseWheel(t){this._cacheTransformEventData(t),this._handleEvent(t,"wheel"),this._resetTransformEventData()}_transformObject(t){const e=this.getScenePoint(t),i=this._currentTransform,s=i.target,n=s.group?Zi(e,void 0,s.group.calcTransformMatrix()):e;i.shiftKey=t.shiftKey,i.altKey=!!this.centeredKey&&t[this.centeredKey],this._performTransformAction(t,i,n),i.actionPerformed&&this.requestRenderAll()}_performTransformAction(t,e,i){const{action:s,actionHandler:n,target:o}=e,a=!!n&&n(t,e,i.x,i.y);a&&o.setCoords(),s==="drag"&&a&&(e.target.isMoving=!0,this.setCursor(e.target.moveCursor||this.moveCursor)),e.actionPerformed=e.actionPerformed||a}_setCursorFromEvent(t,e){if(!e)return void this.setCursor(this.defaultCursor);let i=e.hoverCursor||this.hoverCursor;const s=Ei(this._activeObject)?this._activeObject:null,n=(!s||e.group!==s)&&e.findControl(this.getViewportPoint(t));if(n){const o=n.control;this.setCursor(o.cursorStyleHandler(t,o,e))}else e.subTargetCheck&&this.targets.concat().reverse().map((o=>{i=o.hoverCursor||i})),this.setCursor(i)}handleMultiSelection(t,e){const i=this._activeObject,s=Ei(i);if(i&&this._isSelectionKeyPressed(t)&&this.selection&&e&&e.selectable&&(i!==e||s)&&(s||!e.isDescendantOf(i)&&!i.isDescendantOf(e))&&!e.onSelect({e:t})&&!i.getActiveControl()){if(s){const n=i.getObjects();if(e===i){const o=this.getViewportPoint(t);if(!(e=this.searchPossibleTargets(n,o)||this.searchPossibleTargets(this._objects,o))||!e.selectable)return!1}e.group===i?(i.remove(e),this._hoveredTarget=e,this._hoveredTargets=[...this.targets],i.size()===1&&this._setActiveObject(i.item(0),t)):(i.multiSelectAdd(e),this._hoveredTarget=i,this._hoveredTargets=[...this.targets]),this._fireSelectionEvents(n,t)}else{i.isEditing&&i.exitEditing();const n=new(A.getClass("ActiveSelection"))([],{canvas:this});n.multiSelectAdd(i,e),this._hoveredTarget=n,this._setActiveObject(n,t),this._fireSelectionEvents([i],t)}return!0}return!1}handleSelection(t){if(!this.selection||!this._groupSelector)return!1;const{x:e,y:i,deltaX:s,deltaY:n}=this._groupSelector,o=new x(e,i),a=o.add(new x(s,n)),l=o.min(a),c=o.max(a).subtract(l),h=this.collectObjects({left:l.x,top:l.y,width:c.x,height:c.y},{includeIntersecting:!this.selectionFullyContained}),d=o.eq(a)?h[0]?[h[0]]:[]:h.length>1?h.filter((u=>!u.onSelect({e:t}))).reverse():h;if(d.length===1)this.setActiveObject(d[0],t);else if(d.length>1){const u=A.getClass("ActiveSelection");this.setActiveObject(new u(d,{canvas:this}),t)}return this._groupSelector=null,!0}toCanvasElement(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:1,e=arguments.length>1?arguments[1]:void 0;const{upper:i}=this.elements;i.ctx=void 0;const s=super.toCanvasElement(t,e);return i.ctx=i.el.getContext("2d"),s}clear(){this.textEditingManager.clear(),super.clear()}destroy(){this.removeListeners(),this.textEditingManager.dispose(),super.destroy()}}const th={x1:0,y1:0,x2:0,y2:0},Gf=y(y({},th),{},{r1:0,r2:0}),Ki=(r,t)=>isNaN(r)&&typeof t=="number"?t:r;function eh(r){return r&&/%$/.test(r)&&Number.isFinite(parseFloat(r))}function ih(r,t){const e=typeof r=="number"?r:typeof r=="string"?parseFloat(r)/(eh(r)?100:1):NaN;return es(0,Ki(e,t),1)}const Xf=/\s*;\s*/,Kf=/\s*:\s*/;function qf(r,t){let e,i;const s=r.getAttribute("style");if(s){const o=s.split(Xf);o[o.length-1]===""&&o.pop();for(let a=o.length;a--;){const[l,c]=o[a].split(Kf).map((h=>h.trim()));l==="stop-color"?e=c:l==="stop-opacity"&&(i=c)}}const n=new K(e||r.getAttribute("stop-color")||"rgb(0,0,0)");return{offset:ih(r.getAttribute("offset"),0),color:n.toRgb(),opacity:Ki(parseFloat(i||r.getAttribute("stop-opacity")||""),1)*n.getAlpha()*t}}function Zf(r,t){const e=[],i=r.getElementsByTagName("stop"),s=ih(t,1);for(let n=i.length;n--;)e.push(qf(i[n],s));return e}function sh(r){return r.nodeName==="linearGradient"||r.nodeName==="LINEARGRADIENT"?"linear":"radial"}function rh(r){return r.getAttribute("gradientUnits")==="userSpaceOnUse"?"pixels":"percentage"}function ye(r,t){return r.getAttribute(t)}function Jf(r,t){return(function(e,i){let s,{width:n,height:o,gradientUnits:a}=i;return Object.entries(e).reduce(((l,c)=>{let[h,d]=c;if(d==="Infinity")s=1;else if(d==="-Infinity")s=0;else{const u=typeof d=="string";s=u?parseFloat(d):d,u&&eh(d)&&(s*=.01,a==="pixels"&&(h!=="x1"&&h!=="x2"&&h!=="r2"||(s*=n),h!=="y1"&&h!=="y2"||(s*=o)))}return l[h]=s,l}),{})})(sh(r)==="linear"?(function(e){return{x1:ye(e,"x1")||0,y1:ye(e,"y1")||0,x2:ye(e,"x2")||"100%",y2:ye(e,"y2")||0}})(r):(function(e){return{x1:ye(e,"fx")||ye(e,"cx")||"50%",y1:ye(e,"fy")||ye(e,"cy")||"50%",r1:0,x2:ye(e,"cx")||"50%",y2:ye(e,"cy")||"50%",r2:ye(e,"r")||"50%"}})(r),y(y({},t),{},{gradientUnits:rh(r)}))}class ar{constructor(t){const{type:e="linear",gradientUnits:i="pixels",coords:s={},colorStops:n=[],offsetX:o=0,offsetY:a=0,gradientTransform:l,id:c}=t||{};Object.assign(this,{type:e,gradientUnits:i,coords:y(y({},e==="radial"?Gf:th),s),colorStops:n,offsetX:o,offsetY:a,gradientTransform:l,id:c?"".concat(c,"_").concat(bi()):bi()})}addColorStop(t){for(const e in t){const i=new K(t[e]);this.colorStops.push({offset:parseFloat(e),color:i.toRgb(),opacity:i.getAlpha()})}return this}toObject(t){return y(y({},as(this,t)),{},{type:this.type,coords:y({},this.coords),colorStops:this.colorStops.map((e=>y({},e))),offsetX:this.offsetX,offsetY:this.offsetY,gradientUnits:this.gradientUnits,gradientTransform:this.gradientTransform?[...this.gradientTransform]:void 0})}toSVG(t){let{additionalTransform:e}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};const i=[],s=this.gradientTransform?this.gradientTransform.concat():qt.concat(),n=this.gradientUnits==="pixels"?"userSpaceOnUse":"objectBoundingBox",o=this.colorStops.map((d=>y({},d))).sort(((d,u)=>d.offset-u.offset));let a=-this.offsetX,l=-this.offsetY;var c;n==="objectBoundingBox"?(a/=t.width,l/=t.height):(a+=t.width/2,l+=t.height/2),(c=t)&&typeof c._renderPathCommands=="function"&&this.gradientUnits!=="percentage"&&(a-=t.pathOffset.x,l-=t.pathOffset.y),s[4]-=a,s[5]-=l;const h=['id="SVGID_'.concat(this.id,'"'),'gradientUnits="'.concat(n,'"'),'gradientTransform="'.concat(e?e+" ":"").concat(Ns(s),'"'),""].join(" ");if(this.type==="linear"){const{x1:d,y1:u,x2:p,y2:g}=this.coords;i.push("<linearGradient ",h,' x1="',d,'" y1="',u,'" x2="',p,'" y2="',g,`">
|
|
2360
|
+
`),e}getSvgStyles(){const t=this.opacity!==void 0&&this.opacity!==1?"opacity: ".concat(this.opacity,";"):"",e=this.visible?"":" visibility: hidden;";return[t,this.getSvgFilter(),e].join("")}toClipPathSVG(t){const e=[],i=this._createSVGBgRect(t);i&&e.push(" ",i);for(let s=0;s<this._objects.length;s++)e.push(" ",this._objects[s].toClipPathSVG(t));return this._createBaseClipPathSVGMarkup(e,{reviver:t})}static fromObject(t,e){let{type:i,objects:s=[],layoutManager:n}=t,o=rt(t,Sf);return Promise.all([Vs(s,e),dn(o,e)]).then((a=>{let[l,c]=a;const h=new this(l,y(y(y({},o),c),{},{layoutManager:new Tf}));if(n){const d=A.getClass(n.type),u=A.getClass(n.strategy);h.layoutManager=new d(new u)}else h.layoutManager=new Ys;return h.layoutManager.subscribeTargets({type:Ge,target:h,targets:h.getObjects()}),h.setCoords(),h}))}}v(gi,"type","Group"),v(gi,"ownDefaults",{strokeWidth:0,subTargetCheck:!1,interactive:!1}),A.setClass(gi);const Ef=(r,t)=>Math.min(t.width/r.width,t.height/r.height),Of=(r,t)=>Math.max(t.width/r.width,t.height/r.height),po="\\s*,?\\s*",xs="".concat(po,"(").concat(Se,")"),kf="".concat(xs).concat(xs).concat(xs).concat(po,"([01])").concat(po,"([01])").concat(xs).concat(xs),Pf={m:"l",M:"L"},Af=(r,t,e,i,s,n,o,a,l,c,h)=>{const d=Je(r),u=Qe(r),p=Je(t),g=Qe(t),f=e*s*p-i*n*g+o,m=i*s*p+e*n*g+a;return["C",c+l*(-e*s*u-i*n*d),h+l*(-i*s*u+e*n*d),f+l*(e*s*g+i*n*p),m+l*(i*s*g-e*n*p),f,m]},_l=(r,t,e,i)=>{const s=Math.atan2(t,r),n=Math.atan2(i,e);return n>=s?n-s:2*Math.PI-(s-n)};function xl(r,t,e,i,s,n,o,a){let l;if(W.cachesBoundsOfCurve&&(l=[...arguments].join(),Ds.boundsOfCurveCache[l]))return Ds.boundsOfCurveCache[l];const c=Math.sqrt,h=Math.abs,d=[],u=[[0,0],[0,0]];let p=6*r-12*e+6*s,g=-3*r+9*e-9*s+3*o,f=3*e-3*r;for(let S=0;S<2;++S){if(S>0&&(p=6*t-12*i+6*n,g=-3*t+9*i-9*n+3*a,f=3*i-3*t),h(g)<1e-12){if(h(p)<1e-12)continue;const P=-f/p;0<P&&P<1&&d.push(P);continue}const T=p*p-4*f*g;if(T<0)continue;const k=c(T),O=(-p+k)/(2*g);0<O&&O<1&&d.push(O);const E=(-p-k)/(2*g);0<E&&E<1&&d.push(E)}let m=d.length;const b=m,_=Xc(r,t,e,i,s,n,o,a);for(;m--;){const{x:S,y:T}=_(d[m]);u[0][m]=S,u[1][m]=T}u[0][b]=r,u[1][b]=t,u[0][b+1]=o,u[1][b+1]=a;const w=[new x(Math.min(...u[0]),Math.min(...u[1])),new x(Math.max(...u[0]),Math.max(...u[1]))];return W.cachesBoundsOfCurve&&(Ds.boundsOfCurveCache[l]=w),w}const Df=(r,t,e)=>{let[i,s,n,o,a,l,c,h]=e;const d=((u,p,g,f,m,b,_)=>{if(g===0||f===0)return[];let w=0,S=0,T=0;const k=Math.PI,O=_*Ao,E=Qe(O),P=Je(O),R=.5*(-P*u-E*p),L=.5*(-P*p+E*u),F=g**2,H=f**2,M=L**2,U=R**2,X=F*H-F*M-H*U;let J=Math.abs(g),N=Math.abs(f);if(X<0){const bt=Math.sqrt(1-X/(F*H));J*=bt,N*=bt}else T=(m===b?-1:1)*Math.sqrt(X/(F*M+H*U));const wt=T*J*L/N,Ut=-T*N*R/J,Wt=P*wt-E*Ut+.5*u,Pe=E*wt+P*Ut+.5*p;let de=_l(1,0,(R-wt)/J,(L-Ut)/N),Lt=_l((R-wt)/J,(L-Ut)/N,(-R-wt)/J,(-L-Ut)/N);b===0&&Lt>0?Lt-=2*k:b===1&&Lt<0&&(Lt+=2*k);const Ae=Math.ceil(Math.abs(Lt/k*2)),ae=[],At=Lt/Ae,Ft=8/3*Math.sin(At/4)*Math.sin(At/4)/Math.sin(At/2);let le=de+At;for(let bt=0;bt<Ae;bt++)ae[bt]=Af(de,le,P,E,J,N,Wt,Pe,Ft,w,S),w=ae[bt][5],S=ae[bt][6],de=le,le+=At;return ae})(c-r,h-t,s,n,a,l,o);for(let u=0,p=d.length;u<p;u++)d[u][1]+=r,d[u][2]+=t,d[u][3]+=r,d[u][4]+=t,d[u][5]+=r,d[u][6]+=t;return d},Mf=r=>{let t=0,e=0,i=0,s=0;const n=[];let o,a=0,l=0;for(const c of r){const h=[...c];let d;switch(h[0]){case"l":h[1]+=t,h[2]+=e;case"L":t=h[1],e=h[2],d=["L",t,e];break;case"h":h[1]+=t;case"H":t=h[1],d=["L",t,e];break;case"v":h[1]+=e;case"V":e=h[1],d=["L",t,e];break;case"m":h[1]+=t,h[2]+=e;case"M":t=h[1],e=h[2],i=h[1],s=h[2],d=["M",t,e];break;case"c":h[1]+=t,h[2]+=e,h[3]+=t,h[4]+=e,h[5]+=t,h[6]+=e;case"C":a=h[3],l=h[4],t=h[5],e=h[6],d=["C",h[1],h[2],a,l,t,e];break;case"s":h[1]+=t,h[2]+=e,h[3]+=t,h[4]+=e;case"S":o==="C"?(a=2*t-a,l=2*e-l):(a=t,l=e),t=h[3],e=h[4],d=["C",a,l,h[1],h[2],t,e],a=d[3],l=d[4];break;case"q":h[1]+=t,h[2]+=e,h[3]+=t,h[4]+=e;case"Q":a=h[1],l=h[2],t=h[3],e=h[4],d=["Q",a,l,t,e];break;case"t":h[1]+=t,h[2]+=e;case"T":o==="Q"?(a=2*t-a,l=2*e-l):(a=t,l=e),t=h[1],e=h[2],d=["Q",a,l,t,e];break;case"a":h[6]+=t,h[7]+=e;case"A":Df(t,e,h).forEach((u=>n.push(u))),t=h[6],e=h[7];break;case"z":case"Z":t=i,e=s,d=["Z"]}d?(n.push(d),o=d[0]):o=""}return n},qr=(r,t,e,i)=>Math.sqrt((e-r)**2+(i-t)**2),Xc=(r,t,e,i,s,n,o,a)=>l=>{const c=l**3,h=(p=>3*p**2*(1-p))(l),d=(p=>3*p*(1-p)**2)(l),u=(p=>(1-p)**3)(l);return new x(o*c+s*h+e*d+r*u,a*c+n*h+i*d+t*u)},qc=r=>r**2,Kc=r=>2*r*(1-r),Zc=r=>(1-r)**2,If=(r,t,e,i,s,n,o,a)=>l=>{const c=qc(l),h=Kc(l),d=Zc(l),u=3*(d*(e-r)+h*(s-e)+c*(o-s)),p=3*(d*(i-t)+h*(n-i)+c*(a-n));return Math.atan2(p,u)},Lf=(r,t,e,i,s,n)=>o=>{const a=qc(o),l=Kc(o),c=Zc(o);return new x(s*a+e*l+r*c,n*a+i*l+t*c)},Ff=(r,t,e,i,s,n)=>o=>{const a=1-o,l=2*(a*(e-r)+o*(s-e)),c=2*(a*(i-t)+o*(n-i));return Math.atan2(c,l)},wl=(r,t,e)=>{let i=new x(t,e),s=0;for(let n=1;n<=100;n+=1){const o=r(n/100);s+=qr(i.x,i.y,o.x,o.y),i=o}return s},jf=(r,t)=>{let e,i=0,s=0,n={x:r.x,y:r.y},o=y({},n),a=.01,l=0;const c=r.iterator,h=r.angleFinder;for(;s<t&&a>1e-4;)o=c(i),l=i,e=qr(n.x,n.y,o.x,o.y),e+s>t?(i-=a,a/=2):(n=o,i+=a,s+=e);return y(y({},o),{},{angle:h(l)})},Jc=r=>{let t,e,i=0,s=0,n=0,o=0,a=0;const l=[];for(const c of r){const h={x:s,y:n,command:c[0],length:0};switch(c[0]){case"M":e=h,e.x=o=s=c[1],e.y=a=n=c[2];break;case"L":e=h,e.length=qr(s,n,c[1],c[2]),s=c[1],n=c[2];break;case"C":t=Xc(s,n,c[1],c[2],c[3],c[4],c[5],c[6]),e=h,e.iterator=t,e.angleFinder=If(s,n,c[1],c[2],c[3],c[4],c[5],c[6]),e.length=wl(t,s,n),s=c[5],n=c[6];break;case"Q":t=Lf(s,n,c[1],c[2],c[3],c[4]),e=h,e.iterator=t,e.angleFinder=Ff(s,n,c[1],c[2],c[3],c[4]),e.length=wl(t,s,n),s=c[3],n=c[4];break;case"Z":e=h,e.destX=o,e.destY=a,e.length=qr(s,n,o,a),s=o,n=a}i+=e.length,l.push(e)}return l.push({length:i,x:s,y:n}),l},$f=function(r,t){let e=arguments.length>2&&arguments[2]!==void 0?arguments[2]:Jc(r),i=0;for(;t-e[i].length>0&&i<e.length-2;)t-=e[i].length,i++;const s=e[i],n=t/s.length,o=r[i];switch(s.command){case"M":return{x:s.x,y:s.y,angle:0};case"Z":return y(y({},new x(s.x,s.y).lerp(new x(s.destX,s.destY),n)),{},{angle:Math.atan2(s.destY-s.y,s.destX-s.x)});case"L":return y(y({},new x(s.x,s.y).lerp(new x(o[1],o[2]),n)),{},{angle:Math.atan2(o[2]-s.y,o[1]-s.x)});case"C":case"Q":return jf(s,t)}},Rf=new RegExp("[mzlhvcsqta][^mzlhvcsqta]*","gi"),Cl=new RegExp(kf,"g"),Bf=new RegExp(Se,"gi"),zf={m:2,l:2,h:1,v:1,c:6,s:4,q:4,t:2,a:7},Hf=r=>{var t;const e=[],i=(t=r.match(Rf))!==null&&t!==void 0?t:[];for(const s of i){const n=s[0];if(n==="z"||n==="Z"){e.push([n]);continue}const o=zf[n.toLowerCase()];let a=[];if(n==="a"||n==="A"){Cl.lastIndex=0;for(let l=null;l=Cl.exec(s);)a.push(...l.slice(1))}else a=s.match(Bf)||[];for(let l=0;l<a.length;l+=o){const c=new Array(o),h=Pf[n];c[0]=l>0&&h?h:n;for(let d=0;d<o;d++)c[d+1]=parseFloat(a[l+d]);e.push(c)}}return e},Vf=(r,t)=>r.map((e=>e.map(((i,s)=>s===0||t===void 0?i:tt(i,t))).join(" "))).join(" ");function go(r,t){const e=r.style;e&&t&&(typeof t=="string"?e.cssText+=";"+t:Object.entries(t).forEach((i=>{let[s,n]=i;return e.setProperty(s,n)})))}class Nf extends Sc{constructor(t){let{allowTouchScrolling:e=!1,containerClass:i=""}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};super(t),v(this,"upper",void 0),v(this,"container",void 0);const{el:s}=this.lower,n=this.createUpperCanvas();this.upper={el:n,ctx:n.getContext("2d")},this.applyCanvasStyle(s,{allowTouchScrolling:e}),this.applyCanvasStyle(n,{allowTouchScrolling:e,styles:{position:"absolute",left:"0",top:"0"}});const o=this.createContainerElement();o.classList.add(i),s.parentNode&&s.parentNode.replaceChild(o,s),o.append(s,n),this.container=o}createUpperCanvas(){const{el:t}=this.lower,e=ti();return e.className=t.className,e.classList.remove("lower-canvas"),e.classList.add("upper-canvas"),e.setAttribute("data-fabric","top"),e.style.cssText=t.style.cssText,e.setAttribute("draggable","true"),e}createContainerElement(){const t=ss().createElement("div");return t.setAttribute("data-fabric","wrapper"),go(t,{position:"relative"}),Xa(t),t}applyCanvasStyle(t,e){const{styles:i,allowTouchScrolling:s}=e;go(t,y(y({},i),{},{"touch-action":s?"manipulation":se})),Xa(t)}setDimensions(t,e){super.setDimensions(t,e);const{el:i,ctx:s}=this.upper;Cc(i,s,t,e)}setCSSDimensions(t){super.setCSSDimensions(t),no(this.upper.el,t),no(this.container,t)}cleanupDOM(t){const e=this.container,{el:i}=this.lower,{el:s}=this.upper;super.cleanupDOM(t),e.removeChild(s),e.removeChild(i),e.parentNode&&e.parentNode.replaceChild(i,e)}dispose(){super.dispose(),Re().dispose(this.upper.el),delete this.upper,delete this.container}}class mn extends Js{constructor(){super(...arguments),v(this,"targets",[]),v(this,"_hoveredTargets",[]),v(this,"_currentTransform",null),v(this,"_groupSelector",null),v(this,"contextTopDirty",!1)}static getDefaults(){return y(y({},super.getDefaults()),mn.ownDefaults)}get upperCanvasEl(){var t;return(t=this.elements.upper)===null||t===void 0?void 0:t.el}get contextTop(){var t;return(t=this.elements.upper)===null||t===void 0?void 0:t.ctx}get wrapperEl(){return this.elements.container}initElements(t){this.elements=new Nf(t,{allowTouchScrolling:this.allowTouchScrolling,containerClass:this.containerClass}),this._createCacheCanvas()}_onObjectAdded(t){this._objectsToRender=void 0,super._onObjectAdded(t)}_onObjectRemoved(t){this._objectsToRender=void 0,t===this._activeObject&&(this.fire("before:selection:cleared",{deselected:[t]}),this._discardActiveObject(),this.fire("selection:cleared",{deselected:[t]}),t.fire("deselected",{target:t})),t===this._hoveredTarget&&(this._hoveredTarget=void 0,this._hoveredTargets=[]),super._onObjectRemoved(t)}_onStackOrderChanged(){this._objectsToRender=void 0,super._onStackOrderChanged()}_chooseObjectsToRender(){const t=this._activeObject;return!this.preserveObjectStacking&&t?this._objects.filter((e=>!e.group&&e!==t)).concat(t):this._objects}renderAll(){this.cancelRequestedRender(),this.destroyed||(!this.contextTopDirty||this._groupSelector||this.isDrawingMode||(this.clearContext(this.contextTop),this.contextTopDirty=!1),this.hasLostContext&&(this.renderTopLayer(this.contextTop),this.hasLostContext=!1),!this._objectsToRender&&(this._objectsToRender=this._chooseObjectsToRender()),this.renderCanvas(this.getContext(),this._objectsToRender))}renderTopLayer(t){t.save(),this.isDrawingMode&&this._isCurrentlyDrawing&&(this.freeDrawingBrush&&this.freeDrawingBrush._render(),this.contextTopDirty=!0),this.selection&&this._groupSelector&&(this._drawSelection(t),this.contextTopDirty=!0),t.restore()}renderTop(){const t=this.contextTop;this.clearContext(t),this.renderTopLayer(t),this.fire("after:render",{ctx:t})}setTargetFindTolerance(t){t=Math.round(t),this.targetFindTolerance=t;const e=this.getRetinaScaling(),i=Math.ceil((2*t+1)*e);this.pixelFindCanvasEl.width=this.pixelFindCanvasEl.height=i,this.pixelFindContext.scale(e,e)}isTargetTransparent(t,e,i){const s=this.targetFindTolerance,n=this.pixelFindContext;this.clearContext(n),n.save(),n.translate(-e+s,-i+s),n.transform(...this.viewportTransform);const o=t.selectionBackgroundColor;t.selectionBackgroundColor="",t.render(n),t.selectionBackgroundColor=o,n.restore();const a=Math.round(s*this.getRetinaScaling());return Yg(n,a,a,a)}_isSelectionKeyPressed(t){const e=this.selectionKey;return!!e&&(Array.isArray(e)?!!e.find((i=>!!i&&t[i]===!0)):t[e])}_shouldClearSelection(t,e){const i=this.getActiveObjects(),s=this._activeObject;return!!(!e||e&&s&&i.length>1&&i.indexOf(e)===-1&&s!==e&&!this._isSelectionKeyPressed(t)||e&&!e.evented||e&&!e.selectable&&s&&s!==e)}_shouldCenterTransform(t,e,i){if(!t)return;let s;return e===cn||e===oe||e===be||e===Hs?s=this.centeredScaling||t.centeredScaling:e===Io&&(s=this.centeredRotation||t.centeredRotation),s?!i:i}_getOriginFromCorner(t,e){const i={x:t.originX,y:t.originY};return e&&(["ml","tl","bl"].includes(e)?i.x=yt:["mr","tr","br"].includes(e)&&(i.x=Y),["tl","mt","tr"].includes(e)?i.y=ro:["bl","mb","br"].includes(e)&&(i.y=ie)),i}_setupCurrentTransform(t,e,i){var s;const n=e.group?Zi(this.getScenePoint(t),void 0,e.group.calcTransformMatrix()):this.getScenePoint(t),{key:o="",control:a}=e.getActiveControl()||{},l=i&&a?(s=a.getActionHandler(t,e,a))===null||s===void 0?void 0:s.bind(a):lg,c=((p,g,f,m)=>{if(!g||!p)return"drag";const b=m.controls[g];return b.getActionName(f,b,m)})(i,o,t,e),h=t[this.centeredKey],d=this._shouldCenterTransform(e,c,h)?{x:V,y:V}:this._getOriginFromCorner(e,o),u={target:e,action:c,actionHandler:l,actionPerformed:!1,corner:o,scaleX:e.scaleX,scaleY:e.scaleY,skewX:e.skewX,skewY:e.skewY,offsetX:n.x-e.left,offsetY:n.y-e.top,originX:d.x,originY:d.y,ex:n.x,ey:n.y,lastX:n.x,lastY:n.y,theta:_t(e.angle),width:e.width,height:e.height,shiftKey:t.shiftKey,altKey:h,original:y(y({},Tc(e)),{},{originX:d.x,originY:d.y})};this._currentTransform=u,this.fire("before:transform",{e:t,transform:u})}setCursor(t){this.upperCanvasEl.style.cursor=t}_drawSelection(t){const{x:e,y:i,deltaX:s,deltaY:n}=this._groupSelector,o=new x(e,i).transform(this.viewportTransform),a=new x(e+s,i+n).transform(this.viewportTransform),l=this.selectionLineWidth/2;let c=Math.min(o.x,a.x),h=Math.min(o.y,a.y),d=Math.max(o.x,a.x),u=Math.max(o.y,a.y);this.selectionColor&&(t.fillStyle=this.selectionColor,t.fillRect(c,h,d-c,u-h)),this.selectionLineWidth&&this.selectionBorderColor&&(t.lineWidth=this.selectionLineWidth,t.strokeStyle=this.selectionBorderColor,c+=l,h+=l,d-=l,u-=l,Ht.prototype._setLineDash.call(this,t,this.selectionDashArray),t.strokeRect(c,h,d-c,u-h))}findTarget(t){if(this.skipTargetFind)return;const e=this.getViewportPoint(t),i=this._activeObject,s=this.getActiveObjects();if(this.targets=[],i&&s.length>=1){if(i.findControl(e,oo(t))||s.length>1&&this.searchPossibleTargets([i],e))return i;if(i===this.searchPossibleTargets([i],e)){if(this.preserveObjectStacking){const n=this.targets;this.targets=[];const o=this.searchPossibleTargets(this._objects,e);return t[this.altSelectionKey]&&o&&o!==i?(this.targets=n,i):o}return i}}return this.searchPossibleTargets(this._objects,e)}_pointIsInObjectSelectionArea(t,e){let i=t.getCoords();const s=this.getZoom(),n=t.padding/s;if(n){const[o,a,l,c]=i,h=Math.atan2(a.y-o.y,a.x-o.x),d=Je(h)*n,u=Qe(h)*n,p=d+u,g=d-u;i=[new x(o.x-g,o.y-p),new x(a.x+p,a.y-g),new x(l.x+g,l.y+p),new x(c.x-p,c.y+g)]}return lt.isPointInPolygon(e,i)}_checkTarget(t,e){return!!(t&&t.visible&&t.evented&&this._pointIsInObjectSelectionArea(t,Zi(e,void 0,this.viewportTransform))&&(!this.perPixelTargetFind&&!t.perPixelTargetFind||t.isEditing||!this.isTargetTransparent(t,e.x,e.y)))}_searchPossibleTargets(t,e){let i=t.length;for(;i--;){const s=t[i];if(this._checkTarget(s,e)){if(Dr(s)&&s.subTargetCheck){const n=this._searchPossibleTargets(s._objects,e);n&&this.targets.push(n)}return s}}}searchPossibleTargets(t,e){const i=this._searchPossibleTargets(t,e);if(i&&Dr(i)&&i.interactive&&this.targets[0]){const s=this.targets;for(let n=s.length-1;n>0;n--){const o=s[n];if(!Dr(o)||!o.interactive)return o}return s[0]}return i}getViewportPoint(t){return this._pointer?this._pointer:this.getPointer(t,!0)}getScenePoint(t){return this._absolutePointer?this._absolutePointer:this.getPointer(t)}getPointer(t){let e=arguments.length>1&&arguments[1]!==void 0&&arguments[1];const i=this.upperCanvasEl,s=i.getBoundingClientRect();let n=eg(t),o=s.width||0,a=s.height||0;o&&a||(ie in s&&ro in s&&(a=Math.abs(s.top-s.bottom)),yt in s&&Y in s&&(o=Math.abs(s.right-s.left))),this.calcOffset(),n.x=n.x-this._offset.left,n.y=n.y-this._offset.top,e||(n=Zi(n,void 0,this.viewportTransform));const l=this.getRetinaScaling();l!==1&&(n.x/=l,n.y/=l);const c=o===0||a===0?new x(1,1):new x(i.width/o,i.height/a);return n.multiply(c)}_setDimensionsImpl(t,e){this._resetTransformEventData(),super._setDimensionsImpl(t,e),this._isCurrentlyDrawing&&this.freeDrawingBrush&&this.freeDrawingBrush._setBrushStyles(this.contextTop)}_createCacheCanvas(){this.pixelFindCanvasEl=ti(),this.pixelFindContext=this.pixelFindCanvasEl.getContext("2d",{willReadFrequently:!0}),this.setTargetFindTolerance(this.targetFindTolerance)}getTopContext(){return this.elements.upper.ctx}getSelectionContext(){return this.elements.upper.ctx}getSelectionElement(){return this.elements.upper.el}getActiveObject(){return this._activeObject}getActiveObjects(){const t=this._activeObject;return Ti(t)?t.getObjects():t?[t]:[]}_fireSelectionEvents(t,e){let i=!1,s=!1;const n=this.getActiveObjects(),o=[],a=[];t.forEach((l=>{n.includes(l)||(i=!0,l.fire("deselected",{e,target:l}),a.push(l))})),n.forEach((l=>{t.includes(l)||(i=!0,l.fire("selected",{e,target:l}),o.push(l))})),t.length>0&&n.length>0?(s=!0,i&&this.fire("selection:updated",{e,selected:o,deselected:a})):n.length>0?(s=!0,this.fire("selection:created",{e,selected:o})):t.length>0&&(s=!0,this.fire("selection:cleared",{e,deselected:a})),s&&(this._objectsToRender=void 0)}setActiveObject(t,e){const i=this.getActiveObjects(),s=this._setActiveObject(t,e);return this._fireSelectionEvents(i,e),s}_setActiveObject(t,e){const i=this._activeObject;return i!==t&&!(!this._discardActiveObject(e,t)&&this._activeObject)&&!t.onSelect({e})&&(this._activeObject=t,Ti(t)&&i!==t&&t.set("canvas",this),t.setCoords(),!0)}_discardActiveObject(t,e){const i=this._activeObject;return!!i&&!i.onDeselect({e:t,object:e})&&(this._currentTransform&&this._currentTransform.target===i&&this.endCurrentTransform(t),Ti(i)&&i===this._hoveredTarget&&(this._hoveredTarget=void 0),this._activeObject=void 0,!0)}discardActiveObject(t){const e=this.getActiveObjects(),i=this.getActiveObject();e.length&&this.fire("before:selection:cleared",{e:t,deselected:[i]});const s=this._discardActiveObject(t);return this._fireSelectionEvents(e,t),s}endCurrentTransform(t){const e=this._currentTransform;this._finalizeCurrentTransform(t),e&&e.target&&(e.target.isMoving=!1),this._currentTransform=null}_finalizeCurrentTransform(t){const e=this._currentTransform,i=e.target,s={e:t,target:i,transform:e,action:e.action};i._scaling&&(i._scaling=!1),i.setCoords(),e.actionPerformed&&(this.fire("object:modified",s),i.fire(zr,s))}setViewportTransform(t){super.setViewportTransform(t);const e=this._activeObject;e&&e.setCoords()}destroy(){const t=this._activeObject;Ti(t)&&(t.removeAll(),t.dispose()),delete this._activeObject,super.destroy(),this.pixelFindContext=null,this.pixelFindCanvasEl=void 0}clear(){this.discardActiveObject(),this._activeObject=void 0,this.clearContext(this.contextTop),super.clear()}drawControls(t){const e=this._activeObject;e&&e._renderControls(t)}_toObject(t,e,i){const s=this._realizeGroupTransformOnObject(t),n=super._toObject(t,e,i);return t.set(s),n}_realizeGroupTransformOnObject(t){const{group:e}=t;if(e&&Ti(e)&&this._activeObject===e){const i=as(t,["angle","flipX","flipY",Y,oe,be,rs,ns,ie]);return sg(t,e.calcOwnMatrix()),i}return{}}_setSVGObject(t,e,i){const s=this._realizeGroupTransformOnObject(e);super._setSVGObject(t,e,i),e.set(s)}}v(mn,"ownDefaults",{uniformScaling:!0,uniScaleKey:"shiftKey",centeredScaling:!1,centeredRotation:!1,centeredKey:"altKey",altActionKey:"shiftKey",selection:!0,selectionKey:"shiftKey",selectionColor:"rgba(100, 100, 255, 0.3)",selectionDashArray:[],selectionBorderColor:"rgba(255, 255, 255, 0.3)",selectionLineWidth:1,selectionFullyContained:!1,hoverCursor:"move",moveCursor:"move",defaultCursor:"default",freeDrawingCursor:"crosshair",notAllowedCursor:"not-allowed",perPixelTargetFind:!1,targetFindTolerance:0,skipTargetFind:!1,stopContextMenu:!1,fireRightClick:!1,fireMiddleClick:!1,enablePointerEvents:!1,containerClass:"canvas-container",preserveObjectStacking:!1});class Uf{constructor(t){v(this,"targets",[]),v(this,"__disposer",void 0);const e=()=>{const{hiddenTextarea:s}=t.getActiveObject()||{};s&&s.focus()},i=t.upperCanvasEl;i.addEventListener("click",e),this.__disposer=()=>i.removeEventListener("click",e)}exitTextEditing(){this.target=void 0,this.targets.forEach((t=>{t.isEditing&&t.exitEditing()}))}add(t){this.targets.push(t)}remove(t){this.unregister(t),Yi(this.targets,t)}register(t){this.target=t}unregister(t){t===this.target&&(this.target=void 0)}onMouseMove(t){var e;!((e=this.target)===null||e===void 0)&&e.isEditing&&this.target.updateSelectionOnMouseMove(t)}clear(){this.targets=[],this.target=void 0}dispose(){this.clear(),this.__disposer(),delete this.__disposer}}const Wf=["target","oldTarget","fireCanvas","e"],ce={passive:!1},Ui=(r,t)=>{const e=r.getViewportPoint(t),i=r.getScenePoint(t);return{viewportPoint:e,scenePoint:i,pointer:e,absolutePointer:i}},li=function(r){for(var t=arguments.length,e=new Array(t>1?t-1:0),i=1;i<t;i++)e[i-1]=arguments[i];return r.addEventListener(...e)},ue=function(r){for(var t=arguments.length,e=new Array(t>1?t-1:0),i=1;i<t;i++)e[i-1]=arguments[i];return r.removeEventListener(...e)},Yf={mouse:{in:"over",out:"out",targetIn:"mouseover",targetOut:"mouseout",canvasIn:"mouse:over",canvasOut:"mouse:out"},drag:{in:"enter",out:"leave",targetIn:"dragenter",targetOut:"dragleave",canvasIn:"drag:enter",canvasOut:"drag:leave"}};class fo extends mn{constructor(t){super(t,arguments.length>1&&arguments[1]!==void 0?arguments[1]:{}),v(this,"_isClick",void 0),v(this,"textEditingManager",new Uf(this)),["_onMouseDown","_onTouchStart","_onMouseMove","_onMouseUp","_onTouchEnd","_onResize","_onMouseWheel","_onMouseOut","_onMouseEnter","_onContextMenu","_onClick","_onDragStart","_onDragEnd","_onDragProgress","_onDragOver","_onDragEnter","_onDragLeave","_onDrop"].forEach((e=>{this[e]=this[e].bind(this)})),this.addOrRemove(li,"add")}_getEventPrefix(){return this.enablePointerEvents?"pointer":"mouse"}addOrRemove(t,e){const i=this.upperCanvasEl,s=this._getEventPrefix();t(wc(i),"resize",this._onResize),t(i,s+"down",this._onMouseDown),t(i,"".concat(s,"move"),this._onMouseMove,ce),t(i,"".concat(s,"out"),this._onMouseOut),t(i,"".concat(s,"enter"),this._onMouseEnter),t(i,"wheel",this._onMouseWheel,{passive:!1}),t(i,"contextmenu",this._onContextMenu),t(i,"click",this._onClick),t(i,"dblclick",this._onClick),t(i,"dragstart",this._onDragStart),t(i,"dragend",this._onDragEnd),t(i,"dragover",this._onDragOver),t(i,"dragenter",this._onDragEnter),t(i,"dragleave",this._onDragLeave),t(i,"drop",this._onDrop),this.enablePointerEvents||t(i,"touchstart",this._onTouchStart,ce)}removeListeners(){this.addOrRemove(ue,"remove");const t=this._getEventPrefix(),e=we(this.upperCanvasEl);ue(e,"".concat(t,"up"),this._onMouseUp),ue(e,"touchend",this._onTouchEnd,ce),ue(e,"".concat(t,"move"),this._onMouseMove,ce),ue(e,"touchmove",this._onMouseMove,ce),clearTimeout(this._willAddMouseDown)}_onMouseWheel(t){this.__onMouseWheel(t)}_onMouseOut(t){const e=this._hoveredTarget,i=y({e:t},Ui(this,t));this.fire("mouse:out",y(y({},i),{},{target:e})),this._hoveredTarget=void 0,e&&e.fire("mouseout",y({},i)),this._hoveredTargets.forEach((s=>{this.fire("mouse:out",y(y({},i),{},{target:s})),s&&s.fire("mouseout",y({},i))})),this._hoveredTargets=[]}_onMouseEnter(t){this._currentTransform||this.findTarget(t)||(this.fire("mouse:over",y({e:t},Ui(this,t))),this._hoveredTarget=void 0,this._hoveredTargets=[])}_onDragStart(t){this._isClick=!1;const e=this.getActiveObject();if(e&&e.onDragStart(t)){this._dragSource=e;const i={e:t,target:e};return this.fire("dragstart",i),e.fire("dragstart",i),void li(this.upperCanvasEl,"drag",this._onDragProgress)}qa(t)}_renderDragEffects(t,e,i){let s=!1;const n=this._dropTarget;n&&n!==e&&n!==i&&(n.clearContextTop(),s=!0),e==null||e.clearContextTop(),i!==e&&(i==null||i.clearContextTop());const o=this.contextTop;o.save(),o.transform(...this.viewportTransform),e&&(o.save(),e.transform(o),e.renderDragSourceEffect(t),o.restore(),s=!0),i&&(o.save(),i.transform(o),i.renderDropTargetEffect(t),o.restore(),s=!0),o.restore(),s&&(this.contextTopDirty=!0)}_onDragEnd(t){const e=!!t.dataTransfer&&t.dataTransfer.dropEffect!==se,i=e?this._activeObject:void 0,s={e:t,target:this._dragSource,subTargets:this.targets,dragSource:this._dragSource,didDrop:e,dropTarget:i};ue(this.upperCanvasEl,"drag",this._onDragProgress),this.fire("dragend",s),this._dragSource&&this._dragSource.fire("dragend",s),delete this._dragSource,this._onMouseUp(t)}_onDragProgress(t){const e={e:t,target:this._dragSource,dragSource:this._dragSource,dropTarget:this._draggedoverTarget};this.fire("drag",e),this._dragSource&&this._dragSource.fire("drag",e)}findDragTargets(t){return this.targets=[],{target:this._searchPossibleTargets(this._objects,this.getViewportPoint(t)),targets:[...this.targets]}}_onDragOver(t){const e="dragover",{target:i,targets:s}=this.findDragTargets(t),n=this._dragSource,o={e:t,target:i,subTargets:s,dragSource:n,canDrop:!1,dropTarget:void 0};let a;this.fire(e,o),this._fireEnterLeaveEvents(i,o),i&&(i.canDrop(t)&&(a=i),i.fire(e,o));for(let l=0;l<s.length;l++){const c=s[l];c.canDrop(t)&&(a=c),c.fire(e,o)}this._renderDragEffects(t,n,a),this._dropTarget=a}_onDragEnter(t){const{target:e,targets:i}=this.findDragTargets(t),s={e:t,target:e,subTargets:i,dragSource:this._dragSource};this.fire("dragenter",s),this._fireEnterLeaveEvents(e,s)}_onDragLeave(t){const e={e:t,target:this._draggedoverTarget,subTargets:this.targets,dragSource:this._dragSource};this.fire("dragleave",e),this._fireEnterLeaveEvents(void 0,e),this._renderDragEffects(t,this._dragSource),this._dropTarget=void 0,this.targets=[],this._hoveredTargets=[]}_onDrop(t){const{target:e,targets:i}=this.findDragTargets(t),s=this._basicEventHandler("drop:before",y({e:t,target:e,subTargets:i,dragSource:this._dragSource},Ui(this,t)));s.didDrop=!1,s.dropTarget=void 0,this._basicEventHandler("drop",s),this.fire("drop:after",s)}_onContextMenu(t){const e=this.findTarget(t),i=this.targets||[],s=this._basicEventHandler("contextmenu:before",{e:t,target:e,subTargets:i});return this.stopContextMenu&&qa(t),this._basicEventHandler("contextmenu",s),!1}_onClick(t){const e=t.detail;e>3||e<2||(this._cacheTransformEventData(t),e==2&&t.type==="dblclick"&&this._handleEvent(t,"dblclick"),e==3&&this._handleEvent(t,"tripleclick"),this._resetTransformEventData())}getPointerId(t){const e=t.changedTouches;return e?e[0]&&e[0].identifier:this.enablePointerEvents?t.pointerId:-1}_isMainEvent(t){return t.isPrimary===!0||t.isPrimary!==!1&&(t.type==="touchend"&&t.touches.length===0||!t.changedTouches||t.changedTouches[0].identifier===this.mainTouchId)}_onTouchStart(t){let e=!this.allowTouchScrolling;const i=this._activeObject;this.mainTouchId===void 0&&(this.mainTouchId=this.getPointerId(t)),this.__onMouseDown(t),(this.isDrawingMode||i&&this._target===i)&&(e=!0),e&&t.preventDefault(),this._resetTransformEventData();const s=this.upperCanvasEl,n=this._getEventPrefix(),o=we(s);li(o,"touchend",this._onTouchEnd,ce),e&&li(o,"touchmove",this._onMouseMove,ce),ue(s,"".concat(n,"down"),this._onMouseDown)}_onMouseDown(t){this.__onMouseDown(t),this._resetTransformEventData();const e=this.upperCanvasEl,i=this._getEventPrefix();ue(e,"".concat(i,"move"),this._onMouseMove,ce);const s=we(e);li(s,"".concat(i,"up"),this._onMouseUp),li(s,"".concat(i,"move"),this._onMouseMove,ce)}_onTouchEnd(t){if(t.touches.length>0)return;this.__onMouseUp(t),this._resetTransformEventData(),delete this.mainTouchId;const e=this._getEventPrefix(),i=we(this.upperCanvasEl);ue(i,"touchend",this._onTouchEnd,ce),ue(i,"touchmove",this._onMouseMove,ce),this._willAddMouseDown&&clearTimeout(this._willAddMouseDown),this._willAddMouseDown=setTimeout((()=>{li(this.upperCanvasEl,"".concat(e,"down"),this._onMouseDown),this._willAddMouseDown=0}),400)}_onMouseUp(t){this.__onMouseUp(t),this._resetTransformEventData();const e=this.upperCanvasEl,i=this._getEventPrefix();if(this._isMainEvent(t)){const s=we(this.upperCanvasEl);ue(s,"".concat(i,"up"),this._onMouseUp),ue(s,"".concat(i,"move"),this._onMouseMove,ce),li(e,"".concat(i,"move"),this._onMouseMove,ce)}}_onMouseMove(t){const e=this.getActiveObject();!this.allowTouchScrolling&&(!e||!e.shouldStartDragging(t))&&t.preventDefault&&t.preventDefault(),this.__onMouseMove(t)}_onResize(){this.calcOffset(),this._resetTransformEventData()}_shouldRender(t){const e=this.getActiveObject();return!!e!=!!t||e&&t&&e!==t}__onMouseUp(t){var e;this._cacheTransformEventData(t),this._handleEvent(t,"up:before");const i=this._currentTransform,s=this._isClick,n=this._target,{button:o}=t;if(o)return(this.fireMiddleClick&&o===1||this.fireRightClick&&o===2)&&this._handleEvent(t,"up"),void this._resetTransformEventData();if(this.isDrawingMode&&this._isCurrentlyDrawing)return void this._onMouseUpInDrawingMode(t);if(!this._isMainEvent(t))return;let a,l,c=!1;if(i&&(this._finalizeCurrentTransform(t),c=i.actionPerformed),!s){const h=n===this._activeObject;this.handleSelection(t),c||(c=this._shouldRender(n)||!h&&n===this._activeObject)}if(n){const h=n.findControl(this.getViewportPoint(t),oo(t)),{key:d,control:u}=h||{};if(l=d,n.selectable&&n!==this._activeObject&&n.activeOn==="up")this.setActiveObject(n,t),c=!0;else if(u){const p=u.getMouseUpHandler(t,n,u);p&&(a=this.getScenePoint(t),p.call(u,t,i,a.x,a.y))}n.isMoving=!1}if(i&&(i.target!==n||i.corner!==l)){const h=i.target&&i.target.controls[i.corner],d=h&&h.getMouseUpHandler(t,i.target,h);a=a||this.getScenePoint(t),d&&d.call(h,t,i,a.x,a.y)}this._setCursorFromEvent(t,n),this._handleEvent(t,"up"),this._groupSelector=null,this._currentTransform=null,n&&(n.__corner=void 0),c?this.requestRenderAll():s||(e=this._activeObject)!==null&&e!==void 0&&e.isEditing||this.renderTop()}_basicEventHandler(t,e){const{target:i,subTargets:s=[]}=e;this.fire(t,e),i&&i.fire(t,e);for(let n=0;n<s.length;n++)s[n]!==i&&s[n].fire(t,e);return e}_handleEvent(t,e,i){const s=this._target,n=this.targets||[],o=y(y(y({e:t,target:s,subTargets:n},Ui(this,t)),{},{transform:this._currentTransform},e==="up:before"||e==="up"?{isClick:this._isClick,currentTarget:this.findTarget(t),currentSubTargets:this.targets}:{}),e==="down:before"||e==="down"?i:{});this.fire("mouse:".concat(e),o),s&&s.fire("mouse".concat(e),o);for(let a=0;a<n.length;a++)n[a]!==s&&n[a].fire("mouse".concat(e),o)}_onMouseDownInDrawingMode(t){this._isCurrentlyDrawing=!0,this.getActiveObject()&&(this.discardActiveObject(t),this.requestRenderAll());const e=this.getScenePoint(t);this.freeDrawingBrush&&this.freeDrawingBrush.onMouseDown(e,{e:t,pointer:e}),this._handleEvent(t,"down",{alreadySelected:!1})}_onMouseMoveInDrawingMode(t){if(this._isCurrentlyDrawing){const e=this.getScenePoint(t);this.freeDrawingBrush&&this.freeDrawingBrush.onMouseMove(e,{e:t,pointer:e})}this.setCursor(this.freeDrawingCursor),this._handleEvent(t,"move")}_onMouseUpInDrawingMode(t){const e=this.getScenePoint(t);this.freeDrawingBrush?this._isCurrentlyDrawing=!!this.freeDrawingBrush.onMouseUp({e:t,pointer:e}):this._isCurrentlyDrawing=!1,this._handleEvent(t,"up")}__onMouseDown(t){this._isClick=!0,this._cacheTransformEventData(t),this._handleEvent(t,"down:before");let e=this._target,i=!!e&&e===this._activeObject;const{button:s}=t;if(s)return(this.fireMiddleClick&&s===1||this.fireRightClick&&s===2)&&this._handleEvent(t,"down",{alreadySelected:i}),void this._resetTransformEventData();if(this.isDrawingMode)return void this._onMouseDownInDrawingMode(t);if(!this._isMainEvent(t)||this._currentTransform)return;let n=this._shouldRender(e),o=!1;if(this.handleMultiSelection(t,e)?(e=this._activeObject,o=!0,n=!0):this._shouldClearSelection(t,e)&&this.discardActiveObject(t),this.selection&&(!e||!e.selectable&&!e.isEditing&&e!==this._activeObject)){const a=this.getScenePoint(t);this._groupSelector={x:a.x,y:a.y,deltaY:0,deltaX:0}}if(i=!!e&&e===this._activeObject,e){e.selectable&&e.activeOn==="down"&&this.setActiveObject(e,t);const a=e.findControl(this.getViewportPoint(t),oo(t));if(e===this._activeObject&&(a||!o)){this._setupCurrentTransform(t,e,i);const l=a?a.control:void 0,c=this.getScenePoint(t),h=l&&l.getMouseDownHandler(t,e,l);h&&h.call(l,t,this._currentTransform,c.x,c.y)}}n&&(this._objectsToRender=void 0),this._handleEvent(t,"down",{alreadySelected:i}),n&&this.requestRenderAll()}_resetTransformEventData(){this._target=this._pointer=this._absolutePointer=void 0}_cacheTransformEventData(t){this._resetTransformEventData(),this._pointer=this.getViewportPoint(t),this._absolutePointer=Zi(this._pointer,void 0,this.viewportTransform),this._target=this._currentTransform?this._currentTransform.target:this.findTarget(t)}__onMouseMove(t){if(this._isClick=!1,this._cacheTransformEventData(t),this._handleEvent(t,"move:before"),this.isDrawingMode)return void this._onMouseMoveInDrawingMode(t);if(!this._isMainEvent(t))return;const e=this._groupSelector;if(e){const i=this.getScenePoint(t);e.deltaX=i.x-e.x,e.deltaY=i.y-e.y,this.renderTop()}else if(this._currentTransform)this._transformObject(t);else{const i=this.findTarget(t);this._setCursorFromEvent(t,i),this._fireOverOutEvents(t,i)}this.textEditingManager.onMouseMove(t),this._handleEvent(t,"move"),this._resetTransformEventData()}_fireOverOutEvents(t,e){const i=this._hoveredTarget,s=this._hoveredTargets,n=this.targets,o=Math.max(s.length,n.length);this.fireSyntheticInOutEvents("mouse",{e:t,target:e,oldTarget:i,fireCanvas:!0});for(let a=0;a<o;a++)n[a]===e||s[a]&&s[a]===i||this.fireSyntheticInOutEvents("mouse",{e:t,target:n[a],oldTarget:s[a]});this._hoveredTarget=e,this._hoveredTargets=this.targets.concat()}_fireEnterLeaveEvents(t,e){const i=this._draggedoverTarget,s=this._hoveredTargets,n=this.targets,o=Math.max(s.length,n.length);this.fireSyntheticInOutEvents("drag",y(y({},e),{},{target:t,oldTarget:i,fireCanvas:!0}));for(let a=0;a<o;a++)this.fireSyntheticInOutEvents("drag",y(y({},e),{},{target:n[a],oldTarget:s[a]}));this._draggedoverTarget=t}fireSyntheticInOutEvents(t,e){let{target:i,oldTarget:s,fireCanvas:n,e:o}=e,a=rt(e,Wf);const{targetIn:l,targetOut:c,canvasIn:h,canvasOut:d}=Yf[t],u=s!==i;if(s&&u){const p=y(y({},a),{},{e:o,target:s,nextTarget:i},Ui(this,o));n&&this.fire(d,p),s.fire(c,p)}if(i&&u){const p=y(y({},a),{},{e:o,target:i,previousTarget:s},Ui(this,o));n&&this.fire(h,p),i.fire(l,p)}}__onMouseWheel(t){this._cacheTransformEventData(t),this._handleEvent(t,"wheel"),this._resetTransformEventData()}_transformObject(t){const e=this.getScenePoint(t),i=this._currentTransform,s=i.target,n=s.group?Zi(e,void 0,s.group.calcTransformMatrix()):e;i.shiftKey=t.shiftKey,i.altKey=!!this.centeredKey&&t[this.centeredKey],this._performTransformAction(t,i,n),i.actionPerformed&&this.requestRenderAll()}_performTransformAction(t,e,i){const{action:s,actionHandler:n,target:o}=e,a=!!n&&n(t,e,i.x,i.y);a&&o.setCoords(),s==="drag"&&a&&(e.target.isMoving=!0,this.setCursor(e.target.moveCursor||this.moveCursor)),e.actionPerformed=e.actionPerformed||a}_setCursorFromEvent(t,e){if(!e)return void this.setCursor(this.defaultCursor);let i=e.hoverCursor||this.hoverCursor;const s=Ti(this._activeObject)?this._activeObject:null,n=(!s||e.group!==s)&&e.findControl(this.getViewportPoint(t));if(n){const o=n.control;this.setCursor(o.cursorStyleHandler(t,o,e))}else e.subTargetCheck&&this.targets.concat().reverse().map((o=>{i=o.hoverCursor||i})),this.setCursor(i)}handleMultiSelection(t,e){const i=this._activeObject,s=Ti(i);if(i&&this._isSelectionKeyPressed(t)&&this.selection&&e&&e.selectable&&(i!==e||s)&&(s||!e.isDescendantOf(i)&&!i.isDescendantOf(e))&&!e.onSelect({e:t})&&!i.getActiveControl()){if(s){const n=i.getObjects();if(e===i){const o=this.getViewportPoint(t);if(!(e=this.searchPossibleTargets(n,o)||this.searchPossibleTargets(this._objects,o))||!e.selectable)return!1}e.group===i?(i.remove(e),this._hoveredTarget=e,this._hoveredTargets=[...this.targets],i.size()===1&&this._setActiveObject(i.item(0),t)):(i.multiSelectAdd(e),this._hoveredTarget=i,this._hoveredTargets=[...this.targets]),this._fireSelectionEvents(n,t)}else{i.isEditing&&i.exitEditing();const n=new(A.getClass("ActiveSelection"))([],{canvas:this});n.multiSelectAdd(i,e),this._hoveredTarget=n,this._setActiveObject(n,t),this._fireSelectionEvents([i],t)}return!0}return!1}handleSelection(t){if(!this.selection||!this._groupSelector)return!1;const{x:e,y:i,deltaX:s,deltaY:n}=this._groupSelector,o=new x(e,i),a=o.add(new x(s,n)),l=o.min(a),c=o.max(a).subtract(l),h=this.collectObjects({left:l.x,top:l.y,width:c.x,height:c.y},{includeIntersecting:!this.selectionFullyContained}),d=o.eq(a)?h[0]?[h[0]]:[]:h.length>1?h.filter((u=>!u.onSelect({e:t}))).reverse():h;if(d.length===1)this.setActiveObject(d[0],t);else if(d.length>1){const u=A.getClass("ActiveSelection");this.setActiveObject(new u(d,{canvas:this}),t)}return this._groupSelector=null,!0}toCanvasElement(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:1,e=arguments.length>1?arguments[1]:void 0;const{upper:i}=this.elements;i.ctx=void 0;const s=super.toCanvasElement(t,e);return i.ctx=i.el.getContext("2d"),s}clear(){this.textEditingManager.clear(),super.clear()}destroy(){this.removeListeners(),this.textEditingManager.dispose(),super.destroy()}}const Qc={x1:0,y1:0,x2:0,y2:0},Gf=y(y({},Qc),{},{r1:0,r2:0}),qi=(r,t)=>isNaN(r)&&typeof t=="number"?t:r;function th(r){return r&&/%$/.test(r)&&Number.isFinite(parseFloat(r))}function eh(r,t){const e=typeof r=="number"?r:typeof r=="string"?parseFloat(r)/(th(r)?100:1):NaN;return es(0,qi(e,t),1)}const Xf=/\s*;\s*/,qf=/\s*:\s*/;function Kf(r,t){let e,i;const s=r.getAttribute("style");if(s){const o=s.split(Xf);o[o.length-1]===""&&o.pop();for(let a=o.length;a--;){const[l,c]=o[a].split(qf).map((h=>h.trim()));l==="stop-color"?e=c:l==="stop-opacity"&&(i=c)}}const n=new q(e||r.getAttribute("stop-color")||"rgb(0,0,0)");return{offset:eh(r.getAttribute("offset"),0),color:n.toRgb(),opacity:qi(parseFloat(i||r.getAttribute("stop-opacity")||""),1)*n.getAlpha()*t}}function Zf(r,t){const e=[],i=r.getElementsByTagName("stop"),s=eh(t,1);for(let n=i.length;n--;)e.push(Kf(i[n],s));return e}function ih(r){return r.nodeName==="linearGradient"||r.nodeName==="LINEARGRADIENT"?"linear":"radial"}function sh(r){return r.getAttribute("gradientUnits")==="userSpaceOnUse"?"pixels":"percentage"}function ye(r,t){return r.getAttribute(t)}function Jf(r,t){return(function(e,i){let s,{width:n,height:o,gradientUnits:a}=i;return Object.entries(e).reduce(((l,c)=>{let[h,d]=c;if(d==="Infinity")s=1;else if(d==="-Infinity")s=0;else{const u=typeof d=="string";s=u?parseFloat(d):d,u&&th(d)&&(s*=.01,a==="pixels"&&(h!=="x1"&&h!=="x2"&&h!=="r2"||(s*=n),h!=="y1"&&h!=="y2"||(s*=o)))}return l[h]=s,l}),{})})(ih(r)==="linear"?(function(e){return{x1:ye(e,"x1")||0,y1:ye(e,"y1")||0,x2:ye(e,"x2")||"100%",y2:ye(e,"y2")||0}})(r):(function(e){return{x1:ye(e,"fx")||ye(e,"cx")||"50%",y1:ye(e,"fy")||ye(e,"cy")||"50%",r1:0,x2:ye(e,"cx")||"50%",y2:ye(e,"cy")||"50%",r2:ye(e,"r")||"50%"}})(r),y(y({},t),{},{gradientUnits:sh(r)}))}class ar{constructor(t){const{type:e="linear",gradientUnits:i="pixels",coords:s={},colorStops:n=[],offsetX:o=0,offsetY:a=0,gradientTransform:l,id:c}=t||{};Object.assign(this,{type:e,gradientUnits:i,coords:y(y({},e==="radial"?Gf:Qc),s),colorStops:n,offsetX:o,offsetY:a,gradientTransform:l,id:c?"".concat(c,"_").concat(mi()):mi()})}addColorStop(t){for(const e in t){const i=new q(t[e]);this.colorStops.push({offset:parseFloat(e),color:i.toRgb(),opacity:i.getAlpha()})}return this}toObject(t){return y(y({},as(this,t)),{},{type:this.type,coords:y({},this.coords),colorStops:this.colorStops.map((e=>y({},e))),offsetX:this.offsetX,offsetY:this.offsetY,gradientUnits:this.gradientUnits,gradientTransform:this.gradientTransform?[...this.gradientTransform]:void 0})}toSVG(t){let{additionalTransform:e}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};const i=[],s=this.gradientTransform?this.gradientTransform.concat():Kt.concat(),n=this.gradientUnits==="pixels"?"userSpaceOnUse":"objectBoundingBox",o=this.colorStops.map((d=>y({},d))).sort(((d,u)=>d.offset-u.offset));let a=-this.offsetX,l=-this.offsetY;var c;n==="objectBoundingBox"?(a/=t.width,l/=t.height):(a+=t.width/2,l+=t.height/2),(c=t)&&typeof c._renderPathCommands=="function"&&this.gradientUnits!=="percentage"&&(a-=t.pathOffset.x,l-=t.pathOffset.y),s[4]-=a,s[5]-=l;const h=['id="SVGID_'.concat(this.id,'"'),'gradientUnits="'.concat(n,'"'),'gradientTransform="'.concat(e?e+" ":"").concat(Ns(s),'"'),""].join(" ");if(this.type==="linear"){const{x1:d,y1:u,x2:p,y2:g}=this.coords;i.push("<linearGradient ",h,' x1="',d,'" y1="',u,'" x2="',p,'" y2="',g,`">
|
|
2361
2361
|
`)}else if(this.type==="radial"){const{x1:d,y1:u,x2:p,y2:g,r1:f,r2:m}=this.coords,b=f>m;i.push("<radialGradient ",h,' cx="',b?d:p,'" cy="',b?u:g,'" r="',b?f:m,'" fx="',b?p:d,'" fy="',b?g:u,`">
|
|
2362
2362
|
`),b&&(o.reverse(),o.forEach((w=>{w.offset=1-w.offset})));const _=Math.min(f,m);if(_>0){const w=_/Math.max(f,m);o.forEach((S=>{S.offset+=w*(1-S.offset)}))}}return o.forEach((d=>{let{color:u,offset:p,opacity:g}=d;i.push("<stop ",'offset="',100*p+"%",'" style="stop-color:',u,g!==void 0?";stop-opacity: "+g:";",`"/>
|
|
2363
2363
|
`)})),i.push(this.type==="linear"?"</linearGradient>":"</radialGradient>",`
|
|
2364
|
-
`),i.join("")}toLive(t){const{x1:e,y1:i,x2:s,y2:n,r1:o,r2:a}=this.coords,l=this.type==="linear"?t.createLinearGradient(e,i,s,n):t.createRadialGradient(e,i,o,s,n,a);return this.colorStops.forEach((c=>{let{color:h,opacity:d,offset:u}=c;l.addColorStop(u,d!==void 0?new
|
|
2365
|
-
`)}static async fromObject(t,e){let{type:i,source:s,patternTransform:n}=t,o=rt(t,Qf);const a=await Ir(s,y(y({},e),{},{crossOrigin:o.crossOrigin}));return new this(y(y({},o),{},{patternTransform:n&&n.slice(0),source:a}))}}v(Bn,"type","Pattern"),A.setClass(Bn),A.setClass(Bn,"pattern");const tm=["path","left","top"],em=["d"];class
|
|
2366
|
-
`)]}_getOffsetTransform(){const t=W.NUM_FRACTION_DIGITS;return" translate(".concat(
|
|
2367
|
-
`];{const{radius:e}=this,i=
|
|
2368
|
-
`]}}static async fromElement(t,e,i){const s=ni(t,this.ATTRIBUTE_NAMES,i),{left:n=0,top:o=0,radius:a=0}=s;return new this(y(y({},rt(s,im)),{},{radius:a,left:n-a,top:o-a}))}static fromObject(t){return super._fromObject(t)}}v(We,"type","Circle"),v(We,"cacheProperties",[...ri,...
|
|
2369
|
-
`)]}static async fromElement(t,e,i){const s=ni(t,this.ATTRIBUTE_NAMES,i),{x1:n=0,y1:o=0,x2:a=0,y2:l=0}=s;return new this([n,o,a,l],rt(s,sm))}static fromObject(t){let{x1:e,y1:i,x2:s,y2:n}=t,o=rt(t,rm);return this._fromObject(y(y({},o),{},{points:[e,i,s,n]}),{extraParam:"points"})}}v(
|
|
2370
|
-
`)]}_render(t){t.beginPath(),t.save(),t.transform(1,0,0,this.ry/this.rx,0,0),t.arc(0,0,this.rx,0,Rr,!1),t.restore(),this._renderPaintInOrder(t)}static async fromElement(t,e,i){const s=ni(t,this.ATTRIBUTE_NAMES,i);return s.left=(s.left||0)-s.rx,s.top=(s.top||0)-s.ry,new this(s)}}function nm(r){if(!r)return[];const t=r.replace(/,/g," ").trim().split(/\s+/),e=[];for(let i=0;i<t.length;i+=2)e.push({x:parseFloat(t[i]),y:parseFloat(t[i+1])});return e}v(Ye,"type","Ellipse"),v(Ye,"cacheProperties",[...ri,...
|
|
2371
|
-
`)]}_render(t){const e=this.points.length,i=this.pathOffset.x,s=this.pathOffset.y;if(e&&!isNaN(this.points[e-1].y)){t.beginPath(),t.moveTo(this.points[0].x-i,this.points[0].y-s);for(let n=0;n<e;n++){const o=this.points[n];t.lineTo(o.x-i,o.y-s)}!this.isOpen()&&t.closePath(),this._renderPaintInOrder(t)}}complexity(){return this.points.length}static async fromElement(t,e,i){return new this(nm(t.getAttribute("points")),y(y({},rt(ni(t,this.ATTRIBUTE_NAMES,i),om)),e))}static fromObject(t){return this._fromObject(t,{extraParam:"points"})}}v(xe,"ownDefaults",
|
|
2372
|
-
`)}const cm=["textAnchor","textDecoration","dx","dy","top","left","fontSize","strokeWidth"];let Hn;class Gt extends lh{static getDefaults(){return y(y({},super.getDefaults()),Gt.ownDefaults)}constructor(t,e){super(),v(this,"__charBounds",[]),Object.assign(this,Gt.ownDefaults),this.setOptions(e),this.styles||(this.styles={}),this.text=t,this.initialized=!0,this.path&&this.setPathInfo(),this.initDimensions(),this.setCoords()}setPathInfo(){const t=this.path;t&&(t.segmentsInfo=Qc(t.path))}_splitText(){const t=this._splitTextIntoLines(this.text);return this.textLines=t.lines,this._textLines=t.graphemeLines,this._unwrappedTextLines=t._unwrappedLines,this._text=t.graphemeText,t}initDimensions(){this._splitText(),this._clearCache(),this.dirty=!0,this.path?(this.width=this.path.width,this.height=this.path.height):(this.width=this.calcTextWidth()||this.cursorWidth||this.MIN_TEXT_WIDTH,this.height=this.calcTextHeight()),this.textAlign.includes(Le)&&this.enlargeSpaces()}enlargeSpaces(){let t,e,i,s,n,o,a;for(let l=0,c=this._textLines.length;l<c;l++)if((this.textAlign===Le||l!==c-1&&!this.isEndOfWrapping(l))&&(s=0,n=this._textLines[l],e=this.getLineWidth(l),e<this.width&&(a=this.textLines[l].match(this._reSpacesAndTabs)))){i=a.length,t=(this.width-e)/i;for(let h=0;h<=n.length;h++)o=this.__charBounds[l][h],this._reSpaceAndTab.test(n[h])?(o.width+=t,o.kernedWidth+=t,o.left+=s,s+=t):o.left+=s}}isEndOfWrapping(t){return t===this._textLines.length-1}missingNewlineOffset(t){return 1}get2DCursorLocation(t,e){const i=e?this._unwrappedTextLines:this._textLines;let s;for(s=0;s<i.length;s++){if(t<=i[s].length)return{lineIndex:s,charIndex:t};t-=i[s].length+this.missingNewlineOffset(s,e)}return{lineIndex:s-1,charIndex:i[s-1].length<t?i[s-1].length:t}}toString(){return"#<Text (".concat(this.complexity(),'): { "text": "').concat(this.text,'", "fontFamily": "').concat(this.fontFamily,'" }>')}_getCacheCanvasDimensions(){const t=super._getCacheCanvasDimensions(),e=this.fontSize;return t.width+=e*t.zoomX,t.height+=e*t.zoomY,t}_render(t){const e=this.path;e&&!e.isNotVisible()&&e._render(t),this._setTextStyles(t),this._renderTextLinesBackground(t),this._renderTextDecoration(t,"underline"),this._renderText(t),this._renderTextDecoration(t,"overline"),this._renderTextDecoration(t,"linethrough")}_renderText(t){this.paintFirst===re?(this._renderTextStroke(t),this._renderTextFill(t)):(this._renderTextFill(t),this._renderTextStroke(t))}_setTextStyles(t,e,i){if(t.textBaseline="alphabetic",this.path)switch(this.pathAlign){case V:t.textBaseline="middle";break;case"ascender":t.textBaseline=ie;break;case"descender":t.textBaseline=ro}t.font=this._getFontDeclaration(e,i)}calcTextWidth(){let t=this.getLineWidth(0);for(let e=1,i=this._textLines.length;e<i;e++){const s=this.getLineWidth(e);s>t&&(t=s)}return t}_renderTextLine(t,e,i,s,n,o){this._renderChars(t,e,i,s,n,o)}_renderTextLinesBackground(t){if(!this.textBackgroundColor&&!this.styleHas("textBackgroundColor"))return;const e=t.fillStyle,i=this._getLeftOffset();let s=this._getTopOffset();for(let n=0,o=this._textLines.length;n<o;n++){const a=this.getHeightOfLine(n);if(!this.textBackgroundColor&&!this.styleHas("textBackgroundColor",n)){s+=a;continue}const l=this._textLines[n].length,c=this._getLineLeftOffset(n);let h,d,u=0,p=0,g=this.getValueOfPropertyAt(n,0,"textBackgroundColor");const f=this.getHeightOfLineImpl(n);for(let m=0;m<l;m++){const b=this.__charBounds[n][m];d=this.getValueOfPropertyAt(n,m,"textBackgroundColor"),this.path?(t.save(),t.translate(b.renderLeft,b.renderTop),t.rotate(b.angle),t.fillStyle=d,d&&t.fillRect(-b.width/2,-f*(1-this._fontSizeFraction),b.width,f),t.restore()):d!==g?(h=i+c+p,this.direction==="rtl"&&(h=this.width-h-u),t.fillStyle=g,g&&t.fillRect(h,s,u,f),p=b.left,u=b.width,g=d):u+=b.kernedWidth}d&&!this.path&&(h=i+c+p,this.direction==="rtl"&&(h=this.width-h-u),t.fillStyle=d,t.fillRect(h,s,u,f)),s+=a}t.fillStyle=e,this._removeShadow(t)}_measureChar(t,e,i,s){const n=Ds.getFontCache(e),o=this._getFontDeclaration(e),a=i?i+t:t,l=i&&o===this._getFontDeclaration(s),c=e.fontSize/this.CACHE_FONT_SIZE;let h,d,u,p;if(i&&n.has(i)&&(u=n.get(i)),n.has(t)&&(p=h=n.get(t)),l&&n.has(a)&&(d=n.get(a),p=d-u),h===void 0||u===void 0||d===void 0){const g=(function(){return Hn||(Hn=ve({width:0,height:0}).getContext("2d")),Hn})();this._setTextStyles(g,e,!0),h===void 0&&(p=h=g.measureText(t).width,n.set(t,h)),u===void 0&&l&&i&&(u=g.measureText(i).width,n.set(i,u)),l&&d===void 0&&(d=g.measureText(a).width,n.set(a,d),p=d-u)}return{width:h*c,kernedWidth:p*c}}getHeightOfChar(t,e){return this.getValueOfPropertyAt(t,e,"fontSize")}measureLine(t){const e=this._measureLine(t);return this.charSpacing!==0&&(e.width-=this._getWidthOfCharSpacing()),e.width<0&&(e.width=0),e}_measureLine(t){let e,i,s=0;const n=this.pathSide===_t,o=this.path,a=this._textLines[t],l=a.length,c=new Array(l);this.__charBounds[t]=c;for(let h=0;h<l;h++){const d=a[h];i=this._getGraphemeBox(d,t,h,e),c[h]=i,s+=i.kernedWidth,e=d}if(c[l]={left:i?i.left+i.width:0,width:0,kernedWidth:0,height:this.fontSize,deltaY:0},o&&o.segmentsInfo){let h=0;const d=o.segmentsInfo[o.segmentsInfo.length-1].length;switch(this.textAlign){case Y:h=n?d-s:0;break;case V:h=(d-s)/2;break;case _t:h=n?0:d-s}h+=this.pathStartOffset*(n?-1:1);for(let u=n?l-1:0;n?u>=0:u<l;n?u--:u++)i=c[u],h>d?h%=d:h<0&&(h+=d),this._setGraphemeOnPath(h,i),h+=i.kernedWidth}return{width:s,numOfSpaces:0}}_setGraphemeOnPath(t,e){const i=t+e.kernedWidth/2,s=this.path,n=$f(s.path,i,s.segmentsInfo);e.renderLeft=n.x-s.pathOffset.x,e.renderTop=n.y-s.pathOffset.y,e.angle=n.angle+(this.pathSide===_t?Math.PI:0)}_getGraphemeBox(t,e,i,s,n){const o=this.getCompleteStyleDeclaration(e,i),a=s?this.getCompleteStyleDeclaration(e,i-1):{},l=this._measureChar(t,o,s,a);let c,h=l.kernedWidth,d=l.width;this.charSpacing!==0&&(c=this._getWidthOfCharSpacing(),d+=c,h+=c);const u={width:d,left:0,height:o.fontSize,kernedWidth:h,deltaY:o.deltaY};if(i>0&&!n){const p=this.__charBounds[e][i-1];u.left=p.left+p.width+l.kernedWidth-l.width}return u}getHeightOfLineImpl(t){const e=this.__lineHeights;if(e[t])return e[t];let i=this.getHeightOfChar(t,0);for(let s=1,n=this._textLines[t].length;s<n;s++)i=Math.max(this.getHeightOfChar(t,s),i);return e[t]=i*this._fontSizeMult}getHeightOfLine(t){return this.getHeightOfLineImpl(t)*this.lineHeight}calcTextHeight(){let t=0;for(let e=0,i=this._textLines.length;e<i;e++)t+=e===i-1?this.getHeightOfLineImpl(e):this.getHeightOfLine(e);return t}_getLeftOffset(){return this.direction==="ltr"?-this.width/2:this.width/2}_getTopOffset(){return-this.height/2}_renderTextCommon(t,e){t.save();let i=0;const s=this._getLeftOffset(),n=this._getTopOffset();for(let o=0,a=this._textLines.length;o<a;o++)this._renderTextLine(e,t,this._textLines[o],s+this._getLineLeftOffset(o),n+i+this.getHeightOfLineImpl(o),o),i+=this.getHeightOfLine(o);t.restore()}_renderTextFill(t){(this.fill||this.styleHas(Dt))&&this._renderTextCommon(t,"fillText")}_renderTextStroke(t){(this.stroke&&this.strokeWidth!==0||!this.isEmptyStyles())&&(this.shadow&&!this.shadow.affectStroke&&this._removeShadow(t),t.save(),this._setLineDash(t,this.strokeDashArray),t.beginPath(),this._renderTextCommon(t,"strokeText"),t.closePath(),t.restore())}_renderChars(t,e,i,s,n,o){const a=this.textAlign.includes(Le),l=this.path,c=!a&&this.charSpacing===0&&this.isEmptyStyles(o)&&!l,h=this.direction==="ltr",d=this.direction==="ltr"?1:-1,u=e.direction;let p,g,f,m,b,_="",w=0;if(e.save(),u!==this.direction&&(e.canvas.setAttribute("dir",h?"ltr":"rtl"),e.direction=h?"ltr":"rtl",e.textAlign=h?Y:_t),n-=this.getHeightOfLineImpl(o)*this._fontSizeFraction,c)return this._renderChar(t,e,o,0,i.join(""),s,n),void e.restore();for(let S=0,T=i.length-1;S<=T;S++)m=S===T||this.charSpacing||l,_+=i[S],f=this.__charBounds[o][S],w===0?(s+=d*(f.kernedWidth-f.width),w+=f.width):w+=f.kernedWidth,a&&!m&&this._reSpaceAndTab.test(i[S])&&(m=!0),m||(p=p||this.getCompleteStyleDeclaration(o,S),g=this.getCompleteStyleDeclaration(o,S+1),m=Wo(p,g,!1)),m&&(l?(e.save(),e.translate(f.renderLeft,f.renderTop),e.rotate(f.angle),this._renderChar(t,e,o,S,_,-w/2,0),e.restore()):(b=s,this._renderChar(t,e,o,S,_,b,n)),_="",p=g,s+=d*w,w=0);e.restore()}_applyPatternGradientTransformText(t){const e=this.width+this.strokeWidth,i=this.height+this.strokeWidth,s=ve({width:e,height:i}),n=s.getContext("2d");return s.width=e,s.height=i,n.beginPath(),n.moveTo(0,0),n.lineTo(e,0),n.lineTo(e,i),n.lineTo(0,i),n.closePath(),n.translate(e/2,i/2),n.fillStyle=t.toLive(n),this._applyPatternGradientTransform(n,t),n.fill(),n.createPattern(s,"no-repeat")}handleFiller(t,e,i){let s,n;return ge(i)?i.gradientUnits==="percentage"||i.gradientTransform||i.patternTransform?(s=-this.width/2,n=-this.height/2,t.translate(s,n),t[e]=this._applyPatternGradientTransformText(i),{offsetX:s,offsetY:n}):(t[e]=i.toLive(t),this._applyPatternGradientTransform(t,i)):(t[e]=i,{offsetX:0,offsetY:0})}_setStrokeStyles(t,e){let{stroke:i,strokeWidth:s}=e;return t.lineWidth=s,t.lineCap=this.strokeLineCap,t.lineDashOffset=this.strokeDashOffset,t.lineJoin=this.strokeLineJoin,t.miterLimit=this.strokeMiterLimit,this.handleFiller(t,"strokeStyle",i)}_setFillStyles(t,e){let{fill:i}=e;return this.handleFiller(t,"fillStyle",i)}_renderChar(t,e,i,s,n,o,a){const l=this._getStyleDeclaration(i,s),c=this.getCompleteStyleDeclaration(i,s),h=t==="fillText"&&c.fill,d=t==="strokeText"&&c.stroke&&c.strokeWidth;if(d||h){if(e.save(),e.font=this._getFontDeclaration(c),l.textBackgroundColor&&this._removeShadow(e),l.deltaY&&(a+=l.deltaY),h){const u=this._setFillStyles(e,c);e.fillText(n,o-u.offsetX,a-u.offsetY)}if(d){const u=this._setStrokeStyles(e,c);e.strokeText(n,o-u.offsetX,a-u.offsetY)}e.restore()}}setSuperscript(t,e){this._setScript(t,e,this.superscript)}setSubscript(t,e){this._setScript(t,e,this.subscript)}_setScript(t,e,i){const s=this.get2DCursorLocation(t,!0),n=this.getValueOfPropertyAt(s.lineIndex,s.charIndex,"fontSize"),o=this.getValueOfPropertyAt(s.lineIndex,s.charIndex,"deltaY"),a={fontSize:n*i.size,deltaY:o+n*i.baseline};this.setSelectionStyles(a,t,e)}_getLineLeftOffset(t){const e=this.getLineWidth(t),i=this.width-e,s=this.textAlign,n=this.direction,o=this.isEndOfWrapping(t);let a=0;return s===Le||s===Is&&!o||s===Ms&&!o||s===Yr&&!o?0:(s===V&&(a=i/2),s===_t&&(a=i),s===Is&&(a=i/2),s===Ms&&(a=i),n==="rtl"&&(s===_t||s===Le||s===Ms?a=0:s===Y||s===Yr?a=-i:s!==V&&s!==Is||(a=-i/2)),a)}_clearCache(){this._forceClearCache=!1,this.__lineWidths=[],this.__lineHeights=[],this.__charBounds=[]}getLineWidth(t){if(this.__lineWidths[t]!==void 0)return this.__lineWidths[t];const{width:e}=this.measureLine(t);return this.__lineWidths[t]=e,e}_getWidthOfCharSpacing(){return this.charSpacing!==0?this.fontSize*this.charSpacing/1e3:0}getValueOfPropertyAt(t,e,i){var s;return(s=this._getStyleDeclaration(t,e)[i])!==null&&s!==void 0?s:this[i]}_renderTextDecoration(t,e){if(!this[e]&&!this.styleHas(e))return;let i=this._getTopOffset();const s=this._getLeftOffset(),n=this.path,o=this._getWidthOfCharSpacing(),a=e==="linethrough"?.5:e==="overline"?1:0,l=this.offsets[e];for(let c=0,h=this._textLines.length;c<h;c++){const d=this.getHeightOfLine(c);if(!this[e]&&!this.styleHas(e,c)){i+=d;continue}const u=this._textLines[c],p=d/this.lineHeight,g=this._getLineLeftOffset(c);let f=0,m=0,b=this.getValueOfPropertyAt(c,0,e),_=this.getValueOfPropertyAt(c,0,Dt),w=this.getValueOfPropertyAt(c,0,Ri),S=b,T=_,k=w;const O=i+p*(1-this._fontSizeFraction);let E=this.getHeightOfChar(c,0),P=this.getValueOfPropertyAt(c,0,"deltaY");for(let F=0,H=u.length;F<H;F++){const M=this.__charBounds[c][F];S=this.getValueOfPropertyAt(c,F,e),T=this.getValueOfPropertyAt(c,F,Dt),k=this.getValueOfPropertyAt(c,F,Ri);const U=this.getHeightOfChar(c,F),X=this.getValueOfPropertyAt(c,F,"deltaY");if(n&&S&&T){const Q=this.fontSize*k/1e3;t.save(),t.fillStyle=_,t.translate(M.renderLeft,M.renderTop),t.rotate(M.angle),t.fillRect(-M.kernedWidth/2,l*U+X-a*Q,M.kernedWidth,Q),t.restore()}else if((S!==b||T!==_||U!==E||k!==w||X!==P)&&m>0){const Q=this.fontSize*w/1e3;let N=s+g+f;this.direction==="rtl"&&(N=this.width-N-m),b&&_&&w&&(t.fillStyle=_,t.fillRect(N,O+l*E+P-a*Q,m,Q)),f=M.left,m=M.width,b=S,w=k,_=T,E=U,P=X}else m+=M.kernedWidth}let R=s+g+f;this.direction==="rtl"&&(R=this.width-R-m),t.fillStyle=T;const L=this.fontSize*k/1e3;S&&T&&k&&t.fillRect(R,O+l*E+P-a*L,m-o,L),i+=d}this._removeShadow(t)}_getFontDeclaration(){let{fontFamily:t=this.fontFamily,fontStyle:e=this.fontStyle,fontWeight:i=this.fontWeight,fontSize:s=this.fontSize}=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},n=arguments.length>1?arguments[1]:void 0;const o=t.includes("'")||t.includes('"')||t.includes(",")||Gt.genericFonts.includes(t.toLowerCase())?t:'"'.concat(t,'"');return[e,i,"".concat(n?this.CACHE_FONT_SIZE:s,"px"),o].join(" ")}render(t){this.visible&&(this.canvas&&this.canvas.skipOffscreen&&!this.group&&!this.isOnScreen()||(this._forceClearCache&&this.initDimensions(),super.render(t)))}graphemeSplit(t){return Uo(t)}_splitTextIntoLines(t){const e=t.split(this._reNewline),i=new Array(e.length),s=[`
|
|
2373
|
-
`];let n=[];for(let o=0;o<e.length;o++)i[o]=this.graphemeSplit(e[o]),n=n.concat(i[o],s);return n.pop(),{_unwrappedLines:i,lines:e,graphemeText:n,graphemeLines:i}}toObject(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[];return y(y({},super.toObject([...
|
|
2374
|
-
`]}_getSVGTextAndBg(r,t){const e=[],i=[];let s,n=r;this.backgroundColor&&i.push(...zn(this.backgroundColor,-this.width/2,-this.height/2,this.width,this.height));for(let o=0,a=this._textLines.length;o<a;o++)s=this._getLineLeftOffset(o),this.direction==="rtl"&&(s+=this.width),(this.textBackgroundColor||this.styleHas("textBackgroundColor",o))&&this._setSVGTextLineBg(i,o,t+s,n),this._setSVGTextLineText(e,o,t+s,n),n+=this.getHeightOfLine(o);return{textSpans:e,textBgRects:i}}_createTextCharSpan(r,t,e,i,s){const n=W.NUM_FRACTION_DIGITS,o=this.getSvgSpanStyles(t,r!==r.trim()||!!r.match(am)),a=o?'style="'.concat(o,'"'):"",l=t.deltaY,c=l?' dy="'.concat(et(l,n),'" '):"",{angle:h,renderLeft:d,renderTop:u,width:p}=s;let g="";if(d!==void 0){const f=p/2;h&&(g=' rotate="'.concat(et(ei(h),n),'"'));const m=os({angle:ei(h)});m[4]=d,m[5]=u;const b=new x(-f,0).transform(m);e=b.x,i=b.y}return'<tspan x="'.concat(et(e,n),'" y="').concat(et(i,n),'" ').concat(c).concat(g).concat(a,">").concat(Kg(r),"</tspan>")}_setSVGTextLineText(r,t,e,i){const s=this.getHeightOfLine(t),n=this.textAlign.includes(Le),o=this._textLines[t];let a,l,c,h,d,u="",p=0;i+=s*(1-this._fontSizeFraction)/this.lineHeight;for(let g=0,f=o.length-1;g<=f;g++)d=g===f||this.charSpacing||this.path,u+=o[g],c=this.__charBounds[t][g],p===0?(e+=c.kernedWidth-c.width,p+=c.width):p+=c.kernedWidth,n&&!d&&this._reSpaceAndTab.test(o[g])&&(d=!0),d||(a=a||this.getCompleteStyleDeclaration(t,g),l=this.getCompleteStyleDeclaration(t,g+1),d=Wo(a,l,!0)),d&&(h=this._getStyleDeclaration(t,g),r.push(this._createTextCharSpan(u,h,e,i,c)),u="",a=l,this.direction==="rtl"?e-=p:e+=p,p=0)}_setSVGTextLineBg(r,t,e,i){const s=this._textLines[t],n=this.getHeightOfLine(t)/this.lineHeight;let o,a=0,l=0,c=this.getValueOfPropertyAt(t,0,"textBackgroundColor");for(let h=0;h<s.length;h++){const{left:d,width:u,kernedWidth:p}=this.__charBounds[t][h];o=this.getValueOfPropertyAt(t,h,"textBackgroundColor"),o!==c?(c&&r.push(...zn(c,e+l,i,a,n)),l=d,a=u,c=o):a+=p}o&&r.push(...zn(c,e+l,i,a,n))}_getSVGLineTopOffset(r){let t,e=0;for(t=0;t<r;t++)e+=this.getHeightOfLine(t);const i=this.getHeightOfLine(t);return{lineTop:e,offset:(this._fontSizeMult-this._fontSizeFraction)*i/(this.lineHeight*this._fontSizeMult)}}getSvgStyles(r){return"".concat(super.getSvgStyles(r)," text-decoration-thickness: ").concat(et(this.textDecorationThickness*this.getObjectScaling().y/10,W.NUM_FRACTION_DIGITS),"%; white-space: pre;")}getSvgSpanStyles(r,t){const{fontFamily:e,strokeWidth:i,stroke:s,fill:n,fontSize:o,fontStyle:a,fontWeight:l,deltaY:c,textDecorationThickness:h,linethrough:d,overline:u,underline:p}=r,g=this.getSvgTextDecoration({underline:p??this.underline,overline:u??this.overline,linethrough:d??this.linethrough}),f=h||this.textDecorationThickness;return[s?Us(re,s):"",i?"stroke-width: ".concat(i,"; "):"",e?"font-family: ".concat(e.includes("'")||e.includes('"')?e:"'".concat(e,"'"),"; "):"",o?"font-size: ".concat(o,"px; "):"",a?"font-style: ".concat(a,"; "):"",l?"font-weight: ".concat(l,"; "):"",g?"text-decoration: ".concat(g,"; text-decoration-thickness: ").concat(et(f*this.getObjectScaling().y/10,W.NUM_FRACTION_DIGITS),"%; "):"",n?Us(Dt,n):"",c?"baseline-shift: ".concat(-c,"; "):"",t?"white-space: pre; ":""].join("")}getSvgTextDecoration(r){return["overline","underline","line-through"].filter((t=>r[t.replace("-","")])).join(" ")}}]),A.setClass(Gt),A.setSVGClass(Gt);class hm{constructor(t){v(this,"target",void 0),v(this,"__mouseDownInPlace",!1),v(this,"__dragStartFired",!1),v(this,"__isDraggingOver",!1),v(this,"__dragStartSelection",void 0),v(this,"__dragImageDisposer",void 0),v(this,"_dispose",void 0),this.target=t;const e=[this.target.on("dragenter",this.dragEnterHandler.bind(this)),this.target.on("dragover",this.dragOverHandler.bind(this)),this.target.on("dragleave",this.dragLeaveHandler.bind(this)),this.target.on("dragend",this.dragEndHandler.bind(this)),this.target.on("drop",this.dropHandler.bind(this))];this._dispose=()=>{e.forEach((i=>i())),this._dispose=void 0}}isPointerOverSelection(t){const e=this.target,i=e.getSelectionStartFromPointer(t);return e.isEditing&&i>=e.selectionStart&&i<=e.selectionEnd&&e.selectionStart<e.selectionEnd}start(t){return this.__mouseDownInPlace=this.isPointerOverSelection(t)}isActive(){return this.__mouseDownInPlace}end(t){const e=this.isActive();return e&&!this.__dragStartFired&&(this.target.setCursorByClick(t),this.target.initDelayedCursor(!0)),this.__mouseDownInPlace=!1,this.__dragStartFired=!1,this.__isDraggingOver=!1,e}getDragStartSelection(){return this.__dragStartSelection}setDragImage(t,e){var i;let{selectionStart:s,selectionEnd:n}=e;const o=this.target,a=o.canvas,l=new x(o.flipX?-1:1,o.flipY?-1:1),c=o._getCursorBoundaries(s),h=new x(c.left+c.leftOffset,c.top+c.topOffset).multiply(l).transform(o.calcTransformMatrix()),d=a.getScenePoint(t).subtract(h),u=o.getCanvasRetinaScaling(),p=o.getBoundingRect(),g=h.subtract(new x(p.left,p.top)),f=a.viewportTransform,m=g.add(d).transform(f,!0),b=o.backgroundColor,_=No(o.styles);o.backgroundColor="";const w={stroke:"transparent",fill:"transparent",textBackgroundColor:"transparent"};o.setSelectionStyles(w,0,s),o.setSelectionStyles(w,n,o.text.length),o.dirty=!0;const S=o.toCanvasElement({enableRetinaScaling:a.enableRetinaScaling,viewportTransform:!0});o.backgroundColor=b,o.styles=_,o.dirty=!0,go(S,{position:"fixed",left:"".concat(-S.width,"px"),border:se,width:"".concat(S.width/u,"px"),height:"".concat(S.height/u,"px")}),this.__dragImageDisposer&&this.__dragImageDisposer(),this.__dragImageDisposer=()=>{S.remove()},we(t.target||this.target.hiddenTextarea).body.appendChild(S),(i=t.dataTransfer)===null||i===void 0||i.setDragImage(S,m.x,m.y)}onDragStart(t){this.__dragStartFired=!0;const e=this.target,i=this.isActive();if(i&&t.dataTransfer){const s=this.__dragStartSelection={selectionStart:e.selectionStart,selectionEnd:e.selectionEnd},n=e._text.slice(s.selectionStart,s.selectionEnd).join(""),o=y({text:e.text,value:n},s);t.dataTransfer.setData("text/plain",n),t.dataTransfer.setData("application/fabric",JSON.stringify({value:n,styles:e.getSelectionStyles(s.selectionStart,s.selectionEnd,!0)})),t.dataTransfer.effectAllowed="copyMove",this.setDragImage(t,o)}return e.abortCursorAnimation(),i}canDrop(t){if(this.target.editable&&!this.target.getActiveControl()&&!t.defaultPrevented){if(this.isActive()&&this.__dragStartSelection){const e=this.target.getSelectionStartFromPointer(t),i=this.__dragStartSelection;return e<i.selectionStart||e>i.selectionEnd}return!0}return!1}targetCanDrop(t){return this.target.canDrop(t)}dragEnterHandler(t){let{e}=t;const i=this.targetCanDrop(e);!this.__isDraggingOver&&i&&(this.__isDraggingOver=!0)}dragOverHandler(t){const{e}=t,i=this.targetCanDrop(e);!this.__isDraggingOver&&i?this.__isDraggingOver=!0:this.__isDraggingOver&&!i&&(this.__isDraggingOver=!1),this.__isDraggingOver&&(e.preventDefault(),t.canDrop=!0,t.dropTarget=this.target)}dragLeaveHandler(){(this.__isDraggingOver||this.isActive())&&(this.__isDraggingOver=!1)}dropHandler(t){var e;const{e:i}=t,s=i.defaultPrevented;this.__isDraggingOver=!1,i.preventDefault();let n=(e=i.dataTransfer)===null||e===void 0?void 0:e.getData("text/plain");if(n&&!s){const o=this.target,a=o.canvas;let l=o.getSelectionStartFromPointer(i);const{styles:c}=i.dataTransfer.types.includes("application/fabric")?JSON.parse(i.dataTransfer.getData("application/fabric")):{},h=n[Math.max(0,n.length-1)],d=0;if(this.__dragStartSelection){const u=this.__dragStartSelection.selectionStart,p=this.__dragStartSelection.selectionEnd;l>u&&l<=p?l=u:l>p&&(l-=p-u),o.removeChars(u,p),delete this.__dragStartSelection}o._reNewline.test(h)&&(o._reNewline.test(o._text[l])||l===o._text.length)&&(n=n.trimEnd()),t.didDrop=!0,t.dropTarget=o,o.insertChars(n,c,l),a.setActiveObject(o),o.enterEditing(i),o.selectionStart=Math.min(l+d,o._text.length),o.selectionEnd=Math.min(o.selectionStart+n.length,o._text.length),o.hiddenTextarea.value=o.text,o._updateTextarea(),o.hiddenTextarea.focus(),o.fire(Br,{index:l+d,action:"drop"}),a.fire("text:changed",{target:o}),a.contextTopDirty=!0,a.requestRenderAll()}}dragEndHandler(t){let{e}=t;if(this.isActive()&&this.__dragStartFired&&this.__dragStartSelection){var i;const s=this.target,n=this.target.canvas,{selectionStart:o,selectionEnd:a}=this.__dragStartSelection,l=((i=e.dataTransfer)===null||i===void 0?void 0:i.dropEffect)||se;l===se?(s.selectionStart=o,s.selectionEnd=a,s._updateTextarea(),s.hiddenTextarea.focus()):(s.clearContextTop(),l==="move"&&(s.removeChars(o,a),s.selectionStart=s.selectionEnd=o,s.hiddenTextarea&&(s.hiddenTextarea.value=s.text),s._updateTextarea(),s.fire(Br,{index:o,action:"dragend"}),n.fire("text:changed",{target:s}),n.requestRenderAll()),s.exitEditing())}this.__dragImageDisposer&&this.__dragImageDisposer(),delete this.__dragImageDisposer,delete this.__dragStartSelection,this.__isDraggingOver=!1}dispose(){this._dispose&&this._dispose()}}const Sl=/[ \n\.,;!\?\-]/;class dm extends Gt{constructor(){super(...arguments),v(this,"_currentCursorOpacity",1)}initBehavior(){this._tick=this._tick.bind(this),this._onTickComplete=this._onTickComplete.bind(this),this.updateSelectionOnMouseMove=this.updateSelectionOnMouseMove.bind(this)}onDeselect(t){return this.isEditing&&this.exitEditing(),this.selected=!1,super.onDeselect(t)}_animateCursor(t){let{toValue:e,duration:i,delay:s,onComplete:n}=t;return Bc({startValue:this._currentCursorOpacity,endValue:e,duration:i,delay:s,onComplete:n,abort:()=>!this.canvas||this.selectionStart!==this.selectionEnd,onChange:o=>{this._currentCursorOpacity=o,this.renderCursorOrSelection()}})}_tick(t){this._currentTickState=this._animateCursor({toValue:0,duration:this.cursorDuration/2,delay:Math.max(t||0,100),onComplete:this._onTickComplete})}_onTickComplete(){var t;(t=this._currentTickCompleteState)===null||t===void 0||t.abort(),this._currentTickCompleteState=this._animateCursor({toValue:1,duration:this.cursorDuration,onComplete:this._tick})}initDelayedCursor(t){this.abortCursorAnimation(),this._tick(t?0:this.cursorDelay)}abortCursorAnimation(){let t=!1;[this._currentTickState,this._currentTickCompleteState].forEach((e=>{e&&!e.isDone()&&(t=!0,e.abort())})),this._currentCursorOpacity=1,t&&this.clearContextTop()}restartCursorIfNeeded(){[this._currentTickState,this._currentTickCompleteState].some((t=>!t||t.isDone()))&&this.initDelayedCursor()}selectAll(){return this.selectionStart=0,this.selectionEnd=this._text.length,this._fireSelectionChanged(),this._updateTextarea(),this}cmdAll(){this.selectAll(),this.renderCursorOrSelection()}getSelectedText(){return this._text.slice(this.selectionStart,this.selectionEnd).join("")}findWordBoundaryLeft(t){let e=0,i=t-1;if(this._reSpace.test(this._text[i]))for(;this._reSpace.test(this._text[i]);)e++,i--;for(;/\S/.test(this._text[i])&&i>-1;)e++,i--;return t-e}findWordBoundaryRight(t){let e=0,i=t;if(this._reSpace.test(this._text[i]))for(;this._reSpace.test(this._text[i]);)e++,i++;for(;/\S/.test(this._text[i])&&i<this._text.length;)e++,i++;return t+e}findLineBoundaryLeft(t){let e=0,i=t-1;for(;!/\n/.test(this._text[i])&&i>-1;)e++,i--;return t-e}findLineBoundaryRight(t){let e=0,i=t;for(;!/\n/.test(this._text[i])&&i<this._text.length;)e++,i++;return t+e}searchWordBoundary(t,e){const i=this._text;let s=t>0&&this._reSpace.test(i[t])&&(e===-1||!Mo.test(i[t-1]))?t-1:t,n=i[s];for(;s>0&&s<i.length&&!Sl.test(n);)s+=e,n=i[s];return e===-1&&Sl.test(n)&&s++,s}selectWord(t){var e;t=(e=t)!==null&&e!==void 0?e:this.selectionStart;const i=this.searchWordBoundary(t,-1),s=Math.max(i,this.searchWordBoundary(t,1));this.selectionStart=i,this.selectionEnd=s,this._fireSelectionChanged(),this._updateTextarea(),this.renderCursorOrSelection()}selectLine(t){var e;t=(e=t)!==null&&e!==void 0?e:this.selectionStart;const i=this.findLineBoundaryLeft(t),s=this.findLineBoundaryRight(t);this.selectionStart=i,this.selectionEnd=s,this._fireSelectionChanged(),this._updateTextarea()}enterEditing(t){!this.isEditing&&this.editable&&(this.enterEditingImpl(),this.fire("editing:entered",t?{e:t}:void 0),this._fireSelectionChanged(),this.canvas&&(this.canvas.fire("text:editing:entered",{target:this,e:t}),this.canvas.requestRenderAll()))}enterEditingImpl(){this.canvas&&(this.canvas.calcOffset(),this.canvas.textEditingManager.exitTextEditing()),this.isEditing=!0,this.initHiddenTextarea(),this.hiddenTextarea.focus(),this.hiddenTextarea.value=this.text,this._updateTextarea(),this._saveEditingProps(),this._setEditingProps(),this._textBeforeEdit=this.text,this._tick()}updateSelectionOnMouseMove(t){if(this.getActiveControl())return;const e=this.hiddenTextarea;we(e).activeElement!==e&&e.focus();const i=this.getSelectionStartFromPointer(t),s=this.selectionStart,n=this.selectionEnd;(i===this.__selectionStartOnMouseDown&&s!==n||s!==i&&n!==i)&&(i>this.__selectionStartOnMouseDown?(this.selectionStart=this.__selectionStartOnMouseDown,this.selectionEnd=i):(this.selectionStart=i,this.selectionEnd=this.__selectionStartOnMouseDown),this.selectionStart===s&&this.selectionEnd===n||(this._fireSelectionChanged(),this._updateTextarea(),this.renderCursorOrSelection()))}_setEditingProps(){this.hoverCursor="text",this.canvas&&(this.canvas.defaultCursor=this.canvas.moveCursor="text"),this.borderColor=this.editingBorderColor,this.hasControls=this.selectable=!1,this.lockMovementX=this.lockMovementY=!0}fromStringToGraphemeSelection(t,e,i){const s=i.slice(0,t),n=this.graphemeSplit(s).length;if(t===e)return{selectionStart:n,selectionEnd:n};const o=i.slice(t,e);return{selectionStart:n,selectionEnd:n+this.graphemeSplit(o).length}}fromGraphemeToStringSelection(t,e,i){const s=i.slice(0,t).join("").length;return t===e?{selectionStart:s,selectionEnd:s}:{selectionStart:s,selectionEnd:s+i.slice(t,e).join("").length}}_updateTextarea(){if(this.cursorOffsetCache={},this.hiddenTextarea){if(!this.inCompositionMode){const t=this.fromGraphemeToStringSelection(this.selectionStart,this.selectionEnd,this._text);this.hiddenTextarea.selectionStart=t.selectionStart,this.hiddenTextarea.selectionEnd=t.selectionEnd}this.updateTextareaPosition()}}updateFromTextArea(){if(!this.hiddenTextarea)return;this.cursorOffsetCache={};const t=this.hiddenTextarea;this.text=t.value,this.set("dirty",!0),this.initDimensions(),this.setCoords();const e=this.fromStringToGraphemeSelection(t.selectionStart,t.selectionEnd,t.value);this.selectionEnd=this.selectionStart=e.selectionEnd,this.inCompositionMode||(this.selectionStart=e.selectionStart),this.updateTextareaPosition()}updateTextareaPosition(){if(this.selectionStart===this.selectionEnd){const t=this._calcTextareaPosition();this.hiddenTextarea.style.left=t.left,this.hiddenTextarea.style.top=t.top}}_calcTextareaPosition(){if(!this.canvas)return{left:"1px",top:"1px"};const t=this.inCompositionMode?this.compositionStart:this.selectionStart,e=this._getCursorBoundaries(t),i=this.get2DCursorLocation(t),s=i.lineIndex,n=i.charIndex,o=this.getValueOfPropertyAt(s,n,"fontSize")*this.lineHeight,a=e.leftOffset,l=this.getCanvasRetinaScaling(),c=this.canvas.upperCanvasEl,h=c.width/l,d=c.height/l,u=h-o,p=d-o,g=new x(e.left+a,e.top+e.topOffset+o).transform(this.calcTransformMatrix()).transform(this.canvas.viewportTransform).multiply(new x(c.clientWidth/h,c.clientHeight/d));return g.x<0&&(g.x=0),g.x>u&&(g.x=u),g.y<0&&(g.y=0),g.y>p&&(g.y=p),g.x+=this.canvas._offset.left,g.y+=this.canvas._offset.top,{left:"".concat(g.x,"px"),top:"".concat(g.y,"px"),fontSize:"".concat(o,"px"),charHeight:o}}_saveEditingProps(){this._savedProps={hasControls:this.hasControls,borderColor:this.borderColor,lockMovementX:this.lockMovementX,lockMovementY:this.lockMovementY,hoverCursor:this.hoverCursor,selectable:this.selectable,defaultCursor:this.canvas&&this.canvas.defaultCursor,moveCursor:this.canvas&&this.canvas.moveCursor}}_restoreEditingProps(){this._savedProps&&(this.hoverCursor=this._savedProps.hoverCursor,this.hasControls=this._savedProps.hasControls,this.borderColor=this._savedProps.borderColor,this.selectable=this._savedProps.selectable,this.lockMovementX=this._savedProps.lockMovementX,this.lockMovementY=this._savedProps.lockMovementY,this.canvas&&(this.canvas.defaultCursor=this._savedProps.defaultCursor||this.canvas.defaultCursor,this.canvas.moveCursor=this._savedProps.moveCursor||this.canvas.moveCursor),delete this._savedProps)}_exitEditing(){const t=this.hiddenTextarea;this.selected=!1,this.isEditing=!1,t&&(t.blur&&t.blur(),t.parentNode&&t.parentNode.removeChild(t)),this.hiddenTextarea=null,this.abortCursorAnimation(),this.selectionStart!==this.selectionEnd&&this.clearContextTop()}exitEditingImpl(){this._exitEditing(),this.selectionEnd=this.selectionStart,this._restoreEditingProps(),this._forceClearCache&&(this.initDimensions(),this.setCoords())}exitEditing(){const t=this._textBeforeEdit!==this.text;return this.exitEditingImpl(),this.fire("editing:exited"),t&&this.fire(zr),this.canvas&&(this.canvas.fire("text:editing:exited",{target:this}),t&&this.canvas.fire("object:modified",{target:this})),this}_removeExtraneousStyles(){for(const t in this.styles)this._textLines[t]||delete this.styles[t]}removeStyleFromTo(t,e){const{lineIndex:i,charIndex:s}=this.get2DCursorLocation(t,!0),{lineIndex:n,charIndex:o}=this.get2DCursorLocation(e,!0);if(i!==n){if(this.styles[i])for(let a=s;a<this._unwrappedTextLines[i].length;a++)delete this.styles[i][a];if(this.styles[n])for(let a=o;a<this._unwrappedTextLines[n].length;a++){const l=this.styles[n][a];l&&(this.styles[i]||(this.styles[i]={}),this.styles[i][s+a-o]=l)}for(let a=i+1;a<=n;a++)delete this.styles[a];this.shiftLineStyles(n,i-n)}else if(this.styles[i]){const a=this.styles[i],l=o-s;for(let c=s;c<o;c++)delete a[c];for(const c in this.styles[i]){const h=parseInt(c,10);h>=o&&(a[h-l]=a[c],delete a[c])}}}shiftLineStyles(t,e){const i=Object.assign({},this.styles);for(const s in this.styles){const n=parseInt(s,10);n>t&&(this.styles[n+e]=i[n],i[n-e]||delete this.styles[n])}}insertNewlineStyleObject(t,e,i,s){const n={},o=this._unwrappedTextLines[t].length,a=o===e;let l=!1;i||(i=1),this.shiftLineStyles(t,i);const c=this.styles[t]?this.styles[t][e===0?e:e-1]:void 0;for(const d in this.styles[t]){const u=parseInt(d,10);u>=e&&(l=!0,n[u-e]=this.styles[t][d],a&&e===0||delete this.styles[t][d])}let h=!1;for(l&&!a&&(this.styles[t+i]=n,h=!0),(h||o>e)&&i--;i>0;)s&&s[i-1]?this.styles[t+i]={0:y({},s[i-1])}:c?this.styles[t+i]={0:y({},c)}:delete this.styles[t+i],i--;this._forceClearCache=!0}insertCharStyleObject(t,e,i,s){this.styles||(this.styles={});const n=this.styles[t],o=n?y({},n):{};i||(i=1);for(const l in o){const c=parseInt(l,10);c>=e&&(n[c+i]=o[c],o[c-i]||delete n[c])}if(this._forceClearCache=!0,s){for(;i--;)Object.keys(s[i]).length&&(this.styles[t]||(this.styles[t]={}),this.styles[t][e+i]=y({},s[i]));return}if(!n)return;const a=n[e?e-1:1];for(;a&&i--;)this.styles[t][e+i]=y({},a)}insertNewStyleBlock(t,e,i){const s=this.get2DCursorLocation(e,!0),n=[0];let o,a=0;for(let l=0;l<t.length;l++)t[l]===`
|
|
2375
|
-
`?(a++,n[a]=0):n[a]++;for(n[0]>0&&(this.insertCharStyleObject(s.lineIndex,s.charIndex,n[0],i),i=i&&i.slice(n[0]+1)),a&&this.insertNewlineStyleObject(s.lineIndex,s.charIndex+n[0],a),o=1;o<a;o++)n[o]>0?this.insertCharStyleObject(s.lineIndex+o,0,n[o],i):i&&this.styles[s.lineIndex+o]&&i[0]&&(this.styles[s.lineIndex+o][0]=i[0]),i=i&&i.slice(n[o]+1);n[o]>0&&this.insertCharStyleObject(s.lineIndex+o,0,n[o],i)}removeChars(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:t+1;this.removeStyleFromTo(t,e),this._text.splice(t,e-t),this.text=this._text.join(""),this.set("dirty",!0),this.initDimensions(),this.setCoords(),this._removeExtraneousStyles()}insertChars(t,e,i){let s=arguments.length>3&&arguments[3]!==void 0?arguments[3]:i;s>i&&this.removeStyleFromTo(i,s);const n=this.graphemeSplit(t);this.insertNewStyleBlock(n,i,e),this._text=[...this._text.slice(0,i),...n,...this._text.slice(s)],this.text=this._text.join(""),this.set("dirty",!0),this.initDimensions(),this.setCoords(),this._removeExtraneousStyles()}setSelectionStartEndWithShift(t,e,i){i<=t?(e===t?this._selectionDirection=Y:this._selectionDirection===_t&&(this._selectionDirection=Y,this.selectionEnd=t),this.selectionStart=i):i>t&&i<e?this._selectionDirection===_t?this.selectionEnd=i:this.selectionStart=i:(e===t?this._selectionDirection=_t:this._selectionDirection===Y&&(this._selectionDirection=_t,this.selectionStart=e),this.selectionEnd=i)}}class um extends dm{initHiddenTextarea(){const t=this.canvas&&we(this.canvas.getElement())||ss(),e=t.createElement("textarea");Object.entries({autocapitalize:"off",autocorrect:"off",autocomplete:"off",spellcheck:"false","data-fabric":"textarea",wrap:"off",name:"fabricTextarea"}).map((o=>{let[a,l]=o;return e.setAttribute(a,l)}));const{top:i,left:s,fontSize:n}=this._calcTextareaPosition();e.style.cssText="position: absolute; top: ".concat(i,"; left: ").concat(s,"; z-index: -999; opacity: 0; width: 1px; height: 1px; font-size: 1px; padding-top: ").concat(n,";"),(this.hiddenTextareaContainer||t.body).appendChild(e),Object.entries({blur:"blur",keydown:"onKeyDown",keyup:"onKeyUp",input:"onInput",copy:"copy",cut:"copy",paste:"paste",compositionstart:"onCompositionStart",compositionupdate:"onCompositionUpdate",compositionend:"onCompositionEnd"}).map((o=>{let[a,l]=o;return e.addEventListener(a,this[l].bind(this))})),this.hiddenTextarea=e}blur(){this.abortCursorAnimation()}onKeyDown(t){if(!this.isEditing)return;const e=this.direction==="rtl"?this.keysMapRtl:this.keysMap;if(t.keyCode in e)this[e[t.keyCode]](t);else{if(!(t.keyCode in this.ctrlKeysMapDown)||!t.ctrlKey&&!t.metaKey)return;this[this.ctrlKeysMapDown[t.keyCode]](t)}t.stopImmediatePropagation(),t.preventDefault(),t.keyCode>=33&&t.keyCode<=40?(this.inCompositionMode=!1,this.clearContextTop(),this.renderCursorOrSelection()):this.canvas&&this.canvas.requestRenderAll()}onKeyUp(t){!this.isEditing||this._copyDone||this.inCompositionMode?this._copyDone=!1:t.keyCode in this.ctrlKeysMapUp&&(t.ctrlKey||t.metaKey)&&(this[this.ctrlKeysMapUp[t.keyCode]](t),t.stopImmediatePropagation(),t.preventDefault(),this.canvas&&this.canvas.requestRenderAll())}onInput(t){const e=this.fromPaste,{value:i,selectionStart:s,selectionEnd:n}=this.hiddenTextarea;if(this.fromPaste=!1,t&&t.stopPropagation(),!this.isEditing)return;const o=()=>{this.updateFromTextArea(),this.fire(Br),this.canvas&&(this.canvas.fire("text:changed",{target:this}),this.canvas.requestRenderAll())};if(this.hiddenTextarea.value==="")return this.styles={},void o();const a=this._splitTextIntoLines(i).graphemeText,l=this._text.length,c=a.length,h=this.selectionStart,d=this.selectionEnd,u=h!==d;let p,g,f,m,b=c-l;const _=this.fromStringToGraphemeSelection(s,n,i),w=h>_.selectionStart;u?(g=this._text.slice(h,d),b+=d-h):c<l&&(g=w?this._text.slice(d+b,d):this._text.slice(h,h-b));const S=a.slice(_.selectionEnd-b,_.selectionEnd);if(g&&g.length&&(S.length&&(p=this.getSelectionStyles(h,h+1,!1),p=S.map((()=>p[0]))),u?(f=h,m=d):w?(f=d-g.length,m=d):(f=d,m=d+g.length),this.removeStyleFromTo(f,m)),S.length){const{copyPasteData:T}=Re();e&&S.join("")===T.copiedText&&!W.disableStyleCopyPaste&&(p=T.copiedTextStyle),this.insertNewStyleBlock(S,h,p)}o()}onCompositionStart(){this.inCompositionMode=!0}onCompositionEnd(){this.inCompositionMode=!1}onCompositionUpdate(t){let{target:e}=t;const{selectionStart:i,selectionEnd:s}=e;this.compositionStart=i,this.compositionEnd=s,this.updateTextareaPosition()}copy(){if(this.selectionStart===this.selectionEnd)return;const{copyPasteData:t}=Re();t.copiedText=this.getSelectedText(),W.disableStyleCopyPaste?t.copiedTextStyle=void 0:t.copiedTextStyle=this.getSelectionStyles(this.selectionStart,this.selectionEnd,!0),this._copyDone=!0}paste(){this.fromPaste=!0}_getWidthBeforeCursor(t,e){let i,s=this._getLineLeftOffset(t);return e>0&&(i=this.__charBounds[t][e-1],s+=i.left+i.width),s}getDownCursorOffset(t,e){const i=this._getSelectionForOffset(t,e),s=this.get2DCursorLocation(i),n=s.lineIndex;if(n===this._textLines.length-1||t.metaKey||t.keyCode===34)return this._text.length-i;const o=s.charIndex,a=this._getWidthBeforeCursor(n,o),l=this._getIndexOnLine(n+1,a);return this._textLines[n].slice(o).length+l+1+this.missingNewlineOffset(n)}_getSelectionForOffset(t,e){return t.shiftKey&&this.selectionStart!==this.selectionEnd&&e?this.selectionEnd:this.selectionStart}getUpCursorOffset(t,e){const i=this._getSelectionForOffset(t,e),s=this.get2DCursorLocation(i),n=s.lineIndex;if(n===0||t.metaKey||t.keyCode===33)return-i;const o=s.charIndex,a=this._getWidthBeforeCursor(n,o),l=this._getIndexOnLine(n-1,a),c=this._textLines[n].slice(0,o),h=this.missingNewlineOffset(n-1);return-this._textLines[n-1].length+l-c.length+(1-h)}_getIndexOnLine(t,e){const i=this._textLines[t];let s,n,o=this._getLineLeftOffset(t),a=0;for(let l=0,c=i.length;l<c;l++)if(s=this.__charBounds[t][l].width,o+=s,o>e){n=!0;const h=o-s,d=o,u=Math.abs(h-e);a=Math.abs(d-e)<u?l:l-1;break}return n||(a=i.length-1),a}moveCursorDown(t){this.selectionStart>=this._text.length&&this.selectionEnd>=this._text.length||this._moveCursorUpOrDown("Down",t)}moveCursorUp(t){this.selectionStart===0&&this.selectionEnd===0||this._moveCursorUpOrDown("Up",t)}_moveCursorUpOrDown(t,e){const i=this["get".concat(t,"CursorOffset")](e,this._selectionDirection===_t);if(e.shiftKey?this.moveCursorWithShift(i):this.moveCursorWithoutShift(i),i!==0){const s=this.text.length;this.selectionStart=es(0,this.selectionStart,s),this.selectionEnd=es(0,this.selectionEnd,s),this.abortCursorAnimation(),this.initDelayedCursor(),this._fireSelectionChanged(),this._updateTextarea()}}moveCursorWithShift(t){const e=this._selectionDirection===Y?this.selectionStart+t:this.selectionEnd+t;return this.setSelectionStartEndWithShift(this.selectionStart,this.selectionEnd,e),t!==0}moveCursorWithoutShift(t){return t<0?(this.selectionStart+=t,this.selectionEnd=this.selectionStart):(this.selectionEnd+=t,this.selectionStart=this.selectionEnd),t!==0}moveCursorLeft(t){this.selectionStart===0&&this.selectionEnd===0||this._moveCursorLeftOrRight("Left",t)}_move(t,e,i){let s;if(t.altKey)s=this["findWordBoundary".concat(i)](this[e]);else{if(!t.metaKey&&t.keyCode!==35&&t.keyCode!==36)return this[e]+=i==="Left"?-1:1,!0;s=this["findLineBoundary".concat(i)](this[e])}return s!==void 0&&this[e]!==s&&(this[e]=s,!0)}_moveLeft(t,e){return this._move(t,e,"Left")}_moveRight(t,e){return this._move(t,e,"Right")}moveCursorLeftWithoutShift(t){let e=!0;return this._selectionDirection=Y,this.selectionEnd===this.selectionStart&&this.selectionStart!==0&&(e=this._moveLeft(t,"selectionStart")),this.selectionEnd=this.selectionStart,e}moveCursorLeftWithShift(t){return this._selectionDirection===_t&&this.selectionStart!==this.selectionEnd?this._moveLeft(t,"selectionEnd"):this.selectionStart!==0?(this._selectionDirection=Y,this._moveLeft(t,"selectionStart")):void 0}moveCursorRight(t){this.selectionStart>=this._text.length&&this.selectionEnd>=this._text.length||this._moveCursorLeftOrRight("Right",t)}_moveCursorLeftOrRight(t,e){const i="moveCursor".concat(t).concat(e.shiftKey?"WithShift":"WithoutShift");this._currentCursorOpacity=1,this[i](e)&&(this.abortCursorAnimation(),this.initDelayedCursor(),this._fireSelectionChanged(),this._updateTextarea())}moveCursorRightWithShift(t){return this._selectionDirection===Y&&this.selectionStart!==this.selectionEnd?this._moveRight(t,"selectionStart"):this.selectionEnd!==this._text.length?(this._selectionDirection=_t,this._moveRight(t,"selectionEnd")):void 0}moveCursorRightWithoutShift(t){let e=!0;return this._selectionDirection=_t,this.selectionStart===this.selectionEnd?(e=this._moveRight(t,"selectionStart"),this.selectionEnd=this.selectionStart):this.selectionStart=this.selectionEnd,e}}const Tl=r=>!!r.button;class pm extends um{constructor(){super(...arguments),v(this,"draggableTextDelegate",void 0)}initBehavior(){this.on("mousedown",this._mouseDownHandler),this.on("mouseup",this.mouseUpHandler),this.on("mousedblclick",this.doubleClickHandler),this.on("mousetripleclick",this.tripleClickHandler),this.draggableTextDelegate=new hm(this),super.initBehavior()}shouldStartDragging(){return this.draggableTextDelegate.isActive()}onDragStart(t){return this.draggableTextDelegate.onDragStart(t)}canDrop(t){return this.draggableTextDelegate.canDrop(t)}doubleClickHandler(t){this.isEditing&&(this.selectWord(this.getSelectionStartFromPointer(t.e)),this.renderCursorOrSelection())}tripleClickHandler(t){this.isEditing&&(this.selectLine(this.getSelectionStartFromPointer(t.e)),this.renderCursorOrSelection())}_mouseDownHandler(t){let{e,alreadySelected:i}=t;this.canvas&&this.editable&&!Tl(e)&&!this.getActiveControl()&&(this.draggableTextDelegate.start(e)||(this.canvas.textEditingManager.register(this),i&&(this.inCompositionMode=!1,this.setCursorByClick(e)),this.isEditing&&(this.__selectionStartOnMouseDown=this.selectionStart,this.selectionStart===this.selectionEnd&&this.abortCursorAnimation(),this.renderCursorOrSelection()),this.selected||(this.selected=i||this.isEditing)))}mouseUpHandler(t){let{e,transform:i}=t;const s=this.draggableTextDelegate.end(e);if(this.canvas){this.canvas.textEditingManager.unregister(this);const n=this.canvas._activeObject;if(n&&n!==this)return}!this.editable||this.group&&!this.group.interactive||i&&i.actionPerformed||Tl(e)||s||this.selected&&!this.getActiveControl()&&(this.enterEditing(e),this.selectionStart===this.selectionEnd?this.initDelayedCursor(!0):this.renderCursorOrSelection())}setCursorByClick(t){const e=this.getSelectionStartFromPointer(t),i=this.selectionStart,s=this.selectionEnd;t.shiftKey?this.setSelectionStartEndWithShift(i,s,e):(this.selectionStart=e,this.selectionEnd=e),this.isEditing&&(this._fireSelectionChanged(),this._updateTextarea())}getSelectionStartFromPointer(t){const e=this.canvas.getScenePoint(t).transform(Ce(this.calcTransformMatrix())).add(new x(-this._getLeftOffset(),-this._getTopOffset()));let i=0,s=0,n=0;for(let c=0;c<this._textLines.length&&i<=e.y;c++)i+=this.getHeightOfLine(c),n=c,c>0&&(s+=this._textLines[c-1].length+this.missingNewlineOffset(c-1));let o=Math.abs(this._getLineLeftOffset(n));const a=this._textLines[n].length,l=this.__charBounds[n];for(let c=0;c<a;c++){const h=o+l[c].kernedWidth;if(e.x<=h){Math.abs(e.x-h)<=Math.abs(e.x-o)&&s++;break}o=h,s++}return Math.min(this.flipX?a-s:s,this._text.length)}}const cr="moveCursorUp",hr="moveCursorDown",dr="moveCursorLeft",ur="moveCursorRight",pr="exitEditing",El=(r,t)=>{const e=t.getRetinaScaling();r.setTransform(e,0,0,e,0,0);const i=t.viewportTransform;r.transform(i[0],i[1],i[2],i[3],i[4],i[5])},gm=y({selectionStart:0,selectionEnd:0,selectionColor:"rgba(17,119,255,0.3)",isEditing:!1,editable:!0,editingBorderColor:"rgba(102,153,255,0.25)",cursorWidth:2,cursorColor:"",cursorDelay:1e3,cursorDuration:600,caching:!0,hiddenTextareaContainer:null,keysMap:{9:pr,27:pr,33:cr,34:hr,35:ur,36:dr,37:dr,38:cr,39:ur,40:hr},keysMapRtl:{9:pr,27:pr,33:cr,34:hr,35:dr,36:ur,37:ur,38:cr,39:dr,40:hr},ctrlKeysMapDown:{65:"cmdAll"},ctrlKeysMapUp:{67:"copy",88:"cut"}},{_selectionDirection:null,_reSpace:/\s|\r?\n/,inCompositionMode:!1});class Xe extends pm{static getDefaults(){return y(y({},super.getDefaults()),Xe.ownDefaults)}get type(){const t=super.type;return t==="itext"?"i-text":t}constructor(t,e){super(t,y(y({},Xe.ownDefaults),e)),this.initBehavior()}_set(t,e){return this.isEditing&&this._savedProps&&t in this._savedProps?(this._savedProps[t]=e,this):(t==="canvas"&&(this.canvas instanceof fo&&this.canvas.textEditingManager.remove(this),e instanceof fo&&e.textEditingManager.add(this)),super._set(t,e))}setSelectionStart(t){t=Math.max(t,0),this._updateAndFire("selectionStart",t)}setSelectionEnd(t){t=Math.min(t,this.text.length),this._updateAndFire("selectionEnd",t)}_updateAndFire(t,e){this[t]!==e&&(this._fireSelectionChanged(),this[t]=e),this._updateTextarea()}_fireSelectionChanged(){this.fire("selection:changed"),this.canvas&&this.canvas.fire("text:selection:changed",{target:this})}initDimensions(){this.isEditing&&this.initDelayedCursor(),super.initDimensions()}getSelectionStyles(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:this.selectionStart||0,e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:this.selectionEnd,i=arguments.length>2?arguments[2]:void 0;return super.getSelectionStyles(t,e,i)}setSelectionStyles(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:this.selectionStart||0,i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:this.selectionEnd;return super.setSelectionStyles(t,e,i)}get2DCursorLocation(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:this.selectionStart,e=arguments.length>1?arguments[1]:void 0;return super.get2DCursorLocation(t,e)}render(t){super.render(t),this.cursorOffsetCache={},this.renderCursorOrSelection()}toCanvasElement(t){const e=this.isEditing;this.isEditing=!1;const i=super.toCanvasElement(t);return this.isEditing=e,i}renderCursorOrSelection(){if(!this.isEditing||!this.canvas)return;const t=this.clearContextTop(!0);if(!t)return;const e=this._getCursorBoundaries(),i=this.findAncestorsWithClipPath(),s=i.length>0;let n,o=t;if(s){n=ve(t.canvas),o=n.getContext("2d"),El(o,this.canvas);const a=this.calcTransformMatrix();o.transform(a[0],a[1],a[2],a[3],a[4],a[5])}if(this.selectionStart!==this.selectionEnd||this.inCompositionMode?this.renderSelection(o,e):this.renderCursor(o,e),s)for(const a of i){const l=a.clipPath,c=ve(t.canvas),h=c.getContext("2d");if(El(h,this.canvas),!l.absolutePositioned){const d=a.calcTransformMatrix();h.transform(d[0],d[1],d[2],d[3],d[4],d[5])}l.transform(h),l.drawObject(h,!0,{}),this.drawClipPathOnCache(o,l,c)}s&&(t.setTransform(1,0,0,1,0,0),t.drawImage(n,0,0)),this.canvas.contextTopDirty=!0,t.restore()}findAncestorsWithClipPath(){const t=[];let e=this;for(;e;)e.clipPath&&t.push(e),e=e.parent;return t}_getCursorBoundaries(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:this.selectionStart,e=arguments.length>1?arguments[1]:void 0;const i=this._getLeftOffset(),s=this._getTopOffset(),n=this._getCursorBoundariesOffsets(t,e);return{left:i,top:s,leftOffset:n.left,topOffset:n.top}}_getCursorBoundariesOffsets(t,e){return e?this.__getCursorBoundariesOffsets(t):this.cursorOffsetCache&&"top"in this.cursorOffsetCache?this.cursorOffsetCache:this.cursorOffsetCache=this.__getCursorBoundariesOffsets(t)}__getCursorBoundariesOffsets(t){let e=0,i=0;const{charIndex:s,lineIndex:n}=this.get2DCursorLocation(t);for(let c=0;c<n;c++)e+=this.getHeightOfLine(c);const o=this._getLineLeftOffset(n),a=this.__charBounds[n][s];a&&(i=a.left),this.charSpacing!==0&&s===this._textLines[n].length&&(i-=this._getWidthOfCharSpacing());const l={top:e,left:o+(i>0?i:0)};return this.direction==="rtl"&&(this.textAlign===_t||this.textAlign===Le||this.textAlign===Ms?l.left*=-1:this.textAlign===Y||this.textAlign===Yr?l.left=o-(i>0?i:0):this.textAlign!==V&&this.textAlign!==Is||(l.left=o-(i>0?i:0))),l}renderCursorAt(t){this._renderCursor(this.canvas.contextTop,this._getCursorBoundaries(t,!0),t)}renderCursor(t,e){this._renderCursor(t,e,this.selectionStart)}getCursorRenderingData(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:this.selectionStart,e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:this._getCursorBoundaries(t);const i=this.get2DCursorLocation(t),s=i.lineIndex,n=i.charIndex>0?i.charIndex-1:0,o=this.getValueOfPropertyAt(s,n,"fontSize"),a=this.getObjectScaling().x*this.canvas.getZoom(),l=this.cursorWidth/a,c=this.getValueOfPropertyAt(s,n,"deltaY"),h=e.topOffset+(1-this._fontSizeFraction)*this.getHeightOfLine(s)/this.lineHeight-o*(1-this._fontSizeFraction);return{color:this.cursorColor||this.getValueOfPropertyAt(s,n,"fill"),opacity:this._currentCursorOpacity,left:e.left+e.leftOffset-l/2,top:h+e.top+c,width:l,height:o}}_renderCursor(t,e,i){const{color:s,opacity:n,left:o,top:a,width:l,height:c}=this.getCursorRenderingData(i,e);t.fillStyle=s,t.globalAlpha=n,t.fillRect(o,a,l,c)}renderSelection(t,e){const i={selectionStart:this.inCompositionMode?this.hiddenTextarea.selectionStart:this.selectionStart,selectionEnd:this.inCompositionMode?this.hiddenTextarea.selectionEnd:this.selectionEnd};this._renderSelection(t,i,e)}renderDragSourceEffect(){const t=this.draggableTextDelegate.getDragStartSelection();this._renderSelection(this.canvas.contextTop,t,this._getCursorBoundaries(t.selectionStart,!0))}renderDropTargetEffect(t){const e=this.getSelectionStartFromPointer(t);this.renderCursorAt(e)}_renderSelection(t,e,i){const s=e.selectionStart,n=e.selectionEnd,o=this.textAlign.includes(Le),a=this.get2DCursorLocation(s),l=this.get2DCursorLocation(n),c=a.lineIndex,h=l.lineIndex,d=a.charIndex<0?0:a.charIndex,u=l.charIndex<0?0:l.charIndex;for(let p=c;p<=h;p++){const g=this._getLineLeftOffset(p)||0;let f=this.getHeightOfLine(p),m=0,b=0,_=0;if(p===c&&(b=this.__charBounds[c][d].left),p>=c&&p<h)_=o&&!this.isEndOfWrapping(p)?this.width:this.getLineWidth(p)||5;else if(p===h)if(u===0)_=this.__charBounds[h][u].left;else{const O=this._getWidthOfCharSpacing();_=this.__charBounds[h][u-1].left+this.__charBounds[h][u-1].width-O}m=f,(this.lineHeight<1||p===h&&this.lineHeight>1)&&(f/=this.lineHeight);let w=i.left+g+b,S=f,T=0;const k=_-b;this.inCompositionMode?(t.fillStyle=this.compositionColor||"black",S=1,T=f):t.fillStyle=this.selectionColor,this.direction==="rtl"&&(this.textAlign===_t||this.textAlign===Le||this.textAlign===Ms?w=this.width-w-k:this.textAlign===Y||this.textAlign===Yr?w=i.left+g-_:this.textAlign!==V&&this.textAlign!==Is||(w=i.left+g-_)),t.fillRect(w,i.top+i.topOffset+T,k,S),i.topOffset+=m}}getCurrentCharFontSize(){const t=this._getCurrentCharIndex();return this.getValueOfPropertyAt(t.l,t.c,"fontSize")}getCurrentCharColor(){const t=this._getCurrentCharIndex();return this.getValueOfPropertyAt(t.l,t.c,Dt)}_getCurrentCharIndex(){const t=this.get2DCursorLocation(this.selectionStart,!0),e=t.charIndex>0?t.charIndex-1:0;return{l:t.lineIndex,c:e}}dispose(){this.exitEditingImpl(),this.draggableTextDelegate.dispose(),super.dispose()}}v(Xe,"ownDefaults",gm),v(Xe,"type","IText"),A.setClass(Xe),A.setClass(Xe,"i-text");class pi extends Xe{static getDefaults(){return y(y({},super.getDefaults()),pi.ownDefaults)}constructor(t,e){super(t,y(y({},pi.ownDefaults),e))}static createControls(){return{controls:Wg()}}initDimensions(){this.initialized&&(this.isEditing&&this.initDelayedCursor(),this._clearCache(),this.dynamicMinWidth=0,this._styleMap=this._generateStyleMap(this._splitText()),this.dynamicMinWidth>this.width&&this._set("width",this.dynamicMinWidth),this.textAlign.includes(Le)&&this.enlargeSpaces(),this.height=this.calcTextHeight())}_generateStyleMap(t){let e=0,i=0,s=0;const n={};for(let o=0;o<t.graphemeLines.length;o++)t.graphemeText[s]===`
|
|
2376
|
-
`&&o>0?(i=0,s++,e++):!this.splitByGrapheme&&this._reSpaceAndTab.test(t.graphemeText[s])&&o>0&&(i++,s++),n[o]={line:e,offset:i},s+=t.graphemeLines[o].length,i+=t.graphemeLines[o].length;return n}styleHas(t,e){if(this._styleMap&&!this.isWrapping){const i=this._styleMap[e];i&&(e=i.line)}return super.styleHas(t,e)}isEmptyStyles(t){if(!this.styles)return!0;let e,i=0,s=t+1,n=!1;const o=this._styleMap[t],a=this._styleMap[t+1];o&&(t=o.line,i=o.offset),a&&(s=a.line,n=s===t,e=a.offset);const l=t===void 0?this.styles:{line:this.styles[t]};for(const c in l)for(const h in l[c]){const d=parseInt(h,10);if(d>=i&&(!n||d<e))for(const u in l[c][h])return!1}return!0}_getStyleDeclaration(t,e){if(this._styleMap&&!this.isWrapping){const i=this._styleMap[t];if(!i)return{};t=i.line,e=i.offset+e}return super._getStyleDeclaration(t,e)}_setStyleDeclaration(t,e,i){const s=this._styleMap[t];super._setStyleDeclaration(s.line,s.offset+e,i)}_deleteStyleDeclaration(t,e){const i=this._styleMap[t];super._deleteStyleDeclaration(i.line,i.offset+e)}_getLineStyle(t){const e=this._styleMap[t];return!!this.styles[e.line]}_setLineStyle(t){const e=this._styleMap[t];super._setLineStyle(e.line)}_wrapText(t,e){this.isWrapping=!0;const i=this.getGraphemeDataForRender(t),s=[];for(let n=0;n<i.wordsData.length;n++)s.push(...this._wrapLine(n,e,i));return this.isWrapping=!1,s}getGraphemeDataForRender(t){const e=this.splitByGrapheme,i=e?"":" ";let s=0;return{wordsData:t.map(((n,o)=>{let a=0;const l=e?this.graphemeSplit(n):this.wordSplit(n);return l.length===0?[{word:[],width:0}]:l.map((c=>{const h=e?[c]:this.graphemeSplit(c),d=this._measureWord(h,o,a);return s=Math.max(d,s),a+=h.length+i.length,{word:h,width:d}}))})),largestWordWidth:s}}_measureWord(t,e){let i,s=arguments.length>2&&arguments[2]!==void 0?arguments[2]:0,n=0;for(let o=0,a=t.length;o<a;o++)n+=this._getGraphemeBox(t[o],e,o+s,i,!0).kernedWidth,i=t[o];return n}wordSplit(t){return t.split(this._wordJoiners)}_wrapLine(t,e,i){let{largestWordWidth:s,wordsData:n}=i,o=arguments.length>3&&arguments[3]!==void 0?arguments[3]:0;const a=this._getWidthOfCharSpacing(),l=this.splitByGrapheme,c=[],h=l?"":" ";let d=0,u=[],p=0,g=0,f=!0;e-=o;const m=Math.max(e,s,this.dynamicMinWidth),b=n[t];let _;for(p=0,_=0;_<b.length;_++){const{word:w,width:S}=b[_];p+=w.length,d+=g+S-a,d>m&&!f?(c.push(u),u=[],d=S,f=!0):d+=a,f||l||u.push(h),u=u.concat(w),g=l?0:this._measureWord([h],t,p),p++,f=!1}return _&&c.push(u),s+o>this.dynamicMinWidth&&(this.dynamicMinWidth=s-a+o),c}isEndOfWrapping(t){return!this._styleMap[t+1]||this._styleMap[t+1].line!==this._styleMap[t].line}missingNewlineOffset(t,e){return this.splitByGrapheme&&!e?this.isEndOfWrapping(t)?1:0:1}_splitTextIntoLines(t){const e=super._splitTextIntoLines(t),i=this._wrapText(e.lines,this.width),s=new Array(i.length);for(let n=0;n<i.length;n++)s[n]=i[n].join("");return e.lines=s,e.graphemeLines=i,e}getMinWidth(){return Math.max(this.minWidth,this.dynamicMinWidth)}_removeExtraneousStyles(){const t=new Map;for(const e in this._styleMap){const i=parseInt(e,10);if(this._textLines[i]){const s=this._styleMap[e].line;t.set("".concat(s),!0)}}for(const e in this.styles)t.has(e)||delete this.styles[e]}toObject(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[];return super.toObject(["minWidth","splitByGrapheme",...t])}}v(pi,"type","Textbox"),v(pi,"textLayoutProperties",[...Xe.textLayoutProperties,"width"]),v(pi,"ownDefaults",{minWidth:20,dynamicMinWidth:2,lockScalingFlip:!0,noScaleCache:!1,_wordJoiners:/[ \t\r]/,splitByGrapheme:!1}),A.setClass(pi);class Ol extends fn{shouldPerformLayout(t){return!!t.target.clipPath&&super.shouldPerformLayout(t)}shouldLayoutClipPath(){return!1}calcLayoutResult(t,e){const{target:i}=t,{clipPath:s,group:n}=i;if(!s||!this.shouldPerformLayout(t))return;const{width:o,height:a}=Ke(Gc(i,s)),l=new x(o,a);if(s.absolutePositioned)return{center:Zi(s.getRelativeCenterPoint(),void 0,n?n.calcTransformMatrix():void 0),size:l};{const c=s.getRelativeCenterPoint().transform(i.calcOwnMatrix(),!0);if(this.shouldPerformLayout(t)){const{center:h=new x,correction:d=new x}=this.calcBoundingBox(e,t)||{};return{center:h.add(c),correction:d.subtract(c),size:l}}return{center:i.getRelativeCenterPoint().add(c),size:l}}}}v(Ol,"type","clip-path"),A.setClass(Ol);class kl extends fn{getInitialSize(t,e){let{target:i}=t,{size:s}=e;return new x(i.width||s.x,i.height||s.y)}}v(kl,"type","fixed"),A.setClass(kl);class fm extends Ys{subscribeTargets(t){const e=t.target;t.targets.reduce(((i,s)=>(s.parent&&i.add(s.parent),i)),new Set).forEach((i=>{i.layoutManager.subscribeTargets({target:i,targets:[e]})}))}unsubscribeTargets(t){const e=t.target,i=e.getObjects();t.targets.reduce(((s,n)=>(n.parent&&s.add(n.parent),s)),new Set).forEach((s=>{!i.some((n=>n.parent===s))&&s.layoutManager.unsubscribeTargets({target:s,targets:[e]})}))}}class Mi extends fi{static getDefaults(){return y(y({},super.getDefaults()),Mi.ownDefaults)}constructor(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};super(),Object.assign(this,Mi.ownDefaults),this.setOptions(e);const{left:i,top:s,layoutManager:n}=e;this.groupInit(t,{left:i,top:s,layoutManager:n??new fm})}_shouldSetNestedCoords(){return!0}__objectSelectionMonitor(){}multiSelectAdd(){for(var t=arguments.length,e=new Array(t),i=0;i<t;i++)e[i]=arguments[i];this.multiSelectionStacking==="selection-order"?this.add(...e):e.forEach((s=>{const n=this._objects.findIndex((a=>a.isInFrontOf(s))),o=n===-1?this.size():n;this.insertAt(o,s)}))}canEnterGroup(t){return this.getObjects().some((e=>e.isDescendantOf(t)||t.isDescendantOf(e)))?(mi("error","ActiveSelection: circular object trees are not supported, this call has no effect"),!1):super.canEnterGroup(t)}enterGroup(t,e){t.parent&&t.parent===t.group?t.parent._exitGroup(t):t.group&&t.parent!==t.group&&t.group.remove(t),this._enterGroup(t,e)}exitGroup(t,e){this._exitGroup(t,e),t.parent&&t.parent._enterGroup(t,!0)}_onAfterObjectsChange(t,e){super._onAfterObjectsChange(t,e);const i=new Set;e.forEach((s=>{const{parent:n}=s;n&&i.add(n)})),t===Go?i.forEach((s=>{s._onAfterObjectsChange(Gr,e)})):i.forEach((s=>{s._set("dirty",!0)}))}onDeselect(){return this.removeAll(),!1}toString(){return"#<ActiveSelection: (".concat(this.complexity(),")>")}shouldCache(){return!1}isOnACache(){return!1}_renderControls(t,e,i){t.save(),t.globalAlpha=this.isMoving?this.borderOpacityWhenMoving:1;const s=y(y({hasControls:!1},i),{},{forActiveSelection:!0});for(let n=0;n<this._objects.length;n++)this._objects[n]._renderControls(t,s);super._renderControls(t,e),t.restore()}}v(Mi,"type","ActiveSelection"),v(Mi,"ownDefaults",{multiSelectionStacking:"canvas-stacking"}),A.setClass(Mi),A.setClass(Mi,"activeSelection");class mm{constructor(){v(this,"resources",{})}applyFilters(t,e,i,s,n){const o=n.getContext("2d");if(!o)return;o.drawImage(e,0,0,i,s);const a={sourceWidth:i,sourceHeight:s,imageData:o.getImageData(0,0,i,s),originalEl:e,originalImageData:o.getImageData(0,0,i,s),canvasEl:n,ctx:o,filterBackend:this};t.forEach((c=>{c.applyTo(a)}));const{imageData:l}=a;return l.width===i&&l.height===s||(n.width=l.width,n.height=l.height),o.putImageData(l,0,0),a}}class ch{constructor(){let{tileSize:t=W.textureSize}=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};v(this,"aPosition",new Float32Array([0,0,0,1,1,0,1,1])),v(this,"resources",{}),this.tileSize=t,this.setupGLContext(t,t),this.captureGPUInfo()}setupGLContext(t,e){this.dispose(),this.createWebGLCanvas(t,e)}createWebGLCanvas(t,e){const i=ve({width:t,height:e}),s=i.getContext("webgl",{alpha:!0,premultipliedAlpha:!1,depth:!1,stencil:!1,antialias:!1});s&&(s.clearColor(0,0,0,0),this.canvas=i,this.gl=s)}applyFilters(t,e,i,s,n,o){const a=this.gl,l=n.getContext("2d");if(!a||!l)return;let c;o&&(c=this.getCachedTexture(o,e));const h={originalWidth:e.width||e.naturalWidth||0,originalHeight:e.height||e.naturalHeight||0,sourceWidth:i,sourceHeight:s,destinationWidth:i,destinationHeight:s,context:a,sourceTexture:this.createTexture(a,i,s,c?void 0:e),targetTexture:this.createTexture(a,i,s),originalTexture:c||this.createTexture(a,i,s,c?void 0:e),passes:t.length,webgl:!0,aPosition:this.aPosition,programCache:this.programCache,pass:0,filterBackend:this,targetCanvas:n},d=a.createFramebuffer();return a.bindFramebuffer(a.FRAMEBUFFER,d),t.forEach((u=>{u&&u.applyTo(h)})),(function(u){const p=u.targetCanvas,g=p.width,f=p.height,m=u.destinationWidth,b=u.destinationHeight;g===m&&f===b||(p.width=m,p.height=b)})(h),this.copyGLTo2D(a,h),a.bindTexture(a.TEXTURE_2D,null),a.deleteTexture(h.sourceTexture),a.deleteTexture(h.targetTexture),a.deleteFramebuffer(d),l.setTransform(1,0,0,1,0,0),h}dispose(){this.canvas&&(this.canvas=null,this.gl=null),this.clearWebGLCaches()}clearWebGLCaches(){this.programCache={},this.textureCache={}}createTexture(t,e,i,s,n){const{NEAREST:o,TEXTURE_2D:a,RGBA:l,UNSIGNED_BYTE:c,CLAMP_TO_EDGE:h,TEXTURE_MAG_FILTER:d,TEXTURE_MIN_FILTER:u,TEXTURE_WRAP_S:p,TEXTURE_WRAP_T:g}=t,f=t.createTexture();return t.bindTexture(a,f),t.texParameteri(a,d,n||o),t.texParameteri(a,u,n||o),t.texParameteri(a,p,h),t.texParameteri(a,g,h),s?t.texImage2D(a,0,l,l,c,s):t.texImage2D(a,0,l,e,i,0,l,c,null),f}getCachedTexture(t,e,i){const{textureCache:s}=this;if(s[t])return s[t];{const n=this.createTexture(this.gl,e.width,e.height,e,i);return n&&(s[t]=n),n}}evictCachesForKey(t){this.textureCache[t]&&(this.gl.deleteTexture(this.textureCache[t]),delete this.textureCache[t])}copyGLTo2D(t,e){const i=t.canvas,s=e.targetCanvas,n=s.getContext("2d");if(!n)return;n.translate(0,s.height),n.scale(1,-1);const o=i.height-s.height;n.drawImage(i,0,o,s.width,s.height,0,0,s.width,s.height)}copyGLTo2DPutImageData(t,e){const i=e.targetCanvas.getContext("2d"),s=e.destinationWidth,n=e.destinationHeight,o=s*n*4;if(!i)return;const a=new Uint8Array(this.imageBuffer,0,o),l=new Uint8ClampedArray(this.imageBuffer,0,o);t.readPixels(0,0,s,n,t.RGBA,t.UNSIGNED_BYTE,a);const c=new ImageData(l,s,n);i.putImageData(c,0,0)}captureGPUInfo(){if(this.gpuInfo)return this.gpuInfo;const t=this.gl,e={renderer:"",vendor:""};if(!t)return e;const i=t.getExtension("WEBGL_debug_renderer_info");if(i){const s=t.getParameter(i.UNMASKED_RENDERER_WEBGL),n=t.getParameter(i.UNMASKED_VENDOR_WEBGL);s&&(e.renderer=s.toLowerCase()),n&&(e.vendor=n.toLowerCase())}return this.gpuInfo=e,e}}let Vn;function bm(){const{WebGLProbe:r}=Re();return r.queryWebGL(ti()),W.enableGLFiltering&&r.isSupported(W.textureSize)?new ch({tileSize:W.textureSize}):new mm}function Nn(){return!Vn&&(!(arguments.length>0&&arguments[0]!==void 0)||arguments[0])&&(Vn=bm()),Vn}const vm=["filters","resizeFilter","src","crossOrigin","type"],hh=["cropX","cropY"];class te extends Vt{static getDefaults(){return y(y({},super.getDefaults()),te.ownDefaults)}constructor(t,e){super(),v(this,"_lastScaleX",1),v(this,"_lastScaleY",1),v(this,"_filterScalingX",1),v(this,"_filterScalingY",1),this.filters=[],Object.assign(this,te.ownDefaults),this.setOptions(e),this.cacheKey="texture".concat(bi()),this.setElement(typeof t=="string"?(this.canvas&&we(this.canvas.getElement())||ss()).getElementById(t):t,e)}getElement(){return this._element}setElement(t){var e;let i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};this.removeTexture(this.cacheKey),this.removeTexture("".concat(this.cacheKey,"_filtered")),this._element=t,this._originalElement=t,this._setWidthHeight(i),(e=t.classList)===null||e===void 0||e.add(te.CSS_CANVAS),this.filters.length!==0&&this.applyFilters(),this.resizeFilter&&this.applyResizeFilters()}removeTexture(t){const e=Nn(!1);e instanceof ch&&e.evictCachesForKey(t)}dispose(){super.dispose(),this.removeTexture(this.cacheKey),this.removeTexture("".concat(this.cacheKey,"_filtered")),this._cacheContext=null,["_originalElement","_element","_filteredEl","_cacheCanvas"].forEach((t=>{const e=this[t];e&&Re().dispose(e),this[t]=void 0}))}getCrossOrigin(){return this._originalElement&&(this._originalElement.crossOrigin||null)}getOriginalSize(){const t=this.getElement();return t?{width:t.naturalWidth||t.width,height:t.naturalHeight||t.height}:{width:0,height:0}}_stroke(t){if(!this.stroke||this.strokeWidth===0)return;const e=this.width/2,i=this.height/2;t.beginPath(),t.moveTo(-e,-i),t.lineTo(e,-i),t.lineTo(e,i),t.lineTo(-e,i),t.lineTo(-e,-i),t.closePath()}toObject(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[];const e=[];return this.filters.forEach((i=>{i&&e.push(i.toObject())})),y(y({},super.toObject([...hh,...t])),{},{src:this.getSrc(),crossOrigin:this.getCrossOrigin(),filters:e},this.resizeFilter?{resizeFilter:this.resizeFilter.toObject()}:{})}hasCrop(){return!!this.cropX||!!this.cropY||this.width<this._element.width||this.height<this._element.height}_toSVG(){const t=[],e=this._element,i=-this.width/2,s=-this.height/2;let n=[],o=[],a="",l="";if(!e)return[];if(this.hasCrop()){const c=bi();n.push('<clipPath id="imageCrop_'+c+`">
|
|
2364
|
+
`),i.join("")}toLive(t){const{x1:e,y1:i,x2:s,y2:n,r1:o,r2:a}=this.coords,l=this.type==="linear"?t.createLinearGradient(e,i,s,n):t.createRadialGradient(e,i,o,s,n,a);return this.colorStops.forEach((c=>{let{color:h,opacity:d,offset:u}=c;l.addColorStop(u,d!==void 0?new q(h).setAlpha(d).toRgba():h)})),l}static async fromObject(t){const{colorStops:e,gradientTransform:i}=t;return new this(y(y({},t),{},{colorStops:e?e.map((s=>y({},s))):void 0,gradientTransform:i?[...i]:void 0}))}static fromElement(t,e,i){const s=sh(t),n=e._findCenterFromElement();return new this(y({id:t.getAttribute("id")||void 0,type:ih(t),coords:Jf(t,{width:i.viewBoxWidth||i.width,height:i.viewBoxHeight||i.height}),colorStops:Zf(t,i.opacity),gradientUnits:s,gradientTransform:ho(t.getAttribute("gradientTransform")||"")},s==="pixels"?{offsetX:e.width/2-n.x,offsetY:e.height/2-n.y}:{offsetX:0,offsetY:0}))}}v(ar,"type","Gradient"),A.setClass(ar,"gradient"),A.setClass(ar,"linear"),A.setClass(ar,"radial");const Qf=["type","source","patternTransform"];class Bn{get type(){return"pattern"}set type(t){fi("warn","Setting type has no effect",t)}constructor(t){v(this,"repeat","repeat"),v(this,"offsetX",0),v(this,"offsetY",0),v(this,"crossOrigin",""),this.id=mi(),Object.assign(this,t)}isImageSource(){return!!this.source&&typeof this.source.src=="string"}isCanvasSource(){return!!this.source&&!!this.source.toDataURL}sourceToString(){return this.isImageSource()?this.source.src:this.isCanvasSource()?this.source.toDataURL():""}toLive(t){return this.source&&(!this.isImageSource()||this.source.complete&&this.source.naturalWidth!==0&&this.source.naturalHeight!==0)?t.createPattern(this.source,this.repeat):null}toObject(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[];const{repeat:e,crossOrigin:i}=this;return y(y({},as(this,t)),{},{type:"pattern",source:this.sourceToString(),repeat:e,crossOrigin:i,offsetX:tt(this.offsetX,W.NUM_FRACTION_DIGITS),offsetY:tt(this.offsetY,W.NUM_FRACTION_DIGITS),patternTransform:this.patternTransform?[...this.patternTransform]:null})}toSVG(t){let{width:e,height:i}=t;const{source:s,repeat:n,id:o}=this,a=qi(this.offsetX/e,0),l=qi(this.offsetY/i,0),c=n==="repeat-y"||n==="no-repeat"?1+Math.abs(a||0):qi(s.width/e,0),h=n==="repeat-x"||n==="no-repeat"?1+Math.abs(l||0):qi(s.height/i,0);return['<pattern id="SVGID_'.concat(o,'" x="').concat(a,'" y="').concat(l,'" width="').concat(c,'" height="').concat(h,'">'),'<image x="0" y="0" width="'.concat(s.width,'" height="').concat(s.height,'" xlink:href="').concat(this.sourceToString(),'"></image>'),"</pattern>",""].join(`
|
|
2365
|
+
`)}static async fromObject(t,e){let{type:i,source:s,patternTransform:n}=t,o=rt(t,Qf);const a=await Ir(s,y(y({},e),{},{crossOrigin:o.crossOrigin}));return new this(y(y({},o),{},{patternTransform:n&&n.slice(0),source:a}))}}v(Bn,"type","Pattern"),A.setClass(Bn),A.setClass(Bn,"pattern");const tm=["path","left","top"],em=["d"];class Ei extends Ht{constructor(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},{path:i,left:s,top:n}=e,o=rt(e,tm);super(),Object.assign(this,Ei.ownDefaults),this.setOptions(o),this._setPath(t||[],!0),typeof s=="number"&&this.set(Y,s),typeof n=="number"&&this.set(ie,n)}_setPath(t,e){this.path=Mf(Array.isArray(t)?t:Hf(t)),this.setBoundingBox(e)}_findCenterFromElement(){const t=this._calcBoundsFromPath();return new x(t.left+t.width/2,t.top+t.height/2)}_renderPathCommands(t){const e=-this.pathOffset.x,i=-this.pathOffset.y;t.beginPath();for(const s of this.path)switch(s[0]){case"L":t.lineTo(s[1]+e,s[2]+i);break;case"M":t.moveTo(s[1]+e,s[2]+i);break;case"C":t.bezierCurveTo(s[1]+e,s[2]+i,s[3]+e,s[4]+i,s[5]+e,s[6]+i);break;case"Q":t.quadraticCurveTo(s[1]+e,s[2]+i,s[3]+e,s[4]+i);break;case"Z":t.closePath()}}_render(t){this._renderPathCommands(t),this._renderPaintInOrder(t)}toString(){return"#<Path (".concat(this.complexity(),'): { "top": ').concat(this.top,', "left": ').concat(this.left," }>")}toObject(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[];return y(y({},super.toObject(t)),{},{path:this.path.map((e=>e.slice()))})}toDatalessObject(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[];const e=this.toObject(t);return this.sourcePath&&(delete e.path,e.sourcePath=this.sourcePath),e}_toSVG(){const t=Vf(this.path,W.NUM_FRACTION_DIGITS);return["<path ","COMMON_PARTS",'d="'.concat(t,`" stroke-linecap="round" />
|
|
2366
|
+
`)]}_getOffsetTransform(){const t=W.NUM_FRACTION_DIGITS;return" translate(".concat(tt(-this.pathOffset.x,t),", ").concat(tt(-this.pathOffset.y,t),")")}toClipPathSVG(t){const e=this._getOffsetTransform();return" "+this._createBaseClipPathSVGMarkup(this._toSVG(),{reviver:t,additionalTransform:e})}toSVG(t){const e=this._getOffsetTransform();return this._createBaseSVGMarkup(this._toSVG(),{reviver:t,additionalTransform:e})}complexity(){return this.path.length}setDimensions(){this.setBoundingBox()}setBoundingBox(t){const{width:e,height:i,pathOffset:s}=this._calcDimensions();this.set({width:e,height:i,pathOffset:s}),t&&this.setPositionByOrigin(s,V,V)}_calcBoundsFromPath(){const t=[];let e=0,i=0,s=0,n=0;for(const o of this.path)switch(o[0]){case"L":s=o[1],n=o[2],t.push({x:e,y:i},{x:s,y:n});break;case"M":s=o[1],n=o[2],e=s,i=n;break;case"C":t.push(...xl(s,n,o[1],o[2],o[3],o[4],o[5],o[6])),s=o[5],n=o[6];break;case"Q":t.push(...xl(s,n,o[1],o[2],o[1],o[2],o[3],o[4])),s=o[3],n=o[4];break;case"Z":s=e,n=i}return qe(t)}_calcDimensions(){const t=this._calcBoundsFromPath();return y(y({},t),{},{pathOffset:new x(t.left+t.width/2,t.top+t.height/2)})}static fromObject(t){return this._fromObject(t,{extraParam:"path"})}static async fromElement(t,e,i){const s=ni(t,this.ATTRIBUTE_NAMES,i),{d:n}=s;return new this(n,y(y(y({},rt(s,em)),e),{},{left:void 0,top:void 0}))}}v(Ei,"type","Path"),v(Ei,"cacheProperties",[...ri,"path","fillRule"]),v(Ei,"ATTRIBUTE_NAMES",[...yi,"d"]),A.setClass(Ei),A.setSVGClass(Ei);const im=["left","top","radius"],rh=["radius","startAngle","endAngle","counterClockwise"];class We extends Ht{static getDefaults(){return y(y({},super.getDefaults()),We.ownDefaults)}constructor(t){super(),Object.assign(this,We.ownDefaults),this.setOptions(t)}_set(t,e){return super._set(t,e),t==="radius"&&this.setRadius(e),this}_render(t){t.beginPath(),t.arc(0,0,this.radius,_t(this.startAngle),_t(this.endAngle),this.counterClockwise),this._renderPaintInOrder(t)}getRadiusX(){return this.get("radius")*this.get(oe)}getRadiusY(){return this.get("radius")*this.get(be)}setRadius(t){this.radius=t,this.set({width:2*t,height:2*t})}toObject(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[];return super.toObject([...rh,...t])}_toSVG(){const t=(this.endAngle-this.startAngle)%360;if(t===0)return["<circle ","COMMON_PARTS",'cx="0" cy="0" ','r="',"".concat(this.radius),`" />
|
|
2367
|
+
`];{const{radius:e}=this,i=_t(this.startAngle),s=_t(this.endAngle),n=Je(i)*e,o=Qe(i)*e,a=Je(s)*e,l=Qe(s)*e,c=t>180?1:0,h=this.counterClockwise?0:1;return['<path d="M '.concat(n," ").concat(o," A ").concat(e," ").concat(e," 0 ").concat(c," ").concat(h," ").concat(a," ").concat(l,'" '),"COMMON_PARTS",` />
|
|
2368
|
+
`]}}static async fromElement(t,e,i){const s=ni(t,this.ATTRIBUTE_NAMES,i),{left:n=0,top:o=0,radius:a=0}=s;return new this(y(y({},rt(s,im)),{},{radius:a,left:n-a,top:o-a}))}static fromObject(t){return super._fromObject(t)}}v(We,"type","Circle"),v(We,"cacheProperties",[...ri,...rh]),v(We,"ownDefaults",{radius:0,startAngle:0,endAngle:360,counterClockwise:!1}),v(We,"ATTRIBUTE_NAMES",["cx","cy","r",...yi]),A.setClass(We),A.setSVGClass(We);const sm=["x1","y1","x2","y2"],rm=["x1","y1","x2","y2"],mo=["x1","x2","y1","y2"];class Oi extends Ht{constructor(){let[t,e,i,s]=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[0,0,0,0],n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};super(),Object.assign(this,Oi.ownDefaults),this.setOptions(n),this.x1=t,this.x2=i,this.y1=e,this.y2=s,this._setWidthHeight();const{left:o,top:a}=n;typeof o=="number"&&this.set(Y,o),typeof a=="number"&&this.set(ie,a)}_setWidthHeight(){const{x1:t,y1:e,x2:i,y2:s}=this;this.width=Math.abs(i-t),this.height=Math.abs(s-e);const{left:n,top:o,width:a,height:l}=qe([{x:t,y:e},{x:i,y:s}]),c=new x(n+a/2,o+l/2);this.setPositionByOrigin(c,V,V)}_set(t,e){return super._set(t,e),mo.includes(t)&&this._setWidthHeight(),this}_render(t){t.beginPath();const e=this.calcLinePoints();t.moveTo(e.x1,e.y1),t.lineTo(e.x2,e.y2),t.lineWidth=this.strokeWidth;const i=t.strokeStyle;var s;ge(this.stroke)?t.strokeStyle=this.stroke.toLive(t):t.strokeStyle=(s=this.stroke)!==null&&s!==void 0?s:t.fillStyle,this.stroke&&this._renderStroke(t),t.strokeStyle=i}_findCenterFromElement(){return new x((this.x1+this.x2)/2,(this.y1+this.y2)/2)}toObject(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[];return y(y({},super.toObject(t)),this.calcLinePoints())}_getNonTransformedDimensions(){const t=super._getNonTransformedDimensions();return this.strokeLineCap==="butt"&&(this.width===0&&(t.y-=this.strokeWidth),this.height===0&&(t.x-=this.strokeWidth)),t}calcLinePoints(){const{x1:t,x2:e,y1:i,y2:s,width:n,height:o}=this,a=t<=e?-1:1,l=i<=s?-1:1;return{x1:a*n/2,x2:a*-n/2,y1:l*o/2,y2:l*-o/2}}_toSVG(){const{x1:t,x2:e,y1:i,y2:s}=this.calcLinePoints();return["<line ","COMMON_PARTS",'x1="'.concat(t,'" y1="').concat(i,'" x2="').concat(e,'" y2="').concat(s,`" />
|
|
2369
|
+
`)]}static async fromElement(t,e,i){const s=ni(t,this.ATTRIBUTE_NAMES,i),{x1:n=0,y1:o=0,x2:a=0,y2:l=0}=s;return new this([n,o,a,l],rt(s,sm))}static fromObject(t){let{x1:e,y1:i,x2:s,y2:n}=t,o=rt(t,rm);return this._fromObject(y(y({},o),{},{points:[e,i,s,n]}),{extraParam:"points"})}}v(Oi,"type","Line"),v(Oi,"cacheProperties",[...ri,...mo]),v(Oi,"ATTRIBUTE_NAMES",yi.concat(mo)),A.setClass(Oi),A.setSVGClass(Oi);class Ai extends Ht{static getDefaults(){return y(y({},super.getDefaults()),Ai.ownDefaults)}constructor(t){super(),Object.assign(this,Ai.ownDefaults),this.setOptions(t)}_render(t){const e=this.width/2,i=this.height/2;t.beginPath(),t.moveTo(-e,i),t.lineTo(0,-i),t.lineTo(e,i),t.closePath(),this._renderPaintInOrder(t)}_toSVG(){const t=this.width/2,e=this.height/2;return["<polygon ","COMMON_PARTS",'points="',"".concat(-t," ").concat(e,",0 ").concat(-e,",").concat(t," ").concat(e),'" />']}}v(Ai,"type","Triangle"),v(Ai,"ownDefaults",{width:100,height:100}),A.setClass(Ai),A.setSVGClass(Ai);const nh=["rx","ry"];class Ye extends Ht{static getDefaults(){return y(y({},super.getDefaults()),Ye.ownDefaults)}constructor(t){super(),Object.assign(this,Ye.ownDefaults),this.setOptions(t)}_set(t,e){switch(super._set(t,e),t){case"rx":this.rx=e,this.set("width",2*e);break;case"ry":this.ry=e,this.set("height",2*e)}return this}getRx(){return this.get("rx")*this.get(oe)}getRy(){return this.get("ry")*this.get(be)}toObject(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[];return super.toObject([...nh,...t])}_toSVG(){return["<ellipse ","COMMON_PARTS",'cx="0" cy="0" rx="'.concat(this.rx,'" ry="').concat(this.ry,`" />
|
|
2370
|
+
`)]}_render(t){t.beginPath(),t.save(),t.transform(1,0,0,this.ry/this.rx,0,0),t.arc(0,0,this.rx,0,Rr,!1),t.restore(),this._renderPaintInOrder(t)}static async fromElement(t,e,i){const s=ni(t,this.ATTRIBUTE_NAMES,i);return s.left=(s.left||0)-s.rx,s.top=(s.top||0)-s.ry,new this(s)}}function nm(r){if(!r)return[];const t=r.replace(/,/g," ").trim().split(/\s+/),e=[];for(let i=0;i<t.length;i+=2)e.push({x:parseFloat(t[i]),y:parseFloat(t[i+1])});return e}v(Ye,"type","Ellipse"),v(Ye,"cacheProperties",[...ri,...nh]),v(Ye,"ownDefaults",{rx:0,ry:0}),v(Ye,"ATTRIBUTE_NAMES",[...yi,"cx","cy","rx","ry"]),A.setClass(Ye),A.setSVGClass(Ye);const om=["left","top"],oh={exactBoundingBox:!1};class xe extends Ht{static getDefaults(){return y(y({},super.getDefaults()),xe.ownDefaults)}constructor(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};super(),v(this,"strokeDiff",void 0),Object.assign(this,xe.ownDefaults),this.setOptions(e),this.points=t;const{left:i,top:s}=e;this.initialized=!0,this.setBoundingBox(!0),typeof i=="number"&&this.set(Y,i),typeof s=="number"&&this.set(ie,s)}isOpen(){return!0}_projectStrokeOnPoints(t){return Xg(this.points,t,this.isOpen())}_calcDimensions(t){t=y({scaleX:this.scaleX,scaleY:this.scaleY,skewX:this.skewX,skewY:this.skewY,strokeLineCap:this.strokeLineCap,strokeLineJoin:this.strokeLineJoin,strokeMiterLimit:this.strokeMiterLimit,strokeUniform:this.strokeUniform,strokeWidth:this.strokeWidth},t||{});const e=this.exactBoundingBox?this._projectStrokeOnPoints(t).map((c=>c.projectedPoint)):this.points;if(e.length===0)return{left:0,top:0,width:0,height:0,pathOffset:new x,strokeOffset:new x,strokeDiff:new x};const i=qe(e),s=hn(y(y({},t),{},{scaleX:1,scaleY:1})),n=qe(this.points.map((c=>Qt(c,s,!0)))),o=new x(this.scaleX,this.scaleY);let a=i.left+i.width/2,l=i.top+i.height/2;return this.exactBoundingBox&&(a-=l*Math.tan(_t(this.skewX)),l-=a*Math.tan(_t(this.skewY))),y(y({},i),{},{pathOffset:new x(a,l),strokeOffset:new x(n.left,n.top).subtract(new x(i.left,i.top)).multiply(o),strokeDiff:new x(i.width,i.height).subtract(new x(n.width,n.height)).multiply(o)})}_findCenterFromElement(){const t=qe(this.points);return new x(t.left+t.width/2,t.top+t.height/2)}setDimensions(){this.setBoundingBox()}setBoundingBox(t){const{left:e,top:i,width:s,height:n,pathOffset:o,strokeOffset:a,strokeDiff:l}=this._calcDimensions();this.set({width:s,height:n,pathOffset:o,strokeOffset:a,strokeDiff:l}),t&&this.setPositionByOrigin(new x(e+s/2,i+n/2),V,V)}isStrokeAccountedForInDimensions(){return this.exactBoundingBox}_getNonTransformedDimensions(){return this.exactBoundingBox?new x(this.width,this.height):super._getNonTransformedDimensions()}_getTransformedDimensions(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(this.exactBoundingBox){let o;if(Object.keys(t).some((a=>this.strokeUniform||this.constructor.layoutProperties.includes(a)))){var e,i;const{width:a,height:l}=this._calcDimensions(t);o=new x((e=t.width)!==null&&e!==void 0?e:a,(i=t.height)!==null&&i!==void 0?i:l)}else{var s,n;o=new x((s=t.width)!==null&&s!==void 0?s:this.width,(n=t.height)!==null&&n!==void 0?n:this.height)}return o.multiply(new x(t.scaleX||this.scaleX,t.scaleY||this.scaleY))}return super._getTransformedDimensions(t)}_set(t,e){const i=this.initialized&&this[t]!==e,s=super._set(t,e);return this.exactBoundingBox&&i&&((t===oe||t===be)&&this.strokeUniform&&this.constructor.layoutProperties.includes("strokeUniform")||this.constructor.layoutProperties.includes(t))&&this.setDimensions(),s}toObject(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[];return y(y({},super.toObject(t)),{},{points:this.points.map((e=>{let{x:i,y:s}=e;return{x:i,y:s}}))})}_toSVG(){const t=[],e=this.pathOffset.x,i=this.pathOffset.y,s=W.NUM_FRACTION_DIGITS;for(let n=0,o=this.points.length;n<o;n++)t.push(tt(this.points[n].x-e,s),",",tt(this.points[n].y-i,s)," ");return["<".concat(this.constructor.type.toLowerCase()," "),"COMMON_PARTS",'points="'.concat(t.join(""),`" />
|
|
2371
|
+
`)]}_render(t){const e=this.points.length,i=this.pathOffset.x,s=this.pathOffset.y;if(e&&!isNaN(this.points[e-1].y)){t.beginPath(),t.moveTo(this.points[0].x-i,this.points[0].y-s);for(let n=0;n<e;n++){const o=this.points[n];t.lineTo(o.x-i,o.y-s)}!this.isOpen()&&t.closePath(),this._renderPaintInOrder(t)}}complexity(){return this.points.length}static async fromElement(t,e,i){return new this(nm(t.getAttribute("points")),y(y({},rt(ni(t,this.ATTRIBUTE_NAMES,i),om)),e))}static fromObject(t){return this._fromObject(t,{extraParam:"points"})}}v(xe,"ownDefaults",oh),v(xe,"type","Polyline"),v(xe,"layoutProperties",[rs,ns,"strokeLineCap","strokeLineJoin","strokeMiterLimit","strokeWidth","strokeUniform","points"]),v(xe,"cacheProperties",[...ri,"points"]),v(xe,"ATTRIBUTE_NAMES",[...yi]),A.setClass(xe),A.setSVGClass(xe);class lr extends xe{isOpen(){return!1}}v(lr,"ownDefaults",oh),v(lr,"type","Polygon"),A.setClass(lr),A.setSVGClass(lr);class ah extends Ht{isEmptyStyles(t){if(!this.styles||t!==void 0&&!this.styles[t])return!0;const e=t===void 0?this.styles:{line:this.styles[t]};for(const i in e)for(const s in e[i])for(const n in e[i][s])return!1;return!0}styleHas(t,e){if(!this.styles||e!==void 0&&!this.styles[e])return!1;const i=e===void 0?this.styles:{0:this.styles[e]};for(const s in i)for(const n in i[s])if(i[s][n][t]!==void 0)return!0;return!1}cleanStyle(t){if(!this.styles)return!1;const e=this.styles;let i,s,n=0,o=!0,a=0;for(const l in e){i=0;for(const c in e[l]){const h=e[l][c]||{};n++,h[t]!==void 0?(s?h[t]!==s&&(o=!1):s=h[t],h[t]===this[t]&&delete h[t]):o=!1,Object.keys(h).length!==0?i++:delete e[l][c]}i===0&&delete e[l]}for(let l=0;l<this._textLines.length;l++)a+=this._textLines[l].length;o&&n===a&&(this[t]=s,this.removeStyle(t))}removeStyle(t){if(!this.styles)return;const e=this.styles;let i,s,n;for(s in e){for(n in i=e[s],i)delete i[n][t],Object.keys(i[n]).length===0&&delete i[n];Object.keys(i).length===0&&delete e[s]}}_extendStyles(t,e){const{lineIndex:i,charIndex:s}=this.get2DCursorLocation(t);this._getLineStyle(i)||this._setLineStyle(i);const n=$o(y(y({},this._getStyleDeclaration(i,s)),e),(o=>o!==void 0));this._setStyleDeclaration(i,s,n)}getSelectionStyles(t,e,i){const s=[];for(let n=t;n<(e||t);n++)s.push(this.getStyleAtPosition(n,i));return s}getStyleAtPosition(t,e){const{lineIndex:i,charIndex:s}=this.get2DCursorLocation(t);return e?this.getCompleteStyleDeclaration(i,s):this._getStyleDeclaration(i,s)}setSelectionStyles(t,e,i){for(let s=e;s<(i||e);s++)this._extendStyles(s,t);this._forceClearCache=!0}_getStyleDeclaration(t,e){var i;const s=this.styles&&this.styles[t];return s&&(i=s[e])!==null&&i!==void 0?i:{}}getCompleteStyleDeclaration(t,e){return y(y({},as(this,this.constructor._styleProperties)),this._getStyleDeclaration(t,e))}_setStyleDeclaration(t,e,i){this.styles[t][e]=i}_deleteStyleDeclaration(t,e){delete this.styles[t][e]}_getLineStyle(t){return!!this.styles[t]}_setLineStyle(t){this.styles[t]={}}_deleteLineStyle(t){delete this.styles[t]}}v(ah,"_styleProperties",hg);const am=/ +/g,lm=/"/g;function zn(r,t,e,i,s){return" ".concat((function(n,o){let{left:a,top:l,width:c,height:h}=o,d=arguments.length>2&&arguments[2]!==void 0?arguments[2]:W.NUM_FRACTION_DIGITS;const u=Us(Dt,n,!1),[p,g,f,m]=[a,l,c,h].map((b=>tt(b,d)));return"<rect ".concat(u,' x="').concat(p,'" y="').concat(g,'" width="').concat(f,'" height="').concat(m,'"></rect>')})(r,{left:t,top:e,width:i,height:s}),`
|
|
2372
|
+
`)}const cm=["textAnchor","textDecoration","dx","dy","top","left","fontSize","strokeWidth"];let Hn;class Gt extends ah{static getDefaults(){return y(y({},super.getDefaults()),Gt.ownDefaults)}constructor(t,e){super(),v(this,"__charBounds",[]),Object.assign(this,Gt.ownDefaults),this.setOptions(e),this.styles||(this.styles={}),this.text=t,this.initialized=!0,this.path&&this.setPathInfo(),this.initDimensions(),this.setCoords()}setPathInfo(){const t=this.path;t&&(t.segmentsInfo=Jc(t.path))}_splitText(){const t=this._splitTextIntoLines(this.text);return this.textLines=t.lines,this._textLines=t.graphemeLines,this._unwrappedTextLines=t._unwrappedLines,this._text=t.graphemeText,t}initDimensions(){this._splitText(),this._clearCache(),this.dirty=!0,this.path?(this.width=this.path.width,this.height=this.path.height):(this.width=this.calcTextWidth()||this.cursorWidth||this.MIN_TEXT_WIDTH,this.height=this.calcTextHeight()),this.textAlign.includes(Le)&&this.enlargeSpaces()}enlargeSpaces(){let t,e,i,s,n,o,a;for(let l=0,c=this._textLines.length;l<c;l++)if((this.textAlign===Le||l!==c-1&&!this.isEndOfWrapping(l))&&(s=0,n=this._textLines[l],e=this.getLineWidth(l),e<this.width&&(a=this.textLines[l].match(this._reSpacesAndTabs)))){i=a.length,t=(this.width-e)/i;for(let h=0;h<=n.length;h++)o=this.__charBounds[l][h],this._reSpaceAndTab.test(n[h])?(o.width+=t,o.kernedWidth+=t,o.left+=s,s+=t):o.left+=s}}isEndOfWrapping(t){return t===this._textLines.length-1}missingNewlineOffset(t){return 1}get2DCursorLocation(t,e){const i=e?this._unwrappedTextLines:this._textLines;let s;for(s=0;s<i.length;s++){if(t<=i[s].length)return{lineIndex:s,charIndex:t};t-=i[s].length+this.missingNewlineOffset(s,e)}return{lineIndex:s-1,charIndex:i[s-1].length<t?i[s-1].length:t}}toString(){return"#<Text (".concat(this.complexity(),'): { "text": "').concat(this.text,'", "fontFamily": "').concat(this.fontFamily,'" }>')}_getCacheCanvasDimensions(){const t=super._getCacheCanvasDimensions(),e=this.fontSize;return t.width+=e*t.zoomX,t.height+=e*t.zoomY,t}_render(t){const e=this.path;e&&!e.isNotVisible()&&e._render(t),this._setTextStyles(t),this._renderTextLinesBackground(t),this._renderTextDecoration(t,"underline"),this._renderText(t),this._renderTextDecoration(t,"overline"),this._renderTextDecoration(t,"linethrough")}_renderText(t){this.paintFirst===re?(this._renderTextStroke(t),this._renderTextFill(t)):(this._renderTextFill(t),this._renderTextStroke(t))}_setTextStyles(t,e,i){if(t.textBaseline="alphabetic",this.path)switch(this.pathAlign){case V:t.textBaseline="middle";break;case"ascender":t.textBaseline=ie;break;case"descender":t.textBaseline=ro}t.font=this._getFontDeclaration(e,i)}calcTextWidth(){let t=this.getLineWidth(0);for(let e=1,i=this._textLines.length;e<i;e++){const s=this.getLineWidth(e);s>t&&(t=s)}return t}_renderTextLine(t,e,i,s,n,o){this._renderChars(t,e,i,s,n,o)}_renderTextLinesBackground(t){if(!this.textBackgroundColor&&!this.styleHas("textBackgroundColor"))return;const e=t.fillStyle,i=this._getLeftOffset();let s=this._getTopOffset();for(let n=0,o=this._textLines.length;n<o;n++){const a=this.getHeightOfLine(n);if(!this.textBackgroundColor&&!this.styleHas("textBackgroundColor",n)){s+=a;continue}const l=this._textLines[n].length,c=this._getLineLeftOffset(n);let h,d,u=0,p=0,g=this.getValueOfPropertyAt(n,0,"textBackgroundColor");const f=this.getHeightOfLineImpl(n);for(let m=0;m<l;m++){const b=this.__charBounds[n][m];d=this.getValueOfPropertyAt(n,m,"textBackgroundColor"),this.path?(t.save(),t.translate(b.renderLeft,b.renderTop),t.rotate(b.angle),t.fillStyle=d,d&&t.fillRect(-b.width/2,-f*(1-this._fontSizeFraction),b.width,f),t.restore()):d!==g?(h=i+c+p,this.direction==="rtl"&&(h=this.width-h-u),t.fillStyle=g,g&&t.fillRect(h,s,u,f),p=b.left,u=b.width,g=d):u+=b.kernedWidth}d&&!this.path&&(h=i+c+p,this.direction==="rtl"&&(h=this.width-h-u),t.fillStyle=d,t.fillRect(h,s,u,f)),s+=a}t.fillStyle=e,this._removeShadow(t)}_measureChar(t,e,i,s){const n=Ds.getFontCache(e),o=this._getFontDeclaration(e),a=i?i+t:t,l=i&&o===this._getFontDeclaration(s),c=e.fontSize/this.CACHE_FONT_SIZE;let h,d,u,p;if(i&&n.has(i)&&(u=n.get(i)),n.has(t)&&(p=h=n.get(t)),l&&n.has(a)&&(d=n.get(a),p=d-u),h===void 0||u===void 0||d===void 0){const g=(function(){return Hn||(Hn=ve({width:0,height:0}).getContext("2d")),Hn})();this._setTextStyles(g,e,!0),h===void 0&&(p=h=g.measureText(t).width,n.set(t,h)),u===void 0&&l&&i&&(u=g.measureText(i).width,n.set(i,u)),l&&d===void 0&&(d=g.measureText(a).width,n.set(a,d),p=d-u)}return{width:h*c,kernedWidth:p*c}}getHeightOfChar(t,e){return this.getValueOfPropertyAt(t,e,"fontSize")}measureLine(t){const e=this._measureLine(t);return this.charSpacing!==0&&(e.width-=this._getWidthOfCharSpacing()),e.width<0&&(e.width=0),e}_measureLine(t){let e,i,s=0;const n=this.pathSide===yt,o=this.path,a=this._textLines[t],l=a.length,c=new Array(l);this.__charBounds[t]=c;for(let h=0;h<l;h++){const d=a[h];i=this._getGraphemeBox(d,t,h,e),c[h]=i,s+=i.kernedWidth,e=d}if(c[l]={left:i?i.left+i.width:0,width:0,kernedWidth:0,height:this.fontSize,deltaY:0},o&&o.segmentsInfo){let h=0;const d=o.segmentsInfo[o.segmentsInfo.length-1].length;switch(this.textAlign){case Y:h=n?d-s:0;break;case V:h=(d-s)/2;break;case yt:h=n?0:d-s}h+=this.pathStartOffset*(n?-1:1);for(let u=n?l-1:0;n?u>=0:u<l;n?u--:u++)i=c[u],h>d?h%=d:h<0&&(h+=d),this._setGraphemeOnPath(h,i),h+=i.kernedWidth}return{width:s,numOfSpaces:0}}_setGraphemeOnPath(t,e){const i=t+e.kernedWidth/2,s=this.path,n=$f(s.path,i,s.segmentsInfo);e.renderLeft=n.x-s.pathOffset.x,e.renderTop=n.y-s.pathOffset.y,e.angle=n.angle+(this.pathSide===yt?Math.PI:0)}_getGraphemeBox(t,e,i,s,n){const o=this.getCompleteStyleDeclaration(e,i),a=s?this.getCompleteStyleDeclaration(e,i-1):{},l=this._measureChar(t,o,s,a);let c,h=l.kernedWidth,d=l.width;this.charSpacing!==0&&(c=this._getWidthOfCharSpacing(),d+=c,h+=c);const u={width:d,left:0,height:o.fontSize,kernedWidth:h,deltaY:o.deltaY};if(i>0&&!n){const p=this.__charBounds[e][i-1];u.left=p.left+p.width+l.kernedWidth-l.width}return u}getHeightOfLineImpl(t){const e=this.__lineHeights;if(e[t])return e[t];let i=this.getHeightOfChar(t,0);for(let s=1,n=this._textLines[t].length;s<n;s++)i=Math.max(this.getHeightOfChar(t,s),i);return e[t]=i*this._fontSizeMult}getHeightOfLine(t){return this.getHeightOfLineImpl(t)*this.lineHeight}calcTextHeight(){let t=0;for(let e=0,i=this._textLines.length;e<i;e++)t+=e===i-1?this.getHeightOfLineImpl(e):this.getHeightOfLine(e);return t}_getLeftOffset(){return this.direction==="ltr"?-this.width/2:this.width/2}_getTopOffset(){return-this.height/2}_renderTextCommon(t,e){t.save();let i=0;const s=this._getLeftOffset(),n=this._getTopOffset();for(let o=0,a=this._textLines.length;o<a;o++)this._renderTextLine(e,t,this._textLines[o],s+this._getLineLeftOffset(o),n+i+this.getHeightOfLineImpl(o),o),i+=this.getHeightOfLine(o);t.restore()}_renderTextFill(t){(this.fill||this.styleHas(Dt))&&this._renderTextCommon(t,"fillText")}_renderTextStroke(t){(this.stroke&&this.strokeWidth!==0||!this.isEmptyStyles())&&(this.shadow&&!this.shadow.affectStroke&&this._removeShadow(t),t.save(),this._setLineDash(t,this.strokeDashArray),t.beginPath(),this._renderTextCommon(t,"strokeText"),t.closePath(),t.restore())}_renderChars(t,e,i,s,n,o){const a=this.textAlign.includes(Le),l=this.path,c=!a&&this.charSpacing===0&&this.isEmptyStyles(o)&&!l,h=this.direction==="ltr",d=this.direction==="ltr"?1:-1,u=e.direction;let p,g,f,m,b,_="",w=0;if(e.save(),u!==this.direction&&(e.canvas.setAttribute("dir",h?"ltr":"rtl"),e.direction=h?"ltr":"rtl",e.textAlign=h?Y:yt),n-=this.getHeightOfLineImpl(o)*this._fontSizeFraction,c)return this._renderChar(t,e,o,0,i.join(""),s,n),void e.restore();for(let S=0,T=i.length-1;S<=T;S++)m=S===T||this.charSpacing||l,_+=i[S],f=this.__charBounds[o][S],w===0?(s+=d*(f.kernedWidth-f.width),w+=f.width):w+=f.kernedWidth,a&&!m&&this._reSpaceAndTab.test(i[S])&&(m=!0),m||(p=p||this.getCompleteStyleDeclaration(o,S),g=this.getCompleteStyleDeclaration(o,S+1),m=Wo(p,g,!1)),m&&(l?(e.save(),e.translate(f.renderLeft,f.renderTop),e.rotate(f.angle),this._renderChar(t,e,o,S,_,-w/2,0),e.restore()):(b=s,this._renderChar(t,e,o,S,_,b,n)),_="",p=g,s+=d*w,w=0);e.restore()}_applyPatternGradientTransformText(t){const e=this.width+this.strokeWidth,i=this.height+this.strokeWidth,s=ve({width:e,height:i}),n=s.getContext("2d");return s.width=e,s.height=i,n.beginPath(),n.moveTo(0,0),n.lineTo(e,0),n.lineTo(e,i),n.lineTo(0,i),n.closePath(),n.translate(e/2,i/2),n.fillStyle=t.toLive(n),this._applyPatternGradientTransform(n,t),n.fill(),n.createPattern(s,"no-repeat")}handleFiller(t,e,i){let s,n;return ge(i)?i.gradientUnits==="percentage"||i.gradientTransform||i.patternTransform?(s=-this.width/2,n=-this.height/2,t.translate(s,n),t[e]=this._applyPatternGradientTransformText(i),{offsetX:s,offsetY:n}):(t[e]=i.toLive(t),this._applyPatternGradientTransform(t,i)):(t[e]=i,{offsetX:0,offsetY:0})}_setStrokeStyles(t,e){let{stroke:i,strokeWidth:s}=e;return t.lineWidth=s,t.lineCap=this.strokeLineCap,t.lineDashOffset=this.strokeDashOffset,t.lineJoin=this.strokeLineJoin,t.miterLimit=this.strokeMiterLimit,this.handleFiller(t,"strokeStyle",i)}_setFillStyles(t,e){let{fill:i}=e;return this.handleFiller(t,"fillStyle",i)}_renderChar(t,e,i,s,n,o,a){const l=this._getStyleDeclaration(i,s),c=this.getCompleteStyleDeclaration(i,s),h=t==="fillText"&&c.fill,d=t==="strokeText"&&c.stroke&&c.strokeWidth;if(d||h){if(e.save(),e.font=this._getFontDeclaration(c),l.textBackgroundColor&&this._removeShadow(e),l.deltaY&&(a+=l.deltaY),h){const u=this._setFillStyles(e,c);e.fillText(n,o-u.offsetX,a-u.offsetY)}if(d){const u=this._setStrokeStyles(e,c);e.strokeText(n,o-u.offsetX,a-u.offsetY)}e.restore()}}setSuperscript(t,e){this._setScript(t,e,this.superscript)}setSubscript(t,e){this._setScript(t,e,this.subscript)}_setScript(t,e,i){const s=this.get2DCursorLocation(t,!0),n=this.getValueOfPropertyAt(s.lineIndex,s.charIndex,"fontSize"),o=this.getValueOfPropertyAt(s.lineIndex,s.charIndex,"deltaY"),a={fontSize:n*i.size,deltaY:o+n*i.baseline};this.setSelectionStyles(a,t,e)}_getLineLeftOffset(t){const e=this.getLineWidth(t),i=this.width-e,s=this.textAlign,n=this.direction,o=this.isEndOfWrapping(t);let a=0;return s===Le||s===Is&&!o||s===Ms&&!o||s===Yr&&!o?0:(s===V&&(a=i/2),s===yt&&(a=i),s===Is&&(a=i/2),s===Ms&&(a=i),n==="rtl"&&(s===yt||s===Le||s===Ms?a=0:s===Y||s===Yr?a=-i:s!==V&&s!==Is||(a=-i/2)),a)}_clearCache(){this._forceClearCache=!1,this.__lineWidths=[],this.__lineHeights=[],this.__charBounds=[]}getLineWidth(t){if(this.__lineWidths[t]!==void 0)return this.__lineWidths[t];const{width:e}=this.measureLine(t);return this.__lineWidths[t]=e,e}_getWidthOfCharSpacing(){return this.charSpacing!==0?this.fontSize*this.charSpacing/1e3:0}getValueOfPropertyAt(t,e,i){var s;return(s=this._getStyleDeclaration(t,e)[i])!==null&&s!==void 0?s:this[i]}_renderTextDecoration(t,e){if(!this[e]&&!this.styleHas(e))return;let i=this._getTopOffset();const s=this._getLeftOffset(),n=this.path,o=this._getWidthOfCharSpacing(),a=e==="linethrough"?.5:e==="overline"?1:0,l=this.offsets[e];for(let c=0,h=this._textLines.length;c<h;c++){const d=this.getHeightOfLine(c);if(!this[e]&&!this.styleHas(e,c)){i+=d;continue}const u=this._textLines[c],p=d/this.lineHeight,g=this._getLineLeftOffset(c);let f=0,m=0,b=this.getValueOfPropertyAt(c,0,e),_=this.getValueOfPropertyAt(c,0,Dt),w=this.getValueOfPropertyAt(c,0,Ri),S=b,T=_,k=w;const O=i+p*(1-this._fontSizeFraction);let E=this.getHeightOfChar(c,0),P=this.getValueOfPropertyAt(c,0,"deltaY");for(let F=0,H=u.length;F<H;F++){const M=this.__charBounds[c][F];S=this.getValueOfPropertyAt(c,F,e),T=this.getValueOfPropertyAt(c,F,Dt),k=this.getValueOfPropertyAt(c,F,Ri);const U=this.getHeightOfChar(c,F),X=this.getValueOfPropertyAt(c,F,"deltaY");if(n&&S&&T){const J=this.fontSize*k/1e3;t.save(),t.fillStyle=_,t.translate(M.renderLeft,M.renderTop),t.rotate(M.angle),t.fillRect(-M.kernedWidth/2,l*U+X-a*J,M.kernedWidth,J),t.restore()}else if((S!==b||T!==_||U!==E||k!==w||X!==P)&&m>0){const J=this.fontSize*w/1e3;let N=s+g+f;this.direction==="rtl"&&(N=this.width-N-m),b&&_&&w&&(t.fillStyle=_,t.fillRect(N,O+l*E+P-a*J,m,J)),f=M.left,m=M.width,b=S,w=k,_=T,E=U,P=X}else m+=M.kernedWidth}let R=s+g+f;this.direction==="rtl"&&(R=this.width-R-m),t.fillStyle=T;const L=this.fontSize*k/1e3;S&&T&&k&&t.fillRect(R,O+l*E+P-a*L,m-o,L),i+=d}this._removeShadow(t)}_getFontDeclaration(){let{fontFamily:t=this.fontFamily,fontStyle:e=this.fontStyle,fontWeight:i=this.fontWeight,fontSize:s=this.fontSize}=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},n=arguments.length>1?arguments[1]:void 0;const o=t.includes("'")||t.includes('"')||t.includes(",")||Gt.genericFonts.includes(t.toLowerCase())?t:'"'.concat(t,'"');return[e,i,"".concat(n?this.CACHE_FONT_SIZE:s,"px"),o].join(" ")}render(t){this.visible&&(this.canvas&&this.canvas.skipOffscreen&&!this.group&&!this.isOnScreen()||(this._forceClearCache&&this.initDimensions(),super.render(t)))}graphemeSplit(t){return Uo(t)}_splitTextIntoLines(t){const e=t.split(this._reNewline),i=new Array(e.length),s=[`
|
|
2373
|
+
`];let n=[];for(let o=0;o<e.length;o++)i[o]=this.graphemeSplit(e[o]),n=n.concat(i[o],s);return n.pop(),{_unwrappedLines:i,lines:e,graphemeText:n,graphemeLines:i}}toObject(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[];return y(y({},super.toObject([...Lc,...t])),{},{styles:Jg(this.styles,this.text)},this.path?{path:this.path.toObject()}:{})}set(t,e){const{textLayoutProperties:i}=this.constructor;super.set(t,e);let s=!1,n=!1;if(typeof t=="object")for(const o in t)o==="path"&&this.setPathInfo(),s=s||i.includes(o),n=n||o==="path";else s=i.includes(t),n=t==="path";return n&&this.setPathInfo(),s&&this.initialized&&(this.initDimensions(),this.setCoords()),this}complexity(){return 1}static async fromElement(t,e,i){const s=ni(t,Gt.ATTRIBUTE_NAMES,i),n=y(y({},e),s),{textAnchor:o=Y,textDecoration:a="",dx:l=0,dy:c=0,top:h=0,left:d=0,fontSize:u=Do,strokeWidth:p=1}=n,g=rt(n,cm),f=new this(Wr(t.textContent||"").trim(),y({left:d+l,top:h+c,underline:a.includes("underline"),overline:a.includes("overline"),linethrough:a.includes("line-through"),strokeWidth:0,fontSize:u},g)),m=f.getScaledHeight()/f.height,b=((f.height+f.strokeWidth)*f.lineHeight-f.height)*m,_=f.getScaledHeight()+b;let w=0;return o===V&&(w=f.getScaledWidth()/2),o===yt&&(w=f.getScaledWidth()),f.set({left:f.left-w,top:f.top-(_-f.fontSize*(.07+f._fontSizeFraction))/f.lineHeight,strokeWidth:p}),f}static fromObject(t){return this._fromObject(y(y({},t),{},{styles:Qg(t.styles||{},t.text)}),{extraParam:"text"})}}v(Gt,"textLayoutProperties",Ic),v(Gt,"cacheProperties",[...ri,...Lc]),v(Gt,"ownDefaults",dg),v(Gt,"type","Text"),v(Gt,"genericFonts",["serif","sans-serif","monospace","cursive","fantasy","system-ui","ui-serif","ui-sans-serif","ui-monospace","ui-rounded","math","emoji","fangsong"]),v(Gt,"ATTRIBUTE_NAMES",yi.concat("x","y","dx","dy","font-family","font-style","font-weight","font-size","letter-spacing","text-decoration","text-anchor")),Nc(Gt,[class extends Ac{_toSVG(){const r=this._getSVGLeftTopOffsets(),t=this._getSVGTextAndBg(r.textTop,r.textLeft);return this._wrapSVGTextAndBg(t)}toSVG(r){const t=this._createBaseSVGMarkup(this._toSVG(),{reviver:r,noStyle:!0,withShadow:!0}),e=this.path;return e?t+e._createBaseSVGMarkup(e._toSVG(),{reviver:r,withShadow:!0,additionalTransform:Ns(this.calcOwnMatrix())}):t}_getSVGLeftTopOffsets(){return{textLeft:-this.width/2,textTop:-this.height/2,lineTop:this.getHeightOfLine(0)}}_wrapSVGTextAndBg(r){let{textBgRects:t,textSpans:e}=r;const i=this.getSvgTextDecoration(this);return[t.join(""),' <text xml:space="preserve" ','font-family="'.concat(this.fontFamily.replace(lm,"'"),'" '),'font-size="'.concat(this.fontSize,'" '),this.fontStyle?'font-style="'.concat(this.fontStyle,'" '):"",this.fontWeight?'font-weight="'.concat(this.fontWeight,'" '):"",i?'text-decoration="'.concat(i,'" '):"",this.direction==="rtl"?'direction="'.concat(this.direction,'" '):"",'style="',this.getSvgStyles(!0),'"',this.addPaintOrder()," >",e.join(""),`</text>
|
|
2374
|
+
`]}_getSVGTextAndBg(r,t){const e=[],i=[];let s,n=r;this.backgroundColor&&i.push(...zn(this.backgroundColor,-this.width/2,-this.height/2,this.width,this.height));for(let o=0,a=this._textLines.length;o<a;o++)s=this._getLineLeftOffset(o),this.direction==="rtl"&&(s+=this.width),(this.textBackgroundColor||this.styleHas("textBackgroundColor",o))&&this._setSVGTextLineBg(i,o,t+s,n),this._setSVGTextLineText(e,o,t+s,n),n+=this.getHeightOfLine(o);return{textSpans:e,textBgRects:i}}_createTextCharSpan(r,t,e,i,s){const n=W.NUM_FRACTION_DIGITS,o=this.getSvgSpanStyles(t,r!==r.trim()||!!r.match(am)),a=o?'style="'.concat(o,'"'):"",l=t.deltaY,c=l?' dy="'.concat(tt(l,n),'" '):"",{angle:h,renderLeft:d,renderTop:u,width:p}=s;let g="";if(d!==void 0){const f=p/2;h&&(g=' rotate="'.concat(tt(ei(h),n),'"'));const m=os({angle:ei(h)});m[4]=d,m[5]=u;const b=new x(-f,0).transform(m);e=b.x,i=b.y}return'<tspan x="'.concat(tt(e,n),'" y="').concat(tt(i,n),'" ').concat(c).concat(g).concat(a,">").concat(qg(r),"</tspan>")}_setSVGTextLineText(r,t,e,i){const s=this.getHeightOfLine(t),n=this.textAlign.includes(Le),o=this._textLines[t];let a,l,c,h,d,u="",p=0;i+=s*(1-this._fontSizeFraction)/this.lineHeight;for(let g=0,f=o.length-1;g<=f;g++)d=g===f||this.charSpacing||this.path,u+=o[g],c=this.__charBounds[t][g],p===0?(e+=c.kernedWidth-c.width,p+=c.width):p+=c.kernedWidth,n&&!d&&this._reSpaceAndTab.test(o[g])&&(d=!0),d||(a=a||this.getCompleteStyleDeclaration(t,g),l=this.getCompleteStyleDeclaration(t,g+1),d=Wo(a,l,!0)),d&&(h=this._getStyleDeclaration(t,g),r.push(this._createTextCharSpan(u,h,e,i,c)),u="",a=l,this.direction==="rtl"?e-=p:e+=p,p=0)}_setSVGTextLineBg(r,t,e,i){const s=this._textLines[t],n=this.getHeightOfLine(t)/this.lineHeight;let o,a=0,l=0,c=this.getValueOfPropertyAt(t,0,"textBackgroundColor");for(let h=0;h<s.length;h++){const{left:d,width:u,kernedWidth:p}=this.__charBounds[t][h];o=this.getValueOfPropertyAt(t,h,"textBackgroundColor"),o!==c?(c&&r.push(...zn(c,e+l,i,a,n)),l=d,a=u,c=o):a+=p}o&&r.push(...zn(c,e+l,i,a,n))}_getSVGLineTopOffset(r){let t,e=0;for(t=0;t<r;t++)e+=this.getHeightOfLine(t);const i=this.getHeightOfLine(t);return{lineTop:e,offset:(this._fontSizeMult-this._fontSizeFraction)*i/(this.lineHeight*this._fontSizeMult)}}getSvgStyles(r){return"".concat(super.getSvgStyles(r)," text-decoration-thickness: ").concat(tt(this.textDecorationThickness*this.getObjectScaling().y/10,W.NUM_FRACTION_DIGITS),"%; white-space: pre;")}getSvgSpanStyles(r,t){const{fontFamily:e,strokeWidth:i,stroke:s,fill:n,fontSize:o,fontStyle:a,fontWeight:l,deltaY:c,textDecorationThickness:h,linethrough:d,overline:u,underline:p}=r,g=this.getSvgTextDecoration({underline:p??this.underline,overline:u??this.overline,linethrough:d??this.linethrough}),f=h||this.textDecorationThickness;return[s?Us(re,s):"",i?"stroke-width: ".concat(i,"; "):"",e?"font-family: ".concat(e.includes("'")||e.includes('"')?e:"'".concat(e,"'"),"; "):"",o?"font-size: ".concat(o,"px; "):"",a?"font-style: ".concat(a,"; "):"",l?"font-weight: ".concat(l,"; "):"",g?"text-decoration: ".concat(g,"; text-decoration-thickness: ").concat(tt(f*this.getObjectScaling().y/10,W.NUM_FRACTION_DIGITS),"%; "):"",n?Us(Dt,n):"",c?"baseline-shift: ".concat(-c,"; "):"",t?"white-space: pre; ":""].join("")}getSvgTextDecoration(r){return["overline","underline","line-through"].filter((t=>r[t.replace("-","")])).join(" ")}}]),A.setClass(Gt),A.setSVGClass(Gt);class hm{constructor(t){v(this,"target",void 0),v(this,"__mouseDownInPlace",!1),v(this,"__dragStartFired",!1),v(this,"__isDraggingOver",!1),v(this,"__dragStartSelection",void 0),v(this,"__dragImageDisposer",void 0),v(this,"_dispose",void 0),this.target=t;const e=[this.target.on("dragenter",this.dragEnterHandler.bind(this)),this.target.on("dragover",this.dragOverHandler.bind(this)),this.target.on("dragleave",this.dragLeaveHandler.bind(this)),this.target.on("dragend",this.dragEndHandler.bind(this)),this.target.on("drop",this.dropHandler.bind(this))];this._dispose=()=>{e.forEach((i=>i())),this._dispose=void 0}}isPointerOverSelection(t){const e=this.target,i=e.getSelectionStartFromPointer(t);return e.isEditing&&i>=e.selectionStart&&i<=e.selectionEnd&&e.selectionStart<e.selectionEnd}start(t){return this.__mouseDownInPlace=this.isPointerOverSelection(t)}isActive(){return this.__mouseDownInPlace}end(t){const e=this.isActive();return e&&!this.__dragStartFired&&(this.target.setCursorByClick(t),this.target.initDelayedCursor(!0)),this.__mouseDownInPlace=!1,this.__dragStartFired=!1,this.__isDraggingOver=!1,e}getDragStartSelection(){return this.__dragStartSelection}setDragImage(t,e){var i;let{selectionStart:s,selectionEnd:n}=e;const o=this.target,a=o.canvas,l=new x(o.flipX?-1:1,o.flipY?-1:1),c=o._getCursorBoundaries(s),h=new x(c.left+c.leftOffset,c.top+c.topOffset).multiply(l).transform(o.calcTransformMatrix()),d=a.getScenePoint(t).subtract(h),u=o.getCanvasRetinaScaling(),p=o.getBoundingRect(),g=h.subtract(new x(p.left,p.top)),f=a.viewportTransform,m=g.add(d).transform(f,!0),b=o.backgroundColor,_=No(o.styles);o.backgroundColor="";const w={stroke:"transparent",fill:"transparent",textBackgroundColor:"transparent"};o.setSelectionStyles(w,0,s),o.setSelectionStyles(w,n,o.text.length),o.dirty=!0;const S=o.toCanvasElement({enableRetinaScaling:a.enableRetinaScaling,viewportTransform:!0});o.backgroundColor=b,o.styles=_,o.dirty=!0,go(S,{position:"fixed",left:"".concat(-S.width,"px"),border:se,width:"".concat(S.width/u,"px"),height:"".concat(S.height/u,"px")}),this.__dragImageDisposer&&this.__dragImageDisposer(),this.__dragImageDisposer=()=>{S.remove()},we(t.target||this.target.hiddenTextarea).body.appendChild(S),(i=t.dataTransfer)===null||i===void 0||i.setDragImage(S,m.x,m.y)}onDragStart(t){this.__dragStartFired=!0;const e=this.target,i=this.isActive();if(i&&t.dataTransfer){const s=this.__dragStartSelection={selectionStart:e.selectionStart,selectionEnd:e.selectionEnd},n=e._text.slice(s.selectionStart,s.selectionEnd).join(""),o=y({text:e.text,value:n},s);t.dataTransfer.setData("text/plain",n),t.dataTransfer.setData("application/fabric",JSON.stringify({value:n,styles:e.getSelectionStyles(s.selectionStart,s.selectionEnd,!0)})),t.dataTransfer.effectAllowed="copyMove",this.setDragImage(t,o)}return e.abortCursorAnimation(),i}canDrop(t){if(this.target.editable&&!this.target.getActiveControl()&&!t.defaultPrevented){if(this.isActive()&&this.__dragStartSelection){const e=this.target.getSelectionStartFromPointer(t),i=this.__dragStartSelection;return e<i.selectionStart||e>i.selectionEnd}return!0}return!1}targetCanDrop(t){return this.target.canDrop(t)}dragEnterHandler(t){let{e}=t;const i=this.targetCanDrop(e);!this.__isDraggingOver&&i&&(this.__isDraggingOver=!0)}dragOverHandler(t){const{e}=t,i=this.targetCanDrop(e);!this.__isDraggingOver&&i?this.__isDraggingOver=!0:this.__isDraggingOver&&!i&&(this.__isDraggingOver=!1),this.__isDraggingOver&&(e.preventDefault(),t.canDrop=!0,t.dropTarget=this.target)}dragLeaveHandler(){(this.__isDraggingOver||this.isActive())&&(this.__isDraggingOver=!1)}dropHandler(t){var e;const{e:i}=t,s=i.defaultPrevented;this.__isDraggingOver=!1,i.preventDefault();let n=(e=i.dataTransfer)===null||e===void 0?void 0:e.getData("text/plain");if(n&&!s){const o=this.target,a=o.canvas;let l=o.getSelectionStartFromPointer(i);const{styles:c}=i.dataTransfer.types.includes("application/fabric")?JSON.parse(i.dataTransfer.getData("application/fabric")):{},h=n[Math.max(0,n.length-1)],d=0;if(this.__dragStartSelection){const u=this.__dragStartSelection.selectionStart,p=this.__dragStartSelection.selectionEnd;l>u&&l<=p?l=u:l>p&&(l-=p-u),o.removeChars(u,p),delete this.__dragStartSelection}o._reNewline.test(h)&&(o._reNewline.test(o._text[l])||l===o._text.length)&&(n=n.trimEnd()),t.didDrop=!0,t.dropTarget=o,o.insertChars(n,c,l),a.setActiveObject(o),o.enterEditing(i),o.selectionStart=Math.min(l+d,o._text.length),o.selectionEnd=Math.min(o.selectionStart+n.length,o._text.length),o.hiddenTextarea.value=o.text,o._updateTextarea(),o.hiddenTextarea.focus(),o.fire(Br,{index:l+d,action:"drop"}),a.fire("text:changed",{target:o}),a.contextTopDirty=!0,a.requestRenderAll()}}dragEndHandler(t){let{e}=t;if(this.isActive()&&this.__dragStartFired&&this.__dragStartSelection){var i;const s=this.target,n=this.target.canvas,{selectionStart:o,selectionEnd:a}=this.__dragStartSelection,l=((i=e.dataTransfer)===null||i===void 0?void 0:i.dropEffect)||se;l===se?(s.selectionStart=o,s.selectionEnd=a,s._updateTextarea(),s.hiddenTextarea.focus()):(s.clearContextTop(),l==="move"&&(s.removeChars(o,a),s.selectionStart=s.selectionEnd=o,s.hiddenTextarea&&(s.hiddenTextarea.value=s.text),s._updateTextarea(),s.fire(Br,{index:o,action:"dragend"}),n.fire("text:changed",{target:s}),n.requestRenderAll()),s.exitEditing())}this.__dragImageDisposer&&this.__dragImageDisposer(),delete this.__dragImageDisposer,delete this.__dragStartSelection,this.__isDraggingOver=!1}dispose(){this._dispose&&this._dispose()}}const Sl=/[ \n\.,;!\?\-]/;class dm extends Gt{constructor(){super(...arguments),v(this,"_currentCursorOpacity",1)}initBehavior(){this._tick=this._tick.bind(this),this._onTickComplete=this._onTickComplete.bind(this),this.updateSelectionOnMouseMove=this.updateSelectionOnMouseMove.bind(this)}onDeselect(t){return this.isEditing&&this.exitEditing(),this.selected=!1,super.onDeselect(t)}_animateCursor(t){let{toValue:e,duration:i,delay:s,onComplete:n}=t;return Rc({startValue:this._currentCursorOpacity,endValue:e,duration:i,delay:s,onComplete:n,abort:()=>!this.canvas||this.selectionStart!==this.selectionEnd,onChange:o=>{this._currentCursorOpacity=o,this.renderCursorOrSelection()}})}_tick(t){this._currentTickState=this._animateCursor({toValue:0,duration:this.cursorDuration/2,delay:Math.max(t||0,100),onComplete:this._onTickComplete})}_onTickComplete(){var t;(t=this._currentTickCompleteState)===null||t===void 0||t.abort(),this._currentTickCompleteState=this._animateCursor({toValue:1,duration:this.cursorDuration,onComplete:this._tick})}initDelayedCursor(t){this.abortCursorAnimation(),this._tick(t?0:this.cursorDelay)}abortCursorAnimation(){let t=!1;[this._currentTickState,this._currentTickCompleteState].forEach((e=>{e&&!e.isDone()&&(t=!0,e.abort())})),this._currentCursorOpacity=1,t&&this.clearContextTop()}restartCursorIfNeeded(){[this._currentTickState,this._currentTickCompleteState].some((t=>!t||t.isDone()))&&this.initDelayedCursor()}selectAll(){return this.selectionStart=0,this.selectionEnd=this._text.length,this._fireSelectionChanged(),this._updateTextarea(),this}cmdAll(){this.selectAll(),this.renderCursorOrSelection()}getSelectedText(){return this._text.slice(this.selectionStart,this.selectionEnd).join("")}findWordBoundaryLeft(t){let e=0,i=t-1;if(this._reSpace.test(this._text[i]))for(;this._reSpace.test(this._text[i]);)e++,i--;for(;/\S/.test(this._text[i])&&i>-1;)e++,i--;return t-e}findWordBoundaryRight(t){let e=0,i=t;if(this._reSpace.test(this._text[i]))for(;this._reSpace.test(this._text[i]);)e++,i++;for(;/\S/.test(this._text[i])&&i<this._text.length;)e++,i++;return t+e}findLineBoundaryLeft(t){let e=0,i=t-1;for(;!/\n/.test(this._text[i])&&i>-1;)e++,i--;return t-e}findLineBoundaryRight(t){let e=0,i=t;for(;!/\n/.test(this._text[i])&&i<this._text.length;)e++,i++;return t+e}searchWordBoundary(t,e){const i=this._text;let s=t>0&&this._reSpace.test(i[t])&&(e===-1||!Mo.test(i[t-1]))?t-1:t,n=i[s];for(;s>0&&s<i.length&&!Sl.test(n);)s+=e,n=i[s];return e===-1&&Sl.test(n)&&s++,s}selectWord(t){var e;t=(e=t)!==null&&e!==void 0?e:this.selectionStart;const i=this.searchWordBoundary(t,-1),s=Math.max(i,this.searchWordBoundary(t,1));this.selectionStart=i,this.selectionEnd=s,this._fireSelectionChanged(),this._updateTextarea(),this.renderCursorOrSelection()}selectLine(t){var e;t=(e=t)!==null&&e!==void 0?e:this.selectionStart;const i=this.findLineBoundaryLeft(t),s=this.findLineBoundaryRight(t);this.selectionStart=i,this.selectionEnd=s,this._fireSelectionChanged(),this._updateTextarea()}enterEditing(t){!this.isEditing&&this.editable&&(this.enterEditingImpl(),this.fire("editing:entered",t?{e:t}:void 0),this._fireSelectionChanged(),this.canvas&&(this.canvas.fire("text:editing:entered",{target:this,e:t}),this.canvas.requestRenderAll()))}enterEditingImpl(){this.canvas&&(this.canvas.calcOffset(),this.canvas.textEditingManager.exitTextEditing()),this.isEditing=!0,this.initHiddenTextarea(),this.hiddenTextarea.focus(),this.hiddenTextarea.value=this.text,this._updateTextarea(),this._saveEditingProps(),this._setEditingProps(),this._textBeforeEdit=this.text,this._tick()}updateSelectionOnMouseMove(t){if(this.getActiveControl())return;const e=this.hiddenTextarea;we(e).activeElement!==e&&e.focus();const i=this.getSelectionStartFromPointer(t),s=this.selectionStart,n=this.selectionEnd;(i===this.__selectionStartOnMouseDown&&s!==n||s!==i&&n!==i)&&(i>this.__selectionStartOnMouseDown?(this.selectionStart=this.__selectionStartOnMouseDown,this.selectionEnd=i):(this.selectionStart=i,this.selectionEnd=this.__selectionStartOnMouseDown),this.selectionStart===s&&this.selectionEnd===n||(this._fireSelectionChanged(),this._updateTextarea(),this.renderCursorOrSelection()))}_setEditingProps(){this.hoverCursor="text",this.canvas&&(this.canvas.defaultCursor=this.canvas.moveCursor="text"),this.borderColor=this.editingBorderColor,this.hasControls=this.selectable=!1,this.lockMovementX=this.lockMovementY=!0}fromStringToGraphemeSelection(t,e,i){const s=i.slice(0,t),n=this.graphemeSplit(s).length;if(t===e)return{selectionStart:n,selectionEnd:n};const o=i.slice(t,e);return{selectionStart:n,selectionEnd:n+this.graphemeSplit(o).length}}fromGraphemeToStringSelection(t,e,i){const s=i.slice(0,t).join("").length;return t===e?{selectionStart:s,selectionEnd:s}:{selectionStart:s,selectionEnd:s+i.slice(t,e).join("").length}}_updateTextarea(){if(this.cursorOffsetCache={},this.hiddenTextarea){if(!this.inCompositionMode){const t=this.fromGraphemeToStringSelection(this.selectionStart,this.selectionEnd,this._text);this.hiddenTextarea.selectionStart=t.selectionStart,this.hiddenTextarea.selectionEnd=t.selectionEnd}this.updateTextareaPosition()}}updateFromTextArea(){if(!this.hiddenTextarea)return;this.cursorOffsetCache={};const t=this.hiddenTextarea;this.text=t.value,this.set("dirty",!0),this.initDimensions(),this.setCoords();const e=this.fromStringToGraphemeSelection(t.selectionStart,t.selectionEnd,t.value);this.selectionEnd=this.selectionStart=e.selectionEnd,this.inCompositionMode||(this.selectionStart=e.selectionStart),this.updateTextareaPosition()}updateTextareaPosition(){if(this.selectionStart===this.selectionEnd){const t=this._calcTextareaPosition();this.hiddenTextarea.style.left=t.left,this.hiddenTextarea.style.top=t.top}}_calcTextareaPosition(){if(!this.canvas)return{left:"1px",top:"1px"};const t=this.inCompositionMode?this.compositionStart:this.selectionStart,e=this._getCursorBoundaries(t),i=this.get2DCursorLocation(t),s=i.lineIndex,n=i.charIndex,o=this.getValueOfPropertyAt(s,n,"fontSize")*this.lineHeight,a=e.leftOffset,l=this.getCanvasRetinaScaling(),c=this.canvas.upperCanvasEl,h=c.width/l,d=c.height/l,u=h-o,p=d-o,g=new x(e.left+a,e.top+e.topOffset+o).transform(this.calcTransformMatrix()).transform(this.canvas.viewportTransform).multiply(new x(c.clientWidth/h,c.clientHeight/d));return g.x<0&&(g.x=0),g.x>u&&(g.x=u),g.y<0&&(g.y=0),g.y>p&&(g.y=p),g.x+=this.canvas._offset.left,g.y+=this.canvas._offset.top,{left:"".concat(g.x,"px"),top:"".concat(g.y,"px"),fontSize:"".concat(o,"px"),charHeight:o}}_saveEditingProps(){this._savedProps={hasControls:this.hasControls,borderColor:this.borderColor,lockMovementX:this.lockMovementX,lockMovementY:this.lockMovementY,hoverCursor:this.hoverCursor,selectable:this.selectable,defaultCursor:this.canvas&&this.canvas.defaultCursor,moveCursor:this.canvas&&this.canvas.moveCursor}}_restoreEditingProps(){this._savedProps&&(this.hoverCursor=this._savedProps.hoverCursor,this.hasControls=this._savedProps.hasControls,this.borderColor=this._savedProps.borderColor,this.selectable=this._savedProps.selectable,this.lockMovementX=this._savedProps.lockMovementX,this.lockMovementY=this._savedProps.lockMovementY,this.canvas&&(this.canvas.defaultCursor=this._savedProps.defaultCursor||this.canvas.defaultCursor,this.canvas.moveCursor=this._savedProps.moveCursor||this.canvas.moveCursor),delete this._savedProps)}_exitEditing(){const t=this.hiddenTextarea;this.selected=!1,this.isEditing=!1,t&&(t.blur&&t.blur(),t.parentNode&&t.parentNode.removeChild(t)),this.hiddenTextarea=null,this.abortCursorAnimation(),this.selectionStart!==this.selectionEnd&&this.clearContextTop()}exitEditingImpl(){this._exitEditing(),this.selectionEnd=this.selectionStart,this._restoreEditingProps(),this._forceClearCache&&(this.initDimensions(),this.setCoords())}exitEditing(){const t=this._textBeforeEdit!==this.text;return this.exitEditingImpl(),this.fire("editing:exited"),t&&this.fire(zr),this.canvas&&(this.canvas.fire("text:editing:exited",{target:this}),t&&this.canvas.fire("object:modified",{target:this})),this}_removeExtraneousStyles(){for(const t in this.styles)this._textLines[t]||delete this.styles[t]}removeStyleFromTo(t,e){const{lineIndex:i,charIndex:s}=this.get2DCursorLocation(t,!0),{lineIndex:n,charIndex:o}=this.get2DCursorLocation(e,!0);if(i!==n){if(this.styles[i])for(let a=s;a<this._unwrappedTextLines[i].length;a++)delete this.styles[i][a];if(this.styles[n])for(let a=o;a<this._unwrappedTextLines[n].length;a++){const l=this.styles[n][a];l&&(this.styles[i]||(this.styles[i]={}),this.styles[i][s+a-o]=l)}for(let a=i+1;a<=n;a++)delete this.styles[a];this.shiftLineStyles(n,i-n)}else if(this.styles[i]){const a=this.styles[i],l=o-s;for(let c=s;c<o;c++)delete a[c];for(const c in this.styles[i]){const h=parseInt(c,10);h>=o&&(a[h-l]=a[c],delete a[c])}}}shiftLineStyles(t,e){const i=Object.assign({},this.styles);for(const s in this.styles){const n=parseInt(s,10);n>t&&(this.styles[n+e]=i[n],i[n-e]||delete this.styles[n])}}insertNewlineStyleObject(t,e,i,s){const n={},o=this._unwrappedTextLines[t].length,a=o===e;let l=!1;i||(i=1),this.shiftLineStyles(t,i);const c=this.styles[t]?this.styles[t][e===0?e:e-1]:void 0;for(const d in this.styles[t]){const u=parseInt(d,10);u>=e&&(l=!0,n[u-e]=this.styles[t][d],a&&e===0||delete this.styles[t][d])}let h=!1;for(l&&!a&&(this.styles[t+i]=n,h=!0),(h||o>e)&&i--;i>0;)s&&s[i-1]?this.styles[t+i]={0:y({},s[i-1])}:c?this.styles[t+i]={0:y({},c)}:delete this.styles[t+i],i--;this._forceClearCache=!0}insertCharStyleObject(t,e,i,s){this.styles||(this.styles={});const n=this.styles[t],o=n?y({},n):{};i||(i=1);for(const l in o){const c=parseInt(l,10);c>=e&&(n[c+i]=o[c],o[c-i]||delete n[c])}if(this._forceClearCache=!0,s){for(;i--;)Object.keys(s[i]).length&&(this.styles[t]||(this.styles[t]={}),this.styles[t][e+i]=y({},s[i]));return}if(!n)return;const a=n[e?e-1:1];for(;a&&i--;)this.styles[t][e+i]=y({},a)}insertNewStyleBlock(t,e,i){const s=this.get2DCursorLocation(e,!0),n=[0];let o,a=0;for(let l=0;l<t.length;l++)t[l]===`
|
|
2375
|
+
`?(a++,n[a]=0):n[a]++;for(n[0]>0&&(this.insertCharStyleObject(s.lineIndex,s.charIndex,n[0],i),i=i&&i.slice(n[0]+1)),a&&this.insertNewlineStyleObject(s.lineIndex,s.charIndex+n[0],a),o=1;o<a;o++)n[o]>0?this.insertCharStyleObject(s.lineIndex+o,0,n[o],i):i&&this.styles[s.lineIndex+o]&&i[0]&&(this.styles[s.lineIndex+o][0]=i[0]),i=i&&i.slice(n[o]+1);n[o]>0&&this.insertCharStyleObject(s.lineIndex+o,0,n[o],i)}removeChars(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:t+1;this.removeStyleFromTo(t,e),this._text.splice(t,e-t),this.text=this._text.join(""),this.set("dirty",!0),this.initDimensions(),this.setCoords(),this._removeExtraneousStyles()}insertChars(t,e,i){let s=arguments.length>3&&arguments[3]!==void 0?arguments[3]:i;s>i&&this.removeStyleFromTo(i,s);const n=this.graphemeSplit(t);this.insertNewStyleBlock(n,i,e),this._text=[...this._text.slice(0,i),...n,...this._text.slice(s)],this.text=this._text.join(""),this.set("dirty",!0),this.initDimensions(),this.setCoords(),this._removeExtraneousStyles()}setSelectionStartEndWithShift(t,e,i){i<=t?(e===t?this._selectionDirection=Y:this._selectionDirection===yt&&(this._selectionDirection=Y,this.selectionEnd=t),this.selectionStart=i):i>t&&i<e?this._selectionDirection===yt?this.selectionEnd=i:this.selectionStart=i:(e===t?this._selectionDirection=yt:this._selectionDirection===Y&&(this._selectionDirection=yt,this.selectionStart=e),this.selectionEnd=i)}}class um extends dm{initHiddenTextarea(){const t=this.canvas&&we(this.canvas.getElement())||ss(),e=t.createElement("textarea");Object.entries({autocapitalize:"off",autocorrect:"off",autocomplete:"off",spellcheck:"false","data-fabric":"textarea",wrap:"off",name:"fabricTextarea"}).map((o=>{let[a,l]=o;return e.setAttribute(a,l)}));const{top:i,left:s,fontSize:n}=this._calcTextareaPosition();e.style.cssText="position: absolute; top: ".concat(i,"; left: ").concat(s,"; z-index: -999; opacity: 0; width: 1px; height: 1px; font-size: 1px; padding-top: ").concat(n,";"),(this.hiddenTextareaContainer||t.body).appendChild(e),Object.entries({blur:"blur",keydown:"onKeyDown",keyup:"onKeyUp",input:"onInput",copy:"copy",cut:"copy",paste:"paste",compositionstart:"onCompositionStart",compositionupdate:"onCompositionUpdate",compositionend:"onCompositionEnd"}).map((o=>{let[a,l]=o;return e.addEventListener(a,this[l].bind(this))})),this.hiddenTextarea=e}blur(){this.abortCursorAnimation()}onKeyDown(t){if(!this.isEditing)return;const e=this.direction==="rtl"?this.keysMapRtl:this.keysMap;if(t.keyCode in e)this[e[t.keyCode]](t);else{if(!(t.keyCode in this.ctrlKeysMapDown)||!t.ctrlKey&&!t.metaKey)return;this[this.ctrlKeysMapDown[t.keyCode]](t)}t.stopImmediatePropagation(),t.preventDefault(),t.keyCode>=33&&t.keyCode<=40?(this.inCompositionMode=!1,this.clearContextTop(),this.renderCursorOrSelection()):this.canvas&&this.canvas.requestRenderAll()}onKeyUp(t){!this.isEditing||this._copyDone||this.inCompositionMode?this._copyDone=!1:t.keyCode in this.ctrlKeysMapUp&&(t.ctrlKey||t.metaKey)&&(this[this.ctrlKeysMapUp[t.keyCode]](t),t.stopImmediatePropagation(),t.preventDefault(),this.canvas&&this.canvas.requestRenderAll())}onInput(t){const e=this.fromPaste,{value:i,selectionStart:s,selectionEnd:n}=this.hiddenTextarea;if(this.fromPaste=!1,t&&t.stopPropagation(),!this.isEditing)return;const o=()=>{this.updateFromTextArea(),this.fire(Br),this.canvas&&(this.canvas.fire("text:changed",{target:this}),this.canvas.requestRenderAll())};if(this.hiddenTextarea.value==="")return this.styles={},void o();const a=this._splitTextIntoLines(i).graphemeText,l=this._text.length,c=a.length,h=this.selectionStart,d=this.selectionEnd,u=h!==d;let p,g,f,m,b=c-l;const _=this.fromStringToGraphemeSelection(s,n,i),w=h>_.selectionStart;u?(g=this._text.slice(h,d),b+=d-h):c<l&&(g=w?this._text.slice(d+b,d):this._text.slice(h,h-b));const S=a.slice(_.selectionEnd-b,_.selectionEnd);if(g&&g.length&&(S.length&&(p=this.getSelectionStyles(h,h+1,!1),p=S.map((()=>p[0]))),u?(f=h,m=d):w?(f=d-g.length,m=d):(f=d,m=d+g.length),this.removeStyleFromTo(f,m)),S.length){const{copyPasteData:T}=Re();e&&S.join("")===T.copiedText&&!W.disableStyleCopyPaste&&(p=T.copiedTextStyle),this.insertNewStyleBlock(S,h,p)}o()}onCompositionStart(){this.inCompositionMode=!0}onCompositionEnd(){this.inCompositionMode=!1}onCompositionUpdate(t){let{target:e}=t;const{selectionStart:i,selectionEnd:s}=e;this.compositionStart=i,this.compositionEnd=s,this.updateTextareaPosition()}copy(){if(this.selectionStart===this.selectionEnd)return;const{copyPasteData:t}=Re();t.copiedText=this.getSelectedText(),W.disableStyleCopyPaste?t.copiedTextStyle=void 0:t.copiedTextStyle=this.getSelectionStyles(this.selectionStart,this.selectionEnd,!0),this._copyDone=!0}paste(){this.fromPaste=!0}_getWidthBeforeCursor(t,e){let i,s=this._getLineLeftOffset(t);return e>0&&(i=this.__charBounds[t][e-1],s+=i.left+i.width),s}getDownCursorOffset(t,e){const i=this._getSelectionForOffset(t,e),s=this.get2DCursorLocation(i),n=s.lineIndex;if(n===this._textLines.length-1||t.metaKey||t.keyCode===34)return this._text.length-i;const o=s.charIndex,a=this._getWidthBeforeCursor(n,o),l=this._getIndexOnLine(n+1,a);return this._textLines[n].slice(o).length+l+1+this.missingNewlineOffset(n)}_getSelectionForOffset(t,e){return t.shiftKey&&this.selectionStart!==this.selectionEnd&&e?this.selectionEnd:this.selectionStart}getUpCursorOffset(t,e){const i=this._getSelectionForOffset(t,e),s=this.get2DCursorLocation(i),n=s.lineIndex;if(n===0||t.metaKey||t.keyCode===33)return-i;const o=s.charIndex,a=this._getWidthBeforeCursor(n,o),l=this._getIndexOnLine(n-1,a),c=this._textLines[n].slice(0,o),h=this.missingNewlineOffset(n-1);return-this._textLines[n-1].length+l-c.length+(1-h)}_getIndexOnLine(t,e){const i=this._textLines[t];let s,n,o=this._getLineLeftOffset(t),a=0;for(let l=0,c=i.length;l<c;l++)if(s=this.__charBounds[t][l].width,o+=s,o>e){n=!0;const h=o-s,d=o,u=Math.abs(h-e);a=Math.abs(d-e)<u?l:l-1;break}return n||(a=i.length-1),a}moveCursorDown(t){this.selectionStart>=this._text.length&&this.selectionEnd>=this._text.length||this._moveCursorUpOrDown("Down",t)}moveCursorUp(t){this.selectionStart===0&&this.selectionEnd===0||this._moveCursorUpOrDown("Up",t)}_moveCursorUpOrDown(t,e){const i=this["get".concat(t,"CursorOffset")](e,this._selectionDirection===yt);if(e.shiftKey?this.moveCursorWithShift(i):this.moveCursorWithoutShift(i),i!==0){const s=this.text.length;this.selectionStart=es(0,this.selectionStart,s),this.selectionEnd=es(0,this.selectionEnd,s),this.abortCursorAnimation(),this.initDelayedCursor(),this._fireSelectionChanged(),this._updateTextarea()}}moveCursorWithShift(t){const e=this._selectionDirection===Y?this.selectionStart+t:this.selectionEnd+t;return this.setSelectionStartEndWithShift(this.selectionStart,this.selectionEnd,e),t!==0}moveCursorWithoutShift(t){return t<0?(this.selectionStart+=t,this.selectionEnd=this.selectionStart):(this.selectionEnd+=t,this.selectionStart=this.selectionEnd),t!==0}moveCursorLeft(t){this.selectionStart===0&&this.selectionEnd===0||this._moveCursorLeftOrRight("Left",t)}_move(t,e,i){let s;if(t.altKey)s=this["findWordBoundary".concat(i)](this[e]);else{if(!t.metaKey&&t.keyCode!==35&&t.keyCode!==36)return this[e]+=i==="Left"?-1:1,!0;s=this["findLineBoundary".concat(i)](this[e])}return s!==void 0&&this[e]!==s&&(this[e]=s,!0)}_moveLeft(t,e){return this._move(t,e,"Left")}_moveRight(t,e){return this._move(t,e,"Right")}moveCursorLeftWithoutShift(t){let e=!0;return this._selectionDirection=Y,this.selectionEnd===this.selectionStart&&this.selectionStart!==0&&(e=this._moveLeft(t,"selectionStart")),this.selectionEnd=this.selectionStart,e}moveCursorLeftWithShift(t){return this._selectionDirection===yt&&this.selectionStart!==this.selectionEnd?this._moveLeft(t,"selectionEnd"):this.selectionStart!==0?(this._selectionDirection=Y,this._moveLeft(t,"selectionStart")):void 0}moveCursorRight(t){this.selectionStart>=this._text.length&&this.selectionEnd>=this._text.length||this._moveCursorLeftOrRight("Right",t)}_moveCursorLeftOrRight(t,e){const i="moveCursor".concat(t).concat(e.shiftKey?"WithShift":"WithoutShift");this._currentCursorOpacity=1,this[i](e)&&(this.abortCursorAnimation(),this.initDelayedCursor(),this._fireSelectionChanged(),this._updateTextarea())}moveCursorRightWithShift(t){return this._selectionDirection===Y&&this.selectionStart!==this.selectionEnd?this._moveRight(t,"selectionStart"):this.selectionEnd!==this._text.length?(this._selectionDirection=yt,this._moveRight(t,"selectionEnd")):void 0}moveCursorRightWithoutShift(t){let e=!0;return this._selectionDirection=yt,this.selectionStart===this.selectionEnd?(e=this._moveRight(t,"selectionStart"),this.selectionEnd=this.selectionStart):this.selectionStart=this.selectionEnd,e}}const Tl=r=>!!r.button;class pm extends um{constructor(){super(...arguments),v(this,"draggableTextDelegate",void 0)}initBehavior(){this.on("mousedown",this._mouseDownHandler),this.on("mouseup",this.mouseUpHandler),this.on("mousedblclick",this.doubleClickHandler),this.on("mousetripleclick",this.tripleClickHandler),this.draggableTextDelegate=new hm(this),super.initBehavior()}shouldStartDragging(){return this.draggableTextDelegate.isActive()}onDragStart(t){return this.draggableTextDelegate.onDragStart(t)}canDrop(t){return this.draggableTextDelegate.canDrop(t)}doubleClickHandler(t){this.isEditing&&(this.selectWord(this.getSelectionStartFromPointer(t.e)),this.renderCursorOrSelection())}tripleClickHandler(t){this.isEditing&&(this.selectLine(this.getSelectionStartFromPointer(t.e)),this.renderCursorOrSelection())}_mouseDownHandler(t){let{e,alreadySelected:i}=t;this.canvas&&this.editable&&!Tl(e)&&!this.getActiveControl()&&(this.draggableTextDelegate.start(e)||(this.canvas.textEditingManager.register(this),i&&(this.inCompositionMode=!1,this.setCursorByClick(e)),this.isEditing&&(this.__selectionStartOnMouseDown=this.selectionStart,this.selectionStart===this.selectionEnd&&this.abortCursorAnimation(),this.renderCursorOrSelection()),this.selected||(this.selected=i||this.isEditing)))}mouseUpHandler(t){let{e,transform:i}=t;const s=this.draggableTextDelegate.end(e);if(this.canvas){this.canvas.textEditingManager.unregister(this);const n=this.canvas._activeObject;if(n&&n!==this)return}!this.editable||this.group&&!this.group.interactive||i&&i.actionPerformed||Tl(e)||s||this.selected&&!this.getActiveControl()&&(this.enterEditing(e),this.selectionStart===this.selectionEnd?this.initDelayedCursor(!0):this.renderCursorOrSelection())}setCursorByClick(t){const e=this.getSelectionStartFromPointer(t),i=this.selectionStart,s=this.selectionEnd;t.shiftKey?this.setSelectionStartEndWithShift(i,s,e):(this.selectionStart=e,this.selectionEnd=e),this.isEditing&&(this._fireSelectionChanged(),this._updateTextarea())}getSelectionStartFromPointer(t){const e=this.canvas.getScenePoint(t).transform(Ce(this.calcTransformMatrix())).add(new x(-this._getLeftOffset(),-this._getTopOffset()));let i=0,s=0,n=0;for(let c=0;c<this._textLines.length&&i<=e.y;c++)i+=this.getHeightOfLine(c),n=c,c>0&&(s+=this._textLines[c-1].length+this.missingNewlineOffset(c-1));let o=Math.abs(this._getLineLeftOffset(n));const a=this._textLines[n].length,l=this.__charBounds[n];for(let c=0;c<a;c++){const h=o+l[c].kernedWidth;if(e.x<=h){Math.abs(e.x-h)<=Math.abs(e.x-o)&&s++;break}o=h,s++}return Math.min(this.flipX?a-s:s,this._text.length)}}const cr="moveCursorUp",hr="moveCursorDown",dr="moveCursorLeft",ur="moveCursorRight",pr="exitEditing",El=(r,t)=>{const e=t.getRetinaScaling();r.setTransform(e,0,0,e,0,0);const i=t.viewportTransform;r.transform(i[0],i[1],i[2],i[3],i[4],i[5])},gm=y({selectionStart:0,selectionEnd:0,selectionColor:"rgba(17,119,255,0.3)",isEditing:!1,editable:!0,editingBorderColor:"rgba(102,153,255,0.25)",cursorWidth:2,cursorColor:"",cursorDelay:1e3,cursorDuration:600,caching:!0,hiddenTextareaContainer:null,keysMap:{9:pr,27:pr,33:cr,34:hr,35:ur,36:dr,37:dr,38:cr,39:ur,40:hr},keysMapRtl:{9:pr,27:pr,33:cr,34:hr,35:dr,36:ur,37:ur,38:cr,39:dr,40:hr},ctrlKeysMapDown:{65:"cmdAll"},ctrlKeysMapUp:{67:"copy",88:"cut"}},{_selectionDirection:null,_reSpace:/\s|\r?\n/,inCompositionMode:!1});class Xe extends pm{static getDefaults(){return y(y({},super.getDefaults()),Xe.ownDefaults)}get type(){const t=super.type;return t==="itext"?"i-text":t}constructor(t,e){super(t,y(y({},Xe.ownDefaults),e)),this.initBehavior()}_set(t,e){return this.isEditing&&this._savedProps&&t in this._savedProps?(this._savedProps[t]=e,this):(t==="canvas"&&(this.canvas instanceof fo&&this.canvas.textEditingManager.remove(this),e instanceof fo&&e.textEditingManager.add(this)),super._set(t,e))}setSelectionStart(t){t=Math.max(t,0),this._updateAndFire("selectionStart",t)}setSelectionEnd(t){t=Math.min(t,this.text.length),this._updateAndFire("selectionEnd",t)}_updateAndFire(t,e){this[t]!==e&&(this._fireSelectionChanged(),this[t]=e),this._updateTextarea()}_fireSelectionChanged(){this.fire("selection:changed"),this.canvas&&this.canvas.fire("text:selection:changed",{target:this})}initDimensions(){this.isEditing&&this.initDelayedCursor(),super.initDimensions()}getSelectionStyles(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:this.selectionStart||0,e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:this.selectionEnd,i=arguments.length>2?arguments[2]:void 0;return super.getSelectionStyles(t,e,i)}setSelectionStyles(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:this.selectionStart||0,i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:this.selectionEnd;return super.setSelectionStyles(t,e,i)}get2DCursorLocation(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:this.selectionStart,e=arguments.length>1?arguments[1]:void 0;return super.get2DCursorLocation(t,e)}render(t){super.render(t),this.cursorOffsetCache={},this.renderCursorOrSelection()}toCanvasElement(t){const e=this.isEditing;this.isEditing=!1;const i=super.toCanvasElement(t);return this.isEditing=e,i}renderCursorOrSelection(){if(!this.isEditing||!this.canvas)return;const t=this.clearContextTop(!0);if(!t)return;const e=this._getCursorBoundaries(),i=this.findAncestorsWithClipPath(),s=i.length>0;let n,o=t;if(s){n=ve(t.canvas),o=n.getContext("2d"),El(o,this.canvas);const a=this.calcTransformMatrix();o.transform(a[0],a[1],a[2],a[3],a[4],a[5])}if(this.selectionStart!==this.selectionEnd||this.inCompositionMode?this.renderSelection(o,e):this.renderCursor(o,e),s)for(const a of i){const l=a.clipPath,c=ve(t.canvas),h=c.getContext("2d");if(El(h,this.canvas),!l.absolutePositioned){const d=a.calcTransformMatrix();h.transform(d[0],d[1],d[2],d[3],d[4],d[5])}l.transform(h),l.drawObject(h,!0,{}),this.drawClipPathOnCache(o,l,c)}s&&(t.setTransform(1,0,0,1,0,0),t.drawImage(n,0,0)),this.canvas.contextTopDirty=!0,t.restore()}findAncestorsWithClipPath(){const t=[];let e=this;for(;e;)e.clipPath&&t.push(e),e=e.parent;return t}_getCursorBoundaries(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:this.selectionStart,e=arguments.length>1?arguments[1]:void 0;const i=this._getLeftOffset(),s=this._getTopOffset(),n=this._getCursorBoundariesOffsets(t,e);return{left:i,top:s,leftOffset:n.left,topOffset:n.top}}_getCursorBoundariesOffsets(t,e){return e?this.__getCursorBoundariesOffsets(t):this.cursorOffsetCache&&"top"in this.cursorOffsetCache?this.cursorOffsetCache:this.cursorOffsetCache=this.__getCursorBoundariesOffsets(t)}__getCursorBoundariesOffsets(t){let e=0,i=0;const{charIndex:s,lineIndex:n}=this.get2DCursorLocation(t);for(let c=0;c<n;c++)e+=this.getHeightOfLine(c);const o=this._getLineLeftOffset(n),a=this.__charBounds[n][s];a&&(i=a.left),this.charSpacing!==0&&s===this._textLines[n].length&&(i-=this._getWidthOfCharSpacing());const l={top:e,left:o+(i>0?i:0)};return this.direction==="rtl"&&(this.textAlign===yt||this.textAlign===Le||this.textAlign===Ms?l.left*=-1:this.textAlign===Y||this.textAlign===Yr?l.left=o-(i>0?i:0):this.textAlign!==V&&this.textAlign!==Is||(l.left=o-(i>0?i:0))),l}renderCursorAt(t){this._renderCursor(this.canvas.contextTop,this._getCursorBoundaries(t,!0),t)}renderCursor(t,e){this._renderCursor(t,e,this.selectionStart)}getCursorRenderingData(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:this.selectionStart,e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:this._getCursorBoundaries(t);const i=this.get2DCursorLocation(t),s=i.lineIndex,n=i.charIndex>0?i.charIndex-1:0,o=this.getValueOfPropertyAt(s,n,"fontSize"),a=this.getObjectScaling().x*this.canvas.getZoom(),l=this.cursorWidth/a,c=this.getValueOfPropertyAt(s,n,"deltaY"),h=e.topOffset+(1-this._fontSizeFraction)*this.getHeightOfLine(s)/this.lineHeight-o*(1-this._fontSizeFraction);return{color:this.cursorColor||this.getValueOfPropertyAt(s,n,"fill"),opacity:this._currentCursorOpacity,left:e.left+e.leftOffset-l/2,top:h+e.top+c,width:l,height:o}}_renderCursor(t,e,i){const{color:s,opacity:n,left:o,top:a,width:l,height:c}=this.getCursorRenderingData(i,e);t.fillStyle=s,t.globalAlpha=n,t.fillRect(o,a,l,c)}renderSelection(t,e){const i={selectionStart:this.inCompositionMode?this.hiddenTextarea.selectionStart:this.selectionStart,selectionEnd:this.inCompositionMode?this.hiddenTextarea.selectionEnd:this.selectionEnd};this._renderSelection(t,i,e)}renderDragSourceEffect(){const t=this.draggableTextDelegate.getDragStartSelection();this._renderSelection(this.canvas.contextTop,t,this._getCursorBoundaries(t.selectionStart,!0))}renderDropTargetEffect(t){const e=this.getSelectionStartFromPointer(t);this.renderCursorAt(e)}_renderSelection(t,e,i){const s=e.selectionStart,n=e.selectionEnd,o=this.textAlign.includes(Le),a=this.get2DCursorLocation(s),l=this.get2DCursorLocation(n),c=a.lineIndex,h=l.lineIndex,d=a.charIndex<0?0:a.charIndex,u=l.charIndex<0?0:l.charIndex;for(let p=c;p<=h;p++){const g=this._getLineLeftOffset(p)||0;let f=this.getHeightOfLine(p),m=0,b=0,_=0;if(p===c&&(b=this.__charBounds[c][d].left),p>=c&&p<h)_=o&&!this.isEndOfWrapping(p)?this.width:this.getLineWidth(p)||5;else if(p===h)if(u===0)_=this.__charBounds[h][u].left;else{const O=this._getWidthOfCharSpacing();_=this.__charBounds[h][u-1].left+this.__charBounds[h][u-1].width-O}m=f,(this.lineHeight<1||p===h&&this.lineHeight>1)&&(f/=this.lineHeight);let w=i.left+g+b,S=f,T=0;const k=_-b;this.inCompositionMode?(t.fillStyle=this.compositionColor||"black",S=1,T=f):t.fillStyle=this.selectionColor,this.direction==="rtl"&&(this.textAlign===yt||this.textAlign===Le||this.textAlign===Ms?w=this.width-w-k:this.textAlign===Y||this.textAlign===Yr?w=i.left+g-_:this.textAlign!==V&&this.textAlign!==Is||(w=i.left+g-_)),t.fillRect(w,i.top+i.topOffset+T,k,S),i.topOffset+=m}}getCurrentCharFontSize(){const t=this._getCurrentCharIndex();return this.getValueOfPropertyAt(t.l,t.c,"fontSize")}getCurrentCharColor(){const t=this._getCurrentCharIndex();return this.getValueOfPropertyAt(t.l,t.c,Dt)}_getCurrentCharIndex(){const t=this.get2DCursorLocation(this.selectionStart,!0),e=t.charIndex>0?t.charIndex-1:0;return{l:t.lineIndex,c:e}}dispose(){this.exitEditingImpl(),this.draggableTextDelegate.dispose(),super.dispose()}}v(Xe,"ownDefaults",gm),v(Xe,"type","IText"),A.setClass(Xe),A.setClass(Xe,"i-text");class ui extends Xe{static getDefaults(){return y(y({},super.getDefaults()),ui.ownDefaults)}constructor(t,e){super(t,y(y({},ui.ownDefaults),e))}static createControls(){return{controls:Wg()}}initDimensions(){this.initialized&&(this.isEditing&&this.initDelayedCursor(),this._clearCache(),this.dynamicMinWidth=0,this._styleMap=this._generateStyleMap(this._splitText()),this.dynamicMinWidth>this.width&&this._set("width",this.dynamicMinWidth),this.textAlign.includes(Le)&&this.enlargeSpaces(),this.height=this.calcTextHeight())}_generateStyleMap(t){let e=0,i=0,s=0;const n={};for(let o=0;o<t.graphemeLines.length;o++)t.graphemeText[s]===`
|
|
2376
|
+
`&&o>0?(i=0,s++,e++):!this.splitByGrapheme&&this._reSpaceAndTab.test(t.graphemeText[s])&&o>0&&(i++,s++),n[o]={line:e,offset:i},s+=t.graphemeLines[o].length,i+=t.graphemeLines[o].length;return n}styleHas(t,e){if(this._styleMap&&!this.isWrapping){const i=this._styleMap[e];i&&(e=i.line)}return super.styleHas(t,e)}isEmptyStyles(t){if(!this.styles)return!0;let e,i=0,s=t+1,n=!1;const o=this._styleMap[t],a=this._styleMap[t+1];o&&(t=o.line,i=o.offset),a&&(s=a.line,n=s===t,e=a.offset);const l=t===void 0?this.styles:{line:this.styles[t]};for(const c in l)for(const h in l[c]){const d=parseInt(h,10);if(d>=i&&(!n||d<e))for(const u in l[c][h])return!1}return!0}_getStyleDeclaration(t,e){if(this._styleMap&&!this.isWrapping){const i=this._styleMap[t];if(!i)return{};t=i.line,e=i.offset+e}return super._getStyleDeclaration(t,e)}_setStyleDeclaration(t,e,i){const s=this._styleMap[t];super._setStyleDeclaration(s.line,s.offset+e,i)}_deleteStyleDeclaration(t,e){const i=this._styleMap[t];super._deleteStyleDeclaration(i.line,i.offset+e)}_getLineStyle(t){const e=this._styleMap[t];return!!this.styles[e.line]}_setLineStyle(t){const e=this._styleMap[t];super._setLineStyle(e.line)}_wrapText(t,e){this.isWrapping=!0;const i=this.getGraphemeDataForRender(t),s=[];for(let n=0;n<i.wordsData.length;n++)s.push(...this._wrapLine(n,e,i));return this.isWrapping=!1,s}getGraphemeDataForRender(t){const e=this.splitByGrapheme,i=e?"":" ";let s=0;return{wordsData:t.map(((n,o)=>{let a=0;const l=e?this.graphemeSplit(n):this.wordSplit(n);return l.length===0?[{word:[],width:0}]:l.map((c=>{const h=e?[c]:this.graphemeSplit(c),d=this._measureWord(h,o,a);return s=Math.max(d,s),a+=h.length+i.length,{word:h,width:d}}))})),largestWordWidth:s}}_measureWord(t,e){let i,s=arguments.length>2&&arguments[2]!==void 0?arguments[2]:0,n=0;for(let o=0,a=t.length;o<a;o++)n+=this._getGraphemeBox(t[o],e,o+s,i,!0).kernedWidth,i=t[o];return n}wordSplit(t){return t.split(this._wordJoiners)}_wrapLine(t,e,i){let{largestWordWidth:s,wordsData:n}=i,o=arguments.length>3&&arguments[3]!==void 0?arguments[3]:0;const a=this._getWidthOfCharSpacing(),l=this.splitByGrapheme,c=[],h=l?"":" ";let d=0,u=[],p=0,g=0,f=!0;e-=o;const m=Math.max(e,s,this.dynamicMinWidth),b=n[t];let _;for(p=0,_=0;_<b.length;_++){const{word:w,width:S}=b[_];p+=w.length,d+=g+S-a,d>m&&!f?(c.push(u),u=[],d=S,f=!0):d+=a,f||l||u.push(h),u=u.concat(w),g=l?0:this._measureWord([h],t,p),p++,f=!1}return _&&c.push(u),s+o>this.dynamicMinWidth&&(this.dynamicMinWidth=s-a+o),c}isEndOfWrapping(t){return!this._styleMap[t+1]||this._styleMap[t+1].line!==this._styleMap[t].line}missingNewlineOffset(t,e){return this.splitByGrapheme&&!e?this.isEndOfWrapping(t)?1:0:1}_splitTextIntoLines(t){const e=super._splitTextIntoLines(t),i=this._wrapText(e.lines,this.width),s=new Array(i.length);for(let n=0;n<i.length;n++)s[n]=i[n].join("");return e.lines=s,e.graphemeLines=i,e}getMinWidth(){return Math.max(this.minWidth,this.dynamicMinWidth)}_removeExtraneousStyles(){const t=new Map;for(const e in this._styleMap){const i=parseInt(e,10);if(this._textLines[i]){const s=this._styleMap[e].line;t.set("".concat(s),!0)}}for(const e in this.styles)t.has(e)||delete this.styles[e]}toObject(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[];return super.toObject(["minWidth","splitByGrapheme",...t])}}v(ui,"type","Textbox"),v(ui,"textLayoutProperties",[...Xe.textLayoutProperties,"width"]),v(ui,"ownDefaults",{minWidth:20,dynamicMinWidth:2,lockScalingFlip:!0,noScaleCache:!1,_wordJoiners:/[ \t\r]/,splitByGrapheme:!1}),A.setClass(ui);class Ol extends fn{shouldPerformLayout(t){return!!t.target.clipPath&&super.shouldPerformLayout(t)}shouldLayoutClipPath(){return!1}calcLayoutResult(t,e){const{target:i}=t,{clipPath:s,group:n}=i;if(!s||!this.shouldPerformLayout(t))return;const{width:o,height:a}=qe(Yc(i,s)),l=new x(o,a);if(s.absolutePositioned)return{center:Zi(s.getRelativeCenterPoint(),void 0,n?n.calcTransformMatrix():void 0),size:l};{const c=s.getRelativeCenterPoint().transform(i.calcOwnMatrix(),!0);if(this.shouldPerformLayout(t)){const{center:h=new x,correction:d=new x}=this.calcBoundingBox(e,t)||{};return{center:h.add(c),correction:d.subtract(c),size:l}}return{center:i.getRelativeCenterPoint().add(c),size:l}}}}v(Ol,"type","clip-path"),A.setClass(Ol);class kl extends fn{getInitialSize(t,e){let{target:i}=t,{size:s}=e;return new x(i.width||s.x,i.height||s.y)}}v(kl,"type","fixed"),A.setClass(kl);class fm extends Ys{subscribeTargets(t){const e=t.target;t.targets.reduce(((i,s)=>(s.parent&&i.add(s.parent),i)),new Set).forEach((i=>{i.layoutManager.subscribeTargets({target:i,targets:[e]})}))}unsubscribeTargets(t){const e=t.target,i=e.getObjects();t.targets.reduce(((s,n)=>(n.parent&&s.add(n.parent),s)),new Set).forEach((s=>{!i.some((n=>n.parent===s))&&s.layoutManager.unsubscribeTargets({target:s,targets:[e]})}))}}class Di extends gi{static getDefaults(){return y(y({},super.getDefaults()),Di.ownDefaults)}constructor(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};super(),Object.assign(this,Di.ownDefaults),this.setOptions(e);const{left:i,top:s,layoutManager:n}=e;this.groupInit(t,{left:i,top:s,layoutManager:n??new fm})}_shouldSetNestedCoords(){return!0}__objectSelectionMonitor(){}multiSelectAdd(){for(var t=arguments.length,e=new Array(t),i=0;i<t;i++)e[i]=arguments[i];this.multiSelectionStacking==="selection-order"?this.add(...e):e.forEach((s=>{const n=this._objects.findIndex((a=>a.isInFrontOf(s))),o=n===-1?this.size():n;this.insertAt(o,s)}))}canEnterGroup(t){return this.getObjects().some((e=>e.isDescendantOf(t)||t.isDescendantOf(e)))?(fi("error","ActiveSelection: circular object trees are not supported, this call has no effect"),!1):super.canEnterGroup(t)}enterGroup(t,e){t.parent&&t.parent===t.group?t.parent._exitGroup(t):t.group&&t.parent!==t.group&&t.group.remove(t),this._enterGroup(t,e)}exitGroup(t,e){this._exitGroup(t,e),t.parent&&t.parent._enterGroup(t,!0)}_onAfterObjectsChange(t,e){super._onAfterObjectsChange(t,e);const i=new Set;e.forEach((s=>{const{parent:n}=s;n&&i.add(n)})),t===Go?i.forEach((s=>{s._onAfterObjectsChange(Gr,e)})):i.forEach((s=>{s._set("dirty",!0)}))}onDeselect(){return this.removeAll(),!1}toString(){return"#<ActiveSelection: (".concat(this.complexity(),")>")}shouldCache(){return!1}isOnACache(){return!1}_renderControls(t,e,i){t.save(),t.globalAlpha=this.isMoving?this.borderOpacityWhenMoving:1;const s=y(y({hasControls:!1},i),{},{forActiveSelection:!0});for(let n=0;n<this._objects.length;n++)this._objects[n]._renderControls(t,s);super._renderControls(t,e),t.restore()}}v(Di,"type","ActiveSelection"),v(Di,"ownDefaults",{multiSelectionStacking:"canvas-stacking"}),A.setClass(Di),A.setClass(Di,"activeSelection");class mm{constructor(){v(this,"resources",{})}applyFilters(t,e,i,s,n){const o=n.getContext("2d");if(!o)return;o.drawImage(e,0,0,i,s);const a={sourceWidth:i,sourceHeight:s,imageData:o.getImageData(0,0,i,s),originalEl:e,originalImageData:o.getImageData(0,0,i,s),canvasEl:n,ctx:o,filterBackend:this};t.forEach((c=>{c.applyTo(a)}));const{imageData:l}=a;return l.width===i&&l.height===s||(n.width=l.width,n.height=l.height),o.putImageData(l,0,0),a}}class lh{constructor(){let{tileSize:t=W.textureSize}=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};v(this,"aPosition",new Float32Array([0,0,0,1,1,0,1,1])),v(this,"resources",{}),this.tileSize=t,this.setupGLContext(t,t),this.captureGPUInfo()}setupGLContext(t,e){this.dispose(),this.createWebGLCanvas(t,e)}createWebGLCanvas(t,e){const i=ve({width:t,height:e}),s=i.getContext("webgl",{alpha:!0,premultipliedAlpha:!1,depth:!1,stencil:!1,antialias:!1});s&&(s.clearColor(0,0,0,0),this.canvas=i,this.gl=s)}applyFilters(t,e,i,s,n,o){const a=this.gl,l=n.getContext("2d");if(!a||!l)return;let c;o&&(c=this.getCachedTexture(o,e));const h={originalWidth:e.width||e.naturalWidth||0,originalHeight:e.height||e.naturalHeight||0,sourceWidth:i,sourceHeight:s,destinationWidth:i,destinationHeight:s,context:a,sourceTexture:this.createTexture(a,i,s,c?void 0:e),targetTexture:this.createTexture(a,i,s),originalTexture:c||this.createTexture(a,i,s,c?void 0:e),passes:t.length,webgl:!0,aPosition:this.aPosition,programCache:this.programCache,pass:0,filterBackend:this,targetCanvas:n},d=a.createFramebuffer();return a.bindFramebuffer(a.FRAMEBUFFER,d),t.forEach((u=>{u&&u.applyTo(h)})),(function(u){const p=u.targetCanvas,g=p.width,f=p.height,m=u.destinationWidth,b=u.destinationHeight;g===m&&f===b||(p.width=m,p.height=b)})(h),this.copyGLTo2D(a,h),a.bindTexture(a.TEXTURE_2D,null),a.deleteTexture(h.sourceTexture),a.deleteTexture(h.targetTexture),a.deleteFramebuffer(d),l.setTransform(1,0,0,1,0,0),h}dispose(){this.canvas&&(this.canvas=null,this.gl=null),this.clearWebGLCaches()}clearWebGLCaches(){this.programCache={},this.textureCache={}}createTexture(t,e,i,s,n){const{NEAREST:o,TEXTURE_2D:a,RGBA:l,UNSIGNED_BYTE:c,CLAMP_TO_EDGE:h,TEXTURE_MAG_FILTER:d,TEXTURE_MIN_FILTER:u,TEXTURE_WRAP_S:p,TEXTURE_WRAP_T:g}=t,f=t.createTexture();return t.bindTexture(a,f),t.texParameteri(a,d,n||o),t.texParameteri(a,u,n||o),t.texParameteri(a,p,h),t.texParameteri(a,g,h),s?t.texImage2D(a,0,l,l,c,s):t.texImage2D(a,0,l,e,i,0,l,c,null),f}getCachedTexture(t,e,i){const{textureCache:s}=this;if(s[t])return s[t];{const n=this.createTexture(this.gl,e.width,e.height,e,i);return n&&(s[t]=n),n}}evictCachesForKey(t){this.textureCache[t]&&(this.gl.deleteTexture(this.textureCache[t]),delete this.textureCache[t])}copyGLTo2D(t,e){const i=t.canvas,s=e.targetCanvas,n=s.getContext("2d");if(!n)return;n.translate(0,s.height),n.scale(1,-1);const o=i.height-s.height;n.drawImage(i,0,o,s.width,s.height,0,0,s.width,s.height)}copyGLTo2DPutImageData(t,e){const i=e.targetCanvas.getContext("2d"),s=e.destinationWidth,n=e.destinationHeight,o=s*n*4;if(!i)return;const a=new Uint8Array(this.imageBuffer,0,o),l=new Uint8ClampedArray(this.imageBuffer,0,o);t.readPixels(0,0,s,n,t.RGBA,t.UNSIGNED_BYTE,a);const c=new ImageData(l,s,n);i.putImageData(c,0,0)}captureGPUInfo(){if(this.gpuInfo)return this.gpuInfo;const t=this.gl,e={renderer:"",vendor:""};if(!t)return e;const i=t.getExtension("WEBGL_debug_renderer_info");if(i){const s=t.getParameter(i.UNMASKED_RENDERER_WEBGL),n=t.getParameter(i.UNMASKED_VENDOR_WEBGL);s&&(e.renderer=s.toLowerCase()),n&&(e.vendor=n.toLowerCase())}return this.gpuInfo=e,e}}let Vn;function bm(){const{WebGLProbe:r}=Re();return r.queryWebGL(ti()),W.enableGLFiltering&&r.isSupported(W.textureSize)?new lh({tileSize:W.textureSize}):new mm}function Nn(){return!Vn&&(!(arguments.length>0&&arguments[0]!==void 0)||arguments[0])&&(Vn=bm()),Vn}const vm=["filters","resizeFilter","src","crossOrigin","type"],ch=["cropX","cropY"];class te extends Ht{static getDefaults(){return y(y({},super.getDefaults()),te.ownDefaults)}constructor(t,e){super(),v(this,"_lastScaleX",1),v(this,"_lastScaleY",1),v(this,"_filterScalingX",1),v(this,"_filterScalingY",1),this.filters=[],Object.assign(this,te.ownDefaults),this.setOptions(e),this.cacheKey="texture".concat(mi()),this.setElement(typeof t=="string"?(this.canvas&&we(this.canvas.getElement())||ss()).getElementById(t):t,e)}getElement(){return this._element}setElement(t){var e;let i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};this.removeTexture(this.cacheKey),this.removeTexture("".concat(this.cacheKey,"_filtered")),this._element=t,this._originalElement=t,this._setWidthHeight(i),(e=t.classList)===null||e===void 0||e.add(te.CSS_CANVAS),this.filters.length!==0&&this.applyFilters(),this.resizeFilter&&this.applyResizeFilters()}removeTexture(t){const e=Nn(!1);e instanceof lh&&e.evictCachesForKey(t)}dispose(){super.dispose(),this.removeTexture(this.cacheKey),this.removeTexture("".concat(this.cacheKey,"_filtered")),this._cacheContext=null,["_originalElement","_element","_filteredEl","_cacheCanvas"].forEach((t=>{const e=this[t];e&&Re().dispose(e),this[t]=void 0}))}getCrossOrigin(){return this._originalElement&&(this._originalElement.crossOrigin||null)}getOriginalSize(){const t=this.getElement();return t?{width:t.naturalWidth||t.width,height:t.naturalHeight||t.height}:{width:0,height:0}}_stroke(t){if(!this.stroke||this.strokeWidth===0)return;const e=this.width/2,i=this.height/2;t.beginPath(),t.moveTo(-e,-i),t.lineTo(e,-i),t.lineTo(e,i),t.lineTo(-e,i),t.lineTo(-e,-i),t.closePath()}toObject(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[];const e=[];return this.filters.forEach((i=>{i&&e.push(i.toObject())})),y(y({},super.toObject([...ch,...t])),{},{src:this.getSrc(),crossOrigin:this.getCrossOrigin(),filters:e},this.resizeFilter?{resizeFilter:this.resizeFilter.toObject()}:{})}hasCrop(){return!!this.cropX||!!this.cropY||this.width<this._element.width||this.height<this._element.height}_toSVG(){const t=[],e=this._element,i=-this.width/2,s=-this.height/2;let n=[],o=[],a="",l="";if(!e)return[];if(this.hasCrop()){const c=mi();n.push('<clipPath id="imageCrop_'+c+`">
|
|
2377
2377
|
`,' <rect x="'+i+'" y="'+s+'" width="'+this.width+'" height="'+this.height+`" />
|
|
2378
2378
|
`,`</clipPath>
|
|
2379
2379
|
`),a=' clip-path="url(#imageCrop_'+c+')" '}if(this.imageSmoothing||(l=' image-rendering="optimizeSpeed"'),t.push(" <image ","COMMON_PARTS",'xlink:href="'.concat(this.getSvgSrc(!0),'" x="').concat(i-this.cropX,'" y="').concat(s-this.cropY,'" width="').concat(e.width||e.naturalWidth,'" height="').concat(e.height||e.naturalHeight,'"').concat(l).concat(a,`></image>
|
|
2380
2380
|
`)),this.stroke||this.strokeDashArray){const c=this.fill;this.fill=null,o=[' <rect x="'.concat(i,'" y="').concat(s,'" width="').concat(this.width,'" height="').concat(this.height,'" style="').concat(this.getSvgStyles(),`" />
|
|
2381
|
-
`)],this.fill=c}return n=this.paintFirst!==Dt?n.concat(o,t):n.concat(t,o),n}getSrc(t){const e=t?this._element:this._originalElement;return e?e.toDataURL?e.toDataURL():this.srcFromAttribute?e.getAttribute("src")||"":e.src:this.src||""}getSvgSrc(t){return this.getSrc(t)}setSrc(t){let{crossOrigin:e,signal:i}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return Ir(t,{crossOrigin:e,signal:i}).then((s=>{e!==void 0&&this.set({crossOrigin:e}),this.setElement(s)}))}toString(){return'#<Image: { src: "'.concat(this.getSrc(),'" }>')}applyResizeFilters(){const t=this.resizeFilter,e=this.minimumScaleTrigger,i=this.getTotalObjectScaling(),s=i.x,n=i.y,o=this._filteredEl||this._originalElement;if(this.group&&this.set("dirty",!0),!t||s>e&&n>e)return this._element=o,this._filterScalingX=1,this._filterScalingY=1,this._lastScaleX=s,void(this._lastScaleY=n);const a=ve(o),{width:l,height:c}=o;this._element=a,this._lastScaleX=t.scaleX=s,this._lastScaleY=t.scaleY=n,Nn().applyFilters([t],o,l,c,this._element),this._filterScalingX=a.width/this._originalElement.width,this._filterScalingY=a.height/this._originalElement.height}applyFilters(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:this.filters||[];if(t=t.filter((n=>n&&!n.isNeutralState())),this.set("dirty",!0),this.removeTexture("".concat(this.cacheKey,"_filtered")),t.length===0)return this._element=this._originalElement,this._filteredEl=void 0,this._filterScalingX=1,void(this._filterScalingY=1);const e=this._originalElement,i=e.naturalWidth||e.width,s=e.naturalHeight||e.height;if(this._element===this._originalElement){const n=ve({width:i,height:s});this._element=n,this._filteredEl=n}else this._filteredEl&&(this._element=this._filteredEl,this._filteredEl.getContext("2d").clearRect(0,0,i,s),this._lastScaleX=1,this._lastScaleY=1);Nn().applyFilters(t,this._originalElement,i,s,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)}_render(t){t.imageSmoothingEnabled=this.imageSmoothing,this.isMoving!==!0&&this.resizeFilter&&this._needsResize()&&this.applyResizeFilters(),this._stroke(t),this._renderPaintInOrder(t)}drawCacheOnCanvas(t){t.imageSmoothingEnabled=this.imageSmoothing,super.drawCacheOnCanvas(t)}shouldCache(){return this.needsItsOwnCache()}_renderFill(t){const e=this._element;if(!e)return;const i=this._filterScalingX,s=this._filterScalingY,n=this.width,o=this.height,a=Math.max(this.cropX,0),l=Math.max(this.cropY,0),c=e.naturalWidth||e.width,h=e.naturalHeight||e.height,d=a*i,u=l*s,p=Math.min(n*i,c-d),g=Math.min(o*s,h-u),f=-n/2,m=-o/2,b=Math.min(n,c/i-a),_=Math.min(o,h/s-l);e&&t.drawImage(e,d,u,p,g,f,m,b,_)}_needsResize(){const t=this.getTotalObjectScaling();return t.x!==this._lastScaleX||t.y!==this._lastScaleY}_resetWidthHeight(){this.set(this.getOriginalSize())}_setWidthHeight(){let{width:t,height:e}=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};const i=this.getOriginalSize();this.width=t||i.width,this.height=e||i.height}parsePreserveAspectRatioAttribute(){const t=cg(this.preserveAspectRatio||""),e=this.width,i=this.height,s={width:e,height:i};let n,o=this._element.width,a=this._element.height,l=1,c=1,h=0,d=0,u=0,p=0;return!t||t.alignX===se&&t.alignY===se?(l=e/o,c=i/a):(t.meetOrSlice==="meet"&&(l=c=Ef(this._element,s),n=(e-o*l)/2,t.alignX==="Min"&&(h=-n),t.alignX==="Max"&&(h=n),n=(i-a*c)/2,t.alignY==="Min"&&(d=-n),t.alignY==="Max"&&(d=n)),t.meetOrSlice==="slice"&&(l=c=Of(this._element,s),n=o-e/l,t.alignX==="Mid"&&(u=n/2),t.alignX==="Max"&&(u=n),n=a-i/c,t.alignY==="Mid"&&(p=n/2),t.alignY==="Max"&&(p=n),o=e/l,a=i/c)),{width:o,height:a,scaleX:l,scaleY:c,offsetLeft:h,offsetTop:d,cropX:u,cropY:p}}static fromObject(t,e){let{filters:i,resizeFilter:s,src:n,crossOrigin:o,type:a}=t,l=rt(t,vm);return Promise.all([Ir(n,y(y({},e),{},{crossOrigin:o})),i&&Vs(i,e),s&&Vs([s],e),dn(l,e)]).then((c=>{let[h,d=[],[u]=[],p={}]=c;return new this(h,y(y({},l),{},{src:n,filters:d,resizeFilter:u},p))}))}static fromURL(t){let{crossOrigin:e=null,signal:i}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},s=arguments.length>2?arguments[2]:void 0;return Ir(t,{crossOrigin:e,signal:i}).then((n=>new this(n,s)))}static async fromElement(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},i=arguments.length>2?arguments[2]:void 0;const s=ni(t,this.ATTRIBUTE_NAMES,i);return this.fromURL(s["xlink:href"]||s.href,e,s).catch((n=>(
|
|
2381
|
+
`)],this.fill=c}return n=this.paintFirst!==Dt?n.concat(o,t):n.concat(t,o),n}getSrc(t){const e=t?this._element:this._originalElement;return e?e.toDataURL?e.toDataURL():this.srcFromAttribute?e.getAttribute("src")||"":e.src:this.src||""}getSvgSrc(t){return this.getSrc(t)}setSrc(t){let{crossOrigin:e,signal:i}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return Ir(t,{crossOrigin:e,signal:i}).then((s=>{e!==void 0&&this.set({crossOrigin:e}),this.setElement(s)}))}toString(){return'#<Image: { src: "'.concat(this.getSrc(),'" }>')}applyResizeFilters(){const t=this.resizeFilter,e=this.minimumScaleTrigger,i=this.getTotalObjectScaling(),s=i.x,n=i.y,o=this._filteredEl||this._originalElement;if(this.group&&this.set("dirty",!0),!t||s>e&&n>e)return this._element=o,this._filterScalingX=1,this._filterScalingY=1,this._lastScaleX=s,void(this._lastScaleY=n);const a=ve(o),{width:l,height:c}=o;this._element=a,this._lastScaleX=t.scaleX=s,this._lastScaleY=t.scaleY=n,Nn().applyFilters([t],o,l,c,this._element),this._filterScalingX=a.width/this._originalElement.width,this._filterScalingY=a.height/this._originalElement.height}applyFilters(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:this.filters||[];if(t=t.filter((n=>n&&!n.isNeutralState())),this.set("dirty",!0),this.removeTexture("".concat(this.cacheKey,"_filtered")),t.length===0)return this._element=this._originalElement,this._filteredEl=void 0,this._filterScalingX=1,void(this._filterScalingY=1);const e=this._originalElement,i=e.naturalWidth||e.width,s=e.naturalHeight||e.height;if(this._element===this._originalElement){const n=ve({width:i,height:s});this._element=n,this._filteredEl=n}else this._filteredEl&&(this._element=this._filteredEl,this._filteredEl.getContext("2d").clearRect(0,0,i,s),this._lastScaleX=1,this._lastScaleY=1);Nn().applyFilters(t,this._originalElement,i,s,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)}_render(t){t.imageSmoothingEnabled=this.imageSmoothing,this.isMoving!==!0&&this.resizeFilter&&this._needsResize()&&this.applyResizeFilters(),this._stroke(t),this._renderPaintInOrder(t)}drawCacheOnCanvas(t){t.imageSmoothingEnabled=this.imageSmoothing,super.drawCacheOnCanvas(t)}shouldCache(){return this.needsItsOwnCache()}_renderFill(t){const e=this._element;if(!e)return;const i=this._filterScalingX,s=this._filterScalingY,n=this.width,o=this.height,a=Math.max(this.cropX,0),l=Math.max(this.cropY,0),c=e.naturalWidth||e.width,h=e.naturalHeight||e.height,d=a*i,u=l*s,p=Math.min(n*i,c-d),g=Math.min(o*s,h-u),f=-n/2,m=-o/2,b=Math.min(n,c/i-a),_=Math.min(o,h/s-l);e&&t.drawImage(e,d,u,p,g,f,m,b,_)}_needsResize(){const t=this.getTotalObjectScaling();return t.x!==this._lastScaleX||t.y!==this._lastScaleY}_resetWidthHeight(){this.set(this.getOriginalSize())}_setWidthHeight(){let{width:t,height:e}=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};const i=this.getOriginalSize();this.width=t||i.width,this.height=e||i.height}parsePreserveAspectRatioAttribute(){const t=cg(this.preserveAspectRatio||""),e=this.width,i=this.height,s={width:e,height:i};let n,o=this._element.width,a=this._element.height,l=1,c=1,h=0,d=0,u=0,p=0;return!t||t.alignX===se&&t.alignY===se?(l=e/o,c=i/a):(t.meetOrSlice==="meet"&&(l=c=Ef(this._element,s),n=(e-o*l)/2,t.alignX==="Min"&&(h=-n),t.alignX==="Max"&&(h=n),n=(i-a*c)/2,t.alignY==="Min"&&(d=-n),t.alignY==="Max"&&(d=n)),t.meetOrSlice==="slice"&&(l=c=Of(this._element,s),n=o-e/l,t.alignX==="Mid"&&(u=n/2),t.alignX==="Max"&&(u=n),n=a-i/c,t.alignY==="Mid"&&(p=n/2),t.alignY==="Max"&&(p=n),o=e/l,a=i/c)),{width:o,height:a,scaleX:l,scaleY:c,offsetLeft:h,offsetTop:d,cropX:u,cropY:p}}static fromObject(t,e){let{filters:i,resizeFilter:s,src:n,crossOrigin:o,type:a}=t,l=rt(t,vm);return Promise.all([Ir(n,y(y({},e),{},{crossOrigin:o})),i&&Vs(i,e),s&&Vs([s],e),dn(l,e)]).then((c=>{let[h,d=[],[u]=[],p={}]=c;return new this(h,y(y({},l),{},{src:n,filters:d,resizeFilter:u},p))}))}static fromURL(t){let{crossOrigin:e=null,signal:i}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},s=arguments.length>2?arguments[2]:void 0;return Ir(t,{crossOrigin:e,signal:i}).then((n=>new this(n,s)))}static async fromElement(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},i=arguments.length>2?arguments[2]:void 0;const s=ni(t,this.ATTRIBUTE_NAMES,i);return this.fromURL(s["xlink:href"]||s.href,e,s).catch((n=>(fi("log","Unable to parse Image",n),null)))}}v(te,"type","Image"),v(te,"cacheProperties",[...ri,...ch]),v(te,"ownDefaults",{strokeWidth:0,srcFromAttribute:!1,minimumScaleTrigger:.5,cropX:0,cropY:0,imageSmoothing:!0}),v(te,"CSS_CANVAS","canvas-img"),v(te,"ATTRIBUTE_NAMES",[...yi,"x","y","width","height","preserveAspectRatio","xlink:href","href","crossOrigin","image-rendering"]),A.setClass(te),A.setSVGClass(te);pn(["pattern","defs","symbol","metadata","clipPath","mask","desc"]);const bn=r=>r.webgl!==void 0,Xo="precision highp float",ym=`
|
|
2382
2382
|
`.concat(Xo,`;
|
|
2383
2383
|
varying vec2 vTexCoord;
|
|
2384
2384
|
uniform sampler2D uTexture;
|
|
@@ -2429,7 +2429,7 @@ Resulting to default behavior: removing object from previous canvas and adding t
|
|
|
2429
2429
|
`.concat(Cm[this.mode],`
|
|
2430
2430
|
}
|
|
2431
2431
|
}
|
|
2432
|
-
`)}applyTo2d(t){let{imageData:{data:e}}=t;const i=new
|
|
2432
|
+
`)}applyTo2d(t){let{imageData:{data:e}}=t;const i=new q(this.color).getSource(),s=this.alpha,n=i[0]*s,o=i[1]*s,a=i[2]*s,l=1-s;for(let c=0;c<e.length;c+=4){const h=e[c],d=e[c+1],u=e[c+2];let p,g,f;switch(this.mode){case"multiply":p=h*n/255,g=d*o/255,f=u*a/255;break;case"screen":p=255-(255-h)*(255-n)/255,g=255-(255-d)*(255-o)/255,f=255-(255-u)*(255-a)/255;break;case"add":p=h+n,g=d+o,f=u+a;break;case"difference":p=Math.abs(h-n),g=Math.abs(d-o),f=Math.abs(u-a);break;case"subtract":p=h-n,g=d-o,f=u-a;break;case"darken":p=Math.min(h,n),g=Math.min(d,o),f=Math.min(u,a);break;case"lighten":p=Math.max(h,n),g=Math.max(d,o),f=Math.max(u,a);break;case"overlay":p=n<128?2*h*n/255:255-2*(255-h)*(255-n)/255,g=o<128?2*d*o/255:255-2*(255-d)*(255-o)/255,f=a<128?2*u*a/255:255-2*(255-u)*(255-a)/255;break;case"exclusion":p=n+h-2*n*h/255,g=o+d-2*o*d/255,f=a+u-2*a*u/255;break;case"tint":p=n+h*l,g=o+d*l,f=a+u*l}e[c]=p,e[c+1]=g,e[c+2]=f}}sendUniformData(t,e){const i=new q(this.color).getSource();i[0]=this.alpha*i[0]/255,i[1]=this.alpha*i[1]/255,i[2]=this.alpha*i[2]/255,i[3]=this.alpha,t.uniform4fv(e.uColor,i)}}v(gr,"defaults",{color:"#F95C63",mode:"multiply",alpha:1}),v(gr,"type","BlendColor"),v(gr,"uniformLocations",["uColor"]),A.setClass(gr);const Sm={multiply:`
|
|
2433
2433
|
precision highp float;
|
|
2434
2434
|
uniform sampler2D uTexture;
|
|
2435
2435
|
uniform sampler2D uImage;
|
|
@@ -2504,7 +2504,7 @@ Resulting to default behavior: removing object from previous canvas and adding t
|
|
|
2504
2504
|
color.rgb += uBrightness;
|
|
2505
2505
|
gl_FragColor = color;
|
|
2506
2506
|
}
|
|
2507
|
-
`}applyTo2d(t){let{imageData:{data:e}}=t;const i=Math.round(255*this.brightness);for(let s=0;s<e.length;s+=4)e[s]+=i,e[s+1]+=i,e[s+2]+=i}isNeutralState(){return this.brightness===0}sendUniformData(t,e){t.uniform1f(e.uBrightness,this.brightness)}}v(br,"type","Brightness"),v(br,"defaults",{brightness:0}),v(br,"uniformLocations",["uBrightness"]),A.setClass(br);const
|
|
2507
|
+
`}applyTo2d(t){let{imageData:{data:e}}=t;const i=Math.round(255*this.brightness);for(let s=0;s<e.length;s+=4)e[s]+=i,e[s+1]+=i,e[s+2]+=i}isNeutralState(){return this.brightness===0}sendUniformData(t,e){t.uniform1f(e.uBrightness,this.brightness)}}v(br,"type","Brightness"),v(br,"defaults",{brightness:0}),v(br,"uniformLocations",["uBrightness"]),A.setClass(br);const hh={matrix:[1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1,0],colorsOnly:!0};class Ki extends Mt{getFragmentSource(){return`
|
|
2508
2508
|
precision highp float;
|
|
2509
2509
|
uniform sampler2D uTexture;
|
|
2510
2510
|
varying vec2 vTexCoord;
|
|
@@ -2515,7 +2515,7 @@ Resulting to default behavior: removing object from previous canvas and adding t
|
|
|
2515
2515
|
color *= uColorMatrix;
|
|
2516
2516
|
color += uConstants;
|
|
2517
2517
|
gl_FragColor = color;
|
|
2518
|
-
}`}applyTo2d(t){const e=t.imageData.data,i=this.matrix,s=this.colorsOnly;for(let n=0;n<e.length;n+=4){const o=e[n],a=e[n+1],l=e[n+2];if(e[n]=o*i[0]+a*i[1]+l*i[2]+255*i[4],e[n+1]=o*i[5]+a*i[6]+l*i[7]+255*i[9],e[n+2]=o*i[10]+a*i[11]+l*i[12]+255*i[14],!s){const c=e[n+3];e[n]+=c*i[3],e[n+1]+=c*i[8],e[n+2]+=c*i[13],e[n+3]=o*i[15]+a*i[16]+l*i[17]+c*i[18]+255*i[19]}}}sendUniformData(t,e){const i=this.matrix,s=[i[0],i[1],i[2],i[3],i[5],i[6],i[7],i[8],i[10],i[11],i[12],i[13],i[15],i[16],i[17],i[18]],n=[i[4],i[9],i[14],i[19]];t.uniformMatrix4fv(e.uColorMatrix,!1,s),t.uniform4fv(e.uConstants,n)}toObject(){return y(y({},super.toObject()),{},{matrix:[...this.matrix]})}}function zi(r,t){var e;const i=(v(e=class extends
|
|
2518
|
+
}`}applyTo2d(t){const e=t.imageData.data,i=this.matrix,s=this.colorsOnly;for(let n=0;n<e.length;n+=4){const o=e[n],a=e[n+1],l=e[n+2];if(e[n]=o*i[0]+a*i[1]+l*i[2]+255*i[4],e[n+1]=o*i[5]+a*i[6]+l*i[7]+255*i[9],e[n+2]=o*i[10]+a*i[11]+l*i[12]+255*i[14],!s){const c=e[n+3];e[n]+=c*i[3],e[n+1]+=c*i[8],e[n+2]+=c*i[13],e[n+3]=o*i[15]+a*i[16]+l*i[17]+c*i[18]+255*i[19]}}}sendUniformData(t,e){const i=this.matrix,s=[i[0],i[1],i[2],i[3],i[5],i[6],i[7],i[8],i[10],i[11],i[12],i[13],i[15],i[16],i[17],i[18]],n=[i[4],i[9],i[14],i[19]];t.uniformMatrix4fv(e.uColorMatrix,!1,s),t.uniform4fv(e.uConstants,n)}toObject(){return y(y({},super.toObject()),{},{matrix:[...this.matrix]})}}function zi(r,t){var e;const i=(v(e=class extends Ki{toObject(){return{type:this.type,colorsOnly:this.colorsOnly}}},"type",r),v(e,"defaults",{colorsOnly:!1,matrix:t}),e);return A.setClass(i,r),i}v(Ki,"type","ColorMatrix"),v(Ki,"defaults",hh),v(Ki,"uniformLocations",["uColorMatrix","uConstants"]),A.setClass(Ki);zi("Brownie",[.5997,.34553,-.27082,0,.186,-.0377,.86095,.15059,0,-.1449,.24113,-.07441,.44972,0,-.02965,0,0,0,1,0]);zi("Vintage",[.62793,.32021,-.03965,0,.03784,.02578,.64411,.03259,0,.02926,.0466,-.08512,.52416,0,.02023,0,0,0,1,0]);zi("Kodachrome",[1.12855,-.39673,-.03992,0,.24991,-.16404,1.08352,-.05498,0,.09698,-.16786,-.56034,1.60148,0,.13972,0,0,0,1,0]);zi("Technicolor",[1.91252,-.85453,-.09155,0,.04624,-.30878,1.76589,-.10601,0,-.27589,-.2311,-.75018,1.84759,0,.12137,0,0,0,1,0]);zi("Polaroid",[1.438,-.062,-.062,0,0,-.122,1.378,-.122,0,0,-.016,-.016,1.483,0,0,0,0,0,1,0]);zi("Sepia",[.393,.769,.189,0,0,.349,.686,.168,0,0,.272,.534,.131,0,0,0,0,0,1,0]);zi("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]);class Pl extends Mt{constructor(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};super(t),this.subFilters=t.subFilters||[]}applyTo(t){bn(t)&&(t.passes+=this.subFilters.length-1),this.subFilters.forEach((e=>{e.applyTo(t)}))}toObject(){return{type:this.type,subFilters:this.subFilters.map((t=>t.toObject()))}}isNeutralState(){return!this.subFilters.some((t=>!t.isNeutralState()))}static fromObject(t,e){return Promise.all((t.subFilters||[]).map((i=>A.getClass(i.type).fromObject(i,e)))).then((i=>new this({subFilters:i})))}}v(Pl,"type","Composed"),A.setClass(Pl);class vr extends Mt{getFragmentSource(){return`
|
|
2519
2519
|
precision highp float;
|
|
2520
2520
|
uniform sampler2D uTexture;
|
|
2521
2521
|
uniform float uContrast;
|
|
@@ -2669,7 +2669,7 @@ Resulting to default behavior: removing object from previous canvas and adding t
|
|
|
2669
2669
|
gl_FragColor = color;
|
|
2670
2670
|
gl_FragColor.a = alpha;
|
|
2671
2671
|
}
|
|
2672
|
-
`};class yr extends Mt{getCacheKey(){return"".concat(this.type,"_").concat(Math.sqrt(this.matrix.length),"_").concat(this.opaque?1:0)}getFragmentSource(){return Em[this.getCacheKey()]}applyTo2d(t){const e=t.imageData,i=e.data,s=this.matrix,n=Math.round(Math.sqrt(s.length)),o=Math.floor(n/2),a=e.width,l=e.height,c=t.ctx.createImageData(a,l),h=c.data,d=this.opaque?1:0;let u,p,g,f,m,b,_,w,S,T,k,O,E;for(k=0;k<l;k++)for(T=0;T<a;T++){for(m=4*(k*a+T),u=0,p=0,g=0,f=0,E=0;E<n;E++)for(O=0;O<n;O++)_=k+E-o,b=T+O-o,_<0||_>=l||b<0||b>=a||(w=4*(_*a+b),S=s[E*n+O],u+=i[w]*S,p+=i[w+1]*S,g+=i[w+2]*S,d||(f+=i[w+3]*S));h[m]=u,h[m+1]=p,h[m+2]=g,h[m+3]=d?i[m+3]:f}t.imageData=c}sendUniformData(t,e){t.uniform1fv(e.uMatrix,this.matrix)}toObject(){return y(y({},super.toObject()),{},{opaque:this.opaque,matrix:[...this.matrix]})}}v(yr,"type","Convolute"),v(yr,"defaults",{opaque:!1,matrix:[0,0,0,0,1,0,0,0,0]}),v(yr,"uniformLocations",["uMatrix","uOpaque","uHalfSize","uSize"]),A.setClass(yr);const
|
|
2672
|
+
`};class yr extends Mt{getCacheKey(){return"".concat(this.type,"_").concat(Math.sqrt(this.matrix.length),"_").concat(this.opaque?1:0)}getFragmentSource(){return Em[this.getCacheKey()]}applyTo2d(t){const e=t.imageData,i=e.data,s=this.matrix,n=Math.round(Math.sqrt(s.length)),o=Math.floor(n/2),a=e.width,l=e.height,c=t.ctx.createImageData(a,l),h=c.data,d=this.opaque?1:0;let u,p,g,f,m,b,_,w,S,T,k,O,E;for(k=0;k<l;k++)for(T=0;T<a;T++){for(m=4*(k*a+T),u=0,p=0,g=0,f=0,E=0;E<n;E++)for(O=0;O<n;O++)_=k+E-o,b=T+O-o,_<0||_>=l||b<0||b>=a||(w=4*(_*a+b),S=s[E*n+O],u+=i[w]*S,p+=i[w+1]*S,g+=i[w+2]*S,d||(f+=i[w+3]*S));h[m]=u,h[m+1]=p,h[m+2]=g,h[m+3]=d?i[m+3]:f}t.imageData=c}sendUniformData(t,e){t.uniform1fv(e.uMatrix,this.matrix)}toObject(){return y(y({},super.toObject()),{},{opaque:this.opaque,matrix:[...this.matrix]})}}v(yr,"type","Convolute"),v(yr,"defaults",{opaque:!1,matrix:[0,0,0,0,1,0,0,0,0]}),v(yr,"uniformLocations",["uMatrix","uOpaque","uHalfSize","uSize"]),A.setClass(yr);const dh="Gamma";class _r extends Mt{getFragmentSource(){return`
|
|
2673
2673
|
precision highp float;
|
|
2674
2674
|
uniform sampler2D uTexture;
|
|
2675
2675
|
uniform vec3 uGamma;
|
|
@@ -2683,7 +2683,7 @@ Resulting to default behavior: removing object from previous canvas and adding t
|
|
|
2683
2683
|
gl_FragColor = color;
|
|
2684
2684
|
gl_FragColor.rgb *= color.a;
|
|
2685
2685
|
}
|
|
2686
|
-
`}constructor(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};super(t),this.gamma=t.gamma||this.constructor.defaults.gamma.concat()}applyTo2d(t){let{imageData:{data:e}}=t;const i=this.gamma,s=1/i[0],n=1/i[1],o=1/i[2];this.rgbValues||(this.rgbValues={r:new Uint8Array(256),g:new Uint8Array(256),b:new Uint8Array(256)});const a=this.rgbValues;for(let l=0;l<256;l++)a.r[l]=255*Math.pow(l/255,s),a.g[l]=255*Math.pow(l/255,n),a.b[l]=255*Math.pow(l/255,o);for(let l=0;l<e.length;l+=4)e[l]=a.r[e[l]],e[l+1]=a.g[e[l+1]],e[l+2]=a.b[e[l+2]]}sendUniformData(t,e){t.uniform3fv(e.uGamma,this.gamma)}isNeutralState(){const{gamma:t}=this;return t[0]===1&&t[1]===1&&t[2]===1}toObject(){return{type:
|
|
2686
|
+
`}constructor(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};super(t),this.gamma=t.gamma||this.constructor.defaults.gamma.concat()}applyTo2d(t){let{imageData:{data:e}}=t;const i=this.gamma,s=1/i[0],n=1/i[1],o=1/i[2];this.rgbValues||(this.rgbValues={r:new Uint8Array(256),g:new Uint8Array(256),b:new Uint8Array(256)});const a=this.rgbValues;for(let l=0;l<256;l++)a.r[l]=255*Math.pow(l/255,s),a.g[l]=255*Math.pow(l/255,n),a.b[l]=255*Math.pow(l/255,o);for(let l=0;l<e.length;l+=4)e[l]=a.r[e[l]],e[l+1]=a.g[e[l+1]],e[l+2]=a.b[e[l+2]]}sendUniformData(t,e){t.uniform3fv(e.uGamma,this.gamma)}isNeutralState(){const{gamma:t}=this;return t[0]===1&&t[1]===1&&t[2]===1}toObject(){return{type:dh,gamma:this.gamma.concat()}}}v(_r,"type",dh),v(_r,"defaults",{gamma:[1,1,1]}),v(_r,"uniformLocations",["uGamma"]),A.setClass(_r);const Om={average:`
|
|
2687
2687
|
precision highp float;
|
|
2688
2688
|
uniform sampler2D uTexture;
|
|
2689
2689
|
varying vec2 vTexCoord;
|
|
@@ -2712,7 +2712,7 @@ Resulting to default behavior: removing object from previous canvas and adding t
|
|
|
2712
2712
|
float average = 0.21 * col.r + 0.72 * col.g + 0.07 * col.b;
|
|
2713
2713
|
gl_FragColor = vec4(average, average, average, col.a);
|
|
2714
2714
|
}
|
|
2715
|
-
`};class xr extends Mt{applyTo2d(t){let{imageData:{data:e}}=t;for(let i,s=0;s<e.length;s+=4){const n=e[s],o=e[s+1],a=e[s+2];switch(this.mode){case"average":i=(n+o+a)/3;break;case"lightness":i=(Math.min(n,o,a)+Math.max(n,o,a))/2;break;case"luminosity":i=.21*n+.72*o+.07*a}e[s+2]=e[s+1]=e[s]=i}}getCacheKey(){return"".concat(this.type,"_").concat(this.mode)}getFragmentSource(){return Om[this.mode]}sendUniformData(t,e){t.uniform1i(e.uMode,1)}isNeutralState(){return!1}}v(xr,"type","Grayscale"),v(xr,"defaults",{mode:"average"}),v(xr,"uniformLocations",["uMode"]),A.setClass(xr);const km=y(y({},
|
|
2715
|
+
`};class xr extends Mt{applyTo2d(t){let{imageData:{data:e}}=t;for(let i,s=0;s<e.length;s+=4){const n=e[s],o=e[s+1],a=e[s+2];switch(this.mode){case"average":i=(n+o+a)/3;break;case"lightness":i=(Math.min(n,o,a)+Math.max(n,o,a))/2;break;case"luminosity":i=.21*n+.72*o+.07*a}e[s+2]=e[s+1]=e[s]=i}}getCacheKey(){return"".concat(this.type,"_").concat(this.mode)}getFragmentSource(){return Om[this.mode]}sendUniformData(t,e){t.uniform1i(e.uMode,1)}isNeutralState(){return!1}}v(xr,"type","Grayscale"),v(xr,"defaults",{mode:"average"}),v(xr,"uniformLocations",["uMode"]),A.setClass(xr);const km=y(y({},hh),{},{rotation:0});class Un extends Ki{calculateMatrix(){const t=this.rotation*Math.PI,e=Je(t),i=Qe(t),s=1/3,n=Math.sqrt(s)*i,o=1-e;this.matrix=[e+o/3,s*o-n,s*o+n,0,0,s*o+n,e+s*o,s*o-n,0,0,s*o-n,s*o+n,e+s*o,0,0,0,0,0,1,0]}isNeutralState(){return this.rotation===0}applyTo(t){this.calculateMatrix(),super.applyTo(t)}toObject(){return{type:this.type,rotation:this.rotation}}}v(Un,"type","HueRotation"),v(Un,"defaults",km),A.setClass(Un);class wr extends Mt{applyTo2d(t){let{imageData:{data:e}}=t;for(let i=0;i<e.length;i+=4)e[i]=255-e[i],e[i+1]=255-e[i+1],e[i+2]=255-e[i+2],this.alpha&&(e[i+3]=255-e[i+3])}getFragmentSource(){return`
|
|
2716
2716
|
precision highp float;
|
|
2717
2717
|
uniform sampler2D uTexture;
|
|
2718
2718
|
uniform int uInvert;
|
|
@@ -2775,7 +2775,7 @@ void main() {
|
|
|
2775
2775
|
gl_FragColor.a = 0.0;
|
|
2776
2776
|
}
|
|
2777
2777
|
}
|
|
2778
|
-
`}applyTo2d(t){let{imageData:{data:e}}=t;const i=255*this.distance,s=new
|
|
2778
|
+
`}applyTo2d(t){let{imageData:{data:e}}=t;const i=255*this.distance,s=new q(this.color).getSource(),n=[s[0]-i,s[1]-i,s[2]-i],o=[s[0]+i,s[1]+i,s[2]+i];for(let a=0;a<e.length;a+=4){const l=e[a],c=e[a+1],h=e[a+2];l>n[0]&&c>n[1]&&h>n[2]&&l<o[0]&&c<o[1]&&h<o[2]&&(e[a+3]=0)}}sendUniformData(t,e){const i=new q(this.color).getSource(),s=this.distance,n=[0+i[0]/255-s,0+i[1]/255-s,0+i[2]/255-s,1],o=[i[0]/255+s,i[1]/255+s,i[2]/255+s,1];t.uniform4fv(e.uLow,n),t.uniform4fv(e.uHigh,o)}}v(Tr,"type","RemoveColor"),v(Tr,"defaults",{color:"#FFFFFF",distance:.02,useAlpha:!1}),v(Tr,"uniformLocations",["uLow","uHigh"]),A.setClass(Tr);class Er extends Mt{sendUniformData(t,e){t.uniform2fv(e.uDelta,this.horizontal?[1/this.width,0]:[0,1/this.height]),t.uniform1fv(e.uTaps,this.taps)}getFilterWindow(){const t=this.tempScale;return Math.ceil(this.lanczosLobes/t)}getCacheKey(){const t=this.getFilterWindow();return"".concat(this.type,"_").concat(t)}getFragmentSource(){const t=this.getFilterWindow();return this.generateShader(t)}getTaps(){const t=this.lanczosCreate(this.lanczosLobes),e=this.tempScale,i=this.getFilterWindow(),s=new Array(i);for(let n=1;n<=i;n++)s[n-1]=t(n*e);return s}generateShader(t){const e=new Array(t);for(let i=1;i<=t;i++)e[i-1]="".concat(i,".0 * uDelta");return`
|
|
2779
2779
|
precision highp float;
|
|
2780
2780
|
uniform sampler2D uTexture;
|
|
2781
2781
|
uniform vec2 uDelta;
|
|
@@ -2820,7 +2820,7 @@ void main() {
|
|
|
2820
2820
|
color.b += max != color.b ? (max - color.b) * amt : 0.00;
|
|
2821
2821
|
gl_FragColor = color;
|
|
2822
2822
|
}
|
|
2823
|
-
`}applyTo2d(t){let{imageData:{data:e}}=t;const i=-this.vibrance;for(let s=0;s<e.length;s+=4){const n=e[s],o=e[s+1],a=e[s+2],l=Math.max(n,o,a),c=(n+o+a)/3,h=2*Math.abs(l-c)/255*i;e[s]+=l!==n?(l-n)*h:0,e[s+1]+=l!==o?(l-o)*h:0,e[s+2]+=l!==a?(l-a)*h:0}}sendUniformData(t,e){t.uniform1f(e.uVibrance,-this.vibrance)}isNeutralState(){return this.vibrance===0}}v(kr,"type","Vibrance"),v(kr,"defaults",{vibrance:0}),v(kr,"uniformLocations",["uVibrance"]),A.setClass(kr);var Pm=Object.defineProperty,Am=Object.getOwnPropertyDescriptor,Pt=(r,t,e,i)=>{for(var s=i>1?void 0:i?Am(t,e):t,n=r.length-1,o;n>=0;n--)(o=r[n])&&(s=(i?o(t,e,s):o(s))||s);return i&&s&&Pm(t,e,s),s};let dt=class extends kt{constructor(){super(...arguments),this.backgroundImageUrl=void 0,this.handwrittenImageUrl=void 0,this.imageHeight=null,this.imageWidth=null,this.imageLeft=null,this.imageTop=null,this.displayType="default",this.backgroundFabImg=void 0,this.rect=void 0,this.areaPosition={left:0,top:0},this.uploadingText=void 0,this.handwrittenImage=void 0,this.clipMaskOverlay=void 0,this.areaSize={width:0,height:0},this._dimensionsUpdateTimeout=void 0,this.DEFAULT_BACKGROUND_URL="https://cdn.shopify.com/s/files/1/1956/2323/files/insert_86e8bcd5-3e82-4910-b350-485fa6958502.png?v=1726598821",this.AREA_PERCENTAGES={default:{left:.084,top:.4899,width:.832,height:.45},fullSize:{left:.084,top:.06,width:.832,height:.879}},this.HANDWRITTEN_IMAGE_STYLES={transparentCorners:!1,cornerColor:"#4287f5",cornerStyle:"circle",cornerStrokeWidth:2,cornerStrokeColor:"#2563eb",scalingLimitations:"preserveAspectRatio",bringToFrontOnSelect:!1,borderColor:"#4287f5",borderScaleFactor:10},this.CONTROL_VISIBILITY={tl:!0,tr:!0,bl:!0,br:!0,mt:!1,mb:!1,ml:!1,mr:!1,mtr:!1}}async handleBackgroundImageUrlChange(){this.canvas&&(this.removeBackgroundImage(),await this.loadBackgroundImage(),this.updateProcessedImgAreaPosition(),this.canvas.renderAll())}async handleHandwrittenImageUrlChange(){this.canvas&&(this.removeHandwrittenImage(),this.handwrittenImageUrl&&await this.loadHandwrittenImage(),this.updateProcessedImgAreaPosition(),this.resetHandwrittenImagePosition(),this.updateClipMaskOverlay(),this.canvas.renderAll())}handleHandwrittenImageDimensionsChange(){this.debounceUpdateDimensions()}firstUpdated(){this.initializeCanvas(),this.setupEventListeners(),this.loadInitialContent()}render(){return j`<canvas class="base-canvas"></canvas>`}initializeCanvas(){this.canvas=new fo(this.baseCanvas,{width:500,height:500,containerClass:"fabric-container",preserveObjectStacking:!0})}setupEventListeners(){document.addEventListener("pbo-image-processing",this.handleImageProcessing.bind(this))}async loadInitialContent(){this.backgroundImageUrl?(await this.loadBackgroundImage(),this.updateProcessedImgAreaPosition(),this.createUploadingText()):this.updateProcessedImgAreaPosition(),this.canvas.renderAll()}removeBackgroundImage(){this.backgroundFabImg&&(this.canvas.remove(this.backgroundFabImg),this.backgroundFabImg=void 0)}async loadBackgroundImage(){const r=this.backgroundImageUrl||this.DEFAULT_BACKGROUND_URL;await this.appendBackgroundImageToCanvas(r)}async appendBackgroundImageToCanvas(r,t){const e=await te.fromURL(r);e.selectable=!1,this.backgroundFabImg=e,this.canvas.setDimensions({width:e.width,height:e.height}),this.canvas.add(e),this.canvas.sendObjectToBack(e),this.canvas.renderAll(),t&&t()}removeHandwrittenImage(){this.handwrittenImage&&(this.canvas.remove(this.handwrittenImage),this.handwrittenImage=void 0)}async loadHandwrittenImage(){this.handwrittenImage=await te.fromURL(this.handwrittenImageUrl),this.configureHandwrittenImage(),this.setupHandwrittenImageEvents(),this.canvas.add(this.handwrittenImage)}configureHandwrittenImage(){if(!this.handwrittenImage)return;const r=this.calculateImageScale(),t=this.createClipRect(),e=this.handwrittenImage.width*r,i=this.handwrittenImage.height*r,s=this.areaPosition.left+(this.areaSize.width-e)/2,n=this.areaPosition.top+(this.areaSize.height-i)/2;this.handwrittenImage.set({...this.HANDWRITTEN_IMAGE_STYLES,selectable:!0,lockRotation:!0,lockScalingFlip:!0,noScaleCache:!1,cornerSize:this.calculateCornerSize(),touchCornerSize:this.calculateTouchCornerSize(),left:s,top:n,scaleX:r,scaleY:r,clipPath:t}),this.handwrittenImage.setControlsVisibility(this.CONTROL_VISIBILITY),this.updateHandwrittenImageDimensions(r)}calculateImageScale(){if(!this.handwrittenImage)return 1;const r=this.areaSize.width/this.handwrittenImage.width,t=this.areaSize.height/this.handwrittenImage.height;return Math.min(r,t)}calculateCornerSize(){return this.areaSize.width*(ui()?.06:.03)}calculateTouchCornerSize(){return this.areaSize.width*(ui()?.2:.06)}createClipRect(){return new ee({width:this.areaSize.width,height:this.areaSize.height,left:this.areaPosition.left,top:this.areaPosition.top,absolutePositioned:!0})}updateHandwrittenImageDimensions(r){if(!this.handwrittenImage)return;const t=this.handwrittenImage.width*r,e=this.handwrittenImage.height*r;this.setHandwrittenImageDimensions({left:this.areaPosition.left+(this.areaSize.width-t)/2,top:this.areaPosition.top+(this.areaSize.height-e)/2,width:t,height:e})}setupHandwrittenImageEvents(){this.handwrittenImage&&(this.handwrittenImage.on("scaling",this.handleImageScaling.bind(this)),this.handwrittenImage.on("moving",this.handleImageMoving.bind(this)),this.handwrittenImage.on("selected",this.handleImageSelected.bind(this)),this.handwrittenImage.on("deselected",this.handleImageDeselected.bind(this)))}handleImageScaling(r){const{top:t,left:e,height:i,width:s,scaleX:n,scaleY:o}=r.transform.target;this.setHandwrittenImageDimensions({top:t,left:e,height:i*o,width:s*n})}handleImageMoving(r){const{top:t,left:e}=r.transform.target;this.setHandwrittenImageDimensions({top:t,left:e})}handleImageSelected(){this.showSelectionUI()}handleImageDeselected(){this.hideSelectionUI()}showSelectionUI(){var r,t;(r=this.rect)==null||r.set("visible",!0),(t=this.handwrittenImage)==null||t.set("clipPath",null),this.clipMaskOverlay?this.clipMaskOverlay.set("visible",!0):(this.clipMaskOverlay=this.createClipMaskOverlay(),this.canvas.add(this.clipMaskOverlay)),this.canvas.bringObjectToFront(this.clipMaskOverlay),this.canvas.renderAll()}hideSelectionUI(){var r,t,e;(r=this.rect)==null||r.set("visible",!1),(t=this.handwrittenImage)==null||t.set({clipPath:this.createClipRect()}),(e=this.clipMaskOverlay)==null||e.set("visible",!1)}createClipMaskOverlay(){const r=this.canvas.getWidth(),t=this.canvas.getHeight(),{left:e,top:i}=this.areaPosition,{width:s,height:n}=this.areaSize,o="rgba(0,0,0,0.1)",a=[this.createMaskRect(0,0,r,i,o),this.createMaskRect(0,i+n,r,t-(i+n),o),this.createMaskRect(0,i,e,n,o),this.createMaskRect(e+s,i,r-(e+s),n,o)];return new fi(a,{selectable:!1,evented:!1})}createMaskRect(r,t,e,i,s){return new ee({left:r,top:t,width:e,height:i,fill:s,selectable:!1,evented:!1})}updateClipMaskOverlay(){this.clipMaskOverlay&&(this.canvas.remove(this.clipMaskOverlay),this.clipMaskOverlay=void 0),this.handwrittenImage&&this.canvas.getActiveObject()===this.handwrittenImage&&(this.clipMaskOverlay=this.createClipMaskOverlay(),this.canvas.add(this.clipMaskOverlay),this.canvas.bringObjectToFront(this.clipMaskOverlay))}resetHandwrittenImagePosition(){if(!this.handwrittenImage)return;const r=this.areaSize.width/this.handwrittenImage.width,t=this.areaSize.height/this.handwrittenImage.height,e=Math.min(r,t),i=this.handwrittenImage.width*e,s=this.handwrittenImage.height*e,n=this.areaPosition.left+(this.areaSize.width-i)/2,o=this.areaPosition.top+(this.areaSize.height-s)/2;this.handwrittenImage.set({left:n,top:o,scaleX:e,scaleY:e});const a=new ee({width:this.areaSize.width,height:this.areaSize.height,left:this.areaPosition.left,top:this.areaPosition.top,absolutePositioned:!0});this.handwrittenImage.set({clipPath:a}),this.setHandwrittenImageDimensions({top:o,left:n,height:this.handwrittenImage.height*e,width:this.handwrittenImage.width*e}),this.emitDimensionsChangedEvent()}updateProcessedImgAreaPosition(){const r=this.getAreaPercentages();this.areaPosition={left:r.left*this.canvas.getWidth(),top:r.top*this.canvas.getHeight()},this.areaSize={width:r.width*this.canvas.getWidth(),height:r.height*this.canvas.getHeight()},this.updateAreaRect()}getAreaPercentages(){return this.displayType==="default"?this.AREA_PERCENTAGES.default:this.AREA_PERCENTAGES.fullSize}updateAreaRect(){this.rect?this.rect.set({left:this.areaPosition.left,top:this.areaPosition.top,width:this.areaSize.width,height:this.areaSize.height}):this.createAreaRect()}createAreaRect(){this.rect=new ee({left:this.areaPosition.left,top:this.areaPosition.top,width:this.areaSize.width,height:this.areaSize.height,selectable:!1,fill:"rgba(255, 255, 255, 0.5)",visible:!1,evented:!1}),this.canvas.add(this.rect)}debounceUpdateDimensions(){this._dimensionsUpdateTimeout&&clearTimeout(this._dimensionsUpdateTimeout),this._dimensionsUpdateTimeout=setTimeout(()=>{var r;this.applyHandwrittenImageDimensions(),(r=this.canvas)==null||r.renderAll(),this.emitDimensionsChangedEvent()},300)}applyHandwrittenImageDimensions(){this.isValidForDimensionUpdate()&&(this.handwrittenImage.set({left:this.imageLeft,top:this.imageTop}),this.handwrittenImage.scaleToHeight(this.imageHeight),this.handwrittenImage.scaleToWidth(this.imageWidth))}isValidForDimensionUpdate(){return ys(this.handwrittenImage)&&ys(this.imageLeft)&&ys(this.imageTop)&&ys(this.imageWidth)&&ys(this.imageHeight)}setHandwrittenImageDimensions(r){const{top:t,left:e,height:i,width:s}=r;if(!this.hasValidDimensions(r)){console.warn("Invalid dimensions provided for handwritten image");return}this.updateDimensionIfChanged("imageLeft",e),this.updateDimensionIfChanged("imageTop",t),this.updateDimensionIfChanged("imageHeight",i),this.updateDimensionIfChanged("imageWidth",s)}hasValidDimensions(r){const{top:t,left:e,height:i,width:s}=r;return!!(t||e||i||s)}updateDimensionIfChanged(r,t){t&&this[r]!==t&&(this[r]=t)}emitDimensionsChangedEvent(){var r,t;this.emit("handwritten-image-dimensions-changed",{detail:{left:this.imageLeft??0,top:this.imageTop??0,width:this.imageWidth??0,height:this.imageHeight??0,cardHeight:((r=this.backgroundFabImg)==null?void 0:r.height)??0,cardWidth:((t=this.backgroundFabImg)==null?void 0:t.width)??0}})}createUploadingText(){this.uploadingText=new pi("Uploading",{left:this.areaPosition.left,top:this.areaPosition.top+this.areaSize.height/2-this.areaSize.height/13/1.1,width:this.areaSize.width,textAlign:"center",fontSize:this.areaSize.height/13/1.1,fontFamily:"Arial",selectable:!1,evented:!1})}handleImageProcessing(r){const t=r.detail.isLoading;this.uploadingText&&(t?this.canvas.add(this.uploadingText):this.canvas.remove(this.uploadingText),this.canvas.renderAll())}};dt.styles=[Ot,Bp];Pt([C({attribute:"background-url"})],dt.prototype,"backgroundImageUrl",2);Pt([C({attribute:"handwritten-url"})],dt.prototype,"handwrittenImageUrl",2);Pt([C({type:Number,reflect:!0,attribute:"height"})],dt.prototype,"imageHeight",2);Pt([C({type:Number,reflect:!0,attribute:"width"})],dt.prototype,"imageWidth",2);Pt([C({type:Number,reflect:!0,attribute:"left"})],dt.prototype,"imageLeft",2);Pt([C({type:Number,reflect:!0,attribute:"top"})],dt.prototype,"imageTop",2);Pt([C({attribute:"display-type"})],dt.prototype,"displayType",2);Pt([z(".base-canvas")],dt.prototype,"baseCanvas",2);Pt([I()],dt.prototype,"canvas",2);Pt([I()],dt.prototype,"backgroundFabImg",2);Pt([I()],dt.prototype,"rect",2);Pt([I()],dt.prototype,"areaPosition",2);Pt([I()],dt.prototype,"uploadingText",2);Pt([I()],dt.prototype,"handwrittenImage",2);Pt([I()],dt.prototype,"clipMaskOverlay",2);Pt([I()],dt.prototype,"areaSize",2);Pt([J("backgroundImageUrl")],dt.prototype,"handleBackgroundImageUrlChange",1);Pt([J(["handwrittenImageUrl","displayType"])],dt.prototype,"handleHandwrittenImageUrlChange",1);Pt([J(["imageLeft","imageTop","imageWidth","imageHeight"])],dt.prototype,"handleHandwrittenImageDimensionsChange",1);dt=Pt([Et("pbo-handwritten-canvas")],dt);const Dm=ft`
|
|
2823
|
+
`}applyTo2d(t){let{imageData:{data:e}}=t;const i=-this.vibrance;for(let s=0;s<e.length;s+=4){const n=e[s],o=e[s+1],a=e[s+2],l=Math.max(n,o,a),c=(n+o+a)/3,h=2*Math.abs(l-c)/255*i;e[s]+=l!==n?(l-n)*h:0,e[s+1]+=l!==o?(l-o)*h:0,e[s+2]+=l!==a?(l-a)*h:0}}sendUniformData(t,e){t.uniform1f(e.uVibrance,-this.vibrance)}isNeutralState(){return this.vibrance===0}}v(kr,"type","Vibrance"),v(kr,"defaults",{vibrance:0}),v(kr,"uniformLocations",["uVibrance"]),A.setClass(kr);var Pm=Object.defineProperty,Am=Object.getOwnPropertyDescriptor,Pt=(r,t,e,i)=>{for(var s=i>1?void 0:i?Am(t,e):t,n=r.length-1,o;n>=0;n--)(o=r[n])&&(s=(i?o(t,e,s):o(s))||s);return i&&s&&Pm(t,e,s),s};let dt=class extends kt{constructor(){super(...arguments),this.backgroundImageUrl=void 0,this.handwrittenImageUrl=void 0,this.imageHeight=null,this.imageWidth=null,this.imageLeft=null,this.imageTop=null,this.displayType="default",this.backgroundFabImg=void 0,this.rect=void 0,this.areaPosition={left:0,top:0},this.uploadingText=void 0,this.handwrittenImage=void 0,this.clipMaskOverlay=void 0,this.areaSize={width:0,height:0},this._dimensionsUpdateTimeout=void 0,this.DEFAULT_BACKGROUND_URL="https://cdn.shopify.com/s/files/1/1956/2323/files/insert_86e8bcd5-3e82-4910-b350-485fa6958502.png?v=1726598821",this.AREA_PERCENTAGES={default:{left:.084,top:.4899,width:.832,height:.45},fullSize:{left:.084,top:.06,width:.832,height:.879}},this.HANDWRITTEN_IMAGE_STYLES={transparentCorners:!1,cornerColor:"#4287f5",cornerStyle:"circle",cornerStrokeWidth:2,cornerStrokeColor:"#2563eb",scalingLimitations:"preserveAspectRatio",bringToFrontOnSelect:!1,borderColor:"#4287f5",borderScaleFactor:10},this.CONTROL_VISIBILITY={tl:!0,tr:!0,bl:!0,br:!0,mt:!1,mb:!1,ml:!1,mr:!1,mtr:!1}}async handleBackgroundImageUrlChange(){this.canvas&&(this.removeBackgroundImage(),await this.loadBackgroundImage(),this.updateProcessedImgAreaPosition(),this.canvas.renderAll())}async handleHandwrittenImageUrlChange(){this.canvas&&(this.removeHandwrittenImage(),this.handwrittenImageUrl&&await this.loadHandwrittenImage(),this.updateProcessedImgAreaPosition(),this.resetHandwrittenImagePosition(),this.updateClipMaskOverlay(),this.canvas.renderAll())}handleHandwrittenImageDimensionsChange(){this.debounceUpdateDimensions()}firstUpdated(){this.initializeCanvas(),this.setupEventListeners(),this.loadInitialContent()}render(){return j`<canvas class="base-canvas"></canvas>`}initializeCanvas(){this.canvas=new fo(this.baseCanvas,{width:500,height:500,containerClass:"fabric-container",preserveObjectStacking:!0})}setupEventListeners(){document.addEventListener("pbo-image-processing",this.handleImageProcessing.bind(this))}async loadInitialContent(){this.backgroundImageUrl?(await this.loadBackgroundImage(),this.updateProcessedImgAreaPosition(),this.createUploadingText()):this.updateProcessedImgAreaPosition(),this.canvas.renderAll()}removeBackgroundImage(){this.backgroundFabImg&&(this.canvas.remove(this.backgroundFabImg),this.backgroundFabImg=void 0)}async loadBackgroundImage(){const r=this.backgroundImageUrl||this.DEFAULT_BACKGROUND_URL;await this.appendBackgroundImageToCanvas(r)}async appendBackgroundImageToCanvas(r,t){const e=await te.fromURL(r);e.selectable=!1,this.backgroundFabImg=e,this.canvas.setDimensions({width:e.width,height:e.height}),this.canvas.add(e),this.canvas.sendObjectToBack(e),this.canvas.renderAll(),t&&t()}removeHandwrittenImage(){this.handwrittenImage&&(this.canvas.remove(this.handwrittenImage),this.handwrittenImage=void 0)}async loadHandwrittenImage(){this.handwrittenImage=await te.fromURL(this.handwrittenImageUrl),this.configureHandwrittenImage(),this.setupHandwrittenImageEvents(),this.canvas.add(this.handwrittenImage)}configureHandwrittenImage(){if(!this.handwrittenImage)return;const r=this.calculateImageScale(),t=this.createClipRect(),e=this.handwrittenImage.width*r,i=this.handwrittenImage.height*r,s=this.areaPosition.left+(this.areaSize.width-e)/2,n=this.areaPosition.top+(this.areaSize.height-i)/2;this.handwrittenImage.set({...this.HANDWRITTEN_IMAGE_STYLES,selectable:!0,lockRotation:!0,lockScalingFlip:!0,noScaleCache:!1,cornerSize:this.calculateCornerSize(),touchCornerSize:this.calculateTouchCornerSize(),left:s,top:n,scaleX:r,scaleY:r,clipPath:t}),this.handwrittenImage.setControlsVisibility(this.CONTROL_VISIBILITY),this.updateHandwrittenImageDimensions(r)}calculateImageScale(){if(!this.handwrittenImage)return 1;const r=this.areaSize.width/this.handwrittenImage.width,t=this.areaSize.height/this.handwrittenImage.height;return Math.min(r,t)}calculateCornerSize(){return this.areaSize.width*(Ii()?.06:.03)}calculateTouchCornerSize(){return this.areaSize.width*(Ii()?.2:.06)}createClipRect(){return new ee({width:this.areaSize.width,height:this.areaSize.height,left:this.areaPosition.left,top:this.areaPosition.top,absolutePositioned:!0})}updateHandwrittenImageDimensions(r){if(!this.handwrittenImage)return;const t=this.handwrittenImage.width*r,e=this.handwrittenImage.height*r;this.setHandwrittenImageDimensions({left:this.areaPosition.left+(this.areaSize.width-t)/2,top:this.areaPosition.top+(this.areaSize.height-e)/2,width:t,height:e})}setupHandwrittenImageEvents(){this.handwrittenImage&&(this.handwrittenImage.on("scaling",this.handleImageScaling.bind(this)),this.handwrittenImage.on("moving",this.handleImageMoving.bind(this)),this.handwrittenImage.on("selected",this.handleImageSelected.bind(this)),this.handwrittenImage.on("deselected",this.handleImageDeselected.bind(this)))}handleImageScaling(r){const{top:t,left:e,height:i,width:s,scaleX:n,scaleY:o}=r.transform.target;this.setHandwrittenImageDimensions({top:t,left:e,height:i*o,width:s*n})}handleImageMoving(r){const{top:t,left:e}=r.transform.target;this.setHandwrittenImageDimensions({top:t,left:e})}handleImageSelected(){this.showSelectionUI()}handleImageDeselected(){this.hideSelectionUI()}showSelectionUI(){var r,t;(r=this.rect)==null||r.set("visible",!0),(t=this.handwrittenImage)==null||t.set("clipPath",null),this.clipMaskOverlay?this.clipMaskOverlay.set("visible",!0):(this.clipMaskOverlay=this.createClipMaskOverlay(),this.canvas.add(this.clipMaskOverlay)),this.canvas.bringObjectToFront(this.clipMaskOverlay),this.canvas.renderAll()}hideSelectionUI(){var r,t,e;(r=this.rect)==null||r.set("visible",!1),(t=this.handwrittenImage)==null||t.set({clipPath:this.createClipRect()}),(e=this.clipMaskOverlay)==null||e.set("visible",!1)}createClipMaskOverlay(){const r=this.canvas.getWidth(),t=this.canvas.getHeight(),{left:e,top:i}=this.areaPosition,{width:s,height:n}=this.areaSize,o="rgba(0,0,0,0.1)",a=[this.createMaskRect(0,0,r,i,o),this.createMaskRect(0,i+n,r,t-(i+n),o),this.createMaskRect(0,i,e,n,o),this.createMaskRect(e+s,i,r-(e+s),n,o)];return new gi(a,{selectable:!1,evented:!1})}createMaskRect(r,t,e,i,s){return new ee({left:r,top:t,width:e,height:i,fill:s,selectable:!1,evented:!1})}updateClipMaskOverlay(){this.clipMaskOverlay&&(this.canvas.remove(this.clipMaskOverlay),this.clipMaskOverlay=void 0),this.handwrittenImage&&this.canvas.getActiveObject()===this.handwrittenImage&&(this.clipMaskOverlay=this.createClipMaskOverlay(),this.canvas.add(this.clipMaskOverlay),this.canvas.bringObjectToFront(this.clipMaskOverlay))}resetHandwrittenImagePosition(){if(!this.handwrittenImage)return;const r=this.areaSize.width/this.handwrittenImage.width,t=this.areaSize.height/this.handwrittenImage.height,e=Math.min(r,t),i=this.handwrittenImage.width*e,s=this.handwrittenImage.height*e,n=this.areaPosition.left+(this.areaSize.width-i)/2,o=this.areaPosition.top+(this.areaSize.height-s)/2;this.handwrittenImage.set({left:n,top:o,scaleX:e,scaleY:e});const a=new ee({width:this.areaSize.width,height:this.areaSize.height,left:this.areaPosition.left,top:this.areaPosition.top,absolutePositioned:!0});this.handwrittenImage.set({clipPath:a}),this.setHandwrittenImageDimensions({top:o,left:n,height:this.handwrittenImage.height*e,width:this.handwrittenImage.width*e}),this.emitDimensionsChangedEvent()}updateProcessedImgAreaPosition(){const r=this.getAreaPercentages();this.areaPosition={left:r.left*this.canvas.getWidth(),top:r.top*this.canvas.getHeight()},this.areaSize={width:r.width*this.canvas.getWidth(),height:r.height*this.canvas.getHeight()},this.updateAreaRect()}getAreaPercentages(){return this.displayType==="default"?this.AREA_PERCENTAGES.default:this.AREA_PERCENTAGES.fullSize}updateAreaRect(){this.rect?this.rect.set({left:this.areaPosition.left,top:this.areaPosition.top,width:this.areaSize.width,height:this.areaSize.height}):this.createAreaRect()}createAreaRect(){this.rect=new ee({left:this.areaPosition.left,top:this.areaPosition.top,width:this.areaSize.width,height:this.areaSize.height,selectable:!1,fill:"rgba(255, 255, 255, 0.5)",visible:!1,evented:!1}),this.canvas.add(this.rect)}debounceUpdateDimensions(){this._dimensionsUpdateTimeout&&clearTimeout(this._dimensionsUpdateTimeout),this._dimensionsUpdateTimeout=setTimeout(()=>{var r;this.applyHandwrittenImageDimensions(),(r=this.canvas)==null||r.renderAll(),this.emitDimensionsChangedEvent()},300)}applyHandwrittenImageDimensions(){this.isValidForDimensionUpdate()&&(this.handwrittenImage.set({left:this.imageLeft,top:this.imageTop}),this.handwrittenImage.scaleToHeight(this.imageHeight),this.handwrittenImage.scaleToWidth(this.imageWidth))}isValidForDimensionUpdate(){return ys(this.handwrittenImage)&&ys(this.imageLeft)&&ys(this.imageTop)&&ys(this.imageWidth)&&ys(this.imageHeight)}setHandwrittenImageDimensions(r){const{top:t,left:e,height:i,width:s}=r;if(!this.hasValidDimensions(r)){console.warn("Invalid dimensions provided for handwritten image");return}this.updateDimensionIfChanged("imageLeft",e),this.updateDimensionIfChanged("imageTop",t),this.updateDimensionIfChanged("imageHeight",i),this.updateDimensionIfChanged("imageWidth",s)}hasValidDimensions(r){const{top:t,left:e,height:i,width:s}=r;return!!(t||e||i||s)}updateDimensionIfChanged(r,t){t&&this[r]!==t&&(this[r]=t)}emitDimensionsChangedEvent(){var r,t;this.emit("handwritten-image-dimensions-changed",{detail:{left:this.imageLeft??0,top:this.imageTop??0,width:this.imageWidth??0,height:this.imageHeight??0,cardHeight:((r=this.backgroundFabImg)==null?void 0:r.height)??0,cardWidth:((t=this.backgroundFabImg)==null?void 0:t.width)??0}})}createUploadingText(){this.uploadingText=new ui("Uploading",{left:this.areaPosition.left,top:this.areaPosition.top+this.areaSize.height/2-this.areaSize.height/13/1.1,width:this.areaSize.width,textAlign:"center",fontSize:this.areaSize.height/13/1.1,fontFamily:"Arial",selectable:!1,evented:!1})}handleImageProcessing(r){const t=r.detail.isLoading;this.uploadingText&&(t?this.canvas.add(this.uploadingText):this.canvas.remove(this.uploadingText),this.canvas.renderAll())}};dt.styles=[Ot,Bp];Pt([C({attribute:"background-url"})],dt.prototype,"backgroundImageUrl",2);Pt([C({attribute:"handwritten-url"})],dt.prototype,"handwrittenImageUrl",2);Pt([C({type:Number,reflect:!0,attribute:"height"})],dt.prototype,"imageHeight",2);Pt([C({type:Number,reflect:!0,attribute:"width"})],dt.prototype,"imageWidth",2);Pt([C({type:Number,reflect:!0,attribute:"left"})],dt.prototype,"imageLeft",2);Pt([C({type:Number,reflect:!0,attribute:"top"})],dt.prototype,"imageTop",2);Pt([C({attribute:"display-type"})],dt.prototype,"displayType",2);Pt([z(".base-canvas")],dt.prototype,"baseCanvas",2);Pt([I()],dt.prototype,"canvas",2);Pt([I()],dt.prototype,"backgroundFabImg",2);Pt([I()],dt.prototype,"rect",2);Pt([I()],dt.prototype,"areaPosition",2);Pt([I()],dt.prototype,"uploadingText",2);Pt([I()],dt.prototype,"handwrittenImage",2);Pt([I()],dt.prototype,"clipMaskOverlay",2);Pt([I()],dt.prototype,"areaSize",2);Pt([it("backgroundImageUrl")],dt.prototype,"handleBackgroundImageUrlChange",1);Pt([it(["handwrittenImageUrl","displayType"])],dt.prototype,"handleHandwrittenImageUrlChange",1);Pt([it(["imageLeft","imageTop","imageWidth","imageHeight"])],dt.prototype,"handleHandwrittenImageDimensionsChange",1);dt=Pt([Et("pbo-handwritten-canvas")],dt);const Dm=gt`
|
|
2824
2824
|
:host {
|
|
2825
2825
|
display: block;
|
|
2826
2826
|
width: 100%;
|
|
@@ -2878,7 +2878,7 @@ void main() {
|
|
|
2878
2878
|
.type-canvas-container.image-loading pbo-image {
|
|
2879
2879
|
display: block;
|
|
2880
2880
|
}
|
|
2881
|
-
`;var Mm=Object.defineProperty,Im=Object.getOwnPropertyDescriptor,
|
|
2881
|
+
`;var Mm=Object.defineProperty,Im=Object.getOwnPropertyDescriptor,ft=(r,t,e,i)=>{for(var s=i>1?void 0:i?Im(t,e):t,n=r.length-1,o;n>=0;n--)(o=r[n])&&(s=(i?o(t,e,s):o(s))||s);return i&&s&&Mm(t,e,s),s};const Wn=[{family:"Calibri",label:"Calibri",fontSizePt:15.9,lineHeight:1.185,maxLines:{default:12,fullSize:23}},{family:"Caveat",label:"Caveat",fontSizePt:16.5,lineHeight:1.245,maxLines:{default:11,fullSize:21}},{family:"Dancing Script",label:"Dancing Script",fontSizePt:16.4,lineHeight:1.25,maxLines:{default:11,fullSize:21}},{family:"Kalam",label:"Kalam",fontSizePt:15,lineHeight:1.25,maxLines:{default:12,fullSize:23}},{family:"Reenie Beanie",label:"Reenie Beanie",fontSizePt:17.1,lineHeight:1.2,maxLines:{default:11,fullSize:21}},{family:"Great Vibes",label:"Great Vibes",fontSizePt:17.1,lineHeight:1.2,maxLines:{default:11,fullSize:21}}],ws={width:5,displayArea:{default:{x:.42,y:3.43,width:4.16,height:3.15},fullSize:{x:.42,y:.42,width:4.16,height:6.16}}};let nt=class extends kt{constructor(){super(...arguments),this.backgroundImageUrl=void 0,this.message="",this.font="Arial",this.color="#000",this.alignment="left",this.displayType="default",this.scale=1,this.logicalSize={width:0,height:0},this.areaPosition={left:0,top:0},this.areaSize={width:0,height:0},this.imgLoading=!1,this.backgroundImage=void 0,this.resizeObserver=void 0,this.dpi=0,this.fontConfig=Wn.find(r=>r.family==="Arial"),this.processedMessage=""}async handleBackgroundImageUrlChange(){this.imgLoading=!0,await this.appendBackgroundImageToCanvas(this.backgroundImageUrl??"",()=>{this.imgLoading=!1}),this.updateTextAreaPosition()}handleBackgroundImageChange(){if(!this.backgroundImage)return;const r=this.canvas.getContext("2d");if(!r)throw new Error("Could not get canvas context");r.drawImage(this.backgroundImage,0,0,this.logicalSize.width,this.logicalSize.height)}handleProcessedMessageChange(){this.debounceTimer&&clearTimeout(this.debounceTimer),this.debounceTimer=setTimeout(()=>{this.emit("pbo-type-canvas-processed",{detail:{message:this.processedMessage}})},300)}inchToPixel(r,t){return r*t}ptToInch(r){return r/72}firstUpdated(){this.resizeObserver=new ResizeObserver(()=>{this.updateTextAreaPosition()}),this.resizeObserver.observe(this.canvasContainer)}updated(r){var t,e,i;if(r.has("message")||r.has("font")||r.has("color")||r.has("alignment")||r.has("areaPosition")||r.has("areaSize")||r.has("displayType")){if(!this.backgroundImage||this.areaSize.width===0||this.areaSize.height===0)return;const s=this.canvas.getContext("2d");if(!s)return;s.clearRect(0,0,this.logicalSize.width,this.logicalSize.height),s.drawImage(this.backgroundImage,0,0,this.logicalSize.width,this.logicalSize.height),this.fontConfig=Wn.find(n=>n.family===this.font)||Wn[0],this.wrapText({ctx:s,message:this.message,areaPosition:this.areaPosition,areaSize:this.areaSize,maxLineSize:((t=this.fontConfig)==null?void 0:t.maxLines[this.displayType])||12,alignment:this.alignment,fontSizePt:((e=this.fontConfig)==null?void 0:e.fontSizePt)||15.9,lineHeight:((i=this.fontConfig)==null?void 0:i.lineHeight)||1.185,verticalAlignment:this.displayType==="fullSize"?"middle":"top"})}}getMaxStringLength(r,t,e){let i=0;for(let s=1;s<=t.length;s++){const n=t.substring(0,s);if(r.measureText(n).width>e)break;i=s}return i}wrapText({ctx:r,message:t,areaPosition:e,areaSize:i,maxLineSize:s,alignment:n,lineHeight:o=1.185,fontSizePt:a,verticalAlignment:l}){if(!r||!t||!e||!i)return;const c=this.inchToPixel(this.ptToInch(a),this.dpi),h=t.split(`
|
|
2882
2882
|
`);let d=[];r.font=`400 ${c}px ${this.font}`,h.forEach(p=>{const g=p.split(" ");let f="";for(let m=0;m<g.length;m++)if(r.measureText(g[m]).width>i.width){const w=this.getMaxStringLength(r,g[m],i.width),S=g[m];m+1<g.length?(g[m]=S.substring(0,w),g[m+1]=S.substring(w,S.length)+g[m+1]):(g[m]=S.substring(0,w),g.push(S.substring(w,S.length)))}for(let m=0;m<g.length;m++){let b=f+g[m]+" ";r.measureText(b).width>i.width&&m>0?(d.push(f),f=g[m]+" "):f=b}d.push(f)}),this.processedMessage=d.slice(0,s).join(`
|
|
2883
2883
|
`);let u=this.areaPosition.left;if(n==="center"&&(u+=this.areaSize.width/2),n==="right"&&(u+=this.areaSize.width),l==="top"){r.textBaseline="top";for(let p=0;p<s&&p<d.length;p++){const g=d[p];r.fillStyle=this.color,r.textAlign=n,r.fillText(g,u,this.areaPosition.top+p*c*o)}}if(l==="middle"){r.textBaseline="middle";for(let p=0;p<s&&p<d.length;p++){const g=d[p],f=Math.min(d.length,s),m=(p+1-f/2-.5)*c*o;r.fillStyle=this.color,r.textAlign=n,r.fillText(g,u,m+this.areaPosition.top+this.areaSize.height/2)}}}updateTextAreaPosition(){if(!this.canvas||!this.backgroundImage)return;const r=window.devicePixelRatio||1,t=this.canvasContainer.clientWidth;this.scale=t/this.backgroundImage.width,this.logicalSize={width:this.canvasContainer.clientWidth,height:this.backgroundImage.height*this.scale},this.canvas.width=this.logicalSize.width*r,this.canvas.height=this.logicalSize.height*r,this.canvas.style.width=`${this.logicalSize.width}px`,this.canvas.style.height=`${this.logicalSize.height}px`;const e=this.canvas.getContext("2d");e&&(e.setTransform(1,0,0,1,0,0),e.scale(r,r),e.drawImage(this.backgroundImage,0,0,this.logicalSize.width,this.logicalSize.height),this.dpi=this.logicalSize.width/ws.width,this.areaPosition={left:this.inchToPixel(ws.displayArea[this.displayType].x,this.dpi),top:this.inchToPixel(ws.displayArea[this.displayType].y,this.dpi)},this.areaSize={width:this.inchToPixel(ws.displayArea[this.displayType].width,this.dpi),height:this.inchToPixel(ws.displayArea[this.displayType].height,this.dpi)})}async appendBackgroundImageToCanvas(r,t){return new Promise((e,i)=>{const s=new Image;s.onerror=()=>{i(new Error("Failed to load image"))},s.onload=()=>{this.backgroundImage=s,t&&t(),e()},r!==""&&(s.src=r)})}render(){return j`
|
|
2884
2884
|
<div
|
|
@@ -2888,7 +2888,7 @@ void main() {
|
|
|
2888
2888
|
<canvas class="base-canvas"></canvas>
|
|
2889
2889
|
<pbo-image skeleton></pbo-image>
|
|
2890
2890
|
</div>
|
|
2891
|
-
`}};nt.styles=[Ot,Dm];
|
|
2891
|
+
`}};nt.styles=[Ot,Dm];ft([C({attribute:"background-url"})],nt.prototype,"backgroundImageUrl",2);ft([C()],nt.prototype,"message",2);ft([C()],nt.prototype,"font",2);ft([C()],nt.prototype,"color",2);ft([C()],nt.prototype,"alignment",2);ft([C({attribute:"display-type"})],nt.prototype,"displayType",2);ft([z(".base-canvas")],nt.prototype,"canvas",2);ft([z(".type-canvas-container")],nt.prototype,"canvasContainer",2);ft([I()],nt.prototype,"scale",2);ft([I()],nt.prototype,"logicalSize",2);ft([I()],nt.prototype,"areaPosition",2);ft([I()],nt.prototype,"areaSize",2);ft([I()],nt.prototype,"imgLoading",2);ft([I()],nt.prototype,"backgroundImage",2);ft([I()],nt.prototype,"resizeObserver",2);ft([I()],nt.prototype,"dpi",2);ft([I()],nt.prototype,"fontConfig",2);ft([I()],nt.prototype,"processedMessage",2);ft([it("backgroundImageUrl")],nt.prototype,"handleBackgroundImageUrlChange",1);ft([it("backgroundImage")],nt.prototype,"handleBackgroundImageChange",1);ft([it("processedMessage")],nt.prototype,"handleProcessedMessageChange",1);nt=ft([Et("pbo-type-canvas")],nt);const Lm=gt`
|
|
2892
2892
|
:host {
|
|
2893
2893
|
display: block;
|
|
2894
2894
|
height: 100%;
|
|
@@ -2942,7 +2942,7 @@ void main() {
|
|
|
2942
2942
|
outline-offset: 2px;
|
|
2943
2943
|
border-radius: 50%;
|
|
2944
2944
|
}
|
|
2945
|
-
`;var Fm=Object.defineProperty,jm=Object.getOwnPropertyDescriptor,Hi=(r,t,e,i)=>{for(var s=i>1?void 0:i?jm(t,e):t,n=r.length-1,o;n>=0;n--)(o=r[n])&&(s=(i?o(t,e,s):o(s))||s);return i&&s&&Fm(t,e,s),s};let Be=class extends kt{constructor(){super(...arguments),this.formData={font:"Monsieur La Doulaise",text:"",color:"rgb(0,0,0)",alignment:"left"},this.cardUrl="",this.handwrittenPreviewProps={isLoading:!1,url:""},this.pinchToCloseDisabled=!1,this.distance=null,this.handleTouchMove=r=>{if(this.pinchToCloseDisabled)return;r.preventDefault();const t=r.touches[0],e=r.touches[1];if(!(t&&!e)&&t&&e){const i={x:t.clientX,y:t.clientY},s={x:e.clientX,y:e.clientY},n=
|
|
2945
|
+
`;var Fm=Object.defineProperty,jm=Object.getOwnPropertyDescriptor,Hi=(r,t,e,i)=>{for(var s=i>1?void 0:i?jm(t,e):t,n=r.length-1,o;n>=0;n--)(o=r[n])&&(s=(i?o(t,e,s):o(s))||s);return i&&s&&Fm(t,e,s),s};let Be=class extends kt{constructor(){super(...arguments),this.formData={font:"Monsieur La Doulaise",text:"",color:"rgb(0,0,0)",alignment:"left"},this.cardUrl="",this.handwrittenPreviewProps={isLoading:!1,url:""},this.pinchToCloseDisabled=!1,this.distance=null,this.handleTouchMove=r=>{if(this.pinchToCloseDisabled)return;r.preventDefault();const t=r.touches[0],e=r.touches[1];if(!(t&&!e)&&t&&e){const i={x:t.clientX,y:t.clientY},s={x:e.clientX,y:e.clientY},n=Dp(i,s);if(this.distance===null){this.distance=n;return}this.distance-n>10&&(this.distance=null,this.close())}},this.handleTouchEnd=()=>{this.pinchToCloseDisabled||(this.distance=null)}}render(){return j`
|
|
2946
2946
|
<div class="panel" @touchmove=${this.handleTouchMove} @touchend=${this.handleTouchEnd}>
|
|
2947
2947
|
<div class="zoomed-preview">
|
|
2948
2948
|
<div
|
|
@@ -2968,7 +2968,7 @@ void main() {
|
|
|
2968
2968
|
</svg>
|
|
2969
2969
|
</button>
|
|
2970
2970
|
</div>
|
|
2971
|
-
`}};Be.styles=[Ot,Lm];Hi([C()],Be.prototype,"formData",2);Hi([C()],Be.prototype,"cardUrl",2);Hi([C()],Be.prototype,"close",2);Hi([C()],Be.prototype,"handwrittenPreviewProps",2);Hi([C({type:Boolean,reflect:!0,attribute:"pinch-to-close-disabled"})],Be.prototype,"pinchToCloseDisabled",2);Hi([I()],Be.prototype,"distance",2);Be=Hi([Et("pbo-zoomed-preview")],Be);var $m=Object.defineProperty,Rm=Object.getOwnPropertyDescriptor,
|
|
2971
|
+
`}};Be.styles=[Ot,Lm];Hi([C()],Be.prototype,"formData",2);Hi([C()],Be.prototype,"cardUrl",2);Hi([C()],Be.prototype,"close",2);Hi([C()],Be.prototype,"handwrittenPreviewProps",2);Hi([C({type:Boolean,reflect:!0,attribute:"pinch-to-close-disabled"})],Be.prototype,"pinchToCloseDisabled",2);Hi([I()],Be.prototype,"distance",2);Be=Hi([Et("pbo-zoomed-preview")],Be);var $m=Object.defineProperty,Rm=Object.getOwnPropertyDescriptor,Nt=(r,t,e,i)=>{for(var s=i>1?void 0:i?Rm(t,e):t,n=r.length-1,o;n>=0;n--)(o=r[n])&&(s=(i?o(t,e,s):o(s))||s);return i&&s&&$m(t,e,s),s};let Tt=class extends kt{constructor(){super(...arguments),this.card=null,this.focusIndex=0,this.livePreviewProps={font:"Monsieur La Doulaise",text:"",color:"rgb(0,0,0)",alignment:"left"},this.handwrittenPreviewProps={isLoading:!1,processedFileUrl:null},this.type="type",this.mainImageTemplates=[],this.closeZoomedPreview=()=>{var e,i;const r=(e=this.shadowRoot)==null?void 0:e.querySelector("#handwritten-main-canvas"),t=(i=this.shadowRoot)==null?void 0:i.querySelector("#handwritten-zoomed-preview-canvas");r&&t&&(r.imageWidth=t.imageWidth,r.imageHeight=t.imageHeight,r.imageTop=t.imageTop,r.imageLeft=t.imageLeft),this.zoomedPreview&&(this.zoomedPreview.open=!1),this.emit("pbo_close_live_preview",{detail:{editor:this.type}})},this.openZoomedPreview=()=>{var e,i;const r=(e=this.shadowRoot)==null?void 0:e.querySelector("#handwritten-main-canvas"),t=(i=this.shadowRoot)==null?void 0:i.querySelector("#handwritten-zoomed-preview-canvas");r&&t&&(t.imageWidth=r.imageWidth,t.imageHeight=r.imageHeight,t.imageTop=r.imageTop,t.imageLeft=r.imageLeft),this.zoomedPreview&&(this.zoomedPreview.open=!0),this.emit("pbo_open_live_preview",{detail:{editor:this.type}})},this.handleOpenZoomedClick=()=>{this.openZoomedPreview()}}firstUpdated(){this.updateComplete,this.thumbnailElements[this.focusIndex].classList.add("active"),this.mainSlideElements[this.focusIndex].classList.add("active")}handleCardChange(r,t){var e,i,s,n;t&&(this.mainImageTemplates=[j`<pbo-image src="${t.medias.cover.url}" alt="" />`,j`<pbo-type-canvas
|
|
2972
2972
|
background-url=${t.medias.insert.url}
|
|
2973
2973
|
message=${(e=this.livePreviewProps)==null?void 0:e.text}
|
|
2974
2974
|
alignment=${((i=this.livePreviewProps)==null?void 0:i.alignment)||"left"}
|
|
@@ -2976,7 +2976,7 @@ void main() {
|
|
|
2976
2976
|
font=${(n=this.livePreviewProps)==null?void 0:n.font}
|
|
2977
2977
|
display-type=${t.hasEditorial?"default":"fullSize"}
|
|
2978
2978
|
@click="${this.handleOpenZoomedClick}"
|
|
2979
|
-
></pbo-type-canvas>`,j`<pbo-image src="${t.medias.rendered_2.url}" alt="" />`])}handleFocusIndexChange(r,t){var e,i,s,n;this.thumbnailElements.length!==0&&r!==t&&((e=this.thumbnailElements[r])==null||e.classList.remove("active"),(i=this.thumbnailElements[t])==null||i.classList.add("active"),(s=this.mainSlideElements[r])==null||s.classList.remove("active"),(n=this.mainSlideElements[t])==null||n.classList.add("active"),this.requestUpdate())}
|
|
2979
|
+
></pbo-type-canvas>`,j`<pbo-image src="${t.medias.rendered_2.url}" alt="" />`])}handleFocusIndexChange(r,t){var e,i,s,n;this.thumbnailElements.length!==0&&r!==t&&((e=this.thumbnailElements[r])==null||e.classList.remove("active"),(i=this.thumbnailElements[t])==null||i.classList.add("active"),(s=this.mainSlideElements[r])==null||s.classList.remove("active"),(n=this.mainSlideElements[t])==null||n.classList.add("active"),this.requestUpdate())}focusOn(r){if(r<0||r>=this.thumbnailElements.length){console.warn("Invalid index:",r);return}this.focusIndex=r}get mainSlides(){return this.card?[j`<pbo-image src="${this.card.medias.cover.url}" alt="" />`,j`<pbo-type-canvas
|
|
2980
2980
|
background-url=${this.card.medias.insert.url}
|
|
2981
2981
|
message=${this.livePreviewProps.text}
|
|
2982
2982
|
alignment=${this.livePreviewProps.alignment}
|
|
@@ -3041,23 +3041,19 @@ void main() {
|
|
|
3041
3041
|
</button>
|
|
3042
3042
|
</div>
|
|
3043
3043
|
|
|
3044
|
-
<div
|
|
3045
|
-
class="main-slide-container"
|
|
3046
|
-
@touchmove="${this.handleTouchMove}"
|
|
3047
|
-
@touchend="${this.handleTouchEnd}"
|
|
3048
|
-
>
|
|
3044
|
+
<div class="main-slide-container">
|
|
3049
3045
|
<div class="main-slide" @click="${this.handleOpenZoomedClick}">
|
|
3050
3046
|
<pbo-image src="${(i=this.card)==null?void 0:i.medias.cover.url}" alt=""></pbo-image>
|
|
3051
|
-
${
|
|
3047
|
+
${Ii()?j`<button
|
|
3052
3048
|
class="zoomed-preview-open-button"
|
|
3053
3049
|
type="button"
|
|
3054
3050
|
aria-label="Open zoomed preview"
|
|
3055
3051
|
@click="${this.handleOpenZoomedClick}"
|
|
3056
3052
|
>
|
|
3057
3053
|
${this.zoomIcon()}
|
|
3058
|
-
</button>`:
|
|
3054
|
+
</button>`:K}
|
|
3059
3055
|
</div>
|
|
3060
|
-
<div class="main-slide"
|
|
3056
|
+
<div class="main-slide">
|
|
3061
3057
|
${Dn(this.type==="type"?j`<pbo-type-canvas
|
|
3062
3058
|
background-url=${(s=this.card)==null?void 0:s.medias.insert.url}
|
|
3063
3059
|
message=${(n=this.livePreviewProps)==null?void 0:n.text}
|
|
@@ -3065,33 +3061,31 @@ void main() {
|
|
|
3065
3061
|
color=${(a=this.livePreviewProps)==null?void 0:a.color}
|
|
3066
3062
|
font=${(l=this.livePreviewProps)==null?void 0:l.font}
|
|
3067
3063
|
display-type=${(c=this.card)!=null&&c.hasEditorial?"default":"fullSize"}
|
|
3068
|
-
@click="${this.handleOpenZoomedClick}"
|
|
3069
3064
|
></pbo-type-canvas>`:j`<pbo-handwritten-canvas
|
|
3070
3065
|
id="handwritten-main-canvas"
|
|
3071
3066
|
background-url=${(h=this.card)==null?void 0:h.medias.insert.url}
|
|
3072
3067
|
handwritten-url=${this.handwrittenPreviewProps.processedFileUrl}
|
|
3073
3068
|
display-type=${(d=this.card)!=null&&d.hasEditorial?"default":"fullSize"}
|
|
3074
|
-
@click="${this.handleOpenZoomedClick}"
|
|
3075
3069
|
></pbo-handwritten-canvas>`)}
|
|
3076
|
-
${
|
|
3070
|
+
${Ii()?j`<button
|
|
3077
3071
|
class="zoomed-preview-open-button"
|
|
3078
3072
|
type="button"
|
|
3079
3073
|
aria-label="Open zoomed preview"
|
|
3080
3074
|
@click="${this.handleOpenZoomedClick}"
|
|
3081
3075
|
>
|
|
3082
3076
|
${this.zoomIcon()}
|
|
3083
|
-
</button>`:
|
|
3077
|
+
</button>`:K}
|
|
3084
3078
|
</div>
|
|
3085
|
-
<div class="main-slide"
|
|
3079
|
+
<div class="main-slide">
|
|
3086
3080
|
<pbo-image src="${(u=this.card)==null?void 0:u.medias.rendered_2.url}" alt=""></pbo-image>
|
|
3087
|
-
${
|
|
3081
|
+
${Ii()?j`<button
|
|
3088
3082
|
class="zoomed-preview-open-button"
|
|
3089
3083
|
type="button"
|
|
3090
3084
|
aria-label="Open zoomed preview"
|
|
3091
3085
|
@click="${this.handleOpenZoomedClick}"
|
|
3092
3086
|
>
|
|
3093
3087
|
${this.zoomIcon()}
|
|
3094
|
-
</button>`:
|
|
3088
|
+
</button>`:K}
|
|
3095
3089
|
</div>
|
|
3096
3090
|
</div>
|
|
3097
3091
|
</div>
|
|
@@ -3108,7 +3102,6 @@ void main() {
|
|
|
3108
3102
|
.close=${this.closeZoomedPreview}
|
|
3109
3103
|
.formData=${this.livePreviewProps}
|
|
3110
3104
|
.cardUrl=${(p=this.card)==null?void 0:p.medias.insert.url}
|
|
3111
|
-
?pinch-to-close-disabled="${!this.allowPinchToToggle}"
|
|
3112
3105
|
>
|
|
3113
3106
|
<img
|
|
3114
3107
|
src="${(g=this.card)==null?void 0:g.medias.cover.url}"
|
|
@@ -3122,17 +3115,15 @@ void main() {
|
|
|
3122
3115
|
color=${(_=this.livePreviewProps)==null?void 0:_.color}
|
|
3123
3116
|
font=${(w=this.livePreviewProps)==null?void 0:w.font}
|
|
3124
3117
|
display-type=${(S=this.card)!=null&&S.hasEditorial?"default":"fullSize"}
|
|
3125
|
-
@click="${this.handleOpenZoomedClick}"
|
|
3126
3118
|
style=${pe({display:this.focusIndex===1?"block":"none"})}
|
|
3127
|
-
></pbo-type-canvas>`:
|
|
3119
|
+
></pbo-type-canvas>`:K)}
|
|
3128
3120
|
${Dn(this.type==="handwritten"?j`<pbo-handwritten-canvas
|
|
3129
3121
|
id="handwritten-zoomed-preview-canvas"
|
|
3130
3122
|
background-url=${(T=this.card)==null?void 0:T.medias.insert.url}
|
|
3131
3123
|
handwritten-url=${this.handwrittenPreviewProps.processedFileUrl}
|
|
3132
3124
|
display-type=${(k=this.card)!=null&&k.hasEditorial?"default":"fullSize"}
|
|
3133
|
-
@click="${this.handleOpenZoomedClick}"
|
|
3134
3125
|
style=${pe({display:this.focusIndex===1?"block":"none"})}
|
|
3135
|
-
></pbo-handwritten-canvas>`:
|
|
3126
|
+
></pbo-handwritten-canvas>`:K)}
|
|
3136
3127
|
<img
|
|
3137
3128
|
src="${(O=this.card)==null?void 0:O.medias.rendered_2.url}"
|
|
3138
3129
|
alt=""
|
|
@@ -3140,7 +3131,7 @@ void main() {
|
|
|
3140
3131
|
/>
|
|
3141
3132
|
</pbo-zoomed-preview>
|
|
3142
3133
|
</pbo-drawer>
|
|
3143
|
-
`}};
|
|
3134
|
+
`}};Tt.styles=[Ot,Lp];Tt.dependencies={"pbo-image":ne,"pbo-type-canvas":nt,"pbo-handwritten-canvas":dt,"pbo-drawer":Oe,"pbo-zoomed-preview":Be};Nt([C({type:Object})],Tt.prototype,"card",2);Nt([C({type:Number,reflect:!0})],Tt.prototype,"focusIndex",2);Nt([C({type:Object})],Tt.prototype,"livePreviewProps",2);Nt([C()],Tt.prototype,"handwrittenPreviewProps",2);Nt([C()],Tt.prototype,"type",2);Nt([z("#thumbnails")],Tt.prototype,"thumbnailCarousel",2);Nt([z("#main-carousel")],Tt.prototype,"mainCarousel",2);Nt([z(".editor__zoomed")],Tt.prototype,"zoomedPreview",2);Nt([z(".main-slide.active")],Tt.prototype,"activeMainSlide",2);Nt([z("pbo-type-canvas")],Tt.prototype,"typeCanvas",2);Nt([_o(".thumbnail")],Tt.prototype,"thumbnailElements",2);Nt([_o(".main-slide")],Tt.prototype,"mainSlideElements",2);Nt([I()],Tt.prototype,"mainImageTemplates",2);Nt([it("card")],Tt.prototype,"handleCardChange",1);Nt([it("focusIndex")],Tt.prototype,"handleFocusIndexChange",1);Tt=Nt([Et("pbo-editor-card-slider")],Tt);const Bm=gt`
|
|
3144
3135
|
:host {
|
|
3145
3136
|
display: block;
|
|
3146
3137
|
}
|
|
@@ -3243,7 +3234,7 @@ void main() {
|
|
|
3243
3234
|
.submit-error:not(:empty) {
|
|
3244
3235
|
display: block;
|
|
3245
3236
|
}
|
|
3246
|
-
`,zm=
|
|
3237
|
+
`,zm=gt`
|
|
3247
3238
|
:host {
|
|
3248
3239
|
display: block;
|
|
3249
3240
|
}
|
|
@@ -3328,7 +3319,7 @@ void main() {
|
|
|
3328
3319
|
<!-- Fake loading -->
|
|
3329
3320
|
${this.isImageProcessing?j`<div class="fake-loading-container">
|
|
3330
3321
|
<pbo-fake-loading ?loading=${this.isImageProcessing}></pbo-fake-loading>
|
|
3331
|
-
</div>`:
|
|
3322
|
+
</div>`:K}
|
|
3332
3323
|
|
|
3333
3324
|
<div class="buttons-container">
|
|
3334
3325
|
<!-- Upload button -->
|
|
@@ -3372,7 +3363,7 @@ void main() {
|
|
|
3372
3363
|
</pbo-button>
|
|
3373
3364
|
</div>
|
|
3374
3365
|
</form>
|
|
3375
|
-
`}};G.styles=[Ot,Bm];G.dependencies={"pbo-button":ht,"pbo-fake-loading":ii};st([C()],G.prototype,"card",2);st([C()],G.prototype,"submitHandwrittenForm",2);st([C()],G.prototype,"getProcessedImg",2);st([C({type:Function})],G.prototype,"onClose",2);st([C({type:Boolean,reflect:!0,attribute:"loading"})],G.prototype,"isSubmitLoading",2);st([C({type:String,attribute:"cta-primary-label"})],G.prototype,"ctaPrimaryLabel",2);st([C({type:Boolean,reflect:!0,attribute:"disabled"})],G.prototype,"isSubmitDisabled",2);st([z(".pixel-input")],G.prototype,"imageInput",2);st([z(".handwritten-form")],G.prototype,"handwrittenForm",2);st([z("pbo-button[name='upload']")],G.prototype,"uploadButton",2);st([z("pbo-button[name='save']")],G.prototype,"saveButton",2);st([z("pbo-button[name='reupload']")],G.prototype,"reuploadButton",2);st([I()],G.prototype,"isProcessingError",2);st([I()],G.prototype,"submitError",2);st([I()],G.prototype,"isImageProcessing",2);st([I()],G.prototype,"sourceImg",2);st([I()],G.prototype,"processedImg",2);st([I()],G.prototype,"handwrittenDimensions",2);st([
|
|
3366
|
+
`}};G.styles=[Ot,Bm];G.dependencies={"pbo-button":ht,"pbo-fake-loading":ii};st([C()],G.prototype,"card",2);st([C()],G.prototype,"submitHandwrittenForm",2);st([C()],G.prototype,"getProcessedImg",2);st([C({type:Function})],G.prototype,"onClose",2);st([C({type:Boolean,reflect:!0,attribute:"loading"})],G.prototype,"isSubmitLoading",2);st([C({type:String,attribute:"cta-primary-label"})],G.prototype,"ctaPrimaryLabel",2);st([C({type:Boolean,reflect:!0,attribute:"disabled"})],G.prototype,"isSubmitDisabled",2);st([z(".pixel-input")],G.prototype,"imageInput",2);st([z(".handwritten-form")],G.prototype,"handwrittenForm",2);st([z("pbo-button[name='upload']")],G.prototype,"uploadButton",2);st([z("pbo-button[name='save']")],G.prototype,"saveButton",2);st([z("pbo-button[name='reupload']")],G.prototype,"reuploadButton",2);st([I()],G.prototype,"isProcessingError",2);st([I()],G.prototype,"submitError",2);st([I()],G.prototype,"isImageProcessing",2);st([I()],G.prototype,"sourceImg",2);st([I()],G.prototype,"processedImg",2);st([I()],G.prototype,"handwrittenDimensions",2);st([it("isSubmitLoading")],G.prototype,"handleSubmitLoadingChange",1);st([it("isSubmitDisabled")],G.prototype,"handleSubmitDisabledChange",1);st([it("isProcessingError")],G.prototype,"handleProcessingErrorChange",1);st([it("sourceImg")],G.prototype,"handleSourceImgChange",1);st([it("processedFileUrl")],G.prototype,"handleProcessImageChange",1);st([it("isImageProcessing")],G.prototype,"handleImageProcessingChange",1);st([it("processedImg")],G.prototype,"handleProcessedImgChange",1);G=st([Et("pbo-handwritten-form")],G);const Wm=G,Ym=gt`
|
|
3376
3367
|
:host {
|
|
3377
3368
|
display: block;
|
|
3378
3369
|
}
|
|
@@ -3505,7 +3496,7 @@ void main() {
|
|
|
3505
3496
|
<slot name="label">${this.label}</slot>
|
|
3506
3497
|
</label>
|
|
3507
3498
|
</div>
|
|
3508
|
-
<select part="base" class="js-choice"></select>`}};si.styles=[Ot,Ym,
|
|
3499
|
+
<select part="base" class="js-choice"></select>`}};si.styles=[Ot,Ym,qs,Kr(oc)];hs([C()],si.prototype,"size",2);hs([C()],si.prototype,"label",2);hs([C({type:Boolean,reflect:!0})],si.prototype,"disabled",2);hs([it("disabled",{waitUntilFirstUpdate:!0})],si.prototype,"handleDisabledChanged",1);hs([z(".js-choice")],si.prototype,"choiceEl",2);si=hs([Et("pbo-editor-selector")],si);const qm=si;var Km=Object.defineProperty,Zm=Object.getOwnPropertyDescriptor,Bt=(r,t,e,i)=>{for(var s=i>1?void 0:i?Zm(t,e):t,n=r.length-1,o;n>=0;n--)(o=r[n])&&(s=(i?o(t,e,s):o(s))||s);return i&&s&&Km(t,e,s),s};let xt=class extends kt{constructor(){super(...arguments),this.card=null,this.onClose=()=>{},this.typeFormCtaLabel="",this.handwrittenFormCtaLabel="",this.hideColor=!1,this.formData={font:"Monsieur La Doulaise",text:"",color:"rgb(0,0,0)",alignment:"left"},this.handwrittenFormState={isLoading:!1,processedFileUrl:""},this.editorType="type",this.handleTypingFormChange=()=>{this.formData=this.typeForm.formData,this.slider.focusIndex!==1&&this.slider.focusOn(1)},this.handleHandwrittenFormChange=r=>{this.handwrittenFormState=r.detail,this.slider.focusOn(1),Ii()&&r.detail.processedFileUrl!==""&&r.detail.isLoading===!1&&(this.slider.openZoomedPreview(),this.slider.scrollIntoView({behavior:"smooth",block:"start"}))},this.handleHandwrittenImageDimensionsChanged=r=>{this.handwrittenForm.setDimensions(r.detail)},this.handleEditorChange=r=>{this.emit("pbo-switch-editor",{detail:{fromEditor:this.editorType,toEditor:r.detail.editor},bubbles:!0,composed:!0}),this.editorType=r.detail.editor}}async handleCardChange(){await this.updateComplete,this.card&&(this.slider.card=this.card,this.requestUpdate(),this.typeForm.card=this.card,this.handwrittenForm.card=this.card)}handleEditorTypeChange(){this.updateComplete.then(()=>{var r,t;if(this.editorType==="handwritten"&&Ii()&&this.handwrittenForm.scrollIntoView(!0),this.editorType==="type"){const e=(r=this.typeForm.shadowRoot)==null?void 0:r.querySelector("textarea");e==null||e.focus()}else{const e=(t=this.handwrittenForm.shadowRoot)==null?void 0:t.querySelector("pbo-button[name='upload']");e==null||e.focus()}})}firstUpdated(){this.addEventListener("handwritten-image-dimensions-changed",this.handleHandwrittenImageDimensionsChanged),this.typeForm.addEventListener("pbo-type-form-change",this.handleTypingFormChange),this.handwrittenForm.addEventListener("pbo-handwritten-form-change",this.handleHandwrittenFormChange)}disconnectedCallback(){this.typeForm.removeEventListener("pbo-type-form-change",this.handleTypingFormChange),this.handwrittenForm.removeEventListener("pbo-handwritten-form-change",this.handleHandwrittenFormChange)}render(){return j`
|
|
3509
3500
|
<div class="editor">
|
|
3510
3501
|
<div class="editor__card" part="editor-card-slider-container">
|
|
3511
3502
|
<pbo-editor-card-slider
|
|
@@ -3563,7 +3554,7 @@ void main() {
|
|
|
3563
3554
|
></pbo-handwritten-form>
|
|
3564
3555
|
</div>
|
|
3565
3556
|
</div>
|
|
3566
|
-
`}};
|
|
3557
|
+
`}};xt.styles=[Ot,Hd];xt.dependencies={"pbo-editor-card-slider":Tt,"pbo-type-form":Z,"pbo-handwritten-form":Wm,"pbo-editor-selector":qm};Bt([C({type:Object})],xt.prototype,"card",2);Bt([C()],xt.prototype,"submitTypeForm",2);Bt([C()],xt.prototype,"submitHandwrittenForm",2);Bt([C()],xt.prototype,"getProcessedImg",2);Bt([C({type:Function})],xt.prototype,"onClose",2);Bt([C({type:String,attribute:"type-form-cta-primary-label"})],xt.prototype,"typeFormCtaLabel",2);Bt([C({type:String,attribute:"handwritten-form-cta-primary-label"})],xt.prototype,"handwrittenFormCtaLabel",2);Bt([C({type:Boolean,attribute:"hide-type-form-color-block"})],xt.prototype,"hideColor",2);Bt([z("pbo-type-form")],xt.prototype,"typeForm",2);Bt([z("pbo-handwritten-form")],xt.prototype,"handwrittenForm",2);Bt([z("pbo-editor-card-slider")],xt.prototype,"slider",2);Bt([I()],xt.prototype,"formData",2);Bt([I()],xt.prototype,"handwrittenFormState",2);Bt([I()],xt.prototype,"editorType",2);Bt([it("card")],xt.prototype,"handleCardChange",1);Bt([it("editorType")],xt.prototype,"handleEditorTypeChange",1);xt=Bt([Et("pbo-editor")],xt);var Jm=Object.defineProperty,Qm=Object.getOwnPropertyDescriptor,mt=(r,t,e,i)=>{for(var s=i>1?void 0:i?Qm(t,e):t,n=r.length-1,o;n>=0;n--)(o=r[n])&&(s=(i?o(t,e,s):o(s))||s);return i&&s&&Jm(t,e,s),s};let et=class extends kt{constructor(){super(...arguments),this.onClose=()=>{},this.currentPage="selection",this.categories=[],this.isLoadingCategories=!1,this.isError=!1,this.errorMessage="Unknown error occurred. Please try again later.",this.selectionTitle="SELECT CARD",this.editorTitle="PERSONALIZE",this.typeFormCtaLabel="Add to Cart",this.handwrittenFormCtaLabel="Add to Cart",this.hideColor=!1,this.selectedCard=null,this.selectedCardId=null,this.selectedCardDetails=null,this.handleCardSelected=t=>{const{cardId:e}=t.detail,i=this.findCardInCategoryById(e);this.selectedCard=i,this.goToEditor()}}get editorEl(){var t;return((t=this.shadowRoot)==null?void 0:t.querySelector("pbo-editor"))||null}handleGetProcessedImgUpdate(){this.editorEl&&(this.editorEl.getProcessedImg=this.getProcessedImg)}async goToEditor(){var t;this.currentPage="editor",await this.updateComplete,(t=this.titleEl)==null||t.focus()}async goToSelector(){var t;this.currentPage="selection",await this.updateComplete,(t=this.titleEl)==null||t.focus()}connectedCallback(){var t;super.connectedCallback(),(t=this.shadowRoot)==null||t.addEventListener("pbo-category-card-selected",this.handleCardSelected)}disconnectedCallback(){var t;super.disconnectedCallback(),(t=this.shadowRoot)==null||t.removeEventListener("pbo-category-card-selected",this.handleCardSelected)}firstUpdated(){if(!this.cardSelectionEl){console.error("Card selection element not found");return}this.cardSelectionEl.categories=this.categories}handleCategoriesUpdate(){this.cardSelectionEl&&this.categories!==void 0&&this.categories.length>0&&(this.cardSelectionEl.categories=this.categories,this.requestUpdate())}setIsLoadingCategories(t){this.isLoadingCategories=t,this.cardSelectionEl&&(this.cardSelectionEl.loading=t)}findCardInCategoryById(t){for(const e of this.categories){const i=e.cards.find(s=>s.pboId===t);if(i)return i}return null}render(){return j`
|
|
3567
3558
|
<div part="base" class="page-manager">
|
|
3568
3559
|
<div class="header" part="header">
|
|
3569
3560
|
<div class="back-button" part="back-button">
|
|
@@ -3615,7 +3606,7 @@ void main() {
|
|
|
3615
3606
|
<h4 class="notification">
|
|
3616
3607
|
An error occurred while loading the page. Please refresh the page and try again.
|
|
3617
3608
|
</h4>
|
|
3618
|
-
${this.errorMessage&&this.errorMessage!==""?j`<p class="error-message">${this.errorMessage}</p>`:
|
|
3609
|
+
${this.errorMessage&&this.errorMessage!==""?j`<p class="error-message">${this.errorMessage}</p>`:K}
|
|
3619
3610
|
</div>
|
|
3620
3611
|
<pbo-button
|
|
3621
3612
|
variant="primary"
|
|
@@ -3625,7 +3616,7 @@ void main() {
|
|
|
3625
3616
|
>
|
|
3626
3617
|
Refresh page now
|
|
3627
3618
|
</pbo-button>
|
|
3628
|
-
</div>`:
|
|
3619
|
+
</div>`:K}
|
|
3629
3620
|
<div
|
|
3630
3621
|
class="category-selection"
|
|
3631
3622
|
?hidden=${this.currentPage!=="selection"}
|
|
@@ -3658,4 +3649,4 @@ void main() {
|
|
|
3658
3649
|
</div>
|
|
3659
3650
|
</div>
|
|
3660
3651
|
</div>
|
|
3661
|
-
`}};
|
|
3652
|
+
`}};et.styles=[Ot,Nh];et.dependencies={"pbo-button":ht,"pbo-card-selection":ji,"pbo-editor":xt};mt([z("pbo-card-selection")],et.prototype,"cardSelectionEl",2);mt([z(".title")],et.prototype,"titleEl",2);mt([C({type:Function})],et.prototype,"onClose",2);mt([C({type:String,reflect:!0})],et.prototype,"currentPage",2);mt([C()],et.prototype,"categories",2);mt([C()],et.prototype,"submitTypeForm",2);mt([C()],et.prototype,"submitHandwrittenForm",2);mt([C()],et.prototype,"getProcessedImg",2);mt([C({type:Boolean})],et.prototype,"isLoadingCategories",2);mt([C({type:Boolean})],et.prototype,"isError",2);mt([C({type:String})],et.prototype,"errorMessage",2);mt([C({type:String,attribute:"selection-title"})],et.prototype,"selectionTitle",2);mt([C({type:String,attribute:"editor-title"})],et.prototype,"editorTitle",2);mt([C({type:String,attribute:"type-form-cta-primary-label"})],et.prototype,"typeFormCtaLabel",2);mt([C({type:String,attribute:"handwritten-form-cta-primary-label"})],et.prototype,"handwrittenFormCtaLabel",2);mt([C({type:Boolean,attribute:"hide-type-form-color-block"})],et.prototype,"hideColor",2);mt([I()],et.prototype,"selectedCard",2);mt([I()],et.prototype,"selectedCardId",2);mt([I()],et.prototype,"selectedCardDetails",2);mt([it("getProcessedImg")],et.prototype,"handleGetProcessedImgUpdate",1);mt([it("categories")],et.prototype,"handleCategoriesUpdate",1);et=mt([Et("pbo-page-manager")],et);const pb=et;export{pb as default};
|