import{a as X,c as Z,d as tt}from"./chunk-OBCB7GVX.js";import{j as K}from"./chunk-6U74XUQG.js";import{$e as R,Ab as V,Aq as n,Bb as F,Bq as Q,K as x,La as D,Pd as q,Rb as w,Sb as y,Ta as A,Ua as U,Vb as N,Vf as W,Xa as S,Yf as $,a as h,b as g,dc as L,fb as B,gb as I,gu as v,ha as a,ia as O,jc as k,ka as d,kl as J,ku as z,l as b,lb as E,lu as p,na as P,nc as H,oa as j,ob as M,qb as l,rc as Y,t as c,ta as u,tv as G,u as T,ua as m,za as _}from"./chunk-J36AVOW5.js";var et=(()=>{let t=class t{constructor(o){this.shopifyStateService=o}interceptNavigate(o,e){return this.shopifyStateService.selectParameters().pipe(x(1),c(r=>r?{commands:o,extras:g(h({},e),{queryParams:h(h({},e?.queryParams),r)})}:{commands:o,extras:e}))}};t.\u0275fac=function(e){return new(e||t)(d(v))},t.\u0275prov=a({token:t,factory:t.\u0275fac});let i=t;return i})();var ot=(()=>{let t=class t{constructor(o){this.shopifyService=o}canActivate(o,e){return this.shopifyService.storeShopifyParametersIfPresent(o.queryParams),this.shopifyService.initialise(),!0}canActivateChild(o,e){return this.canActivate(o,e)}};t.\u0275fac=function(e){return new(e||t)(d(p))},t.\u0275prov=a({token:t,factory:t.\u0275fac});let i=t;return i})();var st={[n.ApprovalNotification]:!1,[n.OpenBin]:!1,[n.UploadToShopifyButton]:!0,[n.DownloadAssetButton]:!1,[n.ApproveAssetButton]:!1,[n.AssetEmbeddableLinkButton]:!1,[n.AssetCollectionButton]:!1,[n.ShareAssetButton]:!1,[n.AssetMoreActionsButton]:!1,[n.EditAssetsButton]:!1,[n.DeleteAssetsButton]:!1,[n.ShareAssetsButton]:!1,[n.AssetsCollectionButton]:!1,[n.DownloadAssetsButton]:!1},at={[n.ApprovalNotification]:!0,[n.OpenBin]:!0,[n.UploadToShopifyButton]:!1,[n.DownloadAssetButton]:!1,[n.ApproveAssetButton]:!0,[n.AssetEmbeddableLinkButton]:!0,[n.AssetCollectionButton]:!0,[n.ShareAssetButton]:!0,[n.AssetMoreActionsButton]:!0,[n.EditAssetsButton]:!0,[n.DeleteAssetsButton]:!0,[n.ShareAssetsButton]:!0,[n.AssetsCollectionButton]:!0,[n.DownloadAssetsButton]:!0},it=(()=>{let t=class t{constructor(o){this.shopifyService=o}overrideElementVisibility(o){return T([this.shopifyService.isInShopify(),this.shopifyService.canUploadImage()]).pipe(c(([e,r])=>{if(e)return r?st[o]:at[o]}))}};t.\u0275fac=function(e){return new(e||t)(d(p))},t.\u0275prov=a({token:t,factory:t.\u0275fac});let i=t;return i})();function pt(i,t){if(i&1){let s=E();B(0,"dash-download-button-presentation",2),w(1,"async"),M("downloadAssets",function(e){u(s);let r=l();return m(r.sendToShopify(e))})("preparingDownload",function(e){u(s);let r=l();return m(r.preparingDownload.next(e))})("opened",function(){u(s);let e=l();return m(e.dropdownOpened())})("closed",function(){u(s);let e=l();return m(e.dropdownClosed())}),I()}if(i&2){let s=l(),o=V(3);S("appSource",s.appSource)("assetDownloadData",s.assetDownloadData)("downloadButtonTemplate",o)("showPresetControls",!1)("downloadIsDisabled",y(1,5,s.preparingDownload))}}function dt(i,t){if(i&1&&(B(0,"platform-button",3),w(1,"async"),F(2," Upload to Shopify "),I()),i&2){let s=l();S("inverted",!0)("fullwidth",!0)("isLoading",y(1,4,s.preparingDownload)),U("aria-expanded",s.isOpen)}}var Pt=(()=>{let t=class t{constructor(o,e){this.shopifyService=o,this.messagingService=e,this.finished=new _,this.downloaded=new _,this.preparingDownload=new b(!1),this.isOpen=!1}dropdownOpened(){this.isOpen=!0}dropdownClosed(){this.isOpen=!1}canUploadImage(){return this.shopifyService.canUploadImage()}sendToShopify({dimensions:o,presetParameterOverrides:e,downloadAnalyticsData:r}){this.shopifyService.sendToShopify({assets:this.assetDownloadData,dimensions:o,presetParameterOverrides:e,downloadAnalyticsData:r}).subscribe({error:()=>{this.messagingService.showError("We couldn't upload your assets to Shopify. Refresh the page and try again, or get in touch if it still doesn't work."),this.endDownloadFailed()},complete:()=>this.endDownloadSuccessful()})}endDownloadSuccessful(){this.finished.emit(),this.downloaded.emit(),this.preparingDownload.next(!1)}endDownloadFailed(){this.finished.emit(),this.preparingDownload.next(!1)}};t.\u0275fac=function(e){return new(e||t)(D(p),D(J))},t.\u0275cmp=P({type:t,selectors:[["dash-send-to-shopify-button"]],inputs:{appSource:"appSource",assetDownloadData:"assetDownloadData"},outputs:{finished:"finished",downloaded:"downloaded"},decls:4,vars:3,consts:[["downloadButtonTemplate",""],[3,"appSource","assetDownloadData","downloadButtonTemplate","showPresetControls","downloadIsDisabled","downloadAssets","preparingDownload","opened","closed",4,"ngIf"],[3,"downloadAssets","preparingDownload","opened","closed","appSource","assetDownloadData","downloadButtonTemplate","showPresetControls","downloadIsDisabled"],["buttonId","uploadToShopifyButton","intercomId","Upload to Shopify","element","label","icon","upload","type","pill",1,"DOWNLOAD",3,"inverted","fullwidth","isLoading"]],template:function(e,r){e&1&&(A(0,pt,2,7,"dash-download-button-presentation",1),w(1,"async"),A(2,dt,3,6,"ng-template",null,0,N)),e&2&&S("ngIf",y(1,1,r.canUploadImage()))},dependencies:[L,q,X,k],encapsulation:2,changeDetection:0});let i=t;return i})();var lt={CropAndDownload:"Crop & upload to Shopify",CustomDownload:"Upload to Shopify"},nt=(()=>{let t=class t{constructor(o){this.shopifyService=o}overrideCopy(o){return this.shopifyService.isInShopifyAndCanUploadImage().pipe(c(e=>{if(e)return lt[o]}))}};t.\u0275fac=function(e){return new(e||t)(d(p))},t.\u0275prov=a({token:t,factory:t.\u0275fac});let i=t;return i})();var rt=(()=>{let t=class t{constructor(){}canActivate(o,e){let r=new Y({fromObject:o.queryParams}).toString();return window.location.href=`${$}/shopify/callback?${r}`,!1}canActivateChild(o,e){return this.canActivate(o,e)}};t.\u0275fac=function(e){return new(e||t)},t.\u0275prov=a({token:t,factory:t.\u0275fac});let i=t;return i})();var ne=(()=>{let t=class t{static forRoot(){return{ngModule:t,providers:[p]}}};t.\u0275fac=function(e){return new(e||t)},t.\u0275mod=j({type:t}),t.\u0275inj=O({providers:[ot,rt,v,z,{provide:W,useClass:et,multi:!0},{provide:Q,useClass:it,multi:!0},{provide:K,useClass:nt,multi:!0}],imports:[H,R,tt,G,Z]});let i=t;return i})();export{ot as a,rt as b,Pt as c,ne as d};
