Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

framer-plugin

Package Overview
Dependencies
Maintainers
51
Versions
37
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

framer-plugin - npm Package Compare versions

Comparing version 2.0.0 to 2.0.1

2

dist/index.js
var jt=Object.defineProperty;var $t=(t,e,n)=>e in t?jt(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var i=(t,e,n)=>($t(t,typeof e!="symbol"?e+"":e,n),n),it=(t,e,n)=>{if(!e.has(t))throw TypeError("Cannot "+n)};var r=(t,e,n)=>(it(t,e,"read from private field"),n?n.call(t):e.get(t)),c=(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)},m=(t,e,n,o)=>(it(t,e,"write to private field"),o?o.call(t,n):e.set(t,n),n);var Le=(t,e,n,o)=>({set _(s){m(t,e,s,n)},get _(){return r(t,e,o)}});import te from"react";import{useCallback as Pn,useEffect as Tn,useRef as xn}from"react";var Xt="invoke";function T(t){return Xt in t}function y(t){return t===null}function Ve(t){return t===!0||t===!1}function d(t){return typeof t=="string"}function z(t){return typeof t=="number"&&Number.isFinite(t)}function Te(t){return typeof t=="function"}function g(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}function Me(t){return Array.isArray(t)}function F(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 Yt="FileAsset",qt="__class";function xe(t){return g(t)?t[qt]===Yt:!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 Ie(t){return t instanceof N}var Zt="ImageAsset",Qt="__class";function H(t){return g(t)?t[Qt]===Zt:!1}var L,K,Be=class Be{constructor(e,n){i(this,"id");i(this,"url");i(this,"thumbnailUrl");i(this,"altText");i(this,"resolution");c(this,L,void 0);c(this,K,void 0);l(T(n)),m(this,K,n),this.url=e.url,this.id=e.id,this.thumbnailUrl=e.thumbnailUrl,this.altText=e.altText,this.resolution=e.resolution}cloneWithAttributes({altText:e,resolution:n}){return new Be({__class:"ImageAsset",id:this.id,url:this.url,thumbnailUrl:this.thumbnailUrl,altText:e!==void 0?e:this.altText,resolution:n!==void 0?n:this.resolution},r(this,K))}async measure(){return en(this.url)}async getData(){if(r(this,L)&&r(this,L).bytes.length>0)return r(this,L);let e=await r(this,K).invoke("getImageData",{id:this.id,resolution:this.resolution});if(!e)throw new Error("Failed to load image data");return m(this,L,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})}};L=new WeakMap,K=new WeakMap;var f=Be;function Ne(t){return t instanceof f}function W(t){return t.type==="bytes"?[t.bytes.buffer]:[]}function Jt(t){if(!g(t))return!1;let e="bytes",n="mimeType";return!(!(e in t)||!(n in t)||!(t[e]instanceof Uint8Array)||!d(t[n]))}async function re(t){if(t instanceof File)return Oe(t);let e=await ot(t.image);return{name:t.name,altText:t.altText,resolution:t.resolution,...e}}async function Ee(t){if(t instanceof File)return Oe(t);let e=await ot(t.file);return{name:t.name,...e}}async function ot(t){return t instanceof File?Oe(t):Jt(t)?{type:"bytes",mimeType:t.mimeType,bytes:t.bytes}:{type:"url",url:t}}function Ge(t){return Promise.all(t.map(re))}async function Oe(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 v=new Uint8Array(u);e({bytes:v,mimeType:a,type:"bytes",name:t.name})},o.onerror=s=>{n(s)},o.readAsArrayBuffer(t)})}async function en(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 tn="Font";function st(t){return g(t)&&t.__class===tn}function nn(t){if(!z(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 on(t){if(!d(t))return!1;switch(t){case"normal":case"italic":return!0;default:return!1}}function se(t){return g(t)?d(t.family)&&d(t.selector)&&nn(t.weight)&&on(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}},rt=new Map;function V(t){let e=rt.get(t.selector);if(e)return e;let n=new w(t);return rt.set(t.selector,n),n}function M(t){return{__class:"Font",selector:t.selector,family:t.family,weight:t.weight,style:t.style}}var at="__class",_e="LinearGradient",Ue="RadialGradient",ze="ConicGradient";function Ce(t){if(!g(t))return!1;switch(t[at]){case _e:case Ue:case ze:return!0;default:return!1}}function ae(t){return t instanceof j||t instanceof $||t instanceof X}function lt(t){if(t instanceof j)return{__class:_e,angle:t.angle,stops:t.stops};if(t instanceof $)return{__class:Ue,width:t.width,height:t.height,x:t.x,y:t.y,stops:t.stops};if(t instanceof X)return{__class:ze,angle:t.angle,x:t.x,y:t.y,stops:t.stops};F(t)}function Se(t){switch(t[at]){case _e:return new j(t);case Ue:return new $(t);case ze:return new X(t);default:F(t)}}var j=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})`}},$=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})`}},X=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 rn="ColorStyle",sn="__class";function E(t){return g(t)?t[sn]===rn:!1}var C,He=class He{constructor(e,n){i(this,"id");i(this,"name");i(this,"light");i(this,"dark");c(this,C,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(T(n)),m(this,C,n)}async setAttributes(e){let n=await r(this,C).invoke("setColorStyleAttributes",this.id,e);return n?new He(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("removeColorStyle",this.id)}};C=new WeakMap;var b=He;function G(t){return t instanceof b}function Ke(t){return{__class:"ColorStyle",id:t.id,name:t.name,light:t.light,dark:t.dark}}var an="TextStyle",ln="__class";function dt(t){return g(t)?t[ln]===an:!1}var S,je=class je{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");c(this,S,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(e.color)?new b(e.color,n):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(T(n)),m(this,S,n)}async setAttributes(e){let n=await r(this,S).invoke("setTextStyleAttributes",this.id,e);return n?new je(n,r(this,S)):null}async getPluginData(e){return r(this,S).invoke("getPluginDataForNode",this.id,e)}async setPluginData(e,n){return r(this,S).invoke("setPluginDataForNode",this.id,e,n)}async getPluginDataKeys(){return r(this,S).invoke("getPluginDataKeysForNode",this.id)}async remove(){return r(this,S).invoke("removeTextStyle",this.id)}};S=new WeakMap;var I=je;function Y(t){return t instanceof I}function ut(t){return{__class:"TextStyle",id:t.id,name:t.name,tag:t.tag,font:M(t.font),boldFont:t.boldFont?M(t.font):null,italicFont:t.italicFont?M(t.italicFont):null,boldItalicFont:t.boldItalicFont?M(t.boldItalicFont):null,color:G(t.color)?Ke(t.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 ke(t){if(un(t))return cn(t);if(Me(t))return t.map(ke);if(g(t)&&!(t instanceof Uint8Array)){let e={};for(let n in t)e[n]=ke(t[n]);return e}return t}function ct(t,e){let n={};for(let o in t)n[o]=$e(t[o],e);return n}function $e(t,e){if(dn(t))switch(t.__class){case"ImageAsset":return new f(t,e);case"FileAsset":return new N(t);case"LinearGradient":case"RadialGradient":case"ConicGradient":return Se(t);case"TextStyle":return new I(t,e);case"Font":return V(t);case"ColorStyle":return new b(t,e);default:F(t)}if(g(t)){let n={};for(let o in t)n[o]=$e(t[o],e);return n}return Me(t)?t.map(n=>$e(n,e)):t}function dn(t){return!!(H(t)||xe(t)||Ce(t))}function un(t){return!!(Ne(t)||Ie(t)||ae(t)||Y(t)||se(t)||G(t))}function cn(t){if(Ne(t))return{__class:"ImageAsset",id:t.id,thumbnailUrl:t.thumbnailUrl,url:t.url,altText:t.altText,resolution:t.resolution};if(Ie(t))return{__class:"FileAsset",id:t.id,extension:t.extension,url:t.url};if(ae(t))return lt(t);if(Y(t))return ut(t);if(se(t))return M(t);if(G(t))return Ke(t);F(t)}function mn(t,e){for(let n in t){let o=t[n];H(o)&&(t[n]=new f(o,e)),xe(o)&&(t[n]=new N(o)),E(o)&&(t[n]=new b(o,e))}}var x,De=class{constructor(e,n){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(T(n)),m(this,x,n),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,n){return r(this,x).invoke("setPluginDataForNode",this.id,e,n)}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 k,q=class{constructor(e,n){i(this,"id");i(this,"name");c(this,k,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(T(n)),m(this,k,n),Object.freeze(this)}async getFields(){return r(this,k).invoke("getCollectionFields",this.id)}async getItems(){return(await r(this,k).invoke("getCollectionItems",this.id)).map(n=>new Xe(n,r(this,k)))}async setPluginData(e,n){return r(this,k).invoke("setPluginDataForNode",this.id,e,n)}async getPluginData(e){return r(this,k).invoke("getPluginDataForNode",this.id,e)}async getPluginDataKeys(){return r(this,k).invoke("getPluginDataKeysForNode",this.id)}};k=new WeakMap;var O,Xe=class{constructor(e,n){i(this,"id");i(this,"slug");i(this,"draft");i(this,"fieldData");c(this,O,void 0);this.id=e.id,this.slug=e.slug,this.draft=e.draft??!1,this.fieldData=e.fieldData,mn(this.fieldData,n),l(T(n)),m(this,O,n),Object.freeze(this),Object.freeze(this.fieldData)}async setPluginData(e,n){return r(this,O).invoke("setPluginDataForNode",this.id,e,n)}async getPluginData(e){return r(this,O).invoke("getPluginDataForNode",this.id,e)}async getPluginDataKeys(){return r(this,O).invoke("getPluginDataKeysForNode",this.id)}};O=new WeakMap;var gn=(()=>{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)}}}})(),mt=5,pn=(()=>{let t=1;return{next:()=>`drag-${t++}`}})();function hn(){}function gt(t,e,n){if(t.mode!=="canvas")return hn;l(T(t));let o=pn.next(),s=document.body.style.cursor,a={type:"idle"},u=document.body,v=h=>{a.type!=="idle"&&(a.type==="dragging"&&t.invoke("onDragEnd",{...h,dragSessionId:o}),a={type:"idle"},Ht())},ye=h=>{if(a.type==="idle")return;if(!(h.buttons>0&&!!(h.buttons&1))){v({cancelled:!1});return}let{clientX:fe,clientY:ie}=h;if(a.type==="pointerDown"){let oe=fe-a.dragStart.mouse.x,nt=ie-a.dragStart.mouse.y;if(Math.abs(oe)<mt&&Math.abs(nt)<mt)return;a={type:"dragging",dragStart:a.dragStart},t.invoke("onDragStart",a.dragStart),document.getSelection()?.empty(),gn.disableUntilMouseUp()}u.setPointerCapture(h.pointerId);let be={x:fe,y:ie};t.invoke("onDrag",{dragSessionId:o,mouse:be}).then(oe=>{a.type==="dragging"&&(document.body.style.cursor=oe??"")})},Qe=h=>{h.key==="Escape"&&v({cancelled:!0})},Je=()=>{v({cancelled:!0})},et=h=>{v({cancelled:!0});let ne=e.getBoundingClientRect(),fe={x:ne.x,y:ne.y,width:ne.width,height:ne.height},ie,be=e.querySelectorAll("svg");if(be.length===1){let Pe=be.item(0).getBoundingClientRect();ie={x:Pe.x,y:Pe.y,width:Pe.width,height:Pe.height}}let oe={x:h.clientX,y:h.clientY};a={type:"pointerDown",dragStart:{dragSessionId:o,elementRect:fe,svgRect:ie,mouse:oe}},t.invoke("setDragData",o,n()),u.addEventListener("pointermove",ye,!0),u.addEventListener("pointerup",ye,!0),window.addEventListener("keydown",Qe,!0),window.addEventListener("blur",Je)},tt=()=>{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",et),e.addEventListener("mouseenter",tt);function Ht(){document.body.style.cursor=s,u.removeEventListener("pointermove",ye,!0),u.removeEventListener("pointerup",ye,!0),window.removeEventListener("keydown",Qe,!0),window.removeEventListener("blur",Je)}return()=>{e.removeEventListener("pointerdown",et),e.removeEventListener("mouseenter",tt),v({cancelled:!0})}}var le=class extends Error{};var yn={canvas:!0,image:!0,editImage:!0,configureManagedCollection:!0,syncManagedCollection:!0,collection:!0};function pt(t){return d(t)&&t in yn}var fn={methodResponse:!0,pluginReadyResponse:!0,subscriptionMessage:!0};function bn(t){return d(t)&&t in fn}function ht(t){return g(t)&&bn(t["type"])}var he,P,D,A=class{constructor(e,n){i(this,"id");c(this,he,void 0);c(this,P,void 0);c(this,D,void 0);l(d(e.id),"Node must have an id"),this.id=e.id,m(this,P,n),m(this,he,e.originalId??null),l(T(n)),m(this,D,n)}get isReplica(){return r(this,he)!==null}remove(){return r(this,P).removeNode(this.id)}select(){return r(this,P).setSelection([this.id])}clone(){return r(this,P).cloneNode(this.id)}setAttributes(e){return r(this,P).setAttributes(this.id,e)}getRect(){return r(this,P).getRect(this.id)}zoomIntoView(e){return r(this,P).zoomIntoView([this.id],e)}getParent(){return r(this,P).getParent(this.id)}getChildren(){return B(this)?Promise.resolve([]):r(this,P).getChildren(this.id)}async getNodesWithType(e){return B(this)?Promise.resolve([]):(await r(this,D).invoke("getNodesWithType",this.id,e)).map(o=>p(o,r(this,P)))}async getNodesWithAttribute(e){return B(this)?Promise.resolve([]):(await r(this,D).invoke("getNodesWithAttribute",this.id,e)).map(o=>p(o,r(this,P)))}async getNodesWithAttributeSet(e){return B(this)?Promise.resolve([]):(await r(this,D).invoke("getNodesWithAttributeSet",this.id,e)).map(o=>p(o,r(this,P)))}async*walk(){if(yield this,!B(this))for(let e of await this.getChildren())yield*e.walk()}async getPluginData(e){return r(this,D).invoke("getPluginDataForNode",this.id,e)}async setPluginData(e,n){return r(this,D).invoke("setPluginDataForNode",this.id,e,n)}async getPluginDataKeys(){return r(this,D).invoke("getPluginDataKeysForNode",this.id)}};he=new WeakMap,P=new WeakMap,D=new WeakMap;var _=class extends A{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=E(n.backgroundColor)?new b(n.backgroundColor,o):n.backgroundColor??null,this.backgroundImage=n.backgroundImage?new f(n.backgroundImage,o):null,this.rotation=n.rotation??0,this.opacity=n.opacity??1,this.borderRadius=n.borderRadius??null,this.backgroundGradient=Ce(n.backgroundGradient)?Se(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)}},Z,de=class extends A{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");c(this,Z,void 0);l(T(o)),m(this,Z,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?V(n.font):null,this.inlineTextStyle=n.inlineTextStyle?new I(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,Z).invoke("setTextForNode",this.id,n)}async getText(){return r(this,Z).invoke("getTextForNode",this.id)}};Z=new WeakMap;var ue=class extends A{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)}},ce=class extends A{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=ct(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)}},me=class extends A{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)}},ge=class extends A{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)}},pe=class extends A{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 me(t,e);case"ComponentNode":return new ge(t,e);case"ComponentInstanceNode":return new ce(t,e);case"FrameNode":return new _(t,e);case"SVGNode":return new ue(t,e);case"TextNode":return new de(t,e);case"UnknownNode":return new pe(t,e);default:return new pe(t,e)}}function ve(t){return t instanceof _}function yt(t){return t instanceof de}function ft(t){return t instanceof ue}function Ae(t){return t instanceof ce}function bt(t){return t instanceof me}function Pt(t){return t instanceof ge}function B(t){return t instanceof pe}function Fe(t){return!!(ve(t)||yt(t)||Ae(t)||ft(t)||B(t))}function Ye(t){return!!(bt(t)||Pt(t)||B(t))}var Q=null;function Tt(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 we,Re,J,U,ee,R,We=class{constructor({isTestEnv:e}={}){c(this,we,0);c(this,Re,0);c(this,J,[]);c(this,U,void 0);c(this,ee,new Map);c(this,R,void 0);i(this,"subscriptions",new Map);i(this,"onMessage",e=>{let n=e.data;if(ht(n))switch(n.type){case"pluginReadyResponse":{if(!e.source)throw new Error("No 'source' on incoming message: "+n.type);l(r(this,R)===n.mode,"Mode must match"),this.applyPluginTheme(n.theme),m(this,U,(s,a)=>window.parent.postMessage(s,e.origin,a));for(let s of r(this,J))r(this,U).call(this,...s);m(this,J,[]);break}case"methodResponse":{let o=r(this,ee).get(n.id);if(!o)throw new Error(`No handler for response with id ${n.id}`);r(this,ee).delete(n.id),n.error?o.reject(new le(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:F(n)}});i(this,"applyPluginTheme",e=>{Tt(()=>{document.body.setAttribute("data-framer-theme",e.mode);for(let n in e.tokens)document.body.style.setProperty(n,e.tokens[n])})});if(e){m(this,R,"canvas");return}if(typeof window>"u"){console.warn("Framer Plugin API is not supported in non-browser environments"),m(this,R,"canvas");return}let o=new URL(window.location.href).searchParams.get("mode");l(pt(o),`Invalid mode: ${o}`),m(this,R,o),window.addEventListener("message",this.onMessage);let s={type:"pluginReadySignal"};window.parent.postMessage(s,"*"),this.subscribe("theme",this.applyPluginTheme),window.addEventListener("pointerdown",()=>{this.invoke("onPointerDown")})}get mode(){return r(this,R)}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:Le(this,we)._++,type:"methodInvocation"},v=s;r(this,ee).set(u.id,{resolve:v,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(e.type==="methodInvocation"&&(e.args=e.args.map(ke)),!r(this,U)){r(this,J).push([e,n]);return}r(this,U).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("getCurrentUser2")}async getProjectInfo(){return this.invoke("getProjectInfo2")}async getSelection(){return(await this.invoke("getSelection")).map(n=>{let o=p(n,this);return l(Fe(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(Fe(a)),a});e(o)})}async getCanvasRoot(){let e=await this.invoke("getCanvasRoot"),n=p(e,this);return l(Ye(n)),n}subscribeToCanvasRoot(e){return this.subscribe("canvasRoot",n=>{let o=p(n,this);l(Ye(o)),e(o)})}async getPublishInfo(){return this.invoke("getPublishInfo")}subscribeToPublishInfo(e){return this.subscribe("publishInfo",e)}async createFrameNode(e,n){let o=await this.invoke("createNode","FrameNode",n??null,e);if(!o)return null;let s=p(o,this);return l(s instanceof _),s}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(Fe(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=await this.invoke("setAttributes",e,n);return o?p(o,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 f(e,this):null}subscribeToImage(e){return this.subscribe("image",n=>{if(!n){e(null);return}e(new f(n,this))})}async addImage(e){let n=await re(e),o=W(n);return this.invokeTransferable("addImage",o,n)}async setImage(e){let n=await re(e),o=W(n);return this.invokeTransferable("setImage",o,n)}async uploadImage(e){let n=await re(e),o=W(n),s=await this.invokeTransferable("uploadImage",o,n);return new f(s,this)}async addImages(e){let n=await Ge(e),o=n.flatMap(W);await this.invokeTransferable("addImages",o,n)}async uploadImages(e){let n=await Ge(e),o=n.flatMap(W),s=await this.invokeTransferable("uploadImages",o,n),a=[];for(let u of s)a.push(new f(u,this));return a}async uploadFile(e){let n=await Ee(e),o=await this.invokeTransferable("uploadFile",W(n),n);return new N(o)}async uploadFiles(e){let n=await Promise.all(e.map(Ee)),o=n.flatMap(W),s=await this.invokeTransferable("uploadFiles",o,n),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:n}){let o=await this.invoke("addComponentInstance",{url:e,attributes:n}),s=p(o,this);return l(Ae(s)),s}async addDetachedComponentLayers({url:e,layout:n,attributes:o}){let s=await this.invoke("addDetachedComponentLayers",{url:e,layout:n,attributes:o}),a=p(s,this);return l(ve(a)),a}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 gt(this,e,n)}async getManagedCollection(){let e=await this.invoke("getManagedCollection");return l(e,"Collection data must be defined"),new De(e,this)}async getCollection(e){let n=await this.invoke("getCollection",e);return n?new q(n,this):null}async getActiveCollection(){let e=await this.invoke("getActiveCollection");return l(e),new q(e,this)}async getCollections(){return(await this.invoke("getCollections")).map(n=>new q(n,this))}notify(e,n){let o=`notification-${Le(this,Re)._++}`;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 b(n,this))}async getColorStyle(e){let n=await this.invoke("getColorStyle",e);return n?new b(n,this):null}async createColorStyle(e){let n=await this.invoke("createColorStyle",e);return new b(n,this)}subscribeToColorStyles(e){return this.subscribe("colorStyles",n=>{let o=n.map(s=>new b(s,this));return e(o)})}async getTextStyles(){return(await this.invoke("getTextStyles")).map(n=>new I(n,this))}async getTextStyle(e){let n=await this.invoke("getTextStyle",e);return n?new I(n,this):null}async createTextStyle(e){let n=await this.invoke("createTextStyle",e);return new I(n,this)}subscribeToTextStyles(e){return this.subscribe("textStyles",n=>{let o=n.map(s=>new I(s,this));return e(o)})}async getFont(e,n){let o=await this.invoke("getFont",e,n);return o?V(o):null}async getFonts(){return(await this.invoke("getFonts")).map(V)}async unstable_ensureMinimumDependencyVersion(e,n){return this.invoke("unstable_ensureMinimumDependencyVersion",e,n)}};we=new WeakMap,Re=new WeakMap,J=new WeakMap,U=new WeakMap,ee=new WeakMap,R=new WeakMap;var qe=new We;function Ze(t,e){let n=In(()=>Te(e)?e():e);Tn(()=>{let o=t.current;if(o instanceof HTMLElement)return qe.makeDraggable(o,n)},[n])}function In(t){let e=xn(t);return e.current=t,Pn((...n)=>e.current(...n),[])}var Nn=te.forwardRef(function({data:e,children:n,...o},s){let a=te.useRef(null);if(Ze(a,e),te.isValidElement(n)){let u=Object.assign({},o);return g(n.props)&&Object.assign(u,n.props),u.ref=kn(a,s,n.ref),te.cloneElement(n,u)}return te.Children.count(n)>1&&te.Children.only(n),null}),Cn="current";function Sn(t){return g(t)&&Cn in t}function kn(...t){return e=>{for(let n of t)Te(n)?n(e):Sn(n)&&(n.current=e)}}var Dn={fixed:!0,sticky:!0,absolute:!0,relative:!0},xt="position";function qi(t){if(!(xt in t))return!1;let e=t[xt];return d(e)&&Dn[e]===!0}var It="top";function Zi(t){if(!(It in t))return!1;let e=t[It];return d(e)||y(e)}var Nt="width";function Qi(t){if(!(Nt in t))return!1;let e=t[Nt];return d(e)||y(e)}var Ct="maxWidth";function Ji(t){if(!(Ct in t))return!1;let e=t[Ct];return d(e)||y(e)}var St="aspectRatio";function eo(t){if(!(St in t))return!1;let e=t[St];return z(e)||y(e)}var kt="name";function to(t){if(!(kt in t))return!1;let e=t[kt];return d(e)||y(e)}var Dt="visible";function no(t){if(!(Dt in t))return!1;let e=t[Dt];return Ve(e)}var vt="locked";function io(t){if(!(vt in t))return!1;let e=t[vt];return Ve(e)}var At="backgroundColor";function oo(t){if(!(At in t))return!1;let e=t[At];return d(e)||G(e)||y(e)}var Ft="backgroundColor";function ro(t){if(!(Ft in t))return!1;let e=t[Ft];return d(e)||E(e)||y(e)}var Wt="backgroundImage";function so(t){if(!(Wt in t))return!1;let e=t[Wt];return e instanceof f||y(e)}var wt="backgroundImage";function ao(t){if(!(wt in t))return!1;let e=t[wt];return e instanceof f?!1:H(e)||y(e)}var Rt="backgroundGradient";function lo(t){if(!(Rt in t))return!1;let e=t[Rt];return ae(e)||y(e)}var Lt="backgroundGradient";function uo(t){if(!(Lt in t))return!1;let e=t[Lt];return g(e)||y(e)}var Vt="rotation";function co(t){if(!(Vt in t))return!1;let e=t[Vt];return z(e)}var Mt="opacity";function mo(t){if(!(Mt in t))return!1;let e=t[Mt];return z(e)}var Et="borderRadius";function go(t){if(!(Et in t))return!1;let e=t[Et];return d(e)||y(e)}var Gt="svg";function po(t){if(!(Gt in t))return!1;let e=t[Gt];return d(e)}var Ot="componentIdentifier";function ho(t){if(!(Ot in t))return!1;let e=t[Ot];return d(e)}var Bt="font";function yo(t){if(!(Bt in t))return!1;let e=t[Bt];return se(e)}var _t="font";function fo(t){if(!(_t in t))return!1;let e=t[_t];return st(e)||y(e)}var Ut="inlineTextStyle";function bo(t){if(!(Ut in t))return!1;let e=t[Ut];return Y(e)||y(e)}var zt="inlineTextStyle";function Po(t){if(!(zt in t))return!1;let e=t[zt];return dt(e)||y(e)}var Kt="link";function To(t){if(!(Kt in t))return!1;let e=t[Kt];return d(e)||y(e)}export{ce as ComponentInstanceNode,ge as ComponentNode,X as ConicGradient,Nn as Draggable,_ as FrameNode,le as FramerPluginError,j as LinearGradient,$ as RadialGradient,ue as SVGNode,de as TextNode,me as WebPageNode,qe as framer,G as isColorStyle,Ae as isComponentInstanceNode,Pt as isComponentNode,Ie as isFileAsset,ve as isFrameNode,Ne as isImageAsset,ft as isSVGNode,yt as isTextNode,Y as isTextStyle,bt as isWebPageNode,eo as supportsAspectRatio,oo as supportsBackgroundColor,ro as supportsBackgroundColorData,lo as supportsBackgroundGradient,uo as supportsBackgroundGradientData,so as supportsBackgroundImage,ao as supportsBackgroundImageData,go as supportsBorderRadius,ho as supportsComponentInfo,yo as supportsFont,fo as supportsFontData,bo as supportsInlineTextStyle,Po as supportsInlineTextStyleData,To as supportsLink,io as supportsLocked,to as supportsName,mo as supportsOpacity,Zi as supportsPins,qi as supportsPosition,co as supportsRotation,po as supportsSVG,Qi as supportsSize,Ji as supportsSizeConstraints,no as supportsVisible,Ze as useMakeDraggable};
`))}catch{}throw n}var Yt="FileAsset",qt="__class";function xe(t){return g(t)?t[qt]===Yt:!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 Ie(t){return t instanceof N}var Zt="ImageAsset",Qt="__class";function H(t){return g(t)?t[Qt]===Zt:!1}var L,K,Be=class Be{constructor(e,n){i(this,"id");i(this,"url");i(this,"thumbnailUrl");i(this,"altText");i(this,"resolution");c(this,L,void 0);c(this,K,void 0);l(T(n)),m(this,K,n),this.url=e.url,this.id=e.id,this.thumbnailUrl=e.thumbnailUrl,this.altText=e.altText,this.resolution=e.resolution}cloneWithAttributes({altText:e,resolution:n}){return new Be({__class:"ImageAsset",id:this.id,url:this.url,thumbnailUrl:this.thumbnailUrl,altText:e!==void 0?e:this.altText,resolution:n!==void 0?n:this.resolution},r(this,K))}async measure(){return en(this.url)}async getData(){if(r(this,L)&&r(this,L).bytes.length>0)return r(this,L);let e=await r(this,K).invoke("getImageData",{id:this.id,resolution:this.resolution});if(!e)throw new Error("Failed to load image data");return m(this,L,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})}};L=new WeakMap,K=new WeakMap;var f=Be;function Ne(t){return t instanceof f}function W(t){return t.type==="bytes"?[t.bytes.buffer]:[]}function Jt(t){if(!g(t))return!1;let e="bytes",n="mimeType";return!(!(e in t)||!(n in t)||!(t[e]instanceof Uint8Array)||!d(t[n]))}async function re(t){if(t instanceof File)return Oe(t);let e=await ot(t.image);return{name:t.name,altText:t.altText,resolution:t.resolution,...e}}async function Ee(t){if(t instanceof File)return Oe(t);let e=await ot(t.file);return{name:t.name,...e}}async function ot(t){return t instanceof File?Oe(t):Jt(t)?{type:"bytes",mimeType:t.mimeType,bytes:t.bytes}:{type:"url",url:t}}function Ge(t){return Promise.all(t.map(re))}async function Oe(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 v=new Uint8Array(u);e({bytes:v,mimeType:a,type:"bytes",name:t.name})},o.onerror=s=>{n(s)},o.readAsArrayBuffer(t)})}async function en(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 tn="Font";function st(t){return g(t)&&t.__class===tn}function nn(t){if(!z(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 on(t){if(!d(t))return!1;switch(t){case"normal":case"italic":return!0;default:return!1}}function se(t){return g(t)?d(t.family)&&d(t.selector)&&nn(t.weight)&&on(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}},rt=new Map;function V(t){let e=rt.get(t.selector);if(e)return e;let n=new w(t);return rt.set(t.selector,n),n}function M(t){return{__class:"Font",selector:t.selector,family:t.family,weight:t.weight,style:t.style}}var at="__class",_e="LinearGradient",Ue="RadialGradient",ze="ConicGradient";function Ce(t){if(!g(t))return!1;switch(t[at]){case _e:case Ue:case ze:return!0;default:return!1}}function ae(t){return t instanceof j||t instanceof $||t instanceof X}function lt(t){if(t instanceof j)return{__class:_e,angle:t.angle,stops:t.stops};if(t instanceof $)return{__class:Ue,width:t.width,height:t.height,x:t.x,y:t.y,stops:t.stops};if(t instanceof X)return{__class:ze,angle:t.angle,x:t.x,y:t.y,stops:t.stops};F(t)}function Se(t){switch(t[at]){case _e:return new j(t);case Ue:return new $(t);case ze:return new X(t);default:F(t)}}var j=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})`}},$=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})`}},X=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 rn="ColorStyle",sn="__class";function E(t){return g(t)?t[sn]===rn:!1}var C,He=class He{constructor(e,n){i(this,"id");i(this,"name");i(this,"light");i(this,"dark");c(this,C,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(T(n)),m(this,C,n)}async setAttributes(e){let n=await r(this,C).invoke("setColorStyleAttributes",this.id,e);return n?new He(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("removeColorStyle",this.id)}};C=new WeakMap;var b=He;function G(t){return t instanceof b}function Ke(t){return{__class:"ColorStyle",id:t.id,name:t.name,light:t.light,dark:t.dark}}var an="TextStyle",ln="__class";function dt(t){return g(t)?t[ln]===an:!1}var S,je=class je{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");c(this,S,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(e.color)?new b(e.color,n):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(T(n)),m(this,S,n)}async setAttributes(e){let n=await r(this,S).invoke("setTextStyleAttributes",this.id,e);return n?new je(n,r(this,S)):null}async getPluginData(e){return r(this,S).invoke("getPluginDataForNode",this.id,e)}async setPluginData(e,n){return r(this,S).invoke("setPluginDataForNode",this.id,e,n)}async getPluginDataKeys(){return r(this,S).invoke("getPluginDataKeysForNode",this.id)}async remove(){return r(this,S).invoke("removeTextStyle",this.id)}};S=new WeakMap;var I=je;function Y(t){return t instanceof I}function ut(t){return{__class:"TextStyle",id:t.id,name:t.name,tag:t.tag,font:M(t.font),boldFont:t.boldFont?M(t.font):null,italicFont:t.italicFont?M(t.italicFont):null,boldItalicFont:t.boldItalicFont?M(t.boldItalicFont):null,color:G(t.color)?Ke(t.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 ke(t){if(un(t))return cn(t);if(Me(t))return t.map(ke);if(g(t)&&!(t instanceof Uint8Array)){let e={};for(let n in t)e[n]=ke(t[n]);return e}return t}function ct(t,e){let n={};for(let o in t)n[o]=$e(t[o],e);return n}function $e(t,e){if(dn(t))switch(t.__class){case"ImageAsset":return new f(t,e);case"FileAsset":return new N(t);case"LinearGradient":case"RadialGradient":case"ConicGradient":return Se(t);case"TextStyle":return new I(t,e);case"Font":return V(t);case"ColorStyle":return new b(t,e);default:F(t)}if(g(t)){let n={};for(let o in t)n[o]=$e(t[o],e);return n}return Me(t)?t.map(n=>$e(n,e)):t}function dn(t){return!!(H(t)||xe(t)||Ce(t))}function un(t){return!!(Ne(t)||Ie(t)||ae(t)||Y(t)||se(t)||G(t))}function cn(t){if(Ne(t))return{__class:"ImageAsset",id:t.id,thumbnailUrl:t.thumbnailUrl,url:t.url,altText:t.altText,resolution:t.resolution};if(Ie(t))return{__class:"FileAsset",id:t.id,extension:t.extension,url:t.url};if(ae(t))return lt(t);if(Y(t))return ut(t);if(se(t))return M(t);if(G(t))return Ke(t);F(t)}function mn(t,e){for(let n in t){let o=t[n];H(o)&&(t[n]=new f(o,e)),xe(o)&&(t[n]=new N(o)),E(o)&&(t[n]=new b(o,e))}}var x,De=class{constructor(e,n){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(T(n)),m(this,x,n),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,n){return r(this,x).invoke("setPluginDataForNode",this.id,e,n)}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 k,q=class{constructor(e,n){i(this,"id");i(this,"name");c(this,k,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(T(n)),m(this,k,n),Object.freeze(this)}async getFields(){return r(this,k).invoke("getCollectionFields",this.id)}async getItems(){return(await r(this,k).invoke("getCollectionItems",this.id)).map(n=>new Xe(n,r(this,k)))}async setPluginData(e,n){return r(this,k).invoke("setPluginDataForNode",this.id,e,n)}async getPluginData(e){return r(this,k).invoke("getPluginDataForNode",this.id,e)}async getPluginDataKeys(){return r(this,k).invoke("getPluginDataKeysForNode",this.id)}};k=new WeakMap;var O,Xe=class{constructor(e,n){i(this,"id");i(this,"slug");i(this,"draft");i(this,"fieldData");c(this,O,void 0);this.id=e.id,this.slug=e.slug,this.draft=e.draft??!1,this.fieldData=e.fieldData,mn(this.fieldData,n),l(T(n)),m(this,O,n),Object.freeze(this),Object.freeze(this.fieldData)}async setPluginData(e,n){return r(this,O).invoke("setPluginDataForNode",this.id,e,n)}async getPluginData(e){return r(this,O).invoke("getPluginDataForNode",this.id,e)}async getPluginDataKeys(){return r(this,O).invoke("getPluginDataKeysForNode",this.id)}};O=new WeakMap;var gn=(()=>{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)}}}})(),mt=5,pn=(()=>{let t=1;return{next:()=>`drag-${t++}`}})();function hn(){}function gt(t,e,n){if(t.mode!=="canvas")return hn;l(T(t));let o=pn.next(),s=document.body.style.cursor,a={type:"idle"},u=document.body,v=h=>{a.type!=="idle"&&(a.type==="dragging"&&t.invoke("onDragEnd",{...h,dragSessionId:o}),a={type:"idle"},Ht())},ye=h=>{if(a.type==="idle")return;if(!(h.buttons>0&&!!(h.buttons&1))){v({cancelled:!1});return}let{clientX:fe,clientY:ie}=h;if(a.type==="pointerDown"){let oe=fe-a.dragStart.mouse.x,nt=ie-a.dragStart.mouse.y;if(Math.abs(oe)<mt&&Math.abs(nt)<mt)return;a={type:"dragging",dragStart:a.dragStart},t.invoke("onDragStart",a.dragStart),document.getSelection()?.empty(),gn.disableUntilMouseUp()}u.setPointerCapture(h.pointerId);let be={x:fe,y:ie};t.invoke("onDrag",{dragSessionId:o,mouse:be}).then(oe=>{a.type==="dragging"&&(document.body.style.cursor=oe??"")})},Qe=h=>{h.key==="Escape"&&v({cancelled:!0})},Je=()=>{v({cancelled:!0})},et=h=>{v({cancelled:!0});let ne=e.getBoundingClientRect(),fe={x:ne.x,y:ne.y,width:ne.width,height:ne.height},ie,be=e.querySelectorAll("svg");if(be.length===1){let Pe=be.item(0).getBoundingClientRect();ie={x:Pe.x,y:Pe.y,width:Pe.width,height:Pe.height}}let oe={x:h.clientX,y:h.clientY};a={type:"pointerDown",dragStart:{dragSessionId:o,elementRect:fe,svgRect:ie,mouse:oe}},t.invoke("setDragData",o,n()),u.addEventListener("pointermove",ye,!0),u.addEventListener("pointerup",ye,!0),window.addEventListener("keydown",Qe,!0),window.addEventListener("blur",Je)},tt=()=>{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",et),e.addEventListener("mouseenter",tt);function Ht(){document.body.style.cursor=s,u.removeEventListener("pointermove",ye,!0),u.removeEventListener("pointerup",ye,!0),window.removeEventListener("keydown",Qe,!0),window.removeEventListener("blur",Je)}return()=>{e.removeEventListener("pointerdown",et),e.removeEventListener("mouseenter",tt),v({cancelled:!0})}}var le=class extends Error{};var yn={canvas:!0,image:!0,editImage:!0,configureManagedCollection:!0,syncManagedCollection:!0,collection:!0};function pt(t){return d(t)&&t in yn}var fn={methodResponse:!0,pluginReadyResponse:!0,subscriptionMessage:!0};function bn(t){return d(t)&&t in fn}function ht(t){return g(t)&&bn(t["type"])}var he,P,D,A=class{constructor(e,n){i(this,"id");c(this,he,void 0);c(this,P,void 0);c(this,D,void 0);l(d(e.id),"Node must have an id"),this.id=e.id,m(this,P,n),m(this,he,e.originalId??null),l(T(n)),m(this,D,n)}get isReplica(){return r(this,he)!==null}remove(){return r(this,P).removeNode(this.id)}select(){return r(this,P).setSelection([this.id])}clone(){return r(this,P).cloneNode(this.id)}setAttributes(e){return r(this,P).setAttributes(this.id,e)}getRect(){return r(this,P).getRect(this.id)}zoomIntoView(e){return r(this,P).zoomIntoView([this.id],e)}getParent(){return r(this,P).getParent(this.id)}getChildren(){return B(this)?Promise.resolve([]):r(this,P).getChildren(this.id)}async getNodesWithType(e){return B(this)?Promise.resolve([]):(await r(this,D).invoke("getNodesWithType",this.id,e)).map(o=>p(o,r(this,P)))}async getNodesWithAttribute(e){return B(this)?Promise.resolve([]):(await r(this,D).invoke("getNodesWithAttribute",this.id,e)).map(o=>p(o,r(this,P)))}async getNodesWithAttributeSet(e){return B(this)?Promise.resolve([]):(await r(this,D).invoke("getNodesWithAttributeSet",this.id,e)).map(o=>p(o,r(this,P)))}async*walk(){if(yield this,!B(this))for(let e of await this.getChildren())yield*e.walk()}async getPluginData(e){return r(this,D).invoke("getPluginDataForNode",this.id,e)}async setPluginData(e,n){return r(this,D).invoke("setPluginDataForNode",this.id,e,n)}async getPluginDataKeys(){return r(this,D).invoke("getPluginDataKeysForNode",this.id)}};he=new WeakMap,P=new WeakMap,D=new WeakMap;var _=class extends A{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=E(n.backgroundColor)?new b(n.backgroundColor,o):n.backgroundColor??null,this.backgroundImage=n.backgroundImage?new f(n.backgroundImage,o):null,this.rotation=n.rotation??0,this.opacity=n.opacity??1,this.borderRadius=n.borderRadius??null,this.backgroundGradient=Ce(n.backgroundGradient)?Se(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)}},Z,de=class extends A{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");c(this,Z,void 0);l(T(o)),m(this,Z,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?V(n.font):null,this.inlineTextStyle=n.inlineTextStyle?new I(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,Z).invoke("setTextForNode",this.id,n)}async getText(){return r(this,Z).invoke("getTextForNode",this.id)}};Z=new WeakMap;var ue=class extends A{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)}},ce=class extends A{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=ct(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)}},me=class extends A{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)}},ge=class extends A{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)}},pe=class extends A{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 me(t,e);case"ComponentNode":return new ge(t,e);case"ComponentInstanceNode":return new ce(t,e);case"FrameNode":return new _(t,e);case"SVGNode":return new ue(t,e);case"TextNode":return new de(t,e);case"UnknownNode":return new pe(t,e);default:return new pe(t,e)}}function ve(t){return t instanceof _}function yt(t){return t instanceof de}function ft(t){return t instanceof ue}function Ae(t){return t instanceof ce}function bt(t){return t instanceof me}function Pt(t){return t instanceof ge}function B(t){return t instanceof pe}function Fe(t){return!!(ve(t)||yt(t)||Ae(t)||ft(t)||B(t))}function Ye(t){return!!(bt(t)||Pt(t)||B(t))}var Q=null;function Tt(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 we,Re,J,U,ee,R,We=class{constructor({isTestEnv:e}={}){c(this,we,0);c(this,Re,0);c(this,J,[]);c(this,U,void 0);c(this,ee,new Map);c(this,R,void 0);i(this,"subscriptions",new Map);i(this,"onMessage",e=>{let n=e.data;if(ht(n))switch(n.type){case"pluginReadyResponse":{if(!e.source)throw new Error("No 'source' on incoming message: "+n.type);l(r(this,R)===n.mode,"Mode must match"),this.applyPluginTheme(n.theme),m(this,U,(s,a)=>window.parent.postMessage(s,e.origin,a));for(let s of r(this,J))r(this,U).call(this,...s);m(this,J,[]);break}case"methodResponse":{let o=r(this,ee).get(n.id);if(!o)throw new Error(`No handler for response with id ${n.id}`);r(this,ee).delete(n.id),n.error?o.reject(new le(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:F(n)}});i(this,"applyPluginTheme",e=>{Tt(()=>{document.body.setAttribute("data-framer-theme",e.mode);for(let n in e.tokens)document.body.style.setProperty(n,e.tokens[n])})});if(e){m(this,R,"canvas");return}if(typeof window>"u"){console.warn("Framer Plugin API is not supported in non-browser environments"),m(this,R,"canvas");return}let o=new URL(window.location.href).searchParams.get("mode");l(pt(o),`Invalid mode: ${o}`),m(this,R,o),window.addEventListener("message",this.onMessage);let s={type:"pluginReadySignal"};window.parent.postMessage(s,"*"),this.subscribe("theme",this.applyPluginTheme),window.addEventListener("pointerdown",()=>{this.invoke("onPointerDown")})}get mode(){return r(this,R)}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:Le(this,we)._++,type:"methodInvocation"},v=s;r(this,ee).set(u.id,{resolve:v,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(e.type==="methodInvocation"&&(e.args=e.args.map(ke)),!r(this,U)){r(this,J).push([e,n]);return}r(this,U).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(Fe(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(Fe(a)),a});e(o)})}async getCanvasRoot(){let e=await this.invoke("getCanvasRoot"),n=p(e,this);return l(Ye(n)),n}subscribeToCanvasRoot(e){return this.subscribe("canvasRoot",n=>{let o=p(n,this);l(Ye(o)),e(o)})}async getPublishInfo(){return this.invoke("getPublishInfo")}subscribeToPublishInfo(e){return this.subscribe("publishInfo",e)}async createFrameNode(e,n){let o=await this.invoke("createNode","FrameNode",n??null,e);if(!o)return null;let s=p(o,this);return l(s instanceof _),s}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(Fe(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=await this.invoke("setAttributes",e,n);return o?p(o,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 f(e,this):null}subscribeToImage(e){return this.subscribe("image",n=>{if(!n){e(null);return}e(new f(n,this))})}async addImage(e){let n=await re(e),o=W(n);return this.invokeTransferable("addImage",o,n)}async setImage(e){let n=await re(e),o=W(n);return this.invokeTransferable("setImage",o,n)}async uploadImage(e){let n=await re(e),o=W(n),s=await this.invokeTransferable("uploadImage",o,n);return new f(s,this)}async addImages(e){let n=await Ge(e),o=n.flatMap(W);await this.invokeTransferable("addImages",o,n)}async uploadImages(e){let n=await Ge(e),o=n.flatMap(W),s=await this.invokeTransferable("uploadImages",o,n),a=[];for(let u of s)a.push(new f(u,this));return a}async uploadFile(e){let n=await Ee(e),o=await this.invokeTransferable("uploadFile",W(n),n);return new N(o)}async uploadFiles(e){let n=await Promise.all(e.map(Ee)),o=n.flatMap(W),s=await this.invokeTransferable("uploadFiles",o,n),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:n}){let o=await this.invoke("addComponentInstance",{url:e,attributes:n}),s=p(o,this);return l(Ae(s)),s}async addDetachedComponentLayers({url:e,layout:n,attributes:o}){let s=await this.invoke("addDetachedComponentLayers",{url:e,layout:n,attributes:o}),a=p(s,this);return l(ve(a)),a}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 gt(this,e,n)}async getManagedCollection(){let e=await this.invoke("getManagedCollection");return l(e,"Collection data must be defined"),new De(e,this)}async getCollection(e){let n=await this.invoke("getCollection",e);return n?new q(n,this):null}async getActiveCollection(){let e=await this.invoke("getActiveCollection");return l(e),new q(e,this)}async getCollections(){return(await this.invoke("getCollections")).map(n=>new q(n,this))}notify(e,n){let o=`notification-${Le(this,Re)._++}`;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 b(n,this))}async getColorStyle(e){let n=await this.invoke("getColorStyle",e);return n?new b(n,this):null}async createColorStyle(e){let n=await this.invoke("createColorStyle",e);return new b(n,this)}subscribeToColorStyles(e){return this.subscribe("colorStyles",n=>{let o=n.map(s=>new b(s,this));return e(o)})}async getTextStyles(){return(await this.invoke("getTextStyles")).map(n=>new I(n,this))}async getTextStyle(e){let n=await this.invoke("getTextStyle",e);return n?new I(n,this):null}async createTextStyle(e){let n=await this.invoke("createTextStyle",e);return new I(n,this)}subscribeToTextStyles(e){return this.subscribe("textStyles",n=>{let o=n.map(s=>new I(s,this));return e(o)})}async getFont(e,n){let o=await this.invoke("getFont",e,n);return o?V(o):null}async getFonts(){return(await this.invoke("getFonts")).map(V)}async unstable_ensureMinimumDependencyVersion(e,n){return this.invoke("unstable_ensureMinimumDependencyVersion",e,n)}};we=new WeakMap,Re=new WeakMap,J=new WeakMap,U=new WeakMap,ee=new WeakMap,R=new WeakMap;var qe=new We;function Ze(t,e){let n=In(()=>Te(e)?e():e);Tn(()=>{let o=t.current;if(o instanceof HTMLElement)return qe.makeDraggable(o,n)},[n])}function In(t){let e=xn(t);return e.current=t,Pn((...n)=>e.current(...n),[])}var Nn=te.forwardRef(function({data:e,children:n,...o},s){let a=te.useRef(null);if(Ze(a,e),te.isValidElement(n)){let u=Object.assign({},o);return g(n.props)&&Object.assign(u,n.props),u.ref=kn(a,s,n.ref),te.cloneElement(n,u)}return te.Children.count(n)>1&&te.Children.only(n),null}),Cn="current";function Sn(t){return g(t)&&Cn in t}function kn(...t){return e=>{for(let n of t)Te(n)?n(e):Sn(n)&&(n.current=e)}}var Dn={fixed:!0,sticky:!0,absolute:!0,relative:!0},xt="position";function qi(t){if(!(xt in t))return!1;let e=t[xt];return d(e)&&Dn[e]===!0}var It="top";function Zi(t){if(!(It in t))return!1;let e=t[It];return d(e)||y(e)}var Nt="width";function Qi(t){if(!(Nt in t))return!1;let e=t[Nt];return d(e)||y(e)}var Ct="maxWidth";function Ji(t){if(!(Ct in t))return!1;let e=t[Ct];return d(e)||y(e)}var St="aspectRatio";function eo(t){if(!(St in t))return!1;let e=t[St];return z(e)||y(e)}var kt="name";function to(t){if(!(kt in t))return!1;let e=t[kt];return d(e)||y(e)}var Dt="visible";function no(t){if(!(Dt in t))return!1;let e=t[Dt];return Ve(e)}var vt="locked";function io(t){if(!(vt in t))return!1;let e=t[vt];return Ve(e)}var At="backgroundColor";function oo(t){if(!(At in t))return!1;let e=t[At];return d(e)||G(e)||y(e)}var Ft="backgroundColor";function ro(t){if(!(Ft in t))return!1;let e=t[Ft];return d(e)||E(e)||y(e)}var Wt="backgroundImage";function so(t){if(!(Wt in t))return!1;let e=t[Wt];return e instanceof f||y(e)}var wt="backgroundImage";function ao(t){if(!(wt in t))return!1;let e=t[wt];return e instanceof f?!1:H(e)||y(e)}var Rt="backgroundGradient";function lo(t){if(!(Rt in t))return!1;let e=t[Rt];return ae(e)||y(e)}var Lt="backgroundGradient";function uo(t){if(!(Lt in t))return!1;let e=t[Lt];return g(e)||y(e)}var Vt="rotation";function co(t){if(!(Vt in t))return!1;let e=t[Vt];return z(e)}var Mt="opacity";function mo(t){if(!(Mt in t))return!1;let e=t[Mt];return z(e)}var Et="borderRadius";function go(t){if(!(Et in t))return!1;let e=t[Et];return d(e)||y(e)}var Gt="svg";function po(t){if(!(Gt in t))return!1;let e=t[Gt];return d(e)}var Ot="componentIdentifier";function ho(t){if(!(Ot in t))return!1;let e=t[Ot];return d(e)}var Bt="font";function yo(t){if(!(Bt in t))return!1;let e=t[Bt];return se(e)}var _t="font";function fo(t){if(!(_t in t))return!1;let e=t[_t];return st(e)||y(e)}var Ut="inlineTextStyle";function bo(t){if(!(Ut in t))return!1;let e=t[Ut];return Y(e)||y(e)}var zt="inlineTextStyle";function Po(t){if(!(zt in t))return!1;let e=t[zt];return dt(e)||y(e)}var Kt="link";function To(t){if(!(Kt in t))return!1;let e=t[Kt];return d(e)||y(e)}export{ce as ComponentInstanceNode,ge as ComponentNode,X as ConicGradient,Nn as Draggable,_ as FrameNode,le as FramerPluginError,j as LinearGradient,$ as RadialGradient,ue as SVGNode,de as TextNode,me as WebPageNode,qe as framer,G as isColorStyle,Ae as isComponentInstanceNode,Pt as isComponentNode,Ie as isFileAsset,ve as isFrameNode,Ne as isImageAsset,ft as isSVGNode,yt as isTextNode,Y as isTextStyle,bt as isWebPageNode,eo as supportsAspectRatio,oo as supportsBackgroundColor,ro as supportsBackgroundColorData,lo as supportsBackgroundGradient,uo as supportsBackgroundGradientData,so as supportsBackgroundImage,ao as supportsBackgroundImageData,go as supportsBorderRadius,ho as supportsComponentInfo,yo as supportsFont,fo as supportsFontData,bo as supportsInlineTextStyle,Po as supportsInlineTextStyleData,To as supportsLink,io as supportsLocked,to as supportsName,mo as supportsOpacity,Zi as supportsPins,qi as supportsPosition,co as supportsRotation,po as supportsSVG,Qi as supportsSize,Ji as supportsSizeConstraints,no as supportsVisible,Ze as useMakeDraggable};
{
"name": "framer-plugin",
"version": "2.0.0",
"version": "2.0.1",
"type": "module",

@@ -5,0 +5,0 @@ "main": "src/index.ts",

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc