polotno 4.22.0 → 4.22.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -3,6 +3,7 @@ import type { StoreType, Section } from '../ui-types.js';
3
3
  export type { Section } from '../ui-types.js';
4
4
  export { SectionTab } from './tab-button.js';
5
5
  export { ImagesGrid } from './images-grid.js';
6
+ export { VariablesSection } from './variables-panel.js';
6
7
  export declare const TemplatesSection: Section;
7
8
  export declare const TextSection: Section;
8
9
  export declare const PhotosSection: Section;
@@ -1 +1 @@
1
- import{jsx as e,jsxs as n}from"react/jsx-runtime";import*as o from"react";import{observer as a}from"mobx-react-lite";import{flags as t}from"../utils/flags.js";import{useMobile as i}from"../utils/screen.js";import{t as l}from"../utils/l10n.js";import{cn as s}from"../lib/utils.js";import{PolotnoScope as r}from"../primitives/portal-scope.js";import{SectionTab as p}from"./tab-button.js";import{TemplatesPanel as d}from"./templates-panel.js";import{TextPanel as m}from"./text-panel.js";import{PhotosPanel as c}from"./photos-panel.js";import{ElementsPanel as b}from"./elements-panel.js";import{UploadPanel as f}from"./upload-panel.js";import{BackgroundPanel as u}from"./background-panel.js";import{PagesPanel as P}from"./pages-panel.js";import{LayersPanel as x}from"./layers-panel.js";import{SizePanel as S}from"./size-panel.js";import{DrawPanel as h}from"./draw-panel.js";import{VideosPanel as g}from"./videos-panel.js";import{ImageClipPanel as v}from"./image-clip-panel.js";import{ImageEditPanel as j}from"./image-edit-panel.js";import{AnimationsPanel as w}from"./animations-panel.js";import{EffectsPanel as T}from"./effects-panel.js";import{PolotnoIcon as k}from"../icons/registry.js";export{SectionTab}from"./tab-button.js";export{ImagesGrid}from"./images-grid.js";export const TemplatesSection={name:"templates",Tab:a(n=>e(p,Object.assign({name:l("sidePanel.templates")},n,{children:e(k,{name:"sidePanel.templates"})}))),Panel:({store:n})=>e(d,{store:n})};export const TextSection={name:"text",Tab:a(n=>e(p,Object.assign({name:l("sidePanel.text")},n,{children:e(k,{name:"sidePanel.text"})}))),Panel:({store:n})=>e(m,{store:n})};export const PhotosSection={name:"photos",Tab:a(n=>e(p,Object.assign({name:l("sidePanel.photos")},n,{children:e(k,{name:"sidePanel.photos"})}))),Panel:({store:n})=>e(c,{store:n})};export const ElementsSection={name:"elements",Tab:a(n=>e(p,Object.assign({name:l("sidePanel.elements"),iconSize:16},n,{children:e(k,{name:"sidePanel.elements"})}))),Panel:({store:n})=>e(b,{store:n})};export const UploadSection={name:"upload",Tab:a(n=>e(p,Object.assign({name:l("sidePanel.upload")},n,{children:e(k,{name:"sidePanel.upload"})}))),Panel:({store:n})=>e(f,{store:n})};export const BackgroundSection={name:"background",Tab:a(n=>e(p,Object.assign({name:l("sidePanel.background")},n,{children:e(k,{name:"sidePanel.background"})}))),Panel:({store:n})=>e(u,{store:n})};export const PagesSection={name:"pages",Tab:a(n=>e(p,Object.assign({name:l("sidePanel.pages")},n,{children:e(k,{name:"sidePanel.pages"})}))),Panel:({store:n})=>e(P,{store:n}),visibleInList:!1};export const LayersSection={name:"layers",Tab:a(n=>e(p,Object.assign({name:l("sidePanel.layers")},n,{children:e(k,{name:"sidePanel.layers"})}))),Panel:({store:n})=>e(x,{store:n})};export const SizeSection={name:"size",Tab:a(n=>e(p,Object.assign({name:l("sidePanel.resize")},n,{children:e(k,{name:"sidePanel.resize"})}))),Panel:({store:n})=>e(S,{store:n})};export const DrawSection={name:"draw",Tab:a(n=>e(p,Object.assign({name:l("sidePanel.draw")},n,{children:e(k,{name:"sidePanel.draw"})}))),Panel:({store:n})=>e(h,{store:n})};export const VideosSection={name:"videos",Tab:n=>e(p,Object.assign({name:l("sidePanel.videos")},n,{children:e(k,{name:"sidePanel.videos"})})),Panel:g};export const ImageEditSection={name:"image-edit",Tab:()=>null,Panel:j,visibleInList:!1};export const DEFAULT_SECTIONS=[TemplatesSection,TextSection,PhotosSection,ElementsSection,DrawSection,UploadSection,BackgroundSection,LayersSection,SizeSection,ImageEditSection];const C={name:"image-clip",Tab:()=>null,Panel:v},E={name:"effects",Tab:()=>null,Panel:T},N={name:"animation",Tab:()=>null,Panel:w};export const INTERNAL_SECTIONS=[C,E];const I=new Set([v,T,w]),O=({onClick:o})=>n("div",{className:"pn-side-panel-hide-button pn:absolute pn:right-[-14px] pn:top-1/2 pn:z-10 pn:h-24 pn:w-[15px] pn:cursor-pointer pn:max-md:hidden pn:pn-mobile:hidden",onClick:o,children:[e("svg",{width:"15",height:"96",viewBox:"0 0 16 96",xmlns:"http://www.w3.org/2000/svg",children:e("path",{className:"pn:stroke-border pn:fill-background",d:"M 1 7 C 2 9 4 10 7.2 13.28 C 7.45 13.4625 7.6 13.6 7.7 13.8048 L 7.8 13.8 C 9.8 15.8 11.6 17.6 12.9 19.7 C 14 21.6 14.7 23.9 14.9 27 H 15 V 68 C 15 71.7 14.3 74.3 13 76.6 C 11.7 78.8 9.9 80.5 7.8 82.6344 L 7.79 82.6 C 7.6 82.8 7.4507 83 7.2729 83.2127 C 3.9102 86.5228 2 87 1 90"})}),e("div",{className:"pn:absolute pn:left-1/2 pn:top-1/2 pn:text-[0.5rem] pn:text-muted-foreground pn:hover:text-foreground",style:{transform:"translate(-50%, -50%) scaleY(2)"},children:"<"})]});export const SidePanel=a(({store:a,sections:l,defaultSection:p="photos"})=>{var d,m;(()=>{const e=o.useRef(!0);e.current&&(e.current=!1,a.openSidePanel(p))})();const c=i();o.useLayoutEffect(()=>{c?a.openSidePanel(""):a.openSidePanel(p)},[c]);const b=[...l||DEFAULT_SECTIONS],f=b.find(e=>"image-edit"===e.name),u=!!f;o.useLayoutEffect(()=>(a._setImageEditPanelAvailable(u),()=>a._setImageEditPanelAvailable(!1)),[a,u]);const P=o.useRef(p),x=(null==f?void 0:f.Panel)===j,S="expand"===(null===(d=a.activeTool)||void 0===d?void 0:d.name)||"inpaint"===(null===(m=a.activeTool)||void 0===m?void 0:m.name),h=c&&x&&S&&"image-edit"===a.openedSidePanel;if(o.useLayoutEffect(()=>{"image-edit"!==a.openedSidePanel?P.current=a.openedSidePanel:x&&!a.activeTool&&a.openSidePanel("image-edit"===P.current?"":P.current)},[a,a.openedSidePanel,a.activeTool,x]),INTERNAL_SECTIONS.forEach(e=>{b.find(n=>n.name===e.name)||b.push(e)}),t.animationsEnabled){if(!b.find(e=>"videos"===e.name)){const e=Math.floor(b.length/2);b.splice(e,0,VideosSection)}if(!b.find(e=>"animations"===e.name)){const e=Math.floor(b.length/2);b.splice(e,0,N)}}const g=b.filter(e=>{var n;return null===(n=e.visibleInList)||void 0===n||n}),v=e=>{const n=e.target,o=n.closest(".polotno-close-panel"),t=n.closest(".polotno-mobile");o&&(c||t)&&a.openSidePanel("")},w=o.useRef(null),T=o.useRef(null),k=o.useRef(new Set);return a.openedSidePanel&&k.current.add(a.openedSidePanel),e(r,{elementRef:T,children:n("div",{ref:T,className:s("polotno-side-panel pn-side-panel pn:relative pn:flex pn:h-full pn:bg-background pn:p-0 pn:text-foreground","pn:md:border-r pn:md:border-border","pn:max-md:h-auto pn:max-md:w-full pn:pn-mobile:h-auto pn:pn-mobile:w-full","pn:max-md:border-t pn:max-md:border-border pn:pn-mobile:border-t pn:pn-mobile:border-border",h&&"pn:flex-col-reverse",!a.openedSidePanel&&"collapsed"),children:[e("div",{ref:w,className:s("polotno-side-tabs-container pn:bg-background pn:max-md:w-full pn:max-md:overflow-auto pn:pn-mobile:w-full pn:pn-mobile:overflow-auto pn:md:overflow-y-auto pn:md:overflow-x-hidden pn:md:min-w-[72px]",a.openedSidePanel&&"pn:md:border-r pn:md:border-border"),children:e("div",{className:"polotno-side-tabs-inner pn:flex pn:flex-col pn:max-md:flex-row pn:max-md:min-w-min pn:pn-mobile:flex-row pn:pn-mobile:min-w-min",children:g.map(({name:n,Tab:o})=>e(o,{active:n===a.openedSidePanel,onClick:()=>{n===a.openedSidePanel&&c?a.openSidePanel(""):a.openSidePanel(n)}},n))})}),b.map(({name:n,Panel:o})=>k.current.has(n)&&e("div",{className:s("polotno-panel-container pn-side-panel-content pn:h-full pn:px-2",!I.has(o)&&"pn:pt-2.5","pn:w-[var(--pn-sidebar-width,350px)]",!a.openedSidePanel&&"pn:w-0",n!==a.openedSidePanel&&"pn:hidden","pn:max-md:w-full pn:max-md:bg-background pn:pn-mobile:w-full pn:pn-mobile:bg-background",h&&"image-edit"===n?"pn:flex pn:h-auto pn:max-h-[40dvh] pn:shrink-0 pn:flex-col pn:border-b pn:border-border":"pn:max-md:absolute pn:max-md:bottom-[54px] pn:max-md:z-[100] pn:max-md:!h-[50vh] pn:pn-mobile:absolute pn:pn-mobile:bottom-[54px] pn:pn-mobile:z-[100] pn:pn-mobile:!h-[50vh]"),onClick:v,children:e(o,{store:a})},n)),a.openedSidePanel&&c&&!S&&e("div",{className:"polotno-close-panel",style:{position:"absolute",left:0,bottom:"72px",width:"100vw",height:"100vh",zIndex:99,backgroundColor:"rgba(0,0,0,0.05)"},onClick:()=>a.openSidePanel("")}),a.openedSidePanel&&e(O,{onClick:()=>a.openSidePanel("")})]})})});SidePanel.displayName="SidePanel";export default SidePanel;
1
+ import{jsx as e,jsxs as n}from"react/jsx-runtime";import*as o from"react";import{observer as a}from"mobx-react-lite";import{flags as t}from"../utils/flags.js";import{useMobile as i}from"../utils/screen.js";import{t as l}from"../utils/l10n.js";import{cn as s}from"../lib/utils.js";import{PolotnoScope as r}from"../primitives/portal-scope.js";import{SectionTab as p}from"./tab-button.js";import{TemplatesPanel as d}from"./templates-panel.js";import{TextPanel as m}from"./text-panel.js";import{PhotosPanel as c}from"./photos-panel.js";import{ElementsPanel as b}from"./elements-panel.js";import{UploadPanel as f}from"./upload-panel.js";import{BackgroundPanel as u}from"./background-panel.js";import{PagesPanel as P}from"./pages-panel.js";import{LayersPanel as x}from"./layers-panel.js";import{SizePanel as S}from"./size-panel.js";import{DrawPanel as h}from"./draw-panel.js";import{VideosPanel as g}from"./videos-panel.js";import{ImageClipPanel as v}from"./image-clip-panel.js";import{ImageEditPanel as j}from"./image-edit-panel.js";import{AnimationsPanel as w}from"./animations-panel.js";import{EffectsPanel as T}from"./effects-panel.js";import{PolotnoIcon as k}from"../icons/registry.js";export{SectionTab}from"./tab-button.js";export{ImagesGrid}from"./images-grid.js";export{VariablesSection}from"./variables-panel.js";export const TemplatesSection={name:"templates",Tab:a(n=>e(p,Object.assign({name:l("sidePanel.templates")},n,{children:e(k,{name:"sidePanel.templates"})}))),Panel:({store:n})=>e(d,{store:n})};export const TextSection={name:"text",Tab:a(n=>e(p,Object.assign({name:l("sidePanel.text")},n,{children:e(k,{name:"sidePanel.text"})}))),Panel:({store:n})=>e(m,{store:n})};export const PhotosSection={name:"photos",Tab:a(n=>e(p,Object.assign({name:l("sidePanel.photos")},n,{children:e(k,{name:"sidePanel.photos"})}))),Panel:({store:n})=>e(c,{store:n})};export const ElementsSection={name:"elements",Tab:a(n=>e(p,Object.assign({name:l("sidePanel.elements"),iconSize:16},n,{children:e(k,{name:"sidePanel.elements"})}))),Panel:({store:n})=>e(b,{store:n})};export const UploadSection={name:"upload",Tab:a(n=>e(p,Object.assign({name:l("sidePanel.upload")},n,{children:e(k,{name:"sidePanel.upload"})}))),Panel:({store:n})=>e(f,{store:n})};export const BackgroundSection={name:"background",Tab:a(n=>e(p,Object.assign({name:l("sidePanel.background")},n,{children:e(k,{name:"sidePanel.background"})}))),Panel:({store:n})=>e(u,{store:n})};export const PagesSection={name:"pages",Tab:a(n=>e(p,Object.assign({name:l("sidePanel.pages")},n,{children:e(k,{name:"sidePanel.pages"})}))),Panel:({store:n})=>e(P,{store:n}),visibleInList:!1};export const LayersSection={name:"layers",Tab:a(n=>e(p,Object.assign({name:l("sidePanel.layers")},n,{children:e(k,{name:"sidePanel.layers"})}))),Panel:({store:n})=>e(x,{store:n})};export const SizeSection={name:"size",Tab:a(n=>e(p,Object.assign({name:l("sidePanel.resize")},n,{children:e(k,{name:"sidePanel.resize"})}))),Panel:({store:n})=>e(S,{store:n})};export const DrawSection={name:"draw",Tab:a(n=>e(p,Object.assign({name:l("sidePanel.draw")},n,{children:e(k,{name:"sidePanel.draw"})}))),Panel:({store:n})=>e(h,{store:n})};export const VideosSection={name:"videos",Tab:n=>e(p,Object.assign({name:l("sidePanel.videos")},n,{children:e(k,{name:"sidePanel.videos"})})),Panel:g};export const ImageEditSection={name:"image-edit",Tab:()=>null,Panel:j,visibleInList:!1};export const DEFAULT_SECTIONS=[TemplatesSection,TextSection,PhotosSection,ElementsSection,DrawSection,UploadSection,BackgroundSection,LayersSection,SizeSection,ImageEditSection];const C={name:"image-clip",Tab:()=>null,Panel:v},E={name:"effects",Tab:()=>null,Panel:T},N={name:"animation",Tab:()=>null,Panel:w};export const INTERNAL_SECTIONS=[C,E];const I=new Set([v,T,w]),O=({onClick:o})=>n("div",{className:"pn-side-panel-hide-button pn:absolute pn:right-[-14px] pn:top-1/2 pn:z-10 pn:h-24 pn:w-[15px] pn:cursor-pointer pn:max-md:hidden pn:pn-mobile:hidden",onClick:o,children:[e("svg",{width:"15",height:"96",viewBox:"0 0 16 96",xmlns:"http://www.w3.org/2000/svg",children:e("path",{className:"pn:stroke-border pn:fill-background",d:"M 1 7 C 2 9 4 10 7.2 13.28 C 7.45 13.4625 7.6 13.6 7.7 13.8048 L 7.8 13.8 C 9.8 15.8 11.6 17.6 12.9 19.7 C 14 21.6 14.7 23.9 14.9 27 H 15 V 68 C 15 71.7 14.3 74.3 13 76.6 C 11.7 78.8 9.9 80.5 7.8 82.6344 L 7.79 82.6 C 7.6 82.8 7.4507 83 7.2729 83.2127 C 3.9102 86.5228 2 87 1 90"})}),e("div",{className:"pn:absolute pn:left-1/2 pn:top-1/2 pn:text-[0.5rem] pn:text-muted-foreground pn:hover:text-foreground",style:{transform:"translate(-50%, -50%) scaleY(2)"},children:"<"})]});export const SidePanel=a(({store:a,sections:l,defaultSection:p="photos"})=>{var d,m;(()=>{const e=o.useRef(!0);e.current&&(e.current=!1,a.openSidePanel(p))})();const c=i();o.useLayoutEffect(()=>{c?a.openSidePanel(""):a.openSidePanel(p)},[c]);const b=[...l||DEFAULT_SECTIONS],f=b.find(e=>"image-edit"===e.name),u=!!f;o.useLayoutEffect(()=>(a._setImageEditPanelAvailable(u),()=>a._setImageEditPanelAvailable(!1)),[a,u]);const P=o.useRef(p),x=(null==f?void 0:f.Panel)===j,S="expand"===(null===(d=a.activeTool)||void 0===d?void 0:d.name)||"inpaint"===(null===(m=a.activeTool)||void 0===m?void 0:m.name),h=c&&x&&S&&"image-edit"===a.openedSidePanel;if(o.useLayoutEffect(()=>{"image-edit"!==a.openedSidePanel?P.current=a.openedSidePanel:x&&!a.activeTool&&a.openSidePanel("image-edit"===P.current?"":P.current)},[a,a.openedSidePanel,a.activeTool,x]),INTERNAL_SECTIONS.forEach(e=>{b.find(n=>n.name===e.name)||b.push(e)}),t.animationsEnabled){if(!b.find(e=>"videos"===e.name)){const e=Math.floor(b.length/2);b.splice(e,0,VideosSection)}if(!b.find(e=>"animations"===e.name)){const e=Math.floor(b.length/2);b.splice(e,0,N)}}const g=b.filter(e=>{var n;return null===(n=e.visibleInList)||void 0===n||n}),v=e=>{const n=e.target,o=n.closest(".polotno-close-panel"),t=n.closest(".polotno-mobile");o&&(c||t)&&a.openSidePanel("")},w=o.useRef(null),T=o.useRef(null),k=o.useRef(new Set);return a.openedSidePanel&&k.current.add(a.openedSidePanel),e(r,{elementRef:T,children:n("div",{ref:T,className:s("polotno-side-panel pn-side-panel pn:relative pn:flex pn:h-full pn:bg-background pn:p-0 pn:text-foreground","pn:md:border-r pn:md:border-border","pn:max-md:h-auto pn:max-md:w-full pn:pn-mobile:h-auto pn:pn-mobile:w-full","pn:max-md:border-t pn:max-md:border-border pn:pn-mobile:border-t pn:pn-mobile:border-border",h&&"pn:flex-col-reverse",!a.openedSidePanel&&"collapsed"),children:[e("div",{ref:w,className:s("polotno-side-tabs-container pn:bg-background pn:max-md:w-full pn:max-md:overflow-auto pn:pn-mobile:w-full pn:pn-mobile:overflow-auto pn:md:overflow-y-auto pn:md:overflow-x-hidden pn:md:min-w-[72px]",a.openedSidePanel&&"pn:md:border-r pn:md:border-border"),children:e("div",{className:"polotno-side-tabs-inner pn:flex pn:flex-col pn:max-md:flex-row pn:max-md:min-w-min pn:pn-mobile:flex-row pn:pn-mobile:min-w-min",children:g.map(({name:n,Tab:o})=>e(o,{active:n===a.openedSidePanel,onClick:()=>{n===a.openedSidePanel&&c?a.openSidePanel(""):a.openSidePanel(n)}},n))})}),b.map(({name:n,Panel:o})=>k.current.has(n)&&e("div",{className:s("polotno-panel-container pn-side-panel-content pn:h-full pn:px-2",!I.has(o)&&"pn:pt-2.5","pn:w-[var(--pn-sidebar-width,350px)]",!a.openedSidePanel&&"pn:w-0",n!==a.openedSidePanel&&"pn:hidden","pn:max-md:w-full pn:max-md:bg-background pn:pn-mobile:w-full pn:pn-mobile:bg-background",h&&"image-edit"===n?"pn:flex pn:h-auto pn:max-h-[40dvh] pn:shrink-0 pn:flex-col pn:border-b pn:border-border":"pn:max-md:absolute pn:max-md:bottom-[54px] pn:max-md:z-[100] pn:max-md:!h-[50vh] pn:pn-mobile:absolute pn:pn-mobile:bottom-[54px] pn:pn-mobile:z-[100] pn:pn-mobile:!h-[50vh]"),onClick:v,children:e(o,{store:a})},n)),a.openedSidePanel&&c&&!S&&e("div",{className:"polotno-close-panel",style:{position:"absolute",left:0,bottom:"72px",width:"100vw",height:"100vh",zIndex:99,backgroundColor:"rgba(0,0,0,0.05)"},onClick:()=>a.openSidePanel("")}),a.openedSidePanel&&e(O,{onClick:()=>a.openSidePanel("")})]})})});SidePanel.displayName="SidePanel";export default SidePanel;
@@ -1 +1 @@
1
- import*as e from"mobx";import{NO_KEY_MESSAGE as o,NO_VALID_MESSAGE as t,NOT_PAID_MESSAGE as n,NOT_PAID_STYLE as a}from"@polotno/core/validate-key";import{getAPI as i}from"./api.js";import{removeBackgroundState as r}from"./flags.js";const s=e.observable({value:!1}),l=e.observable({value:"v1"});export const ___=()=>l.value;const c=e.observable({value:0});export const ____=()=>c.value;export const isCreditVisible=()=>s.value;const d=e.action(()=>{s.value=!0});let u="";export const getKey=()=>u||"";export const setKey=e=>{u=e||""};let p="undefined"!=typeof window?window.location.origin:"";const v="undefined"!=typeof navigator&&navigator.userAgent.indexOf("Headless")>-1,f="undefined"!=typeof navigator&&navigator.userAgent.indexOf("Electron")>-1;"file://"===p&&v&&(p="headless"),"file://"===p&&f&&(p="electron");const m=`%cPolotno error! Current domain is not allowed. It may lead to unexpected behavior and stop working. Please add "${p}" here: https://polotno.com/cabinet`;let g=fetch;export const __=e=>{g=e};export async function isKeyPaid(s){for(let u=0;u<5;u++){try{const d=await g(i()+"/validate-key",{method:"POST",body:JSON.stringify({key:s,sdkVersion:"4.22.0"})});if(e.runInAction(()=>{l.value=d.headers.get("x-api-version")||""}),!s){return console.error(o),e.runInAction(()=>{c.value=1}),!1}if(200!==d.status){await new Promise(e=>setTimeout(e,3e3));continue}const u=await d.json();return u.is_valid||(console.error(t),e.runInAction(()=>{c.value=1})),u.is_paid||(console.log(n,a),e.runInAction(()=>{0===c.value&&(c.value=2)})),u.is_domain_valid||console.log(m,"background: rgba(247, 101, 68, 1); color: white; padding: 5px; margin: 5px;"),e.runInAction(()=>{r.defaultEnabled=u.remove_background_enabled}),u.is_paid||!1}catch(d){await new Promise(e=>setTimeout(e,3e3))}}return console.error("Can not validate Polotno API key. Please report to anton@polotno.com immediately."),!0}export async function validateKey(e){await isKeyPaid(u)&&!e||d()}
1
+ import*as e from"mobx";import{NO_KEY_MESSAGE as o,NO_VALID_MESSAGE as t,NOT_PAID_MESSAGE as n,NOT_PAID_STYLE as a}from"@polotno/core/validate-key";import{getAPI as i}from"./api.js";import{removeBackgroundState as r}from"./flags.js";const s=e.observable({value:!1}),l=e.observable({value:"v1"});export const ___=()=>l.value;const c=e.observable({value:0});export const ____=()=>c.value;export const isCreditVisible=()=>s.value;const d=e.action(()=>{s.value=!0});let u="";export const getKey=()=>u||"";export const setKey=e=>{u=e||""};let p="undefined"!=typeof window?window.location.origin:"";const v="undefined"!=typeof navigator&&navigator.userAgent.indexOf("Headless")>-1,f="undefined"!=typeof navigator&&navigator.userAgent.indexOf("Electron")>-1;"file://"===p&&v&&(p="headless"),"file://"===p&&f&&(p="electron");const m=`%cPolotno error! Current domain is not allowed. It may lead to unexpected behavior and stop working. Please add "${p}" here: https://polotno.com/cabinet`;let g=fetch;export const __=e=>{g=e};export async function isKeyPaid(s){for(let u=0;u<5;u++){try{const d=await g(i()+"/validate-key",{method:"POST",body:JSON.stringify({key:s,sdkVersion:"4.22.1"})});if(e.runInAction(()=>{l.value=d.headers.get("x-api-version")||""}),!s){return console.error(o),e.runInAction(()=>{c.value=1}),!1}if(200!==d.status){await new Promise(e=>setTimeout(e,3e3));continue}const u=await d.json();return u.is_valid||(console.error(t),e.runInAction(()=>{c.value=1})),u.is_paid||(console.log(n,a),e.runInAction(()=>{0===c.value&&(c.value=2)})),u.is_domain_valid||console.log(m,"background: rgba(247, 101, 68, 1); color: white; padding: 5px; margin: 5px;"),e.runInAction(()=>{r.defaultEnabled=u.remove_background_enabled}),u.is_paid||!1}catch(d){await new Promise(e=>setTimeout(e,3e3))}}return console.error("Can not validate Polotno API key. Please report to anton@polotno.com immediately."),!0}export async function validateKey(e){await isKeyPaid(u)&&!e||d()}