@planningcenter/url 3.1.0 → 3.2.0-qa-60.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +2 -2
- package/dist/url.js +1 -1
- package/dist/url.js.map +1 -1
- package/dist/url.modern.js +1 -1
- package/dist/url.modern.js.map +1 -1
- package/dist/url.module.js +1 -1
- package/dist/url.module.js.map +1 -1
- package/dist/url.umd.js +1 -1
- package/dist/url.umd.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export type Environment = "production" | "staging" | "development" | "test" | "prototype";
|
|
1
|
+
export type Environment = "production" | "staging" | "testing" | "development" | "test" | "prototype";
|
|
2
2
|
export type Product = "api" | "accounts" | "calendar" | "check-ins" | "giving" | "groups" | "home" | "login" | "people" | "publishing" | "registrations" | "services";
|
|
3
3
|
declare const legacy: (env: Environment) => (productName: Product) => string;
|
|
4
4
|
export default legacy;
|
|
@@ -9,4 +9,4 @@ export declare function pcoApiUrl(product: Product, { env, squiggly, }?: {
|
|
|
9
9
|
env?: Environment;
|
|
10
10
|
squiggly?: boolean;
|
|
11
11
|
}): string;
|
|
12
|
-
export declare const inferEnvironment: () => "production" | "staging" | "development" | "prototype";
|
|
12
|
+
export declare const inferEnvironment: () => "production" | "staging" | "testing" | "development" | "prototype";
|
package/dist/url.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var n=function(n){return function(t){if(n&&t){var c=function(){return"undefined"!=typeof location&&location&&location.protocol&&"https:"===location.protocol?"https":"http"};switch(n){case"production":return"https://"+t+"."+
|
|
1
|
+
var n=function(n){return function(t){if(n&&t){var c=function(){return"undefined"!=typeof location&&location&&location.protocol&&"https:"===location.protocol?"https":"http"};switch(n){case"production":return"https://"+t+"."+i();case"staging":return"https://"+t+"-staging."+i();case"testing":return"https://"+t+"-testing."+i();case"development":var r="test";try{r=location.hostname.match(/\pco\.(\w+)$/)[1]}catch(n){"localhost"!==location.hostname&&console.error(location.hostname+" is not a supported dev TLD")}var a=o(t);return c()+"://"+(a?a+".":"")+t+".pco."+r;case"prototype":return"https://"+e()+"."+t+".planningcenter.ninja";case"test":var s=o(t);return c()+"://"+(s?s+".":"")+t+".pco.test";default:return"http://"+t+"."+i()}}}},t=function(){var n=window.location.origin;return n.endsWith("-testing.planningcenteronline.com")||n.endsWith("/testing.planningcenteronline.com")||n.endsWith(".testing.churchcenter.com")||n.endsWith("/testing.churchcenter.com")?"testing":n.endsWith("-staging.planningcenteronline.com")||n.endsWith("/staging.planningcenteronline.com")||n.endsWith(".staging.churchcenter.com")||n.endsWith("/staging.churchcenter.com")?"staging":n.endsWith(".planningcenteronline.com")||n.endsWith(".churchcenter.com")||n.endsWith("/churchcenter.com")?"production":n.endsWith(".planningcenter.ninja")||n.endsWith(".churchcenter.ninja")?"prototype":n.endsWith("pco.codes")||n.endsWith("pco.dev")||n.endsWith("pco.test")||n.endsWith("churchcenter.test")?"development":"production"},e=function(){var n,t,e=null==(n=location)||null==(t=n.hostname)?void 0:t.match(/(?:www\.)?(.+)\..+\.planningcenter\.ninja/);return e&&"localhost"!==e[1]?e[1]:"main"},o=function(n){var t,e,o=null==(t=location)||null==(e=t.hostname)?void 0:e.match(/^(.+?)\.(.+?)\.pco\.\w+$/);return o&&o[2]===n?o[1]:null},i=function(){var n=location.hostname.match(/planningcenter(online)?.com/);return null===n?"planningcenteronline.com":n[0]};exports.default=n,exports.inferEnvironment=t,exports.pcoApiUrl=function(e,o){var i,c,r=void 0===o?{}:o,a=r.env,s=void 0===a?t():a,l=r.squiggly,h=void 0===l||l,p=h?"/~api":"";return p+="/"+e+"/v2",n(s)(h?(void 0===i&&(i=1),(c=window.location.hostname.split(".").slice(0,-1*(1+i)))["prototype"===t()?c.length-1:0].replace(/-staging$/,"").replace(/-testing$/,"")):"api")+p},exports.pcoUrl=function(e,o){var i=(void 0===o?{}:o).env,c=void 0===i?t():i;return n(c)(e)};
|
|
2
2
|
//# sourceMappingURL=url.js.map
|
package/dist/url.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"url.js","sources":["../index.ts"],"sourcesContent":["export type Environment =\n | \"production\"\n | \"staging\"\n | \"development\"\n | \"test\"\n | \"prototype\"\n\nexport type Product =\n | \"api\"\n | \"accounts\"\n | \"calendar\"\n | \"check-ins\"\n | \"giving\"\n | \"groups\"\n | \"home\"\n | \"login\"\n | \"people\"\n | \"publishing\"\n | \"registrations\"\n | \"services\"\n\nconst legacy = (env: Environment) => (productName: Product) => {\n if (!(env && productName)) return\n\n const getCurrentProtocol = () => {\n if (typeof location !== 'undefined' && location && location.protocol) {\n return location.protocol === 'https:' ? 'https' : 'http'\n }\n return 'http'\n }\n\n switch (env) {\n case \"production\":\n return `https://${productName}.${domain()}`\n case \"staging\":\n return `https://${productName}-staging.${domain()}`\n case \"
|
|
1
|
+
{"version":3,"file":"url.js","sources":["../index.ts"],"sourcesContent":["export type Environment =\n | \"production\"\n | \"staging\"\n | \"testing\"\n | \"development\"\n | \"test\"\n | \"prototype\"\n\nexport type Product =\n | \"api\"\n | \"accounts\"\n | \"calendar\"\n | \"check-ins\"\n | \"giving\"\n | \"groups\"\n | \"home\"\n | \"login\"\n | \"people\"\n | \"publishing\"\n | \"registrations\"\n | \"services\"\n\nconst legacy = (env: Environment) => (productName: Product) => {\n if (!(env && productName)) return\n\n const getCurrentProtocol = () => {\n if (typeof location !== 'undefined' && location && location.protocol) {\n return location.protocol === 'https:' ? 'https' : 'http'\n }\n return 'http'\n }\n\n switch (env) {\n case \"production\":\n return `https://${productName}.${domain()}`\n case \"staging\":\n return `https://${productName}-staging.${domain()}`\n case \"testing\":\n return `https://${productName}-testing.${domain()}`\n case \"development\": {\n let tld = \"test\"\n\n try {\n tld = location.hostname.match(/\\pco\\.(\\w+)$/)[1]\n } catch (error) {\n // don't show warning in Topbar's local dev env\n if (location.hostname !== \"localhost\") {\n console.error(`${location.hostname} is not a supported dev TLD`)\n }\n }\n\n const prefix = worktreeName(productName)\n return `${getCurrentProtocol()}://${prefix ? `${prefix}.` : ''}${productName}.pco.${tld}`\n }\n case \"prototype\":\n return `https://${prototypeEnv()}.${productName}.planningcenter.ninja`\n case \"test\": {\n const prefix = worktreeName(productName)\n return `${getCurrentProtocol()}://${prefix ? `${prefix}.` : ''}${productName}.pco.test`\n }\n default:\n return `http://${productName}.${domain()}`\n }\n}\n\nexport default legacy\n\nexport function pcoUrl(\n product: Product,\n { env = inferEnvironment() }: { env?: Environment } = {},\n) {\n return legacy(env)(product)\n}\n\nexport function pcoApiUrl(\n product: Product,\n {\n env = inferEnvironment(),\n squiggly = true,\n }: { env?: Environment; squiggly?: boolean } = {},\n) {\n let path = squiggly ? \"/~api\" : \"\"\n path += `/${product}/v2`\n\n return legacy(env)(squiggly ? inferProduct() : \"api\") + path\n}\n\nexport const inferEnvironment = () => {\n const origin = window.location.origin\n\n if (origin.endsWith(\"-testing.planningcenteronline.com\")) return \"testing\"\n if (origin.endsWith(\"/testing.planningcenteronline.com\")) return \"testing\"\n if (origin.endsWith(\".testing.churchcenter.com\")) return \"testing\"\n if (origin.endsWith(\"/testing.churchcenter.com\")) return \"testing\"\n if (origin.endsWith(\"-staging.planningcenteronline.com\")) return \"staging\"\n if (origin.endsWith(\"/staging.planningcenteronline.com\")) return \"staging\"\n if (origin.endsWith(\".staging.churchcenter.com\")) return \"staging\"\n if (origin.endsWith(\"/staging.churchcenter.com\")) return \"staging\"\n if (origin.endsWith(\".planningcenteronline.com\")) return \"production\"\n if (origin.endsWith(\".churchcenter.com\")) return \"production\"\n if (origin.endsWith(\"/churchcenter.com\")) return \"production\"\n if (origin.endsWith(\".planningcenter.ninja\")) return \"prototype\"\n if (origin.endsWith(\".churchcenter.ninja\")) return \"prototype\"\n if (origin.endsWith(\"pco.codes\")) return \"development\"\n if (origin.endsWith(\"pco.dev\")) return \"development\"\n if (origin.endsWith(\"pco.test\")) return \"development\"\n if (origin.endsWith(\"churchcenter.test\")) return \"development\"\n\n return \"production\"\n}\n/**\n * If the hostname is a Protonova URL, get the env from the subdomain. Defaults to main.\n * Example: my-cool-change.accounts.planningcenter.ninja -> my-cool-change\n * @returns {string}\n */\nconst prototypeEnv = () => {\n const result = location?.hostname?.match(\n /(?:www\\.)?(.+)\\..+\\.planningcenter\\.ninja/,\n )\n\n if (result && result[1] !== \"localhost\") {\n return result[1]\n }\n\n return \"main\"\n}\n\nconst worktreeName = (productName: string) => {\n const match = location?.hostname?.match(/^(.+?)\\.(.+?)\\.pco\\.\\w+$/)\n if (match && match[2] === productName) return match[1]\n return null\n}\n\nconst domain = () => {\n const result = location.hostname.match(/planningcenter(online)?.com/)\n\n if (result === null) {\n return \"planningcenteronline.com\"\n } else {\n return result[0]\n }\n}\n\nconst extractSubdomainsFrom = (host, tldLength = 1) => {\n return host.split(\".\").slice(0, (1 + tldLength) * -1)\n}\n\nconst inferProduct = () => {\n const subdomains = extractSubdomainsFrom(window.location.hostname)\n\n return subdomains[\n inferEnvironment() === \"prototype\" ? subdomains.length - 1 : 0\n ].replace(/-staging$/, \"\").replace(/-testing$/, \"\")\n}\n"],"names":["legacy","env","productName","getCurrentProtocol","location","protocol","domain","tld","hostname","match","error","console","prefix","worktreeName","prototypeEnv","inferEnvironment","origin","window","endsWith","_location","_location$hostname","result","_location2","_location2$hostname","product","_temp2","tldLength","subdomains","_ref2","squiggly","_ref2$squiggly","path","split","slice","length","replace","pcoUrl","_temp","_ref$env"],"mappings":"AAsBMA,IAAAA,EAAS,SAACC,GAAD,OAAuBC,SAAAA,GACpC,GAAMD,GAAOC,EAAb,CAEA,IAAMC,EAAqB,WACzB,MAAwB,oBAAbC,UAA4BA,UAAYA,SAASC,UAC7B,WAAtBD,SAASC,SAAwB,QAEnC,MACR,EAED,OAAQJ,GACN,IAAK,aACH,MAAkBC,WAAAA,MAAeI,IACnC,IAAK,UACH,MAAkBJ,WAAAA,cAAuBI,IAC3C,IAAK,UACH,MAAk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EAAAe,EAAoBd,MAAM,4BACxC,OAAIA,GAASA,EAAM,KAAOP,EAAoBO,EAAM,GAErD,IAAA,EAEKH,EAAS,WACb,IAAMe,EAASjB,SAASI,SAASC,MAAM,+BAEvC,OAAe,OAAXY,EACK,2BAEAA,EAAO,EAEjB,iEAnEe,SACdG,EAIiDC,GAAA,IAgEdC,EAK7BC,EArE2CC,OAAA,IAAAH,EAAF,GAF7CxB,EAAAA,EAAAA,EAAAA,IAAAA,aAAMc,UACNc,SAAAA,OAAW,IAAAC,KAGTC,EAAOF,EAAW,QAAU,GAGhC,OAFAE,GAAYP,IAAAA,QAELxB,EAAOC,EAAPD,CAAY6B,QA2DiC,IAAjBH,IAAAA,EAAY,IAKzCC,EAAmCV,OAAOb,SAASI,SAJ7CwB,MAAM,KAAKC,MAAM,GAAsB,GAAlB,EAAIP,KAOZ,cAAvBX,IAAqCY,EAAWO,OAAS,EAAI,GAC7DC,QAAQ,YAAa,IAAIA,QAAQ,YAAa,KApED,OAASJ,CACzD,iBAlBeK,SACdZ,KACsD,YAAA,IAAAa,EAAA,CAAA,KAApDpC,IAAAA,OAAMc,IAAAA,EAAAA,IAAgDuB,EAExD,OAAOtC,EAAOC,EAAPD,CAAYwB,EACpB"}
|
package/dist/url.modern.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const n=n=>t=>{if(!n||!t)return;const e=()=>"undefined"!=typeof location&&location&&location.protocol&&"https:"===location.protocol?"https":"http";switch(n){case"production":return`https://${t}.${
|
|
1
|
+
const n=n=>t=>{if(!n||!t)return;const e=()=>"undefined"!=typeof location&&location&&location.protocol&&"https:"===location.protocol?"https":"http";switch(n){case"production":return`https://${t}.${s()}`;case"staging":return`https://${t}-staging.${s()}`;case"testing":return`https://${t}-testing.${s()}`;case"development":{let n="test";try{n=location.hostname.match(/\pco\.(\w+)$/)[1]}catch(n){"localhost"!==location.hostname&&console.error(`${location.hostname} is not a supported dev TLD`)}const o=i(t);return`${e()}://${o?`${o}.`:""}${t}.pco.${n}`}case"prototype":return`https://${c()}.${t}.planningcenter.ninja`;case"test":{const n=i(t);return`${e()}://${n?`${n}.`:""}${t}.pco.test`}default:return`http://${t}.${s()}`}};function t(t,{env:e=o()}={}){return n(e)(t)}function e(t,{env:e=o(),squiggly:c=!0}={}){let i=c?"/~api":"";return i+=`/${t}/v2`,n(e)(c?r():"api")+i}const o=()=>{const n=window.location.origin;return n.endsWith("-testing.planningcenteronline.com")||n.endsWith("/testing.planningcenteronline.com")||n.endsWith(".testing.churchcenter.com")||n.endsWith("/testing.churchcenter.com")?"testing":n.endsWith("-staging.planningcenteronline.com")||n.endsWith("/staging.planningcenteronline.com")||n.endsWith(".staging.churchcenter.com")||n.endsWith("/staging.churchcenter.com")?"staging":n.endsWith(".planningcenteronline.com")||n.endsWith(".churchcenter.com")||n.endsWith("/churchcenter.com")?"production":n.endsWith(".planningcenter.ninja")||n.endsWith(".churchcenter.ninja")?"prototype":n.endsWith("pco.codes")||n.endsWith("pco.dev")||n.endsWith("pco.test")||n.endsWith("churchcenter.test")?"development":"production"},c=()=>{var n,t;const e=null==(n=location)||null==(t=n.hostname)?void 0:t.match(/(?:www\.)?(.+)\..+\.planningcenter\.ninja/);return e&&"localhost"!==e[1]?e[1]:"main"},i=n=>{var t,e;const o=null==(t=location)||null==(e=t.hostname)?void 0:e.match(/^(.+?)\.(.+?)\.pco\.\w+$/);return o&&o[2]===n?o[1]:null},s=()=>{const n=location.hostname.match(/planningcenter(online)?.com/);return null===n?"planningcenteronline.com":n[0]},r=()=>{const n=((n,t=1)=>window.location.hostname.split(".").slice(0,-1*(1+t)))();return n["prototype"===o()?n.length-1:0].replace(/-staging$/,"").replace(/-testing$/,"")};export{n as default,o as inferEnvironment,e as pcoApiUrl,t as pcoUrl};
|
|
2
2
|
//# sourceMappingURL=url.modern.js.map
|
package/dist/url.modern.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"url.modern.js","sources":["../index.ts"],"sourcesContent":["export type Environment =\n | \"production\"\n | \"staging\"\n | \"development\"\n | \"test\"\n | \"prototype\"\n\nexport type Product =\n | \"api\"\n | \"accounts\"\n | \"calendar\"\n | \"check-ins\"\n | \"giving\"\n | \"groups\"\n | \"home\"\n | \"login\"\n | \"people\"\n | \"publishing\"\n | \"registrations\"\n | \"services\"\n\nconst legacy = (env: Environment) => (productName: Product) => {\n if (!(env && productName)) return\n\n const getCurrentProtocol = () => {\n if (typeof location !== 'undefined' && location && location.protocol) {\n return location.protocol === 'https:' ? 'https' : 'http'\n }\n return 'http'\n }\n\n switch (env) {\n case \"production\":\n return `https://${productName}.${domain()}`\n case \"staging\":\n return `https://${productName}-staging.${domain()}`\n case \"
|
|
1
|
+
{"version":3,"file":"url.modern.js","sources":["../index.ts"],"sourcesContent":["export type Environment =\n | \"production\"\n | \"staging\"\n | \"testing\"\n | \"development\"\n | \"test\"\n | \"prototype\"\n\nexport type Product =\n | \"api\"\n | \"accounts\"\n | \"calendar\"\n | \"check-ins\"\n | \"giving\"\n | \"groups\"\n | \"home\"\n | \"login\"\n | \"people\"\n | \"publishing\"\n | \"registrations\"\n | \"services\"\n\nconst legacy = (env: Environment) => (productName: Product) => {\n if (!(env && productName)) return\n\n const getCurrentProtocol = () => {\n if (typeof location !== 'undefined' && location && location.protocol) {\n return location.protocol === 'https:' ? 'https' : 'http'\n }\n return 'http'\n }\n\n switch (env) {\n case \"production\":\n return `https://${productName}.${domain()}`\n case \"staging\":\n return `https://${productName}-staging.${domain()}`\n case \"testing\":\n return `https://${productName}-testing.${domain()}`\n case \"development\": {\n let tld = \"test\"\n\n try {\n tld = location.hostname.match(/\\pco\\.(\\w+)$/)[1]\n } catch (error) {\n // don't show warning in Topbar's local dev env\n if (location.hostname !== \"localhost\") {\n console.error(`${location.hostname} is not a supported dev TLD`)\n }\n }\n\n const prefix = worktreeName(productName)\n return `${getCurrentProtocol()}://${prefix ? `${prefix}.` : ''}${productName}.pco.${tld}`\n }\n case \"prototype\":\n return `https://${prototypeEnv()}.${productName}.planningcenter.ninja`\n case \"test\": {\n const prefix = worktreeName(productName)\n return `${getCurrentProtocol()}://${prefix ? `${prefix}.` : ''}${productName}.pco.test`\n }\n default:\n return `http://${productName}.${domain()}`\n }\n}\n\nexport default legacy\n\nexport function pcoUrl(\n product: Product,\n { env = inferEnvironment() }: { env?: Environment } = {},\n) {\n return legacy(env)(product)\n}\n\nexport function pcoApiUrl(\n product: Product,\n {\n env = inferEnvironment(),\n squiggly = true,\n }: { env?: Environment; squiggly?: boolean } = {},\n) {\n let path = squiggly ? \"/~api\" : \"\"\n path += `/${product}/v2`\n\n return legacy(env)(squiggly ? inferProduct() : \"api\") + path\n}\n\nexport const inferEnvironment = () => {\n const origin = window.location.origin\n\n if (origin.endsWith(\"-testing.planningcenteronline.com\")) return \"testing\"\n if (origin.endsWith(\"/testing.planningcenteronline.com\")) return \"testing\"\n if (origin.endsWith(\".testing.churchcenter.com\")) return \"testing\"\n if (origin.endsWith(\"/testing.churchcenter.com\")) return \"testing\"\n if (origin.endsWith(\"-staging.planningcenteronline.com\")) return \"staging\"\n if (origin.endsWith(\"/staging.planningcenteronline.com\")) return \"staging\"\n if (origin.endsWith(\".staging.churchcenter.com\")) return \"staging\"\n if (origin.endsWith(\"/staging.churchcenter.com\")) return \"staging\"\n if (origin.endsWith(\".planningcenteronline.com\")) return \"production\"\n if (origin.endsWith(\".churchcenter.com\")) return \"production\"\n if (origin.endsWith(\"/churchcenter.com\")) return \"production\"\n if (origin.endsWith(\".planningcenter.ninja\")) return \"prototype\"\n if (origin.endsWith(\".churchcenter.ninja\")) return \"prototype\"\n if (origin.endsWith(\"pco.codes\")) return \"development\"\n if (origin.endsWith(\"pco.dev\")) return \"development\"\n if (origin.endsWith(\"pco.test\")) return \"development\"\n if (origin.endsWith(\"churchcenter.test\")) return \"development\"\n\n return \"production\"\n}\n/**\n * If the hostname is a Protonova URL, get the env from the subdomain. Defaults to main.\n * Example: my-cool-change.accounts.planningcenter.ninja -> my-cool-change\n * @returns {string}\n */\nconst prototypeEnv = () => {\n const result = location?.hostname?.match(\n /(?:www\\.)?(.+)\\..+\\.planningcenter\\.ninja/,\n )\n\n if (result && result[1] !== \"localhost\") {\n return result[1]\n }\n\n return \"main\"\n}\n\nconst worktreeName = (productName: string) => {\n const match = location?.hostname?.match(/^(.+?)\\.(.+?)\\.pco\\.\\w+$/)\n if (match && match[2] === productName) return match[1]\n return null\n}\n\nconst domain = () => {\n const result = location.hostname.match(/planningcenter(online)?.com/)\n\n if (result === null) {\n return \"planningcenteronline.com\"\n } else {\n return result[0]\n }\n}\n\nconst extractSubdomainsFrom = (host, tldLength = 1) => {\n return host.split(\".\").slice(0, (1 + tldLength) * -1)\n}\n\nconst inferProduct = () => {\n const subdomains = extractSubdomainsFrom(window.location.hostname)\n\n return subdomains[\n inferEnvironment() === \"prototype\" ? subdomains.length - 1 : 0\n ].replace(/-staging$/, \"\").replace(/-testing$/, \"\")\n}\n"],"names":["legacy","env","productName","getCurrentProtocol","location","protocol","domain","tld","hostname","match","error","console","prefix","worktreeName","prototypeEnv","pcoUrl","product","inferEnvironment","pcoApiUrl","squiggly","path","inferProduct","origin","window","endsWith","_location","_location$hostname","result","_location2","_location2$hostname","subdomains","host","tldLength","split","slice","extractSubdomainsFrom","length","replace"],"mappings":"AAsBMA,MAAAA,EAAUC,GAAsBC,IACpC,IAAMD,IAAOC,EAAc,OAE3B,MAAMC,EAAqB,IACD,oBAAbC,UAA4BA,UAAYA,SAASC,UAC7B,WAAtBD,SAASC,SAAwB,QAEnC,OAGT,OAAQJ,GACN,IAAK,aACH,iBAAkBC,KAAeI,MACnC,IAAK,UACH,iBAAkBJ,aAAuBI,MAC3C,IAAK,UACH,iBAAkBJ,aAAuBI,MAC3C,IAAK,cAAe,CAClB,IAAIC,EAAM,OAEV,IACEA,EAAMH,SAASI,SAASC,MAAM,gBAAgB,EAM/C,CALC,MAAOC,GAEmB,cAAtBN,SAASI,UACXG,QAAQD,MAAM,GAAGN,SAASI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,EAAAC,EAAA,MAAMpB,EAAK,SAAGL,WAAH,OAAAyB,EAAGD,EAAUpB,eAAb,EAAGqB,EAAoBpB,MAAM,4BACxC,OAAIA,GAASA,EAAM,KAAOP,EAAoBO,EAAM,GAC7C,MAGHH,EAAS,KACb,MAAMqB,EAASvB,SAASI,SAASC,MAAM,+BAEvC,OAAe,OAAXkB,EACK,2BAEAA,EAAO,EACf,EAOGN,EAAe,KACnB,MAAMS,EALsB,EAACC,EAAMC,EAAY,IAKNT,OAAOnB,SAASI,SAJ7CyB,MAAM,KAAKC,MAAM,GAAsB,GAAlB,EAAIF,IAIlBG,GAEnB,OAAOL,EACkB,cAAvBb,IAAqCa,EAAWM,OAAS,EAAI,GAC7DC,QAAQ,YAAa,IAAIA,QAAQ,YAAa,GAFzC"}
|
package/dist/url.module.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var n=function(n){return function(t){if(n&&t){var e=function(){return"undefined"!=typeof location&&location&&location.protocol&&"https:"===location.protocol?"https":"http"};switch(n){case"production":return"https://"+t+"."+
|
|
1
|
+
var n=function(n){return function(t){if(n&&t){var e=function(){return"undefined"!=typeof location&&location&&location.protocol&&"https:"===location.protocol?"https":"http"};switch(n){case"production":return"https://"+t+"."+r();case"staging":return"https://"+t+"-staging."+r();case"testing":return"https://"+t+"-testing."+r();case"development":var o="test";try{o=location.hostname.match(/\pco\.(\w+)$/)[1]}catch(n){"localhost"!==location.hostname&&console.error(location.hostname+" is not a supported dev TLD")}var a=i(t);return e()+"://"+(a?a+".":"")+t+".pco."+o;case"prototype":return"https://"+c()+"."+t+".planningcenter.ninja";case"test":var s=i(t);return e()+"://"+(s?s+".":"")+t+".pco.test";default:return"http://"+t+"."+r()}}}};function t(t,e){var c=(void 0===e?{}:e).env,i=void 0===c?o():c;return n(i)(t)}function e(t,e){var c=void 0===e?{}:e,i=c.env,r=void 0===i?o():i,s=c.squiggly,l=void 0===s||s,h=l?"/~api":"";return h+="/"+t+"/v2",n(r)(l?a():"api")+h}var o=function(){var n=window.location.origin;return n.endsWith("-testing.planningcenteronline.com")||n.endsWith("/testing.planningcenteronline.com")||n.endsWith(".testing.churchcenter.com")||n.endsWith("/testing.churchcenter.com")?"testing":n.endsWith("-staging.planningcenteronline.com")||n.endsWith("/staging.planningcenteronline.com")||n.endsWith(".staging.churchcenter.com")||n.endsWith("/staging.churchcenter.com")?"staging":n.endsWith(".planningcenteronline.com")||n.endsWith(".churchcenter.com")||n.endsWith("/churchcenter.com")?"production":n.endsWith(".planningcenter.ninja")||n.endsWith(".churchcenter.ninja")?"prototype":n.endsWith("pco.codes")||n.endsWith("pco.dev")||n.endsWith("pco.test")||n.endsWith("churchcenter.test")?"development":"production"},c=function(){var n,t,e=null==(n=location)||null==(t=n.hostname)?void 0:t.match(/(?:www\.)?(.+)\..+\.planningcenter\.ninja/);return e&&"localhost"!==e[1]?e[1]:"main"},i=function(n){var t,e,o=null==(t=location)||null==(e=t.hostname)?void 0:e.match(/^(.+?)\.(.+?)\.pco\.\w+$/);return o&&o[2]===n?o[1]:null},r=function(){var n=location.hostname.match(/planningcenter(online)?.com/);return null===n?"planningcenteronline.com":n[0]},a=function(){var n,t=(void 0===n&&(n=1),window.location.hostname.split(".").slice(0,-1*(1+n)));return t["prototype"===o()?t.length-1:0].replace(/-staging$/,"").replace(/-testing$/,"")};export{n as default,o as inferEnvironment,e as pcoApiUrl,t as pcoUrl};
|
|
2
2
|
//# sourceMappingURL=url.module.js.map
|
package/dist/url.module.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"url.module.js","sources":["../index.ts"],"sourcesContent":["export type Environment =\n | \"production\"\n | \"staging\"\n | \"development\"\n | \"test\"\n | \"prototype\"\n\nexport type Product =\n | \"api\"\n | \"accounts\"\n | \"calendar\"\n | \"check-ins\"\n | \"giving\"\n | \"groups\"\n | \"home\"\n | \"login\"\n | \"people\"\n | \"publishing\"\n | \"registrations\"\n | \"services\"\n\nconst legacy = (env: Environment) => (productName: Product) => {\n if (!(env && productName)) return\n\n const getCurrentProtocol = () => {\n if (typeof location !== 'undefined' && location && location.protocol) {\n return location.protocol === 'https:' ? 'https' : 'http'\n }\n return 'http'\n }\n\n switch (env) {\n case \"production\":\n return `https://${productName}.${domain()}`\n case \"staging\":\n return `https://${productName}-staging.${domain()}`\n case \"
|
|
1
|
+
{"version":3,"file":"url.module.js","sources":["../index.ts"],"sourcesContent":["export type Environment =\n | \"production\"\n | \"staging\"\n | \"testing\"\n | \"development\"\n | \"test\"\n | \"prototype\"\n\nexport type Product =\n | \"api\"\n | \"accounts\"\n | \"calendar\"\n | \"check-ins\"\n | \"giving\"\n | \"groups\"\n | \"home\"\n | \"login\"\n | \"people\"\n | \"publishing\"\n | \"registrations\"\n | \"services\"\n\nconst legacy = (env: Environment) => (productName: Product) => {\n if (!(env && productName)) return\n\n const getCurrentProtocol = () => {\n if (typeof location !== 'undefined' && location && location.protocol) {\n return location.protocol === 'https:' ? 'https' : 'http'\n }\n return 'http'\n }\n\n switch (env) {\n case \"production\":\n return `https://${productName}.${domain()}`\n case \"staging\":\n return `https://${productName}-staging.${domain()}`\n case \"testing\":\n return `https://${productName}-testing.${domain()}`\n case \"development\": {\n let tld = \"test\"\n\n try {\n tld = location.hostname.match(/\\pco\\.(\\w+)$/)[1]\n } catch (error) {\n // don't show warning in Topbar's local dev env\n if (location.hostname !== \"localhost\") {\n console.error(`${location.hostname} is not a supported dev TLD`)\n }\n }\n\n const prefix = worktreeName(productName)\n return `${getCurrentProtocol()}://${prefix ? `${prefix}.` : ''}${productName}.pco.${tld}`\n }\n case \"prototype\":\n return `https://${prototypeEnv()}.${productName}.planningcenter.ninja`\n case \"test\": {\n const prefix = worktreeName(productName)\n return `${getCurrentProtocol()}://${prefix ? `${prefix}.` : ''}${productName}.pco.test`\n }\n default:\n return `http://${productName}.${domain()}`\n }\n}\n\nexport default legacy\n\nexport function pcoUrl(\n product: Product,\n { env = inferEnvironment() }: { env?: Environment } = {},\n) {\n return legacy(env)(product)\n}\n\nexport function pcoApiUrl(\n product: Product,\n {\n env = inferEnvironment(),\n squiggly = true,\n }: { env?: Environment; squiggly?: boolean } = {},\n) {\n let path = squiggly ? \"/~api\" : \"\"\n path += `/${product}/v2`\n\n return legacy(env)(squiggly ? inferProduct() : \"api\") + path\n}\n\nexport const inferEnvironment = () => {\n const origin = window.location.origin\n\n if (origin.endsWith(\"-testing.planningcenteronline.com\")) return \"testing\"\n if (origin.endsWith(\"/testing.planningcenteronline.com\")) return \"testing\"\n if (origin.endsWith(\".testing.churchcenter.com\")) return \"testing\"\n if (origin.endsWith(\"/testing.churchcenter.com\")) return \"testing\"\n if (origin.endsWith(\"-staging.planningcenteronline.com\")) return \"staging\"\n if (origin.endsWith(\"/staging.planningcenteronline.com\")) return \"staging\"\n if (origin.endsWith(\".staging.churchcenter.com\")) return \"staging\"\n if (origin.endsWith(\"/staging.churchcenter.com\")) return \"staging\"\n if (origin.endsWith(\".planningcenteronline.com\")) return \"production\"\n if (origin.endsWith(\".churchcenter.com\")) return \"production\"\n if (origin.endsWith(\"/churchcenter.com\")) return \"production\"\n if (origin.endsWith(\".planningcenter.ninja\")) return \"prototype\"\n if (origin.endsWith(\".churchcenter.ninja\")) return \"prototype\"\n if (origin.endsWith(\"pco.codes\")) return \"development\"\n if (origin.endsWith(\"pco.dev\")) return \"development\"\n if (origin.endsWith(\"pco.test\")) return \"development\"\n if (origin.endsWith(\"churchcenter.test\")) return \"development\"\n\n return \"production\"\n}\n/**\n * If the hostname is a Protonova URL, get the env from the subdomain. Defaults to main.\n * Example: my-cool-change.accounts.planningcenter.ninja -> my-cool-change\n * @returns {string}\n */\nconst prototypeEnv = () => {\n const result = location?.hostname?.match(\n /(?:www\\.)?(.+)\\..+\\.planningcenter\\.ninja/,\n )\n\n if (result && result[1] !== \"localhost\") {\n return result[1]\n }\n\n return \"main\"\n}\n\nconst worktreeName = (productName: string) => {\n const match = location?.hostname?.match(/^(.+?)\\.(.+?)\\.pco\\.\\w+$/)\n if (match && match[2] === productName) return match[1]\n return null\n}\n\nconst domain = () => {\n const result = location.hostname.match(/planningcenter(online)?.com/)\n\n if (result === null) {\n return \"planningcenteronline.com\"\n } else {\n return result[0]\n }\n}\n\nconst extractSubdomainsFrom = (host, tldLength = 1) => {\n return host.split(\".\").slice(0, (1 + tldLength) * -1)\n}\n\nconst inferProduct = () => {\n const subdomains = extractSubdomainsFrom(window.location.hostname)\n\n return subdomains[\n inferEnvironment() === \"prototype\" ? subdomains.length - 1 : 0\n ].replace(/-staging$/, \"\").replace(/-testing$/, \"\")\n}\n"],"names":["legacy","env","productName","getCurrentProtocol","location","protocol","domain","tld","hostname","match","error","console","prefix","worktreeName","prototypeEnv","pcoUrl","product","_temp","inferEnvironment","_ref$env","pcoApiUrl","_temp2","_ref2","squiggly","_ref2$squiggly","path","inferProduct","origin","window","endsWith","_location","_location$hostname","result","_location2","_location2$hostname","tldLength","subdomains","split","slice","length","replace"],"mappings":"AAsBMA,IAAAA,EAAS,SAACC,GAAD,OAAuBC,SAAAA,GACpC,GAAMD,GAAOC,EAAb,CAEA,IAAMC,EAAqB,WACzB,MAAwB,oBAAbC,UAA4BA,UAAYA,SAASC,UAC7B,WAAtBD,SAASC,SAAwB,QAEnC,MACR,EAED,OAAQJ,GACN,IAAK,aACH,MAAkBC,WAAAA,MAAeI,IACnC,IAAK,UACH,MAAkBJ,WAAAA,cAAuBI,IAC3C,IAAK,UACH,MAAkBJ,WAAAA,cAAuBI,IAC3C,IAAK,cACH,IAAIC,EAAM,OAEV,IACEA,EAAMH,SAASI,SAASC,MAAM,gBAAgB,EAM/C,CALC,MAAOC,GAEmB,cAAtBN,SAASI,UACXG,QAAQD,MAASN,SAASI,SAA1B,8BAEH,CAED,IAAMI,EAASC,EAAaX,GAC5B,OAAUC,IAA0BS,OAAAA,EAAYA,EAAN,IAAkB,IAAKV,EAAmBK,QAAAA,EAEtF,IAAK,YACH,MAAkBO,WAAAA,IAAkBZ,IAAAA,0BACtC,IAAK,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AAMzB,EAAQ,OAAHwB,EAAG7B,WAAA,OAAA8B,EAAAD,EAAUzB,eAAV,EAAA0B,EAAoBzB,MAAM,4BACxC,OAAIA,GAASA,EAAM,KAAOP,EAAoBO,EAAM,GAErD,IAAA,EAEKH,EAAS,WACb,IAAM0B,EAAS5B,SAASI,SAASC,MAAM,+BAEvC,OAAe,OAAXuB,EACK,2BAEAA,EAAO,EAEjB,EAMKN,EAAe,WACnB,IALmCS,EAK7BC,QAL8C,IAAjBD,IAAAA,EAAY,GAKNP,OAAOxB,SAASI,SAJ7C6B,MAAM,KAAKC,MAAM,GAAsB,GAAlB,EAAIH,KAMrC,OAAOC,EACkB,cAAvBlB,IAAqCkB,EAAWG,OAAS,EAAI,GAC7DC,QAAQ,YAAa,IAAIA,QAAQ,YAAa,GACjD"}
|
package/dist/url.umd.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
!function(n,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t(((n||self).PLANNINGCENTER=n.PLANNINGCENTER||{},n.PLANNINGCENTER.url={}))}(this,function(n){var t=function(n){return function(t){if(n&&t){var e=function(){return"undefined"!=typeof location&&location&&location.protocol&&"https:"===location.protocol?"https":"http"};switch(n){case"production":return"https://"+t+"."+
|
|
1
|
+
!function(n,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t(((n||self).PLANNINGCENTER=n.PLANNINGCENTER||{},n.PLANNINGCENTER.url={}))}(this,function(n){var t=function(n){return function(t){if(n&&t){var e=function(){return"undefined"!=typeof location&&location&&location.protocol&&"https:"===location.protocol?"https":"http"};switch(n){case"production":return"https://"+t+"."+c();case"staging":return"https://"+t+"-staging."+c();case"testing":return"https://"+t+"-testing."+c();case"development":var r="test";try{r=location.hostname.match(/\pco\.(\w+)$/)[1]}catch(n){"localhost"!==location.hostname&&console.error(location.hostname+" is not a supported dev TLD")}var a=i(t);return e()+"://"+(a?a+".":"")+t+".pco."+r;case"prototype":return"https://"+o()+"."+t+".planningcenter.ninja";case"test":var s=i(t);return e()+"://"+(s?s+".":"")+t+".pco.test";default:return"http://"+t+"."+c()}}}},e=function(){var n=window.location.origin;return n.endsWith("-testing.planningcenteronline.com")||n.endsWith("/testing.planningcenteronline.com")||n.endsWith(".testing.churchcenter.com")||n.endsWith("/testing.churchcenter.com")?"testing":n.endsWith("-staging.planningcenteronline.com")||n.endsWith("/staging.planningcenteronline.com")||n.endsWith(".staging.churchcenter.com")||n.endsWith("/staging.churchcenter.com")?"staging":n.endsWith(".planningcenteronline.com")||n.endsWith(".churchcenter.com")||n.endsWith("/churchcenter.com")?"production":n.endsWith(".planningcenter.ninja")||n.endsWith(".churchcenter.ninja")?"prototype":n.endsWith("pco.codes")||n.endsWith("pco.dev")||n.endsWith("pco.test")||n.endsWith("churchcenter.test")?"development":"production"},o=function(){var n,t,e=null==(n=location)||null==(t=n.hostname)?void 0:t.match(/(?:www\.)?(.+)\..+\.planningcenter\.ninja/);return e&&"localhost"!==e[1]?e[1]:"main"},i=function(n){var t,e,o=null==(t=location)||null==(e=t.hostname)?void 0:e.match(/^(.+?)\.(.+?)\.pco\.\w+$/);return o&&o[2]===n?o[1]:null},c=function(){var n=location.hostname.match(/planningcenter(online)?.com/);return null===n?"planningcenteronline.com":n[0]};n.default=t,n.inferEnvironment=e,n.pcoApiUrl=function(n,o){var i,c,r=void 0===o?{}:o,a=r.env,s=void 0===a?e():a,l=r.squiggly,h=void 0===l||l,p=h?"/~api":"";return p+="/"+n+"/v2",t(s)(h?(void 0===i&&(i=1),(c=window.location.hostname.split(".").slice(0,-1*(1+i)))["prototype"===e()?c.length-1:0].replace(/-staging$/,"").replace(/-testing$/,"")):"api")+p},n.pcoUrl=function(n,o){var i=(void 0===o?{}:o).env,c=void 0===i?e():i;return t(c)(n)}});
|
|
2
2
|
//# sourceMappingURL=url.umd.js.map
|
package/dist/url.umd.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"url.umd.js","sources":["../index.ts"],"sourcesContent":["export type Environment =\n | \"production\"\n | \"staging\"\n | \"development\"\n | \"test\"\n | \"prototype\"\n\nexport type Product =\n | \"api\"\n | \"accounts\"\n | \"calendar\"\n | \"check-ins\"\n | \"giving\"\n | \"groups\"\n | \"home\"\n | \"login\"\n | \"people\"\n | \"publishing\"\n | \"registrations\"\n | \"services\"\n\nconst legacy = (env: Environment) => (productName: Product) => {\n if (!(env && productName)) return\n\n const getCurrentProtocol = () => {\n if (typeof location !== 'undefined' && location && location.protocol) {\n return location.protocol === 'https:' ? 'https' : 'http'\n }\n return 'http'\n }\n\n switch (env) {\n case \"production\":\n return `https://${productName}.${domain()}`\n case \"staging\":\n return `https://${productName}-staging.${domain()}`\n case \"
|
|
1
|
+
{"version":3,"file":"url.umd.js","sources":["../index.ts"],"sourcesContent":["export type Environment =\n | \"production\"\n | \"staging\"\n | \"testing\"\n | \"development\"\n | \"test\"\n | \"prototype\"\n\nexport type Product =\n | \"api\"\n | \"accounts\"\n | \"calendar\"\n | \"check-ins\"\n | \"giving\"\n | \"groups\"\n | \"home\"\n | \"login\"\n | \"people\"\n | \"publishing\"\n | \"registrations\"\n | \"services\"\n\nconst legacy = (env: Environment) => (productName: Product) => {\n if (!(env && productName)) return\n\n const getCurrentProtocol = () => {\n if (typeof location !== 'undefined' && location && location.protocol) {\n return location.protocol === 'https:' ? 'https' : 'http'\n }\n return 'http'\n }\n\n switch (env) {\n case \"production\":\n return `https://${productName}.${domain()}`\n case \"staging\":\n return `https://${productName}-staging.${domain()}`\n case \"testing\":\n return `https://${productName}-testing.${domain()}`\n case \"development\": {\n let tld = \"test\"\n\n try {\n tld = location.hostname.match(/\\pco\\.(\\w+)$/)[1]\n } catch (error) {\n // don't show warning in Topbar's local dev env\n if (location.hostname !== \"localhost\") {\n console.error(`${location.hostname} is not a supported dev TLD`)\n }\n }\n\n const prefix = worktreeName(productName)\n return `${getCurrentProtocol()}://${prefix ? `${prefix}.` : ''}${productName}.pco.${tld}`\n }\n case \"prototype\":\n return `https://${prototypeEnv()}.${productName}.planningcenter.ninja`\n case \"test\": {\n const prefix = worktreeName(productName)\n return `${getCurrentProtocol()}://${prefix ? `${prefix}.` : ''}${productName}.pco.test`\n }\n default:\n return `http://${productName}.${domain()}`\n }\n}\n\nexport default legacy\n\nexport function pcoUrl(\n product: Product,\n { env = inferEnvironment() }: { env?: Environment } = {},\n) {\n return legacy(env)(product)\n}\n\nexport function pcoApiUrl(\n product: Product,\n {\n env = inferEnvironment(),\n squiggly = true,\n }: { env?: Environment; squiggly?: boolean } = {},\n) {\n let path = squiggly ? \"/~api\" : \"\"\n path += `/${product}/v2`\n\n return legacy(env)(squiggly ? inferProduct() : \"api\") + path\n}\n\nexport const inferEnvironment = () => {\n const origin = window.location.origin\n\n if (origin.endsWith(\"-testing.planningcenteronline.com\")) return \"testing\"\n if (origin.endsWith(\"/testing.planningcenteronline.com\")) return \"testing\"\n if (origin.endsWith(\".testing.churchcenter.com\")) return \"testing\"\n if (origin.endsWith(\"/testing.churchcenter.com\")) return \"testing\"\n if (origin.endsWith(\"-staging.planningcenteronline.com\")) return \"staging\"\n if (origin.endsWith(\"/staging.planningcenteronline.com\")) return \"staging\"\n if (origin.endsWith(\".staging.churchcenter.com\")) return \"staging\"\n if (origin.endsWith(\"/staging.churchcenter.com\")) return \"staging\"\n if (origin.endsWith(\".planningcenteronline.com\")) return \"production\"\n if (origin.endsWith(\".churchcenter.com\")) return \"production\"\n if (origin.endsWith(\"/churchcenter.com\")) return \"production\"\n if (origin.endsWith(\".planningcenter.ninja\")) return \"prototype\"\n if (origin.endsWith(\".churchcenter.ninja\")) return \"prototype\"\n if (origin.endsWith(\"pco.codes\")) return \"development\"\n if (origin.endsWith(\"pco.dev\")) return \"development\"\n if (origin.endsWith(\"pco.test\")) return \"development\"\n if (origin.endsWith(\"churchcenter.test\")) return \"development\"\n\n return \"production\"\n}\n/**\n * If the hostname is a Protonova URL, get the env from the subdomain. Defaults to main.\n * Example: my-cool-change.accounts.planningcenter.ninja -> my-cool-change\n * @returns {string}\n */\nconst prototypeEnv = () => {\n const result = location?.hostname?.match(\n /(?:www\\.)?(.+)\\..+\\.planningcenter\\.ninja/,\n )\n\n if (result && result[1] !== \"localhost\") {\n return result[1]\n }\n\n return \"main\"\n}\n\nconst worktreeName = (productName: string) => {\n const match = location?.hostname?.match(/^(.+?)\\.(.+?)\\.pco\\.\\w+$/)\n if (match && match[2] === productName) return match[1]\n return null\n}\n\nconst domain = () => {\n const result = location.hostname.match(/planningcenter(online)?.com/)\n\n if (result === null) {\n return \"planningcenteronline.com\"\n } else {\n return result[0]\n }\n}\n\nconst extractSubdomainsFrom = (host, tldLength = 1) => {\n return host.split(\".\").slice(0, (1 + tldLength) * -1)\n}\n\nconst inferProduct = () => {\n const subdomains = extractSubdomainsFrom(window.location.hostname)\n\n return subdomains[\n inferEnvironment() === \"prototype\" ? subdomains.length - 1 : 0\n ].replace(/-staging$/, \"\").replace(/-testing$/, \"\")\n}\n"],"names":["legacy","env","productName","getCurrentProtocol","location","protocol","domain","tld","hostname","match","error","console","prefix","worktreeName","prototypeEnv","inferEnvironment","origin","window","endsWith","_location","_location$hostname","result","_location2","_location2$hostname","product","_temp2","tldLength","subdomains","_ref2","squiggly","_ref2$squiggly","path","split","slice","length","replace","pcoUrl","_temp","_ref$env"],"mappings":"oRAsBMA,IAAAA,EAAS,SAACC,GAAD,OAAuBC,SAAAA,GACpC,GAAMD,GAAOC,EAAb,CAEA,IAAMC,EAAqB,WACzB,MAAwB,oBAAbC,UAA4BA,UAAYA,SAASC,UAC7B,WAAtBD,SAASC,SAAwB,QAEnC,MACR,EAED,OAAQJ,GACN,IAAK,aACH,MAAkBC,WAAAA,MAAeI,IACnC,IAAK,UACH,MAAkBJ,WAAAA,cAAuBI,IAC3C,IAAK,UACH,MAAkBJ,WAAAA,cAAuBI,IAC3C,IAAK,cACH,IAAIC,EAAM,OAEV,IACEA,EAAMH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