@pairbo/ui-kit 0.3.0 → 0.3.1
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/ui-kit.js
CHANGED
|
@@ -2,21 +2,21 @@
|
|
|
2
2
|
* @license
|
|
3
3
|
* Copyright 2019 Google LLC
|
|
4
4
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
5
|
-
*/const
|
|
5
|
+
*/const bn=globalThis,Sa=bn.ShadowRoot&&(bn.ShadyCSS===void 0||bn.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,Ta=Symbol(),fl=new WeakMap;let Gc=class{constructor(t,e,i){if(this._$cssResult$=!0,i!==Ta)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(Sa&&t===void 0){const i=e!==void 0&&e.length===1;i&&(t=fl.get(e)),t===void 0&&((this.o=t=new CSSStyleSheet).replaceSync(this.cssText),i&&fl.set(e,t))}return t}toString(){return this.cssText}};const Kn=n=>new Gc(typeof n=="string"?n:n+"",void 0,Ta),ct=(n,...t)=>{const e=n.length===1?n[0]:t.reduce((i,s,r)=>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)+n[r+1],n[0]);return new Gc(e,n,Ta)},ed=(n,t)=>{if(Sa)n.adoptedStyleSheets=t.map(e=>e instanceof CSSStyleSheet?e:e.styleSheet);else for(const e of t){const i=document.createElement("style"),s=bn.litNonce;s!==void 0&&i.setAttribute("nonce",s),i.textContent=e.cssText,n.appendChild(i)}},ml=Sa?n=>n:n=>n instanceof CSSStyleSheet?(t=>{let e="";for(const i of t.cssRules)e+=i.cssText;return Kn(e)})(n):n;/**
|
|
6
6
|
* @license
|
|
7
7
|
* Copyright 2017 Google LLC
|
|
8
8
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
9
|
-
*/const{is:id,defineProperty:
|
|
9
|
+
*/const{is:id,defineProperty:sd,getOwnPropertyDescriptor:rd,getOwnPropertyNames:nd,getOwnPropertySymbols:od,getPrototypeOf:ad}=Object,Ti=globalThis,vl=Ti.trustedTypes,ld=vl?vl.emptyScript:"",So=Ti.reactiveElementPolyfillSupport,er=(n,t)=>n,kn={toAttribute(n,t){switch(t){case Boolean:n=n?ld:null;break;case Object:case Array:n=n==null?n:JSON.stringify(n)}return n},fromAttribute(n,t){let e=n;switch(t){case Boolean:e=n!==null;break;case Number:e=n===null?null:Number(n);break;case Object:case Array:try{e=JSON.parse(n)}catch{e=null}}return e}},Ea=(n,t)=>!id(n,t),bl={attribute:!0,type:String,converter:kn,reflect:!1,hasChanged:Ea};Symbol.metadata??(Symbol.metadata=Symbol("metadata")),Ti.litPropertyMetadata??(Ti.litPropertyMetadata=new WeakMap);let ds=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=bl){if(e.state&&(e.attribute=!1),this._$Ei(),this.elementProperties.set(t,e),!e.noAccessor){const i=Symbol(),s=this.getPropertyDescriptor(t,i,e);s!==void 0&&sd(this.prototype,t,s)}}static getPropertyDescriptor(t,e,i){const{get:s,set:r}=rd(this.prototype,t)??{get(){return this[e]},set(o){this[e]=o}};return{get(){return s==null?void 0:s.call(this)},set(o){const a=s==null?void 0:s.call(this);r.call(this,o),this.requestUpdate(t,a,i)},configurable:!0,enumerable:!0}}static getPropertyOptions(t){return this.elementProperties.get(t)??bl}static _$Ei(){if(this.hasOwnProperty(er("elementProperties")))return;const t=ad(this);t.finalize(),t.l!==void 0&&(this.l=[...t.l]),this.elementProperties=new Map(t.elementProperties)}static finalize(){if(this.hasOwnProperty(er("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(er("properties"))){const e=this.properties,i=[...nd(e),...od(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(ml(s))}else t!==void 0&&e.push(ml(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 ed(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)}_$EC(t,e){var r;const i=this.constructor.elementProperties.get(t),s=this.constructor._$Eu(t,i);if(s!==void 0&&i.reflect===!0){const o=(((r=i.converter)==null?void 0:r.toAttribute)!==void 0?i.converter:kn).toAttribute(e,i.type);this._$Em=t,o==null?this.removeAttribute(s):this.setAttribute(s,o),this._$Em=null}}_$AK(t,e){var r;const i=this.constructor,s=i._$Eh.get(t);if(s!==void 0&&this._$Em!==s){const o=i.getPropertyOptions(s),a=typeof o.converter=="function"?{fromAttribute:o.converter}:((r=o.converter)==null?void 0:r.fromAttribute)!==void 0?o.converter:kn;this._$Em=s,this[s]=a.fromAttribute(e,o.type),this._$Em=null}}requestUpdate(t,e,i){if(t!==void 0){if(i??(i=this.constructor.getPropertyOptions(t)),!(i.hasChanged??Ea)(this[t],e))return;this.P(t,e,i)}this.isUpdatePending===!1&&(this._$ES=this._$ET())}P(t,e,i){this._$AL.has(t)||this._$AL.set(t,e),i.reflect===!0&&this._$Em!==t&&(this._$Ej??(this._$Ej=new Set)).add(t)}async _$ET(){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[r,o]of this._$Ep)this[r]=o;this._$Ep=void 0}const s=this.constructor.elementProperties;if(s.size>0)for(const[r,o]of s)o.wrapped!==!0||this._$AL.has(r)||this[r]===void 0||this.P(r,this[r],o)}let t=!1;const e=this._$AL;try{t=this.shouldUpdate(e),t?(this.willUpdate(e),(i=this._$EO)==null||i.forEach(s=>{var r;return(r=s.hostUpdate)==null?void 0:r.call(s)}),this.update(e)):this._$EU()}catch(s){throw t=!1,this._$EU(),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)}_$EU(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$ES}shouldUpdate(t){return!0}update(t){this._$Ej&&(this._$Ej=this._$Ej.forEach(e=>this._$EC(e,this[e]))),this._$EU()}updated(t){}firstUpdated(t){}};ds.elementStyles=[],ds.shadowRootOptions={mode:"open"},ds[er("elementProperties")]=new Map,ds[er("finalized")]=new Map,So==null||So({ReactiveElement:ds}),(Ti.reactiveElementVersions??(Ti.reactiveElementVersions=[])).push("2.0.4");/**
|
|
10
10
|
* @license
|
|
11
11
|
* Copyright 2017 Google LLC
|
|
12
12
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
13
|
-
*/const
|
|
14
|
-
\f\r]`,
|
|
15
|
-
\f\r"'\`<>=]|("|')|))|$)`,"g"),wl=/'/g,Cl=/"/g,Kc=/^(?:script|style|textarea|title)$/i,ud=n=>(t,...e)=>({_$litType$:n,strings:t,values:e}),V=ud(1),Ce=Symbol.for("lit-noChange"),
|
|
13
|
+
*/const ir=globalThis,An=ir.trustedTypes,_l=An?An.createPolicy("lit-html",{createHTML:n=>n}):void 0,Yc="$lit$",xi=`lit$${Math.random().toFixed(9).slice(2)}$`,Xc="?"+xi,cd=`<${Xc}>`,Qi=document,hr=()=>Qi.createComment(""),ur=n=>n===null||typeof n!="object"&&typeof n!="function",Oa=Array.isArray,hd=n=>Oa(n)||typeof(n==null?void 0:n[Symbol.iterator])=="function",To=`[
|
|
14
|
+
\f\r]`,Us=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,yl=/-->/g,xl=/>/g,zi=RegExp(`>|${To}(?:([^\\s"'>=/]+)(${To}*=${To}*(?:[^
|
|
15
|
+
\f\r"'\`<>=]|("|')|))|$)`,"g"),wl=/'/g,Cl=/"/g,Kc=/^(?:script|style|textarea|title)$/i,ud=n=>(t,...e)=>({_$litType$:n,strings:t,values:e}),V=ud(1),Ce=Symbol.for("lit-noChange"),at=Symbol.for("lit-nothing"),Sl=new WeakMap,Yi=Qi.createTreeWalker(Qi,129);function qc(n,t){if(!Oa(n)||!n.hasOwnProperty("raw"))throw Error("invalid template strings array");return _l!==void 0?_l.createHTML(t):t}const dd=(n,t)=>{const e=n.length-1,i=[];let s,r=t===2?"<svg>":t===3?"<math>":"",o=Us;for(let a=0;a<e;a++){const l=n[a];let c,h,u=-1,d=0;for(;d<l.length&&(o.lastIndex=d,h=o.exec(l),h!==null);)d=o.lastIndex,o===Us?h[1]==="!--"?o=yl:h[1]!==void 0?o=xl:h[2]!==void 0?(Kc.test(h[2])&&(s=RegExp("</"+h[2],"g")),o=zi):h[3]!==void 0&&(o=zi):o===zi?h[0]===">"?(o=s??Us,u=-1):h[1]===void 0?u=-2:(u=o.lastIndex-h[2].length,c=h[1],o=h[3]===void 0?zi:h[3]==='"'?Cl:wl):o===Cl||o===wl?o=zi:o===yl||o===xl?o=Us:(o=zi,s=void 0);const p=o===zi&&n[a+1].startsWith("/>")?" ":"";r+=o===Us?l+cd:u>=0?(i.push(c),l.slice(0,u)+Yc+l.slice(u)+xi+p):l+xi+(u===-2?a:p)}return[qc(n,r+(n[e]||"<?>")+(t===2?"</svg>":t===3?"</math>":"")),i]};let qo=class Zc{constructor({strings:t,_$litType$:e},i){let s;this.parts=[];let r=0,o=0;const a=t.length-1,l=this.parts,[c,h]=dd(t,e);if(this.el=Zc.createElement(c,i),Yi.currentNode=this.el.content,e===2||e===3){const u=this.el.content.firstChild;u.replaceWith(...u.childNodes)}for(;(s=Yi.nextNode())!==null&&l.length<a;){if(s.nodeType===1){if(s.hasAttributes())for(const u of s.getAttributeNames())if(u.endsWith(Yc)){const d=h[o++],p=s.getAttribute(u).split(xi),g=/([.?@])?(.*)/.exec(d);l.push({type:1,index:r,name:g[2],strings:p,ctor:g[1]==="."?gd:g[1]==="?"?fd:g[1]==="@"?md:Zn}),s.removeAttribute(u)}else u.startsWith(xi)&&(l.push({type:6,index:r}),s.removeAttribute(u));if(Kc.test(s.tagName)){const u=s.textContent.split(xi),d=u.length-1;if(d>0){s.textContent=An?An.emptyScript:"";for(let p=0;p<d;p++)s.append(u[p],hr()),Yi.nextNode(),l.push({type:2,index:++r});s.append(u[d],hr())}}}else if(s.nodeType===8)if(s.data===Xc)l.push({type:2,index:r});else{let u=-1;for(;(u=s.data.indexOf(xi,u+1))!==-1;)l.push({type:7,index:r}),u+=xi.length-1}r++}}static createElement(t,e){const i=Qi.createElement("template");return i.innerHTML=t,i}};function Os(n,t,e=n,i){var o,a;if(t===Ce)return t;let s=i!==void 0?(o=e._$Co)==null?void 0:o[i]:e._$Cl;const r=ur(t)?void 0:t._$litDirective$;return(s==null?void 0:s.constructor)!==r&&((a=s==null?void 0:s._$AO)==null||a.call(s,!1),r===void 0?s=void 0:(s=new r(n),s._$AT(n,e,i)),i!==void 0?(e._$Co??(e._$Co=[]))[i]=s:e._$Cl=s),s!==void 0&&(t=Os(n,s._$AS(n,t.values),s,i)),t}let pd=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)??Qi).importNode(e,!0);Yi.currentNode=s;let r=Yi.nextNode(),o=0,a=0,l=i[0];for(;l!==void 0;){if(o===l.index){let c;l.type===2?c=new qn(r,r.nextSibling,this,t):l.type===1?c=new l.ctor(r,l.name,l.strings,this,t):l.type===6&&(c=new vd(r,this,t)),this._$AV.push(c),l=i[++a]}o!==(l==null?void 0:l.index)&&(r=Yi.nextNode(),o++)}return Yi.currentNode=Qi,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++}},qn=class Jc{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=at,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=Os(this,t,e),ur(t)?t===at||t==null||t===""?(this._$AH!==at&&this._$AR(),this._$AH=at):t!==this._$AH&&t!==Ce&&this._(t):t._$litType$!==void 0?this.$(t):t.nodeType!==void 0?this.T(t):hd(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!==at&&ur(this._$AH)?this._$AA.nextSibling.data=t:this.T(Qi.createTextNode(t)),this._$AH=t}$(t){var r;const{values:e,_$litType$:i}=t,s=typeof i=="number"?this._$AC(t):(i.el===void 0&&(i.el=qo.createElement(qc(i.h,i.h[0]),this.options)),i);if(((r=this._$AH)==null?void 0:r._$AD)===s)this._$AH.p(e);else{const o=new pd(s,this),a=o.u(this.options);o.p(e),this.T(a),this._$AH=o}}_$AC(t){let e=Sl.get(t.strings);return e===void 0&&Sl.set(t.strings,e=new qo(t)),e}k(t){Oa(this._$AH)||(this._$AH=[],this._$AR());const e=this._$AH;let i,s=0;for(const r of t)s===e.length?e.push(i=new Jc(this.O(hr()),this.O(hr()),this,this.options)):i=e[s],i._$AI(r),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&&t!==this._$AB;){const s=t.nextSibling;t.remove(),t=s}}setConnected(t){var e;this._$AM===void 0&&(this._$Cv=t,(e=this._$AP)==null||e.call(this,t))}},Zn=class{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(t,e,i,s,r){this.type=1,this._$AH=at,this._$AN=void 0,this.element=t,this.name=e,this._$AM=s,this.options=r,i.length>2||i[0]!==""||i[1]!==""?(this._$AH=Array(i.length-1).fill(new String),this.strings=i):this._$AH=at}_$AI(t,e=this,i,s){const r=this.strings;let o=!1;if(r===void 0)t=Os(this,t,e,0),o=!ur(t)||t!==this._$AH&&t!==Ce,o&&(this._$AH=t);else{const a=t;let l,c;for(t=r[0],l=0;l<r.length-1;l++)c=Os(this,a[i+l],e,l),c===Ce&&(c=this._$AH[l]),o||(o=!ur(c)||c!==this._$AH[l]),c===at?t=at:t!==at&&(t+=(c??"")+r[l+1]),this._$AH[l]=c}o&&!s&&this.j(t)}j(t){t===at?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,t??"")}},gd=class extends Zn{constructor(){super(...arguments),this.type=3}j(t){this.element[this.name]=t===at?void 0:t}},fd=class extends Zn{constructor(){super(...arguments),this.type=4}j(t){this.element.toggleAttribute(this.name,!!t&&t!==at)}},md=class extends Zn{constructor(t,e,i,s,r){super(t,e,i,s,r),this.type=5}_$AI(t,e=this){if((t=Os(this,t,e,0)??at)===Ce)return;const i=this._$AH,s=t===at&&i!==at||t.capture!==i.capture||t.once!==i.once||t.passive!==i.passive,r=t!==at&&(i===at||s);s&&this.element.removeEventListener(this.name,this,i),r&&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)}},vd=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){Os(this,t)}};const bd={I:qn},Eo=ir.litHtmlPolyfillSupport;Eo==null||Eo(qo,qn),(ir.litHtmlVersions??(ir.litHtmlVersions=[])).push("3.2.1");const Qc=(n,t,e)=>{const i=(e==null?void 0:e.renderBefore)??t;let s=i._$litPart$;if(s===void 0){const r=(e==null?void 0:e.renderBefore)??null;i._$litPart$=s=new qn(t.insertBefore(hr(),r),r,void 0,e??{})}return s._$AI(n),s};/**
|
|
16
16
|
* @license
|
|
17
17
|
* Copyright 2017 Google LLC
|
|
18
18
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
19
|
-
*/let Zi=class extends
|
|
19
|
+
*/let Zi=class extends ds{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=Qc(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 Ce}};var Wc;Zi._$litElement$=!0,Zi.finalized=!0,(Wc=globalThis.litElementHydrateSupport)==null||Wc.call(globalThis,{LitElement:Zi});const Oo=globalThis.litElementPolyfillSupport;Oo==null||Oo({LitElement:Zi});(globalThis.litElementVersions??(globalThis.litElementVersions=[])).push("4.1.1");/**
|
|
20
20
|
* @license
|
|
21
21
|
* Copyright 2017 Google LLC
|
|
22
22
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
* @license
|
|
25
25
|
* Copyright 2017 Google LLC
|
|
26
26
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
27
|
-
*/const _d={attribute:!0,type:String,converter:
|
|
27
|
+
*/const _d={attribute:!0,type:String,converter:kn,reflect:!1,hasChanged:Ea},yd=(n=_d,t,e)=>{const{kind:i,metadata:s}=e;let r=globalThis.litPropertyMetadata.get(s);if(r===void 0&&globalThis.litPropertyMetadata.set(s,r=new Map),r.set(e.name,n),i==="accessor"){const{name:o}=e;return{set(a){const l=t.get.call(this);t.set.call(this,a),this.requestUpdate(o,l,n)},init(a){return a!==void 0&&this.P(o,void 0,n),a}}}if(i==="setter"){const{name:o}=e;return function(a){const l=this[o];t.call(this,a),this.requestUpdate(o,l,n)}}throw Error("Unsupported decorator location: "+i)};function S(n){return(t,e)=>typeof e=="object"?yd(n,t,e):((i,s,r)=>{const o=s.hasOwnProperty(r);return s.constructor.createProperty(r,o?{...i,wrapped:!0}:i),o?Object.getOwnPropertyDescriptor(s,r):void 0})(n,t,e)}/**
|
|
28
28
|
* @license
|
|
29
29
|
* Copyright 2017 Google LLC
|
|
30
30
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
@@ -36,11 +36,11 @@
|
|
|
36
36
|
* @license
|
|
37
37
|
* Copyright 2017 Google LLC
|
|
38
38
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
39
|
-
*/function
|
|
39
|
+
*/function q(n,t){return(e,i,s)=>{const r=o=>{var a;return((a=o.renderRoot)==null?void 0:a.querySelector(n))??null};return th(e,i,{get(){return r(this)}})}}/**
|
|
40
40
|
* @license
|
|
41
41
|
* Copyright 2017 Google LLC
|
|
42
42
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
43
|
-
*/let xd;function ka(n){return(t,e)=>th(t,e,{get(){return(this.renderRoot??xd??(xd=document.createDocumentFragment())).querySelectorAll(n)}})}const wd=
|
|
43
|
+
*/let xd;function ka(n){return(t,e)=>th(t,e,{get(){return(this.renderRoot??xd??(xd=document.createDocumentFragment())).querySelectorAll(n)}})}const wd=ct`
|
|
44
44
|
:host {
|
|
45
45
|
display: block;
|
|
46
46
|
font-family: Arial, sans-serif;
|
|
@@ -52,7 +52,7 @@
|
|
|
52
52
|
background-color: #fff;
|
|
53
53
|
color: black;
|
|
54
54
|
}
|
|
55
|
-
`;var Cd=Object.getOwnPropertyDescriptor,Sd=(n,t,e,i)=>{for(var
|
|
55
|
+
`;var Cd=Object.getOwnPropertyDescriptor,Sd=(n,t,e,i)=>{for(var s=i>1?void 0:i?Cd(t,e):t,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=o(s)||s);return s};let Pn=class extends Zi{constructor(){super(),this.giftLabel="This is a gift?",this.premiumLabel="Add a premium greeting card",this.premiumDescription="Select a premium greeting card and add your personal message. You'll choose from our 100% recycled paper cards, priced at $6, and we'll package it with your gift for that extra thoughtful touch.",this.noteLabel="Add a free message",this.giftSelected=!1,this.premiumSelected=!1,this.freeMessageSelected=!1}toggleMessageSelector(){var t;const n=(t=this.shadowRoot)==null?void 0:t.querySelector(".message-selector");n&&n.classList.toggle("message-selector-hidden")}_onGiftChange(n){const t=n.target;this.giftSelected=t.checked,this.giftSelected||(this.premiumSelected=!1,this.freeMessageSelected=!1)}_onPremiumChange(n){n.target.checked?(this.premiumSelected=!0,this.freeMessageSelected=!1):this.premiumSelected=!1}_onFreeMessageChange(n){n.target.checked?(this.freeMessageSelected=!0,this.premiumSelected=!1):this.freeMessageSelected=!1}render(){return V`
|
|
56
56
|
<div class="message-selector">
|
|
57
57
|
<!-- Gift Checkbox: Always visible -->
|
|
58
58
|
<div>
|
|
@@ -103,7 +103,7 @@
|
|
|
103
103
|
</ul>
|
|
104
104
|
</div>
|
|
105
105
|
</div>
|
|
106
|
-
`}};
|
|
106
|
+
`}};Pn.styles=[wd,ct`
|
|
107
107
|
.message-selector {
|
|
108
108
|
text-align: left;
|
|
109
109
|
}
|
|
@@ -124,7 +124,7 @@
|
|
|
124
124
|
code {
|
|
125
125
|
font-family: monospace;
|
|
126
126
|
}
|
|
127
|
-
`];
|
|
127
|
+
`];Pn.properties={giftLabel:{type:String},premiumLabel:{type:String},premiumDescription:{type:String},noteLabel:{type:String},giftSelected:{type:Boolean},premiumSelected:{type:Boolean},freeMessageSelected:{type:Boolean}};Pn=Sd([xt("pairbo-message-selector")],Pn);const Tt=ct`
|
|
128
128
|
:host {
|
|
129
129
|
box-sizing: border-box;
|
|
130
130
|
text-shadow: none;
|
|
@@ -141,7 +141,7 @@
|
|
|
141
141
|
[hidden] {
|
|
142
142
|
display: none !important;
|
|
143
143
|
}
|
|
144
|
-
`,Td=
|
|
144
|
+
`,Td=ct`
|
|
145
145
|
:host {
|
|
146
146
|
display: block;
|
|
147
147
|
}
|
|
@@ -151,15 +151,19 @@
|
|
|
151
151
|
.choices__item {
|
|
152
152
|
font-size: 16px;
|
|
153
153
|
}
|
|
154
|
-
`;/*! choices.js v11.0.3 | © 2024 Josh Johnson | https://github.com/jshjohnson/Choices#readme */var Zo=function(n,t){return Zo=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,i){e.__proto__=i}||function(e,i){for(var r in i)Object.prototype.hasOwnProperty.call(i,r)&&(e[r]=i[r])},Zo(n,t)};function eh(n,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");Zo(n,t);function e(){this.constructor=n}n.prototype=t===null?Object.create(t):(e.prototype=t.prototype,new e)}var ne=function(){return ne=Object.assign||function(t){for(var e,i=1,r=arguments.length;i<r;i++){e=arguments[i];for(var s in e)Object.prototype.hasOwnProperty.call(e,s)&&(t[s]=e[s])}return t},ne.apply(this,arguments)};function Ed(n,t,e){for(var i=0,r=t.length,s;i<r;i++)(s||!(i in t))&&(s||(s=Array.prototype.slice.call(t,0,i)),s[i]=t[i]);return n.concat(s||Array.prototype.slice.call(t))}var Tt={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"},se={showDropdown:"showDropdown",hideDropdown:"hideDropdown",change:"change",choice:"choice",search:"search",addItem:"addItem",removeItem:"removeItem",highlightItem:"highlightItem",highlightChoice:"highlightChoice",unhighlightItem:"unhighlightItem"},Gt={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},Od=["fuseOptions","classNames"],wi={Text:"text",SelectOne:"select-one",SelectMultiple:"select-multiple"},kd=function(n){return{type:Tt.ADD_CHOICE,choice:n}},Tl=function(n){return{type:Tt.REMOVE_CHOICE,choice:n}},Ad=function(n){return{type:Tt.FILTER_CHOICES,results:n}},Pd=function(n){return{type:Tt.ACTIVATE_CHOICES,active:n}},Dd=function(n){return{type:Tt.ADD_GROUP,group:n}},Md=function(n){return{type:Tt.ADD_ITEM,item:n}},El=function(n){return{type:Tt.REMOVE_ITEM,item:n}},Vs=function(n,t){return{type:Tt.HIGHLIGHT_ITEM,item:n,highlighted:t}},Id=function(n,t){return Math.floor(Math.random()*(t-n)+n)},Ol=function(n){return Array.from({length:n},function(){return Id(0,36).toString(36)}).join("")},Ld=function(n,t){var e=n.id||n.name&&"".concat(n.name,"-").concat(Ol(2))||Ol(4);return e=e.replace(/(:|\.|\[|\]|,)/g,""),e="".concat(t,"-").concat(e),e},Fd=function(n,t,e){e===void 0&&(e=1);for(var i="".concat(e>0?"next":"previous","ElementSibling"),r=n[i];r;){if(r.matches(t))return r;r=r[i]}return null},jd=function(n,t,e){e===void 0&&(e=1);var i;return e>0?i=t.scrollTop+t.offsetHeight>=n.offsetTop+n.offsetHeight:i=n.offsetTop>=t.scrollTop,i},Qn=function(n){if(typeof n!="string"){if(n==null)return"";if(typeof n=="object"){if("raw"in n)return Qn(n.raw);if("trusted"in n)return n.trusted}return n}return n.replace(/&/g,"&").replace(/>/g,">").replace(/</g,"<").replace(/'/g,"'").replace(/"/g,""")},Rd=function(){var n=document.createElement("div");return function(t){n.innerHTML=t.trim();for(var e=n.children[0];n.firstChild;)n.removeChild(n.firstChild);return e}}(),rs=function(n,t){return typeof n=="function"?n(Qn(t),t):n},kl=function(n){return typeof n=="function"?n():n},Xi=function(n){if(typeof n=="string")return n;if(typeof n=="object"){if("trusted"in n)return n.trusted;if("raw"in n)return n.raw}return""},$d=function(n){if(typeof n=="string")return n;if(typeof n=="object"){if("escaped"in n)return n.escaped;if("trusted"in n)return n.trusted}return""},Aa=function(n,t){return n?$d(t):Qn(t)},Je=function(n,t,e){n.innerHTML=Aa(t,e)},Bd=function(n,t){var e=n.value,i=n.label,r=i===void 0?e:i,s=t.value,o=t.label,a=o===void 0?s:o;return Xi(r).localeCompare(Xi(a),[],{sensitivity:"base",ignorePunctuation:!0,numeric:!0})},Nd=function(n,t){return n.rank-t.rank},zd=function(n,t,e){e===void 0&&(e=null);var i=new CustomEvent(t,{detail:e,bubbles:!0,cancelable:!0});return n.dispatchEvent(i)},Hd=function(n,t){var e=Object.keys(n).sort(),i=Object.keys(t).sort();return e.filter(function(r){return i.indexOf(r)<0})},to=function(n){return Array.isArray(n)?n:[n]},Wr=function(n){return n&&Array.isArray(n)?n.map(function(t){return".".concat(t)}).join(""):".".concat(n)},G=function(n,t){var e;(e=n.classList).add.apply(e,to(t))},$e=function(n,t){var e;(e=n.classList).remove.apply(e,to(t))},Vd=function(n){if(typeof n<"u")try{return JSON.parse(n)}catch{return n}return{}},Ud=function(n,t,e){var i=n.itemEl;i&&($e(i,e),G(i,t))},Wd=function(){function n(t){var e=t.element,i=t.type,r=t.classNames;this.element=e,this.classNames=r,this.type=i,this.isActive=!1}return n.prototype.show=function(){return G(this.element,this.classNames.activeState),this.element.setAttribute("aria-expanded","true"),this.isActive=!0,this},n.prototype.hide=function(){return $e(this.element,this.classNames.activeState),this.element.setAttribute("aria-expanded","false"),this.isActive=!1,this},n}(),Al=function(){function n(t){var e=t.element,i=t.type,r=t.classNames,s=t.position;this.element=e,this.classNames=r,this.type=i,this.position=s,this.isOpen=!1,this.isFlipped=!1,this.isDisabled=!1,this.isLoading=!1}return n.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},n.prototype.setActiveDescendant=function(t){this.element.setAttribute("aria-activedescendant",t)},n.prototype.removeActiveDescendant=function(){this.element.removeAttribute("aria-activedescendant")},n.prototype.open=function(t,e){G(this.element,this.classNames.openState),this.element.setAttribute("aria-expanded","true"),this.isOpen=!0,this.shouldFlip(t,e)&&(G(this.element,this.classNames.flippedState),this.isFlipped=!0)},n.prototype.close=function(){$e(this.element,this.classNames.openState),this.element.setAttribute("aria-expanded","false"),this.removeActiveDescendant(),this.isOpen=!1,this.isFlipped&&($e(this.element,this.classNames.flippedState),this.isFlipped=!1)},n.prototype.addFocusState=function(){G(this.element,this.classNames.focusState)},n.prototype.removeFocusState=function(){$e(this.element,this.classNames.focusState)},n.prototype.enable=function(){$e(this.element,this.classNames.disabledState),this.element.removeAttribute("aria-disabled"),this.type===wi.SelectOne&&this.element.setAttribute("tabindex","0"),this.isDisabled=!1},n.prototype.disable=function(){G(this.element,this.classNames.disabledState),this.element.setAttribute("aria-disabled","true"),this.type===wi.SelectOne&&this.element.setAttribute("tabindex","-1"),this.isDisabled=!0},n.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)},n.prototype.unwrap=function(t){var e=this.element,i=e.parentNode;i&&(i.insertBefore(t,e),i.removeChild(e))},n.prototype.addLoadingState=function(){G(this.element,this.classNames.loadingState),this.element.setAttribute("aria-busy","true"),this.isLoading=!0},n.prototype.removeLoadingState=function(){$e(this.element,this.classNames.loadingState),this.element.removeAttribute("aria-busy"),this.isLoading=!1},n}(),Gd=function(){function n(t){var e=t.element,i=t.type,r=t.classNames,s=t.preventPaste;this.element=e,this.type=i,this.classNames=r,this.preventPaste=s,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(n.prototype,"placeholder",{set:function(t){this.element.placeholder=t},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"value",{get:function(){return this.element.value},set:function(t){this.element.value=t},enumerable:!1,configurable:!0}),n.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})},n.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)},n.prototype.enable=function(){var t=this.element;t.removeAttribute("disabled"),this.isDisabled=!1},n.prototype.disable=function(){var t=this.element;t.setAttribute("disabled",""),this.isDisabled=!0},n.prototype.focus=function(){this.isFocussed||this.element.focus()},n.prototype.blur=function(){this.isFocussed&&this.element.blur()},n.prototype.clear=function(t){return t===void 0&&(t=!0),this.element.value="",t&&this.setWidth(),this},n.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")},n.prototype.setActiveDescendant=function(t){this.element.setAttribute("aria-activedescendant",t)},n.prototype.removeActiveDescendant=function(){this.element.removeAttribute("aria-activedescendant")},n.prototype._onInput=function(){this.type!==wi.SelectOne&&this.setWidth()},n.prototype._onPaste=function(t){this.preventPaste&&t.preventDefault()},n.prototype._onFocus=function(){this.isFocussed=!0},n.prototype._onBlur=function(){this.isFocussed=!1},n}(),Yd=4,Pl=function(){function n(t){var e=t.element;this.element=e,this.scrollPos=this.element.scrollTop,this.height=this.element.offsetHeight}return n.prototype.prepend=function(t){var e=this.element.firstElementChild;e?this.element.insertBefore(t,e):this.element.append(t)},n.prototype.scrollToTop=function(){this.element.scrollTop=0},n.prototype.scrollToChildElement=function(t,e){var i=this;if(t){var r=this.element.offsetHeight,s=this.element.scrollTop+r,o=t.offsetHeight,a=t.offsetTop+o,l=e>0?this.element.scrollTop+a-s:t.offsetTop;requestAnimationFrame(function(){i._animateScroll(l,e)})}},n.prototype._scrollDown=function(t,e,i){var r=(i-t)/e,s=r>1?r:1;this.element.scrollTop=t+s},n.prototype._scrollUp=function(t,e,i){var r=(t-i)/e,s=r>1?r:1;this.element.scrollTop=t-s},n.prototype._animateScroll=function(t,e){var i=this,r=Yd,s=this.element.scrollTop,o=!1;e>0?(this._scrollDown(s,r,t),s<t&&(o=!0)):(this._scrollUp(s,r,t),s>t&&(o=!0)),o&&requestAnimationFrame(function(){i._animateScroll(t,e)})},n}(),ih=function(){function n(t){var e=t.element,i=t.classNames;this.element=e,this.classNames=i,this.isDisabled=!1}return Object.defineProperty(n.prototype,"isActive",{get:function(){return this.element.dataset.choice==="active"},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"dir",{get:function(){return this.element.dir},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"value",{get:function(){return this.element.value},set:function(t){this.element.setAttribute("value",t),this.element.value=t},enumerable:!1,configurable:!0}),n.prototype.conceal=function(){var t=this.element;G(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")},n.prototype.reveal=function(){var t=this.element;$e(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")},n.prototype.enable=function(){this.element.removeAttribute("disabled"),this.element.disabled=!1,this.isDisabled=!1},n.prototype.disable=function(){this.element.setAttribute("disabled",""),this.element.disabled=!0,this.isDisabled=!0},n.prototype.triggerEvent=function(t,e){zd(this.element,t,e||{})},n}(),Xd=function(n){eh(t,n);function t(){return n!==null&&n.apply(this,arguments)||this}return t}(ih),Qr=function(n,t){return t===void 0&&(t=!0),typeof n>"u"?t:!!n},rh=function(n){if(typeof n=="string"&&(n=n.split(" ").filter(function(t){return t.length})),Array.isArray(n)&&n.length)return n},Re=function(n,t,e){if(e===void 0&&(e=!0),typeof n=="string"){var i=Qn(n),r=e||i===n?n:{escaped:i,raw:n},s=Re({value:n,label:r,selected:!0},!1);return s}var o=n;if("choices"in o){if(!t)throw new TypeError("optGroup is not allowed");var a=o,l=a.choices.map(function(d){return Re(d,!1)}),c={id:0,label:Xi(a.label)||a.value,active:!!l.length,disabled:!!a.disabled,choices:l};return c}var h=o,u={id:0,group:null,score:0,rank:0,value:h.value,label:h.label||h.value,active:Qr(h.active),selected:Qr(h.selected,!1),disabled:Qr(h.disabled,!1),placeholder:Qr(h.placeholder,!1),highlighted:!1,labelClass:rh(h.labelClass),labelDescription:h.labelDescription,customProperties:h.customProperties};return u},Kd=function(n){return n.tagName==="INPUT"},sh=function(n){return n.tagName==="SELECT"},qd=function(n){return n.tagName==="OPTION"},Zd=function(n){return n.tagName==="OPTGROUP"},Jd=function(n){eh(t,n);function t(e){var i=e.element,r=e.classNames,s=e.template,o=e.extractPlaceholder,a=n.call(this,{element:i,classNames:r})||this;return a.template=s,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,r=document.createDocumentFragment();e.forEach(function(s){var o=s;if(!o.element){var a=i.template(o);r.appendChild(a),o.element=a}}),this.element.appendChild(r)},t.prototype.optionsAsChoices=function(){var e=this,i=[];return this.element.querySelectorAll(":scope > option, :scope > optgroup").forEach(function(r){qd(r)?i.push(e._optionToChoice(r)):Zd(r)&&i.push(e._optgroupToChoice(r))}),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.innerText,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"?rh(e.dataset.labelClass):void 0,labelDescription:typeof e.dataset.labelDescription<"u"?e.dataset.labelDescription:void 0,customProperties:Vd(e.dataset.customProperties)}},t.prototype._optgroupToChoice=function(e){var i=this,r=e.querySelectorAll("option"),s=Array.from(r).map(function(o){return i._optionToChoice(o)});return{id:0,label:e.label||"",element:e,active:!!s.length,disabled:e.disabled,choices:s}},t}(ih),Qd={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"]},Dl={items:[],choices:[],silent:!1,renderChoiceLimit:-1,maxItemCount:-1,closeDropdownOnSelect:"auto",singleModeForMultiSelect:!1,addChoices:!1,addItems:!0,addItemFilter:function(n){return!!n&&n!==""},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:Bd,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(n){return'Press Enter to add <b>"'.concat(n,'"</b>')},removeItemIconText:function(){return"Remove item"},removeItemLabelText:function(n){return"Remove item: ".concat(n)},maxItemText:function(n){return"Only ".concat(n," values can be added")},valueComparer:function(n,t){return n===t},fuseOptions:{includeScore:!0},labelId:"",callbackOnInit:null,callbackOnCreateTemplates:null,classNames:Qd,appendGroupInSearch:!1},Ml=function(n){var t=n.itemEl;t&&(t.remove(),n.itemEl=void 0)};function tp(n,t,e){var i=n,r=!0;switch(t.type){case Tt.ADD_ITEM:{t.item.selected=!0;var s=t.item.element;s&&(s.selected=!0,s.setAttribute("selected","")),i.push(t.item);break}case Tt.REMOVE_ITEM:{t.item.selected=!1;var s=t.item.element;if(s){s.selected=!1,s.removeAttribute("selected");var o=s.parentElement;o&&sh(o)&&o.type===wi.SelectOne&&(o.value="")}Ml(t.item),i=i.filter(function(h){return h.id!==t.item.id});break}case Tt.REMOVE_CHOICE:{Ml(t.choice),i=i.filter(function(c){return c.id!==t.choice.id});break}case Tt.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&&Ud(l,a?e.classNames.highlightedState:e.classNames.selectedState,a?e.classNames.selectedState:e.classNames.highlightedState));break}default:{r=!1;break}}return{state:i,update:r}}function ep(n,t){var e=n,i=!0;switch(t.type){case Tt.ADD_GROUP:{e.push(t.group);break}case Tt.CLEAR_CHOICES:{e=[];break}default:{i=!1;break}}return{state:e,update:i}}function ip(n,t,e){var i=n,r=!0;switch(t.type){case Tt.ADD_CHOICE:{i.push(t.choice);break}case Tt.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 Tt.ADD_ITEM:case Tt.REMOVE_ITEM:{t.item.choiceEl=void 0;break}case Tt.FILTER_CHOICES:{var s=[];t.results.forEach(function(o){s[o.item.id]=o}),i.forEach(function(o){var a=s[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 Tt.ACTIVATE_CHOICES:{i.forEach(function(o){o.active=t.active,e&&e.appendGroupInSearch&&(o.choiceEl=void 0)});break}case Tt.CLEAR_CHOICES:{i=[];break}default:{r=!1;break}}return{state:i,update:r}}var Il={groups:ep,items:tp,choices:ip},rp=function(){function n(t){this._state=this.defaultState,this._listeners=[],this._txn=0,this._context=t}return Object.defineProperty(n.prototype,"defaultState",{get:function(){return{groups:[],items:[],choices:[]}},enumerable:!1,configurable:!0}),n.prototype.changeSet=function(t){return{groups:t,items:t,choices:t}},n.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)})},n.prototype.subscribe=function(t){return this._listeners.push(t),this},n.prototype.dispatch=function(t){var e=this,i=this._state,r=!1,s=this._changeSet||this.changeSet(!1);Object.keys(Il).forEach(function(o){var a=Il[o](i[o],t,e._context);a.update&&(r=!0,s[o]=!0,i[o]=a.state)}),r&&(this._txn?this._changeSet=s:this._listeners.forEach(function(o){return o(s)}))},n.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(n.prototype,"state",{get:function(){return this._state},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"items",{get:function(){return this.state.items},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"highlightedActiveItems",{get:function(){return this.items.filter(function(t){return!t.disabled&&t.active&&t.highlighted})},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"choices",{get:function(){return this.state.choices},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"activeChoices",{get:function(){return this.choices.filter(function(t){return t.active})},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"searchableChoices",{get:function(){return this.choices.filter(function(t){return!t.disabled&&!t.placeholder})},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"groups",{get:function(){return this.state.groups},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"activeGroups",{get:function(){var t=this;return this.state.groups.filter(function(e){var i=e.active&&!e.disabled,r=t.state.choices.some(function(s){return s.active&&!s.disabled});return i&&r},[])},enumerable:!1,configurable:!0}),n.prototype.inTxn=function(){return this._txn>0},n.prototype.getChoiceById=function(t){return this.activeChoices.find(function(e){return e.id===t})},n.prototype.getGroupById=function(t){return this.groups.find(function(e){return e.id===t})},n}(),Yt={noChoices:"no-choices",noResults:"no-results",addChoice:"add-choice",generic:""};function sp(n,t,e){return(t=op(t))in n?Object.defineProperty(n,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):n[t]=e,n}function Ll(n,t){var e=Object.keys(n);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(n);t&&(i=i.filter(function(r){return Object.getOwnPropertyDescriptor(n,r).enumerable})),e.push.apply(e,i)}return e}function mr(n){for(var t=1;t<arguments.length;t++){var e=arguments[t]!=null?arguments[t]:{};t%2?Ll(Object(e),!0).forEach(function(i){sp(n,i,e[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(e)):Ll(Object(e)).forEach(function(i){Object.defineProperty(n,i,Object.getOwnPropertyDescriptor(e,i))})}return n}function np(n,t){if(typeof n!="object"||!n)return n;var e=n[Symbol.toPrimitive];if(e!==void 0){var i=e.call(n,t);if(typeof i!="object")return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(n)}function op(n){var t=np(n,"string");return typeof t=="symbol"?t:t+""}function hi(n){return Array.isArray?Array.isArray(n):ah(n)==="[object Array]"}function ap(n){if(typeof n=="string")return n;let t=n+"";return t=="0"&&1/n==-1/0?"-0":t}function lp(n){return n==null?"":ap(n)}function Ne(n){return typeof n=="string"}function nh(n){return typeof n=="number"}function cp(n){return n===!0||n===!1||hp(n)&&ah(n)=="[object Boolean]"}function oh(n){return typeof n=="object"}function hp(n){return oh(n)&&n!==null}function me(n){return n!=null}function Ao(n){return!n.trim().length}function ah(n){return n==null?n===void 0?"[object Undefined]":"[object Null]":Object.prototype.toString.call(n)}const up="Incorrect 'index' type",dp=n=>`Invalid value for key ${n}`,pp=n=>`Pattern length exceeds max of ${n}.`,gp=n=>`Missing ${n} property in key`,fp=n=>`Property 'weight' in key '${n}' must be a positive integer`,Fl=Object.prototype.hasOwnProperty;class mp{constructor(t){this._keys=[],this._keyMap={};let e=0;t.forEach(i=>{let r=lh(i);this._keys.push(r),this._keyMap[r.id]=r,e+=r.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 lh(n){let t=null,e=null,i=null,r=1,s=null;if(Ne(n)||hi(n))i=n,t=jl(n),e=Jo(n);else{if(!Fl.call(n,"name"))throw new Error(gp("name"));const o=n.name;if(i=o,Fl.call(n,"weight")&&(r=n.weight,r<=0))throw new Error(fp(o));t=jl(o),e=Jo(o),s=n.getFn}return{path:t,id:e,weight:r,src:i,getFn:s}}function jl(n){return hi(n)?n:n.split(".")}function Jo(n){return hi(n)?n.join("."):n}function vp(n,t){let e=[],i=!1;const r=(s,o,a)=>{if(me(s))if(!o[a])e.push(s);else{let l=o[a];const c=s[l];if(!me(c))return;if(a===o.length-1&&(Ne(c)||nh(c)||cp(c)))e.push(lp(c));else if(hi(c)){i=!0;for(let h=0,u=c.length;h<u;h+=1)r(c[h],o,a+1)}else o.length&&r(c,o,a+1)}};return r(n,Ne(t)?t.split("."):t,0),i?e:e[0]}const bp={includeMatches:!1,findAllMatches:!1,minMatchCharLength:1},_p={isCaseSensitive:!1,includeScore:!1,keys:[],shouldSort:!0,sortFn:(n,t)=>n.score===t.score?n.idx<t.idx?-1:1:n.score<t.score?-1:1},yp={location:0,threshold:.6,distance:100},xp={useExtendedSearch:!1,getFn:vp,ignoreLocation:!1,ignoreFieldNorm:!1,fieldNormWeight:1};var U=mr(mr(mr(mr({},_p),bp),yp),xp);const wp=/[^ ]+/g;function Cp(n=1,t=3){const e=new Map,i=Math.pow(10,t);return{get(r){const s=r.match(wp).length;if(e.has(s))return e.get(s);const o=1/Math.pow(s,.5*n),a=parseFloat(Math.round(o*i)/i);return e.set(s,a),a},clear(){e.clear()}}}class Pa{constructor({getFn:t=U.getFn,fieldNormWeight:e=U.fieldNormWeight}={}){this.norm=Cp(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,Ne(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();Ne(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(!me(t)||Ao(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((r,s)=>{let o=r.getFn?r.getFn(t):this.getFn(t,r.path);if(me(o)){if(hi(o)){let a=[];const l=[{nestedArrIndex:-1,value:o}];for(;l.length;){const{nestedArrIndex:c,value:h}=l.pop();if(me(h))if(Ne(h)&&!Ao(h)){let u={v:h,i:c,n:this.norm.get(h)};a.push(u)}else hi(h)&&h.forEach((u,d)=>{l.push({nestedArrIndex:d,value:u})})}i.$[s]=a}else if(Ne(o)&&!Ao(o)){let a={v:o,n:this.norm.get(o)};i.$[s]=a}}}),this.records.push(i)}toJSON(){return{keys:this.keys,records:this.records}}}function ch(n,t,{getFn:e=U.getFn,fieldNormWeight:i=U.fieldNormWeight}={}){const r=new Pa({getFn:e,fieldNormWeight:i});return r.setKeys(n.map(lh)),r.setSources(t),r.create(),r}function Sp(n,{getFn:t=U.getFn,fieldNormWeight:e=U.fieldNormWeight}={}){const{keys:i,records:r}=n,s=new Pa({getFn:t,fieldNormWeight:e});return s.setKeys(i),s.setIndexRecords(r),s}function Us(n,{errors:t=0,currentLocation:e=0,expectedLocation:i=0,distance:r=U.distance,ignoreLocation:s=U.ignoreLocation}={}){const o=t/n.length;if(s)return o;const a=Math.abs(i-e);return r?o+a/r:a?1:o}function Tp(n=[],t=U.minMatchCharLength){let e=[],i=-1,r=-1,s=0;for(let o=n.length;s<o;s+=1){let a=n[s];a&&i===-1?i=s:!a&&i!==-1&&(r=s-1,r-i+1>=t&&e.push([i,r]),i=-1)}return n[s-1]&&s-i>=t&&e.push([i,s-1]),e}const Vi=32;function Ep(n,t,e,{location:i=U.location,distance:r=U.distance,threshold:s=U.threshold,findAllMatches:o=U.findAllMatches,minMatchCharLength:a=U.minMatchCharLength,includeMatches:l=U.includeMatches,ignoreLocation:c=U.ignoreLocation}={}){if(t.length>Vi)throw new Error(pp(Vi));const h=t.length,u=n.length,d=Math.max(0,Math.min(i,u));let p=s,g=d;const f=a>1||l,m=f?Array(u):[];let v;for(;(v=n.indexOf(t,g))>-1;){let C=Us(t,{currentLocation:v,expectedLocation:d,distance:r,ignoreLocation:c});if(p=Math.min(C,p),g=v+h,f){let T=0;for(;T<h;)m[v+T]=1,T+=1}}g=-1;let y=[],x=1,E=h+u;const O=1<<h-1;for(let C=0;C<h;C+=1){let T=0,F=E;for(;T<F;)Us(t,{errors:C,currentLocation:d+F,expectedLocation:d,distance:r,ignoreLocation:c})<=p?T=F:E=F,F=Math.floor((E-T)/2+T);E=F;let j=Math.max(1,d-F+1),A=o?u:Math.min(d+F,u)+h,k=Array(A+2);k[A+1]=(1<<C)-1;for(let L=A;L>=j;L-=1){let z=L-1,X=e[n.charAt(z)];if(f&&(m[z]=+!!X),k[L]=(k[L+1]<<1|1)&X,C&&(k[L]|=(y[L+1]|y[L])<<1|1|y[L+1]),k[L]&O&&(x=Us(t,{errors:C,currentLocation:z,expectedLocation:d,distance:r,ignoreLocation:c}),x<=p)){if(p=x,g=z,g<=d)break;j=Math.max(1,2*d-g)}}if(Us(t,{errors:C+1,currentLocation:d,expectedLocation:d,distance:r,ignoreLocation:c})>p)break;y=k}const D={isMatch:g>=0,score:Math.max(.001,x)};if(f){const C=Tp(m,a);C.length?l&&(D.indices=C):D.isMatch=!1}return D}function Op(n){let t={};for(let e=0,i=n.length;e<i;e+=1){const r=n.charAt(e);t[r]=(t[r]||0)|1<<i-e-1}return t}class hh{constructor(t,{location:e=U.location,threshold:i=U.threshold,distance:r=U.distance,includeMatches:s=U.includeMatches,findAllMatches:o=U.findAllMatches,minMatchCharLength:a=U.minMatchCharLength,isCaseSensitive:l=U.isCaseSensitive,ignoreLocation:c=U.ignoreLocation}={}){if(this.options={location:e,threshold:i,distance:r,includeMatches:s,findAllMatches:o,minMatchCharLength:a,isCaseSensitive:l,ignoreLocation:c},this.pattern=l?t:t.toLowerCase(),this.chunks=[],!this.pattern.length)return;const h=(d,p)=>{this.chunks.push({pattern:d,alphabet:Op(d),startIndex:p})},u=this.pattern.length;if(u>Vi){let d=0;const p=u%Vi,g=u-p;for(;d<g;)h(this.pattern.substr(d,Vi),d),d+=Vi;if(p){const f=u-Vi;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:r,distance:s,threshold:o,findAllMatches:a,minMatchCharLength:l,ignoreLocation:c}=this.options;let h=[],u=0,d=!1;this.chunks.forEach(({pattern:g,alphabet:f,startIndex:m})=>{const{isMatch:v,score:y,indices:x}=Ep(t,g,f,{location:r+m,distance:s,threshold:o,findAllMatches:a,minMatchCharLength:l,includeMatches:i,ignoreLocation:c});v&&(d=!0),u+=y,v&&x&&(h=[...h,...x])});let p={isMatch:d,score:d?u/this.chunks.length:1};return d&&i&&(p.indices=h),p}}class Fi{constructor(t){this.pattern=t}static isMultiMatch(t){return Rl(t,this.multiRegex)}static isSingleMatch(t){return Rl(t,this.singleRegex)}search(){}}function Rl(n,t){const e=n.match(t);return e?e[1]:null}class kp extends Fi{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 Ap extends Fi{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 Pp extends Fi{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 Dp extends Fi{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 Mp extends Fi{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 Ip extends Fi{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 uh extends Fi{constructor(t,{location:e=U.location,threshold:i=U.threshold,distance:r=U.distance,includeMatches:s=U.includeMatches,findAllMatches:o=U.findAllMatches,minMatchCharLength:a=U.minMatchCharLength,isCaseSensitive:l=U.isCaseSensitive,ignoreLocation:c=U.ignoreLocation}={}){super(t),this._bitapSearch=new hh(t,{location:e,threshold:i,distance:r,includeMatches:s,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 dh extends Fi{constructor(t){super(t)}static get type(){return"include"}static get multiRegex(){return/^'"(.*)"$/}static get singleRegex(){return/^'(.*)$/}search(t){let e=0,i;const r=[],s=this.pattern.length;for(;(i=t.indexOf(this.pattern,e))>-1;)e=i+s,r.push([i,e-1]);const o=!!r.length;return{isMatch:o,score:o?0:1,indices:r}}}const Qo=[kp,dh,Pp,Dp,Ip,Mp,Ap,uh],$l=Qo.length,Lp=/ +(?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)/,Fp="|";function jp(n,t={}){return n.split(Fp).map(e=>{let i=e.trim().split(Lp).filter(s=>s&&!!s.trim()),r=[];for(let s=0,o=i.length;s<o;s+=1){const a=i[s];let l=!1,c=-1;for(;!l&&++c<$l;){const h=Qo[c];let u=h.isMultiMatch(a);u&&(r.push(new h(u,t)),l=!0)}if(!l)for(c=-1;++c<$l;){const h=Qo[c];let u=h.isSingleMatch(a);if(u){r.push(new h(u,t));break}}}return r})}const Rp=new Set([uh.type,dh.type]);class $p{constructor(t,{isCaseSensitive:e=U.isCaseSensitive,includeMatches:i=U.includeMatches,minMatchCharLength:r=U.minMatchCharLength,ignoreLocation:s=U.ignoreLocation,findAllMatches:o=U.findAllMatches,location:a=U.location,threshold:l=U.threshold,distance:c=U.distance}={}){this.query=null,this.options={isCaseSensitive:e,includeMatches:i,minMatchCharLength:r,findAllMatches:o,ignoreLocation:s,location:a,threshold:l,distance:c},this.pattern=e?t:t.toLowerCase(),this.query=jp(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:r}=this.options;t=r?t:t.toLowerCase();let s=0,o=[],a=0;for(let l=0,c=e.length;l<c;l+=1){const h=e[l];o.length=0,s=0;for(let u=0,d=h.length;u<d;u+=1){const p=h[u],{isMatch:g,indices:f,score:m}=p.search(t);if(g){if(s+=1,a+=m,i){const v=p.constructor.type;Rp.has(v)?o=[...o,...f]:o.push(f)}}else{a=0,s=0,o.length=0;break}}if(s){let u={isMatch:!0,score:a/s};return i&&(u.indices=o),u}}return{isMatch:!1,score:1}}}const ta=[];function Bp(...n){ta.push(...n)}function ea(n,t){for(let e=0,i=ta.length;e<i;e+=1){let r=ta[e];if(r.condition(n,t))return new r(n,t)}return new hh(n,t)}const Mn={AND:"$and",OR:"$or"},ia={PATH:"$path",PATTERN:"$val"},ra=n=>!!(n[Mn.AND]||n[Mn.OR]),Np=n=>!!n[ia.PATH],zp=n=>!hi(n)&&oh(n)&&!ra(n),Bl=n=>({[Mn.AND]:Object.keys(n).map(t=>({[t]:n[t]}))});function ph(n,t,{auto:e=!0}={}){const i=r=>{let s=Object.keys(r);const o=Np(r);if(!o&&s.length>1&&!ra(r))return i(Bl(r));if(zp(r)){const l=o?r[ia.PATH]:s[0],c=o?r[ia.PATTERN]:r[l];if(!Ne(c))throw new Error(dp(l));const h={keyId:Jo(l),pattern:c};return e&&(h.searcher=ea(c,t)),h}let a={children:[],operator:s[0]};return s.forEach(l=>{const c=r[l];hi(c)&&c.forEach(h=>{a.children.push(i(h))})}),a};return ra(n)||(n=Bl(n)),i(n)}function Hp(n,{ignoreFieldNorm:t=U.ignoreFieldNorm}){n.forEach(e=>{let i=1;e.matches.forEach(({key:r,norm:s,score:o})=>{const a=r?r.weight:null;i*=Math.pow(o===0&&a?Number.EPSILON:o,(a||1)*(t?1:s))}),e.score=i})}function Vp(n,t){const e=n.matches;t.matches=[],me(e)&&e.forEach(i=>{if(!me(i.indices)||!i.indices.length)return;const{indices:r,value:s}=i;let o={indices:r,value:s};i.key&&(o.key=i.key.src),i.idx>-1&&(o.refIndex=i.idx),t.matches.push(o)})}function Up(n,t){t.score=n.score}function Wp(n,t,{includeMatches:e=U.includeMatches,includeScore:i=U.includeScore}={}){const r=[];return e&&r.push(Vp),i&&r.push(Up),n.map(s=>{const{idx:o}=s,a={item:t[o],refIndex:o};return r.length&&r.forEach(l=>{l(s,a)}),a})}class Mr{constructor(t,e={},i){this.options=mr(mr({},U),e),this.options.useExtendedSearch,this._keyStore=new mp(this.options.keys),this.setCollection(t,i)}setCollection(t,e){if(this._docs=t,e&&!(e instanceof Pa))throw new Error(up);this._myIndex=e||ch(this.options.keys,this._docs,{getFn:this.options.getFn,fieldNormWeight:this.options.fieldNormWeight})}add(t){me(t)&&(this._docs.push(t),this._myIndex.add(t))}remove(t=()=>!1){const e=[];for(let i=0,r=this._docs.length;i<r;i+=1){const s=this._docs[i];t(s,i)&&(this.removeAt(i),i-=1,r-=1,e.push(s))}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:r,shouldSort:s,sortFn:o,ignoreFieldNorm:a}=this.options;let l=Ne(t)?Ne(this._docs[0])?this._searchStringList(t):this._searchObjectList(t):this._searchLogical(t);return Hp(l,{ignoreFieldNorm:a}),s&&l.sort(o),nh(e)&&e>-1&&(l=l.slice(0,e)),Wp(l,this._docs,{includeMatches:i,includeScore:r})}_searchStringList(t){const e=ea(t,this.options),{records:i}=this._myIndex,r=[];return i.forEach(({v:s,i:o,n:a})=>{if(!me(s))return;const{isMatch:l,score:c,indices:h}=e.searchIn(s);l&&r.push({item:s,idx:o,matches:[{score:c,value:s,norm:a,indices:h}]})}),r}_searchLogical(t){const e=ph(t,this.options),i=(a,l,c)=>{if(!a.children){const{keyId:u,searcher:d}=a,p=this._findMatches({key:this._keyStore.get(u),value:this._myIndex.getValueForItemAtKeyId(l,u),searcher:d});return p&&p.length?[{idx:c,item:l,matches:p}]:[]}const h=[];for(let u=0,d=a.children.length;u<d;u+=1){const p=a.children[u],g=i(p,l,c);if(g.length)h.push(...g);else if(a.operator===Mn.AND)return[]}return h},r=this._myIndex.records,s={},o=[];return r.forEach(({$:a,i:l})=>{if(me(a)){let c=i(e,a,l);c.length&&(s[l]||(s[l]={idx:l,item:a,matches:[]},o.push(s[l])),c.forEach(({matches:h})=>{s[l].matches.push(...h)}))}}),o}_searchObjectList(t){const e=ea(t,this.options),{keys:i,records:r}=this._myIndex,s=[];return r.forEach(({$:o,i:a})=>{if(!me(o))return;let l=[];i.forEach((c,h)=>{l.push(...this._findMatches({key:c,value:o[h],searcher:e}))}),l.length&&s.push({idx:a,item:o,matches:l})}),s}_findMatches({key:t,value:e,searcher:i}){if(!me(e))return[];let r=[];if(hi(e))e.forEach(({v:s,i:o,n:a})=>{if(!me(s))return;const{isMatch:l,score:c,indices:h}=i.searchIn(s);l&&r.push({score:c,key:t,value:s,idx:o,norm:a,indices:h})});else{const{v:s,n:o}=e,{isMatch:a,score:l,indices:c}=i.searchIn(s);a&&r.push({score:l,key:t,value:s,norm:o,indices:c})}return r}}Mr.version="7.0.0";Mr.createIndex=ch;Mr.parseIndex=Sp;Mr.config=U;Mr.parseQuery=ph;Bp($p);var Gp=function(){function n(t){this._haystack=[],this._fuseOptions=ne(ne({},t.fuseOptions),{keys:Ed([],t.searchFields),includeMatches:!0})}return n.prototype.index=function(t){this._haystack=t,this._fuse&&this._fuse.setCollection(t)},n.prototype.reset=function(){this._haystack=[],this._fuse=void 0},n.prototype.isEmptyIndex=function(){return!this._haystack.length},n.prototype.search=function(t){this._fuse||(this._fuse=new Mr(this._haystack,this._fuseOptions));var e=this._fuse.search(t);return e.map(function(i,r){return{item:i.item,score:i.score||0,rank:r+1}})},n}();function Yp(n){return new Gp(n)}var Xp=function(n){for(var t in n)if(Object.prototype.hasOwnProperty.call(n,t))return!1;return!0},Po=function(n,t,e){var i=n.dataset,r=t.customProperties,s=t.labelClass,o=t.labelDescription;s&&(i.labelClass=to(s).join(" ")),o&&(i.labelDescription=o),e&&r&&(typeof r=="string"?i.customProperties=r:typeof r=="object"&&!Xp(r)&&(i.customProperties=JSON.stringify(r)))},Nl=function(n,t,e){var i=t&&n.querySelector("label[for='".concat(t,"']")),r=i&&i.innerText;r&&e.setAttribute("aria-label",r)},Kp={containerOuter:function(n,t,e,i,r,s,o){var a=n.classNames.containerOuter,l=document.createElement("div");return G(l,a),l.dataset.type=s,t&&(l.dir=t),i&&(l.tabIndex=0),e&&(l.setAttribute("role",r?"combobox":"listbox"),r?l.setAttribute("aria-autocomplete","list"):o||Nl(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(n){var t=n.classNames.containerInner,e=document.createElement("div");return G(e,t),e},itemList:function(n,t){var e=n.searchEnabled,i=n.classNames,r=i.list,s=i.listSingle,o=i.listItems,a=document.createElement("div");return G(a,r),G(a,t?s:o),this._isSelectElement&&e&&a.setAttribute("role","listbox"),a},placeholder:function(n,t){var e=n.allowHTML,i=n.classNames.placeholder,r=document.createElement("div");return G(r,i),Je(r,e,t),r},item:function(n,t,e){var i=n.allowHTML,r=n.removeItemButtonAlignLeft,s=n.removeItemIconText,o=n.removeItemLabelText,a=n.classNames,l=a.item,c=a.button,h=a.highlightedState,u=a.itemSelectable,d=a.placeholder,p=Xi(t.value),g=document.createElement("div");if(G(g,l),t.labelClass){var f=document.createElement("span");Je(f,i,t.label),G(f,t.labelClass),g.appendChild(f)}else Je(g,i,t.label);if(g.dataset.item="",g.dataset.id=t.id,g.dataset.value=p,Po(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&&(G(g,d),g.dataset.placeholder=""),G(g,t.highlighted?h:u),e){t.disabled&&$e(g,u),g.dataset.deletable="";var m=document.createElement("button");m.type="button",G(m,c),Je(m,!0,rs(s,t.value));var v=rs(o,t.value);v&&m.setAttribute("aria-label",v),m.dataset.button="",r?g.insertAdjacentElement("afterbegin",m):g.appendChild(m)}return g},choiceList:function(n,t){var e=n.classNames.list,i=document.createElement("div");return G(i,e),t||i.setAttribute("aria-multiselectable","true"),i.setAttribute("role","listbox"),i},choiceGroup:function(n,t){var e=n.allowHTML,i=n.classNames,r=i.group,s=i.groupHeading,o=i.itemDisabled,a=t.id,l=t.label,c=t.disabled,h=Xi(l),u=document.createElement("div");G(u,r),c&&G(u,o),u.setAttribute("role","group"),u.dataset.group="",u.dataset.id=a,u.dataset.value=h,c&&u.setAttribute("aria-disabled","true");var d=document.createElement("div");return G(d,s),Je(d,e,l||""),u.appendChild(d),u},choice:function(n,t,e,i){var r=n.allowHTML,s=n.classNames,o=s.item,a=s.itemChoice,l=s.itemSelectable,c=s.selectedState,h=s.itemDisabled,u=s.description,d=s.placeholder,p=t.label,g=Xi(t.value),f=document.createElement("div");f.id=t.elementId,G(f,o),G(f,a),i&&typeof p=="string"&&(p=Aa(r,p),p+=" (".concat(i,")"),p={trusted:p});var m=f;if(t.labelClass){var v=document.createElement("span");Je(v,r,p),G(v,t.labelClass),m=v,f.appendChild(v)}else Je(f,r,p);if(t.labelDescription){var y="".concat(t.elementId,"-description");m.setAttribute("aria-describedby",y);var x=document.createElement("span");Je(x,r,t.labelDescription),x.id=y,G(x,u),f.appendChild(x)}return t.selected&&G(f,c),t.placeholder&&G(f,d),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)),Po(f,t,!1),t.disabled?(G(f,h),f.dataset.choiceDisabled="",f.setAttribute("aria-disabled","true")):(G(f,l),f.dataset.choiceSelectable=""),f},input:function(n,t){var e=n.classNames,i=e.input,r=e.inputCloned,s=n.labelId,o=document.createElement("input");return o.type="search",G(o,i),G(o,r),o.autocomplete="off",o.autocapitalize="off",o.spellcheck=!1,o.setAttribute("role","textbox"),o.setAttribute("aria-autocomplete","list"),t?o.setAttribute("aria-label",t):s||Nl(this._docRoot,this.passedElement.element.id,o),o},dropdown:function(n){var t=n.classNames,e=t.list,i=t.listDropdown,r=document.createElement("div");return G(r,e),G(r,i),r.setAttribute("aria-expanded","false"),r},notice:function(n,t,e){var i=n.classNames,r=i.item,s=i.itemChoice,o=i.addChoice,a=i.noResults,l=i.noChoices,c=i.notice;e===void 0&&(e=Yt.generic);var h=document.createElement("div");switch(Je(h,!0,t),G(h,r),G(h,s),G(h,c),e){case Yt.addChoice:G(h,o);break;case Yt.noResults:G(h,a);break;case Yt.noChoices:G(h,l);break}return e===Yt.addChoice&&(h.dataset.choiceSelectable="",h.dataset.choice=""),h},option:function(n){var t=Xi(n.label),e=new Option(t,n.value,!1,n.selected);return Po(e,n,!0),e.disabled=n.disabled,n.selected&&e.setAttribute("selected",""),e}},qp="-ms-scroll-limit"in document.documentElement.style&&"-ms-ime-align"in document.documentElement.style,Zp={},Do=function(n){if(n)return n.dataset.id?parseInt(n.dataset.id,10):void 0},Gr="[data-choice-selectable]",gh=function(){function n(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 r=n.defaults;this.config=ne(ne(ne({},r.allOptions),r.options),e),Od.forEach(function(v){i.config[v]=ne(ne(ne({},r.allOptions[v]),r.options[v]),e[v])});var s=this.config;s.silent||this._validateConfig();var o=s.shadowRoot||document.documentElement;this._docRoot=o;var a=typeof t=="string"?o.querySelector(t):t;if(!a||typeof a!="object"||!(Kd(a)||sh(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===wi.Text;(c||s.maxItemCount!==1)&&(s.singleModeForMultiSelect=!1),s.singleModeForMultiSelect&&(l=wi.SelectMultiple);var h=l===wi.SelectOne,u=l===wi.SelectMultiple,d=h||u;if(this._elementType=l,this._isTextElement=c,this._isSelectOneElement=h,this._isSelectMultipleElement=u,this._isSelectElement=h||u,this._canAddUserChoices=c&&s.addItems||d&&s.addChoices,typeof s.renderSelectedChoices!="boolean"&&(s.renderSelectedChoices=s.renderSelectedChoices==="always"||h),s.closeDropdownOnSelect==="auto"?s.closeDropdownOnSelect=c||h||s.singleModeForMultiSelect:s.closeDropdownOnSelect=Qr(s.closeDropdownOnSelect),s.placeholder&&(s.placeholderValue?this._hasNonChoicePlaceholder=!0:a.dataset.placeholder&&(this._hasNonChoicePlaceholder=!0,s.placeholderValue=a.dataset.placeholder)),e.addItemFilter&&typeof e.addItemFilter!="function"){var p=e.addItemFilter instanceof RegExp?e.addItemFilter:new RegExp(e.addItemFilter);s.addItemFilter=p.test.bind(p)}if(this._isTextElement)this.passedElement=new Xd({element:a,classNames:s.classNames});else{var g=a;this.passedElement=new Jd({element:g,classNames:s.classNames,template:function(v){return i._templates.option(v)},extractPlaceholder:s.placeholder&&!this._hasNonChoicePlaceholder})}if(this.initialised=!1,this._store=new rp(s),this._currentValue="",s.searchEnabled=!c&&s.searchEnabled||u,this._canSearch=s.searchEnabled,this._isScrollingOnIe=!1,this._highlightPosition=0,this._wasTap=!0,this._placeholderValue=this._generatePlaceholderValue(),this._baseId=Ld(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=r.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){s.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(v){return v.value})}return Object.defineProperty(n,"defaults",{get:function(){return Object.preventExtensions({get options(){return Zp},get allOptions(){return Dl},get templates(){return Kp}})},enumerable:!1,configurable:!0}),n.prototype.init=function(){if(!(this.initialised||this.initialisedOK!==void 0)){this._searcher=Yp(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)}},n.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=n.defaults.templates,this.initialised=!1,this.initialisedOK=void 0)},n.prototype.enable=function(){return this.passedElement.isDisabled&&this.passedElement.enable(),this.containerOuter.isDisabled&&(this._addEventListeners(),this.input.enable(),this.containerOuter.enable()),this},n.prototype.disable=function(){return this.passedElement.isDisabled||this.passedElement.disable(),this.containerOuter.isDisabled||(this._removeEventListeners(),this.input.disable(),this.containerOuter.disable()),this},n.prototype.highlightItem=function(t,e){if(e===void 0&&(e=!0),!t||!t.id)return this;var i=this._store.items.find(function(r){return r.id===t.id});return!i||i.highlighted?this:(this._store.dispatch(Vs(i,!0)),e&&this.passedElement.triggerEvent(se.highlightItem,this._getChoiceForOutput(i)),this)},n.prototype.unhighlightItem=function(t,e){if(e===void 0&&(e=!0),!t||!t.id)return this;var i=this._store.items.find(function(r){return r.id===t.id});return!i||!i.highlighted?this:(this._store.dispatch(Vs(i,!1)),e&&this.passedElement.triggerEvent(se.unhighlightItem,this._getChoiceForOutput(i)),this)},n.prototype.highlightAll=function(){var t=this;return this._store.withTxn(function(){t._store.items.forEach(function(e){e.highlighted||(t._store.dispatch(Vs(e,!0)),t.passedElement.triggerEvent(se.highlightItem,t._getChoiceForOutput(e)))})}),this},n.prototype.unhighlightAll=function(){var t=this;return this._store.withTxn(function(){t._store.items.forEach(function(e){e.highlighted&&(t._store.dispatch(Vs(e,!1)),t.passedElement.triggerEvent(se.highlightItem,t._getChoiceForOutput(e)))})}),this},n.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},n.prototype.removeActiveItems=function(t){var e=this;return this._store.withTxn(function(){e._store.items.filter(function(i){var r=i.id;return r!==t}).forEach(function(i){return e._removeItem(i)})}),this},n.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},n.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(se.showDropdown)}),this)},n.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(se.hideDropdown)}),this):this},n.prototype.getValue=function(t){var e=this,i=this._store.items.map(function(r){return t?r.value:e._getChoiceForOutput(r)});return this._isSelectOneElement||this.config.singleModeForMultiSelect?i[0]:i},n.prototype.setValue=function(t){var e=this;return this.initialisedOK?(this._store.withTxn(function(){t.forEach(function(i){i&&e._addChoice(Re(i,!1))})}),this._searcher.reset(),this):(this._warnChoicesInitFailed("setValue"),this)},n.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(r){return e._findAndSelectChoiceByValue(r)}),e.unhighlightAll()}),this._searcher.reset(),this):(this._warnChoicesInitFailed("setChoiceByValue"),this)},n.prototype.setChoices=function(t,e,i,r,s){var o=this;if(t===void 0&&(t=[]),e===void 0&&(e="value"),i===void 0&&(i="label"),r===void 0&&(r=!1),s===void 0&&(s=!0),!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(r&&this.clearChoices(),typeof t=="function"){var a=t(this);if(typeof Promise=="function"&&a instanceof Promise)return new Promise(function(l){return requestAnimationFrame(l)}).then(function(){return o._handleLoadingState(!0)}).then(function(){return a}).then(function(l){return o.setChoices(l,e,i,r)}).catch(function(l){o.config.silent||console.error(l)}).then(function(){return o._handleLoadingState(!1)}).then(function(){return o});if(!Array.isArray(a))throw new TypeError(".setChoices first argument function must return either array of choices or Promise, got: ".concat(typeof a));return this.setChoices(a,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(){s&&(o._isSearching=!1);var l=e==="value",c=i==="label";t.forEach(function(h){if("choices"in h){var u=h;c||(u=ne(ne({},u),{label:u[i]})),o._addGroup(Re(u,!0))}else{var d=h;(!c||!l)&&(d=ne(ne({},d),{value:d[e],label:d[i]})),o._addChoice(Re(d,!1))}}),o.unhighlightAll()}),this._searcher.reset(),this},n.prototype.refresh=function(t,e,i){var r=this;return t===void 0&&(t=!1),e===void 0&&(e=!1),i===void 0&&(i=!1),this._isSelectElement?(this._store.withTxn(function(){var s=r.passedElement.optionsAsChoices(),o={};i||r._store.items.forEach(function(l){l.id&&l.active&&l.selected&&!l.disabled&&(o[l.value]=!0)}),r.clearStore(!1);var a=function(l){i?r._store.dispatch(El(l)):o[l.value]&&(l.selected=!0)};s.forEach(function(l){if("choices"in l){l.choices.forEach(a);return}a(l)}),r._addPredefinedChoices(s,e,t),r._isSearching&&r._searchChoices(r.input.value)}),this):(this.config.silent||console.warn("refresh method can only be used on choices backed by a <select> element"),this)},n.prototype.removeChoice=function(t){var e=this._store.choices.find(function(i){return i.value===t});return e?(this._clearNotice(),this._store.dispatch(Tl(e)),this._searcher.reset(),e.selected&&this.passedElement.triggerEvent(se.removeItem,this._getChoiceForOutput(e)),this):this},n.prototype.clearChoices=function(){var t=this;return this._store.withTxn(function(){t._store.choices.forEach(function(e){e.selected||t._store.dispatch(Tl(e))})}),this._searcher.reset(),this},n.prototype.clearStore=function(t){return t===void 0&&(t=!0),this._stopSearch(),t&&this.passedElement.element.replaceChildren(""),this.itemList.element.replaceChildren(""),this.choiceList.element.replaceChildren(""),this._clearNotice(),this._store.reset(),this._lastAddedChoiceId=0,this._lastAddedGroupId=0,this._searcher.reset(),this},n.prototype.clearInput=function(){var t=!this._isSelectOneElement;return this.input.clear(t),this._stopSearch(),this},n.prototype._validateConfig=function(){var t=this.config,e=Hd(t,Dl);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"))},n.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())},n.prototype._renderChoices=function(){var t=this;if(this._canAddItems()){var e=this,i=e.config,r=e._isSearching,s=this._store,o=s.activeGroups,a=s.activeChoices,l=0;if(r&&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(),u=function(g){return g.filter(function(f){return!f.placeholder&&(r?!!f.rank:i.renderSelectedChoices||!f.selected)})},d=!1,p=function(g,f,m){r?g.sort(Nd):i.shouldSort&&g.sort(i.sorter);var v=g.length;v=!f&&l&&v>l?l:v,v--,g.every(function(y,x){var E=y.choiceEl||t._templates.choice(i,y,i.itemSelectText,m);return y.choiceEl=E,h.appendChild(E),!y.disabled&&(r||!y.selected)&&(d=!0),x<v})};a.length&&(i.resetScrollPosition&&requestAnimationFrame(function(){return t.choiceList.scrollToTop()}),!this._hasNonChoicePlaceholder&&!r&&this._isSelectOneElement&&p(a.filter(function(g){return g.placeholder&&!g.group}),!1,void 0),o.length&&!r?(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=u(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&&r?g.label:void 0)}})):p(u(a),!1,void 0)),d||(this._notice||(this._notice={text:kl(r?i.noResultsText:i.noChoicesText),type:r?Yt.noResults:Yt.noChoices}),h.replaceChildren("")),this._renderNotice(h),this.choiceList.element.replaceChildren(h),d&&this._highlightChoice()}},n.prototype._renderItems=function(){var t=this,e=this._store.items||[],i=this.itemList.element,r=this.config,s=document.createDocumentFragment(),o=function(u){return i.querySelector('[data-item][data-id="'.concat(u.id,'"]'))},a=function(u){var d=u.itemEl;d&&d.parentElement||(d=o(u)||t._templates.item(r,u,r.removeItemButton),u.itemEl=d,s.appendChild(d))};e.forEach(a);var l=!!s.childNodes.length;if(this._isSelectOneElement&&this._hasNonChoicePlaceholder){var c=i.children.length;if(l||c>1){var h=i.querySelector(Wr(r.classNames.placeholder));h&&h.remove()}else c||(l=!0,a(Re({selected:!0,value:"",label:r.placeholderValue||"",placeholder:!0},!1)))}l&&(i.append(s),r.shouldSortItems&&!this._isSelectOneElement&&(e.sort(r.sorter),e.forEach(function(u){var d=o(u);d&&(d.remove(),s.append(d))}),i.append(s))),this._isTextElement&&(this.passedElement.value=e.map(function(u){var d=u.value;return d}).join(r.delimiter))},n.prototype._displayNotice=function(t,e,i){i===void 0&&(i=!0);var r=this._notice;if(r&&(r.type===e&&r.text===t||r.type===Yt.addChoice&&(e===Yt.noResults||e===Yt.noChoices))){i&&this.showDropdown(!0);return}this._clearNotice(),this._notice=t?{text:t,type:e}:void 0,this._renderNotice(),i&&t&&this.showDropdown(!0)},n.prototype._clearNotice=function(){if(this._notice){var t=this.choiceList.element.querySelector(Wr(this.config.classNames.notice));t&&t.remove(),this._notice=void 0}},n.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)}},n.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}},n.prototype._triggerChange=function(t){t!=null&&this.passedElement.triggerEvent(se.change,{value:t})},n.prototype._handleButtonAction=function(t){var e=this,i=this._store.items;if(!(!i.length||!this.config.removeItems||!this.config.removeItemButton)){var r=t&&Do(t.parentElement),s=r&&i.find(function(o){return o.id===r});s&&this._store.withTxn(function(){if(e._removeItem(s),e._triggerChange(s.value),e._isSelectOneElement&&!e._hasNonChoicePlaceholder){var o=e._store.choices.reverse().find(function(a){return!a.disabled&&a.placeholder});o&&(e._addItem(o),e.unhighlightAll(),o.value&&e._triggerChange(o.value))}})}},n.prototype._handleItemAction=function(t,e){var i=this;e===void 0&&(e=!1);var r=this._store.items;if(!(!r.length||!this.config.removeItems||this._isSelectOneElement)){var s=Do(t);s&&(r.forEach(function(o){o.id===s&&!o.highlighted?i.highlightItem(o):!e&&o.highlighted&&i.unhighlightItem(o)}),this.input.focus())}},n.prototype._handleChoiceAction=function(t){var e=this,i=Do(t),r=i&&this._store.getChoiceById(i);if(!r||r.disabled)return!1;var s=this.dropdown.isActive;if(!r.selected){if(!this._canAddItems())return!0;this._store.withTxn(function(){e._addItem(r,!0,!0),e.clearInput(),e.unhighlightAll()}),this._triggerChange(r.value)}return s&&this.config.closeDropdownOnSelect&&(this.hideDropdown(!0),this.containerOuter.element.focus()),!0},n.prototype._handleBackspace=function(t){var e=this.config;if(!(!e.removeItems||!t.length)){var i=t[t.length-1],r=t.some(function(s){return s.highlighted});e.editItems&&!r&&i?(this.input.value=i.value,this.input.setWidth(),this._removeItem(i),this._triggerChange(i.value)):(r||this.highlightItem(i,!1),this.removeHighlightedItems(!0))}},n.prototype._loadChoices=function(){var t,e=this,i=this.config;if(this._isTextElement){if(this._presetChoices=i.items.map(function(o){return Re(o,!1)}),this.passedElement.value){var r=this.passedElement.value.split(i.delimiter).map(function(o){return Re(o,!1,e.config.allowHtmlUserInput)});this._presetChoices=this._presetChoices.concat(r)}this._presetChoices.forEach(function(o){o.selected=!0})}else if(this._isSelectElement){this._presetChoices=i.choices.map(function(o){return Re(o,!0)});var s=this.passedElement.optionsAsChoices();s&&(t=this._presetChoices).push.apply(t,s)}},n.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||"")},n.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(se.search,{value:t,resultCount:e})}else this._store.choices.some(function(i){return!i.active})&&this._stopSearch()},n.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,Yt.addChoice),!1):!0},n.prototype._canCreateItem=function(t){var e=this.config,i=!0,r="";if(i&&typeof e.addItemFilter=="function"&&!e.addItemFilter(t)&&(i=!1,r=rs(e.customAddItemText,t)),i){var s=this._store.choices.find(function(o){return e.valueComparer(o.value,t)});if(this._isSelectElement){if(s)return this._displayNotice("",Yt.addChoice),!1}else this._isTextElement&&!e.duplicateItemsAllowed&&s&&(i=!1,r=rs(e.uniqueItemText,t))}return i&&(r=rs(e.addItemText,t)),r&&this._displayNotice(r,Yt.addChoice),i},n.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 r=i.search(e);this._currentValue=e,this._highlightPosition=0,this._isSearching=!0;var s=this._notice,o=s&&s.type;return o!==Yt.addChoice&&(r.length?this._clearNotice():this._displayNotice(kl(this.config.noResultsText),Yt.noResults)),this._store.dispatch(Ad(r)),r.length},n.prototype._stopSearch=function(){this._isSearching&&(this._currentValue="",this._isSearching=!1,this._clearNotice(),this._store.dispatch(Pd(!0)),this.passedElement.triggerEvent(se.search,{value:"",resultCount:0}))},n.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()},n.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()},n.prototype._onKeyDown=function(t){var e=t.keyCode,i=this.dropdown.isActive,r=t.key.length===1||t.key.length===2&&t.key.charCodeAt(0)>=55296||t.key==="Unidentified";switch(!this._isTextElement&&!i&&e!==Gt.ESC_KEY&&e!==Gt.TAB_KEY&&e!==Gt.SHIFT_KEY&&(this.showDropdown(),!this.input.isFocussed&&r&&(this.input.value+=t.key,t.key===" "&&t.preventDefault())),e){case Gt.A_KEY:return this._onSelectKey(t,this.itemList.element.hasChildNodes());case Gt.ENTER_KEY:return this._onEnterKey(t,i);case Gt.ESC_KEY:return this._onEscapeKey(t,i);case Gt.UP_KEY:case Gt.PAGE_UP_KEY:case Gt.DOWN_KEY:case Gt.PAGE_DOWN_KEY:return this._onDirectionKey(t,i);case Gt.DELETE_KEY:case Gt.BACK_KEY:return this._onDeleteKey(t,this._store.items,this.input.isFocussed)}},n.prototype._onKeyUp=function(){this._canSearch=this.config.searchEnabled},n.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())))},n.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()}},n.prototype._onEnterKey=function(t,e){var i=this,r=this.input.value,s=t.target;if(t.preventDefault(),s&&s.hasAttribute("data-button")){this._handleButtonAction(s);return}if(!e){(this._isSelectElement||this._notice)&&this.showDropdown();return}var o=this.dropdown.element.querySelector(Wr(this.config.classNames.highlightedState));if(!(o&&this._handleChoiceAction(o))){if(!s||!r){this.hideDropdown(!0);return}if(this._canAddItems()){var a=!1;this._store.withTxn(function(){if(a=i._findAndSelectChoiceByValue(r,!0),!a){if(!i._canAddUserChoices||!i._canCreateItem(r))return;i._addChoice(Re(r,!1,i.config.allowHtmlUserInput),!0,!0),a=!0}i.clearInput(),i.unhighlightAll()}),a&&(this._triggerChange(r),this.config.closeDropdownOnSelect&&this.hideDropdown(!0))}}},n.prototype._onEscapeKey=function(t,e){e&&(t.stopPropagation(),this.hideDropdown(!0),this._stopSearch(),this.containerOuter.element.focus())},n.prototype._onDirectionKey=function(t,e){var i=t.keyCode;if(e||this._isSelectOneElement){this.showDropdown(),this._canSearch=!1;var r=i===Gt.DOWN_KEY||i===Gt.PAGE_DOWN_KEY?1:-1,s=t.metaKey||i===Gt.PAGE_DOWN_KEY||i===Gt.PAGE_UP_KEY,o=void 0;if(s)r>0?o=this.dropdown.element.querySelector("".concat(Gr,":last-of-type")):o=this.dropdown.element.querySelector(Gr);else{var a=this.dropdown.element.querySelector(Wr(this.config.classNames.highlightedState));a?o=Fd(a,Gr,r):o=this.dropdown.element.querySelector(Gr)}o&&(jd(o,this.choiceList.element,r)||this.choiceList.scrollToChildElement(o,r),this._highlightChoice(o)),t.preventDefault()}},n.prototype._onDeleteKey=function(t,e,i){!this._isSelectOneElement&&!t.target.value&&i&&(this._handleBackspace(e),t.preventDefault())},n.prototype._onTouchMove=function(){this._wasTap&&(this._wasTap=!1)},n.prototype._onTouchEnd=function(t){var e=(t||t.touches[0]).target,i=this._wasTap&&this.containerOuter.element.contains(e);if(i){var r=e===this.containerOuter.element||e===this.containerInner.element;r&&(this._isTextElement?this.input.focus():this._isSelectMultipleElement&&this.showDropdown()),t.stopPropagation()}this._wasTap=!0},n.prototype._onMouseDown=function(t){var e=t.target;if(e instanceof HTMLElement){if(qp&&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 r=e.closest("[data-button],[data-item],[data-choice]");r instanceof HTMLElement&&("button"in r.dataset?this._handleButtonAction(r):"item"in r.dataset?this._handleItemAction(r,t.shiftKey):"choice"in r.dataset&&this._handleChoiceAction(r)),t.preventDefault()}}},n.prototype._onMouseOver=function(t){var e=t.target;e instanceof HTMLElement&&"choice"in e.dataset&&this._highlightChoice(e)},n.prototype._onClick=function(t){var e=t.target,i=this.containerOuter,r=i.element.contains(e);r?!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())},n.prototype._onFocus=function(t){var e=t.target,i=this.containerOuter,r=e&&i.element.contains(e);if(r){var s=e===this.input.element;this._isTextElement?s&&i.addFocusState():this._isSelectMultipleElement?s&&(this.showDropdown(!0),i.addFocusState()):(i.addFocusState(),s&&this.showDropdown(!0))}},n.prototype._onBlur=function(t){var e=t.target,i=this.containerOuter,r=e&&i.element.contains(e);r&&!this._isScrollingOnIe?e===this.input.element?(i.removeFocusState(),this.hideDropdown(!0),(this._isTextElement||this._isSelectMultipleElement)&&this.unhighlightAll()):e===this.containerOuter.element&&i.removeFocusState():(this._isScrollingOnIe=!1,this.input.element.focus())},n.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)})},n.prototype._highlightChoice=function(t){t===void 0&&(t=null);var e=Array.from(this.dropdown.element.querySelectorAll(Gr));if(e.length){var i=t,r=this.config.classNames.highlightedState,s=Array.from(this.dropdown.element.querySelectorAll(Wr(r)));s.forEach(function(o){$e(o,r),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])),G(i,r),i.setAttribute("aria-selected","true"),this.passedElement.triggerEvent(se.highlightChoice,{el:i}),this.dropdown.isActive&&(this.input.setActiveDescendant(i.id),this.containerOuter.setActiveDescendant(i.id))}},n.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(Md(t)),e&&(this.passedElement.triggerEvent(se.addItem,this._getChoiceForOutput(t)),i&&this.passedElement.triggerEvent(se.choice,this._getChoiceForOutput(t)))},n.prototype._removeItem=function(t){if(t.id){this._store.dispatch(El(t));var e=this._notice;e&&e.type===Yt.noChoices&&this._clearNotice(),this.passedElement.triggerEvent(se.removeItem,this._getChoiceForOutput(t))}},n.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 r=this.config;if(!((this._isSelectElement||!r.duplicateItemsAllowed)&&this._store.choices.find(function(a){return r.valueComparer(a.value,t.value)}))){this._lastAddedChoiceId++,t.id=this._lastAddedChoiceId,t.elementId="".concat(this._baseId,"-").concat(this._idNames.itemChoice,"-").concat(t.id);var s=r.prependValue,o=r.appendValue;s&&(t.value=s+t.value),o&&(t.value+=o.toString()),(s||o)&&t.element&&(t.element.value=t.value),this._clearNotice(),this._store.dispatch(kd(t)),t.selected&&this._addItem(t,e,i)}},n.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(Dd(t)),t.choices&&(this._lastAddedGroupId++,t.id=this._lastAddedGroupId,t.choices.forEach(function(r){r.group=t,t.disabled&&(r.disabled=!0),i._addChoice(r,e)}))},n.prototype._createTemplates=function(){var t=this,e=this.config.callbackOnCreateTemplates,i={};typeof e=="function"&&(i=e.call(this,Rd,Aa,to));var r={};Object.keys(this._templates).forEach(function(s){s in i?r[s]=i[s].bind(t):r[s]=t._templates[s].bind(t)}),this._templates=r},n.prototype._createElements=function(){var t=this._templates,e=this,i=e.config,r=e._isSelectOneElement,s=i.position,o=i.classNames,a=this._elementType;this.containerOuter=new Al({element:t.containerOuter(i,this._direction,this._isSelectElement,r,i.searchEnabled,a,i.labelId),classNames:o,type:a,position:s}),this.containerInner=new Al({element:t.containerInner(i),classNames:o,type:a,position:s}),this.input=new Gd({element:t.input(i,this._placeholderValue),classNames:o,type:a,preventPaste:!i.paste}),this.choiceList=new Pl({element:t.choiceList(i,r)}),this.itemList=new Pl({element:t.itemList(i,r)}),this.dropdown=new Wd({element:t.dropdown(i),classNames:o,type:a})},n.prototype._createStructure=function(){var t=this,e=t.containerInner,i=t.containerOuter,r=t.passedElement,s=this.dropdown.element;r.conceal(),e.wrap(r.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(s),e.element.appendChild(this.itemList.element),s.appendChild(this.choiceList.element),this._isSelectOneElement?this.config.searchEnabled&&s.insertBefore(this.input.element,s.firstChild):e.element.appendChild(this.input.element),this._highlightPosition=0,this._isSearching=!1},n.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()},n.prototype._addPredefinedChoices=function(t,e,i){var r=this;if(e===void 0&&(e=!1),i===void 0&&(i=!0),e){var s=t.findIndex(function(o){return o.selected})===-1;s&&t.some(function(o){return o.disabled||"choices"in o?!1:(o.selected=!0,!0)})}t.forEach(function(o){"choices"in o?r._isSelectElement&&r._addGroup(o,i):r._addChoice(o,i)})},n.prototype._findAndSelectChoiceByValue=function(t,e){var i=this;e===void 0&&(e=!1);var r=this._store.choices.find(function(s){return i.config.valueComparer(s.value,t)});return r&&!r.disabled&&!r.selected?(this._addItem(r,!0,e),!0):!1},n.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},n.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"))},n.version="11.0.3",n}();const fh='.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}';class nr{constructor(t,...e){this.slotNames=[],this.handleSlotChange=i=>{const r=i.target;(this.slotNames.includes("[default]")&&!r.name||r.name&&this.slotNames.includes(r.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)}}/**
|
|
154
|
+
|
|
155
|
+
.form-control__label > slot {
|
|
156
|
+
font-size: 16.5px;
|
|
157
|
+
}
|
|
158
|
+
`;/*! choices.js v11.0.3 | © 2024 Josh Johnson | https://github.com/jshjohnson/Choices#readme */var Zo=function(n,t){return Zo=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])},Zo(n,t)};function eh(n,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");Zo(n,t);function e(){this.constructor=n}n.prototype=t===null?Object.create(t):(e.prototype=t.prototype,new e)}var re=function(){return re=Object.assign||function(t){for(var e,i=1,s=arguments.length;i<s;i++){e=arguments[i];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])}return t},re.apply(this,arguments)};function Ed(n,t,e){for(var i=0,s=t.length,r;i<s;i++)(r||!(i in t))&&(r||(r=Array.prototype.slice.call(t,0,i)),r[i]=t[i]);return n.concat(r||Array.prototype.slice.call(t))}var Et={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"},se={showDropdown:"showDropdown",hideDropdown:"hideDropdown",change:"change",choice:"choice",search:"search",addItem:"addItem",removeItem:"removeItem",highlightItem:"highlightItem",highlightChoice:"highlightChoice",unhighlightItem:"unhighlightItem"},Gt={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},Od=["fuseOptions","classNames"],Ci={Text:"text",SelectOne:"select-one",SelectMultiple:"select-multiple"},kd=function(n){return{type:Et.ADD_CHOICE,choice:n}},Tl=function(n){return{type:Et.REMOVE_CHOICE,choice:n}},Ad=function(n){return{type:Et.FILTER_CHOICES,results:n}},Pd=function(n){return{type:Et.ACTIVATE_CHOICES,active:n}},Dd=function(n){return{type:Et.ADD_GROUP,group:n}},Md=function(n){return{type:Et.ADD_ITEM,item:n}},El=function(n){return{type:Et.REMOVE_ITEM,item:n}},Hr=function(n,t){return{type:Et.HIGHLIGHT_ITEM,item:n,highlighted:t}},Id=function(n,t){return Math.floor(Math.random()*(t-n)+n)},Ol=function(n){return Array.from({length:n},function(){return Id(0,36).toString(36)}).join("")},Ld=function(n,t){var e=n.id||n.name&&"".concat(n.name,"-").concat(Ol(2))||Ol(4);return e=e.replace(/(:|\.|\[|\]|,)/g,""),e="".concat(t,"-").concat(e),e},Fd=function(n,t,e){e===void 0&&(e=1);for(var i="".concat(e>0?"next":"previous","ElementSibling"),s=n[i];s;){if(s.matches(t))return s;s=s[i]}return null},jd=function(n,t,e){e===void 0&&(e=1);var i;return e>0?i=t.scrollTop+t.offsetHeight>=n.offsetTop+n.offsetHeight:i=n.offsetTop>=t.scrollTop,i},Jn=function(n){if(typeof n!="string"){if(n==null)return"";if(typeof n=="object"){if("raw"in n)return Jn(n.raw);if("trusted"in n)return n.trusted}return n}return n.replace(/&/g,"&").replace(/>/g,">").replace(/</g,"<").replace(/'/g,"'").replace(/"/g,""")},Rd=function(){var n=document.createElement("div");return function(t){n.innerHTML=t.trim();for(var e=n.children[0];n.firstChild;)n.removeChild(n.firstChild);return e}}(),sr=function(n,t){return typeof n=="function"?n(Jn(t),t):n},kl=function(n){return typeof n=="function"?n():n},Xi=function(n){if(typeof n=="string")return n;if(typeof n=="object"){if("trusted"in n)return n.trusted;if("raw"in n)return n.raw}return""},$d=function(n){if(typeof n=="string")return n;if(typeof n=="object"){if("escaped"in n)return n.escaped;if("trusted"in n)return n.trusted}return""},Aa=function(n,t){return n?$d(t):Jn(t)},Je=function(n,t,e){n.innerHTML=Aa(t,e)},Bd=function(n,t){var e=n.value,i=n.label,s=i===void 0?e:i,r=t.value,o=t.label,a=o===void 0?r:o;return Xi(s).localeCompare(Xi(a),[],{sensitivity:"base",ignorePunctuation:!0,numeric:!0})},Nd=function(n,t){return n.rank-t.rank},zd=function(n,t,e){e===void 0&&(e=null);var i=new CustomEvent(t,{detail:e,bubbles:!0,cancelable:!0});return n.dispatchEvent(i)},Hd=function(n,t){var e=Object.keys(n).sort(),i=Object.keys(t).sort();return e.filter(function(s){return i.indexOf(s)<0})},Qn=function(n){return Array.isArray(n)?n:[n]},Ws=function(n){return n&&Array.isArray(n)?n.map(function(t){return".".concat(t)}).join(""):".".concat(n)},G=function(n,t){var e;(e=n.classList).add.apply(e,Qn(t))},$e=function(n,t){var e;(e=n.classList).remove.apply(e,Qn(t))},Vd=function(n){if(typeof n<"u")try{return JSON.parse(n)}catch{return n}return{}},Ud=function(n,t,e){var i=n.itemEl;i&&($e(i,e),G(i,t))},Wd=function(){function n(t){var e=t.element,i=t.type,s=t.classNames;this.element=e,this.classNames=s,this.type=i,this.isActive=!1}return n.prototype.show=function(){return G(this.element,this.classNames.activeState),this.element.setAttribute("aria-expanded","true"),this.isActive=!0,this},n.prototype.hide=function(){return $e(this.element,this.classNames.activeState),this.element.setAttribute("aria-expanded","false"),this.isActive=!1,this},n}(),Al=function(){function n(t){var e=t.element,i=t.type,s=t.classNames,r=t.position;this.element=e,this.classNames=s,this.type=i,this.position=r,this.isOpen=!1,this.isFlipped=!1,this.isDisabled=!1,this.isLoading=!1}return n.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},n.prototype.setActiveDescendant=function(t){this.element.setAttribute("aria-activedescendant",t)},n.prototype.removeActiveDescendant=function(){this.element.removeAttribute("aria-activedescendant")},n.prototype.open=function(t,e){G(this.element,this.classNames.openState),this.element.setAttribute("aria-expanded","true"),this.isOpen=!0,this.shouldFlip(t,e)&&(G(this.element,this.classNames.flippedState),this.isFlipped=!0)},n.prototype.close=function(){$e(this.element,this.classNames.openState),this.element.setAttribute("aria-expanded","false"),this.removeActiveDescendant(),this.isOpen=!1,this.isFlipped&&($e(this.element,this.classNames.flippedState),this.isFlipped=!1)},n.prototype.addFocusState=function(){G(this.element,this.classNames.focusState)},n.prototype.removeFocusState=function(){$e(this.element,this.classNames.focusState)},n.prototype.enable=function(){$e(this.element,this.classNames.disabledState),this.element.removeAttribute("aria-disabled"),this.type===Ci.SelectOne&&this.element.setAttribute("tabindex","0"),this.isDisabled=!1},n.prototype.disable=function(){G(this.element,this.classNames.disabledState),this.element.setAttribute("aria-disabled","true"),this.type===Ci.SelectOne&&this.element.setAttribute("tabindex","-1"),this.isDisabled=!0},n.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)},n.prototype.unwrap=function(t){var e=this.element,i=e.parentNode;i&&(i.insertBefore(t,e),i.removeChild(e))},n.prototype.addLoadingState=function(){G(this.element,this.classNames.loadingState),this.element.setAttribute("aria-busy","true"),this.isLoading=!0},n.prototype.removeLoadingState=function(){$e(this.element,this.classNames.loadingState),this.element.removeAttribute("aria-busy"),this.isLoading=!1},n}(),Gd=function(){function n(t){var e=t.element,i=t.type,s=t.classNames,r=t.preventPaste;this.element=e,this.type=i,this.classNames=s,this.preventPaste=r,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(n.prototype,"placeholder",{set:function(t){this.element.placeholder=t},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"value",{get:function(){return this.element.value},set:function(t){this.element.value=t},enumerable:!1,configurable:!0}),n.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})},n.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)},n.prototype.enable=function(){var t=this.element;t.removeAttribute("disabled"),this.isDisabled=!1},n.prototype.disable=function(){var t=this.element;t.setAttribute("disabled",""),this.isDisabled=!0},n.prototype.focus=function(){this.isFocussed||this.element.focus()},n.prototype.blur=function(){this.isFocussed&&this.element.blur()},n.prototype.clear=function(t){return t===void 0&&(t=!0),this.element.value="",t&&this.setWidth(),this},n.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")},n.prototype.setActiveDescendant=function(t){this.element.setAttribute("aria-activedescendant",t)},n.prototype.removeActiveDescendant=function(){this.element.removeAttribute("aria-activedescendant")},n.prototype._onInput=function(){this.type!==Ci.SelectOne&&this.setWidth()},n.prototype._onPaste=function(t){this.preventPaste&&t.preventDefault()},n.prototype._onFocus=function(){this.isFocussed=!0},n.prototype._onBlur=function(){this.isFocussed=!1},n}(),Yd=4,Pl=function(){function n(t){var e=t.element;this.element=e,this.scrollPos=this.element.scrollTop,this.height=this.element.offsetHeight}return n.prototype.prepend=function(t){var e=this.element.firstElementChild;e?this.element.insertBefore(t,e):this.element.append(t)},n.prototype.scrollToTop=function(){this.element.scrollTop=0},n.prototype.scrollToChildElement=function(t,e){var i=this;if(t){var s=this.element.offsetHeight,r=this.element.scrollTop+s,o=t.offsetHeight,a=t.offsetTop+o,l=e>0?this.element.scrollTop+a-r:t.offsetTop;requestAnimationFrame(function(){i._animateScroll(l,e)})}},n.prototype._scrollDown=function(t,e,i){var s=(i-t)/e,r=s>1?s:1;this.element.scrollTop=t+r},n.prototype._scrollUp=function(t,e,i){var s=(t-i)/e,r=s>1?s:1;this.element.scrollTop=t-r},n.prototype._animateScroll=function(t,e){var i=this,s=Yd,r=this.element.scrollTop,o=!1;e>0?(this._scrollDown(r,s,t),r<t&&(o=!0)):(this._scrollUp(r,s,t),r>t&&(o=!0)),o&&requestAnimationFrame(function(){i._animateScroll(t,e)})},n}(),ih=function(){function n(t){var e=t.element,i=t.classNames;this.element=e,this.classNames=i,this.isDisabled=!1}return Object.defineProperty(n.prototype,"isActive",{get:function(){return this.element.dataset.choice==="active"},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"dir",{get:function(){return this.element.dir},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"value",{get:function(){return this.element.value},set:function(t){this.element.setAttribute("value",t),this.element.value=t},enumerable:!1,configurable:!0}),n.prototype.conceal=function(){var t=this.element;G(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")},n.prototype.reveal=function(){var t=this.element;$e(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")},n.prototype.enable=function(){this.element.removeAttribute("disabled"),this.element.disabled=!1,this.isDisabled=!1},n.prototype.disable=function(){this.element.setAttribute("disabled",""),this.element.disabled=!0,this.isDisabled=!0},n.prototype.triggerEvent=function(t,e){zd(this.element,t,e||{})},n}(),Xd=function(n){eh(t,n);function t(){return n!==null&&n.apply(this,arguments)||this}return t}(ih),Qs=function(n,t){return t===void 0&&(t=!0),typeof n>"u"?t:!!n},sh=function(n){if(typeof n=="string"&&(n=n.split(" ").filter(function(t){return t.length})),Array.isArray(n)&&n.length)return n},Re=function(n,t,e){if(e===void 0&&(e=!0),typeof n=="string"){var i=Jn(n),s=e||i===n?n:{escaped:i,raw:n},r=Re({value:n,label:s,selected:!0},!1);return r}var o=n;if("choices"in o){if(!t)throw new TypeError("optGroup is not allowed");var a=o,l=a.choices.map(function(d){return Re(d,!1)}),c={id:0,label:Xi(a.label)||a.value,active:!!l.length,disabled:!!a.disabled,choices:l};return c}var h=o,u={id:0,group:null,score:0,rank:0,value:h.value,label:h.label||h.value,active:Qs(h.active),selected:Qs(h.selected,!1),disabled:Qs(h.disabled,!1),placeholder:Qs(h.placeholder,!1),highlighted:!1,labelClass:sh(h.labelClass),labelDescription:h.labelDescription,customProperties:h.customProperties};return u},Kd=function(n){return n.tagName==="INPUT"},rh=function(n){return n.tagName==="SELECT"},qd=function(n){return n.tagName==="OPTION"},Zd=function(n){return n.tagName==="OPTGROUP"},Jd=function(n){eh(t,n);function t(e){var i=e.element,s=e.classNames,r=e.template,o=e.extractPlaceholder,a=n.call(this,{element:i,classNames:s})||this;return a.template=r,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(r){var o=r;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){qd(s)?i.push(e._optionToChoice(s)):Zd(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.innerText,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"?sh(e.dataset.labelClass):void 0,labelDescription:typeof e.dataset.labelDescription<"u"?e.dataset.labelDescription:void 0,customProperties:Vd(e.dataset.customProperties)}},t.prototype._optgroupToChoice=function(e){var i=this,s=e.querySelectorAll("option"),r=Array.from(s).map(function(o){return i._optionToChoice(o)});return{id:0,label:e.label||"",element:e,active:!!r.length,disabled:e.disabled,choices:r}},t}(ih),Qd={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"]},Dl={items:[],choices:[],silent:!1,renderChoiceLimit:-1,maxItemCount:-1,closeDropdownOnSelect:"auto",singleModeForMultiSelect:!1,addChoices:!1,addItems:!0,addItemFilter:function(n){return!!n&&n!==""},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:Bd,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(n){return'Press Enter to add <b>"'.concat(n,'"</b>')},removeItemIconText:function(){return"Remove item"},removeItemLabelText:function(n){return"Remove item: ".concat(n)},maxItemText:function(n){return"Only ".concat(n," values can be added")},valueComparer:function(n,t){return n===t},fuseOptions:{includeScore:!0},labelId:"",callbackOnInit:null,callbackOnCreateTemplates:null,classNames:Qd,appendGroupInSearch:!1},Ml=function(n){var t=n.itemEl;t&&(t.remove(),n.itemEl=void 0)};function tp(n,t,e){var i=n,s=!0;switch(t.type){case Et.ADD_ITEM:{t.item.selected=!0;var r=t.item.element;r&&(r.selected=!0,r.setAttribute("selected","")),i.push(t.item);break}case Et.REMOVE_ITEM:{t.item.selected=!1;var r=t.item.element;if(r){r.selected=!1,r.removeAttribute("selected");var o=r.parentElement;o&&rh(o)&&o.type===Ci.SelectOne&&(o.value="")}Ml(t.item),i=i.filter(function(h){return h.id!==t.item.id});break}case Et.REMOVE_CHOICE:{Ml(t.choice),i=i.filter(function(c){return c.id!==t.choice.id});break}case Et.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&&Ud(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 ep(n,t){var e=n,i=!0;switch(t.type){case Et.ADD_GROUP:{e.push(t.group);break}case Et.CLEAR_CHOICES:{e=[];break}default:{i=!1;break}}return{state:e,update:i}}function ip(n,t,e){var i=n,s=!0;switch(t.type){case Et.ADD_CHOICE:{i.push(t.choice);break}case Et.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 Et.ADD_ITEM:case Et.REMOVE_ITEM:{t.item.choiceEl=void 0;break}case Et.FILTER_CHOICES:{var r=[];t.results.forEach(function(o){r[o.item.id]=o}),i.forEach(function(o){var a=r[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 Et.ACTIVATE_CHOICES:{i.forEach(function(o){o.active=t.active,e&&e.appendGroupInSearch&&(o.choiceEl=void 0)});break}case Et.CLEAR_CHOICES:{i=[];break}default:{s=!1;break}}return{state:i,update:s}}var Il={groups:ep,items:tp,choices:ip},sp=function(){function n(t){this._state=this.defaultState,this._listeners=[],this._txn=0,this._context=t}return Object.defineProperty(n.prototype,"defaultState",{get:function(){return{groups:[],items:[],choices:[]}},enumerable:!1,configurable:!0}),n.prototype.changeSet=function(t){return{groups:t,items:t,choices:t}},n.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)})},n.prototype.subscribe=function(t){return this._listeners.push(t),this},n.prototype.dispatch=function(t){var e=this,i=this._state,s=!1,r=this._changeSet||this.changeSet(!1);Object.keys(Il).forEach(function(o){var a=Il[o](i[o],t,e._context);a.update&&(s=!0,r[o]=!0,i[o]=a.state)}),s&&(this._txn?this._changeSet=r:this._listeners.forEach(function(o){return o(r)}))},n.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(n.prototype,"state",{get:function(){return this._state},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"items",{get:function(){return this.state.items},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"highlightedActiveItems",{get:function(){return this.items.filter(function(t){return!t.disabled&&t.active&&t.highlighted})},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"choices",{get:function(){return this.state.choices},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"activeChoices",{get:function(){return this.choices.filter(function(t){return t.active})},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"searchableChoices",{get:function(){return this.choices.filter(function(t){return!t.disabled&&!t.placeholder})},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"groups",{get:function(){return this.state.groups},enumerable:!1,configurable:!0}),Object.defineProperty(n.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(r){return r.active&&!r.disabled});return i&&s},[])},enumerable:!1,configurable:!0}),n.prototype.inTxn=function(){return this._txn>0},n.prototype.getChoiceById=function(t){return this.activeChoices.find(function(e){return e.id===t})},n.prototype.getGroupById=function(t){return this.groups.find(function(e){return e.id===t})},n}(),Yt={noChoices:"no-choices",noResults:"no-results",addChoice:"add-choice",generic:""};function rp(n,t,e){return(t=op(t))in n?Object.defineProperty(n,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):n[t]=e,n}function Ll(n,t){var e=Object.keys(n);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(n);t&&(i=i.filter(function(s){return Object.getOwnPropertyDescriptor(n,s).enumerable})),e.push.apply(e,i)}return e}function ms(n){for(var t=1;t<arguments.length;t++){var e=arguments[t]!=null?arguments[t]:{};t%2?Ll(Object(e),!0).forEach(function(i){rp(n,i,e[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(e)):Ll(Object(e)).forEach(function(i){Object.defineProperty(n,i,Object.getOwnPropertyDescriptor(e,i))})}return n}function np(n,t){if(typeof n!="object"||!n)return n;var e=n[Symbol.toPrimitive];if(e!==void 0){var i=e.call(n,t);if(typeof i!="object")return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(n)}function op(n){var t=np(n,"string");return typeof t=="symbol"?t:t+""}function ui(n){return Array.isArray?Array.isArray(n):ah(n)==="[object Array]"}function ap(n){if(typeof n=="string")return n;let t=n+"";return t=="0"&&1/n==-1/0?"-0":t}function lp(n){return n==null?"":ap(n)}function Ne(n){return typeof n=="string"}function nh(n){return typeof n=="number"}function cp(n){return n===!0||n===!1||hp(n)&&ah(n)=="[object Boolean]"}function oh(n){return typeof n=="object"}function hp(n){return oh(n)&&n!==null}function me(n){return n!=null}function ko(n){return!n.trim().length}function ah(n){return n==null?n===void 0?"[object Undefined]":"[object Null]":Object.prototype.toString.call(n)}const up="Incorrect 'index' type",dp=n=>`Invalid value for key ${n}`,pp=n=>`Pattern length exceeds max of ${n}.`,gp=n=>`Missing ${n} property in key`,fp=n=>`Property 'weight' in key '${n}' must be a positive integer`,Fl=Object.prototype.hasOwnProperty;class mp{constructor(t){this._keys=[],this._keyMap={};let e=0;t.forEach(i=>{let s=lh(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 lh(n){let t=null,e=null,i=null,s=1,r=null;if(Ne(n)||ui(n))i=n,t=jl(n),e=Jo(n);else{if(!Fl.call(n,"name"))throw new Error(gp("name"));const o=n.name;if(i=o,Fl.call(n,"weight")&&(s=n.weight,s<=0))throw new Error(fp(o));t=jl(o),e=Jo(o),r=n.getFn}return{path:t,id:e,weight:s,src:i,getFn:r}}function jl(n){return ui(n)?n:n.split(".")}function Jo(n){return ui(n)?n.join("."):n}function vp(n,t){let e=[],i=!1;const s=(r,o,a)=>{if(me(r))if(!o[a])e.push(r);else{let l=o[a];const c=r[l];if(!me(c))return;if(a===o.length-1&&(Ne(c)||nh(c)||cp(c)))e.push(lp(c));else if(ui(c)){i=!0;for(let h=0,u=c.length;h<u;h+=1)s(c[h],o,a+1)}else o.length&&s(c,o,a+1)}};return s(n,Ne(t)?t.split("."):t,0),i?e:e[0]}const bp={includeMatches:!1,findAllMatches:!1,minMatchCharLength:1},_p={isCaseSensitive:!1,includeScore:!1,keys:[],shouldSort:!0,sortFn:(n,t)=>n.score===t.score?n.idx<t.idx?-1:1:n.score<t.score?-1:1},yp={location:0,threshold:.6,distance:100},xp={useExtendedSearch:!1,getFn:vp,ignoreLocation:!1,ignoreFieldNorm:!1,fieldNormWeight:1};var U=ms(ms(ms(ms({},_p),bp),yp),xp);const wp=/[^ ]+/g;function Cp(n=1,t=3){const e=new Map,i=Math.pow(10,t);return{get(s){const r=s.match(wp).length;if(e.has(r))return e.get(r);const o=1/Math.pow(r,.5*n),a=parseFloat(Math.round(o*i)/i);return e.set(r,a),a},clear(){e.clear()}}}class Pa{constructor({getFn:t=U.getFn,fieldNormWeight:e=U.fieldNormWeight}={}){this.norm=Cp(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,Ne(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();Ne(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(!me(t)||ko(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,r)=>{let o=s.getFn?s.getFn(t):this.getFn(t,s.path);if(me(o)){if(ui(o)){let a=[];const l=[{nestedArrIndex:-1,value:o}];for(;l.length;){const{nestedArrIndex:c,value:h}=l.pop();if(me(h))if(Ne(h)&&!ko(h)){let u={v:h,i:c,n:this.norm.get(h)};a.push(u)}else ui(h)&&h.forEach((u,d)=>{l.push({nestedArrIndex:d,value:u})})}i.$[r]=a}else if(Ne(o)&&!ko(o)){let a={v:o,n:this.norm.get(o)};i.$[r]=a}}}),this.records.push(i)}toJSON(){return{keys:this.keys,records:this.records}}}function ch(n,t,{getFn:e=U.getFn,fieldNormWeight:i=U.fieldNormWeight}={}){const s=new Pa({getFn:e,fieldNormWeight:i});return s.setKeys(n.map(lh)),s.setSources(t),s.create(),s}function Sp(n,{getFn:t=U.getFn,fieldNormWeight:e=U.fieldNormWeight}={}){const{keys:i,records:s}=n,r=new Pa({getFn:t,fieldNormWeight:e});return r.setKeys(i),r.setIndexRecords(s),r}function Vr(n,{errors:t=0,currentLocation:e=0,expectedLocation:i=0,distance:s=U.distance,ignoreLocation:r=U.ignoreLocation}={}){const o=t/n.length;if(r)return o;const a=Math.abs(i-e);return s?o+a/s:a?1:o}function Tp(n=[],t=U.minMatchCharLength){let e=[],i=-1,s=-1,r=0;for(let o=n.length;r<o;r+=1){let a=n[r];a&&i===-1?i=r:!a&&i!==-1&&(s=r-1,s-i+1>=t&&e.push([i,s]),i=-1)}return n[r-1]&&r-i>=t&&e.push([i,r-1]),e}const Vi=32;function Ep(n,t,e,{location:i=U.location,distance:s=U.distance,threshold:r=U.threshold,findAllMatches:o=U.findAllMatches,minMatchCharLength:a=U.minMatchCharLength,includeMatches:l=U.includeMatches,ignoreLocation:c=U.ignoreLocation}={}){if(t.length>Vi)throw new Error(pp(Vi));const h=t.length,u=n.length,d=Math.max(0,Math.min(i,u));let p=r,g=d;const f=a>1||l,m=f?Array(u):[];let v;for(;(v=n.indexOf(t,g))>-1;){let C=Vr(t,{currentLocation:v,expectedLocation:d,distance:s,ignoreLocation:c});if(p=Math.min(C,p),g=v+h,f){let T=0;for(;T<h;)m[v+T]=1,T+=1}}g=-1;let y=[],x=1,E=h+u;const O=1<<h-1;for(let C=0;C<h;C+=1){let T=0,F=E;for(;T<F;)Vr(t,{errors:C,currentLocation:d+F,expectedLocation:d,distance:s,ignoreLocation:c})<=p?T=F:E=F,F=Math.floor((E-T)/2+T);E=F;let j=Math.max(1,d-F+1),A=o?u:Math.min(d+F,u)+h,k=Array(A+2);k[A+1]=(1<<C)-1;for(let L=A;L>=j;L-=1){let z=L-1,X=e[n.charAt(z)];if(f&&(m[z]=+!!X),k[L]=(k[L+1]<<1|1)&X,C&&(k[L]|=(y[L+1]|y[L])<<1|1|y[L+1]),k[L]&O&&(x=Vr(t,{errors:C,currentLocation:z,expectedLocation:d,distance:s,ignoreLocation:c}),x<=p)){if(p=x,g=z,g<=d)break;j=Math.max(1,2*d-g)}}if(Vr(t,{errors:C+1,currentLocation:d,expectedLocation:d,distance:s,ignoreLocation:c})>p)break;y=k}const D={isMatch:g>=0,score:Math.max(.001,x)};if(f){const C=Tp(m,a);C.length?l&&(D.indices=C):D.isMatch=!1}return D}function Op(n){let t={};for(let e=0,i=n.length;e<i;e+=1){const s=n.charAt(e);t[s]=(t[s]||0)|1<<i-e-1}return t}class hh{constructor(t,{location:e=U.location,threshold:i=U.threshold,distance:s=U.distance,includeMatches:r=U.includeMatches,findAllMatches:o=U.findAllMatches,minMatchCharLength:a=U.minMatchCharLength,isCaseSensitive:l=U.isCaseSensitive,ignoreLocation:c=U.ignoreLocation}={}){if(this.options={location:e,threshold:i,distance:s,includeMatches:r,findAllMatches:o,minMatchCharLength:a,isCaseSensitive:l,ignoreLocation:c},this.pattern=l?t:t.toLowerCase(),this.chunks=[],!this.pattern.length)return;const h=(d,p)=>{this.chunks.push({pattern:d,alphabet:Op(d),startIndex:p})},u=this.pattern.length;if(u>Vi){let d=0;const p=u%Vi,g=u-p;for(;d<g;)h(this.pattern.substr(d,Vi),d),d+=Vi;if(p){const f=u-Vi;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:r,threshold:o,findAllMatches:a,minMatchCharLength:l,ignoreLocation:c}=this.options;let h=[],u=0,d=!1;this.chunks.forEach(({pattern:g,alphabet:f,startIndex:m})=>{const{isMatch:v,score:y,indices:x}=Ep(t,g,f,{location:s+m,distance:r,threshold:o,findAllMatches:a,minMatchCharLength:l,includeMatches:i,ignoreLocation:c});v&&(d=!0),u+=y,v&&x&&(h=[...h,...x])});let p={isMatch:d,score:d?u/this.chunks.length:1};return d&&i&&(p.indices=h),p}}class Fi{constructor(t){this.pattern=t}static isMultiMatch(t){return Rl(t,this.multiRegex)}static isSingleMatch(t){return Rl(t,this.singleRegex)}search(){}}function Rl(n,t){const e=n.match(t);return e?e[1]:null}class kp extends Fi{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 Ap extends Fi{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 Pp extends Fi{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 Dp extends Fi{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 Mp extends Fi{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 Ip extends Fi{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 uh extends Fi{constructor(t,{location:e=U.location,threshold:i=U.threshold,distance:s=U.distance,includeMatches:r=U.includeMatches,findAllMatches:o=U.findAllMatches,minMatchCharLength:a=U.minMatchCharLength,isCaseSensitive:l=U.isCaseSensitive,ignoreLocation:c=U.ignoreLocation}={}){super(t),this._bitapSearch=new hh(t,{location:e,threshold:i,distance:s,includeMatches:r,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 dh extends Fi{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=[],r=this.pattern.length;for(;(i=t.indexOf(this.pattern,e))>-1;)e=i+r,s.push([i,e-1]);const o=!!s.length;return{isMatch:o,score:o?0:1,indices:s}}}const Qo=[kp,dh,Pp,Dp,Ip,Mp,Ap,uh],$l=Qo.length,Lp=/ +(?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)/,Fp="|";function jp(n,t={}){return n.split(Fp).map(e=>{let i=e.trim().split(Lp).filter(r=>r&&!!r.trim()),s=[];for(let r=0,o=i.length;r<o;r+=1){const a=i[r];let l=!1,c=-1;for(;!l&&++c<$l;){const h=Qo[c];let u=h.isMultiMatch(a);u&&(s.push(new h(u,t)),l=!0)}if(!l)for(c=-1;++c<$l;){const h=Qo[c];let u=h.isSingleMatch(a);if(u){s.push(new h(u,t));break}}}return s})}const Rp=new Set([uh.type,dh.type]);class $p{constructor(t,{isCaseSensitive:e=U.isCaseSensitive,includeMatches:i=U.includeMatches,minMatchCharLength:s=U.minMatchCharLength,ignoreLocation:r=U.ignoreLocation,findAllMatches:o=U.findAllMatches,location:a=U.location,threshold:l=U.threshold,distance:c=U.distance}={}){this.query=null,this.options={isCaseSensitive:e,includeMatches:i,minMatchCharLength:s,findAllMatches:o,ignoreLocation:r,location:a,threshold:l,distance:c},this.pattern=e?t:t.toLowerCase(),this.query=jp(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 r=0,o=[],a=0;for(let l=0,c=e.length;l<c;l+=1){const h=e[l];o.length=0,r=0;for(let u=0,d=h.length;u<d;u+=1){const p=h[u],{isMatch:g,indices:f,score:m}=p.search(t);if(g){if(r+=1,a+=m,i){const v=p.constructor.type;Rp.has(v)?o=[...o,...f]:o.push(f)}}else{a=0,r=0,o.length=0;break}}if(r){let u={isMatch:!0,score:a/r};return i&&(u.indices=o),u}}return{isMatch:!1,score:1}}}const ta=[];function Bp(...n){ta.push(...n)}function ea(n,t){for(let e=0,i=ta.length;e<i;e+=1){let s=ta[e];if(s.condition(n,t))return new s(n,t)}return new hh(n,t)}const Dn={AND:"$and",OR:"$or"},ia={PATH:"$path",PATTERN:"$val"},sa=n=>!!(n[Dn.AND]||n[Dn.OR]),Np=n=>!!n[ia.PATH],zp=n=>!ui(n)&&oh(n)&&!sa(n),Bl=n=>({[Dn.AND]:Object.keys(n).map(t=>({[t]:n[t]}))});function ph(n,t,{auto:e=!0}={}){const i=s=>{let r=Object.keys(s);const o=Np(s);if(!o&&r.length>1&&!sa(s))return i(Bl(s));if(zp(s)){const l=o?s[ia.PATH]:r[0],c=o?s[ia.PATTERN]:s[l];if(!Ne(c))throw new Error(dp(l));const h={keyId:Jo(l),pattern:c};return e&&(h.searcher=ea(c,t)),h}let a={children:[],operator:r[0]};return r.forEach(l=>{const c=s[l];ui(c)&&c.forEach(h=>{a.children.push(i(h))})}),a};return sa(n)||(n=Bl(n)),i(n)}function Hp(n,{ignoreFieldNorm:t=U.ignoreFieldNorm}){n.forEach(e=>{let i=1;e.matches.forEach(({key:s,norm:r,score:o})=>{const a=s?s.weight:null;i*=Math.pow(o===0&&a?Number.EPSILON:o,(a||1)*(t?1:r))}),e.score=i})}function Vp(n,t){const e=n.matches;t.matches=[],me(e)&&e.forEach(i=>{if(!me(i.indices)||!i.indices.length)return;const{indices:s,value:r}=i;let o={indices:s,value:r};i.key&&(o.key=i.key.src),i.idx>-1&&(o.refIndex=i.idx),t.matches.push(o)})}function Up(n,t){t.score=n.score}function Wp(n,t,{includeMatches:e=U.includeMatches,includeScore:i=U.includeScore}={}){const s=[];return e&&s.push(Vp),i&&s.push(Up),n.map(r=>{const{idx:o}=r,a={item:t[o],refIndex:o};return s.length&&s.forEach(l=>{l(r,a)}),a})}class Ms{constructor(t,e={},i){this.options=ms(ms({},U),e),this.options.useExtendedSearch,this._keyStore=new mp(this.options.keys),this.setCollection(t,i)}setCollection(t,e){if(this._docs=t,e&&!(e instanceof Pa))throw new Error(up);this._myIndex=e||ch(this.options.keys,this._docs,{getFn:this.options.getFn,fieldNormWeight:this.options.fieldNormWeight})}add(t){me(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 r=this._docs[i];t(r,i)&&(this.removeAt(i),i-=1,s-=1,e.push(r))}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:r,sortFn:o,ignoreFieldNorm:a}=this.options;let l=Ne(t)?Ne(this._docs[0])?this._searchStringList(t):this._searchObjectList(t):this._searchLogical(t);return Hp(l,{ignoreFieldNorm:a}),r&&l.sort(o),nh(e)&&e>-1&&(l=l.slice(0,e)),Wp(l,this._docs,{includeMatches:i,includeScore:s})}_searchStringList(t){const e=ea(t,this.options),{records:i}=this._myIndex,s=[];return i.forEach(({v:r,i:o,n:a})=>{if(!me(r))return;const{isMatch:l,score:c,indices:h}=e.searchIn(r);l&&s.push({item:r,idx:o,matches:[{score:c,value:r,norm:a,indices:h}]})}),s}_searchLogical(t){const e=ph(t,this.options),i=(a,l,c)=>{if(!a.children){const{keyId:u,searcher:d}=a,p=this._findMatches({key:this._keyStore.get(u),value:this._myIndex.getValueForItemAtKeyId(l,u),searcher:d});return p&&p.length?[{idx:c,item:l,matches:p}]:[]}const h=[];for(let u=0,d=a.children.length;u<d;u+=1){const p=a.children[u],g=i(p,l,c);if(g.length)h.push(...g);else if(a.operator===Dn.AND)return[]}return h},s=this._myIndex.records,r={},o=[];return s.forEach(({$:a,i:l})=>{if(me(a)){let c=i(e,a,l);c.length&&(r[l]||(r[l]={idx:l,item:a,matches:[]},o.push(r[l])),c.forEach(({matches:h})=>{r[l].matches.push(...h)}))}}),o}_searchObjectList(t){const e=ea(t,this.options),{keys:i,records:s}=this._myIndex,r=[];return s.forEach(({$:o,i:a})=>{if(!me(o))return;let l=[];i.forEach((c,h)=>{l.push(...this._findMatches({key:c,value:o[h],searcher:e}))}),l.length&&r.push({idx:a,item:o,matches:l})}),r}_findMatches({key:t,value:e,searcher:i}){if(!me(e))return[];let s=[];if(ui(e))e.forEach(({v:r,i:o,n:a})=>{if(!me(r))return;const{isMatch:l,score:c,indices:h}=i.searchIn(r);l&&s.push({score:c,key:t,value:r,idx:o,norm:a,indices:h})});else{const{v:r,n:o}=e,{isMatch:a,score:l,indices:c}=i.searchIn(r);a&&s.push({score:l,key:t,value:r,norm:o,indices:c})}return s}}Ms.version="7.0.0";Ms.createIndex=ch;Ms.parseIndex=Sp;Ms.config=U;Ms.parseQuery=ph;Bp($p);var Gp=function(){function n(t){this._haystack=[],this._fuseOptions=re(re({},t.fuseOptions),{keys:Ed([],t.searchFields),includeMatches:!0})}return n.prototype.index=function(t){this._haystack=t,this._fuse&&this._fuse.setCollection(t)},n.prototype.reset=function(){this._haystack=[],this._fuse=void 0},n.prototype.isEmptyIndex=function(){return!this._haystack.length},n.prototype.search=function(t){this._fuse||(this._fuse=new Ms(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}})},n}();function Yp(n){return new Gp(n)}var Xp=function(n){for(var t in n)if(Object.prototype.hasOwnProperty.call(n,t))return!1;return!0},Ao=function(n,t,e){var i=n.dataset,s=t.customProperties,r=t.labelClass,o=t.labelDescription;r&&(i.labelClass=Qn(r).join(" ")),o&&(i.labelDescription=o),e&&s&&(typeof s=="string"?i.customProperties=s:typeof s=="object"&&!Xp(s)&&(i.customProperties=JSON.stringify(s)))},Nl=function(n,t,e){var i=t&&n.querySelector("label[for='".concat(t,"']")),s=i&&i.innerText;s&&e.setAttribute("aria-label",s)},Kp={containerOuter:function(n,t,e,i,s,r,o){var a=n.classNames.containerOuter,l=document.createElement("div");return G(l,a),l.dataset.type=r,t&&(l.dir=t),i&&(l.tabIndex=0),e&&(l.setAttribute("role",s?"combobox":"listbox"),s?l.setAttribute("aria-autocomplete","list"):o||Nl(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(n){var t=n.classNames.containerInner,e=document.createElement("div");return G(e,t),e},itemList:function(n,t){var e=n.searchEnabled,i=n.classNames,s=i.list,r=i.listSingle,o=i.listItems,a=document.createElement("div");return G(a,s),G(a,t?r:o),this._isSelectElement&&e&&a.setAttribute("role","listbox"),a},placeholder:function(n,t){var e=n.allowHTML,i=n.classNames.placeholder,s=document.createElement("div");return G(s,i),Je(s,e,t),s},item:function(n,t,e){var i=n.allowHTML,s=n.removeItemButtonAlignLeft,r=n.removeItemIconText,o=n.removeItemLabelText,a=n.classNames,l=a.item,c=a.button,h=a.highlightedState,u=a.itemSelectable,d=a.placeholder,p=Xi(t.value),g=document.createElement("div");if(G(g,l),t.labelClass){var f=document.createElement("span");Je(f,i,t.label),G(f,t.labelClass),g.appendChild(f)}else Je(g,i,t.label);if(g.dataset.item="",g.dataset.id=t.id,g.dataset.value=p,Ao(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&&(G(g,d),g.dataset.placeholder=""),G(g,t.highlighted?h:u),e){t.disabled&&$e(g,u),g.dataset.deletable="";var m=document.createElement("button");m.type="button",G(m,c),Je(m,!0,sr(r,t.value));var v=sr(o,t.value);v&&m.setAttribute("aria-label",v),m.dataset.button="",s?g.insertAdjacentElement("afterbegin",m):g.appendChild(m)}return g},choiceList:function(n,t){var e=n.classNames.list,i=document.createElement("div");return G(i,e),t||i.setAttribute("aria-multiselectable","true"),i.setAttribute("role","listbox"),i},choiceGroup:function(n,t){var e=n.allowHTML,i=n.classNames,s=i.group,r=i.groupHeading,o=i.itemDisabled,a=t.id,l=t.label,c=t.disabled,h=Xi(l),u=document.createElement("div");G(u,s),c&&G(u,o),u.setAttribute("role","group"),u.dataset.group="",u.dataset.id=a,u.dataset.value=h,c&&u.setAttribute("aria-disabled","true");var d=document.createElement("div");return G(d,r),Je(d,e,l||""),u.appendChild(d),u},choice:function(n,t,e,i){var s=n.allowHTML,r=n.classNames,o=r.item,a=r.itemChoice,l=r.itemSelectable,c=r.selectedState,h=r.itemDisabled,u=r.description,d=r.placeholder,p=t.label,g=Xi(t.value),f=document.createElement("div");f.id=t.elementId,G(f,o),G(f,a),i&&typeof p=="string"&&(p=Aa(s,p),p+=" (".concat(i,")"),p={trusted:p});var m=f;if(t.labelClass){var v=document.createElement("span");Je(v,s,p),G(v,t.labelClass),m=v,f.appendChild(v)}else Je(f,s,p);if(t.labelDescription){var y="".concat(t.elementId,"-description");m.setAttribute("aria-describedby",y);var x=document.createElement("span");Je(x,s,t.labelDescription),x.id=y,G(x,u),f.appendChild(x)}return t.selected&&G(f,c),t.placeholder&&G(f,d),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)),Ao(f,t,!1),t.disabled?(G(f,h),f.dataset.choiceDisabled="",f.setAttribute("aria-disabled","true")):(G(f,l),f.dataset.choiceSelectable=""),f},input:function(n,t){var e=n.classNames,i=e.input,s=e.inputCloned,r=n.labelId,o=document.createElement("input");return o.type="search",G(o,i),G(o,s),o.autocomplete="off",o.autocapitalize="off",o.spellcheck=!1,o.setAttribute("role","textbox"),o.setAttribute("aria-autocomplete","list"),t?o.setAttribute("aria-label",t):r||Nl(this._docRoot,this.passedElement.element.id,o),o},dropdown:function(n){var t=n.classNames,e=t.list,i=t.listDropdown,s=document.createElement("div");return G(s,e),G(s,i),s.setAttribute("aria-expanded","false"),s},notice:function(n,t,e){var i=n.classNames,s=i.item,r=i.itemChoice,o=i.addChoice,a=i.noResults,l=i.noChoices,c=i.notice;e===void 0&&(e=Yt.generic);var h=document.createElement("div");switch(Je(h,!0,t),G(h,s),G(h,r),G(h,c),e){case Yt.addChoice:G(h,o);break;case Yt.noResults:G(h,a);break;case Yt.noChoices:G(h,l);break}return e===Yt.addChoice&&(h.dataset.choiceSelectable="",h.dataset.choice=""),h},option:function(n){var t=Xi(n.label),e=new Option(t,n.value,!1,n.selected);return Ao(e,n,!0),e.disabled=n.disabled,n.selected&&e.setAttribute("selected",""),e}},qp="-ms-scroll-limit"in document.documentElement.style&&"-ms-ime-align"in document.documentElement.style,Zp={},Po=function(n){if(n)return n.dataset.id?parseInt(n.dataset.id,10):void 0},Gs="[data-choice-selectable]",gh=function(){function n(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=n.defaults;this.config=re(re(re({},s.allOptions),s.options),e),Od.forEach(function(v){i.config[v]=re(re(re({},s.allOptions[v]),s.options[v]),e[v])});var r=this.config;r.silent||this._validateConfig();var o=r.shadowRoot||document.documentElement;this._docRoot=o;var a=typeof t=="string"?o.querySelector(t):t;if(!a||typeof a!="object"||!(Kd(a)||rh(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===Ci.Text;(c||r.maxItemCount!==1)&&(r.singleModeForMultiSelect=!1),r.singleModeForMultiSelect&&(l=Ci.SelectMultiple);var h=l===Ci.SelectOne,u=l===Ci.SelectMultiple,d=h||u;if(this._elementType=l,this._isTextElement=c,this._isSelectOneElement=h,this._isSelectMultipleElement=u,this._isSelectElement=h||u,this._canAddUserChoices=c&&r.addItems||d&&r.addChoices,typeof r.renderSelectedChoices!="boolean"&&(r.renderSelectedChoices=r.renderSelectedChoices==="always"||h),r.closeDropdownOnSelect==="auto"?r.closeDropdownOnSelect=c||h||r.singleModeForMultiSelect:r.closeDropdownOnSelect=Qs(r.closeDropdownOnSelect),r.placeholder&&(r.placeholderValue?this._hasNonChoicePlaceholder=!0:a.dataset.placeholder&&(this._hasNonChoicePlaceholder=!0,r.placeholderValue=a.dataset.placeholder)),e.addItemFilter&&typeof e.addItemFilter!="function"){var p=e.addItemFilter instanceof RegExp?e.addItemFilter:new RegExp(e.addItemFilter);r.addItemFilter=p.test.bind(p)}if(this._isTextElement)this.passedElement=new Xd({element:a,classNames:r.classNames});else{var g=a;this.passedElement=new Jd({element:g,classNames:r.classNames,template:function(v){return i._templates.option(v)},extractPlaceholder:r.placeholder&&!this._hasNonChoicePlaceholder})}if(this.initialised=!1,this._store=new sp(r),this._currentValue="",r.searchEnabled=!c&&r.searchEnabled||u,this._canSearch=r.searchEnabled,this._isScrollingOnIe=!1,this._highlightPosition=0,this._wasTap=!0,this._placeholderValue=this._generatePlaceholderValue(),this._baseId=Ld(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){r.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(v){return v.value})}return Object.defineProperty(n,"defaults",{get:function(){return Object.preventExtensions({get options(){return Zp},get allOptions(){return Dl},get templates(){return Kp}})},enumerable:!1,configurable:!0}),n.prototype.init=function(){if(!(this.initialised||this.initialisedOK!==void 0)){this._searcher=Yp(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)}},n.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=n.defaults.templates,this.initialised=!1,this.initialisedOK=void 0)},n.prototype.enable=function(){return this.passedElement.isDisabled&&this.passedElement.enable(),this.containerOuter.isDisabled&&(this._addEventListeners(),this.input.enable(),this.containerOuter.enable()),this},n.prototype.disable=function(){return this.passedElement.isDisabled||this.passedElement.disable(),this.containerOuter.isDisabled||(this._removeEventListeners(),this.input.disable(),this.containerOuter.disable()),this},n.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(Hr(i,!0)),e&&this.passedElement.triggerEvent(se.highlightItem,this._getChoiceForOutput(i)),this)},n.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(Hr(i,!1)),e&&this.passedElement.triggerEvent(se.unhighlightItem,this._getChoiceForOutput(i)),this)},n.prototype.highlightAll=function(){var t=this;return this._store.withTxn(function(){t._store.items.forEach(function(e){e.highlighted||(t._store.dispatch(Hr(e,!0)),t.passedElement.triggerEvent(se.highlightItem,t._getChoiceForOutput(e)))})}),this},n.prototype.unhighlightAll=function(){var t=this;return this._store.withTxn(function(){t._store.items.forEach(function(e){e.highlighted&&(t._store.dispatch(Hr(e,!1)),t.passedElement.triggerEvent(se.highlightItem,t._getChoiceForOutput(e)))})}),this},n.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},n.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},n.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},n.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(se.showDropdown)}),this)},n.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(se.hideDropdown)}),this):this},n.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},n.prototype.setValue=function(t){var e=this;return this.initialisedOK?(this._store.withTxn(function(){t.forEach(function(i){i&&e._addChoice(Re(i,!1))})}),this._searcher.reset(),this):(this._warnChoicesInitFailed("setValue"),this)},n.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)},n.prototype.setChoices=function(t,e,i,s,r){var o=this;if(t===void 0&&(t=[]),e===void 0&&(e="value"),i===void 0&&(i="label"),s===void 0&&(s=!1),r===void 0&&(r=!0),!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(s&&this.clearChoices(),typeof t=="function"){var a=t(this);if(typeof Promise=="function"&&a instanceof Promise)return new Promise(function(l){return requestAnimationFrame(l)}).then(function(){return o._handleLoadingState(!0)}).then(function(){return a}).then(function(l){return o.setChoices(l,e,i,s)}).catch(function(l){o.config.silent||console.error(l)}).then(function(){return o._handleLoadingState(!1)}).then(function(){return o});if(!Array.isArray(a))throw new TypeError(".setChoices first argument function must return either array of choices or Promise, got: ".concat(typeof a));return this.setChoices(a,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(){r&&(o._isSearching=!1);var l=e==="value",c=i==="label";t.forEach(function(h){if("choices"in h){var u=h;c||(u=re(re({},u),{label:u[i]})),o._addGroup(Re(u,!0))}else{var d=h;(!c||!l)&&(d=re(re({},d),{value:d[e],label:d[i]})),o._addChoice(Re(d,!1))}}),o.unhighlightAll()}),this._searcher.reset(),this},n.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 r=s.passedElement.optionsAsChoices(),o={};i||s._store.items.forEach(function(l){l.id&&l.active&&l.selected&&!l.disabled&&(o[l.value]=!0)}),s.clearStore(!1);var a=function(l){i?s._store.dispatch(El(l)):o[l.value]&&(l.selected=!0)};r.forEach(function(l){if("choices"in l){l.choices.forEach(a);return}a(l)}),s._addPredefinedChoices(r,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)},n.prototype.removeChoice=function(t){var e=this._store.choices.find(function(i){return i.value===t});return e?(this._clearNotice(),this._store.dispatch(Tl(e)),this._searcher.reset(),e.selected&&this.passedElement.triggerEvent(se.removeItem,this._getChoiceForOutput(e)),this):this},n.prototype.clearChoices=function(){var t=this;return this._store.withTxn(function(){t._store.choices.forEach(function(e){e.selected||t._store.dispatch(Tl(e))})}),this._searcher.reset(),this},n.prototype.clearStore=function(t){return t===void 0&&(t=!0),this._stopSearch(),t&&this.passedElement.element.replaceChildren(""),this.itemList.element.replaceChildren(""),this.choiceList.element.replaceChildren(""),this._clearNotice(),this._store.reset(),this._lastAddedChoiceId=0,this._lastAddedGroupId=0,this._searcher.reset(),this},n.prototype.clearInput=function(){var t=!this._isSelectOneElement;return this.input.clear(t),this._stopSearch(),this},n.prototype._validateConfig=function(){var t=this.config,e=Hd(t,Dl);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"))},n.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())},n.prototype._renderChoices=function(){var t=this;if(this._canAddItems()){var e=this,i=e.config,s=e._isSearching,r=this._store,o=r.activeGroups,a=r.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(),u=function(g){return g.filter(function(f){return!f.placeholder&&(s?!!f.rank:i.renderSelectedChoices||!f.selected)})},d=!1,p=function(g,f,m){s?g.sort(Nd):i.shouldSort&&g.sort(i.sorter);var v=g.length;v=!f&&l&&v>l?l:v,v--,g.every(function(y,x){var E=y.choiceEl||t._templates.choice(i,y,i.itemSelectText,m);return y.choiceEl=E,h.appendChild(E),!y.disabled&&(s||!y.selected)&&(d=!0),x<v})};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=u(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(u(a),!1,void 0)),d||(this._notice||(this._notice={text:kl(s?i.noResultsText:i.noChoicesText),type:s?Yt.noResults:Yt.noChoices}),h.replaceChildren("")),this._renderNotice(h),this.choiceList.element.replaceChildren(h),d&&this._highlightChoice()}},n.prototype._renderItems=function(){var t=this,e=this._store.items||[],i=this.itemList.element,s=this.config,r=document.createDocumentFragment(),o=function(u){return i.querySelector('[data-item][data-id="'.concat(u.id,'"]'))},a=function(u){var d=u.itemEl;d&&d.parentElement||(d=o(u)||t._templates.item(s,u,s.removeItemButton),u.itemEl=d,r.appendChild(d))};e.forEach(a);var l=!!r.childNodes.length;if(this._isSelectOneElement&&this._hasNonChoicePlaceholder){var c=i.children.length;if(l||c>1){var h=i.querySelector(Ws(s.classNames.placeholder));h&&h.remove()}else c||(l=!0,a(Re({selected:!0,value:"",label:s.placeholderValue||"",placeholder:!0},!1)))}l&&(i.append(r),s.shouldSortItems&&!this._isSelectOneElement&&(e.sort(s.sorter),e.forEach(function(u){var d=o(u);d&&(d.remove(),r.append(d))}),i.append(r))),this._isTextElement&&(this.passedElement.value=e.map(function(u){var d=u.value;return d}).join(s.delimiter))},n.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===Yt.addChoice&&(e===Yt.noResults||e===Yt.noChoices))){i&&this.showDropdown(!0);return}this._clearNotice(),this._notice=t?{text:t,type:e}:void 0,this._renderNotice(),i&&t&&this.showDropdown(!0)},n.prototype._clearNotice=function(){if(this._notice){var t=this.choiceList.element.querySelector(Ws(this.config.classNames.notice));t&&t.remove(),this._notice=void 0}},n.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)}},n.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}},n.prototype._triggerChange=function(t){t!=null&&this.passedElement.triggerEvent(se.change,{value:t})},n.prototype._handleButtonAction=function(t){var e=this,i=this._store.items;if(!(!i.length||!this.config.removeItems||!this.config.removeItemButton)){var s=t&&Po(t.parentElement),r=s&&i.find(function(o){return o.id===s});r&&this._store.withTxn(function(){if(e._removeItem(r),e._triggerChange(r.value),e._isSelectOneElement&&!e._hasNonChoicePlaceholder){var o=e._store.choices.reverse().find(function(a){return!a.disabled&&a.placeholder});o&&(e._addItem(o),e.unhighlightAll(),o.value&&e._triggerChange(o.value))}})}},n.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 r=Po(t);r&&(s.forEach(function(o){o.id===r&&!o.highlighted?i.highlightItem(o):!e&&o.highlighted&&i.unhighlightItem(o)}),this.input.focus())}},n.prototype._handleChoiceAction=function(t){var e=this,i=Po(t),s=i&&this._store.getChoiceById(i);if(!s||s.disabled)return!1;var r=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 r&&this.config.closeDropdownOnSelect&&(this.hideDropdown(!0),this.containerOuter.element.focus()),!0},n.prototype._handleBackspace=function(t){var e=this.config;if(!(!e.removeItems||!t.length)){var i=t[t.length-1],s=t.some(function(r){return r.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))}},n.prototype._loadChoices=function(){var t,e=this,i=this.config;if(this._isTextElement){if(this._presetChoices=i.items.map(function(o){return Re(o,!1)}),this.passedElement.value){var s=this.passedElement.value.split(i.delimiter).map(function(o){return Re(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 Re(o,!0)});var r=this.passedElement.optionsAsChoices();r&&(t=this._presetChoices).push.apply(t,r)}},n.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||"")},n.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(se.search,{value:t,resultCount:e})}else this._store.choices.some(function(i){return!i.active})&&this._stopSearch()},n.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,Yt.addChoice),!1):!0},n.prototype._canCreateItem=function(t){var e=this.config,i=!0,s="";if(i&&typeof e.addItemFilter=="function"&&!e.addItemFilter(t)&&(i=!1,s=sr(e.customAddItemText,t)),i){var r=this._store.choices.find(function(o){return e.valueComparer(o.value,t)});if(this._isSelectElement){if(r)return this._displayNotice("",Yt.addChoice),!1}else this._isTextElement&&!e.duplicateItemsAllowed&&r&&(i=!1,s=sr(e.uniqueItemText,t))}return i&&(s=sr(e.addItemText,t)),s&&this._displayNotice(s,Yt.addChoice),i},n.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 r=this._notice,o=r&&r.type;return o!==Yt.addChoice&&(s.length?this._clearNotice():this._displayNotice(kl(this.config.noResultsText),Yt.noResults)),this._store.dispatch(Ad(s)),s.length},n.prototype._stopSearch=function(){this._isSearching&&(this._currentValue="",this._isSearching=!1,this._clearNotice(),this._store.dispatch(Pd(!0)),this.passedElement.triggerEvent(se.search,{value:"",resultCount:0}))},n.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()},n.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()},n.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!==Gt.ESC_KEY&&e!==Gt.TAB_KEY&&e!==Gt.SHIFT_KEY&&(this.showDropdown(),!this.input.isFocussed&&s&&(this.input.value+=t.key,t.key===" "&&t.preventDefault())),e){case Gt.A_KEY:return this._onSelectKey(t,this.itemList.element.hasChildNodes());case Gt.ENTER_KEY:return this._onEnterKey(t,i);case Gt.ESC_KEY:return this._onEscapeKey(t,i);case Gt.UP_KEY:case Gt.PAGE_UP_KEY:case Gt.DOWN_KEY:case Gt.PAGE_DOWN_KEY:return this._onDirectionKey(t,i);case Gt.DELETE_KEY:case Gt.BACK_KEY:return this._onDeleteKey(t,this._store.items,this.input.isFocussed)}},n.prototype._onKeyUp=function(){this._canSearch=this.config.searchEnabled},n.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())))},n.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()}},n.prototype._onEnterKey=function(t,e){var i=this,s=this.input.value,r=t.target;if(t.preventDefault(),r&&r.hasAttribute("data-button")){this._handleButtonAction(r);return}if(!e){(this._isSelectElement||this._notice)&&this.showDropdown();return}var o=this.dropdown.element.querySelector(Ws(this.config.classNames.highlightedState));if(!(o&&this._handleChoiceAction(o))){if(!r||!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(Re(s,!1,i.config.allowHtmlUserInput),!0,!0),a=!0}i.clearInput(),i.unhighlightAll()}),a&&(this._triggerChange(s),this.config.closeDropdownOnSelect&&this.hideDropdown(!0))}}},n.prototype._onEscapeKey=function(t,e){e&&(t.stopPropagation(),this.hideDropdown(!0),this._stopSearch(),this.containerOuter.element.focus())},n.prototype._onDirectionKey=function(t,e){var i=t.keyCode;if(e||this._isSelectOneElement){this.showDropdown(),this._canSearch=!1;var s=i===Gt.DOWN_KEY||i===Gt.PAGE_DOWN_KEY?1:-1,r=t.metaKey||i===Gt.PAGE_DOWN_KEY||i===Gt.PAGE_UP_KEY,o=void 0;if(r)s>0?o=this.dropdown.element.querySelector("".concat(Gs,":last-of-type")):o=this.dropdown.element.querySelector(Gs);else{var a=this.dropdown.element.querySelector(Ws(this.config.classNames.highlightedState));a?o=Fd(a,Gs,s):o=this.dropdown.element.querySelector(Gs)}o&&(jd(o,this.choiceList.element,s)||this.choiceList.scrollToChildElement(o,s),this._highlightChoice(o)),t.preventDefault()}},n.prototype._onDeleteKey=function(t,e,i){!this._isSelectOneElement&&!t.target.value&&i&&(this._handleBackspace(e),t.preventDefault())},n.prototype._onTouchMove=function(){this._wasTap&&(this._wasTap=!1)},n.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},n.prototype._onMouseDown=function(t){var e=t.target;if(e instanceof HTMLElement){if(qp&&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()}}},n.prototype._onMouseOver=function(t){var e=t.target;e instanceof HTMLElement&&"choice"in e.dataset&&this._highlightChoice(e)},n.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())},n.prototype._onFocus=function(t){var e=t.target,i=this.containerOuter,s=e&&i.element.contains(e);if(s){var r=e===this.input.element;this._isTextElement?r&&i.addFocusState():this._isSelectMultipleElement?r&&(this.showDropdown(!0),i.addFocusState()):(i.addFocusState(),r&&this.showDropdown(!0))}},n.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._isScrollingOnIe=!1,this.input.element.focus())},n.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)})},n.prototype._highlightChoice=function(t){t===void 0&&(t=null);var e=Array.from(this.dropdown.element.querySelectorAll(Gs));if(e.length){var i=t,s=this.config.classNames.highlightedState,r=Array.from(this.dropdown.element.querySelectorAll(Ws(s)));r.forEach(function(o){$e(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])),G(i,s),i.setAttribute("aria-selected","true"),this.passedElement.triggerEvent(se.highlightChoice,{el:i}),this.dropdown.isActive&&(this.input.setActiveDescendant(i.id),this.containerOuter.setActiveDescendant(i.id))}},n.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(Md(t)),e&&(this.passedElement.triggerEvent(se.addItem,this._getChoiceForOutput(t)),i&&this.passedElement.triggerEvent(se.choice,this._getChoiceForOutput(t)))},n.prototype._removeItem=function(t){if(t.id){this._store.dispatch(El(t));var e=this._notice;e&&e.type===Yt.noChoices&&this._clearNotice(),this.passedElement.triggerEvent(se.removeItem,this._getChoiceForOutput(t))}},n.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(!((this._isSelectElement||!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 r=s.prependValue,o=s.appendValue;r&&(t.value=r+t.value),o&&(t.value+=o.toString()),(r||o)&&t.element&&(t.element.value=t.value),this._clearNotice(),this._store.dispatch(kd(t)),t.selected&&this._addItem(t,e,i)}},n.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(Dd(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)}))},n.prototype._createTemplates=function(){var t=this,e=this.config.callbackOnCreateTemplates,i={};typeof e=="function"&&(i=e.call(this,Rd,Aa,Qn));var s={};Object.keys(this._templates).forEach(function(r){r in i?s[r]=i[r].bind(t):s[r]=t._templates[r].bind(t)}),this._templates=s},n.prototype._createElements=function(){var t=this._templates,e=this,i=e.config,s=e._isSelectOneElement,r=i.position,o=i.classNames,a=this._elementType;this.containerOuter=new Al({element:t.containerOuter(i,this._direction,this._isSelectElement,s,i.searchEnabled,a,i.labelId),classNames:o,type:a,position:r}),this.containerInner=new Al({element:t.containerInner(i),classNames:o,type:a,position:r}),this.input=new Gd({element:t.input(i,this._placeholderValue),classNames:o,type:a,preventPaste:!i.paste}),this.choiceList=new Pl({element:t.choiceList(i,s)}),this.itemList=new Pl({element:t.itemList(i,s)}),this.dropdown=new Wd({element:t.dropdown(i),classNames:o,type:a})},n.prototype._createStructure=function(){var t=this,e=t.containerInner,i=t.containerOuter,s=t.passedElement,r=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(r),e.element.appendChild(this.itemList.element),r.appendChild(this.choiceList.element),this._isSelectOneElement?this.config.searchEnabled&&r.insertBefore(this.input.element,r.firstChild):e.element.appendChild(this.input.element),this._highlightPosition=0,this._isSearching=!1},n.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()},n.prototype._addPredefinedChoices=function(t,e,i){var s=this;if(e===void 0&&(e=!1),i===void 0&&(i=!0),e){var r=t.findIndex(function(o){return o.selected})===-1;r&&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)})},n.prototype._findAndSelectChoiceByValue=function(t,e){var i=this;e===void 0&&(e=!1);var s=this._store.choices.find(function(r){return i.config.valueComparer(r.value,t)});return s&&!s.disabled&&!s.selected?(this._addItem(s,!0,e),!0):!1},n.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},n.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"))},n.version="11.0.3",n}();const fh='.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}';class ns{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)}}/**
|
|
155
159
|
* @license
|
|
156
160
|
* Copyright 2017 Google LLC
|
|
157
161
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
158
|
-
*/const
|
|
162
|
+
*/const yi={ATTRIBUTE:1,PROPERTY:3,BOOLEAN_ATTRIBUTE:4},to=n=>(...t)=>({_$litDirective$:n,values:t});let eo=class{constructor(t){}get _$AU(){return this._$AM._$AU}_$AT(t,e,i){this._$Ct=t,this._$AM=e,this._$Ci=i}_$AS(t,e){return this.update(t,e)}update(t,e){return this.render(...e)}};/**
|
|
159
163
|
* @license
|
|
160
164
|
* Copyright 2018 Google LLC
|
|
161
165
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
162
|
-
*/const
|
|
166
|
+
*/const ve=to(class extends eo{constructor(n){var t;if(super(n),n.type!==yi.ATTRIBUTE||n.name!=="class"||((t=n.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(n){return" "+Object.keys(n).filter(t=>n[t]).join(" ")+" "}update(n,[t]){var i,s;if(this.st===void 0){this.st=new Set,n.strings!==void 0&&(this.nt=new Set(n.strings.join(" ").split(/\s/).filter(r=>r!=="")));for(const r in t)t[r]&&!((i=this.nt)!=null&&i.has(r))&&this.st.add(r);return this.render(t)}const e=n.element.classList;for(const r of this.st)r in t||(e.remove(r),this.st.delete(r));for(const r in t){const o=!!t[r];o===this.st.has(r)||(s=this.nt)!=null&&s.has(r)||(o?(e.add(r),this.st.add(r)):(e.remove(r),this.st.delete(r)))}return Ce}}),Tr=ct`
|
|
163
167
|
.form-control .form-control__label {
|
|
164
168
|
display: none;
|
|
165
169
|
}
|
|
@@ -215,31 +219,31 @@
|
|
|
215
219
|
.form-control--has-help-text.form-control--radio-group .form-control__help-text {
|
|
216
220
|
margin-top: var(--pbo-spacing-2x);
|
|
217
221
|
}
|
|
218
|
-
`;function
|
|
222
|
+
`;function Z(n,t){const e={waitUntilFirstUpdate:!1,...t};return function(i,s){const r=Array.isArray(n)?n:[n],{update:o}=i;i.update=function(a){r.forEach(l=>{const c=l;if(a.has(c)){const h=a.get(c),u=this[c];h!==u&&(!e.waitUntilFirstUpdate||this.hasUpdated)&&this[s](h,u)}}),o.call(this,a)}}}var Jp=Object.defineProperty,Qp=Object.getOwnPropertyDescriptor,os=(n,t,e,i)=>{for(var s=i>1?void 0:i?Qp(t,e):t,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(t,e,s):o(s))||s);return i&&s&&Jp(t,e,s),s};let He=class extends Zi{constructor(){super(...arguments),this.hasSlotController=new ns(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=n=>{var e;const t=n.composedPath();this&&!t.includes(this)&&((e=this._choices)==null||e.hideDropdown())}}get value(){var n;return(n=this._choices)==null?void 0:n.getValue().value}handleDisabledChanged(){var n;this._choices&&this.disabled?this._choices.disable():(n=this._choices)==null||n.enable()}firstUpdated(){this._initializeChoices(),this.handleDisabledChanged(),document.addEventListener("click",this._handleDocumentClick,!0)}disconnectedCallback(){super.disconnectedCallback(),document.removeEventListener("click",this._handleDocumentClick,!0)}_initializeChoices(){var n;(n=this._choices)==null||n.destroy(),this._choices=new gh(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},r)=>{var a;const o=[i(s.item).join(" "),i(r.highlighted?s.highlightedState:s.itemSelectable).join(" ")].join(" ");return t(`
|
|
219
223
|
<div
|
|
220
224
|
class="${o}"
|
|
221
225
|
data-item
|
|
222
|
-
data-id="${
|
|
223
|
-
data-value="${e(
|
|
224
|
-
${
|
|
225
|
-
${
|
|
226
|
-
style="font-family: ${((a=
|
|
226
|
+
data-id="${r.id}"
|
|
227
|
+
data-value="${e(r.value)}"
|
|
228
|
+
${r.active?'aria-selected="true"':""}
|
|
229
|
+
${r.disabled?'aria-disabled="true"':""}
|
|
230
|
+
style="font-family: ${((a=r.customProperties)==null?void 0:a.font)||"inherit"}"
|
|
227
231
|
>
|
|
228
|
-
${
|
|
232
|
+
${r.label}
|
|
229
233
|
</div>
|
|
230
|
-
`)},choice:({classNames:
|
|
234
|
+
`)},choice:({classNames:s},r)=>{var a;const o=[i(s.item).join(" "),i(s.itemChoice).join(" "),i(r.disabled?s.itemDisabled:s.itemSelectable).join(" ")].join(" ");return t(`
|
|
231
235
|
<div class="${o}"
|
|
232
236
|
data-select-text="${this.config.itemSelectText}"
|
|
233
|
-
data-choice ${
|
|
234
|
-
data-id="${
|
|
235
|
-
data-value="${e(
|
|
236
|
-
${
|
|
237
|
-
style="font-family: ${((a=
|
|
237
|
+
data-choice ${r.disabled?'data-choice-disabled aria-disabled="true"':"data-choice-selectable"}
|
|
238
|
+
data-id="${r.id}"
|
|
239
|
+
data-value="${e(r.value)}"
|
|
240
|
+
${r.groupId>0?'role="treeitem"':'role="option"'}
|
|
241
|
+
style="font-family: ${((a=r.customProperties)==null?void 0:a.font)||"inherit"}"
|
|
238
242
|
>
|
|
239
|
-
${
|
|
243
|
+
${r.label}
|
|
240
244
|
</div>
|
|
241
245
|
`)}}}}),this.choiceEl.addEventListener("change",t=>{const e=t.target;this.dispatchEvent(new CustomEvent("pbo-change",{detail:{value:e.value},bubbles:!0,composed:!0}))})}render(){const n=this.hasSlotController.test("label"),t=this.label?!0:!!n;return V` <div
|
|
242
|
-
class=${
|
|
246
|
+
class=${ve({"form-control":!0,"form-control--small":this.size==="small","form-control--medium":this.size==="medium","form-control--large":this.size==="large","form-control--radio-group":!0,"form-control--has-label":t})}
|
|
243
247
|
>
|
|
244
248
|
<label
|
|
245
249
|
part="form-control-label"
|
|
@@ -250,7 +254,7 @@
|
|
|
250
254
|
<slot name="label">${this.label}</slot>
|
|
251
255
|
</label>
|
|
252
256
|
</div>
|
|
253
|
-
<select part="base" class="js-choice"></select>`}};He.styles=[
|
|
257
|
+
<select part="base" class="js-choice"></select>`}};He.styles=[Tt,Td,Tr,Kn(fh)];os([S({type:Array})],He.prototype,"fonts",2);os([S({type:Boolean,reflect:!0})],He.prototype,"disabled",2);os([S()],He.prototype,"size",2);os([S()],He.prototype,"label",2);os([q(".js-choice")],He.prototype,"choiceEl",2);os([Z("disabled",{waitUntilFirstUpdate:!0})],He.prototype,"handleDisabledChanged",1);He=os([xt("pbo-selector")],He);const mh=ct`
|
|
254
258
|
:host {
|
|
255
259
|
display: inline-block;
|
|
256
260
|
position: relative;
|
|
@@ -912,12 +916,12 @@
|
|
|
912
916
|
* @license
|
|
913
917
|
* Copyright 2020 Google LLC
|
|
914
918
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
915
|
-
*/const vh=Symbol.for(""),tg=n=>{if((n==null?void 0:n.r)===vh)return n==null?void 0:n._$litStatic$},zl=(n,...t)=>({_$litStatic$:t.reduce((e,i,
|
|
916
|
-
take care to ensure page security.`)})(i)+n[
|
|
919
|
+
*/const vh=Symbol.for(""),tg=n=>{if((n==null?void 0:n.r)===vh)return n==null?void 0:n._$litStatic$},zl=(n,...t)=>({_$litStatic$:t.reduce((e,i,s)=>e+(r=>{if(r._$litStatic$!==void 0)return r._$litStatic$;throw Error(`Value passed to 'literal' function must be a 'literal' result: ${r}. Use 'unsafeStatic' to pass non-literal values, but
|
|
920
|
+
take care to ensure page security.`)})(i)+n[s+1],n[0]),r:vh}),Hl=new Map,eg=n=>(t,...e)=>{const i=e.length;let s,r;const o=[],a=[];let l,c=0,h=!1;for(;c<i;){for(l=t[c];c<i&&(r=e[c],(s=tg(r))!==void 0);)l+=s+t[++c],h=!0;c!==i&&a.push(r),o.push(l),c++}if(c===i&&o.push(t[i]),h){const u=o.join("$$lit$$");(t=Hl.get(u))===void 0&&(o.raw=o,Hl.set(u,t=o)),e=a}return n(t,...e)},Vl=eg(V);class Pt extends Zi{emit(t,e){const i=new CustomEvent(t,{bubbles:!0,cancelable:!0,composed:!0,detail:{},...e});return this.dispatchEvent(i),i}}const Ys=new WeakMap,Xs=new WeakMap,Ks=new WeakMap,Do=new WeakSet,Ur=new WeakMap;class Da{constructor(t,e){this.handleFormData=i=>{const s=this.options.disabled(this.host),r=this.options.name(this.host),o=this.options.value(this.host),a=this.host.tagName.toLowerCase()==="pbo-button";this.host.isConnected&&!s&&!a&&typeof r=="string"&&r.length>0&&typeof o<"u"&&(Array.isArray(o)?o.forEach(l=>{i.formData.append(r,l.toString())}):i.formData.append(r,o.toString()))},this.handleFormSubmit=i=>{var o;const s=this.options.disabled(this.host),r=this.options.reportValidity;this.form&&!this.form.noValidate&&((o=Ys.get(this.form))==null||o.forEach(a=>{this.setUserInteracted(a,!0)})),this.form&&!this.form.noValidate&&!s&&!r(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),Ur.set(this.host,[])},this.handleInteraction=i=>{const s=Ur.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 r=document.createElement("button");r.type=i,r.style.position="absolute",r.style.width="0",r.style.height="0",r.style.clipPath="inset(50%)",r.style.overflow="hidden",r.style.whiteSpace="nowrap",s&&(r.name=s.name,r.value=s.value,["formation","formenctype","formmethod","formnovalidate","formtarget"].forEach(o=>{s.hasAttribute(o)&&r.setAttribute(o,s.getAttribute(o))})),this.form.append(r),r.click(),r.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),Ur.set(this.host,[]),this.options.assumeInteractionOn.forEach(e=>{this.host.addEventListener(e,this.handleInteraction)})}hostDisconnected(){this.detachForm(),Ur.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,Ys.has(this.form)?Ys.get(this.form).add(this.host):Ys.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),Xs.has(this.form)||(Xs.set(this.form,this.form.reportValidity),this.form.reportValidity=()=>this.reportFormValidity()),Ks.has(this.form)||(Ks.set(this.form,this.form.checkValidity),this.form.checkValidity=()=>this.checkFormValidity())):this.form=void 0}detachForm(){if(!this.form)return;const t=Ys.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),Xs.has(this.form)&&(this.form.reportValidity=Xs.get(this.form),Xs.delete(this.form)),Ks.has(this.form)&&(this.form.checkValidity=Ks.get(this.form),Ks.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?Do.add(t):Do.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=!!Do.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 io=Object.freeze({badInput:!1,customError:!1,patternMismatch:!1,rangeOverflow:!1,rangeUnderflow:!1,stepMismatch:!1,tooLong:!1,tooShort:!1,typeMismatch:!1,valid:!0,valueMissing:!1}),ig=Object.freeze({...io,valid:!1,valueMissing:!1}),sg=Object.freeze({...io,valid:!1,customError:!0});/**
|
|
917
921
|
* @license
|
|
918
922
|
* Copyright 2018 Google LLC
|
|
919
923
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
920
|
-
*/const
|
|
924
|
+
*/const wi=n=>n??at,rg=ct`
|
|
921
925
|
:host {
|
|
922
926
|
--track-width: 2px;
|
|
923
927
|
--track-color: rgb(128 128 128 / 25%);
|
|
@@ -974,19 +978,19 @@
|
|
|
974
978
|
stroke-dasharray: 0.05em, 3em;
|
|
975
979
|
}
|
|
976
980
|
}
|
|
977
|
-
`;var ng=Object.getOwnPropertyDescriptor,og=(n,t,e,i)=>{for(var
|
|
981
|
+
`;var ng=Object.getOwnPropertyDescriptor,og=(n,t,e,i)=>{for(var s=i>1?void 0:i?ng(t,e):t,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=o(s)||s);return s};let ks=class extends Pt{render(){return V`
|
|
978
982
|
<svg part="base" class="spinner" role="progressbar" aria-label="loading">
|
|
979
983
|
<circle class="spinner__track"></circle>
|
|
980
984
|
<circle class="spinner__indicator"></circle>
|
|
981
985
|
</svg>
|
|
982
|
-
`}};
|
|
986
|
+
`}};ks.styles=[Tt,rg];ks=og([xt("pbo-spinner")],ks);var ag=Object.defineProperty,lg=Object.getOwnPropertyDescriptor,Ut=(n,t,e,i)=>{for(var s=i>1?void 0:i?lg(t,e):t,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(t,e,s):o(s))||s);return i&&s&&ag(t,e,s),s};let pt=class extends Pt{constructor(){super(...arguments),this.formControlController=new Da(this,{assumeInteractionOn:["click"]}),this.hasSlotController=new ns(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:io}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(t,e){}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(t){this.doAction("reset",t)}submit(t){this.doAction("submit",t)}render(){const t=this.isLink(),e=t?zl`a`:zl`button`;return Vl`
|
|
983
987
|
<${e}
|
|
984
988
|
part="base"
|
|
985
|
-
class= ${
|
|
986
|
-
?disabled=${
|
|
989
|
+
class= ${ve({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})}
|
|
990
|
+
?disabled=${wi(t?void 0:this.disabled)}
|
|
987
991
|
tabindex=${this.disabled?"-1":"0"}
|
|
988
992
|
href="${this.href}"
|
|
989
|
-
name=${
|
|
993
|
+
name=${wi(t?void 0:this.name)}
|
|
990
994
|
@blur=${this.handleBlur}
|
|
991
995
|
@focus=${this.handleFocus}
|
|
992
996
|
@invalid=${this.isButton()?this.handleInvalid:null}
|
|
@@ -996,7 +1000,7 @@
|
|
|
996
1000
|
<slot part="label" class="button__label"></slot>
|
|
997
1001
|
<slot name="suffix" part="suffix" class="button__suffix"></slot>
|
|
998
1002
|
${this.loading?Vl`<pbo-spinner part="spinner"></pbo-spinner>`:""}
|
|
999
|
-
</${e}>`}};pt.styles=[
|
|
1003
|
+
</${e}>`}};pt.styles=[Tt,mh];pt.dependencies={"pbo-spinner":ks};Ut([q(".button")],pt.prototype,"button",2);Ut([q(".button--loading pbo-spinner")],pt.prototype,"spinner",2);Ut([S({type:Boolean,reflect:!0})],pt.prototype,"disabled",2);Ut([S()],pt.prototype,"href",2);Ut([S()],pt.prototype,"name",2);Ut([S()],pt.prototype,"value",2);Ut([S({reflect:!0})],pt.prototype,"variant",2);Ut([S({type:Boolean,reflect:!0})],pt.prototype,"outline",2);Ut([S({reflect:!0})],pt.prototype,"size",2);Ut([S({type:Boolean,reflect:!0})],pt.prototype,"circle",2);Ut([S({reflect:!0})],pt.prototype,"type",2);Ut([S({type:Boolean,reflect:!0,attribute:"color-block"})],pt.prototype,"colorBlock",2);Ut([S({type:Boolean,reflect:!0})],pt.prototype,"loading",2);Ut([S({type:Boolean,reflect:!0})],pt.prototype,"error",2);Ut([W()],pt.prototype,"isIconButton",2);Ut([W()],pt.prototype,"hasFocus",2);pt=Ut([xt("pbo-button")],pt);const B_=pt,cg=ct`
|
|
1000
1004
|
:host {
|
|
1001
1005
|
display: inline-block;
|
|
1002
1006
|
}
|
|
@@ -1005,10 +1009,10 @@
|
|
|
1005
1009
|
/* display: flex; */
|
|
1006
1010
|
/* flex-wrap: nowrap; */
|
|
1007
1011
|
}
|
|
1008
|
-
`;var hg=Object.defineProperty,ug=Object.getOwnPropertyDescriptor,so=(n,t,e,i)=>{for(var
|
|
1012
|
+
`;var hg=Object.defineProperty,ug=Object.getOwnPropertyDescriptor,so=(n,t,e,i)=>{for(var s=i>1?void 0:i?ug(t,e):t,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(t,e,s):o(s))||s);return i&&s&&hg(t,e,s),s};let Oi=class extends Pt{constructor(){super(...arguments),this.disableRole=!1,this.label=""}handleFocus(t){const e=qs(t.target);e==null||e.toggleAttribute("data-pbo-button-group__button--focus",!0)}handleBlur(t){const e=qs(t.target);e==null||e.toggleAttribute("data-pbo-button-group__button--focus",!1)}handleMouseOver(t){const e=qs(t.target);e==null||e.toggleAttribute("data-pbo-button-group__button--hover",!0)}handleMouseOut(t){const e=qs(t.target);e==null||e.toggleAttribute("data-pbo-button-group__button--hover",!1)}handleSlotChange(){const t=[...this.defaultSlot.assignedElements({flatten:!0})];t.forEach(e=>{const i=t.indexOf(e),s=qs(e);s&&(s.toggleAttribute("data-pbo-button-group__button",!0),s.toggleAttribute("data-pbo-button-group__button--first",i===0),s.toggleAttribute("data-pbo-button-group__button--inner",i>0&&i<t.length-1),s.toggleAttribute("data-pbo-button-group__button--last",i===t.length-1),s.toggleAttribute("data-pbo-button-group__button--radio",s.tagName.toLowerCase()==="pbo-radio-button"))})}render(){return V`
|
|
1009
1013
|
<div
|
|
1010
1014
|
part="base"
|
|
1011
|
-
class=${
|
|
1015
|
+
class=${ve({"button-group":!0})}
|
|
1012
1016
|
role="${this.disableRole?"presentation":"group"}"
|
|
1013
1017
|
aria-label=${this.label}
|
|
1014
1018
|
@focusout=${this.handleBlur}
|
|
@@ -1018,7 +1022,7 @@
|
|
|
1018
1022
|
>
|
|
1019
1023
|
<slot @slotchange=${this.handleSlotChange}></slot>
|
|
1020
1024
|
</div>
|
|
1021
|
-
`}};Oi.styles=[
|
|
1025
|
+
`}};Oi.styles=[Tt,cg];so([q("slot")],Oi.prototype,"defaultSlot",2);so([W()],Oi.prototype,"disableRole",2);so([S()],Oi.prototype,"label",2);Oi=so([xt("pbo-button-group")],Oi);function qs(n){const t="pbo-button, pbo-radio-button";return n.closest(t)??n.querySelector(t)}const z_=Oi,dg=ct`
|
|
1022
1026
|
${mh}
|
|
1023
1027
|
|
|
1024
1028
|
.button__prefix,
|
|
@@ -1039,26 +1043,26 @@
|
|
|
1039
1043
|
* @license
|
|
1040
1044
|
* Copyright 2018 Google LLC
|
|
1041
1045
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
1042
|
-
*/const bh="important",pg=" !"+bh,
|
|
1046
|
+
*/const bh="important",pg=" !"+bh,oe=to(class extends eo{constructor(n){var t;if(super(n),n.type!==yi.ATTRIBUTE||n.name!=="style"||((t=n.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(n){return Object.keys(n).reduce((t,e)=>{const i=n[e];return i==null?t:t+`${e=e.includes("-")?e:e.replace(/(?:^(webkit|moz|ms|o)|)(?=[A-Z])/g,"-$&").toLowerCase()}:${i};`},"")}update(n,[t]){const{style:e}=n.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 r=typeof s=="string"&&s.endsWith(pg);i.includes("-")||r?e.setProperty(i,r?s.slice(0,-11):s,r?bh:""):e[i]=s}}return Ce}});var gg=Object.defineProperty,fg=Object.getOwnPropertyDescriptor,Ke=(n,t,e,i)=>{for(var s=i>1?void 0:i?fg(t,e):t,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(t,e,s):o(s))||s);return i&&s&&gg(t,e,s),s};let be=class extends Pt{constructor(){super(...arguments),this.hasSlotController=new ns(this,"[prefix]","prefix","suffix"),this.checked=!1,this.disabled=!1,this.size="medium",this.circle=!1,this.iconOnly=!1,this.hasFocus=!1,this.handleClick=t=>{if(this.disabled){t.preventDefault(),t.stopPropagation();return}this.checked=!0}}connectedCallback(){super.connectedCallback(),this.setAttribute("role","presentation")}handleBlur(){this.hasFocus=!1,this.emit("pbo-blur")}handleFocus(){}focus(t){this.input.focus(t)}blur(){this.input.blur()}isColorString(t){if(!t)return!1;if(t.startsWith("#"))return/^#([A-Fa-f0-9]{3}){1,2}$/.test(t);const e=new Option().style;return e.color=t,e.color!==""}render(){return V`
|
|
1043
1047
|
<div part="base" role="presentation">
|
|
1044
1048
|
<button
|
|
1045
1049
|
part="${`button${this.checked?"button--checked":""}`}"
|
|
1046
1050
|
role="radio"
|
|
1047
1051
|
aria-checked="${this.checked}"
|
|
1048
|
-
class=${
|
|
1052
|
+
class=${ve({button:!0,"button--default":!0,"button--color-block":!!this.isColorString(this.value),"button--small":this.size==="small","button--medium":this.size==="medium","button--large":this.size==="large","button--checked":this.checked,"button--disabled":this.disabled,"button--outline":!0,"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--icon":this.iconOnly})}
|
|
1049
1053
|
type="button"
|
|
1050
|
-
value=${
|
|
1054
|
+
value=${wi(this.value)}
|
|
1051
1055
|
@blur=${this.handleBlur}
|
|
1052
1056
|
@click=${this.handleClick}
|
|
1053
1057
|
@focus=${this.handleFocus}
|
|
1054
|
-
style=${
|
|
1058
|
+
style=${oe({backgroundColor:this.isColorString(this.value)?this.value:""})}
|
|
1055
1059
|
>
|
|
1056
1060
|
<slot name="prefix" part="prefix" class="button__prefix"></slot>
|
|
1057
1061
|
<slot part="label" class="button__label"></slot>
|
|
1058
1062
|
<slot name="suffix" part="suffix" class="button__suffix"></slot>
|
|
1059
1063
|
</button>
|
|
1060
1064
|
</div>
|
|
1061
|
-
`}};
|
|
1065
|
+
`}};be.styles=[Tt,dg];Ke([q(".button")],be.prototype,"input",2);Ke([q(".hidden-input")],be.prototype,"hiddenInput",2);Ke([S({type:Boolean,reflect:!0})],be.prototype,"checked",2);Ke([S()],be.prototype,"value",2);Ke([S({type:Boolean,reflect:!0})],be.prototype,"disabled",2);Ke([S({reflect:!0})],be.prototype,"size",2);Ke([S({type:Boolean,reflect:!0})],be.prototype,"circle",2);Ke([S({type:Boolean,reflect:!0,attribute:"icon-only"})],be.prototype,"iconOnly",2);Ke([W()],be.prototype,"hasFocus",2);be=Ke([xt("pbo-radio-button")],be);const V_=be,mg=ct`
|
|
1062
1066
|
:host {
|
|
1063
1067
|
display: block;
|
|
1064
1068
|
}
|
|
@@ -1090,11 +1094,15 @@
|
|
|
1090
1094
|
padding: 4px;
|
|
1091
1095
|
border-radius: 16px;
|
|
1092
1096
|
}
|
|
1093
|
-
|
|
1097
|
+
|
|
1098
|
+
.form-control__label > slot {
|
|
1099
|
+
font-size: 16.5px;
|
|
1100
|
+
}
|
|
1101
|
+
`;var vg=Object.defineProperty,bg=Object.getOwnPropertyDescriptor,Kt=(n,t,e,i)=>{for(var s=i>1?void 0:i?bg(t,e):t,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(t,e,s):o(s))||s);return i&&s&&vg(t,e,s),s};let vt=class extends Pt{constructor(){super(...arguments),this.formControlController=new Da(this),this.hasSlotController=new ns(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 t=this.required&&!this.value;return this.customValidityMessage!==""?sg:t?ig:io}get validationMessage(){const t=this.required&&!this.value;return this.customValidityMessage!==""?this.customValidityMessage:t?this.validationInput.validationMessage:""}connectedCallback(){super.connectedCallback(),this.defaultValue=this.value}checkValidity(){const t=this.required&&!this.value,e=this.customValidityMessage!=="";return t||e?(this.formControlController.emitInvalidEvent(),!1):!0}getForm(){return this.formControlController.getForm()}reportValidity(){const t=this.validity.valid;return this.errorMessage=this.customValidityMessage||t?"":this.validationInput.validationMessage,this.formControlController.setValidity(t),this.validationInput.hidden=!0,clearTimeout(this.validationTimeout),t||(this.validationInput.hidden=!1,this.validationInput.reportValidity(),this.validationTimeout=setTimeout(()=>this.validationInput.hidden=!0,1e4)),t}setCustomValidity(t){this.customValidityMessage=t,this.errorMessage=t,this.validationInput.setCustomValidity(t),this.formControlController.updateValidity()}getAllRadios(){return[...this.querySelectorAll("pbo-radio, pbo-radio-button")]}updateCheckedRadio(){this.getAllRadios().forEach(e=>e.checked=e.value===this.value),this.formControlController.setValidity(this.validity.valid)}handleRadioClick(t){const e=t.target.closest("pbo-radio-button"),i=this.getAllRadios(),s=this.value;!e||e.disabled||(this.value=e.value,i.forEach(r=>r.checked=r===e),this.value!==s&&(this.emit("pbo-change"),this.emit("pbo-input")))}handleLabelClick(){this.focus()}handleKeyDown(t){}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 e;const t=this.getAllRadios();if(await Promise.all(t.map(async i=>{await i.updateComplete,i.checked=i.value===this.value})),this.hasButtonGroup=t.some(i=>i.tagName.toLowerCase()==="pbo-radio-button"),t.length>0&&!t.some(i=>i.checked))if(this.hasButtonGroup){const i=(e=t[0].shadowRoot)==null?void 0:e.querySelector("button");i&&i.setAttribute("tabindex","0")}else t[0].setAttribute("tabindex","0")}handleInvalid(t){this.formControlController.setValidity(!1),this.formControlController.emitInvalidEvent(t)}render(){const t=this.hasSlotController.test("label"),e=this.hasSlotController.test("help-text"),i=this.helpText?!0:!!e,s=this.label?!0:!!t;return V`
|
|
1094
1102
|
<fieldset
|
|
1095
1103
|
role="radiogroup"
|
|
1096
1104
|
part="form-control"
|
|
1097
|
-
class=${
|
|
1105
|
+
class=${ve({"form-control":!0,"form-control--small":this.size==="small","form-control--medium":this.size==="medium","form-control--large":this.size==="large","form-control--radio-group":!0,"form-control--has-label":s,"form-control--has-help-text":i,"radio-icon-group":this.iconGroup})}
|
|
1098
1106
|
role="radiogroup"
|
|
1099
1107
|
aria-labelledby="label"
|
|
1100
1108
|
aria-describedby="help-text"
|
|
@@ -1104,7 +1112,7 @@
|
|
|
1104
1112
|
part="form-control-label"
|
|
1105
1113
|
id="label"
|
|
1106
1114
|
class="form-control__label"
|
|
1107
|
-
aria-hidden=${
|
|
1115
|
+
aria-hidden=${s?"false":"true"}
|
|
1108
1116
|
@click=${this.handleLabelClick}
|
|
1109
1117
|
>
|
|
1110
1118
|
<slot name="label">${this.label}</slot>
|
|
@@ -1137,7 +1145,7 @@
|
|
|
1137
1145
|
<slot name="help-text">${this.helpText}</slot>
|
|
1138
1146
|
</div>
|
|
1139
1147
|
</fieldset>
|
|
1140
|
-
`}};vt.styles=[
|
|
1148
|
+
`}};vt.styles=[Tt,mg,Tr];vt.dependencies={"pbo-button-group":Oi};Kt([q("slot:not([name])")],vt.prototype,"defaultSlot",2);Kt([q(".radio-group__validation-input")],vt.prototype,"validationInput",2);Kt([W()],vt.prototype,"hasButtonGroup",2);Kt([W()],vt.prototype,"errorMessage",2);Kt([W()],vt.prototype,"defaultValue",2);Kt([S({type:Boolean,reflect:!0})],vt.prototype,"required",2);Kt([S()],vt.prototype,"name",2);Kt([S({reflect:!0})],vt.prototype,"value",2);Kt([S({attribute:"help-text"})],vt.prototype,"helpText",2);Kt([S()],vt.prototype,"label",2);Kt([S({type:Boolean,reflect:!0,attribute:"icon-group"})],vt.prototype,"iconGroup",2);Kt([S()],vt.prototype,"size",2);Kt([S({type:Boolean,reflect:!0})],vt.prototype,"disabled",2);Kt([S({reflect:!0})],vt.prototype,"form",2);Kt([Z("value")],vt.prototype,"handleValueChange",1);vt=Kt([xt("pbo-radio-group")],vt);const W_=vt,_g=ct`
|
|
1141
1149
|
:host {
|
|
1142
1150
|
display: block;
|
|
1143
1151
|
position: relative;
|
|
@@ -1146,6 +1154,9 @@
|
|
|
1146
1154
|
position: absolute;
|
|
1147
1155
|
right: 0px;
|
|
1148
1156
|
}
|
|
1157
|
+
.form-control__help-text > slot {
|
|
1158
|
+
font-size: 11px;
|
|
1159
|
+
}
|
|
1149
1160
|
.textarea {
|
|
1150
1161
|
display: grid;
|
|
1151
1162
|
align-items: center;
|
|
@@ -1240,7 +1251,7 @@
|
|
|
1240
1251
|
|
|
1241
1252
|
.textarea__control {
|
|
1242
1253
|
font-family: inherit;
|
|
1243
|
-
font-size:
|
|
1254
|
+
font-size: 15px;
|
|
1244
1255
|
font-weight: inherit;
|
|
1245
1256
|
line-height: 1.4;
|
|
1246
1257
|
color: var(--pbo-input-color);
|
|
@@ -1326,33 +1337,33 @@
|
|
|
1326
1337
|
* @license
|
|
1327
1338
|
* Copyright 2020 Google LLC
|
|
1328
1339
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
1329
|
-
*/const{I:yg}=bd,Ul=(n,t)=>(n==null?void 0:n._$litType$)!==void 0,xg=n=>{var t;return((t=n==null?void 0:n._$litType$)==null?void 0:t.h)!=null},wg=n=>n.strings===void 0,Wl=()=>document.createComment(""),Gl=(n,t,e)=>{var
|
|
1340
|
+
*/const{I:yg}=bd,Ul=(n,t)=>(n==null?void 0:n._$litType$)!==void 0,xg=n=>{var t;return((t=n==null?void 0:n._$litType$)==null?void 0:t.h)!=null},wg=n=>n.strings===void 0,Wl=()=>document.createComment(""),Gl=(n,t,e)=>{var r;const i=n._$AA.parentNode,s=n._$AB;if(e===void 0){const o=i.insertBefore(Wl(),s),a=i.insertBefore(Wl(),s);e=new yg(o,a,n,n.options)}else{const o=e._$AB.nextSibling,a=e._$AM,l=a!==n;if(l){let c;(r=e._$AQ)==null||r.call(e,n),e._$AM=n,e._$AP!==void 0&&(c=n._$AU)!==a._$AU&&e._$AP(c)}if(o!==s||l){let c=e._$AA;for(;c!==o;){const h=c.nextSibling;i.insertBefore(c,s),c=h}}}return e},Cg={},ra=(n,t=Cg)=>n._$AH=t,Yl=n=>n._$AH,Sg=n=>{n._$AR()};/**
|
|
1330
1341
|
* @license
|
|
1331
1342
|
* Copyright 2020 Google LLC
|
|
1332
1343
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
1333
|
-
*/const Tg=
|
|
1344
|
+
*/const Tg=to(class extends eo{constructor(n){if(super(n),n.type!==yi.PROPERTY&&n.type!==yi.ATTRIBUTE&&n.type!==yi.BOOLEAN_ATTRIBUTE)throw Error("The `live` directive is not allowed on child or event bindings");if(!wg(n))throw Error("`live` bindings can only contain a single expression")}render(n){return n}update(n,[t]){if(t===Ce||t===at)return t;const e=n.element,i=n.name;if(n.type===yi.PROPERTY){if(t===e[i])return Ce}else if(n.type===yi.BOOLEAN_ATTRIBUTE){if(!!t===e.hasAttribute(i))return Ce}else if(n.type===yi.ATTRIBUTE&&e.getAttribute(i)===t+"")return Ce;return ra(n),t}});var Eg=Object.defineProperty,Og=Object.getOwnPropertyDescriptor,zt=(n,t,e,i)=>{for(var s=i>1?void 0:i?Og(t,e):t,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(t,e,s):o(s))||s);return i&&s&&Eg(t,e,s),s};let bt=class extends Pt{constructor(){super(...arguments),this.formControlController=new Da(this,{assumeInteractionOn:["pbo-input"]}),this.hasSlotController=new ns(this,"help-text"),this.hasFocus=!1,this.name="",this.value="",this.size="medium",this.filled=!1,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(){this.value=this.input.value,this.emit("pbo-change")}handleBlur(){this.hasFocus=!1,this.emit("pbo-blur")}handleFocus(){this.hasFocus=!0,this.emit("pbo-focus")}handleInput(){this.value=this.input.value,this.emit("pbo-input")}handleInvalid(t){this.formControlController.setValidity(!1),this.formControlController.emitInvalidEvent(t)}focus(t){this.input.focus(t)}blur(){this.input.blur()}select(){this.input.select()}scrollPosition(t){if(t){typeof t.top=="number"&&(this.input.scrollTop=t.top),typeof t.left=="number"&&(this.input.scrollLeft=t.left);return}return{top:this.input.scrollTop,left:this.input.scrollTop}}setSelectionRange(t,e,i="none"){this.input.setSelectionRange(t,e,i)}setRangeText(t,e,i,s="preserve"){const r=e??this.input.selectionStart,o=i??this.input.selectionEnd;this.input.setRangeText(t,r,o,s),this.value!==this.input.value&&(this.value=this.input.value)}checkValidity(){return this.input.checkValidity()}getForm(){return this.formControlController.getForm()}reportValidity(){return this.input.reportValidity()}setCustomValidity(t){this.input.setCustomValidity(t),this.formControlController.updateValidity()}render(){const t=this.hasSlotController.test("help-text"),e=this.helpText?!0:!!t;return V` <div
|
|
1334
1345
|
part="form-control"
|
|
1335
|
-
class=${
|
|
1346
|
+
class=${ve({"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":e,invalid:!0})}
|
|
1336
1347
|
>
|
|
1337
1348
|
<div part="form-control-input" class="form-control-input">
|
|
1338
1349
|
<div
|
|
1339
1350
|
part="base"
|
|
1340
|
-
class=${
|
|
1351
|
+
class=${ve({textarea:!0,"textarea--small":this.size==="small","textarea--medium":this.size==="medium","textarea--large":this.size==="large","textarea--standard":!this.filled,"textarea--filled":this.filled,"textarea--disabled":this.disabled,"textarea--focused":this.hasFocus,"textarea--empty":!this.value,"textarea--resize-none":this.resize==="none","textarea--resize-vertical":this.resize==="vertical","textarea--resize-auto":this.resize==="auto"})}
|
|
1341
1352
|
>
|
|
1342
1353
|
<textarea
|
|
1343
1354
|
part="textarea"
|
|
1344
1355
|
id="input"
|
|
1345
1356
|
class="textarea__control"
|
|
1346
1357
|
title=${this.title}
|
|
1347
|
-
name=${
|
|
1358
|
+
name=${wi(this.name)}
|
|
1348
1359
|
.value=${Tg(this.value)}
|
|
1349
1360
|
?disabled=${this.disabled}
|
|
1350
1361
|
?readonly=${this.readonly}
|
|
1351
1362
|
?required=${this.required}
|
|
1352
|
-
placeholder=${
|
|
1353
|
-
rows=${
|
|
1354
|
-
minlength=${
|
|
1355
|
-
maxlength=${
|
|
1363
|
+
placeholder=${wi(this.placeholder)}
|
|
1364
|
+
rows=${wi(this.rows)}
|
|
1365
|
+
minlength=${wi(this.minlength)}
|
|
1366
|
+
maxlength=${wi(this.maxlength)}
|
|
1356
1367
|
aria-describedby="help-text"
|
|
1357
1368
|
@change=${this.handleChange}
|
|
1358
1369
|
@input=${this.handleInput}
|
|
@@ -1372,17 +1383,14 @@
|
|
|
1372
1383
|
>
|
|
1373
1384
|
<slot name="help-text">${this.helpText}</slot>
|
|
1374
1385
|
</div>
|
|
1375
|
-
</div>`}};bt.styles=[
|
|
1386
|
+
</div>`}};bt.styles=[Tt,_g,Tr];zt([q(".textarea__control")],bt.prototype,"input",2);zt([q(".textarea__size-adjuster")],bt.prototype,"sizeAdjuster",2);zt([W()],bt.prototype,"hasFocus",2);zt([S()],bt.prototype,"name",2);zt([S()],bt.prototype,"value",2);zt([S({reflect:!0})],bt.prototype,"size",2);zt([S({type:Boolean,reflect:!0})],bt.prototype,"filled",2);zt([S()],bt.prototype,"placeholder",2);zt([S({type:Number})],bt.prototype,"rows",2);zt([S()],bt.prototype,"resize",2);zt([S({type:Boolean,reflect:!0})],bt.prototype,"disabled",2);zt([S({type:Boolean,reflect:!0})],bt.prototype,"readonly",2);zt([S({reflect:!0})],bt.prototype,"form",2);zt([S({type:Boolean,reflect:!0})],bt.prototype,"required",2);zt([S({type:Number})],bt.prototype,"minlength",2);zt([S({type:Number})],bt.prototype,"maxlength",2);zt([S({attribute:"help-text"})],bt.prototype,"helpText",2);bt=zt([xt("pbo-textarea")],bt);const Y_=bt,kg=ct`
|
|
1376
1387
|
:host {
|
|
1377
1388
|
display: block;
|
|
1378
|
-
width: 100%;
|
|
1379
|
-
height: 100%;
|
|
1380
1389
|
}
|
|
1390
|
+
|
|
1381
1391
|
@media screen and (min-width: 640px) {
|
|
1382
1392
|
:host {
|
|
1383
1393
|
display: block;
|
|
1384
|
-
height: 100%;
|
|
1385
|
-
width: 100%;
|
|
1386
1394
|
}
|
|
1387
1395
|
}
|
|
1388
1396
|
|
|
@@ -1435,7 +1443,7 @@
|
|
|
1435
1443
|
grid-column: 7 / 11;
|
|
1436
1444
|
}
|
|
1437
1445
|
}
|
|
1438
|
-
`,Ag=
|
|
1446
|
+
`,Ag=ct`
|
|
1439
1447
|
:host {
|
|
1440
1448
|
display: block;
|
|
1441
1449
|
}
|
|
@@ -1458,13 +1466,13 @@
|
|
|
1458
1466
|
.cta-buttons pbo-button::part(base) {
|
|
1459
1467
|
font-size: var(--pbo-font-size-medium);
|
|
1460
1468
|
}
|
|
1461
|
-
`,
|
|
1469
|
+
`,vs=()=>/Mobi|Android|iPhone|iPad|iPod/i.test(navigator.userAgent),Zs=n=>n!=null,_h=n=>Object.entries(n).reduce((t,[e,i])=>(i==null||(t[e]=i),t),{});function Pg(n,t){let e;return function(...i){clearTimeout(e),e=setTimeout(()=>n.apply(this,i),t)}}var Dg=Object.defineProperty,Mg=Object.getOwnPropertyDescriptor,Lt=(n,t,e,i)=>{for(var s=i>1?void 0:i?Mg(t,e):t,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(t,e,s):o(s))||s);return i&&s&&Dg(t,e,s),s};let rt=class extends Pt{constructor(){super(...arguments),this.resizeTimeout=null,this.cardInnerImageUrl="../../../public/Greeting Card from Pairbo.png",this.card=null,this.submitTypeForm=async t=>{console.error("submitTypingForm function not implemented",t)},this.loading=!1,this.disabled=!1,this.windowHeight=window.innerHeight,this.charsNum=0,this.ctaButtonState=rt.CTA_STATES.primary,this.wrappedSubmitTypeForm=async t=>{console.warn("submitTypingForm function not implemented",t)},this.handleResize=()=>{this.resizeTimeout&&window.clearTimeout(this.resizeTimeout),this.resizeTimeout=window.setTimeout(()=>{this.windowHeight=window.innerHeight},50)}}updateWrappedSubmitTypeForm(){this.wrappedSubmitTypeForm=async t=>{this.loading=!0,this.disabled=!0;try{this.submitTypeForm(t),await new Promise(e=>setTimeout(e,1e3))}catch(e){console.error("Error submitting type form:",e)}finally{this.loading=!1,this.disabled=!1}}}isLoadingChanged(){this.ctaButtons.forEach(t=>{t.loading=this.loading})}disabledChanged(){this.greetingText.disabled=this.disabled,this.fontSelector.disabled=this.disabled,this.textColor.childNodes.forEach(t=>{t.disabled=this.disabled}),this.textAlignment.childNodes.forEach(t=>{t.disabled=this.disabled}),this.ctaButtons.forEach(t=>{t.disabled=this.disabled})}firstUpdated(){this.disabledChanged(),this.isLoadingChanged(),this.textArea.addEventListener("invalid",()=>{alert("Please add a message to continue")})}get formData(){var e,i,s,r,o,a,l,c;const t={pboCardId:((e=this.card)==null?void 0:e.pboId)||"Unknown",productId:(i=this.card)==null?void 0:i.productId,sku:(s=this.card)==null?void 0:s.sku,variantId:(r=this.card)==null?void 0:r.variantId,font:((o=this.fontSelector)==null?void 0:o.value)||"",text:((a=this.greetingText)==null?void 0:a.value)||"",color:((l=this.textColor)==null?void 0:l.value)||"",alignment:((c=this.textAlignment)==null?void 0:c.value)||""};return _h(t)}handleFormChange(t){var e;this.ctaButtonState=rt.CTA_STATES.primary,this.charsNum=((e=this.greetingText)==null?void 0:e.value.length)||0,this.emit("pbo-change",{detail:this.formData})}hostConnected(){this.addEventListener("pbo-change",this.handleFormChange)}hostDisconnected(){this.removeEventListener("pbo-change",this.handleFormChange)}submitFormHandler(t){var i;t.preventDefault();const e=(i=t.submitter)==null?void 0:i.name;if(this.ctaButtonState.type==="danger"){e==="skip"&&this.wrappedSubmitTypeForm(this.formData);return}if(this.greetingText.value===""||this.greetingText.value===null||this.greetingText.value===void 0){this.ctaButtonState=rt.CTA_STATES.danger,this.greetingText.focus();return}this.wrappedSubmitTypeForm(this.formData)}connectedCallback(){super.connectedCallback(),window.addEventListener("resize",this.handleResize)}disconnectedCallback(){super.disconnectedCallback(),window.removeEventListener("resize",this.handleResize),this.resizeTimeout&&window.clearTimeout(this.resizeTimeout)}render(){const t=223-this.charsNum;return V`
|
|
1462
1470
|
<form class="typing-form" @submit=${this.submitFormHandler}>
|
|
1463
1471
|
<pbo-textarea
|
|
1464
1472
|
exportparts="textarea:editor-textarea"
|
|
1465
1473
|
class="greeting-text"
|
|
1466
1474
|
@pbo-input=${this.handleFormChange}
|
|
1467
|
-
help-text=${t
|
|
1475
|
+
help-text=${t===1?`${t} character`:`${t} characters`}
|
|
1468
1476
|
maxlength="223"
|
|
1469
1477
|
rows="${window.innerHeight>=800?12:8}"
|
|
1470
1478
|
placeholder="Type your message here"
|
|
@@ -1569,11 +1577,11 @@
|
|
|
1569
1577
|
`:""}
|
|
1570
1578
|
</div>
|
|
1571
1579
|
</form>
|
|
1572
|
-
`}};
|
|
1580
|
+
`}};rt.styles=[Tt,Tr,Ag];rt.dependencies={"pbo-selector":He,"pbo-textarea":bt,"pbo-color-radio-group":vt,"pbo-radio-group":vt,"pbo-radio-button":vt,"pbo-button":pt};rt.CTA_STATES={danger:{type:"danger",message:"Add a message to Continue"},primary:{type:"primary",message:"Save and Continue"}};Lt([S({type:String,reflect:!0})],rt.prototype,"cardInnerImageUrl",2);Lt([S()],rt.prototype,"card",2);Lt([S()],rt.prototype,"submitTypeForm",2);Lt([S({type:Boolean,reflect:!0})],rt.prototype,"loading",2);Lt([S({type:Boolean,reflect:!0})],rt.prototype,"disabled",2);Lt([q(".greeting-text")],rt.prototype,"greetingText",2);Lt([q(".font-selector")],rt.prototype,"fontSelector",2);Lt([q(".text-color")],rt.prototype,"textColor",2);Lt([q(".text-alignment")],rt.prototype,"textAlignment",2);Lt([q(".typing-form")],rt.prototype,"typingForm",2);Lt([q("pbo-textarea")],rt.prototype,"textArea",2);Lt([ka(".cta-buttons pbo-button")],rt.prototype,"ctaButtons",2);Lt([W()],rt.prototype,"windowHeight",2);Lt([W()],rt.prototype,"charsNum",2);Lt([W()],rt.prototype,"ctaButtonState",2);Lt([W()],rt.prototype,"wrappedSubmitTypeForm",2);Lt([Z("submitTypeForm")],rt.prototype,"updateWrappedSubmitTypeForm",1);Lt([Z("loading",{waitUntilFirstUpdate:!0})],rt.prototype,"isLoadingChanged",1);Lt([Z("disabled",{waitUntilFirstUpdate:!0})],rt.prototype,"disabledChanged",1);rt=Lt([xt("pbo-type-form")],rt);/**
|
|
1573
1581
|
* @license
|
|
1574
1582
|
* Copyright 2017 Google LLC
|
|
1575
1583
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
1576
|
-
*/const Xl=n=>xg(n)?n._$litType$.h:n.strings,
|
|
1584
|
+
*/const Xl=n=>xg(n)?n._$litType$.h:n.strings,Mo=to(class extends eo{constructor(n){super(n),this.et=new WeakMap}render(n){return[n]}update(n,[t]){const e=Ul(this.it)?Xl(this.it):null,i=Ul(t)?Xl(t):null;if(e!==null&&(i===null||e!==i)){const s=Yl(n).pop();let r=this.et.get(e);if(r===void 0){const o=document.createDocumentFragment();r=Qc(at,o),r.setConnected(!1),this.et.set(e,r)}ra(r,[s]),Gl(r,void 0,s)}if(i!==null){if(e===null||e!==i){const s=this.et.get(i);if(s!==void 0){const r=Yl(s).pop();Sg(n),Gl(n,void 0,r),ra(n,[r])}}this.it=t}else this.it=void 0;return this.render(t)}}),Ig=ct`
|
|
1577
1585
|
:host {
|
|
1578
1586
|
display: block;
|
|
1579
1587
|
width: 100%;
|
|
@@ -1687,7 +1695,7 @@
|
|
|
1687
1695
|
width: 100%;
|
|
1688
1696
|
height: auto;
|
|
1689
1697
|
}
|
|
1690
|
-
`,Lg=
|
|
1698
|
+
`,Lg=ct`
|
|
1691
1699
|
:host,
|
|
1692
1700
|
:host * {
|
|
1693
1701
|
max-height: 100%;
|
|
@@ -1735,29 +1743,29 @@
|
|
|
1735
1743
|
background-color: #f3f3f3;
|
|
1736
1744
|
}
|
|
1737
1745
|
}
|
|
1738
|
-
`;var Fg=Object.defineProperty,jg=Object.getOwnPropertyDescriptor,qe=(n,t,e,i)=>{for(var
|
|
1746
|
+
`;var Fg=Object.defineProperty,jg=Object.getOwnPropertyDescriptor,qe=(n,t,e,i)=>{for(var s=i>1?void 0:i?jg(t,e):t,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(t,e,s):o(s))||s);return i&&s&&Fg(t,e,s),s};let ue=class extends Pt{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?V`<div class="skeleton"></div>`:V`
|
|
1739
1747
|
${this.loaded?"":V` <div class="skeleton"></div>`}
|
|
1740
1748
|
<img
|
|
1741
1749
|
src=${this.src}
|
|
1742
1750
|
alt=${this.alt}
|
|
1743
|
-
class=${
|
|
1751
|
+
class=${ve({loaded:this.loaded,hidden:!this.loaded})}
|
|
1744
1752
|
@error=${()=>this.handleError()}
|
|
1745
1753
|
/>
|
|
1746
|
-
`}};ue.styles=[
|
|
1754
|
+
`}};ue.styles=[Tt,Lg];qe([S()],ue.prototype,"skeletonHeight",2);qe([S()],ue.prototype,"skeletonWidth",2);qe([S()],ue.prototype,"src",2);qe([S()],ue.prototype,"alt",2);qe([S()],ue.prototype,"placeholder",2);qe([S({type:Boolean})],ue.prototype,"skeleton",2);qe([W()],ue.prototype,"loaded",2);qe([q("img")],ue.prototype,"imgEl",2);qe([Z("src")],ue.prototype,"handleSrcChange",1);ue=qe([xt("pbo-image")],ue);var Rg=Object.defineProperty,$g=Object.getOwnPropertyDescriptor,qt=(n,t,e,i)=>{for(var s=i>1?void 0:i?$g(t,e):t,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(t,e,s):o(s))||s);return i&&s&&Rg(t,e,s),s};let At=class extends Pt{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=()=>{this.zoomedPreview&&(this.zoomedPreview.open=!1)},this.openZoomedPreview=()=>{this.zoomedPreview&&(this.zoomedPreview.open=!0)},this.handleOpenZoomedClick=t=>{if(!vs()){t.preventDefault(),t.stopPropagation();return}this.openZoomedPreview()}}firstUpdated(){this.addEventListener("handwritten-image-dimensions-changed",e=>{var o,a;const{detail:i}=e,s=(o=this.shadowRoot)==null?void 0:o.querySelector("#handwritten-main-canvas"),r=(a=this.shadowRoot)==null?void 0:a.querySelector("#handwritten-zoomed-preview-canvas");s&&r&&(s.imageWidth=i.width,s.imageHeight=i.height,s.imageTop=i.top,s.imageLeft=i.left,r.imageWidth=i.width,r.imageHeight=i.height,r.imageTop=i.top,r.imageLeft=i.left)}),this.updateComplete,this.thumbnailElements[this.focusIndex].classList.add("active"),this.mainSlideElements[this.focusIndex].classList.add("active");const t=(e,i)=>{e.addEventListener("click",()=>{this.focusOn(i)})};for(let e=0;e<this.thumbnailElements.length;e++)t(this.thumbnailElements[e],e)}handleCardChange(t,e){var i,s,r,o;e&&(this.mainImageTemplates=[V`<pbo-image src="${e.medias.cover.url||"https://picsum.photos/id/1/300/400"}" alt="" />`,V`<pbo-type-canvas
|
|
1747
1755
|
background-url=${e.medias.insert.url}
|
|
1748
1756
|
message=${(i=this.livePreviewProps)==null?void 0:i.text}
|
|
1749
|
-
alignment=${((
|
|
1750
|
-
color=${(
|
|
1757
|
+
alignment=${((s=this.livePreviewProps)==null?void 0:s.alignment)||"left"}
|
|
1758
|
+
color=${(r=this.livePreviewProps)==null?void 0:r.color}
|
|
1751
1759
|
font=${(o=this.livePreviewProps)==null?void 0:o.font}
|
|
1752
1760
|
@click="${this.handleOpenZoomedClick}"
|
|
1753
|
-
></pbo-type-canvas>`,V`<pbo-image src="${e.medias.rendered_2.url||"https://picsum.photos/id/10/300/400"}" alt="" />`])}handleFocusIndexChange(t,e){var i,r,
|
|
1761
|
+
></pbo-type-canvas>`,V`<pbo-image src="${e.medias.rendered_2.url||"https://picsum.photos/id/10/300/400"}" alt="" />`])}handleFocusIndexChange(t,e){var i,s,r,o;this.thumbnailElements.length!==0&&t!==e&&((i=this.thumbnailElements[t])==null||i.classList.remove("active"),(s=this.thumbnailElements[e])==null||s.classList.add("active"),(r=this.mainSlideElements[t])==null||r.classList.remove("active"),(o=this.mainSlideElements[e])==null||o.classList.add("active"),this.requestUpdate())}focusOn(t){if(t<0||t>=this.thumbnailElements.length){console.warn("Invalid index:",t);return}this.focusIndex=t}get mainSlides(){return this.card?[V`<pbo-image src="${this.card.medias.cover.url}" alt="" />`,V`<pbo-type-canvas
|
|
1754
1762
|
background-url=${this.card.medias.insert.url}
|
|
1755
1763
|
message=${this.livePreviewProps.text}
|
|
1756
1764
|
alignment=${this.livePreviewProps.alignment}
|
|
1757
1765
|
color=${this.livePreviewProps.color}
|
|
1758
1766
|
font=${this.livePreviewProps.font}
|
|
1759
1767
|
@click="${this.handleOpenZoomedClick}"
|
|
1760
|
-
></pbo-type-canvas>`,V`<img src="${this.card.medias.rendered_2.url}" alt="" />`][this.focusIndex]:[]}render(){var t,e,i,r,
|
|
1768
|
+
></pbo-type-canvas>`,V`<img src="${this.card.medias.rendered_2.url}" alt="" />`][this.focusIndex]:[]}render(){var t,e,i,s,r,o,a,l,c,h,u,d,p,g,f,m,v,y,x,E;return V`
|
|
1761
1769
|
<div class="card--slider--wrapper">
|
|
1762
1770
|
<div id="thumbnails" class="thumbnails">
|
|
1763
1771
|
<div class="thumbnail">
|
|
@@ -1773,8 +1781,8 @@
|
|
|
1773
1781
|
|
|
1774
1782
|
<div class="main-slide-container">
|
|
1775
1783
|
<div class="main-slide" @click="${this.handleOpenZoomedClick}">
|
|
1776
|
-
<pbo-image src="${((
|
|
1777
|
-
${
|
|
1784
|
+
<pbo-image src="${((s=this.card)==null?void 0:s.medias.cover.url)||"https://picsum.photos/id/1/300/400"}" alt="" />
|
|
1785
|
+
${vs()?V`<div class="zoomed-preview-open-button" @click="${this.handleOpenZoomedClick}">
|
|
1778
1786
|
<svg
|
|
1779
1787
|
stroke="currentColor"
|
|
1780
1788
|
fill="none"
|
|
@@ -1795,8 +1803,8 @@
|
|
|
1795
1803
|
</div>`:""}
|
|
1796
1804
|
</div>
|
|
1797
1805
|
<div class="main-slide" @click="${this.handleOpenZoomedClick}">
|
|
1798
|
-
${
|
|
1799
|
-
background-url=${(
|
|
1806
|
+
${Mo(this.type==="type"?V`<pbo-type-canvas
|
|
1807
|
+
background-url=${(r=this.card)==null?void 0:r.medias.insert.url}
|
|
1800
1808
|
message=${(o=this.livePreviewProps)==null?void 0:o.text}
|
|
1801
1809
|
alignment=${((a=this.livePreviewProps)==null?void 0:a.alignment)||"left"}
|
|
1802
1810
|
color=${(l=this.livePreviewProps)==null?void 0:l.color}
|
|
@@ -1808,7 +1816,7 @@
|
|
|
1808
1816
|
handwritten-url=${this.handwrittenPreviewProps.processedFileUrl}
|
|
1809
1817
|
@click="${this.handleOpenZoomedClick}"
|
|
1810
1818
|
></pbo-handwritten-canvas>`)}
|
|
1811
|
-
${
|
|
1819
|
+
${vs()?V`<div class="zoomed-preview-open-button">
|
|
1812
1820
|
<svg
|
|
1813
1821
|
stroke="currentColor"
|
|
1814
1822
|
fill="none"
|
|
@@ -1830,7 +1838,7 @@
|
|
|
1830
1838
|
</div>
|
|
1831
1839
|
<div class="main-slide" @click=${this.handleOpenZoomedClick}>
|
|
1832
1840
|
<pbo-image src="${((u=this.card)==null?void 0:u.medias.rendered_2.url)||"https://picsum.photos/id/10/300/400"}" alt="" />
|
|
1833
|
-
${
|
|
1841
|
+
${vs()?V`<div class="zoomed-preview-open-button" @click="${this.handleOpenZoomedClick}">
|
|
1834
1842
|
<svg
|
|
1835
1843
|
stroke="currentColor"
|
|
1836
1844
|
fill="none"
|
|
@@ -1854,7 +1862,7 @@
|
|
|
1854
1862
|
</div>
|
|
1855
1863
|
<pbo-drawer
|
|
1856
1864
|
placement="bottom"
|
|
1857
|
-
style="${
|
|
1865
|
+
style="${oe({"--size":"100%","--panel-background-color":"#454545ca"})}"
|
|
1858
1866
|
contained
|
|
1859
1867
|
class="editor__zoomed"
|
|
1860
1868
|
>
|
|
@@ -1866,32 +1874,32 @@
|
|
|
1866
1874
|
<img
|
|
1867
1875
|
src="${((p=this.card)==null?void 0:p.medias.cover.url)||"https://picsum.photos/id/1/300/400"}"
|
|
1868
1876
|
alt=""
|
|
1869
|
-
style=${
|
|
1877
|
+
style=${oe({display:this.focusIndex===0?"block":"none"})}
|
|
1870
1878
|
/>
|
|
1871
|
-
${
|
|
1879
|
+
${Mo(this.type==="type"?V`<pbo-type-canvas
|
|
1872
1880
|
background-url=${(g=this.card)==null?void 0:g.medias.insert.url}
|
|
1873
1881
|
message=${(f=this.livePreviewProps)==null?void 0:f.text}
|
|
1874
1882
|
alignment=${((m=this.livePreviewProps)==null?void 0:m.alignment)||"left"}
|
|
1875
1883
|
color=${(v=this.livePreviewProps)==null?void 0:v.color}
|
|
1876
1884
|
font=${(y=this.livePreviewProps)==null?void 0:y.font}
|
|
1877
1885
|
@click="${this.handleOpenZoomedClick}"
|
|
1878
|
-
style=${
|
|
1879
|
-
></pbo-type-canvas>`:
|
|
1880
|
-
${
|
|
1886
|
+
style=${oe({display:this.focusIndex===1?"block":"none"})}
|
|
1887
|
+
></pbo-type-canvas>`:at)}
|
|
1888
|
+
${Mo(this.type==="handwritten"?V`<pbo-handwritten-canvas
|
|
1881
1889
|
id="handwritten-zoomed-preview-canvas"
|
|
1882
1890
|
background-url=${(x=this.card)==null?void 0:x.medias.insert.url}
|
|
1883
1891
|
handwritten-url=${this.handwrittenPreviewProps.processedFileUrl}
|
|
1884
1892
|
@click="${this.handleOpenZoomedClick}"
|
|
1885
|
-
style=${
|
|
1886
|
-
></pbo-handwritten-canvas>`:
|
|
1893
|
+
style=${oe({display:this.focusIndex===1?"block":"none"})}
|
|
1894
|
+
></pbo-handwritten-canvas>`:at)}
|
|
1887
1895
|
<img
|
|
1888
1896
|
src="${((E=this.card)==null?void 0:E.medias.rendered_2.url)||"https://picsum.photos/id/10/300/400"}"
|
|
1889
1897
|
alt=""
|
|
1890
|
-
style=${
|
|
1898
|
+
style=${oe({display:this.focusIndex===2?"block":"none"})}
|
|
1891
1899
|
/>
|
|
1892
1900
|
</pbo-zoomed-preview>
|
|
1893
1901
|
</pbo-drawer>
|
|
1894
|
-
`}};
|
|
1902
|
+
`}};At.styles=[Tt,Ig];At.dependencies={"pbo-image":ue};qt([S({type:Object})],At.prototype,"card",2);qt([S({type:Number,reflect:!0})],At.prototype,"focusIndex",2);qt([S({type:Object})],At.prototype,"livePreviewProps",2);qt([S()],At.prototype,"handwrittenPreviewProps",2);qt([S()],At.prototype,"type",2);qt([q("#thumbnails")],At.prototype,"thumbnailCarousel",2);qt([q("#main-carousel")],At.prototype,"mainCarousel",2);qt([q(".editor__zoomed")],At.prototype,"zoomedPreview",2);qt([q(".main-slide.active")],At.prototype,"activeMainSlide",2);qt([q("pbo-type-canvas")],At.prototype,"typeCanvas",2);qt([ka(".thumbnail")],At.prototype,"thumbnailElements",2);qt([ka(".main-slide")],At.prototype,"mainSlideElements",2);qt([W()],At.prototype,"mainImageTemplates",2);qt([Z("card")],At.prototype,"handleCardChange",1);qt([Z("focusIndex")],At.prototype,"handleFocusIndexChange",1);At=qt([xt("pbo-editor-card-slider")],At);var Bg=Object.defineProperty,Ng=Object.getOwnPropertyDescriptor,_e=(n,t,e,i)=>{for(var s=i>1?void 0:i?Ng(t,e):t,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(t,e,s):o(s))||s);return i&&s&&Bg(t,e,s),s};let Nt=class extends Pt{constructor(){super(...arguments),this.card=null,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.focusOn(1)},this.handelHandwrittenFormChange=t=>{this.handwrittenFormState=t.detail,this.slider.focusOn(1)},this.handleHandwrittenImageDimensionsChanged=t=>{this.handwrittenForm.setDimensions(t.detail)},this.handleZoomedPreviewOpen=()=>{this.zoomedPreview.open=!0},this.openZoomedPreview=()=>{this.zoomedPreview&&(this.zoomedPreview.open=!0)},this.closeZoomedPreview=()=>{this.zoomedPreview&&(this.zoomedPreview.open=!1)},this.handleEditorChange=t=>{this.editorType=t.detail.value}}firstUpdated(){this.addEventListener("handwritten-image-dimensions-changed",this.handleHandwrittenImageDimensionsChanged),this.typeForm.addEventListener("pbo-change",this.handleTypingFormChange),this.handwrittenForm.addEventListener("pbo-change",this.handelHandwrittenFormChange),document.addEventListener("pbo-zoomed-preview-open",this.handleZoomedPreviewOpen)}async handleCardChange(){await this.updateComplete,this.card&&(this.slider.card=this.card,this.requestUpdate(),this.typeForm.card=this.card,this.handwrittenForm.card=this.card)}disconnectedCallback(){this.typeForm.removeEventListener("pbo-change",this.handleTypingFormChange),this.handwrittenForm.removeEventListener("pbo-change",this.handelHandwrittenFormChange)}render(){var t;return V`
|
|
1895
1903
|
<div class="editor">
|
|
1896
1904
|
<div class="editor__card" part="editor-card-slider-container">
|
|
1897
1905
|
<pbo-editor-card-slider
|
|
@@ -1919,7 +1927,7 @@
|
|
|
1919
1927
|
cta-link-button-base
|
|
1920
1928
|
"
|
|
1921
1929
|
.submitTypeForm=${this.submitTypeForm}
|
|
1922
|
-
style=${
|
|
1930
|
+
style=${oe({display:this.editorType==="type"?"block":"none"})}
|
|
1923
1931
|
></pbo-type-form>
|
|
1924
1932
|
<pbo-handwritten-form
|
|
1925
1933
|
part="handwritten-form"
|
|
@@ -1929,7 +1937,7 @@
|
|
|
1929
1937
|
cta-link-button-base,
|
|
1930
1938
|
cta-link-button-label
|
|
1931
1939
|
"
|
|
1932
|
-
style=${
|
|
1940
|
+
style=${oe({display:this.editorType==="handwritten"?"block":"none"})}
|
|
1933
1941
|
.submitHandwrittenForm=${this.submitHandwrittenForm}
|
|
1934
1942
|
.getProcessedImg=${this.getProcessedImg}
|
|
1935
1943
|
></pbo-handwritten-form>
|
|
@@ -1938,7 +1946,7 @@
|
|
|
1938
1946
|
|
|
1939
1947
|
<pbo-drawer
|
|
1940
1948
|
placement="bottom"
|
|
1941
|
-
style="${
|
|
1949
|
+
style="${oe({"--size":"100%","--panel-background-color":"#454545ca"})}"
|
|
1942
1950
|
contained
|
|
1943
1951
|
class="editor__zoomed"
|
|
1944
1952
|
>
|
|
@@ -1950,10 +1958,10 @@
|
|
|
1950
1958
|
.close=${this.closeZoomedPreview}
|
|
1951
1959
|
></pbo-zoomed-preview>
|
|
1952
1960
|
</pbo-drawer>
|
|
1953
|
-
`}};
|
|
1961
|
+
`}};Nt.styles=[Tt,kg];Nt.dependencies={"editor-card-slider":At,"pbo-type-form":rt};_e([S({type:Object})],Nt.prototype,"card",2);_e([S()],Nt.prototype,"submitTypeForm",2);_e([S()],Nt.prototype,"submitHandwrittenForm",2);_e([S()],Nt.prototype,"getProcessedImg",2);_e([q("pbo-type-form")],Nt.prototype,"typeForm",2);_e([q("pbo-handwritten-form")],Nt.prototype,"handwrittenForm",2);_e([q("pbo-editor-card-slider")],Nt.prototype,"slider",2);_e([q(".editor__zoomed")],Nt.prototype,"zoomedPreview",2);_e([W()],Nt.prototype,"formData",2);_e([W()],Nt.prototype,"handwrittenFormState",2);_e([W()],Nt.prototype,"editorType",2);_e([Z("card")],Nt.prototype,"handleCardChange",1);Nt=_e([xt("pbo-editor")],Nt);const J_=Nt,Q_=rt,t0=At,zg=ct`
|
|
1954
1962
|
:host {
|
|
1955
1963
|
display: block;
|
|
1956
|
-
--title-font-size:
|
|
1964
|
+
--title-font-size: 18.75px;
|
|
1957
1965
|
--title-font-weight: var(--pbo-font-weight-normal);
|
|
1958
1966
|
--title-margin: var(--pbo-spacing-medium) 0 var(--pbo-spacing-x-small) 0;
|
|
1959
1967
|
}
|
|
@@ -2051,11 +2059,11 @@
|
|
|
2051
2059
|
* Version : 4.1.4
|
|
2052
2060
|
* License : MIT
|
|
2053
2061
|
* Copyright: 2022 Naotoshi Fujita
|
|
2054
|
-
*/var Kl="(prefers-reduced-motion: reduce)",br=1,Wg=2,Ar=3,Ir=4,Os=5,yn=6,In=7,Gg={CREATED:br,MOUNTED:Wg,IDLE:Ar,MOVING:Ir,SCROLLING:Os,DRAGGING:yn,DESTROYED:In};function ui(n){n.length=0}function ji(n,t,e){return Array.prototype.slice.call(n,t,e)}function at(n){return n.bind.apply(n,[null].concat(ji(arguments,1)))}var yh=setTimeout,na=function(){};function ql(n){return requestAnimationFrame(n)}function no(n,t){return typeof t===n}function ps(n){return!Ia(n)&&no("object",n)}var Ma=Array.isArray,xh=at(no,"function"),ki=at(no,"string"),ks=at(no,"undefined");function Ia(n){return n===null}function wh(n){try{return n instanceof(n.ownerDocument.defaultView||window).HTMLElement}catch{return!1}}function As(n){return Ma(n)?n:[n]}function Te(n,t){As(n).forEach(t)}function La(n,t){return n.indexOf(t)>-1}function xn(n,t){return n.push.apply(n,As(t)),n}function ri(n,t,e){n&&Te(t,function(i){i&&n.classList[e?"add":"remove"](i)})}function Ve(n,t){ri(n,ki(t)?t.split(" "):t,!0)}function Ps(n,t){Te(t,n.appendChild.bind(n))}function Fa(n,t){Te(n,function(e){var i=(t||e).parentNode;i&&i.insertBefore(e,t)})}function gs(n,t){return wh(n)&&(n.msMatchesSelector||n.matches).call(n,t)}function Ch(n,t){var e=n?ji(n.children):[];return t?e.filter(function(i){return gs(i,t)}):e}function Ds(n,t){return t?Ch(n,t)[0]:n.firstElementChild}var fs=Object.keys;function Ji(n,t,e){return n&&(e?fs(n).reverse():fs(n)).forEach(function(i){i!=="__proto__"&&t(n[i],i)}),n}function ms(n){return ji(arguments,1).forEach(function(t){Ji(t,function(e,i){n[i]=t[i]})}),n}function Ci(n){return ji(arguments,1).forEach(function(t){Ji(t,function(e,i){Ma(e)?n[i]=e.slice():ps(e)?n[i]=Ci({},ps(n[i])?n[i]:{},e):n[i]=e})}),n}function Zl(n,t){Te(t||fs(n),function(e){delete n[e]})}function Ue(n,t){Te(n,function(e){Te(t,function(i){e&&e.removeAttribute(i)})})}function Y(n,t,e){ps(t)?Ji(t,function(i,r){Y(n,r,i)}):Te(n,function(i){Ia(e)||e===""?Ue(i,t):i.setAttribute(t,String(e))})}function wr(n,t,e){var i=document.createElement(n);return t&&(ki(t)?Ve(i,t):Y(i,t)),e&&Ps(e,i),i}function Pe(n,t,e){if(ks(e))return getComputedStyle(n)[t];Ia(e)||(n.style[t]=""+e)}function vs(n,t){Pe(n,"display",t)}function Sh(n){n.setActive&&n.setActive()||n.focus({preventScroll:!0})}function Me(n,t){return n.getAttribute(t)}function Jl(n,t){return n&&n.classList.contains(t)}function xe(n){return n.getBoundingClientRect()}function tr(n){Te(n,function(t){t&&t.parentNode&&t.parentNode.removeChild(t)})}function Th(n){return Ds(new DOMParser().parseFromString(n,"text/html").body)}function ti(n,t){n.preventDefault(),t&&(n.stopPropagation(),n.stopImmediatePropagation())}function Eh(n,t){return n&&n.querySelector(t)}function ja(n,t){return t?ji(n.querySelectorAll(t)):[]}function si(n,t){ri(n,t,!1)}function oa(n){return n.timeStamp}function Hi(n){return ki(n)?n:n?n+"px":""}var Ms="splide",Ra="data-"+Ms;function ns(n,t){if(!n)throw new Error("["+Ms+"] "+(t||""))}var Ai=Math.min,Ln=Math.max,Fn=Math.floor,bs=Math.ceil,ae=Math.abs;function Oh(n,t,e){return ae(n-t)<e}function wn(n,t,e,i){var r=Ai(t,e),s=Ln(t,e);return i?r<n&&n<s:r<=n&&n<=s}function pr(n,t,e){var i=Ai(t,e),r=Ln(t,e);return Ai(Ln(i,n),r)}function aa(n){return+(n>0)-+(n<0)}function la(n,t){return Te(t,function(e){n=n.replace("%s",""+e)}),n}function $a(n){return n<10?"0"+n:""+n}var Ql={};function Yg(n){return""+n+$a(Ql[n]=(Ql[n]||0)+1)}function kh(){var n=[];function t(o,a,l,c){r(o,a,function(h,u,d){var p="addEventListener"in h,g=p?h.removeEventListener.bind(h,u,l,c):h.removeListener.bind(h,l);p?h.addEventListener(u,l,c):h.addListener(l),n.push([h,u,d,l,g])})}function e(o,a,l){r(o,a,function(c,h,u){n=n.filter(function(d){return d[0]===c&&d[1]===h&&d[2]===u&&(!l||d[3]===l)?(d[4](),!1):!0})})}function i(o,a,l){var c,h=!0;return typeof CustomEvent=="function"?c=new CustomEvent(a,{bubbles:h,detail:l}):(c=document.createEvent("CustomEvent"),c.initCustomEvent(a,h,!1,l)),o.dispatchEvent(c),c}function r(o,a,l){Te(o,function(c){c&&Te(a,function(h){h.split(" ").forEach(function(u){var d=u.split(".");l(c,d[0],d[1])})})})}function s(){n.forEach(function(o){o[4]()}),ui(n)}return{bind:t,unbind:e,dispatch:i,destroy:s}}var ar="mounted",tc="ready",Pi="move",Is="moved",Ah="click",Xg="active",Kg="inactive",qg="visible",Zg="hidden",Rt="refresh",de="updated",_s="resize",Ba="resized",Jg="drag",Qg="dragging",tf="dragged",Na="scroll",Lr="scrolled",ef="overflow",Ph="destroy",rf="arrows:mounted",sf="arrows:updated",nf="pagination:mounted",of="pagination:updated",Dh="navigation:mounted",Mh="autoplay:play",af="autoplay:playing",Ih="autoplay:pause",Lh="lazyload:loaded",Fh="sk",jh="sh",jn="ei";function _t(n){var t=n?n.event.bus:document.createDocumentFragment(),e=kh();function i(s,o){e.bind(t,As(s).join(" "),function(a){o.apply(o,Ma(a.detail)?a.detail:[])})}function r(s){e.dispatch(t,s,ji(arguments,1))}return n&&n.event.on(Ph,e.destroy),ms(e,{bus:t,on:i,off:at(e.unbind,t),emit:r})}function oo(n,t,e,i){var r=Date.now,s,o=0,a,l=!0,c=0;function h(){if(!l){if(o=n?Ai((r()-s)/n,1):1,e&&e(o),o>=1&&(t(),s=r(),i&&++c>=i))return d();a=ql(h)}}function u(v){v||g(),s=r()-(v?o*n:0),l=!1,a=ql(h)}function d(){l=!0}function p(){s=r(),o=0,e&&e(o)}function g(){a&&cancelAnimationFrame(a),o=0,a=0,l=!0}function f(v){n=v}function m(){return l}return{start:u,rewind:p,pause:d,cancel:g,set:f,isPaused:m}}function lf(n){var t=n;function e(r){t=r}function i(r){return La(As(r),t)}return{set:e,is:i}}function cf(n,t){var e=oo(0,n,null,1);return function(){e.isPaused()&&e.start()}}function hf(n,t,e){var i=n.state,r=e.breakpoints||{},s=e.reducedMotion||{},o=kh(),a=[];function l(){var g=e.mediaQuery==="min";fs(r).sort(function(f,m){return g?+f-+m:+m-+f}).forEach(function(f){h(r[f],"("+(g?"min":"max")+"-width:"+f+"px)")}),h(s,Kl),u()}function c(g){g&&o.destroy()}function h(g,f){var m=matchMedia(f);o.bind(m,"change",u),a.push([g,m])}function u(){var g=i.is(In),f=e.direction,m=a.reduce(function(v,y){return Ci(v,y[1].matches?y[0]:{})},{});Zl(e),p(m),e.destroy?n.destroy(e.destroy==="completely"):g?(c(!0),n.mount()):f!==e.direction&&n.refresh()}function d(g){matchMedia(Kl).matches&&(g?Ci(e,s):Zl(e,fs(s)))}function p(g,f,m){Ci(e,g),f&&Ci(Object.getPrototypeOf(e),g),(m||!i.is(br))&&n.emit(de,e)}return{setup:l,destroy:c,reduce:d,set:p}}var ao="Arrow",lo=ao+"Left",co=ao+"Right",Rh=ao+"Up",$h=ao+"Down",ec="rtl",ho="ttb",Io={width:["height"],left:["top","right"],right:["bottom","left"],x:["y"],X:["Y"],Y:["X"],ArrowLeft:[Rh,co],ArrowRight:[$h,lo]};function uf(n,t,e){function i(s,o,a){a=a||e.direction;var l=a===ec&&!o?1:a===ho?0:-1;return Io[s]&&Io[s][l]||s.replace(/width|left|right/i,function(c,h){var u=Io[c.toLowerCase()][l]||c;return h>0?u.charAt(0).toUpperCase()+u.slice(1):u})}function r(s){return s*(e.direction===ec?1:-1)}return{resolve:i,orient:r}}var ai="role",Cr="tabindex",df="disabled",je="aria-",Ls=je+"controls",Bh=je+"current",ic=je+"selected",Se=je+"label",za=je+"labelledby",Nh=je+"hidden",Ha=je+"orientation",ys=je+"roledescription",rc=je+"live",sc=je+"busy",nc=je+"atomic",Va=[ai,Cr,df,Ls,Bh,Se,za,Nh,Ha,ys],Ze=Ms+"__",Ri="is-",Lo=Ms,oc=Ze+"track",pf=Ze+"list",uo=Ze+"slide",zh=uo+"--clone",gf=uo+"__container",Ua=Ze+"arrows",po=Ze+"arrow",Hh=po+"--prev",Vh=po+"--next",go=Ze+"pagination",Uh=go+"__page",ff=Ze+"progress",mf=ff+"__bar",vf=Ze+"toggle",bf=Ze+"spinner",_f=Ze+"sr",yf=Ri+"initialized",er=Ri+"active",Wh=Ri+"prev",Gh=Ri+"next",ca=Ri+"visible",ha=Ri+"loading",Yh=Ri+"focus-in",Xh=Ri+"overflow",xf=[er,ca,Wh,Gh,ha,Yh,Xh],wf={slide:uo,clone:zh,arrows:Ua,arrow:po,prev:Hh,next:Vh,pagination:go,page:Uh,spinner:bf};function Cf(n,t){if(xh(n.closest))return n.closest(t);for(var e=n;e&&e.nodeType===1&&!gs(e,t);)e=e.parentElement;return e}var Sf=5,ac=200,Kh="touchstart mousedown",Fo="touchmove mousemove",jo="touchend touchcancel mouseup click";function Tf(n,t,e){var i=_t(n),r=i.on,s=i.bind,o=n.root,a=e.i18n,l={},c=[],h=[],u=[],d,p,g;function f(){x(),E(),y()}function m(){r(Rt,v),r(Rt,f),r(de,y),s(document,Kh+" keydown",function(C){g=C.type==="keydown"},{capture:!0}),s(o,"focusin",function(){ri(o,Yh,!!g)})}function v(C){var T=Va.concat("style");ui(c),si(o,h),si(d,u),Ue([d,p],T),Ue(o,C?T:["style",ys])}function y(){si(o,h),si(d,u),h=D(Lo),u=D(oc),Ve(o,h),Ve(d,u),Y(o,Se,e.label),Y(o,za,e.labelledby)}function x(){d=O("."+oc),p=Ds(d,"."+pf),ns(d&&p,"A track/list element is missing."),xn(c,Ch(p,"."+uo+":not(."+zh+")")),Ji({arrows:Ua,pagination:go,prev:Hh,next:Vh,bar:mf,toggle:vf},function(C,T){l[T]=O("."+C)}),ms(l,{root:o,track:d,list:p,slides:c})}function E(){var C=o.id||Yg(Ms),T=e.role;o.id=C,d.id=d.id||C+"-track",p.id=p.id||C+"-list",!Me(o,ai)&&o.tagName!=="SECTION"&&T&&Y(o,ai,T),Y(o,ys,a.carousel),Y(p,ai,"presentation")}function O(C){var T=Eh(o,C);return T&&Cf(T,"."+Lo)===o?T:void 0}function D(C){return[C+"--"+e.type,C+"--"+e.direction,e.drag&&C+"--draggable",e.isNavigation&&C+"--nav",C===Lo&&er]}return ms(l,{setup:f,mount:m,destroy:v})}var Pr="slide",Fr="loop",Fs="fade";function Ef(n,t,e,i){var r=_t(n),s=r.on,o=r.emit,a=r.bind,l=n.Components,c=n.root,h=n.options,u=h.isNavigation,d=h.updateOnMove,p=h.i18n,g=h.pagination,f=h.slideFocus,m=l.Direction.resolve,v=Me(i,"style"),y=Me(i,Se),x=e>-1,E=Ds(i,"."+gf),O;function D(){x||(i.id=c.id+"-slide"+$a(t+1),Y(i,ai,g?"tabpanel":"group"),Y(i,ys,p.slide),Y(i,Se,y||la(p.slideLabel,[t+1,n.length]))),C()}function C(){a(i,"click",at(o,Ah,$)),a(i,"keydown",at(o,Fh,$)),s([Is,jh,Lr],A),s(Dh,F),d&&s(Pi,j)}function T(){O=!0,r.destroy(),si(i,xf),Ue(i,Va),Y(i,"style",v),Y(i,Se,y||"")}function F(){var B=n.splides.map(function(M){var H=M.splide.Components.Slides.getAt(t);return H?H.slide.id:""}).join(" ");Y(i,Se,la(p.slideX,(x?e:t)+1)),Y(i,Ls,B),Y(i,ai,f?"button":""),f&&Ue(i,ys)}function j(){O||A()}function A(){if(!O){var B=n.index;k(),P(),ri(i,Wh,t===B-1),ri(i,Gh,t===B+1)}}function k(){var B=z();B!==Jl(i,er)&&(ri(i,er,B),Y(i,Bh,u&&B||""),o(B?Xg:Kg,$))}function P(){var B=X(),M=!B&&(!z()||x);if(n.state.is([Ir,Os])||Y(i,Nh,M||""),Y(ja(i,h.focusableNodes||""),Cr,M?-1:""),f&&Y(i,Cr,M?-1:0),B!==Jl(i,ca)&&(ri(i,ca,B),o(B?qg:Zg,$)),!B&&document.activeElement===i){var H=l.Slides.getAt(n.index);H&&Sh(H.slide)}}function L(B,M,H){Pe(H&&E||i,B,M)}function z(){var B=n.index;return B===t||h.cloneStatus&&B===e}function X(){if(n.is(Fs))return z();var B=xe(l.Elements.track),M=xe(i),H=m("left",!0),Q=m("right",!0);return Fn(B[H])<=bs(M[H])&&Fn(M[Q])<=bs(B[Q])}function J(B,M){var H=ae(B-t);return!x&&(h.rewind||n.is(Fr))&&(H=Ai(H,n.length-H)),H<=M}var $={index:t,slideIndex:e,slide:i,container:E,isClone:x,mount:D,destroy:T,update:A,style:L,isWithin:J};return $}function Of(n,t,e){var i=_t(n),r=i.on,s=i.emit,o=i.bind,a=t.Elements,l=a.slides,c=a.list,h=[];function u(){d(),r(Rt,p),r(Rt,d)}function d(){l.forEach(function(A,k){f(A,k,-1)})}function p(){O(function(A){A.destroy()}),ui(h)}function g(){O(function(A){A.update()})}function f(A,k,P){var L=Ef(n,k,P,A);L.mount(),h.push(L),h.sort(function(z,X){return z.index-X.index})}function m(A){return A?D(function(k){return!k.isClone}):h}function v(A){var k=t.Controller,P=k.toIndex(A),L=k.hasFocus()?1:e.perPage;return D(function(z){return wn(z.index,P,P+L-1)})}function y(A){return D(A)[0]}function x(A,k){Te(A,function(P){if(ki(P)&&(P=Th(P)),wh(P)){var L=l[k];L?Fa(P,L):Ps(c,P),Ve(P,e.classes.slide),T(P,at(s,_s))}}),s(Rt)}function E(A){tr(D(A).map(function(k){return k.slide})),s(Rt)}function O(A,k){m(k).forEach(A)}function D(A){return h.filter(xh(A)?A:function(k){return ki(A)?gs(k.slide,A):La(As(A),k.index)})}function C(A,k,P){O(function(L){L.style(A,k,P)})}function T(A,k){var P=ja(A,"img"),L=P.length;L?P.forEach(function(z){o(z,"load error",function(){--L||k()})}):k()}function F(A){return A?l.length:h.length}function j(){return h.length>e.perPage}return{mount:u,destroy:p,update:g,register:f,get:m,getIn:v,getAt:y,add:x,remove:E,forEach:O,filter:D,style:C,getLength:F,isEnough:j}}function kf(n,t,e){var i=_t(n),r=i.on,s=i.bind,o=i.emit,a=t.Slides,l=t.Direction.resolve,c=t.Elements,h=c.root,u=c.track,d=c.list,p=a.getAt,g=a.style,f,m,v;function y(){x(),s(window,"resize load",cf(at(o,_s))),r([de,Rt],x),r(_s,E)}function x(){f=e.direction===ho,Pe(h,"maxWidth",Hi(e.width)),Pe(u,l("paddingLeft"),O(!1)),Pe(u,l("paddingRight"),O(!0)),E(!0)}function E($){var B=xe(h);($||m.width!==B.width||m.height!==B.height)&&(Pe(u,"height",D()),g(l("marginRight"),Hi(e.gap)),g("width",T()),g("height",F(),!0),m=B,o(Ba),v!==(v=J())&&(ri(h,Xh,v),o(ef,v)))}function O($){var B=e.padding,M=l($?"right":"left");return B&&Hi(B[M]||(ps(B)?0:B))||"0px"}function D(){var $="";return f&&($=C(),ns($,"height or heightRatio is missing."),$="calc("+$+" - "+O(!1)+" - "+O(!0)+")"),$}function C(){return Hi(e.height||xe(d).width*e.heightRatio)}function T(){return e.autoWidth?null:Hi(e.fixedWidth)||(f?"":j())}function F(){return Hi(e.fixedHeight)||(f?e.autoHeight?null:j():C())}function j(){var $=Hi(e.gap);return"calc((100%"+($&&" + "+$)+")/"+(e.perPage||1)+($&&" - "+$)+")"}function A(){return xe(d)[l("width")]}function k($,B){var M=p($||0);return M?xe(M.slide)[l("width")]+(B?0:z()):0}function P($,B){var M=p($);if(M){var H=xe(M.slide)[l("right")],Q=xe(d)[l("left")];return ae(H-Q)+(B?0:z())}return 0}function L($){return P(n.length-1)-P(0)+k(0,$)}function z(){var $=p(0);return $&&parseFloat(Pe($.slide,l("marginRight")))||0}function X($){return parseFloat(Pe(u,l("padding"+($?"Right":"Left"))))||0}function J(){return n.is(Fs)||L(!0)>A()}return{mount:y,resize:E,listSize:A,slideSize:k,sliderSize:L,totalSize:P,getPadding:X,isOverflow:J}}var Af=2;function Pf(n,t,e){var i=_t(n),r=i.on,s=t.Elements,o=t.Slides,a=t.Direction.resolve,l=[],c;function h(){r(Rt,u),r([de,_s],p),(c=m())&&(g(c),t.Layout.resize(!0))}function u(){d(),h()}function d(){tr(l),ui(l),i.destroy()}function p(){var v=m();c!==v&&(c<v||!v)&&i.emit(Rt)}function g(v){var y=o.get().slice(),x=y.length;if(x){for(;y.length<v;)xn(y,y);xn(y.slice(-v),y.slice(0,v)).forEach(function(E,O){var D=O<v,C=f(E.slide,O);D?Fa(C,y[0].slide):Ps(s.list,C),xn(l,C),o.register(C,O-v+(D?0:x),E.index)})}}function f(v,y){var x=v.cloneNode(!0);return Ve(x,e.classes.clone),x.id=n.root.id+"-clone"+$a(y+1),x}function m(){var v=e.clones;if(!n.is(Fr))v=0;else if(ks(v)){var y=e[a("fixedWidth")]&&t.Layout.slideSize(0),x=y&&bs(xe(s.track)[a("width")]/y);v=x||e[a("autoWidth")]&&n.length||e.perPage*Af}return v}return{mount:h,destroy:d}}function Df(n,t,e){var i=_t(n),r=i.on,s=i.emit,o=n.state.set,a=t.Layout,l=a.slideSize,c=a.getPadding,h=a.totalSize,u=a.listSize,d=a.sliderSize,p=t.Direction,g=p.resolve,f=p.orient,m=t.Elements,v=m.list,y=m.track,x;function E(){x=t.Transition,r([ar,Ba,de,Rt],O)}function O(){t.Controller.isBusy()||(t.Scroll.cancel(),C(n.index),t.Slides.update())}function D(M,H,Q,Ct){M!==H&&$(M>Q)&&(A(),T(j(L(),M>Q),!0)),o(Ir),s(Pi,H,Q,M),x.start(H,function(){o(Ar),s(Is,H,Q,M),Ct&&Ct()})}function C(M){T(P(M,!0))}function T(M,H){if(!n.is(Fs)){var Q=H?M:F(M);Pe(v,"transform","translate"+g("X")+"("+Q+"px)"),M!==Q&&s(jh)}}function F(M){if(n.is(Fr)){var H=k(M),Q=H>t.Controller.getEnd(),Ct=H<0;(Ct||Q)&&(M=j(M,Q))}return M}function j(M,H){var Q=M-J(H),Ct=d();return M-=f(Ct*(bs(ae(Q)/Ct)||1))*(H?1:-1),M}function A(){T(L(),!0),x.cancel()}function k(M){for(var H=t.Slides.get(),Q=0,Ct=1/0,ot=0;ot<H.length;ot++){var ge=H[ot].index,I=ae(P(ge,!0)-M);if(I<=Ct)Ct=I,Q=ge;else break}return Q}function P(M,H){var Q=f(h(M-1)-X(M));return H?z(Q):Q}function L(){var M=g("left");return xe(v)[M]-xe(y)[M]+f(c(!1))}function z(M){return e.trimSpace&&n.is(Pr)&&(M=pr(M,0,f(d(!0)-u()))),M}function X(M){var H=e.focus;return H==="center"?(u()-l(M,!0))/2:+H*l(M)||0}function J(M){return P(M?t.Controller.getEnd():0,!!e.trimSpace)}function $(M){var H=f(j(L(),M));return M?H>=0:H<=v[g("scrollWidth")]-xe(y)[g("width")]}function B(M,H){H=ks(H)?L():H;var Q=M!==!0&&f(H)<f(J(!1)),Ct=M!==!1&&f(H)>f(J(!0));return Q||Ct}return{mount:E,move:D,jump:C,translate:T,shift:j,cancel:A,toIndex:k,toPosition:P,getPosition:L,getLimit:J,exceededLimit:B,reposition:O}}function Mf(n,t,e){var i=_t(n),r=i.on,s=i.emit,o=t.Move,a=o.getPosition,l=o.getLimit,c=o.toPosition,h=t.Slides,u=h.isEnough,d=h.getLength,p=e.omitEnd,g=n.is(Fr),f=n.is(Pr),m=at(L,!1),v=at(L,!0),y=e.start||0,x,E=y,O,D,C;function T(){F(),r([de,Rt,jn],F),r(Ba,j)}function F(){O=d(!0),D=e.perMove,C=e.perPage,x=$();var I=pr(y,0,p?x:O-1);I!==y&&(y=I,o.reposition())}function j(){x!==$()&&s(jn)}function A(I,et,Wt){if(!ge()){var ht=P(I),ut=J(ht);ut>-1&&(et||ut!==y)&&(Q(ut),o.move(ht,ut,E,Wt))}}function k(I,et,Wt,ht){t.Scroll.scroll(I,et,Wt,function(){var ut=J(o.toIndex(a()));Q(p?Ai(ut,x):ut),ht&&ht()})}function P(I){var et=y;if(ki(I)){var Wt=I.match(/([+\-<>])(\d+)?/)||[],ht=Wt[1],ut=Wt[2];ht==="+"||ht==="-"?et=z(y+ +(""+ht+(+ut||1)),y):ht===">"?et=ut?B(+ut):m(!0):ht==="<"&&(et=v(!0))}else et=g?I:pr(I,0,x);return et}function L(I,et){var Wt=D||(ot()?1:C),ht=z(y+Wt*(I?-1:1),y,!(D||ot()));return ht===-1&&f&&!Oh(a(),l(!I),1)?I?0:x:et?ht:J(ht)}function z(I,et,Wt){if(u()||ot()){var ht=X(I);ht!==I&&(et=I,I=ht,Wt=!1),I<0||I>x?!D&&(wn(0,I,et,!0)||wn(x,et,I,!0))?I=B(M(I)):g?I=Wt?I<0?-(O%C||C):O:I:e.rewind?I=I<0?x:0:I=-1:Wt&&I!==et&&(I=B(M(et)+(I<et?-1:1)))}else I=-1;return I}function X(I){if(f&&e.trimSpace==="move"&&I!==y)for(var et=a();et===c(I,!0)&&wn(I,0,n.length-1,!e.rewind);)I<y?--I:++I;return I}function J(I){return g?(I+O)%O||0:I}function $(){for(var I=O-(ot()||g&&D?1:C);p&&I-- >0;)if(c(O-1,!0)!==c(I,!0)){I++;break}return pr(I,0,O-1)}function B(I){return pr(ot()?I:C*I,0,x)}function M(I){return ot()?Ai(I,x):Fn((I>=x?O-1:I)/C)}function H(I){var et=o.toIndex(I);return f?pr(et,0,x):et}function Q(I){I!==y&&(E=y,y=I)}function Ct(I){return I?E:y}function ot(){return!ks(e.focus)||e.isNavigation}function ge(){return n.state.is([Ir,Os])&&!!e.waitForTransition}return{mount:T,go:A,scroll:k,getNext:m,getPrev:v,getAdjacent:L,getEnd:$,setIndex:Q,getIndex:Ct,toIndex:B,toPage:M,toDest:H,hasFocus:ot,isBusy:ge}}var If="http://www.w3.org/2000/svg",Lf="m15.5 0.932-4.3 4.38 14.5 14.6-14.5 14.5 4.3 4.4 14.6-14.6 4.4-4.3-4.4-4.4-14.6-14.6z",Gs=40;function Ff(n,t,e){var i=_t(n),r=i.on,s=i.bind,o=i.emit,a=e.classes,l=e.i18n,c=t.Elements,h=t.Controller,u=c.arrows,d=c.track,p=u,g=c.prev,f=c.next,m,v,y={};function x(){O(),r(de,E)}function E(){D(),x()}function O(){var k=e.arrows;k&&!(g&&f)&&F(),g&&f&&(ms(y,{prev:g,next:f}),vs(p,k?"":"none"),Ve(p,v=Ua+"--"+e.direction),k&&(C(),A(),Y([g,f],Ls,d.id),o(rf,g,f)))}function D(){i.destroy(),si(p,v),m?(tr(u?[g,f]:p),g=f=null):Ue([g,f],Va)}function C(){r([ar,Is,Rt,Lr,jn],A),s(f,"click",at(T,">")),s(g,"click",at(T,"<"))}function T(k){h.go(k,!0)}function F(){p=u||wr("div",a.arrows),g=j(!0),f=j(!1),m=!0,Ps(p,[g,f]),!u&&Fa(p,d)}function j(k){var P='<button class="'+a.arrow+" "+(k?a.prev:a.next)+'" type="button"><svg xmlns="'+If+'" viewBox="0 0 '+Gs+" "+Gs+'" width="'+Gs+'" height="'+Gs+'" focusable="false"><path d="'+(e.arrowPath||Lf)+'" />';return Th(P)}function A(){if(g&&f){var k=n.index,P=h.getPrev(),L=h.getNext(),z=P>-1&&k<P?l.last:l.prev,X=L>-1&&k>L?l.first:l.next;g.disabled=P<0,f.disabled=L<0,Y(g,Se,z),Y(f,Se,X),o(sf,g,f,P,L)}}return{arrows:y,mount:x,destroy:D,update:A}}var jf=Ra+"-interval";function Rf(n,t,e){var i=_t(n),r=i.on,s=i.bind,o=i.emit,a=oo(e.interval,n.go.bind(n,">"),C),l=a.isPaused,c=t.Elements,h=t.Elements,u=h.root,d=h.toggle,p=e.autoplay,g,f,m=p==="pause";function v(){p&&(y(),d&&Y(d,Ls,c.track.id),m||x(),D())}function y(){e.pauseOnHover&&s(u,"mouseenter mouseleave",function(F){g=F.type==="mouseenter",O()}),e.pauseOnFocus&&s(u,"focusin focusout",function(F){f=F.type==="focusin",O()}),d&&s(d,"click",function(){m?x():E(!0)}),r([Pi,Na,Rt],a.rewind),r(Pi,T)}function x(){l()&&t.Slides.isEnough()&&(a.start(!e.resetProgress),f=g=m=!1,D(),o(Mh))}function E(F){F===void 0&&(F=!0),m=!!F,D(),l()||(a.pause(),o(Ih))}function O(){m||(g||f?E(!1):x())}function D(){d&&(ri(d,er,!m),Y(d,Se,e.i18n[m?"play":"pause"]))}function C(F){var j=c.bar;j&&Pe(j,"width",F*100+"%"),o(af,F)}function T(F){var j=t.Slides.getAt(F);a.set(j&&+Me(j.slide,jf)||e.interval)}return{mount:v,destroy:a.cancel,play:x,pause:E,isPaused:l}}function $f(n,t,e){var i=_t(n),r=i.on;function s(){e.cover&&(r(Lh,at(a,!0)),r([ar,de,Rt],at(o,!0)))}function o(l){t.Slides.forEach(function(c){var h=Ds(c.container||c.slide,"img");h&&h.src&&a(l,h,c)})}function a(l,c,h){h.style("background",l?'center/cover no-repeat url("'+c.src+'")':"",!0),vs(c,l?"none":"")}return{mount:s,destroy:at(o,!1)}}var Bf=10,Nf=600,zf=.6,Hf=1.5,Vf=800;function Uf(n,t,e){var i=_t(n),r=i.on,s=i.emit,o=n.state.set,a=t.Move,l=a.getPosition,c=a.getLimit,h=a.exceededLimit,u=a.translate,d=n.is(Pr),p,g,f=1;function m(){r(Pi,E),r([de,Rt],O)}function v(C,T,F,j,A){var k=l();if(E(),F&&(!d||!h())){var P=t.Layout.sliderSize(),L=aa(C)*P*Fn(ae(C)/P)||0;C=a.toPosition(t.Controller.toDest(C%P))+L}var z=Oh(k,C,1);f=1,T=z?0:T||Ln(ae(C-k)/Hf,Vf),g=j,p=oo(T,y,at(x,k,C,A),1),o(Os),s(Na),p.start()}function y(){o(Ar),g&&g(),s(Lr)}function x(C,T,F,j){var A=l(),k=C+(T-C)*D(j),P=(k-A)*f;u(A+P),d&&!F&&h()&&(f*=zf,ae(P)<Bf&&v(c(h(!0)),Nf,!1,g,!0))}function E(){p&&p.cancel()}function O(){p&&!p.isPaused()&&(E(),y())}function D(C){var T=e.easingFunc;return T?T(C):1-Math.pow(1-C,4)}return{mount:m,destroy:E,scroll:v,cancel:O}}var gr={passive:!1,capture:!0};function Wf(n,t,e){var i=_t(n),r=i.on,s=i.emit,o=i.bind,a=i.unbind,l=n.state,c=t.Move,h=t.Scroll,u=t.Controller,d=t.Elements.track,p=t.Media.reduce,g=t.Direction,f=g.resolve,m=g.orient,v=c.getPosition,y=c.exceededLimit,x,E,O,D,C,T=!1,F,j,A;function k(){o(d,Fo,na,gr),o(d,jo,na,gr),o(d,Kh,L,gr),o(d,"click",J,{capture:!0}),o(d,"dragstart",ti),r([ar,de],P)}function P(){var N=e.drag;gl(!N),D=N==="free"}function L(N){if(F=!1,!j){var dt=ut(N);ht(N.target)&&(dt||!N.button)&&(u.isBusy()?ti(N,!0):(A=dt?d:window,C=l.is([Ir,Os]),O=null,o(A,Fo,z,gr),o(A,jo,X,gr),c.cancel(),h.cancel(),$(N)))}}function z(N){if(l.is(yn)||(l.set(yn),s(Jg)),N.cancelable)if(C){c.translate(x+Wt(ot(N)));var dt=ge(N)>ac,Ni=T!==(T=y());(dt||Ni)&&$(N),F=!0,s(Qg),ti(N)}else H(N)&&(C=M(N),ti(N))}function X(N){l.is(yn)&&(l.set(Ar),s(tf)),C&&(B(N),ti(N)),a(A,Fo,z),a(A,jo,X),C=!1}function J(N){!j&&F&&ti(N,!0)}function $(N){O=E,E=N,x=v()}function B(N){var dt=Q(N),Ni=Ct(dt),Vr=e.rewind&&e.rewindByDrag;p(!1),D?u.scroll(Ni,0,e.snap):n.is(Fs)?u.go(m(aa(dt))<0?Vr?"<":"-":Vr?">":"+"):n.is(Pr)&&T&&Vr?u.go(y(!0)?">":"<"):u.go(u.toDest(Ni),!0),p(!0)}function M(N){var dt=e.dragMinThreshold,Ni=ps(dt),Vr=Ni&&dt.mouse||0,td=(Ni?dt.touch:+dt)||10;return ae(ot(N))>(ut(N)?td:Vr)}function H(N){return ae(ot(N))>ae(ot(N,!0))}function Q(N){if(n.is(Fr)||!T){var dt=ge(N);if(dt&&dt<ac)return ot(N)/dt}return 0}function Ct(N){return v()+aa(N)*Ai(ae(N)*(e.flickPower||600),D?1/0:t.Layout.listSize()*(e.flickMaxPages||1))}function ot(N,dt){return et(N,dt)-et(I(N),dt)}function ge(N){return oa(N)-oa(I(N))}function I(N){return E===N&&O||E}function et(N,dt){return(ut(N)?N.changedTouches[0]:N)["page"+f(dt?"Y":"X")]}function Wt(N){return N/(T&&n.is(Pr)?Sf:1)}function ht(N){var dt=e.noDrag;return!gs(N,"."+Uh+", ."+po)&&(!dt||!gs(N,dt))}function ut(N){return typeof TouchEvent<"u"&&N instanceof TouchEvent}function Qu(){return C}function gl(N){j=N}return{mount:k,disable:gl,isDragging:Qu}}var Gf={Spacebar:" ",Right:co,Left:lo,Up:Rh,Down:$h};function Wa(n){return n=ki(n)?n:n.key,Gf[n]||n}var lc="keydown";function Yf(n,t,e){var i=_t(n),r=i.on,s=i.bind,o=i.unbind,a=n.root,l=t.Direction.resolve,c,h;function u(){d(),r(de,p),r(de,d),r(Pi,f)}function d(){var v=e.keyboard;v&&(c=v==="global"?window:a,s(c,lc,m))}function p(){o(c,lc)}function g(v){h=v}function f(){var v=h;h=!0,yh(function(){h=v})}function m(v){if(!h){var y=Wa(v);y===l(lo)?n.go("<"):y===l(co)&&n.go(">")}}return{mount:u,destroy:p,disable:g}}var os=Ra+"-lazy",Cn=os+"-srcset",Xf="["+os+"], ["+Cn+"]";function Kf(n,t,e){var i=_t(n),r=i.on,s=i.off,o=i.bind,a=i.emit,l=e.lazyLoad==="sequential",c=[Is,Lr],h=[];function u(){e.lazyLoad&&(d(),r(Rt,d))}function d(){ui(h),p(),l?v():(s(c),r(c,g),g())}function p(){t.Slides.forEach(function(y){ja(y.slide,Xf).forEach(function(x){var E=Me(x,os),O=Me(x,Cn);if(E!==x.src||O!==x.srcset){var D=e.classes.spinner,C=x.parentElement,T=Ds(C,"."+D)||wr("span",D,C);h.push([x,y,T]),x.src||vs(x,"none")}})})}function g(){h=h.filter(function(y){var x=e.perPage*((e.preloadPages||1)+1)-1;return y[1].isWithin(n.index,x)?f(y):!0}),h.length||s(c)}function f(y){var x=y[0];Ve(y[1].slide,ha),o(x,"load error",at(m,y)),Y(x,"src",Me(x,os)),Y(x,"srcset",Me(x,Cn)),Ue(x,os),Ue(x,Cn)}function m(y,x){var E=y[0],O=y[1];si(O.slide,ha),x.type!=="error"&&(tr(y[2]),vs(E,""),a(Lh,E,O),a(_s)),l&&v()}function v(){h.length&&f(h.shift())}return{mount:u,destroy:at(ui,h),check:g}}function qf(n,t,e){var i=_t(n),r=i.on,s=i.emit,o=i.bind,a=t.Slides,l=t.Elements,c=t.Controller,h=c.hasFocus,u=c.getIndex,d=c.go,p=t.Direction.resolve,g=l.pagination,f=[],m,v;function y(){x(),r([de,Rt,jn],y);var j=e.pagination;g&&vs(g,j?"":"none"),j&&(r([Pi,Na,Lr],F),E(),F(),s(nf,{list:m,items:f},T(n.index)))}function x(){m&&(tr(g?ji(m.children):m),si(m,v),ui(f),m=null),i.destroy()}function E(){var j=n.length,A=e.classes,k=e.i18n,P=e.perPage,L=h()?c.getEnd()+1:bs(j/P);m=g||wr("ul",A.pagination,l.track.parentElement),Ve(m,v=go+"--"+C()),Y(m,ai,"tablist"),Y(m,Se,k.select),Y(m,Ha,C()===ho?"vertical":"");for(var z=0;z<L;z++){var X=wr("li",null,m),J=wr("button",{class:A.page,type:"button"},X),$=a.getIn(z).map(function(M){return M.slide.id}),B=!h()&&P>1?k.pageX:k.slideX;o(J,"click",at(O,z)),e.paginationKeyboard&&o(J,"keydown",at(D,z)),Y(X,ai,"presentation"),Y(J,ai,"tab"),Y(J,Ls,$.join(" ")),Y(J,Se,la(B,z+1)),Y(J,Cr,-1),f.push({li:X,button:J,page:z})}}function O(j){d(">"+j,!0)}function D(j,A){var k=f.length,P=Wa(A),L=C(),z=-1;P===p(co,!1,L)?z=++j%k:P===p(lo,!1,L)?z=(--j+k)%k:P==="Home"?z=0:P==="End"&&(z=k-1);var X=f[z];X&&(Sh(X.button),d(">"+z),ti(A,!0))}function C(){return e.paginationDirection||e.direction}function T(j){return f[c.toPage(j)]}function F(){var j=T(u(!0)),A=T(u());if(j){var k=j.button;si(k,er),Ue(k,ic),Y(k,Cr,-1)}if(A){var P=A.button;Ve(P,er),Y(P,ic,!0),Y(P,Cr,"")}s(of,{list:m,items:f},j,A)}return{items:f,mount:y,destroy:x,getAt:T,update:F}}var Zf=[" ","Enter"];function Jf(n,t,e){var i=e.isNavigation,r=e.slideFocus,s=[];function o(){n.splides.forEach(function(g){g.isParent||(c(n,g.splide),c(g.splide,n))}),i&&h()}function a(){s.forEach(function(g){g.destroy()}),ui(s)}function l(){a(),o()}function c(g,f){var m=_t(g);m.on(Pi,function(v,y,x){f.go(f.is(Fr)?x:v)}),s.push(m)}function h(){var g=_t(n),f=g.on;f(Ah,d),f(Fh,p),f([ar,de],u),s.push(g),g.emit(Dh,n.splides)}function u(){Y(t.Elements.list,Ha,e.direction===ho?"vertical":"")}function d(g){n.go(g.index)}function p(g,f){La(Zf,Wa(f))&&(d(g),ti(f))}return{setup:at(t.Media.set,{slideFocus:ks(r)?i:r},!0),mount:o,destroy:a,remount:l}}function Qf(n,t,e){var i=_t(n),r=i.bind,s=0;function o(){e.wheel&&r(t.Elements.track,"wheel",a,gr)}function a(c){if(c.cancelable){var h=c.deltaY,u=h<0,d=oa(c),p=e.wheelMinThreshold||0,g=e.wheelSleep||0;ae(h)>p&&d-s>g&&(n.go(u?"<":">"),s=d),l(u)&&ti(c)}}function l(c){return!e.releaseWheel||n.state.is(Ir)||t.Controller.getAdjacent(c)!==-1}return{mount:o}}var tm=90;function em(n,t,e){var i=_t(n),r=i.on,s=t.Elements.track,o=e.live&&!e.isNavigation,a=wr("span",_f),l=oo(tm,at(h,!1));function c(){o&&(d(!t.Autoplay.isPaused()),Y(s,nc,!0),a.textContent="…",r(Mh,at(d,!0)),r(Ih,at(d,!1)),r([Is,Lr],at(h,!0)))}function h(p){Y(s,sc,p),p?(Ps(s,a),l.start()):(tr(a),l.cancel())}function u(){Ue(s,[rc,nc,sc]),tr(a)}function d(p){o&&Y(s,rc,p?"off":"polite")}return{mount:c,disable:d,destroy:u}}var im=Object.freeze({__proto__:null,Media:hf,Direction:uf,Elements:Tf,Slides:Of,Layout:kf,Clones:Pf,Move:Df,Controller:Mf,Arrows:Ff,Autoplay:Rf,Cover:$f,Scroll:Uf,Drag:Wf,Keyboard:Yf,LazyLoad:Kf,Pagination:qf,Sync:Jf,Wheel:Qf,Live:em}),rm={prev:"Previous slide",next:"Next slide",first:"Go to first slide",last:"Go to last slide",slideX:"Go to slide %s",pageX:"Go to page %s",play:"Start autoplay",pause:"Pause autoplay",carousel:"carousel",slide:"slide",select:"Select a slide to show",slideLabel:"%s of %s"},sm={type:"slide",role:"region",speed:400,perPage:1,cloneStatus:!0,arrows:!0,pagination:!0,paginationKeyboard:!0,interval:5e3,pauseOnHover:!0,pauseOnFocus:!0,resetProgress:!0,easing:"cubic-bezier(0.25, 1, 0.5, 1)",drag:!0,direction:"ltr",trimSpace:!0,focusableNodes:"a, button, textarea, input, select, iframe",live:!0,classes:wf,i18n:rm,reducedMotion:{speed:0,rewindSpeed:0,autoplay:"pause"}};function nm(n,t,e){var i=t.Slides;function r(){_t(n).on([ar,Rt],s)}function s(){i.forEach(function(a){a.style("transform","translateX(-"+100*a.index+"%)")})}function o(a,l){i.style("transition","opacity "+e.speed+"ms "+e.easing),yh(l)}return{mount:r,start:o,cancel:na}}function om(n,t,e){var i=t.Move,r=t.Controller,s=t.Scroll,o=t.Elements.list,a=at(Pe,o,"transition"),l;function c(){_t(n).bind(o,"transitionend",function(p){p.target===o&&l&&(u(),l())})}function h(p,g){var f=i.toPosition(p,!0),m=i.getPosition(),v=d(p);ae(f-m)>=1&&v>=1?e.useScroll?s.scroll(f,v,!1,g):(a("transform "+v+"ms "+e.easing),i.translate(f,!0),l=g):(i.jump(p),g())}function u(){a(""),s.cancel()}function d(p){var g=e.rewindSpeed;if(n.is(Pr)&&g){var f=r.getIndex(!0),m=r.getEnd();if(f===0&&p>=m||f>=m&&p===0)return g}return e.speed}return{mount:c,start:h,cancel:u}}var am=function(){function n(e,i){this.event=_t(),this.Components={},this.state=lf(br),this.splides=[],this._o={},this._E={};var r=ki(e)?Eh(document,e):e;ns(r,r+" is invalid."),this.root=r,i=Ci({label:Me(r,Se)||"",labelledby:Me(r,za)||""},sm,n.defaults,i||{});try{Ci(i,JSON.parse(Me(r,Ra)))}catch{ns(!1,"Invalid JSON")}this._o=Object.create(Ci({},i))}var t=n.prototype;return t.mount=function(i,r){var s=this,o=this.state,a=this.Components;ns(o.is([br,In]),"Already mounted!"),o.set(br),this._C=a,this._T=r||this._T||(this.is(Fs)?nm:om),this._E=i||this._E;var l=ms({},im,this._E,{Transition:this._T});return Ji(l,function(c,h){var u=c(s,a,s._o);a[h]=u,u.setup&&u.setup()}),Ji(a,function(c){c.mount&&c.mount()}),this.emit(ar),Ve(this.root,yf),o.set(Ar),this.emit(tc),this},t.sync=function(i){return this.splides.push({splide:i}),i.splides.push({splide:this,isParent:!0}),this.state.is(Ar)&&(this._C.Sync.remount(),i.Components.Sync.remount()),this},t.go=function(i){return this._C.Controller.go(i),this},t.on=function(i,r){return this.event.on(i,r),this},t.off=function(i){return this.event.off(i),this},t.emit=function(i){var r;return(r=this.event).emit.apply(r,[i].concat(ji(arguments,1))),this},t.add=function(i,r){return this._C.Slides.add(i,r),this},t.remove=function(i){return this._C.Slides.remove(i),this},t.is=function(i){return this._o.type===i},t.refresh=function(){return this.emit(Rt),this},t.destroy=function(i){i===void 0&&(i=!0);var r=this.event,s=this.state;return s.is(br)?_t(this).on(tc,this.destroy.bind(this,i)):(Ji(this._C,function(o){o.destroy&&o.destroy(i)},!0),r.emit(Ph),r.destroy(),i&&ui(this.splides),s.set(In)),this},Ug(n,[{key:"options",get:function(){return this._o},set:function(i){this._C.Media.set(i,!0,!0)}},{key:"length",get:function(){return this._C.Slides.getLength(!0)}},{key:"index",get:function(){return this._C.Controller.getIndex()}}]),n}(),Ga=am;Ga.defaults={};Ga.STATES=Gg;/**
|
|
2062
|
+
*/var Kl="(prefers-reduced-motion: reduce)",bs=1,Wg=2,As=3,Is=4,Er=5,_n=6,Mn=7,Gg={CREATED:bs,MOUNTED:Wg,IDLE:As,MOVING:Is,SCROLLING:Er,DRAGGING:_n,DESTROYED:Mn};function di(n){n.length=0}function ji(n,t,e){return Array.prototype.slice.call(n,t,e)}function lt(n){return n.bind.apply(n,[null].concat(ji(arguments,1)))}var yh=setTimeout,na=function(){};function ql(n){return requestAnimationFrame(n)}function ro(n,t){return typeof t===n}function dr(n){return!Ia(n)&&ro("object",n)}var Ma=Array.isArray,xh=lt(ro,"function"),ki=lt(ro,"string"),Or=lt(ro,"undefined");function Ia(n){return n===null}function wh(n){try{return n instanceof(n.ownerDocument.defaultView||window).HTMLElement}catch{return!1}}function kr(n){return Ma(n)?n:[n]}function Te(n,t){kr(n).forEach(t)}function La(n,t){return n.indexOf(t)>-1}function yn(n,t){return n.push.apply(n,kr(t)),n}function si(n,t,e){n&&Te(t,function(i){i&&n.classList[e?"add":"remove"](i)})}function Ve(n,t){si(n,ki(t)?t.split(" "):t,!0)}function Ar(n,t){Te(t,n.appendChild.bind(n))}function Fa(n,t){Te(n,function(e){var i=(t||e).parentNode;i&&i.insertBefore(e,t)})}function pr(n,t){return wh(n)&&(n.msMatchesSelector||n.matches).call(n,t)}function Ch(n,t){var e=n?ji(n.children):[];return t?e.filter(function(i){return pr(i,t)}):e}function Pr(n,t){return t?Ch(n,t)[0]:n.firstElementChild}var gr=Object.keys;function Ji(n,t,e){return n&&(e?gr(n).reverse():gr(n)).forEach(function(i){i!=="__proto__"&&t(n[i],i)}),n}function fr(n){return ji(arguments,1).forEach(function(t){Ji(t,function(e,i){n[i]=t[i]})}),n}function Si(n){return ji(arguments,1).forEach(function(t){Ji(t,function(e,i){Ma(e)?n[i]=e.slice():dr(e)?n[i]=Si({},dr(n[i])?n[i]:{},e):n[i]=e})}),n}function Zl(n,t){Te(t||gr(n),function(e){delete n[e]})}function Ue(n,t){Te(n,function(e){Te(t,function(i){e&&e.removeAttribute(i)})})}function Y(n,t,e){dr(t)?Ji(t,function(i,s){Y(n,s,i)}):Te(n,function(i){Ia(e)||e===""?Ue(i,t):i.setAttribute(t,String(e))})}function ws(n,t,e){var i=document.createElement(n);return t&&(ki(t)?Ve(i,t):Y(i,t)),e&&Ar(e,i),i}function Pe(n,t,e){if(Or(e))return getComputedStyle(n)[t];Ia(e)||(n.style[t]=""+e)}function mr(n,t){Pe(n,"display",t)}function Sh(n){n.setActive&&n.setActive()||n.focus({preventScroll:!0})}function Me(n,t){return n.getAttribute(t)}function Jl(n,t){return n&&n.classList.contains(t)}function xe(n){return n.getBoundingClientRect()}function ts(n){Te(n,function(t){t&&t.parentNode&&t.parentNode.removeChild(t)})}function Th(n){return Pr(new DOMParser().parseFromString(n,"text/html").body)}function ti(n,t){n.preventDefault(),t&&(n.stopPropagation(),n.stopImmediatePropagation())}function Eh(n,t){return n&&n.querySelector(t)}function ja(n,t){return t?ji(n.querySelectorAll(t)):[]}function ri(n,t){si(n,t,!1)}function oa(n){return n.timeStamp}function Hi(n){return ki(n)?n:n?n+"px":""}var Dr="splide",Ra="data-"+Dr;function rr(n,t){if(!n)throw new Error("["+Dr+"] "+(t||""))}var Ai=Math.min,In=Math.max,Ln=Math.floor,vr=Math.ceil,ae=Math.abs;function Oh(n,t,e){return ae(n-t)<e}function xn(n,t,e,i){var s=Ai(t,e),r=In(t,e);return i?s<n&&n<r:s<=n&&n<=r}function ps(n,t,e){var i=Ai(t,e),s=In(t,e);return Ai(In(i,n),s)}function aa(n){return+(n>0)-+(n<0)}function la(n,t){return Te(t,function(e){n=n.replace("%s",""+e)}),n}function $a(n){return n<10?"0"+n:""+n}var Ql={};function Yg(n){return""+n+$a(Ql[n]=(Ql[n]||0)+1)}function kh(){var n=[];function t(o,a,l,c){s(o,a,function(h,u,d){var p="addEventListener"in h,g=p?h.removeEventListener.bind(h,u,l,c):h.removeListener.bind(h,l);p?h.addEventListener(u,l,c):h.addListener(l),n.push([h,u,d,l,g])})}function e(o,a,l){s(o,a,function(c,h,u){n=n.filter(function(d){return d[0]===c&&d[1]===h&&d[2]===u&&(!l||d[3]===l)?(d[4](),!1):!0})})}function i(o,a,l){var c,h=!0;return typeof CustomEvent=="function"?c=new CustomEvent(a,{bubbles:h,detail:l}):(c=document.createEvent("CustomEvent"),c.initCustomEvent(a,h,!1,l)),o.dispatchEvent(c),c}function s(o,a,l){Te(o,function(c){c&&Te(a,function(h){h.split(" ").forEach(function(u){var d=u.split(".");l(c,d[0],d[1])})})})}function r(){n.forEach(function(o){o[4]()}),di(n)}return{bind:t,unbind:e,dispatch:i,destroy:r}}var as="mounted",tc="ready",Pi="move",Mr="moved",Ah="click",Xg="active",Kg="inactive",qg="visible",Zg="hidden",jt="refresh",de="updated",br="resize",Ba="resized",Jg="drag",Qg="dragging",tf="dragged",Na="scroll",Ls="scrolled",ef="overflow",Ph="destroy",sf="arrows:mounted",rf="arrows:updated",nf="pagination:mounted",of="pagination:updated",Dh="navigation:mounted",Mh="autoplay:play",af="autoplay:playing",Ih="autoplay:pause",Lh="lazyload:loaded",Fh="sk",jh="sh",Fn="ei";function _t(n){var t=n?n.event.bus:document.createDocumentFragment(),e=kh();function i(r,o){e.bind(t,kr(r).join(" "),function(a){o.apply(o,Ma(a.detail)?a.detail:[])})}function s(r){e.dispatch(t,r,ji(arguments,1))}return n&&n.event.on(Ph,e.destroy),fr(e,{bus:t,on:i,off:lt(e.unbind,t),emit:s})}function no(n,t,e,i){var s=Date.now,r,o=0,a,l=!0,c=0;function h(){if(!l){if(o=n?Ai((s()-r)/n,1):1,e&&e(o),o>=1&&(t(),r=s(),i&&++c>=i))return d();a=ql(h)}}function u(v){v||g(),r=s()-(v?o*n:0),l=!1,a=ql(h)}function d(){l=!0}function p(){r=s(),o=0,e&&e(o)}function g(){a&&cancelAnimationFrame(a),o=0,a=0,l=!0}function f(v){n=v}function m(){return l}return{start:u,rewind:p,pause:d,cancel:g,set:f,isPaused:m}}function lf(n){var t=n;function e(s){t=s}function i(s){return La(kr(s),t)}return{set:e,is:i}}function cf(n,t){var e=no(0,n,null,1);return function(){e.isPaused()&&e.start()}}function hf(n,t,e){var i=n.state,s=e.breakpoints||{},r=e.reducedMotion||{},o=kh(),a=[];function l(){var g=e.mediaQuery==="min";gr(s).sort(function(f,m){return g?+f-+m:+m-+f}).forEach(function(f){h(s[f],"("+(g?"min":"max")+"-width:"+f+"px)")}),h(r,Kl),u()}function c(g){g&&o.destroy()}function h(g,f){var m=matchMedia(f);o.bind(m,"change",u),a.push([g,m])}function u(){var g=i.is(Mn),f=e.direction,m=a.reduce(function(v,y){return Si(v,y[1].matches?y[0]:{})},{});Zl(e),p(m),e.destroy?n.destroy(e.destroy==="completely"):g?(c(!0),n.mount()):f!==e.direction&&n.refresh()}function d(g){matchMedia(Kl).matches&&(g?Si(e,r):Zl(e,gr(r)))}function p(g,f,m){Si(e,g),f&&Si(Object.getPrototypeOf(e),g),(m||!i.is(bs))&&n.emit(de,e)}return{setup:l,destroy:c,reduce:d,set:p}}var oo="Arrow",ao=oo+"Left",lo=oo+"Right",Rh=oo+"Up",$h=oo+"Down",ec="rtl",co="ttb",Io={width:["height"],left:["top","right"],right:["bottom","left"],x:["y"],X:["Y"],Y:["X"],ArrowLeft:[Rh,lo],ArrowRight:[$h,ao]};function uf(n,t,e){function i(r,o,a){a=a||e.direction;var l=a===ec&&!o?1:a===co?0:-1;return Io[r]&&Io[r][l]||r.replace(/width|left|right/i,function(c,h){var u=Io[c.toLowerCase()][l]||c;return h>0?u.charAt(0).toUpperCase()+u.slice(1):u})}function s(r){return r*(e.direction===ec?1:-1)}return{resolve:i,orient:s}}var li="role",Cs="tabindex",df="disabled",je="aria-",Ir=je+"controls",Bh=je+"current",ic=je+"selected",Se=je+"label",za=je+"labelledby",Nh=je+"hidden",Ha=je+"orientation",_r=je+"roledescription",sc=je+"live",rc=je+"busy",nc=je+"atomic",Va=[li,Cs,df,Ir,Bh,Se,za,Nh,Ha,_r],Ze=Dr+"__",Ri="is-",Lo=Dr,oc=Ze+"track",pf=Ze+"list",ho=Ze+"slide",zh=ho+"--clone",gf=ho+"__container",Ua=Ze+"arrows",uo=Ze+"arrow",Hh=uo+"--prev",Vh=uo+"--next",po=Ze+"pagination",Uh=po+"__page",ff=Ze+"progress",mf=ff+"__bar",vf=Ze+"toggle",bf=Ze+"spinner",_f=Ze+"sr",yf=Ri+"initialized",es=Ri+"active",Wh=Ri+"prev",Gh=Ri+"next",ca=Ri+"visible",ha=Ri+"loading",Yh=Ri+"focus-in",Xh=Ri+"overflow",xf=[es,ca,Wh,Gh,ha,Yh,Xh],wf={slide:ho,clone:zh,arrows:Ua,arrow:uo,prev:Hh,next:Vh,pagination:po,page:Uh,spinner:bf};function Cf(n,t){if(xh(n.closest))return n.closest(t);for(var e=n;e&&e.nodeType===1&&!pr(e,t);)e=e.parentElement;return e}var Sf=5,ac=200,Kh="touchstart mousedown",Fo="touchmove mousemove",jo="touchend touchcancel mouseup click";function Tf(n,t,e){var i=_t(n),s=i.on,r=i.bind,o=n.root,a=e.i18n,l={},c=[],h=[],u=[],d,p,g;function f(){x(),E(),y()}function m(){s(jt,v),s(jt,f),s(de,y),r(document,Kh+" keydown",function(C){g=C.type==="keydown"},{capture:!0}),r(o,"focusin",function(){si(o,Yh,!!g)})}function v(C){var T=Va.concat("style");di(c),ri(o,h),ri(d,u),Ue([d,p],T),Ue(o,C?T:["style",_r])}function y(){ri(o,h),ri(d,u),h=D(Lo),u=D(oc),Ve(o,h),Ve(d,u),Y(o,Se,e.label),Y(o,za,e.labelledby)}function x(){d=O("."+oc),p=Pr(d,"."+pf),rr(d&&p,"A track/list element is missing."),yn(c,Ch(p,"."+ho+":not(."+zh+")")),Ji({arrows:Ua,pagination:po,prev:Hh,next:Vh,bar:mf,toggle:vf},function(C,T){l[T]=O("."+C)}),fr(l,{root:o,track:d,list:p,slides:c})}function E(){var C=o.id||Yg(Dr),T=e.role;o.id=C,d.id=d.id||C+"-track",p.id=p.id||C+"-list",!Me(o,li)&&o.tagName!=="SECTION"&&T&&Y(o,li,T),Y(o,_r,a.carousel),Y(p,li,"presentation")}function O(C){var T=Eh(o,C);return T&&Cf(T,"."+Lo)===o?T:void 0}function D(C){return[C+"--"+e.type,C+"--"+e.direction,e.drag&&C+"--draggable",e.isNavigation&&C+"--nav",C===Lo&&es]}return fr(l,{setup:f,mount:m,destroy:v})}var Ps="slide",Fs="loop",Lr="fade";function Ef(n,t,e,i){var s=_t(n),r=s.on,o=s.emit,a=s.bind,l=n.Components,c=n.root,h=n.options,u=h.isNavigation,d=h.updateOnMove,p=h.i18n,g=h.pagination,f=h.slideFocus,m=l.Direction.resolve,v=Me(i,"style"),y=Me(i,Se),x=e>-1,E=Pr(i,"."+gf),O;function D(){x||(i.id=c.id+"-slide"+$a(t+1),Y(i,li,g?"tabpanel":"group"),Y(i,_r,p.slide),Y(i,Se,y||la(p.slideLabel,[t+1,n.length]))),C()}function C(){a(i,"click",lt(o,Ah,$)),a(i,"keydown",lt(o,Fh,$)),r([Mr,jh,Ls],A),r(Dh,F),d&&r(Pi,j)}function T(){O=!0,s.destroy(),ri(i,xf),Ue(i,Va),Y(i,"style",v),Y(i,Se,y||"")}function F(){var B=n.splides.map(function(M){var H=M.splide.Components.Slides.getAt(t);return H?H.slide.id:""}).join(" ");Y(i,Se,la(p.slideX,(x?e:t)+1)),Y(i,Ir,B),Y(i,li,f?"button":""),f&&Ue(i,_r)}function j(){O||A()}function A(){if(!O){var B=n.index;k(),P(),si(i,Wh,t===B-1),si(i,Gh,t===B+1)}}function k(){var B=z();B!==Jl(i,es)&&(si(i,es,B),Y(i,Bh,u&&B||""),o(B?Xg:Kg,$))}function P(){var B=X(),M=!B&&(!z()||x);if(n.state.is([Is,Er])||Y(i,Nh,M||""),Y(ja(i,h.focusableNodes||""),Cs,M?-1:""),f&&Y(i,Cs,M?-1:0),B!==Jl(i,ca)&&(si(i,ca,B),o(B?qg:Zg,$)),!B&&document.activeElement===i){var H=l.Slides.getAt(n.index);H&&Sh(H.slide)}}function L(B,M,H){Pe(H&&E||i,B,M)}function z(){var B=n.index;return B===t||h.cloneStatus&&B===e}function X(){if(n.is(Lr))return z();var B=xe(l.Elements.track),M=xe(i),H=m("left",!0),Q=m("right",!0);return Ln(B[H])<=vr(M[H])&&Ln(M[Q])<=vr(B[Q])}function J(B,M){var H=ae(B-t);return!x&&(h.rewind||n.is(Fs))&&(H=Ai(H,n.length-H)),H<=M}var $={index:t,slideIndex:e,slide:i,container:E,isClone:x,mount:D,destroy:T,update:A,style:L,isWithin:J};return $}function Of(n,t,e){var i=_t(n),s=i.on,r=i.emit,o=i.bind,a=t.Elements,l=a.slides,c=a.list,h=[];function u(){d(),s(jt,p),s(jt,d)}function d(){l.forEach(function(A,k){f(A,k,-1)})}function p(){O(function(A){A.destroy()}),di(h)}function g(){O(function(A){A.update()})}function f(A,k,P){var L=Ef(n,k,P,A);L.mount(),h.push(L),h.sort(function(z,X){return z.index-X.index})}function m(A){return A?D(function(k){return!k.isClone}):h}function v(A){var k=t.Controller,P=k.toIndex(A),L=k.hasFocus()?1:e.perPage;return D(function(z){return xn(z.index,P,P+L-1)})}function y(A){return D(A)[0]}function x(A,k){Te(A,function(P){if(ki(P)&&(P=Th(P)),wh(P)){var L=l[k];L?Fa(P,L):Ar(c,P),Ve(P,e.classes.slide),T(P,lt(r,br))}}),r(jt)}function E(A){ts(D(A).map(function(k){return k.slide})),r(jt)}function O(A,k){m(k).forEach(A)}function D(A){return h.filter(xh(A)?A:function(k){return ki(A)?pr(k.slide,A):La(kr(A),k.index)})}function C(A,k,P){O(function(L){L.style(A,k,P)})}function T(A,k){var P=ja(A,"img"),L=P.length;L?P.forEach(function(z){o(z,"load error",function(){--L||k()})}):k()}function F(A){return A?l.length:h.length}function j(){return h.length>e.perPage}return{mount:u,destroy:p,update:g,register:f,get:m,getIn:v,getAt:y,add:x,remove:E,forEach:O,filter:D,style:C,getLength:F,isEnough:j}}function kf(n,t,e){var i=_t(n),s=i.on,r=i.bind,o=i.emit,a=t.Slides,l=t.Direction.resolve,c=t.Elements,h=c.root,u=c.track,d=c.list,p=a.getAt,g=a.style,f,m,v;function y(){x(),r(window,"resize load",cf(lt(o,br))),s([de,jt],x),s(br,E)}function x(){f=e.direction===co,Pe(h,"maxWidth",Hi(e.width)),Pe(u,l("paddingLeft"),O(!1)),Pe(u,l("paddingRight"),O(!0)),E(!0)}function E($){var B=xe(h);($||m.width!==B.width||m.height!==B.height)&&(Pe(u,"height",D()),g(l("marginRight"),Hi(e.gap)),g("width",T()),g("height",F(),!0),m=B,o(Ba),v!==(v=J())&&(si(h,Xh,v),o(ef,v)))}function O($){var B=e.padding,M=l($?"right":"left");return B&&Hi(B[M]||(dr(B)?0:B))||"0px"}function D(){var $="";return f&&($=C(),rr($,"height or heightRatio is missing."),$="calc("+$+" - "+O(!1)+" - "+O(!0)+")"),$}function C(){return Hi(e.height||xe(d).width*e.heightRatio)}function T(){return e.autoWidth?null:Hi(e.fixedWidth)||(f?"":j())}function F(){return Hi(e.fixedHeight)||(f?e.autoHeight?null:j():C())}function j(){var $=Hi(e.gap);return"calc((100%"+($&&" + "+$)+")/"+(e.perPage||1)+($&&" - "+$)+")"}function A(){return xe(d)[l("width")]}function k($,B){var M=p($||0);return M?xe(M.slide)[l("width")]+(B?0:z()):0}function P($,B){var M=p($);if(M){var H=xe(M.slide)[l("right")],Q=xe(d)[l("left")];return ae(H-Q)+(B?0:z())}return 0}function L($){return P(n.length-1)-P(0)+k(0,$)}function z(){var $=p(0);return $&&parseFloat(Pe($.slide,l("marginRight")))||0}function X($){return parseFloat(Pe(u,l("padding"+($?"Right":"Left"))))||0}function J(){return n.is(Lr)||L(!0)>A()}return{mount:y,resize:E,listSize:A,slideSize:k,sliderSize:L,totalSize:P,getPadding:X,isOverflow:J}}var Af=2;function Pf(n,t,e){var i=_t(n),s=i.on,r=t.Elements,o=t.Slides,a=t.Direction.resolve,l=[],c;function h(){s(jt,u),s([de,br],p),(c=m())&&(g(c),t.Layout.resize(!0))}function u(){d(),h()}function d(){ts(l),di(l),i.destroy()}function p(){var v=m();c!==v&&(c<v||!v)&&i.emit(jt)}function g(v){var y=o.get().slice(),x=y.length;if(x){for(;y.length<v;)yn(y,y);yn(y.slice(-v),y.slice(0,v)).forEach(function(E,O){var D=O<v,C=f(E.slide,O);D?Fa(C,y[0].slide):Ar(r.list,C),yn(l,C),o.register(C,O-v+(D?0:x),E.index)})}}function f(v,y){var x=v.cloneNode(!0);return Ve(x,e.classes.clone),x.id=n.root.id+"-clone"+$a(y+1),x}function m(){var v=e.clones;if(!n.is(Fs))v=0;else if(Or(v)){var y=e[a("fixedWidth")]&&t.Layout.slideSize(0),x=y&&vr(xe(r.track)[a("width")]/y);v=x||e[a("autoWidth")]&&n.length||e.perPage*Af}return v}return{mount:h,destroy:d}}function Df(n,t,e){var i=_t(n),s=i.on,r=i.emit,o=n.state.set,a=t.Layout,l=a.slideSize,c=a.getPadding,h=a.totalSize,u=a.listSize,d=a.sliderSize,p=t.Direction,g=p.resolve,f=p.orient,m=t.Elements,v=m.list,y=m.track,x;function E(){x=t.Transition,s([as,Ba,de,jt],O)}function O(){t.Controller.isBusy()||(t.Scroll.cancel(),C(n.index),t.Slides.update())}function D(M,H,Q,Ct){M!==H&&$(M>Q)&&(A(),T(j(L(),M>Q),!0)),o(Is),r(Pi,H,Q,M),x.start(H,function(){o(As),r(Mr,H,Q,M),Ct&&Ct()})}function C(M){T(P(M,!0))}function T(M,H){if(!n.is(Lr)){var Q=H?M:F(M);Pe(v,"transform","translate"+g("X")+"("+Q+"px)"),M!==Q&&r(jh)}}function F(M){if(n.is(Fs)){var H=k(M),Q=H>t.Controller.getEnd(),Ct=H<0;(Ct||Q)&&(M=j(M,Q))}return M}function j(M,H){var Q=M-J(H),Ct=d();return M-=f(Ct*(vr(ae(Q)/Ct)||1))*(H?1:-1),M}function A(){T(L(),!0),x.cancel()}function k(M){for(var H=t.Slides.get(),Q=0,Ct=1/0,ot=0;ot<H.length;ot++){var ge=H[ot].index,I=ae(P(ge,!0)-M);if(I<=Ct)Ct=I,Q=ge;else break}return Q}function P(M,H){var Q=f(h(M-1)-X(M));return H?z(Q):Q}function L(){var M=g("left");return xe(v)[M]-xe(y)[M]+f(c(!1))}function z(M){return e.trimSpace&&n.is(Ps)&&(M=ps(M,0,f(d(!0)-u()))),M}function X(M){var H=e.focus;return H==="center"?(u()-l(M,!0))/2:+H*l(M)||0}function J(M){return P(M?t.Controller.getEnd():0,!!e.trimSpace)}function $(M){var H=f(j(L(),M));return M?H>=0:H<=v[g("scrollWidth")]-xe(y)[g("width")]}function B(M,H){H=Or(H)?L():H;var Q=M!==!0&&f(H)<f(J(!1)),Ct=M!==!1&&f(H)>f(J(!0));return Q||Ct}return{mount:E,move:D,jump:C,translate:T,shift:j,cancel:A,toIndex:k,toPosition:P,getPosition:L,getLimit:J,exceededLimit:B,reposition:O}}function Mf(n,t,e){var i=_t(n),s=i.on,r=i.emit,o=t.Move,a=o.getPosition,l=o.getLimit,c=o.toPosition,h=t.Slides,u=h.isEnough,d=h.getLength,p=e.omitEnd,g=n.is(Fs),f=n.is(Ps),m=lt(L,!1),v=lt(L,!0),y=e.start||0,x,E=y,O,D,C;function T(){F(),s([de,jt,Fn],F),s(Ba,j)}function F(){O=d(!0),D=e.perMove,C=e.perPage,x=$();var I=ps(y,0,p?x:O-1);I!==y&&(y=I,o.reposition())}function j(){x!==$()&&r(Fn)}function A(I,et,Wt){if(!ge()){var ht=P(I),ut=J(ht);ut>-1&&(et||ut!==y)&&(Q(ut),o.move(ht,ut,E,Wt))}}function k(I,et,Wt,ht){t.Scroll.scroll(I,et,Wt,function(){var ut=J(o.toIndex(a()));Q(p?Ai(ut,x):ut),ht&&ht()})}function P(I){var et=y;if(ki(I)){var Wt=I.match(/([+\-<>])(\d+)?/)||[],ht=Wt[1],ut=Wt[2];ht==="+"||ht==="-"?et=z(y+ +(""+ht+(+ut||1)),y):ht===">"?et=ut?B(+ut):m(!0):ht==="<"&&(et=v(!0))}else et=g?I:ps(I,0,x);return et}function L(I,et){var Wt=D||(ot()?1:C),ht=z(y+Wt*(I?-1:1),y,!(D||ot()));return ht===-1&&f&&!Oh(a(),l(!I),1)?I?0:x:et?ht:J(ht)}function z(I,et,Wt){if(u()||ot()){var ht=X(I);ht!==I&&(et=I,I=ht,Wt=!1),I<0||I>x?!D&&(xn(0,I,et,!0)||xn(x,et,I,!0))?I=B(M(I)):g?I=Wt?I<0?-(O%C||C):O:I:e.rewind?I=I<0?x:0:I=-1:Wt&&I!==et&&(I=B(M(et)+(I<et?-1:1)))}else I=-1;return I}function X(I){if(f&&e.trimSpace==="move"&&I!==y)for(var et=a();et===c(I,!0)&&xn(I,0,n.length-1,!e.rewind);)I<y?--I:++I;return I}function J(I){return g?(I+O)%O||0:I}function $(){for(var I=O-(ot()||g&&D?1:C);p&&I-- >0;)if(c(O-1,!0)!==c(I,!0)){I++;break}return ps(I,0,O-1)}function B(I){return ps(ot()?I:C*I,0,x)}function M(I){return ot()?Ai(I,x):Ln((I>=x?O-1:I)/C)}function H(I){var et=o.toIndex(I);return f?ps(et,0,x):et}function Q(I){I!==y&&(E=y,y=I)}function Ct(I){return I?E:y}function ot(){return!Or(e.focus)||e.isNavigation}function ge(){return n.state.is([Is,Er])&&!!e.waitForTransition}return{mount:T,go:A,scroll:k,getNext:m,getPrev:v,getAdjacent:L,getEnd:$,setIndex:Q,getIndex:Ct,toIndex:B,toPage:M,toDest:H,hasFocus:ot,isBusy:ge}}var If="http://www.w3.org/2000/svg",Lf="m15.5 0.932-4.3 4.38 14.5 14.6-14.5 14.5 4.3 4.4 14.6-14.6 4.4-4.3-4.4-4.4-14.6-14.6z",Wr=40;function Ff(n,t,e){var i=_t(n),s=i.on,r=i.bind,o=i.emit,a=e.classes,l=e.i18n,c=t.Elements,h=t.Controller,u=c.arrows,d=c.track,p=u,g=c.prev,f=c.next,m,v,y={};function x(){O(),s(de,E)}function E(){D(),x()}function O(){var k=e.arrows;k&&!(g&&f)&&F(),g&&f&&(fr(y,{prev:g,next:f}),mr(p,k?"":"none"),Ve(p,v=Ua+"--"+e.direction),k&&(C(),A(),Y([g,f],Ir,d.id),o(sf,g,f)))}function D(){i.destroy(),ri(p,v),m?(ts(u?[g,f]:p),g=f=null):Ue([g,f],Va)}function C(){s([as,Mr,jt,Ls,Fn],A),r(f,"click",lt(T,">")),r(g,"click",lt(T,"<"))}function T(k){h.go(k,!0)}function F(){p=u||ws("div",a.arrows),g=j(!0),f=j(!1),m=!0,Ar(p,[g,f]),!u&&Fa(p,d)}function j(k){var P='<button class="'+a.arrow+" "+(k?a.prev:a.next)+'" type="button"><svg xmlns="'+If+'" viewBox="0 0 '+Wr+" "+Wr+'" width="'+Wr+'" height="'+Wr+'" focusable="false"><path d="'+(e.arrowPath||Lf)+'" />';return Th(P)}function A(){if(g&&f){var k=n.index,P=h.getPrev(),L=h.getNext(),z=P>-1&&k<P?l.last:l.prev,X=L>-1&&k>L?l.first:l.next;g.disabled=P<0,f.disabled=L<0,Y(g,Se,z),Y(f,Se,X),o(rf,g,f,P,L)}}return{arrows:y,mount:x,destroy:D,update:A}}var jf=Ra+"-interval";function Rf(n,t,e){var i=_t(n),s=i.on,r=i.bind,o=i.emit,a=no(e.interval,n.go.bind(n,">"),C),l=a.isPaused,c=t.Elements,h=t.Elements,u=h.root,d=h.toggle,p=e.autoplay,g,f,m=p==="pause";function v(){p&&(y(),d&&Y(d,Ir,c.track.id),m||x(),D())}function y(){e.pauseOnHover&&r(u,"mouseenter mouseleave",function(F){g=F.type==="mouseenter",O()}),e.pauseOnFocus&&r(u,"focusin focusout",function(F){f=F.type==="focusin",O()}),d&&r(d,"click",function(){m?x():E(!0)}),s([Pi,Na,jt],a.rewind),s(Pi,T)}function x(){l()&&t.Slides.isEnough()&&(a.start(!e.resetProgress),f=g=m=!1,D(),o(Mh))}function E(F){F===void 0&&(F=!0),m=!!F,D(),l()||(a.pause(),o(Ih))}function O(){m||(g||f?E(!1):x())}function D(){d&&(si(d,es,!m),Y(d,Se,e.i18n[m?"play":"pause"]))}function C(F){var j=c.bar;j&&Pe(j,"width",F*100+"%"),o(af,F)}function T(F){var j=t.Slides.getAt(F);a.set(j&&+Me(j.slide,jf)||e.interval)}return{mount:v,destroy:a.cancel,play:x,pause:E,isPaused:l}}function $f(n,t,e){var i=_t(n),s=i.on;function r(){e.cover&&(s(Lh,lt(a,!0)),s([as,de,jt],lt(o,!0)))}function o(l){t.Slides.forEach(function(c){var h=Pr(c.container||c.slide,"img");h&&h.src&&a(l,h,c)})}function a(l,c,h){h.style("background",l?'center/cover no-repeat url("'+c.src+'")':"",!0),mr(c,l?"none":"")}return{mount:r,destroy:lt(o,!1)}}var Bf=10,Nf=600,zf=.6,Hf=1.5,Vf=800;function Uf(n,t,e){var i=_t(n),s=i.on,r=i.emit,o=n.state.set,a=t.Move,l=a.getPosition,c=a.getLimit,h=a.exceededLimit,u=a.translate,d=n.is(Ps),p,g,f=1;function m(){s(Pi,E),s([de,jt],O)}function v(C,T,F,j,A){var k=l();if(E(),F&&(!d||!h())){var P=t.Layout.sliderSize(),L=aa(C)*P*Ln(ae(C)/P)||0;C=a.toPosition(t.Controller.toDest(C%P))+L}var z=Oh(k,C,1);f=1,T=z?0:T||In(ae(C-k)/Hf,Vf),g=j,p=no(T,y,lt(x,k,C,A),1),o(Er),r(Na),p.start()}function y(){o(As),g&&g(),r(Ls)}function x(C,T,F,j){var A=l(),k=C+(T-C)*D(j),P=(k-A)*f;u(A+P),d&&!F&&h()&&(f*=zf,ae(P)<Bf&&v(c(h(!0)),Nf,!1,g,!0))}function E(){p&&p.cancel()}function O(){p&&!p.isPaused()&&(E(),y())}function D(C){var T=e.easingFunc;return T?T(C):1-Math.pow(1-C,4)}return{mount:m,destroy:E,scroll:v,cancel:O}}var gs={passive:!1,capture:!0};function Wf(n,t,e){var i=_t(n),s=i.on,r=i.emit,o=i.bind,a=i.unbind,l=n.state,c=t.Move,h=t.Scroll,u=t.Controller,d=t.Elements.track,p=t.Media.reduce,g=t.Direction,f=g.resolve,m=g.orient,v=c.getPosition,y=c.exceededLimit,x,E,O,D,C,T=!1,F,j,A;function k(){o(d,Fo,na,gs),o(d,jo,na,gs),o(d,Kh,L,gs),o(d,"click",J,{capture:!0}),o(d,"dragstart",ti),s([as,de],P)}function P(){var N=e.drag;gl(!N),D=N==="free"}function L(N){if(F=!1,!j){var dt=ut(N);ht(N.target)&&(dt||!N.button)&&(u.isBusy()?ti(N,!0):(A=dt?d:window,C=l.is([Is,Er]),O=null,o(A,Fo,z,gs),o(A,jo,X,gs),c.cancel(),h.cancel(),$(N)))}}function z(N){if(l.is(_n)||(l.set(_n),r(Jg)),N.cancelable)if(C){c.translate(x+Wt(ot(N)));var dt=ge(N)>ac,Ni=T!==(T=y());(dt||Ni)&&$(N),F=!0,r(Qg),ti(N)}else H(N)&&(C=M(N),ti(N))}function X(N){l.is(_n)&&(l.set(As),r(tf)),C&&(B(N),ti(N)),a(A,Fo,z),a(A,jo,X),C=!1}function J(N){!j&&F&&ti(N,!0)}function $(N){O=E,E=N,x=v()}function B(N){var dt=Q(N),Ni=Ct(dt),Vs=e.rewind&&e.rewindByDrag;p(!1),D?u.scroll(Ni,0,e.snap):n.is(Lr)?u.go(m(aa(dt))<0?Vs?"<":"-":Vs?">":"+"):n.is(Ps)&&T&&Vs?u.go(y(!0)?">":"<"):u.go(u.toDest(Ni),!0),p(!0)}function M(N){var dt=e.dragMinThreshold,Ni=dr(dt),Vs=Ni&&dt.mouse||0,td=(Ni?dt.touch:+dt)||10;return ae(ot(N))>(ut(N)?td:Vs)}function H(N){return ae(ot(N))>ae(ot(N,!0))}function Q(N){if(n.is(Fs)||!T){var dt=ge(N);if(dt&&dt<ac)return ot(N)/dt}return 0}function Ct(N){return v()+aa(N)*Ai(ae(N)*(e.flickPower||600),D?1/0:t.Layout.listSize()*(e.flickMaxPages||1))}function ot(N,dt){return et(N,dt)-et(I(N),dt)}function ge(N){return oa(N)-oa(I(N))}function I(N){return E===N&&O||E}function et(N,dt){return(ut(N)?N.changedTouches[0]:N)["page"+f(dt?"Y":"X")]}function Wt(N){return N/(T&&n.is(Ps)?Sf:1)}function ht(N){var dt=e.noDrag;return!pr(N,"."+Uh+", ."+uo)&&(!dt||!pr(N,dt))}function ut(N){return typeof TouchEvent<"u"&&N instanceof TouchEvent}function Qu(){return C}function gl(N){j=N}return{mount:k,disable:gl,isDragging:Qu}}var Gf={Spacebar:" ",Right:lo,Left:ao,Up:Rh,Down:$h};function Wa(n){return n=ki(n)?n:n.key,Gf[n]||n}var lc="keydown";function Yf(n,t,e){var i=_t(n),s=i.on,r=i.bind,o=i.unbind,a=n.root,l=t.Direction.resolve,c,h;function u(){d(),s(de,p),s(de,d),s(Pi,f)}function d(){var v=e.keyboard;v&&(c=v==="global"?window:a,r(c,lc,m))}function p(){o(c,lc)}function g(v){h=v}function f(){var v=h;h=!0,yh(function(){h=v})}function m(v){if(!h){var y=Wa(v);y===l(ao)?n.go("<"):y===l(lo)&&n.go(">")}}return{mount:u,destroy:p,disable:g}}var nr=Ra+"-lazy",wn=nr+"-srcset",Xf="["+nr+"], ["+wn+"]";function Kf(n,t,e){var i=_t(n),s=i.on,r=i.off,o=i.bind,a=i.emit,l=e.lazyLoad==="sequential",c=[Mr,Ls],h=[];function u(){e.lazyLoad&&(d(),s(jt,d))}function d(){di(h),p(),l?v():(r(c),s(c,g),g())}function p(){t.Slides.forEach(function(y){ja(y.slide,Xf).forEach(function(x){var E=Me(x,nr),O=Me(x,wn);if(E!==x.src||O!==x.srcset){var D=e.classes.spinner,C=x.parentElement,T=Pr(C,"."+D)||ws("span",D,C);h.push([x,y,T]),x.src||mr(x,"none")}})})}function g(){h=h.filter(function(y){var x=e.perPage*((e.preloadPages||1)+1)-1;return y[1].isWithin(n.index,x)?f(y):!0}),h.length||r(c)}function f(y){var x=y[0];Ve(y[1].slide,ha),o(x,"load error",lt(m,y)),Y(x,"src",Me(x,nr)),Y(x,"srcset",Me(x,wn)),Ue(x,nr),Ue(x,wn)}function m(y,x){var E=y[0],O=y[1];ri(O.slide,ha),x.type!=="error"&&(ts(y[2]),mr(E,""),a(Lh,E,O),a(br)),l&&v()}function v(){h.length&&f(h.shift())}return{mount:u,destroy:lt(di,h),check:g}}function qf(n,t,e){var i=_t(n),s=i.on,r=i.emit,o=i.bind,a=t.Slides,l=t.Elements,c=t.Controller,h=c.hasFocus,u=c.getIndex,d=c.go,p=t.Direction.resolve,g=l.pagination,f=[],m,v;function y(){x(),s([de,jt,Fn],y);var j=e.pagination;g&&mr(g,j?"":"none"),j&&(s([Pi,Na,Ls],F),E(),F(),r(nf,{list:m,items:f},T(n.index)))}function x(){m&&(ts(g?ji(m.children):m),ri(m,v),di(f),m=null),i.destroy()}function E(){var j=n.length,A=e.classes,k=e.i18n,P=e.perPage,L=h()?c.getEnd()+1:vr(j/P);m=g||ws("ul",A.pagination,l.track.parentElement),Ve(m,v=po+"--"+C()),Y(m,li,"tablist"),Y(m,Se,k.select),Y(m,Ha,C()===co?"vertical":"");for(var z=0;z<L;z++){var X=ws("li",null,m),J=ws("button",{class:A.page,type:"button"},X),$=a.getIn(z).map(function(M){return M.slide.id}),B=!h()&&P>1?k.pageX:k.slideX;o(J,"click",lt(O,z)),e.paginationKeyboard&&o(J,"keydown",lt(D,z)),Y(X,li,"presentation"),Y(J,li,"tab"),Y(J,Ir,$.join(" ")),Y(J,Se,la(B,z+1)),Y(J,Cs,-1),f.push({li:X,button:J,page:z})}}function O(j){d(">"+j,!0)}function D(j,A){var k=f.length,P=Wa(A),L=C(),z=-1;P===p(lo,!1,L)?z=++j%k:P===p(ao,!1,L)?z=(--j+k)%k:P==="Home"?z=0:P==="End"&&(z=k-1);var X=f[z];X&&(Sh(X.button),d(">"+z),ti(A,!0))}function C(){return e.paginationDirection||e.direction}function T(j){return f[c.toPage(j)]}function F(){var j=T(u(!0)),A=T(u());if(j){var k=j.button;ri(k,es),Ue(k,ic),Y(k,Cs,-1)}if(A){var P=A.button;Ve(P,es),Y(P,ic,!0),Y(P,Cs,"")}r(of,{list:m,items:f},j,A)}return{items:f,mount:y,destroy:x,getAt:T,update:F}}var Zf=[" ","Enter"];function Jf(n,t,e){var i=e.isNavigation,s=e.slideFocus,r=[];function o(){n.splides.forEach(function(g){g.isParent||(c(n,g.splide),c(g.splide,n))}),i&&h()}function a(){r.forEach(function(g){g.destroy()}),di(r)}function l(){a(),o()}function c(g,f){var m=_t(g);m.on(Pi,function(v,y,x){f.go(f.is(Fs)?x:v)}),r.push(m)}function h(){var g=_t(n),f=g.on;f(Ah,d),f(Fh,p),f([as,de],u),r.push(g),g.emit(Dh,n.splides)}function u(){Y(t.Elements.list,Ha,e.direction===co?"vertical":"")}function d(g){n.go(g.index)}function p(g,f){La(Zf,Wa(f))&&(d(g),ti(f))}return{setup:lt(t.Media.set,{slideFocus:Or(s)?i:s},!0),mount:o,destroy:a,remount:l}}function Qf(n,t,e){var i=_t(n),s=i.bind,r=0;function o(){e.wheel&&s(t.Elements.track,"wheel",a,gs)}function a(c){if(c.cancelable){var h=c.deltaY,u=h<0,d=oa(c),p=e.wheelMinThreshold||0,g=e.wheelSleep||0;ae(h)>p&&d-r>g&&(n.go(u?"<":">"),r=d),l(u)&&ti(c)}}function l(c){return!e.releaseWheel||n.state.is(Is)||t.Controller.getAdjacent(c)!==-1}return{mount:o}}var tm=90;function em(n,t,e){var i=_t(n),s=i.on,r=t.Elements.track,o=e.live&&!e.isNavigation,a=ws("span",_f),l=no(tm,lt(h,!1));function c(){o&&(d(!t.Autoplay.isPaused()),Y(r,nc,!0),a.textContent="…",s(Mh,lt(d,!0)),s(Ih,lt(d,!1)),s([Mr,Ls],lt(h,!0)))}function h(p){Y(r,rc,p),p?(Ar(r,a),l.start()):(ts(a),l.cancel())}function u(){Ue(r,[sc,nc,rc]),ts(a)}function d(p){o&&Y(r,sc,p?"off":"polite")}return{mount:c,disable:d,destroy:u}}var im=Object.freeze({__proto__:null,Media:hf,Direction:uf,Elements:Tf,Slides:Of,Layout:kf,Clones:Pf,Move:Df,Controller:Mf,Arrows:Ff,Autoplay:Rf,Cover:$f,Scroll:Uf,Drag:Wf,Keyboard:Yf,LazyLoad:Kf,Pagination:qf,Sync:Jf,Wheel:Qf,Live:em}),sm={prev:"Previous slide",next:"Next slide",first:"Go to first slide",last:"Go to last slide",slideX:"Go to slide %s",pageX:"Go to page %s",play:"Start autoplay",pause:"Pause autoplay",carousel:"carousel",slide:"slide",select:"Select a slide to show",slideLabel:"%s of %s"},rm={type:"slide",role:"region",speed:400,perPage:1,cloneStatus:!0,arrows:!0,pagination:!0,paginationKeyboard:!0,interval:5e3,pauseOnHover:!0,pauseOnFocus:!0,resetProgress:!0,easing:"cubic-bezier(0.25, 1, 0.5, 1)",drag:!0,direction:"ltr",trimSpace:!0,focusableNodes:"a, button, textarea, input, select, iframe",live:!0,classes:wf,i18n:sm,reducedMotion:{speed:0,rewindSpeed:0,autoplay:"pause"}};function nm(n,t,e){var i=t.Slides;function s(){_t(n).on([as,jt],r)}function r(){i.forEach(function(a){a.style("transform","translateX(-"+100*a.index+"%)")})}function o(a,l){i.style("transition","opacity "+e.speed+"ms "+e.easing),yh(l)}return{mount:s,start:o,cancel:na}}function om(n,t,e){var i=t.Move,s=t.Controller,r=t.Scroll,o=t.Elements.list,a=lt(Pe,o,"transition"),l;function c(){_t(n).bind(o,"transitionend",function(p){p.target===o&&l&&(u(),l())})}function h(p,g){var f=i.toPosition(p,!0),m=i.getPosition(),v=d(p);ae(f-m)>=1&&v>=1?e.useScroll?r.scroll(f,v,!1,g):(a("transform "+v+"ms "+e.easing),i.translate(f,!0),l=g):(i.jump(p),g())}function u(){a(""),r.cancel()}function d(p){var g=e.rewindSpeed;if(n.is(Ps)&&g){var f=s.getIndex(!0),m=s.getEnd();if(f===0&&p>=m||f>=m&&p===0)return g}return e.speed}return{mount:c,start:h,cancel:u}}var am=function(){function n(e,i){this.event=_t(),this.Components={},this.state=lf(bs),this.splides=[],this._o={},this._E={};var s=ki(e)?Eh(document,e):e;rr(s,s+" is invalid."),this.root=s,i=Si({label:Me(s,Se)||"",labelledby:Me(s,za)||""},rm,n.defaults,i||{});try{Si(i,JSON.parse(Me(s,Ra)))}catch{rr(!1,"Invalid JSON")}this._o=Object.create(Si({},i))}var t=n.prototype;return t.mount=function(i,s){var r=this,o=this.state,a=this.Components;rr(o.is([bs,Mn]),"Already mounted!"),o.set(bs),this._C=a,this._T=s||this._T||(this.is(Lr)?nm:om),this._E=i||this._E;var l=fr({},im,this._E,{Transition:this._T});return Ji(l,function(c,h){var u=c(r,a,r._o);a[h]=u,u.setup&&u.setup()}),Ji(a,function(c){c.mount&&c.mount()}),this.emit(as),Ve(this.root,yf),o.set(As),this.emit(tc),this},t.sync=function(i){return this.splides.push({splide:i}),i.splides.push({splide:this,isParent:!0}),this.state.is(As)&&(this._C.Sync.remount(),i.Components.Sync.remount()),this},t.go=function(i){return this._C.Controller.go(i),this},t.on=function(i,s){return this.event.on(i,s),this},t.off=function(i){return this.event.off(i),this},t.emit=function(i){var s;return(s=this.event).emit.apply(s,[i].concat(ji(arguments,1))),this},t.add=function(i,s){return this._C.Slides.add(i,s),this},t.remove=function(i){return this._C.Slides.remove(i),this},t.is=function(i){return this._o.type===i},t.refresh=function(){return this.emit(jt),this},t.destroy=function(i){i===void 0&&(i=!0);var s=this.event,r=this.state;return r.is(bs)?_t(this).on(tc,this.destroy.bind(this,i)):(Ji(this._C,function(o){o.destroy&&o.destroy(i)},!0),s.emit(Ph),s.destroy(),i&&di(this.splides),r.set(Mn)),this},Ug(n,[{key:"options",get:function(){return this._o},set:function(i){this._C.Media.set(i,!0,!0)}},{key:"length",get:function(){return this._C.Slides.getLength(!0)}},{key:"index",get:function(){return this._C.Controller.getIndex()}}]),n}(),Ga=am;Ga.defaults={};Ga.STATES=Gg;/**
|
|
2055
2063
|
* @license
|
|
2056
2064
|
* Copyright 2021 Google LLC
|
|
2057
2065
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
2058
|
-
*/function*qh(n,t){if(n!==void 0){let e=0;for(const i of n)yield t(i,e++)}}var lm=Object.defineProperty,cm=Object.getOwnPropertyDescriptor,
|
|
2066
|
+
*/function*qh(n,t){if(n!==void 0){let e=0;for(const i of n)yield t(i,e++)}}var lm=Object.defineProperty,cm=Object.getOwnPropertyDescriptor,Fr=(n,t,e,i)=>{for(var s=i>1?void 0:i?cm(t,e):t,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(t,e,s):o(s))||s);return i&&s&&lm(t,e,s),s};let Di=class extends Pt{constructor(){super(...arguments),this.cards=[],this.skeleton=!1,this.firstUpdated=()=>{this.imageSplide=new Ga(this.imageCarousel,{perPage:2,perMove:1,autoHeight:!0,gap:"0.6%",rewind:!1,pagination:!1,isNavigation:!1,mediaQuery:"min",breakpoints:{640:{perPage:4,gap:"16px"}}}),this.imageSplide.on("arrows:mounted arrows:updated",()=>{this.updateArrowVisibility()}),this.imageSplide.mount()},this.disconnectedCallback=()=>{var t;super.disconnectedCallback(),(t=this.imageSplide)==null||t.destroy()},this.clickHandler=t=>{const e=t.target;this.emit("pbo-category-card-selected",{detail:{cardId:e.dataset.cardId}})}}updateArrowVisibility(){const t=this.imageCarousel.querySelector(".splide__arrow--next"),e=this.imageCarousel.querySelector(".splide__arrow--prev");t.style.visibility=t.disabled?"hidden":"visible",e.style.visibility=e.disabled?"hidden":"visible"}render(){return this.skeleton?V`
|
|
2059
2067
|
<div class="category-container skeleton">
|
|
2060
2068
|
<div class="title"></div>
|
|
2061
2069
|
<div
|
|
@@ -2091,7 +2099,7 @@
|
|
|
2091
2099
|
>
|
|
2092
2100
|
<div class="splide__track">
|
|
2093
2101
|
<ul class="splide__list">
|
|
2094
|
-
${qh(this.cards,t=>
|
|
2102
|
+
${qh(this.cards,t=>V`
|
|
2095
2103
|
<li class="splide__slide">
|
|
2096
2104
|
<img
|
|
2097
2105
|
src=${t.medias.cover.url}
|
|
@@ -2100,12 +2108,12 @@
|
|
|
2100
2108
|
data-card-id="${t.pboId}"
|
|
2101
2109
|
/>
|
|
2102
2110
|
</li>
|
|
2103
|
-
`)
|
|
2111
|
+
`)}
|
|
2104
2112
|
</ul>
|
|
2105
2113
|
</div>
|
|
2106
2114
|
</div>
|
|
2107
2115
|
</div>
|
|
2108
|
-
`}};Di.styles=[
|
|
2116
|
+
`}};Di.styles=[Tt,zg,Kn(Hg)];Fr([S({type:Array})],Di.prototype,"cards",2);Fr([S({type:Boolean,reflect:!0})],Di.prototype,"skeleton",2);Fr([q("#category-carousel")],Di.prototype,"imageCarousel",2);Fr([W()],Di.prototype,"imageSplide",2);Di=Fr([xt("pbo-category")],Di);const i0=Di,hm=ct`
|
|
2109
2117
|
:host {
|
|
2110
2118
|
--size: 70%;
|
|
2111
2119
|
--header-spacing: var(--pbo-spacing-large);
|
|
@@ -2191,15 +2199,15 @@
|
|
|
2191
2199
|
width: 100%;
|
|
2192
2200
|
height: var(--size);
|
|
2193
2201
|
}
|
|
2194
|
-
`;var um=Object.defineProperty,dm=Object.getOwnPropertyDescriptor,
|
|
2202
|
+
`;var um=Object.defineProperty,dm=Object.getOwnPropertyDescriptor,ls=(n,t,e,i)=>{for(var s=i>1?void 0:i?dm(t,e):t,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(t,e,s):o(s))||s);return i&&s&&um(t,e,s),s};let We=class extends Pt{constructor(){super(...arguments),this.open=!1,this.placement="bottom",this.radius=!0,this.contained=!1}requestClose(n){this.hide()}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 V`
|
|
2195
2203
|
<div
|
|
2196
2204
|
part="base"
|
|
2197
|
-
class=${
|
|
2205
|
+
class=${ve({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})}
|
|
2198
2206
|
>
|
|
2199
2207
|
<div part="overlay" class="drawer__overlay" @click=${()=>this.requestClose("overlay")}></div>
|
|
2200
2208
|
<div
|
|
2201
2209
|
part="panel"
|
|
2202
|
-
class="${
|
|
2210
|
+
class="${ve({drawer__panel:!0})}"
|
|
2203
2211
|
role="dialog"
|
|
2204
2212
|
aria-modal="true"
|
|
2205
2213
|
aria-hidden=${this.open?"false":"true"}
|
|
@@ -2208,7 +2216,7 @@
|
|
|
2208
2216
|
<slot part="body" class="drawer__body"></slot>
|
|
2209
2217
|
</div>
|
|
2210
2218
|
</div>
|
|
2211
|
-
`}};We.styles=[
|
|
2219
|
+
`}};We.styles=[Tt,hm];ls([q(".drawer")],We.prototype,"drawer",2);ls([S({type:Boolean,reflect:!0})],We.prototype,"open",2);ls([S({reflect:!0})],We.prototype,"placement",2);ls([S({type:Boolean,reflect:!0})],We.prototype,"radius",2);ls([S({type:Boolean,reflect:!0})],We.prototype,"contained",2);ls([Z("open",{waitUntilFirstUpdate:!0})],We.prototype,"handleOpenChange",1);We=ls([xt("pbo-drawer")],We);const s0=We,pm=ct`
|
|
2212
2220
|
:host {
|
|
2213
2221
|
display: block;
|
|
2214
2222
|
width: 100%;
|
|
@@ -2216,10 +2224,11 @@
|
|
|
2216
2224
|
--header-height: var(--pbo-drawer-header-height);
|
|
2217
2225
|
--header-padding: 0 var(--pbo-spacing-large) 0 var(--pbo-spacing-large);
|
|
2218
2226
|
--icon-button-size: 24px;
|
|
2227
|
+
--title-font-size: 18.75px;
|
|
2219
2228
|
}
|
|
2220
2229
|
|
|
2221
2230
|
.body {
|
|
2222
|
-
overflow:
|
|
2231
|
+
overflow: hidden;
|
|
2223
2232
|
}
|
|
2224
2233
|
|
|
2225
2234
|
.back-button {
|
|
@@ -2253,7 +2262,7 @@
|
|
|
2253
2262
|
}
|
|
2254
2263
|
|
|
2255
2264
|
.title {
|
|
2256
|
-
font-size: var(--
|
|
2265
|
+
font-size: var(--title-font-size);
|
|
2257
2266
|
}
|
|
2258
2267
|
|
|
2259
2268
|
.icon-button {
|
|
@@ -2284,10 +2293,14 @@
|
|
|
2284
2293
|
}
|
|
2285
2294
|
|
|
2286
2295
|
.category-selection {
|
|
2296
|
+
height: 100%;
|
|
2297
|
+
width: 100%;
|
|
2298
|
+
overflow: scroll;
|
|
2287
2299
|
display: grid;
|
|
2288
2300
|
grid-template-columns: repeat(12, 1fr);
|
|
2289
2301
|
padding: var(--pbo-spacing-small);
|
|
2290
2302
|
}
|
|
2303
|
+
|
|
2291
2304
|
@media screen and (min-width: 640px) {
|
|
2292
2305
|
.category-selection {
|
|
2293
2306
|
padding: var(--pbo-spacing-medium);
|
|
@@ -2295,11 +2308,14 @@
|
|
|
2295
2308
|
}
|
|
2296
2309
|
|
|
2297
2310
|
.category-selection pbo-card-selection {
|
|
2298
|
-
grid-column: 1 /
|
|
2311
|
+
grid-column: 1 / 13;
|
|
2299
2312
|
}
|
|
2300
2313
|
|
|
2301
2314
|
.editor {
|
|
2302
2315
|
padding: var(--pbo-spacing-small);
|
|
2316
|
+
overflow: scroll;
|
|
2317
|
+
height: 100%;
|
|
2318
|
+
width: 100%;
|
|
2303
2319
|
}
|
|
2304
2320
|
|
|
2305
2321
|
@media screen and (min-width: 640px) {
|
|
@@ -2310,13 +2326,13 @@
|
|
|
2310
2326
|
|
|
2311
2327
|
@media screen and (min-width: 768px) {
|
|
2312
2328
|
.category-selection pbo-card-selection {
|
|
2313
|
-
grid-column: 2 /
|
|
2329
|
+
grid-column: 2 / 12;
|
|
2314
2330
|
}
|
|
2315
2331
|
}
|
|
2316
2332
|
|
|
2317
2333
|
@media screen and (min-width: 1280px) {
|
|
2318
2334
|
.category-selection pbo-card-selection {
|
|
2319
|
-
grid-column:
|
|
2335
|
+
grid-column: 3 / 11;
|
|
2320
2336
|
}
|
|
2321
2337
|
}
|
|
2322
2338
|
|
|
@@ -2335,18 +2351,18 @@
|
|
|
2335
2351
|
height: 100%;
|
|
2336
2352
|
padding: var(--pbo-spacing-large);
|
|
2337
2353
|
}
|
|
2338
|
-
`,gm=
|
|
2354
|
+
`,gm=ct`
|
|
2339
2355
|
:host {
|
|
2340
2356
|
display: block;
|
|
2341
2357
|
}
|
|
2342
|
-
`;var fm=Object.defineProperty,mm=Object.getOwnPropertyDescriptor,Ya=(n,t,e,i)=>{for(var
|
|
2358
|
+
`;var fm=Object.defineProperty,mm=Object.getOwnPropertyDescriptor,Ya=(n,t,e,i)=>{for(var s=i>1?void 0:i?mm(t,e):t,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(t,e,s):o(s))||s);return i&&s&&fm(t,e,s),s};let is=class extends Pt{constructor(){super(...arguments),this.categories=[],this.loading=!0}render(){return this.loading?V`
|
|
2343
2359
|
<pbo-category skeleton></pbo-category>
|
|
2344
2360
|
<pbo-category skeleton></pbo-category>
|
|
2345
2361
|
`:V`
|
|
2346
2362
|
${qh(this.categories,t=>V`<pbo-category .cards=${t.cards} .name=${t.name}>
|
|
2347
2363
|
<h3 slot="title">${t.name}</h3>
|
|
2348
2364
|
</pbo-category>`)}
|
|
2349
|
-
`}};
|
|
2365
|
+
`}};is.styles=[Tt,gm];Ya([S({type:Array})],is.prototype,"categories",2);Ya([S({type:Boolean,reflect:!0})],is.prototype,"loading",2);is=Ya([xt("pbo-card-selection")],is);var vm=Object.defineProperty,bm=Object.getOwnPropertyDescriptor,Zt=(n,t,e,i)=>{for(var s=i>1?void 0:i?bm(t,e):t,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(t,e,s):o(s))||s);return i&&s&&vm(t,e,s),s};let Mt=class extends Pt{constructor(){super(...arguments),this.onClose=()=>{},this.currentPage="selection",this.categories=[],this.isLoadingCategories=!1,this.isError=!1,this.errorMessage="Neque porro quisquam est qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit...",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)}goToEditor(){this.currentPage="editor"}goToSelector(){this.currentPage="selection"}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(){console.log(this.categories),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){console.log("Categories from findCardInCategoryById",this.categories);for(const e of this.categories){const i=e.cards.find(s=>s.pboId===t);if(console.log("card from findCardInCategoryById",i),i)return i}return null}render(){return V`
|
|
2350
2366
|
<div part="base" class="page-manager">
|
|
2351
2367
|
<div class="header" part="header">
|
|
2352
2368
|
<div class="back-button" part="back-button">
|
|
@@ -2386,7 +2402,7 @@
|
|
|
2386
2402
|
<h4 class="notification">
|
|
2387
2403
|
An error occurred while loading the page. Please refresh the page and try again.
|
|
2388
2404
|
</h4>
|
|
2389
|
-
${this.errorMessage&&this.errorMessage!==""?V`<p class="error-message">${this.errorMessage}</p>`:
|
|
2405
|
+
${this.errorMessage&&this.errorMessage!==""?V`<p class="error-message">${this.errorMessage}</p>`:at}
|
|
2390
2406
|
</div>
|
|
2391
2407
|
<pbo-button
|
|
2392
2408
|
variant="primary"
|
|
@@ -2396,34 +2412,33 @@
|
|
|
2396
2412
|
>
|
|
2397
2413
|
Refresh page now
|
|
2398
2414
|
</pbo-button>
|
|
2399
|
-
</div>`:
|
|
2400
|
-
|
|
2401
|
-
|
|
2402
|
-
|
|
2403
|
-
|
|
2404
|
-
|
|
2405
|
-
|
|
2406
|
-
|
|
2407
|
-
|
|
2408
|
-
|
|
2409
|
-
|
|
2410
|
-
|
|
2411
|
-
|
|
2412
|
-
|
|
2413
|
-
|
|
2414
|
-
|
|
2415
|
-
|
|
2416
|
-
|
|
2417
|
-
|
|
2418
|
-
|
|
2419
|
-
|
|
2420
|
-
|
|
2421
|
-
|
|
2422
|
-
|
|
2423
|
-
</div>`:ct)}
|
|
2415
|
+
</div>`:at}
|
|
2416
|
+
<div
|
|
2417
|
+
class="category-selection"
|
|
2418
|
+
?hidden=${this.currentPage!=="selection"}
|
|
2419
|
+
part="category-selection-container"
|
|
2420
|
+
>
|
|
2421
|
+
<pbo-card-selection
|
|
2422
|
+
part="card-selection"
|
|
2423
|
+
.categories=${this.categories}
|
|
2424
|
+
?loading=${this.isLoadingCategories}
|
|
2425
|
+
name="selection"
|
|
2426
|
+
></pbo-card-selection>
|
|
2427
|
+
</div>
|
|
2428
|
+
<div class="editor" ?hidden=${this.currentPage!=="editor"} part="editor-container">
|
|
2429
|
+
<pbo-editor
|
|
2430
|
+
part="editor"
|
|
2431
|
+
exportparts="editor-card-slider-container,editor-form-container,type-form,handwritten-form,editor-textarea,font-selector-label,color-selector-label,alignment-selector-label,type-form-label, cta-button-base,cta-button-label,cta-link-button-base,cta-link-button-label"
|
|
2432
|
+
.card=${this.selectedCard}
|
|
2433
|
+
.submitTypeForm=${this.submitTypeForm}
|
|
2434
|
+
.submitHandwrittenForm=${this.submitHandwrittenForm}
|
|
2435
|
+
.getProcessedImg=${this.getProcessedImg}
|
|
2436
|
+
name="editor"
|
|
2437
|
+
></pbo-editor>
|
|
2438
|
+
</div>
|
|
2424
2439
|
</div>
|
|
2425
2440
|
</div>
|
|
2426
|
-
`}};
|
|
2441
|
+
`}};Mt.styles=[Tt,pm];Mt.dependencies={"pbo-button":pt,"pbo-card-selection":is,"pbo-editor":Nt};Zt([q("pbo-card-selection")],Mt.prototype,"cardSelectionEl",2);Zt([S({type:Function})],Mt.prototype,"onClose",2);Zt([S({type:String,reflect:!0})],Mt.prototype,"currentPage",2);Zt([S()],Mt.prototype,"categories",2);Zt([S()],Mt.prototype,"submitTypeForm",2);Zt([S()],Mt.prototype,"submitHandwrittenForm",2);Zt([S()],Mt.prototype,"getProcessedImg",2);Zt([S({type:Boolean})],Mt.prototype,"isLoadingCategories",2);Zt([S({type:Boolean})],Mt.prototype,"isError",2);Zt([S({type:String})],Mt.prototype,"errorMessage",2);Zt([W()],Mt.prototype,"selectedCard",2);Zt([W()],Mt.prototype,"selectedCardId",2);Zt([W()],Mt.prototype,"selectedCardDetails",2);Zt([Z("getProcessedImg")],Mt.prototype,"handleGetProcessedImgUpdate",1);Zt([Z("categories")],Mt.prototype,"handleCategoriesUpdate",1);Mt=Zt([xt("pbo-page-manager")],Mt);const o0=Mt,a0=is,_m=ct`
|
|
2427
2442
|
:host {
|
|
2428
2443
|
display: block;
|
|
2429
2444
|
width: 100%;
|
|
@@ -2475,33 +2490,33 @@
|
|
|
2475
2490
|
.type-canvas-container.image-loading pbo-image {
|
|
2476
2491
|
display: block;
|
|
2477
2492
|
}
|
|
2478
|
-
`;function b(n,t,e){return(t=function(i){var
|
|
2479
|
-
void main(){}`),r=t.createShader(t.FRAGMENT_SHADER);return!!r&&(t.shaderSource(r,i),t.compileShader(r),!!t.getShaderParameter(r,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 Cm={};let uc;const Ge=()=>uc||(uc={document,window,isTouchSupported:"ontouchstart"in window||"ontouchstart"in document||window&&window.navigator&&window.navigator.maxTouchPoints>0,WebGLProbe:new wm,dispose(){},copyPasteData:Cm}),jr=()=>Ge().document,Xa=()=>Ge().window,Zh=()=>{var n;return Math.max((n=tt.devicePixelRatio)!==null&&n!==void 0?n:Xa().devicePixelRatio,1)},as=new class{constructor(){b(this,"charWidthsCache",{}),b(this,"boundsOfCurveCache",{})}getFontCache(n){let{fontFamily:t,fontStyle:e,fontWeight:i}=n;t=t.toLowerCase(),this.charWidthsCache[t]||(this.charWidthsCache[t]={});const r=this.charWidthsCache[t],s="".concat(e.toLowerCase(),"_").concat((i+"").toLowerCase());return r[s]||(r[s]={}),r[s]}clearFontCache(n){(n=(n||"").toLowerCase())?this.charWidthsCache[n]&&delete this.charWidthsCache[n]:this.charWidthsCache={}}limitDimsByArea(n){const{perfLimitSizeTotal:t}=tt,e=Math.sqrt(t*n);return[Math.floor(e),Math.floor(t/e)]}},ua="6.5.4";function Sn(){}const Rs=Math.PI/2,Rn=2*Math.PI,Ka=Math.PI/180,ie=Object.freeze([1,0,0,1,0,0]),qa=16,vi=.4477152502,K="center",it="left",le="top",da="bottom",Et="right",ce="none",Za=/\r?\n/,Jh="moving",fo="scaling",Qh="rotating",Ja="rotate",tu="skewing",xs="resizing",Sm="modifyPoly",Tm="modifyPath",$n="changed",mo="scale",pe="scaleX",Ee="scaleY",Rr="skewX",$r="skewY",$t="fill",he="stroke",Bn="modified",hr="json",Ro="svg",R=new class{constructor(){this[hr]=new Map,this[Ro]=new Map}has(n){return this[hr].has(n)}getClass(n){const t=this[hr].get(n);if(!t)throw new ze("No class registered for ".concat(n));return t}setClass(n,t){t?this[hr].set(t,n):(this[hr].set(n.type,n),this[hr].set(n.type.toLowerCase(),n))}getSVGClass(n){return this[Ro].get(n)}setSVGClass(n,t){this[Ro].set(t??n.type.toLowerCase(),n)}},Nn=new class extends Array{remove(n){const t=this.indexOf(n);t>-1&&this.splice(t,1)}cancelAll(){const n=this.splice(0);return n.forEach(t=>t.abort()),n}cancelByCanvas(n){if(!n)return[];const t=this.filter(e=>{var i;return e.target===n||typeof e.target=="object"&&((i=e.target)===null||i===void 0?void 0:i.canvas)===n});return t.forEach(e=>e.abort()),t}cancelByTarget(n){if(!n)return[];const t=this.filter(e=>e.target===n);return t.forEach(e=>e.abort()),t}};class Em{constructor(){b(this,"__eventListeners",{})}on(t,e){if(this.__eventListeners||(this.__eventListeners={}),typeof t=="object")return Object.entries(t).forEach(i=>{let[r,s]=i;this.on(r,s)}),()=>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(r=>{let[s,o]=r;i.push(this.once(s,o))}),()=>i.forEach(r=>r())}if(e){const i=this.on(t,function(){for(var r=arguments.length,s=new Array(r),o=0;o<r;o++)s[o]=arguments[o];e.call(this,...s),i()});return i}return()=>!1}_removeEventListener(t,e){if(this.__eventListeners[t])if(e){const i=this.__eventListeners[t],r=i.indexOf(e);r>-1&&i.splice(r,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[r,s]=i;this._removeEventListener(r,s)}):this._removeEventListener(t,e)}fire(t,e){var i;if(!this.__eventListeners)return;const r=(i=this.__eventListeners[t])===null||i===void 0?void 0:i.concat();if(r)for(let s=0;s<r.length;s++)r[s].call(this,e||{})}}const fr=(n,t)=>{const e=n.indexOf(t);return e!==-1&&n.splice(e,1),n},di=n=>{if(n===0)return 1;switch(Math.abs(n)/Rs){case 1:case 3:return 0;case 2:return-1}return Math.cos(n)},pi=n=>{if(n===0)return 0;const t=n/Rs,e=Math.sign(n);switch(t){case 1:return e;case 2:return 0;case 3:return-e}return Math.sin(n)};class w{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 w(this.x+t.x,this.y+t.y)}addEquals(t){return this.x+=t.x,this.y+=t.y,this}scalarAdd(t){return new w(this.x+t,this.y+t)}scalarAddEquals(t){return this.x+=t,this.y+=t,this}subtract(t){return new w(this.x-t.x,this.y-t.y)}subtractEquals(t){return this.x-=t.x,this.y-=t.y,this}scalarSubtract(t){return new w(this.x-t,this.y-t)}scalarSubtractEquals(t){return this.x-=t,this.y-=t,this}multiply(t){return new w(this.x*t.x,this.y*t.y)}scalarMultiply(t){return new w(this.x*t,this.y*t)}scalarMultiplyEquals(t){return this.x*=t,this.y*=t,this}divide(t){return new w(this.x/t.x,this.y/t.y)}scalarDivide(t){return new w(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 w(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 w(Math.min(this.x,t.x),Math.min(this.y,t.y))}max(t){return new w(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 w(this.x,this.y)}rotate(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:Qa;const i=pi(t),r=di(t),s=this.subtract(e);return new w(s.x*r-s.y*i,s.x*i+s.y*r).add(e)}transform(t){let e=arguments.length>1&&arguments[1]!==void 0&&arguments[1];return new w(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 Qa=new w(0,0),Tn=n=>!!n&&Array.isArray(n._objects);function eu(n){class t extends n{constructor(){super(...arguments),b(this,"_objects",[])}_onObjectAdded(i){}_onObjectRemoved(i){}_onStackOrderChanged(i){}add(){for(var i=arguments.length,r=new Array(i),s=0;s<i;s++)r[s]=arguments[s];const o=this._objects.push(...r);return r.forEach(a=>this._onObjectAdded(a)),o}insertAt(i){for(var r=arguments.length,s=new Array(r>1?r-1:0),o=1;o<r;o++)s[o-1]=arguments[o];return this._objects.splice(i,0,...s),s.forEach(a=>this._onObjectAdded(a)),this._objects.length}remove(){const i=this._objects,r=[];for(var s=arguments.length,o=new Array(s),a=0;a<s;a++)o[a]=arguments[a];return o.forEach(l=>{const c=i.indexOf(l);c!==-1&&(i.splice(c,1),r.push(l),this._onObjectRemoved(l))}),r}forEachObject(i){this.getObjects().forEach((r,s,o)=>i(r,s,o))}getObjects(){for(var i=arguments.length,r=new Array(i),s=0;s<i;s++)r[s]=arguments[s];return r.length===0?[...this._objects]:this._objects.filter(o=>o.isType(...r))}item(i){return this._objects[i]}isEmpty(){return this._objects.length===0}size(){return this._objects.length}contains(i,r){return!!this._objects.includes(i)||!!r&&this._objects.some(s=>s instanceof t&&s.contains(i,!0))}complexity(){return this._objects.reduce((i,r)=>i+=r.complexity?r.complexity():0,0)}sendObjectToBack(i){return!(!i||i===this._objects[0])&&(fr(this._objects,i),this._objects.unshift(i),this._onStackOrderChanged(i),!0)}bringObjectToFront(i){return!(!i||i===this._objects[this._objects.length-1])&&(fr(this._objects,i),this._objects.push(i),this._onStackOrderChanged(i),!0)}sendObjectBackwards(i,r){if(!i)return!1;const s=this._objects.indexOf(i);if(s!==0){const o=this.findNewLowerIndex(i,s,r);return fr(this._objects,i),this._objects.splice(o,0,i),this._onStackOrderChanged(i),!0}return!1}bringObjectForward(i,r){if(!i)return!1;const s=this._objects.indexOf(i);if(s!==this._objects.length-1){const o=this.findNewUpperIndex(i,s,r);return fr(this._objects,i),this._objects.splice(o,0,i),this._onStackOrderChanged(i),!0}return!1}moveObjectTo(i,r){return i!==this._objects[r]&&(fr(this._objects,i),this._objects.splice(r,0,i),this._onStackOrderChanged(i),!0)}findNewLowerIndex(i,r,s){let o;if(s){o=r;for(let a=r-1;a>=0;--a)if(i.isOverlapping(this._objects[a])){o=a;break}}else o=r-1;return o}findNewUpperIndex(i,r,s){let o;if(s){o=r;for(let a=r+1;a<this._objects.length;++a)if(i.isOverlapping(this._objects[a])){o=a;break}}else o=r+1;return o}collectObjects(i){let{left:r,top:s,width:o,height:a}=i,{includeIntersecting:l=!0}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};const c=[],h=new w(r,s),u=h.add(new w(o,a));for(let d=this._objects.length-1;d>=0;d--){const p=this._objects[d];p.selectable&&p.visible&&(l&&p.intersectsWithRect(h,u)||p.isContainedWithinRect(h,u)||l&&p.containsPoint(h)||l&&p.containsPoint(u))&&c.push(p)}return c}}return t}class iu extends Em{_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 En(n){return Xa().requestAnimationFrame(n)}function Om(n){return Xa().cancelAnimationFrame(n)}let km=0;const Ii=()=>km++,Fe=()=>{const n=jr().createElement("canvas");if(!n||n.getContext===void 0)throw new ze("Failed to create `canvas` element");return n},Am=()=>jr().createElement("img"),Ye=n=>{const t=Fe();return t.width=n.width,t.height=n.height,t},ru=(n,t,e)=>n.toDataURL("image/".concat(t),e),Ot=n=>n*Ka,rr=n=>n/Ka,Pm=n=>n.every((t,e)=>t===ie[e]),oe=(n,t,e)=>new w(n).transform(t,e),Ie=n=>{const t=1/(n[0]*n[3]-n[1]*n[2]),e=[t*n[3],-t*n[1],-t*n[2],t*n[0],0,0],{x:i,y:r}=new w(n[4],n[5]).transform(e,!0);return e[4]=-i,e[5]=-r,e},Vt=(n,t,e)=>[n[0]*t[0]+n[2]*t[1],n[1]*t[0]+n[3]*t[1],n[0]*t[2]+n[2]*t[3],n[1]*t[2]+n[3]*t[3],e?0:n[0]*t[4]+n[2]*t[5]+n[4],e?0:n[1]*t[4]+n[3]*t[5]+n[5]],tl=(n,t)=>n.reduceRight((e,i)=>i&&e?Vt(i,e,t):i||e,void 0)||ie.concat(),su=n=>{let[t,e]=n;return Math.atan2(e,t)},zn=n=>{const t=su(n),e=Math.pow(n[0],2)+Math.pow(n[1],2),i=Math.sqrt(e),r=(n[0]*n[3]-n[2]*n[1])/i,s=Math.atan2(n[0]*n[2]+n[1]*n[3],e);return{angle:rr(t),scaleX:i,scaleY:r,skewX:rr(s),skewY:0,translateX:n[4]||0,translateY:n[5]||0}},$s=function(n){return[1,0,0,1,n,arguments.length>1&&arguments[1]!==void 0?arguments[1]:0]};function Bs(){let{angle:n=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=Ot(n),r=di(i),s=pi(i);return[r,s,-s,r,t?t-(r*t-s*e):0,e?e-(s*t+r*e):0]}const el=function(n){return[n,0,0,arguments.length>1&&arguments[1]!==void 0?arguments[1]:n,0,0]},nu=n=>Math.tan(Ot(n)),ou=n=>[1,0,nu(n),1,0,0],au=n=>[1,nu(n),0,1,0,0],vo=n=>{let{scaleX:t=1,scaleY:e=1,flipX:i=!1,flipY:r=!1,skewX:s=0,skewY:o=0}=n,a=el(i?-t:t,r?-e:e);return s&&(a=Vt(a,ou(s),!0)),o&&(a=Vt(a,au(o),!0)),a},Dm=n=>{const{translateX:t=0,translateY:e=0,angle:i=0}=n;let r=$s(t,e);i&&(r=Vt(r,Bs({angle:i})));const s=vo(n);return Pm(s)||(r=Vt(r,s)),r},On=function(n){let{signal:t,crossOrigin:e=null}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return new Promise(function(i,r){if(t&&t.aborted)return r(new ym("loadImage"));const s=Am();let o;t&&(o=function(l){s.src="",r(l)},t.addEventListener("abort",o,{once:!0}));const a=function(){s.onload=s.onerror=null,o&&(t==null||t.removeEventListener("abort",o)),i(s)};n?(s.onload=a,s.onerror=function(){o&&(t==null||t.removeEventListener("abort",o)),r(new ze("Error loading ".concat(s.src)))},e&&(s.crossOrigin=e),s.src=n):a()})},ws=function(n){let{signal:t,reviver:e=Sn}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return new Promise((i,r)=>{const s=[];t&&t.addEventListener("abort",r,{once:!0}),Promise.all(n.map(o=>R.getClass(o.type).fromObject(o,{signal:t}).then(a=>(e(o,a),s.push(a),a)))).then(i).catch(o=>{s.forEach(a=>{a.dispose&&a.dispose()}),r(o)}).finally(()=>{t&&t.removeEventListener("abort",r)})})},bo=function(n){let{signal:t}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return new Promise((e,i)=>{const r=[];t&&t.addEventListener("abort",i,{once:!0});const s=Object.values(n).map(a=>a&&a.type&&R.has(a.type)?ws([a],{signal:t}).then(l=>{let[c]=l;return r.push(c),c}):a),o=Object.keys(n);Promise.all(s).then(a=>a.reduce((l,c,h)=>(l[o[h]]=c,l),{})).then(e).catch(a=>{r.forEach(l=>{l.dispose&&l.dispose()}),i(a)}).finally(()=>{t&&t.removeEventListener("abort",i)})})},Br=function(n){return(arguments.length>1&&arguments[1]!==void 0?arguments[1]:[]).reduce((t,e)=>(e in n&&(t[e]=n[e]),t),{})},il=(n,t)=>Object.keys(n).reduce((e,i)=>(t(n[i],i,n)&&(e[i]=n[i]),e),{}),dc={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"},$o=(n,t,e)=>(e<0&&(e+=1),e>1&&(e-=1),e<1/6?n+6*(t-n)*e:e<.5?t:e<2/3?n+(t-n)*(2/3-e)*6:n),pc=(n,t,e,i)=>{n/=255,t/=255,e/=255;const r=Math.max(n,t,e),s=Math.min(n,t,e);let o,a;const l=(r+s)/2;if(r===s)o=a=0;else{const c=r-s;switch(a=l>.5?c/(2-r-s):c/(r+s),r){case n:o=(t-e)/c+(t<e?6:0);break;case t:o=(e-n)/c+2;break;case e:o=(n-t)/c+4}o/=6}return[Math.round(360*o),Math.round(100*a),Math.round(100*l),i]},gc=function(){let n=arguments.length>0&&arguments[0]!==void 0?arguments[0]:"1";return parseFloat(n)/(n.endsWith("%")?100:1)},Ys=n=>Math.min(Math.round(n),255).toString(16).toUpperCase().padStart(2,"0"),fc=n=>{let[t,e,i,r=1]=n;const s=Math.round(.3*t+.59*e+.11*i);return[s,s,s,r]};class rt{constructor(t){if(b(this,"isUnrecognised",!1),t)if(t instanceof rt)this.setSource([...t._source]);else if(Array.isArray(t)){const[e,i,r,s=1]=t;this.setSource([e,i,r,s])}else this.setSource(this._tryParsingColor(t));else this.setSource([0,0,0,1])}_tryParsingColor(t){return(t=t.toLowerCase())in dc&&(t=dc[t]),t==="transparent"?[255,255,255,0]:rt.sourceFromHex(t)||rt.sourceFromRgb(t)||rt.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]=pc(...this.getSource());return"hsl(".concat(t,",").concat(e,"%,").concat(i,"%)")}toHsla(){const[t,e,i,r]=pc(...this.getSource());return"hsla(".concat(t,",").concat(e,"%,").concat(i,"%,").concat(r,")")}toHex(){return this.toHexa().slice(0,6)}toHexa(){const[t,e,i,r]=this.getSource();return"".concat(Ys(t)).concat(Ys(e)).concat(Ys(i)).concat(Ys(Math.round(255*r)))}getAlpha(){return this.getSource()[3]}setAlpha(t){return this._source[3]=t,this}toGrayscale(){return this.setSource(fc(this.getSource())),this}toBlackWhite(t){const[e,,,i]=fc(this.getSource()),r=e<(t||127)?0:255;return this.setSource([r,r,r,i]),this}overlayWith(t){t instanceof rt||(t=new rt(t));const e=this.getSource(),i=t.getSource(),[r,s,o]=e.map((a,l)=>Math.round(.5*a+.5*i[l]));return this.setSource([r,s,o,e[3]]),this}static fromRgb(t){return rt.fromRgba(t)}static fromRgba(t){return new rt(rt.sourceFromRgb(t))}static sourceFromRgb(t){const e=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,r,s]=e.slice(1,4).map(o=>{const a=parseFloat(o);return o.endsWith("%")?Math.round(2.55*a):a});return[i,r,s,gc(e[4])]}}static fromHsl(t){return rt.fromHsla(t)}static fromHsla(t){return new rt(rt.sourceFromHsl(t))}static sourceFromHsl(t){const e=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=(rt.parseAngletoDegrees(e[1])%360+360)%360/360,r=parseFloat(e[2])/100,s=parseFloat(e[3])/100;let o,a,l;if(r===0)o=a=l=s;else{const c=s<=.5?s*(r+1):s+r-s*r,h=2*s-c;o=$o(h,c,i+1/3),a=$o(h,c,i),l=$o(h,c,i-1/3)}return[Math.round(255*o),Math.round(255*a),Math.round(255*l),gc(e[4])]}static fromHex(t){return new rt(rt.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[r,s,o,a=255]=i.map(l=>parseInt(l,16));return[r,s,o,a/255]}}static parseAngletoDegrees(t){const e=t.toLowerCase(),i=parseFloat(e);return e.includes("rad")?rr(i):e.includes("turn")?360*i:i}}const mt=(n,t)=>parseFloat(Number(n).toFixed(t)),Sr=function(n){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:qa;const e=/\D{0,2}$/.exec(n),i=parseFloat(n),r=tt.DPI;switch(e==null?void 0:e[0]){case"mm":return i*r/25.4;case"cm":return i*r/2.54;case"in":return i*r;case"pt":return i*r/72;case"pc":return i*r/72*12;case"em":return i*t;default:return i}},Mm=n=>{const[t,e]=n.trim().split(" "),[i,r]=(s=t)&&s!==ce?[s.slice(1,4),s.slice(5,8)]:s===ce?[s,s]:["Mid","Mid"];var s;return{meetOrSlice:e||"meet",alignX:i,alignY:r}},Hn=n=>"matrix("+n.map(t=>mt(t,tt.NUM_FRACTION_DIGITS)).join(" ")+")",Cs=function(n,t){let e,i,r=!(arguments.length>2&&arguments[2]!==void 0)||arguments[2];if(t)if(t.toLive)e="url(#SVGID_".concat(t.id,")");else{const s=new rt(t),o=s.getAlpha();e=s.toRgb(),o!==1&&(i=o.toString())}else e="none";return r?"".concat(n,": ").concat(e,"; ").concat(i?"".concat(n,"-opacity: ").concat(i,"; "):""):"".concat(n,'="').concat(e,'" ').concat(i?"".concat(n,'-opacity="').concat(i,'" '):"")},we=n=>!!n&&n.toLive!==void 0,mc=n=>!!n&&typeof n.toObject=="function",vc=n=>!!n&&n.offsetX!==void 0&&"source"in n,Ui=n=>!!n&&"multiSelectionStacking"in n;function lu(n){const t=n&&De(n);let e=0,i=0;if(!n||!t)return{left:e,top:i};let r=n;const s=t.documentElement,o=t.body||{scrollLeft:0,scrollTop:0};for(;r&&(r.parentNode||r.host)&&(r=r.parentNode||r.host,r===t?(e=o.scrollLeft||s.scrollLeft||0,i=o.scrollTop||s.scrollTop||0):(e+=r.scrollLeft||0,i+=r.scrollTop||0),r.nodeType!==1||r.style.position!=="fixed"););return{left:e,top:i}}const De=n=>n.ownerDocument||null,cu=n=>{var t;return((t=n.ownerDocument)===null||t===void 0?void 0:t.defaultView)||null},hu=function(n,t,e){let{width:i,height:r}=e,s=arguments.length>3&&arguments[3]!==void 0?arguments[3]:1;n.width=i,n.height=r,s>1&&(n.setAttribute("width",(i*s).toString()),n.setAttribute("height",(r*s).toString()),t.scale(s,s))},pa=(n,t)=>{let{width:e,height:i}=t;e&&(n.style.width=typeof e=="number"?"".concat(e,"px"):e),i&&(n.style.height=typeof i=="number"?"".concat(i,"px"):i)};function bc(n){return n.onselectstart!==void 0&&(n.onselectstart=()=>!1),n.style.userSelect=ce,n}class uu{constructor(t){b(this,"_originalCanvasStyle",void 0),b(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&&jr().getElementById(t)||Fe();var i;if(e.hasAttribute("data-fabric"))throw new ze("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:r}=this.lower;r.classList.remove("lower-canvas"),r.removeAttribute("data-fabric"),r.setAttribute("width","".concat(e)),r.setAttribute("height","".concat(i)),r.style.cssText=this._originalCanvasStyle||"",this._originalCanvasStyle=void 0}setDimensions(t,e){const{el:i,ctx:r}=this.lower;hu(i,r,t,e)}setCSSDimensions(t){pa(this.lower.el,t)}calcOffset(){return function(t){var e;const i=t&&De(t),r={left:0,top:0};if(!i)return r;const s=((e=cu(t))===null||e===void 0?void 0:e.getComputedStyle(t,null))||{};r.left+=parseInt(s.borderLeftWidth,10)||0,r.top+=parseInt(s.borderTopWidth,10)||0,r.left+=parseInt(s.paddingLeft,10)||0,r.top+=parseInt(s.paddingTop,10)||0;let o={left:0,top:0};const a=i.documentElement;t.getBoundingClientRect!==void 0&&(o=t.getBoundingClientRect());const l=lu(t);return{left:o.left+l.left-(a.clientLeft||0)+r.left,top:o.top+l.top-(a.clientTop||0)+r.top}}(this.lower.el)}dispose(){Ge().dispose(this.lower.el),delete this.lower}}const Im={backgroundVpt:!0,backgroundColor:"",overlayVpt:!0,overlayColor:"",includeDefaultValues:!0,svgViewportTransformation:!0,renderOnAddRemove:!0,skipOffscreen:!0,enableRetinaScaling:!0,imageSmoothingEnabled:!0,controlsAboveOverlay:!1,allowTouchScrolling:!1,viewportTransform:[...ie]};class Ns extends eu(iu){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 Ns.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 uu(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),r=1;r<e;r++)i[r-1]=arguments[r];const s=super.insertAt(t,...i);return i.length>0&&this.renderOnAddRemove&&this.requestRenderAll(),s}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.
|
|
2480
|
-
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?Zh():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
|
|
2493
|
+
`;function b(n,t,e){return(t=function(i){var s=function(r,o){if(typeof r!="object"||!r)return r;var a=r[Symbol.toPrimitive];if(a!==void 0){var l=a.call(r,o);if(typeof l!="object")return l;throw new TypeError("@@toPrimitive must return a primitive value.")}return(o==="string"?String:Number)(r)}(i,"string");return typeof s=="symbol"?s:s+""}(t))in n?Object.defineProperty(n,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):n[t]=e,n}function cc(n,t){var e=Object.keys(n);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(n);t&&(i=i.filter(function(s){return Object.getOwnPropertyDescriptor(n,s).enumerable})),e.push.apply(e,i)}return e}function _(n){for(var t=1;t<arguments.length;t++){var e=arguments[t]!=null?arguments[t]:{};t%2?cc(Object(e),!0).forEach(function(i){b(n,i,e[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(e)):cc(Object(e)).forEach(function(i){Object.defineProperty(n,i,Object.getOwnPropertyDescriptor(e,i))})}return n}function gt(n,t){if(n==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}(n,t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(n);for(i=0;i<r.length;i++)e=r[i],t.indexOf(e)>=0||{}.propertyIsEnumerable.call(n,e)&&(s[e]=n[e])}return s}function $i(n,t){return t||(t=n.slice(0)),Object.freeze(Object.defineProperties(n,{raw:{value:Object.freeze(t)}}))}class hc{constructor(){b(this,"browserShadowBlurConstant",1),b(this,"DPI",96),b(this,"devicePixelRatio",typeof window<"u"?window.devicePixelRatio:1),b(this,"perfLimitSizeTotal",2097152),b(this,"maxCacheSideLimit",4096),b(this,"minCacheSideLimit",256),b(this,"disableStyleCopyPaste",!1),b(this,"enableGLFiltering",!0),b(this,"textureSize",4096),b(this,"forceGLPutImageData",!1),b(this,"cachesBoundsOfCurve",!1),b(this,"fontPaths",{}),b(this,"NUM_FRACTION_DIGITS",4)}}const tt=new class extends hc{constructor(n){super(),this.configure(n)}configure(){let n=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};Object.assign(this,n)}addFonts(){let n=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};this.fontPaths=_(_({},this.fontPaths),n)}removeFonts(){(arguments.length>0&&arguments[0]!==void 0?arguments[0]:[]).forEach(n=>{delete this.fontPaths[n]})}clearFonts(){this.fontPaths={}}restoreDefaults(n){const t=new hc,e=(n==null?void 0:n.reduce((i,s)=>(i[s]=t[s],i),{}))||t;this.configure(e)}},Mi=function(n){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[n]("fabric",...e)};class ze extends Error{constructor(t,e){super("fabric: ".concat(t),e)}}class ym extends ze{constructor(t){super("".concat(t," 'options.signal' is in 'aborted' state"))}}class xm{}class wm extends xm{testPrecision(t,e){const i="precision ".concat(e,` float;
|
|
2494
|
+
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 Cm={};let uc;const Ge=()=>uc||(uc={document,window,isTouchSupported:"ontouchstart"in window||"ontouchstart"in document||window&&window.navigator&&window.navigator.maxTouchPoints>0,WebGLProbe:new wm,dispose(){},copyPasteData:Cm}),js=()=>Ge().document,Xa=()=>Ge().window,Zh=()=>{var n;return Math.max((n=tt.devicePixelRatio)!==null&&n!==void 0?n:Xa().devicePixelRatio,1)},or=new class{constructor(){b(this,"charWidthsCache",{}),b(this,"boundsOfCurveCache",{})}getFontCache(n){let{fontFamily:t,fontStyle:e,fontWeight:i}=n;t=t.toLowerCase(),this.charWidthsCache[t]||(this.charWidthsCache[t]={});const s=this.charWidthsCache[t],r="".concat(e.toLowerCase(),"_").concat((i+"").toLowerCase());return s[r]||(s[r]={}),s[r]}clearFontCache(n){(n=(n||"").toLowerCase())?this.charWidthsCache[n]&&delete this.charWidthsCache[n]:this.charWidthsCache={}}limitDimsByArea(n){const{perfLimitSizeTotal:t}=tt,e=Math.sqrt(t*n);return[Math.floor(e),Math.floor(t/e)]}},ua="6.5.4";function Cn(){}const jr=Math.PI/2,jn=2*Math.PI,Ka=Math.PI/180,ie=Object.freeze([1,0,0,1,0,0]),qa=16,bi=.4477152502,K="center",it="left",le="top",da="bottom",Ot="right",ce="none",Za=/\r?\n/,Jh="moving",go="scaling",Qh="rotating",Ja="rotate",tu="skewing",yr="resizing",Sm="modifyPoly",Tm="modifyPath",Rn="changed",fo="scale",pe="scaleX",Ee="scaleY",Rs="skewX",$s="skewY",Rt="fill",he="stroke",$n="modified",hs="json",Ro="svg",R=new class{constructor(){this[hs]=new Map,this[Ro]=new Map}has(n){return this[hs].has(n)}getClass(n){const t=this[hs].get(n);if(!t)throw new ze("No class registered for ".concat(n));return t}setClass(n,t){t?this[hs].set(t,n):(this[hs].set(n.type,n),this[hs].set(n.type.toLowerCase(),n))}getSVGClass(n){return this[Ro].get(n)}setSVGClass(n,t){this[Ro].set(t??n.type.toLowerCase(),n)}},Bn=new class extends Array{remove(n){const t=this.indexOf(n);t>-1&&this.splice(t,1)}cancelAll(){const n=this.splice(0);return n.forEach(t=>t.abort()),n}cancelByCanvas(n){if(!n)return[];const t=this.filter(e=>{var i;return e.target===n||typeof e.target=="object"&&((i=e.target)===null||i===void 0?void 0:i.canvas)===n});return t.forEach(e=>e.abort()),t}cancelByTarget(n){if(!n)return[];const t=this.filter(e=>e.target===n);return t.forEach(e=>e.abort()),t}};class Em{constructor(){b(this,"__eventListeners",{})}on(t,e){if(this.__eventListeners||(this.__eventListeners={}),typeof t=="object")return Object.entries(t).forEach(i=>{let[s,r]=i;this.on(s,r)}),()=>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[r,o]=s;i.push(this.once(r,o))}),()=>i.forEach(s=>s())}if(e){const i=this.on(t,function(){for(var s=arguments.length,r=new Array(s),o=0;o<s;o++)r[o]=arguments[o];e.call(this,...r),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,r]=i;this._removeEventListener(s,r)}):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 r=0;r<s.length;r++)s[r].call(this,e||{})}}const fs=(n,t)=>{const e=n.indexOf(t);return e!==-1&&n.splice(e,1),n},pi=n=>{if(n===0)return 1;switch(Math.abs(n)/jr){case 1:case 3:return 0;case 2:return-1}return Math.cos(n)},gi=n=>{if(n===0)return 0;const t=n/jr,e=Math.sign(n);switch(t){case 1:return e;case 2:return 0;case 3:return-e}return Math.sin(n)};class w{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 w(this.x+t.x,this.y+t.y)}addEquals(t){return this.x+=t.x,this.y+=t.y,this}scalarAdd(t){return new w(this.x+t,this.y+t)}scalarAddEquals(t){return this.x+=t,this.y+=t,this}subtract(t){return new w(this.x-t.x,this.y-t.y)}subtractEquals(t){return this.x-=t.x,this.y-=t.y,this}scalarSubtract(t){return new w(this.x-t,this.y-t)}scalarSubtractEquals(t){return this.x-=t,this.y-=t,this}multiply(t){return new w(this.x*t.x,this.y*t.y)}scalarMultiply(t){return new w(this.x*t,this.y*t)}scalarMultiplyEquals(t){return this.x*=t,this.y*=t,this}divide(t){return new w(this.x/t.x,this.y/t.y)}scalarDivide(t){return new w(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 w(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 w(Math.min(this.x,t.x),Math.min(this.y,t.y))}max(t){return new w(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 w(this.x,this.y)}rotate(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:Qa;const i=gi(t),s=pi(t),r=this.subtract(e);return new w(r.x*s-r.y*i,r.x*i+r.y*s).add(e)}transform(t){let e=arguments.length>1&&arguments[1]!==void 0&&arguments[1];return new w(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 Qa=new w(0,0),Sn=n=>!!n&&Array.isArray(n._objects);function eu(n){class t extends n{constructor(){super(...arguments),b(this,"_objects",[])}_onObjectAdded(i){}_onObjectRemoved(i){}_onStackOrderChanged(i){}add(){for(var i=arguments.length,s=new Array(i),r=0;r<i;r++)s[r]=arguments[r];const o=this._objects.push(...s);return s.forEach(a=>this._onObjectAdded(a)),o}insertAt(i){for(var s=arguments.length,r=new Array(s>1?s-1:0),o=1;o<s;o++)r[o-1]=arguments[o];return this._objects.splice(i,0,...r),r.forEach(a=>this._onObjectAdded(a)),this._objects.length}remove(){const i=this._objects,s=[];for(var r=arguments.length,o=new Array(r),a=0;a<r;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,r,o)=>i(s,r,o))}getObjects(){for(var i=arguments.length,s=new Array(i),r=0;r<i;r++)s[r]=arguments[r];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(r=>r instanceof t&&r.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])&&(fs(this._objects,i),this._objects.unshift(i),this._onStackOrderChanged(i),!0)}bringObjectToFront(i){return!(!i||i===this._objects[this._objects.length-1])&&(fs(this._objects,i),this._objects.push(i),this._onStackOrderChanged(i),!0)}sendObjectBackwards(i,s){if(!i)return!1;const r=this._objects.indexOf(i);if(r!==0){const o=this.findNewLowerIndex(i,r,s);return fs(this._objects,i),this._objects.splice(o,0,i),this._onStackOrderChanged(i),!0}return!1}bringObjectForward(i,s){if(!i)return!1;const r=this._objects.indexOf(i);if(r!==this._objects.length-1){const o=this.findNewUpperIndex(i,r,s);return fs(this._objects,i),this._objects.splice(o,0,i),this._onStackOrderChanged(i),!0}return!1}moveObjectTo(i,s){return i!==this._objects[s]&&(fs(this._objects,i),this._objects.splice(s,0,i),this._onStackOrderChanged(i),!0)}findNewLowerIndex(i,s,r){let o;if(r){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,r){let o;if(r){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:r,width:o,height:a}=i,{includeIntersecting:l=!0}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};const c=[],h=new w(s,r),u=h.add(new w(o,a));for(let d=this._objects.length-1;d>=0;d--){const p=this._objects[d];p.selectable&&p.visible&&(l&&p.intersectsWithRect(h,u)||p.isContainedWithinRect(h,u)||l&&p.containsPoint(h)||l&&p.containsPoint(u))&&c.push(p)}return c}}return t}class iu extends Em{_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 Tn(n){return Xa().requestAnimationFrame(n)}function Om(n){return Xa().cancelAnimationFrame(n)}let km=0;const Ii=()=>km++,Fe=()=>{const n=js().createElement("canvas");if(!n||n.getContext===void 0)throw new ze("Failed to create `canvas` element");return n},Am=()=>js().createElement("img"),Ye=n=>{const t=Fe();return t.width=n.width,t.height=n.height,t},su=(n,t,e)=>n.toDataURL("image/".concat(t),e),kt=n=>n*Ka,ss=n=>n/Ka,Pm=n=>n.every((t,e)=>t===ie[e]),ne=(n,t,e)=>new w(n).transform(t,e),Ie=n=>{const t=1/(n[0]*n[3]-n[1]*n[2]),e=[t*n[3],-t*n[1],-t*n[2],t*n[0],0,0],{x:i,y:s}=new w(n[4],n[5]).transform(e,!0);return e[4]=-i,e[5]=-s,e},Vt=(n,t,e)=>[n[0]*t[0]+n[2]*t[1],n[1]*t[0]+n[3]*t[1],n[0]*t[2]+n[2]*t[3],n[1]*t[2]+n[3]*t[3],e?0:n[0]*t[4]+n[2]*t[5]+n[4],e?0:n[1]*t[4]+n[3]*t[5]+n[5]],tl=(n,t)=>n.reduceRight((e,i)=>i&&e?Vt(i,e,t):i||e,void 0)||ie.concat(),ru=n=>{let[t,e]=n;return Math.atan2(e,t)},Nn=n=>{const t=ru(n),e=Math.pow(n[0],2)+Math.pow(n[1],2),i=Math.sqrt(e),s=(n[0]*n[3]-n[2]*n[1])/i,r=Math.atan2(n[0]*n[2]+n[1]*n[3],e);return{angle:ss(t),scaleX:i,scaleY:s,skewX:ss(r),skewY:0,translateX:n[4]||0,translateY:n[5]||0}},Rr=function(n){return[1,0,0,1,n,arguments.length>1&&arguments[1]!==void 0?arguments[1]:0]};function $r(){let{angle:n=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=kt(n),s=pi(i),r=gi(i);return[s,r,-r,s,t?t-(s*t-r*e):0,e?e-(r*t+s*e):0]}const el=function(n){return[n,0,0,arguments.length>1&&arguments[1]!==void 0?arguments[1]:n,0,0]},nu=n=>Math.tan(kt(n)),ou=n=>[1,0,nu(n),1,0,0],au=n=>[1,nu(n),0,1,0,0],mo=n=>{let{scaleX:t=1,scaleY:e=1,flipX:i=!1,flipY:s=!1,skewX:r=0,skewY:o=0}=n,a=el(i?-t:t,s?-e:e);return r&&(a=Vt(a,ou(r),!0)),o&&(a=Vt(a,au(o),!0)),a},Dm=n=>{const{translateX:t=0,translateY:e=0,angle:i=0}=n;let s=Rr(t,e);i&&(s=Vt(s,$r({angle:i})));const r=mo(n);return Pm(r)||(s=Vt(s,r)),s},En=function(n){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 ym("loadImage"));const r=Am();let o;t&&(o=function(l){r.src="",s(l)},t.addEventListener("abort",o,{once:!0}));const a=function(){r.onload=r.onerror=null,o&&(t==null||t.removeEventListener("abort",o)),i(r)};n?(r.onload=a,r.onerror=function(){o&&(t==null||t.removeEventListener("abort",o)),s(new ze("Error loading ".concat(r.src)))},e&&(r.crossOrigin=e),r.src=n):a()})},xr=function(n){let{signal:t,reviver:e=Cn}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return new Promise((i,s)=>{const r=[];t&&t.addEventListener("abort",s,{once:!0}),Promise.all(n.map(o=>R.getClass(o.type).fromObject(o,{signal:t}).then(a=>(e(o,a),r.push(a),a)))).then(i).catch(o=>{r.forEach(a=>{a.dispose&&a.dispose()}),s(o)}).finally(()=>{t&&t.removeEventListener("abort",s)})})},vo=function(n){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 r=Object.values(n).map(a=>a&&a.type&&R.has(a.type)?xr([a],{signal:t}).then(l=>{let[c]=l;return s.push(c),c}):a),o=Object.keys(n);Promise.all(r).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)})})},Bs=function(n){return(arguments.length>1&&arguments[1]!==void 0?arguments[1]:[]).reduce((t,e)=>(e in n&&(t[e]=n[e]),t),{})},il=(n,t)=>Object.keys(n).reduce((e,i)=>(t(n[i],i,n)&&(e[i]=n[i]),e),{}),dc={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"},$o=(n,t,e)=>(e<0&&(e+=1),e>1&&(e-=1),e<1/6?n+6*(t-n)*e:e<.5?t:e<2/3?n+(t-n)*(2/3-e)*6:n),pc=(n,t,e,i)=>{n/=255,t/=255,e/=255;const s=Math.max(n,t,e),r=Math.min(n,t,e);let o,a;const l=(s+r)/2;if(s===r)o=a=0;else{const c=s-r;switch(a=l>.5?c/(2-s-r):c/(s+r),s){case n:o=(t-e)/c+(t<e?6:0);break;case t:o=(e-n)/c+2;break;case e:o=(n-t)/c+4}o/=6}return[Math.round(360*o),Math.round(100*a),Math.round(100*l),i]},gc=function(){let n=arguments.length>0&&arguments[0]!==void 0?arguments[0]:"1";return parseFloat(n)/(n.endsWith("%")?100:1)},Gr=n=>Math.min(Math.round(n),255).toString(16).toUpperCase().padStart(2,"0"),fc=n=>{let[t,e,i,s=1]=n;const r=Math.round(.3*t+.59*e+.11*i);return[r,r,r,s]};class st{constructor(t){if(b(this,"isUnrecognised",!1),t)if(t instanceof st)this.setSource([...t._source]);else if(Array.isArray(t)){const[e,i,s,r=1]=t;this.setSource([e,i,s,r])}else this.setSource(this._tryParsingColor(t));else this.setSource([0,0,0,1])}_tryParsingColor(t){return(t=t.toLowerCase())in dc&&(t=dc[t]),t==="transparent"?[255,255,255,0]:st.sourceFromHex(t)||st.sourceFromRgb(t)||st.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]=pc(...this.getSource());return"hsl(".concat(t,",").concat(e,"%,").concat(i,"%)")}toHsla(){const[t,e,i,s]=pc(...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(Gr(t)).concat(Gr(e)).concat(Gr(i)).concat(Gr(Math.round(255*s)))}getAlpha(){return this.getSource()[3]}setAlpha(t){return this._source[3]=t,this}toGrayscale(){return this.setSource(fc(this.getSource())),this}toBlackWhite(t){const[e,,,i]=fc(this.getSource()),s=e<(t||127)?0:255;return this.setSource([s,s,s,i]),this}overlayWith(t){t instanceof st||(t=new st(t));const e=this.getSource(),i=t.getSource(),[s,r,o]=e.map((a,l)=>Math.round(.5*a+.5*i[l]));return this.setSource([s,r,o,e[3]]),this}static fromRgb(t){return st.fromRgba(t)}static fromRgba(t){return new st(st.sourceFromRgb(t))}static sourceFromRgb(t){const e=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,r]=e.slice(1,4).map(o=>{const a=parseFloat(o);return o.endsWith("%")?Math.round(2.55*a):a});return[i,s,r,gc(e[4])]}}static fromHsl(t){return st.fromHsla(t)}static fromHsla(t){return new st(st.sourceFromHsl(t))}static sourceFromHsl(t){const e=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=(st.parseAngletoDegrees(e[1])%360+360)%360/360,s=parseFloat(e[2])/100,r=parseFloat(e[3])/100;let o,a,l;if(s===0)o=a=l=r;else{const c=r<=.5?r*(s+1):r+s-r*s,h=2*r-c;o=$o(h,c,i+1/3),a=$o(h,c,i),l=$o(h,c,i-1/3)}return[Math.round(255*o),Math.round(255*a),Math.round(255*l),gc(e[4])]}static fromHex(t){return new st(st.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,r,o,a=255]=i.map(l=>parseInt(l,16));return[s,r,o,a/255]}}static parseAngletoDegrees(t){const e=t.toLowerCase(),i=parseFloat(e);return e.includes("rad")?ss(i):e.includes("turn")?360*i:i}}const mt=(n,t)=>parseFloat(Number(n).toFixed(t)),Ss=function(n){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:qa;const e=/\D{0,2}$/.exec(n),i=parseFloat(n),s=tt.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}},Mm=n=>{const[t,e]=n.trim().split(" "),[i,s]=(r=t)&&r!==ce?[r.slice(1,4),r.slice(5,8)]:r===ce?[r,r]:["Mid","Mid"];var r;return{meetOrSlice:e||"meet",alignX:i,alignY:s}},zn=n=>"matrix("+n.map(t=>mt(t,tt.NUM_FRACTION_DIGITS)).join(" ")+")",wr=function(n,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 r=new st(t),o=r.getAlpha();e=r.toRgb(),o!==1&&(i=o.toString())}else e="none";return s?"".concat(n,": ").concat(e,"; ").concat(i?"".concat(n,"-opacity: ").concat(i,"; "):""):"".concat(n,'="').concat(e,'" ').concat(i?"".concat(n,'-opacity="').concat(i,'" '):"")},we=n=>!!n&&n.toLive!==void 0,mc=n=>!!n&&typeof n.toObject=="function",vc=n=>!!n&&n.offsetX!==void 0&&"source"in n,Ui=n=>!!n&&"multiSelectionStacking"in n;function lu(n){const t=n&&De(n);let e=0,i=0;if(!n||!t)return{left:e,top:i};let s=n;const r=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||r.scrollLeft||0,i=o.scrollTop||r.scrollTop||0):(e+=s.scrollLeft||0,i+=s.scrollTop||0),s.nodeType!==1||s.style.position!=="fixed"););return{left:e,top:i}}const De=n=>n.ownerDocument||null,cu=n=>{var t;return((t=n.ownerDocument)===null||t===void 0?void 0:t.defaultView)||null},hu=function(n,t,e){let{width:i,height:s}=e,r=arguments.length>3&&arguments[3]!==void 0?arguments[3]:1;n.width=i,n.height=s,r>1&&(n.setAttribute("width",(i*r).toString()),n.setAttribute("height",(s*r).toString()),t.scale(r,r))},pa=(n,t)=>{let{width:e,height:i}=t;e&&(n.style.width=typeof e=="number"?"".concat(e,"px"):e),i&&(n.style.height=typeof i=="number"?"".concat(i,"px"):i)};function bc(n){return n.onselectstart!==void 0&&(n.onselectstart=()=>!1),n.style.userSelect=ce,n}class uu{constructor(t){b(this,"_originalCanvasStyle",void 0),b(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&&js().getElementById(t)||Fe();var i;if(e.hasAttribute("data-fabric"))throw new ze("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;hu(i,s,t,e)}setCSSDimensions(t){pa(this.lower.el,t)}calcOffset(){return function(t){var e;const i=t&&De(t),s={left:0,top:0};if(!i)return s;const r=((e=cu(t))===null||e===void 0?void 0:e.getComputedStyle(t,null))||{};s.left+=parseInt(r.borderLeftWidth,10)||0,s.top+=parseInt(r.borderTopWidth,10)||0,s.left+=parseInt(r.paddingLeft,10)||0,s.top+=parseInt(r.paddingTop,10)||0;let o={left:0,top:0};const a=i.documentElement;t.getBoundingClientRect!==void 0&&(o=t.getBoundingClientRect());const l=lu(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(){Ge().dispose(this.lower.el),delete this.lower}}const Im={backgroundVpt:!0,backgroundColor:"",overlayVpt:!0,overlayColor:"",includeDefaultValues:!0,svgViewportTransformation:!0,renderOnAddRemove:!0,skipOffscreen:!0,enableRetinaScaling:!0,imageSmoothingEnabled:!0,controlsAboveOverlay:!1,allowTouchScrolling:!1,viewportTransform:[...ie]};class Br extends eu(iu){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 Br.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 uu(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 r=super.insertAt(t,...i);return i.length>0&&this.renderOnAddRemove&&this.requestRenderAll(),r}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.
|
|
2495
|
+
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?Zh():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=_({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],r=ne(t,Ie(s));s[0]=e,s[3]=e;const o=ne(r,s);s[4]+=i.x-o.x,s[5]+=i.y-o.y,this.setViewportTransform(s)}setZoom(t){this.zoomToPoint(new w(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 w(-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=Tn(()=>this.renderAndReset()))}calcViewportBoundaries(){const t=this.width,e=this.height,i=Ie(this.viewportTransform),s=ne({x:0,y:0},i),r=ne({x:t,y:e},i),o=s.min(r),a=s.max(r);return this.vptCoords={tl:o,tr:new w(a.x,o.y),bl:new w(o.x,a.y),br:a}}cancelRequestedRender(){this.nextRenderHandle&&(Om(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")],r=this.viewportTransform,o=this["".concat(e,"Vpt")];if(!i&&!s)return;const a=we(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(...r),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(...r),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 w(this.width/2,this.height/2)}centerObjectH(t){return this._centerObject(t,new w(this.getCenterPoint().x,t.getCenterPoint().y))}centerObjectV(t){return this._centerObject(t,new w(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 w(this.getVpCenter().x,t.getCenterPoint().y))}viewportCenterObjectV(t){return this._centerObject(t,new w(t.getCenterPoint().x,this.getVpCenter().y))}getVpCenter(){return ne(this.getCenterPoint(),Ie(this.viewportTransform))}_centerObject(t,e){t.setXY(e,K,K),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 _(_(_({version:ua},Bs(this,e)),{},{objects:this._objects.filter(r=>!r.excludeFromExport).map(r=>this._toObject(r,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 r=t[e](i);return this.includeDefaultValues||(t.includeDefaultValues=!!s),r}__serializeBgOverlay(t,e){const i={},s=this.backgroundImage,r=this.overlayImage,o=this.backgroundColor,a=this.overlayColor;return we(o)?o.excludeFromExport||(i.background=o.toObject(e)):o&&(i.background=o),we(a)?a.excludeFromExport||(i.overlay=a.toObject(e)):a&&(i.overlay=a),s&&!s.excludeFromExport&&(i.backgroundImage=this._toObject(s,t,e)),r&&!r.excludeFromExport&&(i.overlayImage=this._toObject(r,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,`)" >
|
|
2481
2496
|
`)),this._setSVGBgOverlayColor(i,"background"),this._setSVGBgOverlayImage(i,"backgroundImage",e),this._setSVGObjects(i,e),this.clipPath&&i.push(`</g>
|
|
2482
2497
|
`),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" ?>
|
|
2483
2498
|
`,'<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" ',`"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
|
2484
|
-
`)}_setSVGHeader(t,e){const i=e.width||"".concat(this.width),
|
|
2499
|
+
`)}_setSVGHeader(t,e){const i=e.width||"".concat(this.width),s=e.height||"".concat(this.height),r=tt.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(mt(-l[4]/l[0],r)," ").concat(mt(-l[5]/l[3],r)," ").concat(mt(this.width/l[0],r)," ").concat(mt(this.height/l[3],r),'" ')}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">
|
|
2485
2500
|
`,"<desc>Created with Fabric.js ",ua,`</desc>
|
|
2486
2501
|
`,`<defs>
|
|
2487
2502
|
`,this.createSVGFontFacesMarkup(),this.createSVGRefElementsMarkup(),this.createSVGClipPathMarkup(e),`</defs>
|
|
2488
2503
|
`)}createSVGClipPathMarkup(t){const e=this.clipPath;return e?(e.clipPathId="CLIPPATH_".concat(Ii()),'<clipPath id="'.concat(e.clipPathId,`" >
|
|
2489
2504
|
`).concat(e.toClipPathSVG(t.reviver),`</clipPath>
|
|
2490
|
-
`)):""}createSVGRefElementsMarkup(){return["background","overlay"].map(t=>{const e=this["".concat(t,"Color")];if(we(e)){const i=this["".concat(t,"Vpt")],
|
|
2491
|
-
font-family: '`.concat(
|
|
2492
|
-
src: url('`).concat(i[
|
|
2505
|
+
`)):""}createSVGRefElementsMarkup(){return["background","overlay"].map(t=>{const e=this["".concat(t,"Color")];if(we(e)){const i=this["".concat(t,"Vpt")],s=this.viewportTransform,r={isType:()=>!1,width:this.width/(i?s[0]:1),height:this.height/(i?s[3]:1)};return e.toSVG(r,{additionalTransform:i?zn(s):""})}}).join("")}createSVGFontFacesMarkup(){const t=[],e={},i=tt.fontPaths;this._objects.forEach(function r(o){t.push(o),Sn(o)&&o._objects.forEach(r)}),t.forEach(r=>{if(!(o=r)||typeof o._renderText!="function")return;var o;const{styles:a,fontFamily:l}=r;!e[l]&&i[l]&&(e[l]=!0,a&&Object.values(a).forEach(c=>{Object.values(c).forEach(h=>{let{fontFamily:u=""}=h;!e[u]&&i[u]&&(e[u]=!0)})}))});const s=Object.keys(e).map(r=>` @font-face {
|
|
2506
|
+
font-family: '`.concat(r,`';
|
|
2507
|
+
src: url('`).concat(i[r],`');
|
|
2493
2508
|
}
|
|
2494
|
-
`)).join("");return
|
|
2495
|
-
`.concat(
|
|
2496
|
-
`):""}_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
|
|
2509
|
+
`)).join("");return s?` <style type="text/css"><![CDATA[
|
|
2510
|
+
`.concat(s,`]]></style>
|
|
2511
|
+
`):""}_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(we(i)){const s=i.repeat||"",r=this.width,o=this.height,a=this["".concat(e,"Vpt")]?zn(Ie(this.viewportTransform)):"";t.push('<rect transform="'.concat(a," translate(").concat(r/2,",").concat(o/2,')" x="').concat(i.offsetX-r/2,'" y="').concat(i.offsetY-o/2,'" width="').concat(s!=="repeat-y"&&s!=="no-repeat"||!vc(i)?r:i.source.width,'" height="').concat(s!=="repeat-x"&&s!=="no-repeat"||!vc(i)?o:i.source.height,'" fill="url(#SVGID_').concat(i.id,`)"></rect>
|
|
2497
2512
|
`))}else t.push('<rect x="0" y="0" width="100%" height="100%" ','fill="',i,'"',`></rect>
|
|
2498
|
-
`)}loadFromJSON(t,e){let{signal:i}=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};if(!t)return Promise.reject(new ze("`json` is undefined"));const
|
|
2513
|
+
`)}loadFromJSON(t,e){let{signal:i}=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};if(!t)return Promise.reject(new ze("`json` is undefined"));const s=typeof t=="string"?JSON.parse(t):t,{objects:r=[],backgroundImage:o,background:a,overlayImage:l,overlay:c,clipPath:h}=s,u=this.renderOnAddRemove;return this.renderOnAddRemove=!1,Promise.all([xr(r,{reviver:e,signal:i}),vo({backgroundImage:o,backgroundColor:a,overlayImage:l,overlayColor:c,clipPath:h},{signal:i})]).then(d=>{let[p,g]=d;return this.clear(),this.add(...p),this.set(s),this.set(g),this.renderOnAddRemove=u,this})}clone(t){const e=this.toObject(t);return this.cloneWithoutData().loadFromJSON(e)}cloneWithoutData(){const t=Ye(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:r=!1}=t,o=s*(r?this.getRetinaScaling():1);return su(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:r,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,u=this.height,d=this.skipControlsDrawing,p=c*t,g=this.viewportTransform,f=[p,0,0,p,(g[4]-(s||0))*t,(g[5]-(r||0))*t],m=this.enableRetinaScaling,v=Ye({width:a,height:l}),y=o?this._objects.filter(x=>o(x)):this._objects;return this.enableRetinaScaling=!1,this.viewportTransform=f,this.width=a,this.height=l,this.skipControlsDrawing=!0,this.calcViewportBoundaries(),this.renderCanvas(v.getContext("2d"),y),this.viewportTransform=g,this.width=h,this.height=u,this.calcViewportBoundaries(),this.enableRetinaScaling=m,this.skipControlsDrawing=d,v}dispose(){return!this.disposed&&this.elements.cleanupDOM({width:this.width,height:this.height}),Bn.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," }>")}}b(Br,"ownDefaults",Im);const Lm=["touchstart","touchmove","touchend"],Fm=n=>{const t=lu(n.target),e=function(i){const s=i.changedTouches;return s&&s[0]?s[0]:i}(n);return new w(e.clientX+t.left,e.clientY+t.top)},ga=n=>Lm.includes(n.type)||n.pointerType==="touch",fa=n=>{n.preventDefault(),n.stopPropagation()},ci=n=>{let t=0,e=0,i=0,s=0;for(let r=0,o=n.length;r<o;r++){const{x:a,y:l}=n[r];(a>i||!r)&&(i=a),(a<t||!r)&&(t=a),(l>s||!r)&&(s=l),(l<e||!r)&&(e=l)}return{left:t,top:e,width:i-t,height:s-e}},jm=["translateX","translateY","scaleX","scaleY"],Rm=(n,t)=>Hn(n,Vt(t,n.calcOwnMatrix())),Hn=(n,t)=>{const e=Nn(t),{translateX:i,translateY:s,scaleX:r,scaleY:o}=e,a=gt(e,jm),l=new w(i,s);n.flipX=!1,n.flipY=!1,Object.assign(n,a),n.set({scaleX:r,scaleY:o}),n.setPositionByOrigin(l,K,K)},$m=n=>{n.scaleX=1,n.scaleY=1,n.skewX=0,n.skewY=0,n.flipX=!1,n.flipY=!1,n.rotate(0)},du=n=>({scaleX:n.scaleX,scaleY:n.scaleY,skewX:n.skewX,skewY:n.skewY,angle:n.angle,left:n.left,flipX:n.flipX,flipY:n.flipY,top:n.top}),sl=(n,t,e)=>{const i=n/2,s=t/2,r=[new w(-i,-s),new w(i,-s),new w(-i,s),new w(i,s)].map(a=>a.transform(e)),o=ci(r);return new w(o.width,o.height)},bo=function(){let n=arguments.length>0&&arguments[0]!==void 0?arguments[0]:ie;return Vt(Ie(arguments.length>1&&arguments[1]!==void 0?arguments[1]:ie),n)},Ts=function(n){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:ie,e=arguments.length>2&&arguments[2]!==void 0?arguments[2]:ie;return n.transform(bo(t,e))},Bm=function(n){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:ie,e=arguments.length>2&&arguments[2]!==void 0?arguments[2]:ie;return n.transform(bo(t,e),!0)},Nm=(n,t,e)=>{const i=bo(t,e);return Hn(n,Vt(i,n.calcOwnMatrix())),i},pu=(n,t)=>{var e;const{transform:{target:i}}=t;(e=i.canvas)===null||e===void 0||e.fire("object:".concat(n),_(_({},t),{},{target:i})),i.fire(n,t)},zm={left:-.5,top:-.5,center:0,bottom:.5,right:.5},Dt=n=>typeof n=="string"?zm[n]:n-.5,Vn="not-allowed";function gu(n){return Dt(n.originX)===Dt(K)&&Dt(n.originY)===Dt(K)}function _c(n){return .5-Dt(n)}const Le=(n,t)=>n[t],fu=(n,t,e,i)=>({e:n,transform:t,pointer:new w(e,i)});function mu(n,t){const e=n.getTotalAngle()+ss(Math.atan2(t.y,t.x))+360;return Math.round(e%360/45)}function rl(n,t,e,i,s){var r;let{target:o,corner:a}=n;const l=o.controls[a],c=((r=o.canvas)===null||r===void 0?void 0:r.getZoom())||1,h=o.padding/c,u=function(d,p,g,f){const m=d.getRelativeCenterPoint(),v=g!==void 0&&f!==void 0?d.translateToGivenOrigin(m,K,K,g,f):new w(d.left,d.top);return(d.angle?p.rotate(-kt(d.angle),m):p).subtract(v)}(o,new w(i,s),t,e);return u.x>=h&&(u.x-=h),u.x<=-h&&(u.x+=h),u.y>=h&&(u.y-=h),u.y<=h&&(u.y+=h),u.x-=l.offsetX,u.y-=l.offsetY,u}const Hm=(n,t,e,i)=>{const{target:s,offsetX:r,offsetY:o}=t,a=e-r,l=i-o,c=!Le(s,"lockMovementX")&&s.left!==a,h=!Le(s,"lockMovementY")&&s.top!==l;return c&&s.set(it,a),h&&s.set(le,l),(c||h)&&pu(Jh,fu(n,t,e,i)),c||h};class vu{getSvgStyles(t){const e=this.fillRule?this.fillRule:"nonzero",i=this.strokeWidth?this.strokeWidth:"0",s=this.strokeDashArray?this.strokeDashArray.join(" "):ce,r=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;",u=t?"":this.getSvgFilter(),d=wr(Rt,this.fill);return[wr(he,this.stroke),"stroke-width: ",i,"; ","stroke-dasharray: ",s,"; ","stroke-linecap: ",o,"; ","stroke-dashoffset: ",r,"; ","stroke-linejoin: ",a,"; ","stroke-miterlimit: ",l,"; ",d,"fill-rule: ",e,"; ","opacity: ",c,";",u,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(zn(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(""),r=t.indexOf("COMMON_PARTS");return t[r]=s,e?e(t.join("")):t.join("")}_createBaseSVGMarkup(t){let{noStyle:e,reviver:i,withShadow:s,additionalTransform:r}=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,u=this.stroke,d=this.fill,p=this.shadow,g=[],f=t.indexOf("COMMON_PARTS");let m;l&&(l.clipPathId="CLIPPATH_".concat(Ii()),m='<clipPath id="'.concat(l.clipPathId,`" >
|
|
2499
2514
|
`).concat(l.toClipPathSVG(i),`</clipPath>
|
|
2500
2515
|
`)),h&&g.push("<g ",a,this.getSvgCommons(),` >
|
|
2501
2516
|
`),g.push("<g ",this.getSvgTransform(!1),h?"":a+this.getSvgCommons(),` >
|
|
2502
|
-
`);const v=[o,c,e?"":this.addPaintOrder()," ",
|
|
2517
|
+
`);const v=[o,c,e?"":this.addPaintOrder()," ",r?'transform="'.concat(r,'" '):""].join("");return t[f]=v,we(d)&&g.push(d.toSVG(this)),we(u)&&g.push(u.toSVG(this)),p&&g.push(p.toSVG(this)),l&&g.push(m),g.push(t.join("")),g.push(`</g>
|
|
2503
2518
|
`),h&&g.push(`</g>
|
|
2504
|
-
`),i?i(g.join("")):g.join("")}addPaintOrder(){return this.paintFirst
|
|
2519
|
+
`),i?i(g.join("")):g.join("")}addPaintOrder(){return this.paintFirst!==Rt?' paint-order="'.concat(this.paintFirst,'" '):""}}function _o(n){return new RegExp("^("+n.join("|")+")\\b","i")}var yc;const rs=String.raw(yc||(yc=$i(["(?:[-+]?(?:d*.d+|d+.?)(?:[eE][-+]?d+)?)"],["(?:[-+]?(?:\\d*\\.\\d+|\\d+\\.?)(?:[eE][-+]?\\d+)?)"]))),Vm=new RegExp("(normal|italic)?\\s*(normal|small-caps)?\\s*(normal|bold|bolder|lighter|100|200|300|400|500|600|700|800|900)?\\s*("+rs+"(?:px|cm|mm|em|pt|pc|in)*)(?:\\/(normal|"+rs+"))?\\s+(.*)"),Um={cx:it,x:it,r:"radius",cy:le,y:le,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"},Bo="font-size",No="clip-path";_o(["path","circle","polygon","polyline","ellipse","rect","line","image","text"]);_o(["symbol","image","marker","pattern","view","svg"]);const xc=_o(["symbol","g","a","svg","clipPath","defs"]),Wm=new w(1,0),bu=new w,_u=(n,t)=>n.rotate(t),ma=(n,t)=>new w(t).subtract(n),va=n=>n.distanceFrom(bu),ba=(n,t)=>Math.atan2(ar(n,t),Ym(n,t)),Gm=n=>ba(Wm,n),nl=n=>n.eq(bu)?n:n.scalarDivide(va(n)),yu=function(n){let t=!(arguments.length>1&&arguments[1]!==void 0)||arguments[1];return nl(new w(-n.y,n.x).scalarMultiply(t?1:-1))},ar=(n,t)=>n.x*t.y-n.y*t.x,Ym=(n,t)=>n.x*t.x+n.y*t.y,wc=(n,t,e)=>{if(n.eq(t)||n.eq(e))return!0;const i=ar(t,e),s=ar(t,n),r=ar(e,n);return i>=0?s>=0&&r<=0:!(s<=0&&r>=0)},Cc="(-?\\d+(?:\\.\\d*)?(?:px)?(?:\\s?|$))?",Sc=new RegExp("(?:\\s|^)"+Cc+Cc+"("+rs+"?(?:px)?)?(?:\\s?|$)(?:$|\\s)");class hi{constructor(t){const e=typeof t=="string"?hi.parseShadow(t):t;Object.assign(this,hi.ownDefaults,e),this.id=Ii()}static parseShadow(t){const e=t.trim(),[,i=0,s=0,r=0]=(Sc.exec(e)||[]).map(o=>parseFloat(o)||0);return{color:(e.replace(Sc,"")||"rgb(0,0,0)").trim(),offsetX:i,offsetY:s,blur:r}}toString(){return[this.offsetX,this.offsetY,this.blur,this.color].join("px ")}toSVG(t){const e=_u(new w(this.offsetX,this.offsetY),kt(-t.angle)),i=new st(this.color);let s=40,r=40;return t.width&&t.height&&(s=100*mt((Math.abs(e.x)+this.blur)/t.width,tt.NUM_FRACTION_DIGITS)+20,r=100*mt((Math.abs(e.y)+this.blur)/t.height,tt.NUM_FRACTION_DIGITS)+20),t.flipX&&(e.x*=-1),t.flipY&&(e.y*=-1),'<filter id="SVGID_'.concat(this.id,'" y="-').concat(r,'%" height="').concat(100+2*r,'%" x="-').concat(s,'%" width="').concat(100+2*s,`%" >
|
|
2505
2520
|
<feGaussianBlur in="SourceAlpha" stdDeviation="`).concat(mt(this.blur?this.blur/2:0,tt.NUM_FRACTION_DIGITS),`"></feGaussianBlur>
|
|
2506
2521
|
<feOffset dx="`).concat(mt(e.x,tt.NUM_FRACTION_DIGITS),'" dy="').concat(mt(e.y,tt.NUM_FRACTION_DIGITS),`" result="oBlur" ></feOffset>
|
|
2507
2522
|
<feFlood flood-color="`).concat(i.toRgb(),'" flood-opacity="').concat(i.getAlpha(),`"/>
|
|
@@ -2511,44 +2526,44 @@ Resulting to default behavior: removing object from previous canvas and adding t
|
|
|
2511
2526
|
<feMergeNode in="SourceGraphic"></feMergeNode>
|
|
2512
2527
|
</feMerge>
|
|
2513
2528
|
</filter>
|
|
2514
|
-
`)}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=ci.ownDefaults;return this.includeDefaultValues?t:il(t,(i,r)=>i!==e[r])}static async fromObject(t){return new this(t)}}b(ci,"ownDefaults",{color:"rgb(0,0,0)",blur:0,offsetX:0,offsetY:0,affectStroke:!1,includeDefaultValues:!0,nonScaling:!1}),b(ci,"type","shadow"),R.setClass(ci,"shadow");const Dr=(n,t,e)=>Math.max(n,Math.min(t,e)),Xm=[le,it,pe,Ee,"flipX","flipY","originX","originY","angle","opacity","globalCompositeOperation","shadow","visible",Rr,$r],fi=[$t,he,"strokeWidth","strokeDashArray","width","height","paintFirst","strokeUniform","strokeLineCap","strokeDashOffset","strokeLineJoin","strokeMiterLimit","backgroundColor","clipPath"],Km={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:it,originY:le,strokeWidth:1,strokeUniform:!1,padding:0,opacity:1,paintFirst:$t,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},qm=(n,t,e,i)=>-e*Math.cos(n/i*Rs)+e+t,Zm=()=>!1;class ol{constructor(t){let{startValue:e,byValue:i,duration:r=500,delay:s=0,easing:o=qm,onStart:a=Sn,onChange:l=Sn,onComplete:c=Sn,abort:h=Zm,target:u}=t;b(this,"_state","pending"),b(this,"durationProgress",0),b(this,"valueProgress",0),this.tick=this.tick.bind(this),this.duration=r,this.delay=s,this.easing=o,this._onStart=a,this._onChange=l,this._onComplete=c,this._abort=h,this.target=u,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(()=>En(t),this.delay):En(t)}tick(t){const e=(t||+new Date)-this.startTime,i=Math.min(e,this.duration);this.durationProgress=i/this.duration;const{value:r,valueProgress:s}=this.calculate(i);this.value=Object.freeze(r),this.valueProgress=s,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),En(this.tick)))}register(){Nn.push(this)}unregister(){Nn.remove(this)}abort(){this._state="aborted",this.unregister()}}const Jm=["startValue","endValue"];class Qm extends ol{constructor(t){let{startValue:e=0,endValue:i=100}=t;super(_(_({},gt(t,Jm)),{},{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 tv=["startValue","endValue"];class ev extends ol{constructor(t){let{startValue:e=[0],endValue:i=[100]}=t;super(_(_({},gt(t,tv)),{},{startValue:e,byValue:i.map((r,s)=>r-e[s])}))}calculate(t){const e=this.startValue.map((i,r)=>this.easing(t,i,this.byValue[r],this.duration,r));return{value:e,valueProgress:Math.abs((e[0]-this.startValue[0])/this.byValue[0])}}}const iv=["startValue","endValue","easing","onChange","onComplete","abort"],rv=(n,t,e,i)=>t+e*(1-Math.cos(n/i*Rs)),zo=n=>n&&((t,e,i)=>n(new rt(t).toRgba(),e,i));class sv extends ol{constructor(t){let{startValue:e,endValue:i,easing:r=rv,onChange:s,onComplete:o,abort:a}=t,l=gt(t,iv);const c=new rt(e).getSource(),h=new rt(i).getSource();super(_(_({},l),{},{startValue:c,byValue:h.map((u,d)=>u-c[d]),easing:r,onChange:zo(s),onComplete:zo(o),abort:zo(a)}))}calculate(t){const[e,i,r,s]=this.startValue.map((a,l)=>this.easing(t,a,this.byValue[l],this.duration,l)),o=[...[e,i,r].map(Math.round),Dr(0,s,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 xu(n){const t=(e=>Array.isArray(e.startValue)||Array.isArray(e.endValue))(n)?new ev(n):new Qm(n);return t.start(),t}function nv(n){const t=new sv(n);return t.start(),t}class ft{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(r=>!this.includes(r))),this}static isPointContained(t,e,i){let r=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&&(r||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&&(r||t.x>=Math.min(e.x,i.x)&&t.x<=Math.max(e.x,i.x));{const s=ma(e,i),o=ma(e,t).divide(s);return r?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 w(t).setX(Math.min(t.x-1,...e.map(s=>s.x)));let r=0;for(let s=0;s<e.length;s++){const o=this.intersectSegmentSegment(e[s],e[(s+1)%e.length],t,i);if(o.includes(t))return!0;r+=+(o.status==="Intersection")}return r%2==1}static intersectLineLine(t,e,i,r){let s=!(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=r.x-i.x,h=r.y-i.y,u=t.x-i.x,d=t.y-i.y,p=c*d-h*u,g=a*d-l*u,f=h*a-c*l;if(f!==0){const m=p/f,v=g/f;return(s||0<=m&&m<=1)&&(o||0<=v&&v<=1)?new ft("Intersection").append(new w(t.x+m*a,t.y+m*l)):new ft}if(p===0||g===0){const m=s||o||ft.isPointContained(t,i,r)||ft.isPointContained(e,i,r)||ft.isPointContained(i,t,e)||ft.isPointContained(r,t,e);return new ft(m?"Coincident":void 0)}return new ft("Parallel")}static intersectSegmentLine(t,e,i,r){return ft.intersectLineLine(t,e,i,r,!1,!0)}static intersectSegmentSegment(t,e,i,r){return ft.intersectLineLine(t,e,i,r,!1,!1)}static intersectLinePolygon(t,e,i){let r=!(arguments.length>3&&arguments[3]!==void 0)||arguments[3];const s=new ft,o=i.length;for(let a,l,c,h=0;h<o;h++){if(a=i[h],l=i[(h+1)%o],c=ft.intersectLineLine(t,e,a,l,r,!1),c.status==="Coincident")return c;s.append(...c.points)}return s.points.length>0&&(s.status="Intersection"),s}static intersectSegmentPolygon(t,e,i){return ft.intersectLinePolygon(t,e,i,!1)}static intersectPolygonPolygon(t,e){const i=new ft,r=t.length,s=[];for(let o=0;o<r;o++){const a=t[o],l=t[(o+1)%r],c=ft.intersectSegmentPolygon(a,l,e);c.status==="Coincident"?(s.push(c),i.append(a,l)):i.append(...c.points)}return s.length>0&&s.length===t.length?new ft("Coincident"):(i.points.length>0&&(i.status="Intersection"),i)}static intersectPolygonRectangle(t,e,i){const r=e.min(i),s=e.max(i),o=new w(s.x,r.y),a=new w(r.x,s.y);return ft.intersectPolygonPolygon(t,[r,o,s,a])}}class ov extends iu{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?oe(t,this.group.calcTransformMatrix()):t}setXY(t,e,i){this.group&&(t=oe(t,Ie(this.group.calcTransformMatrix()))),this.setRelativeXY(t,e,i)}getRelativeXY(){return new w(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:r}=this.aCoords||(this.aCoords=this.calcACoords()),s=[t,e,i,r];if(this.group){const o=this.group.calcTransformMatrix();return s.map(a=>oe(a,o))}return s}intersectsWithRect(t,e){return ft.intersectPolygonRectangle(this.getCoords(),t,e).status==="Intersection"}intersectsWithObject(t){const e=ft.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:r,width:s,height:o}=this.getBoundingRect();return i>=t.x&&i+s<=e.x&&r>=t.y&&r+o<=e.y}isOverlapping(t){return this.intersectsWithObject(t)||this.isContainedWithinObject(t)||t.isContainedWithinObject(this)}containsPoint(t){return ft.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 li(this.getCoords())}getScaledWidth(){return this._getTransformedDimensions().x}getScaledHeight(){return this._getTransformedDimensions().y}scale(t){this._set(pe,t),this._set(Ee,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?rr(su(this.calcTransformMatrix())):this.angle}getViewportTransform(){var t;return((t=this.canvas)===null||t===void 0?void 0:t.viewportTransform)||ie.concat()}calcACoords(){const t=Bs({angle:this.angle}),{x:e,y:i}=this.getRelativeCenterPoint(),r=$s(e,i),s=Vt(r,t),o=this._getTransformedDimensions(),a=o.x/2,l=o.y/2;return{tl:oe({x:-a,y:-l},s),tr:oe({x:a,y:-l},s),bl:oe({x:-a,y:l},s),br:oe({x:a,y:l},s)}}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,Dt(this.originX),Dt(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),r=this.matrixCache;return r&&r.key.every((s,o)=>s===i[o])?r.value:(this.group&&(e=Vt(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(),r={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},s=Dm(r);return this.ownMatrixCache={key:t,value:s},s}_getNonTransformedDimensions(){return new w(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=_({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 r=i,s=0;this.strokeUniform&&(r=0,s=i);const o=e.width+r,a=e.height+r;let l;return l=e.skewX===0&&e.skewY===0?new w(o*e.scaleX,a*e.scaleY):rl(o,a,vo(e)),l.scalarAdd(s)}translateToGivenOrigin(t,e,i,r,s){let o=t.x,a=t.y;const l=Dt(r)-Dt(e),c=Dt(s)-Dt(i);if(l||c){const h=this._getTransformedDimensions();o+=l*h.x,a+=c*h.y}return new w(o,a)}translateToCenterPoint(t,e,i){if(e===K&&i===K)return t;const r=this.translateToGivenOrigin(t,e,i,K,K);return this.angle?r.rotate(Ot(this.angle),t):r}translateToOriginPoint(t,e,i){const r=this.translateToGivenOrigin(t,K,K,e,i);return this.angle?r.rotate(Ot(this.angle),t):r}getCenterPoint(){const t=this.getRelativeCenterPoint();return this.group?oe(t,this.group.calcTransformMatrix()):t}getRelativeCenterPoint(){return this.translateToCenterPoint(new w(this.left,this.top),this.originX,this.originY)}getPointByOrigin(t,e){return this.translateToOriginPoint(this.getRelativeCenterPoint(),t,e)}setPositionByOrigin(t,e,i){const r=this.translateToCenterPoint(t,e,i),s=this.translateToOriginPoint(r,this.originX,this.originY);this.set({left:s.x,top:s.y})}_getLeftTopCoords(){return this.translateToOriginPoint(this.getRelativeCenterPoint(),it,le)}}const av=["type"],lv=["extraParam"];let Qe=class kn extends ov{static getDefaults(){return kn.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(),b(this,"_cacheContext",null),Object.assign(this,kn.ownDefaults),this.setOptions(t)}_createCacheCanvas(){this._cacheCanvas=Fe(),this._cacheContext=this._cacheCanvas.getContext("2d"),this._updateCacheCanvas(),this.dirty=!0}_limitCacheSize(t){const e=t.width,i=t.height,r=tt.maxCacheSideLimit,s=tt.minCacheSideLimit;if(e<=r&&i<=r&&e*i<=tt.perfLimitSizeTotal)return e<s&&(t.width=s),i<s&&(t.height=s),t;const o=e/i,[a,l]=as.limitDimsByArea(o),c=Dr(s,a,r),h=Dr(s,l,r);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,r=e.y*t.y/this.scaleY;return{width:Math.ceil(i+2),height:Math.ceil(r+2),zoomX:t.x,zoomY:t.y,x:i,y:r}}_updateCacheCanvas(){const t=this._cacheCanvas,e=this._cacheContext,{width:i,height:r,zoomX:s,zoomY:o,x:a,y:l}=this._limitCacheSize(this._getCacheCanvasDimensions()),c=i!==t.width||r!==t.height,h=this.zoomX!==s||this.zoomY!==o;if(!t||!e)return!1;if(c||h){i!==t.width||r!==t.height?(t.width=i,t.height=r):(e.setTransform(1,0,0,1,0,0),e.clearRect(0,0,t.width,t.height));const u=a/2,d=l/2;return this.cacheTranslationX=Math.round(t.width/2-u)+u,this.cacheTranslationY=Math.round(t.height/2-d)+d,e.translate(this.cacheTranslationX,this.cacheTranslationY),e.scale(s,o),this.zoomX=s,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 w(Math.abs(this.scaleX),Math.abs(this.scaleY));const t=zn(this.calcTransformMatrix());return new w(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!==pe&&t!==Ee||(e=this._constrainScale(e)),t===pe&&e<0?(this.flipX=!this.flipX,e*=-1):t==="scaleY"&&e<0?(this.flipY=!this.flipY,e*=-1):t!=="shadow"||!e||e instanceof ci||(e=new ci(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:r,cacheTranslationY:s}=this,{width:o,height:a}=this._cacheCanvas;this.drawObject(this._cacheContext,t.forClipping,{zoomX:e,zoomY:i,cacheTranslationX:r,cacheTranslationY:s,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===he&&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 r=this.fill,s=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=r,this.stroke=s}createClipPathLayer(t,e){const i=Ye(e),r=i.getContext("2d");if(r.translate(e.cacheTranslationX,e.cacheTranslationY),r.scale(e.zoomX,e.zoomY),t._cacheCanvas=i,e.parentClipPaths.forEach(s=>{s.transform(r)}),e.parentClipPaths.push(t),t.absolutePositioned){const s=Ie(this.calcTransformMatrix());r.transform(s[0],s[1],s[2],s[3],s[4],s[5])}return t.transform(r),t.drawObject(r,!0,e),i}_drawClipPath(t,e,i){if(!e)return;e._transformDone=!0;const r=this.createClipPathLayer(e,i);this.drawClipPathOnCache(t,e,r)}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,we(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&&(we(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,r=this.getCanvasRetinaScaling(),[s,,,o]=(i==null?void 0:i.viewportTransform)||ie,a=s*r,l=o*r,c=e.nonScaling?new w(1,1):this.getObjectScaling();t.shadowColor=e.color,t.shadowBlur=e.blur*tt.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(!we(e))return{offsetX:0,offsetY:0};const i=e.gradientTransform||e.patternTransform,r=-this.width/2+e.offsetX||0,s=-this.height/2+e.offsetY||0;return e.gradientUnits==="percentage"?t.transform(this.width,0,0,this.height,r,s):t.transform(1,0,0,1,r,s),i&&t.transform(i[0],i[1],i[2],i[3],i[4],i[5]),{offsetX:r,offsetY:s}}_renderPaintInOrder(t){this.paintFirst===he?(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 r=this._limitCacheSize(this._getCacheCanvasDimensions()),s=this.getCanvasRetinaScaling(),o=r.x/this.scaleX/s,a=r.y/this.scaleY/s,l=Ye({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(r.zoomX/this.scaleX/s,r.zoomY/this.scaleY/s),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(s*this.scaleX/r.zoomX,s*this.scaleY/r.zoomY),t.strokeStyle=(i=c.createPattern(l,"no-repeat"))!==null&&i!==void 0?i:"")}_findCenterFromElement(){return new w(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(R.getClass("image"))(e)}toCanvasElement(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};const e=du(this),i=this.group,r=this.shadow,s=Math.abs,o=t.enableRetinaScaling?Zh():1,a=(t.multiplier||1)*o,l=t.canvasProvider||(y=>new Ns(y,{enableRetinaScaling:!1,renderOnAddRemove:!1,skipOffscreen:!1}));delete this.group,t.withoutTransform&&$m(this),t.withoutShadow&&(this.shadow=null),t.viewportTransform&&Nm(this,this.getViewportTransform()),this.setCoords();const c=Fe(),h=this.getBoundingRect(),u=this.shadow,d=new w;if(u){const y=u.blur,x=u.nonScaling?new w(1,1):this.getObjectScaling();d.x=2*Math.round(s(u.offsetX)+y)*s(x.x),d.y=2*Math.round(s(u.offsetY)+y)*s(x.y)}const p=h.width+d.x,g=h.height+d.y;c.width=Math.ceil(p),c.height=Math.ceil(g);const f=l(c);t.format==="jpeg"&&(f.backgroundColor="#fff"),this.setPositionByOrigin(new w(f.width/2,f.height/2),K,K);const m=this.canvas;f._objects=[this],this.set("canvas",f),this.setCoords();const v=f.toCanvasElement(a||1,t);return this.set("canvas",m),this.shadow=r,i&&(this.group=i),this.set(e),this.setCoords(),f._objects=[],f.destroy(),v}toDataURL(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};return ru(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:r}=this;if(e){const{x:s,y:o}=this.getRelativeCenterPoint();this.originX=K,this.originY=K,this.left=s,this.top=o}if(this.set("angle",t),e){const{x:s,y:o}=this.translateToOriginPoint(this.getRelativeCenterPoint(),i,r);this.left=s,this.top=o,this.originX=i,this.originY=r}}setOnGroup(){}_setupCompositeOperation(t){this.globalCompositeOperation&&(t.globalCompositeOperation=this.globalCompositeOperation)}dispose(){Nn.cancelByTarget(this),this.off(),this._set("canvas",void 0),this._cacheCanvas&&Ge().dispose(this._cacheCanvas),this._cacheCanvas=void 0,this._cacheContext=null}animate(t,e){return Object.entries(t).reduce((i,r)=>{let[s,o]=r;return i[s]=this._animate(s,o,e),i},{})}_animate(t,e){let i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};const r=t.split("."),s=this.constructor.colorProperties.includes(r[r.length-1]),{abort:o,startValue:a,onChange:l,onComplete:c}=i,h=_(_({},i),{},{target:this,startValue:a??r.reduce((u,d)=>u[d],this),endValue:e,abort:o==null?void 0:o.bind(this),onChange:(u,d,p)=>{r.reduce((g,f,m)=>(m===r.length-1&&(g[f]=u),g[f]),this),l&&l(u,d,p)},onComplete:(u,d,p)=>{this.setCoords(),c&&c(u,d,p)}});return s?nv(h):xu(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 r,s=0;s<e.length;s++){if(r=e[s],r===t)return{fork:[this,...e.slice(0,s)],otherFork:[],common:e.slice(s)};for(let o=0;o<i.length;o++){if(this===i[o])return{fork:[],otherFork:[t,...i.slice(0,o)],common:[this,...e]};if(r===i[o])return{fork:[this,...e.slice(0,s)],otherFork:[t,...i.slice(0,o)],common:e.slice(s)}}}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 r=e.fork.pop(),s=e.otherFork.pop(),o=i._objects.indexOf(r),a=i._objects.indexOf(s);return o>-1&&o>a}toObject(){const t=(arguments.length>0&&arguments[0]!==void 0?arguments[0]:[]).concat(kn.customProperties,this.constructor.customProperties||[]);let e;const i=tt.NUM_FRACTION_DIGITS,{clipPath:r,fill:s,stroke:o,shadow:a,strokeDashArray:l,left:c,top:h,originX:u,originY:d,width:p,height:g,strokeWidth:f,strokeLineCap:m,strokeDashOffset:v,strokeLineJoin:y,strokeUniform:x,strokeMiterLimit:E,scaleX:O,scaleY:D,angle:C,flipX:T,flipY:F,opacity:j,visible:A,backgroundColor:k,fillRule:P,paintFirst:L,globalCompositeOperation:z,skewX:X,skewY:J}=this;r&&!r.excludeFromExport&&(e=r.toObject(t.concat("inverted","absolutePositioned")));const $=M=>mt(M,i),B=_(_({},Br(this,t)),{},{type:this.constructor.type,version:ua,originX:u,originY:d,left:$(c),top:$(h),width:$(p),height:$(g),fill:mc(s)?s.toObject():s,stroke:mc(o)?o.toObject():o,strokeWidth:$(f),strokeDashArray:l&&l.concat(),strokeLineCap:m,strokeDashOffset:v,strokeLineJoin:y,strokeUniform:x,strokeMiterLimit:$(E),scaleX:$(O),scaleY:$(D),angle:$(C),flipX:T,flipY:F,opacity:$(j),shadow:a&&a.toObject(),visible:A,backgroundColor:k,fillRule:P,paintFirst:L,globalCompositeOperation:z,skewX:$(X),skewY:$(J)},e?{clipPath:e}:null);return this.includeDefaultValues?B:this._removeDefaultValues(B)}toDatalessObject(t){return this.toObject(t)}_removeDefaultValues(t){const e=this.constructor.getDefaults(),i=Object.keys(e).length>0?e:Object.getPrototypeOf(this);return il(t,(r,s)=>{if(s===it||s===le||s==="type")return!0;const o=i[s];return r!==o&&!(Array.isArray(r)&&Array.isArray(o)&&r.length===0&&o.length===0)})}toString(){return"#<".concat(this.constructor.type,">")}static _fromObject(t){let e=gt(t,av),i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},{extraParam:r}=i,s=gt(i,lv);return bo(e,s).then(o=>r?(delete o[r],new this(e[r],o)):new this(o))}static fromObject(t,e){return this._fromObject(t,e)}};b(Qe,"stateProperties",Xm),b(Qe,"cacheProperties",fi),b(Qe,"ownDefaults",Km),b(Qe,"type","FabricObject"),b(Qe,"colorProperties",[$t,he,"backgroundColor"]),b(Qe,"customProperties",[]),R.setClass(Qe),R.setClass(Qe,"object");const Nr=(n,t,e)=>(i,r,s,o)=>{const a=t(i,r,s,o);return a&&pu(n,_(_({},fu(i,r,s,o)),e)),a};function zr(n){return(t,e,i,r)=>{const{target:s,originX:o,originY:a}=e,l=s.getRelativeCenterPoint(),c=s.translateToOriginPoint(l,o,a),h=n(t,e,i,r);return s.setPositionByOrigin(c,e.originX,e.originY),h}}const Tc=Nr(xs,zr((n,t,e,i)=>{const r=sl(t,t.originX,t.originY,e,i);if(Dt(t.originX)===Dt(K)||Dt(t.originX)===Dt(Et)&&r.x<0||Dt(t.originX)===Dt(it)&&r.x>0){const{target:s}=t,o=s.strokeWidth/(s.strokeUniform?s.scaleX:1),a=gu(t)?2:1,l=s.width,c=Math.abs(r.x*a/s.scaleX)-o;return s.set("width",Math.max(c,1)),l!==s.width}return!1}));function cv(n,t,e,i,r){i=i||{};const s=this.sizeX||i.cornerSize||r.cornerSize,o=this.sizeY||i.cornerSize||r.cornerSize,a=i.transparentCorners!==void 0?i.transparentCorners:r.transparentCorners,l=a?he:$t,c=!a&&(i.cornerStrokeColor||r.cornerStrokeColor);let h,u=t,d=e;n.save(),n.fillStyle=i.cornerColor||r.cornerColor||"",n.strokeStyle=i.cornerStrokeColor||r.cornerStrokeColor||"",s>o?(h=s,n.scale(1,o/s),d=e*s/o):o>s?(h=o,n.scale(s/o,1),u=t*o/s):h=s,n.beginPath(),n.arc(u,d,h/2,0,Rn,!1),n[l](),c&&n.stroke(),n.restore()}function hv(n,t,e,i,r){i=i||{};const s=this.sizeX||i.cornerSize||r.cornerSize,o=this.sizeY||i.cornerSize||r.cornerSize,a=i.transparentCorners!==void 0?i.transparentCorners:r.transparentCorners,l=a?he:$t,c=!a&&(i.cornerStrokeColor||r.cornerStrokeColor),h=s/2,u=o/2;n.save(),n.fillStyle=i.cornerColor||r.cornerColor||"",n.strokeStyle=i.cornerStrokeColor||r.cornerStrokeColor||"",n.translate(t,e);const d=r.getTotalAngle();n.rotate(Ot(d)),n["".concat(l,"Rect")](-h,-u,s,o),c&&n.strokeRect(-h,-u,s,o),n.restore()}class ke{constructor(t){b(this,"visible",!0),b(this,"actionName",mo),b(this,"angle",0),b(this,"x",0),b(this,"y",0),b(this,"offsetX",0),b(this,"offsetY",0),b(this,"sizeX",0),b(this,"sizeY",0),b(this,"touchSizeX",0),b(this,"touchSizeY",0),b(this,"cursorStyle","crosshair"),b(this,"withConnection",!1),Object.assign(this,t)}shouldActivate(t,e,i,r){var s;let{tl:o,tr:a,br:l,bl:c}=r;return((s=e.canvas)===null||s===void 0?void 0:s.getActiveObject())===e&&e.isControlVisible(t)&&ft.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,r;return(i=(r=t._controlsVisibility)===null||r===void 0?void 0:r[e])!==null&&i!==void 0?i:this.visible}setVisibility(t,e,i){this.visible=t}positionHandler(t,e,i,r){return new w(this.x*t.x+this.offsetX,this.y*t.y+this.offsetY).transform(e)}calcCornerCoords(t,e,i,r,s,o){const a=tl([$s(i,r),Bs({angle:t}),el((s?this.touchSizeX:this.sizeX)||e,(s?this.touchSizeY:this.sizeY)||e)]);return{tl:new w(-.5,-.5).transform(a),tr:new w(.5,-.5).transform(a),br:new w(.5,.5).transform(a),bl:new w(-.5,.5).transform(a)}}render(t,e,i,r,s){((r=r||{}).cornerStyle||s.cornerStyle)==="circle"?cv.call(this,t,e,i,r,s):hv.call(this,t,e,i,r,s)}}const uv=(n,t,e)=>e.lockRotation?Un:t.cursorStyle,dv=Nr(Qh,zr((n,t,e,i)=>{let{target:r,ex:s,ey:o,theta:a,originX:l,originY:c}=t;const h=r.translateToOriginPoint(r.getRelativeCenterPoint(),l,c);if(Le(r,"lockRotation"))return!1;const u=Math.atan2(o-h.y,s-h.x),d=Math.atan2(i-h.y,e-h.x);let p=rr(d-u+a);if(r.snapAngle&&r.snapAngle>0){const f=r.snapAngle,m=r.snapThreshold||f,v=Math.ceil(p/f)*f,y=Math.floor(p/f)*f;Math.abs(p-y)<m?p=y:Math.abs(p-v)<m&&(p=v)}p<0&&(p=360+p),p%=360;const g=r.angle!==p;return r.angle=p,g}));function wu(n,t){const e=t.canvas,i=n[e.uniScaleKey];return e.uniformScaling&&!i||!e.uniformScaling&&i}function Cu(n,t,e){const i=Le(n,"lockScalingX"),r=Le(n,"lockScalingY");if(i&&r||!t&&(i||r)&&e||i&&t==="x"||r&&t==="y")return!0;const{width:s,height:o,strokeWidth:a}=n;return s===0&&a===0&&t!=="y"||o===0&&a===0&&t!=="x"}const pv=["e","se","s","sw","w","nw","n","ne","e"],ts=(n,t,e)=>{const i=wu(n,e);if(Cu(e,t.x!==0&&t.y===0?"x":t.x===0&&t.y!==0?"y":"",i))return Un;const r=mu(e,t);return"".concat(pv[r],"-resize")};function al(n,t,e,i){let r=arguments.length>4&&arguments[4]!==void 0?arguments[4]:{};const s=t.target,o=r.by,a=wu(n,s);let l,c,h,u,d,p;if(Cu(s,o,a))return!1;if(t.gestureScale)c=t.scaleX*t.gestureScale,h=t.scaleY*t.gestureScale;else{if(l=sl(t,t.originX,t.originY,e,i),d=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=d),t.signY||(t.signY=p),Le(s,"lockScalingFlip")&&(t.signX!==d||t.signY!==p))return!1;if(u=s._getTransformedDimensions(),a&&!o){const m=Math.abs(l.x)+Math.abs(l.y),{original:v}=t,y=m/(Math.abs(u.x*v.scaleX/s.scaleX)+Math.abs(u.y*v.scaleY/s.scaleY));c=v.scaleX*y,h=v.scaleY*y}else c=Math.abs(l.x*s.scaleX/u.x),h=Math.abs(l.y*s.scaleY/u.y);gu(t)&&(c*=2,h*=2),t.signX!==d&&o!=="y"&&(t.originX=_c(t.originX),c*=-1,t.signX=d),t.signY!==p&&o!=="x"&&(t.originY=_c(t.originY),h*=-1,t.signY=p)}const g=s.scaleX,f=s.scaleY;return o?(o==="x"&&s.set(pe,c),o==="y"&&s.set(Ee,h)):(!Le(s,"lockScalingX")&&s.set(pe,c),!Le(s,"lockScalingY")&&s.set(Ee,h)),g!==s.scaleX||f!==s.scaleY}const Xs=Nr(fo,zr((n,t,e,i)=>al(n,t,e,i))),gv=Nr(fo,zr((n,t,e,i)=>al(n,t,e,i,{by:"x"}))),fv=Nr(fo,zr((n,t,e,i)=>al(n,t,e,i,{by:"y"}))),mv=["target","ex","ey","skewingSide"],Ho={x:{counterAxis:"y",scale:pe,skew:Rr,lockSkewing:"lockSkewingX",origin:"originX",flip:"flipX"},y:{counterAxis:"x",scale:Ee,skew:$r,lockSkewing:"lockSkewingY",origin:"originY",flip:"flipY"}},vv=["ns","nesw","ew","nwse"],bv=(n,t,e)=>{if(t.x!==0&&Le(e,"lockSkewingY")||t.y!==0&&Le(e,"lockSkewingX"))return Un;const i=mu(e,t)%4;return"".concat(vv[i],"-resize")};function Su(n,t,e,i,r){const{target:s}=e,{counterAxis:o,origin:a,lockSkewing:l,skew:c,flip:h}=Ho[n];if(Le(s,l))return!1;const{origin:u,flip:d}=Ho[o],p=Dt(e[u])*(s[d]?-1:1),g=-Math.sign(p)*(s[h]?-1:1),f=.5*-((s[c]===0&&sl(e,K,K,i,r)[n]>0||s[c]>0?1:-1)*g)+.5;return Nr(tu,zr((v,y,x,E)=>function(O,D,C){let{target:T,ex:F,ey:j,skewingSide:A}=D,k=gt(D,mv);const{skew:P}=Ho[O],L=C.subtract(new w(F,j)).divide(new w(T.scaleX,T.scaleY))[O],z=T[P],X=k[P],J=Math.tan(Ot(X)),$=O==="y"?T._getTransformedDimensions({scaleX:1,scaleY:1,skewX:0}).x:T._getTransformedDimensions({scaleX:1,scaleY:1}).y,B=2*L*A/Math.max($,1)+J,M=rr(Math.atan(B));T.set(P,M);const H=z!==T[P];if(H&&O==="y"){const{skewX:Q,scaleX:Ct}=T,ot=T._getTransformedDimensions({skewY:z}),ge=T._getTransformedDimensions(),I=Q!==0?ot.x/ge.x:1;I!==1&&T.set(pe,I*Ct)}return H}(n,y,new w(x,E))))(t,_(_({},e),{},{[a]:f,skewingSide:g}),i,r)}const _v=(n,t,e,i)=>Su("x",n,t,e,i),yv=(n,t,e,i)=>Su("y",n,t,e,i);function xo(n,t){return n[t.canvas.altActionKey]}const Ks=(n,t,e)=>{const i=xo(n,e);return t.x===0?i?Rr:Ee:t.y===0?i?$r:pe:""},_r=(n,t,e)=>xo(n,e)?bv(0,t,e):ts(n,t,e),Ec=(n,t,e,i)=>xo(n,t.target)?yv(n,t,e,i):gv(n,t,e,i),Oc=(n,t,e,i)=>xo(n,t.target)?_v(n,t,e,i):fv(n,t,e,i),Tu=()=>({ml:new ke({x:-.5,y:0,cursorStyleHandler:_r,actionHandler:Ec,getActionName:Ks}),mr:new ke({x:.5,y:0,cursorStyleHandler:_r,actionHandler:Ec,getActionName:Ks}),mb:new ke({x:0,y:.5,cursorStyleHandler:_r,actionHandler:Oc,getActionName:Ks}),mt:new ke({x:0,y:-.5,cursorStyleHandler:_r,actionHandler:Oc,getActionName:Ks}),tl:new ke({x:-.5,y:-.5,cursorStyleHandler:ts,actionHandler:Xs}),tr:new ke({x:.5,y:-.5,cursorStyleHandler:ts,actionHandler:Xs}),bl:new ke({x:-.5,y:.5,cursorStyleHandler:ts,actionHandler:Xs}),br:new ke({x:.5,y:.5,cursorStyleHandler:ts,actionHandler:Xs}),mtr:new ke({x:0,y:-.5,actionHandler:dv,cursorStyleHandler:uv,offsetY:-40,withConnection:!0,actionName:Ja})}),xv=()=>({mr:new ke({x:.5,y:0,actionHandler:Tc,cursorStyleHandler:_r,actionName:xs}),ml:new ke({x:-.5,y:0,actionHandler:Tc,cursorStyleHandler:_r,actionName:xs})}),wv=()=>_(_({},Tu()),xv());class Ss extends Qe{static getDefaults(){return _(_({},super.getDefaults()),Ss.ownDefaults)}constructor(t){super(),Object.assign(this,this.constructor.createControls(),Ss.ownDefaults),this.setOptions(t)}static createControls(){return{controls:Tu()}}_updateCacheCanvas(){const t=this.canvas;if(this.noScaleCache&&t&&t._currentTransform){const e=t._currentTransform,i=e.target,r=e.action;if(this===i&&r&&r.startsWith(mo))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 r=i.length-1;r>=0;r--){const[s,o]=i[r],a=this.controls[s];if(a.shouldActivate(s,this,t,e?o.touchCorner:o.corner))return this.__corner=s,{key:s,control:a,coord:this.oCoords[s]}}}calcOCoords(){const t=this.getViewportTransform(),e=this.getCenterPoint(),i=$s(e.x,e.y),r=Bs({angle:this.getTotalAngle()-(this.group&&this.flipX?180:0)}),s=Vt(i,r),o=Vt(t,s),a=Vt(o,[1/t[0],0,0,1/t[3],0,0]),l=this.group?zn(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((u,d)=>{const p=u.positionHandler(c,a,this,u);h[d]=Object.assign(p,this._calcCornerCoords(u,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(),r=this.getViewportTransform();t.translate(e.x,e.y),t.scale(1/r[0],1/r[3]),t.rotate(Ot(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 r=_({hasControls:this.hasControls,borderColor:this.borderColor,borderDashArray:this.borderDashArray},i);t.save(),t.strokeStyle=r.borderColor,this._setLineDash(t,r.borderDashArray),this.strokeBorders(t,e),r.hasControls&&this.drawControlsConnectingLines(t,e),t.restore()}_renderControls(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};const{hasBorders:i,hasControls:r}=this,s=_({hasBorders:i,hasControls:r},e),o=this.getViewportTransform(),a=s.hasBorders,l=s.hasControls,c=Vt(o,this.calcTransformMatrix()),h=zn(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(Ot(this.group?h.angle:this.angle)),a&&this.drawBorders(t,h,e),l&&this.drawControls(t,e),t.restore()}drawBorders(t,e,i){let r;if(i&&i.forActiveSelection||this.group){const s=rl(this.width,this.height,vo(e)),o=this.isStrokeAccountedForInDimensions()?Qa:(this.strokeUniform?new w().scalarAdd(this.canvas?this.canvas.getZoom():1):new w(e.scaleX,e.scaleY)).scalarMultiply(this.strokeWidth);r=s.add(o).scalarAdd(this.borderScaleFactor).scalarAdd(2*this.padding)}else r=this._calculateCurrentDimensions().scalarAdd(this.borderScaleFactor);this._drawBorders(t,r,i)}drawControlsConnectingLines(t,e){let i=!1;t.beginPath(),this.forEachControl((r,s)=>{r.withConnection&&r.getVisibility(this,s)&&(i=!0,t.moveTo(r.x*e.x,r.y*e.y),t.lineTo(r.x*e.x+r.offsetX,r.y*e.y+r.offsetY))}),i&&t.stroke()}drawControls(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};t.save();const i=this.getCanvasRetinaScaling(),{cornerStrokeColor:r,cornerDashArray:s,cornerColor:o}=this,a=_({cornerStrokeColor:r,cornerDashArray:s,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,r]=e;return this.setControlVisible(i,r)})}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 r=this.width+4,s=this.height+4;return e.clearRect(-r/2,-s/2,r,s),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 Eu(n,t){return t.forEach(e=>{Object.getOwnPropertyNames(e.prototype).forEach(i=>{i!=="constructor"&&Object.defineProperty(n.prototype,i,Object.getOwnPropertyDescriptor(e.prototype,i)||Object.create(null))})}),n}b(Ss,"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 Xt extends Ss{}Eu(Xt,[vu]),R.setClass(Xt),R.setClass(Xt,"object");const Cv=(n,t,e,i)=>{const r=2*(i=Math.round(i))+1,{data:s}=n.getImageData(t-i,e-i,r,r);for(let o=3;o<s.length;o+=4)if(s[o]>0)return!1;return!0};class Ou{constructor(t){this.options=t,this.strokeProjectionMagnitude=this.options.strokeWidth/2,this.scale=new w(this.options.scaleX,this.options.scaleY),this.strokeUniformScalar=this.options.strokeUniform?new w(1/this.options.scaleX,1/this.options.scaleY):new w(1,1)}createSideVector(t,e){const i=ma(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 w(t);return e.y+=e.x*Math.tan(Ot(this.options.skewY)),e.x+=e.y*Math.tan(Ot(this.options.skewX)),e}scaleUnitVector(t,e){return t.multiply(this.strokeUniformScalar).scalarMultiply(e)}}const Sv=new w;class Er extends Ou{static getOrthogonalRotationFactor(t,e){const i=e?ba(t,e):Gm(t);return Math.abs(i)<Rs?-1:1}constructor(t,e,i,r){super(r),b(this,"AB",void 0),b(this,"AC",void 0),b(this,"alpha",void 0),b(this,"bisector",void 0),this.A=new w(t),this.B=new w(e),this.C=new w(i),this.AB=this.createSideVector(this.A,this.B),this.AC=this.createSideVector(this.A,this.C),this.alpha=ba(this.AB,this.AC),this.bisector=nl(_u(this.AB.eq(Sv)?this.AC:this.AB,this.alpha/2))}calcOrthogonalProjection(t,e){let i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:this.strokeProjectionMagnitude;const r=this.createSideVector(t,e),s=yu(r),o=Er.getOrthogonalRotationFactor(s,this.bisector);return this.scaleUnitVector(s,i*o)}projectBevel(){const t=[];return(this.alpha%Rn==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),r=this.scaleUnitVector(this.bisector,-this.strokeProjectionMagnitude*i),s=this.options.strokeUniform?va(this.scaleUnitVector(this.bisector,this.options.strokeMiterLimit)):this.options.strokeMiterLimit;return va(r)/this.strokeProjectionMagnitude<=s&&t.push(this.applySkew(this.A.add(r))),t.push(...this.projectBevel()),t}projectRoundNoSkew(t,e){const i=[],r=new w(Er.getOrthogonalRotationFactor(this.bisector),Er.getOrthogonalRotationFactor(new w(this.bisector.y,this.bisector.x)));return[new w(1,0).scalarMultiply(this.strokeProjectionMagnitude).multiply(this.strokeUniformScalar).multiply(r),new w(0,1).scalarMultiply(this.strokeProjectionMagnitude).multiply(this.strokeUniformScalar).multiply(r)].forEach(s=>{wc(s,t,e)&&i.push(this.A.add(s))}),i}projectRoundWithSkew(t,e){const i=[],{skewX:r,skewY:s,scaleX:o,scaleY:a,strokeUniform:l}=this.options,c=new w(Math.tan(Ot(r)),Math.tan(Ot(s))),h=this.strokeProjectionMagnitude,u=l?h/a/Math.sqrt(1/a**2+1/o**2*c.y**2):h/Math.sqrt(1+c.y**2),d=new w(Math.sqrt(Math.max(h**2-u**2,0)),u),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 w(p,Math.sqrt(Math.max(h**2-p**2,0)));return[g,g.scalarMultiply(-1),d,d.scalarMultiply(-1)].map(f=>this.applySkew(l?f.multiply(this.strokeUniformScalar):f)).forEach(f=>{wc(f,t,e)&&i.push(this.applySkew(this.A).add(f))}),i}projectRound(){const t=[];t.push(...this.projectBevel());const e=this.alpha%Rn==0,i=this.applySkew(this.A),r=t[e?0:2].subtract(i),s=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(r,o)>0,l=a?r:s,c=a?s:r;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 kc extends Ou{constructor(t,e,i){super(i),this.A=new w(t),this.T=new w(e)}calcOrthogonalProjection(t,e){let i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:this.strokeProjectionMagnitude;const r=this.createSideVector(t,e);return this.scaleUnitVector(yu(r),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 w(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 Er(this.A,this.T,this.T,this.options).projectRound());return t}projectSquare(){const t=[];if(this.A.eq(this.T)){const e=new w(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(nl(this.createSideVector(this.A,this.T)),-this.strokeProjectionMagnitude),r=this.A.add(i);t.push(r.add(e),r.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 Tv=function(n,t){let e=arguments.length>2&&arguments[2]!==void 0&&arguments[2];const i=[];if(n.length===0)return i;const r=n.reduce((s,o)=>(s[s.length-1].eq(o)||s.push(new w(o)),s),[new w(n[0])]);if(r.length===1)e=!0;else if(!e){const s=r[0],o=((a,l)=>{for(let c=a.length-1;c>=0;c--)if(l(a[c],c,a))return c;return-1})(r,a=>!a.eq(s));r.splice(o+1)}return r.forEach((s,o,a)=>{let l,c;o===0?(c=a[1],l=e?s:a[a.length-1]):o===a.length-1?(l=a[o-1],c=e?s:a[0]):(l=a[o-1],c=a[o+1]),e&&a.length===1?i.push(...new kc(s,s,t).project()):!e||o!==0&&o!==a.length-1?i.push(...new Er(s,l,c,t).project()):i.push(...new kc(s,o===0?c:l,t).project())}),i},ll=n=>{const t={};return Object.keys(n).forEach(e=>{t[e]={},Object.keys(n[e]).forEach(i=>{t[e][i]=_({},n[e][i])})}),t},Ev=n=>n.replace(/&/g,"&").replace(/"/g,""").replace(/'/g,"'").replace(/</g,"<").replace(/>/g,">"),cl=n=>{const t=[];for(let e,i=0;i<n.length;i++)(e=Ov(n,i))!==!1&&t.push(e);return t},Ov=(n,t)=>{const e=n.charCodeAt(t);if(isNaN(e))return"";if(e<55296||e>57343)return n.charAt(t);if(55296<=e&&e<=56319){if(n.length<=t+1)throw"High surrogate without following low surrogate";const r=n.charCodeAt(t+1);if(56320>r||r>57343)throw"High surrogate without following low surrogate";return n.charAt(t)+n.charAt(t+1)}if(t===0)throw"Low surrogate without preceding high surrogate";const i=n.charCodeAt(t-1);if(55296>i||i>56319)throw"Low surrogate without preceding high surrogate";return!1},hl=function(n,t){let e=arguments.length>2&&arguments[2]!==void 0&&arguments[2];return n.fill!==t.fill||n.stroke!==t.stroke||n.strokeWidth!==t.strokeWidth||n.fontSize!==t.fontSize||n.fontFamily!==t.fontFamily||n.fontWeight!==t.fontWeight||n.fontStyle!==t.fontStyle||n.textBackgroundColor!==t.textBackgroundColor||n.deltaY!==t.deltaY||e&&(n.overline!==t.overline||n.underline!==t.underline||n.linethrough!==t.linethrough)},kv=(n,t)=>{const e=t.split(`
|
|
2515
|
-
`),i=[];let
|
|
2516
|
-
`)]}static async fromElement(t,e,i){const r=mi(t,this.ATTRIBUTE_NAMES,i),{left:s=0,top:o=0,width:a=0,height:l=0,visible:c=!0}=r,h=gt(r,qv);return new this(_(_(_({},e),h),{},{left:s,top:o,width:a,height:l,visible:!!(c&&a&&l)}))}}b(Ht,"type","Rect"),b(Ht,"cacheProperties",[...fi,...ku]),b(Ht,"ownDefaults",{rx:0,ry:0}),b(Ht,"ATTRIBUTE_NAMES",[...Bi,"x","y","rx","ry","width","height"]),R.setClass(Ht),R.setSVGClass(Ht);const ni="initialization",Wn="added",dl="removed",Gn="imperative",Au=(n,t)=>{const{strokeUniform:e,strokeWidth:i,width:r,height:s,group:o}=t,a=o&&o!==n?_o(o.calcTransformMatrix(),n.calcTransformMatrix()):null,l=a?t.getRelativeCenterPoint().transform(a):t.getRelativeCenterPoint(),c=!t.isStrokeAccountedForInDimensions(),h=e&&c?Bm(new w(i,i),void 0,n.calcTransformMatrix()):Qa,u=!e&&c?i:0,d=rl(r+u,s+u,tl([a,t.calcOwnMatrix()],!0)).add(h).scalarDivide(2);return[l.subtract(d),l.add(d)]};class wo{calcLayoutResult(t,e){if(this.shouldPerformLayout(t))return this.calcBoundingBox(e,t)}shouldPerformLayout(t){let{type:e,prevStrategy:i,strategy:r}=t;return e===ni||e===Gn||!!i&&r!==i}shouldLayoutClipPath(t){let{type:e,target:{clipPath:i}}=t;return e!==ni&&i&&!i.absolutePositioned}getInitialSize(t,e){return e.size}calcBoundingBox(t,e){const{type:i,target:r}=e;if(i===Gn&&e.overrides)return e.overrides;if(t.length===0)return;const{left:s,top:o,width:a,height:l}=li(t.map(u=>Au(r,u)).reduce((u,d)=>u.concat(d),[])),c=new w(a,l),h=new w(s,o).add(c.scalarDivide(2));if(i===ni){const u=this.getInitialSize(e,{size:c,center:h});return{center:h,relativeCorrection:new w(0,0),size:u}}return{center:h.transform(r.calcOwnMatrix()),size:c}}}b(wo,"type","strategy");class ya extends wo{shouldPerformLayout(t){return!0}}b(ya,"type","fit-content"),R.setClass(ya);const Zv=["strategy"],Jv=["target","strategy","bubbles","prevStrategy"],Pu="layoutManager";class Ts{constructor(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:new ya;b(this,"strategy",void 0),this.strategy=t,this._subscriptions=new Map}performLayout(t){const e=_(_({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[Bn,Jh,xs,Qh,fo,tu,$n,Sm,Tm].map(r=>t.on(r,s=>this.performLayout(r===Bn?{type:"object_modified",trigger:r,e:s,target:i}:{type:"object_modifying",trigger:r,e:s,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:r}=e;if(i===ni||i===Wn?this.subscribeTargets(t):i===dl&&this.unsubscribeTargets(t),e.fire("layout:before",{context:t}),r&&r.fire("object:layout:before",{target:e,context:t}),i===Gn&&t.deep){const s=gt(t,Zv);e.forEachObject(o=>o.layoutManager&&o.layoutManager.performLayout(_(_({},s),{},{bubbles:!1,target:o})))}}getLayoutResult(t){const{target:e,strategy:i,type:r}=t,s=i.calcLayoutResult(t,e.getObjects());if(!s)return;const o=r===ni?new w:e.getRelativeCenterPoint(),{center:a,correction:l=new w,relativeCorrection:c=new w}=s,h=o.subtract(a).add(l).transform(r===ni?ie:Ie(e.calcOwnMatrix()),!0).add(c);return{result:s,prevCenter:o,nextCenter:a,offset:h}}commitLayout(t,e){const{target:i}=t,{result:{size:r},nextCenter:s}=e;var o,a;i.set({width:r.x,height:r.y}),this.layoutObjects(t,e),t.type===ni?i.set({left:(o=t.x)!==null&&o!==void 0?o:s.x+r.x*Dt(i.originX),top:(a=t.y)!==null&&a!==void 0?a:s.y+r.y*Dt(i.originY)}):(i.setPositionByOrigin(s,K,K),i.setCoords(),i.set("dirty",!0))}layoutObjects(t,e){const{target:i}=t;i.forEachObject(r=>{r.group===i&&this.layoutObject(t,e,r)}),t.strategy.shouldLayoutClipPath(t)&&this.layoutObject(t,e,i.clipPath)}layoutObject(t,e,i){let{offset:r}=e;i.set({left:i.left+r.x,top:i.top+r.y})}onAfterLayout(t,e){const{target:i,strategy:r,bubbles:s,prevStrategy:o}=t,a=gt(t,Jv),{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;s&&c!=null&&c.layoutManager&&((a.path||(a.path=[])).push(i),c.layoutManager.performLayout(_(_({},a),{},{target:c}))),i.set("dirty",!0)}dispose(){const{_subscriptions:t}=this;t.forEach(e=>e.forEach(i=>i())),t.clear()}toObject(){return{type:Pu,strategy:this.strategy.constructor.type}}toJSON(){return this.toObject()}}R.setClass(Ts,Pu);const Qv=["type","objects","layoutManager"];class tb extends Ts{performLayout(){}}class Ei extends eu(Xt){static getDefaults(){return _(_({},super.getDefaults()),Ei.ownDefaults)}constructor(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};super(),b(this,"_activeObjects",[]),b(this,"__objectSelectionTracker",void 0),b(this,"__objectSelectionDisposer",void 0),Object.assign(this,Ei.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(r=>{this.enterGroup(r,!1)}),this.layoutManager=(i=e.layoutManager)!==null&&i!==void 0?i:new Ts,this.layoutManager.performLayout({type:ni,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,r)=>this.canEnterGroup(e)&&r.indexOf(e)===i)}add(){for(var t=arguments.length,e=new Array(t),i=0;i<t;i++)e[i]=arguments[i];const r=this._filterObjectsBeforeEnteringGroup(e),s=super.add(...r);return this._onAfterObjectsChange(Wn,r),s}insertAt(t){for(var e=arguments.length,i=new Array(e>1?e-1:0),r=1;r<e;r++)i[r-1]=arguments[r];const s=this._filterObjectsBeforeEnteringGroup(i),o=super.insertAt(t,...s);return this._onAfterObjectsChange(Wn,s),o}remove(){const t=super.remove(...arguments);return this._onAfterObjectsChange(dl,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(r=>{r._set(t,e)}),this}_shouldSetNestedCoords(){return this.subTargetCheck}removeAll(){return this._activeObjects=[],this.remove(...this._objects)}__objectSelectionMonitor(t,e){let{target:i}=e;const r=this._activeObjects;if(t)r.push(i),this._set("dirty",!0);else if(r.length>0){const s=r.indexOf(i);s>-1&&(r.splice(s,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&&Vn(t,Vt(Ie(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||(Vn(t,Vt(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=Xt.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 s=0;s<this._objects.length;s++){var r;const o=this._objects[s];(r=this.canvas)!==null&&r!==void 0&&r.preserveObjectStacking&&o.group!==this?(t.save(),t.transform(...Ie(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(_({target:this,type:Gn},t))}render(t){this._transformDone=!0,super.render(t),this._transformDone=!1}__serializeObjects(t,e){const i=this.includeDefaultValues;return this._objects.filter(function(r){return!r.excludeFromExport}).map(function(r){const s=r.includeDefaultValues;r.includeDefaultValues=i;const o=r[t||"toObject"](e);return r.includeDefaultValues=s,o})}toObject(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[];const e=this.layoutManager.toObject();return _(_(_({},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=Ht.prototype._toSVG.call(this),i=e.indexOf("COMMON_PARTS");e[i]='for="group" ';const r=e.join("");return t?t(r):r}_toSVG(t){const e=["<g ","COMMON_PARTS",` >
|
|
2517
|
-
`],i=this._createSVGBgRect(t);i&&e.push(" ",i);for(let
|
|
2518
|
-
`),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 r=0;r<this._objects.length;r++)e.push(" ",this._objects[r].toClipPathSVG(t));return this._createBaseClipPathSVGMarkup(e,{reviver:t})}static fromObject(t,e){let{type:i,objects:r=[],layoutManager:s}=t,o=gt(t,Qv);return Promise.all([ws(r,e),bo(o,e)]).then(a=>{let[l,c]=a;const h=new this(l,_(_(_({},o),c),{},{layoutManager:new tb}));if(s){const u=R.getClass(s.type),d=R.getClass(s.strategy);h.layoutManager=new u(new d)}else h.layoutManager=new Ts;return h.layoutManager.subscribeTargets({type:ni,target:h,targets:h.getObjects()}),h.setCoords(),h})}}b(Ei,"type","Group"),b(Ei,"ownDefaults",{strokeWidth:0,subTargetCheck:!1,interactive:!1}),R.setClass(Ei);const eb=(n,t)=>Math.min(t.width/n.width,t.height/n.height),ib=(n,t)=>Math.max(t.width/n.width,t.height/n.height),xa="\\s*,?\\s*",Jr="".concat(xa,"(").concat(sr,")"),rb="".concat(Jr).concat(Jr).concat(Jr).concat(xa,"([01])").concat(xa,"([01])").concat(Jr).concat(Jr),sb={m:"l",M:"L"},nb=(n,t,e,i,r,s,o,a,l,c,h)=>{const u=di(n),d=pi(n),p=di(t),g=pi(t),f=e*r*p-i*s*g+o,m=i*r*p+e*s*g+a;return["C",c+l*(-e*r*d-i*s*u),h+l*(-i*r*d+e*s*u),f+l*(e*r*g+i*s*p),m+l*(i*r*g-e*s*p),f,m]},Rc=(n,t,e,i)=>{const r=Math.atan2(t,n),s=Math.atan2(i,e);return s>=r?s-r:2*Math.PI-(r-s)};function $c(n,t,e,i,r,s,o,a){let l;if(tt.cachesBoundsOfCurve&&(l=[...arguments].join(),as.boundsOfCurveCache[l]))return as.boundsOfCurveCache[l];const c=Math.sqrt,h=Math.abs,u=[],d=[[0,0],[0,0]];let p=6*n-12*e+6*r,g=-3*n+9*e-9*r+3*o,f=3*e-3*n;for(let E=0;E<2;++E){if(E>0&&(p=6*t-12*i+6*s,g=-3*t+9*i-9*s+3*a,f=3*i-3*t),h(g)<1e-12){if(h(p)<1e-12)continue;const F=-f/p;0<F&&F<1&&u.push(F);continue}const O=p*p-4*f*g;if(O<0)continue;const D=c(O),C=(-p+D)/(2*g);0<C&&C<1&&u.push(C);const T=(-p-D)/(2*g);0<T&&T<1&&u.push(T)}let m=u.length;const v=m,y=Du(n,t,e,i,r,s,o,a);for(;m--;){const{x:E,y:O}=y(u[m]);d[0][m]=E,d[1][m]=O}d[0][v]=n,d[1][v]=t,d[0][v+1]=o,d[1][v+1]=a;const x=[new w(Math.min(...d[0]),Math.min(...d[1])),new w(Math.max(...d[0]),Math.max(...d[1]))];return tt.cachesBoundsOfCurve&&(as.boundsOfCurveCache[l]=x),x}const ob=(n,t,e)=>{let[i,r,s,o,a,l,c,h]=e;const u=((d,p,g,f,m,v,y)=>{if(g===0||f===0)return[];let x=0,E=0,O=0;const D=Math.PI,C=y*Ka,T=pi(C),F=di(C),j=.5*(-F*d-T*p),A=.5*(-F*p+T*d),k=g**2,P=f**2,L=A**2,z=j**2,X=k*P-k*L-P*z;let J=Math.abs(g),$=Math.abs(f);if(X<0){const ut=Math.sqrt(1-X/(k*P));J*=ut,$*=ut}else O=(m===v?-1:1)*Math.sqrt(X/(k*L+P*z));const B=O*J*A/$,M=-O*$*j/J,H=F*B-T*M+.5*d,Q=T*B+F*M+.5*p;let Ct=Rc(1,0,(j-B)/J,(A-M)/$),ot=Rc((j-B)/J,(A-M)/$,(-j-B)/J,(-A-M)/$);v===0&&ot>0?ot-=2*D:v===1&&ot<0&&(ot+=2*D);const ge=Math.ceil(Math.abs(ot/D*2)),I=[],et=ot/ge,Wt=8/3*Math.sin(et/4)*Math.sin(et/4)/Math.sin(et/2);let ht=Ct+et;for(let ut=0;ut<ge;ut++)I[ut]=nb(Ct,ht,F,T,J,$,H,Q,Wt,x,E),x=I[ut][5],E=I[ut][6],Ct=ht,ht+=et;return I})(c-n,h-t,r,s,a,l,o);for(let d=0,p=u.length;d<p;d++)u[d][1]+=n,u[d][2]+=t,u[d][3]+=n,u[d][4]+=t,u[d][5]+=n,u[d][6]+=t;return u},ab=n=>{let t=0,e=0,i=0,r=0;const s=[];let o,a=0,l=0;for(const c of n){const h=[...c];let u;switch(h[0]){case"l":h[1]+=t,h[2]+=e;case"L":t=h[1],e=h[2],u=["L",t,e];break;case"h":h[1]+=t;case"H":t=h[1],u=["L",t,e];break;case"v":h[1]+=e;case"V":e=h[1],u=["L",t,e];break;case"m":h[1]+=t,h[2]+=e;case"M":t=h[1],e=h[2],i=h[1],r=h[2],u=["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],u=["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],u=["C",a,l,h[1],h[2],t,e],a=u[3],l=u[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],u=["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],u=["Q",a,l,t,e];break;case"a":h[6]+=t,h[7]+=e;case"A":ob(t,e,h).forEach(d=>s.push(d)),t=h[6],e=h[7];break;case"z":case"Z":t=i,e=r,u=["Z"]}u?(s.push(u),o=u[0]):o=""}return s},Yn=(n,t,e,i)=>Math.sqrt((e-n)**2+(i-t)**2),Du=(n,t,e,i,r,s,o,a)=>l=>{const c=l**3,h=(p=>3*p**2*(1-p))(l),u=(p=>3*p*(1-p)**2)(l),d=(p=>(1-p)**3)(l);return new w(o*c+r*h+e*u+n*d,a*c+s*h+i*u+t*d)},Mu=n=>n**2,Iu=n=>2*n*(1-n),Lu=n=>(1-n)**2,lb=(n,t,e,i,r,s,o,a)=>l=>{const c=Mu(l),h=Iu(l),u=Lu(l),d=3*(u*(e-n)+h*(r-e)+c*(o-r)),p=3*(u*(i-t)+h*(s-i)+c*(a-s));return Math.atan2(p,d)},cb=(n,t,e,i,r,s)=>o=>{const a=Mu(o),l=Iu(o),c=Lu(o);return new w(r*a+e*l+n*c,s*a+i*l+t*c)},hb=(n,t,e,i,r,s)=>o=>{const a=1-o,l=2*(a*(e-n)+o*(r-e)),c=2*(a*(i-t)+o*(s-i));return Math.atan2(c,l)},Bc=(n,t,e)=>{let i=new w(t,e),r=0;for(let s=1;s<=100;s+=1){const o=n(s/100);r+=Yn(i.x,i.y,o.x,o.y),i=o}return r},ub=(n,t)=>{let e,i=0,r=0,s={x:n.x,y:n.y},o=_({},s),a=.01,l=0;const c=n.iterator,h=n.angleFinder;for(;r<t&&a>1e-4;)o=c(i),l=i,e=Yn(s.x,s.y,o.x,o.y),e+r>t?(i-=a,a/=2):(s=o,i+=a,r+=e);return _(_({},o),{},{angle:h(l)})},Fu=n=>{let t,e,i=0,r=0,s=0,o=0,a=0;const l=[];for(const c of n){const h={x:r,y:s,command:c[0],length:0};switch(c[0]){case"M":e=h,e.x=o=r=c[1],e.y=a=s=c[2];break;case"L":e=h,e.length=Yn(r,s,c[1],c[2]),r=c[1],s=c[2];break;case"C":t=Du(r,s,c[1],c[2],c[3],c[4],c[5],c[6]),e=h,e.iterator=t,e.angleFinder=lb(r,s,c[1],c[2],c[3],c[4],c[5],c[6]),e.length=Bc(t,r,s),r=c[5],s=c[6];break;case"Q":t=cb(r,s,c[1],c[2],c[3],c[4]),e=h,e.iterator=t,e.angleFinder=hb(r,s,c[1],c[2],c[3],c[4]),e.length=Bc(t,r,s),r=c[3],s=c[4];break;case"Z":e=h,e.destX=o,e.destY=a,e.length=Yn(r,s,o,a),r=o,s=a}i+=e.length,l.push(e)}return l.push({length:i,x:r,y:s}),l},db=function(n,t){let e=arguments.length>2&&arguments[2]!==void 0?arguments[2]:Fu(n),i=0;for(;t-e[i].length>0&&i<e.length-2;)t-=e[i].length,i++;const r=e[i],s=t/r.length,o=n[i];switch(r.command){case"M":return{x:r.x,y:r.y,angle:0};case"Z":return _(_({},new w(r.x,r.y).lerp(new w(r.destX,r.destY),s)),{},{angle:Math.atan2(r.destY-r.y,r.destX-r.x)});case"L":return _(_({},new w(r.x,r.y).lerp(new w(o[1],o[2]),s)),{},{angle:Math.atan2(o[2]-r.y,o[1]-r.x)});case"C":case"Q":return ub(r,t)}},pb=new RegExp("[mzlhvcsqta][^mzlhvcsqta]*","gi"),Nc=new RegExp(rb,"g"),gb=new RegExp(sr,"gi"),fb={m:2,l:2,h:1,v:1,c:6,s:4,q:4,t:2,a:7},mb=n=>{var t;const e=[],i=(t=n.match(pb))!==null&&t!==void 0?t:[];for(const r of i){const s=r[0];if(s==="z"||s==="Z"){e.push([s]);continue}const o=fb[s.toLowerCase()];let a=[];if(s==="a"||s==="A"){Nc.lastIndex=0;for(let l=null;l=Nc.exec(r);)a.push(...l.slice(1))}else a=r.match(gb)||[];for(let l=0;l<a.length;l+=o){const c=new Array(o),h=sb[s];c[0]=l>0&&h?h:s;for(let u=0;u<o;u++)c[u+1]=parseFloat(a[l+u]);e.push(c)}}return e},vb=(n,t)=>n.map(e=>e.map((i,r)=>r===0||t===void 0?i:mt(i,t)).join(" ")).join(" ");function wa(n,t){const e=n.style;e&&t&&(typeof t=="string"?e.cssText+=";"+t:Object.entries(t).forEach(i=>{let[r,s]=i;return e.setProperty(r,s)}))}class bb extends uu{constructor(t){let{allowTouchScrolling:e=!1,containerClass:i=""}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};super(t),b(this,"upper",void 0),b(this,"container",void 0);const{el:r}=this.lower,s=this.createUpperCanvas();this.upper={el:s,ctx:s.getContext("2d")},this.applyCanvasStyle(r,{allowTouchScrolling:e}),this.applyCanvasStyle(s,{allowTouchScrolling:e,styles:{position:"absolute",left:"0",top:"0"}});const o=this.createContainerElement();o.classList.add(i),r.parentNode&&r.parentNode.replaceChild(o,r),o.append(r,s),this.container=o}createUpperCanvas(){const{el:t}=this.lower,e=Fe();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=jr().createElement("div");return t.setAttribute("data-fabric","wrapper"),wa(t,{position:"relative"}),bc(t),t}applyCanvasStyle(t,e){const{styles:i,allowTouchScrolling:r}=e;wa(t,_(_({},i),{},{"touch-action":r?"manipulation":ce})),bc(t)}setDimensions(t,e){super.setDimensions(t,e);const{el:i,ctx:r}=this.upper;hu(i,r,t,e)}setCSSDimensions(t){super.setCSSDimensions(t),pa(this.upper.el,t),pa(this.container,t)}cleanupDOM(t){const e=this.container,{el:i}=this.lower,{el:r}=this.upper;super.cleanupDOM(t),e.removeChild(r),e.removeChild(i),e.parentNode&&e.parentNode.replaceChild(i,e)}dispose(){super.dispose(),Ge().dispose(this.upper.el),delete this.upper,delete this.container}}class Co extends Ns{constructor(){super(...arguments),b(this,"targets",[]),b(this,"_hoveredTargets",[]),b(this,"_objectsToRender",void 0),b(this,"_currentTransform",null),b(this,"_groupSelector",null),b(this,"contextTopDirty",!1)}static getDefaults(){return _(_({},super.getDefaults()),Co.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 bb(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 r=this.targetFindTolerance,s=this.pixelFindContext;this.clearContext(s),s.save(),s.translate(-e+r,-i+r),s.transform(...this.viewportTransform);const o=t.selectionBackgroundColor;t.selectionBackgroundColor="",t.render(s),t.selectionBackgroundColor=o,s.restore();const a=Math.round(r*this.getRetinaScaling());return Cv(s,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(),r=this._activeObject;return!!(!e||e&&r&&i.length>1&&i.indexOf(e)===-1&&r!==e&&!this._isSelectionKeyPressed(t)||e&&!e.evented||e&&!e.selectable&&r&&r!==e)}_shouldCenterTransform(t,e,i){if(!t)return;let r;return e===mo||e===pe||e===Ee||e===xs?r=this.centeredScaling||t.centeredScaling:e===Ja&&(r=this.centeredRotation||t.centeredRotation),r?!i:i}_getOriginFromCorner(t,e){const i={x:t.originX,y:t.originY};return e&&(["ml","tl","bl"].includes(e)?i.x=Et:["mr","tr","br"].includes(e)&&(i.x=it),["tl","mt","tr"].includes(e)?i.y=da:["bl","mb","br"].includes(e)&&(i.y=le)),i}_setupCurrentTransform(t,e,i){var r;const s=e.group?Tr(this.getScenePoint(t),void 0,e.group.calcTransformMatrix()):this.getScenePoint(t),{key:o="",control:a}=e.getActiveControl()||{},l=i&&a?(r=a.getActionHandler(t,e,a))===null||r===void 0?void 0:r.bind(a):Hm,c=((p,g,f,m)=>{if(!g||!p)return"drag";const v=m.controls[g];return v.getActionName(f,v,m)})(i,o,t,e),h=t[this.centeredKey],u=this._shouldCenterTransform(e,c,h)?{x:K,y:K}:this._getOriginFromCorner(e,o),d={target:e,action:c,actionHandler:l,actionPerformed:!1,corner:o,scaleX:e.scaleX,scaleY:e.scaleY,skewX:e.skewX,skewY:e.skewY,offsetX:s.x-e.left,offsetY:s.y-e.top,originX:u.x,originY:u.y,ex:s.x,ey:s.y,lastX:s.x,lastY:s.y,theta:Ot(e.angle),width:e.width,height:e.height,shiftKey:t.shiftKey,altKey:h,original:_(_({},du(e)),{},{originX:u.x,originY:u.y})};this._currentTransform=d,this.fire("before:transform",{e:t,transform:d})}setCursor(t){this.upperCanvasEl.style.cursor=t}_drawSelection(t){const{x:e,y:i,deltaX:r,deltaY:s}=this._groupSelector,o=new w(e,i).transform(this.viewportTransform),a=new w(e+r,i+s).transform(this.viewportTransform),l=this.selectionLineWidth/2;let c=Math.min(o.x,a.x),h=Math.min(o.y,a.y),u=Math.max(o.x,a.x),d=Math.max(o.y,a.y);this.selectionColor&&(t.fillStyle=this.selectionColor,t.fillRect(c,h,u-c,d-h)),this.selectionLineWidth&&this.selectionBorderColor&&(t.lineWidth=this.selectionLineWidth,t.strokeStyle=this.selectionBorderColor,c+=l,h+=l,u-=l,d-=l,Xt.prototype._setLineDash.call(this,t,this.selectionDashArray),t.strokeRect(c,h,u-c,d-h))}findTarget(t){if(this.skipTargetFind)return;const e=this.getViewportPoint(t),i=this._activeObject,r=this.getActiveObjects();if(this.targets=[],i&&r.length>=1){if(i.findControl(e,ga(t))||r.length>1&&this.searchPossibleTargets([i],e))return i;if(i===this.searchPossibleTargets([i],e)){if(this.preserveObjectStacking){const s=this.targets;this.targets=[];const o=this.searchPossibleTargets(this._objects,e);return t[this.altSelectionKey]&&o&&o!==i?(this.targets=s,i):o}return i}}return this.searchPossibleTargets(this._objects,e)}_pointIsInObjectSelectionArea(t,e){let i=t.getCoords();const r=this.getZoom(),s=t.padding/r;if(s){const[o,a,l,c]=i,h=Math.atan2(a.y-o.y,a.x-o.x),u=di(h)*s,d=pi(h)*s,p=u+d,g=u-d;i=[new w(o.x-g,o.y-p),new w(a.x+p,a.y-g),new w(l.x+g,l.y+p),new w(c.x-p,c.y+g)]}return ft.isPointInPolygon(e,i)}_checkTarget(t,e){return!!(t&&t.visible&&t.evented&&this._pointIsInObjectSelectionArea(t,Tr(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 r=t[i];if(this._checkTarget(r,e)){if(Tn(r)&&r.subTargetCheck){const s=this._searchPossibleTargets(r._objects,e);s&&this.targets.push(s)}return r}}}searchPossibleTargets(t,e){const i=this._searchPossibleTargets(t,e);if(i&&Tn(i)&&i.interactive&&this.targets[0]){const r=this.targets;for(let s=r.length-1;s>0;s--){const o=r[s];if(!Tn(o)||!o.interactive)return o}return r[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,r=i.getBoundingClientRect();let s=Fm(t),o=r.width||0,a=r.height||0;o&&a||(le in r&&da in r&&(a=Math.abs(r.top-r.bottom)),Et in r&&it in r&&(o=Math.abs(r.right-r.left))),this.calcOffset(),s.x=s.x-this._offset.left,s.y=s.y-this._offset.top,e||(s=Tr(s,void 0,this.viewportTransform));const l=this.getRetinaScaling();l!==1&&(s.x/=l,s.y/=l);const c=o===0||a===0?new w(1,1):new w(i.width/o,i.height/a);return s.multiply(c)}_setDimensionsImpl(t,e){this._resetTransformEventData(),super._setDimensionsImpl(t,e),this._isCurrentlyDrawing&&this.freeDrawingBrush&&this.freeDrawingBrush._setBrushStyles(this.contextTop)}_createCacheCanvas(){this.pixelFindCanvasEl=Fe(),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 Ui(t)?t.getObjects():t?[t]:[]}_fireSelectionEvents(t,e){let i=!1,r=!1;const s=this.getActiveObjects(),o=[],a=[];t.forEach(l=>{s.includes(l)||(i=!0,l.fire("deselected",{e,target:l}),a.push(l))}),s.forEach(l=>{t.includes(l)||(i=!0,l.fire("selected",{e,target:l}),o.push(l))}),t.length>0&&s.length>0?(r=!0,i&&this.fire("selection:updated",{e,selected:o,deselected:a})):s.length>0?(r=!0,this.fire("selection:created",{e,selected:o})):t.length>0&&(r=!0,this.fire("selection:cleared",{e,deselected:a})),r&&(this._objectsToRender=void 0)}setActiveObject(t,e){const i=this.getActiveObjects(),r=this._setActiveObject(t,e);return this._fireSelectionEvents(i,e),r}_setActiveObject(t,e){const i=this._activeObject;return i!==t&&!(!this._discardActiveObject(e,t)&&this._activeObject)&&!t.onSelect({e})&&(this._activeObject=t,Ui(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),Ui(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 r=this._discardActiveObject(t);return this._fireSelectionEvents(e,t),r}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,r={e:t,target:i,transform:e,action:e.action};i._scaling&&(i._scaling=!1),i.setCoords(),e.actionPerformed&&(this.fire("object:modified",r),i.fire(Bn,r))}setViewportTransform(t){super.setViewportTransform(t);const e=this._activeObject;e&&e.setCoords()}destroy(){const t=this._activeObject;Ui(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 r=this._realizeGroupTransformOnObject(t),s=super._toObject(t,e,i);return t.set(r),s}_realizeGroupTransformOnObject(t){const{group:e}=t;if(e&&Ui(e)&&this._activeObject===e){const i=Br(t,["angle","flipX","flipY",it,pe,Ee,Rr,$r,le]);return Rm(t,e.calcOwnMatrix()),i}return{}}_setSVGObject(t,e,i){const r=this._realizeGroupTransformOnObject(e);super._setSVGObject(t,e,i),e.set(r)}}b(Co,"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 _b{constructor(t){b(this,"targets",[]),b(this,"__disposer",void 0);const e=()=>{const{hiddenTextarea:r}=t.getActiveObject()||{};r&&r.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),fr(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 yb=["target","oldTarget","fireCanvas","e"],fe={passive:!1},ur=(n,t)=>{const e=n.getViewportPoint(t),i=n.getScenePoint(t);return{viewportPoint:e,scenePoint:i,pointer:e,absolutePointer:i}},bi=function(n){for(var t=arguments.length,e=new Array(t>1?t-1:0),i=1;i<t;i++)e[i-1]=arguments[i];return n.addEventListener(...e)},ye=function(n){for(var t=arguments.length,e=new Array(t>1?t-1:0),i=1;i<t;i++)e[i-1]=arguments[i];return n.removeEventListener(...e)},xb={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 Xn extends Co{constructor(t){super(t,arguments.length>1&&arguments[1]!==void 0?arguments[1]:{}),b(this,"_isClick",void 0),b(this,"textEditingManager",new _b(this)),["_onMouseDown","_onTouchStart","_onMouseMove","_onMouseUp","_onTouchEnd","_onResize","_onMouseWheel","_onMouseOut","_onMouseEnter","_onContextMenu","_onDoubleClick","_onDragStart","_onDragEnd","_onDragProgress","_onDragOver","_onDragEnter","_onDragLeave","_onDrop"].forEach(e=>{this[e]=this[e].bind(this)}),this.addOrRemove(bi,"add")}_getEventPrefix(){return this.enablePointerEvents?"pointer":"mouse"}addOrRemove(t,e){const i=this.upperCanvasEl,r=this._getEventPrefix();t(cu(i),"resize",this._onResize),t(i,r+"down",this._onMouseDown),t(i,"".concat(r,"move"),this._onMouseMove,fe),t(i,"".concat(r,"out"),this._onMouseOut),t(i,"".concat(r,"enter"),this._onMouseEnter),t(i,"wheel",this._onMouseWheel),t(i,"contextmenu",this._onContextMenu),t(i,"dblclick",this._onDoubleClick),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,fe)}removeListeners(){this.addOrRemove(ye,"remove");const t=this._getEventPrefix(),e=De(this.upperCanvasEl);ye(e,"".concat(t,"up"),this._onMouseUp),ye(e,"touchend",this._onTouchEnd,fe),ye(e,"".concat(t,"move"),this._onMouseMove,fe),ye(e,"touchmove",this._onMouseMove,fe),clearTimeout(this._willAddMouseDown)}_onMouseWheel(t){this.__onMouseWheel(t)}_onMouseOut(t){const e=this._hoveredTarget,i=_({e:t},ur(this,t));this.fire("mouse:out",_(_({},i),{},{target:e})),this._hoveredTarget=void 0,e&&e.fire("mouseout",_({},i)),this._hoveredTargets.forEach(r=>{this.fire("mouse:out",_(_({},i),{},{target:r})),r&&r.fire("mouseout",_({},i))}),this._hoveredTargets=[]}_onMouseEnter(t){this._currentTransform||this.findTarget(t)||(this.fire("mouse:over",_({e:t},ur(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 bi(this.upperCanvasEl,"drag",this._onDragProgress)}fa(t)}_renderDragEffects(t,e,i){let r=!1;const s=this._dropTarget;s&&s!==e&&s!==i&&(s.clearContextTop(),r=!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(),r=!0),i&&(o.save(),i.transform(o),i.renderDropTargetEffect(t),o.restore(),r=!0),o.restore(),r&&(this.contextTopDirty=!0)}_onDragEnd(t){const e=!!t.dataTransfer&&t.dataTransfer.dropEffect!==ce,i=e?this._activeObject:void 0,r={e:t,target:this._dragSource,subTargets:this.targets,dragSource:this._dragSource,didDrop:e,dropTarget:i};ye(this.upperCanvasEl,"drag",this._onDragProgress),this.fire("dragend",r),this._dragSource&&this._dragSource.fire("dragend",r),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:r}=this.findDragTargets(t),s=this._dragSource,o={e:t,target:i,subTargets:r,dragSource:s,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<r.length;l++){const c=r[l];c.canDrop(t)&&(a=c),c.fire(e,o)}this._renderDragEffects(t,s,a),this._dropTarget=a}_onDragEnter(t){const{target:e,targets:i}=this.findDragTargets(t),r={e:t,target:e,subTargets:i,dragSource:this._dragSource};this.fire("dragenter",r),this._fireEnterLeaveEvents(e,r)}_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),r=this._basicEventHandler("drop:before",_({e:t,target:e,subTargets:i,dragSource:this._dragSource},ur(this,t)));r.didDrop=!1,r.dropTarget=void 0,this._basicEventHandler("drop",r),this.fire("drop:after",r)}_onContextMenu(t){const e=this.findTarget(t),i=this.targets||[],r=this._basicEventHandler("contextmenu:before",{e:t,target:e,subTargets:i});return this.stopContextMenu&&fa(t),this._basicEventHandler("contextmenu",r),!1}_onDoubleClick(t){this._cacheTransformEventData(t),this._handleEvent(t,"dblclick"),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 r=this.upperCanvasEl,s=this._getEventPrefix(),o=De(r);bi(o,"touchend",this._onTouchEnd,fe),e&&bi(o,"touchmove",this._onMouseMove,fe),ye(r,"".concat(s,"down"),this._onMouseDown)}_onMouseDown(t){this.__onMouseDown(t),this._resetTransformEventData();const e=this.upperCanvasEl,i=this._getEventPrefix();ye(e,"".concat(i,"move"),this._onMouseMove,fe);const r=De(e);bi(r,"".concat(i,"up"),this._onMouseUp),bi(r,"".concat(i,"move"),this._onMouseMove,fe)}_onTouchEnd(t){if(t.touches.length>0)return;this.__onMouseUp(t),this._resetTransformEventData(),delete this.mainTouchId;const e=this._getEventPrefix(),i=De(this.upperCanvasEl);ye(i,"touchend",this._onTouchEnd,fe),ye(i,"touchmove",this._onMouseMove,fe),this._willAddMouseDown&&clearTimeout(this._willAddMouseDown),this._willAddMouseDown=setTimeout(()=>{bi(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 r=De(this.upperCanvasEl);ye(r,"".concat(i,"up"),this._onMouseUp),ye(r,"".concat(i,"move"),this._onMouseMove,fe),bi(e,"".concat(i,"move"),this._onMouseMove,fe)}}_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,r=this._isClick,s=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),!r){const h=s===this._activeObject;this.handleSelection(t),c||(c=this._shouldRender(s)||!h&&s===this._activeObject)}if(s){const h=s.findControl(this.getViewportPoint(t),ga(t)),{key:u,control:d}=h||{};if(l=u,s.selectable&&s!==this._activeObject&&s.activeOn==="up")this.setActiveObject(s,t),c=!0;else if(d){const p=d.getMouseUpHandler(t,s,d);p&&(a=this.getScenePoint(t),p.call(d,t,i,a.x,a.y))}s.isMoving=!1}if(i&&(i.target!==s||i.corner!==l)){const h=i.target&&i.target.controls[i.corner],u=h&&h.getMouseUpHandler(t,i.target,h);a=a||this.getScenePoint(t),u&&u.call(h,t,i,a.x,a.y)}this._setCursorFromEvent(t,s),this._handleEvent(t,"up"),this._groupSelector=null,this._currentTransform=null,s&&(s.__corner=void 0),c?this.requestRenderAll():r||(e=this._activeObject)!==null&&e!==void 0&&e.isEditing||this.renderTop()}_basicEventHandler(t,e){const{target:i,subTargets:r=[]}=e;this.fire(t,e),i&&i.fire(t,e);for(let s=0;s<r.length;s++)r[s]!==i&&r[s].fire(t,e);return e}_handleEvent(t,e){const i=this._target,r=this.targets||[],s=_(_({e:t,target:i,subTargets:r},ur(this,t)),{},{transform:this._currentTransform},e==="up:before"||e==="up"?{isClick:this._isClick,currentTarget:this.findTarget(t),currentSubTargets:this.targets}:{});this.fire("mouse:".concat(e),s),i&&i.fire("mouse".concat(e),s);for(let o=0;o<r.length;o++)r[o]!==i&&r[o].fire("mouse".concat(e),s)}_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")}_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;const{button:i}=t;if(i)return(this.fireMiddleClick&&i===1||this.fireRightClick&&i===2)&&this._handleEvent(t,"down"),void this._resetTransformEventData();if(this.isDrawingMode)return void this._onMouseDownInDrawingMode(t);if(!this._isMainEvent(t)||this._currentTransform)return;let r=this._shouldRender(e),s=!1;if(this.handleMultiSelection(t,e)?(e=this._activeObject,s=!0,r=!0):this._shouldClearSelection(t,e)&&this.discardActiveObject(t),this.selection&&(!e||!e.selectable&&!e.isEditing&&e!==this._activeObject)){const o=this.getScenePoint(t);this._groupSelector={x:o.x,y:o.y,deltaY:0,deltaX:0}}if(e){const o=e===this._activeObject;e.selectable&&e.activeOn==="down"&&this.setActiveObject(e,t);const a=e.findControl(this.getViewportPoint(t),ga(t));if(e===this._activeObject&&(a||!s)){this._setupCurrentTransform(t,e,o);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)}}r&&(this._objectsToRender=void 0),this._handleEvent(t,"down"),r&&this.requestRenderAll()}_resetTransformEventData(){this._target=this._pointer=this._absolutePointer=void 0}_cacheTransformEventData(t){this._resetTransformEventData(),this._pointer=this.getViewportPoint(t),this._absolutePointer=Tr(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,r=this._hoveredTargets,s=this.targets,o=Math.max(r.length,s.length);this.fireSyntheticInOutEvents("mouse",{e:t,target:e,oldTarget:i,fireCanvas:!0});for(let a=0;a<o;a++)this.fireSyntheticInOutEvents("mouse",{e:t,target:s[a],oldTarget:r[a]});this._hoveredTarget=e,this._hoveredTargets=this.targets.concat()}_fireEnterLeaveEvents(t,e){const i=this._draggedoverTarget,r=this._hoveredTargets,s=this.targets,o=Math.max(r.length,s.length);this.fireSyntheticInOutEvents("drag",_(_({},e),{},{target:t,oldTarget:i,fireCanvas:!0}));for(let a=0;a<o;a++)this.fireSyntheticInOutEvents("drag",_(_({},e),{},{target:s[a],oldTarget:r[a]}));this._draggedoverTarget=t}fireSyntheticInOutEvents(t,e){let{target:i,oldTarget:r,fireCanvas:s,e:o}=e,a=gt(e,yb);const{targetIn:l,targetOut:c,canvasIn:h,canvasOut:u}=xb[t],d=r!==i;if(r&&d){const p=_(_({},a),{},{e:o,target:r,nextTarget:i},ur(this,o));s&&this.fire(u,p),r.fire(c,p)}if(i&&d){const p=_(_({},a),{},{e:o,target:i,previousTarget:r},ur(this,o));s&&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,r=i.target,s=r.group?Tr(e,void 0,r.group.calcTransformMatrix()):e;i.shiftKey=t.shiftKey,i.altKey=!!this.centeredKey&&t[this.centeredKey],this._performTransformAction(t,i,s),i.actionPerformed&&this.requestRenderAll()}_performTransformAction(t,e,i){const{action:r,actionHandler:s,target:o}=e,a=!!s&&s(t,e,i.x,i.y);a&&o.setCoords(),r==="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 r=Ui(this._activeObject)?this._activeObject:null,s=(!r||e.group!==r)&&e.findControl(this.getViewportPoint(t));if(s){const o=s.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,r=Ui(i);if(i&&this._isSelectionKeyPressed(t)&&this.selection&&e&&e.selectable&&(i!==e||r)&&(r||!e.isDescendantOf(i)&&!i.isDescendantOf(e))&&!e.onSelect({e:t})&&!i.getActiveControl()){if(r){const s=i.getObjects();if(e===i){const o=this.getViewportPoint(t);if(!(e=this.searchPossibleTargets(s,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(s,t)}else{i.isEditing&&i.exitEditing();const s=new(R.getClass("ActiveSelection"))([],{canvas:this});s.multiSelectAdd(i,e),this._hoveredTarget=s,this._setActiveObject(s,t),this._fireSelectionEvents([i],t)}return!0}return!1}handleSelection(t){if(!this.selection||!this._groupSelector)return!1;const{x:e,y:i,deltaX:r,deltaY:s}=this._groupSelector,o=new w(e,i),a=o.add(new w(r,s)),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}),u=o.eq(a)?h[0]?[h[0]]:[]:h.length>1?h.filter(d=>!d.onSelect({e:t})).reverse():h;if(u.length===1)this.setActiveObject(u[0],t);else if(u.length>1){const d=R.getClass("ActiveSelection");this.setActiveObject(new d(u,{canvas:this}),t)}return this._groupSelector=null,!0}clear(){this.textEditingManager.clear(),super.clear()}destroy(){this.removeListeners(),this.textEditingManager.dispose(),super.destroy()}}const ju={x1:0,y1:0,x2:0,y2:0},wb=_(_({},ju),{},{r1:0,r2:0}),yr=(n,t)=>isNaN(n)&&typeof t=="number"?t:n,Cb=/^(\d+\.\d+)%|(\d+)%$/;function Ru(n){return n&&Cb.test(n)}function $u(n,t){const e=typeof n=="number"?n:typeof n=="string"?parseFloat(n)/(Ru(n)?100:1):NaN;return Dr(0,yr(e,t),1)}const Sb=/\s*;\s*/,Tb=/\s*:\s*/;function Eb(n,t){let e,i;const r=n.getAttribute("style");if(r){const o=r.split(Sb);o[o.length-1]===""&&o.pop();for(let a=o.length;a--;){const[l,c]=o[a].split(Tb).map(h=>h.trim());l==="stop-color"?e=c:l==="stop-opacity"&&(i=c)}}const s=new rt(e||n.getAttribute("stop-color")||"rgb(0,0,0)");return{offset:$u(n.getAttribute("offset"),0),color:s.toRgb(),opacity:yr(parseFloat(i||n.getAttribute("stop-opacity")||""),1)*s.getAlpha()*t}}function Ob(n,t){const e=[],i=n.getElementsByTagName("stop"),r=$u(t,1);for(let s=i.length;s--;)e.push(Eb(i[s],r));return e}function Bu(n){return n.nodeName==="linearGradient"||n.nodeName==="LINEARGRADIENT"?"linear":"radial"}function Nu(n){return n.getAttribute("gradientUnits")==="userSpaceOnUse"?"pixels":"percentage"}function Oe(n,t){return n.getAttribute(t)}function kb(n,t){return function(e,i){let r,{width:s,height:o,gradientUnits:a}=i;return Object.keys(e).reduce((l,c)=>{const h=e[c];return h==="Infinity"?r=1:h==="-Infinity"?r=0:(r=typeof h=="string"?parseFloat(h):h,typeof h=="string"&&Ru(h)&&(r*=.01,a==="pixels"&&(c!=="x1"&&c!=="x2"&&c!=="r2"||(r*=s),c!=="y1"&&c!=="y2"||(r*=o)))),l[c]=r,l},{})}(Bu(n)==="linear"?function(e){return{x1:Oe(e,"x1")||0,y1:Oe(e,"y1")||0,x2:Oe(e,"x2")||"100%",y2:Oe(e,"y2")||0}}(n):function(e){return{x1:Oe(e,"fx")||Oe(e,"cx")||"50%",y1:Oe(e,"fy")||Oe(e,"cy")||"50%",r1:0,x2:Oe(e,"cx")||"50%",y2:Oe(e,"cy")||"50%",r2:Oe(e,"r")||"50%"}}(n),_(_({},t),{},{gradientUnits:Nu(n)}))}class qs{constructor(t){const{type:e="linear",gradientUnits:i="pixels",coords:r={},colorStops:s=[],offsetX:o=0,offsetY:a=0,gradientTransform:l,id:c}=t||{};Object.assign(this,{type:e,gradientUnits:i,coords:_(_({},e==="radial"?wb:ju),r),colorStops:s,offsetX:o,offsetY:a,gradientTransform:l,id:c?"".concat(c,"_").concat(Ii()):Ii()})}addColorStop(t){for(const e in t){const i=new rt(t[e]);this.colorStops.push({offset:parseFloat(e),color:i.toRgb(),opacity:i.getAlpha()})}return this}toObject(t){return _(_({},Br(this,t)),{},{type:this.type,coords:_({},this.coords),colorStops:this.colorStops.map(e=>_({},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=[],r=this.gradientTransform?this.gradientTransform.concat():ie.concat(),s=this.gradientUnits==="pixels"?"userSpaceOnUse":"objectBoundingBox",o=this.colorStops.map(u=>_({},u)).sort((u,d)=>u.offset-d.offset);let a=-this.offsetX,l=-this.offsetY;var c;s==="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),r[4]-=a,r[5]-=l;const h=['id="SVGID_'.concat(this.id,'"'),'gradientUnits="'.concat(s,'"'),'gradientTransform="'.concat(e?e+" ":"").concat(Hn(r),'"'),""].join(" ");if(this.type==="linear"){const{x1:u,y1:d,x2:p,y2:g}=this.coords;i.push("<linearGradient ",h,' x1="',u,'" y1="',d,'" x2="',p,'" y2="',g,`">
|
|
2529
|
+
`)}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=hi.ownDefaults;return this.includeDefaultValues?t:il(t,(i,s)=>i!==e[s])}static async fromObject(t){return new this(t)}}b(hi,"ownDefaults",{color:"rgb(0,0,0)",blur:0,offsetX:0,offsetY:0,affectStroke:!1,includeDefaultValues:!0,nonScaling:!1}),b(hi,"type","shadow"),R.setClass(hi,"shadow");const Ds=(n,t,e)=>Math.max(n,Math.min(t,e)),Xm=[le,it,pe,Ee,"flipX","flipY","originX","originY","angle","opacity","globalCompositeOperation","shadow","visible",Rs,$s],mi=[Rt,he,"strokeWidth","strokeDashArray","width","height","paintFirst","strokeUniform","strokeLineCap","strokeDashOffset","strokeLineJoin","strokeMiterLimit","backgroundColor","clipPath"],Km={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:it,originY:le,strokeWidth:1,strokeUniform:!1,padding:0,opacity:1,paintFirst:Rt,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},qm=(n,t,e,i)=>-e*Math.cos(n/i*jr)+e+t,Zm=()=>!1;class ol{constructor(t){let{startValue:e,byValue:i,duration:s=500,delay:r=0,easing:o=qm,onStart:a=Cn,onChange:l=Cn,onComplete:c=Cn,abort:h=Zm,target:u}=t;b(this,"_state","pending"),b(this,"durationProgress",0),b(this,"valueProgress",0),this.tick=this.tick.bind(this),this.duration=s,this.delay=r,this.easing=o,this._onStart=a,this._onChange=l,this._onComplete=c,this._abort=h,this.target=u,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(()=>Tn(t),this.delay):Tn(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:r}=this.calculate(i);this.value=Object.freeze(s),this.valueProgress=r,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),Tn(this.tick)))}register(){Bn.push(this)}unregister(){Bn.remove(this)}abort(){this._state="aborted",this.unregister()}}const Jm=["startValue","endValue"];class Qm extends ol{constructor(t){let{startValue:e=0,endValue:i=100}=t;super(_(_({},gt(t,Jm)),{},{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 tv=["startValue","endValue"];class ev extends ol{constructor(t){let{startValue:e=[0],endValue:i=[100]}=t;super(_(_({},gt(t,tv)),{},{startValue:e,byValue:i.map((s,r)=>s-e[r])}))}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 iv=["startValue","endValue","easing","onChange","onComplete","abort"],sv=(n,t,e,i)=>t+e*(1-Math.cos(n/i*jr)),zo=n=>n&&((t,e,i)=>n(new st(t).toRgba(),e,i));class rv extends ol{constructor(t){let{startValue:e,endValue:i,easing:s=sv,onChange:r,onComplete:o,abort:a}=t,l=gt(t,iv);const c=new st(e).getSource(),h=new st(i).getSource();super(_(_({},l),{},{startValue:c,byValue:h.map((u,d)=>u-c[d]),easing:s,onChange:zo(r),onComplete:zo(o),abort:zo(a)}))}calculate(t){const[e,i,s,r]=this.startValue.map((a,l)=>this.easing(t,a,this.byValue[l],this.duration,l)),o=[...[e,i,s].map(Math.round),Ds(0,r,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 xu(n){const t=(e=>Array.isArray(e.startValue)||Array.isArray(e.endValue))(n)?new ev(n):new Qm(n);return t.start(),t}function nv(n){const t=new rv(n);return t.start(),t}class ft{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 r=ma(e,i),o=ma(e,t).divide(r);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 w(t).setX(Math.min(t.x-1,...e.map(r=>r.x)));let s=0;for(let r=0;r<e.length;r++){const o=this.intersectSegmentSegment(e[r],e[(r+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 r=!(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,u=t.x-i.x,d=t.y-i.y,p=c*d-h*u,g=a*d-l*u,f=h*a-c*l;if(f!==0){const m=p/f,v=g/f;return(r||0<=m&&m<=1)&&(o||0<=v&&v<=1)?new ft("Intersection").append(new w(t.x+m*a,t.y+m*l)):new ft}if(p===0||g===0){const m=r||o||ft.isPointContained(t,i,s)||ft.isPointContained(e,i,s)||ft.isPointContained(i,t,e)||ft.isPointContained(s,t,e);return new ft(m?"Coincident":void 0)}return new ft("Parallel")}static intersectSegmentLine(t,e,i,s){return ft.intersectLineLine(t,e,i,s,!1,!0)}static intersectSegmentSegment(t,e,i,s){return ft.intersectLineLine(t,e,i,s,!1,!1)}static intersectLinePolygon(t,e,i){let s=!(arguments.length>3&&arguments[3]!==void 0)||arguments[3];const r=new ft,o=i.length;for(let a,l,c,h=0;h<o;h++){if(a=i[h],l=i[(h+1)%o],c=ft.intersectLineLine(t,e,a,l,s,!1),c.status==="Coincident")return c;r.append(...c.points)}return r.points.length>0&&(r.status="Intersection"),r}static intersectSegmentPolygon(t,e,i){return ft.intersectLinePolygon(t,e,i,!1)}static intersectPolygonPolygon(t,e){const i=new ft,s=t.length,r=[];for(let o=0;o<s;o++){const a=t[o],l=t[(o+1)%s],c=ft.intersectSegmentPolygon(a,l,e);c.status==="Coincident"?(r.push(c),i.append(a,l)):i.append(...c.points)}return r.length>0&&r.length===t.length?new ft("Coincident"):(i.points.length>0&&(i.status="Intersection"),i)}static intersectPolygonRectangle(t,e,i){const s=e.min(i),r=e.max(i),o=new w(r.x,s.y),a=new w(s.x,r.y);return ft.intersectPolygonPolygon(t,[s,o,r,a])}}class ov extends iu{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?ne(t,this.group.calcTransformMatrix()):t}setXY(t,e,i){this.group&&(t=ne(t,Ie(this.group.calcTransformMatrix()))),this.setRelativeXY(t,e,i)}getRelativeXY(){return new w(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()),r=[t,e,i,s];if(this.group){const o=this.group.calcTransformMatrix();return r.map(a=>ne(a,o))}return r}intersectsWithRect(t,e){return ft.intersectPolygonRectangle(this.getCoords(),t,e).status==="Intersection"}intersectsWithObject(t){const e=ft.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:r,height:o}=this.getBoundingRect();return i>=t.x&&i+r<=e.x&&s>=t.y&&s+o<=e.y}isOverlapping(t){return this.intersectsWithObject(t)||this.isContainedWithinObject(t)||t.isContainedWithinObject(this)}containsPoint(t){return ft.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 ci(this.getCoords())}getScaledWidth(){return this._getTransformedDimensions().x}getScaledHeight(){return this._getTransformedDimensions().y}scale(t){this._set(pe,t),this._set(Ee,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?ss(ru(this.calcTransformMatrix())):this.angle}getViewportTransform(){var t;return((t=this.canvas)===null||t===void 0?void 0:t.viewportTransform)||ie.concat()}calcACoords(){const t=$r({angle:this.angle}),{x:e,y:i}=this.getRelativeCenterPoint(),s=Rr(e,i),r=Vt(s,t),o=this._getTransformedDimensions(),a=o.x/2,l=o.y/2;return{tl:ne({x:-a,y:-l},r),tr:ne({x:a,y:-l},r),bl:ne({x:-a,y:l},r),br:ne({x:a,y:l},r)}}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,Dt(this.originX),Dt(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((r,o)=>r===i[o])?s.value:(this.group&&(e=Vt(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},r=Dm(s);return this.ownMatrixCache={key:t,value:r},r}_getNonTransformedDimensions(){return new w(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=_({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,r=0;this.strokeUniform&&(s=0,r=i);const o=e.width+s,a=e.height+s;let l;return l=e.skewX===0&&e.skewY===0?new w(o*e.scaleX,a*e.scaleY):sl(o,a,mo(e)),l.scalarAdd(r)}translateToGivenOrigin(t,e,i,s,r){let o=t.x,a=t.y;const l=Dt(s)-Dt(e),c=Dt(r)-Dt(i);if(l||c){const h=this._getTransformedDimensions();o+=l*h.x,a+=c*h.y}return new w(o,a)}translateToCenterPoint(t,e,i){if(e===K&&i===K)return t;const s=this.translateToGivenOrigin(t,e,i,K,K);return this.angle?s.rotate(kt(this.angle),t):s}translateToOriginPoint(t,e,i){const s=this.translateToGivenOrigin(t,K,K,e,i);return this.angle?s.rotate(kt(this.angle),t):s}getCenterPoint(){const t=this.getRelativeCenterPoint();return this.group?ne(t,this.group.calcTransformMatrix()):t}getRelativeCenterPoint(){return this.translateToCenterPoint(new w(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),r=this.translateToOriginPoint(s,this.originX,this.originY);this.set({left:r.x,top:r.y})}_getLeftTopCoords(){return this.translateToOriginPoint(this.getRelativeCenterPoint(),it,le)}}const av=["type"],lv=["extraParam"];let Qe=class On extends ov{static getDefaults(){return On.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(),b(this,"_cacheContext",null),Object.assign(this,On.ownDefaults),this.setOptions(t)}_createCacheCanvas(){this._cacheCanvas=Fe(),this._cacheContext=this._cacheCanvas.getContext("2d"),this._updateCacheCanvas(),this.dirty=!0}_limitCacheSize(t){const e=t.width,i=t.height,s=tt.maxCacheSideLimit,r=tt.minCacheSideLimit;if(e<=s&&i<=s&&e*i<=tt.perfLimitSizeTotal)return e<r&&(t.width=r),i<r&&(t.height=r),t;const o=e/i,[a,l]=or.limitDimsByArea(o),c=Ds(r,a,s),h=Ds(r,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:r,zoomY:o,x:a,y:l}=this._limitCacheSize(this._getCacheCanvasDimensions()),c=i!==t.width||s!==t.height,h=this.zoomX!==r||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 u=a/2,d=l/2;return this.cacheTranslationX=Math.round(t.width/2-u)+u,this.cacheTranslationY=Math.round(t.height/2-d)+d,e.translate(this.cacheTranslationX,this.cacheTranslationY),e.scale(r,o),this.zoomX=r,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 w(Math.abs(this.scaleX),Math.abs(this.scaleY));const t=Nn(this.calcTransformMatrix());return new w(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!==pe&&t!==Ee||(e=this._constrainScale(e)),t===pe&&e<0?(this.flipX=!this.flipX,e*=-1):t==="scaleY"&&e<0?(this.flipY=!this.flipY,e*=-1):t!=="shadow"||!e||e instanceof hi||(e=new hi(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:r}=this,{width:o,height:a}=this._cacheCanvas;this.drawObject(this._cacheContext,t.forClipping,{zoomX:e,zoomY:i,cacheTranslationX:s,cacheTranslationY:r,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===he&&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,r=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=r}createClipPathLayer(t,e){const i=Ye(e),s=i.getContext("2d");if(s.translate(e.cacheTranslationX,e.cacheTranslationY),s.scale(e.zoomX,e.zoomY),t._cacheCanvas=i,e.parentClipPaths.forEach(r=>{r.transform(s)}),e.parentClipPaths.push(t),t.absolutePositioned){const r=Ie(this.calcTransformMatrix());s.transform(r[0],r[1],r[2],r[3],r[4],r[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,we(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&&(we(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(),[r,,,o]=(i==null?void 0:i.viewportTransform)||ie,a=r*s,l=o*s,c=e.nonScaling?new w(1,1):this.getObjectScaling();t.shadowColor=e.color,t.shadowBlur=e.blur*tt.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(!we(e))return{offsetX:0,offsetY:0};const i=e.gradientTransform||e.patternTransform,s=-this.width/2+e.offsetX||0,r=-this.height/2+e.offsetY||0;return e.gradientUnits==="percentage"?t.transform(this.width,0,0,this.height,s,r):t.transform(1,0,0,1,s,r),i&&t.transform(i[0],i[1],i[2],i[3],i[4],i[5]),{offsetX:s,offsetY:r}}_renderPaintInOrder(t){this.paintFirst===he?(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()),r=this.getCanvasRetinaScaling(),o=s.x/this.scaleX/r,a=s.y/this.scaleY/r,l=Ye({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/r,s.zoomY/this.scaleY/r),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(r*this.scaleX/s.zoomX,r*this.scaleY/s.zoomY),t.strokeStyle=(i=c.createPattern(l,"no-repeat"))!==null&&i!==void 0?i:"")}_findCenterFromElement(){return new w(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(R.getClass("image"))(e)}toCanvasElement(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};const e=du(this),i=this.group,s=this.shadow,r=Math.abs,o=t.enableRetinaScaling?Zh():1,a=(t.multiplier||1)*o,l=t.canvasProvider||(y=>new Br(y,{enableRetinaScaling:!1,renderOnAddRemove:!1,skipOffscreen:!1}));delete this.group,t.withoutTransform&&$m(this),t.withoutShadow&&(this.shadow=null),t.viewportTransform&&Nm(this,this.getViewportTransform()),this.setCoords();const c=Fe(),h=this.getBoundingRect(),u=this.shadow,d=new w;if(u){const y=u.blur,x=u.nonScaling?new w(1,1):this.getObjectScaling();d.x=2*Math.round(r(u.offsetX)+y)*r(x.x),d.y=2*Math.round(r(u.offsetY)+y)*r(x.y)}const p=h.width+d.x,g=h.height+d.y;c.width=Math.ceil(p),c.height=Math.ceil(g);const f=l(c);t.format==="jpeg"&&(f.backgroundColor="#fff"),this.setPositionByOrigin(new w(f.width/2,f.height/2),K,K);const m=this.canvas;f._objects=[this],this.set("canvas",f),this.setCoords();const v=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(),v}toDataURL(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};return su(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:r,y:o}=this.getRelativeCenterPoint();this.originX=K,this.originY=K,this.left=r,this.top=o}if(this.set("angle",t),e){const{x:r,y:o}=this.translateToOriginPoint(this.getRelativeCenterPoint(),i,s);this.left=r,this.top=o,this.originX=i,this.originY=s}}setOnGroup(){}_setupCompositeOperation(t){this.globalCompositeOperation&&(t.globalCompositeOperation=this.globalCompositeOperation)}dispose(){Bn.cancelByTarget(this),this.off(),this._set("canvas",void 0),this._cacheCanvas&&Ge().dispose(this._cacheCanvas),this._cacheCanvas=void 0,this._cacheContext=null}animate(t,e){return Object.entries(t).reduce((i,s)=>{let[r,o]=s;return i[r]=this._animate(r,o,e),i},{})}_animate(t,e){let i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};const s=t.split("."),r=this.constructor.colorProperties.includes(s[s.length-1]),{abort:o,startValue:a,onChange:l,onComplete:c}=i,h=_(_({},i),{},{target:this,startValue:a??s.reduce((u,d)=>u[d],this),endValue:e,abort:o==null?void 0:o.bind(this),onChange:(u,d,p)=>{s.reduce((g,f,m)=>(m===s.length-1&&(g[f]=u),g[f]),this),l&&l(u,d,p)},onComplete:(u,d,p)=>{this.setCoords(),c&&c(u,d,p)}});return r?nv(h):xu(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,r=0;r<e.length;r++){if(s=e[r],s===t)return{fork:[this,...e.slice(0,r)],otherFork:[],common:e.slice(r)};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,r)],otherFork:[t,...i.slice(0,o)],common:e.slice(r)}}}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(),r=e.otherFork.pop(),o=i._objects.indexOf(s),a=i._objects.indexOf(r);return o>-1&&o>a}toObject(){const t=(arguments.length>0&&arguments[0]!==void 0?arguments[0]:[]).concat(On.customProperties,this.constructor.customProperties||[]);let e;const i=tt.NUM_FRACTION_DIGITS,{clipPath:s,fill:r,stroke:o,shadow:a,strokeDashArray:l,left:c,top:h,originX:u,originY:d,width:p,height:g,strokeWidth:f,strokeLineCap:m,strokeDashOffset:v,strokeLineJoin:y,strokeUniform:x,strokeMiterLimit:E,scaleX:O,scaleY:D,angle:C,flipX:T,flipY:F,opacity:j,visible:A,backgroundColor:k,fillRule:P,paintFirst:L,globalCompositeOperation:z,skewX:X,skewY:J}=this;s&&!s.excludeFromExport&&(e=s.toObject(t.concat("inverted","absolutePositioned")));const $=M=>mt(M,i),B=_(_({},Bs(this,t)),{},{type:this.constructor.type,version:ua,originX:u,originY:d,left:$(c),top:$(h),width:$(p),height:$(g),fill:mc(r)?r.toObject():r,stroke:mc(o)?o.toObject():o,strokeWidth:$(f),strokeDashArray:l&&l.concat(),strokeLineCap:m,strokeDashOffset:v,strokeLineJoin:y,strokeUniform:x,strokeMiterLimit:$(E),scaleX:$(O),scaleY:$(D),angle:$(C),flipX:T,flipY:F,opacity:$(j),shadow:a&&a.toObject(),visible:A,backgroundColor:k,fillRule:P,paintFirst:L,globalCompositeOperation:z,skewX:$(X),skewY:$(J)},e?{clipPath:e}:null);return this.includeDefaultValues?B:this._removeDefaultValues(B)}toDatalessObject(t){return this.toObject(t)}_removeDefaultValues(t){const e=this.constructor.getDefaults(),i=Object.keys(e).length>0?e:Object.getPrototypeOf(this);return il(t,(s,r)=>{if(r===it||r===le||r==="type")return!0;const o=i[r];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=gt(t,av),i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},{extraParam:s}=i,r=gt(i,lv);return vo(e,r).then(o=>s?(delete o[s],new this(e[s],o)):new this(o))}static fromObject(t,e){return this._fromObject(t,e)}};b(Qe,"stateProperties",Xm),b(Qe,"cacheProperties",mi),b(Qe,"ownDefaults",Km),b(Qe,"type","FabricObject"),b(Qe,"colorProperties",[Rt,he,"backgroundColor"]),b(Qe,"customProperties",[]),R.setClass(Qe),R.setClass(Qe,"object");const Ns=(n,t,e)=>(i,s,r,o)=>{const a=t(i,s,r,o);return a&&pu(n,_(_({},fu(i,s,r,o)),e)),a};function zs(n){return(t,e,i,s)=>{const{target:r,originX:o,originY:a}=e,l=r.getRelativeCenterPoint(),c=r.translateToOriginPoint(l,o,a),h=n(t,e,i,s);return r.setPositionByOrigin(c,e.originX,e.originY),h}}const Tc=Ns(yr,zs((n,t,e,i)=>{const s=rl(t,t.originX,t.originY,e,i);if(Dt(t.originX)===Dt(K)||Dt(t.originX)===Dt(Ot)&&s.x<0||Dt(t.originX)===Dt(it)&&s.x>0){const{target:r}=t,o=r.strokeWidth/(r.strokeUniform?r.scaleX:1),a=gu(t)?2:1,l=r.width,c=Math.abs(s.x*a/r.scaleX)-o;return r.set("width",Math.max(c,1)),l!==r.width}return!1}));function cv(n,t,e,i,s){i=i||{};const r=this.sizeX||i.cornerSize||s.cornerSize,o=this.sizeY||i.cornerSize||s.cornerSize,a=i.transparentCorners!==void 0?i.transparentCorners:s.transparentCorners,l=a?he:Rt,c=!a&&(i.cornerStrokeColor||s.cornerStrokeColor);let h,u=t,d=e;n.save(),n.fillStyle=i.cornerColor||s.cornerColor||"",n.strokeStyle=i.cornerStrokeColor||s.cornerStrokeColor||"",r>o?(h=r,n.scale(1,o/r),d=e*r/o):o>r?(h=o,n.scale(r/o,1),u=t*o/r):h=r,n.beginPath(),n.arc(u,d,h/2,0,jn,!1),n[l](),c&&n.stroke(),n.restore()}function hv(n,t,e,i,s){i=i||{};const r=this.sizeX||i.cornerSize||s.cornerSize,o=this.sizeY||i.cornerSize||s.cornerSize,a=i.transparentCorners!==void 0?i.transparentCorners:s.transparentCorners,l=a?he:Rt,c=!a&&(i.cornerStrokeColor||s.cornerStrokeColor),h=r/2,u=o/2;n.save(),n.fillStyle=i.cornerColor||s.cornerColor||"",n.strokeStyle=i.cornerStrokeColor||s.cornerStrokeColor||"",n.translate(t,e);const d=s.getTotalAngle();n.rotate(kt(d)),n["".concat(l,"Rect")](-h,-u,r,o),c&&n.strokeRect(-h,-u,r,o),n.restore()}class ke{constructor(t){b(this,"visible",!0),b(this,"actionName",fo),b(this,"angle",0),b(this,"x",0),b(this,"y",0),b(this,"offsetX",0),b(this,"offsetY",0),b(this,"sizeX",0),b(this,"sizeY",0),b(this,"touchSizeX",0),b(this,"touchSizeY",0),b(this,"cursorStyle","crosshair"),b(this,"withConnection",!1),Object.assign(this,t)}shouldActivate(t,e,i,s){var r;let{tl:o,tr:a,br:l,bl:c}=s;return((r=e.canvas)===null||r===void 0?void 0:r.getActiveObject())===e&&e.isControlVisible(t)&&ft.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 w(this.x*t.x+this.offsetX,this.y*t.y+this.offsetY).transform(e)}calcCornerCoords(t,e,i,s,r,o){const a=tl([Rr(i,s),$r({angle:t}),el((r?this.touchSizeX:this.sizeX)||e,(r?this.touchSizeY:this.sizeY)||e)]);return{tl:new w(-.5,-.5).transform(a),tr:new w(.5,-.5).transform(a),br:new w(.5,.5).transform(a),bl:new w(-.5,.5).transform(a)}}render(t,e,i,s,r){((s=s||{}).cornerStyle||r.cornerStyle)==="circle"?cv.call(this,t,e,i,s,r):hv.call(this,t,e,i,s,r)}}const uv=(n,t,e)=>e.lockRotation?Vn:t.cursorStyle,dv=Ns(Qh,zs((n,t,e,i)=>{let{target:s,ex:r,ey:o,theta:a,originX:l,originY:c}=t;const h=s.translateToOriginPoint(s.getRelativeCenterPoint(),l,c);if(Le(s,"lockRotation"))return!1;const u=Math.atan2(o-h.y,r-h.x),d=Math.atan2(i-h.y,e-h.x);let p=ss(d-u+a);if(s.snapAngle&&s.snapAngle>0){const f=s.snapAngle,m=s.snapThreshold||f,v=Math.ceil(p/f)*f,y=Math.floor(p/f)*f;Math.abs(p-y)<m?p=y:Math.abs(p-v)<m&&(p=v)}p<0&&(p=360+p),p%=360;const g=s.angle!==p;return s.angle=p,g}));function wu(n,t){const e=t.canvas,i=n[e.uniScaleKey];return e.uniformScaling&&!i||!e.uniformScaling&&i}function Cu(n,t,e){const i=Le(n,"lockScalingX"),s=Le(n,"lockScalingY");if(i&&s||!t&&(i||s)&&e||i&&t==="x"||s&&t==="y")return!0;const{width:r,height:o,strokeWidth:a}=n;return r===0&&a===0&&t!=="y"||o===0&&a===0&&t!=="x"}const pv=["e","se","s","sw","w","nw","n","ne","e"],tr=(n,t,e)=>{const i=wu(n,e);if(Cu(e,t.x!==0&&t.y===0?"x":t.x===0&&t.y!==0?"y":"",i))return Vn;const s=mu(e,t);return"".concat(pv[s],"-resize")};function al(n,t,e,i){let s=arguments.length>4&&arguments[4]!==void 0?arguments[4]:{};const r=t.target,o=s.by,a=wu(n,r);let l,c,h,u,d,p;if(Cu(r,o,a))return!1;if(t.gestureScale)c=t.scaleX*t.gestureScale,h=t.scaleY*t.gestureScale;else{if(l=rl(t,t.originX,t.originY,e,i),d=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=d),t.signY||(t.signY=p),Le(r,"lockScalingFlip")&&(t.signX!==d||t.signY!==p))return!1;if(u=r._getTransformedDimensions(),a&&!o){const m=Math.abs(l.x)+Math.abs(l.y),{original:v}=t,y=m/(Math.abs(u.x*v.scaleX/r.scaleX)+Math.abs(u.y*v.scaleY/r.scaleY));c=v.scaleX*y,h=v.scaleY*y}else c=Math.abs(l.x*r.scaleX/u.x),h=Math.abs(l.y*r.scaleY/u.y);gu(t)&&(c*=2,h*=2),t.signX!==d&&o!=="y"&&(t.originX=_c(t.originX),c*=-1,t.signX=d),t.signY!==p&&o!=="x"&&(t.originY=_c(t.originY),h*=-1,t.signY=p)}const g=r.scaleX,f=r.scaleY;return o?(o==="x"&&r.set(pe,c),o==="y"&&r.set(Ee,h)):(!Le(r,"lockScalingX")&&r.set(pe,c),!Le(r,"lockScalingY")&&r.set(Ee,h)),g!==r.scaleX||f!==r.scaleY}const Yr=Ns(go,zs((n,t,e,i)=>al(n,t,e,i))),gv=Ns(go,zs((n,t,e,i)=>al(n,t,e,i,{by:"x"}))),fv=Ns(go,zs((n,t,e,i)=>al(n,t,e,i,{by:"y"}))),mv=["target","ex","ey","skewingSide"],Ho={x:{counterAxis:"y",scale:pe,skew:Rs,lockSkewing:"lockSkewingX",origin:"originX",flip:"flipX"},y:{counterAxis:"x",scale:Ee,skew:$s,lockSkewing:"lockSkewingY",origin:"originY",flip:"flipY"}},vv=["ns","nesw","ew","nwse"],bv=(n,t,e)=>{if(t.x!==0&&Le(e,"lockSkewingY")||t.y!==0&&Le(e,"lockSkewingX"))return Vn;const i=mu(e,t)%4;return"".concat(vv[i],"-resize")};function Su(n,t,e,i,s){const{target:r}=e,{counterAxis:o,origin:a,lockSkewing:l,skew:c,flip:h}=Ho[n];if(Le(r,l))return!1;const{origin:u,flip:d}=Ho[o],p=Dt(e[u])*(r[d]?-1:1),g=-Math.sign(p)*(r[h]?-1:1),f=.5*-((r[c]===0&&rl(e,K,K,i,s)[n]>0||r[c]>0?1:-1)*g)+.5;return Ns(tu,zs((v,y,x,E)=>function(O,D,C){let{target:T,ex:F,ey:j,skewingSide:A}=D,k=gt(D,mv);const{skew:P}=Ho[O],L=C.subtract(new w(F,j)).divide(new w(T.scaleX,T.scaleY))[O],z=T[P],X=k[P],J=Math.tan(kt(X)),$=O==="y"?T._getTransformedDimensions({scaleX:1,scaleY:1,skewX:0}).x:T._getTransformedDimensions({scaleX:1,scaleY:1}).y,B=2*L*A/Math.max($,1)+J,M=ss(Math.atan(B));T.set(P,M);const H=z!==T[P];if(H&&O==="y"){const{skewX:Q,scaleX:Ct}=T,ot=T._getTransformedDimensions({skewY:z}),ge=T._getTransformedDimensions(),I=Q!==0?ot.x/ge.x:1;I!==1&&T.set(pe,I*Ct)}return H}(n,y,new w(x,E))))(t,_(_({},e),{},{[a]:f,skewingSide:g}),i,s)}const _v=(n,t,e,i)=>Su("x",n,t,e,i),yv=(n,t,e,i)=>Su("y",n,t,e,i);function yo(n,t){return n[t.canvas.altActionKey]}const Xr=(n,t,e)=>{const i=yo(n,e);return t.x===0?i?Rs:Ee:t.y===0?i?$s:pe:""},_s=(n,t,e)=>yo(n,e)?bv(0,t,e):tr(n,t,e),Ec=(n,t,e,i)=>yo(n,t.target)?yv(n,t,e,i):gv(n,t,e,i),Oc=(n,t,e,i)=>yo(n,t.target)?_v(n,t,e,i):fv(n,t,e,i),Tu=()=>({ml:new ke({x:-.5,y:0,cursorStyleHandler:_s,actionHandler:Ec,getActionName:Xr}),mr:new ke({x:.5,y:0,cursorStyleHandler:_s,actionHandler:Ec,getActionName:Xr}),mb:new ke({x:0,y:.5,cursorStyleHandler:_s,actionHandler:Oc,getActionName:Xr}),mt:new ke({x:0,y:-.5,cursorStyleHandler:_s,actionHandler:Oc,getActionName:Xr}),tl:new ke({x:-.5,y:-.5,cursorStyleHandler:tr,actionHandler:Yr}),tr:new ke({x:.5,y:-.5,cursorStyleHandler:tr,actionHandler:Yr}),bl:new ke({x:-.5,y:.5,cursorStyleHandler:tr,actionHandler:Yr}),br:new ke({x:.5,y:.5,cursorStyleHandler:tr,actionHandler:Yr}),mtr:new ke({x:0,y:-.5,actionHandler:dv,cursorStyleHandler:uv,offsetY:-40,withConnection:!0,actionName:Ja})}),xv=()=>({mr:new ke({x:.5,y:0,actionHandler:Tc,cursorStyleHandler:_s,actionName:yr}),ml:new ke({x:-.5,y:0,actionHandler:Tc,cursorStyleHandler:_s,actionName:yr})}),wv=()=>_(_({},Tu()),xv());class Cr extends Qe{static getDefaults(){return _(_({},super.getDefaults()),Cr.ownDefaults)}constructor(t){super(),Object.assign(this,this.constructor.createControls(),Cr.ownDefaults),this.setOptions(t)}static createControls(){return{controls:Tu()}}_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(fo))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[r,o]=i[s],a=this.controls[r];if(a.shouldActivate(r,this,t,e?o.touchCorner:o.corner))return this.__corner=r,{key:r,control:a,coord:this.oCoords[r]}}}calcOCoords(){const t=this.getViewportTransform(),e=this.getCenterPoint(),i=Rr(e.x,e.y),s=$r({angle:this.getTotalAngle()-(this.group&&this.flipX?180:0)}),r=Vt(i,s),o=Vt(t,r),a=Vt(o,[1/t[0],0,0,1/t[3],0,0]),l=this.group?Nn(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((u,d)=>{const p=u.positionHandler(c,a,this,u);h[d]=Object.assign(p,this._calcCornerCoords(u,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(kt(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=_({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,r=_({hasBorders:i,hasControls:s},e),o=this.getViewportTransform(),a=r.hasBorders,l=r.hasControls,c=Vt(o,this.calcTransformMatrix()),h=Nn(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(kt(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 r=sl(this.width,this.height,mo(e)),o=this.isStrokeAccountedForInDimensions()?Qa:(this.strokeUniform?new w().scalarAdd(this.canvas?this.canvas.getZoom():1):new w(e.scaleX,e.scaleY)).scalarMultiply(this.strokeWidth);s=r.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,r)=>{s.withConnection&&s.getVisibility(this,r)&&(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:r,cornerColor:o}=this,a=_({cornerStrokeColor:s,cornerDashArray:r,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,r=this.height+4;return e.clearRect(-s/2,-r/2,s,r),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 Eu(n,t){return t.forEach(e=>{Object.getOwnPropertyNames(e.prototype).forEach(i=>{i!=="constructor"&&Object.defineProperty(n.prototype,i,Object.getOwnPropertyDescriptor(e.prototype,i)||Object.create(null))})}),n}b(Cr,"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 Xt extends Cr{}Eu(Xt,[vu]),R.setClass(Xt),R.setClass(Xt,"object");const Cv=(n,t,e,i)=>{const s=2*(i=Math.round(i))+1,{data:r}=n.getImageData(t-i,e-i,s,s);for(let o=3;o<r.length;o+=4)if(r[o]>0)return!1;return!0};class Ou{constructor(t){this.options=t,this.strokeProjectionMagnitude=this.options.strokeWidth/2,this.scale=new w(this.options.scaleX,this.options.scaleY),this.strokeUniformScalar=this.options.strokeUniform?new w(1/this.options.scaleX,1/this.options.scaleY):new w(1,1)}createSideVector(t,e){const i=ma(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 w(t);return e.y+=e.x*Math.tan(kt(this.options.skewY)),e.x+=e.y*Math.tan(kt(this.options.skewX)),e}scaleUnitVector(t,e){return t.multiply(this.strokeUniformScalar).scalarMultiply(e)}}const Sv=new w;class Es extends Ou{static getOrthogonalRotationFactor(t,e){const i=e?ba(t,e):Gm(t);return Math.abs(i)<jr?-1:1}constructor(t,e,i,s){super(s),b(this,"AB",void 0),b(this,"AC",void 0),b(this,"alpha",void 0),b(this,"bisector",void 0),this.A=new w(t),this.B=new w(e),this.C=new w(i),this.AB=this.createSideVector(this.A,this.B),this.AC=this.createSideVector(this.A,this.C),this.alpha=ba(this.AB,this.AC),this.bisector=nl(_u(this.AB.eq(Sv)?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),r=yu(s),o=Es.getOrthogonalRotationFactor(r,this.bisector);return this.scaleUnitVector(r,i*o)}projectBevel(){const t=[];return(this.alpha%jn==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),r=this.options.strokeUniform?va(this.scaleUnitVector(this.bisector,this.options.strokeMiterLimit)):this.options.strokeMiterLimit;return va(s)/this.strokeProjectionMagnitude<=r&&t.push(this.applySkew(this.A.add(s))),t.push(...this.projectBevel()),t}projectRoundNoSkew(t,e){const i=[],s=new w(Es.getOrthogonalRotationFactor(this.bisector),Es.getOrthogonalRotationFactor(new w(this.bisector.y,this.bisector.x)));return[new w(1,0).scalarMultiply(this.strokeProjectionMagnitude).multiply(this.strokeUniformScalar).multiply(s),new w(0,1).scalarMultiply(this.strokeProjectionMagnitude).multiply(this.strokeUniformScalar).multiply(s)].forEach(r=>{wc(r,t,e)&&i.push(this.A.add(r))}),i}projectRoundWithSkew(t,e){const i=[],{skewX:s,skewY:r,scaleX:o,scaleY:a,strokeUniform:l}=this.options,c=new w(Math.tan(kt(s)),Math.tan(kt(r))),h=this.strokeProjectionMagnitude,u=l?h/a/Math.sqrt(1/a**2+1/o**2*c.y**2):h/Math.sqrt(1+c.y**2),d=new w(Math.sqrt(Math.max(h**2-u**2,0)),u),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 w(p,Math.sqrt(Math.max(h**2-p**2,0)));return[g,g.scalarMultiply(-1),d,d.scalarMultiply(-1)].map(f=>this.applySkew(l?f.multiply(this.strokeUniformScalar):f)).forEach(f=>{wc(f,t,e)&&i.push(this.applySkew(this.A).add(f))}),i}projectRound(){const t=[];t.push(...this.projectBevel());const e=this.alpha%jn==0,i=this.applySkew(this.A),s=t[e?0:2].subtract(i),r=t[e?1:0].subtract(i),o=e?this.applySkew(this.AB.scalarMultiply(-1)):this.applySkew(this.bisector.multiply(this.strokeUniformScalar).scalarMultiply(-1)),a=ar(s,o)>0,l=a?s:r,c=a?r: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 kc extends Ou{constructor(t,e,i){super(i),this.A=new w(t),this.T=new w(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(yu(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 w(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 Es(this.A,this.T,this.T,this.options).projectRound());return t}projectSquare(){const t=[];if(this.A.eq(this.T)){const e=new w(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(nl(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 Tv=function(n,t){let e=arguments.length>2&&arguments[2]!==void 0&&arguments[2];const i=[];if(n.length===0)return i;const s=n.reduce((r,o)=>(r[r.length-1].eq(o)||r.push(new w(o)),r),[new w(n[0])]);if(s.length===1)e=!0;else if(!e){const r=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(r));s.splice(o+1)}return s.forEach((r,o,a)=>{let l,c;o===0?(c=a[1],l=e?r:a[a.length-1]):o===a.length-1?(l=a[o-1],c=e?r:a[0]):(l=a[o-1],c=a[o+1]),e&&a.length===1?i.push(...new kc(r,r,t).project()):!e||o!==0&&o!==a.length-1?i.push(...new Es(r,l,c,t).project()):i.push(...new kc(r,o===0?c:l,t).project())}),i},ll=n=>{const t={};return Object.keys(n).forEach(e=>{t[e]={},Object.keys(n[e]).forEach(i=>{t[e][i]=_({},n[e][i])})}),t},Ev=n=>n.replace(/&/g,"&").replace(/"/g,""").replace(/'/g,"'").replace(/</g,"<").replace(/>/g,">"),cl=n=>{const t=[];for(let e,i=0;i<n.length;i++)(e=Ov(n,i))!==!1&&t.push(e);return t},Ov=(n,t)=>{const e=n.charCodeAt(t);if(isNaN(e))return"";if(e<55296||e>57343)return n.charAt(t);if(55296<=e&&e<=56319){if(n.length<=t+1)throw"High surrogate without following low surrogate";const s=n.charCodeAt(t+1);if(56320>s||s>57343)throw"High surrogate without following low surrogate";return n.charAt(t)+n.charAt(t+1)}if(t===0)throw"Low surrogate without preceding high surrogate";const i=n.charCodeAt(t-1);if(55296>i||i>56319)throw"Low surrogate without preceding high surrogate";return!1},hl=function(n,t){let e=arguments.length>2&&arguments[2]!==void 0&&arguments[2];return n.fill!==t.fill||n.stroke!==t.stroke||n.strokeWidth!==t.strokeWidth||n.fontSize!==t.fontSize||n.fontFamily!==t.fontFamily||n.fontWeight!==t.fontWeight||n.fontStyle!==t.fontStyle||n.textBackgroundColor!==t.textBackgroundColor||n.deltaY!==t.deltaY||e&&(n.overline!==t.overline||n.underline!==t.underline||n.linethrough!==t.linethrough)},kv=(n,t)=>{const e=t.split(`
|
|
2530
|
+
`),i=[];let s=-1,r={};n=ll(n);for(let o=0;o<e.length;o++){const a=cl(e[o]);if(n[o])for(let l=0;l<a.length;l++){s++;const c=n[o][l];c&&Object.keys(c).length>0&&(hl(r,c,!0)?i.push({start:s,end:s+1,style:c}):i[i.length-1].end++),r=c||{}}else s+=a.length,r={}}return i},Av=(n,t)=>{if(!Array.isArray(n))return ll(n);const e=t.split(Za),i={};let s=-1,r=0;for(let o=0;o<e.length;o++){const a=cl(e[o]);for(let l=0;l<a.length;l++)s++,n[r]&&n[r].start<=s&&s<n[r].end&&(i[o]=i[o]||{},i[o][l]=_({},n[r].style),s===n[r].end-1&&r++)}return i},Bi=["display","transform",Rt,"fill-opacity","fill-rule","opacity",he,"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 Ac(n,t){const e=n.nodeName,i=n.getAttribute("class"),s=n.getAttribute("id"),r="(?![a-zA-Z\\-]+)";let o;if(o=new RegExp("^"+e,"i"),t=t.replace(o,""),s&&t.length&&(o=new RegExp("#"+s+r,"i"),t=t.replace(o,"")),i&&t.length){const a=i.split(" ");for(let l=a.length;l--;)o=new RegExp("\\."+a[l]+r,"i"),t=t.replace(o,"")}return t.length===0}function Pv(n,t){let e=!0;const i=Ac(n,t.pop());return i&&t.length&&(e=function(s,r){let o,a=!0;for(;s.parentElement&&s.parentElement.nodeType===1&&r.length;)a&&(o=r.pop()),a=Ac(s=s.parentElement,o);return r.length===0}(n,t)),i&&e&&t.length===0}const Dv=n=>{var t;return(t=Um[n])!==null&&t!==void 0?t:n},Mv=new RegExp("(".concat(rs,")"),"gi"),Iv=n=>n.replace(Mv," $1 ").replace(/,/gi," ").replace(/\s+/gi," ");var Pc,Dc,Mc,Ic,Lc,Fc,jc;const ee="(".concat(rs,")"),Lv=String.raw(Pc||(Pc=$i(["(skewX)(",")"],["(skewX)\\(","\\)"])),ee),Fv=String.raw(Dc||(Dc=$i(["(skewY)(",")"],["(skewY)\\(","\\)"])),ee),jv=String.raw(Mc||(Mc=$i(["(rotate)(","(?: "," ",")?)"],["(rotate)\\(","(?: "," ",")?\\)"])),ee,ee,ee),Rv=String.raw(Ic||(Ic=$i(["(scale)(","(?: ",")?)"],["(scale)\\(","(?: ",")?\\)"])),ee,ee),$v=String.raw(Lc||(Lc=$i(["(translate)(","(?: ",")?)"],["(translate)\\(","(?: ",")?\\)"])),ee,ee),Bv=String.raw(Fc||(Fc=$i(["(matrix)("," "," "," "," "," ",")"],["(matrix)\\("," "," "," "," "," ","\\)"])),ee,ee,ee,ee,ee,ee),ul="(?:".concat(Bv,"|").concat($v,"|").concat(jv,"|").concat(Rv,"|").concat(Lv,"|").concat(Fv,")"),Nv="(?:".concat(ul,"*)"),zv=String.raw(jc||(jc=$i(["^s*(?:","?)s*$"],["^\\s*(?:","?)\\s*$"])),Nv),Hv=new RegExp(zv),Vv=new RegExp(ul),Uv=new RegExp(ul,"g");function _a(n){const t=[];if(!(n=Iv(n).replace(/\s*([()])\s*/gi,"$1"))||n&&!Hv.test(n))return[...ie];for(const e of n.matchAll(Uv)){const i=Vv.exec(e[0]);if(!i)continue;let s=ie;const r=i.filter(g=>!!g),[,o,...a]=r,[l,c,h,u,d,p]=a.map(g=>parseFloat(g));switch(o){case"translate":s=Rr(l,c);break;case Ja:s=$r({angle:l},{x:c,y:h});break;case fo:s=el(l,c);break;case Rs:s=ou(l);break;case $s:s=au(l);break;case"matrix":s=[l,c,h,u,d,p]}t.push(s)}return tl(t)}function Wv(n,t,e,i){const s=Array.isArray(t);let r,o=t;if(n!==Rt&&n!==he||t!==ce){if(n==="strokeUniform")return t==="non-scaling-stroke";if(n==="strokeDashArray")o=t===ce?null:t.replace(/,/g," ").split(/\s+/).map(parseFloat);else if(n==="transformMatrix")o=e&&e.transformMatrix?Vt(e.transformMatrix,_a(t)):_a(t);else if(n==="visible")o=t!==ce&&t!=="hidden",e&&e.visible===!1&&(o=!1);else if(n==="opacity")o=parseFloat(t),e&&e.opacity!==void 0&&(o*=e.opacity);else if(n==="textAnchor")o=t==="start"?it:t==="end"?Ot:K;else if(n==="charSpacing")r=Ss(t,i)/i*1e3;else if(n==="paintFirst"){const a=t.indexOf(Rt),l=t.indexOf(he);o=Rt,(a>-1&&l>-1&&l<a||a===-1&&l>-1)&&(o=he)}else{if(n==="href"||n==="xlink:href"||n==="font"||n==="id")return t;if(n==="imageSmoothing")return t==="optimizeQuality";r=s?t.map(Ss):Ss(t,i)}}else o="";return!s&&isNaN(r)?o:r}function Gv(n,t){const e=n.match(Vm);if(!e)return;const i=e[1],s=e[3],r=e[4],o=e[5],a=e[6];i&&(t.fontStyle=i),s&&(t.fontWeight=isNaN(parseFloat(s))?s:parseFloat(s)),r&&(t.fontSize=Ss(r)),a&&(t.fontFamily=a),o&&(t.lineHeight=o==="normal"?1:o)}function Yv(n,t){n.replace(/;\s*$/,"").split(";").forEach(e=>{if(!e)return;const[i,s]=e.split(":");t[i.trim().toLowerCase()]=s.trim()})}function Xv(n){const t={},e=n.getAttribute("style");return e&&(typeof e=="string"?Yv(e,t):function(i,s){Object.entries(i).forEach(r=>{let[o,a]=r;a!==void 0&&(s[o.toLowerCase()]=a)})}(e,t)),t}const Kv={stroke:"strokeOpacity",fill:"fillOpacity"};function vi(n,t,e){if(!n)return{};let i,s={},r=qa;n.parentNode&&xc.test(n.parentNode.nodeName)&&(s=vi(n.parentElement,t,e),s.fontSize&&(i=r=Ss(s.fontSize)));const o=_(_(_({},t.reduce((c,h)=>{const u=n.getAttribute(h);return u&&(c[h]=u),c},{})),function(c){let h=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},u={};for(const d in h)Pv(c,d.split(" "))&&(u=_(_({},u),h[d]));return u}(n,e)),Xv(n));o[No]&&n.setAttribute(No,o[No]),o[Bo]&&(i=Ss(o[Bo],r),o[Bo]="".concat(i));const a={};for(const c in o){const h=Dv(c),u=Wv(h,o[c],s,i);a[h]=u}a&&a.font&&Gv(a.font,a);const l=_(_({},s),a);return xc.test(n.nodeName)?l:function(c){const h=Xt.getDefaults();return Object.entries(Kv).forEach(u=>{let[d,p]=u;if(c[p]===void 0||c[d]==="")return;if(c[d]===void 0){if(!h[d])return;c[d]=h[d]}if(c[d].indexOf("url(")===0)return;const g=new st(c[d]);c[d]=g.setAlpha(mt(g.getAlpha()*c[p],2)).toRgba()}),c}(l)}const qv=["left","top","width","height","visible"],ku=["rx","ry"];class Ht extends Xt{static getDefaults(){return _(_({},super.getDefaults()),Ht.ownDefaults)}constructor(t){super(),Object.assign(this,Ht.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,r=-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,r),t.lineTo(s+e-o,r),l&&t.bezierCurveTo(s+e-bi*o,r,s+e,r+bi*a,s+e,r+a),t.lineTo(s+e,r+i-a),l&&t.bezierCurveTo(s+e,r+i-bi*a,s+e-bi*o,r+i,s+e-o,r+i),t.lineTo(s+o,r+i),l&&t.bezierCurveTo(s+bi*o,r+i,s,r+i-bi*a,s,r+i-a),t.lineTo(s,r+a),l&&t.bezierCurveTo(s,r+bi*a,s+bi*o,r,s+o,r),t.closePath(),this._renderPaintInOrder(t)}toObject(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[];return super.toObject([...ku,...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,`" />
|
|
2531
|
+
`)]}static async fromElement(t,e,i){const s=vi(t,this.ATTRIBUTE_NAMES,i),{left:r=0,top:o=0,width:a=0,height:l=0,visible:c=!0}=s,h=gt(s,qv);return new this(_(_(_({},e),h),{},{left:r,top:o,width:a,height:l,visible:!!(c&&a&&l)}))}}b(Ht,"type","Rect"),b(Ht,"cacheProperties",[...mi,...ku]),b(Ht,"ownDefaults",{rx:0,ry:0}),b(Ht,"ATTRIBUTE_NAMES",[...Bi,"x","y","rx","ry","width","height"]),R.setClass(Ht),R.setSVGClass(Ht);const ni="initialization",Un="added",dl="removed",Wn="imperative",Au=(n,t)=>{const{strokeUniform:e,strokeWidth:i,width:s,height:r,group:o}=t,a=o&&o!==n?bo(o.calcTransformMatrix(),n.calcTransformMatrix()):null,l=a?t.getRelativeCenterPoint().transform(a):t.getRelativeCenterPoint(),c=!t.isStrokeAccountedForInDimensions(),h=e&&c?Bm(new w(i,i),void 0,n.calcTransformMatrix()):Qa,u=!e&&c?i:0,d=sl(s+u,r+u,tl([a,t.calcOwnMatrix()],!0)).add(h).scalarDivide(2);return[l.subtract(d),l.add(d)]};class xo{calcLayoutResult(t,e){if(this.shouldPerformLayout(t))return this.calcBoundingBox(e,t)}shouldPerformLayout(t){let{type:e,prevStrategy:i,strategy:s}=t;return e===ni||e===Wn||!!i&&s!==i}shouldLayoutClipPath(t){let{type:e,target:{clipPath:i}}=t;return e!==ni&&i&&!i.absolutePositioned}getInitialSize(t,e){return e.size}calcBoundingBox(t,e){const{type:i,target:s}=e;if(i===Wn&&e.overrides)return e.overrides;if(t.length===0)return;const{left:r,top:o,width:a,height:l}=ci(t.map(u=>Au(s,u)).reduce((u,d)=>u.concat(d),[])),c=new w(a,l),h=new w(r,o).add(c.scalarDivide(2));if(i===ni){const u=this.getInitialSize(e,{size:c,center:h});return{center:h,relativeCorrection:new w(0,0),size:u}}return{center:h.transform(s.calcOwnMatrix()),size:c}}}b(xo,"type","strategy");class ya extends xo{shouldPerformLayout(t){return!0}}b(ya,"type","fit-content"),R.setClass(ya);const Zv=["strategy"],Jv=["target","strategy","bubbles","prevStrategy"],Pu="layoutManager";class Sr{constructor(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:new ya;b(this,"strategy",void 0),this.strategy=t,this._subscriptions=new Map}performLayout(t){const e=_(_({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[$n,Jh,yr,Qh,go,tu,Rn,Sm,Tm].map(s=>t.on(s,r=>this.performLayout(s===$n?{type:"object_modified",trigger:s,e:r,target:i}:{type:"object_modifying",trigger:s,e:r,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===ni||i===Un?this.subscribeTargets(t):i===dl&&this.unsubscribeTargets(t),e.fire("layout:before",{context:t}),s&&s.fire("object:layout:before",{target:e,context:t}),i===Wn&&t.deep){const r=gt(t,Zv);e.forEachObject(o=>o.layoutManager&&o.layoutManager.performLayout(_(_({},r),{},{bubbles:!1,target:o})))}}getLayoutResult(t){const{target:e,strategy:i,type:s}=t,r=i.calcLayoutResult(t,e.getObjects());if(!r)return;const o=s===ni?new w:e.getRelativeCenterPoint(),{center:a,correction:l=new w,relativeCorrection:c=new w}=r,h=o.subtract(a).add(l).transform(s===ni?ie:Ie(e.calcOwnMatrix()),!0).add(c);return{result:r,prevCenter:o,nextCenter:a,offset:h}}commitLayout(t,e){const{target:i}=t,{result:{size:s},nextCenter:r}=e;var o,a;i.set({width:s.x,height:s.y}),this.layoutObjects(t,e),t.type===ni?i.set({left:(o=t.x)!==null&&o!==void 0?o:r.x+s.x*Dt(i.originX),top:(a=t.y)!==null&&a!==void 0?a:r.y+s.y*Dt(i.originY)}):(i.setPositionByOrigin(r,K,K),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:r,prevStrategy:o}=t,a=gt(t,Jv),{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;r&&c!=null&&c.layoutManager&&((a.path||(a.path=[])).push(i),c.layoutManager.performLayout(_(_({},a),{},{target:c}))),i.set("dirty",!0)}dispose(){const{_subscriptions:t}=this;t.forEach(e=>e.forEach(i=>i())),t.clear()}toObject(){return{type:Pu,strategy:this.strategy.constructor.type}}toJSON(){return this.toObject()}}R.setClass(Sr,Pu);const Qv=["type","objects","layoutManager"];class tb extends Sr{performLayout(){}}class Ei extends eu(Xt){static getDefaults(){return _(_({},super.getDefaults()),Ei.ownDefaults)}constructor(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};super(),b(this,"_activeObjects",[]),b(this,"__objectSelectionTracker",void 0),b(this,"__objectSelectionDisposer",void 0),Object.assign(this,Ei.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 Sr,this.layoutManager.performLayout({type:ni,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),r=super.add(...s);return this._onAfterObjectsChange(Un,s),r}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 r=this._filterObjectsBeforeEnteringGroup(i),o=super.insertAt(t,...r);return this._onAfterObjectsChange(Un,r),o}remove(){const t=super.remove(...arguments);return this._onAfterObjectsChange(dl,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 r=s.indexOf(i);r>-1&&(s.splice(r,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&&Hn(t,Vt(Ie(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||(Hn(t,Vt(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=Xt.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 r=0;r<this._objects.length;r++){var s;const o=this._objects[r];(s=this.canvas)!==null&&s!==void 0&&s.preserveObjectStacking&&o.group!==this?(t.save(),t.transform(...Ie(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(_({target:this,type:Wn},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 r=s.includeDefaultValues;s.includeDefaultValues=i;const o=s[t||"toObject"](e);return s.includeDefaultValues=r,o})}toObject(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[];const e=this.layoutManager.toObject();return _(_(_({},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=Ht.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",` >
|
|
2532
|
+
`],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>
|
|
2533
|
+
`),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:r}=t,o=gt(t,Qv);return Promise.all([xr(s,e),vo(o,e)]).then(a=>{let[l,c]=a;const h=new this(l,_(_(_({},o),c),{},{layoutManager:new tb}));if(r){const u=R.getClass(r.type),d=R.getClass(r.strategy);h.layoutManager=new u(new d)}else h.layoutManager=new Sr;return h.layoutManager.subscribeTargets({type:ni,target:h,targets:h.getObjects()}),h.setCoords(),h})}}b(Ei,"type","Group"),b(Ei,"ownDefaults",{strokeWidth:0,subTargetCheck:!1,interactive:!1}),R.setClass(Ei);const eb=(n,t)=>Math.min(t.width/n.width,t.height/n.height),ib=(n,t)=>Math.max(t.width/n.width,t.height/n.height),xa="\\s*,?\\s*",Js="".concat(xa,"(").concat(rs,")"),sb="".concat(Js).concat(Js).concat(Js).concat(xa,"([01])").concat(xa,"([01])").concat(Js).concat(Js),rb={m:"l",M:"L"},nb=(n,t,e,i,s,r,o,a,l,c,h)=>{const u=pi(n),d=gi(n),p=pi(t),g=gi(t),f=e*s*p-i*r*g+o,m=i*s*p+e*r*g+a;return["C",c+l*(-e*s*d-i*r*u),h+l*(-i*s*d+e*r*u),f+l*(e*s*g+i*r*p),m+l*(i*s*g-e*r*p),f,m]},Rc=(n,t,e,i)=>{const s=Math.atan2(t,n),r=Math.atan2(i,e);return r>=s?r-s:2*Math.PI-(s-r)};function $c(n,t,e,i,s,r,o,a){let l;if(tt.cachesBoundsOfCurve&&(l=[...arguments].join(),or.boundsOfCurveCache[l]))return or.boundsOfCurveCache[l];const c=Math.sqrt,h=Math.abs,u=[],d=[[0,0],[0,0]];let p=6*n-12*e+6*s,g=-3*n+9*e-9*s+3*o,f=3*e-3*n;for(let E=0;E<2;++E){if(E>0&&(p=6*t-12*i+6*r,g=-3*t+9*i-9*r+3*a,f=3*i-3*t),h(g)<1e-12){if(h(p)<1e-12)continue;const F=-f/p;0<F&&F<1&&u.push(F);continue}const O=p*p-4*f*g;if(O<0)continue;const D=c(O),C=(-p+D)/(2*g);0<C&&C<1&&u.push(C);const T=(-p-D)/(2*g);0<T&&T<1&&u.push(T)}let m=u.length;const v=m,y=Du(n,t,e,i,s,r,o,a);for(;m--;){const{x:E,y:O}=y(u[m]);d[0][m]=E,d[1][m]=O}d[0][v]=n,d[1][v]=t,d[0][v+1]=o,d[1][v+1]=a;const x=[new w(Math.min(...d[0]),Math.min(...d[1])),new w(Math.max(...d[0]),Math.max(...d[1]))];return tt.cachesBoundsOfCurve&&(or.boundsOfCurveCache[l]=x),x}const ob=(n,t,e)=>{let[i,s,r,o,a,l,c,h]=e;const u=((d,p,g,f,m,v,y)=>{if(g===0||f===0)return[];let x=0,E=0,O=0;const D=Math.PI,C=y*Ka,T=gi(C),F=pi(C),j=.5*(-F*d-T*p),A=.5*(-F*p+T*d),k=g**2,P=f**2,L=A**2,z=j**2,X=k*P-k*L-P*z;let J=Math.abs(g),$=Math.abs(f);if(X<0){const ut=Math.sqrt(1-X/(k*P));J*=ut,$*=ut}else O=(m===v?-1:1)*Math.sqrt(X/(k*L+P*z));const B=O*J*A/$,M=-O*$*j/J,H=F*B-T*M+.5*d,Q=T*B+F*M+.5*p;let Ct=Rc(1,0,(j-B)/J,(A-M)/$),ot=Rc((j-B)/J,(A-M)/$,(-j-B)/J,(-A-M)/$);v===0&&ot>0?ot-=2*D:v===1&&ot<0&&(ot+=2*D);const ge=Math.ceil(Math.abs(ot/D*2)),I=[],et=ot/ge,Wt=8/3*Math.sin(et/4)*Math.sin(et/4)/Math.sin(et/2);let ht=Ct+et;for(let ut=0;ut<ge;ut++)I[ut]=nb(Ct,ht,F,T,J,$,H,Q,Wt,x,E),x=I[ut][5],E=I[ut][6],Ct=ht,ht+=et;return I})(c-n,h-t,s,r,a,l,o);for(let d=0,p=u.length;d<p;d++)u[d][1]+=n,u[d][2]+=t,u[d][3]+=n,u[d][4]+=t,u[d][5]+=n,u[d][6]+=t;return u},ab=n=>{let t=0,e=0,i=0,s=0;const r=[];let o,a=0,l=0;for(const c of n){const h=[...c];let u;switch(h[0]){case"l":h[1]+=t,h[2]+=e;case"L":t=h[1],e=h[2],u=["L",t,e];break;case"h":h[1]+=t;case"H":t=h[1],u=["L",t,e];break;case"v":h[1]+=e;case"V":e=h[1],u=["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],u=["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],u=["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],u=["C",a,l,h[1],h[2],t,e],a=u[3],l=u[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],u=["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],u=["Q",a,l,t,e];break;case"a":h[6]+=t,h[7]+=e;case"A":ob(t,e,h).forEach(d=>r.push(d)),t=h[6],e=h[7];break;case"z":case"Z":t=i,e=s,u=["Z"]}u?(r.push(u),o=u[0]):o=""}return r},Gn=(n,t,e,i)=>Math.sqrt((e-n)**2+(i-t)**2),Du=(n,t,e,i,s,r,o,a)=>l=>{const c=l**3,h=(p=>3*p**2*(1-p))(l),u=(p=>3*p*(1-p)**2)(l),d=(p=>(1-p)**3)(l);return new w(o*c+s*h+e*u+n*d,a*c+r*h+i*u+t*d)},Mu=n=>n**2,Iu=n=>2*n*(1-n),Lu=n=>(1-n)**2,lb=(n,t,e,i,s,r,o,a)=>l=>{const c=Mu(l),h=Iu(l),u=Lu(l),d=3*(u*(e-n)+h*(s-e)+c*(o-s)),p=3*(u*(i-t)+h*(r-i)+c*(a-r));return Math.atan2(p,d)},cb=(n,t,e,i,s,r)=>o=>{const a=Mu(o),l=Iu(o),c=Lu(o);return new w(s*a+e*l+n*c,r*a+i*l+t*c)},hb=(n,t,e,i,s,r)=>o=>{const a=1-o,l=2*(a*(e-n)+o*(s-e)),c=2*(a*(i-t)+o*(r-i));return Math.atan2(c,l)},Bc=(n,t,e)=>{let i=new w(t,e),s=0;for(let r=1;r<=100;r+=1){const o=n(r/100);s+=Gn(i.x,i.y,o.x,o.y),i=o}return s},ub=(n,t)=>{let e,i=0,s=0,r={x:n.x,y:n.y},o=_({},r),a=.01,l=0;const c=n.iterator,h=n.angleFinder;for(;s<t&&a>1e-4;)o=c(i),l=i,e=Gn(r.x,r.y,o.x,o.y),e+s>t?(i-=a,a/=2):(r=o,i+=a,s+=e);return _(_({},o),{},{angle:h(l)})},Fu=n=>{let t,e,i=0,s=0,r=0,o=0,a=0;const l=[];for(const c of n){const h={x:s,y:r,command:c[0],length:0};switch(c[0]){case"M":e=h,e.x=o=s=c[1],e.y=a=r=c[2];break;case"L":e=h,e.length=Gn(s,r,c[1],c[2]),s=c[1],r=c[2];break;case"C":t=Du(s,r,c[1],c[2],c[3],c[4],c[5],c[6]),e=h,e.iterator=t,e.angleFinder=lb(s,r,c[1],c[2],c[3],c[4],c[5],c[6]),e.length=Bc(t,s,r),s=c[5],r=c[6];break;case"Q":t=cb(s,r,c[1],c[2],c[3],c[4]),e=h,e.iterator=t,e.angleFinder=hb(s,r,c[1],c[2],c[3],c[4]),e.length=Bc(t,s,r),s=c[3],r=c[4];break;case"Z":e=h,e.destX=o,e.destY=a,e.length=Gn(s,r,o,a),s=o,r=a}i+=e.length,l.push(e)}return l.push({length:i,x:s,y:r}),l},db=function(n,t){let e=arguments.length>2&&arguments[2]!==void 0?arguments[2]:Fu(n),i=0;for(;t-e[i].length>0&&i<e.length-2;)t-=e[i].length,i++;const s=e[i],r=t/s.length,o=n[i];switch(s.command){case"M":return{x:s.x,y:s.y,angle:0};case"Z":return _(_({},new w(s.x,s.y).lerp(new w(s.destX,s.destY),r)),{},{angle:Math.atan2(s.destY-s.y,s.destX-s.x)});case"L":return _(_({},new w(s.x,s.y).lerp(new w(o[1],o[2]),r)),{},{angle:Math.atan2(o[2]-s.y,o[1]-s.x)});case"C":case"Q":return ub(s,t)}},pb=new RegExp("[mzlhvcsqta][^mzlhvcsqta]*","gi"),Nc=new RegExp(sb,"g"),gb=new RegExp(rs,"gi"),fb={m:2,l:2,h:1,v:1,c:6,s:4,q:4,t:2,a:7},mb=n=>{var t;const e=[],i=(t=n.match(pb))!==null&&t!==void 0?t:[];for(const s of i){const r=s[0];if(r==="z"||r==="Z"){e.push([r]);continue}const o=fb[r.toLowerCase()];let a=[];if(r==="a"||r==="A"){Nc.lastIndex=0;for(let l=null;l=Nc.exec(s);)a.push(...l.slice(1))}else a=s.match(gb)||[];for(let l=0;l<a.length;l+=o){const c=new Array(o),h=rb[r];c[0]=l>0&&h?h:r;for(let u=0;u<o;u++)c[u+1]=parseFloat(a[l+u]);e.push(c)}}return e},vb=(n,t)=>n.map(e=>e.map((i,s)=>s===0||t===void 0?i:mt(i,t)).join(" ")).join(" ");function wa(n,t){const e=n.style;e&&t&&(typeof t=="string"?e.cssText+=";"+t:Object.entries(t).forEach(i=>{let[s,r]=i;return e.setProperty(s,r)}))}class bb extends uu{constructor(t){let{allowTouchScrolling:e=!1,containerClass:i=""}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};super(t),b(this,"upper",void 0),b(this,"container",void 0);const{el:s}=this.lower,r=this.createUpperCanvas();this.upper={el:r,ctx:r.getContext("2d")},this.applyCanvasStyle(s,{allowTouchScrolling:e}),this.applyCanvasStyle(r,{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,r),this.container=o}createUpperCanvas(){const{el:t}=this.lower,e=Fe();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=js().createElement("div");return t.setAttribute("data-fabric","wrapper"),wa(t,{position:"relative"}),bc(t),t}applyCanvasStyle(t,e){const{styles:i,allowTouchScrolling:s}=e;wa(t,_(_({},i),{},{"touch-action":s?"manipulation":ce})),bc(t)}setDimensions(t,e){super.setDimensions(t,e);const{el:i,ctx:s}=this.upper;hu(i,s,t,e)}setCSSDimensions(t){super.setCSSDimensions(t),pa(this.upper.el,t),pa(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(),Ge().dispose(this.upper.el),delete this.upper,delete this.container}}class wo extends Br{constructor(){super(...arguments),b(this,"targets",[]),b(this,"_hoveredTargets",[]),b(this,"_objectsToRender",void 0),b(this,"_currentTransform",null),b(this,"_groupSelector",null),b(this,"contextTopDirty",!1)}static getDefaults(){return _(_({},super.getDefaults()),wo.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 bb(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,r=this.pixelFindContext;this.clearContext(r),r.save(),r.translate(-e+s,-i+s),r.transform(...this.viewportTransform);const o=t.selectionBackgroundColor;t.selectionBackgroundColor="",t.render(r),t.selectionBackgroundColor=o,r.restore();const a=Math.round(s*this.getRetinaScaling());return Cv(r,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===fo||e===pe||e===Ee||e===yr?s=this.centeredScaling||t.centeredScaling:e===Ja&&(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=Ot:["mr","tr","br"].includes(e)&&(i.x=it),["tl","mt","tr"].includes(e)?i.y=da:["bl","mb","br"].includes(e)&&(i.y=le)),i}_setupCurrentTransform(t,e,i){var s;const r=e.group?Ts(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):Hm,c=((p,g,f,m)=>{if(!g||!p)return"drag";const v=m.controls[g];return v.getActionName(f,v,m)})(i,o,t,e),h=t[this.centeredKey],u=this._shouldCenterTransform(e,c,h)?{x:K,y:K}:this._getOriginFromCorner(e,o),d={target:e,action:c,actionHandler:l,actionPerformed:!1,corner:o,scaleX:e.scaleX,scaleY:e.scaleY,skewX:e.skewX,skewY:e.skewY,offsetX:r.x-e.left,offsetY:r.y-e.top,originX:u.x,originY:u.y,ex:r.x,ey:r.y,lastX:r.x,lastY:r.y,theta:kt(e.angle),width:e.width,height:e.height,shiftKey:t.shiftKey,altKey:h,original:_(_({},du(e)),{},{originX:u.x,originY:u.y})};this._currentTransform=d,this.fire("before:transform",{e:t,transform:d})}setCursor(t){this.upperCanvasEl.style.cursor=t}_drawSelection(t){const{x:e,y:i,deltaX:s,deltaY:r}=this._groupSelector,o=new w(e,i).transform(this.viewportTransform),a=new w(e+s,i+r).transform(this.viewportTransform),l=this.selectionLineWidth/2;let c=Math.min(o.x,a.x),h=Math.min(o.y,a.y),u=Math.max(o.x,a.x),d=Math.max(o.y,a.y);this.selectionColor&&(t.fillStyle=this.selectionColor,t.fillRect(c,h,u-c,d-h)),this.selectionLineWidth&&this.selectionBorderColor&&(t.lineWidth=this.selectionLineWidth,t.strokeStyle=this.selectionBorderColor,c+=l,h+=l,u-=l,d-=l,Xt.prototype._setLineDash.call(this,t,this.selectionDashArray),t.strokeRect(c,h,u-c,d-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,ga(t))||s.length>1&&this.searchPossibleTargets([i],e))return i;if(i===this.searchPossibleTargets([i],e)){if(this.preserveObjectStacking){const r=this.targets;this.targets=[];const o=this.searchPossibleTargets(this._objects,e);return t[this.altSelectionKey]&&o&&o!==i?(this.targets=r,i):o}return i}}return this.searchPossibleTargets(this._objects,e)}_pointIsInObjectSelectionArea(t,e){let i=t.getCoords();const s=this.getZoom(),r=t.padding/s;if(r){const[o,a,l,c]=i,h=Math.atan2(a.y-o.y,a.x-o.x),u=pi(h)*r,d=gi(h)*r,p=u+d,g=u-d;i=[new w(o.x-g,o.y-p),new w(a.x+p,a.y-g),new w(l.x+g,l.y+p),new w(c.x-p,c.y+g)]}return ft.isPointInPolygon(e,i)}_checkTarget(t,e){return!!(t&&t.visible&&t.evented&&this._pointIsInObjectSelectionArea(t,Ts(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(Sn(s)&&s.subTargetCheck){const r=this._searchPossibleTargets(s._objects,e);r&&this.targets.push(r)}return s}}}searchPossibleTargets(t,e){const i=this._searchPossibleTargets(t,e);if(i&&Sn(i)&&i.interactive&&this.targets[0]){const s=this.targets;for(let r=s.length-1;r>0;r--){const o=s[r];if(!Sn(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 r=Fm(t),o=s.width||0,a=s.height||0;o&&a||(le in s&&da in s&&(a=Math.abs(s.top-s.bottom)),Ot in s&&it in s&&(o=Math.abs(s.right-s.left))),this.calcOffset(),r.x=r.x-this._offset.left,r.y=r.y-this._offset.top,e||(r=Ts(r,void 0,this.viewportTransform));const l=this.getRetinaScaling();l!==1&&(r.x/=l,r.y/=l);const c=o===0||a===0?new w(1,1):new w(i.width/o,i.height/a);return r.multiply(c)}_setDimensionsImpl(t,e){this._resetTransformEventData(),super._setDimensionsImpl(t,e),this._isCurrentlyDrawing&&this.freeDrawingBrush&&this.freeDrawingBrush._setBrushStyles(this.contextTop)}_createCacheCanvas(){this.pixelFindCanvasEl=Fe(),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 Ui(t)?t.getObjects():t?[t]:[]}_fireSelectionEvents(t,e){let i=!1,s=!1;const r=this.getActiveObjects(),o=[],a=[];t.forEach(l=>{r.includes(l)||(i=!0,l.fire("deselected",{e,target:l}),a.push(l))}),r.forEach(l=>{t.includes(l)||(i=!0,l.fire("selected",{e,target:l}),o.push(l))}),t.length>0&&r.length>0?(s=!0,i&&this.fire("selection:updated",{e,selected:o,deselected:a})):r.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,Ui(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),Ui(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($n,s))}setViewportTransform(t){super.setViewportTransform(t);const e=this._activeObject;e&&e.setCoords()}destroy(){const t=this._activeObject;Ui(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),r=super._toObject(t,e,i);return t.set(s),r}_realizeGroupTransformOnObject(t){const{group:e}=t;if(e&&Ui(e)&&this._activeObject===e){const i=Bs(t,["angle","flipX","flipY",it,pe,Ee,Rs,$s,le]);return Rm(t,e.calcOwnMatrix()),i}return{}}_setSVGObject(t,e,i){const s=this._realizeGroupTransformOnObject(e);super._setSVGObject(t,e,i),e.set(s)}}b(wo,"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 _b{constructor(t){b(this,"targets",[]),b(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),fs(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 yb=["target","oldTarget","fireCanvas","e"],fe={passive:!1},us=(n,t)=>{const e=n.getViewportPoint(t),i=n.getScenePoint(t);return{viewportPoint:e,scenePoint:i,pointer:e,absolutePointer:i}},_i=function(n){for(var t=arguments.length,e=new Array(t>1?t-1:0),i=1;i<t;i++)e[i-1]=arguments[i];return n.addEventListener(...e)},ye=function(n){for(var t=arguments.length,e=new Array(t>1?t-1:0),i=1;i<t;i++)e[i-1]=arguments[i];return n.removeEventListener(...e)},xb={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 Yn extends wo{constructor(t){super(t,arguments.length>1&&arguments[1]!==void 0?arguments[1]:{}),b(this,"_isClick",void 0),b(this,"textEditingManager",new _b(this)),["_onMouseDown","_onTouchStart","_onMouseMove","_onMouseUp","_onTouchEnd","_onResize","_onMouseWheel","_onMouseOut","_onMouseEnter","_onContextMenu","_onDoubleClick","_onDragStart","_onDragEnd","_onDragProgress","_onDragOver","_onDragEnter","_onDragLeave","_onDrop"].forEach(e=>{this[e]=this[e].bind(this)}),this.addOrRemove(_i,"add")}_getEventPrefix(){return this.enablePointerEvents?"pointer":"mouse"}addOrRemove(t,e){const i=this.upperCanvasEl,s=this._getEventPrefix();t(cu(i),"resize",this._onResize),t(i,s+"down",this._onMouseDown),t(i,"".concat(s,"move"),this._onMouseMove,fe),t(i,"".concat(s,"out"),this._onMouseOut),t(i,"".concat(s,"enter"),this._onMouseEnter),t(i,"wheel",this._onMouseWheel),t(i,"contextmenu",this._onContextMenu),t(i,"dblclick",this._onDoubleClick),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,fe)}removeListeners(){this.addOrRemove(ye,"remove");const t=this._getEventPrefix(),e=De(this.upperCanvasEl);ye(e,"".concat(t,"up"),this._onMouseUp),ye(e,"touchend",this._onTouchEnd,fe),ye(e,"".concat(t,"move"),this._onMouseMove,fe),ye(e,"touchmove",this._onMouseMove,fe),clearTimeout(this._willAddMouseDown)}_onMouseWheel(t){this.__onMouseWheel(t)}_onMouseOut(t){const e=this._hoveredTarget,i=_({e:t},us(this,t));this.fire("mouse:out",_(_({},i),{},{target:e})),this._hoveredTarget=void 0,e&&e.fire("mouseout",_({},i)),this._hoveredTargets.forEach(s=>{this.fire("mouse:out",_(_({},i),{},{target:s})),s&&s.fire("mouseout",_({},i))}),this._hoveredTargets=[]}_onMouseEnter(t){this._currentTransform||this.findTarget(t)||(this.fire("mouse:over",_({e:t},us(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 _i(this.upperCanvasEl,"drag",this._onDragProgress)}fa(t)}_renderDragEffects(t,e,i){let s=!1;const r=this._dropTarget;r&&r!==e&&r!==i&&(r.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!==ce,i=e?this._activeObject:void 0,s={e:t,target:this._dragSource,subTargets:this.targets,dragSource:this._dragSource,didDrop:e,dropTarget:i};ye(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),r=this._dragSource,o={e:t,target:i,subTargets:s,dragSource:r,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,r,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",_({e:t,target:e,subTargets:i,dragSource:this._dragSource},us(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&&fa(t),this._basicEventHandler("contextmenu",s),!1}_onDoubleClick(t){this._cacheTransformEventData(t),this._handleEvent(t,"dblclick"),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,r=this._getEventPrefix(),o=De(s);_i(o,"touchend",this._onTouchEnd,fe),e&&_i(o,"touchmove",this._onMouseMove,fe),ye(s,"".concat(r,"down"),this._onMouseDown)}_onMouseDown(t){this.__onMouseDown(t),this._resetTransformEventData();const e=this.upperCanvasEl,i=this._getEventPrefix();ye(e,"".concat(i,"move"),this._onMouseMove,fe);const s=De(e);_i(s,"".concat(i,"up"),this._onMouseUp),_i(s,"".concat(i,"move"),this._onMouseMove,fe)}_onTouchEnd(t){if(t.touches.length>0)return;this.__onMouseUp(t),this._resetTransformEventData(),delete this.mainTouchId;const e=this._getEventPrefix(),i=De(this.upperCanvasEl);ye(i,"touchend",this._onTouchEnd,fe),ye(i,"touchmove",this._onMouseMove,fe),this._willAddMouseDown&&clearTimeout(this._willAddMouseDown),this._willAddMouseDown=setTimeout(()=>{_i(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=De(this.upperCanvasEl);ye(s,"".concat(i,"up"),this._onMouseUp),ye(s,"".concat(i,"move"),this._onMouseMove,fe),_i(e,"".concat(i,"move"),this._onMouseMove,fe)}}_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,r=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=r===this._activeObject;this.handleSelection(t),c||(c=this._shouldRender(r)||!h&&r===this._activeObject)}if(r){const h=r.findControl(this.getViewportPoint(t),ga(t)),{key:u,control:d}=h||{};if(l=u,r.selectable&&r!==this._activeObject&&r.activeOn==="up")this.setActiveObject(r,t),c=!0;else if(d){const p=d.getMouseUpHandler(t,r,d);p&&(a=this.getScenePoint(t),p.call(d,t,i,a.x,a.y))}r.isMoving=!1}if(i&&(i.target!==r||i.corner!==l)){const h=i.target&&i.target.controls[i.corner],u=h&&h.getMouseUpHandler(t,i.target,h);a=a||this.getScenePoint(t),u&&u.call(h,t,i,a.x,a.y)}this._setCursorFromEvent(t,r),this._handleEvent(t,"up"),this._groupSelector=null,this._currentTransform=null,r&&(r.__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 r=0;r<s.length;r++)s[r]!==i&&s[r].fire(t,e);return e}_handleEvent(t,e){const i=this._target,s=this.targets||[],r=_(_({e:t,target:i,subTargets:s},us(this,t)),{},{transform:this._currentTransform},e==="up:before"||e==="up"?{isClick:this._isClick,currentTarget:this.findTarget(t),currentSubTargets:this.targets}:{});this.fire("mouse:".concat(e),r),i&&i.fire("mouse".concat(e),r);for(let o=0;o<s.length;o++)s[o]!==i&&s[o].fire("mouse".concat(e),r)}_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")}_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;const{button:i}=t;if(i)return(this.fireMiddleClick&&i===1||this.fireRightClick&&i===2)&&this._handleEvent(t,"down"),void this._resetTransformEventData();if(this.isDrawingMode)return void this._onMouseDownInDrawingMode(t);if(!this._isMainEvent(t)||this._currentTransform)return;let s=this._shouldRender(e),r=!1;if(this.handleMultiSelection(t,e)?(e=this._activeObject,r=!0,s=!0):this._shouldClearSelection(t,e)&&this.discardActiveObject(t),this.selection&&(!e||!e.selectable&&!e.isEditing&&e!==this._activeObject)){const o=this.getScenePoint(t);this._groupSelector={x:o.x,y:o.y,deltaY:0,deltaX:0}}if(e){const o=e===this._activeObject;e.selectable&&e.activeOn==="down"&&this.setActiveObject(e,t);const a=e.findControl(this.getViewportPoint(t),ga(t));if(e===this._activeObject&&(a||!r)){this._setupCurrentTransform(t,e,o);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)}}s&&(this._objectsToRender=void 0),this._handleEvent(t,"down"),s&&this.requestRenderAll()}_resetTransformEventData(){this._target=this._pointer=this._absolutePointer=void 0}_cacheTransformEventData(t){this._resetTransformEventData(),this._pointer=this.getViewportPoint(t),this._absolutePointer=Ts(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,r=this.targets,o=Math.max(s.length,r.length);this.fireSyntheticInOutEvents("mouse",{e:t,target:e,oldTarget:i,fireCanvas:!0});for(let a=0;a<o;a++)this.fireSyntheticInOutEvents("mouse",{e:t,target:r[a],oldTarget:s[a]});this._hoveredTarget=e,this._hoveredTargets=this.targets.concat()}_fireEnterLeaveEvents(t,e){const i=this._draggedoverTarget,s=this._hoveredTargets,r=this.targets,o=Math.max(s.length,r.length);this.fireSyntheticInOutEvents("drag",_(_({},e),{},{target:t,oldTarget:i,fireCanvas:!0}));for(let a=0;a<o;a++)this.fireSyntheticInOutEvents("drag",_(_({},e),{},{target:r[a],oldTarget:s[a]}));this._draggedoverTarget=t}fireSyntheticInOutEvents(t,e){let{target:i,oldTarget:s,fireCanvas:r,e:o}=e,a=gt(e,yb);const{targetIn:l,targetOut:c,canvasIn:h,canvasOut:u}=xb[t],d=s!==i;if(s&&d){const p=_(_({},a),{},{e:o,target:s,nextTarget:i},us(this,o));r&&this.fire(u,p),s.fire(c,p)}if(i&&d){const p=_(_({},a),{},{e:o,target:i,previousTarget:s},us(this,o));r&&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,r=s.group?Ts(e,void 0,s.group.calcTransformMatrix()):e;i.shiftKey=t.shiftKey,i.altKey=!!this.centeredKey&&t[this.centeredKey],this._performTransformAction(t,i,r),i.actionPerformed&&this.requestRenderAll()}_performTransformAction(t,e,i){const{action:s,actionHandler:r,target:o}=e,a=!!r&&r(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=Ui(this._activeObject)?this._activeObject:null,r=(!s||e.group!==s)&&e.findControl(this.getViewportPoint(t));if(r){const o=r.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=Ui(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 r=i.getObjects();if(e===i){const o=this.getViewportPoint(t);if(!(e=this.searchPossibleTargets(r,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(r,t)}else{i.isEditing&&i.exitEditing();const r=new(R.getClass("ActiveSelection"))([],{canvas:this});r.multiSelectAdd(i,e),this._hoveredTarget=r,this._setActiveObject(r,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:r}=this._groupSelector,o=new w(e,i),a=o.add(new w(s,r)),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}),u=o.eq(a)?h[0]?[h[0]]:[]:h.length>1?h.filter(d=>!d.onSelect({e:t})).reverse():h;if(u.length===1)this.setActiveObject(u[0],t);else if(u.length>1){const d=R.getClass("ActiveSelection");this.setActiveObject(new d(u,{canvas:this}),t)}return this._groupSelector=null,!0}clear(){this.textEditingManager.clear(),super.clear()}destroy(){this.removeListeners(),this.textEditingManager.dispose(),super.destroy()}}const ju={x1:0,y1:0,x2:0,y2:0},wb=_(_({},ju),{},{r1:0,r2:0}),ys=(n,t)=>isNaN(n)&&typeof t=="number"?t:n,Cb=/^(\d+\.\d+)%|(\d+)%$/;function Ru(n){return n&&Cb.test(n)}function $u(n,t){const e=typeof n=="number"?n:typeof n=="string"?parseFloat(n)/(Ru(n)?100:1):NaN;return Ds(0,ys(e,t),1)}const Sb=/\s*;\s*/,Tb=/\s*:\s*/;function Eb(n,t){let e,i;const s=n.getAttribute("style");if(s){const o=s.split(Sb);o[o.length-1]===""&&o.pop();for(let a=o.length;a--;){const[l,c]=o[a].split(Tb).map(h=>h.trim());l==="stop-color"?e=c:l==="stop-opacity"&&(i=c)}}const r=new st(e||n.getAttribute("stop-color")||"rgb(0,0,0)");return{offset:$u(n.getAttribute("offset"),0),color:r.toRgb(),opacity:ys(parseFloat(i||n.getAttribute("stop-opacity")||""),1)*r.getAlpha()*t}}function Ob(n,t){const e=[],i=n.getElementsByTagName("stop"),s=$u(t,1);for(let r=i.length;r--;)e.push(Eb(i[r],s));return e}function Bu(n){return n.nodeName==="linearGradient"||n.nodeName==="LINEARGRADIENT"?"linear":"radial"}function Nu(n){return n.getAttribute("gradientUnits")==="userSpaceOnUse"?"pixels":"percentage"}function Oe(n,t){return n.getAttribute(t)}function kb(n,t){return function(e,i){let s,{width:r,height:o,gradientUnits:a}=i;return Object.keys(e).reduce((l,c)=>{const h=e[c];return h==="Infinity"?s=1:h==="-Infinity"?s=0:(s=typeof h=="string"?parseFloat(h):h,typeof h=="string"&&Ru(h)&&(s*=.01,a==="pixels"&&(c!=="x1"&&c!=="x2"&&c!=="r2"||(s*=r),c!=="y1"&&c!=="y2"||(s*=o)))),l[c]=s,l},{})}(Bu(n)==="linear"?function(e){return{x1:Oe(e,"x1")||0,y1:Oe(e,"y1")||0,x2:Oe(e,"x2")||"100%",y2:Oe(e,"y2")||0}}(n):function(e){return{x1:Oe(e,"fx")||Oe(e,"cx")||"50%",y1:Oe(e,"fy")||Oe(e,"cy")||"50%",r1:0,x2:Oe(e,"cx")||"50%",y2:Oe(e,"cy")||"50%",r2:Oe(e,"r")||"50%"}}(n),_(_({},t),{},{gradientUnits:Nu(n)}))}class Kr{constructor(t){const{type:e="linear",gradientUnits:i="pixels",coords:s={},colorStops:r=[],offsetX:o=0,offsetY:a=0,gradientTransform:l,id:c}=t||{};Object.assign(this,{type:e,gradientUnits:i,coords:_(_({},e==="radial"?wb:ju),s),colorStops:r,offsetX:o,offsetY:a,gradientTransform:l,id:c?"".concat(c,"_").concat(Ii()):Ii()})}addColorStop(t){for(const e in t){const i=new st(t[e]);this.colorStops.push({offset:parseFloat(e),color:i.toRgb(),opacity:i.getAlpha()})}return this}toObject(t){return _(_({},Bs(this,t)),{},{type:this.type,coords:_({},this.coords),colorStops:this.colorStops.map(e=>_({},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():ie.concat(),r=this.gradientUnits==="pixels"?"userSpaceOnUse":"objectBoundingBox",o=this.colorStops.map(u=>_({},u)).sort((u,d)=>u.offset-d.offset);let a=-this.offsetX,l=-this.offsetY;var c;r==="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(r,'"'),'gradientTransform="'.concat(e?e+" ":"").concat(zn(s),'"'),""].join(" ");if(this.type==="linear"){const{x1:u,y1:d,x2:p,y2:g}=this.coords;i.push("<linearGradient ",h,' x1="',u,'" y1="',d,'" x2="',p,'" y2="',g,`">
|
|
2519
2534
|
`)}else if(this.type==="radial"){const{x1:u,y1:d,x2:p,y2:g,r1:f,r2:m}=this.coords,v=f>m;i.push("<radialGradient ",h,' cx="',v?u:p,'" cy="',v?d:g,'" r="',v?f:m,'" fx="',v?p:u,'" fy="',v?g:d,`">
|
|
2520
2535
|
`),v&&(o.reverse(),o.forEach(x=>{x.offset=1-x.offset}));const y=Math.min(f,m);if(y>0){const x=y/Math.max(f,m);o.forEach(E=>{E.offset+=x*(1-E.offset)})}}return o.forEach(u=>{let{color:d,offset:p,opacity:g}=u;i.push("<stop ",'offset="',100*p+"%",'" style="stop-color:',d,g!==void 0?";stop-opacity: "+g:";",`"/>
|
|
2521
2536
|
`)}),i.push(this.type==="linear"?"</linearGradient>":"</radialGradient>",`
|
|
2522
|
-
`),i.join("")}toLive(t){const{x1:e,y1:i,x2:
|
|
2523
|
-
`)}static async fromObject(t,e){let{type:i,source:
|
|
2524
|
-
`)]}_getOffsetTransform(){const t=tt.NUM_FRACTION_DIGITS;return" translate(".concat(mt(-this.pathOffset.x,t),", ").concat(mt(-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:
|
|
2525
|
-
`];{const{radius:e}=this,i=
|
|
2526
|
-
`]}}static async fromElement(t,e,i){const
|
|
2527
|
-
`)]}static async fromElement(t,e,i){const
|
|
2528
|
-
`)]}_render(t){t.beginPath(),t.save(),t.transform(1,0,0,this.ry/this.rx,0,0),t.arc(0,0,this.rx,0,
|
|
2529
|
-
`)]}_render(t){const e=this.points.length,i=this.pathOffset.x,
|
|
2530
|
-
`)}const zb=["textAnchor","textDecoration","dx","dy","top","left","fontSize","strokeWidth"];let Wo;class Qt extends Xu{static getDefaults(){return _(_({},super.getDefaults()),Qt.ownDefaults)}constructor(t,e){super(),b(this,"__charBounds",[]),Object.assign(this,Qt.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=Fu(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(Be)&&this.enlargeSpaces()}enlargeSpaces(){let t,e,i,r,s,o,a;for(let l=0,c=this._textLines.length;l<c;l++)if((this.textAlign===Be||l!==c-1&&!this.isEndOfWrapping(l))&&(r=0,s=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<=s.length;h++)o=this.__charBounds[l][h],this._reSpaceAndTab.test(s[h])?(o.width+=t,o.kernedWidth+=t,o.left+=r,r+=t):o.left+=r}}isEndOfWrapping(t){return t===this._textLines.length-1}missingNewlineOffset(t){return 1}get2DCursorLocation(t,e){const i=e?this._unwrappedTextLines:this._textLines;let r;for(r=0;r<i.length;r++){if(t<=i[r].length)return{lineIndex:r,charIndex:t};t-=i[r].length+this.missingNewlineOffset(r,e)}return{lineIndex:r-1,charIndex:i[r-1].length<t?i[r-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===he?(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 K:t.textBaseline="middle";break;case"ascender":t.textBaseline=le;break;case"descender":t.textBaseline=da}t.font=this._getFontDeclaration(e,i)}calcTextWidth(){let t=this.getLineWidth(0);for(let e=1,i=this._textLines.length;e<i;e++){const r=this.getLineWidth(e);r>t&&(t=r)}return t}_renderTextLine(t,e,i,r,s,o){this._renderChars(t,e,i,r,s,o)}_renderTextLinesBackground(t){if(!this.textBackgroundColor&&!this.styleHas("textBackgroundColor"))return;const e=t.fillStyle,i=this._getLeftOffset();let r=this._getTopOffset();for(let s=0,o=this._textLines.length;s<o;s++){const a=this.getHeightOfLine(s);if(!this.textBackgroundColor&&!this.styleHas("textBackgroundColor",s)){r+=a;continue}const l=this._textLines[s].length,c=this._getLineLeftOffset(s);let h,u,d=0,p=0,g=this.getValueOfPropertyAt(s,0,"textBackgroundColor");for(let f=0;f<l;f++){const m=this.__charBounds[s][f];u=this.getValueOfPropertyAt(s,f,"textBackgroundColor"),this.path?(t.save(),t.translate(m.renderLeft,m.renderTop),t.rotate(m.angle),t.fillStyle=u,u&&t.fillRect(-m.width/2,-a/this.lineHeight*(1-this._fontSizeFraction),m.width,a/this.lineHeight),t.restore()):u!==g?(h=i+c+p,this.direction==="rtl"&&(h=this.width-h-d),t.fillStyle=g,g&&t.fillRect(h,r,d,a/this.lineHeight),p=m.left,d=m.width,g=u):d+=m.kernedWidth}u&&!this.path&&(h=i+c+p,this.direction==="rtl"&&(h=this.width-h-d),t.fillStyle=u,t.fillRect(h,r,d,a/this.lineHeight)),r+=a}t.fillStyle=e,this._removeShadow(t)}_measureChar(t,e,i,r){const s=as.getFontCache(e),o=this._getFontDeclaration(e),a=i+t,l=i&&o===this._getFontDeclaration(r),c=e.fontSize/this.CACHE_FONT_SIZE;let h,u,d,p;if(i&&s[i]!==void 0&&(d=s[i]),s[t]!==void 0&&(p=h=s[t]),l&&s[a]!==void 0&&(u=s[a],p=u-d),h===void 0||d===void 0||u===void 0){const g=function(){return Wo||(Wo=Ye({width:0,height:0}).getContext("2d")),Wo}();this._setTextStyles(g,e,!0),h===void 0&&(p=h=g.measureText(t).width,s[t]=h),d===void 0&&l&&i&&(d=g.measureText(i).width,s[i]=d),l&&u===void 0&&(u=g.measureText(a).width,s[a]=u,p=u-d)}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,r=0;const s=this.pathSide===Et,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 u=a[h];i=this._getGraphemeBox(u,t,h,e),c[h]=i,r+=i.kernedWidth,e=u}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 u=o.segmentsInfo[o.segmentsInfo.length-1].length;switch(this.textAlign){case it:h=s?u-r:0;break;case K:h=(u-r)/2;break;case Et:h=s?0:u-r}h+=this.pathStartOffset*(s?-1:1);for(let d=s?l-1:0;s?d>=0:d<l;s?d--:d++)i=c[d],h>u?h%=u:h<0&&(h+=u),this._setGraphemeOnPath(h,i),h+=i.kernedWidth}return{width:r,numOfSpaces:0}}_setGraphemeOnPath(t,e){const i=t+e.kernedWidth/2,r=this.path,s=db(r.path,i,r.segmentsInfo);e.renderLeft=s.x-r.pathOffset.x,e.renderTop=s.y-r.pathOffset.y,e.angle=s.angle+(this.pathSide===Et?Math.PI:0)}_getGraphemeBox(t,e,i,r,s){const o=this.getCompleteStyleDeclaration(e,i),a=r?this.getCompleteStyleDeclaration(e,i-1):{},l=this._measureChar(t,o,r,a);let c,h=l.kernedWidth,u=l.width;this.charSpacing!==0&&(c=this._getWidthOfCharSpacing(),u+=c,h+=c);const d={width:u,left:0,height:o.fontSize,kernedWidth:h,deltaY:o.deltaY};if(i>0&&!s){const p=this.__charBounds[e][i-1];d.left=p.left+p.width+l.kernedWidth-l.width}return d}getHeightOfLine(t){if(this.__lineHeights[t])return this.__lineHeights[t];let e=this.getHeightOfChar(t,0);for(let i=1,r=this._textLines[t].length;i<r;i++)e=Math.max(this.getHeightOfChar(t,i),e);return this.__lineHeights[t]=e*this.lineHeight*this._fontSizeMult}calcTextHeight(){let t,e=0;for(let i=0,r=this._textLines.length;i<r;i++)t=this.getHeightOfLine(i),e+=i===r-1?t/this.lineHeight:t;return e}_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 r=this._getLeftOffset(),s=this._getTopOffset();for(let o=0,a=this._textLines.length;o<a;o++){const l=this.getHeightOfLine(o),c=l/this.lineHeight,h=this._getLineLeftOffset(o);this._renderTextLine(e,t,this._textLines[o],r+h,s+i+c,o),i+=l}t.restore()}_renderTextFill(t){(this.fill||this.styleHas($t))&&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,r,s,o){const a=this.getHeightOfLine(o),l=this.textAlign.includes(Be),c=this.path,h=!l&&this.charSpacing===0&&this.isEmptyStyles(o)&&!c,u=this.direction==="ltr",d=this.direction==="ltr"?1:-1,p=e.direction;let g,f,m,v,y,x="",E=0;if(e.save(),p!==this.direction&&(e.canvas.setAttribute("dir",u?"ltr":"rtl"),e.direction=u?"ltr":"rtl",e.textAlign=u?it:Et),s-=a*this._fontSizeFraction/this.lineHeight,h)return this._renderChar(t,e,o,0,i.join(""),r,s),void e.restore();for(let O=0,D=i.length-1;O<=D;O++)v=O===D||this.charSpacing||c,x+=i[O],m=this.__charBounds[o][O],E===0?(r+=d*(m.kernedWidth-m.width),E+=m.width):E+=m.kernedWidth,l&&!v&&this._reSpaceAndTab.test(i[O])&&(v=!0),v||(g=g||this.getCompleteStyleDeclaration(o,O),f=this.getCompleteStyleDeclaration(o,O+1),v=hl(g,f,!1)),v&&(c?(e.save(),e.translate(m.renderLeft,m.renderTop),e.rotate(m.angle),this._renderChar(t,e,o,O,x,-E/2,0),e.restore()):(y=r,this._renderChar(t,e,o,O,x,y,s)),x="",g=f,r+=d*E,E=0);e.restore()}_applyPatternGradientTransformText(t){const e=this.width+this.strokeWidth,i=this.height+this.strokeWidth,r=Ye({width:e,height:i}),s=r.getContext("2d");return r.width=e,r.height=i,s.beginPath(),s.moveTo(0,0),s.lineTo(e,0),s.lineTo(e,i),s.lineTo(0,i),s.closePath(),s.translate(e/2,i/2),s.fillStyle=t.toLive(s),this._applyPatternGradientTransform(s,t),s.fill(),s.createPattern(r,"no-repeat")}handleFiller(t,e,i){let r,s;return we(i)?i.gradientUnits==="percentage"||i.gradientTransform||i.patternTransform?(r=-this.width/2,s=-this.height/2,t.translate(r,s),t[e]=this._applyPatternGradientTransformText(i),{offsetX:r,offsetY:s}):(t[e]=i.toLive(t),this._applyPatternGradientTransform(t,i)):(t[e]=i,{offsetX:0,offsetY:0})}_setStrokeStyles(t,e){let{stroke:i,strokeWidth:r}=e;return t.lineWidth=r,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,r,s,o,a){const l=this._getStyleDeclaration(i,r),c=this.getCompleteStyleDeclaration(i,r),h=t==="fillText"&&c.fill,u=t==="strokeText"&&c.stroke&&c.strokeWidth;if(u||h){if(e.save(),e.font=this._getFontDeclaration(c),l.textBackgroundColor&&this._removeShadow(e),l.deltaY&&(a+=l.deltaY),h){const d=this._setFillStyles(e,c);e.fillText(s,o-d.offsetX,a-d.offsetY)}if(u){const d=this._setStrokeStyles(e,c);e.strokeText(s,o-d.offsetX,a-d.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 r=this.get2DCursorLocation(t,!0),s=this.getValueOfPropertyAt(r.lineIndex,r.charIndex,"fontSize"),o=this.getValueOfPropertyAt(r.lineIndex,r.charIndex,"deltaY"),a={fontSize:s*i.size,deltaY:o+s*i.baseline};this.setSelectionStyles(a,t,e)}_getLineLeftOffset(t){const e=this.getLineWidth(t),i=this.width-e,r=this.textAlign,s=this.direction,o=this.isEndOfWrapping(t);let a=0;return r===Be||r===hs&&!o||r===cs&&!o||r===Kn&&!o?0:(r===K&&(a=i/2),r===Et&&(a=i),r===hs&&(a=i/2),r===cs&&(a=i),s==="rtl"&&(r===Et||r===Be||r===cs?a=0:r===it||r===Kn?a=-i:r!==K&&r!==hs||(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 r;return(r=this._getStyleDeclaration(t,e)[i])!==null&&r!==void 0?r:this[i]}_renderTextDecoration(t,e){if(!this[e]&&!this.styleHas(e))return;let i=this._getTopOffset();const r=this._getLeftOffset(),s=this.path,o=this._getWidthOfCharSpacing(),a=this.offsets[e];for(let l=0,c=this._textLines.length;l<c;l++){const h=this.getHeightOfLine(l);if(!this[e]&&!this.styleHas(e,l)){i+=h;continue}const u=this._textLines[l],d=h/this.lineHeight,p=this._getLineLeftOffset(l);let g,f,m=0,v=0,y=this.getValueOfPropertyAt(l,0,e),x=this.getValueOfPropertyAt(l,0,$t);const E=i+d*(1-this._fontSizeFraction);let O=this.getHeightOfChar(l,0),D=this.getValueOfPropertyAt(l,0,"deltaY");for(let T=0,F=u.length;T<F;T++){const j=this.__charBounds[l][T];g=this.getValueOfPropertyAt(l,T,e),f=this.getValueOfPropertyAt(l,T,$t);const A=this.getHeightOfChar(l,T),k=this.getValueOfPropertyAt(l,T,"deltaY");if(s&&g&&f)t.save(),t.fillStyle=x,t.translate(j.renderLeft,j.renderTop),t.rotate(j.angle),t.fillRect(-j.kernedWidth/2,a*A+k,j.kernedWidth,this.fontSize/15),t.restore();else if((g!==y||f!==x||A!==O||k!==D)&&v>0){let P=r+p+m;this.direction==="rtl"&&(P=this.width-P-v),y&&x&&(t.fillStyle=x,t.fillRect(P,E+a*O+D,v,this.fontSize/15)),m=j.left,v=j.width,y=g,x=f,O=A,D=k}else v+=j.kernedWidth}let C=r+p+m;this.direction==="rtl"&&(C=this.width-C-v),t.fillStyle=f,g&&f&&t.fillRect(C,E+a*O+D,v-o,this.fontSize/15),i+=h}this._removeShadow(t)}_getFontDeclaration(){let{fontFamily:t=this.fontFamily,fontStyle:e=this.fontStyle,fontWeight:i=this.fontWeight,fontSize:r=this.fontSize}=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},s=arguments.length>1?arguments[1]:void 0;const o=t.includes("'")||t.includes('"')||t.includes(",")||Qt.genericFonts.includes(t.toLowerCase())?t:'"'.concat(t,'"');return[e,i,"".concat(s?this.CACHE_FONT_SIZE:r,"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 cl(t)}_splitTextIntoLines(t){const e=t.split(this._reNewline),i=new Array(e.length),r=[`
|
|
2531
|
-
`];let
|
|
2532
|
-
`]}_getSVGTextAndBg(n,t){const e=[],i=[];let r,s=n;this.backgroundColor&&i.push(...Uo(this.backgroundColor,-this.width/2,-this.height/2,this.width,this.height));for(let o=0,a=this._textLines.length;o<a;o++)r=this._getLineLeftOffset(o),this.direction==="rtl"&&(r+=this.width),(this.textBackgroundColor||this.styleHas("textBackgroundColor",o))&&this._setSVGTextLineBg(i,o,t+r,s),this._setSVGTextLineText(e,o,t+r,s),s+=this.getHeightOfLine(o);return{textSpans:e,textBgRects:i}}_createTextCharSpan(n,t,e,i){const r=this.getSvgSpanStyles(t,n!==n.trim()||!!n.match(Bb)),s=r?'style="'.concat(r,'"'):"",o=t.deltaY,a=o?' dy="'.concat(mt(o,tt.NUM_FRACTION_DIGITS),'" '):"";return'<tspan x="'.concat(mt(e,tt.NUM_FRACTION_DIGITS),'" y="').concat(mt(i,tt.NUM_FRACTION_DIGITS),'" ').concat(a).concat(s,">").concat(Ev(n),"</tspan>")}_setSVGTextLineText(n,t,e,i){const r=this.getHeightOfLine(t),s=this.textAlign.includes(Be),o=this._textLines[t];let a,l,c,h,u,d="",p=0;i+=r*(1-this._fontSizeFraction)/this.lineHeight;for(let g=0,f=o.length-1;g<=f;g++)u=g===f||this.charSpacing,d+=o[g],c=this.__charBounds[t][g],p===0?(e+=c.kernedWidth-c.width,p+=c.width):p+=c.kernedWidth,s&&!u&&this._reSpaceAndTab.test(o[g])&&(u=!0),u||(a=a||this.getCompleteStyleDeclaration(t,g),l=this.getCompleteStyleDeclaration(t,g+1),u=hl(a,l,!0)),u&&(h=this._getStyleDeclaration(t,g),n.push(this._createTextCharSpan(d,h,e,i)),d="",a=l,this.direction==="rtl"?e-=p:e+=p,p=0)}_setSVGTextLineBg(n,t,e,i){const r=this._textLines[t],s=this.getHeightOfLine(t)/this.lineHeight;let o,a=0,l=0,c=this.getValueOfPropertyAt(t,0,"textBackgroundColor");for(let h=0;h<r.length;h++){const{left:u,width:d,kernedWidth:p}=this.__charBounds[t][h];o=this.getValueOfPropertyAt(t,h,"textBackgroundColor"),o!==c?(c&&n.push(...Uo(c,e+l,i,a,s)),l=u,a=d,c=o):a+=p}o&&n.push(...Uo(c,e+l,i,a,s))}_getSVGLineTopOffset(n){let t,e=0;for(t=0;t<n;t++)e+=this.getHeightOfLine(t);const i=this.getHeightOfLine(t);return{lineTop:e,offset:(this._fontSizeMult-this._fontSizeFraction)*i/(this.lineHeight*this._fontSizeMult)}}getSvgStyles(n){return"".concat(super.getSvgStyles(n)," white-space: pre;")}getSvgSpanStyles(n,t){const{fontFamily:e,strokeWidth:i,stroke:r,fill:s,fontSize:o,fontStyle:a,fontWeight:l,deltaY:c}=n,h=this.getSvgTextDecoration(n);return[r?Cs(he,r):"",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,"; "):"",h&&"text-decoration: ".concat(h,"; "),s?Cs($t,s):"",c?"baseline-shift: ".concat(-c,"; "):"",t?"white-space: pre; ":""].join("")}getSvgTextDecoration(n){return["overline","underline","line-through"].filter(t=>n[t.replace("-","")]).join(" ")}}]),R.setClass(Qt),R.setSVGClass(Qt);class Hb{constructor(t){b(this,"target",void 0),b(this,"__mouseDownInPlace",!1),b(this,"__dragStartFired",!1),b(this,"__isDraggingOver",!1),b(this,"__dragStartSelection",void 0),b(this,"__dragImageDisposer",void 0),b(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:r,selectionEnd:s}=e;const o=this.target,a=o.canvas,l=new w(o.flipX?-1:1,o.flipY?-1:1),c=o._getCursorBoundaries(r),h=new w(c.left+c.leftOffset,c.top+c.topOffset).multiply(l).transform(o.calcTransformMatrix()),u=a.getScenePoint(t).subtract(h),d=o.getCanvasRetinaScaling(),p=o.getBoundingRect(),g=h.subtract(new w(p.left,p.top)),f=a.viewportTransform,m=g.add(u).transform(f,!0),v=o.backgroundColor,y=ll(o.styles);o.backgroundColor="";const x={stroke:"transparent",fill:"transparent",textBackgroundColor:"transparent"};o.setSelectionStyles(x,0,r),o.setSelectionStyles(x,s,o.text.length),o.dirty=!0;const E=o.toCanvasElement({enableRetinaScaling:a.enableRetinaScaling,viewportTransform:!0});o.backgroundColor=v,o.styles=y,o.dirty=!0,wa(E,{position:"fixed",left:"".concat(-E.width,"px"),border:ce,width:"".concat(E.width/d,"px"),height:"".concat(E.height/d,"px")}),this.__dragImageDisposer&&this.__dragImageDisposer(),this.__dragImageDisposer=()=>{E.remove()},De(t.target||this.target.hiddenTextarea).body.appendChild(E),(i=t.dataTransfer)===null||i===void 0||i.setDragImage(E,m.x,m.y)}onDragStart(t){this.__dragStartFired=!0;const e=this.target,i=this.isActive();if(i&&t.dataTransfer){const r=this.__dragStartSelection={selectionStart:e.selectionStart,selectionEnd:e.selectionEnd},s=e._text.slice(r.selectionStart,r.selectionEnd).join(""),o=_({text:e.text,value:s},r);t.dataTransfer.setData("text/plain",s),t.dataTransfer.setData("application/fabric",JSON.stringify({value:s,styles:e.getSelectionStyles(r.selectionStart,r.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,r=i.defaultPrevented;this.__isDraggingOver=!1,i.preventDefault();let s=(e=i.dataTransfer)===null||e===void 0?void 0:e.getData("text/plain");if(s&&!r){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=s[Math.max(0,s.length-1)],u=0;if(this.__dragStartSelection){const d=this.__dragStartSelection.selectionStart,p=this.__dragStartSelection.selectionEnd;l>d&&l<=p?l=d:l>p&&(l-=p-d),o.removeChars(d,p),delete this.__dragStartSelection}o._reNewline.test(h)&&(o._reNewline.test(o._text[l])||l===o._text.length)&&(s=s.trimEnd()),t.didDrop=!0,t.dropTarget=o,o.insertChars(s,c,l),a.setActiveObject(o),o.enterEditing(i),o.selectionStart=Math.min(l+u,o._text.length),o.selectionEnd=Math.min(o.selectionStart+s.length,o._text.length),o.hiddenTextarea.value=o.text,o._updateTextarea(),o.hiddenTextarea.focus(),o.fire($n,{index:l+u,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 r=this.target,s=this.target.canvas,{selectionStart:o,selectionEnd:a}=this.__dragStartSelection,l=((i=e.dataTransfer)===null||i===void 0?void 0:i.dropEffect)||ce;l===ce?(r.selectionStart=o,r.selectionEnd=a,r._updateTextarea(),r.hiddenTextarea.focus()):(r.clearContextTop(),l==="move"&&(r.removeChars(o,a),r.selectionStart=r.selectionEnd=o,r.hiddenTextarea&&(r.hiddenTextarea.value=r.text),r._updateTextarea(),r.fire($n,{index:o,action:"dragend"}),s.fire("text:changed",{target:r}),s.requestRenderAll()),r.exitEditing())}this.__dragImageDisposer&&this.__dragImageDisposer(),delete this.__dragImageDisposer,delete this.__dragStartSelection,this.__isDraggingOver=!1}dispose(){this._dispose&&this._dispose()}}const zc=/[ \n\.,;!\?\-]/;class Vb extends Qt{constructor(){super(...arguments),b(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:r,onComplete:s}=t;return xu({startValue:this._currentCursorOpacity,endValue:e,duration:i,delay:r,onComplete:s,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}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 r=t>0&&this._reSpace.test(i[t])&&(e===-1||!Za.test(i[t-1]))?t-1:t,s=i[r];for(;r>0&&r<i.length&&!zc.test(s);)r+=e,s=i[r];return e===-1&&zc.test(s)&&r++,r}selectWord(t){t=t||this.selectionStart;const e=this.searchWordBoundary(t,-1),i=Math.max(e,this.searchWordBoundary(t,1));this.selectionStart=e,this.selectionEnd=i,this._fireSelectionChanged(),this._updateTextarea(),this.renderCursorOrSelection()}selectLine(t){t=t||this.selectionStart;const e=this.findLineBoundaryLeft(t),i=this.findLineBoundaryRight(t);return this.selectionStart=e,this.selectionEnd=i,this._fireSelectionChanged(),this._updateTextarea(),this}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;De(e).activeElement!==e&&e.focus();const i=this.getSelectionStartFromPointer(t),r=this.selectionStart,s=this.selectionEnd;(i===this.__selectionStartOnMouseDown&&r!==s||r!==i&&s!==i)&&(i>this.__selectionStartOnMouseDown?(this.selectionStart=this.__selectionStartOnMouseDown,this.selectionEnd=i):(this.selectionStart=i,this.selectionEnd=this.__selectionStartOnMouseDown),this.selectionStart===r&&this.selectionEnd===s||(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 r=i.slice(0,t),s=this.graphemeSplit(r).length;if(t===e)return{selectionStart:s,selectionEnd:s};const o=i.slice(t,e);return{selectionStart:s,selectionEnd:s+this.graphemeSplit(o).length}}fromGraphemeToStringSelection(t,e,i){const r=i.slice(0,t).join("").length;return t===e?{selectionStart:r,selectionEnd:r}:{selectionStart:r,selectionEnd:r+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),r=i.lineIndex,s=i.charIndex,o=this.getValueOfPropertyAt(r,s,"fontSize")*this.lineHeight,a=e.leftOffset,l=this.getCanvasRetinaScaling(),c=this.canvas.upperCanvasEl,h=c.width/l,u=c.height/l,d=h-o,p=u-o,g=new w(e.left+a,e.top+e.topOffset+o).transform(this.calcTransformMatrix()).transform(this.canvas.viewportTransform).multiply(new w(c.clientWidth/h,c.clientHeight/u));return g.x<0&&(g.x=0),g.x>d&&(g.x=d),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(Bn),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:r}=this.get2DCursorLocation(t,!0),{lineIndex:s,charIndex:o}=this.get2DCursorLocation(e,!0);if(i!==s){if(this.styles[i])for(let a=r;a<this._unwrappedTextLines[i].length;a++)delete this.styles[i][a];if(this.styles[s])for(let a=o;a<this._unwrappedTextLines[s].length;a++){const l=this.styles[s][a];l&&(this.styles[i]||(this.styles[i]={}),this.styles[i][r+a-o]=l)}for(let a=i+1;a<=s;a++)delete this.styles[a];this.shiftLineStyles(s,i-s)}else if(this.styles[i]){const a=this.styles[i],l=o-r;for(let c=r;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 r in this.styles){const s=parseInt(r,10);s>t&&(this.styles[s+e]=i[s],i[s-e]||delete this.styles[s])}}insertNewlineStyleObject(t,e,i,r){const s={},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 u in this.styles[t]){const d=parseInt(u,10);d>=e&&(l=!0,s[d-e]=this.styles[t][u],a&&e===0||delete this.styles[t][u])}let h=!1;for(l&&!a&&(this.styles[t+i]=s,h=!0),(h||o>e)&&i--;i>0;)r&&r[i-1]?this.styles[t+i]={0:_({},r[i-1])}:c?this.styles[t+i]={0:_({},c)}:delete this.styles[t+i],i--;this._forceClearCache=!0}insertCharStyleObject(t,e,i,r){this.styles||(this.styles={});const s=this.styles[t],o=s?_({},s):{};i||(i=1);for(const l in o){const c=parseInt(l,10);c>=e&&(s[c+i]=o[c],o[c-i]||delete s[c])}if(this._forceClearCache=!0,r){for(;i--;)Object.keys(r[i]).length&&(this.styles[t]||(this.styles[t]={}),this.styles[t][e+i]=_({},r[i]));return}if(!s)return;const a=s[e?e-1:1];for(;a&&i--;)this.styles[t][e+i]=_({},a)}insertNewStyleBlock(t,e,i){const r=this.get2DCursorLocation(e,!0),s=[0];let o,a=0;for(let l=0;l<t.length;l++)t[l]===`
|
|
2533
|
-
`?(a++,s[a]=0):s[a]++;for(s[0]>0&&(this.insertCharStyleObject(r.lineIndex,r.charIndex,s[0],i),i=i&&i.slice(s[0]+1)),a&&this.insertNewlineStyleObject(r.lineIndex,r.charIndex+s[0],a),o=1;o<a;o++)s[o]>0?this.insertCharStyleObject(r.lineIndex+o,0,s[o],i):i&&this.styles[r.lineIndex+o]&&i[0]&&(this.styles[r.lineIndex+o][0]=i[0]),i=i&&i.slice(s[o]+1);s[o]>0&&this.insertCharStyleObject(r.lineIndex+o,0,s[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 r=arguments.length>3&&arguments[3]!==void 0?arguments[3]:i;r>i&&this.removeStyleFromTo(i,r);const s=this.graphemeSplit(t);this.insertNewStyleBlock(s,i,e),this._text=[...this._text.slice(0,i),...s,...this._text.slice(r)],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=it:this._selectionDirection===Et&&(this._selectionDirection=it,this.selectionEnd=t),this.selectionStart=i):i>t&&i<e?this._selectionDirection===Et?this.selectionEnd=i:this.selectionStart=i:(e===t?this._selectionDirection=Et:this._selectionDirection===it&&(this._selectionDirection=Et,this.selectionStart=e),this.selectionEnd=i)}}class Ub extends Vb{initHiddenTextarea(){const t=this.canvas&&De(this.canvas.getElement())||jr(),e=t.createElement("textarea");Object.entries({autocapitalize:"off",autocorrect:"off",autocomplete:"off",spellcheck:"false","data-fabric":"textarea",wrap:"off"}).map(o=>{let[a,l]=o;return e.setAttribute(a,l)});const{top:i,left:r,fontSize:s}=this._calcTextareaPosition();e.style.cssText="position: absolute; top: ".concat(i,"; left: ").concat(r,"; z-index: -999; opacity: 0; width: 1px; height: 1px; font-size: 1px; padding-top: ").concat(s,";"),(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;if(this.fromPaste=!1,t&&t.stopPropagation(),!this.isEditing)return;const i=()=>{this.updateFromTextArea(),this.fire($n),this.canvas&&(this.canvas.fire("text:changed",{target:this}),this.canvas.requestRenderAll())};if(this.hiddenTextarea.value==="")return this.styles={},void i();const r=this._splitTextIntoLines(this.hiddenTextarea.value).graphemeText,s=this._text.length,o=r.length,a=this.selectionStart,l=this.selectionEnd,c=a!==l;let h,u,d,p,g=o-s;const f=this.fromStringToGraphemeSelection(this.hiddenTextarea.selectionStart,this.hiddenTextarea.selectionEnd,this.hiddenTextarea.value),m=a>f.selectionStart;c?(u=this._text.slice(a,l),g+=l-a):o<s&&(u=m?this._text.slice(l+g,l):this._text.slice(a,a-g));const v=r.slice(f.selectionEnd-g,f.selectionEnd);if(u&&u.length&&(v.length&&(h=this.getSelectionStyles(a,a+1,!1),h=v.map(()=>h[0])),c?(d=a,p=l):m?(d=l-u.length,p=l):(d=l,p=l+u.length),this.removeStyleFromTo(d,p)),v.length){const{copyPasteData:y}=Ge();e&&v.join("")===y.copiedText&&!tt.disableStyleCopyPaste&&(h=y.copiedTextStyle),this.insertNewStyleBlock(v,a,h)}i()}onCompositionStart(){this.inCompositionMode=!0}onCompositionEnd(){this.inCompositionMode=!1}onCompositionUpdate(t){let{target:e}=t;const{selectionStart:i,selectionEnd:r}=e;this.compositionStart=i,this.compositionEnd=r,this.updateTextareaPosition()}copy(){if(this.selectionStart===this.selectionEnd)return;const{copyPasteData:t}=Ge();t.copiedText=this.getSelectedText(),tt.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,r=this._getLineLeftOffset(t);return e>0&&(i=this.__charBounds[t][e-1],r+=i.left+i.width),r}getDownCursorOffset(t,e){const i=this._getSelectionForOffset(t,e),r=this.get2DCursorLocation(i),s=r.lineIndex;if(s===this._textLines.length-1||t.metaKey||t.keyCode===34)return this._text.length-i;const o=r.charIndex,a=this._getWidthBeforeCursor(s,o),l=this._getIndexOnLine(s+1,a);return this._textLines[s].slice(o).length+l+1+this.missingNewlineOffset(s)}_getSelectionForOffset(t,e){return t.shiftKey&&this.selectionStart!==this.selectionEnd&&e?this.selectionEnd:this.selectionStart}getUpCursorOffset(t,e){const i=this._getSelectionForOffset(t,e),r=this.get2DCursorLocation(i),s=r.lineIndex;if(s===0||t.metaKey||t.keyCode===33)return-i;const o=r.charIndex,a=this._getWidthBeforeCursor(s,o),l=this._getIndexOnLine(s-1,a),c=this._textLines[s].slice(0,o),h=this.missingNewlineOffset(s-1);return-this._textLines[s-1].length+l-c.length+(1-h)}_getIndexOnLine(t,e){const i=this._textLines[t];let r,s,o=this._getLineLeftOffset(t),a=0;for(let l=0,c=i.length;l<c;l++)if(r=this.__charBounds[t][l].width,o+=r,o>e){s=!0;const h=o-r,u=o,d=Math.abs(h-e);a=Math.abs(u-e)<d?l:l-1;break}return s||(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===Et);if(e.shiftKey?this.moveCursorWithShift(i):this.moveCursorWithoutShift(i),i!==0){const r=this.text.length;this.selectionStart=Dr(0,this.selectionStart,r),this.selectionEnd=Dr(0,this.selectionEnd,r),this.abortCursorAnimation(),this.initDelayedCursor(),this._fireSelectionChanged(),this._updateTextarea()}}moveCursorWithShift(t){const e=this._selectionDirection===it?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 r;if(t.altKey)r=this["findWordBoundary".concat(i)](this[e]);else{if(!t.metaKey&&t.keyCode!==35&&t.keyCode!==36)return this[e]+=i==="Left"?-1:1,!0;r=this["findLineBoundary".concat(i)](this[e])}return r!==void 0&&this[e]!==r&&(this[e]=r,!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=it,this.selectionEnd===this.selectionStart&&this.selectionStart!==0&&(e=this._moveLeft(t,"selectionStart")),this.selectionEnd=this.selectionStart,e}moveCursorLeftWithShift(t){return this._selectionDirection===Et&&this.selectionStart!==this.selectionEnd?this._moveLeft(t,"selectionEnd"):this.selectionStart!==0?(this._selectionDirection=it,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===it&&this.selectionStart!==this.selectionEnd?this._moveRight(t,"selectionStart"):this.selectionEnd!==this._text.length?(this._selectionDirection=Et,this._moveRight(t,"selectionEnd")):void 0}moveCursorRightWithoutShift(t){let e=!0;return this._selectionDirection=Et,this.selectionStart===this.selectionEnd?(e=this._moveRight(t,"selectionStart"),this.selectionEnd=this.selectionStart):this.selectionStart=this.selectionEnd,e}}const Go=n=>!!n.button;class Wb extends Ub{constructor(){super(...arguments),b(this,"draggableTextDelegate",void 0)}initBehavior(){this.on("mousedown",this._mouseDownHandler),this.on("mousedown:before",this._mouseDownHandlerBefore),this.on("mouseup",this.mouseUpHandler),this.on("mousedblclick",this.doubleClickHandler),this.on("tripleclick",this.tripleClickHandler),this.__lastClickTime=+new Date,this.__lastLastClickTime=+new Date,this.__lastPointer={},this.on("mousedown",this.onMouseDown),this.draggableTextDelegate=new Hb(this),super.initBehavior()}shouldStartDragging(){return this.draggableTextDelegate.isActive()}onDragStart(t){return this.draggableTextDelegate.onDragStart(t)}canDrop(t){return this.draggableTextDelegate.canDrop(t)}onMouseDown(t){if(!this.canvas)return;this.__newClickTime=+new Date;const e=t.pointer;this.isTripleClick(e)&&(this.fire("tripleclick",t),fa(t.e)),this.__lastLastClickTime=this.__lastClickTime,this.__lastClickTime=this.__newClickTime,this.__lastPointer=e,this.__lastSelected=this.selected&&!this.getActiveControl()}isTripleClick(t){return this.__newClickTime-this.__lastClickTime<500&&this.__lastClickTime-this.__lastLastClickTime<500&&this.__lastPointer.x===t.x&&this.__lastPointer.y===t.y}doubleClickHandler(t){this.isEditing&&this.selectWord(this.getSelectionStartFromPointer(t.e))}tripleClickHandler(t){this.isEditing&&this.selectLine(this.getSelectionStartFromPointer(t.e))}_mouseDownHandler(t){let{e}=t;this.canvas&&this.editable&&!Go(e)&&!this.getActiveControl()&&(this.draggableTextDelegate.start(e)||(this.canvas.textEditingManager.register(this),this.selected&&(this.inCompositionMode=!1,this.setCursorByClick(e)),this.isEditing&&(this.__selectionStartOnMouseDown=this.selectionStart,this.selectionStart===this.selectionEnd&&this.abortCursorAnimation(),this.renderCursorOrSelection())))}_mouseDownHandlerBefore(t){let{e}=t;this.canvas&&this.editable&&!Go(e)&&(this.selected=this===this.canvas._activeObject)}mouseUpHandler(t){let{e,transform:i}=t;const r=this.draggableTextDelegate.end(e);if(this.canvas){this.canvas.textEditingManager.unregister(this);const s=this.canvas._activeObject;if(s&&s!==this)return}!this.editable||this.group&&!this.group.interactive||i&&i.actionPerformed||Go(e)||r||(this.__lastSelected&&!this.getActiveControl()?(this.selected=!1,this.__lastSelected=!1,this.enterEditing(e),this.selectionStart===this.selectionEnd?this.initDelayedCursor(!0):this.renderCursorOrSelection()):this.selected=!0)}setCursorByClick(t){const e=this.getSelectionStartFromPointer(t),i=this.selectionStart,r=this.selectionEnd;t.shiftKey?this.setSelectionStartEndWithShift(i,r,e):(this.selectionStart=e,this.selectionEnd=e),this.isEditing&&(this._fireSelectionChanged(),this._updateTextarea())}getSelectionStartFromPointer(t){const e=this.canvas.getScenePoint(t).transform(Ie(this.calcTransformMatrix())).add(new w(-this._getLeftOffset(),-this._getTopOffset()));let i=0,r=0,s=0;for(let c=0;c<this._textLines.length&&i<=e.y;c++)i+=this.getHeightOfLine(c),s=c,c>0&&(r+=this._textLines[c-1].length+this.missingNewlineOffset(c-1));let o=Math.abs(this._getLineLeftOffset(s));const a=this._textLines[s].length,l=this.__charBounds[s];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)&&r++;break}o=h,r++}return Math.min(this.flipX?a-r:r,this._text.length)}}const Js="moveCursorUp",Qs="moveCursorDown",tn="moveCursorLeft",en="moveCursorRight",rn="exitEditing",Gb=_({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:rn,27:rn,33:Js,34:Qs,35:en,36:tn,37:tn,38:Js,39:en,40:Qs},keysMapRtl:{9:rn,27:rn,33:Js,34:Qs,35:tn,36:en,37:en,38:Js,39:tn,40:Qs},ctrlKeysMapDown:{65:"selectAll"},ctrlKeysMapUp:{67:"copy",88:"cut"}},{_selectionDirection:null,_reSpace:/\s|\r?\n/,inCompositionMode:!1});class oi extends Wb{static getDefaults(){return _(_({},super.getDefaults()),oi.ownDefaults)}get type(){const t=super.type;return t==="itext"?"i-text":t}constructor(t,e){super(t,_(_({},oi.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 Xn&&this.canvas.textEditingManager.remove(this),e instanceof Xn&&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)return;const t=this.clearContextTop(!0);if(!t)return;const e=this._getCursorBoundaries();this.selectionStart!==this.selectionEnd||this.inCompositionMode?this.renderSelection(t,e):this.renderCursor(t,e),this.canvas.contextTopDirty=!0,t.restore()}_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(),r=this._getTopOffset(),s=this._getCursorBoundariesOffsets(t,e);return{left:i,top:r,leftOffset:s.left,topOffset:s.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:r,lineIndex:s}=this.get2DCursorLocation(t);for(let c=0;c<s;c++)e+=this.getHeightOfLine(c);const o=this._getLineLeftOffset(s),a=this.__charBounds[s][r];a&&(i=a.left),this.charSpacing!==0&&r===this._textLines[s].length&&(i-=this._getWidthOfCharSpacing());const l={top:e,left:o+(i>0?i:0)};return this.direction==="rtl"&&(this.textAlign===Et||this.textAlign===Be||this.textAlign===cs?l.left*=-1:this.textAlign===it||this.textAlign===Kn?l.left=o-(i>0?i:0):this.textAlign!==K&&this.textAlign!==hs||(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),r=i.lineIndex,s=i.charIndex>0?i.charIndex-1:0,o=this.getValueOfPropertyAt(r,s,"fontSize"),a=this.getObjectScaling().x*this.canvas.getZoom(),l=this.cursorWidth/a,c=this.getValueOfPropertyAt(r,s,"deltaY"),h=e.topOffset+(1-this._fontSizeFraction)*this.getHeightOfLine(r)/this.lineHeight-o*(1-this._fontSizeFraction);return{color:this.cursorColor||this.getValueOfPropertyAt(r,s,"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:r,opacity:s,left:o,top:a,width:l,height:c}=this.getCursorRenderingData(i,e);t.fillStyle=r,t.globalAlpha=s,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 r=e.selectionStart,s=e.selectionEnd,o=this.textAlign.includes(Be),a=this.get2DCursorLocation(r),l=this.get2DCursorLocation(s),c=a.lineIndex,h=l.lineIndex,u=a.charIndex<0?0:a.charIndex,d=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,v=0,y=0;if(p===c&&(v=this.__charBounds[c][u].left),p>=c&&p<h)y=o&&!this.isEndOfWrapping(p)?this.width:this.getLineWidth(p)||5;else if(p===h)if(d===0)y=this.__charBounds[h][d].left;else{const C=this._getWidthOfCharSpacing();y=this.__charBounds[h][d-1].left+this.__charBounds[h][d-1].width-C}m=f,(this.lineHeight<1||p===h&&this.lineHeight>1)&&(f/=this.lineHeight);let x=i.left+g+v,E=f,O=0;const D=y-v;this.inCompositionMode?(t.fillStyle=this.compositionColor||"black",E=1,O=f):t.fillStyle=this.selectionColor,this.direction==="rtl"&&(this.textAlign===Et||this.textAlign===Be||this.textAlign===cs?x=this.width-x-D:this.textAlign===it||this.textAlign===Kn?x=i.left+g-y:this.textAlign!==K&&this.textAlign!==hs||(x=i.left+g-y)),t.fillRect(x,i.top+i.topOffset+O,D,E),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,$t)}_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()}}b(oi,"ownDefaults",Gb),b(oi,"type","IText"),R.setClass(oi),R.setClass(oi,"i-text");class Si extends oi{static getDefaults(){return _(_({},super.getDefaults()),Si.ownDefaults)}constructor(t,e){super(t,_(_({},Si.ownDefaults),e))}static createControls(){return{controls:wv()}}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(Be)&&this.enlargeSpaces(),this.height=this.calcTextHeight())}_generateStyleMap(t){let e=0,i=0,r=0;const s={};for(let o=0;o<t.graphemeLines.length;o++)t.graphemeText[r]===`
|
|
2534
|
-
`&&o>0?(i=0,r++,e++):!this.splitByGrapheme&&this._reSpaceAndTab.test(t.graphemeText[r])&&o>0&&(i++,r++),s[o]={line:e,offset:i},r+=t.graphemeLines[o].length,i+=t.graphemeLines[o].length;return s}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,r=t+1,s=!1;const o=this._styleMap[t],a=this._styleMap[t+1];o&&(t=o.line,i=o.offset),a&&(r=a.line,s=r===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 u=parseInt(h,10);if(u>=i&&(!s||u<e))for(const d 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 r=this._styleMap[t];super._setStyleDeclaration(r.line,r.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),r=[];for(let s=0;s<i.wordsData.length;s++)r.push(...this._wrapLine(s,e,i));return this.isWrapping=!1,r}getGraphemeDataForRender(t){const e=this.splitByGrapheme,i=e?"":" ";let r=0;return{wordsData:t.map((s,o)=>{let a=0;const l=e?this.graphemeSplit(s):this.wordSplit(s);return l.length===0?[{word:[],width:0}]:l.map(c=>{const h=e?[c]:this.graphemeSplit(c),u=this._measureWord(h,o,a);return r=Math.max(u,r),a+=h.length+i.length,{word:h,width:u}})}),largestWordWidth:r}}_measureWord(t,e){let i,r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:0,s=0;for(let o=0,a=t.length;o<a;o++)s+=this._getGraphemeBox(t[o],e,o+r,i,!0).kernedWidth,i=t[o];return s}wordSplit(t){return t.split(this._wordJoiners)}_wrapLine(t,e,i){let{largestWordWidth:r,wordsData:s}=i,o=arguments.length>3&&arguments[3]!==void 0?arguments[3]:0;const a=this._getWidthOfCharSpacing(),l=this.splitByGrapheme,c=[],h=l?"":" ";let u=0,d=[],p=0,g=0,f=!0;e-=o;const m=Math.max(e,r,this.dynamicMinWidth),v=s[t];let y;for(p=0,y=0;y<v.length;y++){const{word:x,width:E}=v[y];p+=x.length,u+=g+E-a,u>m&&!f?(c.push(d),d=[],u=E,f=!0):u+=a,f||l||d.push(h),d=d.concat(x),g=l?0:this._measureWord([h],t,p),p++,f=!1}return y&&c.push(d),r+o>this.dynamicMinWidth&&(this.dynamicMinWidth=r-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),r=new Array(i.length);for(let s=0;s<i.length;s++)r[s]=i[s].join("");return e.lines=r,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 r=this._styleMap[e].line;t.set("".concat(r),!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])}}b(Si,"type","Textbox"),b(Si,"textLayoutProperties",[...oi.textLayoutProperties,"width"]),b(Si,"ownDefaults",{minWidth:20,dynamicMinWidth:2,lockScalingFlip:!0,noScaleCache:!1,_wordJoiners:/[ \t\r]/,splitByGrapheme:!1}),R.setClass(Si);class Hc extends wo{shouldPerformLayout(t){return!!t.target.clipPath&&super.shouldPerformLayout(t)}shouldLayoutClipPath(){return!1}calcLayoutResult(t,e){const{target:i}=t,{clipPath:r,group:s}=i;if(!r||!this.shouldPerformLayout(t))return;const{width:o,height:a}=li(Au(i,r)),l=new w(o,a);if(r.absolutePositioned)return{center:Tr(r.getRelativeCenterPoint(),void 0,s?s.calcTransformMatrix():void 0),size:l};{const c=r.getRelativeCenterPoint().transform(i.calcOwnMatrix(),!0);if(this.shouldPerformLayout(t)){const{center:h=new w,correction:u=new w}=this.calcBoundingBox(e,t)||{};return{center:h.add(c),correction:u.subtract(c),size:l}}return{center:i.getRelativeCenterPoint().add(c),size:l}}}}b(Hc,"type","clip-path"),R.setClass(Hc);class Vc extends wo{getInitialSize(t,e){let{target:i}=t,{size:r}=e;return new w(i.width||r.x,i.height||r.y)}}b(Vc,"type","fixed"),R.setClass(Vc);class Yb extends Ts{subscribeTargets(t){const e=t.target;t.targets.reduce((i,r)=>(r.parent&&i.add(r.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((r,s)=>(s.parent&&r.add(s.parent),r),new Set).forEach(r=>{!i.some(s=>s.parent===r)&&r.layoutManager.unsubscribeTargets({target:r,targets:[e]})})}}class qi extends Ei{static getDefaults(){return _(_({},super.getDefaults()),qi.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,qi.ownDefaults),this.setOptions(e);const{left:i,top:r,layoutManager:s}=e;this.groupInit(t,{left:i,top:r,layoutManager:s??new Yb})}_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(r=>{const s=this._objects.findIndex(a=>a.isInFrontOf(r)),o=s===-1?this.size():s;this.insertAt(o,r)})}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(r=>{const{parent:s}=r;s&&i.add(s)}),t===dl?i.forEach(r=>{r._onAfterObjectsChange(Wn,e)}):i.forEach(r=>{r._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 r=_(_({hasControls:!1},i),{},{forActiveSelection:!0});for(let s=0;s<this._objects.length;s++)this._objects[s]._renderControls(t,r);super._renderControls(t,e),t.restore()}}b(qi,"type","ActiveSelection"),b(qi,"ownDefaults",{multiSelectionStacking:"canvas-stacking"}),R.setClass(qi),R.setClass(qi,"activeSelection");class Xb{constructor(){b(this,"resources",{})}applyFilters(t,e,i,r,s){const o=s.getContext("2d");if(!o)return;o.drawImage(e,0,0,i,r);const a={sourceWidth:i,sourceHeight:r,imageData:o.getImageData(0,0,i,r),originalEl:e,originalImageData:o.getImageData(0,0,i,r),canvasEl:s,ctx:o,filterBackend:this};t.forEach(c=>{c.applyTo(a)});const{imageData:l}=a;return l.width===i&&l.height===r||(s.width=l.width,s.height=l.height),o.putImageData(l,0,0),a}}class Ku{constructor(){let{tileSize:t=tt.textureSize}=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};b(this,"aPosition",new Float32Array([0,0,0,1,1,0,1,1])),b(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=Ye({width:t,height:e}),r=i.getContext("webgl",{alpha:!0,premultipliedAlpha:!1,depth:!1,stencil:!1,antialias:!1});r&&(r.clearColor(0,0,0,0),this.canvas=i,this.gl=r)}applyFilters(t,e,i,r,s,o){const a=this.gl,l=s.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:r,destinationWidth:i,destinationHeight:r,context:a,sourceTexture:this.createTexture(a,i,r,c?void 0:e),targetTexture:this.createTexture(a,i,r),originalTexture:c||this.createTexture(a,i,r,c?void 0:e),passes:t.length,webgl:!0,aPosition:this.aPosition,programCache:this.programCache,pass:0,filterBackend:this,targetCanvas:s},u=a.createFramebuffer();return a.bindFramebuffer(a.FRAMEBUFFER,u),t.forEach(d=>{d&&d.applyTo(h)}),function(d){const p=d.targetCanvas,g=p.width,f=p.height,m=d.destinationWidth,v=d.destinationHeight;g===m&&f===v||(p.width=m,p.height=v)}(h),this.copyGLTo2D(a,h),a.bindTexture(a.TEXTURE_2D,null),a.deleteTexture(h.sourceTexture),a.deleteTexture(h.targetTexture),a.deleteFramebuffer(u),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,r,s){const{NEAREST:o,TEXTURE_2D:a,RGBA:l,UNSIGNED_BYTE:c,CLAMP_TO_EDGE:h,TEXTURE_MAG_FILTER:u,TEXTURE_MIN_FILTER:d,TEXTURE_WRAP_S:p,TEXTURE_WRAP_T:g}=t,f=t.createTexture();return t.bindTexture(a,f),t.texParameteri(a,u,s||o),t.texParameteri(a,d,s||o),t.texParameteri(a,p,h),t.texParameteri(a,g,h),r?t.texImage2D(a,0,l,l,c,r):t.texImage2D(a,0,l,e,i,0,l,c,null),f}getCachedTexture(t,e,i){const{textureCache:r}=this;if(r[t])return r[t];{const s=this.createTexture(this.gl,e.width,e.height,e,i);return s&&(r[t]=s),s}}evictCachesForKey(t){this.textureCache[t]&&(this.gl.deleteTexture(this.textureCache[t]),delete this.textureCache[t])}copyGLTo2D(t,e){const i=t.canvas,r=e.targetCanvas,s=r.getContext("2d");if(!s)return;s.translate(0,r.height),s.scale(1,-1);const o=i.height-r.height;s.drawImage(i,0,o,r.width,r.height,0,0,r.width,r.height)}copyGLTo2DPutImageData(t,e){const i=e.targetCanvas.getContext("2d"),r=e.destinationWidth,s=e.destinationHeight,o=r*s*4;if(!i)return;const a=new Uint8Array(this.imageBuffer,0,o),l=new Uint8ClampedArray(this.imageBuffer,0,o);t.readPixels(0,0,r,s,t.RGBA,t.UNSIGNED_BYTE,a);const c=new ImageData(l,r,s);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 r=t.getParameter(i.UNMASKED_RENDERER_WEBGL),s=t.getParameter(i.UNMASKED_VENDOR_WEBGL);r&&(e.renderer=r.toLowerCase()),s&&(e.vendor=s.toLowerCase())}return this.gpuInfo=e,e}}let Yo;function Kb(){const{WebGLProbe:n}=Ge();return n.queryWebGL(Fe()),tt.enableGLFiltering&&n.isSupported(tt.textureSize)?new Ku({tileSize:tt.textureSize}):new Xb}function Xo(){return!Yo&&(!(arguments.length>0&&arguments[0]!==void 0)||arguments[0])&&(Yo=Kb()),Yo}const qb=["filters","resizeFilter","src","crossOrigin","type"],qu=["cropX","cropY"];class te extends Xt{static getDefaults(){return _(_({},super.getDefaults()),te.ownDefaults)}constructor(t,e){super(),b(this,"_lastScaleX",1),b(this,"_lastScaleY",1),b(this,"_filterScalingX",1),b(this,"_filterScalingY",1),this.filters=[],Object.assign(this,te.ownDefaults),this.setOptions(e),this.cacheKey="texture".concat(Ii()),this.setElement(typeof t=="string"?(this.canvas&&De(this.canvas.getElement())||jr()).getElementById(t):t,e)}getElement(){return this._element}setElement(t){let e=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(e),t.classList.add(te.CSS_CANVAS),this.filters.length!==0&&this.applyFilters(),this.resizeFilter&&this.applyResizeFilters()}removeTexture(t){const e=Xo(!1);e instanceof Ku&&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&&Ge().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())}),_(_({},super.toObject([...qu,...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,r=-this.height/2;let s=[],o=[],a="",l="";if(!e)return[];if(this.hasCrop()){const c=Ii();s.push('<clipPath id="imageCrop_'+c+`">
|
|
2535
|
-
`,' <rect x="'+i+'" y="'+
|
|
2537
|
+
`),i.join("")}toLive(t){const{x1:e,y1:i,x2:s,y2:r,r1:o,r2:a}=this.coords,l=this.type==="linear"?t.createLinearGradient(e,i,s,r):t.createRadialGradient(e,i,o,s,r,a);return this.colorStops.forEach(c=>{let{color:h,opacity:u,offset:d}=c;l.addColorStop(d,u!==void 0?new st(h).setAlpha(u).toRgba():h)}),l}static async fromObject(t){const{colorStops:e,gradientTransform:i}=t;return new this(_(_({},t),{},{colorStops:e?e.map(s=>_({},s)):void 0,gradientTransform:i?[...i]:void 0}))}static fromElement(t,e,i){const s=Nu(t),r=e._findCenterFromElement();return new this(_({id:t.getAttribute("id")||void 0,type:Bu(t),coords:kb(t,{width:i.viewBoxWidth||i.width,height:i.viewBoxHeight||i.height}),colorStops:Ob(t,i.opacity),gradientUnits:s,gradientTransform:_a(t.getAttribute("gradientTransform")||"")},s==="pixels"?{offsetX:e.width/2-r.x,offsetY:e.height/2-r.y}:{offsetX:0,offsetY:0}))}}b(Kr,"type","Gradient"),R.setClass(Kr,"gradient"),R.setClass(Kr,"linear"),R.setClass(Kr,"radial");const Ab=["type","source","patternTransform"];class Vo{get type(){return"pattern"}set type(t){Mi("warn","Setting type has no effect",t)}constructor(t){b(this,"repeat","repeat"),b(this,"offsetX",0),b(this,"offsetY",0),b(this,"crossOrigin",""),this.id=Ii(),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 _(_({},Bs(this,t)),{},{type:"pattern",source:this.sourceToString(),repeat:e,crossOrigin:i,offsetX:mt(this.offsetX,tt.NUM_FRACTION_DIGITS),offsetY:mt(this.offsetY,tt.NUM_FRACTION_DIGITS),patternTransform:this.patternTransform?[...this.patternTransform]:null})}toSVG(t){let{width:e,height:i}=t;const{source:s,repeat:r,id:o}=this,a=ys(this.offsetX/e,0),l=ys(this.offsetY/i,0),c=r==="repeat-y"||r==="no-repeat"?1+Math.abs(a||0):ys(s.width/e,0),h=r==="repeat-x"||r==="no-repeat"?1+Math.abs(l||0):ys(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(`
|
|
2538
|
+
`)}static async fromObject(t,e){let{type:i,source:s,patternTransform:r}=t,o=gt(t,Ab);const a=await En(s,_(_({},e),{},{crossOrigin:o.crossOrigin}));return new this(_(_({},o),{},{patternTransform:r&&r.slice(0),source:a}))}}b(Vo,"type","Pattern"),R.setClass(Vo),R.setClass(Vo,"pattern");const Pb=["path","left","top"],Db=["d"];class Wi extends Xt{constructor(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},{path:i,left:s,top:r}=e,o=gt(e,Pb);super(),Object.assign(this,Wi.ownDefaults),this.setOptions(o),this._setPath(t||[],!0),typeof s=="number"&&this.set(it,s),typeof r=="number"&&this.set(le,r)}_setPath(t,e){this.path=ab(Array.isArray(t)?t:mb(t)),this.setBoundingBox(e)}_findCenterFromElement(){const t=this._calcBoundsFromPath();return new w(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 _(_({},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=vb(this.path,tt.NUM_FRACTION_DIGITS);return["<path ","COMMON_PARTS",'d="'.concat(t,`" stroke-linecap="round" />
|
|
2539
|
+
`)]}_getOffsetTransform(){const t=tt.NUM_FRACTION_DIGITS;return" translate(".concat(mt(-this.pathOffset.x,t),", ").concat(mt(-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,K,K)}_calcBoundsFromPath(){const t=[];let e=0,i=0,s=0,r=0;for(const o of this.path)switch(o[0]){case"L":s=o[1],r=o[2],t.push({x:e,y:i},{x:s,y:r});break;case"M":s=o[1],r=o[2],e=s,i=r;break;case"C":t.push(...$c(s,r,o[1],o[2],o[3],o[4],o[5],o[6])),s=o[5],r=o[6];break;case"Q":t.push(...$c(s,r,o[1],o[2],o[1],o[2],o[3],o[4])),s=o[3],r=o[4];break;case"Z":s=e,r=i}return ci(t)}_calcDimensions(){const t=this._calcBoundsFromPath();return _(_({},t),{},{pathOffset:new w(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=vi(t,this.ATTRIBUTE_NAMES,i),{d:r}=s;return new this(r,_(_(_({},gt(s,Db)),e),{},{left:void 0,top:void 0}))}}b(Wi,"type","Path"),b(Wi,"cacheProperties",[...mi,"path","fillRule"]),b(Wi,"ATTRIBUTE_NAMES",[...Bi,"d"]),R.setClass(Wi),R.setSVGClass(Wi);const Mb=["left","top","radius"],zu=["radius","startAngle","endAngle","counterClockwise"];class ei extends Xt{static getDefaults(){return _(_({},super.getDefaults()),ei.ownDefaults)}constructor(t){super(),Object.assign(this,ei.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,kt(this.startAngle),kt(this.endAngle),this.counterClockwise),this._renderPaintInOrder(t)}getRadiusX(){return this.get("radius")*this.get(pe)}getRadiusY(){return this.get("radius")*this.get(Ee)}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([...zu,...t])}_toSVG(){const t=(this.endAngle-this.startAngle)%360;if(t===0)return["<circle ","COMMON_PARTS",'cx="0" cy="0" ','r="',"".concat(this.radius),`" />
|
|
2540
|
+
`];{const{radius:e}=this,i=kt(this.startAngle),s=kt(this.endAngle),r=pi(i)*e,o=gi(i)*e,a=pi(s)*e,l=gi(s)*e,c=t>180?1:0,h=this.counterClockwise?0:1;return['<path d="M '.concat(r," ").concat(o," A ").concat(e," ").concat(e," 0 ").concat(c," ").concat(h," ").concat(a," ").concat(l,'" '),"COMMON_PARTS",` />
|
|
2541
|
+
`]}}static async fromElement(t,e,i){const s=vi(t,this.ATTRIBUTE_NAMES,i),{left:r=0,top:o=0,radius:a=0}=s;return new this(_(_({},gt(s,Mb)),{},{radius:a,left:r-a,top:o-a}))}static fromObject(t){return super._fromObject(t)}}b(ei,"type","Circle"),b(ei,"cacheProperties",[...mi,...zu]),b(ei,"ownDefaults",{radius:0,startAngle:0,endAngle:360,counterClockwise:!1}),b(ei,"ATTRIBUTE_NAMES",["cx","cy","r",...Bi]),R.setClass(ei),R.setSVGClass(ei);const Ib=["x1","y1","x2","y2"],Lb=["x1","y1","x2","y2"],Ca=["x1","x2","y1","y2"];class Gi extends Xt{constructor(){let[t,e,i,s]=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[0,0,0,0],r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};super(),Object.assign(this,Gi.ownDefaults),this.setOptions(r),this.x1=t,this.x2=i,this.y1=e,this.y2=s,this._setWidthHeight();const{left:o,top:a}=r;typeof o=="number"&&this.set(it,o),typeof a=="number"&&this.set(le,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:r,top:o,width:a,height:l}=ci([{x:t,y:e},{x:i,y:s}]),c=new w(r+a/2,o+l/2);this.setPositionByOrigin(c,K,K)}_set(t,e){return super._set(t,e),Ca.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;we(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 w((this.x1+this.x2)/2,(this.y1+this.y2)/2)}toObject(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[];return _(_({},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:r,height:o}=this,a=t<=e?-1:1,l=i<=s?-1:1;return{x1:a*r/2,x2:a*-r/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,`" />
|
|
2542
|
+
`)]}static async fromElement(t,e,i){const s=vi(t,this.ATTRIBUTE_NAMES,i),{x1:r=0,y1:o=0,x2:a=0,y2:l=0}=s;return new this([r,o,a,l],gt(s,Ib))}static fromObject(t){let{x1:e,y1:i,x2:s,y2:r}=t,o=gt(t,Lb);return this._fromObject(_(_({},o),{},{points:[e,i,s,r]}),{extraParam:"points"})}}b(Gi,"type","Line"),b(Gi,"cacheProperties",[...mi,...Ca]),b(Gi,"ATTRIBUTE_NAMES",Bi.concat(Ca)),R.setClass(Gi),R.setSVGClass(Gi);class Ki extends Xt{static getDefaults(){return _(_({},super.getDefaults()),Ki.ownDefaults)}constructor(t){super(),Object.assign(this,Ki.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),'" />']}}b(Ki,"type","Triangle"),b(Ki,"ownDefaults",{width:100,height:100}),R.setClass(Ki),R.setSVGClass(Ki);const Hu=["rx","ry"];class ii extends Xt{static getDefaults(){return _(_({},super.getDefaults()),ii.ownDefaults)}constructor(t){super(),Object.assign(this,ii.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(pe)}getRy(){return this.get("ry")*this.get(Ee)}toObject(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[];return super.toObject([...Hu,...t])}_toSVG(){return["<ellipse ","COMMON_PARTS",'cx="0" cy="0" rx="'.concat(this.rx,'" ry="').concat(this.ry,`" />
|
|
2543
|
+
`)]}_render(t){t.beginPath(),t.save(),t.transform(1,0,0,this.ry/this.rx,0,0),t.arc(0,0,this.rx,0,jn,!1),t.restore(),this._renderPaintInOrder(t)}static async fromElement(t,e,i){const s=vi(t,this.ATTRIBUTE_NAMES,i);return s.left=(s.left||0)-s.rx,s.top=(s.top||0)-s.ry,new this(s)}}function Fb(n){if(!n)return[];const t=n.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}b(ii,"type","Ellipse"),b(ii,"cacheProperties",[...mi,...Hu]),b(ii,"ownDefaults",{rx:0,ry:0}),b(ii,"ATTRIBUTE_NAMES",[...Bi,"cx","cy","rx","ry"]),R.setClass(ii),R.setSVGClass(ii);const jb=["left","top"],Vu={exactBoundingBox:!1};class Ae extends Xt{static getDefaults(){return _(_({},super.getDefaults()),Ae.ownDefaults)}constructor(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};super(),b(this,"strokeDiff",void 0),Object.assign(this,Ae.ownDefaults),this.setOptions(e),this.points=t;const{left:i,top:s}=e;this.initialized=!0,this.setBoundingBox(!0),typeof i=="number"&&this.set(it,i),typeof s=="number"&&this.set(le,s)}isOpen(){return!0}_projectStrokeOnPoints(t){return Tv(this.points,t,this.isOpen())}_calcDimensions(t){t=_({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 w,strokeOffset:new w,strokeDiff:new w};const i=ci(e),s=mo(_(_({},t),{},{scaleX:1,scaleY:1})),r=ci(this.points.map(c=>ne(c,s,!0))),o=new w(this.scaleX,this.scaleY);let a=i.left+i.width/2,l=i.top+i.height/2;return this.exactBoundingBox&&(a-=l*Math.tan(kt(this.skewX)),l-=a*Math.tan(kt(this.skewY))),_(_({},i),{},{pathOffset:new w(a,l),strokeOffset:new w(r.left,r.top).subtract(new w(i.left,i.top)).multiply(o),strokeDiff:new w(i.width,i.height).subtract(new w(r.width,r.height)).multiply(o)})}_findCenterFromElement(){const t=ci(this.points);return new w(t.left+t.width/2,t.top+t.height/2)}setDimensions(){this.setBoundingBox()}setBoundingBox(t){const{left:e,top:i,width:s,height:r,pathOffset:o,strokeOffset:a,strokeDiff:l}=this._calcDimensions();this.set({width:s,height:r,pathOffset:o,strokeOffset:a,strokeDiff:l}),t&&this.setPositionByOrigin(new w(e+s/2,i+r/2),K,K)}isStrokeAccountedForInDimensions(){return this.exactBoundingBox}_getNonTransformedDimensions(){return this.exactBoundingBox?new w(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 w((e=t.width)!==null&&e!==void 0?e:a,(i=t.height)!==null&&i!==void 0?i:l)}else{var s,r;o=new w((s=t.width)!==null&&s!==void 0?s:this.width,(r=t.height)!==null&&r!==void 0?r:this.height)}return o.multiply(new w(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===pe||t===Ee)&&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 _(_({},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=tt.NUM_FRACTION_DIGITS;for(let r=0,o=this.points.length;r<o;r++)t.push(mt(this.points[r].x-e,s),",",mt(this.points[r].y-i,s)," ");return["<".concat(this.constructor.type.toLowerCase()," "),"COMMON_PARTS",'points="'.concat(t.join(""),`" />
|
|
2544
|
+
`)]}_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 r=0;r<e;r++){const o=this.points[r];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(Fb(t.getAttribute("points")),_(_({},gt(vi(t,this.ATTRIBUTE_NAMES,i),jb)),e))}static fromObject(t){return this._fromObject(t,{extraParam:"points"})}}b(Ae,"ownDefaults",Vu),b(Ae,"type","Polyline"),b(Ae,"layoutProperties",[Rs,$s,"strokeLineCap","strokeLineJoin","strokeMiterLimit","strokeWidth","strokeUniform","points"]),b(Ae,"cacheProperties",[...mi,"points"]),b(Ae,"ATTRIBUTE_NAMES",[...Bi]),R.setClass(Ae),R.setSVGClass(Ae);class qr extends Ae{isOpen(){return!1}}b(qr,"ownDefaults",Vu),b(qr,"type","Polygon"),R.setClass(qr),R.setSVGClass(qr);const Uu=["fontSize","fontWeight","fontFamily","fontStyle"],Wu=["underline","overline","linethrough"],Gu=[...Uu,"lineHeight","text","charSpacing","textAlign","styles","path","pathStartOffset","pathSide","pathAlign"],Yu=[...Gu,...Wu,"textBackgroundColor","direction"],Rb=[...Uu,...Wu,he,"strokeWidth",Rt,"deltaY","textBackgroundColor"],$b={_reNewline:Za,_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:it,fontStyle:"normal",lineHeight:1.16,superscript:{size:.6,baseline:-.35},subscript:{size:.6,baseline:.11},textBackgroundColor:"",stroke:null,shadow:null,path:void 0,pathStartOffset:0,pathSide:it,pathAlign:"baseline",_fontSizeFraction:.222,offsets:{underline:.1,linethrough:-.315,overline:-.88},_fontSizeMult:1.13,charSpacing:0,deltaY:0,direction:"ltr",CACHE_FONT_SIZE:400,MIN_TEXT_WIDTH:2},Be="justify",Xn="justify-left",lr="justify-right",cr="justify-center";class Xu extends Xt{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 r 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 r in i[s])if(i[s][r][t]!==void 0)return!0;return!1}cleanStyle(t){if(!this.styles)return!1;const e=this.styles;let i,s,r=0,o=!0,a=0;for(const l in e){i=0;for(const c in e[l]){const h=e[l][c]||{};r++,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&&r===a&&(this[t]=s,this.removeStyle(t))}removeStyle(t){if(!this.styles)return;const e=this.styles;let i,s,r;for(s in e){for(r in i=e[s],i)delete i[r][t],Object.keys(i[r]).length===0&&delete i[r];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 r=il(_(_({},this._getStyleDeclaration(i,s)),e),o=>o!==void 0);this._setStyleDeclaration(i,s,r)}getSelectionStyles(t,e,i){const s=[];for(let r=t;r<(e||t);r++)s.push(this.getStyleAtPosition(r,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 _(_({},Bs(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]}}b(Xu,"_styleProperties",Rb);const Bb=/ +/g,Nb=/"/g;function Uo(n,t,e,i,s){return" ".concat(function(r,o){let{left:a,top:l,width:c,height:h}=o,u=arguments.length>2&&arguments[2]!==void 0?arguments[2]:tt.NUM_FRACTION_DIGITS;const d=wr(Rt,r,!1),[p,g,f,m]=[a,l,c,h].map(v=>mt(v,u));return"<rect ".concat(d,' x="').concat(p,'" y="').concat(g,'" width="').concat(f,'" height="').concat(m,'"></rect>')}(n,{left:t,top:e,width:i,height:s}),`
|
|
2545
|
+
`)}const zb=["textAnchor","textDecoration","dx","dy","top","left","fontSize","strokeWidth"];let Wo;class Qt extends Xu{static getDefaults(){return _(_({},super.getDefaults()),Qt.ownDefaults)}constructor(t,e){super(),b(this,"__charBounds",[]),Object.assign(this,Qt.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=Fu(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(Be)&&this.enlargeSpaces()}enlargeSpaces(){let t,e,i,s,r,o,a;for(let l=0,c=this._textLines.length;l<c;l++)if((this.textAlign===Be||l!==c-1&&!this.isEndOfWrapping(l))&&(s=0,r=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<=r.length;h++)o=this.__charBounds[l][h],this._reSpaceAndTab.test(r[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===he?(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 K:t.textBaseline="middle";break;case"ascender":t.textBaseline=le;break;case"descender":t.textBaseline=da}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,r,o){this._renderChars(t,e,i,s,r,o)}_renderTextLinesBackground(t){if(!this.textBackgroundColor&&!this.styleHas("textBackgroundColor"))return;const e=t.fillStyle,i=this._getLeftOffset();let s=this._getTopOffset();for(let r=0,o=this._textLines.length;r<o;r++){const a=this.getHeightOfLine(r);if(!this.textBackgroundColor&&!this.styleHas("textBackgroundColor",r)){s+=a;continue}const l=this._textLines[r].length,c=this._getLineLeftOffset(r);let h,u,d=0,p=0,g=this.getValueOfPropertyAt(r,0,"textBackgroundColor");for(let f=0;f<l;f++){const m=this.__charBounds[r][f];u=this.getValueOfPropertyAt(r,f,"textBackgroundColor"),this.path?(t.save(),t.translate(m.renderLeft,m.renderTop),t.rotate(m.angle),t.fillStyle=u,u&&t.fillRect(-m.width/2,-a/this.lineHeight*(1-this._fontSizeFraction),m.width,a/this.lineHeight),t.restore()):u!==g?(h=i+c+p,this.direction==="rtl"&&(h=this.width-h-d),t.fillStyle=g,g&&t.fillRect(h,s,d,a/this.lineHeight),p=m.left,d=m.width,g=u):d+=m.kernedWidth}u&&!this.path&&(h=i+c+p,this.direction==="rtl"&&(h=this.width-h-d),t.fillStyle=u,t.fillRect(h,s,d,a/this.lineHeight)),s+=a}t.fillStyle=e,this._removeShadow(t)}_measureChar(t,e,i,s){const r=or.getFontCache(e),o=this._getFontDeclaration(e),a=i+t,l=i&&o===this._getFontDeclaration(s),c=e.fontSize/this.CACHE_FONT_SIZE;let h,u,d,p;if(i&&r[i]!==void 0&&(d=r[i]),r[t]!==void 0&&(p=h=r[t]),l&&r[a]!==void 0&&(u=r[a],p=u-d),h===void 0||d===void 0||u===void 0){const g=function(){return Wo||(Wo=Ye({width:0,height:0}).getContext("2d")),Wo}();this._setTextStyles(g,e,!0),h===void 0&&(p=h=g.measureText(t).width,r[t]=h),d===void 0&&l&&i&&(d=g.measureText(i).width,r[i]=d),l&&u===void 0&&(u=g.measureText(a).width,r[a]=u,p=u-d)}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 r=this.pathSide===Ot,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 u=a[h];i=this._getGraphemeBox(u,t,h,e),c[h]=i,s+=i.kernedWidth,e=u}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 u=o.segmentsInfo[o.segmentsInfo.length-1].length;switch(this.textAlign){case it:h=r?u-s:0;break;case K:h=(u-s)/2;break;case Ot:h=r?0:u-s}h+=this.pathStartOffset*(r?-1:1);for(let d=r?l-1:0;r?d>=0:d<l;r?d--:d++)i=c[d],h>u?h%=u:h<0&&(h+=u),this._setGraphemeOnPath(h,i),h+=i.kernedWidth}return{width:s,numOfSpaces:0}}_setGraphemeOnPath(t,e){const i=t+e.kernedWidth/2,s=this.path,r=db(s.path,i,s.segmentsInfo);e.renderLeft=r.x-s.pathOffset.x,e.renderTop=r.y-s.pathOffset.y,e.angle=r.angle+(this.pathSide===Ot?Math.PI:0)}_getGraphemeBox(t,e,i,s,r){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,u=l.width;this.charSpacing!==0&&(c=this._getWidthOfCharSpacing(),u+=c,h+=c);const d={width:u,left:0,height:o.fontSize,kernedWidth:h,deltaY:o.deltaY};if(i>0&&!r){const p=this.__charBounds[e][i-1];d.left=p.left+p.width+l.kernedWidth-l.width}return d}getHeightOfLine(t){if(this.__lineHeights[t])return this.__lineHeights[t];let e=this.getHeightOfChar(t,0);for(let i=1,s=this._textLines[t].length;i<s;i++)e=Math.max(this.getHeightOfChar(t,i),e);return this.__lineHeights[t]=e*this.lineHeight*this._fontSizeMult}calcTextHeight(){let t,e=0;for(let i=0,s=this._textLines.length;i<s;i++)t=this.getHeightOfLine(i),e+=i===s-1?t/this.lineHeight:t;return e}_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(),r=this._getTopOffset();for(let o=0,a=this._textLines.length;o<a;o++){const l=this.getHeightOfLine(o),c=l/this.lineHeight,h=this._getLineLeftOffset(o);this._renderTextLine(e,t,this._textLines[o],s+h,r+i+c,o),i+=l}t.restore()}_renderTextFill(t){(this.fill||this.styleHas(Rt))&&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,r,o){const a=this.getHeightOfLine(o),l=this.textAlign.includes(Be),c=this.path,h=!l&&this.charSpacing===0&&this.isEmptyStyles(o)&&!c,u=this.direction==="ltr",d=this.direction==="ltr"?1:-1,p=e.direction;let g,f,m,v,y,x="",E=0;if(e.save(),p!==this.direction&&(e.canvas.setAttribute("dir",u?"ltr":"rtl"),e.direction=u?"ltr":"rtl",e.textAlign=u?it:Ot),r-=a*this._fontSizeFraction/this.lineHeight,h)return this._renderChar(t,e,o,0,i.join(""),s,r),void e.restore();for(let O=0,D=i.length-1;O<=D;O++)v=O===D||this.charSpacing||c,x+=i[O],m=this.__charBounds[o][O],E===0?(s+=d*(m.kernedWidth-m.width),E+=m.width):E+=m.kernedWidth,l&&!v&&this._reSpaceAndTab.test(i[O])&&(v=!0),v||(g=g||this.getCompleteStyleDeclaration(o,O),f=this.getCompleteStyleDeclaration(o,O+1),v=hl(g,f,!1)),v&&(c?(e.save(),e.translate(m.renderLeft,m.renderTop),e.rotate(m.angle),this._renderChar(t,e,o,O,x,-E/2,0),e.restore()):(y=s,this._renderChar(t,e,o,O,x,y,r)),x="",g=f,s+=d*E,E=0);e.restore()}_applyPatternGradientTransformText(t){const e=this.width+this.strokeWidth,i=this.height+this.strokeWidth,s=Ye({width:e,height:i}),r=s.getContext("2d");return s.width=e,s.height=i,r.beginPath(),r.moveTo(0,0),r.lineTo(e,0),r.lineTo(e,i),r.lineTo(0,i),r.closePath(),r.translate(e/2,i/2),r.fillStyle=t.toLive(r),this._applyPatternGradientTransform(r,t),r.fill(),r.createPattern(s,"no-repeat")}handleFiller(t,e,i){let s,r;return we(i)?i.gradientUnits==="percentage"||i.gradientTransform||i.patternTransform?(s=-this.width/2,r=-this.height/2,t.translate(s,r),t[e]=this._applyPatternGradientTransformText(i),{offsetX:s,offsetY:r}):(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,r,o,a){const l=this._getStyleDeclaration(i,s),c=this.getCompleteStyleDeclaration(i,s),h=t==="fillText"&&c.fill,u=t==="strokeText"&&c.stroke&&c.strokeWidth;if(u||h){if(e.save(),e.font=this._getFontDeclaration(c),l.textBackgroundColor&&this._removeShadow(e),l.deltaY&&(a+=l.deltaY),h){const d=this._setFillStyles(e,c);e.fillText(r,o-d.offsetX,a-d.offsetY)}if(u){const d=this._setStrokeStyles(e,c);e.strokeText(r,o-d.offsetX,a-d.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),r=this.getValueOfPropertyAt(s.lineIndex,s.charIndex,"fontSize"),o=this.getValueOfPropertyAt(s.lineIndex,s.charIndex,"deltaY"),a={fontSize:r*i.size,deltaY:o+r*i.baseline};this.setSelectionStyles(a,t,e)}_getLineLeftOffset(t){const e=this.getLineWidth(t),i=this.width-e,s=this.textAlign,r=this.direction,o=this.isEndOfWrapping(t);let a=0;return s===Be||s===cr&&!o||s===lr&&!o||s===Xn&&!o?0:(s===K&&(a=i/2),s===Ot&&(a=i),s===cr&&(a=i/2),s===lr&&(a=i),r==="rtl"&&(s===Ot||s===Be||s===lr?a=0:s===it||s===Xn?a=-i:s!==K&&s!==cr||(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(),r=this.path,o=this._getWidthOfCharSpacing(),a=this.offsets[e];for(let l=0,c=this._textLines.length;l<c;l++){const h=this.getHeightOfLine(l);if(!this[e]&&!this.styleHas(e,l)){i+=h;continue}const u=this._textLines[l],d=h/this.lineHeight,p=this._getLineLeftOffset(l);let g,f,m=0,v=0,y=this.getValueOfPropertyAt(l,0,e),x=this.getValueOfPropertyAt(l,0,Rt);const E=i+d*(1-this._fontSizeFraction);let O=this.getHeightOfChar(l,0),D=this.getValueOfPropertyAt(l,0,"deltaY");for(let T=0,F=u.length;T<F;T++){const j=this.__charBounds[l][T];g=this.getValueOfPropertyAt(l,T,e),f=this.getValueOfPropertyAt(l,T,Rt);const A=this.getHeightOfChar(l,T),k=this.getValueOfPropertyAt(l,T,"deltaY");if(r&&g&&f)t.save(),t.fillStyle=x,t.translate(j.renderLeft,j.renderTop),t.rotate(j.angle),t.fillRect(-j.kernedWidth/2,a*A+k,j.kernedWidth,this.fontSize/15),t.restore();else if((g!==y||f!==x||A!==O||k!==D)&&v>0){let P=s+p+m;this.direction==="rtl"&&(P=this.width-P-v),y&&x&&(t.fillStyle=x,t.fillRect(P,E+a*O+D,v,this.fontSize/15)),m=j.left,v=j.width,y=g,x=f,O=A,D=k}else v+=j.kernedWidth}let C=s+p+m;this.direction==="rtl"&&(C=this.width-C-v),t.fillStyle=f,g&&f&&t.fillRect(C,E+a*O+D,v-o,this.fontSize/15),i+=h}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]:{},r=arguments.length>1?arguments[1]:void 0;const o=t.includes("'")||t.includes('"')||t.includes(",")||Qt.genericFonts.includes(t.toLowerCase())?t:'"'.concat(t,'"');return[e,i,"".concat(r?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 cl(t)}_splitTextIntoLines(t){const e=t.split(this._reNewline),i=new Array(e.length),s=[`
|
|
2546
|
+
`];let r=[];for(let o=0;o<e.length;o++)i[o]=this.graphemeSplit(e[o]),r=r.concat(i[o],s);return r.pop(),{_unwrappedLines:i,lines:e,graphemeText:r,graphemeLines:i}}toObject(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[];return _(_({},super.toObject([...Yu,...t])),{},{styles:kv(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,r=!1;if(typeof t=="object")for(const o in t)o==="path"&&this.setPathInfo(),s=s||i.includes(o),r=r||o==="path";else s=i.includes(t),r=t==="path";return r&&this.setPathInfo(),s&&this.initialized&&(this.initDimensions(),this.setCoords()),this}complexity(){return 1}static async fromElement(t,e,i){const s=vi(t,Qt.ATTRIBUTE_NAMES,i),r=_(_({},e),s),{textAnchor:o=it,textDecoration:a="",dx:l=0,dy:c=0,top:h=0,left:u=0,fontSize:d=qa,strokeWidth:p=1}=r,g=gt(r,zb),f=new this((t.textContent||"").replace(/^\s+|\s+$|\n+/g,"").replace(/\s+/g," "),_({left:u+l,top:h+c,underline:a.includes("underline"),overline:a.includes("overline"),linethrough:a.includes("line-through"),strokeWidth:0,fontSize:d},g)),m=f.getScaledHeight()/f.height,v=((f.height+f.strokeWidth)*f.lineHeight-f.height)*m,y=f.getScaledHeight()+v;let x=0;return o===K&&(x=f.getScaledWidth()/2),o===Ot&&(x=f.getScaledWidth()),f.set({left:f.left-x,top:f.top-(y-f.fontSize*(.07+f._fontSizeFraction))/f.lineHeight,strokeWidth:p}),f}static fromObject(t){return this._fromObject(_(_({},t),{},{styles:Av(t.styles||{},t.text)}),{extraParam:"text"})}}b(Qt,"textLayoutProperties",Gu),b(Qt,"cacheProperties",[...mi,...Yu]),b(Qt,"ownDefaults",$b),b(Qt,"type","Text"),b(Qt,"genericFonts",["serif","sans-serif","monospace","cursive","fantasy","system-ui","ui-serif","ui-sans-serif","ui-monospace","ui-rounded","math","emoji","fangsong"]),b(Qt,"ATTRIBUTE_NAMES",Bi.concat("x","y","dx","dy","font-family","font-style","font-weight","font-size","letter-spacing","text-decoration","text-anchor")),Eu(Qt,[class extends vu{_toSVG(){const n=this._getSVGLeftTopOffsets(),t=this._getSVGTextAndBg(n.textTop,n.textLeft);return this._wrapSVGTextAndBg(t)}toSVG(n){return this._createBaseSVGMarkup(this._toSVG(),{reviver:n,noStyle:!0,withShadow:!0})}_getSVGLeftTopOffsets(){return{textLeft:-this.width/2,textTop:-this.height/2,lineTop:this.getHeightOfLine(0)}}_wrapSVGTextAndBg(n){let{textBgRects:t,textSpans:e}=n;const i=this.getSvgTextDecoration(this);return[t.join(""),' <text xml:space="preserve" ',this.fontFamily?'font-family="'.concat(this.fontFamily.replace(Nb,"'"),'" '):"",this.fontSize?'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>
|
|
2547
|
+
`]}_getSVGTextAndBg(n,t){const e=[],i=[];let s,r=n;this.backgroundColor&&i.push(...Uo(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,r),this._setSVGTextLineText(e,o,t+s,r),r+=this.getHeightOfLine(o);return{textSpans:e,textBgRects:i}}_createTextCharSpan(n,t,e,i){const s=this.getSvgSpanStyles(t,n!==n.trim()||!!n.match(Bb)),r=s?'style="'.concat(s,'"'):"",o=t.deltaY,a=o?' dy="'.concat(mt(o,tt.NUM_FRACTION_DIGITS),'" '):"";return'<tspan x="'.concat(mt(e,tt.NUM_FRACTION_DIGITS),'" y="').concat(mt(i,tt.NUM_FRACTION_DIGITS),'" ').concat(a).concat(r,">").concat(Ev(n),"</tspan>")}_setSVGTextLineText(n,t,e,i){const s=this.getHeightOfLine(t),r=this.textAlign.includes(Be),o=this._textLines[t];let a,l,c,h,u,d="",p=0;i+=s*(1-this._fontSizeFraction)/this.lineHeight;for(let g=0,f=o.length-1;g<=f;g++)u=g===f||this.charSpacing,d+=o[g],c=this.__charBounds[t][g],p===0?(e+=c.kernedWidth-c.width,p+=c.width):p+=c.kernedWidth,r&&!u&&this._reSpaceAndTab.test(o[g])&&(u=!0),u||(a=a||this.getCompleteStyleDeclaration(t,g),l=this.getCompleteStyleDeclaration(t,g+1),u=hl(a,l,!0)),u&&(h=this._getStyleDeclaration(t,g),n.push(this._createTextCharSpan(d,h,e,i)),d="",a=l,this.direction==="rtl"?e-=p:e+=p,p=0)}_setSVGTextLineBg(n,t,e,i){const s=this._textLines[t],r=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:u,width:d,kernedWidth:p}=this.__charBounds[t][h];o=this.getValueOfPropertyAt(t,h,"textBackgroundColor"),o!==c?(c&&n.push(...Uo(c,e+l,i,a,r)),l=u,a=d,c=o):a+=p}o&&n.push(...Uo(c,e+l,i,a,r))}_getSVGLineTopOffset(n){let t,e=0;for(t=0;t<n;t++)e+=this.getHeightOfLine(t);const i=this.getHeightOfLine(t);return{lineTop:e,offset:(this._fontSizeMult-this._fontSizeFraction)*i/(this.lineHeight*this._fontSizeMult)}}getSvgStyles(n){return"".concat(super.getSvgStyles(n)," white-space: pre;")}getSvgSpanStyles(n,t){const{fontFamily:e,strokeWidth:i,stroke:s,fill:r,fontSize:o,fontStyle:a,fontWeight:l,deltaY:c}=n,h=this.getSvgTextDecoration(n);return[s?wr(he,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,"; "):"",h&&"text-decoration: ".concat(h,"; "),r?wr(Rt,r):"",c?"baseline-shift: ".concat(-c,"; "):"",t?"white-space: pre; ":""].join("")}getSvgTextDecoration(n){return["overline","underline","line-through"].filter(t=>n[t.replace("-","")]).join(" ")}}]),R.setClass(Qt),R.setSVGClass(Qt);class Hb{constructor(t){b(this,"target",void 0),b(this,"__mouseDownInPlace",!1),b(this,"__dragStartFired",!1),b(this,"__isDraggingOver",!1),b(this,"__dragStartSelection",void 0),b(this,"__dragImageDisposer",void 0),b(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:r}=e;const o=this.target,a=o.canvas,l=new w(o.flipX?-1:1,o.flipY?-1:1),c=o._getCursorBoundaries(s),h=new w(c.left+c.leftOffset,c.top+c.topOffset).multiply(l).transform(o.calcTransformMatrix()),u=a.getScenePoint(t).subtract(h),d=o.getCanvasRetinaScaling(),p=o.getBoundingRect(),g=h.subtract(new w(p.left,p.top)),f=a.viewportTransform,m=g.add(u).transform(f,!0),v=o.backgroundColor,y=ll(o.styles);o.backgroundColor="";const x={stroke:"transparent",fill:"transparent",textBackgroundColor:"transparent"};o.setSelectionStyles(x,0,s),o.setSelectionStyles(x,r,o.text.length),o.dirty=!0;const E=o.toCanvasElement({enableRetinaScaling:a.enableRetinaScaling,viewportTransform:!0});o.backgroundColor=v,o.styles=y,o.dirty=!0,wa(E,{position:"fixed",left:"".concat(-E.width,"px"),border:ce,width:"".concat(E.width/d,"px"),height:"".concat(E.height/d,"px")}),this.__dragImageDisposer&&this.__dragImageDisposer(),this.__dragImageDisposer=()=>{E.remove()},De(t.target||this.target.hiddenTextarea).body.appendChild(E),(i=t.dataTransfer)===null||i===void 0||i.setDragImage(E,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},r=e._text.slice(s.selectionStart,s.selectionEnd).join(""),o=_({text:e.text,value:r},s);t.dataTransfer.setData("text/plain",r),t.dataTransfer.setData("application/fabric",JSON.stringify({value:r,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 r=(e=i.dataTransfer)===null||e===void 0?void 0:e.getData("text/plain");if(r&&!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=r[Math.max(0,r.length-1)],u=0;if(this.__dragStartSelection){const d=this.__dragStartSelection.selectionStart,p=this.__dragStartSelection.selectionEnd;l>d&&l<=p?l=d:l>p&&(l-=p-d),o.removeChars(d,p),delete this.__dragStartSelection}o._reNewline.test(h)&&(o._reNewline.test(o._text[l])||l===o._text.length)&&(r=r.trimEnd()),t.didDrop=!0,t.dropTarget=o,o.insertChars(r,c,l),a.setActiveObject(o),o.enterEditing(i),o.selectionStart=Math.min(l+u,o._text.length),o.selectionEnd=Math.min(o.selectionStart+r.length,o._text.length),o.hiddenTextarea.value=o.text,o._updateTextarea(),o.hiddenTextarea.focus(),o.fire(Rn,{index:l+u,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,r=this.target.canvas,{selectionStart:o,selectionEnd:a}=this.__dragStartSelection,l=((i=e.dataTransfer)===null||i===void 0?void 0:i.dropEffect)||ce;l===ce?(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(Rn,{index:o,action:"dragend"}),r.fire("text:changed",{target:s}),r.requestRenderAll()),s.exitEditing())}this.__dragImageDisposer&&this.__dragImageDisposer(),delete this.__dragImageDisposer,delete this.__dragStartSelection,this.__isDraggingOver=!1}dispose(){this._dispose&&this._dispose()}}const zc=/[ \n\.,;!\?\-]/;class Vb extends Qt{constructor(){super(...arguments),b(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:r}=t;return xu({startValue:this._currentCursorOpacity,endValue:e,duration:i,delay:s,onComplete:r,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}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||!Za.test(i[t-1]))?t-1:t,r=i[s];for(;s>0&&s<i.length&&!zc.test(r);)s+=e,r=i[s];return e===-1&&zc.test(r)&&s++,s}selectWord(t){t=t||this.selectionStart;const e=this.searchWordBoundary(t,-1),i=Math.max(e,this.searchWordBoundary(t,1));this.selectionStart=e,this.selectionEnd=i,this._fireSelectionChanged(),this._updateTextarea(),this.renderCursorOrSelection()}selectLine(t){t=t||this.selectionStart;const e=this.findLineBoundaryLeft(t),i=this.findLineBoundaryRight(t);return this.selectionStart=e,this.selectionEnd=i,this._fireSelectionChanged(),this._updateTextarea(),this}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;De(e).activeElement!==e&&e.focus();const i=this.getSelectionStartFromPointer(t),s=this.selectionStart,r=this.selectionEnd;(i===this.__selectionStartOnMouseDown&&s!==r||s!==i&&r!==i)&&(i>this.__selectionStartOnMouseDown?(this.selectionStart=this.__selectionStartOnMouseDown,this.selectionEnd=i):(this.selectionStart=i,this.selectionEnd=this.__selectionStartOnMouseDown),this.selectionStart===s&&this.selectionEnd===r||(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),r=this.graphemeSplit(s).length;if(t===e)return{selectionStart:r,selectionEnd:r};const o=i.slice(t,e);return{selectionStart:r,selectionEnd:r+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,r=i.charIndex,o=this.getValueOfPropertyAt(s,r,"fontSize")*this.lineHeight,a=e.leftOffset,l=this.getCanvasRetinaScaling(),c=this.canvas.upperCanvasEl,h=c.width/l,u=c.height/l,d=h-o,p=u-o,g=new w(e.left+a,e.top+e.topOffset+o).transform(this.calcTransformMatrix()).transform(this.canvas.viewportTransform).multiply(new w(c.clientWidth/h,c.clientHeight/u));return g.x<0&&(g.x=0),g.x>d&&(g.x=d),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($n),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:r,charIndex:o}=this.get2DCursorLocation(e,!0);if(i!==r){if(this.styles[i])for(let a=s;a<this._unwrappedTextLines[i].length;a++)delete this.styles[i][a];if(this.styles[r])for(let a=o;a<this._unwrappedTextLines[r].length;a++){const l=this.styles[r][a];l&&(this.styles[i]||(this.styles[i]={}),this.styles[i][s+a-o]=l)}for(let a=i+1;a<=r;a++)delete this.styles[a];this.shiftLineStyles(r,i-r)}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 r=parseInt(s,10);r>t&&(this.styles[r+e]=i[r],i[r-e]||delete this.styles[r])}}insertNewlineStyleObject(t,e,i,s){const r={},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 u in this.styles[t]){const d=parseInt(u,10);d>=e&&(l=!0,r[d-e]=this.styles[t][u],a&&e===0||delete this.styles[t][u])}let h=!1;for(l&&!a&&(this.styles[t+i]=r,h=!0),(h||o>e)&&i--;i>0;)s&&s[i-1]?this.styles[t+i]={0:_({},s[i-1])}:c?this.styles[t+i]={0:_({},c)}:delete this.styles[t+i],i--;this._forceClearCache=!0}insertCharStyleObject(t,e,i,s){this.styles||(this.styles={});const r=this.styles[t],o=r?_({},r):{};i||(i=1);for(const l in o){const c=parseInt(l,10);c>=e&&(r[c+i]=o[c],o[c-i]||delete r[c])}if(this._forceClearCache=!0,s){for(;i--;)Object.keys(s[i]).length&&(this.styles[t]||(this.styles[t]={}),this.styles[t][e+i]=_({},s[i]));return}if(!r)return;const a=r[e?e-1:1];for(;a&&i--;)this.styles[t][e+i]=_({},a)}insertNewStyleBlock(t,e,i){const s=this.get2DCursorLocation(e,!0),r=[0];let o,a=0;for(let l=0;l<t.length;l++)t[l]===`
|
|
2548
|
+
`?(a++,r[a]=0):r[a]++;for(r[0]>0&&(this.insertCharStyleObject(s.lineIndex,s.charIndex,r[0],i),i=i&&i.slice(r[0]+1)),a&&this.insertNewlineStyleObject(s.lineIndex,s.charIndex+r[0],a),o=1;o<a;o++)r[o]>0?this.insertCharStyleObject(s.lineIndex+o,0,r[o],i):i&&this.styles[s.lineIndex+o]&&i[0]&&(this.styles[s.lineIndex+o][0]=i[0]),i=i&&i.slice(r[o]+1);r[o]>0&&this.insertCharStyleObject(s.lineIndex+o,0,r[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 r=this.graphemeSplit(t);this.insertNewStyleBlock(r,i,e),this._text=[...this._text.slice(0,i),...r,...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=it:this._selectionDirection===Ot&&(this._selectionDirection=it,this.selectionEnd=t),this.selectionStart=i):i>t&&i<e?this._selectionDirection===Ot?this.selectionEnd=i:this.selectionStart=i:(e===t?this._selectionDirection=Ot:this._selectionDirection===it&&(this._selectionDirection=Ot,this.selectionStart=e),this.selectionEnd=i)}}class Ub extends Vb{initHiddenTextarea(){const t=this.canvas&&De(this.canvas.getElement())||js(),e=t.createElement("textarea");Object.entries({autocapitalize:"off",autocorrect:"off",autocomplete:"off",spellcheck:"false","data-fabric":"textarea",wrap:"off"}).map(o=>{let[a,l]=o;return e.setAttribute(a,l)});const{top:i,left:s,fontSize:r}=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(r,";"),(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;if(this.fromPaste=!1,t&&t.stopPropagation(),!this.isEditing)return;const i=()=>{this.updateFromTextArea(),this.fire(Rn),this.canvas&&(this.canvas.fire("text:changed",{target:this}),this.canvas.requestRenderAll())};if(this.hiddenTextarea.value==="")return this.styles={},void i();const s=this._splitTextIntoLines(this.hiddenTextarea.value).graphemeText,r=this._text.length,o=s.length,a=this.selectionStart,l=this.selectionEnd,c=a!==l;let h,u,d,p,g=o-r;const f=this.fromStringToGraphemeSelection(this.hiddenTextarea.selectionStart,this.hiddenTextarea.selectionEnd,this.hiddenTextarea.value),m=a>f.selectionStart;c?(u=this._text.slice(a,l),g+=l-a):o<r&&(u=m?this._text.slice(l+g,l):this._text.slice(a,a-g));const v=s.slice(f.selectionEnd-g,f.selectionEnd);if(u&&u.length&&(v.length&&(h=this.getSelectionStyles(a,a+1,!1),h=v.map(()=>h[0])),c?(d=a,p=l):m?(d=l-u.length,p=l):(d=l,p=l+u.length),this.removeStyleFromTo(d,p)),v.length){const{copyPasteData:y}=Ge();e&&v.join("")===y.copiedText&&!tt.disableStyleCopyPaste&&(h=y.copiedTextStyle),this.insertNewStyleBlock(v,a,h)}i()}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}=Ge();t.copiedText=this.getSelectedText(),tt.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),r=s.lineIndex;if(r===this._textLines.length-1||t.metaKey||t.keyCode===34)return this._text.length-i;const o=s.charIndex,a=this._getWidthBeforeCursor(r,o),l=this._getIndexOnLine(r+1,a);return this._textLines[r].slice(o).length+l+1+this.missingNewlineOffset(r)}_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),r=s.lineIndex;if(r===0||t.metaKey||t.keyCode===33)return-i;const o=s.charIndex,a=this._getWidthBeforeCursor(r,o),l=this._getIndexOnLine(r-1,a),c=this._textLines[r].slice(0,o),h=this.missingNewlineOffset(r-1);return-this._textLines[r-1].length+l-c.length+(1-h)}_getIndexOnLine(t,e){const i=this._textLines[t];let s,r,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){r=!0;const h=o-s,u=o,d=Math.abs(h-e);a=Math.abs(u-e)<d?l:l-1;break}return r||(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===Ot);if(e.shiftKey?this.moveCursorWithShift(i):this.moveCursorWithoutShift(i),i!==0){const s=this.text.length;this.selectionStart=Ds(0,this.selectionStart,s),this.selectionEnd=Ds(0,this.selectionEnd,s),this.abortCursorAnimation(),this.initDelayedCursor(),this._fireSelectionChanged(),this._updateTextarea()}}moveCursorWithShift(t){const e=this._selectionDirection===it?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=it,this.selectionEnd===this.selectionStart&&this.selectionStart!==0&&(e=this._moveLeft(t,"selectionStart")),this.selectionEnd=this.selectionStart,e}moveCursorLeftWithShift(t){return this._selectionDirection===Ot&&this.selectionStart!==this.selectionEnd?this._moveLeft(t,"selectionEnd"):this.selectionStart!==0?(this._selectionDirection=it,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===it&&this.selectionStart!==this.selectionEnd?this._moveRight(t,"selectionStart"):this.selectionEnd!==this._text.length?(this._selectionDirection=Ot,this._moveRight(t,"selectionEnd")):void 0}moveCursorRightWithoutShift(t){let e=!0;return this._selectionDirection=Ot,this.selectionStart===this.selectionEnd?(e=this._moveRight(t,"selectionStart"),this.selectionEnd=this.selectionStart):this.selectionStart=this.selectionEnd,e}}const Go=n=>!!n.button;class Wb extends Ub{constructor(){super(...arguments),b(this,"draggableTextDelegate",void 0)}initBehavior(){this.on("mousedown",this._mouseDownHandler),this.on("mousedown:before",this._mouseDownHandlerBefore),this.on("mouseup",this.mouseUpHandler),this.on("mousedblclick",this.doubleClickHandler),this.on("tripleclick",this.tripleClickHandler),this.__lastClickTime=+new Date,this.__lastLastClickTime=+new Date,this.__lastPointer={},this.on("mousedown",this.onMouseDown),this.draggableTextDelegate=new Hb(this),super.initBehavior()}shouldStartDragging(){return this.draggableTextDelegate.isActive()}onDragStart(t){return this.draggableTextDelegate.onDragStart(t)}canDrop(t){return this.draggableTextDelegate.canDrop(t)}onMouseDown(t){if(!this.canvas)return;this.__newClickTime=+new Date;const e=t.pointer;this.isTripleClick(e)&&(this.fire("tripleclick",t),fa(t.e)),this.__lastLastClickTime=this.__lastClickTime,this.__lastClickTime=this.__newClickTime,this.__lastPointer=e,this.__lastSelected=this.selected&&!this.getActiveControl()}isTripleClick(t){return this.__newClickTime-this.__lastClickTime<500&&this.__lastClickTime-this.__lastLastClickTime<500&&this.__lastPointer.x===t.x&&this.__lastPointer.y===t.y}doubleClickHandler(t){this.isEditing&&this.selectWord(this.getSelectionStartFromPointer(t.e))}tripleClickHandler(t){this.isEditing&&this.selectLine(this.getSelectionStartFromPointer(t.e))}_mouseDownHandler(t){let{e}=t;this.canvas&&this.editable&&!Go(e)&&!this.getActiveControl()&&(this.draggableTextDelegate.start(e)||(this.canvas.textEditingManager.register(this),this.selected&&(this.inCompositionMode=!1,this.setCursorByClick(e)),this.isEditing&&(this.__selectionStartOnMouseDown=this.selectionStart,this.selectionStart===this.selectionEnd&&this.abortCursorAnimation(),this.renderCursorOrSelection())))}_mouseDownHandlerBefore(t){let{e}=t;this.canvas&&this.editable&&!Go(e)&&(this.selected=this===this.canvas._activeObject)}mouseUpHandler(t){let{e,transform:i}=t;const s=this.draggableTextDelegate.end(e);if(this.canvas){this.canvas.textEditingManager.unregister(this);const r=this.canvas._activeObject;if(r&&r!==this)return}!this.editable||this.group&&!this.group.interactive||i&&i.actionPerformed||Go(e)||s||(this.__lastSelected&&!this.getActiveControl()?(this.selected=!1,this.__lastSelected=!1,this.enterEditing(e),this.selectionStart===this.selectionEnd?this.initDelayedCursor(!0):this.renderCursorOrSelection()):this.selected=!0)}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(Ie(this.calcTransformMatrix())).add(new w(-this._getLeftOffset(),-this._getTopOffset()));let i=0,s=0,r=0;for(let c=0;c<this._textLines.length&&i<=e.y;c++)i+=this.getHeightOfLine(c),r=c,c>0&&(s+=this._textLines[c-1].length+this.missingNewlineOffset(c-1));let o=Math.abs(this._getLineLeftOffset(r));const a=this._textLines[r].length,l=this.__charBounds[r];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 Zr="moveCursorUp",Jr="moveCursorDown",Qr="moveCursorLeft",tn="moveCursorRight",en="exitEditing",Gb=_({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:en,27:en,33:Zr,34:Jr,35:tn,36:Qr,37:Qr,38:Zr,39:tn,40:Jr},keysMapRtl:{9:en,27:en,33:Zr,34:Jr,35:Qr,36:tn,37:tn,38:Zr,39:Qr,40:Jr},ctrlKeysMapDown:{65:"selectAll"},ctrlKeysMapUp:{67:"copy",88:"cut"}},{_selectionDirection:null,_reSpace:/\s|\r?\n/,inCompositionMode:!1});class oi extends Wb{static getDefaults(){return _(_({},super.getDefaults()),oi.ownDefaults)}get type(){const t=super.type;return t==="itext"?"i-text":t}constructor(t,e){super(t,_(_({},oi.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 Yn&&this.canvas.textEditingManager.remove(this),e instanceof Yn&&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)return;const t=this.clearContextTop(!0);if(!t)return;const e=this._getCursorBoundaries();this.selectionStart!==this.selectionEnd||this.inCompositionMode?this.renderSelection(t,e):this.renderCursor(t,e),this.canvas.contextTopDirty=!0,t.restore()}_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(),r=this._getCursorBoundariesOffsets(t,e);return{left:i,top:s,leftOffset:r.left,topOffset:r.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:r}=this.get2DCursorLocation(t);for(let c=0;c<r;c++)e+=this.getHeightOfLine(c);const o=this._getLineLeftOffset(r),a=this.__charBounds[r][s];a&&(i=a.left),this.charSpacing!==0&&s===this._textLines[r].length&&(i-=this._getWidthOfCharSpacing());const l={top:e,left:o+(i>0?i:0)};return this.direction==="rtl"&&(this.textAlign===Ot||this.textAlign===Be||this.textAlign===lr?l.left*=-1:this.textAlign===it||this.textAlign===Xn?l.left=o-(i>0?i:0):this.textAlign!==K&&this.textAlign!==cr||(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,r=i.charIndex>0?i.charIndex-1:0,o=this.getValueOfPropertyAt(s,r,"fontSize"),a=this.getObjectScaling().x*this.canvas.getZoom(),l=this.cursorWidth/a,c=this.getValueOfPropertyAt(s,r,"deltaY"),h=e.topOffset+(1-this._fontSizeFraction)*this.getHeightOfLine(s)/this.lineHeight-o*(1-this._fontSizeFraction);return{color:this.cursorColor||this.getValueOfPropertyAt(s,r,"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:r,left:o,top:a,width:l,height:c}=this.getCursorRenderingData(i,e);t.fillStyle=s,t.globalAlpha=r,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,r=e.selectionEnd,o=this.textAlign.includes(Be),a=this.get2DCursorLocation(s),l=this.get2DCursorLocation(r),c=a.lineIndex,h=l.lineIndex,u=a.charIndex<0?0:a.charIndex,d=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,v=0,y=0;if(p===c&&(v=this.__charBounds[c][u].left),p>=c&&p<h)y=o&&!this.isEndOfWrapping(p)?this.width:this.getLineWidth(p)||5;else if(p===h)if(d===0)y=this.__charBounds[h][d].left;else{const C=this._getWidthOfCharSpacing();y=this.__charBounds[h][d-1].left+this.__charBounds[h][d-1].width-C}m=f,(this.lineHeight<1||p===h&&this.lineHeight>1)&&(f/=this.lineHeight);let x=i.left+g+v,E=f,O=0;const D=y-v;this.inCompositionMode?(t.fillStyle=this.compositionColor||"black",E=1,O=f):t.fillStyle=this.selectionColor,this.direction==="rtl"&&(this.textAlign===Ot||this.textAlign===Be||this.textAlign===lr?x=this.width-x-D:this.textAlign===it||this.textAlign===Xn?x=i.left+g-y:this.textAlign!==K&&this.textAlign!==cr||(x=i.left+g-y)),t.fillRect(x,i.top+i.topOffset+O,D,E),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,Rt)}_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()}}b(oi,"ownDefaults",Gb),b(oi,"type","IText"),R.setClass(oi),R.setClass(oi,"i-text");class ai extends oi{static getDefaults(){return _(_({},super.getDefaults()),ai.ownDefaults)}constructor(t,e){super(t,_(_({},ai.ownDefaults),e))}static createControls(){return{controls:wv()}}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(Be)&&this.enlargeSpaces(),this.height=this.calcTextHeight())}_generateStyleMap(t){let e=0,i=0,s=0;const r={};for(let o=0;o<t.graphemeLines.length;o++)t.graphemeText[s]===`
|
|
2549
|
+
`&&o>0?(i=0,s++,e++):!this.splitByGrapheme&&this._reSpaceAndTab.test(t.graphemeText[s])&&o>0&&(i++,s++),r[o]={line:e,offset:i},s+=t.graphemeLines[o].length,i+=t.graphemeLines[o].length;return r}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,r=!1;const o=this._styleMap[t],a=this._styleMap[t+1];o&&(t=o.line,i=o.offset),a&&(s=a.line,r=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 u=parseInt(h,10);if(u>=i&&(!r||u<e))for(const d 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 r=0;r<i.wordsData.length;r++)s.push(...this._wrapLine(r,e,i));return this.isWrapping=!1,s}getGraphemeDataForRender(t){const e=this.splitByGrapheme,i=e?"":" ";let s=0;return{wordsData:t.map((r,o)=>{let a=0;const l=e?this.graphemeSplit(r):this.wordSplit(r);return l.length===0?[{word:[],width:0}]:l.map(c=>{const h=e?[c]:this.graphemeSplit(c),u=this._measureWord(h,o,a);return s=Math.max(u,s),a+=h.length+i.length,{word:h,width:u}})}),largestWordWidth:s}}_measureWord(t,e){let i,s=arguments.length>2&&arguments[2]!==void 0?arguments[2]:0,r=0;for(let o=0,a=t.length;o<a;o++)r+=this._getGraphemeBox(t[o],e,o+s,i,!0).kernedWidth,i=t[o];return r}wordSplit(t){return t.split(this._wordJoiners)}_wrapLine(t,e,i){let{largestWordWidth:s,wordsData:r}=i,o=arguments.length>3&&arguments[3]!==void 0?arguments[3]:0;const a=this._getWidthOfCharSpacing(),l=this.splitByGrapheme,c=[],h=l?"":" ";let u=0,d=[],p=0,g=0,f=!0;e-=o;const m=Math.max(e,s,this.dynamicMinWidth),v=r[t];let y;for(p=0,y=0;y<v.length;y++){const{word:x,width:E}=v[y];p+=x.length,u+=g+E-a,u>m&&!f?(c.push(d),d=[],u=E,f=!0):u+=a,f||l||d.push(h),d=d.concat(x),g=l?0:this._measureWord([h],t,p),p++,f=!1}return y&&c.push(d),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 r=0;r<i.length;r++)s[r]=i[r].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])}}b(ai,"type","Textbox"),b(ai,"textLayoutProperties",[...oi.textLayoutProperties,"width"]),b(ai,"ownDefaults",{minWidth:20,dynamicMinWidth:2,lockScalingFlip:!0,noScaleCache:!1,_wordJoiners:/[ \t\r]/,splitByGrapheme:!1}),R.setClass(ai);class Hc extends xo{shouldPerformLayout(t){return!!t.target.clipPath&&super.shouldPerformLayout(t)}shouldLayoutClipPath(){return!1}calcLayoutResult(t,e){const{target:i}=t,{clipPath:s,group:r}=i;if(!s||!this.shouldPerformLayout(t))return;const{width:o,height:a}=ci(Au(i,s)),l=new w(o,a);if(s.absolutePositioned)return{center:Ts(s.getRelativeCenterPoint(),void 0,r?r.calcTransformMatrix():void 0),size:l};{const c=s.getRelativeCenterPoint().transform(i.calcOwnMatrix(),!0);if(this.shouldPerformLayout(t)){const{center:h=new w,correction:u=new w}=this.calcBoundingBox(e,t)||{};return{center:h.add(c),correction:u.subtract(c),size:l}}return{center:i.getRelativeCenterPoint().add(c),size:l}}}}b(Hc,"type","clip-path"),R.setClass(Hc);class Vc extends xo{getInitialSize(t,e){let{target:i}=t,{size:s}=e;return new w(i.width||s.x,i.height||s.y)}}b(Vc,"type","fixed"),R.setClass(Vc);class Yb extends Sr{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,r)=>(r.parent&&s.add(r.parent),s),new Set).forEach(s=>{!i.some(r=>r.parent===s)&&s.layoutManager.unsubscribeTargets({target:s,targets:[e]})})}}class qi extends Ei{static getDefaults(){return _(_({},super.getDefaults()),qi.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,qi.ownDefaults),this.setOptions(e);const{left:i,top:s,layoutManager:r}=e;this.groupInit(t,{left:i,top:s,layoutManager:r??new Yb})}_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 r=this._objects.findIndex(a=>a.isInFrontOf(s)),o=r===-1?this.size():r;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:r}=s;r&&i.add(r)}),t===dl?i.forEach(s=>{s._onAfterObjectsChange(Un,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=_(_({hasControls:!1},i),{},{forActiveSelection:!0});for(let r=0;r<this._objects.length;r++)this._objects[r]._renderControls(t,s);super._renderControls(t,e),t.restore()}}b(qi,"type","ActiveSelection"),b(qi,"ownDefaults",{multiSelectionStacking:"canvas-stacking"}),R.setClass(qi),R.setClass(qi,"activeSelection");class Xb{constructor(){b(this,"resources",{})}applyFilters(t,e,i,s,r){const o=r.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:r,ctx:o,filterBackend:this};t.forEach(c=>{c.applyTo(a)});const{imageData:l}=a;return l.width===i&&l.height===s||(r.width=l.width,r.height=l.height),o.putImageData(l,0,0),a}}class Ku{constructor(){let{tileSize:t=tt.textureSize}=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};b(this,"aPosition",new Float32Array([0,0,0,1,1,0,1,1])),b(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=Ye({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,r,o){const a=this.gl,l=r.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:r},u=a.createFramebuffer();return a.bindFramebuffer(a.FRAMEBUFFER,u),t.forEach(d=>{d&&d.applyTo(h)}),function(d){const p=d.targetCanvas,g=p.width,f=p.height,m=d.destinationWidth,v=d.destinationHeight;g===m&&f===v||(p.width=m,p.height=v)}(h),this.copyGLTo2D(a,h),a.bindTexture(a.TEXTURE_2D,null),a.deleteTexture(h.sourceTexture),a.deleteTexture(h.targetTexture),a.deleteFramebuffer(u),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,r){const{NEAREST:o,TEXTURE_2D:a,RGBA:l,UNSIGNED_BYTE:c,CLAMP_TO_EDGE:h,TEXTURE_MAG_FILTER:u,TEXTURE_MIN_FILTER:d,TEXTURE_WRAP_S:p,TEXTURE_WRAP_T:g}=t,f=t.createTexture();return t.bindTexture(a,f),t.texParameteri(a,u,r||o),t.texParameteri(a,d,r||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 r=this.createTexture(this.gl,e.width,e.height,e,i);return r&&(s[t]=r),r}}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,r=s.getContext("2d");if(!r)return;r.translate(0,s.height),r.scale(1,-1);const o=i.height-s.height;r.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,r=e.destinationHeight,o=s*r*4;if(!i)return;const a=new Uint8Array(this.imageBuffer,0,o),l=new Uint8ClampedArray(this.imageBuffer,0,o);t.readPixels(0,0,s,r,t.RGBA,t.UNSIGNED_BYTE,a);const c=new ImageData(l,s,r);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),r=t.getParameter(i.UNMASKED_VENDOR_WEBGL);s&&(e.renderer=s.toLowerCase()),r&&(e.vendor=r.toLowerCase())}return this.gpuInfo=e,e}}let Yo;function Kb(){const{WebGLProbe:n}=Ge();return n.queryWebGL(Fe()),tt.enableGLFiltering&&n.isSupported(tt.textureSize)?new Ku({tileSize:tt.textureSize}):new Xb}function Xo(){return!Yo&&(!(arguments.length>0&&arguments[0]!==void 0)||arguments[0])&&(Yo=Kb()),Yo}const qb=["filters","resizeFilter","src","crossOrigin","type"],qu=["cropX","cropY"];class te extends Xt{static getDefaults(){return _(_({},super.getDefaults()),te.ownDefaults)}constructor(t,e){super(),b(this,"_lastScaleX",1),b(this,"_lastScaleY",1),b(this,"_filterScalingX",1),b(this,"_filterScalingY",1),this.filters=[],Object.assign(this,te.ownDefaults),this.setOptions(e),this.cacheKey="texture".concat(Ii()),this.setElement(typeof t=="string"?(this.canvas&&De(this.canvas.getElement())||js()).getElementById(t):t,e)}getElement(){return this._element}setElement(t){let e=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(e),t.classList.add(te.CSS_CANVAS),this.filters.length!==0&&this.applyFilters(),this.resizeFilter&&this.applyResizeFilters()}removeTexture(t){const e=Xo(!1);e instanceof Ku&&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&&Ge().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())}),_(_({},super.toObject([...qu,...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 r=[],o=[],a="",l="";if(!e)return[];if(this.hasCrop()){const c=Ii();r.push('<clipPath id="imageCrop_'+c+`">
|
|
2550
|
+
`,' <rect x="'+i+'" y="'+s+'" width="'+this.width+'" height="'+this.height+`" />
|
|
2536
2551
|
`,`</clipPath>
|
|
2537
|
-
`),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(
|
|
2538
|
-
`)),this.stroke||this.strokeDashArray){const c=this.fill;this.fill=null,o=[' <rect x="'.concat(i,'" y="').concat(
|
|
2539
|
-
`)],this.fill=c}return
|
|
2552
|
+
`),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>
|
|
2553
|
+
`)),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(),`" />
|
|
2554
|
+
`)],this.fill=c}return r=this.paintFirst!==Rt?r.concat(o,t):r.concat(t,o),r}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 En(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,r=i.y,o=this._filteredEl||this._originalElement;if(this.group&&this.set("dirty",!0),!t||s>e&&r>e)return this._element=o,this._filterScalingX=1,this._filterScalingY=1,this._lastScaleX=s,void(this._lastScaleY=r);const a=Ye(o),{width:l,height:c}=o;this._element=a,this._lastScaleX=t.scaleX=s,this._lastScaleY=t.scaleY=r,Xo().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(r=>r&&!r.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 r=Ye({width:i,height:s});this._element=r,this._filteredEl=r}else this._filteredEl&&(this._element=this._filteredEl,this._filteredEl.getContext("2d").clearRect(0,0,i,s),this._lastScaleX=1,this._lastScaleY=1);Xo().applyFilters(t,this._originalElement,i,s,this._element),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,r=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,u=a*i,d=l*s,p=Math.min(r*i,c-u),g=Math.min(o*s,h-d),f=-r/2,m=-o/2,v=Math.min(r,c/i-a),y=Math.min(o,h/s-l);e&&t.drawImage(e,u,d,p,g,f,m,v,y)}_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=Mm(this.preserveAspectRatio||""),e=this.width,i=this.height,s={width:e,height:i};let r,o=this._element.width,a=this._element.height,l=1,c=1,h=0,u=0,d=0,p=0;return!t||t.alignX===ce&&t.alignY===ce?(l=e/o,c=i/a):(t.meetOrSlice==="meet"&&(l=c=eb(this._element,s),r=(e-o*l)/2,t.alignX==="Min"&&(h=-r),t.alignX==="Max"&&(h=r),r=(i-a*c)/2,t.alignY==="Min"&&(u=-r),t.alignY==="Max"&&(u=r)),t.meetOrSlice==="slice"&&(l=c=ib(this._element,s),r=o-e/l,t.alignX==="Mid"&&(d=r/2),t.alignX==="Max"&&(d=r),r=a-i/c,t.alignY==="Mid"&&(p=r/2),t.alignY==="Max"&&(p=r),o=e/l,a=i/c)),{width:o,height:a,scaleX:l,scaleY:c,offsetLeft:h,offsetTop:u,cropX:d,cropY:p}}static fromObject(t,e){let{filters:i,resizeFilter:s,src:r,crossOrigin:o,type:a}=t,l=gt(t,qb);return Promise.all([En(r,_(_({},e),{},{crossOrigin:o})),i&&xr(i,e),s&&xr([s],e),vo(l,e)]).then(c=>{let[h,u=[],[d]=[],p={}]=c;return new this(h,_(_({},l),{},{src:r,filters:u,resizeFilter:d},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 En(t,{crossOrigin:e,signal:i}).then(r=>new this(r,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=vi(t,this.ATTRIBUTE_NAMES,i);return this.fromURL(s["xlink:href"],e,s).catch(r=>(Mi("log","Unable to parse Image",r),null))}}b(te,"type","Image"),b(te,"cacheProperties",[...mi,...qu]),b(te,"ownDefaults",{strokeWidth:0,srcFromAttribute:!1,minimumScaleTrigger:.5,cropX:0,cropY:0,imageSmoothing:!0}),b(te,"CSS_CANVAS","canvas-img"),b(te,"ATTRIBUTE_NAMES",[...Bi,"x","y","width","height","preserveAspectRatio","xlink:href","crossOrigin","image-rendering"]),R.setClass(te),R.setSVGClass(te);_o(["pattern","defs","symbol","metadata","clipPath","mask","desc"]);const Co=n=>n.webgl!==void 0,pl="precision highp float",Zb=`
|
|
2540
2555
|
`.concat(pl,`;
|
|
2541
2556
|
varying vec2 vTexCoord;
|
|
2542
2557
|
uniform sampler2D uTexture;
|
|
2543
2558
|
void main() {
|
|
2544
2559
|
gl_FragColor = texture2D(uTexture, vTexCoord);
|
|
2545
|
-
}`),Jb=["type"],Qb=["type"],t_=new RegExp(pl,"g");class
|
|
2560
|
+
}`),Jb=["type"],Qb=["type"],t_=new RegExp(pl,"g");class $t{get type(){return this.constructor.type}constructor(){let t=gt(arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},Jb);Object.assign(this,this.constructor.defaults,t)}getFragmentSource(){return Zb}getVertexSource(){return`
|
|
2546
2561
|
attribute vec2 aPosition;
|
|
2547
2562
|
varying vec2 vTexCoord;
|
|
2548
2563
|
void main() {
|
|
2549
2564
|
vTexCoord = aPosition;
|
|
2550
2565
|
gl_Position = vec4(aPosition * 2.0 - 1.0, 0.0, 1.0);
|
|
2551
|
-
}`}createProgram(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:this.getFragmentSource(),i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:this.getVertexSource();const{WebGLProbe:{GLPrecision:
|
|
2566
|
+
}`}createProgram(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:this.getFragmentSource(),i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:this.getVertexSource();const{WebGLProbe:{GLPrecision:s="highp"}}=Ge();s!=="highp"&&(e=e.replace(t_,pl.replace("highp",s)));const r=t.createShader(t.VERTEX_SHADER),o=t.createShader(t.FRAGMENT_SHADER),a=t.createProgram();if(!r||!o||!a)throw new ze("Vertex, fragment shader or program creation error");if(t.shaderSource(r,i),t.compileShader(r),!t.getShaderParameter(r,t.COMPILE_STATUS))throw new ze("Vertex shader compile error for ".concat(this.type,": ").concat(t.getShaderInfoLog(r)));if(t.shaderSource(o,e),t.compileShader(o),!t.getShaderParameter(o,t.COMPILE_STATUS))throw new ze("Fragment shader compile error for ".concat(this.type,": ").concat(t.getShaderInfoLog(o)));if(t.attachShader(a,r),t.attachShader(a,o),t.linkProgram(a),!t.getProgramParameter(a,t.LINK_STATUS))throw new ze('Shader link error for "'.concat(this.type,'" ').concat(t.getProgramInfoLog(a)));const l=this.getUniformLocations(t,a)||{};return l.uStepW=t.getUniformLocation(a,"uStepW"),l.uStepH=t.getUniformLocation(a,"uStepH"),{program:a,attributeLocations:this.getAttributeLocations(t,a),uniformLocations:l}}getAttributeLocations(t,e){return{aPosition:t.getAttribLocation(e,"aPosition")}}getUniformLocations(t,e){const i=this.constructor.uniformLocations,s={};for(let r=0;r<i.length;r++)s[i[r]]=t.getUniformLocation(e,i[r]);return s}sendAttributeData(t,e,i){const s=e.aPosition,r=t.createBuffer();t.bindBuffer(t.ARRAY_BUFFER,r),t.enableVertexAttribArray(s),t.vertexAttribPointer(s,2,t.FLOAT,!1,0,0),t.bufferData(t.ARRAY_BUFFER,i,t.STATIC_DRAW)}_setupFrameBuffer(t){const e=t.context;if(t.passes>1){const i=t.destinationWidth,s=t.destinationHeight;t.sourceWidth===i&&t.sourceHeight===s||(e.deleteTexture(t.targetTexture),t.targetTexture=t.filterBackend.createTexture(e,i,s)),e.framebufferTexture2D(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,t.targetTexture,0)}else e.bindFramebuffer(e.FRAMEBUFFER,null),e.finish()}_swapTextures(t){t.passes--,t.pass++;const e=t.targetTexture;t.targetTexture=t.sourceTexture,t.sourceTexture=e}isNeutralState(t){return!1}applyTo(t){Co(t)?(this._setupFrameBuffer(t),this.applyToWebGL(t),this._swapTextures(t)):this.applyTo2d(t)}applyTo2d(t){}getCacheKey(){return this.type}retrieveShader(t){const e=this.getCacheKey();return t.programCache[e]||(t.programCache[e]=this.createProgram(t.context)),t.programCache[e]}applyToWebGL(t){const e=t.context,i=this.retrieveShader(t);t.pass===0&&t.originalTexture?e.bindTexture(e.TEXTURE_2D,t.originalTexture):e.bindTexture(e.TEXTURE_2D,t.sourceTexture),e.useProgram(i.program),this.sendAttributeData(e,i.attributeLocations,t.aPosition),e.uniform1f(i.uniformLocations.uStepW,1/t.sourceWidth),e.uniform1f(i.uniformLocations.uStepH,1/t.sourceHeight),this.sendUniformData(e,i.uniformLocations),e.viewport(0,0,t.destinationWidth,t.destinationHeight),e.drawArrays(e.TRIANGLE_STRIP,0,4)}bindAdditionalTexture(t,e,i){t.activeTexture(i),t.bindTexture(t.TEXTURE_2D,e),t.activeTexture(t.TEXTURE0)}unbindAdditionalTexture(t,e){t.activeTexture(e),t.bindTexture(t.TEXTURE_2D,null),t.activeTexture(t.TEXTURE0)}sendUniformData(t,e){}createHelpLayer(t){if(!t.helpLayer){const{sourceWidth:e,sourceHeight:i}=t,s=Ye({width:e,height:i});t.helpLayer=s}}toObject(){const t=Object.keys(this.constructor.defaults||{});return _({type:this.type},t.reduce((e,i)=>(e[i]=this[i],e),{}))}toJSON(){return this.toObject()}static async fromObject(t,e){return new this(gt(t,Qb))}}b($t,"type","BaseFilter"),b($t,"uniformLocations",[]);const e_={multiply:`gl_FragColor.rgb *= uColor.rgb;
|
|
2552
2567
|
`,screen:`gl_FragColor.rgb = 1.0 - (1.0 - gl_FragColor.rgb) * (1.0 - uColor.rgb);
|
|
2553
2568
|
`,add:`gl_FragColor.rgb += uColor.rgb;
|
|
2554
2569
|
`,difference:`gl_FragColor.rgb = abs(gl_FragColor.rgb - uColor.rgb);
|
|
@@ -2575,7 +2590,7 @@ Resulting to default behavior: removing object from previous canvas and adding t
|
|
|
2575
2590
|
`,tint:`
|
|
2576
2591
|
gl_FragColor.rgb *= (1.0 - uColor.a);
|
|
2577
2592
|
gl_FragColor.rgb += uColor.rgb;
|
|
2578
|
-
`};class sn extends
|
|
2593
|
+
`};class sn extends $t{getCacheKey(){return"".concat(this.type,"_").concat(this.mode)}getFragmentSource(){return`
|
|
2579
2594
|
precision highp float;
|
|
2580
2595
|
uniform sampler2D uTexture;
|
|
2581
2596
|
uniform vec4 uColor;
|
|
@@ -2587,7 +2602,7 @@ Resulting to default behavior: removing object from previous canvas and adding t
|
|
|
2587
2602
|
`.concat(e_[this.mode],`
|
|
2588
2603
|
}
|
|
2589
2604
|
}
|
|
2590
|
-
`)}applyTo2d(t){let{imageData:{data:e}}=t;const i=new
|
|
2605
|
+
`)}applyTo2d(t){let{imageData:{data:e}}=t;const i=new st(this.color).getSource(),s=this.alpha,r=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],u=e[c+1],d=e[c+2];let p,g,f;switch(this.mode){case"multiply":p=h*r/255,g=u*o/255,f=d*a/255;break;case"screen":p=255-(255-h)*(255-r)/255,g=255-(255-u)*(255-o)/255,f=255-(255-d)*(255-a)/255;break;case"add":p=h+r,g=u+o,f=d+a;break;case"difference":p=Math.abs(h-r),g=Math.abs(u-o),f=Math.abs(d-a);break;case"subtract":p=h-r,g=u-o,f=d-a;break;case"darken":p=Math.min(h,r),g=Math.min(u,o),f=Math.min(d,a);break;case"lighten":p=Math.max(h,r),g=Math.max(u,o),f=Math.max(d,a);break;case"overlay":p=r<128?2*h*r/255:255-2*(255-h)*(255-r)/255,g=o<128?2*u*o/255:255-2*(255-u)*(255-o)/255,f=a<128?2*d*a/255:255-2*(255-d)*(255-a)/255;break;case"exclusion":p=r+h-2*r*h/255,g=o+u-2*o*u/255,f=a+d-2*a*d/255;break;case"tint":p=r+h*l,g=o+u*l,f=a+d*l}e[c]=p,e[c+1]=g,e[c+2]=f}}sendUniformData(t,e){const i=new st(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)}}b(sn,"defaults",{color:"#F95C63",mode:"multiply",alpha:1}),b(sn,"type","BlendColor"),b(sn,"uniformLocations",["uColor"]),R.setClass(sn);const i_={multiply:`
|
|
2591
2606
|
precision highp float;
|
|
2592
2607
|
uniform sampler2D uTexture;
|
|
2593
2608
|
uniform sampler2D uImage;
|
|
@@ -2613,7 +2628,7 @@ Resulting to default behavior: removing object from previous canvas and adding t
|
|
|
2613
2628
|
color.a = color2.a;
|
|
2614
2629
|
gl_FragColor = color;
|
|
2615
2630
|
}
|
|
2616
|
-
`},
|
|
2631
|
+
`},s_=["type","image"];class rn extends $t{getCacheKey(){return"".concat(this.type,"_").concat(this.mode)}getFragmentSource(){return i_[this.mode]}getVertexSource(){return`
|
|
2617
2632
|
attribute vec2 aPosition;
|
|
2618
2633
|
varying vec2 vTexCoord;
|
|
2619
2634
|
varying vec2 vTexCoord2;
|
|
@@ -2623,7 +2638,7 @@ Resulting to default behavior: removing object from previous canvas and adding t
|
|
|
2623
2638
|
vTexCoord2 = (uTransformMatrix * vec3(aPosition, 1.0)).xy;
|
|
2624
2639
|
gl_Position = vec4(aPosition * 2.0 - 1.0, 0.0, 1.0);
|
|
2625
2640
|
}
|
|
2626
|
-
`}applyToWebGL(t){const e=t.context,i=this.createTexture(t.filterBackend,this.image);this.bindAdditionalTexture(e,i,e.TEXTURE1),super.applyToWebGL(t),this.unbindAdditionalTexture(e,e.TEXTURE1)}createTexture(t,e){return t.getCachedTexture(e.cacheKey,e.getElement())}calculateMatrix(){const t=this.image,{width:e,height:i}=t.getElement();return[1/t.scaleX,0,0,0,1/t.scaleY,0,-t.left/e,-t.top/i,1]}applyTo2d(t){let{imageData:{data:e,width:i,height:
|
|
2641
|
+
`}applyToWebGL(t){const e=t.context,i=this.createTexture(t.filterBackend,this.image);this.bindAdditionalTexture(e,i,e.TEXTURE1),super.applyToWebGL(t),this.unbindAdditionalTexture(e,e.TEXTURE1)}createTexture(t,e){return t.getCachedTexture(e.cacheKey,e.getElement())}calculateMatrix(){const t=this.image,{width:e,height:i}=t.getElement();return[1/t.scaleX,0,0,0,1/t.scaleY,0,-t.left/e,-t.top/i,1]}applyTo2d(t){let{imageData:{data:e,width:i,height:s},filterBackend:{resources:r}}=t;const o=this.image;r.blendImage||(r.blendImage=Fe());const a=r.blendImage,l=a.getContext("2d");a.width!==i||a.height!==s?(a.width=i,a.height=s):l.clearRect(0,0,i,s),l.setTransform(o.scaleX,0,0,o.scaleY,o.left,o.top),l.drawImage(o.getElement(),0,0,i,s);const c=l.getImageData(0,0,i,s).data;for(let h=0;h<e.length;h+=4){const u=e[h],d=e[h+1],p=e[h+2],g=e[h+3],f=c[h],m=c[h+1],v=c[h+2],y=c[h+3];switch(this.mode){case"multiply":e[h]=u*f/255,e[h+1]=d*m/255,e[h+2]=p*v/255,e[h+3]=g*y/255;break;case"mask":e[h+3]=y}}}sendUniformData(t,e){const i=this.calculateMatrix();t.uniform1i(e.uImage,1),t.uniformMatrix3fv(e.uTransformMatrix,!1,i)}toObject(){return _(_({},super.toObject()),{},{image:this.image&&this.image.toObject()})}static async fromObject(t,e){let{type:i,image:s}=t,r=gt(t,s_);return te.fromObject(s,e).then(o=>new this(_(_({},r),{},{image:o})))}}b(rn,"type","BlendImage"),b(rn,"defaults",{mode:"multiply",alpha:1}),b(rn,"uniformLocations",["uTransformMatrix","uImage"]),R.setClass(rn);class nn extends $t{getFragmentSource(){return`
|
|
2627
2642
|
precision highp float;
|
|
2628
2643
|
uniform sampler2D uTexture;
|
|
2629
2644
|
uniform vec2 uDelta;
|
|
@@ -2646,7 +2661,7 @@ Resulting to default behavior: removing object from previous canvas and adding t
|
|
|
2646
2661
|
}
|
|
2647
2662
|
gl_FragColor = color / total;
|
|
2648
2663
|
}
|
|
2649
|
-
`}applyTo(t){
|
|
2664
|
+
`}applyTo(t){Co(t)?(this.aspectRatio=t.sourceWidth/t.sourceHeight,t.passes++,this._setupFrameBuffer(t),this.horizontal=!0,this.applyToWebGL(t),this._swapTextures(t),this._setupFrameBuffer(t),this.horizontal=!1,this.applyToWebGL(t),this._swapTextures(t)):this.applyTo2d(t)}applyTo2d(t){t.imageData=this.simpleBlur(t)}simpleBlur(t){let{ctx:e,imageData:i,filterBackend:{resources:s}}=t;const{width:r,height:o}=i;s.blurLayer1||(s.blurLayer1=Fe(),s.blurLayer2=Fe());const a=s.blurLayer1,l=s.blurLayer2;a.width===r&&a.height===o||(l.width=a.width=r,l.height=a.height=o);const c=a.getContext("2d"),h=l.getContext("2d"),u=15,d=.06*this.blur*.5;let p,g,f,m;for(c.putImageData(i,0,0),h.clearRect(0,0,r,o),m=-15;m<=u;m++)p=(Math.random()-.5)/4,g=m/u,f=d*g*r+p,h.globalAlpha=1-Math.abs(g),h.drawImage(a,f,p),c.drawImage(l,0,0),h.globalAlpha=1,h.clearRect(0,0,l.width,l.height);for(m=-15;m<=u;m++)p=(Math.random()-.5)/4,g=m/u,f=d*g*o+p,h.globalAlpha=1-Math.abs(g),h.drawImage(a,p,f),c.drawImage(l,0,0),h.globalAlpha=1,h.clearRect(0,0,l.width,l.height);e.drawImage(a,0,0);const v=e.getImageData(0,0,a.width,a.height);return c.globalAlpha=1,c.clearRect(0,0,a.width,a.height),v}sendUniformData(t,e){const i=this.chooseRightDelta();t.uniform2fv(e.uDelta,i)}isNeutralState(){return this.blur===0}chooseRightDelta(){let t=1;const e=[0,0];this.horizontal?this.aspectRatio>1&&(t=1/this.aspectRatio):this.aspectRatio<1&&(t=this.aspectRatio);const i=t*this.blur*.12;return this.horizontal?e[0]=i:e[1]=i,e}}b(nn,"type","Blur"),b(nn,"defaults",{blur:0}),b(nn,"uniformLocations",["uDelta"]),R.setClass(nn);class on extends $t{getFragmentSource(){return`
|
|
2650
2665
|
precision highp float;
|
|
2651
2666
|
uniform sampler2D uTexture;
|
|
2652
2667
|
uniform float uBrightness;
|
|
@@ -2656,7 +2671,7 @@ Resulting to default behavior: removing object from previous canvas and adding t
|
|
|
2656
2671
|
color.rgb += uBrightness;
|
|
2657
2672
|
gl_FragColor = color;
|
|
2658
2673
|
}
|
|
2659
|
-
`}applyTo2d(t){let{imageData:{data:e}}=t;const i=Math.round(255*this.brightness);for(let
|
|
2674
|
+
`}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)}}b(on,"type","Brightness"),b(on,"defaults",{brightness:0}),b(on,"uniformLocations",["uBrightness"]),R.setClass(on);const Zu={matrix:[1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1,0],colorsOnly:!0};class xs extends $t{getFragmentSource(){return`
|
|
2660
2675
|
precision highp float;
|
|
2661
2676
|
uniform sampler2D uTexture;
|
|
2662
2677
|
varying vec2 vTexCoord;
|
|
@@ -2667,7 +2682,7 @@ Resulting to default behavior: removing object from previous canvas and adding t
|
|
|
2667
2682
|
color *= uColorMatrix;
|
|
2668
2683
|
color += uConstants;
|
|
2669
2684
|
gl_FragColor = color;
|
|
2670
|
-
}`}applyTo2d(t){const e=t.imageData.data,i=this.matrix,
|
|
2685
|
+
}`}applyTo2d(t){const e=t.imageData.data,i=this.matrix,s=this.colorsOnly;for(let r=0;r<e.length;r+=4){const o=e[r],a=e[r+1],l=e[r+2];if(e[r]=o*i[0]+a*i[1]+l*i[2]+255*i[4],e[r+1]=o*i[5]+a*i[6]+l*i[7]+255*i[9],e[r+2]=o*i[10]+a*i[11]+l*i[12]+255*i[14],!s){const c=e[r+3];e[r]+=c*i[3],e[r+1]+=c*i[8],e[r+2]+=c*i[13],e[r+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]],r=[i[4],i[9],i[14],i[19]];t.uniformMatrix4fv(e.uColorMatrix,!1,s),t.uniform4fv(e.uConstants,r)}toObject(){return _(_({},super.toObject()),{},{matrix:[...this.matrix]})}}function cs(n,t){var e;const i=(b(e=class extends xs{toObject(){return{type:this.type,colorsOnly:this.colorsOnly}}},"type",n),b(e,"defaults",{colorsOnly:!1,matrix:t}),e);return R.setClass(i,n),i}b(xs,"type","ColorMatrix"),b(xs,"defaults",Zu),b(xs,"uniformLocations",["uColorMatrix","uConstants"]),R.setClass(xs);cs("Brownie",[.5997,.34553,-.27082,0,.186,-.0377,.86095,.15059,0,-.1449,.24113,-.07441,.44972,0,-.02965,0,0,0,1,0]);cs("Vintage",[.62793,.32021,-.03965,0,.03784,.02578,.64411,.03259,0,.02926,.0466,-.08512,.52416,0,.02023,0,0,0,1,0]);cs("Kodachrome",[1.12855,-.39673,-.03992,0,.24991,-.16404,1.08352,-.05498,0,.09698,-.16786,-.56034,1.60148,0,.13972,0,0,0,1,0]);cs("Technicolor",[1.91252,-.85453,-.09155,0,.04624,-.30878,1.76589,-.10601,0,-.27589,-.2311,-.75018,1.84759,0,.12137,0,0,0,1,0]);cs("Polaroid",[1.438,-.062,-.062,0,0,-.122,1.378,-.122,0,0,-.016,-.016,1.483,0,0,0,0,0,1,0]);cs("Sepia",[.393,.769,.189,0,0,.349,.686,.168,0,0,.272,.534,.131,0,0,0,0,0,1,0]);cs("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 Uc extends $t{constructor(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};super(t),this.subFilters=t.subFilters||[]}applyTo(t){Co(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=>R.getClass(i.type).fromObject(i,e))).then(i=>new this({subFilters:i}))}}b(Uc,"type","Composed"),R.setClass(Uc);class an extends $t{getFragmentSource(){return`
|
|
2671
2686
|
precision highp float;
|
|
2672
2687
|
uniform sampler2D uTexture;
|
|
2673
2688
|
uniform float uContrast;
|
|
@@ -2677,7 +2692,7 @@ Resulting to default behavior: removing object from previous canvas and adding t
|
|
|
2677
2692
|
float contrastF = 1.015 * (uContrast + 1.0) / (1.0 * (1.015 - uContrast));
|
|
2678
2693
|
color.rgb = contrastF * (color.rgb - 0.5) + 0.5;
|
|
2679
2694
|
gl_FragColor = color;
|
|
2680
|
-
}`}isNeutralState(){return this.contrast===0}applyTo2d(t){let{imageData:{data:e}}=t;const i=Math.floor(255*this.contrast),
|
|
2695
|
+
}`}isNeutralState(){return this.contrast===0}applyTo2d(t){let{imageData:{data:e}}=t;const i=Math.floor(255*this.contrast),s=259*(i+255)/(255*(259-i));for(let r=0;r<e.length;r+=4)e[r]=s*(e[r]-128)+128,e[r+1]=s*(e[r+1]-128)+128,e[r+2]=s*(e[r+2]-128)+128}sendUniformData(t,e){t.uniform1f(e.uContrast,this.contrast)}}b(an,"type","Contrast"),b(an,"defaults",{contrast:0}),b(an,"uniformLocations",["uContrast"]),R.setClass(an);const r_={Convolute_3_1:`
|
|
2681
2696
|
precision highp float;
|
|
2682
2697
|
uniform sampler2D uTexture;
|
|
2683
2698
|
uniform float uMatrix[9];
|
|
@@ -2821,7 +2836,7 @@ Resulting to default behavior: removing object from previous canvas and adding t
|
|
|
2821
2836
|
gl_FragColor = color;
|
|
2822
2837
|
gl_FragColor.a = alpha;
|
|
2823
2838
|
}
|
|
2824
|
-
`};class
|
|
2839
|
+
`};class ln extends $t{getCacheKey(){return"".concat(this.type,"_").concat(Math.sqrt(this.matrix.length),"_").concat(this.opaque?1:0)}getFragmentSource(){return r_[this.getCacheKey()]}applyTo2d(t){const e=t.imageData,i=e.data,s=this.matrix,r=Math.round(Math.sqrt(s.length)),o=Math.floor(r/2),a=e.width,l=e.height,c=t.ctx.createImageData(a,l),h=c.data,u=this.opaque?1:0;let d,p,g,f,m,v,y,x,E,O,D,C,T;for(D=0;D<l;D++)for(O=0;O<a;O++){for(m=4*(D*a+O),d=0,p=0,g=0,f=0,T=0;T<r;T++)for(C=0;C<r;C++)y=D+T-o,v=O+C-o,y<0||y>=l||v<0||v>=a||(x=4*(y*a+v),E=s[T*r+C],d+=i[x]*E,p+=i[x+1]*E,g+=i[x+2]*E,u||(f+=i[x+3]*E));h[m]=d,h[m+1]=p,h[m+2]=g,h[m+3]=u?i[m+3]:f}t.imageData=c}sendUniformData(t,e){t.uniform1fv(e.uMatrix,this.matrix)}toObject(){return _(_({},super.toObject()),{},{opaque:this.opaque,matrix:[...this.matrix]})}}b(ln,"type","Convolute"),b(ln,"defaults",{opaque:!1,matrix:[0,0,0,0,1,0,0,0,0]}),b(ln,"uniformLocations",["uMatrix","uOpaque","uHalfSize","uSize"]),R.setClass(ln);const Ju="Gamma";class cn extends $t{getFragmentSource(){return`
|
|
2825
2840
|
precision highp float;
|
|
2826
2841
|
uniform sampler2D uTexture;
|
|
2827
2842
|
uniform vec3 uGamma;
|
|
@@ -2835,7 +2850,7 @@ Resulting to default behavior: removing object from previous canvas and adding t
|
|
|
2835
2850
|
gl_FragColor = color;
|
|
2836
2851
|
gl_FragColor.rgb *= color.a;
|
|
2837
2852
|
}
|
|
2838
|
-
`}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,
|
|
2853
|
+
`}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],r=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,r),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:Ju,gamma:this.gamma.concat()}}}b(cn,"type",Ju),b(cn,"defaults",{gamma:[1,1,1]}),b(cn,"uniformLocations",["uGamma"]),R.setClass(cn);const n_={average:`
|
|
2839
2854
|
precision highp float;
|
|
2840
2855
|
uniform sampler2D uTexture;
|
|
2841
2856
|
varying vec2 vTexCoord;
|
|
@@ -2864,7 +2879,7 @@ Resulting to default behavior: removing object from previous canvas and adding t
|
|
|
2864
2879
|
float average = 0.21 * col.r + 0.72 * col.g + 0.07 * col.b;
|
|
2865
2880
|
gl_FragColor = vec4(average, average, average, col.a);
|
|
2866
2881
|
}
|
|
2867
|
-
`};class
|
|
2882
|
+
`};class hn extends $t{applyTo2d(t){let{imageData:{data:e}}=t;for(let i,s=0;s<e.length;s+=4){const r=e[s],o=e[s+1],a=e[s+2];switch(this.mode){case"average":i=(r+o+a)/3;break;case"lightness":i=(Math.min(r,o,a)+Math.max(r,o,a))/2;break;case"luminosity":i=.21*r+.72*o+.07*a}e[s+2]=e[s+1]=e[s]=i}}getCacheKey(){return"".concat(this.type,"_").concat(this.mode)}getFragmentSource(){return n_[this.mode]}sendUniformData(t,e){t.uniform1i(e.uMode,1)}isNeutralState(){return!1}}b(hn,"type","Grayscale"),b(hn,"defaults",{mode:"average"}),b(hn,"uniformLocations",["uMode"]),R.setClass(hn);const o_=_(_({},Zu),{},{rotation:0});class Ko extends xs{calculateMatrix(){const t=this.rotation*Math.PI,e=pi(t),i=gi(t),s=1/3,r=Math.sqrt(s)*i,o=1-e;this.matrix=[e+o/3,s*o-r,s*o+r,0,0,s*o+r,e+s*o,s*o-r,0,0,s*o-r,s*o+r,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}}}b(Ko,"type","HueRotation"),b(Ko,"defaults",o_),R.setClass(Ko);class un extends $t{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`
|
|
2868
2883
|
precision highp float;
|
|
2869
2884
|
uniform sampler2D uTexture;
|
|
2870
2885
|
uniform int uInvert;
|
|
@@ -2882,7 +2897,7 @@ Resulting to default behavior: removing object from previous canvas and adding t
|
|
|
2882
2897
|
gl_FragColor = color;
|
|
2883
2898
|
}
|
|
2884
2899
|
}
|
|
2885
|
-
`}isNeutralState(){return!this.invert}sendUniformData(t,e){t.uniform1i(e.uInvert,Number(this.invert)),t.uniform1i(e.uAlpha,Number(this.alpha))}}b(
|
|
2900
|
+
`}isNeutralState(){return!this.invert}sendUniformData(t,e){t.uniform1i(e.uInvert,Number(this.invert)),t.uniform1i(e.uAlpha,Number(this.alpha))}}b(un,"type","Invert"),b(un,"defaults",{alpha:!1,invert:!0}),b(un,"uniformLocations",["uInvert","uAlpha"]),R.setClass(un);class dn extends $t{getFragmentSource(){return`
|
|
2886
2901
|
precision highp float;
|
|
2887
2902
|
uniform sampler2D uTexture;
|
|
2888
2903
|
uniform float uStepH;
|
|
@@ -2897,7 +2912,7 @@ Resulting to default behavior: removing object from previous canvas and adding t
|
|
|
2897
2912
|
color.rgb += (0.5 - rand(vTexCoord, uSeed, 0.1 / uStepH)) * uNoise;
|
|
2898
2913
|
gl_FragColor = color;
|
|
2899
2914
|
}
|
|
2900
|
-
`}applyTo2d(t){let{imageData:{data:e}}=t;const i=this.noise;for(let
|
|
2915
|
+
`}applyTo2d(t){let{imageData:{data:e}}=t;const i=this.noise;for(let s=0;s<e.length;s+=4){const r=(.5-Math.random())*i;e[s]+=r,e[s+1]+=r,e[s+2]+=r}}sendUniformData(t,e){t.uniform1f(e.uNoise,this.noise/255),t.uniform1f(e.uSeed,Math.random())}isNeutralState(){return this.noise===0}}b(dn,"type","Noise"),b(dn,"defaults",{noise:0}),b(dn,"uniformLocations",["uNoise","uSeed"]),R.setClass(dn);class pn extends $t{applyTo2d(t){let{imageData:{data:e,width:i,height:s}}=t;for(let r=0;r<s;r+=this.blocksize)for(let o=0;o<i;o+=this.blocksize){const a=4*r*i+4*o,l=e[a],c=e[a+1],h=e[a+2],u=e[a+3];for(let d=r;d<Math.min(r+this.blocksize,s);d++)for(let p=o;p<Math.min(o+this.blocksize,i);p++){const g=4*d*i+4*p;e[g]=l,e[g+1]=c,e[g+2]=h,e[g+3]=u}}}isNeutralState(){return this.blocksize===1}getFragmentSource(){return`
|
|
2901
2916
|
precision highp float;
|
|
2902
2917
|
uniform sampler2D uTexture;
|
|
2903
2918
|
uniform float uBlocksize;
|
|
@@ -2915,7 +2930,7 @@ Resulting to default behavior: removing object from previous canvas and adding t
|
|
|
2915
2930
|
vec4 color = texture2D(uTexture, squareCoords);
|
|
2916
2931
|
gl_FragColor = color;
|
|
2917
2932
|
}
|
|
2918
|
-
`}sendUniformData(t,e){t.uniform1f(e.uBlocksize,this.blocksize)}}b(
|
|
2933
|
+
`}sendUniformData(t,e){t.uniform1f(e.uBlocksize,this.blocksize)}}b(pn,"type","Pixelate"),b(pn,"defaults",{blocksize:4}),b(pn,"uniformLocations",["uBlocksize"]),R.setClass(pn);class gn extends $t{getFragmentSource(){return`
|
|
2919
2934
|
precision highp float;
|
|
2920
2935
|
uniform sampler2D uTexture;
|
|
2921
2936
|
uniform vec4 uLow;
|
|
@@ -2927,7 +2942,7 @@ void main() {
|
|
|
2927
2942
|
gl_FragColor.a = 0.0;
|
|
2928
2943
|
}
|
|
2929
2944
|
}
|
|
2930
|
-
`}applyTo2d(t){let{imageData:{data:e}}=t;const i=255*this.distance,
|
|
2945
|
+
`}applyTo2d(t){let{imageData:{data:e}}=t;const i=255*this.distance,s=new st(this.color).getSource(),r=[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>r[0]&&c>r[1]&&h>r[2]&&l<o[0]&&c<o[1]&&h<o[2]&&(e[a+3]=0)}}sendUniformData(t,e){const i=new st(this.color).getSource(),s=this.distance,r=[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,r),t.uniform4fv(e.uHigh,o)}}b(gn,"type","RemoveColor"),b(gn,"defaults",{color:"#FFFFFF",distance:.02,useAlpha:!1}),b(gn,"uniformLocations",["uLow","uHigh"]),R.setClass(gn);class fn extends $t{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 r=1;r<=i;r++)s[r-1]=t(r*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`
|
|
2931
2946
|
precision highp float;
|
|
2932
2947
|
uniform sampler2D uTexture;
|
|
2933
2948
|
uniform vec2 uDelta;
|
|
@@ -2936,14 +2951,14 @@ void main() {
|
|
|
2936
2951
|
void main() {
|
|
2937
2952
|
vec4 color = texture2D(uTexture, vTexCoord);
|
|
2938
2953
|
float sum = 1.0;
|
|
2939
|
-
`).concat(e.map((i,
|
|
2940
|
-
color += texture2D(uTexture, vTexCoord + `.concat(i,") * uTaps[").concat(
|
|
2941
|
-
sum += 2.0 * uTaps[`).concat(
|
|
2954
|
+
`).concat(e.map((i,s)=>`
|
|
2955
|
+
color += texture2D(uTexture, vTexCoord + `.concat(i,") * uTaps[").concat(s,"] + texture2D(uTexture, vTexCoord - ").concat(i,") * uTaps[").concat(s,`];
|
|
2956
|
+
sum += 2.0 * uTaps[`).concat(s,`];
|
|
2942
2957
|
`)).join(`
|
|
2943
2958
|
`),`
|
|
2944
2959
|
gl_FragColor = color / sum;
|
|
2945
2960
|
}
|
|
2946
|
-
`)}applyToForWebgl(t){t.passes++,this.width=t.sourceWidth,this.horizontal=!0,this.dW=Math.round(this.width*this.scaleX),this.dH=t.sourceHeight,this.tempScale=this.dW/this.width,this.taps=this.getTaps(),t.destinationWidth=this.dW,super.applyTo(t),t.sourceWidth=t.destinationWidth,this.height=t.sourceHeight,this.horizontal=!1,this.dH=Math.round(this.height*this.scaleY),this.tempScale=this.dH/this.height,this.taps=this.getTaps(),t.destinationHeight=this.dH,super.applyTo(t),t.sourceHeight=t.destinationHeight}applyTo(t){
|
|
2961
|
+
`)}applyToForWebgl(t){t.passes++,this.width=t.sourceWidth,this.horizontal=!0,this.dW=Math.round(this.width*this.scaleX),this.dH=t.sourceHeight,this.tempScale=this.dW/this.width,this.taps=this.getTaps(),t.destinationWidth=this.dW,super.applyTo(t),t.sourceWidth=t.destinationWidth,this.height=t.sourceHeight,this.horizontal=!1,this.dH=Math.round(this.height*this.scaleY),this.tempScale=this.dH/this.height,this.taps=this.getTaps(),t.destinationHeight=this.dH,super.applyTo(t),t.sourceHeight=t.destinationHeight}applyTo(t){Co(t)?this.applyToForWebgl(t):this.applyTo2d(t)}isNeutralState(){return this.scaleX===1&&this.scaleY===1}lanczosCreate(t){return e=>{if(e>=t||e<=-t)return 0;if(e<11920929e-14&&e>-11920929e-14)return 1;const i=(e*=Math.PI)/t;return Math.sin(e)/e*Math.sin(i)/i}}applyTo2d(t){const e=t.imageData,i=this.scaleX,s=this.scaleY;this.rcpScaleX=1/i,this.rcpScaleY=1/s;const r=e.width,o=e.height,a=Math.round(r*i),l=Math.round(o*s);let c;c=this.resizeType==="sliceHack"?this.sliceByTwo(t,r,o,a,l):this.resizeType==="hermite"?this.hermiteFastResize(t,r,o,a,l):this.resizeType==="bilinear"?this.bilinearFiltering(t,r,o,a,l):this.resizeType==="lanczos"?this.lanczosResize(t,r,o,a,l):new ImageData(a,l),t.imageData=c}sliceByTwo(t,e,i,s,r){const o=t.imageData,a=.5;let l=!1,c=!1,h=e*a,u=i*a;const d=t.filterBackend.resources;let p=0,g=0;const f=e;let m=0;d.sliceByTwo||(d.sliceByTwo=Fe());const v=d.sliceByTwo;(v.width<1.5*e||v.height<i)&&(v.width=1.5*e,v.height=i);const y=v.getContext("2d");for(y.clearRect(0,0,1.5*e,i),y.putImageData(o,0,0),s=Math.floor(s),r=Math.floor(r);!l||!c;)e=h,i=u,s<Math.floor(h*a)?h=Math.floor(h*a):(h=s,l=!0),r<Math.floor(u*a)?u=Math.floor(u*a):(u=r,c=!0),y.drawImage(v,p,g,e,i,f,m,h,u),p=f,g=m,m+=u;return y.getImageData(p,g,s,r)}lanczosResize(t,e,i,s,r){const o=t.imageData.data,a=t.ctx.createImageData(s,r),l=a.data,c=this.lanczosCreate(this.lanczosLobes),h=this.rcpScaleX,u=this.rcpScaleY,d=2/this.rcpScaleX,p=2/this.rcpScaleY,g=Math.ceil(h*this.lanczosLobes/2),f=Math.ceil(u*this.lanczosLobes/2),m={},v={x:0,y:0},y={x:0,y:0};return function x(E){let O,D,C,T,F,j,A,k,P,L,z;for(v.x=(E+.5)*h,y.x=Math.floor(v.x),O=0;O<r;O++){for(v.y=(O+.5)*u,y.y=Math.floor(v.y),F=0,j=0,A=0,k=0,P=0,D=y.x-g;D<=y.x+g;D++)if(!(D<0||D>=e)){L=Math.floor(1e3*Math.abs(D-v.x)),m[L]||(m[L]={});for(let X=y.y-f;X<=y.y+f;X++)X<0||X>=i||(z=Math.floor(1e3*Math.abs(X-v.y)),m[L][z]||(m[L][z]=c(Math.sqrt(Math.pow(L*d,2)+Math.pow(z*p,2))/1e3)),C=m[L][z],C>0&&(T=4*(X*e+D),F+=C,j+=C*o[T],A+=C*o[T+1],k+=C*o[T+2],P+=C*o[T+3]))}T=4*(O*s+E),l[T]=j/F,l[T+1]=A/F,l[T+2]=k/F,l[T+3]=P/F}return++E<s?x(E):a}(0)}bilinearFiltering(t,e,i,s,r){let o,a,l,c,h,u,d,p,g,f,m,v,y,x=0;const E=this.rcpScaleX,O=this.rcpScaleY,D=4*(e-1),C=t.imageData.data,T=t.ctx.createImageData(s,r),F=T.data;for(d=0;d<r;d++)for(p=0;p<s;p++)for(h=Math.floor(E*p),u=Math.floor(O*d),g=E*p-h,f=O*d-u,y=4*(u*e+h),m=0;m<4;m++)o=C[y+m],a=C[y+4+m],l=C[y+D+m],c=C[y+D+4+m],v=o*(1-g)*(1-f)+a*g*(1-f)+l*f*(1-g)+c*g*f,F[x++]=v;return T}hermiteFastResize(t,e,i,s,r){const o=this.rcpScaleX,a=this.rcpScaleY,l=Math.ceil(o/2),c=Math.ceil(a/2),h=t.imageData.data,u=t.ctx.createImageData(s,r),d=u.data;for(let p=0;p<r;p++)for(let g=0;g<s;g++){const f=4*(g+p*s);let m=0,v=0,y=0,x=0,E=0,O=0,D=0;const C=(p+.5)*a;for(let T=Math.floor(p*a);T<(p+1)*a;T++){const F=Math.abs(C-(T+.5))/c,j=(g+.5)*o,A=F*F;for(let k=Math.floor(g*o);k<(g+1)*o;k++){let P=Math.abs(j-(k+.5))/l;const L=Math.sqrt(A+P*P);L>1&&L<-1||(m=2*L*L*L-3*L*L+1,m>0&&(P=4*(k+T*e),D+=m*h[P+3],y+=m,h[P+3]<255&&(m=m*h[P+3]/250),x+=m*h[P],E+=m*h[P+1],O+=m*h[P+2],v+=m))}}d[f]=x/v,d[f+1]=E/v,d[f+2]=O/v,d[f+3]=D/y}return u}}b(fn,"type","Resize"),b(fn,"defaults",{resizeType:"hermite",scaleX:1,scaleY:1,lanczosLobes:3}),b(fn,"uniformLocations",["uDelta","uTaps"]),R.setClass(fn);class mn extends $t{getFragmentSource(){return`
|
|
2947
2962
|
precision highp float;
|
|
2948
2963
|
uniform sampler2D uTexture;
|
|
2949
2964
|
uniform float uSaturation;
|
|
@@ -2957,7 +2972,7 @@ void main() {
|
|
|
2957
2972
|
color.b += rgbMax != color.b ? (rgbMax - color.b) * uSaturation : 0.00;
|
|
2958
2973
|
gl_FragColor = color;
|
|
2959
2974
|
}
|
|
2960
|
-
`}applyTo2d(t){let{imageData:{data:e}}=t;const i=-this.saturation;for(let
|
|
2975
|
+
`}applyTo2d(t){let{imageData:{data:e}}=t;const i=-this.saturation;for(let s=0;s<e.length;s+=4){const r=e[s],o=e[s+1],a=e[s+2],l=Math.max(r,o,a);e[s]+=l!==r?(l-r)*i:0,e[s+1]+=l!==o?(l-o)*i:0,e[s+2]+=l!==a?(l-a)*i:0}}sendUniformData(t,e){t.uniform1f(e.uSaturation,-this.saturation)}isNeutralState(){return this.saturation===0}}b(mn,"type","Saturation"),b(mn,"defaults",{saturation:0}),b(mn,"uniformLocations",["uSaturation"]),R.setClass(mn);class vn extends $t{getFragmentSource(){return`
|
|
2961
2976
|
precision highp float;
|
|
2962
2977
|
uniform sampler2D uTexture;
|
|
2963
2978
|
uniform float uVibrance;
|
|
@@ -2972,16 +2987,16 @@ void main() {
|
|
|
2972
2987
|
color.b += max != color.b ? (max - color.b) * amt : 0.00;
|
|
2973
2988
|
gl_FragColor = color;
|
|
2974
2989
|
}
|
|
2975
|
-
`}applyTo2d(t){let{imageData:{data:e}}=t;const i=-this.vibrance;for(let
|
|
2976
|
-
`)),this.updateTextAreaPosition(),this.canvas.renderAll()}}async handleBackgroundImageUrlChange(){this.canvas&&(this.backgroundFabImg&&this.canvas.remove(this.backgroundFabImg),this.imgLoading=!0,await this.appendBackgroundImageToCanvas(this.backgroundImageUrl||"https://cdn.shopify.com/s/files/1/1956/2323/files/insert_86e8bcd5-3e82-4910-b350-485fa6958502.png?v=1726598821",()=>{this.imgLoading=!1}),this.updateTextAreaPosition(),this.canvas.renderAll())}updateTextAreaPosition(){this.areaPosition={left:.084*this.canvas.getWidth(),top:.4874*this.canvas.getHeight()},this.areaSize={width:.832*this.canvas.getWidth(),height:this.canvas.getHeight()-this.areaPosition.top-this.areaPosition.left},this.rect?(this.rect.set("left",this.areaPosition.left),this.rect.set("top",this.areaPosition.top),this.rect.set("width",this.areaSize.width),this.rect.set("height",this.areaSize.height)):(this.rect=new Ht({left:this.areaPosition.left,top:this.areaPosition.top,width:this.areaSize.width,height:this.areaSize.height,selectable:!1,fill:"rgba(255, 255, 255, 0)"}),this.canvas.add(this.rect)),this.textBox?(this.textBox.set("left",this.areaPosition.left),this.textBox.set("top",this.areaPosition.top),this.textBox.set("width",this.areaSize.width),this.textBox.set("height",this.areaSize.height),this.textBox.set("lineHeight",1.1),this.textBox.set("fontSize",this.areaSize.height/13/1.1)):(this.textBox=new
|
|
2990
|
+
`}applyTo2d(t){let{imageData:{data:e}}=t;const i=-this.vibrance;for(let s=0;s<e.length;s+=4){const r=e[s],o=e[s+1],a=e[s+2],l=Math.max(r,o,a),c=(r+o+a)/3,h=2*Math.abs(l-c)/255*i;e[s]+=l!==r?(l-r)*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}}b(vn,"type","Vibrance"),b(vn,"defaults",{vibrance:0}),b(vn,"uniformLocations",["uVibrance"]),R.setClass(vn);var a_=Object.defineProperty,l_=Object.getOwnPropertyDescriptor,Ft=(n,t,e,i)=>{for(var s=i>1?void 0:i?l_(t,e):t,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(t,e,s):o(s))||s);return i&&s&&a_(t,e,s),s};let yt=class extends Pt{constructor(){super(...arguments),this.backgroundImageUrl=void 0,this.message="",this.font="Arial",this.color="#000",this.alignment="left",this.backgroundImage=void 0,this.backgroundFabImg=void 0,this.rect=void 0,this.textBox=void 0,this.areaPosition={left:0,top:0},this.imgLoading=!1,this.areaSize={width:0,height:0}}handleAlignmentChange(t,e){t!==e&&this.textBox&&(this.textBox.set("textAlign",e),this.canvas.renderAll())}handleColorChange(t,e){t!==e&&this.textBox&&(this.textBox.set("fill",e),this.canvas.renderAll())}handleFontChange(t,e){t!==e&&this.textBox&&(this.textBox.set("fontFamily",e),this.canvas.renderAll())}handleMessageChange(t,e){if(this.textBox){this.textBox.set("text",e);const i=this.textBox.textLines;i.length>12&&this.textBox.set("text",i.slice(0,12).join(`
|
|
2991
|
+
`)),this.updateTextAreaPosition(),this.canvas.renderAll()}}async handleBackgroundImageUrlChange(){this.canvas&&(this.backgroundFabImg&&this.canvas.remove(this.backgroundFabImg),this.imgLoading=!0,await this.appendBackgroundImageToCanvas(this.backgroundImageUrl||"https://cdn.shopify.com/s/files/1/1956/2323/files/insert_86e8bcd5-3e82-4910-b350-485fa6958502.png?v=1726598821",()=>{this.imgLoading=!1}),this.updateTextAreaPosition(),this.canvas.renderAll())}updateTextAreaPosition(){this.areaPosition={left:.084*this.canvas.getWidth(),top:.4874*this.canvas.getHeight()},this.areaSize={width:.832*this.canvas.getWidth(),height:this.canvas.getHeight()-this.areaPosition.top-this.areaPosition.left},this.rect?(this.rect.set("left",this.areaPosition.left),this.rect.set("top",this.areaPosition.top),this.rect.set("width",this.areaSize.width),this.rect.set("height",this.areaSize.height)):(this.rect=new Ht({left:this.areaPosition.left,top:this.areaPosition.top,width:this.areaSize.width,height:this.areaSize.height,selectable:!1,fill:"rgba(255, 255, 255, 0)"}),this.canvas.add(this.rect)),this.textBox?(this.textBox.set("left",this.areaPosition.left),this.textBox.set("top",this.areaPosition.top),this.textBox.set("width",this.areaSize.width),this.textBox.set("height",this.areaSize.height),this.textBox.set("lineHeight",1.1),this.textBox.set("fontSize",this.areaSize.height/13/1.1)):(this.textBox=new ai(this.message,{left:this.areaPosition.left,top:this.areaPosition.top,width:this.areaSize.width,height:this.areaSize.height,lineHeight:1.1,fontSize:this.areaSize.height/13/1.1,textAlign:"left",selectable:!1,objectCaching:!1,paintFirst:"stroke",strokeWidth:.5}),this.canvas.add(this.textBox))}firstUpdated(){this.canvas=new Yn(this.baseCanvas,{width:500,height:500,containerClass:"fabric-container",selection:!1}),this.imgLoading=!0,this.backgroundImageUrl?this.appendBackgroundImageToCanvas(this.backgroundImageUrl,()=>{this.imgLoading=!1}).then(()=>{this.updateTextAreaPosition(),this.canvas.renderAll()}):(this.updateTextAreaPosition(),this.canvas.renderAll())}async appendBackgroundImageToCanvas(t,e){const i=await te.fromURL(t);i.selectable=!1,this.backgroundFabImg=i,this.canvas.setDimensions({width:i.width,height:i.height}),this.canvas.add(i),this.canvas.sendObjectToBack(i),this.canvas.renderAll(),e&&e()}render(){return V`
|
|
2977
2992
|
<div
|
|
2978
|
-
class="${
|
|
2993
|
+
class="${ve({"type-canvas-container":!0,"image-loading":this.imgLoading})}
|
|
2979
2994
|
"
|
|
2980
2995
|
>
|
|
2981
2996
|
<canvas class="base-canvas"></canvas>
|
|
2982
2997
|
<pbo-image skeleton></pbo-image>
|
|
2983
2998
|
</div>
|
|
2984
|
-
`}};yt.styles=[
|
|
2999
|
+
`}};yt.styles=[Tt,_m];Ft([S({attribute:"background-url"})],yt.prototype,"backgroundImageUrl",2);Ft([S()],yt.prototype,"message",2);Ft([S()],yt.prototype,"font",2);Ft([S()],yt.prototype,"color",2);Ft([S()],yt.prototype,"alignment",2);Ft([q(".base-canvas")],yt.prototype,"baseCanvas",2);Ft([W()],yt.prototype,"canvas",2);Ft([W()],yt.prototype,"backgroundImage",2);Ft([W()],yt.prototype,"backgroundFabImg",2);Ft([W()],yt.prototype,"rect",2);Ft([W()],yt.prototype,"textBox",2);Ft([W()],yt.prototype,"areaPosition",2);Ft([W()],yt.prototype,"imgLoading",2);Ft([W()],yt.prototype,"areaSize",2);Ft([Z("alignment")],yt.prototype,"handleAlignmentChange",1);Ft([Z("color")],yt.prototype,"handleColorChange",1);Ft([Z("font")],yt.prototype,"handleFontChange",1);Ft([Z("message")],yt.prototype,"handleMessageChange",1);Ft([Z("backgroundImageUrl")],yt.prototype,"handleBackgroundImageUrlChange",1);yt=Ft([xt("pbo-type-canvas")],yt);const c0=yt,c_=ct`
|
|
2985
3000
|
:host {
|
|
2986
3001
|
display: block;
|
|
2987
3002
|
height: 100%;
|
|
@@ -3022,11 +3037,11 @@ void main() {
|
|
|
3022
3037
|
fill: #fff9f9;
|
|
3023
3038
|
scale: 1.1;
|
|
3024
3039
|
}
|
|
3025
|
-
`;var h_=Object.defineProperty,u_=Object.getOwnPropertyDescriptor,
|
|
3040
|
+
`;var h_=Object.defineProperty,u_=Object.getOwnPropertyDescriptor,Nr=(n,t,e,i)=>{for(var s=i>1?void 0:i?u_(t,e):t,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(t,e,s):o(s))||s);return i&&s&&h_(t,e,s),s};let Li=class extends Pt{constructor(){super(...arguments),this.formData={font:"Monsieur La Doulaise",text:"",color:"rgb(0,0,0)",alignment:"left"},this.cardUrl="",this.handwrittenPreviewProps={isLoading:!1,url:""}}render(){return V`
|
|
3026
3041
|
<div class="panel">
|
|
3027
3042
|
<div class="zoomed-preview">
|
|
3028
3043
|
<div
|
|
3029
|
-
style=${
|
|
3044
|
+
style=${oe({display:"flex","justify-content":"center",flexDirection:"column",height:"100%"})}
|
|
3030
3045
|
>
|
|
3031
3046
|
<slot part="base"></slot>
|
|
3032
3047
|
</div>
|
|
@@ -3040,17 +3055,18 @@ void main() {
|
|
|
3040
3055
|
</svg>
|
|
3041
3056
|
</div>
|
|
3042
3057
|
</div>
|
|
3043
|
-
`}};Li.styles=[
|
|
3058
|
+
`}};Li.styles=[Tt,c_];Nr([S()],Li.prototype,"formData",2);Nr([S()],Li.prototype,"cardUrl",2);Nr([S()],Li.prototype,"close",2);Nr([S()],Li.prototype,"handwrittenPreviewProps",2);Li=Nr([xt("pbo-zoomed-preview")],Li);const u0=Li,d_=ct`
|
|
3044
3059
|
:host {
|
|
3045
3060
|
display: block;
|
|
3046
3061
|
}
|
|
3047
3062
|
|
|
3048
3063
|
.label {
|
|
3049
3064
|
line-height: normal;
|
|
3050
|
-
font-size:
|
|
3065
|
+
font-size: 15px;
|
|
3051
3066
|
}
|
|
3052
3067
|
.label svg {
|
|
3053
3068
|
vertical-align: middle;
|
|
3069
|
+
pointer-events: none;
|
|
3054
3070
|
}
|
|
3055
3071
|
.icon {
|
|
3056
3072
|
/* display: inline; */
|
|
@@ -3065,7 +3081,7 @@ void main() {
|
|
|
3065
3081
|
white-space: nowrap;
|
|
3066
3082
|
overflow: hidden;
|
|
3067
3083
|
}
|
|
3068
|
-
`;var p_=Object.defineProperty,g_=Object.getOwnPropertyDescriptor,
|
|
3084
|
+
`;var p_=Object.defineProperty,g_=Object.getOwnPropertyDescriptor,Hs=(n,t,e,i)=>{for(var s=i>1?void 0:i?g_(t,e):t,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(t,e,s):o(s))||s);return i&&s&&p_(t,e,s),s};let fi=class extends Pt{constructor(){super(...arguments),this.hasSlotController=new ns(this,"help-text","label"),this.size="medium",this.label="",this.disabled=!1,this._handleDocumentClick=t=>{var i;const e=t.composedPath();this&&!e.includes(this)&&((i=this._choices)==null||i.hideDropdown())}}handleDisabledChanged(){var t;this._choices&&this.disabled?this._choices.disable():(t=this._choices)==null||t.enable()}get value(){var t;return(t=this._choices)==null?void 0:t.getValue().value}firstUpdated(){this._initializeChoices(),this.handleDisabledChanged(),document.addEventListener("click",this._handleDocumentClick,!0)}disconnectedCallback(){super.disconnectedCallback(),document.removeEventListener("click",this._handleDocumentClick,!0)}_initializeChoices(){var t;(t=this._choices)==null||t.destroy(),this._choices=new gh(this.choiceEl,{allowHTML:!0,searchEnabled:!1,shouldSort:!1,removeItemButton:!1,shadowRoot:this.shadowRoot,choices:[{value:"type",label:`
|
|
3069
3085
|
<div class="choice-wrapper">
|
|
3070
3086
|
<span class="label">Type message
|
|
3071
3087
|
<svg
|
|
@@ -3091,7 +3107,8 @@ void main() {
|
|
|
3091
3107
|
<path d="M3 11H4V8.5H3V11Z" fill="currentColor"></path>
|
|
3092
3108
|
<path d="M11 9.5H7V7.5H17V9.5H13V16.5H11V9.5Z" fill="currentColor"></path>
|
|
3093
3109
|
</svg>
|
|
3094
|
-
|
|
3110
|
+
</span>
|
|
3111
|
+
</div>`},{value:"handwritten",label:`
|
|
3095
3112
|
<div class="choice-wrapper">
|
|
3096
3113
|
<span class="label">Upload handwritten message
|
|
3097
3114
|
<svg
|
|
@@ -3142,8 +3159,9 @@ void main() {
|
|
|
3142
3159
|
d="M336 192h40a40 40 0 0 1 40 40v192a40 40 0 0 1-40 40H136a40 40 0 0 1-40-40V232a40 40 0 0 1 40-40h40m160-64-80-80-80 80m80 193V48"
|
|
3143
3160
|
></path>
|
|
3144
3161
|
</svg>
|
|
3145
|
-
|
|
3146
|
-
|
|
3162
|
+
</span>
|
|
3163
|
+
</div>`}],placeholder:!1,shouldSortItems:!1,itemSelectText:""}),this.choiceEl.addEventListener("change",e=>{const i=e.target;this.dispatchEvent(new CustomEvent("pbo-change",{detail:{value:i.value},bubbles:!0,composed:!0}))})}render(){const t=this.hasSlotController.test("label"),e=this.label?!0:!!t;return V` <div
|
|
3164
|
+
class=${ve({"form-control":!0,"form-control--small":this.size==="small","form-control--medium":this.size==="medium","form-control--large":this.size==="large","form-control--radio-group":!0,"form-control--has-label":e})}
|
|
3147
3165
|
>
|
|
3148
3166
|
<label
|
|
3149
3167
|
part="form-control-label"
|
|
@@ -3154,7 +3172,7 @@ void main() {
|
|
|
3154
3172
|
<slot name="label">${this.label}</slot>
|
|
3155
3173
|
</label>
|
|
3156
3174
|
</div>
|
|
3157
|
-
<select part="base" class="js-choice"></select>`}};
|
|
3175
|
+
<select part="base" class="js-choice"></select>`}};fi.styles=[Tt,d_,Tr,Kn(fh)];Hs([S()],fi.prototype,"size",2);Hs([S()],fi.prototype,"label",2);Hs([S({type:Boolean,reflect:!0})],fi.prototype,"disabled",2);Hs([Z("disabled",{waitUntilFirstUpdate:!0})],fi.prototype,"handleDisabledChanged",1);Hs([q(".js-choice")],fi.prototype,"choiceEl",2);fi=Hs([xt("pbo-editor-selector")],fi);const p0=fi,f_=ct`
|
|
3158
3176
|
:host {
|
|
3159
3177
|
display: block;
|
|
3160
3178
|
}
|
|
@@ -3174,15 +3192,21 @@ void main() {
|
|
|
3174
3192
|
font-size: var(--pbo-font-size-medium);
|
|
3175
3193
|
}
|
|
3176
3194
|
|
|
3177
|
-
.
|
|
3195
|
+
.step-title {
|
|
3178
3196
|
margin: 0;
|
|
3179
|
-
font-size:
|
|
3197
|
+
font-size: 17.5px;
|
|
3198
|
+
font-weight: 800;
|
|
3199
|
+
font-style: normal;
|
|
3200
|
+
line-height: normal;
|
|
3180
3201
|
}
|
|
3181
3202
|
|
|
3182
|
-
.
|
|
3203
|
+
.step-description {
|
|
3183
3204
|
margin-top: var(--pbo-spacing-2x-small);
|
|
3184
3205
|
margin-bottom: 0;
|
|
3185
|
-
font-size:
|
|
3206
|
+
font-size: 17.5px;
|
|
3207
|
+
font-weight: 400;
|
|
3208
|
+
font-style: normal;
|
|
3209
|
+
line-height: normal;
|
|
3186
3210
|
}
|
|
3187
3211
|
|
|
3188
3212
|
.fake-loading-container {
|
|
@@ -3197,7 +3221,11 @@ void main() {
|
|
|
3197
3221
|
gap: var(--pbo-spacing-medium);
|
|
3198
3222
|
padding: 0;
|
|
3199
3223
|
}
|
|
3200
|
-
|
|
3224
|
+
|
|
3225
|
+
.reupload-cta::part(base) {
|
|
3226
|
+
color: black;
|
|
3227
|
+
}
|
|
3228
|
+
`,m_=ct`
|
|
3201
3229
|
:host {
|
|
3202
3230
|
display: block;
|
|
3203
3231
|
}
|
|
@@ -3220,31 +3248,33 @@ void main() {
|
|
|
3220
3248
|
display: flex;
|
|
3221
3249
|
align-items: center;
|
|
3222
3250
|
}
|
|
3223
|
-
`;var v_=Object.defineProperty,b_=Object.getOwnPropertyDescriptor,
|
|
3224
|
-
class="${
|
|
3251
|
+
`;var v_=Object.defineProperty,b_=Object.getOwnPropertyDescriptor,zr=(n,t,e,i)=>{for(var s=i>1?void 0:i?b_(t,e):t,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(t,e,s):o(s))||s);return i&&s&&v_(t,e,s),s};let Xe=class extends Pt{constructor(){super(...arguments),this.loading=!1,this.loadingTime=0,this.loadingPattern="random",this.progress=0,this.loadingInterval=null,this.startTime=0,this.PHASES={QUICK:{target:90,duration:15e3},SLOW:{target:98,duration:3e4},FINAL:{target:100,duration:1e3}}}startLoading(){this.startTime=Date.now(),this.progress=0,this.loadingInterval&&clearInterval(this.loadingInterval),this.loadingInterval=window.setInterval(()=>{const t=Date.now()-this.startTime;if(this.progress<this.PHASES.QUICK.target)this.progress=Math.min(this.PHASES.QUICK.target,t/this.PHASES.QUICK.duration*this.PHASES.QUICK.target);else if(this.progress<this.PHASES.SLOW.target){const e=(t-this.PHASES.QUICK.duration)/this.PHASES.SLOW.duration;this.progress=Math.min(this.PHASES.SLOW.target,this.PHASES.QUICK.target+e*(this.PHASES.SLOW.target-this.PHASES.QUICK.target))}this.requestUpdate()},50)}completeLoading(){this.loadingInterval&&clearInterval(this.loadingInterval);const t=this.progress,e=Date.now();this.loadingInterval=window.setInterval(()=>{const i=Date.now()-e,s=Math.min(100,t+i/this.PHASES.FINAL.duration*(100-t));this.progress=s,s>=100&&this.stopLoading(),this.requestUpdate()},16)}stopLoading(){this.loadingInterval&&(clearInterval(this.loadingInterval),this.loadingInterval=null)}updated(t){t.has("loading")&&(this.loading?this.startLoading():this.completeLoading())}disconnectedCallback(){super.disconnectedCallback(),this.stopLoading()}render(){return V`<div
|
|
3252
|
+
class="${ve({"fake-loading":!0,"fake-loading--linear":this.loadingPattern==="linear","fake-loading--random":this.loadingPattern==="random","fake-loading--loading":!0})}"
|
|
3225
3253
|
>
|
|
3226
|
-
<pbo-spinner
|
|
3254
|
+
<pbo-spinner
|
|
3255
|
+
style="${oe({"--track-width":"3px","--indicator-color":"black"})}"
|
|
3256
|
+
></pbo-spinner>
|
|
3227
3257
|
<span>${Math.round(this.progress)}%</span>
|
|
3228
|
-
</div>`}};Xe.styles=[
|
|
3258
|
+
</div>`}};Xe.styles=[Tt,m_];Xe.dependencies={"pbo-spinner":ks};zr([S({type:Boolean,reflect:!0})],Xe.prototype,"loading",2);zr([S({type:Number})],Xe.prototype,"loadingTime",2);zr([S()],Xe.prototype,"loadingPattern",2);zr([W()],Xe.prototype,"progress",2);Xe=zr([xt("pbo-fake-loading")],Xe);var __=Object.defineProperty,y_=Object.getOwnPropertyDescriptor,wt=(n,t,e,i)=>{for(var s=i>1?void 0:i?y_(t,e):t,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(t,e,s):o(s))||s);return i&&s&&__(t,e,s),s};let nt=class extends Pt{constructor(){super(...arguments),this.card=null,this.submitHandwrittenForm=async t=>{console.warn("submitHandwrittenForm not implemented",t)},this.getProcessedImg=async t=>(console.warn("getProcessedImg not implemented",t.name),{masked_img:"",uid:""}),this.isSubmitLoading=!1,this.isSubmitDisabled=!1,this.isProcessingError=!1,this.isImageProcessing=!1,this.sourceImg=null,this.processedImg={uid:null,masked_img:null},this.handwrittenDimensions={top:null,left:null,width:null,height:null,cardHeight:null,cardWidth:null}}showPicker(){this.imageInput.showPicker()}setButtonsDisabled(t){this.uploadButton&&this.saveButton&&this.reuploadButton&&(this.uploadButton.disabled=t,this.saveButton.disabled=t,this.reuploadButton.disabled=t)}setButtonsError(t){this.uploadButton&&this.saveButton&&(this.uploadButton.variant=t?"danger":"primary",this.saveButton.variant=t?"danger":"primary",this.uploadButton.value=t?"Error uploading image":"Upload Handwritten Image")}setButtonsLoading(t){this.uploadButton&&this.saveButton&&(this.saveButton.loading=t)}handleSubmitLoadingChange(){this.setButtonsLoading(this.isSubmitLoading)}handleSubmitDisabledChange(){this.setButtonsDisabled(this.isSubmitDisabled)}handleProcessingErrorChange(){this.setButtonsError(this.isProcessingError)}handleSourceImgChange(t,e){this.processedImg={uid:null,masked_img:null},this.emit("pbo-change",{detail:{isLoading:!0,processedFileUrl:null}})}handleProcessImageChange(t,e){this.emit("pbo-change",{detail:{isLoading:!1,processedFileUrl:e}})}handleImageProcessingChange(){this.setButtonsDisabled(this.isImageProcessing),this.setButtonsLoading(this.isImageProcessing),this.emit("pbo-image-processing",{detail:{isLoading:this.isImageProcessing}})}get formData(){var s,r,o,a;const t=177.8/this.handwrittenDimensions.cardHeight,e=127/this.handwrittenDimensions.cardWidth,i={pboCardId:((s=this.card)==null?void 0:s.pboId)||"Unknown",productId:(r=this.card)==null?void 0:r.productId,sku:(o=this.card)==null?void 0:o.sku,variantId:(a=this.card)==null?void 0:a.variantId,pred_image_uid:this.processedImg.uid||"",position_x:this.handwrittenDimensions.top*e,position_y:this.handwrittenDimensions.left*t,height:this.handwrittenDimensions.height*t,width:this.handwrittenDimensions.width*e};return _h(i)}setDimensions(t){this.handwrittenDimensions=t}handleProcessedImgChange(){this.processedImg.masked_img&&this.emit("pbo-change",{detail:{isLoading:!1,processedFileUrl:this.processedImg.masked_img}})}async handleFileChange(t){var i,s;this.sourceImg=null,this.processedImg={uid:null,masked_img:null},this.isProcessingError=!1;const e=(s=(i=t.target)==null?void 0:i.files)==null?void 0:s[0];if(e!=null){this.sourceImg=e,this.isImageProcessing=!0;try{const r=await this.getProcessedImg(e);console.log(r),this.processedImg={masked_img:`data:image/png;base64,${r.masked_img}`,uid:r.uid}}catch{this.isProcessingError=!0}finally{this.isImageProcessing=!1}}}async handleSubmit(t){t.preventDefault(),this.isSubmitLoading=!0,this.isSubmitDisabled=!0;try{await this.submitHandwrittenForm(this.formData)}catch(e){console.error("Error submitting handwritten form:",e)}finally{this.isSubmitLoading=!1,this.isSubmitDisabled=!1}}render(){return V`
|
|
3229
3259
|
<form name="handwritten-form" class="handwritten-form" @submit=${this.handleSubmit}>
|
|
3230
3260
|
<section>
|
|
3231
|
-
<
|
|
3232
|
-
<
|
|
3261
|
+
<div class="step-title">Step 1</div>
|
|
3262
|
+
<div class="step-description">Write message & signature on white paper</div>
|
|
3233
3263
|
</section>
|
|
3234
3264
|
|
|
3235
3265
|
<section>
|
|
3236
|
-
<
|
|
3237
|
-
<
|
|
3266
|
+
<div class="step-title">Step 2</div>
|
|
3267
|
+
<div class="step-description">Take a well-lit photo on your phone, then crop and save it</div>
|
|
3238
3268
|
</section>
|
|
3239
3269
|
|
|
3240
3270
|
<section>
|
|
3241
|
-
<
|
|
3242
|
-
<
|
|
3271
|
+
<div class="step-title">Step 3</div>
|
|
3272
|
+
<div class="step-description">Crop photo tightly around text, then upload</div>
|
|
3243
3273
|
</section>
|
|
3244
3274
|
|
|
3245
3275
|
<section>
|
|
3246
|
-
<
|
|
3247
|
-
<
|
|
3276
|
+
<div class="step-title">Step 4</div>
|
|
3277
|
+
<div class="step-description">Review preview & adjust if needed</div>
|
|
3248
3278
|
</section>
|
|
3249
3279
|
|
|
3250
3280
|
<input
|
|
@@ -3259,9 +3289,10 @@ void main() {
|
|
|
3259
3289
|
<!-- Fake loading -->
|
|
3260
3290
|
${this.isImageProcessing?V`<div class="fake-loading-container">
|
|
3261
3291
|
<pbo-fake-loading ?loading=${this.isImageProcessing}></pbo-fake-loading>
|
|
3262
|
-
</div>`:
|
|
3292
|
+
</div>`:at}
|
|
3263
3293
|
|
|
3264
3294
|
<div class="buttons-container">
|
|
3295
|
+
<!-- Upload button -->
|
|
3265
3296
|
<pbo-button
|
|
3266
3297
|
exportparts="base:cta-button-base, label:cta-button-label"
|
|
3267
3298
|
name="upload"
|
|
@@ -3269,34 +3300,38 @@ void main() {
|
|
|
3269
3300
|
size="medium"
|
|
3270
3301
|
variant="primary"
|
|
3271
3302
|
@click=${this.showPicker}
|
|
3272
|
-
style=${
|
|
3303
|
+
style=${oe({display:this.processedImg.masked_img?"none":"block"})}
|
|
3273
3304
|
>
|
|
3274
|
-
${this.isProcessingError?"Please Try Again":"
|
|
3305
|
+
${this.isProcessingError?"Please Try Again":""} ${this.isImageProcessing?"Uploading":""}
|
|
3306
|
+
${!this.isProcessingError&&!this.isImageProcessing?"Upload Handwritten Image":""}
|
|
3275
3307
|
</pbo-button>
|
|
3308
|
+
|
|
3309
|
+
<!-- Save button -->
|
|
3276
3310
|
<pbo-button
|
|
3277
3311
|
exportparts="base:cta-button-base, label:cta-button-label"
|
|
3278
3312
|
name="save"
|
|
3279
3313
|
type="submit"
|
|
3280
3314
|
variant="primary"
|
|
3281
3315
|
class="submit-cta"
|
|
3282
|
-
style=${
|
|
3316
|
+
style=${oe({display:this.sourceImg&&this.processedImg.masked_img&&!this.isImageProcessing?"block":"none"})}
|
|
3283
3317
|
>
|
|
3284
3318
|
Save and Continue
|
|
3285
3319
|
</pbo-button>
|
|
3320
|
+
<!-- Reupload button -->
|
|
3286
3321
|
<pbo-button
|
|
3287
3322
|
exportparts="base:cta-link-button-base, label:cta-link-button-label"
|
|
3288
3323
|
name="reupload"
|
|
3289
3324
|
variant="text"
|
|
3290
|
-
class="submit-cta"
|
|
3325
|
+
class="submit-cta reupload-cta"
|
|
3291
3326
|
@click=${this.showPicker}
|
|
3292
3327
|
size="small"
|
|
3293
|
-
style=${
|
|
3328
|
+
style=${oe({display:this.sourceImg&&this.processedImg.masked_img?"block":"none","--pbo-text-color":"black"})}
|
|
3294
3329
|
>
|
|
3295
3330
|
reupload image
|
|
3296
3331
|
</pbo-button>
|
|
3297
3332
|
</div>
|
|
3298
3333
|
</form>
|
|
3299
|
-
`}};nt.styles=[
|
|
3334
|
+
`}};nt.styles=[Tt,f_];nt.dependencies={"pbo-button":pt,"pbo-fake-loading":Xe};wt([S()],nt.prototype,"card",2);wt([S()],nt.prototype,"submitHandwrittenForm",2);wt([S()],nt.prototype,"getProcessedImg",2);wt([S({type:Boolean,reflect:!0,attribute:"loading"})],nt.prototype,"isSubmitLoading",2);wt([S({type:Boolean,reflect:!0,attribute:"disabled"})],nt.prototype,"isSubmitDisabled",2);wt([q(".pixel-input")],nt.prototype,"imageInput",2);wt([q(".handwritten-form")],nt.prototype,"handwrittenForm",2);wt([q("pbo-button[name='upload']")],nt.prototype,"uploadButton",2);wt([q("pbo-button[name='save']")],nt.prototype,"saveButton",2);wt([q("pbo-button[name='reupload']")],nt.prototype,"reuploadButton",2);wt([W()],nt.prototype,"isProcessingError",2);wt([W()],nt.prototype,"isImageProcessing",2);wt([W()],nt.prototype,"sourceImg",2);wt([W()],nt.prototype,"processedImg",2);wt([W()],nt.prototype,"handwrittenDimensions",2);wt([Z("isSubmitLoading")],nt.prototype,"handleSubmitLoadingChange",1);wt([Z("isSubmitDisabled")],nt.prototype,"handleSubmitDisabledChange",1);wt([Z("isProcessingError")],nt.prototype,"handleProcessingErrorChange",1);wt([Z("sourceImg")],nt.prototype,"handleSourceImgChange",1);wt([Z("processedFileUrl")],nt.prototype,"handleProcessImageChange",1);wt([Z("isImageProcessing")],nt.prototype,"handleImageProcessingChange",1);wt([Z("processedImg")],nt.prototype,"handleProcessedImgChange",1);nt=wt([xt("pbo-handwritten-form")],nt);const m0=nt,x_=ct`
|
|
3300
3335
|
:host {
|
|
3301
3336
|
display: block;
|
|
3302
3337
|
width: 100%;
|
|
@@ -3324,7 +3359,7 @@ void main() {
|
|
|
3324
3359
|
display: block;
|
|
3325
3360
|
object-fit: contain;
|
|
3326
3361
|
}
|
|
3327
|
-
`;var w_=Object.defineProperty,C_=Object.getOwnPropertyDescriptor,
|
|
3362
|
+
`;var w_=Object.defineProperty,C_=Object.getOwnPropertyDescriptor,Bt=(n,t,e,i)=>{for(var s=i>1?void 0:i?C_(t,e):t,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(t,e,s):o(s))||s);return i&&s&&w_(t,e,s),s};let St=class extends Pt{constructor(){super(...arguments),this.backgroundImageUrl=void 0,this.handwrittenImageUrl=void 0,this.imageHeight=null,this.imageWidth=null,this.imageLeft=null,this.imageTop=null,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}async handleBackgroundImageUrlChange(){this.canvas&&(this.backgroundFabImg&&this.canvas.remove(this.backgroundFabImg),await this.appendBackgroundImageToCanvas(this.backgroundImageUrl||"https://cdn.shopify.com/s/files/1/1956/2323/files/insert_86e8bcd5-3e82-4910-b350-485fa6958502.png?v=1726598821"),this.updateProcessedImgAreaPosition(),this.canvas.renderAll())}async handleHandwrittenImageUrlChange(t,e){if(this.canvas){if(this.handwrittenImage&&this.canvas.remove(this.handwrittenImage),e){this.handwrittenImage=await te.fromURL(e),this.handwrittenImage.selectable=!0,this.handwrittenImage.lockRotation=!0,this.handwrittenImage.lockScalingFlip=!0,this.handwrittenImage.noScaleCache=!1;const i=this.areaSize.width/this.handwrittenImage.width,s=this.areaSize.height/this.handwrittenImage.height,r=Math.min(i,s);this.handwrittenImage.set({transparentCorners:!1,cornerColor:"#4287f5",cornerStyle:"circle",cornerSize:this.areaSize.width*(vs()?.06:.03),cornerStrokeWidth:2,cornerStrokeColor:"#2563eb",touchCornerSize:this.areaSize.width*(vs()?.2:.06),scalingLimitations:"preserveAspectRatio",left:this.areaPosition.left,top:this.areaPosition.top,scaleX:r,scaleY:r,bringToFrontOnSelect:!1,borderColor:"#4287f5",borderScaleFactor:10}),this.setHandwrittenImageDimensions({top:this.areaPosition.top,left:this.areaPosition.left,height:this.handwrittenImage.height*r,width:this.handwrittenImage.width*r}),this.handwrittenImage.setControlsVisibility({tl:!0,tr:!0,bl:!0,br:!0,mt:!1,mb:!1,ml:!1,mr:!1,mtr:!1});const o=new Ht({width:this.areaSize.width,height:this.areaSize.height,left:this.areaPosition.left,top:this.areaPosition.top,absolutePositioned:!0});this.handwrittenImage.set({clipPath:o}),this.handwrittenImage.on("scaling",a=>{const{top:l,left:c,height:h,width:u,scaleX:d,scaleY:p}=a.transform.target;this.setHandwrittenImageDimensions({top:l,left:c,height:h*p,width:u*d})}),this.handwrittenImage.on("moving",a=>{const{top:l,left:c}=a.transform.target;this.setHandwrittenImageDimensions({top:l,left:c})}),this.handwrittenImage.on("selected",()=>{var a,l;(a=this.rect)==null||a.set("visible",!0),(l=this.handwrittenImage)==null||l.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()}),this.handwrittenImage.on("deselected",()=>{var a,l,c;(a=this.rect)==null||a.set("visible",!1),(l=this.handwrittenImage)==null||l.set({clipPath:o}),(c=this.clipMaskOverlay)==null||c.set("visible",!1)}),this.canvas.add(this.handwrittenImage),this.canvas.renderAll()}this.updateProcessedImgAreaPosition(),this.canvas.renderAll()}}createClipMaskOverlay(){const t=this.canvas.getWidth(),e=this.canvas.getHeight(),{left:i,top:s}=this.areaPosition,{width:r,height:o}=this.areaSize,a="rgba(0,0,0,0.1)",l=new Ht({left:0,top:0,width:t,height:s,fill:a,selectable:!1,evented:!1}),c=new Ht({left:0,top:s+o,width:t,height:e-(s+o),fill:a,selectable:!1,evented:!1}),h=new Ht({left:0,top:s,width:i,height:o,fill:a,selectable:!1,evented:!1}),u=new Ht({left:i+r,top:s,width:t-(i+r),height:o,fill:a,selectable:!1,evented:!1});return new Ei([l,c,h,u],{selectable:!1,evented:!1})}updateProcessedImgAreaPosition(){this.areaPosition={left:.084*this.canvas.getWidth(),top:.4874*this.canvas.getHeight()},this.areaSize={width:.832*this.canvas.getWidth(),height:this.canvas.getHeight()-this.areaPosition.top-this.areaPosition.left},this.rect?(this.rect.set("left",this.areaPosition.left),this.rect.set("top",this.areaPosition.top),this.rect.set("width",this.areaSize.width),this.rect.set("height",this.areaSize.height)):(this.rect=new Ht({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))}handleHandwrittenImageDimensionsChange(t,e){this._dimensionsUpdateTimeout&&clearTimeout(this._dimensionsUpdateTimeout),this._dimensionsUpdateTimeout=setTimeout(()=>{var i,s,r;this.applyHandwrittenImageDimensions(),(i=this.canvas)==null||i.renderAll(),this.emit("handwritten-image-dimensions-changed",{detail:{left:this.imageLeft,top:this.imageTop,width:this.imageWidth,height:this.imageHeight,cardHeight:((s=this.backgroundFabImg)==null?void 0:s.height)||0,cardWidth:((r=this.backgroundFabImg)==null?void 0:r.width)||0}})},300)}applyHandwrittenImageDimensions(){!Zs(this.handwrittenImage)||!Zs(this.imageLeft)||!Zs(this.imageTop)||!Zs(this.imageWidth)||!Zs(this.imageHeight)||(this.handwrittenImage.set({left:this.imageLeft,top:this.imageTop}),this.handwrittenImage.scaleToHeight(this.imageHeight),this.handwrittenImage.scaleToWidth(this.imageWidth))}setHandwrittenImageDimensions(t){const{top:e=null,left:i=null,height:s=null,width:r=null}=t;if(!e&&!i&&!s&&!r){console.warn("Invalid dimensions provided for handwritten image");return}i&&this.imageLeft!==i&&(this.imageLeft=i),e&&this.imageTop!==e&&(this.imageTop=e),s&&this.imageHeight!==s&&(this.imageHeight=s),r&&this.imageWidth!==r&&(this.imageWidth=r)}firstUpdated(){this.canvas=new Yn(this.baseCanvas,{width:500,height:500,containerClass:"fabric-container",preserveObjectStacking:!0}),this.backgroundImageUrl?this.appendBackgroundImageToCanvas(this.backgroundImageUrl,()=>{}).then(()=>{this.updateProcessedImgAreaPosition(),this.uploadingText=new ai("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}),this.canvas.renderAll()}):(this.updateProcessedImgAreaPosition(),this.canvas.renderAll()),document.addEventListener("pbo-image-processing",t=>{const e=t.detail.isLoading;this.uploadingText&&(e?this.canvas.add(this.uploadingText):this.canvas.remove(this.uploadingText),this.canvas.renderAll())})}async appendBackgroundImageToCanvas(t,e){const i=await te.fromURL(t);i.selectable=!1,this.backgroundFabImg=i,this.canvas.setDimensions({width:i.width,height:i.height}),this.canvas.add(i),this.canvas.sendObjectToBack(i),this.canvas.renderAll(),e&&e()}render(){return V`<canvas class="base-canvas"></canvas> `}};St.styles=[Tt,x_];Bt([S({attribute:"background-url"})],St.prototype,"backgroundImageUrl",2);Bt([S({attribute:"handwritten-url"})],St.prototype,"handwrittenImageUrl",2);Bt([S({type:Number,reflect:!0,attribute:"height"})],St.prototype,"imageHeight",2);Bt([S({type:Number,reflect:!0,attribute:"width"})],St.prototype,"imageWidth",2);Bt([S({type:Number,reflect:!0,attribute:"left"})],St.prototype,"imageLeft",2);Bt([S({type:Number,reflect:!0,attribute:"top"})],St.prototype,"imageTop",2);Bt([q(".base-canvas")],St.prototype,"baseCanvas",2);Bt([W()],St.prototype,"canvas",2);Bt([W()],St.prototype,"backgroundFabImg",2);Bt([W()],St.prototype,"rect",2);Bt([W()],St.prototype,"areaPosition",2);Bt([W()],St.prototype,"uploadingText",2);Bt([W()],St.prototype,"handwrittenImage",2);Bt([W()],St.prototype,"clipMaskOverlay",2);Bt([W()],St.prototype,"areaSize",2);Bt([Z("backgroundImageUrl")],St.prototype,"handleBackgroundImageUrlChange",1);Bt([Z("handwrittenImageUrl")],St.prototype,"handleHandwrittenImageUrlChange",1);Bt([Z("imageLeft"),Z("imageTop"),Z("imageWidth"),Z("imageHeight")],St.prototype,"handleHandwrittenImageDimensionsChange",1);St=Bt([xt("pbo-handwritten-canvas")],St);const b0=St,S_=ct`
|
|
3328
3363
|
:host {
|
|
3329
3364
|
display: block;
|
|
3330
3365
|
width: auto;
|
|
@@ -3382,7 +3417,7 @@ void main() {
|
|
|
3382
3417
|
resize: vertical;
|
|
3383
3418
|
min-height: 96px;
|
|
3384
3419
|
}
|
|
3385
|
-
`;var T_=Object.defineProperty,E_=Object.getOwnPropertyDescriptor,Jt=(n,t,e,i)=>{for(var
|
|
3420
|
+
`;var T_=Object.defineProperty,E_=Object.getOwnPropertyDescriptor,Jt=(n,t,e,i)=>{for(var s=i>1?void 0:i?E_(t,e):t,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(t,e,s):o(s))||s);return i&&s&&T_(t,e,s),s};let It=class extends Pt{constructor(){super(...arguments),this.hasSlotController=new ns(this,"is-gift-label","premium-card-label","free-message-label"),this.hidden=!1,this.expand=!1,this.freeMessage="",this.isGift=!0,this.isPremiumChecked=!1,this.isFreeMessageChecked=!1,this.debouncedFreeMessageChange=()=>{}}handleOnFreeMessageChange(){this.onFreeMessageChange&&(this.debouncedFreeMessageChange=Pg(this.onFreeMessageChange,300))}handleIsGiftChange(){this.isPremiumChecked=!1,this.isFreeMessageChecked=!1}handleIsFreeMessageCheckedChange(){var t;console.debug("isFreeMessageChecked",this.isFreeMessageChecked),this.isFreeMessageChecked&&(this.isPremiumChecked=!1),this.isFreeMessageChecked||(this.freeMessage="",console.debug("freeMessage is empty"),console.debug("onFreeMessageClear",this.onFreeMessageClear),(t=this.onFreeMessageClear)==null||t.call(this))}handleIsPremiumCheckedChange(){var t;this.isPremiumChecked?(this.isFreeMessageChecked=!1,this.emit("pbo-open-drawer")):this.emit("pbo-close-drawer"),(t=this.onPremiumSelected)==null||t.call(this,this.isPremiumChecked)}handleFreeMessageChange(){var t;this.freeMessage===""?(console.debug("freeMessage is empty"),(t=this.onFreeMessageClear)==null||t.call(this)):this.debouncedFreeMessageChange&&this.debouncedFreeMessageChange(this.freeMessage)}setGiftOptionEnabled(t){this.isGift=t}setPremiumEnabled(t){this.isPremiumChecked=t}setFreeMessageEnabled(t){this.isFreeMessageChecked=t}handlePremiumChange(t){const e=t.target.checked;this.setPremiumEnabled(e)}render(){const t=this.hasSlotController.test("is-gift-label"),e=this.hasSlotController.test("premium-card-label"),i=this.hasSlotController.test("free-message-label");return V`
|
|
3386
3421
|
<div part="base" class="gift-options" ?hidden=${this.hidden}>
|
|
3387
3422
|
<!-- 🎁 Is this a gift -->
|
|
3388
3423
|
<div class="is-gift" part="is-gift option-container" ?hidden=${!t}>
|
|
@@ -3391,7 +3426,7 @@ void main() {
|
|
|
3391
3426
|
type="checkbox"
|
|
3392
3427
|
part="checkbox"
|
|
3393
3428
|
?checked=${this.isGift}
|
|
3394
|
-
@change=${
|
|
3429
|
+
@change=${s=>{const r=s.target.checked;this.isGift=r}}
|
|
3395
3430
|
/>
|
|
3396
3431
|
<slot name="is-gift-label" part="is-gift-label"></slot>
|
|
3397
3432
|
<span class="is-gift-icon">
|
|
@@ -3410,7 +3445,7 @@ void main() {
|
|
|
3410
3445
|
type="checkbox"
|
|
3411
3446
|
part="checkbox"
|
|
3412
3447
|
.checked=${this.isPremiumChecked}
|
|
3413
|
-
@change=${
|
|
3448
|
+
@change=${s=>{const r=s.target.checked;this.isPremiumChecked=r}}
|
|
3414
3449
|
/>
|
|
3415
3450
|
<slot name="premium-card-label" part="premium-card-label"></slot>
|
|
3416
3451
|
</label>
|
|
@@ -3426,7 +3461,7 @@ void main() {
|
|
|
3426
3461
|
type="checkbox"
|
|
3427
3462
|
part="checkbox"
|
|
3428
3463
|
.checked=${this.isFreeMessageChecked}
|
|
3429
|
-
@change=${
|
|
3464
|
+
@change=${s=>{const r=s.target.checked;this.isFreeMessageChecked=r}}
|
|
3430
3465
|
/>
|
|
3431
3466
|
<slot name="free-message-label"></slot>
|
|
3432
3467
|
</label>
|
|
@@ -3437,9 +3472,9 @@ void main() {
|
|
|
3437
3472
|
placeholder="Leave your message"
|
|
3438
3473
|
.value=${this.freeMessage}
|
|
3439
3474
|
?hidden=${!this.isFreeMessageChecked}
|
|
3440
|
-
@input=${
|
|
3475
|
+
@input=${s=>{this.freeMessage=s.target.value}}
|
|
3441
3476
|
></pbo-textarea>
|
|
3442
3477
|
</div>
|
|
3443
3478
|
<hr part="divider" class="divider" ?hidden=${!this.isGift} />
|
|
3444
3479
|
</div>
|
|
3445
|
-
`}clear(){this.isPremiumChecked=!1,this.isFreeMessageChecked=!1,this.freeMessage=""}};
|
|
3480
|
+
`}clear(){this.isPremiumChecked=!1,this.isFreeMessageChecked=!1,this.freeMessage=""}};It.styles=[Tt,S_];It.dependencies={"pbo-textarea":bt};Jt([S({type:Function})],It.prototype,"onPremiumSelected",2);Jt([S({type:Function})],It.prototype,"onFreeMessageChange",2);Jt([S({type:Function})],It.prototype,"onFreeMessageClear",2);Jt([S({type:Boolean,reflect:!0})],It.prototype,"hidden",2);Jt([S({type:Boolean,reflect:!0})],It.prototype,"expand",2);Jt([S()],It.prototype,"freeMessage",2);Jt([S()],It.prototype,"isGift",2);Jt([S()],It.prototype,"isPremiumChecked",2);Jt([S()],It.prototype,"isFreeMessageChecked",2);Jt([W()],It.prototype,"debouncedFreeMessageChange",2);Jt([Z("onFreeMessageChange")],It.prototype,"handleOnFreeMessageChange",1);Jt([Z("isGift")],It.prototype,"handleIsGiftChange",1);Jt([Z("isFreeMessageChecked")],It.prototype,"handleIsFreeMessageCheckedChange",1);Jt([Z("isPremiumChecked")],It.prototype,"handleIsPremiumCheckedChange",1);Jt([Z("freeMessage")],It.prototype,"handleFreeMessageChange",1);It=Jt([xt("pbo-gift-options")],It);const y0=It,x0=ks,w0=ue,C0=Xe;export{Pn as MessageSelector,B_ as PboButton,z_ as PboButtonGroup,a0 as PboCardSelection,i0 as PboCategory,s0 as PboDrawer,J_ as PboEditor,t0 as PboEditorCardSlider,p0 as PboEditorSelector,C0 as PboFakeLoading,y0 as PboGiftOption,b0 as PboHandwrittenCanvas,m0 as PboHandwrittenForm,w0 as PboImage,o0 as PboPageManager,V_ as PboRadioButton,W_ as PboRadioGroup,He as PboSelector,x0 as PboSpinner,Y_ as PboTextarea,c0 as PboTypeCanvas,Q_ as PboTypeForm,u0 as PboZoomedPreview};
|