framer-plugin
Advanced tools
Comparing version 0.3.3 to 0.3.4
@@ -1,4 +0,4 @@ | ||
var Gt=Object.defineProperty;var Bt=(n,e,t)=>e in n?Gt(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;var i=(n,e,t)=>(Bt(n,typeof e!="symbol"?e+"":e,t),t),et=(n,e,t)=>{if(!e.has(n))throw TypeError("Cannot "+t)};var r=(n,e,t)=>(et(n,e,"read from private field"),t?t.call(n):e.get(n)),c=(n,e,t)=>{if(e.has(n))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(n):e.set(n,t)},m=(n,e,t,o)=>(et(n,e,"write to private field"),o?o.call(n,t):e.set(n,t),t);var Fe=(n,e,t,o)=>({set _(s){m(n,e,s,t)},get _(){return r(n,e,o)}});import q from"react";import{useCallback as an,useEffect as ln,useRef as dn}from"react";var Ot="invoke";function b(n){return Ot in n}function P(n){return n===null}function We(n){return n===!0||n===!1}function d(n){return typeof n=="string"}function ee(n){return typeof n=="number"&&Number.isFinite(n)}function fe(n){return typeof n=="function"}function g(n){return typeof n=="object"&&n!==null&&!Array.isArray(n)}function we(n){return Array.isArray(n)}function A(n,e){throw e||new Error(n?`Unexpected value: ${n}`:"Application entered invalid state")}function l(n,...e){if(n)return;let t=Error("Assertion Error"+(e.length>0?": "+e.join(" "):""));if(t.stack)try{let o=t.stack.split(` | ||
`);o[1]?.includes("assert")?(o.splice(1,1),t.stack=o.join(` | ||
`)):o[0]?.includes("assert")&&(o.splice(0,1),t.stack=o.join(` | ||
`))}catch{}throw t}var Ut="FileAsset",_t="__class";function be(n){return g(n)?n[_t]===Ut:!1}var N=class{constructor(e){i(this,"id");i(this,"url");i(this,"extension");this.url=e.url,this.id=e.id,this.extension=e.extension}};function Pe(n){return n instanceof N}var zt="ImageAsset",Ht="__class";function U(n){return g(n)?n[Ht]===zt:!1}var R,O,Ve=class Ve{constructor(e,t){i(this,"id");i(this,"url");i(this,"thumbnailUrl");i(this,"altText");c(this,R,void 0);c(this,O,void 0);l(b(t)),m(this,O,t),this.url=e.url,this.id=e.id,this.thumbnailUrl=e.thumbnailUrl,this.altText=e.altText}cloneWithAttributes({altText:e}){return new Ve({__class:"ImageAsset",id:this.id,url:this.url,thumbnailUrl:this.thumbnailUrl,altText:e!==void 0?e:this.altText},r(this,O))}async measure(){return jt(this.url)}async getData(){if(r(this,R)&&r(this,R).bytes.length>0)return r(this,R);let e=await r(this,O).invoke("getImageData",{id:this.id});if(!e)throw new Error("Failed to load image data");return m(this,R,e),e}async loadBitmap(){let{mimeType:e,bytes:t}=await this.getData(),o=new Blob([t],{type:e});return createImageBitmap(o)}async loadImage(){let e=await this.getData(),t=URL.createObjectURL(new Blob([e.bytes]));return new Promise((o,s)=>{let a=new Image;a.onload=()=>o(a),a.onerror=()=>s(),a.src=t})}};R=new WeakMap,O=new WeakMap;var y=Ve;function xe(n){return n instanceof y}function F(n){return n.type==="bytes"?[n.bytes.buffer]:[]}function Kt(n){if(!g(n))return!1;let e="bytes",t="mimeType";return!(!(e in n)||!(t in n)||!(n[e]instanceof Uint8Array)||!d(n[t]))}async function te(n){if(n instanceof File)return Me(n);let e=await tt(n.image);return{name:n.name,altText:n.altText,...e}}async function Re(n){if(n instanceof File)return Me(n);let e=await tt(n.file);return{name:n.name,...e}}async function tt(n){return n instanceof File?Me(n):Kt(n)?{type:"bytes",mimeType:n.mimeType,bytes:n.bytes}:{type:"url",url:n}}function Le(n){return Promise.all(n.map(te))}async function Me(n){return new Promise((e,t)=>{let o=new FileReader;o.onload=s=>{let a=n.type,u=s.target?.result;if(!u||!(u instanceof ArrayBuffer)){t(new Error("Failed to read file, arrayBuffer is null"));return}let k=new Uint8Array(u);e({bytes:k,mimeType:a,type:"bytes",name:n.name})},o.onerror=s=>{t(s)},o.readAsArrayBuffer(n)})}async function jt(n){let e=n instanceof File,t=e?URL.createObjectURL(n):n,o=new Image;return o.crossOrigin="anonymous",o.src=t,await o.decode().finally(()=>{e&&URL.revokeObjectURL(t)}),{height:o.height,width:o.width}}var nt="__class",Ee="LinearGradient",Ge="RadialGradient",Be="ConicGradient";function Te(n){if(!g(n))return!1;switch(n[nt]){case Ee:case Ge:case Be:return!0;default:return!1}}function ne(n){return n instanceof _||n instanceof z||n instanceof H}function it(n){if(n instanceof _)return{__class:Ee,angle:n.angle,stops:n.stops};if(n instanceof z)return{__class:Ge,width:n.width,height:n.height,x:n.x,y:n.y,stops:n.stops};if(n instanceof H)return{__class:Be,angle:n.angle,x:n.x,y:n.y,stops:n.stops};A(n)}function Ne(n){switch(n[nt]){case Ee:return new _(n);case Ge:return new z(n);case Be:return new H(n);default:A(n)}}var _=class n{constructor(e){i(this,"angle");i(this,"stops");this.angle=e.angle,this.stops=e.stops,Object.freeze(this)}cloneWithAttributes(e){return new n({angle:e.angle??this.angle,stops:e.stops??this.stops})}toCSS(){let e=this.stops.map(t=>`${t.color} ${t.position*100}%`).join(", ");return`linear-gradient(${this.angle}deg, ${e})`}},z=class n{constructor(e){i(this,"width");i(this,"height");i(this,"x");i(this,"y");i(this,"stops");this.width=e.width,this.height=e.height,this.x=e.x,this.y=e.y,this.stops=e.stops,Object.freeze(this)}cloneWithAttributes(e){return new n({width:e.width??this.width,height:e.height??this.height,x:e.x??this.x,y:e.y??this.y,stops:e.stops??this.stops})}toCSS(){let e=this.stops.map((t,o)=>{let s=this.stops[o+1],a=t.position===1&&s?.position===1?t.position-1e-4:t.position;return`${t.color} ${a*100}%`}).join(", ");return`radial-gradient(${this.width} ${this.height} at ${this.x} ${this.y}, ${e})`}},H=class n{constructor(e){i(this,"angle");i(this,"x");i(this,"y");i(this,"stops");this.angle=e.angle,this.x=e.x,this.y=e.y,this.stops=e.stops,Object.freeze(this)}cloneWithAttributes(e){return new n({angle:e.angle??this.angle,x:e.x??this.x,y:e.y??this.y,stops:e.stops??this.stops})}toCSS(){let e=this.stops.map(t=>`${t.color} ${t.position*360}deg`).join(", ");return`conic-gradient(from ${this.angle}deg at ${this.x} ${this.y}, ${e})`}};var W=class{constructor(e){i(this,"selector");i(this,"family");i(this,"weight");i(this,"style");this.selector=e.selector,this.family=e.family,this.weight=e.weight,this.style=e.style}},ot=new Map;function Oe(n){let e=ot.get(n.selector);if(e)return e;let t=new W(n);return ot.set(n.selector,t),t}function ie(n){return{__class:"Font",selector:n.selector,family:n.family,weight:n.weight,style:n.style}}var I,Ue=class Ue{constructor(e,t){i(this,"id");i(this,"name");i(this,"light");i(this,"dark");c(this,I,void 0);l(d(e.id),"Style must have an id"),this.id=e.id,this.name=e.name,this.light=e.light,this.dark=e.dark,l(b(t)),m(this,I,t)}async setAttributes(e){let t=await r(this,I).invoke("setColorStyleAttributes",this.id,e);return t?new Ue(t,r(this,I)):null}async getPluginData(e){return r(this,I).invoke("getPluginDataForNode",this.id,e)}async setPluginData(e,t){return r(this,I).invoke("setPluginDataForNode",this.id,e,t)}async getPluginDataKeys(){return r(this,I).invoke("getPluginDataKeysForNode",this.id)}async remove(){return r(this,I).invoke("removeColorStyle",this.id)}};I=new WeakMap;var L=Ue,$t="TextStyle",Xt="__class";function rt(n){return g(n)?n[Xt]===$t:!1}var C,_e=class _e{constructor(e,t){i(this,"id");i(this,"name");i(this,"tag");i(this,"font");i(this,"boldFont");i(this,"italicFont");i(this,"boldItalicFont");i(this,"color");i(this,"transform");i(this,"alignment");i(this,"decoration");i(this,"balance");i(this,"breakpoints");i(this,"minWidth");i(this,"fontSize");i(this,"letterSpacing");i(this,"lineHeight");i(this,"paragraphSpacing");c(this,C,void 0);l(d(e.id),"Style must have an id"),this.id=e.id,this.name=e.name,this.tag=e.tag,this.font=new W(e.font),this.boldFont=e.boldFont?new W(e.boldFont):null,this.italicFont=e.italicFont?new W(e.italicFont):null,this.boldItalicFont=e.boldItalicFont?new W(e.boldItalicFont):null,this.color=e.color,this.transform=e.transform,this.alignment=e.alignment,this.decoration=e.decoration,this.balance=e.balance,this.breakpoints=e.breakpoints,this.minWidth=e.minWidth,this.fontSize=e.fontSize,this.letterSpacing=e.letterSpacing,this.lineHeight=e.lineHeight,this.paragraphSpacing=e.paragraphSpacing,l(b(t)),m(this,C,t)}async setAttributes(e){let t=await r(this,C).invoke("setTextStyleAttributes",this.id,e);return t?new _e(t,r(this,C)):null}async getPluginData(e){return r(this,C).invoke("getPluginDataForNode",this.id,e)}async setPluginData(e,t){return r(this,C).invoke("setPluginDataForNode",this.id,e,t)}async getPluginDataKeys(){return r(this,C).invoke("getPluginDataKeysForNode",this.id)}async remove(){return r(this,C).invoke("removeTextStyle",this.id)}};C=new WeakMap;var T=_e;function K(n){return n instanceof T}function st(n){return{__class:"TextStyle",id:n.id,name:n.name,tag:n.tag,font:ie(n.font),boldFont:n.boldFont?ie(n.font):null,italicFont:n.italicFont?ie(n.italicFont):null,boldItalicFont:n.boldItalicFont?ie(n.boldItalicFont):null,color:n.color,transform:n.transform,alignment:n.alignment,decoration:n.decoration,balance:n.balance,breakpoints:n.breakpoints,minWidth:n.minWidth,fontSize:n.fontSize,letterSpacing:n.letterSpacing,lineHeight:n.lineHeight,paragraphSpacing:n.paragraphSpacing}}function M(n){if(qt(n))return Zt(n);if(we(n))return n.map(M);if(g(n)){let e={};for(let t in n)e[t]=M(n[t]);return e}return n}function at(n,e){let t={};for(let o in n)t[o]=ze(n[o],e);return t}function ze(n,e){if(Yt(n))switch(n.__class){case"ImageAsset":return new y(n,e);case"FileAsset":return new N(n);case"LinearGradient":case"RadialGradient":case"ConicGradient":return Ne(n);case"TextStyle":return new T(n,e);default:A(n)}if(g(n)){let t={};for(let o in n)t[o]=ze(n[o],e);return t}return we(n)?n.map(t=>ze(t,e)):n}function Yt(n){return!!(U(n)||be(n)||Te(n))}function qt(n){return!!(xe(n)||Pe(n)||ne(n)||K(n))}function Zt(n){if(xe(n))return{__class:"ImageAsset",id:n.id,thumbnailUrl:n.thumbnailUrl,url:n.url,altText:n.altText};if(Pe(n))return{__class:"FileAsset",id:n.id,extension:n.extension,url:n.url};if(ne(n))return it(n);if(K(n))return st(n);A(n)}function Qt(n,e){for(let t in n){let o=n[t];U(o)&&(n[t]=new y(o,e)),be(o)&&(n[t]=new N(o))}}var x,Ie=class{constructor(e,t){i(this,"id");i(this,"name");c(this,x,void 0);l(d(e.id),"Node must have an id"),l(d(e.name),"Node must have a name"),this.id=e.id,this.name=e.name,l(b(t)),m(this,x,t),Object.freeze(this)}async getItemIds(){return r(this,x).invoke("getManagedCollectionItemIds",this.id)}async setItemOrder(e){return r(this,x).invoke("setManagedCollectionItemOrder",this.id,e)}async getFields(){return r(this,x).invoke("getManagedCollectionFields",this.id)}async setFields(e){return r(this,x).invoke("setManagedCollectionFields",this.id,e)}async addItems(e){return r(this,x).invoke("addManagedCollectionItems",this.id,e)}async removeItems(e){return r(this,x).invoke("removeManagedCollectionItems",this.id,e)}async setPluginData(e,t){return r(this,x).invoke("setPluginDataForNode",this.id,e,t)}async getPluginData(e){return r(this,x).invoke("getPluginDataForNode",this.id,e)}async getPluginDataKeys(){return r(this,x).invoke("getPluginDataKeysForNode",this.id)}};x=new WeakMap;var S,oe=class{constructor(e,t){i(this,"id");i(this,"name");c(this,S,void 0);l(d(e.id),"Node must have an id"),l(d(e.name),"Node must have a name"),this.id=e.id,this.name=e.name,l(b(t)),m(this,S,t),Object.freeze(this)}async getFields(){return r(this,S).invoke("getCollectionFields",this.id)}async getItems(){return(await r(this,S).invoke("getCollectionItems",this.id)).map(t=>new He(t,r(this,S)))}async setPluginData(e,t){return r(this,S).invoke("setPluginDataForNode",this.id,e,t)}async getPluginData(e){return r(this,S).invoke("getPluginDataForNode",this.id,e)}async getPluginDataKeys(){return r(this,S).invoke("getPluginDataKeysForNode",this.id)}};S=new WeakMap;var V,He=class{constructor(e,t){i(this,"id");i(this,"slug");i(this,"fieldData");c(this,V,void 0);this.id=e.id,this.slug=e.slug,this.fieldData=e.fieldData,Qt(this.fieldData,t),l(b(t)),m(this,V,t),Object.freeze(this),Object.freeze(this.fieldData)}async setPluginData(e,t){return r(this,V).invoke("setPluginDataForNode",this.id,e,t)}async getPluginData(e){return r(this,V).invoke("getPluginDataForNode",this.id,e)}async getPluginDataKeys(){return r(this,V).invoke("getPluginDataKeysForNode",this.id)}};V=new WeakMap;var Jt=(()=>{let n=null;return{disableUntilMouseUp:()=>{if(n)return;n=document.createElement("style"),n.textContent="* { pointer-events: none !important; user-select: none !important; -webkit-user-select: none !important; }",document.head.appendChild(n);let e=()=>{n&&(document.head.removeChild(n),n=null,s())},t=a=>{a.buttons>0&&a.buttons&1||e()},o=()=>{e()};window.addEventListener("pointerup",t,!0),window.addEventListener("pointermove",t,!0),window.addEventListener("blur",o);function s(){window.removeEventListener("pointerup",t,!0),window.removeEventListener("pointermove",t,!0),window.removeEventListener("blur",o)}}}})(),lt=5,en=(()=>{let n=1;return{next:()=>`drag-${n++}`}})();function tn(){}function dt(n,e,t){if(!(n.mode==="canvas"||n.mode==="default"))return tn;l(b(n));let o=en.next(),s=document.body.style.cursor,a={type:"idle"},u=document.body,k=h=>{a.type!=="idle"&&(a.type==="dragging"&&n.invoke("onDragEnd",{...h,dragSessionId:o}),a={type:"idle"},Et())},ge=h=>{if(a.type==="idle")return;if(!(h.buttons>0&&!!(h.buttons&1))){k({cancelled:!1});return}let{clientX:pe,clientY:Q}=h;if(a.type==="pointerDown"){let J=pe-a.dragStart.mouse.x,Je=Q-a.dragStart.mouse.y;if(Math.abs(J)<lt&&Math.abs(Je)<lt)return;a={type:"dragging",dragStart:a.dragStart},n.invoke("onDragStart",a.dragStart),document.getSelection()?.empty(),Jt.disableUntilMouseUp()}u.setPointerCapture(h.pointerId);let he={x:pe,y:Q};n.invoke("onDrag",{dragSessionId:o,mouse:he}).then(J=>{a.type==="dragging"&&(document.body.style.cursor=J??"")})},Ye=h=>{h.key==="Escape"&&k({cancelled:!0})},qe=()=>{k({cancelled:!0})},Ze=h=>{k({cancelled:!0});let Z=e.getBoundingClientRect(),pe={x:Z.x,y:Z.y,width:Z.width,height:Z.height},Q,he=e.querySelectorAll("svg");if(he.length===1){let ye=he.item(0).getBoundingClientRect();Q={x:ye.x,y:ye.y,width:ye.width,height:ye.height}}let J={x:h.clientX,y:h.clientY};a={type:"pointerDown",dragStart:{dragSessionId:o,elementRect:pe,svgRect:Q,mouse:J}},n.invoke("setDragData",o,t()),u.addEventListener("pointermove",ge,!0),u.addEventListener("pointerup",ge,!0),window.addEventListener("keydown",Ye,!0),window.addEventListener("blur",qe)},Qe=()=>{let h=t();h.type==="detachedComponentLayers"&&n.invoke("preloadDetachedComponentLayers",h.url),h.type==="image"&&n.invoke("preloadImageUrlForInsertion",h.image),h.previewImage&&n.invoke("preloadDragPreviewImage",h.previewImage)};e.addEventListener("pointerdown",Ze),e.addEventListener("mouseenter",Qe);function Et(){document.body.style.cursor=s,u.removeEventListener("pointermove",ge,!0),u.removeEventListener("pointerup",ge,!0),window.removeEventListener("keydown",Ye,!0),window.removeEventListener("blur",qe)}return()=>{e.removeEventListener("pointerdown",Ze),e.removeEventListener("mouseenter",Qe),k({cancelled:!0})}}var re=class extends Error{};var nn={canvas:!0,default:!0,image:!0,editImage:!0,configureManagedCollection:!0,syncManagedCollection:!0,collection:!0};function ut(n){return d(n)&&n in nn}var on={methodResponse:!0,pluginReadyResponse:!0,subscriptionMessage:!0};function rn(n){return d(n)&&n in on}function ct(n){return g(n)&&rn(n["type"])}var me,f,v,D=class{constructor(e,t){i(this,"id");c(this,me,void 0);c(this,f,void 0);c(this,v,void 0);l(d(e.id),"Node must have an id"),this.id=e.id,m(this,f,t),m(this,me,e.originalId??null),l(b(t)),m(this,v,t)}get isReplica(){return r(this,me)!==null}remove(){return r(this,f).removeNode(this.id)}select(){return r(this,f).setSelection([this.id])}clone(){return r(this,f).cloneNode(this.id)}setAttributes(e){return r(this,f).setAttributes(this.id,e)}getRect(){return r(this,f).getRect(this.id)}zoomIntoView(e){return r(this,f).zoomIntoView([this.id],e)}getParent(){return r(this,f).getParent(this.id)}getChildren(){return E(this)?Promise.resolve([]):r(this,f).getChildren(this.id)}async getNodesWithType(e){return E(this)?Promise.resolve([]):(await r(this,v).invoke("getNodesWithType",this.id,e)).map(o=>p(o,r(this,f)))}async getNodesWithAttribute(e){return E(this)?Promise.resolve([]):(await r(this,v).invoke("getNodesWithAttribute",this.id,e)).map(o=>p(o,r(this,f)))}async getNodesWithAttributeSet(e){return E(this)?Promise.resolve([]):(await r(this,v).invoke("getNodesWithAttributeSet",this.id,e)).map(o=>p(o,r(this,f)))}async*walk(){if(yield this,!E(this))for(let e of await this.getChildren())yield*e.walk()}async getPluginData(e){return r(this,v).invoke("getPluginDataForNode",this.id,e)}async setPluginData(e,t){return r(this,v).invoke("setPluginDataForNode",this.id,e,t)}async getPluginDataKeys(){return r(this,v).invoke("getPluginDataKeysForNode",this.id)}};me=new WeakMap,f=new WeakMap,v=new WeakMap;var G=class extends D{constructor(t,o){super(t,o);i(this,"__class","FrameNode");i(this,"name");i(this,"visible");i(this,"locked");i(this,"backgroundColor");i(this,"backgroundImage");i(this,"backgroundGradient");i(this,"rotation");i(this,"opacity");i(this,"borderRadius");i(this,"position");i(this,"top");i(this,"right");i(this,"bottom");i(this,"left");i(this,"centerX");i(this,"centerY");i(this,"width");i(this,"height");i(this,"maxWidth");i(this,"minWidth");i(this,"maxHeight");i(this,"minHeight");i(this,"aspectRatio");l(t.__class==="FrameNode","FrameNode must have a __class property"),this.name=t.name??null,this.visible=t.visible??!0,this.locked=t.locked??!1,this.backgroundColor=t.backgroundColor??null,this.backgroundImage=t.backgroundImage?new y(t.backgroundImage,o):null,this.rotation=t.rotation??0,this.opacity=t.opacity??1,this.borderRadius=t.borderRadius??null,this.backgroundGradient=Te(t.backgroundGradient)?Ne(t.backgroundGradient):null,l(t.position,"Must have a position"),this.position=t.position,this.left=t.left??null,this.right=t.right??null,this.top=t.top??null,this.bottom=t.bottom??null,this.centerX=t.centerX??null,this.centerY=t.centerY??null,this.width=t.width??null,this.height=t.height??null,this.maxWidth=t.maxWidth??null,this.minWidth=t.minWidth??null,this.maxHeight=t.maxHeight??null,this.minHeight=t.minHeight??null,this.aspectRatio=t.aspectRatio??null,Object.freeze(this)}clone(){return super.clone()}setAttributes(t){return super.setAttributes(t)}},j,se=class extends D{constructor(t,o){super(t,o);i(this,"__class","TextNode");i(this,"name");i(this,"visible");i(this,"locked");i(this,"rotation");i(this,"opacity");i(this,"inlineTextStyle");i(this,"position");i(this,"top");i(this,"right");i(this,"bottom");i(this,"left");i(this,"centerX");i(this,"centerY");i(this,"width");i(this,"height");i(this,"maxWidth");i(this,"minWidth");i(this,"maxHeight");i(this,"minHeight");c(this,j,void 0);l(b(o)),m(this,j,o),this.name=t.name??null,this.visible=t.visible??!0,this.locked=t.locked??!1,this.rotation=t.rotation??0,this.opacity=t.opacity??1,this.inlineTextStyle=t.inlineTextStyle?new T(t.inlineTextStyle,o):null,l(t.position,"Must have a position"),this.position=t.position,this.left=t.left??null,this.right=t.right??null,this.top=t.top??null,this.bottom=t.bottom??null,this.centerX=t.centerX??null,this.centerY=t.centerY??null,this.width=t.width??null,this.height=t.height??null,this.maxWidth=t.maxWidth??null,this.minWidth=t.minWidth??null,this.maxHeight=t.maxHeight??null,this.minHeight=t.minHeight??null,Object.freeze(this)}clone(){return super.clone()}setAttributes(t){return super.setAttributes(t)}async setText(t){await r(this,j).invoke("setTextForNode",this.id,t)}async getText(){return r(this,j).invoke("getTextForNode",this.id)}};j=new WeakMap;var ae=class extends D{constructor(t,o){super(t,o);i(this,"__class","SVGNode");i(this,"name");i(this,"visible");i(this,"locked");i(this,"svg");i(this,"rotation");i(this,"opacity");i(this,"position");i(this,"top");i(this,"right");i(this,"bottom");i(this,"left");i(this,"centerX");i(this,"centerY");i(this,"width");i(this,"height");l(t.svg,"SVG node must have a non-empty SVG string"),this.name=t.name??null,this.visible=t.visible??!0,this.locked=t.locked??!1,this.svg=t.svg,this.rotation=t.rotation??0,this.opacity=t.opacity??1,l(t.position,"Must have a position"),this.position=t.position??null,this.left=t.left??null,this.right=t.right??null,this.top=t.top??null,this.bottom=t.bottom??null,this.centerX=t.centerX??null,this.centerY=t.centerY??null,this.width=t.width??null,this.height=t.height??null,Object.freeze(this)}clone(){return super.clone()}setAttributes(t){return super.setAttributes(t)}},le=class extends D{constructor(t,o){super(t,o);i(this,"__class","ComponentInstanceNode");i(this,"name");i(this,"visible");i(this,"locked");i(this,"componentIdentifier");i(this,"insertURL");i(this,"componentName");i(this,"controls");i(this,"rotation");i(this,"opacity");i(this,"position");i(this,"top");i(this,"right");i(this,"bottom");i(this,"left");i(this,"centerX");i(this,"centerY");i(this,"width");i(this,"height");i(this,"maxWidth");i(this,"minWidth");i(this,"maxHeight");i(this,"minHeight");i(this,"aspectRatio");l(t.componentIdentifier,"ComponentInstance node must have a component identifier"),this.name=t.name??null,this.visible=t.visible??!0,this.locked=t.locked??!1,this.componentIdentifier=t.componentIdentifier,this.componentName=t.componentName??null,this.insertURL=t.insertURL??null,this.controls=at(t.controls??{},o),this.rotation=t.rotation??0,this.opacity=t.opacity??1,l(t.position,"Must have a position"),this.position=t.position,this.left=t.left??null,this.right=t.right??null,this.top=t.top??null,this.bottom=t.bottom??null,this.centerX=t.centerX??null,this.centerY=t.centerY??null,this.width=t.width??null,this.height=t.height??null,this.maxWidth=t.maxWidth??null,this.minWidth=t.minWidth??null,this.maxHeight=t.maxHeight??null,this.minHeight=t.minHeight??null,this.aspectRatio=t.aspectRatio??null,Object.freeze(this)}clone(){return super.clone()}setAttributes(t){return super.setAttributes(t)}},de=class extends D{constructor(t,o){super(t,o);i(this,"_class","WebPageNode");Object.freeze(this)}clone(){return super.clone()}setAttributes(t){return super.setAttributes(t)}},ue=class extends D{constructor(t,o){super(t,o);i(this,"__class","ComponentNode");i(this,"name");i(this,"componentIdentifier");i(this,"insertURL");i(this,"componentName");l(t.componentIdentifier,"ComponentNode must have a componentIdentifier"),this.componentIdentifier=t.componentIdentifier,this.insertURL=t.insertURL??null,this.componentName=t.componentName??null,this.name=t.name??null,Object.freeze(this)}clone(){return super.clone()}setAttributes(t){return super.setAttributes(t)}},ce=class extends D{constructor(t,o){super(t,o);i(this,"__class","UnknownNode");Object.freeze(this)}clone(){throw Error("Can not clone unknown node")}setAttributes(t){throw Error("Can not set attributes on unknown node")}};function p(n,e){switch(n.__class){case"WebPageNode":return new de(n,e);case"ComponentNode":return new ue(n,e);case"ComponentInstanceNode":return new le(n,e);case"FrameNode":return new G(n,e);case"SVGNode":return new ae(n,e);case"TextNode":return new se(n,e);case"UnknownNode":return new ce(n,e);default:return new ce(n,e)}}function Ke(n){return M(n)}function Ce(n){return n instanceof G}function mt(n){return n instanceof se}function gt(n){return n instanceof ae}function Se(n){return n instanceof le}function pt(n){return n instanceof de}function ht(n){return n instanceof ue}function E(n){return n instanceof ce}function ve(n){return!!(Ce(n)||mt(n)||Se(n)||gt(n)||E(n))}function je(n){return!!(pt(n)||ht(n)||E(n))}var $=null;function yt(n){if(!$){let t=document.createElement("style");document.head.appendChild(t),$=t.sheet}if(!$){n();return}let e=$.insertRule("* { transition: none !important; animation: none !important; }");n(),requestAnimationFrame(()=>{requestAnimationFrame(()=>{$&&$.deleteRule(e)})})}var sn=2,De,Ae,X,B,Y,w,ke=class{constructor({isTestEnv:e}={}){c(this,De,0);c(this,Ae,0);c(this,X,[]);c(this,B,void 0);c(this,Y,new Map);c(this,w,void 0);i(this,"subscriptions",new Map);i(this,"onMessage",e=>{let t=e.data;if(ct(t))switch(t.type){case"pluginReadyResponse":{if(!e.source)throw new Error("No 'source' on incoming message: "+t.type);l(r(this,w)===t.mode,"Mode must match"),this.applyPluginTheme(t.theme),m(this,B,(s,a)=>window.parent.postMessage(s,e.origin,a));for(let s of r(this,X))r(this,B).call(this,...s);m(this,X,[]);break}case"methodResponse":{let o=r(this,Y).get(t.id);if(!o)throw new Error(`No handler for response with id ${t.id}`);r(this,Y).delete(t.id),t.error?o.reject(new re(t.error)):o.resolve(t.result);break}case"subscriptionMessage":{let{topic:o,payload:s}=t,a=this.subscriptions.get(o);if(!a)throw new Error("Received a subscription message but no handler present");for(let u of a)u(s);break}default:A(t)}});i(this,"applyPluginTheme",e=>{yt(()=>{document.body.setAttribute("data-framer-theme",e.mode);for(let t in e.tokens)document.body.style.setProperty(t,e.tokens[t])})});if(e){m(this,w,"canvas");return}if(typeof window>"u"){console.warn("Framer Plugin API is not supported in non-browser environments"),m(this,w,"canvas");return}let o=new URL(window.location.href).searchParams.get("mode");l(ut(o),`Invalid mode: ${o}`),m(this,w,o),window.addEventListener("message",this.onMessage);let s={type:"pluginReadySignal",breakingChangesVersion:sn};window.parent.postMessage(s,"*"),this.subscribe("theme",this.applyPluginTheme),window.addEventListener("pointerdown",()=>{this.invoke("onPointerDown")})}get mode(){return r(this,w)}invoke(e,...t){return this.invokeTransferable(e,void 0,...t)}invokeTransferable(e,t,...o){return new Promise((s,a)=>{let u={args:o,methodName:e,id:Fe(this,De)._++,type:"methodInvocation"},k=s;r(this,Y).set(u.id,{resolve:k,reject:a}),this.queueMessage(u,t)})}subscribe(e,t){this.queueMessage({type:"subscribe",topic:e});let o=this.subscriptions.get(e)??new Set;return o.add(t),this.subscriptions.set(e,o),()=>{let s=this.subscriptions.get(e)??new Set;s.delete(t),s.size===0&&this.queueMessage({type:"unsubscribe",topic:e}),this.subscriptions.set(e,s)}}queueMessage(e,t){if(!r(this,B)){r(this,X).push([e,t]);return}r(this,B).call(this,e,t)}async showUI(e){return this.invoke("showUI",e)}async hideUI(){return this.invoke("hideUI")}async closePlugin(e,t){return this.invoke("closePlugin",e,t)}async getCurrentUser(){return this.invoke("getCurrentUser")}async getSelection(){return(await this.invoke("getSelection")).map(t=>{let o=p(t,this);return l(ve(o)),o})}async setSelection(e){let t=d(e)?[e]:Array.from(e);return this.invoke("setSelection",t)}subscribeToSelection(e){return this.subscribe("selection",t=>{let o=t.map(s=>{let a=p(s,this);return l(ve(a)),a});e(o)})}async getCanvasRoot(){let e=await this.invoke("getCanvasRoot"),t=p(e,this);return l(je(t)),t}subscribeToCanvasRoot(e){return this.subscribe("canvasRoot",t=>{let o=p(t,this);l(je(o)),e(o)})}async getPublishInfo(){return this.invoke("getPublishInfo")}subscribeToPublishInfo(e){return this.subscribe("publishInfo",e)}async createFrameNode(e,t){let o=Ke(e),s=await this.invoke("createNode","FrameNode",t??null,o);if(!s)return null;let a=p(s,this);return l(a instanceof G),a}async removeNode(e){return this.invoke("removeNode",e)}async cloneNode(e){let t=await this.invoke("cloneNode",e);return t?p(t,this):null}async getNode(e){let t=await this.invoke("getNode",e);return t?p(t,this):null}async getParent(e){let t=await this.invoke("getParent",e);return t?p(t,this):null}async getChildren(e){return(await this.invoke("getChildren",e)).map(o=>{let s=p(o,this);return l(ve(s)),s})}async getRect(e){return this.invoke("getRect",e)}async zoomIntoView(e,t){let o=d(e)?[e]:Array.from(e);return this.invoke("zoomIntoView",o,t)}async setAttributes(e,t){let o=Ke(t),s=await this.invoke("setAttributes",e,o);return s?p(s,this):null}async setParent(e,t,o){return this.invoke("setParent",e,t,o)}async getNodesWithType(e){return(await this.invoke("getNodesWithType",null,e)).map(o=>p(o,this))}async getNodesWithAttribute(e){return(await this.invoke("getNodesWithAttribute",null,e)).map(o=>p(o,this))}async getNodesWithAttributeSet(e){return(await this.invoke("getNodesWithAttributeSet",null,e)).map(o=>p(o,this))}async getImage(){let e=await this.invoke("getImage");return e?new y(e,this):null}subscribeToImage(e){return this.subscribe("image",t=>{if(!t){e(null);return}e(new y(t,this))})}async addImage(e){let t=await te(e),o=F(t);return this.invokeTransferable("addImage",o,t)}async setImage(e){let t=await te(e),o=F(t);return this.invokeTransferable("setImage",o,t)}async uploadImage(e){let t=await te(e),o=F(t),s=await this.invokeTransferable("uploadImage",o,t);return new y(s,this)}async addImages(e){let t=await Le(e),o=t.flatMap(F);await this.invokeTransferable("addImages",o,t)}async uploadImages(e){let t=await Le(e),o=t.flatMap(F),s=await this.invokeTransferable("uploadImages",o,t),a=[];for(let u of s)a.push(new y(u,this));return a}async uploadFile(e){let t=await Re(e),o=await this.invokeTransferable("uploadFile",F(t),t);return new N(o)}async uploadFiles(e){let t=await Promise.all(e.map(Re)),o=t.flatMap(F),s=await this.invokeTransferable("uploadFiles",o,t),a=[];for(let u of s)a.push(new N(u));return a}async addSVG(e){return this.invoke("addSVG",e)}async addComponentInstance({url:e,attributes:t}){let o=M(t),s=await this.invoke("addComponentInstance",{url:e,attributes:g(o)?o:void 0}),a=p(s,this);return l(Se(a)),a}async addDetachedComponentLayers({url:e,layout:t,attributes:o}){let s=M(o),a=await this.invoke("addDetachedComponentLayers",{url:e,layout:t,attributes:g(s)?s:void 0}),u=p(a,this);return l(Ce(u)),u}async preloadDetachedComponentLayers(e){await this.invoke("preloadDetachedComponentLayers",e)}async preloadImageUrlForInsertion(e){await this.invoke("preloadImageUrlForInsertion",e)}async preloadDragPreviewImage(e){await this.invoke("preloadDragPreviewImage",e)}async getText(){return this.invoke("getText")}async setText(e){return this.invoke("setText",e)}async addText(e,t){return this.invoke("addText",e,t)}async setCustomCode(e){return this.invoke("setCustomCode",e)}async getCustomCode(){return this.invoke("getCustomCode")}subscribeToCustomCode(e){return this.subscribe("customCode",e)}subscribeToText(e){return this.subscribe("text",e)}makeDraggable(e,t){return dt(this,e,t)}async getManagedCollection(){let e=await this.invoke("getManagedCollection");return l(e,"Collection data must be defined"),new Ie(e,this)}async getCollection(){let e=await this.invoke("getCollection");return l(e,"Collection data must be defined"),new oe(e,this)}async getCollections(){return(await this.invoke("getCollections")).map(t=>new oe(t,this))}notify(e,t){let o=`notification-${Fe(this,Ae)._++}`;return this.invoke("notify",e,{notificationId:o,variant:t?.variant??"info",buttonText:t?.button?.text,durationMs:t?.durationMs}).then(s=>{s==="actionButtonClicked"&&t?.button?.onClick&&t.button.onClick(),t?.onDisappear&&t.onDisappear()}),{close:()=>this.invoke("closeNotification",o)}}async getPluginData(e){return this.invoke("getPluginData",e)}async setPluginData(e,t){return this.invoke("setPluginData",e,t)}async getPluginDataKeys(){return this.invoke("getPluginDataKeys")}async getColorStyles(){return(await this.invoke("getColorStyles")).map(t=>new L(t,this))}async getColorStyle(e){let t=await this.invoke("getColorStyle",e);return t?new L(t,this):null}async createColorStyle(e){let t=await this.invoke("createColorStyle",e);return new L(t,this)}subscribeToColorStyles(e){return this.subscribe("colorStyles",t=>{let o=t.map(s=>new L(s,this));return e(o)})}async getTextStyles(){return(await this.invoke("getTextStyles")).map(t=>new T(t,this))}async getTextStyle(e){let t=await this.invoke("getTextStyle",e);return t?new T(t,this):null}async createTextStyle(e){let t=await this.invoke("createTextStyle",e);return new T(t,this)}subscribeToTextStyles(e){return this.subscribe("textStyles",t=>{let o=t.map(s=>new T(s,this));return e(o)})}async getFont(e,t){let o=await this.invoke("getFont",e,t);return o?Oe(o):null}async getFonts(){return(await this.invoke("getFonts")).map(Oe)}};De=new WeakMap,Ae=new WeakMap,X=new WeakMap,B=new WeakMap,Y=new WeakMap,w=new WeakMap;var $e=new ke;function Xe(n,e){let t=un(()=>fe(e)?e():e);ln(()=>{let o=n.current;if(o instanceof HTMLElement)return $e.makeDraggable(o,t)},[t])}function un(n){let e=dn(n);return e.current=n,an((...t)=>e.current(...t),[])}var cn=q.forwardRef(function({data:e,children:t,...o},s){let a=q.useRef(null);if(Xe(a,e),q.isValidElement(t)){let u=Object.assign({},o);return g(t.props)&&Object.assign(u,t.props),u.ref=pn(a,s,t.ref),q.cloneElement(t,u)}return q.Children.count(t)>1&&q.Children.only(t),null}),mn="current";function gn(n){return g(n)&&mn in n}function pn(...n){return e=>{for(let t of n)fe(t)?t(e):gn(t)&&(t.current=e)}}var hn={fixed:!0,sticky:!0,absolute:!0,relative:!0},ft="position";function Li(n){if(!(ft in n))return!1;let e=n[ft];return d(e)&&hn[e]===!0}var bt="top";function Mi(n){if(!(bt in n))return!1;let e=n[bt];return d(e)||P(e)}var Pt="width";function Vi(n){if(!(Pt in n))return!1;let e=n[Pt];return d(e)||P(e)}var xt="maxWidth";function Ei(n){if(!(xt in n))return!1;let e=n[xt];return d(e)||P(e)}var Tt="aspectRatio";function Gi(n){if(!(Tt in n))return!1;let e=n[Tt];return ee(e)||P(e)}var Nt="name";function Bi(n){if(!(Nt in n))return!1;let e=n[Nt];return d(e)||P(e)}var It="visible";function Oi(n){if(!(It in n))return!1;let e=n[It];return We(e)}var Ct="locked";function Ui(n){if(!(Ct in n))return!1;let e=n[Ct];return We(e)}var St="backgroundColor";function _i(n){if(!(St in n))return!1;let e=n[St];return d(e)||P(e)}var vt="backgroundImage";function zi(n){if(!(vt in n))return!1;let e=n[vt];return e instanceof y||P(e)}var kt="backgroundImage";function Hi(n){if(!(kt in n))return!1;let e=n[kt];return e instanceof y?!1:U(e)||P(e)}var Dt="backgroundGradient";function Ki(n){if(!(Dt in n))return!1;let e=n[Dt];return ne(e)||P(e)}var At="backgroundGradient";function ji(n){if(!(At in n))return!1;let e=n[At];return g(e)||P(e)}var Ft="rotation";function $i(n){if(!(Ft in n))return!1;let e=n[Ft];return ee(e)}var Wt="opacity";function Xi(n){if(!(Wt in n))return!1;let e=n[Wt];return ee(e)}var wt="borderRadius";function Yi(n){if(!(wt in n))return!1;let e=n[wt];return d(e)||P(e)}var Rt="svg";function qi(n){if(!(Rt in n))return!1;let e=n[Rt];return d(e)}var Lt="componentIdentifier";function Zi(n){if(!(Lt in n))return!1;let e=n[Lt];return d(e)}var Mt="inlineTextStyle";function Qi(n){if(!(Mt in n))return!1;let e=n[Mt];return K(e)||P(e)}var Vt="inlineTextStyle";function Ji(n){if(!(Vt in n))return!1;let e=n[Vt];return rt(e)||P(e)}export{le as ComponentInstanceNode,ue as ComponentNode,H as ConicGradient,cn as Draggable,G as FrameNode,re as FramerPluginError,_ as LinearGradient,z as RadialGradient,ae as SVGNode,se as TextNode,de as WebPageNode,$e as framer,Se as isComponentInstanceNode,ht as isComponentNode,Pe as isFileAsset,Ce as isFrameNode,xe as isImageAsset,gt as isSVGNode,mt as isTextNode,K as isTextStyle,pt as isWebPageNode,Gi as supportsAspectRatio,_i as supportsBackgroundColor,Ki as supportsBackgroundGradient,ji as supportsBackgroundGradientData,zi as supportsBackgroundImage,Hi as supportsBackgroundImageData,Yi as supportsBorderRadius,Zi as supportsComponentInfo,Qi as supportsInlineTextStyle,Ji as supportsInlineTextStyleData,Ui as supportsLocked,Bi as supportsName,Xi as supportsOpacity,Mi as supportsPins,Li as supportsPosition,$i as supportsRotation,qi as supportsSVG,Vi as supportsSize,Ei as supportsSizeConstraints,Oi as supportsVisible,Xe as useMakeDraggable}; | ||
var zt=Object.defineProperty;var Ht=(t,e,n)=>e in t?zt(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var i=(t,e,n)=>(Ht(t,typeof e!="symbol"?e+"":e,n),n),tt=(t,e,n)=>{if(!e.has(t))throw TypeError("Cannot "+n)};var r=(t,e,n)=>(tt(t,e,"read from private field"),n?n.call(t):e.get(t)),m=(t,e,n)=>{if(e.has(t))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(t):e.set(t,n)},g=(t,e,n,o)=>(tt(t,e,"write to private field"),o?o.call(t,n):e.set(t,n),n);var we=(t,e,n,o)=>({set _(s){g(t,e,s,n)},get _(){return r(t,e,o)}});import J from"react";import{useCallback as hn,useEffect as yn,useRef as fn}from"react";var Kt="invoke";function P(t){return Kt in t}function f(t){return t===null}function Re(t){return t===!0||t===!1}function d(t){return typeof t=="string"}function U(t){return typeof t=="number"&&Number.isFinite(t)}function Pe(t){return typeof t=="function"}function c(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}function Le(t){return Array.isArray(t)}function A(t,e){throw e||new Error(t?`Unexpected value: ${t}`:"Application entered invalid state")}function l(t,...e){if(t)return;let n=Error("Assertion Error"+(e.length>0?": "+e.join(" "):""));if(n.stack)try{let o=n.stack.split(` | ||
`);o[1]?.includes("assert")?(o.splice(1,1),n.stack=o.join(` | ||
`)):o[0]?.includes("assert")&&(o.splice(0,1),n.stack=o.join(` | ||
`))}catch{}throw n}var jt="FileAsset",$t="__class";function Te(t){return c(t)?t[$t]===jt:!1}var I=class{constructor(e){i(this,"id");i(this,"url");i(this,"extension");this.url=e.url,this.id=e.id,this.extension=e.extension}};function xe(t){return t instanceof I}var Xt="ImageAsset",Yt="__class";function H(t){return c(t)?t[Yt]===Xt:!1}var R,z,Ge=class Ge{constructor(e,n){i(this,"id");i(this,"url");i(this,"thumbnailUrl");i(this,"altText");m(this,R,void 0);m(this,z,void 0);l(P(n)),g(this,z,n),this.url=e.url,this.id=e.id,this.thumbnailUrl=e.thumbnailUrl,this.altText=e.altText}cloneWithAttributes({altText:e}){return new Ge({__class:"ImageAsset",id:this.id,url:this.url,thumbnailUrl:this.thumbnailUrl,altText:e!==void 0?e:this.altText},r(this,z))}async measure(){return Zt(this.url)}async getData(){if(r(this,R)&&r(this,R).bytes.length>0)return r(this,R);let e=await r(this,z).invoke("getImageData",{id:this.id});if(!e)throw new Error("Failed to load image data");return g(this,R,e),e}async loadBitmap(){let{mimeType:e,bytes:n}=await this.getData(),o=new Blob([n],{type:e});return createImageBitmap(o)}async loadImage(){let e=await this.getData(),n=URL.createObjectURL(new Blob([e.bytes]));return new Promise((o,s)=>{let a=new Image;a.onload=()=>o(a),a.onerror=()=>s(),a.src=n})}};R=new WeakMap,z=new WeakMap;var y=Ge;function Ie(t){return t instanceof y}function F(t){return t.type==="bytes"?[t.bytes.buffer]:[]}function qt(t){if(!c(t))return!1;let e="bytes",n="mimeType";return!(!(e in t)||!(n in t)||!(t[e]instanceof Uint8Array)||!d(t[n]))}async function ie(t){if(t instanceof File)return Ee(t);let e=await nt(t.image);return{name:t.name,altText:t.altText,...e}}async function Ve(t){if(t instanceof File)return Ee(t);let e=await nt(t.file);return{name:t.name,...e}}async function nt(t){return t instanceof File?Ee(t):qt(t)?{type:"bytes",mimeType:t.mimeType,bytes:t.bytes}:{type:"url",url:t}}function Me(t){return Promise.all(t.map(ie))}async function Ee(t){return new Promise((e,n)=>{let o=new FileReader;o.onload=s=>{let a=t.type,u=s.target?.result;if(!u||!(u instanceof ArrayBuffer)){n(new Error("Failed to read file, arrayBuffer is null"));return}let D=new Uint8Array(u);e({bytes:D,mimeType:a,type:"bytes",name:t.name})},o.onerror=s=>{n(s)},o.readAsArrayBuffer(t)})}async function Zt(t){let e=t instanceof File,n=e?URL.createObjectURL(t):t,o=new Image;return o.crossOrigin="anonymous",o.src=n,await o.decode().finally(()=>{e&&URL.revokeObjectURL(n)}),{height:o.height,width:o.width}}var Qt="Font";function ot(t){return c(t)&&t.__class===Qt}function Jt(t){if(!U(t))return!1;switch(t){case 100:case 200:case 300:case 400:case 500:case 600:case 700:case 800:case 900:return!0;default:return!1}}function en(t){if(!d(t))return!1;switch(t){case"normal":case"italic":return!0;default:return!1}}function oe(t){return c(t)?d(t.family)&&d(t.selector)&&Jt(t.weight)&&en(t.style):!1}var W=class{constructor(e){i(this,"selector");i(this,"family");i(this,"weight");i(this,"style");this.selector=e.selector,this.family=e.family,this.weight=e.weight,this.style=e.style}},it=new Map;function L(t){let e=it.get(t.selector);if(e)return e;let n=new W(t);return it.set(t.selector,n),n}function V(t){return{__class:"Font",selector:t.selector,family:t.family,weight:t.weight,style:t.style}}var rt="__class",Oe="LinearGradient",Be="RadialGradient",_e="ConicGradient";function Ne(t){if(!c(t))return!1;switch(t[rt]){case Oe:case Be:case _e:return!0;default:return!1}}function re(t){return t instanceof K||t instanceof j||t instanceof $}function st(t){if(t instanceof K)return{__class:Oe,angle:t.angle,stops:t.stops};if(t instanceof j)return{__class:Be,width:t.width,height:t.height,x:t.x,y:t.y,stops:t.stops};if(t instanceof $)return{__class:_e,angle:t.angle,x:t.x,y:t.y,stops:t.stops};A(t)}function Ce(t){switch(t[rt]){case Oe:return new K(t);case Be:return new j(t);case _e:return new $(t);default:A(t)}}var K=class t{constructor(e){i(this,"angle");i(this,"stops");this.angle=e.angle,this.stops=e.stops,Object.freeze(this)}cloneWithAttributes(e){return new t({angle:e.angle??this.angle,stops:e.stops??this.stops})}toCSS(){let e=this.stops.map(n=>`${n.color} ${n.position*100}%`).join(", ");return`linear-gradient(${this.angle}deg, ${e})`}},j=class t{constructor(e){i(this,"width");i(this,"height");i(this,"x");i(this,"y");i(this,"stops");this.width=e.width,this.height=e.height,this.x=e.x,this.y=e.y,this.stops=e.stops,Object.freeze(this)}cloneWithAttributes(e){return new t({width:e.width??this.width,height:e.height??this.height,x:e.x??this.x,y:e.y??this.y,stops:e.stops??this.stops})}toCSS(){let e=this.stops.map((n,o)=>{let s=this.stops[o+1],a=n.position===1&&s?.position===1?n.position-1e-4:n.position;return`${n.color} ${a*100}%`}).join(", ");return`radial-gradient(${this.width} ${this.height} at ${this.x} ${this.y}, ${e})`}},$=class t{constructor(e){i(this,"angle");i(this,"x");i(this,"y");i(this,"stops");this.angle=e.angle,this.x=e.x,this.y=e.y,this.stops=e.stops,Object.freeze(this)}cloneWithAttributes(e){return new t({angle:e.angle??this.angle,x:e.x??this.x,y:e.y??this.y,stops:e.stops??this.stops})}toCSS(){let e=this.stops.map(n=>`${n.color} ${n.position*360}deg`).join(", ");return`conic-gradient(from ${this.angle}deg at ${this.x} ${this.y}, ${e})`}};var N,Ue=class Ue{constructor(e,n){i(this,"id");i(this,"name");i(this,"light");i(this,"dark");m(this,N,void 0);l(d(e.id),"Style must have an id"),this.id=e.id,this.name=e.name,this.light=e.light,this.dark=e.dark,l(P(n)),g(this,N,n)}async setAttributes(e){let n=await r(this,N).invoke("setColorStyleAttributes",this.id,e);return n?new Ue(n,r(this,N)):null}async getPluginData(e){return r(this,N).invoke("getPluginDataForNode",this.id,e)}async setPluginData(e,n){return r(this,N).invoke("setPluginDataForNode",this.id,e,n)}async getPluginDataKeys(){return r(this,N).invoke("getPluginDataKeysForNode",this.id)}async remove(){return r(this,N).invoke("removeColorStyle",this.id)}};N=new WeakMap;var M=Ue,tn="TextStyle",nn="__class";function at(t){return c(t)?t[nn]===tn:!1}var C,ze=class ze{constructor(e,n){i(this,"id");i(this,"name");i(this,"tag");i(this,"font");i(this,"boldFont");i(this,"italicFont");i(this,"boldItalicFont");i(this,"color");i(this,"transform");i(this,"alignment");i(this,"decoration");i(this,"balance");i(this,"breakpoints");i(this,"minWidth");i(this,"fontSize");i(this,"letterSpacing");i(this,"lineHeight");i(this,"paragraphSpacing");m(this,C,void 0);l(d(e.id),"Style must have an id"),this.id=e.id,this.name=e.name,this.tag=e.tag,this.font=new W(e.font),this.boldFont=e.boldFont?new W(e.boldFont):null,this.italicFont=e.italicFont?new W(e.italicFont):null,this.boldItalicFont=e.boldItalicFont?new W(e.boldItalicFont):null,this.color=e.color,this.transform=e.transform,this.alignment=e.alignment,this.decoration=e.decoration,this.balance=e.balance,this.breakpoints=e.breakpoints,this.minWidth=e.minWidth,this.fontSize=e.fontSize,this.letterSpacing=e.letterSpacing,this.lineHeight=e.lineHeight,this.paragraphSpacing=e.paragraphSpacing,l(P(n)),g(this,C,n)}async setAttributes(e){let n=await r(this,C).invoke("setTextStyleAttributes",this.id,e);return n?new ze(n,r(this,C)):null}async getPluginData(e){return r(this,C).invoke("getPluginDataForNode",this.id,e)}async setPluginData(e,n){return r(this,C).invoke("setPluginDataForNode",this.id,e,n)}async getPluginDataKeys(){return r(this,C).invoke("getPluginDataKeysForNode",this.id)}async remove(){return r(this,C).invoke("removeTextStyle",this.id)}};C=new WeakMap;var x=ze;function X(t){return t instanceof x}function lt(t){return{__class:"TextStyle",id:t.id,name:t.name,tag:t.tag,font:V(t.font),boldFont:t.boldFont?V(t.font):null,italicFont:t.italicFont?V(t.italicFont):null,boldItalicFont:t.boldItalicFont?V(t.boldItalicFont):null,color:t.color,transform:t.transform,alignment:t.alignment,decoration:t.decoration,balance:t.balance,breakpoints:t.breakpoints,minWidth:t.minWidth,fontSize:t.fontSize,letterSpacing:t.letterSpacing,lineHeight:t.lineHeight,paragraphSpacing:t.paragraphSpacing}}function E(t){if(rn(t))return sn(t);if(Le(t))return t.map(E);if(c(t)){let e={};for(let n in t)e[n]=E(t[n]);return e}return t}function dt(t,e){let n={};for(let o in t)n[o]=He(t[o],e);return n}function He(t,e){if(on(t))switch(t.__class){case"ImageAsset":return new y(t,e);case"FileAsset":return new I(t);case"LinearGradient":case"RadialGradient":case"ConicGradient":return Ce(t);case"TextStyle":return new x(t,e);case"Font":return L(t);default:A(t)}if(c(t)){let n={};for(let o in t)n[o]=He(t[o],e);return n}return Le(t)?t.map(n=>He(n,e)):t}function on(t){return!!(H(t)||Te(t)||Ne(t))}function rn(t){return!!(Ie(t)||xe(t)||re(t)||X(t)||oe(t))}function sn(t){if(Ie(t))return{__class:"ImageAsset",id:t.id,thumbnailUrl:t.thumbnailUrl,url:t.url,altText:t.altText};if(xe(t))return{__class:"FileAsset",id:t.id,extension:t.extension,url:t.url};if(re(t))return st(t);if(X(t))return lt(t);if(oe(t))return V(t);A(t)}function an(t,e){for(let n in t){let o=t[n];H(o)&&(t[n]=new y(o,e)),Te(o)&&(t[n]=new I(o))}}var T,Se=class{constructor(e,n){i(this,"id");i(this,"name");m(this,T,void 0);l(d(e.id),"Node must have an id"),l(d(e.name),"Node must have a name"),this.id=e.id,this.name=e.name,l(P(n)),g(this,T,n),Object.freeze(this)}async getItemIds(){return r(this,T).invoke("getManagedCollectionItemIds",this.id)}async setItemOrder(e){return r(this,T).invoke("setManagedCollectionItemOrder",this.id,e)}async getFields(){return r(this,T).invoke("getManagedCollectionFields",this.id)}async setFields(e){return r(this,T).invoke("setManagedCollectionFields",this.id,e)}async addItems(e){return r(this,T).invoke("addManagedCollectionItems",this.id,e)}async removeItems(e){return r(this,T).invoke("removeManagedCollectionItems",this.id,e)}async setPluginData(e,n){return r(this,T).invoke("setPluginDataForNode",this.id,e,n)}async getPluginData(e){return r(this,T).invoke("getPluginDataForNode",this.id,e)}async getPluginDataKeys(){return r(this,T).invoke("getPluginDataKeysForNode",this.id)}};T=new WeakMap;var S,se=class{constructor(e,n){i(this,"id");i(this,"name");m(this,S,void 0);l(d(e.id),"Node must have an id"),l(d(e.name),"Node must have a name"),this.id=e.id,this.name=e.name,l(P(n)),g(this,S,n),Object.freeze(this)}async getFields(){return r(this,S).invoke("getCollectionFields",this.id)}async getItems(){return(await r(this,S).invoke("getCollectionItems",this.id)).map(n=>new Ke(n,r(this,S)))}async setPluginData(e,n){return r(this,S).invoke("setPluginDataForNode",this.id,e,n)}async getPluginData(e){return r(this,S).invoke("getPluginDataForNode",this.id,e)}async getPluginDataKeys(){return r(this,S).invoke("getPluginDataKeysForNode",this.id)}};S=new WeakMap;var G,Ke=class{constructor(e,n){i(this,"id");i(this,"slug");i(this,"fieldData");m(this,G,void 0);this.id=e.id,this.slug=e.slug,this.fieldData=e.fieldData,an(this.fieldData,n),l(P(n)),g(this,G,n),Object.freeze(this),Object.freeze(this.fieldData)}async setPluginData(e,n){return r(this,G).invoke("setPluginDataForNode",this.id,e,n)}async getPluginData(e){return r(this,G).invoke("getPluginDataForNode",this.id,e)}async getPluginDataKeys(){return r(this,G).invoke("getPluginDataKeysForNode",this.id)}};G=new WeakMap;var ln=(()=>{let t=null;return{disableUntilMouseUp:()=>{if(t)return;t=document.createElement("style"),t.textContent="* { pointer-events: none !important; user-select: none !important; -webkit-user-select: none !important; }",document.head.appendChild(t);let e=()=>{t&&(document.head.removeChild(t),t=null,s())},n=a=>{a.buttons>0&&a.buttons&1||e()},o=()=>{e()};window.addEventListener("pointerup",n,!0),window.addEventListener("pointermove",n,!0),window.addEventListener("blur",o);function s(){window.removeEventListener("pointerup",n,!0),window.removeEventListener("pointermove",n,!0),window.removeEventListener("blur",o)}}}})(),ut=5,dn=(()=>{let t=1;return{next:()=>`drag-${t++}`}})();function un(){}function ct(t,e,n){if(t.mode!=="canvas")return un;l(P(t));let o=dn.next(),s=document.body.style.cursor,a={type:"idle"},u=document.body,D=h=>{a.type!=="idle"&&(a.type==="dragging"&&t.invoke("onDragEnd",{...h,dragSessionId:o}),a={type:"idle"},Ut())},he=h=>{if(a.type==="idle")return;if(!(h.buttons>0&&!!(h.buttons&1))){D({cancelled:!1});return}let{clientX:ye,clientY:te}=h;if(a.type==="pointerDown"){let ne=ye-a.dragStart.mouse.x,et=te-a.dragStart.mouse.y;if(Math.abs(ne)<ut&&Math.abs(et)<ut)return;a={type:"dragging",dragStart:a.dragStart},t.invoke("onDragStart",a.dragStart),document.getSelection()?.empty(),ln.disableUntilMouseUp()}u.setPointerCapture(h.pointerId);let fe={x:ye,y:te};t.invoke("onDrag",{dragSessionId:o,mouse:fe}).then(ne=>{a.type==="dragging"&&(document.body.style.cursor=ne??"")})},qe=h=>{h.key==="Escape"&&D({cancelled:!0})},Ze=()=>{D({cancelled:!0})},Qe=h=>{D({cancelled:!0});let ee=e.getBoundingClientRect(),ye={x:ee.x,y:ee.y,width:ee.width,height:ee.height},te,fe=e.querySelectorAll("svg");if(fe.length===1){let be=fe.item(0).getBoundingClientRect();te={x:be.x,y:be.y,width:be.width,height:be.height}}let ne={x:h.clientX,y:h.clientY};a={type:"pointerDown",dragStart:{dragSessionId:o,elementRect:ye,svgRect:te,mouse:ne}},t.invoke("setDragData",o,n()),u.addEventListener("pointermove",he,!0),u.addEventListener("pointerup",he,!0),window.addEventListener("keydown",qe,!0),window.addEventListener("blur",Ze)},Je=()=>{let h=n();h.type==="detachedComponentLayers"&&t.invoke("preloadDetachedComponentLayers",h.url),h.type==="image"&&t.invoke("preloadImageUrlForInsertion",h.image),h.previewImage&&t.invoke("preloadDragPreviewImage",h.previewImage)};e.addEventListener("pointerdown",Qe),e.addEventListener("mouseenter",Je);function Ut(){document.body.style.cursor=s,u.removeEventListener("pointermove",he,!0),u.removeEventListener("pointerup",he,!0),window.removeEventListener("keydown",qe,!0),window.removeEventListener("blur",Ze)}return()=>{e.removeEventListener("pointerdown",Qe),e.removeEventListener("mouseenter",Je),D({cancelled:!0})}}var ae=class extends Error{};var cn={canvas:!0,image:!0,editImage:!0,configureManagedCollection:!0,syncManagedCollection:!0,collection:!0};function mt(t){return d(t)&&t in cn}var mn={methodResponse:!0,pluginReadyResponse:!0,subscriptionMessage:!0};function gn(t){return d(t)&&t in mn}function gt(t){return c(t)&&gn(t["type"])}var pe,b,k,v=class{constructor(e,n){i(this,"id");m(this,pe,void 0);m(this,b,void 0);m(this,k,void 0);l(d(e.id),"Node must have an id"),this.id=e.id,g(this,b,n),g(this,pe,e.originalId??null),l(P(n)),g(this,k,n)}get isReplica(){return r(this,pe)!==null}remove(){return r(this,b).removeNode(this.id)}select(){return r(this,b).setSelection([this.id])}clone(){return r(this,b).cloneNode(this.id)}setAttributes(e){return r(this,b).setAttributes(this.id,e)}getRect(){return r(this,b).getRect(this.id)}zoomIntoView(e){return r(this,b).zoomIntoView([this.id],e)}getParent(){return r(this,b).getParent(this.id)}getChildren(){return O(this)?Promise.resolve([]):r(this,b).getChildren(this.id)}async getNodesWithType(e){return O(this)?Promise.resolve([]):(await r(this,k).invoke("getNodesWithType",this.id,e)).map(o=>p(o,r(this,b)))}async getNodesWithAttribute(e){return O(this)?Promise.resolve([]):(await r(this,k).invoke("getNodesWithAttribute",this.id,e)).map(o=>p(o,r(this,b)))}async getNodesWithAttributeSet(e){return O(this)?Promise.resolve([]):(await r(this,k).invoke("getNodesWithAttributeSet",this.id,e)).map(o=>p(o,r(this,b)))}async*walk(){if(yield this,!O(this))for(let e of await this.getChildren())yield*e.walk()}async getPluginData(e){return r(this,k).invoke("getPluginDataForNode",this.id,e)}async setPluginData(e,n){return r(this,k).invoke("setPluginDataForNode",this.id,e,n)}async getPluginDataKeys(){return r(this,k).invoke("getPluginDataKeysForNode",this.id)}};pe=new WeakMap,b=new WeakMap,k=new WeakMap;var B=class extends v{constructor(n,o){super(n,o);i(this,"__class","FrameNode");i(this,"name");i(this,"visible");i(this,"locked");i(this,"backgroundColor");i(this,"backgroundImage");i(this,"backgroundGradient");i(this,"rotation");i(this,"opacity");i(this,"borderRadius");i(this,"position");i(this,"top");i(this,"right");i(this,"bottom");i(this,"left");i(this,"centerX");i(this,"centerY");i(this,"width");i(this,"height");i(this,"maxWidth");i(this,"minWidth");i(this,"maxHeight");i(this,"minHeight");i(this,"aspectRatio");i(this,"link");i(this,"linkOpenInNewTab");l(n.__class==="FrameNode","FrameNode must have a __class property"),this.name=n.name??null,this.visible=n.visible??!0,this.locked=n.locked??!1,this.backgroundColor=n.backgroundColor??null,this.backgroundImage=n.backgroundImage?new y(n.backgroundImage,o):null,this.rotation=n.rotation??0,this.opacity=n.opacity??1,this.borderRadius=n.borderRadius??null,this.backgroundGradient=Ne(n.backgroundGradient)?Ce(n.backgroundGradient):null,l(n.position,"Must have a position"),this.position=n.position,this.left=n.left??null,this.right=n.right??null,this.top=n.top??null,this.bottom=n.bottom??null,this.centerX=n.centerX??null,this.centerY=n.centerY??null,this.width=n.width??null,this.height=n.height??null,this.maxWidth=n.maxWidth??null,this.minWidth=n.minWidth??null,this.maxHeight=n.maxHeight??null,this.minHeight=n.minHeight??null,this.aspectRatio=n.aspectRatio??null,this.link=n.link??null,this.linkOpenInNewTab=n.linkOpenInNewTab??null,Object.freeze(this)}clone(){return super.clone()}setAttributes(n){return super.setAttributes(n)}},Y,le=class extends v{constructor(n,o){super(n,o);i(this,"__class","TextNode");i(this,"name");i(this,"visible");i(this,"locked");i(this,"rotation");i(this,"opacity");i(this,"font");i(this,"inlineTextStyle");i(this,"position");i(this,"top");i(this,"right");i(this,"bottom");i(this,"left");i(this,"centerX");i(this,"centerY");i(this,"width");i(this,"height");i(this,"maxWidth");i(this,"minWidth");i(this,"maxHeight");i(this,"minHeight");i(this,"link");i(this,"linkOpenInNewTab");m(this,Y,void 0);l(P(o)),g(this,Y,o),this.name=n.name??null,this.visible=n.visible??!0,this.locked=n.locked??!1,this.rotation=n.rotation??0,this.opacity=n.opacity??1,this.font=n.font?L(n.font):null,this.inlineTextStyle=n.inlineTextStyle?new x(n.inlineTextStyle,o):null,l(n.position,"Must have a position"),this.position=n.position,this.left=n.left??null,this.right=n.right??null,this.top=n.top??null,this.bottom=n.bottom??null,this.centerX=n.centerX??null,this.centerY=n.centerY??null,this.width=n.width??null,this.height=n.height??null,this.maxWidth=n.maxWidth??null,this.minWidth=n.minWidth??null,this.maxHeight=n.maxHeight??null,this.minHeight=n.minHeight??null,this.link=n.link??null,this.linkOpenInNewTab=n.linkOpenInNewTab??null,Object.freeze(this)}clone(){return super.clone()}setAttributes(n){return super.setAttributes(n)}async setText(n){await r(this,Y).invoke("setTextForNode",this.id,n)}async getText(){return r(this,Y).invoke("getTextForNode",this.id)}};Y=new WeakMap;var de=class extends v{constructor(n,o){super(n,o);i(this,"__class","SVGNode");i(this,"name");i(this,"visible");i(this,"locked");i(this,"svg");i(this,"rotation");i(this,"opacity");i(this,"position");i(this,"top");i(this,"right");i(this,"bottom");i(this,"left");i(this,"centerX");i(this,"centerY");i(this,"width");i(this,"height");l(n.svg,"SVG node must have a non-empty SVG string"),this.name=n.name??null,this.visible=n.visible??!0,this.locked=n.locked??!1,this.svg=n.svg,this.rotation=n.rotation??0,this.opacity=n.opacity??1,l(n.position,"Must have a position"),this.position=n.position??null,this.left=n.left??null,this.right=n.right??null,this.top=n.top??null,this.bottom=n.bottom??null,this.centerX=n.centerX??null,this.centerY=n.centerY??null,this.width=n.width??null,this.height=n.height??null,Object.freeze(this)}clone(){return super.clone()}setAttributes(n){return super.setAttributes(n)}},ue=class extends v{constructor(n,o){super(n,o);i(this,"__class","ComponentInstanceNode");i(this,"name");i(this,"visible");i(this,"locked");i(this,"componentIdentifier");i(this,"insertURL");i(this,"componentName");i(this,"controls");i(this,"rotation");i(this,"opacity");i(this,"position");i(this,"top");i(this,"right");i(this,"bottom");i(this,"left");i(this,"centerX");i(this,"centerY");i(this,"width");i(this,"height");i(this,"maxWidth");i(this,"minWidth");i(this,"maxHeight");i(this,"minHeight");i(this,"aspectRatio");l(n.componentIdentifier,"ComponentInstance node must have a component identifier"),this.name=n.name??null,this.visible=n.visible??!0,this.locked=n.locked??!1,this.componentIdentifier=n.componentIdentifier,this.componentName=n.componentName??null,this.insertURL=n.insertURL??null,this.controls=dt(n.controls??{},o),this.rotation=n.rotation??0,this.opacity=n.opacity??1,l(n.position,"Must have a position"),this.position=n.position,this.left=n.left??null,this.right=n.right??null,this.top=n.top??null,this.bottom=n.bottom??null,this.centerX=n.centerX??null,this.centerY=n.centerY??null,this.width=n.width??null,this.height=n.height??null,this.maxWidth=n.maxWidth??null,this.minWidth=n.minWidth??null,this.maxHeight=n.maxHeight??null,this.minHeight=n.minHeight??null,this.aspectRatio=n.aspectRatio??null,Object.freeze(this)}clone(){return super.clone()}setAttributes(n){return super.setAttributes(n)}},ce=class extends v{constructor(n,o){super(n,o);i(this,"_class","WebPageNode");i(this,"path");i(this,"collectionId");l(n),this.path=n.path??null,this.collectionId=n.collectionId??null,Object.freeze(this)}clone(){return super.clone()}setAttributes(n){return super.setAttributes(n)}},me=class extends v{constructor(n,o){super(n,o);i(this,"__class","ComponentNode");i(this,"name");i(this,"componentIdentifier");i(this,"insertURL");i(this,"componentName");l(n.componentIdentifier,"ComponentNode must have a componentIdentifier"),this.componentIdentifier=n.componentIdentifier,this.insertURL=n.insertURL??null,this.componentName=n.componentName??null,this.name=n.name??null,Object.freeze(this)}clone(){return super.clone()}setAttributes(n){return super.setAttributes(n)}},ge=class extends v{constructor(n,o){super(n,o);i(this,"__class","UnknownNode");Object.freeze(this)}clone(){throw Error("Can not clone unknown node")}setAttributes(n){throw Error("Can not set attributes on unknown node")}};function p(t,e){switch(t.__class){case"WebPageNode":return new ce(t,e);case"ComponentNode":return new me(t,e);case"ComponentInstanceNode":return new ue(t,e);case"FrameNode":return new B(t,e);case"SVGNode":return new de(t,e);case"TextNode":return new le(t,e);case"UnknownNode":return new ge(t,e);default:return new ge(t,e)}}function je(t){return E(t)}function ke(t){return t instanceof B}function pt(t){return t instanceof le}function ht(t){return t instanceof de}function De(t){return t instanceof ue}function yt(t){return t instanceof ce}function ft(t){return t instanceof me}function O(t){return t instanceof ge}function ve(t){return!!(ke(t)||pt(t)||De(t)||ht(t)||O(t))}function $e(t){return!!(yt(t)||ft(t)||O(t))}var q=null;function bt(t){if(!q){let n=document.createElement("style");document.head.appendChild(n),q=n.sheet}if(!q){t();return}let e=q.insertRule("* { transition: none !important; animation: none !important; }");t(),requestAnimationFrame(()=>{requestAnimationFrame(()=>{q&&q.deleteRule(e)})})}var pn=2,Fe,We,Z,_,Q,w,Ae=class{constructor({isTestEnv:e}={}){m(this,Fe,0);m(this,We,0);m(this,Z,[]);m(this,_,void 0);m(this,Q,new Map);m(this,w,void 0);i(this,"subscriptions",new Map);i(this,"onMessage",e=>{let n=e.data;if(gt(n))switch(n.type){case"pluginReadyResponse":{if(!e.source)throw new Error("No 'source' on incoming message: "+n.type);l(r(this,w)===n.mode,"Mode must match"),this.applyPluginTheme(n.theme),g(this,_,(s,a)=>window.parent.postMessage(s,e.origin,a));for(let s of r(this,Z))r(this,_).call(this,...s);g(this,Z,[]);break}case"methodResponse":{let o=r(this,Q).get(n.id);if(!o)throw new Error(`No handler for response with id ${n.id}`);r(this,Q).delete(n.id),n.error?o.reject(new ae(n.error)):o.resolve(n.result);break}case"subscriptionMessage":{let{topic:o,payload:s}=n,a=this.subscriptions.get(o);if(!a)throw new Error("Received a subscription message but no handler present");for(let u of a)u(s);break}default:A(n)}});i(this,"applyPluginTheme",e=>{bt(()=>{document.body.setAttribute("data-framer-theme",e.mode);for(let n in e.tokens)document.body.style.setProperty(n,e.tokens[n])})});if(e){g(this,w,"canvas");return}if(typeof window>"u"){console.warn("Framer Plugin API is not supported in non-browser environments"),g(this,w,"canvas");return}let o=new URL(window.location.href).searchParams.get("mode");l(mt(o),`Invalid mode: ${o}`),g(this,w,o),window.addEventListener("message",this.onMessage);let s={type:"pluginReadySignal",breakingChangesVersion:pn};window.parent.postMessage(s,"*"),this.subscribe("theme",this.applyPluginTheme),window.addEventListener("pointerdown",()=>{this.invoke("onPointerDown")})}get mode(){return r(this,w)}invoke(e,...n){return this.invokeTransferable(e,void 0,...n)}invokeTransferable(e,n,...o){return new Promise((s,a)=>{let u={args:o,methodName:e,id:we(this,Fe)._++,type:"methodInvocation"},D=s;r(this,Q).set(u.id,{resolve:D,reject:a}),this.queueMessage(u,n)})}subscribe(e,n){this.queueMessage({type:"subscribe",topic:e});let o=this.subscriptions.get(e)??new Set;return o.add(n),this.subscriptions.set(e,o),()=>{let s=this.subscriptions.get(e)??new Set;s.delete(n),s.size===0&&this.queueMessage({type:"unsubscribe",topic:e}),this.subscriptions.set(e,s)}}queueMessage(e,n){if(!r(this,_)){r(this,Z).push([e,n]);return}r(this,_).call(this,e,n)}async showUI(e){return this.invoke("showUI",e)}async hideUI(){return this.invoke("hideUI")}async closePlugin(e,n){return this.invoke("closePlugin",e,n)}async getCurrentUser(){return this.invoke("getCurrentUser")}async getProjectInfo(){return this.invoke("getProjectInfo")}async getSelection(){return(await this.invoke("getSelection")).map(n=>{let o=p(n,this);return l(ve(o)),o})}async setSelection(e){let n=d(e)?[e]:Array.from(e);return this.invoke("setSelection",n)}subscribeToSelection(e){return this.subscribe("selection",n=>{let o=n.map(s=>{let a=p(s,this);return l(ve(a)),a});e(o)})}async getCanvasRoot(){let e=await this.invoke("getCanvasRoot"),n=p(e,this);return l($e(n)),n}subscribeToCanvasRoot(e){return this.subscribe("canvasRoot",n=>{let o=p(n,this);l($e(o)),e(o)})}async getPublishInfo(){return this.invoke("getPublishInfo")}subscribeToPublishInfo(e){return this.subscribe("publishInfo",e)}async createFrameNode(e,n){let o=je(e),s=await this.invoke("createNode","FrameNode",n??null,o);if(!s)return null;let a=p(s,this);return l(a instanceof B),a}async removeNode(e){return this.invoke("removeNode",e)}async cloneNode(e){let n=await this.invoke("cloneNode",e);return n?p(n,this):null}async getNode(e){let n=await this.invoke("getNode",e);return n?p(n,this):null}async getParent(e){let n=await this.invoke("getParent",e);return n?p(n,this):null}async getChildren(e){return(await this.invoke("getChildren",e)).map(o=>{let s=p(o,this);return l(ve(s)),s})}async getRect(e){return this.invoke("getRect",e)}async zoomIntoView(e,n){let o=d(e)?[e]:Array.from(e);return this.invoke("zoomIntoView",o,n)}async setAttributes(e,n){let o=je(n),s=await this.invoke("setAttributes",e,o);return s?p(s,this):null}async setParent(e,n,o){return this.invoke("setParent",e,n,o)}async getNodesWithType(e){return(await this.invoke("getNodesWithType",null,e)).map(o=>p(o,this))}async getNodesWithAttribute(e){return(await this.invoke("getNodesWithAttribute",null,e)).map(o=>p(o,this))}async getNodesWithAttributeSet(e){return(await this.invoke("getNodesWithAttributeSet",null,e)).map(o=>p(o,this))}async getImage(){let e=await this.invoke("getImage");return e?new y(e,this):null}subscribeToImage(e){return this.subscribe("image",n=>{if(!n){e(null);return}e(new y(n,this))})}async addImage(e){let n=await ie(e),o=F(n);return this.invokeTransferable("addImage",o,n)}async setImage(e){let n=await ie(e),o=F(n);return this.invokeTransferable("setImage",o,n)}async uploadImage(e){let n=await ie(e),o=F(n),s=await this.invokeTransferable("uploadImage",o,n);return new y(s,this)}async addImages(e){let n=await Me(e),o=n.flatMap(F);await this.invokeTransferable("addImages",o,n)}async uploadImages(e){let n=await Me(e),o=n.flatMap(F),s=await this.invokeTransferable("uploadImages",o,n),a=[];for(let u of s)a.push(new y(u,this));return a}async uploadFile(e){let n=await Ve(e),o=await this.invokeTransferable("uploadFile",F(n),n);return new I(o)}async uploadFiles(e){let n=await Promise.all(e.map(Ve)),o=n.flatMap(F),s=await this.invokeTransferable("uploadFiles",o,n),a=[];for(let u of s)a.push(new I(u));return a}async addSVG(e){return this.invoke("addSVG",e)}async addComponentInstance({url:e,attributes:n}){let o=E(n),s=await this.invoke("addComponentInstance",{url:e,attributes:c(o)?o:void 0}),a=p(s,this);return l(De(a)),a}async addDetachedComponentLayers({url:e,layout:n,attributes:o}){let s=E(o),a=await this.invoke("addDetachedComponentLayers",{url:e,layout:n,attributes:c(s)?s:void 0}),u=p(a,this);return l(ke(u)),u}async preloadDetachedComponentLayers(e){await this.invoke("preloadDetachedComponentLayers",e)}async preloadImageUrlForInsertion(e){await this.invoke("preloadImageUrlForInsertion",e)}async preloadDragPreviewImage(e){await this.invoke("preloadDragPreviewImage",e)}async getText(){return this.invoke("getText")}async setText(e){return this.invoke("setText",e)}async addText(e,n){return this.invoke("addText",e,n)}async setCustomCode(e){return this.invoke("setCustomCode",e)}async getCustomCode(){return this.invoke("getCustomCode")}subscribeToCustomCode(e){return this.subscribe("customCode",e)}subscribeToText(e){return this.subscribe("text",e)}makeDraggable(e,n){return ct(this,e,n)}async getManagedCollection(){let e=await this.invoke("getManagedCollection");return l(e,"Collection data must be defined"),new Se(e,this)}async getCollection(){let e=await this.invoke("getCollection");return l(e,"Collection data must be defined"),new se(e,this)}async getCollections(){return(await this.invoke("getCollections")).map(n=>new se(n,this))}notify(e,n){let o=`notification-${we(this,We)._++}`;return this.invoke("notify",e,{notificationId:o,variant:n?.variant??"info",buttonText:n?.button?.text,durationMs:n?.durationMs}).then(s=>{s==="actionButtonClicked"&&n?.button?.onClick&&n.button.onClick(),n?.onDisappear&&n.onDisappear()}),{close:()=>this.invoke("closeNotification",o)}}async getPluginData(e){return this.invoke("getPluginData",e)}async setPluginData(e,n){return this.invoke("setPluginData",e,n)}async getPluginDataKeys(){return this.invoke("getPluginDataKeys")}async getColorStyles(){return(await this.invoke("getColorStyles")).map(n=>new M(n,this))}async getColorStyle(e){let n=await this.invoke("getColorStyle",e);return n?new M(n,this):null}async createColorStyle(e){let n=await this.invoke("createColorStyle",e);return new M(n,this)}subscribeToColorStyles(e){return this.subscribe("colorStyles",n=>{let o=n.map(s=>new M(s,this));return e(o)})}async getTextStyles(){return(await this.invoke("getTextStyles")).map(n=>new x(n,this))}async getTextStyle(e){let n=await this.invoke("getTextStyle",e);return n?new x(n,this):null}async createTextStyle(e){let n=await this.invoke("createTextStyle",e);return new x(n,this)}subscribeToTextStyles(e){return this.subscribe("textStyles",n=>{let o=n.map(s=>new x(s,this));return e(o)})}async getFont(e,n){let o=await this.invoke("getFont",e,n);return o?L(o):null}async getFonts(){return(await this.invoke("getFonts")).map(L)}};Fe=new WeakMap,We=new WeakMap,Z=new WeakMap,_=new WeakMap,Q=new WeakMap,w=new WeakMap;var Xe=new Ae;function Ye(t,e){let n=bn(()=>Pe(e)?e():e);yn(()=>{let o=t.current;if(o instanceof HTMLElement)return Xe.makeDraggable(o,n)},[n])}function bn(t){let e=fn(t);return e.current=t,hn((...n)=>e.current(...n),[])}var Pn=J.forwardRef(function({data:e,children:n,...o},s){let a=J.useRef(null);if(Ye(a,e),J.isValidElement(n)){let u=Object.assign({},o);return c(n.props)&&Object.assign(u,n.props),u.ref=In(a,s,n.ref),J.cloneElement(n,u)}return J.Children.count(n)>1&&J.Children.only(n),null}),Tn="current";function xn(t){return c(t)&&Tn in t}function In(...t){return e=>{for(let n of t)Pe(n)?n(e):xn(n)&&(n.current=e)}}var Nn={fixed:!0,sticky:!0,absolute:!0,relative:!0},Pt="position";function Ki(t){if(!(Pt in t))return!1;let e=t[Pt];return d(e)&&Nn[e]===!0}var Tt="top";function ji(t){if(!(Tt in t))return!1;let e=t[Tt];return d(e)||f(e)}var xt="width";function $i(t){if(!(xt in t))return!1;let e=t[xt];return d(e)||f(e)}var It="maxWidth";function Xi(t){if(!(It in t))return!1;let e=t[It];return d(e)||f(e)}var Nt="aspectRatio";function Yi(t){if(!(Nt in t))return!1;let e=t[Nt];return U(e)||f(e)}var Ct="name";function qi(t){if(!(Ct in t))return!1;let e=t[Ct];return d(e)||f(e)}var St="visible";function Zi(t){if(!(St in t))return!1;let e=t[St];return Re(e)}var kt="locked";function Qi(t){if(!(kt in t))return!1;let e=t[kt];return Re(e)}var Dt="backgroundColor";function Ji(t){if(!(Dt in t))return!1;let e=t[Dt];return d(e)||f(e)}var vt="backgroundImage";function eo(t){if(!(vt in t))return!1;let e=t[vt];return e instanceof y||f(e)}var At="backgroundImage";function to(t){if(!(At in t))return!1;let e=t[At];return e instanceof y?!1:H(e)||f(e)}var Ft="backgroundGradient";function no(t){if(!(Ft in t))return!1;let e=t[Ft];return re(e)||f(e)}var Wt="backgroundGradient";function io(t){if(!(Wt in t))return!1;let e=t[Wt];return c(e)||f(e)}var wt="rotation";function oo(t){if(!(wt in t))return!1;let e=t[wt];return U(e)}var Rt="opacity";function ro(t){if(!(Rt in t))return!1;let e=t[Rt];return U(e)}var Lt="borderRadius";function so(t){if(!(Lt in t))return!1;let e=t[Lt];return d(e)||f(e)}var Vt="svg";function ao(t){if(!(Vt in t))return!1;let e=t[Vt];return d(e)}var Mt="componentIdentifier";function lo(t){if(!(Mt in t))return!1;let e=t[Mt];return d(e)}var Et="font";function uo(t){if(!(Et in t))return!1;let e=t[Et];return oe(e)}var Gt="font";function co(t){if(!(Gt in t))return!1;let e=t[Gt];return ot(e)||f(e)}var Ot="inlineTextStyle";function mo(t){if(!(Ot in t))return!1;let e=t[Ot];return X(e)||f(e)}var Bt="inlineTextStyle";function go(t){if(!(Bt in t))return!1;let e=t[Bt];return at(e)||f(e)}var _t="link";function po(t){if(!(_t in t))return!1;let e=t[_t];return d(e)||f(e)}export{ue as ComponentInstanceNode,me as ComponentNode,$ as ConicGradient,Pn as Draggable,B as FrameNode,ae as FramerPluginError,K as LinearGradient,j as RadialGradient,de as SVGNode,le as TextNode,ce as WebPageNode,Xe as framer,De as isComponentInstanceNode,ft as isComponentNode,xe as isFileAsset,ke as isFrameNode,Ie as isImageAsset,ht as isSVGNode,pt as isTextNode,X as isTextStyle,yt as isWebPageNode,Yi as supportsAspectRatio,Ji as supportsBackgroundColor,no as supportsBackgroundGradient,io as supportsBackgroundGradientData,eo as supportsBackgroundImage,to as supportsBackgroundImageData,so as supportsBorderRadius,lo as supportsComponentInfo,uo as supportsFont,co as supportsFontData,mo as supportsInlineTextStyle,go as supportsInlineTextStyleData,po as supportsLink,Qi as supportsLocked,qi as supportsName,ro as supportsOpacity,ji as supportsPins,Ki as supportsPosition,oo as supportsRotation,ao as supportsSVG,$i as supportsSize,Xi as supportsSizeConstraints,Zi as supportsVisible,Ye as useMakeDraggable}; |
{ | ||
"name": "framer-plugin", | ||
"version": "0.3.3", | ||
"version": "0.3.4", | ||
"type": "module", | ||
@@ -38,9 +38,9 @@ "main": "src/index.ts", | ||
"@typescript-eslint/eslint-plugin": "^8.2.0", | ||
"@typescript-eslint/parser": "^8.2.0", | ||
"eslint": "^8.56.0", | ||
"@typescript-eslint/parser": "^8.5.0", | ||
"eslint": "^8.57.0", | ||
"jest": "^29.4.1", | ||
"tsd": "^0.31.0", | ||
"tsup": "^8.0.2", | ||
"typescript": "^5.5.4" | ||
"typescript": "^5.6.2" | ||
} | ||
} |
@@ -7,3 +7,3 @@ export type { ImageAsset } from "./assets" | ||
export { useMakeDraggable } from "./useMakeDraggable" | ||
export type { UIOptions, User, Mode, Notification } from "./framerAPI" | ||
export type { UIOptions, User, ProjectInfo, Mode, Notification } from "./framerAPI" | ||
export type { PublishInfo, Publish } from "./publishInfo" | ||
@@ -10,0 +10,0 @@ export { |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
312885
1963