OCDevManageRegionDiscountSelector.react",["fbt","GeoSelector.react","GeoSelectorItem.react","OCDevManagePlaceholder.react","OCDevManageRegionDiscountSelectorQuery.graphql","RelayHooks","XOCCountrySpecificPricingTarget.oculus","emptyFunction","react","useOCDevUIQuery"],(function(t,n,r,o,a,i,l,s){"use strict";var e,u,c=u||(u=o("react")),d=u,m=d.useCallback,p=d.useMemo,_=10,f=e!==void 0?e:e=n("OCDevManageRegionDiscountSelectorQuery.graphql");function g(e){var t=e.approvedPricePoints,n=e.currencySymbol,o=e.currentPrice,a=e.isDisabled,i=e.onChange,l=e.savedPriceAmount,u=e.value,d=p(function(){var e;if(l==null||o<=0)return{matchedPriceKey:null,savedDiscountPercent:null};var n=parseFloat(l);if(isNaN(n))return{matchedPriceKey:null,savedDiscountPercent:null};var r=Math.round(n*100),a=o*100,i=Math.round((1-r/a)*100);if(t==null)return{matchedPriceKey:null,savedDiscountPercent:i};var s=t.find(function(e){return e.amount!=null&&e.amount===r});return{matchedPriceKey:(e=s==null?void 0:s.key)!=null?e:null,savedDiscountPercent:i}},[l,t,o]),f=d.matchedPriceKey,g=d.savedDiscountPercent,h=u!=null?u:f,y=p(function(){if(t==null)return[];var e=o*100,n=e*(1-_/100),r=[];for(var a of t){var i=a.amount,l=a.key;i!=null&&l!=null&&i>=99&&i<=n&&r.push({amount:i,key:l})}return r},[t,o]),C=p(function(){var e=Math.round(o*100),n={amount:e,key:"NO_DISCOUNT"},r=u!=null?u:f;if(r==null||r==="")return[n].concat(y);if(r==="NO_DISCOUNT")return[n].concat(y);var a=y.some(function(e){return e.key===r});if(a)return[n].concat(y);if(t!=null){var i=t.find(function(e){return e.key===r});if(i!=null&&i.amount!=null&&i.key!=null)return[n,{amount:i.amount,key:i.key}].concat(y)}return[n].concat(y)},[t,o,y,f,u]),b=m(function(e){var t=o*100;return Math.round((1-e/t)*100)},[o]),v=p(function(){var e={};for(var t of C){var n=t.amount,r=t.key;e[r]=n}return e},[C]),S=m(function(e){var t=v[e];if(t!=null){var r=""+n+(t/100).toFixed(2);i(e,r)}},[n,i,v]);if(t==null)return c.jsx(r("GeoSelector.react"),{isLabelHidden:!0,isLoading:!0,label:s._(/*BTDS*/"Discount u0025"),value:null,onChange:r("emptyFunction"),children:c.jsx(r("GeoSelectorItem.react"),{label:s._(/*BTDS*/"Loading..."),value:null})});if(h==null&&g!=null&&a===!0){var R=parseFloat(l!=null?l:"0"),L=R===Math.floor(R),E=R>=100||L,k=E?R/100:R;return c.jsx(r("GeoSelector.react"),{isDisabled:!0,isLabelHidden:!0,label:s._(/*BTDS*/"Discount u0025"),value:"SAVED_DISCOUNT",onChange:r("emptyFunction"),children:c.jsx(r("GeoSelectorItem.react"),{label:g+"% ("+k.toFixed(2)+")",value:"SAVED_DISCOUNT"},"SAVED_DISCOUNT")})}return c.jsx(r("GeoSelector.react"),{isDisabled:a!=null?a:!1,isLabelHidden:!0,label:s._(/*BTDS*/"Discount u0025"),value:h!=null?h:"",onChange:S,children:C.map(function(e){var t=e.amount,n=e.key;return c.jsx(r("GeoSelectorItem.react"),{label:b(t)+"% ("+(t/100).toFixed(2)+")",value:n},n)})})}g.displayName=g.name+" [from "+i.id+"]";function h(e){var t=e.countryCode,n=r("XOCCountrySpecificPricingTarget.oculus").cast(t),o=r("useOCDevUIQuery")(f,{country:n!=null?n:"US"});return c.jsx(g,babelHelpers.extends({},e,{approvedPricePoints:n!=null?o.xoc_approved_price_points:null}))}h.displayName=h.name+" [from "+i.id+"]";function y(e){return c.jsx(r("OCDevManagePlaceholder.react"),{fallback:c.jsx(g,babelHelpers.extends({},e,{approvedPricePoints:null})),children:c.jsx(h,babelHelpers.extends({},e))})}y.displayName=y.name+" [from "+i.id+"]";function C(){var e=o("RelayHooks").useQueryLoader(f),t=e[1];return m(function(e){var n=r("XOCCountrySpecificPricingTarget.oculus").cast(e);t({country:n!=null?n:"US"})},[t])}l.RegionDiscountSelectorQuery=f,l.useRegionDiscountPrefetch=C,l.OCDevManageRegionDiscountSelectorWrapper=y}),226);
-----
OCDevManageRegionDiscountSelectorQuery.graphql",[],(function(t,n,r,o,a,i){"use strict";var e=(function(){var e=[{defaultValue:null,kind:"LocalArgument",name:"country"}],t=[{alias:null,args:[{kind:"Variable",name:"country",variableName:"country"},{kind:"Literal",name:"force_99_suffix",value:!0}],concreteType:"XOCApprovedPricePoint",kind:"LinkedField",name:"xoc_approved_price_points",plural:!0,selections:[{alias:null,args:null,kind:"ScalarField",name:"amount",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"key",storageKey:null}],storageKey:null}];return{fragment:{argumentDefinitions:e,kind:"Fragment",metadata:null,name:"OCDevManageRegionDiscountSelectorQuery",selections:t,type:"Query",abstractKey:null},kind:"Request",operation:{argumentDefinitions:e,kind:"Operation",name:"OCDevManageRegionDiscountSelectorQuery",selections:t},params:{id:"33581168628163379",metadata:{},name:"OCDevManageRegionDiscountSelectorQuery",operationKind:"query",text:null}}})();a.exports=e}),null);
-----